@aglyn/plugins-ai 1.14.0 → 1.15.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 (128) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-site-build-page.component.js +5 -3
  3. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  4. package/src/lib/components/ai-site-import-finish.component.d.ts +3 -1
  5. package/src/lib/components/ai-site-import-finish.component.js +3 -3
  6. package/src/lib/components/ai-site-import-finish.component.js.map +1 -1
  7. package/src/lib/components/ai-site-import-job.component.d.ts +4 -3
  8. package/src/lib/components/ai-site-import-job.component.js +141 -43
  9. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  10. package/src/lib/components/ai-site-import-plan.component.d.ts +42 -0
  11. package/src/lib/components/ai-site-import-plan.component.js +246 -0
  12. package/src/lib/components/ai-site-import-plan.component.js.map +1 -0
  13. package/src/lib/components/ai-site-import-start.component.d.ts +3 -1
  14. package/src/lib/components/ai-site-import-start.component.js +3 -2
  15. package/src/lib/components/ai-site-import-start.component.js.map +1 -1
  16. package/src/lib/components/ai-site-start-card.component.js +6 -2
  17. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  18. package/src/lib/components/ai-site-start-steps.component.d.ts +3 -2
  19. package/src/lib/components/ai-site-start-steps.component.js +12 -5
  20. package/src/lib/components/ai-site-start-steps.component.js.map +1 -1
  21. package/src/lib/jobs/ai-job-import-step.d.ts +47 -2
  22. package/src/lib/jobs/ai-job-import-step.js +356 -22
  23. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  24. package/src/lib/jobs/ai-job-layout-language.js +4 -1
  25. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  26. package/src/lib/jobs/ai-job-page-language.d.ts +21 -2
  27. package/src/lib/jobs/ai-job-page-language.js +217 -5
  28. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  29. package/src/lib/jobs/ai-job-page-step.d.ts +7 -0
  30. package/src/lib/jobs/ai-job-page-step.js +73 -12
  31. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  32. package/src/lib/jobs/ai-job-plan-step.js +4 -2
  33. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  34. package/src/lib/jobs/ai-job-site-look.js +14 -5
  35. package/src/lib/jobs/ai-job-site-look.js.map +1 -1
  36. package/src/lib/jobs/ai-job-text-step.d.ts +10 -2
  37. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  38. package/src/lib/jobs/ai-jobs.js +2 -1
  39. package/src/lib/jobs/ai-jobs.js.map +1 -1
  40. package/src/lib/jobs/ai-site-import-compile.d.ts +43 -2
  41. package/src/lib/jobs/ai-site-import-compile.js +105 -62
  42. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  43. package/src/lib/jobs/ai-site-import-document.d.ts +25 -1
  44. package/src/lib/jobs/ai-site-import-document.js +26 -7
  45. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  46. package/src/lib/jobs/ai-site-import-honesty.d.ts +65 -0
  47. package/src/lib/jobs/ai-site-import-honesty.js +271 -0
  48. package/src/lib/jobs/ai-site-import-honesty.js.map +1 -0
  49. package/src/lib/jobs/ai-site-import-improve.d.ts +233 -0
  50. package/src/lib/jobs/ai-site-import-improve.js +1151 -0
  51. package/src/lib/jobs/ai-site-import-improve.js.map +1 -0
  52. package/src/lib/jobs/ai-site-import-look.d.ts +4 -0
  53. package/src/lib/jobs/ai-site-import-look.js +16 -6
  54. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  55. package/src/lib/jobs/ai-site-import-pictures.d.ts +83 -0
  56. package/src/lib/jobs/ai-site-import-pictures.js +261 -0
  57. package/src/lib/jobs/ai-site-import-pictures.js.map +1 -0
  58. package/src/lib/jobs/ai-site-import-plan.d.ts +78 -0
  59. package/src/lib/jobs/ai-site-import-plan.js +627 -0
  60. package/src/lib/jobs/ai-site-import-plan.js.map +1 -0
  61. package/src/lib/jobs/ai-site-import-wording.js +2 -5
  62. package/src/lib/jobs/ai-site-import-wording.js.map +1 -1
  63. package/src/lib/layout-language/ai-layout-compiler.d.ts +6 -0
  64. package/src/lib/layout-language/ai-layout-compiler.js +10 -6
  65. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  66. package/src/lib/layout-language/ai-layout-design.d.ts +9 -0
  67. package/src/lib/layout-language/ai-layout-design.js +29 -3
  68. package/src/lib/layout-language/ai-layout-design.js.map +1 -1
  69. package/src/lib/layout-language/ai-layout-frame-source.d.ts +5 -0
  70. package/src/lib/layout-language/ai-layout-frame-source.js +4 -2
  71. package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
  72. package/src/lib/layout-language/ai-layout-frame.d.ts +2 -0
  73. package/src/lib/layout-language/ai-layout-frame.js +20 -12
  74. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  75. package/src/lib/layout-language/ai-layout-language.d.ts +8 -0
  76. package/src/lib/layout-language/ai-layout-language.js +7 -3
  77. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  78. package/src/lib/model/ai-site-import-fidelity.d.ts +62 -0
  79. package/src/lib/model/ai-site-import-fidelity.js +374 -0
  80. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  81. package/src/lib/model/ai-site-import-ledger.d.ts +82 -0
  82. package/src/lib/model/ai-site-import-ledger.js +254 -0
  83. package/src/lib/model/ai-site-import-ledger.js.map +1 -0
  84. package/src/lib/model/ai-site-import-view.d.ts +110 -6
  85. package/src/lib/model/ai-site-import-view.js +166 -13
  86. package/src/lib/model/ai-site-import-view.js.map +1 -1
  87. package/src/lib/model/ai-site-import.d.ts +227 -2
  88. package/src/lib/model/ai-site-import.js +312 -15
  89. package/src/lib/model/ai-site-import.js.map +1 -1
  90. package/src/lib/model/ai-site-job.js +4 -0
  91. package/src/lib/model/ai-site-job.js.map +1 -1
  92. package/src/lib/model/ai-site-kinds.d.ts +2 -0
  93. package/src/lib/model/ai-site-kinds.js +7 -0
  94. package/src/lib/model/ai-site-kinds.js.map +1 -1
  95. package/src/lib/model/ai-site-look.d.ts +14 -5
  96. package/src/lib/model/ai-site-look.js +22 -16
  97. package/src/lib/model/ai-site-look.js.map +1 -1
  98. package/src/lib/model/ai-site-start.d.ts +37 -7
  99. package/src/lib/model/ai-site-start.js +54 -10
  100. package/src/lib/model/ai-site-start.js.map +1 -1
  101. package/src/lib/model/ai-site-starter-look.d.ts +69 -0
  102. package/src/lib/model/ai-site-starter-look.js +90 -0
  103. package/src/lib/model/ai-site-starter-look.js.map +1 -0
  104. package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -0
  105. package/src/lib/runtime/ai-doctrine-validators.js +3 -2
  106. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  107. package/src/lib/runtime/ai-doctrine.d.ts +10 -0
  108. package/src/lib/runtime/ai-doctrine.js +16 -2
  109. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  110. package/src/lib/server/ai-jobs-resume.js +12 -3
  111. package/src/lib/server/ai-jobs-resume.js.map +1 -1
  112. package/src/lib/server/ai-jobs-route.js +5 -1
  113. package/src/lib/server/ai-jobs-route.js.map +1 -1
  114. package/src/lib/server/ai-site-import-route.d.ts +6 -0
  115. package/src/lib/server/ai-site-import-route.js +8 -1
  116. package/src/lib/server/ai-site-import-route.js.map +1 -1
  117. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +46 -7
  118. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +260 -14
  119. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  120. package/src/lib/site-import/fixtures/site-import-improve-answers.d.ts +33 -0
  121. package/src/lib/site-import/fixtures/site-import-improve-answers.js +457 -0
  122. package/src/lib/site-import/fixtures/site-import-improve-answers.js.map +1 -0
  123. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +29 -0
  124. package/src/lib/site-import/fixtures/site-layout-recordings.js +26 -0
  125. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  126. package/src/lib/site-import/site-import-flag.d.ts +17 -0
  127. package/src/lib/site-import/site-import-flag.js +15 -0
  128. package/src/lib/site-import/site-import-flag.js.map +1 -1
