@aglyn/plugins-ai 1.11.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/components/ai-media-create.component.js +1 -1
- package/src/lib/components/ai-media-create.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.js +1 -1
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +1 -1
- package/src/lib/jobs/ai-job-import-step.js +37 -8
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-privacy-step.js +2 -2
- package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +27 -37
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +19 -4
- package/src/lib/jobs/ai-site-import-look.js +162 -46
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/jobs/ai-theme-brand-inputs.d.ts +12 -0
- package/src/lib/jobs/ai-theme-brand-inputs.js +1 -1
- package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +7 -1
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/model/ai-credit-estimate.d.ts +15 -0
- package/src/lib/model/ai-credit-estimate.js +13 -0
- package/src/lib/model/ai-credit-estimate.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +46 -3
- package/src/lib/model/ai-site-import-fidelity.js +254 -62
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-report.d.ts +7 -0
- package/src/lib/model/ai-site-import-report.js +17 -5
- package/src/lib/model/ai-site-import-report.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +75 -4
- package/src/lib/model/ai-site-import.js +34 -11
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +16 -0
- package/src/lib/model/ai-site-look.js +76 -14
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/model/ai-upsell-copy.js +1 -1
- package/src/lib/model/ai-upsell-copy.js.map +1 -1
- package/src/lib/site-import/fixtures/aglyn-com-recordings.d.ts +2 -1
- package/src/lib/site-import/fixtures/aglyn-com-recordings.js +3 -2
- package/src/lib/site-import/fixtures/aglyn-com-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.d.ts +5 -0
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.js +116 -3
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +7 -0
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +15 -0
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +32 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +59 -3
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-look-slate.d.ts +2 -1
- package/src/lib/site-import/fixtures/site-look-slate.js +2 -1
- package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -1
- package/src/lib/site-import/site-import-crawl.d.ts +9 -1
- package/src/lib/site-import/site-import-crawl.js +128 -23
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +89 -1
- package/src/lib/site-import/site-import-css.js +468 -28
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-data-forms.d.ts +32 -0
- package/src/lib/site-import/site-import-data-forms.js +531 -0
- package/src/lib/site-import/site-import-data-forms.js.map +1 -0
- package/src/lib/site-import/site-import-html.d.ts +10 -1
- package/src/lib/site-import/site-import-html.js +21 -5
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +9 -2
- package/src/lib/site-import/site-import-layout.js +383 -62
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/site-import/site-import-nav.js +17 -3
- package/src/lib/site-import/site-import-nav.js.map +1 -1
- package/src/lib/site-import/site-import-page.js +5 -0
- package/src/lib/site-import/site-import-page.js.map +1 -1
- package/src/lib/site-import/site-import-same-page.d.ts +41 -0
- package/src/lib/site-import/site-import-same-page.js +108 -0
- package/src/lib/site-import/site-import-same-page.js.map +1 -0
|
@@ -35,6 +35,13 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
35
35
|
* columns, a flex row, a grid framework's row and cells, a table row) is a
|
|
36
36
|
* row; its columns' widths come from the grid template, the cells' sizes
|
|
37
37
|
* or equal shares, in twelfths.
|
|
38
|
+
* - **Placement (AGL-4152).** A grid whose children name where they go is read
|
|
39
|
+
* in the rows and columns a visitor sees, whatever order its markup writes
|
|
40
|
+
* them in: each child's box from its `grid-area`, `grid-row` or
|
|
41
|
+
* `grid-column`, cells by row overlap and then column overlap, and rows
|
|
42
|
+
* built to the same columns stacked into those columns, so a card's words
|
|
43
|
+
* stay under its own heading. What comes out is rows, cells and groups like
|
|
44
|
+
* any others. `order` on a flex or grid child is read the same way.
|
|
38
45
|
* - **Groups.** Three or more siblings built alike (the same elements in the
|
|
39
46
|
* same order) are a group, and what they hold says its kind: icon or
|
|
40
47
|
* picture with a title and words are `cards`, a leading number `steps`, a
|
|
@@ -56,7 +63,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
56
63
|
* never the rule: the reader reads what an element draws, through the page's
|
|
57
64
|
* own stylesheets (`site-import-css.ts`). Nothing a page wrote runs.
|
|
58
65
|
*=========================================*/ import { AI_SITE_IMPORT_MAX_SECTIONS, siteImportFilterNodes, siteImportLayoutLines } from "../model/ai-site-import.js";
|
|
59
|
-
import { SITE_IMPORT_CSS_WIDE_WIDTH, siteImportAspectRatio, siteImportBackgroundOf, siteImportBorderSides, siteImportColorDistance, siteImportColorOf, siteImportCssOf, siteImportFontFamilies, siteImportFontSizePx, siteImportGridColumns, siteImportHasBorder, siteImportHasShadow, siteImportHex, siteImportLengthPx, siteImportLuminance, siteImportOpaque, siteImportRadiusPx, siteImportSaturation, siteImportStylesOf, siteImportTwelfths } from "./site-import-css.js";
|
|
66
|
+
import { SITE_IMPORT_CSS_WIDE_WIDTH, siteImportAspectRatio, siteImportBackgroundOf, siteImportBorderSides, siteImportColorDistance, siteImportColorOf, siteImportCssOf, siteImportPaletteOf, siteImportFontFamilies, siteImportFontSizePx, siteImportGridBoxes, siteImportGridColumns, siteImportHasBorder, siteImportHasShadow, siteImportHex, siteImportLengthPx, siteImportLuminance, siteImportOpaque, siteImportOrderOf, siteImportRadiusPx, siteImportSaturation, siteImportStylesOf, siteImportTwelfths } from "./site-import-css.js";
|
|
60
67
|
import { extractSiteImportPage } from "./site-import-html.js";
|
|
61
68
|
import { siteImportLabel } from "./site-import-page.js";
|
|
62
69
|
const isElementPart = (part)=>'element' in part;
|
|
@@ -67,8 +74,8 @@ const isElementPart = (part)=>'element' in part;
|
|
|
67
74
|
}
|
|
68
75
|
const BUTTON_CLASS = /(?:^|[\s_-])(?:btn|button)(?:$|[\s_-])|Button-root|wp-block-button__link|sqs-block-button-element|elementor-button|w-button/i;
|
|
69
76
|
const TEXT_BUTTON_CLASS = /MuiButton-text\b|btn-link\b|is-style-text/i;
|
|
70
|
-
const OUTLINED_CLASS = /MuiButton-outlined\b|btn-outline|is-style-outline|--outline
|
|
71
|
-
const FILLED_CLASS = /MuiButton-contained\b|btn-primary
|
|
77
|
+
/** An element's own `--primary` or `--secondary` (AGL-4152), whatever it is called, never a longer name that starts so (`--primary-inverse`). */ const OUTLINED_CLASS = /MuiButton-outlined\b|btn-outline|is-style-outline|--outline|--secondary(?=\s|$)|btn-secondary/i;
|
|
78
|
+
const FILLED_CLASS = /MuiButton-contained\b|btn-primary|--primary(?=\s|$)|--solid|is-style-fill/i;
|
|
72
79
|
const LANDMARK_TAGS = new Set([
|
|
73
80
|
'section',
|
|
74
81
|
'article',
|
|
@@ -134,13 +141,13 @@ const STATEMENT_MIN_WEIGHT = 600;
|
|
|
134
141
|
*/ export function siteImportLayout(page, stylesheets = []) {
|
|
135
142
|
const { structure, blocks } = page;
|
|
136
143
|
if (!structure) return null;
|
|
137
|
-
const { css, styles, sections } = readSections(page, stylesheets);
|
|
144
|
+
const { css, styles, darkStyles, sections } = readSections(page, stylesheets);
|
|
138
145
|
if (!sections.length) return null;
|
|
139
146
|
return {
|
|
140
147
|
v: 1,
|
|
141
148
|
sections,
|
|
142
149
|
icons: structure.icons.map((icon)=>_extends({}, icon)),
|
|
143
|
-
look: siteImportLookFacts(structure, styles, css.fontFaces, blocks, sections)
|
|
150
|
+
look: siteImportLookFacts(structure, styles, css.fontFaces, blocks, sections, darkStyles, css.variableUses)
|
|
144
151
|
};
|
|
145
152
|
}
|
|
146
153
|
/** A page's sections, as the layout reads them, with the stylesheets and styles they were read through. */ function readSections(page, stylesheets) {
|
|
@@ -152,14 +159,136 @@ const STATEMENT_MIN_WEIGHT = 600;
|
|
|
152
159
|
];
|
|
153
160
|
const css = siteImportCssOf(sheets);
|
|
154
161
|
const styles = siteImportStylesOf(structure, css);
|
|
155
|
-
const
|
|
162
|
+
const darkStyles = siteImportDarkStylesOf(structure, sheets);
|
|
163
|
+
const reader = new LayoutReader(structure, blocks, styles, ()=>siteImportStylesOf(structure, siteImportCssOf(sheets, SITE_IMPORT_CSS_WIDE_WIDTH)), ()=>siteImportStylesOf(structure, siteImportCssOf(sheets, TABLET_WIDTH)), (_page_videos = page.videos) != null ? _page_videos : [], darkStyles);
|
|
156
164
|
return {
|
|
157
165
|
css,
|
|
158
166
|
styles,
|
|
167
|
+
darkStyles,
|
|
159
168
|
sections: reader.sections()
|
|
160
169
|
};
|
|
161
170
|
}
|
|
171
|
+
/** A page's styles in its dark scheme (AGL-4152), `null` where its stylesheets say nothing of one. */ function siteImportDarkStylesOf(structure, sheets) {
|
|
172
|
+
if (!sheets.some((sheet)=>/dark/i.test(sheet))) return null;
|
|
173
|
+
const css = siteImportCssOf(sheets, undefined, {
|
|
174
|
+
scheme: 'dark'
|
|
175
|
+
});
|
|
176
|
+
return css.darkRules ? siteImportStylesOf(structure, css) : null;
|
|
177
|
+
}
|
|
162
178
|
let LayoutReader = class LayoutReader {
|
|
179
|
+
/*---------------- what a grid or `order` moves (AGL-4152) ----------------*/ /**
|
|
180
|
+
* The page as a visitor reads it: each flex or grid container whose children
|
|
181
|
+
* say where they go, inner ones first, has its children set in that order.
|
|
182
|
+
* Every container that says nothing is untouched, its order the markup's.
|
|
183
|
+
*/ readPlacement() {
|
|
184
|
+
for(let id = this.elements.length - 1; id >= 0; id -= 1){
|
|
185
|
+
var _style_get;
|
|
186
|
+
const node = this.elements[id];
|
|
187
|
+
if (node.region !== 'main' || node.nav || node.children.length < 2) continue;
|
|
188
|
+
const style = this.style(id);
|
|
189
|
+
const display = (_style_get = style.get('display')) != null ? _style_get : '';
|
|
190
|
+
if (!/\b(?:grid|flex)\b/.test(display)) continue;
|
|
191
|
+
if (/\bgrid\b/.test(display) && this.readGrid(id, style)) continue;
|
|
192
|
+
this.readOrder(id);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/** A row's or a grid's children in their `order`, where any sets one. */ readOrder(element) {
|
|
196
|
+
const node = this.elements[element];
|
|
197
|
+
const orderOf = (child)=>siteImportOrderOf(this.style(child));
|
|
198
|
+
const content = node.children.filter((child)=>this.leaves(child).length);
|
|
199
|
+
if (!content.some((child)=>orderOf(child) !== 0)) return;
|
|
200
|
+
const sorted = content.map((child, at)=>({
|
|
201
|
+
child,
|
|
202
|
+
at
|
|
203
|
+
})).sort((a, b)=>orderOf(a.child) - orderOf(b.child) || a.at - b.at).map((entry)=>entry.child);
|
|
204
|
+
this.setChildren(element, [
|
|
205
|
+
...sorted,
|
|
206
|
+
...node.children.filter((child)=>!content.includes(child))
|
|
207
|
+
]);
|
|
208
|
+
this.moveLeaves(sorted);
|
|
209
|
+
}
|
|
210
|
+
/** A grid read by its children's boxes; `false`, and nothing changed, where they do not say where they go. */ readGrid(grid, style) {
|
|
211
|
+
const node = this.elements[grid];
|
|
212
|
+
// What is not drawn takes no cell: it stays where it is read, after what is.
|
|
213
|
+
const content = node.children.filter((child)=>this.leaves(child).length && this.style(child).get('display') !== 'none');
|
|
214
|
+
if (content.length < 2) return false;
|
|
215
|
+
const boxes = siteImportGridBoxes(style, content.map((child)=>this.style(child)));
|
|
216
|
+
if (!boxes) return false;
|
|
217
|
+
const items = content.map((element, at)=>{
|
|
218
|
+
const lines = this.leaves(element).filter((leaf)=>leaf.kind === 'line').map((leaf)=>{
|
|
219
|
+
var _this_block;
|
|
220
|
+
return (_this_block = this.block(leaf)) == null ? void 0 : _this_block.kind;
|
|
221
|
+
});
|
|
222
|
+
return {
|
|
223
|
+
element,
|
|
224
|
+
box: boxes[at],
|
|
225
|
+
words: lines.some((kind)=>kind !== 'image'),
|
|
226
|
+
heading: lines.includes('heading'),
|
|
227
|
+
picture: lines.includes('image') || this.leaves(element).some((leaf)=>leaf.kind === 'video')
|
|
228
|
+
};
|
|
229
|
+
});
|
|
230
|
+
for (const item of items)if (!item.words && items.some((other)=>other.words && overLaid(other.box, item.box))) this.placedBehind.add(item.element);
|
|
231
|
+
const bands = siteImportGridBands(items, (item)=>this.placedBehind.has(item.element));
|
|
232
|
+
const children = bands.flatMap((band)=>band.length === 1 ? band[0].items.map((item)=>item.element) : [
|
|
233
|
+
this.drawnRow(grid, band)
|
|
234
|
+
]);
|
|
235
|
+
const rest = node.children.filter((child)=>!content.includes(child));
|
|
236
|
+
this.setChildren(grid, [
|
|
237
|
+
...children,
|
|
238
|
+
...rest
|
|
239
|
+
]);
|
|
240
|
+
this.placed.set(grid, 'stack');
|
|
241
|
+
this.moveLeaves([
|
|
242
|
+
...bands.flat().flatMap((cell)=>cell.items.map((item)=>item.element)),
|
|
243
|
+
...rest
|
|
244
|
+
]);
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
/** A row a placed grid draws: its cells side by side, each one child or the children stacked in it. */ drawnRow(grid, cells) {
|
|
248
|
+
const row = this.drawnElement(grid);
|
|
249
|
+
this.placed.set(row, 'row');
|
|
250
|
+
this.setChildren(row, cells.map((cell)=>{
|
|
251
|
+
const only = cell.items.length === 1 ? cell.items[0].element : null;
|
|
252
|
+
const held = only != null ? only : this.drawnElement(row);
|
|
253
|
+
if (only === null) this.setChildren(held, cell.items.map((item)=>item.element));
|
|
254
|
+
this.placedWidth.set(held, cell.end - cell.start);
|
|
255
|
+
return held;
|
|
256
|
+
}));
|
|
257
|
+
return row;
|
|
258
|
+
}
|
|
259
|
+
/** A box the page does not write but draws, styled by nothing: its id is past every written element's. */ drawnElement(parent) {
|
|
260
|
+
const { region, nav } = this.elements[parent];
|
|
261
|
+
const id = this.elements.length;
|
|
262
|
+
this.elements.push({
|
|
263
|
+
id,
|
|
264
|
+
tag: 'div',
|
|
265
|
+
parent,
|
|
266
|
+
children: [],
|
|
267
|
+
region,
|
|
268
|
+
nav,
|
|
269
|
+
attrs: {},
|
|
270
|
+
blocks: []
|
|
271
|
+
});
|
|
272
|
+
this.own.push([]);
|
|
273
|
+
return id;
|
|
274
|
+
}
|
|
275
|
+
setChildren(element, children) {
|
|
276
|
+
this.elements[element] = _extends({}, this.elements[element], {
|
|
277
|
+
children
|
|
278
|
+
});
|
|
279
|
+
for (const child of children)this.elements[child] = _extends({}, this.elements[child], {
|
|
280
|
+
parent: element
|
|
281
|
+
});
|
|
282
|
+
this.leafMemo.clear();
|
|
283
|
+
}
|
|
284
|
+
/** These elements' leaves, in the order given, take the places they hold among themselves, so nothing around them moves. */ moveLeaves(elements) {
|
|
285
|
+
const moved = elements.flatMap((element)=>this.leaves(element));
|
|
286
|
+
const places = moved.map((leaf)=>leaf.order).sort((a, b)=>a - b);
|
|
287
|
+
moved.forEach((leaf, at)=>{
|
|
288
|
+
leaf.order = places[at];
|
|
289
|
+
});
|
|
290
|
+
this.leafMemo.clear();
|
|
291
|
+
}
|
|
163
292
|
/*---------------- leaves and parts ----------------*/ leaves(element) {
|
|
164
293
|
var _this_own_element;
|
|
165
294
|
const held = this.leafMemo.get(element);
|
|
@@ -208,7 +337,7 @@ let LayoutReader = class LayoutReader {
|
|
|
208
337
|
return this.styles.of(element);
|
|
209
338
|
}
|
|
210
339
|
block(leaf) {
|
|
211
|
-
return this.blocks[leaf.
|
|
340
|
+
return this.blocks[leaf.written];
|
|
212
341
|
}
|
|
213
342
|
/*---------------- sections ----------------*/ sections() {
|
|
214
343
|
const root = this.structure.main >= 0 ? this.structure.main : this.structure.body;
|
|
@@ -370,6 +499,8 @@ let LayoutReader = class LayoutReader {
|
|
|
370
499
|
} : {})
|
|
371
500
|
};
|
|
372
501
|
}
|
|
502
|
+
// Its fill in the page's dark scheme, read as its fill is, where that scheme changes it.
|
|
503
|
+
const dark = this.darkStyles ? cut.anchor !== null ? this.bandOf(cut.anchor, false, this.darkStyles) : this.bandOf(container, true, this.darkStyles) : null;
|
|
373
504
|
const lines = (behind == null ? void 0 : behind.poster) !== undefined ? [
|
|
374
505
|
behind.poster,
|
|
375
506
|
...this.linesOf(nodes)
|
|
@@ -381,9 +512,14 @@ let LayoutReader = class LayoutReader {
|
|
|
381
512
|
return _extends({
|
|
382
513
|
name,
|
|
383
514
|
from,
|
|
384
|
-
band: band.band
|
|
515
|
+
band: band.band
|
|
516
|
+
}, band.absolute && band.absolute !== band.band ? {
|
|
517
|
+
absoluteBand: band.absolute
|
|
518
|
+
} : {}, {
|
|
385
519
|
background: band.background
|
|
386
|
-
}, band.
|
|
520
|
+
}, (dark == null ? void 0 : dark.background) && dark.background !== band.background ? {
|
|
521
|
+
darkBackground: dark.background
|
|
522
|
+
} : {}, band.backdrop ? {
|
|
387
523
|
backdrop: band.backdrop
|
|
388
524
|
} : {}, {
|
|
389
525
|
align
|
|
@@ -430,28 +566,28 @@ let LayoutReader = class LayoutReader {
|
|
|
430
566
|
}
|
|
431
567
|
return chain;
|
|
432
568
|
}
|
|
433
|
-
bandOf(element, inherited) {
|
|
569
|
+
bandOf(element, inherited, styles = this.styles) {
|
|
434
570
|
var _ref, _ref1, _this_backgroundBand;
|
|
435
571
|
var _this_elements_element, _this_elements_at;
|
|
436
572
|
// The section's own background, else the one wrapper inside it that covers it.
|
|
437
573
|
const chain = inherited ? [] : this.wrappersOf(element);
|
|
438
574
|
for (const at of chain){
|
|
439
|
-
const found = this.backgroundBand(at);
|
|
575
|
+
const found = this.backgroundBand(at, styles);
|
|
440
576
|
if (found) return found;
|
|
441
577
|
}
|
|
442
578
|
// None of its own: the page's, under it.
|
|
443
579
|
for(let at = inherited ? element : (_ref = (_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.parent) != null ? _ref : -1; at >= 0; at = (_ref1 = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.parent) != null ? _ref1 : -1){
|
|
444
|
-
const found = this.backgroundBand(at);
|
|
580
|
+
const found = this.backgroundBand(at, styles);
|
|
445
581
|
if (found) return found;
|
|
446
582
|
}
|
|
447
|
-
return (_this_backgroundBand = this.backgroundBand(-2)) != null ? _this_backgroundBand : {
|
|
583
|
+
return (_this_backgroundBand = this.backgroundBand(-2, styles)) != null ? _this_backgroundBand : {
|
|
448
584
|
band: 'plain',
|
|
449
585
|
background: null
|
|
450
586
|
};
|
|
451
587
|
}
|
|
452
|
-
backgroundBand(element) {
|
|
588
|
+
backgroundBand(element, styles) {
|
|
453
589
|
var _this_elements_element;
|
|
454
|
-
const style =
|
|
590
|
+
const style = styles.of(element);
|
|
455
591
|
const background = siteImportBackgroundOf(style);
|
|
456
592
|
const hex = background.color && background.color.a >= 0.5 ? siteImportHex(background.color) : null;
|
|
457
593
|
if (background.image && !/\.svg(?:$|\?)/i.test(background.image)) {
|
|
@@ -476,7 +612,8 @@ let LayoutReader = class LayoutReader {
|
|
|
476
612
|
};
|
|
477
613
|
}
|
|
478
614
|
if (background.color && background.color.a >= 0.5) return {
|
|
479
|
-
band:
|
|
615
|
+
band: siteImportBandOn(background.color, this.pageGround),
|
|
616
|
+
absolute: siteImportBandOfColor(background.color),
|
|
480
617
|
background: hex
|
|
481
618
|
};
|
|
482
619
|
const theme = (_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.attrs.theme;
|
|
@@ -572,10 +709,16 @@ let LayoutReader = class LayoutReader {
|
|
|
572
709
|
const runs = this.groupRuns(element, parts, range);
|
|
573
710
|
const elementParts = parts.filter(isElementPart);
|
|
574
711
|
// Items built alike are a group, a heading over them included; only a container of unlike parts is a row of columns.
|
|
575
|
-
if (!runs.length && elementParts.length >= 2 && this.isRow(element)
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
712
|
+
if (!runs.length && elementParts.length >= 2 && this.isRow(element)) {
|
|
713
|
+
// A child laid out of the flow takes no cell of the row (AGL-4152): a section's picture laid behind its words.
|
|
714
|
+
const inFlow = parts.filter((part)=>!isElementPart(part) || !this.outOfFlow(part.element));
|
|
715
|
+
if (this.rowWorthy(inFlow, range)) {
|
|
716
|
+
const laid = elementParts.filter((part)=>this.outOfFlow(part.element)).flatMap((part)=>this.read(part.element, range));
|
|
717
|
+
return [
|
|
718
|
+
...laid,
|
|
719
|
+
this.row(element, inFlow, range)
|
|
720
|
+
];
|
|
721
|
+
}
|
|
579
722
|
}
|
|
580
723
|
const out = [];
|
|
581
724
|
for(let index = 0; index < parts.length;){
|
|
@@ -830,6 +973,8 @@ let LayoutReader = class LayoutReader {
|
|
|
830
973
|
var _node_attrs_class, _style_get, _style_get1;
|
|
831
974
|
const node = this.elements[element];
|
|
832
975
|
if (!node) return false;
|
|
976
|
+
const placed = this.placed.get(element);
|
|
977
|
+
if (placed) return placed === 'row';
|
|
833
978
|
if (node.tag === 'tr') return true;
|
|
834
979
|
const classes = (_node_attrs_class = node.attrs.class) != null ? _node_attrs_class : '';
|
|
835
980
|
if (/\bMuiGrid-container\b|(?:^|\s)row(?:\s|$)|\bcolumns\b|wp-block-columns|elementor-row|e-con-inner|sqs-row/.test(classes)) return true;
|
|
@@ -842,6 +987,10 @@ let LayoutReader = class LayoutReader {
|
|
|
842
987
|
if (/\bflex\b/.test(display)) return !/column/.test((_style_get1 = style.get('flex-direction')) != null ? _style_get1 : 'row');
|
|
843
988
|
return false;
|
|
844
989
|
}
|
|
990
|
+
outOfFlow(element) {
|
|
991
|
+
var _this_style_get;
|
|
992
|
+
return /^(?:absolute|fixed)$/.test((_this_style_get = this.style(element).get('position')) != null ? _this_style_get : '');
|
|
993
|
+
}
|
|
845
994
|
/** A row is columns of content, not a line of buttons or links. */ rowWorthy(parts, range) {
|
|
846
995
|
const substantial = parts.filter((part)=>{
|
|
847
996
|
if (!isElementPart(part)) return false;
|
|
@@ -907,6 +1056,8 @@ let LayoutReader = class LayoutReader {
|
|
|
907
1056
|
/** A cell's size: a framework's column class, its width share or its flex grow. */ cellSize(element) {
|
|
908
1057
|
var _ref, _ref1, _ref2;
|
|
909
1058
|
var _this_elements_element, _style_get, _style_get1;
|
|
1059
|
+
const placed = this.placedWidth.get(element);
|
|
1060
|
+
if (placed !== undefined) return placed;
|
|
910
1061
|
const classes = (_ref = (_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.attrs.class) != null ? _ref : '';
|
|
911
1062
|
let best = null;
|
|
912
1063
|
for (const match of classes.matchAll(MUI_GRID_SIZE)){
|
|
@@ -1010,6 +1161,8 @@ let LayoutReader = class LayoutReader {
|
|
|
1010
1161
|
*/ couldBeItem(element, range) {
|
|
1011
1162
|
const node = this.elements[element];
|
|
1012
1163
|
if (!node) return false;
|
|
1164
|
+
// A row of a placed grid holds items; it is never one.
|
|
1165
|
+
if (this.placed.get(element) === 'row') return false;
|
|
1013
1166
|
if (/^(?:li|dt|dd|details|figure|article)$/.test(node.tag)) return true;
|
|
1014
1167
|
const leaves = this.leaves(element).filter((leaf)=>this.inRange(leaf, range));
|
|
1015
1168
|
if (leaves.length && leaves.every((leaf)=>{
|
|
@@ -1480,6 +1633,8 @@ let LayoutReader = class LayoutReader {
|
|
|
1480
1633
|
var _style_get, _ref, _style_get1;
|
|
1481
1634
|
var _this_elements_container;
|
|
1482
1635
|
const count = parts.length;
|
|
1636
|
+
const placed = this.placed.get(container);
|
|
1637
|
+
if (placed) return placed === 'row' ? count : 1;
|
|
1483
1638
|
const style = this.style(container);
|
|
1484
1639
|
const display = (_style_get = style.get('display')) != null ? _style_get : '';
|
|
1485
1640
|
if (/\bgrid\b/.test(display)) {
|
|
@@ -1759,8 +1914,14 @@ let LayoutReader = class LayoutReader {
|
|
|
1759
1914
|
return node.cells.some((cell)=>beside(cell.nodes));
|
|
1760
1915
|
});
|
|
1761
1916
|
if (beside(hero.nodes)) picture = 'beside';
|
|
1762
|
-
else if (this.pictureBehind(image))
|
|
1763
|
-
|
|
1917
|
+
else if (this.pictureBehind(image)) {
|
|
1918
|
+
picture = 'behind';
|
|
1919
|
+
// A picture its grid lays behind the words is the section's ground, as a background picture is: a photo is `dark`.
|
|
1920
|
+
if (this.placedUnderWords(image) && hero === sections[0]) {
|
|
1921
|
+
hero.band = 'dark';
|
|
1922
|
+
delete hero.absoluteBand;
|
|
1923
|
+
}
|
|
1924
|
+
} else picture = hero.lines.indexOf(image) > hero.lines.indexOf(h1) ? 'below' : 'above';
|
|
1764
1925
|
}
|
|
1765
1926
|
}
|
|
1766
1927
|
const measure = this.measureOf(hero, hero.lines.find((ref)=>{
|
|
@@ -1800,6 +1961,7 @@ let LayoutReader = class LayoutReader {
|
|
|
1800
1961
|
/** A picture laid over its section's whole area, behind the words. */ pictureBehind(ref) {
|
|
1801
1962
|
var _ref, _ref1;
|
|
1802
1963
|
var _this_elements_at;
|
|
1964
|
+
if (this.placedUnderWords(ref)) return true;
|
|
1803
1965
|
const element = this.elements.find((node)=>node.blocks.some((index)=>this.mainIndex[index] === ref));
|
|
1804
1966
|
for(let at = (_ref = element == null ? void 0 : element.id) != null ? _ref : -1, depth = 0; at >= 0 && depth < 3; at = (_ref1 = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.parent) != null ? _ref1 : -1, depth += 1){
|
|
1805
1967
|
const position = this.style(at).get('position');
|
|
@@ -1807,17 +1969,28 @@ let LayoutReader = class LayoutReader {
|
|
|
1807
1969
|
}
|
|
1808
1970
|
return false;
|
|
1809
1971
|
}
|
|
1972
|
+
/** A picture its grid places in the same cells as words (AGL-4152). */ placedUnderWords(ref) {
|
|
1973
|
+
var _ref, _ref1;
|
|
1974
|
+
var _this_elements_at;
|
|
1975
|
+
const element = this.elements.find((node)=>node.blocks.some((index)=>this.mainIndex[index] === ref));
|
|
1976
|
+
for(let at = (_ref = element == null ? void 0 : element.id) != null ? _ref : -1; at >= 0; at = (_ref1 = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.parent) != null ? _ref1 : -1)if (this.placedBehind.has(at)) return true;
|
|
1977
|
+
return false;
|
|
1978
|
+
}
|
|
1810
1979
|
linesOf(nodes) {
|
|
1811
1980
|
return siteImportLayoutLines(nodes);
|
|
1812
1981
|
}
|
|
1813
|
-
constructor(structure, blocks, styles, wideStylesOf, tabletStylesOf = ()=>styles, videos = []){
|
|
1814
|
-
var _siteImportFontSizePx;
|
|
1982
|
+
constructor(structure, blocks, styles, wideStylesOf, tabletStylesOf = ()=>styles, videos = [], darkStyles = null){
|
|
1983
|
+
var _siteImportFontSizePx, _siteImportBackgroundOf_color;
|
|
1815
1984
|
this.structure = structure;
|
|
1816
1985
|
this.blocks = blocks;
|
|
1817
1986
|
this.styles = styles;
|
|
1818
1987
|
this.wideStylesOf = wideStylesOf;
|
|
1819
1988
|
this.tabletStylesOf = tabletStylesOf;
|
|
1820
1989
|
this.videos = videos;
|
|
1990
|
+
this.darkStyles = darkStyles;
|
|
1991
|
+
/** A grid read by its children's places: `stack` when its children now run down the page, `row` for a row of cells it draws. */ this.placed = new Map();
|
|
1992
|
+
/** A cell's width on its grid, in tracks. */ this.placedWidth = new Map();
|
|
1993
|
+
/** A placed child that holds no words and has words laid over it. */ this.placedBehind = new Set();
|
|
1821
1994
|
/** Each element's leaves, its subtree's, in order (memoized). */ this.leafMemo = new Map();
|
|
1822
1995
|
/** Tab panels a tab strip has read already. */ this.usedPanels = new Set();
|
|
1823
1996
|
this.bodySize = 16;
|
|
@@ -1825,7 +1998,9 @@ let LayoutReader = class LayoutReader {
|
|
|
1825
1998
|
this.tabletStyles = null;
|
|
1826
1999
|
this.mainBlocksMemo = null;
|
|
1827
2000
|
this.tabsMemo = null;
|
|
1828
|
-
this.elements =
|
|
2001
|
+
this.elements = [
|
|
2002
|
+
...structure.elements
|
|
2003
|
+
];
|
|
1829
2004
|
this.mainIndex = [];
|
|
1830
2005
|
let main = 0;
|
|
1831
2006
|
for (const block of blocks)this.mainIndex.push(block.region === 'main' ? main++ : -1);
|
|
@@ -1838,29 +2013,34 @@ let LayoutReader = class LayoutReader {
|
|
|
1838
2013
|
if (!block || ref < 0 || !isLine(block)) return;
|
|
1839
2014
|
(_this_own_element = this.own[element]) == null ? void 0 : _this_own_element.push({
|
|
1840
2015
|
order: index,
|
|
2016
|
+
written: index,
|
|
1841
2017
|
kind: 'line',
|
|
1842
2018
|
ref,
|
|
1843
2019
|
element
|
|
1844
2020
|
});
|
|
1845
2021
|
});
|
|
1846
2022
|
for (const element of this.elements){
|
|
1847
|
-
var _element_order
|
|
2023
|
+
var _element_order;
|
|
1848
2024
|
var _this_own_element_id, _this_own_element_id1, _this_own_element_id2;
|
|
1849
2025
|
if (element.region !== 'main' || element.nav) continue;
|
|
2026
|
+
const order = (_element_order = element.order) != null ? _element_order : 0;
|
|
1850
2027
|
if (element.icon !== undefined) (_this_own_element_id = this.own[element.id]) == null ? void 0 : _this_own_element_id.push({
|
|
1851
|
-
order
|
|
2028
|
+
order,
|
|
2029
|
+
written: order,
|
|
1852
2030
|
kind: 'icon',
|
|
1853
2031
|
ref: element.icon,
|
|
1854
2032
|
element: element.id
|
|
1855
2033
|
});
|
|
1856
2034
|
if (element.form !== undefined) (_this_own_element_id1 = this.own[element.id]) == null ? void 0 : _this_own_element_id1.push({
|
|
1857
|
-
order
|
|
2035
|
+
order,
|
|
2036
|
+
written: order,
|
|
1858
2037
|
kind: 'form',
|
|
1859
2038
|
ref: element.form,
|
|
1860
2039
|
element: element.id
|
|
1861
2040
|
});
|
|
1862
2041
|
if (element.video !== undefined) (_this_own_element_id2 = this.own[element.id]) == null ? void 0 : _this_own_element_id2.push({
|
|
1863
|
-
order
|
|
2042
|
+
order,
|
|
2043
|
+
written: order,
|
|
1864
2044
|
kind: 'video',
|
|
1865
2045
|
ref: element.video,
|
|
1866
2046
|
element: element.id
|
|
@@ -1868,8 +2048,90 @@ let LayoutReader = class LayoutReader {
|
|
|
1868
2048
|
}
|
|
1869
2049
|
const body = structure.body >= 0 ? structure.body : -2;
|
|
1870
2050
|
this.bodySize = (_siteImportFontSizePx = siteImportFontSizePx(styles.of(body))) != null ? _siteImportFontSizePx : 16;
|
|
2051
|
+
const ground = (_siteImportBackgroundOf_color = siteImportBackgroundOf(styles.of(body)).color) != null ? _siteImportBackgroundOf_color : siteImportBackgroundOf(styles.of(-2)).color;
|
|
2052
|
+
this.pageGround = ground && ground.a >= 0.5 ? ground : null;
|
|
2053
|
+
this.readPlacement();
|
|
1871
2054
|
}
|
|
1872
2055
|
};
|
|
2056
|
+
/** How much of two stretches of a grid's lines coincide. */ const overlapOf = (aStart, aEnd, bStart, bEnd)=>Math.max(0, Math.min(aEnd, bEnd) - Math.max(aStart, bStart));
|
|
2057
|
+
/** Whether words are laid over a box: at least half their cells are its cells. */ function overLaid(words, under) {
|
|
2058
|
+
const cells = overlapOf(words.rowStart, words.rowEnd, under.rowStart, under.rowEnd) * overlapOf(words.columnStart, words.columnEnd, under.columnStart, under.columnEnd);
|
|
2059
|
+
return cells * 2 >= (words.rowEnd - words.rowStart) * (words.columnEnd - words.columnStart) && cells > 0;
|
|
2060
|
+
}
|
|
2061
|
+
/**
|
|
2062
|
+
* A placed grid's children as a visitor reads them (AGL-4152): sorted by row
|
|
2063
|
+
* then column, clustered into visual rows where their rows overlap, split into
|
|
2064
|
+
* cells where their columns do, each cell top to bottom with what is laid
|
|
2065
|
+
* under words first. A row then joins the columns above it where it is built
|
|
2066
|
+
* to them and those columns have something it belongs to: words under a
|
|
2067
|
+
* heading or a picture. A row with a heading or a picture where its column
|
|
2068
|
+
* already holds one starts anew, so rows of whole cards stay rows, and words
|
|
2069
|
+
* with nothing above them to belong to stay rows too. One band is one row of
|
|
2070
|
+
* the page; a band of one cell is simply stacked.
|
|
2071
|
+
*/ function siteImportGridBands(items, behind) {
|
|
2072
|
+
const sorted = [
|
|
2073
|
+
...items
|
|
2074
|
+
].sort((a, b)=>a.box.rowStart - b.box.rowStart || a.box.columnStart - b.box.columnStart);
|
|
2075
|
+
const rows = [];
|
|
2076
|
+
let rowEnd = Number.NEGATIVE_INFINITY;
|
|
2077
|
+
for (const item of sorted){
|
|
2078
|
+
const joins = item.box.rowStart < rowEnd;
|
|
2079
|
+
if (joins) rows[rows.length - 1].push(item);
|
|
2080
|
+
else rows.push([
|
|
2081
|
+
item
|
|
2082
|
+
]);
|
|
2083
|
+
rowEnd = joins ? Math.max(rowEnd, item.box.rowEnd) : item.box.rowEnd;
|
|
2084
|
+
}
|
|
2085
|
+
const bands = [];
|
|
2086
|
+
for (const row of rows){
|
|
2087
|
+
const cells = [];
|
|
2088
|
+
for (const item of [
|
|
2089
|
+
...row
|
|
2090
|
+
].sort((a, b)=>a.box.columnStart - b.box.columnStart)){
|
|
2091
|
+
const { columnStart: start, columnEnd: end } = item.box;
|
|
2092
|
+
const last = cells[cells.length - 1];
|
|
2093
|
+
// The same cell where half the narrower of the two is shared; a block nudged over its neighbor's edge is still beside it.
|
|
2094
|
+
if (last && overlapOf(last.start, last.end, start, end) * 2 >= Math.min(last.end - last.start, end - start)) {
|
|
2095
|
+
last.items.push(item);
|
|
2096
|
+
last.end = Math.max(last.end, end);
|
|
2097
|
+
} else cells.push({
|
|
2098
|
+
start,
|
|
2099
|
+
end,
|
|
2100
|
+
items: [
|
|
2101
|
+
item
|
|
2102
|
+
]
|
|
2103
|
+
});
|
|
2104
|
+
}
|
|
2105
|
+
const band = bands[bands.length - 1];
|
|
2106
|
+
const columns = band ? columnsFor(band, cells) : null;
|
|
2107
|
+
if (band && columns) {
|
|
2108
|
+
cells.forEach((cell, at)=>{
|
|
2109
|
+
const column = band[columns[at]];
|
|
2110
|
+
column.items.push(...cell.items);
|
|
2111
|
+
column.start = Math.min(column.start, cell.start);
|
|
2112
|
+
column.end = Math.max(column.end, cell.end);
|
|
2113
|
+
});
|
|
2114
|
+
} else bands.push(cells);
|
|
2115
|
+
}
|
|
2116
|
+
for (const band of bands){
|
|
2117
|
+
for (const cell of band)cell.items.sort((a, b)=>Number(behind(b)) - Number(behind(a)) || a.box.rowStart - b.box.rowStart || a.box.columnStart - b.box.columnStart);
|
|
2118
|
+
}
|
|
2119
|
+
return bands;
|
|
2120
|
+
}
|
|
2121
|
+
/** The column of a band each cell of the row under it belongs in, or `null` where that row is a row of its own. */ function columnsFor(band, cells) {
|
|
2122
|
+
if (band.length < 2 || !band.some((column)=>column.items.some((item)=>item.heading || item.picture))) return null;
|
|
2123
|
+
const taken = [];
|
|
2124
|
+
for (const cell of cells){
|
|
2125
|
+
const overlaps = band.map((column)=>overlapOf(column.start, column.end, cell.start, cell.end));
|
|
2126
|
+
const best = overlaps.indexOf(Math.max(...overlaps));
|
|
2127
|
+
const column = band[best];
|
|
2128
|
+
if (overlaps[best] * 2 < cell.end - cell.start || taken.includes(best)) return null;
|
|
2129
|
+
const has = (test)=>cell.items.some(test) && column.items.some(test);
|
|
2130
|
+
if (has((item)=>item.heading) || has((item)=>item.picture)) return null;
|
|
2131
|
+
taken.push(best);
|
|
2132
|
+
}
|
|
2133
|
+
return taken;
|
|
2134
|
+
}
|
|
1873
2135
|
/** Drops a group's own alignment where its section reads the same (AGL-4138): only an item set apart from its section says how. */ function keepOwnAlign(nodes, align) {
|
|
1874
2136
|
for (const node of nodes){
|
|
1875
2137
|
if (node.kind === 'group' && node.align === align) delete node.align;
|
|
@@ -1983,6 +2245,22 @@ function mode(values) {
|
|
|
1983
2245
|
...counts.entries()
|
|
1984
2246
|
].sort((a, b)=>b[1] - a[1] || b[0] - a[0])[0]) == null ? void 0 : _sort_[0]) != null ? _ref : 0;
|
|
1985
2247
|
}
|
|
2248
|
+
/** How far a light fill may sit from the page's ground and still be that ground (AGL-4152), in OKLab. */ const SAME_GROUND = 0.02;
|
|
2249
|
+
/**
|
|
2250
|
+
* A section's fill as a band of its page (AGL-4152): a light fill is `plain`
|
|
2251
|
+
* on the page's own ground (white, where the page sets none) and `soft`
|
|
2252
|
+
* anywhere else, so a page on light grey with white bands draws those bands
|
|
2253
|
+
* apart from it in both color schemes. A strong color or a dark one is what it is.
|
|
2254
|
+
*/ export function siteImportBandOn(color, page) {
|
|
2255
|
+
const band = siteImportBandOfColor(color);
|
|
2256
|
+
if (band !== 'plain' && band !== 'soft') return band;
|
|
2257
|
+
return siteImportColorDistance(color, page != null ? page : {
|
|
2258
|
+
r: 255,
|
|
2259
|
+
g: 255,
|
|
2260
|
+
b: 255,
|
|
2261
|
+
a: 1
|
|
2262
|
+
}) <= SAME_GROUND ? 'plain' : 'soft';
|
|
2263
|
+
}
|
|
1986
2264
|
/** A solid background's band: near white is the page, light or tinted is soft, a strong color is the brand's, dark is dark. */ export function siteImportBandOfColor(color) {
|
|
1987
2265
|
const light = siteImportLuminance(color);
|
|
1988
2266
|
const saturation = siteImportSaturation(color);
|
|
@@ -2046,7 +2324,7 @@ function mode(values) {
|
|
|
2046
2324
|
var _page_blocks;
|
|
2047
2325
|
if (!page.structure) return null;
|
|
2048
2326
|
if ((_page_blocks = page.blocks) == null ? void 0 : _page_blocks.length) {
|
|
2049
|
-
const { css, styles, sections } = readSections(_extends({
|
|
2327
|
+
const { css, styles, darkStyles, sections } = readSections(_extends({
|
|
2050
2328
|
structure: page.structure,
|
|
2051
2329
|
blocks: [
|
|
2052
2330
|
...page.blocks
|
|
@@ -2054,13 +2332,13 @@ function mode(values) {
|
|
|
2054
2332
|
}, page.videos ? {
|
|
2055
2333
|
videos: page.videos
|
|
2056
2334
|
} : {}), stylesheets);
|
|
2057
|
-
return siteImportLookFacts(page.structure, styles, css.fontFaces, page.blocks, sections);
|
|
2335
|
+
return siteImportLookFacts(page.structure, styles, css.fontFaces, page.blocks, sections, darkStyles, css.variableUses);
|
|
2058
2336
|
}
|
|
2059
2337
|
const css = siteImportCssOf([
|
|
2060
2338
|
...page.structure.styles,
|
|
2061
2339
|
...stylesheets
|
|
2062
2340
|
]);
|
|
2063
|
-
return siteImportLookFacts(page.structure, siteImportStylesOf(page.structure, css), css.fontFaces, []);
|
|
2341
|
+
return siteImportLookFacts(page.structure, siteImportStylesOf(page.structure, css), css.fontFaces, [], [], null, css.variableUses);
|
|
2064
2342
|
}
|
|
2065
2343
|
/**
|
|
2066
2344
|
* The look facts of a page's markup and the stylesheets it links (AGL-4106),
|
|
@@ -2131,13 +2409,16 @@ function mode(values) {
|
|
|
2131
2409
|
return others.some((other)=>siteImportColorDistance(own, other) < SAME_COLOR) ? null : top;
|
|
2132
2410
|
}
|
|
2133
2411
|
/** The fill most of a page's dark sections sit on (AGL-4152), the first of them on a tie; `null` where none has one. */ function darkBackgroundOf(sections) {
|
|
2412
|
+
return mostUsedFill(sections.filter((section)=>section.band === 'dark').map((section)=>section.background));
|
|
2413
|
+
}
|
|
2414
|
+
/** The fill most of these are, the first of them on a tie; `null` where none is a solid color. */ function mostUsedFill(fills) {
|
|
2134
2415
|
var _ref;
|
|
2135
2416
|
var _sort_;
|
|
2136
2417
|
const counts = new Map();
|
|
2137
|
-
for (const
|
|
2138
|
-
if (
|
|
2418
|
+
for (const fill of fills){
|
|
2419
|
+
if (fill && /^#[0-9a-f]{6}$/i.test(fill)) {
|
|
2139
2420
|
var _counts_get;
|
|
2140
|
-
const hex =
|
|
2421
|
+
const hex = fill.toLowerCase();
|
|
2141
2422
|
counts.set(hex, ((_counts_get = counts.get(hex)) != null ? _counts_get : 0) + 1);
|
|
2142
2423
|
}
|
|
2143
2424
|
}
|
|
@@ -2146,6 +2427,7 @@ function mode(values) {
|
|
|
2146
2427
|
...counts.entries()
|
|
2147
2428
|
].sort((a, b)=>b[1] - a[1])[0]) == null ? void 0 : _sort_[0]) != null ? _ref : null;
|
|
2148
2429
|
}
|
|
2430
|
+
/** The case most of a page's buttons of one style are set in; `null` for a page with none. */ const caseOf = ({ upper, lower })=>upper + lower ? upper > lower ? 'upper' : 'none' : null;
|
|
2149
2431
|
/** Whether a button's words are written in capitals: three letters or more, none of them lower case. */ function writtenInCapitals(text) {
|
|
2150
2432
|
const letters = text.replace(RegExp("[^\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376-\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05D0-\\u05EA\\u05EF-\\u05F2\\u0620-\\u064A\\u066E-\\u066F\\u0671-\\u06D3\\u06D5\\u06E5-\\u06E6\\u06EE-\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4-\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086A\\u0870-\\u0887\\u0889-\\u088F\\u08A0-\\u08C9\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F-\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC-\\u09DD\\u09DF-\\u09E1\\u09F0-\\u09F1\\u09FC\\u0A05-\\u0A0A\\u0A0F-\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32-\\u0A33\\u0A35-\\u0A36\\u0A38-\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2-\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0-\\u0AE1\\u0AF9\\u0B05-\\u0B0C\\u0B0F-\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32-\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C-\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99-\\u0B9A\\u0B9C\\u0B9E-\\u0B9F\\u0BA3-\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58-\\u0C5A\\u0C5C-\\u0C5D\\u0C60-\\u0C61\\u0C80\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDC-\\u0CDE\\u0CE0-\\u0CE1\\u0CF1-\\u0CF2\\u0D04-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D54-\\u0D56\\u0D5F-\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32-\\u0E33\\u0E40-\\u0E46\\u0E81-\\u0E82\\u0E84\\u0E86-\\u0E8A\\u0E8C-\\u0EA3\\u0EA5\\u0EA7-\\u0EB0\\u0EB2-\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065-\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16F1-\\u16F8\\u1700-\\u1711\\u171F-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1878\\u1880-\\u1884\\u1887-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4C\\u1B83-\\u1BA0\\u1BAE-\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1C80-\\u1C8A\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1CE9-\\u1CEC\\u1CEE-\\u1CF3\\u1CF5-\\u1CF6\\u1CFA\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183-\\u2184\\u2C00-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3006\\u3031-\\u3035\\u303B-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312F\\u3131-\\u318E\\u31A0-\\u31BF\\u31F0-\\u31FF\\u3400-\\u4DBF\\u4E00-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A-\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7DC\\uA7F1-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA8FD-\\uA8FE\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5-\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB69\\uAB70-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40-\\uFB41\\uFB43-\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC\\u{10000}-\\u{1000B}\\u{1000D}-\\u{10026}\\u{10028}-\\u{1003A}\\u{1003C}-\\u{1003D}\\u{1003F}-\\u{1004D}\\u{10050}-\\u{1005D}\\u{10080}-\\u{100FA}\\u{10280}-\\u{1029C}\\u{102A0}-\\u{102D0}\\u{10300}-\\u{1031F}\\u{1032D}-\\u{10340}\\u{10342}-\\u{10349}\\u{10350}-\\u{10375}\\u{10380}-\\u{1039D}\\u{103A0}-\\u{103C3}\\u{103C8}-\\u{103CF}\\u{10400}-\\u{1049D}\\u{104B0}-\\u{104D3}\\u{104D8}-\\u{104FB}\\u{10500}-\\u{10527}\\u{10530}-\\u{10563}\\u{10570}-\\u{1057A}\\u{1057C}-\\u{1058A}\\u{1058C}-\\u{10592}\\u{10594}-\\u{10595}\\u{10597}-\\u{105A1}\\u{105A3}-\\u{105B1}\\u{105B3}-\\u{105B9}\\u{105BB}-\\u{105BC}\\u{105C0}-\\u{105F3}\\u{10600}-\\u{10736}\\u{10740}-\\u{10755}\\u{10760}-\\u{10767}\\u{10780}-\\u{10785}\\u{10787}-\\u{107B0}\\u{107B2}-\\u{107BA}\\u{10800}-\\u{10805}\\u{10808}\\u{1080A}-\\u{10835}\\u{10837}-\\u{10838}\\u{1083C}\\u{1083F}-\\u{10855}\\u{10860}-\\u{10876}\\u{10880}-\\u{1089E}\\u{108E0}-\\u{108F2}\\u{108F4}-\\u{108F5}\\u{10900}-\\u{10915}\\u{10920}-\\u{10939}\\u{10940}-\\u{10959}\\u{10980}-\\u{109B7}\\u{109BE}-\\u{109BF}\\u{10A00}\\u{10A10}-\\u{10A13}\\u{10A15}-\\u{10A17}\\u{10A19}-\\u{10A35}\\u{10A60}-\\u{10A7C}\\u{10A80}-\\u{10A9C}\\u{10AC0}-\\u{10AC7}\\u{10AC9}-\\u{10AE4}\\u{10B00}-\\u{10B35}\\u{10B40}-\\u{10B55}\\u{10B60}-\\u{10B72}\\u{10B80}-\\u{10B91}\\u{10C00}-\\u{10C48}\\u{10C80}-\\u{10CB2}\\u{10CC0}-\\u{10CF2}\\u{10D00}-\\u{10D23}\\u{10D4A}-\\u{10D65}\\u{10D6F}-\\u{10D85}\\u{10E80}-\\u{10EA9}\\u{10EB0}-\\u{10EB1}\\u{10EC2}-\\u{10EC7}\\u{10F00}-\\u{10F1C}\\u{10F27}\\u{10F30}-\\u{10F45}\\u{10F70}-\\u{10F81}\\u{10FB0}-\\u{10FC4}\\u{10FE0}-\\u{10FF6}\\u{11003}-\\u{11037}\\u{11071}-\\u{11072}\\u{11075}\\u{11083}-\\u{110AF}\\u{110D0}-\\u{110E8}\\u{11103}-\\u{11126}\\u{11144}\\u{11147}\\u{11150}-\\u{11172}\\u{11176}\\u{11183}-\\u{111B2}\\u{111C1}-\\u{111C4}\\u{111DA}\\u{111DC}\\u{11200}-\\u{11211}\\u{11213}-\\u{1122B}\\u{1123F}-\\u{11240}\\u{11280}-\\u{11286}\\u{11288}\\u{1128A}-\\u{1128D}\\u{1128F}-\\u{1129D}\\u{1129F}-\\u{112A8}\\u{112B0}-\\u{112DE}\\u{11305}-\\u{1130C}\\u{1130F}-\\u{11310}\\u{11313}-\\u{11328}\\u{1132A}-\\u{11330}\\u{11332}-\\u{11333}\\u{11335}-\\u{11339}\\u{1133D}\\u{11350}\\u{1135D}-\\u{11361}\\u{11380}-\\u{11389}\\u{1138B}\\u{1138E}\\u{11390}-\\u{113B5}\\u{113B7}\\u{113D1}\\u{113D3}\\u{11400}-\\u{11434}\\u{11447}-\\u{1144A}\\u{1145F}-\\u{11461}\\u{11480}-\\u{114AF}\\u{114C4}-\\u{114C5}\\u{114C7}\\u{11580}-\\u{115AE}\\u{115D8}-\\u{115DB}\\u{11600}-\\u{1162F}\\u{11644}\\u{11680}-\\u{116AA}\\u{116B8}\\u{11700}-\\u{1171A}\\u{11740}-\\u{11746}\\u{11800}-\\u{1182B}\\u{118A0}-\\u{118DF}\\u{118FF}-\\u{11906}\\u{11909}\\u{1190C}-\\u{11913}\\u{11915}-\\u{11916}\\u{11918}-\\u{1192F}\\u{1193F}\\u{11941}\\u{119A0}-\\u{119A7}\\u{119AA}-\\u{119D0}\\u{119E1}\\u{119E3}\\u{11A00}\\u{11A0B}-\\u{11A32}\\u{11A3A}\\u{11A50}\\u{11A5C}-\\u{11A89}\\u{11A9D}\\u{11AB0}-\\u{11AF8}\\u{11BC0}-\\u{11BE0}\\u{11C00}-\\u{11C08}\\u{11C0A}-\\u{11C2E}\\u{11C40}\\u{11C72}-\\u{11C8F}\\u{11D00}-\\u{11D06}\\u{11D08}-\\u{11D09}\\u{11D0B}-\\u{11D30}\\u{11D46}\\u{11D60}-\\u{11D65}\\u{11D67}-\\u{11D68}\\u{11D6A}-\\u{11D89}\\u{11D98}\\u{11DB0}-\\u{11DDB}\\u{11EE0}-\\u{11EF2}\\u{11F02}\\u{11F04}-\\u{11F10}\\u{11F12}-\\u{11F33}\\u{11FB0}\\u{12000}-\\u{12399}\\u{12480}-\\u{12543}\\u{12F90}-\\u{12FF0}\\u{13000}-\\u{1342F}\\u{13441}-\\u{13446}\\u{13460}-\\u{143FA}\\u{14400}-\\u{14646}\\u{16100}-\\u{1611D}\\u{16800}-\\u{16A38}\\u{16A40}-\\u{16A5E}\\u{16A70}-\\u{16ABE}\\u{16AD0}-\\u{16AED}\\u{16B00}-\\u{16B2F}\\u{16B40}-\\u{16B43}\\u{16B63}-\\u{16B77}\\u{16B7D}-\\u{16B8F}\\u{16D40}-\\u{16D6C}\\u{16E40}-\\u{16E7F}\\u{16EA0}-\\u{16EB8}\\u{16EBB}-\\u{16ED3}\\u{16F00}-\\u{16F4A}\\u{16F50}\\u{16F93}-\\u{16F9F}\\u{16FE0}-\\u{16FE1}\\u{16FE3}\\u{16FF2}-\\u{16FF3}\\u{17000}-\\u{18CD5}\\u{18CFF}-\\u{18D1E}\\u{18D80}-\\u{18DF2}\\u{1AFF0}-\\u{1AFF3}\\u{1AFF5}-\\u{1AFFB}\\u{1AFFD}-\\u{1AFFE}\\u{1B000}-\\u{1B122}\\u{1B132}\\u{1B150}-\\u{1B152}\\u{1B155}\\u{1B164}-\\u{1B167}\\u{1B170}-\\u{1B2FB}\\u{1BC00}-\\u{1BC6A}\\u{1BC70}-\\u{1BC7C}\\u{1BC80}-\\u{1BC88}\\u{1BC90}-\\u{1BC99}\\u{1D400}-\\u{1D454}\\u{1D456}-\\u{1D49C}\\u{1D49E}-\\u{1D49F}\\u{1D4A2}\\u{1D4A5}-\\u{1D4A6}\\u{1D4A9}-\\u{1D4AC}\\u{1D4AE}-\\u{1D4B9}\\u{1D4BB}\\u{1D4BD}-\\u{1D4C3}\\u{1D4C5}-\\u{1D505}\\u{1D507}-\\u{1D50A}\\u{1D50D}-\\u{1D514}\\u{1D516}-\\u{1D51C}\\u{1D51E}-\\u{1D539}\\u{1D53B}-\\u{1D53E}\\u{1D540}-\\u{1D544}\\u{1D546}\\u{1D54A}-\\u{1D550}\\u{1D552}-\\u{1D6A5}\\u{1D6A8}-\\u{1D6C0}\\u{1D6C2}-\\u{1D6DA}\\u{1D6DC}-\\u{1D6FA}\\u{1D6FC}-\\u{1D714}\\u{1D716}-\\u{1D734}\\u{1D736}-\\u{1D74E}\\u{1D750}-\\u{1D76E}\\u{1D770}-\\u{1D788}\\u{1D78A}-\\u{1D7A8}\\u{1D7AA}-\\u{1D7C2}\\u{1D7C4}-\\u{1D7CB}\\u{1DF00}-\\u{1DF1E}\\u{1DF25}-\\u{1DF2A}\\u{1E030}-\\u{1E06D}\\u{1E100}-\\u{1E12C}\\u{1E137}-\\u{1E13D}\\u{1E14E}\\u{1E290}-\\u{1E2AD}\\u{1E2C0}-\\u{1E2EB}\\u{1E4D0}-\\u{1E4EB}\\u{1E5D0}-\\u{1E5ED}\\u{1E5F0}\\u{1E6C0}-\\u{1E6DE}\\u{1E6E0}-\\u{1E6E2}\\u{1E6E4}-\\u{1E6E5}\\u{1E6E7}-\\u{1E6ED}\\u{1E6F0}-\\u{1E6F4}\\u{1E6FE}-\\u{1E6FF}\\u{1E7E0}-\\u{1E7E6}\\u{1E7E8}-\\u{1E7EB}\\u{1E7ED}-\\u{1E7EE}\\u{1E7F0}-\\u{1E7FE}\\u{1E800}-\\u{1E8C4}\\u{1E900}-\\u{1E943}\\u{1E94B}\\u{1EE00}-\\u{1EE03}\\u{1EE05}-\\u{1EE1F}\\u{1EE21}-\\u{1EE22}\\u{1EE24}\\u{1EE27}\\u{1EE29}-\\u{1EE32}\\u{1EE34}-\\u{1EE37}\\u{1EE39}\\u{1EE3B}\\u{1EE42}\\u{1EE47}\\u{1EE49}\\u{1EE4B}\\u{1EE4D}-\\u{1EE4F}\\u{1EE51}-\\u{1EE52}\\u{1EE54}\\u{1EE57}\\u{1EE59}\\u{1EE5B}\\u{1EE5D}\\u{1EE5F}\\u{1EE61}-\\u{1EE62}\\u{1EE64}\\u{1EE67}-\\u{1EE6A}\\u{1EE6C}-\\u{1EE72}\\u{1EE74}-\\u{1EE77}\\u{1EE79}-\\u{1EE7C}\\u{1EE7E}\\u{1EE80}-\\u{1EE89}\\u{1EE8B}-\\u{1EE9B}\\u{1EEA1}-\\u{1EEA3}\\u{1EEA5}-\\u{1EEA9}\\u{1EEAB}-\\u{1EEBB}\\u{20000}-\\u{2A6DF}\\u{2A700}-\\u{2B81D}\\u{2B820}-\\u{2CEAD}\\u{2CEB0}-\\u{2EBE0}\\u{2EBF0}-\\u{2EE5D}\\u{2F800}-\\u{2FA1D}\\u{30000}-\\u{3134A}\\u{31350}-\\u{33479}]", "gu"), '');
|
|
2151
2433
|
return letters.length >= 3 && letters === letters.toUpperCase() && letters !== letters.toLowerCase();
|
|
@@ -2156,8 +2438,8 @@ function mode(values) {
|
|
|
2156
2438
|
* (AGL-4152), its links' color, its header's background, its eyebrows' own
|
|
2157
2439
|
* color (AGL-4138), and, given its sections, the fill its dark bands sit on
|
|
2158
2440
|
* (AGL-4152).
|
|
2159
|
-
*/ export function siteImportLookFacts(structure, styles, fontFaces = [], blocks = [], sections = []) {
|
|
2160
|
-
var _ref, _siteImportFontFamilies_,
|
|
2441
|
+
*/ export function siteImportLookFacts(structure, styles, fontFaces = [], blocks = [], sections = [], darkStyles = null, variableUses = null) {
|
|
2442
|
+
var _elements_find, _ref, _ref1, _siteImportFontFamilies_, _elements_find1, _siteImportFontFamilies_1, _siteImportBackgroundOf_color, _ref2, _ref3, _elements_find2, _ref4, _siteImportBackgroundOf_color1, _ref5, _ref6, _ref7;
|
|
2161
2443
|
var _filter_sort_;
|
|
2162
2444
|
const { elements } = structure;
|
|
2163
2445
|
const body = structure.body >= 0 ? structure.body : -2;
|
|
@@ -2173,16 +2455,30 @@ function mode(values) {
|
|
|
2173
2455
|
...structure.stylesheets,
|
|
2174
2456
|
...imports
|
|
2175
2457
|
]);
|
|
2176
|
-
|
|
2177
|
-
const
|
|
2458
|
+
// Its body's family; where neither the body nor the root names one, the family its words are set in (AGL-4152).
|
|
2459
|
+
const paragraph = (_elements_find = elements.find((element)=>element.tag === 'p' && element.region === 'main')) != null ? _elements_find : elements.find((element)=>element.tag === 'p');
|
|
2460
|
+
const bodyFamily = (_ref = (_ref1 = (_siteImportFontFamilies_ = siteImportFontFamilies(bodyStyle.get('font-family'))[0]) != null ? _siteImportFontFamilies_ : siteImportFontFamilies(styles.of(-2).get('font-family'))[0]) != null ? _ref1 : paragraph ? siteImportFontFamilies(styles.of(paragraph.id).get('font-family'))[0] : undefined) != null ? _ref : null;
|
|
2461
|
+
const heading = (_elements_find1 = elements.find((element)=>/^h[12]$/.test(element.tag) && element.region === 'main')) != null ? _elements_find1 : elements.find((element)=>/^h[1-3]$/.test(element.tag));
|
|
2178
2462
|
const headingFamily = heading ? (_siteImportFontFamilies_1 = siteImportFontFamilies(styles.of(heading.id).get('font-family'))[0]) != null ? _siteImportFontFamilies_1 : bodyFamily : bodyFamily;
|
|
2179
2463
|
const known = (family)=>family && (google.includes(family) || fontFaces.includes(family) || !/^(?:arial|helvetica|helvetica neue|segoe ui|roboto fallback|times new roman|georgia|verdana)$/i.test(family)) ? family : null;
|
|
2180
2464
|
const background = (_siteImportBackgroundOf_color = siteImportBackgroundOf(bodyStyle).color) != null ? _siteImportBackgroundOf_color : siteImportBackgroundOf(styles.of(-2)).color;
|
|
2181
2465
|
// Buttons, the page's own and its header's: the most used fill.
|
|
2182
2466
|
const fills = new Map();
|
|
2183
|
-
//
|
|
2184
|
-
|
|
2185
|
-
|
|
2467
|
+
// Each style's case (AGL-4152): set in capitals, or written in them.
|
|
2468
|
+
const filledCase = {
|
|
2469
|
+
upper: 0,
|
|
2470
|
+
lower: 0
|
|
2471
|
+
};
|
|
2472
|
+
const outlinedCase = {
|
|
2473
|
+
upper: 0,
|
|
2474
|
+
lower: 0
|
|
2475
|
+
};
|
|
2476
|
+
const textCase = {
|
|
2477
|
+
upper: 0,
|
|
2478
|
+
lower: 0
|
|
2479
|
+
};
|
|
2480
|
+
const outlines = [];
|
|
2481
|
+
const outlinedFills = [];
|
|
2186
2482
|
const wordsOf = (element)=>{
|
|
2187
2483
|
const own = [];
|
|
2188
2484
|
const visit = (at, depth)=>{
|
|
@@ -2197,15 +2493,19 @@ function mode(values) {
|
|
|
2197
2493
|
return block && block.kind !== 'image' ? block.text : '';
|
|
2198
2494
|
}).join(' ');
|
|
2199
2495
|
};
|
|
2496
|
+
const count = (tally, element, style)=>{
|
|
2497
|
+
if (style.get('text-transform') === 'uppercase' || writtenInCapitals(wordsOf(element))) tally.upper += 1;
|
|
2498
|
+
else tally.lower += 1;
|
|
2499
|
+
};
|
|
2200
2500
|
const linkColors = new Map();
|
|
2201
2501
|
for (const element of elements){
|
|
2202
|
-
var
|
|
2502
|
+
var _ref8;
|
|
2203
2503
|
var _elements_at;
|
|
2204
2504
|
if (element.tag !== 'a' && element.tag !== 'button') continue;
|
|
2205
2505
|
if (element.region === 'footer') continue;
|
|
2206
2506
|
const style = styles.of(element.id);
|
|
2207
2507
|
let under = null;
|
|
2208
|
-
for(let at = element.parent; at >= 0; at = (
|
|
2508
|
+
for(let at = element.parent; at >= 0; at = (_ref8 = (_elements_at = elements[at]) == null ? void 0 : _elements_at.parent) != null ? _ref8 : -1){
|
|
2209
2509
|
const color = siteImportBackgroundOf(styles.of(at)).color;
|
|
2210
2510
|
if (color && color.a >= 0.5) {
|
|
2211
2511
|
under = siteImportHex(color);
|
|
@@ -2214,7 +2514,7 @@ function mode(values) {
|
|
|
2214
2514
|
}
|
|
2215
2515
|
const kind = siteImportButtonStyleOf(element, style, under != null ? under : background ? siteImportHex(background) : '#ffffff');
|
|
2216
2516
|
if (kind === 'primary') {
|
|
2217
|
-
var _fills_get;
|
|
2517
|
+
var _fills_get, _element_attrs_class;
|
|
2218
2518
|
const fill = siteImportBackgroundOf(style).color;
|
|
2219
2519
|
if (!fill) continue;
|
|
2220
2520
|
const hex = siteImportHex(fill);
|
|
@@ -2227,10 +2527,19 @@ function mode(values) {
|
|
|
2227
2527
|
const radius = siteImportRadiusPx(style);
|
|
2228
2528
|
if (radius !== null) entry.radius.push(radius);
|
|
2229
2529
|
fills.set(hex, entry);
|
|
2230
|
-
|
|
2231
|
-
|
|
2530
|
+
count(filledCase, element, style);
|
|
2531
|
+
// An outlined button that fills itself is read as a filled one, and its fill said apart.
|
|
2532
|
+
if (OUTLINED_CLASS.test((_element_attrs_class = element.attrs.class) != null ? _element_attrs_class : '')) outlinedFills.push(hex);
|
|
2533
|
+
} else if (kind === 'secondary') {
|
|
2534
|
+
count(outlinedCase, element, style);
|
|
2535
|
+
const color = hexOf(style.get('color'));
|
|
2536
|
+
if (color) outlines.push(color);
|
|
2537
|
+
} else if (kind === 'quiet') {
|
|
2538
|
+
count(textCase, element, style);
|
|
2232
2539
|
} else if (!kind && element.tag === 'a' && element.region === 'main') {
|
|
2233
2540
|
var _linkColors_get;
|
|
2541
|
+
// A page draws a link standing on its own as a text button (the compile's `quiet`).
|
|
2542
|
+
count(textCase, element, style);
|
|
2234
2543
|
const color = hexOf(style.get('color'));
|
|
2235
2544
|
if (color) linkColors.set(color, ((_linkColors_get = linkColors.get(color)) != null ? _linkColors_get : 0) + 1);
|
|
2236
2545
|
}
|
|
@@ -2238,26 +2547,30 @@ function mode(values) {
|
|
|
2238
2547
|
const topFill = [
|
|
2239
2548
|
...fills.entries()
|
|
2240
2549
|
].sort((a, b)=>b[1].count - a[1].count)[0];
|
|
2241
|
-
const radii = (
|
|
2550
|
+
const radii = (_ref2 = topFill == null ? void 0 : topFill[1].radius) != null ? _ref2 : [];
|
|
2242
2551
|
const text = hexOf(bodyStyle.get('color'));
|
|
2243
2552
|
// The links' color: the most used one that is not the body text's.
|
|
2244
|
-
const link = (
|
|
2553
|
+
const link = (_ref3 = (_filter_sort_ = [
|
|
2245
2554
|
...linkColors.entries()
|
|
2246
|
-
].filter(([hex])=>hex !== text).sort((a, b)=>b[1] - a[1])[0]) == null ? void 0 : _filter_sort_[0]) != null ?
|
|
2247
|
-
const header = (
|
|
2555
|
+
].filter(([hex])=>hex !== text).sort((a, b)=>b[1] - a[1])[0]) == null ? void 0 : _filter_sort_[0]) != null ? _ref3 : null;
|
|
2556
|
+
const header = (_elements_find2 = elements.find((element)=>element.tag === 'header' && element.region === 'header')) != null ? _elements_find2 : elements.find((element)=>element.attrs.role === 'banner');
|
|
2248
2557
|
let headerFill = null;
|
|
2249
|
-
for(let at = (
|
|
2250
|
-
var
|
|
2558
|
+
for(let at = (_ref4 = header == null ? void 0 : header.id) != null ? _ref4 : -1, depth = 0; at >= 0 && depth < 3; depth += 1){
|
|
2559
|
+
var _ref9;
|
|
2251
2560
|
var _elements_at1;
|
|
2252
2561
|
const color = siteImportBackgroundOf(styles.of(at)).color;
|
|
2253
2562
|
if (color && color.a >= 0.5) {
|
|
2254
2563
|
headerFill = siteImportHex(color);
|
|
2255
2564
|
break;
|
|
2256
2565
|
}
|
|
2257
|
-
const children = (
|
|
2566
|
+
const children = (_ref9 = (_elements_at1 = elements[at]) == null ? void 0 : _elements_at1.children) != null ? _ref9 : [];
|
|
2258
2567
|
at = children.length === 1 ? children[0] : -1;
|
|
2259
2568
|
}
|
|
2260
|
-
|
|
2569
|
+
// The page's own fill in its dark scheme, where its stylesheets change it.
|
|
2570
|
+
const darkFill = darkStyles ? (_siteImportBackgroundOf_color1 = siteImportBackgroundOf(darkStyles.of(body)).color) != null ? _siteImportBackgroundOf_color1 : siteImportBackgroundOf(darkStyles.of(-2)).color : null;
|
|
2571
|
+
const darkGround = darkFill && darkFill.a >= 0.5 && (!background || siteImportHex(darkFill) !== siteImportHex(background)) ? siteImportHex(darkFill) : null;
|
|
2572
|
+
const palette = variableUses ? siteImportPaletteOf(styles, variableUses) : [];
|
|
2573
|
+
return _extends({
|
|
2261
2574
|
fonts: {
|
|
2262
2575
|
body: known(bodyFamily),
|
|
2263
2576
|
headings: known(headingFamily),
|
|
@@ -2265,21 +2578,29 @@ function mode(values) {
|
|
|
2265
2578
|
},
|
|
2266
2579
|
background: background ? siteImportHex(background) : null,
|
|
2267
2580
|
text,
|
|
2268
|
-
buttonFill: (
|
|
2269
|
-
buttonText: (
|
|
2581
|
+
buttonFill: (_ref5 = topFill == null ? void 0 : topFill[0]) != null ? _ref5 : null,
|
|
2582
|
+
buttonText: (_ref6 = topFill == null ? void 0 : topFill[1].text) != null ? _ref6 : null,
|
|
2270
2583
|
buttonRadius: radii.length ? radii.sort((a, b)=>a - b)[Math.floor(radii.length / 2)] : null,
|
|
2271
2584
|
link,
|
|
2272
2585
|
header: headerFill,
|
|
2273
|
-
darkBackground: darkBackgroundOf(sections),
|
|
2274
|
-
|
|
2275
|
-
|
|
2586
|
+
darkBackground: darkGround != null ? darkGround : darkBackgroundOf(sections),
|
|
2587
|
+
paperBackground: mostUsedFill(sections.filter((section)=>section.band === 'soft').map((section)=>section.background)),
|
|
2588
|
+
darkPaper: mostUsedFill(sections.filter((section)=>section.band === 'soft').map((section)=>section.darkBackground)),
|
|
2589
|
+
// Most of each style's buttons decide; none, and its case is no fact of the source's.
|
|
2590
|
+
buttonCase: caseOf(filledCase),
|
|
2591
|
+
outlinedCase: caseOf(outlinedCase),
|
|
2592
|
+
textCase: caseOf(textCase),
|
|
2593
|
+
buttonOutline: mostUsedFill(outlines),
|
|
2594
|
+
outlinedFill: mostUsedFill(outlinedFills),
|
|
2276
2595
|
// Its eyebrows' own color: none of its words', its buttons' or its links', which the theme draws already.
|
|
2277
2596
|
eyebrow: blocks.length ? eyebrowColorOf(structure, styles, blocks, [
|
|
2278
2597
|
text,
|
|
2279
|
-
(
|
|
2598
|
+
(_ref7 = topFill == null ? void 0 : topFill[0]) != null ? _ref7 : null,
|
|
2280
2599
|
link
|
|
2281
2600
|
]) : null
|
|
2282
|
-
}
|
|
2601
|
+
}, palette.length ? {
|
|
2602
|
+
palette
|
|
2603
|
+
} : {});
|
|
2283
2604
|
}
|
|
2284
2605
|
/** Counts a layout's sections, bands, rows, groups, pictures, icons and buttons. */ export function siteImportLayoutCounts(layout, blocks = []) {
|
|
2285
2606
|
const counts = {
|