@sanity/vision 6.20.0-next.58 → 6.20.0-next.63

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.
@@ -1,28 +1,29 @@
1
- import { t as visionLocaleNamespace } from "./i18n-t8J2mRUI.js";
2
- import { Component, Fragment, Suspense, use, useEffect, useImperativeHandle, useRef, useState } from "react";
1
+ import { t as visionLocaleNamespace } from "./i18n-JS8KzGj8.js";
2
+ import { Component, Fragment, Suspense, createContext, lazy, use, useEffect, useImperativeHandle, useRef, useState, useSyncExternalStore } from "react";
3
3
  import { ContextMenuButton, RELEASES_STUDIO_CLIENT_OPTIONS, Translate, UserAvatar, VARIANTS_STUDIO_CLIENT_OPTIONS, getDefaultVariant, getReleaseIdFromReleaseDocumentId, getVariantTitle, isCardinalityOneRelease, sortReleases, useActiveReleases, useClient, useCurrentUser, useDataset, useDateTimeFormat, useKeyValueStore, usePerspective, useScheduledDraftsEnabled, useTranslation, useWorkspace } from "sanity";
4
4
  import { IntentLink } from "sanity/router";
5
5
  import { c } from "react/compiler-runtime";
6
- import { Box, Container, Flex, Grid, VStack } from "ui5";
7
- import { Badge, Button, Card, Dialog, Heading, Hotkeys, Inline, Label, Select, Spinner, Tab, TabList, Text, TextInput, rem, useClickOutsideEvent, useTheme, useTheme_v2 } from "@sanity/ui";
8
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
6
  import { SplitPane } from "@rexxars/react-split-pane";
10
7
  import { ChevronLeftIcon } from "@sanity/icons/ChevronLeft";
11
8
  import { ChevronRightIcon } from "@sanity/icons/ChevronRight";
9
+ import { Badge, Button, Card, Dialog, Heading, Hotkeys, Inline, Label, Select, Spinner, Stack, Tab, TabList, Text, TextInput, rem, useClickOutsideEvent, useTheme, useTheme_v2 } from "@sanity/ui";
12
10
  import { useToast } from "@sanity/ui/toast";
13
11
  import { isHotkey } from "is-hotkey-esm";
12
+ import { Box, Container, Flex, Grid, VStack } from "ui5";
14
13
  import { useEffectEvent } from "use-effect-event";
15
14
  import { closeBrackets } from "@codemirror/autocomplete";
16
15
  import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
17
16
  import { javascriptLanguage } from "@codemirror/lang-javascript";
18
- import { HighlightStyle, bracketMatching, defaultHighlightStyle, indentOnInput, syntaxHighlighting } from "@codemirror/language";
17
+ import { HighlightStyle, bracketMatching, defaultHighlightStyle, foldGutter, indentOnInput, syntaxHighlighting } from "@codemirror/language";
19
18
  import { highlightSelectionMatches } from "@codemirror/search";
19
+ import { EditorState } from "@codemirror/state";
20
20
  import { EditorView, drawSelection, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, keymap, lineNumbers } from "@codemirror/view";
21
21
  import { groq } from "@sanity/lezer-groq";
22
- import CodeMirror, { EditorSelection } from "@uiw/react-codemirror";
22
+ import CodeMirror, { EditorSelection as EditorSelection$1 } from "@uiw/react-codemirror";
23
23
  import { assignInlineVars } from "@vanilla-extract/dynamic";
24
24
  import { tags } from "@lezer/highlight";
25
25
  import { hues } from "@sanity/color";
26
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
26
27
  import { ErrorOutlineIcon } from "@sanity/icons/ErrorOutline";
27
28
  import { Tooltip } from "@sanity/ui/tooltip";
28
29
  import debounce from "lodash-es/debounce.js";
@@ -37,8 +38,8 @@ import { Code } from "@sanity/ui/code";
37
38
  import { Menu, MenuButton, MenuItem } from "@sanity/ui/menu";
38
39
  import { dequal } from "dequal/lite";
39
40
  import { uuid } from "@sanity/uuid";
40
- import { map, startWith } from "rxjs/operators";
41
41
  import { PlayIcon } from "@sanity/icons/Play";
42
+ import { RocketIcon } from "@sanity/icons/Rocket";
42
43
  import { StopIcon } from "@sanity/icons/Stop";
43
44
  import { CopyIcon } from "@sanity/icons/Copy";
44
45
  import { HelpCircleIcon } from "@sanity/icons/HelpCircle";
@@ -50,7 +51,18 @@ import { LinkIcon } from "@sanity/icons/Link";
50
51
  import LRU from "quick-lru";
51
52
  import { DocumentSheetIcon } from "@sanity/icons/DocumentSheet";
52
53
  import { useObservablePromise } from "react-rx";
53
- import { catchError, map as map$1, of } from "rxjs";
54
+ import { catchError, map, of } from "rxjs";
55
+ var __defProp = Object.defineProperty, __exportAll = (all, no_symbols) => {
56
+ let target = {};
57
+ for (var name in all) __defProp(target, name, {
58
+ get: all[name],
59
+ enumerable: !0
60
+ });
61
+ return no_symbols || __defProp(target, Symbol.toStringTag, { value: "Module" }), target;
62
+ };
63
+ function prefixApiVersion(version) {
64
+ return version[0] !== "v" && version !== "other" ? `v${version}` : version;
65
+ }
54
66
  const API_VERSIONS = [
55
67
  "v1",
56
68
  "vX",
@@ -59,20 +71,7 @@ const API_VERSIONS = [
59
71
  "v2022-03-07",
60
72
  "v2025-02-19",
61
73
  `v${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}`
62
- ], [DEFAULT_API_VERSION] = API_VERSIONS.slice(-1);
63
- function DelayedSpinner(props) {
64
- let $ = c(5), [show, setShow] = useState(!1), t0, t1;
65
- $[0] === props.delay ? (t0 = $[1], t1 = $[2]) : (t0 = () => {
66
- let timer = setTimeout(() => setShow(!0), props.delay || 500);
67
- return () => clearTimeout(timer);
68
- }, t1 = [props.delay], $[0] = props.delay, $[1] = t0, $[2] = t1), useEffect(t0, t1);
69
- let t2;
70
- return $[3] === show ? t2 = $[4] : (t2 = show ? /* @__PURE__ */ jsx(Spinner, {
71
- muted: !0,
72
- size: 4
73
- }) : null, $[3] = show, $[4] = t2), t2;
74
- }
75
- const sharedExtensions = [
74
+ ], [DEFAULT_API_VERSION] = API_VERSIONS.slice(-1), VARIANTS_API_VERSION = prefixApiVersion(VARIANTS_STUDIO_CLIENT_OPTIONS.apiVersion), sharedExtensions = [
76
75
  lineNumbers(),
77
76
  highlightActiveLine(),
78
77
  highlightActiveLineGutter(),
@@ -92,7 +91,12 @@ const sharedExtensions = [
92
91
  ...defaultKeymap,
93
92
  ...historyKeymap
94
93
  ])
95
- ], groqExtensions = [groq(), ...sharedExtensions], paramsExtensions = [javascriptLanguage, ...sharedExtensions];
94
+ ], groqExtensions = [groq(), ...sharedExtensions], paramsExtensions = [javascriptLanguage, ...sharedExtensions], resultJsonExtensions = [
95
+ javascriptLanguage,
96
+ ...sharedExtensions,
97
+ foldGutter(),
98
+ EditorState.readOnly.of(!0)
99
+ ];
96
100
  function useCodemirrorTheme(theme) {
97
101
  let $ = c(7), t0;
98
102
  $[0] === theme ? t0 = $[1] : (t0 = createTheme(theme), $[0] = theme, $[1] = t0);
@@ -121,7 +125,40 @@ function createTheme(theme) {
121
125
  color: card.fg
122
126
  },
123
127
  ".cm-panels.cm-panels-top": { borderBottom: `2px solid ${card.border}` },
124
- ".cm-panels.cm-panels-bottom": { borderTop: `2px solid ${card.border}` }
128
+ ".cm-panels.cm-panels-bottom": { borderTop: `2px solid ${card.border}` },
129
+ ".cm-tooltip": {
130
+ backgroundColor: card.bg,
131
+ color: card.fg,
132
+ border: `1px solid ${card.border}`,
133
+ borderRadius: "3px"
134
+ },
135
+ ".cm-tooltip-lint": {
136
+ fontFamily: fonts.text.family,
137
+ maxWidth: "520px"
138
+ },
139
+ ".cm-panel.cm-panel-lint ul [aria-selected]": { backgroundColor: selection },
140
+ ".cm-panel.cm-panel-lint ul [aria-selected] .cm-diagnostic": { color: card.fg },
141
+ ".cm-vista-function-doc, .cm-vista-extract-button": {
142
+ fontFamily: fonts.text.family,
143
+ fontSize: rem(fonts.text.sizes[1].fontSize)
144
+ },
145
+ ".cm-vista-function-code, .cm-vista-function-doc code": {
146
+ fontFamily: fonts.code.family,
147
+ fontSize: rem(fonts.code.sizes[1].fontSize)
148
+ },
149
+ ".cm-vista-function-note": { color: card.muted.fg },
150
+ ".cm-vista-function-link": { color: card.link.fg },
151
+ ".cm-vista-extract-button:hover, .cm-vista-extract-button:focus-visible": { backgroundColor: selection },
152
+ ".cm-tooltip.cm-tooltip-autocomplete > ul": { fontFamily: fonts.code.family },
153
+ ".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
154
+ backgroundColor: selection,
155
+ color: card.fg
156
+ },
157
+ ".cm-completionDetail": {
158
+ color: card.muted.fg,
159
+ fontStyle: "normal",
160
+ marginLeft: "1em"
161
+ }
125
162
  }, { dark: color.dark });
126
163
  }
127
164
  function createHighlight(theme) {
@@ -225,57 +262,142 @@ function createHighlight(theme) {
225
262
  }
226
263
  ]);
227
264
  }
228
- var contentBorderRightWidthVar = "var(--_1o4e43l1)", contentPaddingTopVar = "var(--_1o4e43l2)", editorRoot = "_1o4e43l3", linePaddingLeftVar = "var(--_1o4e43l0)";
265
+ function insets(element, sides) {
266
+ let style = getComputedStyle(element), total = 0;
267
+ for (let side of sides) total += (parseFloat(style[`padding${side}`]) || 0) + (parseFloat(style[`border${side}Width`]) || 0);
268
+ return total;
269
+ }
270
+ /** How many digits CodeMirror's line-number gutter reserves for a document of `lines` lines: 9, 99, 999, ... */
271
+ function lineNumberDigits(lines) {
272
+ let widest = 9;
273
+ for (; widest < lines;) widest = widest * 10 + 9;
274
+ return String(widest).length;
275
+ }
276
+ let measuredScrollbarWidth;
277
+ /** The width of a classic vertical scrollbar; 0 where scrollbars are overlaid (macOS, phones) */
278
+ function getScrollbarWidth() {
279
+ if (measuredScrollbarWidth === void 0) {
280
+ let probe = document.createElement("div");
281
+ probe.style.cssText = "position:absolute;top:-9999px;left:-9999px;width:100px;height:100px;overflow:scroll;visibility:hidden", document.body.append(probe), measuredScrollbarWidth = Math.max(0, probe.offsetWidth - probe.clientWidth), probe.remove();
282
+ }
283
+ return measuredScrollbarWidth;
284
+ }
285
+ /**
286
+ * How many default-width characters fit on a line of the editor without scrolling sideways: the
287
+ * scroller's visible width less its gutters and the insets around the text (the content's
288
+ * padding and borders, and the line's padding). With `lines`, the width is the one the editor
289
+ * will have once the document has that many lines: a wider line-number gutter, and a vertical
290
+ * scrollbar where the document will no longer fit the editor's height. `undefined` while the
291
+ * editor has no layout, as when it is hidden or has not measured its font yet.
292
+ */
293
+ function getVisibleColumns(view, { lines, scrollbarWidth } = {}) {
294
+ let { scrollDOM, contentDOM, defaultCharacterWidth, defaultLineHeight } = view, gutters = scrollDOM.querySelector(".cm-gutters"), line = contentDOM.querySelector(".cm-line"), currentLines = view.state.doc.lines, nextLines = lines ?? currentLines, gutterGrowth = (lineNumberDigits(nextLines) - lineNumberDigits(currentLines)) * defaultCharacterWidth, willOverflowVertically = nextLines * defaultLineHeight + insets(contentDOM, ["Top", "Bottom"]) > scrollDOM.clientHeight, hasVerticalScrollbar = scrollDOM.scrollHeight > scrollDOM.clientHeight, scrollbarReserve = willOverflowVertically && !hasVerticalScrollbar ? scrollbarWidth ?? getScrollbarWidth() : 0, width = scrollDOM.clientWidth - (gutters instanceof HTMLElement ? gutters.offsetWidth : 0) - gutterGrowth - insets(contentDOM, ["Left", "Right"]) - (line ? insets(line, ["Left", "Right"]) : 0) - scrollbarReserve, columns = Math.floor(width / defaultCharacterWidth);
295
+ return Number.isFinite(columns) && columns > 0 ? columns : void 0;
296
+ }
297
+ var contentBorderRightWidthVar = "var(--okz3su1)", contentPaddingTopVar = "var(--okz3su2)", editorRoot = "okz3su3", editorRootAutoHeight = "okz3su4", linePaddingLeftVar = "var(--okz3su0)";
229
298
  function EditorRoot(t0) {
230
- let $ = c(13), { children } = t0, { sanity } = useTheme(), t1;
231
- $[0] === sanity.space[3] ? t1 = $[1] : (t1 = rem(sanity.space[3]), $[0] = sanity.space[3], $[1] = t1);
232
- let t2 = `${t1}`, t3;
233
- $[2] === sanity.space[4] ? t3 = $[3] : (t3 = rem(sanity.space[4]), $[2] = sanity.space[4], $[3] = t3);
234
- let t4 = `${t3}`, t5;
235
- $[4] === sanity.space[5] ? t5 = $[5] : (t5 = rem(sanity.space[5]), $[4] = sanity.space[5], $[5] = t5);
236
- let t6 = `${t5}`, t7;
237
- $[6] !== t2 || $[7] !== t4 || $[8] !== t6 ? (t7 = assignInlineVars({
238
- [linePaddingLeftVar]: t2,
239
- [contentBorderRightWidthVar]: t4,
240
- [contentPaddingTopVar]: t6
241
- }), $[6] = t2, $[7] = t4, $[8] = t6, $[9] = t7) : t7 = $[9];
242
- let t8;
243
- return $[10] !== children || $[11] !== t7 ? (t8 = /* @__PURE__ */ jsx("div", {
244
- className: editorRoot,
245
- style: t7,
299
+ let $ = c(14), { autoHeight, underHeader, children } = t0, { sanity } = useTheme(), t1 = autoHeight ? `${editorRoot} ${editorRootAutoHeight}` : editorRoot, t2;
300
+ $[0] === sanity.space[3] ? t2 = $[1] : (t2 = rem(sanity.space[3]), $[0] = sanity.space[3], $[1] = t2);
301
+ let t3 = `${t2}`, t4;
302
+ $[2] === sanity.space[4] ? t4 = $[3] : (t4 = rem(sanity.space[4]), $[2] = sanity.space[4], $[3] = t4);
303
+ let t5 = `${t4}`, t6 = sanity.space[underHeader ? 3 : 5], t7;
304
+ $[4] === t6 ? t7 = $[5] : (t7 = rem(t6), $[4] = t6, $[5] = t7);
305
+ let t8 = `${t7}`, t9;
306
+ $[6] !== t3 || $[7] !== t5 || $[8] !== t8 ? (t9 = assignInlineVars({
307
+ [linePaddingLeftVar]: t3,
308
+ [contentBorderRightWidthVar]: t5,
309
+ [contentPaddingTopVar]: t8
310
+ }), $[6] = t3, $[7] = t5, $[8] = t8, $[9] = t9) : t9 = $[9];
311
+ let t10;
312
+ return $[10] !== children || $[11] !== t1 || $[12] !== t9 ? (t10 = /* @__PURE__ */ jsx("div", {
313
+ className: t1,
314
+ style: t9,
246
315
  children
247
- }), $[10] = children, $[11] = t7, $[12] = t8) : t8 = $[12], t8;
316
+ }), $[10] = children, $[11] = t1, $[12] = t9, $[13] = t10) : t10 = $[13], t10;
248
317
  }
