@aglyn/plugins-ai 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/components/ai-insight-dialog.component.js +7 -2
- package/src/lib/components/ai-insight-dialog.component.js.map +1 -1
- package/src/lib/components/ai-job-request.component.d.ts +28 -0
- package/src/lib/components/ai-job-request.component.js +103 -0
- package/src/lib/components/ai-job-request.component.js.map +1 -0
- package/src/lib/components/ai-jobs-list-page.component.d.ts +2 -0
- package/src/lib/components/ai-jobs-list-page.component.js +2 -2
- package/src/lib/components/ai-jobs-list-page.component.js.map +1 -1
- package/src/lib/components/ai-site-build-page.component.js +36 -6
- package/src/lib/components/ai-site-build-page.component.js.map +1 -1
- package/src/lib/components/ai-site-import-job.component.js +2 -2
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/insights/ai-insight-digest.d.ts +34 -5
- package/src/lib/insights/ai-insight-digest.js +171 -10
- package/src/lib/insights/ai-insight-digest.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +35 -2
- package/src/lib/jobs/ai-job-import-step.js +124 -12
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-insight-step.d.ts +1 -1
- package/src/lib/jobs/ai-job-insight-step.js +5 -1
- package/src/lib/jobs/ai-job-insight-step.js.map +1 -1
- package/src/lib/jobs/ai-jobs.d.ts +6 -0
- package/src/lib/jobs/ai-jobs.js +43 -6
- package/src/lib/jobs/ai-jobs.js.map +1 -1
- package/src/lib/jobs/ai-layout-stock-photos.d.ts +13 -6
- package/src/lib/jobs/ai-layout-stock-photos.js +104 -32
- package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +110 -23
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.d.ts +5 -0
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-forms.d.ts +83 -0
- package/src/lib/jobs/ai-site-import-forms.js +376 -0
- package/src/lib/jobs/ai-site-import-forms.js.map +1 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.d.ts +21 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js +77 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js.map +1 -0
- package/src/lib/layout-language/ai-layout-compiler.d.ts +2 -0
- package/src/lib/layout-language/ai-layout-compiler.js +215 -30
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/model/ai-credit-estimate.d.ts +25 -22
- package/src/lib/model/ai-credit-estimate.js +24 -22
- package/src/lib/model/ai-credit-estimate.js.map +1 -1
- package/src/lib/model/ai-insight.d.ts +4 -0
- package/src/lib/model/ai-insight.js +1 -0
- package/src/lib/model/ai-insight.js.map +1 -1
- package/src/lib/model/ai-site-build-progress.d.ts +8 -0
- package/src/lib/model/ai-site-build-progress.js +62 -1
- package/src/lib/model/ai-site-build-progress.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +2 -0
- package/src/lib/model/ai-site-import-fidelity.js +41 -5
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-report.d.ts +60 -0
- package/src/lib/model/ai-site-import-report.js +116 -0
- package/src/lib/model/ai-site-import-report.js.map +1 -0
- package/src/lib/model/ai-site-import-view.d.ts +7 -1
- package/src/lib/model/ai-site-import-view.js +14 -2
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +49 -2
- package/src/lib/model/ai-site-import.js +81 -23
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/plugin.js +1 -1
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/runtime/ai-insight-check.js +22 -6
- package/src/lib/runtime/ai-insight-check.js.map +1 -1
- package/src/lib/server/ai-insight-digest-route.js +3 -1
- package/src/lib/server/ai-insight-digest-route.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +4 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +9 -4
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +10 -1
- package/src/lib/site-import/site-import-css.js +19 -12
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-html.d.ts +17 -4
- package/src/lib/site-import/site-import-html.js +146 -17
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.js +194 -32
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/tools/ai-insight-tool.js +11 -3
- package/src/lib/tools/ai-insight-tool.js.map +1 -1
|
@@ -19,10 +19,11 @@
|
|
|
19
19
|
* read what they find.
|
|
20
20
|
*
|
|
21
21
|
* `site-layout/` holds five pages of aglyn.com as AglynBot read them on
|
|
22
|
-
* 2026-10-28 and 2026-10-29 (home, product, pricing, contact, one blog post)
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* 2026-10-28 and 2026-10-29 (home, product, pricing, contact, one blog post),
|
|
23
|
+
* its pricing page again as it read on 2026-11-01, which a live import fell
|
|
24
|
+
* short on (`livePricing`), and one page in the markup a Squarespace site is
|
|
25
|
+
* built with, written for these specs about a studio that does not exist, so
|
|
26
|
+
* the readers are never tuned to one site's markup.
|
|
26
27
|
*
|
|
27
28
|
* The aglyn.com recordings keep what the `aglyn-com/` ones dropped and the
|
|
28
29
|
* layout is made of: class names, inline icons and the page's own stylesheet.
|
|
@@ -54,6 +55,10 @@ export const SITE_LAYOUT_POTTERY_ORIGIN = 'https://www.tidewater-pottery.example
|
|
|
54
55
|
file: 'aglyn-pricing.html',
|
|
55
56
|
url: `${SITE_LAYOUT_AGLYN_ORIGIN}/pricing`
|
|
56
57
|
},
|
|
58
|
+
livePricing: {
|
|
59
|
+
file: 'aglyn-pricing-2026-11.html',
|
|
60
|
+
url: `${SITE_LAYOUT_AGLYN_ORIGIN}/pricing`
|
|
61
|
+
},
|
|
57
62
|
contact: {
|
|
58
63
|
file: 'aglyn-contact.html',
|
|
59
64
|
url: `${SITE_LAYOUT_AGLYN_ORIGIN}/contact`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/ai/src/lib/site-import/fixtures/site-layout-recordings.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 * Pages recorded with their layout (AGL-4106), for the specs of the layout,\n * menu and stylesheet readers, and for the compile and fidelity specs that\n * read what they find.\n *\n * `site-layout/` holds five pages of aglyn.com as AglynBot read them on\n * 2026-10-28 and 2026-10-29 (home, product, pricing, contact, one blog post)\n * and one page in the markup a Squarespace site is built with, written for
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/ai/src/lib/site-import/fixtures/site-layout-recordings.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 * Pages recorded with their layout (AGL-4106), for the specs of the layout,\n * menu and stylesheet readers, and for the compile and fidelity specs that\n * read what they find.\n *\n * `site-layout/` holds five pages of aglyn.com as AglynBot read them on\n * 2026-10-28 and 2026-10-29 (home, product, pricing, contact, one blog post),\n * its pricing page again as it read on 2026-11-01, which a live import fell\n * short on (`livePricing`), and one page in the markup a Squarespace site is\n * built with, written for these specs about a studio that does not exist, so\n * the readers are never tuned to one site's markup.\n *\n * The aglyn.com recordings keep what the `aglyn-com/` ones dropped and the\n * layout is made of: class names, inline icons and the page's own stylesheet.\n * Each was trimmed before it entered the repo: script bodies are gone (one\n * small inline script with a hostile line stands in for them; the\n * structured data stays), so are preload links, `data-*` attributes and\n * `srcset`s; the stylesheet keeps only the rules for classes the page uses\n * and the properties the readers read; class names the kept rules do not name\n * are dropped, a grid framework's own hints kept; the pricing page keeps the\n * first 14 rows of its plan table, and the product, pricing, contact and blog\n * pages their header menu without its panels and their footer's © line. The\n * home page keeps its header and footer whole, for the menu reader. Every\n * address, phone number, author and profile is a placeholder.\n */\n\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nconst DIR = join(__dirname, 'site-layout')\n\nexport const SITE_LAYOUT_AGLYN_ORIGIN = 'https://aglyn.com'\nexport const SITE_LAYOUT_POTTERY_ORIGIN = 'https://www.tidewater-pottery.example'\n\n/** The recorded pages, by name: the file and the address it was read from. */\nexport const SITE_LAYOUT_PAGES = {\n home: { file: 'aglyn-home.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/` },\n product: { file: 'aglyn-product.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/product` },\n pricing: { file: 'aglyn-pricing.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/pricing` },\n livePricing: { file: 'aglyn-pricing-2026-11.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/pricing` },\n contact: { file: 'aglyn-contact.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/contact` },\n post: { file: 'aglyn-blog-post.html', url: `${SITE_LAYOUT_AGLYN_ORIGIN}/blog/multi-site-cost-sheet-2026` },\n pottery: { file: 'squarespace-pottery.html', url: `${SITE_LAYOUT_POTTERY_ORIGIN}/` },\n} as const\n\nexport type SiteLayoutPageName = keyof typeof SITE_LAYOUT_PAGES\n\nconst cache = new Map<string, string>()\n\n/** One recorded page's markup. */\nexport function siteLayoutRecording(name: SiteLayoutPageName): string {\n const { file } = SITE_LAYOUT_PAGES[name]\n const held = cache.get(file)\n if (held !== undefined) return held\n const text = readFileSync(join(DIR, file), 'utf8')\n cache.set(file, text)\n return text\n}\n\n/** Whether an address is on the recorded page's own site. */\nexport function siteLayoutSameSite(name: SiteLayoutPageName): (url: URL) => boolean {\n const origin = new URL(SITE_LAYOUT_PAGES[name].url).origin\n const bare = origin.replace('://www.', '://')\n const www = origin.replace('://', '://www.').replace('://www.www.', '://www.')\n return (url) => url.origin === origin || url.origin === bare || url.origin === www\n}\n"],"names":["readFileSync","join","DIR","__dirname","SITE_LAYOUT_AGLYN_ORIGIN","SITE_LAYOUT_POTTERY_ORIGIN","SITE_LAYOUT_PAGES","home","file","url","product","pricing","livePricing","contact","post","pottery","cache","Map","siteLayoutRecording","name","held","get","undefined","text","set","siteLayoutSameSite","origin","URL","bare","replace","www"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GAED,SAASA,YAAY,QAAQ,UAAS;AACtC,SAASC,IAAI,QAAQ,YAAW;AAEhC,MAAMC,MAAMD,KAAKE,WAAW;AAE5B,OAAO,MAAMC,2BAA2B,oBAAmB;AAC3D,OAAO,MAAMC,6BAA6B,wCAAuC;AAEjF,4EAA4E,GAC5E,OAAO,MAAMC,oBAAoB;IAC/BC,MAAM;QAAEC,MAAM;QAAmBC,KAAK,GAAGL,yBAAyB,CAAC,CAAC;IAAC;IACrEM,SAAS;QAAEF,MAAM;QAAsBC,KAAK,G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
};
|
|
23
|
+
/**
|
|
24
|
+
* The width a page's column is read at (AGL-4083). A container caps itself
|
|
25
|
+
* only on screens wider than its cap (`@media (min-width:1536px)` around a
|
|
26
|
+
* `max-width:1536px`), so on a laptop it runs the whole page: read there, it
|
|
27
|
+
* would look as if it had no cap at all.
|
|
28
|
+
*/
|
|
29
|
+
export declare const SITE_IMPORT_CSS_WIDE_WIDTH = 1920;
|
|
23
30
|
interface Compound {
|
|
24
31
|
tag: string | null;
|
|
25
32
|
id: string | null;
|
|
@@ -52,11 +59,13 @@ export interface SiteImportCss {
|
|
|
52
59
|
/** Families its `@font-face` rules name, in order. */
|
|
53
60
|
fontFaces: string[];
|
|
54
61
|
}
|
|
62
|
+
/** A length in px at the read width; `em`/`rem` at 16. */
|
|
63
|
+
export declare function siteImportLengthPx(value: string): number | null;
|
|
55
64
|
/**
|
|
56
65
|
* The page's sheets parsed for a wide screen. Malformed CSS is read as far as
|
|
57
66
|
* it makes sense, as a browser would; nothing throws.
|
|
58
67
|
*/
|
|
59
|
-
export declare function siteImportCssOf(sheets: readonly string[]): SiteImportCss;
|
|
68
|
+
export declare function siteImportCssOf(sheets: readonly string[], viewport?: number): SiteImportCss;
|
|
60
69
|
/** One element's resolved style: the kept properties, `var()` read, lowercased. */
|
|
61
70
|
export type SiteImportComputedStyle = ReadonlyMap<string, string>;
|
|
62
71
|
/** Reads elements' styles over a page's structure, each once. */
|
|
@@ -40,6 +40,12 @@
|
|
|
40
40
|
width: 1280,
|
|
41
41
|
height: 800
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* The width a page's column is read at (AGL-4083). A container caps itself
|
|
45
|
+
* only on screens wider than its cap (`@media (min-width:1536px)` around a
|
|
46
|
+
* `max-width:1536px`), so on a laptop it runs the whole page: read there, it
|
|
47
|
+
* would look as if it had no cap at all.
|
|
48
|
+
*/ export const SITE_IMPORT_CSS_WIDE_WIDTH = 1920;
|
|
43
49
|
/** The properties the layout reader reads; every other declaration is dropped as the sheet is parsed. */ const KEPT_PROPERTIES = new Set([
|
|
44
50
|
'background',
|
|
45
51
|
'background-color',
|
|
@@ -197,13 +203,13 @@ const SIMPLE = new RegExp(String.raw`^(?:(\*|${IDENT})|#(${IDENT})|\.(${IDENT})|
|
|
|
197
203
|
out.push(text.slice(start));
|
|
198
204
|
return out.map((part)=>part.trim()).filter(Boolean);
|
|
199
205
|
}
|
|
200
|
-
/** A length in px at the read width; `em`/`rem` at 16. */ function
|
|
206
|
+
/** A length in px at the read width; `em`/`rem` at 16. */ export function siteImportLengthPx(value) {
|
|
201
207
|
const match = /^(-?\d*\.?\d+)\s*(px|em|rem)?$/i.exec(value.trim());
|
|
202
208
|
if (!match) return null;
|
|
203
209
|
const amount = Number(match[1]);
|
|
204
210
|
return match[2] && match[2].toLowerCase() !== 'px' ? amount * 16 : amount;
|
|
205
211
|
}
|
|
206
|
-
/** Whether one media query holds for a light-mode screen of
|
|
212
|
+
/** Whether one media query holds for a light-mode screen of this width. */ function mediaQueryHolds(query, viewport) {
|
|
207
213
|
let text = query.trim().toLowerCase();
|
|
208
214
|
let negate = false;
|
|
209
215
|
if (text.startsWith('not ')) {
|
|
@@ -221,10 +227,11 @@ const SIMPLE = new RegExp(String.raw`^(?:(\*|${IDENT})|#(${IDENT})|\.(${IDENT})|
|
|
|
221
227
|
}
|
|
222
228
|
const inner = term.replace(/^\(|\)$/g, '').trim();
|
|
223
229
|
const feature = /^([\w-]+)\s*:\s*(.+)$/.exec(inner);
|
|
224
|
-
const {
|
|
230
|
+
const { height } = SITE_IMPORT_CSS_VIEWPORT;
|
|
231
|
+
const width = viewport;
|
|
225
232
|
if (feature) {
|
|
226
233
|
const [, name, value] = feature;
|
|
227
|
-
const px =
|
|
234
|
+
const px = siteImportLengthPx(value);
|
|
228
235
|
if (name === 'min-width') holds && (holds = px !== null && width >= px);
|
|
229
236
|
else if (name === 'max-width') holds && (holds = px !== null && width <= px);
|
|
230
237
|
else if (name === 'min-height') holds && (holds = px !== null && height >= px);
|
|
@@ -243,20 +250,20 @@ const SIMPLE = new RegExp(String.raw`^(?:(\*|${IDENT})|#(${IDENT})|\.(${IDENT})|
|
|
|
243
250
|
const size = range[3] === 'width' ? width : height;
|
|
244
251
|
const test = (a, op, b)=>op === '<' ? a < b : op === '<=' ? a <= b : op === '>' ? a > b : a >= b;
|
|
245
252
|
if (range[1] && range[2]) {
|
|
246
|
-
const px =
|
|
253
|
+
const px = siteImportLengthPx(range[1]);
|
|
247
254
|
holds && (holds = px !== null && test(px, range[2], size));
|
|
248
255
|
}
|
|
249
256
|
if (range[4] && range[5]) {
|
|
250
|
-
const px =
|
|
257
|
+
const px = siteImportLengthPx(range[5]);
|
|
251
258
|
holds && (holds = px !== null && test(size, range[4], px));
|
|
252
259
|
}
|
|
253
260
|
}
|
|
254
261
|
}
|
|
255
262
|
return negate ? !holds : holds;
|
|
256
263
|
}
|
|
257
|
-
function mediaHolds(prelude) {
|
|
264
|
+
function mediaHolds(prelude, viewport) {
|
|
258
265
|
const list = splitList(prelude.replace(/^@media\s*/i, ''));
|
|
259
|
-
return !list.length || list.some(mediaQueryHolds);
|
|
266
|
+
return !list.length || list.some((query)=>mediaQueryHolds(query, viewport));
|
|
260
267
|
}
|
|
261
268
|
function declarationsOf(body) {
|
|
262
269
|
const decls = [];
|
|
@@ -290,7 +297,7 @@ function declarationsOf(body) {
|
|
|
290
297
|
/**
|
|
291
298
|
* The page's sheets parsed for a wide screen. Malformed CSS is read as far as
|
|
292
299
|
* it makes sense, as a browser would; nothing throws.
|
|
293
|
-
*/ export function siteImportCssOf(sheets) {
|
|
300
|
+
*/ export function siteImportCssOf(sheets, viewport = SITE_IMPORT_CSS_VIEWPORT.width) {
|
|
294
301
|
const css = {
|
|
295
302
|
rules: [],
|
|
296
303
|
index: new Map(),
|
|
@@ -348,7 +355,7 @@ function declarationsOf(body) {
|
|
|
348
355
|
const prelude = text.slice(start, at).trim();
|
|
349
356
|
const applies = groups.every(Boolean);
|
|
350
357
|
if (/^@(?:media)\b/i.test(prelude)) {
|
|
351
|
-
groups.push(applies && mediaHolds(prelude));
|
|
358
|
+
groups.push(applies && mediaHolds(prelude, viewport));
|
|
352
359
|
start = at = at + 1;
|
|
353
360
|
continue;
|
|
354
361
|
}
|
|
@@ -766,7 +773,7 @@ const NAMED_COLORS = {
|
|
|
766
773
|
if (!value) return null;
|
|
767
774
|
const first = (_value_trim_split_ = value.trim().split(/[\s/]+/)[0]) != null ? _value_trim_split_ : '';
|
|
768
775
|
if (first.endsWith('%')) return Number(first.slice(0, -1)) >= 50 ? 999 : Number(first.slice(0, -1));
|
|
769
|
-
return
|
|
776
|
+
return siteImportLengthPx(first);
|
|
770
777
|
}
|
|
771
778
|
/** A font size in px, or `null`. */ export function siteImportFontSizePx(style) {
|
|
772
779
|
const value = style.get('font-size');
|
|
@@ -774,7 +781,7 @@ const NAMED_COLORS = {
|
|
|
774
781
|
const clamp = /clamp\(([^,]+),([^,]+),([^)]+)\)/.exec(value);
|
|
775
782
|
// A fluid size at the read width: its maximum, as a wide screen shows it.
|
|
776
783
|
const text = clamp ? clamp[3] : value;
|
|
777
|
-
return
|
|
784
|
+
return siteImportLengthPx(text.trim());
|
|
778
785
|
}
|
|
779
786
|
/** The relative widths a grid template draws its columns at, or `null` for none. */ export function siteImportGridColumns(template) {
|
|
780
787
|
if (!template || /^(?:none|subgrid|masonry)$/.test(template.trim())) return null;
|
|
@@ -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/** 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 '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. */\nfunction lengthPx(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 the read width. */\nfunction mediaQueryHolds(query: string): 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 { width, height } = SITE_IMPORT_CSS_VIEWPORT\n if (feature) {\n const [, name, value] = feature\n const px = lengthPx(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 = lengthPx(range[1])\n holds &&= px !== null && test(px, range[2], size)\n }\n if (range[4] && range[5]) {\n const px = lengthPx(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): boolean {\n const list = splitList(prelude.replace(/^@media\\s*/i, ''))\n return !list.length || list.some(mediaQueryHolds)\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[]): 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))\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/** 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 lengthPx(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 lengthPx(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","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","lengthPx","amount","Number","mediaQueryHolds","query","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","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,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;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;AAkC9I;;2CAE2C,GAE3C,SAASE,cAAcC,IAAY;IACjC,OAAOA,KAAKC,OAAO,CAAC,8BAA8B,CAACC,GAAGC;QACpD,IAAI,wBAAwBC,IAAI,CAACD,UAAU;YACzC,MAAME,OAA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/**\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 '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/** 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","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,2BAA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AAS;IACzE,IAAI,CAACH,OAAO,OAAOJ,QAAQ9M,GAAG,CAAC,IAAM;IACrC,MAAMsN,SAASR,QAAQ9M,GAAG,CAAC,CAACqN,SAAWvN,KAAKC,GAAG,CAAC,GAAGD,KAAK4K,KAAK,CAAC,AAAC5K,KAAKC,GAAG,CAAC,GAAGsN,UAAUH,QAAS;IAC9F,kDAAkD;IAClD,MAAM3G,SAAS,IAAI7J,IAAIoQ,QAAQ9M,GAAG,CAAC,CAACqN,SAAWvN,KAAK4K,KAAK,CAAC2C,SAAS;IACnE,IAAI9G,OAAOtF,IAAI,KAAK,GAAG,OAAO6L,QAAQ9M,GAAG,CAAC,IAAM;IAChD,OAAOsN;AACT;AAEA,qFAAqF,GACrF,OAAO,SAASC,uBAAuB3O,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"}
|
|
@@ -96,12 +96,25 @@ export interface SiteImportNavLink {
|
|
|
96
96
|
text: string;
|
|
97
97
|
url: string;
|
|
98
98
|
}
|
|
99
|
+
/** One field of a form that was kept: what it asks, never what was typed (AGL-4083). */
|
|
100
|
+
export interface SiteImportFormField {
|
|
101
|
+
/** `text`, `email`, `tel`, `url`, `number`, `date`, `time`, `textarea`, `select`, `radio` or `checkbox`. */
|
|
102
|
+
type: string;
|
|
103
|
+
name: string;
|
|
104
|
+
/** The words a visitor reads for it. Absent on a read kept before they were. */
|
|
105
|
+
label?: string;
|
|
106
|
+
required?: true;
|
|
107
|
+
/** A list's choices, or the boxes of one question. */
|
|
108
|
+
options?: string[];
|
|
109
|
+
placeholder?: string;
|
|
110
|
+
}
|
|
99
111
|
/** A form that was kept: what it asks, never what was typed. */
|
|
100
112
|
export interface SiteImportForm {
|
|
101
|
-
fields:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
fields: SiteImportFormField[];
|
|
114
|
+
/** The words on its button. */
|
|
115
|
+
submit?: string;
|
|
116
|
+
/** The fields no form element can take, by the words they ask with: a file to attach. */
|
|
117
|
+
leftOut?: string[];
|
|
105
118
|
}
|
|
106
119
|
export interface SiteImportExtract {
|
|
107
120
|
title: string;
|