@aglyn/plugins-ai 1.22.0 → 1.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-job-requests.d.ts +5 -1
  3. package/src/lib/components/ai-job-requests.js +9 -0
  4. package/src/lib/components/ai-job-requests.js.map +1 -1
  5. package/src/lib/jobs/ai-job-import-step.d.ts +8 -0
  6. package/src/lib/jobs/ai-job-import-step.js +19 -2
  7. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  8. package/src/lib/jobs/ai-job-page-language.d.ts +8 -0
  9. package/src/lib/jobs/ai-job-page-language.js +22 -1
  10. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  11. package/src/lib/jobs/ai-job-page-step.d.ts +10 -0
  12. package/src/lib/jobs/ai-job-page-step.js +23 -1
  13. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  14. package/src/lib/jobs/ai-site-import-actions.d.ts +12 -3
  15. package/src/lib/jobs/ai-site-import-actions.js +43 -18
  16. package/src/lib/jobs/ai-site-import-actions.js.map +1 -1
  17. package/src/lib/jobs/ai-site-import-improve.d.ts +44 -0
  18. package/src/lib/jobs/ai-site-import-improve.js +308 -21
  19. package/src/lib/jobs/ai-site-import-improve.js.map +1 -1
  20. package/src/lib/layout-language/ai-layout-compiler.d.ts +6 -0
  21. package/src/lib/layout-language/ai-layout-compiler.js +10 -4
  22. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  23. package/src/lib/layout-language/ai-layout-frame.js +11 -2
  24. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  25. package/src/lib/layout-language/ai-layout-gaps.d.ts +27 -0
  26. package/src/lib/layout-language/ai-layout-gaps.js +124 -0
  27. package/src/lib/layout-language/ai-layout-gaps.js.map +1 -1
  28. package/src/lib/layout-language/ai-layout-language.d.ts +5 -0
  29. package/src/lib/layout-language/ai-layout-language.js +46 -1
  30. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  31. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +9 -8
  32. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  33. package/src/lib/site-import/site-import-page.d.ts +2 -2
  34. package/src/lib/site-import/site-import-page.js +42 -2
  35. package/src/lib/site-import/site-import-page.js.map +1 -1
@@ -764,12 +764,21 @@ import { AiLayoutTreeBuilder } from "./ai-layout-tree.js";
764
764
  * A source's footer (AGL-4108): its columns, words, profiles and © line, as
765
765
  * the source has them, on the quiet band a footer sits on.