249
318
  function VisionCodeMirror(t0) {
250
- let $ = c(10), { ref, onChange, initialValue: initialValueProp, extensions } = t0, [value, setValue] = useState(initialValueProp), t1;
251
- $[0] === onChange ? t1 = $[1] : (t1 = (nextValue, viewUpdate) => {
319
+ let $ = c(21), { ref, onChange, initialValue: initialValueProp, extensions, autoHeight: t1, underHeader: t2 } = t0, autoHeight = t1 !== void 0 && t1, underHeader = t2 === void 0 ? autoHeight : t2, [value, setValue] = useState(initialValueProp), [hasView, setHasView] = useState(!1), [seenInitialValue, setSeenInitialValue] = useState(initialValueProp);
320
+ initialValueProp !== seenInitialValue && (setSeenInitialValue(initialValueProp), hasView || setValue(initialValueProp));
321
+ let t3;
322
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => setHasView(!0), $[0] = t3) : t3 = $[0];
323
+ let handleCreateEditor = t3, t4, t5;
324
+ $[1] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => () => setHasView(!1), t5 = [], $[1] = t4, $[2] = t5) : (t4 = $[1], t5 = $[2]), useEffect(t4, t5);
325
+ let t6;
326
+ $[3] === onChange ? t6 = $[4] : (t6 = (nextValue, viewUpdate) => {
252
327
  setValue(nextValue), onChange?.(nextValue, viewUpdate);
253
- }, $[0] = onChange, $[1] = t1);
254
- let handleChange = t1, theme = useCodemirrorTheme(useTheme()), codeMirrorRef = useRef(null), t2;
255
- $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = (newContent) => {
328
+ }, $[3] = onChange, $[4] = t6);
329
+ let handleChange = t6, theme = useCodemirrorTheme(useTheme()), codeMirrorRef = useRef(null), t7;
330
+ $[5] === Symbol.for("react.memo_cache_sentinel") ? (t7 = (newContent) => {
331
+ setValue(newContent);
256
332
  let editorView = codeMirrorRef.current?.view;
257
333
  if (!editorView) return;
258
334
  let currentDoc = editorView.state.doc.toString();
259
- newContent !== currentDoc && editorView.dispatch({
335
+ newContent !== currentDoc && (editorView.dispatch({
260
336
  changes: {
261
337
  from: 0,
262
338
  to: currentDoc.length,
263
339
  insert: newContent
264
340
  },
265
- selection: EditorSelection.cursor(newContent.length)
341
+ selection: EditorSelection$1.cursor(newContent.length)
342
+ }), editorView.scrollDOM.scrollTop = 0, editorView.scrollDOM.scrollLeft = 0);
343
+ }, $[5] = t7) : t7 = $[5];
344
+ let resetEditorContent = t7, t8;
345
+ $[6] === Symbol.for("react.memo_cache_sentinel") ? (t8 = (changes) => {
346
+ codeMirrorRef.current?.view?.dispatch({
347
+ changes: [...changes],
348
+ userEvent: "input"
266
349
  });
267
- }, $[2] = t2) : t2 = $[2];
268
- let resetEditorContent = t2, t3, t4;
269
- $[3] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => ({ resetEditorContent }), t4 = [resetEditorContent], $[3] = t3, $[4] = t4) : (t3 = $[3], t4 = $[4]), useImperativeHandle(ref, t3, t4);
270
- let t5;
271
- return $[5] !== extensions || $[6] !== handleChange || $[7] !== theme || $[8] !== value ? (t5 = /* @__PURE__ */ jsx(EditorRoot, { children: /* @__PURE__ */ jsx(CodeMirror, {
350
+ }, $[6] = t8) : t8 = $[6];
351
+ let applyChanges = t8, t9;
352
+ $[7] === Symbol.for("react.memo_cache_sentinel") ? (t9 = (command) => {
353
+ let editorView_0 = codeMirrorRef.current?.view;
354
+ return editorView_0 ? command(editorView_0) : !1;
355
+ }, $[7] = t9) : t9 = $[7];
356
+ let runCommand = t9, t10;
357
+ $[8] === Symbol.for("react.memo_cache_sentinel") ? (t10 = (from, to) => {
358
+ let editorView_1 = codeMirrorRef.current?.view;
359
+ if (!editorView_1) return;
360
+ let length = editorView_1.state.doc.length;
361
+ editorView_1.dispatch({
362
+ selection: EditorSelection$1.range(Math.min(from, length), Math.min(to, length)),
363
+ scrollIntoView: !0
364
+ }), editorView_1.focus();
365
+ }, $[8] = t10) : t10 = $[8];
366
+ let selectRange = t10, t11;
367
+ $[9] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (lines) => {
368
+ let editorView_2 = codeMirrorRef.current?.view;
369
+ return editorView_2 ? getVisibleColumns(editorView_2, { lines }) : void 0;
370
+ }, $[9] = t11) : t11 = $[9];
371
+ let getVisibleColumnsOfEditor = t11, t12, t13;
372
+ $[10] === Symbol.for("react.memo_cache_sentinel") ? (t12 = () => ({
373
+ resetEditorContent,
374
+ applyChanges,
375
+ runCommand,
376
+ selectRange,
377
+ getVisibleColumns: getVisibleColumnsOfEditor
378
+ }), t13 = [
379
+ resetEditorContent,
380
+ applyChanges,
381
+ runCommand,
382
+ selectRange,
383
+ getVisibleColumnsOfEditor
384
+ ], $[10] = t12, $[11] = t13) : (t12 = $[10], t13 = $[11]), useImperativeHandle(ref, t12, t13);
385
+ let t14;
386
+ $[12] !== extensions || $[13] !== handleChange || $[14] !== theme || $[15] !== value ? (t14 = /* @__PURE__ */ jsx(CodeMirror, {
272
387
  ref: codeMirrorRef,
273
388
  basicSetup: !1,
274
389
  theme,
275
390
  extensions,
276
391
  value,
277
- onChange: handleChange
278
- }) }), $[5] = extensions, $[6] = handleChange, $[7] = theme, $[8] = value, $[9] = t5) : t5 = $[9], t5;
392
+ onChange: handleChange,
393
+ onCreateEditor: handleCreateEditor
394
+ }), $[12] = extensions, $[13] = handleChange, $[14] = theme, $[15] = value, $[16] = t14) : t14 = $[16];
395
+ let t15;
396
+ return $[17] !== autoHeight || $[18] !== t14 || $[19] !== underHeader ? (t15 = /* @__PURE__ */ jsx(EditorRoot, {
397
+ autoHeight,
398
+ underHeader,
399
+ children: t14
400
+ }), $[17] = autoHeight, $[18] = t14, $[19] = underHeader, $[20] = t15) : t15 = $[20], t15;
279
401
  }
