@sanity/themer 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,34 @@
1
1
  import { a as DEFAULT_BACKGROUND, c as resolveThemeOptions, d as hslToHex, f as relativeLuminance, i as DEFAULT_ACCENT, l as isColor, n as buildTheme, o as SCHEMES, r as buildPalette, s as deriveTextColor, u as hexToHsl } from "./presets-CqBgS3A-.js";
2
- import { a as displayTitle, c as resolveThemes, l as addThemerTransitionType, n as CONFIG_TITLE, t as CONFIG_SLUG } from "./themes-Bxgltjmb.js";
2
+ import { a as displayTitle, c as resolveThemes, l as addThemerTransitionType, n as CONFIG_TITLE, t as CONFIG_SLUG } from "./themes-au1BLKmY.js";
3
3
  import { c } from "react/compiler-runtime";
4
4
  import { useColorSchemeValue } from "sanity";
5
5
  import { Badge, BoundaryElementProvider, Box, Button, Card, Dialog, Flex, Layer, Stack, Text, TextInput, ThemeProvider, useMediaIndex, useRootTheme, useTheme_v2 } from "@sanity/ui";
6
6
  import { Tooltip } from "@sanity/ui/tooltip";
7
- import { Activity, createContext, startTransition, useContext, useEffect, useRef, useState } from "react";
7
+ import { Activity, createContext, startTransition, useContext, useEffect, useId, useRef, useState } from "react";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { dequal } from "dequal/lite";
10
10
  import { useSelector } from "@xstate/react";
11
11
  import { MotionConfig, Reorder, useDragControls } from "motion/react";
12
- import { ArrowLeftIcon } from "@sanity/icons/ArrowLeft";
13
12
  import { CloseIcon } from "@sanity/icons/Close";
14
- import { CodeBlockIcon } from "@sanity/icons/CodeBlock";
15
13
  import { SplitVerticalIcon } from "@sanity/icons/SplitVertical";
14
+ import { CheckmarkIcon } from "@sanity/icons/Checkmark";
16
15
  import { assignInlineVars } from "@vanilla-extract/dynamic";
16
+ import { EllipsisHorizontalIcon } from "@sanity/icons/EllipsisHorizontal";
17
17
  import { ResetIcon } from "@sanity/icons/Reset";
18
18
  import { TrashIcon } from "@sanity/icons/Trash";
19
+ import { Menu, MenuButton, MenuDivider, MenuItem } from "@sanity/ui/menu";
19
20
  import { SparklesIcon } from "@sanity/icons/Sparkles";
20
21
  import { ImageIcon } from "@sanity/icons/Image";
21
22
  import { useToast } from "@sanity/ui/toast";
22
23
  import { AddIcon } from "@sanity/icons/Add";
23
24
  import { ClipboardIcon } from "@sanity/icons/Clipboard";
25
+ import { CodeBlockIcon } from "@sanity/icons/CodeBlock";
26
+ import { CopyIcon } from "@sanity/icons/Copy";
27
+ import { EditIcon } from "@sanity/icons/Edit";
24
28
  import { RestoreIcon } from "@sanity/icons/Restore";
25
29
  import { ArrowDownIcon } from "@sanity/icons/ArrowDown";
26
30
  import { ArrowUpIcon } from "@sanity/icons/ArrowUp";
27
- import { CopyIcon } from "@sanity/icons/Copy";
28
- import { EditIcon } from "@sanity/icons/Edit";
29
- import { EllipsisHorizontalIcon } from "@sanity/icons/EllipsisHorizontal";
30
31
  import { ShareIcon } from "@sanity/icons/Share";
31
- import { Menu, MenuButton, MenuDivider, MenuItem } from "@sanity/ui/menu";
32
32
  import scrollIntoView from "scroll-into-view-if-needed";
33
33
  import { Code } from "@sanity/ui/code";
34
34
  import { registerLanguage } from "react-refractor";
@@ -279,13 +279,14 @@ var removedThumbnail = "_1vdkp0v0";
279
279
  /**
280
280
  * The flow for restoring removed themes: the presets and custom themes the
281
281
  * user took out of the list, each with a button to put it back — and, for
282
- * custom themes, one to delete it for good. The machine leaves the flow once
283
- * the last one is gone.
282
+ * custom themes, one to delete it for good. The footer leads back to the
283
+ * list, and the machine leaves the flow on its own once the last theme is
284
+ * gone.
284
285
  *
285
286
  * @internal
286
287
  */
287
288
  function RemovedThemes(t0) {
288
- let $ = c(7), { actorRef, removed } = t0, t1;
289
+ let $ = c(12), { actorRef, removed } = t0, t1;
289
290
  if ($[0] !== actorRef || $[1] !== removed) {
290
291
  let t2;
291
292
  $[3] === actorRef ? t2 = $[4] : (t2 = (theme) => /* @__PURE__ */ jsxs(Stack, {
@@ -327,13 +328,31 @@ function RemovedThemes(t0) {
327
328
  }, theme.slug), $[3] = actorRef, $[4] = t2), t1 = removed.map(t2), $[0] = actorRef, $[1] = removed, $[2] = t1;
328
329
  } else t1 = $[2];
329
330
  let t2;
330
- return $[5] === t1 ? t2 = $[6] : (t2 = /* @__PURE__ */ jsx(ScrollArea, {
331
+ $[5] === t1 ? t2 = $[6] : (t2 = /* @__PURE__ */ jsx(ScrollArea, {
331
332
  padding: 3,
332
333
  children: /* @__PURE__ */ jsx(Stack, {
333
334
  gap: 5,
334
335
  children: t1
335
336
  })
336
- }), $[5] = t1, $[6] = t2), t2;
337
+ }), $[5] = t1, $[6] = t2);
338
+ let t3;
339
+ $[7] === actorRef ? t3 = $[8] : (t3 = /* @__PURE__ */ jsx(Card, {
340
+ borderTop: !0,
341
+ padding: 3,
342
+ children: /* @__PURE__ */ jsx(Flex, {
343
+ justify: "flex-end",
344
+ children: /* @__PURE__ */ jsx(Button, {
345
+ gap: 2,
346
+ icon: CheckmarkIcon,
347
+ onClick: () => actorRef.send({ type: "flow.list" }),
348
+ padding: 2,
349
+ text: "Done",
350
+ mode: "ghost"
351
+ })
352
+ })
353
+ }), $[7] = actorRef, $[8] = t3);
354
+ let t4;
355
+ return $[9] !== t2 || $[10] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, t3] }), $[9] = t2, $[10] = t3, $[11] = t4) : t4 = $[11], t4;
337
356
  }
338
357
  /** The variants in the order the tool offers them @internal */
339
358
  const IMAGE_PALETTE_VARIANTS = [
@@ -664,8 +683,30 @@ function TooltipButton(props) {
664
683
  }), $[8] = t0, $[9] = t2, $[10] = t3) : t3 = $[10], t3;
665
684
  }
666
685
  /**
686
+ * The file picker for an image, as a hidden file input that a button or menu
687
+ * item clicks: the chosen file goes to `onFile`, and nowhere else — nothing
688
+ * is uploaded.
689
+ *
690
+ * @internal
691
+ */
692
+ function ImageFileInput(t0) {
693
+ let $ = c(5), { onFile, ref } = t0, t1;
694
+ $[0] === onFile ? t1 = $[1] : (t1 = (event) => {
695
+ let file = event.currentTarget.files?.[0];
696
+ event.currentTarget.value = "", file && onFile(file);
697
+ }, $[0] = onFile, $[1] = t1);
698
+ let t2;
699
+ return $[2] !== ref || $[3] !== t1 ? (t2 = /* @__PURE__ */ jsx("input", {
700
+ accept: "image/*",
701
+ hidden: !0,
702
+ onChange: t1,
703
+ ref,
704
+ type: "file"
705
+ }), $[2] = ref, $[3] = t1, $[4] = t2) : t2 = $[4], t2;
706
+ }
707
+ /**
667
708
  * A button that opens the file picker for an image, and hands the chosen file
668
- * over — the picker is a hidden file input, so nothing is uploaded anywhere.
709
+ * over.
669
710
  *
670
711
  * @internal
671
712
  */
@@ -681,15 +722,9 @@ function ImageFileButton(props) {
681
722
  onClick: t0
682
723
  }), $[4] = buttonProps, $[5] = t1);
683
724
  let t2;