766
766
  */ function sourceFooter(page, source, plan, name) {
767
+ var _footerLogoOf;
767
768
  const tree = page.tree;
768
769
  const drawn = aiLayoutSourceFooter(tree, source.footer, {
769
770
  name
770
771
  });
771
- // It opens with the logo, where the source's does (AGL-4139).
772
- const logo = footerLogoOf(tree, plan, name);
772
+ // It opens with the logo, where the source's does (AGL-4139); a footer a site's plan draws always opens with the
773
+ // brand, its logo or else its name as a wordmark (AGL-4152).
774
+ const logo = (_footerLogoOf = footerLogoOf(tree, plan, name)) != null ? _footerLogoOf : source.planned === true && name.trim() ? tree.add('muiTypography', {
775
+ children: name.trim(),
776
+ variant: 'h6',
777
+ component: 'p'
778
+ }, {
779
+ fontWeight: 800,
780
+ color: 'text.primary'
781
+ }, null, 'footerWordmark') : null;
773
782
  // A planned footer with no columns to carry is one short band, never a tall one around its © line (AGL-4152).
774
783
  const compact = source.planned === true && !drawn.top;
775
784
  const stack = tree.add('muiStack', {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/layout-language/ai-layout-frame.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SX_SCHEME_DARK_KEY } from '@aglyn/aglyn/app-utils/scheme-sx'\nimport type { AiStoreFrameLinks } from '../model/ai-site-store-pages'\nimport { AI_ICON_LIBRARY } from '../runtime/ai-icon-library'\nimport {\n AI_LAYOUT_MAX_IMAGES,\n bandSx,\n compileFlow,\n compileRow,\n destinationProps,\n type PageScope,\n type SectionScope,\n} from './ai-layout-compiler'\nimport { aiLayoutContactItems, aiLayoutContactShown } from './ai-layout-contact'\nimport { aiLayoutFitText } from './ai-layout-copy'\nimport { aiLayoutRepairFrameHollows } from './ai-layout-frame-hollows'\nimport { AI_LAYOUT_CART_ELEMENT } from './ai-layout-listings'\nimport {\n AI_LAYOUT_MAX_ITEMS,\n type AiLayoutBand,\n type AiLayoutBlock,\n type AiLayoutSection,\n type AiLayoutSettlement,\n} from './ai-layout-language'\nimport { AI_LAYOUT_LABELS_EN, aiLayoutLabel } from './ai-layout-labels'\nimport {\n aiLayoutRenamedLabel,\n aiLayoutResolveLink,\n type AiLayoutPage,\n type AiLayoutTargets,\n} from './ai-layout-links'\nimport {\n AI_LAYOUT_HEADER_MEASURE,\n aiLayoutNavBreakpoint,\n aiLayoutSourceFooter,\n aiLayoutSourceHeader,\n type AiLayoutFrameSource,\n} from './ai-layout-frame-source'\nimport { AiLayoutTreeBuilder, type AiLayoutRawTree } from './ai-layout-tree'\n\n/**\n * A site's frame — the header and the footer every page renders between —\n * compiled from the layout language (AGL-3660), the same language a page is\n * designed in.\n *\n * The design is the model's: the header's band and alignment and its one\n * call to action, and the footer's columns and every word in them. What a\n * frame owes the site is the platform's, written here, so it is never wrong\n * and never invented: the site's name as the brand, linking home; its pages\n * as the navigation, a row on a wide screen and the platform's Drawer behind\n * its Menu Button on a phone; the Layout Slot, the page's one main landmark,\n * held tall enough that the footer sits at the bottom of a short page; and\n * the site's pages and name in the footer, where the design gave neither.\n *\n * Every label of the navigation is held to one line, the logo never narrower\n * than itself, and the row shows from the screen width it measures to fit\n * (`aiLayoutNavBreakpoint`), the Menu Button below it (AGL-4108: the 10/29\n * import's seven long titles wrapped from 900 px up and the logo lay over\n * \"Home\" at 1280). A site brought in from elsewhere whose menu the reader\n * found is drawn as its source builds it instead (`plan.source`,\n * `ai-layout-frame-source.ts`): its menus, its buttons, its phone menu and its\n * footer, in place of the site's pages and the design's button and footer.\n */\n\nexport interface AiLayoutFramePlan {\n /** The site's name, which the header and the footer carry as its brand. */\n siteName: string\n /** The site's home page, which the brand links; none where the site has none yet. */\n homeId: string | null\n /** The pages the navigation links, in order. */\n navPages: readonly AiLayoutPage[]\n /**\n * Whether the site's pages close on a dark photo band (AGL-3660,\n * `AiLayoutDesignChoices.coverClose`): a brand or dark footer under it\n * would read as a second loud band, so the footer takes the quiet one.\n */\n closesDark?: boolean\n /**\n * Whether the site sells (AGL-3676): its header carries the store's cart\n * button — the commerce plugin's Cart, which opens the cart in a drawer\n * from every page — beside the navigation.\n */\n cart?: boolean\n /**\n * A selling store's Shop page (AGL-3676), by its id. Its header is a\n * storefront's: the cart beside the navigation and no call-to-action button\n * repeating a link the navigation already has, and a thin announcement bar\n * above it — the line the design gave its header as a note, else one that\n * opens the shop — linking the Shop page.\n */\n shopId?: string | null\n /**\n * A store's own pages (AGL-3676), by path: the header links the account\n * beside the cart, and the footer the account and the store's policies\n * under the site's pages. They are written after the layout, so they are\n * linked by their addresses, as the blog is.\n */\n storeLinks?: AiStoreFrameLinks | null\n /** The site's language (AGL-3760): the frame's own words are in it where `ai-layout-labels.ts` lists it. */\n language?: string\n /**\n * The brand as a site brought in from elsewhere draws it (AGL-4084): its\n * logo alone, its logo with its name, or its name alone, as the source's\n * header shows it. Absent, the name alone.\n */\n brand?: AiLayoutFrameBrand | null\n /**\n * A site brought in from elsewhere whose header the reader found\n * (AGL-4108): its menu with its menus, its buttons with their own\n * addresses, its phone menu and its footer, drawn as the source has them\n * (`ai-layout-frame-source.ts`) in place of the site's pages and the\n * design's button and footer.\n */\n source?: AiLayoutFrameSource | null\n}\n\n/** A header's brand as the source shows it (AGL-4084). */\nexport interface AiLayoutFrameBrand {\n /** The logo, from the site's own media library. */\n logo?: { src: string } | null\n /** The logo a dark-scheme visitor sees, where the frame draws one for each scheme (AGL-4119). */\n logoDark?: { src: string } | null\n /** Whether the footer opens with the logo too (AGL-4119). */\n footer?: boolean\n /** Whether the header prints the name as words, beside the logo or alone. */\n name: boolean\n /** The logo's words for a screen reader, as the source names it (AGL-4108); the site's name where it gave none. */\n alt?: string\n /** The logo's width over its height, which the header row is measured with (AGL-4108). */\n aspect?: number\n /** The height a redesigned header draws it at (AGL-4152); absent, `AI_LAYOUT_LOGO_HEIGHT`. */\n height?: string\n}\n\n/** The height a header's logo is drawn at: a Besigner field the owner may change. */\nexport const AI_LAYOUT_LOGO_HEIGHT = '40px'\n\n/** What the header's link to a store's account page says (AGL-3676), in English. */\nexport const AI_LAYOUT_ACCOUNT_LINK = AI_LAYOUT_LABELS_EN.account\n\n/** What a store's announcement bar says where its design gave it no line (AGL-3676): true of every store. */\nexport const AI_LAYOUT_STORE_ANNOUNCEMENT = AI_LAYOUT_LABELS_EN.storeAnnouncement\n\n/** The way into the shop beside the design's own announcement (AGL-3676). */\nexport const AI_LAYOUT_STORE_ANNOUNCEMENT_LINK = AI_LAYOUT_LABELS_EN.shopNow\n\nexport interface AiLayoutCompiledFrame {\n tree: AiLayoutRawTree\n settled: AiLayoutSettlement[]\n}\n\n/** The header's colors by band, as palette roles. */\nfunction headerLook(band: AiLayoutBand): {\n props: Record<string, unknown>\n sx: Record<string, unknown>\n} {\n if (band === 'brand')\n return { props: { color: 'primary' }, sx: { boxShadow: 'none' } }\n if (band === 'dark') {\n return {\n props: { color: 'primary' },\n sx: {\n boxShadow: 'none',\n bgcolor: 'primary.dark',\n color: 'primary.contrastText',\n },\n }\n }\n // A rule, a shadow or nothing under a plain header is the site theme's\n // MuiAppBar style (AGL-3660); the band's color stays here.\n return {\n props: { color: 'inherit' },\n sx: { bgcolor: 'background.paper' },\n }\n}\n\n/** A line that reads as a copyright notice: \"© 2026 …\", \"Copyright …\", \"All rights reserved.\" */\nexport function aiLayoutIsCopyright(text: unknown): boolean {\n return typeof text === 'string' && /^\\s*(?:©|\\(c\\)|copyright\\b)|all rights reserved/i.test(text)\n}\n\n/** What a footer leaves out: a picture slot, and the page sections a footer is no place for. */\nconst FOOTER_LEAVES_OUT: ReadonlySet<AiLayoutBlock['kind']> = new Set([\n 'image',\n 'faq',\n 'quotes',\n 'cards',\n 'steps',\n 'stats',\n 'form',\n 'component',\n])\n\n/** A frame scope: no headings of its own (a layout carries no outline), no pictures. */\nfunction frameScope(\n page: PageScope,\n at: string,\n band: AiLayoutBand,\n centered: boolean,\n): SectionScope {\n return {\n page,\n index: at === 'header' ? 0 : 1,\n at,\n band,\n centered,\n level: 2,\n headed: true,\n itemsLeft: AI_LAYOUT_MAX_ITEMS,\n frame: true,\n link: { sections: [], from: -1, formSection: null },\n }\n}\n\n/** Compiles a site's header and footer, designed in the layout language, into its layout. */\nexport function aiCompileLayoutFrame(\n frame: { header: AiLayoutSection | null; footer: AiLayoutSection | null },\n plan: AiLayoutFramePlan,\n targets: AiLayoutTargets,\n): AiLayoutCompiledFrame {\n const tree = new AiLayoutTreeBuilder('lf')\n // A store's own pages are destinations the footer's list links by path (AGL-3676).\n const storePages: AiLayoutPage[] = (plan.storeLinks?.footer ?? []).map((link) => ({\n id: `store:${link.href}`,\n label: link.label,\n slug: link.href,\n href: link.href,\n }))\n const page: PageScope = {\n tree,\n plan: { title: plan.siteName, sections: [] },\n targets: { ...targets, pages: [...targets.pages, ...storePages], pageId: null },\n // A footer is drawn compact: its lines are lines, never blocks rule 1 would ask to share.\n options: { reusableComponents: true, ...(plan.language ? { language: plan.language } : {}) },\n settled: [],\n scrollTo: {},\n // A frame's lines are its own, never a page section's items.\n itemIds: [],\n // A frame shows no picture slot: a header and a footer are the same on every page.\n images: AI_LAYOUT_MAX_IMAGES,\n strong: { brand: 0, dark: 0 },\n formSection: null,\n pageIcon: AI_ICON_LIBRARY.sparkle,\n formsPlaced: new Set(),\n // A frame is drawn the platform's one way on every site.\n design: null,\n pictures: 0,\n features: 0,\n splitAt: -2,\n quotesOnly: [],\n }\n const name = aiLayoutFitText(plan.siteName, 'heading', plan.language) || 'Home'\n const header = frame.header ?? { blocks: [] }\n const band = header.band ?? 'plain'\n const look = headerLook(band)\n const scope = frameScope(\n page,\n 'header',\n band === 'brand' || band === 'dark' ? 'brand' : 'plain',\n false,\n )\n const navLink = (\n entry: AiLayoutPage,\n role: string,\n interactions?: unknown[],\n ) => {\n const id = tree.add(\n 'muiScreenLink',\n {\n children:\n aiLayoutFitText(entry.label, 'label', plan.language) || entry.label.slice(0, 28),\n // The blog is a path, not a page (AGL-3660).\n ...(entry.href ? { href: entry.href } : { screenId: entry.id }),\n renderAs: 'link',\n color: 'inherit',\n },\n { textDecoration: 'none' },\n null,\n role,\n )\n if (interactions) tree.nodes[id].interactions = interactions\n return id\n }\n const pages = plan.navPages.filter((entry) => entry.label.trim())\n const centeredNav = header.align === 'center' && pages.length > 0\n // The brand takes the room the navigation does not, and gives way before\n // it does: a long name ends in an ellipsis rather than pushing into the links.\n // A logo never gives way: drawn narrower than itself it lay over the first\n // link (the 10/29 header at 1280, AGL-4108).\n const brandSx = {\n typography: 'h6',\n fontWeight: 800,\n textDecoration: 'none',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n minWidth: 0,\n ...(centeredNav ? {} : { flexGrow: 1 }),\n }\n const logo = plan.brand?.logo?.src ? plan.brand.logo.src : null\n const source = plan.source ?? null\n const alt = (plan.brand?.alt ?? '').replace(/\\s+/g, ' ').trim().slice(0, 120) || name.slice(0, 40)\n const brand = logo\n ? brandMark(tree, { src: logo, srcDark: plan.brand?.logoDark?.src ?? null, name: name.slice(0, 40), alt, withName: plan.brand?.name === true, homeId: plan.homeId, centered: centeredNav, grow: !source, height: plan.brand?.height ?? AI_LAYOUT_LOGO_HEIGHT })\n : plan.homeId\n ? tree.add(\n 'muiScreenLink',\n {\n children: name.slice(0, 40),\n screenId: plan.homeId,\n renderAs: 'link',\n color: 'inherit',\n },\n brandSx,\n null,\n 'brand',\n )\n : tree.add(\n 'muiTypography',\n { children: name, variant: 'h6', component: 'p' },\n brandSx,\n null,\n 'brand',\n )\n // How wide the brand is drawn, which the row is measured with (AGL-4108).\n const aspect = plan.brand?.aspect && Number.isFinite(plan.brand.aspect) && plan.brand.aspect > 0 ? Math.min(plan.brand.aspect, 8) : null\n const logoHeight = Number.parseInt(plan.brand?.height ?? AI_LAYOUT_LOGO_HEIGHT, 10)\n const brandWidth = logo\n ? (aspect ? Math.round(aspect * logoHeight) : AI_LAYOUT_HEADER_MEASURE.logo) + (plan.brand?.name ? name.slice(0, 40).length * 11 + 12 : 0)\n : Math.min(name.length, 40) * 11\n // The source's own header (AGL-4108), drawn as it builds it.\n const close = [AI_LAYOUT_CLOSE_DRAWER]\n const drawn = source ? aiLayoutSourceHeader(tree, source, { onBrand: band === 'brand' || band === 'dark', close, brandWidth }) : null\n // Every label on one line, and the row only on a screen it fits (AGL-4108).\n const pagesBreakpoint = aiLayoutNavBreakpoint({ brandWidth, nav: pages.map((entry) => ({ label: entry.label, menu: false })), ctas: [] })\n const breakpoint = drawn?.breakpoint ?? pagesBreakpoint\n const nav = drawn\n ? drawn.nav\n : pages.length\n ? tree.add(\n 'muiStack',\n {\n component: 'nav',\n ariaLabel: 'Main',\n direction: 'row',\n spacing: '3',\n alignItems: 'center',\n },\n { display: { xs: 'none', [breakpoint]: 'flex' }, whiteSpace: 'nowrap' },\n pages.map((entry) => navLink(entry, 'navLink')),\n 'nav',\n )\n : null\n // The design's call to action: its first button, where it goes somewhere.\n // A source's header carries its own buttons instead (AGL-4108).\n const ctaBlock = source ? undefined : header.blocks.find((block) => block.kind === 'button')\n // A store's announcement: the first short line the design gave its header (AGL-3676).\n const store = !!plan.shopId\n const noteBlock = store ? header.blocks.find((block) => block.kind === 'note' || block.kind === 'text' || block.kind === 'lede') : undefined\n for (const block of header.blocks) {\n if (block !== ctaBlock && block !== noteBlock)\n page.settled.push({\n at: 'header',\n what: `a ${block.kind} in the header; left out`,\n })\n }\n const ctaLabel = ctaBlock ? aiLayoutFitText(ctaBlock.text, 'label', plan.language) : ''\n const ctaResolved =\n ctaBlock && ctaLabel\n ? aiLayoutResolveLink(ctaBlock.to, ctaLabel, scope.link, page.targets)\n : null\n if (ctaBlock && !ctaResolved)\n page.settled.push({\n at: 'header',\n what: `the button \"${ctaLabel}\" has nowhere to go; left out`,\n })\n // A storefront's header is its navigation and its cart (AGL-3676): the\n // live Willow Wick header's \"Shop candles\" button repeated its nav's Shop.\n // A store's button that only repeats a page the navigation links is left\n // out, and a store that sells carries its cart in that place instead.\n const repeatsNav =\n ctaResolved?.kind === 'page' && pages.some((entry) => !entry.href && entry.id === ctaResolved.screenId)\n const ctaTo = ctaResolved && store && (plan.cart || repeatsNav) ? null : ctaResolved\n if (ctaResolved && !ctaTo)\n page.settled.push({\n at: 'header',\n what: `the button \"${ctaLabel}\" left out: a store's header carries its ${plan.cart ? 'cart' : 'navigation'}, not a button repeating it`,\n })\n const ctaProps = ctaTo\n ? {\n children: aiLayoutRenamedLabel(ctaLabel, ctaTo),\n variant: 'contained',\n color: scope.band === 'brand' ? 'secondary' : 'primary',\n ...destinationProps(ctaTo),\n }\n : null\n // On the smallest phones the call to action moves into the menu.\n const cta = ctaProps\n ? tree.add(\n 'muiButton',\n ctaProps,\n {\n display: { xs: 'none', sm: 'inline-flex' },\n whiteSpace: 'nowrap',\n flexShrink: 0,\n },\n null,\n 'cta',\n )\n : null\n // A store's account, beside its cart and in the phone's menu (AGL-3676).\n const accountPath = plan.storeLinks?.account ?? null\n const accountLink = (role: string, interactions?: unknown[], sx?: Record<string, unknown>) => {\n const id = tree.add(\n 'muiScreenLink',\n { children: aiLayoutLabel('account', plan.language), href: accountPath, renderAs: 'link', color: 'inherit' },\n { textDecoration: 'none', whiteSpace: 'nowrap', ...sx },\n null,\n role,\n )\n if (interactions) tree.nodes[id].interactions = interactions\n return id\n }\n // A phone's menu: the platform's Drawer, opened by its Menu Button; a link\n // followed from it closes it. A source's holds its menus, links and buttons (AGL-4108).\n const drawer = drawn?.drawer.length\n ? tree.add(\n 'muiDrawer',\n { anchor: 'right' },\n null,\n [\n tree.add(\n 'muiStack',\n { component: 'nav', ariaLabel: 'Menu' },\n { display: 'flex', flexDirection: 'column', gap: 3, p: 3 },\n [...drawn.drawer, accountPath ? accountLink('menuAccount', close) : null],\n 'menu',\n ),\n ],\n 'drawer',\n )\n : !source && pages.length\n ? tree.add(\n 'muiDrawer',\n { anchor: 'right' },\n null,\n [\n tree.add(\n 'muiStack',\n { component: 'nav', ariaLabel: 'Menu' },\n {\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n p: 3,\n typography: 'h6',\n },\n [\n ...pages.map((entry) => navLink(entry, 'menuLink', close)),\n accountPath ? accountLink('menuAccount', close) : null,\n ctaProps\n ? tree.add(\n 'muiButton',\n { ...ctaProps, fullWidth: true },\n { mt: 2 },\n null,\n 'menuCta',\n )\n : null,\n ],\n 'menu',\n ),\n ],\n 'drawer',\n )\n : null\n const toggle = drawer\n ? tree.add(\n 'muiDrawerToggle',\n { ariaLabel: 'Open the menu' },\n // Pushed to the end of the row where no button is there to push it.\n { display: { xs: 'inline-flex', [breakpoint]: 'none' }, flexShrink: 0, ...(drawn && !drawn.ctas ? { ml: 'auto' } : {}) },\n null,\n 'menuButton',\n )\n : null\n const middle =\n nav && centeredNav\n ? tree.add(\n 'muiBox',\n null,\n { flexGrow: 1, display: 'flex', justifyContent: 'center' },\n [nav],\n 'navRoom',\n )\n : nav\n // A store's cart, on every page, where a shopper looks for it (AGL-3676).\n const cart = plan.cart\n ? tree.add(AI_LAYOUT_CART_ELEMENT, { variant: 'button' }, { flexShrink: 0 }, null, 'cart')\n : null\n // On a phone the account is in the menu, and the cart stays in the bar.\n const account = accountPath ? accountLink('account', undefined, { display: { xs: 'none', [breakpoint]: 'inline-flex' }, flexShrink: 0 }) : null\n // The row lives in a Container inside the Toolbar Content, which may only sit in an App Bar.\n const row = tree.add(\n 'muiContainer',\n { maxWidth: 'lg' },\n { display: 'flex', alignItems: 'center', columnGap: 3 },\n [brand, middle, drawn ? drawn.ctas : cta, account, cart, toggle, drawer],\n 'headerRow',\n )\n const toolbar = tree.add(\n 'muiToolbar',\n { disableGutters: true },\n { minHeight: { xs: 64, md: 76 } },\n // A source's menus shown on hover open under the whole bar (AGL-4139).\n [row, drawn?.panels ?? null],\n 'toolbar',\n )\n // A source's header bar on the ground it sits on (AGL-4108): the page's own, where it is the page's.\n const barLook = source?.header === 'page' ? { props: { color: 'inherit' }, sx: { bgcolor: 'background.default' } } : look\n const bar = tree.add(\n 'muiAppBar',\n {\n ...barLook.props,\n position: 'sticky',\n // Over a page that opens with a photo cover, the bar sits on the photo (AGL-3660).\n overHero: true,\n component: 'header',\n ariaLabel: 'Site header',\n },\n barLook.sx,\n [toolbar],\n 'header',\n )\n // A selling store's announcement bar, above the header, linking its shop (AGL-3676).\n const announcement =\n store && plan.cart && plan.shopId\n ? (() => {\n const said = aiLayoutFitText(noteBlock?.text, 'note', plan.language)\n if (noteBlock && !said) page.settled.push({ at: 'header', what: 'an announcement with no words left; the shop’s own line instead' })\n // The design's line, then the way into the shop; else the way in alone.\n const link = tree.add(\n 'muiScreenLink',\n {\n children: aiLayoutLabel(said ? 'shopNow' : 'storeAnnouncement', plan.language),\n screenId: plan.shopId,\n renderAs: 'link',\n color: 'inherit',\n },\n { fontWeight: 700 },\n null,\n 'announcementLink',\n )\n const words = said\n ? tree.add('muiTypography', { children: said, variant: 'body2', component: 'p' }, null, null, 'announcementText')\n : null\n return tree.add(\n 'muiStack',\n { direction: 'row', spacing: '1.5', justifyContent: 'center', alignItems: 'baseline', useFlexGap: true, flexWrap: 'wrap' },\n { bgcolor: 'primary.main', color: 'primary.contrastText', typography: 'body2', py: 1, px: 2 },\n [words, link],\n 'announcement',\n )\n })()\n : null\n // The page grows into the room the window leaves, so a short page keeps\n // its footer at the bottom.\n const slot = tree.add(\n 'layoutSlot',\n { component: 'main' },\n { flexGrow: 1 },\n null,\n 'slot',\n )\n const footer = source?.footer ? sourceFooter(page, source, plan, name) : compileFooter(page, frame.footer, plan, name)\n // No heading with nothing under it, no column of only a heading, columns\n // top-aligned (AGL-3735): a list under a heading can compile to nothing.\n if (aiLayoutRepairFrameHollows(tree.nodes as unknown as Record<string, unknown>)) {\n page.settled.push({ at: 'footer', what: 'a heading with nothing under it taken out, and its column with it' })\n }\n const column = tree.add(\n 'muiStack',\n null,\n { minHeight: '100vh' },\n [announcement, bar, slot, footer],\n 'frame',\n )\n tree.prune(column, new Set([slot]))\n const rootId = tree.add('div', null, null, [column], 'layout')\n return { tree: { rootId, nodes: tree.nodes }, settled: page.settled }\n}\n\n/** What a store's own column of account and policy links is headed where the footer design gave no store heading (AGL-3735). */\nexport const AI_LAYOUT_STORE_FOOTER_HEADING = AI_LAYOUT_LABELS_EN.customerCare\n\n/** A footer heading a store's account and policies belong under (AGL-3735). */\nconst STORE_HEADING = /\\b(?:shop|store|shopping|help|customer|care|support|service|orders?|account|policies|policy|legal|info|information|shipping|returns)\\b/i\n\n/**\n * The footer heading a store's account and policy links go under\n * (AGL-3735): a heading of the design's that names the store or its help\n * (\"Our shop\", \"Help\", \"Customer care\"), the first with nothing under it\n * before one with words or links of its own. Never the heading over the\n * site's pages, whose list is the site's navigation. `end` is where the\n * links go: the end of what that heading heads.\n */\nexport function aiLayoutFooterStoreHeading(\n columns: readonly AiLayoutBlock[][],\n navItems: readonly { to: string }[],\n): { column: AiLayoutBlock[]; end: number; heading: string } | null {\n const navTo = new Set(navItems.map((item) => item.to))\n const candidates: Array<{ column: AiLayoutBlock[]; end: number; heading: string; empty: boolean }> = []\n for (const column of columns) {\n column.forEach((block, at) => {\n if (block.kind !== 'heading' || !STORE_HEADING.test(block.text ?? '')) return\n let end = at + 1\n while (end < column.length && column[end].kind !== 'heading') end += 1\n const under = column.slice(at + 1, end)\n const site = under.some((one) => one.kind === 'list' && (one.items ?? []).some((item) => navTo.has(item.to ?? '')))\n if (site) return\n candidates.push({ column: column as AiLayoutBlock[], end, heading: String(block.text), empty: under.length === 0 })\n })\n }\n const pick = candidates.find((one) => one.empty) ?? candidates[0]\n return pick ? { column: pick.column, end: pick.end, heading: pick.heading } : null\n}\n\n/** A link followed from the phone menu closes it. */\nconst AI_LAYOUT_CLOSE_DRAWER = {\n id: 'ai-close-menu',\n name: 'Close the menu',\n enabled: true,\n trigger: { event: 'elementClick', everyTime: true },\n steps: [{ type: 'closeDrawer' }],\n}\n\n/**\n * The footer the design describes, with what every footer owes a visitor\n * written by code: the site's pages, where the design links none of them,\n * and the site's name under a rule.\n */\nfunction compileFooter(\n page: PageScope,\n footer: AiLayoutSection | null,\n plan: AiLayoutFramePlan,\n name: string,\n): string {\n const tree = page.tree\n const asked = footer?.band ?? 'soft'\n const band = plan.closesDark && (asked === 'brand' || asked === 'dark') ? 'soft' : asked\n if (band !== asked) page.settled.push({ at: 'footer', what: `a ${asked} footer under a dark closing band drawn soft` })\n const scope = frameScope(page, 'footer', band, footer?.align === 'center')\n // The footer's page links are the site's pages, every one, as the header's\n // are (AGL-3660): a list the model wrote of page links is drawn with them\n // in its place, and a footer with none gets one. The model places the list;\n // it never chooses which pages it holds.\n const navItems = plan.navPages.map((entry) => ({\n title: entry.label,\n text: '',\n to: `page:${entry.id}`,\n }))\n let linksPages = false\n const blocks = (footer?.blocks ?? []).flatMap((given): AiLayoutBlock[] => {\n // The bottom bar carries the frame's one copyright line; a line of the\n // answer's own that reads as one would print it twice.\n if (aiLayoutIsCopyright(given.text)) {\n page.settled.push({ at: 'footer', what: 'a copyright line; the footer writes its own' })\n return []\n }\n const notice = (item: { title: string; text: string }) => aiLayoutIsCopyright(item.title) || aiLayoutIsCopyright(item.text)\n const block = given.items?.some(notice) ? { ...given, items: given.items.filter((item) => !notice(item)) } : given\n if (block !== given) page.settled.push({ at: 'footer', what: 'a copyright line in a list; the footer writes its own' })\n if (FOOTER_LEAVES_OUT.has(block.kind)) {\n page.settled.push({\n at: 'footer',\n what: `a ${block.kind} in the footer; left out`,\n })\n return []\n }\n const pageLinks =\n block.kind === 'list' &&\n (block.items ?? []).some((item) => /^page:/.test(item.to ?? ''))\n if (!pageLinks) return [block]\n if (linksPages || !navItems.length) {\n page.settled.push({ at: 'footer', what: 'a second list of page links; left out' })\n return []\n }\n linksPages = true\n return [{ ...block, items: navItems }]\n })\n const cols = footer?.cols && footer.cols.length >= 2 ? footer.cols : null\n const columns: AiLayoutBlock[][] = cols ? cols.map(() => []) : [[]]\n for (const block of blocks)\n columns[\n cols && block.col !== undefined ? Math.min(block.col, cols.length - 1) : 0\n ].push(block)\n const weights = cols ? [...cols] : [2]\n if (!linksPages && plan.navPages.length) {\n columns.push([\n {\n kind: 'list',\n items: plan.navPages.map((entry) => ({\n title: entry.label,\n text: '',\n to: `page:${entry.id}`,\n })),\n },\n ])\n weights.push(1)\n }\n // A store's account and policies (AGL-3676): under the store heading the\n // design already wrote (\"Our shop\", \"Help\"…), never as a column with no\n // heading beside a heading with nothing under it (AGL-3735); where the\n // design wrote none, a column of their own, headed.\n const storeLinks = plan.storeLinks?.footer ?? []\n if (storeLinks.length) {\n const list: AiLayoutBlock = { kind: 'list', items: storeLinks.map((link) => ({ title: link.label, text: '', to: `page:store:${link.href}` })) }\n const home = aiLayoutFooterStoreHeading(columns, navItems)\n if (home) {\n home.column.splice(home.end, 0, list)\n page.settled.push({ at: 'footer', what: `the store's account and policy links under \"${home.heading}\"` })\n } else {\n columns.push([{ kind: 'heading', text: aiLayoutLabel('customerCare', plan.language) }, list])\n weights.push(1)\n }\n }\n // How to reach the business (AGL-3979): the phone and email it gave, as\n // links that call and write, in a column of their own under its heading,\n // wherever the design's footer did not already show them.\n const contact = page.targets.contact\n const contactItems = contact ? aiLayoutContactItems(contact, aiLayoutContactShown(blocks, contact)) : []\n if (contactItems.length) {\n columns.push([\n { kind: 'heading', text: aiLayoutLabel('contact', plan.language) },\n { kind: 'list', items: contactItems },\n ])\n weights.push(1)\n page.settled.push({ at: 'footer', what: 'the phone and email the business gave, in a column of their own' })\n }\n const filled = columns\n .map((column, position) => ({ column, weight: weights[position] ?? 1 }))\n .filter((entry) => entry.column.length)\n // A footer's columns are top-aligned: each starts at its heading (AGL-3735).\n const top =\n filled.length > 1\n ? compileRow(scope, filled, 'flex-start')\n : filled.length === 1\n ? compileFlow(scope, filled[0].column, 'full')\n : null\n const copyright = tree.add(\n 'muiTypography',\n { children: `© ${name}`, variant: 'body2', component: 'p' },\n scope.band === 'brand' ? null : { color: 'text.secondary' },\n null,\n 'copyright',\n )\n const bottom = tree.add(\n 'muiBox',\n null,\n { pt: 3, borderTop: 1, borderColor: 'divider' },\n [copyright],\n 'footerBottom',\n )\n // The site's own logo, where the header draws it from the site (AGL-4119).\n const footerLogo = footerLogoOf(tree, plan, name)\n const stack = tree.add(\n 'muiStack',\n { spacing: '6' },\n null,\n footerLogo ? [footerLogo, top, bottom] : [top, bottom],\n 'footerStack',\n )\n const container = tree.add(\n 'muiContainer',\n { maxWidth: 'lg' },\n { py: { xs: 6, md: 8 } },\n [stack],\n 'footerInner',\n )\n return tree.add(\n 'section',\n {\n element: 'footer',\n ariaLabel: 'Site footer',\n ...(scope.band === 'dark' ? { colorScheme: 'dark' } : {}),\n },\n scope.band === 'soft'\n ? { bgcolor: 'background.paper', borderTop: 1, borderColor: 'divider' }\n : bandSx(scope.band),\n [container],\n 'footer',\n )\n}\n\n/**\n * A source's footer (AGL-4108): its columns, words, profiles and © line, as\n * the source has them, on the quiet band a footer sits on.\n */\nfunction sourceFooter(page: PageScope, source: AiLayoutFrameSource, plan: Pick<AiLayoutFramePlan, 'brand'>, name: string): string {\n const tree = page.tree\n const drawn = aiLayoutSourceFooter(tree, source.footer as NonNullable<AiLayoutFrameSource['footer']>, { name })\n // It opens with the logo, where the source's does (AGL-4139).\n const logo = footerLogoOf(tree, plan, name)\n // A planned footer with no columns to carry is one short band, never a tall one around its © line (AGL-4152).\n const compact = source.planned === true && !drawn.top\n const stack = tree.add('muiStack', { spacing: compact ? '2' : '6' }, drawn.sx, [logo, drawn.top, drawn.bottom], 'footerStack')\n const container = tree.add('muiContainer', { maxWidth: 'lg' }, compact ? { py: { xs: 3, md: 4 } } : { py: { xs: 6, md: 8 } }, [stack], 'footerInner')\n return tree.add(\n 'section',\n { element: 'footer', ariaLabel: 'Site footer' },\n { bgcolor: 'background.paper', borderTop: 1, borderColor: 'divider' },\n [container],\n 'footer',\n )\n}\n\n/** The footer's logo, where the brand says the footer opens with it (AGL-4119); `null` otherwise. */\nfunction footerLogoOf(tree: AiLayoutTreeBuilder, plan: Pick<AiLayoutFramePlan, 'brand'>, name: string): string | null {\n const brand = plan.brand\n if (!brand?.footer || !brand.logo?.src) return null\n return tree.add(\n 'muiBox',\n null,\n null,\n logoPictures(tree, {\n src: brand.logo.src,\n srcDark: brand.logoDark?.src ?? null,\n props: { alt: (brand.alt ?? '').trim() || name.slice(0, 40), objectFit: 'contain', width: 'auto', height: AI_LAYOUT_LOGO_HEIGHT },\n role: 'footerLogo',\n }),\n 'footerLogoBox',\n )\n}\n\n/**\n * A logo as a picture, or as a pair where the site keeps one for dark\n * backgrounds (AGL-4119): the second takes the first's place in the dark\n * scheme, so a visitor sees exactly one.\n */\nfunction logoPictures(\n tree: AiLayoutTreeBuilder,\n input: { src: string; srcDark: string | null; props: Record<string, unknown>; role: string },\n): string[] {\n const light = tree.add(\n 'image',\n { src: input.src, ...input.props },\n input.srcDark ? { [SX_SCHEME_DARK_KEY]: { display: 'none' } } : null,\n null,\n input.role,\n )\n if (!input.srcDark) return [light]\n const { loading: _deferred, ...props } = input.props\n const dark = tree.add(\n 'image',\n { src: input.srcDark, ...props },\n { display: 'none', [SX_SCHEME_DARK_KEY]: { display: 'block' } },\n null,\n `${input.role}Dark`,\n )\n return [light, dark]\n}\n\n/**\n * The header's brand drawn with the site's logo (AGL-4084), as the source's\n * header draws it: the logo alone, named by its alt text, or the logo with\n * the name beside it; either way the link home.\n */\nfunction brandMark(\n tree: AiLayoutTreeBuilder,\n input: { src: string; srcDark: string | null; name: string; alt: string; withName: boolean; homeId: string | null; centered: boolean; grow: boolean; height: string },\n): string {\n const image = (alone: boolean, linked: boolean) =>\n logoPictures(tree, {\n src: input.src,\n srcDark: input.srcDark,\n role: 'logo',\n props: {\n ...(alone ? { alt: input.alt } : { decorative: true }),\n objectFit: 'contain',\n width: 'auto',\n height: input.height,\n loading: 'eager',\n ...(linked && input.homeId ? { screenId: input.homeId } : {}),\n },\n })\n // Never narrower than the logo (AGL-4108); it grows into the room the\n // navigation leaves only where the navigation does not take it itself.\n const grow = input.centered || !input.grow ? null : { flexGrow: 1 }\n if (!input.withName) {\n // One link around a pair, so the picture out of sight is no stop in the tab order.\n const homeLink = input.srcDark && input.homeId\n return tree.add(\n homeLink ? 'muiLinkBox' : 'muiBox',\n homeLink ? { screenId: input.homeId } : null,\n { ...(grow ?? {}), display: 'flex', alignItems: 'center', flexShrink: 0 },\n image(true, !homeLink),\n 'brand',\n )\n }\n const words = tree.add('muiTypography', { children: input.name, variant: 'h6', component: 'p' }, { fontWeight: 800, whiteSpace: 'nowrap' }, null, 'brandName')\n const row = tree.add('muiStack', { direction: 'row', spacing: '1.5', alignItems: 'center' }, null, [...image(false, false), words], 'brandRow')\n return input.homeId\n ? tree.add('muiLinkBox', { screenId: input.homeId, ariaLabel: input.name }, { ...(grow ?? {}), textDecoration: 'none', color: 'inherit', flexShrink: 0 }, [row], 'brand')\n : tree.add('muiBox', null, { ...(grow ?? {}), flexShrink: 0 }, [row], 'brand')\n}\n"],"names":["SX_SCHEME_DARK_KEY","AI_ICON_LIBRARY","AI_LAYOUT_MAX_IMAGES","bandSx","compileFlow","compileRow","destinationProps","aiLayoutContactItems","aiLayoutContactShown","aiLayoutFitText","aiLayoutRepairFrameHollows","AI_LAYOUT_CART_ELEMENT","AI_LAYOUT_MAX_ITEMS","AI_LAYOUT_LABELS_EN","aiLayoutLabel","aiLayoutRenamedLabel","aiLayoutResolveLink","AI_LAYOUT_HEADER_MEASURE","aiLayoutNavBreakpoint","aiLayoutSourceFooter","aiLayoutSourceHeader","AiLayoutTreeBuilder","AI_LAYOUT_LOGO_HEIGHT","AI_LAYOUT_ACCOUNT_LINK","account","AI_LAYOUT_STORE_ANNOUNCEMENT","storeAnnouncement","AI_LAYOUT_STORE_ANNOUNCEMENT_LINK","shopNow","headerLook","band","props","color","sx","boxShadow","bgcolor","aiLayoutIsCopyright","text","test","FOOTER_LEAVES_OUT","Set","frameScope","page","at","centered","index","level","headed","itemsLeft","frame","link","sections","from","formSection","aiCompileLayoutFrame","plan","targets","header","tree","storePages","storeLinks","footer","map","id","href","label","slug","title","siteName","pages","pageId","options","reusableComponents","language","settled","scrollTo","itemIds","images","strong","brand","dark","pageIcon","sparkle","formsPlaced","design","pictures","features","splitAt","quotesOnly","name","blocks","look","scope","navLink","entry","role","interactions","add","children","slice","screenId","renderAs","textDecoration","nodes","navPages","filter","trim","centeredNav","align","length","brandSx","typography","fontWeight","whiteSpace","overflow","textOverflow","minWidth","flexGrow","logo","src","source","alt","replace","brandMark","srcDark","logoDark","withName","homeId","grow","height","variant","component","aspect","Number","isFinite","Math","min","logoHeight","parseInt","brandWidth","round","close","AI_LAYOUT_CLOSE_DRAWER","drawn","onBrand","pagesBreakpoint","nav","menu","ctas","breakpoint","ariaLabel","direction","spacing","alignItems","display","xs","ctaBlock","undefined","find","block","kind","store","shopId","noteBlock","push","what","ctaLabel","ctaResolved","to","repeatsNav","some","ctaTo","cart","ctaProps","cta","sm","flexShrink","accountPath","accountLink","drawer","anchor","flexDirection","gap","p","fullWidth","mt","toggle","ml","middle","justifyContent","row","maxWidth","columnGap","toolbar","disableGutters","minHeight","md","panels","barLook","bar","position","overHero","announcement","said","words","useFlexGap","flexWrap","py","px","slot","sourceFooter","compileFooter","column","prune","rootId","AI_LAYOUT_STORE_FOOTER_HEADING","customerCare","STORE_HEADING","aiLayoutFooterStoreHeading","columns","navItems","candidates","navTo","item","forEach","end","under","site","one","items","has","heading","String","empty","pick","enabled","trigger","event","everyTime","steps","type","asked","closesDark","linksPages","flatMap","given","notice","pageLinks","cols","col","weights","list","home","splice","contact","contactItems","filled","weight","top","copyright","bottom","pt","borderTop","borderColor","footerLogo","footerLogoOf","stack","container","element","colorScheme","compact","planned","logoPictures","objectFit","width","input","light","loading","_deferred","image","alone","linked","decorative","homeLink"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,kBAAkB,QAAQ,mCAAkC;AAErE,SAASC,eAAe,QAAQ,gCAA4B;AAC5D,SACEC,oBAAoB,EACpBC,MAAM,EACNC,WAAW,EACXC,UAAU,EACVC,gBAAgB,QAGX,0BAAsB;AAC7B,SAASC,oBAAoB,EAAEC,oBAAoB,QAAQ,yBAAqB;AAChF,SAASC,eAAe,QAAQ,sBAAkB;AAClD,SAASC,0BAA0B,QAAQ,+BAA2B;AACtE,SAASC,sBAAsB,QAAQ,0BAAsB;AAC7D,SACEC,mBAAmB,QAKd,0BAAsB;AAC7B,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,wBAAoB;AACvE,SACEC,oBAAoB,EACpBC,mBAAmB,QAGd,uBAAmB;AAC1B,SACEC,wBAAwB,EACxBC,qBAAqB,EACrBC,oBAAoB,EACpBC,oBAAoB,QAEf,8BAA0B;AACjC,SAASC,mBAAmB,QAA8B,sBAAkB;AAgG5E,mFAAmF,GACnF,OAAO,MAAMC,wBAAwB,OAAM;AAE3C,kFAAkF,GAClF,OAAO,MAAMC,yBAAyBV,oBAAoBW,OAAO,CAAA;AAEjE,2GAA2G,GAC3G,OAAO,MAAMC,+BAA+BZ,oBAAoBa,iBAAiB,CAAA;AAEjF,2EAA2E,GAC3E,OAAO,MAAMC,oCAAoCd,oBAAoBe,OAAO,CAAA;AAO5E,mDAAm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AC;YAAI0B,SAAS;YAAQD,YAAY;YAAUuB,YAAY;YACtEuG,MAAM,MAAM,CAACI,WACb;IAEJ;IACA,MAAM/E,QAAQlJ,KAAKuC,GAAG,CAAC,iBAAiB;QAAEC,UAAUiL,MAAM1L,IAAI;QAAEyC,SAAS;QAAMC,WAAW;IAAI,GAAG;QAAEnB,YAAY;QAAKC,YAAY;IAAS,GAAG,MAAM;IAClJ,MAAM6E,MAAMpI,KAAKuC,GAAG,CAAC,YAAY;QAAEsD,WAAW;QAAOC,SAAS;QAAOC,YAAY;IAAS,GAAG,MAAM;WAAI8H,MAAM,OAAO;QAAQ3E;KAAM,EAAE;IACpI,OAAOuE,MAAMpJ,MAAM,GACfrE,KAAKuC,GAAG,CAAC,cAAc;QAAEG,UAAU+K,MAAMpJ,MAAM;QAAEuB,WAAW6H,MAAM1L,IAAI;IAAC,GAAG,aAAMuC,eAAAA,OAAQ,CAAC;QAAI1B,gBAAgB;QAAQtE,OAAO;QAAWgJ,YAAY;QAAK;QAACc;KAAI,EAAE,WAC/JpI,KAAKuC,GAAG,CAAC,UAAU,MAAM,aAAM+B,eAAAA,OAAQ,CAAC;QAAIgD,YAAY;QAAK;QAACc;KAAI,EAAE;AAC1E"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/layout-language/ai-layout-frame.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SX_SCHEME_DARK_KEY } from '@aglyn/aglyn/app-utils/scheme-sx'\nimport type { AiStoreFrameLinks } from '../model/ai-site-store-pages'\nimport { AI_ICON_LIBRARY } from '../runtime/ai-icon-library'\nimport {\n AI_LAYOUT_MAX_IMAGES,\n bandSx,\n compileFlow,\n compileRow,\n destinationProps,\n type PageScope,\n type SectionScope,\n} from './ai-layout-compiler'\nimport { aiLayoutContactItems, aiLayoutContactShown } from './ai-layout-contact'\nimport { aiLayoutFitText } from './ai-layout-copy'\nimport { aiLayoutRepairFrameHollows } from './ai-layout-frame-hollows'\nimport { AI_LAYOUT_CART_ELEMENT } from './ai-layout-listings'\nimport {\n AI_LAYOUT_MAX_ITEMS,\n type AiLayoutBand,\n type AiLayoutBlock,\n type AiLayoutSection,\n type AiLayoutSettlement,\n} from './ai-layout-language'\nimport { AI_LAYOUT_LABELS_EN, aiLayoutLabel } from './ai-layout-labels'\nimport {\n aiLayoutRenamedLabel,\n aiLayoutResolveLink,\n type AiLayoutPage,\n type AiLayoutTargets,\n} from './ai-layout-links'\nimport {\n AI_LAYOUT_HEADER_MEASURE,\n aiLayoutNavBreakpoint,\n aiLayoutSourceFooter,\n aiLayoutSourceHeader,\n type AiLayoutFrameSource,\n} from './ai-layout-frame-source'\nimport { AiLayoutTreeBuilder, type AiLayoutRawTree } from './ai-layout-tree'\n\n/**\n * A site's frame — the header and the footer every page renders between —\n * compiled from the layout language (AGL-3660), the same language a page is\n * designed in.\n *\n * The design is the model's: the header's band and alignment and its one\n * call to action, and the footer's columns and every word in them. What a\n * frame owes the site is the platform's, written here, so it is never wrong\n * and never invented: the site's name as the brand, linking home; its pages\n * as the navigation, a row on a wide screen and the platform's Drawer behind\n * its Menu Button on a phone; the Layout Slot, the page's one main landmark,\n * held tall enough that the footer sits at the bottom of a short page; and\n * the site's pages and name in the footer, where the design gave neither.\n *\n * Every label of the navigation is held to one line, the logo never narrower\n * than itself, and the row shows from the screen width it measures to fit\n * (`aiLayoutNavBreakpoint`), the Menu Button below it (AGL-4108: the 10/29\n * import's seven long titles wrapped from 900 px up and the logo lay over\n * \"Home\" at 1280). A site brought in from elsewhere whose menu the reader\n * found is drawn as its source builds it instead (`plan.source`,\n * `ai-layout-frame-source.ts`): its menus, its buttons, its phone menu and its\n * footer, in place of the site's pages and the design's button and footer.\n */\n\nexport interface AiLayoutFramePlan {\n /** The site's name, which the header and the footer carry as its brand. */\n siteName: string\n /** The site's home page, which the brand links; none where the site has none yet. */\n homeId: string | null\n /** The pages the navigation links, in order. */\n navPages: readonly AiLayoutPage[]\n /**\n * Whether the site's pages close on a dark photo band (AGL-3660,\n * `AiLayoutDesignChoices.coverClose`): a brand or dark footer under it\n * would read as a second loud band, so the footer takes the quiet one.\n */\n closesDark?: boolean\n /**\n * Whether the site sells (AGL-3676): its header carries the store's cart\n * button — the commerce plugin's Cart, which opens the cart in a drawer\n * from every page — beside the navigation.\n */\n cart?: boolean\n /**\n * A selling store's Shop page (AGL-3676), by its id. Its header is a\n * storefront's: the cart beside the navigation and no call-to-action button\n * repeating a link the navigation already has, and a thin announcement bar\n * above it — the line the design gave its header as a note, else one that\n * opens the shop — linking the Shop page.\n */\n shopId?: string | null\n /**\n * A store's own pages (AGL-3676), by path: the header links the account\n * beside the cart, and the footer the account and the store's policies\n * under the site's pages. They are written after the layout, so they are\n * linked by their addresses, as the blog is.\n */\n storeLinks?: AiStoreFrameLinks | null\n /** The site's language (AGL-3760): the frame's own words are in it where `ai-layout-labels.ts` lists it. */\n language?: string\n /**\n * The brand as a site brought in from elsewhere draws it (AGL-4084): its\n * logo alone, its logo with its name, or its name alone, as the source's\n * header shows it. Absent, the name alone.\n */\n brand?: AiLayoutFrameBrand | null\n /**\n * A site brought in from elsewhere whose header the reader found\n * (AGL-4108): its menu with its menus, its buttons with their own\n * addresses, its phone menu and its footer, drawn as the source has them\n * (`ai-layout-frame-source.ts`) in place of the site's pages and the\n * design's button and footer.\n */\n source?: AiLayoutFrameSource | null\n}\n\n/** A header's brand as the source shows it (AGL-4084). */\nexport interface AiLayoutFrameBrand {\n /** The logo, from the site's own media library. */\n logo?: { src: string } | null\n /** The logo a dark-scheme visitor sees, where the frame draws one for each scheme (AGL-4119). */\n logoDark?: { src: string } | null\n /** Whether the footer opens with the logo too (AGL-4119). */\n footer?: boolean\n /** Whether the header prints the name as words, beside the logo or alone. */\n name: boolean\n /** The logo's words for a screen reader, as the source names it (AGL-4108); the site's name where it gave none. */\n alt?: string\n /** The logo's width over its height, which the header row is measured with (AGL-4108). */\n aspect?: number\n /** The height a redesigned header draws it at (AGL-4152); absent, `AI_LAYOUT_LOGO_HEIGHT`. */\n height?: string\n}\n\n/** The height a header's logo is drawn at: a Besigner field the owner may change. */\nexport const AI_LAYOUT_LOGO_HEIGHT = '40px'\n\n/** What the header's link to a store's account page says (AGL-3676), in English. */\nexport const AI_LAYOUT_ACCOUNT_LINK = AI_LAYOUT_LABELS_EN.account\n\n/** What a store's announcement bar says where its design gave it no line (AGL-3676): true of every store. */\nexport const AI_LAYOUT_STORE_ANNOUNCEMENT = AI_LAYOUT_LABELS_EN.storeAnnouncement\n\n/** The way into the shop beside the design's own announcement (AGL-3676). */\nexport const AI_LAYOUT_STORE_ANNOUNCEMENT_LINK = AI_LAYOUT_LABELS_EN.shopNow\n\nexport interface AiLayoutCompiledFrame {\n tree: AiLayoutRawTree\n settled: AiLayoutSettlement[]\n}\n\n/** The header's colors by band, as palette roles. */\nfunction headerLook(band: AiLayoutBand): {\n props: Record<string, unknown>\n sx: Record<string, unknown>\n} {\n if (band === 'brand')\n return { props: { color: 'primary' }, sx: { boxShadow: 'none' } }\n if (band === 'dark') {\n return {\n props: { color: 'primary' },\n sx: {\n boxShadow: 'none',\n bgcolor: 'primary.dark',\n color: 'primary.contrastText',\n },\n }\n }\n // A rule, a shadow or nothing under a plain header is the site theme's\n // MuiAppBar style (AGL-3660); the band's color stays here.\n return {\n props: { color: 'inherit' },\n sx: { bgcolor: 'background.paper' },\n }\n}\n\n/** A line that reads as a copyright notice: \"© 2026 …\", \"Copyright …\", \"All rights reserved.\" */\nexport function aiLayoutIsCopyright(text: unknown): boolean {\n return typeof text === 'string' && /^\\s*(?:©|\\(c\\)|copyright\\b)|all rights reserved/i.test(text)\n}\n\n/** What a footer leaves out: a picture slot, and the page sections a footer is no place for. */\nconst FOOTER_LEAVES_OUT: ReadonlySet<AiLayoutBlock['kind']> = new Set([\n 'image',\n 'faq',\n 'quotes',\n 'cards',\n 'steps',\n 'stats',\n 'form',\n 'component',\n])\n\n/** A frame scope: no headings of its own (a layout carries no outline), no pictures. */\nfunction frameScope(\n page: PageScope,\n at: string,\n band: AiLayoutBand,\n centered: boolean,\n): SectionScope {\n return {\n page,\n index: at === 'header' ? 0 : 1,\n at,\n band,\n centered,\n level: 2,\n headed: true,\n itemsLeft: AI_LAYOUT_MAX_ITEMS,\n frame: true,\n link: { sections: [], from: -1, formSection: null },\n }\n}\n\n/** Compiles a site's header and footer, designed in the layout language, into its layout. */\nexport function aiCompileLayoutFrame(\n frame: { header: AiLayoutSection | null; footer: AiLayoutSection | null },\n plan: AiLayoutFramePlan,\n targets: AiLayoutTargets,\n): AiLayoutCompiledFrame {\n const tree = new AiLayoutTreeBuilder('lf')\n // A store's own pages are destinations the footer's list links by path (AGL-3676).\n const storePages: AiLayoutPage[] = (plan.storeLinks?.footer ?? []).map((link) => ({\n id: `store:${link.href}`,\n label: link.label,\n slug: link.href,\n href: link.href,\n }))\n const page: PageScope = {\n tree,\n plan: { title: plan.siteName, sections: [] },\n targets: { ...targets, pages: [...targets.pages, ...storePages], pageId: null },\n // A footer is drawn compact: its lines are lines, never blocks rule 1 would ask to share.\n options: { reusableComponents: true, ...(plan.language ? { language: plan.language } : {}) },\n settled: [],\n scrollTo: {},\n // A frame's lines are its own, never a page section's items.\n itemIds: [],\n // A frame shows no picture slot: a header and a footer are the same on every page.\n images: AI_LAYOUT_MAX_IMAGES,\n strong: { brand: 0, dark: 0 },\n formSection: null,\n pageIcon: AI_ICON_LIBRARY.sparkle,\n formsPlaced: new Set(),\n // A frame is drawn the platform's one way on every site.\n design: null,\n pictures: 0,\n features: 0,\n splitAt: -2,\n quotesOnly: [],\n }\n const name = aiLayoutFitText(plan.siteName, 'heading', plan.language) || 'Home'\n const header = frame.header ?? { blocks: [] }\n const band = header.band ?? 'plain'\n const look = headerLook(band)\n const scope = frameScope(\n page,\n 'header',\n band === 'brand' || band === 'dark' ? 'brand' : 'plain',\n false,\n )\n const navLink = (\n entry: AiLayoutPage,\n role: string,\n interactions?: unknown[],\n ) => {\n const id = tree.add(\n 'muiScreenLink',\n {\n children:\n aiLayoutFitText(entry.label, 'label', plan.language) || entry.label.slice(0, 28),\n // The blog is a path, not a page (AGL-3660).\n ...(entry.href ? { href: entry.href } : { screenId: entry.id }),\n renderAs: 'link',\n color: 'inherit',\n },\n { textDecoration: 'none' },\n null,\n role,\n )\n if (interactions) tree.nodes[id].interactions = interactions\n return id\n }\n const pages = plan.navPages.filter((entry) => entry.label.trim())\n const centeredNav = header.align === 'center' && pages.length > 0\n // The brand takes the room the navigation does not, and gives way before\n // it does: a long name ends in an ellipsis rather than pushing into the links.\n // A logo never gives way: drawn narrower than itself it lay over the first\n // link (the 10/29 header at 1280, AGL-4108).\n const brandSx = {\n typography: 'h6',\n fontWeight: 800,\n textDecoration: 'none',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n minWidth: 0,\n ...(centeredNav ? {} : { flexGrow: 1 }),\n }\n const logo = plan.brand?.logo?.src ? plan.brand.logo.src : null\n const source = plan.source ?? null\n const alt = (plan.brand?.alt ?? '').replace(/\\s+/g, ' ').trim().slice(0, 120) || name.slice(0, 40)\n const brand = logo\n ? brandMark(tree, { src: logo, srcDark: plan.brand?.logoDark?.src ?? null, name: name.slice(0, 40), alt, withName: plan.brand?.name === true, homeId: plan.homeId, centered: centeredNav, grow: !source, height: plan.brand?.height ?? AI_LAYOUT_LOGO_HEIGHT })\n : plan.homeId\n ? tree.add(\n 'muiScreenLink',\n {\n children: name.slice(0, 40),\n screenId: plan.homeId,\n renderAs: 'link',\n color: 'inherit',\n },\n brandSx,\n null,\n 'brand',\n )\n : tree.add(\n 'muiTypography',\n { children: name, variant: 'h6', component: 'p' },\n brandSx,\n null,\n 'brand',\n )\n // How wide the brand is drawn, which the row is measured with (AGL-4108).\n const aspect = plan.brand?.aspect && Number.isFinite(plan.brand.aspect) && plan.brand.aspect > 0 ? Math.min(plan.brand.aspect, 8) : null\n const logoHeight = Number.parseInt(plan.brand?.height ?? AI_LAYOUT_LOGO_HEIGHT, 10)\n const brandWidth = logo\n ? (aspect ? Math.round(aspect * logoHeight) : AI_LAYOUT_HEADER_MEASURE.logo) + (plan.brand?.name ? name.slice(0, 40).length * 11 + 12 : 0)\n : Math.min(name.length, 40) * 11\n // The source's own header (AGL-4108), drawn as it builds it.\n const close = [AI_LAYOUT_CLOSE_DRAWER]\n const drawn = source ? aiLayoutSourceHeader(tree, source, { onBrand: band === 'brand' || band === 'dark', close, brandWidth }) : null\n // Every label on one line, and the row only on a screen it fits (AGL-4108).\n const pagesBreakpoint = aiLayoutNavBreakpoint({ brandWidth, nav: pages.map((entry) => ({ label: entry.label, menu: false })), ctas: [] })\n const breakpoint = drawn?.breakpoint ?? pagesBreakpoint\n const nav = drawn\n ? drawn.nav\n : pages.length\n ? tree.add(\n 'muiStack',\n {\n component: 'nav',\n ariaLabel: 'Main',\n direction: 'row',\n spacing: '3',\n alignItems: 'center',\n },\n { display: { xs: 'none', [breakpoint]: 'flex' }, whiteSpace: 'nowrap' },\n pages.map((entry) => navLink(entry, 'navLink')),\n 'nav',\n )\n : null\n // The design's call to action: its first button, where it goes somewhere.\n // A source's header carries its own buttons instead (AGL-4108).\n const ctaBlock = source ? undefined : header.blocks.find((block) => block.kind === 'button')\n // A store's announcement: the first short line the design gave its header (AGL-3676).\n const store = !!plan.shopId\n const noteBlock = store ? header.blocks.find((block) => block.kind === 'note' || block.kind === 'text' || block.kind === 'lede') : undefined\n for (const block of header.blocks) {\n if (block !== ctaBlock && block !== noteBlock)\n page.settled.push({\n at: 'header',\n what: `a ${block.kind} in the header; left out`,\n })\n }\n const ctaLabel = ctaBlock ? aiLayoutFitText(ctaBlock.text, 'label', plan.language) : ''\n const ctaResolved =\n ctaBlock && ctaLabel\n ? aiLayoutResolveLink(ctaBlock.to, ctaLabel, scope.link, page.targets)\n : null\n if (ctaBlock && !ctaResolved)\n page.settled.push({\n at: 'header',\n what: `the button \"${ctaLabel}\" has nowhere to go; left out`,\n })\n // A storefront's header is its navigation and its cart (AGL-3676): the\n // live Willow Wick header's \"Shop candles\" button repeated its nav's Shop.\n // A store's button that only repeats a page the navigation links is left\n // out, and a store that sells carries its cart in that place instead.\n const repeatsNav =\n ctaResolved?.kind === 'page' && pages.some((entry) => !entry.href && entry.id === ctaResolved.screenId)\n const ctaTo = ctaResolved && store && (plan.cart || repeatsNav) ? null : ctaResolved\n if (ctaResolved && !ctaTo)\n page.settled.push({\n at: 'header',\n what: `the button \"${ctaLabel}\" left out: a store's header carries its ${plan.cart ? 'cart' : 'navigation'}, not a button repeating it`,\n })\n const ctaProps = ctaTo\n ? {\n children: aiLayoutRenamedLabel(ctaLabel, ctaTo),\n variant: 'contained',\n color: scope.band === 'brand' ? 'secondary' : 'primary',\n ...destinationProps(ctaTo),\n }\n : null\n // On the smallest phones the call to action moves into the menu.\n const cta = ctaProps\n ? tree.add(\n 'muiButton',\n ctaProps,\n {\n display: { xs: 'none', sm: 'inline-flex' },\n whiteSpace: 'nowrap',\n flexShrink: 0,\n },\n null,\n 'cta',\n )\n : null\n // A store's account, beside its cart and in the phone's menu (AGL-3676).\n const accountPath = plan.storeLinks?.account ?? null\n const accountLink = (role: string, interactions?: unknown[], sx?: Record<string, unknown>) => {\n const id = tree.add(\n 'muiScreenLink',\n { children: aiLayoutLabel('account', plan.language), href: accountPath, renderAs: 'link', color: 'inherit' },\n { textDecoration: 'none', whiteSpace: 'nowrap', ...sx },\n null,\n role,\n )\n if (interactions) tree.nodes[id].interactions = interactions\n return id\n }\n // A phone's menu: the platform's Drawer, opened by its Menu Button; a link\n // followed from it closes it. A source's holds its menus, links and buttons (AGL-4108).\n const drawer = drawn?.drawer.length\n ? tree.add(\n 'muiDrawer',\n { anchor: 'right' },\n null,\n [\n tree.add(\n 'muiStack',\n { component: 'nav', ariaLabel: 'Menu' },\n { display: 'flex', flexDirection: 'column', gap: 3, p: 3 },\n [...drawn.drawer, accountPath ? accountLink('menuAccount', close) : null],\n 'menu',\n ),\n ],\n 'drawer',\n )\n : !source && pages.length\n ? tree.add(\n 'muiDrawer',\n { anchor: 'right' },\n null,\n [\n tree.add(\n 'muiStack',\n { component: 'nav', ariaLabel: 'Menu' },\n {\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n p: 3,\n typography: 'h6',\n },\n [\n ...pages.map((entry) => navLink(entry, 'menuLink', close)),\n accountPath ? accountLink('menuAccount', close) : null,\n ctaProps\n ? tree.add(\n 'muiButton',\n { ...ctaProps, fullWidth: true },\n { mt: 2 },\n null,\n 'menuCta',\n )\n : null,\n ],\n 'menu',\n ),\n ],\n 'drawer',\n )\n : null\n const toggle = drawer\n ? tree.add(\n 'muiDrawerToggle',\n { ariaLabel: 'Open the menu' },\n // Pushed to the end of the row where no button is there to push it.\n { display: { xs: 'inline-flex', [breakpoint]: 'none' }, flexShrink: 0, ...(drawn && !drawn.ctas ? { ml: 'auto' } : {}) },\n null,\n 'menuButton',\n )\n : null\n const middle =\n nav && centeredNav\n ? tree.add(\n 'muiBox',\n null,\n { flexGrow: 1, display: 'flex', justifyContent: 'center' },\n [nav],\n 'navRoom',\n )\n : nav\n // A store's cart, on every page, where a shopper looks for it (AGL-3676).\n const cart = plan.cart\n ? tree.add(AI_LAYOUT_CART_ELEMENT, { variant: 'button' }, { flexShrink: 0 }, null, 'cart')\n : null\n // On a phone the account is in the menu, and the cart stays in the bar.\n const account = accountPath ? accountLink('account', undefined, { display: { xs: 'none', [breakpoint]: 'inline-flex' }, flexShrink: 0 }) : null\n // The row lives in a Container inside the Toolbar Content, which may only sit in an App Bar.\n const row = tree.add(\n 'muiContainer',\n { maxWidth: 'lg' },\n { display: 'flex', alignItems: 'center', columnGap: 3 },\n [brand, middle, drawn ? drawn.ctas : cta, account, cart, toggle, drawer],\n 'headerRow',\n )\n const toolbar = tree.add(\n 'muiToolbar',\n { disableGutters: true },\n { minHeight: { xs: 64, md: 76 } },\n // A source's menus shown on hover open under the whole bar (AGL-4139).\n [row, drawn?.panels ?? null],\n 'toolbar',\n )\n // A source's header bar on the ground it sits on (AGL-4108): the page's own, where it is the page's.\n const barLook = source?.header === 'page' ? { props: { color: 'inherit' }, sx: { bgcolor: 'background.default' } } : look\n const bar = tree.add(\n 'muiAppBar',\n {\n ...barLook.props,\n position: 'sticky',\n // Over a page that opens with a photo cover, the bar sits on the photo (AGL-3660).\n overHero: true,\n component: 'header',\n ariaLabel: 'Site header',\n },\n barLook.sx,\n [toolbar],\n 'header',\n )\n // A selling store's announcement bar, above the header, linking its shop (AGL-3676).\n const announcement =\n store && plan.cart && plan.shopId\n ? (() => {\n const said = aiLayoutFitText(noteBlock?.text, 'note', plan.language)\n if (noteBlock && !said) page.settled.push({ at: 'header', what: 'an announcement with no words left; the shop’s own line instead' })\n // The design's line, then the way into the shop; else the way in alone.\n const link = tree.add(\n 'muiScreenLink',\n {\n children: aiLayoutLabel(said ? 'shopNow' : 'storeAnnouncement', plan.language),\n screenId: plan.shopId,\n renderAs: 'link',\n color: 'inherit',\n },\n { fontWeight: 700 },\n null,\n 'announcementLink',\n )\n const words = said\n ? tree.add('muiTypography', { children: said, variant: 'body2', component: 'p' }, null, null, 'announcementText')\n : null\n return tree.add(\n 'muiStack',\n { direction: 'row', spacing: '1.5', justifyContent: 'center', alignItems: 'baseline', useFlexGap: true, flexWrap: 'wrap' },\n { bgcolor: 'primary.main', color: 'primary.contrastText', typography: 'body2', py: 1, px: 2 },\n [words, link],\n 'announcement',\n )\n })()\n : null\n // The page grows into the room the window leaves, so a short page keeps\n // its footer at the bottom.\n const slot = tree.add(\n 'layoutSlot',\n { component: 'main' },\n { flexGrow: 1 },\n null,\n 'slot',\n )\n const footer = source?.footer ? sourceFooter(page, source, plan, name) : compileFooter(page, frame.footer, plan, name)\n // No heading with nothing under it, no column of only a heading, columns\n // top-aligned (AGL-3735): a list under a heading can compile to nothing.\n if (aiLayoutRepairFrameHollows(tree.nodes as unknown as Record<string, unknown>)) {\n page.settled.push({ at: 'footer', what: 'a heading with nothing under it taken out, and its column with it' })\n }\n const column = tree.add(\n 'muiStack',\n null,\n { minHeight: '100vh' },\n [announcement, bar, slot, footer],\n 'frame',\n )\n tree.prune(column, new Set([slot]))\n const rootId = tree.add('div', null, null, [column], 'layout')\n return { tree: { rootId, nodes: tree.nodes }, settled: page.settled }\n}\n\n/** What a store's own column of account and policy links is headed where the footer design gave no store heading (AGL-3735). */\nexport const AI_LAYOUT_STORE_FOOTER_HEADING = AI_LAYOUT_LABELS_EN.customerCare\n\n/** A footer heading a store's account and policies belong under (AGL-3735). */\nconst STORE_HEADING = /\\b(?:shop|store|shopping|help|customer|care|support|service|orders?|account|policies|policy|legal|info|information|shipping|returns)\\b/i\n\n/**\n * The footer heading a store's account and policy links go under\n * (AGL-3735): a heading of the design's that names the store or its help\n * (\"Our shop\", \"Help\", \"Customer care\"), the first with nothing under it\n * before one with words or links of its own. Never the heading over the\n * site's pages, whose list is the site's navigation. `end` is where the\n * links go: the end of what that heading heads.\n */\nexport function aiLayoutFooterStoreHeading(\n columns: readonly AiLayoutBlock[][],\n navItems: readonly { to: string }[],\n): { column: AiLayoutBlock[]; end: number; heading: string } | null {\n const navTo = new Set(navItems.map((item) => item.to))\n const candidates: Array<{ column: AiLayoutBlock[]; end: number; heading: string; empty: boolean }> = []\n for (const column of columns) {\n column.forEach((block, at) => {\n if (block.kind !== 'heading' || !STORE_HEADING.test(block.text ?? '')) return\n let end = at + 1\n while (end < column.length && column[end].kind !== 'heading') end += 1\n const under = column.slice(at + 1, end)\n const site = under.some((one) => one.kind === 'list' && (one.items ?? []).some((item) => navTo.has(item.to ?? '')))\n if (site) return\n candidates.push({ column: column as AiLayoutBlock[], end, heading: String(block.text), empty: under.length === 0 })\n })\n }\n const pick = candidates.find((one) => one.empty) ?? candidates[0]\n return pick ? { column: pick.column, end: pick.end, heading: pick.heading } : null\n}\n\n/** A link followed from the phone menu closes it. */\nconst AI_LAYOUT_CLOSE_DRAWER = {\n id: 'ai-close-menu',\n name: 'Close the menu',\n enabled: true,\n trigger: { event: 'elementClick', everyTime: true },\n steps: [{ type: 'closeDrawer' }],\n}\n\n/**\n * The footer the design describes, with what every footer owes a visitor\n * written by code: the site's pages, where the design links none of them,\n * and the site's name under a rule.\n */\nfunction compileFooter(\n page: PageScope,\n footer: AiLayoutSection | null,\n plan: AiLayoutFramePlan,\n name: string,\n): string {\n const tree = page.tree\n const asked = footer?.band ?? 'soft'\n const band = plan.closesDark && (asked === 'brand' || asked === 'dark') ? 'soft' : asked\n if (band !== asked) page.settled.push({ at: 'footer', what: `a ${asked} footer under a dark closing band drawn soft` })\n const scope = frameScope(page, 'footer', band, footer?.align === 'center')\n // The footer's page links are the site's pages, every one, as the header's\n // are (AGL-3660): a list the model wrote of page links is drawn with them\n // in its place, and a footer with none gets one. The model places the list;\n // it never chooses which pages it holds.\n const navItems = plan.navPages.map((entry) => ({\n title: entry.label,\n text: '',\n to: `page:${entry.id}`,\n }))\n let linksPages = false\n const blocks = (footer?.blocks ?? []).flatMap((given): AiLayoutBlock[] => {\n // The bottom bar carries the frame's one copyright line; a line of the\n // answer's own that reads as one would print it twice.\n if (aiLayoutIsCopyright(given.text)) {\n page.settled.push({ at: 'footer', what: 'a copyright line; the footer writes its own' })\n return []\n }\n const notice = (item: { title: string; text: string }) => aiLayoutIsCopyright(item.title) || aiLayoutIsCopyright(item.text)\n const block = given.items?.some(notice) ? { ...given, items: given.items.filter((item) => !notice(item)) } : given\n if (block !== given) page.settled.push({ at: 'footer', what: 'a copyright line in a list; the footer writes its own' })\n if (FOOTER_LEAVES_OUT.has(block.kind)) {\n page.settled.push({\n at: 'footer',\n what: `a ${block.kind} in the footer; left out`,\n })\n return []\n }\n const pageLinks =\n block.kind === 'list' &&\n (block.items ?? []).some((item) => /^page:/.test(item.to ?? ''))\n if (!pageLinks) return [block]\n if (linksPages || !navItems.length) {\n page.settled.push({ at: 'footer', what: 'a second list of page links; left out' })\n return []\n }\n linksPages = true\n return [{ ...block, items: navItems }]\n })\n const cols = footer?.cols && footer.cols.length >= 2 ? footer.cols : null\n const columns: AiLayoutBlock[][] = cols ? cols.map(() => []) : [[]]\n for (const block of blocks)\n columns[\n cols && block.col !== undefined ? Math.min(block.col, cols.length - 1) : 0\n ].push(block)\n const weights = cols ? [...cols] : [2]\n if (!linksPages && plan.navPages.length) {\n columns.push([\n {\n kind: 'list',\n items: plan.navPages.map((entry) => ({\n title: entry.label,\n text: '',\n to: `page:${entry.id}`,\n })),\n },\n ])\n weights.push(1)\n }\n // A store's account and policies (AGL-3676): under the store heading the\n // design already wrote (\"Our shop\", \"Help\"…), never as a column with no\n // heading beside a heading with nothing under it (AGL-3735); where the\n // design wrote none, a column of their own, headed.\n const storeLinks = plan.storeLinks?.footer ?? []\n if (storeLinks.length) {\n const list: AiLayoutBlock = { kind: 'list', items: storeLinks.map((link) => ({ title: link.label, text: '', to: `page:store:${link.href}` })) }\n const home = aiLayoutFooterStoreHeading(columns, navItems)\n if (home) {\n home.column.splice(home.end, 0, list)\n page.settled.push({ at: 'footer', what: `the store's account and policy links under \"${home.heading}\"` })\n } else {\n columns.push([{ kind: 'heading', text: aiLayoutLabel('customerCare', plan.language) }, list])\n weights.push(1)\n }\n }\n // How to reach the business (AGL-3979): the phone and email it gave, as\n // links that call and write, in a column of their own under its heading,\n // wherever the design's footer did not already show them.\n const contact = page.targets.contact\n const contactItems = contact ? aiLayoutContactItems(contact, aiLayoutContactShown(blocks, contact)) : []\n if (contactItems.length) {\n columns.push([\n { kind: 'heading', text: aiLayoutLabel('contact', plan.language) },\n { kind: 'list', items: contactItems },\n ])\n weights.push(1)\n page.settled.push({ at: 'footer', what: 'the phone and email the business gave, in a column of their own' })\n }\n const filled = columns\n .map((column, position) => ({ column, weight: weights[position] ?? 1 }))\n .filter((entry) => entry.column.length)\n // A footer's columns are top-aligned: each starts at its heading (AGL-3735).\n const top =\n filled.length > 1\n ? compileRow(scope, filled, 'flex-start')\n : filled.length === 1\n ? compileFlow(scope, filled[0].column, 'full')\n : null\n const copyright = tree.add(\n 'muiTypography',\n { children: `© ${name}`, variant: 'body2', component: 'p' },\n scope.band === 'brand' ? null : { color: 'text.secondary' },\n null,\n 'copyright',\n )\n const bottom = tree.add(\n 'muiBox',\n null,\n { pt: 3, borderTop: 1, borderColor: 'divider' },\n [copyright],\n 'footerBottom',\n )\n // The site's own logo, where the header draws it from the site (AGL-4119).\n const footerLogo = footerLogoOf(tree, plan, name)\n const stack = tree.add(\n 'muiStack',\n { spacing: '6' },\n null,\n footerLogo ? [footerLogo, top, bottom] : [top, bottom],\n 'footerStack',\n )\n const container = tree.add(\n 'muiContainer',\n { maxWidth: 'lg' },\n { py: { xs: 6, md: 8 } },\n [stack],\n 'footerInner',\n )\n return tree.add(\n 'section',\n {\n element: 'footer',\n ariaLabel: 'Site footer',\n ...(scope.band === 'dark' ? { colorScheme: 'dark' } : {}),\n },\n scope.band === 'soft'\n ? { bgcolor: 'background.paper', borderTop: 1, borderColor: 'divider' }\n : bandSx(scope.band),\n [container],\n 'footer',\n )\n}\n\n/**\n * A source's footer (AGL-4108): its columns, words, profiles and © line, as\n * the source has them, on the quiet band a footer sits on.\n */\nfunction sourceFooter(page: PageScope, source: AiLayoutFrameSource, plan: Pick<AiLayoutFramePlan, 'brand'>, name: string): string {\n const tree = page.tree\n const drawn = aiLayoutSourceFooter(tree, source.footer as NonNullable<AiLayoutFrameSource['footer']>, { name })\n // It opens with the logo, where the source's does (AGL-4139); a footer a site's plan draws always opens with the\n // brand, its logo or else its name as a wordmark (AGL-4152).\n const logo = footerLogoOf(tree, plan, name) ?? (source.planned === true && name.trim() ? tree.add('muiTypography', { children: name.trim(), variant: 'h6', component: 'p' }, { fontWeight: 800, color: 'text.primary' }, null, 'footerWordmark') : null)\n // A planned footer with no columns to carry is one short band, never a tall one around its © line (AGL-4152).\n const compact = source.planned === true && !drawn.top\n const stack = tree.add('muiStack', { spacing: compact ? '2' : '6' }, drawn.sx, [logo, drawn.top, drawn.bottom], 'footerStack')\n const container = tree.add('muiContainer', { maxWidth: 'lg' }, compact ? { py: { xs: 3, md: 4 } } : { py: { xs: 6, md: 8 } }, [stack], 'footerInner')\n return tree.add(\n 'section',\n { element: 'footer', ariaLabel: 'Site footer' },\n { bgcolor: 'background.paper', borderTop: 1, borderColor: 'divider' },\n [container],\n 'footer',\n )\n}\n\n/** The footer's logo, where the brand says the footer opens with it (AGL-4119); `null` otherwise. */\nfunction footerLogoOf(tree: AiLayoutTreeBuilder, plan: Pick<AiLayoutFramePlan, 'brand'>, name: string): string | null {\n const brand = plan.brand\n if (!brand?.footer || !brand.logo?.src) return null\n return tree.add(\n 'muiBox',\n null,\n null,\n logoPictures(tree, {\n src: brand.logo.src,\n srcDark: brand.logoDark?.src ?? null,\n props: { alt: (brand.alt ?? '').trim() || name.slice(0, 40), objectFit: 'contain', width: 'auto', height: AI_LAYOUT_LOGO_HEIGHT },\n role: 'footerLogo',\n }),\n 'footerLogoBox',\n )\n}\n\n/**\n * A logo as a picture, or as a pair where the site keeps one for dark\n * backgrounds (AGL-4119): the second takes the first's place in the dark\n * scheme, so a visitor sees exactly one.\n */\nfunction logoPictures(\n tree: AiLayoutTreeBuilder,\n input: { src: string; srcDark: string | null; props: Record<string, unknown>; role: string },\n): string[] {\n const light = tree.add(\n 'image',\n { src: input.src, ...input.props },\n input.srcDark ? { [SX_SCHEME_DARK_KEY]: { display: 'none' } } : null,\n null,\n input.role,\n )\n if (!input.srcDark) return [light]\n const { loading: _deferred, ...props } = input.props\n const dark = tree.add(\n 'image',\n { src: input.srcDark, ...props },\n { display: 'none', [SX_SCHEME_DARK_KEY]: { display: 'block' } },\n null,\n `${input.role}Dark`,\n )\n return [light, dark]\n}\n\n/**\n * The header's brand drawn with the site's logo (AGL-4084), as the source's\n * header draws it: the logo alone, named by its alt text, or the logo with\n * the name beside it; either way the link home.\n */\nfunction brandMark(\n tree: AiLayoutTreeBuilder,\n input: { src: string; srcDark: string | null; name: string; alt: string; withName: boolean; homeId: string | null; centered: boolean; grow: boolean; height: string },\n): string {\n const image = (alone: boolean, linked: boolean) =>\n logoPictures(tree, {\n src: input.src,\n srcDark: input.srcDark,\n role: 'logo',\n props: {\n ...(alone ? { alt: input.alt } : { decorative: true }),\n objectFit: 'contain',\n width: 'auto',\n height: input.height,\n loading: 'eager',\n ...(linked && input.homeId ? { screenId: input.homeId } : {}),\n },\n })\n // Never narrower than the logo (AGL-4108); it grows into the room the\n // navigation leaves only where the navigation does not take it itself.\n const grow = input.centered || !input.grow ? null : { flexGrow: 1 }\n if (!input.withName) {\n // One link around a pair, so the picture out of sight is no stop in the tab order.\n const homeLink = input.srcDark && input.homeId\n return tree.add(\n homeLink ? 'muiLinkBox' : 'muiBox',\n homeLink ? { screenId: input.homeId } : null,\n { ...(grow ?? {}), display: 'flex', alignItems: 'center', flexShrink: 0 },\n image(true, !homeLink),\n 'brand',\n )\n }\n const words = tree.add('muiTypography', { children: input.name, variant: 'h6', component: 'p' }, { fontWeight: 800, whiteSpace: 'nowrap' }, null, 'brandName')\n const row = tree.add('muiStack', { direction: 'row', spacing: '1.5', alignItems: 'center' }, null, [...image(false, false), words], 'brandRow')\n return input.homeId\n ? tree.add('muiLinkBox', { screenId: input.homeId, ariaLabel: input.name }, { ...(grow ?? {}), textDecoration: 'none', color: 'inherit', flexShrink: 0 }, [row], 'brand')\n : tree.add('muiBox', null, { ...(grow ?? {}), flexShrink: 0 }, [row], 'brand')\n}\n"],"names":["SX_SCHEME_DARK_KEY","AI_ICON_LIBRARY","AI_LAYOUT_MAX_IMAGES","bandSx","compileFlow","compileRow","destinationProps","aiLayoutContactItems","aiLayoutContactShown","aiLayoutFitText","aiLayoutRepairFrameHollows","AI_LAYOUT_CART_ELEMENT","AI_LAYOUT_MAX_ITEMS","AI_LAYOUT_LABELS_EN","aiLayoutLabel","aiLayoutRenamedLabel","aiLayoutResolveLink","AI_LAYOUT_HEADER_MEASURE","aiLayoutNavBreakpoint","aiLayoutSourceFooter","aiLayoutSourceHeader","AiLayoutTreeBuilder","AI_LAYOUT_LOGO_HEIGHT","AI_LAYOUT_ACCOUNT_LINK","account","AI_LAYOUT_STORE_ANNOUNCEMENT","storeAnnouncement","AI_LAYOUT_STORE_ANNOUNCEMENT_LINK","shopNow","headerLook","band","props","color","sx","boxShadow","bgcolor","aiLayoutIsCopyright","text","test","FOOTER_LEAVES_OUT","Set","frameScope","page","at","centered","index","level","headed","itemsLeft","frame","link","sections","from","formSection","aiCompileLayoutFrame","plan","targets","header","tree","storePages","storeLinks","footer","map","id","href","label","slug","title","siteName","pages","pageId","options","reusableComponents","language","settled","scrollTo","itemIds","images","strong","brand","dark","pageIcon","sparkle","formsPlaced","design","pictures","features","splitAt","quotesOnly","name","blocks","look","scope","navLink","entry","role","interactions","add","children","slice","screenId","renderAs","textDecoration","nodes","navPages","filter","trim","centeredNav","align","length","brandSx","typography","fontWeight","whiteSpace","overflow","textOverflow","minWidth","flexGrow","logo","src","source","alt","replace","brandMark","srcDark","logoDark","withName","homeId","grow","height","variant","component","aspect","Number","isFinite","Math","min","logoHeight","parseInt","brandWidth","round","close","AI_LAYOUT_CLOSE_DRAWER","drawn","onBrand","pagesBreakpoint","nav","menu","ctas","breakpoint","ariaLabel","direction","spacing","alignItems","display","xs","ctaBlock","undefined","find","block","kind","store","shopId","noteBlock","push","what","ctaLabel","ctaResolved","to","repeatsNav","some","ctaTo","cart","ctaProps","cta","sm","flexShrink","accountPath","accountLink","drawer","anchor","flexDirection","gap","p","fullWidth","mt","toggle","ml","middle","justifyContent","row","maxWidth","columnGap","toolbar","disableGutters","minHeight","md","panels","barLook","bar","position","overHero","announcement","said","words","useFlexGap","flexWrap","py","px","slot","sourceFooter","compileFooter","column","prune","rootId","AI_LAYOUT_STORE_FOOTER_HEADING","customerCare","STORE_HEADING","aiLayoutFooterStoreHeading","columns","navItems","candidates","navTo","item","forEach","end","under","site","one","items","has","heading","String","empty","pick","enabled","trigger","event","everyTime","steps","type","asked","closesDark","linksPages","flatMap","given","notice","pageLinks","cols","col","weights","list","home","splice","contact","contactItems","filled","weight","top","copyright","bottom","pt","borderTop","borderColor","footerLogo","footerLogoOf","stack","container","element","colorScheme","planned","compact","logoPictures","objectFit","width","input","light","loading","_deferred","image","alone","linked","decorative","homeLink"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,kBAAkB,QAAQ,mCAAkC;AAErE,SAASC,eAAe,QAAQ,gCAA4B;AAC5D,SACEC,oBAAoB,EACpBC,MAAM,EACNC,WAAW,EACXC,UAAU,EACVC,gBAAgB,QAGX,0BAAsB;AAC7B,SAASC,oBAAoB,EAAEC,oBAAoB,QAAQ,yBAAqB;AAChF,SAASC,eAAe,QAAQ,sBAAkB;AAClD,SAASC,0BAA0B,QAAQ,+BAA2B;AACtE,SAASC,sBAAsB,QAAQ,0BAAsB;AAC7D,SACEC,mBAAmB,QAKd,0BAAsB;AAC7B,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,wBAAoB;AACvE,SACEC,oBAAoB,EACpBC,mBAAmB,QAGd,uBAAmB;AAC1B,SACEC,wBAAwB,EACxBC,qBAAqB,EACrBC,oBAAoB,EACpBC,oBAAoB,QAEf,8BAA0B;AACjC,SAASC,mBAAmB,QAA8B,sBAAkB;AAgG5E,mFAAmF,GACnF,OAAO,MAAMC,wBAAwB,OAAM;AAE3C,kFAAkF,GAClF,OAAO,MAAMC,yBAAyBV,oBAAoBW,OAAO,CAAA;AAEjE,2GAA2G,GAC3G,OAAO,MAAMC,+BAA+BZ,oBAAoBa,iBAAiB,CAAA;AAEjF,2EAA2E,GAC3E,OAAO,MAAMC,oCAAoCd,oBAAoBe,OAAO,CAAA;AAO5E,mDAAmD,GACnD,SAASC,WAAWC,IAAkB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MrJ,QAAQ,EAAE;QACnB,mFAAmF;QACnF,MAAM6J,WAAWR,MAAMvJ,OAAO,IAAIuJ,MAAMpJ,MAAM;QAC9C,OAAOrE,KAAKuC,GAAG,CACb0L,WAAW,eAAe,UAC1BA,WAAW;YAAEvL,UAAU+K,MAAMpJ,MAAM;QAAC,IAAI,MACxC,aAAMC,eAAAA,OAAQ,CAAC;YAAI0B,SAAS;YAAQD,YAAY;YAAUuB,YAAY;YACtEuG,MAAM,MAAM,CAACI,WACb;IAEJ;IACA,MAAM/E,QAAQlJ,KAAKuC,GAAG,CAAC,iBAAiB;QAAEC,UAAUiL,MAAM1L,IAAI;QAAEyC,SAAS;QAAMC,WAAW;IAAI,GAAG;QAAEnB,YAAY;QAAKC,YAAY;IAAS,GAAG,MAAM;IAClJ,MAAM6E,MAAMpI,KAAKuC,GAAG,CAAC,YAAY;QAAEsD,WAAW;QAAOC,SAAS;QAAOC,YAAY;IAAS,GAAG,MAAM;WAAI8H,MAAM,OAAO;QAAQ3E;KAAM,EAAE;IACpI,OAAOuE,MAAMpJ,MAAM,GACfrE,KAAKuC,GAAG,CAAC,cAAc;QAAEG,UAAU+K,MAAMpJ,MAAM;QAAEuB,WAAW6H,MAAM1L,IAAI;IAAC,GAAG,aAAMuC,eAAAA,OAAQ,CAAC;QAAI1B,gBAAgB;QAAQtE,OAAO;QAAWgJ,YAAY;QAAK;QAACc;KAAI,EAAE,WAC/JpI,KAAKuC,GAAG,CAAC,UAAU,MAAM,aAAM+B,eAAAA,OAAQ,CAAC;QAAIgD,YAAY;QAAK;QAACc;KAAI,EAAE;AAC1E"}
@@ -35,6 +35,33 @@ export declare function aiLayoutWithoutSections(input: NodesMap, rootId: string,
35
35
  nodes: NodesMap;
36
36
  dropped: string[];
37
37
  };
38
+ /**
39
+ * A finished page with no section left a heading alone (AGL-4152), its first
40
+ * aside: each such section goes, with any link that scrolled to it
41
+ * (`aiLayoutWithoutSections`). The last word on a redesigned page, after its
42
+ * pictures are placed or dropped: a heading over a list its answer left empty,
43
+ * or over a band of pictures none of which could be found, says only that
44
+ * something is missing. Anything under it that is not a holder, an icon or a
45
+ * heading (a picture, a button, a form, a film, a table, a line of words)
46
+ * keeps the section.
47
+ */
48
+ export declare function aiLayoutWithoutHollowSections(input: NodesMap, rootId: string): {
49
+ nodes: NodesMap;
50
+ dropped: string[];
51
+ };
52
+ /**
53
+ * A finished page whose rows of cards each show a picture on every card or on
54
+ * none (AGL-4152). A redesign gives a row most of whose cards had a picture
55
+ * one on each, and the page step fills the ones it asked for; a card whose
56
+ * picture could not be found then stood bare beside pictured ones. Each such
57
+ * row's pictures are taken out, so the row reads even. A row is two or more
58
+ * items drawn alike (the same element, its parts in the same order but for
59
+ * the picture); a split row of words beside a picture is no such row.
60
+ */
61
+ export declare function aiLayoutEvenCardPictures(input: NodesMap): {
62
+ nodes: NodesMap;
63
+ evened: number;
64
+ };
38
65
  /** The page or frame with every gap taken out, and what was taken. */
39
66
  export declare function aiLayoutWithoutGaps(input: NodesMap, rootId: string): {
40
67
  nodes: NodesMap;
@@ -253,6 +253,130 @@ function cloneNodes(input) {
253
253
  dropped
254
254
  };
255
255
  }
256
+ /** Elements that only hold or frame others: a section of these and headings says nothing. */ const HOLDERS = new Set([
257
+ 'div',
258
+ 'section',
259
+ 'muiBox',
260
+ 'muiStack',
261
+ 'muiContainer',
262
+ 'muiGrid',
263
+ 'muiPaper',
264
+ 'muiCard',
265
+ 'muiCardContent',
266
+ 'muiLinkBox',
267
+ 'icon'
268
+ ]);
269
+ /** Whether a section shows nothing but its heading (AGL-4152): every element under it a holder, an icon, a heading or words-less text. */ function hollowSection(nodes, id) {
270
+ return subtree(nodes, id).every((each)=>{
271
+ const node = nodes[each];
272
+ if (HOLDERS.has(node.componentId)) return true;
273
+ if (node.componentId === 'muiTypography') return isHeading(node) || !wordsOf(node);
274
+ return false;
275
+ });
276
+ }
277
+ /**
278
+ * A finished page with no section left a heading alone (AGL-4152), its first
279
+ * aside: each such section goes, with any link that scrolled to it
280
+ * (`aiLayoutWithoutSections`). The last word on a redesigned page, after its
281
+ * pictures are placed or dropped: a heading over a list its answer left empty,
282
+ * or over a band of pictures none of which could be found, says only that
283
+ * something is missing. Anything under it that is not a holder, an icon or a
284
+ * heading (a picture, a button, a form, a film, a table, a line of words)
285
+ * keeps the section.
286
+ */ export function aiLayoutWithoutHollowSections(input, rootId) {
287
+ var _ref;
288
+ var _nodes_rootId;
289
+ const nodes = input;
290
+ const [, ...rest] = (_ref = (_nodes_rootId = nodes[rootId]) == null ? void 0 : _nodes_rootId.nodes) != null ? _ref : [];
291
+ const hollow = rest.filter((id)=>nodes[id] && hollowSection(nodes, id)).map((id)=>{
292
+ var _ref;
293
+ var _nodes_id_props, _nodes_id;
294
+ return {
295
+ id,
296
+ name: String((_ref = (_nodes_id = nodes[id]) == null ? void 0 : (_nodes_id_props = _nodes_id.props) == null ? void 0 : _nodes_id_props['ariaLabel']) != null ? _ref : id),
297
+ why: 'left with only its heading'
298
+ };
299
+ });
300
+ return aiLayoutWithoutSections(input, rootId, hollow);
301
+ }
302
+ /** Elements that wrap one item of a row without being it: a grid's cell, a link around a card. */ const ITEM_WRAPPERS = new Set([
303
+ 'muiGrid',
304
+ 'muiLinkBox',
305
+ 'muiBox'
306
+ ]);
307
+ /** The element an item of a row is drawn as: through its cell and any link around it, to its card or its stack. */ function itemOf(nodes, id) {
308
+ let at = id;
309
+ for(let depth = 0; depth < 4; depth += 1){
310
+ var _ref;
311
+ const node = nodes[at];
312
+ const children = (_ref = node == null ? void 0 : node.nodes) != null ? _ref : [];
313
+ if (!node || node.componentId === 'muiCard' || children.length !== 1 || !ITEM_WRAPPERS.has(node.componentId)) return at;
314
+ at = children[0];
315
+ }
316
+ return at;
317
+ }
318
+ /**
319
+ * A finished page whose rows of cards each show a picture on every card or on
320
+ * none (AGL-4152). A redesign gives a row most of whose cards had a picture
321
+ * one on each, and the page step fills the ones it asked for; a card whose
322
+ * picture could not be found then stood bare beside pictured ones. Each such
323
+ * row's pictures are taken out, so the row reads even. A row is two or more
324
+ * items drawn alike (the same element, its parts in the same order but for
325
+ * the picture); a split row of words beside a picture is no such row.
326
+ */ export function aiLayoutEvenCardPictures(input) {
327
+ const source = input;
328
+ const rows = [];
329
+ for (const node of Object.values(source)){
330
+ var _node_nodes;
331
+ const children = (_node_nodes = node.nodes) != null ? _node_nodes : [];
332
+ if (children.length < 2) continue;
333
+ const items = children.map((child)=>itemOf(source, child));
334
+ const shapes = items.map((item)=>source[item]);
335
+ const first = shapes[0];
336
+ if (!first || first.componentId !== 'muiCard' && first.componentId !== 'muiStack') continue;
337
+ if (!shapes.every((shape)=>shape && shape.componentId === first.componentId)) continue;
338
+ const pictureOf = (item)=>{
339
+ var _ref;
340
+ var _source_item;
341
+ return ((_ref = (_source_item = source[item]) == null ? void 0 : _source_item.nodes) != null ? _ref : []).filter((child)=>{
342
+ var _source_child;
343
+ return ((_source_child = source[child]) == null ? void 0 : _source_child.componentId) === 'image';
344
+ });
345
+ };
346
+ const pictured = items.filter((item)=>pictureOf(item).length).length;
347
+ if (!pictured || pictured === items.length) continue;
348
+ const partsOf = (item)=>{
349
+ var _ref;
350
+ var _source_item;
351
+ return ((_ref = (_source_item = source[item]) == null ? void 0 : _source_item.nodes) != null ? _ref : []).filter((child)=>{
352
+ var _source_child;
353
+ return ((_source_child = source[child]) == null ? void 0 : _source_child.componentId) !== 'image';
354
+ }).map((child)=>{
355
+ var _source_child;
356
+ return (_source_child = source[child]) == null ? void 0 : _source_child.componentId;
357
+ }).join(',');
358
+ };
359
+ const parts = partsOf(items[0]);
360
+ if (!parts || !items.every((item)=>partsOf(item) === parts)) continue;
361
+ rows.push(items.flatMap(pictureOf));
362
+ }
363
+ if (!rows.length) return {
364
+ nodes: input,
365
+ evened: 0
366
+ };
367
+ const nodes = cloneNodes(input);
368
+ const parents = parentsOf(nodes);
369
+ for (const picture of rows.flat()){
370
+ var _nodes_parent_nodes;
371
+ const parent = parents.get(picture);
372
+ for (const each of subtree(nodes, picture))delete nodes[each];
373
+ if (parent && nodes[parent]) nodes[parent].nodes = ((_nodes_parent_nodes = nodes[parent].nodes) != null ? _nodes_parent_nodes : []).filter((child)=>child !== picture);
374
+ }
375
+ return {
376
+ nodes: nodes,
377
+ evened: rows.length
378
+ };
379
+ }
256
380
  /** The page or frame with every gap taken out, and what was taken. */ export function aiLayoutWithoutGaps(input, rootId) {
257
381
  const found = gapsOf(input);
258
382
  if (!found.length) return {