280
402
  const SUPPORTED_PERSPECTIVES = [
281
403
  "pinnedRelease",
@@ -328,15 +450,32 @@ function isVisionPasteTarget(root, event) {
328
450
  function isPlainObject(obj) {
329
451
  return !!obj && typeof obj == "object" && Object.prototype.toString.call(obj) === "[object Object]";
330
452
  }
331
- const hasLocalStorage = supportsLocalStorage(), keyPrefix = "sanityVision:";
453
+ /** Every `localStorage` key Vision writes (classic and redesign alike) starts with this prefix */
454
+ const VISION_STORAGE_KEY_PREFIX = "sanityVision:", hasLocalStorage = supportsLocalStorage(), clearListeners = /* @__PURE__ */ new Set();
455
+ /** The `localStorage` instance when it is available and writable, `undefined` otherwise */
456
+ function getStorage() {
457
+ return hasLocalStorage ? globalThis.localStorage : void 0;
458
+ }
459
+ /** Runs `listener` after `clearLocalStorage`, so in-memory copies of stored values can drop too */
460
+ function onLocalStorageCleared(listener) {
461
+ return clearListeners.add(listener), () => {
462
+ clearListeners.delete(listener);
463
+ };
464
+ }
332
465
  function clearLocalStorage() {
333
- if (hasLocalStorage) for (let i = 0; i < localStorage.length; i++) {
334
- let key = localStorage.key(i);
335
- key?.startsWith(keyPrefix) && localStorage.removeItem(key);
466
+ let storage = getStorage();
467
+ if (storage) {
468
+ let keys = [];
469
+ for (let i = 0; i < storage.length; i++) {
470
+ let key = storage.key(i);
471
+ key?.startsWith("sanityVision:") && keys.push(key);
472
+ }
473
+ keys.forEach((key) => storage.removeItem(key));
336
474
  }
475
+ clearListeners.forEach((listener) => listener());
337
476
  }
338
477
  function getLocalStorage(namespace) {
339
- let storageKey = `${keyPrefix}${namespace}`, loadedState = null;
478
+ let storageKey = `${VISION_STORAGE_KEY_PREFIX}${namespace}`, loadedState = null;
340
479
  return {
341
480
  get,
342
481
  set,
@@ -380,20 +519,74 @@ function supportsLocalStorage() {
380
519
  }
381
520
  function parseApiQueryString(qs) {
382
521
  let params = {}, options = {};
383
- for (let [key, value] of qs.entries()) key[0] === "$" ? params[key.slice(1)] = JSON.parse(value) : key === "perspective" && (options[key] = value);
522
+ for (let [key, value] of qs.entries()) key[0] === "$" ? Object.defineProperty(params, key.slice(1), {
523
+ value: JSON.parse(value),
524
+ enumerable: !0,
525
+ configurable: !0,
526
+ writable: !0
527
+ }) : (key === "perspective" || key === "variant" || key === "resultSourceMap") && (options[key] = value);
384
528
  return {
385
529
  query: qs.get("query") || "",
386
530
  params,
387
531
  options
388
532
  };
389
533
  }
390
- function prefixApiVersion(version) {
391
- return version[0] !== "v" && version !== "other" ? `v${version}` : version;
392
- }
393
534
  function validateApiVersion(apiVersion) {
394
535
  let parseableApiVersion = apiVersion.replace(/^v/, "").trim().toUpperCase();
395
536
  return parseableApiVersion.length > 0 && (parseableApiVersion === "X" || parseableApiVersion === "1" || /^\d{4}-\d{2}-\d{2}$/.test(parseableApiVersion) && !isNaN(Date.parse(parseableApiVersion)));
396
537
  }
538
+ /**
539
+ * Matches Content Lake query and listen URLs on any domain (custom CDN domains included),
540
+ * capturing the API version, the dataset and the query string. Not anchored: the classic tool's
541
+ * paste handler has always picked the URL out of the pasted text with it. `parseQueryUrl` is
542
+ * stricter and takes the whole text to be the URL.
543
+ */
544
+ const SANITY_QUERY_URL = /\/(vX|v1|v\d{4}-\d\d-\d\d)\/.*?(?:query|listen)\/(.*?)\?(.*)/, QUERY_URL_PATHNAME = /^\/(vX|v1|v\d{4}-\d\d-\d\d)\/(?:[^/]+\/)*(?:query|listen)\/([^/]+)\/?$/, API_CDN_HOST = /(?:^|\.)apicdn\.sanity\.(?:io|work)$/;
545
+ /** `<project>.apicdn.sanity.io`, where `useCdn` sends queries */
546
+ function isApiCdnHost(hostname) {
547
+ return API_CDN_HOST.test(hostname);
548
+ }
549
+ /**
550
+ * Parses a Content Lake query (or listen) URL, as pasted from the browser's network tab, into the
551
+ * pieces of a tab. Returns `null` when the text is not such a URL: the whole text has to be one
552
+ * http(s) URL, since a query URL quoted inside other text is not a paste of that URL, and the
553
+ * redesign claims a paste it parses and replaces the tab's query with it.
554
+ */
555
+ function parseQueryUrl(data, datasets) {
556
+ let trimmed = data.trim(), url = parseHttpUrl(trimmed), match = url?.pathname.match(QUERY_URL_PATHNAME);
557
+ if (!url || !match) return null;
558
+ let [, usedApiVersion, usedDataset] = match, parts;
559
+ try {
560
+ parts = parseApiQueryString(url.searchParams);
561
+ } catch {
562
+ return null;
563
+ }
564
+ if (!parts.query) return null;
565
+ let urlPerspective = parts.options.perspective, perspective = urlPerspective && isSupportedPerspective(urlPerspective) && !isVirtualPerspective(urlPerspective) ? urlPerspective : void 0, { resultSourceMap } = parts.options, includeSourceMap = resultSourceMap === "true" || resultSourceMap === "withKeyArraySelector";
566
+ return {
567
+ query: parts.query,
568
+ params: parts.params,
569
+ rawParams: JSON.stringify(parts.params, null, 2),
570
+ dataset: usedDataset,
571
+ isKnownDataset: datasets.includes(usedDataset),
572
+ apiVersion: validateApiVersion(usedApiVersion) ? usedApiVersion : void 0,
573
+ urlPerspective: urlPerspective || void 0,
574
+ perspective,
575
+ hasUnsupportedPerspective: !!urlPerspective && perspective === void 0,
576
+ variant: parts.options.variant || void 0,
577
+ includeSourceMap,
578
+ useCdn: isApiCdnHost(url.hostname),
579
+ url: trimmed
580
+ };
581
+ }
582
+ function parseHttpUrl(text) {
583
+ try {
584
+ let url = new URL(text);
585
+ return url.protocol === "http:" || url.protocol === "https:" ? url : null;
586
+ } catch {
587
+ return null;
588
+ }
589
+ }
397
590
  function tryParseParams(val, t) {
398
591
  try {
399
592
  let parsed = val ? JSON5.parse(val) : {};
@@ -402,7 +595,7 @@ function tryParseParams(val, t) {
402
595
  return err.message = `${t("params.error.params-invalid-json")}:\n\n${err.message.replace("JSON5:", "")}`, err;
403
596
  }
404
597
  }
405
- var controlsContainer = "phmcesm", downloadsCard = "phmcesj", header = "phmces3", inputBackgroundContainer = "phmces7", inputBackgroundContainerLeft = "phmces8", inputContainer = "phmces9", queryCopyLink = "phmces6", queryRecallPaneContainer = "phmces1", queryRecallPaneWrapper = "phmces2", result = "phmcese", resultContainer = "phmcesc", resultContainerInvalid = "phmcesd", resultFooter = "phmcesf", resultInnerContainer = "phmcesb", resultOuterContainer = "phmcesa", root = "phmces0", saveResultLabel = "phmcesl", saveResultSpanGapVar = "var(--phmcesk)", splitpaneContainer = "phmces5", styledLabel = "phmces4", timingsCard = "phmcesg", timingsTextContainer = "phmcesi", timingsTextMinHeightVar = "var(--phmcesh)";
598
+ var controlsContainer = "ch9tvfm", downloadsCard = "ch9tvfj", header = "ch9tvf3", inputBackgroundContainer = "ch9tvf7", inputBackgroundContainerLeft = "ch9tvf8", inputContainer = "ch9tvf9", queryCopyLink = "ch9tvf6", queryRecallPaneContainer = "ch9tvf1", queryRecallPaneWrapper = "ch9tvf2", result = "ch9tvfe", resultContainer = "ch9tvfc", resultContainerInvalid = "ch9tvfd", resultFooter = "ch9tvff", resultInnerContainer = "ch9tvfb", resultOuterContainer = "ch9tvfa", root = "ch9tvf0", saveResultLabel = "ch9tvfl", saveResultSpanGapVar = "var(--ch9tvfk)", splitpaneContainer = "ch9tvf5", styledLabel = "ch9tvf4", timingsCard = "ch9tvfg", timingsTextContainer = "ch9tvfi", timingsTextMinHeightVar = "var(--ch9tvfh)";
406
599
  function Root(t0) {
407
600
  let $ = c(6), props, ref;
408
601
  $[0] === t0 ? (props = $[1], ref = $[2]) : ({ref, ...props} = t0, $[0] = t0, $[1] = props, $[2] = ref);
@@ -627,17 +820,44 @@ const SHARED_QUERY_DOCUMENT_TYPE = "vision.sharedQuery", SHARED_QUERY_LISTEN_OPT
627
820
  includeResult: !0,
628
821
  visibility: "query"
629
822
  }, defaultValue = { queries: [] }, keyValueStoreKey = "studio.vision-tool.saved-queries";
823
+ /** The keys whose entry differs between two lists */
824
+ function changedKeys(before, after) {
825
+ let was = new Map(before.map((query) => [query._key, query])), is = new Map(after.map((query) => [query._key, query]));
826
+ return [.../* @__PURE__ */ new Set([...was.keys(), ...is.keys()])].filter((key) => !dequal(was.get(key), is.get(key)));
827
+ }
828
+ /**
829
+ * Whether `queries` shows every entry the hook's writes touched as the hook last wrote it, or
830
+ * as the store kept it when a write failed. The store's initial read predates the writes and
831
+ * never does, and neither does an echo of a write that failed; an own echo of a write that went
832
+ * through, or another instance's write built on it, does.
833
+ */
834
+ function reflectsOwnWrites(queries, { latest, keys }) {
835
+ let shown = new Map(queries.map((query) => [query._key, query])), wanted = new Map(latest.map((query) => [query._key, query]));
836
+ for (let key of keys) if (!dequal(shown.get(key), wanted.get(key))) return !1;
837
+ return !0;
838
+ }
839
+ /** The error for a failed move whose rollback failed too: the query is now in both lists */
840
+ function moveLeftBothCopies(error, keptCopy) {
841
+ let message = error instanceof Error ? error.message : String(error);
842
+ return Error(`${message} Removing the ${keptCopy} copy made for the move failed as well, so the query is now in both lists; delete the one you do not want.`, { cause: error });
843
+ }
630
844
  function useSavedQueries() {
631
- let $ = c(45), keyValueStore = useKeyValueStore(), t0;
845
+ let $ = c(73), keyValueStore = useKeyValueStore(), t0;
632
846
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { apiVersion: DEFAULT_API_VERSION }, $[0] = t0) : t0 = $[0];
633
847
  let workspaceClient = useClient(t0), currentUser = useCurrentUser(), [value, setValue] = useState(defaultValue), t1;
634
848
  $[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[1] = t1) : t1 = $[1];
635
- let [sharedQueries, setSharedQueries] = useState(t1), [saving, setSaving] = useState(!1), t2;
849
+ let [sharedQueries, setSharedQueries] = useState(t1), [pendingSaves, setPendingSaves] = useState(0), t2;
636
850
  $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[2] = t2) : t2 = $[2];
637
- let [deleting, setDeleting] = useState(t2), [saveQueryError, setSaveQueryError] = useState(), [deleteQueryError, setDeleteQueryError] = useState(), [error, setError] = useState(), t3;
638
- $[3] === keyValueStore ? t3 = $[4] : (t3 = keyValueStore.getKey(keyValueStoreKey), $[3] = keyValueStore, $[4] = t3);
639
- let personalQueries = t3, t4;
640
- $[5] === currentUser?.id ? t4 = $[6] : (t4 = (docs) => {
851
+ let [deleting, setDeleting] = useState(t2), t3;
852
+ $[3] === Symbol.for("react.memo_cache_sentinel") ? (t3 = [], $[3] = t3) : t3 = $[3];
853
+ let [moving, setMoving] = useState(t3), [saveQueryError, setSaveQueryError] = useState(), [deleteQueryError, setDeleteQueryError] = useState(), [error, setError] = useState(), latestQueriesRef = useRef(defaultValue.queries), t4;
854
+ $[4] === Symbol.for("react.memo_cache_sentinel") ? (t4 = Promise.resolve(), $[4] = t4) : t4 = $[4];
855
+ let personalWritesRef = useRef(t4), pendingPersonalWritesRef = useRef(0), ownWritesRef = useRef(null), storeEventsLiveRef = useRef(!1), loadedPersonalQueriesRef = useRef(!1), t5;
856
+ $[5] === Symbol.for("react.memo_cache_sentinel") ? (t5 = /* @__PURE__ */ new Map(), $[5] = t5) : t5 = $[5];
857
+ let movesRef = useRef(t5), t6;
858
+ $[6] === keyValueStore ? t6 = $[7] : (t6 = keyValueStore.getKey(keyValueStoreKey), $[6] = keyValueStore, $[7] = t6);
859
+ let personalQueries = t6, t7;
860
+ $[8] === currentUser?.id ? t7 = $[9] : (t7 = (docs) => {
641
861
  let currentUserId = currentUser?.id;
642
862
  return docs.map((doc) => ({
643
863
  _key: doc._id,
@@ -648,17 +868,30 @@ function useSavedQueries() {
648
868
  title: doc.title,
649
869
  url: doc.url
650
870
  }));
651
- }, $[5] = currentUser?.id, $[6] = t4);
652
- let mapSharedQueries = t4, t5, t6;
653
- $[7] === personalQueries ? (t5 = $[8], t6 = $[9]) : (t5 = () => {
654
- let sub = personalQueries.pipe(startWith(defaultValue), map(_temp$5)).subscribe({
655
- next: setValue,
871
+ }, $[8] = currentUser?.id, $[9] = t7);
872
+ let mapSharedQueries = t7, t8, t9;
873
+ $[10] === personalQueries ? (t8 = $[11], t9 = $[12]) : (t8 = () => {
874
+ storeEventsLiveRef.current = !1;
875
+ let subscribing = !0, sub = personalQueries.subscribe({
876
+ next: (data) => {
877
+ let stored = data || null, ownWrites = ownWritesRef.current;
878
+ if (ownWrites && !storeEventsLiveRef.current) {
879
+ if (!reflectsOwnWrites(stored?.queries ?? defaultValue.queries, ownWrites)) return;
880
+ subscribing || (storeEventsLiveRef.current = !0);
881
+ }
882
+ if (!(pendingPersonalWritesRef.current > 0)) {
883
+ if (storeEventsLiveRef.current && (ownWritesRef.current = null), !stored) {
884
+ if (loadedPersonalQueriesRef.current) return;
885
+ latestQueriesRef.current = defaultValue.queries, setValue(defaultValue);
886
+ } else loadedPersonalQueriesRef.current = !0, latestQueriesRef.current = stored.queries, setValue(stored);
887
+ }
888
+ },
656
889
  error: (err) => setError(err)
657
890
  });
658
- return () => sub?.unsubscribe();
659
- }, t6 = [personalQueries], $[7] = personalQueries, $[8] = t5, $[9] = t6), useEffect(t5, t6);
660
- let t7, t8;
661
- $[10] !== mapSharedQueries || $[11] !== workspaceClient ? (t7 = () => {
891
+ return subscribing = !1, () => sub.unsubscribe();
892
+ }, t9 = [personalQueries], $[10] = personalQueries, $[11] = t8, $[12] = t9), useEffect(t8, t9);
893
+ let t10, t11;
894
+ $[13] !== mapSharedQueries || $[14] !== workspaceClient ? (t10 = () => {
662
895
  let cancelled = !1, fetchSharedQueries = async () => {
663
896
  let nextDocs = await workspaceClient.fetch("*[_type == $sharedQueryType]{\n _id,\n authorId,\n savedAt,\n title,\n url\n} | order(savedAt desc)", { sharedQueryType: SHARED_QUERY_DOCUMENT_TYPE }) || [];
664
897
  cancelled || setSharedQueries(mapSharedQueries(nextDocs));
@@ -679,120 +912,204 @@ function useSavedQueries() {
679
912
  return () => {
680
913
  cancelled = !0, sub_0.unsubscribe();
681
914
  };
682
- }, t8 = [workspaceClient, mapSharedQueries], $[10] = mapSharedQueries, $[11] = workspaceClient, $[12] = t7, $[13] = t8) : (t7 = $[12], t8 = $[13]), useEffect(t7, t8);
683
- let t9;
684
- $[14] !== sharedQueries || $[15] !== value.queries ? (t9 = [...sharedQueries, ...value.queries].sort(_temp2$4), $[14] = sharedQueries, $[15] = value.queries, $[16] = t9) : t9 = $[16];
685
- let queries = t9, t10;
686
- $[17] !== currentUser || $[18] !== keyValueStore || $[19] !== mapSharedQueries || $[20] !== value.queries || $[21] !== workspaceClient ? (t10 = async (query) => {
687
- if (setSaving(!0), setSaveQueryError(void 0), query.shared) {
688
- if (!currentUser?.id) {
689
- let authError = /* @__PURE__ */ Error("No current user found. Unable to save shared query.");
690
- throw setSaveQueryError(authError), setSaving(!1), authError;
691
- }
692
- try {
693
- let createdDoc = await workspaceClient.create({
694
- _type: SHARED_QUERY_DOCUMENT_TYPE,
695
- authorId: currentUser.id,
696
- savedAt: query.savedAt,
697
- title: query.title,
698
- url: query.url
699
- });
700
- setSharedQueries((prev) => [...mapSharedQueries([createdDoc]), ...prev]), setSaving(!1);
701
- return;
702
- } catch (t11) {
703
- let err_3 = t11, saveError = err_3 instanceof Error ? err_3 : Error(String(err_3));
704
- throw setSaveQueryError(saveError), setSaving(!1), saveError;
705
- }
706
- }
915
+ }, t11 = [workspaceClient, mapSharedQueries], $[13] = mapSharedQueries, $[14] = workspaceClient, $[15] = t10, $[16] = t11) : (t10 = $[15], t11 = $[16]), useEffect(t10, t11);
916
+ let t12;
917
+ $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = (task) => {
918
+ pendingPersonalWritesRef.current += 1;
919
+ let run = () => task().finally(() => {
920
+ --pendingPersonalWritesRef.current;
921
+ }), result = personalWritesRef.current.then(run, run);
922
+ return personalWritesRef.current = result.catch(_temp$6), result;
923
+ }, $[17] = t12) : t12 = $[17];
924
+ let enqueuePersonalWrite = t12, t13;
925
+ $[18] === Symbol.for("react.memo_cache_sentinel") ? (t13 = (before, attempted, kept) => {
926
+ let keys = new Set(ownWritesRef.current?.keys);
927
+ for (let key of changedKeys(before, attempted)) keys.add(key);
928
+ ownWritesRef.current = {
929
+ latest: kept,
930
+ keys
931
+ };
932
+ }, $[18] = t13) : t13 = $[18];
933
+ let recordOwnWrite = t13, t14;
934
+ $[19] === keyValueStore ? t14 = $[20] : (t14 = async (queries) => {
935
+ if (await keyValueStore.setKey(keyValueStoreKey, { queries }) === null) throw Error("The saved queries could not be stored.");
936
+ }, $[19] = keyValueStore, $[20] = t14);
937
+ let storePersonalQueries = t14, t15;
938
+ $[21] === storePersonalQueries ? t15 = $[22] : (t15 = (update) => enqueuePersonalWrite(async () => {
939
+ let before_0 = latestQueriesRef.current, next = update(before_0);
940
+ recordOwnWrite(before_0, next, next), latestQueriesRef.current = next, setValue({ queries: next });
707
941
  try {
708
- let newQueries = [{
709
- ...query,
710
- _key: uuid()
711
- }, ...value.queries];
712
- setValue({ queries: newQueries }), await keyValueStore.setKey(keyValueStoreKey, { queries: newQueries });
713
- } catch (t12) {
714
- let err_4 = t12, saveError_0 = err_4 instanceof Error ? err_4 : Error(String(err_4));
715
- throw setSaveQueryError(saveError_0), setSaving(!1), saveError_0;
942
+ await storePersonalQueries(next);
943
+ } catch (t16) {
944
+ let err_3 = t16;
945
+ throw recordOwnWrite(before_0, next, before_0), latestQueriesRef.current = before_0, setValue({ queries: before_0 }), err_3;
716
946
  }
717
- setSaving(!1);
718
- }, $[17] = currentUser, $[18] = keyValueStore, $[19] = mapSharedQueries, $[20] = value.queries, $[21] = workspaceClient, $[22] = t10) : t10 = $[22];
719
- let saveQuery = t10, t11;
720
- $[23] !== currentUser || $[24] !== keyValueStore || $[25] !== mapSharedQueries || $[26] !== value.queries || $[27] !== workspaceClient ? (t11 = async (query_0) => {
721
- if (setSaving(!0), setSaveQueryError(void 0), query_0.shared) {
722
- if (!currentUser?.id || query_0.authorId !== currentUser.id) {
723
- let authError_0 = /* @__PURE__ */ Error("Only the author can update a shared query.");
724
- throw setSaveQueryError(authError_0), setSaving(!1), authError_0;
725
- }
726
- try {
727
- let updatedDoc = await workspaceClient.patch(query_0._key).set({
728
- savedAt: query_0.savedAt,
729
- title: query_0.title,
730
- url: query_0.url
731
- }).commit(), [updatedSharedQuery] = mapSharedQueries([updatedDoc]);
732
- setSharedQueries((prev_0) => prev_0.map((existingQuery) => existingQuery._key === query_0._key ? updatedSharedQuery : existingQuery)), setSaving(!1);
733
- return;
734
- } catch (t12) {
735
- let err_5 = t12, updateError = err_5 instanceof Error ? err_5 : Error(String(err_5));
736
- throw setSaveQueryError(updateError), setSaving(!1), updateError;
737
- }
947
+ return next;
948
+ }), $[21] = storePersonalQueries, $[22] = t15);
949
+ let writePersonalQueries = t15, t16;
950
+ $[23] !== sharedQueries || $[24] !== value.queries ? (t16 = [...sharedQueries, ...value.queries].sort(_temp2$4), $[23] = sharedQueries, $[24] = value.queries, $[25] = t16) : t16 = $[25];
951
+ let queries_0 = t16, t17;
952
+ $[26] === Symbol.for("react.memo_cache_sentinel") ? (t17 = (task_0) => (setPendingSaves(_temp3$3), setSaveQueryError(void 0), task_0().catch((err_4) => {
953
+ let saveError = err_4 instanceof Error ? err_4 : Error(String(err_4));
954
+ throw setSaveQueryError(saveError), saveError;
955
+ }).finally(() => setPendingSaves(_temp4))), $[26] = t17) : t17 = $[26];
956
+ let runSave = t17, t18;
957
+ $[27] !== currentUser || $[28] !== mapSharedQueries || $[29] !== workspaceClient || $[30] !== writePersonalQueries ? (t18 = (query) => runSave(async () => {
958
+ if (query.shared) {
959
+ if (!currentUser?.id) throw Error("No current user found. Unable to save shared query.");
960
+ let createdDoc = await workspaceClient.create({
961
+ _type: SHARED_QUERY_DOCUMENT_TYPE,
962
+ authorId: currentUser.id,
963
+ savedAt: query.savedAt,
964
+ title: query.title,
965
+ url: query.url
966
+ });
967
+ return setSharedQueries((prev) => [...mapSharedQueries([createdDoc]), ...prev]), createdDoc._id;
738
968
  }
969
+ let newQuery = {
970
+ ...query,
971
+ _key: uuid()
972
+ };
973
+ return await writePersonalQueries((queries_1) => [newQuery, ...queries_1]), newQuery._key;
974
+ }), $[27] = currentUser, $[28] = mapSharedQueries, $[29] = workspaceClient, $[30] = writePersonalQueries, $[31] = t18) : t18 = $[31];
975
+ let saveQuery = t18, t19;
976
+ $[32] !== currentUser || $[33] !== mapSharedQueries || $[34] !== workspaceClient || $[35] !== writePersonalQueries ? (t19 = (query_0) => runSave(async () => {
977
+ if (query_0.shared) {
978
+ if (!currentUser?.id || query_0.authorId !== currentUser.id) throw Error("Only the author can update a shared query.");
979
+ let updatedDoc = await workspaceClient.patch(query_0._key).set({
980
+ savedAt: query_0.savedAt,
981
+ title: query_0.title,
982
+ url: query_0.url
983
+ }).commit(), [updatedSharedQuery] = mapSharedQueries([updatedDoc]);
984
+ setSharedQueries((prev_0) => prev_0.map((existingQuery) => existingQuery._key === query_0._key ? updatedSharedQuery : existingQuery));
985
+ } else await writePersonalQueries((queries_2) => queries_2.map((q) => q._key === query_0._key ? {
986
+ ...q,
987
+ ...query_0
988
+ } : q));
989
+ }), $[32] = currentUser, $[33] = mapSharedQueries, $[34] = workspaceClient, $[35] = writePersonalQueries, $[36] = t19) : t19 = $[36];
990
+ let updateQuery = t19, t20;
991
+ $[37] !== currentUser || $[38] !== sharedQueries || $[39] !== workspaceClient ? (t20 = async (key_0) => {
992
+ let sharedQuery = sharedQueries.find((query_1) => query_1._key === key_0 && query_1.shared);
993
+ if (!sharedQuery) throw Error(`No shared query with key "${key_0}"`);
994
+ if (!currentUser?.id || sharedQuery.authorId !== currentUser.id) throw Error("Only the author can delete a shared query.");
995
+ await workspaceClient.delete(key_0), setSharedQueries((prev_1) => prev_1.filter((query_2) => query_2._key !== key_0));
996
+ }, $[37] = currentUser, $[38] = sharedQueries, $[39] = workspaceClient, $[40] = t20) : t20 = $[40];
997
+ let deleteSharedQuery = t20, t21;
998
+ $[41] === writePersonalQueries ? t21 = $[42] : (t21 = async (key_1) => {
999
+ await writePersonalQueries((queries_3) => queries_3.filter((q_0) => q_0._key !== key_1));
1000
+ }, $[41] = writePersonalQueries, $[42] = t21);
1001
+ let deletePersonalQuery = t21, t22;
1002
+ $[43] !== deletePersonalQuery || $[44] !== deleteSharedQuery || $[45] !== sharedQueries ? (t22 = async (key_2) => {
1003
+ setDeleting((prev_2) => [...prev_2, key_2]), setDeleteQueryError(void 0);
739
1004
  try {
740
- let updatedQueries = value.queries.map((q) => q._key === query_0._key ? {
741
- ...q,
742
- ...query_0
743
- } : q);
744
- setValue({ queries: updatedQueries }), await keyValueStore.setKey(keyValueStoreKey, { queries: updatedQueries });
745
- } catch (t13) {
746
- let err_6 = t13, updateError_0 = err_6 instanceof Error ? err_6 : Error(String(err_6));
747
- throw setSaveQueryError(updateError_0), setSaving(!1), updateError_0;
1005
+ sharedQueries.some((query_3) => query_3._key === key_2 && query_3.shared) ? await deleteSharedQuery(key_2) : await deletePersonalQuery(key_2);
1006
+ } catch (t23) {
1007
+ let err_5 = t23;
1008
+ setDeleteQueryError(err_5 instanceof Error ? err_5 : Error(String(err_5)));
748
1009
  }
749
- setSaving(!1);
750
- }, $[23] = currentUser, $[24] = keyValueStore, $[25] = mapSharedQueries, $[26] = value.queries, $[27] = workspaceClient, $[28] = t11) : t11 = $[28];
751
- let updateQuery = t11, t12;
752
- $[29] !== currentUser || $[30] !== keyValueStore || $[31] !== sharedQueries || $[32] !== value.queries || $[33] !== workspaceClient ? (t12 = async (key) => {
753
- setDeleting((prev_1) => [...prev_1, key]), setDeleteQueryError(void 0);
754
- let clearDeleting = () => setDeleting((prev_2) => prev_2.filter((k) => k !== key)), sharedQuery = sharedQueries.find((query_1) => query_1._key === key && query_1.shared);
755
- if (sharedQuery) {
756
- if (!currentUser?.id || sharedQuery.authorId !== currentUser.id) {
757
- setDeleteQueryError(/* @__PURE__ */ Error("Only the author can delete a shared query.")), clearDeleting();
758
- return;
759
- }
1010
+ setDeleting((prev_3) => prev_3.filter((k) => k !== key_2));
1011
+ }, $[43] = deletePersonalQuery, $[44] = deleteSharedQuery, $[45] = sharedQueries, $[46] = t22) : t22 = $[46];
1012
+ let deleteQuery = t22, t23;
1013
+ $[47] === Symbol.for("react.memo_cache_sentinel") ? (t23 = (key_3, move) => {
1014
+ let pending = movesRef.current.get(key_3);
1015
+ if (pending) return pending;
1016
+ let keys_0 = /* @__PURE__ */ new Set([key_3]), alsoMoving = (copyKey) => {
1017
+ let thisMove = movesRef.current.get(key_3);
1018
+ thisMove && movesRef.current.set(copyKey, thisMove), keys_0.add(copyKey), setMoving((prev_4) => [...prev_4, copyKey]);
1019
+ };
1020
+ setMoving((prev_5) => [...prev_5, key_3]);
1021
+ let result_0 = move(alsoMoving).finally(() => {
1022
+ for (let moved of keys_0) movesRef.current.delete(moved);
1023
+ setMoving((prev_6) => prev_6.filter((moved_0) => !keys_0.has(moved_0)));
1024
+ });
1025
+ return movesRef.current.set(key_3, result_0), result_0;
1026
+ }, $[47] = t23) : t23 = $[47];
1027
+ let runMove = t23, t24;
1028
+ $[48] !== deletePersonalQuery || $[49] !== saveQuery || $[50] !== workspaceClient ? (t24 = (key_4) => runMove(key_4, async (alsoMoving_0) => {
1029
+ let query_4 = latestQueriesRef.current.find((q_1) => q_1._key === key_4);
1030
+ if (!query_4) throw Error(`No personal saved query with key "${key_4}"`);
1031
+ let sharedKey = await saveQuery({
1032
+ shared: !0,
1033
+ title: query_4.title,
1034
+ url: query_4.url,
1035
+ savedAt: (/* @__PURE__ */ new Date()).toISOString()
1036
+ });
1037
+ alsoMoving_0(sharedKey);
1038
+ try {
1039
+ await deletePersonalQuery(key_4);
1040
+ } catch (t25) {
1041
+ let err_6 = t25;
760
1042
  try {
761
- await workspaceClient.delete(key), setSharedQueries((prev_3) => prev_3.filter((query_2) => query_2._key !== key));
762
- } catch (t13) {
763
- setDeleteQueryError(t13);
1043
+ await workspaceClient.delete(sharedKey), setSharedQueries((prev_7) => prev_7.filter((q_2) => q_2._key !== sharedKey));
1044
+ } catch {
1045
+ throw moveLeftBothCopies(err_6, "shared");
764
1046
  }
765
- clearDeleting();
766
- } else {
1047
+ throw err_6;
1048
+ }
1049
+ }), $[48] = deletePersonalQuery, $[49] = saveQuery, $[50] = workspaceClient, $[51] = t24) : t24 = $[51];
1050
+ let shareQuery = t24, t25;
1051
+ $[52] !== deletePersonalQuery || $[53] !== deleteSharedQuery || $[54] !== saveQuery || $[55] !== sharedQueries ? (t25 = (key_5) => runMove(key_5, async (alsoMoving_1) => {
1052
+ let query_5 = sharedQueries.find((q_3) => q_3._key === key_5);
1053
+ if (!query_5) throw Error(`No shared query with key "${key_5}"`);
1054
+ let personalKey = await saveQuery({
1055
+ shared: !1,
1056
+ title: query_5.title,
1057
+ url: query_5.url,
1058
+ savedAt: (/* @__PURE__ */ new Date()).toISOString()
1059
+ });
1060
+ alsoMoving_1(personalKey);
1061
+ try {
1062
+ await deleteSharedQuery(key_5);
1063
+ } catch (t26) {
1064
+ let err_7 = t26;
767
1065
  try {
768
- let filteredQueries = value.queries.filter((q_0) => q_0._key !== key);
769
- setValue({ queries: filteredQueries }), await keyValueStore.setKey(keyValueStoreKey, { queries: filteredQueries });
770
- } catch (t14) {
771
- setDeleteQueryError(t14);
1066
+ await deletePersonalQuery(personalKey);
1067
+ } catch {
1068
+ throw moveLeftBothCopies(err_7, "personal");
772
1069
  }
773
- clearDeleting();
1070
+ throw err_7;
1071
+ }
1072
+ }), $[52] = deletePersonalQuery, $[53] = deleteSharedQuery, $[54] = saveQuery, $[55] = sharedQueries, $[56] = t25) : t25 = $[56];
1073
+ let unshareQuery = t25, t26;
1074
+ $[57] === storePersonalQueries ? t26 = $[58] : (t26 = () => enqueuePersonalWrite(async () => {
1075
+ let before_1 = latestQueriesRef.current;
1076
+ recordOwnWrite(before_1, defaultValue.queries, defaultValue.queries);
1077
+ try {
1078
+ await storePersonalQueries(defaultValue.queries);
1079
+ } catch (t27) {
1080
+ let err_8 = t27;
1081
+ throw recordOwnWrite(before_1, defaultValue.queries, before_1), err_8;
774
1082
  }
775
- }, $[29] = currentUser, $[30] = keyValueStore, $[31] = sharedQueries, $[32] = value.queries, $[33] = workspaceClient, $[34] = t12) : t12 = $[34];
776
- let deleteQuery = t12, t13;
777
- return $[35] !== deleteQuery || $[36] !== deleteQueryError || $[37] !== deleting || $[38] !== error || $[39] !== queries || $[40] !== saveQuery || $[41] !== saveQueryError || $[42] !== saving || $[43] !== updateQuery ? (t13 = {
778
- queries,
1083
+ latestQueriesRef.current = defaultValue.queries, setValue(defaultValue);
1084
+ }), $[57] = storePersonalQueries, $[58] = t26);
1085
+ let clearQueries = t26, t27 = pendingSaves > 0, t28;
1086
+ return $[59] !== clearQueries || $[60] !== deleteQuery || $[61] !== deleteQueryError || $[62] !== deleting || $[63] !== error || $[64] !== moving || $[65] !== queries_0 || $[66] !== saveQuery || $[67] !== saveQueryError || $[68] !== shareQuery || $[69] !== t27 || $[70] !== unshareQuery || $[71] !== updateQuery ? (t28 = {
1087
+ queries: queries_0,
779
1088
  saveQuery,
780
1089
  updateQuery,
781
1090
  deleteQuery,
782
- saving,
1091
+ shareQuery,
1092
+ unshareQuery,
1093
+ clearQueries,
1094
+ saving: t27,
783
1095
  deleting,
1096
+ moving,
784
1097
  saveQueryError,
785
1098
  deleteQueryError,
786
1099
  error
787
- }, $[35] = deleteQuery, $[36] = deleteQueryError, $[37] = deleting, $[38] = error, $[39] = queries, $[40] = saveQuery, $[41] = saveQueryError, $[42] = saving, $[43] = updateQuery, $[44] = t13) : t13 = $[44], t13;
1100
+ }, $[59] = clearQueries, $[60] = deleteQuery, $[61] = deleteQueryError, $[62] = deleting, $[63] = error, $[64] = moving, $[65] = queries_0, $[66] = saveQuery, $[67] = saveQueryError, $[68] = shareQuery, $[69] = t27, $[70] = unshareQuery, $[71] = updateQuery, $[72] = t28) : t28 = $[72], t28;
1101
+ }
1102
+ function _temp4(count_0) {
1103
+ return count_0 - 1;
1104
+ }
1105
+ function _temp3$3(count) {
1106
+ return count + 1;
788
1107
  }
789
1108
  function _temp2$4(a, b) {
790
1109
  return new Date(b.savedAt || 0).getTime() - new Date(a.savedAt || 0).getTime();
791
1110
  }
792
- function _temp$5(data) {
793
- return data || defaultValue;
794
- }
795
- var fixedHeader = "_116oler0", queryList = "_116oler2", scrollContainer = "_116oler1";
1111
+ function _temp$6() {}
1112
+ var fixedHeader = "_17ffm660", queryList = "_17ffm662", scrollContainer = "_17ffm661";
796
1113
  function FixedHeader(props) {
797
1114
  let $ = c(2), t0;
798
1115
  return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(VStack, {
@@ -822,7 +1139,7 @@ function QueryList(props) {
822
1139
  }), $[0] = props, $[1] = t0), t0;
823
1140
  }
824
1141
  function QueryRecall(t0) {
825
- let $ = c(136), { url, getStateFromUrl, setStateFromParsedUrl, currentQuery, currentParams, generateUrl, compactMode: t1 } = t0, compactMode = t1 !== void 0 && t1, toast = useToast(), { saveQuery, updateQuery, queries, deleteQuery, saving } = useSavedQueries(), { t } = useTranslation(visionLocaleNamespace), t2;
1142
+ let $ = c(134), { url, getStateFromUrl, setStateFromParsedUrl, currentQuery, currentParams, generateUrl, compactMode: t1 } = t0, compactMode = t1 !== void 0 && t1, toast = useToast(), { saveQuery, updateQuery, queries, deleteQuery, shareQuery, unshareQuery, saving } = useSavedQueries(), { t } = useTranslation(visionLocaleNamespace), t2;
826
1143
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
827
1144
  month: "short",
828
1145
  day: "numeric",
@@ -880,68 +1197,61 @@ function QueryRecall(t0) {
880
1197
  setShareDialogQuery(query);
881
1198
  }, $[13] = t6) : t6 = $[13];
882
1199
  let handleShareQuery = t6, t7;
883
- $[14] !== deleteQuery || $[15] !== saveQuery || $[16] !== shareDialogQuery || $[17] !== t || $[18] !== toast ? (t7 = async () => {
884
- if (!shareDialogQuery) return;
885
- let sharedQueryKey = shareDialogQuery._key, sharedQueryUrl = shareDialogQuery.url, sharedQueryTitle = shareDialogQuery.title || t("label.untitled-query");
886
- try {
887
- await saveQuery({
888
- shared: !0,
889
- title: sharedQueryTitle,
890
- url: sharedQueryUrl,
891
- savedAt: (/* @__PURE__ */ new Date()).toISOString()
892
- }), await deleteQuery(sharedQueryKey), toast.push({
893
- closable: !0,
894
- status: "success",
895
- title: t("save-query.shared-success")
896
- });
897
- } catch (t8) {
898
- let err_0 = t8;
899
- toast.push({
900
- closable: !0,
901
- status: "error",
902
- title: t("save-query.error"),
903
- description: err_0 instanceof Error ? err_0.message : String(err_0)
904
- });
1200
+ $[14] !== shareDialogQuery || $[15] !== shareQuery || $[16] !== t || $[17] !== toast ? (t7 = async () => {
1201
+ if (shareDialogQuery) {
1202
+ try {
1203
+ await shareQuery(shareDialogQuery._key), toast.push({
1204
+ closable: !0,
1205
+ status: "success",
1206
+ title: t("save-query.shared-success")
1207
+ });
1208
+ } catch (t8) {
1209
+ let err_0 = t8;
1210
+ toast.push({
1211
+ closable: !0,
1212
+ status: "error",
1213
+ title: t("save-query.error"),
1214
+ description: err_0 instanceof Error ? err_0.message : String(err_0)
1215
+ });
1216
+ }
1217
+ setShareDialogQuery(null);
905
1218
  }
906
- setShareDialogQuery(null);
907
- }, $[14] = deleteQuery, $[15] = saveQuery, $[16] = shareDialogQuery, $[17] = t, $[18] = toast, $[19] = t7) : t7 = $[19];
1219
+ }, $[14] = shareDialogQuery, $[15] = shareQuery, $[16] = t, $[17] = toast, $[18] = t7) : t7 = $[18];
908
1220
  let handleConfirmShareQuery = t7, t8;
909
- $[20] !== deleteQuery || $[21] !== formatDate || $[22] !== getStateFromUrl || $[23] !== queries || $[24] !== saveQuery || $[25] !== t || $[26] !== toast ? (t8 = async (query_0) => {
1221
+ $[19] !== formatDate || $[20] !== getStateFromUrl || $[21] !== queries || $[22] !== t || $[23] !== toast || $[24] !== unshareQuery ? (t8 = async (query_0) => {
910
1222
  setPendingUnshareKeys((prev) => [...prev, query_0._key]);
911
1223
  let clearPending = () => setPendingUnshareKeys((prev_0) => prev_0.filter((key) => key !== query_0._key)), nextQueryObj = getStateFromUrl(query_0.url), duplicatePersonalQuery = queries?.find((existingQuery) => {
912
1224
  if (existingQuery._key === query_0._key || existingQuery.shared) return !1;
913
1225
  let existingQueryObj = getStateFromUrl(existingQuery.url);
914
1226
  return nextQueryObj && existingQueryObj && existingQueryObj.query === nextQueryObj.query && dequal(existingQueryObj.params, nextQueryObj.params);
915
- }), unsharedQueryTitle = query_0.title || t("label.untitled-query");
1227
+ });
916
1228
  if (duplicatePersonalQuery) toast.push({
917
1229
  closable: !0,
918
1230
  status: "warning",
919
1231
  title: t("save-query.already-saved"),
920
1232
  description: `${duplicatePersonalQuery.title} - ${formatDate.format(new Date(duplicatePersonalQuery.savedAt || ""))}`
921
1233
  }), clearPending();
922
- else try {
923
- await saveQuery({
924
- shared: !1,
925
- title: unsharedQueryTitle,
926
- url: query_0.url,
927
- savedAt: (/* @__PURE__ */ new Date()).toISOString()
928
- }), await deleteQuery(query_0._key), toast.push({
929
- closable: !0,
930
- status: "success",
931
- title: t("save-query.unshared-success")
932
- }), clearPending();
933
- } catch (t9) {
934
- let err_1 = t9;
935
- toast.push({
936
- closable: !0,
937
- status: "error",
938
- title: t("save-query.error"),
939
- description: err_1 instanceof Error ? err_1.message : String(err_1)
940
- }), clearPending();
1234
+ else {
1235
+ try {
1236
+ await unshareQuery(query_0._key), toast.push({
1237
+ closable: !0,
1238
+ status: "success",
1239
+ title: t("save-query.unshared-success")
1240
+ });
1241
+ } catch (t9) {
1242
+ let err_1 = t9;
1243
+ toast.push({
1244
+ closable: !0,
1245
+ status: "error",
1246
+ title: t("save-query.error"),
1247
+ description: err_1 instanceof Error ? err_1.message : String(err_1)
1248
+ });
1249
+ }
1250
+ clearPending();
941
1251
  }
942
- }, $[20] = deleteQuery, $[21] = formatDate, $[22] = getStateFromUrl, $[23] = queries, $[24] = saveQuery, $[25] = t, $[26] = toast, $[27] = t8) : t8 = $[27];
1252
+ }, $[19] = formatDate, $[20] = getStateFromUrl, $[21] = queries, $[22] = t, $[23] = toast, $[24] = unshareQuery, $[25] = t8) : t8 = $[25];
943
1253
  let handleUnshareQuery = t8, t9;
944
- $[28] !== t || $[29] !== toast || $[30] !== updateQuery ? (t9 = async (query_1, newTitle) => {
1254
+ $[26] !== t || $[27] !== toast || $[28] !== updateQuery ? (t9 = async (query_1, newTitle) => {
945
1255
  setEditingKey(null), setOptimisticTitles((prev_1) => ({
946
1256
  ...prev_1,
947
1257
  [query_1._key]: newTitle
@@ -966,9 +1276,9 @@ function QueryRecall(t0) {
966
1276
  description: err_2.message
967
1277
  });
968
1278
  }
969
- }, $[28] = t, $[29] = toast, $[30] = updateQuery, $[31] = t9) : t9 = $[31];
1279
+ }, $[26] = t, $[27] = toast, $[28] = updateQuery, $[29] = t9) : t9 = $[29];
970
1280
  let handleTitleSave = t9, t10;
971
- $[32] !== currentParams || $[33] !== currentQuery || $[34] !== formatDate || $[35] !== generateUrl || $[36] !== getStateFromUrl || $[37] !== queries || $[38] !== t || $[39] !== toast || $[40] !== updateQuery ? (t10 = async (query_2) => {
1281
+ $[30] !== currentParams || $[31] !== currentQuery || $[32] !== formatDate || $[33] !== generateUrl || $[34] !== getStateFromUrl || $[35] !== queries || $[36] !== t || $[37] !== toast || $[38] !== updateQuery ? (t10 = async (query_2) => {
972
1282
  let newUrl_0 = generateUrl(currentQuery, currentParams);
973
1283
  if (queries?.some((q_1) => {
974
1284
  if (q_1._key === query_2._key) return !1;
@@ -1005,48 +1315,48 @@ function QueryRecall(t0) {
1005
1315
  description: err_3.message
1006
1316
  });
1007
1317
  }
1008
- }, $[32] = currentParams, $[33] = currentQuery, $[34] = formatDate, $[35] = generateUrl, $[36] = getStateFromUrl, $[37] = queries, $[38] = t, $[39] = toast, $[40] = updateQuery, $[41] = t10) : t10 = $[41];
1318
+ }, $[30] = currentParams, $[31] = currentQuery, $[32] = formatDate, $[33] = generateUrl, $[34] = getStateFromUrl, $[35] = queries, $[36] = t, $[37] = toast, $[38] = updateQuery, $[39] = t10) : t10 = $[39];
1009
1319
  let handleUpdate = t10, T0, T1, T2, t11, t12, t13, t14, t15;
1010
- if ($[42] !== compactMode || $[43] !== currentParams || $[44] !== currentQuery || $[45] !== deleteQuery || $[46] !== editingKey || $[47] !== editingTitle || $[48] !== formatDate || $[49] !== getStateFromUrl || $[50] !== handleSave || $[51] !== handleTitleSave || $[52] !== handleUnshareQuery || $[53] !== handleUpdate || $[54] !== optimisticTitles || $[55] !== pendingUnshareKeys || $[56] !== queries || $[57] !== queryFilter || $[58] !== saving || $[59] !== searchQuery || $[60] !== selectedUrl || $[61] !== setStateFromParsedUrl || $[62] !== t) {
1320
+ if ($[40] !== compactMode || $[41] !== currentParams || $[42] !== currentQuery || $[43] !== deleteQuery || $[44] !== editingKey || $[45] !== editingTitle || $[46] !== formatDate || $[47] !== getStateFromUrl || $[48] !== handleSave || $[49] !== handleTitleSave || $[50] !== handleUnshareQuery || $[51] !== handleUpdate || $[52] !== optimisticTitles || $[53] !== pendingUnshareKeys || $[54] !== queries || $[55] !== queryFilter || $[56] !== saving || $[57] !== searchQuery || $[58] !== selectedUrl || $[59] !== setStateFromParsedUrl || $[60] !== t) {
1011
1321
  let filteredQueries = (queries?.filter((q_3) => !pendingUnshareKeys.includes(q_3._key)))?.filter((q_4) => {
1012
1322
  let matchesSearch = (q_4.title ?? "").toLowerCase().includes(searchQuery.toLowerCase()), matchesFilter = queryFilter === "all" || queryFilter === "personal" && !q_4.shared || queryFilter === "shared" && q_4.shared;
1013
1323
  return matchesSearch && matchesFilter;
1014
1324
  });
1015
1325
  T2 = ScrollContainer;
1016
1326
  let t16;
1017
- $[71] === t ? t16 = $[72] : (t16 = t("label.saved-queries"), $[71] = t, $[72] = t16);
1327
+ $[69] === t ? t16 = $[70] : (t16 = t("label.saved-queries"), $[69] = t, $[70] = t16);
1018
1328
  let t17;
1019
- $[73] === t16 ? t17 = $[74] : (t17 = /* @__PURE__ */ jsx(StyledLabel, {
1329
+ $[71] === t16 ? t17 = $[72] : (t17 = /* @__PURE__ */ jsx(StyledLabel, {
1020
1330
  muted: !0,
1021
1331
  children: t16
1022
- }), $[73] = t16, $[74] = t17);
1332
+ }), $[71] = t16, $[72] = t17);
1023
1333
  let t18;
1024
- $[75] === t ? t18 = $[76] : (t18 = t("action.save-query"), $[75] = t, $[76] = t18);
1334
+ $[73] === t ? t18 = $[74] : (t18 = t("action.save-query"), $[73] = t, $[74] = t18);
1025
1335
  let t19;
1026
- $[77] === handleSave ? t19 = $[78] : (t19 = () => void handleSave(), $[77] = handleSave, $[78] = t19);
1336
+ $[75] === handleSave ? t19 = $[76] : (t19 = () => void handleSave(), $[75] = handleSave, $[76] = t19);
1027
1337
  let t20;
1028
- $[79] !== saving || $[80] !== t18 || $[81] !== t19 ? (t20 = /* @__PURE__ */ jsx(Button, {
1338
+ $[77] !== saving || $[78] !== t18 || $[79] !== t19 ? (t20 = /* @__PURE__ */ jsx(Button, {
1029
1339
  "aria-label": t18,
1030
1340
  icon: AddIcon,
1031
1341
  disabled: saving,
1032
1342
  onClick: t19,
1033
1343
  mode: "bleed"
1034
- }), $[79] = saving, $[80] = t18, $[81] = t19, $[82] = t20) : t20 = $[82];
1344
+ }), $[77] = saving, $[78] = t18, $[79] = t19, $[80] = t20) : t20 = $[80];
1035
1345
  let t21;
1036
- $[83] !== t17 || $[84] !== t20 ? (t21 = /* @__PURE__ */ jsxs(Flex, {
1346
+ $[81] !== t17 || $[82] !== t20 ? (t21 = /* @__PURE__ */ jsxs(Flex, {
1037
1347
  padding: 3,
1038
1348
  paddingTop: 2,
1039
1349
  paddingBottom: 0,
1040
1350
  justifyContent: "space-between",
1041
1351
  alignItems: "center",
1042
1352
  children: [t17, t20]
1043
- }), $[83] = t17, $[84] = t20, $[85] = t21) : t21 = $[85];
1353
+ }), $[81] = t17, $[82] = t20, $[83] = t21) : t21 = $[83];
1044
1354
  let t22;
1045
- $[86] === t ? t22 = $[87] : (t22 = t("label.search-queries"), $[86] = t, $[87] = t22);
1355
+ $[84] === t ? t22 = $[85] : (t22 = t("label.search-queries"), $[84] = t, $[85] = t22);
1046
1356
  let t23;
1047
- $[88] === Symbol.for("react.memo_cache_sentinel") ? (t23 = (event) => setSearchQuery(event.currentTarget.value), $[88] = t23) : t23 = $[88];
1357
+ $[86] === Symbol.for("react.memo_cache_sentinel") ? (t23 = (event) => setSearchQuery(event.currentTarget.value), $[86] = t23) : t23 = $[86];
1048
1358
  let t24;
1049
- $[89] !== searchQuery || $[90] !== t22 ? (t24 = /* @__PURE__ */ jsx(Box, {
1359
+ $[87] !== searchQuery || $[88] !== t22 ? (t24 = /* @__PURE__ */ jsx(Box, {
1050
1360
  padding: 3,
1051
1361
  paddingTop: 0,
1052
1362
  children: /* @__PURE__ */ jsx(TextInput, {
@@ -1055,45 +1365,45 @@ function QueryRecall(t0) {
1055
1365
  value: searchQuery,
1056
1366
  onChange: t23
1057
1367
  })
1058
- }), $[89] = searchQuery, $[90] = t22, $[91] = t24) : t24 = $[91];
1368
+ }), $[87] = searchQuery, $[88] = t22, $[89] = t24) : t24 = $[89];
1059
1369
  let t25;
1060
- $[92] === t ? t25 = $[93] : (t25 = t("label.all"), $[92] = t, $[93] = t25);
1370
+ $[90] === t ? t25 = $[91] : (t25 = t("label.all"), $[90] = t, $[91] = t25);
1061
1371
  let t26 = queryFilter === "all", t27;
1062
- $[94] === Symbol.for("react.memo_cache_sentinel") ? (t27 = () => setQueryFilter("all"), $[94] = t27) : t27 = $[94];
1372
+ $[92] === Symbol.for("react.memo_cache_sentinel") ? (t27 = () => setQueryFilter("all"), $[92] = t27) : t27 = $[92];
1063
1373
  let t28;
1064
- $[95] !== t25 || $[96] !== t26 ? (t28 = /* @__PURE__ */ jsx(Tab, {
1374
+ $[93] !== t25 || $[94] !== t26 ? (t28 = /* @__PURE__ */ jsx(Tab, {
1065
1375
  id: "query-filter-all",
1066
1376
  "aria-controls": "vision-query-recall-list",
1067
1377
  label: t25,
1068
1378
  selected: t26,
1069
1379
  onClick: t27
1070
- }), $[95] = t25, $[96] = t26, $[97] = t28) : t28 = $[97];
1380
+ }), $[93] = t25, $[94] = t26, $[95] = t28) : t28 = $[95];
1071
1381
  let t29;
1072
- $[98] === t ? t29 = $[99] : (t29 = t("label.personal"), $[98] = t, $[99] = t29);
1382
+ $[96] === t ? t29 = $[97] : (t29 = t("label.personal"), $[96] = t, $[97] = t29);
1073
1383
  let t30 = queryFilter === "personal", t31;
1074
- $[100] === Symbol.for("react.memo_cache_sentinel") ? (t31 = () => setQueryFilter("personal"), $[100] = t31) : t31 = $[100];
1384
+ $[98] === Symbol.for("react.memo_cache_sentinel") ? (t31 = () => setQueryFilter("personal"), $[98] = t31) : t31 = $[98];
1075
1385
  let t32;
1076
- $[101] !== t29 || $[102] !== t30 ? (t32 = /* @__PURE__ */ jsx(Tab, {
1386
+ $[99] !== t29 || $[100] !== t30 ? (t32 = /* @__PURE__ */ jsx(Tab, {
1077
1387
  id: "query-filter-personal",
1078
1388
  "aria-controls": "vision-query-recall-list",
1079
1389
  label: t29,
1080
1390
  selected: t30,
1081
1391
  onClick: t31
1082
- }), $[101] = t29, $[102] = t30, $[103] = t32) : t32 = $[103];
1392
+ }), $[99] = t29, $[100] = t30, $[101] = t32) : t32 = $[101];
1083
1393
  let t33;
1084
- $[104] === t ? t33 = $[105] : (t33 = t("label.shared"), $[104] = t, $[105] = t33);
1394
+ $[102] === t ? t33 = $[103] : (t33 = t("label.shared"), $[102] = t, $[103] = t33);
1085
1395
  let t34 = queryFilter === "shared", t35;
1086
- $[106] === Symbol.for("react.memo_cache_sentinel") ? (t35 = () => setQueryFilter("shared"), $[106] = t35) : t35 = $[106];
1396
+ $[104] === Symbol.for("react.memo_cache_sentinel") ? (t35 = () => setQueryFilter("shared"), $[104] = t35) : t35 = $[104];
1087
1397
  let t36;
1088
- $[107] !== t33 || $[108] !== t34 ? (t36 = /* @__PURE__ */ jsx(Tab, {
1398
+ $[105] !== t33 || $[106] !== t34 ? (t36 = /* @__PURE__ */ jsx(Tab, {
1089
1399
  id: "query-filter-shared",
1090
1400
  "aria-controls": "vision-query-recall-list",
1091
1401
  label: t33,
1092
1402
  selected: t34,
1093
1403
  onClick: t35
1094
- }), $[107] = t33, $[108] = t34, $[109] = t36) : t36 = $[109];
1404
+ }), $[105] = t33, $[106] = t34, $[107] = t36) : t36 = $[107];
1095
1405
  let t37;
1096
- $[110] !== t28 || $[111] !== t32 || $[112] !== t36 ? (t37 = /* @__PURE__ */ jsx(Box, {
1406
+ $[108] !== t28 || $[109] !== t32 || $[110] !== t36 ? (t37 = /* @__PURE__ */ jsx(Box, {
1097
1407
  paddingX: 3,
1098
1408
  paddingBottom: 2,
1099
1409
  children: /* @__PURE__ */ jsxs(TabList, {
@@ -1104,14 +1414,14 @@ function QueryRecall(t0) {
1104
1414
  t36
1105
1415
  ]
1106
1416
  })
1107
- }), $[110] = t28, $[111] = t32, $[112] = t36, $[113] = t37) : t37 = $[113], $[114] !== t21 || $[115] !== t24 || $[116] !== t37 ? (t15 = /* @__PURE__ */ jsxs(FixedHeader, {
1417
+ }), $[108] = t28, $[109] = t32, $[110] = t36, $[111] = t37) : t37 = $[111], $[112] !== t21 || $[113] !== t24 || $[114] !== t37 ? (t15 = /* @__PURE__ */ jsxs(FixedHeader, {
1108
1418
  gap: 3,
1109
1419
  children: [
1110
1420
  t21,
1111
1421
  t24,
1112
1422
  t37
1113
1423
  ]
1114
- }), $[114] = t21, $[115] = t24, $[116] = t37, $[117] = t15) : t15 = $[117], T1 = QueryList, t14 = "vision-query-recall-list", T0 = Flex, t11 = 3, t12 = "column", t13 = filteredQueries?.map((q_5, index) => {
1424
+ }), $[112] = t21, $[113] = t24, $[114] = t37, $[115] = t15) : t15 = $[115], T1 = QueryList, t14 = "vision-query-recall-list", T0 = Flex, t11 = 3, t12 = "column", t13 = filteredQueries?.map((q_5, index) => {
1115
1425
  let queryObj = getStateFromUrl(q_5.url), fullQueryPreview = queryObj?.query || "", shortQueryPreview = fullQueryPreview.split("{")[0], isSelected = selectedUrl === q_5.url, canMutateQuery = !q_5.shared || q_5.isOwnedByCurrentUser, areQueriesEqual = queryObj && currentQuery === queryObj.query && dequal(currentParams, queryObj.params), isEdited = isSelected && !areQueriesEqual && canMutateQuery;
1116
1426
  return /* @__PURE__ */ jsx(Card, {
1117
1427
  paddingX: compactMode ? 3 : 4,
@@ -1216,6 +1526,7 @@ function QueryRecall(t0) {
1216
1526
  })
1217
1527
  ] }),
1218
1528
  popover: {
1529
+ animate: !0,
1219
1530
  portal: !0,
1220
1531
  placement: "bottom-end",
1221
1532
  tone: "default"
@@ -1225,6 +1536,7 @@ function QueryRecall(t0) {
1225
1536
  })]
1226
1537
  }),
1227
1538
  fullQueryPreview ? /* @__PURE__ */ jsx(Tooltip, {
1539
+ animate: !0,
1228
1540
  content: /* @__PURE__ */ jsx(Box, {
1229
1541
  padding: 2,
1230
1542
  style: {
@@ -1361,21 +1673,22 @@ function QueryRecall(t0) {
1361
1673
  ]
1362
1674
  })
1363
1675
  }, q_5._key);
1364
- }), $[42] = compactMode, $[43] = currentParams, $[44] = currentQuery, $[45] = deleteQuery, $[46] = editingKey, $[47] = editingTitle, $[48] = formatDate, $[49] = getStateFromUrl, $[50] = handleSave, $[51] = handleTitleSave, $[52] = handleUnshareQuery, $[53] = handleUpdate, $[54] = optimisticTitles, $[55] = pendingUnshareKeys, $[56] = queries, $[57] = queryFilter, $[58] = saving, $[59] = searchQuery, $[60] = selectedUrl, $[61] = setStateFromParsedUrl, $[62] = t, $[63] = T0, $[64] = T1, $[65] = T2, $[66] = t11, $[67] = t12, $[68] = t13, $[69] = t14, $[70] = t15;
1365
- } else T0 = $[63], T1 = $[64], T2 = $[65], t11 = $[66], t12 = $[67], t13 = $[68], t14 = $[69], t15 = $[70];
1676
+ }), $[40] = compactMode, $[41] = currentParams, $[42] = currentQuery, $[43] = deleteQuery, $[44] = editingKey, $[45] = editingTitle, $[46] = formatDate, $[47] = getStateFromUrl, $[48] = handleSave, $[49] = handleTitleSave, $[50] = handleUnshareQuery, $[51] = handleUpdate, $[52] = optimisticTitles, $[53] = pendingUnshareKeys, $[54] = queries, $[55] = queryFilter, $[56] = saving, $[57] = searchQuery, $[58] = selectedUrl, $[59] = setStateFromParsedUrl, $[60] = t, $[61] = T0, $[62] = T1, $[63] = T2, $[64] = t11, $[65] = t12, $[66] = t13, $[67] = t14, $[68] = t15;
1677
+ } else T0 = $[61], T1 = $[62], T2 = $[63], t11 = $[64], t12 = $[65], t13 = $[66], t14 = $[67], t15 = $[68];
1366
1678
  let t16;
1367
- $[118] !== T0 || $[119] !== t11 || $[120] !== t12 || $[121] !== t13 ? (t16 = /* @__PURE__ */ jsx(T0, {
1679
+ $[116] !== T0 || $[117] !== t11 || $[118] !== t12 || $[119] !== t13 ? (t16 = /* @__PURE__ */ jsx(T0, {
1368
1680
  paddingY: t11,
1369
1681
  flexDirection: t12,
1370
1682
  children: t13
1371
- }), $[118] = T0, $[119] = t11, $[120] = t12, $[121] = t13, $[122] = t16) : t16 = $[122];
1683
+ }), $[116] = T0, $[117] = t11, $[118] = t12, $[119] = t13, $[120] = t16) : t16 = $[120];
1372
1684
  let t17;
1373
- $[123] !== T1 || $[124] !== t14 || $[125] !== t16 ? (t17 = /* @__PURE__ */ jsx(T1, {
1685
+ $[121] !== T1 || $[122] !== t14 || $[123] !== t16 ? (t17 = /* @__PURE__ */ jsx(T1, {
1374
1686
  id: t14,
1375
1687
  children: t16
1376
- }), $[123] = T1, $[124] = t14, $[125] = t16, $[126] = t17) : t17 = $[126];
1688
+ }), $[121] = T1, $[122] = t14, $[123] = t16, $[124] = t17) : t17 = $[124];
1377
1689
  let t18;
1378
- $[127] !== handleConfirmShareQuery || $[128] !== shareDialogQuery || $[129] !== t ? (t18 = shareDialogQuery && /* @__PURE__ */ jsx(Dialog, {
1690
+ $[125] !== handleConfirmShareQuery || $[126] !== shareDialogQuery || $[127] !== t ? (t18 = shareDialogQuery && /* @__PURE__ */ jsx(Dialog, {
1691
+ animate: !0,
1379
1692
  id: "vision-query-recall-share-dialog",
1380
1693
  width: 1,
1381
1694
  header: t("label.share"),
@@ -1404,13 +1717,13 @@ function QueryRecall(t0) {
1404
1717
  children: t("save-query.share-warning")
1405
1718
  })
1406
1719
  })
1407
- }), $[127] = handleConfirmShareQuery, $[128] = shareDialogQuery, $[129] = t, $[130] = t18) : t18 = $[130];
1720
+ }), $[125] = handleConfirmShareQuery, $[126] = shareDialogQuery, $[127] = t, $[128] = t18) : t18 = $[128];
1408
1721
  let t19;
1409
- return $[131] !== T2 || $[132] !== t15 || $[133] !== t17 || $[134] !== t18 ? (t19 = /* @__PURE__ */ jsxs(T2, { children: [
1722
+ return $[129] !== T2 || $[130] !== t15 || $[131] !== t17 || $[132] !== t18 ? (t19 = /* @__PURE__ */ jsxs(T2, { children: [
1410
1723
  t15,
1411
1724
  t17,
1412
1725
  t18
1413
- ] }), $[131] = T2, $[132] = t15, $[133] = t17, $[134] = t18, $[135] = t19) : t19 = $[135], t19;
1726
+ ] }), $[129] = T2, $[130] = t15, $[131] = t17, $[132] = t18, $[133] = t19) : t19 = $[133], t19;
1414
1727
  }
1415
1728
  function narrowBreakpoint() {
1416
1729
  return typeof window < "u" && window.innerWidth > 600;
@@ -1426,7 +1739,7 @@ function calculatePaneSizeOptions(height) {
1426
1739
  };
1427
1740
  }
1428
1741
  function usePaneSize(t0) {
1429
- let $ = c(7), { visionRootRef } = t0, [rootSize, setRootSize] = useState(_temp$4), [isNarrowBreakpoint, setIsNarrowBreakpoint] = useState(_temp2$3), [paneSizeOptions, setPaneSizeOptions] = useState(_temp3$2), t1, t2;
1742
+ let $ = c(7), { visionRootRef } = t0, [rootSize, setRootSize] = useState(_temp$5), [isNarrowBreakpoint, setIsNarrowBreakpoint] = useState(_temp2$3), [paneSizeOptions, setPaneSizeOptions] = useState(_temp3$2), t1, t2;
1430
1743
  $[0] === visionRootRef ? (t1 = $[1], t2 = $[2]) : (t1 = () => {
1431
1744
  if (!visionRootRef.current) return;
1432
1745
  let handleResize = (entries) => {
@@ -1453,7 +1766,7 @@ function _temp3$2() {
1453
1766
  function _temp2$3() {
1454
1767
  return narrowBreakpoint();
1455
1768
  }
1456
- function _temp$4() {
1769
+ function _temp$5() {
1457
1770
  return {
1458
1771
  width: typeof window < "u" ? window.innerWidth : 1e3,
1459
1772
  height: typeof window < "u" ? window.innerHeight : 800
@@ -1464,7 +1777,7 @@ function _temp$4() {
1464
1777
  * To handle query and listen execution.
1465
1778
  */
1466
1779
  function VisionGuiControls(t0) {
1467
- let $ = c(30), { hasValidParams, listenInProgress, queryInProgress, onQueryExecution, onListenExecution } = t0, { t } = useTranslation(visionLocaleNamespace), t1;
1780
+ let $ = c(34), { hasValidParams, listenInProgress, queryInProgress, onQueryExecution, onListenExecution, onSwitchToRedesign } = t0, { t } = useTranslation(visionLocaleNamespace), t1;
1468
1781
  $[0] === t ? t1 = $[1] : (t1 = t("params.error.params-invalid-json"), $[0] = t, $[1] = t1);
1469
1782
  let t2;
1470
1783
  $[2] === t1 ? t2 = $[3] : (t2 = /* @__PURE__ */ jsx(Card, {
@@ -1487,6 +1800,7 @@ function VisionGuiControls(t0) {
1487
1800
  flexBasis: "0%",
1488
1801
  flexGrow: 1,
1489
1802
  children: /* @__PURE__ */ jsx(Tooltip, {
1803
+ animate: !0,
1490
1804
  content: t3,
1491
1805
  placement: "top",
1492
1806
  portal: !0,
@@ -1520,24 +1834,52 @@ function VisionGuiControls(t0) {
1520
1834
  })
1521
1835
  }), $[17] = onListenExecution, $[18] = t10, $[19] = t11, $[20] = t12, $[21] = t9, $[22] = t13) : t13 = $[22];
1522
1836
  let t14;
1523
- $[23] !== t13 || $[24] !== t8 ? (t14 = /* @__PURE__ */ jsxs(Flex, {
1524
- justifyContent: "space-evenly",
1525
- children: [t8, t13]
1526
- }), $[23] = t13, $[24] = t8, $[25] = t14) : t14 = $[25];
1837
+ $[23] !== onSwitchToRedesign || $[24] !== t ? (t14 = onSwitchToRedesign && /* @__PURE__ */ jsx(Box, {
1838
+ flexShrink: 0,
1839
+ marginLeft: 3,
1840
+ children: /* @__PURE__ */ jsx(Tooltip, {
1841
+ animate: !0,
1842
+ content: /* @__PURE__ */ jsx(Text, {
1843
+ size: 1,
1844
+ children: t("vista.redesign.try.description")
1845
+ }),
1846
+ placement: "top",
1847
+ portal: !0,
1848
+ children: /* @__PURE__ */ jsx(Button, {
1849
+ "aria-label": t("vista.redesign.try"),
1850
+ "data-testid": "vision-try-redesign",
1851
+ icon: RocketIcon,
1852
+ mode: "bleed",
1853
+ onClick: onSwitchToRedesign,
1854
+ tone: "primary",
1855
+ type: "button"
1856
+ })
1857
+ })
1858
+ }), $[23] = onSwitchToRedesign, $[24] = t, $[25] = t14) : t14 = $[25];
1527
1859
  let t15;
1528
- return $[26] !== hasValidParams || $[27] !== t14 || $[28] !== t2 ? (t15 = /* @__PURE__ */ jsx(ControlsContainer, { children: /* @__PURE__ */ jsx(Card, {
1860
+ $[26] !== t13 || $[27] !== t14 || $[28] !== t8 ? (t15 = /* @__PURE__ */ jsxs(Flex, {
1861
+ justifyContent: "space-evenly",
1862
+ children: [
1863
+ t8,
1864
+ t13,
1865
+ t14
1866
+ ]
1867
+ }), $[26] = t13, $[27] = t14, $[28] = t8, $[29] = t15) : t15 = $[29];
1868
+ let t16;
1869
+ return $[30] !== hasValidParams || $[31] !== t15 || $[32] !== t2 ? (t16 = /* @__PURE__ */ jsx(ControlsContainer, { children: /* @__PURE__ */ jsx(Card, {
1529
1870
  padding: 3,
1530
1871
  paddingX: 3,
1531
1872
  children: /* @__PURE__ */ jsx(Tooltip, {
1873
+ animate: !0,
1532
1874
  content: t2,
1533
1875
  placement: "top",
1534
1876
  disabled: hasValidParams,
1535
1877
  portal: !0,
1536
- children: t14
1878
+ children: t15
1537
1879
  })
1538
- }) }), $[26] = hasValidParams, $[27] = t14, $[28] = t2, $[29] = t15) : t15 = $[29], t15;
1880
+ }) }), $[30] = hasValidParams, $[31] = t15, $[32] = t2, $[33] = t16) : t16 = $[33], t16;
1539
1881
  }
1540
- var dot = "_1mjpm8q2", perspectivePopoverContent = "_1mjpm8q0", perspectivePopoverLink = "_1mjpm8q1";
1882
+ var dot = "e85d3y2", perspectivePopoverContent = "e85d3y0", perspectivePopoverLink = "e85d3y1";
1541
1883
  function PerspectivePopoverContent(props) {
1542
1884
  let $ = c(2), t0;
1543
1885
  return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Box, {
@@ -1561,7 +1903,7 @@ function Dot(t0) {
1561
1903
  }
1562
1904
  function PerspectivePopover() {
1563
1905
  let $ = c(39), [open, setOpen] = useState(!1), buttonRef = useRef(null), popoverRef = useRef(null), t0;
1564
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setOpen(_temp$3), $[0] = t0) : t0 = $[0];
1906
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setOpen(_temp$4), $[0] = t0) : t0 = $[0];
1565
1907
  let handleClick = t0, { t } = useTranslation(visionLocaleNamespace), t1, t2;
1566
1908
  $[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => setOpen(!1), t2 = () => [buttonRef.current, popoverRef.current], $[1] = t1, $[2] = t2) : (t1 = $[1], t2 = $[2]), useClickOutsideEvent(t1, t2);
1567
1909
  let t3;
@@ -1640,6 +1982,7 @@ function PerspectivePopover() {
1640
1982
  }), $[33] = open, $[34] = t16);
1641
1983
  let t17;
1642
1984
  return $[35] !== open || $[36] !== t14 || $[37] !== t16 ? (t17 = /* @__PURE__ */ jsx(Popover, {
1985
+ animate: !0,
1643
1986
  content: t14,
1644
1987
  placement: "bottom-start",
1645
1988
  portal: !0,
@@ -1649,7 +1992,7 @@ function PerspectivePopover() {
1649
1992
  children: t16
1650
1993
  }), $[35] = open, $[36] = t14, $[37] = t16, $[38] = t17) : t17 = $[38], t17;
1651
1994
  }
1652
- function _temp$3(o) {
1995
+ function _temp$4(o) {
1653
1996
  return !o;
1654
1997
  }
1655
1998
  const PinnedReleasePerspectiveOption = (t0) => {
@@ -1665,7 +2008,7 @@ const PinnedReleasePerspectiveOption = (t0) => {
1665
2008
  name,
1666
2009
  t3,
1667
2010
  label
1668
- ].filter(_temp$2), $[8] = label, $[9] = name, $[10] = t3, $[11] = t4) : t4 = $[11];
2011
+ ].filter(_temp$3), $[8] = label, $[9] = name, $[10] = t3, $[11] = t4) : t4 = $[11];
1669
2012
  let text = t4.join(" "), t5;
1670
2013
  $[12] === pinnedPerspective ? t5 = $[13] : (t5 = hasPinnedPerspective(pinnedPerspective), $[12] = pinnedPerspective, $[13] = t5);
1671
2014
  let t6 = !t5, t7;
@@ -1757,6 +2100,7 @@ function VisionGuiHeader(t0) {
1757
2100
  }), $[33] = isApiVersionLocked, $[34] = onChangeApiVersion, $[35] = t16, $[36] = t19, $[37] = t20) : t20 = $[37];
1758
2101
  let t21;
1759
2102
  $[38] !== t14 || $[39] !== t15 || $[40] !== t20 ? (t21 = /* @__PURE__ */ jsx(Tooltip, {
2103
+ animate: !0,
1760
2104
  content: t14,
1761
2105
  disabled: t15,
1762
2106
  placement: "bottom",
@@ -1871,6 +2215,7 @@ function VisionGuiHeader(t0) {
1871
2215
  value: url
1872
2216
  })
1873
2217
  }), /* @__PURE__ */ jsx(Tooltip, {
2218
+ animate: !0,
1874
2219
  content: t("action.copy-url-to-clipboard"),
1875
2220
  children: /* @__PURE__ */ jsx(Button, {
1876
2221
  "aria-label": t("action.copy-url-to-clipboard"),
@@ -1907,23 +2252,51 @@ function _temp3$1(version) {
1907
2252
  function _temp2$2(ds) {
1908
2253
  return /* @__PURE__ */ jsx("option", { children: ds }, ds);
1909
2254
  }
1910
- function _temp$2(value) {
2255
+ function _temp$3(value) {
1911
2256
  return value !== void 0;
1912
2257
  }
1913
2258
  function getBlobUrl(content, mimeType) {
1914
2259
  return URL.createObjectURL(new Blob([content], { type: mimeType }));
1915
2260
  }
2261
+ const NOTHING = Symbol("nothing");
2262
+ /**
2263
+ * One blob URL per encoder, replaced (and the previous one revoked) when the encoded content
2264
+ * changes. The value last encoded is remembered as well, so asking for the same result again
2265
+ * costs nothing: results are never mutated, and encoding one only to compare it is the expensive
2266
+ * part for a large result.
2267
+ */
1916
2268
  function getMemoizedBlobUrlResolver(mimeType, stringEncoder) {
1917
2269
  return (() => {
1918
- let prevResult = "", prevContent = "";
2270
+ let prevInput = NOTHING, prevResult = "", prevContent = "";
1919
2271
  return (input) => {
2272
+ if (input === prevInput && prevResult) return prevResult;
1920
2273
  let content = stringEncoder(input);
1921
- if (typeof content == "string" && content !== "") return content === prevContent || (prevContent = content, prevResult && URL.revokeObjectURL(prevResult), prevResult = getBlobUrl(content, mimeType)), prevResult;
2274
+ if (typeof content == "string" && content !== "") return prevInput = input, content === prevContent || (prevContent = content, prevResult && URL.revokeObjectURL(prevResult), prevResult = getBlobUrl(content, mimeType)), prevResult;
1922
2275
  };
1923
2276
  })();
1924
2277
  }
1925
2278
  const getJsonBlobUrl = getMemoizedBlobUrlResolver("application/json", (input) => JSON.stringify(input, null, 2)), getCsvBlobUrl = getMemoizedBlobUrlResolver("text/csv", (input) => json2csv(Array.isArray(input) ? input : [input]).trim());
1926
2279
  /**
2280
+ * Whether `getCsvBlobUrl` can produce anything for a result: `json2csv` yields nothing unless at
2281
+ * least one item is an object. A look at the shape, so a download button can be disabled without
2282
+ * converting a result nobody asked to download.
2283
+ */
2284
+ function canEncodeCsv(input) {
2285
+ return (Array.isArray(input) ? input : [input]).some((item) => typeof item == "object" && !!item && !Array.isArray(item));
2286
+ }
2287
+ function DelayedSpinner(props) {
2288
+ let $ = c(5), [show, setShow] = useState(!1), t0, t1;
2289
+ $[0] === props.delay ? (t0 = $[1], t1 = $[2]) : (t0 = () => {
2290
+ let timer = setTimeout(() => setShow(!0), props.delay || 500);
2291
+ return () => clearTimeout(timer);
2292
+ }, t1 = [props.delay], $[0] = props.delay, $[1] = t0, $[2] = t1), useEffect(t0, t1);
2293
+ let t2;
2294
+ return $[3] === show ? t2 = $[4] : (t2 = show ? /* @__PURE__ */ jsx(Spinner, {
2295
+ muted: !0,
2296
+ size: 4
2297
+ }) : null, $[3] = show, $[4] = t2), t2;
2298
+ }
2299
+ /**
1927
2300
  * Returns true when `selected` does not satisfy `required`.
1928
2301
  *
1929
2302
  * `X` is the experimental API: it satisfies every requirement, and when it is
@@ -1963,7 +2336,7 @@ function hasReleaseInPerspective(perspective) {
1963
2336
  function getUnsatisfiedApiVersionCapability(context, capabilities = API_VERSION_CAPABILITIES) {
1964
2337
  if (context.statusCode === 400) return capabilities.find((capability) => capability.applies(context) && isApiVersionBelow(context.apiVersion, capability.requiredApiVersion));
1965
2338
  }
1966
- var errorCode = "qq7z3z0";
2339
+ var errorCode = "_14yleie0";
1967
2340
  function ErrorCode(props) {
1968
2341
  let $ = c(2), t0;
1969
2342
  return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Code, {
@@ -2057,58 +2430,130 @@ function QueryErrorDialog(props) {
2057
2430
  ]
2058
2431
  }), $[14] = T0, $[15] = t0, $[16] = t1, $[17] = t2, $[18] = t3, $[19] = t4, $[20] = t5, $[21] = t6) : t6 = $[21], t6;
2059
2432
  }
2060
- var codeFamilyVar = "var(--ujs8fm0)", codeFontSizeVar = "var(--ujs8fm1)", codeLineHeightVar = "var(--ujs8fm2)", resultViewWrapper = "ujs8fmc", space0Var = "var(--ujs8fm3)", space2Var = "var(--ujs8fm4)", space4HalfVar = "var(--ujs8fm6)", space4Var = "var(--ujs8fm5)", syntaxBooleanVar = "var(--ujs8fma)", syntaxConstantVar = "var(--ujs8fm8)", syntaxNumberVar = "var(--ujs8fmb)", syntaxPropertyVar = "var(--ujs8fm7)", syntaxStringVar = "var(--ujs8fm9)";
2433
+ /** A dotted key path written the way it reads in code: `0.author.tags.1` as `[0].author.tags[1]` */
2434
+ function describeKeypath(keypath) {
2435
+ return keypath.split(".").map((segment, index) => /^\d+$/.test(segment) ? `[${segment}]` : index === 0 ? segment : `.${segment}`).join("");
2436
+ }
2437
+ /**
2438
+ * The value at one of `@rexxars/react-json-inspector`'s dotted key paths (`0.author.name`; empty
2439
+ * for the root). A key may contain dots itself, so at each step the longest run of segments that
2440
+ * names a property wins. Undefined when the path leads nowhere.
2441
+ */
2442
+ function getAtKeypath(data, keypath) {
2443
+ if (keypath === "") return { value: data };
2444
+ let segments = keypath.split("."), current = data, index = 0;
2445
+ for (; index < segments.length;) {
2446
+ let container = current;
2447
+ if (typeof container != "object" || !container) return;
2448
+ let end = segments.length;
2449
+ for (; end > index && !Object.hasOwn(container, segments.slice(index, end).join("."));) end--;
2450
+ if (end === index) return;
2451
+ current = Reflect.get(container, segments.slice(index, end).join(".")), index = end;
2452
+ }
2453
+ return { value: current };
2454
+ }
2455
+ var codeFamilyVar = "var(--_1nwt4640)", codeFontSizeVar = "var(--_1nwt4641)", codeLineHeightVar = "var(--_1nwt4642)", copyNodeButton = "_1nwt464e", copyableResult = "_1nwt464d", resultViewWrapper = "_1nwt464c", space0Var = "var(--_1nwt4643)", space2Var = "var(--_1nwt4644)", space4HalfVar = "var(--_1nwt4646)", space4Var = "var(--_1nwt4645)", syntaxBooleanVar = "var(--_1nwt464a)", syntaxConstantVar = "var(--_1nwt4648)", syntaxNumberVar = "var(--_1nwt464b)", syntaxPropertyVar = "var(--_1nwt4647)", syntaxStringVar = "var(--_1nwt4649)";
2061
2456
  const lru = new LRU({ maxSize: 5e4 });
2062
2457
  function ResultViewWrapper(t0) {
2063
- let $ = c(24), { children } = t0, { color, font, space } = useTheme_v2(), codeSize = font.code.sizes[2], t1 = font.code.family, t2 = `${codeSize.fontSize}px`, t3 = `${codeSize.lineHeight}px`, t4;
2064
- $[0] === space[0] ? t4 = $[1] : (t4 = rem(space[0]), $[0] = space[0], $[1] = t4);
2065
- let t5 = `${t4}`, t6;
2066
- $[2] === space[2] ? t6 = $[3] : (t6 = rem(space[2]), $[2] = space[2], $[3] = t6);
2067
- let t7 = `${t6}`, t8;
2068
- $[4] === space[4] ? t8 = $[5] : (t8 = rem(space[4]), $[4] = space[4], $[5] = t8);
2069
- let t9 = `${t8}`, t10 = space[4] / 2, t11;
2070
- $[6] === t10 ? t11 = $[7] : (t11 = rem(t10), $[6] = t10, $[7] = t11);
2071
- let t12 = `${t11}`, t13;
2072
- $[8] !== color.syntax.boolean || $[9] !== color.syntax.constant || $[10] !== color.syntax.number || $[11] !== color.syntax.property || $[12] !== color.syntax.string || $[13] !== font.code.family || $[14] !== t12 || $[15] !== t2 || $[16] !== t3 || $[17] !== t5 || $[18] !== t7 || $[19] !== t9 ? (t13 = assignInlineVars({
2073
- [codeFamilyVar]: t1,
2074
- [codeFontSizeVar]: t2,
2075
- [codeLineHeightVar]: t3,
2076
- [space0Var]: t5,
2077
- [space2Var]: t7,
2078
- [space4Var]: t9,
2079
- [space4HalfVar]: t12,
2458
+ let $ = c(25), { children, copyable } = t0, { color, font, space } = useTheme_v2(), codeSize = font.code.sizes[2], t1 = copyable ? `${resultViewWrapper} ${copyableResult}` : resultViewWrapper, t2 = font.code.family, t3 = `${codeSize.fontSize}px`, t4 = `${codeSize.lineHeight}px`, t5;
2459
+ $[0] === space[0] ? t5 = $[1] : (t5 = rem(space[0]), $[0] = space[0], $[1] = t5);
2460
+ let t6 = `${t5}`, t7;
2461
+ $[2] === space[2] ? t7 = $[3] : (t7 = rem(space[2]), $[2] = space[2], $[3] = t7);
2462
+ let t8 = `${t7}`, t9;
2463
+ $[4] === space[4] ? t9 = $[5] : (t9 = rem(space[4]), $[4] = space[4], $[5] = t9);
2464
+ let t10 = `${t9}`, t11 = space[4] / 2, t12;
2465
+ $[6] === t11 ? t12 = $[7] : (t12 = rem(t11), $[6] = t11, $[7] = t12);
2466
+ let t13 = `${t12}`, t14;
2467
+ $[8] !== color.syntax.boolean || $[9] !== color.syntax.constant || $[10] !== color.syntax.number || $[11] !== color.syntax.property || $[12] !== color.syntax.string || $[13] !== font.code.family || $[14] !== t10 || $[15] !== t13 || $[16] !== t3 || $[17] !== t4 || $[18] !== t6 || $[19] !== t8 ? (t14 = assignInlineVars({
2468
+ [codeFamilyVar]: t2,
2469
+ [codeFontSizeVar]: t3,
2470
+ [codeLineHeightVar]: t4,
2471
+ [space0Var]: t6,
2472
+ [space2Var]: t8,
2473
+ [space4Var]: t10,
2474
+ [space4HalfVar]: t13,
2080
2475
  [syntaxPropertyVar]: color.syntax.property,
2081
2476
  [syntaxConstantVar]: color.syntax.constant,
2082
2477
  [syntaxStringVar]: color.syntax.string,
2083
2478
  [syntaxBooleanVar]: color.syntax.boolean,
2084
2479
  [syntaxNumberVar]: color.syntax.number
2085
- }), $[8] = color.syntax.boolean, $[9] = color.syntax.constant, $[10] = color.syntax.number, $[11] = color.syntax.property, $[12] = color.syntax.string, $[13] = font.code.family, $[14] = t12, $[15] = t2, $[16] = t3, $[17] = t5, $[18] = t7, $[19] = t9, $[20] = t13) : t13 = $[20];
2086
- let t14;
2087
- return $[21] !== children || $[22] !== t13 ? (t14 = /* @__PURE__ */ jsx("div", {
2088
- className: resultViewWrapper,
2089
- style: t13,
2480
+ }), $[8] = color.syntax.boolean, $[9] = color.syntax.constant, $[10] = color.syntax.number, $[11] = color.syntax.property, $[12] = color.syntax.string, $[13] = font.code.family, $[14] = t10, $[15] = t13, $[16] = t3, $[17] = t4, $[18] = t6, $[19] = t8, $[20] = t14) : t14 = $[20];
2481
+ let t15;
2482
+ return $[21] !== children || $[22] !== t1 || $[23] !== t14 ? (t15 = /* @__PURE__ */ jsx("div", {
2483
+ className: t1,
2484
+ style: t14,
2090
2485
  children
2091
- }), $[21] = children, $[22] = t13, $[23] = t14) : t14 = $[23], t14;
2486
+ }), $[21] = children, $[22] = t1, $[23] = t14, $[24] = t15) : t15 = $[24], t15;
2092
2487
  }
2488
+ const ResultLabelContext = createContext(null);
2093
2489
  function ResultView(props) {
2094
- let $ = c(7), { data, datasetName } = props, workspaceDataset = useDataset();
2490
+ let $ = c(17), { data, datasetName, copy } = props, linkDocuments = useDataset() === datasetName, t0;
2491
+ $[0] !== copy || $[1] !== data || $[2] !== linkDocuments ? (t0 = {
2492
+ data,
2493
+ copy,
2494
+ linkDocuments
2495
+ }, $[0] = copy, $[1] = data, $[2] = linkDocuments, $[3] = t0) : t0 = $[3];
2496
+ let labelContext = t0;
2095
2497
  if (isRecord(data) || Array.isArray(data)) {
2096
- let t0 = workspaceDataset === datasetName ? DocumentEditLabel : void 0, t1;
2097
- return $[0] !== data || $[1] !== t0 ? (t1 = /* @__PURE__ */ jsx(ResultViewWrapper, { children: /* @__PURE__ */ jsx(JsonInspector, {
2498
+ let t1 = !!copy, t2 = copy || linkDocuments ? InteractiveLabel : void 0, t3;
2499
+ $[4] !== data || $[5] !== t2 ? (t3 = /* @__PURE__ */ jsx(JsonInspector, {
2098
2500
  data,
2099
2501
  search: !1,
2100
2502
  isExpanded,
2101
2503
  onClick: toggleExpanded,
2102
- interactiveLabel: t0
2103
- }) }), $[0] = data, $[1] = t0, $[2] = t1) : t1 = $[2], t1;
2504
+ interactiveLabel: t2
2505
+ }), $[4] = data, $[5] = t2, $[6] = t3) : t3 = $[6];
2506
+ let t4;
2507
+ $[7] !== labelContext || $[8] !== t3 ? (t4 = /* @__PURE__ */ jsx(ResultLabelContext, {
2508
+ value: labelContext,
2509
+ children: t3
2510
+ }), $[7] = labelContext, $[8] = t3, $[9] = t4) : t4 = $[9];
2511
+ let t5;
2512
+ return $[10] !== t1 || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsx(ResultViewWrapper, {
2513
+ copyable: t1,
2514
+ children: t4
2515
+ }), $[10] = t1, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
2104
2516
  }
2105
- let t0;
2106
- $[3] === data ? t0 = $[4] : (t0 = JSON.stringify(data), $[3] = data, $[4] = t0);
2107
2517
  let t1;
2108
- return $[5] === t0 ? t1 = $[6] : (t1 = /* @__PURE__ */ jsx(Code, {
2518
+ $[13] === data ? t1 = $[14] : (t1 = JSON.stringify(data), $[13] = data, $[14] = t1);
2519
+ let t2;
2520
+ return $[15] === t1 ? t2 = $[16] : (t2 = /* @__PURE__ */ jsx(Code, {
2109
2521
  language: "json",
2110
- children: t0
2111
- }), $[5] = t0, $[6] = t1), t1;
2522
+ children: t1
2523
+ }), $[15] = t1, $[16] = t2), t2;
2524
+ }
2525
+ function InteractiveLabel(props) {
2526
+ let $ = c(6), context = use(ResultLabelContext);
2527
+ if (props.isKey) {
2528
+ let t0;
2529
+ return $[0] !== context || $[1] !== props.keypath ? (t0 = context?.copy ? /* @__PURE__ */ jsx(CopyNodeButton, {
2530
+ copy: context.copy,
2531
+ data: context.data,
2532
+ keypath: props.keypath
2533
+ }) : null, $[0] = context, $[1] = props.keypath, $[2] = t0) : t0 = $[2], t0;
2534
+ }
2535
+ let t0;
2536
+ return $[3] !== context?.linkDocuments || $[4] !== props ? (t0 = context?.linkDocuments ? /* @__PURE__ */ jsx(DocumentEditLabel, { ...props }) : null, $[3] = context?.linkDocuments, $[4] = props, $[5] = t0) : t0 = $[5], t0;
2537
+ }
2538
+ function CopyNodeButton(props) {
2539
+ let $ = c(8), { copy, data, keypath } = props, t0;
2540
+ $[0] !== copy || $[1] !== data || $[2] !== keypath ? (t0 = (event) => {
2541
+ event.preventDefault(), event.stopPropagation();
2542
+ let found = getAtKeypath(data, keypath);
2543
+ found && copy.onCopy(found.value, keypath);
2544
+ }, $[0] = copy, $[1] = data, $[2] = keypath, $[3] = t0) : t0 = $[3];
2545
+ let t1;
2546
+ $[4] === Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsx(CopyIcon, {}), $[4] = t1) : t1 = $[4];
2547
+ let t2;
2548
+ return $[5] !== copy.label || $[6] !== t0 ? (t2 = /* @__PURE__ */ jsx("button", {
2549
+ "aria-label": copy.label,
2550
+ className: copyNodeButton,
2551
+ "data-testid": "result-copy-node",
2552
+ onClick: t0,
2553
+ title: copy.label,
2554
+ type: "button",
2555
+ children: t1
2556
+ }), $[5] = copy.label, $[6] = t0, $[7] = t2) : t2 = $[7], t2;
2112
2557
  }
2113
2558
  function DocumentEditLabel(props) {
2114
2559
  let $ = c(5);
@@ -2156,6 +2601,7 @@ function SaveCsvButton(t0) {
2156
2601
  }), $[2] = t2) : t2 = $[2];
2157
2602
  let t3;
2158
2603
  return $[3] === t1 ? t3 = $[4] : (t3 = /* @__PURE__ */ jsx(Tooltip, {
2604
+ animate: !0,
2159
2605
  content: t1,
2160
2606
  placement: "top",
2161
2607
  children: t2
@@ -2350,9 +2796,9 @@ function SaveResultButtons(t0) {
2350
2796
  function nodeContains(node, other) {
2351
2797
  return !node || !other ? !1 : node === other || !!(node.compareDocumentPosition(other) & 16);
2352
2798
  }
2353
- const sanityUrl = /\/(vX|v1|v\d{4}-\d\d-\d\d)\/.*?(?:query|listen)\/(.*?)\?(.*)/, VARIANTS_API_VERSION = prefixApiVersion(VARIANTS_STUDIO_CLIENT_OPTIONS.apiVersion), isRunHotkey = (event) => isHotkey("ctrl+enter", event) || isHotkey("mod+enter", event);
2799
+ const isRunHotkey = (event) => isHotkey("ctrl+enter", event) || isHotkey("mod+enter", event);
2354
2800
  function VisionGui(props) {
2355
- let $ = c(233), { datasets, config, projectId, defaultDataset } = props, toast = useToast(), { t } = useTranslation(visionLocaleNamespace), { perspectiveStack, selectedVariantNames } = usePerspective(), selectedVariantName = getDefaultVariant(selectedVariantNames), isScheduledDraftsEnabled = useScheduledDraftsEnabled(), { data: t0 } = useActiveReleases(), t1;
2801
+ let $ = c(234), { datasets, config, projectId, defaultDataset, onSwitchToRedesign } = props, toast = useToast(), { t } = useTranslation(visionLocaleNamespace), { perspectiveStack, selectedVariantNames } = usePerspective(), selectedVariantName = getDefaultVariant(selectedVariantNames), isScheduledDraftsEnabled = useScheduledDraftsEnabled(), { data: t0 } = useActiveReleases(), t1;
2356
2802
  $[0] === t0 ? t1 = $[1] : (t1 = t0 === void 0 ? [] : t0, $[0] = t0, $[1] = t1);
2357
2803
  let releases = t1, isDraftModelEnabled = useWorkspace().document.drafts.enabled, editorQueryRef = useRef(null), editorParamsRef = useRef(null), visionRootRef = useRef(null), customApiVersionElementRef = useRef(null), querySubscriptionRef = useRef(void 0), listenSubscriptionRef = useRef(void 0), t2;
2358
2804
  $[2] === projectId ? t2 = $[3] : (t2 = () => getLocalStorage(projectId || "default"), $[2] = projectId, $[3] = t2);
@@ -2390,7 +2836,7 @@ function VisionGui(props) {
2390
2836
  }
2391
2837
  let t17;
2392
2838
  if ($[35] !== isDraftModelEnabled || $[36] !== releases) {
2393
- let scheduledDraftReleases = releases.filter(_temp$1), releaseIds = sortReleases(scheduledDraftReleases).map(_temp2$1), t18;
2839
+ let scheduledDraftReleases = releases.filter(_temp$2), releaseIds = sortReleases(scheduledDraftReleases).map(_temp2$1), t18;
2394
2840
  $[38] === isDraftModelEnabled ? t18 = $[39] : (t18 = isDraftModelEnabled ? ["drafts"] : ["published"], $[38] = isDraftModelEnabled, $[39] = t18);
2395
2841
  let defaultPerspective = t18;
2396
2842
  t17 = [...releaseIds, ...defaultPerspective], $[35] = isDraftModelEnabled, $[36] = releases, $[37] = t17;
@@ -2517,7 +2963,7 @@ function VisionGui(props) {
2517
2963
  }, $[94] = localStorage, $[95] = t30);
2518
2964
  let handleParamsChange = t30, t31;
2519
2965
  $[96] !== apiVersion || $[97] !== dataset || $[98] !== datasets || $[99] !== perspective || $[100] !== toast ? (t31 = (data) => {
2520
- let match = data.match(sanityUrl);
2966
+ let match = data.match(SANITY_QUERY_URL);
2521
2967
  if (!match) return null;
2522
2968
  let [, usedApiVersion, usedDataset, urlQuery] = match, parts = parseApiQueryString(new URLSearchParams(urlQuery));
2523
2969
  if (!parts) return null;
@@ -2655,20 +3101,21 @@ function VisionGui(props) {
2655
3101
  editorRef: editorParamsRef
2656
3102
  }), $[163] = handleParamsChange, $[164] = params.error, $[165] = params.raw, $[166] = params.valid, $[167] = t60) : t60 = $[167];
2657
3103
  let t61;
2658
- $[168] !== handleListenExecution || $[169] !== handleQueryExecution || $[170] !== listenInProgress || $[171] !== params.valid || $[172] !== queryInProgress ? (t61 = /* @__PURE__ */ jsx(VisionGuiControls, {
3104
+ $[168] !== handleListenExecution || $[169] !== handleQueryExecution || $[170] !== listenInProgress || $[171] !== onSwitchToRedesign || $[172] !== params.valid || $[173] !== queryInProgress ? (t61 = /* @__PURE__ */ jsx(VisionGuiControls, {
2659
3105
  hasValidParams: params.valid,
2660
3106
  queryInProgress,
2661
3107
  listenInProgress,
2662
3108
  onQueryExecution: handleQueryExecution,
2663
- onListenExecution: handleListenExecution
2664
- }), $[168] = handleListenExecution, $[169] = handleQueryExecution, $[170] = listenInProgress, $[171] = params.valid, $[172] = queryInProgress, $[173] = t61) : t61 = $[173];
3109
+ onListenExecution: handleListenExecution,
3110
+ onSwitchToRedesign
3111
+ }), $[168] = handleListenExecution, $[169] = handleQueryExecution, $[170] = listenInProgress, $[171] = onSwitchToRedesign, $[172] = params.valid, $[173] = queryInProgress, $[174] = t61) : t61 = $[174];
2665
3112
  let t62;
2666
- $[174] !== t60 || $[175] !== t61 ? (t62 = /* @__PURE__ */ jsxs(InputContainer, {
3113
+ $[175] !== t60 || $[176] !== t61 ? (t62 = /* @__PURE__ */ jsxs(InputContainer, {
2667
3114
  display: "flex",
2668
3115
  children: [t60, t61]
2669
- }), $[174] = t60, $[175] = t61, $[176] = t62) : t62 = $[176];
3116
+ }), $[175] = t60, $[176] = t61, $[177] = t62) : t62 = $[177];
2670
3117
  let t63;
2671
- $[177] !== paneSizeOptions.allowResize || $[178] !== paneSizeOptions.maxSize || $[179] !== paneSizeOptions.size || $[180] !== t51 || $[181] !== t54 || $[182] !== t59 || $[183] !== t62 ? (t63 = /* @__PURE__ */ jsx(Box, {
3118
+ $[178] !== paneSizeOptions.allowResize || $[179] !== paneSizeOptions.maxSize || $[180] !== paneSizeOptions.size || $[181] !== t51 || $[182] !== t54 || $[183] !== t59 || $[184] !== t62 ? (t63 = /* @__PURE__ */ jsx(Box, {
2672
3119
  height: "stretch",
2673
3120
  flexBasis: "0%",
2674
3121
  flexGrow: 1,
@@ -2683,15 +3130,15 @@ function VisionGui(props) {
2683
3130
  primary: "first",
2684
3131
  children: [t59, t62]
2685
3132
  })
2686
- }), $[177] = paneSizeOptions.allowResize, $[178] = paneSizeOptions.maxSize, $[179] = paneSizeOptions.size, $[180] = t51, $[181] = t54, $[182] = t59, $[183] = t62, $[184] = t63) : t63 = $[184];
3133
+ }), $[178] = paneSizeOptions.allowResize, $[179] = paneSizeOptions.maxSize, $[180] = paneSizeOptions.size, $[181] = t51, $[182] = t54, $[183] = t59, $[184] = t62, $[185] = t63) : t63 = $[185];
2687
3134
  let t64;
2688
- $[185] !== perspective || $[186] !== perspectiveStack || $[187] !== scheduledDraftsStack ? (t64 = getActivePerspective({
3135
+ $[186] !== perspective || $[187] !== perspectiveStack || $[188] !== scheduledDraftsStack ? (t64 = getActivePerspective({
2689
3136
  visionPerspective: perspective,
2690
3137
  perspectiveStack,
2691
3138
  scheduledDraftsStack
2692
- }), $[185] = perspective, $[186] = perspectiveStack, $[187] = scheduledDraftsStack, $[188] = t64) : t64 = $[188];
3139
+ }), $[186] = perspective, $[187] = perspectiveStack, $[188] = scheduledDraftsStack, $[189] = t64) : t64 = $[189];
2693
3140
  let t65;
2694
- $[189] !== activeVariant || $[190] !== dataset || $[191] !== e2eTime || $[192] !== error || $[193] !== listenInProgress || $[194] !== listenMutations || $[195] !== queryInProgress || $[196] !== queryResult || $[197] !== queryTime || $[198] !== t64 || $[199] !== userApiVersion ? (t65 = /* @__PURE__ */ jsx(VisionGuiResult, {
3141
+ $[190] !== activeVariant || $[191] !== dataset || $[192] !== e2eTime || $[193] !== error || $[194] !== listenInProgress || $[195] !== listenMutations || $[196] !== queryInProgress || $[197] !== queryResult || $[198] !== queryTime || $[199] !== t64 || $[200] !== userApiVersion ? (t65 = /* @__PURE__ */ jsx(VisionGuiResult, {
2695
3142
  error,
2696
3143
  apiVersion: userApiVersion,
2697
3144
  perspective: t64,
@@ -2703,9 +3150,9 @@ function VisionGui(props) {
2703
3150
  dataset,
2704
3151
  queryTime,
2705
3152
  e2eTime
2706
- }), $[189] = activeVariant, $[190] = dataset, $[191] = e2eTime, $[192] = error, $[193] = listenInProgress, $[194] = listenMutations, $[195] = queryInProgress, $[196] = queryResult, $[197] = queryTime, $[198] = t64, $[199] = userApiVersion, $[200] = t65) : t65 = $[200];
3153
+ }), $[190] = activeVariant, $[191] = dataset, $[192] = e2eTime, $[193] = error, $[194] = listenInProgress, $[195] = listenMutations, $[196] = queryInProgress, $[197] = queryResult, $[198] = queryTime, $[199] = t64, $[200] = userApiVersion, $[201] = t65) : t65 = $[201];
2707
3154
  let t66;
2708
- $[201] !== t50 || $[202] !== t63 || $[203] !== t65 ? (t66 = /* @__PURE__ */ jsx(Box, {
3155
+ $[202] !== t50 || $[203] !== t63 || $[204] !== t65 ? (t66 = /* @__PURE__ */ jsx(Box, {
2709
3156
  height: "stretch",
2710
3157
  flexBasis: "0%",
2711
3158
  flexGrow: 1,
@@ -2715,52 +3162,52 @@ function VisionGui(props) {
2715
3162
  minSize: 300,
2716
3163
  children: [t63, t65]
2717
3164
  })
2718
- }), $[201] = t50, $[202] = t63, $[203] = t65, $[204] = t66) : t66 = $[204];
3165
+ }), $[202] = t50, $[203] = t63, $[204] = t65, $[205] = t66) : t66 = $[205];
2719
3166
  let t67;
2720
- $[205] === Symbol.for("react.memo_cache_sentinel") ? (t67 = {
3167
+ $[206] === Symbol.for("react.memo_cache_sentinel") ? (t67 = {
2721
3168
  position: "absolute",
2722
3169
  left: -32,
2723
3170
  top: "50%",
2724
3171
  transform: "translateY(-50%)",
2725
3172
  zIndex: 100,
2726
3173
  pointerEvents: "auto"
2727
- }, $[205] = t67) : t67 = $[205];
3174
+ }, $[206] = t67) : t67 = $[206];
2728
3175
  let t68;
2729
- $[206] === isQueryRecallCollapsed ? t68 = $[207] : (t68 = () => setIsQueryRecallCollapsed(!isQueryRecallCollapsed), $[206] = isQueryRecallCollapsed, $[207] = t68);
3176
+ $[207] === isQueryRecallCollapsed ? t68 = $[208] : (t68 = () => setIsQueryRecallCollapsed(!isQueryRecallCollapsed), $[207] = isQueryRecallCollapsed, $[208] = t68);
2730
3177
  let t69;
2731
- $[208] === Symbol.for("react.memo_cache_sentinel") ? (t69 = {
3178
+ $[209] === Symbol.for("react.memo_cache_sentinel") ? (t69 = {
2732
3179
  display: "flex",
2733
3180
  alignItems: "center",
2734
3181
  height: "100%"
2735
- }, $[208] = t69) : t69 = $[208];
3182
+ }, $[209] = t69) : t69 = $[209];
2736
3183
  let t70;
2737
- $[209] === isQueryRecallCollapsed ? t70 = $[210] : (t70 = /* @__PURE__ */ jsx("div", {
3184
+ $[210] === isQueryRecallCollapsed ? t70 = $[211] : (t70 = /* @__PURE__ */ jsx("div", {
2738
3185
  style: t69,
2739
3186
  children: jsx(isQueryRecallCollapsed ? ChevronLeftIcon : ChevronRightIcon, {})
2740
- }), $[209] = isQueryRecallCollapsed, $[210] = t70);
3187
+ }), $[210] = isQueryRecallCollapsed, $[211] = t70);
2741
3188
  let t71;
2742
- $[211] !== t68 || $[212] !== t70 ? (t71 = /* @__PURE__ */ jsx(Button, {
3189
+ $[212] !== t68 || $[213] !== t70 ? (t71 = /* @__PURE__ */ jsx(Button, {
2743
3190
  mode: "ghost",
2744
3191
  padding: 2,
2745
3192
  style: t67,
2746
3193
  onClick: t68,
2747
3194
  children: t70
2748
- }), $[211] = t68, $[212] = t70, $[213] = t71) : t71 = $[213];
3195
+ }), $[212] = t68, $[213] = t70, $[214] = t71) : t71 = $[214];
2749
3196
  let t72;
2750
- $[214] === params.parsed ? t72 = $[215] : (t72 = params.parsed || {}, $[214] = params.parsed, $[215] = t72);
3197
+ $[215] === params.parsed ? t72 = $[216] : (t72 = params.parsed || {}, $[215] = params.parsed, $[216] = t72);
2751
3198
  let t73;
2752
- $[216] !== generateUrl || $[217] !== getStateFromUrl || $[218] !== query || $[219] !== setStateFromParsedUrl || $[220] !== t72 || $[221] !== url ? (t73 = /* @__PURE__ */ jsx(QueryRecallPaneWrapper, { children: /* @__PURE__ */ jsx(QueryRecall, {
3199
+ $[217] !== generateUrl || $[218] !== getStateFromUrl || $[219] !== query || $[220] !== setStateFromParsedUrl || $[221] !== t72 || $[222] !== url ? (t73 = /* @__PURE__ */ jsx(QueryRecallPaneWrapper, { children: /* @__PURE__ */ jsx(QueryRecall, {
2753
3200
  url,
2754
3201
  getStateFromUrl,
2755
3202
  setStateFromParsedUrl,
2756
3203
  currentQuery: query,
2757
3204
  currentParams: t72,
2758
3205
  generateUrl
2759
- }) }), $[216] = generateUrl, $[217] = getStateFromUrl, $[218] = query, $[219] = setStateFromParsedUrl, $[220] = t72, $[221] = url, $[222] = t73) : t73 = $[222];
3206
+ }) }), $[217] = generateUrl, $[218] = getStateFromUrl, $[219] = query, $[220] = setStateFromParsedUrl, $[221] = t72, $[222] = url, $[223] = t73) : t73 = $[223];
2760
3207
  let t74;
2761
- $[223] !== t71 || $[224] !== t73 ? (t74 = /* @__PURE__ */ jsxs(QueryRecallPaneContainer, { children: [t71, t73] }), $[223] = t71, $[224] = t73, $[225] = t74) : t74 = $[225];
3208
+ $[224] !== t71 || $[225] !== t73 ? (t74 = /* @__PURE__ */ jsxs(QueryRecallPaneContainer, { children: [t71, t73] }), $[224] = t71, $[225] = t73, $[226] = t74) : t74 = $[226];
2762
3209
  let t75;
2763
- $[226] !== t49 || $[227] !== t66 || $[228] !== t74 ? (t75 = /* @__PURE__ */ jsx(SplitpaneContainer, {
3210
+ $[227] !== t49 || $[228] !== t66 || $[229] !== t74 ? (t75 = /* @__PURE__ */ jsx(SplitpaneContainer, {
2764
3211
  flexBasis: "auto",
2765
3212
  flexGrow: 1,
2766
3213
  flexShrink: 1,
@@ -2772,21 +3219,21 @@ function VisionGui(props) {
2772
3219
  primary: "first",
2773
3220
  children: [t66, t74]
2774
3221
  })
2775
- }), $[226] = t49, $[227] = t66, $[228] = t74, $[229] = t75) : t75 = $[229];
3222
+ }), $[227] = t49, $[228] = t66, $[229] = t74, $[230] = t75) : t75 = $[230];
2776
3223
  let t76;
2777
- return $[230] !== t48 || $[231] !== t75 ? (t76 = /* @__PURE__ */ jsxs(Root, {
3224
+ return $[231] !== t48 || $[232] !== t75 ? (t76 = /* @__PURE__ */ jsxs(Root, {
2778
3225
  flexDirection: "column",
2779
3226
  height: "100%",
2780
3227
  ref: visionRootRef,
2781
3228
  overflow: "hidden",
2782
3229
  "data-testid": "vision-root",
2783
3230
  children: [t48, t75]
2784
- }), $[230] = t48, $[231] = t75, $[232] = t76) : t76 = $[232], t76;
3231
+ }), $[231] = t48, $[232] = t75, $[233] = t76) : t76 = $[233], t76;
2785
3232
  }
2786
3233
  function _temp2$1(release_0) {
2787
3234
  return getReleaseIdFromReleaseDocumentId(release_0._id);
2788
3235
  }
2789
- function _temp$1(release) {
3236
+ function _temp$2(release) {
2790
3237
  return isCardinalityOneRelease(release) && release.state === "scheduled";
2791
3238
  }
2792
3239
  function useDatasets(t0) {
@@ -2800,7 +3247,7 @@ function useDatasets(t0) {
2800
3247
  let t2;
2801
3248
  if ($[2] !== client.observable.datasets || $[3] !== configDatasets) {
2802
3249
  let t3;
2803
- $[5] === configDatasets ? t3 = $[6] : (t3 = (result) => typeof configDatasets == "function" ? configDatasets(result).map(_temp) : result.map(_temp2), $[5] = configDatasets, $[6] = t3), t2 = client.observable.datasets.list().pipe(map$1(t3), catchError(_temp3)), $[2] = client.observable.datasets, $[3] = configDatasets, $[4] = t2;
3250
+ $[5] === configDatasets ? t3 = $[6] : (t3 = (result) => typeof configDatasets == "function" ? configDatasets(result).map(_temp$1) : result.map(_temp2), $[5] = configDatasets, $[6] = t3), t2 = client.observable.datasets.list().pipe(map(t3), catchError(_temp3)), $[2] = client.observable.datasets, $[3] = configDatasets, $[4] = t2;
2804
3251
  } else t2 = $[4];
2805
3252
  t1 = t2;
2806
3253
  }
@@ -2812,7 +3259,7 @@ function _temp3(err) {
2812
3259
  function _temp2(ds) {
2813
3260
  return ds.name;
2814
3261
  }
2815
- function _temp(d) {
3262
+ function _temp$1(d) {
2816
3263
  return d.name;
2817
3264
  }
2818
3265
  function VisionContainer(props) {
@@ -2840,21 +3287,17 @@ function VisionContainer(props) {
2840
3287
  }), $[5] = datasetsPromise, $[6] = props, $[7] = t3) : t3 = $[7], t3;
2841
3288
  }
2842
3289
  function LoadedVisionContainer(t0) {
2843
- let $ = c(17), datasetsPromise, props;
2844
- $[0] === t0 ? (datasetsPromise = $[1], props = $[2]) : ({datasetsPromise, ...props} = t0, $[0] = t0, $[1] = datasetsPromise, $[2] = props);
2845
- let loadedDatasets = use(datasetsPromise), t1;
2846
- $[3] !== loadedDatasets || $[4] !== props.client ? (t1 = loadedDatasets instanceof Error ? [props.client.config().dataset || "production"] : loadedDatasets, $[3] = loadedDatasets, $[4] = props.client, $[5] = t1) : t1 = $[5];
2847
- let datasets = t1, t2;
2848
- $[6] === props.client ? t2 = $[7] : (t2 = props.client.config(), $[6] = props.client, $[7] = t2);
2849
- let projectId = t2.projectId, t3;
2850
- $[8] !== datasets || $[9] !== props.client || $[10] !== props.config.defaultDataset ? (t3 = props.config.defaultDataset || props.client.config().dataset || datasets[0], $[8] = datasets, $[9] = props.client, $[10] = props.config.defaultDataset, $[11] = t3) : t3 = $[11];
2851
- let defaultDataset = t3, t4;
2852
- return $[12] !== datasets || $[13] !== defaultDataset || $[14] !== projectId || $[15] !== props ? (t4 = /* @__PURE__ */ jsx(VisionGui, {
2853
- ...props,
2854
- datasets,
2855
- projectId,
2856
- defaultDataset
2857
- }, projectId), $[12] = datasets, $[13] = defaultDataset, $[14] = projectId, $[15] = props, $[16] = t4) : t4 = $[16], t4;
3290
+ let $ = c(11), { children, client, config, datasetsPromise } = t0, loadedDatasets = use(datasetsPromise), T0, t1, t2;
3291
+ if ($[0] !== children || $[1] !== client || $[2] !== config.defaultDataset || $[3] !== loadedDatasets) {
3292
+ let clientConfig = client.config(), datasets = loadedDatasets instanceof Error ? [clientConfig.dataset || "production"] : loadedDatasets, projectId = clientConfig.projectId || "default", defaultDataset = config.defaultDataset || clientConfig.dataset || datasets[0];
3293
+ T0 = Fragment, t1 = projectId, t2 = children({
3294
+ datasets,
3295
+ projectId,
3296
+ defaultDataset
3297
+ }), $[0] = children, $[1] = client, $[2] = config.defaultDataset, $[3] = loadedDatasets, $[4] = T0, $[5] = t1, $[6] = t2;
3298
+ } else T0 = $[4], t1 = $[5], t2 = $[6];
3299
+ let t3;
3300
+ return $[7] !== T0 || $[8] !== t1 || $[9] !== t2 ? (t3 = /* @__PURE__ */ jsx(T0, { children: t2 }, t1), $[7] = T0, $[8] = t1, $[9] = t2, $[10] = t3) : t3 = $[10], t3;
2858
3301
  }
2859
3302
  /**
2860
3303
  * @internal
@@ -2869,10 +3312,12 @@ var VisionErrorBoundary = class extends Component {
2869
3312
  static getDerivedStateFromError(error) {
2870
3313
  return { error: error instanceof Error ? error.message : `${error}` };
2871
3314
  }
2872
- handleRetryRender = () => this.setState((prev) => ({
2873
- error: null,
2874
- numRetries: prev.numRetries + 1
2875
- }));
3315
+ handleRetryRender = () => {
3316
+ this.props.onRetry?.(), this.setState((prev) => ({
3317
+ error: null,
3318
+ numRetries: prev.numRetries + 1
3319
+ }));
3320
+ };
2876
3321
  handleRetryWithCacheClear = () => {
2877
3322
  clearLocalStorage(), this.handleRetryRender();
2878
3323
  };
@@ -2922,8 +3367,173 @@ var VisionErrorBoundary = class extends Component {
2922
3367
  });
2923
3368
  }
2924
3369
  };
3370
+ /**
3371
+ * A `lazy()` component whose failed import can be tried again. React keeps a rejected `lazy()`
3372
+ * for good, so `retry` (for the error boundary's Retry) swaps in a fresh one. The rejected one
3373
+ * stays until then: swapped as soon as the import fails, the Suspense boundary's next render
3374
+ * would start another import instead of surfacing the error, so a chunk that keeps failing
3375
+ * would be fetched over and over and never reach the error boundary.
3376
+ */
3377
+ function createRetryableLazy(load) {
3378
+ let failed = !1, attempt = () => load().catch((error) => {
3379
+ throw failed = !0, error;
3380
+ }), LazyComponent = lazy(attempt);
3381
+ function RetryableLazy(props) {
3382
+ let $ = c(2), t0;
3383
+ return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(LazyComponent, { ...props }), $[0] = props, $[1] = t0), t0;
3384
+ }
3385
+ return {
3386
+ Component: RetryableLazy,
3387
+ retry: () => {
3388
+ failed && (failed = !1, LazyComponent = lazy(attempt));
3389
+ }
3390
+ };
3391
+ }
3392
+ const TOAST_ID = "vision-redesign-invitation";
3393
+ /**
3394
+ * The toast's body. It renders in the studio's toast layer, which can sit outside the locale
3395
+ * provider that has Vision's strings, so it is handed them translated
3396
+ */
3397
+ function RedesignToastActions(props) {
3398
+ let $ = c(14), { description, acceptLabel, dismissLabel, onAccept, onDismiss } = props, t0;
3399
+ $[0] === description ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Text, {
3400
+ size: 1,
3401
+ children: description
3402
+ }), $[0] = description, $[1] = t0);
3403
+ let t1;
3404
+ $[2] !== acceptLabel || $[3] !== onAccept ? (t1 = /* @__PURE__ */ jsx(Button, {
3405
+ "data-testid": "vision-redesign-accept",
3406
+ fontSize: 1,
3407
+ onClick: onAccept,
3408
+ padding: 2,
3409
+ text: acceptLabel,
3410
+ tone: "primary"
3411
+ }), $[2] = acceptLabel, $[3] = onAccept, $[4] = t1) : t1 = $[4];
3412
+ let t2;
3413
+ $[5] !== dismissLabel || $[6] !== onDismiss ? (t2 = /* @__PURE__ */ jsx(Button, {
3414
+ "data-testid": "vision-redesign-dismiss",
3415
+ fontSize: 1,
3416
+ mode: "bleed",
3417
+ onClick: onDismiss,
3418
+ padding: 2,
3419
+ text: dismissLabel
3420
+ }), $[5] = dismissLabel, $[6] = onDismiss, $[7] = t2) : t2 = $[7];
3421
+ let t3;
3422
+ $[8] !== t1 || $[9] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Flex, {
3423
+ gap: 2,
3424
+ children: [t1, t2]
3425
+ }), $[8] = t1, $[9] = t2, $[10] = t3) : t3 = $[10];
3426
+ let t4;
3427
+ return $[11] !== t0 || $[12] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Stack, {
3428
+ gap: 3,
3429
+ paddingTop: 1,
3430
+ children: [t0, t3]
3431
+ }), $[11] = t0, $[12] = t3, $[13] = t4) : t4 = $[13], t4;
3432
+ }
3433
+ /**
3434
+ * Invites the user to try the redesigned Vision. Renders nothing itself: it pushes a persistent
3435
+ * toast while mounted and removes it again on unmount, so it disappears as soon as the user opts
3436
+ * in or leaves the tool.
3437
+ */
3438
+ function RedesignToast(t0) {
3439
+ let $ = c(8), { onAccept, onDismiss } = t0, toast = useToast(), { t } = useTranslation(visionLocaleNamespace), accept = useEffectEvent(onAccept), dismiss = useEffectEvent(onDismiss), t1;
3440
+ $[0] !== accept || $[1] !== dismiss || $[2] !== t || $[3] !== toast ? (t1 = () => {
3441
+ let remove = () => {
3442
+ toast.push({
3443
+ id: TOAST_ID,
3444
+ duration: .01
3445
+ });
3446
+ };
3447
+ return toast.push({
3448
+ id: TOAST_ID,
3449
+ closable: !1,
3450
+ duration: Infinity,
3451
+ status: "info",
3452
+ title: t("vista.redesign.toast.title"),
3453
+ description: /* @__PURE__ */ jsx(RedesignToastActions, {
3454
+ acceptLabel: t("vista.redesign.toast.accept"),
3455
+ description: t("vista.redesign.toast.description"),
3456
+ dismissLabel: t("vista.redesign.toast.dismiss"),
3457
+ onAccept: () => {
3458
+ remove(), accept();
3459
+ },
3460
+ onDismiss: () => {
3461
+ remove(), dismiss();
3462
+ }
3463
+ })
3464
+ }), remove;
3465
+ }, $[0] = accept, $[1] = dismiss, $[2] = t, $[3] = toast, $[4] = t1) : t1 = $[4];
3466
+ let t2;
3467
+ return $[5] !== t || $[6] !== toast ? (t2 = [t, toast], $[5] = t, $[6] = toast, $[7] = t2) : t2 = $[7], useEffect(t1, t2), null;
3468
+ }
3469
+ const DEFAULT_PREFERENCE = {
3470
+ optedIn: !1,
3471
+ dismissed: !1
3472
+ }, cache = /* @__PURE__ */ new Map(), listeners = /* @__PURE__ */ new Set();
3473
+ function storageKey(projectId) {
3474
+ return `${VISION_STORAGE_KEY_PREFIX}redesign:${projectId}`;
3475
+ }
3476
+ function notify() {
3477
+ listeners.forEach((listener) => listener());
3478
+ }
3479
+ function subscribe(listener) {
3480
+ listeners.add(listener);
3481
+ let unsubscribeClear = onLocalStorageCleared(() => {
3482
+ cache.clear(), listener();
3483
+ });
3484
+ return () => {
3485
+ listeners.delete(listener), unsubscribeClear();
3486
+ };
3487
+ }
3488
+ function parsePreference(raw) {
3489
+ if (raw === null) return DEFAULT_PREFERENCE;
3490
+ try {
3491
+ let stored = JSON.parse(raw);
3492
+ return isPlainObject(stored) ? {
3493
+ optedIn: stored.optedIn === !0,
3494
+ dismissed: stored.dismissed === !0
3495
+ } : DEFAULT_PREFERENCE;
3496
+ } catch {
3497
+ return DEFAULT_PREFERENCE;
3498
+ }
3499
+ }
3500
+ function readRedesignPreference(projectId) {
3501
+ let storage = getStorage(), cached = cache.get(projectId);
3502
+ if (!storage) return cached?.preference ?? DEFAULT_PREFERENCE;
3503
+ let raw = storage.getItem(storageKey(projectId));
3504
+ if (cached && cached.raw === raw) return cached.preference;
3505
+ let preference = parsePreference(raw);
3506
+ return cache.set(projectId, {
3507
+ raw,
3508
+ preference
3509
+ }), preference;
3510
+ }
3511
+ function writeRedesignPreference(projectId, patch) {
3512
+ let next = {
3513
+ ...readRedesignPreference(projectId),
3514
+ ...patch
3515
+ }, storage = getStorage(), raw = JSON.stringify(next);
3516
+ try {
3517
+ storage?.setItem(storageKey(projectId), raw);
3518
+ } catch {
3519
+ raw = storage?.getItem(storageKey(projectId)) ?? null;
3520
+ }
3521
+ return cache.set(projectId, {
3522
+ raw,
3523
+ preference: next
3524
+ }), notify(), next;
3525
+ }
3526
+ function useRedesignPreference(projectId) {
3527
+ let $ = c(2), t0;
3528
+ return $[0] === projectId ? t0 = $[1] : (t0 = () => readRedesignPreference(projectId), $[0] = projectId, $[1] = t0), useSyncExternalStore(subscribe, t0, _temp);
3529
+ }
3530
+ function _temp() {
3531
+ return DEFAULT_PREFERENCE;
3532
+ }
3533
+ var SanityVision_exports = /* @__PURE__ */ __exportAll({ default: () => SanityVision });
3534
+ const vistaGui = createRetryableLazy(() => import("./VistaGui-DdELkwzW.js").then((module) => ({ default: module.VistaGui }))), VistaGuiLoader = vistaGui.Component;
2925
3535
  function SanityVision(props) {
2926
- let $ = c(6), t0;
3536
+ let $ = c(31), t0;
2927
3537
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { apiVersion: "1" }, $[0] = t0) : t0 = $[0];
2928
3538
  let client = useClient(t0), t1;
2929
3539
  $[1] === props.tool.options ? t1 = $[2] : (t1 = {
@@ -2931,11 +3541,47 @@ function SanityVision(props) {
2931
3541
  ...props.tool.options
2932
3542
  }, $[1] = props.tool.options, $[2] = t1);
2933
3543
  let config = t1, t2;
2934
- return $[3] !== client || $[4] !== config ? (t2 = /* @__PURE__ */ jsx(VisionErrorBoundary, { children: /* @__PURE__ */ jsx(VisionContainer, {
3544
+ $[3] === client ? t2 = $[4] : (t2 = client.config().projectId || "default", $[3] = client, $[4] = t2);
3545
+ let projectId = t2, redesignEnabled = config.beta?.redesign?.enabled === !0, preference = useRedesignPreference(projectId), showRedesign = redesignEnabled && preference.optedIn, t3;
3546
+ $[5] === projectId ? t3 = $[6] : (t3 = () => writeRedesignPreference(projectId, {
3547
+ optedIn: !0,
3548
+ dismissed: !1
3549
+ }), $[5] = projectId, $[6] = t3);
3550
+ let optIn = t3, t4;
3551
+ $[7] === projectId ? t4 = $[8] : (t4 = () => writeRedesignPreference(projectId, { dismissed: !0 }), $[7] = projectId, $[8] = t4);
3552
+ let dismiss = t4, t5;
3553
+ $[9] === projectId ? t5 = $[10] : (t5 = () => writeRedesignPreference(projectId, {
3554
+ optedIn: !1,
3555
+ dismissed: !1
3556
+ }), $[9] = projectId, $[10] = t5);
3557
+ let switchToClassic = t5, t6;
3558
+ $[11] !== client || $[12] !== config || $[13] !== optIn || $[14] !== redesignEnabled || $[15] !== showRedesign || $[16] !== switchToClassic ? (t6 = (loaded) => showRedesign ? /* @__PURE__ */ jsx(VistaGuiLoader, {
3559
+ ...loaded,
3560
+ config,
3561
+ onSwitchToClassic: switchToClassic
3562
+ }) : /* @__PURE__ */ jsx(VisionGui, {
3563
+ ...loaded,
3564
+ client,
3565
+ config,
3566
+ onSwitchToRedesign: redesignEnabled ? optIn : void 0
3567
+ }), $[11] = client, $[12] = config, $[13] = optIn, $[14] = redesignEnabled, $[15] = showRedesign, $[16] = switchToClassic, $[17] = t6) : t6 = $[17];
3568
+ let t7;
3569
+ $[18] !== client || $[19] !== config || $[20] !== t6 ? (t7 = /* @__PURE__ */ jsx(VisionContainer, {
2935
3570
  client,
2936
- config
2937
- }) }), $[3] = client, $[4] = config, $[5] = t2) : t2 = $[5], t2;
3571
+ config,
3572
+ children: t6
3573
+ }), $[18] = client, $[19] = config, $[20] = t6, $[21] = t7) : t7 = $[21];
3574
+ let t8;
3575
+ $[22] !== dismiss || $[23] !== optIn || $[24] !== preference || $[25] !== redesignEnabled || $[26] !== showRedesign ? (t8 = redesignEnabled && !showRedesign && !preference.dismissed && /* @__PURE__ */ jsx(RedesignToast, {
3576
+ onAccept: optIn,
3577
+ onDismiss: dismiss
3578
+ }), $[22] = dismiss, $[23] = optIn, $[24] = preference, $[25] = redesignEnabled, $[26] = showRedesign, $[27] = t8) : t8 = $[27];
3579
+ let t9;
3580
+ return $[28] !== t7 || $[29] !== t8 ? (t9 = /* @__PURE__ */ jsxs(VisionErrorBoundary, {
3581
+ onRetry: vistaGui.retry,
3582
+ children: [t7, t8]
3583
+ }), $[28] = t7, $[29] = t8, $[30] = t9) : t9 = $[30], t9;
2938
3584
  }
2939
- export { SanityVision as default };
3585
+ export { VARIANTS_API_VERSION as A, getActivePerspective as C, resultJsonExtensions as D, paramsExtensions as E, API_VERSIONS as O, encodeQueryString as S, groqExtensions as T, VISION_STORAGE_KEY_PREFIX as _, getAtKeypath as a, isPlainObject as b, DelayedSpinner as c, getJsonBlobUrl as d, SanityVision as default, useSavedQueries as f, validateApiVersion as g, parseQueryUrl as h, describeKeypath as i, prefixApiVersion as j, DEFAULT_API_VERSION as k, canEncodeCsv as l, isApiCdnHost as m, createRetryableLazy as n, QueryErrorDialog as o, parseParams as p, ResultView as r, isApiVersionBelow as s, SanityVision_exports as t, getCsvBlobUrl as u, getStorage as v, VisionCodeMirror as w, isVisionPasteTarget as x, onLocalStorageCleared as y };
2940
3586
 
2941
- //# sourceMappingURL=SanityVision-CzPeT0iH.js.map
3587
+ //# sourceMappingURL=SanityVision-egTyQq4i.js.map