camox 0.69.0 → 0.71.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,6 +1,5 @@
1
- import { reads, useReadQuery, useStudioCache } from "../../../lib/studio-reads.js";
1
+ import { reads, useReadQuery } from "../../../lib/studio-reads.js";
2
2
  import { cn } from "../../../lib/utils.js";
3
- import { getDraftReadClient } from "../../../lib/api-client.js";
4
3
  import { draftMutations, patrolMutations } from "../../../lib/queries.js";
5
4
  import { previewStore } from "../../preview/previewStore.js";
6
5
  import { studioStore } from "../studioStore.js";
@@ -954,7 +953,7 @@ function _temp5(locale) {
954
953
  * draft.
955
954
  */
956
955
  function DraftOverview(t0) {
957
- const $ = c(34);
956
+ const $ = c(35);
958
957
  const { projectId, preview } = t0;
959
958
  const { overview, changes } = preview;
960
959
  let t1;
@@ -967,34 +966,36 @@ function DraftOverview(t0) {
967
966
  } else t1 = $[0];
968
967
  const retry = useMutation(t1);
969
968
  if (changes.length === 0) {
970
- let t2;
971
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
972
- t2 = /* @__PURE__ */ jsx("p", {
969
+ const t2 = preview.code ? "This draft changes the website's code." : "This draft has no changes.";
970
+ let t3;
971
+ if ($[1] !== t2) {
972
+ t3 = /* @__PURE__ */ jsx("p", {
973
973
  className: "text-muted-foreground text-sm",
974
- children: "This draft has no changes."
974
+ children: t2
975
975
  });
976
976
  $[1] = t2;
977
- } else t2 = $[1];
978
- return t2;
977
+ $[2] = t3;
978
+ } else t3 = $[2];
979
+ return t3;
979
980
  }
980
981
  if (overview.status === "ready") {
981
982
  let t2;
982
- if ($[2] !== overview.bullets) {
983
+ if ($[3] !== overview.bullets) {
983
984
  t2 = overview.bullets.map(_temp11);
984
- $[2] = overview.bullets;
985
- $[3] = t2;
986
- } else t2 = $[3];
985
+ $[3] = overview.bullets;
986
+ $[4] = t2;
987
+ } else t2 = $[4];
987
988
  let t3;
988
- if ($[4] !== t2) {
989
+ if ($[5] !== t2) {
989
990
  t3 = /* @__PURE__ */ jsx("ul", {
990
991
  className: "text-foreground/85 flex list-disc flex-col gap-1.5 pl-5 leading-relaxed",
991
992
  children: t2
992
993
  });
993
- $[4] = t2;
994
- $[5] = t3;
995
- } else t3 = $[5];
994
+ $[5] = t2;
995
+ $[6] = t3;
996
+ } else t3 = $[6];
996
997
  let t4;
997
- if ($[6] !== overview.stale) {
998
+ if ($[7] !== overview.stale) {
998
999
  t4 = overview.stale && /* @__PURE__ */ jsxs("p", {
999
1000
  className: "text-muted-foreground flex items-center gap-1.5 text-xs",
1000
1001
  children: [/* @__PURE__ */ jsx(Spinner, {
@@ -1002,53 +1003,53 @@ function DraftOverview(t0) {
1002
1003
  className: "size-3"
1003
1004
  }), "Updating…"]
1004
1005
  });
1005
- $[6] = overview.stale;
1006
- $[7] = t4;
1007
- } else t4 = $[7];
1006
+ $[7] = overview.stale;
1007
+ $[8] = t4;
1008
+ } else t4 = $[8];
1008
1009
  let t5;
1009
- if ($[8] !== t3 || $[9] !== t4) {
1010
+ if ($[9] !== t3 || $[10] !== t4) {
1010
1011
  t5 = /* @__PURE__ */ jsxs("div", {
1011
1012
  "data-overview": true,
1012
1013
  className: "flex flex-col gap-2",
1013
1014
  children: [t3, t4]
1014
1015
  });
1015
- $[8] = t3;
1016
- $[9] = t4;
1017
- $[10] = t5;
1018
- } else t5 = $[10];
1016
+ $[9] = t3;
1017
+ $[10] = t4;
1018
+ $[11] = t5;
1019
+ } else t5 = $[11];
1019
1020
  return t5;
1020
1021
  }
1021
1022
  if (overview.status === "failed") {
1022
1023
  let t2;
1023
- if ($[11] !== changes) {
1024
+ if ($[12] !== changes) {
1024
1025
  t2 = new Set(changes.map(_temp12));
1025
- $[11] = changes;
1026
- $[12] = t2;
1027
- } else t2 = $[12];
1026
+ $[12] = changes;
1027
+ $[13] = t2;
1028
+ } else t2 = $[13];
1028
1029
  const places = t2.size;
1029
1030
  let t3;
1030
- if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
1031
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
1031
1032
  t3 = /* @__PURE__ */ jsx("p", {
1032
1033
  className: "text-sm font-medium",
1033
1034
  children: "Couldn't summarize this draft"
1034
1035
  });
1035
- $[13] = t3;
1036
- } else t3 = $[13];
1036
+ $[14] = t3;
1037
+ } else t3 = $[14];
1037
1038
  let t4;
1038
- if ($[14] !== projectId || $[15] !== retry) {
1039
+ if ($[15] !== projectId || $[16] !== retry) {
1039
1040
  t4 = () => retry.mutate({ projectId });
1040
- $[14] = projectId;
1041
- $[15] = retry;
1042
- $[16] = t4;
1043
- } else t4 = $[16];
1041
+ $[15] = projectId;
1042
+ $[16] = retry;
1043
+ $[17] = t4;
1044
+ } else t4 = $[17];
1044
1045
  let t5;
1045
- if ($[17] !== retry.isPending) {
1046
+ if ($[18] !== retry.isPending) {
1046
1047
  t5 = retry.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
1047
- $[17] = retry.isPending;
1048
- $[18] = t5;
1049
- } else t5 = $[18];
1048
+ $[18] = retry.isPending;
1049
+ $[19] = t5;
1050
+ } else t5 = $[19];
1050
1051
  let t6;
1051
- if ($[19] !== retry.isPending || $[20] !== t4 || $[21] !== t5) {
1052
+ if ($[20] !== retry.isPending || $[21] !== t4 || $[22] !== t5) {
1052
1053
  t6 = /* @__PURE__ */ jsxs("div", {
1053
1054
  className: "flex items-center gap-3",
1054
1055
  children: [t3, /* @__PURE__ */ jsxs(Button, {
@@ -1060,25 +1061,25 @@ function DraftOverview(t0) {
1060
1061
  children: [t5, "Retry"]
1061
1062
  })]
1062
1063
  });
1063
- $[19] = retry.isPending;
1064
- $[20] = t4;
1065
- $[21] = t5;
1066
- $[22] = t6;
1067
- } else t6 = $[22];
1064
+ $[20] = retry.isPending;
1065
+ $[21] = t4;
1066
+ $[22] = t5;
1067
+ $[23] = t6;
1068
+ } else t6 = $[23];
1068
1069
  let t7;
1069
- if ($[23] !== changes.length) {
1070
+ if ($[24] !== changes.length) {
1070
1071
  t7 = plural(changes.length, "change");
1071
- $[23] = changes.length;
1072
- $[24] = t7;
1073
- } else t7 = $[24];
1072
+ $[24] = changes.length;
1073
+ $[25] = t7;
1074
+ } else t7 = $[25];
1074
1075
  let t8;
1075
- if ($[25] !== places) {
1076
+ if ($[26] !== places) {
1076
1077
  t8 = plural(places, "place");
1077
- $[25] = places;
1078
- $[26] = t8;
1079
- } else t8 = $[26];
1078
+ $[26] = places;
1079
+ $[27] = t8;
1080
+ } else t8 = $[27];
1080
1081
  let t9;
1081
- if ($[27] !== t7 || $[28] !== t8) {
1082
+ if ($[28] !== t7 || $[29] !== t8) {
1082
1083
  t9 = /* @__PURE__ */ jsxs("p", {
1083
1084
  className: "text-muted-foreground text-sm",
1084
1085
  children: [
@@ -1087,26 +1088,26 @@ function DraftOverview(t0) {
1087
1088
  t8
1088
1089
  ]
1089
1090
  });
1090
- $[27] = t7;
1091
- $[28] = t8;
1092
- $[29] = t9;
1093
- } else t9 = $[29];
1091
+ $[28] = t7;
1092
+ $[29] = t8;
1093
+ $[30] = t9;
1094
+ } else t9 = $[30];
1094
1095
  let t10;
1095
- if ($[30] !== t6 || $[31] !== t9) {
1096
+ if ($[31] !== t6 || $[32] !== t9) {
1096
1097
  t10 = /* @__PURE__ */ jsxs("div", {
1097
1098
  "data-overview": true,
1098
1099
  className: "flex flex-col gap-2",
1099
1100
  children: [t6, t9]
1100
1101
  });
1101
- $[30] = t6;
1102
- $[31] = t9;
1103
- $[32] = t10;
1104
- } else t10 = $[32];
1102
+ $[31] = t6;
1103
+ $[32] = t9;
1104
+ $[33] = t10;
1105
+ } else t10 = $[33];
1105
1106
  return t10;
1106
1107
  }
1107
1108
  if (overview.status === "none") return null;
1108
1109
  let t2;
1109
- if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
1110
+ if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
1110
1111
  t2 = /* @__PURE__ */ jsxs("div", {
1111
1112
  "data-overview": true,
1112
1113
  className: "flex flex-col gap-2",
@@ -1120,8 +1121,8 @@ function DraftOverview(t0) {
1120
1121
  })
1121
1122
  ]
1122
1123
  });
1123
- $[33] = t2;
1124
- } else t2 = $[33];
1124
+ $[34] = t2;
1125
+ } else t2 = $[34];
1125
1126
  return t2;
