@aglyn/plugins-ai 1.0.0-beta.270 → 1.0.0-beta.271

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 (216) hide show
  1. package/package.json +17 -17
  2. package/src/lib/activity/ai-activity-actions.d.ts +1 -1
  3. package/src/lib/activity/ai-activity-actions.js +1 -0
  4. package/src/lib/activity/ai-activity-actions.js.map +1 -1
  5. package/src/lib/assets/site-styles/beauty.webp +0 -0
  6. package/src/lib/assets/site-styles/blog.webp +0 -0
  7. package/src/lib/assets/site-styles/business.webp +0 -0
  8. package/src/lib/assets/site-styles/coming-soon.webp +0 -0
  9. package/src/lib/assets/site-styles/education.webp +0 -0
  10. package/src/lib/assets/site-styles/events.webp +0 -0
  11. package/src/lib/assets/site-styles/fitness.webp +0 -0
  12. package/src/lib/assets/site-styles/landing.webp +0 -0
  13. package/src/lib/assets/site-styles/music.webp +0 -0
  14. package/src/lib/assets/site-styles/nonprofit.webp +0 -0
  15. package/src/lib/assets/site-styles/personal.webp +0 -0
  16. package/src/lib/assets/site-styles/photography.webp +0 -0
  17. package/src/lib/assets/site-styles/portfolio.webp +0 -0
  18. package/src/lib/assets/site-styles/professional.webp +0 -0
  19. package/src/lib/assets/site-styles/realestate.webp +0 -0
  20. package/src/lib/assets/site-styles/restaurant.webp +0 -0
  21. package/src/lib/assets/site-styles/store.webp +0 -0
  22. package/src/lib/assets/site-styles/studio.webp +0 -0
  23. package/src/lib/assets/site-styles/trades.webp +0 -0
  24. package/src/lib/assets/site-styles/wellness.webp +0 -0
  25. package/src/lib/assets/site-styles/yoga.webp +0 -0
  26. package/src/lib/components/ai-credits-card.component.d.ts +4 -3
  27. package/src/lib/components/ai-credits-card.component.js +15 -15
  28. package/src/lib/components/ai-credits-card.component.js.map +1 -1
  29. package/src/lib/components/ai-job-input-form.component.d.ts +36 -0
  30. package/src/lib/components/ai-job-input-form.component.js +100 -0
  31. package/src/lib/components/ai-job-input-form.component.js.map +1 -0
  32. package/src/lib/components/ai-job-requests.d.ts +4 -0
  33. package/src/lib/components/ai-job-requests.js +4 -0
  34. package/src/lib/components/ai-job-requests.js.map +1 -1
  35. package/src/lib/components/ai-site-start-card.component.d.ts +1 -1
  36. package/src/lib/components/ai-site-start-card.component.js +99 -31
  37. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  38. package/src/lib/components/ai-site-start-steps.component.d.ts +43 -2
  39. package/src/lib/components/ai-site-start-steps.component.js +651 -15
  40. package/src/lib/components/ai-site-start-steps.component.js.map +1 -1
  41. package/src/lib/components/ai-site-start-tracking.d.ts +10 -0
  42. package/src/lib/components/ai-site-start-tracking.js +14 -0
  43. package/src/lib/components/ai-site-start-tracking.js.map +1 -1
  44. package/src/lib/components/ai-site-style-previews.js +26 -22
  45. package/src/lib/components/ai-site-style-previews.js.map +1 -1
  46. package/src/lib/components/ai-upsell-dialog.component.d.ts +7 -5
  47. package/src/lib/components/ai-upsell-dialog.component.js +8 -6
  48. package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
  49. package/src/lib/components/assist-build-card.component.js +11 -1
  50. package/src/lib/components/assist-build-card.component.js.map +1 -1
  51. package/src/lib/components/assist-jobs-drawer.component.js +9 -1
  52. package/src/lib/components/assist-jobs-drawer.component.js.map +1 -1
  53. package/src/lib/components/assist-panel.component.js +8 -4
  54. package/src/lib/components/assist-panel.component.js.map +1 -1
  55. package/src/lib/components/staff-org-ai-card.component.js +4 -7
  56. package/src/lib/components/staff-org-ai-card.component.js.map +1 -1
  57. package/src/lib/declarations.d.ts +2 -2
  58. package/src/lib/declarations.js +9 -5
  59. package/src/lib/declarations.js.map +1 -1
  60. package/src/lib/jobs/ai-build-capabilities.js +3 -1
  61. package/src/lib/jobs/ai-build-capabilities.js.map +1 -1
  62. package/src/lib/jobs/ai-business-profile-prefill.d.ts +1 -1
  63. package/src/lib/jobs/ai-business-profile-prefill.js +14 -3
  64. package/src/lib/jobs/ai-business-profile-prefill.js.map +1 -1
  65. package/src/lib/jobs/ai-job-build-step.js +5 -3
  66. package/src/lib/jobs/ai-job-build-step.js.map +1 -1
  67. package/src/lib/jobs/ai-job-form-step.d.ts +15 -1
  68. package/src/lib/jobs/ai-job-form-step.js +75 -8
  69. package/src/lib/jobs/ai-job-form-step.js.map +1 -1
  70. package/src/lib/jobs/ai-job-page-language.d.ts +13 -0
  71. package/src/lib/jobs/ai-job-page-language.js +37 -1
  72. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  73. package/src/lib/jobs/ai-job-page-step.d.ts +17 -0
  74. package/src/lib/jobs/ai-job-page-step.js +37 -16
  75. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  76. package/src/lib/jobs/ai-job-plan-step.d.ts +25 -2
  77. package/src/lib/jobs/ai-job-plan-step.js +103 -29
  78. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  79. package/src/lib/jobs/ai-job-settings-step.js +4 -3
  80. package/src/lib/jobs/ai-job-settings-step.js.map +1 -1
  81. package/src/lib/jobs/ai-job-site-datasets.d.ts +27 -0
  82. package/src/lib/jobs/ai-job-site-datasets.js +140 -14
  83. package/src/lib/jobs/ai-job-site-datasets.js.map +1 -1
  84. package/src/lib/jobs/ai-job-site-look.js +18 -5
  85. package/src/lib/jobs/ai-job-site-look.js.map +1 -1
  86. package/src/lib/jobs/ai-job-site-step.d.ts +16 -1
  87. package/src/lib/jobs/ai-job-site-step.js +95 -22
  88. package/src/lib/jobs/ai-job-site-step.js.map +1 -1
  89. package/src/lib/jobs/ai-job-text-step.d.ts +8 -1
  90. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  91. package/src/lib/jobs/ai-job-tracking-step.d.ts +14 -3
  92. package/src/lib/jobs/ai-job-tracking-step.js +28 -5
  93. package/src/lib/jobs/ai-job-tracking-step.js.map +1 -1
  94. package/src/lib/jobs/ai-jobs.d.ts +8 -1
  95. package/src/lib/jobs/ai-jobs.js +63 -8
  96. package/src/lib/jobs/ai-jobs.js.map +1 -1
  97. package/src/lib/jobs/ai-layout-stock-photos.d.ts +27 -2
  98. package/src/lib/jobs/ai-layout-stock-photos.js +190 -19
  99. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  100. package/src/lib/jobs/ai-site-inspiration-signals.d.ts +98 -0
  101. package/src/lib/jobs/ai-site-inspiration-signals.js +585 -0
  102. package/src/lib/jobs/ai-site-inspiration-signals.js.map +1 -0
  103. package/src/lib/jobs/ai-site-inspiration.d.ts +157 -0
  104. package/src/lib/jobs/ai-site-inspiration.js +346 -0
  105. package/src/lib/jobs/ai-site-inspiration.js.map +1 -0
  106. package/src/lib/jobs/ai-site-publish.d.ts +26 -1
  107. package/src/lib/jobs/ai-site-publish.js +162 -13
  108. package/src/lib/jobs/ai-site-publish.js.map +1 -1
  109. package/src/lib/jobs/ai-theme-brand-inputs.d.ts +16 -0
  110. package/src/lib/jobs/ai-theme-brand-inputs.js +18 -4
  111. package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -1
  112. package/src/lib/jobs/fixtures/ai-candle-shop-free-plan-recording.d.ts +97 -0
  113. package/src/lib/jobs/fixtures/ai-candle-shop-free-plan-recording.js +137 -0
  114. package/src/lib/jobs/fixtures/ai-candle-shop-free-plan-recording.js.map +1 -0
  115. package/src/lib/jobs/fixtures/ai-site-inspiration-pages.d.ts +38 -0
  116. package/src/lib/jobs/fixtures/ai-site-inspiration-pages.js +103 -0
  117. package/src/lib/jobs/fixtures/ai-site-inspiration-pages.js.map +1 -0
  118. package/src/lib/jobs/fixtures/ai-stock-photo-agl3988-recordings.d.ts +25 -0
  119. package/src/lib/jobs/fixtures/ai-stock-photo-agl3988-recordings.js +174 -0
  120. package/src/lib/jobs/fixtures/ai-stock-photo-agl3988-recordings.js.map +1 -0
  121. package/src/lib/layout-language/ai-layout-compiler.d.ts +1 -1
  122. package/src/lib/layout-language/ai-layout-compiler.js +438 -25
  123. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  124. package/src/lib/layout-language/ai-layout-contact.d.ts +57 -0
  125. package/src/lib/layout-language/ai-layout-contact.js +137 -0
  126. package/src/lib/layout-language/ai-layout-contact.js.map +1 -0
  127. package/src/lib/layout-language/ai-layout-copy.d.ts +12 -0
  128. package/src/lib/layout-language/ai-layout-copy.js +34 -2
  129. package/src/lib/layout-language/ai-layout-copy.js.map +1 -1
  130. package/src/lib/layout-language/ai-layout-design.d.ts +65 -8
  131. package/src/lib/layout-language/ai-layout-design.js +411 -97
  132. package/src/lib/layout-language/ai-layout-design.js.map +1 -1
  133. package/src/lib/layout-language/ai-layout-frame.js +23 -0
  134. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  135. package/src/lib/layout-language/ai-layout-labels.d.ts +2 -0
  136. package/src/lib/layout-language/ai-layout-labels.js +12 -6
  137. package/src/lib/layout-language/ai-layout-labels.js.map +1 -1
  138. package/src/lib/layout-language/ai-layout-language.d.ts +3 -2
  139. package/src/lib/layout-language/ai-layout-language.js +4 -3
  140. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  141. package/src/lib/layout-language/ai-layout-links.d.ts +13 -0
  142. package/src/lib/layout-language/ai-layout-links.js +30 -0
  143. package/src/lib/layout-language/ai-layout-links.js.map +1 -1
  144. package/src/lib/layout-language/ai-layout-pictures.d.ts +49 -6
  145. package/src/lib/layout-language/ai-layout-pictures.js +145 -22
  146. package/src/lib/layout-language/ai-layout-pictures.js.map +1 -1
  147. package/src/lib/model/ai-build-job.d.ts +16 -1
  148. package/src/lib/model/ai-build-job.js +40 -0
  149. package/src/lib/model/ai-build-job.js.map +1 -1
  150. package/src/lib/model/ai-job-input.d.ts +33 -0
  151. package/src/lib/model/ai-job-input.js +59 -0
  152. package/src/lib/model/ai-job-input.js.map +1 -0
  153. package/src/lib/model/ai-job-notice.d.ts +4 -0
  154. package/src/lib/model/ai-job-notice.js +11 -1
  155. package/src/lib/model/ai-job-notice.js.map +1 -1
  156. package/src/lib/model/ai-jobs.types.d.ts +40 -1
  157. package/src/lib/model/ai-jobs.types.js.map +1 -1
  158. package/src/lib/model/ai-site-details.d.ts +122 -0
  159. package/src/lib/model/ai-site-details.js +300 -0
  160. package/src/lib/model/ai-site-details.js.map +1 -0
  161. package/src/lib/model/ai-site-entity.d.ts +181 -0
  162. package/src/lib/model/ai-site-entity.js +390 -0
  163. package/src/lib/model/ai-site-entity.js.map +1 -0
  164. package/src/lib/model/ai-site-inspiration.d.ts +72 -0
  165. package/src/lib/model/ai-site-inspiration.js +109 -0
  166. package/src/lib/model/ai-site-inspiration.js.map +1 -0
  167. package/src/lib/model/ai-site-job.d.ts +13 -1
  168. package/src/lib/model/ai-site-job.js +15 -2
  169. package/src/lib/model/ai-site-job.js.map +1 -1
  170. package/src/lib/model/ai-site-kinds.js +109 -21
  171. package/src/lib/model/ai-site-kinds.js.map +1 -1
  172. package/src/lib/model/ai-site-look.d.ts +10 -0
  173. package/src/lib/model/ai-site-look.js +24 -0
  174. package/src/lib/model/ai-site-look.js.map +1 -1
  175. package/src/lib/model/ai-site-start-seo.d.ts +19 -5
  176. package/src/lib/model/ai-site-start-seo.js +25 -7
  177. package/src/lib/model/ai-site-start-seo.js.map +1 -1
  178. package/src/lib/model/ai-site-start-steps.d.ts +9 -3
  179. package/src/lib/model/ai-site-start-steps.js +67 -5
  180. package/src/lib/model/ai-site-start-steps.js.map +1 -1
  181. package/src/lib/model/ai-site-start.d.ts +68 -4
  182. package/src/lib/model/ai-site-start.js +166 -13
  183. package/src/lib/model/ai-site-start.js.map +1 -1
  184. package/src/lib/model/ai-upsell-copy.js +4 -1
  185. package/src/lib/model/ai-upsell-copy.js.map +1 -1
  186. package/src/lib/plan-entitlements.d.ts +4 -3
  187. package/src/lib/plan-entitlements.js +3 -8
  188. package/src/lib/plan-entitlements.js.map +1 -1
  189. package/src/lib/runtime/ai-dataset-generation.d.ts +8 -1
  190. package/src/lib/runtime/ai-dataset-generation.js +12 -2
  191. package/src/lib/runtime/ai-dataset-generation.js.map +1 -1
  192. package/src/lib/runtime/ai-doctrine-validators.d.ts +26 -33
  193. package/src/lib/runtime/ai-doctrine-validators.js +54 -44
  194. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  195. package/src/lib/runtime/ai-doctrine.js +1 -1
  196. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  197. package/src/lib/runtime/ai-node-tree.d.ts +7 -0
  198. package/src/lib/runtime/ai-node-tree.js +9 -1
  199. package/src/lib/runtime/ai-node-tree.js.map +1 -1
  200. package/src/lib/server/ai-create-route.d.ts +1 -1
  201. package/src/lib/server/ai-create-route.js +3 -4
  202. package/src/lib/server/ai-create-route.js.map +1 -1
  203. package/src/lib/server/ai-jobs-resume.js +27 -3
  204. package/src/lib/server/ai-jobs-resume.js.map +1 -1
  205. package/src/lib/server/ai-jobs-route.js +7 -0
  206. package/src/lib/server/ai-jobs-route.js.map +1 -1
  207. package/src/lib/usage/assist-credits.d.ts +4 -4
  208. package/src/lib/usage/assist-credits.js +4 -4
  209. package/src/lib/usage/assist-credits.js.map +1 -1
  210. package/src/lib/usage/staff-org-ai-view.js +6 -3
  211. package/src/lib/usage/staff-org-ai-view.js.map +1 -1
  212. package/src/lib/usage/staff-org-ai.d.ts +4 -2
  213. package/src/lib/usage/staff-org-ai.js +7 -7
  214. package/src/lib/usage/staff-org-ai.js.map +1 -1
  215. package/src/lib/usage/staff-org-usage-ai.js +2 -2
  216. package/src/lib/usage/staff-org-usage-ai.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/layout-language/ai-layout-pictures.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DEFAULT_SITE_IMAGES } from '@aglyn/aglyn/app-utils/default-site'\nimport type { NodesMap } from '@aglyn/aglyn/types/nodes'\nimport { aiLayoutLabel, aiLayoutSpeaksOtherThanEnglish } from './ai-layout-labels'\n\n/**\n * THE PICTURES OF A LANGUAGE PAGE (AGL-3660).\n *\n * The compiler writes a picture slot as a frame holding an icon and an\n * `image` with alt text and no source (`ai-layout-compiler.ts`), and stays\n * pure: it never looks a photo up. This module is what runs after it, on the\n * stored page — it finds each empty slot, decides what kind of picture the\n * slot is, and fills it with a photo the site can serve from its own origin.\n *\n * Two sources fill a slot, in order:\n *\n * 1. A stock photo searched for by the slot's own description and copied into\n * the site's media library (`jobs/ai-layout-stock-photos.ts`), when the\n * deployment has a stock-photo key.\n * 2. Where the library cannot be asked at all — no stock-photo key, the\n * library down, refusing or out of time before it answered — one of the\n * STARTER PHOTOS every new site is born with (`DEFAULT_SITE_IMAGES`,\n * served at `/_static/starter/` by the tenant and the console alike,\n * credited in the CREDITS file beside them). They are the platform's own\n * files, so a visitor's browser asks no other host for them, and a\n * starter reads better than no picture when there is no library.\n *\n * Where the library answered and nothing in it fits a slot\n * ({@link AI_LAYOUT_NO_PHOTO}), the slot never takes a starter: the beta.257\n * Copper Kettle Catering start (2026-10-15) opened a barbecue caterer's home\n * page on the starters' pottery workbench (AGL-3831). Nor does it ship empty\n * (AGL-3856): its picture is taken out, frame and all\n * ({@link aiLayoutDropEmptyPictures}). A cover's frame is a black scrim laid\n * over the whole section, and with nothing in it the beta.261 Synchronicity\n * Gym hero read as a solid black block; a split's picture card is a rounded\n * gray box, and the beta.262 Adult Hybrid Learning Center hero read as\n * broken. Without them the section shows its own band, a cover's section\n * still pinned to the site's dark scheme so the words written for a dark\n * photo stay readable, and a split's words take the row's width.\n *\n * A slot keeps the alt text the model wrote only when it describes the photo\n * placed: a stock photo that is not what it says is described by what it is\n * (`aiStockPhotoAlt`), and a starter photo always by its own words, since\n * the model never wrote for it (AGL-3831). A stand-in the compiler drew where\n * the model described no picture is decorative while empty; the photo placed\n * there is described by its own words and is no longer decorative (AGL-3856).\n */\n\n/** What a picture slot is for, read from where it sits and what it says. */\nexport type AiLayoutPictureRole = 'hero' | 'about' | 'gallery'\n\n/** One empty picture slot of a stored page, in document order. */\nexport interface AiLayoutPictureSlot {\n /** The `image` node. */\n imageId: string\n /** The frame around it, which sets the slot's shape. */\n frameId: string | null\n /** The placeholder icon sharing the frame, taken out once a photo fills it. */\n iconId: string | null\n alt: string\n /** The frame's shape as width over height; 1 when it names none. */\n aspect: number\n /** The plan index of the section it sits in, or -1. */\n sectionIndex: number\n role: AiLayoutPictureRole\n /**\n * A product's photo (AGL-3676): what it is of, most specific first — its\n * name, then what its photo should show — searched for with the shop's\n * category and held to it, so a wick trimmer is never a laptop on a desk.\n */\n product?: { subjects: readonly string[] }\n /**\n * A stand-in the compiler drew where the model described no picture\n * (AGL-3856): its words are what a search looks for, never what a photo\n * shows, so a photo placed there is described by its own, and is no longer\n * decorative once it is.\n */\n standIn?: boolean\n /**\n * A portrait of one of the business's people (AGL-3856): a record of a\n * team, staff or instructors list. Its photo shows an adult, in the role\n * its words or its list name where one is listed, never a child or a thing.\n */\n people?: boolean\n /**\n * A dataset record's cover (AGL-3856): what the record is filed under — the\n * value of its list's category-like field (\"Weddings and elopements\") —\n * read after its own name for what its photo is OF. A photographer's record\n * is the photographed moment, never the photographer or the camera.\n */\n record?: { category?: string }\n}\n\n/** A photo a slot is filled with. */\nexport interface AiLayoutPicturePhoto {\n /** The site-served address: a starter path or the media library's own. */\n src: string\n width: number\n height: number\n /**\n * What the photo shows, where the slot's own alt text does not say it: the\n * slot takes it in place of the words the model wrote before the photo was\n * found. Absent, the slot's words describe it.\n */\n alt?: string\n}\n\n/** Words that say a picture shows people, or a section is about them. */\nconst PEOPLE =\n /\\b(team|story|owner|owners|founder|founders|staff|crew|people|person|portrait|meet|family|families|who we are|our (?:team|crew|people|story)|therapist|counsel(?:l)?or|coach|doctor|dentist|stylist|trainer|smil(?:e|es|ing)|headshot)\\b/i\n\n/**\n * \"About\" as what a section or a picture is (AGL-3923): leading its words\n * (\"About us\", \"About the studio\"), never the preposition inside them. The\n * beta.267 Brightvale closing band, \"Ready to talk about your marketing?\",\n * was read as a picture of people and searched \"ready talk marketing\" among\n * portraits, which answered a tin-can telephone.\n */\nconst ABOUT = /^\\W*about\\b/i\n\n/**\n * An `aspectRatio` (`'16 / 9'`) as a number, or `null` where none is named.\n * A responsive one (`{ xs: '4 / 3', md: '4 / 5' }`, as a designed page's\n * pictures carry, AGL-3660) reads at the desktop breakpoint first: one photo\n * serves every width, and the wide screen is where its shape shows most.\n */\nfunction aspectOf(value: unknown): number | null {\n if (value && typeof value === 'object') {\n const byBreakpoint = value as Record<string, unknown>\n for (const breakpoint of ['md', 'lg', 'xl', 'sm', 'xs']) {\n const ratio = aspectOf(byBreakpoint[breakpoint])\n if (ratio !== null) return ratio\n }\n return null\n }\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*\\/\\s*(\\d+(?:\\.\\d+)?)\\s*$/.exec(String(value ?? ''))\n if (!match) return null\n const ratio = Number(match[1]) / Number(match[2])\n return Number.isFinite(ratio) && ratio > 0 ? ratio : null\n}\n\n/** The shape a full-bleed cover's photo is searched for: it fills a wide band. */\nconst COVER_ASPECT = 16 / 9\n\n/**\n * A slot's shape (AGL-3660): the image's own `aspectRatio` (a designed\n * picture card sets it on the image), else its frame's, else — for a frame\n * laid absolutely over its whole section, a designed photo cover — a wide\n * band's. 1 where nothing says.\n */\nfunction slotAspect(image: { sx?: Record<string, unknown> } | undefined, frame: { sx?: Record<string, unknown> } | undefined): number {\n const own = aspectOf(image?.sx?.['aspectRatio']) ?? aspectOf(frame?.sx?.['aspectRatio'])\n if (own !== null) return own\n const sx = frame?.sx\n if (sx?.['position'] === 'absolute' && sx['width'] === '100%' && sx['height'] === '100%') return COVER_ASPECT\n return 1\n}\n\n/** A slot's role: the first section's picture is the hero; people make an about picture. */\nexport function aiLayoutPictureRole(input: {\n sectionIndex: number\n sectionName: string\n alt: string\n}): AiLayoutPictureRole {\n if (input.sectionIndex === 0) return 'hero'\n if (PEOPLE.test(input.sectionName) || PEOPLE.test(input.alt) || ABOUT.test(input.sectionName) || ABOUT.test(input.alt)) return 'about'\n return 'gallery'\n}\n\n/**\n * Every empty picture slot of a stored page, walked from its root in\n * document order. A slot that already has a source — one the owner placed, or\n * an earlier pass filled — is not a slot.\n */\nexport function aiLayoutPictureSlots(\n nodes: NodesMap,\n rootId: string,\n sections: { ids: readonly string[]; names: readonly string[] },\n): AiLayoutPictureSlot[] {\n const map = nodes as unknown as Record<\n string,\n { componentId?: string; props?: Record<string, unknown>; sx?: Record<string, unknown>; nodes?: string[] }\n >\n const slots: AiLayoutPictureSlot[] = []\n const seen = new Set<string>()\n const visit = (id: string, parentId: string | null, sectionIndex: number) => {\n if (seen.has(id)) return\n seen.add(id)\n const node = map[id]\n if (!node) return\n const index = sections.ids.indexOf(id)\n const here = index >= 0 ? index : sectionIndex\n if (node.componentId === 'image') {\n const src = node.props?.['src']\n const alt = typeof node.props?.['alt'] === 'string' ? (node.props['alt'] as string).trim() : ''\n if ((typeof src !== 'string' || !src.trim()) && alt) {\n const frame = parentId ? map[parentId] : undefined\n const iconId =\n frame?.nodes?.find((child) => child !== id && map[child]?.componentId === 'icon') ?? null\n slots.push({\n imageId: id,\n frameId: frame ? parentId : null,\n iconId,\n alt,\n aspect: slotAspect(node, frame),\n sectionIndex: here,\n ...(node.props?.['decorative'] === true ? { standIn: true } : {}),\n role: aiLayoutPictureRole({\n sectionIndex: here,\n sectionName: here >= 0 ? (sections.names[here] ?? '') : '',\n alt,\n }),\n })\n }\n }\n for (const child of node.nodes ?? []) visit(child, id, here)\n }\n visit(rootId, null, -1)\n return slots\n}\n\n/** The starter photos, by name, each with the words that describe it. */\nexport const AI_LAYOUT_STARTER_PHOTOS = DEFAULT_SITE_IMAGES\n\n/**\n * A source's answer for a slot the library answered and nothing in it fits\n * (AGL-3831): the slot keeps its no-photo treatment rather than take a\n * starter. Its source is empty, so a caller reading `src` to fill something\n * that must hold a photo (a product's, a record's) falls back as it would on\n * `null`.\n */\nexport const AI_LAYOUT_NO_PHOTO: Readonly<AiLayoutPicturePhoto> = Object.freeze({ src: '', width: 0, height: 0 })\n\ntype StarterName = keyof typeof AI_LAYOUT_STARTER_PHOTOS\n\n/**\n * The starter photos each role draws from, best first. A hero draws from the\n * wide photos that read as a page's opening, an about picture leads with the\n * owner, and the rest are the gallery's.\n */\nconst STARTER_POOLS: Readonly<Record<AiLayoutPictureRole, readonly StarterName[]>> = {\n hero: ['hero', 'desk', 'craft'],\n about: ['about', 'hero'],\n gallery: ['desk', 'plants', 'craft'],\n}\n\nconst ALL_STARTERS = Object.keys(AI_LAYOUT_STARTER_PHOTOS) as StarterName[]\n\n/** A small stable number from a seed, so the same job always picks the same photos. */\nexport function aiLayoutSeedNumber(seed: string): number {\n let hash = 2166136261\n for (let index = 0; index < seed.length; index += 1) {\n hash ^= seed.charCodeAt(index)\n hash = Math.imul(hash, 16777619)\n }\n return hash >>> 0\n}\n\nfunction rotate<T>(list: readonly T[], by: number): T[] {\n if (!list.length) return []\n const start = by % list.length\n return [...list.slice(start), ...list.slice(0, start)]\n}\n\n/**\n * A starter photo for each slot (AGL-3660). No photo repeats on a page while\n * an unused one remains, and every pool turns by the seed, so sites do not\n * all open with the same photo while one job always picks the same.\n *\n * The slots are served by what they are for, not where they sit: the hero\n * first, then the pictures of people (an about picture leads with the owner),\n * then the rest. The live Juniper Clay start (2026-10-08) had six slots and\n * five starters, and the owner's photo went to a stoneware card before the\n * About section that described the artist asked for it. Only a page with more\n * slots than starters repeats one: the photo placed longest ago, never the\n * one in a slot beside it. The owner's portrait goes only to a picture of\n * people; a gallery picture never takes it, even to avoid a repeat.\n */\nexport function aiLayoutStarterPhotos(\n slots: readonly AiLayoutPictureSlot[],\n seed: string,\n): AiLayoutPicturePhoto[] {\n const turn = aiLayoutSeedNumber(seed)\n const order: AiLayoutPictureRole[] = ['hero', 'about', 'gallery']\n const served = slots\n .map((slot, index) => ({ slot, index }))\n .sort((a, b) => order.indexOf(a.slot.role) - order.indexOf(b.slot.role) || a.index - b.index)\n const names: Array<StarterName | undefined> = slots.map(() => undefined)\n /** When each starter was last placed, by its turn in the serving order. */\n const placedAt = new Map<StarterName, number>()\n served.forEach(({ slot, index }, step) => {\n // An about picture leads with the owner on every site; the others turn.\n const pool = slot.role === 'about' ? [...STARTER_POOLS.about] : rotate(STARTER_POOLS[slot.role], turn)\n const rest = rotate(\n ALL_STARTERS.filter((name) => !pool.includes(name)),\n turn,\n )\n // The owner's portrait is a picture of a person, and only a picture of\n // people takes it: never a vase in a gallery (AGL-3660). A portrait of\n // one of the business's people takes only people, repeated before a\n // workbench stands in for a teacher (AGL-3856).\n const candidates = slot.people\n ? [...STARTER_POOLS.about]\n : [...pool, ...rest].filter((name) => slot.role === 'about' || name !== 'about')\n const unused = candidates.find((candidate) => !placedAt.has(candidate))\n const beside = new Set([names[index - 1], names[index + 1]].filter(Boolean))\n const name =\n unused ??\n [...candidates]\n .sort((a, b) => (placedAt.get(a) ?? -1) - (placedAt.get(b) ?? -1))\n .find((candidate) => !beside.has(candidate)) ??\n candidates[0]\n names[index] = name\n placedAt.set(name, step)\n })\n return names.map((name) => {\n const photo = AI_LAYOUT_STARTER_PHOTOS[name as StarterName]\n return { src: photo.src, width: photo.width, height: photo.height, alt: photo.alt }\n })\n}\n\n/**\n * The starters that show no one's business (AGL-3923): a team at a table in a\n * bright office, a tidy desk. Never the workbench, the coffee shop's owner or\n * the houseplants, which read as another business's own photos (AGL-3831).\n */\nconst NEUTRAL_STARTERS: readonly StarterName[] = ['hero', 'desk']\n\n/**\n * A neutral starter for each slot a library could not fill, where the site\n * has a library (AGL-3923): each at most once on a page, the hero served\n * first and each pool turned by the seed, and none for a portrait of the\n * business's people or a product, nor for a slot past the two. A slot given\n * none keeps the no-photo treatment.\n */\nexport function aiLayoutNeutralStarterPhotos(\n slots: readonly AiLayoutPictureSlot[],\n seed: string,\n): Array<AiLayoutPicturePhoto | null> {\n const pool = rotate(NEUTRAL_STARTERS, aiLayoutSeedNumber(seed))\n const order: AiLayoutPictureRole[] = ['hero', 'gallery', 'about']\n const served = slots\n .map((slot, index) => ({ slot, index }))\n .filter(({ slot }) => !slot.people && !slot.product)\n .sort((a, b) => order.indexOf(a.slot.role) - order.indexOf(b.slot.role) || a.index - b.index)\n const photos: Array<AiLayoutPicturePhoto | null> = slots.map(() => null)\n served.forEach(({ index }, step) => {\n const name = pool[step]\n if (!name) return\n const photo = AI_LAYOUT_STARTER_PHOTOS[name]\n photos[index] = { src: photo.src, width: photo.width, height: photo.height, alt: photo.alt }\n })\n return photos\n}\n\n/**\n * The page with each slot filled by its photo: the `image` given its source,\n * its intrinsic size and how it loads (the hero eagerly, as the starter home\n * page loads its own), and the placeholder icon taken out of the frame. The\n * alt text is kept as the model wrote it unless the photo brings its own\n * words. A slot given no photo is left as the compiler wrote it.\n */\nexport function aiLayoutPlacePictures(\n nodes: NodesMap,\n slots: readonly AiLayoutPictureSlot[],\n photos: ReadonlyArray<AiLayoutPicturePhoto | null>,\n): NodesMap {\n const next = { ...(nodes as unknown as Record<string, Record<string, unknown>>) }\n // Only the page's first picture loads eagerly (rule 16, AGL-3660): a hero\n // of several photos loaded them all eagerly, and a live Portfolio page was\n // refused for it (2026-10-10). The slots are in document order; every later\n // picture leaves `loading` unset, which the renderer loads when reached.\n const lead = slots.findIndex((_, index) => Boolean(photos[index] && next[slots[index].imageId]))\n slots.forEach((slot, index) => {\n const photo = photos[index]\n const node = next[slot.imageId]\n if (!photo || !node) return\n const props = { ...((node['props'] as Record<string, unknown> | undefined) ?? {}) }\n delete props['loading']\n // A photo placed is described by its words, never hidden from a screen\n // reader: a stand-in was decorative only while it showed nothing (AGL-3856).\n if (photo.alt?.trim()) delete props['decorative']\n next[slot.imageId] = {\n ...node,\n props: {\n ...props,\n src: photo.src,\n intrinsicWidth: photo.width,\n intrinsicHeight: photo.height,\n ...(photo.alt?.trim() ? { alt: photo.alt.trim() } : {}),\n ...(index === lead && slot.role === 'hero' ? { loading: 'eager' } : {}),\n },\n }\n if (slot.iconId && slot.frameId && next[slot.frameId]) {\n const frame = next[slot.frameId]\n next[slot.frameId] = {\n ...frame,\n nodes: ((frame['nodes'] as string[] | undefined) ?? []).filter((child) => child !== slot.iconId),\n }\n delete next[slot.iconId]\n }\n })\n return next as unknown as NodesMap\n}\n\n/** Whether a node is a grid row: a `muiGrid` container. */\nconst isGridRow = (node: Record<string, unknown> | undefined) =>\n node?.['componentId'] === 'muiGrid' && (node['props'] as Record<string, unknown> | undefined)?.['container'] === true\n\n/** Whether a node is a column of a grid row: a sized `muiGrid` item. */\nconst isGridColumn = (node: Record<string, unknown> | undefined) =>\n node?.['componentId'] === 'muiGrid' && !isGridRow(node)\n\n/**\n * The page without the pictures left with no photo (AGL-3856). A slot whose\n * photo is missing loses its image, its icon and its frame where the frame\n * holds nothing else, and so does every wrapper that holds nothing once it\n * is gone, up to its section. A cover's black scrim over nothing read as a\n * solid black block (the beta.261 Synchronicity Gym hero), and an empty\n * rounded gray card as a broken picture (the beta.262 Adult Hybrid Learning\n * Center hero). A column of a split row taken out leaves the words' column\n * the row's full width. A cover's section stays pinned to the site's dark\n * scheme, which paints that scheme's background and text colors, so the\n * words written for a dark photo stay readable. A slot a photo fills, a\n * starter's included, is kept.\n */\nexport function aiLayoutDropEmptyPictures(\n nodes: NodesMap,\n slots: readonly AiLayoutPictureSlot[],\n photos: ReadonlyArray<AiLayoutPicturePhoto | null>,\n sectionIds: readonly string[] = [],\n): NodesMap {\n const map = nodes as unknown as Record<string, Record<string, unknown>>\n const empty = slots.filter((slot, index) => {\n if (photos[index]?.src) return false\n const src = (map[slot.imageId]?.['props'] as Record<string, unknown> | undefined)?.['src']\n return Boolean(map[slot.imageId]) && !(typeof src === 'string' && src.trim())\n })\n if (!empty.length) return nodes\n const next = { ...map }\n const children = (id: string) => (next[id]?.['nodes'] as string[] | undefined) ?? []\n const parentOf = (id: string) => Object.keys(next).find((key) => children(key).includes(id)) ?? null\n const remove = (id: string) => {\n const parent = parentOf(id)\n if (parent) next[parent] = { ...next[parent], nodes: children(parent).filter((child) => child !== id) }\n delete next[id]\n return parent\n }\n const sections = new Set(sectionIds)\n for (const slot of empty) {\n const own = new Set([slot.imageId, slot.iconId].filter(Boolean) as string[])\n const frameHoldsOnly = Boolean(slot.frameId && next[slot.frameId] && children(slot.frameId).every((child) => own.has(child)))\n let parent = remove(slot.imageId)\n if (slot.iconId && next[slot.iconId]) remove(slot.iconId)\n if (!frameHoldsOnly) continue\n // The frame, then each wrapper it leaves empty: never a section, nor the page's root.\n let at: string | null = slot.frameId\n while (at && next[at] && !children(at).length && !sections.has(at) && parentOf(at) !== null) {\n const column = isGridColumn(next[at])\n parent = remove(at)\n at = column ? null : parent\n }\n // A split row left with one column gives its words the row's width.\n if (parent && isGridRow(next[parent])) {\n const [only, ...rest] = children(parent)\n if (only && !rest.length && isGridColumn(next[only])) {\n const column = next[only] as Record<string, unknown>\n const sx = { ...((column['sx'] as Record<string, unknown> | undefined) ?? {}) }\n delete sx['order']\n next[only] = {\n ...column,\n props: { ...((column['props'] as Record<string, unknown> | undefined) ?? {}), size: 'xs:12' },\n sx: Object.keys(sx).length ? sx : null,\n }\n }\n }\n }\n return next as unknown as NodesMap\n}\n\n/**\n * A source of photos found for the slots themselves — a stock search copied\n * into the site's library — answering per slot, in order: a photo; or\n * {@link AI_LAYOUT_NO_PHOTO} where the library answered and nothing fits,\n * which leaves the slot without a photo; or `null` where the library could\n * not be asked, which takes a starter photo. It may throw, and then every\n * slot takes a starter.\n */\nexport type AiLayoutPictureSource = (\n slots: readonly AiLayoutPictureSlot[],\n) => Promise<ReadonlyArray<AiLayoutPicturePhoto | null>>\n\n/**\n * Fills a stored page's empty picture slots (AGL-3660): from `source` where\n * one is given and it answers; a slot it answers with nothing fitting stays\n * without a photo and is taken out ({@link aiLayoutDropEmptyPictures}); every\n * other slot takes a starter photo, described by its own words (AGL-3831). Never throws, and never leaves a page worse than it\n * came: a picture is decoration, and a job never fails over one.\n */\nexport async function aiResolveLayoutPictures(\n nodes: NodesMap,\n input: {\n rootId: string\n sectionIds: readonly string[]\n sectionNames: readonly string[]\n /** A per-job word, so two sites do not open with the same photo. */\n seed: string\n source?: AiLayoutPictureSource | null\n /** The site's language (AGL-3750); a starter photo's English words are not its own. */\n language?: string\n },\n): Promise<NodesMap> {\n try {\n const slots = aiLayoutPictureSlots(nodes, input.rootId, {\n ids: input.sectionIds,\n names: input.sectionNames,\n })\n if (!slots.length) return nodes\n let found: ReadonlyArray<AiLayoutPicturePhoto | null> = []\n if (input.source) {\n try {\n found = await input.source(slots)\n } catch (error) {\n console.warn('ai layout pictures: the stock source failed; starter photos fill the page', { error })\n found = []\n }\n }\n // The starters' words are English; a site in another language says it\n // shows an illustrative photo, true of any photo, as a stock photo's does.\n const otherLanguage = aiLayoutSpeaksOtherThanEnglish(input.language)\n const said = (photo: AiLayoutPicturePhoto): AiLayoutPicturePhoto =>\n otherLanguage ? { ...photo, alt: aiLayoutLabel('illustrativePhoto', input.language) } : photo\n // With a library, a starter is only ever a neutral one (AGL-3923): the\n // beta.267 Brightvale start, whose library refused its copies, showed a\n // pottery bench and a coffee shop's owner as a marketer's pictures.\n const starters = (input.source ? aiLayoutNeutralStarterPhotos(slots, input.seed) : aiLayoutStarterPhotos(slots, input.seed)).map(\n (photo) => (photo ? said(photo) : null),\n )\n const photos = slots.map((_slot, index) => {\n const answer = found[index]\n if (answer) return answer.src ? answer : null\n return starters[index] ?? null\n })\n // The page floor (AGL-3923; Zach, 2026-10-12: a starter photo before no\n // photo at all): a page the library answered that would show no picture\n // keeps one neutral starter, in its hero, else its first slot.\n if (input.source && !photos.some((photo) => photo?.src)) {\n const at = Math.max(0, slots.findIndex((slot) => slot.role === 'hero'))\n const [floor] = rotate(NEUTRAL_STARTERS, aiLayoutSeedNumber(input.seed))\n const photo = floor ? AI_LAYOUT_STARTER_PHOTOS[floor] : null\n if (photo) photos[at] = said({ src: photo.src, width: photo.width, height: photo.height, alt: photo.alt })\n }\n return aiLayoutDropEmptyPictures(aiLayoutPlacePictures(nodes, slots, photos), slots, photos, input.sectionIds)\n } catch (error) {\n console.error('ai layout pictures: the page keeps its empty picture slots', { error })\n return nodes\n }\n}\n"],"names":["DEFAULT_SITE_IMAGES","aiLayoutLabel","aiLayoutSpeaksOtherThanEnglish","PEOPLE","ABOUT","aspectOf","value","byBreakpoint","breakpoint","ratio","match","exec","String","Number","isFinite","COVER_ASPECT","slotAspect","image","frame","own","sx","aiLayoutPictureRole","input","sectionIndex","test","sectionName","alt","aiLayoutPictureSlots","nodes","rootId","sections","map","slots","seen","Set","visit","id","parentId","node","has","add","index","ids","indexOf","here","componentId","src","props","trim","undefined","iconId","find","child","push","imageId","frameId","aspect","standIn","role","names","AI_LAYOUT_STARTER_PHOTOS","AI_LAYOUT_NO_PHOTO","Object","freeze","width","height","STARTER_POOLS","hero","about","gallery","ALL_STARTERS","keys","aiLayoutSeedNumber","seed","hash","length","charCodeAt","Math","imul","rotate","list","by","start","slice","aiLayoutStarterPhotos","turn","order","served","slot","sort","a","b","placedAt","Map","forEach","step","unused","pool","rest","filter","name","includes","candidates","people","candidate","beside","Boolean","get","set","photo","NEUTRAL_STARTERS","aiLayoutNeutralStarterPhotos","product","photos","aiLayoutPlacePictures","next","lead","findIndex","_","intrinsicWidth","intrinsicHeight","loading","isGridRow","isGridColumn","aiLayoutDropEmptyPictures","sectionIds","empty","children","parentOf","key","remove","parent","frameHoldsOnly","every","at","column","only","size","aiResolveLayoutPictures","sectionNames","found","source","error","console","warn","otherLanguage","language","said","starters","_slot","answer","some","max","floor"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,mBAAmB,QAAQ,sCAAqC;AAEzE,SAASC,aAAa,EAAEC,8BAA8B,QAAQ,wBAAoB;AAwGlF,uEAAuE,GACvE,MAAMC,S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kBAAmB;QAC5B;QACA,wEAAwE;QACxE,wEAAwE;QACxE,+DAA+D;QAC/D,IAAI9H,MAAMuH,MAAM,IAAI,CAAC5B,OAAOsC,IAAI,CAAC,CAAC1C,QAAUA,yBAAAA,MAAO/D,GAAG,GAAG;YACvD,MAAMwF,KAAKzD,KAAK2E,GAAG,CAAC,GAAGxH,MAAMqF,SAAS,CAAC,CAAC7B,OAASA,KAAK9B,IAAI,KAAK;YAC/D,MAAM,CAAC+F,MAAM,GAAG1E,OAAO+B,kBAAkBtC,mBAAmBlD,MAAMmD,IAAI;YACtE,MAAMoC,QAAQ4C,QAAQ7F,wBAAwB,CAAC6F,MAAM,GAAG;YACxD,IAAI5C,OAAOI,MAAM,CAACqB,GAAG,GAAGa,KAAK;gBAAErG,KAAK+D,MAAM/D,GAAG;gBAAEkB,OAAO6C,MAAM7C,KAAK;gBAAEC,QAAQ4C,MAAM5C,MAAM;gBAAEvC,KAAKmF,MAAMnF,GAAG;YAAC;QAC1G;QACA,OAAOkG,0BAA0BV,sBAAsBtF,OAAOI,OAAOiF,SAASjF,OAAOiF,QAAQ3F,MAAMuG,UAAU;IAC/G,EAAE,OAAOiB,OAAO;QACdC,QAAQD,KAAK,CAAC,8DAA8D;YAAEA;QAAM;QACpF,OAAOlH;IACT;AACF"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/layout-language/ai-layout-pictures.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DEFAULT_SITE_IMAGES } from '@aglyn/aglyn/app-utils/default-site'\nimport type { NodesMap } from '@aglyn/aglyn/types/nodes'\nimport { aiLayoutLabel, aiLayoutSpeaksOtherThanEnglish } from './ai-layout-labels'\n\n/**\n * THE PICTURES OF A LANGUAGE PAGE (AGL-3660).\n *\n * The compiler writes a picture slot as a frame holding an icon and an\n * `image` with alt text and no source (`ai-layout-compiler.ts`), and stays\n * pure: it never looks a photo up. This module is what runs after it, on the\n * stored page — it finds each empty slot, decides what kind of picture the\n * slot is, and fills it with a photo the site can serve from its own origin.\n *\n * Three sources fill a slot, in order:\n *\n * 1. A stock photo searched for by the slot's own description and copied into\n * the site's media library (`jobs/ai-layout-stock-photos.ts`), when the\n * deployment has a stock-photo key.\n * 2. Where the library failed the slot — down, refusing, out of time, or its\n * photo not copied — one of the photos the same job already placed on\n * this site, on its other pages or its datasets' records\n * ({@link aiLayoutJobPhotoPicks}, AGL-3988): each was found for the\n * site's own world, so a wedding photographer's home page shows a wedding\n * and never an office.\n * 3. Where the job has no photo of its own — no stock-photo key, or the\n * library failed it from the start — one of the\n * STARTER PHOTOS every new site is born with (`DEFAULT_SITE_IMAGES`,\n * served at `/_static/starter/` by the tenant and the console alike,\n * credited in the CREDITS file beside them). They are the platform's own\n * files, so a visitor's browser asks no other host for them, and a\n * starter reads better than no picture when there is no library.\n *\n * Where the library answered and nothing in it fits a slot\n * ({@link AI_LAYOUT_NO_PHOTO}), the slot never takes a starter: the beta.257\n * Copper Kettle Catering start (2026-10-15) opened a barbecue caterer's home\n * page on the starters' pottery workbench (AGL-3831). Nor does it ship empty\n * (AGL-3856): its picture is taken out, frame and all\n * ({@link aiLayoutDropEmptyPictures}). A cover's frame is a black scrim laid\n * over the whole section, and with nothing in it the beta.261 Synchronicity\n * Gym hero read as a solid black block; a split's picture card is a rounded\n * gray box, and the beta.262 Adult Hybrid Learning Center hero read as\n * broken. Without them the section shows its own band, a cover's section\n * still pinned to the site's dark scheme so the words written for a dark\n * photo stay readable, and a split's words take the row's width.\n *\n * A slot keeps the alt text the model wrote only when it describes the photo\n * placed: a stock photo that is not what it says is described by what it is\n * (`aiStockPhotoAlt`), and a starter photo always by its own words, since\n * the model never wrote for it (AGL-3831). A stand-in the compiler drew where\n * the model described no picture is decorative while empty; the photo placed\n * there is described by its own words and is no longer decorative (AGL-3856).\n */\n\n/** What a picture slot is for, read from where it sits and what it says. */\nexport type AiLayoutPictureRole = 'hero' | 'about' | 'gallery'\n\n/** One empty picture slot of a stored page, in document order. */\nexport interface AiLayoutPictureSlot {\n /** The `image` node. */\n imageId: string\n /** The frame around it, which sets the slot's shape. */\n frameId: string | null\n /** The placeholder icon sharing the frame, taken out once a photo fills it. */\n iconId: string | null\n alt: string\n /** The frame's shape as width over height; 1 when it names none. */\n aspect: number\n /** The plan index of the section it sits in, or -1. */\n sectionIndex: number\n role: AiLayoutPictureRole\n /**\n * A product's photo (AGL-3676): what it is of, most specific first — its\n * name, then what its photo should show — searched for with the shop's\n * category and held to it, so a wick trimmer is never a laptop on a desk.\n */\n product?: { subjects: readonly string[] }\n /**\n * A stand-in the compiler drew where the model described no picture\n * (AGL-3856): its words are what a search looks for, never what a photo\n * shows, so a photo placed there is described by its own, and is no longer\n * decorative once it is.\n */\n standIn?: boolean\n /**\n * A portrait of one of the business's people (AGL-3856): a record of a\n * team, staff or instructors list. Its photo shows an adult, in the role\n * its words or its list name where one is listed, never a child or a thing.\n */\n people?: boolean\n /**\n * A dataset record's cover (AGL-3856): what the record is filed under — the\n * value of its list's category-like field (\"Weddings and elopements\") —\n * read after its own name for what its photo is OF. A photographer's record\n * is the photographed moment, never the photographer or the camera.\n */\n record?: { category?: string }\n}\n\n/** A photo a slot is filled with. */\nexport interface AiLayoutPicturePhoto {\n /** The site-served address: a starter path or the media library's own. */\n src: string\n width: number\n height: number\n /**\n * What the photo shows, where the slot's own alt text does not say it: the\n * slot takes it in place of the words the model wrote before the photo was\n * found. Absent, the slot's words describe it.\n */\n alt?: string\n}\n\n/** Words that say a picture shows people, or a section is about them. */\nconst PEOPLE =\n /\\b(team|story|owner|owners|founder|founders|staff|crew|people|person|portrait|meet|family|families|who we are|our (?:team|crew|people|story)|therapist|counsel(?:l)?or|coach|doctor|dentist|stylist|trainer|smil(?:e|es|ing)|headshot)\\b/i\n\n/**\n * \"About\" as what a section or a picture is (AGL-3923): leading its words\n * (\"About us\", \"About the studio\"), never the preposition inside them. The\n * beta.267 Brightvale closing band, \"Ready to talk about your marketing?\",\n * was read as a picture of people and searched \"ready talk marketing\" among\n * portraits, which answered a tin-can telephone.\n */\nconst ABOUT = /^\\W*about\\b/i\n\n/**\n * An `aspectRatio` (`'16 / 9'`) as a number, or `null` where none is named.\n * A responsive one (`{ xs: '4 / 3', md: '4 / 5' }`, as a designed page's\n * pictures carry, AGL-3660) reads at the desktop breakpoint first: one photo\n * serves every width, and the wide screen is where its shape shows most.\n */\nfunction aspectOf(value: unknown): number | null {\n if (value && typeof value === 'object') {\n const byBreakpoint = value as Record<string, unknown>\n for (const breakpoint of ['md', 'lg', 'xl', 'sm', 'xs']) {\n const ratio = aspectOf(byBreakpoint[breakpoint])\n if (ratio !== null) return ratio\n }\n return null\n }\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*\\/\\s*(\\d+(?:\\.\\d+)?)\\s*$/.exec(String(value ?? ''))\n if (!match) return null\n const ratio = Number(match[1]) / Number(match[2])\n return Number.isFinite(ratio) && ratio > 0 ? ratio : null\n}\n\n/** The shape a full-bleed cover's photo is searched for: it fills a wide band. */\nconst COVER_ASPECT = 16 / 9\n\n/**\n * A slot's shape (AGL-3660): the image's own `aspectRatio` (a designed\n * picture card sets it on the image), else its frame's, else — for a frame\n * laid absolutely over its whole section, a designed photo cover — a wide\n * band's. 1 where nothing says.\n */\nfunction slotAspect(image: { sx?: Record<string, unknown> } | undefined, frame: { sx?: Record<string, unknown> } | undefined): number {\n const own = aspectOf(image?.sx?.['aspectRatio']) ?? aspectOf(frame?.sx?.['aspectRatio'])\n if (own !== null) return own\n const sx = frame?.sx\n if (sx?.['position'] === 'absolute' && sx['width'] === '100%' && sx['height'] === '100%') return COVER_ASPECT\n return 1\n}\n\n/** A slot's role: the first section's picture is the hero; people make an about picture. */\nexport function aiLayoutPictureRole(input: {\n sectionIndex: number\n sectionName: string\n alt: string\n}): AiLayoutPictureRole {\n if (input.sectionIndex === 0) return 'hero'\n if (PEOPLE.test(input.sectionName) || PEOPLE.test(input.alt) || ABOUT.test(input.sectionName) || ABOUT.test(input.alt)) return 'about'\n return 'gallery'\n}\n\n/**\n * Every empty picture slot of a stored page, walked from its root in\n * document order. A slot that already has a source — one the owner placed, or\n * an earlier pass filled — is not a slot.\n */\nexport function aiLayoutPictureSlots(\n nodes: NodesMap,\n rootId: string,\n sections: { ids: readonly string[]; names: readonly string[] },\n): AiLayoutPictureSlot[] {\n const map = nodes as unknown as Record<\n string,\n { componentId?: string; props?: Record<string, unknown>; sx?: Record<string, unknown>; nodes?: string[] }\n >\n const slots: AiLayoutPictureSlot[] = []\n const seen = new Set<string>()\n const visit = (id: string, parentId: string | null, sectionIndex: number) => {\n if (seen.has(id)) return\n seen.add(id)\n const node = map[id]\n if (!node) return\n const index = sections.ids.indexOf(id)\n const here = index >= 0 ? index : sectionIndex\n if (node.componentId === 'image') {\n const src = node.props?.['src']\n const alt = typeof node.props?.['alt'] === 'string' ? (node.props['alt'] as string).trim() : ''\n if ((typeof src !== 'string' || !src.trim()) && alt) {\n const frame = parentId ? map[parentId] : undefined\n const iconId =\n frame?.nodes?.find((child) => child !== id && map[child]?.componentId === 'icon') ?? null\n slots.push({\n imageId: id,\n frameId: frame ? parentId : null,\n iconId,\n alt,\n aspect: slotAspect(node, frame),\n sectionIndex: here,\n ...(node.props?.['decorative'] === true ? { standIn: true } : {}),\n role: aiLayoutPictureRole({\n sectionIndex: here,\n sectionName: here >= 0 ? (sections.names[here] ?? '') : '',\n alt,\n }),\n })\n }\n }\n for (const child of node.nodes ?? []) visit(child, id, here)\n }\n visit(rootId, null, -1)\n return slots\n}\n\n/** The starter photos, by name, each with the words that describe it. */\nexport const AI_LAYOUT_STARTER_PHOTOS = DEFAULT_SITE_IMAGES\n\n/**\n * A source's answer for a slot the library answered and nothing in it fits\n * (AGL-3831): the slot keeps its no-photo treatment rather than take a\n * starter. Its source is empty, so a caller reading `src` to fill something\n * that must hold a photo (a product's, a record's) falls back as it would on\n * `null`.\n */\nexport const AI_LAYOUT_NO_PHOTO: Readonly<AiLayoutPicturePhoto> = Object.freeze({ src: '', width: 0, height: 0 })\n\ntype StarterName = keyof typeof AI_LAYOUT_STARTER_PHOTOS\n\n/**\n * The starter photos each role draws from, best first. A hero draws from the\n * wide photos that read as a page's opening, an about picture leads with the\n * owner, and the rest are the gallery's.\n */\nconst STARTER_POOLS: Readonly<Record<AiLayoutPictureRole, readonly StarterName[]>> = {\n hero: ['hero', 'desk', 'craft'],\n about: ['about', 'hero'],\n gallery: ['desk', 'plants', 'craft'],\n}\n\nconst ALL_STARTERS = Object.keys(AI_LAYOUT_STARTER_PHOTOS) as StarterName[]\n\n/** A small stable number from a seed, so the same job always picks the same photos. */\nexport function aiLayoutSeedNumber(seed: string): number {\n let hash = 2166136261\n for (let index = 0; index < seed.length; index += 1) {\n hash ^= seed.charCodeAt(index)\n hash = Math.imul(hash, 16777619)\n }\n return hash >>> 0\n}\n\nfunction rotate<T>(list: readonly T[], by: number): T[] {\n if (!list.length) return []\n const start = by % list.length\n return [...list.slice(start), ...list.slice(0, start)]\n}\n\n/**\n * A starter photo for each slot (AGL-3660). No photo repeats on a page while\n * an unused one remains, and every pool turns by the seed, so sites do not\n * all open with the same photo while one job always picks the same.\n *\n * The slots are served by what they are for, not where they sit: the hero\n * first, then the pictures of people (an about picture leads with the owner),\n * then the rest. The live Juniper Clay start (2026-10-08) had six slots and\n * five starters, and the owner's photo went to a stoneware card before the\n * About section that described the artist asked for it. Only a page with more\n * slots than starters repeats one: the photo placed longest ago, never the\n * one in a slot beside it. The owner's portrait goes only to a picture of\n * people; a gallery picture never takes it, even to avoid a repeat.\n */\nexport function aiLayoutStarterPhotos(\n slots: readonly AiLayoutPictureSlot[],\n seed: string,\n): AiLayoutPicturePhoto[] {\n const turn = aiLayoutSeedNumber(seed)\n const order: AiLayoutPictureRole[] = ['hero', 'about', 'gallery']\n const served = slots\n .map((slot, index) => ({ slot, index }))\n .sort((a, b) => order.indexOf(a.slot.role) - order.indexOf(b.slot.role) || a.index - b.index)\n const names: Array<StarterName | undefined> = slots.map(() => undefined)\n /** When each starter was last placed, by its turn in the serving order. */\n const placedAt = new Map<StarterName, number>()\n served.forEach(({ slot, index }, step) => {\n // An about picture leads with the owner on every site; the others turn.\n const pool = slot.role === 'about' ? [...STARTER_POOLS.about] : rotate(STARTER_POOLS[slot.role], turn)\n const rest = rotate(\n ALL_STARTERS.filter((name) => !pool.includes(name)),\n turn,\n )\n // The owner's portrait is a picture of a person, and only a picture of\n // people takes it: never a vase in a gallery (AGL-3660). A portrait of\n // one of the business's people takes only people, repeated before a\n // workbench stands in for a teacher (AGL-3856).\n const candidates = slot.people\n ? [...STARTER_POOLS.about]\n : [...pool, ...rest].filter((name) => slot.role === 'about' || name !== 'about')\n const unused = candidates.find((candidate) => !placedAt.has(candidate))\n const beside = new Set([names[index - 1], names[index + 1]].filter(Boolean))\n const name =\n unused ??\n [...candidates]\n .sort((a, b) => (placedAt.get(a) ?? -1) - (placedAt.get(b) ?? -1))\n .find((candidate) => !beside.has(candidate)) ??\n candidates[0]\n names[index] = name\n placedAt.set(name, step)\n })\n return names.map((name) => {\n const photo = AI_LAYOUT_STARTER_PHOTOS[name as StarterName]\n return { src: photo.src, width: photo.width, height: photo.height, alt: photo.alt }\n })\n}\n\n/**\n * The starters that show no one's business (AGL-3923): a team at a table in a\n * bright office, a tidy desk. Never the workbench, the coffee shop's owner or\n * the houseplants, which read as another business's own photos (AGL-3831).\n */\nconst NEUTRAL_STARTERS: readonly StarterName[] = ['hero', 'desk']\n\n/**\n * A neutral starter for each of a list's records (AGL-3988), where the site\n * has a library and the job has no photo of its own: the two taken in turn\n * from the seed, so no record shows the photo of the one beside it. A card\n * of a listing cannot drop its frame as a page's picture does, so every\n * record takes one. Pure.\n */\nexport function aiLayoutNeutralStarterRun(count: number, seed: string): AiLayoutPicturePhoto[] {\n const pool = rotate(NEUTRAL_STARTERS, aiLayoutSeedNumber(seed))\n return Array.from({ length: Math.max(0, count) }, (_, index) => {\n const photo = AI_LAYOUT_STARTER_PHOTOS[pool[index % pool.length] as StarterName]\n return { src: photo.src, width: photo.width, height: photo.height, alt: photo.alt }\n })\n}\n\n/**\n * A neutral starter for each slot a library could not fill, where the site\n * has a library (AGL-3923): each at most once on a page, the hero served\n * first and each pool turned by the seed, and none for a portrait of the\n * business's people or a product, nor for a slot past the two. A slot given\n * none keeps the no-photo treatment.\n */\nexport function aiLayoutNeutralStarterPhotos(\n slots: readonly AiLayoutPictureSlot[],\n seed: string,\n): Array<AiLayoutPicturePhoto | null> {\n const pool = rotate(NEUTRAL_STARTERS, aiLayoutSeedNumber(seed))\n const order: AiLayoutPictureRole[] = ['hero', 'gallery', 'about']\n const served = slots\n .map((slot, index) => ({ slot, index }))\n .filter(({ slot }) => !slot.people && !slot.product)\n .sort((a, b) => order.indexOf(a.slot.role) - order.indexOf(b.slot.role) || a.index - b.index)\n const photos: Array<AiLayoutPicturePhoto | null> = slots.map(() => null)\n served.forEach(({ index }, step) => {\n const name = pool[step]\n if (!name) return\n const photo = AI_LAYOUT_STARTER_PHOTOS[name]\n photos[index] = { src: photo.src, width: photo.width, height: photo.height, alt: photo.alt }\n })\n return photos\n}\n\n/** A text's words a photo's own words may share: lowercase, four letters or more. */\nconst wordsOf = (text: string): Set<string> =>\n new Set(\n text\n .toLowerCase()\n .split(/[^a-zÀ-ɏ]+/)\n .filter((word) => word.length >= 4),\n )\n\n/**\n * The job's own photos for the slots a library could not fill (AGL-3988):\n * the photos THIS job already placed on this site — on its other pages, on\n * its datasets' records, and on this page — which were each found for the\n * site's own world, before any starter. The beta.270 Sugar Hollow\n * Photography start (2026-10-19) opened a wedding photographer's home page\n * on the starters' desk and an office team, and filed five wedding galleries\n * under a workbench, a windowsill and the same office, while the library\n * had already given the job three wedding and family photos.\n *\n * Each slot `need` names takes the one that fits it best: one this page does\n * not show yet before one it does, a wide photo for a hero, the shape\n * nearest its frame, and the most words shared with what the slot says it\n * shows; never the photo of the slot beside it. A product's photo and a\n * portrait of the business's people are of one named thing, which no other\n * photo is, so they take none. Among equals the seed picks, so one job\n * always picks the same. `null` for a slot given none. Pure.\n */\nexport function aiLayoutJobPhotoPicks(\n slots: readonly AiLayoutPictureSlot[],\n need: readonly boolean[],\n jobPhotos: readonly AiLayoutPicturePhoto[],\n placed: ReadonlyArray<AiLayoutPicturePhoto | null | undefined>,\n seed: string,\n): Array<AiLayoutPicturePhoto | null> {\n const seen = new Set<string>()\n const pool = jobPhotos.filter((photo) => {\n if (!photo.src || !(photo.width > 0) || !(photo.height > 0) || seen.has(photo.src)) return false\n seen.add(photo.src)\n return true\n })\n const picks: Array<AiLayoutPicturePhoto | null> = slots.map(() => null)\n if (!pool.length) return picks\n const shown = slots.map((_slot, index) => placed[index]?.src || '')\n const order: AiLayoutPictureRole[] = ['hero', 'about', 'gallery']\n const served = slots\n .map((slot, index) => ({ slot, index }))\n .filter(({ slot, index }) => need[index] && !slot.product && !slot.people)\n .sort((a, b) => order.indexOf(a.slot.role) - order.indexOf(b.slot.role) || a.index - b.index)\n const turn = aiLayoutSeedNumber(seed)\n for (const { slot, index } of served) {\n const beside = new Set([shown[index - 1], shown[index + 1]].filter(Boolean))\n const says = wordsOf(slot.alt)\n let best: { photo: AiLayoutPicturePhoto; score: number; rank: number } | null = null\n for (const [at, photo] of pool.entries()) {\n if (beside.has(photo.src)) continue\n const aspect = photo.width / photo.height\n const uses = shown.filter((src) => src === photo.src).length\n const shared = [...wordsOf(photo.alt ?? '')].filter((word) => says.has(word)).length\n const score =\n -100 * uses +\n (slot.role === 'hero' && aspect >= 1.3 ? 20 : 0) -\n 10 * Math.abs(Math.log(aspect / (slot.aspect > 0 ? slot.aspect : 1))) +\n 4 * shared\n // The seed turns the pool, so equals are taken in a per-job order.\n const rank = (at - (turn % pool.length) + pool.length) % pool.length\n if (!best || score > best.score || (score === best.score && rank < best.rank)) best = { photo, score, rank }\n }\n if (!best) continue\n picks[index] = { ...best.photo }\n shown[index] = best.photo.src\n }\n return picks\n}\n\n/**\n * The page with each slot filled by its photo: the `image` given its source,\n * its intrinsic size and how it loads (the hero eagerly, as the starter home\n * page loads its own), and the placeholder icon taken out of the frame. The\n * alt text is kept as the model wrote it unless the photo brings its own\n * words. A slot given no photo is left as the compiler wrote it.\n */\nexport function aiLayoutPlacePictures(\n nodes: NodesMap,\n slots: readonly AiLayoutPictureSlot[],\n photos: ReadonlyArray<AiLayoutPicturePhoto | null>,\n): NodesMap {\n const next = { ...(nodes as unknown as Record<string, Record<string, unknown>>) }\n // Only the page's first picture loads eagerly (rule 16, AGL-3660): a hero\n // of several photos loaded them all eagerly, and a live Portfolio page was\n // refused for it (2026-10-10). The slots are in document order; every later\n // picture leaves `loading` unset, which the renderer loads when reached.\n const lead = slots.findIndex((_, index) => Boolean(photos[index] && next[slots[index].imageId]))\n slots.forEach((slot, index) => {\n const photo = photos[index]\n const node = next[slot.imageId]\n if (!photo || !node) return\n const props = { ...((node['props'] as Record<string, unknown> | undefined) ?? {}) }\n delete props['loading']\n // A photo placed is described by its words, never hidden from a screen\n // reader: a stand-in was decorative only while it showed nothing (AGL-3856).\n // One that brings no words of its own, such as an owner's upload with no\n // alt text, keeps the slot's (AGL-3979): a picture a visitor sees always\n // has a description.\n const alt = photo.alt?.trim() || (typeof props['alt'] === 'string' ? props['alt'].trim() : '')\n if (alt) delete props['decorative']\n next[slot.imageId] = {\n ...node,\n props: {\n ...props,\n src: photo.src,\n intrinsicWidth: photo.width,\n intrinsicHeight: photo.height,\n ...(alt ? { alt } : {}),\n ...(index === lead && slot.role === 'hero' ? { loading: 'eager' } : {}),\n },\n }\n if (slot.iconId && slot.frameId && next[slot.frameId]) {\n const frame = next[slot.frameId]\n next[slot.frameId] = {\n ...frame,\n nodes: ((frame['nodes'] as string[] | undefined) ?? []).filter((child) => child !== slot.iconId),\n }\n delete next[slot.iconId]\n }\n })\n return next as unknown as NodesMap\n}\n\n/** Whether a node is a grid row: a `muiGrid` container. */\nconst isGridRow = (node: Record<string, unknown> | undefined) =>\n node?.['componentId'] === 'muiGrid' && (node['props'] as Record<string, unknown> | undefined)?.['container'] === true\n\n/** Whether a node is a column of a grid row: a sized `muiGrid` item. */\nconst isGridColumn = (node: Record<string, unknown> | undefined) =>\n node?.['componentId'] === 'muiGrid' && !isGridRow(node)\n\n/**\n * The page without the pictures left with no photo (AGL-3856). A slot whose\n * photo is missing loses its image, its icon and its frame where the frame\n * holds nothing else, and so does every wrapper that holds nothing once it\n * is gone, up to its section. A cover's black scrim over nothing read as a\n * solid black block (the beta.261 Synchronicity Gym hero), and an empty\n * rounded gray card as a broken picture (the beta.262 Adult Hybrid Learning\n * Center hero). A column of a split row taken out leaves the words' column\n * the row's full width. A cover's section stays pinned to the site's dark\n * scheme, which paints that scheme's background and text colors, so the\n * words written for a dark photo stay readable. A slot a photo fills, a\n * starter's included, is kept.\n */\nexport function aiLayoutDropEmptyPictures(\n nodes: NodesMap,\n slots: readonly AiLayoutPictureSlot[],\n photos: ReadonlyArray<AiLayoutPicturePhoto | null>,\n sectionIds: readonly string[] = [],\n): NodesMap {\n const map = nodes as unknown as Record<string, Record<string, unknown>>\n const empty = slots.filter((slot, index) => {\n if (photos[index]?.src) return false\n const src = (map[slot.imageId]?.['props'] as Record<string, unknown> | undefined)?.['src']\n return Boolean(map[slot.imageId]) && !(typeof src === 'string' && src.trim())\n })\n if (!empty.length) return nodes\n const next = { ...map }\n const children = (id: string) => (next[id]?.['nodes'] as string[] | undefined) ?? []\n const parentOf = (id: string) => Object.keys(next).find((key) => children(key).includes(id)) ?? null\n const remove = (id: string) => {\n const parent = parentOf(id)\n if (parent) next[parent] = { ...next[parent], nodes: children(parent).filter((child) => child !== id) }\n delete next[id]\n return parent\n }\n const sections = new Set(sectionIds)\n for (const slot of empty) {\n const own = new Set([slot.imageId, slot.iconId].filter(Boolean) as string[])\n const frameHoldsOnly = Boolean(slot.frameId && next[slot.frameId] && children(slot.frameId).every((child) => own.has(child)))\n let parent = remove(slot.imageId)\n if (slot.iconId && next[slot.iconId]) remove(slot.iconId)\n if (!frameHoldsOnly) continue\n // The frame, then each wrapper it leaves empty: never a section, nor the page's root.\n let at: string | null = slot.frameId\n while (at && next[at] && !children(at).length && !sections.has(at) && parentOf(at) !== null) {\n const column = isGridColumn(next[at])\n parent = remove(at)\n at = column ? null : parent\n }\n // A split row left with one column gives its words the row's width.\n if (parent && isGridRow(next[parent])) {\n const [only, ...rest] = children(parent)\n if (only && !rest.length && isGridColumn(next[only])) {\n const column = next[only] as Record<string, unknown>\n const sx = { ...((column['sx'] as Record<string, unknown> | undefined) ?? {}) }\n delete sx['order']\n next[only] = {\n ...column,\n props: { ...((column['props'] as Record<string, unknown> | undefined) ?? {}), size: 'xs:12' },\n sx: Object.keys(sx).length ? sx : null,\n }\n }\n }\n }\n return next as unknown as NodesMap\n}\n\n/**\n * A source of photos found for the slots themselves — a stock search copied\n * into the site's library — answering per slot, in order: a photo; or\n * {@link AI_LAYOUT_NO_PHOTO} where the library answered and nothing fits,\n * which leaves the slot without a photo; or `null` where the library could\n * not be asked, which takes a starter photo. It may throw, and then every\n * slot takes a starter.\n */\nexport type AiLayoutPictureSource = (\n slots: readonly AiLayoutPictureSlot[],\n) => Promise<ReadonlyArray<AiLayoutPicturePhoto | null>>\n\n/**\n * Fills a stored page's empty picture slots (AGL-3660): from `source` where\n * one is given and it answers; a slot it answers with nothing fitting stays\n * without a photo and is taken out ({@link aiLayoutDropEmptyPictures}). A\n * slot it could not answer — the library down, out of time, or its photo not\n * copied — takes one of the photos the job already placed on this site\n * (`jobPhotos`, {@link aiLayoutJobPhotoPicks}, AGL-3988), and only where the\n * job has none of its own, a starter photo described by its own words\n * (AGL-3831). Never throws, and never leaves a page worse than it came: a\n * picture is decoration, and a job never fails over one.\n */\nexport async function aiResolveLayoutPictures(\n nodes: NodesMap,\n input: {\n rootId: string\n sectionIds: readonly string[]\n sectionNames: readonly string[]\n /** A per-job word, so two sites do not open with the same photo. */\n seed: string\n source?: AiLayoutPictureSource | null\n /**\n * The photos this job already placed on this site (AGL-3988): its other\n * pages' and its datasets' records', each found for the site's world.\n * Taken before any starter where `source` could not fill a slot.\n */\n jobPhotos?: readonly AiLayoutPicturePhoto[]\n /** The site's language (AGL-3750); a starter photo's English words are not its own. */\n language?: string\n },\n): Promise<NodesMap> {\n try {\n const slots = aiLayoutPictureSlots(nodes, input.rootId, {\n ids: input.sectionIds,\n names: input.sectionNames,\n })\n if (!slots.length) return nodes\n let found: ReadonlyArray<AiLayoutPicturePhoto | null> = []\n if (input.source) {\n try {\n found = await input.source(slots)\n } catch (error) {\n console.warn('ai layout pictures: the stock source failed; the job’s own photos or starters fill the page', { error })\n found = []\n }\n }\n // The starters' words are English; a site in another language says it\n // shows an illustrative photo, true of any photo, as a stock photo's does.\n const otherLanguage = aiLayoutSpeaksOtherThanEnglish(input.language)\n const said = (photo: AiLayoutPicturePhoto): AiLayoutPicturePhoto =>\n otherLanguage ? { ...photo, alt: aiLayoutLabel('illustrativePhoto', input.language) } : photo\n /** The slots the source could not answer: no library, or it failed them. */\n const unanswered = slots.map((_slot, index) => !found[index])\n const photos: Array<AiLayoutPicturePhoto | null> = slots.map((_slot, index) => {\n const answer = found[index]\n return answer?.src ? answer : null\n })\n // With a library, the job's own photos come before any starter (AGL-3988),\n // and a starter is only ever a neutral one (AGL-3923): the beta.267\n // Brightvale start, whose library refused its copies, showed a pottery\n // bench and a coffee shop's owner as a marketer's pictures.\n const own = input.source ? (input.jobPhotos ?? []).filter((photo) => photo.src && photo.width > 0 && photo.height > 0) : []\n if (own.length) {\n aiLayoutJobPhotoPicks(slots, unanswered, own, photos, input.seed).forEach((pick, index) => {\n if (pick && unanswered[index]) photos[index] = pick\n })\n } else {\n const starters = input.source ? aiLayoutNeutralStarterPhotos(slots, input.seed) : aiLayoutStarterPhotos(slots, input.seed)\n starters.forEach((photo, index) => {\n if (photo && unanswered[index]) photos[index] = said(photo)\n })\n }\n // The page floor (AGL-3923; Zach, 2026-10-12: a starter photo before no\n // photo at all): a page the library answered that would show no picture\n // keeps one, in its hero, else its first slot: one of the job's own\n // photos where it has any (AGL-3988), else a neutral starter.\n if (input.source && !photos.some((photo) => photo?.src)) {\n const at = Math.max(0, slots.findIndex((slot) => slot.role === 'hero'))\n const lead = { ...(slots[at] as AiLayoutPictureSlot), product: undefined, people: undefined }\n const [pick] = aiLayoutJobPhotoPicks([lead], [true], own, [null], input.seed)\n const [floor] = rotate(NEUTRAL_STARTERS, aiLayoutSeedNumber(input.seed))\n const starter = floor ? AI_LAYOUT_STARTER_PHOTOS[floor] : null\n if (pick) photos[at] = pick\n else if (starter) photos[at] = said({ src: starter.src, width: starter.width, height: starter.height, alt: starter.alt })\n }\n return aiLayoutDropEmptyPictures(aiLayoutPlacePictures(nodes, slots, photos), slots, photos, input.sectionIds)\n } catch (error) {\n console.error('ai layout pictures: the page keeps its empty picture slots', { error })\n return nodes\n }\n}\n"],"names":["DEFAULT_SITE_IMAGES","aiLayoutLabel","aiLayoutSpeaksOtherThanEnglish","PEOPLE","ABOUT","aspectOf","value","byBreakpoint","breakpoint","ratio","match","exec","String","Number","isFinite","COVER_ASPECT","slotAspect","image","frame","own","sx","aiLayoutPictureRole","input","sectionIndex","test","sectionName","alt","aiLayoutPictureSlots","nodes","rootId","sections","map","slots","seen","Set","visit","id","parentId","node","has","add","index","ids","indexOf","here","componentId","src","props","trim","undefined","iconId","find","child","push","imageId","frameId","aspect","standIn","role","names","AI_LAYOUT_STARTER_PHOTOS","AI_LAYOUT_NO_PHOTO","Object","freeze","width","height","STARTER_POOLS","hero","about","gallery","ALL_STARTERS","keys","aiLayoutSeedNumber","seed","hash","length","charCodeAt","Math","imul","rotate","list","by","start","slice","aiLayoutStarterPhotos","turn","order","served","slot","sort","a","b","placedAt","Map","forEach","step","unused","pool","rest","filter","name","includes","candidates","people","candidate","beside","Boolean","get","set","photo","NEUTRAL_STARTERS","aiLayoutNeutralStarterRun","count","Array","from","max","_","aiLayoutNeutralStarterPhotos","product","photos","wordsOf","text","toLowerCase","split","word","aiLayoutJobPhotoPicks","need","jobPhotos","placed","picks","shown","_slot","says","best","at","entries","uses","shared","score","abs","log","rank","aiLayoutPlacePictures","next","lead","findIndex","intrinsicWidth","intrinsicHeight","loading","isGridRow","isGridColumn","aiLayoutDropEmptyPictures","sectionIds","empty","children","parentOf","key","remove","parent","frameHoldsOnly","every","column","only","size","aiResolveLayoutPictures","sectionNames","found","source","error","console","warn","otherLanguage","language","said","unanswered","answer","pick","starters","some","floor","starter"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,mBAAmB,QAAQ,sCAAqC;AAEzE,SAASC,aAAa,EAAEC,8BAA8B,QAAQ,wBAAoB;AA8GlF,uEAAuE,GACvE,MAAMC,SACJ;AAEF;;;;;;CAMC,GACD,MAAMC,QAAQ;AAEd;;;;;CAKC,GACD,SAASC,SAASC,KAAc;IAC9B,IAAIA,SAAS,OAAOA,UAAU,UAAU;QACtC,MAAMC,eAAeD;QACrB,KAAK,MAAME,cAAc;YAAC;YAAM;YAAM;YAAM;YAAM;SAAK,CAAE;YACvD,MAAMC,QAAQJ,SAASE,YAAY,CAACC,WAAW;YAC/C,IAAIC,UAAU,MAAM,OAAOA;QAC7B;QACA,OAAO;IACT;IACA,MAAMC,QAAQ,iDAAiDC,IAAI,CAACC,OAAON,gBAAAA,QAAS;IACpF,IAAI,CAACI,OAAO,OAAO;IACnB,MAAMD,QAAQI,OAAOH,KAAK,CAAC,EAAE,IAAIG,OAAOH,KAAK,CAAC,EAAE;IAChD,OAAOG,OAAOC,QAAQ,CAACL,UAAUA,QAAQ,IAAIA,QAAQ;AACvD;AAEA,gFAAgF,GAChF,MAAMM,eAAe,KAAK;AAE1B;;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ACmB;aAAK,EAAE;gBAAC;aAAK,EAAE7H,KAAK;gBAAC;aAAK,EAAEG,MAAMmD,IAAI;YAC5E,MAAM,CAAC0G,MAAM,GAAGpG,OAAO+B,kBAAkBtC,mBAAmBlD,MAAMmD,IAAI;YACtE,MAAM2G,UAAUD,QAAQvH,wBAAwB,CAACuH,MAAM,GAAG;YAC1D,IAAIH,MAAMzD,MAAM,CAACe,GAAG,GAAG0C;iBAClB,IAAII,SAAS7D,MAAM,CAACe,GAAG,GAAGuC,KAAK;gBAAE/H,KAAKsI,QAAQtI,GAAG;gBAAEkB,OAAOoH,QAAQpH,KAAK;gBAAEC,QAAQmH,QAAQnH,MAAM;gBAAEvC,KAAK0J,QAAQ1J,GAAG;YAAC;QACzH;QACA,OAAO6H,0BAA0BT,sBAAsBlH,OAAOI,OAAOuF,SAASvF,OAAOuF,QAAQjG,MAAMkI,UAAU;IAC/G,EAAE,OAAOgB,OAAO;QACdC,QAAQD,KAAK,CAAC,8DAA8D;YAAEA;QAAM;QACpF,OAAO5I;IACT;AACF"}
@@ -17,7 +17,7 @@
17
17
  import { type PluginAiCapability } from '@aglyn/aglyn/plugin-manager/plugin-ai-capabilities';
18
18
  import type { PluginDraftRecord } from '@aglyn/aglyn/plugin-manager/plugin-resource-drafts';
19
19
  import { type AiBuildItem, type AiBuildPlan, type AiBuildPlanCreate, type AiBuildPlanCreateKind, type AiBuildPlanScreen } from './ai-build-plan';
20
- import type { AiJobItemLedger } from './ai-jobs.types';
20
+ import type { AiJobInputField, AiJobItemLedger } from './ai-jobs.types';
21
21
  import { type AiCreditRange, type AiCreditsSmaller } from './ai-credit-estimate';
22
22
  /**
23
23
  * What a `build` job is (AGL-3616): one request — "a few pages, a contact
@@ -146,6 +146,21 @@ export declare function aiBuildPlanShapeRefusal(plan: AiBuildPlan, options?: {
146
146
  * the build answers with the question.
147
147
  */
148
148
  export declare function aiBuildPlanMissingInput(plan: AiBuildPlan, ops: AiBuildOps | null | undefined): string | null;
149
+ /**
150
+ * The code on the build's admission refusal for a plan only the person can
151
+ * complete (AGL-3978): the plan step keeps such a plan and waits in
152
+ * `needs_input` for the fields `aiBuildPlanInputFields` reads, where the
153
+ * operations describe them.
154
+ */
155
+ export declare const AI_BUILD_NEEDS_INPUT_CODE = "needs-input";
156
+ /**
157
+ * The fields the person fills before this plan can be built (AGL-3978), one
158
+ * per id an item asks for, as its operation describes them (`inputFields`).
159
+ * Empty when nothing asks, or when an item asks without fields to fill — a
160
+ * tracking change naming no tag at all — which the build answers with its
161
+ * question instead.
162
+ */
163
+ export declare function aiBuildPlanInputFields(plan: AiBuildPlan, ops: AiBuildOps | null | undefined): AiJobInputField[];
149
164
  /** "a booking service", "an email design". */
150
165
  export declare function aiArticle(noun: string): string;
151
166
  /**
@@ -323,6 +323,46 @@ import { AI_CREDIT_RANGE_ZERO, AI_MEASURED_PASS_CREDITS, aiCreditRangeAdd, aiCre
323
323
  }
324
324
  return questions.length ? questions.join(' ') : null;
325
325
  }
326
+ /**
327
+ * The code on the build's admission refusal for a plan only the person can
328
+ * complete (AGL-3978): the plan step keeps such a plan and waits in
329
+ * `needs_input` for the fields `aiBuildPlanInputFields` reads, where the
330
+ * operations describe them.
331
+ */ export const AI_BUILD_NEEDS_INPUT_CODE = 'needs-input';
332
+ /**
333
+ * The fields the person fills before this plan can be built (AGL-3978), one
334
+ * per id an item asks for, as its operation describes them (`inputFields`).
335
+ * Empty when nothing asks, or when an item asks without fields to fill — a
336
+ * tracking change naming no tag at all — which the build answers with its
337
+ * question instead.
338
+ */ export function aiBuildPlanInputFields(plan, ops) {
339
+ var _plan_items;
340
+ if (!ops) return [];
341
+ const fields = [];
342
+ for (const item of (_plan_items = plan.items) != null ? _plan_items : []){
343
+ var _ref;
344
+ var _capability_missingInput;
345
+ const capability = ops.get(item.op);
346
+ const one = {
347
+ name: item.name,
348
+ why: item.why,
349
+ args: item.args
350
+ };
351
+ if (!(capability == null ? void 0 : (_capability_missingInput = capability.missingInput) == null ? void 0 : _capability_missingInput.call(capability, one))) continue;
352
+ const asked = (_ref = capability.inputFields == null ? void 0 : capability.inputFields.call(capability, one)) != null ? _ref : [];
353
+ if (!asked.length) return [];
354
+ for (const field of asked){
355
+ fields.push({
356
+ item: item.name,
357
+ arg: field.arg,
358
+ label: field.label,
359
+ shape: field.shape,
360
+ pattern: field.pattern.source
361
+ });
362
+ }
363
+ }
364
+ return fields;
365
+ }
326
366
  /** "a booking service", "an email design". */ export function aiArticle(noun) {
327
367
  return `${/^[aeiou]/i.test(noun) ? 'an' : 'a'} ${noun}`;
328
368
  }