@aglyn/plugins-ai 1.10.0 → 1.12.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.
- package/package.json +17 -17
- package/src/lib/jobs/ai-job-import-step.d.ts +1 -1
- package/src/lib/jobs/ai-job-import-step.js +26 -7
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-privacy-step.js +2 -2
- package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +27 -37
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.js +20 -1
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +7 -1
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/model/ai-credit-estimate.d.ts +15 -0
- package/src/lib/model/ai-credit-estimate.js +13 -0
- package/src/lib/model/ai-credit-estimate.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +46 -3
- package/src/lib/model/ai-site-import-fidelity.js +254 -62
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-report.d.ts +7 -0
- package/src/lib/model/ai-site-import-report.js +17 -5
- package/src/lib/model/ai-site-import-report.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +46 -3
- package/src/lib/model/ai-site-import.js +34 -11
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +16 -0
- package/src/lib/model/ai-site-look.js +76 -14
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/site-import/fixtures/aglyn-com-recordings.d.ts +2 -1
- package/src/lib/site-import/fixtures/aglyn-com-recordings.js +3 -2
- package/src/lib/site-import/fixtures/aglyn-com-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.d.ts +5 -0
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.js +116 -3
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +7 -0
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +15 -0
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.js +4 -3
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-look-slate.d.ts +2 -1
- package/src/lib/site-import/fixtures/site-look-slate.js +2 -1
- package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -1
- package/src/lib/site-import/site-import-crawl.d.ts +7 -1
- package/src/lib/site-import/site-import-crawl.js +101 -6
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +8 -1
- package/src/lib/site-import/site-import-css.js +30 -8
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-html.d.ts +2 -0
- package/src/lib/site-import/site-import-html.js +3 -0
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +9 -2
- package/src/lib/site-import/site-import-layout.js +104 -30
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/site-import/site-import-page.js +5 -0
- package/src/lib/site-import/site-import-page.js.map +1 -1
- package/src/lib/site-import/site-import-same-page.d.ts +41 -0
- package/src/lib/site-import/site-import-same-page.js +108 -0
- package/src/lib/site-import/site-import-same-page.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-compile.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\n/*==========================================\n * A PAGE BROUGHT IN, BUILT BY THE SITE COMPILER (AGL-4107).\n *\n * On 10/29 an import of aglyn.com came out one column of plain lines: the\n * import drew its own stacked text instead of the site's cards, columns,\n * pictures, icons and bands. This module is the page's build now:\n *\n * 1. The source's LAYOUT, as the reader read it (`AiSiteImportPageRead.\n * layout`, AGL-4106) — its sections and bands, rows of columns, groups of\n * cards, steps, figures, questions, quotes, logos and plans, its tables,\n * tabs, pictures and icons — becomes the layout language the guided\n * start's compiler takes (`aiSiteImportDesignedSections`): a group is a\n * `cards` block whose items carry every part (icon, picture, figure,\n * paragraphs, bullet points, links), a table a `table` block, tabs a\n * `tabs` block. Every line is placed exactly once, in its own section; a\n * line the layout placed nowhere is added at its section's end.\n * 2. The site compiler draws it (`aiCompileLayoutPage`, `verbatim`), with\n * the palette's own elements and the theme's tokens: the Card, the\n * Accordion, the Table, the Tabs, the hero around the source's picture.\n * Every word is the source's, as written.\n * A video is the Video element where the source's film sat (AGL-4140),\n * poster first, playing from where the old page played it, and a button\n * whose words say it plays the film scrolls to it and presses play.\n * 3. A main page's DESIGN is the one question a model answers\n * (`submit_design`, `aiSiteImportDesignText`): which hero the opening\n * becomes, how each group is drawn, a band where the source gave none,\n * the kind of a group the reader could not tell, an alignment. A page of\n * a collection, and any page whose answer is missing, is drawn from the\n * layout with no model.\n * 4. How the owner asked the site FINISHED (AGL-4152). Keep my site, the\n * default for an import that asked nothing, is the above held tighter:\n * the source's alignment, its boxing and its heading's measure, whatever\n * the answer says. Improve it frees the layout: the answer's bands and\n * alignment on every section, the site's band rhythm, the theme's widths,\n * any hero, any group's kind and style, like runs of lines as cards.\n * Either way every word, picture, icon, button, heading, form and film\n * is the source's.\n *\n * A read made before the reader kept no layout: its page is read into one\n * here, from its lines, one section at each second-level heading.\n *=========================================*/\n\nimport {\n aiCompileLayoutPage,\n type AiLayoutCompiledPage,\n type AiLayoutPagePlan,\n} from '../layout-language/ai-layout-compiler'\nimport type { AiLayoutDesign } from '../layout-language/ai-layout-design'\nimport {\n AI_LAYOUT_GROUP_STYLES,\n AI_LAYOUT_IMPORT_HEROES,\n AI_LAYOUT_MAX_COLS,\n type AiLayoutBlock,\n type AiLayoutColorRole,\n type AiLayoutDesignAnswer,\n type AiLayoutDesignSection,\n type AiLayoutGroupStyle,\n type AiLayoutImportHero,\n type AiLayoutItem,\n type AiLayoutLink,\n type AiLayoutPicture,\n type AiLayoutPictureFit,\n type AiLayoutSection,\n type AiLayoutSettlement,\n type AiLayoutStyle,\n type AiLayoutVideo,\n type AiLayoutWidth,\n} from '../layout-language/ai-layout-language'\nimport type { AiLayoutTargets } from '../layout-language/ai-layout-links'\nimport {\n AI_SITE_IMPORT_LABEL_MAX_CHARS,\n SITE_IMPORT_PLAY_WORDS,\n siteImportFilmSource,\n siteImportWidthOf,\n type AiSiteImportPhoto,\n type SiteImportGroupKind,\n type SiteImportHeroPicture,\n type SiteImportIconShape,\n type SiteImportLayout,\n type SiteImportLayoutGroup,\n type SiteImportLayoutItem,\n type SiteImportLayoutLine,\n type SiteImportLayoutNode,\n type SiteImportLayoutSection,\n type SiteImportLayoutVideo,\n type SiteImportLineRef,\n type SiteImportLookFacts,\n type SiteImportPictureFit,\n type SiteImportRule,\n type AiSiteImportFinish,\n} from '../model/ai-site-import'\nimport { aiHexOklch } from '../model/ai-site-look'\nimport { aiModelAtLeastStepTier } from '../providers/routing'\nimport type { SiteImportBlock } from '../site-import/site-import-html'\nimport {\n AI_SITE_IMPORT_DOC_MAX_NODES,\n AI_SITE_IMPORT_LABEL_CHARS,\n aiSiteImportDocLines,\n aiSiteImportTextParts,\n aiSiteImportWordsIn,\n type AiSiteImportDocument,\n} from './ai-site-import-document'\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\n/** Whether a block is a line of the page: a link inside a sentence is in its sentence. */\nfunction isLine(block: SiteImportBlock | undefined): boolean {\n if (!block) return false\n if (block.kind === 'image') return !!block.url\n if (block.kind === 'link') return !block.inline && !!clean(block.text)\n return !!clean(block.text)\n}\n\n/*------------------------------------------\n * The page's job: its model and its links\n *-----------------------------------------*/\n\n/**\n * The model a page brought in asks its design answer on (AGL-4107): the page\n * step's own tier, balanced, whatever the deployment's default model is — the\n * job's own pick where it is that tier or above.\n */\nexport function aiImportPageModel(modelFor?: (kind: 'job.page') => string | undefined): string {\n return aiModelAtLeastStepTier('job.page', modelFor?.('job.page'))\n}\n\n/**\n * Every page the import plans that a page brought in may link (AGL-4107), by\n * the id its draft is written under: a link to one in a wave still to come\n * shows its words until that page is live, then goes there.\n */\nexport function aiSiteImportLinkablePages(doc: Pick<AiSiteImportDocument, 'links'> | null): Array<{ id: string; label: string; slug: string }> {\n if (!doc) return []\n const seen = new Set<string>()\n return doc.links.flatMap((link) => {\n if (seen.has(link.id)) return []\n seen.add(link.id)\n const path = link.path.replace(/\\/+$/, '') || '/'\n return [{ id: link.id, label: path, slug: path }]\n })\n}\n\n/**\n * The listing a page brought in keeps (AGL-4107): its source's own title and\n * description, word for word, never clipped and never rewritten — the 10/29\n * import's Home was retitled \"Aglyn: Build a Website with AI, Free to Start\".\n * Only a part the source left empty takes what was `written` for it.\n */\nexport function aiImportedPageListing(\n screen: { seoTitle: string; seoDescription: string },\n written: { title?: string; description?: string } = {},\n): { title: string; description: string } {\n return {\n title: screen.seoTitle.trim() || (written.title ?? '').trim(),\n description: screen.seoDescription.trim() || (written.description ?? '').trim(),\n }\n}\n\n/** Whether a page brought in still owes a part of its listing: one its source left empty. */\nexport function aiImportedPageListingOwed(listing: { title: string; description: string }): boolean {\n return !listing.title || !listing.description\n}\n\n/*------------------------------------------\n * The layout a page is built from\n *-----------------------------------------*/\n\n/**\n * The layout of a page whose read kept none (AGL-4107): its lines in their\n * sections — the opening, then one at each second-level heading — each line\n * where the source put it, in order.\n */\nexport function aiSiteImportLayoutOfLines(doc: Pick<AiSiteImportDocument, 'blocks' | 'title'>): SiteImportLayout {\n const { lines, sections } = aiSiteImportDocLines(doc.blocks, doc.title)\n // The document's lines are numbered over the page's lines; the layout's are indexes of its blocks.\n const refOf: number[] = []\n doc.blocks.forEach((block, index) => {\n if (isLine(block)) refOf.push(index)\n })\n return {\n v: 1,\n sections: sections.map((section, index) => {\n const refs = section.lines.map((n) => refOf[n - 1]).filter((ref): ref is number => ref !== undefined)\n return {\n name: section.name,\n from: 'heading' as const,\n band: index % 2 === 1 ? ('soft' as const) : ('plain' as const),\n background: null,\n align: 'start' as const,\n nodes: refs.map((ref): SiteImportLayoutNode => (doc.blocks[ref]?.kind === 'image' ? { kind: 'picture', line: ref } : { kind: 'line', line: ref })),\n lines: refs,\n }\n }),\n icons: [],\n look: { fonts: { body: null, headings: null, google: [] }, background: null, text: null, buttonFill: null, buttonText: null, buttonRadius: null, link: null, header: null },\n }\n}\n\n/** The layout a page is built from: the reader's, else one read from its lines. */\nexport function aiSiteImportLayoutOf(doc: Pick<AiSiteImportDocument, 'blocks' | 'title' | 'layout'>): SiteImportLayout {\n return doc.layout && doc.layout.sections.length ? doc.layout : aiSiteImportLayoutOfLines(doc)\n}\n\n/**\n * The page's sections by name, in order (AGL-4107): the source's own, as its\n * layout names them — its `aria-label`s, its headings — two of one name told\n * apart, so a link to either finds it. The page's plan has exactly these.\n */\nexport function aiSiteImportSectionNames(doc: Pick<AiSiteImportDocument, 'blocks' | 'title' | 'layout'>): string[] {\n const named = new Set<string>()\n const names = aiSiteImportLayoutOf(doc).sections.map((section, index) => {\n const name = clean(section.name).slice(0, AI_SITE_IMPORT_LABEL_MAX_CHARS) || `Section ${index + 1}`\n let unique = name\n for (let attempt = 2; named.has(unique.toLowerCase()); attempt += 1) {\n unique = `${name.slice(0, AI_SITE_IMPORT_LABEL_MAX_CHARS - 5)} (${attempt})`\n }\n named.add(unique.toLowerCase())\n return unique\n })\n return names.length ? names : ['Introduction']\n}\n\n/*------------------------------------------\n * The source's icons, on the icon element's square\n *-----------------------------------------*/\n\n/** How many numbers each path command takes, by its lower-case letter. */\nconst PATH_PARAMS: Readonly<Record<string, number>> = { m: 2, l: 2, h: 1, v: 1, c: 6, s: 4, q: 4, t: 2, a: 7, z: 0 }\n\nconst NUMBER = /[\\s,]*([-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)/y\nconst FLAG = /[\\s,]*([01])/y\n\n/** A number of a path, at most three decimals, as short as it reads. */\nconst round = (value: number): string => {\n const fixed = Math.round(value * 1000) / 1000\n return Object.is(fixed, -0) ? '0' : String(fixed)\n}\n\n/**\n * A path's drawing moved onto the icon element's 24-unit square (AGL-4107):\n * every coordinate scaled from its viewBox and centered, every relative move\n * scaled alone, an arc's radii scaled and its flags and rotation kept.\n * `null` for anything that is not path data.\n */\nexport function aiSiteImportPathOn24(d: string, viewBox: string): string | null {\n const box = viewBox.trim().split(/[\\s,]+/).map(Number)\n if (box.length !== 4 || box.some((value) => !Number.isFinite(value)) || box[2] <= 0 || box[3] <= 0) return null\n const [minX, minY, width, height] = box\n const scale = 24 / Math.max(width, height)\n const dx = (24 - width * scale) / 2 - minX * scale\n const dy = (24 - height * scale) / 2 - minY * scale\n const identity = Math.abs(scale - 1) < 1e-9 && Math.abs(dx) < 1e-9 && Math.abs(dy) < 1e-9\n const out: string[] = []\n let at = 0\n let first = true\n const source = d.trim()\n while (at < source.length) {\n while (at < source.length && /[\\s,]/.test(source[at])) at += 1\n if (at >= source.length) break\n const command = source[at]\n const lower = command.toLowerCase()\n if (!(lower in PATH_PARAMS)) return null\n at += 1\n const count = PATH_PARAMS[lower]\n const relative = command === lower\n const groups: number[][] = []\n if (count === 0) {\n out.push(command)\n first = false\n continue\n }\n for (;;) {\n const group: number[] = []\n for (let index = 0; index < count; index += 1) {\n const pattern = lower === 'a' && (index === 3 || index === 4) ? FLAG : NUMBER\n pattern.lastIndex = at\n const match = pattern.exec(source)\n if (!match) break\n group.push(Number(match[1]))\n at = pattern.lastIndex\n }\n if (group.length === 0) break\n if (group.length !== count) return null\n groups.push(group)\n }\n if (!groups.length) return null\n const parts = groups.map((group, index) => {\n // A path that opens on a relative move opens at that point, as an absolute one would.\n const absolute = !relative || (first && lower === 'm' && index === 0)\n const x = (value: number) => (absolute ? value * scale + dx : value * scale)\n const y = (value: number) => (absolute ? value * scale + dy : value * scale)\n switch (lower) {\n case 'h':\n return [x(group[0])]\n case 'v':\n return [y(group[0])]\n case 'a':\n return [group[0] * scale, group[1] * scale, group[2], group[3], group[4], x(group[5]), y(group[6])]\n default:\n return group.map((value, position) => (position % 2 === 0 ? x(value) : y(value)))\n }\n })\n out.push(`${command}${parts.map((part) => part.map(round).join(' ')).join(' ')}`)\n first = false\n }\n if (!out.length || !/^[Mm]/.test(out[0])) return null\n return identity ? source : out.join('')\n}\n\n/** The attributes of a shape in a reader's cleaned drawing. */\nfunction shapeAttributes(source: string): Record<string, string> {\n const out: Record<string, string> = {}\n for (const match of source.matchAll(/([a-zA-Z-]+)=\"([^\"]*)\"/g)) out[match[1].toLowerCase()] = match[2]\n return out\n}\n\nconst num = (value: string | undefined): number => (value === undefined ? Number.NaN : Number.parseFloat(value))\n\n/** A shape of a drawing as path data, or `null` for one that is only a stroke or is moved by a transform. */\nfunction shapePath(tag: string, attributes: Record<string, string>): string | null {\n if (attributes['transform'] || attributes['fill'] === 'none') return null\n switch (tag) {\n case 'path':\n return attributes['d']?.trim() || null\n case 'circle':\n case 'ellipse': {\n const cx = num(attributes['cx'] ?? '0')\n const cy = num(attributes['cy'] ?? '0')\n const rx = tag === 'circle' ? num(attributes['r']) : num(attributes['rx'])\n const ry = tag === 'circle' ? rx : num(attributes['ry'])\n if (![cx, cy, rx, ry].every(Number.isFinite) || rx <= 0 || ry <= 0) return null\n return `M${cx - rx} ${cy}A${rx} ${ry} 0 1 0 ${cx + rx} ${cy}A${rx} ${ry} 0 1 0 ${cx - rx} ${cy}Z`\n }\n case 'rect': {\n const x = num(attributes['x'] ?? '0')\n const y = num(attributes['y'] ?? '0')\n const width = num(attributes['width'])\n const height = num(attributes['height'])\n if (![x, y, width, height].every(Number.isFinite) || width <= 0 || height <= 0) return null\n return `M${x} ${y}H${x + width}V${y + height}H${x}Z`\n }\n case 'polygon': {\n const points = (attributes['points'] ?? '').trim().split(/[\\s,]+/).map(Number)\n if (points.length < 4 || points.length % 2 || points.some((value) => !Number.isFinite(value))) return null\n return `M${points.slice(0, 2).join(' ')}L${points.slice(2).join(' ')}Z`\n }\n default:\n // A line or an open polyline is a stroke: filled, it draws nothing.\n return null\n }\n}\n\n/**\n * The source's icon as the icon element draws one (AGL-4107): one path on its\n * 24-unit square. A one-path icon is its path, moved onto the square; a small\n * drawing of several filled shapes is their paths together. A drawing made of\n * strokes, or of shapes a transform moves, has no one path, and is left out:\n * an icon is no word of the page.\n */\nexport function aiSiteImportIconPath(shape: SiteImportIconShape | undefined): string | null {\n if (!shape) return null\n if (shape.path) return aiSiteImportPathOn24(shape.path, shape.viewBox)\n if (!shape.svg) return null\n const paths: string[] = []\n for (const match of shape.svg.matchAll(/<(path|circle|ellipse|rect|polygon|polyline|line)\\b([^>]*)\\/?>/gi)) {\n const path = shapePath(match[1].toLowerCase(), shapeAttributes(match[2]))\n if (!path) return null\n paths.push(path)\n }\n return paths.length ? aiSiteImportPathOn24(paths.join(''), shape.viewBox) : null\n}\n\n/*------------------------------------------\n * The layout in the layout language\n *-----------------------------------------*/\n\n/** The groups a design answer may read as another kind: the ones whose kind the reader told by their shape alone. */\nconst OPEN_KINDS: ReadonlySet<SiteImportGroupKind> = new Set(['cards', 'steps', 'stats', 'list', 'text'])\n\n/**\n * The groups that keep their kind even on a page its owner asked improved\n * (AGL-4152): a quote's words and a strip of logos have no place in a card's\n * title or a step's, and would stop being what they are; questions and\n * answers stay questions a visitor opens, and plans stay plan cards. The 11/4\n * eval's answers redrew five pages' questions as cards.\n */\nconst FIXED_KINDS: ReadonlySet<SiteImportGroupKind> = new Set(['quotes', 'logos', 'faq', 'pricing'])\n\n/** The styles that box a group's items, and the ones that leave them open: Keep my site keeps a group's own (AGL-4152). */\nconst BOXED_STYLES: ReadonlySet<AiLayoutGroupStyle> = new Set(['cards', 'articles'])\nconst OPEN_STYLES: ReadonlySet<AiLayoutGroupStyle> = new Set(['ruled', 'icons', 'pictures'])\n\n/** The fewest like items a run of lines needs to be drawn as cards, on a page its owner asked improved (AGL-4152). */\nconst LIKE_ITEMS_AS_CARDS = 3\n\n/** The hero each place of the source's picture opens as, where no answer chose one. */\nconst HERO_FOR: Readonly<Record<SiteImportHeroPicture, AiLayoutImportHero>> = {\n beside: 'split',\n behind: 'cover',\n below: 'column',\n above: 'column',\n}\n\ninterface MapScope {\n doc: AiSiteImportDocument\n layout: SiteImportLayout\n /** Lines taken into a block, by index of the page's blocks. */\n used: Set<number>\n /** Pictures the library could not hold, which a page leaves out. */\n missing: Set<number>\n photos: ReadonlyMap<string, AiSiteImportPhoto>\n pathTo: ReadonlyMap<string, string>\n /** The site's saved form a page brought in places where its source had one. */\n formId: string | null\n formPlaced: boolean\n /** The section being mapped: its design answer, and how many of its groups have been met. */\n answer: AiLayoutDesignSection | null\n groupAt: number\n settled: AiLayoutSettlement[]\n at: string\n /** The page's films the Video element plays, by their index (AGL-4140). */\n films: ReadonlyMap<number, AiLayoutVideo>\n /** The film a play button of this section plays: the section's own first, else the page's. */\n film: number | null\n /** How the owner asked the page finished (AGL-4152): kept as its source lays it out, or improved. */\n finish: AiSiteImportFinish\n}\n\n/** Where a link of the source goes on the new site, in the compiler's words; `undefined` where it can go nowhere a page may send a visitor. */\nfunction linkTo(scope: Pick<MapScope, 'doc' | 'pathTo'>, href: string | undefined): string | undefined {\n const value = (href ?? '').trim()\n if (/^mailto:[^\\s@]+@[^\\s@]+$/i.test(value) || /^tel:\\+?[\\d\\s().-]{3,}$/i.test(value)) return value\n let url: URL\n try {\n url = new URL(value)\n } catch {\n return undefined\n }\n if (url.protocol !== 'https:' && url.protocol !== 'http:') return undefined\n if (scope.doc.origins.includes(url.origin)) {\n // The old site's own page: the page it becomes, any page the import plans\n // (AGL-4107), which a visitor reaches once it is live.\n const path = url.pathname.replace(/\\/+$/, '') || '/'\n const id = scope.pathTo.get(path)\n return id ? `page:${id}` : undefined\n }\n return url.protocol === 'https:' ? url.toString() : undefined\n}\n\n/** A line's words, as written; marks it taken. */\nfunction take(scope: MapScope, ref: SiteImportLineRef | undefined): string {\n if (ref === undefined || scope.used.has(ref)) return ''\n const block = scope.doc.blocks[ref]\n if (!isLine(block)) return ''\n scope.used.add(ref)\n return block.kind === 'image' ? '' : clean(block.text)\n}\n\n/** A width over a height as `aspect-ratio` writes it: \"1600 / 900\", or \"1.7778\" for a ratio alone. */\nfunction ratioText(width: number, height = 1): string {\n const round = (value: number) => String(Math.round(value * 10_000) / 10_000)\n return height === 1 ? round(width) : `${round(width)} / ${round(height)}`\n}\n\n/** The radius past which a source's picture reads as rounded (AGL-4138), not merely softened: 10 px. */\nconst ROUNDED_PX = 10\n\n/**\n * How a picture of a page brought in is framed (AGL-4138): at the box the\n * source crops it to, where it sets one, else at the picture's own shape —\n * the library's copy's size first, its `width` and `height` second — so a\n * frame of its own shape, filled, cuts nothing off; its fit, and the\n * source's rounded corners and shadow. A round portrait is the byline's.\n */\nfunction pictureFitOf(photo: AiSiteImportPhoto, fit: SiteImportPictureFit | undefined): AiLayoutPictureFit | undefined {\n const out: AiLayoutPictureFit = {}\n if (fit?.box) Object.assign(out, { ratio: ratioText(fit.box), cropped: true as const })\n else if (fit?.height) Object.assign(out, { height: Math.round(fit.height), cropped: true as const })\n else if (photo.width && photo.height) out.ratio = ratioText(photo.width, photo.height)\n else if (fit?.ratio) out.ratio = ratioText(fit.ratio)\n if (fit?.objectFit) out.objectFit = fit.objectFit\n if (fit?.radius !== undefined && fit.radius >= ROUNDED_PX && fit.radius < 999) out.rounded = true\n if (fit?.shadow) out.shadow = true\n // The width the source holds it to, as the theme's breakpoint nearest it; the widest is no hold at all.\n const measure = siteImportWidthOf(fit?.measure)\n if (measure && measure !== 'xl') out.measure = measure\n return Object.keys(out).length ? out : undefined\n}\n\n/** A picture line as the library holds it; marks it taken, and missing where the library holds none. */\nfunction takePicture(scope: MapScope, ref: SiteImportLineRef | undefined, href?: string, fit?: SiteImportPictureFit): AiLayoutPicture | null {\n if (ref === undefined || scope.used.has(ref)) return null\n const block = scope.doc.blocks[ref]\n if (!block || block.kind !== 'image') return null\n scope.used.add(ref)\n const photo = scope.photos.get(block.url)\n if (!photo) {\n scope.missing.add(ref)\n return null\n }\n const alt = clean(block.alt || photo.alt || '').slice(0, 200)\n const ratio = photo.width && photo.height ? photo.width / photo.height : 0\n const to = linkTo(scope, href)\n const framed = pictureFitOf(photo, fit)\n return { src: photo.src, alt, ...(ratio > 0 ? { ratio } : {}), ...(to ? { to } : {}), ...(framed ? { fit: framed } : {}) }\n}\n\n/*------------------------------------------\n * The source's colors as the theme's roles (AGL-4138)\n *-----------------------------------------*/\n\n/** How colorful a color must be to be a color, not a grey. */\nconst COLORFUL_CHROMA = 0.04\n\n/** How far apart two colors look, in OKLab. */\nfunction colorGap(a: string, b: string): number {\n const [x, y] = [aiHexOklch(a), aiHexOklch(b)]\n const ax = x.C * Math.cos((x.h * Math.PI) / 180)\n const ay = x.C * Math.sin((x.h * Math.PI) / 180)\n const bx = y.C * Math.cos((y.h * Math.PI) / 180)\n const by = y.C * Math.sin((y.h * Math.PI) / 180)\n return Math.hypot(x.L - y.L, ax - bx, ay - by)\n}\n\nconst HEX = /^#[0-9a-f]{6}$/i\n\n/** Whether a colorful color is the brand's: the source's buttons' fill or its links' color, by its look or its hue. */\nfunction brandish(hex: string, look: Pick<SiteImportLookFacts, 'buttonFill' | 'link'> | null | undefined): boolean {\n const own = aiHexOklch(hex)\n return [look?.buttonFill, look?.link].some((other) => {\n if (!other || !HEX.test(other)) return false\n const them = aiHexOklch(other)\n if (them.C < COLORFUL_CHROMA) return false\n const hue = Math.abs(own.h - them.h) % 360\n return colorGap(hex, other) <= 0.1 || Math.min(hue, 360 - hue) <= 25\n })\n}\n\n/**\n * A source's own color as the theme role a page brought in draws it in\n * (AGL-4138), so no value is ever written onto an element: the brand's\n * colors as `primary`, any other color as the theme's third, which the look\n * pins to the source's eyebrows' (`aiSiteImportStyle`); a grey as the words'\n * ink or their muted shade, or as the divider for a rule; a light fill as the\n * theme's tint. `null` where no role is the color's: white words on a dark\n * band take the band's own.\n */\nexport function aiSiteImportColorRole(hex: string | null | undefined, look: Pick<SiteImportLookFacts, 'buttonFill' | 'link'> | null | undefined, use: 'ink' | 'fill' | 'rule'): AiLayoutColorRole | null {\n if (!hex || !HEX.test(hex)) return null\n const own = aiHexOklch(hex)\n if (use === 'fill' && own.L >= 0.9) return 'action.hover'\n if (own.C < COLORFUL_CHROMA) {\n if (use === 'rule') return 'divider'\n if (use === 'fill' || own.L >= 0.9) return null\n return own.L <= 0.35 ? 'text.primary' : 'text.secondary'\n }\n return brandish(hex, look) ? 'primary.main' : 'tertiary.main'\n}\n\n/** An icon's color in a tile: the fill's own contrast where the icon is a light one on a strong fill. */\nfunction tileInk(fill: AiLayoutColorRole, color: string | null, look: SiteImportLookFacts): AiLayoutColorRole | null {\n const light = !!color && HEX.test(color) && aiHexOklch(color).L >= 0.9\n if (light && fill === 'primary.main') return 'primary.contrastText'\n if (light && fill === 'tertiary.main') return 'tertiary.contrastText'\n return aiSiteImportColorRole(color, look, 'ink')\n}\n\n/** A group's rule as the compiler draws it: its side, its width in the theme's border steps, its color's role. */\nfunction ruleOf(rule: SiteImportRule, look: SiteImportLookFacts): NonNullable<AiLayoutBlock['rule']> {\n const width = rule.width >= 3 ? 3 : rule.width === 2 ? 2 : 1\n return { side: rule.side, width, color: aiSiteImportColorRole(rule.color, look, 'rule') }\n}\n\n/** Words as text blocks, a paragraph longer than a text element holds split between its sentences. */\nfunction textBlocks(kind: 'text' | 'lede' | 'note', text: string): AiLayoutBlock[] {\n return aiSiteImportTextParts(text).map((part) => ({ kind, text: part }))\n}\n\n/** A link of the source: a button where its words fit one, a link in a list where they run longer, its words where it goes nowhere. */\nfunction linkBlocks(scope: MapScope, text: string, href: string, style: AiLayoutStyle): AiLayoutBlock[] {\n const to = linkTo(scope, href)\n if (text.length <= AI_SITE_IMPORT_LABEL_CHARS) return [{ kind: 'button', text, ...(to ? { to } : {}), style }]\n if (to) return [{ kind: 'list', items: [{ title: text, text: '', to }] }]\n return textBlocks('text', text)\n}\n\n/** One line in place, as the kind of block its source and its role say. */\nfunction lineBlocks(scope: MapScope, node: SiteImportLayoutLine): AiLayoutBlock[] {\n const block = scope.doc.blocks[node.line]\n if (!block || scope.used.has(node.line)) return []\n if (block.kind === 'image') {\n const picture = takePicture(scope, node.line)\n return picture ? [{ kind: 'image', picture }] : []\n }\n const text = take(scope, node.line)\n if (!text) return []\n switch (block.kind) {\n case 'heading':\n return [{ kind: 'heading', text }]\n case 'link':\n return linkBlocks(scope, text, block.href, node.button ?? 'quiet')\n case 'list-item':\n return [{ kind: 'list', items: [{ title: text, text: '' }] }]\n case 'quote':\n return [{ kind: 'quotes', style: 'quiet', items: [{ title: '', text }] }]\n default: {\n // A button whose words say it plays a film plays the section's film, else the page's (AGL-4140).\n if (node.button && scope.film !== null && SITE_IMPORT_PLAY_WORDS.test(text) && text.length <= AI_SITE_IMPORT_LABEL_CHARS) {\n return [{ kind: 'button', text, style: node.button, to: `video:${scope.film}` }]\n }\n if (node.role === 'eyebrow') {\n // In its own pill and its own color, as the source sets it (AGL-4138).\n const color = aiSiteImportColorRole(node.color, scope.layout.look, 'ink')\n return [{ kind: 'eyebrow', text, ...(node.chip ? { chip: true as const } : {}), ...(color ? { color } : {}) }]\n }\n // A statement is a lede set large (AGL-4138), split as any text is between its sentences where it runs long.\n if (node.role === 'statement') return textBlocks('lede', text).map((block) => ({ ...block, style: 'large' as const }))\n return textBlocks(node.role === 'lede' ? 'lede' : node.role === 'note' ? 'note' : 'text', text)\n }\n }\n}\n\n/** The icon a group item or a bullet carries, by its index into the page's icons. */\nfunction iconAt(scope: MapScope, index: number | undefined): string | undefined {\n return index === undefined ? undefined : (aiSiteImportIconPath(scope.layout.icons[index]) ?? undefined)\n}\n\n/** The style of a link inside an item: as the source draws it, else a plan's own button outlined and any other a quiet link. */\nfunction itemLinkStyle(group: SiteImportLayoutGroup, item: SiteImportLayoutItem, ref: SiteImportLineRef): AiLayoutStyle {\n return item.ctas?.find((cta) => cta.line === ref)?.style ?? (group.group === 'pricing' ? 'secondary' : 'quiet')\n}\n\n/** One item of a group, drawn as `kind`, every line of it in exactly one of its parts. */\nfunction itemOf(scope: MapScope, group: SiteImportLayoutGroup, item: SiteImportLayoutItem, kind: SiteImportGroupKind = group.group): AiLayoutItem {\n const out: AiLayoutItem = { title: '', text: '' }\n const named = new Set<number>([\n ...(item.title !== undefined ? [item.title] : []),\n ...(item.figure !== undefined ? [item.figure] : []),\n ...(item.image !== undefined ? [item.image] : []),\n ...(item.badge !== undefined ? [item.badge] : []),\n ...(item.period !== undefined ? [item.period] : []),\n ...(item.text ?? []),\n ...(item.list ?? []),\n ...(item.link ?? []),\n ])\n const paragraphs: string[] = []\n const links: AiLayoutLink[] = []\n const addLink = (ref: number) => {\n const block = scope.doc.blocks[ref]\n const text = take(scope, ref)\n if (!text) return\n const to = block?.kind === 'link' ? linkTo(scope, block.href) : undefined\n if (text.length <= AI_SITE_IMPORT_LABEL_CHARS) links.push({ text, ...(to ? { to } : {}), style: itemLinkStyle(group, item, ref) })\n else paragraphs.push(text)\n }\n // The item's lines in the source's order: each where its part says.\n for (const ref of item.lines) {\n if (scope.used.has(ref)) continue\n const block = scope.doc.blocks[ref]\n if (!block) continue\n if (ref === item.title) out.title = take(scope, ref)\n else if (ref === item.figure) out.figure = take(scope, ref)\n else if (ref === item.period) out.period = take(scope, ref)\n // A figure stands alone: its tag, if it has one, is among its words.\n else if (ref === item.badge && kind !== 'stats') out.badge = take(scope, ref)\n else if (ref === item.image || (block.kind === 'image' && !named.has(ref))) {\n const picture = takePicture(scope, ref, undefined, ref === item.image ? item.imageFit : undefined)\n if (picture && !out.picture) out.picture = picture\n } else if (item.list?.includes(ref)) {\n const line = take(scope, ref)\n if (line) out.list = [...(out.list ?? []), line]\n } else if (item.link?.includes(ref) || (block.kind === 'link' && (!named.has(ref) || clean(block.text).length <= AI_SITE_IMPORT_LABEL_CHARS))) addLink(ref)\n else {\n const line = take(scope, ref)\n if (line) paragraphs.push(...aiSiteImportTextParts(line))\n }\n }\n if (paragraphs.length) out.text = paragraphs[0]\n if (paragraphs.length > 1) out.more = paragraphs.slice(1)\n if (links.length) out.links = links\n // A row's name is a heading only where the source says so.\n if (group.inline && item.title !== undefined && scope.doc.blocks[item.title]?.kind !== 'heading') out.label = true\n const icon = iconAt(scope, item.icon)\n if (icon) out.iconPath = icon\n const mark = iconAt(scope, item.listIcon)\n if (mark && out.list?.length) out.listIconPath = mark\n // Its icon's square and its arrow, as the source draws them (AGL-4138).\n const fill = icon && item.tile ? aiSiteImportColorRole(item.tile.fill, scope.layout.look, 'fill') : null\n if (fill && item.tile) out.tile = { fill, color: tileInk(fill, item.tile.color, scope.layout.look) }\n const arrow = iconAt(scope, item.mark)\n if (arrow) out.markPath = arrow\n if (item.figureMuted && out.figure) out.figureMuted = true\n // A film the item holds plays from its poster (AGL-4140), and the item is no link around it.\n const film = item.video !== undefined ? scope.films.get(item.video) : undefined\n if (film && out.picture) {\n out.picture = { ...out.picture, video: film }\n return out\n }\n const to = linkTo(scope, item.to)\n if (to) out.to = to\n return out\n}\n\n/** The style a group of cards is drawn in where its design answer chose none: the source's own box, its rule, icons or pictures. */\nfunction defaultStyle(group: SiteImportLayoutGroup, items: readonly AiLayoutItem[]): AiLayoutGroupStyle {\n const pictured = items.length > 0 && items.every((item) => item.picture)\n if (pictured) return group.boxed ? 'articles' : 'pictures'\n if (group.boxed) return 'cards'\n // A rule along each item, a step's line over its number, is no box (AGL-4138).\n if (group.rule) return 'ruled'\n return items.length > 0 && items.every((item) => item.iconPath) ? 'icons' : 'ruled'\n}\n\n/** What a group of a page brought in carries of how its source draws it (AGL-4138): its items' own alignment, its tablet columns, its rule when it is drawn ruled. */\nfunction drawnAs(scope: MapScope, group: SiteImportLayoutGroup, style?: AiLayoutGroupStyle): Pick<AiLayoutBlock, 'itemsAlign' | 'columnsSm' | 'rule'> {\n return {\n ...(group.align ? { itemsAlign: group.align } : {}),\n ...(group.columnsSm ? { columnsSm: group.columnsSm } : {}),\n ...(style === 'ruled' && group.rule ? { rule: ruleOf(group.rule, scope.layout.look) } : {}),\n }\n}\n\n/**\n * The style an answer chose, where the group can be drawn so: pictures need a\n * picture on every item, icons an icon. A page kept as it is keeps the\n * source's boxing (AGL-4152): a boxed group takes only a boxed style, an open\n * one only an open style.\n */\nfunction styleFor(asked: AiLayoutGroupStyle | undefined, group: SiteImportLayoutGroup, items: readonly AiLayoutItem[], finish: AiSiteImportFinish): AiLayoutGroupStyle {\n const fallback = defaultStyle(group, items)\n if (!asked || !(AI_LAYOUT_GROUP_STYLES as readonly string[]).includes(asked)) return fallback\n if (finish !== 'improve' && !(group.boxed ? BOXED_STYLES : OPEN_STYLES).has(asked)) return fallback\n if ((asked === 'pictures' || asked === 'articles') && !items.every((item) => item.picture)) return fallback\n if (asked === 'icons' && !items.every((item) => item.iconPath)) return fallback\n return asked\n}\n\n/**\n * Whether a run of lines that only share a shape reads as cards (AGL-4152):\n * three or more items, each showing the same parts and led by its own title,\n * with no heading among an item's lines but its title, so every heading of\n * the source is still a heading.\n */\nfunction likeItems(scope: MapScope, group: SiteImportLayoutGroup): boolean {\n if (group.items.length < LIKE_ITEMS_AS_CARDS) return false\n if (new Set(group.items.map((item) => itemShape(item).join(' + '))).size !== 1) return false\n return group.items.every((item) => item.title !== undefined && item.lines.every((ref) => ref === item.title || scope.doc.blocks[ref]?.kind !== 'heading'))\n}\n\n/** The longest line that leads a figure: \"1-click\", \"$0.83\". */\nconst FIGURE_MAX_CHARS = 14\n\n/**\n * Whether a group can be drawn as figures (AGL-4083): each item a short line\n * over its label and nothing else. A figure has no place for a link, a bullet,\n * a picture or an icon, so an item with one, drawn as a figure, loses it.\n */\nfunction holdsOnlyFigures(scope: MapScope, group: SiteImportLayoutGroup): boolean {\n return group.items.every((item) => {\n const lead = item.title ?? item.lines[0]\n const block = lead === undefined ? undefined : scope.doc.blocks[lead]\n return (\n !!block &&\n block.kind !== 'image' &&\n clean(block.text).length <= FIGURE_MAX_CHARS &&\n item.lines.length <= 3 &&\n !item.link?.length &&\n !item.list?.length &&\n item.image === undefined &&\n item.icon === undefined &&\n !item.lines.some((ref) => scope.doc.blocks[ref]?.kind === 'link' || scope.doc.blocks[ref]?.kind === 'image')\n )\n })\n}\n\n/** A group of the source, in the layout language: every item of it, in the kind and style its answer chose or its source shows. */\nfunction groupBlocks(scope: MapScope, group: SiteImportLayoutGroup): AiLayoutBlock[] {\n const answer = scope.answer?.groups[scope.groupAt] ?? null\n scope.groupAt += 1\n const improve = scope.finish === 'improve'\n // Rows the source sets are drawn as its rows: no answer's kind or style is one of them (AGL-4083). On a\n // page its owner asked improved, a kind the answer names is (AGL-4152); a style alone has nothing to draw in rows.\n if (group.inline && !(improve && answer?.kind)) {\n if (answer?.kind || answer?.style) scope.settled.push({ at: scope.at, what: `a ${group.group} group drawn as the source's rows` })\n return [{ kind: 'cards', items: group.items.map((item) => itemOf(scope, group, item)), columns: 1, inline: true }]\n }\n // A page its owner asked improved reads any group as the answer does (AGL-4152), but a quote, a logo, a question or a plan.\n const opens = improve ? !FIXED_KINDS.has(group.group) : OPEN_KINDS.has(group.group)\n const answered: SiteImportGroupKind = answer?.kind && opens ? answer.kind : group.group\n // Lines that only share a shape, three or more alike, are cards on a page its owner asked improved (AGL-4152).\n const carded = improve && answered === 'text' && likeItems(scope, group)\n if (carded) scope.settled.push({ at: scope.at, what: `${group.items.length} like runs of lines drawn as cards` })\n const asked: SiteImportGroupKind = carded ? 'cards' : answered\n // A list is one line an item (AGL-4083): one asked of items with more would\n // join a label to its value, and 49 of a plan's rows lost theirs so on 11/1.\n const joins = asked === 'list' && group.group !== 'list' && group.items.some((item) => item.lines.length > 1)\n const unfigured = asked === 'stats' && group.group !== 'stats' && !holdsOnlyFigures(scope, group)\n const kind: SiteImportGroupKind = joins ? 'cards' : unfigured ? group.group : asked\n if (joins) scope.settled.push({ at: scope.at, what: `a ${group.group} group kept apart: its items hold more than one line each, so it is no list` })\n else if (unfigured) scope.settled.push({ at: scope.at, what: `a ${group.group} group kept as it is: its items hold more than a figure can show` })\n else if (kind !== group.group && !carded) scope.settled.push({ at: scope.at, what: `a ${group.group} group drawn as ${kind}, as its design answer read it` })\n const columns = Math.max(1, Math.min(AI_LAYOUT_MAX_COLS, group.columns || 1))\n if (kind === 'text') {\n // Lines that only share a shape: each where it stands.\n return group.items.flatMap((item) => item.lines.flatMap((ref) => lineBlocks(scope, { kind: 'line', line: ref })))\n }\n if (kind === 'list') {\n const items = group.items.flatMap((item): AiLayoutItem[] => {\n const linked = item.lines.map((ref) => scope.doc.blocks[ref]).find((block) => block?.kind === 'link')\n const words = item.lines.map((ref) => take(scope, ref)).filter(Boolean).join(' ')\n for (const ref of item.lines) {\n if (scope.doc.blocks[ref]?.kind === 'image') takePicture(scope, ref)\n }\n if (!words) return []\n const icon = iconAt(scope, item.icon)\n const to = linkTo(scope, item.to ?? (linked?.kind === 'link' ? linked.href : undefined))\n return [{ title: words, text: '', ...(icon ? { iconPath: icon } : {}), ...(to ? { to } : {}) }]\n })\n return items.length ? [{ kind: 'list', items, columns }] : []\n }\n if (kind === 'logos') {\n const items = group.items.flatMap((item): AiLayoutItem[] => {\n let picture: AiLayoutPicture | null = null\n const words: string[] = []\n for (const ref of item.lines) {\n if (scope.doc.blocks[ref]?.kind === 'image') picture = picture ?? takePicture(scope, ref)\n else {\n const line = take(scope, ref)\n if (line) words.push(line)\n }\n }\n if (picture && !words.length) return [{ title: '', text: '', picture }]\n // A strip of linked tags keeps its links (AGL-4138): a blog's categories go to their pages.\n const to = picture ? undefined : linkTo(scope, item.to)\n return words.length ? [{ title: words.join(' '), text: '', ...(picture ? { picture } : {}), ...(to ? { to } : {}) }] : picture ? [{ title: '', text: '', picture }] : []\n })\n return items.length ? [{ kind: 'logos', items }] : []\n }\n const items = group.items.map((item) => itemOf(scope, group, item, kind))\n // Whether the items are boxed: the source's, or on a page its owner asked improved, the answer's style (AGL-4152).\n const boxed = improve && answer?.style ? BOXED_STYLES.has(answer.style) : group.boxed\n if (kind === 'quotes') {\n // The reader names a quote's words its title and who said it its text.\n const quotes = items.map((item) => ({ ...item, title: [item.text, ...(item.more ?? [])].filter(Boolean).join(' '), text: item.title, more: [] as string[] }))\n return [{ kind: 'quotes', items: quotes.map(({ more: _more, ...item }) => item), columns, ...(boxed ? { variant: 'cards' as const } : { style: 'quiet' as const }), ...drawnAs(scope, group) }]\n }\n if (kind === 'faq') return [{ kind: 'faq', items, columns }]\n if (kind === 'stats') return [{ kind: 'stats', items, columns, ...(boxed ? { variant: 'cards' as const } : {}), ...drawnAs(scope, group) }]\n // A group kept apart from a list is ruled, where its boxing allows (AGL-4152).\n const style = styleFor(joins ? 'ruled' : answer?.style, group, items, scope.finish)\n return [{ kind: kind === 'steps' ? 'steps' : 'cards', items, columns, variant: style, ...drawnAs(scope, group, style) }]\n}\n\n/** A section's nodes in the layout language, a row of columns placed by `col` where the section may still take one. */\nfunction nodeBlocks(scope: MapScope, nodes: readonly SiteImportLayoutNode[], row: { cols: number[] | null; allowed: boolean }): AiLayoutBlock[] {\n const out: AiLayoutBlock[] = []\n for (const node of nodes) {\n switch (node.kind) {\n case 'line':\n out.push(...lineBlocks(scope, node))\n break\n case 'picture': {\n const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit)\n if (picture) out.push({ kind: 'image', picture })\n break\n }\n case 'icon':\n // A lone icon is no word and no picture of the page.\n break\n case 'video':\n out.push(...videoBlocks(scope, node))\n break\n case 'form': {\n // The form rebuilt for this one (AGL-4083); a read from before they were, the site's only form, once.\n const own = scope.doc.forms?.find((entry) => entry.index === node.form)\n if (scope.doc.forms) {\n if (own?.formId) out.push({ kind: 'form', to: own.formId })\n } else if (scope.formId && !scope.formPlaced) {\n scope.formPlaced = true\n out.push({ kind: 'form', to: scope.formId })\n }\n break\n }\n case 'row': {\n const cells = node.cells.filter((cell) => cell.nodes.length)\n const byline = bylineOf(scope, cells)\n if (byline) {\n // A portrait beside a name and a date: the portrait small, over its words.\n out.push(...byline)\n break\n }\n if (row.allowed && !row.cols && cells.length >= 2 && cells.length <= AI_LAYOUT_MAX_COLS) {\n // The section's row: each cell a column, by the source's widths.\n const weights = node.cells.map((cell, index) => ({ cell, weight: node.cols[index] ?? 1 })).filter((entry) => entry.cell.nodes.length)\n row.cols = weights.map((entry) => Math.min(12, Math.max(1, Math.round(entry.weight))))\n weights.forEach((entry, col) => {\n for (const block of nodeBlocks(scope, entry.cell.nodes, { cols: null, allowed: false })) out.push({ ...block, col })\n })\n } else {\n // A second row of a section, or one inside a column: its cells one under another.\n for (const cell of node.cells) out.push(...nodeBlocks(scope, cell.nodes, { cols: null, allowed: false }))\n }\n break\n }\n case 'group':\n out.push(...groupBlocks(scope, node))\n break\n case 'table': {\n const rows = node.rows.map((tableRow) => ({ cells: tableRow.cells.map((cell) => cell.lines.map((ref) => take(scope, ref)).filter(Boolean).join(' ')) }))\n if (rows.some((tableRow) => tableRow.cells.some(Boolean))) out.push({ kind: 'table', header: node.header, rows })\n break\n }\n case 'tabs': {\n const tabs = node.tabs.map((tab) => {\n const label = tab.label === null ? '' : take(scope, tab.label)\n // A panel sets its first row side by side, as a section does (AGL-4114).\n const panelRow = { cols: null as number[] | null, allowed: true }\n const blocks = mergeLists(nodeBlocks(scope, tab.panel, panelRow))\n return {\n label,\n ...(tab.selected ? { selected: true } : {}),\n blocks,\n ...(panelRow.cols && blocks.some((block) => block.col !== undefined) ? { cols: panelRow.cols } : {}),\n }\n })\n if (tabs.some((tab) => tab.label || tab.blocks.length)) out.push({ kind: 'tabs', tabs })\n break\n }\n default:\n break\n }\n }\n return out\n}\n\n/**\n * A video of the source, where it sat (AGL-4140): the Video element, its\n * poster the library's copy of the source's, where the Video element can play\n * the film. One on a host it cannot play is its poster, linking to where the\n * film plays; with no poster either, nothing of it can be shown.\n */\nfunction videoBlocks(scope: MapScope, node: Pick<SiteImportLayoutVideo, 'video' | 'poster' | 'fit' | 'shadow'>): AiLayoutBlock[] {\n const film = scope.films.get(node.video)\n if (film) {\n // A film is pressed to play from its poster: with none, the Video element has nothing to show, and it is left out.\n const picture = filmPlaces(scope, node.video, node.poster) ? takePicture(scope, node.poster, undefined, node.fit) : null\n if (!picture) {\n scope.settled.push({ at: scope.at, what: 'a video left out: it has no poster picture' })\n return []\n }\n const video: AiLayoutVideo = { ...film, ...(node.shadow ? { shadow: true } : {}) }\n return [{ kind: 'video', video, picture }]\n }\n const source = scope.doc.videos?.[node.video]\n const where = source?.embed ?? source?.src\n const picture = takePicture(scope, node.poster, where, node.fit)\n const host = (() => {\n try {\n return where ? new URL(where).hostname.replace(/^www\\./, '') : ''\n } catch {\n return ''\n }\n })()\n if (picture && source) scope.settled.push({ at: scope.at, what: `a video${host ? ` on ${host}` : ''} shown as its picture${picture.to ? ', linking to it' : ''}` })\n return picture ? [{ kind: 'image', picture }] : []\n}\n\n/** The page's films the Video element plays, by index (AGL-4140): each read's video that plays from a host it knows, or from the old site's https address. */\nfunction filmsOf(doc: AiSiteImportDocument): Map<number, AiLayoutVideo> {\n const films = new Map<number, AiLayoutVideo>()\n ;(doc.videos ?? []).forEach((video, index) => {\n const source = siteImportFilmSource(video)\n if (!source) return\n const title = clean(video.title).slice(0, 200)\n const description = clean(video.description).slice(0, 2_000)\n films.set(index, {\n index,\n src: source.src,\n ...(title ? { title } : {}),\n ...(description ? { description } : {}),\n ...(video.uploadDate ? { uploadDate: video.uploadDate } : {}),\n ...(video.durationSeconds ? { durationSeconds: video.durationSeconds } : {}),\n })\n })\n return films\n}\n\n/** Whether a film is drawn as the Video element: one it plays, its poster a picture the library holds. */\nfunction filmPlaces(scope: Pick<MapScope, 'films' | 'doc' | 'photos'>, video: number, poster: SiteImportLineRef | undefined): boolean {\n const block = poster === undefined ? undefined : scope.doc.blocks[poster]\n return scope.films.has(video) && block?.kind === 'image' && scope.photos.has(block.url)\n}\n\n/** The first film of a list of nodes drawn as the Video element, rows, tabs and items opened. */\nfunction firstFilm(scope: Pick<MapScope, 'films' | 'doc' | 'photos'>, nodes: readonly SiteImportLayoutNode[]): number | null {\n for (const node of nodes) {\n const found =\n node.kind === 'video'\n ? filmPlaces(scope, node.video, node.poster)\n ? node.video\n : null\n : node.kind === 'row'\n ? firstFilm(scope, node.cells.flatMap((cell) => cell.nodes))\n : node.kind === 'tabs'\n ? firstFilm(scope, node.tabs.flatMap((tab) => tab.panel))\n : node.kind === 'group'\n ? (node.items.find((item) => item.video !== undefined && filmPlaces(scope, item.video, item.image))?.video ?? null)\n : null\n if (found !== null) return found\n }\n return null\n}\n\n/** The most words beside a lone picture that make a row a byline: a name, a date, a role. */\nconst BYLINE_MAX_WORDS = 12\n\n/**\n * A row that is a byline (AGL-4107): one cell a lone picture, the other a few\n * words — a writer's portrait beside their name and date. Drawn as columns it\n * set a portrait across half the page; it is the portrait, small, and its words.\n */\nfunction bylineOf(scope: MapScope, cells: ReadonlyArray<{ nodes: SiteImportLayoutNode[] }>): AiLayoutBlock[] | null {\n if (cells.length !== 2) return null\n const at = cells.findIndex((cell) => cell.nodes.length === 1 && cell.nodes[0].kind === 'picture')\n if (at === -1) return null\n const words = cells[1 - at].nodes\n if (!words.every((node) => node.kind === 'line')) return null\n const count = words.reduce((total, node) => {\n const block = scope.doc.blocks[(node as SiteImportLayoutLine).line]\n return total + (block && block.kind !== 'image' ? aiSiteImportWordsIn(clean(block.text)) : 0)\n }, 0)\n if (count === 0 || count > BYLINE_MAX_WORDS) return null\n const node = cells[at].nodes[0] as Extract<SiteImportLayoutNode, { kind: 'picture' }>\n const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit)\n return [...(picture ? [{ kind: 'image' as const, picture: { ...picture, small: true } }] : []), ...nodeBlocks(scope, words, { cols: null, allowed: false })]\n}\n\n/** Paragraphs past which a section is reading copy, set at the start whatever its source centers. */\nconst READING_PARAGRAPHS = 4\n\n/** Neighboring one-line lists of one column as one list, as the source's list items read. */\nfunction mergeLists(blocks: readonly AiLayoutBlock[]): AiLayoutBlock[] {\n const out: AiLayoutBlock[] = []\n for (const block of blocks) {\n const last = out[out.length - 1]\n const plain = (entry: AiLayoutBlock | undefined) => entry?.kind === 'list' && entry.columns === undefined && !entry.items?.some((item) => item.iconPath)\n if (plain(block) && plain(last) && last?.col === block.col) {\n out[out.length - 1] = { ...last, items: [...(last.items ?? []), ...(block.items ?? [])] }\n continue\n }\n out.push(block)\n }\n return out\n}\n\n/** The heroes that lay dimmed words over the picture, which draw their section dark. */\nconst DIMMED_HEROES: ReadonlySet<AiLayoutImportHero> = new Set(['cover', 'poster'])\n\n/**\n * The heroes that keep the source's picture where it lays it (AGL-4138): under\n * or over its words in a column, beside them, or behind them. An answer may\n * choose among these alone.\n */\nconst HEROES_AT: Readonly<Record<SiteImportHeroPicture, ReadonlySet<AiLayoutImportHero>>> = {\n below: new Set(['column', 'editorial']),\n above: new Set(['column', 'editorial']),\n beside: new Set(['split', 'bleed', 'panel']),\n behind: new Set(['cover', 'poster', 'panel']),\n}\n\n/**\n * The hero a section's opening takes: the first section's, around its picture\n * beside, behind or under its words. Words dimmed over the picture draw the\n * section dark, so a section that keeps a lighter ground of its own, with its\n * picture anywhere but behind it, opens as its source does (AGL-4083): an\n * answer never repaints a section's own band. Nor does it move the picture\n * (AGL-4138): a picture under centered words stays under them, as a picture\n * beside the words stays beside them.\n */\nfunction heroOf(\n section: SiteImportLayoutSection,\n index: number,\n answer: AiLayoutDesignSection | null,\n settled: AiLayoutSettlement[],\n drawn: { band: SiteImportLayoutSection['band']; finish: AiSiteImportFinish },\n): AiLayoutImportHero | undefined {\n if (index !== 0 || !section.hero?.picture) return undefined\n // An answer of \"none\" keeps the opening as the source lays it out.\n if (answer?.hero === 'none') return undefined\n const place = section.hero.picture\n const own = HERO_FOR[place]\n // Dimmed words need a dark ground: the section's own, or on a page its owner asked improved, the answer's (AGL-4152).\n if (answer?.hero && DIMMED_HEROES.has(answer.hero) && drawn.band !== 'dark' && place !== 'behind') {\n settled.push({ at: 'sections[0]', what: `the ${answer.hero} hero set aside: the section keeps its own lighter ground` })\n return own\n }\n // The picture stays where the source lays it, unless the owner asked the page improved (AGL-4152).\n if (answer?.hero && drawn.finish !== 'improve' && !HEROES_AT[place].has(answer.hero)) {\n settled.push({ at: 'sections[0]', what: `the ${answer.hero} hero set aside: the source lays its picture ${place} its words` })\n return own\n }\n return answer?.hero ?? own\n}\n\n/** How a page is finished (AGL-4152): the finish asked of it, else its document's, else kept as it is. */\nexport function aiSiteImportFinishOf(doc: Pick<AiSiteImportDocument, 'finish'> | null | undefined, asked?: AiSiteImportFinish | null): AiSiteImportFinish {\n const finish = asked ?? doc?.finish\n return finish === 'improve' ? 'improve' : 'keep'\n}\n\n/**\n * The Container width a source holds its opening's heading to (AGL-4152):\n * the theme's breakpoint nearest its measure, at most a page's own, which an\n * opening's words may span; none where the source sets none.\n */\nexport function aiSiteImportHeroMeasure(section: Pick<SiteImportLayoutSection, 'hero'>): Exclude<AiLayoutWidth, 'xl'> | null {\n const step = siteImportWidthOf(section.hero?.measure)\n return step === 'xl' ? 'lg' : step\n}\n\nexport interface AiSiteImportDesigned {\n sections: AiLayoutSection[]\n /** Lines taken into a block, by index of the page's blocks. */\n used: Set<number>\n /** Pictures the library could not hold. */\n missing: Set<number>\n settled: AiLayoutSettlement[]\n}\n\n/**\n * The page's sections in the layout language (AGL-4107): the source's layout,\n * each section in its own band (or the answer's, where the source gave none),\n * its row, its groups and their items, its tables, tabs and pictures, every\n * line taken exactly once and every line the layout placed nowhere added at\n * its section's end.\n */\nexport function aiSiteImportDesignedSections(\n doc: AiSiteImportDocument,\n answer?: AiLayoutDesignAnswer | null,\n options: { formId?: string | null; finish?: AiSiteImportFinish | null } = {},\n): AiSiteImportDesigned {\n const layout = aiSiteImportLayoutOf(doc)\n const finish = aiSiteImportFinishOf(doc, options.finish)\n const improve = finish === 'improve'\n const scope: MapScope = {\n doc,\n layout,\n used: new Set(),\n missing: new Set(),\n photos: new Map(doc.photos.flatMap((photo) => (photo.from ? [[photo.from, photo] as const] : []))),\n pathTo: new Map(doc.links.map((link) => [link.path.replace(/\\/+$/, '') || '/', link.id])),\n formId: options.formId ?? null,\n formPlaced: false,\n answer: null,\n groupAt: 0,\n settled: [],\n at: '',\n films: filmsOf(doc),\n film: null,\n finish,\n }\n const backdropOf = (section: SiteImportLayoutSection) => (section.backdrop?.kind === 'video' ? section.backdrop : null)\n const pageFilm = layout.sections.reduce<number | null>((found, section) => found ?? firstFilm(scope, section.nodes), null)\n const sections = layout.sections.map((section, index): AiLayoutSection => {\n const given = answer?.sections[index] ?? null\n scope.answer = given\n scope.groupAt = 0\n scope.at = `sections[${index}]`\n const behind = backdropOf(section)\n scope.film = firstFilm(scope, section.nodes) ?? pageFilm\n const row = { cols: null as number[] | null, allowed: true }\n // A film playing on its own behind the section's words is drawn as its poster there (AGL-4140): the\n // opening's hero lays it behind them. A film that starts on its own is one rule 16 refuses.\n const poster = behind ? takePicture(scope, behind.poster) : null\n if (behind) scope.settled.push({ at: scope.at, what: 'a film playing behind the words drawn as its poster' })\n const blocks = [...(poster ? [{ kind: 'image' as const, picture: poster }] : []), ...nodeBlocks(scope, section.nodes, row)]\n // Every line the layout placed nowhere, at the section's end, as its kind says.\n for (const ref of section.lines) {\n if (scope.used.has(ref)) continue\n const block = doc.blocks[ref]\n if (!isLine(block)) continue\n blocks.push(...lineBlocks(scope, { kind: 'line', line: ref }))\n }\n // A band only where the source gave the section none of its own; any section's, on a page its owner asked improved (AGL-4152).\n const band = given?.band && (improve || (section.background === null && !section.backdrop)) ? given.band : section.band\n const hero = heroOf(section, index, given, scope.settled, { band: improve ? band : section.band, finish })\n // A long read is set at the start, as text is read, whatever its source centers.\n const reading = blocks.filter((block) => block.kind === 'text').length > READING_PARAGRAPHS\n const source = reading ? 'start' : section.align\n // The source's own heading measure for its opening's words, on a page kept as it is (AGL-4152).\n const measure = hero && !improve ? aiSiteImportHeroMeasure(section) : null\n return {\n band,\n // Kept as it is, a section keeps the source's alignment (AGL-4152); improved, the answer's.\n align: improve ? (given?.align ?? source) : source,\n // As wide as the source runs (AGL-4083), or the theme's own on a page its owner asked improved (AGL-4152);\n // where it sets no cap, a page's width, a long read's measure.\n width: (improve ? null : siteImportWidthOf(section.width)) ?? (reading ? 'md' : 'lg'),\n ...(row.cols && blocks.some((block) => block.col !== undefined) ? { cols: row.cols } : {}),\n blocks: mergeLists(blocks),\n ...(hero ? { hero } : {}),\n ...(measure ? { measure } : {}),\n }\n })\n return { sections, used: scope.used, missing: scope.missing, settled: scope.settled }\n}\n\n/*------------------------------------------\n * The page compiled\n *-----------------------------------------*/\n\nexport interface AiSiteImportCompileInput {\n doc: AiSiteImportDocument\n /** The ids the page stores its sections under, in plan order: one for each of the page's sections. */\n sectionIds: readonly string[]\n /** The page's plan: its title and its sections by name. */\n plan: AiLayoutPagePlan\n targets: AiLayoutTargets\n /** The site the page belongs to, which its hero is drawn for. */\n design?: AiLayoutDesign | null\n language?: string\n /** The page's design answer, for a main page; absent, the page is drawn as its source lays it out. */\n answer?: AiLayoutDesignAnswer | null\n /** How the page is finished (AGL-4152); absent is `keep`. */\n finish?: AiSiteImportFinish | null\n}\n\nexport interface AiSiteImportCompiled extends Pick<AiLayoutCompiledPage, 'tree' | 'sectionRoots' | 'videoIds'> {\n sections: AiLayoutSection[]\n /** The lines on the page, by index of its blocks, in source order. */\n placed: number[]\n /** Every line the page has. */\n lines: number\n /** The words on the page, and the words its lines hold. */\n words: number\n sourceWords: number\n /** Set when the page ran past what one page may weigh, and its last sections keep only their names. */\n cut: boolean\n settled: AiLayoutSettlement[]\n}\n\n/**\n * The page brought in, built by the site compiler (AGL-4107): every line on\n * it exactly once, every word as its source wrote it, laid out as its source\n * lays it out and drawn in the site's own theme.\n */\nexport function aiCompileImportedPage(input: AiSiteImportCompileInput): AiSiteImportCompiled {\n const { doc } = input\n const formId = input.targets.forms.length === 1 ? input.targets.forms[0].id : null\n const finish = aiSiteImportFinishOf(doc, input.finish)\n const designed = aiSiteImportDesignedSections(doc, input.answer ?? null, { formId, finish })\n const compile = (sections: readonly AiLayoutSection[]) =>\n aiCompileLayoutPage(sections, input.plan, input.targets, {\n // A page brought in draws its repeats as its source does (AGL-4107).\n reusableComponents: false,\n sectionIds: input.sectionIds,\n verbatim: true,\n finish,\n ...(input.design ? { design: input.design } : {}),\n ...(input.language ? { language: input.language } : {}),\n })\n let sections = designed.sections\n let compiled = compile(sections)\n let cut = false\n // A page past what one page may weigh keeps its last sections by name.\n for (let last = sections.length - 1; Object.keys(compiled.tree.nodes).length > AI_SITE_IMPORT_DOC_MAX_NODES && last > 0; last -= 1) {\n cut = true\n sections = sections.map((section, index) => (index >= last ? { ...section, blocks: [], cols: undefined } : section))\n compiled = compile(sections)\n }\n const dropped = new Set<number>()\n if (cut) {\n const layout = aiSiteImportLayoutOf(doc)\n layout.sections.forEach((section, index) => {\n if (!sections[index]?.blocks.length) for (const ref of section.lines) dropped.add(ref)\n })\n }\n const lineRefs = doc.blocks.flatMap((block, index) => (isLine(block) ? [index] : []))\n const placed = lineRefs.filter((ref) => designed.used.has(ref) && !designed.missing.has(ref) && !dropped.has(ref))\n const wordsOf = (ref: number) => {\n const block = doc.blocks[ref]\n return block && block.kind !== 'image' ? aiSiteImportWordsIn(clean(block.text)) : 0\n }\n return {\n tree: compiled.tree,\n sectionRoots: compiled.sectionRoots,\n // Its films' Video elements keep their ids when stored, as its sections do: a button that plays one names it (AGL-4140).\n ...(compiled.videoIds?.length ? { videoIds: compiled.videoIds } : {}),\n sections,\n placed,\n lines: lineRefs.length,\n words: placed.reduce((total, ref) => total + wordsOf(ref), 0),\n sourceWords: lineRefs.reduce((total, ref) => total + wordsOf(ref), 0),\n cut,\n settled: [...designed.settled, ...compiled.settled],\n }\n}\n\n/*------------------------------------------\n * What the design answer is shown\n *-----------------------------------------*/\n\n/** The most characters of a page's structure a design prompt shows. */\nexport const AI_SITE_IMPORT_DESIGN_MAX_CHARS = 12_000\n\n/** What a line is, as the design answer reads its place. */\nfunction lineKind(block: SiteImportBlock | undefined, node: SiteImportLayoutLine): string {\n if (!block) return 'line'\n if (block.kind === 'heading') return 'heading'\n if (block.kind === 'link') return node.button ? `${node.button === 'primary' ? 'filled' : node.button === 'secondary' ? 'outlined' : 'quiet'} button` : 'link'\n if (block.kind === 'list-item') return 'list item'\n if (block.kind === 'quote') return 'quote'\n if (block.kind === 'image') return 'picture'\n // A statement is read as the lede it was before the import drew it larger (AGL-4138): the answer's text is unchanged.\n return node.role === 'statement' ? 'lede' : (node.role ?? 'text')\n}\n\n/** What an item of a group shows, as one phrase: \"icon + title + text + link\". */\nfunction itemShape(item: SiteImportLayoutItem): string[] {\n return [\n item.image !== undefined ? 'picture' : '',\n item.icon !== undefined ? 'icon' : '',\n item.figure !== undefined ? 'figure' : '',\n item.title !== undefined ? 'title' : '',\n item.text?.length ? 'text' : '',\n item.list?.length ? `${item.listIcon !== undefined ? 'checked ' : ''}list` : '',\n item.link?.length ? 'link' : '',\n ].filter(Boolean)\n}\n\n/** A run of one kind of part counted: \"2 buttons\", not \"button, button\". */\nfunction counted(parts: readonly string[]): string {\n const out: string[] = []\n for (let at = 0; at < parts.length; ) {\n let run = 1\n while (parts[at + run] === parts[at]) run += 1\n out.push(run > 1 ? `${run} ${parts[at]}s` : parts[at])\n at += run\n }\n return out.join(', ')\n}\n\n/** A section's nodes as the design answer reads them, its groups numbered in order. */\nfunction describeNodes(doc: Pick<AiSiteImportDocument, 'blocks'>, nodes: readonly SiteImportLayoutNode[], groups: { count: number }): string[] {\n const parts: string[] = []\n for (const node of nodes) {\n switch (node.kind) {\n case 'line':\n parts.push(lineKind(doc.blocks[node.line], node))\n break\n case 'picture':\n // A film reads as the picture it opens on (AGL-4140): the design answer is asked nothing new of it.\n case 'video':\n parts.push('picture')\n break\n case 'form':\n parts.push('form')\n break\n case 'row':\n parts.push(`a row of ${node.cells.length} columns (${node.cells.map((cell, index) => `column ${index + 1}: ${describeNodes(doc, cell.nodes, groups).join(', ') || 'empty'}`).join('; ')})`)\n break\n case 'group': {\n groups.count += 1\n const shape = [...new Set(node.items.map((item) => itemShape(item).join(' + ')).filter(Boolean))].slice(0, 2).join(' or ')\n // A group set apart by a rule reads \"boxed\", as it did before the rule was kept (AGL-4138): the answer's text is unchanged.\n parts.push(`group ${groups.count}: ${node.items.length} ${node.group} in ${node.columns} column${node.columns === 1 ? '' : 's'}${node.boxed || node.rule ? ', boxed' : ''}${shape ? `, each ${shape}` : ''}`)\n break\n }\n case 'table':\n parts.push(`a table of ${node.rows.length} rows`)\n break\n case 'tabs':\n parts.push(`${node.tabs.length} tabs (${node.tabs.map((tab, index) => `tab ${index + 1}: ${describeNodes(doc, tab.panel, groups).join(', ') || 'not drawn'}`).join('; ')})`)\n break\n default:\n break\n }\n }\n return parts\n}\n\n/**\n * The page's structure as its design answer reads it (AGL-4107): each\n * section's name, band, alignment and what it shows, its groups numbered as\n * the answer names them. No word of the page is in it but its sections'\n * names, which are fenced where the prompt shows them.\n */\nexport function aiSiteImportDesignText(doc: Pick<AiSiteImportDocument, 'blocks' | 'title' | 'layout'>): string {\n const layout = aiSiteImportLayoutOf(doc)\n const names = aiSiteImportSectionNames(doc)\n return layout.sections\n .map((section, index) => {\n const groups = { count: 0 }\n const shows = describeNodes(doc, section.nodes, groups)\n const band = section.background === null && !section.backdrop ? 'no band of its own' : `${section.band} band${section.backdrop?.kind === 'gradient' ? ' with a gradient' : ''}`\n const hero = index === 0 && section.hero?.picture ? `; opens the page, its picture ${section.hero.picture} its words` : index === 0 ? '; opens the page, with no picture' : ''\n return `Section ${index + 1} \"${names[index]}\": ${band}, ${section.align === 'center' ? 'centered' : 'aligned to the start'}${hero}. Groups: ${groups.count}. Shows: ${counted(shows)}.`\n })\n .join('\\n')\n}\n"],"names":["aiCompileLayoutPage","AI_LAYOUT_GROUP_STYLES","AI_LAYOUT_MAX_COLS","AI_SITE_IMPORT_LABEL_MAX_CHARS","SITE_IMPORT_PLAY_WORDS","siteImportFilmSource","siteImportWidthOf","aiHexOklch","aiModelAtLeastStepTier","AI_SITE_IMPORT_DOC_MAX_NODES","AI_SITE_IMPORT_LABEL_CHARS","aiSiteImportDocLines","aiSiteImportTextParts","aiSiteImportWordsIn","clean","text","replace","trim","isLine","block","kind","url","inline","aiImportPageModel","modelFor","aiSiteImportLinkablePages","doc","seen","Set","links","flatMap","link","has","id","add","path","label","slug","aiImportedPageListing","screen","written","title","seoTitle","description","seoDescription","aiImportedPageListingOwed","listing","aiSiteImportLayoutOfLines","lines","sections","blocks","refOf","forEach","index","push","v","map","section","refs","n","filter","ref","undefined","name","from","band","background","align","nodes","line","icons","look","fonts","body","headings","google","buttonFill","buttonText","buttonRadius","header","aiSiteImportLayoutOf","layout","length","aiSiteImportSectionNames","named","names","slice","unique","attempt","toLowerCase","PATH_PARAMS","m","l","h","c","s","q","t","a","z","NUMBER","FLAG","round","value","fixed","Math","Object","is","String","aiSiteImportPathOn24","d","viewBox","box","split","Number","some","isFinite","minX","minY","width","height","scale","max","dx","dy","identity","abs","out","at","first","source","test","command","lower","count","relative","groups","group","pattern","lastIndex","match","exec","parts","absolute","x","y","position","part","join","shapeAttributes","matchAll","num","NaN","parseFloat","shapePath","tag","attributes","cx","cy","rx","ry","every","points","aiSiteImportIconPath","shape","svg","paths","OPEN_KINDS","FIXED_KINDS","BOXED_STYLES","OPEN_STYLES","LIKE_ITEMS_AS_CARDS","HERO_FOR","beside","behind","below","above","linkTo","scope","href","URL","protocol","origins","includes","origin","pathname","pathTo","get","toString","take","used","ratioText","ROUNDED_PX","pictureFitOf","photo","fit","assign","ratio","cropped","objectFit","radius","rounded","shadow","measure","keys","takePicture","photos","missing","alt","to","framed","src","COLORFUL_CHROMA","colorGap","b","ax","C","cos","PI","ay","sin","bx","by","hypot","L","HEX","brandish","hex","own","other","them","hue","min","aiSiteImportColorRole","use","tileInk","fill","color","light","ruleOf","rule","side","textBlocks","linkBlocks","style","items","lineBlocks","node","picture","button","film","role","chip","iconAt","itemLinkStyle","item","ctas","find","cta","itemOf","figure","image","badge","period","list","paragraphs","addLink","imageFit","more","icon","iconPath","mark","listIcon","listIconPath","tile","arrow","markPath","figureMuted","video","films","defaultStyle","pictured","boxed","drawnAs","itemsAlign","columnsSm","styleFor","asked","finish","fallback","likeItems","itemShape","size","FIGURE_MAX_CHARS","holdsOnlyFigures","lead","groupBlocks","answer","groupAt","improve","settled","what","columns","opens","answered","carded","joins","unfigured","linked","words","Boolean","quotes","_more","variant","nodeBlocks","row","videoBlocks","forms","entry","form","formId","formPlaced","cells","cell","byline","bylineOf","allowed","cols","weights","weight","col","rows","tableRow","tabs","tab","panelRow","mergeLists","panel","selected","filmPlaces","poster","videos","where","embed","host","hostname","filmsOf","Map","set","uploadDate","durationSeconds","firstFilm","found","BYLINE_MAX_WORDS","findIndex","reduce","total","small","READING_PARAGRAPHS","last","plain","DIMMED_HEROES","HEROES_AT","heroOf","drawn","hero","place","aiSiteImportFinishOf","aiSiteImportHeroMeasure","step","aiSiteImportDesignedSections","options","backdropOf","backdrop","pageFilm","given","reading","aiCompileImportedPage","input","compiled","targets","designed","compile","plan","reusableComponents","sectionIds","verbatim","design","language","cut","tree","dropped","lineRefs","placed","wordsOf","sectionRoots","videoIds","sourceWords","AI_SITE_IMPORT_DESIGN_MAX_CHARS","lineKind","counted","run","describeNodes","aiSiteImportDesignText","shows"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAwC2C,GAE3C,SACEA,mBAAmB,QAGd,2CAAuC;AAE9C,SACEC,sBAAsB,EAEtBC,kBAAkB,QAgBb,2CAAuC;AAE9C,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3K;YACF;gBACE;QACJ;IACF;IACA,OAAON;AACT;AAEA;;;;;CAKC,GACD,OAAO,SAASqQ,uBAAuBzX,GAA8D;IACnG,MAAMuD,SAASD,qBAAqBtD;IACpC,MAAM2D,QAAQF,yBAAyBzD;IACvC,OAAOuD,OAAOhC,QAAQ,CACnBO,GAAG,CAAC,CAACC,SAASJ;YAGiGI,mBAClFA;QAH5B,MAAM+E,SAAS;YAAEF,OAAO;QAAE;QAC1B,MAAM8Q,QAAQF,cAAcxX,KAAK+B,QAAQW,KAAK,EAAEoE;QAChD,MAAMvE,OAAOR,QAAQS,UAAU,KAAK,QAAQ,CAACT,QAAQ4T,QAAQ,GAAG,uBAAuB,GAAG5T,QAAQQ,IAAI,CAAC,KAAK,EAAER,EAAAA,oBAAAA,QAAQ4T,QAAQ,qBAAhB5T,kBAAkBrC,IAAI,MAAK,aAAa,qBAAqB,IAAI;QAC/K,MAAMyV,OAAOxT,UAAU,OAAKI,gBAAAA,QAAQoT,IAAI,qBAAZpT,cAAc+L,OAAO,IAAG,CAAC,8BAA8B,EAAE/L,QAAQoT,IAAI,CAACrH,OAAO,CAAC,UAAU,CAAC,GAAGnM,UAAU,IAAI,sCAAsC;QAC5K,OAAO,CAAC,QAAQ,EAAEA,QAAQ,EAAE,EAAE,EAAEgC,KAAK,CAAChC,MAAM,CAAC,GAAG,EAAEY,KAAK,EAAE,EAAER,QAAQU,KAAK,KAAK,WAAW,aAAa,yBAAyB0S,KAAK,UAAU,EAAErO,OAAOF,KAAK,CAAC,SAAS,EAAE0Q,QAAQI,OAAO,CAAC,CAAC;IAC1L,GACChQ,IAAI,CAAC;AACV"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-compile.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\n/*==========================================\n * A PAGE BROUGHT IN, BUILT BY THE SITE COMPILER (AGL-4107).\n *\n * On 10/29 an import of aglyn.com came out one column of plain lines: the\n * import drew its own stacked text instead of the site's cards, columns,\n * pictures, icons and bands. This module is the page's build now:\n *\n * 1. The source's LAYOUT, as the reader read it (`AiSiteImportPageRead.\n * layout`, AGL-4106) — its sections and bands, rows of columns, groups of\n * cards, steps, figures, questions, quotes, logos and plans, its tables,\n * tabs, pictures and icons — becomes the layout language the guided\n * start's compiler takes (`aiSiteImportDesignedSections`): a group is a\n * `cards` block whose items carry every part (icon, picture, figure,\n * paragraphs, bullet points, links), a table a `table` block, tabs a\n * `tabs` block. Every line is placed exactly once, in its own section; a\n * line the layout placed nowhere is added at its section's end.\n * 2. The site compiler draws it (`aiCompileLayoutPage`, `verbatim`), with\n * the palette's own elements and the theme's tokens: the Card, the\n * Accordion, the Table, the Tabs, the hero around the source's picture.\n * Every word is the source's, as written.\n * A video is the Video element where the source's film sat (AGL-4140),\n * poster first, playing from where the old page played it, and a button\n * whose words say it plays the film scrolls to it and presses play.\n * 3. A main page's DESIGN is the one question a model answers\n * (`submit_design`, `aiSiteImportDesignText`): which hero the opening\n * becomes, how each group is drawn, a band where the source gave none,\n * the kind of a group the reader could not tell, an alignment. A page of\n * a collection, and any page whose answer is missing, is drawn from the\n * layout with no model.\n * 4. How the owner asked the site FINISHED (AGL-4152). Keep my site, the\n * default for an import that asked nothing, is the above held tighter:\n * the source's alignment, its boxing and its heading's measure, whatever\n * the answer says. Improve it frees the layout: the answer's bands and\n * alignment on every section, the site's band rhythm, the theme's widths,\n * any hero, any group's kind and style, like runs of lines as cards.\n * Either way every word, picture, icon, button, heading, form and film\n * is the source's.\n *\n * A read made before the reader kept no layout: its page is read into one\n * here, from its lines, one section at each second-level heading.\n *=========================================*/\n\nimport {\n aiCompileLayoutPage,\n type AiLayoutCompiledPage,\n type AiLayoutPagePlan,\n} from '../layout-language/ai-layout-compiler'\nimport type { AiLayoutDesign } from '../layout-language/ai-layout-design'\nimport {\n AI_LAYOUT_GROUP_STYLES,\n AI_LAYOUT_IMPORT_HEROES,\n AI_LAYOUT_MAX_COLS,\n type AiLayoutBlock,\n type AiLayoutColorRole,\n type AiLayoutDesignAnswer,\n type AiLayoutDesignSection,\n type AiLayoutGroupStyle,\n type AiLayoutImportHero,\n type AiLayoutItem,\n type AiLayoutLink,\n type AiLayoutPicture,\n type AiLayoutPictureFit,\n type AiLayoutSection,\n type AiLayoutSettlement,\n type AiLayoutStyle,\n type AiLayoutVideo,\n type AiLayoutWidth,\n} from '../layout-language/ai-layout-language'\nimport type { AiLayoutTargets } from '../layout-language/ai-layout-links'\nimport {\n AI_SITE_IMPORT_LABEL_MAX_CHARS,\n SITE_IMPORT_PLAY_WORDS,\n siteImportFilmSource,\n siteImportWidthOf,\n type AiSiteImportPhoto,\n type SiteImportGroupKind,\n type SiteImportHeroPicture,\n type SiteImportIconShape,\n type SiteImportLayout,\n type SiteImportLayoutGroup,\n type SiteImportLayoutItem,\n type SiteImportLayoutLine,\n type SiteImportLayoutNode,\n type SiteImportLayoutSection,\n type SiteImportLayoutVideo,\n type SiteImportLineRef,\n type SiteImportLookFacts,\n type SiteImportPictureFit,\n type SiteImportRule,\n type AiSiteImportFinish,\n} from '../model/ai-site-import'\nimport { aiHexOklch } from '../model/ai-site-look'\nimport { aiModelAtLeastStepTier } from '../providers/routing'\nimport type { SiteImportBlock } from '../site-import/site-import-html'\nimport {\n AI_SITE_IMPORT_DOC_MAX_NODES,\n AI_SITE_IMPORT_LABEL_CHARS,\n aiSiteImportDocLines,\n aiSiteImportTextParts,\n aiSiteImportWordsIn,\n type AiSiteImportDocument,\n} from './ai-site-import-document'\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\n/** Whether a block is a line of the page: a link inside a sentence is in its sentence. */\nfunction isLine(block: SiteImportBlock | undefined): boolean {\n if (!block) return false\n if (block.kind === 'image') return !!block.url\n if (block.kind === 'link') return !block.inline && !!clean(block.text)\n return !!clean(block.text)\n}\n\n/*------------------------------------------\n * The page's job: its model and its links\n *-----------------------------------------*/\n\n/**\n * The model a page brought in asks its design answer on (AGL-4107): the page\n * step's own tier, balanced, whatever the deployment's default model is — the\n * job's own pick where it is that tier or above.\n */\nexport function aiImportPageModel(modelFor?: (kind: 'job.page') => string | undefined): string {\n return aiModelAtLeastStepTier('job.page', modelFor?.('job.page'))\n}\n\n/**\n * Every page the import plans that a page brought in may link (AGL-4107), by\n * the id its draft is written under: a link to one in a wave still to come\n * shows its words until that page is live, then goes there.\n */\nexport function aiSiteImportLinkablePages(doc: Pick<AiSiteImportDocument, 'links'> | null): Array<{ id: string; label: string; slug: string }> {\n if (!doc) return []\n const seen = new Set<string>()\n return doc.links.flatMap((link) => {\n if (seen.has(link.id)) return []\n seen.add(link.id)\n const path = link.path.replace(/\\/+$/, '') || '/'\n return [{ id: link.id, label: path, slug: path }]\n })\n}\n\n/**\n * The listing a page brought in keeps (AGL-4107): its source's own title and\n * description, word for word, never clipped and never rewritten — the 10/29\n * import's Home was retitled \"Aglyn: Build a Website with AI, Free to Start\".\n * Only a part the source left empty takes what was `written` for it.\n */\nexport function aiImportedPageListing(\n screen: { seoTitle: string; seoDescription: string },\n written: { title?: string; description?: string } = {},\n): { title: string; description: string } {\n return {\n title: screen.seoTitle.trim() || (written.title ?? '').trim(),\n description: screen.seoDescription.trim() || (written.description ?? '').trim(),\n }\n}\n\n/** Whether a page brought in still owes a part of its listing: one its source left empty. */\nexport function aiImportedPageListingOwed(listing: { title: string; description: string }): boolean {\n return !listing.title || !listing.description\n}\n\n/*------------------------------------------\n * The layout a page is built from\n *-----------------------------------------*/\n\n/**\n * The layout of a page whose read kept none (AGL-4107): its lines in their\n * sections — the opening, then one at each second-level heading — each line\n * where the source put it, in order.\n */\nexport function aiSiteImportLayoutOfLines(doc: Pick<AiSiteImportDocument, 'blocks' | 'title'>): SiteImportLayout {\n const { lines, sections } = aiSiteImportDocLines(doc.blocks, doc.title)\n // The document's lines are numbered over the page's lines; the layout's are indexes of its blocks.\n const refOf: number[] = []\n doc.blocks.forEach((block, index) => {\n if (isLine(block)) refOf.push(index)\n })\n return {\n v: 1,\n sections: sections.map((section, index) => {\n const refs = section.lines.map((n) => refOf[n - 1]).filter((ref): ref is number => ref !== undefined)\n return {\n name: section.name,\n from: 'heading' as const,\n band: index % 2 === 1 ? ('soft' as const) : ('plain' as const),\n background: null,\n align: 'start' as const,\n nodes: refs.map((ref): SiteImportLayoutNode => (doc.blocks[ref]?.kind === 'image' ? { kind: 'picture', line: ref } : { kind: 'line', line: ref })),\n lines: refs,\n }\n }),\n icons: [],\n look: { fonts: { body: null, headings: null, google: [] }, background: null, text: null, buttonFill: null, buttonText: null, buttonRadius: null, link: null, header: null },\n }\n}\n\n/** The layout a page is built from: the reader's, else one read from its lines. */\nexport function aiSiteImportLayoutOf(doc: Pick<AiSiteImportDocument, 'blocks' | 'title' | 'layout'>): SiteImportLayout {\n return doc.layout && doc.layout.sections.length ? doc.layout : aiSiteImportLayoutOfLines(doc)\n}\n\n/**\n * The page's sections by name, in order (AGL-4107): the source's own, as its\n * layout names them — its `aria-label`s, its headings — two of one name told\n * apart, so a link to either finds it. The page's plan has exactly these.\n */\nexport function aiSiteImportSectionNames(doc: Pick<AiSiteImportDocument, 'blocks' | 'title' | 'layout'>): string[] {\n const named = new Set<string>()\n const names = aiSiteImportLayoutOf(doc).sections.map((section, index) => {\n const name = clean(section.name).slice(0, AI_SITE_IMPORT_LABEL_MAX_CHARS) || `Section ${index + 1}`\n let unique = name\n for (let attempt = 2; named.has(unique.toLowerCase()); attempt += 1) {\n unique = `${name.slice(0, AI_SITE_IMPORT_LABEL_MAX_CHARS - 5)} (${attempt})`\n }\n named.add(unique.toLowerCase())\n return unique\n })\n return names.length ? names : ['Introduction']\n}\n\n/*------------------------------------------\n * The source's icons, on the icon element's square\n *-----------------------------------------*/\n\n/** How many numbers each path command takes, by its lower-case letter. */\nconst PATH_PARAMS: Readonly<Record<string, number>> = { m: 2, l: 2, h: 1, v: 1, c: 6, s: 4, q: 4, t: 2, a: 7, z: 0 }\n\nconst NUMBER = /[\\s,]*([-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)/y\nconst FLAG = /[\\s,]*([01])/y\n\n/** A number of a path, at most three decimals, as short as it reads. */\nconst round = (value: number): string => {\n const fixed = Math.round(value * 1000) / 1000\n return Object.is(fixed, -0) ? '0' : String(fixed)\n}\n\n/**\n * A path's drawing moved onto the icon element's 24-unit square (AGL-4107):\n * every coordinate scaled from its viewBox and centered, every relative move\n * scaled alone, an arc's radii scaled and its flags and rotation kept.\n * `null` for anything that is not path data.\n */\nexport function aiSiteImportPathOn24(d: string, viewBox: string): string | null {\n const box = viewBox.trim().split(/[\\s,]+/).map(Number)\n if (box.length !== 4 || box.some((value) => !Number.isFinite(value)) || box[2] <= 0 || box[3] <= 0) return null\n const [minX, minY, width, height] = box\n const scale = 24 / Math.max(width, height)\n const dx = (24 - width * scale) / 2 - minX * scale\n const dy = (24 - height * scale) / 2 - minY * scale\n const identity = Math.abs(scale - 1) < 1e-9 && Math.abs(dx) < 1e-9 && Math.abs(dy) < 1e-9\n const out: string[] = []\n let at = 0\n let first = true\n const source = d.trim()\n while (at < source.length) {\n while (at < source.length && /[\\s,]/.test(source[at])) at += 1\n if (at >= source.length) break\n const command = source[at]\n const lower = command.toLowerCase()\n if (!(lower in PATH_PARAMS)) return null\n at += 1\n const count = PATH_PARAMS[lower]\n const relative = command === lower\n const groups: number[][] = []\n if (count === 0) {\n out.push(command)\n first = false\n continue\n }\n for (;;) {\n const group: number[] = []\n for (let index = 0; index < count; index += 1) {\n const pattern = lower === 'a' && (index === 3 || index === 4) ? FLAG : NUMBER\n pattern.lastIndex = at\n const match = pattern.exec(source)\n if (!match) break\n group.push(Number(match[1]))\n at = pattern.lastIndex\n }\n if (group.length === 0) break\n if (group.length !== count) return null\n groups.push(group)\n }\n if (!groups.length) return null\n const parts = groups.map((group, index) => {\n // A path that opens on a relative move opens at that point, as an absolute one would.\n const absolute = !relative || (first && lower === 'm' && index === 0)\n const x = (value: number) => (absolute ? value * scale + dx : value * scale)\n const y = (value: number) => (absolute ? value * scale + dy : value * scale)\n switch (lower) {\n case 'h':\n return [x(group[0])]\n case 'v':\n return [y(group[0])]\n case 'a':\n return [group[0] * scale, group[1] * scale, group[2], group[3], group[4], x(group[5]), y(group[6])]\n default:\n return group.map((value, position) => (position % 2 === 0 ? x(value) : y(value)))\n }\n })\n out.push(`${command}${parts.map((part) => part.map(round).join(' ')).join(' ')}`)\n first = false\n }\n if (!out.length || !/^[Mm]/.test(out[0])) return null\n return identity ? source : out.join('')\n}\n\n/** The attributes of a shape in a reader's cleaned drawing. */\nfunction shapeAttributes(source: string): Record<string, string> {\n const out: Record<string, string> = {}\n for (const match of source.matchAll(/([a-zA-Z-]+)=\"([^\"]*)\"/g)) out[match[1].toLowerCase()] = match[2]\n return out\n}\n\nconst num = (value: string | undefined): number => (value === undefined ? Number.NaN : Number.parseFloat(value))\n\n/** A shape of a drawing as path data, or `null` for one that is only a stroke or is moved by a transform. */\nfunction shapePath(tag: string, attributes: Record<string, string>): string | null {\n if (attributes['transform'] || attributes['fill'] === 'none') return null\n switch (tag) {\n case 'path':\n return attributes['d']?.trim() || null\n case 'circle':\n case 'ellipse': {\n const cx = num(attributes['cx'] ?? '0')\n const cy = num(attributes['cy'] ?? '0')\n const rx = tag === 'circle' ? num(attributes['r']) : num(attributes['rx'])\n const ry = tag === 'circle' ? rx : num(attributes['ry'])\n if (![cx, cy, rx, ry].every(Number.isFinite) || rx <= 0 || ry <= 0) return null\n return `M${cx - rx} ${cy}A${rx} ${ry} 0 1 0 ${cx + rx} ${cy}A${rx} ${ry} 0 1 0 ${cx - rx} ${cy}Z`\n }\n case 'rect': {\n const x = num(attributes['x'] ?? '0')\n const y = num(attributes['y'] ?? '0')\n const width = num(attributes['width'])\n const height = num(attributes['height'])\n if (![x, y, width, height].every(Number.isFinite) || width <= 0 || height <= 0) return null\n return `M${x} ${y}H${x + width}V${y + height}H${x}Z`\n }\n case 'polygon': {\n const points = (attributes['points'] ?? '').trim().split(/[\\s,]+/).map(Number)\n if (points.length < 4 || points.length % 2 || points.some((value) => !Number.isFinite(value))) return null\n return `M${points.slice(0, 2).join(' ')}L${points.slice(2).join(' ')}Z`\n }\n default:\n // A line or an open polyline is a stroke: filled, it draws nothing.\n return null\n }\n}\n\n/**\n * The source's icon as the icon element draws one (AGL-4107): one path on its\n * 24-unit square. A one-path icon is its path, moved onto the square; a small\n * drawing of several filled shapes is their paths together. A drawing made of\n * strokes, or of shapes a transform moves, has no one path, and is left out:\n * an icon is no word of the page.\n */\nexport function aiSiteImportIconPath(shape: SiteImportIconShape | undefined): string | null {\n if (!shape) return null\n if (shape.path) return aiSiteImportPathOn24(shape.path, shape.viewBox)\n if (!shape.svg) return null\n const paths: string[] = []\n for (const match of shape.svg.matchAll(/<(path|circle|ellipse|rect|polygon|polyline|line)\\b([^>]*)\\/?>/gi)) {\n const path = shapePath(match[1].toLowerCase(), shapeAttributes(match[2]))\n if (!path) return null\n paths.push(path)\n }\n return paths.length ? aiSiteImportPathOn24(paths.join(''), shape.viewBox) : null\n}\n\n/*------------------------------------------\n * The layout in the layout language\n *-----------------------------------------*/\n\n/** The groups a design answer may read as another kind: the ones whose kind the reader told by their shape alone. */\nconst OPEN_KINDS: ReadonlySet<SiteImportGroupKind> = new Set(['cards', 'steps', 'stats', 'list', 'text'])\n\n/**\n * The groups that keep their kind even on a page its owner asked improved\n * (AGL-4152): a quote's words and a strip of logos have no place in a card's\n * title or a step's, and would stop being what they are; questions and\n * answers stay questions a visitor opens, and plans stay plan cards. The 11/4\n * eval's answers redrew five pages' questions as cards.\n */\nconst FIXED_KINDS: ReadonlySet<SiteImportGroupKind> = new Set(['quotes', 'logos', 'faq', 'pricing'])\n\n/** The styles that box a group's items, and the ones that leave them open: Keep my site keeps a group's own (AGL-4152). */\nconst BOXED_STYLES: ReadonlySet<AiLayoutGroupStyle> = new Set(['cards', 'articles'])\nconst OPEN_STYLES: ReadonlySet<AiLayoutGroupStyle> = new Set(['ruled', 'icons', 'pictures'])\n\n/** The fewest like items a run of lines needs to be drawn as cards, on a page its owner asked improved (AGL-4152). */\nconst LIKE_ITEMS_AS_CARDS = 3\n\n/** The hero each place of the source's picture opens as, where no answer chose one. */\nconst HERO_FOR: Readonly<Record<SiteImportHeroPicture, AiLayoutImportHero>> = {\n beside: 'split',\n behind: 'cover',\n below: 'column',\n above: 'column',\n}\n\n/**\n * The source's own opening as a hero (AGL-4152): its picture's place, refined\n * by how it sets its words. Over or under a picture, a centered column or a\n * start-aligned editorial; behind them, a poster or a cover; beside them, a split.\n */\nfunction ownHeroOf(section: Pick<SiteImportLayoutSection, 'align'>, place: SiteImportHeroPicture): AiLayoutImportHero {\n if (place === 'beside') return 'split'\n if (place === 'behind') return section.align === 'center' ? 'poster' : 'cover'\n return section.align === 'center' ? 'column' : 'editorial'\n}\n\ninterface MapScope {\n doc: AiSiteImportDocument\n layout: SiteImportLayout\n /** Lines taken into a block, by index of the page's blocks. */\n used: Set<number>\n /** Pictures the library could not hold, which a page leaves out. */\n missing: Set<number>\n photos: ReadonlyMap<string, AiSiteImportPhoto>\n pathTo: ReadonlyMap<string, string>\n /** The site's saved form a page brought in places where its source had one. */\n formId: string | null\n formPlaced: boolean\n /** The section being mapped: its design answer, and how many of its groups have been met. */\n answer: AiLayoutDesignSection | null\n groupAt: number\n settled: AiLayoutSettlement[]\n at: string\n /** The page's films the Video element plays, by their index (AGL-4140). */\n films: ReadonlyMap<number, AiLayoutVideo>\n /** The film a play button of this section plays: the section's own first, else the page's. */\n film: number | null\n /** How the owner asked the page finished (AGL-4152): kept as its source lays it out, or improved. */\n finish: AiSiteImportFinish\n}\n\n/** Where a link of the source goes on the new site, in the compiler's words; `undefined` where it can go nowhere a page may send a visitor. */\nfunction linkTo(scope: Pick<MapScope, 'doc' | 'pathTo'>, href: string | undefined): string | undefined {\n const value = (href ?? '').trim()\n if (/^mailto:[^\\s@]+@[^\\s@]+$/i.test(value) || /^tel:\\+?[\\d\\s().-]{3,}$/i.test(value)) return value\n let url: URL\n try {\n url = new URL(value)\n } catch {\n return undefined\n }\n if (url.protocol !== 'https:' && url.protocol !== 'http:') return undefined\n if (scope.doc.origins.includes(url.origin)) {\n // The old site's own page: the page it becomes, any page the import plans\n // (AGL-4107), which a visitor reaches once it is live.\n const path = url.pathname.replace(/\\/+$/, '') || '/'\n const id = scope.pathTo.get(path)\n return id ? `page:${id}` : undefined\n }\n return url.protocol === 'https:' ? url.toString() : undefined\n}\n\n/** A line's words, as written; marks it taken. */\nfunction take(scope: MapScope, ref: SiteImportLineRef | undefined): string {\n if (ref === undefined || scope.used.has(ref)) return ''\n const block = scope.doc.blocks[ref]\n if (!isLine(block)) return ''\n scope.used.add(ref)\n return block.kind === 'image' ? '' : clean(block.text)\n}\n\n/** A width over a height as `aspect-ratio` writes it: \"1600 / 900\", or \"1.7778\" for a ratio alone. */\nfunction ratioText(width: number, height = 1): string {\n const round = (value: number) => String(Math.round(value * 10_000) / 10_000)\n return height === 1 ? round(width) : `${round(width)} / ${round(height)}`\n}\n\n/** The radius past which a source's picture reads as rounded (AGL-4138), not merely softened: 10 px. */\nconst ROUNDED_PX = 10\n\n/**\n * How a picture of a page brought in is framed (AGL-4138): at the box the\n * source crops it to, where it sets one, else at the picture's own shape —\n * the library's copy's size first, its `width` and `height` second — so a\n * frame of its own shape, filled, cuts nothing off; its fit, and the\n * source's rounded corners and shadow. A round portrait is the byline's.\n */\nfunction pictureFitOf(photo: AiSiteImportPhoto, fit: SiteImportPictureFit | undefined): AiLayoutPictureFit | undefined {\n const out: AiLayoutPictureFit = {}\n if (fit?.box) Object.assign(out, { ratio: ratioText(fit.box), cropped: true as const })\n else if (fit?.height) Object.assign(out, { height: Math.round(fit.height), cropped: true as const })\n else if (photo.width && photo.height) out.ratio = ratioText(photo.width, photo.height)\n else if (fit?.ratio) out.ratio = ratioText(fit.ratio)\n if (fit?.objectFit) out.objectFit = fit.objectFit\n if (fit?.radius !== undefined && fit.radius >= ROUNDED_PX && fit.radius < 999) out.rounded = true\n if (fit?.shadow) out.shadow = true\n // The width the source holds it to, as the theme's breakpoint nearest it; the widest is no hold at all.\n const measure = siteImportWidthOf(fit?.measure)\n if (measure && measure !== 'xl') out.measure = measure\n return Object.keys(out).length ? out : undefined\n}\n\n/** A picture line as the library holds it; marks it taken, and missing where the library holds none. */\nfunction takePicture(scope: MapScope, ref: SiteImportLineRef | undefined, href?: string, fit?: SiteImportPictureFit): AiLayoutPicture | null {\n if (ref === undefined || scope.used.has(ref)) return null\n const block = scope.doc.blocks[ref]\n if (!block || block.kind !== 'image') return null\n scope.used.add(ref)\n const photo = scope.photos.get(block.url)\n if (!photo) {\n scope.missing.add(ref)\n return null\n }\n const alt = clean(block.alt || photo.alt || '').slice(0, 200)\n const ratio = photo.width && photo.height ? photo.width / photo.height : 0\n const to = linkTo(scope, href)\n const framed = pictureFitOf(photo, fit)\n return { src: photo.src, alt, ...(ratio > 0 ? { ratio } : {}), ...(to ? { to } : {}), ...(framed ? { fit: framed } : {}) }\n}\n\n/*------------------------------------------\n * The source's colors as the theme's roles (AGL-4138)\n *-----------------------------------------*/\n\n/** How colorful a color must be to be a color, not a grey. */\nconst COLORFUL_CHROMA = 0.04\n\n/** How far apart two colors look, in OKLab. */\nfunction colorGap(a: string, b: string): number {\n const [x, y] = [aiHexOklch(a), aiHexOklch(b)]\n const ax = x.C * Math.cos((x.h * Math.PI) / 180)\n const ay = x.C * Math.sin((x.h * Math.PI) / 180)\n const bx = y.C * Math.cos((y.h * Math.PI) / 180)\n const by = y.C * Math.sin((y.h * Math.PI) / 180)\n return Math.hypot(x.L - y.L, ax - bx, ay - by)\n}\n\nconst HEX = /^#[0-9a-f]{6}$/i\n\n/** Whether a colorful color is the brand's: the source's buttons' fill or its links' color, by its look or its hue. */\nfunction brandish(hex: string, look: Pick<SiteImportLookFacts, 'buttonFill' | 'link'> | null | undefined): boolean {\n const own = aiHexOklch(hex)\n return [look?.buttonFill, look?.link].some((other) => {\n if (!other || !HEX.test(other)) return false\n const them = aiHexOklch(other)\n if (them.C < COLORFUL_CHROMA) return false\n const hue = Math.abs(own.h - them.h) % 360\n return colorGap(hex, other) <= 0.1 || Math.min(hue, 360 - hue) <= 25\n })\n}\n\n/**\n * A source's own color as the theme role a page brought in draws it in\n * (AGL-4138), so no value is ever written onto an element: the brand's\n * colors as `primary`, any other color as the theme's third, which the look\n * pins to the source's eyebrows' (`aiSiteImportStyle`); a grey as the words'\n * ink or their muted shade, or as the divider for a rule; a light fill as the\n * theme's tint. `null` where no role is the color's: white words on a dark\n * band take the band's own.\n */\nexport function aiSiteImportColorRole(hex: string | null | undefined, look: Pick<SiteImportLookFacts, 'buttonFill' | 'link'> | null | undefined, use: 'ink' | 'fill' | 'rule'): AiLayoutColorRole | null {\n if (!hex || !HEX.test(hex)) return null\n const own = aiHexOklch(hex)\n if (use === 'fill' && own.L >= 0.9) return 'action.hover'\n if (own.C < COLORFUL_CHROMA) {\n if (use === 'rule') return 'divider'\n if (use === 'fill' || own.L >= 0.9) return null\n return own.L <= 0.35 ? 'text.primary' : 'text.secondary'\n }\n return brandish(hex, look) ? 'primary.main' : 'tertiary.main'\n}\n\n/** An icon's color in a tile: the fill's own contrast where the icon is a light one on a strong fill. */\nfunction tileInk(fill: AiLayoutColorRole, color: string | null, look: SiteImportLookFacts): AiLayoutColorRole | null {\n const light = !!color && HEX.test(color) && aiHexOklch(color).L >= 0.9\n if (light && fill === 'primary.main') return 'primary.contrastText'\n if (light && fill === 'tertiary.main') return 'tertiary.contrastText'\n return aiSiteImportColorRole(color, look, 'ink')\n}\n\n/** A group's rule as the compiler draws it: its side, its width in the theme's border steps, its color's role. */\nfunction ruleOf(rule: SiteImportRule, look: SiteImportLookFacts): NonNullable<AiLayoutBlock['rule']> {\n const width = rule.width >= 3 ? 3 : rule.width === 2 ? 2 : 1\n return { side: rule.side, width, color: aiSiteImportColorRole(rule.color, look, 'rule') }\n}\n\n/** Words as text blocks, a paragraph longer than a text element holds split between its sentences. */\nfunction textBlocks(kind: 'text' | 'lede' | 'note', text: string): AiLayoutBlock[] {\n return aiSiteImportTextParts(text).map((part) => ({ kind, text: part }))\n}\n\n/** A link of the source: a button where its words fit one, a link in a list where they run longer, its words where it goes nowhere. */\nfunction linkBlocks(scope: MapScope, text: string, href: string, style: AiLayoutStyle): AiLayoutBlock[] {\n const to = linkTo(scope, href)\n if (text.length <= AI_SITE_IMPORT_LABEL_CHARS) return [{ kind: 'button', text, ...(to ? { to } : {}), style }]\n if (to) return [{ kind: 'list', items: [{ title: text, text: '', to }] }]\n return textBlocks('text', text)\n}\n\n/** One line in place, as the kind of block its source and its role say. */\nfunction lineBlocks(scope: MapScope, node: SiteImportLayoutLine): AiLayoutBlock[] {\n const block = scope.doc.blocks[node.line]\n if (!block || scope.used.has(node.line)) return []\n if (block.kind === 'image') {\n const picture = takePicture(scope, node.line)\n return picture ? [{ kind: 'image', picture }] : []\n }\n const text = take(scope, node.line)\n if (!text) return []\n switch (block.kind) {\n case 'heading':\n return [{ kind: 'heading', text }]\n case 'link':\n return linkBlocks(scope, text, block.href, node.button ?? 'quiet')\n case 'list-item':\n return [{ kind: 'list', items: [{ title: text, text: '' }] }]\n case 'quote':\n return [{ kind: 'quotes', style: 'quiet', items: [{ title: '', text }] }]\n default: {\n // A button whose words say it plays a film plays the section's film, else the page's (AGL-4140).\n if (node.button && scope.film !== null && SITE_IMPORT_PLAY_WORDS.test(text) && text.length <= AI_SITE_IMPORT_LABEL_CHARS) {\n return [{ kind: 'button', text, style: node.button, to: `video:${scope.film}` }]\n }\n if (node.role === 'eyebrow') {\n // In its own pill and its own color, as the source sets it (AGL-4138).\n const color = aiSiteImportColorRole(node.color, scope.layout.look, 'ink')\n return [{ kind: 'eyebrow', text, ...(node.chip ? { chip: true as const } : {}), ...(color ? { color } : {}) }]\n }\n // A statement is a lede set large (AGL-4138), split as any text is between its sentences where it runs long.\n if (node.role === 'statement') return textBlocks('lede', text).map((block) => ({ ...block, style: 'large' as const }))\n return textBlocks(node.role === 'lede' ? 'lede' : node.role === 'note' ? 'note' : 'text', text)\n }\n }\n}\n\n/** The icon a group item or a bullet carries, by its index into the page's icons. */\nfunction iconAt(scope: MapScope, index: number | undefined): string | undefined {\n return index === undefined ? undefined : (aiSiteImportIconPath(scope.layout.icons[index]) ?? undefined)\n}\n\n/** The style of a link inside an item: as the source draws it, else a plan's own button outlined and any other a quiet link. */\nfunction itemLinkStyle(group: SiteImportLayoutGroup, item: SiteImportLayoutItem, ref: SiteImportLineRef): AiLayoutStyle {\n return item.ctas?.find((cta) => cta.line === ref)?.style ?? (group.group === 'pricing' ? 'secondary' : 'quiet')\n}\n\n/** One item of a group, drawn as `kind`, every line of it in exactly one of its parts. */\nfunction itemOf(scope: MapScope, group: SiteImportLayoutGroup, item: SiteImportLayoutItem, kind: SiteImportGroupKind = group.group): AiLayoutItem {\n const out: AiLayoutItem = { title: '', text: '' }\n const named = new Set<number>([\n ...(item.title !== undefined ? [item.title] : []),\n ...(item.figure !== undefined ? [item.figure] : []),\n ...(item.image !== undefined ? [item.image] : []),\n ...(item.badge !== undefined ? [item.badge] : []),\n ...(item.period !== undefined ? [item.period] : []),\n ...(item.text ?? []),\n ...(item.list ?? []),\n ...(item.link ?? []),\n ])\n const paragraphs: string[] = []\n const links: AiLayoutLink[] = []\n const addLink = (ref: number) => {\n const block = scope.doc.blocks[ref]\n const text = take(scope, ref)\n if (!text) return\n const to = block?.kind === 'link' ? linkTo(scope, block.href) : undefined\n if (text.length <= AI_SITE_IMPORT_LABEL_CHARS) links.push({ text, ...(to ? { to } : {}), style: itemLinkStyle(group, item, ref) })\n else paragraphs.push(text)\n }\n // The item's lines in the source's order: each where its part says.\n for (const ref of item.lines) {\n if (scope.used.has(ref)) continue\n const block = scope.doc.blocks[ref]\n if (!block) continue\n if (ref === item.title) out.title = take(scope, ref)\n else if (ref === item.figure) out.figure = take(scope, ref)\n else if (ref === item.period) out.period = take(scope, ref)\n // A figure stands alone: its tag, if it has one, is among its words.\n else if (ref === item.badge && kind !== 'stats') out.badge = take(scope, ref)\n else if (ref === item.image || (block.kind === 'image' && !named.has(ref))) {\n const picture = takePicture(scope, ref, undefined, ref === item.image ? item.imageFit : undefined)\n if (picture && !out.picture) out.picture = picture\n } else if (item.list?.includes(ref)) {\n const line = take(scope, ref)\n if (line) out.list = [...(out.list ?? []), line]\n } else if (item.link?.includes(ref) || (block.kind === 'link' && (!named.has(ref) || clean(block.text).length <= AI_SITE_IMPORT_LABEL_CHARS))) addLink(ref)\n else {\n const line = take(scope, ref)\n if (line) paragraphs.push(...aiSiteImportTextParts(line))\n }\n }\n if (paragraphs.length) out.text = paragraphs[0]\n if (paragraphs.length > 1) out.more = paragraphs.slice(1)\n if (links.length) out.links = links\n // A row's name is a heading only where the source says so.\n if (group.inline && item.title !== undefined && scope.doc.blocks[item.title]?.kind !== 'heading') out.label = true\n const icon = iconAt(scope, item.icon)\n if (icon) out.iconPath = icon\n const mark = iconAt(scope, item.listIcon)\n if (mark && out.list?.length) out.listIconPath = mark\n // Its icon's square and its arrow, as the source draws them (AGL-4138).\n const fill = icon && item.tile ? aiSiteImportColorRole(item.tile.fill, scope.layout.look, 'fill') : null\n if (fill && item.tile) out.tile = { fill, color: tileInk(fill, item.tile.color, scope.layout.look) }\n const arrow = iconAt(scope, item.mark)\n if (arrow) out.markPath = arrow\n if (item.figureMuted && out.figure) out.figureMuted = true\n // A film the item holds plays from its poster (AGL-4140), and the item is no link around it.\n const film = item.video !== undefined ? scope.films.get(item.video) : undefined\n if (film && out.picture) {\n out.picture = { ...out.picture, video: film }\n return out\n }\n const to = linkTo(scope, item.to)\n if (to) out.to = to\n return out\n}\n\n/** The style a group of cards is drawn in where its design answer chose none: the source's own box, its rule, icons or pictures. */\nfunction defaultStyle(group: SiteImportLayoutGroup, items: readonly AiLayoutItem[]): AiLayoutGroupStyle {\n const pictured = items.length > 0 && items.every((item) => item.picture)\n if (pictured) return group.boxed ? 'articles' : 'pictures'\n if (group.boxed) return 'cards'\n // A rule along each item, a step's line over its number, is no box (AGL-4138).\n if (group.rule) return 'ruled'\n return items.length > 0 && items.every((item) => item.iconPath) ? 'icons' : 'ruled'\n}\n\n/** What a group of a page brought in carries of how its source draws it (AGL-4138): its items' own alignment, its tablet columns, its rule when it is drawn ruled. */\nfunction drawnAs(scope: MapScope, group: SiteImportLayoutGroup, style?: AiLayoutGroupStyle): Pick<AiLayoutBlock, 'itemsAlign' | 'columnsSm' | 'rule'> {\n return {\n ...(group.align ? { itemsAlign: group.align } : {}),\n ...(group.columnsSm ? { columnsSm: group.columnsSm } : {}),\n ...(style === 'ruled' && group.rule ? { rule: ruleOf(group.rule, scope.layout.look) } : {}),\n }\n}\n\n/**\n * The style an answer chose, where the group can be drawn so: pictures need a\n * picture on every item, icons an icon. A page kept as it is keeps the\n * source's boxing (AGL-4152): a boxed group takes only a boxed style, an open\n * one only an open style.\n */\nfunction styleFor(asked: AiLayoutGroupStyle | undefined, group: SiteImportLayoutGroup, items: readonly AiLayoutItem[], finish: AiSiteImportFinish): AiLayoutGroupStyle {\n const fallback = defaultStyle(group, items)\n if (!asked || !(AI_LAYOUT_GROUP_STYLES as readonly string[]).includes(asked)) return fallback\n if (finish !== 'improve' && !(group.boxed ? BOXED_STYLES : OPEN_STYLES).has(asked)) return fallback\n if ((asked === 'pictures' || asked === 'articles') && !items.every((item) => item.picture)) return fallback\n if (asked === 'icons' && !items.every((item) => item.iconPath)) return fallback\n return asked\n}\n\n/**\n * Whether a run of lines that only share a shape reads as cards (AGL-4152):\n * three or more items, each showing the same parts and led by its own title,\n * with no heading among an item's lines but its title, so every heading of\n * the source is still a heading.\n */\nfunction likeItems(scope: MapScope, group: SiteImportLayoutGroup): boolean {\n if (group.items.length < LIKE_ITEMS_AS_CARDS) return false\n if (new Set(group.items.map((item) => itemShape(item).join(' + '))).size !== 1) return false\n return group.items.every((item) => item.title !== undefined && item.lines.every((ref) => ref === item.title || scope.doc.blocks[ref]?.kind !== 'heading'))\n}\n\n/** The longest line that leads a figure: \"1-click\", \"$0.83\". */\nconst FIGURE_MAX_CHARS = 14\n\n/**\n * Whether a group can be drawn as figures (AGL-4083): each item a short line\n * over its label and nothing else. A figure has no place for a link, a bullet,\n * a picture or an icon, so an item with one, drawn as a figure, loses it.\n */\nfunction holdsOnlyFigures(scope: MapScope, group: SiteImportLayoutGroup): boolean {\n return group.items.every((item) => {\n const lead = item.title ?? item.lines[0]\n const block = lead === undefined ? undefined : scope.doc.blocks[lead]\n return (\n !!block &&\n block.kind !== 'image' &&\n clean(block.text).length <= FIGURE_MAX_CHARS &&\n item.lines.length <= 3 &&\n !item.link?.length &&\n !item.list?.length &&\n item.image === undefined &&\n item.icon === undefined &&\n !item.lines.some((ref) => scope.doc.blocks[ref]?.kind === 'link' || scope.doc.blocks[ref]?.kind === 'image')\n )\n })\n}\n\n/** A group of the source, in the layout language: every item of it, in the kind and style its answer chose or its source shows. */\nfunction groupBlocks(scope: MapScope, group: SiteImportLayoutGroup): AiLayoutBlock[] {\n const answer = scope.answer?.groups[scope.groupAt] ?? null\n scope.groupAt += 1\n const improve = scope.finish === 'improve'\n // Rows the source sets are drawn as its rows: no answer's kind or style is one of them (AGL-4083). On a\n // page its owner asked improved, a kind the answer names is (AGL-4152); a style alone has nothing to draw in rows.\n if (group.inline && !(improve && answer?.kind)) {\n if (answer?.kind || answer?.style) scope.settled.push({ at: scope.at, what: `a ${group.group} group drawn as the source's rows` })\n return [{ kind: 'cards', items: group.items.map((item) => itemOf(scope, group, item)), columns: 1, inline: true }]\n }\n // A page its owner asked improved reads any group as the answer does (AGL-4152), but a quote, a logo, a question or a plan.\n const opens = improve ? !FIXED_KINDS.has(group.group) : OPEN_KINDS.has(group.group)\n const answered: SiteImportGroupKind = answer?.kind && opens ? answer.kind : group.group\n // Lines that only share a shape, three or more alike, are cards on a page its owner asked improved (AGL-4152).\n const carded = improve && answered === 'text' && likeItems(scope, group)\n if (carded) scope.settled.push({ at: scope.at, what: `${group.items.length} like runs of lines drawn as cards` })\n const asked: SiteImportGroupKind = carded ? 'cards' : answered\n // A list is one line an item (AGL-4083): one asked of items with more would\n // join a label to its value, and 49 of a plan's rows lost theirs so on 11/1.\n const joins = asked === 'list' && group.group !== 'list' && group.items.some((item) => item.lines.length > 1)\n const unfigured = asked === 'stats' && group.group !== 'stats' && !holdsOnlyFigures(scope, group)\n const kind: SiteImportGroupKind = joins ? 'cards' : unfigured ? group.group : asked\n if (joins) scope.settled.push({ at: scope.at, what: `a ${group.group} group kept apart: its items hold more than one line each, so it is no list` })\n else if (unfigured) scope.settled.push({ at: scope.at, what: `a ${group.group} group kept as it is: its items hold more than a figure can show` })\n else if (kind !== group.group && !carded) scope.settled.push({ at: scope.at, what: `a ${group.group} group drawn as ${kind}, as its design answer read it` })\n const columns = Math.max(1, Math.min(AI_LAYOUT_MAX_COLS, group.columns || 1))\n if (kind === 'text') {\n // Lines that only share a shape: each where it stands.\n return group.items.flatMap((item) => item.lines.flatMap((ref) => lineBlocks(scope, { kind: 'line', line: ref })))\n }\n if (kind === 'list') {\n const items = group.items.flatMap((item): AiLayoutItem[] => {\n const linked = item.lines.map((ref) => scope.doc.blocks[ref]).find((block) => block?.kind === 'link')\n const words = item.lines.map((ref) => take(scope, ref)).filter(Boolean).join(' ')\n for (const ref of item.lines) {\n if (scope.doc.blocks[ref]?.kind === 'image') takePicture(scope, ref)\n }\n if (!words) return []\n const icon = iconAt(scope, item.icon)\n const to = linkTo(scope, item.to ?? (linked?.kind === 'link' ? linked.href : undefined))\n return [{ title: words, text: '', ...(icon ? { iconPath: icon } : {}), ...(to ? { to } : {}) }]\n })\n return items.length ? [{ kind: 'list', items, columns }] : []\n }\n if (kind === 'logos') {\n const items = group.items.flatMap((item): AiLayoutItem[] => {\n let picture: AiLayoutPicture | null = null\n const words: string[] = []\n for (const ref of item.lines) {\n if (scope.doc.blocks[ref]?.kind === 'image') picture = picture ?? takePicture(scope, ref)\n else {\n const line = take(scope, ref)\n if (line) words.push(line)\n }\n }\n if (picture && !words.length) return [{ title: '', text: '', picture }]\n // A strip of linked tags keeps its links (AGL-4138): a blog's categories go to their pages.\n const to = picture ? undefined : linkTo(scope, item.to)\n return words.length ? [{ title: words.join(' '), text: '', ...(picture ? { picture } : {}), ...(to ? { to } : {}) }] : picture ? [{ title: '', text: '', picture }] : []\n })\n return items.length ? [{ kind: 'logos', items }] : []\n }\n const items = group.items.map((item) => itemOf(scope, group, item, kind))\n // Whether the items are boxed: the source's, or on a page its owner asked improved, the answer's style (AGL-4152).\n const boxed = improve && answer?.style ? BOXED_STYLES.has(answer.style) : group.boxed\n if (kind === 'quotes') {\n // The reader names a quote's words its title and who said it its text.\n const quotes = items.map((item) => ({ ...item, title: [item.text, ...(item.more ?? [])].filter(Boolean).join(' '), text: item.title, more: [] as string[] }))\n return [{ kind: 'quotes', items: quotes.map(({ more: _more, ...item }) => item), columns, ...(boxed ? { variant: 'cards' as const } : { style: 'quiet' as const }), ...drawnAs(scope, group) }]\n }\n if (kind === 'faq') return [{ kind: 'faq', items, columns }]\n if (kind === 'stats') return [{ kind: 'stats', items, columns, ...(boxed ? { variant: 'cards' as const } : {}), ...drawnAs(scope, group) }]\n // A group kept apart from a list is ruled, where its boxing allows (AGL-4152).\n const style = styleFor(joins ? 'ruled' : answer?.style, group, items, scope.finish)\n return [{ kind: kind === 'steps' ? 'steps' : 'cards', items, columns, variant: style, ...drawnAs(scope, group, style) }]\n}\n\n/** A section's nodes in the layout language, a row of columns placed by `col` where the section may still take one. */\nfunction nodeBlocks(scope: MapScope, nodes: readonly SiteImportLayoutNode[], row: { cols: number[] | null; allowed: boolean }): AiLayoutBlock[] {\n const out: AiLayoutBlock[] = []\n for (const node of nodes) {\n switch (node.kind) {\n case 'line':\n out.push(...lineBlocks(scope, node))\n break\n case 'picture': {\n const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit)\n if (picture) out.push({ kind: 'image', picture })\n break\n }\n case 'icon':\n // A lone icon is no word and no picture of the page.\n break\n case 'video':\n out.push(...videoBlocks(scope, node))\n break\n case 'form': {\n // The form rebuilt for this one (AGL-4083); a read from before they were, the site's only form, once.\n const own = scope.doc.forms?.find((entry) => entry.index === node.form)\n if (scope.doc.forms) {\n if (own?.formId) out.push({ kind: 'form', to: own.formId })\n } else if (scope.formId && !scope.formPlaced) {\n scope.formPlaced = true\n out.push({ kind: 'form', to: scope.formId })\n }\n break\n }\n case 'row': {\n const cells = node.cells.filter((cell) => cell.nodes.length)\n const byline = bylineOf(scope, cells)\n if (byline) {\n // A portrait beside a name and a date: the portrait small, over its words.\n out.push(...byline)\n break\n }\n if (row.allowed && !row.cols && cells.length >= 2 && cells.length <= AI_LAYOUT_MAX_COLS) {\n // The section's row: each cell a column, by the source's widths.\n const weights = node.cells.map((cell, index) => ({ cell, weight: node.cols[index] ?? 1 })).filter((entry) => entry.cell.nodes.length)\n row.cols = weights.map((entry) => Math.min(12, Math.max(1, Math.round(entry.weight))))\n weights.forEach((entry, col) => {\n for (const block of nodeBlocks(scope, entry.cell.nodes, { cols: null, allowed: false })) out.push({ ...block, col })\n })\n } else {\n // A second row of a section, or one inside a column: its cells one under another.\n for (const cell of node.cells) out.push(...nodeBlocks(scope, cell.nodes, { cols: null, allowed: false }))\n }\n break\n }\n case 'group':\n out.push(...groupBlocks(scope, node))\n break\n case 'table': {\n const rows = node.rows.map((tableRow) => ({ cells: tableRow.cells.map((cell) => cell.lines.map((ref) => take(scope, ref)).filter(Boolean).join(' ')) }))\n if (rows.some((tableRow) => tableRow.cells.some(Boolean))) out.push({ kind: 'table', header: node.header, rows })\n break\n }\n case 'tabs': {\n const tabs = node.tabs.map((tab) => {\n const label = tab.label === null ? '' : take(scope, tab.label)\n // A panel sets its first row side by side, as a section does (AGL-4114).\n const panelRow = { cols: null as number[] | null, allowed: true }\n const blocks = mergeLists(nodeBlocks(scope, tab.panel, panelRow))\n return {\n label,\n ...(tab.selected ? { selected: true } : {}),\n blocks,\n ...(panelRow.cols && blocks.some((block) => block.col !== undefined) ? { cols: panelRow.cols } : {}),\n }\n })\n if (tabs.some((tab) => tab.label || tab.blocks.length)) out.push({ kind: 'tabs', tabs })\n break\n }\n default:\n break\n }\n }\n return out\n}\n\n/**\n * A video of the source, where it sat (AGL-4140): the Video element, its\n * poster the library's copy of the source's, where the Video element can play\n * the film. One on a host it cannot play is its poster, linking to where the\n * film plays; with no poster either, nothing of it can be shown.\n */\nfunction videoBlocks(scope: MapScope, node: Pick<SiteImportLayoutVideo, 'video' | 'poster' | 'fit' | 'shadow'>): AiLayoutBlock[] {\n const film = scope.films.get(node.video)\n if (film) {\n // A film is pressed to play from its poster: with none, the Video element has nothing to show, and it is left out.\n const picture = filmPlaces(scope, node.video, node.poster) ? takePicture(scope, node.poster, undefined, node.fit) : null\n if (!picture) {\n scope.settled.push({ at: scope.at, what: 'a video left out: it has no poster picture' })\n return []\n }\n const video: AiLayoutVideo = { ...film, ...(node.shadow ? { shadow: true } : {}) }\n return [{ kind: 'video', video, picture }]\n }\n const source = scope.doc.videos?.[node.video]\n const where = source?.embed ?? source?.src\n const picture = takePicture(scope, node.poster, where, node.fit)\n const host = (() => {\n try {\n return where ? new URL(where).hostname.replace(/^www\\./, '') : ''\n } catch {\n return ''\n }\n })()\n if (picture && source) scope.settled.push({ at: scope.at, what: `a video${host ? ` on ${host}` : ''} shown as its picture${picture.to ? ', linking to it' : ''}` })\n return picture ? [{ kind: 'image', picture }] : []\n}\n\n/** The page's films the Video element plays, by index (AGL-4140): each read's video that plays from a host it knows, or from the old site's https address. */\nfunction filmsOf(doc: AiSiteImportDocument): Map<number, AiLayoutVideo> {\n const films = new Map<number, AiLayoutVideo>()\n ;(doc.videos ?? []).forEach((video, index) => {\n const source = siteImportFilmSource(video)\n if (!source) return\n const title = clean(video.title).slice(0, 200)\n const description = clean(video.description).slice(0, 2_000)\n films.set(index, {\n index,\n src: source.src,\n ...(title ? { title } : {}),\n ...(description ? { description } : {}),\n ...(video.uploadDate ? { uploadDate: video.uploadDate } : {}),\n ...(video.durationSeconds ? { durationSeconds: video.durationSeconds } : {}),\n })\n })\n return films\n}\n\n/** Whether a film is drawn as the Video element: one it plays, its poster a picture the library holds. */\nfunction filmPlaces(scope: Pick<MapScope, 'films' | 'doc' | 'photos'>, video: number, poster: SiteImportLineRef | undefined): boolean {\n const block = poster === undefined ? undefined : scope.doc.blocks[poster]\n return scope.films.has(video) && block?.kind === 'image' && scope.photos.has(block.url)\n}\n\n/** The first film of a list of nodes drawn as the Video element, rows, tabs and items opened. */\nfunction firstFilm(scope: Pick<MapScope, 'films' | 'doc' | 'photos'>, nodes: readonly SiteImportLayoutNode[]): number | null {\n for (const node of nodes) {\n const found =\n node.kind === 'video'\n ? filmPlaces(scope, node.video, node.poster)\n ? node.video\n : null\n : node.kind === 'row'\n ? firstFilm(scope, node.cells.flatMap((cell) => cell.nodes))\n : node.kind === 'tabs'\n ? firstFilm(scope, node.tabs.flatMap((tab) => tab.panel))\n : node.kind === 'group'\n ? (node.items.find((item) => item.video !== undefined && filmPlaces(scope, item.video, item.image))?.video ?? null)\n : null\n if (found !== null) return found\n }\n return null\n}\n\n/** The most words beside a lone picture that make a row a byline: a name, a date, a role. */\nconst BYLINE_MAX_WORDS = 12\n\n/**\n * A row that is a byline (AGL-4107): one cell a lone picture, the other a few\n * words — a writer's portrait beside their name and date. Drawn as columns it\n * set a portrait across half the page; it is the portrait, small, and its words.\n */\nfunction bylineOf(scope: MapScope, cells: ReadonlyArray<{ nodes: SiteImportLayoutNode[] }>): AiLayoutBlock[] | null {\n if (cells.length !== 2) return null\n const at = cells.findIndex((cell) => cell.nodes.length === 1 && cell.nodes[0].kind === 'picture')\n if (at === -1) return null\n const words = cells[1 - at].nodes\n if (!words.every((node) => node.kind === 'line')) return null\n const count = words.reduce((total, node) => {\n const block = scope.doc.blocks[(node as SiteImportLayoutLine).line]\n return total + (block && block.kind !== 'image' ? aiSiteImportWordsIn(clean(block.text)) : 0)\n }, 0)\n if (count === 0 || count > BYLINE_MAX_WORDS) return null\n const node = cells[at].nodes[0] as Extract<SiteImportLayoutNode, { kind: 'picture' }>\n const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit)\n return [...(picture ? [{ kind: 'image' as const, picture: { ...picture, small: true } }] : []), ...nodeBlocks(scope, words, { cols: null, allowed: false })]\n}\n\n/** Paragraphs past which a section is reading copy, set at the start whatever its source centers. */\nconst READING_PARAGRAPHS = 4\n\n/** Neighboring one-line lists of one column as one list, as the source's list items read. */\nfunction mergeLists(blocks: readonly AiLayoutBlock[]): AiLayoutBlock[] {\n const out: AiLayoutBlock[] = []\n for (const block of blocks) {\n const last = out[out.length - 1]\n const plain = (entry: AiLayoutBlock | undefined) => entry?.kind === 'list' && entry.columns === undefined && !entry.items?.some((item) => item.iconPath)\n if (plain(block) && plain(last) && last?.col === block.col) {\n out[out.length - 1] = { ...last, items: [...(last.items ?? []), ...(block.items ?? [])] }\n continue\n }\n out.push(block)\n }\n return out\n}\n\n/** The heroes that lay dimmed words over the picture, which draw their section dark. */\nconst DIMMED_HEROES: ReadonlySet<AiLayoutImportHero> = new Set(['cover', 'poster'])\n\n/**\n * The hero a section's opening takes: the first section's, around its picture\n * beside, behind or under its words. Words dimmed over the picture draw the\n * section dark, so a section that keeps a lighter ground of its own, with its\n * picture anywhere but behind it, opens as its source does (AGL-4083): an\n * answer never repaints a section's own band. Nor does it move the picture\n * (AGL-4138): a picture under centered words stays under them, as a picture\n * beside the words stays beside them. Kept as it is (AGL-4152), the opening is\n * the source's own whatever the answer says: a hero that moved its words is\n * set aside with what it asked.\n */\nfunction heroOf(\n section: SiteImportLayoutSection,\n index: number,\n answer: AiLayoutDesignSection | null,\n settled: AiLayoutSettlement[],\n drawn: { band: SiteImportLayoutSection['band']; finish: AiSiteImportFinish },\n): AiLayoutImportHero | undefined {\n if (index !== 0 || !section.hero?.picture) return undefined\n const place = section.hero.picture\n if (drawn.finish !== 'improve') {\n const own = ownHeroOf(section, place)\n if (answer?.hero && answer.hero !== 'none' && answer.hero !== own) settled.push({ at: 'sections[0]', what: `the ${answer.hero} hero set aside: the page keeps its source's own opening, a ${own} hero` })\n return own\n }\n // An answer of \"none\" keeps the opening as the source lays it out.\n if (answer?.hero === 'none') return undefined\n const own = HERO_FOR[place]\n // Dimmed words need a dark ground: the section's own, or on a page its owner asked improved, the answer's (AGL-4152).\n if (answer?.hero && DIMMED_HEROES.has(answer.hero) && drawn.band !== 'dark' && place !== 'behind') {\n settled.push({ at: 'sections[0]', what: `the ${answer.hero} hero set aside: the section keeps its own lighter ground` })\n return own\n }\n return answer?.hero ?? own\n}\n\n/** How a page is finished (AGL-4152): the finish asked of it, else its document's, else kept as it is. */\nexport function aiSiteImportFinishOf(doc: Pick<AiSiteImportDocument, 'finish'> | null | undefined, asked?: AiSiteImportFinish | null): AiSiteImportFinish {\n const finish = asked ?? doc?.finish\n return finish === 'improve' ? 'improve' : 'keep'\n}\n\n/**\n * The Container width a source holds its opening's heading to (AGL-4152):\n * the theme's breakpoint nearest its measure, at most a page's own, which an\n * opening's words may span; none where the source sets none.\n */\nexport function aiSiteImportHeroMeasure(section: Pick<SiteImportLayoutSection, 'hero'>): Exclude<AiLayoutWidth, 'xl'> | null {\n const step = siteImportWidthOf(section.hero?.measure)\n return step === 'xl' ? 'lg' : step\n}\n\nexport interface AiSiteImportDesigned {\n sections: AiLayoutSection[]\n /** Lines taken into a block, by index of the page's blocks. */\n used: Set<number>\n /** Pictures the library could not hold. */\n missing: Set<number>\n settled: AiLayoutSettlement[]\n}\n\n/**\n * The page's sections in the layout language (AGL-4107): the source's layout,\n * each section in its own band (or the answer's, where the source gave none),\n * its row, its groups and their items, its tables, tabs and pictures, every\n * line taken exactly once and every line the layout placed nowhere added at\n * its section's end.\n */\nexport function aiSiteImportDesignedSections(\n doc: AiSiteImportDocument,\n answer?: AiLayoutDesignAnswer | null,\n options: { formId?: string | null; finish?: AiSiteImportFinish | null } = {},\n): AiSiteImportDesigned {\n const layout = aiSiteImportLayoutOf(doc)\n const finish = aiSiteImportFinishOf(doc, options.finish)\n const improve = finish === 'improve'\n const scope: MapScope = {\n doc,\n layout,\n used: new Set(),\n missing: new Set(),\n photos: new Map(doc.photos.flatMap((photo) => (photo.from ? [[photo.from, photo] as const] : []))),\n pathTo: new Map(doc.links.map((link) => [link.path.replace(/\\/+$/, '') || '/', link.id])),\n formId: options.formId ?? null,\n formPlaced: false,\n answer: null,\n groupAt: 0,\n settled: [],\n at: '',\n films: filmsOf(doc),\n film: null,\n finish,\n }\n const backdropOf = (section: SiteImportLayoutSection) => (section.backdrop?.kind === 'video' ? section.backdrop : null)\n const pageFilm = layout.sections.reduce<number | null>((found, section) => found ?? firstFilm(scope, section.nodes), null)\n const sections = layout.sections.map((section, index): AiLayoutSection => {\n const given = answer?.sections[index] ?? null\n scope.answer = given\n scope.groupAt = 0\n scope.at = `sections[${index}]`\n const behind = backdropOf(section)\n scope.film = firstFilm(scope, section.nodes) ?? pageFilm\n const row = { cols: null as number[] | null, allowed: true }\n // A film playing on its own behind the section's words is drawn as its poster there (AGL-4140): the\n // opening's hero lays it behind them. A film that starts on its own is one rule 16 refuses.\n const poster = behind ? takePicture(scope, behind.poster) : null\n if (behind) scope.settled.push({ at: scope.at, what: 'a film playing behind the words drawn as its poster' })\n const blocks = [...(poster ? [{ kind: 'image' as const, picture: poster }] : []), ...nodeBlocks(scope, section.nodes, row)]\n // Every line the layout placed nowhere, at the section's end, as its kind says.\n for (const ref of section.lines) {\n if (scope.used.has(ref)) continue\n const block = doc.blocks[ref]\n if (!isLine(block)) continue\n blocks.push(...lineBlocks(scope, { kind: 'line', line: ref }))\n }\n // A band only where the source gave the section none of its own; any section's, on a page its owner asked improved (AGL-4152).\n // Kept, its band against its page's ground (AGL-4152); improved, as its color alone reads.\n const own = improve ? (section.absoluteBand ?? section.band) : section.band\n const band = given?.band && (improve || (section.background === null && !section.backdrop)) ? given.band : own\n const hero = heroOf(section, index, given, scope.settled, { band: improve ? band : section.band, finish })\n // A long read is set at the start, as text is read, whatever its source centers.\n const reading = blocks.filter((block) => block.kind === 'text').length > READING_PARAGRAPHS\n const source = reading ? 'start' : section.align\n // The source's own heading measure for its opening's words, on a page kept as it is (AGL-4152).\n const measure = hero && !improve ? aiSiteImportHeroMeasure(section) : null\n return {\n band,\n // Kept as it is, a section keeps the source's alignment (AGL-4152); improved, the answer's.\n align: improve ? (given?.align ?? source) : source,\n // As wide as the source runs (AGL-4083), or the theme's own on a page its owner asked improved (AGL-4152);\n // where it sets no cap, a page's width, a long read's measure.\n width: (improve ? null : siteImportWidthOf(section.width)) ?? (reading ? 'md' : 'lg'),\n ...(row.cols && blocks.some((block) => block.col !== undefined) ? { cols: row.cols } : {}),\n blocks: mergeLists(blocks),\n ...(hero ? { hero } : {}),\n ...(measure ? { measure } : {}),\n }\n })\n return { sections, used: scope.used, missing: scope.missing, settled: scope.settled }\n}\n\n/*------------------------------------------\n * The page compiled\n *-----------------------------------------*/\n\nexport interface AiSiteImportCompileInput {\n doc: AiSiteImportDocument\n /** The ids the page stores its sections under, in plan order: one for each of the page's sections. */\n sectionIds: readonly string[]\n /** The page's plan: its title and its sections by name. */\n plan: AiLayoutPagePlan\n targets: AiLayoutTargets\n /** The site the page belongs to, which its hero is drawn for. */\n design?: AiLayoutDesign | null\n language?: string\n /** The page's design answer, for a main page; absent, the page is drawn as its source lays it out. */\n answer?: AiLayoutDesignAnswer | null\n /** How the page is finished (AGL-4152); absent is `keep`. */\n finish?: AiSiteImportFinish | null\n}\n\nexport interface AiSiteImportCompiled extends Pick<AiLayoutCompiledPage, 'tree' | 'sectionRoots' | 'videoIds'> {\n sections: AiLayoutSection[]\n /** The lines on the page, by index of its blocks, in source order. */\n placed: number[]\n /** Every line the page has. */\n lines: number\n /** The words on the page, and the words its lines hold. */\n words: number\n sourceWords: number\n /** Set when the page ran past what one page may weigh, and its last sections keep only their names. */\n cut: boolean\n settled: AiLayoutSettlement[]\n}\n\n/**\n * The page brought in, built by the site compiler (AGL-4107): every line on\n * it exactly once, every word as its source wrote it, laid out as its source\n * lays it out and drawn in the site's own theme.\n */\nexport function aiCompileImportedPage(input: AiSiteImportCompileInput): AiSiteImportCompiled {\n const { doc } = input\n const formId = input.targets.forms.length === 1 ? input.targets.forms[0].id : null\n const finish = aiSiteImportFinishOf(doc, input.finish)\n const designed = aiSiteImportDesignedSections(doc, input.answer ?? null, { formId, finish })\n const compile = (sections: readonly AiLayoutSection[]) =>\n aiCompileLayoutPage(sections, input.plan, input.targets, {\n // A page brought in draws its repeats as its source does (AGL-4107).\n reusableComponents: false,\n sectionIds: input.sectionIds,\n verbatim: true,\n finish,\n ...(input.design ? { design: input.design } : {}),\n ...(input.language ? { language: input.language } : {}),\n })\n let sections = designed.sections\n let compiled = compile(sections)\n let cut = false\n // A page past what one page may weigh keeps its last sections by name.\n for (let last = sections.length - 1; Object.keys(compiled.tree.nodes).length > AI_SITE_IMPORT_DOC_MAX_NODES && last > 0; last -= 1) {\n cut = true\n sections = sections.map((section, index) => (index >= last ? { ...section, blocks: [], cols: undefined } : section))\n compiled = compile(sections)\n }\n const dropped = new Set<number>()\n if (cut) {\n const layout = aiSiteImportLayoutOf(doc)\n layout.sections.forEach((section, index) => {\n if (!sections[index]?.blocks.length) for (const ref of section.lines) dropped.add(ref)\n })\n }\n const lineRefs = doc.blocks.flatMap((block, index) => (isLine(block) ? [index] : []))\n const placed = lineRefs.filter((ref) => designed.used.has(ref) && !designed.missing.has(ref) && !dropped.has(ref))\n const wordsOf = (ref: number) => {\n const block = doc.blocks[ref]\n return block && block.kind !== 'image' ? aiSiteImportWordsIn(clean(block.text)) : 0\n }\n return {\n tree: compiled.tree,\n sectionRoots: compiled.sectionRoots,\n // Its films' Video elements keep their ids when stored, as its sections do: a button that plays one names it (AGL-4140).\n ...(compiled.videoIds?.length ? { videoIds: compiled.videoIds } : {}),\n sections,\n placed,\n lines: lineRefs.length,\n words: placed.reduce((total, ref) => total + wordsOf(ref), 0),\n sourceWords: lineRefs.reduce((total, ref) => total + wordsOf(ref), 0),\n cut,\n settled: [...designed.settled, ...compiled.settled],\n }\n}\n\n/*------------------------------------------\n * What the design answer is shown\n *-----------------------------------------*/\n\n/** The most characters of a page's structure a design prompt shows. */\nexport const AI_SITE_IMPORT_DESIGN_MAX_CHARS = 12_000\n\n/** What a line is, as the design answer reads its place. */\nfunction lineKind(block: SiteImportBlock | undefined, node: SiteImportLayoutLine): string {\n if (!block) return 'line'\n if (block.kind === 'heading') return 'heading'\n if (block.kind === 'link') return node.button ? `${node.button === 'primary' ? 'filled' : node.button === 'secondary' ? 'outlined' : 'quiet'} button` : 'link'\n if (block.kind === 'list-item') return 'list item'\n if (block.kind === 'quote') return 'quote'\n if (block.kind === 'image') return 'picture'\n // A statement is read as the lede it was before the import drew it larger (AGL-4138): the answer's text is unchanged.\n return node.role === 'statement' ? 'lede' : (node.role ?? 'text')\n}\n\n/** What an item of a group shows, as one phrase: \"icon + title + text + link\". */\nfunction itemShape(item: SiteImportLayoutItem): string[] {\n return [\n item.image !== undefined ? 'picture' : '',\n item.icon !== undefined ? 'icon' : '',\n item.figure !== undefined ? 'figure' : '',\n item.title !== undefined ? 'title' : '',\n item.text?.length ? 'text' : '',\n item.list?.length ? `${item.listIcon !== undefined ? 'checked ' : ''}list` : '',\n item.link?.length ? 'link' : '',\n ].filter(Boolean)\n}\n\n/** A run of one kind of part counted: \"2 buttons\", not \"button, button\". */\nfunction counted(parts: readonly string[]): string {\n const out: string[] = []\n for (let at = 0; at < parts.length; ) {\n let run = 1\n while (parts[at + run] === parts[at]) run += 1\n out.push(run > 1 ? `${run} ${parts[at]}s` : parts[at])\n at += run\n }\n return out.join(', ')\n}\n\n/** A section's nodes as the design answer reads them, its groups numbered in order. */\nfunction describeNodes(doc: Pick<AiSiteImportDocument, 'blocks'>, nodes: readonly SiteImportLayoutNode[], groups: { count: number }): string[] {\n const parts: string[] = []\n for (const node of nodes) {\n switch (node.kind) {\n case 'line':\n parts.push(lineKind(doc.blocks[node.line], node))\n break\n case 'picture':\n // A film reads as the picture it opens on (AGL-4140): the design answer is asked nothing new of it.\n case 'video':\n parts.push('picture')\n break\n case 'form':\n parts.push('form')\n break\n case 'row':\n parts.push(`a row of ${node.cells.length} columns (${node.cells.map((cell, index) => `column ${index + 1}: ${describeNodes(doc, cell.nodes, groups).join(', ') || 'empty'}`).join('; ')})`)\n break\n case 'group': {\n groups.count += 1\n const shape = [...new Set(node.items.map((item) => itemShape(item).join(' + ')).filter(Boolean))].slice(0, 2).join(' or ')\n // A group set apart by a rule reads \"boxed\", as it did before the rule was kept (AGL-4138): the answer's text is unchanged.\n parts.push(`group ${groups.count}: ${node.items.length} ${node.group} in ${node.columns} column${node.columns === 1 ? '' : 's'}${node.boxed || node.rule ? ', boxed' : ''}${shape ? `, each ${shape}` : ''}`)\n break\n }\n case 'table':\n parts.push(`a table of ${node.rows.length} rows`)\n break\n case 'tabs':\n parts.push(`${node.tabs.length} tabs (${node.tabs.map((tab, index) => `tab ${index + 1}: ${describeNodes(doc, tab.panel, groups).join(', ') || 'not drawn'}`).join('; ')})`)\n break\n default:\n break\n }\n }\n return parts\n}\n\n/**\n * The page's structure as its design answer reads it (AGL-4107): each\n * section's name, band, alignment and what it shows, its groups numbered as\n * the answer names them. No word of the page is in it but its sections'\n * names, which are fenced where the prompt shows them.\n */\nexport function aiSiteImportDesignText(doc: Pick<AiSiteImportDocument, 'blocks' | 'title' | 'layout'>): string {\n const layout = aiSiteImportLayoutOf(doc)\n const names = aiSiteImportSectionNames(doc)\n return layout.sections\n .map((section, index) => {\n const groups = { count: 0 }\n const shows = describeNodes(doc, section.nodes, groups)\n const band = section.background === null && !section.backdrop ? 'no band of its own' : `${section.absoluteBand ?? section.band} band${section.backdrop?.kind === 'gradient' ? ' with a gradient' : ''}`\n const hero = index === 0 && section.hero?.picture ? `; opens the page, its picture ${section.hero.picture} its words` : index === 0 ? '; opens the page, with no picture' : ''\n return `Section ${index + 1} \"${names[index]}\": ${band}, ${section.align === 'center' ? 'centered' : 'aligned to the start'}${hero}. Groups: ${groups.count}. Shows: ${counted(shows)}.`\n })\n .join('\\n')\n}\n"],"names":["aiCompileLayoutPage","AI_LAYOUT_GROUP_STYLES","AI_LAYOUT_MAX_COLS","AI_SITE_IMPORT_LABEL_MAX_CHARS","SITE_IMPORT_PLAY_WORDS","siteImportFilmSource","siteImportWidthOf","aiHexOklch","aiModelAtLeastStepTier","AI_SITE_IMPORT_DOC_MAX_NODES","AI_SITE_IMPORT_LABEL_CHARS","aiSiteImportDocLines","aiSiteImportTextParts","aiSiteImportWordsIn","clean","text","replace","trim","isLine","block","kind","url","inline","aiImportPageModel","modelFor","aiSiteImportLinkablePages","doc","seen","Set","links","flatMap","link","has","id","add","path","label","slug","aiImportedPageListing","screen","written","title","seoTitle","description","seoDescription","aiImportedPageListingOwed","listing","aiSiteImportLayoutOfLines","lines","sections","blocks","refOf","forEach","index","push","v","map","section","refs","n","filter","ref","undefined","name","from","band","background","align","nodes","line","icons","look","fonts","body","headings","google","buttonFill","buttonText","buttonRadius","header","aiSiteImportLayoutOf","layout","length","aiSiteImportSectionNames","named","names","slice","unique","attempt","toLowerCase","PATH_PARAMS","m","l","h","c","s","q","t","a","z","NUMBER","FLAG","round","value","fixed","Math","Object","is","String","aiSiteImportPathOn24","d","viewBox","box","split","Number","some","isFinite","minX","minY","width","height","scale","max","dx","dy","identity","abs","out","at","first","source","test","command","lower","count","relative","groups","group","pattern","lastIndex","match","exec","parts","absolute","x","y","position","part","join","shapeAttributes","matchAll","num","NaN","parseFloat","shapePath","tag","attributes","cx","cy","rx","ry","every","points","aiSiteImportIconPath","shape","svg","paths","OPEN_KINDS","FIXED_KINDS","BOXED_STYLES","OPEN_STYLES","LIKE_ITEMS_AS_CARDS","HERO_FOR","beside","behind","below","above","ownHeroOf","place","linkTo","scope","href","URL","protocol","origins","includes","origin","pathname","pathTo","get","toString","take","used","ratioText","ROUNDED_PX","pictureFitOf","photo","fit","assign","ratio","cropped","objectFit","radius","rounded","shadow","measure","keys","takePicture","photos","missing","alt","to","framed","src","COLORFUL_CHROMA","colorGap","b","ax","C","cos","PI","ay","sin","bx","by","hypot","L","HEX","brandish","hex","own","other","them","hue","min","aiSiteImportColorRole","use","tileInk","fill","color","light","ruleOf","rule","side","textBlocks","linkBlocks","style","items","lineBlocks","node","picture","button","film","role","chip","iconAt","itemLinkStyle","item","ctas","find","cta","itemOf","figure","image","badge","period","list","paragraphs","addLink","imageFit","more","icon","iconPath","mark","listIcon","listIconPath","tile","arrow","markPath","figureMuted","video","films","defaultStyle","pictured","boxed","drawnAs","itemsAlign","columnsSm","styleFor","asked","finish","fallback","likeItems","itemShape","size","FIGURE_MAX_CHARS","holdsOnlyFigures","lead","groupBlocks","answer","groupAt","improve","settled","what","columns","opens","answered","carded","joins","unfigured","linked","words","Boolean","quotes","_more","variant","nodeBlocks","row","videoBlocks","forms","entry","form","formId","formPlaced","cells","cell","byline","bylineOf","allowed","cols","weights","weight","col","rows","tableRow","tabs","tab","panelRow","mergeLists","panel","selected","filmPlaces","poster","videos","where","embed","host","hostname","filmsOf","Map","set","uploadDate","durationSeconds","firstFilm","found","BYLINE_MAX_WORDS","findIndex","reduce","total","small","READING_PARAGRAPHS","last","plain","DIMMED_HEROES","heroOf","drawn","hero","aiSiteImportFinishOf","aiSiteImportHeroMeasure","step","aiSiteImportDesignedSections","options","backdropOf","backdrop","pageFilm","given","absoluteBand","reading","aiCompileImportedPage","input","compiled","targets","designed","compile","plan","reusableComponents","sectionIds","verbatim","design","language","cut","tree","dropped","lineRefs","placed","wordsOf","sectionRoots","videoIds","sourceWords","AI_SITE_IMPORT_DESIGN_MAX_CHARS","lineKind","counted","run","describeNodes","aiSiteImportD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