684
- $[6] === onFile ? t2 = $[7] : (t2 = /* @__PURE__ */ jsx("input", {
685
- accept: "image/*",
686
- hidden: !0,
687
- onChange: (event) => {
688
- let file = event.currentTarget.files?.[0];
689
- event.currentTarget.value = "", file && onFile(file);
690
- },
691
- ref: inputRef,
692
- type: "file"
725
+ $[6] === onFile ? t2 = $[7] : (t2 = /* @__PURE__ */ jsx(ImageFileInput, {
726
+ onFile,
727
+ ref: inputRef
693
728
  }), $[6] = onFile, $[7] = t2);
694
729
  let t3;
695
730
  return $[8] !== t1 || $[9] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Fragment, { children: [t1, t2] }), $[8] = t1, $[9] = t2, $[10] = t3) : t3 = $[10], t3;
@@ -737,19 +772,15 @@ async function decodeImage(file) {
737
772
  * @internal
738
773
  */
739
774
  function useImagePalette(onPalette) {
740
- let $ = c(10), toast = useToast(), [busy, setBusy] = useState(!1), onPaletteRef = useRef(onPalette), mountedRef = useRef(!0), latestPickRef = useRef(0), t0, t1;
775
+ let $ = c(8), toast = useToast(), [busy, setBusy] = useState(!1), onPaletteRef = useRef(onPalette), latestPickRef = useRef(0), t0, t1;
741
776
  $[0] === onPalette ? (t0 = $[1], t1 = $[2]) : (t0 = () => {
742
777
  onPaletteRef.current = onPalette;
743
778
  }, t1 = [onPalette], $[0] = onPalette, $[1] = t0, $[2] = t1), useEffect(t0, t1);
744
- let t2, t3;
745
- $[3] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => (mountedRef.current = !0, () => {
746
- mountedRef.current = !1;
747
- }), t3 = [], $[3] = t2, $[4] = t3) : (t2 = $[3], t3 = $[4]), useEffect(t2, t3);
748
- let t4;
749
- $[5] === toast ? t4 = $[6] : (t4 = (file) => {
779
+ let t2;
780
+ $[3] === toast ? t2 = $[4] : (t2 = (file) => {
750
781
  let pick = latestPickRef.current += 1;
751
782
  setBusy(!0);
752
- let isCurrent = () => mountedRef.current && latestPickRef.current === pick, extract = async () => {
783
+ let isCurrent = () => latestPickRef.current === pick, extract = async () => {
753
784
  let palette = extractImagePalette(await readImagePixels(file));
754
785
  isCurrent() && (Object.values(palette).every(_temp$6) ? toast.push({
755
786
  status: "warning",
@@ -764,12 +795,12 @@ function useImagePalette(onPalette) {
764
795
  }).finally(() => {
765
796
  isCurrent() && setBusy(!1);
766
797
  });
767
- }, $[5] = toast, $[6] = t4);
768
- let pickImage = t4, t5;
769
- return $[7] !== busy || $[8] !== pickImage ? (t5 = {
798
+ }, $[3] = toast, $[4] = t2);
799
+ let pickImage = t2, t3;
800
+ return $[5] !== busy || $[6] !== pickImage ? (t3 = {
770
801
  busy,
771
802
  pickImage
772
- }, $[7] = busy, $[8] = pickImage, $[9] = t5) : t5 = $[9], t5;
803
+ }, $[5] = busy, $[6] = pickImage, $[7] = t3) : t3 = $[7], t3;
773
804
  }
774
805
  function _temp$6(swatch) {
775
806
  return swatch === null;
@@ -1072,7 +1103,7 @@ function _temp$4(snapshot) {
1072
1103
  return snapshot.context.images;
1073
1104
  }
1074
1105
  function ThemeEditorForm(props) {
1075
- let $ = c(49), { focusTitle, imageUrl, onDone, onLucky, onOptionsChange, onPalette, onRemove, onTitleChange, onVariant, options, palette, split, title } = props, studioScheme = useColorSchemeValue(), t0;
1106
+ let $ = c(53), { focusTitle, imageUrl, onDone, onLucky, onOptionsChange, onPalette, onRemove, onTitleChange, onVariant, options, palette, split, title } = props, studioScheme = useColorSchemeValue(), actionsId = useId(), t0;
1076
1107
  $[0] === options ? t0 = $[1] : (t0 = resolveThemeOptions(options), $[0] = options, $[1] = t0);
1077
1108
  let resolved = t0, t1;
1078
1109
  $[2] === options ? t1 = $[3] : (t1 = buildPalette(options), $[2] = options, $[3] = t1);
@@ -1145,38 +1176,54 @@ function ThemeEditorForm(props) {
1145
1176
  })
1146
1177
  }), $[33] = t10, $[34] = t3, $[35] = t7, $[36] = t8, $[37] = t11) : t11 = $[37];
1147
1178
  let t12;
1148
- $[38] === onRemove ? t12 = $[39] : (t12 = /* @__PURE__ */ jsx(TooltipButton, {
1179
+ $[38] === onDone ? t12 = $[39] : (t12 = /* @__PURE__ */ jsx(Button, {
1180
+ gap: 2,
1181
+ icon: CheckmarkIcon,
1182
+ onClick: onDone,
1183
+ padding: 2,
1184
+ text: "Done",
1185
+ mode: "ghost"
1186
+ }), $[38] = onDone, $[39] = t12);
1187
+ let t13;
1188
+ $[40] === Symbol.for("react.memo_cache_sentinel") ? (t13 = /* @__PURE__ */ jsx(Button, {
1189
+ "aria-label": "More actions",
1190
+ icon: EllipsisHorizontalIcon,
1191
+ mode: "bleed",
1192
+ padding: 2
1193
+ }), $[40] = t13) : t13 = $[40];
1194
+ let t14;
1195
+ $[41] === onRemove ? t14 = $[42] : (t14 = /* @__PURE__ */ jsx(Menu, { children: /* @__PURE__ */ jsx(MenuItem, {
1149
1196
  icon: TrashIcon,
1150
- mode: "ghost",
1151
1197
  onClick: onRemove,
1152
1198
  text: "Remove",
1153
- tone: "critical",
1154
- tooltip: "Remove the theme — it can be restored until it is deleted"
1155
- }), $[38] = onRemove, $[39] = t12);
1156
- let t13;
1157
- $[40] === Symbol.for("react.memo_cache_sentinel") ? (t13 = /* @__PURE__ */ jsx(Box, { flex: 1 }), $[40] = t13) : t13 = $[40];
1158
- let t14;
1159
- $[41] === onDone ? t14 = $[42] : (t14 = /* @__PURE__ */ jsx(Button, {
1160
- mode: "ghost",
1161
- onClick: onDone,
1162
- padding: 2,
1163
- text: "Done"
1164
- }), $[41] = onDone, $[42] = t14);
1199
+ tone: "critical"
1200
+ }) }), $[41] = onRemove, $[42] = t14);
1165
1201
  let t15;
1166
- $[43] !== t12 || $[44] !== t14 ? (t15 = /* @__PURE__ */ jsx(Card, {
1202
+ $[43] === Symbol.for("react.memo_cache_sentinel") ? (t15 = {
1203
+ animate: !0,
1204
+ placement: "top-end",
1205
+ portal: !0
1206
+ }, $[43] = t15) : t15 = $[43];
1207
+ let t16;
1208
+ $[44] !== actionsId || $[45] !== t14 ? (t16 = /* @__PURE__ */ jsx(MenuButton, {
1209
+ button: t13,
1210
+ id: actionsId,
1211
+ menu: t14,
1212
+ popover: t15
1213
+ }), $[44] = actionsId, $[45] = t14, $[46] = t16) : t16 = $[46];
1214
+ let t17;
1215
+ $[47] !== t12 || $[48] !== t16 ? (t17 = /* @__PURE__ */ jsx(Card, {
1167
1216
  borderTop: !0,
1168
1217
  padding: 3,
1169
1218
  children: /* @__PURE__ */ jsxs(Flex, {
1219
+ align: "center",
1170
1220
  gap: 2,
1171
- children: [
1172
- t12,
1173
- t13,
1174
- t14
1175
- ]
1221
+ justify: "flex-end",
1222
+ children: [t12, t16]
1176
1223
  })
1177
- }), $[43] = t12, $[44] = t14, $[45] = t15) : t15 = $[45];
1178
- let t16;
1179
- return $[46] !== t11 || $[47] !== t15 ? (t16 = /* @__PURE__ */ jsxs(Fragment, { children: [t11, t15] }), $[46] = t11, $[47] = t15, $[48] = t16) : t16 = $[48], t16;
1224
+ }), $[47] = t12, $[48] = t16, $[49] = t17) : t17 = $[49];
1225
+ let t18;
1226
+ return $[50] !== t11 || $[51] !== t17 ? (t18 = /* @__PURE__ */ jsxs(Fragment, { children: [t11, t17] }), $[50] = t11, $[51] = t17, $[52] = t18) : t18 = $[52], t18;
1180
1227
  }
1181
1228
  function _temp2(event_0) {
1182
1229
  return event_0.currentTarget.select();
@@ -1577,9 +1624,9 @@ function isEditable(target) {
1577
1624
  * @internal
1578
1625
  */
1579
1626
  function PasteThemeDialog(props) {
1580
- let $ = c(37), { actorRef, onClose } = props, t0;
1627
+ let $ = c(39), { actorRef, onClose } = props, t0;
1581
1628
  $[0] === actorRef ? t0 = $[1] : (t0 = { actorRef }, $[0] = actorRef, $[1] = t0);
1582
- let { addThemeFromText } = useThemeCodes(t0), [text, setText] = useState(""), [invalid, setInvalid] = useState(!1), t1;
1629
+ let { addThemeFromText } = useThemeCodes(t0), [text, setText] = useState(""), [invalid, setInvalid] = useState(!1), id = useId(), errorId = `${id}-error`, t1;
1583
1630
  $[2] !== addThemeFromText || $[3] !== onClose || $[4] !== text ? (t1 = () => {
1584
1631
  addThemeFromText(text) ? onClose() : setInvalid(!0);
1585
1632
  }, $[2] = addThemeFromText, $[3] = onClose, $[4] = text, $[5] = t1) : t1 = $[5];
@@ -1617,7 +1664,7 @@ function PasteThemeDialog(props) {
1617
1664
  size: 1,
1618
1665
  children: "Paste the code someone copied from their themer — the theme is added to your list and applied."
1619
1666
  }), $[18] = t8) : t8 = $[18];
1620
- let t9 = invalid ? "themer-paste-error" : void 0, t10 = invalid ? "That is not a theme code" : void 0, t11;
1667
+ let t9 = invalid ? errorId : void 0, t10 = invalid ? "That is not a theme code" : void 0, t11;
1621
1668
  $[19] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (event_0) => {
1622
1669
  setText(event_0.currentTarget.value), setInvalid(!1);
1623
1670
  }, $[19] = t11) : t11 = $[19];
@@ -1634,8 +1681,8 @@ function PasteThemeDialog(props) {
1634
1681
  value: text
1635
1682
  }), $[20] = invalid, $[21] = t10, $[22] = t9, $[23] = text, $[24] = t12) : t12 = $[24];
