@aglyn/plugins-ai 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-insight-dialog.component.js +7 -2
  3. package/src/lib/components/ai-insight-dialog.component.js.map +1 -1
  4. package/src/lib/components/ai-job-request.component.d.ts +28 -0
  5. package/src/lib/components/ai-job-request.component.js +103 -0
  6. package/src/lib/components/ai-job-request.component.js.map +1 -0
  7. package/src/lib/components/ai-jobs-list-page.component.d.ts +2 -0
  8. package/src/lib/components/ai-jobs-list-page.component.js +2 -2
  9. package/src/lib/components/ai-jobs-list-page.component.js.map +1 -1
  10. package/src/lib/components/ai-site-build-page.component.js +36 -6
  11. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  12. package/src/lib/components/ai-site-import-job.component.js +2 -2
  13. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  14. package/src/lib/insights/ai-insight-digest.d.ts +34 -5
  15. package/src/lib/insights/ai-insight-digest.js +171 -10
  16. package/src/lib/insights/ai-insight-digest.js.map +1 -1
  17. package/src/lib/jobs/ai-job-import-step.d.ts +35 -2
  18. package/src/lib/jobs/ai-job-import-step.js +124 -12
  19. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  20. package/src/lib/jobs/ai-job-insight-step.d.ts +1 -1
  21. package/src/lib/jobs/ai-job-insight-step.js +5 -1
  22. package/src/lib/jobs/ai-job-insight-step.js.map +1 -1
  23. package/src/lib/jobs/ai-jobs.d.ts +6 -0
  24. package/src/lib/jobs/ai-jobs.js +43 -6
  25. package/src/lib/jobs/ai-jobs.js.map +1 -1
  26. package/src/lib/jobs/ai-layout-stock-photos.d.ts +13 -6
  27. package/src/lib/jobs/ai-layout-stock-photos.js +104 -32
  28. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  29. package/src/lib/jobs/ai-site-import-compile.js +110 -23
  30. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  31. package/src/lib/jobs/ai-site-import-document.d.ts +5 -0
  32. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  33. package/src/lib/jobs/ai-site-import-forms.d.ts +83 -0
  34. package/src/lib/jobs/ai-site-import-forms.js +376 -0
  35. package/src/lib/jobs/ai-site-import-forms.js.map +1 -0
  36. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.d.ts +21 -0
  37. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js +77 -0
  38. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js.map +1 -0
  39. package/src/lib/layout-language/ai-layout-compiler.d.ts +2 -0
  40. package/src/lib/layout-language/ai-layout-compiler.js +215 -30
  41. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  42. package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
  43. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  44. package/src/lib/model/ai-credit-estimate.d.ts +25 -22
  45. package/src/lib/model/ai-credit-estimate.js +24 -22
  46. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  47. package/src/lib/model/ai-insight.d.ts +4 -0
  48. package/src/lib/model/ai-insight.js +1 -0
  49. package/src/lib/model/ai-insight.js.map +1 -1
  50. package/src/lib/model/ai-site-build-progress.d.ts +8 -0
  51. package/src/lib/model/ai-site-build-progress.js +62 -1
  52. package/src/lib/model/ai-site-build-progress.js.map +1 -1
  53. package/src/lib/model/ai-site-import-fidelity.d.ts +2 -0
  54. package/src/lib/model/ai-site-import-fidelity.js +41 -5
  55. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  56. package/src/lib/model/ai-site-import-report.d.ts +60 -0
  57. package/src/lib/model/ai-site-import-report.js +116 -0
  58. package/src/lib/model/ai-site-import-report.js.map +1 -0
  59. package/src/lib/model/ai-site-import-view.d.ts +7 -1
  60. package/src/lib/model/ai-site-import-view.js +14 -2
  61. package/src/lib/model/ai-site-import-view.js.map +1 -1
  62. package/src/lib/model/ai-site-import.d.ts +49 -2
  63. package/src/lib/model/ai-site-import.js +81 -23
  64. package/src/lib/model/ai-site-import.js.map +1 -1
  65. package/src/lib/plugin.js +1 -1
  66. package/src/lib/plugin.js.map +1 -1
  67. package/src/lib/runtime/ai-insight-check.js +22 -6
  68. package/src/lib/runtime/ai-insight-check.js.map +1 -1
  69. package/src/lib/server/ai-insight-digest-route.js +3 -1
  70. package/src/lib/server/ai-insight-digest-route.js.map +1 -1
  71. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +4 -0
  72. package/src/lib/site-import/fixtures/site-layout-recordings.js +9 -4
  73. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  74. package/src/lib/site-import/site-import-css.d.ts +10 -1
  75. package/src/lib/site-import/site-import-css.js +19 -12
  76. package/src/lib/site-import/site-import-css.js.map +1 -1
  77. package/src/lib/site-import/site-import-html.d.ts +17 -4
  78. package/src/lib/site-import/site-import-html.js +146 -17
  79. package/src/lib/site-import/site-import-html.js.map +1 -1
  80. package/src/lib/site-import/site-import-layout.js +194 -32
  81. package/src/lib/site-import/site-import-layout.js.map +1 -1
  82. package/src/lib/tools/ai-insight-tool.js +11 -3
  83. package/src/lib/tools/ai-insight-tool.js.map +1 -1