1126
1127
  }
1127
1128
  function _temp12(change) {
@@ -1134,270 +1135,109 @@ function _temp10(error) {
1134
1135
  return toast.error(error.message || "Could not summarize the draft");
1135
1136
  }
1136
1137
  /**
1137
- * Renames a regular draft, whichever draft the studio views: the request names the draft it
1138
- * renames. A blank name clears it, so the draft shows its computed label again.
1139
- */
1140
- function useRenameDraft(projectId) {
1141
- const $ = c(8);
1142
- const studioCache = useStudioCache();
1143
- let t0;
1144
- if ($[0] !== projectId) {
1145
- t0 = (t1) => {
1146
- const { draftId, name } = t1;
1147
- return getDraftReadClient(draftId).drafts.rename({
1148
- projectId,
1149
- name
1150
- });
1151
- };
1152
- $[0] = projectId;
1153
- $[1] = t0;
1154
- } else t0 = $[1];
1155
- let t1;
1156
- if ($[2] !== projectId || $[3] !== studioCache) {
1157
- t1 = (renamed) => {
1158
- studioCache.set(reads.draft({
1159
- projectId,
1160
- draftId: renamed.id
1161
- }), renamed);
1162
- studioCache.invalidate(reads.draftList({ projectId }));
1163
- };
1164
- $[2] = projectId;
1165
- $[3] = studioCache;
1166
- $[4] = t1;
1167
- } else t1 = $[4];
1168
- let t2;
1169
- if ($[5] !== t0 || $[6] !== t1) {
1170
- t2 = {
1171
- mutationFn: t0,
1172
- onSuccess: t1,
1173
- onError: _temp13
1174
- };
1175
- $[5] = t0;
1176
- $[6] = t1;
1177
- $[7] = t2;
1178
- } else t2 = $[7];
1179
- return useMutation(t2);
1180
- }
1181
- function _temp13(error) {
1182
- return toast.error(error.message || "Could not rename the draft");
1183
- }
1184
- /**
1185
- * The draft's name in the review's header, renamed in place by any member (#203), like a page
1186
- * nickname in the Canvas Inspector: a title whose border shows on hover or focus, without
1187
- * moving the text. An unnamed draft shows its computed label until focused. Saves on Enter or
1188
- * blur, and a blank name clears it; Escape puts the name back.
1189
- */
1190
- function DraftNameInput(t0) {
1191
- const $ = c(23);
1192
- const { projectId, draft, ref, className } = t0;
1193
- const rename = useRenameDraft(projectId);
1194
- const name = draft.name ?? "";
1195
- let t1;
1196
- if ($[0] !== draft.id || $[1] !== draft.name || $[2] !== name || $[3] !== rename) {
1197
- t1 = (input) => {
1198
- if ((input.value.trim() || null) === draft.name) {
1199
- input.value = name;
1200
- return;
1201
- }
1202
- rename.mutate({
1203
- draftId: draft.id,
1204
- name: input.value
1205
- }, { onError: () => void (input.value = name) });
1206
- };
1207
- $[0] = draft.id;
1208
- $[1] = draft.name;
1209
- $[2] = name;
1210
- $[3] = rename;
1211
- $[4] = t1;
1212
- } else t1 = $[4];
1213
- const save = t1;
1214
- let t2;
1215
- if ($[5] !== draft) {
1216
- t2 = draftLabel({
1217
- ...draft,
1218
- name: null
1219
- });
1220
- $[5] = draft;
1221
- $[6] = t2;
1222
- } else t2 = $[6];
1223
- let t3;
1224
- if ($[7] !== draft) {
1225
- t3 = draftLabel(draft);
1226
- $[7] = draft;
1227
- $[8] = t3;
1228
- } else t3 = $[8];
1229
- let t4;
1230
- if ($[9] !== className) {
1231
- t4 = cn("hover:border-input focus-visible:border-ring focus-visible:ring-ring/50 placeholder:text-foreground focus:placeholder:text-muted-foreground -mx-1.5 h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-base font-medium transition-[color,box-shadow,border-color] outline-none hover:shadow-xs focus-visible:ring-3", className);
1232
- $[9] = className;
1233
- $[10] = t4;
1234
- } else t4 = $[10];
1235
- let t5;
1236
- if ($[11] !== save) {
1237
- t5 = (event) => save(event.currentTarget);
1238
- $[11] = save;
1239
- $[12] = t5;
1240
- } else t5 = $[12];
1241
- let t6;
1242
- if ($[13] !== name) {
1243
- t6 = (event_0) => {
1244
- if (event_0.key === "Enter") {
1245
- event_0.preventDefault();
1246
- event_0.currentTarget.blur();
1247
- }
1248
- if (event_0.key !== "Escape") return;
1249
- event_0.stopPropagation();
1250
- event_0.currentTarget.value = name;
1251
- event_0.currentTarget.blur();
1252
- };
1253
- $[13] = name;
1254
- $[14] = t6;
1255
- } else t6 = $[14];
1256
- let t7;
1257
- if ($[15] !== name || $[16] !== ref || $[17] !== t2 || $[18] !== t3 || $[19] !== t4 || $[20] !== t5 || $[21] !== t6) {
1258
- t7 = /* @__PURE__ */ jsx("input", {
1259
- ref,
1260
- "aria-label": "Draft name",
1261
- defaultValue: name,
1262
- placeholder: t2,
1263
- title: t3,
1264
- maxLength: 200,
1265
- className: t4,
1266
- onBlur: t5,
1267
- onKeyDown: t6
1268
- }, name);
1269
- $[15] = name;
1270
- $[16] = ref;
1271
- $[17] = t2;
1272
- $[18] = t3;
1273
- $[19] = t4;
1274
- $[20] = t5;
1275
- $[21] = t6;
1276
- $[22] = t7;
1277
- } else t7 = $[22];
1278
- return t7;
1279
- }
1280
- /**
1281
1138
  * Reviews a draft before publishing it whole, or deletes it (ADR 0009). Publishing sends back
1282
1139
  * the token of the preview shown; when Live changed since, nothing is published and the new
1283
1140
  * preview is shown. Once the draft ends, the studio switches to Live.
1284
1141
  */
1285
1142
  function ReviewDraftSheet(t0) {
1286
- const $ = c(81);
1287
- const { projectId, draftId, open, startRenaming: t1, onOpenChange } = t0;
1288
- const startRenaming = t1 === void 0 ? false : t1;
1143
+ const $ = c(74);
1144
+ const { projectId, draftId, open, onOpenChange } = t0;
1289
1145
  const [confirmingDelete, setConfirmingDelete] = React.useState(false);
1290
- let t2;
1146
+ let t1;
1291
1147
  if ($[0] !== draftId || $[1] !== projectId) {
1292
- t2 = reads.publishPreview({
1148
+ t1 = reads.publishPreview({
1293
1149
  projectId,
1294
1150
  draftId
1295
1151
  });
1296
1152
  $[0] = draftId;
1297
1153
  $[1] = projectId;
1298
- $[2] = t2;
1299
- } else t2 = $[2];
1300
- let t3;
1154
+ $[2] = t1;
1155
+ } else t1 = $[2];
1156
+ let t2;
1301
1157
  if ($[3] !== open) {
1302
- t3 = { enabled: open };
1158
+ t2 = { enabled: open };
1303
1159
  $[3] = open;
1304
- $[4] = t3;
1305
- } else t3 = $[4];
1306
- const preview = useReadQuery(t2, t3);
1307
- let t4;
1160
+ $[4] = t2;
1161
+ } else t2 = $[4];
1162
+ const preview = useReadQuery(t1, t2);
1163
+ let t3;
1308
1164
  if ($[5] !== draftId || $[6] !== projectId) {
1309
- t4 = reads.draft({
1165
+ t3 = reads.draft({
1310
1166
  projectId,
1311
1167
  draftId
1312
1168
  });
1313
1169
  $[5] = draftId;
1314
1170
  $[6] = projectId;
1315
- $[7] = t4;
1316
- } else t4 = $[7];
1317
- let t5;
1171
+ $[7] = t3;
1172
+ } else t3 = $[7];
1173
+ let t4;
1318
1174
  if ($[8] !== open) {
1319
- t5 = { enabled: open };
1175
+ t4 = { enabled: open };
1320
1176
  $[8] = open;
1321
- $[9] = t5;
1322
- } else t5 = $[9];
1323
- const draft = useReadQuery(t4, t5);
1324
- let t6;
1177
+ $[9] = t4;
1178
+ } else t4 = $[9];
1179
+ const draft = useReadQuery(t3, t4);
1180
+ let t5;
1325
1181
  if ($[10] !== projectId) {
1326
- t6 = reads.localeList({ projectId });
1182
+ t5 = reads.localeList({ projectId });
1327
1183
  $[10] = projectId;
1328
- $[11] = t6;
1329
- } else t6 = $[11];
1330
- let t7;
1184
+ $[11] = t5;
1185
+ } else t5 = $[11];
1186
+ let t6;
1331
1187
  if ($[12] !== open) {
1332
- t7 = { enabled: open };
1188
+ t6 = { enabled: open };
1333
1189
  $[12] = open;
1334
- $[13] = t7;
1335
- } else t7 = $[13];
1336
- const locales = useReadQuery(t6, t7);
1190
+ $[13] = t6;
1191
+ } else t6 = $[13];
1192
+ const locales = useReadQuery(t5, t6);
1337
1193
  const leaveDraft = useLeaveDraft();