1636
1683
  let t13;
1637
- $[25] === invalid ? t13 = $[26] : (t13 = invalid && /* @__PURE__ */ jsx(Card, {
1638
- id: "themer-paste-error",
1684
+ $[25] !== errorId || $[26] !== invalid ? (t13 = invalid && /* @__PURE__ */ jsx(Card, {
1685
+ id: errorId,
1639
1686
  padding: 3,
1640
1687
  radius: 2,
1641
1688
  role: "alert",
@@ -1644,9 +1691,9 @@ function PasteThemeDialog(props) {
1644
1691
  size: 1,
1645
1692
  children: "That is not a theme code — codes are one word, copied from a theme's menu."
1646
1693
  })
1647
- }), $[25] = invalid, $[26] = t13);
1694
+ }), $[25] = errorId, $[26] = invalid, $[27] = t13) : t13 = $[27];
1648
1695
  let t14;
1649
- $[27] !== t12 || $[28] !== t13 ? (t14 = /* @__PURE__ */ jsxs(Stack, {
1696
+ $[28] !== t12 || $[29] !== t13 ? (t14 = /* @__PURE__ */ jsxs(Stack, {
1650
1697
  gap: 3,
1651
1698
  padding: 4,
1652
1699
  children: [
@@ -1654,23 +1701,23 @@ function PasteThemeDialog(props) {
1654
1701
  t12,
1655
1702
  t13
1656
1703
  ]
1657
- }), $[27] = t12, $[28] = t13, $[29] = t14) : t14 = $[29];
1704
+ }), $[28] = t12, $[29] = t13, $[30] = t14) : t14 = $[30];
1658
1705
  let t15;
1659
- $[30] !== t14 || $[31] !== t7 ? (t15 = /* @__PURE__ */ jsx("form", {
1706
+ $[31] !== t14 || $[32] !== t7 ? (t15 = /* @__PURE__ */ jsx("form", {
1660
1707
  onSubmit: t7,
1661
1708
  children: t14
1662
- }), $[30] = t14, $[31] = t7, $[32] = t15) : t15 = $[32];
1709
+ }), $[31] = t14, $[32] = t7, $[33] = t15) : t15 = $[33];
1663
1710
  let t16;
1664
- return $[33] !== onClose || $[34] !== t15 || $[35] !== t6 ? (t16 = /* @__PURE__ */ jsx(Dialog, {
1711
+ return $[34] !== id || $[35] !== onClose || $[36] !== t15 || $[37] !== t6 ? (t16 = /* @__PURE__ */ jsx(Dialog, {
1665
1712
  animate: !0,
1666
1713
  footer: t6,
1667
1714
  header: "Add a shared theme",
1668
- id: "themer-paste",
1715
+ id,
1669
1716
  onClickOutside: onClose,
1670
1717
  onClose,
1671
1718
  width: 0,
1672
1719
  children: t15
1673
- }), $[33] = onClose, $[34] = t15, $[35] = t6, $[36] = t16) : t16 = $[36], t16;
1720
+ }), $[34] = id, $[35] = onClose, $[36] = t15, $[37] = t6, $[38] = t16) : t16 = $[38], t16;
1674
1721
  }
1675
1722
  var frame$1 = "_1wsn7882", menuCard = "_1wsn7884", menuSlot = "_1wsn7883", pickButton = "_1wsn7881", root = "_1wsn7880";
