@aglyn/plugins-ai 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +2 -2
  2. package/package.json +17 -17
  3. package/src/lib/components/ai-insight-dialog.component.js +14 -0
  4. package/src/lib/components/ai-insight-dialog.component.js.map +1 -1
  5. package/src/lib/insights/ai-figure-readers.d.ts +13 -0
  6. package/src/lib/insights/ai-figure-readers.js +158 -11
  7. package/src/lib/insights/ai-figure-readers.js.map +1 -1
  8. package/src/lib/insights/ai-figure-summaries.js +4 -2
  9. package/src/lib/insights/ai-figure-summaries.js.map +1 -1
  10. package/src/lib/insights/ai-insight-digest.d.ts +27 -17
  11. package/src/lib/insights/ai-insight-digest.js +96 -107
  12. package/src/lib/insights/ai-insight-digest.js.map +1 -1
  13. package/src/lib/jobs/ai-job-import-step.d.ts +28 -2
  14. package/src/lib/jobs/ai-job-import-step.js +170 -14
  15. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  16. package/src/lib/jobs/ai-job-insight-budget.d.ts +19 -3
  17. package/src/lib/jobs/ai-job-insight-budget.js +18 -4
  18. package/src/lib/jobs/ai-job-insight-budget.js.map +1 -1
  19. package/src/lib/jobs/ai-job-insight-step.d.ts +2 -2
  20. package/src/lib/jobs/ai-job-insight-step.js +17 -7
  21. package/src/lib/jobs/ai-job-insight-step.js.map +1 -1
  22. package/src/lib/jobs/ai-job-layout-language.js +2 -0
  23. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  24. package/src/lib/jobs/ai-job-page-language.js +6 -2
  25. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  26. package/src/lib/jobs/ai-site-import-compile.d.ts +13 -3
  27. package/src/lib/jobs/ai-site-import-compile.js +336 -27
  28. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  29. package/src/lib/jobs/ai-site-import-document.d.ts +3 -1
  30. package/src/lib/jobs/ai-site-import-document.js +36 -0
  31. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  32. package/src/lib/jobs/ai-site-import-look.d.ts +9 -0
  33. package/src/lib/jobs/ai-site-import-look.js +89 -6
  34. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  35. package/src/lib/layout-language/ai-layout-compiler.d.ts +16 -0
  36. package/src/lib/layout-language/ai-layout-compiler.js +351 -54
  37. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  38. package/src/lib/layout-language/ai-layout-frame-source.d.ts +88 -2
  39. package/src/lib/layout-language/ai-layout-frame-source.js +591 -30
  40. package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
  41. package/src/lib/layout-language/ai-layout-frame.js +30 -18
  42. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  43. package/src/lib/layout-language/ai-layout-language.d.ts +72 -3
  44. package/src/lib/layout-language/ai-layout-language.js +5 -3
  45. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  46. package/src/lib/layout-language/ai-layout-store.d.ts +8 -0
  47. package/src/lib/layout-language/ai-layout-store.js +32 -6
  48. package/src/lib/layout-language/ai-layout-store.js.map +1 -1
  49. package/src/lib/model/ai-insight.d.ts +23 -3
  50. package/src/lib/model/ai-insight.js +17 -3
  51. package/src/lib/model/ai-insight.js.map +1 -1
  52. package/src/lib/model/ai-site-import-fidelity.d.ts +31 -1
  53. package/src/lib/model/ai-site-import-fidelity.js +347 -25
  54. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  55. package/src/lib/model/ai-site-import.d.ts +203 -6
  56. package/src/lib/model/ai-site-import.js +161 -5
  57. package/src/lib/model/ai-site-import.js.map +1 -1
  58. package/src/lib/model/ai-site-look.d.ts +8 -1
  59. package/src/lib/model/ai-site-look.js +8 -5
  60. package/src/lib/model/ai-site-look.js.map +1 -1
  61. package/src/lib/providers/routing.js +3 -1
  62. package/src/lib/providers/routing.js.map +1 -1
  63. package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -1
  64. package/src/lib/runtime/ai-doctrine-validators.js +25 -2
  65. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  66. package/src/lib/runtime/ai-insight-check.d.ts +7 -0
  67. package/src/lib/runtime/ai-insight-check.js +111 -27
  68. package/src/lib/runtime/ai-insight-check.js.map +1 -1
  69. package/src/lib/runtime/ai-node-tree.js +19 -2
  70. package/src/lib/runtime/ai-node-tree.js.map +1 -1
  71. package/src/lib/runtime/ai-page-links.d.ts +15 -0
  72. package/src/lib/runtime/ai-page-links.js +48 -0
  73. package/src/lib/runtime/ai-page-links.js.map +1 -1
  74. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +30 -5
  75. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  76. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +9 -0
  77. package/src/lib/site-import/fixtures/site-layout-recordings.js +24 -5
  78. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  79. package/src/lib/site-import/site-import-crawl.d.ts +3 -1
  80. package/src/lib/site-import/site-import-crawl.js +8 -3
  81. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  82. package/src/lib/site-import/site-import-css.d.ts +20 -0
  83. package/src/lib/site-import/site-import-css.js +106 -0
  84. package/src/lib/site-import/site-import-css.js.map +1 -1
  85. package/src/lib/site-import/site-import-html.d.ts +39 -0
  86. package/src/lib/site-import/site-import-html.js +515 -5
  87. package/src/lib/site-import/site-import-html.js.map +1 -1
  88. package/src/lib/site-import/site-import-layout.d.ts +16 -6
  89. package/src/lib/site-import/site-import-layout.js +524 -52
  90. package/src/lib/site-import/site-import-layout.js.map +1 -1
  91. package/src/lib/site-import/site-import-nav.js +286 -24
  92. package/src/lib/site-import/site-import-nav.js.map +1 -1
  93. package/src/lib/site-import/site-import-page.js +3 -0
  94. package/src/lib/site-import/site-import-page.js.map +1 -1
  95. package/src/lib/tools/ai-insight-tool.js +45 -2
  96. package/src/lib/tools/ai-insight-tool.js.map +1 -1