1338
1194
  const showInCanvas = useShowInCanvas();
1339
1195
  const popup = React.useRef(null);
1340
- const nameInput = React.useRef(null);
1341
- let t8;
1342
- if ($[14] !== startRenaming) {
1343
- t8 = () => {
1344
- if (startRenaming && nameInput.current) {
1345
- nameInput.current.select();
1346
- return nameInput.current;
1347
- }
1348
- return popup.current;
1349
- };
1350
- $[14] = startRenaming;
1351
- $[15] = t8;
1352
- } else t8 = $[15];
1353
- const initialFocus = t8;
1354
- let t9;
1355
- if ($[16] !== draft.data?.translatingLocales) {
1356
- t9 = draft.data?.translatingLocales.join(",");
1357
- $[16] = draft.data?.translatingLocales;
1358
- $[17] = t9;
1359
- } else t9 = $[17];
1360
- const pending = t9;
1196
+ let t7;
1197
+ if ($[14] !== draft.data?.translatingLocales) {
1198
+ t7 = draft.data?.translatingLocales.join(",");
1199
+ $[14] = draft.data?.translatingLocales;
1200
+ $[15] = t7;
1201
+ } else t7 = $[15];
1202
+ const pending = t7;
1361
1203
  const seenPending = React.useRef(pending);
