@marktiderman/genesis-sites 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +23 -2
  2. package/SKILL.md +5 -1
  3. package/dist/assets/{form-island.7bd31cce05.js → form-island.c28e464326.js} +3 -3
  4. package/dist/assets/{islands.ee3511d602.js → islands.7cc682fc1f.js} +1 -1
  5. package/dist/assets/sites-forms.1559674309.css +10 -0
  6. package/dist/assets/sites-forms.css +1 -1
  7. package/dist/assets/sites.7108ff951d.css +2 -0
  8. package/dist/assets/sites.css +1 -1
  9. package/dist/assets.generated-QJK3COCH.js +3 -0
  10. package/dist/{assets.generated-4XWKKLCZ.js.map → assets.generated-QJK3COCH.js.map} +1 -1
  11. package/dist/{chunk-JXIKG55Y.js → chunk-5LEY4UFU.js} +6 -6
  12. package/dist/{chunk-JXIKG55Y.js.map → chunk-5LEY4UFU.js.map} +1 -1
  13. package/dist/{chunk-YAASBQTJ.js → chunk-IU6AI75R.js} +10 -3
  14. package/dist/chunk-IU6AI75R.js.map +1 -0
  15. package/dist/{chunk-FFFP5DH6.js → chunk-KY4ALBVH.js} +43 -4
  16. package/dist/chunk-KY4ALBVH.js.map +1 -0
  17. package/dist/{chunk-RSU5VL44.js → chunk-SMJMXQ3T.js} +3 -3
  18. package/dist/{chunk-RSU5VL44.js.map → chunk-SMJMXQ3T.js.map} +1 -1
  19. package/dist/chunk-TPBKCLES.js +19 -0
  20. package/dist/chunk-TPBKCLES.js.map +1 -0
  21. package/dist/{chunk-P6LQDETQ.js → chunk-VJ4HOFBA.js} +3 -3
  22. package/dist/{chunk-P6LQDETQ.js.map → chunk-VJ4HOFBA.js.map} +1 -1
  23. package/dist/editor.d.ts +76 -6
  24. package/dist/editor.js +545 -129
  25. package/dist/editor.js.map +1 -1
  26. package/dist/handler-VQ4QKTUU.js +10 -0
  27. package/dist/{handler-LD32KEDP.js.map → handler-VQ4QKTUU.js.map} +1 -1
  28. package/dist/import.d.ts +3 -3
  29. package/dist/index.d.ts +45 -6
  30. package/dist/index.js +3 -3
  31. package/dist/{registry-CeSBSfU8.d.ts → registry-BIijndsq.d.ts} +7 -1
  32. package/dist/sections.d.ts +1 -1
  33. package/dist/sections.js +2 -2
  34. package/dist/{store-CUsfzNmK.d.ts → store-BImtGmoF.d.ts} +2 -2
  35. package/dist/supabase.d.ts +4 -4
  36. package/dist/supabase.js +3 -3
  37. package/dist/{templates-DALVa71A.d.ts → templates-kA-jrnWA.d.ts} +2 -2
  38. package/dist/templates.d.ts +3 -3
  39. package/dist/{theme-B3Vh_b-P.d.ts → theme-Cg-inpk5.d.ts} +1 -1
  40. package/dist/web.d.ts +6 -6
  41. package/dist/web.js +5 -5
  42. package/package.json +6 -6
  43. package/dist/assets/sites-forms.e7b97e8ede.css +0 -10
  44. package/dist/assets/sites.debee7c477.css +0 -2
  45. package/dist/assets.generated-4XWKKLCZ.js +0 -3
  46. package/dist/chunk-FFFP5DH6.js.map +0 -1
  47. package/dist/chunk-O6LTQZRQ.js +0 -19
  48. package/dist/chunk-O6LTQZRQ.js.map +0 -1
  49. package/dist/chunk-YAASBQTJ.js.map +0 -1
  50. package/dist/handler-LD32KEDP.js +0 -10
package/dist/editor.js CHANGED
@@ -1,14 +1,14 @@
1
- import { starterSite, exampleBrands, landingPage } from './chunk-FFFP5DH6.js';
2
- import './chunk-RSU5VL44.js';
1
+ import { starterSite, exampleBrands, landingDirectory, landingPath, landingSlugProblems, landingDirectoryProblems, landingMoves, isLandingPage, landingPage, landingPages, landingSlugOf } from './chunk-KY4ALBVH.js';
2
+ import './chunk-SMJMXQ3T.js';
3
3
  import './chunk-VZUDRPFG.js';
4
- import { stableHash, isConflict, prepareRelease, PublishBlockedError, siteTheme, brandDisplayName, themeCss, migrateNode, migratePage, migrateSite } from './chunk-P6LQDETQ.js';
5
- import { getSection, sectionJsonSchema, listSections, SECTION_CATEGORIES, PageDoc, SiteDoc, newSectionId } from './chunk-YAASBQTJ.js';
4
+ import { stableHash, isConflict, prepareRelease, PublishBlockedError, SiteConflictError, siteTheme, brandDisplayName, themeCss, migrateNode, migratePage, migrateSite } from './chunk-VJ4HOFBA.js';
5
+ import { getSection, sectionJsonSchema, listSections, SECTION_CATEGORIES, PageDoc, SiteDoc, newSectionId } from './chunk-IU6AI75R.js';
6
6
  import { isSafeImageSrc, DEFAULT_RESERVED_PATHS, pagePathProblems, isSafeHref } from './chunk-MU2Z2C4F.js';
7
- import * as React7 from 'react';
7
+ import * as React8 from 'react';
8
8
  import { createContext, useContext } from 'react';
9
9
  import { createUsePuck, Puck } from '@puckeditor/core';
10
10
  export { createUsePuck, usePuck } from '@puckeditor/core';
11
- import { Undo2, Redo2, Monitor, Tablet, Smartphone, CheckCircle2, Eye, ExternalLink, RotateCcw, Plus, Home, FileText, ArrowUp, ArrowDown, Trash2, AlertCircle, AlertTriangle } from 'lucide-react';
11
+ import { Undo2, Redo2, Monitor, Tablet, Smartphone, Plus, Megaphone, Trash2, CheckCircle2, Eye, ExternalLink, RotateCcw, Home, FileText, ArrowUp, ArrowDown, AlertCircle, AlertTriangle } from 'lucide-react';
12
12
  import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from '@marktiderman/genesis-ui/alert-dialog';
13
13
  import { Alert, AlertTitle, AlertDescription } from '@marktiderman/genesis-ui/alert';
14
14
  import { Button } from '@marktiderman/genesis-ui/button';
@@ -47,18 +47,18 @@ function uploadProblem(file, maxBytes = 10 * 1024 * 1024) {
47
47
  }