@@ -1,3 +1,4 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
1
2
  /**
2
3
  * @license
3
4
  * Copyright 2026 Aglyn LLC
@@ -41,7 +42,13 @@
41
42
  * source stands in for an `<img>` with no address; and the head's share card,
42
43
  * icons, site name and Organization structured data come along for the
43
44
  * header, the footer and the site's own facts.
44
- *=========================================*/ /** One run of a page's content, in the order the page draws it. */ import { _ as _extends } from "@swc/helpers/_/_extends";
45
+ *
46
+ * A video is kept where it sits (AGL-4140): a `<video>`, a video host's
47
+ * `<iframe>`, a facade that stands in for one (a play button over a still),
48
+ * and the page's `VideoObject` structured data and `og:video`, each once,
49
+ * with its poster as the picture inside it. Its attributes and its data are
50
+ * read; nothing of it is run.
51
+ *=========================================*/ import { videoEmbedOf } from "@aglyn/aglyn/plugin-manager/video-embed-provider";
45
52
  /** Ceilings that keep one odd page from becoming the whole inventory. */ export const SITE_IMPORT_PAGE_LIMITS = {
46
53
  /** A pricing page's plan table runs past 400 (AGL-4083); a wave's read keeps fewer, under its own budget. */ blocks: 2000,
47
54
  /** A legal page's paragraph runs past 2,000 characters. */ blockChars: 10000,
@@ -55,7 +62,8 @@
55
62
  svgIcons: 200,
56
63
  anchors: 800,
57
64
  styleChars: 1500000,
58
- stylesheets: 4
65
+ stylesheets: 4,
66
+ /** A page's videos (AGL-4140). */ videos: 10
59
67
  };
60
68
  /** Elements removed with everything inside them. */ const REMOVED_WITH_CONTENT = [
61
69
  'script',
@@ -574,6 +582,475 @@ const ORGANIZATION_TYPE = /(?:^|\b)(?:Organization|Corporation|LocalBusiness|NGO
574
582
  sameAs: [].concat((_node_sameAs = node['sameAs']) != null ? _node_sameAs : []).map((entry)=>urlOf(entry)).filter(Boolean).slice(0, 20)
575
583
  };
576
584
  }
