@vectoriox/iox-ui 5.177.0 → 5.178.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.
@@ -35727,1674 +35727,1713 @@ function showcasePlans(input) {
35727
35727
  return [...Array.from({ length: count }, (_, i) => plan(i, pages, input.design)), ...scenes, store];
35728
35728
  }
35729
35729
 
35730
+ function isImportPlan(plan) {
35731
+ return plan.source.kind === SitePlanSourceKind.Import;
35732
+ }
35733
+ const WEB_ADDRESS = /^https?:\/\//i;
35734
+ /** The fields of a type that hold pictures — a picture's address, or a list of them. */
35735
+ const PICTURE_CONTROLS = [ContentFieldControl.Media, ContentFieldControl.Gallery];
35730
35736
  /**
35731
- * A site build's WIRE vocabulary (AI plan §3b, W2): what iox-cms's `site-builds` API answers and what every
35732
- * client of it reads — the run's statuses and steps, what it created, why Undo kept something, the preflight's
35733
- * refusals, and the one spelling of each document's `buildKey`. ONE definition: iox-cms stores and answers it,
35734
- * the website wizard (W3) polls it. Pure types, enums and helpers; no transport.
35737
+ * Bring my site X5: every picture an import plan's REAL items show — the old address in each picture or gallery field of
35738
+ * a type the site filled (`seed.importedFrom`), each once, in plan order. The build copies these into the studio's own
35739
+ * storage and the items show the copies (never hot-linked); the wizard counts them. A plan read from no site has none.
35735
35740
  */