1676
1723
  /**
@@ -1696,7 +1743,7 @@ function scrollRefIntoViewIfNeeded(node) {
1696
1743
  function ThemeCard(t0) {
1697
1744
  let $ = c(79), { actorRef, active, theme, themes } = t0, t1;
1698
1745
  $[0] === actorRef ? t1 = $[1] : (t1 = { actorRef }, $[0] = actorRef, $[1] = t1);
1699
- let { copyTheme } = useThemeCodes(t1), { scheme } = useRootTheme(), [menuOpen, setMenuOpen] = useState(!1), dragControls = useDragControls(), dragged = useRef(!1), t2;
1746
+ let { copyTheme } = useThemeCodes(t1), { scheme } = useRootTheme(), [menuOpen, setMenuOpen] = useState(!1), dragControls = useDragControls(), menuId = useId(), dragged = useRef(!1), t2;
1700
1747
  $[2] === theme.title ? t2 = $[3] : (t2 = displayTitle(theme.title), $[2] = theme.title, $[3] = t2);
1701
1748
  let title = t2, t3;
1702
1749
  $[4] === theme.slug ? t3 = $[5] : (t3 = (candidate) => candidate.slug === theme.slug, $[4] = theme.slug, $[5] = t3);
@@ -1772,8 +1819,8 @@ function ThemeCard(t0) {
1772
1819
  padding: 1,
1773
1820
  radius: 2
1774
1821
  }), $[31] = t16, $[32] = t17);
1775
- let t18 = `themer-theme-${theme.slug}`, t19;
1776
- $[33] !== index || $[34] !== listed || $[35] !== moveTo || $[36] !== themes.length ? (t19 = listed && /* @__PURE__ */ jsxs(Fragment, { children: [
1822
+ let t18;
1823
+ $[33] !== index || $[34] !== listed || $[35] !== moveTo || $[36] !== themes.length ? (t18 = listed && /* @__PURE__ */ jsxs(Fragment, { children: [
1777
1824
  /* @__PURE__ */ jsx(MenuItem, {
1778
1825
  disabled: index <= 0,
1779
1826
  icon: ArrowUpIcon,
@@ -1787,35 +1834,35 @@ function ThemeCard(t0) {
1787
1834
  text: "Move down"
1788
1835
  }),
1789
1836
  /* @__PURE__ */ jsx(MenuDivider, {})
1790
- ] }), $[33] = index, $[34] = listed, $[35] = moveTo, $[36] = themes.length, $[37] = t19) : t19 = $[37];
1791
- let t20;
1792
- $[38] !== actorRef || $[39] !== theme.slug || $[40] !== theme.source ? (t20 = theme.source === "custom" && /* @__PURE__ */ jsx(MenuItem, {
1837
+ ] }), $[33] = index, $[34] = listed, $[35] = moveTo, $[36] = themes.length, $[37] = t18) : t18 = $[37];
1838
+ let t19;
1839
+ $[38] !== actorRef || $[39] !== theme.slug || $[40] !== theme.source ? (t19 = theme.source === "custom" && /* @__PURE__ */ jsx(MenuItem, {
1793
1840
  icon: EditIcon,
1794
1841
  onClick: () => actorRef.send({
1795
1842
  type: "theme.edit",
1796
1843
  slug: theme.slug
1797
1844
  }),
1798
1845
  text: "Edit"
1799
- }), $[38] = actorRef, $[39] = theme.slug, $[40] = theme.source, $[41] = t20) : t20 = $[41];
1800
- let t21;
1801
- $[42] !== actorRef || $[43] !== theme.slug ? (t21 = () => actorRef.send({
1846
+ }), $[38] = actorRef, $[39] = theme.slug, $[40] = theme.source, $[41] = t19) : t19 = $[41];
1847
+ let t20;
1848
+ $[42] !== actorRef || $[43] !== theme.slug ? (t20 = () => actorRef.send({
1802
1849
  type: "theme.duplicate",
1803
1850
  slug: theme.slug
1804
- }), $[42] = actorRef, $[43] = theme.slug, $[44] = t21) : t21 = $[44];
1805
- let t22 = theme.source === "custom" ? "Duplicate" : "Duplicate to edit", t23;
1806
- $[45] !== t21 || $[46] !== t22 ? (t23 = /* @__PURE__ */ jsx(MenuItem, {
1851
+ }), $[42] = actorRef, $[43] = theme.slug, $[44] = t20) : t20 = $[44];
1852
+ let t21 = theme.source === "custom" ? "Duplicate" : "Duplicate to edit", t22;
1853
+ $[45] !== t20 || $[46] !== t21 ? (t22 = /* @__PURE__ */ jsx(MenuItem, {
1807
1854
  icon: CopyIcon,
1808
- onClick: t21,
1809
- text: t22
1810
- }), $[45] = t21, $[46] = t22, $[47] = t23) : t23 = $[47];
1811
- let t24;
1812
- $[48] !== copyTheme || $[49] !== theme ? (t24 = /* @__PURE__ */ jsx(MenuItem, {
1855
+ onClick: t20,
1856
+ text: t21
1857
+ }), $[45] = t20, $[46] = t21, $[47] = t22) : t22 = $[47];
1858
+ let t23;
1859
+ $[48] !== copyTheme || $[49] !== theme ? (t23 = /* @__PURE__ */ jsx(MenuItem, {
1813
1860
  icon: ShareIcon,
1814
1861
  onClick: () => void copyTheme(theme),
1815
1862
  text: "Copy to share"
1816
- }), $[48] = copyTheme, $[49] = theme, $[50] = t24) : t24 = $[50];
1817
- let t25;
1818
- $[51] !== actorRef || $[52] !== theme.slug || $[53] !== theme.source ? (t25 = theme.source !== "config" && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MenuDivider, {}), /* @__PURE__ */ jsx(MenuItem, {
1863
+ }), $[48] = copyTheme, $[49] = theme, $[50] = t23) : t23 = $[50];
1864
+ let t24;
1865
+ $[51] !== actorRef || $[52] !== theme.slug || $[53] !== theme.source ? (t24 = theme.source !== "config" && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MenuDivider, {}), /* @__PURE__ */ jsx(MenuItem, {
1819
1866
  icon: TrashIcon,
1820
1867
  onClick: () => actorRef.send({
1821
1868
  type: "theme.remove",
@@ -1823,26 +1870,26 @@ function ThemeCard(t0) {
1823
1870
  }),
1824
1871
  text: "Remove",
1825
1872
  tone: "critical"
1826
- })] }), $[51] = actorRef, $[52] = theme.slug, $[53] = theme.source, $[54] = t25) : t25 = $[54];
1827
- let t26;
1828
- $[55] !== t19 || $[56] !== t20 || $[57] !== t23 || $[58] !== t24 || $[59] !== t25 ? (t26 = /* @__PURE__ */ jsxs(Menu, { children: [
1873
+ })] }), $[51] = actorRef, $[52] = theme.slug, $[53] = theme.source, $[54] = t24) : t24 = $[54];
1874
+ let t25;
1875
+ $[55] !== t18 || $[56] !== t19 || $[57] !== t22 || $[58] !== t23 || $[59] !== t24 ? (t25 = /* @__PURE__ */ jsxs(Menu, { children: [
1876
+ t18,
1829
1877
  t19,
1830
- t20,
1878
+ t22,
1831
1879
  t23,
1832
- t24,
1833
- t25
1834
- ] }), $[55] = t19, $[56] = t20, $[57] = t23, $[58] = t24, $[59] = t25, $[60] = t26) : t26 = $[60];
1835
- let t27, t28;
1836
- $[61] === Symbol.for("react.memo_cache_sentinel") ? (t27 = () => setMenuOpen(!1), t28 = () => setMenuOpen(!0), $[61] = t27, $[62] = t28) : (t27 = $[61], t28 = $[62]);
1837
- let t29;
1838
- $[63] === scheme ? t29 = $[64] : (t29 = {
1880
+ t24
1881
+ ] }), $[55] = t18, $[56] = t19, $[57] = t22, $[58] = t23, $[59] = t24, $[60] = t25) : t25 = $[60];
1882
+ let t26, t27;
1883
+ $[61] === Symbol.for("react.memo_cache_sentinel") ? (t26 = () => setMenuOpen(!1), t27 = () => setMenuOpen(!0), $[61] = t26, $[62] = t27) : (t26 = $[61], t27 = $[62]);
1884
+ let t28;
1885
+ $[63] === scheme ? t28 = $[64] : (t28 = {
1839
1886
  animate: !0,
1840
1887
  placement: "bottom-end",
1841
1888
  portal: !0,
1842
1889
  scheme
1843
- }, $[63] = scheme, $[64] = t29);
1844
- let t30;
1845
- $[65] !== t17 || $[66] !== t18 || $[67] !== t26 || $[68] !== t29 ? (t30 = /* @__PURE__ */ jsx(Tooltip, {
1890
+ }, $[63] = scheme, $[64] = t28);
1891
+ let t29;
1892
+ $[65] !== menuId || $[66] !== t17 || $[67] !== t25 || $[68] !== t28 ? (t29 = /* @__PURE__ */ jsx(Tooltip, {
1846
1893
  animate: !0,
1847
1894
  content: t15,
1848
1895
  placement: "bottom",
@@ -1853,22 +1900,22 @@ function ThemeCard(t0) {
1853
1900
  scheme: "dark",
1854
1901
  children: /* @__PURE__ */ jsx(MenuButton, {
1855
1902
  button: t17,
1856
- id: t18,
1857
- menu: t26,
1858
- onClose: t27,
1859
- onOpen: t28,
1860
- popover: t29
1903
+ id: menuId,
1904
+ menu: t25,
1905
+ onClose: t26,
1906
+ onOpen: t27,
1907
+ popover: t28
1861
1908
  })
1862
1909
  })
1863
- }), $[65] = t17, $[66] = t18, $[67] = t26, $[68] = t29, $[69] = t30) : t30 = $[69];
1864
- let t31;
1865
- $[70] !== menuOpen || $[71] !== t30 ? (t31 = /* @__PURE__ */ jsx("div", {
1910
+ }), $[65] = menuId, $[66] = t17, $[67] = t25, $[68] = t28, $[69] = t29) : t29 = $[69];
1911
+ let t30;
1912
+ $[70] !== menuOpen || $[71] !== t29 ? (t30 = /* @__PURE__ */ jsx("div", {
1866
1913
  className: menuSlot,
1867
1914
  "data-visible": menuOpen,
1868
- children: t30
1869
- }), $[70] = menuOpen, $[71] = t30, $[72] = t31) : t31 = $[72];
1870
- let t32;
1871
- return $[73] !== dragControls || $[74] !== t14 || $[75] !== t31 || $[76] !== t7 || $[77] !== theme.slug ? (t32 = /* @__PURE__ */ jsxs(Reorder.Item, {
1915
+ children: t29
1916
+ }), $[70] = menuOpen, $[71] = t29, $[72] = t30) : t30 = $[72];
1917
+ let t31;
1918
+ return $[73] !== dragControls || $[74] !== t14 || $[75] !== t30 || $[76] !== t7 || $[77] !== theme.slug ? (t31 = /* @__PURE__ */ jsxs(Reorder.Item, {
1872
1919
  as: "div",
1873
1920
  className: root,
1874
1921
  dragControls,
@@ -1878,147 +1925,12 @@ function ThemeCard(t0) {
1878
1925
  ref: t7,
1879
1926
  value: theme.slug,
1880
1927
  whileDrag: t8,
1881
- children: [t14, t31]
1882
- }), $[73] = dragControls, $[74] = t14, $[75] = t31, $[76] = t7, $[77] = theme.slug, $[78] = t32) : t32 = $[78], t32;
1928
+ children: [t14, t30]
1929
+ }), $[73] = dragControls, $[74] = t14, $[75] = t30, $[76] = t7, $[77] = theme.slug, $[78] = t31) : t31 = $[78], t31;
1883
1930
  }
1884
1931
  function _temp$3(candidate_0) {
1885
1932
  return candidate_0.slug;
1886
1933
  }
