@aglyn/plugins-ai 1.10.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/package.json +17 -17
  2. package/src/lib/jobs/ai-job-import-step.d.ts +1 -1
  3. package/src/lib/jobs/ai-job-import-step.js +26 -7
  4. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  5. package/src/lib/jobs/ai-job-privacy-step.js +2 -2
  6. package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
  7. package/src/lib/jobs/ai-site-import-compile.js +27 -37
  8. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  9. package/src/lib/jobs/ai-site-import-look.js +20 -1
  10. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  11. package/src/lib/layout-language/ai-layout-compiler.js +7 -1
  12. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  13. package/src/lib/model/ai-credit-estimate.d.ts +15 -0
  14. package/src/lib/model/ai-credit-estimate.js +13 -0
  15. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  16. package/src/lib/model/ai-site-import-fidelity.d.ts +46 -3
  17. package/src/lib/model/ai-site-import-fidelity.js +254 -62
  18. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  19. package/src/lib/model/ai-site-import-report.d.ts +7 -0
  20. package/src/lib/model/ai-site-import-report.js +17 -5
  21. package/src/lib/model/ai-site-import-report.js.map +1 -1
  22. package/src/lib/model/ai-site-import.d.ts +46 -3
  23. package/src/lib/model/ai-site-import.js +34 -11
  24. package/src/lib/model/ai-site-import.js.map +1 -1
  25. package/src/lib/model/ai-site-look.d.ts +16 -0
  26. package/src/lib/model/ai-site-look.js +76 -14
  27. package/src/lib/model/ai-site-look.js.map +1 -1
  28. package/src/lib/site-import/fixtures/aglyn-com-recordings.d.ts +2 -1
  29. package/src/lib/site-import/fixtures/aglyn-com-recordings.js +3 -2
  30. package/src/lib/site-import/fixtures/aglyn-com-recordings.js.map +1 -1
  31. package/src/lib/site-import/fixtures/site-import-crawl-recordings.d.ts +5 -0
  32. package/src/lib/site-import/fixtures/site-import-crawl-recordings.js +116 -3
  33. package/src/lib/site-import/fixtures/site-import-crawl-recordings.js.map +1 -1
  34. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +7 -0
  35. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +15 -0
  36. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  37. package/src/lib/site-import/fixtures/site-layout-recordings.js +4 -3
  38. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  39. package/src/lib/site-import/fixtures/site-look-slate.d.ts +2 -1
  40. package/src/lib/site-import/fixtures/site-look-slate.js +2 -1
  41. package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -1
  42. package/src/lib/site-import/site-import-crawl.d.ts +7 -1
  43. package/src/lib/site-import/site-import-crawl.js +101 -6
  44. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  45. package/src/lib/site-import/site-import-css.d.ts +8 -1
  46. package/src/lib/site-import/site-import-css.js +30 -8
  47. package/src/lib/site-import/site-import-css.js.map +1 -1
  48. package/src/lib/site-import/site-import-html.d.ts +2 -0
  49. package/src/lib/site-import/site-import-html.js +3 -0
  50. package/src/lib/site-import/site-import-html.js.map +1 -1
  51. package/src/lib/site-import/site-import-layout.d.ts +9 -2
  52. package/src/lib/site-import/site-import-layout.js +104 -30
  53. package/src/lib/site-import/site-import-layout.js.map +1 -1
  54. package/src/lib/site-import/site-import-page.js +5 -0
  55. package/src/lib/site-import/site-import-page.js.map +1 -1
  56. package/src/lib/site-import/site-import-same-page.d.ts +41 -0
  57. package/src/lib/site-import/site-import-same-page.js +108 -0
  58. package/src/lib/site-import/site-import-same-page.js.map +1 -0
