@aglyn/plugins-ai 1.11.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/components/ai-media-create.component.js +1 -1
- package/src/lib/components/ai-media-create.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.js +1 -1
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +1 -1
- package/src/lib/jobs/ai-job-import-step.js +37 -8
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-privacy-step.js +2 -2
- package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +27 -37
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +19 -4
- package/src/lib/jobs/ai-site-import-look.js +162 -46
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/jobs/ai-theme-brand-inputs.d.ts +12 -0
- package/src/lib/jobs/ai-theme-brand-inputs.js +1 -1
- package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +7 -1
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/model/ai-credit-estimate.d.ts +15 -0
- package/src/lib/model/ai-credit-estimate.js +13 -0
- package/src/lib/model/ai-credit-estimate.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +46 -3
- package/src/lib/model/ai-site-import-fidelity.js +254 -62
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-report.d.ts +7 -0
- package/src/lib/model/ai-site-import-report.js +17 -5
- package/src/lib/model/ai-site-import-report.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +75 -4
- package/src/lib/model/ai-site-import.js +34 -11
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +16 -0
- package/src/lib/model/ai-site-look.js +76 -14
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/model/ai-upsell-copy.js +1 -1
- package/src/lib/model/ai-upsell-copy.js.map +1 -1
- package/src/lib/site-import/fixtures/aglyn-com-recordings.d.ts +2 -1
- package/src/lib/site-import/fixtures/aglyn-com-recordings.js +3 -2
- package/src/lib/site-import/fixtures/aglyn-com-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.d.ts +5 -0
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.js +116 -3
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +7 -0
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +15 -0
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +32 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +59 -3
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-look-slate.d.ts +2 -1
- package/src/lib/site-import/fixtures/site-look-slate.js +2 -1
- package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -1
- package/src/lib/site-import/site-import-crawl.d.ts +9 -1
- package/src/lib/site-import/site-import-crawl.js +128 -23
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +89 -1
- package/src/lib/site-import/site-import-css.js +468 -28
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-data-forms.d.ts +32 -0
- package/src/lib/site-import/site-import-data-forms.js +531 -0
- package/src/lib/site-import/site-import-data-forms.js.map +1 -0
- package/src/lib/site-import/site-import-html.d.ts +10 -1
- package/src/lib/site-import/site-import-html.js +21 -5
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +9 -2
- package/src/lib/site-import/site-import-layout.js +383 -62
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/site-import/site-import-nav.js +17 -3
- package/src/lib/site-import/site-import-nav.js.map +1 -1
- package/src/lib/site-import/site-import-page.js +5 -0
- package/src/lib/site-import/site-import-page.js.map +1 -1
- package/src/lib/site-import/site-import-same-page.d.ts +41 -0
- package/src/lib/site-import/site-import-same-page.js +108 -0
- package/src/lib/site-import/site-import-same-page.js.map +1 -0
|
@@ -301,12 +301,18 @@ function frameReader(page, stylesheets) {
|
|
|
301
301
|
return false;
|
|
302
302
|
}
|
|
303
303
|
};
|
|
304
|
+
/** A link to a place on this page that says it skips there (AGL-4152): a way past the menu, never a menu item or a call to action. */ const skip = (anchor)=>{
|
|
305
|
+
var _ref, _ref1;
|
|
306
|
+
var _reader_elements_anchor_element;
|
|
307
|
+
const attrs = (_reader_elements_anchor_element = reader.elements[anchor.element]) == null ? void 0 : _reader_elements_anchor_element.attrs;
|
|
308
|
+
return /^#/.test((_ref = attrs == null ? void 0 : attrs.href) != null ? _ref : '') && (/skip/i.test((_ref1 = attrs == null ? void 0 : attrs.class) != null ? _ref1 : '') || /skip/i.test(anchor.label));
|
|
309
|
+
};
|
|
304
310
|
const items = [];
|
|
305
311
|
const ctas = [];
|
|
306
312
|
const inRow = new Set();
|
|
307
313
|
for (const child of (_ref2 = (_reader_elements_row = reader.elements[row]) == null ? void 0 : _reader_elements_row.children) != null ? _ref2 : []){
|
|
308
314
|
var _ref4, _ref5, _ref6;
|
|
309
|
-
const anchors = reader.anchors(child).filter((anchor)=>!brand(anchor) && (anchor.label || anchor.href));
|
|
315
|
+
const anchors = reader.anchors(child).filter((anchor)=>!brand(anchor) && !skip(anchor) && (anchor.label || anchor.href));
|
|
310
316
|
const texts = reader.texts(child);
|
|
311
317
|
if (!anchors.length && !texts.length) continue;
|
|
312
318
|
anchors.forEach((anchor)=>inRow.add(anchor));
|
|
@@ -356,14 +362,17 @@ function frameReader(page, stylesheets) {
|
|
|
356
362
|
}
|
|
357
363
|
// The header's buttons outside the menu row.
|
|
358
364
|
for (const anchor of reader.anchors(header.id)){
|
|
359
|
-
if (inRow.has(anchor) || brand(anchor) || !anchor.label || reader.contains(row, anchor.element)) continue;
|
|
365
|
+
if (inRow.has(anchor) || brand(anchor) || skip(anchor) || !anchor.label || reader.contains(row, anchor.element)) continue;
|
|
360
366
|
const style = reader.buttonStyle(anchor.element);
|
|
361
367
|
if (!style) continue;
|
|
362
|
-
|
|
368
|
+
// A header can hold one button twice, a wide screen's and a phone's: the strongest drawing of it stands.
|
|
369
|
+
const held = ctas.find((cta)=>cta.label === anchor.label && cta.href === anchor.href);
|
|
370
|
+
if (!held) ctas.push({
|
|
363
371
|
label: clean(anchor.label, AI_SITE_IMPORT_LABEL_MAX_CHARS * 2),
|
|
364
372
|
href: anchor.href,
|
|
365
373
|
style
|
|
366
374
|
});
|
|
375
|
+
else if (CTA_STRENGTH[style] > CTA_STRENGTH[held.style]) held.style = style;
|
|
367
376
|
}
|
|
368
377
|
const phoneMenu = reader.elements.some((node)=>{
|
|
369
378
|
var _node_attrs_class, _node_attrs_label, _node_attrs_class1, _node_attrs_controls;
|
|
@@ -380,6 +389,11 @@ function frameReader(page, stylesheets) {
|
|
|
380
389
|
background: reader.background(header.id)
|
|
381
390
|
};
|
|
382
391
|
}
|
|
392
|
+
/** How strongly a header's button is drawn. */ const CTA_STRENGTH = {
|
|
393
|
+
quiet: 0,
|
|
394
|
+
secondary: 1,
|
|
395
|
+
primary: 2
|
|
396
|
+
};
|
|
383
397
|
/** One entry of a menu, with the heading of the column it sits in. */ function navEntry(reader, anchor, item) {
|
|
384
398
|
const icon = anchor.icon !== undefined ? reader.page.structure.icons[anchor.icon] : undefined;
|
|
385
399
|
const column = columnHeading(reader, anchor.element, item);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-import/site-import-nav.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 * THE SOURCE'S MENU AND FOOTER, AS IT BUILDS THEM (AGL-4106).\n *\n * The import's header used to be the wave's page titles, seven of them, cut\n * to 28 characters, with no menus: the source's own menu was read as a flat\n * list of links and used only for their order. This reads it as the source\n * builds it, with no model:\n *\n * - **The menu** (`siteImportNavTree`). Each top-level item of the header's\n * `<nav>` row: its link, and the panel that opens under it (a container of\n * two or more links), each entry with its name, the line under it in a mega\n * menu, its address, its icon and the heading of the column it sits in;\n * and (AGL-4139) the panel's columns as the source sets them side by side,\n * each one's heading, words, fill, picture and width, the tile behind each\n * icon, and whether the panel opens on hover.\n * The header's buttons outside the row (\"Sign in\", \"Start free\") with their\n * addresses and how they are drawn; whether the source shows a menu button\n * on phones; the header bar's background.\n * - **The footer** (`siteImportFooterColumns`). Each column: its heading and\n * its links. Its profiles on other sites, its other links, its lines of\n * text, its address, phone and email (from its structured data where the\n * footer prints none), and its © line word for word; whether it opens with\n * the logo, and its filled boxes (AGL-4139).\n *\n * Every label is the source's, as written. Untrusted data: it is drawn by the\n * frame compiler as words, and fenced wherever a prompt reads it.\n *=========================================*/\n\nimport {\n AI_SITE_IMPORT_LABEL_MAX_CHARS,\n type SiteImportBand,\n type SiteImportButtonStyle,\n type SiteImportFooter,\n type SiteImportFooterLink,\n type SiteImportNavColumn,\n type SiteImportNavCta,\n type SiteImportNavEntry,\n type SiteImportNavGroup,\n type SiteImportNavTree,\n} from '../model/ai-site-import'\nimport {\n SITE_IMPORT_CSS_WIDE_WIDTH,\n siteImportBackgroundOf,\n siteImportColorOf,\n siteImportCssOf,\n siteImportGridColumns,\n siteImportHex,\n siteImportLengthPx,\n siteImportRadiusPx,\n siteImportStylesOf,\n type SiteImportStyles,\n} from './site-import-css'\nimport type { SiteImportAnchor, SiteImportElement, SiteImportExtract, SiteImportStructure } from './site-import-html'\nimport { siteImportBandOfColor, siteImportButtonStyleOf } from './site-import-layout'\n\n/** A page as the menu reader takes it: its structure, its blocks and its structured data. */\nexport type SiteImportFrameSource = Pick<SiteImportExtract, 'blocks' | 'organization'> & { structure: SiteImportStructure }\n\n/** The most top-level items, entries per menu and footer links kept. */\nexport const SITE_IMPORT_NAV_LIMITS = { items: 12, entries: 40, footerLinks: 160 } as const\n\nconst PHONE_MENU = /\\b(?:menu|navigation|nav)\\b/i\nconst PHONE_MENU_CLASS = /hamburger|burger|menu-?toggle|nav-?toggle|mobile-?menu|navbar-toggler|menu-?button|header-menu-toggle|drawer-?toggle/i\n\nconst SOCIAL_NETWORKS: ReadonlyArray<[RegExp, string]> = [\n [/(?:^|\\.)(?:twitter\\.com|x\\.com)$/i, 'x'],\n [/(?:^|\\.)facebook\\.com$/i, 'facebook'],\n [/(?:^|\\.)instagram\\.com$/i, 'instagram'],\n [/(?:^|\\.)linkedin\\.com$/i, 'linkedin'],\n [/(?:^|\\.)youtube\\.com$/i, 'youtube'],\n [/(?:^|\\.)tiktok\\.com$/i, 'tiktok'],\n [/(?:^|\\.)github\\.com$/i, 'github'],\n [/(?:^|\\.)pinterest\\.com$/i, 'pinterest'],\n [/(?:^|\\.)threads\\.net$/i, 'threads'],\n [/(?:^|\\.)yelp\\.com$/i, 'yelp'],\n [/(?:^|\\.)tripadvisor\\.com$/i, 'tripadvisor'],\n [/(?:^|\\.)nextdoor\\.com$/i, 'nextdoor'],\n [/(?:^|\\.)vimeo\\.com$/i, 'vimeo'],\n [/(?:^|\\.)bsky\\.app$/i, 'bluesky'],\n [/(?:^|\\.)mastodon\\.social$/i, 'mastodon'],\n [/(?:^|\\.)discord\\.(?:gg|com)$/i, 'discord'],\n [/(?:^|\\.)whatsapp\\.com$|(?:^|\\.)wa\\.me$/i, 'whatsapp'],\n]\n\n/** The network a profile address is on, or `null` for an address that is no profile. */\nexport function siteImportSocialNetwork(href: string): string | null {\n try {\n const host = new URL(href).hostname\n return SOCIAL_NETWORKS.find(([pattern]) => pattern.test(host))?.[1] ?? null\n } catch {\n return null\n }\n}\n\nconst clean = (text: string, max = 300) => {\n const line = String(text ?? '').replace(/\\s+/g, ' ').trim()\n return line.length > max ? `${line.slice(0, max - 1).trimEnd()}…` : line\n}\n\nclass FrameReader {\n readonly elements: readonly SiteImportElement[]\n /** Each element's anchors, its subtree's, in order. */\n private readonly anchorMemo = new Map<number, SiteImportAnchor[]>()\n private readonly anchorAt = new Map<number, SiteImportAnchor>()\n\n constructor(\n readonly page: SiteImportFrameSource,\n readonly styles: SiteImportStyles,\n ) {\n this.elements = page.structure.elements\n for (const anchor of page.structure.anchors) this.anchorAt.set(anchor.element, anchor)\n }\n\n anchors(element: number): SiteImportAnchor[] {\n const held = this.anchorMemo.get(element)\n if (held) return held\n const node = this.elements[element]\n if (!node) return []\n const own = this.anchorAt.get(element)\n const list = own ? [own] : []\n for (const child of node.children) list.push(...this.anchors(child))\n this.anchorMemo.set(element, list)\n return list\n }\n\n contains(ancestor: number, element: number): boolean {\n for (let at = element; at >= 0; at = this.elements[at]?.parent ?? -1) if (at === ancestor) return true\n return false\n }\n\n /** The words a menu holds outside its links, by element: a column's heading, a button's name. */\n texts(element: number): Array<{ element: number; text: string }> {\n const texts = this.page.structure.texts ?? []\n return texts.filter((entry) => this.contains(element, entry.element))\n }\n\n first(test: (node: SiteImportElement) => boolean): SiteImportElement | undefined {\n return this.elements.find(test)\n }\n\n background(element: number): string | null {\n for (let at = element, depth = 0; at >= 0 && depth < 4; depth += 1) {\n const color = siteImportBackgroundOf(this.styles.of(at)).color\n if (color && color.a >= 0.5) return siteImportHex(color)\n const children: number[] = (this.elements[at]?.children ?? []).filter((child) => this.anchors(child).length || this.elements[child]?.children.length)\n at = children.length === 1 ? (children[0] as number) : -1\n }\n return null\n }\n\n buttonStyle(element: number): SiteImportButtonStyle | null {\n const node = this.elements[element]\n if (!node) return null\n return siteImportButtonStyleOf(node, this.styles.of(element), this.ground(node.parent) ?? '#ffffff')\n }\n\n /** An element's own solid fill, `#rrggbb`, or `null`. */\n fill(element: number): string | null {\n const color = siteImportBackgroundOf(this.styles.of(element)).color\n return color && color.a >= 0.5 ? siteImportHex(color) : null\n }\n\n /** The fill an element sits on: its own, or the nearest one around it. */\n ground(element: number): string | null {\n for (let at = element; at >= 0; at = this.elements[at]?.parent ?? -1) {\n const fill = this.fill(at)\n if (fill) return fill\n }\n return null\n }\n\n /** Every element under one, itself first, in order. */\n under(element: number): number[] {\n const out: number[] = []\n const visit = (at: number) => {\n const node = this.elements[at]\n if (!node) return\n out.push(at)\n for (const child of node.children) visit(child)\n }\n visit(element)\n return out\n }\n\n /** Whether an element is inside one of the page's links. */\n inLink(element: number, within: number): boolean {\n return this.page.structure.anchors.some((anchor) => anchor.element !== within && this.contains(within, anchor.element) && this.contains(anchor.element, element))\n }\n\n /** The first picture an element shows outside its links. */\n picture(element: number): { url: string; alt: string } | null {\n for (const at of this.under(element)) {\n const picture = this.elements[at]?.picture\n if (picture && !this.inLink(at, element)) return picture\n }\n return null\n }\n\n /** Whether the source hides an element until something shows it. */\n hidden(element: number): boolean {\n const style = this.styles.of(element)\n return this.elements[element]?.attrs.hidden === true || style.get('display') === 'none' || style.get('visibility') === 'hidden'\n }\n\n /** Whether an element lays its children side by side: a flex row, or a grid of two columns or more. */\n sideBySide(element: number): boolean {\n const style = this.styles.of(element)\n const display = style.get('display') ?? ''\n if (/flex/.test(display)) return !/column/.test(style.get('flex-direction') ?? '')\n return /grid/.test(display) && (siteImportGridColumns(style.get('grid-template-columns'))?.length ?? 0) >= 2\n }\n\n /** An element's width in CSS pixels, where the source sets it in pixels. */\n widthPx(element: number, property: 'width' | 'max-width' = 'width', styles: SiteImportStyles = this.styles): number | null {\n const value = styles.of(element).get(property) ?? ''\n return /^\\s*-?\\d*\\.?\\d+\\s*px\\s*$/i.test(value) ? siteImportLengthPx(value) : null\n }\n\n /** Its icon's color as the source draws it, `#rrggbb`. */\n color(element: number): string | null {\n const color = siteImportColorOf(this.styles.of(element).get('color'))\n return color && color.a >= 0.5 ? siteImportHex(color) : null\n }\n}\n\nfunction frameReader(page: SiteImportFrameSource, stylesheets: readonly string[]): FrameReader & { wide: () => SiteImportStyles } {\n const sheets = [...page.structure.styles, ...stylesheets]\n const reader = new FrameReader(page, siteImportStylesOf(page.structure, siteImportCssOf(sheets)))\n // A panel's cap as a wide screen reads it: a framework's widest container sets its own only from 1,536 px up.\n let wide: SiteImportStyles | null = null\n return Object.assign(reader, { wide: () => (wide ??= siteImportStylesOf(page.structure, siteImportCssOf(sheets, SITE_IMPORT_CSS_WIDE_WIDTH))) })\n}\n\n/**\n * A box's fill against the ground it sits on, as a band: none where it is\n * the ground's own; a dark box on a dark ground, or a near-white one, is a\n * light step; else the band its color is.\n */\nfunction boxBand(fill: string | null, ground: string | null): SiteImportBand {\n if (!fill || fill === ground) return 'plain'\n const own = siteImportColorOf(fill)\n if (!own) return 'plain'\n const band = siteImportBandOfColor(own)\n const under = ground ? siteImportColorOf(ground) : null\n if (band === 'dark' && under && siteImportBandOfColor(under) === 'dark') return 'soft'\n return band === 'plain' ? 'soft' : band\n}\n\n/**\n * The source's header menu (AGL-4106), as its home page builds it; `null`\n * for a page with no header menu the reader can find.\n */\nexport function siteImportNavTree(page: SiteImportFrameSource, stylesheets: readonly string[] = []): SiteImportNavTree | null {\n if (!page.structure) return null\n const reader = frameReader(page, stylesheets)\n const header =\n reader.first((node) => node.tag === 'header' && node.region === 'header') ??\n reader.first((node) => node.attrs.role === 'banner') ??\n reader.first((node) => node.tag === 'nav' && node.region !== 'footer')\n if (!header) return null\n const nav =\n reader.first((node) => node.tag === 'nav' && reader.contains(header.id, node.id) && reader.anchors(node.id).length >= 2) ??\n reader.first((node) => node.tag === 'nav' && node.region !== 'footer' && reader.anchors(node.id).length >= 2) ??\n header\n // The row: down through wrappers to the element whose children are the items.\n let row = nav.id\n for (let guard = 0; guard < 32; guard += 1) {\n const children = (reader.elements[row]?.children ?? []).filter((child) => reader.anchors(child).length || reader.texts(child).length)\n if (children.length !== 1) break\n row = children[0] as number\n }\n const brand = (anchor: SiteImportAnchor) => {\n try {\n return new URL(anchor.href ?? '').pathname === '/' && (!!anchor.image || !anchor.label)\n } catch {\n return false\n }\n }\n const items: SiteImportNavGroup[] = []\n const ctas: SiteImportNavCta[] = []\n const inRow = new Set<SiteImportAnchor>()\n for (const child of reader.elements[row]?.children ?? []) {\n const anchors = reader.anchors(child).filter((anchor) => !brand(anchor) && (anchor.label || anchor.href))\n const texts = reader.texts(child)\n if (!anchors.length && !texts.length) continue\n anchors.forEach((anchor) => inRow.add(anchor))\n // A top-level link drawn as a button is a call to action, as the source draws it.\n if (anchors.length === 1 && !texts.length) {\n const anchor = anchors[0] as SiteImportAnchor\n const style = reader.buttonStyle(anchor.element)\n if (style && style !== 'quiet') {\n ctas.push({ label: clean(anchor.label, AI_SITE_IMPORT_LABEL_MAX_CHARS * 2), href: anchor.href, style })\n continue\n }\n }\n // The item's name: its first link, or the words of the button that opens its menu.\n const trigger = anchors[0]\n const opener = texts.find((entry) => !trigger || entry.element < trigger.element)\n const label = clean(opener?.text ?? trigger?.label ?? '', AI_SITE_IMPORT_LABEL_MAX_CHARS * 2)\n if (!label) continue\n const entries = (opener ? anchors : anchors.slice(1)).slice(0, SITE_IMPORT_NAV_LIMITS.entries).filter((anchor) => anchor.href)\n // Its panel as the source sets it (AGL-4139): its columns side by side, and whether it opens on hover.\n const panel = entries.length ? panelOf(reader, child, entries, opener ? opener.element : (trigger as SiteImportAnchor).element) : null\n items.push({\n label,\n href: opener ? null : (trigger?.href ?? null),\n items: entries.map((anchor) => {\n const entry = navEntry(reader, anchor, child)\n if (!panel) return entry\n const at = panel.columns.findIndex((column) => reader.contains(column, anchor.element))\n const tile = tileOf(reader, anchor)\n return { ...entry, ...(at >= 0 ? { at } : {}), ...(tile ? { tile } : {}) }\n }),\n ...(panel ? { columns: panel.columns.map((column) => panelColumn(reader, column, panel.ground)), panel: { width: panel.width, hover: panel.hover } } : {}),\n })\n if (items.length >= SITE_IMPORT_NAV_LIMITS.items) break\n }\n // The header's buttons outside the menu row.\n for (const anchor of reader.anchors(header.id)) {\n if (inRow.has(anchor) || brand(anchor) || !anchor.label || reader.contains(row, anchor.element)) continue\n const style = reader.buttonStyle(anchor.element)\n if (!style) continue\n if (!ctas.some((cta) => cta.label === anchor.label && cta.href === anchor.href)) ctas.push({ label: clean(anchor.label, AI_SITE_IMPORT_LABEL_MAX_CHARS * 2), href: anchor.href, style })\n }\n const phoneMenu = reader.elements.some((node) => {\n if (node.region !== 'header' && !reader.contains(header.id, node.id)) return false\n if (node.tag !== 'button' && node.attrs.role !== 'button' && node.tag !== 'summary' && node.tag !== 'a') return false\n if (node.tag === 'a' && !PHONE_MENU_CLASS.test(node.attrs.class ?? '')) return false\n return PHONE_MENU.test(node.attrs.label ?? '') || PHONE_MENU_CLASS.test(node.attrs.class ?? '') || /menu|nav|drawer/i.test(node.attrs.controls ?? '')\n })\n if (!items.length && !ctas.length) return null\n return { items, ctas, phoneMenu, background: reader.background(header.id) }\n}\n\n/** One entry of a menu, with the heading of the column it sits in. */\nfunction navEntry(reader: FrameReader, anchor: SiteImportAnchor, item: number): SiteImportNavEntry {\n const icon = anchor.icon !== undefined ? reader.page.structure.icons[anchor.icon] : undefined\n const column = columnHeading(reader, anchor.element, item)\n return {\n label: clean(anchor.label, AI_SITE_IMPORT_LABEL_MAX_CHARS * 2),\n ...(anchor.text ? { text: clean(anchor.text) } : {}),\n href: anchor.href as string,\n ...(icon?.path ? { iconPath: icon.path, viewBox: icon.viewBox } : {}),\n ...(column ? { column } : {}),\n }\n}\n\n/** A menu's panel as the reader finds it: its columns' elements, its ground, its cap and how it opens. */\ninterface PanelRead {\n columns: number[]\n ground: string | null\n width: number | null\n hover: boolean\n}\n\nconst BUTTON_TAGS = new Set(['button', 'summary'])\n\n/**\n * The panel a menu's entries sit in (AGL-4139): the box under the item that\n * holds them all and not its name. Its columns are the children of the\n * element that lays them side by side, in the source's order, each one that\n * holds a link, words or a picture (a rule between two holds none); a panel\n * of plain links in a row, or one stacked list, is one column. It opens on\n * hover where the source hides it until shown and its name is no button: a\n * button the source opens on a click, as a disclosure does.\n */\nfunction panelOf(reader: FrameReader & { wide: () => SiteImportStyles }, item: number, entries: readonly SiteImportAnchor[], name: number): PanelRead | null {\n const holdsAll = (at: number) => entries.every((anchor) => reader.contains(at, anchor.element))\n let row = (entries[0] as SiteImportAnchor).element\n while (row >= 0 && row !== item && !holdsAll(row)) row = reader.elements[row]?.parent ?? -1\n if (row < 0 || row === item) return null\n // Up to the panel's own box, short of the item and of its name.\n let panel = row\n for (let up = reader.elements[panel]?.parent ?? -1; up >= 0 && up !== item && !reader.contains(up, name); up = reader.elements[up]?.parent ?? -1) panel = up\n const chain: number[] = []\n for (let at = row; at >= 0; at = reader.elements[at]?.parent ?? -1) {\n chain.push(at)\n if (at === panel) break\n }\n const holds = (at: number) => reader.anchors(at).length > 0 || reader.texts(at).length > 0 || !!reader.picture(at)\n // Down through wrappers to the element that sets its columns side by side.\n for (let guard = 0; guard < 16; guard += 1) {\n const inside = (reader.elements[row]?.children ?? []).filter(holds)\n if (inside.length !== 1) break\n row = inside[0] as number\n }\n const inside = (reader.elements[row]?.children ?? []).filter(holds)\n const plainRow = inside.every((at) => reader.anchors(at).length === 1 && !reader.texts(at).length && !reader.picture(at))\n const columns = reader.sideBySide(row) && inside.length >= 2 && !plainRow ? inside : [row]\n // A name in a button opens on a click; one in a link or plain words on hover, where the panel starts hidden.\n let button = false\n for (let at = name; at >= 0 && at !== item; at = reader.elements[at]?.parent ?? -1) {\n const node = reader.elements[at]\n if (node && (BUTTON_TAGS.has(node.tag) || node.attrs.role === 'button')) button = true\n }\n const hidden = chain.some((at) => reader.hidden(at))\n // Its cap as a wide screen reads it, on it or a wrapper down to its row.\n const wide = reader.wide()\n let width: number | null = null\n for (let at = panel; at >= 0 && width === null; ) {\n width = reader.widthPx(at, 'max-width', wide) ?? (/\\bMuiContainer-maxWidthXl\\b/.test(reader.elements[at]?.attrs.class ?? '') ? 1536 : null)\n if (at === row) break\n const next = (reader.elements[at]?.children ?? []).filter(holds)\n at = next.length === 1 ? (next[0] as number) : -1\n }\n return { columns, ground: reader.ground(row), width, hover: hidden && !button }\n}\n\n/** One column of a panel, or one filled box of a footer, as the source sets it (AGL-4139). */\nfunction panelColumn(reader: FrameReader, column: number, ground: string | null): SiteImportNavColumn {\n const links = reader.anchors(column)\n const firstLink = links[0]?.element ?? Number.POSITIVE_INFINITY\n const own = reader.texts(column).filter((entry) => !reader.inLink(entry.element, column))\n const first = own[0]\n const heading = first && first.element < firstLink && first.text.length <= AI_SITE_IMPORT_LABEL_MAX_CHARS ? clean(first.text, AI_SITE_IMPORT_LABEL_MAX_CHARS) : null\n const lines = (heading ? own.slice(1) : own).map((entry) => clean(entry.text)).filter(Boolean).slice(0, 6)\n // Its fill: its own, or that of the one box it holds.\n const inside = (reader.elements[column]?.children ?? []).filter((at) => reader.anchors(at).length || reader.texts(at).length || reader.picture(at))\n const fill = reader.fill(column) ?? (inside.length === 1 ? reader.fill(inside[0] as number) : null)\n const image = reader.picture(column)\n const width = reader.widthPx(column)\n return {\n heading,\n lines,\n band: boxBand(fill, ground),\n ...(image ? { image } : {}),\n ...(width !== null && width > 2 && width <= 600 ? { width } : {}),\n }\n}\n\n/**\n * The filled box an entry's icon sits in (AGL-4139): the nearest box around\n * the icon, inside its link, that holds nothing but the icon and is filled\n * apart from what the link sits on; its corners, and the icon's own color.\n */\nfunction tileOf(reader: FrameReader, anchor: SiteImportAnchor): SiteImportNavEntry['tile'] | null {\n if (anchor.icon === undefined) return null\n const icon = reader.under(anchor.element).find((at) => reader.elements[at]?.icon === anchor.icon)\n if (icon === undefined) return null\n const ground = reader.ground(anchor.element)\n let at = reader.elements[icon]?.parent ?? -1\n for (let depth = 0; depth < 3 && at >= 0 && at !== anchor.element; depth += 1) {\n const fill = reader.fill(at)\n const onlyIcon = reader.under(at).every((inner) => reader.contains(inner, icon) || reader.contains(icon, inner))\n const width = reader.widthPx(at)\n if (fill && fill !== ground && onlyIcon && (width === null || width <= 96)) {\n return { fill, radius: siteImportRadiusPx(reader.styles.of(at)) ?? 0, color: reader.color(icon) }\n }\n at = reader.elements[at]?.parent ?? -1\n }\n return null\n}\n\n/**\n * The words that head the column an entry sits in: the first words, outside\n * any link, of the nearest container around the entry that has words before\n * its first link (\"By team\" over Agencies, Startups, Creators).\n */\nfunction columnHeading(reader: FrameReader, element: number, item: number): string | null {\n const own = reader.texts(item).filter((entry) => !reader.anchors(item).some((anchor) => reader.contains(anchor.element, entry.element)))\n for (let at = reader.elements[element]?.parent ?? -1; at >= 0 && at !== item; at = reader.elements[at]?.parent ?? -1) {\n const first = own.find((entry) => reader.contains(at, entry.element))\n if (!first) continue\n const firstLink = reader.anchors(at)[0]\n if (firstLink && first.element > firstLink.element) return null\n return first.text.length <= AI_SITE_IMPORT_LABEL_MAX_CHARS ? clean(first.text, AI_SITE_IMPORT_LABEL_MAX_CHARS) : null\n }\n return null\n}\n\nconst EMAIL = /[\\w.+-]+@[\\w-]+(?:\\.[\\w-]+)+/\nconst PHONE = /(?:\\+?\\d[\\d\\s().-]{7,}\\d)/\nconst ADDRESS = /\\d+\\s+[\\p{L}\\d .'-]+(?:street|st\\.?|avenue|ave\\.?|road|rd\\.?|drive|dr\\.?|lane|ln\\.?|boulevard|blvd\\.?|way|court|ct\\.?|place|pl\\.?|suite|ste\\.?|highway|hwy\\.?|parkway|pkwy)\\b/iu\n\n/**\n * The source's footer (AGL-4106), as its home page builds it; `null` for a\n * page with no footer.\n */\nexport function siteImportFooterColumns(page: SiteImportFrameSource, stylesheets: readonly string[] = []): SiteImportFooter | null {\n if (!page.structure) return null\n const reader = frameReader(page, stylesheets)\n const footers = reader.elements.filter((node) => (node.tag === 'footer' || node.attrs.role === 'contentinfo') && node.region === 'footer')\n const footer = footers.find((node) => !footers.some((other) => other !== node && reader.contains(other.id, node.id)))\n if (!footer) return null\n const { blocks, structure } = page\n // The footer's words in order: its text blocks, its menu's words, and its links.\n type Leaf = { element: number; text: string; href: string | null }\n const leaves: Leaf[] = []\n structure.blockElement.forEach((element, index) => {\n const block = blocks[index]\n if (!block || block.region !== 'footer' || block.kind === 'image' || block.kind === 'link') return\n // A line that is only its link's words is that link.\n const next = blocks[index + 1]\n if (next?.kind === 'link' && next.inline && next.text === block.text) return\n if (reader.contains(footer.id, element)) leaves.push({ element, text: clean(block.text, 1_000), href: null })\n })\n for (const entry of reader.texts(footer.id)) leaves.push({ element: entry.element, text: clean(entry.text, 1_000), href: null })\n for (const anchor of reader.anchors(footer.id)) {\n // An icon link is named by its label: a profile's network.\n const label = anchor.label || reader.elements[anchor.element]?.attrs.label || ''\n if (anchor.href && label) leaves.push({ element: anchor.element, text: clean(label), href: anchor.href })\n }\n leaves.sort((a, b) => a.element - b.element)\n const within = (element: number) => leaves.filter((leaf) => reader.contains(element, leaf.element))\n // A column: a heading, then its links, nothing else.\n const columns: SiteImportFooter['columns'] = []\n const inColumns = new Set<Leaf>()\n for (const node of reader.elements) {\n if (!reader.contains(footer.id, node.id) || node.id === footer.id) continue\n const own = within(node.id)\n const [heading, ...rest] = own\n if (!heading || heading.href || heading.text.length > AI_SITE_IMPORT_LABEL_MAX_CHARS || rest.length < 2 || rest.some((leaf) => !leaf.href)) continue\n if (own.some((leaf) => inColumns.has(leaf))) continue\n own.forEach((leaf) => inColumns.add(leaf))\n columns.push({ heading: heading.text, links: rest.slice(0, SITE_IMPORT_NAV_LIMITS.footerLinks).map((leaf) => ({ label: leaf.text, href: leaf.href as string })) })\n }\n // Its filled boxes (AGL-4139): a box filled apart from what it sits on,\n // holding a few words and links of no column, its © line not among them.\n const panels: SiteImportNavColumn[] = []\n const inPanels = new Set<Leaf>()\n const copyrightLine = (leaf: Leaf) => !leaf.href && /©|\\(c\\)\\s*\\d{4}|\\bcopyright\\b/i.test(leaf.text)\n for (const node of reader.elements) {\n if (panels.length >= 4) break\n if (!reader.contains(footer.id, node.id) || node.id === footer.id) continue\n const fill = reader.fill(node.id)\n const ground = reader.ground(node.parent)\n if (!fill || fill === ground) continue\n const own = within(node.id)\n if (!own.length || own.length > 8 || !own.some((leaf) => !leaf.href) || own.some((leaf) => inColumns.has(leaf) || inPanels.has(leaf) || copyrightLine(leaf))) continue\n own.forEach((leaf) => inPanels.add(leaf))\n const words = own.filter((leaf) => !leaf.href)\n const [first] = words\n const heading = first && first.text.length <= AI_SITE_IMPORT_LABEL_MAX_CHARS && own[0] === first ? first.text : null\n const icon = reader.under(node.id).map((at) => reader.elements[at]?.icon).find((index) => index !== undefined)\n const shape = icon !== undefined ? structure.icons[icon] : undefined\n panels.push({\n heading,\n lines: (heading ? words.slice(1) : words).map((leaf) => leaf.text).slice(0, 6),\n band: boxBand(fill, ground),\n links: own.filter((leaf) => leaf.href).map((leaf) => ({ label: leaf.text, href: leaf.href as string })),\n ...(shape?.path && (shape.viewBox || '0 0 24 24') === '0 0 24 24' ? { iconPath: shape.path } : {}),\n })\n }\n // It opens with the site's logo: its first picture, before any of its words, the header's brand by its address or its name.\n const home = structure.anchors.find((anchor) => anchor.region === 'header' && !!anchor.image && /^https?:\\/\\/[^/]+\\/?$/i.test(anchor.href ?? ''))\n const brand = home ? reader.picture(home.element) : null\n const firstPicture = reader.under(footer.id).find((at) => !!reader.elements[at]?.picture)\n const picture = firstPicture !== undefined ? reader.elements[firstPicture]?.picture : undefined\n const logo =\n firstPicture !== undefined &&\n !!picture &&\n !leaves.some((leaf) => leaf.element < firstPicture) &&\n (!!brand && (brand.url === picture.url || (!!brand.alt && brand.alt === picture.alt)))\n const social: SiteImportFooter['social'] = []\n const links: SiteImportFooterLink[] = []\n const text: string[] = []\n let copyright: string | null = null\n let address: string | null = null\n let phone: string | null = null\n let email: string | null = null\n for (const leaf of leaves) {\n if (inColumns.has(leaf) || inPanels.has(leaf)) continue\n if (leaf.href) {\n const network = siteImportSocialNetwork(leaf.href)\n if (network) {\n if (!social.some((entry) => entry.href === leaf.href)) social.push({ label: leaf.text, href: leaf.href, network })\n } else if (leaf.href.startsWith('mailto:')) email ??= leaf.href.slice('mailto:'.length)\n else if (leaf.href.startsWith('tel:')) phone ??= leaf.text\n else if (!links.some((entry) => entry.href === leaf.href && entry.label === leaf.text)) links.push({ label: leaf.text, href: leaf.href })\n continue\n }\n if (!copyright && /©|\\(c\\)\\s*\\d{4}|\\bcopyright\\b/i.test(leaf.text)) {\n copyright = leaf.text\n continue\n }\n if (!email && EMAIL.test(leaf.text) && leaf.text.length <= 120) email = (EMAIL.exec(leaf.text) as RegExpExecArray)[0]\n else if (!phone && PHONE.test(leaf.text) && leaf.text.length <= 40) phone = leaf.text\n else if (!address && ADDRESS.test(leaf.text) && leaf.text.length <= 200) address = leaf.text\n else if (!text.includes(leaf.text)) text.push(leaf.text)\n }\n // What the footer does not print, the site's own structured data says.\n const organization = page.organization\n return {\n columns,\n social,\n links,\n text,\n address: address ?? (organization?.address || null),\n phone: phone ?? (organization?.telephone || null),\n email: email ?? (organization?.email || null),\n copyright,\n ...(logo ? { logo: true } : {}),\n ...(panels.length ? { panels } : {}),\n }\n}\n"],"names":["AI_SITE_IMPORT_LABEL_MAX_CHARS","SITE_IMPORT_CSS_WIDE_WIDTH","siteImportBackgroundOf","siteImportColorOf","siteImportCssOf","siteImportGridColumns","siteImportHex","siteImportLengthPx","siteImportRadiusPx","siteImportStylesOf","siteImportBandOfColor","siteImportButtonStyleOf","SITE_IMPORT_NAV_LIMITS","items","entries","footerLinks","PHONE_MENU","PHONE_MENU_CLASS","SOCIAL_NETWORKS","siteImportSocialNetwork","href","host","URL","hostname","find","pattern","test","clean","text","max","line","String","replace","trim","length","slice","trimEnd","FrameReader","anchors","element","held","anchorMemo","get","node","elements","own","anchorAt","list","child","children","push","set","contains","ancestor","at","parent","texts","page","structure","filter","entry","first","background","depth","color","styles","of","a","buttonStyle","ground","fill","under","out","visit","inLink","within","some","anchor","picture","hidden","style","attrs","sideBySide","display","widthPx","property","value","Map","frameReader","stylesheets","sheets","reader","wide","Object","assign","boxBand","band","siteImportNavTree","header","tag","region","role","nav","id","row","guard","brand","pathname","image","label","ctas","inRow","Set","opener","forEach","add","trigger","panel","panelOf","map","navEntry","columns","findIndex","column","tile","tileOf","panelColumn","width","hover","has","cta","phoneMenu","class","controls","item","icon","undefined","icons","columnHeading","path","iconPath","viewBox","BUTTON_TAGS","name","holdsAll","every","up","chain","holds","inside","plainRow","button","next","links","firstLink","Number","POSITIVE_INFINITY","heading","lines","Boolean","onlyIcon","inner","radius","EMAIL","PHONE","ADDRESS","siteImportFooterColumns","footers","footer","other","blocks","leaves","blockElement","index","block","kind","inline","sort","b","leaf","inColumns","rest","panels","inPanels","copyrightLine","words","shape","home","firstPicture","logo","url","alt","social","copyright","address","phone","email","network","startsWith","exec","includes","organization","telephone"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;2CA0B2C,GAE3C,SACEA,8BAA8B,QAUzB,6BAAyB;AAChC,SACEC,0BAA0B,EAC1BC,sBAAsB,EACtBC,iBAAiB,EACjBC,eAAe,EACfC,qBAAqB,EACrBC,aAAa,EACbC,kBAAkB,EAClBC,kBAAkB,EAClBC,kBAAkB,QAEb,uBAAmB;AAE1B,SAASC,qBAAqB,EAAEC,uBAAuB,QAAQ,0BAAsB;AAKrF,sEAAsE,GACtE,OAAO,MAAMC,yBAAyB;IAAEC,OAAO;IAAIC,SAAS;IAAIC,aAAa;AAAI,EAAU;AAE3F,MAAMC,aAAa;AACnB,MAAMC,mBAAmB;AAEzB,MAAMC,kBAAmD;IACvD;QAAC;QAAqC;KAAI;IAC1C;QAAC;QAA2B;KAAW;IACvC;QAAC;QAA4B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AAA,aAAcC,SAAS,KAAI;QAC5CN,KAAK,EAAEA,gBAAAA,QAAUK,CAAAA,gCAAAA,aAAcL,KAAK,KAAI;QACxCH;OACIJ,OAAO;QAAEA,MAAM;IAAK,IAAI,CAAC,GACzBP,OAAOpJ,MAAM,GAAG;QAAEoJ;IAAO,IAAI,CAAC;AAEtC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-import/site-import-nav.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 * THE SOURCE'S MENU AND FOOTER, AS IT BUILDS THEM (AGL-4106).\n *\n * The import's header used to be the wave's page titles, seven of them, cut\n * to 28 characters, with no menus: the source's own menu was read as a flat\n * list of links and used only for their order. This reads it as the source\n * builds it, with no model:\n *\n * - **The menu** (`siteImportNavTree`). Each top-level item of the header's\n * `<nav>` row: its link, and the panel that opens under it (a container of\n * two or more links), each entry with its name, the line under it in a mega\n * menu, its address, its icon and the heading of the column it sits in;\n * and (AGL-4139) the panel's columns as the source sets them side by side,\n * each one's heading, words, fill, picture and width, the tile behind each\n * icon, and whether the panel opens on hover.\n * The header's buttons outside the row (\"Sign in\", \"Start free\") with their\n * addresses and how they are drawn; whether the source shows a menu button\n * on phones; the header bar's background.\n * - **The footer** (`siteImportFooterColumns`). Each column: its heading and\n * its links. Its profiles on other sites, its other links, its lines of\n * text, its address, phone and email (from its structured data where the\n * footer prints none), and its © line word for word; whether it opens with\n * the logo, and its filled boxes (AGL-4139).\n *\n * Every label is the source's, as written. Untrusted data: it is drawn by the\n * frame compiler as words, and fenced wherever a prompt reads it.\n *=========================================*/\n\nimport {\n AI_SITE_IMPORT_LABEL_MAX_CHARS,\n type SiteImportBand,\n type SiteImportButtonStyle,\n type SiteImportFooter,\n type SiteImportFooterLink,\n type SiteImportNavColumn,\n type SiteImportNavCta,\n type SiteImportNavEntry,\n type SiteImportNavGroup,\n type SiteImportNavTree,\n} from '../model/ai-site-import'\nimport {\n SITE_IMPORT_CSS_WIDE_WIDTH,\n siteImportBackgroundOf,\n siteImportColorOf,\n siteImportCssOf,\n siteImportGridColumns,\n siteImportHex,\n siteImportLengthPx,\n siteImportRadiusPx,\n siteImportStylesOf,\n type SiteImportStyles,\n} from './site-import-css'\nimport type { SiteImportAnchor, SiteImportElement, SiteImportExtract, SiteImportStructure } from './site-import-html'\nimport { siteImportBandOfColor, siteImportButtonStyleOf } from './site-import-layout'\n\n/** A page as the menu reader takes it: its structure, its blocks and its structured data. */\nexport type SiteImportFrameSource = Pick<SiteImportExtract, 'blocks' | 'organization'> & { structure: SiteImportStructure }\n\n/** The most top-level items, entries per menu and footer links kept. */\nexport const SITE_IMPORT_NAV_LIMITS = { items: 12, entries: 40, footerLinks: 160 } as const\n\nconst PHONE_MENU = /\\b(?:menu|navigation|nav)\\b/i\nconst PHONE_MENU_CLASS = /hamburger|burger|menu-?toggle|nav-?toggle|mobile-?menu|navbar-toggler|menu-?button|header-menu-toggle|drawer-?toggle/i\n\nconst SOCIAL_NETWORKS: ReadonlyArray<[RegExp, string]> = [\n [/(?:^|\\.)(?:twitter\\.com|x\\.com)$/i, 'x'],\n [/(?:^|\\.)facebook\\.com$/i, 'facebook'],\n [/(?:^|\\.)instagram\\.com$/i, 'instagram'],\n [/(?:^|\\.)linkedin\\.com$/i, 'linkedin'],\n [/(?:^|\\.)youtube\\.com$/i, 'youtube'],\n [/(?:^|\\.)tiktok\\.com$/i, 'tiktok'],\n [/(?:^|\\.)github\\.com$/i, 'github'],\n [/(?:^|\\.)pinterest\\.com$/i, 'pinterest'],\n [/(?:^|\\.)threads\\.net$/i, 'threads'],\n [/(?:^|\\.)yelp\\.com$/i, 'yelp'],\n [/(?:^|\\.)tripadvisor\\.com$/i, 'tripadvisor'],\n [/(?:^|\\.)nextdoor\\.com$/i, 'nextdoor'],\n [/(?:^|\\.)vimeo\\.com$/i, 'vimeo'],\n [/(?:^|\\.)bsky\\.app$/i, 'bluesky'],\n [/(?:^|\\.)mastodon\\.social$/i, 'mastodon'],\n [/(?:^|\\.)discord\\.(?:gg|com)$/i, 'discord'],\n [/(?:^|\\.)whatsapp\\.com$|(?:^|\\.)wa\\.me$/i, 'whatsapp'],\n]\n\n/** The network a profile address is on, or `null` for an address that is no profile. */\nexport function siteImportSocialNetwork(href: string): string | null {\n try {\n const host = new URL(href).hostname\n return SOCIAL_NETWORKS.find(([pattern]) => pattern.test(host))?.[1] ?? null\n } catch {\n return null\n }\n}\n\nconst clean = (text: string, max = 300) => {\n const line = String(text ?? '').replace(/\\s+/g, ' ').trim()\n return line.length > max ? `${line.slice(0, max - 1).trimEnd()}…` : line\n}\n\nclass FrameReader {\n readonly elements: readonly SiteImportElement[]\n /** Each element's anchors, its subtree's, in order. */\n private readonly anchorMemo = new Map<number, SiteImportAnchor[]>()\n private readonly anchorAt = new Map<number, SiteImportAnchor>()\n\n constructor(\n readonly page: SiteImportFrameSource,\n readonly styles: SiteImportStyles,\n ) {\n this.elements = page.structure.elements\n for (const anchor of page.structure.anchors) this.anchorAt.set(anchor.element, anchor)\n }\n\n anchors(element: number): SiteImportAnchor[] {\n const held = this.anchorMemo.get(element)\n if (held) return held\n const node = this.elements[element]\n if (!node) return []\n const own = this.anchorAt.get(element)\n const list = own ? [own] : []\n for (const child of node.children) list.push(...this.anchors(child))\n this.anchorMemo.set(element, list)\n return list\n }\n\n contains(ancestor: number, element: number): boolean {\n for (let at = element; at >= 0; at = this.elements[at]?.parent ?? -1) if (at === ancestor) return true\n return false\n }\n\n /** The words a menu holds outside its links, by element: a column's heading, a button's name. */\n texts(element: number): Array<{ element: number; text: string }> {\n const texts = this.page.structure.texts ?? []\n return texts.filter((entry) => this.contains(element, entry.element))\n }\n\n first(test: (node: SiteImportElement) => boolean): SiteImportElement | undefined {\n return this.elements.find(test)\n }\n\n background(element: number): string | null {\n for (let at = element, depth = 0; at >= 0 && depth < 4; depth += 1) {\n const color = siteImportBackgroundOf(this.styles.of(at)).color\n if (color && color.a >= 0.5) return siteImportHex(color)\n const children: number[] = (this.elements[at]?.children ?? []).filter((child) => this.anchors(child).length || this.elements[child]?.children.length)\n at = children.length === 1 ? (children[0] as number) : -1\n }\n return null\n }\n\n buttonStyle(element: number): SiteImportButtonStyle | null {\n const node = this.elements[element]\n if (!node) return null\n return siteImportButtonStyleOf(node, this.styles.of(element), this.ground(node.parent) ?? '#ffffff')\n }\n\n /** An element's own solid fill, `#rrggbb`, or `null`. */\n fill(element: number): string | null {\n const color = siteImportBackgroundOf(this.styles.of(element)).color\n return color && color.a >= 0.5 ? siteImportHex(color) : null\n }\n\n /** The fill an element sits on: its own, or the nearest one around it. */\n ground(element: number): string | null {\n for (let at = element; at >= 0; at = this.elements[at]?.parent ?? -1) {\n const fill = this.fill(at)\n if (fill) return fill\n }\n return null\n }\n\n /** Every element under one, itself first, in order. */\n under(element: number): number[] {\n const out: number[] = []\n const visit = (at: number) => {\n const node = this.elements[at]\n if (!node) return\n out.push(at)\n for (const child of node.children) visit(child)\n }\n visit(element)\n return out\n }\n\n /** Whether an element is inside one of the page's links. */\n inLink(element: number, within: number): boolean {\n return this.page.structure.anchors.some((anchor) => anchor.element !== within && this.contains(within, anchor.element) && this.contains(anchor.element, element))\n }\n\n /** The first picture an element shows outside its links. */\n picture(element: number): { url: string; alt: string } | null {\n for (const at of this.under(element)) {\n const picture = this.elements[at]?.picture\n if (picture && !this.inLink(at, element)) return picture\n }\n return null\n }\n\n /** Whether the source hides an element until something shows it. */\n hidden(element: number): boolean {\n const style = this.styles.of(element)\n return this.elements[element]?.attrs.hidden === true || style.get('display') === 'none' || style.get('visibility') === 'hidden'\n }\n\n /** Whether an element lays its children side by side: a flex row, or a grid of two columns or more. */\n sideBySide(element: number): boolean {\n const style = this.styles.of(element)\n const display = style.get('display') ?? ''\n if (/flex/.test(display)) return !/column/.test(style.get('flex-direction') ?? '')\n return /grid/.test(display) && (siteImportGridColumns(style.get('grid-template-columns'))?.length ?? 0) >= 2\n }\n\n /** An element's width in CSS pixels, where the source sets it in pixels. */\n widthPx(element: number, property: 'width' | 'max-width' = 'width', styles: SiteImportStyles = this.styles): number | null {\n const value = styles.of(element).get(property) ?? ''\n return /^\\s*-?\\d*\\.?\\d+\\s*px\\s*$/i.test(value) ? siteImportLengthPx(value) : null\n }\n\n /** Its icon's color as the source draws it, `#rrggbb`. */\n color(element: number): string | null {\n const color = siteImportColorOf(this.styles.of(element).get('color'))\n return color && color.a >= 0.5 ? siteImportHex(color) : null\n }\n}\n\nfunction frameReader(page: SiteImportFrameSource, stylesheets: readonly string[]): FrameReader & { wide: () => SiteImportStyles } {\n const sheets = [...page.structure.styles, ...stylesheets]\n const reader = new FrameReader(page, siteImportStylesOf(page.structure, siteImportCssOf(sheets)))\n // A panel's cap as a wide screen reads it: a framework's widest container sets its own only from 1,536 px up.\n let wide: SiteImportStyles | null = null\n return Object.assign(reader, { wide: () => (wide ??= siteImportStylesOf(page.structure, siteImportCssOf(sheets, SITE_IMPORT_CSS_WIDE_WIDTH))) })\n}\n\n/**\n * A box's fill against the ground it sits on, as a band: none where it is\n * the ground's own; a dark box on a dark ground, or a near-white one, is a\n * light step; else the band its color is.\n */\nfunction boxBand(fill: string | null, ground: string | null): SiteImportBand {\n if (!fill || fill === ground) return 'plain'\n const own = siteImportColorOf(fill)\n if (!own) return 'plain'\n const band = siteImportBandOfColor(own)\n const under = ground ? siteImportColorOf(ground) : null\n if (band === 'dark' && under && siteImportBandOfColor(under) === 'dark') return 'soft'\n return band === 'plain' ? 'soft' : band\n}\n\n/**\n * The source's header menu (AGL-4106), as its home page builds it; `null`\n * for a page with no header menu the reader can find.\n */\nexport function siteImportNavTree(page: SiteImportFrameSource, stylesheets: readonly string[] = []): SiteImportNavTree | null {\n if (!page.structure) return null\n const reader = frameReader(page, stylesheets)\n const header =\n reader.first((node) => node.tag === 'header' && node.region === 'header') ??\n reader.first((node) => node.attrs.role === 'banner') ??\n reader.first((node) => node.tag === 'nav' && node.region !== 'footer')\n if (!header) return null\n const nav =\n reader.first((node) => node.tag === 'nav' && reader.contains(header.id, node.id) && reader.anchors(node.id).length >= 2) ??\n reader.first((node) => node.tag === 'nav' && node.region !== 'footer' && reader.anchors(node.id).length >= 2) ??\n header\n // The row: down through wrappers to the element whose children are the items.\n let row = nav.id\n for (let guard = 0; guard < 32; guard += 1) {\n const children = (reader.elements[row]?.children ?? []).filter((child) => reader.anchors(child).length || reader.texts(child).length)\n if (children.length !== 1) break\n row = children[0] as number\n }\n const brand = (anchor: SiteImportAnchor) => {\n try {\n return new URL(anchor.href ?? '').pathname === '/' && (!!anchor.image || !anchor.label)\n } catch {\n return false\n }\n }\n /** A link to a place on this page that says it skips there (AGL-4152): a way past the menu, never a menu item or a call to action. */\n const skip = (anchor: SiteImportAnchor) => {\n const attrs = reader.elements[anchor.element]?.attrs\n return /^#/.test(attrs?.href ?? '') && (/skip/i.test(attrs?.class ?? '') || /skip/i.test(anchor.label))\n }\n const items: SiteImportNavGroup[] = []\n const ctas: SiteImportNavCta[] = []\n const inRow = new Set<SiteImportAnchor>()\n for (const child of reader.elements[row]?.children ?? []) {\n const anchors = reader.anchors(child).filter((anchor) => !brand(anchor) && !skip(anchor) && (anchor.label || anchor.href))\n const texts = reader.texts(child)\n if (!anchors.length && !texts.length) continue\n anchors.forEach((anchor) => inRow.add(anchor))\n // A top-level link drawn as a button is a call to action, as the source draws it.\n if (anchors.length === 1 && !texts.length) {\n const anchor = anchors[0] as SiteImportAnchor\n const style = reader.buttonStyle(anchor.element)\n if (style && style !== 'quiet') {\n ctas.push({ label: clean(anchor.label, AI_SITE_IMPORT_LABEL_MAX_CHARS * 2), href: anchor.href, style })\n continue\n }\n }\n // The item's name: its first link, or the words of the button that opens its menu.\n const trigger = anchors[0]\n const opener = texts.find((entry) => !trigger || entry.element < trigger.element)\n const label = clean(opener?.text ?? trigger?.label ?? '', AI_SITE_IMPORT_LABEL_MAX_CHARS * 2)\n if (!label) continue\n const entries = (opener ? anchors : anchors.slice(1)).slice(0, SITE_IMPORT_NAV_LIMITS.entries).filter((anchor) => anchor.href)\n // Its panel as the source sets it (AGL-4139): its columns side by side, and whether it opens on hover.\n const panel = entries.length ? panelOf(reader, child, entries, opener ? opener.element : (trigger as SiteImportAnchor).element) : null\n items.push({\n label,\n href: opener ? null : (trigger?.href ?? null),\n items: entries.map((anchor) => {\n const entry = navEntry(reader, anchor, child)\n if (!panel) return entry\n const at = panel.columns.findIndex((column) => reader.contains(column, anchor.element))\n const tile = tileOf(reader, anchor)\n return { ...entry, ...(at >= 0 ? { at } : {}), ...(tile ? { tile } : {}) }\n }),\n ...(panel ? { columns: panel.columns.map((column) => panelColumn(reader, column, panel.ground)), panel: { width: panel.width, hover: panel.hover } } : {}),\n })\n if (items.length >= SITE_IMPORT_NAV_LIMITS.items) break\n }\n // The header's buttons outside the menu row.\n for (const anchor of reader.anchors(header.id)) {\n if (inRow.has(anchor) || brand(anchor) || skip(anchor) || !anchor.label || reader.contains(row, anchor.element)) continue\n const style = reader.buttonStyle(anchor.element)\n if (!style) continue\n // A header can hold one button twice, a wide screen's and a phone's: the strongest drawing of it stands.\n const held = ctas.find((cta) => cta.label === anchor.label && cta.href === anchor.href)\n if (!held) ctas.push({ label: clean(anchor.label, AI_SITE_IMPORT_LABEL_MAX_CHARS * 2), href: anchor.href, style })\n else if (CTA_STRENGTH[style] > CTA_STRENGTH[held.style]) held.style = style\n }\n const phoneMenu = reader.elements.some((node) => {\n if (node.region !== 'header' && !reader.contains(header.id, node.id)) return false\n if (node.tag !== 'button' && node.attrs.role !== 'button' && node.tag !== 'summary' && node.tag !== 'a') return false\n if (node.tag === 'a' && !PHONE_MENU_CLASS.test(node.attrs.class ?? '')) return false\n return PHONE_MENU.test(node.attrs.label ?? '') || PHONE_MENU_CLASS.test(node.attrs.class ?? '') || /menu|nav|drawer/i.test(node.attrs.controls ?? '')\n })\n if (!items.length && !ctas.length) return null\n return { items, ctas, phoneMenu, background: reader.background(header.id) }\n}\n\n/** How strongly a header's button is drawn. */\nconst CTA_STRENGTH: Record<SiteImportNavCta['style'], number> = { quiet: 0, secondary: 1, primary: 2 }\n\n/** One entry of a menu, with the heading of the column it sits in. */\nfunction navEntry(reader: FrameReader, anchor: SiteImportAnchor, item: number): SiteImportNavEntry {\n const icon = anchor.icon !== undefined ? reader.page.structure.icons[anchor.icon] : undefined\n const column = columnHeading(reader, anchor.element, item)\n return {\n label: clean(anchor.label, AI_SITE_IMPORT_LABEL_MAX_CHARS * 2),\n ...(anchor.text ? { text: clean(anchor.text) } : {}),\n href: anchor.href as string,\n ...(icon?.path ? { iconPath: icon.path, viewBox: icon.viewBox } : {}),\n ...(column ? { column } : {}),\n }\n}\n\n/** A menu's panel as the reader finds it: its columns' elements, its ground, its cap and how it opens. */\ninterface PanelRead {\n columns: number[]\n ground: string | null\n width: number | null\n hover: boolean\n}\n\nconst BUTTON_TAGS = new Set(['button', 'summary'])\n\n/**\n * The panel a menu's entries sit in (AGL-4139): the box under the item that\n * holds them all and not its name. Its columns are the children of the\n * element that lays them side by side, in the source's order, each one that\n * holds a link, words or a picture (a rule between two holds none); a panel\n * of plain links in a row, or one stacked list, is one column. It opens on\n * hover where the source hides it until shown and its name is no button: a\n * button the source opens on a click, as a disclosure does.\n */\nfunction panelOf(reader: FrameReader & { wide: () => SiteImportStyles }, item: number, entries: readonly SiteImportAnchor[], name: number): PanelRead | null {\n const holdsAll = (at: number) => entries.every((anchor) => reader.contains(at, anchor.element))\n let row = (entries[0] as SiteImportAnchor).element\n while (row >= 0 && row !== item && !holdsAll(row)) row = reader.elements[row]?.parent ?? -1\n if (row < 0 || row === item) return null\n // Up to the panel's own box, short of the item and of its name.\n let panel = row\n for (let up = reader.elements[panel]?.parent ?? -1; up >= 0 && up !== item && !reader.contains(up, name); up = reader.elements[up]?.parent ?? -1) panel = up\n const chain: number[] = []\n for (let at = row; at >= 0; at = reader.elements[at]?.parent ?? -1) {\n chain.push(at)\n if (at === panel) break\n }\n const holds = (at: number) => reader.anchors(at).length > 0 || reader.texts(at).length > 0 || !!reader.picture(at)\n // Down through wrappers to the element that sets its columns side by side.\n for (let guard = 0; guard < 16; guard += 1) {\n const inside = (reader.elements[row]?.children ?? []).filter(holds)\n if (inside.length !== 1) break\n row = inside[0] as number\n }\n const inside = (reader.elements[row]?.children ?? []).filter(holds)\n const plainRow = inside.every((at) => reader.anchors(at).length === 1 && !reader.texts(at).length && !reader.picture(at))\n const columns = reader.sideBySide(row) && inside.length >= 2 && !plainRow ? inside : [row]\n // A name in a button opens on a click; one in a link or plain words on hover, where the panel starts hidden.\n let button = false\n for (let at = name; at >= 0 && at !== item; at = reader.elements[at]?.parent ?? -1) {\n const node = reader.elements[at]\n if (node && (BUTTON_TAGS.has(node.tag) || node.attrs.role === 'button')) button = true\n }\n const hidden = chain.some((at) => reader.hidden(at))\n // Its cap as a wide screen reads it, on it or a wrapper down to its row.\n const wide = reader.wide()\n let width: number | null = null\n for (let at = panel; at >= 0 && width === null; ) {\n width = reader.widthPx(at, 'max-width', wide) ?? (/\\bMuiContainer-maxWidthXl\\b/.test(reader.elements[at]?.attrs.class ?? '') ? 1536 : null)\n if (at === row) break\n const next = (reader.elements[at]?.children ?? []).filter(holds)\n at = next.length === 1 ? (next[0] as number) : -1\n }\n return { columns, ground: reader.ground(row), width, hover: hidden && !button }\n}\n\n/** One column of a panel, or one filled box of a footer, as the source sets it (AGL-4139). */\nfunction panelColumn(reader: FrameReader, column: number, ground: string | null): SiteImportNavColumn {\n const links = reader.anchors(column)\n const firstLink = links[0]?.element ?? Number.POSITIVE_INFINITY\n const own = reader.texts(column).filter((entry) => !reader.inLink(entry.element, column))\n const first = own[0]\n const heading = first && first.element < firstLink && first.text.length <= AI_SITE_IMPORT_LABEL_MAX_CHARS ? clean(first.text, AI_SITE_IMPORT_LABEL_MAX_CHARS) : null\n const lines = (heading ? own.slice(1) : own).map((entry) => clean(entry.text)).filter(Boolean).slice(0, 6)\n // Its fill: its own, or that of the one box it holds.\n const inside = (reader.elements[column]?.children ?? []).filter((at) => reader.anchors(at).length || reader.texts(at).length || reader.picture(at))\n const fill = reader.fill(column) ?? (inside.length === 1 ? reader.fill(inside[0] as number) : null)\n const image = reader.picture(column)\n const width = reader.widthPx(column)\n return {\n heading,\n lines,\n band: boxBand(fill, ground),\n ...(image ? { image } : {}),\n ...(width !== null && width > 2 && width <= 600 ? { width } : {}),\n }\n}\n\n/**\n * The filled box an entry's icon sits in (AGL-4139): the nearest box around\n * the icon, inside its link, that holds nothing but the icon and is filled\n * apart from what the link sits on; its corners, and the icon's own color.\n */\nfunction tileOf(reader: FrameReader, anchor: SiteImportAnchor): SiteImportNavEntry['tile'] | null {\n if (anchor.icon === undefined) return null\n const icon = reader.under(anchor.element).find((at) => reader.elements[at]?.icon === anchor.icon)\n if (icon === undefined) return null\n const ground = reader.ground(anchor.element)\n let at = reader.elements[icon]?.parent ?? -1\n for (let depth = 0; depth < 3 && at >= 0 && at !== anchor.element; depth += 1) {\n const fill = reader.fill(at)\n const onlyIcon = reader.under(at).every((inner) => reader.contains(inner, icon) || reader.contains(icon, inner))\n const width = reader.widthPx(at)\n if (fill && fill !== ground && onlyIcon && (width === null || width <= 96)) {\n return { fill, radius: siteImportRadiusPx(reader.styles.of(at)) ?? 0, color: reader.color(icon) }\n }\n at = reader.elements[at]?.parent ?? -1\n }\n return null\n}\n\n/**\n * The words that head the column an entry sits in: the first words, outside\n * any link, of the nearest container around the entry that has words before\n * its first link (\"By team\" over Agencies, Startups, Creators).\n */\nfunction columnHeading(reader: FrameReader, element: number, item: number): string | null {\n const own = reader.texts(item).filter((entry) => !reader.anchors(item).some((anchor) => reader.contains(anchor.element, entry.element)))\n for (let at = reader.elements[element]?.parent ?? -1; at >= 0 && at !== item; at = reader.elements[at]?.parent ?? -1) {\n const first = own.find((entry) => reader.contains(at, entry.element))\n if (!first) continue\n const firstLink = reader.anchors(at)[0]\n if (firstLink && first.element > firstLink.element) return null\n return first.text.length <= AI_SITE_IMPORT_LABEL_MAX_CHARS ? clean(first.text, AI_SITE_IMPORT_LABEL_MAX_CHARS) : null\n }\n return null\n}\n\nconst EMAIL = /[\\w.+-]+@[\\w-]+(?:\\.[\\w-]+)+/\nconst PHONE = /(?:\\+?\\d[\\d\\s().-]{7,}\\d)/\nconst ADDRESS = /\\d+\\s+[\\p{L}\\d .'-]+(?:street|st\\.?|avenue|ave\\.?|road|rd\\.?|drive|dr\\.?|lane|ln\\.?|boulevard|blvd\\.?|way|court|ct\\.?|place|pl\\.?|suite|ste\\.?|highway|hwy\\.?|parkway|pkwy)\\b/iu\n\n/**\n * The source's footer (AGL-4106), as its home page builds it; `null` for a\n * page with no footer.\n */\nexport function siteImportFooterColumns(page: SiteImportFrameSource, stylesheets: readonly string[] = []): SiteImportFooter | null {\n if (!page.structure) return null\n const reader = frameReader(page, stylesheets)\n const footers = reader.elements.filter((node) => (node.tag === 'footer' || node.attrs.role === 'contentinfo') && node.region === 'footer')\n const footer = footers.find((node) => !footers.some((other) => other !== node && reader.contains(other.id, node.id)))\n if (!footer) return null\n const { blocks, structure } = page\n // The footer's words in order: its text blocks, its menu's words, and its links.\n type Leaf = { element: number; text: string; href: string | null }\n const leaves: Leaf[] = []\n structure.blockElement.forEach((element, index) => {\n const block = blocks[index]\n if (!block || block.region !== 'footer' || block.kind === 'image' || block.kind === 'link') return\n // A line that is only its link's words is that link.\n const next = blocks[index + 1]\n if (next?.kind === 'link' && next.inline && next.text === block.text) return\n if (reader.contains(footer.id, element)) leaves.push({ element, text: clean(block.text, 1_000), href: null })\n })\n for (const entry of reader.texts(footer.id)) leaves.push({ element: entry.element, text: clean(entry.text, 1_000), href: null })\n for (const anchor of reader.anchors(footer.id)) {\n // An icon link is named by its label: a profile's network.\n const label = anchor.label || reader.elements[anchor.element]?.attrs.label || ''\n if (anchor.href && label) leaves.push({ element: anchor.element, text: clean(label), href: anchor.href })\n }\n leaves.sort((a, b) => a.element - b.element)\n const within = (element: number) => leaves.filter((leaf) => reader.contains(element, leaf.element))\n // A column: a heading, then its links, nothing else.\n const columns: SiteImportFooter['columns'] = []\n const inColumns = new Set<Leaf>()\n for (const node of reader.elements) {\n if (!reader.contains(footer.id, node.id) || node.id === footer.id) continue\n const own = within(node.id)\n const [heading, ...rest] = own\n if (!heading || heading.href || heading.text.length > AI_SITE_IMPORT_LABEL_MAX_CHARS || rest.length < 2 || rest.some((leaf) => !leaf.href)) continue\n if (own.some((leaf) => inColumns.has(leaf))) continue\n own.forEach((leaf) => inColumns.add(leaf))\n columns.push({ heading: heading.text, links: rest.slice(0, SITE_IMPORT_NAV_LIMITS.footerLinks).map((leaf) => ({ label: leaf.text, href: leaf.href as string })) })\n }\n // Its filled boxes (AGL-4139): a box filled apart from what it sits on,\n // holding a few words and links of no column, its © line not among them.\n const panels: SiteImportNavColumn[] = []\n const inPanels = new Set<Leaf>()\n const copyrightLine = (leaf: Leaf) => !leaf.href && /©|\\(c\\)\\s*\\d{4}|\\bcopyright\\b/i.test(leaf.text)\n for (const node of reader.elements) {\n if (panels.length >= 4) break\n if (!reader.contains(footer.id, node.id) || node.id === footer.id) continue\n const fill = reader.fill(node.id)\n const ground = reader.ground(node.parent)\n if (!fill || fill === ground) continue\n const own = within(node.id)\n if (!own.length || own.length > 8 || !own.some((leaf) => !leaf.href) || own.some((leaf) => inColumns.has(leaf) || inPanels.has(leaf) || copyrightLine(leaf))) continue\n own.forEach((leaf) => inPanels.add(leaf))\n const words = own.filter((leaf) => !leaf.href)\n const [first] = words\n const heading = first && first.text.length <= AI_SITE_IMPORT_LABEL_MAX_CHARS && own[0] === first ? first.text : null\n const icon = reader.under(node.id).map((at) => reader.elements[at]?.icon).find((index) => index !== undefined)\n const shape = icon !== undefined ? structure.icons[icon] : undefined\n panels.push({\n heading,\n lines: (heading ? words.slice(1) : words).map((leaf) => leaf.text).slice(0, 6),\n band: boxBand(fill, ground),\n links: own.filter((leaf) => leaf.href).map((leaf) => ({ label: leaf.text, href: leaf.href as string })),\n ...(shape?.path && (shape.viewBox || '0 0 24 24') === '0 0 24 24' ? { iconPath: shape.path } : {}),\n })\n }\n // It opens with the site's logo: its first picture, before any of its words, the header's brand by its address or its name.\n const home = structure.anchors.find((anchor) => anchor.region === 'header' && !!anchor.image && /^https?:\\/\\/[^/]+\\/?$/i.test(anchor.href ?? ''))\n const brand = home ? reader.picture(home.element) : null\n const firstPicture = reader.under(footer.id).find((at) => !!reader.elements[at]?.picture)\n const picture = firstPicture !== undefined ? reader.elements[firstPicture]?.picture : undefined\n const logo =\n firstPicture !== undefined &&\n !!picture &&\n !leaves.some((leaf) => leaf.element < firstPicture) &&\n (!!brand && (brand.url === picture.url || (!!brand.alt && brand.alt === picture.alt)))\n const social: SiteImportFooter['social'] = []\n const links: SiteImportFooterLink[] = []\n const text: string[] = []\n let copyright: string | null = null\n let address: string | null = null\n let phone: string | null = null\n let email: string | null = null\n for (const leaf of leaves) {\n if (inColumns.has(leaf) || inPanels.has(leaf)) continue\n if (leaf.href) {\n const network = siteImportSocialNetwork(leaf.href)\n if (network) {\n if (!social.some((entry) => entry.href === leaf.href)) social.push({ label: leaf.text, href: leaf.href, network })\n } else if (leaf.href.startsWith('mailto:')) email ??= leaf.href.slice('mailto:'.length)\n else if (leaf.href.startsWith('tel:')) phone ??= leaf.text\n else if (!links.some((entry) => entry.href === leaf.href && entry.label === leaf.text)) links.push({ label: leaf.text, href: leaf.href })\n continue\n }\n if (!copyright && /©|\\(c\\)\\s*\\d{4}|\\bcopyright\\b/i.test(leaf.text)) {\n copyright = leaf.text\n continue\n }\n if (!email && EMAIL.test(leaf.text) && leaf.text.length <= 120) email = (EMAIL.exec(leaf.text) as RegExpExecArray)[0]\n else if (!phone && PHONE.test(leaf.text) && leaf.text.length <= 40) phone = leaf.text\n else if (!address && ADDRESS.test(leaf.text) && leaf.text.length <= 200) address = leaf.text\n else if (!text.includes(leaf.text)) text.push(leaf.text)\n }\n // What the footer does not print, the site's own structured data says.\n const organization = page.organization\n return {\n columns,\n social,\n links,\n text,\n address: address ?? (organization?.address || null),\n phone: phone ?? (organization?.telephone || null),\n email: email ?? (organization?.email || null),\n copyright,\n ...(logo ? { logo: true } : {}),\n ...(panels.length ? { panels } : {}),\n }\n}\n"],"names":["AI_SITE_IMPORT_LABEL_MAX_CHARS","SITE_IMPORT_CSS_WIDE_WIDTH","siteImportBackgroundOf","siteImportColorOf","siteImportCssOf","siteImportGridColumns","siteImportHex","siteImportLengthPx","siteImportRadiusPx","siteImportStylesOf","siteImportBandOfColor","siteImportButtonStyleOf","SITE_IMPORT_NAV_LIMITS","items","entries","footerLinks","PHONE_MENU","PHONE_MENU_CLASS","SOCIAL_NETWORKS","siteImportSocialNetwork","href","host","URL","hostname","find","pattern","test","clean","text","max","line","String","replace","trim","length","slice","trimEnd","FrameReader","anchors","element","held","anchorMemo","get","node","elements","own","anchorAt","list","child","children","push","set","contains","ancestor","at","parent","texts","page","structure","filter","entry","first","background","depth","color","styles","of","a","buttonStyle","ground","fill","under","out","visit","inLink","within","some","anchor","picture","hidden","style","attrs","sideBySide","display","widthPx","property","value","Map","frameReader","stylesheets","sheets","reader","wide","Object","assign","boxBand","band","siteImportNavTree","header","tag","region","role","nav","id","row","guard","brand","pathname","image","label","skip","class","ctas","inRow","Set","opener","forEach","add","trigger","panel","panelOf","map","navEntry","columns","findIndex","column","tile","tileOf","panelColumn","width","hover","has","cta","CTA_STRENGTH","phoneMenu","controls","quiet","secondary","primary","item","icon","undefined","icons","columnHeading","path","iconPath","viewBox","BUTTON_TAGS","name","holdsAll","every","up","chain","holds","inside","plainRow","button","next","links","firstLink","Number","POSITIVE_INFINITY","heading","lines","Boolean","onlyIcon","inner","radius","EMAIL","PHONE","ADDRESS","siteImportFooterColumns","footers","footer","other","blocks","leaves","blockElement","index","block","kind","inline","sort","b","leaf","inColumns","rest","panels","inPanels","copyrightLine","words","shape","home","firstPicture","logo","url","alt","social","copyright","address","phone","email","network","startsWith","exec","includes","organization","telephone"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;2CA0B2C,GAE3C,SACEA,8BAA8B,QAUzB,6BAAyB;AAChC,SACEC,0BAA0B,EAC1BC,sBAAsB,EACtBC,iBAAiB,EACjBC,eAAe,EACfC,qBAAqB,EACrBC,aAAa,EACbC,kBAAkB,EAClBC,kBAAkB,EAClBC,kBAAkB,QAEb,uBAAmB;AAE1B,SAASC,qBAAqB,EAAEC,uBAAuB,QAAQ,0BAAsB;AAKrF,sEAAsE,GACtE,OAAO,MAAMC,yBAAyB;IAAEC,OAAO;IAAIC,SAAS;IAAIC,aAAa;AAAI,EAAU;AAE3F,MAAMC,aAAa;AACnB,MAAMC,mBAAmB;AAEzB,MAAMC,kBAAmD;IACvD;QAAC;QAAqC;KAAI;IAC1C;QAAC;QAA2B;KAAW;IACvC;QAAC;QAA4B;KAAY;IACzC;QAAC;QAA2B;KAAW;IACvC;QAAC;QAA0B;KAAU;IACrC;QAAC;QAAyB;KAAS;IACnC;QAAC;QAAyB;KAAS;IACnC;QAAC;QAA4B;KAAY;IACzC;QAAC;QAA0B;KAAU;IACrC;QAAC;QAAuB;KAAO;IAC/B;QAAC;QAA8B;KAAc;IAC7C;QAAC;QAA2B;KAAW;IACvC;QAAC;QAAwB;KAAQ;IACjC;QAAC;QAAuB;KAAU;IAClC;QAAC;QAA8B;KAAW;IAC1C;QAAC;QAAiC;KAAU;IAC5C;QAAC;QAA2C;KAAW;CACxD;AAED,sFAAsF,GACtF,OAAO,SAASC,wBAAwBC,IAAY;IAClD,IAAI;;YAEKF;QADP,MAAMG,OAAO,IAAIC,IAAIF,MAAMG,QAAQ;QACnC,gBAAOL,wBAAAA,gB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;QAC9CC,KAAK,EAAEA,gBAAAA,QAAUM,CAAAA,gCAAAA,aAAcC,SAAS,KAAI;QAC5CN,KAAK,EAAEA,gBAAAA,QAAUK,CAAAA,gCAAAA,aAAcL,KAAK,KAAI;QACxCH;OACIJ,OAAO;QAAEA,MAAM;IAAK,IAAI,CAAC,GACzBP,OAAOzJ,MAAM,GAAG;QAAEyJ;IAAO,IAAI,CAAC;AAEtC"}
|
|
@@ -272,9 +272,14 @@ const SOCIAL_HOSTS = /(?:^|\.)(?:twitter\.com|x\.com|facebook\.com|instagram\.co
|
|
|
272
272
|
case 'off-origin-redirect':
|
|
273
273
|
return 'off-site';
|
|
274
274
|
case 'http-error':
|
|
275
|
+
if (status === 404 || status === 410) return 'missing';
|
|
275
276
|
return status !== undefined && AI_SITE_IMPORT_BLOCKED_STATUSES.has(status) ? 'blocked' : 'unreadable';
|
|
276
277
|
case 'not-reached':
|
|
277
278
|
return 'not-reached';
|
|
279
|
+
case 'duplicate':
|
|
280
|
+
return 'duplicate';
|
|
281
|
+
case 'system-page':
|
|
282
|
+
return 'system-page';
|
|
278
283
|
case 'not-html':
|
|
279
284
|
return 'file';
|
|
280
285
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-import/site-import-page.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 * ONE CRAWLED PAGE, AS AN IMPORT KEEPS IT (AGL-3976).\n *\n * The crawler's page (`SiteImportPage`) holds everything it extracted; an\n * import keeps much less, and keeps it in two shapes:\n *\n * - **Listed**, for the inventory: its address, title, how it was found and\n * how many words and photos it has. No text: an inventory of a whole site\n * rides the job document.\n * - **Read**, for a wave: its text in order, its sections from its headings,\n * and its photos' addresses. The text is kept as the page says it and is\n * fenced as untrusted data only where a prompt shows it; the section names\n * and the title travel outside the fence, so they are neutralized (no\n * fence marker, no hidden character) and cut short. Every block of its\n * main region rides along too (AGL-4083), so a page can be brought in word\n * for word.\n *\n * And from the home page, what the site's header and footer are made of\n * (AGL-4083): its brand as the source draws it (`siteImportHeaderBrand`) and\n * its own facts (`siteImportSiteFacts`), for the header and footer the import\n * builds.\n *=========================================*/\n\nimport { neutralizeUntrustedText } from '@aglyn/shared-util-tools/untrusted-text'\nimport {\n AI_SITE_IMPORT_BLOCKED_STATUSES,\n AI_SITE_IMPORT_IMAGES_PER_PAGE,\n AI_SITE_IMPORT_LABEL_MAX_CHARS,\n AI_SITE_IMPORT_MAX_SECTIONS,\n AI_SITE_IMPORT_PAGE_TEXT_MAX_CHARS,\n AI_SITE_IMPORT_READ_MAX_CHARS,\n aiSiteImportCapBlocks,\n AI_SITE_IMPORT_LAYOUT_MAX_CHARS,\n siteImportLayoutChars,\n siteImportLayoutWithin,\n siteImportLayoutWithoutDrawings,\n type AiSiteImportLeftOutReason,\n type AiSiteImportListedPage,\n type AiSiteImportPageRead,\n} from '../model/ai-site-import'\nimport type { SiteImportPage, SiteImportSkipReason } from './site-import-crawl'\nimport type { SiteImportBlock, SiteImportOrganization } from './site-import-html'\nimport { siteImportLogoCandidates, type SiteImportLogoCandidate } from './site-import-images'\n\n/** A line of untrusted text safe to show outside a fence: neutralized, one line, cut short. */\nexport function siteImportLabel(text: string, max = AI_SITE_IMPORT_LABEL_MAX_CHARS): string {\n const line = neutralizeUntrustedText(text).replace(/\\s+/g, ' ').trim()\n return line.length > max ? `${line.slice(0, max - 1).trimEnd()}…` : line\n}\n\nconst wordsIn = (text: string) => (text.match(/[\\p{L}\\p{N}]+/gu) ?? []).length\n\n/** How many words a page says, its title and headings included; a link inside a sentence is counted once. */\nexport function siteImportPageWords(page: Pick<SiteImportPage, 'title' | 'blocks'>): number {\n return page.blocks.reduce(\n (total, block) => total + (block.kind === 'image' || (block.kind === 'link' && block.inline) ? 0 : wordsIn(block.text)),\n 0,\n )\n}\n\n/** Between a page's own name and its site's in a browser title: \"About | Rosie's Bakery\". */\nconst TITLE_SEPARATOR = /\\s+[|\\u2013\\u2014\\u00b7:-]\\s+/\n\n/**\n * A page's name on the new site: \"Home\" for the home page, else its browser\n * title without the old site's name after a separator (\"About | Rosie's\n * Bakery\" is \"About\"), else its first heading.\n */\nexport function siteImportPageTitle(page: Pick<SiteImportPage, 'path' | 'title' | 'blocks'>): string {\n if ((page.path.replace(/\\/+$/, '') || '/') === '/') return 'Home'\n const own = siteImportLabel((page.title ?? '').split(TITLE_SEPARATOR)[0] ?? '')\n if (own.length >= 2) return own\n return siteImportLabel(page.blocks.find((block) => block.kind === 'heading')?.text ?? '')\n}\n\n/** The page as the inventory lists it. */\nexport function siteImportListedPage(page: SiteImportPage): AiSiteImportListedPage {\n return {\n url: page.url,\n path: page.path,\n title: siteImportPageTitle(page),\n foundBy: page.foundBy,\n words: siteImportPageWords(page),\n images: page.images.length,\n }\n}\n\n/** The page's photos, the ones in its body first, each once. */\nexport function siteImportPageImages(page: Pick<SiteImportPage, 'blocks' | 'images'>): Array<{ url: string; alt: string }> {\n const seen = new Set<string>()\n const images: Array<{ url: string; alt: string }> = []\n const add = (url: string, alt: string) => {\n if (!url || seen.has(url) || images.length >= AI_SITE_IMPORT_IMAGES_PER_PAGE) return\n seen.add(url)\n images.push({ url, alt: siteImportLabel(alt, 250) })\n }\n for (const block of page.blocks) if (block.kind === 'image' && block.region === 'main') add(block.url, block.alt)\n for (const image of page.images) add(image.url, image.alt)\n return images\n}\n\n/**\n * The page's sections, from its headings: the first is its opening (its\n * title or first heading), then one for each second-level heading of its\n * body, at most `AI_SITE_IMPORT_MAX_SECTIONS`. A page with no headings below\n * its title but more to say than an opening gets a second section for it.\n */\nexport function siteImportPageSections(page: Pick<SiteImportPage, 'title' | 'blocks'>): string[] {\n const main = page.blocks.filter((block) => block.region === 'main')\n const headings = main.filter((block): block is Extract<typeof block, { kind: 'heading' }> => block.kind === 'heading')\n const opening = siteImportLabel(headings.find((block) => block.level === 1)?.text || page.title || '') || 'Introduction'\n const sections = [opening]\n const seen = new Set([opening.toLowerCase()])\n for (const heading of headings) {\n if (heading.level !== 2) continue\n const name = siteImportLabel(heading.text)\n if (!name || seen.has(name.toLowerCase())) continue\n seen.add(name.toLowerCase())\n sections.push(name)\n if (sections.length >= AI_SITE_IMPORT_MAX_SECTIONS) break\n }\n if (sections.length === 1 && siteImportPageWords({ title: '', blocks: main }) > 80) sections.push('Details')\n return sections\n}\n\n/** The page's text in order, as a prompt shows it inside its fence. */\nexport function siteImportPageText(page: Pick<SiteImportPage, 'title' | 'description' | 'blocks'>): string {\n const lines: string[] = []\n if (page.title) lines.push(`Title: ${page.title}`)\n if (page.description) lines.push(`Description: ${page.description}`)\n for (const block of page.blocks) {\n const where = block.region === 'main' ? '' : `(${block.region}) `\n if (block.kind === 'heading') lines.push(`${'#'.repeat(block.level)} ${block.text}`)\n else if (block.kind === 'image') lines.push(`${where}[photo: ${block.alt || 'no description'}]`)\n else if (block.kind === 'list-item') lines.push(`${where}- ${block.text}`)\n else if (block.kind === 'quote') lines.push(`${where}> ${block.text}`)\n else if (block.kind === 'link') {\n // A link inside a sentence is in its block's words already.\n if (!block.inline) lines.push(`${where}${block.text}`)\n } else lines.push(`${where}${block.text}`)\n }\n const text = lines.join('\\n')\n return text.length > AI_SITE_IMPORT_PAGE_TEXT_MAX_CHARS ? text.slice(0, AI_SITE_IMPORT_PAGE_TEXT_MAX_CHARS) : text\n}\n\n/**\n * The page as a wave reads it: its main region's blocks whole, within the\n * read's budget, and how the source lays them out (AGL-4106) over the blocks\n * kept, its icons' drawings dropped first when it runs past its own budget.\n */\nexport function siteImportPageRead(page: SiteImportPage, at: string): AiSiteImportPageRead {\n const main = page.blocks.filter((block) => block.region === 'main')\n const capped = aiSiteImportCapBlocks(main, AI_SITE_IMPORT_READ_MAX_CHARS)\n let layout = page.layout ? siteImportLayoutWithin(page.layout, capped.blocks.length) : null\n if (layout && siteImportLayoutChars(layout) > AI_SITE_IMPORT_LAYOUT_MAX_CHARS) layout = siteImportLayoutWithoutDrawings(layout)\n if (layout && siteImportLayoutChars(layout) > AI_SITE_IMPORT_LAYOUT_MAX_CHARS) layout = null\n return {\n at,\n title: siteImportPageTitle(page),\n text: siteImportPageText(page),\n sections: siteImportPageSections(page),\n images: siteImportPageImages(page),\n blocks: capped.blocks,\n ...(capped.cut ? { cut: true } : {}),\n words: siteImportPageWords({ title: '', blocks: main }),\n forms: page.forms.kept,\n ...(layout ? { layout } : {}),\n // Its videos (AGL-4140), which its layout places by index.\n ...(page.videos?.length ? { videos: page.videos } : {}),\n // The source's own title and description, for the page's listing (AGL-4107).\n meta: { title: siteImportMetaText(page.title, SITE_IMPORT_META_TITLE_MAX_CHARS), description: siteImportMetaText(page.description, SITE_IMPORT_META_DESCRIPTION_MAX_CHARS) },\n }\n}\n\n/** The most characters of a source's title and description a read keeps: far past what any listing shows. */\nexport const SITE_IMPORT_META_TITLE_MAX_CHARS = 300\nexport const SITE_IMPORT_META_DESCRIPTION_MAX_CHARS = 1_000\n\n/** A title or a description as the source writes it, one line, neutralized; a longer one is kept to its ceiling. */\nfunction siteImportMetaText(text: string | null | undefined, max: number): string {\n return neutralizeUntrustedText(String(text ?? '')).replace(/\\s+/g, ' ').trim().slice(0, max)\n}\n\n/*------------------------------------------\n * The home page's header and footer (AGL-4083)\n *-----------------------------------------*/\n\n/**\n * How the source's header draws its brand: its logo alone (aglyn.com), its\n * logo with its name beside it, or its name alone. `text` is the name as the\n * header prints it, or the site's own name when it prints nothing at all.\n */\nexport interface SiteImportHeaderBrand {\n kind: 'logo-only' | 'logo-and-name' | 'name-only'\n logo: SiteImportLogoCandidate | null\n /** Whether the header prints the name as words. */\n name: boolean\n text: string\n}\n\n/** The site's own name: its head's, its structured data's, else its home page's title before a separator. */\nexport function siteImportSiteName(home: Pick<SiteImportPage, 'siteName' | 'organization' | 'title'>): string {\n return siteImportLabel(home.siteName || home.organization?.name || (home.title ?? '').split(TITLE_SEPARATOR).pop() || '')\n}\n\n/** Words short enough to be a name, not a sentence. */\nconst looksLikeName = (text: string) => text.length >= 2 && text.length <= AI_SITE_IMPORT_LABEL_MAX_CHARS && text.split(/\\s+/).length <= 8\n\n/**\n * The home page's header brand (AGL-4083), as the source shows it: the link\n * home in its header, the picture inside it, and whether words sit beside\n * the picture, inside the link or next to it. A header with no picture link\n * home is the name alone.\n */\nexport function siteImportHeaderBrand(\n home: Pick<SiteImportPage, 'brand' | 'images' | 'icons' | 'siteName' | 'organization' | 'title' | 'blocks'>,\n): SiteImportHeaderBrand {\n const logo = siteImportLogoCandidates(home).find((candidate) => candidate.source === 'header') ?? null\n const siteName = siteImportSiteName(home)\n const linked = siteImportLabel(home.brand?.text ?? '')\n const beside = home.blocks.find(\n (block) =>\n block.region === 'header' &&\n (block.kind === 'paragraph' || block.kind === 'heading' || block.kind === 'link') &&\n !!siteName &&\n block.text.trim().toLowerCase() === siteName.toLowerCase(),\n )\n const printed = looksLikeName(linked) ? linked : beside && beside.kind !== 'image' ? siteImportLabel(beside.text) : ''\n if (logo && printed) return { kind: 'logo-and-name', logo, name: true, text: printed }\n if (logo) return { kind: 'logo-only', logo, name: false, text: '' }\n return { kind: 'name-only', logo: null, name: true, text: printed || siteName }\n}\n\n/** The facts a site's header and footer carry, as the source writes them. */\nexport interface SiteImportSiteFacts {\n header: SiteImportBlock[]\n footer: SiteImportBlock[]\n organization: SiteImportOrganization | null\n /** Email addresses, from its structured data and its `mailto:` links. */\n emails: string[]\n /** Phone numbers as written, from its structured data and its `tel:` links. */\n phones: string[]\n /** Its profiles on other sites: its structured data's `sameAs` and its links to them. */\n social: string[]\n}\n\nconst SOCIAL_HOSTS =\n /(?:^|\\.)(?:twitter\\.com|x\\.com|facebook\\.com|instagram\\.com|linkedin\\.com|youtube\\.com|tiktok\\.com|github\\.com|pinterest\\.com|threads\\.net|yelp\\.com|tripadvisor\\.com|nextdoor\\.com|vimeo\\.com|bsky\\.app|mastodon\\.social)$/i\n\n/**\n * The home page's own facts (AGL-4083), word for word: its header and footer\n * blocks, its Organization structured data, and the email addresses, phone\n * numbers and profiles they hold. Nothing here is invented or reworded; a\n * fact the page does not state is not here.\n */\nexport function siteImportSiteFacts(home: Pick<SiteImportPage, 'blocks' | 'organization'>): SiteImportSiteFacts {\n const header = home.blocks.filter((block) => block.region === 'header')\n const footer = home.blocks.filter((block) => block.region === 'footer')\n const organization = home.organization ?? null\n const emails: string[] = []\n const phones: string[] = []\n const social: string[] = []\n const add = (list: string[], value: string) => {\n const clean = value.trim()\n if (clean && !list.some((entry) => entry.toLowerCase() === clean.toLowerCase())) list.push(clean)\n }\n if (organization?.email) add(emails, organization.email.toLowerCase())\n if (organization?.telephone) add(phones, organization.telephone)\n for (const url of organization?.sameAs ?? []) add(social, url)\n for (const block of [...header, ...footer]) {\n if (block.kind !== 'link') continue\n if (block.href.startsWith('mailto:')) add(emails, block.href.slice('mailto:'.length))\n else if (block.href.startsWith('tel:')) add(phones, block.text)\n else {\n try {\n if (SOCIAL_HOSTS.test(new URL(block.href).hostname)) add(social, block.href)\n } catch {\n // A link that is not an address is no profile.\n }\n }\n }\n return { header, footer, organization, emails, phones, social }\n}\n\n/** Why the crawler could not read a page, as an import leaves it out; `status` is the answer an `http-error` got. */\nexport function siteImportLeftOutReason(reason: SiteImportSkipReason, status?: number): AiSiteImportLeftOutReason {\n switch (reason) {\n case 'login-form':\n return 'login-form'\n case 'robots':\n return 'robots'\n case 'too-large':\n return 'too-large'\n case 'off-origin-redirect':\n return 'off-site'\n case 'http-error':\n return status !== undefined && AI_SITE_IMPORT_BLOCKED_STATUSES.has(status) ? 'blocked' : 'unreadable'\n case 'not-reached':\n return 'not-reached'\n case 'not-html':\n return 'file'\n default:\n return 'unreadable'\n }\n}\n"],"names":["neutralizeUntrustedText","AI_SITE_IMPORT_BLOCKED_STATUSES","AI_SITE_IMPORT_IMAGES_PER_PAGE","AI_SITE_IMPORT_LABEL_MAX_CHARS","AI_SITE_IMPORT_MAX_SECTIONS","AI_SITE_IMPORT_PAGE_TEXT_MAX_CHARS","AI_SITE_IMPORT_READ_MAX_CHARS","aiSiteImportCapBlocks","AI_SITE_IMPORT_LAYOUT_MAX_CHARS","siteImportLayoutChars","siteImportLayoutWithin","siteImportLayoutWithoutDrawings","siteImportLogoCandidates","siteImportLabel","text","max","line","replace","trim","length","slice","trimEnd","wordsIn","match","siteImportPageWords","page","blocks","reduce","total","block","kind","inline","TITLE_SEPARATOR","siteImportPageTitle","path","own","title","split","find","siteImportListedPage","url","foundBy","words","images","siteImportPageImages","seen","Set","add","alt","has","push","region","image","siteImportPageSections","headings","main","filter","opening","level","sections","toLowerCase","heading","name","siteImportPageText","lines","description","where","repeat","join","siteImportPageRead","at","capped","layout","cut","forms","kept","videos","meta","siteImportMetaText","SITE_IMPORT_META_TITLE_MAX_CHARS","SITE_IMPORT_META_DESCRIPTION_MAX_CHARS","String","siteImportSiteName","home","siteName","organization","pop","looksLikeName","siteImportHeaderBrand","logo","candidate","source","linked","brand","beside","printed","SOCIAL_HOSTS","siteImportSiteFacts","header","footer","emails","phones","social","list","value","clean","some","entry","email","telephone","sameAs","href","startsWith","test","URL","hostname","siteImportLeftOutReason","reason","status","undefined"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;2CAqB2C,GAE3C,SAASA,uBAAuB,QAAQ,0CAAyC;AACjF,SACEC,+BAA+B,EAC/BC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,2BAA2B,EAC3BC,kCAAkC,EAClCC,6BAA6B,EAC7BC,qBAAqB,EACrBC,+BAA+B,EAC/BC,qBAAqB,EACrBC,sBAAsB,EACtBC,+BAA+B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,OAAO;QACT;YACE,OAAO;IACX;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-import/site-import-page.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 * ONE CRAWLED PAGE, AS AN IMPORT KEEPS IT (AGL-3976).\n *\n * The crawler's page (`SiteImportPage`) holds everything it extracted; an\n * import keeps much less, and keeps it in two shapes:\n *\n * - **Listed**, for the inventory: its address, title, how it was found and\n * how many words and photos it has. No text: an inventory of a whole site\n * rides the job document.\n * - **Read**, for a wave: its text in order, its sections from its headings,\n * and its photos' addresses. The text is kept as the page says it and is\n * fenced as untrusted data only where a prompt shows it; the section names\n * and the title travel outside the fence, so they are neutralized (no\n * fence marker, no hidden character) and cut short. Every block of its\n * main region rides along too (AGL-4083), so a page can be brought in word\n * for word.\n *\n * And from the home page, what the site's header and footer are made of\n * (AGL-4083): its brand as the source draws it (`siteImportHeaderBrand`) and\n * its own facts (`siteImportSiteFacts`), for the header and footer the import\n * builds.\n *=========================================*/\n\nimport { neutralizeUntrustedText } from '@aglyn/shared-util-tools/untrusted-text'\nimport {\n AI_SITE_IMPORT_BLOCKED_STATUSES,\n AI_SITE_IMPORT_IMAGES_PER_PAGE,\n AI_SITE_IMPORT_LABEL_MAX_CHARS,\n AI_SITE_IMPORT_MAX_SECTIONS,\n AI_SITE_IMPORT_PAGE_TEXT_MAX_CHARS,\n AI_SITE_IMPORT_READ_MAX_CHARS,\n aiSiteImportCapBlocks,\n AI_SITE_IMPORT_LAYOUT_MAX_CHARS,\n siteImportLayoutChars,\n siteImportLayoutWithin,\n siteImportLayoutWithoutDrawings,\n type AiSiteImportLeftOutReason,\n type AiSiteImportListedPage,\n type AiSiteImportPageRead,\n} from '../model/ai-site-import'\nimport type { SiteImportPage, SiteImportSkipReason } from './site-import-crawl'\nimport type { SiteImportBlock, SiteImportOrganization } from './site-import-html'\nimport { siteImportLogoCandidates, type SiteImportLogoCandidate } from './site-import-images'\n\n/** A line of untrusted text safe to show outside a fence: neutralized, one line, cut short. */\nexport function siteImportLabel(text: string, max = AI_SITE_IMPORT_LABEL_MAX_CHARS): string {\n const line = neutralizeUntrustedText(text).replace(/\\s+/g, ' ').trim()\n return line.length > max ? `${line.slice(0, max - 1).trimEnd()}…` : line\n}\n\nconst wordsIn = (text: string) => (text.match(/[\\p{L}\\p{N}]+/gu) ?? []).length\n\n/** How many words a page says, its title and headings included; a link inside a sentence is counted once. */\nexport function siteImportPageWords(page: Pick<SiteImportPage, 'title' | 'blocks'>): number {\n return page.blocks.reduce(\n (total, block) => total + (block.kind === 'image' || (block.kind === 'link' && block.inline) ? 0 : wordsIn(block.text)),\n 0,\n )\n}\n\n/** Between a page's own name and its site's in a browser title: \"About | Rosie's Bakery\". */\nconst TITLE_SEPARATOR = /\\s+[|\\u2013\\u2014\\u00b7:-]\\s+/\n\n/**\n * A page's name on the new site: \"Home\" for the home page, else its browser\n * title without the old site's name after a separator (\"About | Rosie's\n * Bakery\" is \"About\"), else its first heading.\n */\nexport function siteImportPageTitle(page: Pick<SiteImportPage, 'path' | 'title' | 'blocks'>): string {\n if ((page.path.replace(/\\/+$/, '') || '/') === '/') return 'Home'\n const own = siteImportLabel((page.title ?? '').split(TITLE_SEPARATOR)[0] ?? '')\n if (own.length >= 2) return own\n return siteImportLabel(page.blocks.find((block) => block.kind === 'heading')?.text ?? '')\n}\n\n/** The page as the inventory lists it. */\nexport function siteImportListedPage(page: SiteImportPage): AiSiteImportListedPage {\n return {\n url: page.url,\n path: page.path,\n title: siteImportPageTitle(page),\n foundBy: page.foundBy,\n words: siteImportPageWords(page),\n images: page.images.length,\n }\n}\n\n/** The page's photos, the ones in its body first, each once. */\nexport function siteImportPageImages(page: Pick<SiteImportPage, 'blocks' | 'images'>): Array<{ url: string; alt: string }> {\n const seen = new Set<string>()\n const images: Array<{ url: string; alt: string }> = []\n const add = (url: string, alt: string) => {\n if (!url || seen.has(url) || images.length >= AI_SITE_IMPORT_IMAGES_PER_PAGE) return\n seen.add(url)\n images.push({ url, alt: siteImportLabel(alt, 250) })\n }\n for (const block of page.blocks) if (block.kind === 'image' && block.region === 'main') add(block.url, block.alt)\n for (const image of page.images) add(image.url, image.alt)\n return images\n}\n\n/**\n * The page's sections, from its headings: the first is its opening (its\n * title or first heading), then one for each second-level heading of its\n * body, at most `AI_SITE_IMPORT_MAX_SECTIONS`. A page with no headings below\n * its title but more to say than an opening gets a second section for it.\n */\nexport function siteImportPageSections(page: Pick<SiteImportPage, 'title' | 'blocks'>): string[] {\n const main = page.blocks.filter((block) => block.region === 'main')\n const headings = main.filter((block): block is Extract<typeof block, { kind: 'heading' }> => block.kind === 'heading')\n const opening = siteImportLabel(headings.find((block) => block.level === 1)?.text || page.title || '') || 'Introduction'\n const sections = [opening]\n const seen = new Set([opening.toLowerCase()])\n for (const heading of headings) {\n if (heading.level !== 2) continue\n const name = siteImportLabel(heading.text)\n if (!name || seen.has(name.toLowerCase())) continue\n seen.add(name.toLowerCase())\n sections.push(name)\n if (sections.length >= AI_SITE_IMPORT_MAX_SECTIONS) break\n }\n if (sections.length === 1 && siteImportPageWords({ title: '', blocks: main }) > 80) sections.push('Details')\n return sections\n}\n\n/** The page's text in order, as a prompt shows it inside its fence. */\nexport function siteImportPageText(page: Pick<SiteImportPage, 'title' | 'description' | 'blocks'>): string {\n const lines: string[] = []\n if (page.title) lines.push(`Title: ${page.title}`)\n if (page.description) lines.push(`Description: ${page.description}`)\n for (const block of page.blocks) {\n const where = block.region === 'main' ? '' : `(${block.region}) `\n if (block.kind === 'heading') lines.push(`${'#'.repeat(block.level)} ${block.text}`)\n else if (block.kind === 'image') lines.push(`${where}[photo: ${block.alt || 'no description'}]`)\n else if (block.kind === 'list-item') lines.push(`${where}- ${block.text}`)\n else if (block.kind === 'quote') lines.push(`${where}> ${block.text}`)\n else if (block.kind === 'link') {\n // A link inside a sentence is in its block's words already.\n if (!block.inline) lines.push(`${where}${block.text}`)\n } else lines.push(`${where}${block.text}`)\n }\n const text = lines.join('\\n')\n return text.length > AI_SITE_IMPORT_PAGE_TEXT_MAX_CHARS ? text.slice(0, AI_SITE_IMPORT_PAGE_TEXT_MAX_CHARS) : text\n}\n\n/**\n * The page as a wave reads it: its main region's blocks whole, within the\n * read's budget, and how the source lays them out (AGL-4106) over the blocks\n * kept, its icons' drawings dropped first when it runs past its own budget.\n */\nexport function siteImportPageRead(page: SiteImportPage, at: string): AiSiteImportPageRead {\n const main = page.blocks.filter((block) => block.region === 'main')\n const capped = aiSiteImportCapBlocks(main, AI_SITE_IMPORT_READ_MAX_CHARS)\n let layout = page.layout ? siteImportLayoutWithin(page.layout, capped.blocks.length) : null\n if (layout && siteImportLayoutChars(layout) > AI_SITE_IMPORT_LAYOUT_MAX_CHARS) layout = siteImportLayoutWithoutDrawings(layout)\n if (layout && siteImportLayoutChars(layout) > AI_SITE_IMPORT_LAYOUT_MAX_CHARS) layout = null\n return {\n at,\n title: siteImportPageTitle(page),\n text: siteImportPageText(page),\n sections: siteImportPageSections(page),\n images: siteImportPageImages(page),\n blocks: capped.blocks,\n ...(capped.cut ? { cut: true } : {}),\n words: siteImportPageWords({ title: '', blocks: main }),\n forms: page.forms.kept,\n ...(layout ? { layout } : {}),\n // Its videos (AGL-4140), which its layout places by index.\n ...(page.videos?.length ? { videos: page.videos } : {}),\n // The source's own title and description, for the page's listing (AGL-4107).\n meta: { title: siteImportMetaText(page.title, SITE_IMPORT_META_TITLE_MAX_CHARS), description: siteImportMetaText(page.description, SITE_IMPORT_META_DESCRIPTION_MAX_CHARS) },\n }\n}\n\n/** The most characters of a source's title and description a read keeps: far past what any listing shows. */\nexport const SITE_IMPORT_META_TITLE_MAX_CHARS = 300\nexport const SITE_IMPORT_META_DESCRIPTION_MAX_CHARS = 1_000\n\n/** A title or a description as the source writes it, one line, neutralized; a longer one is kept to its ceiling. */\nfunction siteImportMetaText(text: string | null | undefined, max: number): string {\n return neutralizeUntrustedText(String(text ?? '')).replace(/\\s+/g, ' ').trim().slice(0, max)\n}\n\n/*------------------------------------------\n * The home page's header and footer (AGL-4083)\n *-----------------------------------------*/\n\n/**\n * How the source's header draws its brand: its logo alone (aglyn.com), its\n * logo with its name beside it, or its name alone. `text` is the name as the\n * header prints it, or the site's own name when it prints nothing at all.\n */\nexport interface SiteImportHeaderBrand {\n kind: 'logo-only' | 'logo-and-name' | 'name-only'\n logo: SiteImportLogoCandidate | null\n /** Whether the header prints the name as words. */\n name: boolean\n text: string\n}\n\n/** The site's own name: its head's, its structured data's, else its home page's title before a separator. */\nexport function siteImportSiteName(home: Pick<SiteImportPage, 'siteName' | 'organization' | 'title'>): string {\n return siteImportLabel(home.siteName || home.organization?.name || (home.title ?? '').split(TITLE_SEPARATOR).pop() || '')\n}\n\n/** Words short enough to be a name, not a sentence. */\nconst looksLikeName = (text: string) => text.length >= 2 && text.length <= AI_SITE_IMPORT_LABEL_MAX_CHARS && text.split(/\\s+/).length <= 8\n\n/**\n * The home page's header brand (AGL-4083), as the source shows it: the link\n * home in its header, the picture inside it, and whether words sit beside\n * the picture, inside the link or next to it. A header with no picture link\n * home is the name alone.\n */\nexport function siteImportHeaderBrand(\n home: Pick<SiteImportPage, 'brand' | 'images' | 'icons' | 'siteName' | 'organization' | 'title' | 'blocks'>,\n): SiteImportHeaderBrand {\n const logo = siteImportLogoCandidates(home).find((candidate) => candidate.source === 'header') ?? null\n const siteName = siteImportSiteName(home)\n const linked = siteImportLabel(home.brand?.text ?? '')\n const beside = home.blocks.find(\n (block) =>\n block.region === 'header' &&\n (block.kind === 'paragraph' || block.kind === 'heading' || block.kind === 'link') &&\n !!siteName &&\n block.text.trim().toLowerCase() === siteName.toLowerCase(),\n )\n const printed = looksLikeName(linked) ? linked : beside && beside.kind !== 'image' ? siteImportLabel(beside.text) : ''\n if (logo && printed) return { kind: 'logo-and-name', logo, name: true, text: printed }\n if (logo) return { kind: 'logo-only', logo, name: false, text: '' }\n return { kind: 'name-only', logo: null, name: true, text: printed || siteName }\n}\n\n/** The facts a site's header and footer carry, as the source writes them. */\nexport interface SiteImportSiteFacts {\n header: SiteImportBlock[]\n footer: SiteImportBlock[]\n organization: SiteImportOrganization | null\n /** Email addresses, from its structured data and its `mailto:` links. */\n emails: string[]\n /** Phone numbers as written, from its structured data and its `tel:` links. */\n phones: string[]\n /** Its profiles on other sites: its structured data's `sameAs` and its links to them. */\n social: string[]\n}\n\nconst SOCIAL_HOSTS =\n /(?:^|\\.)(?:twitter\\.com|x\\.com|facebook\\.com|instagram\\.com|linkedin\\.com|youtube\\.com|tiktok\\.com|github\\.com|pinterest\\.com|threads\\.net|yelp\\.com|tripadvisor\\.com|nextdoor\\.com|vimeo\\.com|bsky\\.app|mastodon\\.social)$/i\n\n/**\n * The home page's own facts (AGL-4083), word for word: its header and footer\n * blocks, its Organization structured data, and the email addresses, phone\n * numbers and profiles they hold. Nothing here is invented or reworded; a\n * fact the page does not state is not here.\n */\nexport function siteImportSiteFacts(home: Pick<SiteImportPage, 'blocks' | 'organization'>): SiteImportSiteFacts {\n const header = home.blocks.filter((block) => block.region === 'header')\n const footer = home.blocks.filter((block) => block.region === 'footer')\n const organization = home.organization ?? null\n const emails: string[] = []\n const phones: string[] = []\n const social: string[] = []\n const add = (list: string[], value: string) => {\n const clean = value.trim()\n if (clean && !list.some((entry) => entry.toLowerCase() === clean.toLowerCase())) list.push(clean)\n }\n if (organization?.email) add(emails, organization.email.toLowerCase())\n if (organization?.telephone) add(phones, organization.telephone)\n for (const url of organization?.sameAs ?? []) add(social, url)\n for (const block of [...header, ...footer]) {\n if (block.kind !== 'link') continue\n if (block.href.startsWith('mailto:')) add(emails, block.href.slice('mailto:'.length))\n else if (block.href.startsWith('tel:')) add(phones, block.text)\n else {\n try {\n if (SOCIAL_HOSTS.test(new URL(block.href).hostname)) add(social, block.href)\n } catch {\n // A link that is not an address is no profile.\n }\n }\n }\n return { header, footer, organization, emails, phones, social }\n}\n\n/** Why the crawler could not read a page, as an import leaves it out; `status` is the answer an `http-error` got. */\nexport function siteImportLeftOutReason(reason: SiteImportSkipReason, status?: number): AiSiteImportLeftOutReason {\n switch (reason) {\n case 'login-form':\n return 'login-form'\n case 'robots':\n return 'robots'\n case 'too-large':\n return 'too-large'\n case 'off-origin-redirect':\n return 'off-site'\n case 'http-error':\n if (status === 404 || status === 410) return 'missing'\n return status !== undefined && AI_SITE_IMPORT_BLOCKED_STATUSES.has(status) ? 'blocked' : 'unreadable'\n case 'not-reached':\n return 'not-reached'\n case 'duplicate':\n return 'duplicate'\n case 'system-page':\n return 'system-page'\n case 'not-html':\n return 'file'\n default:\n return 'unreadable'\n }\n}\n"],"names":["neutralizeUntrustedText","AI_SITE_IMPORT_BLOCKED_STATUSES","AI_SITE_IMPORT_IMAGES_PER_PAGE","AI_SITE_IMPORT_LABEL_MAX_CHARS","AI_SITE_IMPORT_MAX_SECTIONS","AI_SITE_IMPORT_PAGE_TEXT_MAX_CHARS","AI_SITE_IMPORT_READ_MAX_CHARS","aiSiteImportCapBlocks","AI_SITE_IMPORT_LAYOUT_MAX_CHARS","siteImportLayoutChars","siteImportLayoutWithin","siteImportLayoutWithoutDrawings","siteImportLogoCandidates","siteImportLabel","text","max","line","replace","trim","length","slice","trimEnd","wordsIn","match","siteImportPageWords","page","blocks","reduce","total","block","kind","inline","TITLE_SEPARATOR","siteImportPageTitle","path","own","title","split","find","siteImportListedPage","url","foundBy","words","images","siteImportPageImages","seen","Set","add","alt","has","push","region","image","siteImportPageSections","headings","main","filter","opening","level","sections","toLowerCase","heading","name","siteImportPageText","lines","description","where","repeat","join","siteImportPageRead","at","capped","layout","cut","forms","kept","videos","meta","siteImportMetaText","SITE_IMPORT_META_TITLE_MAX_CHARS","SITE_IMPORT_META_DESCRIPTION_MAX_CHARS","String","siteImportSiteName","home","siteName","organization","pop","looksLikeName","siteImportHeaderBrand","logo","candidate","source","linked","brand","beside","printed","SOCIAL_HOSTS","siteImportSiteFacts","header","footer","emails","phones","social","list","value","clean","some","entry","email","telephone","sameAs","href","startsWith","test","URL","hostname","siteImportLeftOutReason","reason","status","undefined"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;2CAqB2C,GAE3C,SAASA,uBAAuB,QAAQ,0CAAyC;AACjF,SACEC,+BAA+B,EAC/BC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,2BAA2B,EAC3BC,kCAAkC,EAClCC,6BAA6B,EAC7BC,qBAAqB,EACrBC,+BAA+B,EAC/BC,qBAAqB,EACrBC,sBAAsB,EACtBC,+BAA+B,QAI1B,6BAAyB;AAGhC,SAASC,wBAAwB,QAAsC,0BAAsB;AAE7F,6FAA6F,GAC7F,OAAO,SAASC,gBAAgBC,IAAY,EAAEC,MAAMZ,8BAA8B;IAChF,MAAMa,OAAOhB,wBAAwBc,MAAMG,OAAO,CAAC,QAAQ,KAAKC,IAAI;IACpE,OAAOF,KAAKG,MAAM,GAAGJ,MAAM,GAAGC,KAAKI,KAAK,CAAC,GAAGL,MAAM,GAAGM,OAAO,GAAG,CAAC,CAAC,GAAGL;AACtE;AAEA,MAAMM,UAAU,CAACR;QAAkBA;WAAD,EAACA,cAAAA,KAAKS,KAAK,CAAC,ynaAAXT,cAAiC,EAAE,EAAEK,MAAM;;AAE9E,2GAA2G,GAC3G,OAAO,SAASK,oBAAoBC,IAA8C;IAChF,OAAOA,KAAKC,MAAM,CAACC,MAAM,CACvB,CAACC,OAAOC,QAAUD,QAASC,CAAAA,MAAMC,IAAI,KAAK,WAAYD,MAAMC,IAAI,KAAK,UAAUD,MAAME,MAAM,GAAI,IAAIT,QA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F,IAAI,CAACC,UAAU,CAAC,SAASjE,IAAIsD,QAAQxE,MAAMf,IAAI;aACzD;YACH,IAAI;gBACF,IAAIkF,aAAaiB,IAAI,CAAC,IAAIC,IAAIrF,MAAMkF,IAAI,EAAEI,QAAQ,GAAGpE,IAAIuD,QAAQzE,MAAMkF,IAAI;YAC7E,EAAE,eAAM;YACN,+CAA+C;YACjD;QACF;IACF;IACA,OAAO;QAAEb;QAAQC;QAAQd;QAAce;QAAQC;QAAQC;IAAO;AAChE;AAEA,mHAAmH,GACnH,OAAO,SAASc,wBAAwBC,MAA4B,EAAEC,MAAe;IACnF,OAAQD;QACN,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,IAAIC,WAAW,OAAOA,WAAW,KAAK,OAAO;YAC7C,OAAOA,WAAWC,aAAatH,gCAAgCgD,GAAG,CAACqE,UAAU,YAAY;QAC3F,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT;YACE,OAAO;IACX;AACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { SiteImportBlock, SiteImportExtract } from './site-import-html';
|
|
18
|
+
/** An address with its origin and trailing slash set aside: the site's two names are one site. */
|
|
19
|
+
export declare function siteImportAddressOf(key: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* A page's main content as one string, to compare with another's: its words
|
|
22
|
+
* and photos in order, its forms and its videos. `null` for a page with too
|
|
23
|
+
* little on it to call the same as anything.
|
|
24
|
+
*/
|
|
25
|
+
export declare function siteImportContentSignature(page: Pick<SiteImportExtract, 'blocks' | 'forms' | 'videos'>): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* The address a page's canonical names, when that is another page address of
|
|
28
|
+
* this site; `null` when it names the page itself, another site or a file.
|
|
29
|
+
*/
|
|
30
|
+
export declare function siteImportCanonicalClaim(canonical: string | null, pageKey: string, keyOf: (url: URL) => string | null): string | null;
|
|
31
|
+
/** Whether a canonical is believed on its own: it keeps the path, where a query does not choose the page. */
|
|
32
|
+
export declare function siteImportCanonicalBelieved(pageKey: string, claim: string): boolean;
|
|
33
|
+
/** More words than a screen with nothing in it says; a real page says more. */
|
|
34
|
+
export declare const SITE_IMPORT_SYSTEM_SCREEN_MAX_WORDS = 25;
|
|
35
|
+
/** Whether the path is one a website platform keeps for its cart, checkout, account or search screens. */
|
|
36
|
+
export declare function siteImportSystemScreenPath(pathname: string): boolean;
|
|
37
|
+
/** Whether a page is its platform's screen rather than a page of the owner's site. */
|
|
38
|
+
export declare function siteImportIsSystemScreen(pathname: string, page: {
|
|
39
|
+
blocks: readonly SiteImportBlock[];
|
|
40
|
+
noindex: boolean;
|
|
41
|
+
}): boolean;
|