1887
- var cardGrid = "twjqgh0";
1888
- /**
1889
- * The flow for picking a theme: a grid of theme cards — the configured theme,
1890
- * the presets and the user's own themes — that drag into the order the user
1891
- * wants, with the entry points to the add and restore flows below. A theme
1892
- * code someone shared pastes right into the list, or through the paste button.
1893
- *
1894
- * @internal
1895
- */
1896
- function ThemeList(t0) {
1897
- let $ = c(48), { actorRef, themes, removed, active } = t0, t1;
1898
- $[0] === actorRef ? t1 = $[1] : (t1 = { actorRef }, $[0] = actorRef, $[1] = t1);
1899
- let { addThemeFromClipboard } = useThemeCodes(t1), [pasting, setPasting] = useState(!1), t2;
1900
- $[2] === actorRef ? t2 = $[3] : (t2 = { actorRef }, $[2] = actorRef, $[3] = t2), usePasteThemeCodes(t2);
1901
- let t3;
1902
- $[4] === actorRef ? t3 = $[5] : (t3 = (palette, file) => actorRef.send({
1903
- type: "theme.add",
1904
- title: titleFromFileName(file.name),
1905
- options: optionsFromImagePalette(palette),
1906
- palette,
1907
- imageUrl: URL.createObjectURL(file)
1908
- }), $[4] = actorRef, $[5] = t3);
1909
- let { busy, pickImage } = useImagePalette(t3), t4;
1910
- $[6] === actorRef ? t4 = $[7] : (t4 = (order) => actorRef.send({
1911
- type: "theme.reorder",
1912
- order
1913
- }), $[6] = actorRef, $[7] = t4);
1914
- let t5;
1915
- $[8] === themes ? t5 = $[9] : (t5 = themes.map(_temp$2), $[8] = themes, $[9] = t5);
1916
- let t6 = !active, t7;
1917
- $[10] === Symbol.for("react.memo_cache_sentinel") ? (t7 = {
1918
- slug: CONFIG_SLUG,
1919
- title: CONFIG_TITLE,
1920
- options: {},
1921
- source: "config"
1922
- }, $[10] = t7) : t7 = $[10];
1923
- let t8;
1924
- $[11] !== actorRef || $[12] !== t6 || $[13] !== themes ? (t8 = /* @__PURE__ */ jsx(ThemeCard, {
1925
- actorRef,
1926
- active: t6,
1927
- theme: t7,
1928
- themes
1929
- }), $[11] = actorRef, $[12] = t6, $[13] = themes, $[14] = t8) : t8 = $[14];
1930
- let t9;
1931
- $[15] !== active?.slug || $[16] !== actorRef || $[17] !== themes ? (t9 = themes.map((theme_0) => /* @__PURE__ */ jsx(ThemeCard, {
1932
- actorRef,
1933
- active: theme_0.slug === active?.slug,
1934
- theme: theme_0,
1935
- themes
1936
- }, theme_0.slug)), $[15] = active?.slug, $[16] = actorRef, $[17] = themes, $[18] = t9) : t9 = $[18];
1937
- let t10;
1938
- $[19] !== t4 || $[20] !== t5 || $[21] !== t8 || $[22] !== t9 ? (t10 = /* @__PURE__ */ jsx(MotionConfig, {
1939
- reducedMotion: "user",
1940
- children: /* @__PURE__ */ jsxs(Reorder.Group, {
1941
- as: "div",
1942
- className: cardGrid,
1943
- onReorder: t4,
1944
- values: t5,
1945
- children: [t8, t9]
1946
- })
1947
- }), $[19] = t4, $[20] = t5, $[21] = t8, $[22] = t9, $[23] = t10) : t10 = $[23];
1948
- let t11;
1949
- $[24] !== actorRef || $[25] !== removed.length ? (t11 = removed.length > 0 && /* @__PURE__ */ jsx(Button, {
1950
- gap: 2,
1951
- icon: RestoreIcon,
1952
- mode: "bleed",
1953
- onClick: () => actorRef.send({ type: "flow.removed" }),
1954
- padding: 2,
1955
- text: `Show removed (${removed.length})`,
1956
- width: "fill"
1957
- }), $[24] = actorRef, $[25] = removed.length, $[26] = t11) : t11 = $[26];
1958
- let t12;
1959
- $[27] !== t10 || $[28] !== t11 ? (t12 = /* @__PURE__ */ jsx(ScrollArea, {
1960
- padding: 3,
1961
- children: /* @__PURE__ */ jsxs(Stack, {
1962
- gap: 4,
1963
- children: [t10, t11]
1964
- })
1965
- }), $[27] = t10, $[28] = t11, $[29] = t12) : t12 = $[29];
1966
- let t13;
1967
- $[30] === actorRef ? t13 = $[31] : (t13 = /* @__PURE__ */ jsx(Box, {
1968
- flex: 1,
1969
- children: /* @__PURE__ */ jsx(TooltipButton, {
1970
- icon: AddIcon,
1971
- mode: "ghost",
1972
- onClick: () => actorRef.send({ type: "theme.add" }),
1973
- text: "Add theme",
1974
- tooltip: "Add a theme based on the applied one",
1975
- width: "fill"
1976
- })
1977
- }), $[30] = actorRef, $[31] = t13);
1978
- let t14;
1979
- $[32] !== busy || $[33] !== pickImage ? (t14 = /* @__PURE__ */ jsx(ImageFileButton, {
1980
- loading: busy,
1981
- mode: "ghost",
1982
- onFile: pickImage,
1983
- tooltip: "Add a theme from the colors of an image"
1984
- }), $[32] = busy, $[33] = pickImage, $[34] = t14) : t14 = $[34];
1985
- let t15;
1986
- $[35] === addThemeFromClipboard ? t15 = $[36] : (t15 = /* @__PURE__ */ jsx(TooltipButton, {
1987
- icon: ClipboardIcon,
1988
- mode: "ghost",
1989
- onClick: async () => {
1990
- await addThemeFromClipboard() !== "added" && setPasting(!0);
1991
- },
1992
- tooltip: "Add a theme from a code someone shared"
1993
- }), $[35] = addThemeFromClipboard, $[36] = t15);
1994
- let t16;
1995
- $[37] !== t13 || $[38] !== t14 || $[39] !== t15 ? (t16 = /* @__PURE__ */ jsx(Card, {
1996
- borderTop: !0,
1997
- padding: 3,
1998
- children: /* @__PURE__ */ jsxs(Flex, {
1999
- gap: 2,
2000
- children: [
2001
- t13,
2002
- t14,
2003
- t15
2004
- ]
2005
- })
2006
- }), $[37] = t13, $[38] = t14, $[39] = t15, $[40] = t16) : t16 = $[40];
2007
- let t17;
2008
- $[41] !== actorRef || $[42] !== pasting ? (t17 = pasting && /* @__PURE__ */ jsx(PasteThemeDialog, {
2009
- actorRef,
2010
- onClose: () => setPasting(!1)
2011
- }), $[41] = actorRef, $[42] = pasting, $[43] = t17) : t17 = $[43];
2012
- let t18;
2013
- return $[44] !== t12 || $[45] !== t16 || $[46] !== t17 ? (t18 = /* @__PURE__ */ jsxs(Fragment, { children: [
2014
- t12,
2015
- t16,
2016
- t17
2017
- ] }), $[44] = t12, $[45] = t16, $[46] = t17, $[47] = t18) : t18 = $[47], t18;
2018
- }
2019
- function _temp$2(theme) {
2020
- return theme.slug;
2021
- }
2022
1934
  /**
2023
1935
  * Reduces theme options to the minimal object that recreates them through
2024
1936
  * `buildTheme`: in each scheme the accent is dropped when it is the stock
@@ -2072,7 +1984,7 @@ registerLanguage(typescript);
2072
1984
  * @internal
2073
1985
  */
2074
1986
  function ThemeSnippetDialog(props) {
2075
- let $ = c(23), { onClose, theme } = props, toast = useToast(), t0;
1987
+ let $ = c(24), { onClose, theme } = props, toast = useToast(), id = useId(), t0;
2076
1988
  $[0] === theme.options ? t0 = $[1] : (t0 = createThemeSnippet(theme.options), $[0] = theme.options, $[1] = t0);
2077
1989
  let snippet = t0, t1;
2078
1990
  $[2] !== snippet || $[3] !== toast ? (t1 = async () => {
@@ -2149,16 +2061,216 @@ function ThemeSnippetDialog(props) {
2149
2061
  })
2150
2062
  }), $[16] = t7, $[17] = t8, $[18] = t9) : t9 = $[18];
2151
2063
  let t10;