48
48
  function AssetPicker({ open, siteId, store, assets, current, altElsewhere = false, onDone }) {
49
49
  const canUpload = Boolean(assets?.upload || store.putAsset);
50
- const [tab, setTab] = React7.useState(canUpload ? "upload" : "link");
51
- const [file, setFile] = React7.useState(null);
52
- const [url, setUrl] = React7.useState(current?.src ?? "");
53
- const [chosen, setChosen] = React7.useState(null);
54
- const [alt, setAlt] = React7.useState(current?.alt ?? "");
55
- const [decorative, setDecorative] = React7.useState(current?.decorative === true);
56
- const [library, setLibrary] = React7.useState(null);
57
- const [uploaded, setUploaded] = React7.useState([]);
58
- const [busy, setBusy] = React7.useState(false);
59
- const [error, setError] = React7.useState(null);
60
- const id = React7.useId();
61
- React7.useEffect(() => {
50
+ const [tab, setTab] = React8.useState(canUpload ? "upload" : "link");
51
+ const [file, setFile] = React8.useState(null);
52
+ const [url, setUrl] = React8.useState(current?.src ?? "");
53
+ const [chosen, setChosen] = React8.useState(null);
54
+ const [alt, setAlt] = React8.useState(current?.alt ?? "");
55
+ const [decorative, setDecorative] = React8.useState(current?.decorative === true);
56
+ const [library, setLibrary] = React8.useState(null);
57
+ const [uploaded, setUploaded] = React8.useState([]);
58
+ const [busy, setBusy] = React8.useState(false);
59
+ const [error, setError] = React8.useState(null);
60
+ const id = React8.useId();
61
+ React8.useEffect(() => {
62
62
  if (!open) return;
63
63
  setFile(null);
64
64
  setChosen(null);
@@ -584,9 +584,9 @@ function RichTextField({ field, id, value, onChange, readOnly }) {
584
584
  }
585
585
  function LinesField({ field, id, value, onChange, readOnly }) {
586
586
  const max = field.metadata?.maxItems;
587
- const [text, setText] = React7.useState(() => (value ?? []).join("\n"));
588
- const lastSent = React7.useRef(value);
589
- React7.useEffect(() => {
587
+ const [text, setText] = React8.useState(() => (value ?? []).join("\n"));
588
+ const lastSent = React8.useRef(value);
589
+ React8.useEffect(() => {
590
590
  if (JSON.stringify(value ?? []) !== JSON.stringify(lastSent.current ?? [])) setText((value ?? []).join("\n"));
591
591
  }, [value]);
592
592
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
@@ -818,7 +818,7 @@ var CATEGORY_TITLES = {
818
818
  footer: "Footer"
819
819
  };
820
820
  var META = /* @__PURE__ */ new Set(["puck", "editMode", "id"]);
821
- var SectionBoundary = class extends React7.Component {
821
+ var SectionBoundary = class extends React8.Component {
822
822
  state = { error: null };
823
823
  static getDerivedStateFromError(error) {
824
824
  return { error };
@@ -936,7 +936,7 @@ function createEditorConfig(options2 = {}) {
936
936
  return { config, components: info, slotKeys: (type) => slots.get(sectionTypeOf(type)) ?? [] };
937
937
  }
938
938
  var usePuck = createUsePuck();
939
- var EditorLockContext = React7.createContext(false);
939
+ var EditorLockContext = React8.createContext(false);
940
940
  var fieldId = (p) => p.id ?? `gs-field-${p.name.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
941
941
  function FieldShell({ id, label, children }) {
942
942
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 py-1", children: [
@@ -1002,10 +1002,10 @@ function ComponentItem({ name, info, announce }) {
1002
1002
  const data = usePuck((s) => s.appState.data);
1003
1003
  const meta = info.get(name);
1004
1004
  const type = sectionTypeOf(name);
1005
- const used = React7.useMemo(() => countTypes(data).get(type) ?? 0, [data, type]);
1005
+ const used = React8.useMemo(() => countTypes(data).get(type) ?? 0, [data, type]);
1006
1006
  const full = meta?.limit !== void 0 && used >= meta.limit;
1007
1007
  const dispatch = usePuck((s) => s.dispatch);
1008
- const locked = React7.useContext(EditorLockContext);
1008
+ const locked = React8.useContext(EditorLockContext);
1009
1009
  const label = meta?.label ?? name;
1010
1010
  const add = () => {
1011
1011
  if (locked) return;
@@ -1018,8 +1018,8 @@ function ComponentItem({ name, info, announce }) {
1018
1018
  scrollCanvasTo(id, ref.current?.ownerDocument);
1019
1019
  announce?.(`${label} added at the end of the ${zone === "root:header" ? "header" : zone === "root:footer" ? "footer" : "page"}. Its fields are open; Up and Down move it.`);
1020
1020
  };
1021
- const ref = React7.useRef(null);
1022
- React7.useEffect(() => {
1021
+ const ref = React8.useRef(null);
1022
+ React8.useEffect(() => {
1023
1023
  const copy = ref.current?.closest('[class*="draggableBg"]');
1024
1024
  if (copy) {
1025
1025
  copy.setAttribute("aria-hidden", "true");
@@ -1050,9 +1050,9 @@ function SectionActions({ info, announce }) {
1050
1050
  const getSelectorForId = usePuck((s) => s.getSelectorForId);
1051
1051
  const getItemBySelector = usePuck((s) => s.getItemBySelector);
1052
1052
  const dispatch = usePuck((s) => s.dispatch);
1053
- const locked = React7.useContext(EditorLockContext);
1054
- const upRef = React7.useRef(null);
1055
- const downRef = React7.useRef(null);
1053
+ const locked = React8.useContext(EditorLockContext);
1054
+ const upRef = React8.useRef(null);
1055
+ const downRef = React8.useRef(null);
1056
1056
  if (!selected) return null;
1057
1057
  const id = String(selected.props.id);
1058
1058
  const selector = getSelectorForId(id);
@@ -1208,28 +1208,387 @@ function pageTemplates() {
1208
1208
  }
1209
1209
  return templates;
1210
1210
  }
1211
- async function movePageInList(store, siteId, pageId, by) {
1211
+ async function movePageInList(store, siteId, pageId, by, options2 = {}) {
1212
1212
  if (!store.reorderPages) throw new Error("This store keeps pages in its own order.");
1213
1213
  const pages = await store.listPages(siteId);
1214
1214
  const i = pages.findIndex((p) => p.id === pageId);
1215
- const j = i + by;
1215
+ let j = i + by;
1216
+ if (options2.within) while (j >= 0 && j < pages.length && !options2.within(pages[j])) j += by;
1216
1217
  if (i < 0 || j < 0 || j >= pages.length) return pages;
1217
1218
  const ids = pages.map((p) => p.id);
1218
1219
  [ids[i], ids[j]] = [ids[j], ids[i]];
1219
1220
  await store.reorderPages(siteId, ids);
1220
1221
  return store.listPages(siteId);
1221
1222
  }
1223
+ async function createLandingPage(store, siteId, input) {
1224
+ const title = input.title.trim();
1225
+ if (!title) throw new Error("Give the landing page a title.");
1226
+ const draft = await store.getDraft(siteId);
1227
+ if (!draft) throw new Error(`There's no site ${siteId}, or you can't edit it.`);
1228
+ const directory = landingDirectory(draft.site);
1229
+ const path = landingPath(directory, input.slug);
1230
+ const problems = landingSlugProblems(directory, input.slug, input.reserved ?? DEFAULT_RESERVED_PATHS);
1231
+ if ((await store.listPages(siteId)).some((p) => p.path === path)) problems.push(`A page is already at ${path}.`);
1232
+ if (problems.length) throw new Error(problems.join(" "));
1233
+ const template = pageTemplates().find((t) => t.id === "landing");
1234
+ return store.createPage(siteId, { path, kind: "landing", doc: template.doc({ title, brand: input.brand }) });
1235
+ }
1236
+ async function moveLandingPage(store, pageId, slug, options2 = {}) {
1237
+ const current = await store.getPageDraft(pageId);
1238
+ if (!current) throw new Error("That page no longer exists.");
1239
+ const draft = await store.getDraft(current.siteId);
1240
+ if (!draft) throw new Error("You can't edit this site.");
1241
+ const directory = landingDirectory(draft.site);
1242
+ const problems = landingSlugProblems(directory, slug, options2.reserved ?? DEFAULT_RESERVED_PATHS);
1243
+ if (problems.length) throw new Error(problems.join(" "));
1244
+ return renamePage(store, pageId, landingPath(directory, slug), options2);
1245
+ }
1246
+ async function setLandingDirectory(store, siteId, directory, options2 = {}) {
1247
+ const reserved = options2.reserved ?? DEFAULT_RESERVED_PATHS;
1248
+ const problems = landingDirectoryProblems(directory, reserved);
1249
+ if (problems.length) throw new Error(problems.join(" "));
1250
+ const before = await store.getDraft(siteId);
1251
+ if (!before) throw new Error(`There's no site ${siteId}, or you can't edit it.`);
1252
+ const moved = [];
1253
+ const partly = (err) => moved.length ? new LandingDirectoryError(moved, err) : err;
1254
+ if (options2.movePages) {
1255
+ const pages = await store.listPages(siteId);
1256
+ const moves = landingMoves(pages, landingDirectory(before.site), directory);
1257
+ const moving = new Set(moves.map((m) => m.page.id));
1258
+ const staying = pages.filter((p) => !moving.has(p.id));
1259
+ const errors = moves.flatMap((m) => pathProblems(m.path, staying, { reserved }));
1260
+ const leaving = new Set(moves.map((m) => m.page.path));
1261
+ for (const m of moves) if (leaving.has(m.path)) errors.push(`${m.path} is the old address of another landing page, and must keep redirecting to it.`);
1262
+ if (errors.length) throw new Error(`The landing pages can't move to ${directory}: ${[...new Set(errors)].join(" ")}`);
1263
+ for (const m of moves) {
1264
+ try {
1265
+ moved.push(await store.movePage(m.page.id, m.path));
1266
+ } catch (err) {
1267
+ throw partly(err);
1268
+ }
1269
+ }
1270
+ }
1271
+ for (let attempt = 0; ; attempt++) {
1272
+ const draft = attempt === 0 && !moved.length ? before : await store.getDraft(siteId);
1273
+ if (!draft) throw partly(new Error(`There's no site ${siteId}, or you can't edit it.`));
1274
+ let saved;
1275
+ try {
1276
+ saved = await store.saveSiteDraft(siteId, draft.rev, { ...draft.site, landing: { ...draft.site.landing, directory } });
1277
+ } catch (err) {
1278
+ throw partly(err);
1279
+ }
1280
+ if (!isConflict(saved)) break;
1281
+ if (attempt >= 1) throw moved.length ? partly(new SiteConflictError()) : new SiteConflictError();
1282
+ }
1283
+ return { directory, moved };
1284
+ }
1285
+ var LandingDirectoryError = class extends Error {
1286
+ constructor(moved, cause) {
1287
+ super(`Moved ${moved.map((m) => m.path).join(", ")}, then stopped: ${cause?.message ?? String(cause)} Change the directory to the same place again to finish.`, { cause });
1288
+ this.moved = moved;
1289
+ this.name = "LandingDirectoryError";
1290
+ }
1291
+ moved;
1292
+ };
1293
+ var taken = (pages, path, except) => pages.some((p) => p.path === path && p.id !== except) ? [`A page is already at ${path}.`] : [];
1294
+ function SlugField({ id, directory, slug, problems, onChange, autoFocus }) {
1295
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
1296
+ /* @__PURE__ */ jsx(Label, { htmlFor: `${id}-slug`, children: "Address" }),
1297
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
1298
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-sm text-muted-foreground", children: `${directory}/` }),
1299
+ /* @__PURE__ */ jsx(Input, { id: `${id}-slug`, value: slug, placeholder: "spring-offer", autoFocus, "aria-invalid": problems.length > 0 || void 0, "aria-describedby": `${id}-slug-hint`, onChange: (e) => onChange(e.currentTarget.value) })
1300
+ ] }),
1301
+ /* @__PURE__ */ jsx("p", { id: `${id}-slug-hint`, className: problems.length ? "text-sm text-destructive" : "text-sm text-muted-foreground", children: problems.length ? problems.join(" ") : "Lowercase letters, digits and hyphens." })
1302
+ ] });
1303
+ }
1304
+ function NewLandingDialog({ open, onOpenChange, pages, directory, reserved, onCreate }) {
1305
+ const [title, setTitle] = React8.useState("");
1306
+ const [slug, setSlug] = React8.useState("");
1307
+ const [slugEdited, setSlugEdited] = React8.useState(false);
1308
+ const [error, setError] = React8.useState(null);
1309
+ const [busy, setBusy] = React8.useState(false);
1310
+ const id = React8.useId();
1311
+ React8.useEffect(() => {
1312
+ if (open) {
1313
+ setTitle("");
1314
+ setSlug("");
1315
+ setSlugEdited(false);
1316
+ setError(null);
1317
+ }
1318
+ }, [open]);
1319
+ const problems = slug ? [...landingSlugProblems(directory, slug, reserved), ...taken(pages, landingPath(directory, slug))] : [];
1320
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsx(DialogContent, { className: "sm:max-w-lg", children: /* @__PURE__ */ jsxs(
1321
+ "form",
1322
+ {
1323
+ className: "flex flex-col gap-4",
1324
+ onSubmit: async (e) => {
1325
+ e.preventDefault();
1326
+ if (!title.trim()) return setError("Give the landing page a title.");
1327
+ if (!slug) return setError("Give the landing page an address.");
1328
+ if (problems.length) return setError(problems.join(" "));
1329
+ setBusy(true);
1330
+ try {
1331
+ await onCreate({ title: title.trim(), slug });
1332
+ onOpenChange(false);
1333
+ } catch (err) {
1334
+ setError(err.message);
1335
+ } finally {
1336
+ setBusy(false);
1337
+ }
1338
+ },
1339
+ children: [
1340
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
1341
+ /* @__PURE__ */ jsx(DialogTitle, { children: "New landing page" }),
1342
+ /* @__PURE__ */ jsx(DialogDescription, { children: "A hero, what you offer, quotes and a call to action, made from your brand. It isn't added to the menu." })
1343
+ ] }),
1344
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
1345
+ /* @__PURE__ */ jsx(Label, { htmlFor: `${id}-title`, children: "Title" }),
1346
+ /* @__PURE__ */ jsx(
1347
+ Input,
1348
+ {
1349
+ id: `${id}-title`,
1350
+ value: title,
1351
+ maxLength: 120,
1352
+ autoFocus: true,
1353
+ onChange: (e) => {
1354
+ const t = e.currentTarget.value;
1355
+ setTitle(t);
1356
+ if (!slugEdited) setSlug(t.trim() ? slugify(t).slice(1) : "");
1357
+ }
1358
+ }
1359
+ )
1360
+ ] }),
1361
+ /* @__PURE__ */ jsx(
1362
+ SlugField,
1363
+ {
1364
+ id,
1365
+ directory,
1366
+ slug,
1367
+ problems,
1368
+ onChange: (s) => {
1369
+ setSlug(s);
1370
+ setSlugEdited(true);
1371
+ }
1372
+ }
1373
+ ),
1374
+ error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: error }) : null,
1375
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
1376
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
1377
+ /* @__PURE__ */ jsx(Button, { type: "submit", loading: busy, children: "Create landing page" })
1378
+ ] })
1379
+ ]
1380
+ }
1381
+ ) }) });
1382
+ }
1383
+ function MoveLandingDialog({ page, pages, directory, reserved, onClose, onMove }) {
1384
+ const [slug, setSlug] = React8.useState("");
1385
+ const [error, setError] = React8.useState(null);
1386
+ const [busy, setBusy] = React8.useState(false);
1387
+ const id = React8.useId();
1388
+ const initial = page ? landingSlugOf(directory, page.path) ?? page.path.split("/").pop() ?? "" : "";
1389
+ React8.useEffect(() => {
1390
+ setSlug(initial);
1391
+ setError(null);
1392
+ }, [initial]);
1393
+ if (!page) return null;
1394
+ const outside = landingSlugOf(directory, page.path) === null;
1395
+ const path = landingPath(directory, slug);
1396
+ const unchanged = path === page.path;
1397
+ const problems = slug && !unchanged ? [...landingSlugProblems(directory, slug, reserved), ...taken(pages, path, page.id)] : [];
1398
+ return /* @__PURE__ */ jsx(Dialog, { open: true, onOpenChange: (o) => o ? null : onClose(), children: /* @__PURE__ */ jsx(DialogContent, { className: "sm:max-w-md", children: /* @__PURE__ */ jsxs(
1399
+ "form",
1400
+ {
1401
+ className: "flex flex-col gap-4",
1402
+ onSubmit: async (e) => {
1403
+ e.preventDefault();
1404
+ if (unchanged) return onClose();
1405
+ if (!slug) return setError("Give the landing page an address.");
1406
+ if (problems.length) return setError(problems.join(" "));
1407
+ setBusy(true);
1408
+ try {
1409
+ await onMove(page.id, slug);
1410
+ onClose();
1411
+ } catch (err) {
1412
+ setError(err.message);
1413
+ } finally {
1414
+ setBusy(false);
1415
+ }
1416
+ },
1417
+ children: [
1418
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
1419
+ /* @__PURE__ */ jsxs(DialogTitle, { children: [
1420
+ "Change the address of \u201C",
1421
+ page.title,
1422
+ "\u201D"
1423
+ ] }),
1424
+ /* @__PURE__ */ jsxs(DialogDescription, { children: [
1425
+ "The old address, ",
1426
+ page.path,
1427
+ ", will redirect here, so links in ads and emails keep working.",
1428
+ outside ? ` This page is outside ${directory}: saving moves it into ${directory}, at ${path}.` : ""
1429
+ ] })
1430
+ ] }),
1431
+ /* @__PURE__ */ jsx(SlugField, { id, directory, slug, problems, onChange: setSlug, autoFocus: true }),
1432
+ error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: error }) : null,
1433
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
1434
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: "Cancel" }),
1435
+ /* @__PURE__ */ jsx(Button, { type: "submit", loading: busy, children: outside ? `Move into ${directory}` : "Change address" })
1436
+ ] })
1437
+ ]
1438
+ }
1439
+ ) }) });
1440
+ }
1441
+ function DirectoryDialog({ open, onOpenChange, pages, directory, reserved, onSave }) {
1442
+ const [value, setValue] = React8.useState(directory);
1443
+ const [movePages, setMovePages] = React8.useState(true);
1444
+ const [error, setError] = React8.useState(null);
1445
+ const [busy, setBusy] = React8.useState(false);
1446
+ const id = React8.useId();
1447
+ React8.useEffect(() => {
1448
+ if (open) {
1449
+ setValue(directory);
1450
+ setMovePages(true);
1451
+ setError(null);
1452
+ }
1453
+ }, [open, directory]);
1454
+ const problems = value && value !== directory ? landingDirectoryProblems(value, reserved) : [];
1455
+ const count = landingPages(pages).filter((p) => landingSlugOf(directory, p.path) !== null).length;
1456
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsx(DialogContent, { className: "sm:max-w-md", children: /* @__PURE__ */ jsxs(
1457
+ "form",
1458
+ {
1459
+ className: "flex flex-col gap-4",
1460
+ onSubmit: async (e) => {
1461
+ e.preventDefault();
1462
+ if (value === directory) return onOpenChange(false);
1463
+ if (problems.length) return setError(problems.join(" "));
1464
+ setBusy(true);
1465
+ try {
1466
+ await onSave(value, count > 0 && movePages);
1467
+ onOpenChange(false);
1468
+ } catch (err) {
1469
+ setError(err.message);
1470
+ } finally {
1471
+ setBusy(false);
1472
+ }
1473
+ },
1474
+ children: [
1475
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
1476
+ /* @__PURE__ */ jsx(DialogTitle, { children: "Landing page directory" }),
1477
+ /* @__PURE__ */ jsxs(DialogDescription, { children: [
1478
+ "Where new landing pages go: ",
1479
+ landingPath(value || directory, "spring-offer"),
1480
+ ", for example."
1481
+ ] })
1482
+ ] }),
1483
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
1484
+ /* @__PURE__ */ jsx(Label, { htmlFor: `${id}-dir`, children: "Directory" }),
1485
+ /* @__PURE__ */ jsx(Input, { id: `${id}-dir`, value, placeholder: "/go", autoFocus: true, "aria-invalid": problems.length > 0 || void 0, "aria-describedby": `${id}-dir-hint`, onChange: (e) => setValue(e.currentTarget.value) }),
1486
+ /* @__PURE__ */ jsx("p", { id: `${id}-dir-hint`, className: problems.length ? "text-sm text-destructive" : "text-sm text-muted-foreground", children: problems.length ? problems.join(" ") : 'Starts with "/": lowercase letters, digits and hyphens.' })
1487
+ ] }),
1488
+ count > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
1489
+ /* @__PURE__ */ jsx(Switch, { id: `${id}-move`, checked: movePages, onCheckedChange: setMovePages, "aria-describedby": `${id}-move-d` }),
1490
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
1491
+ /* @__PURE__ */ jsxs(Label, { htmlFor: `${id}-move`, children: [
1492
+ "Move the ",
1493
+ count === 1 ? "landing page" : `${count} landing pages`,
1494
+ " in ",
1495
+ directory,
1496
+ " too"
1497
+ ] }),
1498
+ /* @__PURE__ */ jsx("span", { id: `${id}-move-d`, className: "text-sm text-muted-foreground", children: movePages ? "Their old addresses redirect to the new ones." : "They keep their addresses; only new landing pages use the new directory." })
1499
+ ] })
1500
+ ] }) : null,
1501
+ error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: error }) : null,
1502
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
1503
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
1504
+ /* @__PURE__ */ jsx(Button, { type: "submit", loading: busy, children: "Save" })
1505
+ ] })
1506
+ ]
1507
+ }
1508
+ ) }) });
1509
+ }
1510
+ function LandingPanel(props) {
1511
+ const [adding, setAdding] = React8.useState(false);
1512
+ const [moving, setMoving] = React8.useState(null);
1513
+ const [deleting, setDeleting] = React8.useState(null);
1514
+ const [editingDir, setEditingDir] = React8.useState(false);
1515
+ const list = landingPages(props.pages);
1516
+ const headingId = React8.useId();
1517
+ return /* @__PURE__ */ jsxs("section", { "aria-labelledby": headingId, className: "flex flex-col gap-2", "data-gs-landing": "", children: [
1518
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
1519
+ /* @__PURE__ */ jsx("h2", { id: headingId, className: "text-sm font-semibold", children: "Landing pages" }),
1520
+ props.readOnly ? null : /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", onClick: () => setAdding(true), disabled: props.busy, children: [
1521
+ /* @__PURE__ */ jsx(Plus, { className: "mr-1 h-4 w-4" }),
1522
+ " New landing page"
1523
+ ] })
1524
+ ] }),
1525
+ /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
1526
+ "Campaign pages, kept out of the menu, at ",
1527
+ props.directory,
1528
+ "/\u2026.",
1529
+ props.readOnly ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
1530
+ " ",
1531
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "link", size: "sm", className: "h-auto p-0", disabled: props.busy, onClick: () => setEditingDir(true), children: "Change the directory" })
1532
+ ] })
1533
+ ] }),
1534
+ list.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No landing pages yet." }) : null,
1535
+ /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1", "aria-label": "Landing pages", children: list.map((p) => {
1536
+ const current = p.id === props.currentId;
1537
+ const live = props.liveIds?.has(p.id);
1538
+ return /* @__PURE__ */ jsxs("li", { className: cn("flex flex-col gap-1 rounded-md border p-2", current ? "border-primary bg-muted" : "border-transparent hover:border-border"), children: [
1539
+ /* @__PURE__ */ jsxs("button", { type: "button", className: "flex items-center gap-2 text-left text-sm focus-visible:outline-2 focus-visible:outline-ring", "aria-current": current ? "page" : void 0, onClick: () => props.onOpen(p.id), disabled: props.busy, children: [
1540
+ /* @__PURE__ */ jsx(Megaphone, { "aria-hidden": true, className: "h-4 w-4 shrink-0" }),
1541
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
1542
+ /* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: p.title }),
1543
+ /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: p.path })
1544
+ ] }),
1545
+ props.liveIds ? /* @__PURE__ */ jsx(Badge, { variant: live ? "default" : "secondary", children: live ? "Published" : "Draft" }) : null
1546
+ ] }),
1547
+ props.readOnly ? null : /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
1548
+ /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", disabled: props.busy, onClick: () => setMoving(p), "aria-label": `Address of ${p.title}`, children: "Address" }),
1549
+ /* @__PURE__ */ jsx(Button, { type: "button", size: "icon", variant: "ghost", disabled: props.busy, "aria-label": `Delete ${p.title}`, onClick: () => setDeleting(p), children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }) })
1550
+ ] })
1551
+ ] }, p.id);
1552
+ }) }),
1553
+ /* @__PURE__ */ jsx(NewLandingDialog, { open: adding, onOpenChange: setAdding, pages: props.pages, directory: props.directory, reserved: props.reserved, onCreate: props.onCreate }),
1554
+ /* @__PURE__ */ jsx(MoveLandingDialog, { page: moving, pages: props.pages, directory: props.directory, reserved: props.reserved, onClose: () => setMoving(null), onMove: props.onMove }),
1555
+ /* @__PURE__ */ jsx(DirectoryDialog, { open: editingDir, onOpenChange: setEditingDir, pages: props.pages, directory: props.directory, reserved: props.reserved, onSave: props.onSetDirectory }),
1556
+ /* @__PURE__ */ jsx(AlertDialog, { open: deleting !== null, onOpenChange: (o) => o ? null : setDeleting(null), children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
1557
+ /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
1558
+ /* @__PURE__ */ jsxs(AlertDialogTitle, { children: [
1559
+ "Delete \u201C",
1560
+ deleting?.title,
1561
+ "\u201D?"
1562
+ ] }),
1563
+ /* @__PURE__ */ jsx(AlertDialogDescription, { children: "The landing page leaves the site at its next publish. Releases already published keep it, so a rollback brings it back." })
1564
+ ] }),
1565
+ /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
1566
+ /* @__PURE__ */ jsx(AlertDialogCancel, { children: "Keep it" }),
1567
+ /* @__PURE__ */ jsx(
1568
+ AlertDialogAction,
1569
+ {
1570
+ onClick: () => {
1571
+ if (deleting) void props.onDelete(deleting.id);
1572
+ setDeleting(null);
1573
+ },
1574
+ children: "Delete landing page"
1575
+ }
1576
+ )
1577
+ ] })
1578
+ ] }) })
1579
+ ] });
1580
+ }
1222
1581
  function AddPageDialog({ open, onOpenChange, pages, reserved, onCreate }) {
1223
- const templates = React7.useMemo(() => pageTemplates(), []);
1224
- const [title, setTitle] = React7.useState("");
1225
- const [path, setPath] = React7.useState("");
1226
- const [pathEdited, setPathEdited] = React7.useState(false);
1227
- const [templateId, setTemplateId] = React7.useState("blank");
1228
- const [addToMenu, setAddToMenu] = React7.useState(true);
1229
- const [error, setError] = React7.useState(null);
1230
- const [busy, setBusy] = React7.useState(false);
1231
- const id = React7.useId();
1232
- React7.useEffect(() => {
1582
+ const templates = React8.useMemo(() => pageTemplates().filter((t) => t.kind !== "landing"), []);
1583
+ const [title, setTitle] = React8.useState("");
1584
+ const [path, setPath] = React8.useState("");
1585
+ const [pathEdited, setPathEdited] = React8.useState(false);
1586
+ const [templateId, setTemplateId] = React8.useState("blank");
1587
+ const [addToMenu, setAddToMenu] = React8.useState(true);
1588
+ const [error, setError] = React8.useState(null);
1589
+ const [busy, setBusy] = React8.useState(false);
1590
+ const id = React8.useId();
1591
+ React8.useEffect(() => {
1233
1592
  if (open) {
1234
1593
  setTitle("");
1235
1594
  setPath("");
@@ -1257,7 +1616,7 @@ function AddPageDialog({ open, onOpenChange, pages, reserved, onCreate }) {
1257
1616
  return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsx(DialogContent, { className: "sm:max-w-lg", children: /* @__PURE__ */ jsxs("form", { onSubmit: submit, className: "flex flex-col gap-4", children: [
1258
1617
  /* @__PURE__ */ jsxs(DialogHeader, { children: [
1259
1618
  /* @__PURE__ */ jsx(DialogTitle, { children: "Add a page" }),
1260
- /* @__PURE__ */ jsx(DialogDescription, { children: "Start blank, from a template, or with a landing page made from your brand." })
1619
+ /* @__PURE__ */ jsx(DialogDescription, { children: "Start blank or from a template. For a campaign page, use New landing page under Landing pages." })
1261
1620
  ] }),
1262
1621
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
1263
1622
  /* @__PURE__ */ jsx(Label, { htmlFor: `${id}-title`, children: "Title" }),
@@ -1316,11 +1675,11 @@ function AddPageDialog({ open, onOpenChange, pages, reserved, onCreate }) {
1316
1675
  ] }) }) });
1317
1676
  }
1318
1677
  function RenameDialog({ page, pages, reserved, onClose, onRename }) {
1319
- const [path, setPath] = React7.useState("");
1320
- const [error, setError] = React7.useState(null);
1321
- const [busy, setBusy] = React7.useState(false);
1322
- const id = React7.useId();
1323
- React7.useEffect(() => {
1678
+ const [path, setPath] = React8.useState("");
1679
+ const [error, setError] = React8.useState(null);
1680
+ const [busy, setBusy] = React8.useState(false);
1681
+ const id = React8.useId();
1682
+ React8.useEffect(() => {
1324
1683
  setPath(page?.path ?? "");
1325
1684
  setError(null);
1326
1685
  }, [page]);
@@ -1380,8 +1739,8 @@ function menuItemProblems(item) {
1380
1739
  }
1381
1740
  function MenuEditor({ nav, pages, busy, onChange }) {
1382
1741
  const items = nav;
1383
- const id = React7.useId();
1384
- const list = React7.useRef(null);
1742
+ const id = React8.useId();
1743
+ const list = React8.useRef(null);
1385
1744
  const commit = (next) => onChange(next);
1386
1745
  const move = (i, by) => {
1387
1746
  const next = [...items];
@@ -1394,7 +1753,7 @@ function MenuEditor({ nav, pages, busy, onChange }) {
1394
1753
  (same && !same.disabled ? same : list.current?.querySelector(`[data-menu-move="${j}:${-by}"]`))?.focus();
1395
1754
  });
1396
1755
  };
1397
- const unlinked = pages.filter((p) => !items.some((i) => i.href === p.path));
1756
+ const unlinked = pages.filter((p) => !isLandingPage(p) && !items.some((i) => i.href === p.path));
1398
1757
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
1399
1758
  items.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "The menu is empty." }) : null,
1400
1759
  /* @__PURE__ */ jsx("ol", { ref: list, className: "flex flex-col gap-3", children: items.map((item, i) => {
@@ -1433,9 +1792,10 @@ function MenuEditor({ nav, pages, busy, onChange }) {
1433
1792
  ] });
1434
1793
  }
1435
1794
  function PagesPanel(props) {
1436
- const [adding, setAdding] = React7.useState(false);
1437
- const [renaming, setRenaming] = React7.useState(null);
1438
- const [deleting, setDeleting] = React7.useState(null);
1795
+ const [adding, setAdding] = React8.useState(false);
1796
+ const [renaming, setRenaming] = React8.useState(null);
1797
+ const [deleting, setDeleting] = React8.useState(null);
1798
+ const ordinary = props.pages.filter((p) => !isLandingPage(p));
1439
1799
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 p-3", children: [
1440
1800
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
1441
1801
  /* @__PURE__ */ jsx("h2", { className: "text-sm font-semibold", children: "Pages" }),
@@ -1444,29 +1804,30 @@ function PagesPanel(props) {
1444
1804
  " Add page"
1445
1805
  ] })
1446
1806
  ] }),
1447
- /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1", "aria-label": "Pages", children: props.pages.map((p, i) => {
1807
+ /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1", "aria-label": "Pages", children: ordinary.map((p, i) => {
1448
1808
  const current = p.id === props.currentId;
1449
1809
  return /* @__PURE__ */ jsxs("li", { className: cn("group flex flex-col gap-1 rounded-md border p-2", current ? "border-primary bg-muted" : "border-transparent hover:border-border"), children: [
1450
1810
  /* @__PURE__ */ jsxs("button", { type: "button", className: "flex items-center gap-2 text-left text-sm focus-visible:outline-2 focus-visible:outline-ring", "aria-current": current ? "page" : void 0, onClick: () => props.onOpen(p.id), disabled: props.busy, children: [
1451
1811
  p.path === "/" ? /* @__PURE__ */ jsx(Home, { "aria-hidden": true, className: "h-4 w-4 shrink-0" }) : /* @__PURE__ */ jsx(FileText, { "aria-hidden": true, className: "h-4 w-4 shrink-0" }),
1452
1812
  /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
1453
1813
  /* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: p.title }),
1454
- /* @__PURE__ */ jsxs("span", { className: "truncate text-xs text-muted-foreground", children: [
1455
- p.path,
1456
- p.kind === "landing" ? " \xB7 landing" : ""
1457
- ] })
1814
+ /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: p.path })
1458
1815
  ] })
1459
1816
  ] }),
1460
1817
  props.readOnly ? null : /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
1461
1818
  p.path !== "/" ? /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", disabled: props.busy, onClick: () => setRenaming(p), "aria-label": `Change the address of ${p.title}`, children: "Address" }) : null,
1462
1819
  props.canReorder ? /* @__PURE__ */ jsxs(Fragment, { children: [
1463
1820
  /* @__PURE__ */ jsx(Button, { type: "button", size: "icon", variant: "ghost", disabled: props.busy || i === 0, "aria-label": `Move ${p.title} up`, onClick: () => props.onReorder(p.id, -1), children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-4 w-4" }) }),
1464
- /* @__PURE__ */ jsx(Button, { type: "button", size: "icon", variant: "ghost", disabled: props.busy || i === props.pages.length - 1, "aria-label": `Move ${p.title} down`, onClick: () => props.onReorder(p.id, 1), children: /* @__PURE__ */ jsx(ArrowDown, { className: "h-4 w-4" }) })
1821
+ /* @__PURE__ */ jsx(Button, { type: "button", size: "icon", variant: "ghost", disabled: props.busy || i === ordinary.length - 1, "aria-label": `Move ${p.title} down`, onClick: () => props.onReorder(p.id, 1), children: /* @__PURE__ */ jsx(ArrowDown, { className: "h-4 w-4" }) })
1465
1822
  ] }) : null,
1466
1823
  p.path !== "/" ? /* @__PURE__ */ jsx(Button, { type: "button", size: "icon", variant: "ghost", disabled: props.busy, "aria-label": `Delete ${p.title}`, onClick: () => setDeleting(p), children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }) }) : null
1467
1824
  ] })