35736
- var SiteBuildKind;
35737
- (function (SiteBuildKind) {
35738
- SiteBuildKind["Build"] = "build";
35739
- /** A new design for a built site, everything it holds kept (site-redesign RD2) — `redesign-run.ts`. */
35740
- SiteBuildKind["Redesign"] = "redesign";
35741
- /** Bring my site X4 (W2-5's first kind): a plan read from the owner's own site (`planImport`) — its real items keep
35742
- * their old addresses (`importedFrom`). */
35743
- SiteBuildKind["Import"] = "import";
35744
- })(SiteBuildKind || (SiteBuildKind = {}));
35745
- var SiteBuildStatus;
35746
- (function (SiteBuildStatus) {
35747
- SiteBuildStatus["Running"] = "running";
35748
- SiteBuildStatus["Done"] = "done";
35749
- SiteBuildStatus["Failed"] = "failed";
35750
- SiteBuildStatus["Undoing"] = "undoing";
35751
- SiteBuildStatus["Undone"] = "undone";
35752
- /** A redesign (RD2): its new design going onto the pages, header, footer and look — page by page. */
35753
- SiteBuildStatus["Switching"] = "switching";
35754
- /** A redesign switched: the site wears it; Back is open for `REDESIGN_BACK_DAYS`. */
35755
- SiteBuildStatus["Switched"] = "switched";
35756
- /** A redesign going Back: its snapshot restored, page by page. */
35757
- SiteBuildStatus["Restoring"] = "restoring";
35758
- /** A redesign gone Back: the site wears what it wore before the switch. */
35759
- SiteBuildStatus["Restored"] = "restored";
35760
- /** A staged (or failed, never switched) redesign let go — by the owner, or by a newer redesign: no page was written. */
35761
- SiteBuildStatus["Discarded"] = "discarded";
35762
- })(SiteBuildStatus || (SiteBuildStatus = {}));
35763
- /** The statuses a runner advances — and the ones that hold the org's single-run slot. */
35764
- const ACTIVE_BUILD_STATUSES = [SiteBuildStatus.Running, SiteBuildStatus.Undoing, SiteBuildStatus.Switching, SiteBuildStatus.Restoring];
35765
- /** The steps of a build, in the order they run. */
35766
- var BuildStep;
35767
- (function (BuildStep) {
35768
- BuildStep["Preflight"] = "preflight";
35769
- BuildStep["ContentTypes"] = "content-types";
35770
- BuildStep["SampleImages"] = "sample-images";
35771
- /** I2: the curated stock photos the plan's empty picture slots take, copied into the studio (never hot-linked). */
35772
- BuildStep["StockPhotos"] = "stock-photos";
35773
- BuildStep["Items"] = "items";
35774
- /** Commerce G1: what the business sells, into the studio's SHOP — its categories, then sample products (no price). */
35775
- BuildStep["Shop"] = "shop";
35776
- BuildStep["DataSources"] = "data-sources";
35777
- BuildStep["Pages"] = "pages";
35778
- BuildStep["Globals"] = "globals";
35779
- BuildStep["Look"] = "look";
35780
- })(BuildStep || (BuildStep = {}));
35781
- const BUILD_STEPS = Object.values(BuildStep);
35782
- /** The steps a build of `plan` takes, in order: every one, the shop's only when the plan sells (commerce G1). */
35783
- function buildStepsOf(plan) {
35784
- const sells = planSells(plan);
35785
- return BUILD_STEPS.filter(step => step !== BuildStep.Shop || sells);
35786
- }
35787
- var StepState;
35788
- (function (StepState) {
35789
- StepState["Wait"] = "wait";
35790
- StepState["Run"] = "run";
35791
- StepState["Done"] = "done";
35792
- StepState["Failed"] = "failed";
35793
- })(StepState || (StepState = {}));
35794
- /** What a build creates, as Undo walks it. */
35795
- var CreatedKind;
35796
- (function (CreatedKind) {
35797
- CreatedKind["ContentType"] = "content-type";
35798
- /** Fields the build added to a content type it found (types are shared by every organization of a studio). */
35799
- CreatedKind["ContentTypeFields"] = "content-type-fields";
35800
- CreatedKind["SampleImage"] = "sample-image";
35801
- /** A stock photo copied into the studio's storage (`media/stock/…`), with its assets row. */
35802
- CreatedKind["StockPhoto"] = "stock-photo";
35803
- CreatedKind["Item"] = "item";
35804
- /** Commerce G1: a shop category the build added (one the studio had is reused, never recorded). */
35805
- CreatedKind["ShopCategory"] = "shop-category";
35806
- /** Commerce G1: a sample product, written through the shop's own write path. */
35807
- CreatedKind["ShopProduct"] = "shop-product";
35808
- CreatedKind["DataSource"] = "data-source";
35809
- CreatedKind["Page"] = "page";
35810
- /** RD3-D3 (a) Replace: a page an earlier Undo kept, moved aside (`/<route>-previous`, a draft) so the plan's page takes
35811
- * its address — Undo puts it back while it is as the move left it and its address is free (`CreatedRecord.from`). */
35812
- CreatedKind["PageMoved"] = "page-moved";
35813
- CreatedKind["Global"] = "global";
35814
- CreatedKind["Look"] = "look";
35815
- })(CreatedKind || (CreatedKind = {}));
35816
- /** Why Undo left something in place. */
35817
- var KeptReason;
35818
- (function (KeptReason) {
35819
- KeptReason["Edited"] = "edited";
35820
- KeptReason["Published"] = "published";
35821
- KeptReason["InUse"] = "in-use";
35822
- /** Added to a content type every organization shares: removing a field is the studio owner's change. */
35823
- KeptReason["Shared"] = "shared";
35824
- })(KeptReason || (KeptReason = {}));
35825
- var BuildNoticeCode;
35826
- (function (BuildNoticeCode) {
35827
- /** Storage is not configured: sample items get the empty image box, and the run says so. */
35828
- BuildNoticeCode["NoStorage"] = "no-storage";
35829
- /** A content type the build reuses is not public in this studio: the site will not show its items. */
35830
- BuildNoticeCode["ContentTypeNotPublic"] = "content-type-not-public";
35831
- /** The stock library could not be read: the picture slots keep the empty box, and the run says so. */
35832
- BuildNoticeCode["StockUnavailable"] = "stock-unavailable";
35833
- /** The stock library was read but holds no photo for this kind of business (never built, or reviewed down to
35834
- * none): the picture slots keep the empty box, and the run says so (I2.1 — never silently). */
35835
- BuildNoticeCode["StockMissing"] = "stock-missing";
35836
- /** M7: a picture made for the site was refused by its review twice (or its second try did not fit the cost shown):
35837
- * stock or the empty box stands in, and the run says so. */
35838
- BuildNoticeCode["PictureFallback"] = "picture-fallback";
35839
- /** Commerce G1 (shop-aware A-D9): the studio already sells products — the site shows them, and no sample is added. */
35840
- BuildNoticeCode["ShopHasProducts"] = "shop-has-products";
35841
- /** Commerce G1: the studio had never set its currency and VAT — the build stored the ones its language implies
35842
- * (Hebrew: ILS and 18%), said here so the owner checks them in Settings ▸ General before setting prices. */
35843
- BuildNoticeCode["ShopMoneyInferred"] = "shop-money-inferred";
35844
- /** Commerce G2: the facts the owner gave (email, phone, address) became the shop's contact details where it had none
35845
- * — said, so the owner adds what only they know (the legal name, the business number) in Shop ▸ Settings. */
35846
- BuildNoticeCode["ShopBusinessFromFacts"] = "shop-business-from-facts";
35847
- /** RD3-D3 (a) Keep mine: a page an earlier Undo kept stays at an address the plan builds — the plan's page there is
35848
- * not built. */
35849
- BuildNoticeCode["KeptPageSkipped"] = "kept-page-skipped";
35850
- /** RD3-D3 (a) Replace: that page moved aside as a draft (`/<route>-previous`) — Undo puts it back. */
35851
- BuildNoticeCode["KeptPageMoved"] = "kept-page-moved";
35852
- /** HI1a: the header the plan asked for could not be worn as asked (a long name between two menus, a part the site
35853
- * cannot carry) — the composer mended it, and the run says so; the owner changes it in the builder. */
35854
- BuildNoticeCode["HeaderMended"] = "header-mended";
35855
- /** AW8: the opening the plan asked for was mended (an award word on a basic build, a part the site cannot carry) —
35856
- * said, so the owner knows the home page opens a little differently and where to change it. */
35857
- BuildNoticeCode["OpeningMended"] = "opening-mended";
35858
- /** LI5: the footer the plan asked for was mended (a word that waits drawn as its stand-in, a one-line footer that
35859
- * holds only some parts) — said like the header's and the opening's. */
35860
- BuildNoticeCode["FooterMended"] = "footer-mended";
35861
- /** AW6: the body the plan asked for was mended (a section edge that comes with the award plan, on a basic build) —
35862
- * said like the header's, the opening's and the footer's. */
35863
- BuildNoticeCode["BodyMended"] = "body-mended";
35864
- /** iox-ui#129: pictures nothing fills were not drawn as empty boxes — those sections were composed type-led (the home
35865
- * page opening on its words, a list's cards without their picture). Said once, so the owner knows a photo of theirs
35866
- * brings the picture-led section back (a Re-fit, or the next build). */
35867
- BuildNoticeCode["TypeLed"] = "type-led";
35868
- })(BuildNoticeCode || (BuildNoticeCode = {}));
35869
- /** RD3-D3 (a): what a build does with a page an earlier Undo kept at an address its plan builds — the header and footer's
35870
- * pair (`replaceGlobals`), for pages. */
35871
- var KeptPagesChoice;
35872
- (function (KeptPagesChoice) {
35873
- /** Build every other page; leave these as they are. */
35874
- KeptPagesChoice["Keep"] = "keep";
35875
- /** Move each aside as a draft at `/<route>-previous` (`/shop-previous/:slug` for a per-item page) and build the plan's
35876
- * page at its address. Nothing is deleted. */
35877
- KeptPagesChoice["Replace"] = "replace";
35878
- })(KeptPagesChoice || (KeptPagesChoice = {}));
35879
- /** The suffix a replaced page's address takes. */
35880
- const PREVIOUS_ROUTE_SUFFIX = '-previous';
35881
- /** Where a page moved aside goes: `/<route>-previous`, then `-previous-2`… — never an address in `taken` (shapes
35882
- * compared case-insensitively, trailing slash and parameter names ignored). The home page (`/`) goes to `/home-previous`.
35883
- *
35884
- * ⚠️ The suffix goes on the route's LAST STATIC segment, never on a `:param` (vectoriox/iox-ui#100): `/shop/:slug` moved
35885
- * to `/shop/:slug-previous` still answered every `/shop/<item>` — a parameter matches the whole segment — and, older
35886
- * and published by Publish site, the replaced product page was served instead of the new one. So `/shop/:slug` →
35887
- * `/shop-previous/:slug`, and a route of parameters only (`/:slug`) → `/previous/:slug`. */
35888
- function previousRoute(route, taken) {
35889
- const key = (r) => (r.replace(/\/+$/, '') || '/').replace(/\/:[^/]+/g, '/:').toLowerCase();
35890
- const held = new Set(taken.map(key));
35891
- const segments = (route.replace(/\/+$/, '') || '/home').split('/').filter(Boolean);
35892
- if (!segments.length)
35893
- segments.push('home');
35894
- const at = segments.map((seg, i) => (seg.startsWith(':') ? -1 : i)).filter(i => i >= 0).pop();
35895
- const shaped = (suffix) => {
35896
- const out = [...segments];
35897
- if (at === undefined)
35898
- out.unshift(`previous${suffix}`);
35899
- else
35900
- out[at] = `${out[at]}${PREVIOUS_ROUTE_SUFFIX}${suffix}`;
35901
- return `/${out.join('/')}`;
35902
- };
35903
- let candidate = shaped('');
35904
- for (let n = 2; held.has(key(candidate)); n++)
35905
- candidate = shaped(`-${n}`);
35906
- return candidate;
35741
+ function importedPicturesOf(plan) {
35742
+ if (plan?.source?.kind !== SitePlanSourceKind.Import)
35743
+ return [];
35744
+ const found = new Set();
35745
+ for (const type of plan.contentTypes ?? []) {
35746
+ if (!type.seed?.importedFrom?.length)
35747
+ continue;
35748
+ for (const field of type.fields.filter(f => PICTURE_CONTROLS.includes(f.controller))) {
35749
+ for (const value of type.seed.perItem?.[field.name] ?? []) {
35750
+ for (const address of typeof value === 'string' ? [value] : value)
35751
+ if (WEB_ADDRESS.test(address))
35752
+ found.add(address);
35753
+ }
35754
+ }
35755
+ }
35756
+ return [...found];
35907
35757
  }
35908
- /** The compose issues the run SAYS (header, opening, footer), each kind once (the wizard tracks a notice by its code): the words of every mend of
35909
- * that kind joined, for the log and the API; the screen shows the code's own sentence. An opening that only found no
35910
- * place for a word it carried is not a mend of the mix, so it is not said. */
35911
- const MEND_NOTICES = [
35912
- [ComposeIssueCode.HeaderMended, BuildNoticeCode.HeaderMended],
35913
- [ComposeIssueCode.OpeningMended, BuildNoticeCode.OpeningMended],
35914
- [ComposeIssueCode.FooterMended, BuildNoticeCode.FooterMended],
35915
- [ComposeIssueCode.BodyMended, BuildNoticeCode.BodyMended],
35758
+ /** The patterns an import places (contract `site.patterns`). */
35759
+ var ImportPattern;
35760
+ (function (ImportPattern) {
35761
+ ImportPattern["PageHeader"] = "page-header.simple";
35762
+ ImportPattern["LongForm"] = "story.long-form";
35763
+ ImportPattern["CardGrid"] = "collection.card-grid";
35764
+ ImportPattern["ItemHero"] = "project.hero";
35765
+ ImportPattern["ItemBody"] = "item.body";
35766
+ ImportPattern["ItemGallery"] = "project.gallery";
35767
+ ImportPattern["ItemNext"] = "project.next";
35768
+ })(ImportPattern || (ImportPattern = {}));
35769
+ /** The optional parts an import leaves out (each pattern's `optional`). */
35770
+ const WITHOUT = {
35771
+ pageHeader: ['eyebrow', 'lead'],
35772
+ longForm: ['heading', 'lead', 'more'],
35773
+ cardGridHeader: ['header'],
35774
+ };
35775
+ /** How many pages the header lists — the rest stay reachable from their lists and links. */
35776
+ const IMPORT_NAV_MAX = 6;
35777
+ /** A list's "latest" source on the home page. */
35778
+ const LATEST_LIMIT = 3;
35779
+ const ITEM_PARAM = 'slug';
35780
+ const SLUG_FIELD = 'slug';
35781
+ const HOME_ROUTE = '/';
35782
+ const CONTACT_ARCHETYPE = 'contact';
35783
+ const ABOUT_ARCHETYPE = 'about';
35784
+ const COLLECTION_ARCHETYPE = 'collection';
35785
+ const DETAIL_ARCHETYPE = 'detail';
35786
+ /**
35787
+ * The words that say a list is the template's own type (the Studio's projects are a portfolio, the Practice's services,
35788
+ * the Place's menu) — its items take the template type's place, pages and all (`/work/:slug`). One table, by type name.
35789
+ */
35790
+ const TEMPLATE_TYPE_WORDS = {
35791
+ projects: /\b(projects?|portfolios?|works?|case[\s-]?stud(?:y|ies)|showcase)\b/i,
35792
+ services: /\b(services?|treatments?|offers?)\b/i,
35793
+ menu: /\b(menus?|dishes|drinks)\b/i,
35794
+ };
35795
+ /** The field each role of a list's own type is written to, in field order, and how it is edited. */
35796
+ const OWN_FIELDS = [
35797
+ { role: ContentRole.Title, name: 'title', control: ContentFieldControl.Text, required: true },
35798
+ { role: null, name: SLUG_FIELD, control: ContentFieldControl.Text, required: true },
35799
+ { role: ContentRole.Summary, name: 'summary', control: ContentFieldControl.Textarea },
35800
+ { role: ContentRole.Image, name: 'cover', control: ContentFieldControl.Media },
35801
+ { role: ContentRole.Gallery, name: 'gallery', control: ContentFieldControl.Gallery },
35802
+ { role: ContentRole.Date, name: 'date', control: ContentFieldControl.Text },
35803
+ { role: ContentRole.Meta, name: 'category', control: ContentFieldControl.Text },
35804
+ { role: ContentRole.Body, name: 'body', control: ContentFieldControl.Textarea },
35916
35805
  ];
35917
- const CARRY_ONLY = /^the opening found no place for /;
35918
- function mendNotices(issues) {
35919
- return MEND_NOTICES.flatMap(([issue, notice]) => {
35920
- const said = [...new Set(issues.filter(i => i.code === issue && !CARRY_ONLY.test(i.detail)).map(i => i.detail))];
35921
- return said.length ? [{ code: notice, detail: said.join('; ') }] : [];
35922
- });
35806
+ /** What an item gives each role (null: nothing). */
35807
+ function itemValue(item, role) {
35808
+ switch (role) {
35809
+ case ContentRole.Title: return item.title;
35810
+ case ContentRole.Summary: return item.summary || null;
35811
+ case ContentRole.Image: return item.picture || null;
35812
+ case ContentRole.Gallery: return item.pictures?.length ? item.pictures : null;
35813
+ case ContentRole.Date: return item.date || null;
35814
+ case ContentRole.Meta: return item.meta || null;
35815
+ case ContentRole.Body: return item.text?.trim() ? item.text.trim() : null;
35816
+ default: return null;
35817
+ }
35923
35818
  }
35924
- /** iox-ui#129: what a composition made type-led, said once (`BuildNoticeCode.TypeLed`) — every change's words joined,
35925
- * for the log and the API; the screen shows the code's own sentence. Nothing type-led: nothing said. */
35926
- function typeLedNotices(typeLed) {
35927
- const said = [...new Set((typeLed?.changes ?? []).map(c => c.said))];
35928
- return said.length ? [{ code: BuildNoticeCode.TypeLed, detail: said.join('; ') }] : [];
35819
+ const has = (items, role) => items.some(item => itemValue(item, role) !== null);
35820
+ /** Lowercase words joined by hyphens — a route segment or a slug. */
35821
+ function importSlug(text) {
35822
+ return text.normalize('NFKD').replace(/[̀-ͯ]/g, '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
35929
35823
  }
35930
- var PreflightRefusalCode;
35931
- (function (PreflightRefusalCode) {
35932
- /** The Site Plan itself is invalid (`validateSitePlan`); `issue` is the validator's code. */
35933
- PreflightRefusalCode["InvalidPlan"] = "invalid-plan";
35934
- /** A route the plan wants is already a page of this organization. */
35935
- PreflightRefusalCode["RouteTaken"] = "route-taken";
35936
- /** The studio's content type of that name stores a field the plan needs differently (type or control) —
35937
- * types are shared by every organization, so the build reuses one it finds and adds what it lacks. */
35938
- PreflightRefusalCode["ContentTypeConflict"] = "content-type-conflict";
35939
- /** The name may not be a content type (a platform collection, or not a valid name). */
35940
- PreflightRefusalCode["ContentTypeName"] = "content-type-name";
35941
- /** The plan creates a content type or adds fields to one, and the caller may not (an org owner/admin — schema_all). */
35942
- PreflightRefusalCode["ContentTypesNeedPermission"] = "content-types-need-permission";
35943
- /** The org library holds the alias with a different definition. */
35944
- PreflightRefusalCode["DataSourceConflict"] = "data-source-conflict";
35945
- /** The studio has pages AND a header/footer: replace or keep them is the caller's choice (D7). */
35946
- PreflightRefusalCode["GlobalsNeedDecision"] = "globals-need-decision";
35947
- /** A global the plan adds has the id of one the studio keeps. */
35948
- PreflightRefusalCode["GlobalTaken"] = "global-taken";
35949
- /** RD3-D3 (a): a page an earlier Undo kept (published or edited) sits at an address the plan builds — Keep mine or
35950
- * Replace them is the caller's choice (`KeptPagesChoice`). A page made by hand there stays a plain `route-taken`. */
35951
- PreflightRefusalCode["KeptPageNeedsDecision"] = "kept-page-needs-decision";
35952
- })(PreflightRefusalCode || (PreflightRefusalCode = {}));
35953
- /**
35954
- * The stable key each written document carries beside `siteBuildId`: a step that runs twice looks it up first and
35955
- * skips what exists (so a restart or a Retry continues without duplicates), and a reader finds what the run made
35956
- * by it — the wizard opens the HOME page by `page(<its key>)`. One builder per kind.
35957
- */
35958
- const buildKeys = {
35959
- contentType: (name) => `schema:${name}`,
35960
- contentTypeFields: (name) => `schema-fields:${name}`,
35961
- item: (contentType, n) => `item:${contentType}:${n}`,
35962
- shopCategory: (n) => `shop-category:${n}`,
35963
- shopProduct: (n) => `shop-product:${n}`,
35964
- sampleImage: (n) => `sample-image:${n}`,
35965
- stockPhoto: (libraryKey) => `stock-photo:${libraryKey}`,
35966
- dataSource: (alias) => `data-source:${alias}`,
35967
- page: (key) => `page:${key}`,
35968
- global: (nodeId) => `global:${nodeId}`,
35969
- look: () => 'look',
35970
- pageMoved: (pageId) => `page-moved:${pageId}`,
35971
- };
35972
- /** The id of the page a run made for the plan's home page, or null (not made yet, or no home page). */
35973
- function builtHomePageId(run) {
35974
- const home = run?.plan?.pages?.find(p => p.isHome) ?? run?.plan?.pages?.[0];
35975
- if (!home)
35824
+ /** Makes names unique in order: the second `a` is `a-2`. */
35825
+ class Names {
35826
+ constructor(taken = []) {
35827
+ this.taken = new Set();
35828
+ for (const t of taken)
35829
+ this.taken.add(t);
35830
+ }
35831
+ has(name) { return this.taken.has(name); }
35832
+ claim(name, join = '-') {
35833
+ let out = name;
35834
+ for (let n = 2; this.taken.has(out); n++)
35835
+ out = `${name}${join}${n}`;
35836
+ this.taken.add(out);
35837
+ return out;
35838
+ }
35839
+ }
35840
+ const camel = (slug) => slug.replace(/-([a-z0-9])/g, (_m, c) => c.toUpperCase());
35841
+ /** A route the plan accepts from an old path: each segment as lowercase words; null when nothing is left. */
35842
+ function routeOfPath(path) {
35843
+ if (!path)
35976
35844
  return null;
35977
- const key = buildKeys.page(home.key);
35978
- return run.created?.find(c => c.kind === CreatedKind.Page && c.buildKey === key)?.id ?? null;
35845
+ const segments = path.split(/[?#]/)[0].split('/').map(importSlug).filter(Boolean);
35846
+ return segments.length ? `/${segments.join('/')}` : null;
35979
35847
  }
35980
- /** The step a run stopped at, or null. */
35981
- function failedBuildStep(run) {
35982
- return run?.steps?.find(s => s.state === StepState.Failed) ?? null;
35848
+ /** The template's pages and sources that show its content type (a list or an item of it). */
35849
+ function templateTypeParts(template, typeName) {
35850
+ const aliases = new Set(template.dataSources.filter(d => d.type === PlanDataSourceType.Relative ? false : 'contentType' in d && d.contentType === typeName).map(d => d.alias));
35851
+ for (const d of template.dataSources)
35852
+ if (d.type === PlanDataSourceType.Relative && (aliases.has(d.of) || aliases.has(d.within)))
35853
+ aliases.add(d.alias);
35854
+ const pages = new Set(template.pages.filter(p => p.template === typeName || (!p.isHome && p.sections.some(s => s.binding && aliases.has(s.binding)))).map(p => p.key));
35855
+ return { aliases, pages };
35983
35856
  }
35984
- /** A run still holding the org's slot (building or undoing) — a page that left it comes back to its progress. */
35985
- function isActiveBuild(run) {
35986
- return !!run && ACTIVE_BUILD_STATUSES.includes(run.status);
35857
+ /** The list that takes the template type's place, if one reads as it. */
35858
+ function templateListOf(template, lists) {
35859
+ for (const type of template.contentTypes) {
35860
+ const words = TEMPLATE_TYPE_WORDS[type.name];
35861
+ const list = words ? lists.find(l => l.items.length && [l.key, l.label, l.path ?? ''].some(w => words.test(w.replace(/[-_/]+/g, ' ')))) : undefined;
35862
+ if (list)
35863
+ return { type, list };
35864
+ }
35865
+ return null;
35987
35866
  }
35988
- /** What a build does with each content type its plan names (the preflight's `summary.contentTypes[].action`): content
35989
- * types are shared by every organization of a studio, so one the studio already has is reused, or extended with the
35990
- * fields it lacks — never created twice. */
35991
- var ContentTypeAction;
35992
- (function (ContentTypeAction) {
35993
- ContentTypeAction["Create"] = "create";
35994
- ContentTypeAction["Reuse"] = "reuse";
35995
- ContentTypeAction["Extend"] = "extend";
35996
- })(ContentTypeAction || (ContentTypeAction = {}));
35997
- function buildStepFacts(plan, actions = {}) {
35998
- const contentTypeActions = {};
35999
- for (const t of plan.contentTypes) {
36000
- const action = actions[t.name];
36001
- if (action)
36002
- (contentTypeActions[action] ??= []).push(t.label);
35867
+ /** The items' slugs: their own where the site gave one, else from the title; unique within the list. */
35868
+ function slugsOf(items) {
35869
+ const names = new Names();
35870
+ return items.map((item, i) => names.claim(importSlug(item.slug ?? '') || importSlug(item.title) || `item-${i + 1}`));
35871
+ }
35872
+ /** The real items as a seed: one value per item for each role the type plays, the slug, and each item's old address. */
35873
+ function seedOf(type, items) {
35874
+ const perItem = {};
35875
+ const slugField = type.fields.some(f => f.name === SLUG_FIELD) ? SLUG_FIELD : null;
35876
+ if (slugField)
35877
+ perItem[slugField] = slugsOf(items);
35878
+ for (const [role, field] of Object.entries(type.roles)) {
35879
+ const list = type.fields.find(f => f.name === field)?.controller === ContentFieldControl.Gallery;
35880
+ perItem[field] = items.map(item => {
35881
+ const value = itemValue(item, role);
35882
+ if (list)
35883
+ return Array.isArray(value) ? [...value] : [];
35884
+ return typeof value === 'string' ? value : '';
35885
+ });
35886
+ }
35887
+ return { count: items.length, sample: false, isPublished: true, perItem, importedFrom: items.map(i => i.from) };
35888
+ }
35889
+ const fieldOf = (name, control, required) => ({ name, type: FIELD_TYPE_OF_CONTROL[control], controller: control, ...(required ? { required: true } : {}) });
35890
+ /** A list's own type: the roles its items fill, each its field (`OWN_FIELDS`). */
35891
+ function ownType(name, list) {
35892
+ const fields = [];
35893
+ const roles = {};
35894
+ for (const f of OWN_FIELDS) {
35895
+ if (f.role && f.role !== ContentRole.Title && !has(list.items, f.role))
35896
+ continue;
35897
+ fields.push(fieldOf(f.name, f.control, f.required));
35898
+ if (f.role)
35899
+ roles[f.role] = f.name;
36003
35900
  }
35901
+ const type = { name, label: list.label, roles: roles, fields };
35902
+ return { ...type, seed: seedOf(type, list.items) };
35903
+ }
35904
+ /** The template's type with the list's items: its own fields, and its `body` (the items' own text) when they have one.
35905
+ * A role the template gives a field of its own meaning (the Studio's `meta` is a location) is not filled from the site. */
35906
+ const TEMPLATE_ROLES_FILLED = [ContentRole.Title, ContentRole.Summary, ContentRole.Image, ContentRole.Gallery, ContentRole.Date, ContentRole.Body];
35907
+ function templateType(type, list) {
35908
+ const withBody = has(list.items, ContentRole.Body) && !roleField(type, ContentRole.Body);
35909
+ const bodyName = new Names(type.fields.map(f => f.name)).claim('body');
35910
+ const fields = withBody ? [...type.fields, fieldOf(bodyName, ContentFieldControl.Textarea)] : [...type.fields];
35911
+ const roles = (withBody ? { ...type.roles, [ContentRole.Body]: bodyName } : { ...type.roles });
35912
+ const filled = Object.fromEntries(Object.entries(roles).filter(([role]) => TEMPLATE_ROLES_FILLED.includes(role)));
35913
+ const seed = seedOf({ roles: filled, fields }, list.items);
35914
+ // A field the site does not fill is written empty (never the template's sample words).
35915
+ const empty = Object.fromEntries(fields.filter(f => !(f.name in (seed.perItem ?? {}))).map(f => [f.name, f.controller === ContentFieldControl.Gallery ? [] : '']));
35916
+ return { name: type.name, label: list.label || type.label, roles, fields, seed: { ...seed, ...empty } };
35917
+ }
35918
+ /** The sources of a list's own type: all of it, the latest few, one by its slug, and the next one. */
35919
+ function ownSources(name) {
35920
+ const list = name, latest = `${name}Latest`, item = `${name}Item`, next = `${name}Next`;
36004
35921
  return {
36005
- contentTypes: plan.contentTypes.map(t => t.label),
36006
- contentTypeActions,
36007
- items: plan.contentTypes.reduce((n, t) => n + (t.seed?.count ?? 0), 0),
36008
- products: plan.shop?.products.length ?? 0,
36009
- categories: plan.shop?.categories.length ?? 0,
36010
- pages: plan.pages.length,
36011
- routes: plan.pages.map(p => p.route),
36012
- navLinks: plan.pages.filter(p => p.inNav).length,
36013
- flavorId: plan.design.flavorId,
35922
+ list, latest, item,
35923
+ sources: [
35924
+ { alias: list, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Query, contentType: name },
35925
+ { alias: latest, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Query, contentType: name, limit: LATEST_LIMIT },
35926
+ { alias: item, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Single, contentType: name, filterByRouteParam: { field: SLUG_FIELD, routeParam: ITEM_PARAM } },
35927
+ { alias: next, type: PlanDataSourceType.Relative, of: item, op: RelativeOp.SiblingsNext, within: list },
35928
+ ],
36014
35929
  };
36015
35930
  }
36016
-
35931
+ /** The page of one item: its hero, its own text, its pictures, the next one (each only when the items have it). */
35932
+ function itemSections(type, nextLabel) {
35933
+ const sections = [{ pattern: ImportPattern.ItemHero }];
35934
+ if (roleField(type, ContentRole.Body))
35935
+ sections.push({ pattern: ImportPattern.ItemBody });
35936
+ if (roleField(type, ContentRole.Gallery))
35937
+ sections.push({ pattern: ImportPattern.ItemGallery });
35938
+ sections.push(nextLabel ? { pattern: ImportPattern.ItemNext, slots: { label: nextLabel } } : { pattern: ImportPattern.ItemNext });
35939
+ return sections;
35940
+ }
35941
+ const pageHeader = (title, lead) => lead
35942
+ ? { pattern: ImportPattern.PageHeader, slots: { title, lead }, without: ['eyebrow'] }
35943
+ : { pattern: ImportPattern.PageHeader, slots: { title }, without: [...WITHOUT.pageHeader] };
36017
35944
  /**
36018
- * A REDESIGN run's wire vocabulary (site-redesign plan §3c, RD2): a new design for a built site, with everything it holds
36019
- * kept. The same W2 runner and the same single-run slot as a build (`SiteBuildKind.Redesign` in the `siteBuilds`
36020
- * collection), its own steps: Snapshot → Harvest → Compose → Stage, then the owner's Switch, then Back for
36021
- * `REDESIGN_BACK_DAYS`. Structure is locked (RD-D4): a redesign writes pages' layouts and settings, the header and footer,
36022
- * and the look — never a content type, field, item, data source or route. ONE definition: iox-cms stores and answers it,
36023
- * the redesign screens (RD3) read it. Pure types, enums and helpers; no transport.
35945
+ * The scan's reading → the plan. Every list with items becomes a content type (the one that reads as the template's own
35946
+ * takes its place, routes and all); every page with words becomes a page; nothing is invented — a page or a list the
35947
+ * site did not have is not added, and the template's own pages are kept only where they are the site's frame (the home
35948
+ * page, the contact page).
36024
35949
  */
36025
- /** The steps a redesign takes before its Switch, in the order they run. */
36026
- var RedesignStep;
36027
- (function (RedesignStep) {
36028
- /** Every page in scope (its layout, settings, fingerprint) and the globals — the version Back restores. */
36029
- RedesignStep["Snapshot"] = "snapshot";
36030
- /** `harvestPage` per page in scope: what on it is the owner's. */
36031
- RedesignStep["Harvest"] = "harvest";
36032
- /** What the redesign may ADD (§3e, RD3-D2 as amended): new pages the owner asked for or the reading suggests, the new
36033
- * content they need — asked, checked (`checkAdditions`), drawn and staged; nothing existing is touched. */
36034
- RedesignStep["Additions"] = "additions";
36035
- /** Per page: the model's layout with its carry (a composed page), or the page re-fitted for the new look. */
36036
- RedesignStep["Compose"] = "compose";
36037
- /** The new layouts, header, footer and look written onto the RUN — the live site does not move. */
36038
- RedesignStep["Stage"] = "stage";
36039
- })(RedesignStep || (RedesignStep = {}));
36040
- const REDESIGN_STEPS = Object.values(RedesignStep);
36041
- /** How long Back stays open after a Switch (RD-D11). */
36042
- const REDESIGN_BACK_DAYS = 30;
36043
- const DAY_MS = 24 * 60 * 60 * 1000;
36044
- /** How a page in scope got its new design. */
36045
- var StagedPageWay;
36046
- (function (StagedPageWay) {
36047
- /** The model laid it out (the M8 layout request with the page's carry). */
36048
- StagedPageWay["Composed"] = "composed";
36049
- /** Re-stamped from its run's plan in the new look, the owner's content and edits carried (Re-fit — no model). */
36050
- StagedPageWay["Refit"] = "refit";
36051
- /** Not redesigned: it stays as it is and wears the new look through its tokens and element styles. */
36052
- StagedPageWay["Kept"] = "kept";
36053
- })(StagedPageWay || (StagedPageWay = {}));
36054
- /** Why a page went the way it did, when the way alone does not say it. */
36055
- var StagedPageReason;
36056
- (function (StagedPageReason) {
36057
- /** The page is laid out by patterns in its plan (not a composed page): re-fitted, no model asked (RD-D13). */
36058
- StagedPageReason["Patterns"] = "patterns";
36059
- /** The model's layout did not hold (after its repair and the section fallback): re-fitted instead. */
36060
- StagedPageReason["ModelFellBack"] = "model-fell-back";
36061
- /** There is no reading to ask the model with (a site built from a template): re-fitted. */
36062
- StagedPageReason["NoReading"] = "no-reading";
36063
- /** The model was refused before the call (credits, plan): re-fitted. */
36064
- StagedPageReason["Refused"] = "refused";
36065
- /** A legal page: its text is the owner's, never recomposed (RD-D17). */
36066
- StagedPageReason["Legal"] = "legal";
36067
- /** A page the owner made by hand that stays as it is: there is no reading to lay it out with (a studio built from a
36068
- * template). With a reading it is laid out like a composed page (RD-D16, RD3-D1 — `handPageKey`). */
36069
- StagedPageReason["HandMade"] = "hand-made";
36070
- /** The run that built it, or its page in that run's plan, is gone: nothing to re-stamp it from. */
36071
- StagedPageReason["NoSource"] = "no-source";
36072
- })(StagedPageReason || (StagedPageReason = {}));
36073
- /** Why a redesign staged no additions without asking, or could not use the answer. */
36074
- var AdditionsSkipped;
36075
- (function (AdditionsSkipped) {
36076
- /** No sentence, and the owner turned down the suggestions of their last redesign: nothing is asked. */
36077
- AdditionsSkipped["NothingToAsk"] = "nothing-to-ask";
36078
- /** Asked, and the answer did not pass (after its one re-ask). */
36079
- AdditionsSkipped["NotUsable"] = "not-usable";
36080
- /** Refused before the call (credits, plan) — the redesign goes on without additions. */
36081
- AdditionsSkipped["Refused"] = "refused";
36082
- })(AdditionsSkipped || (AdditionsSkipped = {}));
36083
- /** Why the Switch held an addition back: something took its place since it was staged (never overwritten). */
36084
- var AdditionHeldBack;
36085
- (function (AdditionHeldBack) {
36086
- AdditionHeldBack["RouteTaken"] = "route-taken";
36087
- AdditionHeldBack["TypeExists"] = "type-exists";
36088
- AdditionHeldBack["SourceTaken"] = "source-taken";
36089
- /** It brings a new content type and the person who switched may not add one (an org owner or admin may). */
36090
- AdditionHeldBack["TypesNotAllowed"] = "types-not-allowed";
36091
- })(AdditionHeldBack || (AdditionHeldBack = {}));
36092
- /** What the Switch (and Back) did to one page. */
36093
- var RedesignPageResult;
36094
- (function (RedesignPageResult) {
36095
- RedesignPageResult["Switched"] = "switched";
36096
- /** Edited after the harvest: not switched (RD-D12) — Compare offers "Redo this page". */
36097
- RedesignPageResult["Stale"] = "stale";
36098
- /** The owner kept the old design for it (per-page accept, RD-D9). */
36099
- RedesignPageResult["Declined"] = "declined";
36100
- /** Kept as it is by the redesign (`StagedPageWay.Kept`) — nothing to write. */
36101
- RedesignPageResult["Unchanged"] = "unchanged";
36102
- /** Back: the snapshot is on the page again. */
36103
- RedesignPageResult["Restored"] = "restored";
36104
- /** Back: edited since the switch and not asked to restore — left as it is (RD-D12). */
36105
- RedesignPageResult["EditedSince"] = "edited-since";
36106
- /** Back: the page was deleted since the switch. */
36107
- RedesignPageResult["Gone"] = "gone";
36108
- })(RedesignPageResult || (RedesignPageResult = {}));
36109
- /** The parts of a Switch or a Back, in the order they run — a resumed one carries on after the done ones. */
36110
- var RedesignPart;
36111
- (function (RedesignPart) {
36112
- /** What the redesign adds — new types, items, sources and pages (§3e) — before the pages, so a new page's links resolve. */
36113
- RedesignPart["Additions"] = "additions";
36114
- RedesignPart["Pages"] = "pages";
36115
- RedesignPart["Globals"] = "globals";
36116
- RedesignPart["Look"] = "look";
36117
- })(RedesignPart || (RedesignPart = {}));
36118
- const REDESIGN_PARTS = Object.values(RedesignPart);
36119
- /** The choices of the look a Switch replaced — what Back returns to ("Linen · Warm") — or null when the run does not
36120
- * say (not switched yet, or a run stored before the look was). A studio with no design row wore its defaults. */
36121
- function redesignPreviousChoices(run) {
36122
- const before = run?.look?.before;
36123
- if (!before)
36124
- return null;
36125
- return readDesignConfig(before.config, !!before.config).choices;
36126
- }
36127
- /** The refusals of a redesign's start, switch and back. */
36128
- var RedesignRefusalCode;
36129
- (function (RedesignRefusalCode) {
36130
- /** No page in scope was built by a site build — there is nothing to redesign. */
36131
- RedesignRefusalCode["NothingBuilt"] = "nothing-built";
36132
- /** A page id in scope is not a page of this organization. */
36133
- RedesignRefusalCode["UnknownPage"] = "unknown-page";
36134
- /** The look asked for is not a look (design-core cannot complete it). */
36135
- RedesignRefusalCode["InvalidDesign"] = "invalid-design";
36136
- /** Switch on a run that is not staged, Back on one that is not switched. */
36137
- RedesignRefusalCode["WrongStatus"] = "wrong-status";
36138
- /** Back after `REDESIGN_BACK_DAYS`. */
36139
- RedesignRefusalCode["BackClosed"] = "back-closed";
36140
- /** One page again: the page is not one of the run's staged pages, or it stays as it is with nothing to lay out
36141
- * (a legal page, a page with no plan to compose it from). */
36142
- RedesignRefusalCode["NotRedesignable"] = "not-redesignable";
36143
- })(RedesignRefusalCode || (RedesignRefusalCode = {}));
36144
- /** The day Back closes, or null (not switched). */
36145
- function redesignBackUntil(run) {
36146
- const at = run.switch?.finishedAt ?? run.switch?.at;
36147
- return at ? new Date(new Date(at).getTime() + REDESIGN_BACK_DAYS * DAY_MS) : null;
36148
- }
36149
- /** May Back run now: switched, and within `REDESIGN_BACK_DAYS` of the switch. */
36150
- function redesignBackOpen(run, now) {
36151
- const until = redesignBackUntil(run);
36152
- return run.status === SiteBuildStatus.Switched && !!until && now.getTime() <= until.getTime();
36153
- }
36154
- /** The plan-page key of a page the owner made by hand (RD2.1, RD3-D1 (a)): `hand:<pageId>`. */
36155
- const HAND_PAGE_KEY_PREFIX = 'hand:';
36156
- function handPageKey(pageId) {
36157
- return `${HAND_PAGE_KEY_PREFIX}${pageId}`;
36158
- }
36159
- /** Is `key` a hand-made page's plan-page key. */
36160
- function isHandPageKey(key) {
36161
- return typeof key === 'string' && key.startsWith(HAND_PAGE_KEY_PREFIX) && key.length > HAND_PAGE_KEY_PREFIX.length;
36162
- }
36163
- /**
36164
- * The plan page a redesign gives a page the owner made by hand (RD2.1): its address and name, laid out by the model in the
36165
- * layout language (`compose`), every section the owner's (`harvestPage(…, { built: false })`), no sections of its own to
36166
- * fall back on, never added to the navigation (the owner's header decides that, as before).
36167
- */
36168
- function handPlanPage(page) {
36169
- return { key: handPageKey(page.pageId), name: page.name, route: page.route, inNav: false, sections: [], compose: true };
36170
- }
36171
- /** May the owner let a redesign go (Discard): staged, or failed before any Switch wrote a page. */
36172
- function redesignDiscardable(run) {
36173
- return run.status === SiteBuildStatus.Done || (run.status === SiteBuildStatus.Failed && !run.switch);
36174
- }
36175
- /** Is a run a redesign (a stored run of either kind). */
36176
- function isRedesignRun(run) {
36177
- return run?.kind === SiteBuildKind.Redesign;
35950
+ function planImport(reading, input) {
35951
+ const template = input.template ?? STUDIO_TEMPLATE;
35952
+ const lists = reading.lists.filter(l => l.items.length > 0);
35953
+ const matched = templateListOf(template, lists);
35954
+ const dropped = new Set(); // the template types no list fills
35955
+ const contentTypes = [];
35956
+ const dataSources = [];
35957
+ const templateParts = new Map();
35958
+ for (const type of template.contentTypes) {
35959
+ const parts = templateTypeParts(template, type.name);
35960
+ templateParts.set(type.name, parts);
35961
+ if (matched?.type.name === type.name) {
35962
+ contentTypes.push(templateType(type, matched.list));
35963
+ dataSources.push(...template.dataSources.filter(d => parts.aliases.has(d.alias)));
35964
+ }
35965
+ else
35966
+ dropped.add(type.name);
35967
+ }
35968
+ const droppedAliases = new Set([...dropped].flatMap(t => [...templateParts.get(t).aliases]));
35969
+ const droppedPages = new Set([...dropped].flatMap(t => [...templateParts.get(t).pages]));
35970
+ // Routes and names: the template's frame first, then the lists, then the pages.
35971
+ const kept = template.pages.filter(p => p.isHome || p.archetype === CONTACT_ARCHETYPE || (!droppedPages.has(p.key) && matched && templateParts.get(matched.type.name).pages.has(p.key)));
35972
+ const routes = new Names(kept.map(p => p.route));
35973
+ const keys = new Names(kept.map(p => p.key));
35974
+ const typeNames = new Names(template.contentTypes.map(t => t.name));
35975
+ const aliases = new Names(template.dataSources.map(d => d.alias));
35976
+ const listPages = [];
35977
+ const firstLatest = [];
35978
+ if (matched) {
35979
+ const listPage = template.pages.find(p => templateParts.get(matched.type.name).pages.has(p.key) && !p.template);
35980
+ const latest = template.dataSources.find(d => templateParts.get(matched.type.name).aliases.has(d.alias) && d.type === PlanDataSourceType.Cms && d.mode === PlanDataSourceMode.Query && d.limit);
35981
+ if (listPage && latest)
35982
+ firstLatest.push({ alias: latest.alias, route: listPage.route });
35983
+ }
35984
+ const typeOfMatched = matched ? contentTypes[0] : null;
35985
+ for (const list of lists) {
35986
+ if (list === matched?.list)
35987
+ continue;
35988
+ const name = typeNames.claim(camel(importSlug(list.key) || importSlug(list.label) || 'items'), '');
35989
+ const type = ownType(name, list);
35990
+ const own = ownSources(name);
35991
+ if ([own.list, own.latest, own.item, `${name}Next`].some(a => aliases.has(a)))
35992
+ continue; // never shadow a source
35993
+ own.sources.forEach(s => aliases.claim(s.alias));
35994
+ contentTypes.push(type);
35995
+ dataSources.push(...own.sources);
35996
+ const base = routeOfPath(list.path);
35997
+ const route = routes.claim(base && !routes.has(base) && base !== HOME_ROUTE ? base : `/${importSlug(list.label) || name.toLowerCase()}`);
35998
+ routes.claim(`${route}/:${ITEM_PARAM}`);
35999
+ const key = keys.claim(importSlug(list.label) || name.toLowerCase());
36000
+ listPages.push({
36001
+ key, name: list.label, route, inNav: true, archetype: COLLECTION_ARCHETYPE,
36002
+ sections: [pageHeader(list.label), { pattern: ImportPattern.CardGrid, binding: own.list, without: [...WITHOUT.cardGridHeader] }],
36003
+ });
36004
+ listPages.push({
36005
+ key: keys.claim(`${key}-item`), name: list.label, route: `${route}/:${ITEM_PARAM}`, inNav: false,
36006
+ template: name, routeSource: own.item, archetype: DETAIL_ARCHETYPE, sections: itemSections(type, list.label),
36007
+ });
36008
+ firstLatest.push({ alias: own.latest, route });
36009
+ }
36010
+ // The template's frame: a section that showed a dropped type shows the first list instead, or goes.
36011
+ const frame = [];
36012
+ for (const page of kept) {
36013
+ const sections = [];
36014
+ for (const section of page.sections) {
36015
+ if (!section.binding || !droppedAliases.has(section.binding)) {
36016
+ sections.push(section);
36017
+ continue;
36018
+ }
36019
+ const first = firstLatest[0];
36020
+ if (first)
36021
+ sections.push({ ...section, binding: first.alias, links: { ...(section.links ?? {}), more: first.route } });
36022
+ }
36023
+ // The template type's item page shows the items' own text after its hero.
36024
+ const body = page.template && typeOfMatched && page.template === typeOfMatched.name && roleField(typeOfMatched, ContentRole.Body)
36025
+ && !sections.some(s => s.pattern === ImportPattern.ItemBody);
36026
+ if (body)
36027
+ sections.splice(Math.max(1, sections.findIndex(s => s.pattern === ImportPattern.ItemHero) + 1), 0, { pattern: ImportPattern.ItemBody });
36028
+ frame.push({ ...page, sections });
36029
+ }
36030
+ // The owner's pages of words.
36031
+ const textPages = [];
36032
+ for (const page of reading.pages) {
36033
+ const text = page.text.trim();
36034
+ const title = page.title.trim();
36035
+ if (!text || !title)
36036
+ continue;
36037
+ const base = routeOfPath(page.path);
36038
+ if (!base || base === HOME_ROUTE)
36039
+ continue; // the home page is rebuilt from the template
36040
+ if (routes.has(base) && frame.some(p => p.route === base))
36041
+ continue; // the template's contact page stands for it
36042
+ const route = routes.claim(base);
36043
+ textPages.push({
36044
+ key: keys.claim(importSlug(base.slice(1)) || importSlug(title) || 'page'), name: title, route, inNav: route.split('/').length === 2,
36045
+ archetype: ABOUT_ARCHETYPE,
36046
+ sections: [pageHeader(title, page.description?.trim() || undefined), { pattern: ImportPattern.LongForm, slots: { body1: text }, without: [...WITHOUT.longForm] }],
36047
+ });
36048
+ }
36049
+ // The header lists the lists first, then the pages, the contact page last — at most IMPORT_NAV_MAX.
36050
+ const home = frame.filter(p => p.isHome);
36051
+ const contact = frame.filter(p => !p.isHome && p.archetype === CONTACT_ARCHETYPE);
36052
+ const rest = frame.filter(p => !p.isHome && p.archetype !== CONTACT_ARCHETYPE);
36053
+ let room = IMPORT_NAV_MAX - contact.filter(p => p.inNav).length;
36054
+ const nav = (page) => {
36055
+ if (!page.inNav)
36056
+ return page;
36057
+ if (room > 0) {
36058
+ room--;
36059
+ return page;
36060
+ }
36061
+ return { ...page, inNav: false };
36062
+ };
36063
+ const pages = [...home, ...rest.map(nav), ...listPages.map(nav), ...textPages.map(nav), ...contact];
36064
+ return {
36065
+ version: SITE_PLAN_VERSION,
36066
+ source: { kind: SitePlanSourceKind.Import, scanId: reading.scanId },
36067
+ business: JSON.parse(JSON.stringify(reading.business)),
36068
+ ...(reading.locale ? { locale: reading.locale } : {}),
36069
+ design: JSON.parse(JSON.stringify(input.design)),
36070
+ contentTypes,
36071
+ dataSources: JSON.parse(JSON.stringify(dataSources)),
36072
+ pages: JSON.parse(JSON.stringify(pages)),
36073
+ globals: JSON.parse(JSON.stringify(template.globals)),
36074
+ };
36178
36075
  }
36179
36076
 
36180
36077
  /**
36181
- * The plan WIRE (AI plan M1-3, vectoriox/iox-cms#45, #47): what a model writes when it plans a site — a compact format
36182
- * inside the Claude API's structured-output limits (≤ 24 optional parameters and ≤ 16 unions per request, and a compiled
36183
- * grammar under the size Claude refuses — measured as ≤ 60 properties; `strict-schema.ts`). The Site Plan itself
36184
- * (`SPEC_SITE_PLAN_SHAPE`) has 213 optional keys once every pattern is a branch, so the model never writes it: it writes
36185
- * this, and ONE pure `expandPlanWire` turns it into the Site Plan that `validateSitePlan` and the stage's gate judge
36186
- * exactly as before.
36187
- *
36188
- * - **Written in two PARTS, one request each** (#47 — the whole plan in one format was 64 properties): the **structure** (the business,
36189
- * the content types, the data sources) and then the **pages** (the pages, the header and footer), written knowing the
36190
- * structure. Every top-level key belongs to exactly one part (`part` below); `expandPlanWire` puts the parts together.
36191
- *
36192
- * - **Every key required.** A plan key that may be absent is written with its stated "none" — `''`, `0`, `false`, `[]`.
36193
- * - **Closed lists as enums** (patterns, page types, needs, slots, parts, forms, entrances, header/footer), from the
36194
- * contract — never per-pattern branches: the gate refuses a slot or a part the chosen pattern does not have, with its path.
36195
- * - **Maps as lists:** slots `[{ slot, text }]`, links `[{ slot, route }]`, seed values `[{ field, value }]`, roles `[{ role, field }]`.
36196
- * - **One data source object** for both kinds; `type` says which keys are read (the other kind's hold their none).
36197
- * - **What the model does not decide is not on the wire** (`PLAN_WIRE_DERIVED`): the look (the owner's pick), the run,
36198
- * the language (the reading's), the facts (the owner's own, verbatim), the version, the home page (the page at `/`).
36199
- * So the format is the same for every studio and every run — one compiled grammar, cached by the provider.
36200
- * - **What follows from the pages is derived, never asked** (`plan-derived.ts`, vectoriox/iox-cms#49): a per-item page
36201
- * reading the next item gets its `$siblings.next` source — the structure, asked first and then fixed, cannot know the
36202
- * pages need it, and the pages cannot add a source. `planToWire` writes every source the plan holds, a derived one
36203
- * too (it is the plan's: a change's brief shows it, and a plan → wire → plan round trip stays exact).
36204
- *
36205
- * ONE source: every wire key names the plan keys it carries (`refs`) and is described in the plan table's own words, and
36206
- * every plan key is either carried or derived (`planWireGaps()`); a key the plan shape gains breaks the builder until it
36207
- * is placed. The expanders translate, never repair: a value the model got wrong stays wrong, for the gate to refuse.
36208
- */
36209
- /** The plan's parts, in the order they are written: the pages bind to the structure's sources and types. */
36210
- var PlanPart;
36211
- (function (PlanPart) {
36212
- PlanPart["Structure"] = "structure";
36213
- PlanPart["Pages"] = "pages";
36214
- })(PlanPart || (PlanPart = {}));
36215
- const PLAN_PARTS = [PlanPart.Structure, PlanPart.Pages];
36216
- /** Each part's format name (a request names the format it asks for). */
36217
- const PLAN_WIRE_PART_SCHEMA_NAMES = {
36218
- [PlanPart.Structure]: 'site_plan_structure',
36219
- [PlanPart.Pages]: 'site_plan_pages',
36220
- };
36221
- var PlanWireEntry;
36222
- (function (PlanWireEntry) {
36223
- PlanWireEntry["Plan"] = "plan";
36224
- PlanWireEntry["Business"] = "business";
36225
- PlanWireEntry["ContentType"] = "contentType";
36226
- PlanWireEntry["RoleField"] = "roleField";
36227
- PlanWireEntry["Field"] = "field";
36228
- PlanWireEntry["Seed"] = "seed";
36229
- PlanWireEntry["SeedValue"] = "seedValue";
36230
- PlanWireEntry["DataSource"] = "dataSource";
36231
- PlanWireEntry["Page"] = "page";
36232
- PlanWireEntry["PageSeo"] = "pageSeo";
36233
- PlanWireEntry["Section"] = "section";
36234
- PlanWireEntry["SlotText"] = "slotText";
36235
- PlanWireEntry["SlotLink"] = "slotLink";
36236
- PlanWireEntry["Globals"] = "globals";
36237
- PlanWireEntry["Direction"] = "direction";
36238
- /** Commerce C-D21: one product the business sells, by name. */
36239
- PlanWireEntry["ShopProduct"] = "shopProduct";
36240
- PlanWireEntry["ShopOption"] = "shopOption";
36241
- })(PlanWireEntry || (PlanWireEntry = {}));
36242
- const PLAN_SHAPE = SPEC_SITE_PLAN_SHAPE;
36243
- const key = (ref, none) => ({ refs: [ref], ...(none !== undefined ? { none } : {}) });
36244
- const inPart = (part, spec) => ({ ...spec, part });
36245
- /** The roles a content type's fields play (`roles` of the plan shape), in the plan shape's order — less the item page's
36246
- * own (X4 `ITEM_PAGE_ONLY_ROLES`: an imported item's text is never the model's to write). */
36247
- const ROLE_KEYS = shapeKeys(PLAN_SHAPE['roles']).filter(role => !ITEM_PAGE_ONLY_ROLES.includes(role));
36248
- const roleWords = ROLE_KEYS.map(role => `${role}: ${describeShapeKey(PLAN_SHAPE['roles'], role).replace(/^string — /, '')}`).join('; ');
36249
- /** The footer's words as the model reads them (LI5): each ingredient, its words and their meanings, from the contract. */
36250
- const FOOTER_WIRE_TEXT = 'string[] — the footer as ONE list of <ingredient>:<word> words: one word per ingredient but "holds", which lists '
36251
- + `each block it holds (holds:pages, holds:contact); an ingredient left out is the default (${footerMixWords(footerMix()).join(', ')}). `
36252
- + Object.values(FooterIngredient).map(k => `${k}: ${footerWords(k).map(w => `${w} (${footerMeaning(k, w)})`).join(' | ')}`).join('; ');
36253
- /** The wire's `globals` key the home page's opening travels in (AW8) — a mix beside the header's and the footer's. */
36254
- const OPENING_WIRE_KEY = 'opening';
36255
- /** The opening's words as the model reads them (AW8): each ingredient, the words the product draws, their meanings and
36256
- * which the award plan alone wears, from the contract's opening table. */
36257
- const OPENING_WIRE_TEXT = "string[] — the home page's opening (its first screen) as ONE list of <ingredient>:<word> words: one word per "
36258
- + `ingredient but extras and motion, which list each they take; an ingredient left out is the default; [] = the home page opens with its first `
36259
- + "section as written. The opening takes the place of the home page's first section when that is a hero (its words and pictures carried in); "
36260
- + 'a word marked (award) is worn by an award build only — elsewhere it is mended. '
36261
- + Object.values(OpeningIngredient).map(k => `${k}: ${openingWireWords(GenerationTier.Award).filter(w => w.startsWith(`${k}:`)).map(w => w.slice(k.length + 1))
36262
- .map(w => `${w} (${openingMeaning(k, w)}${openingWordTier(k, w) === 'pro' ? ', award' : ''}${openingHarnessWord(k, w) ? ', the build\'s own — keep it where the plan has it, never choose it' : ''})`).join(' | ')}`).join('; ');
36263
- /** The header's words as the model reads them (HI1): each ingredient, the words the product draws and their meanings,
36264
- * from the contract's header table. */
36265
- const HEADER_WIRE_TEXT = 'string[] — the header as ONE list of <ingredient>:<word> words, one word per ingredient; an ingredient left out is the '
36266
- + `default (${headerMixWords(headerMix()).join(', ')}). The site decides what it can carry: a menu needs three pages or more, the pages in the bar must fit `
36267
- + 'beside the name, pages either side of the name need a short name, two actions need a shop. '
36268
- + Object.values(HeaderIngredient).map(k => `${k}: ${headerWireWords().filter(w => w.startsWith(`${k}:`)).map(w => w.slice(k.length + 1)).map(w => `${w} (${headerMeaning(k, w)})`).join(' | ')}`).join('; ');
36269
- /** The wire's `globals` key the site's body travels in (AW6) — the award tier's alone (AW-D23…D25). */
36270
- const BODY_WIRE_KEY = 'body';
36271
- /** The body's words as the model reads them (AW6): each ingredient, the words an award build may wear today and their
36272
- * meanings, from the contract's body table. */
36273
- const BODY_WIRE_TEXT = "string[] — the site's body as ONE list of <ingredient>:<word> words: how its sections meet and how their grounds "
36274
- + `follow one another; one word per ingredient but sections, which lists each extra kind it takes; an ingredient left out is the default `
36275
- + `(${bodyMixWords(bodyMix()).join(', ')}); [] = straight edges, each section's ground its own. An edge shows only where two neighbouring `
36276
- + 'sections wear different grounds; a calm business (care, advice) never wears a torn or dripping edge. '
36277
- + Object.values(BodyIngredient).map(k => [k, bodyWireWords(GenerationTier.Award).filter(w => w.startsWith(`${k}:`)).map(w => w.slice(k.length + 1))])
36278
- .filter(([, words]) => words.length)
36279
- .map(([k, words]) => `${k}: ${words.map(w => `${w} (${bodyMeaning(k, w)})`).join(' | ')}`).join('; ');
36280
- /** The wire's `globals` key the site's popup travels in (popups PU3) — a mix beside the others; [] = no popup. */
36281
- const POPUP_WIRE_KEY = 'popup';
36282
- /** The popup's words as the model reads them (PU3): each ingredient the wire carries, its words and their meanings, from the
36283
- * contract's popup table; the link names a page of this plan. Text items: a page key is the plan's own word, never a list. */
36284
- const POPUP_WIRE_TEXT = "string[] — the site's popup as ONE list of <ingredient>:<word> words, ONLY when the owner's popup lines ask for one "
36285
- + "(the context says so): [] otherwise. Never a word of copy — the popup says the owner's news as stated. One word per ingredient; "
36286
- + 'an ingredient left out is the kind\'s own. '
36287
- + POPUP_WIRE_INGREDIENTS.map(k => `${k}: ${popupWireWords().filter(w => w.startsWith(`${k}:`)).map(w => w.slice(k.length + 1))
36288
- .map(w => `${w} (${popupMeaning(k, w)})`).join(' | ')}`).join('; ')
36289
- + `; ${POPUP_LINK_WORD}:<page key> — the page of this plan the popup's one action opens (the offer's page if there is one; never the home page).`;
36290
- const WIRE_KEYS = {
36291
- plan: {
36292
- business: inPart(PlanPart.Structure, key('plan.business')),
36293
- contentTypes: inPart(PlanPart.Structure, key('plan.contentTypes')),
36294
- dataSources: inPart(PlanPart.Structure, { refs: ['plan.dataSources'], text: "dataSource[] — merged by alias into the org library; a per-item page's $siblings.next source (what a section reading the next item needs) is added for you, and so are the shop's sources when the business sells" }),
36295
- shop: inPart(PlanPart.Structure, {
36296
- refs: ['plan.shop', 'shop.products'],
36297
- text: `shopProduct[] — what the business sells, when it sells (the need "products"): at most 6 sample products by name, each in a category — never a price, stock or a fee. [] = it sells nothing. Its categories, the shop's data sources (the products, the newest, one product by its :slug) and the store's parts are added for you`,
36298
- }),
36299
- pages: inPart(PlanPart.Pages, key('plan.pages')),
36300
- globals: inPart(PlanPart.Pages, key('plan.globals')),
36301
- direction: inPart(PlanPart.Pages, key('plan.direction')),
36302
- },
36303
- direction: {
36304
- idea: key('direction.idea'),
36305
- cliche: key('direction.cliche'),
36306
- flip: key('direction.flip'),
36307
- rules: key('direction.rules'),
36308
- },
36309
- business: {
36310
- name: key('business.name'),
36311
- tagline: key('business.tagline', "''"),
36312
- },
36313
- contentType: {
36314
- name: key('contentType.name'),
36315
- label: key('contentType.label'),
36316
- roles: { refs: ['contentType.roles'], text: `roleField[] — ${describeShapeKey(PLAN_SHAPE['contentType'], 'roles').replace(/^roles — /, '')}; a role no field plays is left out` },
36317
- fields: key('contentType.fields'),
36318
- seed: { refs: ['contentType.seed'], text: 'seed — the sample items', none: 'count 0 and no values' },
36319
- },
36320
- roleField: {
36321
- role: { refs: ROLE_KEYS.map(role => `roles.${role}`), text: `${ROLE_KEYS.map(r => `'${r}'`).join(' | ')} — ${roleWords}` },
36322
- field: { refs: ['roles.title'], text: 'string — the field of the type that plays it' },
36323
- },
36324
- field: {
36325
- name: key('field.name'),
36326
- controller: { refs: ['field.controller'], text: `one of ${Object.values(ContentFieldControl).join(', ')} — how the field is edited (gallery is a list of pictures, list a list of words); how it is stored follows from this` },
36327
- required: { refs: ['field.required'], text: 'boolean — the field must be filled', none: 'false' },
36328
- note: key('field.note', "''"),
36329
- },
36330
- seed: {
36331
- count: key('seed.count'),
36332
- sample: key('seed.sample'),
36333
- isPublished: key('seed.isPublished'),
36334
- values: { refs: ['seed.[field]'], text: "seedValue[] — one per field, for EVERY field: the samples' value for it, with {n} for the sample's number and {sampleImage:n} for a picture, words a person replaces" },
36335
- },
36336
- seedValue: {
36337
- field: { refs: ['seed.[field]'], text: 'string — a field of the type' },
36338
- value: { refs: ['seed.[field]'], text: `string | string[] — ${describeShapeKey(PLAN_SHAPE['seed'], '[field]')} (a list for an array field)` },
36339
- each: { refs: ['seed.perItem'], text: 'string[] — one value per sample, in order, when each sample has its own content', none: '[]' },
36340
- },
36341
- dataSource: {
36342
- alias: { refs: ['cmsDataSource.alias', 'relativeDataSource.alias', 'shopDataSource.alias'] },
36343
- type: { refs: ['cmsDataSource.type', 'relativeDataSource.type', 'shopDataSource.type'], text: "'cms' | 'relative' | 'shop' — which of the keys below are read ('shop' sources are added for you)" },
36344
- mode: { refs: ['cmsDataSource.mode', 'shopDataSource.mode'], none: "'' (relative)" },
36345
- contentType: { refs: ['cmsDataSource.contentType', 'shopDataSource.resource'], text: "string — a content type of the plan (cms); the shop's list, 'products' or 'categories' (shop)", none: "'' (relative)" },
36346
- limit: { refs: ['cmsDataSource.limit', 'shopDataSource.limit'], none: '0 (all, or relative)' },
36347
- filterField: { refs: ['cmsDataSource.filterByRouteParam', 'shopDataSource.filterByRouteParam'], text: "string — single only: the field that holds the route param's value (e.g. slug)", none: "''" },
36348
- routeParam: { refs: ['cmsDataSource.filterByRouteParam', 'shopDataSource.filterByRouteParam'], text: 'string — single only: the route param that picks the item (the :param of its page route)', none: "''" },
36349
- of: key('relativeDataSource.of', "'' (cms)"),
36350
- op: key('relativeDataSource.op', "'' (cms)"),
36351
- within: key('relativeDataSource.within', "'' (cms)"),
36352
- },
36353
- page: {
36354
- key: key('page.key'),
36355
- name: key('page.name'),
36356
- route: { refs: ['page.route'], text: `${describeShapeKey(PLAN_SHAPE['page'], 'route')}; the page at "/" is the home page` },
36357
- inNav: key('page.inNav', 'false'),
36358
- archetype: key('page.archetype', "''"),
36359
- need: key('page.need', "''"),
36360
- template: key('page.template', "''"),
36361
- routeSource: key('page.routeSource', "''"),
36362
- seo: key('page.seo'),
36363
- sections: key('page.sections'),
36364
- compose: key('page.compose', 'false'),
36365
- },
36366
- pageSeo: {
36367
- title: key('pageSeo.title', "''"),
36368
- description: key('pageSeo.description', "''"),
36369
- },
36370
- section: {
36371
- pattern: key('section.pattern'),
36372
- slots: { refs: ['section.slots'], text: "slotText[] — the pattern's declared slots it fills, each within its budget (site.patterns … max × site.copyLengths)", none: '[]' },
36373
- links: { refs: ['section.links'], text: 'slotLink[] — re-points a linked slot (a button, a link) to another page route of the plan', none: '[]' },
36374
- binding: key('section.binding', "''"),
36375
- without: key('section.without', '[]'),
36376
- form: key('section.form', "''"),
36377
- enter: key('section.enter', "'' (the look's)"),
36378
- },
36379
- slotText: {
36380
- slot: { refs: ['section.slots'], text: "string — one of the pattern's slots" },
36381
- text: { refs: ['section.slots'], text: "string — the words, in the owner's language and voice" },
36382
- },
36383
- slotLink: {
36384
- slot: { refs: ['section.links'], text: "string — one of the pattern's linked slots" },
36385
- route: { refs: ['section.links'], text: 'string — a page route of the plan (no :param)' },
36386
- },
36387
- globals: {
36388
- // HI1: the header travels as its MIX — like the footer, ONE list of `<ingredient>:<word>` words (header-mix.ts).
36389
- header: { refs: ['globals.header', 'plan.mixes', 'mixes.header'], text: HEADER_WIRE_TEXT },
36390
- // LI5: the footer travels as its MIX — ONE list of `<ingredient>:<word>` words (footer-mix.ts), every word with its
36391
- // meaning from the contract's footer table; the plan keeps the pattern it reads as (`globals.footer`) and the mix.
36392
- footer: { refs: ['globals.footer', 'plan.mixes', 'mixes.footer'], text: FOOTER_WIRE_TEXT },
36393
- // AW8: the home page's opening travels as its MIX, ONE list of `<ingredient>:<word>` words (opening-mix.ts); [] = none.
36394
- opening: { refs: ['plan.mixes', 'mixes.opening'], text: OPENING_WIRE_TEXT },
36395
- // AW6: the site's body travels as its MIX, ONE list of `<ingredient>:<word>` words (body-mix.ts); [] = none. The award
36396
- // tier's request alone carries it (AW-D23…D25): a Basic wire is without the key, so its grammar is the one it was.
36397
- body: { refs: ['plan.mixes', 'mixes.body'], text: BODY_WIRE_TEXT, tier: GenerationTier.Award },
36398
- // PU3: the popup travels as its words, ONE list (popup-plan.ts); [] = none. Stamped only from the owner's lines (plan.popup).
36399
- popup: { refs: ['plan.mixes', 'mixes.popup'], text: POPUP_WIRE_TEXT },
36400
- },
36401
- shopProduct: {
36402
- name: key('shopProduct.name'),
36403
- category: key('shopProduct.category'),
36404
- description: key('shopProduct.description'),
36405
- options: key('shopProduct.options'),
36406
- },
36407
- shopOption: {
36408
- name: key('shopOption.name'),
36409
- values: key('shopOption.values'),
36410
- },
36411
- };
36412
- /** The plan keys the model does not write, and where the expander takes each from. */
36413
- const PLAN_WIRE_DERIVED = {
36414
- 'field.type': 'follows from the field\'s control (FIELD_TYPE_OF_CONTROL)',
36415
- 'plan.version': `always '${SITE_PLAN_VERSION}'`,
36416
- 'plan.source': 'this run (the context)',
36417
- 'plan.locale': "the reading's language (the context)",
36418
- 'plan.design': "the owner's pick (the context)",
36419
- 'business.facts': "the owner's own facts, verbatim (the context)",
36420
- 'page.isHome': 'the page at "/"',
36421
- 'page.required': "a template page's (the wizard's Pages step), never the AI's",
36422
- sourceTemplate: 'the AI never writes a template plan',
36423
- sourceAi: 'this run (the context)',
36424
- sourceImport: 'the AI never writes an import plan (Bring my site X4 — planImport)',
36425
- 'roles.body': "an imported item's own text (Bring my site X4) — never the model's",
36426
- 'seed.importedFrom': 'the old addresses of real items read from a site (Bring my site X4) — never the model\'s',
36427
- design: "the owner's pick (the context)",
36428
- 'plan.film': "the owner's film, set by the build (SC6b)",
36429
- film: "the owner's film, set by the build (SC6b)",
36430
- 'plan.artDirection': 'the generation, from the business type and the look (M7 — artDirectionFor)',
36431
- artDirection: 'the generation, from the business type and the look (M7 — artDirectionFor)',
36432
- 'page.layout': 'the layout step: one request per composed page, after the pages (M8 gate 2)',
36433
- 'shop.categories': "the products' own categories, in order (shopCategoriesOf)",
36434
- layoutPage: 'the layout step: one request per composed page, after the pages (M8 gate 2)',
36435
- 'page.free': 'the free step: a page the model writes free, on its own wire, set by the server (FS3)',
36436
- 'section.free': 'the free step: one signature section written free, set by the server (FS3, FS-D19)',
36437
- freePage: 'the free step: a page the model writes free, on its own wire, set by the server (FS3)',
36438
- freeRead: 'the free step (FS3)',
36439
- freeNode: 'the free step (FS3)',
36440
- 'plan.popup': "the owner's popup lines: the reading's stated news and the Plan step's ticks (the context, popups PU3)",
36441
- popupLines: "the owner's popup lines (the context, popups PU3)",
36442
- statedFact: "the reading's stated fact (the context, popups PU3)",
36443
- };
36444
- const wireText = (spec) => {
36445
- const [entry, planKey] = spec.refs[0].split('.');
36446
- const base = spec.text ?? describeShapeKey(PLAN_SHAPE[entry], planKey);
36447
- return spec.none === undefined ? base : `${base} — ${spec.none} = none`;
36448
- };
36449
- const isAward = (options) => options.tier === GenerationTier.Award;
36450
- /** Is a wire key on the request asked at `options`? (A key with no tier is on every request.) */
36451
- const asked = (spec, options) => !spec.tier || (spec.tier === GenerationTier.Award && isAward(options));
36452
- const wireShapeAt = (options) => Object.fromEntries(Object.entries(WIRE_KEYS).map(([entry, keys]) => [entry, Object.fromEntries(Object.entries(keys).filter(([, spec]) => asked(spec, options)).map(([k, spec]) => [k, wireText(spec)]))]));
36453
- /** The wire's shape table, in the plan table's words — what the model reads, and what the format is built from. The
36454
- * Basic tier's (every tier's but the award's); `planWireShape(options)` gives a tier's own. */
36455
- const PLAN_WIRE_SHAPE = wireShapeAt({});
36456
- const AWARD_WIRE_SHAPE = wireShapeAt({ tier: GenerationTier.Award });
36457
- /** The wire's shape table a request at `options` reads (AW6: the award tier's carries the body). Basic = `PLAN_WIRE_SHAPE`. */
36458
- function planWireShape(options = {}) {
36459
- return isAward(options) ? AWARD_WIRE_SHAPE : PLAN_WIRE_SHAPE;
36460
- }
36461
- /** Each part's top-level keys, from the ONE wire table. */
36462
- const PLAN_PART_KEYS = Object.fromEntries(PLAN_PARTS.map(part => [part, Object.entries(WIRE_KEYS.plan).filter(([, spec]) => spec.part === part).map(([k]) => k)]));
36463
- /** The keys of a shape entry, but these. */
36464
- const shapeWithout = (entry, keys) => Object.fromEntries(Object.entries(entry).filter(([k]) => !keys.includes(k.replace(/\?$/, ''))));
36465
- /**
36466
- * The part a plan path is the answer of (`contentTypes[1].seed.title` → structure, `pages[0].sections[2]` → pages). A
36467
- * path no part writes — the root (the composer), or a key the generation decides — is the LAST part's: it is written
36468
- * knowing everything before it.
36469
- */
36470
- function planPartOfPath(path) {
36471
- const top = path.split(/[.[]/, 1)[0];
36472
- return PLAN_PARTS.find(part => PLAN_PART_KEYS[part].includes(top)) ?? PLAN_PARTS[PLAN_PARTS.length - 1];
36473
- }
36474
- /** Plan keys neither carried by a wire key nor derived — always empty (a spec and the builder hold it). */
36475
- function planWireGaps() {
36476
- const carried = new Set(Object.values(WIRE_KEYS).flatMap(keys => Object.values(keys).flatMap(spec => spec.refs)));
36477
- const gaps = [];
36478
- for (const [entry, shape] of Object.entries(PLAN_SHAPE)) {
36479
- if (PLAN_WIRE_DERIVED[entry])
36480
- continue;
36481
- for (const raw of Object.keys(shape)) {
36482
- const ref = `${entry}.${raw.replace(/\?$/, '')}`;
36483
- if (!carried.has(ref) && !PLAN_WIRE_DERIVED[ref])
36484
- gaps.push(ref);
36485
- }
36486
- }
36487
- return gaps;
36488
- }
36489
- class PlanWireShapeError extends Error {
36490
- }
36491
- // ── The format ─────────────────────────────────────────────────────────────────────────────────────────────────────
36492
- const unique = (values) => [...new Set(values)];
36493
- const NONE = '';
36494
- const orNone = (values) => jsonOneOf([NONE, ...values]);
36495
- const closedOrText = (values) => (values.length ? jsonOneOf(values) : jsonText());
36496
- const shaped = (entry, properties) => jsonShapedObject(PLAN_WIRE_SHAPE[entry], properties, `wire ${entry}`);
36497
- /** The patterns a page section may use (every non-global one but a film's, which `placeFilm` places), in library order. */
36498
- function sectionPatternIds() {
36499
- return Object.entries(SITE_PATTERNS).filter(([, p]) => !p.global && !p.film && !p.imported).map(([id]) => id);
36500
- }
36501
- const sectionPatterns = () => sectionPatternIds().map(id => SITE_PATTERNS[id]);
36502
- function wireFieldJsonSchema() {
36503
- return shaped(PlanWireEntry.Field, { name: jsonText(), controller: jsonOneOf(Object.values(ContentFieldControl)), required: jsonBoolean(), note: jsonText() });
36504
- }
36505
- /** The keys an entry leaves out under `options`. */
36506
- const CHILD_KEYS = { contentType: 'fields', page: 'sections' };
36507
- const childless = (entry, options) => (options.children === false && CHILD_KEYS[entry] ? [CHILD_KEYS[entry]] : []);
36508
- /** The shape an entry is written in, under `options`. */
36509
- function wireEntryShape(entry, options = {}) {
36510
- return shapeWithout(PLAN_WIRE_SHAPE[entry], childless(entry, options));
36511
- }
36512
- const shapedAs = (entry, options, properties) => {
36513
- const left = childless(entry, options);
36514
- return jsonShapedObject(wireEntryShape(entry, options), Object.fromEntries(Object.entries(properties).filter(([k]) => !left.includes(k))), `wire ${entry}`);
36515
- };
36516
- function wireContentTypeJsonSchema(options = {}) {
36517
- const value = shaped(PlanWireEntry.SeedValue, { field: jsonText(), value: jsonAnyOf([jsonText(), jsonListOf(jsonText())]), each: jsonListOf(jsonText()) });
36518
- return shapedAs(PlanWireEntry.ContentType, options, {
36519
- name: jsonText(),
36520
- label: jsonText(),
36521
- roles: jsonListOf(shaped(PlanWireEntry.RoleField, { role: jsonOneOf(ROLE_KEYS), field: jsonText() })),
36522
- fields: jsonListOf(wireFieldJsonSchema()),
36523
- seed: shaped(PlanWireEntry.Seed, { count: jsonInteger(), sample: jsonBoolean(), isPublished: jsonBoolean(), values: jsonListOf(value) }),
36524
- });
36525
- }
36526
- function wireDataSourceJsonSchema() {
36527
- return shaped(PlanWireEntry.DataSource, {
36528
- alias: jsonText(),
36529
- type: jsonOneOf(Object.values(PlanDataSourceType)),
36530
- mode: orNone(Object.values(PlanDataSourceMode)),
36531
- contentType: jsonText(),
36532
- limit: jsonInteger(),
36533
- filterField: jsonText(),
36534
- routeParam: jsonText(),
36535
- of: jsonText(),
36536
- op: orNone(Object.values(RelativeOp)),
36537
- within: jsonText(),
36538
- });
36539
- }
36540
- function wireSectionJsonSchema() {
36541
- const patterns = sectionPatterns();
36542
- return shaped(PlanWireEntry.Section, {
36543
- pattern: jsonOneOf(sectionPatternIds()),
36544
- slots: jsonListOf(shaped(PlanWireEntry.SlotText, { slot: closedOrText(unique(patterns.flatMap(patternSlots))), text: jsonText() })),
36545
- links: jsonListOf(shaped(PlanWireEntry.SlotLink, { slot: closedOrText(unique(patterns.flatMap(patternLinkSlots))), route: jsonText() })),
36546
- binding: jsonText(),
36547
- without: jsonListOf(closedOrText(unique(patterns.flatMap(patternOptionalParts)))),
36548
- form: orNone(planFormPresetIds()),
36549
- enter: orNone(ANIMATE_IDS),
36550
- });
36551
- }
36552
- function wirePageJsonSchema(options = {}) {
36553
- return shapedAs(PlanWireEntry.Page, options, {
36554
- key: jsonText(),
36555
- name: jsonText(),
36556
- route: jsonText(),
36557
- inNav: jsonBoolean(),
36558
- archetype: orNone(Object.keys(PAGE_ARCHETYPES)),
36559
- need: orNone(SITE_NEED_IDS),
36560
- template: jsonText(),
36561
- routeSource: jsonText(),
36562
- seo: shaped(PlanWireEntry.PageSeo, { title: jsonText(), description: jsonText() }),
36563
- sections: jsonListOf(wireSectionJsonSchema()),
36564
- compose: jsonBoolean(),
36565
- });
36566
- }
36567
- const PLAN_TOP_SCHEMAS = {
36568
- business: () => shaped(PlanWireEntry.Business, { name: jsonText(), tagline: jsonText() }),
36569
- contentTypes: () => jsonListOf(wireContentTypeJsonSchema()),
36570
- dataSources: () => jsonListOf(wireDataSourceJsonSchema()),
36571
- pages: () => jsonListOf(wirePageJsonSchema()),
36572
- globals: options => jsonShapedObject(planWireShape(options).globals, {
36573
- [GlobalSlot.Header]: jsonListOf(jsonOneOf(headerWireWords())),
36574
- [GlobalSlot.Footer]: jsonListOf(jsonOneOf(footerWireWords())),
36575
- [OPENING_WIRE_KEY]: jsonListOf(jsonOneOf(openingWireWords(GenerationTier.Award))),
36576
- ...(isAward(options) ? { [BODY_WIRE_KEY]: jsonListOf(jsonOneOf(bodyWireWords(GenerationTier.Award))) } : {}),
36577
- [POPUP_WIRE_KEY]: jsonListOf(jsonText()),
36578
- }, `wire ${PlanWireEntry.Globals}`),
36579
- direction: () => shaped(PlanWireEntry.Direction, { idea: jsonText(), cliche: jsonText(), flip: jsonText(), rules: jsonListOf(jsonText()) }),
36580
- shop: () => jsonListOf(wireShopProductJsonSchema()),
36581
- };
36582
- /** Commerce C-D21: one product the business sells, as the structure writes it — never a price, stock or a fee. */
36583
- function wireShopProductJsonSchema() {
36584
- return shaped(PlanWireEntry.ShopProduct, {
36585
- name: jsonText(), category: jsonText(), description: jsonText(),
36586
- options: jsonListOf(shaped(PlanWireEntry.ShopOption, { name: jsonText(), values: jsonListOf(jsonText()) })),
36587
- });
36588
- }
36589
- /** The plan's top-level shape for one part (its keys only) — what that part's request shows and is built from. */
36590
- function planWirePartShape(part, options = {}) {
36591
- return Object.fromEntries(Object.entries(planWireShape(options).plan).filter(([k]) => PLAN_PART_KEYS[part].includes(k)));
36592
- }
36593
- /**
36594
- * The format a model writes one part of a plan in — one request each (vectoriox/iox-cms#47). The same for every studio
36595
- * and run at a tier: nothing in it is pinned, so the provider compiles each part's grammar once per tier (AW6: the award
36596
- * tier's Pages part adds `globals.body`; every other tier's is the format it always was, byte for byte).
36078
+ * A site build's WIRE vocabulary (AI plan §3b, W2): what iox-cms's `site-builds` API answers and what every
36079
+ * client of it reads — the run's statuses and steps, what it created, why Undo kept something, the preflight's
36080
+ * refusals, and the one spelling of each document's `buildKey`. ONE definition: iox-cms stores and answers it,
36081
+ * the website wizard (W3) polls it. Pure types, enums and helpers; no transport.
36597
36082
  */
36598
- function planWirePartJsonSchema(part, options = {}) {
36599
- const gaps = planWireGaps();
36600
- if (gaps.length)
36601
- throw new PlanWireShapeError(`the plan wire neither carries nor derives ${gaps.join(', ')}`);
36602
- const missing = Object.keys(WIRE_KEYS.plan).filter(k => !PLAN_TOP_SCHEMAS[k] || !WIRE_KEYS.plan[k].part);
36603
- if (missing.length)
36604
- throw new PlanWireShapeError(`the plan wire's ${missing.join(', ')} has no part or no format`);
36605
- return jsonShapedObject(planWirePartShape(part, options), Object.fromEntries(PLAN_PART_KEYS[part].map(k => [k, PLAN_TOP_SCHEMAS[k](options)])), `wire plan ${part}`);
36606
- }
36607
- /** A value standing for "absent": `''` (or nothing at all). */
36608
- const isNone = (v) => v === undefined || v === NONE;
36609
- const optional = (name, v, none = isNone) => (none(v) ? {} : { [name]: v });
36610
- const emptyList = (v) => v === undefined || (Array.isArray(v) && v.length === 0);
36611
- /** `[{ <keyName>, <valueName> }]` → `{ key: value }`; anything else is left for the gate to refuse. */
36612
- function listToMap(list, keyName, valueName) {
36613
- if (!Array.isArray(list))
36614
- return list;
36615
- const out = {};
36616
- for (const entry of list) {
36617
- if (!isPlainObject(entry) || typeof entry[keyName] !== 'string')
36618
- return list;
36619
- out[entry[keyName]] = entry[valueName];
36620
- }
36621
- return out;
36622
- }
36623
- const mapToList = (map, keyName, valueName) => Object.entries(map ?? {}).map(([k, v]) => ({ [keyName]: k, [valueName]: v }));
36624
- const each = (list, expand) => (Array.isArray(list) ? list.map(expand) : list);
36625
- function expandWireField(wire) {
36626
- if (!isPlainObject(wire))
36627
- return wire;
36628
- const { required, note, ...rest } = wire;
36629
- const type = FIELD_TYPE_OF_CONTROL[rest['controller']];
36630
- return { ...rest, ...(type ? { type } : {}), ...optional('required', required, v => v === undefined || v === false), ...optional('note', note) };
36083
+ var SiteBuildKind;
36084
+ (function (SiteBuildKind) {
36085
+ SiteBuildKind["Build"] = "build";
36086
+ /** A new design for a built site, everything it holds kept (site-redesign RD2) — `redesign-run.ts`. */
36087
+ SiteBuildKind["Redesign"] = "redesign";
36088
+ /** Bring my site X4 (W2-5's first kind): a plan read from the owner's own site (`planImport`) — its real items keep
36089
+ * their old addresses (`importedFrom`). */
36090
+ SiteBuildKind["Import"] = "import";
36091
+ })(SiteBuildKind || (SiteBuildKind = {}));
36092
+ var SiteBuildStatus;
36093
+ (function (SiteBuildStatus) {
36094
+ SiteBuildStatus["Running"] = "running";
36095
+ SiteBuildStatus["Done"] = "done";
36096
+ SiteBuildStatus["Failed"] = "failed";
36097
+ SiteBuildStatus["Undoing"] = "undoing";
36098
+ SiteBuildStatus["Undone"] = "undone";
36099
+ /** A redesign (RD2): its new design going onto the pages, header, footer and look — page by page. */
36100
+ SiteBuildStatus["Switching"] = "switching";
36101
+ /** A redesign switched: the site wears it; Back is open for `REDESIGN_BACK_DAYS`. */
36102
+ SiteBuildStatus["Switched"] = "switched";
36103
+ /** A redesign going Back: its snapshot restored, page by page. */
36104
+ SiteBuildStatus["Restoring"] = "restoring";
36105
+ /** A redesign gone Back: the site wears what it wore before the switch. */
36106
+ SiteBuildStatus["Restored"] = "restored";
36107
+ /** A staged (or failed, never switched) redesign let go — by the owner, or by a newer redesign: no page was written. */
36108
+ SiteBuildStatus["Discarded"] = "discarded";
36109
+ })(SiteBuildStatus || (SiteBuildStatus = {}));
36110
+ /** The statuses a runner advances — and the ones that hold the org's single-run slot. */
36111
+ const ACTIVE_BUILD_STATUSES = [SiteBuildStatus.Running, SiteBuildStatus.Undoing, SiteBuildStatus.Switching, SiteBuildStatus.Restoring];
36112
+ /** The steps of a build, in the order they run. */
36113
+ var BuildStep;
36114
+ (function (BuildStep) {
36115
+ BuildStep["Preflight"] = "preflight";
36116
+ BuildStep["ContentTypes"] = "content-types";
36117
+ BuildStep["SampleImages"] = "sample-images";
36118
+ /** Bring my site X5: the pictures of the owner's own site, copied into the studio (`media/imported/`, never hot-linked) —
36119
+ * only in a run whose plan was read from a site and holds pictures (`importedPicturesOf`). */
36120
+ BuildStep["ImportPictures"] = "import-pictures";
36121
+ /** I2: the curated stock photos the plan's empty picture slots take, copied into the studio (never hot-linked). */
36122
+ BuildStep["StockPhotos"] = "stock-photos";
36123
+ BuildStep["Items"] = "items";
36124
+ /** Commerce G1: what the business sells, into the studio's SHOP — its categories, then sample products (no price). */
36125
+ BuildStep["Shop"] = "shop";
36126
+ BuildStep["DataSources"] = "data-sources";
36127
+ BuildStep["Pages"] = "pages";
36128
+ BuildStep["Globals"] = "globals";
36129
+ BuildStep["Look"] = "look";
36130
+ })(BuildStep || (BuildStep = {}));
36131
+ const BUILD_STEPS = Object.values(BuildStep);
36132
+ /** The steps a build of `plan` takes, in order: every one, the shop's only when the plan sells (commerce G1), the imported
36133
+ * pictures' only when the plan was read from a site that has some (X5). */
36134
+ function buildStepsOf(plan) {
36135
+ const sells = planSells(plan);
36136
+ const pictures = importedPicturesOf(plan).length > 0;
36137
+ return BUILD_STEPS.filter(step => (step !== BuildStep.Shop || sells) && (step !== BuildStep.ImportPictures || pictures));
36631
36138
  }
36632
- function expandWireContentType(wire, options = {}) {
36633
- if (!isPlainObject(wire))
36634
- return wire;
36635
- const written = options.children === false ? { fields: [], ...wire } : wire;
36636
- const { roles, fields, seed, ...rest } = written;
36637
- const out = { ...rest, roles: listToMap(roles, 'role', 'field'), fields: each(fields, expandWireField) };
36638
- if (!isPlainObject(seed))
36639
- return seed === undefined ? out : { ...out, seed };
36640
- const { values, ...fixed } = seed;
36641
- if (fixed['count'] === 0 && emptyList(values))
36642
- return out;
36643
- const perItem = {};
36644
- const plain = Array.isArray(values) ? values.map(row => {
36645
- if (!isPlainObject(row))
36646
- return row;
36647
- const { each, ...rest } = row;
36648
- if (Array.isArray(each) && each.length)
36649
- perItem[String(rest['field'])] = each;
36650
- return rest;
36651
- }) : values;
36652
- const map = listToMap(plain ?? [], 'field', 'value');
36653
- const items = Object.keys(perItem).length ? { perItem } : {};
36654
- return { ...out, seed: isPlainObject(map) ? { ...fixed, ...items, ...map } : { ...fixed, values } };
36139
+ var StepState;
36140
+ (function (StepState) {
36141
+ StepState["Wait"] = "wait";
36142
+ StepState["Run"] = "run";
36143
+ StepState["Done"] = "done";
36144
+ StepState["Failed"] = "failed";
36145
+ })(StepState || (StepState = {}));
36146
+ /** What a build creates, as Undo walks it. */
36147
+ var CreatedKind;
36148
+ (function (CreatedKind) {
36149
+ CreatedKind["ContentType"] = "content-type";
36150
+ /** Fields the build added to a content type it found (types are shared by every organization of a studio). */
36151
+ CreatedKind["ContentTypeFields"] = "content-type-fields";
36152
+ CreatedKind["SampleImage"] = "sample-image";
36153
+ /** A stock photo copied into the studio's storage (`media/stock/…`), with its assets row. */
36154
+ CreatedKind["StockPhoto"] = "stock-photo";
36155
+ /** Bring my site X5: a picture of the owner's own site copied into the studio's storage (`media/imported/…`), with its
36156
+ * assets row (`source: 'import'`, its old address) — removed by Undo once nothing that stays shows it. */
36157
+ CreatedKind["ImportedPicture"] = "imported-picture";
36158
+ CreatedKind["Item"] = "item";
36159
+ /** Commerce G1: a shop category the build added (one the studio had is reused, never recorded). */
36160
+ CreatedKind["ShopCategory"] = "shop-category";
36161
+ /** Commerce G1: a sample product, written through the shop's own write path. */
36162
+ CreatedKind["ShopProduct"] = "shop-product";
36163
+ CreatedKind["DataSource"] = "data-source";
36164
+ CreatedKind["Page"] = "page";
36165
+ /** RD3-D3 (a) Replace: a page an earlier Undo kept, moved aside (`/<route>-previous`, a draft) so the plan's page takes
36166
+ * its address — Undo puts it back while it is as the move left it and its address is free (`CreatedRecord.from`). */
36167
+ CreatedKind["PageMoved"] = "page-moved";
36168
+ CreatedKind["Global"] = "global";
36169
+ CreatedKind["Look"] = "look";
36170
+ })(CreatedKind || (CreatedKind = {}));
36171
+ /** Why Undo left something in place. */
36172
+ var KeptReason;
36173
+ (function (KeptReason) {
36174
+ KeptReason["Edited"] = "edited";
36175
+ KeptReason["Published"] = "published";
36176
+ KeptReason["InUse"] = "in-use";
36177
+ /** Added to a content type every organization shares: removing a field is the studio owner's change. */
36178
+ KeptReason["Shared"] = "shared";
36179
+ })(KeptReason || (KeptReason = {}));
36180
+ var BuildNoticeCode;
36181
+ (function (BuildNoticeCode) {
36182
+ /** Storage is not configured: sample items get the empty image box, and the run says so. */
36183
+ BuildNoticeCode["NoStorage"] = "no-storage";
36184
+ /** A content type the build reuses is not public in this studio: the site will not show its items. */
36185
+ BuildNoticeCode["ContentTypeNotPublic"] = "content-type-not-public";
36186
+ /** The stock library could not be read: the picture slots keep the empty box, and the run says so. */
36187
+ BuildNoticeCode["StockUnavailable"] = "stock-unavailable";
36188
+ /** The stock library was read but holds no photo for this kind of business (never built, or reviewed down to
36189
+ * none): the picture slots keep the empty box, and the run says so (I2.1 — never silently). */
36190
+ BuildNoticeCode["StockMissing"] = "stock-missing";
36191
+ /** M7: a picture made for the site was refused by its review twice (or its second try did not fit the cost shown):
36192
+ * stock or the empty box stands in, and the run says so. */
36193
+ BuildNoticeCode["PictureFallback"] = "picture-fallback";
36194
+ /** Commerce G1 (shop-aware A-D9): the studio already sells products — the site shows them, and no sample is added. */
36195
+ BuildNoticeCode["ShopHasProducts"] = "shop-has-products";
36196
+ /** Commerce G1: the studio had never set its currency and VAT — the build stored the ones its language implies
36197
+ * (Hebrew: ILS and 18%), said here so the owner checks them in Settings ▸ General before setting prices. */
36198
+ BuildNoticeCode["ShopMoneyInferred"] = "shop-money-inferred";
36199
+ /** Commerce G2: the facts the owner gave (email, phone, address) became the shop's contact details where it had none
36200
+ * — said, so the owner adds what only they know (the legal name, the business number) in Shop ▸ Settings. */
36201
+ BuildNoticeCode["ShopBusinessFromFacts"] = "shop-business-from-facts";
36202
+ /** RD3-D3 (a) Keep mine: a page an earlier Undo kept stays at an address the plan builds — the plan's page there is
36203
+ * not built. */
36204
+ BuildNoticeCode["KeptPageSkipped"] = "kept-page-skipped";
36205
+ /** RD3-D3 (a) Replace: that page moved aside as a draft (`/<route>-previous`) — Undo puts it back. */
36206
+ BuildNoticeCode["KeptPageMoved"] = "kept-page-moved";
36207
+ /** HI1a: the header the plan asked for could not be worn as asked (a long name between two menus, a part the site
36208
+ * cannot carry) — the composer mended it, and the run says so; the owner changes it in the builder. */
36209
+ BuildNoticeCode["HeaderMended"] = "header-mended";
36210
+ /** AW8: the opening the plan asked for was mended (an award word on a basic build, a part the site cannot carry) —
36211
+ * said, so the owner knows the home page opens a little differently and where to change it. */
36212
+ BuildNoticeCode["OpeningMended"] = "opening-mended";
36213
+ /** LI5: the footer the plan asked for was mended (a word that waits drawn as its stand-in, a one-line footer that
36214
+ * holds only some parts) — said like the header's and the opening's. */
36215
+ BuildNoticeCode["FooterMended"] = "footer-mended";
36216
+ /** AW6: the body the plan asked for was mended (a section edge that comes with the award plan, on a basic build) —
36217
+ * said like the header's, the opening's and the footer's. */
36218
+ BuildNoticeCode["BodyMended"] = "body-mended";
36219
+ /** iox-ui#129: pictures nothing fills were not drawn as empty boxes — those sections were composed type-led (the home
36220
+ * page opening on its words, a list's cards without their picture). Said once, so the owner knows a photo of theirs
36221
+ * brings the picture-led section back (a Re-fit, or the next build). */
36222
+ BuildNoticeCode["TypeLed"] = "type-led";
36223
+ /** Bring my site X5: some pictures of the owner's site were not copied (not a picture we keep, too large, unreachable,
36224
+ * or past the plan's picture or size limit) — the items show none in their place (never the old site's), said once,
36225
+ * so the owner adds them in the builder. */
36226
+ BuildNoticeCode["ImportPicturesLeft"] = "import-pictures-left";
36227
+ })(BuildNoticeCode || (BuildNoticeCode = {}));
36228
+ /** RD3-D3 (a): what a build does with a page an earlier Undo kept at an address its plan builds — the header and footer's
36229
+ * pair (`replaceGlobals`), for pages. */
36230
+ var KeptPagesChoice;
36231
+ (function (KeptPagesChoice) {
36232
+ /** Build every other page; leave these as they are. */
36233
+ KeptPagesChoice["Keep"] = "keep";
36234
+ /** Move each aside as a draft at `/<route>-previous` (`/shop-previous/:slug` for a per-item page) and build the plan's
36235
+ * page at its address. Nothing is deleted. */
36236
+ KeptPagesChoice["Replace"] = "replace";
36237
+ })(KeptPagesChoice || (KeptPagesChoice = {}));
36238
+ /** The suffix a replaced page's address takes. */
36239
+ const PREVIOUS_ROUTE_SUFFIX = '-previous';
36240
+ /** Where a page moved aside goes: `/<route>-previous`, then `-previous-2`… — never an address in `taken` (shapes
36241
+ * compared case-insensitively, trailing slash and parameter names ignored). The home page (`/`) goes to `/home-previous`.
36242
+ *
36243
+ * ⚠️ The suffix goes on the route's LAST STATIC segment, never on a `:param` (vectoriox/iox-ui#100): `/shop/:slug` moved
36244
+ * to `/shop/:slug-previous` still answered every `/shop/<item>` — a parameter matches the whole segment — and, older
36245
+ * and published by Publish site, the replaced product page was served instead of the new one. So `/shop/:slug` →
36246
+ * `/shop-previous/:slug`, and a route of parameters only (`/:slug`) → `/previous/:slug`. */
36247
+ function previousRoute(route, taken) {
36248
+ const key = (r) => (r.replace(/\/+$/, '') || '/').replace(/\/:[^/]+/g, '/:').toLowerCase();
36249
+ const held = new Set(taken.map(key));
36250
+ const segments = (route.replace(/\/+$/, '') || '/home').split('/').filter(Boolean);
36251
+ if (!segments.length)
36252
+ segments.push('home');
36253
+ const at = segments.map((seg, i) => (seg.startsWith(':') ? -1 : i)).filter(i => i >= 0).pop();
36254
+ const shaped = (suffix) => {
36255
+ const out = [...segments];
36256
+ if (at === undefined)
36257
+ out.unshift(`previous${suffix}`);
36258
+ else
36259
+ out[at] = `${out[at]}${PREVIOUS_ROUTE_SUFFIX}${suffix}`;
36260
+ return `/${out.join('/')}`;
36261
+ };
36262
+ let candidate = shaped('');
36263
+ for (let n = 2; held.has(key(candidate)); n++)
36264
+ candidate = shaped(`-${n}`);
36265
+ return candidate;
36655
36266
  }
36656
- function expandWireDataSource(wire) {
36657
- if (!isPlainObject(wire))
36658
- return wire;
36659
- const { alias, type, mode, contentType, limit, filterField, routeParam, of, op, within, ...rest } = wire;
36660
- if (type === PlanDataSourceType.Cms) {
36661
- const filter = isNone(filterField) && isNone(routeParam) ? {} : { filterByRouteParam: { field: filterField, routeParam } };
36662
- return { ...rest, alias, type, mode, contentType, ...optional('limit', limit, v => v === undefined || v === 0), ...filter };
36663
- }
36664
- if (type === PlanDataSourceType.Relative)
36665
- return { ...rest, alias, type, of, op, within };
36666
- if (type === PlanDataSourceType.Shop) {
36667
- const filter = isNone(filterField) && isNone(routeParam) ? {} : { filterByRouteParam: { field: filterField, routeParam } };
36668
- return { ...rest, alias, type, mode, resource: contentType, ...optional('limit', limit, v => v === undefined || v === 0), ...filter };
36669
- }
36670
- return wire;
36267
+ /** The compose issues the run SAYS (header, opening, footer), each kind once (the wizard tracks a notice by its code): the words of every mend of
36268
+ * that kind joined, for the log and the API; the screen shows the code's own sentence. An opening that only found no
36269
+ * place for a word it carried is not a mend of the mix, so it is not said. */
36270
+ const MEND_NOTICES = [
36271
+ [ComposeIssueCode.HeaderMended, BuildNoticeCode.HeaderMended],
36272
+ [ComposeIssueCode.OpeningMended, BuildNoticeCode.OpeningMended],
36273
+ [ComposeIssueCode.FooterMended, BuildNoticeCode.FooterMended],
36274
+ [ComposeIssueCode.BodyMended, BuildNoticeCode.BodyMended],
36275
+ ];
36276
+ const CARRY_ONLY = /^the opening found no place for /;
36277
+ function mendNotices(issues) {
36278
+ return MEND_NOTICES.flatMap(([issue, notice]) => {
36279
+ const said = [...new Set(issues.filter(i => i.code === issue && !CARRY_ONLY.test(i.detail)).map(i => i.detail))];
36280
+ return said.length ? [{ code: notice, detail: said.join('; ') }] : [];
36281
+ });
36671
36282
  }
36672
- /** The structure's products → the plan's `shop`: the products as written, their categories derived; `[]` = it sells nothing. */
36673
- function expandWireShop(wire) {
36674
- if (!Array.isArray(wire))
36675
- return wire;
36676
- if (!wire.length)
36677
- return undefined;
36678
- const products = wire.filter(isPlainObject);
36679
- return { categories: products.length === wire.length ? shopCategoriesOf(products) : [], products: wire };
36283
+ /** iox-ui#129: what a composition made type-led, said once (`BuildNoticeCode.TypeLed`) — every change's words joined,
36284
+ * for the log and the API; the screen shows the code's own sentence. Nothing type-led: nothing said. */
36285
+ function typeLedNotices(typeLed) {
36286
+ const said = [...new Set((typeLed?.changes ?? []).map(c => c.said))];
36287
+ return said.length ? [{ code: BuildNoticeCode.TypeLed, detail: said.join('; ') }] : [];
36680
36288
  }
36681
- function expandWireSection(wire) {
36682
- if (!isPlainObject(wire))
36683
- return wire;
36684
- const { slots, links, binding, without, form, enter, ...rest } = wire;
36685
- return {
36686
- ...rest,
36687
- ...optional('slots', listToMap(slots, 'slot', 'text'), v => emptyList(slots) || v === undefined),
36688
- ...optional('links', listToMap(links, 'slot', 'route'), v => emptyList(links) || v === undefined),
36689
- ...optional('binding', binding),
36690
- ...optional('without', without, emptyList),
36691
- ...optional('form', form),
36692
- ...optional('enter', enter),
36693
- };
36289
+ var PreflightRefusalCode;
36290
+ (function (PreflightRefusalCode) {
36291
+ /** The Site Plan itself is invalid (`validateSitePlan`); `issue` is the validator's code. */
36292
+ PreflightRefusalCode["InvalidPlan"] = "invalid-plan";
36293
+ /** A route the plan wants is already a page of this organization. */
36294
+ PreflightRefusalCode["RouteTaken"] = "route-taken";
36295
+ /** The studio's content type of that name stores a field the plan needs differently (type or control) —
36296
+ * types are shared by every organization, so the build reuses one it finds and adds what it lacks. */
36297
+ PreflightRefusalCode["ContentTypeConflict"] = "content-type-conflict";
36298
+ /** The name may not be a content type (a platform collection, or not a valid name). */
36299
+ PreflightRefusalCode["ContentTypeName"] = "content-type-name";
36300
+ /** The plan creates a content type or adds fields to one, and the caller may not (an org owner/admin — schema_all). */
36301
+ PreflightRefusalCode["ContentTypesNeedPermission"] = "content-types-need-permission";
36302
+ /** The org library holds the alias with a different definition. */
36303
+ PreflightRefusalCode["DataSourceConflict"] = "data-source-conflict";
36304
+ /** The studio has pages AND a header/footer: replace or keep them is the caller's choice (D7). */
36305
+ PreflightRefusalCode["GlobalsNeedDecision"] = "globals-need-decision";
36306
+ /** A global the plan adds has the id of one the studio keeps. */
36307
+ PreflightRefusalCode["GlobalTaken"] = "global-taken";
36308
+ /** RD3-D3 (a): a page an earlier Undo kept (published or edited) sits at an address the plan builds — Keep mine or
36309
+ * Replace them is the caller's choice (`KeptPagesChoice`). A page made by hand there stays a plain `route-taken`. */
36310
+ PreflightRefusalCode["KeptPageNeedsDecision"] = "kept-page-needs-decision";
36311
+ })(PreflightRefusalCode || (PreflightRefusalCode = {}));
36312
+ /**
36313
+ * The stable key each written document carries beside `siteBuildId`: a step that runs twice looks it up first and
36314
+ * skips what exists (so a restart or a Retry continues without duplicates), and a reader finds what the run made
36315
+ * by it — the wizard opens the HOME page by `page(<its key>)`. One builder per kind.
36316
+ */
36317
+ const buildKeys = {
36318
+ contentType: (name) => `schema:${name}`,
36319
+ contentTypeFields: (name) => `schema-fields:${name}`,
36320
+ item: (contentType, n) => `item:${contentType}:${n}`,
36321
+ shopCategory: (n) => `shop-category:${n}`,
36322
+ shopProduct: (n) => `shop-product:${n}`,
36323
+ sampleImage: (n) => `sample-image:${n}`,
36324
+ stockPhoto: (libraryKey) => `stock-photo:${libraryKey}`,
36325
+ importedPicture: (originalUrl) => `imported-picture:${originalUrl}`,
36326
+ dataSource: (alias) => `data-source:${alias}`,
36327
+ page: (key) => `page:${key}`,
36328
+ global: (nodeId) => `global:${nodeId}`,
36329
+ look: () => 'look',
36330
+ pageMoved: (pageId) => `page-moved:${pageId}`,
36331
+ };
36332
+ /** The id of the page a run made for the plan's home page, or null (not made yet, or no home page). */
36333
+ function builtHomePageId(run) {
36334
+ const home = run?.plan?.pages?.find(p => p.isHome) ?? run?.plan?.pages?.[0];
36335
+ if (!home)
36336
+ return null;
36337
+ const key = buildKeys.page(home.key);
36338
+ return run.created?.find(c => c.kind === CreatedKind.Page && c.buildKey === key)?.id ?? null;
36694
36339
  }
36695
- function expandWirePage(wire, options = {}) {
36696
- if (!isPlainObject(wire))
36697
- return wire;
36698
- const written = options.children === false ? { sections: [], ...wire } : wire;
36699
- const { archetype, need, template, routeSource, seo, sections, compose, ...rest } = written;
36700
- const words = isPlainObject(seo) ? { ...optional('title', seo['title']), ...optional('description', seo['description']) } : seo;
36340
+ /** The step a run stopped at, or null. */
36341
+ function failedBuildStep(run) {
36342
+ return run?.steps?.find(s => s.state === StepState.Failed) ?? null;
36343
+ }
36344
+ /** A run still holding the org's slot (building or undoing) — a page that left it comes back to its progress. */
36345
+ function isActiveBuild(run) {
36346
+ return !!run && ACTIVE_BUILD_STATUSES.includes(run.status);
36347
+ }
36348
+ /** What a build does with each content type its plan names (the preflight's `summary.contentTypes[].action`): content
36349
+ * types are shared by every organization of a studio, so one the studio already has is reused, or extended with the
36350
+ * fields it lacks — never created twice. */
36351
+ var ContentTypeAction;
36352
+ (function (ContentTypeAction) {
36353
+ ContentTypeAction["Create"] = "create";
36354
+ ContentTypeAction["Reuse"] = "reuse";
36355
+ ContentTypeAction["Extend"] = "extend";
36356
+ })(ContentTypeAction || (ContentTypeAction = {}));
36357
+ function buildStepFacts(plan, actions = {}) {
36358
+ const contentTypeActions = {};
36359
+ for (const t of plan.contentTypes) {
36360
+ const action = actions[t.name];
36361
+ if (action)
36362
+ (contentTypeActions[action] ??= []).push(t.label);
36363
+ }
36701
36364
  return {
36702
- ...rest,
36703
- ...(wire['route'] === '/' ? { isHome: true } : {}),
36704
- ...optional('archetype', archetype),
36705
- ...optional('need', need),
36706
- ...optional('template', template),
36707
- ...optional('routeSource', routeSource),
36708
- ...optional('seo', words, v => v === undefined || (isPlainObject(v) && Object.keys(v).length === 0)),
36709
- sections: each(sections, expandWireSection),
36710
- ...(compose === true ? { compose: true } : compose === false || compose === undefined ? {} : { compose }),
36365
+ contentTypes: plan.contentTypes.map(t => t.label),
36366
+ contentTypeActions,
36367
+ items: plan.contentTypes.reduce((n, t) => n + (t.seed?.count ?? 0), 0),
36368
+ pictures: importedPicturesOf(plan).length,
36369
+ products: plan.shop?.products.length ?? 0,
36370
+ categories: plan.shop?.categories.length ?? 0,
36371
+ pages: plan.pages.length,
36372
+ routes: plan.pages.map(p => p.route),
36373
+ navLinks: plan.pages.filter(p => p.inNav).length,
36374
+ flavorId: plan.design.flavorId,
36711
36375
  };
36712
36376
  }
36713
- function expandWireBusiness(wire, facts) {
36714
- if (!isPlainObject(wire))
36715
- return wire;
36716
- const { tagline, ...rest } = wire;
36717
- return { ...rest, ...optional('tagline', tagline), ...(facts && Object.keys(facts).length ? { facts: { ...facts } } : {}) };
36718
- }
36377
+
36719
36378
  /**
36720
- * A model's plan (its parts, on the wire) + what the generation decides (the look, the run, the language, the owner's
36721
- * facts) → the Site Plan. Pure. Translates, never repairs: whatever an answer got wrong is still wrong, for
36722
- * `validateSitePlan` — a part that is not an object is the result itself, a part not written yet leaves its keys out
36723
- * (the validator then names them, at their own paths). What follows from the pages alone is added (`withDerivedSources`).
36379
+ * A REDESIGN run's wire vocabulary (site-redesign plan §3c, RD2): a new design for a built site, with everything it holds
36380
+ * kept. The same W2 runner and the same single-run slot as a build (`SiteBuildKind.Redesign` in the `siteBuilds`
36381
+ * collection), its own steps: Snapshot → Harvest → Compose → Stage, then the owner's Switch, then Back for
36382
+ * `REDESIGN_BACK_DAYS`. Structure is locked (RD-D4): a redesign writes pages' layouts and settings, the header and footer,
36383
+ * and the look — never a content type, field, item, data source or route. ONE definition: iox-cms stores and answers it,
36384
+ * the redesign screens (RD3) read it. Pure types, enums and helpers; no transport.
36724
36385
  */
36725
- function expandPlanWire(parts, context) {
36726
- const written = PLAN_PARTS.filter(part => parts[part] !== undefined).map(part => parts[part]);
36727
- const odd = written.find(value => !isPlainObject(value));
36728
- if (odd !== undefined)
36729
- return odd;
36730
- const wire = Object.assign({}, ...written);
36731
- const { business, contentTypes, dataSources, pages, direction, shop, globals, ...rest } = wire;
36732
- const sells = expandWireShop(shop);
36733
- return withDerivedSources({
36734
- ...rest,
36735
- ...expandWireGlobals(globals),
36736
- ...(sells === undefined ? {} : { shop: sells }),
36737
- ...(isPlainObject(direction) && direction['idea'] === NONE ? {} : direction === undefined ? {} : { direction }),
36738
- version: SITE_PLAN_VERSION,
36739
- source: { ...context.source },
36740
- business: expandWireBusiness(business, context.facts),
36741
- ...(context.locale ? { locale: context.locale } : {}),
36742
- ...(context.popup ? { popup: JSON.parse(JSON.stringify(context.popup)) } : {}),
36743
- design: { ...context.design },
36744
- contentTypes: each(contentTypes, expandWireContentType),
36745
- dataSources: each(dataSources, expandWireDataSource),
36746
- pages: each(pages, expandWirePage),
36747
- });
36748
- }
36749
- /** The wire's globals → the plan's: a header or footer mix that is a stored pattern becomes that pattern; any other becomes
36750
- * `mixes.<part>` beside the Studio pattern (the mix wins). A part that is not a word list is left for the validator. */
36751
- function expandWireGlobals(globals) {
36752
- if (globals === undefined)
36753
- return {};
36754
- if (!isPlainObject(globals))
36755
- return { globals };
36756
- const { [OPENING_WIRE_KEY]: opening, [BODY_WIRE_KEY]: body, [POPUP_WIRE_KEY]: popup, ...rest } = globals;
36757
- const out = { ...rest };
36758
- const mixes = {};
36759
- // AW8: the opening is a mix only (no stored pattern stands for it on the wire); [] = none. Not a list: the validator says so.
36760
- // AW6: so is the body (the award tier's wire alone writes it); [] = none.
36761
- // PU3: so is the popup ([] = none).
36762
- for (const [name, words] of [[OPENING_WIRE_KEY, opening], [BODY_WIRE_KEY, body], [POPUP_WIRE_KEY, popup]]) {
36763
- if (words !== undefined && (!Array.isArray(words) || words.length))
36764
- mixes[name] = Array.isArray(words) ? [...words] : words;
36765
- }
36766
- for (const [slot, readId, fallback] of [
36767
- [GlobalSlot.Header, (w) => headerPatternIdOf(headerMixFromWords(w)), DEFAULT_HEADER_PATTERN],
36768
- [GlobalSlot.Footer, (w) => footerPatternIdOf(footerMixFromWords(w)), DEFAULT_FOOTER_PATTERN],
36769
- ]) {
36770
- const words = globals[slot];
36771
- if (!Array.isArray(words))
36772
- continue;
36773
- let named = null;
36774
- try {
36775
- named = readId(words);
36776
- }
36777
- catch { /* the validator names the word */ }
36778
- // A mix that IS a stored pattern is kept as that pattern alone (the plan stays as a template would write it).
36779
- out[slot] = named ?? fallback;
36780
- if (!named)
36781
- mixes[slot] = [...words];
36782
- }
36783
- return { globals: out, ...(Object.keys(mixes).length ? { mixes } : {}) };
36386
+ /** The steps a redesign takes before its Switch, in the order they run. */
36387
+ var RedesignStep;
36388
+ (function (RedesignStep) {
36389
+ /** Every page in scope (its layout, settings, fingerprint) and the globals — the version Back restores. */
36390
+ RedesignStep["Snapshot"] = "snapshot";
36391
+ /** `harvestPage` per page in scope: what on it is the owner's. */
36392
+ RedesignStep["Harvest"] = "harvest";
36393
+ /** What the redesign may ADD (§3e, RD3-D2 as amended): new pages the owner asked for or the reading suggests, the new
36394
+ * content they need — asked, checked (`checkAdditions`), drawn and staged; nothing existing is touched. */
36395
+ RedesignStep["Additions"] = "additions";
36396
+ /** Per page: the model's layout with its carry (a composed page), or the page re-fitted for the new look. */
36397
+ RedesignStep["Compose"] = "compose";
36398
+ /** The new layouts, header, footer and look written onto the RUN — the live site does not move. */
36399
+ RedesignStep["Stage"] = "stage";
36400
+ })(RedesignStep || (RedesignStep = {}));
36401
+ const REDESIGN_STEPS = Object.values(RedesignStep);
36402
+ /** How long Back stays open after a Switch (RD-D11). */
36403
+ const REDESIGN_BACK_DAYS = 30;
36404
+ const DAY_MS = 24 * 60 * 60 * 1000;
36405
+ /** How a page in scope got its new design. */
36406
+ var StagedPageWay;
36407
+ (function (StagedPageWay) {
36408
+ /** The model laid it out (the M8 layout request with the page's carry). */
36409
+ StagedPageWay["Composed"] = "composed";
36410
+ /** Re-stamped from its run's plan in the new look, the owner's content and edits carried (Re-fit — no model). */
36411
+ StagedPageWay["Refit"] = "refit";
36412
+ /** Not redesigned: it stays as it is and wears the new look through its tokens and element styles. */
36413
+ StagedPageWay["Kept"] = "kept";
36414
+ })(StagedPageWay || (StagedPageWay = {}));
36415
+ /** Why a page went the way it did, when the way alone does not say it. */
36416
+ var StagedPageReason;
36417
+ (function (StagedPageReason) {
36418
+ /** The page is laid out by patterns in its plan (not a composed page): re-fitted, no model asked (RD-D13). */
36419
+ StagedPageReason["Patterns"] = "patterns";
36420
+ /** The model's layout did not hold (after its repair and the section fallback): re-fitted instead. */
36421
+ StagedPageReason["ModelFellBack"] = "model-fell-back";
36422
+ /** There is no reading to ask the model with (a site built from a template): re-fitted. */
36423
+ StagedPageReason["NoReading"] = "no-reading";
36424
+ /** The model was refused before the call (credits, plan): re-fitted. */
36425
+ StagedPageReason["Refused"] = "refused";
36426
+ /** A legal page: its text is the owner's, never recomposed (RD-D17). */
36427
+ StagedPageReason["Legal"] = "legal";
36428
+ /** A page the owner made by hand that stays as it is: there is no reading to lay it out with (a studio built from a
36429
+ * template). With a reading it is laid out like a composed page (RD-D16, RD3-D1 — `handPageKey`). */
36430
+ StagedPageReason["HandMade"] = "hand-made";
36431
+ /** The run that built it, or its page in that run's plan, is gone: nothing to re-stamp it from. */
36432
+ StagedPageReason["NoSource"] = "no-source";
36433
+ })(StagedPageReason || (StagedPageReason = {}));
36434
+ /** Why a redesign staged no additions without asking, or could not use the answer. */
36435
+ var AdditionsSkipped;
36436
+ (function (AdditionsSkipped) {
36437
+ /** No sentence, and the owner turned down the suggestions of their last redesign: nothing is asked. */
36438
+ AdditionsSkipped["NothingToAsk"] = "nothing-to-ask";
36439
+ /** Asked, and the answer did not pass (after its one re-ask). */
36440
+ AdditionsSkipped["NotUsable"] = "not-usable";
36441
+ /** Refused before the call (credits, plan) — the redesign goes on without additions. */
36442
+ AdditionsSkipped["Refused"] = "refused";
36443
+ })(AdditionsSkipped || (AdditionsSkipped = {}));
36444
+ /** Why the Switch held an addition back: something took its place since it was staged (never overwritten). */
36445
+ var AdditionHeldBack;
36446
+ (function (AdditionHeldBack) {
36447
+ AdditionHeldBack["RouteTaken"] = "route-taken";
36448
+ AdditionHeldBack["TypeExists"] = "type-exists";
36449
+ AdditionHeldBack["SourceTaken"] = "source-taken";
36450
+ /** It brings a new content type and the person who switched may not add one (an org owner or admin may). */
36451
+ AdditionHeldBack["TypesNotAllowed"] = "types-not-allowed";
36452
+ })(AdditionHeldBack || (AdditionHeldBack = {}));
36453
+ /** What the Switch (and Back) did to one page. */
36454
+ var RedesignPageResult;
36455
+ (function (RedesignPageResult) {
36456
+ RedesignPageResult["Switched"] = "switched";
36457
+ /** Edited after the harvest: not switched (RD-D12) — Compare offers "Redo this page". */
36458
+ RedesignPageResult["Stale"] = "stale";
36459
+ /** The owner kept the old design for it (per-page accept, RD-D9). */
36460
+ RedesignPageResult["Declined"] = "declined";
36461
+ /** Kept as it is by the redesign (`StagedPageWay.Kept`) — nothing to write. */
36462
+ RedesignPageResult["Unchanged"] = "unchanged";
36463
+ /** Back: the snapshot is on the page again. */
36464
+ RedesignPageResult["Restored"] = "restored";
36465
+ /** Back: edited since the switch and not asked to restore — left as it is (RD-D12). */
36466
+ RedesignPageResult["EditedSince"] = "edited-since";
36467
+ /** Back: the page was deleted since the switch. */
36468
+ RedesignPageResult["Gone"] = "gone";
36469
+ })(RedesignPageResult || (RedesignPageResult = {}));
36470
+ /** The parts of a Switch or a Back, in the order they run — a resumed one carries on after the done ones. */
36471
+ var RedesignPart;
36472
+ (function (RedesignPart) {
36473
+ /** What the redesign adds — new types, items, sources and pages (§3e) — before the pages, so a new page's links resolve. */
36474
+ RedesignPart["Additions"] = "additions";
36475
+ RedesignPart["Pages"] = "pages";
36476
+ RedesignPart["Globals"] = "globals";
36477
+ RedesignPart["Look"] = "look";
36478
+ })(RedesignPart || (RedesignPart = {}));
36479
+ const REDESIGN_PARTS = Object.values(RedesignPart);
36480
+ /** The choices of the look a Switch replaced — what Back returns to ("Linen · Warm") — or null when the run does not
36481
+ * say (not switched yet, or a run stored before the look was). A studio with no design row wore its defaults. */
36482
+ function redesignPreviousChoices(run) {
36483
+ const before = run?.look?.before;
36484
+ if (!before)
36485
+ return null;
36486
+ return readDesignConfig(before.config, !!before.config).choices;
36784
36487
  }
36785
- // ── The plan → the wire ────────────────────────────────────────────────────────────────────────────────────────────
36786
- function fieldToWire(field) {
36787
- return { name: field.name, controller: field.controller, required: field.required ?? false, note: field.note ?? NONE };
36488
+ /** The refusals of a redesign's start, switch and back. */
36489
+ var RedesignRefusalCode;
36490
+ (function (RedesignRefusalCode) {
36491
+ /** No page in scope was built by a site build — there is nothing to redesign. */
36492
+ RedesignRefusalCode["NothingBuilt"] = "nothing-built";
36493
+ /** A page id in scope is not a page of this organization. */
36494
+ RedesignRefusalCode["UnknownPage"] = "unknown-page";
36495
+ /** The look asked for is not a look (design-core cannot complete it). */
36496
+ RedesignRefusalCode["InvalidDesign"] = "invalid-design";
36497
+ /** Switch on a run that is not staged, Back on one that is not switched. */
36498
+ RedesignRefusalCode["WrongStatus"] = "wrong-status";
36499
+ /** Back after `REDESIGN_BACK_DAYS`. */
36500
+ RedesignRefusalCode["BackClosed"] = "back-closed";
36501
+ /** One page again: the page is not one of the run's staged pages, or it stays as it is with nothing to lay out
36502
+ * (a legal page, a page with no plan to compose it from). */
36503
+ RedesignRefusalCode["NotRedesignable"] = "not-redesignable";
36504
+ })(RedesignRefusalCode || (RedesignRefusalCode = {}));
36505
+ /** The day Back closes, or null (not switched). */
36506
+ function redesignBackUntil(run) {
36507
+ const at = run.switch?.finishedAt ?? run.switch?.at;
36508
+ return at ? new Date(new Date(at).getTime() + REDESIGN_BACK_DAYS * DAY_MS) : null;
36788
36509
  }
36789
- function contentTypeToWire(type, options = {}) {
36790
- const played = type.roles;
36791
- const roles = ROLE_KEYS.filter(role => played[role]).map(role => ({ role, field: played[role] }));
36792
- // X4: an imported item's old address is never on the wire (`importedFrom` stays with the plan).
36793
- const { count = 0, sample = false, isPublished = false, perItem = {}, importedFrom: _from, ...values } = type.seed ?? {};
36794
- return {
36795
- name: type.name, label: type.label, roles, ...(options.children === false ? {} : { fields: type.fields.map(fieldToWire) }),
36796
- seed: { count, sample, isPublished, values: mapToList(values, 'field', 'value').map(row => ({ ...row, each: perItem[String(row['field'])] ?? [] })) },
36797
- };
36510
+ /** May Back run now: switched, and within `REDESIGN_BACK_DAYS` of the switch. */
36511
+ function redesignBackOpen(run, now) {
36512
+ const until = redesignBackUntil(run);
36513
+ return run.status === SiteBuildStatus.Switched && !!until && now.getTime() <= until.getTime();
36798
36514
  }
36799
- function dataSourceToWire(source) {
36800
- const blank = { alias: source.alias, type: source.type, mode: NONE, contentType: NONE, limit: 0, filterField: NONE, routeParam: NONE, of: NONE, op: NONE, within: NONE };
36801
- if (source.type === PlanDataSourceType.Relative)
36802
- return { ...blank, of: source.of, op: source.op, within: source.within };
36803
- if (source.type === PlanDataSourceType.Shop) {
36804
- return {
36805
- ...blank, mode: source.mode, contentType: source.resource, limit: source.limit ?? 0,
36806
- filterField: source.filterByRouteParam?.field ?? NONE, routeParam: source.filterByRouteParam?.routeParam ?? NONE,
36807
- };
36808
- }
36809
- return {
36810
- ...blank, mode: source.mode, contentType: source.contentType, limit: source.limit ?? 0,
36811
- filterField: source.filterByRouteParam?.field ?? NONE, routeParam: source.filterByRouteParam?.routeParam ?? NONE,
36812
- };
36515
+ /** The plan-page key of a page the owner made by hand (RD2.1, RD3-D1 (a)): `hand:<pageId>`. */
36516
+ const HAND_PAGE_KEY_PREFIX = 'hand:';
36517
+ function handPageKey(pageId) {
36518
+ return `${HAND_PAGE_KEY_PREFIX}${pageId}`;
36813
36519
  }
36814
- function sectionToWire(section) {
36815
- return {
36816
- pattern: section.pattern, slots: mapToList(section.slots, 'slot', 'text'), links: mapToList(section.links, 'slot', 'route'),
36817
- binding: section.binding ?? NONE, without: [...(section.without ?? [])], form: section.form ?? NONE, enter: section.enter ?? NONE,
36818
- };
36520
+ /** Is `key` a hand-made page's plan-page key. */
36521
+ function isHandPageKey(key) {
36522
+ return typeof key === 'string' && key.startsWith(HAND_PAGE_KEY_PREFIX) && key.length > HAND_PAGE_KEY_PREFIX.length;
36819
36523
  }
36820
- function pageToWire(page, options = {}) {
36821
- return {
36822
- key: page.key, name: page.name, route: page.route, inNav: page.inNav ?? false, archetype: page.archetype ?? NONE, need: page.need ?? NONE,
36823
- template: page.template ?? NONE, routeSource: page.routeSource ?? NONE,
36824
- seo: { title: page.seo?.title ?? NONE, description: page.seo?.description ?? NONE },
36825
- ...(options.children === false ? {} : { sections: page.sections.map(sectionToWire) }),
36826
- compose: page.compose ?? false,
36827
- };
36524
+ /**
36525
+ * The plan page a redesign gives a page the owner made by hand (RD2.1): its address and name, laid out by the model in the
36526
+ * layout language (`compose`), every section the owner's (`harvestPage(…, { built: false })`), no sections of its own to
36527
+ * fall back on, never added to the navigation (the owner's header decides that, as before).
36528
+ */
36529
+ function handPlanPage(page) {
36530
+ return { key: handPageKey(page.pageId), name: page.name, route: page.route, inNav: false, sections: [], compose: true };
36828
36531
  }
36829
- const PLAN_TO_WIRE = {
36830
- business: plan => ({ name: plan.business.name, tagline: plan.business.tagline ?? NONE }),
36831
- contentTypes: plan => plan.contentTypes.map(type => contentTypeToWire(type)),
36832
- dataSources: plan => plan.dataSources.map(dataSourceToWire),
36833
- pages: plan => plan.pages.map(page => pageToWire(page)),
36834
- globals: (plan, options) => ({
36835
- ...plan.globals, [GlobalSlot.Header]: headerMixWords(headerMixOfPlan(plan)), [GlobalSlot.Footer]: footerMixWords(footerMixOfPlan(plan)),
36836
- [OPENING_WIRE_KEY]: [...(plan.mixes?.opening ?? [])],
36837
- // AW6: the award tier's wire writes the body ([] = none); every other tier's has no such key (its plan wears none).
36838
- ...(isAward(options) ? { [BODY_WIRE_KEY]: [...(plan.mixes?.body ?? [])] } : {}),
36839
- [POPUP_WIRE_KEY]: [...(plan.mixes?.popup ?? [])],
36840
- }),
36841
- direction: plan => ({ idea: plan.direction?.idea ?? NONE, cliche: plan.direction?.cliche ?? NONE, flip: plan.direction?.flip ?? NONE, rules: [...(plan.direction?.rules ?? [])] }),
36842
- shop: plan => (plan.shop?.products ?? []).map(p => ({ name: p.name, category: p.category, description: p.description, options: p.options.map(o => ({ name: o.name, values: [...o.values] })) })),
36843
- };
36844
- /** One part of the plan on the wire: what that part's request (asked at `options`' tier) would have answered. */
36845
- function planPartToWire(plan, part, options = {}) {
36846
- return Object.fromEntries(PLAN_PART_KEYS[part].map(k => [k, PLAN_TO_WIRE[k](plan, options)]));
36532
+ /** May the owner let a redesign go (Discard): staged, or failed before any Switch wrote a page. */
36533
+ function redesignDiscardable(run) {
36534
+ return run.status === SiteBuildStatus.Done || (run.status === SiteBuildStatus.Failed && !run.switch);
36847
36535
  }
36848
- /** The plan → the wire, by part: what a model would have written (the change prompt shows it; fakes and evals write it).
36849
- * At the award tier the body travels too (AW6); below it, a plan's body is not on the wire. */
36850
- function planToWire(plan, options = {}) {
36851
- return Object.fromEntries(PLAN_PARTS.map(part => [part, planPartToWire(plan, part, options)]));
36536
+ /** Is a run a redesign (a stored run of either kind). */
36537
+ function isRedesignRun(run) {
36538
+ return run?.kind === SiteBuildKind.Redesign;
36852
36539
  }
36853
36540
 
36854
36541
  /**
36855
- * What a REDESIGN may add (site-redesign plan §3e — RD3-D2 as amended by Doron, 2026-11-21: "the system can suggest new
36856
- * pages if make sense and in case do use asked for redisign and new pages or content"). Additive only: a new page takes
36857
- * a NEW address, new content (a type, items) sits beside what exists, and nothing existing — a type, a field, an item,
36858
- * a data source, a relation, an address — is ever edited or removed. Facts are never invented (a missing one is a
36859
- * placeholder the gate blocks on).
36542
+ * The plan WIRE (AI plan M1-3, vectoriox/iox-cms#45, #47): what a model writes when it plans a site — a compact format
36543
+ * inside the Claude API's structured-output limits (≤ 24 optional parameters and ≤ 16 unions per request, and a compiled
36544
+ * grammar under the size Claude refuses — measured as ≤ 60 properties; `strict-schema.ts`). The Site Plan itself
36545
+ * (`SPEC_SITE_PLAN_SHAPE`) has 213 optional keys once every pattern is a branch, so the model never writes it: it writes
36546
+ * this, and ONE pure `expandPlanWire` turns it into the Site Plan that `validateSitePlan` and the stage's gate judge
36547
+ * exactly as before.
36860
36548
  *
36861
- * Two strict requests, built from the plan wire's OWN entries (the vocabulary, the expanders and the gate are the
36862
- * build's): **Pages** first — every redesign, the pages to add with who wanted them and why, the new types those pages
36863
- * need (by name) and the new items an existing type should get (by count) — then **Content**, only when Pages named a new
36864
- * type or new items: the new types in full and the new items' values. The sources a new type is read by are DERIVED
36865
- * (`additionSourcesOf`), never asked — so the Pages request can bind them before the type exists. Pure; no transport.
36866
- */
36867
- /** Who wanted a page the redesign adds. */
36868
- var AdditionOrigin;
36869
- (function (AdditionOrigin) {
36870
- /** The owner's sentence asked for it — staged with its switch ON. */
36871
- AdditionOrigin["Asked"] = "asked";
36872
- /** The reading says the site lacks it — staged with its switch OFF, never added unless the owner turns it on. */
36873
- AdditionOrigin["Suggested"] = "suggested";
36874
- })(AdditionOrigin || (AdditionOrigin = {}));
36875
- /** The two requests, in the order they are asked. */
36876
- var AdditionsPart;
36877
- (function (AdditionsPart) {
36878
- AdditionsPart["Pages"] = "pages";
36879
- AdditionsPart["Content"] = "content";
36880
- })(AdditionsPart || (AdditionsPart = {}));
36881
- /** Each request's format name. */
36882
- const REDESIGN_ADDITIONS_SCHEMA_NAMES = {
36883
- [AdditionsPart.Pages]: 'site_redesign_pages',
36884
- [AdditionsPart.Content]: 'site_redesign_content',
36885
- };
36886
- /** At most this many of each (the build's sample cap for items). */
36887
- const ADDITION_CAPS = { suggested: 2, asked: 6, itemsPerType: 6 };
36888
- /** The suffix of a new type's one-item source (its per-item page reads it by `:slug`). */
36889
- const ADDITION_ITEM_SOURCE_SUFFIX = 'Item';
36890
- /** The field and route param a new type's item page is picked by. */
36891
- const ADDITION_SLUG = 'slug';
36892
- const PAGE_KEYS = {
36893
- origin: `string — ${AdditionOrigin.Asked}: the owner's sentence asks for this page; ${AdditionOrigin.Suggested}: the site lacks it and the owner decides (at most ${ADDITION_CAPS.suggested})`,
36894
- reason: 'string — one plain sentence the owner reads beside the page: what they asked, or why a site like theirs has it',
36895
- };
36896
- const NEW_TYPE_SHAPE = { name: 'string — a NEW content type name (never one the studio has)', label: 'string — its name as the owner reads it' };
36897
- const NEW_ITEMS_SHAPE = { contentType: 'string — a content type the studio HAS, or one of newTypes', count: `number — how many new items (1–${ADDITION_CAPS.itemsPerType}); the owner's sentence must ask for them` };
36898
- const PAGES_SHAPE = {
36899
- pages: 'page[] — ONLY the pages to add, each at an address the studio does not have; [] = none',
36900
- newTypes: 'newType[] — the new kinds of content the new pages need; [] = none',
36901
- newItems: 'newItems[] — new items the sentence asks for; [] = none',
36902
- };
36903
- const ITEM_SHAPE = { contentType: 'string — the type the item goes into', values: 'seedValue[] — its field values; a fact the owner did not give stays empty' };
36904
- const CONTENT_SHAPE = {
36905
- contentTypes: 'contentType[] — exactly the new types named, in full (a per-item page needs a slug field)',
36906
- items: 'item[] — the new items, one entry each',
36549
+ * - **Written in two PARTS, one request each** (#47 — the whole plan in one format was 64 properties): the **structure** (the business,
36550
+ * the content types, the data sources) and then the **pages** (the pages, the header and footer), written knowing the
36551
+ * structure. Every top-level key belongs to exactly one part (`part` below); `expandPlanWire` puts the parts together.
36552
+ *
36553
+ * - **Every key required.** A plan key that may be absent is written with its stated "none" — `''`, `0`, `false`, `[]`.
36554
+ * - **Closed lists as enums** (patterns, page types, needs, slots, parts, forms, entrances, header/footer), from the
36555
+ * contract — never per-pattern branches: the gate refuses a slot or a part the chosen pattern does not have, with its path.
36556
+ * - **Maps as lists:** slots `[{ slot, text }]`, links `[{ slot, route }]`, seed values `[{ field, value }]`, roles `[{ role, field }]`.
36557
+ * - **One data source object** for both kinds; `type` says which keys are read (the other kind's hold their none).
36558
+ * - **What the model does not decide is not on the wire** (`PLAN_WIRE_DERIVED`): the look (the owner's pick), the run,
36559
+ * the language (the reading's), the facts (the owner's own, verbatim), the version, the home page (the page at `/`).
36560
+ * So the format is the same for every studio and every run — one compiled grammar, cached by the provider.
36561
+ * - **What follows from the pages is derived, never asked** (`plan-derived.ts`, vectoriox/iox-cms#49): a per-item page
36562
+ * reading the next item gets its `$siblings.next` source — the structure, asked first and then fixed, cannot know the
36563
+ * pages need it, and the pages cannot add a source. `planToWire` writes every source the plan holds, a derived one
36564
+ * too (it is the plan's: a change's brief shows it, and a plan → wire → plan round trip stays exact).
36565
+ *
36566
+ * ONE source: every wire key names the plan keys it carries (`refs`) and is described in the plan table's own words, and
36567
+ * every plan key is either carried or derived (`planWireGaps()`); a key the plan shape gains breaks the builder until it
36568
+ * is placed. The expanders translate, never repair: a value the model got wrong stays wrong, for the gate to refuse.
36569
+ */
36570
+ /** The plan's parts, in the order they are written: the pages bind to the structure's sources and types. */
36571
+ var PlanPart;
36572
+ (function (PlanPart) {
36573
+ PlanPart["Structure"] = "structure";
36574
+ PlanPart["Pages"] = "pages";
36575
+ })(PlanPart || (PlanPart = {}));
36576
+ const PLAN_PARTS = [PlanPart.Structure, PlanPart.Pages];
36577
+ /** Each part's format name (a request names the format it asks for). */
36578
+ const PLAN_WIRE_PART_SCHEMA_NAMES = {
36579
+ [PlanPart.Structure]: 'site_plan_structure',
36580
+ [PlanPart.Pages]: 'site_plan_pages',
36907
36581
  };
36908
- const withKeys = (schema, extra) => {
36909
- const s = schema;
36910
- return { ...schema, properties: { ...s.properties, ...extra }, required: [...s.required, ...Object.keys(extra)] };
36582
+ var PlanWireEntry;
36583
+ (function (PlanWireEntry) {
36584
+ PlanWireEntry["Plan"] = "plan";
36585
+ PlanWireEntry["Business"] = "business";
36586
+ PlanWireEntry["ContentType"] = "contentType";
36587
+ PlanWireEntry["RoleField"] = "roleField";
36588
+ PlanWireEntry["Field"] = "field";
36589
+ PlanWireEntry["Seed"] = "seed";
36590
+ PlanWireEntry["SeedValue"] = "seedValue";
36591
+ PlanWireEntry["DataSource"] = "dataSource";
36592
+ PlanWireEntry["Page"] = "page";
36593
+ PlanWireEntry["PageSeo"] = "pageSeo";
36594
+ PlanWireEntry["Section"] = "section";
36595
+ PlanWireEntry["SlotText"] = "slotText";
36596
+ PlanWireEntry["SlotLink"] = "slotLink";
36597
+ PlanWireEntry["Globals"] = "globals";
36598
+ PlanWireEntry["Direction"] = "direction";
36599
+ /** Commerce C-D21: one product the business sells, by name. */
36600
+ PlanWireEntry["ShopProduct"] = "shopProduct";
36601
+ PlanWireEntry["ShopOption"] = "shopOption";
36602
+ })(PlanWireEntry || (PlanWireEntry = {}));
36603
+ const PLAN_SHAPE = SPEC_SITE_PLAN_SHAPE;
36604
+ const key = (ref, none) => ({ refs: [ref], ...(none !== undefined ? { none } : {}) });
36605
+ const inPart = (part, spec) => ({ ...spec, part });
36606
+ /** The roles a content type's fields play (`roles` of the plan shape), in the plan shape's order — less the item page's
36607
+ * own (X4 `ITEM_PAGE_ONLY_ROLES`: an imported item's text is never the model's to write). */
36608
+ const ROLE_KEYS = shapeKeys(PLAN_SHAPE['roles']).filter(role => !ITEM_PAGE_ONLY_ROLES.includes(role));
36609
+ const roleWords = ROLE_KEYS.map(role => `${role}: ${describeShapeKey(PLAN_SHAPE['roles'], role).replace(/^string — /, '')}`).join('; ');
36610
+ /** The footer's words as the model reads them (LI5): each ingredient, its words and their meanings, from the contract. */
36611
+ const FOOTER_WIRE_TEXT = 'string[] — the footer as ONE list of <ingredient>:<word> words: one word per ingredient but "holds", which lists '
36612
+ + `each block it holds (holds:pages, holds:contact); an ingredient left out is the default (${footerMixWords(footerMix()).join(', ')}). `
36613
+ + Object.values(FooterIngredient).map(k => `${k}: ${footerWords(k).map(w => `${w} (${footerMeaning(k, w)})`).join(' | ')}`).join('; ');
36614
+ /** The wire's `globals` key the home page's opening travels in (AW8) — a mix beside the header's and the footer's. */
36615
+ const OPENING_WIRE_KEY = 'opening';
36616
+ /** The opening's words as the model reads them (AW8): each ingredient, the words the product draws, their meanings and
36617
+ * which the award plan alone wears, from the contract's opening table. */
36618
+ const OPENING_WIRE_TEXT = "string[] — the home page's opening (its first screen) as ONE list of <ingredient>:<word> words: one word per "
36619
+ + `ingredient but extras and motion, which list each they take; an ingredient left out is the default; [] = the home page opens with its first `
36620
+ + "section as written. The opening takes the place of the home page's first section when that is a hero (its words and pictures carried in); "
36621
+ + 'a word marked (award) is worn by an award build only — elsewhere it is mended. '
36622
+ + Object.values(OpeningIngredient).map(k => `${k}: ${openingWireWords(GenerationTier.Award).filter(w => w.startsWith(`${k}:`)).map(w => w.slice(k.length + 1))
36623
+ .map(w => `${w} (${openingMeaning(k, w)}${openingWordTier(k, w) === 'pro' ? ', award' : ''}${openingHarnessWord(k, w) ? ', the build\'s own — keep it where the plan has it, never choose it' : ''})`).join(' | ')}`).join('; ');
36624
+ /** The header's words as the model reads them (HI1): each ingredient, the words the product draws and their meanings,
36625
+ * from the contract's header table. */
36626
+ const HEADER_WIRE_TEXT = 'string[] — the header as ONE list of <ingredient>:<word> words, one word per ingredient; an ingredient left out is the '
36627
+ + `default (${headerMixWords(headerMix()).join(', ')}). The site decides what it can carry: a menu needs three pages or more, the pages in the bar must fit `
36628
+ + 'beside the name, pages either side of the name need a short name, two actions need a shop. '
36629
+ + Object.values(HeaderIngredient).map(k => `${k}: ${headerWireWords().filter(w => w.startsWith(`${k}:`)).map(w => w.slice(k.length + 1)).map(w => `${w} (${headerMeaning(k, w)})`).join(' | ')}`).join('; ');
36630
+ /** The wire's `globals` key the site's body travels in (AW6) — the award tier's alone (AW-D23…D25). */
36631
+ const BODY_WIRE_KEY = 'body';
36632
+ /** The body's words as the model reads them (AW6): each ingredient, the words an award build may wear today and their
36633
+ * meanings, from the contract's body table. */
36634
+ const BODY_WIRE_TEXT = "string[] — the site's body as ONE list of <ingredient>:<word> words: how its sections meet and how their grounds "
36635
+ + `follow one another; one word per ingredient but sections, which lists each extra kind it takes; an ingredient left out is the default `
36636
+ + `(${bodyMixWords(bodyMix()).join(', ')}); [] = straight edges, each section's ground its own. An edge shows only where two neighbouring `
36637
+ + 'sections wear different grounds; a calm business (care, advice) never wears a torn or dripping edge. '
36638
+ + Object.values(BodyIngredient).map(k => [k, bodyWireWords(GenerationTier.Award).filter(w => w.startsWith(`${k}:`)).map(w => w.slice(k.length + 1))])
36639
+ .filter(([, words]) => words.length)
36640
+ .map(([k, words]) => `${k}: ${words.map(w => `${w} (${bodyMeaning(k, w)})`).join(' | ')}`).join('; ');
36641
+ /** The wire's `globals` key the site's popup travels in (popups PU3) — a mix beside the others; [] = no popup. */
36642
+ const POPUP_WIRE_KEY = 'popup';
36643
+ /** The popup's words as the model reads them (PU3): each ingredient the wire carries, its words and their meanings, from the
36644
+ * contract's popup table; the link names a page of this plan. Text items: a page key is the plan's own word, never a list. */
36645
+ const POPUP_WIRE_TEXT = "string[] — the site's popup as ONE list of <ingredient>:<word> words, ONLY when the owner's popup lines ask for one "
36646
+ + "(the context says so): [] otherwise. Never a word of copy — the popup says the owner's news as stated. One word per ingredient; "
36647
+ + 'an ingredient left out is the kind\'s own. '
36648
+ + POPUP_WIRE_INGREDIENTS.map(k => `${k}: ${popupWireWords().filter(w => w.startsWith(`${k}:`)).map(w => w.slice(k.length + 1))
36649
+ .map(w => `${w} (${popupMeaning(k, w)})`).join(' | ')}`).join('; ')
36650
+ + `; ${POPUP_LINK_WORD}:<page key> — the page of this plan the popup's one action opens (the offer's page if there is one; never the home page).`;
36651
+ const WIRE_KEYS = {
36652
+ plan: {
36653
+ business: inPart(PlanPart.Structure, key('plan.business')),
36654
+ contentTypes: inPart(PlanPart.Structure, key('plan.contentTypes')),
36655
+ dataSources: inPart(PlanPart.Structure, { refs: ['plan.dataSources'], text: "dataSource[] — merged by alias into the org library; a per-item page's $siblings.next source (what a section reading the next item needs) is added for you, and so are the shop's sources when the business sells" }),
36656
+ shop: inPart(PlanPart.Structure, {
36657
+ refs: ['plan.shop', 'shop.products'],
36658
+ text: `shopProduct[] — what the business sells, when it sells (the need "products"): at most 6 sample products by name, each in a category — never a price, stock or a fee. [] = it sells nothing. Its categories, the shop's data sources (the products, the newest, one product by its :slug) and the store's parts are added for you`,
36659
+ }),
36660
+ pages: inPart(PlanPart.Pages, key('plan.pages')),
36661
+ globals: inPart(PlanPart.Pages, key('plan.globals')),
36662
+ direction: inPart(PlanPart.Pages, key('plan.direction')),
36663
+ },
36664
+ direction: {
36665
+ idea: key('direction.idea'),
36666
+ cliche: key('direction.cliche'),
36667
+ flip: key('direction.flip'),
36668
+ rules: key('direction.rules'),
36669
+ },
36670
+ business: {
36671
+ name: key('business.name'),
36672
+ tagline: key('business.tagline', "''"),
36673
+ },
36674
+ contentType: {
36675
+ name: key('contentType.name'),
36676
+ label: key('contentType.label'),
36677
+ roles: { refs: ['contentType.roles'], text: `roleField[] — ${describeShapeKey(PLAN_SHAPE['contentType'], 'roles').replace(/^roles — /, '')}; a role no field plays is left out` },
36678
+ fields: key('contentType.fields'),
36679
+ seed: { refs: ['contentType.seed'], text: 'seed — the sample items', none: 'count 0 and no values' },
36680
+ },
36681
+ roleField: {
36682
+ role: { refs: ROLE_KEYS.map(role => `roles.${role}`), text: `${ROLE_KEYS.map(r => `'${r}'`).join(' | ')} — ${roleWords}` },
36683
+ field: { refs: ['roles.title'], text: 'string — the field of the type that plays it' },
36684
+ },
36685
+ field: {
36686
+ name: key('field.name'),
36687
+ controller: { refs: ['field.controller'], text: `one of ${Object.values(ContentFieldControl).join(', ')} — how the field is edited (gallery is a list of pictures, list a list of words); how it is stored follows from this` },
36688
+ required: { refs: ['field.required'], text: 'boolean — the field must be filled', none: 'false' },
36689
+ note: key('field.note', "''"),
36690
+ },
36691
+ seed: {
36692
+ count: key('seed.count'),
36693
+ sample: key('seed.sample'),
36694
+ isPublished: key('seed.isPublished'),
36695
+ values: { refs: ['seed.[field]'], text: "seedValue[] — one per field, for EVERY field: the samples' value for it, with {n} for the sample's number and {sampleImage:n} for a picture, words a person replaces" },
36696
+ },
36697
+ seedValue: {
36698
+ field: { refs: ['seed.[field]'], text: 'string — a field of the type' },
36699
+ value: { refs: ['seed.[field]'], text: `string | string[] — ${describeShapeKey(PLAN_SHAPE['seed'], '[field]')} (a list for an array field)` },
36700
+ each: { refs: ['seed.perItem'], text: 'string[] — one value per sample, in order, when each sample has its own content', none: '[]' },
36701
+ },
36702
+ dataSource: {
36703
+ alias: { refs: ['cmsDataSource.alias', 'relativeDataSource.alias', 'shopDataSource.alias'] },
36704
+ type: { refs: ['cmsDataSource.type', 'relativeDataSource.type', 'shopDataSource.type'], text: "'cms' | 'relative' | 'shop' — which of the keys below are read ('shop' sources are added for you)" },
36705
+ mode: { refs: ['cmsDataSource.mode', 'shopDataSource.mode'], none: "'' (relative)" },
36706
+ contentType: { refs: ['cmsDataSource.contentType', 'shopDataSource.resource'], text: "string — a content type of the plan (cms); the shop's list, 'products' or 'categories' (shop)", none: "'' (relative)" },
36707
+ limit: { refs: ['cmsDataSource.limit', 'shopDataSource.limit'], none: '0 (all, or relative)' },
36708
+ filterField: { refs: ['cmsDataSource.filterByRouteParam', 'shopDataSource.filterByRouteParam'], text: "string — single only: the field that holds the route param's value (e.g. slug)", none: "''" },
36709
+ routeParam: { refs: ['cmsDataSource.filterByRouteParam', 'shopDataSource.filterByRouteParam'], text: 'string — single only: the route param that picks the item (the :param of its page route)', none: "''" },
36710
+ of: key('relativeDataSource.of', "'' (cms)"),
36711
+ op: key('relativeDataSource.op', "'' (cms)"),
36712
+ within: key('relativeDataSource.within', "'' (cms)"),
36713
+ },
36714
+ page: {
36715
+ key: key('page.key'),
36716
+ name: key('page.name'),
36717
+ route: { refs: ['page.route'], text: `${describeShapeKey(PLAN_SHAPE['page'], 'route')}; the page at "/" is the home page` },
36718
+ inNav: key('page.inNav', 'false'),
36719
+ archetype: key('page.archetype', "''"),
36720
+ need: key('page.need', "''"),
36721
+ template: key('page.template', "''"),
36722
+ routeSource: key('page.routeSource', "''"),
36723
+ seo: key('page.seo'),
36724
+ sections: key('page.sections'),
36725
+ compose: key('page.compose', 'false'),
36726
+ },
36727
+ pageSeo: {
36728
+ title: key('pageSeo.title', "''"),
36729
+ description: key('pageSeo.description', "''"),
36730
+ },
36731
+ section: {
36732
+ pattern: key('section.pattern'),
36733
+ slots: { refs: ['section.slots'], text: "slotText[] — the pattern's declared slots it fills, each within its budget (site.patterns … max × site.copyLengths)", none: '[]' },
36734
+ links: { refs: ['section.links'], text: 'slotLink[] — re-points a linked slot (a button, a link) to another page route of the plan', none: '[]' },
36735
+ binding: key('section.binding', "''"),
36736
+ without: key('section.without', '[]'),
36737
+ form: key('section.form', "''"),
36738
+ enter: key('section.enter', "'' (the look's)"),
36739
+ },
36740
+ slotText: {
36741
+ slot: { refs: ['section.slots'], text: "string — one of the pattern's slots" },
36742
+ text: { refs: ['section.slots'], text: "string — the words, in the owner's language and voice" },
36743
+ },
36744
+ slotLink: {
36745
+ slot: { refs: ['section.links'], text: "string — one of the pattern's linked slots" },
36746
+ route: { refs: ['section.links'], text: 'string — a page route of the plan (no :param)' },
36747
+ },
36748
+ globals: {
36749
+ // HI1: the header travels as its MIX — like the footer, ONE list of `<ingredient>:<word>` words (header-mix.ts).
36750
+ header: { refs: ['globals.header', 'plan.mixes', 'mixes.header'], text: HEADER_WIRE_TEXT },
36751
+ // LI5: the footer travels as its MIX — ONE list of `<ingredient>:<word>` words (footer-mix.ts), every word with its
36752
+ // meaning from the contract's footer table; the plan keeps the pattern it reads as (`globals.footer`) and the mix.
36753
+ footer: { refs: ['globals.footer', 'plan.mixes', 'mixes.footer'], text: FOOTER_WIRE_TEXT },
36754
+ // AW8: the home page's opening travels as its MIX, ONE list of `<ingredient>:<word>` words (opening-mix.ts); [] = none.
36755
+ opening: { refs: ['plan.mixes', 'mixes.opening'], text: OPENING_WIRE_TEXT },
36756
+ // AW6: the site's body travels as its MIX, ONE list of `<ingredient>:<word>` words (body-mix.ts); [] = none. The award
36757
+ // tier's request alone carries it (AW-D23…D25): a Basic wire is without the key, so its grammar is the one it was.
36758
+ body: { refs: ['plan.mixes', 'mixes.body'], text: BODY_WIRE_TEXT, tier: GenerationTier.Award },
36759
+ // PU3: the popup travels as its words, ONE list (popup-plan.ts); [] = none. Stamped only from the owner's lines (plan.popup).
36760
+ popup: { refs: ['plan.mixes', 'mixes.popup'], text: POPUP_WIRE_TEXT },
36761
+ },
36762
+ shopProduct: {
36763
+ name: key('shopProduct.name'),
36764
+ category: key('shopProduct.category'),
36765
+ description: key('shopProduct.description'),
36766
+ options: key('shopProduct.options'),
36767
+ },
36768
+ shopOption: {
36769
+ name: key('shopOption.name'),
36770
+ values: key('shopOption.values'),
36771
+ },
36911
36772
  };
36912
- /** The format a model writes one additions request in (≤ 40 properties each — `redesign-additions.spec`). */
36913
- function redesignAdditionsJsonSchema(part) {
36914
- if (part === AdditionsPart.Pages) {
36915
- const page = withKeys(wirePageJsonSchema(), {
36916
- origin: { ...jsonOneOf(Object.values(AdditionOrigin)), description: PAGE_KEYS['origin'] },
36917
- reason: { ...jsonText(), description: PAGE_KEYS['reason'] },
36918
- });
36919
- return jsonShapedObject(PAGES_SHAPE, {
36920
- pages: jsonListOf(page),
36921
- newTypes: jsonListOf(jsonShapedObject(NEW_TYPE_SHAPE, { name: jsonText(), label: jsonText() }, 'additions newType')),
36922
- newItems: jsonListOf(jsonShapedObject(NEW_ITEMS_SHAPE, { contentType: jsonText(), count: jsonInteger() }, 'additions newItems')),
36923
- }, 'additions pages');
36924
- }
36925
- const value = jsonShapedObject(PLAN_WIRE_SHAPE[PlanWireEntry.SeedValue], { field: jsonText(), value: jsonAnyOf([jsonText(), jsonListOf(jsonText())]), each: jsonListOf(jsonText()) }, 'additions seedValue');
36926
- return jsonShapedObject(CONTENT_SHAPE, {
36927
- contentTypes: jsonListOf(wireContentTypeJsonSchema()),
36928
- items: jsonListOf(jsonShapedObject(ITEM_SHAPE, { contentType: jsonText(), values: jsonListOf(value) }, 'additions item')),
36929
- }, 'additions content');
36930
- }
36931
- /** The sources a new type is read by — derived, never asked: the list (`<type>`) and one item by `:slug`. */
36932
- function additionSourcesOf(typeName) {
36933
- return [
36934
- { alias: typeName, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Query, contentType: typeName },
36935
- { alias: `${typeName}${ADDITION_ITEM_SOURCE_SUFFIX}`, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Single, contentType: typeName, filterByRouteParam: { field: ADDITION_SLUG, routeParam: ADDITION_SLUG } },
36936
- ];
36937
- }
36938
- const list = (value) => (Array.isArray(value) ? value : []);
36939
- const text = (value) => (typeof value === 'string' ? value : '');
36940
- /** Does the Pages answer ask for content (so the Content request is asked). */
36941
- function additionsNeedContent(pagesAnswer) {
36942
- return isPlainObject(pagesAnswer) && (list(pagesAnswer['newTypes']).length > 0 || list(pagesAnswer['newItems']).length > 0);
36773
+ /** The plan keys the model does not write, and where the expander takes each from. */
36774
+ const PLAN_WIRE_DERIVED = {
36775
+ 'field.type': 'follows from the field\'s control (FIELD_TYPE_OF_CONTROL)',
36776
+ 'plan.version': `always '${SITE_PLAN_VERSION}'`,
36777
+ 'plan.source': 'this run (the context)',
36778
+ 'plan.locale': "the reading's language (the context)",
36779
+ 'plan.design': "the owner's pick (the context)",
36780
+ 'business.facts': "the owner's own facts, verbatim (the context)",
36781
+ 'page.isHome': 'the page at "/"',
36782
+ 'page.required': "a template page's (the wizard's Pages step), never the AI's",
36783
+ sourceTemplate: 'the AI never writes a template plan',
36784
+ sourceAi: 'this run (the context)',
36785
+ sourceImport: 'the AI never writes an import plan (Bring my site X4 — planImport)',
36786
+ 'roles.body': "an imported item's own text (Bring my site X4) — never the model's",
36787
+ 'seed.importedFrom': 'the old addresses of real items read from a site (Bring my site X4) — never the model\'s',
36788
+ design: "the owner's pick (the context)",
36789
+ 'plan.film': "the owner's film, set by the build (SC6b)",
36790
+ film: "the owner's film, set by the build (SC6b)",
36791
+ 'plan.artDirection': 'the generation, from the business type and the look (M7 — artDirectionFor)',
36792
+ artDirection: 'the generation, from the business type and the look (M7 — artDirectionFor)',
36793
+ 'page.layout': 'the layout step: one request per composed page, after the pages (M8 gate 2)',
36794
+ 'shop.categories': "the products' own categories, in order (shopCategoriesOf)",
36795
+ layoutPage: 'the layout step: one request per composed page, after the pages (M8 gate 2)',
36796
+ 'page.free': 'the free step: a page the model writes free, on its own wire, set by the server (FS3)',
36797
+ 'section.free': 'the free step: one signature section written free, set by the server (FS3, FS-D19)',
36798
+ freePage: 'the free step: a page the model writes free, on its own wire, set by the server (FS3)',
36799
+ freeRead: 'the free step (FS3)',
36800
+ freeNode: 'the free step (FS3)',
36801
+ 'plan.popup': "the owner's popup lines: the reading's stated news and the Plan step's ticks (the context, popups PU3)",
36802
+ popupLines: "the owner's popup lines (the context, popups PU3)",
36803
+ statedFact: "the reading's stated fact (the context, popups PU3)",
36804
+ };
36805
+ const wireText = (spec) => {
36806
+ const [entry, planKey] = spec.refs[0].split('.');
36807
+ const base = spec.text ?? describeShapeKey(PLAN_SHAPE[entry], planKey);
36808
+ return spec.none === undefined ? base : `${base} — ${spec.none} = none`;
36809
+ };
36810
+ const isAward = (options) => options.tier === GenerationTier.Award;
36811
+ /** Is a wire key on the request asked at `options`? (A key with no tier is on every request.) */
36812
+ const asked = (spec, options) => !spec.tier || (spec.tier === GenerationTier.Award && isAward(options));
36813
+ const wireShapeAt = (options) => Object.fromEntries(Object.entries(WIRE_KEYS).map(([entry, keys]) => [entry, Object.fromEntries(Object.entries(keys).filter(([, spec]) => asked(spec, options)).map(([k, spec]) => [k, wireText(spec)]))]));
36814
+ /** The wire's shape table, in the plan table's words — what the model reads, and what the format is built from. The
36815
+ * Basic tier's (every tier's but the award's); `planWireShape(options)` gives a tier's own. */
36816
+ const PLAN_WIRE_SHAPE = wireShapeAt({});
36817
+ const AWARD_WIRE_SHAPE = wireShapeAt({ tier: GenerationTier.Award });
36818
+ /** The wire's shape table a request at `options` reads (AW6: the award tier's carries the body). Basic = `PLAN_WIRE_SHAPE`. */
36819
+ function planWireShape(options = {}) {
36820
+ return isAward(options) ? AWARD_WIRE_SHAPE : PLAN_WIRE_SHAPE;
36943
36821
  }
36822
+ /** Each part's top-level keys, from the ONE wire table. */
36823
+ const PLAN_PART_KEYS = Object.fromEntries(PLAN_PARTS.map(part => [part, Object.entries(WIRE_KEYS.plan).filter(([, spec]) => spec.part === part).map(([k]) => k)]));
36824
+ /** The keys of a shape entry, but these. */
36825
+ const shapeWithout = (entry, keys) => Object.fromEntries(Object.entries(entry).filter(([k]) => !keys.includes(k.replace(/\?$/, ''))));
36944
36826
  /**
36945
- * The answers → what the redesign adds. Translates, never repairs (as `expandPlanWire`): a wrong value stays wrong, for
36946
- * `checkAdditions`. The Content answer is absent when it was not asked.
36827
+ * The part a plan path is the answer of (`contentTypes[1].seed.title` → structure, `pages[0].sections[2]` → pages). A
36828
+ * path no part writes — the root (the composer), or a key the generation decides — is the LAST part's: it is written
36829
+ * knowing everything before it.
36947
36830
  */
36948
- function expandAdditions(pagesAnswer, contentAnswer) {
36949
- const pages = isPlainObject(pagesAnswer) ? pagesAnswer : {};
36950
- const content = isPlainObject(contentAnswer) ? contentAnswer : {};
36951
- const newTypes = list(pages['newTypes']).filter(isPlainObject).map(t => ({ name: text(t['name']), label: text(t['label']) }));
36952
- return {
36953
- pages: list(pages['pages']).filter(isPlainObject).map(wire => {
36954
- const { origin, reason, ...page } = wire;
36955
- return { page: expandWirePage(page), origin: origin, reason: text(reason) };
36956
- }),
36957
- contentTypes: list(content['contentTypes']).map(t => expandWireContentType(t)),
36958
- dataSources: newTypes.filter(t => t.name).flatMap(t => additionSourcesOf(t.name)),
36959
- items: list(content['items']).filter(isPlainObject).map(item => ({
36960
- contentType: text(item['contentType']),
36961
- values: Object.fromEntries(list(item['values']).filter(isPlainObject).map(v => [text(v['field']), v['value']])),
36962
- })),
36963
- asks: {
36964
- newTypes,
36965
- newItems: list(pages['newItems']).filter(isPlainObject).map(n => ({ contentType: text(n['contentType']), count: Number(n['count']) || 0 })),
36966
- },
36967
- };
36831
+ function planPartOfPath(path) {
36832
+ const top = path.split(/[.[]/, 1)[0];
36833
+ return PLAN_PARTS.find(part => PLAN_PART_KEYS[part].includes(top)) ?? PLAN_PARTS[PLAN_PARTS.length - 1];
36968
36834
  }
36969
- /** What `checkAdditions` refuses. */
36970
- var AdditionIssueCode;
36971
- (function (AdditionIssueCode) {
36972
- /** A new page at an address the studio (or another addition) already has. */
36973
- AdditionIssueCode["RouteTaken"] = "addition-route-taken";
36974
- /** A new type whose name the studio already has — an existing type is never changed. */
36975
- AdditionIssueCode["TypeExists"] = "addition-type-exists";
36976
- /** An item, or a page's binding, for a type that is neither the studio's nor a new one. */
36977
- AdditionIssueCode["TypeUnknown"] = "addition-type-unknown";
36978
- /** A binding to a source that is neither the studio's nor a new type's derived one. */
36979
- AdditionIssueCode["SourceUnknown"] = "addition-source-unknown";
36980
- /** An `asked` page or new items with no sentence to ask for them. */
36981
- AdditionIssueCode["NotAsked"] = "addition-not-asked";
36982
- /** More than `ADDITION_CAPS` allows. */
36983
- AdditionIssueCode["TooMany"] = "addition-too-many";
36984
- /** A new type named by Pages that Content did not write (or wrote twice), or one written that Pages did not name. */
36985
- AdditionIssueCode["TypeMismatch"] = "addition-type-mismatch";
36986
- })(AdditionIssueCode || (AdditionIssueCode = {}));
36987
- const routeKey = (route) => (route.replace(/\/+$/, '') || '/').toLowerCase();
36988
- /**
36989
- * THE additive check (§3e): every page at a new address, every new type a new name, every item into a known type, every
36990
- * binding to a known source, `asked` only with a sentence, the caps held, and the Content answer exactly the types Pages
36991
- * named. Refuses with a path; never repairs. An existing type's FIELDS cannot be expressed by the format at all.
36992
- */
36993
- function checkAdditions(additions, studio) {
36994
- const issues = [];
36995
- const say = (code, path, message) => issues.push({ code, path, message });
36996
- const asked = !!studio.prompt.trim();
36997
- const taken = new Set(studio.routes.map(routeKey));
36998
- const types = new Set(studio.contentTypes);
36999
- const newTypes = new Set(additions.asks.newTypes.map(t => t.name));
37000
- const sources = new Set([...studio.dataSources, ...additions.dataSources.map(s => s.alias)]);
37001
- additions.pages.forEach(({ page, origin }, i) => {
37002
- const key = routeKey(String(page?.route ?? ''));
37003
- if (taken.has(key))
37004
- say(AdditionIssueCode.RouteTaken, `pages[${i}].route`, `${page.route} is already a page of this site — a new page takes a new address`);
37005
- taken.add(key);
37006
- if (origin === AdditionOrigin.Asked && !asked)
37007
- say(AdditionIssueCode.NotAsked, `pages[${i}].origin`, 'nothing was asked: a page the site lacks is "suggested"');
37008
- if (page.template && !types.has(page.template) && !newTypes.has(page.template))
37009
- say(AdditionIssueCode.TypeUnknown, `pages[${i}].template`, `"${page.template}" is not a content type of this site or a new one`);
37010
- for (const [alias, path] of [[page.routeSource, `pages[${i}].routeSource`], ...(page.sections ?? []).map((s, j) => [s.binding, `pages[${i}].sections[${j}].binding`])]) {
37011
- if (alias && !sources.has(alias))
37012
- say(AdditionIssueCode.SourceUnknown, path, `"${alias}" is not a source of this site or of a new type`);
36835
+ /** Plan keys neither carried by a wire key nor derived — always empty (a spec and the builder hold it). */
36836
+ function planWireGaps() {
36837
+ const carried = new Set(Object.values(WIRE_KEYS).flatMap(keys => Object.values(keys).flatMap(spec => spec.refs)));
36838
+ const gaps = [];
36839
+ for (const [entry, shape] of Object.entries(PLAN_SHAPE)) {
36840
+ if (PLAN_WIRE_DERIVED[entry])
36841
+ continue;
36842
+ for (const raw of Object.keys(shape)) {
36843
+ const ref = `${entry}.${raw.replace(/\?$/, '')}`;
36844
+ if (!carried.has(ref) && !PLAN_WIRE_DERIVED[ref])
36845
+ gaps.push(ref);
37013
36846
  }
36847
+ }
36848
+ return gaps;
36849
+ }
36850
+ class PlanWireShapeError extends Error {
36851
+ }
36852
+ // ── The format ─────────────────────────────────────────────────────────────────────────────────────────────────────
36853
+ const unique = (values) => [...new Set(values)];
36854
+ const NONE = '';
36855
+ const orNone = (values) => jsonOneOf([NONE, ...values]);
36856
+ const closedOrText = (values) => (values.length ? jsonOneOf(values) : jsonText());
36857
+ const shaped = (entry, properties) => jsonShapedObject(PLAN_WIRE_SHAPE[entry], properties, `wire ${entry}`);
36858
+ /** The patterns a page section may use (every non-global one but a film's, which `placeFilm` places), in library order. */
36859
+ function sectionPatternIds() {
36860
+ return Object.entries(SITE_PATTERNS).filter(([, p]) => !p.global && !p.film && !p.imported).map(([id]) => id);
36861
+ }
36862
+ const sectionPatterns = () => sectionPatternIds().map(id => SITE_PATTERNS[id]);
36863
+ function wireFieldJsonSchema() {
36864
+ return shaped(PlanWireEntry.Field, { name: jsonText(), controller: jsonOneOf(Object.values(ContentFieldControl)), required: jsonBoolean(), note: jsonText() });
36865
+ }
36866
+ /** The keys an entry leaves out under `options`. */
36867
+ const CHILD_KEYS = { contentType: 'fields', page: 'sections' };
36868
+ const childless = (entry, options) => (options.children === false && CHILD_KEYS[entry] ? [CHILD_KEYS[entry]] : []);
36869
+ /** The shape an entry is written in, under `options`. */
36870
+ function wireEntryShape(entry, options = {}) {
36871
+ return shapeWithout(PLAN_WIRE_SHAPE[entry], childless(entry, options));
36872
+ }
36873
+ const shapedAs = (entry, options, properties) => {
36874
+ const left = childless(entry, options);
36875
+ return jsonShapedObject(wireEntryShape(entry, options), Object.fromEntries(Object.entries(properties).filter(([k]) => !left.includes(k))), `wire ${entry}`);
36876
+ };
36877
+ function wireContentTypeJsonSchema(options = {}) {
36878
+ const value = shaped(PlanWireEntry.SeedValue, { field: jsonText(), value: jsonAnyOf([jsonText(), jsonListOf(jsonText())]), each: jsonListOf(jsonText()) });
36879
+ return shapedAs(PlanWireEntry.ContentType, options, {
36880
+ name: jsonText(),
36881
+ label: jsonText(),
36882
+ roles: jsonListOf(shaped(PlanWireEntry.RoleField, { role: jsonOneOf(ROLE_KEYS), field: jsonText() })),
36883
+ fields: jsonListOf(wireFieldJsonSchema()),
36884
+ seed: shaped(PlanWireEntry.Seed, { count: jsonInteger(), sample: jsonBoolean(), isPublished: jsonBoolean(), values: jsonListOf(value) }),
37014
36885
  });
37015
- const suggested = additions.pages.filter(p => p.origin === AdditionOrigin.Suggested).length;
37016
- const askedPages = additions.pages.filter(p => p.origin === AdditionOrigin.Asked).length;
37017
- if (suggested > ADDITION_CAPS.suggested)
37018
- say(AdditionIssueCode.TooMany, 'pages', `${suggested} suggested pages — at most ${ADDITION_CAPS.suggested}`);
37019
- if (askedPages > ADDITION_CAPS.asked)
37020
- say(AdditionIssueCode.TooMany, 'pages', `${askedPages} asked pages — at most ${ADDITION_CAPS.asked}`);
37021
- additions.asks.newTypes.forEach((t, i) => {
37022
- if (types.has(t.name))
37023
- say(AdditionIssueCode.TypeExists, `newTypes[${i}].name`, `"${t.name}" is already a content type — an existing type is never changed`);
36886
+ }
36887
+ function wireDataSourceJsonSchema() {
36888
+ return shaped(PlanWireEntry.DataSource, {
36889
+ alias: jsonText(),
36890
+ type: jsonOneOf(Object.values(PlanDataSourceType)),
36891
+ mode: orNone(Object.values(PlanDataSourceMode)),
36892
+ contentType: jsonText(),
36893
+ limit: jsonInteger(),
36894
+ filterField: jsonText(),
36895
+ routeParam: jsonText(),
36896
+ of: jsonText(),
36897
+ op: orNone(Object.values(RelativeOp)),
36898
+ within: jsonText(),
37024
36899
  });
37025
- const written = additions.contentTypes.map(t => t?.name);
37026
- additions.contentTypes.forEach((t, i) => {
37027
- if (types.has(t?.name))
37028
- say(AdditionIssueCode.TypeExists, `contentTypes[${i}].name`, `"${t.name}" is already a content type — an existing type is never changed`);
37029
- else if (!newTypes.has(t?.name) || written.indexOf(t.name) !== i)
37030
- say(AdditionIssueCode.TypeMismatch, `contentTypes[${i}].name`, `"${t?.name}" is not one of the new types named, once each`);
36900
+ }
36901
+ function wireSectionJsonSchema() {
36902
+ const patterns = sectionPatterns();
36903
+ return shaped(PlanWireEntry.Section, {
36904
+ pattern: jsonOneOf(sectionPatternIds()),
36905
+ slots: jsonListOf(shaped(PlanWireEntry.SlotText, { slot: closedOrText(unique(patterns.flatMap(patternSlots))), text: jsonText() })),
36906
+ links: jsonListOf(shaped(PlanWireEntry.SlotLink, { slot: closedOrText(unique(patterns.flatMap(patternLinkSlots))), route: jsonText() })),
36907
+ binding: jsonText(),
36908
+ without: jsonListOf(closedOrText(unique(patterns.flatMap(patternOptionalParts)))),
36909
+ form: orNone(planFormPresetIds()),
36910
+ enter: orNone(ANIMATE_IDS),
37031
36911
  });
37032
- for (const name of newTypes)
37033
- if (additions.contentTypes.length && !written.includes(name))
37034
- say(AdditionIssueCode.TypeMismatch, 'contentTypes', `the new type "${name}" was named but not written`);
37035
- if (additions.items.length && !asked)
37036
- say(AdditionIssueCode.NotAsked, 'items', 'nothing was asked: new items only when the sentence asks for them');
37037
- const perType = new Map();
37038
- additions.items.forEach((item, i) => {
37039
- if (!types.has(item.contentType) && !newTypes.has(item.contentType))
37040
- say(AdditionIssueCode.TypeUnknown, `items[${i}].contentType`, `"${item.contentType}" is not a content type of this site or a new one`);
37041
- perType.set(item.contentType, (perType.get(item.contentType) ?? 0) + 1);
36912
+ }
36913
+ function wirePageJsonSchema(options = {}) {
36914
+ return shapedAs(PlanWireEntry.Page, options, {
36915
+ key: jsonText(),
36916
+ name: jsonText(),
36917
+ route: jsonText(),
36918
+ inNav: jsonBoolean(),
36919
+ archetype: orNone(Object.keys(PAGE_ARCHETYPES)),
36920
+ need: orNone(SITE_NEED_IDS),
36921
+ template: jsonText(),
36922
+ routeSource: jsonText(),
36923
+ seo: shaped(PlanWireEntry.PageSeo, { title: jsonText(), description: jsonText() }),
36924
+ sections: jsonListOf(wireSectionJsonSchema()),
36925
+ compose: jsonBoolean(),
37042
36926
  });
37043
- for (const [type, n] of perType)
37044
- if (n > ADDITION_CAPS.itemsPerType)
37045
- say(AdditionIssueCode.TooMany, 'items', `${n} new ${type} items — at most ${ADDITION_CAPS.itemsPerType}`);
37046
- return issues;
37047
36927
  }
37048
- /** A page the redesign adds is keyed `added:<n>` in the run's plan (its order in the Pages answer). */
37049
- const ADDITION_KEY_PREFIX = 'added:';
37050
- const additionKey = (n) => `${ADDITION_KEY_PREFIX}${n}`;
37051
- const isAdditionKey = (key) => typeof key === 'string' && key.startsWith(ADDITION_KEY_PREFIX);
37052
- /** What a Switch's `additions` names to write the new items the sentence asked for into types the studio HAS. */
37053
- const ADDITION_ITEMS_KEY = 'items';
37054
- /** The data source aliases a page reads (its route source and its sections' bindings). */
37055
- function aliasesOf$1(page) {
37056
- return [page.routeSource, ...(page.sections ?? []).map(s => s.binding)].filter((a) => typeof a === 'string' && !!a);
36928
+ const PLAN_TOP_SCHEMAS = {
36929
+ business: () => shaped(PlanWireEntry.Business, { name: jsonText(), tagline: jsonText() }),
36930
+ contentTypes: () => jsonListOf(wireContentTypeJsonSchema()),
36931
+ dataSources: () => jsonListOf(wireDataSourceJsonSchema()),
36932
+ pages: () => jsonListOf(wirePageJsonSchema()),
36933
+ globals: options => jsonShapedObject(planWireShape(options).globals, {
36934
+ [GlobalSlot.Header]: jsonListOf(jsonOneOf(headerWireWords())),
36935
+ [GlobalSlot.Footer]: jsonListOf(jsonOneOf(footerWireWords())),
36936
+ [OPENING_WIRE_KEY]: jsonListOf(jsonOneOf(openingWireWords(GenerationTier.Award))),
36937
+ ...(isAward(options) ? { [BODY_WIRE_KEY]: jsonListOf(jsonOneOf(bodyWireWords(GenerationTier.Award))) } : {}),
36938
+ [POPUP_WIRE_KEY]: jsonListOf(jsonText()),
36939
+ }, `wire ${PlanWireEntry.Globals}`),
36940
+ direction: () => shaped(PlanWireEntry.Direction, { idea: jsonText(), cliche: jsonText(), flip: jsonText(), rules: jsonListOf(jsonText()) }),
36941
+ shop: () => jsonListOf(wireShopProductJsonSchema()),
36942
+ };
36943
+ /** Commerce C-D21: one product the business sells, as the structure writes it — never a price, stock or a fee. */
36944
+ function wireShopProductJsonSchema() {
36945
+ return shaped(PlanWireEntry.ShopProduct, {
36946
+ name: jsonText(), category: jsonText(), description: jsonText(),
36947
+ options: jsonListOf(shaped(PlanWireEntry.ShopOption, { name: jsonText(), values: jsonListOf(jsonText()) })),
36948
+ });
37057
36949
  }
37058
- /** The NEW content types an added page brings: its template, or a type whose derived source it reads. */
37059
- function typesOfAddition(page, additions) {
37060
- const aliases = new Set(aliasesOf$1(page));
37061
- return additions.contentTypes.map(t => t.name).filter(name => page.template === name || additionSourcesOf(name).some(source => aliases.has(source.alias)));
36950
+ /** The plan's top-level shape for one part (its keys only) — what that part's request shows and is built from. */
36951
+ function planWirePartShape(part, options = {}) {
36952
+ return Object.fromEntries(Object.entries(planWireShape(options).plan).filter(([k]) => PLAN_PART_KEYS[part].includes(k)));
37062
36953
  }
37063
36954
  /**
37064
- * The plan with what the redesign adds (§3e) — pure. Each added page keyed `added:<n>`; the new types and their derived
37065
- * sources appended (a source alias the plan already has is never replaced). `only`: just these additions' pages, and only
37066
- * the new types (and their sources) those pages bring — what a Switch with some additions turned off writes.
36955
+ * The format a model writes one part of a plan in — one request each (vectoriox/iox-cms#47). The same for every studio
36956
+ * and run at a tier: nothing in it is pinned, so the provider compiles each part's grammar once per tier (AW6: the award
36957
+ * tier's Pages part adds `globals.body`; every other tier's is the format it always was, byte for byte).
37067
36958
  */
37068
- function withAdditions(plan, additions, only) {
37069
- const pages = additions.pages.map((a, i) => ({ ...a.page, key: additionKey(i) })).filter(p => !only || only.has(p.key));
37070
- const brought = new Set(pages.flatMap(p => typesOfAddition(p, additions)));
37071
- const types = additions.contentTypes.filter(t => !only || brought.has(t.name));
37072
- const typeNames = new Set(types.map(t => t.name));
37073
- const have = new Set(plan.dataSources.map(d => d.alias));
37074
- const sources = additions.dataSources.filter(d => d.type === PlanDataSourceType.Cms && typeNames.has(d.contentType) && !have.has(d.alias));
37075
- return { ...plan, pages: [...plan.pages, ...pages], contentTypes: [...plan.contentTypes, ...types], dataSources: [...plan.dataSources, ...sources] };
36959
+ function planWirePartJsonSchema(part, options = {}) {
36960
+ const gaps = planWireGaps();
36961
+ if (gaps.length)
36962
+ throw new PlanWireShapeError(`the plan wire neither carries nor derives ${gaps.join(', ')}`);
36963
+ const missing = Object.keys(WIRE_KEYS.plan).filter(k => !PLAN_TOP_SCHEMAS[k] || !WIRE_KEYS.plan[k].part);
36964
+ if (missing.length)
36965
+ throw new PlanWireShapeError(`the plan wire's ${missing.join(', ')} has no part or no format`);
36966
+ return jsonShapedObject(planWirePartShape(part, options), Object.fromEntries(PLAN_PART_KEYS[part].map(k => [k, PLAN_TOP_SCHEMAS[k](options)])), `wire plan ${part}`);
37076
36967
  }
37077
-
37078
- function isImportPlan(plan) {
37079
- return plan.source.kind === SitePlanSourceKind.Import;
36968
+ /** A value standing for "absent": `''` (or nothing at all). */
36969
+ const isNone = (v) => v === undefined || v === NONE;
36970
+ const optional = (name, v, none = isNone) => (none(v) ? {} : { [name]: v });
36971
+ const emptyList = (v) => v === undefined || (Array.isArray(v) && v.length === 0);
36972
+ /** `[{ <keyName>, <valueName> }]` → `{ key: value }`; anything else is left for the gate to refuse. */
36973
+ function listToMap(list, keyName, valueName) {
36974
+ if (!Array.isArray(list))
36975
+ return list;
36976
+ const out = {};
36977
+ for (const entry of list) {
36978
+ if (!isPlainObject(entry) || typeof entry[keyName] !== 'string')
36979
+ return list;
36980
+ out[entry[keyName]] = entry[valueName];
36981
+ }
36982
+ return out;
36983
+ }
36984
+ const mapToList = (map, keyName, valueName) => Object.entries(map ?? {}).map(([k, v]) => ({ [keyName]: k, [valueName]: v }));
36985
+ const each = (list, expand) => (Array.isArray(list) ? list.map(expand) : list);
36986
+ function expandWireField(wire) {
36987
+ if (!isPlainObject(wire))
36988
+ return wire;
36989
+ const { required, note, ...rest } = wire;
36990
+ const type = FIELD_TYPE_OF_CONTROL[rest['controller']];
36991
+ return { ...rest, ...(type ? { type } : {}), ...optional('required', required, v => v === undefined || v === false), ...optional('note', note) };
36992
+ }
36993
+ function expandWireContentType(wire, options = {}) {
36994
+ if (!isPlainObject(wire))
36995
+ return wire;
36996
+ const written = options.children === false ? { fields: [], ...wire } : wire;
36997
+ const { roles, fields, seed, ...rest } = written;
36998
+ const out = { ...rest, roles: listToMap(roles, 'role', 'field'), fields: each(fields, expandWireField) };
36999
+ if (!isPlainObject(seed))
37000
+ return seed === undefined ? out : { ...out, seed };
37001
+ const { values, ...fixed } = seed;
37002
+ if (fixed['count'] === 0 && emptyList(values))
37003
+ return out;
37004
+ const perItem = {};
37005
+ const plain = Array.isArray(values) ? values.map(row => {
37006
+ if (!isPlainObject(row))
37007
+ return row;
37008
+ const { each, ...rest } = row;
37009
+ if (Array.isArray(each) && each.length)
37010
+ perItem[String(rest['field'])] = each;
37011
+ return rest;
37012
+ }) : values;
37013
+ const map = listToMap(plain ?? [], 'field', 'value');
37014
+ const items = Object.keys(perItem).length ? { perItem } : {};
37015
+ return { ...out, seed: isPlainObject(map) ? { ...fixed, ...items, ...map } : { ...fixed, values } };
37016
+ }
37017
+ function expandWireDataSource(wire) {
37018
+ if (!isPlainObject(wire))
37019
+ return wire;
37020
+ const { alias, type, mode, contentType, limit, filterField, routeParam, of, op, within, ...rest } = wire;
37021
+ if (type === PlanDataSourceType.Cms) {
37022
+ const filter = isNone(filterField) && isNone(routeParam) ? {} : { filterByRouteParam: { field: filterField, routeParam } };
37023
+ return { ...rest, alias, type, mode, contentType, ...optional('limit', limit, v => v === undefined || v === 0), ...filter };
37024
+ }
37025
+ if (type === PlanDataSourceType.Relative)
37026
+ return { ...rest, alias, type, of, op, within };
37027
+ if (type === PlanDataSourceType.Shop) {
37028
+ const filter = isNone(filterField) && isNone(routeParam) ? {} : { filterByRouteParam: { field: filterField, routeParam } };
37029
+ return { ...rest, alias, type, mode, resource: contentType, ...optional('limit', limit, v => v === undefined || v === 0), ...filter };
37030
+ }
37031
+ return wire;
37032
+ }
37033
+ /** The structure's products → the plan's `shop`: the products as written, their categories derived; `[]` = it sells nothing. */
37034
+ function expandWireShop(wire) {
37035
+ if (!Array.isArray(wire))
37036
+ return wire;
37037
+ if (!wire.length)
37038
+ return undefined;
37039
+ const products = wire.filter(isPlainObject);
37040
+ return { categories: products.length === wire.length ? shopCategoriesOf(products) : [], products: wire };
37041
+ }
37042
+ function expandWireSection(wire) {
37043
+ if (!isPlainObject(wire))
37044
+ return wire;
37045
+ const { slots, links, binding, without, form, enter, ...rest } = wire;
37046
+ return {
37047
+ ...rest,
37048
+ ...optional('slots', listToMap(slots, 'slot', 'text'), v => emptyList(slots) || v === undefined),
37049
+ ...optional('links', listToMap(links, 'slot', 'route'), v => emptyList(links) || v === undefined),
37050
+ ...optional('binding', binding),
37051
+ ...optional('without', without, emptyList),
37052
+ ...optional('form', form),
37053
+ ...optional('enter', enter),
37054
+ };
37055
+ }
37056
+ function expandWirePage(wire, options = {}) {
37057
+ if (!isPlainObject(wire))
37058
+ return wire;
37059
+ const written = options.children === false ? { sections: [], ...wire } : wire;
37060
+ const { archetype, need, template, routeSource, seo, sections, compose, ...rest } = written;
37061
+ const words = isPlainObject(seo) ? { ...optional('title', seo['title']), ...optional('description', seo['description']) } : seo;
37062
+ return {
37063
+ ...rest,
37064
+ ...(wire['route'] === '/' ? { isHome: true } : {}),
37065
+ ...optional('archetype', archetype),
37066
+ ...optional('need', need),
37067
+ ...optional('template', template),
37068
+ ...optional('routeSource', routeSource),
37069
+ ...optional('seo', words, v => v === undefined || (isPlainObject(v) && Object.keys(v).length === 0)),
37070
+ sections: each(sections, expandWireSection),
37071
+ ...(compose === true ? { compose: true } : compose === false || compose === undefined ? {} : { compose }),
37072
+ };
37073
+ }
37074
+ function expandWireBusiness(wire, facts) {
37075
+ if (!isPlainObject(wire))
37076
+ return wire;
37077
+ const { tagline, ...rest } = wire;
37078
+ return { ...rest, ...optional('tagline', tagline), ...(facts && Object.keys(facts).length ? { facts: { ...facts } } : {}) };
37080
37079
  }
37081
- /** The patterns an import places (contract `site.patterns`). */
37082
- var ImportPattern;
37083
- (function (ImportPattern) {
37084
- ImportPattern["PageHeader"] = "page-header.simple";
37085
- ImportPattern["LongForm"] = "story.long-form";
37086
- ImportPattern["CardGrid"] = "collection.card-grid";
37087
- ImportPattern["ItemHero"] = "project.hero";
37088
- ImportPattern["ItemBody"] = "item.body";
37089
- ImportPattern["ItemGallery"] = "project.gallery";
37090
- ImportPattern["ItemNext"] = "project.next";
37091
- })(ImportPattern || (ImportPattern = {}));
37092
- /** The optional parts an import leaves out (each pattern's `optional`). */
37093
- const WITHOUT = {
37094
- pageHeader: ['eyebrow', 'lead'],
37095
- longForm: ['heading', 'lead', 'more'],
37096
- cardGridHeader: ['header'],
37097
- };
37098
- /** How many pages the header lists — the rest stay reachable from their lists and links. */
37099
- const IMPORT_NAV_MAX = 6;
37100
- /** A list's "latest" source on the home page. */
37101
- const LATEST_LIMIT = 3;
37102
- const ITEM_PARAM = 'slug';
37103
- const SLUG_FIELD = 'slug';
37104
- const HOME_ROUTE = '/';
37105
- const CONTACT_ARCHETYPE = 'contact';
37106
- const ABOUT_ARCHETYPE = 'about';
37107
- const COLLECTION_ARCHETYPE = 'collection';
37108
- const DETAIL_ARCHETYPE = 'detail';
37109
37080
  /**
37110
- * The words that say a list is the template's own type (the Studio's projects are a portfolio, the Practice's services,
37111
- * the Place's menu) — its items take the template type's place, pages and all (`/work/:slug`). One table, by type name.
37081
+ * A model's plan (its parts, on the wire) + what the generation decides (the look, the run, the language, the owner's
37082
+ * facts) → the Site Plan. Pure. Translates, never repairs: whatever an answer got wrong is still wrong, for
37083
+ * `validateSitePlan` — a part that is not an object is the result itself, a part not written yet leaves its keys out
37084
+ * (the validator then names them, at their own paths). What follows from the pages alone is added (`withDerivedSources`).
37112
37085
  */
37113
- const TEMPLATE_TYPE_WORDS = {
37114
- projects: /\b(projects?|portfolios?|works?|case[\s-]?stud(?:y|ies)|showcase)\b/i,
37115
- services: /\b(services?|treatments?|offers?)\b/i,
37116
- menu: /\b(menus?|dishes|drinks)\b/i,
37117
- };
37118
- /** The field each role of a list's own type is written to, in field order, and how it is edited. */
37119
- const OWN_FIELDS = [
37120
- { role: ContentRole.Title, name: 'title', control: ContentFieldControl.Text, required: true },
37121
- { role: null, name: SLUG_FIELD, control: ContentFieldControl.Text, required: true },
37122
- { role: ContentRole.Summary, name: 'summary', control: ContentFieldControl.Textarea },
37123
- { role: ContentRole.Image, name: 'cover', control: ContentFieldControl.Media },
37124
- { role: ContentRole.Gallery, name: 'gallery', control: ContentFieldControl.Gallery },
37125
- { role: ContentRole.Date, name: 'date', control: ContentFieldControl.Text },
37126
- { role: ContentRole.Meta, name: 'category', control: ContentFieldControl.Text },
37127
- { role: ContentRole.Body, name: 'body', control: ContentFieldControl.Textarea },
37128
- ];
37129
- /** What an item gives each role (null: nothing). */
37130
- function itemValue(item, role) {
37131
- switch (role) {
37132
- case ContentRole.Title: return item.title;
37133
- case ContentRole.Summary: return item.summary || null;
37134
- case ContentRole.Image: return item.picture || null;
37135
- case ContentRole.Gallery: return item.pictures?.length ? item.pictures : null;
37136
- case ContentRole.Date: return item.date || null;
37137
- case ContentRole.Meta: return item.meta || null;
37138
- case ContentRole.Body: return item.text?.trim() ? item.text.trim() : null;
37139
- default: return null;
37086
+ function expandPlanWire(parts, context) {
37087
+ const written = PLAN_PARTS.filter(part => parts[part] !== undefined).map(part => parts[part]);
37088
+ const odd = written.find(value => !isPlainObject(value));
37089
+ if (odd !== undefined)
37090
+ return odd;
37091
+ const wire = Object.assign({}, ...written);
37092
+ const { business, contentTypes, dataSources, pages, direction, shop, globals, ...rest } = wire;
37093
+ const sells = expandWireShop(shop);
37094
+ return withDerivedSources({
37095
+ ...rest,
37096
+ ...expandWireGlobals(globals),
37097
+ ...(sells === undefined ? {} : { shop: sells }),
37098
+ ...(isPlainObject(direction) && direction['idea'] === NONE ? {} : direction === undefined ? {} : { direction }),
37099
+ version: SITE_PLAN_VERSION,
37100
+ source: { ...context.source },
37101
+ business: expandWireBusiness(business, context.facts),
37102
+ ...(context.locale ? { locale: context.locale } : {}),
37103
+ ...(context.popup ? { popup: JSON.parse(JSON.stringify(context.popup)) } : {}),
37104
+ design: { ...context.design },
37105
+ contentTypes: each(contentTypes, expandWireContentType),
37106
+ dataSources: each(dataSources, expandWireDataSource),
37107
+ pages: each(pages, expandWirePage),
37108
+ });
37109
+ }
37110
+ /** The wire's globals → the plan's: a header or footer mix that is a stored pattern becomes that pattern; any other becomes
37111
+ * `mixes.<part>` beside the Studio pattern (the mix wins). A part that is not a word list is left for the validator. */
37112
+ function expandWireGlobals(globals) {
37113
+ if (globals === undefined)
37114
+ return {};
37115
+ if (!isPlainObject(globals))
37116
+ return { globals };
37117
+ const { [OPENING_WIRE_KEY]: opening, [BODY_WIRE_KEY]: body, [POPUP_WIRE_KEY]: popup, ...rest } = globals;
37118
+ const out = { ...rest };
37119
+ const mixes = {};
37120
+ // AW8: the opening is a mix only (no stored pattern stands for it on the wire); [] = none. Not a list: the validator says so.
37121
+ // AW6: so is the body (the award tier's wire alone writes it); [] = none.
37122
+ // PU3: so is the popup ([] = none).
37123
+ for (const [name, words] of [[OPENING_WIRE_KEY, opening], [BODY_WIRE_KEY, body], [POPUP_WIRE_KEY, popup]]) {
37124
+ if (words !== undefined && (!Array.isArray(words) || words.length))
37125
+ mixes[name] = Array.isArray(words) ? [...words] : words;
37126
+ }
37127
+ for (const [slot, readId, fallback] of [
37128
+ [GlobalSlot.Header, (w) => headerPatternIdOf(headerMixFromWords(w)), DEFAULT_HEADER_PATTERN],
37129
+ [GlobalSlot.Footer, (w) => footerPatternIdOf(footerMixFromWords(w)), DEFAULT_FOOTER_PATTERN],
37130
+ ]) {
37131
+ const words = globals[slot];
37132
+ if (!Array.isArray(words))
37133
+ continue;
37134
+ let named = null;
37135
+ try {
37136
+ named = readId(words);
37137
+ }
37138
+ catch { /* the validator names the word */ }
37139
+ // A mix that IS a stored pattern is kept as that pattern alone (the plan stays as a template would write it).
37140
+ out[slot] = named ?? fallback;
37141
+ if (!named)
37142
+ mixes[slot] = [...words];
37140
37143
  }
37144
+ return { globals: out, ...(Object.keys(mixes).length ? { mixes } : {}) };
37141
37145
  }
37142
- const has = (items, role) => items.some(item => itemValue(item, role) !== null);
37143
- /** Lowercase words joined by hyphens — a route segment or a slug. */
37144
- function importSlug(text) {
37145
- return text.normalize('NFKD').replace(/[̀-ͯ]/g, '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
37146
+ // ── The plan → the wire ────────────────────────────────────────────────────────────────────────────────────────────
37147
+ function fieldToWire(field) {
37148
+ return { name: field.name, controller: field.controller, required: field.required ?? false, note: field.note ?? NONE };
37146
37149
  }
37147
- /** Makes names unique in order: the second `a` is `a-2`. */
37148
- class Names {
37149
- constructor(taken = []) {
37150
- this.taken = new Set();
37151
- for (const t of taken)
37152
- this.taken.add(t);
37153
- }
37154
- has(name) { return this.taken.has(name); }
37155
- claim(name, join = '-') {
37156
- let out = name;
37157
- for (let n = 2; this.taken.has(out); n++)
37158
- out = `${name}${join}${n}`;
37159
- this.taken.add(out);
37160
- return out;
37150
+ function contentTypeToWire(type, options = {}) {
37151
+ const played = type.roles;
37152
+ const roles = ROLE_KEYS.filter(role => played[role]).map(role => ({ role, field: played[role] }));
37153
+ // X4: an imported item's old address is never on the wire (`importedFrom` stays with the plan).
37154
+ const { count = 0, sample = false, isPublished = false, perItem = {}, importedFrom: _from, ...values } = type.seed ?? {};
37155
+ return {
37156
+ name: type.name, label: type.label, roles, ...(options.children === false ? {} : { fields: type.fields.map(fieldToWire) }),
37157
+ seed: { count, sample, isPublished, values: mapToList(values, 'field', 'value').map(row => ({ ...row, each: perItem[String(row['field'])] ?? [] })) },
37158
+ };
37159
+ }
37160
+ function dataSourceToWire(source) {
37161
+ const blank = { alias: source.alias, type: source.type, mode: NONE, contentType: NONE, limit: 0, filterField: NONE, routeParam: NONE, of: NONE, op: NONE, within: NONE };
37162
+ if (source.type === PlanDataSourceType.Relative)
37163
+ return { ...blank, of: source.of, op: source.op, within: source.within };
37164
+ if (source.type === PlanDataSourceType.Shop) {
37165
+ return {
37166
+ ...blank, mode: source.mode, contentType: source.resource, limit: source.limit ?? 0,
37167
+ filterField: source.filterByRouteParam?.field ?? NONE, routeParam: source.filterByRouteParam?.routeParam ?? NONE,
37168
+ };
37161
37169
  }
37170
+ return {
37171
+ ...blank, mode: source.mode, contentType: source.contentType, limit: source.limit ?? 0,
37172
+ filterField: source.filterByRouteParam?.field ?? NONE, routeParam: source.filterByRouteParam?.routeParam ?? NONE,
37173
+ };
37162
37174
  }
37163
- const camel = (slug) => slug.replace(/-([a-z0-9])/g, (_m, c) => c.toUpperCase());
37164
- /** A route the plan accepts from an old path: each segment as lowercase words; null when nothing is left. */
37165
- function routeOfPath(path) {
37166
- if (!path)
37167
- return null;
37168
- const segments = path.split(/[?#]/)[0].split('/').map(importSlug).filter(Boolean);
37169
- return segments.length ? `/${segments.join('/')}` : null;
37175
+ function sectionToWire(section) {
37176
+ return {
37177
+ pattern: section.pattern, slots: mapToList(section.slots, 'slot', 'text'), links: mapToList(section.links, 'slot', 'route'),
37178
+ binding: section.binding ?? NONE, without: [...(section.without ?? [])], form: section.form ?? NONE, enter: section.enter ?? NONE,
37179
+ };
37170
37180
  }
37171
- /** The template's pages and sources that show its content type (a list or an item of it). */
37172
- function templateTypeParts(template, typeName) {
37173
- const aliases = new Set(template.dataSources.filter(d => d.type === PlanDataSourceType.Relative ? false : 'contentType' in d && d.contentType === typeName).map(d => d.alias));
37174
- for (const d of template.dataSources)
37175
- if (d.type === PlanDataSourceType.Relative && (aliases.has(d.of) || aliases.has(d.within)))
37176
- aliases.add(d.alias);
37177
- const pages = new Set(template.pages.filter(p => p.template === typeName || (!p.isHome && p.sections.some(s => s.binding && aliases.has(s.binding)))).map(p => p.key));
37178
- return { aliases, pages };
37181
+ function pageToWire(page, options = {}) {
37182
+ return {
37183
+ key: page.key, name: page.name, route: page.route, inNav: page.inNav ?? false, archetype: page.archetype ?? NONE, need: page.need ?? NONE,
37184
+ template: page.template ?? NONE, routeSource: page.routeSource ?? NONE,
37185
+ seo: { title: page.seo?.title ?? NONE, description: page.seo?.description ?? NONE },
37186
+ ...(options.children === false ? {} : { sections: page.sections.map(sectionToWire) }),
37187
+ compose: page.compose ?? false,
37188
+ };
37179
37189
  }
37180
- /** The list that takes the template type's place, if one reads as it. */
37181
- function templateListOf(template, lists) {
37182
- for (const type of template.contentTypes) {
37183
- const words = TEMPLATE_TYPE_WORDS[type.name];
37184
- const list = words ? lists.find(l => l.items.length && [l.key, l.label, l.path ?? ''].some(w => words.test(w.replace(/[-_/]+/g, ' ')))) : undefined;
37185
- if (list)
37186
- return { type, list };
37187
- }
37188
- return null;
37190
+ const PLAN_TO_WIRE = {
37191
+ business: plan => ({ name: plan.business.name, tagline: plan.business.tagline ?? NONE }),
37192
+ contentTypes: plan => plan.contentTypes.map(type => contentTypeToWire(type)),
37193
+ dataSources: plan => plan.dataSources.map(dataSourceToWire),
37194
+ pages: plan => plan.pages.map(page => pageToWire(page)),
37195
+ globals: (plan, options) => ({
37196
+ ...plan.globals, [GlobalSlot.Header]: headerMixWords(headerMixOfPlan(plan)), [GlobalSlot.Footer]: footerMixWords(footerMixOfPlan(plan)),
37197
+ [OPENING_WIRE_KEY]: [...(plan.mixes?.opening ?? [])],
37198
+ // AW6: the award tier's wire writes the body ([] = none); every other tier's has no such key (its plan wears none).
37199
+ ...(isAward(options) ? { [BODY_WIRE_KEY]: [...(plan.mixes?.body ?? [])] } : {}),
37200
+ [POPUP_WIRE_KEY]: [...(plan.mixes?.popup ?? [])],
37201
+ }),
37202
+ direction: plan => ({ idea: plan.direction?.idea ?? NONE, cliche: plan.direction?.cliche ?? NONE, flip: plan.direction?.flip ?? NONE, rules: [...(plan.direction?.rules ?? [])] }),
37203
+ shop: plan => (plan.shop?.products ?? []).map(p => ({ name: p.name, category: p.category, description: p.description, options: p.options.map(o => ({ name: o.name, values: [...o.values] })) })),
37204
+ };
37205
+ /** One part of the plan on the wire: what that part's request (asked at `options`' tier) would have answered. */
37206
+ function planPartToWire(plan, part, options = {}) {
37207
+ return Object.fromEntries(PLAN_PART_KEYS[part].map(k => [k, PLAN_TO_WIRE[k](plan, options)]));
37189
37208
  }
37190
- /** The items' slugs: their own where the site gave one, else from the title; unique within the list. */
37191
- function slugsOf(items) {
37192
- const names = new Names();
37193
- return items.map((item, i) => names.claim(importSlug(item.slug ?? '') || importSlug(item.title) || `item-${i + 1}`));
37209
+ /** The plan → the wire, by part: what a model would have written (the change prompt shows it; fakes and evals write it).
37210
+ * At the award tier the body travels too (AW6); below it, a plan's body is not on the wire. */
37211
+ function planToWire(plan, options = {}) {
37212
+ return Object.fromEntries(PLAN_PARTS.map(part => [part, planPartToWire(plan, part, options)]));
37194
37213
  }
37195
- /** The real items as a seed: one value per item for each role the type plays, the slug, and each item's old address. */
37196
- function seedOf(type, items) {
37197
- const perItem = {};
37198
- const slugField = type.fields.some(f => f.name === SLUG_FIELD) ? SLUG_FIELD : null;
37199
- if (slugField)
37200
- perItem[slugField] = slugsOf(items);
37201
- for (const [role, field] of Object.entries(type.roles)) {
37202
- const list = type.fields.find(f => f.name === field)?.controller === ContentFieldControl.Gallery;
37203
- perItem[field] = items.map(item => {
37204
- const value = itemValue(item, role);
37205
- if (list)
37206
- return Array.isArray(value) ? [...value] : [];
37207
- return typeof value === 'string' ? value : '';
37214
+
37215
+ /**
37216
+ * What a REDESIGN may add (site-redesign plan §3e — RD3-D2 as amended by Doron, 2026-11-21: "the system can suggest new
37217
+ * pages if make sense and in case do use asked for redisign and new pages or content"). Additive only: a new page takes
37218
+ * a NEW address, new content (a type, items) sits beside what exists, and nothing existing — a type, a field, an item,
37219
+ * a data source, a relation, an address — is ever edited or removed. Facts are never invented (a missing one is a
37220
+ * placeholder the gate blocks on).
37221
+ *
37222
+ * Two strict requests, built from the plan wire's OWN entries (the vocabulary, the expanders and the gate are the
37223
+ * build's): **Pages** first — every redesign, the pages to add with who wanted them and why, the new types those pages
37224
+ * need (by name) and the new items an existing type should get (by count) — then **Content**, only when Pages named a new
37225
+ * type or new items: the new types in full and the new items' values. The sources a new type is read by are DERIVED
37226
+ * (`additionSourcesOf`), never asked — so the Pages request can bind them before the type exists. Pure; no transport.
37227
+ */
37228
+ /** Who wanted a page the redesign adds. */
37229
+ var AdditionOrigin;
37230
+ (function (AdditionOrigin) {
37231
+ /** The owner's sentence asked for it — staged with its switch ON. */
37232
+ AdditionOrigin["Asked"] = "asked";
37233
+ /** The reading says the site lacks it — staged with its switch OFF, never added unless the owner turns it on. */
37234
+ AdditionOrigin["Suggested"] = "suggested";
37235
+ })(AdditionOrigin || (AdditionOrigin = {}));
37236
+ /** The two requests, in the order they are asked. */
37237
+ var AdditionsPart;
37238
+ (function (AdditionsPart) {
37239
+ AdditionsPart["Pages"] = "pages";
37240
+ AdditionsPart["Content"] = "content";
37241
+ })(AdditionsPart || (AdditionsPart = {}));
37242
+ /** Each request's format name. */
37243
+ const REDESIGN_ADDITIONS_SCHEMA_NAMES = {
37244
+ [AdditionsPart.Pages]: 'site_redesign_pages',
37245
+ [AdditionsPart.Content]: 'site_redesign_content',
37246
+ };
37247
+ /** At most this many of each (the build's sample cap for items). */
37248
+ const ADDITION_CAPS = { suggested: 2, asked: 6, itemsPerType: 6 };
37249
+ /** The suffix of a new type's one-item source (its per-item page reads it by `:slug`). */
37250
+ const ADDITION_ITEM_SOURCE_SUFFIX = 'Item';
37251
+ /** The field and route param a new type's item page is picked by. */
37252
+ const ADDITION_SLUG = 'slug';
37253
+ const PAGE_KEYS = {
37254
+ origin: `string — ${AdditionOrigin.Asked}: the owner's sentence asks for this page; ${AdditionOrigin.Suggested}: the site lacks it and the owner decides (at most ${ADDITION_CAPS.suggested})`,
37255
+ reason: 'string — one plain sentence the owner reads beside the page: what they asked, or why a site like theirs has it',
37256
+ };
37257
+ const NEW_TYPE_SHAPE = { name: 'string — a NEW content type name (never one the studio has)', label: 'string — its name as the owner reads it' };
37258
+ const NEW_ITEMS_SHAPE = { contentType: 'string — a content type the studio HAS, or one of newTypes', count: `number — how many new items (1–${ADDITION_CAPS.itemsPerType}); the owner's sentence must ask for them` };
37259
+ const PAGES_SHAPE = {
37260
+ pages: 'page[] — ONLY the pages to add, each at an address the studio does not have; [] = none',
37261
+ newTypes: 'newType[] — the new kinds of content the new pages need; [] = none',
37262
+ newItems: 'newItems[] — new items the sentence asks for; [] = none',
37263
+ };
37264
+ const ITEM_SHAPE = { contentType: 'string — the type the item goes into', values: 'seedValue[] — its field values; a fact the owner did not give stays empty' };
37265
+ const CONTENT_SHAPE = {
37266
+ contentTypes: 'contentType[] — exactly the new types named, in full (a per-item page needs a slug field)',
37267
+ items: 'item[] — the new items, one entry each',
37268
+ };
37269
+ const withKeys = (schema, extra) => {
37270
+ const s = schema;
37271
+ return { ...schema, properties: { ...s.properties, ...extra }, required: [...s.required, ...Object.keys(extra)] };
37272
+ };
37273
+ /** The format a model writes one additions request in (≤ 40 properties each — `redesign-additions.spec`). */
37274
+ function redesignAdditionsJsonSchema(part) {
37275
+ if (part === AdditionsPart.Pages) {
37276
+ const page = withKeys(wirePageJsonSchema(), {
37277
+ origin: { ...jsonOneOf(Object.values(AdditionOrigin)), description: PAGE_KEYS['origin'] },
37278
+ reason: { ...jsonText(), description: PAGE_KEYS['reason'] },
37208
37279
  });
37280
+ return jsonShapedObject(PAGES_SHAPE, {
37281
+ pages: jsonListOf(page),
37282
+ newTypes: jsonListOf(jsonShapedObject(NEW_TYPE_SHAPE, { name: jsonText(), label: jsonText() }, 'additions newType')),
37283
+ newItems: jsonListOf(jsonShapedObject(NEW_ITEMS_SHAPE, { contentType: jsonText(), count: jsonInteger() }, 'additions newItems')),
37284
+ }, 'additions pages');
37209
37285
  }
37210
- return { count: items.length, sample: false, isPublished: true, perItem, importedFrom: items.map(i => i.from) };
37286
+ const value = jsonShapedObject(PLAN_WIRE_SHAPE[PlanWireEntry.SeedValue], { field: jsonText(), value: jsonAnyOf([jsonText(), jsonListOf(jsonText())]), each: jsonListOf(jsonText()) }, 'additions seedValue');
37287
+ return jsonShapedObject(CONTENT_SHAPE, {
37288
+ contentTypes: jsonListOf(wireContentTypeJsonSchema()),
37289
+ items: jsonListOf(jsonShapedObject(ITEM_SHAPE, { contentType: jsonText(), values: jsonListOf(value) }, 'additions item')),
37290
+ }, 'additions content');
37211
37291
  }
37212
- const fieldOf = (name, control, required) => ({ name, type: FIELD_TYPE_OF_CONTROL[control], controller: control, ...(required ? { required: true } : {}) });
37213
- /** A list's own type: the roles its items fill, each its field (`OWN_FIELDS`). */
37214
- function ownType(name, list) {
37215
- const fields = [];
37216
- const roles = {};
37217
- for (const f of OWN_FIELDS) {
37218
- if (f.role && f.role !== ContentRole.Title && !has(list.items, f.role))
37219
- continue;
37220
- fields.push(fieldOf(f.name, f.control, f.required));
37221
- if (f.role)
37222
- roles[f.role] = f.name;
37223
- }
37224
- const type = { name, label: list.label, roles: roles, fields };
37225
- return { ...type, seed: seedOf(type, list.items) };
37292
+ /** The sources a new type is read by — derived, never asked: the list (`<type>`) and one item by `:slug`. */
37293
+ function additionSourcesOf(typeName) {
37294
+ return [
37295
+ { alias: typeName, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Query, contentType: typeName },
37296
+ { alias: `${typeName}${ADDITION_ITEM_SOURCE_SUFFIX}`, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Single, contentType: typeName, filterByRouteParam: { field: ADDITION_SLUG, routeParam: ADDITION_SLUG } },
37297
+ ];
37226
37298
  }
37227
- /** The template's type with the list's items: its own fields, and its `body` (the items' own text) when they have one.
37228
- * A role the template gives a field of its own meaning (the Studio's `meta` is a location) is not filled from the site. */
37229
- const TEMPLATE_ROLES_FILLED = [ContentRole.Title, ContentRole.Summary, ContentRole.Image, ContentRole.Gallery, ContentRole.Date, ContentRole.Body];
37230
- function templateType(type, list) {
37231
- const withBody = has(list.items, ContentRole.Body) && !roleField(type, ContentRole.Body);
37232
- const bodyName = new Names(type.fields.map(f => f.name)).claim('body');
37233
- const fields = withBody ? [...type.fields, fieldOf(bodyName, ContentFieldControl.Textarea)] : [...type.fields];
37234
- const roles = (withBody ? { ...type.roles, [ContentRole.Body]: bodyName } : { ...type.roles });
37235
- const filled = Object.fromEntries(Object.entries(roles).filter(([role]) => TEMPLATE_ROLES_FILLED.includes(role)));
37236
- const seed = seedOf({ roles: filled, fields }, list.items);
37237
- // A field the site does not fill is written empty (never the template's sample words).
37238
- const empty = Object.fromEntries(fields.filter(f => !(f.name in (seed.perItem ?? {}))).map(f => [f.name, f.controller === ContentFieldControl.Gallery ? [] : '']));
37239
- return { name: type.name, label: list.label || type.label, roles, fields, seed: { ...seed, ...empty } };
37299
+ const list = (value) => (Array.isArray(value) ? value : []);
37300
+ const text = (value) => (typeof value === 'string' ? value : '');
37301
+ /** Does the Pages answer ask for content (so the Content request is asked). */
37302
+ function additionsNeedContent(pagesAnswer) {
37303
+ return isPlainObject(pagesAnswer) && (list(pagesAnswer['newTypes']).length > 0 || list(pagesAnswer['newItems']).length > 0);
37240
37304
  }
37241
- /** The sources of a list's own type: all of it, the latest few, one by its slug, and the next one. */
37242
- function ownSources(name) {
37243
- const list = name, latest = `${name}Latest`, item = `${name}Item`, next = `${name}Next`;
37305
+ /**
37306
+ * The answers → what the redesign adds. Translates, never repairs (as `expandPlanWire`): a wrong value stays wrong, for
37307
+ * `checkAdditions`. The Content answer is absent when it was not asked.
37308
+ */
37309
+ function expandAdditions(pagesAnswer, contentAnswer) {
37310
+ const pages = isPlainObject(pagesAnswer) ? pagesAnswer : {};
37311
+ const content = isPlainObject(contentAnswer) ? contentAnswer : {};
37312
+ const newTypes = list(pages['newTypes']).filter(isPlainObject).map(t => ({ name: text(t['name']), label: text(t['label']) }));
37244
37313
  return {
37245
- list, latest, item,
37246
- sources: [
37247
- { alias: list, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Query, contentType: name },
37248
- { alias: latest, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Query, contentType: name, limit: LATEST_LIMIT },
37249
- { alias: item, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Single, contentType: name, filterByRouteParam: { field: SLUG_FIELD, routeParam: ITEM_PARAM } },
37250
- { alias: next, type: PlanDataSourceType.Relative, of: item, op: RelativeOp.SiblingsNext, within: list },
37251
- ],
37314
+ pages: list(pages['pages']).filter(isPlainObject).map(wire => {
37315
+ const { origin, reason, ...page } = wire;
37316
+ return { page: expandWirePage(page), origin: origin, reason: text(reason) };
37317
+ }),
37318
+ contentTypes: list(content['contentTypes']).map(t => expandWireContentType(t)),
37319
+ dataSources: newTypes.filter(t => t.name).flatMap(t => additionSourcesOf(t.name)),
37320
+ items: list(content['items']).filter(isPlainObject).map(item => ({
37321
+ contentType: text(item['contentType']),
37322
+ values: Object.fromEntries(list(item['values']).filter(isPlainObject).map(v => [text(v['field']), v['value']])),
37323
+ })),
37324
+ asks: {
37325
+ newTypes,
37326
+ newItems: list(pages['newItems']).filter(isPlainObject).map(n => ({ contentType: text(n['contentType']), count: Number(n['count']) || 0 })),
37327
+ },
37252
37328
  };
37253
37329
  }
37254
- /** The page of one item: its hero, its own text, its pictures, the next one (each only when the items have it). */
37255
- function itemSections(type, nextLabel) {
37256
- const sections = [{ pattern: ImportPattern.ItemHero }];
37257
- if (roleField(type, ContentRole.Body))
37258
- sections.push({ pattern: ImportPattern.ItemBody });
37259
- if (roleField(type, ContentRole.Gallery))
37260
- sections.push({ pattern: ImportPattern.ItemGallery });
37261
- sections.push(nextLabel ? { pattern: ImportPattern.ItemNext, slots: { label: nextLabel } } : { pattern: ImportPattern.ItemNext });
37262
- return sections;
37263
- }
37264
- const pageHeader = (title, lead) => lead
37265
- ? { pattern: ImportPattern.PageHeader, slots: { title, lead }, without: ['eyebrow'] }
37266
- : { pattern: ImportPattern.PageHeader, slots: { title }, without: [...WITHOUT.pageHeader] };
37330
+ /** What `checkAdditions` refuses. */
37331
+ var AdditionIssueCode;
37332
+ (function (AdditionIssueCode) {
37333
+ /** A new page at an address the studio (or another addition) already has. */
37334
+ AdditionIssueCode["RouteTaken"] = "addition-route-taken";
37335
+ /** A new type whose name the studio already has — an existing type is never changed. */
37336
+ AdditionIssueCode["TypeExists"] = "addition-type-exists";
37337
+ /** An item, or a page's binding, for a type that is neither the studio's nor a new one. */
37338
+ AdditionIssueCode["TypeUnknown"] = "addition-type-unknown";
37339
+ /** A binding to a source that is neither the studio's nor a new type's derived one. */
37340
+ AdditionIssueCode["SourceUnknown"] = "addition-source-unknown";
37341
+ /** An `asked` page or new items with no sentence to ask for them. */
37342
+ AdditionIssueCode["NotAsked"] = "addition-not-asked";
37343
+ /** More than `ADDITION_CAPS` allows. */
37344
+ AdditionIssueCode["TooMany"] = "addition-too-many";
37345
+ /** A new type named by Pages that Content did not write (or wrote twice), or one written that Pages did not name. */
37346
+ AdditionIssueCode["TypeMismatch"] = "addition-type-mismatch";
37347
+ })(AdditionIssueCode || (AdditionIssueCode = {}));
37348
+ const routeKey = (route) => (route.replace(/\/+$/, '') || '/').toLowerCase();
37267
37349
  /**
37268
- * The scan's reading → the plan. Every list with items becomes a content type (the one that reads as the template's own
37269
- * takes its place, routes and all); every page with words becomes a page; nothing is invented — a page or a list the
37270
- * site did not have is not added, and the template's own pages are kept only where they are the site's frame (the home
37271
- * page, the contact page).
37350
+ * THE additive check (§3e): every page at a new address, every new type a new name, every item into a known type, every
37351
+ * binding to a known source, `asked` only with a sentence, the caps held, and the Content answer exactly the types Pages
37352
+ * named. Refuses with a path; never repairs. An existing type's FIELDS cannot be expressed by the format at all.
37272
37353
  */
37273
- function planImport(reading, input) {
37274
- const template = input.template ?? STUDIO_TEMPLATE;
37275
- const lists = reading.lists.filter(l => l.items.length > 0);
37276
- const matched = templateListOf(template, lists);
37277
- const dropped = new Set(); // the template types no list fills
37278
- const contentTypes = [];
37279
- const dataSources = [];
37280
- const templateParts = new Map();
37281
- for (const type of template.contentTypes) {
37282
- const parts = templateTypeParts(template, type.name);
37283
- templateParts.set(type.name, parts);
37284
- if (matched?.type.name === type.name) {
37285
- contentTypes.push(templateType(type, matched.list));
37286
- dataSources.push(...template.dataSources.filter(d => parts.aliases.has(d.alias)));
37287
- }
37288
- else
37289
- dropped.add(type.name);
37290
- }
37291
- const droppedAliases = new Set([...dropped].flatMap(t => [...templateParts.get(t).aliases]));
37292
- const droppedPages = new Set([...dropped].flatMap(t => [...templateParts.get(t).pages]));
37293
- // Routes and names: the template's frame first, then the lists, then the pages.
37294
- const kept = template.pages.filter(p => p.isHome || p.archetype === CONTACT_ARCHETYPE || (!droppedPages.has(p.key) && matched && templateParts.get(matched.type.name).pages.has(p.key)));
37295
- const routes = new Names(kept.map(p => p.route));
37296
- const keys = new Names(kept.map(p => p.key));
37297
- const typeNames = new Names(template.contentTypes.map(t => t.name));
37298
- const aliases = new Names(template.dataSources.map(d => d.alias));
37299
- const listPages = [];
37300
- const firstLatest = [];
37301
- if (matched) {
37302
- const listPage = template.pages.find(p => templateParts.get(matched.type.name).pages.has(p.key) && !p.template);
37303
- const latest = template.dataSources.find(d => templateParts.get(matched.type.name).aliases.has(d.alias) && d.type === PlanDataSourceType.Cms && d.mode === PlanDataSourceMode.Query && d.limit);
37304
- if (listPage && latest)
37305
- firstLatest.push({ alias: latest.alias, route: listPage.route });
37306
- }
37307
- const typeOfMatched = matched ? contentTypes[0] : null;
37308
- for (const list of lists) {
37309
- if (list === matched?.list)
37310
- continue;
37311
- const name = typeNames.claim(camel(importSlug(list.key) || importSlug(list.label) || 'items'), '');
37312
- const type = ownType(name, list);
37313
- const own = ownSources(name);
37314
- if ([own.list, own.latest, own.item, `${name}Next`].some(a => aliases.has(a)))
37315
- continue; // never shadow a source
37316
- own.sources.forEach(s => aliases.claim(s.alias));
37317
- contentTypes.push(type);
37318
- dataSources.push(...own.sources);
37319
- const base = routeOfPath(list.path);
37320
- const route = routes.claim(base && !routes.has(base) && base !== HOME_ROUTE ? base : `/${importSlug(list.label) || name.toLowerCase()}`);
37321
- routes.claim(`${route}/:${ITEM_PARAM}`);
37322
- const key = keys.claim(importSlug(list.label) || name.toLowerCase());
37323
- listPages.push({
37324
- key, name: list.label, route, inNav: true, archetype: COLLECTION_ARCHETYPE,
37325
- sections: [pageHeader(list.label), { pattern: ImportPattern.CardGrid, binding: own.list, without: [...WITHOUT.cardGridHeader] }],
37326
- });
37327
- listPages.push({
37328
- key: keys.claim(`${key}-item`), name: list.label, route: `${route}/:${ITEM_PARAM}`, inNav: false,
37329
- template: name, routeSource: own.item, archetype: DETAIL_ARCHETYPE, sections: itemSections(type, list.label),
37330
- });
37331
- firstLatest.push({ alias: own.latest, route });
37332
- }
37333
- // The template's frame: a section that showed a dropped type shows the first list instead, or goes.
37334
- const frame = [];
37335
- for (const page of kept) {
37336
- const sections = [];
37337
- for (const section of page.sections) {
37338
- if (!section.binding || !droppedAliases.has(section.binding)) {
37339
- sections.push(section);
37340
- continue;
37341
- }
37342
- const first = firstLatest[0];
37343
- if (first)
37344
- sections.push({ ...section, binding: first.alias, links: { ...(section.links ?? {}), more: first.route } });
37345
- }
37346
- // The template type's item page shows the items' own text after its hero.
37347
- const body = page.template && typeOfMatched && page.template === typeOfMatched.name && roleField(typeOfMatched, ContentRole.Body)
37348
- && !sections.some(s => s.pattern === ImportPattern.ItemBody);
37349
- if (body)
37350
- sections.splice(Math.max(1, sections.findIndex(s => s.pattern === ImportPattern.ItemHero) + 1), 0, { pattern: ImportPattern.ItemBody });
37351
- frame.push({ ...page, sections });
37352
- }
37353
- // The owner's pages of words.
37354
- const textPages = [];
37355
- for (const page of reading.pages) {
37356
- const text = page.text.trim();
37357
- const title = page.title.trim();
37358
- if (!text || !title)
37359
- continue;
37360
- const base = routeOfPath(page.path);
37361
- if (!base || base === HOME_ROUTE)
37362
- continue; // the home page is rebuilt from the template
37363
- if (routes.has(base) && frame.some(p => p.route === base))
37364
- continue; // the template's contact page stands for it
37365
- const route = routes.claim(base);
37366
- textPages.push({
37367
- key: keys.claim(importSlug(base.slice(1)) || importSlug(title) || 'page'), name: title, route, inNav: route.split('/').length === 2,
37368
- archetype: ABOUT_ARCHETYPE,
37369
- sections: [pageHeader(title, page.description?.trim() || undefined), { pattern: ImportPattern.LongForm, slots: { body1: text }, without: [...WITHOUT.longForm] }],
37370
- });
37371
- }
37372
- // The header lists the lists first, then the pages, the contact page last — at most IMPORT_NAV_MAX.
37373
- const home = frame.filter(p => p.isHome);
37374
- const contact = frame.filter(p => !p.isHome && p.archetype === CONTACT_ARCHETYPE);
37375
- const rest = frame.filter(p => !p.isHome && p.archetype !== CONTACT_ARCHETYPE);
37376
- let room = IMPORT_NAV_MAX - contact.filter(p => p.inNav).length;
37377
- const nav = (page) => {
37378
- if (!page.inNav)
37379
- return page;
37380
- if (room > 0) {
37381
- room--;
37382
- return page;
37354
+ function checkAdditions(additions, studio) {
37355
+ const issues = [];
37356
+ const say = (code, path, message) => issues.push({ code, path, message });
37357
+ const asked = !!studio.prompt.trim();
37358
+ const taken = new Set(studio.routes.map(routeKey));
37359
+ const types = new Set(studio.contentTypes);
37360
+ const newTypes = new Set(additions.asks.newTypes.map(t => t.name));
37361
+ const sources = new Set([...studio.dataSources, ...additions.dataSources.map(s => s.alias)]);
37362
+ additions.pages.forEach(({ page, origin }, i) => {
37363
+ const key = routeKey(String(page?.route ?? ''));
37364
+ if (taken.has(key))
37365
+ say(AdditionIssueCode.RouteTaken, `pages[${i}].route`, `${page.route} is already a page of this site — a new page takes a new address`);
37366
+ taken.add(key);
37367
+ if (origin === AdditionOrigin.Asked && !asked)
37368
+ say(AdditionIssueCode.NotAsked, `pages[${i}].origin`, 'nothing was asked: a page the site lacks is "suggested"');
37369
+ if (page.template && !types.has(page.template) && !newTypes.has(page.template))
37370
+ say(AdditionIssueCode.TypeUnknown, `pages[${i}].template`, `"${page.template}" is not a content type of this site or a new one`);
37371
+ for (const [alias, path] of [[page.routeSource, `pages[${i}].routeSource`], ...(page.sections ?? []).map((s, j) => [s.binding, `pages[${i}].sections[${j}].binding`])]) {
37372
+ if (alias && !sources.has(alias))
37373
+ say(AdditionIssueCode.SourceUnknown, path, `"${alias}" is not a source of this site or of a new type`);
37383
37374
  }
37384
- return { ...page, inNav: false };
37385
- };
37386
- const pages = [...home, ...rest.map(nav), ...listPages.map(nav), ...textPages.map(nav), ...contact];
37387
- return {
37388
- version: SITE_PLAN_VERSION,
37389
- source: { kind: SitePlanSourceKind.Import, scanId: reading.scanId },
37390
- business: JSON.parse(JSON.stringify(reading.business)),
37391
- ...(reading.locale ? { locale: reading.locale } : {}),
37392
- design: JSON.parse(JSON.stringify(input.design)),
37393
- contentTypes,
37394
- dataSources: JSON.parse(JSON.stringify(dataSources)),
37395
- pages: JSON.parse(JSON.stringify(pages)),
37396
- globals: JSON.parse(JSON.stringify(template.globals)),
37397
- };
37375
+ });
37376
+ const suggested = additions.pages.filter(p => p.origin === AdditionOrigin.Suggested).length;
37377
+ const askedPages = additions.pages.filter(p => p.origin === AdditionOrigin.Asked).length;
37378
+ if (suggested > ADDITION_CAPS.suggested)
37379
+ say(AdditionIssueCode.TooMany, 'pages', `${suggested} suggested pages — at most ${ADDITION_CAPS.suggested}`);
37380
+ if (askedPages > ADDITION_CAPS.asked)
37381
+ say(AdditionIssueCode.TooMany, 'pages', `${askedPages} asked pages — at most ${ADDITION_CAPS.asked}`);
37382
+ additions.asks.newTypes.forEach((t, i) => {
37383
+ if (types.has(t.name))
37384
+ say(AdditionIssueCode.TypeExists, `newTypes[${i}].name`, `"${t.name}" is already a content type — an existing type is never changed`);
37385
+ });
37386
+ const written = additions.contentTypes.map(t => t?.name);
37387
+ additions.contentTypes.forEach((t, i) => {
37388
+ if (types.has(t?.name))
37389
+ say(AdditionIssueCode.TypeExists, `contentTypes[${i}].name`, `"${t.name}" is already a content type — an existing type is never changed`);
37390
+ else if (!newTypes.has(t?.name) || written.indexOf(t.name) !== i)
37391
+ say(AdditionIssueCode.TypeMismatch, `contentTypes[${i}].name`, `"${t?.name}" is not one of the new types named, once each`);
37392
+ });
37393
+ for (const name of newTypes)
37394
+ if (additions.contentTypes.length && !written.includes(name))
37395
+ say(AdditionIssueCode.TypeMismatch, 'contentTypes', `the new type "${name}" was named but not written`);
37396
+ if (additions.items.length && !asked)
37397
+ say(AdditionIssueCode.NotAsked, 'items', 'nothing was asked: new items only when the sentence asks for them');
37398
+ const perType = new Map();
37399
+ additions.items.forEach((item, i) => {
37400
+ if (!types.has(item.contentType) && !newTypes.has(item.contentType))
37401
+ say(AdditionIssueCode.TypeUnknown, `items[${i}].contentType`, `"${item.contentType}" is not a content type of this site or a new one`);
37402
+ perType.set(item.contentType, (perType.get(item.contentType) ?? 0) + 1);
37403
+ });
37404
+ for (const [type, n] of perType)
37405
+ if (n > ADDITION_CAPS.itemsPerType)
37406
+ say(AdditionIssueCode.TooMany, 'items', `${n} new ${type} items — at most ${ADDITION_CAPS.itemsPerType}`);
37407
+ return issues;
37408
+ }
37409
+ /** A page the redesign adds is keyed `added:<n>` in the run's plan (its order in the Pages answer). */
37410
+ const ADDITION_KEY_PREFIX = 'added:';
37411
+ const additionKey = (n) => `${ADDITION_KEY_PREFIX}${n}`;
37412
+ const isAdditionKey = (key) => typeof key === 'string' && key.startsWith(ADDITION_KEY_PREFIX);
37413
+ /** What a Switch's `additions` names to write the new items the sentence asked for into types the studio HAS. */
37414
+ const ADDITION_ITEMS_KEY = 'items';
37415
+ /** The data source aliases a page reads (its route source and its sections' bindings). */
37416
+ function aliasesOf$1(page) {
37417
+ return [page.routeSource, ...(page.sections ?? []).map(s => s.binding)].filter((a) => typeof a === 'string' && !!a);
37418
+ }
37419
+ /** The NEW content types an added page brings: its template, or a type whose derived source it reads. */
37420
+ function typesOfAddition(page, additions) {
37421
+ const aliases = new Set(aliasesOf$1(page));
37422
+ return additions.contentTypes.map(t => t.name).filter(name => page.template === name || additionSourcesOf(name).some(source => aliases.has(source.alias)));
37423
+ }
37424
+ /**
37425
+ * The plan with what the redesign adds (§3e) — pure. Each added page keyed `added:<n>`; the new types and their derived
37426
+ * sources appended (a source alias the plan already has is never replaced). `only`: just these additions' pages, and only
37427
+ * the new types (and their sources) those pages bring — what a Switch with some additions turned off writes.
37428
+ */
37429
+ function withAdditions(plan, additions, only) {
37430
+ const pages = additions.pages.map((a, i) => ({ ...a.page, key: additionKey(i) })).filter(p => !only || only.has(p.key));
37431
+ const brought = new Set(pages.flatMap(p => typesOfAddition(p, additions)));
37432
+ const types = additions.contentTypes.filter(t => !only || brought.has(t.name));
37433
+ const typeNames = new Set(types.map(t => t.name));
37434
+ const have = new Set(plan.dataSources.map(d => d.alias));
37435
+ const sources = additions.dataSources.filter(d => d.type === PlanDataSourceType.Cms && typeNames.has(d.contentType) && !have.has(d.alias));
37436
+ return { ...plan, pages: [...plan.pages, ...pages], contentTypes: [...plan.contentTypes, ...types], dataSources: [...plan.dataSources, ...sources] };
37398
37437
  }
37399
37438
 
37400
37439
  /**
@@ -41901,5 +41940,5 @@ function siteGlobalsOf(globals) {
41901
41940
  * Generated bundle index. Do not edit.
41902
41941
  */
41903
41942
 
41904
- export { ACCOUNT_ENTRY_ID, ACTION_START_SCALE, ACTIVE_BUILD_STATUSES, ADDITION_CAPS, ADDITION_ITEMS_KEY, ADDITION_ITEM_SOURCE_SUFFIX, ADDITION_KEY_PREFIX, ADDITION_SLUG, ADJUSTMENTS, ADJUST_AXIS_LABELS, ADJUST_LOOK, ADJUST_OWN, ADJUST_STEPS, ADJUST_STEP_IDS, AI_COMPOSED_PAGES_BY_TIER, AI_COMPOSED_PAGES_ESTIMATED, AI_COMPOSED_PAGE_LEAN_TOKENS, AI_MODEL_STEPS, AI_PICTURE_MAKERS, AI_PLAN_REASKED_PART, AI_REFUSAL_NEXT, AI_REFUSAL_STATUS, AI_STEPS, AI_STEP_FEATURE, AI_STEP_LABELS, AI_STEP_NEEDS, AI_STEP_PART_TOKENS, AI_STEP_RUNS_AS, AI_STEP_TYPICAL_TOKENS, ART_DIRECTION_PARTS, AWARD_COMPOSED_PAGES_ESTIMATED, AdditionHeldBack, AdditionIssueCode, AdditionOrigin, AdditionsPart, AdditionsSkipped, AdjustAxis, AdjustKind, AiCallStatus, AiCapability, AiFeature, AiGenerationStage, AiKeyMode, AiLimit, AiNextKind, AiPictureMaker, AiProviderId, AiRefusalCode, AiStep, BAR_ITEMS_MAX, BAR_ITEMS_MIN, BASELINE_ROLES, BASELINE_WORDS_HE, BODY_TOKEN, BUILD_STEPS, BUTTON_LINK_PROPS, BaselineRole, BindScope, BodyIngredient, BodyMixError, BodyRepairCode, BodyRhythm, BodySeam, BodySectionWord, BodyTexture, BuildNoticeCode, BuildStep, CARRIED_BUTTON_STYLES, CARRY_LAYER_KINDS, CARRY_PHOTO_KINDS, CARRY_PROMPT_QUOTE, CARRY_WHOLE_LAYER_KINDS, CONTENT_ROLE_MEANINGS, COPY_OUT, CREDITS_PER_USD, CardBindTarget, CarryBlockKind, CarryKeptReason, CarryKind, CarryReferenceVia, CheckSeverity, ComposeError, ComposeIssueCode, ContentFieldControl, ContentFieldType, ContentRole, ContentTypeAction, CreatedKind, DANGLING_LINK_CODES, DEFAULT_FOOTER_PATTERN, DEFAULT_GENERATION_TIER, DEFAULT_HEADER_PATTERN, DEFAULT_PHONE_MENU_BREAKPOINT, DEFAULT_SITE_LOCALE, DRAWER_BEAT_MS, DRAWER_KINDS, DRAWER_LETTER_MS, DRAWER_LINE_MS, DRAWER_SPINE, DRAWER_STEPS, ENTRANCE_EASING, ENTRANCE_ORIGIN_LOOK, ENTRANCE_TRIGGER, EntrancePart, EntranceSide, FACT_KEYS, FIELD_TYPE_OF_CONTROL, FILL_ASPECT, FILM_PATTERN, FINAL_GENERATION_STAGES, FINDING_SEVERITY, FOOTER_INSET_STYLES, FOOTER_LEGAL_ROLE, FOOTER_TOKEN, FORM_LEGAL_ROLE, FREE_BUILDER_TYPE, FREE_CONTRAST, FREE_ELEMENT_STYLES, FREE_HOLDERS, FREE_HOVER_PROPS, FREE_LEAD_ROLE, FREE_MOVES, FREE_PHONE_LAYERS, FREE_PHONE_LIMITS, FREE_SECTIONS, FREE_STYLE_PROPS, FREE_TOKEN_PROPS, FREE_TO_LAYOUT_CODE, FREE_WIRE_NODE_KEYS, FREE_WORD_TYPES, FallbackOpeningKept, FilmUnplaced, FindingGrouping, FooterArrange, FooterClosing, FooterGround, FooterHold, FooterIngredient, FooterMixError, FooterNameStyle, FooterRepairCode, FooterRole, FreeIssueCode, FreeLayer, FreeNodeType, FreePictures, FreePurpose, FreeTrigger, GRAMMAR_TOO_LARGE_MESSAGE, GenerationTier, GlobalSlot, GroundTone, HAND_PAGE_KEY_PREFIX, HEADER_TOKEN, HEBREW_PREFIXES, HeaderAction, HeaderArrange, HeaderIngredient, HeaderMixError, HeaderPages, HeaderRepairCode, HeaderReplacedKind, IMPORT_NAV_MAX, IMPRINT_COUNTRIES, ISRAEL, ITEM_PAGE_ONLY_ROLES, ImportPattern, JOINED_HEADER_PADDING, JSON_SCHEMA_BANNED_KEYWORDS, JsonSchemaShapeError, KeptPagesChoice, KeptReason, LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_CHECK_VIEWPORT, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_COLUMN_MENDED, LAYOUT_DEPTH_ON_PHONE, LAYOUT_DRIFT, LAYOUT_EASING, LAYOUT_ENTRANCE_MAX_MS, LAYOUT_FONT_SIZE, LAYOUT_HIDDEN_OPACITY, LAYOUT_KINETIC_KINDS, LAYOUT_LINE_HEIGHT, LAYOUT_LIST_TOKEN, LAYOUT_MIX_OFFERED, LAYOUT_MIX_OFFERED_AWARD, LAYOUT_MIX_WORDS, LAYOUT_NEAR_MISS, LAYOUT_OPERATED, LAYOUT_OWNED_PROPS, LAYOUT_PACE, LAYOUT_PHONE_BREAKPOINT, LAYOUT_PHONE_PADDING, LAYOUT_PHOTO_ASPECT, LAYOUT_READY_MADE_TOKEN, LAYOUT_RISE, LAYOUT_SCREEN_PX, LAYOUT_SETTLE_PASSES, LAYOUT_TEXT_KINDS, LAYOUT_TOOLTIP_TRAIT, LAYOUT_VIEWPORTS, LAYOUT_WIRE_AUTOPLAY_MS, LEGAL_KINDS, LEGAL_PAGE_SETTING, LIST_CARD_PART, LIST_DECK_MAX_PX, LIST_DECK_SHARE, LIST_FRAME_STYLE_KEYS, LIST_INGREDIENTS, LIST_ITEM_MIN_PX, LIST_LONG_WORDS, LIST_RHYTHMS, LIST_ROLE_WORDS, LIST_RULES, LIST_SAY_WORDS, LIST_TABLE, LIST_WORDS_BESIDE_RULE, LayoutAlign, LayoutBleed, LayoutButtonVariant, LayoutColour, LayoutColourMode, LayoutDepth, LayoutDial, LayoutEase, LayoutEditOp, LayoutEnter, LayoutGalleryEffect, LayoutGapCode, LayoutIssueCode, LayoutLayerKind, LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListHow, LayoutListItem, LayoutListMove, LayoutListPhone, LayoutListRole, LayoutListSide, LayoutListWho, LayoutMendKind, LayoutMixIngredient, LayoutNavKind, LayoutPace, LayoutPhotoShape, LayoutPhotoSource, LayoutRole, LayoutScrubRefusal, LayoutSectionKind, LayoutSequenceToken, LayoutSide, LayoutSignatureId, LayoutSize, LayoutSourceChoice, LayoutTrackProp, LayoutTransition, LayoutViewport, LegalBlocks, LegalFact, LegalKind, ListPartChange, ListPartOutcome, ListSayCode, ListWordRefusal, MAX_SITE_PICTURES, MOTION_TRIGGERS, MOVING_OPENING_MEDIA, MenuSide, NAV_PART_LABELS, NAV_SHAPE_COPY, NEUTRAL_STYLE_PROPS, NODE_BASELINES, NO_TOKENS, NavPagesSource, NavRole, NavShape, NavShapeError, ONCE_ENTRANCE_MS, OPENING_DISSOLVE, OPENING_HEIGHT, OPENING_MIX_PROP, OPENING_TOKEN, OpeningExtra, OpeningFrame, OpeningGround, OpeningIngredient, OpeningMedia, OpeningMixError, OpeningMotion, OpeningRepairCode, OpeningRole, OpeningWords, PAGE_ARCHETYPES, PERSONAL_CONTROLS, PHOTO_ANALYSIS_WIDTH, PHOTO_CALM_DETAIL, PHOTO_GRID, PHOTO_LIGHT_LUMINANCE, PICTURE_ASPECTS, PICTURE_NEVER, PICTURE_REAL_PLACE_FAMILIES, PICTURE_REROLL_EVERY, PICTURE_REVIEW_FORMAT, PICTURE_REVIEW_SHAPE, PICTURE_TEXT_CONTRAST, PICTURE_TOKENS_UNKNOWN_MAKER, PICTURE_WORLDS, PICTURE_WORLD_IDS, PLAN_EDITS_ANSWER_SHAPES, PLAN_EDITS_PART_SCHEMA_NAMES, PLAN_EDIT_OP_PART, PLAN_EDIT_SHAPE, PLAN_EDIT_WIRE_KEYS, PLAN_PARTS, PLAN_PART_KEYS, PLAN_WIRE_DERIVED, PLAN_WIRE_PART_SCHEMA_NAMES, PLAN_WIRE_SHAPE, POPUP_GLOBAL_ID, POPUP_LINK_WORD, POPUP_WIRE_INGREDIENTS, PREVIOUS_ROUTE_SUFFIX, PRICING_PATTERN, PROOF_FINGERPRINTS, PUBLISH_BLOCKING_PLACEHOLDERS, PageDataKind, PathIssueCollector, PatternDirective, PatternGlobalPosition, PatternOpens, PatternPlaceholder, PatternRecipe, PhoneMenuBreakpoint, PhotoTone, PictureRefusal, PictureWorld, PlaceholderKind, PlanChangeAction, PlanChangeKind, PlanDataSourceMode, PlanDataSourceType, PlanEditIssueCode, PlanEditOp, PlanEditsOutcome, PlanPart, PlanWireEntry, PlanWireShapeError, PlanWordIssueCode, PopupMixError, PopupRefusal, PreflightRefusalCode, PriceBindTarget, PromptLimit, PublishRefusalCode, PublishScope, REDESIGN_ADDITIONS_SCHEMA_NAMES, REDESIGN_BACK_DAYS, REDESIGN_PARTS, REDESIGN_STEPS, RENDER_CHECK, REQUIRED_CONTENT_ROLES, RedesignPageResult, RedesignPart, RedesignRefusalCode, RedesignStep, RelativeOp, SAMPLE_IMAGE_REF, SCENE_LEVEL, SCENE_OTHER_PAGES, SCRIM_BACKGROUND, SCRIM_COVER, SCRIM_LEVELS, SCRUBBED_ENTRANCE, SCRUB_UNTIL, SHOP_CART_BUTTON_ID, SHOP_CART_DRAWER_ID, SHOP_FIELDS, SHOP_LATEST_LIMIT, SHOP_LIST_LIMIT, SHOP_NEED, SHOP_ONLY_CONTENT_ROLES, SHOP_PRODUCTS_MAX, SHOP_ROLES, SHOP_SLUG_FIELD, SHOWCASE_FILM, SHOWCASE_SHOP, SIGN_IN_DIALOG_ID, SITE_CHECKS, SITE_FACT_LABELS, SITE_FINDING_WORDS, SITE_HEADER_PATTERN, SITE_LIBRARY, SITE_LOCALES, SITE_NEED_IDS, SITE_PAGE_MOVED_ASIDE, SITE_PATTERNS, SITE_PLAN_VERSION, SITE_TEMPLATES, SPEC_SITE_ARCHETYPES, SPEC_SITE_COPY_LENGTHS, SPEC_SITE_DENSITY_COPY, SPEC_SITE_FACTS, SPEC_SITE_FOOTER_PARTS, SPEC_SITE_HEADER_PARTS, SPEC_SITE_LAYOUT, SPEC_SITE_LIBRARY, SPEC_SITE_LOCALES, SPEC_SITE_NEED_IDS, SPEC_SITE_PATTERNS, SPEC_SITE_PICTURE_NEVER, SPEC_SITE_PICTURE_WORLDS, SPEC_SITE_PLAN_SHAPE, SPEC_SITE_REQUIRED_ROLES, SPEC_SITE_ROLES, SPEC_SITE_TEMPLATES, STAMPED_PAGE_ARCHETYPES, START_QUOTE_STEPS, START_QUOTE_TOKENS, STOCK_FAMILIES, STOCK_FAMILY_INTENTS, STOCK_INTENT_ORDER, STOCK_INTENT_SUBJECTS, STOCK_ITEM_ASPECT, STOCK_MIN_KEPT, STOCK_PROVIDER_TERMS, STOCK_SEED_MARGIN, STOCK_SUBJECT_WORDS, STORE_CONTACT_CODES, STRICT_SCHEMA_BUDGET, STRICT_SCHEMA_LIMITS, STUDIO_TEMPLATE, SWAP_CARRY_KINDS, ScrimLevel, ScrubUntil, SectionFallbackLastResort, SectionMaker, SectionSwapAction, SectionSwapRule, ShopResource, ShopSourceRole, SiteBuildKind, SiteBuildStatus, SiteCheckId, SiteFindingCode, SiteLocale, SitePageMaker, SitePageStatus, SitePlanError, SitePlanIssueCode, SitePlanSourceKind, SiteTemplateError, SiteTemplateId, StagedPageReason, StagedPageWay, StepState, StockIntent, StockOrientation, StockProviderId, StockReviewFlag, StockReviewVerdict, StockSlotKind, StockSubject, TEMPLATE_TYPE_WORDS, TYPE_LED_KEPT, TYPE_LED_OPTIONAL_PARTS, TYPE_LED_SWAPS, TypeLedChangeKind, WORDS_AREA_DEFAULT_SHARE, WordsEdge, addBarItem, addStockCredits, additionKey, additionSourcesOf, additionsNeedContent, adjustStepLabel, adjustStepOf, adjustStyleProps, aiModelStep, aiRefusalNext, aiStepParts, applyHeaderMix, applyLayoutEdits, applyOpeningMix, applyOwnPhotoGalleries, applyPictureScrims, applyPlanEdits, applyStockItemPhotos, applyStockPhotos, archetypeIssues, areaLuminance, artDirectionFor, artDirectionIssues, artDirectionPreamble, aspectRatioOf, assertStyleSlots, assertValidSitePlan, auditLayoutMotion, auditSite, barIconForRoute, bentoFill, bentoFillsParams, blocksPublish, bodyMeaning, bodyMix, bodyMixFromWords, bodyMixOfPlan, bodyMixWords, bodySeamClass, bodySeamShape, bodyTokenOf, bodyWireWords, bodyWordDrawn, bodyWordOffered, bodyWordTier, bodyWordWaits, bodyWords, boxSides, brandHueWord, buildKeys, buildStepFacts, buildStepsOf, builtHomePageId, calmParts, calmUnder, canonicalNodeJson, canonicalValue, carryBlockOf, carryButtonLink, carryHandles, carryInto, carryKindOf, carryNotPlaced, carrySection, checkAdditions, checkBody, checkCarry, checkFooter, checkFree, checkFreeSection, checkHeader, checkLayout, checkList, checkOpening, checkPopup, chooseScrim, chooseTypeLedOpening, columnIssues, composablePage, composeContextOf, composeFreePage, composeFreeSection, composeLayout, composeListFrame, composeNavHeader, composeOpening, composePopup, composePresetForm, composeSection, composeSite, composedPagesMax, composedPagesShare, composerLeftovers, composingShare, contactFactsOf, contentTypeOfSource, contentTypePreviewFields, contentTypeToWire, copyLengthOf, copyOutInteraction, costUsd, countryLegalFacts, coverCrop, createSerializedNode, creditsOfUsd, dataSourceToWire, derivedBeats, derivedDataSources, derivedShopSources, describeCarryForPrompt, describeInventoryForPrompt, describeListShape, describePlanData, describeShapeKey, dissolveInteraction, distinctFallbackSections, distinctFooter, distinctHeader, drawerRamp, drawerRestX, drawerStepCount, drawerSteps, drawerWidth, drawersTiming, drawnBodyMix, drawnFooterMix, drawnHeaderMix, drawnOpeningMix, driftAt, driftOverlap, duplicateNodeIds, editedPageIds, emptyAreaPhrase, emptyPictures, entranceAction, entranceInteraction, estimatePictures, estimateStepCredits, expandAdditions, expandFreeWire, expandLayoutWire, expandPlanWire, expandWireContentType, expandWireDataSource, expandWireEdit, expandWireField, expandWirePage, expandWireSection, expandWireShop, factIssues, failedBuildStep, fallBackBySection, fallBackFree, fallbackFingerprintOf, fallbackFingerprintOfPlanPage, fieldToWire, figuresNotIn, fillContactFacts, filmOfPlan, filmPlacement, findNavRoot, findOpening, findingMessageOf, findingSentence, fingerprintOf, fingerprintOfPlanPage, followedAfter, followedIssues, footerCallWord, footerMeaning, footerMix, footerMixFromWords, footerMixOfPlan, footerMixWords, footerNameFits, footerPattern, footerPatternIdOf, footerReferences, footerTableWords, footerTokenOf, footerTokenWords, footerWait, footerWireWords, footerWords, formAsksPersonalData, formLegalFacts, frameWords, freeContrastIssues, freeControlsOf, freeMoveOf, freeMoveWord, freeMoveWords, freeNodeId, freeSectionAsLayout, freeSectionOwner, freeSignaturePage, freeSlotIssues, freeStampedId, freeStyleIssues, freeStyleToSlots, freeStyleWithoutSlot, freeToWire, freeWireJsonSchema, freeWirePath, generationTierOf, groundToneOf, groupSentence, groupSiteFindings, handPageKey, handPlanPage, harvestPage, hash53, headerAdvice, headerCompanions, headerContextOfPlan, headerGallery, headerGalleryIdOf, headerMeaning, headerMix, headerMixFromWords, headerMixOfNavKind, headerMixOfPlan, headerMixValue, headerMixWords, headerPatternIdOf, headerRecipe, headerReferences, headerShape, headerSiteFor, headerTokenOf, headerTokenWords, headerWireWords, headerWordDrawn, headerWords, importSlug, isActiveBuild, isAdditionKey, isDrawers, isHandPageKey, isImportPlan, isLayoutRule, isLegalKind, isNonEmptyString, isPerItemPage, isPictureWorld, isPlainObject, isRedesignRun, isRtlLocale, isScrubbedEntrance, isSectionCarryHandle, isSectionStamp, isShopResource, isTemplateRoute, joinPageHeader, jsonAnyOf, jsonBoolean, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonSchemaKeywords, jsonSchemaObjects, jsonShapedObject, jsonText, judgeLayoutRender, keepListParts, layerMetricsOf, layerShownSpans, layoutBandScheme, layoutBoxPx, layoutColumnsOffered, layoutColumnsVw, layoutCounterDepth, layoutDesignOf, layoutDialOf, layoutDriftPhoto, layoutElementStyle, layoutEntersOffered, layoutFlagsOffered, layoutGalleryLists, layoutGallerySources, layoutGlideDepth, layoutHeldStill, layoutListBare, layoutListBinding, layoutListDrawnCols, layoutListPair, layoutListShapes, layoutListsContext, layoutLookChanges, layoutLookOf, layoutMixOffered, layoutMotionOf, layoutNearMiss, layoutNodeClass, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutPathSteps, layoutPhotoIds, layoutPresetColours, layoutPresetOf, layoutRepairJsonSchema, layoutRoomPx, layoutRuleEdge, layoutScrubTakes, layoutSectionKindsOffered, layoutShapeHasPurpose, layoutSignatureOffered, layoutSignaturesOffered, layoutStillLine, layoutTextFits, layoutTextWidthEm, layoutToWire, layoutVoidScreens, layoutVoids, layoutWireJsonSchema, layoutWirePartWords, legalFactsOf, legalFormLine, legalKindBlocks, legalKindOfPage, legalKindRow, legalKindsFor, legalLabel, legalPageOf, legalRoute, legalTitle, listBelowPro, listBindingOfType, listBuiltWords, listColumns, listDetailOf, listIngredientWords, listMeaning, listMixFromWords, listMixOfFrame, listMixValue, listMixWords, listNeverIsEmpty, listOverhang, listPanelRows, listSaidSentence, listSentence, listShapeOfType, listTokenOf, listTokensOf, listWait, listWordOffered, listWordRef, listWordRefs, listWordRefusal, listWordTier, listWords, luminanceOf, measureFree, measureLayout, mendCarry, mendLayout, mendNotices, menuAtEveryWidth, menuLookOf, menuWords, modelCanDo, moveBarItem, moveEntrance, nameStyleOf, namedFooterMix, namedHeaderMix, namedOpeningMix, navHeaderContext, navPages, navShapeBreakpoint, navShapeOf, nearestHeaderMix, nestSitePages, nextSourceOf, nodeBindPaths, offeredForTier, onceEntrance, openingAdvice, openingAdviceMix, openingContextOf, openingFromSection, openingGallery, openingGalleryIdOf, openingHarnessWord, openingIsTypeLed, openingMeaning, openingMix, openingMixFromWords, openingMixOfPlan, openingMixValue, openingMixWords, openingPatternIdOf, openingPhoneInset, openingRecipe, openingReferences, openingTokenOf, openingTokenParts, openingWireWords, openingWordDrawn, openingWordOffered, openingWordTier, openingWordWaits, openingWords$1 as openingWords, orientationOfRatio, outwardCredits, ownPhotoFit, ownerContentInto, paddingKeepingClear, pageBuildSource, pageListIssues, pageShowsShop, pageToWire, parseLayoutPhotoId, parsePatternPath, parseSampleImageRef, pathAt, patternById, patternHasForm, patternLinkSlots, patternListGap, patternManifest, patternNeedsBinding, patternNodes, patternOptionalParts, patternRoleNeeds, patternScopes, patternSlotBudgets, patternSlots, patternTakesBinding, phoneGapBefore, phoneMenuPages, phoneWordsColour, photoInventory, photoShapeOf, pickListWord, pictureAspect, pictureItemsOf, pictureMakerOf, picturePrompt, pictureRefusalOf, pictureRerolls, pictureReviewIssues, pictureReviewJsonSchema, pictureReviewPasses, pictureSlotKey, pictureTargets, pictureTokensFor, pictureTryFits, picturelessTypes, pinnedPagesOf, pixelsUnder, placeFilm, plainCarryText, planEditOps, planEditToWire, planEditWireGaps, planEditWireKeys, planEditWireOps, planEditWireShape, planEditsFromWire, planEditsJsonSchema, planEditsToWire, planEntrances, planFromTemplate, planHasShopSource, planHeader, planImport, planLayoutPhotos, planNavShape, planOwnPhotos, planPartOfPath, planPartToWire, planPictures, planSells, planStockPhotos, planToWire, planWireGaps, planWirePartJsonSchema, planWirePartShape, planWireShape, planWordIssues, popupMeaning, popupMixFromWords, popupMixOfPlan, popupTokenOf, popupWireWords, previousRoute, pricesIn, promptLimitsOf, publishRefusal, publishVerdict, quietMoveEntrance, quoteItemOf, quoteListOf, quotesIn, readHeader, readOpening, readyMadeColumn, readyMadeToken, recipeListBinds, recomposeAsks, redesignAdditionsJsonSchema, redesignBackOpen, redesignBackUntil, redesignDiscardable, redesignPreviousChoices, refitBuiltPage, refitPage, refreshSectionStamps, releasedLayoutDefaults, removeBarItem, requiredAcknowledgements, requiredShapeKeys, rewordStoreGlobal, rhythmIssues, roleField, routeMatches, routeParams, samenessIssues, sampleImageRef, scoreStockPhoto, screenFontSize, screenWordColumns, screenWordMisfit, screenWordOverflowPx, scrubEntranceStamps, scrubTokenOf, scrubUntilChoice, scrubbedEntrance, scrubsEntrance, sectionBreaks, sectionBuildKey, sectionEntrances, sectionFingerprint, sectionOrigin, sectionPatternIds, sectionToWire, sectionTokenOf, sectionUnchanged, sectionsNamed, sequenceRepeats, sequenceShare, sequenceTokenOf, setStyleProps, settleLayoutPage, shapeKeys, shopCategoriesOf, shopContentType, shopListAliases, shopListsShownOn, shopPageOfPlan, shopSourceAliases, showcaseGlobals, showcasePages, showcasePlans, showcaseScenes, showcaseStorePages, shownTogether, signatureOf, siteBuiltWithLaw, siteFactLabel, siteGlobalsOf, siteNavPages, sitePages, sitePagesOf, siteParentRoute, siteSells, siteTreeOf, siteTreeOfPlan, slotBudget, splitCssValue, splitSide, stampFooterMix, stampHeaderMix, stampOpeningMix, stampOpeningMotion, stampSection, startComposingShare, startQuote, stockCopyKey, stockCreditLine, stockCreditLines, stockCreditNode, stockCreditNodeId, stockFits, stockGroupOf, stockItemSlots, stockKept, stockPhotoRatio, stockPhotoSubject, stockPhotoUsable, stockPhotoWords, stockSlots, stockWord, stockWords, storedHeaderMix, storedOpeningMix, strictSchemaComplexity, strictSchemaRefusal, swapParts, tierOf, tierOffers, toneOf, typeLedGroundFor, typeLedGrounds, typeLedLayoutSection, typeLedNotices, typeLedOpeningSection, typeLedOpeningWays, typeLedRound, typeLedSection, typesOfAddition, typicalStepTokens, validatePlanEdits, validateSitePlan, variantNamesOf, walkFree, walkSerialized, wearBodyMix, wireContentTypeJsonSchema, wireDataSourceJsonSchema, wireFieldJsonSchema, wirePageJsonSchema, wireSectionJsonSchema, wireShopProductJsonSchema, withAdditions, withCarriedText, withComposedPages, withDerivedSources, withDistinctFooter, withDistinctHeader, withHeaderWord, withListWord, withOpeningWord, withShownList, withoutFreeOrphans, wordPattern, wordsOverPhotos, wordsOverPicture, wornHeaderOfPlan, wornOpenings, writtenTexts };
41943
+ export { ACCOUNT_ENTRY_ID, ACTION_START_SCALE, ACTIVE_BUILD_STATUSES, ADDITION_CAPS, ADDITION_ITEMS_KEY, ADDITION_ITEM_SOURCE_SUFFIX, ADDITION_KEY_PREFIX, ADDITION_SLUG, ADJUSTMENTS, ADJUST_AXIS_LABELS, ADJUST_LOOK, ADJUST_OWN, ADJUST_STEPS, ADJUST_STEP_IDS, AI_COMPOSED_PAGES_BY_TIER, AI_COMPOSED_PAGES_ESTIMATED, AI_COMPOSED_PAGE_LEAN_TOKENS, AI_MODEL_STEPS, AI_PICTURE_MAKERS, AI_PLAN_REASKED_PART, AI_REFUSAL_NEXT, AI_REFUSAL_STATUS, AI_STEPS, AI_STEP_FEATURE, AI_STEP_LABELS, AI_STEP_NEEDS, AI_STEP_PART_TOKENS, AI_STEP_RUNS_AS, AI_STEP_TYPICAL_TOKENS, ART_DIRECTION_PARTS, AWARD_COMPOSED_PAGES_ESTIMATED, AdditionHeldBack, AdditionIssueCode, AdditionOrigin, AdditionsPart, AdditionsSkipped, AdjustAxis, AdjustKind, AiCallStatus, AiCapability, AiFeature, AiGenerationStage, AiKeyMode, AiLimit, AiNextKind, AiPictureMaker, AiProviderId, AiRefusalCode, AiStep, BAR_ITEMS_MAX, BAR_ITEMS_MIN, BASELINE_ROLES, BASELINE_WORDS_HE, BODY_TOKEN, BUILD_STEPS, BUTTON_LINK_PROPS, BaselineRole, BindScope, BodyIngredient, BodyMixError, BodyRepairCode, BodyRhythm, BodySeam, BodySectionWord, BodyTexture, BuildNoticeCode, BuildStep, CARRIED_BUTTON_STYLES, CARRY_LAYER_KINDS, CARRY_PHOTO_KINDS, CARRY_PROMPT_QUOTE, CARRY_WHOLE_LAYER_KINDS, CONTENT_ROLE_MEANINGS, COPY_OUT, CREDITS_PER_USD, CardBindTarget, CarryBlockKind, CarryKeptReason, CarryKind, CarryReferenceVia, CheckSeverity, ComposeError, ComposeIssueCode, ContentFieldControl, ContentFieldType, ContentRole, ContentTypeAction, CreatedKind, DANGLING_LINK_CODES, DEFAULT_FOOTER_PATTERN, DEFAULT_GENERATION_TIER, DEFAULT_HEADER_PATTERN, DEFAULT_PHONE_MENU_BREAKPOINT, DEFAULT_SITE_LOCALE, DRAWER_BEAT_MS, DRAWER_KINDS, DRAWER_LETTER_MS, DRAWER_LINE_MS, DRAWER_SPINE, DRAWER_STEPS, ENTRANCE_EASING, ENTRANCE_ORIGIN_LOOK, ENTRANCE_TRIGGER, EntrancePart, EntranceSide, FACT_KEYS, FIELD_TYPE_OF_CONTROL, FILL_ASPECT, FILM_PATTERN, FINAL_GENERATION_STAGES, FINDING_SEVERITY, FOOTER_INSET_STYLES, FOOTER_LEGAL_ROLE, FOOTER_TOKEN, FORM_LEGAL_ROLE, FREE_BUILDER_TYPE, FREE_CONTRAST, FREE_ELEMENT_STYLES, FREE_HOLDERS, FREE_HOVER_PROPS, FREE_LEAD_ROLE, FREE_MOVES, FREE_PHONE_LAYERS, FREE_PHONE_LIMITS, FREE_SECTIONS, FREE_STYLE_PROPS, FREE_TOKEN_PROPS, FREE_TO_LAYOUT_CODE, FREE_WIRE_NODE_KEYS, FREE_WORD_TYPES, FallbackOpeningKept, FilmUnplaced, FindingGrouping, FooterArrange, FooterClosing, FooterGround, FooterHold, FooterIngredient, FooterMixError, FooterNameStyle, FooterRepairCode, FooterRole, FreeIssueCode, FreeLayer, FreeNodeType, FreePictures, FreePurpose, FreeTrigger, GRAMMAR_TOO_LARGE_MESSAGE, GenerationTier, GlobalSlot, GroundTone, HAND_PAGE_KEY_PREFIX, HEADER_TOKEN, HEBREW_PREFIXES, HeaderAction, HeaderArrange, HeaderIngredient, HeaderMixError, HeaderPages, HeaderRepairCode, HeaderReplacedKind, IMPORT_NAV_MAX, IMPRINT_COUNTRIES, ISRAEL, ITEM_PAGE_ONLY_ROLES, ImportPattern, JOINED_HEADER_PADDING, JSON_SCHEMA_BANNED_KEYWORDS, JsonSchemaShapeError, KeptPagesChoice, KeptReason, LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_CHECK_VIEWPORT, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_COLUMN_MENDED, LAYOUT_DEPTH_ON_PHONE, LAYOUT_DRIFT, LAYOUT_EASING, LAYOUT_ENTRANCE_MAX_MS, LAYOUT_FONT_SIZE, LAYOUT_HIDDEN_OPACITY, LAYOUT_KINETIC_KINDS, LAYOUT_LINE_HEIGHT, LAYOUT_LIST_TOKEN, LAYOUT_MIX_OFFERED, LAYOUT_MIX_OFFERED_AWARD, LAYOUT_MIX_WORDS, LAYOUT_NEAR_MISS, LAYOUT_OPERATED, LAYOUT_OWNED_PROPS, LAYOUT_PACE, LAYOUT_PHONE_BREAKPOINT, LAYOUT_PHONE_PADDING, LAYOUT_PHOTO_ASPECT, LAYOUT_READY_MADE_TOKEN, LAYOUT_RISE, LAYOUT_SCREEN_PX, LAYOUT_SETTLE_PASSES, LAYOUT_TEXT_KINDS, LAYOUT_TOOLTIP_TRAIT, LAYOUT_VIEWPORTS, LAYOUT_WIRE_AUTOPLAY_MS, LEGAL_KINDS, LEGAL_PAGE_SETTING, LIST_CARD_PART, LIST_DECK_MAX_PX, LIST_DECK_SHARE, LIST_FRAME_STYLE_KEYS, LIST_INGREDIENTS, LIST_ITEM_MIN_PX, LIST_LONG_WORDS, LIST_RHYTHMS, LIST_ROLE_WORDS, LIST_RULES, LIST_SAY_WORDS, LIST_TABLE, LIST_WORDS_BESIDE_RULE, LayoutAlign, LayoutBleed, LayoutButtonVariant, LayoutColour, LayoutColourMode, LayoutDepth, LayoutDial, LayoutEase, LayoutEditOp, LayoutEnter, LayoutGalleryEffect, LayoutGapCode, LayoutIssueCode, LayoutLayerKind, LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListHow, LayoutListItem, LayoutListMove, LayoutListPhone, LayoutListRole, LayoutListSide, LayoutListWho, LayoutMendKind, LayoutMixIngredient, LayoutNavKind, LayoutPace, LayoutPhotoShape, LayoutPhotoSource, LayoutRole, LayoutScrubRefusal, LayoutSectionKind, LayoutSequenceToken, LayoutSide, LayoutSignatureId, LayoutSize, LayoutSourceChoice, LayoutTrackProp, LayoutTransition, LayoutViewport, LegalBlocks, LegalFact, LegalKind, ListPartChange, ListPartOutcome, ListSayCode, ListWordRefusal, MAX_SITE_PICTURES, MOTION_TRIGGERS, MOVING_OPENING_MEDIA, MenuSide, NAV_PART_LABELS, NAV_SHAPE_COPY, NEUTRAL_STYLE_PROPS, NODE_BASELINES, NO_TOKENS, NavPagesSource, NavRole, NavShape, NavShapeError, ONCE_ENTRANCE_MS, OPENING_DISSOLVE, OPENING_HEIGHT, OPENING_MIX_PROP, OPENING_TOKEN, OpeningExtra, OpeningFrame, OpeningGround, OpeningIngredient, OpeningMedia, OpeningMixError, OpeningMotion, OpeningRepairCode, OpeningRole, OpeningWords, PAGE_ARCHETYPES, PERSONAL_CONTROLS, PHOTO_ANALYSIS_WIDTH, PHOTO_CALM_DETAIL, PHOTO_GRID, PHOTO_LIGHT_LUMINANCE, PICTURE_ASPECTS, PICTURE_NEVER, PICTURE_REAL_PLACE_FAMILIES, PICTURE_REROLL_EVERY, PICTURE_REVIEW_FORMAT, PICTURE_REVIEW_SHAPE, PICTURE_TEXT_CONTRAST, PICTURE_TOKENS_UNKNOWN_MAKER, PICTURE_WORLDS, PICTURE_WORLD_IDS, PLAN_EDITS_ANSWER_SHAPES, PLAN_EDITS_PART_SCHEMA_NAMES, PLAN_EDIT_OP_PART, PLAN_EDIT_SHAPE, PLAN_EDIT_WIRE_KEYS, PLAN_PARTS, PLAN_PART_KEYS, PLAN_WIRE_DERIVED, PLAN_WIRE_PART_SCHEMA_NAMES, PLAN_WIRE_SHAPE, POPUP_GLOBAL_ID, POPUP_LINK_WORD, POPUP_WIRE_INGREDIENTS, PREVIOUS_ROUTE_SUFFIX, PRICING_PATTERN, PROOF_FINGERPRINTS, PUBLISH_BLOCKING_PLACEHOLDERS, PageDataKind, PathIssueCollector, PatternDirective, PatternGlobalPosition, PatternOpens, PatternPlaceholder, PatternRecipe, PhoneMenuBreakpoint, PhotoTone, PictureRefusal, PictureWorld, PlaceholderKind, PlanChangeAction, PlanChangeKind, PlanDataSourceMode, PlanDataSourceType, PlanEditIssueCode, PlanEditOp, PlanEditsOutcome, PlanPart, PlanWireEntry, PlanWireShapeError, PlanWordIssueCode, PopupMixError, PopupRefusal, PreflightRefusalCode, PriceBindTarget, PromptLimit, PublishRefusalCode, PublishScope, REDESIGN_ADDITIONS_SCHEMA_NAMES, REDESIGN_BACK_DAYS, REDESIGN_PARTS, REDESIGN_STEPS, RENDER_CHECK, REQUIRED_CONTENT_ROLES, RedesignPageResult, RedesignPart, RedesignRefusalCode, RedesignStep, RelativeOp, SAMPLE_IMAGE_REF, SCENE_LEVEL, SCENE_OTHER_PAGES, SCRIM_BACKGROUND, SCRIM_COVER, SCRIM_LEVELS, SCRUBBED_ENTRANCE, SCRUB_UNTIL, SHOP_CART_BUTTON_ID, SHOP_CART_DRAWER_ID, SHOP_FIELDS, SHOP_LATEST_LIMIT, SHOP_LIST_LIMIT, SHOP_NEED, SHOP_ONLY_CONTENT_ROLES, SHOP_PRODUCTS_MAX, SHOP_ROLES, SHOP_SLUG_FIELD, SHOWCASE_FILM, SHOWCASE_SHOP, SIGN_IN_DIALOG_ID, SITE_CHECKS, SITE_FACT_LABELS, SITE_FINDING_WORDS, SITE_HEADER_PATTERN, SITE_LIBRARY, SITE_LOCALES, SITE_NEED_IDS, SITE_PAGE_MOVED_ASIDE, SITE_PATTERNS, SITE_PLAN_VERSION, SITE_TEMPLATES, SPEC_SITE_ARCHETYPES, SPEC_SITE_COPY_LENGTHS, SPEC_SITE_DENSITY_COPY, SPEC_SITE_FACTS, SPEC_SITE_FOOTER_PARTS, SPEC_SITE_HEADER_PARTS, SPEC_SITE_LAYOUT, SPEC_SITE_LIBRARY, SPEC_SITE_LOCALES, SPEC_SITE_NEED_IDS, SPEC_SITE_PATTERNS, SPEC_SITE_PICTURE_NEVER, SPEC_SITE_PICTURE_WORLDS, SPEC_SITE_PLAN_SHAPE, SPEC_SITE_REQUIRED_ROLES, SPEC_SITE_ROLES, SPEC_SITE_TEMPLATES, STAMPED_PAGE_ARCHETYPES, START_QUOTE_STEPS, START_QUOTE_TOKENS, STOCK_FAMILIES, STOCK_FAMILY_INTENTS, STOCK_INTENT_ORDER, STOCK_INTENT_SUBJECTS, STOCK_ITEM_ASPECT, STOCK_MIN_KEPT, STOCK_PROVIDER_TERMS, STOCK_SEED_MARGIN, STOCK_SUBJECT_WORDS, STORE_CONTACT_CODES, STRICT_SCHEMA_BUDGET, STRICT_SCHEMA_LIMITS, STUDIO_TEMPLATE, SWAP_CARRY_KINDS, ScrimLevel, ScrubUntil, SectionFallbackLastResort, SectionMaker, SectionSwapAction, SectionSwapRule, ShopResource, ShopSourceRole, SiteBuildKind, SiteBuildStatus, SiteCheckId, SiteFindingCode, SiteLocale, SitePageMaker, SitePageStatus, SitePlanError, SitePlanIssueCode, SitePlanSourceKind, SiteTemplateError, SiteTemplateId, StagedPageReason, StagedPageWay, StepState, StockIntent, StockOrientation, StockProviderId, StockReviewFlag, StockReviewVerdict, StockSlotKind, StockSubject, TEMPLATE_TYPE_WORDS, TYPE_LED_KEPT, TYPE_LED_OPTIONAL_PARTS, TYPE_LED_SWAPS, TypeLedChangeKind, WORDS_AREA_DEFAULT_SHARE, WordsEdge, addBarItem, addStockCredits, additionKey, additionSourcesOf, additionsNeedContent, adjustStepLabel, adjustStepOf, adjustStyleProps, aiModelStep, aiRefusalNext, aiStepParts, applyHeaderMix, applyLayoutEdits, applyOpeningMix, applyOwnPhotoGalleries, applyPictureScrims, applyPlanEdits, applyStockItemPhotos, applyStockPhotos, archetypeIssues, areaLuminance, artDirectionFor, artDirectionIssues, artDirectionPreamble, aspectRatioOf, assertStyleSlots, assertValidSitePlan, auditLayoutMotion, auditSite, barIconForRoute, bentoFill, bentoFillsParams, blocksPublish, bodyMeaning, bodyMix, bodyMixFromWords, bodyMixOfPlan, bodyMixWords, bodySeamClass, bodySeamShape, bodyTokenOf, bodyWireWords, bodyWordDrawn, bodyWordOffered, bodyWordTier, bodyWordWaits, bodyWords, boxSides, brandHueWord, buildKeys, buildStepFacts, buildStepsOf, builtHomePageId, calmParts, calmUnder, canonicalNodeJson, canonicalValue, carryBlockOf, carryButtonLink, carryHandles, carryInto, carryKindOf, carryNotPlaced, carrySection, checkAdditions, checkBody, checkCarry, checkFooter, checkFree, checkFreeSection, checkHeader, checkLayout, checkList, checkOpening, checkPopup, chooseScrim, chooseTypeLedOpening, columnIssues, composablePage, composeContextOf, composeFreePage, composeFreeSection, composeLayout, composeListFrame, composeNavHeader, composeOpening, composePopup, composePresetForm, composeSection, composeSite, composedPagesMax, composedPagesShare, composerLeftovers, composingShare, contactFactsOf, contentTypeOfSource, contentTypePreviewFields, contentTypeToWire, copyLengthOf, copyOutInteraction, costUsd, countryLegalFacts, coverCrop, createSerializedNode, creditsOfUsd, dataSourceToWire, derivedBeats, derivedDataSources, derivedShopSources, describeCarryForPrompt, describeInventoryForPrompt, describeListShape, describePlanData, describeShapeKey, dissolveInteraction, distinctFallbackSections, distinctFooter, distinctHeader, drawerRamp, drawerRestX, drawerStepCount, drawerSteps, drawerWidth, drawersTiming, drawnBodyMix, drawnFooterMix, drawnHeaderMix, drawnOpeningMix, driftAt, driftOverlap, duplicateNodeIds, editedPageIds, emptyAreaPhrase, emptyPictures, entranceAction, entranceInteraction, estimatePictures, estimateStepCredits, expandAdditions, expandFreeWire, expandLayoutWire, expandPlanWire, expandWireContentType, expandWireDataSource, expandWireEdit, expandWireField, expandWirePage, expandWireSection, expandWireShop, factIssues, failedBuildStep, fallBackBySection, fallBackFree, fallbackFingerprintOf, fallbackFingerprintOfPlanPage, fieldToWire, figuresNotIn, fillContactFacts, filmOfPlan, filmPlacement, findNavRoot, findOpening, findingMessageOf, findingSentence, fingerprintOf, fingerprintOfPlanPage, followedAfter, followedIssues, footerCallWord, footerMeaning, footerMix, footerMixFromWords, footerMixOfPlan, footerMixWords, footerNameFits, footerPattern, footerPatternIdOf, footerReferences, footerTableWords, footerTokenOf, footerTokenWords, footerWait, footerWireWords, footerWords, formAsksPersonalData, formLegalFacts, frameWords, freeContrastIssues, freeControlsOf, freeMoveOf, freeMoveWord, freeMoveWords, freeNodeId, freeSectionAsLayout, freeSectionOwner, freeSignaturePage, freeSlotIssues, freeStampedId, freeStyleIssues, freeStyleToSlots, freeStyleWithoutSlot, freeToWire, freeWireJsonSchema, freeWirePath, generationTierOf, groundToneOf, groupSentence, groupSiteFindings, handPageKey, handPlanPage, harvestPage, hash53, headerAdvice, headerCompanions, headerContextOfPlan, headerGallery, headerGalleryIdOf, headerMeaning, headerMix, headerMixFromWords, headerMixOfNavKind, headerMixOfPlan, headerMixValue, headerMixWords, headerPatternIdOf, headerRecipe, headerReferences, headerShape, headerSiteFor, headerTokenOf, headerTokenWords, headerWireWords, headerWordDrawn, headerWords, importSlug, importedPicturesOf, isActiveBuild, isAdditionKey, isDrawers, isHandPageKey, isImportPlan, isLayoutRule, isLegalKind, isNonEmptyString, isPerItemPage, isPictureWorld, isPlainObject, isRedesignRun, isRtlLocale, isScrubbedEntrance, isSectionCarryHandle, isSectionStamp, isShopResource, isTemplateRoute, joinPageHeader, jsonAnyOf, jsonBoolean, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonSchemaKeywords, jsonSchemaObjects, jsonShapedObject, jsonText, judgeLayoutRender, keepListParts, layerMetricsOf, layerShownSpans, layoutBandScheme, layoutBoxPx, layoutColumnsOffered, layoutColumnsVw, layoutCounterDepth, layoutDesignOf, layoutDialOf, layoutDriftPhoto, layoutElementStyle, layoutEntersOffered, layoutFlagsOffered, layoutGalleryLists, layoutGallerySources, layoutGlideDepth, layoutHeldStill, layoutListBare, layoutListBinding, layoutListDrawnCols, layoutListPair, layoutListShapes, layoutListsContext, layoutLookChanges, layoutLookOf, layoutMixOffered, layoutMotionOf, layoutNearMiss, layoutNodeClass, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutPathSteps, layoutPhotoIds, layoutPresetColours, layoutPresetOf, layoutRepairJsonSchema, layoutRoomPx, layoutRuleEdge, layoutScrubTakes, layoutSectionKindsOffered, layoutShapeHasPurpose, layoutSignatureOffered, layoutSignaturesOffered, layoutStillLine, layoutTextFits, layoutTextWidthEm, layoutToWire, layoutVoidScreens, layoutVoids, layoutWireJsonSchema, layoutWirePartWords, legalFactsOf, legalFormLine, legalKindBlocks, legalKindOfPage, legalKindRow, legalKindsFor, legalLabel, legalPageOf, legalRoute, legalTitle, listBelowPro, listBindingOfType, listBuiltWords, listColumns, listDetailOf, listIngredientWords, listMeaning, listMixFromWords, listMixOfFrame, listMixValue, listMixWords, listNeverIsEmpty, listOverhang, listPanelRows, listSaidSentence, listSentence, listShapeOfType, listTokenOf, listTokensOf, listWait, listWordOffered, listWordRef, listWordRefs, listWordRefusal, listWordTier, listWords, luminanceOf, measureFree, measureLayout, mendCarry, mendLayout, mendNotices, menuAtEveryWidth, menuLookOf, menuWords, modelCanDo, moveBarItem, moveEntrance, nameStyleOf, namedFooterMix, namedHeaderMix, namedOpeningMix, navHeaderContext, navPages, navShapeBreakpoint, navShapeOf, nearestHeaderMix, nestSitePages, nextSourceOf, nodeBindPaths, offeredForTier, onceEntrance, openingAdvice, openingAdviceMix, openingContextOf, openingFromSection, openingGallery, openingGalleryIdOf, openingHarnessWord, openingIsTypeLed, openingMeaning, openingMix, openingMixFromWords, openingMixOfPlan, openingMixValue, openingMixWords, openingPatternIdOf, openingPhoneInset, openingRecipe, openingReferences, openingTokenOf, openingTokenParts, openingWireWords, openingWordDrawn, openingWordOffered, openingWordTier, openingWordWaits, openingWords$1 as openingWords, orientationOfRatio, outwardCredits, ownPhotoFit, ownerContentInto, paddingKeepingClear, pageBuildSource, pageListIssues, pageShowsShop, pageToWire, parseLayoutPhotoId, parsePatternPath, parseSampleImageRef, pathAt, patternById, patternHasForm, patternLinkSlots, patternListGap, patternManifest, patternNeedsBinding, patternNodes, patternOptionalParts, patternRoleNeeds, patternScopes, patternSlotBudgets, patternSlots, patternTakesBinding, phoneGapBefore, phoneMenuPages, phoneWordsColour, photoInventory, photoShapeOf, pickListWord, pictureAspect, pictureItemsOf, pictureMakerOf, picturePrompt, pictureRefusalOf, pictureRerolls, pictureReviewIssues, pictureReviewJsonSchema, pictureReviewPasses, pictureSlotKey, pictureTargets, pictureTokensFor, pictureTryFits, picturelessTypes, pinnedPagesOf, pixelsUnder, placeFilm, plainCarryText, planEditOps, planEditToWire, planEditWireGaps, planEditWireKeys, planEditWireOps, planEditWireShape, planEditsFromWire, planEditsJsonSchema, planEditsToWire, planEntrances, planFromTemplate, planHasShopSource, planHeader, planImport, planLayoutPhotos, planNavShape, planOwnPhotos, planPartOfPath, planPartToWire, planPictures, planSells, planStockPhotos, planToWire, planWireGaps, planWirePartJsonSchema, planWirePartShape, planWireShape, planWordIssues, popupMeaning, popupMixFromWords, popupMixOfPlan, popupTokenOf, popupWireWords, previousRoute, pricesIn, promptLimitsOf, publishRefusal, publishVerdict, quietMoveEntrance, quoteItemOf, quoteListOf, quotesIn, readHeader, readOpening, readyMadeColumn, readyMadeToken, recipeListBinds, recomposeAsks, redesignAdditionsJsonSchema, redesignBackOpen, redesignBackUntil, redesignDiscardable, redesignPreviousChoices, refitBuiltPage, refitPage, refreshSectionStamps, releasedLayoutDefaults, removeBarItem, requiredAcknowledgements, requiredShapeKeys, rewordStoreGlobal, rhythmIssues, roleField, routeMatches, routeParams, samenessIssues, sampleImageRef, scoreStockPhoto, screenFontSize, screenWordColumns, screenWordMisfit, screenWordOverflowPx, scrubEntranceStamps, scrubTokenOf, scrubUntilChoice, scrubbedEntrance, scrubsEntrance, sectionBreaks, sectionBuildKey, sectionEntrances, sectionFingerprint, sectionOrigin, sectionPatternIds, sectionToWire, sectionTokenOf, sectionUnchanged, sectionsNamed, sequenceRepeats, sequenceShare, sequenceTokenOf, setStyleProps, settleLayoutPage, shapeKeys, shopCategoriesOf, shopContentType, shopListAliases, shopListsShownOn, shopPageOfPlan, shopSourceAliases, showcaseGlobals, showcasePages, showcasePlans, showcaseScenes, showcaseStorePages, shownTogether, signatureOf, siteBuiltWithLaw, siteFactLabel, siteGlobalsOf, siteNavPages, sitePages, sitePagesOf, siteParentRoute, siteSells, siteTreeOf, siteTreeOfPlan, slotBudget, splitCssValue, splitSide, stampFooterMix, stampHeaderMix, stampOpeningMix, stampOpeningMotion, stampSection, startComposingShare, startQuote, stockCopyKey, stockCreditLine, stockCreditLines, stockCreditNode, stockCreditNodeId, stockFits, stockGroupOf, stockItemSlots, stockKept, stockPhotoRatio, stockPhotoSubject, stockPhotoUsable, stockPhotoWords, stockSlots, stockWord, stockWords, storedHeaderMix, storedOpeningMix, strictSchemaComplexity, strictSchemaRefusal, swapParts, tierOf, tierOffers, toneOf, typeLedGroundFor, typeLedGrounds, typeLedLayoutSection, typeLedNotices, typeLedOpeningSection, typeLedOpeningWays, typeLedRound, typeLedSection, typesOfAddition, typicalStepTokens, validatePlanEdits, validateSitePlan, variantNamesOf, walkFree, walkSerialized, wearBodyMix, wireContentTypeJsonSchema, wireDataSourceJsonSchema, wireFieldJsonSchema, wirePageJsonSchema, wireSectionJsonSchema, wireShopProductJsonSchema, withAdditions, withCarriedText, withComposedPages, withDerivedSources, withDistinctFooter, withDistinctHeader, withHeaderWord, withListWord, withOpeningWord, withShownList, withoutFreeOrphans, wordPattern, wordsOverPhotos, wordsOverPicture, wornHeaderOfPlan, wornOpenings, writtenTexts };
41905
41944
  //# sourceMappingURL=vectoriox-iox-ui-generation-core.mjs.map