1362
1204
  const { refetch } = preview;
1363
- let t10;
1364
- let t11;
1365
- if ($[18] !== pending || $[19] !== refetch) {
1366
- t10 = () => {
1205
+ let t8;
1206
+ let t9;
1207
+ if ($[16] !== pending || $[17] !== refetch) {
1208
+ t8 = () => {
1367
1209
  if (seenPending.current !== void 0 && seenPending.current !== pending) refetch();
1368
1210
  seenPending.current = pending;
1369
1211
  };
1370
- t11 = [pending, refetch];
1371
- $[18] = pending;
1372
- $[19] = refetch;
1373
- $[20] = t10;
1374
- $[21] = t11;
1212
+ t9 = [pending, refetch];
1213
+ $[16] = pending;
1214
+ $[17] = refetch;
1215
+ $[18] = t8;
1216
+ $[19] = t9;
1375
1217
  } else {
1376
- t10 = $[20];
1377
- t11 = $[21];
1218
+ t8 = $[18];
1219
+ t9 = $[19];
1378
1220
  }
1379
- React.useEffect(t10, t11);
1380
- const discard = draft.data?.name === null;
1381
- let t12;
1382
- if ($[22] !== discard || $[23] !== leaveDraft || $[24] !== onOpenChange) {
1383
- t12 = (ended) => {
1221
+ React.useEffect(t8, t9);
1222
+ let t10;
1223
+ if ($[20] !== leaveDraft || $[21] !== onOpenChange) {
1224
+ t10 = (ended) => {
1384
1225
  onOpenChange(false);
1385
- leaveDraft(ended, { discarded: discard });
1226
+ leaveDraft(ended);
1386
1227
  };
1387
- $[22] = discard;
1388
- $[23] = leaveDraft;
1389
- $[24] = onOpenChange;
1390
- $[25] = t12;
1391
- } else t12 = $[25];
1392
- const leave = t12;
1393
- let t13;
1394
- if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
1395
- t13 = draftMutations.publish();
1396
- $[26] = t13;
1397
- } else t13 = $[26];
1398
- let t14;
1399
- if ($[27] !== leave || $[28] !== preview) {
1400
- t14 = (result) => {
1228
+ $[20] = leaveDraft;
1229
+ $[21] = onOpenChange;
1230
+ $[22] = t10;
1231
+ } else t10 = $[22];
1232
+ const leave = t10;
1233
+ let t11;
1234
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
1235
+ t11 = draftMutations.publish();
1236
+ $[23] = t11;
1237
+ } else t11 = $[23];
1238
+ let t12;
1239
+ if ($[24] !== leave || $[25] !== preview) {
1240
+ t12 = (result) => {
1401
1241
  if ("publishing" in result && result.publishing) {
1402
1242
  preview.refetch();
1403
1243
  return;
@@ -1407,13 +1247,13 @@ function ReviewDraftSheet(t0) {
1407
1247
  toast.info("This draft has no changes, so there is nothing to publish.");
1408
1248
  preview.refetch();
1409
1249
  };
1410
- $[27] = leave;
1411
- $[28] = preview;
1412
- $[29] = t14;
1413
- } else t14 = $[29];
1414
- let t15;
1415
- if ($[30] !== preview) {
1416
- t15 = (error) => {
1250
+ $[24] = leave;
1251
+ $[25] = preview;
1252
+ $[26] = t12;
1253
+ } else t12 = $[26];
1254
+ let t13;
1255
+ if ($[27] !== preview) {
1256
+ t13 = (error) => {
1417
1257
  if (error.code === CONFLICTS_CHANGED_ERROR) {
1418
1258
  toast.error("Live changed since you opened this review. Check the new list.");
1419
1259
  preview.refetch();
@@ -1438,37 +1278,35 @@ function ReviewDraftSheet(t0) {
1438
1278
  toast.error(error.message || "Could not publish the draft");
1439
1279
  preview.refetch();
1440
1280
  };
1441
- $[30] = preview;
1442
- $[31] = t15;
1443
- } else t15 = $[31];
1444
- let t16;
1445
- if ($[32] !== t14 || $[33] !== t15) {
1446
- t16 = {
1447
- ...t13,
1448
- onSuccess: t14,
1449
- onError: t15
1281
+ $[27] = preview;
1282
+ $[28] = t13;
1283
+ } else t13 = $[28];
1284
+ let t14;
1285
+ if ($[29] !== t12 || $[30] !== t13) {
1286
+ t14 = {
1287
+ ...t11,
1288
+ onSuccess: t12,
1289
+ onError: t13
1450
1290
  };
1451
- $[32] = t14;
1452
- $[33] = t15;
1453
- $[34] = t16;
1454
- } else t16 = $[34];
1455
- const publish = useMutation(t16);
1291
+ $[29] = t12;
1292
+ $[30] = t13;
1293
+ $[31] = t14;
1294
+ } else t14 = $[31];
1295
+ const publish = useMutation(t14);
1456
1296
  const data = preview.data;
1457
1297
  const headline = data?.overview.status === "ready" ? data.overview.headline : null;
1458
1298
  const busy = publish.isPending;
1459
1299
  const ready = !!data && data.blockers.length === 0 && data.translating.length === 0 && data.findings.length === 0 && data.checking.length === 0 && !data.code?.building && !data.code?.publishing && !busy && !preview.isFetching;
1460
- let t17;
1461
- if ($[35] !== draft.data || $[36] !== headline || $[37] !== projectId) {
1462
- t17 = /* @__PURE__ */ jsx("div", {
1300
+ let t15;
1301
+ if ($[32] !== draft.data || $[33] !== headline) {
1302
+ t15 = /* @__PURE__ */ jsx("div", {
1463
1303
  className: "flex flex-col gap-1 border-b p-4 pr-12",
1464
- children: headline ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(SheetDescription, {
1304
+ children: headline ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SheetDescription, {
1465
1305
  className: "flex min-w-0 items-center gap-1",
1466
- children: [draft.data && /* @__PURE__ */ jsx(DraftNameInput, {
1467
- ref: nameInput,
1468
- projectId,
1469
- draft: draft.data,
1470
- className: "placeholder:text-muted-foreground text-muted-foreground field-sizing-content h-6 w-auto max-w-full text-sm font-normal"
1471
- }), draft.data && /* @__PURE__ */ jsxs("span", {
1306
+ children: draft.data && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
1307
+ className: "truncate",
1308
+ children: draftLabel(draft.data)
1309
+ }), /* @__PURE__ */ jsxs("span", {
1472
1310
  className: "shrink-0",
1473
1311
  children: [
1474
1312
  "· ",
@@ -1476,30 +1314,22 @@ function ReviewDraftSheet(t0) {
1476
1314
  ", started ",
1477
1315
  timeAgo(draft.data.createdAt)
1478
1316
  ]
1479
- })]
1317
+ })] })
1480
1318
  }), /* @__PURE__ */ jsx(SheetTitle, {
1481
1319
  className: "text-lg leading-snug font-semibold",
1482
1320
  children: headline
1483
- })] }) : /* @__PURE__ */ jsxs(Fragment, { children: [draft.data ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SheetTitle, {
1484
- className: "sr-only",
1485
- children: draftLabel(draft.data)
1486
- }), /* @__PURE__ */ jsx(DraftNameInput, {
1487
- ref: nameInput,
1488
- projectId,
1489
- draft: draft.data
1490
- })] }) : /* @__PURE__ */ jsx(SheetTitle, {
1491
- className: "text-base",
1492
- children: "Draft"
1321
+ })] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SheetTitle, {
1322
+ className: "truncate text-base",
1323
+ children: draft.data ? draftLabel(draft.data) : "Draft"
1493
1324
  }), /* @__PURE__ */ jsx(SheetDescription, { children: draft.data ? `${draft.data.createdBy.name} · started ${timeAgo(draft.data.createdAt)}` : "Publishing applies this whole draft to Live." })] })
1494
1325
  });