2152
- return $[19] !== onClose || $[20] !== t2 || $[21] !== t9 ? (t10 = /* @__PURE__ */ jsx(Dialog, {
2064
+ return $[19] !== id || $[20] !== onClose || $[21] !== t2 || $[22] !== t9 ? (t10 = /* @__PURE__ */ jsx(Dialog, {
2153
2065
  animate: !0,
2154
2066
  footer: t2,
2155
2067
  header: "Add to your config",
2156
- id: "themer-snippet",
2068
+ id,
2157
2069
  onClickOutside: onClose,
2158
2070
  onClose,
2159
2071
  width: 1,
2160
2072
  children: t9
2161
- }), $[19] = onClose, $[20] = t2, $[21] = t9, $[22] = t10) : t10 = $[22], t10;
2073
+ }), $[19] = id, $[20] = onClose, $[21] = t2, $[22] = t9, $[23] = t10) : t10 = $[23], t10;
2074
+ }
2075
+ var cardGrid = "twjqgh0";
2076
+ /**
2077
+ * The flow for picking a theme: a grid of theme cards — the configured theme,
2078
+ * the presets and the user's own themes — that drag into the order the user
2079
+ * wants, with the entry point to the restore flow below. The footer takes the
2080
+ * applied theme on to the editor — a copy of it, for a preset or the
2081
+ * configured theme — and keeps the ways to add a theme and the applied
2082
+ * theme's code behind its menu. A theme code someone shared pastes right into
2083
+ * the list too.
2084
+ *
2085
+ * @internal
2086
+ */
2087
+ function ThemeList(t0) {
2088
+ let $ = c(71), { actorRef, themes, removed, active } = t0, t1;
2089
+ $[0] === actorRef ? t1 = $[1] : (t1 = { actorRef }, $[0] = actorRef, $[1] = t1);
2090
+ let { addThemeFromClipboard } = useThemeCodes(t1), dialog = useSelector(actorRef, selectDialog), imageInputRef = useRef(null), actionsId = useId(), t2;
2091
+ $[2] === actorRef ? t2 = $[3] : (t2 = { actorRef }, $[2] = actorRef, $[3] = t2), usePasteThemeCodes(t2);
2092
+ let t3;
2093
+ $[4] === actorRef ? t3 = $[5] : (t3 = (palette, file) => actorRef.send({
2094
+ type: "theme.add",
2095
+ title: titleFromFileName(file.name),
2096
+ options: optionsFromImagePalette(palette),
2097
+ palette,
2098
+ imageUrl: URL.createObjectURL(file)
2099
+ }), $[4] = actorRef, $[5] = t3);
2100
+ let { busy, pickImage } = useImagePalette(t3), t4;
2101
+ $[6] === actorRef ? t4 = $[7] : (t4 = (order) => actorRef.send({
2102
+ type: "theme.reorder",
2103
+ order
2104
+ }), $[6] = actorRef, $[7] = t4);
2105
+ let t5;
2106
+ $[8] === themes ? t5 = $[9] : (t5 = themes.map(_temp$2), $[8] = themes, $[9] = t5);
2107
+ let t6 = !active, t7;
2108
+ $[10] === Symbol.for("react.memo_cache_sentinel") ? (t7 = {
2109
+ slug: CONFIG_SLUG,
2110
+ title: CONFIG_TITLE,
2111
+ options: {},
2112
+ source: "config"
2113
+ }, $[10] = t7) : t7 = $[10];
2114
+ let t8;
2115
+ $[11] !== actorRef || $[12] !== t6 || $[13] !== themes ? (t8 = /* @__PURE__ */ jsx(ThemeCard, {
2116
+ actorRef,
2117
+ active: t6,
2118
+ theme: t7,
2119
+ themes
2120
+ }), $[11] = actorRef, $[12] = t6, $[13] = themes, $[14] = t8) : t8 = $[14];
2121
+ let t9;
2122
+ $[15] !== active?.slug || $[16] !== actorRef || $[17] !== themes ? (t9 = themes.map((theme_0) => /* @__PURE__ */ jsx(ThemeCard, {
2123
+ actorRef,
2124
+ active: theme_0.slug === active?.slug,
2125
+ theme: theme_0,
2126
+ themes
2127
+ }, theme_0.slug)), $[15] = active?.slug, $[16] = actorRef, $[17] = themes, $[18] = t9) : t9 = $[18];
2128
+ let t10;
2129
+ $[19] !== t4 || $[20] !== t5 || $[21] !== t8 || $[22] !== t9 ? (t10 = /* @__PURE__ */ jsx(MotionConfig, {
2130
+ reducedMotion: "user",
2131
+ children: /* @__PURE__ */ jsxs(Reorder.Group, {
2132
+ as: "div",
2133
+ className: cardGrid,
2134
+ onReorder: t4,
2135
+ values: t5,
2136
+ children: [t8, t9]
2137
+ })
2138
+ }), $[19] = t4, $[20] = t5, $[21] = t8, $[22] = t9, $[23] = t10) : t10 = $[23];
2139
+ let t11;
2140
+ $[24] !== actorRef || $[25] !== removed.length ? (t11 = removed.length > 0 && /* @__PURE__ */ jsx(Button, {
2141
+ gap: 2,
2142
+ icon: RestoreIcon,
2143
+ mode: "bleed",
2144
+ onClick: () => actorRef.send({ type: "flow.removed" }),
2145
+ padding: 2,
2146
+ text: `Show removed (${removed.length})`,
2147
+ width: "fill"
2148
+ }), $[24] = actorRef, $[25] = removed.length, $[26] = t11) : t11 = $[26];
2149
+ let t12;
2150
+ $[27] !== t10 || $[28] !== t11 ? (t12 = /* @__PURE__ */ jsx(ScrollArea, {
2151
+ padding: 3,
2152
+ children: /* @__PURE__ */ jsxs(Stack, {
2153
+ gap: 4,
2154
+ children: [t10, t11]
2155
+ })
2156
+ }), $[27] = t10, $[28] = t11, $[29] = t12) : t12 = $[29];
2157
+ let t13;
2158
+ $[30] !== active || $[31] !== actorRef ? (t13 = active?.source === "custom" ? /* @__PURE__ */ jsx(Button, {
2159
+ gap: 2,
2160
+ icon: EditIcon,
2161
+ onClick: () => actorRef.send({
2162
+ type: "theme.edit",
2163
+ slug: active.slug
2164
+ }),
2165
+ padding: 2,
2166
+ text: "Edit",
2167
+ mode: "ghost"
2168
+ }) : /* @__PURE__ */ jsx(Button, {
2169
+ gap: 2,
2170
+ icon: CopyIcon,
2171
+ onClick: () => actorRef.send({
2172
+ type: "theme.duplicate",
2173
+ slug: active?.slug ?? "config"
2174
+ }),
2175
+ padding: 2,
2176
+ text: "Duplicate & Edit",
2177
+ mode: "ghost"
2178
+ }), $[30] = active, $[31] = actorRef, $[32] = t13) : t13 = $[32];
2179
+ let t14;
2180
+ $[33] === busy ? t14 = $[34] : (t14 = /* @__PURE__ */ jsx(Button, {
2181
+ "aria-label": "More actions",
2182
+ icon: EllipsisHorizontalIcon,
2183
+ loading: busy,
2184
+ mode: "bleed",
2185
+ padding: 2
2186
+ }), $[33] = busy, $[34] = t14);
2187
+ let t15;
2188
+ $[35] === actorRef ? t15 = $[36] : (t15 = /* @__PURE__ */ jsx(MenuItem, {
2189
+ icon: AddIcon,
2190
+ onClick: () => actorRef.send({ type: "theme.add" }),
2191
+ text: "Add theme"
2192
+ }), $[35] = actorRef, $[36] = t15);
2193
+ let t16;
2194
+ $[37] === Symbol.for("react.memo_cache_sentinel") ? (t16 = /* @__PURE__ */ jsx(MenuItem, {
2195
+ icon: ImageIcon,
2196
+ onClick: () => imageInputRef.current?.click(),
2197
+ text: "Add from image"
2198
+ }), $[37] = t16) : t16 = $[37];
2199
+ let t17;
2200
+ $[38] !== actorRef || $[39] !== addThemeFromClipboard ? (t17 = /* @__PURE__ */ jsx(MenuItem, {
2201
+ icon: ClipboardIcon,
2202
+ onClick: async () => {
2203
+ await addThemeFromClipboard() !== "added" && actorRef.send({ type: "dialog.paste" });
2204
+ },
2205
+ text: "Add from code"
2206
+ }), $[38] = actorRef, $[39] = addThemeFromClipboard, $[40] = t17) : t17 = $[40];
2207
+ let t18;
2208
+ $[41] !== active || $[42] !== actorRef ? (t18 = active && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MenuDivider, {}), /* @__PURE__ */ jsx(MenuItem, {
2209
+ icon: CodeBlockIcon,
2210
+ onClick: () => actorRef.send({ type: "dialog.snippet" }),
2211
+ text: "Show theme code"
2212
+ })] }), $[41] = active, $[42] = actorRef, $[43] = t18) : t18 = $[43];
2213
+ let t19;
2214
+ $[44] !== t15 || $[45] !== t17 || $[46] !== t18 ? (t19 = /* @__PURE__ */ jsxs(Menu, { children: [
2215
+ t15,
2216
+ t16,
2217
+ t17,
2218
+ t18
2219
+ ] }), $[44] = t15, $[45] = t17, $[46] = t18, $[47] = t19) : t19 = $[47];
2220
+ let t20;
2221
+ $[48] === Symbol.for("react.memo_cache_sentinel") ? (t20 = {
2222
+ animate: !0,
2223
+ placement: "top-end",
2224
+ portal: !0
2225
+ }, $[48] = t20) : t20 = $[48];
2226
+ let t21;
2227
+ $[49] !== actionsId || $[50] !== t14 || $[51] !== t19 ? (t21 = /* @__PURE__ */ jsx(MenuButton, {
2228
+ button: t14,
2229
+ id: actionsId,
2230
+ menu: t19,
2231
+ popover: t20
2232
+ }), $[49] = actionsId, $[50] = t14, $[51] = t19, $[52] = t21) : t21 = $[52];
2233
+ let t22;
2234
+ $[53] !== t13 || $[54] !== t21 ? (t22 = /* @__PURE__ */ jsx(Card, {
2235
+ borderTop: !0,
2236
+ padding: 3,
2237
+ children: /* @__PURE__ */ jsxs(Flex, {
2238
+ align: "center",
2239
+ gap: 2,
2240
+ justify: "flex-end",
2241
+ children: [t13, t21]
2242
+ })
2243
+ }), $[53] = t13, $[54] = t21, $[55] = t22) : t22 = $[55];
2244
+ let t23;
2245
+ $[56] === pickImage ? t23 = $[57] : (t23 = /* @__PURE__ */ jsx(ImageFileInput, {
2246
+ onFile: pickImage,
2247
+ ref: imageInputRef
2248
+ }), $[56] = pickImage, $[57] = t23);
2249
+ let t24;
2250
+ $[58] !== actorRef || $[59] !== dialog ? (t24 = dialog === "paste" && /* @__PURE__ */ jsx(PasteThemeDialog, {
2251
+ actorRef,
2252
+ onClose: () => actorRef.send({ type: "dialog.close" })
2253
+ }), $[58] = actorRef, $[59] = dialog, $[60] = t24) : t24 = $[60];
2254
+ let t25;
2255
+ $[61] !== active || $[62] !== actorRef || $[63] !== dialog ? (t25 = dialog === "snippet" && active && /* @__PURE__ */ jsx(ThemeSnippetDialog, {
2256
+ onClose: () => actorRef.send({ type: "dialog.close" }),
2257
+ theme: active
2258
+ }), $[61] = active, $[62] = actorRef, $[63] = dialog, $[64] = t25) : t25 = $[64];
2259
+ let t26;
2260
+ return $[65] !== t12 || $[66] !== t22 || $[67] !== t23 || $[68] !== t24 || $[69] !== t25 ? (t26 = /* @__PURE__ */ jsxs(Fragment, { children: [
2261
+ t12,
2262
+ t22,
2263
+ t23,
2264
+ t24,
2265
+ t25
2266
+ ] }), $[65] = t12, $[66] = t22, $[67] = t23, $[68] = t24, $[69] = t25, $[70] = t26) : t26 = $[70], t26;
2267
+ }
2268
+ function _temp$2(theme) {
2269
+ return theme.slug;
2270
+ }
2271
+ /** The dialog the list has open, if any — a state of the machine's list flow */
2272
+ function selectDialog(snapshot) {
2273
+ return snapshot.matches({ flow: { list: "pasting" } }) ? "paste" : snapshot.matches({ flow: { list: "snippet" } }) ? "snippet" : null;
2162
2274
  }