@@ -16,9 +16,9 @@
16
16
  */
17
17
  import { type AiLayoutCompiledPage, type AiLayoutPagePlan } from '../layout-language/ai-layout-compiler';
18
18
  import type { AiLayoutDesign } from '../layout-language/ai-layout-design';
19
- import { type AiLayoutColorRole, type AiLayoutDesignAnswer, type AiLayoutSection, type AiLayoutSettlement, type AiLayoutWidth } from '../layout-language/ai-layout-language';
19
+ import { type AiLayoutBlock, type AiLayoutColorRole, type AiLayoutDesignAnswer, type AiLayoutDesignSection, type AiLayoutImportHero, type AiLayoutPicture, type AiLayoutSection, type AiLayoutSettlement, type AiLayoutVideo, type AiLayoutWidth } from '../layout-language/ai-layout-language';
20
20
  import type { AiLayoutTargets } from '../layout-language/ai-layout-links';
21
- import { type SiteImportIconShape, type SiteImportLayout, type SiteImportLayoutSection, type SiteImportLookFacts, type AiSiteImportFinish } from '../model/ai-site-import';
21
+ import { type AiSiteImportPhoto, type SiteImportIconShape, type SiteImportLayout, type SiteImportLayoutNode, type SiteImportLayoutSection, type SiteImportLineRef, type SiteImportLookFacts, type SiteImportPictureFit, type AiSiteImportFinish } from '../model/ai-site-import';
22
22
  import { type AiSiteImportDocument } from './ai-site-import-document';
23
23
  /**
24
24
  * The model a page brought in asks its design answer on (AGL-4107): the page
@@ -86,6 +86,34 @@ export declare function aiSiteImportPathOn24(d: string, viewBox: string): string
86
86
  * an icon is no word of the page.
87
87
  */
88
88
  export declare function aiSiteImportIconPath(shape: SiteImportIconShape | undefined): string | null;