1468
1825
  ] }, p.id);
1469
1826
  }) }),
1827
+ props.landing ? /* @__PURE__ */ jsxs(Fragment, { children: [
1828
+ /* @__PURE__ */ jsx(Separator, {}),
1829
+ props.landing
1830
+ ] }) : null,
1470
1831
  /* @__PURE__ */ jsx(Separator, {}),
1471
1832
  /* @__PURE__ */ jsxs("section", { "aria-labelledby": "gs-menu-heading", className: "flex flex-col gap-2", children: [
1472
1833
  /* @__PURE__ */ jsx("h2", { id: "gs-menu-heading", className: "text-sm font-semibold", children: "Menu" }),
@@ -1517,12 +1878,12 @@ function PagesPanel(props) {
1517
1878
 
1518
1879
  // src/editor/preview.ts
1519
1880
  async function loadSiteCss() {
1520
- const { ASSETS } = await import('./assets.generated-4XWKKLCZ.js');
1881
+ const { ASSETS } = await import('./assets.generated-QJK3COCH.js');
1521
1882
  return ASSETS.css.body;
1522
1883
  }
1523
1884
  var styleText = (css) => css.replace(/<\/style/gi, "<\\/style");
1524
1885
  async function renderPreview(input) {
1525
- const [{ renderSitePageToString }, { ASSETS }] = await Promise.all([import('./handler-LD32KEDP.js'), import('./assets.generated-4XWKKLCZ.js')]);
1886
+ const [{ renderSitePageToString }, { ASSETS }] = await Promise.all([import('./handler-VQ4QKTUU.js'), import('./assets.generated-QJK3COCH.js')]);
1526
1887
  const result = await renderSitePageToString(new Request(`https://preview.invalid${input.path}`), {
1527
1888
  store: input.store,
1528
1889
  brand: { getBrand: () => input.brand },
@@ -1545,7 +1906,7 @@ function SeoFields({ siteName, pagePath, pageTitle, readOnly }) {
1545
1906
  const root = usePuck2((s) => s.appState.data.root);
1546
1907
  const dispatch = usePuck2((s) => s.dispatch);
1547
1908
  const services = useEditorServices();
1548
- const id = React7.useId();
1909
+ const id = React8.useId();
1549
1910
  const set = (patch) => {
1550
1911
  const next = { ...seo ?? {}, ...patch };
1551
1912
  for (const k of Object.keys(next)) if (next[k] === void 0 || next[k] === "" || next[k] === false) delete next[k];
@@ -1627,9 +1988,9 @@ function IssueList({ issues, currentPageId, onOpenPage, onShown }) {
1627
1988
  ] }, i)) });
1628
1989
  }
1629
1990
  function PublishPanel(props) {
1630
- const [note, setNote] = React7.useState("");
1631
- const [rollingBack, setRollingBack] = React7.useState(null);
1632
- const id = React7.useId();
1991
+ const [note, setNote] = React8.useState("");
1992
+ const [rollingBack, setRollingBack] = React8.useState(null);
1993
+ const id = React8.useId();
1633
1994
  const errors = props.issues?.filter((i) => i.severity === "error") ?? [];
1634
1995
  const warnings = props.issues?.filter((i) => i.severity === "warning") ?? [];
1635
1996
  const live = props.releases.find((r) => r.id === props.liveReleaseId);
@@ -1767,9 +2128,9 @@ function worst(...states) {
1767
2128
  return "saved";
1768
2129
  }
1769
2130
  function useCanvasFrame(css, href, theme, dark, lang) {
1770
- return React7.useCallback(
2131
+ return React8.useCallback(
1771
2132
  ({ children, document: document2 }) => {
1772
- React7.useEffect(() => {
2133
+ React8.useEffect(() => {
1773
2134
  if (!document2) return;
1774
2135
  const nodes = [];
1775
2136
  if (href) {
@@ -1848,7 +2209,7 @@ function useSelectFooter() {
1848
2209
  }
1849
2210
  function SelectionWatcher({ onSelect }) {
1850
2211
  const selected = usePuck3((s) => s.selectedItem?.props.id);
1851
- React7.useEffect(() => {
2212
+ React8.useEffect(() => {
1852
2213
  if (selected) onSelect();
1853
2214
  }, [selected]);
1854
2215
  return null;
@@ -1867,44 +2228,45 @@ function PagesTab(props) {
1867
2228
  );
1868
2229
  }
1869
2230
  function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved, previewUrl, autosaveDelay, initialPageId, siteStylesheet, readOnly = false, onDirtyChange, className }) {
1870
- const [loadError, setLoadError] = React7.useState(null);
1871
- const [site, setSite] = React7.useState(null);
1872
- const [pages, setPages] = React7.useState([]);
1873
- const [open, setOpen] = React7.useState(null);
1874
- const [editorKey, setEditorKey] = React7.useState(0);
1875
- const [siteState, setSiteState] = React7.useState(null);
1876
- const [pageState, setPageState] = React7.useState(null);
1877
- const [invalid, setInvalid] = React7.useState(null);
1878
- const [busy, setBusy] = React7.useState(false);
1879
- const [notice, setNotice] = React7.useState(null);
1880
- const [css, setCss] = React7.useState(null);
1881
- const [h1Id, setH1Id] = React7.useState(null);
1882
- const [formMap, setFormMap] = React7.useState(/* @__PURE__ */ new Map());
1883
- const [issues, setIssues] = React7.useState(null);
1884
- const [checking, setChecking] = React7.useState(false);
1885
- const [publishing, setPublishing] = React7.useState(false);
1886
- const [releases, setReleases] = React7.useState([]);
1887
- const [liveId, setLiveId] = React7.useState(null);
1888
- const [leftTab, setLeftTab] = React7.useState(readOnly ? "outline" : "add");
1889
- const [rightTab, setRightTab] = React7.useState("edit");
1890
- const [viewport, setViewport] = React7.useState("desktop");
1891
- const [picker, setPicker] = React7.useState(null);
1892
- const [preview, setPreview] = React7.useState(null);
1893
- const siteSaver = React7.useRef(null);
1894
- const pageSaver = React7.useRef(null);
1895
- const pageSaverFor = React7.useRef(null);
1896
- const counts = React7.useRef(/* @__PURE__ */ new Map());
1897
- const focusTitle = React7.useRef(false);
1898
- const titleId = React7.useId();
1899
- const [announcement, setAnnouncement] = React7.useState("");
1900
- const [menuDraft, setMenuDraft] = React7.useState(null);
2231
+ const [loadError, setLoadError] = React8.useState(null);
2232
+ const [site, setSite] = React8.useState(null);
2233
+ const [pages, setPages] = React8.useState([]);
2234
+ const [open, setOpen] = React8.useState(null);
2235
+ const [editorKey, setEditorKey] = React8.useState(0);
2236
+ const [siteState, setSiteState] = React8.useState(null);
2237
+ const [pageState, setPageState] = React8.useState(null);
2238
+ const [invalid, setInvalid] = React8.useState(null);
2239
+ const [busy, setBusy] = React8.useState(false);
2240
+ const [notice, setNotice] = React8.useState(null);
2241
+ const [css, setCss] = React8.useState(null);
2242
+ const [h1Id, setH1Id] = React8.useState(null);
2243
+ const [formMap, setFormMap] = React8.useState(/* @__PURE__ */ new Map());
2244
+ const [issues, setIssues] = React8.useState(null);
2245
+ const [checking, setChecking] = React8.useState(false);
2246
+ const [publishing, setPublishing] = React8.useState(false);
2247
+ const [releases, setReleases] = React8.useState([]);
2248
+ const [liveId, setLiveId] = React8.useState(null);
2249
+ const [liveIds, setLiveIds] = React8.useState(null);
2250
+ const [leftTab, setLeftTab] = React8.useState(readOnly ? "outline" : "add");
2251
+ const [rightTab, setRightTab] = React8.useState("edit");
2252
+ const [viewport, setViewport] = React8.useState("desktop");
2253
+ const [picker, setPicker] = React8.useState(null);
2254
+ const [preview, setPreview] = React8.useState(null);
2255
+ const siteSaver = React8.useRef(null);
2256
+ const pageSaver = React8.useRef(null);
2257
+ const pageSaverFor = React8.useRef(null);
2258
+ const counts = React8.useRef(/* @__PURE__ */ new Map());
2259
+ const focusTitle = React8.useRef(false);
2260
+ const titleId = React8.useId();
2261
+ const [announcement, setAnnouncement] = React8.useState("");
2262
+ const [menuDraft, setMenuDraft] = React8.useState(null);
1901
2263
  const locked = readOnly || publishing;
1902
- const lockedRef = React7.useRef(locked);
2264
+ const lockedRef = React8.useRef(locked);
1903
2265
  lockedRef.current = locked;
1904
2266
  const kind = open?.kind ?? "page";
1905
- const editor = React7.useMemo(() => createEditorConfig({ kind, counts: () => counts.current, readOnly: () => lockedRef.current }), [kind]);
1906
- const slotKeys = React7.useMemo(() => createEditorConfig().slotKeys, []);
1907
- const theme = React7.useMemo(() => {
2267
+ const editor = React8.useMemo(() => createEditorConfig({ kind, counts: () => counts.current, readOnly: () => lockedRef.current }), [kind]);
2268
+ const slotKeys = React8.useMemo(() => createEditorConfig().slotKeys, []);
2269
+ const theme = React8.useMemo(() => {
1908
2270
  try {
1909
2271
  return siteTheme(brand, site?.theme ?? {});
1910
2272
  } catch (err) {
@@ -1913,7 +2275,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
1913
2275
  }
1914
2276
  }, [brand, site?.theme]);
1915
2277
  const iframe = useCanvasFrame(css, siteStylesheet, themeCss(theme), theme.colorScheme === "dark", site?.lang ?? "en");
1916
- const loadPage = React7.useCallback(
2278
+ const loadPage = React8.useCallback(
1917
2279
  async (pageId, siteDoc) => {
1918
2280
  const draft = await store.getPageDraft(pageId);
1919
2281
  if (!draft) throw new Error("That page no longer exists, or you can't edit it.");
@@ -1942,12 +2304,13 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
1942
2304
  },
1943
2305
  [store, autosaveDelay, slotKeys, readOnly]
1944
2306
  );
1945
- const refreshPublishing = React7.useCallback(async () => {
2307
+ const refreshPublishing = React8.useCallback(async () => {
1946
2308
  const [list, live] = await Promise.all([store.listReleases(siteId), store.getLive(siteId)]);
1947
2309
  setReleases(list);
1948
2310
  setLiveId(live?.id ?? null);
2311
+ setLiveIds(new Set(live?.snapshot.pages.map((p) => p.id) ?? []));
1949
2312
  }, [store, siteId]);
1950
- React7.useEffect(() => {
2313
+ React8.useEffect(() => {
1951
2314
  let cancelled = false;
1952
2315
  (async () => {
1953
2316
  try {
@@ -1978,7 +2341,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
1978
2341
  };
1979
2342
  }, [siteId, store, readOnly]);
1980
2343
  const menuInvalid = menuDraft !== null && !menuDraft.every((i) => menuItemProblems(i).length === 0);
1981
- React7.useEffect(() => {
2344
+ React8.useEffect(() => {
1982
2345
  const guard = (e) => {
1983
2346
  if (siteSaver.current?.dirty || pageSaver.current?.dirty || invalid || menuInvalid) {
1984
2347
  e.preventDefault();
@@ -1989,20 +2352,20 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
1989
2352
  return () => window.removeEventListener("beforeunload", guard);
1990
2353
  }, [invalid, menuInvalid]);
1991
2354
  const dirty = !readOnly && (worst(siteState, pageState) !== "saved" || Boolean(invalid) || menuInvalid);
1992
- const dirtyReported = React7.useRef(false);
1993
- const onDirtyChangeRef = React7.useRef(onDirtyChange);
2355
+ const dirtyReported = React8.useRef(false);
2356
+ const onDirtyChangeRef = React8.useRef(onDirtyChange);
1994
2357
  onDirtyChangeRef.current = onDirtyChange;
1995
- React7.useEffect(() => {
2358
+ React8.useEffect(() => {
1996
2359
  if (dirty === dirtyReported.current) return;
1997
2360
  dirtyReported.current = dirty;
1998
2361
  onDirtyChangeRef.current?.(dirty);
1999
2362
  }, [dirty]);
2000
- const formSlugs = React7.useMemo(() => {
2363
+ const formSlugs = React8.useMemo(() => {
2001
2364
  const slugs = /* @__PURE__ */ new Set();
2002
2365
  for (const item of open?.data.content ?? []) if (item.type.startsWith("form-embed") && typeof item.props.form === "string") slugs.add(item.props.form);
2003
2366
  return [...slugs].sort().join(",");
2004
2367
  }, [open]);
2005
- React7.useEffect(() => {
2368
+ React8.useEffect(() => {
2006
2369
  if (!forms || !formSlugs) return;
2007
2370
  let cancelled = false;
2008
2371
  Promise.all(formSlugs.split(",").map(async (slug) => [slug, await Promise.resolve(forms(slug, { siteId, pagePath: open?.path ?? "/", mode: "preview" })).catch(() => null)])).then((entries) => {
@@ -2012,7 +2375,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2012
2375
  cancelled = true;
2013
2376
  };
2014
2377
  }, [forms, formSlugs, siteId, open?.path]);
2015
- const onChange = React7.useCallback(
2378
+ const onChange = React8.useCallback(
2016
2379
  (data) => {
2017
2380
  if (!open || !site || readOnly || pageSaverFor.current !== open.id) return;
2018
2381
  const editorData = data;
@@ -2039,7 +2402,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2039
2402
  },
2040
2403
  [open, site, slotKeys, readOnly]
2041
2404
  );
2042
- const onNavChange = React7.useCallback(
2405
+ const onNavChange = React8.useCallback(
2043
2406
  (nav) => {
2044
2407
  const current = siteSaver.current?.latest ?? site;
2045
2408
  if (!current || readOnly) return;
@@ -2050,14 +2413,14 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2050
2413
  },
2051
2414
  [site, readOnly]
2052
2415
  );
2053
- const onMenuEdit = React7.useCallback(
2416
+ const onMenuEdit = React8.useCallback(
2054
2417
  (items) => {
2055
2418
  setMenuDraft(items);
2056
2419
  if (items.every((i) => menuItemProblems(i).length === 0)) onNavChange(items.map((i) => ({ label: i.label.trim(), href: i.href.trim() })));
2057
2420
  },
2058
2421
  [onNavChange]
2059
2422
  );
2060
- const flushAll = React7.useCallback(async () => {
2423
+ const flushAll = React8.useCallback(async () => {
2061
2424
  if (invalid) {
2062
2425
  setNotice({ tone: "error", text: `Fix this first: ${invalid}` });
2063
2426
  return false;
@@ -2074,7 +2437,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2074
2437
  return false;
2075
2438
  }
2076
2439
  }, [invalid, menuInvalid]);
2077
- const resync = React7.useCallback(async (options2 = {}) => {
2440
+ const resync = React8.useCallback(async (options2 = {}) => {
2078
2441
  const [draft, list] = await Promise.all([store.getDraft(siteId), store.listPages(siteId)]);
2079
2442
  setPages(list);
2080
2443
  let redraw = false;
@@ -2108,7 +2471,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2108
2471
  }
2109
2472
  return { draft, list };
2110
2473
  }, [store, siteId, open, site, slotKeys]);
2111
- const runCheck = React7.useCallback(async () => {
2474
+ const runCheck = React8.useCallback(async () => {
2112
2475
  if (!await flushAll()) return;
2113
2476
  setChecking(true);
2114
2477
  try {
@@ -2121,7 +2484,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2121
2484
  }
2122
2485
  }, [flushAll, store, siteId, brand, reserved]);
2123
2486
  const settled = worst(siteState, pageState) === "saved" && !invalid;
2124
- React7.useEffect(() => {
2487
+ React8.useEffect(() => {
2125
2488
  if (rightTab !== "publish" || !settled) return;
2126
2489
  const t = setTimeout(() => void runCheck(), 600);
2127
2490
  return () => clearTimeout(t);
@@ -2194,9 +2557,45 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2194
2557
  setBusy(false);
2195
2558
  }
2196
2559
  };
2560
+ const createLanding = (request) => holding(async () => {
2561
+ if (!await flushAll()) throw new Error("Save your changes first.");
2562
+ const meta = await createLandingPage(store, siteId, { ...request, brand, ...reserved ? { reserved } : {} });
2563
+ const { draft } = await resync();
2564
+ focusTitle.current = true;
2565
+ await loadPage(meta.id, siteSaver.current?.latest ?? draft?.site ?? site);
2566
+ setNotice({ tone: "info", text: `Added the landing page ${request.title} at ${meta.path}.` });
2567
+ });
2568
+ const moveLanding = (pageId, slug) => holding(async () => {
2569
+ if (!await flushAll()) throw new Error("Save your changes first.");
2570
+ const before = pages.find((p) => p.id === pageId)?.path;
2571
+ const moved = await moveLandingPage(store, pageId, slug, reserved ? { reserved } : {});
2572
+ const { draft } = await resync();
2573
+ if (draft && before && draft.site.nav.some((n) => n.href === before)) onNavChange(draft.site.nav.map((n) => n.href === before ? { ...n, href: moved.path } : n));
2574
+ setNotice({ tone: "info", text: `Moved to ${moved.path}. ${before} now redirects there.` });
2575
+ });
2576
+ const changeLandingDirectory = (directory, movePages) => holding(async () => {
2577
+ if (!await flushAll()) throw new Error("Save your changes first.");
2578
+ const before = new Map(pages.map((p) => [p.id, p.path]));
2579
+ let result;
2580
+ const followMoves = (moved) => {
2581
+ const draft = siteSaver.current?.latest ?? null;
2582
+ const to = new Map(moved.map((m) => [before.get(m.id), m.path]));
2583
+ if (draft && draft.nav.some((n) => to.has(n.href))) onNavChange(draft.nav.map((n) => to.has(n.href) ? { ...n, href: to.get(n.href) } : n));
2584
+ };
2585
+ try {
2586
+ result = await setLandingDirectory(store, siteId, directory, { movePages, ...reserved ? { reserved } : {} });
2587
+ } catch (err) {
2588
+ await resync().catch(() => void 0);
2589
+ if (err instanceof LandingDirectoryError) followMoves(err.moved);
2590
+ throw err;
2591
+ }
2592
+ await resync().catch((err) => setNotice({ tone: "error", text: `Couldn't reload the pages; reload the editor before editing: ${err.message}` }));
2593
+ followMoves(result.moved);
2594
+ setNotice({ tone: "info", text: `New landing pages go in ${directory}.${result.moved.length ? ` Moved ${result.moved.length} landing page${result.moved.length === 1 ? "" : "s"}; their old addresses redirect.` : ""}` });
2595
+ });
2197
2596
  const reorder = async (pageId, by) => {
2198
2597
  try {
2199
- setPages(await movePageInList(store, siteId, pageId, by));
2598
+ setPages(await movePageInList(store, siteId, pageId, by, { within: (p) => !isLandingPage(p) }));
2200
2599
  } catch (err) {
2201
2600
  setNotice({ tone: "error", text: err.message });
2202
2601
  }
@@ -2303,13 +2702,13 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2303
2702
  function focusPageTitle() {
2304
2703
  requestAnimationFrame(() => document.getElementById(titleId)?.focus());
2305
2704
  }
2306
- React7.useEffect(() => setViewport("desktop"), [editorKey]);
2307
- React7.useEffect(() => {
2705
+ React8.useEffect(() => setViewport("desktop"), [editorKey]);
2706
+ React8.useEffect(() => {
2308
2707
  if (!focusTitle.current) return;
2309
2708
  focusTitle.current = false;
2310
2709
  focusPageTitle();
2311
2710
  }, [editorKey]);
2312
- const announce = React7.useCallback((message) => {
2711
+ const announce = React8.useCallback((message) => {
2313
2712
  setAnnouncement("");
2314
2713
  requestAnimationFrame(() => setAnnouncement(message));
2315
2714
  }, []);
@@ -2319,7 +2718,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2319
2718
  const textEntry = target.closest("textarea, [contenteditable=''], [contenteditable='true']") || target instanceof HTMLInputElement && !["button", "checkbox", "radio", "submit", "reset", "file", "range", "color"].includes(target.type);
2320
2719
  if (!textEntry) e.preventDefault();
2321
2720
  };
2322
- const services = React7.useMemo(
2721
+ const services = React8.useMemo(
2323
2722
  () => ({
2324
2723
  siteId,
2325
2724
  store,
@@ -2328,7 +2727,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2328
2727
  }),
2329
2728
  [siteId, store, assets]
2330
2729
  );
2331
- const metadata = React7.useMemo(
2730
+ const metadata = React8.useMemo(
2332
2731
  () => ({
2333
2732
  site: { name: site?.name ?? "", lang: site?.lang ?? "en", nav: site?.nav ?? [], ...brand && "logo" in brand && brand.logo ? { logo: { src: brand.logo.src, alt: brand.logo.alt?.trim() || brandDisplayName(brand) } } : {} },
2334
2733
  pagePath: open?.path ?? "/",
@@ -2338,7 +2737,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2338
2737
  }),
2339
2738
  [site?.name, site?.lang, site?.nav, brand, open?.path, open?.placeholders, formMap, h1Id]
2340
2739
  );
2341
- const overrides = React7.useMemo(() => genesisOverrides(editor.components, { iframe }, { announce }), [editor.components, iframe, announce]);
2740
+ const overrides = React8.useMemo(() => genesisOverrides(editor.components, { iframe }, { announce }), [editor.components, iframe, announce]);
2342
2741
  const permissions = locked ? LOCKED : UNLOCKED;
2343
2742
  if (loadError) {
2344
2743
  return /* @__PURE__ */ jsxs(Alert, { variant: "destructive", className, children: [
@@ -2416,7 +2815,24 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2416
2815
  onDelete: remove,
2417
2816
  onReorder: reorder,
2418
2817
  onNavChange: onMenuEdit,
2419
- onFooter: () => setRightTab("edit")
2818
+ onFooter: () => setRightTab("edit"),
2819
+ landing: /* @__PURE__ */ jsx(
2820
+ LandingPanel,
2821
+ {
2822
+ pages,
2823
+ directory: landingDirectory(site),
2824
+ liveIds,
2825
+ currentId: open.id,
2826
+ reserved,
2827
+ busy: busy || publishing,
2828
+ readOnly,
2829
+ onOpen: (id) => void openPage(id),
2830
+ onCreate: createLanding,
2831
+ onMove: moveLanding,
2832
+ onDelete: remove,
2833
+ onSetDirectory: changeLandingDirectory
2834
+ }
2835
+ )
2420
2836
  }
2421
2837
  ) })
2422
2838
  ] }) }),
@@ -2497,6 +2913,6 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2497
2913
  ] }) }) });
2498
2914
  }
2499
2915
 
2500
- export { AssetPicker, AutosaveBlockedError, Autosaver, IMAGE_TYPES, NODE_KEYS, SiteEditor, checkSite, countTypes, createEditorConfig, fromEditorData, genesisOverrides, h1SectionId, humanize, itemToNode, movePageInList, nodeToItem, pageTemplates, pathProblems, placeholderSnapshot, presetComponentName, pruneEmpty, publishSite, renamePage, renderPreview, safeSectionId, sectionFields, sectionTypeOf, slugify, toEditorData, uploadProblem };
2916
+ export { AssetPicker, AutosaveBlockedError, Autosaver, IMAGE_TYPES, LandingDirectoryError, NODE_KEYS, SiteEditor, checkSite, countTypes, createEditorConfig, createLandingPage, fromEditorData, genesisOverrides, h1SectionId, humanize, itemToNode, moveLandingPage, movePageInList, nodeToItem, pageTemplates, pathProblems, placeholderSnapshot, presetComponentName, pruneEmpty, publishSite, renamePage, renderPreview, safeSectionId, sectionFields, sectionTypeOf, setLandingDirectory, slugify, toEditorData, uploadProblem };
2501
2917
  //# sourceMappingURL=editor.js.map
2502
2918
  //# sourceMappingURL=editor.js.map