2163
2275
  function useIsTooSmallForSplitScreen() {
2164
2276
  return useMediaIndex() <= 3;
@@ -2170,37 +2282,31 @@ const VIEW_TITLES = {
2170
2282
  removed: "Removed themes"
2171
2283
  };
2172
2284
  /**
2173
- * The themer sidebar: a header that navigates between the flows and toggles
2174
- * the split preview, the flow itself — picking a theme, editing one, or
2175
- * restoring removed ones — and the dialog with the `buildTheme` snippet of
2176
- * the applied theme.
2285
+ * The themer sidebar: a header with the flow's title, the split preview
2286
+ * toggle and the close button, and the flow itself — picking a theme, editing
2287
+ * one, or restoring removed ones. Each flow ends in a footer like the
2288
+ * Studio's document footer: one primary action, with the rest of its actions
2289
+ * behind a menu button, and the way back to the list where the flow is not
2290
+ * the list.
2177
2291
  *
2178
2292
  * @internal
2179
2293
  */
2180
2294
  function ThemerSidebar(t0) {
2181
- let $ = c(58), { actorRef, dispatch, navbarHeight, split } = t0, [snippetOpen, setSnippetOpen] = useState(!1), view = useSelector(actorRef, selectView, sameView), inList = view.name === "list", isTooSmallForSplitScreen = useIsTooSmallForSplitScreen(), { themes, removed, active } = useSelector(actorRef, _temp$1, dequal), t1;
2295
+ let $ = c(46), { actorRef, dispatch, navbarHeight, split } = t0, view = useSelector(actorRef, selectView, sameView), isTooSmallForSplitScreen = useIsTooSmallForSplitScreen(), { themes, removed, active } = useSelector(actorRef, _temp$1, dequal), t1;
2182
2296
  $[0] === navbarHeight ? t1 = $[1] : (t1 = navbarHeight === null ? void 0 : { height: navbarHeight }, $[0] = navbarHeight, $[1] = t1);
2183
- let t2;
2184
- $[2] !== actorRef || $[3] !== inList ? (t2 = !inList && /* @__PURE__ */ jsx(TooltipButton, {
2185
- icon: ArrowLeftIcon,
2186
- mode: "bleed",
2187
- onClick: () => actorRef.send({ type: "flow.list" }),
2188
- padding: 2,
2189
- tooltip: "Back to the themes"
2190
- }), $[2] = actorRef, $[3] = inList, $[4] = t2) : t2 = $[4];
2191
- let t3 = VIEW_TITLES[view.name], t4;
2192
- $[5] === t3 ? t4 = $[6] : (t4 = /* @__PURE__ */ jsx(Box, {
2297
+ let t2 = VIEW_TITLES[view.name], t3;
2298
+ $[2] === t2 ? t3 = $[3] : (t3 = /* @__PURE__ */ jsx(Box, {
2193
2299
  className: title,
2194
2300
  flex: 1,
2195
2301
  children: /* @__PURE__ */ jsx(Text, {
2196
2302
  size: 1,
2197
2303
  textOverflow: "ellipsis",
2198
2304
  weight: "semibold",
2199
- children: t3
2305
+ children: t2
2200
2306
  })
2201
- }), $[5] = t3, $[6] = t4);
2202
- let t5;
2203
- $[7] !== active || $[8] !== dispatch || $[9] !== isTooSmallForSplitScreen || $[10] !== split || $[11] !== view.name ? (t5 = view.name !== "removed" && /* @__PURE__ */ jsxs(Fragment, { children: [!isTooSmallForSplitScreen && /* @__PURE__ */ jsx(TooltipButton, {
2307
+ }), $[2] = t2, $[3] = t3);
2308
+ let t4;
2309
+ $[4] !== dispatch || $[5] !== isTooSmallForSplitScreen || $[6] !== split ? (t4 = !isTooSmallForSplitScreen && /* @__PURE__ */ jsx(TooltipButton, {
2204
2310
  "aria-pressed": split,
2205
2311
  icon: SplitVerticalIcon,
2206
2312
  mode: "bleed",
@@ -2214,15 +2320,9 @@ function ThemerSidebar(t0) {
2214
2320
  padding: 2,
2215
2321
  selected: split,
2216
2322
  tooltip: "Show light and dark side by side"
2217
- }), active && /* @__PURE__ */ jsx(TooltipButton, {
2218
- icon: CodeBlockIcon,
2219
- mode: "bleed",
2220
- onClick: () => setSnippetOpen(!0),
2221
- padding: 2,
2222
- tooltip: "Show the code for the applied theme"
2223
- })] }), $[7] = active, $[8] = dispatch, $[9] = isTooSmallForSplitScreen, $[10] = split, $[11] = view.name, $[12] = t5) : t5 = $[12];
2224
- let t6;
2225
- $[13] !== dispatch || $[14] !== split ? (t6 = /* @__PURE__ */ jsx(TooltipButton, {
2323
+ }), $[4] = dispatch, $[5] = isTooSmallForSplitScreen, $[6] = split, $[7] = t4) : t4 = $[7];
2324
+ let t5;
2325
+ $[8] !== dispatch || $[9] !== split ? (t5 = /* @__PURE__ */ jsx(TooltipButton, {
2226
2326
  icon: CloseIcon,
2227
2327
  mode: "bleed",
2228
2328
  onClick: () => startTransition(() => {
@@ -2230,79 +2330,68 @@ function ThemerSidebar(t0) {
2230
2330
  }),
2231
2331
  padding: 2,
2232
2332
  tooltip: "Close themer"
2233
- }), $[13] = dispatch, $[14] = split, $[15] = t6) : t6 = $[15];
2333
+ }), $[8] = dispatch, $[9] = split, $[10] = t5) : t5 = $[10];
2334
+ let t6;
2335
+ $[11] !== t4 || $[12] !== t5 ? (t6 = /* @__PURE__ */ jsxs(Flex, { children: [t4, t5] }), $[11] = t4, $[12] = t5, $[13] = t6) : t6 = $[13];
2234
2336
  let t7;
2235
- $[16] !== t5 || $[17] !== t6 ? (t7 = /* @__PURE__ */ jsxs(Flex, { children: [t5, t6] }), $[16] = t5, $[17] = t6, $[18] = t7) : t7 = $[18];
2236
- let t8;
2237
- $[19] !== t2 || $[20] !== t4 || $[21] !== t7 ? (t8 = /* @__PURE__ */ jsxs(Flex, {
2337
+ $[14] !== t3 || $[15] !== t6 ? (t7 = /* @__PURE__ */ jsxs(Flex, {
2238
2338
  align: "center",
2239
2339
  gap: 1,
2240
2340
  height: "fill",
2241
- children: [
2242
- t2,
2243
- t4,
2244
- t7
2245
- ]
2246
- }), $[19] = t2, $[20] = t4, $[21] = t7, $[22] = t8) : t8 = $[22];
2247
- let t9;
2248
- $[23] !== t1 || $[24] !== t8 ? (t9 = /* @__PURE__ */ jsx(Card, {
2341
+ children: [t3, t6]
2342
+ }), $[14] = t3, $[15] = t6, $[16] = t7) : t7 = $[16];
2343
+ let t8;
2344
+ $[17] !== t1 || $[18] !== t7 ? (t8 = /* @__PURE__ */ jsx(Card, {
2249
2345
  borderBottom: !0,
2250
2346
  padding: 3,
2251
2347
  sizing: "border",
2252
2348
  style: t1,
2253
- children: t8
2254
- }), $[23] = t1, $[24] = t8, $[25] = t9) : t9 = $[25];
2255
- let t10 = view.name === "list" ? "visible" : "hidden", t11;
2256
- $[26] !== active || $[27] !== actorRef || $[28] !== removed || $[29] !== themes ? (t11 = /* @__PURE__ */ jsx(ThemeList, {
2349
+ children: t7
2350
+ }), $[17] = t1, $[18] = t7, $[19] = t8) : t8 = $[19];
2351
+ let t9 = view.name === "list" ? "visible" : "hidden", t10;
2352
+ $[20] !== active || $[21] !== actorRef || $[22] !== removed || $[23] !== themes ? (t10 = /* @__PURE__ */ jsx(ThemeList, {
2257
2353
  actorRef,
2258
2354
  active,
2259
2355
  removed,
2260
2356
  themes
2261
- }), $[26] = active, $[27] = actorRef, $[28] = removed, $[29] = themes, $[30] = t11) : t11 = $[30];
2357
+ }), $[20] = active, $[21] = actorRef, $[22] = removed, $[23] = themes, $[24] = t10) : t10 = $[24];
2358
+ let t11;
2359
+ $[25] !== t10 || $[26] !== t9 ? (t11 = /* @__PURE__ */ jsx(Activity, {
2360
+ mode: t9,
2361
+ children: t10
2362
+ }, "list"), $[25] = t10, $[26] = t9, $[27] = t11) : t11 = $[27];
2262
2363
  let t12;
2263
- $[31] !== t10 || $[32] !== t11 ? (t12 = /* @__PURE__ */ jsx(Activity, {
2264
- mode: t10,
2265
- children: t11
2266
- }, "list"), $[31] = t10, $[32] = t11, $[33] = t12) : t12 = $[33];
2267
- let t13;
2268
- $[34] !== actorRef || $[35] !== split || $[36] !== themes || $[37] !== view.focusTitle || $[38] !== view.name || $[39] !== view.slug ? (t13 = view.name === "edit" && /* @__PURE__ */ jsx(ThemeEditor, {
2364
+ $[28] !== actorRef || $[29] !== split || $[30] !== themes || $[31] !== view.focusTitle || $[32] !== view.name || $[33] !== view.slug ? (t12 = view.name === "edit" && /* @__PURE__ */ jsx(ThemeEditor, {
2269
2365
  actorRef,
2270
2366
  focusTitle: view.focusTitle,
2271
2367
  slug: view.slug,
2272
2368
  split,
2273
2369
  themes
2274
- }), $[34] = actorRef, $[35] = split, $[36] = themes, $[37] = view.focusTitle, $[38] = view.name, $[39] = view.slug, $[40] = t13) : t13 = $[40];
2275
- let t14 = view.name === "removed" ? "visible" : "hidden", t15;
2276
- $[41] !== actorRef || $[42] !== removed ? (t15 = /* @__PURE__ */ jsx(RemovedThemes, {
2370
+ }), $[28] = actorRef, $[29] = split, $[30] = themes, $[31] = view.focusTitle, $[32] = view.name, $[33] = view.slug, $[34] = t12) : t12 = $[34];
2371
+ let t13 = view.name === "removed" ? "visible" : "hidden", t14;
2372
+ $[35] !== actorRef || $[36] !== removed ? (t14 = /* @__PURE__ */ jsx(RemovedThemes, {
2277
2373
  actorRef,
2278
2374
  removed
2279
- }), $[41] = actorRef, $[42] = removed, $[43] = t15) : t15 = $[43];
2375
+ }), $[35] = actorRef, $[36] = removed, $[37] = t14) : t14 = $[37];
2376
+ let t15;
2377
+ $[38] !== t13 || $[39] !== t14 ? (t15 = /* @__PURE__ */ jsx(Activity, {
2378
+ mode: t13,
2379
+ children: t14
2380
+ }, "removed"), $[38] = t13, $[39] = t14, $[40] = t15) : t15 = $[40];
2280
2381
  let t16;
2281
- $[44] !== t14 || $[45] !== t15 ? (t16 = /* @__PURE__ */ jsx(Activity, {
2282
- mode: t14,
2283
- children: t15
2284
- }, "removed"), $[44] = t14, $[45] = t15, $[46] = t16) : t16 = $[46];
2285
- let t17;
2286
- $[47] !== t12 || $[48] !== t13 || $[49] !== t16 || $[50] !== t9 ? (t17 = /* @__PURE__ */ jsxs(Flex, {
2287
- direction: "column",
2382
+ return $[41] !== t11 || $[42] !== t12 || $[43] !== t15 || $[44] !== t8 ? (t16 = /* @__PURE__ */ jsx(Card, {
2288
2383
  height: "fill",
2289
- children: [
2290
- t9,
2291
- t12,
2292
- t13,
2293
- t16
2294
- ]
2295
- }), $[47] = t12, $[48] = t13, $[49] = t16, $[50] = t9, $[51] = t17) : t17 = $[51];
2296
- let t18;
2297
- $[52] !== active || $[53] !== snippetOpen ? (t18 = active && snippetOpen && /* @__PURE__ */ jsx(ThemeSnippetDialog, {
2298
- onClose: () => setSnippetOpen(!1),
2299
- theme: active
2300
- }), $[52] = active, $[53] = snippetOpen, $[54] = t18) : t18 = $[54];
2301
- let t19;
2302
- return $[55] !== t17 || $[56] !== t18 ? (t19 = /* @__PURE__ */ jsxs(Card, {
2303
- height: "fill",
2304
- children: [t17, t18]
2305
- }), $[55] = t17, $[56] = t18, $[57] = t19) : t19 = $[57], t19;
2384
+ children: /* @__PURE__ */ jsxs(Flex, {
2385
+ direction: "column",
2386
+ height: "fill",
2387
+ children: [
2388
+ t8,
2389
+ t11,
2390
+ t12,
2391
+ t15
2392
+ ]
2393
+ })
2394
+ }), $[41] = t11, $[42] = t12, $[43] = t15, $[44] = t8, $[45] = t16) : t16 = $[45], t16;
2306
2395
  }
2307
2396
  function _temp$1(snapshot) {
2308
2397
  return resolveThemes(snapshot.context);
@@ -2434,4 +2523,4 @@ function ResizableSidebar(t0) {
2434
2523
  function _temp() {}
2435
2524
  export { ResizableSidebar as default };
2436
2525
 
2437
- //# sourceMappingURL=ResizableSidebar-BpgLA4XQ.js.map
2526
+ //# sourceMappingURL=ResizableSidebar-C1nr3Ls2.js.map