89
+ export interface MapScope {
90
+ doc: AiSiteImportDocument;
91
+ layout: SiteImportLayout;
92
+ /** Lines taken into a block, by index of the page's blocks. */
93
+ used: Set<number>;
94
+ /** Pictures the library could not hold, which a page leaves out. */
95
+ missing: Set<number>;
96
+ photos: ReadonlyMap<string, AiSiteImportPhoto>;
97
+ pathTo: ReadonlyMap<string, string>;
98
+ /** The site's saved form a page brought in places where its source had one. */
99
+ formId: string | null;
100
+ formPlaced: boolean;
101
+ /** The section being mapped: its design answer, and how many of its groups have been met. */
102
+ answer: AiLayoutDesignSection | null;
103
+ groupAt: number;
104
+ settled: AiLayoutSettlement[];
105
+ at: string;
106
+ /** The page's films the Video element plays, by their index (AGL-4140). */
107
+ films: ReadonlyMap<number, AiLayoutVideo>;
108
+ /** The film a play button of this section plays: the section's own first, else the page's. */
109
+ film: number | null;
110
+ /** How the owner asked the page finished (AGL-4152): kept as its source lays it out, or improved. */
111
+ finish: AiSiteImportFinish;
112
+ }
113
+ /** Where a link of the source goes on the new site, in the compiler's words; `undefined` where it can go nowhere a page may send a visitor. */
114
+ export declare function aiSiteImportLinkTo(scope: Pick<MapScope, 'doc' | 'pathTo'>, href: string | undefined): string | undefined;
115
+ /** A picture line as the library holds it; marks it taken, and missing where the library holds none. */
116
+ export declare function aiSiteImportTakePicture(scope: MapScope, ref: SiteImportLineRef | undefined, href?: string, fit?: SiteImportPictureFit): AiLayoutPicture | null;
89
117
  /**
90
118
  * A source's own color as the theme role a page brought in draws it in
91
119
  * (AGL-4138), so no value is ever written onto an element: the brand's
@@ -96,6 +124,11 @@ export declare function aiSiteImportIconPath(shape: SiteImportIconShape | undefi
96
124
  * band take the band's own.
97
125
  */
98
126
  export declare function aiSiteImportColorRole(hex: string | null | undefined, look: Pick<SiteImportLookFacts, 'buttonFill' | 'link'> | null | undefined, use: 'ink' | 'fill' | 'rule'): AiLayoutColorRole | null;
127
+ /** A section's nodes in the layout language, a row of columns placed by `col` where the section may still take one. */
128
+ export declare function aiSiteImportNodeBlocks(scope: MapScope, nodes: readonly SiteImportLayoutNode[], row: {
129
+ cols: number[] | null;
130
+ allowed: boolean;
131
+ }): AiLayoutBlock[];
99
132
  /** How a page is finished (AGL-4152): the finish asked of it, else its document's, else kept as it is. */
100
133
  export declare function aiSiteImportFinishOf(doc: Pick<AiSiteImportDocument, 'finish'> | null | undefined, asked?: AiSiteImportFinish | null): AiSiteImportFinish;
101
134
  /**
@@ -112,6 +145,11 @@ export interface AiSiteImportDesigned {
112
145
  missing: Set<number>;
113
146
  settled: AiLayoutSettlement[];
114
147
  }
148
+ /** A page's lines as the layout language takes them (AGL-4107), each marked as it is taken. */
149
+ export declare function aiSiteImportMapScope(doc: AiSiteImportDocument, options: {
150
+ formId?: string | null;
151
+ finish: AiSiteImportFinish;
152
+ }): MapScope;
115
153
  /**
116
154
  * The page's sections in the layout language (AGL-4107): the source's layout,
117
155
  * each section in its own band (or the answer's, where the source gave none),
@@ -122,6 +160,7 @@ export interface AiSiteImportDesigned {
122
160
  export declare function aiSiteImportDesignedSections(doc: AiSiteImportDocument, answer?: AiLayoutDesignAnswer | null, options?: {
123
161
  formId?: string | null;
124
162
  finish?: AiSiteImportFinish | null;
163
+ plannedHero?: AiLayoutImportHero;
125
164
  }): AiSiteImportDesigned;
126
165
  export interface AiSiteImportCompileInput {
127
166
  doc: AiSiteImportDocument;
@@ -137,6 +176,8 @@ export interface AiSiteImportCompileInput {
137
176
  answer?: AiLayoutDesignAnswer | null;
138
177
  /** How the page is finished (AGL-4152); absent is `keep`. */
139
178
  finish?: AiSiteImportFinish | null;
179
+ /** Sections a generative Improve it planned (AGL-4152), drawn in place of the source's layout. */
180
+ given?: AiSiteImportDesigned | null;
140
181
  }