1495
- $[35] = draft.data;
1496
- $[36] = headline;
1497
- $[37] = projectId;
1498
- $[38] = t17;
1499
- } else t17 = $[38];
1500
- let t18;
1501
- if ($[39] !== data || $[40] !== locales || $[41] !== onOpenChange || $[42] !== preview || $[43] !== projectId || $[44] !== showInCanvas) {
1502
- t18 = data ? /* @__PURE__ */ jsxs("div", {
1326
+ $[32] = draft.data;
1327
+ $[33] = headline;
1328
+ $[34] = t15;
1329
+ } else t15 = $[34];
1330
+ let t16;
1331
+ if ($[35] !== data || $[36] !== locales || $[37] !== onOpenChange || $[38] !== preview || $[39] !== projectId || $[40] !== showInCanvas) {
1332
+ t16 = data ? /* @__PURE__ */ jsxs("div", {
1503
1333
  className: "flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto p-4",
1504
1334
  children: [
1505
1335
  /* @__PURE__ */ jsx(DraftOverview, {
@@ -1528,264 +1358,230 @@ function ReviewDraftSheet(t0) {
1528
1358
  className: "flex flex-1 items-center justify-center",
1529
1359
  children: /* @__PURE__ */ jsx(Spinner, { className: "text-muted-foreground" })
1530
1360
  });
1531
- $[39] = data;
1532
- $[40] = locales;
1533
- $[41] = onOpenChange;
1534
- $[42] = preview;
1535
- $[43] = projectId;
1536
- $[44] = showInCanvas;
1537
- $[45] = t18;
1538
- } else t18 = $[45];
1539
- let t19;
1540
- let t20;
1541
- if ($[46] === Symbol.for("react.memo_cache_sentinel")) {
1542
- t19 = () => setConfirmingDelete(true);
1543
- t20 = /* @__PURE__ */ jsx(Trash2, {});
1544
- $[46] = t19;
1545
- $[47] = t20;
1361
+ $[35] = data;
1362
+ $[36] = locales;
1363
+ $[37] = onOpenChange;
1364
+ $[38] = preview;
1365
+ $[39] = projectId;
1366
+ $[40] = showInCanvas;
1367
+ $[41] = t16;
1368
+ } else t16 = $[41];
1369
+ let t17;
1370
+ let t18;
1371
+ if ($[42] === Symbol.for("react.memo_cache_sentinel")) {
1372
+ t17 = () => setConfirmingDelete(true);
1373
+ t18 = /* @__PURE__ */ jsx(Trash2, {});
1374
+ $[42] = t17;
1375
+ $[43] = t18;
1546
1376
  } else {
1547
- t19 = $[46];
1548
- t20 = $[47];
1377
+ t17 = $[42];
1378
+ t18 = $[43];
1549
1379
  }
1550
- const t21 = discard ? "Discard changes" : "Delete draft";
1551
- let t22;
1552
- if ($[48] !== busy || $[49] !== t21) {
1553
- t22 = /* @__PURE__ */ jsxs(Button, {
1380
+ let t19;
1381
+ if ($[44] !== busy) {
1382
+ t19 = /* @__PURE__ */ jsxs(Button, {
1554
1383
  variant: "ghost",
1555
1384
  className: "text-destructive",
1556
1385
  disabled: busy,
1557
- onClick: t19,
1558
- children: [t20, t21]
1386
+ onClick: t17,
1387
+ children: [t18, "Delete draft"]
1559
1388
  });
1560
- $[48] = busy;
1389
+ $[44] = busy;
1390
+ $[45] = t19;
1391
+ } else t19 = $[45];
1392
+ const t20 = !ready;
1393
+ let t21;
1394
+ if ($[46] !== data || $[47] !== projectId || $[48] !== publish) {
1395
+ t21 = () => data && publish.mutate(publishInput(projectId, data));
1396
+ $[46] = data;
1397
+ $[47] = projectId;
1398
+ $[48] = publish;
1561
1399
  $[49] = t21;
1562
- $[50] = t22;
1563
- } else t22 = $[50];
1564
- const t23 = !ready;
1565
- let t24;
1566
- if ($[51] !== data || $[52] !== projectId || $[53] !== publish) {
1567
- t24 = () => data && publish.mutate(publishInput(projectId, data));
1568
- $[51] = data;
1569
- $[52] = projectId;
1570
- $[53] = publish;
1571
- $[54] = t24;
1572
- } else t24 = $[54];
1573
- let t25;
1574
- if ($[55] !== publish.isPending) {
1575
- t25 = publish.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
1576
- $[55] = publish.isPending;
1577
- $[56] = t25;
1578
- } else t25 = $[56];
1579
- let t26;
1580
- if ($[57] !== t23 || $[58] !== t24 || $[59] !== t25) {
1581
- t26 = /* @__PURE__ */ jsxs(Button, {
1400
+ } else t21 = $[49];
1401
+ let t22;
1402
+ if ($[50] !== publish.isPending) {
1403
+ t22 = publish.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
1404
+ $[50] = publish.isPending;
1405
+ $[51] = t22;
1406
+ } else t22 = $[51];
1407
+ let t23;
1408
+ if ($[52] !== t20 || $[53] !== t21 || $[54] !== t22) {
1409
+ t23 = /* @__PURE__ */ jsxs(Button, {
1582
1410
  className: "ml-auto",
1583
- disabled: t23,
1584
- onClick: t24,
1585
- children: [t25, "Publish"]
1411
+ disabled: t20,
1412
+ onClick: t21,
1413
+ children: [t22, "Publish"]
1586
1414
  });
1587
- $[57] = t23;
1588
- $[58] = t24;
1589
- $[59] = t25;
1590
- $[60] = t26;
1591
- } else t26 = $[60];
1592
- let t27;
1593
- if ($[61] !== t22 || $[62] !== t26) {
1594
- t27 = /* @__PURE__ */ jsx("div", {
1415
+ $[52] = t20;
1416
+ $[53] = t21;
1417
+ $[54] = t22;
1418
+ $[55] = t23;
1419
+ } else t23 = $[55];
1420
+ let t24;
1421
+ if ($[56] !== t19 || $[57] !== t23) {
1422
+ t24 = /* @__PURE__ */ jsx("div", {
1595
1423
  className: "flex flex-col gap-3 border-t p-4",
1596
1424
  children: /* @__PURE__ */ jsxs("div", {
1597
1425
  className: "flex items-center gap-2",
1598
- children: [t22, t26]
1426
+ children: [t19, t23]
1599
1427
  })
1600
1428
  });
1601
- $[61] = t22;
1602
- $[62] = t26;
1603
- $[63] = t27;
1604
- } else t27 = $[63];
1605
- let t28;
1606
- if ($[64] !== initialFocus || $[65] !== t17 || $[66] !== t18 || $[67] !== t27) {
1607
- t28 = /* @__PURE__ */ jsxs(SheetContent, {
1429
+ $[56] = t19;
1430
+ $[57] = t23;
1431
+ $[58] = t24;
1432
+ } else t24 = $[58];
1433
+ let t25;
1434
+ if ($[59] !== t15 || $[60] !== t16 || $[61] !== t24) {
1435
+ t25 = /* @__PURE__ */ jsxs(SheetContent, {
1608
1436
  ref: popup,
1609
- initialFocus,
1437
+ initialFocus: popup,
1610
1438
  side: "right",
1611
1439
  className: "w-full gap-0 data-[side=right]:sm:max-w-lg",
1612
1440
  children: [
1613
- t17,
1614
- t18,
1615
- t27
1441
+ t15,
1442
+ t16,
1443
+ t24
1616
1444
  ]
1617
1445
  });
1618
- $[64] = initialFocus;
1619
- $[65] = t17;
1620
- $[66] = t18;
1621
- $[67] = t27;
1622
- $[68] = t28;
1623
- } else t28 = $[68];
1624
- let t29;
1625
- if ($[69] !== onOpenChange || $[70] !== open || $[71] !== t28) {
1626
- t29 = /* @__PURE__ */ jsx(Sheet, {
1446
+ $[59] = t15;
1447
+ $[60] = t16;
1448
+ $[61] = t24;
1449
+ $[62] = t25;
1450
+ } else t25 = $[62];
1451
+ let t26;
1452
+ if ($[63] !== onOpenChange || $[64] !== open || $[65] !== t25) {
1453
+ t26 = /* @__PURE__ */ jsx(Sheet, {
1627
1454
  open,
1628
1455
  onOpenChange,
1629
- children: t28
1456
+ children: t25
1630
1457
  });
1631
- $[69] = onOpenChange;
1632
- $[70] = open;
1633
- $[71] = t28;
1634
- $[72] = t29;
1635
- } else t29 = $[72];
1636
- let t30;
1637
- if ($[73] !== confirmingDelete || $[74] !== discard || $[75] !== leave || $[76] !== projectId) {
1638
- t30 = /* @__PURE__ */ jsx(DeleteDraftDialog, {
1458
+ $[63] = onOpenChange;
1459
+ $[64] = open;
1460
+ $[65] = t25;
1461
+ $[66] = t26;
1462
+ } else t26 = $[66];
1463
+ let t27;
1464
+ if ($[67] !== confirmingDelete || $[68] !== leave || $[69] !== projectId) {
1465
+ t27 = /* @__PURE__ */ jsx(DeleteDraftDialog, {
1639
1466
  projectId,
1640
1467
  open: confirmingDelete,
1641
- discard,
1642
1468
  onOpenChange: setConfirmingDelete,
1643
1469
  onDeleted: leave
1644
1470
  });
1645
- $[73] = confirmingDelete;
1646
- $[74] = discard;
1647
- $[75] = leave;
1648
- $[76] = projectId;
1649
- $[77] = t30;
1650
- } else t30 = $[77];
1651
- let t31;
1652
- if ($[78] !== t29 || $[79] !== t30) {
1653
- t31 = /* @__PURE__ */ jsxs(Fragment, { children: [t29, t30] });
1654
- $[78] = t29;
1655
- $[79] = t30;
1656
- $[80] = t31;
1657
- } else t31 = $[80];
1658
- return t31;
1471
+ $[67] = confirmingDelete;
1472
+ $[68] = leave;
1473
+ $[69] = projectId;
1474
+ $[70] = t27;
1475
+ } else t27 = $[70];
1476
+ let t28;
1477
+ if ($[71] !== t26 || $[72] !== t27) {
1478
+ t28 = /* @__PURE__ */ jsxs(Fragment, { children: [t26, t27] });
1479
+ $[71] = t26;
1480
+ $[72] = t27;
1481
+ $[73] = t28;
1482
+ } else t28 = $[73];
1483
+ return t28;
1659
1484
  }
1660
- /**
1661
- * Asks before deleting the draft the studio is in, then deletes it. Deleting an unnamed draft
1662
- * is discarding its changes: nobody kept them as a draft yet.
1663
- */
1485
+ /** Asks before deleting the draft the studio is in, then deletes it. */
1664
1486
  function DeleteDraftDialog(t0) {
1665
- const $ = c(36);
1666
- const { projectId, open, discard: t1, onOpenChange, onDeleted } = t0;
1667
- const discard = t1 === void 0 ? false : t1;
1668
- let t2;
1487
+ const $ = c(26);
1488
+ const { projectId, open, onOpenChange, onDeleted } = t0;
1489
+ let t1;
1669
1490
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1670
- t2 = draftMutations.delete();
1671
- $[0] = t2;
1672
- } else t2 = $[0];
1673
- let t3;
1491
+ t1 = draftMutations.delete();
1492
+ $[0] = t1;
1493
+ } else t1 = $[0];
1494
+ let t2;
1674
1495
  if ($[1] !== onDeleted || $[2] !== onOpenChange) {
1675
- t3 = {
1676
- ...t2,
1677
- onSuccess: (t4) => {
1678
- const { ended } = t4;
1496
+ t2 = {
1497
+ ...t1,
1498
+ onSuccess: (t3) => {
1499
+ const { ended } = t3;
1679
1500
  onOpenChange(false);
1680
1501
  onDeleted(ended);
1681
1502
  },
1682
- onError: _temp14
1503
+ onError: _temp13
1683
1504
  };
1684
1505
  $[1] = onDeleted;
1685
1506
  $[2] = onOpenChange;
1686
- $[3] = t3;
1687
- } else t3 = $[3];
1688
- const deleteDraft = useMutation(t3);
1689
- let t4;
1507
+ $[3] = t2;
1508
+ } else t2 = $[3];
1509
+ const deleteDraft = useMutation(t2);
1510
+ let t3;
1690
1511
  if ($[4] !== deleteDraft.isPending || $[5] !== onOpenChange) {
1691
- t4 = (next) => {
1512
+ t3 = (next) => {
1692
1513
  if (!deleteDraft.isPending) onOpenChange(next);
1693
1514
  };
1694
1515
  $[4] = deleteDraft.isPending;
1695
1516
  $[5] = onOpenChange;
1696
- $[6] = t4;
1697
- } else t4 = $[6];
1698
- const t5 = discard ? "Discard these changes?" : "Delete this draft?";
1699
- let t6;
1700
- if ($[7] !== t5) {
1701
- t6 = /* @__PURE__ */ jsx(AlertDialogTitle, { children: t5 });
1702
- $[7] = t5;
1703
- $[8] = t6;
1704
- } else t6 = $[8];
1705
- const t7 = discard ? "These changes are" : "Every change in this draft is";
1706
- let t8;
1707
- if ($[9] !== t7) {
1708
- t8 = /* @__PURE__ */ jsxs(AlertDialogDescription, { children: [t7, " deleted for everyone. Live stays as it is. This can't be undone."] });
1709
- $[9] = t7;
1710
- $[10] = t8;
1711
- } else t8 = $[10];
1712
- let t9;
1713
- if ($[11] !== t6 || $[12] !== t8) {
1714
- t9 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [t6, t8] });
1715
- $[11] = t6;
1716
- $[12] = t8;
1717
- $[13] = t9;
1718
- } else t9 = $[13];
1719
- let t10;
1720
- if ($[14] !== deleteDraft.isPending) {
1721
- t10 = /* @__PURE__ */ jsx(AlertDialogCancel, {
1517
+ $[6] = t3;
1518
+ } else t3 = $[6];
1519
+ let t4;
1520
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
1521
+ t4 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Delete this draft?" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "Every change in this draft is deleted for everyone. Live stays as it is. This can't be undone." })] });
1522
+ $[7] = t4;
1523
+ } else t4 = $[7];
1524
+ let t5;
1525
+ if ($[8] !== deleteDraft.isPending) {
1526
+ t5 = /* @__PURE__ */ jsx(AlertDialogCancel, {
1722
1527
  variant: "outline",
1723
1528
  size: "default",
1724
1529
  disabled: deleteDraft.isPending,
1725
1530
  children: "Cancel"
1726
1531
  });
1727
- $[14] = deleteDraft.isPending;
1728
- $[15] = t10;
1729
- } else t10 = $[15];
1730
- let t11;
1731
- if ($[16] !== deleteDraft || $[17] !== projectId) {
1732
- t11 = () => deleteDraft.mutate({ projectId });
1733
- $[16] = deleteDraft;
1734
- $[17] = projectId;
1735
- $[18] = t11;
1736
- } else t11 = $[18];
1737
- let t12;
1738
- if ($[19] !== deleteDraft.isPending) {
1739
- t12 = deleteDraft.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
1740
- $[19] = deleteDraft.isPending;
1741
- $[20] = t12;
1742
- } else t12 = $[20];
1743
- const t13 = discard ? "Discard changes" : "Delete draft";
1744
- let t14;
1745
- if ($[21] !== deleteDraft.isPending || $[22] !== t11 || $[23] !== t12 || $[24] !== t13) {
1746
- t14 = /* @__PURE__ */ jsxs(AlertDialogAction, {
1532
+ $[8] = deleteDraft.isPending;
1533
+ $[9] = t5;
1534
+ } else t5 = $[9];
1535
+ let t6;
1536
+ if ($[10] !== deleteDraft || $[11] !== projectId) {
1537
+ t6 = () => deleteDraft.mutate({ projectId });
1538
+ $[10] = deleteDraft;
1539
+ $[11] = projectId;
1540
+ $[12] = t6;
1541
+ } else t6 = $[12];
1542
+ let t7;
1543
+ if ($[13] !== deleteDraft.isPending) {
1544
+ t7 = deleteDraft.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
1545
+ $[13] = deleteDraft.isPending;
1546
+ $[14] = t7;
1547
+ } else t7 = $[14];
1548
+ let t8;
1549
+ if ($[15] !== deleteDraft.isPending || $[16] !== t6 || $[17] !== t7) {
1550
+ t8 = /* @__PURE__ */ jsxs(AlertDialogAction, {
1747
1551
  variant: "destructive",
1748
1552
  disabled: deleteDraft.isPending,
1749
- onClick: t11,
1750
- children: [t12, t13]
1553
+ onClick: t6,
1554
+ children: [t7, "Delete draft"]
1751
1555
  });
1752
- $[21] = deleteDraft.isPending;
1753
- $[22] = t11;
1754
- $[23] = t12;
1755
- $[24] = t13;
1756
- $[25] = t14;
1757
- } else t14 = $[25];
1758
- let t15;
1759
- if ($[26] !== t10 || $[27] !== t14) {
1760
- t15 = /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t10, t14] });
1761
- $[26] = t10;
1762
- $[27] = t14;
1763
- $[28] = t15;
1764
- } else t15 = $[28];
1765
- let t16;
1766
- if ($[29] !== t15 || $[30] !== t9) {
1767
- t16 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t9, t15] });
1768
- $[29] = t15;
1769
- $[30] = t9;
1770
- $[31] = t16;
1771
- } else t16 = $[31];
1772
- let t17;
1773
- if ($[32] !== open || $[33] !== t16 || $[34] !== t4) {
1774
- t17 = /* @__PURE__ */ jsx(AlertDialog, {
1556
+ $[15] = deleteDraft.isPending;
1557
+ $[16] = t6;
1558
+ $[17] = t7;
1559
+ $[18] = t8;
1560
+ } else t8 = $[18];
1561
+ let t9;
1562
+ if ($[19] !== t5 || $[20] !== t8) {
1563
+ t9 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t4, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t5, t8] })] });
1564
+ $[19] = t5;
1565
+ $[20] = t8;
1566
+ $[21] = t9;
1567
+ } else t9 = $[21];
1568
+ let t10;
1569
+ if ($[22] !== open || $[23] !== t3 || $[24] !== t9) {
1570
+ t10 = /* @__PURE__ */ jsx(AlertDialog, {
1775
1571
  open,
1776
- onOpenChange: t4,
1777
- children: t16
1572
+ onOpenChange: t3,
1573
+ children: t9
1778
1574
  });
1779
- $[32] = open;
1780
- $[33] = t16;
1781
- $[34] = t4;
1782
- $[35] = t17;
1783
- } else t17 = $[35];
1784
- return t17;
1575
+ $[22] = open;
1576
+ $[23] = t3;
1577
+ $[24] = t9;
1578
+ $[25] = t10;
1579
+ } else t10 = $[25];
1580
+ return t10;
1785
1581
  }
1786
- function _temp14(error) {
1582
+ function _temp13(error) {
1787
1583
  return toast.error(error.message || "Could not delete the draft");
1788
1584
  }
1789
1585
 
1790
1586
  //#endregion
1791
- export { DeleteDraftDialog, ReviewDraftSheet, useRenameDraft };
1587
+ export { DeleteDraftDialog, ReviewDraftSheet };