@@ -212,7 +212,7 @@ const SIMPLE = new RegExp(String.raw`^(?:(\*|${IDENT})|#(${IDENT})|\.(${IDENT})|
212
212
  const amount = Number(match[1]);
213
213
  return match[2] && match[2].toLowerCase() !== 'px' ? amount * 16 : amount;
214
214
  }
215
- /** Whether one media query holds for a light-mode screen of this width. */ function mediaQueryHolds(query, viewport) {
215
+ /** Whether one media query holds for a screen of this width in this color scheme. */ function mediaQueryHolds(query, viewport, scheme) {
216
216
  let text = query.trim().toLowerCase();
217
217
  let negate = false;
218
218
  if (text.startsWith('not ')) {
@@ -239,7 +239,7 @@ const SIMPLE = new RegExp(String.raw`^(?:(\*|${IDENT})|#(${IDENT})|\.(${IDENT})|
239
239
  else if (name === 'max-width') holds && (holds = px !== null && width <= px);
240
240
  else if (name === 'min-height') holds && (holds = px !== null && height >= px);
241
241
  else if (name === 'max-height') holds && (holds = px !== null && height <= px);
242
- else if (name === 'prefers-color-scheme') holds && (holds = value.trim() === 'light');
242
+ else if (name === 'prefers-color-scheme') holds && (holds = value.trim() === scheme);
243
243
  else if (name === 'prefers-reduced-motion') holds && (holds = value.trim() === 'no-preference');
244
244
  else if (name === 'orientation') holds && (holds = value.trim() === 'landscape');
245
245
  else if (name === 'hover' || name === 'any-hover') holds && (holds = value.trim() === 'hover');
@@ -264,9 +264,20 @@ const SIMPLE = new RegExp(String.raw`^(?:(\*|${IDENT})|#(${IDENT})|\.(${IDENT})|
264
264
  }
265
265
  return negate ? !holds : holds;
266
266
  }
267
- function mediaHolds(prelude, viewport) {
267
+ function mediaHolds(prelude, viewport, scheme) {
268
268
  const list = splitList(prelude.replace(/^@media\s*/i, ''));
269
- return !list.length || list.some((query)=>mediaQueryHolds(query, viewport));
269
+ return !list.length || list.some((query)=>mediaQueryHolds(query, viewport, scheme));
270
+ }
271
+ /**
272
+ * A selector's leading mark of the dark scheme (AGL-4152): `.dark`, `.dark-mode`
273
+ * or a `data-theme` that says dark, on the page's root or body. Nothing a read
274
+ * sees carries it, so a dark read lifts it off and the rest applies as written.
275
+ */ const DARK_SCOPE = /^(?:(html|body|:root))?(?:\.dark(?:-mode|-theme)?|\[\s*data-(?:theme|mode|color-scheme|color-mode|bs-theme|mui-color-scheme)\s*[*~|^]?=\s*["']?[^"'\]]*dark[^"'\]]*["']?\s*(?:i\s*)?\])(?=$|[\s>+~.:#[])/i;
276
+ /** What a selector asks of a page in its dark scheme, its mark lifted off: what remains, else the element that held the mark. `null` for a selector with no such mark. */ function withoutDarkScope(text) {
277
+ const match = DARK_SCOPE.exec(text.trim());
278
+ if (!match) return null;
279
+ const rest = text.trim().slice(match[0].length).replace(/^[\s>+~]+/, '');
280
+ return rest || match[1] || ':root';
270
281
  }
271
282
  function declarationsOf(body) {
272
283
  const decls = [];
@@ -300,19 +311,27 @@ function declarationsOf(body) {
300
311
  /**
301
312
  * The page's sheets parsed for a wide screen. Malformed CSS is read as far as
302
313
  * it makes sense, as a browser would; nothing throws.
303
- */ export function siteImportCssOf(sheets, viewport = SITE_IMPORT_CSS_VIEWPORT.width) {
314
+ */ export function siteImportCssOf(sheets, viewport = SITE_IMPORT_CSS_VIEWPORT.width, options = {}) {
315
+ var _options_scheme;
304
316
  const css = {
305
317
  rules: [],
306
318
  index: new Map(),
307
- fontFaces: []
319
+ fontFaces: [],
320
+ darkRules: 0
308
321
  };
322
+ const scheme = (_options_scheme = options.scheme) != null ? _options_scheme : 'light';
309
323
  let order = 0;
324
+ /** For each open group: whether only a dark scheme's media query opens it. */ const darkGroups = [];
310
325
  const addRule = (prelude, body)=>{
311
326
  const decls = declarationsOf(body);
312
327
  if (!decls.length) return;
313
328
  for (const text of splitList(prelude)){
314
- const selector = parseSelector(text);
329
+ const lifted = scheme === 'dark' ? withoutDarkScope(text) : null;
330
+ const selector = parseSelector(lifted != null ? lifted : text);
315
331
  if (!selector) continue;
332
+ if (scheme === 'dark' && (lifted !== null || darkGroups.includes(true))) css.darkRules += 1;
333
+ // The mark it lost still counts: a dark rule outranks the same rule of the light scheme.
334
+ if (lifted !== null) selector.specificity += 1000;
316
335
  const rule = {
317
336
  selector,
318
337
  order: order++,
@@ -347,6 +366,7 @@ function declarationsOf(body) {
347
366
  }
348
367
  if (char === '}') {
349
368
  groups.pop();
369
+ darkGroups.pop();
350
370
  start = at + 1;
351
371
  at += 1;
352
372
  continue;
@@ -358,12 +378,14 @@ function declarationsOf(body) {
358
378
  const prelude = text.slice(start, at).trim();
359
379
  const applies = groups.every(Boolean);
360
380
  if (/^@(?:media)\b/i.test(prelude)) {
361
- groups.push(applies && mediaHolds(prelude, viewport));
381
+ groups.push(applies && mediaHolds(prelude, viewport, scheme));
382
+ darkGroups.push(/prefers-color-scheme\s*:\s*dark/i.test(prelude));
362
383
  start = at = at + 1;
363
384
  continue;
364
385
  }
365
386
  if (/^@(?:supports|layer|container|document|scope|starting-style)\b/i.test(prelude)) {
366
387
  groups.push(applies && !/^@starting-style/i.test(prelude));
388
+ darkGroups.push(false);
367
389
  start = at = at + 1;
368
390
  continue;
369
391
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-import/site-import-css.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 * HOW A PAGE IS STYLED, AS A WIDE SCREEN SHOWS IT (AGL-4106).\n *\n * Bring my site reads a page's layout, not only its lines, and most of a\n * layout lives in the stylesheet: which band is grey and which is dark, which\n * container lays its children out in three columns, which link is drawn as a\n * filled button. This is a small cascade, enough for that and no more:\n *\n * - **The sheets.** The page's own `<style>` sheets and the ones it links,\n * read in order. `@media` rules apply as a 1280-pixel screen in light mode\n * sees them, so a grid's desktop columns win over its phone ones;\n * `@layer`, `@supports` and `@container` are read through; keyframes, font\n * faces (their families noted) and page rules are skipped.\n * - **Selectors.** Tags, classes (escaped ones too, as utility frameworks\n * write them), ids and attributes, joined by any combinator. A rule that\n * only applies on hover, focus or to a generated part (`::before`) is a\n * state the page is not in and is not read.\n * - **The cascade.** Specificity, then order, `!important` over both, and the\n * element's own `style` over every rule; color, font and alignment inherit,\n * and so do custom properties, which `var()` reads.\n *\n * Only the properties the layout reader asks about are kept. Nothing here\n * runs anything a page wrote: values are text compared to text.\n *=========================================*/\n\nimport type { SiteImportElement, SiteImportStructure } from './site-import-html'\n\n/** The width a page is read at: a laptop's, where a desktop layout shows. */\nexport const SITE_IMPORT_CSS_VIEWPORT = { width: 1280, height: 800 } as const\n\n/**\n * The width a page's column is read at (AGL-4083). A container caps itself\n * only on screens wider than its cap (`@media (min-width:1536px)` around a\n * `max-width:1536px`), so on a laptop it runs the whole page: read there, it\n * would look as if it had no cap at all.\n */\nexport const SITE_IMPORT_CSS_WIDE_WIDTH = 1920\n\n/** The properties the layout reader reads; every other declaration is dropped as the sheet is parsed. */\nconst KEPT_PROPERTIES = new Set([\n 'background',\n 'background-color',\n 'background-image',\n 'color',\n 'border',\n 'border-width',\n 'border-style',\n 'border-color',\n 'border-top',\n 'border-right',\n 'border-bottom',\n 'border-left',\n 'border-top-width',\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-style',\n 'border-bottom-style',\n 'border-top-color',\n 'border-bottom-color',\n 'border-radius',\n 'box-shadow',\n 'display',\n 'grid-template-columns',\n 'grid-column',\n 'flex',\n 'flex-direction',\n 'flex-wrap',\n 'flex-grow',\n 'flex-basis',\n 'width',\n 'max-width',\n // The shape a picture is framed at (AGL-4138): a box's own, or a height it is cropped to.\n 'aspect-ratio',\n 'height',\n 'font-family',\n 'font-size',\n 'font-weight',\n 'text-transform',\n 'letter-spacing',\n 'text-align',\n 'position',\n 'visibility',\n 'padding',\n 'padding-top',\n 'padding-bottom',\n 'padding-left',\n 'padding-right',\n 'object-fit',\n 'justify-content',\n 'align-items',\n])\n\n/** What an element takes from its parent when it says nothing itself. */\nconst INHERITED = new Set(['color', 'font-family', 'font-size', 'font-weight', 'text-transform', 'letter-spacing', 'text-align', 'visibility'])\n\ninterface Compound {\n tag: string | null\n id: string | null\n classes: string[]\n attrs: Array<{ name: string; op: string | null; value: string }>\n /** `:root`: only the document's root element. */\n root: boolean\n}\n\ninterface ComplexSelector {\n /** Rightmost last. */\n compounds: Compound[]\n /** `combinators[i]` joins `compounds[i]` and `compounds[i + 1]`: a space, a child, an adjacent or a sibling combinator. */\n combinators: string[]\n specificity: number\n}\n\ninterface CssRule {\n selector: ComplexSelector\n order: number\n decls: Array<[property: string, value: string, important: boolean]>\n}\n\n/** The page's sheets, parsed for one width. */\nexport interface SiteImportCss {\n rules: CssRule[]\n /** Rules by their rightmost compound's id (`#x`), first class (`.x`), tag, or `*`. */\n index: Map<string, CssRule[]>\n /** Families its `@font-face` rules name, in order. */\n fontFaces: string[]\n}\n\n/*------------------------------------------\n * Parsing\n *-----------------------------------------*/\n\nfunction unescapeIdent(text: string): string {\n return text.replace(/\\\\([0-9a-fA-F]{1,6}\\s?|.)/g, (_, escaped: string) => {\n if (/^[0-9a-fA-F]{1,6}\\s?$/.test(escaped)) {\n const code = parseInt(escaped.trim(), 16)\n return code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : ''\n }\n return escaped\n })\n}\n\nconst IDENT = String.raw`(?:\\\\[0-9a-fA-F]{1,6}\\s?|\\\\.|[\\w-]|[^\\x00-\\x7f])+`\nconst SIMPLE = new RegExp(\n String.raw`^(?:(\\*|${IDENT})|#(${IDENT})|\\.(${IDENT})|\\[\\s*([\\w-]+)\\s*(?:([~|^$*]?=)\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\]\\s]+))\\s*(?:[is]\\s*)?)?\\]|(::?)(${IDENT})(\\((?:[^()]|\\([^()]*\\))*\\))?)`,\n)\n\n/** The pseudo-classes a page at rest matches as if they were not there. */\nconst AT_REST = new Set(['link', 'any-link'])\n\n/** One compound selector, or `null` when it depends on a state or a generated part. */\nfunction parseCompound(text: string): Compound | null {\n const compound: Compound = { tag: null, id: null, classes: [], attrs: [], root: false }\n let rest = text\n while (rest) {\n const match = SIMPLE.exec(rest)\n if (!match || !match[0]) return null\n rest = rest.slice(match[0].length)\n if (match[1]) compound.tag = match[1] === '*' ? null : unescapeIdent(match[1]).toLowerCase()\n else if (match[2]) compound.id = unescapeIdent(match[2])\n else if (match[3]) compound.classes.push(unescapeIdent(match[3]))\n else if (match[4]) compound.attrs.push({ name: match[4].toLowerCase(), op: match[5] ?? null, value: match[6] ?? match[7] ?? match[8] ?? '' })\n else if (match[9]) {\n const name = unescapeIdent(match[10] ?? '').toLowerCase()\n if (match[9] === '::') return null\n if (name === 'root') compound.root = true\n else if (!AT_REST.has(name)) return null\n }\n }\n return compound\n}\n\n/** A complex selector, or `null` when any part of it cannot be read at rest. */\nfunction parseSelector(text: string): ComplexSelector | null {\n const compounds: Compound[] = []\n const combinators: string[] = []\n const parts = text.trim().replace(/\\s*([>+~])\\s*/g, ' $1 ').split(/\\s+/)\n let pending: string | null = null\n for (const part of parts) {\n if (!part) continue\n if (part === '>' || part === '+' || part === '~') {\n pending = part\n continue\n }\n const compound = parseCompound(part)\n if (!compound) return null\n if (compounds.length) combinators.push(pending ?? ' ')\n pending = null\n compounds.push(compound)\n }\n if (!compounds.length || pending) return null\n let ids = 0\n let classes = 0\n let tags = 0\n for (const compound of compounds) {\n if (compound.id) ids += 1\n classes += compound.classes.length + compound.attrs.length + (compound.root ? 1 : 0)\n if (compound.tag) tags += 1\n }\n return { compounds, combinators, specificity: ids * 1_000_000 + classes * 1_000 + tags }\n}\n\n/** Splits at top-level commas: none inside brackets or parentheses. */\nfunction splitList(text: string): string[] {\n const out: string[] = []\n let depth = 0\n let start = 0\n for (let at = 0; at < text.length; at += 1) {\n const char = text[at]\n if (char === '(' || char === '[') depth += 1\n else if (char === ')' || char === ']') depth = Math.max(0, depth - 1)\n else if (char === ',' && depth === 0) {\n out.push(text.slice(start, at))\n start = at + 1\n }\n }\n out.push(text.slice(start))\n return out.map((part) => part.trim()).filter(Boolean)\n}\n\n/** A length in px at the read width; `em`/`rem` at 16. */\nexport function siteImportLengthPx(value: string): number | null {\n const match = /^(-?\\d*\\.?\\d+)\\s*(px|em|rem)?$/i.exec(value.trim())\n if (!match) return null\n const amount = Number(match[1])\n return match[2] && match[2].toLowerCase() !== 'px' ? amount * 16 : amount\n}\n\n/** Whether one media query holds for a light-mode screen of this width. */\nfunction mediaQueryHolds(query: string, viewport: number): boolean {\n let text = query.trim().toLowerCase()\n let negate = false\n if (text.startsWith('not ')) {\n negate = true\n text = text.slice(4)\n }\n text = text.replace(/^only\\s+/, '')\n let holds = true\n for (const part of text.split(/\\s+and\\s+/)) {\n const term = part.trim()\n if (!term) continue\n if (!term.startsWith('(')) {\n if (!/^(?:all|screen)$/.test(term)) holds = false\n continue\n }\n const inner = term.replace(/^\\(|\\)$/g, '').trim()\n const feature = /^([\\w-]+)\\s*:\\s*(.+)$/.exec(inner)\n const { height } = SITE_IMPORT_CSS_VIEWPORT\n const width = viewport\n if (feature) {\n const [, name, value] = feature\n const px = siteImportLengthPx(value)\n if (name === 'min-width') holds &&= px !== null && width >= px\n else if (name === 'max-width') holds &&= px !== null && width <= px\n else if (name === 'min-height') holds &&= px !== null && height >= px\n else if (name === 'max-height') holds &&= px !== null && height <= px\n else if (name === 'prefers-color-scheme') holds &&= value.trim() === 'light'\n else if (name === 'prefers-reduced-motion') holds &&= value.trim() === 'no-preference'\n else if (name === 'orientation') holds &&= value.trim() === 'landscape'\n else if (name === 'hover' || name === 'any-hover') holds &&= value.trim() === 'hover'\n else if (name === 'pointer' || name === 'any-pointer') holds &&= value.trim() === 'fine'\n else if (name === 'prefers-contrast' || name === 'forced-colors') holds &&= /^(?:no-preference|none)$/.test(value.trim())\n continue\n }\n // Range syntax: (width >= 900px), (600px <= width < 1200px).\n const range = /^(?:(-?[\\d.]+\\w*)\\s*(<=|<|>=|>)\\s*)?(width|height)\\s*(?:(<=|<|>=|>)\\s*(-?[\\d.]+\\w*))?$/.exec(inner)\n if (range) {\n const size = range[3] === 'width' ? width : height\n const test = (a: number, op: string, b: number) => (op === '<' ? a < b : op === '<=' ? a <= b : op === '>' ? a > b : a >= b)\n if (range[1] && range[2]) {\n const px = siteImportLengthPx(range[1])\n holds &&= px !== null && test(px, range[2], size)\n }\n if (range[4] && range[5]) {\n const px = siteImportLengthPx(range[5])\n holds &&= px !== null && test(size, range[4], px)\n }\n }\n }\n return negate ? !holds : holds\n}\n\nfunction mediaHolds(prelude: string, viewport: number): boolean {\n const list = splitList(prelude.replace(/^@media\\s*/i, ''))\n return !list.length || list.some((query) => mediaQueryHolds(query, viewport))\n}\n\nfunction declarationsOf(body: string): CssRule['decls'] {\n const decls: CssRule['decls'] = []\n // Values may hold semicolons only inside strings or url(), which the kept properties never need.\n for (const part of body.split(';')) {\n const colon = part.indexOf(':')\n if (colon <= 0) continue\n const written = part.slice(0, colon).trim()\n // A custom property's name is case-sensitive, as `var()` reads it.\n const property = written.startsWith('--') ? written : written.toLowerCase()\n if (!property.startsWith('--') && !KEPT_PROPERTIES.has(property)) continue\n let value = part.slice(colon + 1).trim()\n const important = /!\\s*important\\s*$/i.test(value)\n if (important) value = value.replace(/!\\s*important\\s*$/i, '').trim()\n if (value) decls.push([property, value.slice(0, 2_000), important])\n }\n return decls\n}\n\n/** The index key of a selector: its rightmost compound's id, first class, tag, else `*`. */\nfunction keyOf(selector: ComplexSelector): string {\n const last = selector.compounds[selector.compounds.length - 1] as Compound\n if (last.id) return `#${last.id}`\n if (last.classes.length) return `.${last.classes[0]}`\n if (last.root) return ':root'\n if (last.tag) return last.tag\n return '*'\n}\n\n/**\n * The page's sheets parsed for a wide screen. Malformed CSS is read as far as\n * it makes sense, as a browser would; nothing throws.\n */\nexport function siteImportCssOf(sheets: readonly string[], viewport: number = SITE_IMPORT_CSS_VIEWPORT.width): SiteImportCss {\n const css: SiteImportCss = { rules: [], index: new Map(), fontFaces: [] }\n let order = 0\n const addRule = (prelude: string, body: string) => {\n const decls = declarationsOf(body)\n if (!decls.length) return\n for (const text of splitList(prelude)) {\n const selector = parseSelector(text)\n if (!selector) continue\n const rule: CssRule = { selector, order: order++, decls }\n css.rules.push(rule)\n const key = keyOf(selector)\n const list = css.index.get(key)\n if (list) list.push(rule)\n else css.index.set(key, [rule])\n }\n }\n for (const sheet of sheets) {\n const text = String(sheet ?? '').replace(/\\/\\*[\\s\\S]*?\\*\\//g, ' ')\n /** For each open group: whether its rules apply. */\n const groups: boolean[] = []\n let at = 0\n let start = 0\n while (at < text.length) {\n const char = text[at]\n if (char === '\"' || char === \"'\") {\n const end = text.indexOf(char, at + 1)\n at = end < 0 ? text.length : end + 1\n continue\n }\n if (char === ';') {\n // A statement at-rule (@import, @charset) or stray text.\n start = at + 1\n at += 1\n continue\n }\n if (char === '}') {\n groups.pop()\n start = at + 1\n at += 1\n continue\n }\n if (char !== '{') {\n at += 1\n continue\n }\n const prelude = text.slice(start, at).trim()\n const applies = groups.every(Boolean)\n if (/^@(?:media)\\b/i.test(prelude)) {\n groups.push(applies && mediaHolds(prelude, viewport))\n start = at = at + 1\n continue\n }\n if (/^@(?:supports|layer|container|document|scope|starting-style)\\b/i.test(prelude)) {\n groups.push(applies && !/^@starting-style/i.test(prelude))\n start = at = at + 1\n continue\n }\n // A block to read whole: a style rule, a font face, or an at-rule to skip.\n let depth = 1\n let end = at + 1\n while (end < text.length && depth > 0) {\n if (text[end] === '{') depth += 1\n else if (text[end] === '}') depth -= 1\n end += 1\n }\n const body = text.slice(at + 1, Math.max(at + 1, end - 1))\n if (/^@font-face\\b/i.test(prelude)) {\n const family = /font-family\\s*:\\s*([\"']?)([^;\"']+)\\1/i.exec(body)?.[2]?.trim()\n if (family && !css.fontFaces.includes(family)) css.fontFaces.push(family)\n } else if (!prelude.startsWith('@') && applies && prelude) {\n // A rule nested inside a rule (`&:hover`) is a state: only the outer declarations are read.\n addRule(prelude, body.replace(/[^;{}]*\\{[^{}]*\\}/g, ''))\n }\n start = at = end\n }\n }\n return css\n}\n\n/*------------------------------------------\n * Matching and the cascade\n *-----------------------------------------*/\n\nfunction classesOf(element: SiteImportElement): string[] {\n return (element.attrs.class ?? '').split(/\\s+/).filter(Boolean)\n}\n\nfunction attributeOf(element: SiteImportElement, name: string): string | undefined {\n switch (name) {\n case 'class':\n return element.attrs.class\n case 'id':\n return element.attrs.id\n case 'role':\n return element.attrs.role\n case 'aria-label':\n return element.attrs.label\n case 'href':\n return element.attrs.href\n case 'type':\n return element.attrs.type\n case 'style':\n return element.attrs.style\n case 'hidden':\n case 'aria-hidden':\n return element.attrs.hidden ? 'true' : undefined\n case 'data-section-theme':\n case 'data-theme':\n return element.attrs.theme\n default:\n return undefined\n }\n}\n\nfunction compoundMatches(compound: Compound, element: SiteImportElement, rootId: number): boolean {\n if (compound.root && element.id !== rootId) return false\n if (compound.tag && compound.tag !== element.tag) return false\n if (compound.id && compound.id !== element.attrs.id) return false\n if (compound.classes.length) {\n const own = classesOf(element)\n if (!compound.classes.every((name) => own.includes(name))) return false\n }\n for (const attr of compound.attrs) {\n const value = attributeOf(element, attr.name)\n if (value === undefined) return false\n if (!attr.op) continue\n const wanted = attr.value\n const ok =\n attr.op === '='\n ? value === wanted\n : attr.op === '~='\n ? value.split(/\\s+/).includes(wanted)\n : attr.op === '^='\n ? value.startsWith(wanted)\n : attr.op === '$='\n ? value.endsWith(wanted)\n : attr.op === '*='\n ? value.includes(wanted)\n : value === wanted || value.startsWith(`${wanted}-`)\n if (!ok) return false\n }\n return true\n}\n\n/** Whether a selector matches an element, its combinators walked from the right. */\nfunction selectorMatches(\n selector: ComplexSelector,\n element: SiteImportElement,\n elements: readonly SiteImportElement[],\n root: SiteImportElement | null,\n): boolean {\n const rootId = root?.id ?? -2\n /** The element above `at`: its parent, or the document's root above the body. */\n const above = (at: SiteImportElement) => (at.parent >= 0 ? elements[at.parent] : at === root ? undefined : (root ?? undefined))\n const walk = (index: number, at: SiteImportElement): boolean => {\n if (!compoundMatches(selector.compounds[index] as Compound, at, rootId)) return false\n if (index === 0) return true\n const combinator = selector.combinators[index - 1]\n if (combinator === '>') {\n const parent = above(at)\n return !!parent && walk(index - 1, parent)\n }\n if (combinator === '+' || combinator === '~') {\n const siblings = elements[at.parent]?.children ?? []\n const position = siblings.indexOf(at.id)\n for (let before = position - 1; before >= 0; before -= 1) {\n const sibling = elements[siblings[before] as number]\n if (!sibling) continue\n if (walk(index - 1, sibling)) return true\n if (combinator === '+') return false\n }\n return false\n }\n for (let parent = above(at); parent; parent = above(parent)) {\n if (walk(index - 1, parent)) return true\n }\n return false\n }\n return walk(selector.compounds.length - 1, element)\n}\n\n/** One element's resolved style: the kept properties, `var()` read, lowercased. */\nexport type SiteImportComputedStyle = ReadonlyMap<string, string>\n\n/** Reads elements' styles over a page's structure, each once. */\nexport interface SiteImportStyles {\n of(element: number): SiteImportComputedStyle\n /** The root's (`<html>`) element id, which `:root` matches; -1 for none. */\n readonly root: number\n}\n\nconst EMPTY_STYLE: SiteImportComputedStyle = new Map()\n\n/** Replaces each `var(--x, fallback)` with what the custom properties hold, to a few levels. */\nfunction withVariables(value: string, custom: ReadonlyMap<string, string>): string {\n let out = value\n for (let pass = 0; pass < 4 && out.includes('var('); pass += 1) {\n out = out.replace(/var\\(\\s*(--[\\w-]+)\\s*(?:,\\s*((?:[^()]|\\([^()]*\\))*))?\\)/g, (_, name: string, fallback?: string) => custom.get(name) ?? fallback?.trim() ?? '')\n }\n return out\n}\n\n/** The kept declarations an inline `style` attribute writes. */\nfunction inlineDeclarations(style: string | undefined): CssRule['decls'] {\n return style ? declarationsOf(style) : []\n}\n\n/**\n * Elements' styles over a page's structure and its sheets. Styles are\n * resolved on demand, parent first, each element once.\n */\nexport function siteImportStylesOf(structure: Pick<SiteImportStructure, 'elements' | 'root'>, css: SiteImportCss): SiteImportStyles {\n const { elements } = structure\n const resolved = new Map<number, { style: Map<string, string>; custom: Map<string, string> }>()\n // The page's root is above the body: `:root` and `html` rules are its.\n const rootStyle = (() => {\n const style = new Map<string, string>()\n const custom = new Map<string, string>()\n const fake: SiteImportElement = { id: -2, tag: 'html', parent: -1, children: [], region: 'main', nav: false, attrs: structure.root ?? {}, blocks: [] }\n const candidates = [...(css.index.get(':root') ?? []), ...(css.index.get('html') ?? []), ...(css.index.get('*') ?? [])]\n for (const name of classesOf(fake)) candidates.push(...(css.index.get(`.${name}`) ?? []))\n if (fake.attrs.id) candidates.push(...(css.index.get(`#${fake.attrs.id}`) ?? []))\n apply(candidates.filter((rule) => selectorMatches(rule.selector, fake, [], fake)), inlineDeclarations(fake.attrs.style), style, custom)\n return { style, custom, element: fake }\n })()\n\n function apply(rules: CssRule[], inline: CssRule['decls'], style: Map<string, string>, custom: Map<string, string>) {\n const unique = [...new Set(rules)].sort((a, b) => a.selector.specificity - b.selector.specificity || a.order - b.order)\n const important: Array<[string, string]> = []\n const put = (property: string, value: string) => {\n if (property.startsWith('--')) custom.set(property, value)\n else style.set(property, value)\n }\n for (const rule of unique) {\n for (const [property, value, flag] of rule.decls) {\n if (flag) important.push([property, value])\n else put(property, value)\n }\n }\n for (const [property, value, flag] of inline) {\n if (flag) important.push([property, value])\n else put(property, value)\n }\n for (const [property, value] of important) put(property, value)\n }\n\n function resolve(id: number): { style: Map<string, string>; custom: Map<string, string> } {\n const held = resolved.get(id)\n if (held) return held\n const element = elements[id]\n if (!element) return rootStyle\n const parent = element.parent >= 0 ? resolve(element.parent) : rootStyle\n const candidates: CssRule[] = [...(css.index.get(element.tag) ?? []), ...(css.index.get('*') ?? [])]\n for (const name of classesOf(element)) candidates.push(...(css.index.get(`.${name}`) ?? []))\n if (element.attrs.id) candidates.push(...(css.index.get(`#${element.attrs.id}`) ?? []))\n const matched = candidates.filter((rule) => selectorMatches(rule.selector, element, elements, rootStyle.element))\n const own = new Map<string, string>()\n const custom = new Map(parent.custom)\n apply(matched, inlineDeclarations(element.attrs.style), own, custom)\n const style = new Map<string, string>()\n for (const property of INHERITED) {\n const value = parent.style.get(property)\n if (value !== undefined) style.set(property, value)\n }\n for (const [property, value] of own) {\n const lowered = value.trim().toLowerCase()\n if (lowered === 'inherit') {\n const inherited = parent.style.get(property)\n if (inherited !== undefined) style.set(property, inherited)\n continue\n }\n if (lowered === 'initial' || lowered === 'unset' || lowered === 'revert') {\n if (!INHERITED.has(property) || lowered === 'initial') style.delete(property)\n continue\n }\n style.set(property, property === 'font-family' ? withVariables(value, custom) : withVariables(value, custom).toLowerCase())\n }\n const entry = { style, custom }\n resolved.set(id, entry)\n return entry\n }\n\n // The root's own inherited values reach the body through `rootStyle`.\n for (const [property, value] of rootStyle.style) {\n rootStyle.style.set(property, property === 'font-family' ? withVariables(value, rootStyle.custom) : withVariables(value, rootStyle.custom).toLowerCase())\n }\n return {\n root: -2,\n of(element: number): SiteImportComputedStyle {\n if (element === -2) return rootStyle.style\n return elements[element] ? resolve(element).style : EMPTY_STYLE\n },\n }\n}\n\n/*------------------------------------------\n * Values\n *-----------------------------------------*/\n\nexport interface SiteImportRgba {\n r: number\n g: number\n b: number\n a: number\n}\n\nconst NAMED_COLORS: Record<string, string> = {\n white: '#ffffff',\n black: '#000000',\n red: '#ff0000',\n green: '#008000',\n blue: '#0000ff',\n gray: '#808080',\n grey: '#808080',\n silver: '#c0c0c0',\n whitesmoke: '#f5f5f5',\n ghostwhite: '#f8f8ff',\n snow: '#fffafa',\n ivory: '#fffff0',\n beige: '#f5f5dc',\n linen: '#faf0e6',\n navy: '#000080',\n teal: '#008080',\n orange: '#ffa500',\n gold: '#ffd700',\n purple: '#800080',\n crimson: '#dc143c',\n tomato: '#ff6347',\n coral: '#ff7f50',\n aliceblue: '#f0f8ff',\n lightgray: '#d3d3d3',\n lightgrey: '#d3d3d3',\n gainsboro: '#dcdcdc',\n darkslategray: '#2f4f4f',\n dimgray: '#696969',\n}\n\n/** The first color a value names, or `null`; `transparent` is a color of no strength. */\nexport function siteImportColorOf(value: string | undefined): SiteImportRgba | null {\n if (!value) return null\n const text = value.toLowerCase()\n const hex = /#([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})\\b/.exec(text)\n const rgb = /rgba?\\(\\s*(-?[\\d.]+%?)\\s*[,\\s]\\s*(-?[\\d.]+%?)\\s*[,\\s]\\s*(-?[\\d.]+%?)\\s*(?:[,/]\\s*(-?[\\d.]+%?)\\s*)?\\)/.exec(text)\n const hsl = /hsla?\\(\\s*(-?[\\d.]+)(?:deg)?\\s*[,\\s]\\s*([\\d.]+)%\\s*[,\\s]\\s*([\\d.]+)%\\s*(?:[,/]\\s*([\\d.]+%?)\\s*)?\\)/.exec(text)\n const named = /\\b(transparent|[a-z]+)\\b/.exec(text.replace(/[a-z-]+\\(/g, ' ('))\n const first = [hex, rgb, hsl].filter((match): match is RegExpExecArray => !!match).sort((a, b) => a.index - b.index)[0]\n const alphaOf = (raw: string | undefined) => (raw === undefined ? 1 : raw.endsWith('%') ? Number(raw.slice(0, -1)) / 100 : Number(raw))\n if (first === hex && hex) {\n const digits = hex[1]\n const full = digits.length <= 4 ? digits.split('').map((d) => d + d).join('') : digits\n return {\n r: parseInt(full.slice(0, 2), 16),\n g: parseInt(full.slice(2, 4), 16),\n b: parseInt(full.slice(4, 6), 16),\n a: full.length === 8 ? parseInt(full.slice(6, 8), 16) / 255 : 1,\n }\n }\n if (first === rgb && rgb) {\n const channel = (raw: string) => Math.max(0, Math.min(255, raw.endsWith('%') ? (Number(raw.slice(0, -1)) / 100) * 255 : Number(raw)))\n return { r: channel(rgb[1]), g: channel(rgb[2]), b: channel(rgb[3]), a: alphaOf(rgb[4]) }\n }\n if (first === hsl && hsl) {\n const h = (((Number(hsl[1]) % 360) + 360) % 360) / 360\n const s = Number(hsl[2]) / 100\n const l = Number(hsl[3]) / 100\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s\n const p = 2 * l - q\n const tone = (t: number) => {\n const x = t < 0 ? t + 1 : t > 1 ? t - 1 : t\n if (x < 1 / 6) return p + (q - p) * 6 * x\n if (x < 1 / 2) return q\n if (x < 2 / 3) return p + (q - p) * (2 / 3 - x) * 6\n return p\n }\n return { r: tone(h + 1 / 3) * 255, g: tone(h) * 255, b: tone(h - 1 / 3) * 255, a: alphaOf(hsl[4]) }\n }\n if (named) {\n if (named[1] === 'transparent') return { r: 0, g: 0, b: 0, a: 0 }\n const known = NAMED_COLORS[named[1]]\n if (known) return siteImportColorOf(known)\n }\n return null\n}\n\n/** `#rrggbb` of a color, its strength ignored. */\nexport function siteImportHex(color: SiteImportRgba): string {\n return `#${[color.r, color.g, color.b].map((channel) => Math.round(channel).toString(16).padStart(2, '0')).join('')}`\n}\n\n/** Relative luminance, 0 (black) to 1 (white). */\nexport function siteImportLuminance(color: SiteImportRgba): number {\n const linear = (channel: number) => {\n const c = channel / 255\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n }\n return 0.2126 * linear(color.r) + 0.7152 * linear(color.g) + 0.0722 * linear(color.b)\n}\n\n/** How colorful a color is, 0 (grey) to 1. */\nexport function siteImportSaturation(color: SiteImportRgba): number {\n const max = Math.max(color.r, color.g, color.b) / 255\n const min = Math.min(color.r, color.g, color.b) / 255\n if (max === min) return 0\n const l = (max + min) / 2\n return (max - min) / (1 - Math.abs(2 * l - 1))\n}\n\n/** What an element draws behind itself: a color, a gradient and its colors, or a picture. */\nexport interface SiteImportBackground {\n color: SiteImportRgba | null\n gradient: SiteImportRgba[] | null\n /** A picture's address, as written. */\n image: string | null\n}\n\n/** An element's own background, from the shorthand or its parts. */\nexport function siteImportBackgroundOf(style: SiteImportComputedStyle): SiteImportBackground {\n const shorthand = style.get('background') ?? ''\n const imageValue = style.get('background-image') ?? (/(?:url|gradient)\\(/.test(shorthand) ? shorthand : '')\n const colorValue = style.get('background-color') ?? (shorthand && !/(?:url|gradient)\\(/.test(shorthand) ? shorthand : shorthand.replace(/[a-z-]*gradient\\((?:[^()]|\\([^()]*\\))*\\)|url\\([^)]*\\)/g, ' '))\n const color = siteImportColorOf(colorValue)\n let gradient: SiteImportRgba[] | null = null\n let image: string | null = null\n const gradientMatch = /gradient\\(((?:[^()]|\\([^()]*\\))*)\\)/.exec(imageValue)\n if (gradientMatch) {\n const stops: SiteImportRgba[] = []\n for (const match of gradientMatch[1].matchAll(/#[0-9a-f]{3,8}\\b|rgba?\\([^)]*\\)|hsla?\\([^)]*\\)|\\b(?:white|black|transparent)\\b/gi)) {\n const stop = siteImportColorOf(match[0])\n if (stop) stops.push(stop)\n }\n if (stops.length) gradient = stops\n }\n const url = /url\\(\\s*([\"']?)([^\"')]+)\\1\\s*\\)/.exec(imageValue)\n if (url) image = url[2].trim()\n return { color: color && color.a > 0.02 ? color : null, gradient, image }\n}\n\n/** Whether an element draws a border on any side. */\nexport function siteImportHasBorder(style: SiteImportComputedStyle): boolean {\n const sides = ['border', 'border-top', 'border-bottom', 'border-left', 'border-right']\n for (const side of sides) {\n const value = style.get(side)\n if (!value) continue\n if (/\\bnone\\b|\\bhidden\\b/.test(value) || /^0(?:px)?$/.test(value.trim())) continue\n const color = siteImportColorOf(value) ?? siteImportColorOf(style.get('border-color'))\n if (color && color.a < 0.05) continue\n if (/\\d/.test(value) || /\\b(?:solid|dashed|dotted|double)\\b/.test(value)) {\n const width = /(-?[\\d.]+)px/.exec(value)\n if (!width || Number(width[1]) > 0) return true\n }\n }\n const width = style.get('border-width')\n const kind = style.get('border-style')\n if (kind && /\\b(?:solid|dashed|dotted|double)\\b/.test(kind) && (!width || !/^0(?:px)?$/.test(width.trim()))) return true\n return false\n}\n\n/** A side of an element's box. */\nexport type SiteImportSide = 'top' | 'right' | 'bottom' | 'left'\n\nconst SIDES: readonly SiteImportSide[] = ['top', 'right', 'bottom', 'left']\n\n/** One side's border, where it draws one: its width in px and its color as written. */\nexport interface SiteImportBorderSide {\n width: number\n color: SiteImportRgba | null\n}\n\n/**\n * The sides an element draws a border on (AGL-4138), each with its width and\n * color: a box is bordered on every side, a rule on one. The shorthand draws\n * all four; a side's own declaration, or `border-width` and `border-style`\n * by side, draw only theirs.\n */\nexport function siteImportBorderSides(style: SiteImportComputedStyle): Partial<Record<SiteImportSide, SiteImportBorderSide>> {\n const out: Partial<Record<SiteImportSide, SiteImportBorderSide>> = {}\n const shared = siteImportColorOf(style.get('border-color'))\n const drawn = (value: string | undefined): SiteImportBorderSide | null => {\n if (!value || /\\bnone\\b|\\bhidden\\b/.test(value) || /^0(?:px)?$/.test(value.trim())) return null\n const color = siteImportColorOf(value) ?? shared\n if (color && color.a < 0.05) return null\n if (!/\\d/.test(value) && !/\\b(?:solid|dashed|dotted|double)\\b/.test(value)) return null\n const width = /(-?[\\d.]+)(?:px)?(?:\\s|$)/.exec(value.replace(/#[0-9a-f]+|rgba?\\([^)]*\\)|hsla?\\([^)]*\\)/gi, ' '))\n const px = width ? Number(width[1]) : /\\bthick\\b/.test(value) ? 5 : /\\bthin\\b/.test(value) ? 1 : 3\n return px > 0 ? { width: px, color } : null\n }\n const all = drawn(style.get('border'))\n for (const side of SIDES) {\n const own = style.get(`border-${side}`)\n const found = own !== undefined ? drawn(own) : all\n if (found) out[side] = found\n }\n // `border-width` and `border-style` by side, where no shorthand drew a side.\n const kind = style.get('border-style')\n if (!Object.keys(out).length && kind && /\\b(?:solid|dashed|dotted|double)\\b/.test(kind)) {\n const widths = (style.get('border-width') ?? '3px').trim().split(/\\s+/)\n const by = [widths[0], widths[1] ?? widths[0], widths[2] ?? widths[0], widths[3] ?? widths[1] ?? widths[0]]\n SIDES.forEach((side, at) => {\n const px = siteImportLengthPx(by[at] ?? '')\n if (px !== null && px > 0) out[side] = { width: px, color: shared }\n })\n }\n return out\n}\n\n/** A picture box's `aspect-ratio`, width over height: `16 / 9`, `1.5`, `auto 4 / 3`; `null` where it sets none. */\nexport function siteImportAspectRatio(value: string | undefined): number | null {\n const match = /(\\d*\\.?\\d+)\\s*(?:\\/\\s*(\\d*\\.?\\d+))?/.exec((value ?? '').replace(/\\bauto\\b/g, ' '))\n if (!match) return null\n const width = Number(match[1])\n const height = match[2] === undefined ? 1 : Number(match[2])\n return width > 0 && height > 0 ? width / height : null\n}\n\n/** A color as it shows over the ground it sits on, its strength blended in: `rgba(0,0,0,.6)` over white is `#666666`. */\nexport function siteImportOpaque(color: SiteImportRgba, under: SiteImportRgba | null = null): SiteImportRgba {\n const ground = under ?? { r: 255, g: 255, b: 255, a: 1 }\n const a = Math.max(0, Math.min(1, color.a))\n return { r: color.r * a + ground.r * (1 - a), g: color.g * a + ground.g * (1 - a), b: color.b * a + ground.b * (1 - a), a: 1 }\n}\n\n/** How far apart two colors look, in OKLab (0 the same, about 1 black from white). */\nexport function siteImportColorDistance(a: SiteImportRgba, b: SiteImportRgba): number {\n const lab = (color: SiteImportRgba) => {\n const linear = (channel: number) => {\n const c = channel / 255\n return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n }\n const [r, g, bl] = [linear(color.r), linear(color.g), linear(color.b)]\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * bl)\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * bl)\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * bl)\n return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s]\n }\n const [x, y] = [lab(a), lab(b)]\n return Math.hypot((x[0] as number) - (y[0] as number), (x[1] as number) - (y[1] as number), (x[2] as number) - (y[2] as number))\n}\n\n/** Whether an element draws a shadow. */\nexport function siteImportHasShadow(style: SiteImportComputedStyle): boolean {\n const value = style.get('box-shadow')\n return !!value && !/^(?:none|0|initial|unset)$/.test(value.trim()) && !/^0(?:px)?\\s+0(?:px)?\\s+0(?:px)?(?:\\s+0(?:px)?)?\\s+(?:transparent|rgba\\([^)]*,\\s*0\\))/.test(value.trim())\n}\n\n/** An element's corner radius in px, or `null`. */\nexport function siteImportRadiusPx(style: SiteImportComputedStyle): number | null {\n const value = style.get('border-radius')\n if (!value) return null\n const first = value.trim().split(/[\\s/]+/)[0] ?? ''\n if (first.endsWith('%')) return Number(first.slice(0, -1)) >= 50 ? 999 : Number(first.slice(0, -1))\n return siteImportLengthPx(first)\n}\n\n/** A font size in px, or `null`. */\nexport function siteImportFontSizePx(style: SiteImportComputedStyle): number | null {\n const value = style.get('font-size')\n if (!value) return null\n const clamp = /clamp\\(([^,]+),([^,]+),([^)]+)\\)/.exec(value)\n // A fluid size at the read width: its maximum, as a wide screen shows it.\n const text = clamp ? clamp[3] : value\n return siteImportLengthPx(text.trim())\n}\n\n/** The relative widths a grid template draws its columns at, or `null` for none. */\nexport function siteImportGridColumns(template: string | undefined): number[] | null {\n if (!template || /^(?:none|subgrid|masonry)$/.test(template.trim())) return null\n let text = template.trim()\n // repeat(3, 1fr) / repeat(auto-fill, minmax(240px, 1fr)): the count, or three of them.\n text = text.replace(/repeat\\(\\s*([\\w-]+)\\s*,\\s*((?:[^()]|\\([^()]*\\))*)\\)/g, (_, count: string, track: string) => {\n const times = /^\\d+$/.test(count) ? Math.min(12, Number(count)) : 3\n return Array.from({ length: times }, () => track.trim()).join(' ')\n })\n const tracks: string[] = []\n let depth = 0\n let token = ''\n for (const char of text) {\n if (char === '(') depth += 1\n if (char === ')') depth -= 1\n if (/\\s/.test(char) && depth === 0) {\n if (token) tracks.push(token)\n token = ''\n } else token += char\n }\n if (token) tracks.push(token)\n const weights = tracks\n .filter((track) => !/^\\[.*\\]$/.test(track))\n .map((track) => {\n const fr = /(-?[\\d.]+)fr\\)?$/.exec(track)\n if (fr) return Number(fr[1]) || 1\n const px = /(-?[\\d.]+)px/.exec(track)\n if (px) return Number(px[1]) / 100\n const percent = /(-?[\\d.]+)%/.exec(track)\n if (percent) return Number(percent[1]) / 10\n return 1\n })\n return weights.length ? weights : null\n}\n\n/** Weights scaled to twelfths, each at least 1: `[420, 788]` is `[4, 8]`. */\nexport function siteImportTwelfths(weights: readonly number[]): number[] {\n const total = weights.reduce((sum, weight) => sum + Math.max(0, weight), 0)\n if (!total) return weights.map(() => 1)\n const scaled = weights.map((weight) => Math.max(1, Math.round((Math.max(0, weight) / total) * 12)))\n // Two equal tracks stay equal, three stay thirds.\n const unique = new Set(weights.map((weight) => Math.round(weight * 1000)))\n if (unique.size === 1) return weights.map(() => 1)\n return scaled\n}\n\n/** The families a `font-family` value names, quotes dropped, generic ones left out. */\nexport function siteImportFontFamilies(value: string | undefined): string[] {\n if (!value) return []\n return splitList(value)\n .map((family) => family.replace(/^[\"']|[\"']$/g, '').trim())\n .filter((family) => family && !/^(?:serif|sans-serif|monospace|cursive|fantasy|system-ui|ui-[\\w-]+|-apple-system|blinkmacsystemfont|inherit|initial|emoji|math|var\\(.*)$/i.test(family))\n}\n"],"names":["SITE_IMPORT_CSS_VIEWPORT","width","height","SITE_IMPORT_CSS_WIDE_WIDTH","KEPT_PROPERTIES","Set","INHERITED","unescapeIdent","text","replace","_","escaped","test","code","parseInt","trim","String","fromCodePoint","IDENT","raw","SIMPLE","RegExp","AT_REST","parseCompound","compound","tag","id","classes","attrs","root","rest","match","exec","slice","length","toLowerCase","push","name","op","value","has","parseSelector","compounds","combinators","parts","split","pending","part","ids","tags","specificity","splitList","out","depth","start","at","char","Math","max","map","filter","Boolean","siteImportLengthPx","amount","Number","mediaQueryHolds","query","viewport","negate","startsWith","holds","term","inner","feature","px","range","size","a","b","mediaHolds","prelude","list","some","declarationsOf","body","decls","colon","indexOf","written","property","important","keyOf","selector","last","siteImportCssOf","sheets","css","rules","index","Map","fontFaces","order","addRule","rule","key","get","set","sheet","groups","end","pop","applies","every","family","includes","classesOf","element","class","attributeOf","role","label","href","type","style","hidden","undefined","theme","compoundMatches","rootId","own","attr","wanted","ok","endsWith","selectorMatches","elements","above","parent","walk","combinator","siblings","children","position","before","sibling","EMPTY_STYLE","withVariables","custom","pass","fallback","inlineDeclarations","siteImportStylesOf","structure","resolved","rootStyle","fake","region","nav","blocks","candidates","apply","inline","unique","sort","put","flag","resolve","held","matched","lowered","inherited","delete","entry","of","NAMED_COLORS","white","black","red","green","blue","gray","grey","silver","whitesmoke","ghostwhite","snow","ivory","beige","linen","navy","teal","orange","gold","purple","crimson","tomato","coral","aliceblue","lightgray","lightgrey","gainsboro","darkslategray","dimgray","siteImportColorOf","hex","rgb","hsl","named","first","alphaOf","digits","full","d","join","r","g","channel","min","h","s","l","q","p","tone","t","x","known","siteImportHex","color","round","toString","padStart","siteImportLuminance","linear","c","siteImportSaturation","abs","siteImportBackgroundOf","shorthand","imageValue","colorValue","gradient","image","gradientMatch","stops","matchAll","stop","url","siteImportHasBorder","sides","side","kind","SIDES","siteImportBorderSides","shared","drawn","all","found","Object","keys","widths","by","forEach","siteImportAspectRatio","siteImportOpaque","under","ground","siteImportColorDistance","lab","bl","cbrt","m","y","hypot","siteImportHasShadow","siteImportRadiusPx","siteImportFontSizePx","clamp","siteImportGridColumns","template","count","track","times","Array","from","tracks","token","weights","fr","percent","siteImportTwelfths","total","reduce","sum","weight","scaled","siteImportFontFamilies"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;2CAuB2C,GAI3C,2EAA2E,GAC3E,OAAO,MAAMA,2BAA2B;IAAEC,OAAO;IAAMC,QAAQ;AAAI,EAAU;AAE7E;;;;;CAKC,GACD,OAAO,MAAMC,6BAA6B,KAAI;AAE9C,uGAAuG,GACvG,MAAMC,kBAAkB,IAAIC,IAAI;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,0FAA0F;IAC1F;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,uEAAuE,GACvE,MAAMC,YAAY,IAAID,IAAI;IAAC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AK,CAAC,AAAC5K,KAAKC,GAAG,CAAC,GAAG4O,UAAUH,QAAS;IAC9F,kDAAkD;IAClD,MAAMjI,SAAS,IAAI7J,IAAI0R,QAAQpO,GAAG,CAAC,CAAC2O,SAAW7O,KAAK4K,KAAK,CAACiE,SAAS;IACnE,IAAIpI,OAAOtF,IAAI,KAAK,GAAG,OAAOmN,QAAQpO,GAAG,CAAC,IAAM;IAChD,OAAO4O;AACT;AAEA,qFAAqF,GACrF,OAAO,SAASC,uBAAuBjQ,KAAyB;IAC9D,IAAI,CAACA,OAAO,OAAO,EAAE;IACrB,OAAOY,UAAUZ,OACdoB,GAAG,CAAC,CAACsD,SAAWA,OAAOxG,OAAO,CAAC,gBAAgB,IAAIM,IAAI,IACvD6C,MAAM,CAAC,CAACqD,SAAWA,UAAU,CAAC,4IAA4IrG,IAAI,CAACqG;AACpL"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-import/site-import-css.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 * HOW A PAGE IS STYLED, AS A WIDE SCREEN SHOWS IT (AGL-4106).\n *\n * Bring my site reads a page's layout, not only its lines, and most of a\n * layout lives in the stylesheet: which band is grey and which is dark, which\n * container lays its children out in three columns, which link is drawn as a\n * filled button. This is a small cascade, enough for that and no more:\n *\n * - **The sheets.** The page's own `<style>` sheets and the ones it links,\n * read in order. `@media` rules apply as a 1280-pixel screen in light mode\n * sees them, so a grid's desktop columns win over its phone ones;\n * `@layer`, `@supports` and `@container` are read through; keyframes, font\n * faces (their families noted) and page rules are skipped.\n * - **Selectors.** Tags, classes (escaped ones too, as utility frameworks\n * write them), ids and attributes, joined by any combinator. A rule that\n * only applies on hover, focus or to a generated part (`::before`) is a\n * state the page is not in and is not read.\n * - **The cascade.** Specificity, then order, `!important` over both, and the\n * element's own `style` over every rule; color, font and alignment inherit,\n * and so do custom properties, which `var()` reads.\n *\n * Only the properties the layout reader asks about are kept. Nothing here\n * runs anything a page wrote: values are text compared to text.\n *=========================================*/\n\nimport type { SiteImportElement, SiteImportStructure } from './site-import-html'\n\n/** The width a page is read at: a laptop's, where a desktop layout shows. */\nexport const SITE_IMPORT_CSS_VIEWPORT = { width: 1280, height: 800 } as const\n\n/**\n * The width a page's column is read at (AGL-4083). A container caps itself\n * only on screens wider than its cap (`@media (min-width:1536px)` around a\n * `max-width:1536px`), so on a laptop it runs the whole page: read there, it\n * would look as if it had no cap at all.\n */\nexport const SITE_IMPORT_CSS_WIDE_WIDTH = 1920\n\n/** The properties the layout reader reads; every other declaration is dropped as the sheet is parsed. */\nconst KEPT_PROPERTIES = new Set([\n 'background',\n 'background-color',\n 'background-image',\n 'color',\n 'border',\n 'border-width',\n 'border-style',\n 'border-color',\n 'border-top',\n 'border-right',\n 'border-bottom',\n 'border-left',\n 'border-top-width',\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-style',\n 'border-bottom-style',\n 'border-top-color',\n 'border-bottom-color',\n 'border-radius',\n 'box-shadow',\n 'display',\n 'grid-template-columns',\n 'grid-column',\n 'flex',\n 'flex-direction',\n 'flex-wrap',\n 'flex-grow',\n 'flex-basis',\n 'width',\n 'max-width',\n // The shape a picture is framed at (AGL-4138): a box's own, or a height it is cropped to.\n 'aspect-ratio',\n 'height',\n 'font-family',\n 'font-size',\n 'font-weight',\n 'text-transform',\n 'letter-spacing',\n 'text-align',\n 'position',\n 'visibility',\n 'padding',\n 'padding-top',\n 'padding-bottom',\n 'padding-left',\n 'padding-right',\n 'object-fit',\n 'justify-content',\n 'align-items',\n])\n\n/** What an element takes from its parent when it says nothing itself. */\nconst INHERITED = new Set(['color', 'font-family', 'font-size', 'font-weight', 'text-transform', 'letter-spacing', 'text-align', 'visibility'])\n\ninterface Compound {\n tag: string | null\n id: string | null\n classes: string[]\n attrs: Array<{ name: string; op: string | null; value: string }>\n /** `:root`: only the document's root element. */\n root: boolean\n}\n\ninterface ComplexSelector {\n /** Rightmost last. */\n compounds: Compound[]\n /** `combinators[i]` joins `compounds[i]` and `compounds[i + 1]`: a space, a child, an adjacent or a sibling combinator. */\n combinators: string[]\n specificity: number\n}\n\ninterface CssRule {\n selector: ComplexSelector\n order: number\n decls: Array<[property: string, value: string, important: boolean]>\n}\n\n/** The page's sheets, parsed for one width. */\nexport interface SiteImportCss {\n rules: CssRule[]\n /** Rules by their rightmost compound's id (`#x`), first class (`.x`), tag, or `*`. */\n index: Map<string, CssRule[]>\n /** Families its `@font-face` rules name, in order. */\n fontFaces: string[]\n /** Read for its dark scheme (AGL-4152): the rules that scheme alone selects, by a media query or a class on the page. */\n darkRules: number\n}\n\n/** Which of a page's color schemes a read of its stylesheets answers for. */\nexport interface SiteImportCssOptions {\n /** Absent is `light`, as a page is first read. */\n scheme?: 'light' | 'dark'\n}\n\n/*------------------------------------------\n * Parsing\n *-----------------------------------------*/\n\nfunction unescapeIdent(text: string): string {\n return text.replace(/\\\\([0-9a-fA-F]{1,6}\\s?|.)/g, (_, escaped: string) => {\n if (/^[0-9a-fA-F]{1,6}\\s?$/.test(escaped)) {\n const code = parseInt(escaped.trim(), 16)\n return code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : ''\n }\n return escaped\n })\n}\n\nconst IDENT = String.raw`(?:\\\\[0-9a-fA-F]{1,6}\\s?|\\\\.|[\\w-]|[^\\x00-\\x7f])+`\nconst SIMPLE = new RegExp(\n String.raw`^(?:(\\*|${IDENT})|#(${IDENT})|\\.(${IDENT})|\\[\\s*([\\w-]+)\\s*(?:([~|^$*]?=)\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\]\\s]+))\\s*(?:[is]\\s*)?)?\\]|(::?)(${IDENT})(\\((?:[^()]|\\([^()]*\\))*\\))?)`,\n)\n\n/** The pseudo-classes a page at rest matches as if they were not there. */\nconst AT_REST = new Set(['link', 'any-link'])\n\n/** One compound selector, or `null` when it depends on a state or a generated part. */\nfunction parseCompound(text: string): Compound | null {\n const compound: Compound = { tag: null, id: null, classes: [], attrs: [], root: false }\n let rest = text\n while (rest) {\n const match = SIMPLE.exec(rest)\n if (!match || !match[0]) return null\n rest = rest.slice(match[0].length)\n if (match[1]) compound.tag = match[1] === '*' ? null : unescapeIdent(match[1]).toLowerCase()\n else if (match[2]) compound.id = unescapeIdent(match[2])\n else if (match[3]) compound.classes.push(unescapeIdent(match[3]))\n else if (match[4]) compound.attrs.push({ name: match[4].toLowerCase(), op: match[5] ?? null, value: match[6] ?? match[7] ?? match[8] ?? '' })\n else if (match[9]) {\n const name = unescapeIdent(match[10] ?? '').toLowerCase()\n if (match[9] === '::') return null\n if (name === 'root') compound.root = true\n else if (!AT_REST.has(name)) return null\n }\n }\n return compound\n}\n\n/** A complex selector, or `null` when any part of it cannot be read at rest. */\nfunction parseSelector(text: string): ComplexSelector | null {\n const compounds: Compound[] = []\n const combinators: string[] = []\n const parts = text.trim().replace(/\\s*([>+~])\\s*/g, ' $1 ').split(/\\s+/)\n let pending: string | null = null\n for (const part of parts) {\n if (!part) continue\n if (part === '>' || part === '+' || part === '~') {\n pending = part\n continue\n }\n const compound = parseCompound(part)\n if (!compound) return null\n if (compounds.length) combinators.push(pending ?? ' ')\n pending = null\n compounds.push(compound)\n }\n if (!compounds.length || pending) return null\n let ids = 0\n let classes = 0\n let tags = 0\n for (const compound of compounds) {\n if (compound.id) ids += 1\n classes += compound.classes.length + compound.attrs.length + (compound.root ? 1 : 0)\n if (compound.tag) tags += 1\n }\n return { compounds, combinators, specificity: ids * 1_000_000 + classes * 1_000 + tags }\n}\n\n/** Splits at top-level commas: none inside brackets or parentheses. */\nfunction splitList(text: string): string[] {\n const out: string[] = []\n let depth = 0\n let start = 0\n for (let at = 0; at < text.length; at += 1) {\n const char = text[at]\n if (char === '(' || char === '[') depth += 1\n else if (char === ')' || char === ']') depth = Math.max(0, depth - 1)\n else if (char === ',' && depth === 0) {\n out.push(text.slice(start, at))\n start = at + 1\n }\n }\n out.push(text.slice(start))\n return out.map((part) => part.trim()).filter(Boolean)\n}\n\n/** A length in px at the read width; `em`/`rem` at 16. */\nexport function siteImportLengthPx(value: string): number | null {\n const match = /^(-?\\d*\\.?\\d+)\\s*(px|em|rem)?$/i.exec(value.trim())\n if (!match) return null\n const amount = Number(match[1])\n return match[2] && match[2].toLowerCase() !== 'px' ? amount * 16 : amount\n}\n\n/** Whether one media query holds for a screen of this width in this color scheme. */\nfunction mediaQueryHolds(query: string, viewport: number, scheme: 'light' | 'dark'): boolean {\n let text = query.trim().toLowerCase()\n let negate = false\n if (text.startsWith('not ')) {\n negate = true\n text = text.slice(4)\n }\n text = text.replace(/^only\\s+/, '')\n let holds = true\n for (const part of text.split(/\\s+and\\s+/)) {\n const term = part.trim()\n if (!term) continue\n if (!term.startsWith('(')) {\n if (!/^(?:all|screen)$/.test(term)) holds = false\n continue\n }\n const inner = term.replace(/^\\(|\\)$/g, '').trim()\n const feature = /^([\\w-]+)\\s*:\\s*(.+)$/.exec(inner)\n const { height } = SITE_IMPORT_CSS_VIEWPORT\n const width = viewport\n if (feature) {\n const [, name, value] = feature\n const px = siteImportLengthPx(value)\n if (name === 'min-width') holds &&= px !== null && width >= px\n else if (name === 'max-width') holds &&= px !== null && width <= px\n else if (name === 'min-height') holds &&= px !== null && height >= px\n else if (name === 'max-height') holds &&= px !== null && height <= px\n else if (name === 'prefers-color-scheme') holds &&= value.trim() === scheme\n else if (name === 'prefers-reduced-motion') holds &&= value.trim() === 'no-preference'\n else if (name === 'orientation') holds &&= value.trim() === 'landscape'\n else if (name === 'hover' || name === 'any-hover') holds &&= value.trim() === 'hover'\n else if (name === 'pointer' || name === 'any-pointer') holds &&= value.trim() === 'fine'\n else if (name === 'prefers-contrast' || name === 'forced-colors') holds &&= /^(?:no-preference|none)$/.test(value.trim())\n continue\n }\n // Range syntax: (width >= 900px), (600px <= width < 1200px).\n const range = /^(?:(-?[\\d.]+\\w*)\\s*(<=|<|>=|>)\\s*)?(width|height)\\s*(?:(<=|<|>=|>)\\s*(-?[\\d.]+\\w*))?$/.exec(inner)\n if (range) {\n const size = range[3] === 'width' ? width : height\n const test = (a: number, op: string, b: number) => (op === '<' ? a < b : op === '<=' ? a <= b : op === '>' ? a > b : a >= b)\n if (range[1] && range[2]) {\n const px = siteImportLengthPx(range[1])\n holds &&= px !== null && test(px, range[2], size)\n }\n if (range[4] && range[5]) {\n const px = siteImportLengthPx(range[5])\n holds &&= px !== null && test(size, range[4], px)\n }\n }\n }\n return negate ? !holds : holds\n}\n\nfunction mediaHolds(prelude: string, viewport: number, scheme: 'light' | 'dark'): boolean {\n const list = splitList(prelude.replace(/^@media\\s*/i, ''))\n return !list.length || list.some((query) => mediaQueryHolds(query, viewport, scheme))\n}\n\n/**\n * A selector's leading mark of the dark scheme (AGL-4152): `.dark`, `.dark-mode`\n * or a `data-theme` that says dark, on the page's root or body. Nothing a read\n * sees carries it, so a dark read lifts it off and the rest applies as written.\n */\nconst DARK_SCOPE = /^(?:(html|body|:root))?(?:\\.dark(?:-mode|-theme)?|\\[\\s*data-(?:theme|mode|color-scheme|color-mode|bs-theme|mui-color-scheme)\\s*[*~|^]?=\\s*[\"']?[^\"'\\]]*dark[^\"'\\]]*[\"']?\\s*(?:i\\s*)?\\])(?=$|[\\s>+~.:#[])/i\n\n/** What a selector asks of a page in its dark scheme, its mark lifted off: what remains, else the element that held the mark. `null` for a selector with no such mark. */\nfunction withoutDarkScope(text: string): string | null {\n const match = DARK_SCOPE.exec(text.trim())\n if (!match) return null\n const rest = text.trim().slice(match[0].length).replace(/^[\\s>+~]+/, '')\n return rest || match[1] || ':root'\n}\n\nfunction declarationsOf(body: string): CssRule['decls'] {\n const decls: CssRule['decls'] = []\n // Values may hold semicolons only inside strings or url(), which the kept properties never need.\n for (const part of body.split(';')) {\n const colon = part.indexOf(':')\n if (colon <= 0) continue\n const written = part.slice(0, colon).trim()\n // A custom property's name is case-sensitive, as `var()` reads it.\n const property = written.startsWith('--') ? written : written.toLowerCase()\n if (!property.startsWith('--') && !KEPT_PROPERTIES.has(property)) continue\n let value = part.slice(colon + 1).trim()\n const important = /!\\s*important\\s*$/i.test(value)\n if (important) value = value.replace(/!\\s*important\\s*$/i, '').trim()\n if (value) decls.push([property, value.slice(0, 2_000), important])\n }\n return decls\n}\n\n/** The index key of a selector: its rightmost compound's id, first class, tag, else `*`. */\nfunction keyOf(selector: ComplexSelector): string {\n const last = selector.compounds[selector.compounds.length - 1] as Compound\n if (last.id) return `#${last.id}`\n if (last.classes.length) return `.${last.classes[0]}`\n if (last.root) return ':root'\n if (last.tag) return last.tag\n return '*'\n}\n\n/**\n * The page's sheets parsed for a wide screen. Malformed CSS is read as far as\n * it makes sense, as a browser would; nothing throws.\n */\nexport function siteImportCssOf(sheets: readonly string[], viewport: number = SITE_IMPORT_CSS_VIEWPORT.width, options: SiteImportCssOptions = {}): SiteImportCss {\n const css: SiteImportCss = { rules: [], index: new Map(), fontFaces: [], darkRules: 0 }\n const scheme = options.scheme ?? 'light'\n let order = 0\n /** For each open group: whether only a dark scheme's media query opens it. */\n const darkGroups: boolean[] = []\n const addRule = (prelude: string, body: string) => {\n const decls = declarationsOf(body)\n if (!decls.length) return\n for (const text of splitList(prelude)) {\n const lifted = scheme === 'dark' ? withoutDarkScope(text) : null\n const selector = parseSelector(lifted ?? text)\n if (!selector) continue\n if (scheme === 'dark' && (lifted !== null || darkGroups.includes(true))) css.darkRules += 1\n // The mark it lost still counts: a dark rule outranks the same rule of the light scheme.\n if (lifted !== null) selector.specificity += 1_000\n const rule: CssRule = { selector, order: order++, decls }\n css.rules.push(rule)\n const key = keyOf(selector)\n const list = css.index.get(key)\n if (list) list.push(rule)\n else css.index.set(key, [rule])\n }\n }\n for (const sheet of sheets) {\n const text = String(sheet ?? '').replace(/\\/\\*[\\s\\S]*?\\*\\//g, ' ')\n /** For each open group: whether its rules apply. */\n const groups: boolean[] = []\n let at = 0\n let start = 0\n while (at < text.length) {\n const char = text[at]\n if (char === '\"' || char === \"'\") {\n const end = text.indexOf(char, at + 1)\n at = end < 0 ? text.length : end + 1\n continue\n }\n if (char === ';') {\n // A statement at-rule (@import, @charset) or stray text.\n start = at + 1\n at += 1\n continue\n }\n if (char === '}') {\n groups.pop()\n darkGroups.pop()\n start = at + 1\n at += 1\n continue\n }\n if (char !== '{') {\n at += 1\n continue\n }\n const prelude = text.slice(start, at).trim()\n const applies = groups.every(Boolean)\n if (/^@(?:media)\\b/i.test(prelude)) {\n groups.push(applies && mediaHolds(prelude, viewport, scheme))\n darkGroups.push(/prefers-color-scheme\\s*:\\s*dark/i.test(prelude))\n start = at = at + 1\n continue\n }\n if (/^@(?:supports|layer|container|document|scope|starting-style)\\b/i.test(prelude)) {\n groups.push(applies && !/^@starting-style/i.test(prelude))\n darkGroups.push(false)\n start = at = at + 1\n continue\n }\n // A block to read whole: a style rule, a font face, or an at-rule to skip.\n let depth = 1\n let end = at + 1\n while (end < text.length && depth > 0) {\n if (text[end] === '{') depth += 1\n else if (text[end] === '}') depth -= 1\n end += 1\n }\n const body = text.slice(at + 1, Math.max(at + 1, end - 1))\n if (/^@font-face\\b/i.test(prelude)) {\n const family = /font-family\\s*:\\s*([\"']?)([^;\"']+)\\1/i.exec(body)?.[2]?.trim()\n if (family && !css.fontFaces.includes(family)) css.fontFaces.push(family)\n } else if (!prelude.startsWith('@') && applies && prelude) {\n // A rule nested inside a rule (`&:hover`) is a state: only the outer declarations are read.\n addRule(prelude, body.replace(/[^;{}]*\\{[^{}]*\\}/g, ''))\n }\n start = at = end\n }\n }\n return css\n}\n\n/*------------------------------------------\n * Matching and the cascade\n *-----------------------------------------*/\n\nfunction classesOf(element: SiteImportElement): string[] {\n return (element.attrs.class ?? '').split(/\\s+/).filter(Boolean)\n}\n\nfunction attributeOf(element: SiteImportElement, name: string): string | undefined {\n switch (name) {\n case 'class':\n return element.attrs.class\n case 'id':\n return element.attrs.id\n case 'role':\n return element.attrs.role\n case 'aria-label':\n return element.attrs.label\n case 'href':\n return element.attrs.href\n case 'type':\n return element.attrs.type\n case 'style':\n return element.attrs.style\n case 'hidden':\n case 'aria-hidden':\n return element.attrs.hidden ? 'true' : undefined\n case 'data-section-theme':\n case 'data-theme':\n return element.attrs.theme\n default:\n return undefined\n }\n}\n\nfunction compoundMatches(compound: Compound, element: SiteImportElement, rootId: number): boolean {\n if (compound.root && element.id !== rootId) return false\n if (compound.tag && compound.tag !== element.tag) return false\n if (compound.id && compound.id !== element.attrs.id) return false\n if (compound.classes.length) {\n const own = classesOf(element)\n if (!compound.classes.every((name) => own.includes(name))) return false\n }\n for (const attr of compound.attrs) {\n const value = attributeOf(element, attr.name)\n if (value === undefined) return false\n if (!attr.op) continue\n const wanted = attr.value\n const ok =\n attr.op === '='\n ? value === wanted\n : attr.op === '~='\n ? value.split(/\\s+/).includes(wanted)\n : attr.op === '^='\n ? value.startsWith(wanted)\n : attr.op === '$='\n ? value.endsWith(wanted)\n : attr.op === '*='\n ? value.includes(wanted)\n : value === wanted || value.startsWith(`${wanted}-`)\n if (!ok) return false\n }\n return true\n}\n\n/** Whether a selector matches an element, its combinators walked from the right. */\nfunction selectorMatches(\n selector: ComplexSelector,\n element: SiteImportElement,\n elements: readonly SiteImportElement[],\n root: SiteImportElement | null,\n): boolean {\n const rootId = root?.id ?? -2\n /** The element above `at`: its parent, or the document's root above the body. */\n const above = (at: SiteImportElement) => (at.parent >= 0 ? elements[at.parent] : at === root ? undefined : (root ?? undefined))\n const walk = (index: number, at: SiteImportElement): boolean => {\n if (!compoundMatches(selector.compounds[index] as Compound, at, rootId)) return false\n if (index === 0) return true\n const combinator = selector.combinators[index - 1]\n if (combinator === '>') {\n const parent = above(at)\n return !!parent && walk(index - 1, parent)\n }\n if (combinator === '+' || combinator === '~') {\n const siblings = elements[at.parent]?.children ?? []\n const position = siblings.indexOf(at.id)\n for (let before = position - 1; before >= 0; before -= 1) {\n const sibling = elements[siblings[before] as number]\n if (!sibling) continue\n if (walk(index - 1, sibling)) return true\n if (combinator === '+') return false\n }\n return false\n }\n for (let parent = above(at); parent; parent = above(parent)) {\n if (walk(index - 1, parent)) return true\n }\n return false\n }\n return walk(selector.compounds.length - 1, element)\n}\n\n/** One element's resolved style: the kept properties, `var()` read, lowercased. */\nexport type SiteImportComputedStyle = ReadonlyMap<string, string>\n\n/** Reads elements' styles over a page's structure, each once. */\nexport interface SiteImportStyles {\n of(element: number): SiteImportComputedStyle\n /** The root's (`<html>`) element id, which `:root` matches; -1 for none. */\n readonly root: number\n}\n\nconst EMPTY_STYLE: SiteImportComputedStyle = new Map()\n\n/** Replaces each `var(--x, fallback)` with what the custom properties hold, to a few levels. */\nfunction withVariables(value: string, custom: ReadonlyMap<string, string>): string {\n let out = value\n for (let pass = 0; pass < 4 && out.includes('var('); pass += 1) {\n out = out.replace(/var\\(\\s*(--[\\w-]+)\\s*(?:,\\s*((?:[^()]|\\([^()]*\\))*))?\\)/g, (_, name: string, fallback?: string) => custom.get(name) ?? fallback?.trim() ?? '')\n }\n return out\n}\n\n/** The kept declarations an inline `style` attribute writes. */\nfunction inlineDeclarations(style: string | undefined): CssRule['decls'] {\n return style ? declarationsOf(style) : []\n}\n\n/**\n * Elements' styles over a page's structure and its sheets. Styles are\n * resolved on demand, parent first, each element once.\n */\nexport function siteImportStylesOf(structure: Pick<SiteImportStructure, 'elements' | 'root'>, css: SiteImportCss): SiteImportStyles {\n const { elements } = structure\n const resolved = new Map<number, { style: Map<string, string>; custom: Map<string, string> }>()\n // The page's root is above the body: `:root` and `html` rules are its.\n const rootStyle = (() => {\n const style = new Map<string, string>()\n const custom = new Map<string, string>()\n const fake: SiteImportElement = { id: -2, tag: 'html', parent: -1, children: [], region: 'main', nav: false, attrs: structure.root ?? {}, blocks: [] }\n const candidates = [...(css.index.get(':root') ?? []), ...(css.index.get('html') ?? []), ...(css.index.get('*') ?? [])]\n for (const name of classesOf(fake)) candidates.push(...(css.index.get(`.${name}`) ?? []))\n if (fake.attrs.id) candidates.push(...(css.index.get(`#${fake.attrs.id}`) ?? []))\n apply(candidates.filter((rule) => selectorMatches(rule.selector, fake, [], fake)), inlineDeclarations(fake.attrs.style), style, custom)\n return { style, custom, element: fake }\n })()\n\n function apply(rules: CssRule[], inline: CssRule['decls'], style: Map<string, string>, custom: Map<string, string>) {\n const unique = [...new Set(rules)].sort((a, b) => a.selector.specificity - b.selector.specificity || a.order - b.order)\n const important: Array<[string, string]> = []\n const put = (property: string, value: string) => {\n if (property.startsWith('--')) custom.set(property, value)\n else style.set(property, value)\n }\n for (const rule of unique) {\n for (const [property, value, flag] of rule.decls) {\n if (flag) important.push([property, value])\n else put(property, value)\n }\n }\n for (const [property, value, flag] of inline) {\n if (flag) important.push([property, value])\n else put(property, value)\n }\n for (const [property, value] of important) put(property, value)\n }\n\n function resolve(id: number): { style: Map<string, string>; custom: Map<string, string> } {\n const held = resolved.get(id)\n if (held) return held\n const element = elements[id]\n if (!element) return rootStyle\n const parent = element.parent >= 0 ? resolve(element.parent) : rootStyle\n const candidates: CssRule[] = [...(css.index.get(element.tag) ?? []), ...(css.index.get('*') ?? [])]\n for (const name of classesOf(element)) candidates.push(...(css.index.get(`.${name}`) ?? []))\n if (element.attrs.id) candidates.push(...(css.index.get(`#${element.attrs.id}`) ?? []))\n const matched = candidates.filter((rule) => selectorMatches(rule.selector, element, elements, rootStyle.element))\n const own = new Map<string, string>()\n const custom = new Map(parent.custom)\n apply(matched, inlineDeclarations(element.attrs.style), own, custom)\n const style = new Map<string, string>()\n for (const property of INHERITED) {\n const value = parent.style.get(property)\n if (value !== undefined) style.set(property, value)\n }\n for (const [property, value] of own) {\n const lowered = value.trim().toLowerCase()\n if (lowered === 'inherit') {\n const inherited = parent.style.get(property)\n if (inherited !== undefined) style.set(property, inherited)\n continue\n }\n if (lowered === 'initial' || lowered === 'unset' || lowered === 'revert') {\n if (!INHERITED.has(property) || lowered === 'initial') style.delete(property)\n continue\n }\n style.set(property, property === 'font-family' ? withVariables(value, custom) : withVariables(value, custom).toLowerCase())\n }\n const entry = { style, custom }\n resolved.set(id, entry)\n return entry\n }\n\n // The root's own inherited values reach the body through `rootStyle`.\n for (const [property, value] of rootStyle.style) {\n rootStyle.style.set(property, property === 'font-family' ? withVariables(value, rootStyle.custom) : withVariables(value, rootStyle.custom).toLowerCase())\n }\n return {\n root: -2,\n of(element: number): SiteImportComputedStyle {\n if (element === -2) return rootStyle.style\n return elements[element] ? resolve(element).style : EMPTY_STYLE\n },\n }\n}\n\n/*------------------------------------------\n * Values\n *-----------------------------------------*/\n\nexport interface SiteImportRgba {\n r: number\n g: number\n b: number\n a: number\n}\n\nconst NAMED_COLORS: Record<string, string> = {\n white: '#ffffff',\n black: '#000000',\n red: '#ff0000',\n green: '#008000',\n blue: '#0000ff',\n gray: '#808080',\n grey: '#808080',\n silver: '#c0c0c0',\n whitesmoke: '#f5f5f5',\n ghostwhite: '#f8f8ff',\n snow: '#fffafa',\n ivory: '#fffff0',\n beige: '#f5f5dc',\n linen: '#faf0e6',\n navy: '#000080',\n teal: '#008080',\n orange: '#ffa500',\n gold: '#ffd700',\n purple: '#800080',\n crimson: '#dc143c',\n tomato: '#ff6347',\n coral: '#ff7f50',\n aliceblue: '#f0f8ff',\n lightgray: '#d3d3d3',\n lightgrey: '#d3d3d3',\n gainsboro: '#dcdcdc',\n darkslategray: '#2f4f4f',\n dimgray: '#696969',\n}\n\n/** The first color a value names, or `null`; `transparent` is a color of no strength. */\nexport function siteImportColorOf(value: string | undefined): SiteImportRgba | null {\n if (!value) return null\n const text = value.toLowerCase()\n const hex = /#([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})\\b/.exec(text)\n const rgb = /rgba?\\(\\s*(-?[\\d.]+%?)\\s*[,\\s]\\s*(-?[\\d.]+%?)\\s*[,\\s]\\s*(-?[\\d.]+%?)\\s*(?:[,/]\\s*(-?[\\d.]+%?)\\s*)?\\)/.exec(text)\n const hsl = /hsla?\\(\\s*(-?[\\d.]+)(?:deg)?\\s*[,\\s]\\s*([\\d.]+)%\\s*[,\\s]\\s*([\\d.]+)%\\s*(?:[,/]\\s*([\\d.]+%?)\\s*)?\\)/.exec(text)\n const named = /\\b(transparent|[a-z]+)\\b/.exec(text.replace(/[a-z-]+\\(/g, ' ('))\n const first = [hex, rgb, hsl].filter((match): match is RegExpExecArray => !!match).sort((a, b) => a.index - b.index)[0]\n const alphaOf = (raw: string | undefined) => (raw === undefined ? 1 : raw.endsWith('%') ? Number(raw.slice(0, -1)) / 100 : Number(raw))\n if (first === hex && hex) {\n const digits = hex[1]\n const full = digits.length <= 4 ? digits.split('').map((d) => d + d).join('') : digits\n return {\n r: parseInt(full.slice(0, 2), 16),\n g: parseInt(full.slice(2, 4), 16),\n b: parseInt(full.slice(4, 6), 16),\n a: full.length === 8 ? parseInt(full.slice(6, 8), 16) / 255 : 1,\n }\n }\n if (first === rgb && rgb) {\n const channel = (raw: string) => Math.max(0, Math.min(255, raw.endsWith('%') ? (Number(raw.slice(0, -1)) / 100) * 255 : Number(raw)))\n return { r: channel(rgb[1]), g: channel(rgb[2]), b: channel(rgb[3]), a: alphaOf(rgb[4]) }\n }\n if (first === hsl && hsl) {\n const h = (((Number(hsl[1]) % 360) + 360) % 360) / 360\n const s = Number(hsl[2]) / 100\n const l = Number(hsl[3]) / 100\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s\n const p = 2 * l - q\n const tone = (t: number) => {\n const x = t < 0 ? t + 1 : t > 1 ? t - 1 : t\n if (x < 1 / 6) return p + (q - p) * 6 * x\n if (x < 1 / 2) return q\n if (x < 2 / 3) return p + (q - p) * (2 / 3 - x) * 6\n return p\n }\n return { r: tone(h + 1 / 3) * 255, g: tone(h) * 255, b: tone(h - 1 / 3) * 255, a: alphaOf(hsl[4]) }\n }\n if (named) {\n if (named[1] === 'transparent') return { r: 0, g: 0, b: 0, a: 0 }\n const known = NAMED_COLORS[named[1]]\n if (known) return siteImportColorOf(known)\n }\n return null\n}\n\n/** `#rrggbb` of a color, its strength ignored. */\nexport function siteImportHex(color: SiteImportRgba): string {\n return `#${[color.r, color.g, color.b].map((channel) => Math.round(channel).toString(16).padStart(2, '0')).join('')}`\n}\n\n/** Relative luminance, 0 (black) to 1 (white). */\nexport function siteImportLuminance(color: SiteImportRgba): number {\n const linear = (channel: number) => {\n const c = channel / 255\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n }\n return 0.2126 * linear(color.r) + 0.7152 * linear(color.g) + 0.0722 * linear(color.b)\n}\n\n/** How colorful a color is, 0 (grey) to 1. */\nexport function siteImportSaturation(color: SiteImportRgba): number {\n const max = Math.max(color.r, color.g, color.b) / 255\n const min = Math.min(color.r, color.g, color.b) / 255\n if (max === min) return 0\n const l = (max + min) / 2\n return (max - min) / (1 - Math.abs(2 * l - 1))\n}\n\n/** What an element draws behind itself: a color, a gradient and its colors, or a picture. */\nexport interface SiteImportBackground {\n color: SiteImportRgba | null\n gradient: SiteImportRgba[] | null\n /** A picture's address, as written. */\n image: string | null\n}\n\n/** An element's own background, from the shorthand or its parts. */\nexport function siteImportBackgroundOf(style: SiteImportComputedStyle): SiteImportBackground {\n const shorthand = style.get('background') ?? ''\n const imageValue = style.get('background-image') ?? (/(?:url|gradient)\\(/.test(shorthand) ? shorthand : '')\n const colorValue = style.get('background-color') ?? (shorthand && !/(?:url|gradient)\\(/.test(shorthand) ? shorthand : shorthand.replace(/[a-z-]*gradient\\((?:[^()]|\\([^()]*\\))*\\)|url\\([^)]*\\)/g, ' '))\n const color = siteImportColorOf(colorValue)\n let gradient: SiteImportRgba[] | null = null\n let image: string | null = null\n const gradientMatch = /gradient\\(((?:[^()]|\\([^()]*\\))*)\\)/.exec(imageValue)\n if (gradientMatch) {\n const stops: SiteImportRgba[] = []\n for (const match of gradientMatch[1].matchAll(/#[0-9a-f]{3,8}\\b|rgba?\\([^)]*\\)|hsla?\\([^)]*\\)|\\b(?:white|black|transparent)\\b/gi)) {\n const stop = siteImportColorOf(match[0])\n if (stop) stops.push(stop)\n }\n if (stops.length) gradient = stops\n }\n const url = /url\\(\\s*([\"']?)([^\"')]+)\\1\\s*\\)/.exec(imageValue)\n if (url) image = url[2].trim()\n return { color: color && color.a > 0.02 ? color : null, gradient, image }\n}\n\n/** Whether an element draws a border on any side. */\nexport function siteImportHasBorder(style: SiteImportComputedStyle): boolean {\n const sides = ['border', 'border-top', 'border-bottom', 'border-left', 'border-right']\n for (const side of sides) {\n const value = style.get(side)\n if (!value) continue\n if (/\\bnone\\b|\\bhidden\\b/.test(value) || /^0(?:px)?$/.test(value.trim())) continue\n const color = siteImportColorOf(value) ?? siteImportColorOf(style.get('border-color'))\n if (color && color.a < 0.05) continue\n if (/\\d/.test(value) || /\\b(?:solid|dashed|dotted|double)\\b/.test(value)) {\n const width = /(-?[\\d.]+)px/.exec(value)\n if (!width || Number(width[1]) > 0) return true\n }\n }\n const width = style.get('border-width')\n const kind = style.get('border-style')\n if (kind && /\\b(?:solid|dashed|dotted|double)\\b/.test(kind) && (!width || !/^0(?:px)?$/.test(width.trim()))) return true\n return false\n}\n\n/** A side of an element's box. */\nexport type SiteImportSide = 'top' | 'right' | 'bottom' | 'left'\n\nconst SIDES: readonly SiteImportSide[] = ['top', 'right', 'bottom', 'left']\n\n/** One side's border, where it draws one: its width in px and its color as written. */\nexport interface SiteImportBorderSide {\n width: number\n color: SiteImportRgba | null\n}\n\n/**\n * The sides an element draws a border on (AGL-4138), each with its width and\n * color: a box is bordered on every side, a rule on one. The shorthand draws\n * all four; a side's own declaration, or `border-width` and `border-style`\n * by side, draw only theirs.\n */\nexport function siteImportBorderSides(style: SiteImportComputedStyle): Partial<Record<SiteImportSide, SiteImportBorderSide>> {\n const out: Partial<Record<SiteImportSide, SiteImportBorderSide>> = {}\n const shared = siteImportColorOf(style.get('border-color'))\n const drawn = (value: string | undefined): SiteImportBorderSide | null => {\n if (!value || /\\bnone\\b|\\bhidden\\b/.test(value) || /^0(?:px)?$/.test(value.trim())) return null\n const color = siteImportColorOf(value) ?? shared\n if (color && color.a < 0.05) return null\n if (!/\\d/.test(value) && !/\\b(?:solid|dashed|dotted|double)\\b/.test(value)) return null\n const width = /(-?[\\d.]+)(?:px)?(?:\\s|$)/.exec(value.replace(/#[0-9a-f]+|rgba?\\([^)]*\\)|hsla?\\([^)]*\\)/gi, ' '))\n const px = width ? Number(width[1]) : /\\bthick\\b/.test(value) ? 5 : /\\bthin\\b/.test(value) ? 1 : 3\n return px > 0 ? { width: px, color } : null\n }\n const all = drawn(style.get('border'))\n for (const side of SIDES) {\n const own = style.get(`border-${side}`)\n const found = own !== undefined ? drawn(own) : all\n if (found) out[side] = found\n }\n // `border-width` and `border-style` by side, where no shorthand drew a side.\n const kind = style.get('border-style')\n if (!Object.keys(out).length && kind && /\\b(?:solid|dashed|dotted|double)\\b/.test(kind)) {\n const widths = (style.get('border-width') ?? '3px').trim().split(/\\s+/)\n const by = [widths[0], widths[1] ?? widths[0], widths[2] ?? widths[0], widths[3] ?? widths[1] ?? widths[0]]\n SIDES.forEach((side, at) => {\n const px = siteImportLengthPx(by[at] ?? '')\n if (px !== null && px > 0) out[side] = { width: px, color: shared }\n })\n }\n return out\n}\n\n/** A picture box's `aspect-ratio`, width over height: `16 / 9`, `1.5`, `auto 4 / 3`; `null` where it sets none. */\nexport function siteImportAspectRatio(value: string | undefined): number | null {\n const match = /(\\d*\\.?\\d+)\\s*(?:\\/\\s*(\\d*\\.?\\d+))?/.exec((value ?? '').replace(/\\bauto\\b/g, ' '))\n if (!match) return null\n const width = Number(match[1])\n const height = match[2] === undefined ? 1 : Number(match[2])\n return width > 0 && height > 0 ? width / height : null\n}\n\n/** A color as it shows over the ground it sits on, its strength blended in: `rgba(0,0,0,.6)` over white is `#666666`. */\nexport function siteImportOpaque(color: SiteImportRgba, under: SiteImportRgba | null = null): SiteImportRgba {\n const ground = under ?? { r: 255, g: 255, b: 255, a: 1 }\n const a = Math.max(0, Math.min(1, color.a))\n return { r: color.r * a + ground.r * (1 - a), g: color.g * a + ground.g * (1 - a), b: color.b * a + ground.b * (1 - a), a: 1 }\n}\n\n/** How far apart two colors look, in OKLab (0 the same, about 1 black from white). */\nexport function siteImportColorDistance(a: SiteImportRgba, b: SiteImportRgba): number {\n const lab = (color: SiteImportRgba) => {\n const linear = (channel: number) => {\n const c = channel / 255\n return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n }\n const [r, g, bl] = [linear(color.r), linear(color.g), linear(color.b)]\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * bl)\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * bl)\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * bl)\n return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s]\n }\n const [x, y] = [lab(a), lab(b)]\n return Math.hypot((x[0] as number) - (y[0] as number), (x[1] as number) - (y[1] as number), (x[2] as number) - (y[2] as number))\n}\n\n/** Whether an element draws a shadow. */\nexport function siteImportHasShadow(style: SiteImportComputedStyle): boolean {\n const value = style.get('box-shadow')\n return !!value && !/^(?:none|0|initial|unset)$/.test(value.trim()) && !/^0(?:px)?\\s+0(?:px)?\\s+0(?:px)?(?:\\s+0(?:px)?)?\\s+(?:transparent|rgba\\([^)]*,\\s*0\\))/.test(value.trim())\n}\n\n/** An element's corner radius in px, or `null`. */\nexport function siteImportRadiusPx(style: SiteImportComputedStyle): number | null {\n const value = style.get('border-radius')\n if (!value) return null\n const first = value.trim().split(/[\\s/]+/)[0] ?? ''\n if (first.endsWith('%')) return Number(first.slice(0, -1)) >= 50 ? 999 : Number(first.slice(0, -1))\n return siteImportLengthPx(first)\n}\n\n/** A font size in px, or `null`. */\nexport function siteImportFontSizePx(style: SiteImportComputedStyle): number | null {\n const value = style.get('font-size')\n if (!value) return null\n const clamp = /clamp\\(([^,]+),([^,]+),([^)]+)\\)/.exec(value)\n // A fluid size at the read width: its maximum, as a wide screen shows it.\n const text = clamp ? clamp[3] : value\n return siteImportLengthPx(text.trim())\n}\n\n/** The relative widths a grid template draws its columns at, or `null` for none. */\nexport function siteImportGridColumns(template: string | undefined): number[] | null {\n if (!template || /^(?:none|subgrid|masonry)$/.test(template.trim())) return null\n let text = template.trim()\n // repeat(3, 1fr) / repeat(auto-fill, minmax(240px, 1fr)): the count, or three of them.\n text = text.replace(/repeat\\(\\s*([\\w-]+)\\s*,\\s*((?:[^()]|\\([^()]*\\))*)\\)/g, (_, count: string, track: string) => {\n const times = /^\\d+$/.test(count) ? Math.min(12, Number(count)) : 3\n return Array.from({ length: times }, () => track.trim()).join(' ')\n })\n const tracks: string[] = []\n let depth = 0\n let token = ''\n for (const char of text) {\n if (char === '(') depth += 1\n if (char === ')') depth -= 1\n if (/\\s/.test(char) && depth === 0) {\n if (token) tracks.push(token)\n token = ''\n } else token += char\n }\n if (token) tracks.push(token)\n const weights = tracks\n .filter((track) => !/^\\[.*\\]$/.test(track))\n .map((track) => {\n const fr = /(-?[\\d.]+)fr\\)?$/.exec(track)\n if (fr) return Number(fr[1]) || 1\n const px = /(-?[\\d.]+)px/.exec(track)\n if (px) return Number(px[1]) / 100\n const percent = /(-?[\\d.]+)%/.exec(track)\n if (percent) return Number(percent[1]) / 10\n return 1\n })\n return weights.length ? weights : null\n}\n\n/** Weights scaled to twelfths, each at least 1: `[420, 788]` is `[4, 8]`. */\nexport function siteImportTwelfths(weights: readonly number[]): number[] {\n const total = weights.reduce((sum, weight) => sum + Math.max(0, weight), 0)\n if (!total) return weights.map(() => 1)\n const scaled = weights.map((weight) => Math.max(1, Math.round((Math.max(0, weight) / total) * 12)))\n // Two equal tracks stay equal, three stay thirds.\n const unique = new Set(weights.map((weight) => Math.round(weight * 1000)))\n if (unique.size === 1) return weights.map(() => 1)\n return scaled\n}\n\n/** The families a `font-family` value names, quotes dropped, generic ones left out. */\nexport function siteImportFontFamilies(value: string | undefined): string[] {\n if (!value) return []\n return splitList(value)\n .map((family) => family.replace(/^[\"']|[\"']$/g, '').trim())\n .filter((family) => family && !/^(?:serif|sans-serif|monospace|cursive|fantasy|system-ui|ui-[\\w-]+|-apple-system|blinkmacsystemfont|inherit|initial|emoji|math|var\\(.*)$/i.test(family))\n}\n"],"names":["SITE_IMPORT_CSS_VIEWPORT","width","height","SITE_IMPORT_CSS_WIDE_WIDTH","KEPT_PROPERTIES","Set","INHERITED","unescapeIdent","text","replace","_","escaped","test","code","parseInt","trim","String","fromCodePoint","IDENT","raw","SIMPLE","RegExp","AT_REST","parseCompound","compound","tag","id","classes","attrs","root","rest","match","exec","slice","length","toLowerCase","push","name","op","value","has","parseSelector","compounds","combinators","parts","split","pending","part","ids","tags","specificity","splitList","out","depth","start","at","char","Math","max","map","filter","Boolean","siteImportLengthPx","amount","Number","mediaQueryHolds","query","viewport","scheme","negate","startsWith","holds","term","inner","feature","px","range","size","a","b","mediaHolds","prelude","list","some","DARK_SCOPE","withoutDarkScope","declarationsOf","body","decls","colon","indexOf","written","property","important","keyOf","selector","last","siteImportCssOf","sheets","options","css","rules","index","Map","fontFaces","darkRules","order","darkGroups","addRule","lifted","includes","rule","key","get","set","sheet","groups","end","pop","applies","every","family","classesOf","element","class","attributeOf","role","label","href","type","style","hidden","undefined","theme","compoundMatches","rootId","own","attr","wanted","ok","endsWith","selectorMatches","elements","above","parent","walk","combinator","siblings","children","position","before","sibling","EMPTY_STYLE","withVariables","custom","pass","fallback","inlineDeclarations","siteImportStylesOf","structure","resolved","rootStyle","fake","region","nav","blocks","candidates","apply","inline","unique","sort","put","flag","resolve","held","matched","lowered","inherited","delete","entry","of","NAMED_COLORS","white","black","red","green","blue","gray","grey","silver","whitesmoke","ghostwhite","snow","ivory","beige","linen","navy","teal","orange","gold","purple","crimson","tomato","coral","aliceblue","lightgray","lightgrey","gainsboro","darkslategray","dimgray","siteImportColorOf","hex","rgb","hsl","named","first","alphaOf","digits","full","d","join","r","g","channel","min","h","s","l","q","p","tone","t","x","known","siteImportHex","color","round","toString","padStart","siteImportLuminance","linear","c","siteImportSaturation","abs","siteImportBackgroundOf","shorthand","imageValue","colorValue","gradient","image","gradientMatch","stops","matchAll","stop","url","siteImportHasBorder","sides","side","kind","SIDES","siteImportBorderSides","shared","drawn","all","found","Object","keys","widths","by","forEach","siteImportAspectRatio","siteImportOpaque","under","ground","siteImportColorDistance","lab","bl","cbrt","m","y","hypot","siteImportHasShadow","siteImportRadiusPx","siteImportFontSizePx","clamp","siteImportGridColumns","template","count","track","times","Array","from","tracks","token","weights","fr","percent","siteImportTwelfths","total","reduce","sum","weight","scaled","siteImportFontFamilies"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;2CAuB2C,GAI3C,2EAA2E,GAC3E,OAAO,MAAMA,2BAA2B;IAAEC,OAAO;IAAMC,QAAQ;AAAI,EAAU;AAE7E;;;;;CAKC,GACD,OAAO,MAAMC,6BAA6B,KAAI;AAE9C,uGAAuG,GACvG,MAAMC,kBAAkB,IAAIC,IAAI;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,0FAA0F;IAC1F;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,uEAAuE,GACvE,MAAMC,YAAY,IAAID,IAAI;IAAC;IAAS;IAAe;IAAa;IAAe;IAAkB;IAAkB;IAAc;CAAa;AA0C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A,OAAOhH,OAAO,CAAC,gBAAgB,IAAIM,IAAI,IACvD6C,MAAM,CAAC,CAAC6D,SAAWA,UAAU,CAAC,4IAA4I7G,IAAI,CAAC6G;AACpL"}
@@ -146,6 +146,8 @@ export interface SiteImportExtract {
146
146
  description: string;
147
147
  lang: string | null;
148
148
  canonical: string | null;
149
+ /** Its head asks search engines not to list it: `<meta name="robots" content="noindex">` (AGL-4152). */
150
+ noindex: boolean;
149
151
  /** The share card, `og:image` (or `twitter:image`), as an absolute address (AGL-4083). */
150
152
  ogImage: string | null;
151
153
  /** The site's own name, `og:site_name` (or `application-name`); empty when absent. */
@@ -1386,6 +1386,7 @@ const P_WALLS = new Set([
1386
1386
  description: '',
1387
1387
  lang: null,
1388
1388
  canonical: null,
1389
+ noindex: false,
1389
1390
  ogImage: null,
1390
1391
  siteName: '',
1391
1392
  icons: [],
@@ -1452,6 +1453,7 @@ const P_WALLS = new Set([
1452
1453
  break;
1453
1454
  }
1454
1455
  }
1456
+ const noindex = readMetaValues(source, 'robots').some((value)=>/\b(?:noindex|none)\b/i.test(value));
1455
1457
  const bodyStart = source.search(/<body\b/i);
1456
1458
  const body = bodyStart >= 0 ? source.slice(bodyStart) : source.replace(/<head\b[\s\S]*?<\/head\s*>/i, ' ');
1457
1459
  const hasNav = /<nav\b/i.test(body);
@@ -1844,6 +1846,7 @@ const P_WALLS = new Set([
1844
1846
  description,
1845
1847
  lang,
1846
1848
  canonical,
1849
+ noindex,
1847
1850
  ogImage,
1848
1851
  siteName,
1849
1852
  icons,