585
+ /*------------------------------------------
586
+ * The page's videos (AGL-4140)
587
+ *-----------------------------------------*/ /** What a video is never read inside: a script's text, a style, a template, a fallback for no script. */ const VIDEO_SHIELDED = /<(script|style|template|noscript|textarea)\b(?:[^>"']|"[^"]*"|'[^']*')*>[\s\S]*?<\/\1\s*>/gi;
588
+ /** What marks a shielded stretch's place, and a video's, while the videos are read: characters no page writes. */ const SHIELD = '\u0002';
589
+ const PLACE = '\u0003';
590
+ /** A shielded stretch's place while the videos are read. */ const SHIELD_MARK = new RegExp(`${SHIELD}(\\d+)${SHIELD}`, 'g');
591
+ /** The words that name a facade's control as one that plays a film. */ const PLAY_WORDS = /\b(?:play|watch|video|film)\b/i;
592
+ /** A facade's label read as the film's name: "Play video: Our story" is "Our story". */ const PLAY_PREFIX = /^\s*(?:play|watch)(?:\s+(?:the\s+)?(?:video|film))?\s*(?:[:\-–—]\s*|$)/i;
593
+ /** A frame's title that names only its player ("Video player", "YouTube video player"), never the film. */ const PLAYER_TITLE = 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}]+\\s+)?(?:video\\s+)?player$", "iu");
594
+ /** A film's file, by its address. */ const VIDEO_FILE = /\.(?:mp4|m4v|webm|mov|ogv)(?:$|[?#])/i;
595
+ /** The structured data's scripts. */ const LD_JSON = /<script\b[^>]*\btype\s*=\s*["']?application\/ld\+json["']?[^>]*>([\s\S]*?)<\/script\s*>/gi;
596
+ /** A video host's id, by the attribute that names it: the player the Video element frames for it. */ const VIDEO_ID_PLAYERS = [
597
+ {
598
+ host: /youtube/i,
599
+ id: /^[\w-]{11}$/,
600
+ player: (id)=>`https://www.youtube-nocookie.com/embed/${id}`
601
+ },
602
+ {
603
+ host: /vimeo/i,
604
+ id: /^\d{6,12}$/,
605
+ player: (id)=>`https://player.vimeo.com/video/${id}`
606
+ },
607
+ {
608
+ host: /wistia/i,
609
+ id: /^[a-z0-9]{10}$/,
610
+ player: (id)=>`https://fast.wistia.net/embed/iframe/${id}`
611
+ }
612
+ ];
613
+ /** A run of seconds an ISO 8601 duration names (`PT1M30S` is 90), or `undefined`. */ function isoSeconds(value) {
614
+ const match = /^P(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/i.exec(String(value != null ? value : '').trim());
615
+ if (!match || !match.slice(1).some((part)=>part !== undefined)) return undefined;
616
+ const [days, hours, minutes, seconds] = match.slice(1).map((part)=>Number(part != null ? part : 0));
617
+ const total = (days != null ? days : 0) * 86400 + (hours != null ? hours : 0) * 3600 + (minutes != null ? minutes : 0) * 60 + (seconds != null ? seconds : 0);
618
+ return total > 0 ? Math.round(total) : undefined;
619
+ }
620
+ /** The day a date or a date-time names, `YYYY-MM-DD`, or `undefined`. */ function isoDay(value) {
621
+ var _exec;
622
+ return (_exec = /^(\d{4}-\d{2}-\d{2})/.exec(String(value != null ? value : '').trim())) == null ? void 0 : _exec[1];
623
+ }
624
+ /** An attribute's whole number of pixels, or `undefined`. */ function pixels(value) {
625
+ const number = Number(String(value != null ? value : '').trim());
626
+ return Number.isInteger(number) && number > 0 && number <= 10000 ? number : undefined;
627
+ }
628
+ /** A `<video>`'s or a frame's own facts: how it plays, and its size. */ function videoAttributes(attributes) {
629
+ const width = pixels(attributes['width']);
630
+ const height = pixels(attributes['height']);
631
+ return _extends({}, 'autoplay' in attributes ? {
632
+ autoplay: true
633
+ } : {}, 'muted' in attributes ? {
634
+ muted: true
635
+ } : {}, 'loop' in attributes ? {
636
+ loop: true
637
+ } : {}, 'controls' in attributes ? {
638
+ controls: true
639
+ } : {}, width ? {
640
+ width
641
+ } : {}, height ? {
642
+ height
643
+ } : {});
644
+ }
645
+ /** A film's name as its element gives it: a frame's title that names only its player is none. */ function videoName(value) {
646
+ const name = clip(collapse(decodeHtmlEntities(String(value != null ? value : '').replace(PLAY_PREFIX, ''))), 200);
647
+ return PLAYER_TITLE.test(name) ? '' : name;
648
+ }
649
+ /** Whether two addresses name one film: the same address, or the same host's same media id. */ function sameFilm(a, b) {
650
+ if (!a || !b) return false;
651
+ if (a === b) return true;
652
+ const left = videoEmbedOf(a);
653
+ const right = videoEmbedOf(b);
654
+ return !!left && !!right && left.provider.id === right.provider.id && left.mediaId === right.mediaId;
655
+ }
656
+ /** An address's path, its query and fragment left off: how a poster is matched to the structured data's thumbnail. */ function pathOf(url) {
657
+ try {
658
+ return url ? new URL(url).pathname : null;
659
+ } catch (unused) {
660
+ return null;
661
+ }
662
+ }
663
+ /** The page's `VideoObject`s, read before scripts go; malformed data says nothing and nothing in it is run. */ function readVideoObjects(html, pageUrl) {
664
+ const nodes = [];
665
+ const visit = (value, depth)=>{
666
+ var _node_type;
667
+ if (depth > 5 || nodes.length >= SITE_IMPORT_PAGE_LIMITS.videos || !value || typeof value !== 'object') return;
668
+ if (Array.isArray(value)) {
669
+ for (const entry of value)visit(entry, depth + 1);
670
+ return;
671
+ }
672
+ const node = value;
673
+ if ([].concat((_node_type = node['@type']) != null ? _node_type : []).some((type)=>/^(?:schema:)?VideoObject$/i.test(String(type)))) nodes.push(node);
674
+ for (const key of [
675
+ '@graph',
676
+ 'video',
677
+ 'mainEntity',
678
+ 'hasPart',
679
+ 'associatedMedia',
680
+ 'subjectOf'
681
+ ])if (node[key]) visit(node[key], depth + 1);
682
+ };
683
+ for (const match of html.matchAll(LD_JSON)){
684
+ try {
685
+ visit(JSON.parse(match[1]), 0);
686
+ } catch (unused) {
687
+ // Structured data that does not parse says nothing.
688
+ }
689
+ }
690
+ const text = (value, max)=>typeof value === 'string' ? clip(collapse(decodeHtmlEntities(value)), max) : '';
691
+ const address = (value)=>{
692
+ var _resolveSiteUrl;
693
+ const raw = [].concat(value != null ? value : [])[0];
694
+ const written = typeof raw === 'string' ? raw : raw && typeof raw === 'object' ? raw['url'] : undefined;
695
+ return typeof written === 'string' ? (_resolveSiteUrl = resolveSiteUrl(written, pageUrl)) == null ? void 0 : _resolveSiteUrl.toString() : undefined;
696
+ };
697
+ return nodes.map((node)=>{
698
+ const embed = address(node['embedUrl']);
699
+ const content = address(node['contentUrl']);
700
+ const poster = address(node['thumbnailUrl']);
701
+ const description = text(node['description'], 2000);
702
+ const uploadDate = isoDay(node['uploadDate']);
703
+ const durationSeconds = isoSeconds(node['duration']);
704
+ return _extends({}, content ? {
705
+ src: content
706
+ } : {}, embed && embed.startsWith('https:') ? {
707
+ embed
708
+ } : {}, poster ? {
709
+ poster
710
+ } : {}, {
711
+ title: text(node['name'], 200)
712
+ }, description ? {
713
+ description
714
+ } : {}, uploadDate ? {
715
+ uploadDate
716
+ } : {}, durationSeconds ? {
717
+ durationSeconds
718
+ } : {});
719
+ });
720
+ }
721
+ /** Where the element opening at `start` ends: past its own end tag, others of its kind inside it counted; the document's end for one left open. */ function elementEnd(html, tag, start) {
722
+ const pattern = new RegExp(`<(/?)${tag}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`, 'gi');
723
+ pattern.lastIndex = start;
724
+ let depth = 0;
725
+ for(let match = pattern.exec(html); match; match = pattern.exec(html)){
726
+ if (match[1]) {
727
+ depth -= 1;
728
+ if (depth <= 0) return match.index + match[0].length;
729
+ } else if (!/\/\s*>$/.test(match[0])) depth += 1;
730
+ }
731
+ return html.length;
732
+ }
733
+ /**
734
+ * Where a film the page names only in its head or its data is placed: after
735
+ * the words of its opening, at the end of the element that holds its `h1`;
736
+ * at the start of its main content when it has no `h1`.
737
+ */ function openingWordsEnd(html) {
738
+ const h1 = /<h1\b/i.exec(html);
739
+ if (!h1) {
740
+ var _exec;
741
+ const main = (_exec = /<main\b(?:[^>"']|"[^"]*"|'[^']*')*>/i.exec(html)) != null ? _exec : /<body\b(?:[^>"']|"[^"]*"|'[^']*')*>/i.exec(html);
742
+ return main ? main.index + main[0].length : html.length;
743
+ }
744
+ const open = [];
745
+ for (const match of html.slice(0, h1.index).matchAll(TAG)){
746
+ var _match_;
747
+ const tag = match[2].toLowerCase();
748
+ if (VOID_TAGS.has(tag) || /\/\s*$/.test((_match_ = match[3]) != null ? _match_ : '')) continue;
749
+ if (match[1] === '/') {
750
+ const at = open.map((entry)=>entry.tag).lastIndexOf(tag);
751
+ if (at >= 0) open.length = at;
752
+ continue;
753
+ }
754
+ open.push({
755
+ tag,
756
+ start: match.index
757
+ });
758
+ }
759
+ const parent = open[open.length - 1];
760
+ if (!parent || /^(?:html|body|main)$/.test(parent.tag)) return elementEnd(html, 'h1', h1.index);
761
+ return elementEnd(html, parent.tag, parent.start);
762
+ }
763
+ /**
764
+ * The marker a video leaves at its place, with the styles of the element it
765
+ * stands for, and its poster inside it as a picture the walk reads: the
766
+ * page's own `<img>` where the page drew one, framed as the page frames it.
767
+ */ function videoMarker(index, poster, own) {
768
+ var _poster_tag, _poster_size;
769
+ const quote = (value)=>value.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;');
770
+ const picture = poster ? (_poster_tag = poster.tag) != null ? _poster_tag : `<img src="${quote(poster.url)}" alt="${quote(poster.alt)}"${(_poster_size = poster.size) != null ? _poster_size : ''}>` : '';
771
+ return ` <aglyn-video data-video="${index}"${own}>${picture}</aglyn-video> `;
772
+ }
773
+ /** The attributes of an element that style it, as a marker or a box keeps them: its classes, its inline style, its id. */ function styling(attributes) {
774
+ const quote = (value)=>value.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;');
775
+ return [
776
+ 'class',
777
+ 'style',
778
+ 'id'
779
+ ].flatMap((name)=>attributes[name] !== undefined ? [
780
+ ` ${name}="${quote(attributes[name])}"`
781
+ ] : []).join('');
782
+ }
783
+ /** A video's place while the page is read, written once every video's poster is known. */ const VIDEO_PLACE = new RegExp(`${PLACE}(\\d+)${PLACE}`, 'g');
784
+ /**
785
+ * Every video the page shows (AGL-4140), each once, at most
786
+ * `SITE_IMPORT_PAGE_LIMITS.videos`, and the page with a marker at each one's
787
+ * place, its poster inside it as a picture. Read in this order:
788
+ *
789
+ * 1. a `<video>`, from its `src` or its first `<source>`;
790
+ * 2. an `<iframe>` of a video host whose player the Video element frames;
791
+ * 3. a facade: a `lite-youtube` or `lite-vimeo` element, an element naming a
792
+ * host's video id (`data-youtube-id`, `data-wistia-id`, `data-video-id`
793
+ * with the host named beside it), and a `<button>` or `<a>` around a
794
+ * picture whose label or words say it plays a film, or that links a video
795
+ * host's page. Its picture is the film's poster, and words that only name
796
+ * its control are the film's name;
797
+ * 4. the structured data's `VideoObject`s, each matched to a video already
798
+ * found that plays the same film, else to a facade whose picture is its
799
+ * thumbnail, else to the first facade with no film of its own, else one
800
+ * of its own; a thumbnail is the poster of a film that showed none;
801
+ * 5. the head's `og:video`, unless it is a film already found.
802
+ *
803
+ * A film only the data or the head names is placed after the words of the
804
+ * page's opening, or, where the page's own films are placed already, at the
805
+ * end of its main content. A facade with no film found for it is left as it
806
+ * was: a picture in a button. Scripts, styles and templates are never read
807
+ * for one.
808
+ */ function readVideos(html, pageUrl, isSameSite) {
809
+ var _resolveSiteUrl;
810
+ const videos = [];
811
+ /** Each video's poster as its place draws it, and the styles of the element it stands for. */ const places = new Map();
812
+ const room = ()=>videos.length < SITE_IMPORT_PAGE_LIMITS.videos;
813
+ const placed = (video, own, poster = null)=>{
814
+ videos.push(video);
815
+ // A poster drawn from the data takes the player's own size, the shape the page gave the film.
816
+ places.set(videos.length - 1, {
817
+ poster,
818
+ own,
819
+ size: `${video.width ? ` width="${video.width}"` : ''}${video.height ? ` height="${video.height}"` : ''}`
820
+ });
821
+ return `${PLACE}${videos.length - 1}${PLACE}`;
822
+ };
823
+ const shielded = [];
824
+ let out = html.replace(VIDEO_SHIELDED, (whole)=>{
825
+ shielded.push(whole);
826
+ return `${SHIELD}${shielded.length - 1}${SHIELD}`;
827
+ });
828
+ const imageOf = (inner, style)=>{
829
+ var _attributes_alt;
830
+ var _exec;
831
+ const img = /<img\b((?:[^>"']|"[^"]*"|'[^']*')*)>/i.exec(inner);
832
+ const attributes = img ? parseAttributes(img[1]) : {};
833
+ const drawn = (_exec = /background(?:-image)?\s*:[^;]*url\(\s*(['"]?)([^'")]+)\1\s*\)/i.exec(style != null ? style : '')) == null ? void 0 : _exec[2];
834
+ const own = resolveSiteUrl(attributes['src'] || attributes['data-src'] || firstSrcset(attributes['srcset'] || attributes['data-srcset']), pageUrl);
835
+ const url = own != null ? own : resolveSiteUrl(drawn, pageUrl);
836
+ return url ? _extends({
837
+ url: url.toString(),
838
+ alt: clip(collapse((_attributes_alt = attributes['alt']) != null ? _attributes_alt : ''), 300)
839
+ }, own && img ? {
840
+ tag: img[0]
841
+ } : {}) : null;
842
+ };
843
+ // 1. The page's own players.
844
+ out = out.replace(/<video\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/video\s*>/gi, (whole, attributeSource, inner)=>{
845
+ var _resolveSiteUrl, _resolveSiteUrl1;
846
+ if (!room()) return whole;
847
+ const attributes = parseAttributes(attributeSource);
848
+ const sources = [
849
+ ...inner.matchAll(/<source\b((?:[^>"']|"[^"]*"|'[^']*')*)>/gi)
850
+ ].map((match)=>parseAttributes(match[1]));
851
+ const src = (_resolveSiteUrl = resolveSiteUrl(attributes['src'] || attributes['data-src'] || sources.map((source)=>source['src'] || source['data-src']).find(Boolean), pageUrl)) == null ? void 0 : _resolveSiteUrl.toString();
852
+ if (!src) return whole;
853
+ const poster = (_resolveSiteUrl1 = resolveSiteUrl(attributes['poster'] || attributes['data-poster'], pageUrl)) == null ? void 0 : _resolveSiteUrl1.toString();
854
+ return placed(_extends({
855
+ src
856
+ }, poster ? {
857
+ poster
858
+ } : {}, {
859
+ title: videoName(attributes['title'] || attributes['aria-label'])
860
+ }, videoAttributes(attributes)), styling(attributes));
861
+ });
862
+ // 2. A video host's player in a frame.
863
+ out = out.replace(/<iframe\b((?:[^>"']|"[^"]*"|'[^']*')*)>(?:[\s\S]*?<\/iframe\s*>)?/gi, (whole, attributeSource)=>{
864
+ if (!room()) return whole;
865
+ const attributes = parseAttributes(attributeSource);
866
+ const url = resolveSiteUrl(attributes['src'] || attributes['data-src'], pageUrl);
867
+ if (!url || url.protocol !== 'https:' || !videoEmbedOf(url.toString())) return whole;
868
+ const { width, height } = videoAttributes(attributes);
869
+ return placed(_extends({
870
+ embed: url.toString(),
871
+ title: videoName(attributes['title'] || attributes['aria-label'])
872
+ }, width ? {
873
+ width
874
+ } : {}, height ? {
875
+ height
876
+ } : {}), styling(attributes));
877
+ });
878
+ // 3. Facades, outermost first, none inside another.
879
+ const facades = [];
880
+ for (const match of out.matchAll(/<([a-z][\w-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)>/gi)){
881
+ const start = match.index;
882
+ const tag = match[1].toLowerCase();
883
+ if (!/^(?:button|a|lite-youtube|lite-vimeo)$/.test(tag) && !/\bdata-(?:youtube|vimeo|wistia|video)-id\b/i.test(match[2])) continue;
884
+ if (facades.some((facade)=>start >= facade.start && start < facade.end)) continue;
885
+ const attributes = parseAttributes(match[2]);
886
+ const named = Object.entries(attributes).find(([name])=>/^data-(?:youtube|vimeo|wistia|video)-id$/.test(name));
887
+ if (!/^(?:button|a|lite-youtube|lite-vimeo)$/.test(tag) && !named) continue;
888
+ const end = elementEnd(out, tag, start);
889
+ const inner = out.slice(start + match[0].length, end).replace(new RegExp(`<\\/${tag}\\s*>$`, 'i'), '');
890
+ const words = collapse(decodeHtmlEntities(inner.replace(/<[^>]*>/g, ' ').replace(SHIELD_MARK, ' ')));
891
+ const label = attributes['aria-label'] || attributes['playlabel'] || attributes['title'] || '';
892
+ const poster = imageOf(inner, tag.startsWith('lite-') || named ? attributes['style'] : undefined);
893
+ let address;
894
+ let file;
895
+ // A host's id, on a lite element or named by a data attribute with the host beside it.
896
+ const id = tag.startsWith('lite-') ? attributes['videoid'] : named == null ? void 0 : named[1];
897
+ if (id) {
898
+ var _ref, _attributes_class, _attributes_dataprovider, _attributes_datatype, _attributes_dataplatform;
899
+ const hint = tag.startsWith('lite-') ? tag : `${(_ref = named == null ? void 0 : named[0]) != null ? _ref : ''} ${(_attributes_class = attributes['class']) != null ? _attributes_class : ''} ${(_attributes_dataprovider = attributes['data-provider']) != null ? _attributes_dataprovider : ''} ${(_attributes_datatype = attributes['data-type']) != null ? _attributes_datatype : ''} ${(_attributes_dataplatform = attributes['data-platform']) != null ? _attributes_dataplatform : ''}`;
900
+ const player = VIDEO_ID_PLAYERS.find((entry)=>entry.host.test(hint) && entry.id.test(id.trim()));
901
+ if (player) address = player.player(id.trim());
902
+ }
903
+ let open = false;
904
+ if (!address && (tag === 'button' || tag === 'a')) {
905
+ var _attributes_href, _attributes_href1;
906
+ if (!poster) continue;
907
+ const href = tag === 'a' ? resolveSiteUrl(attributes['href'], pageUrl) : null;
908
+ const given = [
909
+ 'data-src',
910
+ 'data-video',
911
+ 'data-video-url',
912
+ 'data-video-src',
913
+ 'data-embed',
914
+ 'data-url'
915
+ ].map((name)=>attributes[name]).find(Boolean);
916
+ const own = resolveSiteUrl(given, pageUrl);
917
+ const plays = PLAY_WORDS.test(label) || PLAY_WORDS.test(words);
918
+ if (own && videoEmbedOf(own.toString())) address = own.toString();
919
+ else if (own && VIDEO_FILE.test(own.pathname)) file = own.toString();
920
+ else if (href && videoEmbedOf(href.toString())) address = href.toString();
921
+ else if (href && plays && href.protocol === 'https:' && !isSameSite(href)) address = href.toString();
922
+ else if (!plays || href && ((_attributes_href = attributes['href']) != null ? _attributes_href : '').trim() && !/^(?:#|javascript:)/i.test(((_attributes_href1 = attributes['href']) != null ? _attributes_href1 : '').trim())) continue;
923
+ else open = true;
924
+ }
925
+ if (!address && !file && !open) continue;
926
+ // The facade's box stays, for the layout it sets (a card, a frame), and
927
+ // so does what else it says; its picture is the film's poster. A link or
928
+ // a button is no destination once the film plays in its place, so its box
929
+ // is a plain one, keeping only what styles it.
930
+ const box = tag === 'a' || tag === 'button' ? 'div' : tag;
931
+ const rest = poster ? inner.replace(/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/i, ' ') : inner;
932
+ // Words that only name the control ("Play video", "Play: A morning with us") are the film's name, not words beside it.
933
+ const said = collapse(decodeHtmlEntities(rest.replace(/<[^>]*>/g, ' ').replace(SHIELD_MARK, ' ')));
934
+ const keeps = !!videoName(said) && videoName(said) !== videoName(label) && !PLAY_PREFIX.test(said);
935
+ facades.push({
936
+ start,
937
+ end,
938
+ // With nothing else to say, the marker is its box, so its poster sits as deep as the page set it.
939
+ place: (token)=>keeps ? `<${box}${styling(attributes)}>${token}${rest}</${box}>` : token,
940
+ own: keeps ? '' : styling(attributes),
941
+ poster,
942
+ addressed: !!address || !!file,
943
+ open,
944
+ video: _extends({}, file ? {
945
+ src: file
946
+ } : {}, address ? {
947
+ embed: address
948
+ } : {}, poster ? {
949
+ poster: poster.url
950
+ } : {}, {
951
+ title: videoName(label) || (keeps ? '' : videoName(words)) || videoName(poster == null ? void 0 : poster.alt)
952
+ })
953
+ });
954
+ }
955
+ // 4. The structured data's films, each once.
956
+ const standalone = [];
957
+ for (const object of readVideoObjects(html, pageUrl)){
958
+ var _videos_find, _facades_find;
959
+ var _facades_find1;
960
+ const merge = (video)=>{
961
+ if (object.title) video.title = object.title;
962
+ if (object.description) video.description = object.description;
963
+ if (object.uploadDate) video.uploadDate = object.uploadDate;
964
+ if (object.durationSeconds) video.durationSeconds = object.durationSeconds;
965
+ if (!video.embed && !video.src) {
966
+ if (object.embed) video.embed = object.embed;
967
+ if (object.src) video.src = object.src;
968
+ }
969
+ if (!video.poster && object.poster) video.poster = object.poster;
970
+ };
971
+ const same = (video)=>sameFilm(video.embed, object.embed) || sameFilm(video.src, object.src);
972
+ const found = (_videos_find = videos.find(same)) != null ? _videos_find : (_facades_find1 = facades.find((facade)=>same(facade.video))) == null ? void 0 : _facades_find1.video;
973
+ if (found) {
974
+ merge(found);
975
+ continue;
976
+ }
977
+ if (!object.embed && !object.src) continue;
978
+ const thumbnail = pathOf(object.poster);
979
+ const facade = (_facades_find = facades.find((entry)=>{
980
+ var _entry_poster;
981
+ return entry.open && !entry.addressed && !!thumbnail && pathOf((_entry_poster = entry.poster) == null ? void 0 : _entry_poster.url) === thumbnail;
982
+ })) != null ? _facades_find : facades.find((entry)=>entry.open && !entry.addressed);
983
+ if (facade) {
984
+ merge(facade.video);
985
+ facade.addressed = true;
986
+ continue;
987
+ }
988
+ standalone.push(_extends({}, object));
989
+ }
990
+ // The facades with a film, in their places, in the page's order.
991
+ const kept = facades.filter((facade)=>facade.addressed).slice(0, Math.max(0, SITE_IMPORT_PAGE_LIMITS.videos - videos.length));
992
+ const tokens = kept.map((facade)=>placed(facade.video, facade.own, facade.poster));
993
+ for(let index = kept.length - 1; index >= 0; index -= 1){
994
+ const facade = kept[index];
995
+ out = `${out.slice(0, facade.start)}${facade.place(tokens[index])}${out.slice(facade.end)}`;
996
+ }
997
+ // 5. The head's film, unless it is one already found.
998
+ const meta = (key)=>{
999
+ var _ref;
1000
+ var _metaTags_find;
1001
+ return collapse((_ref = (_metaTags_find = metaTags(html).find((entry)=>{
1002
+ var _ref, _entry_property;
1003
+ return ((_ref = (_entry_property = entry['property']) != null ? _entry_property : entry['name']) != null ? _ref : '').toLowerCase() === key;
1004
+ })) == null ? void 0 : _metaTags_find['content']) != null ? _ref : '');
1005
+ };
1006
+ const ogVideo = (_resolveSiteUrl = resolveSiteUrl(meta('og:video:secure_url') || meta('og:video:url') || meta('og:video'), pageUrl)) == null ? void 0 : _resolveSiteUrl.toString();
1007
+ if (ogVideo && ![
1008
+ ...videos,
1009
+ ...standalone
1010
+ ].some((video)=>sameFilm(video.embed, ogVideo) || sameFilm(video.src, ogVideo))) {
1011
+ var _resolveSiteUrl1;
1012
+ const file = meta('og:video:type').toLowerCase().startsWith('video/') || VIDEO_FILE.test(ogVideo);
1013
+ const poster = (_resolveSiteUrl1 = resolveSiteUrl(meta('og:image:secure_url') || meta('og:image') || meta('og:image:url'), pageUrl)) == null ? void 0 : _resolveSiteUrl1.toString();
1014
+ if (file || ogVideo.startsWith('https:')) {
1015
+ standalone.push(_extends({}, file ? {
1016
+ src: ogVideo
1017
+ } : {
1018
+ embed: ogVideo
1019
+ }, poster ? {
1020
+ poster
1021
+ } : {}, {
1022
+ title: clip(meta('og:video:title') || meta('og:title'), 200)
1023
+ }));
1024
+ }
1025
+ }
1026
+ const alone = standalone.slice(0, Math.max(0, SITE_IMPORT_PAGE_LIMITS.videos - videos.length));
1027
+ if (alone.length) {
1028
+ const main = /<\/main\s*>/i.exec(out);
1029
+ const at = videos.length && main ? main.index : openingWordsEnd(out);
1030
+ const markers = alone.map((video)=>placed(video, ''));
1031
+ out = `${out.slice(0, at)}${markers.join('')}${out.slice(at)}`;
1032
+ }
1033
+ // Every place written, its poster the one each film ended with.
1034
+ out = out.replace(VIDEO_PLACE, (_whole, index)=>{
1035
+ var _ref, _ref1, _ref2;
1036
+ const at = Number(index);
1037
+ const video = videos[at];
1038
+ const place = places.get(at);
1039
+ const poster = (_ref = place == null ? void 0 : place.poster) != null ? _ref : (video == null ? void 0 : video.poster) ? {
1040
+ url: video.poster,
1041
+ alt: '',
1042
+ size: (_ref1 = place == null ? void 0 : place.size) != null ? _ref1 : ''
1043
+ } : null;
1044
+ return videoMarker(at, poster != null ? poster : undefined, (_ref2 = place == null ? void 0 : place.own) != null ? _ref2 : '');
1045
+ });
1046
+ return {
1047
+ html: out.replace(SHIELD_MARK, (_whole, index)=>{
1048
+ var _shielded_Number;
1049
+ return (_shielded_Number = shielded[Number(index)]) != null ? _shielded_Number : '';
1050
+ }),
1051
+ videos
1052
+ };
1053
+ }
577
1054
  /*------------------------------------------
578
1055
  * How the page is built (AGL-4106)
579
1056
  *-----------------------------------------*/ const SVG_ELEMENT = /<svg\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/svg\s*>/gi;
@@ -863,7 +1340,7 @@ const P_WALLS = new Set([
863
1340
  'marquee',
864
1341
  'applet'
865
1342
  ]);
866
- /** The attributes the layout reader reads. */ function elementAttrs(attributes) {
1343
+ /** The attributes the layout reader reads; a picture's and a film's own size as numbers (AGL-4138). */ function elementAttrs(attributes, tag = '') {
867
1344
  var _attributes_datasectiontheme, _attributes_ariahidden;
868
1345
  var _text, _text1, _text2;
869
1346
  const attrs = {};
@@ -885,6 +1362,15 @@ const P_WALLS = new Set([
885
1362
  put('controls', text(attributes['aria-controls'], 120));
886
1363
  put('labelledby', text(attributes['aria-labelledby'], 120));
887
1364
  if ('hidden' in attributes || ((_attributes_ariahidden = attributes['aria-hidden']) != null ? _attributes_ariahidden : '').toLowerCase() === 'true') attrs.hidden = true;
1365
+ if (tag === 'img' || tag === 'video') {
1366
+ const size = (value)=>/^\s*\d{1,5}(?:px)?\s*$/.test(value != null ? value : '') ? Number.parseInt(value, 10) : 0;
1367
+ const width = size(attributes['width']);
1368
+ const height = size(attributes['height']);
1369
+ if (width > 0 && height > 0) {
1370
+ attrs.width = width;
1371
+ attrs.height = height;
1372
+ }
1373
+ }
888
1374
  return attrs;
889
1375
  }
890
1376
  /**
@@ -927,6 +1413,11 @@ const P_WALLS = new Set([
927
1413
  styles: [],
928
1414
  stylesheets: []
929
1415
  };
1416
+ // A video is a marker at its place (AGL-4140), read before scripts and
1417
+ // players go: its structured data is a script's body.
1418
+ const film = readVideos(source, pageUrl, isSameSite);
1419
+ source = film.html;
1420
+ const videos = film.videos;
930
1421
  // An inline icon is a marker at its place (AGL-4106); its drawing is never words.
931
1422
  const svgIcons = [];
932
1423
  source = readSvgIcons(source, svgIcons);
@@ -1046,7 +1537,7 @@ const P_WALLS = new Set([
1046
1537
  children: [],
1047
1538
  region: region(),
1048
1539
  nav: inNav(),
1049
- attrs: elementAttrs(attributes),
1540
+ attrs: elementAttrs(attributes, tag),
1050
1541
  blocks: []
1051
1542
  });
1052
1543
  (_elements_parent = elements[parent]) == null ? void 0 : _elements_parent.children.push(id);
@@ -1222,6 +1713,18 @@ const P_WALLS = new Set([
1222
1713
  }
1223
1714
  return;
1224
1715
  }
1716
+ if (tag === 'aglyn-video') {
1717
+ // A video at its place (AGL-4140): never words; its poster is the picture inside it.
1718
+ flush();
1719
+ boundary(true);
1720
+ const index = Number(attributes['data-video']);
1721
+ if (!closing && keep && element >= 0 && Number.isInteger(index) && videos[index]) {
1722
+ const own = elements[element];
1723
+ own.video = index;
1724
+ own.order = blocks.length - 0.5;
1725
+ }
1726
+ return;
1727
+ }
1225
1728
  if (tag === 'aglyn-form') {
1226
1729
  const index = Number(attributes['data-form']);
1227
1730
  if (keep && element >= 0 && Number.isInteger(index)) {
@@ -1238,6 +1741,10 @@ const P_WALLS = new Set([
1238
1741
  var _attributes_alt;
1239
1742
  const key = url.toString();
1240
1743
  const alt = clip(collapse((_attributes_alt = attributes['alt']) != null ? _attributes_alt : ''), 300);
1744
+ if (keep && element >= 0) elements[element].picture = {
1745
+ url: key,
1746
+ alt
1747
+ };
1241
1748
  if (anchor && !anchor.image) anchor.image = {
1242
1749
  url: key,
1243
1750
  alt
@@ -1349,7 +1856,10 @@ const P_WALLS = new Set([
1349
1856
  forms: {
1350
1857
  kept: forms.kept,
1351
1858
  removed: forms.removed
1352
- },
1859
+ }
1860
+ }, videos.length ? {
1861
+ videos
1862
+ } : {}, {
1353
1863
  loginForm: false
1354
1864
  }, keep ? {
1355
1865
  structure: {