@aglyn/plugins-ai 1.21.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-import-fidelity.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, SCORED AGAINST ITS SOURCE (AGL-4109).\n *\n * On 10/29 an import of aglyn.com shipped with every section flattened to one\n * column of lines and a header of page titles, and nothing measured it: the\n * specs checked that words came through, never how the page was laid out.\n * This scores a built page against what the reader read of its source\n * (`SiteImportLayout`, AGL-4106), with no model and no browser, over the\n * page's nodes as the compiler draws them or as Firestore stores them:\n *\n * - **The words**: every line of the source exactly once, as written, and\n * none of the page's own. A score of words is 1 or the page is wrong.\n * - **The structure**: its sections, their bands and how wide they run; its\n * rows of columns side by side; its groups by kind, each item its own\n * element with its parts (an FAQ's question on an accordion, a card's link\n * on the card); its tables, tab strips, pictures, icons, buttons as the\n * source draws them, headings and forms.\n * - **The frame** (`siteImportFrameFidelity`): the header's top-level items\n * in order, each menu's entries with their lines and icons, the buttons,\n * the phone menu holding all of it, labels on one line; the footer's\n * columns, links, profiles and facts.\n *\n * Every measure is anchored to the source's own words, never to how the\n * compiler names its elements: each line of the source is found on the\n * built page, and the structure is asked of the elements holding them (are\n * a group's thirteen items thirteen elements, or one stack of lines?). So\n * the same score reads a page compiled in a spec and a page stored on a live\n * site. The score is the lowest ratio of the structure; words are held apart\n * at exactly 1.\n *\n * How the owner asked the site to be finished (AGL-4152) changes what the\n * score means, and each finish is asked for by name; a page scored with\n * neither a finish nor its words scores as it did before the choice:\n *\n * - **Keep my site**: the structure, and the look's pins at 1.0: each\n * section's alignment and its groups' boxes as the source has them, each\n * ground within OKLab ΔE 0.05 of the source's, the hero heading's measure\n * within 10%, and the buttons in the source's case and fill.\n * - **Improve it**: the content alone (words, sections, items, tables, tabs,\n * pictures, icons, buttons, headings, forms, films); the bands, widths,\n * rows, framing, grounds, measure, alignment and boxes are free, and the\n * `design` lines say whether the build reads better than its source.\n * - **Improved words** (lane G): the words are free, and every fact, every\n * line and most of each line's meaning are held instead.\n *=========================================*/\n\nimport { contrastRatio } from '@aglyn/aglyn/app-utils/site-theme'\nimport type { SiteImportBlock } from '../site-import/site-import-html'\nimport { SITE_IMPORT_PLAY_WORDS, siteImportWidthOf, type AiSiteImportFinish, type AiSiteImportWords } from './ai-site-import'\nimport { siteImportLedger } from './ai-site-import-ledger'\nimport { aiHexOklch } from './ai-site-look'\nimport type {\n SiteImportBand,\n SiteImportButtonStyle,\n SiteImportFooter,\n SiteImportGroupKind,\n SiteImportLayout,\n SiteImportLayoutGroup,\n SiteImportLayoutItem,\n SiteImportLayoutNode,\n SiteImportLayoutSection,\n SiteImportLineRef,\n SiteImportNavTree,\n SiteImportPictureFit,\n SiteImportWidth,\n} from './ai-site-import'\n\n/** The lowest score of structure a page brought in ships at (AGL-4109); words are held at exactly 1. */\nexport const SITE_IMPORT_FIDELITY_THRESHOLD = 0.9\n\n/** A node of a page or a layout, as the compiler draws it or Firestore stores it, decoded. */\nexport interface SiteImportFidelityNode {\n componentId?: string\n props?: Record<string, unknown> | null\n sx?: Record<string, unknown> | null\n nodes?: readonly string[] | null\n parentId?: string | null\n interactions?: readonly unknown[] | null\n}\n\n/** A built page or layout: its nodes and the one they hang from. */\nexport interface SiteImportFidelityTree {\n rootId: string\n nodes: Readonly<Record<string, SiteImportFidelityNode>>\n}\n\n/** What the source had, what the built page kept of it, and the share kept. */\nexport interface SiteImportFidelityCount {\n source: number\n built: number\n ratio: number\n}\n\n/** The words of a page: every one of the source's, as written, exactly once, and none of its own. */\nexport interface SiteImportFidelityWords {\n /** Words the source's lines hold. */\n source: number\n /** Words the built page shows. */\n built: number\n /** The source's words the page does not show (counted as often as they are missing). */\n missing: number\n /** Words the page shows that are not the source's, or are shown more often than the source says them. */\n extra: number\n /** Words shown once each, over the larger of the two. */\n ratio: number\n /** A few of the missing and extra words, for a report. */\n examples: { missing: string[]; extra: string[] }\n}\n\nexport interface SiteImportFidelityGroup {\n /** Groups of the kind kept whole: every item of them its own element, with its parts. */\n groups: SiteImportFidelityCount\n /** Items of the kind kept, each its own element with its parts. */\n items: SiteImportFidelityCount\n}\n\n/** A page brought in, scored against its source. */\nexport interface SiteImportPageFidelity {\n /** The lowest ratio of the structure: what the page ships on, at `SITE_IMPORT_FIDELITY_THRESHOLD` or above. */\n score: number\n /** The measure that set the score; `null` when every measure is whole. */\n lowest: string | null\n words: SiteImportFidelityWords\n sections: SiteImportFidelityCount\n /** Sections drawn in the source's band, in order. */\n bands: SiteImportFidelityCount & { read: SiteImportBand[]; drawn: SiteImportBand[] }\n /** Sections drawn as wide as the source runs them, or wider (AGL-4083); one the source sets no cap on counts as kept. */\n widths: SiteImportFidelityCount\n /** The source's rows of two or more columns, set side by side on the page. */\n rows: SiteImportFidelityCount\n /** The source's galleries (AGL-4152), each kept when every photo of it is drawn as a photo, cropped to fill, side by side. Absent on a page with none. */\n galleries?: SiteImportFidelityCount\n /** Pictures and labels the source hides from a visitor, drawn all the same (AGL-4152); any at all is a miss. Absent when the read says of none. */\n concealed?: SiteImportFidelityCount\n /** The source's groups by kind. A group of lines that only share a shape (`text`) is drawn as its lines, and is not scored. */\n groups: Partial<Record<SiteImportGroupKind, SiteImportFidelityGroup>>\n tables: SiteImportFidelityCount\n tabs: SiteImportFidelityCount\n /** The source's pictures placed on the page. */\n pictures: SiteImportFidelityCount\n /**\n * The source's pictures framed as the source frames them (AGL-4138): each\n * in a box of the shape the source shows it at — the box or the height it\n * crops it to, else its own — within 5%, or in no box at all where the\n * source crops nothing. A round portrait, and a picture the source lays\n * behind its words, are framed by design and not scored.\n */\n framing: SiteImportFidelityCount\n /**\n * The source's icons drawn: each group item's own, each bullet's mark. An\n * icon standing alone in the source (a video's play mark) is no word and no\n * picture of the page, and the build leaves it out (AGL-4107): it is\n * counted in `lone` and not scored.\n */\n icons: SiteImportFidelityCount & { lone: number }\n /**\n * The lines the source draws as buttons that go somewhere (a page, an\n * address, an email, a phone), drawn as buttons of the same style with\n * their destinations. A button that goes nowhere a page can send a visitor\n * (a film's play button its script runs) is kept as its words: counted in\n * `unlinked`, not scored.\n */\n buttons: SiteImportFidelityCount & {\n unlinked: number\n /**\n * Under Keep my site (AGL-4152), the buttons set in the source's case, and\n * its filled ones in its own fill within OKLab ΔE 0.05: counted where the\n * source's look and the theme say them, and a button short of either is\n * not kept.\n */\n case?: SiteImportFidelityCount\n fill?: SiteImportFidelityCount\n /** Its outlined ones drawn as the source draws them: no fill of their own, their words and border in the source's color, within OKLab ΔE 0.1 (`SITE_IMPORT_OUTLINE_DELTA`). */\n outline?: SiteImportFidelityCount\n }\n /** The source's headings, drawn as headings. */\n headings: SiteImportFidelityCount\n /** The source's forms, where the site has a form a page places. */\n forms: SiteImportFidelityCount\n /**\n * The source's videos (AGL-4140): each drawn as the Video element, playing\n * from an address. One on a host the element has no player for is drawn as\n * its poster, linking to it, and is not kept. A film that plays on its own\n * behind a section's words is drawn as its poster there and is not counted\n * here: its poster is among the pictures.\n */\n videos: SiteImportFidelityCount\n /**\n * What the page was scored as (AGL-4152): its finish and its words. Absent\n * on a page scored with neither, whose score is the one before the choice,\n * and which carries none of the measures below.\n */\n scoredAs?: { finish: AiSiteImportFinish; words: AiSiteImportWords }\n /** The measures this finish prints as free: reported, never scored. */\n free?: string[]\n /** Sections whose words are set as the source sets them, centered or at the start. */\n align?: SiteImportFidelityCount\n /** Groups whose items are boxed where the source boxes them, and open where it leaves them open. */\n boxed?: SiteImportFidelityCount\n /**\n * Sections with a ground of their own drawn on a ground of the theme\n * within OKLab ΔE 0.05 of it (`SITE_IMPORT_GROUND_DELTA`): `theme` says\n * where the theme's colors were read from, `null` where none was given and\n * nothing is measured; `worst` is the farthest one. Under Keep my site\n * (AGL-4152) in their place against the page too: a section lighter than its\n * page's ground draws lighter than the theme's, and one on its page's ground\n * draws on the theme's, for two near whites read alike by ΔE alone.\n */\n ground?: SiteImportFidelityCount & { theme: SiteImportFidelityTheme['from'] | null; worst: number | null }\n /**\n * Under Keep my site (AGL-4152), the same sections in the theme's dark\n * scheme: on the source's own dark fill within OKLab ΔE 0.05 where its\n * stylesheets say one, else in their place against the dark page.\n */\n darkGround?: SiteImportFidelityCount & { worst: number | null }\n /**\n * The hero heading's box as a share of its section, within 10% of the\n * source's (`SITE_IMPORT_MEASURE_SHARE`): measured where the reader kept the\n * source's measure. `shares` are the two shares compared.\n */\n measure?: SiteImportFidelityCount & { shares: { source: number; built: number } | null }\n /** Each section's ink on its ground, and a filled button's label on its fill, at 4.5:1 or better: measured where a theme is given. */\n readable?: SiteImportFidelityCount\n /** The lines Improve it scores the build on against its source: whether it reads better (AGL-4152). */\n design?: SiteImportDesignFidelity\n /** Under improved words (G4): every fact of the source (prices, numbers, emails, phones, addresses, names) as often as it says it. */\n facts?: SiteImportFidelityFacts\n /** Under improved words (G4): every line of the source placed once, and none the page added (`extra`). */\n lines?: SiteImportFidelityCount & { extra: number }\n /** Under improved words (G4): how much of each line's content its rewrite keeps, held at `floor` a line. */\n meaning?: SiteImportFidelityMeaning\n /** Under a generative Improve it (AGL-4152): the kept ledger, held at 1, and the design lines. */\n improved?: SiteImportImprovedFidelity\n}\n\n/** One line a generative Improve it is held to (AGL-4152): how much of what it asks the page does, and whether that is enough. */\nexport interface SiteImportImprovedLine {\n done: number\n of: number\n ok: boolean\n}\n\n/**\n * A page a generative Improve it built, scored (AGL-4152). Its sections and\n * words are the redesign's own, so what is scored is what must have come\n * through and whether it reads as designed.\n */\nexport interface SiteImportImprovedFidelity {\n /** What must have come through, each at 1. */\n ledger: {\n /** Every fact the source says, on the page. */\n facts: SiteImportImprovedLine & { missing: string[] }\n /** Facts and names on the page that nothing the import read says: none. */\n invented: SiteImportImprovedLine & { found: string[] }\n /** Every thing that must land, on the page. */\n held: SiteImportImprovedLine & { missing: string[] }\n /** Every link's destination, on the page. */\n links: SiteImportImprovedLine & { missing: string[] }\n /** The source's content words on the page, at `SITE_IMPORT_IMPROVED_MEANING` or more. */\n meaning: SiteImportImprovedLine\n }\n /** How it reads; a line is `null` where the page asks it nothing, or what it reads is not given. */\n design: Record<SiteImportImprovedLineName, SiteImportImprovedLine | null>\n /** Whether the ledger holds whole. */\n holds: boolean\n /** The lines short of the bar, ledger first. */\n red: string[]\n}\n\n/** The design lines of a generative Improve it (AGL-4152). */\nexport const SITE_IMPORT_IMPROVED_LINES = ['cta', 'rhythm', 'columns', 'framing', 'contrast', 'frame', 'phone'] as const\nexport type SiteImportImprovedLineName = (typeof SITE_IMPORT_IMPROVED_LINES)[number]\n\n/** The share of a source's content words a redesign keeps on its page (AGL-4152). */\nexport const SITE_IMPORT_IMPROVED_MEANING = 0.6\n\n/** The fewest content words a source line says for its meaning to be held (AGL-4152): fewer is a label, written again freely. */\nexport const SITE_IMPORT_MEANING_LEAST_WORDS = 4\n\n/** What a generative Improve it is scored against, besides its source. */\nexport interface SiteImportImprovedOptions {\n /** Every other line the import read: a fact one of these says is no invention. */\n scope?: readonly string[]\n /** Every destination the source's links have on the new site (`page:<id>`, an address). Absent, not measured. */\n destinations?: readonly string[]\n /** How many forms have a saved form to place. Absent, every form the source has. */\n forms?: number\n /** The site's header and footer, for the `frame` line. Absent, not measured. */\n frame?: SiteImportFidelityTree | null\n /** A page the site's plan proposed: new, so no source's facts or meaning to hold, only what it says. */\n proposed?: boolean\n /** Words the platform's own request put to the redesign, no one's name or fact (`siteImportFactScope`). */\n vocabulary?: readonly string[]\n /** The share of the source's content words the page keeps; absent, `SITE_IMPORT_IMPROVED_MEANING`. */\n meaning?: number\n}\n\n/** How a page was finished and its words kept (AGL-4152), and the theme it is drawn in. */\nexport interface SiteImportFidelityOptions {\n /** Keep my site or Improve it. Scored with neither this nor `words`, the page scores as it did before the choice. */\n finish?: AiSiteImportFinish | null\n /** Whether its words were kept as written or improved (lane G). */\n words?: AiSiteImportWords | null\n /**\n * The theme the page is drawn in (`siteImportFidelityThemeOf`). A tree\n * names roles (`background.paper`, `primary.main`), not colors: without a\n * theme the grounds, the inks and the buttons' case and fill are not\n * measured.\n */\n theme?: SiteImportFidelityTheme | null\n /** Scored as a generative Improve it (AGL-4152): its kept ledger and design lines, in place of its structure. */\n improved?: SiteImportImprovedOptions | null\n}\n\n/** One scheme of a theme, as the fidelity reads it. */\nexport interface SiteImportFidelityScheme {\n /** `background.default`: a plain band's ground. */\n ground: string | null\n /** `background.paper`: a soft band's. */\n paper: string | null\n /** `primary.main`: a brand band's, and a filled button's where the theme sets none apart. */\n brand: string | null\n /** `primary.contrastText`: the words on it. */\n onBrand: string | null\n /** `text.primary`: the words' ink. */\n ink: string | null\n /** `primary.light`: what a theme may draw its own filled buttons in. */\n brandLight?: string | null\n /** `divider`: a hairline, as a base may border an outlined button. */\n divider?: string | null\n}\n\n/** The colors and button style of the theme a page is drawn in, `#rrggbb`. */\nexport interface SiteImportFidelityTheme {\n /** Where they were read from: the site's theme as stored, or computed from its site style. */\n from: 'theme' | 'style'\n light: SiteImportFidelityScheme\n dark: SiteImportFidelityScheme | null\n /**\n * A filled button's own fill and label where the theme sets them apart from\n * the brand's (`MuiButton`), and the case its words are set in; the outlined\n * and text buttons' own style, where the theme sets one: its colors as the\n * theme names them, a palette path resolved in the scheme a button is drawn in.\n * `fillDark` and `labelDark` are the filled button's in the dark scheme.\n */\n button: {\n fill: string | null\n label: string | null\n fillDark?: string | null\n labelDark?: string | null\n case: 'upper' | 'none' | null\n outlined?: { text: unknown; border: unknown; fill: unknown; case: 'upper' | 'none' | null }\n text?: { case: 'upper' | 'none' | null }\n }\n}\n\n/** One line of the design measure: the share of what it asks that the source and the build each do, 0 to 1. */\nexport interface SiteImportDesignLine {\n source: number\n built: number\n}\n\n/**\n * Whether a page improved reads better than its source (AGL-4152), with no\n * model: each line the share of what it asks that the page does. A line is\n * `null` where the page gives it nothing to ask. Better is the build at or\n * above the source on every line and above it on one at least; a build that\n * is merely different is not better.\n */\nexport interface SiteImportDesignFidelity {\n /** Neighboring sections set apart by their bands, or a rule between them. */\n rhythm: SiteImportDesignLine | null\n /** Sections whose words run no wider than `lg`, and a long read no wider than `md`. */\n measure: SiteImportDesignLine | null\n /** A first section holding a picture opens as the page's hero, its heading and its picture together. */\n opening: SiteImportDesignLine | null\n /** Runs of three or more like items drawn as one group, each item an element of its own. */\n grouped: SiteImportDesignLine | null\n /** Inks and grounds that read at 4.5:1. */\n readable: SiteImportDesignLine | null\n better: boolean\n}\n\n/** The facts of a page's words (G4): each found on the built page as often as the source has it, and none of its own. */\nexport interface SiteImportFidelityFacts {\n source: number\n built: number\n missing: number\n extra: number\n /** Facts found as often as said, over the larger of the two: exactly 1 or the page is wrong. */\n ratio: number\n examples: { missing: string[]; extra: string[] }\n}\n\n/** How much of each line's content its rewrite keeps (G4). */\nexport interface SiteImportFidelityMeaning {\n /** The lines rewritten: placed, and drawn in words other than the source's. */\n lines: number\n /** Those keeping less than `floor` of their content words. */\n below: number\n /** The least any line kept; 1 where none was rewritten. */\n lowest: number\n /** The lines at `floor` or above, over the lines rewritten. */\n ratio: number\n floor: number\n /** The lines below the floor, for a report. */\n examples: Array<{ line: SiteImportLineRef; kept: number; source: string; built: string }>\n}\n\n/** How far a ground of the theme may sit from the source's (AGL-4152), in OKLab. */\nexport const SITE_IMPORT_GROUND_DELTA = 0.05\n\n/**\n * How far an outlined button's color may sit from the source's (AGL-4152), in\n * OKLab: it is the theme's primary, a shade deepened to carry white words where\n * the source's own does not, so a role and not a pin. A grey or a light one is\n * far past it.\n */\nexport const SITE_IMPORT_OUTLINE_DELTA = 0.1\n\n/** How far the hero heading's share of its section may sit from the source's (AGL-4152), relatively. */\nexport const SITE_IMPORT_MEASURE_SHARE = 0.1\n\n/** The least share of a line's content words a rewrite keeps (G4): a bold rewrite, the owner asked 11/4, still keeps a third. */\nexport const SITE_IMPORT_MEANING_FLOOR = 0.3\n\n/** The measures Improve it prints as free (AGL-4152): what it may change. */\nexport const SITE_IMPORT_IMPROVE_FREE: readonly string[] = ['bands', 'widths', 'rows', 'framing', 'ground', 'measure', 'align', 'boxed']\n\n/** A page's source as the import read it: its layout over its main-region blocks, and its photos as the library holds them. */\nexport interface SiteImportFidelitySource {\n layout: SiteImportLayout\n /** The page's main-region blocks, which the layout's lines are indexes of. */\n blocks: readonly SiteImportBlock[]\n /** The source's pictures as the site's library holds them (`from` → `src`, and their size); without them a picture is counted, not placed. */\n photos?: ReadonlyArray<{ from?: string; src: string; width?: number; height?: number; graphic?: boolean }>\n /** What the source holds that a visitor cannot see (AGL-4152): a build that draws any of it fails `concealed`. */\n concealed?: { pictures: readonly string[]; words: readonly string[] }\n}\n\n/*------------------------------------------\n * Words and lines\n *-----------------------------------------*/\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\nconst WORD = /[\\p{L}\\p{N}]+/gu\n\n/** A line's words, in order. */\nconst wordsOf = (text: string): string[] => text.match(WORD) ?? []\n\n/**\n * A line's words as one string, for comparing two lines whatever their\n * spacing and marks; a line of marks alone (a table's \"✓\", a \"—\") as it is.\n */\nconst wordLine = (text: string): string => wordsOf(text).join(' ') || clean(text)\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/** A cell of the Table element's grid, its pipes unescaped. */\nfunction tableCells(rows: string): string[] {\n return rows\n .split('\\n')\n .flatMap((line) =>\n line\n .replace(/^\\s*\\|/, '')\n .replace(/\\|\\s*$/, '')\n .split(/(?<!\\\\)\\|/)\n .map((cell) => clean(cell.replace(/\\\\\\|/g, '|'))),\n )\n .filter(Boolean)\n}\n\n/** The words a node shows a visitor: its text, its list lines, its tab labels, its table's cells. */\nfunction shownTexts(node: SiteImportFidelityNode | undefined): string[] {\n if (!node) return []\n const props = node.props ?? {}\n const out: string[] = []\n for (const key of ['children', 'primary', 'secondary']) {\n const value = clean(props[key])\n if (value) out.push(value)\n }\n if (node.componentId === 'muiTabs' && typeof props['labels'] === 'string') out.push(...props['labels'].split('\\n').map(clean).filter(Boolean))\n if (node.componentId === 'dataTable' && typeof props['rows'] === 'string') out.push(...tableCells(props['rows']))\n return out\n}\n\n/** Where a node sends a visitor: a page, an address, a section of the page. */\nfunction hasDestination(node: SiteImportFidelityNode | undefined): boolean {\n if (!node) return false\n const props = node.props ?? {}\n return !!clean(props['screenId']) || !!clean(props['href']) || !!clean(props['to']) || (node.interactions?.length ?? 0) > 0\n}\n\nconst BUTTON_VARIANT: Readonly<Record<SiteImportButtonStyle, string>> = { primary: 'contained', secondary: 'outlined', quiet: 'text' }\n\n/** A section's band as the compiler draws it: a dark scheme, the paper ground, the brand fill, else plain. */\nexport function siteImportFidelityBandOf(node: SiteImportFidelityNode | undefined): SiteImportBand {\n if (node?.props?.['colorScheme'] === 'dark') return 'dark'\n const ground = node?.sx?.['bgcolor']\n if (ground === 'background.paper') return 'soft'\n if (ground === 'primary.main') return 'brand'\n return 'plain'\n}\n\n/** The node a stored page or layout hangs from: the canvas root, else the one with no parent. */\nexport function siteImportFidelityTreeOf(nodes: Readonly<Record<string, SiteImportFidelityNode>>): SiteImportFidelityTree {\n const ids = Object.keys(nodes)\n const rootId = nodes['_@_'] ? '_@_' : (ids.find((id) => !nodes[id]?.parentId) ?? ids[0] ?? '_@_')\n return { rootId, nodes }\n}\n\n/*------------------------------------------\n * The built page, walked once\n *-----------------------------------------*/\n\ninterface Piece {\n node: string\n text: string\n /** Its words, joined: what lines are compared by. */\n key: string\n at: number\n}\n\n/** A built tree in document order: each node's span, its parent, and the words each shows. */\nclass Built {\n readonly order: string[] = []\n private readonly enter = new Map<string, number>()\n private readonly exit = new Map<string, number>()\n readonly parent = new Map<string, string>()\n readonly pieces: Piece[] = []\n\n constructor(readonly tree: SiteImportFidelityTree) {\n const seen = new Set<string>()\n const visit = (id: string, parent: string | null) => {\n if (seen.has(id) || !tree.nodes[id]) return\n seen.add(id)\n if (parent) this.parent.set(id, parent)\n const at = this.order.length\n this.enter.set(id, at)\n this.order.push(id)\n for (const text of shownTexts(tree.nodes[id])) this.pieces.push({ node: id, text, key: wordLine(text), at })\n for (const child of tree.nodes[id]?.nodes ?? []) visit(child, id)\n this.exit.set(id, this.order.length - 1)\n }\n visit(tree.rootId, null)\n }\n\n node(id: string): SiteImportFidelityNode | undefined {\n return this.tree.nodes[id]\n }\n\n /** A node's place in document order; -1 for one not on the page. */\n at(id: string): number {\n return this.enter.get(id) ?? -1\n }\n\n /** A node and the nodes holding it, nearest first, up to the page's root. */\n ancestry(id: string): string[] {\n const out: string[] = []\n for (let at: string | undefined = id; at; at = this.parent.get(at)) out.push(at)\n return out\n }\n\n /** Whether `a` is `b` or holds it. */\n holds(a: string, b: string): boolean {\n const start = this.enter.get(a)\n const end = this.exit.get(a)\n const point = this.enter.get(b)\n return start !== undefined && end !== undefined && point !== undefined && point >= start && point <= end\n }\n\n /** The nodes under one, itself included, in document order. */\n under(id: string): string[] {\n const start = this.enter.get(id)\n const end = this.exit.get(id)\n return start === undefined || end === undefined ? [] : this.order.slice(start, end + 1)\n }\n\n children(id: string): string[] {\n return (this.tree.nodes[id]?.nodes ?? []).filter((child) => this.enter.has(child))\n }\n\n /** The deepest node holding every one of `ids`. */\n common(ids: readonly string[]): string | null {\n if (!ids.length) return null\n for (let at: string | undefined = ids[0]; at; at = this.parent.get(at)) {\n if (ids.every((id) => this.holds(at as string, id))) return at\n }\n return null\n }\n\n /** Whether any node under `id` (itself included) is one `test` takes. */\n has(id: string, test: (node: SiteImportFidelityNode) => boolean): boolean {\n return this.under(id).some((at) => {\n const node = this.tree.nodes[at]\n return !!node && test(node)\n })\n }\n}\n\nconst ratioKept = (source: number, built: number): SiteImportFidelityCount => ({ source, built, ratio: source > 0 ? Math.min(1, built / source) : 1 })\n\nconst ratioBoth = (source: number, built: number): SiteImportFidelityCount => ({\n source,\n built,\n ratio: Math.max(source, built) > 0 ? Math.min(source, built) / Math.max(source, built) : 1,\n})\n\n/*------------------------------------------\n * The page\n *-----------------------------------------*/\n\n/**\n * Each line of the source found on the built page (AGL-4109): the element\n * showing its words, or the picture the library copy of it is. A line is\n * looked for in its own section, nearest after the line before it; an\n * element holds one line, or the run of lines a build joins into one (a\n * list item's words, a quote's).\n */\nclass Placement {\n /** Line → the node showing it. */\n readonly of = new Map<SiteImportLineRef, string>()\n /** Line → the words it is shown in, where a rewrite placed it (AGL-4152). */\n readonly rewrittenAs = new Map<SiteImportLineRef, string>()\n private readonly claimedBy = new Map<Piece, SiteImportLineRef>()\n private readonly imageClaimed = new Set<string>()\n /** Each section's pieces, in order. */\n private readonly scopes: Piece[][] = []\n\n constructor(\n private readonly built: Built,\n private readonly source: SiteImportFidelitySource,\n sectionRoots: ReadonlyArray<string | null>,\n ) {\n const photoOf = new Map<string, string>()\n for (const photo of source.photos ?? []) if (photo.from) photoOf.set(photo.from, photo.src)\n source.layout.sections.forEach((section, index) => {\n const root = sectionRoots[index] ?? built.tree.rootId\n const scope = new Set(built.under(root))\n const pieces = built.pieces.filter((piece) => scope.has(piece.node))\n this.scopes[index] = pieces\n // A film's poster is placed as its Video element's (AGL-4140).\n const images = built.under(root).filter((id) => built.node(id)?.componentId === 'image' || built.node(id)?.componentId === 'video')\n let cursor = -1\n let previous: SiteImportLineRef | null = null\n // Each line's own words, so a line found only in part never takes a piece another line is shown in whole (AGL-4152).\n const own = new Set(section.lines.flatMap((ref) => {\n const line = source.blocks[ref]\n return isLine(line) && line.kind !== 'image' ? [wordLine(clean(line.text))] : []\n }))\n for (const ref of section.lines) {\n const block = source.blocks[ref]\n if (!isLine(block)) continue\n if (block.kind === 'image') {\n const src = photoOf.get(block.url)\n const found = src ? images.find((id) => !this.imageClaimed.has(id) && built.node(id)?.props?.[built.node(id)?.componentId === 'video' ? 'poster' : 'src'] === src) : undefined\n if (found) {\n this.imageClaimed.add(found)\n this.of.set(ref, found)\n }\n previous = ref\n continue\n }\n const piece = this.find(pieces, clean(block.text), cursor, previous, own)\n if (piece) {\n this.claimedBy.set(piece, ref)\n this.of.set(ref, piece.node)\n cursor = piece.at\n }\n previous = ref\n }\n })\n }\n\n /** The piece showing a line: its words exactly, else a part of them (a long paragraph split), else the run it was joined into. */\n private find(pieces: readonly Piece[], text: string, cursor: number, previous: SiteImportLineRef | null, own: ReadonlySet<string> = new Set()): Piece | null {\n const key = wordLine(text)\n if (!key) return null\n const free = (piece: Piece) => {\n const owner = this.claimedBy.get(piece)\n // A piece holds one line, or the lines a build joined: the one before this one.\n return owner === undefined || owner === previous\n }\n // The nearest to the line placed before it: a build keeps a section's lines in their order, near enough.\n const pick = (list: Piece[]) =>\n list.reduce<Piece | null>((best, piece) => {\n if (!best) return piece\n const gap = Math.abs(piece.at - cursor)\n const bestGap = Math.abs(best.at - cursor)\n return gap < bestGap || (gap === bestGap && piece.at >= cursor && best.at < cursor) ? piece : best\n }, null)\n // A line of marks a build joined to the line before it (a \"—\" beside its label) is in that line's piece,\n // never the same mark further down the page, which would leave that one's line with nothing.\n if (!wordsOf(text).length && previous !== null) {\n const joined = pieces.find((piece) => this.claimedBy.get(piece) === previous && clean(piece.text) !== text && clean(piece.text).endsWith(text))\n if (joined) return joined\n }\n const exact = pieces.filter((piece) => piece.key === key && this.claimedBy.get(piece) === undefined)\n if (exact.length) return pick(exact)\n const padded = ` ${key} `\n // A reworded heading that reads \"…, and agencies build a hundred\" never takes the card titled \"Agencies\".\n const part = pieces.filter((piece) => free(piece) && piece.key && !(piece.key !== key && own.has(piece.key)) && (` ${piece.key} `.includes(padded) || padded.includes(` ${piece.key} `)))\n return pick(part)\n }\n\n /**\n * The lines a rewrite changed (G4), placed after the lines found as\n * written: in each section, each run of lines still unplaced is set to the\n * free pieces between the lines placed either side of it, in order, each\n * piece to one line, the pairs sharing most content words chosen. A line a\n * rewrite dropped has no piece to take, and stays unplaced.\n */\n placeRewritten(): void {\n this.source.layout.sections.forEach((section, index) => {\n const pieces = this.scopes[index] ?? []\n const lines = section.lines.filter((ref) => isLine(this.source.blocks[ref]) && this.source.blocks[ref]?.kind !== 'image')\n let run: SiteImportLineRef[] = []\n let from = -1\n const settle = (to: number) => {\n if (run.length) this.align(run, pieces.filter((piece) => piece.at >= from && piece.at <= to && this.claimedBy.get(piece) === undefined))\n run = []\n }\n for (const ref of lines) {\n const node = this.of.get(ref)\n if (node === undefined) {\n run.push(ref)\n continue\n }\n const at = this.built.at(node)\n settle(at)\n from = at\n }\n settle(Number.POSITIVE_INFINITY)\n // A line its neighbors leave no room for (one drawn out of the source's order) is looked for among the section's free pieces.\n const left = lines.filter((ref) => !this.of.has(ref))\n if (left.length) this.align(left, pieces.filter((piece) => this.claimedBy.get(piece) === undefined))\n })\n }\n\n /** A run of lines set to free pieces in order (G4): as many pairs as can be, then the most content kept. */\n private align(lines: readonly SiteImportLineRef[], pieces: readonly Piece[]): void {\n if (!lines.length || !pieces.length) return\n const text = (ref: SiteImportLineRef) => clean((this.source.blocks[ref] as { text?: string } | undefined)?.text)\n const best: number[][] = Array.from({ length: lines.length + 1 }, () => new Array<number>(pieces.length + 1).fill(0))\n for (let i = 1; i <= lines.length; i += 1) {\n for (let j = 1; j <= pieces.length; j += 1) {\n const pair = (best[i - 1]?.[j - 1] ?? 0) + 1 + contentKept(text(lines[i - 1] as number), (pieces[j - 1] as Piece).text)\n ;(best[i] as number[])[j] = Math.max(pair, best[i - 1]?.[j] ?? 0, best[i]?.[j - 1] ?? 0)\n }\n }\n for (let i = lines.length, j = pieces.length; i > 0 && j > 0; ) {\n const here = best[i]?.[j] ?? 0\n if (here === (best[i - 1]?.[j] ?? 0)) i -= 1\n else if (here === (best[i]?.[j - 1] ?? 0)) j -= 1\n else {\n const ref = lines[i - 1] as SiteImportLineRef\n const piece = pieces[j - 1] as Piece\n this.claimedBy.set(piece, ref)\n this.of.set(ref, piece.node)\n this.rewrittenAs.set(ref, piece.text)\n i -= 1\n j -= 1\n }\n }\n }\n\n /** The pieces of the page's sections no line of the source claimed, nor holds as a part of its words: lines the page added. */\n unclaimed(): Piece[] {\n const pieces = [...new Set(this.scopes.flat())]\n const said = this.source.layout.sections.flatMap((section) => section.lines).map((ref) => ` ${wordLine(clean((this.source.blocks[ref] as { text?: string } | undefined)?.text))} `)\n return pieces.filter((piece) => this.claimedBy.get(piece) === undefined && !!piece.key && !said.some((line) => line.includes(` ${piece.key} `)))\n }\n\n /** The nodes a list of lines is shown by, and whether every one of them was found. */\n nodesOf(refs: readonly SiteImportLineRef[]): { nodes: string[]; whole: boolean; measured: boolean } {\n const nodes: string[] = []\n let whole = true\n let measured = false\n const pictures = !!this.source.photos?.length\n for (const ref of refs) {\n const block = this.source.blocks[ref]\n if (!isLine(block)) continue\n if (block.kind === 'image' && !pictures) continue\n measured = true\n const node = this.of.get(ref)\n if (node) nodes.push(node)\n else whole = false\n }\n return { nodes, whole, measured }\n }\n}\n\n/** One part of the source's structure (an item, a cell), found on the built page. */\ninterface Unit {\n nodes: string[]\n whole: boolean\n measured: boolean\n /** The element holding all of it and nothing of the parts beside it. */\n element: string | null\n}\n\n/**\n * Units found on the page, each as the element of its own (AGL-4109): the\n * highest element holding its lines and none of the other units' lines. A\n * unit whose lines are not held apart from another's (thirteen cards' titles\n * in one stack under their thirteen lines) has no element of its own.\n */\nfunction unitsOn(built: Built, placement: Placement, parts: ReadonlyArray<readonly SiteImportLineRef[]>, stop: string | null): Unit[] {\n const found = parts.map((refs) => placement.nodesOf(refs))\n return found.map((part, index) => {\n const others = found.flatMap((other, at) => (at === index ? [] : other.nodes))\n const anchor = built.common(part.nodes)\n if (!anchor || others.some((node) => built.holds(anchor, node))) return { ...part, element: null }\n let element = anchor\n for (let up = built.parent.get(element); up && up !== stop && !others.some((node) => built.holds(up as string, node)); up = built.parent.get(up)) {\n element = up\n if (built.node(up)?.componentId === 'section') break\n }\n return { ...part, element }\n })\n}\n\n/** Whether a node lays its children side by side: a Grid container, or a Stack set in a row. */\nfunction setsSideBySide(node: SiteImportFidelityNode | undefined): boolean {\n if (!node) return false\n const props = node.props ?? {}\n if (node.componentId === 'muiGrid') return props['container'] === true || props['container'] === 'true'\n if (node.componentId === 'muiStack') return props['direction'] === 'row' || (typeof props['direction'] === 'string' && /\\b(?:sm|md|lg):row\\b/.test(props['direction']))\n return false\n}\n\n/**\n * Whether a row of the source is a byline: one cell a lone picture, the other\n * a few words (a writer's portrait beside their name and date), which the\n * build draws as the portrait, small, over its words (AGL-4107), not as two\n * columns across the page.\n */\nfunction isByline(source: SiteImportFidelitySource, cells: ReadonlyArray<{ nodes: SiteImportLayoutNode[] }>): boolean {\n if (cells.length !== 2) return false\n const at = cells.findIndex((cell) => cell.nodes.length === 1 && cell.nodes[0]?.kind === 'picture')\n if (at === -1) return false\n const words = cells[1 - at]?.nodes ?? []\n if (!words.every((node) => node.kind === 'line')) return false\n const count = words.reduce((total, node) => {\n const block = node.kind === 'line' ? source.blocks[node.line] : undefined\n return total + (block && block.kind !== 'image' ? wordsOf(clean(block.text)).length : 0)\n }, 0)\n return count > 0 && count <= 12\n}\n\n/** Every node of a section's layout, rows, cells and tab panels opened, in order. */\nfunction layoutNodes(nodes: readonly SiteImportLayoutNode[]): SiteImportLayoutNode[] {\n const out: SiteImportLayoutNode[] = []\n const visit = (list: readonly SiteImportLayoutNode[]) => {\n for (const node of list) {\n out.push(node)\n if (node.kind === 'row') for (const cell of node.cells) visit(cell.nodes)\n if (node.kind === 'tabs') for (const tab of node.tabs) visit(tab.panel)\n }\n }\n visit(nodes)\n return out\n}\n\n/** Every line a list of layout nodes places, rows, groups, tables and tabs opened. */\nfunction linesOf(nodes: readonly SiteImportLayoutNode[]): SiteImportLineRef[] {\n const out: SiteImportLineRef[] = []\n for (const node of layoutNodes(nodes)) {\n if (node.kind === 'line' || node.kind === 'picture') out.push(node.line)\n else if (node.kind === 'group') for (const item of node.items) out.push(...item.lines)\n else if (node.kind === 'table') for (const row of node.rows) for (const cell of row.cells) out.push(...cell.lines)\n else if (node.kind === 'tabs') for (const tab of node.tabs) if (tab.label !== null) out.push(tab.label)\n }\n return out\n}\n\n/**\n * A built page scored against its source (AGL-4109): the words, each once;\n * the sections and their bands; the rows of columns; the groups by kind, each\n * item an element of its own with its parts; the tables, tabs, pictures,\n * icons, buttons, headings and forms. The score is the lowest ratio of the\n * structure.\n *\n * Scored with a `finish` or its `words` (AGL-4152), the page is scored as\n * that finish asks, with the measures it adds; with neither, as before.\n */\nexport function siteImportFidelity(source: SiteImportFidelitySource, tree: SiteImportFidelityTree, options: SiteImportFidelityOptions = {}): SiteImportPageFidelity {\n const finished = !!options.finish || !!options.words\n // An import that names no finish reads as Keep my site (AGL-4152).\n const finish: AiSiteImportFinish = options.finish ?? 'keep'\n const improvedWords = options.words === 'improved'\n const theme = options.theme ?? null\n // Keep my site holds the buttons to the source's case and fill too.\n const pinned = finished && finish === 'keep'\n const built = new Built(tree)\n const sections = source.layout.sections\n const drawnSections = built.children(tree.rootId)\n // The build draws each of the source's sections as one, in order; a page whose count differs is searched whole.\n const aligned = drawnSections.length === sections.length\n const roots = sections.map((_, index) => (aligned ? (drawnSections[index] ?? null) : null))\n const placement = new Placement(built, source, roots)\n // Lines a rewrite changed are found by their place and their content (G4).\n if (improvedWords) placement.placeRewritten()\n const look = new LookOf(built, source.layout.look, theme)\n\n const words = wordsScore(source, built, finish === 'improve')\n // Improved, a page's bands are read as its colors alone say; kept, against its page's ground (AGL-4152).\n const read = sections.map((section) => (finished && finish === 'improve' ? (section.absoluteBand ?? section.band) : section.band))\n const drawn = drawnSections.map((id) => siteImportFidelityBandOf(built.node(id)))\n const bandsKept = read.filter((band, index) => drawn[index] === band).length\n\n const rows = { source: 0, built: 0 }\n const groups: Partial<Record<SiteImportGroupKind, { groups: number; groupsKept: number; items: number; itemsKept: number }>> = {}\n const tables = { source: 0, built: 0 }\n const tabs = { source: 0, built: 0 }\n const buttons = { source: 0, built: 0, unlinked: 0 }\n // Keep my site's buttons in the source's case, and its filled ones in its fill (AGL-4152).\n const buttonCase = { source: 0, built: 0 }\n const buttonFill = { source: 0, built: 0 }\n const buttonOutline = { source: 0, built: 0 }\n const boxed = { source: 0, built: 0 }\n const icons = { source: 0, built: 0, lone: 0 }\n // The films drawn as the Video element, playing from an address (AGL-4140).\n const drawnFilms = built.order.filter((id) => built.node(id)?.componentId === 'video' && !!clean(built.node(id)?.props?.['src'])).length\n const films = drawnFilms > 0\n /** Whether a button of the source is drawn in its style, going where it goes; under Keep my site, in its case and fill too. */\n const buttonKept = (line: SiteImportLineRef, style: SiteImportButtonStyle): boolean => {\n const id = placement.of.get(line)\n const drawnAs = id ? built.node(id) : undefined\n const drawn = drawnAs?.componentId === 'muiButton' && drawnAs.props?.['variant'] === BUTTON_VARIANT[style] && hasDestination(drawnAs)\n if (!pinned) return drawn\n const cased = look.caseKept(id ?? null, style)\n if (cased !== null) {\n buttonCase.source += 1\n if (drawn && cased) buttonCase.built += 1\n }\n const filled = style === 'primary' ? look.fillKept(id ?? null) : null\n if (filled !== null) {\n buttonFill.source += 1\n if (drawn && filled) buttonFill.built += 1\n }\n const outlined = style === 'secondary' ? look.outlineKept(id ?? null) : null\n if (outlined !== null) {\n buttonOutline.source += 1\n if (drawn && outlined) buttonOutline.built += 1\n }\n return drawn && cased !== false && filled !== false && outlined !== false\n }\n\n sections.forEach((section, index) => {\n const root = roots[index] ?? null\n for (const node of layoutNodes(section.nodes)) {\n switch (node.kind) {\n case 'icon':\n icons.lone += 1\n break\n case 'line': {\n const block = source.blocks[node.line]\n if (!node.button) {\n // A link standing on its own is drawn as a text button: under Keep my site it is held to the source's case as one (AGL-4152).\n const id = placement.of.get(node.line)\n if (pinned && block?.kind === 'link' && id && built.node(id)?.componentId === 'muiButton') {\n buttons.source += 1\n if (buttonKept(node.line, 'quiet')) buttons.built += 1\n }\n break\n }\n // A button whose words say it plays a film plays the page's film where one is drawn (AGL-4140).\n if (block?.kind === 'paragraph' && films && SITE_IMPORT_PLAY_WORDS.test(block.text)) {\n buttons.source += 1\n if (buttonKept(node.line, node.button)) buttons.built += 1\n break\n }\n // A button that goes nowhere a page can send a visitor (a film's play button its script runs) is kept as its words.\n if (block?.kind !== 'link' || !/^(?:https?:|mailto:|tel:)/i.test(block.href)) {\n buttons.unlinked += 1\n break\n }\n buttons.source += 1\n if (buttonKept(node.line, node.button)) buttons.built += 1\n break\n }\n case 'row': {\n const cells = node.cells.filter((cell) => linesOf(cell.nodes).length)\n if (cells.length < 2 || isByline(source, cells)) break\n rows.source += 1\n const units = unitsOn(built, placement, cells.map((cell) => linesOf(cell.nodes)), root)\n const parents = new Set(units.map((unit) => (unit.element ? built.parent.get(unit.element) : null)))\n const parent = parents.size === 1 ? [...parents][0] : null\n if (units.every((unit) => unit.whole && unit.element) && parent && setsSideBySide(built.node(parent))) rows.built += 1\n break\n }\n case 'group': {\n // Improved, a link every item repeats is shown once after the group (AGL-4152): no item holds it.\n const shared = finish === 'improve' ? sharedLinkLines(source.blocks, node.items) : null\n const units = unitsOn(built, placement, node.items.map((item) => (shared ? item.lines.filter((line) => !shared.has(line)) : item.lines)), root)\n // Each item's own icon and its bullets' marks, in the element that is the item.\n node.items.forEach((item, at) => {\n // Its corner arrow too (AGL-4138): a card's \"↗\" is an icon of its own.\n const wanted = (item.icon !== undefined ? 1 : 0) + (item.mark !== undefined ? 1 : 0) + (item.listIcon !== undefined ? (item.list?.length ?? 0) : 0)\n if (!wanted) return\n icons.source += wanted\n const element = units[at]?.element\n if (element) icons.built += Math.min(wanted, built.under(element).filter((id) => built.node(id)?.componentId === 'icon').length)\n })\n // Lines that only share a shape are drawn as their lines: no group to keep.\n if (node.group === 'text') break\n // Its items boxed where the source boxes them, open where it leaves them open (AGL-4152).\n const judged = units.filter((unit) => unit.measured && unit.element)\n if (finished && boxesKept(node) && judged.length) {\n boxed.source += 1\n if (judged.every((unit) => boxedOn(built, unit) === node.boxed)) boxed.built += 1\n }\n const entry = (groups[node.group] ??= { groups: 0, groupsKept: 0, items: 0, itemsKept: 0 })\n let kept = 0\n let measured = 0\n node.items.forEach((item, at) => {\n const unit = units[at] as Unit\n if (!unit.measured) return\n measured += 1\n if (itemKept(built, node.group, item, unit)) kept += 1\n })\n entry.groups += 1\n entry.items += measured\n entry.itemsKept += kept\n if (measured > 0 && kept === measured) entry.groupsKept += 1\n break\n }\n case 'table': {\n tables.source += 1\n const cells = node.rows.flatMap((row) => row.cells.map((cell) => wordLine(cell.lines.map((ref) => clean((source.blocks[ref] as { text?: string })?.text)).join(' '))).filter(Boolean))\n // The theme's Table element, every cell of the source's in it.\n const kept = built.under(root ?? tree.rootId).some((id) => {\n const drawnAs = built.node(id)\n if (drawnAs?.componentId !== 'dataTable' || typeof drawnAs.props?.['rows'] !== 'string') return false\n const shown = new Set(tableCells(drawnAs.props['rows']).map(wordLine))\n return cells.every((cell) => shown.has(cell))\n })\n if (kept) tables.built += 1\n break\n }\n case 'tabs': {\n tabs.source += 1\n const labels = node.tabs.flatMap((tab) => (tab.label !== null ? [tab.label] : []))\n const found = placement.nodesOf(labels)\n if (!found.whole || !found.nodes.length) break\n // The Tabs element names every tab itself; a strip draws each label as an element of its own, side by side.\n const one = new Set(found.nodes).size === 1\n const strip = built.common(found.nodes)\n if (one ? built.node(found.nodes[0] as string)?.componentId === 'muiTabs' : !!strip && setsSideBySide(built.node(strip))) tabs.built += 1\n break\n }\n default:\n break\n }\n }\n })\n\n const pictures = picturesScore(source, built, placement)\n const framing = framingScore(source, built, placement)\n const headings = headingsScore(source, built, placement)\n const widths = widthsScore(sections, built, roots)\n const forms = ratioBoth(\n sections.reduce((total, section) => total + layoutNodes(section.nodes).filter((node) => node.kind === 'form').length, 0),\n built.order.filter((id) => built.node(id)?.componentId === 'form').length,\n )\n // A film playing behind a section's words is drawn as its poster there, and is the pictures' to count.\n const videos = ratioKept(\n sections.reduce(\n (total, section) => total + layoutNodes(section.nodes).reduce((count, node) => count + (node.kind === 'video' ? 1 : node.kind === 'group' ? node.items.filter((item) => item.video !== undefined).length : 0), 0),\n 0,\n ),\n drawnFilms,\n )\n\n const report: Omit<SiteImportPageFidelity, 'score' | 'lowest'> = {\n words,\n sections: ratioBoth(sections.length, drawnSections.length),\n bands: { ...ratioKept(read.length, bandsKept), read, drawn },\n widths,\n rows: ratioKept(rows.source, rows.built),\n groups: Object.fromEntries(\n Object.entries(groups).map(([kind, entry]) => [kind, { groups: ratioKept(entry.groups, entry.groupsKept), items: ratioKept(entry.items, entry.itemsKept) }]),\n ),\n tables: ratioKept(tables.source, tables.built),\n tabs: ratioKept(tabs.source, tabs.built),\n pictures,\n ...(source.concealed ? { concealed: concealedScore(source, built) } : {}),\n ...galleriesScore(source, built, placement),\n framing,\n icons: { ...ratioKept(icons.source, icons.built), lone: icons.lone },\n buttons: { ...ratioKept(buttons.source, buttons.built), unlinked: buttons.unlinked },\n headings,\n forms,\n videos,\n }\n if (!finished) return { ...lowestOf(pageMeasures(report)), ...report }\n\n // The measures a finish adds (AGL-4152).\n if (pinned) report.buttons = { ...report.buttons, case: ratioKept(buttonCase.source, buttonCase.built), fill: ratioKept(buttonFill.source, buttonFill.built), outline: ratioKept(buttonOutline.source, buttonOutline.built) }\n const added: Partial<SiteImportPageFidelity> = {\n scoredAs: { finish, words: improvedWords ? 'improved' : 'kept' },\n free: finish === 'improve' ? [...SITE_IMPORT_IMPROVE_FREE, ...(improvedWords ? ['words'] : [])] : improvedWords ? ['words'] : [],\n align: alignScore(source, built, placement, pinned),\n boxed: ratioKept(boxed.source, boxed.built),\n ground: groundScore(sections, look, roots, pinned),\n ...(pinned ? { darkGround: darkGroundScore(sections, look, roots) } : {}),\n measure: measureScore(source, built, placement, roots),\n readable: look.readable(drawnSections),\n ...(finish === 'improve' ? { design: designScore(source, built, placement, look, roots, drawnSections) } : {}),\n ...(improvedWords ? wordingScores(source, built, placement) : {}),\n }\n const full = { ...report, ...added }\n if (options.improved && finish === 'improve') {\n const improved = improvedScore(source, built, look, drawnSections, options.improved)\n const ledger = Object.entries(improved.ledger) as Array<[string, SiteImportImprovedLine]>\n // A redesign plans its own sections: what it scores on is what its ledger held, and the lowest of those.\n const lowest = ledger.reduce<[string, number] | null>((least, [name, line]) => {\n const ratio = line.of > 0 ? Math.min(1, line.done / line.of) : 1\n return !line.ok && (!least || ratio < least[1]) ? [name, ratio] : least\n }, null)\n return { ...full, improved, score: lowest ? lowest[1] : 1, lowest: lowest ? lowest[0] : null }\n }\n return { ...lowestOf(finishMeasures(full)), ...full }\n}\n\n/**\n * The measures a finished page is scored on (AGL-4152). Keep my site: the\n * structure and the look's pins, its words held apart. Improve it: the\n * content alone, its words among it unless they were improved; everything it\n * may change prints as free.\n */\nfunction finishMeasures(report: Omit<SiteImportPageFidelity, 'score' | 'lowest'>): Array<[string, SiteImportFidelityCount]> {\n const free = new Set(report.free ?? [])\n const pins: Array<[string, SiteImportFidelityCount | undefined]> = [\n ['align', report.align],\n ['boxed', report.boxed],\n ['ground', report.ground],\n ['darkGround', report.darkGround],\n ['measure', report.measure],\n ]\n const words: Array<[string, SiteImportFidelityCount]> = report.scoredAs?.finish === 'improve' && !free.has('words') ? [['words', report.words]] : []\n return [...words, ...pageMeasures(report), ...pins.filter((entry): entry is [string, SiteImportFidelityCount] => !!entry[1])].filter(([name]) => !free.has(name))\n}\n\n/**\n * Whether a page ships (AGL-4109, AGL-4152): its score at the bar, and what\n * is held at exactly 1 whole. Its words, as written, or under improved words\n * every fact and every line, and each line's meaning at the floor; under\n * Keep my site, its alignment, boxes, grounds in both schemes and measure.\n */\nexport function siteImportFidelityHolds(report: SiteImportPageFidelity, threshold = SITE_IMPORT_FIDELITY_THRESHOLD): boolean {\n if (report.improved) return report.improved.holds\n if (report.score < threshold) return false\n const improvedWords = report.scoredAs?.words === 'improved'\n if (improvedWords ? report.facts?.ratio !== 1 || report.lines?.ratio !== 1 || (report.meaning?.below ?? 0) > 0 : report.words.ratio !== 1) return false\n if (report.scoredAs?.finish !== 'keep') return true\n return [report.align, report.boxed, report.ground, report.darkGround, report.measure].every((count) => !count || count.ratio === 1)\n}\n\n/** Whether an item of a group is kept: its own element, every line of it found, and the parts its kind and source say it has. */\nfunction itemKept(built: Built, kind: SiteImportGroupKind, item: SiteImportLayoutItem, unit: Unit): boolean {\n if (!unit.whole || !unit.element) return false\n const element = unit.element\n // A question opens its answer: the theme's accordion.\n if (kind === 'faq' && !built.has(element, (node) => node.componentId === 'muiAccordion')) return false\n // An item the source made a link as a whole still goes there.\n if (item.to && !built.has(element, hasDestination)) return false\n // A picture of the item's own, where the library's copy is not known to the score; a film's poster is its Video element's (AGL-4140).\n if (item.image !== undefined && !built.has(element, (node) => node.componentId === 'image' || node.componentId === 'video')) return false\n return true\n}\n\n/** The link lines of a group's items that every item carries, the same words to the same place: one call to action, said on each. */\nfunction sharedLinkLines(blocks: readonly SiteImportBlock[], items: ReadonlyArray<{ lines: readonly SiteImportLineRef[] }>): Set<SiteImportLineRef> {\n if (items.length < 2) return new Set()\n const keyOf = (line: SiteImportLineRef) => {\n const block = blocks[line]\n return block?.kind === 'link' && !block.inline ? `${wordLine(clean(block.text)).toLowerCase()}\\u0000${block.href}` : null\n }\n const each = items.map((item) => new Set(item.lines.flatMap((line) => keyOf(line) ?? [])))\n const common = [...(each[0] ?? [])].filter((key) => each.every((keys) => keys.has(key)))\n return new Set(items.flatMap((item) => item.lines.filter((line) => common.includes(keyOf(line) ?? ''))))\n}\n\n/**\n * The words: the source's lines against what the page shows, each word as\n * often as it is said. Improved, a link said again with the same words to the\n * same place may be shown once or as often as it is said (AGL-4152): the page\n * shows each call to action once, and a page drawn as before is no worse.\n */\nfunction wordsScore(source: SiteImportFidelitySource, built: Built, improve = false): SiteImportFidelityWords {\n const tally = (lines: readonly string[]) => {\n const counts = new Map<string, number>()\n for (const word of lines.flatMap(wordsOf)) counts.set(word, (counts.get(word) ?? 0) + 1)\n return counts\n }\n const links = new Set<string>()\n const again = (block: SiteImportBlock) => {\n if (!improve || block.kind !== 'link') return false\n const key = `${wordLine(clean(block.text)).toLowerCase()}\\u0000${block.href}`\n if (links.has(key)) return true\n links.add(key)\n return false\n }\n const lines = source.blocks.filter((block): block is Exclude<SiteImportBlock, { kind: 'image' }> => isLine(block) && block.kind !== 'image')\n const full = tally(lines.map((block) => clean(block.text)))\n const least = tally(lines.filter((block) => !again(block)).map((block) => clean(block.text)))\n const shown = tally(built.pieces.map((piece) => piece.text))\n // Each word as often as the page shows it, between the least the source asks and all it says.\n const said = new Map([...full].map(([word, count]) => [word, Math.min(count, Math.max(least.get(word) ?? 0, shown.get(word) ?? 0))]))\n let sourceWords = 0\n let builtWords = 0\n let both = 0\n const missing: string[] = []\n const extra: string[] = []\n for (const [word, count] of said) {\n sourceWords += count\n const on = shown.get(word) ?? 0\n both += Math.min(count, on)\n if (on < count) missing.push(word)\n }\n for (const [word, count] of shown) {\n builtWords += count\n if (count > (said.get(word) ?? 0)) extra.push(word)\n }\n const most = Math.max(sourceWords, builtWords)\n return {\n source: sourceWords,\n built: builtWords,\n missing: sourceWords - both,\n extra: builtWords - both,\n ratio: most > 0 ? both / most : 1,\n examples: { missing: missing.slice(0, 8), extra: extra.slice(0, 8) },\n }\n}\n\nconst WIDTH_RANK: Readonly<Record<SiteImportWidth, number>> = { sm: 0, md: 1, lg: 2, xl: 3 }\n\n/** The sections as wide as their source: each section's Container against the cap the source sets; a section nothing caps runs the whole page. */\nfunction widthsScore(sections: readonly SiteImportLayoutSection[], built: Built, roots: ReadonlyArray<string | null>): SiteImportFidelityCount {\n const kept = sections.filter((section, index) => {\n const wanted = siteImportWidthOf(section.width)\n if (!wanted) return true\n const root = roots[index]\n if (!root) return false\n const container = built.under(root).find((id) => built.node(id)?.componentId === 'muiContainer' && !built.node(id)?.props?.['disableGutters'])\n if (!container) return true\n const rank = WIDTH_RANK[built.node(container)?.props?.['maxWidth'] as SiteImportWidth]\n return rank !== undefined && rank >= WIDTH_RANK[wanted]\n })\n return ratioKept(sections.length, kept.length)\n}\n\n/** The pictures: placed where the library's copies are known, else counted. */\nfunction picturesScore(source: SiteImportFidelitySource, built: Built, placement: Placement): SiteImportFidelityCount {\n const refs = source.layout.sections.flatMap((section) => section.lines).filter((ref) => source.blocks[ref]?.kind === 'image' && isLine(source.blocks[ref]))\n // A film's poster is a picture drawn, on its Video element (AGL-4140).\n const drawn = built.order.filter((id) => built.node(id)?.componentId === 'image' || (built.node(id)?.componentId === 'video' && !!clean(built.node(id)?.props?.['poster']))).length\n if (!source.photos?.length) return ratioBoth(refs.length, drawn)\n return ratioKept(refs.length, refs.filter((ref) => placement.of.has(ref)).length)\n}\n\n/**\n * The source's galleries drawn as galleries (AGL-4152): every photo of one\n * placed, each an Image cropped to fill its cell, in a row of columns. A photo\n * drawn as a mark (fitted whole, as small as a logo) is a gallery lost.\n */\nfunction galleriesScore(source: SiteImportFidelitySource, built: Built, placement: Placement): Pick<SiteImportPageFidelity, 'galleries'> {\n const galleries = source.layout.sections.flatMap((section) => layoutNodes(section.nodes)).filter((node): node is SiteImportLayoutGroup => node.kind === 'group' && !!node.gallery)\n if (!galleries.length) return {}\n const drawn = galleries.filter((group) =>\n group.items.every((item) =>\n item.lines.every((ref) => {\n if (source.blocks[ref]?.kind !== 'image') return true\n const id = placement.of.get(ref)\n const node = id ? built.node(id) : undefined\n if (node?.componentId !== 'image' || node.props?.['objectFit'] === 'contain' || node.props?.['width'] === 'auto') return false\n return built.ancestry(id as string).some((at) => setsSideBySide(built.node(at)))\n }),\n ),\n )\n return { galleries: ratioKept(galleries.length, drawn.length) }\n}\n\n/** What a visitor of the source cannot see and a visitor of the build can (AGL-4152): a hidden picture, or a line that is only a screen reader's label. */\nfunction concealedScore(source: SiteImportFidelitySource, built: Built): SiteImportFidelityCount {\n const pictures = new Set(source.concealed?.pictures ?? [])\n const copies = new Set((source.photos ?? []).flatMap((photo) => (photo.from && pictures.has(photo.from) ? [photo.src] : [])))\n const drawn = built.order.filter((id) => {\n const src = clean(built.node(id)?.props?.['src'])\n return built.node(id)?.componentId === 'image' && (pictures.has(src) || copies.has(src))\n }).length\n const labels = new Set((source.concealed?.words ?? []).map(wordLine))\n const said = built.pieces.filter((piece) => labels.has(piece.key)).length\n const found = drawn + said\n return { source: 0, built: found, ratio: found ? 0 : 1 }\n}\n\n/** How near two shapes must be to be one (AGL-4138): 5%. */\nconst SAME_SHAPE = 0.05\n\n/** A box's shape as the compiler writes it, width over height: \"1600 / 900\", \"1.7778\", 1.5. */\nfunction shapeOf(value: unknown): number | null {\n if (typeof value === 'number') return value > 0 ? value : null\n if (typeof value !== 'string') return null\n const match = /^\\s*(\\d*\\.?\\d+)\\s*(?:\\/\\s*(\\d*\\.?\\d+))?\\s*$/.exec(value)\n if (!match) return null\n const width = Number(match[1])\n const height = match[2] === undefined ? 1 : Number(match[2])\n return width > 0 && height > 0 ? width / height : null\n}\n\n/** A height in px as the compiler writes one: \"320px\", 320. */\nfunction heightOf(value: unknown): number | null {\n if (typeof value === 'number') return value > 1 ? value : null\n const match = typeof value === 'string' ? /^\\s*(\\d*\\.?\\d+)px\\s*$/.exec(value) : null\n return match ? Number(match[1]) : null\n}\n\n/**\n * The box a built picture is shown in: its own `aspectRatio` or height, else\n * the frame holding it alone that sets one; `whole` where nothing frames it, or\n * it is fitted inside its box (`contain`), which cuts nothing.\n */\nfunction builtFrame(built: Built, id: string): { ratios: number[]; height: number | null } | 'whole' {\n const image = built.node(id)\n if (!image) return 'whole'\n if (image.props?.['objectFit'] === 'contain') return 'whole'\n const read = (node: SiteImportFidelityNode | undefined): { ratios: number[]; height: number | null } | null => {\n const sx = node?.sx ?? {}\n const height = heightOf(node?.componentId === 'image' ? (node.props?.['height'] ?? sx['height']) : sx['height'])\n if (height !== null) return { ratios: [], height }\n const ratio = sx['aspectRatio']\n const ratios = (ratio && typeof ratio === 'object' ? Object.values(ratio) : [ratio]).map(shapeOf).filter((value): value is number => value !== null)\n return ratios.length ? { ratios, height: null } : null\n }\n const own = read(image)\n if (own) return own\n const frame = built.parent.get(id)\n const holder = frame ? built.node(frame) : undefined\n if (holder && built.children(frame as string).length === 1 && holder.componentId === 'muiBox') return read(holder) ?? 'whole'\n return 'whole'\n}\n\n/**\n * The pictures framed as their source frames them (AGL-4138): each placed\n * picture's box against the shape the source shows it at — the box or the\n * height it crops it to, else its own, by the library's copy's size or its\n * `width` and `height` — within 5%; a picture the source shows whole may be\n * shown in no box. A round portrait and the picture a section lays behind\n * its words are not scored, nor a picture whose own shape is not known.\n */\nfunction framingScore(source: SiteImportFidelitySource, built: Built, placement: Placement): SiteImportFidelityCount {\n const sizes = new Map<string, number>()\n for (const photo of source.photos ?? []) if (photo.from && photo.width && photo.height) sizes.set(photo.from, photo.width / photo.height)\n let measured = 0\n let kept = 0\n const score = (ref: SiteImportLineRef, fit: SiteImportPictureFit | undefined) => {\n const block = source.blocks[ref]\n const id = placement.of.get(ref)\n if (block?.kind !== 'image' || !id || (fit?.radius ?? 0) >= 999) return\n const frame = builtFrame(built, id)\n const own = sizes.get(block.url) ?? fit?.ratio ?? null\n if (fit?.height) {\n measured += 1\n if (frame !== 'whole' && frame.height !== null && Math.abs(frame.height / fit.height - 1) <= SAME_SHAPE) kept += 1\n return\n }\n const wanted = fit?.box ?? own\n if (wanted === null || wanted === undefined) return\n measured += 1\n if (frame === 'whole') {\n if (!fit?.box) kept += 1\n return\n }\n if (frame.height === null && frame.ratios.every((ratio) => Math.abs(ratio / wanted - 1) <= SAME_SHAPE)) kept += 1\n }\n for (const section of source.layout.sections) {\n // A picture the section lays behind its words fills the band, as it is meant to.\n const behind = section.hero?.picture === 'behind' ? section.lines.find((ref) => source.blocks[ref]?.kind === 'image') : undefined\n for (const node of layoutNodes(section.nodes)) {\n if (node.kind === 'picture' && node.line !== behind) score(node.line, node.fit)\n // A film's poster is framed as any picture is (AGL-4140).\n if (node.kind === 'video' && node.poster !== undefined && node.poster !== behind) score(node.poster, node.fit)\n // A gallery crops its photos to one shape so its rows line up (AGL-4152): `galleries` holds it.\n if (node.kind === 'group' && !node.gallery) for (const item of node.items) if (item.image !== undefined && item.image !== behind) score(item.image, item.imageFit)\n }\n }\n return ratioKept(measured, kept)\n}\n\n/** The headings: each of the source's drawn as a heading (an `h1`–`h6`, or the question of an accordion). */\nfunction headingsScore(source: SiteImportFidelitySource, built: Built, placement: Placement): SiteImportFidelityCount {\n // Words a source sets in a heading and groups as a customer's quote are that quote (AGL-4152), no part of the page's outline.\n const quoted = new Set(source.layout.sections.flatMap((section) => layoutNodes(section.nodes)).flatMap((node) => (node.kind === 'group' && node.group === 'quotes' ? node.items.flatMap((item) => item.lines) : [])))\n const refs = source.layout.sections.flatMap((section: SiteImportLayoutSection) => section.lines).filter((ref) => source.blocks[ref]?.kind === 'heading' && !quoted.has(ref))\n const kept = refs.filter((ref) => {\n const id = placement.of.get(ref)\n const node = id ? built.node(id) : undefined\n return !!node && (/^h[1-6]$/.test(String(node.props?.['component'] ?? '')) || node.componentId === 'muiAccordionSummary')\n })\n return ratioKept(refs.length, kept.length)\n}\n\n/** Every structural measure of a page by name, groups by kind. */\nfunction pageMeasures(report: Omit<SiteImportPageFidelity, 'score' | 'lowest'>): Array<[string, SiteImportFidelityCount]> {\n return [\n ['sections', report.sections],\n ['bands', report.bands],\n ['widths', report.widths],\n ['rows', report.rows],\n ...Object.entries(report.groups).map(([kind, entry]): [string, SiteImportFidelityCount] => [`${kind} items`, entry.items]),\n ['tables', report.tables],\n ['tabs', report.tabs],\n ['pictures', report.pictures],\n ['framing', report.framing],\n ['icons', report.icons],\n ['buttons', report.buttons],\n ['headings', report.headings],\n ['forms', report.forms],\n ['videos', report.videos],\n ...(report.concealed ? [['concealed', report.concealed] as [string, SiteImportFidelityCount]] : []),\n ...(report.galleries ? [['galleries', report.galleries] as [string, SiteImportFidelityCount]] : []),\n ]\n}\n\n/** The score: the lowest ratio, and the measure it came from. */\nfunction lowestOf(measures: ReadonlyArray<[string, SiteImportFidelityCount]>): { score: number; lowest: string | null } {\n let score = 1\n let lowest: string | null = null\n for (const [name, count] of measures) {\n if (count.ratio < score) {\n score = count.ratio\n lowest = name\n }\n }\n return { score, lowest }\n}\n\n/*------------------------------------------\n * The finish: the look kept, the design improved, the words held (AGL-4152)\n *-----------------------------------------*/\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/** What a path of keys holds in a record, or `undefined`. */\nconst pathIn = (value: unknown, ...keys: string[]): unknown => keys.reduce<unknown>((node, key) => (isRecord(node) ? node[key] : undefined), value)\n\nconst round = (value: number) => Math.round(value * 1000) / 1000\n\n/** A color as `#rrggbb`, or `null` for anything else. */\nfunction hexOf(value: unknown): string | null {\n if (typeof value !== 'string' || !/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(value.trim())) return null\n const hex = value.trim().toLowerCase()\n return hex.length === 4 ? `#${[...hex.slice(1)].map((digit) => digit + digit).join('')}` : hex\n}\n\n/** How far apart two `#rrggbb` colors sit in OKLab (AGL-4152). */\nexport function siteImportOklabDelta(a: string, b: string): number {\n const one = aiHexOklch(a)\n const two = aiHexOklch(b)\n const at = (color: { C: number; h: number }, part: 'a' | 'b') => color.C * (part === 'a' ? Math.cos((color.h * Math.PI) / 180) : Math.sin((color.h * Math.PI) / 180))\n return Math.hypot(one.L - two.L, at(one, 'a') - at(two, 'a'), at(one, 'b') - at(two, 'b'))\n}\n\n/** The contrast an ink and its ground read at: the doctrine's 4.5:1. */\nconst READS_AT = 4.5\n\nconst reads = (ink: string, ground: string) => (contrastRatio(ink, ground) ?? 0) >= READS_AT\n\nfunction schemeOf(colors: unknown): SiteImportFidelityScheme | null {\n if (!isRecord(colors)) return null\n const scheme: SiteImportFidelityScheme = {\n ground: hexOf(pathIn(colors, 'background', 'default')),\n paper: hexOf(pathIn(colors, 'background', 'paper')),\n brand: hexOf(pathIn(colors, 'primary', 'main')),\n onBrand: hexOf(pathIn(colors, 'primary', 'contrastText')),\n ink: hexOf(pathIn(colors, 'text', 'primary')),\n brandLight: hexOf(pathIn(colors, 'primary', 'light')),\n divider: hexOf(pathIn(colors, 'divider')),\n }\n return Object.values(scheme).some(Boolean) ? scheme : null\n}\n\n/** A color a style names, in a scheme: a palette path (`primary.main`) as the scheme draws it, a color as itself. */\nfunction colorIn(value: unknown, scheme: SiteImportFidelityScheme): string | null {\n const own = hexOf(value)\n if (own || typeof value !== 'string') return own\n const paths: Readonly<Record<string, string | null>> = {\n 'primary.main': scheme.brand,\n 'primary.contrastText': scheme.onBrand,\n 'background.default': scheme.ground,\n 'background.paper': scheme.paper,\n 'text.primary': scheme.ink,\n 'primary.light': scheme.brandLight ?? null,\n divider: scheme.divider ?? null,\n 'common.white': '#ffffff',\n 'common.black': '#000000',\n }\n return paths[value] ?? null\n}\n\n/** The color a theme draws an outlined button's words in, in its light scheme: its own style's, else the brand's. */\nexport function siteImportOutlinedColorOf(theme: SiteImportFidelityTheme): string | null {\n const named = theme.button.outlined?.text\n return named === null || named === undefined ? theme.light.brand : colorIn(named, theme.light)\n}\n\n/** A CSS `text-transform` as the case a button's words are set in. */\nconst CASE_OF: Readonly<Record<string, 'upper' | 'none'>> = { uppercase: 'upper', none: 'none', capitalize: 'none', lowercase: 'none' }\n\n/**\n * The colors and buttons of a theme, as a page is drawn in them (AGL-4152):\n * each scheme's grounds, brand and ink, and a filled button's own fill and\n * label where the button's component style sets them apart from the brand's\n * (a `contained` variant, or the contained style overrides), with the case\n * its words are set in: the component's own, else the button Text Style's.\n * `from` says whether the theme is the one the site stores or one computed\n * from its site style. `null` for a theme with no light ground.\n */\nexport function siteImportFidelityThemeOf(theme: unknown, from: SiteImportFidelityTheme['from'] = 'theme'): SiteImportFidelityTheme | null {\n const light = schemeOf(pathIn(theme, 'colorSchemes', 'light'))\n if (!light?.ground) return null\n const button = pathIn(theme, 'components', 'MuiButton')\n const variants = pathIn(button, 'variants')\n /** A variant's styles, the one that wins first: the last of the variants, then its style overrides. */\n const stylesOf = (variant: 'contained' | 'outlined' | 'text') => {\n const own = (Array.isArray(variants) ? variants : []).filter((entry) => {\n const color = pathIn(entry, 'props', 'color')\n return pathIn(entry, 'props', 'variant') === variant && (color === undefined || color === 'primary')\n })\n return [...[...own].reverse().flatMap((entry) => [pathIn(entry, 'sx'), pathIn(entry, 'style')]), pathIn(button, 'styleOverrides', `${variant}Primary`), pathIn(button, 'styleOverrides', variant)].filter(isRecord)\n }\n const contained = stylesOf('contained')\n const dark = schemeOf(pathIn(theme, 'colorSchemes', 'dark'))\n const pickIn = (scheme: SiteImportFidelityScheme, ...keys: string[]) => contained.flatMap((style) => keys.map((key) => colorIn(style[key], scheme))).find((color): color is string => !!color) ?? null\n const pick = (...keys: string[]) => pickIn(light, ...keys)\n const transform = [\n pathIn(button, 'styleOverrides', 'root', 'textTransform'),\n pathIn(button, 'sx', 'root', 'textTransform'),\n pathIn(theme, 'typography', 'variants', 'button', 'textTransform'),\n pathIn(theme, 'typography', 'button', 'textTransform'),\n ].find((value): value is string => typeof value === 'string')\n const caseIn = (styles: ReadonlyArray<Record<string, unknown>>): 'upper' | 'none' | null => {\n const own = [...styles.map((style) => style['textTransform']), transform].find((value): value is string => typeof value === 'string')\n return own ? (CASE_OF[own] ?? null) : null\n }\n const outlined = stylesOf('outlined')\n const named = (...keys: string[]) => outlined.flatMap((style) => keys.map((key) => style[key])).find((value) => value !== undefined) ?? null\n return {\n from,\n light,\n dark,\n button: {\n fill: pick('backgroundColor', 'bgcolor', 'background'),\n label: pick('color'),\n ...(dark ? { fillDark: pickIn(dark, 'backgroundColor', 'bgcolor', 'background'), labelDark: pickIn(dark, 'color') } : {}),\n case: caseIn(contained),\n outlined: { text: named('color'), border: named('borderColor'), fill: named('backgroundColor', 'bgcolor', 'background'), case: caseIn(outlined) },\n text: { case: caseIn(stylesOf('text')) },\n },\n }\n}\n\n/** How near the page a fill sits and is the page's own, in OKLab: the look's own line for a fill to be drawn as one. */\nconst LIKE_THE_PAGE = 0.1\n\n/** The look a built page is drawn in, read through its theme: each node's scheme, a section's ground and ink, a button's case and fill. */\nclass LookOf {\n constructor(\n private readonly built: Built,\n private readonly facts: SiteImportLayout['look'] | null | undefined,\n readonly theme: SiteImportFidelityTheme | null,\n ) {}\n\n /** The scheme a node is drawn in: the one the nearest node holding it sets. */\n scheme(id: string): SiteImportFidelityScheme | null {\n if (!this.theme) return null\n for (const at of this.built.ancestry(id)) {\n const scheme = this.built.node(at)?.props?.['colorScheme']\n if (scheme === 'dark') return this.theme.dark\n if (scheme === 'light') return this.theme.light\n }\n return this.theme.light\n }\n\n /** The color a section is drawn on: its band's role in its scheme. */\n ground(id: string): string | null {\n const scheme = this.scheme(id)\n const fill = this.built.node(id)?.sx?.['bgcolor']\n return scheme ? (fill === undefined || fill === null ? scheme.ground : colorIn(fill, scheme)) : null\n }\n\n /** The words' ink on that ground: the brand's label on a brand band, the scheme's ink elsewhere. */\n ink(id: string): string | null {\n const scheme = this.scheme(id)\n return scheme ? (this.built.node(id)?.sx?.['bgcolor'] === 'primary.main' ? scheme.onBrand : scheme.ink) : null\n }\n\n /** A filled button's fill: its own, else the theme's for filled buttons, else its scheme's brand. */\n fill(id: string): string | null {\n const scheme = this.scheme(id)\n if (!scheme) return null\n const own = this.built.node(id)?.sx?.['bgcolor'] ?? this.built.node(id)?.sx?.['backgroundColor']\n if (own !== undefined) return colorIn(own, scheme)\n const button = this.theme?.button\n return (scheme === this.theme?.dark ? (button?.fillDark ?? button?.fill) : button?.fill) ?? scheme.brand\n }\n\n /** A filled button's label: its own, else the theme's for filled buttons, else the words on its scheme's brand. */\n label(id: string): string | null {\n const scheme = this.scheme(id)\n if (!scheme) return null\n const own = this.built.node(id)?.sx?.['color']\n if (own !== undefined) return colorIn(own, scheme)\n const button = this.theme?.button\n return (scheme === this.theme?.dark ? (button?.labelDark ?? button?.label) : button?.label) ?? scheme.onBrand\n }\n\n /**\n * Whether a button is set in its style's case in the source: its own\n * `textTransform`, else the theme's for that style. A read made before each\n * style's case was kept holds its filled buttons' alone. `null` where either\n * is not known.\n */\n caseKept(id: string | null, style: SiteImportButtonStyle): boolean | null {\n const facts = this.facts\n const wanted = style === 'primary' ? facts?.buttonCase : style === 'secondary' ? (facts?.outlinedCase === undefined ? facts?.buttonCase : facts.outlinedCase) : facts?.textCase === undefined ? facts?.buttonCase : facts.textCase\n if (wanted !== 'upper' && wanted !== 'none') return null\n const own = id ? this.built.node(id)?.sx?.['textTransform'] : undefined\n const button = this.theme?.button\n const themed = style === 'primary' ? button?.case : style === 'secondary' ? (button?.outlined?.case ?? button?.case) : (button?.text?.case ?? button?.case)\n const drawn = typeof own === 'string' ? (CASE_OF[own] ?? 'none') : (themed ?? null)\n return drawn === null ? null : drawn === wanted\n }\n\n /**\n * Whether a filled button is drawn in the source's own fill, within OKLab ΔE\n * 0.05, whatever its label: a light fill under a label that cannot be read\n * on it keeps the fill and takes a label that can. A fill that sits on the\n * page like the page is no fill the look can keep: a white button on a near\n * white page reads as its border. `null` where either is not known.\n */\n fillKept(id: string | null): boolean | null {\n const wanted = hexOf(this.facts?.buttonFill)\n if (!wanted || !this.theme) return null\n if (siteImportOklabDelta(wanted, this.page()) < LIKE_THE_PAGE) return null\n const drawn = id ? this.fill(id) : (this.theme.button.fill ?? this.theme.light.brand)\n return drawn ? siteImportOklabDelta(wanted, drawn) <= SITE_IMPORT_GROUND_DELTA : null\n }\n\n /**\n * Whether an outlined button is drawn as the source draws its own: no fill\n * of its own where it sets none, and its words and border in its color,\n * within OKLab ΔE 0.1. On a dark band, which the source's color was not\n * read for, in the scheme's brand. `null` where either is not known.\n */\n outlineKept(id: string | null): boolean | null {\n const wanted = hexOf(this.facts?.buttonOutline)\n if (!wanted || !this.theme) return null\n const scheme = (id ? this.scheme(id) : null) ?? this.theme.light\n const style = this.theme.button.outlined\n const fill = style?.fill ?? null\n const ownFill = hexOf(this.facts?.outlinedFill)\n const filled = fill !== null && fill !== 'transparent' && fill !== 'none'\n if (ownFill ? !filled || siteImportOklabDelta(ownFill, colorIn(fill, scheme) ?? ownFill) > SITE_IMPORT_GROUND_DELTA : filled) return false\n const near = (color: string | null, to: string | null | undefined) => !!color && !!to && siteImportOklabDelta(color, to) <= SITE_IMPORT_OUTLINE_DELTA\n const named = [style?.text, style?.border].map((color) => (color === null || color === undefined ? scheme.brand : colorIn(color, scheme)))\n // A grey or a black of the source's is its words' color: the theme's words are their own ink, not a pin.\n const light = aiHexOklch(wanted).C < 0.03 ? scheme.ink : wanted\n return named.every((color) => (scheme === this.theme?.light ? near(color, light) : near(color, scheme.brand) || near(color, scheme.brandLight) || near(color, scheme.ink)))\n }\n\n /** The source's page ground: white where it sets none. */\n page(): string {\n return hexOf(this.facts?.background) ?? '#ffffff'\n }\n\n /** The color a section is drawn on in the theme's dark scheme: its band's role there. `null` where the theme has no dark scheme. */\n darkGround(id: string): string | null {\n const scheme = this.theme?.dark ?? null\n if (!scheme) return null\n const fill = this.built.node(id)?.sx?.['bgcolor']\n return fill === undefined || fill === null ? scheme.ground : colorIn(fill, scheme)\n }\n\n /** The inks and grounds the page shows: each section's, and each filled button's label on its fill, once each. */\n pairs(sectionIds: readonly string[]): Array<[string, string]> {\n if (!this.theme) return []\n const out = new Map<string, [string, string]>()\n const add = (ink: string | null, ground: string | null) => {\n if (ink && ground) out.set(`${ink}/${ground}`, [ink, ground])\n }\n for (const id of sectionIds) add(this.ink(id), this.ground(id))\n for (const id of this.built.order) {\n const node = this.built.node(id)\n if (node?.componentId === 'muiButton' && node.props?.['variant'] === 'contained') add(this.label(id), this.fill(id))\n }\n return [...out.values()]\n }\n\n /** The inks and grounds that read at 4.5:1, over those the theme says. */\n readable(sectionIds: readonly string[]): SiteImportFidelityCount {\n const pairs = this.pairs(sectionIds)\n return ratioKept(pairs.length, pairs.filter(([ink, ground]) => reads(ink, ground)).length)\n }\n}\n\n/**\n * The groups whose boxing is scored (AGL-4152): a group drawn as the source's\n * own rows draws no box per row, and an FAQ's questions are the theme's\n * accordions, boxed as the theme boxes them.\n */\nfunction boxesKept(group: SiteImportLayoutGroup): boolean {\n return !group.inline && group.group !== 'faq' && group.group !== 'text'\n}\n\n/** Whether a node draws a box: a card or a paper, or a fill, a shadow or a border on two sides or more of its own. */\nfunction drawsBox(node: SiteImportFidelityNode | undefined): boolean {\n if (!node || node.componentId === 'section') return false\n if (node.componentId === 'muiCard' || node.componentId === 'muiPaper') return true\n const sx = node.sx ?? {}\n const sides = ['borderTop', 'borderRight', 'borderBottom', 'borderLeft'].filter((side) => !!sx[side]).length\n return (sx['bgcolor'] !== undefined && sx['bgcolor'] !== 'transparent') || !!sx['border'] || sides >= 2 || (!!sx['boxShadow'] && sx['boxShadow'] !== 'none')\n}\n\n/** Whether an item of a group is drawn boxed: a box under its element holding every part of it. */\nfunction boxedOn(built: Built, unit: Unit): boolean {\n if (!unit.element) return false\n return built.under(unit.element).some((id) => drawsBox(built.node(id)) && unit.nodes.every((node) => built.holds(id, node)))\n}\n\n/** The lines a section sets in its own flow: its lines and its rows' cells', not its groups', tables' or tabs'. */\nfunction flowLines(nodes: readonly SiteImportLayoutNode[]): SiteImportLineRef[] {\n return nodes.flatMap((node) => (node.kind === 'line' && !node.button ? [node.line] : node.kind === 'row' ? node.cells.flatMap((cell) => flowLines(cell.nodes)) : []))\n}\n\n/** The paragraphs past which a section is a long read, set at `md` and at the start (the compile's own count). */\nconst LONG_READ_PARAGRAPHS = 4\n\n/** Whether a section of the source is a long read: more paragraphs in its own flow (not its groups') than a section's words, which a page sets at the start to be read. */\nconst longRead = (source: SiteImportFidelitySource, section: SiteImportLayoutSection) => flowLines(section.nodes).filter((ref) => source.blocks[ref]?.kind === 'paragraph').length > LONG_READ_PARAGRAPHS\n\n/**\n * The sections set as the source sets them (AGL-4152): their headings, else\n * their words, centered or at the start; a long read set at the start, as\n * text is read, is kept whatever its source centers. Under Keep my site the\n * opening a hero draws is held to it too: a centered opening drawn at the\n * start is the opening moved. Elsewhere it is the hero's to place.\n */\nfunction alignScore(source: SiteImportFidelitySource, built: Built, placement: Placement, pinned: boolean): SiteImportFidelityCount {\n let measured = 0\n let kept = 0\n for (const [index, section] of source.layout.sections.entries()) {\n if (index === 0 && section.hero?.picture && !pinned) continue\n const own = flowLines(section.nodes)\n const headings = own.filter((ref) => source.blocks[ref]?.kind === 'heading')\n const lines = (headings.length ? headings : own.filter((ref) => ['paragraph', 'list-item', 'quote'].includes(source.blocks[ref]?.kind ?? ''))).flatMap((ref) => {\n const id = placement.of.get(ref)\n const node = id ? built.node(id) : undefined\n return node?.componentId === 'muiTypography' ? [node] : []\n })\n if (!lines.length) continue\n measured += 1\n const centered = lines.filter((node) => node.props?.['align'] === 'center').length\n const drawn = centered * 2 > lines.length ? 'center' : 'start'\n if (drawn === section.align || (drawn === 'start' && longRead(source, section))) kept += 1\n }\n return ratioKept(measured, kept)\n}\n\n/** How far a ground may sit from its page's and still be its page's (AGL-4152), in OKLab. */\nconst SAME_GROUND = 0.02\n\n/** Where a ground sits against its page's: on it, lighter or darker. */\nfunction placeOn(ground: string, page: string): -1 | 0 | 1 {\n if (siteImportOklabDelta(ground, page) <= SAME_GROUND) return 0\n return aiHexOklch(ground).L > aiHexOklch(page).L ? 1 : -1\n}\n\n/**\n * Each section with a ground of its own on a ground of the theme within OKLab\n * ΔE 0.05 of it. A picture or a film behind its words is its ground, and is\n * not scored. `ordered`, under Keep my site (AGL-4152), in its place against\n * the page too: two near whites read alike by ΔE, and swapped they draw the\n * wrong bands dark in the dark scheme.\n */\nfunction groundScore(sections: readonly SiteImportLayoutSection[], look: LookOf, roots: ReadonlyArray<string | null>, ordered: boolean): NonNullable<SiteImportPageFidelity['ground']> {\n if (!look.theme) return { ...ratioKept(0, 0), theme: null, worst: null }\n const themePage = look.theme.light.ground as string\n let measured = 0\n let kept = 0\n let worst: number | null = null\n for (const [index, section] of sections.entries()) {\n const wanted = hexOf(section.background)\n if (!wanted || section.backdrop?.kind === 'picture' || section.backdrop?.kind === 'video') continue\n measured += 1\n const root = roots[index]\n const drawn = root ? look.ground(root) : null\n if (!drawn) continue\n const delta = siteImportOklabDelta(wanted, drawn)\n worst = Math.max(worst ?? 0, delta)\n if (delta <= SITE_IMPORT_GROUND_DELTA && (!ordered || placeOn(wanted, look.page()) === placeOn(drawn, themePage))) kept += 1\n }\n return { ...ratioKept(measured, kept), theme: look.theme.from, worst: worst === null ? null : round(worst) }\n}\n\n/**\n * The same sections in the theme's dark scheme (AGL-4152): on the source's own\n * dark fill within OKLab ΔE 0.05 where its stylesheets say one. Else as the\n * light page orders them, against the dark page: a section lighter than its\n * page draws lighter, one on its page's ground on the dark page, one darker\n * set apart from it, and a dark band of the source no lighter than the dark\n * page. A brand band is the brand's in either scheme, and is not scored.\n */\nfunction darkGroundScore(sections: readonly SiteImportLayoutSection[], look: LookOf, roots: ReadonlyArray<string | null>): NonNullable<SiteImportPageFidelity['darkGround']> {\n const darkPage = look.theme?.dark?.ground ?? null\n if (!darkPage) return { ...ratioKept(0, 0), worst: null }\n let measured = 0\n let kept = 0\n let worst: number | null = null\n for (const [index, section] of sections.entries()) {\n const wanted = hexOf(section.background)\n if (!wanted || section.band === 'brand' || section.backdrop?.kind === 'picture' || section.backdrop?.kind === 'video') continue\n measured += 1\n const root = roots[index]\n const drawn = root ? look.darkGround(root) : null\n if (!drawn) continue\n const own = hexOf(section.darkBackground)\n if (own) {\n const delta = siteImportOklabDelta(own, drawn)\n worst = Math.max(worst ?? 0, delta)\n if (delta <= SITE_IMPORT_GROUND_DELTA) kept += 1\n continue\n }\n const place = placeOn(drawn, darkPage)\n const wantedPlace = section.band === 'dark' ? -1 : placeOn(wanted, look.page())\n if (wantedPlace === -1 ? (section.band === 'dark' ? place <= 0 : place !== 0) : place === wantedPlace) kept += 1\n }\n return { ...ratioKept(measured, kept), worst: worst === null ? null : round(worst) }\n}\n\n/** The width a page is measured at (AGL-4152): the 1280 the 11/4 live checks set the source beside the import at. */\nconst VIEW_PX = 1280\n\n/** The Container element's Max Width steps, in px, as the theme's breakpoints set them. */\nconst CONTAINER_PX: Readonly<Record<string, number>> = { xs: 444, sm: 600, md: 900, lg: 1200, xl: 1536 }\n\n/** What a responsive value is at the width a page is measured at: its `lg`, else the nearest below. */\nfunction atView(value: unknown): unknown {\n if (!isRecord(value)) return value\n for (const key of ['lg', 'md', 'sm', 'xs']) if (value[key] !== undefined) return value[key]\n return undefined\n}\n\n/** A Grid item's columns, of 12, at the width a page is measured at: `xs:12 md:6` is 6. */\nfunction gridSpan(size: unknown): number | null {\n if (typeof size === 'number') return size\n const steps = typeof size === 'string' ? Object.fromEntries(size.split(/\\s+/).flatMap((part) => (/^(\\w+):(\\d+)$/.exec(part) ? [[part.split(':')[0], Number(part.split(':')[1])]] : []))) : isRecord(size) ? size : null\n const span = steps ? atView(steps) : null\n return typeof span === 'number' && span > 0 ? Math.min(12, span) : null\n}\n\n/** How wide a node's box runs at the width a page is measured at, in px, from its section down, and how wide its section's content runs. */\nfunction boxPx(built: Built, id: string, root: string | null): { box: number; section: number } {\n const chain = built.ancestry(id).reverse()\n const from = root ? chain.indexOf(root) : 0\n let width = VIEW_PX\n let section: number | null = null\n for (const at of chain.slice(Math.max(0, from))) {\n const node = built.node(at)\n if (!node) continue\n if (node.componentId === 'muiContainer') {\n const cap = CONTAINER_PX[String(atView(node.props?.['maxWidth']))]\n if (cap) width = Math.min(width, cap)\n section ??= width\n }\n if (node.componentId === 'muiGrid' && !setsSideBySide(node)) width *= (gridSpan(node.props?.['size']) ?? 12) / 12\n const max = atView(node.sx?.['maxWidth'])\n if (typeof max === 'number') width = max <= 1 ? width * max : Math.min(width, max)\n else if (typeof max === 'string' && CONTAINER_PX[max]) width = Math.min(width, CONTAINER_PX[max] as number)\n else if (typeof max === 'string' && /^\\d+(?:\\.\\d+)?%$/.test(max)) width *= parseFloat(max) / 100\n else if (typeof max === 'string' && /^\\d+(?:\\.\\d+)?px$/.test(max)) width = Math.min(width, parseFloat(max))\n }\n return { box: width, section: section ?? VIEW_PX }\n}\n\n/** The hero heading's box as a share of its section, against the source's measure: within 10%, where the reader kept it. */\nfunction measureScore(source: SiteImportFidelitySource, built: Built, placement: Placement, roots: ReadonlyArray<string | null>): NonNullable<SiteImportPageFidelity['measure']> {\n const index = source.layout.sections.findIndex((section) => !!section.hero)\n const section = source.layout.sections[index]\n const wanted = section?.hero?.measure\n if (!section || typeof wanted !== 'number' || !(wanted > 0)) return { ...ratioKept(0, 0), shares: null }\n const across = Math.min(section.width ?? VIEW_PX, VIEW_PX)\n const share = Math.min(1, wanted / across)\n const heading = section.lines.find((ref) => {\n const block = source.blocks[ref]\n return block?.kind === 'heading' && block.level === 1\n })\n const id = heading === undefined ? undefined : placement.of.get(heading)\n if (!id) return { ...ratioKept(1, 0), shares: { source: round(share), built: 0 } }\n const drawn = boxPx(built, id, roots[index] ?? null)\n const builtShare = Math.min(1, drawn.box / drawn.section)\n return { ...ratioKept(1, Math.abs(builtShare / share - 1) <= SITE_IMPORT_MEASURE_SHARE ? 1 : 0), shares: { source: round(share), built: round(builtShare) } }\n}\n\n/** How wide a section's words run at the width a page is measured at: its first Container's Max Width, else the page. */\nfunction runPx(built: Built, root: string | undefined | null): number {\n const container = root ? built.under(root).find((id) => built.node(id)?.componentId === 'muiContainer') : undefined\n const cap = container ? CONTAINER_PX[String(atView(built.node(container)?.props?.['maxWidth']))] : undefined\n return Math.min(cap ?? VIEW_PX, VIEW_PX)\n}\n\n/** A section's band as Improve it reads it: by its color alone. */\nconst bandAsItsColor = (section: SiteImportLayoutSection | undefined) => section?.absoluteBand ?? section?.band\n\n/** A line of the design measure: the share of what it asks the source and the build each do, `null` where neither is asked anything. */\nfunction designLine(source: [number, number], built: [number, number]): SiteImportDesignLine | null {\n if (!source[1] || !built[1]) return null\n return { source: round(source[0] / source[1]), built: round(built[0] / built[1]) }\n}\n\n/**\n * Whether the build reads better than its source (AGL-4152), line by line:\n * its rhythm, its measure, its opening, its groups and its colors. Better is\n * at or above the source on every line and above it on one.\n */\nfunction designScore(source: SiteImportFidelitySource, built: Built, placement: Placement, look: LookOf, roots: ReadonlyArray<string | null>, drawnSections: readonly string[]): SiteImportDesignFidelity {\n const sections = source.layout.sections\n // Rhythm: neighbors set apart by their bands, or a rule between them.\n const apart = (pairs: number, at: (index: number) => boolean): [number, number] => [Array.from({ length: pairs }, (_, index) => at(index)).filter(Boolean).length, pairs]\n const ruled = (id: string | undefined) => !!id && (!!built.node(id)?.sx?.['borderTop'] || !!built.node(id)?.sx?.['borderBottom'])\n const drawnBand = (id: string | undefined) => siteImportFidelityBandOf(id ? built.node(id) : undefined)\n const rhythm = designLine(\n apart(Math.max(0, sections.length - 1), (index) => bandAsItsColor(sections[index]) !== bandAsItsColor(sections[index + 1])),\n apart(Math.max(0, drawnSections.length - 1), (index) => drawnBand(drawnSections[index]) !== drawnBand(drawnSections[index + 1]) || ruled(drawnSections[index]) || ruled(drawnSections[index + 1])),\n )\n // Measure: words that run no wider than `lg`, a long read no wider than `md`, each section as its Container runs it.\n const caps = sections.map((section) => (longRead(source, section) ? (CONTAINER_PX['md'] as number) : (CONTAINER_PX['lg'] as number)))\n const measure = designLine(\n // The source's cap read as the Container step a page brought in draws it at; a section it sets none on runs the page.\n [sections.filter((section, index) => Math.min(CONTAINER_PX[siteImportWidthOf(section.width) ?? 'xl'] as number, VIEW_PX) <= (caps[index] as number)).length, sections.length],\n [drawnSections.filter((id, index) => runPx(built, id) <= (caps[index] ?? (CONTAINER_PX['lg'] as number))).length, drawnSections.length],\n )\n // Opening: a first section holding a picture opens as the hero, its heading and its picture together.\n const first = sections[0]\n const pictured = !!first && (first.lines.some((ref) => source.blocks[ref]?.kind === 'image') || first.backdrop?.kind === 'picture' || first.backdrop?.kind === 'video')\n const title = sections.flatMap((section) => section.lines).find((ref) => {\n const block = source.blocks[ref]\n return block?.kind === 'heading' && block.level === 1\n })\n const titleNode = title === undefined ? undefined : placement.of.get(title)\n const opener = drawnSections[0]\n const opens = !!opener && !!titleNode && built.holds(opener, titleNode) && built.has(opener, (node) => node.componentId === 'image' || node.componentId === 'video')\n const opening = pictured ? designLine([first?.hero?.picture ? 1 : 0, 1], [opens ? 1 : 0, 1]) : null\n // Grouped: three or more like items drawn as one group: each its own element, held together apart from the section's other lines.\n let runs = 0\n let sourceGrouped = 0\n let builtGrouped = 0\n for (const [index, section] of sections.entries()) {\n for (const node of layoutNodes(section.nodes)) {\n if (node.kind !== 'group' || node.items.length < 3) continue\n runs += 1\n if (node.group !== 'text') sourceGrouped += 1\n const units = unitsOn(built, placement, node.items.map((item) => item.lines), roots[index] ?? null).filter((unit) => unit.measured)\n const parents = new Set(units.map((unit) => (unit.element ? built.parent.get(unit.element) : null)))\n const parent = parents.size === 1 ? [...parents][0] : null\n const mine = new Set(node.items.flatMap((item) => item.lines))\n const others = section.lines.flatMap((ref) => (mine.has(ref) ? [] : [placement.of.get(ref)])).filter((id): id is string => !!id)\n if (units.length >= 3 && parent && units.every((unit) => unit.element) && !others.some((id) => built.holds(parent, id))) builtGrouped += 1\n }\n }\n const grouped = designLine([sourceGrouped, runs], [builtGrouped, runs])\n // Readable: the source's words on its grounds and its buttons' labels on their fill, against the build's.\n const facts = source.layout.look\n const sourcePairs: Array<[string, string]> = []\n const ink = hexOf(facts?.text)\n for (const section of sections) {\n const ground = hexOf(section.background)\n if (ink && ground && (bandAsItsColor(section) === 'plain' || bandAsItsColor(section) === 'soft')) sourcePairs.push([ink, ground])\n }\n const buttonFill = hexOf(facts?.buttonFill)\n const buttonText = hexOf(facts?.buttonText)\n if (buttonFill && buttonText) sourcePairs.push([buttonText, buttonFill])\n const builtPairs = look.pairs(drawnSections)\n const readable = designLine([sourcePairs.filter(([a, b]) => reads(a, b)).length, sourcePairs.length], [builtPairs.filter(([a, b]) => reads(a, b)).length, builtPairs.length])\n const lines = [rhythm, measure, opening, grouped, readable].filter((line): line is SiteImportDesignLine => !!line)\n const better = lines.length > 0 && lines.every((line) => line.built >= line.source) && lines.some((line) => line.built > line.source)\n return { rhythm, measure, opening, grouped, readable, better }\n}\n\n/*------------------------------------------\n * Improved words (G4)\n *-----------------------------------------*/\n\n/** The words that carry no content of a line: what a rewrite may change freely. */\nconst STOP_WORDS = new Set(\n 'a about all also an and any are as at be been but by can do does each for from get had has have he her here his how i if in into is it its just me more most my no not of on one only or our out over own so some such than that the their them then there these they this those to too up us very was we were what when where which who why will with you your yours'.split(' '),\n)\n\n/** A word's crude stem (G4): its case and one ending dropped, so \"builds\", \"building\" and \"build\" read as one word. */\nfunction stemOf(word: string): string {\n let stem = word.toLowerCase().replace(/['’]s$/, '')\n for (const [ending, to] of [\n [/ies$/, 'y'],\n [/ing$/, ''],\n [/ed$/, ''],\n [/ly$/, ''],\n [/(?<!s)s$/, ''],\n ] as const) {\n if (ending.test(stem) && stem.replace(ending, to).length >= 3) {\n stem = stem.replace(ending, to)\n break\n }\n }\n return stem.length > 3 ? stem.replace(/e$/, '') : stem\n}\n\n/** A line's content words, by stem. */\nconst contentOf = (text: string): Set<string> => new Set(wordsOf(text).filter((word) => word.length >= 2 && !STOP_WORDS.has(word.toLowerCase())).map(stemOf))\n\n/**\n * The share of a line's content words another keeps (G4): 1 for a line with\n * none. A rewrite's `meaning`, and the floor the wording pass holds each\n * rewritten line to (`ai-site-import-wording.ts`), so a rewrite it keeps\n * never scores under it here.\n */\nexport function siteImportContentKept(line: string, rewrite: string): number {\n return contentKept(line, rewrite)\n}\n\n/** How many content words a run of words says, by stem (AGL-4152): what a section says of its own. */\nexport function siteImportContentWords(text: string): number {\n return contentOf(text).size\n}\n\n/** The share of a line's content words another keeps: 1 for a line with none. */\nfunction contentKept(line: string, rewrite: string): number {\n const said = contentOf(line)\n if (!said.size) return 1\n const kept = contentOf(rewrite)\n return [...said].filter((stem) => kept.has(stem)).length / said.size\n}\n\n/** The facts a run of words carries, each by its kind, in the order they are taken: emails, addresses, phones, numbers. */\nconst FACTS: ReadonlyArray<readonly [string, RegExp, (found: string) => string | null]> = [\n ['email', /[\\p{L}\\p{N}._%+-]+@[\\p{L}\\p{N}-]+(?:\\.[\\p{L}\\p{N}-]+)+/gu, (found) => found.toLowerCase()],\n [\n 'url',\n /\\bhttps?:\\/\\/[^\\s<>\"'()]+|\\bwww\\.[^\\s<>\"'()]+|\\b(?:[a-z0-9-]+\\.)+(?:com|org|net|io|co|ai|app|dev|us|uk|ca|au|de|fr|info|biz|me|shop|store|site|online)\\b(?:\\/[^\\s<>\"'()]*)?/giu,\n (found) => found.toLowerCase().replace(/[.,;:!?]+$/, '').replace(/^https?:\\/\\//, '').replace(/^www\\./, '').replace(/\\/$/, ''),\n ],\n ['phone', /(?:\\+\\d{1,3}[\\s.-]?)?(?:\\(\\d{2,4}\\)[\\s.-]?)?\\d{2,4}[\\s.-]\\d{3,4}(?:[\\s.-]\\d{2,4})?/g, (found) => (found.replace(/\\D/g, '').length >= 7 ? found.replace(/\\D/g, '') : null)],\n ['number', /[$€£¥₹]?\\s?\\d+(?:[.,]\\d+)*\\s?%?/gu, (found) => found.replace(/\\s+/g, '').replace(/[.,]+$/, '')],\n]\n\n/** A line's facts: its prices and numbers with their currency, emails, phones and addresses, each as often as it says it. */\nfunction factsIn(text: string): string[] {\n let rest = text\n const out: string[] = []\n for (const [kind, pattern, normal] of FACTS) {\n rest = rest.replace(pattern, (found) => {\n const value = normal(found)\n if (!value) return found\n out.push(`${kind}:${value}`)\n return ' '.repeat(found.length)\n })\n }\n return out\n}\n\n/** The words of a line in capitals, each with whether it opens a sentence. */\nfunction capitalsIn(text: string): Array<{ word: string; opens: boolean; afterSubject: boolean }> {\n const out: Array<{ word: string; opens: boolean; afterSubject: boolean }> = []\n let last = 0\n let before = ''\n for (const match of text.matchAll(/[\\p{L}\\p{N}][\\p{L}\\p{N}'’]*/gu)) {\n const at = match.index ?? 0\n const opens = last === 0 || /[.!?:;•·|—–\"“(]/.test(text.slice(last, at))\n // \"We Specialize in…\", \"We Document every job\": a word straight after its sentence's subject is what it does, capitalized for show (AGL-4152).\n const afterSubject = !opens && SUBJECTS.has(before) && /^\\s+$/.test(text.slice(last, at))\n last = at + match[0].length\n before = match[0].toLowerCase()\n if (/^\\p{Lu}/u.test(match[0])) out.push({ word: match[0], opens, afterSubject })\n }\n return out\n}\n\n/** A web or an email address in a run of words, whose words are written small whatever they name. */\nconst ADDRESSES = /\\S+@\\S+|(?:https?:\\/\\/)?[\\p{L}\\p{N}-]+(?:\\.[\\p{L}\\p{N}-]+)+(?:\\/\\S*)?/gu\n\n/** The words a sentence's subject is said by, which the word after it acts for: never a name before a name. */\nconst SUBJECTS = new Set(['i', 'we', 'you', 'they'])\n\n/**\n * A name as it is matched on a page (AGL-4152): its possessive, its stops and\n * its hyphens dropped, in any case. \"HEB's\", \"HEB\", \"H-E-B\" and \"H.E.B.\" are\n * one store.\n */\nexport function siteImportNameKey(word: string): string {\n return word\n .replace(/['’]s$/iu, '')\n .replace(/[^\\p{L}\\p{N}]/gu, '')\n .toLowerCase()\n}\n\n/** Every name key a run of words says: each word, and each run of initials written with stops or hyphens (\"H-E-B\", \"H.E.B.\"). */\nfunction nameKeysIn(text: string): string[] {\n const words = wordsOf(text).map((word) => word.toLowerCase())\n const initials = [...text.matchAll(/(?<![\\p{L}\\p{N}])\\p{L}(?:[.-]\\p{L})+\\.?(?![\\p{L}\\p{N}])/gu)].map((match) => siteImportNameKey(match[0]))\n return [...words, ...initials]\n}\n\n/** Whether a line is set all in capitals or in title case: its capitals say nothing of its names. */\nfunction shouted(text: string): boolean {\n if (!/\\p{Ll}/u.test(text)) return true\n const long = wordsOf(text).filter((word) => word.length >= 4)\n return long.length >= 3 && long.every((word) => /^\\p{Lu}/u.test(word))\n}\n\n/** What a page's facts are told apart by (G4): the names its source says, and every word it says in any case. */\nexport interface SiteImportFactScope {\n /** Each word the source capitalizes past a sentence's first, in a line not set all in capitals. */\n names: ReadonlySet<string>\n /** Every word the source says, lowercased. */\n said: ReadonlySet<string>\n /**\n * Every word the source says, by its stem (AGL-4152): a heading set in title\n * case says \"Filing\" where the source says \"file\", which is no name.\n */\n stems?: ReadonlySet<string>\n}\n\n/**\n * The fact scope of a page's source lines. `vocabulary` is words a rewrite\n * may say that are no one's name and no one's fact (AGL-4152): the platform's\n * own words for what a page tells, which its request puts to the model\n * (\"why choose it\", \"how it works\"). They are said; they name and claim nothing.\n */\nexport function siteImportFactScope(sourceTexts: readonly string[], vocabulary: readonly string[] = []): SiteImportFactScope {\n const said = new Set([...sourceTexts, ...vocabulary].flatMap(wordsOf).map((word) => word.toLowerCase()))\n // A word the source also writes in small letters is an ordinary word, wherever it capitalizes it (AGL-4152);\n // never in an address, where a name is written small (\"example.app\").\n const small = new Set(sourceTexts.flatMap((text) => wordsOf(text.replace(ADDRESSES, ' '))).filter((word) => /^\\p{Ll}/u.test(word)))\n const names = sourceTexts\n .filter((text) => !shouted(text))\n .flatMap((text) => capitalsIn(text).filter((entry) => !entry.opens && entry.word.length > 1 && !entry.afterSubject && !small.has(entry.word.toLowerCase())).map((entry) => entry.word))\n return {\n names: new Set(names),\n said,\n stems: new Set([...said].map(stemOf)),\n }\n}\n\n/** Whether a scope says a word in any case or any of its endings. */\nconst saidIn = (scope: SiteImportFactScope, word: string) => scope.said.has(word.toLowerCase()) || !!scope.stems?.has(stemOf(word))\n\n/**\n * The fact tokens one line says (G4), each as often as it says it: its\n * prices and numbers with their currency, emails, web addresses and phones,\n * and its names. `own` is a rewrite's line, where a word capitalized past a\n * sentence's first that the source never says is a name the rewrite made up.\n * Two lines with the same tokens keep the same facts, which is how the\n * wording pass holds each line it rewrites (`ai-site-import-wording.ts`).\n */\nexport function siteImportFactTokens(text: string, scope: SiteImportFactScope, own: boolean): string[] {\n const out = factsIn(text)\n for (const entry of capitalsIn(text)) {\n if (scope.names.has(entry.word)) out.push(`name:${entry.word}`)\n // A name the source never says, past a sentence's first word, is one the rewrite made up.\n // A word every sentence uses (\"Us\", \"Our\", \"With\") is no one's name, capitalized in a title or not (AGL-4152).\n else if (own && !entry.opens && entry.word.length > 1 && !shouted(text) && !saidIn(scope, entry.word) && !STOP_WORDS.has(entry.word.toLowerCase())) out.push(`name:${entry.word}`)\n }\n return out\n}\n\n/**\n * The facts of a page's words (G4): every price and number with its\n * currency, email, phone and address, and every name — a word the source\n * capitalizes past a sentence's first — as often as the source says it,\n * and no fact or name the source does not have.\n */\nfunction factsScore(sourceTexts: readonly string[], builtTexts: readonly string[]): SiteImportFidelityFacts {\n const scope = siteImportFactScope(sourceTexts)\n const tally = (texts: readonly string[], own: boolean) => {\n const counts = new Map<string, number>()\n for (const text of texts) for (const token of siteImportFactTokens(text, scope, own)) counts.set(token, (counts.get(token) ?? 0) + 1)\n return counts\n }\n const from = tally(sourceTexts, false)\n const to = tally(builtTexts, true)\n let source = 0\n let builtCount = 0\n let both = 0\n const missing: string[] = []\n const extra: string[] = []\n for (const [token, count] of from) {\n source += count\n const on = to.get(token) ?? 0\n both += Math.min(count, on)\n if (on < count) missing.push(token)\n }\n for (const [token, count] of to) {\n builtCount += count\n if (count > (from.get(token) ?? 0)) extra.push(token)\n }\n const most = Math.max(source, builtCount)\n return { source, built: builtCount, missing: source - both, extra: builtCount - both, ratio: most > 0 ? both / most : 1, examples: { missing: missing.slice(0, 8), extra: extra.slice(0, 8) } }\n}\n\n/** A page's words improved (G4): its facts, its lines each placed once, and each rewrite's meaning. */\nfunction wordingScores(source: SiteImportFidelitySource, built: Built, placement: Placement): Pick<SiteImportPageFidelity, 'facts' | 'lines' | 'meaning'> {\n const text = (ref: SiteImportLineRef) => clean((source.blocks[ref] as { text?: string } | undefined)?.text)\n const lines = source.layout.sections.flatMap((section) => section.lines).filter((ref) => isLine(source.blocks[ref]) && source.blocks[ref]?.kind !== 'image')\n const placed = lines.filter((ref) => placement.of.has(ref)).length\n const extra = placement.unclaimed().length\n const rewritten = [...placement.rewrittenAs].flatMap(([ref, rewrite]) => (contentOf(text(ref)).size ? [{ line: ref, kept: round(contentKept(text(ref), rewrite)), source: text(ref), built: rewrite }] : []))\n const below = rewritten.filter((line) => line.kept < SITE_IMPORT_MEANING_FLOOR)\n return {\n facts: factsScore(source.blocks.flatMap((block) => (isLine(block) && block.kind !== 'image' ? [clean(block.text)] : [])), built.pieces.map((piece) => piece.text)),\n lines: { source: lines.length, built: placed, ratio: lines.length + extra > 0 ? placed / (lines.length + extra) : 1, extra },\n meaning: {\n lines: rewritten.length,\n below: below.length,\n lowest: rewritten.reduce((least, line) => Math.min(least, line.kept), 1),\n ratio: rewritten.length ? (rewritten.length - below.length) / rewritten.length : 1,\n floor: SITE_IMPORT_MEANING_FLOOR,\n examples: below.slice(0, 8),\n },\n }\n}\n\n/*------------------------------------------\n * A generative Improve it (AGL-4152)\n *-----------------------------------------*/\n\n/** The tallest a picture reads as framed on a wide screen, in px: past it, one picture is the whole screen. */\nconst FRAMED_PX = 600\n\n/** The tallest the picture a page opens on reads as framed: a hero may hold the screen. */\nconst FRAMED_OPENING_PX = 800\n\n/** The share of neighbors a page keeps on different grounds. */\nconst RHYTHM_SHARE = 0.75\n\n/** The widest fixed size a phone's screen holds, in px. */\nconst PHONE_PX = 360\n\n/** The tallest fixed picture a phone reads, in px. */\nconst PHONE_PICTURE_PX = 520\n\nconst line = (done: number, of: number, ok = done >= of): SiteImportImprovedLine => ({ done, of, ok })\n\n/** A piece that is only a number of a digit or two: a step's number, a count on a cart, no fact of the page's. */\nconst bareNumber = (text: string) => /^\\s*\\d{1,2}\\s*$/.test(text)\n\n/** A width over a height from how a frame writes it: `16 / 9`, `1.5`, or its value at the width a page is measured at. */\nfunction ratioOf(value: unknown): number | null {\n const at = atView(value)\n if (typeof at === 'number') return at > 0 ? at : null\n if (typeof at !== 'string') return null\n const parts = at.split('/').map((part) => Number.parseFloat(part))\n const [width, height] = parts as [number, number | undefined]\n if (!(width > 0)) return null\n return height === undefined ? width : height > 0 ? width / height : null\n}\n\n/** A height a node sets outright, in px; `null` for none, or one that follows the screen. */\nfunction fixedHeightOf(value: unknown): number | null {\n const at = atView(value)\n if (typeof at === 'number') return at > 8 ? at : null\n if (typeof at === 'string' && /^\\d+(?:\\.\\d+)?px$/.test(at)) return Number.parseFloat(at)\n return null\n}\n\n/** Whether a picture fills a frame that sets its own shape: laid over it, or at its whole height. */\nconst fillsFrame = (node: SiteImportFidelityNode | undefined) => node?.sx?.['position'] === 'absolute' || node?.props?.['height'] === '100%' || node?.sx?.['height'] === '100%'\n\n/** Whether a node shows a heading of the page's outline. */\n/** Elements that draw a run of like items as one group: a line inside one is no line stacked on its own. */\nconst GROUPS_A_RUN: ReadonlySet<string> = new Set(['muiAccordion', 'muiList', 'muiCard'])\n\nconst isHeading = (node: SiteImportFidelityNode | undefined) => {\n if (node?.componentId !== 'muiTypography') return false\n const tag = node.props?.['component'] ?? node.props?.['variant']\n return typeof tag === 'string' && /^h[2-6]$/.test(tag)\n}\n\n/** Whether a Grid cell keeps its place beside another on a phone, on more than two across. */\nconst crowdsPhone = (size: unknown) => {\n if (typeof size !== 'string') return false\n const xs = /\\bxs:(\\d+)\\b/.exec(size)?.[1]\n if (xs) return Number(xs) < 6\n return !/\\b(?:sm|md|lg):/.test(size) && size.trim() !== '' && Number(size) < 6\n}\n\n/** The kept ledger and the design lines of a page a generative Improve it built (AGL-4152). */\nfunction improvedScore(source: SiteImportFidelitySource, built: Built, look: LookOf, drawnSections: readonly string[], options: SiteImportImprovedOptions): SiteImportImprovedFidelity {\n const ledger = siteImportLedger({ layout: source.layout, blocks: source.blocks, ...(source.photos ? { photos: source.photos } : {}) })\n const pieces = built.pieces\n const sourceTexts = source.blocks.flatMap((block) => (isLine(block) && block.kind !== 'image' ? [clean(block.text)] : []))\n const anywhere = [...sourceTexts, ...(options.scope ?? [])]\n const scope = siteImportFactScope(anywhere, options.vocabulary ?? [])\n const shown = pieces.map((piece) => piece.text).filter((text) => !bareNumber(text))\n const onPage = new Set(shown.flatMap((text) => siteImportFactTokens(text, scope, false)))\n // Facts: every one the source says, at least once anywhere on the page.\n const ownScope = siteImportFactScope(sourceTexts)\n // A label in title case, \"Start Now\", says no one's name: its capitals are its style.\n const titleCased = (text: string) => wordsOf(text).length >= 2 && wordsOf(text).every((word) => word.length < 3 || /^\\p{Lu}/u.test(word))\n // A page the site's plan proposed has no source to hold: only what it says is held (AGL-4152).\n const said = options.proposed ? [] : [...new Set(sourceTexts.filter((text) => !bareNumber(text)).flatMap((text) => siteImportFactTokens(text, ownScope, false).filter((token) => !token.startsWith('name:') || !titleCased(text))))]\n // A name the page still says, in the sentence case a redesign writes its headings in, is kept (AGL-4152):\n // \"Built on Stone\" rewritten \"built on stone\" keeps its word, and a real name keeps its capital anyway.\n // A name is kept in any of its forms: its possessive, its initials with stops or hyphens (AGL-4152).\n const wordsOnPage = new Set(shown.flatMap(nameKeysIn))\n const missingFacts = said.filter((token) => !onPage.has(token) && !(token.startsWith('name:') && wordsOnPage.has(siteImportNameKey(token.slice(5)))))\n // Invented: none that nothing the import read says.\n const allowed = new Set(anywhere.flatMap((text) => siteImportFactTokens(text, scope, false)))\n const found = [...new Set(shown.flatMap((text) => siteImportFactTokens(text, scope, true)))].filter((token) => !allowed.has(token) && token !== 'name:FAQ' && token !== 'name:FAQs')\n // Held: every thing that must land, on the page.\n const photoOf = new Map((source.photos ?? []).flatMap((photo) => (photo.from ? [[photo.from, photo.src] as const] : [])))\n const keys = pieces.map((piece) => ` ${piece.key} `)\n const shows = (ref: SiteImportLineRef) => {\n const key = wordLine(clean((source.blocks[ref] as { text?: string } | undefined)?.text))\n return !key || keys.some((piece) => piece.includes(` ${key} `))\n }\n const srcs = new Set(built.order.flatMap((id) => [built.node(id)?.props?.['src'], built.node(id)?.props?.['poster']].filter(Boolean) as unknown[]))\n const formsDrawn = built.order.filter((id) => built.node(id)?.componentId === 'form').length\n const formsWanted = options.forms ?? ledger.items.filter((item) => item.kind === 'form').length\n const formOf = (ref: string) => Number(ref.slice(ref.indexOf(':') + 1))\n const musts = ledger.items.filter((item) => item.must && (item.kind !== 'form' || formOf(item.ref) <= formsWanted))\n const missingHeld = musts\n .filter((item) => {\n if (item.kind === 'form') return formsDrawn < formOf(item.ref)\n if (item.kind === 'video') return !built.order.some((id) => built.node(id)?.componentId === 'video')\n if (item.kind === 'picture') {\n const block = source.blocks[item.lines[0] as number]\n const src = block?.kind === 'image' ? photoOf.get(block.url) : undefined\n return !!src && !srcs.has(src)\n }\n return !item.lines.every(shows)\n })\n .map((item) => item.ref)\n // Links: every destination the source's links have here, on the page.\n const hrefs = new Set(built.order.flatMap((id) => {\n const props = built.node(id)?.props ?? {}\n return [props['href'], ...(clean(props['screenId']) ? [`page:${clean(props['screenId'])}`] : [])].filter((value): value is string => typeof value === 'string')\n }))\n const destinations = options.destinations ?? []\n const missingLinks = destinations.filter((to) => !hrefs.has(to) && !hrefs.has(to.replace(/\\/+$/, '')))\n // Meaning: the source's content words, on the page: of what it says, not of its labels (AGL-4152). A heading or a\n // button of a few words (\"Contact us\", \"Visit or call\") is one a redesign is asked to write again as a promise,\n // and on a short page such as a contact page its labels alone would hold the share down; their facts are held above.\n const sourceWords = contentOf(sourceTexts.filter((text) => contentOf(text).size >= SITE_IMPORT_MEANING_LEAST_WORDS).join(' '))\n const pageWords = contentOf(pieces.map((piece) => piece.text).join(' '))\n const kept = [...sourceWords].filter((stem) => pageWords.has(stem)).length\n const meaningOk = options.proposed === true || sourceWords.size === 0 || kept / sourceWords.size >= (options.meaning ?? SITE_IMPORT_IMPROVED_MEANING)\n const ledgerLines = {\n facts: { ...line(said.length - missingFacts.length, said.length), missing: missingFacts.slice(0, 8) },\n invented: { ...line(found.length ? 0 : 1, 1), found: found.slice(0, 8) },\n held: { ...line(musts.length - missingHeld.length, musts.length), missing: missingHeld },\n links: { ...line(destinations.length - missingLinks.length, destinations.length), missing: missingLinks.slice(0, 8) },\n meaning: line(kept, sourceWords.size, meaningOk),\n }\n\n const has = (id: string, test: (node: SiteImportFidelityNode) => boolean) => built.has(id, test)\n const opener = drawnSections[0]\n const closer = drawnSections[drawnSections.length - 1]\n const filled = (node: SiteImportFidelityNode) => node.componentId === 'muiButton' && node.props?.['variant'] === 'contained' && hasDestination(node)\n const asks = (node: SiteImportFidelityNode) => (node.componentId === 'muiButton' && hasDestination(node)) || node.componentId === 'form'\n // A page that draws its form asks with it (AGL-4152): a form in the first two sections opens on its ask, and one in\n // the last two closes on it, as a contact page is drawn (a short opening, the form, what happens after), with no band.\n const formAt = drawnSections.findIndex((id) => has(id, (node) => node.componentId === 'form'))\n const opens = !!opener && (has(opener, filled) || (formAt >= 0 && formAt <= 1))\n const closes = !!closer && (has(closer, asks) || (formAt >= 0 && formAt >= drawnSections.length - 2))\n const cta = opener && closer ? line((opens ? 1 : 0) + (closes ? 1 : 0), 2) : null\n // Rhythm: neighbors on different grounds.\n const pairs = Math.max(0, drawnSections.length - 1)\n const bandOf = (id: string | undefined) => siteImportFidelityBandOf(id ? built.node(id) : undefined)\n const apart = Array.from({ length: pairs }, (_, at) => bandOf(drawnSections[at]) !== bandOf(drawnSections[at + 1])).filter(Boolean).length\n const rhythm = pairs ? line(apart, pairs, apart / pairs >= RHYTHM_SHARE) : null\n // Columns: no pictures stacked across the page, no run of headings or of short lines one under another, a row somewhere,\n // and, on a page of three sections or more, like items drawn as a group somewhere (AGL-4152).\n // A question list's questions and answers are one group, never a run of lines.\n const inRow = (id: string, root: string) => {\n for (const at of built.ancestry(id)) {\n if (at === root) return false\n if (setsSideBySide(built.node(at)) || GROUPS_A_RUN.has(built.node(at)?.componentId ?? '')) return true\n }\n return false\n }\n const planned = drawnSections.filter((id) => {\n const nodes = built.under(id)\n const across = nodes.filter((at) => {\n // A picture of a row, such as a strip of logos, sits beside the others, whatever the width it is measured at.\n if (built.node(at)?.componentId !== 'image' || fillsFrame(built.node(at)) || inRow(at, id)) return false\n const { box, section } = boxPx(built, at, id)\n return box >= 0.75 * section\n })\n if (across.length >= 2) return false\n const heads = nodes.filter((at) => isHeading(built.node(at)) && !inRow(at, id))\n if (heads.length >= 4) return false\n const lines = nodes.filter((at) => {\n const node = built.node(at)\n return node?.componentId === 'muiTypography' && !isHeading(node) && node.props?.['component'] !== 'h1' && clean(node.props?.['children']).length > 0 && clean(node.props?.['children']).length < 200 && !inRow(at, id)\n })\n return lines.length < 4\n }).length\n const anyRow = drawnSections.some((id) => built.under(id).some((at) => id !== at && setsSideBySide(built.node(at)) && built.children(at).length >= 2))\n // A group: three or more cells of one grid, questions of one list, or lines of one list; a form's fields are its own.\n const anyGroup = drawnSections.some((id) =>\n built.under(id).some((at) => {\n const node = built.node(at)\n if (node?.componentId === 'muiGrid' && setsSideBySide(node)) return built.children(at).length >= 3\n if (node?.componentId === 'muiAccordion') return (built.parent.get(at) ? built.children(built.parent.get(at) as string).filter((child) => built.node(child)?.componentId === 'muiAccordion').length : 0) >= 3\n if (node?.componentId === 'muiList') return built.children(at).length >= 3\n return false\n }),\n )\n const columns = drawnSections.length\n ? line(planned, drawnSections.length, planned === drawnSections.length && (drawnSections.length < 3 || (anyRow && (anyGroup || formAt >= 0))))\n : null\n // Framing: every picture at a size a screen holds, in a frame it fills.\n const natural = new Map((source.photos ?? []).flatMap((photo) => (photo.width && photo.height ? [[photo.src, photo.width / photo.height] as const] : [])))\n const rootOf = (id: string) => drawnSections.find((root) => built.holds(root, id)) ?? null\n const images = built.order.filter((id) => built.node(id)?.componentId === 'image')\n const framed = images.filter((id) => {\n const node = built.node(id) as SiteImportFidelityNode\n const frame = fillsFrame(node) ? built.node(built.parent.get(id) ?? '') : node\n const most = opener && built.holds(opener, id) ? FRAMED_OPENING_PX : FRAMED_PX\n const fixed = fixedHeightOf(node.props?.['height']) ?? fixedHeightOf(frame?.sx?.['height'])\n if (fixed !== null) return fixed <= most\n // A frame as tall as the screen says, a cover's, is no height a picture sets.\n if (fillsFrame(node) && !frame?.sx?.['aspectRatio']) return true\n const ratio = ratioOf(frame?.sx?.['aspectRatio']) ?? ratioOf(node.sx?.['aspectRatio']) ?? natural.get(String(node.props?.['src'])) ?? 16 / 9\n return boxPx(built, id, rootOf(id)).box / ratio <= most\n }).length\n const framing = images.length ? line(framed, images.length) : null\n // Contrast: every ink reads, and the source's own brand fills its buttons.\n const facts = source.layout.look\n const brand = [facts?.buttonFill, facts?.link, facts?.buttonOutline, ...(facts?.palette ?? [])].map(hexOf).find((hex): hex is string => !!hex && aiHexOklch(hex).C >= 0.04)\n const pairsRead = look.pairs(drawnSections)\n const fill = look.theme ? (look.theme.button.fill ?? look.theme.light.brand) : null\n const brandShows = !brand || !fill || siteImportOklabDelta(brand, fill) <= SITE_IMPORT_OUTLINE_DELTA\n const contrast = look.theme ? line(pairsRead.filter(([a, b]) => reads(a, b)).length + (brandShows ? 1 : 0), pairsRead.length + 1) : null\n // Frame: a header with its row and a filled call to action, a phone menu, a footer.\n let frame: SiteImportImprovedLine | null = null\n if (options.frame) {\n const shell = new Built(options.frame)\n const drawer = shell.order.find((id) => shell.node(id)?.componentId === 'muiDrawer') ?? null\n const header = shell.order.find((id) => shell.node(id)?.componentId === 'muiAppBar' || shell.node(id)?.props?.['component'] === 'header') ?? null\n const footer = shell.order.find((id) => shell.node(id)?.props?.['element'] === 'footer' || shell.node(id)?.props?.['component'] === 'footer') ?? null\n const inHeader = header ? shell.under(header).filter((id) => !drawer || !shell.holds(drawer, id)) : []\n const row = inHeader.some((id) => shell.node(id)?.props?.['component'] === 'nav')\n const button = inHeader.some((id) => {\n const node = shell.node(id)\n return !!node && filled(node)\n })\n const links = footer ? shell.has(footer, (node) => hasDestination(node)) || shell.pieces.some((piece) => shell.holds(footer, piece.node)) : false\n frame = line([row, button, !!drawer, links].filter(Boolean).length, 4)\n }\n // Phone: every row stacks, nothing wider or taller than a phone holds.\n const nodes = built.order.map((id) => built.node(id)).filter((node): node is SiteImportFidelityNode => !!node)\n const widths = (node: SiteImportFidelityNode) => [node.sx?.['width'], node.sx?.['minWidth'], node.props?.['width']].some((value) => {\n const fixed = fixedHeightOf(typeof value === 'object' && value && 'xs' in (value as object) ? (value as Record<string, unknown>)['xs'] : value)\n return fixed !== null && fixed > PHONE_PX\n })\n const tall = (node: SiteImportFidelityNode) => [node.props?.['height'], node.sx?.['height']].some((value) => {\n const at = typeof value === 'object' && value && 'xs' in (value as object) ? (value as Record<string, unknown>)['xs'] : value\n const fixed = fixedHeightOf(at)\n return fixed !== null && fixed > PHONE_PICTURE_PX\n })\n const bars = nodes.filter((node) => (node.componentId === 'muiGrid' && crowdsPhone(node.props?.['size'])) || widths(node) || tall(node))\n const phone = drawnSections.length ? line(drawnSections.length - Math.min(drawnSections.length, bars.length), drawnSections.length, bars.length === 0) : null\n\n const design: SiteImportImprovedFidelity['design'] = { cta, rhythm, columns, framing, contrast, frame, phone }\n const red = [\n ...Object.entries(ledgerLines).filter(([, entry]) => !entry.ok).map(([name]) => name),\n ...SITE_IMPORT_IMPROVED_LINES.filter((name) => design[name] && !design[name]?.ok),\n ]\n return { ledger: ledgerLines, design, holds: Object.values(ledgerLines).every((entry) => entry.ok), red }\n}\n\n/*------------------------------------------\n * The frame\n *-----------------------------------------*/\n\n/** A built header and footer, scored against the source's. */\nexport interface SiteImportFrameFidelity {\n /** The lowest ratio of the header's and footer's measures. */\n score: number\n lowest: string | null\n /** The source's top-level items, in the header's row, over the larger of the two (a row of page titles scores low). */\n items: SiteImportFidelityCount\n /** Whether the row's items are in the source's order. */\n inOrder: boolean\n /** The source's menus drawn as menus under their names. */\n menus: SiteImportFidelityCount\n /** The source's menu entries, each a link in its menu. */\n entries: SiteImportFidelityCount\n /** The lines under entries and their icons, in their menus. */\n details: SiteImportFidelityCount\n /** The header's buttons, drawn as the source draws them, each with its destination. */\n ctas: SiteImportFidelityCount\n /** Everything of the row in the phone menu: each menu's name and entries, the links, the buttons. */\n drawer: SiteImportFidelityCount\n /** A menu button shown where the row is not, opening the phone menu. */\n phone: SiteImportFidelityCount\n /** The row's labels held to one line. */\n nowrap: SiteImportFidelityCount\n /** Each column of a menu's panel drawn as its own part of the panel's row, in the source's order, with its heading, words and entries (AGL-4139). */\n menuColumns: SiteImportFidelityCount\n /** The source's filled columns and footer boxes, each drawn in a filled box (AGL-4139). */\n panels: SiteImportFidelityCount\n /** The entries whose icon sits in a filled tile, drawn so (AGL-4139). */\n tiles: SiteImportFidelityCount\n /** The pictures a menu's columns show, placed in them (AGL-4139). */\n pictures: SiteImportFidelityCount\n /** The menus the source opens on hover, opening on hover (AGL-4139). */\n hover: SiteImportFidelityCount\n /** The footer opens with the logo, where the source's does (AGL-4139). */\n logo: SiteImportFidelityCount\n /** The footer's columns under their headings. */\n columns: SiteImportFidelityCount\n /** The footer's links, its columns' and its own. */\n links: SiteImportFidelityCount\n /** Its profiles on other sites. */\n social: SiteImportFidelityCount\n /** Its words, address, phone, email and © line, word for word. */\n facts: SiteImportFidelityCount\n}\n\n/**\n * A menu of the header's row as it is built (AGL-4139): the Dropdown or Mega\n * Menu element under its name, or its name as a link and the panel its hover\n * shows; what it holds, and whether it opens on hover.\n */\nfunction siteImportBuiltMenu(built: Built, row: string, name: string): { inside: string[]; hover: boolean } | null {\n const named = (id: string) => clean(labelOf(built.node(id))) === clean(name)\n const hoverSteps = (id: string): Array<Record<string, unknown>> =>\n (built.node(id)?.interactions ?? []).flatMap((interaction) => {\n const record = interaction as { enabled?: boolean; trigger?: { event?: string }; steps?: unknown[] }\n return record.enabled !== false && record.trigger?.event === 'elementHoverEnter' ? ((record.steps ?? []) as Array<Record<string, unknown>>) : []\n })\n const element = built.under(row).find((id) => (built.node(id)?.componentId === 'muiMegaMenu' || built.node(id)?.componentId === 'muiNavMenu') && named(id))\n if (element) return { inside: built.under(element), hover: hoverSteps(element).some((step) => step['type'] === 'openMenu') }\n const link = built.under(row).find((id) => LINK_COMPONENTS.has(built.node(id)?.componentId ?? '') && named(id))\n if (!link) return null\n // The panel its hover shows: on the name itself, or on the item that holds the name and its panel.\n const item = built.children(row).find((id) => built.holds(id, link)) ?? link\n const shown = [...hoverSteps(link), ...hoverSteps(item)].filter((step) => step['type'] === 'showElement')\n const panelId = shown.map((step) => /^\\[data-aglyn=\"leaf:(.+)\"\\]$/.exec(String(step['selector'] ?? ''))?.[1]).find((id): id is string => !!id && !!built.node(id))\n if (!panelId) return null\n return { inside: [...new Set([...built.under(item), ...built.under(panelId)])], hover: true }\n}\n\n/** A node's label as a menu, a link or a button carries it. */\nfunction labelOf(node: SiteImportFidelityNode | undefined): string {\n if (!node) return ''\n return clean(node.props?.['label']) || clean(node.props?.['children']) || clean(node.props?.['ariaLabel'])\n}\n\nconst LINK_COMPONENTS = new Set(['muiScreenLink', 'muiButton', 'muiLinkBox', 'muiLink'])\n\n/**\n * A built header and footer scored against the source's (AGL-4109): the\n * header's top-level items in order, each menu's entries with the lines and\n * icons under them, its buttons, the phone menu holding all of it, the row's\n * labels on one line; the footer's columns, links, profiles and facts. The\n * score is the lowest ratio.\n */\nexport function siteImportFrameFidelity(source: { nav: SiteImportNavTree | null | undefined; footer: SiteImportFooter | null | undefined }, tree: SiteImportFidelityTree): SiteImportFrameFidelity {\n const built = new Built(tree)\n const all = built.order\n const is = (componentId: string) => (id: string) => built.node(id)?.componentId === componentId\n const drawer = all.find(is('muiDrawer')) ?? null\n const inDrawer = (id: string) => !!drawer && built.holds(drawer, id)\n const header = all.find((id) => built.node(id)?.componentId === 'muiAppBar' || built.node(id)?.props?.['component'] === 'header') ?? null\n const footer = all.find((id) => built.node(id)?.props?.['element'] === 'footer' || built.node(id)?.props?.['component'] === 'footer') ?? null\n const inHeader = header ? built.under(header).filter((id) => !inDrawer(id)) : []\n const row = inHeader.find((id) => built.node(id)?.props?.['component'] === 'nav') ?? null\n const nav = source.nav ?? null\n const groups = nav?.items ?? []\n\n // The row: its items by name, in order; a menu drawn as its name and its panel by its name's.\n const itemLabel = (id: string) => labelOf(built.node(id)) || labelOf(built.node(built.children(id).find((child) => LINK_COMPONENTS.has(built.node(child)?.componentId ?? '')) ?? ''))\n const rowItems = row ? built.children(row).map(itemLabel) : []\n const wanted = groups.map((item) => clean(item.label))\n const left = [...rowItems]\n let matched = 0\n for (const label of wanted) {\n const at = left.indexOf(label)\n if (at !== -1) {\n matched += 1\n left.splice(at, 1)\n }\n }\n const inOrder = rowItems.filter((label) => wanted.includes(label)).join('\\n') === wanted.filter((label) => rowItems.includes(label)).join('\\n')\n\n // Each menu: drawn as one, under its name, with its entries, their lines and icons.\n const menus = { source: 0, built: 0 }\n const entries = { source: 0, built: 0 }\n const details = { source: 0, built: 0 }\n const menuColumns = { source: 0, built: 0 }\n const panels = { source: 0, built: 0 }\n const tiles = { source: 0, built: 0 }\n const pictures = { source: 0, built: 0 }\n const hover = { source: 0, built: 0 }\n const filled = (id: string) => {\n const node = built.node(id)\n return !!node && (node.componentId === 'muiCard' || node.props?.['colorScheme'] === 'dark' || node.sx?.['bgcolor'] !== undefined)\n }\n const label = (id: string) => labelOf(built.node(id)) || shownTexts(built.node(id))[0] || ''\n for (const group of groups) {\n if (!group.items.length) continue\n menus.source += 1\n entries.source += group.items.length\n if (group.panel?.hover) hover.source += 1\n const drawnMenu = row ? siteImportBuiltMenu(built, row, group.label) : null\n for (const entry of group.items) {\n if (entry.text) details.source += 1\n if (entry.iconPath) details.source += 1\n if (entry.tile) tiles.source += 1\n }\n const columns = group.columns ?? []\n const panelled = columns.length >= 2 || columns.some((column) => column.band !== 'plain' || !!column.image || column.lines.length > 0)\n if (panelled) {\n menuColumns.source += columns.length\n panels.source += columns.filter((column) => column.band !== 'plain').length\n pictures.source += columns.filter((column) => !!column.image).length\n }\n if (!drawnMenu) continue\n menus.built += 1\n if (group.panel?.hover && drawnMenu.hover) hover.built += 1\n const inside = drawnMenu.inside\n if (panelled) {\n // The panel's row: the part of it whose children hold the source's columns, each in its place.\n const wanted = columns.map((column, index) => ({ column, labels: group.items.filter((entry) => Math.min(entry.at ?? 0, columns.length - 1) === index).map((entry) => clean(entry.label)) }))\n const placed = (cell: string, want: (typeof wanted)[number]) => {\n const texts = new Set(built.under(cell).map(label))\n return want.labels.every((name) => texts.has(name)) && (!want.column.heading || texts.has(clean(want.column.heading))) && want.column.lines.every((line) => texts.has(clean(line)))\n }\n let best: string[] = []\n for (const id of inside) {\n const cells = built.children(id)\n if (cells.length < columns.length) continue\n const kept = wanted.filter((want, index) => !!cells[index] && placed(cells[index] as string, want)).length\n if (kept > best.filter(Boolean).length) best = wanted.map((want, index) => (cells[index] && placed(cells[index] as string, want) ? (cells[index] as string) : ''))\n }\n menuColumns.built += best.filter(Boolean).length\n columns.forEach((column, index) => {\n const cell = best[index]\n if (!cell) return\n if (column.band !== 'plain' && built.under(cell).some(filled)) panels.built += 1\n if (column.image && built.has(cell, (node) => node.componentId === 'image')) pictures.built += 1\n })\n }\n const links = inside.filter((id) => LINK_COMPONENTS.has(built.node(id)?.componentId ?? ''))\n const texts = new Set(inside.flatMap((id) => shownTexts(built.node(id))))\n for (const entry of group.items) {\n const link = links.find((id) => labelOf(built.node(id)) === clean(entry.label) || shownTexts(built.node(id)).includes(clean(entry.label)) || built.under(id).some((at) => shownTexts(built.node(at)).includes(clean(entry.label))))\n if (!link) continue\n entries.built += 1\n if (entry.text && texts.has(clean(entry.text))) details.built += 1\n if (entry.iconPath && built.has(link, (node) => node.componentId === 'icon')) details.built += 1\n // A tile: the icon held in a filled box of its own.\n const icon = built.under(link).find((id) => built.node(id)?.componentId === 'icon')\n const box = icon ? built.parent.get(icon) : undefined\n if (entry.tile && box && box !== link && filled(box)) tiles.built += 1\n }\n }\n\n // The buttons, as the source draws them.\n const ctas = { source: 0, built: 0 }\n for (const cta of nav?.ctas ?? []) {\n ctas.source += 1\n const button = inHeader.find((id) => built.node(id)?.componentId === 'muiButton' && clean(built.node(id)?.props?.['children']) === clean(cta.label))\n const node = button ? built.node(button) : undefined\n if (node && node.props?.['variant'] === BUTTON_VARIANT[cta.style] && (!cta.href || hasDestination(node))) ctas.built += 1\n }\n\n // The phone menu: every name, entry, link and button of the row.\n const drawerTexts = new Set(drawer ? built.under(drawer).flatMap((id) => shownTexts(built.node(id))) : [])\n const drawerWanted = [\n ...groups.flatMap((group) => [\n clean(group.label),\n ...group.items.map((entry) => clean(entry.label)),\n // Every word of a menu's panel too (AGL-4139): its columns' headings and lines.\n ...(group.columns ?? []).flatMap((column) => [...(column.heading ? [clean(column.heading)] : []), ...column.lines.map(clean)]),\n ]),\n ...(nav?.ctas ?? []).map((cta) => clean(cta.label)),\n ].filter(Boolean)\n const toggle = inHeader.some(is('muiDrawerToggle'))\n const hasRow = groups.length > 0 || (nav?.ctas.length ?? 0) > 0\n\n // The footer.\n const foot = source.footer ?? null\n const footIds = footer ? built.under(footer) : []\n const footTexts = new Set(footIds.flatMap((id) => shownTexts(built.node(id))))\n const footLinks = footIds.filter((id) => LINK_COMPONENTS.has(built.node(id)?.componentId ?? ''))\n const footLinkLabels = footLinks.map((id) => labelOf(built.node(id)))\n const columnLinks = (foot?.columns ?? []).flatMap((column) => column.links)\n const linksWanted = [...columnLinks, ...(foot?.links ?? [])]\n const linkLeft = [...footLinkLabels]\n let linksKept = 0\n for (const link of linksWanted) {\n const at = linkLeft.indexOf(clean(link.label))\n if (at !== -1) {\n linksKept += 1\n linkLeft.splice(at, 1)\n }\n }\n const profiles = footIds.filter(is('socialLinks')).flatMap((id) => Object.entries(built.node(id)?.props ?? {}).filter(([, value]) => typeof value === 'string' && /^https?:/.test(value as string)))\n const hrefs = new Set(footLinks.map((id) => clean(built.node(id)?.props?.['href'])))\n const socialKept = (foot?.social ?? []).filter((profile) => profiles.some(([network, href]) => network === profile.network || href === profile.href) || hrefs.has(clean(profile.href))).length\n const facts = [...(foot?.text ?? []), foot?.address, foot?.phone, foot?.email, foot?.copyright].map(clean).filter(Boolean)\n // Its filled boxes, each a filled box holding its heading, words and links (AGL-4139).\n for (const box of foot?.panels ?? []) {\n panels.source += 1\n const want = [box.heading, ...box.lines, ...(box.links ?? []).map((entry) => entry.label)].filter((text): text is string => !!text).map(clean)\n if (footIds.some((id) => filled(id) && want.every((text) => built.under(id).some((at) => label(at) === text)))) panels.built += 1\n }\n // It opens with the logo: a picture before any of its words.\n const firstWords = footIds.find((id) => shownTexts(built.node(id)).length > 0)\n const firstPicture = footIds.find((id) => built.node(id)?.componentId === 'image')\n const logo = ratioKept(foot?.logo ? 1 : 0, foot?.logo && firstPicture && (!firstWords || footIds.indexOf(firstPicture) < footIds.indexOf(firstWords)) ? 1 : 0)\n\n const report: Omit<SiteImportFrameFidelity, 'score' | 'lowest'> = {\n // Over the larger of the two: a row of the site's page titles in place of the source's menus scores low.\n items: { source: wanted.length, built: matched, ratio: Math.max(wanted.length, rowItems.length) > 0 ? matched / Math.max(wanted.length, rowItems.length) : 1 },\n inOrder,\n menus: ratioKept(menus.source, menus.built),\n entries: ratioKept(entries.source, entries.built),\n details: ratioKept(details.source, details.built),\n ctas: ratioKept(ctas.source, ctas.built),\n drawer: ratioKept(drawerWanted.length, drawerWanted.filter((label) => drawerTexts.has(label)).length),\n phone: ratioKept(hasRow ? 1 : 0, hasRow && toggle && !!drawer ? 1 : 0),\n nowrap: ratioKept(row ? 1 : 0, row && built.node(row)?.sx?.['whiteSpace'] === 'nowrap' ? 1 : 0),\n menuColumns: ratioKept(menuColumns.source, menuColumns.built),\n panels: ratioKept(panels.source, panels.built),\n tiles: ratioKept(tiles.source, tiles.built),\n pictures: ratioKept(pictures.source, pictures.built),\n hover: ratioKept(hover.source, hover.built),\n logo,\n columns: ratioKept(foot?.columns.length ?? 0, (foot?.columns ?? []).filter((column) => footTexts.has(clean(column.heading))).length),\n links: ratioKept(linksWanted.length, linksKept),\n social: ratioKept(foot?.social.length ?? 0, socialKept),\n facts: ratioKept(facts.length, facts.filter((fact) => footTexts.has(fact)).length),\n }\n const measures: Array<[string, SiteImportFidelityCount]> = [\n ['items', report.items],\n ['menus', report.menus],\n ['entries', report.entries],\n ['details', report.details],\n ['ctas', report.ctas],\n ['drawer', report.drawer],\n ['phone', report.phone],\n ['nowrap', report.nowrap],\n ['menuColumns', report.menuColumns],\n ['panels', report.panels],\n ['tiles', report.tiles],\n ['pictures', report.pictures],\n ['hover', report.hover],\n ['logo', report.logo],\n ['columns', report.columns],\n ['links', report.links],\n ['social', report.social],\n ['facts', report.facts],\n ]\n return { ...lowestOf(measures), ...report }\n}\n"],"names":["contrastRatio","SITE_IMPORT_PLAY_WORDS","siteImportWidthOf","siteImportLedger","aiHexOklch","SITE_IMPORT_FIDELITY_THRESHOLD","SITE_IMPORT_IMPROVED_LINES","SITE_IMPORT_IMPROVED_MEANING","SITE_IMPORT_MEANING_LEAST_WORDS","SITE_IMPORT_GROUND_DELTA","SITE_IMPORT_OUTLINE_DELTA","SITE_IMPORT_MEASURE_SHARE","SITE_IMPORT_MEANING_FLOOR","SITE_IMPORT_IMPROVE_FREE","clean","text","replace","trim","WORD","wordsOf","match","wordLine","join","isLine","block","kind","url","inline","tableCells","rows","split","flatMap","line","map","cell","filter","Boolean","shownTexts","node","props","out","key","value","push","componentId","hasDestination","interactions","length","BUTTON_VARIANT","primary","secondary","quiet","siteImportFidelityBandOf","ground","sx","siteImportFidelityTreeOf","nodes","ids","Object","keys","rootId","find","id","parentId","Built","tree","at","enter","get","ancestry","parent","holds","a","b","start","end","exit","point","undefined","under","order","slice","children","child","has","common","every","test","some","Map","pieces","seen","Set","visit","add","set","ratioKept","source","built","ratio","Math","min","ratioBoth","max","Placement","cursor","previous","own","free","piece","owner","claimedBy","pick","list","reduce","best","gap","abs","bestGap","joined","endsWith","exact","padded","part","includes","placeRewritten","layout","sections","forEach","section","index","scopes","lines","ref","blocks","run","from","settle","to","align","of","Number","POSITIVE_INFINITY","left","Array","fill","i","j","pair","contentKept","here","rewrittenAs","unclaimed","flat","said","nodesOf","refs","whole","measured","pictures","photos","sectionRoots","imageClaimed","photoOf","photo","src","root","scope","images","found","unitsOn","placement","parts","stop","others","other","anchor","element","up","setsSideBySide","isByline","cells","findIndex","words","count","total","layoutNodes","tab","tabs","panel","linesOf","item","items","row","label","siteImportFidelity","options","finished","finish","improvedWords","theme","pinned","drawnSections","aligned","roots","_","look","LookOf","wordsScore","read","absoluteBand","band","drawn","bandsKept","groups","tables","buttons","unlinked","buttonCase","buttonFill","buttonOutline","boxed","icons","lone","drawnFilms","films","buttonKept","style","drawnAs","cased","caseKept","filled","fillKept","outlined","outlineKept","button","href","units","parents","unit","size","shared","sharedLinkLines","wanted","icon","mark","listIcon","group","judged","boxesKept","boxedOn","entry","groupsKept","itemsKept","kept","itemKept","shown","labels","one","strip","picturesScore","framing","framingScore","headings","headingsScore","widths","widthsScore","forms","videos","video","report","bands","fromEntries","entries","concealed","concealedScore","galleriesScore","lowestOf","pageMeasures","case","outline","added","scoredAs","alignScore","groundScore","darkGround","darkGroundScore","measure","measureScore","readable","design","designScore","wordingScores","full","improved","improvedScore","ledger","lowest","least","name","done","ok","score","finishMeasures","pins","siteImportFidelityHolds","threshold","facts","meaning","below","image","each","keyOf","toLowerCase","improve","tally","counts","word","links","again","sourceWords","builtWords","both","missing","extra","on","most","examples","WIDTH_RANK","sm","md","lg","xl","width","container","rank","galleries","gallery","copies","SAME_SHAPE","shapeOf","exec","height","heightOf","builtFrame","ratios","values","frame","holder","sizes","fit","radius","box","behind","hero","picture","poster","imageFit","quoted","String","measures","isRecord","isArray","pathIn","round","hexOf","hex","digit","siteImportOklabDelta","two","color","C","cos","h","PI","sin","hypot","L","READS_AT","reads","ink","schemeOf","colors","scheme","paper","brand","onBrand","brandLight","divider","colorIn","paths","siteImportOutlinedColorOf","named","light","CASE_OF","uppercase","none","capitalize","lowercase","siteImportFidelityThemeOf","variants","stylesOf","variant","reverse","contained","dark","pickIn","transform","caseIn","styles","fillDark","labelDark","border","LIKE_THE_PAGE","outlinedCase","textCase","themed","page","ownFill","outlinedFill","near","background","pairs","sectionIds","drawsBox","sides","side","flowLines","LONG_READ_PARAGRAPHS","longRead","centered","SAME_GROUND","placeOn","ordered","worst","themePage","backdrop","delta","darkPage","darkBackground","place","wantedPlace","VIEW_PX","CONTAINER_PX","xs","atView","gridSpan","steps","span","boxPx","chain","indexOf","cap","parseFloat","shares","across","share","heading","level","builtShare","runPx","bandAsItsColor","designLine","first","apart","ruled","drawnBand","rhythm","caps","pictured","title","titleNode","opener","opens","opening","runs","sourceGrouped","builtGrouped","mine","grouped","sourcePairs","buttonText","builtPairs","better","STOP_WORDS","stemOf","stem","ending","contentOf","siteImportContentKept","rewrite","siteImportContentWords","FACTS","factsIn","rest","pattern","normal","repeat","capitalsIn","last","before","matchAll","afterSubject","SUBJECTS","ADDRESSES","siteImportNameKey","nameKeysIn","initials","shouted","long","siteImportFactScope","sourceTexts","vocabulary","small","names","stems","saidIn","siteImportFactTokens","factsScore","builtTexts","texts","token","builtCount","placed","rewritten","floor","FRAMED_PX","FRAMED_OPENING_PX","RHYTHM_SHARE","PHONE_PX","PHONE_PICTURE_PX","bareNumber","ratioOf","fixedHeightOf","fillsFrame","GROUPS_A_RUN","isHeading","tag","crowdsPhone","anywhere","onPage","ownScope","titleCased","proposed","startsWith","wordsOnPage","missingFacts","allowed","shows","srcs","formsDrawn","formsWanted","formOf","musts","must","missingHeld","hrefs","destinations","missingLinks","pageWords","meaningOk","ledgerLines","invented","held","closer","asks","formAt","closes","cta","bandOf","inRow","planned","heads","anyRow","anyGroup","columns","natural","rootOf","framed","fixed","link","palette","pairsRead","brandShows","contrast","shell","drawer","header","footer","inHeader","tall","bars","phone","red","siteImportBuiltMenu","labelOf","hoverSteps","interaction","record","enabled","trigger","event","inside","hover","step","LINK_COMPONENTS","panelId","siteImportFrameFidelity","all","is","inDrawer","nav","itemLabel","rowItems","matched","splice","inOrder","menus","details","menuColumns","panels","tiles","drawnMenu","iconPath","tile","panelled","column","want","ctas","drawerTexts","drawerWanted","toggle","hasRow","foot","footIds","footTexts","footLinks","footLinkLabels","columnLinks","linksWanted","linkLeft","linksKept","profiles","socialKept","social","profile","network","address","email","copyright","firstWords","firstPicture","logo","nowrap","fact"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA4C2C,GAE3C,SAASA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,KAAK;SAAC;QACvB;YAAC;YAAS8E,OAAO2V,KAAK;SAAC;QACvB;YAAC;YAAW3V,OAAOG,OAAO;SAAC;QAC3B;YAAC;YAAWH,OAAO4V,OAAO;SAAC;QAC3B;YAAC;YAAQ5V,OAAOsW,IAAI;SAAC;QACrB;YAAC;YAAUtW,OAAO4T,MAAM;SAAC;QACzB;YAAC;YAAS5T,OAAOkU,KAAK;SAAC;QACvB;YAAC;YAAUlU,OAAO+X,MAAM;SAAC;QACzB;YAAC;YAAe/X,OAAO6V,WAAW;SAAC;QACnC;YAAC;YAAU7V,OAAO8V,MAAM;SAAC;QACzB;YAAC;YAAS9V,OAAO+V,KAAK;SAAC;QACvB;YAAC;YAAY/V,OAAO/G,QAAQ;SAAC;QAC7B;YAAC;YAAS+G,OAAO6U,KAAK;SAAC;QACvB;YAAC;YAAQ7U,OAAO8X,IAAI;SAAC;QACrB;YAAC;YAAW9X,OAAOiT,OAAO;SAAC;QAC3B;YAAC;YAASjT,OAAOgD,KAAK;SAAC;QACvB;YAAC;YAAUhD,OAAOsX,MAAM;SAAC;QACzB;YAAC;YAAStX,OAAOqC,KAAK;SAAC;KACxB;IACD,OAAO,aAAK9B,SAASmF,WAAc1F;AACrC"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-import-fidelity.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, SCORED AGAINST ITS SOURCE (AGL-4109).\n *\n * On 10/29 an import of aglyn.com shipped with every section flattened to one\n * column of lines and a header of page titles, and nothing measured it: the\n * specs checked that words came through, never how the page was laid out.\n * This scores a built page against what the reader read of its source\n * (`SiteImportLayout`, AGL-4106), with no model and no browser, over the\n * page's nodes as the compiler draws them or as Firestore stores them:\n *\n * - **The words**: every line of the source exactly once, as written, and\n * none of the page's own. A score of words is 1 or the page is wrong.\n * - **The structure**: its sections, their bands and how wide they run; its\n * rows of columns side by side; its groups by kind, each item its own\n * element with its parts (an FAQ's question on an accordion, a card's link\n * on the card); its tables, tab strips, pictures, icons, buttons as the\n * source draws them, headings and forms.\n * - **The frame** (`siteImportFrameFidelity`): the header's top-level items\n * in order, each menu's entries with their lines and icons, the buttons,\n * the phone menu holding all of it, labels on one line; the footer's\n * columns, links, profiles and facts.\n *\n * Every measure is anchored to the source's own words, never to how the\n * compiler names its elements: each line of the source is found on the\n * built page, and the structure is asked of the elements holding them (are\n * a group's thirteen items thirteen elements, or one stack of lines?). So\n * the same score reads a page compiled in a spec and a page stored on a live\n * site. The score is the lowest ratio of the structure; words are held apart\n * at exactly 1.\n *\n * How the owner asked the site to be finished (AGL-4152) changes what the\n * score means, and each finish is asked for by name; a page scored with\n * neither a finish nor its words scores as it did before the choice:\n *\n * - **Keep my site**: the structure, and the look's pins at 1.0: each\n * section's alignment and its groups' boxes as the source has them, each\n * ground within OKLab ΔE 0.05 of the source's, the hero heading's measure\n * within 10%, and the buttons in the source's case and fill.\n * - **Improve it**: the content alone (words, sections, items, tables, tabs,\n * pictures, icons, buttons, headings, forms, films); the bands, widths,\n * rows, framing, grounds, measure, alignment and boxes are free, and the\n * `design` lines say whether the build reads better than its source.\n * - **Improved words** (lane G): the words are free, and every fact, every\n * line and most of each line's meaning are held instead.\n *=========================================*/\n\nimport { contrastRatio } from '@aglyn/aglyn/app-utils/site-theme'\nimport type { SiteImportBlock } from '../site-import/site-import-html'\nimport { SITE_IMPORT_PLAY_WORDS, siteImportWidthOf, type AiSiteImportFinish, type AiSiteImportWords } from './ai-site-import'\nimport { siteImportLedger } from './ai-site-import-ledger'\nimport { aiHexOklch } from './ai-site-look'\nimport type {\n SiteImportBand,\n SiteImportButtonStyle,\n SiteImportFooter,\n SiteImportGroupKind,\n SiteImportLayout,\n SiteImportLayoutGroup,\n SiteImportLayoutItem,\n SiteImportLayoutNode,\n SiteImportLayoutSection,\n SiteImportLineRef,\n SiteImportNavTree,\n SiteImportPictureFit,\n SiteImportWidth,\n} from './ai-site-import'\n\n/** The lowest score of structure a page brought in ships at (AGL-4109); words are held at exactly 1. */\nexport const SITE_IMPORT_FIDELITY_THRESHOLD = 0.9\n\n/** A node of a page or a layout, as the compiler draws it or Firestore stores it, decoded. */\nexport interface SiteImportFidelityNode {\n componentId?: string\n props?: Record<string, unknown> | null\n sx?: Record<string, unknown> | null\n nodes?: readonly string[] | null\n parentId?: string | null\n interactions?: readonly unknown[] | null\n}\n\n/** A built page or layout: its nodes and the one they hang from. */\nexport interface SiteImportFidelityTree {\n rootId: string\n nodes: Readonly<Record<string, SiteImportFidelityNode>>\n}\n\n/** What the source had, what the built page kept of it, and the share kept. */\nexport interface SiteImportFidelityCount {\n source: number\n built: number\n ratio: number\n}\n\n/** The words of a page: every one of the source's, as written, exactly once, and none of its own. */\nexport interface SiteImportFidelityWords {\n /** Words the source's lines hold. */\n source: number\n /** Words the built page shows. */\n built: number\n /** The source's words the page does not show (counted as often as they are missing). */\n missing: number\n /** Words the page shows that are not the source's, or are shown more often than the source says them. */\n extra: number\n /** Words shown once each, over the larger of the two. */\n ratio: number\n /** A few of the missing and extra words, for a report. */\n examples: { missing: string[]; extra: string[] }\n}\n\nexport interface SiteImportFidelityGroup {\n /** Groups of the kind kept whole: every item of them its own element, with its parts. */\n groups: SiteImportFidelityCount\n /** Items of the kind kept, each its own element with its parts. */\n items: SiteImportFidelityCount\n}\n\n/** A page brought in, scored against its source. */\nexport interface SiteImportPageFidelity {\n /** The lowest ratio of the structure: what the page ships on, at `SITE_IMPORT_FIDELITY_THRESHOLD` or above. */\n score: number\n /** The measure that set the score; `null` when every measure is whole. */\n lowest: string | null\n words: SiteImportFidelityWords\n sections: SiteImportFidelityCount\n /** Sections drawn in the source's band, in order. */\n bands: SiteImportFidelityCount & { read: SiteImportBand[]; drawn: SiteImportBand[] }\n /** Sections drawn as wide as the source runs them, or wider (AGL-4083); one the source sets no cap on counts as kept. */\n widths: SiteImportFidelityCount\n /** The source's rows of two or more columns, set side by side on the page. */\n rows: SiteImportFidelityCount\n /** The source's galleries (AGL-4152), each kept when every photo of it is drawn as a photo, cropped to fill, side by side. Absent on a page with none. */\n galleries?: SiteImportFidelityCount\n /** Pictures and labels the source hides from a visitor, drawn all the same (AGL-4152); any at all is a miss. Absent when the read says of none. */\n concealed?: SiteImportFidelityCount\n /** The source's groups by kind. A group of lines that only share a shape (`text`) is drawn as its lines, and is not scored. */\n groups: Partial<Record<SiteImportGroupKind, SiteImportFidelityGroup>>\n tables: SiteImportFidelityCount\n tabs: SiteImportFidelityCount\n /** The source's pictures placed on the page. */\n pictures: SiteImportFidelityCount\n /**\n * The source's pictures framed as the source frames them (AGL-4138): each\n * in a box of the shape the source shows it at — the box or the height it\n * crops it to, else its own — within 5%, or in no box at all where the\n * source crops nothing. A round portrait, and a picture the source lays\n * behind its words, are framed by design and not scored.\n */\n framing: SiteImportFidelityCount\n /**\n * The source's icons drawn: each group item's own, each bullet's mark. An\n * icon standing alone in the source (a video's play mark) is no word and no\n * picture of the page, and the build leaves it out (AGL-4107): it is\n * counted in `lone` and not scored.\n */\n icons: SiteImportFidelityCount & { lone: number }\n /**\n * The lines the source draws as buttons that go somewhere (a page, an\n * address, an email, a phone), drawn as buttons of the same style with\n * their destinations. A button that goes nowhere a page can send a visitor\n * (a film's play button its script runs) is kept as its words: counted in\n * `unlinked`, not scored.\n */\n buttons: SiteImportFidelityCount & {\n unlinked: number\n /**\n * Under Keep my site (AGL-4152), the buttons set in the source's case, and\n * its filled ones in its own fill within OKLab ΔE 0.05: counted where the\n * source's look and the theme say them, and a button short of either is\n * not kept.\n */\n case?: SiteImportFidelityCount\n fill?: SiteImportFidelityCount\n /** Its outlined ones drawn as the source draws them: no fill of their own, their words and border in the source's color, within OKLab ΔE 0.1 (`SITE_IMPORT_OUTLINE_DELTA`). */\n outline?: SiteImportFidelityCount\n }\n /** The source's headings, drawn as headings. */\n headings: SiteImportFidelityCount\n /** The source's forms, where the site has a form a page places. */\n forms: SiteImportFidelityCount\n /**\n * The source's videos (AGL-4140): each drawn as the Video element, playing\n * from an address. One on a host the element has no player for is drawn as\n * its poster, linking to it, and is not kept. A film that plays on its own\n * behind a section's words is drawn as its poster there and is not counted\n * here: its poster is among the pictures.\n */\n videos: SiteImportFidelityCount\n /**\n * What the page was scored as (AGL-4152): its finish and its words. Absent\n * on a page scored with neither, whose score is the one before the choice,\n * and which carries none of the measures below.\n */\n scoredAs?: { finish: AiSiteImportFinish; words: AiSiteImportWords }\n /** The measures this finish prints as free: reported, never scored. */\n free?: string[]\n /** Sections whose words are set as the source sets them, centered or at the start. */\n align?: SiteImportFidelityCount\n /** Groups whose items are boxed where the source boxes them, and open where it leaves them open. */\n boxed?: SiteImportFidelityCount\n /**\n * Sections with a ground of their own drawn on a ground of the theme\n * within OKLab ΔE 0.05 of it (`SITE_IMPORT_GROUND_DELTA`): `theme` says\n * where the theme's colors were read from, `null` where none was given and\n * nothing is measured; `worst` is the farthest one. Under Keep my site\n * (AGL-4152) in their place against the page too: a section lighter than its\n * page's ground draws lighter than the theme's, and one on its page's ground\n * draws on the theme's, for two near whites read alike by ΔE alone.\n */\n ground?: SiteImportFidelityCount & { theme: SiteImportFidelityTheme['from'] | null; worst: number | null }\n /**\n * Under Keep my site (AGL-4152), the same sections in the theme's dark\n * scheme: on the source's own dark fill within OKLab ΔE 0.05 where its\n * stylesheets say one, else in their place against the dark page.\n */\n darkGround?: SiteImportFidelityCount & { worst: number | null }\n /**\n * The hero heading's box as a share of its section, within 10% of the\n * source's (`SITE_IMPORT_MEASURE_SHARE`): measured where the reader kept the\n * source's measure. `shares` are the two shares compared.\n */\n measure?: SiteImportFidelityCount & { shares: { source: number; built: number } | null }\n /** Each section's ink on its ground, and a filled button's label on its fill, at 4.5:1 or better: measured where a theme is given. */\n readable?: SiteImportFidelityCount\n /** The lines Improve it scores the build on against its source: whether it reads better (AGL-4152). */\n design?: SiteImportDesignFidelity\n /** Under improved words (G4): every fact of the source (prices, numbers, emails, phones, addresses, names) as often as it says it. */\n facts?: SiteImportFidelityFacts\n /** Under improved words (G4): every line of the source placed once, and none the page added (`extra`). */\n lines?: SiteImportFidelityCount & { extra: number }\n /** Under improved words (G4): how much of each line's content its rewrite keeps, held at `floor` a line. */\n meaning?: SiteImportFidelityMeaning\n /** Under a generative Improve it (AGL-4152): the kept ledger, held at 1, and the design lines. */\n improved?: SiteImportImprovedFidelity\n}\n\n/** One line a generative Improve it is held to (AGL-4152): how much of what it asks the page does, and whether that is enough. */\nexport interface SiteImportImprovedLine {\n done: number\n of: number\n ok: boolean\n}\n\n/**\n * A page a generative Improve it built, scored (AGL-4152). Its sections and\n * words are the redesign's own, so what is scored is what must have come\n * through and whether it reads as designed.\n */\nexport interface SiteImportImprovedFidelity {\n /** What must have come through, each at 1. */\n ledger: {\n /** Every fact the source says, on the page. */\n facts: SiteImportImprovedLine & { missing: string[] }\n /**\n * Facts and names on the page that nothing the import read says: none.\n * `at` is the line each was found in, cut short around it (AGL-4152), so\n * a re-ask and a later read of the job can tell which sentence held it.\n */\n invented: SiteImportImprovedLine & { found: string[]; at?: string[] }\n /** Every thing that must land, on the page. */\n held: SiteImportImprovedLine & { missing: string[] }\n /** Every link's destination, on the page. */\n links: SiteImportImprovedLine & { missing: string[] }\n /** The source's content words on the page, at `SITE_IMPORT_IMPROVED_MEANING` or more. */\n meaning: SiteImportImprovedLine\n }\n /** How it reads; a line is `null` where the page asks it nothing, or what it reads is not given. */\n design: Record<SiteImportImprovedLineName, SiteImportImprovedLine | null>\n /** Whether the ledger holds whole. */\n holds: boolean\n /** The lines short of the bar, ledger first. */\n red: string[]\n}\n\n/** The design lines of a generative Improve it (AGL-4152). */\nexport const SITE_IMPORT_IMPROVED_LINES = ['cta', 'rhythm', 'columns', 'framing', 'contrast', 'frame', 'phone'] as const\nexport type SiteImportImprovedLineName = (typeof SITE_IMPORT_IMPROVED_LINES)[number]\n\n/** The share of a source's content words a redesign keeps on its page (AGL-4152). */\nexport const SITE_IMPORT_IMPROVED_MEANING = 0.6\n\n/** The fewest content words a source line says for its meaning to be held (AGL-4152): fewer is a label, written again freely. */\nexport const SITE_IMPORT_MEANING_LEAST_WORDS = 4\n\n/** What a generative Improve it is scored against, besides its source. */\nexport interface SiteImportImprovedOptions {\n /** Every other line the import read: a fact one of these says is no invention. */\n scope?: readonly string[]\n /** Every destination the source's links have on the new site (`page:<id>`, an address). Absent, not measured. */\n destinations?: readonly string[]\n /** How many forms have a saved form to place. Absent, every form the source has. */\n forms?: number\n /** The site's header and footer, for the `frame` line. Absent, not measured. */\n frame?: SiteImportFidelityTree | null\n /** A page the site's plan proposed: new, so no source's facts or meaning to hold, only what it says. */\n proposed?: boolean\n /** Words the platform's own request put to the redesign, no one's name or fact (`siteImportFactScope`). */\n vocabulary?: readonly string[]\n /** The share of the source's content words the page keeps; absent, `SITE_IMPORT_IMPROVED_MEANING`. */\n meaning?: number\n}\n\n/** How a page was finished and its words kept (AGL-4152), and the theme it is drawn in. */\nexport interface SiteImportFidelityOptions {\n /** Keep my site or Improve it. Scored with neither this nor `words`, the page scores as it did before the choice. */\n finish?: AiSiteImportFinish | null\n /** Whether its words were kept as written or improved (lane G). */\n words?: AiSiteImportWords | null\n /**\n * The theme the page is drawn in (`siteImportFidelityThemeOf`). A tree\n * names roles (`background.paper`, `primary.main`), not colors: without a\n * theme the grounds, the inks and the buttons' case and fill are not\n * measured.\n */\n theme?: SiteImportFidelityTheme | null\n /** Scored as a generative Improve it (AGL-4152): its kept ledger and design lines, in place of its structure. */\n improved?: SiteImportImprovedOptions | null\n}\n\n/** One scheme of a theme, as the fidelity reads it. */\nexport interface SiteImportFidelityScheme {\n /** `background.default`: a plain band's ground. */\n ground: string | null\n /** `background.paper`: a soft band's. */\n paper: string | null\n /** `primary.main`: a brand band's, and a filled button's where the theme sets none apart. */\n brand: string | null\n /** `primary.contrastText`: the words on it. */\n onBrand: string | null\n /** `text.primary`: the words' ink. */\n ink: string | null\n /** `primary.light`: what a theme may draw its own filled buttons in. */\n brandLight?: string | null\n /** `divider`: a hairline, as a base may border an outlined button. */\n divider?: string | null\n}\n\n/** The colors and button style of the theme a page is drawn in, `#rrggbb`. */\nexport interface SiteImportFidelityTheme {\n /** Where they were read from: the site's theme as stored, or computed from its site style. */\n from: 'theme' | 'style'\n light: SiteImportFidelityScheme\n dark: SiteImportFidelityScheme | null\n /**\n * A filled button's own fill and label where the theme sets them apart from\n * the brand's (`MuiButton`), and the case its words are set in; the outlined\n * and text buttons' own style, where the theme sets one: its colors as the\n * theme names them, a palette path resolved in the scheme a button is drawn in.\n * `fillDark` and `labelDark` are the filled button's in the dark scheme.\n */\n button: {\n fill: string | null\n label: string | null\n fillDark?: string | null\n labelDark?: string | null\n case: 'upper' | 'none' | null\n outlined?: { text: unknown; border: unknown; fill: unknown; case: 'upper' | 'none' | null }\n text?: { case: 'upper' | 'none' | null }\n }\n}\n\n/** One line of the design measure: the share of what it asks that the source and the build each do, 0 to 1. */\nexport interface SiteImportDesignLine {\n source: number\n built: number\n}\n\n/**\n * Whether a page improved reads better than its source (AGL-4152), with no\n * model: each line the share of what it asks that the page does. A line is\n * `null` where the page gives it nothing to ask. Better is the build at or\n * above the source on every line and above it on one at least; a build that\n * is merely different is not better.\n */\nexport interface SiteImportDesignFidelity {\n /** Neighboring sections set apart by their bands, or a rule between them. */\n rhythm: SiteImportDesignLine | null\n /** Sections whose words run no wider than `lg`, and a long read no wider than `md`. */\n measure: SiteImportDesignLine | null\n /** A first section holding a picture opens as the page's hero, its heading and its picture together. */\n opening: SiteImportDesignLine | null\n /** Runs of three or more like items drawn as one group, each item an element of its own. */\n grouped: SiteImportDesignLine | null\n /** Inks and grounds that read at 4.5:1. */\n readable: SiteImportDesignLine | null\n better: boolean\n}\n\n/** The facts of a page's words (G4): each found on the built page as often as the source has it, and none of its own. */\nexport interface SiteImportFidelityFacts {\n source: number\n built: number\n missing: number\n extra: number\n /** Facts found as often as said, over the larger of the two: exactly 1 or the page is wrong. */\n ratio: number\n examples: { missing: string[]; extra: string[] }\n}\n\n/** How much of each line's content its rewrite keeps (G4). */\nexport interface SiteImportFidelityMeaning {\n /** The lines rewritten: placed, and drawn in words other than the source's. */\n lines: number\n /** Those keeping less than `floor` of their content words. */\n below: number\n /** The least any line kept; 1 where none was rewritten. */\n lowest: number\n /** The lines at `floor` or above, over the lines rewritten. */\n ratio: number\n floor: number\n /** The lines below the floor, for a report. */\n examples: Array<{ line: SiteImportLineRef; kept: number; source: string; built: string }>\n}\n\n/** How far a ground of the theme may sit from the source's (AGL-4152), in OKLab. */\nexport const SITE_IMPORT_GROUND_DELTA = 0.05\n\n/**\n * How far an outlined button's color may sit from the source's (AGL-4152), in\n * OKLab: it is the theme's primary, a shade deepened to carry white words where\n * the source's own does not, so a role and not a pin. A grey or a light one is\n * far past it.\n */\nexport const SITE_IMPORT_OUTLINE_DELTA = 0.1\n\n/** How far the hero heading's share of its section may sit from the source's (AGL-4152), relatively. */\nexport const SITE_IMPORT_MEASURE_SHARE = 0.1\n\n/** The least share of a line's content words a rewrite keeps (G4): a bold rewrite, the owner asked 11/4, still keeps a third. */\nexport const SITE_IMPORT_MEANING_FLOOR = 0.3\n\n/** The measures Improve it prints as free (AGL-4152): what it may change. */\nexport const SITE_IMPORT_IMPROVE_FREE: readonly string[] = ['bands', 'widths', 'rows', 'framing', 'ground', 'measure', 'align', 'boxed']\n\n/** A page's source as the import read it: its layout over its main-region blocks, and its photos as the library holds them. */\nexport interface SiteImportFidelitySource {\n layout: SiteImportLayout\n /** The page's main-region blocks, which the layout's lines are indexes of. */\n blocks: readonly SiteImportBlock[]\n /** The source's pictures as the site's library holds them (`from` → `src`, and their size); without them a picture is counted, not placed. */\n photos?: ReadonlyArray<{ from?: string; src: string; width?: number; height?: number; graphic?: boolean }>\n /** What the source holds that a visitor cannot see (AGL-4152): a build that draws any of it fails `concealed`. */\n concealed?: { pictures: readonly string[]; words: readonly string[] }\n}\n\n/*------------------------------------------\n * Words and lines\n *-----------------------------------------*/\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\nconst WORD = /[\\p{L}\\p{N}]+/gu\n\n/** A line's words, in order. */\nconst wordsOf = (text: string): string[] => text.match(WORD) ?? []\n\n/**\n * A line's words as one string, for comparing two lines whatever their\n * spacing and marks; a line of marks alone (a table's \"✓\", a \"—\") as it is.\n */\nconst wordLine = (text: string): string => wordsOf(text).join(' ') || clean(text)\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/** A cell of the Table element's grid, its pipes unescaped. */\nfunction tableCells(rows: string): string[] {\n return rows\n .split('\\n')\n .flatMap((line) =>\n line\n .replace(/^\\s*\\|/, '')\n .replace(/\\|\\s*$/, '')\n .split(/(?<!\\\\)\\|/)\n .map((cell) => clean(cell.replace(/\\\\\\|/g, '|'))),\n )\n .filter(Boolean)\n}\n\n/** The words a node shows a visitor: its text, its list lines, its tab labels, its table's cells. */\nfunction shownTexts(node: SiteImportFidelityNode | undefined): string[] {\n if (!node) return []\n const props = node.props ?? {}\n const out: string[] = []\n for (const key of ['children', 'primary', 'secondary']) {\n const value = clean(props[key])\n if (value) out.push(value)\n }\n if (node.componentId === 'muiTabs' && typeof props['labels'] === 'string') out.push(...props['labels'].split('\\n').map(clean).filter(Boolean))\n if (node.componentId === 'dataTable' && typeof props['rows'] === 'string') out.push(...tableCells(props['rows']))\n return out\n}\n\n/** Where a node sends a visitor: a page, an address, a section of the page. */\nfunction hasDestination(node: SiteImportFidelityNode | undefined): boolean {\n if (!node) return false\n const props = node.props ?? {}\n return !!clean(props['screenId']) || !!clean(props['href']) || !!clean(props['to']) || (node.interactions?.length ?? 0) > 0\n}\n\nconst BUTTON_VARIANT: Readonly<Record<SiteImportButtonStyle, string>> = { primary: 'contained', secondary: 'outlined', quiet: 'text' }\n\n/** A section's band as the compiler draws it: a dark scheme, the paper ground, the brand fill, else plain. */\nexport function siteImportFidelityBandOf(node: SiteImportFidelityNode | undefined): SiteImportBand {\n if (node?.props?.['colorScheme'] === 'dark') return 'dark'\n const ground = node?.sx?.['bgcolor']\n if (ground === 'background.paper') return 'soft'\n if (ground === 'primary.main') return 'brand'\n return 'plain'\n}\n\n/** The node a stored page or layout hangs from: the canvas root, else the one with no parent. */\nexport function siteImportFidelityTreeOf(nodes: Readonly<Record<string, SiteImportFidelityNode>>): SiteImportFidelityTree {\n const ids = Object.keys(nodes)\n const rootId = nodes['_@_'] ? '_@_' : (ids.find((id) => !nodes[id]?.parentId) ?? ids[0] ?? '_@_')\n return { rootId, nodes }\n}\n\n/*------------------------------------------\n * The built page, walked once\n *-----------------------------------------*/\n\ninterface Piece {\n node: string\n text: string\n /** Its words, joined: what lines are compared by. */\n key: string\n at: number\n}\n\n/** A built tree in document order: each node's span, its parent, and the words each shows. */\nclass Built {\n readonly order: string[] = []\n private readonly enter = new Map<string, number>()\n private readonly exit = new Map<string, number>()\n readonly parent = new Map<string, string>()\n readonly pieces: Piece[] = []\n\n constructor(readonly tree: SiteImportFidelityTree) {\n const seen = new Set<string>()\n const visit = (id: string, parent: string | null) => {\n if (seen.has(id) || !tree.nodes[id]) return\n seen.add(id)\n if (parent) this.parent.set(id, parent)\n const at = this.order.length\n this.enter.set(id, at)\n this.order.push(id)\n for (const text of shownTexts(tree.nodes[id])) this.pieces.push({ node: id, text, key: wordLine(text), at })\n for (const child of tree.nodes[id]?.nodes ?? []) visit(child, id)\n this.exit.set(id, this.order.length - 1)\n }\n visit(tree.rootId, null)\n }\n\n node(id: string): SiteImportFidelityNode | undefined {\n return this.tree.nodes[id]\n }\n\n /** A node's place in document order; -1 for one not on the page. */\n at(id: string): number {\n return this.enter.get(id) ?? -1\n }\n\n /** A node and the nodes holding it, nearest first, up to the page's root. */\n ancestry(id: string): string[] {\n const out: string[] = []\n for (let at: string | undefined = id; at; at = this.parent.get(at)) out.push(at)\n return out\n }\n\n /** Whether `a` is `b` or holds it. */\n holds(a: string, b: string): boolean {\n const start = this.enter.get(a)\n const end = this.exit.get(a)\n const point = this.enter.get(b)\n return start !== undefined && end !== undefined && point !== undefined && point >= start && point <= end\n }\n\n /** The nodes under one, itself included, in document order. */\n under(id: string): string[] {\n const start = this.enter.get(id)\n const end = this.exit.get(id)\n return start === undefined || end === undefined ? [] : this.order.slice(start, end + 1)\n }\n\n children(id: string): string[] {\n return (this.tree.nodes[id]?.nodes ?? []).filter((child) => this.enter.has(child))\n }\n\n /** The deepest node holding every one of `ids`. */\n common(ids: readonly string[]): string | null {\n if (!ids.length) return null\n for (let at: string | undefined = ids[0]; at; at = this.parent.get(at)) {\n if (ids.every((id) => this.holds(at as string, id))) return at\n }\n return null\n }\n\n /** Whether any node under `id` (itself included) is one `test` takes. */\n has(id: string, test: (node: SiteImportFidelityNode) => boolean): boolean {\n return this.under(id).some((at) => {\n const node = this.tree.nodes[at]\n return !!node && test(node)\n })\n }\n}\n\nconst ratioKept = (source: number, built: number): SiteImportFidelityCount => ({ source, built, ratio: source > 0 ? Math.min(1, built / source) : 1 })\n\nconst ratioBoth = (source: number, built: number): SiteImportFidelityCount => ({\n source,\n built,\n ratio: Math.max(source, built) > 0 ? Math.min(source, built) / Math.max(source, built) : 1,\n})\n\n/*------------------------------------------\n * The page\n *-----------------------------------------*/\n\n/**\n * Each line of the source found on the built page (AGL-4109): the element\n * showing its words, or the picture the library copy of it is. A line is\n * looked for in its own section, nearest after the line before it; an\n * element holds one line, or the run of lines a build joins into one (a\n * list item's words, a quote's).\n */\nclass Placement {\n /** Line → the node showing it. */\n readonly of = new Map<SiteImportLineRef, string>()\n /** Line → the words it is shown in, where a rewrite placed it (AGL-4152). */\n readonly rewrittenAs = new Map<SiteImportLineRef, string>()\n private readonly claimedBy = new Map<Piece, SiteImportLineRef>()\n private readonly imageClaimed = new Set<string>()\n /** Each section's pieces, in order. */\n private readonly scopes: Piece[][] = []\n\n constructor(\n private readonly built: Built,\n private readonly source: SiteImportFidelitySource,\n sectionRoots: ReadonlyArray<string | null>,\n ) {\n const photoOf = new Map<string, string>()\n for (const photo of source.photos ?? []) if (photo.from) photoOf.set(photo.from, photo.src)\n source.layout.sections.forEach((section, index) => {\n const root = sectionRoots[index] ?? built.tree.rootId\n const scope = new Set(built.under(root))\n const pieces = built.pieces.filter((piece) => scope.has(piece.node))\n this.scopes[index] = pieces\n // A film's poster is placed as its Video element's (AGL-4140).\n const images = built.under(root).filter((id) => built.node(id)?.componentId === 'image' || built.node(id)?.componentId === 'video')\n let cursor = -1\n let previous: SiteImportLineRef | null = null\n // Each line's own words, so a line found only in part never takes a piece another line is shown in whole (AGL-4152).\n const own = new Set(section.lines.flatMap((ref) => {\n const line = source.blocks[ref]\n return isLine(line) && line.kind !== 'image' ? [wordLine(clean(line.text))] : []\n }))\n for (const ref of section.lines) {\n const block = source.blocks[ref]\n if (!isLine(block)) continue\n if (block.kind === 'image') {\n const src = photoOf.get(block.url)\n const found = src ? images.find((id) => !this.imageClaimed.has(id) && built.node(id)?.props?.[built.node(id)?.componentId === 'video' ? 'poster' : 'src'] === src) : undefined\n if (found) {\n this.imageClaimed.add(found)\n this.of.set(ref, found)\n }\n previous = ref\n continue\n }\n const piece = this.find(pieces, clean(block.text), cursor, previous, own)\n if (piece) {\n this.claimedBy.set(piece, ref)\n this.of.set(ref, piece.node)\n cursor = piece.at\n }\n previous = ref\n }\n })\n }\n\n /** The piece showing a line: its words exactly, else a part of them (a long paragraph split), else the run it was joined into. */\n private find(pieces: readonly Piece[], text: string, cursor: number, previous: SiteImportLineRef | null, own: ReadonlySet<string> = new Set()): Piece | null {\n const key = wordLine(text)\n if (!key) return null\n const free = (piece: Piece) => {\n const owner = this.claimedBy.get(piece)\n // A piece holds one line, or the lines a build joined: the one before this one.\n return owner === undefined || owner === previous\n }\n // The nearest to the line placed before it: a build keeps a section's lines in their order, near enough.\n const pick = (list: Piece[]) =>\n list.reduce<Piece | null>((best, piece) => {\n if (!best) return piece\n const gap = Math.abs(piece.at - cursor)\n const bestGap = Math.abs(best.at - cursor)\n return gap < bestGap || (gap === bestGap && piece.at >= cursor && best.at < cursor) ? piece : best\n }, null)\n // A line of marks a build joined to the line before it (a \"—\" beside its label) is in that line's piece,\n // never the same mark further down the page, which would leave that one's line with nothing.\n if (!wordsOf(text).length && previous !== null) {\n const joined = pieces.find((piece) => this.claimedBy.get(piece) === previous && clean(piece.text) !== text && clean(piece.text).endsWith(text))\n if (joined) return joined\n }\n const exact = pieces.filter((piece) => piece.key === key && this.claimedBy.get(piece) === undefined)\n if (exact.length) return pick(exact)\n const padded = ` ${key} `\n // A reworded heading that reads \"…, and agencies build a hundred\" never takes the card titled \"Agencies\".\n const part = pieces.filter((piece) => free(piece) && piece.key && !(piece.key !== key && own.has(piece.key)) && (` ${piece.key} `.includes(padded) || padded.includes(` ${piece.key} `)))\n return pick(part)\n }\n\n /**\n * The lines a rewrite changed (G4), placed after the lines found as\n * written: in each section, each run of lines still unplaced is set to the\n * free pieces between the lines placed either side of it, in order, each\n * piece to one line, the pairs sharing most content words chosen. A line a\n * rewrite dropped has no piece to take, and stays unplaced.\n */\n placeRewritten(): void {\n this.source.layout.sections.forEach((section, index) => {\n const pieces = this.scopes[index] ?? []\n const lines = section.lines.filter((ref) => isLine(this.source.blocks[ref]) && this.source.blocks[ref]?.kind !== 'image')\n let run: SiteImportLineRef[] = []\n let from = -1\n const settle = (to: number) => {\n if (run.length) this.align(run, pieces.filter((piece) => piece.at >= from && piece.at <= to && this.claimedBy.get(piece) === undefined))\n run = []\n }\n for (const ref of lines) {\n const node = this.of.get(ref)\n if (node === undefined) {\n run.push(ref)\n continue\n }\n const at = this.built.at(node)\n settle(at)\n from = at\n }\n settle(Number.POSITIVE_INFINITY)\n // A line its neighbors leave no room for (one drawn out of the source's order) is looked for among the section's free pieces.\n const left = lines.filter((ref) => !this.of.has(ref))\n if (left.length) this.align(left, pieces.filter((piece) => this.claimedBy.get(piece) === undefined))\n })\n }\n\n /** A run of lines set to free pieces in order (G4): as many pairs as can be, then the most content kept. */\n private align(lines: readonly SiteImportLineRef[], pieces: readonly Piece[]): void {\n if (!lines.length || !pieces.length) return\n const text = (ref: SiteImportLineRef) => clean((this.source.blocks[ref] as { text?: string } | undefined)?.text)\n const best: number[][] = Array.from({ length: lines.length + 1 }, () => new Array<number>(pieces.length + 1).fill(0))\n for (let i = 1; i <= lines.length; i += 1) {\n for (let j = 1; j <= pieces.length; j += 1) {\n const pair = (best[i - 1]?.[j - 1] ?? 0) + 1 + contentKept(text(lines[i - 1] as number), (pieces[j - 1] as Piece).text)\n ;(best[i] as number[])[j] = Math.max(pair, best[i - 1]?.[j] ?? 0, best[i]?.[j - 1] ?? 0)\n }\n }\n for (let i = lines.length, j = pieces.length; i > 0 && j > 0; ) {\n const here = best[i]?.[j] ?? 0\n if (here === (best[i - 1]?.[j] ?? 0)) i -= 1\n else if (here === (best[i]?.[j - 1] ?? 0)) j -= 1\n else {\n const ref = lines[i - 1] as SiteImportLineRef\n const piece = pieces[j - 1] as Piece\n this.claimedBy.set(piece, ref)\n this.of.set(ref, piece.node)\n this.rewrittenAs.set(ref, piece.text)\n i -= 1\n j -= 1\n }\n }\n }\n\n /** The pieces of the page's sections no line of the source claimed, nor holds as a part of its words: lines the page added. */\n unclaimed(): Piece[] {\n const pieces = [...new Set(this.scopes.flat())]\n const said = this.source.layout.sections.flatMap((section) => section.lines).map((ref) => ` ${wordLine(clean((this.source.blocks[ref] as { text?: string } | undefined)?.text))} `)\n return pieces.filter((piece) => this.claimedBy.get(piece) === undefined && !!piece.key && !said.some((line) => line.includes(` ${piece.key} `)))\n }\n\n /** The nodes a list of lines is shown by, and whether every one of them was found. */\n nodesOf(refs: readonly SiteImportLineRef[]): { nodes: string[]; whole: boolean; measured: boolean } {\n const nodes: string[] = []\n let whole = true\n let measured = false\n const pictures = !!this.source.photos?.length\n for (const ref of refs) {\n const block = this.source.blocks[ref]\n if (!isLine(block)) continue\n if (block.kind === 'image' && !pictures) continue\n measured = true\n const node = this.of.get(ref)\n if (node) nodes.push(node)\n else whole = false\n }\n return { nodes, whole, measured }\n }\n}\n\n/** One part of the source's structure (an item, a cell), found on the built page. */\ninterface Unit {\n nodes: string[]\n whole: boolean\n measured: boolean\n /** The element holding all of it and nothing of the parts beside it. */\n element: string | null\n}\n\n/**\n * Units found on the page, each as the element of its own (AGL-4109): the\n * highest element holding its lines and none of the other units' lines. A\n * unit whose lines are not held apart from another's (thirteen cards' titles\n * in one stack under their thirteen lines) has no element of its own.\n */\nfunction unitsOn(built: Built, placement: Placement, parts: ReadonlyArray<readonly SiteImportLineRef[]>, stop: string | null): Unit[] {\n const found = parts.map((refs) => placement.nodesOf(refs))\n return found.map((part, index) => {\n const others = found.flatMap((other, at) => (at === index ? [] : other.nodes))\n const anchor = built.common(part.nodes)\n if (!anchor || others.some((node) => built.holds(anchor, node))) return { ...part, element: null }\n let element = anchor\n for (let up = built.parent.get(element); up && up !== stop && !others.some((node) => built.holds(up as string, node)); up = built.parent.get(up)) {\n element = up\n if (built.node(up)?.componentId === 'section') break\n }\n return { ...part, element }\n })\n}\n\n/** Whether a node lays its children side by side: a Grid container, or a Stack set in a row. */\nfunction setsSideBySide(node: SiteImportFidelityNode | undefined): boolean {\n if (!node) return false\n const props = node.props ?? {}\n if (node.componentId === 'muiGrid') return props['container'] === true || props['container'] === 'true'\n if (node.componentId === 'muiStack') return props['direction'] === 'row' || (typeof props['direction'] === 'string' && /\\b(?:sm|md|lg):row\\b/.test(props['direction']))\n return false\n}\n\n/**\n * Whether a row of the source is a byline: one cell a lone picture, the other\n * a few words (a writer's portrait beside their name and date), which the\n * build draws as the portrait, small, over its words (AGL-4107), not as two\n * columns across the page.\n */\nfunction isByline(source: SiteImportFidelitySource, cells: ReadonlyArray<{ nodes: SiteImportLayoutNode[] }>): boolean {\n if (cells.length !== 2) return false\n const at = cells.findIndex((cell) => cell.nodes.length === 1 && cell.nodes[0]?.kind === 'picture')\n if (at === -1) return false\n const words = cells[1 - at]?.nodes ?? []\n if (!words.every((node) => node.kind === 'line')) return false\n const count = words.reduce((total, node) => {\n const block = node.kind === 'line' ? source.blocks[node.line] : undefined\n return total + (block && block.kind !== 'image' ? wordsOf(clean(block.text)).length : 0)\n }, 0)\n return count > 0 && count <= 12\n}\n\n/** Every node of a section's layout, rows, cells and tab panels opened, in order. */\nfunction layoutNodes(nodes: readonly SiteImportLayoutNode[]): SiteImportLayoutNode[] {\n const out: SiteImportLayoutNode[] = []\n const visit = (list: readonly SiteImportLayoutNode[]) => {\n for (const node of list) {\n out.push(node)\n if (node.kind === 'row') for (const cell of node.cells) visit(cell.nodes)\n if (node.kind === 'tabs') for (const tab of node.tabs) visit(tab.panel)\n }\n }\n visit(nodes)\n return out\n}\n\n/** Every line a list of layout nodes places, rows, groups, tables and tabs opened. */\nfunction linesOf(nodes: readonly SiteImportLayoutNode[]): SiteImportLineRef[] {\n const out: SiteImportLineRef[] = []\n for (const node of layoutNodes(nodes)) {\n if (node.kind === 'line' || node.kind === 'picture') out.push(node.line)\n else if (node.kind === 'group') for (const item of node.items) out.push(...item.lines)\n else if (node.kind === 'table') for (const row of node.rows) for (const cell of row.cells) out.push(...cell.lines)\n else if (node.kind === 'tabs') for (const tab of node.tabs) if (tab.label !== null) out.push(tab.label)\n }\n return out\n}\n\n/**\n * A built page scored against its source (AGL-4109): the words, each once;\n * the sections and their bands; the rows of columns; the groups by kind, each\n * item an element of its own with its parts; the tables, tabs, pictures,\n * icons, buttons, headings and forms. The score is the lowest ratio of the\n * structure.\n *\n * Scored with a `finish` or its `words` (AGL-4152), the page is scored as\n * that finish asks, with the measures it adds; with neither, as before.\n */\nexport function siteImportFidelity(source: SiteImportFidelitySource, tree: SiteImportFidelityTree, options: SiteImportFidelityOptions = {}): SiteImportPageFidelity {\n const finished = !!options.finish || !!options.words\n // An import that names no finish reads as Keep my site (AGL-4152).\n const finish: AiSiteImportFinish = options.finish ?? 'keep'\n const improvedWords = options.words === 'improved'\n const theme = options.theme ?? null\n // Keep my site holds the buttons to the source's case and fill too.\n const pinned = finished && finish === 'keep'\n const built = new Built(tree)\n const sections = source.layout.sections\n const drawnSections = built.children(tree.rootId)\n // The build draws each of the source's sections as one, in order; a page whose count differs is searched whole.\n const aligned = drawnSections.length === sections.length\n const roots = sections.map((_, index) => (aligned ? (drawnSections[index] ?? null) : null))\n const placement = new Placement(built, source, roots)\n // Lines a rewrite changed are found by their place and their content (G4).\n if (improvedWords) placement.placeRewritten()\n const look = new LookOf(built, source.layout.look, theme)\n\n const words = wordsScore(source, built, finish === 'improve')\n // Improved, a page's bands are read as its colors alone say; kept, against its page's ground (AGL-4152).\n const read = sections.map((section) => (finished && finish === 'improve' ? (section.absoluteBand ?? section.band) : section.band))\n const drawn = drawnSections.map((id) => siteImportFidelityBandOf(built.node(id)))\n const bandsKept = read.filter((band, index) => drawn[index] === band).length\n\n const rows = { source: 0, built: 0 }\n const groups: Partial<Record<SiteImportGroupKind, { groups: number; groupsKept: number; items: number; itemsKept: number }>> = {}\n const tables = { source: 0, built: 0 }\n const tabs = { source: 0, built: 0 }\n const buttons = { source: 0, built: 0, unlinked: 0 }\n // Keep my site's buttons in the source's case, and its filled ones in its fill (AGL-4152).\n const buttonCase = { source: 0, built: 0 }\n const buttonFill = { source: 0, built: 0 }\n const buttonOutline = { source: 0, built: 0 }\n const boxed = { source: 0, built: 0 }\n const icons = { source: 0, built: 0, lone: 0 }\n // The films drawn as the Video element, playing from an address (AGL-4140).\n const drawnFilms = built.order.filter((id) => built.node(id)?.componentId === 'video' && !!clean(built.node(id)?.props?.['src'])).length\n const films = drawnFilms > 0\n /** Whether a button of the source is drawn in its style, going where it goes; under Keep my site, in its case and fill too. */\n const buttonKept = (line: SiteImportLineRef, style: SiteImportButtonStyle): boolean => {\n const id = placement.of.get(line)\n const drawnAs = id ? built.node(id) : undefined\n const drawn = drawnAs?.componentId === 'muiButton' && drawnAs.props?.['variant'] === BUTTON_VARIANT[style] && hasDestination(drawnAs)\n if (!pinned) return drawn\n const cased = look.caseKept(id ?? null, style)\n if (cased !== null) {\n buttonCase.source += 1\n if (drawn && cased) buttonCase.built += 1\n }\n const filled = style === 'primary' ? look.fillKept(id ?? null) : null\n if (filled !== null) {\n buttonFill.source += 1\n if (drawn && filled) buttonFill.built += 1\n }\n const outlined = style === 'secondary' ? look.outlineKept(id ?? null) : null\n if (outlined !== null) {\n buttonOutline.source += 1\n if (drawn && outlined) buttonOutline.built += 1\n }\n return drawn && cased !== false && filled !== false && outlined !== false\n }\n\n sections.forEach((section, index) => {\n const root = roots[index] ?? null\n for (const node of layoutNodes(section.nodes)) {\n switch (node.kind) {\n case 'icon':\n icons.lone += 1\n break\n case 'line': {\n const block = source.blocks[node.line]\n if (!node.button) {\n // A link standing on its own is drawn as a text button: under Keep my site it is held to the source's case as one (AGL-4152).\n const id = placement.of.get(node.line)\n if (pinned && block?.kind === 'link' && id && built.node(id)?.componentId === 'muiButton') {\n buttons.source += 1\n if (buttonKept(node.line, 'quiet')) buttons.built += 1\n }\n break\n }\n // A button whose words say it plays a film plays the page's film where one is drawn (AGL-4140).\n if (block?.kind === 'paragraph' && films && SITE_IMPORT_PLAY_WORDS.test(block.text)) {\n buttons.source += 1\n if (buttonKept(node.line, node.button)) buttons.built += 1\n break\n }\n // A button that goes nowhere a page can send a visitor (a film's play button its script runs) is kept as its words.\n if (block?.kind !== 'link' || !/^(?:https?:|mailto:|tel:)/i.test(block.href)) {\n buttons.unlinked += 1\n break\n }\n buttons.source += 1\n if (buttonKept(node.line, node.button)) buttons.built += 1\n break\n }\n case 'row': {\n const cells = node.cells.filter((cell) => linesOf(cell.nodes).length)\n if (cells.length < 2 || isByline(source, cells)) break\n rows.source += 1\n const units = unitsOn(built, placement, cells.map((cell) => linesOf(cell.nodes)), root)\n const parents = new Set(units.map((unit) => (unit.element ? built.parent.get(unit.element) : null)))\n const parent = parents.size === 1 ? [...parents][0] : null\n if (units.every((unit) => unit.whole && unit.element) && parent && setsSideBySide(built.node(parent))) rows.built += 1\n break\n }\n case 'group': {\n // Improved, a link every item repeats is shown once after the group (AGL-4152): no item holds it.\n const shared = finish === 'improve' ? sharedLinkLines(source.blocks, node.items) : null\n const units = unitsOn(built, placement, node.items.map((item) => (shared ? item.lines.filter((line) => !shared.has(line)) : item.lines)), root)\n // Each item's own icon and its bullets' marks, in the element that is the item.\n node.items.forEach((item, at) => {\n // Its corner arrow too (AGL-4138): a card's \"↗\" is an icon of its own.\n const wanted = (item.icon !== undefined ? 1 : 0) + (item.mark !== undefined ? 1 : 0) + (item.listIcon !== undefined ? (item.list?.length ?? 0) : 0)\n if (!wanted) return\n icons.source += wanted\n const element = units[at]?.element\n if (element) icons.built += Math.min(wanted, built.under(element).filter((id) => built.node(id)?.componentId === 'icon').length)\n })\n // Lines that only share a shape are drawn as their lines: no group to keep.\n if (node.group === 'text') break\n // Its items boxed where the source boxes them, open where it leaves them open (AGL-4152).\n const judged = units.filter((unit) => unit.measured && unit.element)\n if (finished && boxesKept(node) && judged.length) {\n boxed.source += 1\n if (judged.every((unit) => boxedOn(built, unit) === node.boxed)) boxed.built += 1\n }\n const entry = (groups[node.group] ??= { groups: 0, groupsKept: 0, items: 0, itemsKept: 0 })\n let kept = 0\n let measured = 0\n node.items.forEach((item, at) => {\n const unit = units[at] as Unit\n if (!unit.measured) return\n measured += 1\n if (itemKept(built, node.group, item, unit)) kept += 1\n })\n entry.groups += 1\n entry.items += measured\n entry.itemsKept += kept\n if (measured > 0 && kept === measured) entry.groupsKept += 1\n break\n }\n case 'table': {\n tables.source += 1\n const cells = node.rows.flatMap((row) => row.cells.map((cell) => wordLine(cell.lines.map((ref) => clean((source.blocks[ref] as { text?: string })?.text)).join(' '))).filter(Boolean))\n // The theme's Table element, every cell of the source's in it.\n const kept = built.under(root ?? tree.rootId).some((id) => {\n const drawnAs = built.node(id)\n if (drawnAs?.componentId !== 'dataTable' || typeof drawnAs.props?.['rows'] !== 'string') return false\n const shown = new Set(tableCells(drawnAs.props['rows']).map(wordLine))\n return cells.every((cell) => shown.has(cell))\n })\n if (kept) tables.built += 1\n break\n }\n case 'tabs': {\n tabs.source += 1\n const labels = node.tabs.flatMap((tab) => (tab.label !== null ? [tab.label] : []))\n const found = placement.nodesOf(labels)\n if (!found.whole || !found.nodes.length) break\n // The Tabs element names every tab itself; a strip draws each label as an element of its own, side by side.\n const one = new Set(found.nodes).size === 1\n const strip = built.common(found.nodes)\n if (one ? built.node(found.nodes[0] as string)?.componentId === 'muiTabs' : !!strip && setsSideBySide(built.node(strip))) tabs.built += 1\n break\n }\n default:\n break\n }\n }\n })\n\n const pictures = picturesScore(source, built, placement)\n const framing = framingScore(source, built, placement)\n const headings = headingsScore(source, built, placement)\n const widths = widthsScore(sections, built, roots)\n const forms = ratioBoth(\n sections.reduce((total, section) => total + layoutNodes(section.nodes).filter((node) => node.kind === 'form').length, 0),\n built.order.filter((id) => built.node(id)?.componentId === 'form').length,\n )\n // A film playing behind a section's words is drawn as its poster there, and is the pictures' to count.\n const videos = ratioKept(\n sections.reduce(\n (total, section) => total + layoutNodes(section.nodes).reduce((count, node) => count + (node.kind === 'video' ? 1 : node.kind === 'group' ? node.items.filter((item) => item.video !== undefined).length : 0), 0),\n 0,\n ),\n drawnFilms,\n )\n\n const report: Omit<SiteImportPageFidelity, 'score' | 'lowest'> = {\n words,\n sections: ratioBoth(sections.length, drawnSections.length),\n bands: { ...ratioKept(read.length, bandsKept), read, drawn },\n widths,\n rows: ratioKept(rows.source, rows.built),\n groups: Object.fromEntries(\n Object.entries(groups).map(([kind, entry]) => [kind, { groups: ratioKept(entry.groups, entry.groupsKept), items: ratioKept(entry.items, entry.itemsKept) }]),\n ),\n tables: ratioKept(tables.source, tables.built),\n tabs: ratioKept(tabs.source, tabs.built),\n pictures,\n ...(source.concealed ? { concealed: concealedScore(source, built) } : {}),\n ...galleriesScore(source, built, placement),\n framing,\n icons: { ...ratioKept(icons.source, icons.built), lone: icons.lone },\n buttons: { ...ratioKept(buttons.source, buttons.built), unlinked: buttons.unlinked },\n headings,\n forms,\n videos,\n }\n if (!finished) return { ...lowestOf(pageMeasures(report)), ...report }\n\n // The measures a finish adds (AGL-4152).\n if (pinned) report.buttons = { ...report.buttons, case: ratioKept(buttonCase.source, buttonCase.built), fill: ratioKept(buttonFill.source, buttonFill.built), outline: ratioKept(buttonOutline.source, buttonOutline.built) }\n const added: Partial<SiteImportPageFidelity> = {\n scoredAs: { finish, words: improvedWords ? 'improved' : 'kept' },\n free: finish === 'improve' ? [...SITE_IMPORT_IMPROVE_FREE, ...(improvedWords ? ['words'] : [])] : improvedWords ? ['words'] : [],\n align: alignScore(source, built, placement, pinned),\n boxed: ratioKept(boxed.source, boxed.built),\n ground: groundScore(sections, look, roots, pinned),\n ...(pinned ? { darkGround: darkGroundScore(sections, look, roots) } : {}),\n measure: measureScore(source, built, placement, roots),\n readable: look.readable(drawnSections),\n ...(finish === 'improve' ? { design: designScore(source, built, placement, look, roots, drawnSections) } : {}),\n ...(improvedWords ? wordingScores(source, built, placement) : {}),\n }\n const full = { ...report, ...added }\n if (options.improved && finish === 'improve') {\n const improved = improvedScore(source, built, look, drawnSections, options.improved)\n const ledger = Object.entries(improved.ledger) as Array<[string, SiteImportImprovedLine]>\n // A redesign plans its own sections: what it scores on is what its ledger held, and the lowest of those.\n const lowest = ledger.reduce<[string, number] | null>((least, [name, line]) => {\n const ratio = line.of > 0 ? Math.min(1, line.done / line.of) : 1\n return !line.ok && (!least || ratio < least[1]) ? [name, ratio] : least\n }, null)\n return { ...full, improved, score: lowest ? lowest[1] : 1, lowest: lowest ? lowest[0] : null }\n }\n return { ...lowestOf(finishMeasures(full)), ...full }\n}\n\n/**\n * The measures a finished page is scored on (AGL-4152). Keep my site: the\n * structure and the look's pins, its words held apart. Improve it: the\n * content alone, its words among it unless they were improved; everything it\n * may change prints as free.\n */\nfunction finishMeasures(report: Omit<SiteImportPageFidelity, 'score' | 'lowest'>): Array<[string, SiteImportFidelityCount]> {\n const free = new Set(report.free ?? [])\n const pins: Array<[string, SiteImportFidelityCount | undefined]> = [\n ['align', report.align],\n ['boxed', report.boxed],\n ['ground', report.ground],\n ['darkGround', report.darkGround],\n ['measure', report.measure],\n ]\n const words: Array<[string, SiteImportFidelityCount]> = report.scoredAs?.finish === 'improve' && !free.has('words') ? [['words', report.words]] : []\n return [...words, ...pageMeasures(report), ...pins.filter((entry): entry is [string, SiteImportFidelityCount] => !!entry[1])].filter(([name]) => !free.has(name))\n}\n\n/**\n * Whether a page ships (AGL-4109, AGL-4152): its score at the bar, and what\n * is held at exactly 1 whole. Its words, as written, or under improved words\n * every fact and every line, and each line's meaning at the floor; under\n * Keep my site, its alignment, boxes, grounds in both schemes and measure.\n */\nexport function siteImportFidelityHolds(report: SiteImportPageFidelity, threshold = SITE_IMPORT_FIDELITY_THRESHOLD): boolean {\n if (report.improved) return report.improved.holds\n if (report.score < threshold) return false\n const improvedWords = report.scoredAs?.words === 'improved'\n if (improvedWords ? report.facts?.ratio !== 1 || report.lines?.ratio !== 1 || (report.meaning?.below ?? 0) > 0 : report.words.ratio !== 1) return false\n if (report.scoredAs?.finish !== 'keep') return true\n return [report.align, report.boxed, report.ground, report.darkGround, report.measure].every((count) => !count || count.ratio === 1)\n}\n\n/** Whether an item of a group is kept: its own element, every line of it found, and the parts its kind and source say it has. */\nfunction itemKept(built: Built, kind: SiteImportGroupKind, item: SiteImportLayoutItem, unit: Unit): boolean {\n if (!unit.whole || !unit.element) return false\n const element = unit.element\n // A question opens its answer: the theme's accordion.\n if (kind === 'faq' && !built.has(element, (node) => node.componentId === 'muiAccordion')) return false\n // An item the source made a link as a whole still goes there.\n if (item.to && !built.has(element, hasDestination)) return false\n // A picture of the item's own, where the library's copy is not known to the score; a film's poster is its Video element's (AGL-4140).\n if (item.image !== undefined && !built.has(element, (node) => node.componentId === 'image' || node.componentId === 'video')) return false\n return true\n}\n\n/** The link lines of a group's items that every item carries, the same words to the same place: one call to action, said on each. */\nfunction sharedLinkLines(blocks: readonly SiteImportBlock[], items: ReadonlyArray<{ lines: readonly SiteImportLineRef[] }>): Set<SiteImportLineRef> {\n if (items.length < 2) return new Set()\n const keyOf = (line: SiteImportLineRef) => {\n const block = blocks[line]\n return block?.kind === 'link' && !block.inline ? `${wordLine(clean(block.text)).toLowerCase()}\\u0000${block.href}` : null\n }\n const each = items.map((item) => new Set(item.lines.flatMap((line) => keyOf(line) ?? [])))\n const common = [...(each[0] ?? [])].filter((key) => each.every((keys) => keys.has(key)))\n return new Set(items.flatMap((item) => item.lines.filter((line) => common.includes(keyOf(line) ?? ''))))\n}\n\n/**\n * The words: the source's lines against what the page shows, each word as\n * often as it is said. Improved, a link said again with the same words to the\n * same place may be shown once or as often as it is said (AGL-4152): the page\n * shows each call to action once, and a page drawn as before is no worse.\n */\nfunction wordsScore(source: SiteImportFidelitySource, built: Built, improve = false): SiteImportFidelityWords {\n const tally = (lines: readonly string[]) => {\n const counts = new Map<string, number>()\n for (const word of lines.flatMap(wordsOf)) counts.set(word, (counts.get(word) ?? 0) + 1)\n return counts\n }\n const links = new Set<string>()\n const again = (block: SiteImportBlock) => {\n if (!improve || block.kind !== 'link') return false\n const key = `${wordLine(clean(block.text)).toLowerCase()}\\u0000${block.href}`\n if (links.has(key)) return true\n links.add(key)\n return false\n }\n const lines = source.blocks.filter((block): block is Exclude<SiteImportBlock, { kind: 'image' }> => isLine(block) && block.kind !== 'image')\n const full = tally(lines.map((block) => clean(block.text)))\n const least = tally(lines.filter((block) => !again(block)).map((block) => clean(block.text)))\n const shown = tally(built.pieces.map((piece) => piece.text))\n // Each word as often as the page shows it, between the least the source asks and all it says.\n const said = new Map([...full].map(([word, count]) => [word, Math.min(count, Math.max(least.get(word) ?? 0, shown.get(word) ?? 0))]))\n let sourceWords = 0\n let builtWords = 0\n let both = 0\n const missing: string[] = []\n const extra: string[] = []\n for (const [word, count] of said) {\n sourceWords += count\n const on = shown.get(word) ?? 0\n both += Math.min(count, on)\n if (on < count) missing.push(word)\n }\n for (const [word, count] of shown) {\n builtWords += count\n if (count > (said.get(word) ?? 0)) extra.push(word)\n }\n const most = Math.max(sourceWords, builtWords)\n return {\n source: sourceWords,\n built: builtWords,\n missing: sourceWords - both,\n extra: builtWords - both,\n ratio: most > 0 ? both / most : 1,\n examples: { missing: missing.slice(0, 8), extra: extra.slice(0, 8) },\n }\n}\n\nconst WIDTH_RANK: Readonly<Record<SiteImportWidth, number>> = { sm: 0, md: 1, lg: 2, xl: 3 }\n\n/** The sections as wide as their source: each section's Container against the cap the source sets; a section nothing caps runs the whole page. */\nfunction widthsScore(sections: readonly SiteImportLayoutSection[], built: Built, roots: ReadonlyArray<string | null>): SiteImportFidelityCount {\n const kept = sections.filter((section, index) => {\n const wanted = siteImportWidthOf(section.width)\n if (!wanted) return true\n const root = roots[index]\n if (!root) return false\n const container = built.under(root).find((id) => built.node(id)?.componentId === 'muiContainer' && !built.node(id)?.props?.['disableGutters'])\n if (!container) return true\n const rank = WIDTH_RANK[built.node(container)?.props?.['maxWidth'] as SiteImportWidth]\n return rank !== undefined && rank >= WIDTH_RANK[wanted]\n })\n return ratioKept(sections.length, kept.length)\n}\n\n/** The pictures: placed where the library's copies are known, else counted. */\nfunction picturesScore(source: SiteImportFidelitySource, built: Built, placement: Placement): SiteImportFidelityCount {\n const refs = source.layout.sections.flatMap((section) => section.lines).filter((ref) => source.blocks[ref]?.kind === 'image' && isLine(source.blocks[ref]))\n // A film's poster is a picture drawn, on its Video element (AGL-4140).\n const drawn = built.order.filter((id) => built.node(id)?.componentId === 'image' || (built.node(id)?.componentId === 'video' && !!clean(built.node(id)?.props?.['poster']))).length\n if (!source.photos?.length) return ratioBoth(refs.length, drawn)\n return ratioKept(refs.length, refs.filter((ref) => placement.of.has(ref)).length)\n}\n\n/**\n * The source's galleries drawn as galleries (AGL-4152): every photo of one\n * placed, each an Image cropped to fill its cell, in a row of columns. A photo\n * drawn as a mark (fitted whole, as small as a logo) is a gallery lost.\n */\nfunction galleriesScore(source: SiteImportFidelitySource, built: Built, placement: Placement): Pick<SiteImportPageFidelity, 'galleries'> {\n const galleries = source.layout.sections.flatMap((section) => layoutNodes(section.nodes)).filter((node): node is SiteImportLayoutGroup => node.kind === 'group' && !!node.gallery)\n if (!galleries.length) return {}\n const drawn = galleries.filter((group) =>\n group.items.every((item) =>\n item.lines.every((ref) => {\n if (source.blocks[ref]?.kind !== 'image') return true\n const id = placement.of.get(ref)\n const node = id ? built.node(id) : undefined\n if (node?.componentId !== 'image' || node.props?.['objectFit'] === 'contain' || node.props?.['width'] === 'auto') return false\n return built.ancestry(id as string).some((at) => setsSideBySide(built.node(at)))\n }),\n ),\n )\n return { galleries: ratioKept(galleries.length, drawn.length) }\n}\n\n/** What a visitor of the source cannot see and a visitor of the build can (AGL-4152): a hidden picture, or a line that is only a screen reader's label. */\nfunction concealedScore(source: SiteImportFidelitySource, built: Built): SiteImportFidelityCount {\n const pictures = new Set(source.concealed?.pictures ?? [])\n const copies = new Set((source.photos ?? []).flatMap((photo) => (photo.from && pictures.has(photo.from) ? [photo.src] : [])))\n const drawn = built.order.filter((id) => {\n const src = clean(built.node(id)?.props?.['src'])\n return built.node(id)?.componentId === 'image' && (pictures.has(src) || copies.has(src))\n }).length\n const labels = new Set((source.concealed?.words ?? []).map(wordLine))\n const said = built.pieces.filter((piece) => labels.has(piece.key)).length\n const found = drawn + said\n return { source: 0, built: found, ratio: found ? 0 : 1 }\n}\n\n/** How near two shapes must be to be one (AGL-4138): 5%. */\nconst SAME_SHAPE = 0.05\n\n/** A box's shape as the compiler writes it, width over height: \"1600 / 900\", \"1.7778\", 1.5. */\nfunction shapeOf(value: unknown): number | null {\n if (typeof value === 'number') return value > 0 ? value : null\n if (typeof value !== 'string') return null\n const match = /^\\s*(\\d*\\.?\\d+)\\s*(?:\\/\\s*(\\d*\\.?\\d+))?\\s*$/.exec(value)\n if (!match) return null\n const width = Number(match[1])\n const height = match[2] === undefined ? 1 : Number(match[2])\n return width > 0 && height > 0 ? width / height : null\n}\n\n/** A height in px as the compiler writes one: \"320px\", 320. */\nfunction heightOf(value: unknown): number | null {\n if (typeof value === 'number') return value > 1 ? value : null\n const match = typeof value === 'string' ? /^\\s*(\\d*\\.?\\d+)px\\s*$/.exec(value) : null\n return match ? Number(match[1]) : null\n}\n\n/**\n * The box a built picture is shown in: its own `aspectRatio` or height, else\n * the frame holding it alone that sets one; `whole` where nothing frames it, or\n * it is fitted inside its box (`contain`), which cuts nothing.\n */\nfunction builtFrame(built: Built, id: string): { ratios: number[]; height: number | null } | 'whole' {\n const image = built.node(id)\n if (!image) return 'whole'\n if (image.props?.['objectFit'] === 'contain') return 'whole'\n const read = (node: SiteImportFidelityNode | undefined): { ratios: number[]; height: number | null } | null => {\n const sx = node?.sx ?? {}\n const height = heightOf(node?.componentId === 'image' ? (node.props?.['height'] ?? sx['height']) : sx['height'])\n if (height !== null) return { ratios: [], height }\n const ratio = sx['aspectRatio']\n const ratios = (ratio && typeof ratio === 'object' ? Object.values(ratio) : [ratio]).map(shapeOf).filter((value): value is number => value !== null)\n return ratios.length ? { ratios, height: null } : null\n }\n const own = read(image)\n if (own) return own\n const frame = built.parent.get(id)\n const holder = frame ? built.node(frame) : undefined\n if (holder && built.children(frame as string).length === 1 && holder.componentId === 'muiBox') return read(holder) ?? 'whole'\n return 'whole'\n}\n\n/**\n * The pictures framed as their source frames them (AGL-4138): each placed\n * picture's box against the shape the source shows it at — the box or the\n * height it crops it to, else its own, by the library's copy's size or its\n * `width` and `height` — within 5%; a picture the source shows whole may be\n * shown in no box. A round portrait and the picture a section lays behind\n * its words are not scored, nor a picture whose own shape is not known.\n */\nfunction framingScore(source: SiteImportFidelitySource, built: Built, placement: Placement): SiteImportFidelityCount {\n const sizes = new Map<string, number>()\n for (const photo of source.photos ?? []) if (photo.from && photo.width && photo.height) sizes.set(photo.from, photo.width / photo.height)\n let measured = 0\n let kept = 0\n const score = (ref: SiteImportLineRef, fit: SiteImportPictureFit | undefined) => {\n const block = source.blocks[ref]\n const id = placement.of.get(ref)\n if (block?.kind !== 'image' || !id || (fit?.radius ?? 0) >= 999) return\n const frame = builtFrame(built, id)\n const own = sizes.get(block.url) ?? fit?.ratio ?? null\n if (fit?.height) {\n measured += 1\n if (frame !== 'whole' && frame.height !== null && Math.abs(frame.height / fit.height - 1) <= SAME_SHAPE) kept += 1\n return\n }\n const wanted = fit?.box ?? own\n if (wanted === null || wanted === undefined) return\n measured += 1\n if (frame === 'whole') {\n if (!fit?.box) kept += 1\n return\n }\n if (frame.height === null && frame.ratios.every((ratio) => Math.abs(ratio / wanted - 1) <= SAME_SHAPE)) kept += 1\n }\n for (const section of source.layout.sections) {\n // A picture the section lays behind its words fills the band, as it is meant to.\n const behind = section.hero?.picture === 'behind' ? section.lines.find((ref) => source.blocks[ref]?.kind === 'image') : undefined\n for (const node of layoutNodes(section.nodes)) {\n if (node.kind === 'picture' && node.line !== behind) score(node.line, node.fit)\n // A film's poster is framed as any picture is (AGL-4140).\n if (node.kind === 'video' && node.poster !== undefined && node.poster !== behind) score(node.poster, node.fit)\n // A gallery crops its photos to one shape so its rows line up (AGL-4152): `galleries` holds it.\n if (node.kind === 'group' && !node.gallery) for (const item of node.items) if (item.image !== undefined && item.image !== behind) score(item.image, item.imageFit)\n }\n }\n return ratioKept(measured, kept)\n}\n\n/** The headings: each of the source's drawn as a heading (an `h1`–`h6`, or the question of an accordion). */\nfunction headingsScore(source: SiteImportFidelitySource, built: Built, placement: Placement): SiteImportFidelityCount {\n // Words a source sets in a heading and groups as a customer's quote are that quote (AGL-4152), no part of the page's outline.\n const quoted = new Set(source.layout.sections.flatMap((section) => layoutNodes(section.nodes)).flatMap((node) => (node.kind === 'group' && node.group === 'quotes' ? node.items.flatMap((item) => item.lines) : [])))\n const refs = source.layout.sections.flatMap((section: SiteImportLayoutSection) => section.lines).filter((ref) => source.blocks[ref]?.kind === 'heading' && !quoted.has(ref))\n const kept = refs.filter((ref) => {\n const id = placement.of.get(ref)\n const node = id ? built.node(id) : undefined\n return !!node && (/^h[1-6]$/.test(String(node.props?.['component'] ?? '')) || node.componentId === 'muiAccordionSummary')\n })\n return ratioKept(refs.length, kept.length)\n}\n\n/** Every structural measure of a page by name, groups by kind. */\nfunction pageMeasures(report: Omit<SiteImportPageFidelity, 'score' | 'lowest'>): Array<[string, SiteImportFidelityCount]> {\n return [\n ['sections', report.sections],\n ['bands', report.bands],\n ['widths', report.widths],\n ['rows', report.rows],\n ...Object.entries(report.groups).map(([kind, entry]): [string, SiteImportFidelityCount] => [`${kind} items`, entry.items]),\n ['tables', report.tables],\n ['tabs', report.tabs],\n ['pictures', report.pictures],\n ['framing', report.framing],\n ['icons', report.icons],\n ['buttons', report.buttons],\n ['headings', report.headings],\n ['forms', report.forms],\n ['videos', report.videos],\n ...(report.concealed ? [['concealed', report.concealed] as [string, SiteImportFidelityCount]] : []),\n ...(report.galleries ? [['galleries', report.galleries] as [string, SiteImportFidelityCount]] : []),\n ]\n}\n\n/** The score: the lowest ratio, and the measure it came from. */\nfunction lowestOf(measures: ReadonlyArray<[string, SiteImportFidelityCount]>): { score: number; lowest: string | null } {\n let score = 1\n let lowest: string | null = null\n for (const [name, count] of measures) {\n if (count.ratio < score) {\n score = count.ratio\n lowest = name\n }\n }\n return { score, lowest }\n}\n\n/*------------------------------------------\n * The finish: the look kept, the design improved, the words held (AGL-4152)\n *-----------------------------------------*/\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/** What a path of keys holds in a record, or `undefined`. */\nconst pathIn = (value: unknown, ...keys: string[]): unknown => keys.reduce<unknown>((node, key) => (isRecord(node) ? node[key] : undefined), value)\n\nconst round = (value: number) => Math.round(value * 1000) / 1000\n\n/** A color as `#rrggbb`, or `null` for anything else. */\nfunction hexOf(value: unknown): string | null {\n if (typeof value !== 'string' || !/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(value.trim())) return null\n const hex = value.trim().toLowerCase()\n return hex.length === 4 ? `#${[...hex.slice(1)].map((digit) => digit + digit).join('')}` : hex\n}\n\n/** How far apart two `#rrggbb` colors sit in OKLab (AGL-4152). */\nexport function siteImportOklabDelta(a: string, b: string): number {\n const one = aiHexOklch(a)\n const two = aiHexOklch(b)\n const at = (color: { C: number; h: number }, part: 'a' | 'b') => color.C * (part === 'a' ? Math.cos((color.h * Math.PI) / 180) : Math.sin((color.h * Math.PI) / 180))\n return Math.hypot(one.L - two.L, at(one, 'a') - at(two, 'a'), at(one, 'b') - at(two, 'b'))\n}\n\n/** The contrast an ink and its ground read at: the doctrine's 4.5:1. */\nconst READS_AT = 4.5\n\nconst reads = (ink: string, ground: string) => (contrastRatio(ink, ground) ?? 0) >= READS_AT\n\nfunction schemeOf(colors: unknown): SiteImportFidelityScheme | null {\n if (!isRecord(colors)) return null\n const scheme: SiteImportFidelityScheme = {\n ground: hexOf(pathIn(colors, 'background', 'default')),\n paper: hexOf(pathIn(colors, 'background', 'paper')),\n brand: hexOf(pathIn(colors, 'primary', 'main')),\n onBrand: hexOf(pathIn(colors, 'primary', 'contrastText')),\n ink: hexOf(pathIn(colors, 'text', 'primary')),\n brandLight: hexOf(pathIn(colors, 'primary', 'light')),\n divider: hexOf(pathIn(colors, 'divider')),\n }\n return Object.values(scheme).some(Boolean) ? scheme : null\n}\n\n/** A color a style names, in a scheme: a palette path (`primary.main`) as the scheme draws it, a color as itself. */\nfunction colorIn(value: unknown, scheme: SiteImportFidelityScheme): string | null {\n const own = hexOf(value)\n if (own || typeof value !== 'string') return own\n const paths: Readonly<Record<string, string | null>> = {\n 'primary.main': scheme.brand,\n 'primary.contrastText': scheme.onBrand,\n 'background.default': scheme.ground,\n 'background.paper': scheme.paper,\n 'text.primary': scheme.ink,\n 'primary.light': scheme.brandLight ?? null,\n divider: scheme.divider ?? null,\n 'common.white': '#ffffff',\n 'common.black': '#000000',\n }\n return paths[value] ?? null\n}\n\n/** The color a theme draws an outlined button's words in, in its light scheme: its own style's, else the brand's. */\nexport function siteImportOutlinedColorOf(theme: SiteImportFidelityTheme): string | null {\n const named = theme.button.outlined?.text\n return named === null || named === undefined ? theme.light.brand : colorIn(named, theme.light)\n}\n\n/** A CSS `text-transform` as the case a button's words are set in. */\nconst CASE_OF: Readonly<Record<string, 'upper' | 'none'>> = { uppercase: 'upper', none: 'none', capitalize: 'none', lowercase: 'none' }\n\n/**\n * The colors and buttons of a theme, as a page is drawn in them (AGL-4152):\n * each scheme's grounds, brand and ink, and a filled button's own fill and\n * label where the button's component style sets them apart from the brand's\n * (a `contained` variant, or the contained style overrides), with the case\n * its words are set in: the component's own, else the button Text Style's.\n * `from` says whether the theme is the one the site stores or one computed\n * from its site style. `null` for a theme with no light ground.\n */\nexport function siteImportFidelityThemeOf(theme: unknown, from: SiteImportFidelityTheme['from'] = 'theme'): SiteImportFidelityTheme | null {\n const light = schemeOf(pathIn(theme, 'colorSchemes', 'light'))\n if (!light?.ground) return null\n const button = pathIn(theme, 'components', 'MuiButton')\n const variants = pathIn(button, 'variants')\n /** A variant's styles, the one that wins first: the last of the variants, then its style overrides. */\n const stylesOf = (variant: 'contained' | 'outlined' | 'text') => {\n const own = (Array.isArray(variants) ? variants : []).filter((entry) => {\n const color = pathIn(entry, 'props', 'color')\n return pathIn(entry, 'props', 'variant') === variant && (color === undefined || color === 'primary')\n })\n return [...[...own].reverse().flatMap((entry) => [pathIn(entry, 'sx'), pathIn(entry, 'style')]), pathIn(button, 'styleOverrides', `${variant}Primary`), pathIn(button, 'styleOverrides', variant)].filter(isRecord)\n }\n const contained = stylesOf('contained')\n const dark = schemeOf(pathIn(theme, 'colorSchemes', 'dark'))\n const pickIn = (scheme: SiteImportFidelityScheme, ...keys: string[]) => contained.flatMap((style) => keys.map((key) => colorIn(style[key], scheme))).find((color): color is string => !!color) ?? null\n const pick = (...keys: string[]) => pickIn(light, ...keys)\n const transform = [\n pathIn(button, 'styleOverrides', 'root', 'textTransform'),\n pathIn(button, 'sx', 'root', 'textTransform'),\n pathIn(theme, 'typography', 'variants', 'button', 'textTransform'),\n pathIn(theme, 'typography', 'button', 'textTransform'),\n ].find((value): value is string => typeof value === 'string')\n const caseIn = (styles: ReadonlyArray<Record<string, unknown>>): 'upper' | 'none' | null => {\n const own = [...styles.map((style) => style['textTransform']), transform].find((value): value is string => typeof value === 'string')\n return own ? (CASE_OF[own] ?? null) : null\n }\n const outlined = stylesOf('outlined')\n const named = (...keys: string[]) => outlined.flatMap((style) => keys.map((key) => style[key])).find((value) => value !== undefined) ?? null\n return {\n from,\n light,\n dark,\n button: {\n fill: pick('backgroundColor', 'bgcolor', 'background'),\n label: pick('color'),\n ...(dark ? { fillDark: pickIn(dark, 'backgroundColor', 'bgcolor', 'background'), labelDark: pickIn(dark, 'color') } : {}),\n case: caseIn(contained),\n outlined: { text: named('color'), border: named('borderColor'), fill: named('backgroundColor', 'bgcolor', 'background'), case: caseIn(outlined) },\n text: { case: caseIn(stylesOf('text')) },\n },\n }\n}\n\n/** How near the page a fill sits and is the page's own, in OKLab: the look's own line for a fill to be drawn as one. */\nconst LIKE_THE_PAGE = 0.1\n\n/** The look a built page is drawn in, read through its theme: each node's scheme, a section's ground and ink, a button's case and fill. */\nclass LookOf {\n constructor(\n private readonly built: Built,\n private readonly facts: SiteImportLayout['look'] | null | undefined,\n readonly theme: SiteImportFidelityTheme | null,\n ) {}\n\n /** The scheme a node is drawn in: the one the nearest node holding it sets. */\n scheme(id: string): SiteImportFidelityScheme | null {\n if (!this.theme) return null\n for (const at of this.built.ancestry(id)) {\n const scheme = this.built.node(at)?.props?.['colorScheme']\n if (scheme === 'dark') return this.theme.dark\n if (scheme === 'light') return this.theme.light\n }\n return this.theme.light\n }\n\n /** The color a section is drawn on: its band's role in its scheme. */\n ground(id: string): string | null {\n const scheme = this.scheme(id)\n const fill = this.built.node(id)?.sx?.['bgcolor']\n return scheme ? (fill === undefined || fill === null ? scheme.ground : colorIn(fill, scheme)) : null\n }\n\n /** The words' ink on that ground: the brand's label on a brand band, the scheme's ink elsewhere. */\n ink(id: string): string | null {\n const scheme = this.scheme(id)\n return scheme ? (this.built.node(id)?.sx?.['bgcolor'] === 'primary.main' ? scheme.onBrand : scheme.ink) : null\n }\n\n /** A filled button's fill: its own, else the theme's for filled buttons, else its scheme's brand. */\n fill(id: string): string | null {\n const scheme = this.scheme(id)\n if (!scheme) return null\n const own = this.built.node(id)?.sx?.['bgcolor'] ?? this.built.node(id)?.sx?.['backgroundColor']\n if (own !== undefined) return colorIn(own, scheme)\n const button = this.theme?.button\n return (scheme === this.theme?.dark ? (button?.fillDark ?? button?.fill) : button?.fill) ?? scheme.brand\n }\n\n /** A filled button's label: its own, else the theme's for filled buttons, else the words on its scheme's brand. */\n label(id: string): string | null {\n const scheme = this.scheme(id)\n if (!scheme) return null\n const own = this.built.node(id)?.sx?.['color']\n if (own !== undefined) return colorIn(own, scheme)\n const button = this.theme?.button\n return (scheme === this.theme?.dark ? (button?.labelDark ?? button?.label) : button?.label) ?? scheme.onBrand\n }\n\n /**\n * Whether a button is set in its style's case in the source: its own\n * `textTransform`, else the theme's for that style. A read made before each\n * style's case was kept holds its filled buttons' alone. `null` where either\n * is not known.\n */\n caseKept(id: string | null, style: SiteImportButtonStyle): boolean | null {\n const facts = this.facts\n const wanted = style === 'primary' ? facts?.buttonCase : style === 'secondary' ? (facts?.outlinedCase === undefined ? facts?.buttonCase : facts.outlinedCase) : facts?.textCase === undefined ? facts?.buttonCase : facts.textCase\n if (wanted !== 'upper' && wanted !== 'none') return null\n const own = id ? this.built.node(id)?.sx?.['textTransform'] : undefined\n const button = this.theme?.button\n const themed = style === 'primary' ? button?.case : style === 'secondary' ? (button?.outlined?.case ?? button?.case) : (button?.text?.case ?? button?.case)\n const drawn = typeof own === 'string' ? (CASE_OF[own] ?? 'none') : (themed ?? null)\n return drawn === null ? null : drawn === wanted\n }\n\n /**\n * Whether a filled button is drawn in the source's own fill, within OKLab ΔE\n * 0.05, whatever its label: a light fill under a label that cannot be read\n * on it keeps the fill and takes a label that can. A fill that sits on the\n * page like the page is no fill the look can keep: a white button on a near\n * white page reads as its border. `null` where either is not known.\n */\n fillKept(id: string | null): boolean | null {\n const wanted = hexOf(this.facts?.buttonFill)\n if (!wanted || !this.theme) return null\n if (siteImportOklabDelta(wanted, this.page()) < LIKE_THE_PAGE) return null\n const drawn = id ? this.fill(id) : (this.theme.button.fill ?? this.theme.light.brand)\n return drawn ? siteImportOklabDelta(wanted, drawn) <= SITE_IMPORT_GROUND_DELTA : null\n }\n\n /**\n * Whether an outlined button is drawn as the source draws its own: no fill\n * of its own where it sets none, and its words and border in its color,\n * within OKLab ΔE 0.1. On a dark band, which the source's color was not\n * read for, in the scheme's brand. `null` where either is not known.\n */\n outlineKept(id: string | null): boolean | null {\n const wanted = hexOf(this.facts?.buttonOutline)\n if (!wanted || !this.theme) return null\n const scheme = (id ? this.scheme(id) : null) ?? this.theme.light\n const style = this.theme.button.outlined\n const fill = style?.fill ?? null\n const ownFill = hexOf(this.facts?.outlinedFill)\n const filled = fill !== null && fill !== 'transparent' && fill !== 'none'\n if (ownFill ? !filled || siteImportOklabDelta(ownFill, colorIn(fill, scheme) ?? ownFill) > SITE_IMPORT_GROUND_DELTA : filled) return false\n const near = (color: string | null, to: string | null | undefined) => !!color && !!to && siteImportOklabDelta(color, to) <= SITE_IMPORT_OUTLINE_DELTA\n const named = [style?.text, style?.border].map((color) => (color === null || color === undefined ? scheme.brand : colorIn(color, scheme)))\n // A grey or a black of the source's is its words' color: the theme's words are their own ink, not a pin.\n const light = aiHexOklch(wanted).C < 0.03 ? scheme.ink : wanted\n return named.every((color) => (scheme === this.theme?.light ? near(color, light) : near(color, scheme.brand) || near(color, scheme.brandLight) || near(color, scheme.ink)))\n }\n\n /** The source's page ground: white where it sets none. */\n page(): string {\n return hexOf(this.facts?.background) ?? '#ffffff'\n }\n\n /** The color a section is drawn on in the theme's dark scheme: its band's role there. `null` where the theme has no dark scheme. */\n darkGround(id: string): string | null {\n const scheme = this.theme?.dark ?? null\n if (!scheme) return null\n const fill = this.built.node(id)?.sx?.['bgcolor']\n return fill === undefined || fill === null ? scheme.ground : colorIn(fill, scheme)\n }\n\n /** The inks and grounds the page shows: each section's, and each filled button's label on its fill, once each. */\n pairs(sectionIds: readonly string[]): Array<[string, string]> {\n if (!this.theme) return []\n const out = new Map<string, [string, string]>()\n const add = (ink: string | null, ground: string | null) => {\n if (ink && ground) out.set(`${ink}/${ground}`, [ink, ground])\n }\n for (const id of sectionIds) add(this.ink(id), this.ground(id))\n for (const id of this.built.order) {\n const node = this.built.node(id)\n if (node?.componentId === 'muiButton' && node.props?.['variant'] === 'contained') add(this.label(id), this.fill(id))\n }\n return [...out.values()]\n }\n\n /** The inks and grounds that read at 4.5:1, over those the theme says. */\n readable(sectionIds: readonly string[]): SiteImportFidelityCount {\n const pairs = this.pairs(sectionIds)\n return ratioKept(pairs.length, pairs.filter(([ink, ground]) => reads(ink, ground)).length)\n }\n}\n\n/**\n * The groups whose boxing is scored (AGL-4152): a group drawn as the source's\n * own rows draws no box per row, and an FAQ's questions are the theme's\n * accordions, boxed as the theme boxes them.\n */\nfunction boxesKept(group: SiteImportLayoutGroup): boolean {\n return !group.inline && group.group !== 'faq' && group.group !== 'text'\n}\n\n/** Whether a node draws a box: a card or a paper, or a fill, a shadow or a border on two sides or more of its own. */\nfunction drawsBox(node: SiteImportFidelityNode | undefined): boolean {\n if (!node || node.componentId === 'section') return false\n if (node.componentId === 'muiCard' || node.componentId === 'muiPaper') return true\n const sx = node.sx ?? {}\n const sides = ['borderTop', 'borderRight', 'borderBottom', 'borderLeft'].filter((side) => !!sx[side]).length\n return (sx['bgcolor'] !== undefined && sx['bgcolor'] !== 'transparent') || !!sx['border'] || sides >= 2 || (!!sx['boxShadow'] && sx['boxShadow'] !== 'none')\n}\n\n/** Whether an item of a group is drawn boxed: a box under its element holding every part of it. */\nfunction boxedOn(built: Built, unit: Unit): boolean {\n if (!unit.element) return false\n return built.under(unit.element).some((id) => drawsBox(built.node(id)) && unit.nodes.every((node) => built.holds(id, node)))\n}\n\n/** The lines a section sets in its own flow: its lines and its rows' cells', not its groups', tables' or tabs'. */\nfunction flowLines(nodes: readonly SiteImportLayoutNode[]): SiteImportLineRef[] {\n return nodes.flatMap((node) => (node.kind === 'line' && !node.button ? [node.line] : node.kind === 'row' ? node.cells.flatMap((cell) => flowLines(cell.nodes)) : []))\n}\n\n/** The paragraphs past which a section is a long read, set at `md` and at the start (the compile's own count). */\nconst LONG_READ_PARAGRAPHS = 4\n\n/** Whether a section of the source is a long read: more paragraphs in its own flow (not its groups') than a section's words, which a page sets at the start to be read. */\nconst longRead = (source: SiteImportFidelitySource, section: SiteImportLayoutSection) => flowLines(section.nodes).filter((ref) => source.blocks[ref]?.kind === 'paragraph').length > LONG_READ_PARAGRAPHS\n\n/**\n * The sections set as the source sets them (AGL-4152): their headings, else\n * their words, centered or at the start; a long read set at the start, as\n * text is read, is kept whatever its source centers. Under Keep my site the\n * opening a hero draws is held to it too: a centered opening drawn at the\n * start is the opening moved. Elsewhere it is the hero's to place.\n */\nfunction alignScore(source: SiteImportFidelitySource, built: Built, placement: Placement, pinned: boolean): SiteImportFidelityCount {\n let measured = 0\n let kept = 0\n for (const [index, section] of source.layout.sections.entries()) {\n if (index === 0 && section.hero?.picture && !pinned) continue\n const own = flowLines(section.nodes)\n const headings = own.filter((ref) => source.blocks[ref]?.kind === 'heading')\n const lines = (headings.length ? headings : own.filter((ref) => ['paragraph', 'list-item', 'quote'].includes(source.blocks[ref]?.kind ?? ''))).flatMap((ref) => {\n const id = placement.of.get(ref)\n const node = id ? built.node(id) : undefined\n return node?.componentId === 'muiTypography' ? [node] : []\n })\n if (!lines.length) continue\n measured += 1\n const centered = lines.filter((node) => node.props?.['align'] === 'center').length\n const drawn = centered * 2 > lines.length ? 'center' : 'start'\n if (drawn === section.align || (drawn === 'start' && longRead(source, section))) kept += 1\n }\n return ratioKept(measured, kept)\n}\n\n/** How far a ground may sit from its page's and still be its page's (AGL-4152), in OKLab. */\nconst SAME_GROUND = 0.02\n\n/** Where a ground sits against its page's: on it, lighter or darker. */\nfunction placeOn(ground: string, page: string): -1 | 0 | 1 {\n if (siteImportOklabDelta(ground, page) <= SAME_GROUND) return 0\n return aiHexOklch(ground).L > aiHexOklch(page).L ? 1 : -1\n}\n\n/**\n * Each section with a ground of its own on a ground of the theme within OKLab\n * ΔE 0.05 of it. A picture or a film behind its words is its ground, and is\n * not scored. `ordered`, under Keep my site (AGL-4152), in its place against\n * the page too: two near whites read alike by ΔE, and swapped they draw the\n * wrong bands dark in the dark scheme.\n */\nfunction groundScore(sections: readonly SiteImportLayoutSection[], look: LookOf, roots: ReadonlyArray<string | null>, ordered: boolean): NonNullable<SiteImportPageFidelity['ground']> {\n if (!look.theme) return { ...ratioKept(0, 0), theme: null, worst: null }\n const themePage = look.theme.light.ground as string\n let measured = 0\n let kept = 0\n let worst: number | null = null\n for (const [index, section] of sections.entries()) {\n const wanted = hexOf(section.background)\n if (!wanted || section.backdrop?.kind === 'picture' || section.backdrop?.kind === 'video') continue\n measured += 1\n const root = roots[index]\n const drawn = root ? look.ground(root) : null\n if (!drawn) continue\n const delta = siteImportOklabDelta(wanted, drawn)\n worst = Math.max(worst ?? 0, delta)\n if (delta <= SITE_IMPORT_GROUND_DELTA && (!ordered || placeOn(wanted, look.page()) === placeOn(drawn, themePage))) kept += 1\n }\n return { ...ratioKept(measured, kept), theme: look.theme.from, worst: worst === null ? null : round(worst) }\n}\n\n/**\n * The same sections in the theme's dark scheme (AGL-4152): on the source's own\n * dark fill within OKLab ΔE 0.05 where its stylesheets say one. Else as the\n * light page orders them, against the dark page: a section lighter than its\n * page draws lighter, one on its page's ground on the dark page, one darker\n * set apart from it, and a dark band of the source no lighter than the dark\n * page. A brand band is the brand's in either scheme, and is not scored.\n */\nfunction darkGroundScore(sections: readonly SiteImportLayoutSection[], look: LookOf, roots: ReadonlyArray<string | null>): NonNullable<SiteImportPageFidelity['darkGround']> {\n const darkPage = look.theme?.dark?.ground ?? null\n if (!darkPage) return { ...ratioKept(0, 0), worst: null }\n let measured = 0\n let kept = 0\n let worst: number | null = null\n for (const [index, section] of sections.entries()) {\n const wanted = hexOf(section.background)\n if (!wanted || section.band === 'brand' || section.backdrop?.kind === 'picture' || section.backdrop?.kind === 'video') continue\n measured += 1\n const root = roots[index]\n const drawn = root ? look.darkGround(root) : null\n if (!drawn) continue\n const own = hexOf(section.darkBackground)\n if (own) {\n const delta = siteImportOklabDelta(own, drawn)\n worst = Math.max(worst ?? 0, delta)\n if (delta <= SITE_IMPORT_GROUND_DELTA) kept += 1\n continue\n }\n const place = placeOn(drawn, darkPage)\n const wantedPlace = section.band === 'dark' ? -1 : placeOn(wanted, look.page())\n if (wantedPlace === -1 ? (section.band === 'dark' ? place <= 0 : place !== 0) : place === wantedPlace) kept += 1\n }\n return { ...ratioKept(measured, kept), worst: worst === null ? null : round(worst) }\n}\n\n/** The width a page is measured at (AGL-4152): the 1280 the 11/4 live checks set the source beside the import at. */\nconst VIEW_PX = 1280\n\n/** The Container element's Max Width steps, in px, as the theme's breakpoints set them. */\nconst CONTAINER_PX: Readonly<Record<string, number>> = { xs: 444, sm: 600, md: 900, lg: 1200, xl: 1536 }\n\n/** What a responsive value is at the width a page is measured at: its `lg`, else the nearest below. */\nfunction atView(value: unknown): unknown {\n if (!isRecord(value)) return value\n for (const key of ['lg', 'md', 'sm', 'xs']) if (value[key] !== undefined) return value[key]\n return undefined\n}\n\n/** A Grid item's columns, of 12, at the width a page is measured at: `xs:12 md:6` is 6. */\nfunction gridSpan(size: unknown): number | null {\n if (typeof size === 'number') return size\n const steps = typeof size === 'string' ? Object.fromEntries(size.split(/\\s+/).flatMap((part) => (/^(\\w+):(\\d+)$/.exec(part) ? [[part.split(':')[0], Number(part.split(':')[1])]] : []))) : isRecord(size) ? size : null\n const span = steps ? atView(steps) : null\n return typeof span === 'number' && span > 0 ? Math.min(12, span) : null\n}\n\n/** How wide a node's box runs at the width a page is measured at, in px, from its section down, and how wide its section's content runs. */\nfunction boxPx(built: Built, id: string, root: string | null): { box: number; section: number } {\n const chain = built.ancestry(id).reverse()\n const from = root ? chain.indexOf(root) : 0\n let width = VIEW_PX\n let section: number | null = null\n for (const at of chain.slice(Math.max(0, from))) {\n const node = built.node(at)\n if (!node) continue\n if (node.componentId === 'muiContainer') {\n const cap = CONTAINER_PX[String(atView(node.props?.['maxWidth']))]\n if (cap) width = Math.min(width, cap)\n section ??= width\n }\n if (node.componentId === 'muiGrid' && !setsSideBySide(node)) width *= (gridSpan(node.props?.['size']) ?? 12) / 12\n const max = atView(node.sx?.['maxWidth'])\n if (typeof max === 'number') width = max <= 1 ? width * max : Math.min(width, max)\n else if (typeof max === 'string' && CONTAINER_PX[max]) width = Math.min(width, CONTAINER_PX[max] as number)\n else if (typeof max === 'string' && /^\\d+(?:\\.\\d+)?%$/.test(max)) width *= parseFloat(max) / 100\n else if (typeof max === 'string' && /^\\d+(?:\\.\\d+)?px$/.test(max)) width = Math.min(width, parseFloat(max))\n }\n return { box: width, section: section ?? VIEW_PX }\n}\n\n/** The hero heading's box as a share of its section, against the source's measure: within 10%, where the reader kept it. */\nfunction measureScore(source: SiteImportFidelitySource, built: Built, placement: Placement, roots: ReadonlyArray<string | null>): NonNullable<SiteImportPageFidelity['measure']> {\n const index = source.layout.sections.findIndex((section) => !!section.hero)\n const section = source.layout.sections[index]\n const wanted = section?.hero?.measure\n if (!section || typeof wanted !== 'number' || !(wanted > 0)) return { ...ratioKept(0, 0), shares: null }\n const across = Math.min(section.width ?? VIEW_PX, VIEW_PX)\n const share = Math.min(1, wanted / across)\n const heading = section.lines.find((ref) => {\n const block = source.blocks[ref]\n return block?.kind === 'heading' && block.level === 1\n })\n const id = heading === undefined ? undefined : placement.of.get(heading)\n if (!id) return { ...ratioKept(1, 0), shares: { source: round(share), built: 0 } }\n const drawn = boxPx(built, id, roots[index] ?? null)\n const builtShare = Math.min(1, drawn.box / drawn.section)\n return { ...ratioKept(1, Math.abs(builtShare / share - 1) <= SITE_IMPORT_MEASURE_SHARE ? 1 : 0), shares: { source: round(share), built: round(builtShare) } }\n}\n\n/** How wide a section's words run at the width a page is measured at: its first Container's Max Width, else the page. */\nfunction runPx(built: Built, root: string | undefined | null): number {\n const container = root ? built.under(root).find((id) => built.node(id)?.componentId === 'muiContainer') : undefined\n const cap = container ? CONTAINER_PX[String(atView(built.node(container)?.props?.['maxWidth']))] : undefined\n return Math.min(cap ?? VIEW_PX, VIEW_PX)\n}\n\n/** A section's band as Improve it reads it: by its color alone. */\nconst bandAsItsColor = (section: SiteImportLayoutSection | undefined) => section?.absoluteBand ?? section?.band\n\n/** A line of the design measure: the share of what it asks the source and the build each do, `null` where neither is asked anything. */\nfunction designLine(source: [number, number], built: [number, number]): SiteImportDesignLine | null {\n if (!source[1] || !built[1]) return null\n return { source: round(source[0] / source[1]), built: round(built[0] / built[1]) }\n}\n\n/**\n * Whether the build reads better than its source (AGL-4152), line by line:\n * its rhythm, its measure, its opening, its groups and its colors. Better is\n * at or above the source on every line and above it on one.\n */\nfunction designScore(source: SiteImportFidelitySource, built: Built, placement: Placement, look: LookOf, roots: ReadonlyArray<string | null>, drawnSections: readonly string[]): SiteImportDesignFidelity {\n const sections = source.layout.sections\n // Rhythm: neighbors set apart by their bands, or a rule between them.\n const apart = (pairs: number, at: (index: number) => boolean): [number, number] => [Array.from({ length: pairs }, (_, index) => at(index)).filter(Boolean).length, pairs]\n const ruled = (id: string | undefined) => !!id && (!!built.node(id)?.sx?.['borderTop'] || !!built.node(id)?.sx?.['borderBottom'])\n const drawnBand = (id: string | undefined) => siteImportFidelityBandOf(id ? built.node(id) : undefined)\n const rhythm = designLine(\n apart(Math.max(0, sections.length - 1), (index) => bandAsItsColor(sections[index]) !== bandAsItsColor(sections[index + 1])),\n apart(Math.max(0, drawnSections.length - 1), (index) => drawnBand(drawnSections[index]) !== drawnBand(drawnSections[index + 1]) || ruled(drawnSections[index]) || ruled(drawnSections[index + 1])),\n )\n // Measure: words that run no wider than `lg`, a long read no wider than `md`, each section as its Container runs it.\n const caps = sections.map((section) => (longRead(source, section) ? (CONTAINER_PX['md'] as number) : (CONTAINER_PX['lg'] as number)))\n const measure = designLine(\n // The source's cap read as the Container step a page brought in draws it at; a section it sets none on runs the page.\n [sections.filter((section, index) => Math.min(CONTAINER_PX[siteImportWidthOf(section.width) ?? 'xl'] as number, VIEW_PX) <= (caps[index] as number)).length, sections.length],\n [drawnSections.filter((id, index) => runPx(built, id) <= (caps[index] ?? (CONTAINER_PX['lg'] as number))).length, drawnSections.length],\n )\n // Opening: a first section holding a picture opens as the hero, its heading and its picture together.\n const first = sections[0]\n const pictured = !!first && (first.lines.some((ref) => source.blocks[ref]?.kind === 'image') || first.backdrop?.kind === 'picture' || first.backdrop?.kind === 'video')\n const title = sections.flatMap((section) => section.lines).find((ref) => {\n const block = source.blocks[ref]\n return block?.kind === 'heading' && block.level === 1\n })\n const titleNode = title === undefined ? undefined : placement.of.get(title)\n const opener = drawnSections[0]\n const opens = !!opener && !!titleNode && built.holds(opener, titleNode) && built.has(opener, (node) => node.componentId === 'image' || node.componentId === 'video')\n const opening = pictured ? designLine([first?.hero?.picture ? 1 : 0, 1], [opens ? 1 : 0, 1]) : null\n // Grouped: three or more like items drawn as one group: each its own element, held together apart from the section's other lines.\n let runs = 0\n let sourceGrouped = 0\n let builtGrouped = 0\n for (const [index, section] of sections.entries()) {\n for (const node of layoutNodes(section.nodes)) {\n if (node.kind !== 'group' || node.items.length < 3) continue\n runs += 1\n if (node.group !== 'text') sourceGrouped += 1\n const units = unitsOn(built, placement, node.items.map((item) => item.lines), roots[index] ?? null).filter((unit) => unit.measured)\n const parents = new Set(units.map((unit) => (unit.element ? built.parent.get(unit.element) : null)))\n const parent = parents.size === 1 ? [...parents][0] : null\n const mine = new Set(node.items.flatMap((item) => item.lines))\n const others = section.lines.flatMap((ref) => (mine.has(ref) ? [] : [placement.of.get(ref)])).filter((id): id is string => !!id)\n if (units.length >= 3 && parent && units.every((unit) => unit.element) && !others.some((id) => built.holds(parent, id))) builtGrouped += 1\n }\n }\n const grouped = designLine([sourceGrouped, runs], [builtGrouped, runs])\n // Readable: the source's words on its grounds and its buttons' labels on their fill, against the build's.\n const facts = source.layout.look\n const sourcePairs: Array<[string, string]> = []\n const ink = hexOf(facts?.text)\n for (const section of sections) {\n const ground = hexOf(section.background)\n if (ink && ground && (bandAsItsColor(section) === 'plain' || bandAsItsColor(section) === 'soft')) sourcePairs.push([ink, ground])\n }\n const buttonFill = hexOf(facts?.buttonFill)\n const buttonText = hexOf(facts?.buttonText)\n if (buttonFill && buttonText) sourcePairs.push([buttonText, buttonFill])\n const builtPairs = look.pairs(drawnSections)\n const readable = designLine([sourcePairs.filter(([a, b]) => reads(a, b)).length, sourcePairs.length], [builtPairs.filter(([a, b]) => reads(a, b)).length, builtPairs.length])\n const lines = [rhythm, measure, opening, grouped, readable].filter((line): line is SiteImportDesignLine => !!line)\n const better = lines.length > 0 && lines.every((line) => line.built >= line.source) && lines.some((line) => line.built > line.source)\n return { rhythm, measure, opening, grouped, readable, better }\n}\n\n/*------------------------------------------\n * Improved words (G4)\n *-----------------------------------------*/\n\n/** The words that carry no content of a line: what a rewrite may change freely. */\nconst STOP_WORDS = new Set(\n 'a about all also an and any are as at be been but by can do does each for from get had has have he her here his how i if in into is it its just me more most my no not of on one only or our out over own so some such than that the their them then there these they this those to too up us very was we were what when where which who why will with you your yours'.split(' '),\n)\n\n/** A word's crude stem (G4): its case and one ending dropped, so \"builds\", \"building\" and \"build\" read as one word. */\nfunction stemOf(word: string): string {\n let stem = word.toLowerCase().replace(/['’]s$/, '')\n for (const [ending, to] of [\n [/ies$/, 'y'],\n [/ing$/, ''],\n [/ed$/, ''],\n [/ly$/, ''],\n [/(?<!s)s$/, ''],\n ] as const) {\n if (ending.test(stem) && stem.replace(ending, to).length >= 3) {\n stem = stem.replace(ending, to)\n break\n }\n }\n return stem.length > 3 ? stem.replace(/e$/, '') : stem\n}\n\n/** A line's content words, by stem. */\nconst contentOf = (text: string): Set<string> => new Set(wordsOf(text).filter((word) => word.length >= 2 && !STOP_WORDS.has(word.toLowerCase())).map(stemOf))\n\n/**\n * The share of a line's content words another keeps (G4): 1 for a line with\n * none. A rewrite's `meaning`, and the floor the wording pass holds each\n * rewritten line to (`ai-site-import-wording.ts`), so a rewrite it keeps\n * never scores under it here.\n */\nexport function siteImportContentKept(line: string, rewrite: string): number {\n return contentKept(line, rewrite)\n}\n\n/** How many content words a run of words says, by stem (AGL-4152): what a section says of its own. */\nexport function siteImportContentWords(text: string): number {\n return contentOf(text).size\n}\n\n/** The share of a line's content words another keeps: 1 for a line with none. */\nfunction contentKept(line: string, rewrite: string): number {\n const said = contentOf(line)\n if (!said.size) return 1\n const kept = contentOf(rewrite)\n return [...said].filter((stem) => kept.has(stem)).length / said.size\n}\n\n/** The facts a run of words carries, each by its kind, in the order they are taken: emails, addresses, phones, numbers. */\nconst FACTS: ReadonlyArray<readonly [string, RegExp, (found: string) => string | null]> = [\n ['email', /[\\p{L}\\p{N}._%+-]+@[\\p{L}\\p{N}-]+(?:\\.[\\p{L}\\p{N}-]+)+/gu, (found) => found.toLowerCase()],\n [\n 'url',\n /\\bhttps?:\\/\\/[^\\s<>\"'()]+|\\bwww\\.[^\\s<>\"'()]+|\\b(?:[a-z0-9-]+\\.)+(?:com|org|net|io|co|ai|app|dev|us|uk|ca|au|de|fr|info|biz|me|shop|store|site|online)\\b(?:\\/[^\\s<>\"'()]*)?/giu,\n (found) => found.toLowerCase().replace(/[.,;:!?]+$/, '').replace(/^https?:\\/\\//, '').replace(/^www\\./, '').replace(/\\/$/, ''),\n ],\n ['phone', /(?:\\+\\d{1,3}[\\s.-]?)?(?:\\(\\d{2,4}\\)[\\s.-]?)?\\d{2,4}[\\s.-]\\d{3,4}(?:[\\s.-]\\d{2,4})?/g, (found) => (found.replace(/\\D/g, '').length >= 7 ? found.replace(/\\D/g, '') : null)],\n ['number', /[$€£¥₹]?\\s?\\d+(?:[.,]\\d+)*\\s?%?/gu, (found) => found.replace(/\\s+/g, '').replace(/[.,]+$/, '')],\n]\n\n/** A line's facts: its prices and numbers with their currency, emails, phones and addresses, each as often as it says it. */\nfunction factsIn(text: string): string[] {\n let rest = text\n const out: string[] = []\n for (const [kind, pattern, normal] of FACTS) {\n rest = rest.replace(pattern, (found) => {\n const value = normal(found)\n if (!value) return found\n out.push(`${kind}:${value}`)\n return ' '.repeat(found.length)\n })\n }\n return out\n}\n\n/** The words of a line in capitals, each with whether it opens a sentence. */\nfunction capitalsIn(text: string): Array<{ word: string; opens: boolean; afterSubject: boolean }> {\n const out: Array<{ word: string; opens: boolean; afterSubject: boolean }> = []\n let last = 0\n let before = ''\n for (const match of text.matchAll(/[\\p{L}\\p{N}][\\p{L}\\p{N}'’]*/gu)) {\n const at = match.index ?? 0\n const opens = last === 0 || /[.!?:;•·|—–\"“(]/.test(text.slice(last, at))\n // \"We Specialize in…\", \"We Document every job\": a word straight after its sentence's subject is what it does, capitalized for show (AGL-4152).\n const afterSubject = !opens && SUBJECTS.has(before) && /^\\s+$/.test(text.slice(last, at))\n last = at + match[0].length\n before = match[0].toLowerCase()\n if (/^\\p{Lu}/u.test(match[0])) out.push({ word: match[0], opens, afterSubject })\n }\n return out\n}\n\n/** A web or an email address in a run of words, whose words are written small whatever they name. */\nconst ADDRESSES = /\\S+@\\S+|(?:https?:\\/\\/)?[\\p{L}\\p{N}-]+(?:\\.[\\p{L}\\p{N}-]+)+(?:\\/\\S*)?/gu\n\n/** The words a sentence's subject is said by, which the word after it acts for: never a name before a name. */\nconst SUBJECTS = new Set(['i', 'we', 'you', 'they'])\n\n/**\n * A name as it is matched on a page (AGL-4152): its possessive, its stops and\n * its hyphens dropped, in any case. \"HEB's\", \"HEB\", \"H-E-B\" and \"H.E.B.\" are\n * one store.\n */\nexport function siteImportNameKey(word: string): string {\n return word\n .replace(/['’]s$/iu, '')\n .replace(/[^\\p{L}\\p{N}]/gu, '')\n .toLowerCase()\n}\n\n/** Every name key a run of words says: each word, and each run of initials written with stops or hyphens (\"H-E-B\", \"H.E.B.\"). */\nfunction nameKeysIn(text: string): string[] {\n const words = wordsOf(text).map((word) => word.toLowerCase())\n const initials = [...text.matchAll(/(?<![\\p{L}\\p{N}])\\p{L}(?:[.-]\\p{L})+\\.?(?![\\p{L}\\p{N}])/gu)].map((match) => siteImportNameKey(match[0]))\n return [...words, ...initials]\n}\n\n/** Whether a line is set all in capitals or in title case: its capitals say nothing of its names. */\nfunction shouted(text: string): boolean {\n if (!/\\p{Ll}/u.test(text)) return true\n const long = wordsOf(text).filter((word) => word.length >= 4)\n return long.length >= 3 && long.every((word) => /^\\p{Lu}/u.test(word))\n}\n\n/** What a page's facts are told apart by (G4): the names its source says, and every word it says in any case. */\nexport interface SiteImportFactScope {\n /** Each word the source capitalizes past a sentence's first, in a line not set all in capitals. */\n names: ReadonlySet<string>\n /** Every word the source says, lowercased. */\n said: ReadonlySet<string>\n /**\n * Every word the source says, by its stem (AGL-4152): a heading set in title\n * case says \"Filing\" where the source says \"file\", which is no name.\n */\n stems?: ReadonlySet<string>\n}\n\n/**\n * The fact scope of a page's source lines. `vocabulary` is words a rewrite\n * may say that are no one's name and no one's fact (AGL-4152): the platform's\n * own words for what a page tells, which its request puts to the model\n * (\"why choose it\", \"how it works\"). They are said; they name and claim nothing.\n */\nexport function siteImportFactScope(sourceTexts: readonly string[], vocabulary: readonly string[] = []): SiteImportFactScope {\n const said = new Set([...sourceTexts, ...vocabulary].flatMap(wordsOf).map((word) => word.toLowerCase()))\n // A word the source also writes in small letters is an ordinary word, wherever it capitalizes it (AGL-4152);\n // never in an address, where a name is written small (\"example.app\").\n const small = new Set(sourceTexts.flatMap((text) => wordsOf(text.replace(ADDRESSES, ' '))).filter((word) => /^\\p{Ll}/u.test(word)))\n const names = sourceTexts\n .filter((text) => !shouted(text))\n .flatMap((text) => capitalsIn(text).filter((entry) => !entry.opens && entry.word.length > 1 && !entry.afterSubject && !small.has(entry.word.toLowerCase())).map((entry) => entry.word))\n return {\n names: new Set(names),\n said,\n stems: new Set([...said].map(stemOf)),\n }\n}\n\n/** Whether a scope says a word in any case or any of its endings. */\nconst saidIn = (scope: SiteImportFactScope, word: string) => scope.said.has(word.toLowerCase()) || !!scope.stems?.has(stemOf(word))\n\n/**\n * The fact tokens one line says (G4), each as often as it says it: its\n * prices and numbers with their currency, emails, web addresses and phones,\n * and its names. `own` is a rewrite's line, where a word capitalized past a\n * sentence's first that the source never says is a name the rewrite made up.\n * Two lines with the same tokens keep the same facts, which is how the\n * wording pass holds each line it rewrites (`ai-site-import-wording.ts`).\n */\nexport function siteImportFactTokens(text: string, scope: SiteImportFactScope, own: boolean): string[] {\n const out = factsIn(text)\n for (const entry of capitalsIn(text)) {\n if (scope.names.has(entry.word)) out.push(`name:${entry.word}`)\n // A name the source never says, past a sentence's first word, is one the rewrite made up.\n // A word every sentence uses (\"Us\", \"Our\", \"With\") is no one's name, capitalized in a title or not (AGL-4152).\n else if (own && !entry.opens && entry.word.length > 1 && !shouted(text) && !saidIn(scope, entry.word) && !STOP_WORDS.has(entry.word.toLowerCase())) out.push(`name:${entry.word}`)\n }\n return out\n}\n\n/**\n * The facts of a page's words (G4): every price and number with its\n * currency, email, phone and address, and every name — a word the source\n * capitalizes past a sentence's first — as often as the source says it,\n * and no fact or name the source does not have.\n */\nfunction factsScore(sourceTexts: readonly string[], builtTexts: readonly string[]): SiteImportFidelityFacts {\n const scope = siteImportFactScope(sourceTexts)\n const tally = (texts: readonly string[], own: boolean) => {\n const counts = new Map<string, number>()\n for (const text of texts) for (const token of siteImportFactTokens(text, scope, own)) counts.set(token, (counts.get(token) ?? 0) + 1)\n return counts\n }\n const from = tally(sourceTexts, false)\n const to = tally(builtTexts, true)\n let source = 0\n let builtCount = 0\n let both = 0\n const missing: string[] = []\n const extra: string[] = []\n for (const [token, count] of from) {\n source += count\n const on = to.get(token) ?? 0\n both += Math.min(count, on)\n if (on < count) missing.push(token)\n }\n for (const [token, count] of to) {\n builtCount += count\n if (count > (from.get(token) ?? 0)) extra.push(token)\n }\n const most = Math.max(source, builtCount)\n return { source, built: builtCount, missing: source - both, extra: builtCount - both, ratio: most > 0 ? both / most : 1, examples: { missing: missing.slice(0, 8), extra: extra.slice(0, 8) } }\n}\n\n/** A page's words improved (G4): its facts, its lines each placed once, and each rewrite's meaning. */\nfunction wordingScores(source: SiteImportFidelitySource, built: Built, placement: Placement): Pick<SiteImportPageFidelity, 'facts' | 'lines' | 'meaning'> {\n const text = (ref: SiteImportLineRef) => clean((source.blocks[ref] as { text?: string } | undefined)?.text)\n const lines = source.layout.sections.flatMap((section) => section.lines).filter((ref) => isLine(source.blocks[ref]) && source.blocks[ref]?.kind !== 'image')\n const placed = lines.filter((ref) => placement.of.has(ref)).length\n const extra = placement.unclaimed().length\n const rewritten = [...placement.rewrittenAs].flatMap(([ref, rewrite]) => (contentOf(text(ref)).size ? [{ line: ref, kept: round(contentKept(text(ref), rewrite)), source: text(ref), built: rewrite }] : []))\n const below = rewritten.filter((line) => line.kept < SITE_IMPORT_MEANING_FLOOR)\n return {\n facts: factsScore(source.blocks.flatMap((block) => (isLine(block) && block.kind !== 'image' ? [clean(block.text)] : [])), built.pieces.map((piece) => piece.text)),\n lines: { source: lines.length, built: placed, ratio: lines.length + extra > 0 ? placed / (lines.length + extra) : 1, extra },\n meaning: {\n lines: rewritten.length,\n below: below.length,\n lowest: rewritten.reduce((least, line) => Math.min(least, line.kept), 1),\n ratio: rewritten.length ? (rewritten.length - below.length) / rewritten.length : 1,\n floor: SITE_IMPORT_MEANING_FLOOR,\n examples: below.slice(0, 8),\n },\n }\n}\n\n/*------------------------------------------\n * A generative Improve it (AGL-4152)\n *-----------------------------------------*/\n\n/** The tallest a picture reads as framed on a wide screen, in px: past it, one picture is the whole screen. */\nconst FRAMED_PX = 600\n\n/** The tallest the picture a page opens on reads as framed: a hero may hold the screen. */\nconst FRAMED_OPENING_PX = 800\n\n/** The share of neighbors a page keeps on different grounds. */\nconst RHYTHM_SHARE = 0.75\n\n/** The widest fixed size a phone's screen holds, in px. */\nconst PHONE_PX = 360\n\n/** The tallest fixed picture a phone reads, in px. */\nconst PHONE_PICTURE_PX = 520\n\nconst line = (done: number, of: number, ok = done >= of): SiteImportImprovedLine => ({ done, of, ok })\n\n/** A piece that is only a number of a digit or two: a step's number, a count on a cart, no fact of the page's. */\nconst bareNumber = (text: string) => /^\\s*\\d{1,2}\\s*$/.test(text)\n\n/** A width over a height from how a frame writes it: `16 / 9`, `1.5`, or its value at the width a page is measured at. */\nfunction ratioOf(value: unknown): number | null {\n const at = atView(value)\n if (typeof at === 'number') return at > 0 ? at : null\n if (typeof at !== 'string') return null\n const parts = at.split('/').map((part) => Number.parseFloat(part))\n const [width, height] = parts as [number, number | undefined]\n if (!(width > 0)) return null\n return height === undefined ? width : height > 0 ? width / height : null\n}\n\n/** A height a node sets outright, in px; `null` for none, or one that follows the screen. */\nfunction fixedHeightOf(value: unknown): number | null {\n const at = atView(value)\n if (typeof at === 'number') return at > 8 ? at : null\n if (typeof at === 'string' && /^\\d+(?:\\.\\d+)?px$/.test(at)) return Number.parseFloat(at)\n return null\n}\n\n/** Whether a picture fills a frame that sets its own shape: laid over it, or at its whole height. */\nconst fillsFrame = (node: SiteImportFidelityNode | undefined) => node?.sx?.['position'] === 'absolute' || node?.props?.['height'] === '100%' || node?.sx?.['height'] === '100%'\n\n/** Whether a node shows a heading of the page's outline. */\n/** Elements that draw a run of like items as one group: a line inside one is no line stacked on its own. */\nconst GROUPS_A_RUN: ReadonlySet<string> = new Set(['muiAccordion', 'muiList', 'muiCard'])\n\nconst isHeading = (node: SiteImportFidelityNode | undefined) => {\n if (node?.componentId !== 'muiTypography') return false\n const tag = node.props?.['component'] ?? node.props?.['variant']\n return typeof tag === 'string' && /^h[2-6]$/.test(tag)\n}\n\n/** Whether a Grid cell keeps its place beside another on a phone, on more than two across. */\nconst crowdsPhone = (size: unknown) => {\n if (typeof size !== 'string') return false\n const xs = /\\bxs:(\\d+)\\b/.exec(size)?.[1]\n if (xs) return Number(xs) < 6\n return !/\\b(?:sm|md|lg):/.test(size) && size.trim() !== '' && Number(size) < 6\n}\n\n/** The most characters a line an invented fact sat in is kept at (AGL-4152). */\nexport const SITE_IMPORT_INVENTED_LINE_CHARS = 120\n\n/**\n * A line cut short around what it says (AGL-4152): whole where it is short,\n * else the `SITE_IMPORT_INVENTED_LINE_CHARS` around the first place it says\n * `what`, an ellipsis where it was cut.\n */\nexport function siteImportLineAround(text: string, what: string, most = SITE_IMPORT_INVENTED_LINE_CHARS): string {\n const line = clean(text)\n if (line.length <= most) return line\n const found = line.toLowerCase().indexOf(what.toLowerCase())\n const room = most - 2\n const start = Math.max(0, Math.min(found < 0 ? 0 : found - Math.floor(room / 2), line.length - room))\n return `${start > 0 ? '…' : ''}${line.slice(start, start + room).trim()}${start + room < line.length ? '…' : ''}`\n}\n\n/** The kept ledger and the design lines of a page a generative Improve it built (AGL-4152). */\nfunction improvedScore(source: SiteImportFidelitySource, built: Built, look: LookOf, drawnSections: readonly string[], options: SiteImportImprovedOptions): SiteImportImprovedFidelity {\n const ledger = siteImportLedger({ layout: source.layout, blocks: source.blocks, ...(source.photos ? { photos: source.photos } : {}) })\n const pieces = built.pieces\n const sourceTexts = source.blocks.flatMap((block) => (isLine(block) && block.kind !== 'image' ? [clean(block.text)] : []))\n const anywhere = [...sourceTexts, ...(options.scope ?? [])]\n const scope = siteImportFactScope(anywhere, options.vocabulary ?? [])\n const shown = pieces.map((piece) => piece.text).filter((text) => !bareNumber(text))\n const onPage = new Set(shown.flatMap((text) => siteImportFactTokens(text, scope, false)))\n // Facts: every one the source says, at least once anywhere on the page.\n const ownScope = siteImportFactScope(sourceTexts)\n // A label in title case, \"Start Now\", says no one's name: its capitals are its style.\n const titleCased = (text: string) => wordsOf(text).length >= 2 && wordsOf(text).every((word) => word.length < 3 || /^\\p{Lu}/u.test(word))\n // A page the site's plan proposed has no source to hold: only what it says is held (AGL-4152).\n const said = options.proposed ? [] : [...new Set(sourceTexts.filter((text) => !bareNumber(text)).flatMap((text) => siteImportFactTokens(text, ownScope, false).filter((token) => !token.startsWith('name:') || !titleCased(text))))]\n // A name the page still says, in the sentence case a redesign writes its headings in, is kept (AGL-4152):\n // \"Built on Stone\" rewritten \"built on stone\" keeps its word, and a real name keeps its capital anyway.\n // A name is kept in any of its forms: its possessive, its initials with stops or hyphens (AGL-4152).\n const wordsOnPage = new Set(shown.flatMap(nameKeysIn))\n const missingFacts = said.filter((token) => !onPage.has(token) && !(token.startsWith('name:') && wordsOnPage.has(siteImportNameKey(token.slice(5)))))\n // Invented: none that nothing the import read says.\n const allowed = new Set(anywhere.flatMap((text) => siteImportFactTokens(text, scope, false)))\n const found = [...new Set(shown.flatMap((text) => siteImportFactTokens(text, scope, true)))].filter((token) => !allowed.has(token) && token !== 'name:FAQ' && token !== 'name:FAQs')\n // The line each was found in, cut short around it (AGL-4152): never the page whole.\n const inventedAt = [\n ...new Set(\n found.slice(0, 8).flatMap((token) => {\n const text = shown.find((entry) => siteImportFactTokens(entry, scope, true).includes(token))\n return text ? [siteImportLineAround(text, token.slice(token.indexOf(':') + 1))] : []\n }),\n ),\n ]\n // Held: every thing that must land, on the page.\n const photoOf = new Map((source.photos ?? []).flatMap((photo) => (photo.from ? [[photo.from, photo.src] as const] : [])))\n const keys = pieces.map((piece) => ` ${piece.key} `)\n const shows = (ref: SiteImportLineRef) => {\n const key = wordLine(clean((source.blocks[ref] as { text?: string } | undefined)?.text))\n return !key || keys.some((piece) => piece.includes(` ${key} `))\n }\n const srcs = new Set(built.order.flatMap((id) => [built.node(id)?.props?.['src'], built.node(id)?.props?.['poster']].filter(Boolean) as unknown[]))\n const formsDrawn = built.order.filter((id) => built.node(id)?.componentId === 'form').length\n const formsWanted = options.forms ?? ledger.items.filter((item) => item.kind === 'form').length\n const formOf = (ref: string) => Number(ref.slice(ref.indexOf(':') + 1))\n const musts = ledger.items.filter((item) => item.must && (item.kind !== 'form' || formOf(item.ref) <= formsWanted))\n const missingHeld = musts\n .filter((item) => {\n if (item.kind === 'form') return formsDrawn < formOf(item.ref)\n if (item.kind === 'video') return !built.order.some((id) => built.node(id)?.componentId === 'video')\n if (item.kind === 'picture') {\n const block = source.blocks[item.lines[0] as number]\n const src = block?.kind === 'image' ? photoOf.get(block.url) : undefined\n return !!src && !srcs.has(src)\n }\n return !item.lines.every(shows)\n })\n .map((item) => item.ref)\n // Links: every destination the source's links have here, on the page.\n const hrefs = new Set(built.order.flatMap((id) => {\n const props = built.node(id)?.props ?? {}\n return [props['href'], ...(clean(props['screenId']) ? [`page:${clean(props['screenId'])}`] : [])].filter((value): value is string => typeof value === 'string')\n }))\n const destinations = options.destinations ?? []\n const missingLinks = destinations.filter((to) => !hrefs.has(to) && !hrefs.has(to.replace(/\\/+$/, '')))\n // Meaning: the source's content words, on the page: of what it says, not of its labels (AGL-4152). A heading or a\n // button of a few words (\"Contact us\", \"Visit or call\") is one a redesign is asked to write again as a promise,\n // and on a short page such as a contact page its labels alone would hold the share down; their facts are held above.\n const sourceWords = contentOf(sourceTexts.filter((text) => contentOf(text).size >= SITE_IMPORT_MEANING_LEAST_WORDS).join(' '))\n const pageWords = contentOf(pieces.map((piece) => piece.text).join(' '))\n const kept = [...sourceWords].filter((stem) => pageWords.has(stem)).length\n const meaningOk = options.proposed === true || sourceWords.size === 0 || kept / sourceWords.size >= (options.meaning ?? SITE_IMPORT_IMPROVED_MEANING)\n const ledgerLines = {\n facts: { ...line(said.length - missingFacts.length, said.length), missing: missingFacts.slice(0, 8) },\n invented: { ...line(found.length ? 0 : 1, 1), found: found.slice(0, 8), ...(inventedAt.length ? { at: inventedAt } : {}) },\n held: { ...line(musts.length - missingHeld.length, musts.length), missing: missingHeld },\n links: { ...line(destinations.length - missingLinks.length, destinations.length), missing: missingLinks.slice(0, 8) },\n meaning: line(kept, sourceWords.size, meaningOk),\n }\n\n const has = (id: string, test: (node: SiteImportFidelityNode) => boolean) => built.has(id, test)\n const opener = drawnSections[0]\n const closer = drawnSections[drawnSections.length - 1]\n const filled = (node: SiteImportFidelityNode) => node.componentId === 'muiButton' && node.props?.['variant'] === 'contained' && hasDestination(node)\n const asks = (node: SiteImportFidelityNode) => (node.componentId === 'muiButton' && hasDestination(node)) || node.componentId === 'form'\n // A page that draws its form asks with it (AGL-4152): a form in the first two sections opens on its ask, and one in\n // the last two closes on it, as a contact page is drawn (a short opening, the form, what happens after), with no band.\n const formAt = drawnSections.findIndex((id) => has(id, (node) => node.componentId === 'form'))\n const opens = !!opener && (has(opener, filled) || (formAt >= 0 && formAt <= 1))\n const closes = !!closer && (has(closer, asks) || (formAt >= 0 && formAt >= drawnSections.length - 2))\n const cta = opener && closer ? line((opens ? 1 : 0) + (closes ? 1 : 0), 2) : null\n // Rhythm: neighbors on different grounds.\n const pairs = Math.max(0, drawnSections.length - 1)\n const bandOf = (id: string | undefined) => siteImportFidelityBandOf(id ? built.node(id) : undefined)\n const apart = Array.from({ length: pairs }, (_, at) => bandOf(drawnSections[at]) !== bandOf(drawnSections[at + 1])).filter(Boolean).length\n const rhythm = pairs ? line(apart, pairs, apart / pairs >= RHYTHM_SHARE) : null\n // Columns: no pictures stacked across the page, no run of headings or of short lines one under another, a row somewhere,\n // and, on a page of three sections or more, like items drawn as a group somewhere (AGL-4152).\n // A question list's questions and answers are one group, never a run of lines.\n const inRow = (id: string, root: string) => {\n for (const at of built.ancestry(id)) {\n if (at === root) return false\n if (setsSideBySide(built.node(at)) || GROUPS_A_RUN.has(built.node(at)?.componentId ?? '')) return true\n }\n return false\n }\n const planned = drawnSections.filter((id) => {\n const nodes = built.under(id)\n const across = nodes.filter((at) => {\n // A picture of a row, such as a strip of logos, sits beside the others, whatever the width it is measured at.\n if (built.node(at)?.componentId !== 'image' || fillsFrame(built.node(at)) || inRow(at, id)) return false\n const { box, section } = boxPx(built, at, id)\n return box >= 0.75 * section\n })\n if (across.length >= 2) return false\n const heads = nodes.filter((at) => isHeading(built.node(at)) && !inRow(at, id))\n if (heads.length >= 4) return false\n const lines = nodes.filter((at) => {\n const node = built.node(at)\n return node?.componentId === 'muiTypography' && !isHeading(node) && node.props?.['component'] !== 'h1' && clean(node.props?.['children']).length > 0 && clean(node.props?.['children']).length < 200 && !inRow(at, id)\n })\n return lines.length < 4\n }).length\n const anyRow = drawnSections.some((id) => built.under(id).some((at) => id !== at && setsSideBySide(built.node(at)) && built.children(at).length >= 2))\n // A group: three or more cells of one grid, questions of one list, or lines of one list; a form's fields are its own.\n const anyGroup = drawnSections.some((id) =>\n built.under(id).some((at) => {\n const node = built.node(at)\n if (node?.componentId === 'muiGrid' && setsSideBySide(node)) return built.children(at).length >= 3\n if (node?.componentId === 'muiAccordion') return (built.parent.get(at) ? built.children(built.parent.get(at) as string).filter((child) => built.node(child)?.componentId === 'muiAccordion').length : 0) >= 3\n if (node?.componentId === 'muiList') return built.children(at).length >= 3\n return false\n }),\n )\n const columns = drawnSections.length\n ? line(planned, drawnSections.length, planned === drawnSections.length && (drawnSections.length < 3 || (anyRow && (anyGroup || formAt >= 0))))\n : null\n // Framing: every picture at a size a screen holds, in a frame it fills.\n const natural = new Map((source.photos ?? []).flatMap((photo) => (photo.width && photo.height ? [[photo.src, photo.width / photo.height] as const] : [])))\n const rootOf = (id: string) => drawnSections.find((root) => built.holds(root, id)) ?? null\n const images = built.order.filter((id) => built.node(id)?.componentId === 'image')\n const framed = images.filter((id) => {\n const node = built.node(id) as SiteImportFidelityNode\n const frame = fillsFrame(node) ? built.node(built.parent.get(id) ?? '') : node\n const most = opener && built.holds(opener, id) ? FRAMED_OPENING_PX : FRAMED_PX\n const fixed = fixedHeightOf(node.props?.['height']) ?? fixedHeightOf(frame?.sx?.['height'])\n if (fixed !== null) return fixed <= most\n // A frame as tall as the screen says, a cover's, is no height a picture sets.\n if (fillsFrame(node) && !frame?.sx?.['aspectRatio']) return true\n const ratio = ratioOf(frame?.sx?.['aspectRatio']) ?? ratioOf(node.sx?.['aspectRatio']) ?? natural.get(String(node.props?.['src'])) ?? 16 / 9\n return boxPx(built, id, rootOf(id)).box / ratio <= most\n }).length\n const framing = images.length ? line(framed, images.length) : null\n // Contrast: every ink reads, and the source's own brand fills its buttons.\n const facts = source.layout.look\n const brand = [facts?.buttonFill, facts?.link, facts?.buttonOutline, ...(facts?.palette ?? [])].map(hexOf).find((hex): hex is string => !!hex && aiHexOklch(hex).C >= 0.04)\n const pairsRead = look.pairs(drawnSections)\n const fill = look.theme ? (look.theme.button.fill ?? look.theme.light.brand) : null\n const brandShows = !brand || !fill || siteImportOklabDelta(brand, fill) <= SITE_IMPORT_OUTLINE_DELTA\n const contrast = look.theme ? line(pairsRead.filter(([a, b]) => reads(a, b)).length + (brandShows ? 1 : 0), pairsRead.length + 1) : null\n // Frame: a header with its row and a filled call to action, a phone menu, a footer.\n let frame: SiteImportImprovedLine | null = null\n if (options.frame) {\n const shell = new Built(options.frame)\n const drawer = shell.order.find((id) => shell.node(id)?.componentId === 'muiDrawer') ?? null\n const header = shell.order.find((id) => shell.node(id)?.componentId === 'muiAppBar' || shell.node(id)?.props?.['component'] === 'header') ?? null\n const footer = shell.order.find((id) => shell.node(id)?.props?.['element'] === 'footer' || shell.node(id)?.props?.['component'] === 'footer') ?? null\n const inHeader = header ? shell.under(header).filter((id) => !drawer || !shell.holds(drawer, id)) : []\n const row = inHeader.some((id) => shell.node(id)?.props?.['component'] === 'nav')\n const button = inHeader.some((id) => {\n const node = shell.node(id)\n return !!node && filled(node)\n })\n const links = footer ? shell.has(footer, (node) => hasDestination(node)) || shell.pieces.some((piece) => shell.holds(footer, piece.node)) : false\n frame = line([row, button, !!drawer, links].filter(Boolean).length, 4)\n }\n // Phone: every row stacks, nothing wider or taller than a phone holds.\n const nodes = built.order.map((id) => built.node(id)).filter((node): node is SiteImportFidelityNode => !!node)\n const widths = (node: SiteImportFidelityNode) => [node.sx?.['width'], node.sx?.['minWidth'], node.props?.['width']].some((value) => {\n const fixed = fixedHeightOf(typeof value === 'object' && value && 'xs' in (value as object) ? (value as Record<string, unknown>)['xs'] : value)\n return fixed !== null && fixed > PHONE_PX\n })\n const tall = (node: SiteImportFidelityNode) => [node.props?.['height'], node.sx?.['height']].some((value) => {\n const at = typeof value === 'object' && value && 'xs' in (value as object) ? (value as Record<string, unknown>)['xs'] : value\n const fixed = fixedHeightOf(at)\n return fixed !== null && fixed > PHONE_PICTURE_PX\n })\n const bars = nodes.filter((node) => (node.componentId === 'muiGrid' && crowdsPhone(node.props?.['size'])) || widths(node) || tall(node))\n const phone = drawnSections.length ? line(drawnSections.length - Math.min(drawnSections.length, bars.length), drawnSections.length, bars.length === 0) : null\n\n const design: SiteImportImprovedFidelity['design'] = { cta, rhythm, columns, framing, contrast, frame, phone }\n const red = [\n ...Object.entries(ledgerLines).filter(([, entry]) => !entry.ok).map(([name]) => name),\n ...SITE_IMPORT_IMPROVED_LINES.filter((name) => design[name] && !design[name]?.ok),\n ]\n return { ledger: ledgerLines, design, holds: Object.values(ledgerLines).every((entry) => entry.ok), red }\n}\n\n/*------------------------------------------\n * The frame\n *-----------------------------------------*/\n\n/** A built header and footer, scored against the source's. */\nexport interface SiteImportFrameFidelity {\n /** The lowest ratio of the header's and footer's measures. */\n score: number\n lowest: string | null\n /** The source's top-level items, in the header's row, over the larger of the two (a row of page titles scores low). */\n items: SiteImportFidelityCount\n /** Whether the row's items are in the source's order. */\n inOrder: boolean\n /** The source's menus drawn as menus under their names. */\n menus: SiteImportFidelityCount\n /** The source's menu entries, each a link in its menu. */\n entries: SiteImportFidelityCount\n /** The lines under entries and their icons, in their menus. */\n details: SiteImportFidelityCount\n /** The header's buttons, drawn as the source draws them, each with its destination. */\n ctas: SiteImportFidelityCount\n /** Everything of the row in the phone menu: each menu's name and entries, the links, the buttons. */\n drawer: SiteImportFidelityCount\n /** A menu button shown where the row is not, opening the phone menu. */\n phone: SiteImportFidelityCount\n /** The row's labels held to one line. */\n nowrap: SiteImportFidelityCount\n /** Each column of a menu's panel drawn as its own part of the panel's row, in the source's order, with its heading, words and entries (AGL-4139). */\n menuColumns: SiteImportFidelityCount\n /** The source's filled columns and footer boxes, each drawn in a filled box (AGL-4139). */\n panels: SiteImportFidelityCount\n /** The entries whose icon sits in a filled tile, drawn so (AGL-4139). */\n tiles: SiteImportFidelityCount\n /** The pictures a menu's columns show, placed in them (AGL-4139). */\n pictures: SiteImportFidelityCount\n /** The menus the source opens on hover, opening on hover (AGL-4139). */\n hover: SiteImportFidelityCount\n /** The footer opens with the logo, where the source's does (AGL-4139). */\n logo: SiteImportFidelityCount\n /** The footer's columns under their headings. */\n columns: SiteImportFidelityCount\n /** The footer's links, its columns' and its own. */\n links: SiteImportFidelityCount\n /** Its profiles on other sites. */\n social: SiteImportFidelityCount\n /** Its words, address, phone, email and © line, word for word. */\n facts: SiteImportFidelityCount\n}\n\n/**\n * A menu of the header's row as it is built (AGL-4139): the Dropdown or Mega\n * Menu element under its name, or its name as a link and the panel its hover\n * shows; what it holds, and whether it opens on hover.\n */\nfunction siteImportBuiltMenu(built: Built, row: string, name: string): { inside: string[]; hover: boolean } | null {\n const named = (id: string) => clean(labelOf(built.node(id))) === clean(name)\n const hoverSteps = (id: string): Array<Record<string, unknown>> =>\n (built.node(id)?.interactions ?? []).flatMap((interaction) => {\n const record = interaction as { enabled?: boolean; trigger?: { event?: string }; steps?: unknown[] }\n return record.enabled !== false && record.trigger?.event === 'elementHoverEnter' ? ((record.steps ?? []) as Array<Record<string, unknown>>) : []\n })\n const element = built.under(row).find((id) => (built.node(id)?.componentId === 'muiMegaMenu' || built.node(id)?.componentId === 'muiNavMenu') && named(id))\n if (element) return { inside: built.under(element), hover: hoverSteps(element).some((step) => step['type'] === 'openMenu') }\n const link = built.under(row).find((id) => LINK_COMPONENTS.has(built.node(id)?.componentId ?? '') && named(id))\n if (!link) return null\n // The panel its hover shows: on the name itself, or on the item that holds the name and its panel.\n const item = built.children(row).find((id) => built.holds(id, link)) ?? link\n const shown = [...hoverSteps(link), ...hoverSteps(item)].filter((step) => step['type'] === 'showElement')\n const panelId = shown.map((step) => /^\\[data-aglyn=\"leaf:(.+)\"\\]$/.exec(String(step['selector'] ?? ''))?.[1]).find((id): id is string => !!id && !!built.node(id))\n if (!panelId) return null\n return { inside: [...new Set([...built.under(item), ...built.under(panelId)])], hover: true }\n}\n\n/** A node's label as a menu, a link or a button carries it. */\nfunction labelOf(node: SiteImportFidelityNode | undefined): string {\n if (!node) return ''\n return clean(node.props?.['label']) || clean(node.props?.['children']) || clean(node.props?.['ariaLabel'])\n}\n\nconst LINK_COMPONENTS = new Set(['muiScreenLink', 'muiButton', 'muiLinkBox', 'muiLink'])\n\n/**\n * A built header and footer scored against the source's (AGL-4109): the\n * header's top-level items in order, each menu's entries with the lines and\n * icons under them, its buttons, the phone menu holding all of it, the row's\n * labels on one line; the footer's columns, links, profiles and facts. The\n * score is the lowest ratio.\n */\nexport function siteImportFrameFidelity(source: { nav: SiteImportNavTree | null | undefined; footer: SiteImportFooter | null | undefined }, tree: SiteImportFidelityTree): SiteImportFrameFidelity {\n const built = new Built(tree)\n const all = built.order\n const is = (componentId: string) => (id: string) => built.node(id)?.componentId === componentId\n const drawer = all.find(is('muiDrawer')) ?? null\n const inDrawer = (id: string) => !!drawer && built.holds(drawer, id)\n const header = all.find((id) => built.node(id)?.componentId === 'muiAppBar' || built.node(id)?.props?.['component'] === 'header') ?? null\n const footer = all.find((id) => built.node(id)?.props?.['element'] === 'footer' || built.node(id)?.props?.['component'] === 'footer') ?? null\n const inHeader = header ? built.under(header).filter((id) => !inDrawer(id)) : []\n const row = inHeader.find((id) => built.node(id)?.props?.['component'] === 'nav') ?? null\n const nav = source.nav ?? null\n const groups = nav?.items ?? []\n\n // The row: its items by name, in order; a menu drawn as its name and its panel by its name's.\n const itemLabel = (id: string) => labelOf(built.node(id)) || labelOf(built.node(built.children(id).find((child) => LINK_COMPONENTS.has(built.node(child)?.componentId ?? '')) ?? ''))\n const rowItems = row ? built.children(row).map(itemLabel) : []\n const wanted = groups.map((item) => clean(item.label))\n const left = [...rowItems]\n let matched = 0\n for (const label of wanted) {\n const at = left.indexOf(label)\n if (at !== -1) {\n matched += 1\n left.splice(at, 1)\n }\n }\n const inOrder = rowItems.filter((label) => wanted.includes(label)).join('\\n') === wanted.filter((label) => rowItems.includes(label)).join('\\n')\n\n // Each menu: drawn as one, under its name, with its entries, their lines and icons.\n const menus = { source: 0, built: 0 }\n const entries = { source: 0, built: 0 }\n const details = { source: 0, built: 0 }\n const menuColumns = { source: 0, built: 0 }\n const panels = { source: 0, built: 0 }\n const tiles = { source: 0, built: 0 }\n const pictures = { source: 0, built: 0 }\n const hover = { source: 0, built: 0 }\n const filled = (id: string) => {\n const node = built.node(id)\n return !!node && (node.componentId === 'muiCard' || node.props?.['colorScheme'] === 'dark' || node.sx?.['bgcolor'] !== undefined)\n }\n const label = (id: string) => labelOf(built.node(id)) || shownTexts(built.node(id))[0] || ''\n for (const group of groups) {\n if (!group.items.length) continue\n menus.source += 1\n entries.source += group.items.length\n if (group.panel?.hover) hover.source += 1\n const drawnMenu = row ? siteImportBuiltMenu(built, row, group.label) : null\n for (const entry of group.items) {\n if (entry.text) details.source += 1\n if (entry.iconPath) details.source += 1\n if (entry.tile) tiles.source += 1\n }\n const columns = group.columns ?? []\n const panelled = columns.length >= 2 || columns.some((column) => column.band !== 'plain' || !!column.image || column.lines.length > 0)\n if (panelled) {\n menuColumns.source += columns.length\n panels.source += columns.filter((column) => column.band !== 'plain').length\n pictures.source += columns.filter((column) => !!column.image).length\n }\n if (!drawnMenu) continue\n menus.built += 1\n if (group.panel?.hover && drawnMenu.hover) hover.built += 1\n const inside = drawnMenu.inside\n if (panelled) {\n // The panel's row: the part of it whose children hold the source's columns, each in its place.\n const wanted = columns.map((column, index) => ({ column, labels: group.items.filter((entry) => Math.min(entry.at ?? 0, columns.length - 1) === index).map((entry) => clean(entry.label)) }))\n const placed = (cell: string, want: (typeof wanted)[number]) => {\n const texts = new Set(built.under(cell).map(label))\n return want.labels.every((name) => texts.has(name)) && (!want.column.heading || texts.has(clean(want.column.heading))) && want.column.lines.every((line) => texts.has(clean(line)))\n }\n let best: string[] = []\n for (const id of inside) {\n const cells = built.children(id)\n if (cells.length < columns.length) continue\n const kept = wanted.filter((want, index) => !!cells[index] && placed(cells[index] as string, want)).length\n if (kept > best.filter(Boolean).length) best = wanted.map((want, index) => (cells[index] && placed(cells[index] as string, want) ? (cells[index] as string) : ''))\n }\n menuColumns.built += best.filter(Boolean).length\n columns.forEach((column, index) => {\n const cell = best[index]\n if (!cell) return\n if (column.band !== 'plain' && built.under(cell).some(filled)) panels.built += 1\n if (column.image && built.has(cell, (node) => node.componentId === 'image')) pictures.built += 1\n })\n }\n const links = inside.filter((id) => LINK_COMPONENTS.has(built.node(id)?.componentId ?? ''))\n const texts = new Set(inside.flatMap((id) => shownTexts(built.node(id))))\n for (const entry of group.items) {\n const link = links.find((id) => labelOf(built.node(id)) === clean(entry.label) || shownTexts(built.node(id)).includes(clean(entry.label)) || built.under(id).some((at) => shownTexts(built.node(at)).includes(clean(entry.label))))\n if (!link) continue\n entries.built += 1\n if (entry.text && texts.has(clean(entry.text))) details.built += 1\n if (entry.iconPath && built.has(link, (node) => node.componentId === 'icon')) details.built += 1\n // A tile: the icon held in a filled box of its own.\n const icon = built.under(link).find((id) => built.node(id)?.componentId === 'icon')\n const box = icon ? built.parent.get(icon) : undefined\n if (entry.tile && box && box !== link && filled(box)) tiles.built += 1\n }\n }\n\n // The buttons, as the source draws them.\n const ctas = { source: 0, built: 0 }\n for (const cta of nav?.ctas ?? []) {\n ctas.source += 1\n const button = inHeader.find((id) => built.node(id)?.componentId === 'muiButton' && clean(built.node(id)?.props?.['children']) === clean(cta.label))\n const node = button ? built.node(button) : undefined\n if (node && node.props?.['variant'] === BUTTON_VARIANT[cta.style] && (!cta.href || hasDestination(node))) ctas.built += 1\n }\n\n // The phone menu: every name, entry, link and button of the row.\n const drawerTexts = new Set(drawer ? built.under(drawer).flatMap((id) => shownTexts(built.node(id))) : [])\n const drawerWanted = [\n ...groups.flatMap((group) => [\n clean(group.label),\n ...group.items.map((entry) => clean(entry.label)),\n // Every word of a menu's panel too (AGL-4139): its columns' headings and lines.\n ...(group.columns ?? []).flatMap((column) => [...(column.heading ? [clean(column.heading)] : []), ...column.lines.map(clean)]),\n ]),\n ...(nav?.ctas ?? []).map((cta) => clean(cta.label)),\n ].filter(Boolean)\n const toggle = inHeader.some(is('muiDrawerToggle'))\n const hasRow = groups.length > 0 || (nav?.ctas.length ?? 0) > 0\n\n // The footer.\n const foot = source.footer ?? null\n const footIds = footer ? built.under(footer) : []\n const footTexts = new Set(footIds.flatMap((id) => shownTexts(built.node(id))))\n const footLinks = footIds.filter((id) => LINK_COMPONENTS.has(built.node(id)?.componentId ?? ''))\n const footLinkLabels = footLinks.map((id) => labelOf(built.node(id)))\n const columnLinks = (foot?.columns ?? []).flatMap((column) => column.links)\n const linksWanted = [...columnLinks, ...(foot?.links ?? [])]\n const linkLeft = [...footLinkLabels]\n let linksKept = 0\n for (const link of linksWanted) {\n const at = linkLeft.indexOf(clean(link.label))\n if (at !== -1) {\n linksKept += 1\n linkLeft.splice(at, 1)\n }\n }\n const profiles = footIds.filter(is('socialLinks')).flatMap((id) => Object.entries(built.node(id)?.props ?? {}).filter(([, value]) => typeof value === 'string' && /^https?:/.test(value as string)))\n const hrefs = new Set(footLinks.map((id) => clean(built.node(id)?.props?.['href'])))\n const socialKept = (foot?.social ?? []).filter((profile) => profiles.some(([network, href]) => network === profile.network || href === profile.href) || hrefs.has(clean(profile.href))).length\n const facts = [...(foot?.text ?? []), foot?.address, foot?.phone, foot?.email, foot?.copyright].map(clean).filter(Boolean)\n // Its filled boxes, each a filled box holding its heading, words and links (AGL-4139).\n for (const box of foot?.panels ?? []) {\n panels.source += 1\n const want = [box.heading, ...box.lines, ...(box.links ?? []).map((entry) => entry.label)].filter((text): text is string => !!text).map(clean)\n if (footIds.some((id) => filled(id) && want.every((text) => built.under(id).some((at) => label(at) === text)))) panels.built += 1\n }\n // It opens with the logo: a picture before any of its words.\n const firstWords = footIds.find((id) => shownTexts(built.node(id)).length > 0)\n const firstPicture = footIds.find((id) => built.node(id)?.componentId === 'image')\n const logo = ratioKept(foot?.logo ? 1 : 0, foot?.logo && firstPicture && (!firstWords || footIds.indexOf(firstPicture) < footIds.indexOf(firstWords)) ? 1 : 0)\n\n const report: Omit<SiteImportFrameFidelity, 'score' | 'lowest'> = {\n // Over the larger of the two: a row of the site's page titles in place of the source's menus scores low.\n items: { source: wanted.length, built: matched, ratio: Math.max(wanted.length, rowItems.length) > 0 ? matched / Math.max(wanted.length, rowItems.length) : 1 },\n inOrder,\n menus: ratioKept(menus.source, menus.built),\n entries: ratioKept(entries.source, entries.built),\n details: ratioKept(details.source, details.built),\n ctas: ratioKept(ctas.source, ctas.built),\n drawer: ratioKept(drawerWanted.length, drawerWanted.filter((label) => drawerTexts.has(label)).length),\n phone: ratioKept(hasRow ? 1 : 0, hasRow && toggle && !!drawer ? 1 : 0),\n nowrap: ratioKept(row ? 1 : 0, row && built.node(row)?.sx?.['whiteSpace'] === 'nowrap' ? 1 : 0),\n menuColumns: ratioKept(menuColumns.source, menuColumns.built),\n panels: ratioKept(panels.source, panels.built),\n tiles: ratioKept(tiles.source, tiles.built),\n pictures: ratioKept(pictures.source, pictures.built),\n hover: ratioKept(hover.source, hover.built),\n logo,\n columns: ratioKept(foot?.columns.length ?? 0, (foot?.columns ?? []).filter((column) => footTexts.has(clean(column.heading))).length),\n links: ratioKept(linksWanted.length, linksKept),\n social: ratioKept(foot?.social.length ?? 0, socialKept),\n facts: ratioKept(facts.length, facts.filter((fact) => footTexts.has(fact)).length),\n }\n const measures: Array<[string, SiteImportFidelityCount]> = [\n ['items', report.items],\n ['menus', report.menus],\n ['entries', report.entries],\n ['details', report.details],\n ['ctas', report.ctas],\n ['drawer', report.drawer],\n ['phone', report.phone],\n ['nowrap', report.nowrap],\n ['menuColumns', report.menuColumns],\n ['panels', report.panels],\n ['tiles', report.tiles],\n ['pictures', report.pictures],\n ['hover', report.hover],\n ['logo', report.logo],\n ['columns', report.columns],\n ['links', report.links],\n ['social', report.social],\n ['facts', report.facts],\n ]\n return { ...lowestOf(measures), ...report }\n}\n"],"names":["contrastRatio","SITE_IMPORT_PLAY_WORDS","siteImportWidthOf","siteImportLedger","aiHexOklch","SITE_IMPORT_FIDELITY_THRESHOLD","SITE_IMPORT_IMPROVED_LINES","SITE_IMPORT_IMPROVED_MEANING","SITE_IMPORT_MEANING_LEAST_WORDS","SITE_IMPORT_GROUND_DELTA","SITE_IMPORT_OUTLINE_DELTA","SITE_IMPORT_MEASURE_SHARE","SITE_IMPORT_MEANING_FLOOR","SITE_IMPORT_IMPROVE_FREE","clean","text","replace","trim","WORD","wordsOf","match","wordLine","join","isLine","block","kind","url","inline","tableCells","rows","split","flatMap","line","map","cell","filter","Boolean","shownTexts","node","props","out","key","value","push","componentId","hasDestination","interactions","length","BUTTON_VARIANT","primary","secondary","quiet","siteImportFidelityBandOf","ground","sx","siteImportFidelityTreeOf","nodes","ids","Object","keys","rootId","find","id","parentId","Built","tree","at","enter","get","ancestry","parent","holds","a","b","start","end","exit","point","undefined","under","order","slice","children","child","has","common","every","test","some","Map","pieces","seen","Set","visit","add","set","ratioKept","source","built","ratio","Math","min","ratioBoth","max","Placement","cursor","previous","own","free","piece","owner","claimedBy","pick","list","reduce","best","gap","abs","bestGap","joined","endsWith","exact","padded","part","includes","placeRewritten","layout","sections","forEach","section","index","scopes","lines","ref","blocks","run","from","settle","to","align","of","Number","POSITIVE_INFINITY","left","Array","fill","i","j","pair","contentKept","here","rewrittenAs","unclaimed","flat","said","nodesOf","refs","whole","measured","pictures","photos","sectionRoots","imageClaimed","photoOf","photo","src","root","scope","images","found","unitsOn","placement","parts","stop","others","other","anchor","element","up","setsSideBySide","isByline","cells","findIndex","words","count","total","layoutNodes","tab","tabs","panel","linesOf","item","items","row","label","siteImportFidelity","options","finished","finish","improvedWords","theme","pinned","drawnSections","aligned","roots","_","look","LookOf","wordsScore","read","absoluteBand","band","drawn","bandsKept","groups","tables","buttons","unlinked","buttonCase","buttonFill","buttonOutline","boxed","icons","lone","drawnFilms","films","buttonKept","style","drawnAs","cased","caseKept","filled","fillKept","outlined","outlineKept","button","href","units","parents","unit","size","shared","sharedLinkLines","wanted","icon","mark","listIcon","group","judged","boxesKept","boxedOn","entry","groupsKept","itemsKept","kept","itemKept","shown","labels","one","strip","picturesScore","framing","framingScore","headings","headingsScore","widths","widthsScore","forms","videos","video","report","bands","fromEntries","entries","concealed","concealedScore","galleriesScore","lowestOf","pageMeasures","case","outline","added","scoredAs","alignScore","groundScore","darkGround","darkGroundScore","measure","measureScore","readable","design","designScore","wordingScores","full","improved","improvedScore","ledger","lowest","least","name","done","ok","score","finishMeasures","pins","siteImportFidelityHolds","threshold","facts","meaning","below","image","each","keyOf","toLowerCase","improve","tally","counts","word","links","again","sourceWords","builtWords","both","missing","extra","on","most","examples","WIDTH_RANK","sm","md","lg","xl","width","container","rank","galleries","gallery","copies","SAME_SHAPE","shapeOf","exec","height","heightOf","builtFrame","ratios","values","frame","holder","sizes","fit","radius","box","behind","hero","picture","poster","imageFit","quoted","String","measures","isRecord","isArray","pathIn","round","hexOf","hex","digit","siteImportOklabDelta","two","color","C","cos","h","PI","sin","hypot","L","READS_AT","reads","ink","schemeOf","colors","scheme","paper","brand","onBrand","brandLight","divider","colorIn","paths","siteImportOutlinedColorOf","named","light","CASE_OF","uppercase","none","capitalize","lowercase","siteImportFidelityThemeOf","variants","stylesOf","variant","reverse","contained","dark","pickIn","transform","caseIn","styles","fillDark","labelDark","border","LIKE_THE_PAGE","outlinedCase","textCase","themed","page","ownFill","outlinedFill","near","background","pairs","sectionIds","drawsBox","sides","side","flowLines","LONG_READ_PARAGRAPHS","longRead","centered","SAME_GROUND","placeOn","ordered","worst","themePage","backdrop","delta","darkPage","darkBackground","place","wantedPlace","VIEW_PX","CONTAINER_PX","xs","atView","gridSpan","steps","span","boxPx","chain","indexOf","cap","parseFloat","shares","across","share","heading","level","builtShare","runPx","bandAsItsColor","designLine","first","apart","ruled","drawnBand","rhythm","caps","pictured","title","titleNode","opener","opens","opening","runs","sourceGrouped","builtGrouped","mine","grouped","sourcePairs","buttonText","builtPairs","better","STOP_WORDS","stemOf","stem","ending","contentOf","siteImportContentKept","rewrite","siteImportContentWords","FACTS","factsIn","rest","pattern","normal","repeat","capitalsIn","last","before","matchAll","afterSubject","SUBJECTS","ADDRESSES","siteImportNameKey","nameKeysIn","initials","shouted","long","siteImportFactScope","sourceTexts","vocabulary","small","names","stems","saidIn","siteImportFactTokens","factsScore","builtTexts","texts","token","builtCount","placed","rewritten","floor","FRAMED_PX","FRAMED_OPENING_PX","RHYTHM_SHARE","PHONE_PX","PHONE_PICTURE_PX","bareNumber","ratioOf","fixedHeightOf","fillsFrame","GROUPS_A_RUN","isHeading","tag","crowdsPhone","SITE_IMPORT_INVENTED_LINE_CHARS","siteImportLineAround","what","room","anywhere","onPage","ownScope","titleCased","proposed","startsWith","wordsOnPage","missingFacts","allowed","inventedAt","shows","srcs","formsDrawn","formsWanted","formOf","musts","must","missingHeld","hrefs","destinations","missingLinks","pageWords","meaningOk","ledgerLines","invented","held","closer","asks","formAt","closes","cta","bandOf","inRow","planned","heads","anyRow","anyGroup","columns","natural","rootOf","framed","fixed","link","palette","pairsRead","brandShows","contrast","shell","drawer","header","footer","inHeader","tall","bars","phone","red","siteImportBuiltMenu","labelOf","hoverSteps","interaction","record","enabled","trigger","event","inside","hover","step","LINK_COMPONENTS","panelId","siteImportFrameFidelity","all","is","inDrawer","nav","itemLabel","rowItems","matched","splice","inOrder","menus","details","menuColumns","panels","tiles","drawnMenu","iconPath","tile","panelled","column","want","ctas","drawerTexts","drawerWanted","toggle","hasRow","foot","footIds","footTexts","footLinks","footLinkLabels","columnLinks","linksWanted","linkLeft","linksKept","profiles","socialKept","social","profile","network","address","email","copyright","firstWords","firstPicture","logo","nowrap","fact"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA4C2C,GAE3C,SAASA,aAAa,QAAQ,oCAAmC;AAEjE,SAASC,sBAAsB,EAAEC,iBAAiB,QAAyD,sBAAkB;AAC7H,SAASC,gBAAgB,QAAQ,6BAAyB;AAC1D,SAASC,UAAU,QAAQ,oBAAgB;AAiB3C,sGAAsG,GACtG,OAAO,MAAMC,iCAAiC,IAAG;AA6MjD,4DAA4D,GAC5D,OAAO,MAAMC,6BAA6B;IAAC;IAAO;IAAU;IAAW;IAAW;IAAY;IAAS;CAAQ,CAAS;AAGxH,mFAAmF,GACnF,OAAO,MAAMC,+BAA+B,IAAG;AAE/C,+HAA+H,GAC/H,OAAO,MAAMC,kCAAkC,EAAC;AAoIhD,kFAAkF,GAClF,OAAO,MAAMC,2BAA2B,KAAI;AAE5C;;;;;CAKC,GACD,OAAO,MAAMC,4BAA4B,IAAG;AAE5C,sGAAsG,GACtG,OAAO,MAAMC,4BAA4B,IAAG;AAE5C,+HAA+H,GAC/H,OAAO,MAAMC,4BAA4B,IAAG;AAE5C,2EAA2E,GAC3E,OAAO,MAAMC,2BAA8C;IAAC;IAAS;IAAU;IAAQ;IAAW;IAAU;IAAW;IAAS;CAAQ,CAAA;AAaxI;;2CAE2C,GAE3C,MAAMC,QAAQ,CAACC,OAA2B,OAAOA,SAAS,WAAWA,KAAKC,OAAO,CAAC,QAAQ,KAAKC,IAAI,KAAK;AAExG,MAAMC,OAAO;AAEb,8BAA8B,GAC9B,MAAMC,UAAU,CAACJ;QAA2BA;YAAAA,cAAAA,KAAKK,KAAK,CAACF,iBAAXH,cAAoB,EAAE;;AAElE;;;CAGC,GACD,MAAMM,WAAW,CAACN,OAAyBI,QAAQJ,MAAMO,IAAI,CAAC,QAAQR,MA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