@@ -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 and their bands; its rows of columns\n * side by side; its groups by kind, each item its own element with its\n * parts (an FAQ's question on an accordion, a card's link on the card);\n * its tables, tab strips, pictures, icons, buttons as the source draws\n * 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\nimport type { SiteImportBlock } from '../site-import/site-import-html'\nimport type {\n SiteImportBand,\n SiteImportButtonStyle,\n SiteImportFooter,\n SiteImportGroupKind,\n SiteImportLayout,\n SiteImportLayoutItem,\n SiteImportLayoutNode,\n SiteImportLayoutSection,\n SiteImportLineRef,\n SiteImportNavTree,\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 /** The source's rows of two or more columns, set side by side on the page. */\n rows: 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 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 & { unlinked: number }\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\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`); without them a picture is counted, not placed. */\n photos?: ReadonlyArray<{ from?: string; src: 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 /** 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 private readonly claimedBy = new Map<Piece, SiteImportLineRef>()\n private readonly imageClaimed = new Set<string>()\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 const images = built.under(root).filter((id) => built.node(id)?.componentId === 'image')\n let cursor = -1\n let previous: SiteImportLineRef | null = null\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?.['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)\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): 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 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 const part = pieces.filter((piece) => free(piece) && piece.key && (` ${piece.key} `.includes(padded) || padded.includes(` ${piece.key} `)))\n return pick(part)\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 */\nexport function siteImportFidelity(source: SiteImportFidelitySource, tree: SiteImportFidelityTree): SiteImportPageFidelity {\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\n const words = wordsScore(source, built)\n const read = sections.map((section) => 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 const icons = { source: 0, built: 0, lone: 0 }\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 if (!node.button) break\n const block = source.blocks[node.line]\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 const id = placement.of.get(node.line)\n const drawnAs = id ? built.node(id) : undefined\n if (drawnAs?.componentId === 'muiButton' && drawnAs.props?.['variant'] === BUTTON_VARIANT[node.button] && hasDestination(drawnAs)) 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 const units = unitsOn(built, placement, node.items.map((item) => 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 const wanted = (item.icon !== 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 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 headings = headingsScore(source, built, placement)\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\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 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 icons: { ...ratioKept(icons.source, icons.built), lone: icons.lone },\n buttons: { ...ratioKept(buttons.source, buttons.built), unlinked: buttons.unlinked },\n headings,\n forms,\n }\n return { ...lowestOf(pageMeasures(report)), ...report }\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.\n if (item.image !== undefined && !built.has(element, (node) => node.componentId === 'image')) return false\n return true\n}\n\n/** The words: the source's lines against what the page shows, each word as often as it is said. */\nfunction wordsScore(source: SiteImportFidelitySource, built: Built): 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 said = tally(source.blocks.flatMap((block) => (isLine(block) && block.kind !== 'image' ? [clean(block.text)] : [])))\n const shown = tally(built.pieces.map((piece) => piece.text))\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\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 const drawn = built.order.filter((id) => built.node(id)?.componentId === 'image').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/** 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 const refs = source.layout.sections.flatMap((section: SiteImportLayoutSection) => section.lines).filter((ref) => source.blocks[ref]?.kind === 'heading')\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 ['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 ['icons', report.icons],\n ['buttons', report.buttons],\n ['headings', report.headings],\n ['forms', report.forms],\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 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 /** 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/** 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.\n const rowItems = row ? built.children(row).map((id) => labelOf(built.node(id))) : []\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 for (const group of groups) {\n if (!group.items.length) continue\n menus.source += 1\n entries.source += group.items.length\n const menu = row\n ? built.under(row).find((id) => (built.node(id)?.componentId === 'muiMegaMenu' || built.node(id)?.componentId === 'muiNavMenu') && clean(built.node(id)?.props?.['label']) === clean(group.label))\n : undefined\n for (const entry of group.items) {\n if (entry.text) details.source += 1\n if (entry.iconPath) details.source += 1\n }\n if (!menu) continue\n menus.built += 1\n const inside = built.under(menu)\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 }\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) => [clean(group.label), ...group.items.map((entry) => clean(entry.label))]),\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\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 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 ['columns', report.columns],\n ['links', report.links],\n ['social', report.social],\n ['facts', report.facts],\n ]\n return { ...lowestOf(measures), ...report }\n}\n"],"names":["SITE_IMPORT_FIDELITY_THRESHOLD","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","holds","a","b","start","enter","get","end","exit","point","undefined","under","order","slice","children","child","has","common","at","parent","every","test","some","Map","pieces","seen","Set","visit","add","set","ratioKept","source","built","ratio","Math","min","ratioBoth","max","Placement","cursor","previous","free","piece","owner","claimedBy","pick","list","reduce","best","gap","abs","bestGap","exact","padded","part","includes","nodesOf","refs","whole","measured","pictures","photos","ref","blocks","of","sectionRoots","imageClaimed","photoOf","photo","from","src","layout","sections","forEach","section","index","root","scope","images","lines","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","drawnSections","aligned","roots","_","wordsScore","read","band","drawn","bandsKept","groups","tables","buttons","unlinked","icons","lone","drawnAs","button","href","units","parents","unit","size","wanted","icon","listIcon","group","entry","groupsKept","itemsKept","kept","itemKept","shown","labels","one","strip","picturesScore","headings","headingsScore","forms","report","bands","fromEntries","entries","lowestOf","pageMeasures","to","image","tally","counts","word","said","sourceWords","builtWords","both","missing","extra","on","most","examples","String","measures","score","lowest","name","labelOf","LINK_COMPONENTS","siteImportFrameFidelity","all","inHeader","is","drawer","inDrawer","header","footer","nav","rowItems","left","matched","indexOf","splice","inOrder","menus","details","menu","iconPath","inside","links","texts","link","ctas","cta","style","drawerTexts","drawerWanted","toggle","hasRow","foot","footIds","footTexts","footLinks","footLinkLabels","columnLinks","columns","column","linksWanted","linkLeft","linksKept","profiles","hrefs","socialKept","social","profile","network","facts","address","phone","email","copyright","nowrap","heading","fact"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA6B2C;AAgB3C,sGAAsG,GACtG,OAAO,MAAMA,iCAAiC,IAAG;AAgGjD;;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,MAAMC;AAE5E,wFAAwF,GACxF,SAASQ,OAAOC,KAAkC;IAChD,IAAI,CAACA,OAAO,OAAO;IACnB,IAAIA,MAAMC,IAAI,KAAK,SAAS,OAAO,CAAC,CAACD,MAAME,GAAG;IAC9C,IAAIF,MAAMC,IAAI,KAAK,QAAQ,OAAO,CAACD,MAAMG,MAAM,IAAI,CAAC,CAACb,MAAMU,MAAMT,IAAI;IACrE,OAAO,CAAC,CAACD,MAAMU,MAAMT,IAAI;AAC3B;AAEA,6DAA6D,GAC7D,SAASa,WAAWC,IAAY;IAC9B,OAAOA,KACJC,KAAK,CAAC,MACNC,OAAO,CAAC,CAACC,OACRA,KACGhB,OAAO,CAAC,UAAU,IAClBA,OAAO,CAAC,U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AAM3D,IAAI,CAACmI,0BAAXxE,iBAAAA,YAAiB3C,EAAE,qBAAnB2C,cAAqB,CAAC,aAAa,MAAK,WAAW,IAAI;QAC7FiL,SAASnL,mBAAU6K,wBAAAA,KAAMM,OAAO,CAACnO,MAAM,oBAAI,GAAG,UAAC6N,wBAAAA,KAAMM,OAAO,oBAAI,EAAE,EAAE/O,MAAM,CAAC,CAACgP,SAAWL,UAAU7L,GAAG,CAACnE,MAAMqQ,OAAOgB,OAAO,IAAIpP,MAAM;QACnImN,OAAOnK,UAAUqL,YAAYrO,MAAM,EAAEuO;QACrCI,QAAQ3L,oBAAU6K,wBAAAA,KAAMc,MAAM,CAAC3O,MAAM,qBAAI,GAAG0O;QAC5CI,OAAO9L,UAAU8L,MAAM9O,MAAM,EAAE8O,MAAM1P,MAAM,CAAC,CAACiQ,OAAStB,UAAU7L,GAAG,CAACmN,OAAOrP,MAAM;IACnF;IACA,MAAMyL,WAAqD;QACzD;YAAC;YAASrB,OAAO3C,KAAK;SAAC;QACvB;YAAC;YAAS2C,OAAO0C,KAAK;SAAC;QACvB;YAAC;YAAW1C,OAAOG,OAAO;SAAC;QAC3B;YAAC;YAAWH,OAAO2C,OAAO;SAAC;QAC3B;YAAC;YAAQ3C,OAAOkD,IAAI;SAAC;QACrB;YAAC;YAAUlD,OAAO+B,MAAM;SAAC;QACzB;YAAC;YAAS/B,OAAO4E,KAAK;SAAC;QACvB;YAAC;YAAU5E,OAAO+E,MAAM;SAAC;QACzB;YAAC;YAAW/E,OAAO+D,OAAO;SAAC;QAC3B;YAAC;YAAS/D,OAAO+C,KAAK;SAAC;QACvB;YAAC;YAAU/C,OAAOuE,MAAM;SAAC;QACzB;YAAC;YAASvE,OAAO0E,KAAK;SAAC;KACxB;IACD,OAAO,aAAKtE,SAASiB,WAAcrB;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\nimport type { SiteImportBlock } from '../site-import/site-import-html'\nimport { siteImportWidthOf } from './ai-site-import'\nimport type {\n SiteImportBand,\n SiteImportButtonStyle,\n SiteImportFooter,\n SiteImportGroupKind,\n SiteImportLayout,\n SiteImportLayoutItem,\n SiteImportLayoutNode,\n SiteImportLayoutSection,\n SiteImportLineRef,\n SiteImportNavTree,\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 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 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 & { unlinked: number }\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\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`); without them a picture is counted, not placed. */\n photos?: ReadonlyArray<{ from?: string; src: 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 /** 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 private readonly claimedBy = new Map<Piece, SiteImportLineRef>()\n private readonly imageClaimed = new Set<string>()\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 const images = built.under(root).filter((id) => built.node(id)?.componentId === 'image')\n let cursor = -1\n let previous: SiteImportLineRef | null = null\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?.['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)\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): 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 const part = pieces.filter((piece) => free(piece) && piece.key && (` ${piece.key} `.includes(padded) || padded.includes(` ${piece.key} `)))\n return pick(part)\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 */\nexport function siteImportFidelity(source: SiteImportFidelitySource, tree: SiteImportFidelityTree): SiteImportPageFidelity {\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\n const words = wordsScore(source, built)\n const read = sections.map((section) => 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 const icons = { source: 0, built: 0, lone: 0 }\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 if (!node.button) break\n const block = source.blocks[node.line]\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 const id = placement.of.get(node.line)\n const drawnAs = id ? built.node(id) : undefined\n if (drawnAs?.componentId === 'muiButton' && drawnAs.props?.['variant'] === BUTTON_VARIANT[node.button] && hasDestination(drawnAs)) 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 const units = unitsOn(built, placement, node.items.map((item) => 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 const wanted = (item.icon !== 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 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 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\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 icons: { ...ratioKept(icons.source, icons.built), lone: icons.lone },\n buttons: { ...ratioKept(buttons.source, buttons.built), unlinked: buttons.unlinked },\n headings,\n forms,\n }\n return { ...lowestOf(pageMeasures(report)), ...report }\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.\n if (item.image !== undefined && !built.has(element, (node) => node.componentId === 'image')) return false\n return true\n}\n\n/** The words: the source's lines against what the page shows, each word as often as it is said. */\nfunction wordsScore(source: SiteImportFidelitySource, built: Built): 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 said = tally(source.blocks.flatMap((block) => (isLine(block) && block.kind !== 'image' ? [clean(block.text)] : [])))\n const shown = tally(built.pieces.map((piece) => piece.text))\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 const drawn = built.order.filter((id) => built.node(id)?.componentId === 'image').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/** 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 const refs = source.layout.sections.flatMap((section: SiteImportLayoutSection) => section.lines).filter((ref) => source.blocks[ref]?.kind === 'heading')\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 ['icons', report.icons],\n ['buttons', report.buttons],\n ['headings', report.headings],\n ['forms', report.forms],\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 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 /** 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/** 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.\n const rowItems = row ? built.children(row).map((id) => labelOf(built.node(id))) : []\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 for (const group of groups) {\n if (!group.items.length) continue\n menus.source += 1\n entries.source += group.items.length\n const menu = row\n ? built.under(row).find((id) => (built.node(id)?.componentId === 'muiMegaMenu' || built.node(id)?.componentId === 'muiNavMenu') && clean(built.node(id)?.props?.['label']) === clean(group.label))\n : undefined\n for (const entry of group.items) {\n if (entry.text) details.source += 1\n if (entry.iconPath) details.source += 1\n }\n if (!menu) continue\n menus.built += 1\n const inside = built.under(menu)\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 }\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) => [clean(group.label), ...group.items.map((entry) => clean(entry.label))]),\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\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 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 ['columns', report.columns],\n ['links', report.links],\n ['social', report.social],\n ['facts', report.facts],\n ]\n return { ...lowestOf(measures), ...report }\n}\n"],"names":["siteImportWidthOf","SITE_IMPORT_FIDELITY_THRESHOLD","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","holds","a","b","start","enter","get","end","exit","point","undefined","under","order","slice","children","child","has","common","at","parent","every","test","some","Map","pieces","seen","Set","visit","add","set","ratioKept","source","built","ratio","Math","min","ratioBoth","max","Placement","cursor","previous","free","piece","owner","claimedBy","pick","list","reduce","best","gap","abs","bestGap","joined","endsWith","exact","padded","part","includes","nodesOf","refs","whole","measured","pictures","photos","ref","blocks","of","sectionRoots","imageClaimed","photoOf","photo","from","src","layout","sections","forEach","section","index","root","scope","images","lines","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","drawnSections","aligned","roots","_","wordsScore","read","band","drawn","bandsKept","groups","tables","buttons","unlinked","icons","lone","drawnAs","button","href","units","parents","unit","size","wanted","icon","listIcon","group","entry","groupsKept","itemsKept","kept","itemKept","shown","labels","one","strip","picturesScore","headings","headingsScore","widths","widthsScore","forms","report","bands","fromEntries","entries","lowestOf","pageMeasures","to","image","tally","counts","word","said","sourceWords","builtWords","both","missing","extra","on","most","examples","WIDTH_RANK","sm","md","lg","xl","width","container","rank","String","measures","score","lowest","name","labelOf","LINK_COMPONENTS","siteImportFrameFidelity","all","inHeader","is","drawer","inDrawer","header","footer","nav","rowItems","left","matched","indexOf","splice","inOrder","menus","details","menu","iconPath","inside","links","texts","link","ctas","cta","style","drawerTexts","drawerWanted","toggle","hasRow","foot","footIds","footTexts","footLinks","footLinkLabels","columnLinks","columns","column","linksWanted","linkLeft","linksKept","profiles","hrefs","socialKept","social","profile","network","facts","address","phone","email","copyright","nowrap","heading","fact"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA6B2C;AAG3C,SAASA,iBAAiB,QAAQ,sBAAkB;AAepD,sGAAsG,GACtG,OAAO,MAAMC,iCAAiC,IAAG;AAkGjD;;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,MAAMC;AAE5E,wFAAwF,GACxF,SAASQ,OAAOC,KAAkC;IAChD,IAAI,CAACA,OAAO,OAAO;IACnB,IAAIA,MAAMC,IAAI,KAAK,SAAS,OAAO,CAAC,CAACD,MAAME,GAAG;IAC9C,IAAIF,MAAMC,IAAI,KAAK,QAAQ,OAAO,CAACD,MAAMG,MAAM,IAAI,CAAC,CAACb,MAAMU,MAAMT,IAAI;IACrE,OAAO,CAAC,CAACD,MAAMU,MAAMT,IAAI;AAC3B;AAEA,6DAA6D,GAC7D,SAASa,WAAWC,IAAY;IAC9B,OAAOA,KACJC,KAAK,CAAC,MACNC,OAAO,CAAC,CAACC,OACRA,KACGhB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UvD,OAAO+E,MAAM;SAAC;QACzB;YAAC;YAAS/E,OAAOkF,KAAK;SAAC;KACxB;IACD,OAAO,aAAK9E,SAASyB,WAAc7B;AACrC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { AiJobItemLedger } from './ai-jobs.types';
18
+ type Dict = Record<string, any>;
19
+ /** The look line's facts, as a site stores them and an import ran them. */
20
+ export interface SiteImportLookReport {
21
+ /** The base theme the site was given: `siteStyle.base`, or `null` where it holds no style. */
22
+ base: string | null;
23
+ /** Whether a look is saved over the base. */
24
+ override: boolean;
25
+ /** The job whose look the site wears: `siteStyle.jobId`. */
26
+ jobId: string | null;
27
+ /** The source's brand color the look was drawn from: `siteStyle.brand`. */
28
+ brand: string | null;
29
+ /** What the import's look pass came to: `look.theme`. */
30
+ pass: string | null;
31
+ primary: string | null;
32
+ secondary: string | null;
33
+ tertiary: string | null;
34
+ fonts: string[];
35
+ }
36
+ /** The look a site wears: its base theme with what was saved over it, and which job saved it. */
37
+ export declare function siteImportLookReport(host: Dict, state: Dict | null | undefined): SiteImportLookReport;
38
+ /** The look line of the report: what the site wears, and whether it is this job's. */
39
+ export declare function siteImportLookLine(host: Dict, state: Dict | null | undefined, jobId: string): string;
40
+ /** One kind of page's cost, as `AI_MEASURED_IMPORT_CREDITS` holds it. */
41
+ export interface SiteImportCreditsMeasured {
42
+ count: number;
43
+ median: number;
44
+ p90: number;
45
+ mean: number;
46
+ }
47
+ /**
48
+ * What each kind of page cost by the ledger, as the table a quote is read
49
+ * from is measured: over the items that came through and gave nothing back,
50
+ * grouped by how their page was built. The p90 is the nearest rank.
51
+ */
52
+ export declare function siteImportCreditsMeasured(state: {
53
+ pages: ReadonlyArray<{
54
+ slot: string;
55
+ build?: string | null;
56
+ }>;
57
+ }, items: ReadonlyArray<Pick<AiJobItemLedger, 'slot' | 'status' | 'creditsSpent' | 'creditsRefunded'>>): Partial<Record<'arranged' | 'copied', SiteImportCreditsMeasured>>;
58
+ /** The credits line of the report: each kind of page's count, median, p90 and mean. */
59
+ export declare function siteImportCreditsLine(measured: ReturnType<typeof siteImportCreditsMeasured>): string;
60
+ export {};
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /**
17
+ * What the fidelity report says of a built site beside its scores (AGL-4109),
18
+ * pure so a spec reads it: the look the site wears and what its pages cost.
19
+ *
20
+ * The 11/1 report read `host.theme`, the base an import starts from, and said
21
+ * the site wore the starter's indigo while it rendered the source's blue. The
22
+ * look an import saves is `themeOverride` over that base, with `siteStyle`
23
+ * beside it (`aiSaveSiteTheme`). The credits line printed a mean, while the
24
+ * table a quote is made of (`AI_MEASURED_IMPORT_CREDITS`) is a median and a
25
+ * p90.
26
+ */ import { readThemeOverride, resolveSiteTheme } from "@aglyn/aglyn/app-utils/site-theme";
27
+ const named = (value)=>typeof value === 'string' && value.trim() ? value : null;
28
+ /** The look a site wears: its base theme with what was saved over it, and which job saved it. */ export function siteImportLookReport(host, state) {
29
+ var _resolveSiteTheme, _ref, _host_siteStyle, _theme_fonts;
30
+ var _theme_colorSchemes, _state_look, _light_primary, _light_secondary, _light_tertiary;
31
+ const theme = (_resolveSiteTheme = resolveSiteTheme(host)) != null ? _resolveSiteTheme : {};
32
+ const light = (_ref = (_theme_colorSchemes = theme['colorSchemes']) == null ? void 0 : _theme_colorSchemes['light']) != null ? _ref : {};
33
+ const style = (_host_siteStyle = host['siteStyle']) != null ? _host_siteStyle : null;
34
+ return {
35
+ base: named(style == null ? void 0 : style['base']),
36
+ override: !!readThemeOverride(host),
37
+ jobId: named(style == null ? void 0 : style['jobId']),
38
+ brand: named(style == null ? void 0 : style['brand']),
39
+ pass: named(state == null ? void 0 : (_state_look = state['look']) == null ? void 0 : _state_look['theme']),
40
+ primary: named((_light_primary = light['primary']) == null ? void 0 : _light_primary['main']),
41
+ secondary: named((_light_secondary = light['secondary']) == null ? void 0 : _light_secondary['main']),
42
+ tertiary: named((_light_tertiary = light['tertiary']) == null ? void 0 : _light_tertiary['main']),
43
+ fonts: ((_theme_fonts = theme['fonts']) != null ? _theme_fonts : []).map((font)=>{
44
+ var _font_family;
45
+ return String((_font_family = font['family']) != null ? _font_family : '');
46
+ }).filter(Boolean)
47
+ };
48
+ }
49
+ /** The look line of the report: what the site wears, and whether it is this job's. */ export function siteImportLookLine(host, state, jobId) {
50
+ var _look_base, _look_base1, _look_pass;
51
+ const look = siteImportLookReport(host, state);
52
+ const colors = [
53
+ 'primary',
54
+ 'secondary',
55
+ 'tertiary'
56
+ ].map((key)=>{
57
+ var _look_key;
58
+ return `${key} ${(_look_key = look[key]) != null ? _look_key : 'not set'}`;
59
+ }).join(', ');
60
+ const brand = look.brand ? `, drawn from ${look.brand}` : '';
61
+ const fonts = look.fonts.join(', ') || 'not set';
62
+ const wearing = look.override ? `an override over the ${(_look_base = look.base) != null ? _look_base : 'site'} base` : `the ${(_look_base1 = look.base) != null ? _look_base1 : 'site'} base, no override`;
63
+ const whose = look.jobId ? look.jobId === jobId ? 'saved by this job' : `saved by job ${look.jobId}, not this one` : 'saved by no job';
64
+ return `${(_look_pass = look.pass) != null ? _look_pass : 'not run'}; ${colors}${brand}; ${fonts}; ${wearing}; ${whose}`;
65
+ }
66
+ /** The middle value of what is sorted: the two middle ones' mean, for an even count. */ function median(sorted) {
67
+ const middle = Math.floor(sorted.length / 2);
68
+ return sorted.length % 2 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
69
+ }
70
+ /**
71
+ * What each kind of page cost by the ledger, as the table a quote is read
72
+ * from is measured: over the items that came through and gave nothing back,
73
+ * grouped by how their page was built. The p90 is the nearest rank.
74
+ */ export function siteImportCreditsMeasured(state, items) {
75
+ const buildOf = new Map(state.pages.map((page)=>{
76
+ var _page_build;
77
+ return [
78
+ page.slot,
79
+ (_page_build = page.build) != null ? _page_build : null
80
+ ];
81
+ }));
82
+ const out = {};
83
+ for (const build of [
84
+ 'arranged',
85
+ 'copied'
86
+ ]){
87
+ const each = items.filter((item)=>buildOf.get(item.slot) === build && item.status === 'succeeded' && !(Number(item.creditsRefunded) > 0)).map((item)=>{
88
+ var _item_creditsSpent;
89
+ return Number((_item_creditsSpent = item.creditsSpent) != null ? _item_creditsSpent : 0);
90
+ }).sort((a, b)=>a - b);
91
+ if (!each.length) continue;
92
+ const total = each.reduce((sum, value)=>sum + value, 0);
93
+ out[build] = {
94
+ count: each.length,
95
+ median: median(each),
96
+ p90: each[Math.ceil(each.length * 0.9) - 1],
97
+ mean: total / each.length
98
+ };
99
+ }
100
+ return out;
101
+ }
102
+ const credits = (value)=>Number.isInteger(value) ? String(value) : value.toFixed(1);
103
+ /** The credits line of the report: each kind of page's count, median, p90 and mean. */ export function siteImportCreditsLine(measured) {
104
+ const parts = [
105
+ 'arranged',
106
+ 'copied'
107
+ ].flatMap((build)=>{
108
+ const row = measured[build];
109
+ return row ? [
110
+ `${row.count} ${build}, median ${credits(row.median)}, p90 ${credits(row.p90)}, mean ${credits(row.mean)}`
111
+ ] : [];
112
+ });
113
+ return parts.length ? parts.join('; ') : 'no page in yet';
114
+ }
115
+
116
+ //# sourceMappingURL=ai-site-import-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-import-report.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 * What the fidelity report says of a built site beside its scores (AGL-4109),\n * pure so a spec reads it: the look the site wears and what its pages cost.\n *\n * The 11/1 report read `host.theme`, the base an import starts from, and said\n * the site wore the starter's indigo while it rendered the source's blue. The\n * look an import saves is `themeOverride` over that base, with `siteStyle`\n * beside it (`aiSaveSiteTheme`). The credits line printed a mean, while the\n * table a quote is made of (`AI_MEASURED_IMPORT_CREDITS`) is a median and a\n * p90.\n */\n\nimport { readThemeOverride, resolveSiteTheme } from '@aglyn/aglyn/app-utils/site-theme'\nimport type { AiJobItemLedger } from './ai-jobs.types'\n\ntype Dict = Record<string, any>\n\n/** The look line's facts, as a site stores them and an import ran them. */\nexport interface SiteImportLookReport {\n /** The base theme the site was given: `siteStyle.base`, or `null` where it holds no style. */\n base: string | null\n /** Whether a look is saved over the base. */\n override: boolean\n /** The job whose look the site wears: `siteStyle.jobId`. */\n jobId: string | null\n /** The source's brand color the look was drawn from: `siteStyle.brand`. */\n brand: string | null\n /** What the import's look pass came to: `look.theme`. */\n pass: string | null\n primary: string | null\n secondary: string | null\n tertiary: string | null\n fonts: string[]\n}\n\nconst named = (value: unknown): string | null => (typeof value === 'string' && value.trim() ? value : null)\n\n/** The look a site wears: its base theme with what was saved over it, and which job saved it. */\nexport function siteImportLookReport(host: Dict, state: Dict | null | undefined): SiteImportLookReport {\n const theme = (resolveSiteTheme(host) ?? {}) as Dict\n const light = (theme['colorSchemes']?.['light'] ?? {}) as Dict\n const style = (host['siteStyle'] ?? null) as Dict | null\n return {\n base: named(style?.['base']),\n override: !!readThemeOverride(host),\n jobId: named(style?.['jobId']),\n brand: named(style?.['brand']),\n pass: named(state?.['look']?.['theme']),\n primary: named(light['primary']?.['main']),\n secondary: named(light['secondary']?.['main']),\n tertiary: named(light['tertiary']?.['main']),\n fonts: ((theme['fonts'] ?? []) as Dict[]).map((font) => String(font['family'] ?? '')).filter(Boolean),\n }\n}\n\n/** The look line of the report: what the site wears, and whether it is this job's. */\nexport function siteImportLookLine(host: Dict, state: Dict | null | undefined, jobId: string): string {\n const look = siteImportLookReport(host, state)\n const colors = (['primary', 'secondary', 'tertiary'] as const).map((key) => `${key} ${look[key] ?? 'not set'}`).join(', ')\n const brand = look.brand ? `, drawn from ${look.brand}` : ''\n const fonts = look.fonts.join(', ') || 'not set'\n const wearing = look.override ? `an override over the ${look.base ?? 'site'} base` : `the ${look.base ?? 'site'} base, no override`\n const whose = look.jobId ? (look.jobId === jobId ? 'saved by this job' : `saved by job ${look.jobId}, not this one`) : 'saved by no job'\n return `${look.pass ?? 'not run'}; ${colors}${brand}; ${fonts}; ${wearing}; ${whose}`\n}\n\n/** One kind of page's cost, as `AI_MEASURED_IMPORT_CREDITS` holds it. */\nexport interface SiteImportCreditsMeasured {\n count: number\n median: number\n p90: number\n mean: number\n}\n\n/** The middle value of what is sorted: the two middle ones' mean, for an even count. */\nfunction median(sorted: readonly number[]): number {\n const middle = Math.floor(sorted.length / 2)\n return sorted.length % 2 ? (sorted[middle] as number) : ((sorted[middle - 1] as number) + (sorted[middle] as number)) / 2\n}\n\n/**\n * What each kind of page cost by the ledger, as the table a quote is read\n * from is measured: over the items that came through and gave nothing back,\n * grouped by how their page was built. The p90 is the nearest rank.\n */\nexport function siteImportCreditsMeasured(\n state: { pages: ReadonlyArray<{ slot: string; build?: string | null }> },\n items: ReadonlyArray<Pick<AiJobItemLedger, 'slot' | 'status' | 'creditsSpent' | 'creditsRefunded'>>,\n): Partial<Record<'arranged' | 'copied', SiteImportCreditsMeasured>> {\n const buildOf = new Map(state.pages.map((page) => [page.slot, page.build ?? null]))\n const out: Partial<Record<'arranged' | 'copied', SiteImportCreditsMeasured>> = {}\n for (const build of ['arranged', 'copied'] as const) {\n const each = items\n .filter((item) => buildOf.get(item.slot) === build && item.status === 'succeeded' && !(Number(item.creditsRefunded) > 0))\n .map((item) => Number(item.creditsSpent ?? 0))\n .sort((a, b) => a - b)\n if (!each.length) continue\n const total = each.reduce((sum, value) => sum + value, 0)\n out[build] = { count: each.length, median: median(each), p90: each[Math.ceil(each.length * 0.9) - 1] as number, mean: total / each.length }\n }\n return out\n}\n\nconst credits = (value: number) => (Number.isInteger(value) ? String(value) : value.toFixed(1))\n\n/** The credits line of the report: each kind of page's count, median, p90 and mean. */\nexport function siteImportCreditsLine(measured: ReturnType<typeof siteImportCreditsMeasured>): string {\n const parts = (['arranged', 'copied'] as const).flatMap((build) => {\n const row = measured[build]\n return row ? [`${row.count} ${build}, median ${credits(row.median)}, p90 ${credits(row.p90)}, mean ${credits(row.mean)}`] : []\n })\n return parts.length ? parts.join('; ') : 'no page in yet'\n}\n"],"names":["readThemeOverride","resolveSiteTheme","named","value","trim","siteImportLookReport","host","state","theme","light","style","base","override","jobId","brand","pass","primary","secondary","tertiary","fonts","map","font","String","filter","Boolean","siteImportLookLine","look","colors","key","join","wearing","whose","median","sorted","middle","Math","floor","length","siteImportCreditsMeasured","items","buildOf","Map","pages","page","slot","build","out","each","item","get","status","Number","creditsRefunded","creditsSpent","sort","a","b","total","reduce","sum","count","p90","ceil","mean","credits","isInteger","toFixed","siteImportCreditsLine","measured","parts","flatMap","row"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;CAUC,GA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