141
182
  export interface AiSiteImportCompiled extends Pick<AiLayoutCompiledPage, 'tree' | 'sectionRoots' | 'videoIds'> {
142
183
  sections: AiLayoutSection[];
@@ -55,8 +55,9 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
55
55
  *
56
56
  * A read made before the reader kept no layout: its page is read into one
57
57
  * here, from its lines, one section at each second-level heading.
58
- *=========================================*/ import { aiCompileLayoutPage } from "../layout-language/ai-layout-compiler.js";
59
- import { AI_LAYOUT_GROUP_STYLES, AI_LAYOUT_MAX_COLS } from "../layout-language/ai-layout-language.js";
58
+ *=========================================*/ import { videoEmbedPosterSrc } from "@aglyn/aglyn/plugin-manager/video-embed-provider";
59
+ import { aiCompileLayoutPage } from "../layout-language/ai-layout-compiler.js";
60
+ import { AI_LAYOUT_GROUP_STYLES, AI_LAYOUT_IMPORT_HEROES, AI_LAYOUT_MAX_COLS } from "../layout-language/ai-layout-language.js";
60
61
  import { AI_SITE_IMPORT_LABEL_MAX_CHARS, SITE_IMPORT_PLAY_WORDS, siteImportFilmSource, siteImportWidthOf } from "../model/ai-site-import.js";
61
62
  import { aiHexOklch } from "../model/ai-site-look.js";
62
63
  import { aiModelAtLeastStepTier } from "../providers/routing.js";
@@ -407,7 +408,7 @@ const OPEN_STYLES = new Set([
407
408
  if (place === 'behind') return section.align === 'center' ? 'poster' : 'cover';
408
409
  return section.align === 'center' ? 'column' : 'editorial';
409
410
  }
410
- /** Where a link of the source goes on the new site, in the compiler's words; `undefined` where it can go nowhere a page may send a visitor. */ function linkTo(scope, href) {
411
+ /** Where a link of the source goes on the new site, in the compiler's words; `undefined` where it can go nowhere a page may send a visitor. */ export function aiSiteImportLinkTo(scope, href) {
411
412
  const value = (href != null ? href : '').trim();
412
413
  if (/^mailto:[^\s@]+@[^\s@]+$/i.test(value) || /^tel:\+?[\d\s().-]{3,}$/i.test(value)) return value;
413
414
  let url;
@@ -464,7 +465,7 @@ const OPEN_STYLES = new Set([
464
465
  if (measure && measure !== 'xl') out.measure = measure;
465
466
  return Object.keys(out).length ? out : undefined;
466
467
  }
467
- /** A picture line as the library holds it; marks it taken, and missing where the library holds none. */ function takePicture(scope, ref, href, fit) {
468
+ /** A picture line as the library holds it; marks it taken, and missing where the library holds none. */ export function aiSiteImportTakePicture(scope, ref, href, fit) {
468
469
  if (ref === undefined || scope.used.has(ref)) return null;
469
470
  const block = scope.doc.blocks[ref];
470
471
  if (!block || block.kind !== 'image') return null;
@@ -476,7 +477,7 @@ const OPEN_STYLES = new Set([
476
477
  }
477
478
  const alt = clean(block.alt || photo.alt || '').slice(0, 200);
478
479
  const ratio = photo.width && photo.height ? photo.width / photo.height : 0;
479
- const to = linkTo(scope, href);
480
+ const to = aiSiteImportLinkTo(scope, href);
480
481
  const framed = pictureFitOf(photo, fit);
481
482
  return _extends({
482
483
  src: photo.src,
@@ -557,7 +558,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
557
558
  }));
558
559
  }
559
560
  /** A link of the source: a button where its words fit one, a link in a list where they run longer, its words where it goes nowhere. */ function linkBlocks(scope, text, href, style) {
560
- const to = linkTo(scope, href);
561
+ const to = aiSiteImportLinkTo(scope, href);
561
562
  if (text.length <= AI_SITE_IMPORT_LABEL_CHARS) return [
562
563
  _extends({
563
564
  kind: 'button',
@@ -586,7 +587,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
586
587
  const block = scope.doc.blocks[node.line];
587
588
  if (!block || scope.used.has(node.line)) return [];
588
589
  if (block.kind === 'image') {
589
- const picture = takePicture(scope, node.line);
590
+ const picture = aiSiteImportTakePicture(scope, node.line);
590
591
  return picture ? [
591
592
  {
592
593
  kind: 'image',
@@ -709,7 +710,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
709
710
  const block = scope.doc.blocks[ref];
710
711
  const text = take(scope, ref);
711
712
  if (!text) return;
712
- const to = (block == null ? void 0 : block.kind) === 'link' ? linkTo(scope, block.href) : undefined;
713
+ const to = (block == null ? void 0 : block.kind) === 'link' ? aiSiteImportLinkTo(scope, block.href) : undefined;
713
714
  if (text.length <= AI_SITE_IMPORT_LABEL_CHARS) links.push(_extends({
714
715
  text
715
716
  }, to ? {
@@ -730,7 +731,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
730
731
  else if (ref === item.period) out.period = take(scope, ref);
731
732
  else if (ref === item.badge && kind !== 'stats') out.badge = take(scope, ref);
732
733
  else if (ref === item.image || block.kind === 'image' && !named.has(ref)) {
733
- const picture = takePicture(scope, ref, undefined, ref === item.image ? item.imageFit : undefined);
734
+ const picture = aiSiteImportTakePicture(scope, ref, undefined, ref === item.image ? item.imageFit : undefined);
734
735
  if (picture && !out.picture) out.picture = picture;
735
736
  } else if ((_item_list1 = item.list) == null ? void 0 : _item_list1.includes(ref)) {
736
737
  var _out_list1;
@@ -771,7 +772,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
771
772
  });
772
773
  return out;
773
774
  }
774
- const to = linkTo(scope, item.to);
775
+ const to = aiSiteImportLinkTo(scope, item.to);
775
776
  if (to) out.to = to;
776
777
  return out;
777
778
  }
@@ -899,11 +900,11 @@ const HEX = /^#[0-9a-f]{6}$/i;
899
900
  const words = item.lines.map((ref)=>take(scope, ref)).filter(Boolean).join(' ');
900
901
  for (const ref of item.lines){
901
902
  var _scope_doc_blocks_ref;
902
- if (((_scope_doc_blocks_ref = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref.kind) === 'image') takePicture(scope, ref);
903
+ if (((_scope_doc_blocks_ref = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref.kind) === 'image') aiSiteImportTakePicture(scope, ref);
903
904
  }
904
905
  if (!words) return [];
905
906
  const icon = iconAt(scope, item.icon);
906
- const to = linkTo(scope, (_item_to = item.to) != null ? _item_to : (linked == null ? void 0 : linked.kind) === 'link' ? linked.href : undefined);
907
+ const to = aiSiteImportLinkTo(scope, (_item_to = item.to) != null ? _item_to : (linked == null ? void 0 : linked.kind) === 'link' ? linked.href : undefined);
907
908
  return [
908
909
  _extends({
909
910
  title: words,
@@ -929,7 +930,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
929
930
  const words = [];
930
931
  for (const ref of item.lines){
931
932
  var _scope_doc_blocks_ref;
932
- if (((_scope_doc_blocks_ref = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref.kind) === 'image') picture = picture != null ? picture : takePicture(scope, ref);
933
+ if (((_scope_doc_blocks_ref = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref.kind) === 'image') picture = picture != null ? picture : aiSiteImportTakePicture(scope, ref);
933
934
  else {
934
935
  const line = take(scope, ref);
935
936
  if (line) words.push(line);
@@ -943,7 +944,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
943
944
  }
944
945
  ];
945
946
  // A strip of linked tags keeps its links (AGL-4138): a blog's categories go to their pages.
946
- const to = picture ? undefined : linkTo(scope, item.to);
947
+ const to = picture ? undefined : aiSiteImportLinkTo(scope, item.to);
947
948
  return words.length ? [
948
949
  _extends({
949
950
  title: words.join(' '),
@@ -1032,7 +1033,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1032
1033
  }, drawnAs(scope, group, style))
1033
1034
  ];
1034
1035
  }
1035
- /** A section's nodes in the layout language, a row of columns placed by `col` where the section may still take one. */ function nodeBlocks(scope, nodes, row) {
1036
+ /** A section's nodes in the layout language, a row of columns placed by `col` where the section may still take one. */ export function aiSiteImportNodeBlocks(scope, nodes, row) {
1036
1037
  const out = [];
1037
1038
  for (const node of nodes){
1038
1039
  switch(node.kind){
@@ -1041,7 +1042,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1041
1042
  break;
1042
1043
  case 'picture':
1043
1044
  {
1044
- const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1045
+ const picture = aiSiteImportTakePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1045
1046
  if (picture) out.push({
1046
1047
  kind: 'image',
1047
1048
  picture
@@ -1092,7 +1093,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1092
1093
  }).filter((entry)=>entry.cell.nodes.length);
1093
1094
  row.cols = weights.map((entry)=>Math.min(12, Math.max(1, Math.round(entry.weight))));
1094
1095
  weights.forEach((entry, col)=>{
1095
- for (const block of nodeBlocks(scope, entry.cell.nodes, {
1096
+ for (const block of aiSiteImportNodeBlocks(scope, entry.cell.nodes, {
1096
1097
  cols: null,
1097
1098
  allowed: false
1098
1099
  }))out.push(_extends({}, block, {
@@ -1105,7 +1106,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1105
1106
  var _node_cols_index;
1106
1107
  return {
1107
1108
  weight: Math.min(12, Math.max(1, Math.round((_node_cols_index = node.cols[index]) != null ? _node_cols_index : 1))),
1108
- blocks: nodeBlocks(scope, cell.nodes, {
1109
+ blocks: aiSiteImportNodeBlocks(scope, cell.nodes, {
1109
1110
  cols: null,
1110
1111
  allowed: false
1111
1112
  })
@@ -1116,8 +1117,8 @@ const HEX = /^#[0-9a-f]{6}$/i;
1116
1117
  row: columns.filter((column)=>column.blocks.length)
1117
1118
  });
1118
1119
  } else {
1119
- // Wider than a row may be: its cells one under another.
1120
- for (const cell of node.cells)out.push(...nodeBlocks(scope, cell.nodes, {
1120
+ // Wider than a row may be, or a second row inside a column: its cells one under another.
1121
+ for (const cell of node.cells)out.push(...aiSiteImportNodeBlocks(scope, cell.nodes, {
1121
1122
  cols: null,
1122
1123
  allowed: false
1123
1124
  }));
@@ -1148,7 +1149,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1148
1149
  cols: null,
1149
1150
  allowed: true
1150
1151
  };
1151
- const blocks = mergeLists(nodeBlocks(scope, tab.panel, panelRow));
1152
+ const blocks = mergeLists(aiSiteImportNodeBlocks(scope, tab.panel, panelRow));
1152
1153
  return _extends({
1153
1154
  label
1154
1155
  }, tab.selected ? {
@@ -1175,35 +1176,47 @@ const HEX = /^#[0-9a-f]{6}$/i;
1175
1176
  * A video of the source, where it sat (AGL-4140): the Video element, its
1176
1177
  * poster the library's copy of the source's, where the Video element can play
1177
1178
  * the film. One on a host it cannot play is its poster, linking to where the
1178
- * film plays; with no poster either, nothing of it can be shown.
1179
+ * film plays; with no poster either, nothing of it can be shown. A film on a
1180
+ * host that publishes its own still (YouTube) needs no poster where the
1181
+ * page's wave was stamped so: the page draws the host's still.
1179
1182
  */ function videoBlocks(scope, node) {
1180
1183
  var _ref;
1181
1184
  var _scope_doc_videos;
1182
1185
  const film = scope.films.get(node.video);
1183
1186
  if (film) {
1184
1187
  // A film is pressed to play from its poster: with none, the Video element has nothing to show, and it is left out.
1185
- const picture = filmPlaces(scope, node.video, node.poster) ? takePicture(scope, node.poster, undefined, node.fit) : null;
1186
- if (!picture) {
1187
- scope.settled.push({
1188
- at: scope.at,
1189
- what: 'a video left out: it has no poster picture'
1190
- });
1191
- return [];
1192
- }
1188
+ const picture = filmPlaces(scope, node.video, node.poster) ? aiSiteImportTakePicture(scope, node.poster, undefined, node.fit) : null;
1193
1189
  const video = _extends({}, film, node.shadow ? {
1194
1190
  shadow: true
1195
1191
  } : {});
1196
- return [
1192
+ if (picture) return [
1197
1193
  {
1198
1194
  kind: 'video',
1199
1195
  video,
1200
1196
  picture
1201
1197
  }
1202
1198
  ];
1199
+ if (filmShowsHostStill(scope, node.video)) {
1200
+ scope.settled.push({
1201
+ at: scope.at,
1202
+ what: 'a video placed with its host’s own still as its poster'
1203
+ });
1204
+ return [
1205
+ {
1206
+ kind: 'video',
1207
+ video
1208
+ }
1209
+ ];
1210
+ }
1211
+ scope.settled.push({
1212
+ at: scope.at,
1213
+ what: 'a video left out: it has no poster picture'
1214
+ });
1215
+ return [];
1203
1216
  }
1204
1217
  const source = (_scope_doc_videos = scope.doc.videos) == null ? void 0 : _scope_doc_videos[node.video];
1205
1218
  const where = (_ref = source == null ? void 0 : source.embed) != null ? _ref : source == null ? void 0 : source.src;
1206
- const picture = takePicture(scope, node.poster, where, node.fit);
1219
+ const picture = aiSiteImportTakePicture(scope, node.poster, where, node.fit);
1207
1220
  const host = (()=>{
1208
1221
  try {
1209
1222
  return where ? new URL(where).hostname.replace(/^www\./, '') : '';
@@ -1249,11 +1262,22 @@ const HEX = /^#[0-9a-f]{6}$/i;
1249
1262
  const block = poster === undefined ? undefined : scope.doc.blocks[poster];
1250
1263
  return scope.films.has(video) && (block == null ? void 0 : block.kind) === 'image' && scope.photos.has(block.url);
1251
1264
  }
1265
+ /**
1266
+ * Whether a film the library holds no poster for is still drawn as the Video
1267
+ * element (AGL-4140): the page's wave was stamped with
1268
+ * `release_video_embed_posters`, and the film plays on a host that publishes
1269
+ * its own still of it (YouTube's, from its media id), which the published
1270
+ * page draws as the poster. Only where the film stands alone: an item's film
1271
+ * plays from the item's picture.
1272
+ */ function filmShowsHostStill(scope, video) {
1273
+ const film = scope.films.get(video);
1274
+ return scope.doc.videoPosters === true && !!film && !!videoEmbedPosterSrc(film.src);
1275
+ }
1252
1276
  /** The first film of a list of nodes drawn as the Video element, rows, tabs and items opened. */ function firstFilm(scope, nodes) {
1253
1277
  for (const node of nodes){
1254
1278
  var _ref;
1255
1279
  var _node_items_find;
1256
- const found = node.kind === 'video' ? filmPlaces(scope, node.video, node.poster) ? node.video : null : node.kind === 'row' ? firstFilm(scope, node.cells.flatMap((cell)=>cell.nodes)) : node.kind === 'tabs' ? firstFilm(scope, node.tabs.flatMap((tab)=>tab.panel)) : node.kind === 'group' ? (_ref = (_node_items_find = node.items.find((item)=>item.video !== undefined && filmPlaces(scope, item.video, item.image))) == null ? void 0 : _node_items_find.video) != null ? _ref : null : null;
1280
+ const found = node.kind === 'video' ? filmPlaces(scope, node.video, node.poster) || filmShowsHostStill(scope, node.video) ? node.video : null : node.kind === 'row' ? firstFilm(scope, node.cells.flatMap((cell)=>cell.nodes)) : node.kind === 'tabs' ? firstFilm(scope, node.tabs.flatMap((tab)=>tab.panel)) : node.kind === 'group' ? (_ref = (_node_items_find = node.items.find((item)=>item.video !== undefined && filmPlaces(scope, item.video, item.image))) == null ? void 0 : _node_items_find.video) != null ? _ref : null : null;
1257
1281
  if (found !== null) return found;
1258
1282
  }
1259
1283
  return null;
@@ -1275,7 +1299,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1275
1299
  }, 0);
1276
1300
  if (count === 0 || count > BYLINE_MAX_WORDS) return null;
1277
1301
  const node = cells[at].nodes[0];
1278
- const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1302
+ const picture = aiSiteImportTakePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1279
1303
  return [
1280
1304
  ...picture ? [
1281
1305
  {
@@ -1285,7 +1309,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1285
1309
  })
1286
1310
  }
1287
1311
  ] : [],
1288
- ...nodeBlocks(scope, words, {
1312
+ ...aiSiteImportNodeBlocks(scope, words, {
1289
1313
  cols: null,
1290
1314
  allowed: false
1291
1315
  })
@@ -1329,7 +1353,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1329
1353
  * the source's own whatever the answer says: a hero that moved its words is
1330
1354
  * set aside with what it asked.
1331
1355
  */ function heroOf(section, index, answer, settled, drawn) {
1332
- var _ref;
1356
+ var _drawn_planned;
1333
1357
  var _section_hero;
1334
1358
  if (index !== 0 || !((_section_hero = section.hero) == null ? void 0 : _section_hero.picture)) return undefined;
1335
1359
  const place = section.hero.picture;
@@ -1341,18 +1365,20 @@ const HEX = /^#[0-9a-f]{6}$/i;
1341
1365
  });
1342
1366
  return own;
1343
1367
  }
1368
+ // A site's plan draws every page's opening alike (AGL-4152), whatever one page's answer asks.
1369
+ const asked = (_drawn_planned = drawn.planned) != null ? _drawn_planned : answer == null ? void 0 : answer.hero;
1344
1370
  // An answer of "none" keeps the opening as the source lays it out.
1345
- if ((answer == null ? void 0 : answer.hero) === 'none') return undefined;
1371
+ if (asked === 'none') return undefined;
1346
1372
  const own = HERO_FOR[place];
1347
1373
  // Dimmed words need a dark ground: the section's own, or on a page its owner asked improved, the answer's (AGL-4152).
1348
- if ((answer == null ? void 0 : answer.hero) && DIMMED_HEROES.has(answer.hero) && drawn.band !== 'dark' && place !== 'behind') {
1374
+ if (asked && DIMMED_HEROES.has(asked) && drawn.band !== 'dark' && place !== 'behind') {
1349
1375
  settled.push({
1350
1376
  at: 'sections[0]',
1351
- what: `the ${answer.hero} hero set aside: the section keeps its own lighter ground`
1377
+ what: `the ${asked} hero set aside: the section keeps its own lighter ground`
1352
1378
  });
1353
1379
  return own;
1354
1380
  }
1355
- return (_ref = answer == null ? void 0 : answer.hero) != null ? _ref : own;
1381
+ return asked != null ? asked : own;
1356
1382
  }
1357
1383
  /** How a page is finished (AGL-4152): the finish asked of it, else its document's, else kept as it is. */ export function aiSiteImportFinishOf(doc, asked) {
1358
1384
  const finish = asked != null ? asked : doc == null ? void 0 : doc.finish;
@@ -1367,20 +1393,11 @@ const HEX = /^#[0-9a-f]{6}$/i;
1367
1393
  const step = siteImportWidthOf((_section_hero = section.hero) == null ? void 0 : _section_hero.measure);
1368
1394
  return step === 'xl' ? 'lg' : step;
1369
1395
  }
1370
- /**
1371
- * The page's sections in the layout language (AGL-4107): the source's layout,
1372
- * each section in its own band (or the answer's, where the source gave none),
1373
- * its row, its groups and their items, its tables, tabs and pictures, every
1374
- * line taken exactly once and every line the layout placed nowhere added at
1375
- * its section's end.
1376
- */ export function aiSiteImportDesignedSections(doc, answer, options = {}) {
1396
+ /** A page's lines as the layout language takes them (AGL-4107), each marked as it is taken. */ export function aiSiteImportMapScope(doc, options) {
1377
1397
  var _options_formId;
1378
- const layout = aiSiteImportLayoutOf(doc);
1379
- const finish = aiSiteImportFinishOf(doc, options.finish);
1380
- const improve = finish === 'improve';
1381
- const scope = {
1398
+ return {
1382
1399
  doc,
1383
- layout,
1400
+ layout: aiSiteImportLayoutOf(doc),
1384
1401
  used: new Set(),
1385
1402
  missing: new Set(),
1386
1403
  photos: new Map(doc.photos.flatMap((photo)=>photo.from ? [
@@ -1401,8 +1418,24 @@ const HEX = /^#[0-9a-f]{6}$/i;
1401
1418
  at: '',
1402
1419
  films: filmsOf(doc),
1403
1420
  film: null,
1404
- finish
1421
+ finish: options.finish
1405
1422
  };
1423
+ }
1424
+ /**
1425
+ * The page's sections in the layout language (AGL-4107): the source's layout,
1426
+ * each section in its own band (or the answer's, where the source gave none),
1427
+ * its row, its groups and their items, its tables, tabs and pictures, every
1428
+ * line taken exactly once and every line the layout placed nowhere added at
1429
+ * its section's end.
1430
+ */ export function aiSiteImportDesignedSections(doc, answer, options = {}) {
1431
+ var _options_formId;
1432
+ const layout = aiSiteImportLayoutOf(doc);
1433
+ const finish = aiSiteImportFinishOf(doc, options.finish);
1434
+ const improve = finish === 'improve';
1435
+ const scope = aiSiteImportMapScope(doc, {
1436
+ formId: (_options_formId = options.formId) != null ? _options_formId : null,
1437
+ finish
1438
+ });
1406
1439
  const backdropOf = (section)=>{
1407
1440
  var _section_backdrop;
1408
1441
  return ((_section_backdrop = section.backdrop) == null ? void 0 : _section_backdrop.kind) === 'video' ? section.backdrop : null;
@@ -1422,7 +1455,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1422
1455
  };
1423
1456
  // A film playing on its own behind the section's words is drawn as its poster there (AGL-4140): the
1424
1457
  // opening's hero lays it behind them. A film that starts on its own is one rule 16 refuses.
1425
- const poster = behind ? takePicture(scope, behind.poster) : null;
1458
+ const poster = behind ? aiSiteImportTakePicture(scope, behind.poster) : null;
1426
1459
  if (behind) scope.settled.push({
1427
1460
  at: scope.at,
1428
1461
  what: 'a film playing behind the words drawn as its poster'
@@ -1434,7 +1467,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1434
1467
  picture: poster
1435
1468
  }
1436
1469
  ] : [],
1437
- ...nodeBlocks(scope, section.nodes, row)
1470
+ ...aiSiteImportNodeBlocks(scope, section.nodes, row)
1438
1471
  ];
1439
1472
  // Every line the layout placed nowhere, at the section's end, as its kind says.
1440
1473
  for (const ref of section.lines){
@@ -1450,10 +1483,12 @@ const HEX = /^#[0-9a-f]{6}$/i;
1450
1483
  // Kept, its band against its page's ground (AGL-4152); improved, as its color alone reads.
1451
1484
  const own = improve ? (_section_absoluteBand = section.absoluteBand) != null ? _section_absoluteBand : section.band : section.band;
1452
1485
  const band = (given == null ? void 0 : given.band) && (improve || section.background === null && !section.backdrop) ? given.band : own;
1453
- const hero = heroOf(section, index, given, scope.settled, {
1486
+ const hero = heroOf(section, index, given, scope.settled, _extends({
1454
1487
  band: improve ? band : section.band,
1455
1488
  finish
1456
- });
1489
+ }, options.plannedHero ? {
1490
+ planned: options.plannedHero
1491
+ } : {}));
1457
1492
  // A long read is set at the start, as text is read, whatever its source centers.
1458
1493
  const reading = blocks.filter((block)=>block.kind === 'text').length > READING_PARAGRAPHS;
1459
1494
  const source = reading ? 'start' : section.align;
@@ -1488,22 +1523,30 @@ const HEX = /^#[0-9a-f]{6}$/i;
1488
1523
  * it exactly once, every word as its source wrote it, laid out as its source
1489
1524
  * lays it out and drawn in the site's own theme.
1490
1525
  */ export function aiCompileImportedPage(input) {
1491
- var _input_answer;
1526
+ var _input_given, _input_answer;
1492
1527
  var _compiled_videoIds;
1493
1528
  const { doc } = input;
1494
1529
  const formId = input.targets.forms.length === 1 ? input.targets.forms[0].id : null;
1495
1530
  const finish = aiSiteImportFinishOf(doc, input.finish);
1496
- const designed = aiSiteImportDesignedSections(doc, (_input_answer = input.answer) != null ? _input_answer : null, {
1531
+ const plannedHero = AI_LAYOUT_IMPORT_HEROES.find((hero)=>{
1532
+ var _input_design_planned, _input_design;
1533
+ return hero === ((_input_design = input.design) == null ? void 0 : (_input_design_planned = _input_design.planned) == null ? void 0 : _input_design_planned.hero);
1534
+ });
1535
+ const designed = (_input_given = input.given) != null ? _input_given : aiSiteImportDesignedSections(doc, (_input_answer = input.answer) != null ? _input_answer : null, _extends({
1497
1536
  formId,
1498
1537
  finish
1499
- });
1538
+ }, plannedHero ? {
1539
+ plannedHero
1540
+ } : {}));
1500
1541
  const compile = (sections)=>aiCompileLayoutPage(sections, input.plan, input.targets, _extends({
1501
1542
  // A page brought in draws its repeats as its source does (AGL-4107).
1502
1543
  reusableComponents: false,
1503
1544
  sectionIds: input.sectionIds,
1504
1545
  verbatim: true,
1505
1546
  finish
1506
- }, input.design ? {
1547
+ }, input.given ? {
1548
+ bandRhythm: 'alternate'
1549
+ } : {}, input.design ? {
1507
1550
  design: input.design
1508
1551
  } : {}, input.language ? {
1509
1552
  language: input.language
@@ -1521,7 +1564,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1521
1564
  compiled = compile(sections);
1522
1565
  }
1523
1566
  const dropped = new Set();
1524
- if (cut) {
1567
+ if (cut && !input.given) {
1525
1568
  const layout = aiSiteImportLayoutOf(doc);
1526
1569
  layout.sections.forEach((section, index)=>{
1527
1570
  var _sections_index;