@aglyn/plugins-ai 1.0.0-beta.143

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 (717) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +25 -0
  3. package/package.json +60 -0
  4. package/src/index.d.ts +21 -0
  5. package/src/index.js +22 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/activity/ai-activity-actions.d.ts +106 -0
  8. package/src/lib/activity/ai-activity-actions.js +209 -0
  9. package/src/lib/activity/ai-activity-actions.js.map +1 -0
  10. package/src/lib/activity/ai-activity.d.ts +219 -0
  11. package/src/lib/activity/ai-activity.js +251 -0
  12. package/src/lib/activity/ai-activity.js.map +1 -0
  13. package/src/lib/billing/ai-overage-charge.d.ts +102 -0
  14. package/src/lib/billing/ai-overage-charge.js +258 -0
  15. package/src/lib/billing/ai-overage-charge.js.map +1 -0
  16. package/src/lib/billing/ai-overage-close.d.ts +62 -0
  17. package/src/lib/billing/ai-overage-close.js +129 -0
  18. package/src/lib/billing/ai-overage-close.js.map +1 -0
  19. package/src/lib/billing/ai-overage-cutover.d.ts +63 -0
  20. package/src/lib/billing/ai-overage-cutover.js +114 -0
  21. package/src/lib/billing/ai-overage-cutover.js.map +1 -0
  22. package/src/lib/billing/ai-overage-events.d.ts +77 -0
  23. package/src/lib/billing/ai-overage-events.js +174 -0
  24. package/src/lib/billing/ai-overage-events.js.map +1 -0
  25. package/src/lib/billing/ai-overage-gate.d.ts +147 -0
  26. package/src/lib/billing/ai-overage-gate.js +177 -0
  27. package/src/lib/billing/ai-overage-gate.js.map +1 -0
  28. package/src/lib/billing/ai-overage-ledger.d.ts +135 -0
  29. package/src/lib/billing/ai-overage-ledger.js +278 -0
  30. package/src/lib/billing/ai-overage-ledger.js.map +1 -0
  31. package/src/lib/billing/ai-overage-standing-writes.d.ts +110 -0
  32. package/src/lib/billing/ai-overage-standing-writes.js +205 -0
  33. package/src/lib/billing/ai-overage-standing-writes.js.map +1 -0
  34. package/src/lib/billing/ai-overage-standing.d.ts +168 -0
  35. package/src/lib/billing/ai-overage-standing.js +215 -0
  36. package/src/lib/billing/ai-overage-standing.js.map +1 -0
  37. package/src/lib/billing/ai-overage-trigger.d.ts +30 -0
  38. package/src/lib/billing/ai-overage-trigger.js +76 -0
  39. package/src/lib/billing/ai-overage-trigger.js.map +1 -0
  40. package/src/lib/components/ai-allotment-editor.component.d.ts +40 -0
  41. package/src/lib/components/ai-allotment-editor.component.js +213 -0
  42. package/src/lib/components/ai-allotment-editor.component.js.map +1 -0
  43. package/src/lib/components/ai-assist-actions-context.d.ts +13 -0
  44. package/src/lib/components/ai-assist-actions-context.js +21 -0
  45. package/src/lib/components/ai-assist-actions-context.js.map +1 -0
  46. package/src/lib/components/ai-assist-provider.component.d.ts +51 -0
  47. package/src/lib/components/ai-assist-provider.component.js +519 -0
  48. package/src/lib/components/ai-assist-provider.component.js.map +1 -0
  49. package/src/lib/components/ai-brief-dialog.component.d.ts +56 -0
  50. package/src/lib/components/ai-brief-dialog.component.js +319 -0
  51. package/src/lib/components/ai-brief-dialog.component.js.map +1 -0
  52. package/src/lib/components/ai-collaborator-permissions-column.component.d.ts +32 -0
  53. package/src/lib/components/ai-collaborator-permissions-column.component.js +132 -0
  54. package/src/lib/components/ai-collaborator-permissions-column.component.js.map +1 -0
  55. package/src/lib/components/ai-credits-card.component.d.ts +34 -0
  56. package/src/lib/components/ai-credits-card.component.js +131 -0
  57. package/src/lib/components/ai-credits-card.component.js.map +1 -0
  58. package/src/lib/components/ai-credits-columns.component.d.ts +56 -0
  59. package/src/lib/components/ai-credits-columns.component.js +118 -0
  60. package/src/lib/components/ai-credits-columns.component.js.map +1 -0
  61. package/src/lib/components/ai-crm-email-draft.component.d.ts +17 -0
  62. package/src/lib/components/ai-crm-email-draft.component.js +159 -0
  63. package/src/lib/components/ai-crm-email-draft.component.js.map +1 -0
  64. package/src/lib/components/ai-crm-import-mapping.component.d.ts +20 -0
  65. package/src/lib/components/ai-crm-import-mapping.component.js +167 -0
  66. package/src/lib/components/ai-crm-import-mapping.component.js.map +1 -0
  67. package/src/lib/components/ai-crm-record-card.component.d.ts +27 -0
  68. package/src/lib/components/ai-crm-record-card.component.js +263 -0
  69. package/src/lib/components/ai-crm-record-card.component.js.map +1 -0
  70. package/src/lib/components/ai-describe-automation.component.d.ts +31 -0
  71. package/src/lib/components/ai-describe-automation.component.js +226 -0
  72. package/src/lib/components/ai-describe-automation.component.js.map +1 -0
  73. package/src/lib/components/ai-describe-button.component.d.ts +39 -0
  74. package/src/lib/components/ai-describe-button.component.js +87 -0
  75. package/src/lib/components/ai-describe-button.component.js.map +1 -0
  76. package/src/lib/components/ai-describe-page.component.d.ts +26 -0
  77. package/src/lib/components/ai-describe-page.component.js +18 -0
  78. package/src/lib/components/ai-describe-page.component.js.map +1 -0
  79. package/src/lib/components/ai-experiment-cards.component.d.ts +75 -0
  80. package/src/lib/components/ai-experiment-cards.component.js +573 -0
  81. package/src/lib/components/ai-experiment-cards.component.js.map +1 -0
  82. package/src/lib/components/ai-explain-automation.component.d.ts +31 -0
  83. package/src/lib/components/ai-explain-automation.component.js +265 -0
  84. package/src/lib/components/ai-explain-automation.component.js.map +1 -0
  85. package/src/lib/components/ai-insight-dialog.component.d.ts +37 -0
  86. package/src/lib/components/ai-insight-dialog.component.js +441 -0
  87. package/src/lib/components/ai-insight-dialog.component.js.map +1 -0
  88. package/src/lib/components/ai-job-plan.component.d.ts +46 -0
  89. package/src/lib/components/ai-job-plan.component.js +192 -0
  90. package/src/lib/components/ai-job-plan.component.js.map +1 -0
  91. package/src/lib/components/ai-model-selector.component.d.ts +21 -0
  92. package/src/lib/components/ai-model-selector.component.js +109 -0
  93. package/src/lib/components/ai-model-selector.component.js.map +1 -0
  94. package/src/lib/components/ai-page-brief-dialog.component.d.ts +29 -0
  95. package/src/lib/components/ai-page-brief-dialog.component.js +27 -0
  96. package/src/lib/components/ai-page-brief-dialog.component.js.map +1 -0
  97. package/src/lib/components/ai-permissions-on-host.component.d.ts +55 -0
  98. package/src/lib/components/ai-permissions-on-host.component.js +91 -0
  99. package/src/lib/components/ai-permissions-on-host.component.js.map +1 -0
  100. package/src/lib/components/ai-product-copy-card.component.d.ts +25 -0
  101. package/src/lib/components/ai-product-copy-card.component.js +328 -0
  102. package/src/lib/components/ai-product-copy-card.component.js.map +1 -0
  103. package/src/lib/components/ai-product-import-option.component.d.ts +14 -0
  104. package/src/lib/components/ai-product-import-option.component.js +58 -0
  105. package/src/lib/components/ai-product-import-option.component.js.map +1 -0
  106. package/src/lib/components/ai-products-hub-card.component.d.ts +15 -0
  107. package/src/lib/components/ai-products-hub-card.component.js +418 -0
  108. package/src/lib/components/ai-products-hub-card.component.js.map +1 -0
  109. package/src/lib/components/ai-products-proposals.component.d.ts +19 -0
  110. package/src/lib/components/ai-products-proposals.component.js +547 -0
  111. package/src/lib/components/ai-products-proposals.component.js.map +1 -0
  112. package/src/lib/components/ai-save-as-component.component.d.ts +38 -0
  113. package/src/lib/components/ai-save-as-component.component.js +231 -0
  114. package/src/lib/components/ai-save-as-component.component.js.map +1 -0
  115. package/src/lib/components/ai-seo-audit-card.component.d.ts +9 -0
  116. package/src/lib/components/ai-seo-audit-card.component.js +620 -0
  117. package/src/lib/components/ai-seo-audit-card.component.js.map +1 -0
  118. package/src/lib/components/ai-seo-fields-card.component.d.ts +10 -0
  119. package/src/lib/components/ai-seo-fields-card.component.js +453 -0
  120. package/src/lib/components/ai-seo-fields-card.component.js.map +1 -0
  121. package/src/lib/components/ai-site-batch-card.component.d.ts +32 -0
  122. package/src/lib/components/ai-site-batch-card.component.js +531 -0
  123. package/src/lib/components/ai-site-batch-card.component.js.map +1 -0
  124. package/src/lib/components/ai-site-seo-start-card.component.d.ts +26 -0
  125. package/src/lib/components/ai-site-seo-start-card.component.js +178 -0
  126. package/src/lib/components/ai-site-seo-start-card.component.js.map +1 -0
  127. package/src/lib/components/ai-site-start-card.component.d.ts +19 -0
  128. package/src/lib/components/ai-site-start-card.component.js +348 -0
  129. package/src/lib/components/ai-site-start-card.component.js.map +1 -0
  130. package/src/lib/components/ai-template-collection-field.component.d.ts +32 -0
  131. package/src/lib/components/ai-template-collection-field.component.js +63 -0
  132. package/src/lib/components/ai-template-collection-field.component.js.map +1 -0
  133. package/src/lib/components/ai-theme-proposal-card.component.d.ts +6 -0
  134. package/src/lib/components/ai-theme-proposal-card.component.js +619 -0
  135. package/src/lib/components/ai-theme-proposal-card.component.js.map +1 -0
  136. package/src/lib/components/ai-usage-strip.component.d.ts +27 -0
  137. package/src/lib/components/ai-usage-strip.component.js +145 -0
  138. package/src/lib/components/ai-usage-strip.component.js.map +1 -0
  139. package/src/lib/components/assist-edit-canvas.d.ts +169 -0
  140. package/src/lib/components/assist-edit-canvas.js +636 -0
  141. package/src/lib/components/assist-edit-canvas.js.map +1 -0
  142. package/src/lib/components/assist-edit-card.component.d.ts +16 -0
  143. package/src/lib/components/assist-edit-card.component.js +181 -0
  144. package/src/lib/components/assist-edit-card.component.js.map +1 -0
  145. package/src/lib/components/assist-jobs-drawer.component.d.ts +72 -0
  146. package/src/lib/components/assist-jobs-drawer.component.js +626 -0
  147. package/src/lib/components/assist-jobs-drawer.component.js.map +1 -0
  148. package/src/lib/components/assist-panel.component.d.ts +136 -0
  149. package/src/lib/components/assist-panel.component.js +1099 -0
  150. package/src/lib/components/assist-panel.component.js.map +1 -0
  151. package/src/lib/components/assist-signals-page.component.d.ts +3 -0
  152. package/src/lib/components/assist-signals-page.component.js +1017 -0
  153. package/src/lib/components/assist-signals-page.component.js.map +1 -0
  154. package/src/lib/components/besigner-ai-controls.component.d.ts +29 -0
  155. package/src/lib/components/besigner-ai-controls.component.js +81 -0
  156. package/src/lib/components/besigner-ai-controls.component.js.map +1 -0
  157. package/src/lib/components/billing-ai-allotments.component.d.ts +36 -0
  158. package/src/lib/components/billing-ai-allotments.component.js +486 -0
  159. package/src/lib/components/billing-ai-allotments.component.js.map +1 -0
  160. package/src/lib/components/billing-ai-top-users.component.d.ts +44 -0
  161. package/src/lib/components/billing-ai-top-users.component.js +304 -0
  162. package/src/lib/components/billing-ai-top-users.component.js.map +1 -0
  163. package/src/lib/components/billing-assist-overage-card.component.d.ts +69 -0
  164. package/src/lib/components/billing-assist-overage-card.component.js +437 -0
  165. package/src/lib/components/billing-assist-overage-card.component.js.map +1 -0
  166. package/src/lib/components/host-ai-allotments.component.d.ts +40 -0
  167. package/src/lib/components/host-ai-allotments.component.js +239 -0
  168. package/src/lib/components/host-ai-allotments.component.js.map +1 -0
  169. package/src/lib/components/member-ai-allotment-card.component.d.ts +28 -0
  170. package/src/lib/components/member-ai-allotment-card.component.js +172 -0
  171. package/src/lib/components/member-ai-allotment-card.component.js.map +1 -0
  172. package/src/lib/components/member-ai-usage-card.component.d.ts +28 -0
  173. package/src/lib/components/member-ai-usage-card.component.js +240 -0
  174. package/src/lib/components/member-ai-usage-card.component.js.map +1 -0
  175. package/src/lib/components/staff-org-ai-card.component.d.ts +17 -0
  176. package/src/lib/components/staff-org-ai-card.component.js +739 -0
  177. package/src/lib/components/staff-org-ai-card.component.js.map +1 -0
  178. package/src/lib/components/staff-org-usage-ai-columns.component.d.ts +41 -0
  179. package/src/lib/components/staff-org-usage-ai-columns.component.js +65 -0
  180. package/src/lib/components/staff-org-usage-ai-columns.component.js.map +1 -0
  181. package/src/lib/components/staff-orgs-ai-spend-column.component.d.ts +28 -0
  182. package/src/lib/components/staff-orgs-ai-spend-column.component.js +89 -0
  183. package/src/lib/components/staff-orgs-ai-spend-column.component.js.map +1 -0
  184. package/src/lib/components/staff-user-ai-usage-card.component.d.ts +27 -0
  185. package/src/lib/components/staff-user-ai-usage-card.component.js +183 -0
  186. package/src/lib/components/staff-user-ai-usage-card.component.js.map +1 -0
  187. package/src/lib/components/use-ai-allotments.d.ts +49 -0
  188. package/src/lib/components/use-ai-allotments.js +171 -0
  189. package/src/lib/components/use-ai-allotments.js.map +1 -0
  190. package/src/lib/components/use-ai-crm-answer.d.ts +50 -0
  191. package/src/lib/components/use-ai-crm-answer.js +220 -0
  192. package/src/lib/components/use-ai-crm-answer.js.map +1 -0
  193. package/src/lib/components/use-ai-job-run.d.ts +51 -0
  194. package/src/lib/components/use-ai-job-run.js +176 -0
  195. package/src/lib/components/use-ai-job-run.js.map +1 -0
  196. package/src/lib/components/use-ai-model-choice.d.ts +47 -0
  197. package/src/lib/components/use-ai-model-choice.js +150 -0
  198. package/src/lib/components/use-ai-model-choice.js.map +1 -0
  199. package/src/lib/components/use-ai-products-jobs.d.ts +36 -0
  200. package/src/lib/components/use-ai-products-jobs.js +190 -0
  201. package/src/lib/components/use-ai-products-jobs.js.map +1 -0
  202. package/src/lib/components/use-ai-usage-meter.d.ts +11 -0
  203. package/src/lib/components/use-ai-usage-meter.js +96 -0
  204. package/src/lib/components/use-ai-usage-meter.js.map +1 -0
  205. package/src/lib/components/use-org-ai-usage.d.ts +42 -0
  206. package/src/lib/components/use-org-ai-usage.js +181 -0
  207. package/src/lib/components/use-org-ai-usage.js.map +1 -0
  208. package/src/lib/components/use-staff-orgs-ai-spend.d.ts +18 -0
  209. package/src/lib/components/use-staff-orgs-ai-spend.js +127 -0
  210. package/src/lib/components/use-staff-orgs-ai-spend.js.map +1 -0
  211. package/src/lib/constants.d.ts +24 -0
  212. package/src/lib/constants.js +23 -0
  213. package/src/lib/constants.js.map +1 -0
  214. package/src/lib/declarations.d.ts +48 -0
  215. package/src/lib/declarations.js +129 -0
  216. package/src/lib/declarations.js.map +1 -0
  217. package/src/lib/declarations.server.d.ts +35 -0
  218. package/src/lib/declarations.server.js +138 -0
  219. package/src/lib/declarations.server.js.map +1 -0
  220. package/src/lib/insights/ai-figure-readers.d.ts +90 -0
  221. package/src/lib/insights/ai-figure-readers.js +863 -0
  222. package/src/lib/insights/ai-figure-readers.js.map +1 -0
  223. package/src/lib/insights/ai-insight-digest.d.ts +165 -0
  224. package/src/lib/insights/ai-insight-digest.js +363 -0
  225. package/src/lib/insights/ai-insight-digest.js.map +1 -0
  226. package/src/lib/insights/ai-insight-readers.d.ts +71 -0
  227. package/src/lib/insights/ai-insight-readers.js +141 -0
  228. package/src/lib/insights/ai-insight-readers.js.map +1 -0
  229. package/src/lib/jobs/ai-crm-access.d.ts +61 -0
  230. package/src/lib/jobs/ai-crm-access.js +94 -0
  231. package/src/lib/jobs/ai-crm-access.js.map +1 -0
  232. package/src/lib/jobs/ai-email-bindings.d.ts +97 -0
  233. package/src/lib/jobs/ai-email-bindings.js +147 -0
  234. package/src/lib/jobs/ai-email-bindings.js.map +1 -0
  235. package/src/lib/jobs/ai-job-admission.d.ts +82 -0
  236. package/src/lib/jobs/ai-job-admission.js +45 -0
  237. package/src/lib/jobs/ai-job-admission.js.map +1 -0
  238. package/src/lib/jobs/ai-job-budget.d.ts +167 -0
  239. package/src/lib/jobs/ai-job-budget.js +161 -0
  240. package/src/lib/jobs/ai-job-budget.js.map +1 -0
  241. package/src/lib/jobs/ai-job-campaign-step.d.ts +108 -0
  242. package/src/lib/jobs/ai-job-campaign-step.js +340 -0
  243. package/src/lib/jobs/ai-job-campaign-step.js.map +1 -0
  244. package/src/lib/jobs/ai-job-component-checks.d.ts +74 -0
  245. package/src/lib/jobs/ai-job-component-checks.js +442 -0
  246. package/src/lib/jobs/ai-job-component-checks.js.map +1 -0
  247. package/src/lib/jobs/ai-job-component-step.d.ts +75 -0
  248. package/src/lib/jobs/ai-job-component-step.js +262 -0
  249. package/src/lib/jobs/ai-job-component-step.js.map +1 -0
  250. package/src/lib/jobs/ai-job-crm-step.d.ts +192 -0
  251. package/src/lib/jobs/ai-job-crm-step.js +734 -0
  252. package/src/lib/jobs/ai-job-crm-step.js.map +1 -0
  253. package/src/lib/jobs/ai-job-draft-ids.d.ts +62 -0
  254. package/src/lib/jobs/ai-job-draft-ids.js +132 -0
  255. package/src/lib/jobs/ai-job-draft-ids.js.map +1 -0
  256. package/src/lib/jobs/ai-job-drafts.d.ts +304 -0
  257. package/src/lib/jobs/ai-job-drafts.js +557 -0
  258. package/src/lib/jobs/ai-job-drafts.js.map +1 -0
  259. package/src/lib/jobs/ai-job-email-step.d.ts +195 -0
  260. package/src/lib/jobs/ai-job-email-step.js +547 -0
  261. package/src/lib/jobs/ai-job-email-step.js.map +1 -0
  262. package/src/lib/jobs/ai-job-experiment-step.d.ts +105 -0
  263. package/src/lib/jobs/ai-job-experiment-step.js +445 -0
  264. package/src/lib/jobs/ai-job-experiment-step.js.map +1 -0
  265. package/src/lib/jobs/ai-job-form-step.d.ts +250 -0
  266. package/src/lib/jobs/ai-job-form-step.js +634 -0
  267. package/src/lib/jobs/ai-job-form-step.js.map +1 -0
  268. package/src/lib/jobs/ai-job-generation.d.ts +114 -0
  269. package/src/lib/jobs/ai-job-generation.js +384 -0
  270. package/src/lib/jobs/ai-job-generation.js.map +1 -0
  271. package/src/lib/jobs/ai-job-insight-budget.d.ts +41 -0
  272. package/src/lib/jobs/ai-job-insight-budget.js +46 -0
  273. package/src/lib/jobs/ai-job-insight-budget.js.map +1 -0
  274. package/src/lib/jobs/ai-job-insight-step.d.ts +58 -0
  275. package/src/lib/jobs/ai-job-insight-step.js +350 -0
  276. package/src/lib/jobs/ai-job-insight-step.js.map +1 -0
  277. package/src/lib/jobs/ai-job-layout-step.d.ts +103 -0
  278. package/src/lib/jobs/ai-job-layout-step.js +340 -0
  279. package/src/lib/jobs/ai-job-layout-step.js.map +1 -0
  280. package/src/lib/jobs/ai-job-page-budget.d.ts +57 -0
  281. package/src/lib/jobs/ai-job-page-budget.js +60 -0
  282. package/src/lib/jobs/ai-job-page-budget.js.map +1 -0
  283. package/src/lib/jobs/ai-job-page-sections.d.ts +150 -0
  284. package/src/lib/jobs/ai-job-page-sections.js +450 -0
  285. package/src/lib/jobs/ai-job-page-sections.js.map +1 -0
  286. package/src/lib/jobs/ai-job-page-step.d.ts +198 -0
  287. package/src/lib/jobs/ai-job-page-step.js +667 -0
  288. package/src/lib/jobs/ai-job-page-step.js.map +1 -0
  289. package/src/lib/jobs/ai-job-plan-conformance.d.ts +107 -0
  290. package/src/lib/jobs/ai-job-plan-conformance.js +164 -0
  291. package/src/lib/jobs/ai-job-plan-conformance.js.map +1 -0
  292. package/src/lib/jobs/ai-job-plan-step.d.ts +196 -0
  293. package/src/lib/jobs/ai-job-plan-step.js +458 -0
  294. package/src/lib/jobs/ai-job-plan-step.js.map +1 -0
  295. package/src/lib/jobs/ai-job-plugin-drafts.d.ts +76 -0
  296. package/src/lib/jobs/ai-job-plugin-drafts.js +91 -0
  297. package/src/lib/jobs/ai-job-plugin-drafts.js.map +1 -0
  298. package/src/lib/jobs/ai-job-products-step.d.ts +106 -0
  299. package/src/lib/jobs/ai-job-products-step.js +436 -0
  300. package/src/lib/jobs/ai-job-products-step.js.map +1 -0
  301. package/src/lib/jobs/ai-job-seo-budget.d.ts +52 -0
  302. package/src/lib/jobs/ai-job-seo-budget.js +63 -0
  303. package/src/lib/jobs/ai-job-seo-budget.js.map +1 -0
  304. package/src/lib/jobs/ai-job-seo-step.d.ts +145 -0
  305. package/src/lib/jobs/ai-job-seo-step.js +809 -0
  306. package/src/lib/jobs/ai-job-seo-step.js.map +1 -0
  307. package/src/lib/jobs/ai-job-site-step.d.ts +252 -0
  308. package/src/lib/jobs/ai-job-site-step.js +538 -0
  309. package/src/lib/jobs/ai-job-site-step.js.map +1 -0
  310. package/src/lib/jobs/ai-job-template-step.d.ts +105 -0
  311. package/src/lib/jobs/ai-job-template-step.js +391 -0
  312. package/src/lib/jobs/ai-job-template-step.js.map +1 -0
  313. package/src/lib/jobs/ai-job-text-step.d.ts +125 -0
  314. package/src/lib/jobs/ai-job-text-step.js +128 -0
  315. package/src/lib/jobs/ai-job-text-step.js.map +1 -0
  316. package/src/lib/jobs/ai-job-theme-budget.d.ts +38 -0
  317. package/src/lib/jobs/ai-job-theme-budget.js +43 -0
  318. package/src/lib/jobs/ai-job-theme-budget.js.map +1 -0
  319. package/src/lib/jobs/ai-job-theme-step.d.ts +115 -0
  320. package/src/lib/jobs/ai-job-theme-step.js +337 -0
  321. package/src/lib/jobs/ai-job-theme-step.js.map +1 -0
  322. package/src/lib/jobs/ai-job-workflow-step.d.ts +139 -0
  323. package/src/lib/jobs/ai-job-workflow-step.js +530 -0
  324. package/src/lib/jobs/ai-job-workflow-step.js.map +1 -0
  325. package/src/lib/jobs/ai-jobs-beat.d.ts +78 -0
  326. package/src/lib/jobs/ai-jobs-beat.js +93 -0
  327. package/src/lib/jobs/ai-jobs-beat.js.map +1 -0
  328. package/src/lib/jobs/ai-jobs-pause.d.ts +38 -0
  329. package/src/lib/jobs/ai-jobs-pause.js +45 -0
  330. package/src/lib/jobs/ai-jobs-pause.js.map +1 -0
  331. package/src/lib/jobs/ai-jobs.d.ts +558 -0
  332. package/src/lib/jobs/ai-jobs.js +1410 -0
  333. package/src/lib/jobs/ai-jobs.js.map +1 -0
  334. package/src/lib/jobs/ai-media-asset-server.d.ts +34 -0
  335. package/src/lib/jobs/ai-media-asset-server.js +34 -0
  336. package/src/lib/jobs/ai-media-asset-server.js.map +1 -0
  337. package/src/lib/jobs/ai-media-asset.d.ts +59 -0
  338. package/src/lib/jobs/ai-media-asset.js +86 -0
  339. package/src/lib/jobs/ai-media-asset.js.map +1 -0
  340. package/src/lib/jobs/ai-product-image.d.ts +78 -0
  341. package/src/lib/jobs/ai-product-image.js +113 -0
  342. package/src/lib/jobs/ai-product-image.js.map +1 -0
  343. package/src/lib/jobs/ai-theme-brand-inputs.d.ts +125 -0
  344. package/src/lib/jobs/ai-theme-brand-inputs.js +378 -0
  345. package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -0
  346. package/src/lib/jobs/ai-theme-brand-server.d.ts +33 -0
  347. package/src/lib/jobs/ai-theme-brand-server.js +33 -0
  348. package/src/lib/jobs/ai-theme-brand-server.js.map +1 -0
  349. package/src/lib/jobs/ai-workflow-records.d.ts +84 -0
  350. package/src/lib/jobs/ai-workflow-records.js +158 -0
  351. package/src/lib/jobs/ai-workflow-records.js.map +1 -0
  352. package/src/lib/jobs/fixtures/ai-free-page-built-recording.d.ts +31 -0
  353. package/src/lib/jobs/fixtures/ai-free-page-built-recording.js +367 -0
  354. package/src/lib/jobs/fixtures/ai-free-page-built-recording.js.map +1 -0
  355. package/src/lib/jobs/fixtures/ai-free-page-recording.d.ts +69 -0
  356. package/src/lib/jobs/fixtures/ai-free-page-recording.js +442 -0
  357. package/src/lib/jobs/fixtures/ai-free-page-recording.js.map +1 -0
  358. package/src/lib/jobs/fixtures/ai-page-briefs.d.ts +146 -0
  359. package/src/lib/jobs/fixtures/ai-page-briefs.js +1850 -0
  360. package/src/lib/jobs/fixtures/ai-page-briefs.js.map +1 -0
  361. package/src/lib/model/ai-allotments.d.ts +208 -0
  362. package/src/lib/model/ai-allotments.js +269 -0
  363. package/src/lib/model/ai-allotments.js.map +1 -0
  364. package/src/lib/model/ai-automation-draft.d.ts +74 -0
  365. package/src/lib/model/ai-automation-draft.js +310 -0
  366. package/src/lib/model/ai-automation-draft.js.map +1 -0
  367. package/src/lib/model/ai-automation-outline.d.ts +50 -0
  368. package/src/lib/model/ai-automation-outline.js +262 -0
  369. package/src/lib/model/ai-automation-outline.js.map +1 -0
  370. package/src/lib/model/ai-build-plan.d.ts +197 -0
  371. package/src/lib/model/ai-build-plan.js +438 -0
  372. package/src/lib/model/ai-build-plan.js.map +1 -0
  373. package/src/lib/model/ai-crm.d.ts +237 -0
  374. package/src/lib/model/ai-crm.js +225 -0
  375. package/src/lib/model/ai-crm.js.map +1 -0
  376. package/src/lib/model/ai-experiment-proposal.d.ts +68 -0
  377. package/src/lib/model/ai-experiment-proposal.js +146 -0
  378. package/src/lib/model/ai-experiment-proposal.js.map +1 -0
  379. package/src/lib/model/ai-experiment.d.ts +309 -0
  380. package/src/lib/model/ai-experiment.js +395 -0
  381. package/src/lib/model/ai-experiment.js.map +1 -0
  382. package/src/lib/model/ai-insight.d.ts +178 -0
  383. package/src/lib/model/ai-insight.js +201 -0
  384. package/src/lib/model/ai-insight.js.map +1 -0
  385. package/src/lib/model/ai-jobs.types.d.ts +412 -0
  386. package/src/lib/model/ai-jobs.types.js +42 -0
  387. package/src/lib/model/ai-jobs.types.js.map +1 -0
  388. package/src/lib/model/ai-page-job.d.ts +92 -0
  389. package/src/lib/model/ai-page-job.js +159 -0
  390. package/src/lib/model/ai-page-job.js.map +1 -0
  391. package/src/lib/model/ai-permissions.d.ts +49 -0
  392. package/src/lib/model/ai-permissions.js +97 -0
  393. package/src/lib/model/ai-permissions.js.map +1 -0
  394. package/src/lib/model/ai-plan-capabilities.d.ts +139 -0
  395. package/src/lib/model/ai-plan-capabilities.js +149 -0
  396. package/src/lib/model/ai-plan-capabilities.js.map +1 -0
  397. package/src/lib/model/ai-products.d.ts +251 -0
  398. package/src/lib/model/ai-products.js +253 -0
  399. package/src/lib/model/ai-products.js.map +1 -0
  400. package/src/lib/model/ai-seo.d.ts +208 -0
  401. package/src/lib/model/ai-seo.js +150 -0
  402. package/src/lib/model/ai-seo.js.map +1 -0
  403. package/src/lib/model/ai-site-inventory.d.ts +164 -0
  404. package/src/lib/model/ai-site-inventory.js +145 -0
  405. package/src/lib/model/ai-site-inventory.js.map +1 -0
  406. package/src/lib/model/ai-site-job.d.ts +247 -0
  407. package/src/lib/model/ai-site-job.js +314 -0
  408. package/src/lib/model/ai-site-job.js.map +1 -0
  409. package/src/lib/model/ai-site-start-seo.d.ts +103 -0
  410. package/src/lib/model/ai-site-start-seo.js +154 -0
  411. package/src/lib/model/ai-site-start-seo.js.map +1 -0
  412. package/src/lib/model/ai-site-start.d.ts +122 -0
  413. package/src/lib/model/ai-site-start.js +159 -0
  414. package/src/lib/model/ai-site-start.js.map +1 -0
  415. package/src/lib/model/ai-site-switch.d.ts +56 -0
  416. package/src/lib/model/ai-site-switch.js +73 -0
  417. package/src/lib/model/ai-site-switch.js.map +1 -0
  418. package/src/lib/model/ai-storefront-claims.d.ts +70 -0
  419. package/src/lib/model/ai-storefront-claims.js +130 -0
  420. package/src/lib/model/ai-storefront-claims.js.map +1 -0
  421. package/src/lib/model/ai-template-subjects.d.ts +82 -0
  422. package/src/lib/model/ai-template-subjects.js +136 -0
  423. package/src/lib/model/ai-template-subjects.js.map +1 -0
  424. package/src/lib/model/ai-theme-proposal.d.ts +210 -0
  425. package/src/lib/model/ai-theme-proposal.js +506 -0
  426. package/src/lib/model/ai-theme-proposal.js.map +1 -0
  427. package/src/lib/model/ai-tokens.d.ts +96 -0
  428. package/src/lib/model/ai-tokens.js +117 -0
  429. package/src/lib/model/ai-tokens.js.map +1 -0
  430. package/src/lib/model/ai-usage-by-user.d.ts +120 -0
  431. package/src/lib/model/ai-usage-by-user.js +139 -0
  432. package/src/lib/model/ai-usage-by-user.js.map +1 -0
  433. package/src/lib/model/ai-workflow-job.d.ts +111 -0
  434. package/src/lib/model/ai-workflow-job.js +183 -0
  435. package/src/lib/model/ai-workflow-job.js.map +1 -0
  436. package/src/lib/model/assist-edit.d.ts +261 -0
  437. package/src/lib/model/assist-edit.js +175 -0
  438. package/src/lib/model/assist-edit.js.map +1 -0
  439. package/src/lib/plugin-config.d.ts +33 -0
  440. package/src/lib/plugin-config.js +118 -0
  441. package/src/lib/plugin-config.js.map +1 -0
  442. package/src/lib/plugin.d.ts +30 -0
  443. package/src/lib/plugin.js +525 -0
  444. package/src/lib/plugin.js.map +1 -0
  445. package/src/lib/providers/anthropic.d.ts +84 -0
  446. package/src/lib/providers/anthropic.js +432 -0
  447. package/src/lib/providers/anthropic.js.map +1 -0
  448. package/src/lib/providers/catalog.d.ts +197 -0
  449. package/src/lib/providers/catalog.js +312 -0
  450. package/src/lib/providers/catalog.js.map +1 -0
  451. package/src/lib/providers/contract.d.ts +464 -0
  452. package/src/lib/providers/contract.js +274 -0
  453. package/src/lib/providers/contract.js.map +1 -0
  454. package/src/lib/providers/model-choice.d.ts +119 -0
  455. package/src/lib/providers/model-choice.js +416 -0
  456. package/src/lib/providers/model-choice.js.map +1 -0
  457. package/src/lib/providers/openai-compatible.d.ts +58 -0
  458. package/src/lib/providers/openai-compatible.js +361 -0
  459. package/src/lib/providers/openai-compatible.js.map +1 -0
  460. package/src/lib/providers/registry.d.ts +49 -0
  461. package/src/lib/providers/registry.js +71 -0
  462. package/src/lib/providers/registry.js.map +1 -0
  463. package/src/lib/providers/routing.d.ts +98 -0
  464. package/src/lib/providers/routing.js +450 -0
  465. package/src/lib/providers/routing.js.map +1 -0
  466. package/src/lib/runtime/ai-abuse-guards.d.ts +113 -0
  467. package/src/lib/runtime/ai-abuse-guards.js +148 -0
  468. package/src/lib/runtime/ai-abuse-guards.js.map +1 -0
  469. package/src/lib/runtime/ai-component-bindings.d.ts +67 -0
  470. package/src/lib/runtime/ai-component-bindings.js +106 -0
  471. package/src/lib/runtime/ai-component-bindings.js.map +1 -0
  472. package/src/lib/runtime/ai-device-audit.d.ts +109 -0
  473. package/src/lib/runtime/ai-device-audit.js +97 -0
  474. package/src/lib/runtime/ai-device-audit.js.map +1 -0
  475. package/src/lib/runtime/ai-doctrine-validators.d.ts +720 -0
  476. package/src/lib/runtime/ai-doctrine-validators.js +3133 -0
  477. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -0
  478. package/src/lib/runtime/ai-doctrine.d.ts +372 -0
  479. package/src/lib/runtime/ai-doctrine.js +944 -0
  480. package/src/lib/runtime/ai-doctrine.js.map +1 -0
  481. package/src/lib/runtime/ai-eval-live.d.ts +321 -0
  482. package/src/lib/runtime/ai-eval-live.js +1257 -0
  483. package/src/lib/runtime/ai-eval-live.js.map +1 -0
  484. package/src/lib/runtime/ai-eval-memory-firestore.d.ts +51 -0
  485. package/src/lib/runtime/ai-eval-memory-firestore.js +183 -0
  486. package/src/lib/runtime/ai-eval-memory-firestore.js.map +1 -0
  487. package/src/lib/runtime/ai-eval.d.ts +441 -0
  488. package/src/lib/runtime/ai-eval.js +1151 -0
  489. package/src/lib/runtime/ai-eval.js.map +1 -0
  490. package/src/lib/runtime/ai-gate.d.ts +130 -0
  491. package/src/lib/runtime/ai-gate.js +272 -0
  492. package/src/lib/runtime/ai-gate.js.map +1 -0
  493. package/src/lib/runtime/ai-generation-bounds.d.ts +24 -0
  494. package/src/lib/runtime/ai-generation-bounds.js +23 -0
  495. package/src/lib/runtime/ai-generation-bounds.js.map +1 -0
  496. package/src/lib/runtime/ai-insight-check.d.ts +76 -0
  497. package/src/lib/runtime/ai-insight-check.js +281 -0
  498. package/src/lib/runtime/ai-insight-check.js.map +1 -0
  499. package/src/lib/runtime/ai-node-tree.d.ts +181 -0
  500. package/src/lib/runtime/ai-node-tree.js +931 -0
  501. package/src/lib/runtime/ai-node-tree.js.map +1 -0
  502. package/src/lib/runtime/ai-page-links.d.ts +79 -0
  503. package/src/lib/runtime/ai-page-links.js +135 -0
  504. package/src/lib/runtime/ai-page-links.js.map +1 -0
  505. package/src/lib/runtime/ai-palette.d.ts +252 -0
  506. package/src/lib/runtime/ai-palette.generated.d.ts +34 -0
  507. package/src/lib/runtime/ai-palette.generated.js +5263 -0
  508. package/src/lib/runtime/ai-palette.generated.js.map +1 -0
  509. package/src/lib/runtime/ai-palette.js +187 -0
  510. package/src/lib/runtime/ai-palette.js.map +1 -0
  511. package/src/lib/runtime/ai-products-generation.d.ts +107 -0
  512. package/src/lib/runtime/ai-products-generation.js +250 -0
  513. package/src/lib/runtime/ai-products-generation.js.map +1 -0
  514. package/src/lib/runtime/ai-repeated-items.d.ts +95 -0
  515. package/src/lib/runtime/ai-repeated-items.js +397 -0
  516. package/src/lib/runtime/ai-repeated-items.js.map +1 -0
  517. package/src/lib/runtime/ai-runtime.d.ts +148 -0
  518. package/src/lib/runtime/ai-runtime.js +237 -0
  519. package/src/lib/runtime/ai-runtime.js.map +1 -0
  520. package/src/lib/runtime/ai-template-examples.d.ts +71 -0
  521. package/src/lib/runtime/ai-template-examples.js +135 -0
  522. package/src/lib/runtime/ai-template-examples.js.map +1 -0
  523. package/src/lib/runtime/assist-answer-cache.d.ts +80 -0
  524. package/src/lib/runtime/assist-answer-cache.js +184 -0
  525. package/src/lib/runtime/assist-answer-cache.js.map +1 -0
  526. package/src/lib/runtime/seo-audit.d.ts +93 -0
  527. package/src/lib/runtime/seo-audit.js +260 -0
  528. package/src/lib/runtime/seo-audit.js.map +1 -0
  529. package/src/lib/runtime/seo-content-fixes.d.ts +41 -0
  530. package/src/lib/runtime/seo-content-fixes.js +168 -0
  531. package/src/lib/runtime/seo-content-fixes.js.map +1 -0
  532. package/src/lib/runtime/seo-fields.d.ts +152 -0
  533. package/src/lib/runtime/seo-fields.js +215 -0
  534. package/src/lib/runtime/seo-fields.js.map +1 -0
  535. package/src/lib/runtime/seo-page-facts.d.ts +61 -0
  536. package/src/lib/runtime/seo-page-facts.js +150 -0
  537. package/src/lib/runtime/seo-page-facts.js.map +1 -0
  538. package/src/lib/runtime/site-inventory.d.ts +63 -0
  539. package/src/lib/runtime/site-inventory.js +230 -0
  540. package/src/lib/runtime/site-inventory.js.map +1 -0
  541. package/src/lib/server/ai-admin-org.d.ts +33 -0
  542. package/src/lib/server/ai-admin-org.js +381 -0
  543. package/src/lib/server/ai-admin-org.js.map +1 -0
  544. package/src/lib/server/ai-admin-orgs-spend.d.ts +40 -0
  545. package/src/lib/server/ai-admin-orgs-spend.js +129 -0
  546. package/src/lib/server/ai-admin-orgs-spend.js.map +1 -0
  547. package/src/lib/server/ai-admin-overage.d.ts +19 -0
  548. package/src/lib/server/ai-admin-overage.js +246 -0
  549. package/src/lib/server/ai-admin-overage.js.map +1 -0
  550. package/src/lib/server/ai-admin-signals.d.ts +34 -0
  551. package/src/lib/server/ai-admin-signals.js +330 -0
  552. package/src/lib/server/ai-admin-signals.js.map +1 -0
  553. package/src/lib/server/ai-admin-user.d.ts +27 -0
  554. package/src/lib/server/ai-admin-user.js +128 -0
  555. package/src/lib/server/ai-admin-user.js.map +1 -0
  556. package/src/lib/server/ai-allotments.d.ts +27 -0
  557. package/src/lib/server/ai-allotments.js +544 -0
  558. package/src/lib/server/ai-allotments.js.map +1 -0
  559. package/src/lib/server/ai-assist-prompts.d.ts +102 -0
  560. package/src/lib/server/ai-assist-prompts.js +207 -0
  561. package/src/lib/server/ai-assist-prompts.js.map +1 -0
  562. package/src/lib/server/ai-assist.d.ts +119 -0
  563. package/src/lib/server/ai-assist.js +517 -0
  564. package/src/lib/server/ai-assist.js.map +1 -0
  565. package/src/lib/server/ai-crm-answer.d.ts +30 -0
  566. package/src/lib/server/ai-crm-answer.js +98 -0
  567. package/src/lib/server/ai-crm-answer.js.map +1 -0
  568. package/src/lib/server/ai-generate-component.d.ts +111 -0
  569. package/src/lib/server/ai-generate-component.js +643 -0
  570. package/src/lib/server/ai-generate-component.js.map +1 -0
  571. package/src/lib/server/ai-host-permissions.d.ts +46 -0
  572. package/src/lib/server/ai-host-permissions.js +204 -0
  573. package/src/lib/server/ai-host-permissions.js.map +1 -0
  574. package/src/lib/server/ai-insight-answer.d.ts +30 -0
  575. package/src/lib/server/ai-insight-answer.js +83 -0
  576. package/src/lib/server/ai-insight-answer.js.map +1 -0
  577. package/src/lib/server/ai-insight-digest-route.d.ts +30 -0
  578. package/src/lib/server/ai-insight-digest-route.js +156 -0
  579. package/src/lib/server/ai-insight-digest-route.js.map +1 -0
  580. package/src/lib/server/ai-jobs-batch.d.ts +48 -0
  581. package/src/lib/server/ai-jobs-batch.js +306 -0
  582. package/src/lib/server/ai-jobs-batch.js.map +1 -0
  583. package/src/lib/server/ai-jobs-beat-route.d.ts +36 -0
  584. package/src/lib/server/ai-jobs-beat-route.js +86 -0
  585. package/src/lib/server/ai-jobs-beat-route.js.map +1 -0
  586. package/src/lib/server/ai-jobs-cancel.d.ts +30 -0
  587. package/src/lib/server/ai-jobs-cancel.js +74 -0
  588. package/src/lib/server/ai-jobs-cancel.js.map +1 -0
  589. package/src/lib/server/ai-jobs-events-route.d.ts +31 -0
  590. package/src/lib/server/ai-jobs-events-route.js +51 -0
  591. package/src/lib/server/ai-jobs-events-route.js.map +1 -0
  592. package/src/lib/server/ai-jobs-events.d.ts +55 -0
  593. package/src/lib/server/ai-jobs-events.js +144 -0
  594. package/src/lib/server/ai-jobs-events.js.map +1 -0
  595. package/src/lib/server/ai-jobs-gate.d.ts +47 -0
  596. package/src/lib/server/ai-jobs-gate.js +106 -0
  597. package/src/lib/server/ai-jobs-gate.js.map +1 -0
  598. package/src/lib/server/ai-jobs-resume.d.ts +23 -0
  599. package/src/lib/server/ai-jobs-resume.js +209 -0
  600. package/src/lib/server/ai-jobs-resume.js.map +1 -0
  601. package/src/lib/server/ai-jobs-route.d.ts +32 -0
  602. package/src/lib/server/ai-jobs-route.js +307 -0
  603. package/src/lib/server/ai-jobs-route.js.map +1 -0
  604. package/src/lib/server/ai-models.d.ts +18 -0
  605. package/src/lib/server/ai-models.js +134 -0
  606. package/src/lib/server/ai-models.js.map +1 -0
  607. package/src/lib/server/ai-seo-apply.d.ts +53 -0
  608. package/src/lib/server/ai-seo-apply.js +294 -0
  609. package/src/lib/server/ai-seo-apply.js.map +1 -0
  610. package/src/lib/server/ai-usage.d.ts +18 -0
  611. package/src/lib/server/ai-usage.js +220 -0
  612. package/src/lib/server/ai-usage.js.map +1 -0
  613. package/src/lib/server/assist-chat.d.ts +234 -0
  614. package/src/lib/server/assist-chat.js +1446 -0
  615. package/src/lib/server/assist-chat.js.map +1 -0
  616. package/src/lib/server/assist-edit-applied.d.ts +22 -0
  617. package/src/lib/server/assist-edit-applied.js +239 -0
  618. package/src/lib/server/assist-edit-applied.js.map +1 -0
  619. package/src/lib/server/assist-edit.d.ts +124 -0
  620. package/src/lib/server/assist-edit.js +1000 -0
  621. package/src/lib/server/assist-edit.js.map +1 -0
  622. package/src/lib/server/assist-feedback.d.ts +31 -0
  623. package/src/lib/server/assist-feedback.js +115 -0
  624. package/src/lib/server/assist-feedback.js.map +1 -0
  625. package/src/lib/server/assist-view-context.d.ts +343 -0
  626. package/src/lib/server/assist-view-context.js +690 -0
  627. package/src/lib/server/assist-view-context.js.map +1 -0
  628. package/src/lib/server/billing-credits.d.ts +59 -0
  629. package/src/lib/server/billing-credits.js +146 -0
  630. package/src/lib/server/billing-credits.js.map +1 -0
  631. package/src/lib/server/billing-overage.d.ts +19 -0
  632. package/src/lib/server/billing-overage.js +337 -0
  633. package/src/lib/server/billing-overage.js.map +1 -0
  634. package/src/lib/server.d.ts +32 -0
  635. package/src/lib/server.js +265 -0
  636. package/src/lib/server.js.map +1 -0
  637. package/src/lib/subprocessors.d.ts +18 -0
  638. package/src/lib/subprocessors.js +52 -0
  639. package/src/lib/subprocessors.js.map +1 -0
  640. package/src/lib/tools/ai-component-tool.d.ts +99 -0
  641. package/src/lib/tools/ai-component-tool.js +369 -0
  642. package/src/lib/tools/ai-component-tool.js.map +1 -0
  643. package/src/lib/tools/ai-crm-tool.d.ts +106 -0
  644. package/src/lib/tools/ai-crm-tool.js +488 -0
  645. package/src/lib/tools/ai-crm-tool.js.map +1 -0
  646. package/src/lib/tools/ai-duplicate-resource-tool.d.ts +71 -0
  647. package/src/lib/tools/ai-duplicate-resource-tool.js +164 -0
  648. package/src/lib/tools/ai-duplicate-resource-tool.js.map +1 -0
  649. package/src/lib/tools/ai-experiment-tool.d.ts +40 -0
  650. package/src/lib/tools/ai-experiment-tool.js +155 -0
  651. package/src/lib/tools/ai-experiment-tool.js.map +1 -0
  652. package/src/lib/tools/ai-insight-tool.d.ts +46 -0
  653. package/src/lib/tools/ai-insight-tool.js +200 -0
  654. package/src/lib/tools/ai-insight-tool.js.map +1 -0
  655. package/src/lib/tools/ai-inventory-lookup-tool.d.ts +86 -0
  656. package/src/lib/tools/ai-inventory-lookup-tool.js +164 -0
  657. package/src/lib/tools/ai-inventory-lookup-tool.js.map +1 -0
  658. package/src/lib/tools/ai-products-tool.d.ts +65 -0
  659. package/src/lib/tools/ai-products-tool.js +644 -0
  660. package/src/lib/tools/ai-products-tool.js.map +1 -0
  661. package/src/lib/tools/ai-seo-tool.d.ts +162 -0
  662. package/src/lib/tools/ai-seo-tool.js +546 -0
  663. package/src/lib/tools/ai-seo-tool.js.map +1 -0
  664. package/src/lib/tools/ai-theme-tool.d.ts +101 -0
  665. package/src/lib/tools/ai-theme-tool.js +562 -0
  666. package/src/lib/tools/ai-theme-tool.js.map +1 -0
  667. package/src/lib/tools/ai-workflow-tool.d.ts +166 -0
  668. package/src/lib/tools/ai-workflow-tool.js +860 -0
  669. package/src/lib/tools/ai-workflow-tool.js.map +1 -0
  670. package/src/lib/usage/ai-allotment-alerts.d.ts +72 -0
  671. package/src/lib/usage/ai-allotment-alerts.js +157 -0
  672. package/src/lib/usage/ai-allotment-alerts.js.map +1 -0
  673. package/src/lib/usage/ai-allotments.d.ts +125 -0
  674. package/src/lib/usage/ai-allotments.js +239 -0
  675. package/src/lib/usage/ai-allotments.js.map +1 -0
  676. package/src/lib/usage/ai-model-sample.d.ts +36 -0
  677. package/src/lib/usage/ai-model-sample.js +68 -0
  678. package/src/lib/usage/ai-model-sample.js.map +1 -0
  679. package/src/lib/usage/ai-usage-alerts.d.ts +55 -0
  680. package/src/lib/usage/ai-usage-alerts.js +114 -0
  681. package/src/lib/usage/ai-usage-alerts.js.map +1 -0
  682. package/src/lib/usage/ai-usage-by-user.d.ts +161 -0
  683. package/src/lib/usage/ai-usage-by-user.js +211 -0
  684. package/src/lib/usage/ai-usage-by-user.js.map +1 -0
  685. package/src/lib/usage/ai-usage-eraser.d.ts +29 -0
  686. package/src/lib/usage/ai-usage-eraser.js +40 -0
  687. package/src/lib/usage/ai-usage-eraser.js.map +1 -0
  688. package/src/lib/usage/ai-usage-meter.d.ts +39 -0
  689. package/src/lib/usage/ai-usage-meter.js +85 -0
  690. package/src/lib/usage/ai-usage-meter.js.map +1 -0
  691. package/src/lib/usage/ai-usage-wire.d.ts +184 -0
  692. package/src/lib/usage/ai-usage-wire.js +98 -0
  693. package/src/lib/usage/ai-usage-wire.js.map +1 -0
  694. package/src/lib/usage/assist-ceiling.d.ts +87 -0
  695. package/src/lib/usage/assist-ceiling.js +110 -0
  696. package/src/lib/usage/assist-ceiling.js.map +1 -0
  697. package/src/lib/usage/assist-free-taste.d.ts +225 -0
  698. package/src/lib/usage/assist-free-taste.js +308 -0
  699. package/src/lib/usage/assist-free-taste.js.map +1 -0
  700. package/src/lib/usage/assist-refusals.d.ts +69 -0
  701. package/src/lib/usage/assist-refusals.js +79 -0
  702. package/src/lib/usage/assist-refusals.js.map +1 -0
  703. package/src/lib/usage/assist-signal-mining.d.ts +375 -0
  704. package/src/lib/usage/assist-signal-mining.js +344 -0
  705. package/src/lib/usage/assist-signal-mining.js.map +1 -0
  706. package/src/lib/usage/assist-usage.d.ts +571 -0
  707. package/src/lib/usage/assist-usage.js +978 -0
  708. package/src/lib/usage/assist-usage.js.map +1 -0
  709. package/src/lib/usage/staff-org-ai.d.ts +242 -0
  710. package/src/lib/usage/staff-org-ai.js +173 -0
  711. package/src/lib/usage/staff-org-ai.js.map +1 -0
  712. package/src/lib/usage/staff-org-usage-ai.d.ts +83 -0
  713. package/src/lib/usage/staff-org-usage-ai.js +59 -0
  714. package/src/lib/usage/staff-org-usage-ai.js.map +1 -0
  715. package/src/lib/usage/staff-orgs-ai-spend.d.ts +83 -0
  716. package/src/lib/usage/staff-orgs-ai-spend.js +114 -0
  717. package/src/lib/usage/staff-orgs-ai-spend.js.map +1 -0
@@ -0,0 +1,506 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ import { CONTRAST_AA, CONTRAST_AA_LARGE, contrastRatio } from "@aglyn/aglyn/app-utils/marketplace-theme";
18
+ import { accessibleShade } from "@aglyn/shared-ui-theme/util/accessible-shade";
19
+ import { inheritedThemeColor } from "@aglyn/shared-ui-theme/util/theme-editor-defaults";
20
+ import { readDarkScheme, readFontFamily, readThemeColor, readToolbarHeight, resetComponentOverrides, SYSTEM_FONT_VALUE, THEME_COLOR_FIELDS, THEME_EDITOR_CONTROLS, THEME_EDITOR_MEDIA_QUERIES, THEME_EDITOR_SCHEMES, writeBorderRadius, writeComponentOverride, writeDarkScheme, writeFontFamily, writeSpacing, writeThemeColor, writeToolbarHeight } from "@aglyn/shared-ui-theme/util/theme-editor-fields";
21
+ import { prefersDarkInk } from "@aglyn/shared-util-tools/contrast";
22
+ /**
23
+ * A theme proposal (AGL-2938): what a theme job hands a person to apply.
24
+ *
25
+ * Not a theme. A proposal is a set of theme editor controls set to values,
26
+ * applied to whatever the site's theme is when the person applies it, through
27
+ * the same writes the editor performs. A proposal that names three colors
28
+ * changes three colors, and every control it does not name is untouched by
29
+ * construction rather than by the model's restraint — which is what makes
30
+ * "make it feel warmer" a targeted diff instead of a regenerated theme.
31
+ *
32
+ * Pure and free of anything server-side: the job step builds a proposal, and
33
+ * the Theme section's widget previews and applies one, from this module.
34
+ */ export const AI_THEME_PROPOSAL_VERSION = 1;
35
+ export const AI_THEME_PROPOSAL_MODES = [
36
+ 'modify',
37
+ 'create'
38
+ ];
39
+ export const AI_THEME_CHANGE_GROUPS = [
40
+ 'color',
41
+ 'darkScheme',
42
+ 'typography',
43
+ 'shape',
44
+ 'spacing',
45
+ 'navigation',
46
+ 'components'
47
+ ];
48
+ /** Every value control, as the catalog lists them. */ export const AI_THEME_VALUE_CONTROLS = THEME_EDITOR_CONTROLS.filter((control)=>control.id !== 'components').map((control)=>control.id);
49
+ /* ------------------------------------------------------------------------ *
50
+ * Reading and applying
51
+ * ------------------------------------------------------------------------ */ /** The color token a control writes, or `null` for a control that is not a color. */ export function aiThemeColorToken(control) {
52
+ return control.startsWith('color.') ? control.slice('color.'.length) : null;
53
+ }
54
+ /** What a control holds on a theme, as a proposal's `before` names it. */ export function readAiThemeControl(theme, control, scheme) {
55
+ var _readThemeColor;
56
+ const token = aiThemeColorToken(control);
57
+ if (token) return (_readThemeColor = readThemeColor(theme, scheme != null ? scheme : 'light', token)) != null ? _readThemeColor : null;
58
+ switch(control){
59
+ case 'darkScheme':
60
+ return readDarkScheme(theme) === 'off' ? 'off' : null;
61
+ case 'fontFamily':
62
+ {
63
+ const family = readFontFamily(theme);
64
+ return family === SYSTEM_FONT_VALUE ? null : family;
65
+ }
66
+ case 'borderRadius':
67
+ var _theme_shape;
68
+ return typeof (theme == null ? void 0 : (_theme_shape = theme.shape) == null ? void 0 : _theme_shape.borderRadius) === 'number' ? theme.shape.borderRadius : null;
69
+ case 'spacing':
70
+ return typeof (theme == null ? void 0 : theme.spacing) === 'number' ? theme.spacing : null;
71
+ case 'navHeight.xs':
72
+ var _ref;
73
+ return (_ref = theme && readToolbarHeight(theme, 'xs')) != null ? _ref : null;
74
+ case 'navHeight.sm':
75
+ var _ref1;
76
+ return (_ref1 = theme && readToolbarHeight(theme, 'sm')) != null ? _ref1 : null;
77
+ default:
78
+ return null;
79
+ }
80
+ }
81
+ function applyControlChange(theme, change) {
82
+ const { control, scheme, value } = change;
83
+ const token = aiThemeColorToken(control);
84
+ if (token) {
85
+ return writeThemeColor(theme, scheme != null ? scheme : 'light', token, typeof value === 'string' ? value : undefined);
86
+ }
87
+ const number = typeof value === 'number' ? value : undefined;
88
+ switch(control){
89
+ case 'darkScheme':
90
+ return writeDarkScheme(theme, value === 'off' ? 'off' : 'auto');
91
+ case 'fontFamily':
92
+ return writeFontFamily(theme, typeof value === 'string' ? value : SYSTEM_FONT_VALUE);
93
+ case 'borderRadius':
94
+ return writeBorderRadius(theme, number);
95
+ case 'spacing':
96
+ return writeSpacing(theme, number);
97
+ case 'navHeight.xs':
98
+ return writeToolbarHeight(theme, 'xs', number);
99
+ case 'navHeight.sm':
100
+ return writeToolbarHeight(theme, 'sm', number);
101
+ default:
102
+ return theme;
103
+ }
104
+ }
105
+ /**
106
+ * The theme a set of changes produces on top of `theme`: each change written
107
+ * the way the editor writes it, then the component overrides. Returns a new
108
+ * object; `theme` is not mutated.
109
+ */ export function applyAiThemeChanges(theme, proposal) {
110
+ let next = _extends({}, theme != null ? theme : {});
111
+ for (const change of proposal.changes)next = applyControlChange(next, change);
112
+ if (proposal.resetComponents) next = resetComponentOverrides(next);
113
+ for (const leaf of proposal.components)next = writeComponentOverride(next, leaf);
114
+ return next;
115
+ }
116
+ /* ------------------------------------------------------------------------ *
117
+ * Scope: which parts of the theme a brief is about
118
+ * ------------------------------------------------------------------------ */ /** The part of the theme a value control belongs to. */ export function aiThemeControlGroup(control) {
119
+ if (aiThemeColorToken(control)) return 'color';
120
+ switch(control){
121
+ case 'darkScheme':
122
+ return 'darkScheme';
123
+ case 'fontFamily':
124
+ return 'typography';
125
+ case 'borderRadius':
126
+ return 'shape';
127
+ case 'spacing':
128
+ return 'spacing';
129
+ default:
130
+ return 'navigation';
131
+ }
132
+ }
133
+ /**
134
+ * The part of the theme a component override belongs to: the type ramp's
135
+ * overrides are typography, the app bar's and the toolbar's are navigation,
136
+ * and the rest are components.
137
+ */ export function aiThemeComponentGroup(component) {
138
+ if (component === 'MuiTypography') return 'typography';
139
+ if (component === 'MuiAppBar' || component === 'MuiToolbar') return 'navigation';
140
+ return 'components';
141
+ }
142
+ /**
143
+ * The words that tie a brief to a part of the theme, matched case-insensitively
144
+ * on whole words. A brief can name several parts.
145
+ */ const BRIEF_VOCABULARY = {
146
+ color: /(#[0-9a-f]{3,8}\b)|\b(colou?rs?|palettes?|hues?|warm(er|th|ly)?|cool(er)?|cold(er)?|contrast\w*|bright(er|ness)?|dark(er|en)?|light(er|en)?|saturat\w*|desaturat\w*|muted|vibrant|pastels?|tones?|tints?|shades?|accents?|primary|secondary|tertiary|backgrounds?|surfaces?|brand\w*|earthy|neon|moody|red|orange|yellow|green|blue|teal|purple|violet|pink|magenta|brown|beige|cream|gold|navy|black|white|gr[ae]y|hex)\b/i,
147
+ darkScheme: /\b(dark (mode|scheme|theme)|light (mode|scheme)|always light|night mode)\b/i,
148
+ typography: /\b(fonts?|typefaces?|typography|serif|sans|monospace|headings?|headlines?|titles?|type ?scale|text size|font size|lettering|weights?|bold(er)?|editorial)\b/i,
149
+ shape: /\b(radius|radii|round(ed|er|ness)?|corners?|sharp(er)?|square(d|r)?|pills?|curv\w*)\b/i,
150
+ spacing: /\b(spac\w*|padding|margins?|roomy|airy|tight(er)?|compact|dense|breathing room|white ?space|gaps?)\b/i,
151
+ navigation: /\b(nav\w*|header height|toolbar|app ?bar|menu bar|top bar)\b/i,
152
+ components: /\b(buttons?|cards?|chips?|inputs?|text ?fields?|links?|tabs?|switch(es)?|sliders?|avatars?|badges?|tooltips?|dividers?|menus?|components?|uppercase|capitali[sz]\w*|shadows?|elevation|outlined|underlin\w*)\b/i
153
+ };
154
+ /**
155
+ * The parts of the theme a job may change. A `create` job is a whole design.
156
+ * A `modify` job may change only what its brief is about, so "make it feel
157
+ * warmer" reaches the colors and nothing else; a brief that names no part at
158
+ * all — in another language, or in words this does not know — is taken to
159
+ * be about the whole design rather than refused.
160
+ */ export function aiThemeBriefScope(brief, mode) {
161
+ if (mode === 'create') return new Set(AI_THEME_CHANGE_GROUPS);
162
+ const named = AI_THEME_CHANGE_GROUPS.filter((group)=>BRIEF_VOCABULARY[group].test(brief));
163
+ return new Set(named.length ? named : AI_THEME_CHANGE_GROUPS);
164
+ }
165
+ const GROUP_WORDS = {
166
+ color: 'colors',
167
+ darkScheme: 'the dark scheme',
168
+ typography: 'typography',
169
+ shape: 'corners',
170
+ spacing: 'spacing',
171
+ navigation: 'navigation',
172
+ components: 'component styles'
173
+ };
174
+ /* ------------------------------------------------------------------------ *
175
+ * Colors as the site renders them, and dark values
176
+ * ------------------------------------------------------------------------ */ const colorKey = (scheme, token)=>`${scheme}:${token}`;
177
+ /** A color as the site renders it in one scheme: its own value, else the brand's. */ export function effectiveThemeColor(theme, scheme, token) {
178
+ var _readThemeColor;
179
+ return (_readThemeColor = readThemeColor(theme, scheme, token)) != null ? _readThemeColor : inheritedThemeColor(scheme, token);
180
+ }
181
+ /** The accents: the colors whose dark value can follow their light one. */ const ACCENT_TOKENS = new Set(THEME_COLOR_FIELDS.filter((field)=>field.group === 'palette').map((field)=>field.token));
182
+ /**
183
+ * The colors a set of changes gives a light value and no dark one, while the
184
+ * site's dark scheme is on. Each is a visitor in dark mode seeing half a
185
+ * change.
186
+ */ export function aiThemeMissingDarkValues(changes, themeAfter) {
187
+ if (readDarkScheme(themeAfter) === 'off') return [];
188
+ const set = new Set(changes.filter((change)=>aiThemeColorToken(change.control)).map((change)=>{
189
+ var _change_scheme;
190
+ return colorKey((_change_scheme = change.scheme) != null ? _change_scheme : 'light', aiThemeColorToken(change.control));
191
+ }));
192
+ return THEME_COLOR_FIELDS.map(({ token })=>token).filter((token)=>set.has(colorKey('light', token)) && !set.has(colorKey('dark', token)));
193
+ }
194
+ /**
195
+ * The dark value an accent keeps when a proposal gave none: the same hue,
196
+ * lightened only as far as it takes to read on the dark background as a fill
197
+ * or an indicator. Surfaces, text and tints have no such value — a pale light
198
+ * surface lightened is still a light surface — so they go on inheriting the
199
+ * platform's dark palette, which is what a site with no dark design renders.
200
+ */ export function deriveAiThemeDarkAccent(light, themeAfter) {
201
+ const background = effectiveThemeColor(themeAfter, 'dark', 'background.default');
202
+ if (!background) return null;
203
+ try {
204
+ return accessibleShade(light, [
205
+ background
206
+ ], 'lighten', {
207
+ minContrast: CONTRAST_AA_LARGE
208
+ });
209
+ } catch (unused) {
210
+ return null;
211
+ }
212
+ }
213
+ /**
214
+ * The pairs a proposal is held to. Body text on the page and on paper, and
215
+ * secondary text on the page, are the pairs the theme publish check
216
+ * (`validateThemeForPublish`) measures, at its bars; the primary color on
217
+ * the page is held to the bar a fill or an indicator owes.
218
+ */ export const AI_THEME_CONTRAST_PAIRS = [
219
+ {
220
+ foreground: 'text.primary',
221
+ backgrounds: [
222
+ 'background.default',
223
+ 'background.paper'
224
+ ],
225
+ required: CONTRAST_AA
226
+ },
227
+ {
228
+ foreground: 'text.secondary',
229
+ backgrounds: [
230
+ 'background.default'
231
+ ],
232
+ required: CONTRAST_AA
233
+ },
234
+ {
235
+ foreground: 'primary',
236
+ backgrounds: [
237
+ 'background.default'
238
+ ],
239
+ required: CONTRAST_AA_LARGE
240
+ }
241
+ ];
242
+ const round2 = (ratio)=>Math.round(ratio * 100) / 100;
243
+ /**
244
+ * Whether dark ink reads better than light ink on a background. A hex takes
245
+ * the shared helper; anything else a theme can hold (`rgba()`) is measured
246
+ * against black and white directly, which is the same comparison.
247
+ */ function darkInkReads(background) {
248
+ var _contrastRatio, _contrastRatio1;
249
+ const verdict = prefersDarkInk(background);
250
+ if (verdict !== null) return verdict;
251
+ return ((_contrastRatio = contrastRatio('#000000', background)) != null ? _contrastRatio : 0) >= ((_contrastRatio1 = contrastRatio('#ffffff', background)) != null ? _contrastRatio1 : 0);
252
+ }
253
+ /**
254
+ * Every pair a set of changes takes below its bar, corrected to the nearest
255
+ * shade of its foreground that clears it, and named.
256
+ *
257
+ * Only pairs the changes touched are corrected. A pair that already fell
258
+ * short with neither of its colors changed is named in `notes` and left
259
+ * alone, because correcting it would change a color the brief did not ask
260
+ * about. A dark scheme the site has switched off is not measured: no visitor
261
+ * sees it.
262
+ */ export function correctAiThemeContrast(themeAfter, touchedChanges) {
263
+ const touched = new Set(touchedChanges.filter((change)=>aiThemeColorToken(change.control)).map((change)=>{
264
+ var _change_scheme;
265
+ return colorKey((_change_scheme = change.scheme) != null ? _change_scheme : 'light', aiThemeColorToken(change.control));
266
+ }));
267
+ const schemes = THEME_EDITOR_SCHEMES.filter((scheme)=>scheme === 'light' || readDarkScheme(themeAfter) !== 'off');
268
+ let theme = themeAfter;
269
+ const corrections = [];
270
+ const notes = [];
271
+ for (const scheme of schemes){
272
+ for (const pair of AI_THEME_CONTRAST_PAIRS){
273
+ var _readThemeColor;
274
+ const foreground = effectiveThemeColor(theme, scheme, pair.foreground);
275
+ const backgrounds = pair.backgrounds.map((token)=>effectiveThemeColor(theme, scheme, token)).filter((value)=>typeof value === 'string');
276
+ if (!foreground || backgrounds.length !== pair.backgrounds.length) continue;
277
+ const ratios = backgrounds.map((background)=>contrastRatio(foreground, background));
278
+ if (ratios.some((ratio)=>ratio === null)) continue;
279
+ const worst = Math.min(...ratios);
280
+ if (worst >= pair.required) continue;
281
+ const involved = [
282
+ pair.foreground,
283
+ ...pair.backgrounds
284
+ ].some((token)=>touched.has(colorKey(scheme, token)));
285
+ if (!involved) {
286
+ notes.push(`${pair.foreground} on ${pair.backgrounds.join(' and ')} in ${scheme} was already ` + `${round2(worst)}:1 before this proposal, below ${pair.required}:1.`);
287
+ continue;
288
+ }
289
+ let corrected;
290
+ try {
291
+ corrected = accessibleShade(foreground, backgrounds, darkInkReads(backgrounds[0]) ? 'darken' : 'lighten', {
292
+ minContrast: pair.required
293
+ });
294
+ } catch (unused) {
295
+ continue;
296
+ }
297
+ const clears = backgrounds.every((background)=>{
298
+ var _contrastRatio;
299
+ return ((_contrastRatio = contrastRatio(corrected, background)) != null ? _contrastRatio : 0) >= pair.required;
300
+ });
301
+ if (!clears) {
302
+ notes.push(`${pair.foreground} cannot reach ${pair.required}:1 on the ${scheme} background by ` + 'changing its shade alone; the background needs to change too.');
303
+ continue;
304
+ }
305
+ corrections.push({
306
+ control: `color.${pair.foreground}`,
307
+ scheme,
308
+ from: (_readThemeColor = readThemeColor(theme, scheme, pair.foreground)) != null ? _readThemeColor : null,
309
+ to: corrected,
310
+ reason: 'contrast',
311
+ against: backgrounds,
312
+ ratio: round2(worst),
313
+ required: pair.required
314
+ });
315
+ theme = writeThemeColor(theme, scheme, pair.foreground, corrected);
316
+ }
317
+ }
318
+ return {
319
+ theme,
320
+ corrections,
321
+ notes
322
+ };
323
+ }
324
+ /** Folds a correction into a change list: the change it corrects, or a new one. */ function withCorrection(changes, correction, base) {
325
+ const index = changes.findIndex((change)=>change.control === correction.control && change.scheme === correction.scheme);
326
+ if (index >= 0) {
327
+ return changes.map((change, at)=>at === index ? _extends({}, change, {
328
+ value: correction.to
329
+ }) : change);
330
+ }
331
+ return [
332
+ ...changes,
333
+ {
334
+ control: correction.control,
335
+ scheme: correction.scheme,
336
+ value: correction.to,
337
+ before: readAiThemeControl(base, correction.control, correction.scheme)
338
+ }
339
+ ];
340
+ }
341
+ /**
342
+ * A proposal from what the model proposed, held to the editor and to the
343
+ * doctrine: changes that change nothing are gone, a modify brief reaches
344
+ * only the parts of the theme it names, accents keep a dark value, and every
345
+ * pair the proposal touches clears its contrast bar.
346
+ */ export function buildAiThemeProposal(input) {
347
+ var _input_dropped, _input_notes;
348
+ const dropped = [
349
+ ...(_input_dropped = input.dropped) != null ? _input_dropped : []
350
+ ];
351
+ const notes = [
352
+ ...(_input_notes = input.notes) != null ? _input_notes : []
353
+ ];
354
+ const scope = aiThemeBriefScope(input.brief, input.mode);
355
+ const outOfScope = (group, what)=>{
356
+ dropped.push(`${what}: the brief did not ask about ${GROUP_WORDS[group]}`);
357
+ };
358
+ let changes = [];
359
+ for (const change of input.changes){
360
+ const before = readAiThemeControl(input.base, change.control, change.scheme);
361
+ if (before === change.value) continue;
362
+ const group = aiThemeControlGroup(change.control);
363
+ if (!scope.has(group)) {
364
+ outOfScope(group, change.scheme ? `${change.control} (${change.scheme})` : change.control);
365
+ continue;
366
+ }
367
+ changes.push(_extends({}, change, {
368
+ before
369
+ }));
370
+ }
371
+ const components = input.components.filter((leaf)=>{
372
+ const group = aiThemeComponentGroup(leaf.component);
373
+ if (scope.has(group)) return true;
374
+ outOfScope(group, `${leaf.component}.${leaf.property}`);
375
+ return false;
376
+ });
377
+ let resetComponents = input.resetComponents;
378
+ if (resetComponents && !scope.has('components')) {
379
+ outOfScope('components', 'Resetting the component overrides');
380
+ resetComponents = false;
381
+ }
382
+ const corrections = [];
383
+ let after = applyAiThemeChanges(input.base, {
384
+ changes,
385
+ components,
386
+ resetComponents
387
+ });
388
+ for (const token of aiThemeMissingDarkValues(changes, after)){
389
+ var _readThemeColor;
390
+ const light = changes.find((change)=>change.scheme === 'light' && aiThemeColorToken(change.control) === token);
391
+ if (!ACCENT_TOKENS.has(token) || typeof (light == null ? void 0 : light.value) !== 'string') {
392
+ notes.push(`${token} keeps its current dark value; only its light value changes.`);
393
+ continue;
394
+ }
395
+ const dark = deriveAiThemeDarkAccent(light.value, after);
396
+ if (!dark) continue;
397
+ const correction = {
398
+ control: `color.${token}`,
399
+ scheme: 'dark',
400
+ from: (_readThemeColor = readThemeColor(input.base, 'dark', token)) != null ? _readThemeColor : null,
401
+ to: dark,
402
+ reason: 'dark-value'
403
+ };
404
+ corrections.push(correction);
405
+ changes = withCorrection(changes, correction, input.base);
406
+ after = writeThemeColor(after, 'dark', token, dark);
407
+ }
408
+ const contrast = correctAiThemeContrast(after, changes);
409
+ for (const correction of contrast.corrections){
410
+ corrections.push(correction);
411
+ changes = withCorrection(changes, correction, input.base);
412
+ }
413
+ notes.push(...contrast.notes);
414
+ return {
415
+ version: AI_THEME_PROPOSAL_VERSION,
416
+ mode: input.mode,
417
+ summary: input.summary,
418
+ source: input.source,
419
+ changes,
420
+ components,
421
+ resetComponents,
422
+ corrections,
423
+ dropped,
424
+ notes
425
+ };
426
+ }
427
+ /**
428
+ * What applying a proposal to the site's CURRENT theme produces, held to the
429
+ * contrast bars again: the theme may have changed since the proposal was
430
+ * made, and a proposal that cleared its bars against the old background can
431
+ * fall short against the new one. The corrections this makes are named
432
+ * beside the proposal's own.
433
+ */ export function aiThemeProposalAfter(theme, proposal) {
434
+ const applied = applyAiThemeChanges(theme, proposal);
435
+ return correctAiThemeContrast(applied, proposal.changes);
436
+ }
437
+ /** The changes whose `before` no longer matches the theme a proposal is applied to. */ export function aiThemeStaleChanges(theme, proposal) {
438
+ return proposal.changes.filter((change)=>readAiThemeControl(theme, change.control, change.scheme) !== change.before);
439
+ }
440
+ /* ------------------------------------------------------------------------ *
441
+ * Reading a stored proposal back
442
+ * ------------------------------------------------------------------------ */ const isRecord = (value)=>typeof value === 'object' && value !== null && !Array.isArray(value);
443
+ const strings = (value)=>Array.isArray(value) ? value.filter((entry)=>typeof entry === 'string') : [];
444
+ const scalar = (value)=>typeof value === 'string' || typeof value === 'number' ? value : null;
445
+ const VALUE_CONTROLS = new Set(AI_THEME_VALUE_CONTROLS);
446
+ /**
447
+ * A proposal as a job output stores it, or `null` for anything that is not
448
+ * one. The job writes these through the Admin SDK and nothing else can, but
449
+ * a reader that applies what it reads to a theme checks the shape first.
450
+ */ export function readAiThemeProposal(value) {
451
+ if (!isRecord(value) || value['version'] !== AI_THEME_PROPOSAL_VERSION) return null;
452
+ const mode = value['mode'] === 'create' ? 'create' : 'modify';
453
+ const source = value['source'] === 'installed' || value['source'] === 'custom' ? value['source'] : 'default';
454
+ const changes = (Array.isArray(value['changes']) ? value['changes'] : []).filter(isRecord).filter((change)=>VALUE_CONTROLS.has(String(change['control']))).map((change)=>({
455
+ control: change['control'],
456
+ scheme: change['scheme'] === 'light' || change['scheme'] === 'dark' ? change['scheme'] : null,
457
+ value: scalar(change['value']),
458
+ before: scalar(change['before'])
459
+ }));
460
+ const components = (Array.isArray(value['components']) ? value['components'] : []).filter(isRecord).filter((leaf)=>{
461
+ var _ref;
462
+ var _THEME_EDITOR_CONTROLS_find;
463
+ return ((_ref = (_THEME_EDITOR_CONTROLS_find = THEME_EDITOR_CONTROLS.find((control)=>control.id === 'components')) == null ? void 0 : _THEME_EDITOR_CONTROLS_find.options) != null ? _ref : []).includes(String(leaf['component'])) && (leaf['target'] === 'styleOverrides' || leaf['target'] === 'defaultProps') && typeof leaf['property'] === 'string' && [
464
+ 'string',
465
+ 'number',
466
+ 'boolean'
467
+ ].includes(typeof leaf['value']) && (leaf['media'] === null || String(leaf['media']) in THEME_EDITOR_MEDIA_QUERIES);
468
+ }).map((leaf)=>{
469
+ var _leaf_media;
470
+ return {
471
+ component: leaf['component'],
472
+ target: leaf['target'],
473
+ slot: typeof leaf['slot'] === 'string' ? leaf['slot'] : null,
474
+ property: leaf['property'],
475
+ media: (_leaf_media = leaf['media']) != null ? _leaf_media : null,
476
+ value: leaf['value']
477
+ };
478
+ });
479
+ const corrections = (Array.isArray(value['corrections']) ? value['corrections'] : []).filter(isRecord).filter((correction)=>aiThemeColorToken(String(correction['control'])) !== null && (correction['scheme'] === 'light' || correction['scheme'] === 'dark') && typeof correction['to'] === 'string').map((correction)=>_extends({
480
+ control: correction['control'],
481
+ scheme: correction['scheme'],
482
+ from: typeof correction['from'] === 'string' ? correction['from'] : null,
483
+ to: correction['to'],
484
+ reason: correction['reason'] === 'dark-value' ? 'dark-value' : 'contrast'
485
+ }, Array.isArray(correction['against']) ? {
486
+ against: strings(correction['against'])
487
+ } : {}, typeof correction['ratio'] === 'number' ? {
488
+ ratio: correction['ratio']
489
+ } : {}, typeof correction['required'] === 'number' ? {
490
+ required: correction['required']
491
+ } : {}));
492
+ return {
493
+ version: AI_THEME_PROPOSAL_VERSION,
494
+ mode,
495
+ summary: typeof value['summary'] === 'string' ? value['summary'] : '',
496
+ source,
497
+ changes,
498
+ components,
499
+ resetComponents: value['resetComponents'] === true,
500
+ corrections,
501
+ dropped: strings(value['dropped']),
502
+ notes: strings(value['notes'])
503
+ };
504
+ }
505
+
506
+ //# sourceMappingURL=ai-theme-proposal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-theme-proposal.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 {\n CONTRAST_AA,\n CONTRAST_AA_LARGE,\n contrastRatio,\n type HostThemeSource,\n} from '@aglyn/aglyn/app-utils/marketplace-theme'\nimport type { HostTheme, HostThemeScheme } from '@aglyn/shared-data-types'\nimport { accessibleShade } from '@aglyn/shared-ui-theme/util/accessible-shade'\nimport { inheritedThemeColor } from '@aglyn/shared-ui-theme/util/theme-editor-defaults'\nimport {\n readDarkScheme,\n readFontFamily,\n readThemeColor,\n readToolbarHeight,\n resetComponentOverrides,\n SYSTEM_FONT_VALUE,\n THEME_COLOR_FIELDS,\n THEME_EDITOR_CONTROLS,\n THEME_EDITOR_MEDIA_QUERIES,\n THEME_EDITOR_SCHEMES,\n writeBorderRadius,\n writeComponentOverride,\n writeDarkScheme,\n writeFontFamily,\n writeSpacing,\n writeThemeColor,\n writeToolbarHeight,\n type ThemeColorToken,\n type ThemeComponentOverrideLeaf,\n type ThemeEditorControlId,\n} from '@aglyn/shared-ui-theme/util/theme-editor-fields'\nimport { prefersDarkInk } from '@aglyn/shared-util-tools/contrast'\n\n/**\n * A theme proposal (AGL-2938): what a theme job hands a person to apply.\n *\n * Not a theme. A proposal is a set of theme editor controls set to values,\n * applied to whatever the site's theme is when the person applies it, through\n * the same writes the editor performs. A proposal that names three colors\n * changes three colors, and every control it does not name is untouched by\n * construction rather than by the model's restraint — which is what makes\n * \"make it feel warmer\" a targeted diff instead of a regenerated theme.\n *\n * Pure and free of anything server-side: the job step builds a proposal, and\n * the Theme section's widget previews and applies one, from this module.\n */\n\nexport const AI_THEME_PROPOSAL_VERSION = 1\n\n/**\n * `modify` changes what the brief is about and nothing else; `create` is a\n * whole design over every control the editor has.\n */\nexport type AiThemeProposalMode = 'modify' | 'create'\n\nexport const AI_THEME_PROPOSAL_MODES: readonly AiThemeProposalMode[] = ['modify', 'create']\n\n/** The parts of a theme a brief can be about. */\nexport type AiThemeChangeGroup =\n | 'color'\n | 'darkScheme'\n | 'typography'\n | 'shape'\n | 'spacing'\n | 'navigation'\n | 'components'\n\nexport const AI_THEME_CHANGE_GROUPS: readonly AiThemeChangeGroup[] = [\n 'color',\n 'darkScheme',\n 'typography',\n 'shape',\n 'spacing',\n 'navigation',\n 'components',\n]\n\n/** The controls a proposal sets one value on; component overrides are leaves of their own. */\nexport type AiThemeValueControl = Exclude<ThemeEditorControlId, 'components'>\n\n/** Every value control, as the catalog lists them. */\nexport const AI_THEME_VALUE_CONTROLS: readonly AiThemeValueControl[] = THEME_EDITOR_CONTROLS.filter(\n (control) => control.id !== 'components',\n).map((control) => control.id as AiThemeValueControl)\n\n/** One editor control set to a value, or back to its default with `null`. */\nexport interface AiThemeControlChange {\n control: AiThemeValueControl\n /** The scheme a color is set for; `null` for every other control. */\n scheme: HostThemeScheme | null\n value: string | number | null\n /** What the site had set when the proposal was made; `null` when it inherited. */\n before: string | number | null\n}\n\n/** A value the proposal carries that the model did not write, and why. */\nexport interface AiThemeCorrection {\n control: `color.${ThemeColorToken}`\n scheme: HostThemeScheme\n /** The value before the correction; `null` when the slot inherited. */\n from: string | null\n to: string\n /**\n * `contrast` — the pair fell below its bar and this is the nearest shade\n * of the foreground that clears it. `dark-value` — the proposal changed an\n * accent for light and gave no dark value, and this keeps the same hue\n * readable on the dark background.\n */\n reason: 'contrast' | 'dark-value'\n /** The colors a contrast correction was measured against. */\n against?: string[]\n /** The worst ratio before the correction. */\n ratio?: number\n /** The bar the pair has to clear. */\n required?: number\n}\n\nexport interface AiThemeProposal {\n version: typeof AI_THEME_PROPOSAL_VERSION\n mode: AiThemeProposalMode\n /** One sentence naming what the proposal changes, in the brief's language. */\n summary: string\n /**\n * Where the site's theme came from when the proposal was made, which is\n * how the editor's Save stores it: an installed theme's edits become its\n * override patch, a default theme stores only the changed values, and a\n * site's own theme changes in place.\n */\n source: HostThemeSource\n changes: AiThemeControlChange[]\n components: ThemeComponentOverrideLeaf[]\n /** The site's own component overrides are dropped before `components` apply. */\n resetComponents: boolean\n corrections: AiThemeCorrection[]\n /** What the model proposed that the proposal leaves out, in words. */\n dropped: string[]\n /** Anything else a person should read before applying, in words. */\n notes: string[]\n}\n\n/* ------------------------------------------------------------------------ *\n * Reading and applying\n * ------------------------------------------------------------------------ */\n\n/** The color token a control writes, or `null` for a control that is not a color. */\nexport function aiThemeColorToken(control: string): ThemeColorToken | null {\n return control.startsWith('color.')\n ? (control.slice('color.'.length) as ThemeColorToken)\n : null\n}\n\n/** What a control holds on a theme, as a proposal's `before` names it. */\nexport function readAiThemeControl(\n theme: HostTheme | undefined,\n control: AiThemeValueControl,\n scheme: HostThemeScheme | null,\n): string | number | null {\n const token = aiThemeColorToken(control)\n if (token) return readThemeColor(theme, scheme ?? 'light', token) ?? null\n switch (control) {\n case 'darkScheme':\n return readDarkScheme(theme) === 'off' ? 'off' : null\n case 'fontFamily': {\n const family = readFontFamily(theme)\n return family === SYSTEM_FONT_VALUE ? null : family\n }\n case 'borderRadius':\n return typeof theme?.shape?.borderRadius === 'number' ? theme.shape.borderRadius : null\n case 'spacing':\n return typeof theme?.spacing === 'number' ? theme.spacing : null\n case 'navHeight.xs':\n return (theme && readToolbarHeight(theme, 'xs')) ?? null\n case 'navHeight.sm':\n return (theme && readToolbarHeight(theme, 'sm')) ?? null\n default:\n return null\n }\n}\n\nfunction applyControlChange(\n theme: HostTheme,\n change: Pick<AiThemeControlChange, 'control' | 'scheme' | 'value'>,\n): HostTheme {\n const { control, scheme, value } = change\n const token = aiThemeColorToken(control)\n if (token) {\n return writeThemeColor(\n theme,\n scheme ?? 'light',\n token,\n typeof value === 'string' ? value : undefined,\n )\n }\n const number = typeof value === 'number' ? value : undefined\n switch (control) {\n case 'darkScheme':\n return writeDarkScheme(theme, value === 'off' ? 'off' : 'auto')\n case 'fontFamily':\n return writeFontFamily(theme, typeof value === 'string' ? value : SYSTEM_FONT_VALUE)\n case 'borderRadius':\n return writeBorderRadius(theme, number)\n case 'spacing':\n return writeSpacing(theme, number)\n case 'navHeight.xs':\n return writeToolbarHeight(theme, 'xs', number)\n case 'navHeight.sm':\n return writeToolbarHeight(theme, 'sm', number)\n default:\n return theme\n }\n}\n\n/**\n * The theme a set of changes produces on top of `theme`: each change written\n * the way the editor writes it, then the component overrides. Returns a new\n * object; `theme` is not mutated.\n */\nexport function applyAiThemeChanges(\n theme: HostTheme | undefined,\n proposal: {\n changes: ReadonlyArray<Pick<AiThemeControlChange, 'control' | 'scheme' | 'value'>>\n components: readonly ThemeComponentOverrideLeaf[]\n resetComponents: boolean\n },\n): HostTheme {\n let next: HostTheme = { ...(theme ?? {}) }\n for (const change of proposal.changes) next = applyControlChange(next, change)\n if (proposal.resetComponents) next = resetComponentOverrides(next)\n for (const leaf of proposal.components) next = writeComponentOverride(next, leaf)\n return next\n}\n\n/* ------------------------------------------------------------------------ *\n * Scope: which parts of the theme a brief is about\n * ------------------------------------------------------------------------ */\n\n/** The part of the theme a value control belongs to. */\nexport function aiThemeControlGroup(control: AiThemeValueControl): AiThemeChangeGroup {\n if (aiThemeColorToken(control)) return 'color'\n switch (control) {\n case 'darkScheme':\n return 'darkScheme'\n case 'fontFamily':\n return 'typography'\n case 'borderRadius':\n return 'shape'\n case 'spacing':\n return 'spacing'\n default:\n return 'navigation'\n }\n}\n\n/**\n * The part of the theme a component override belongs to: the type ramp's\n * overrides are typography, the app bar's and the toolbar's are navigation,\n * and the rest are components.\n */\nexport function aiThemeComponentGroup(\n component: ThemeComponentOverrideLeaf['component'],\n): AiThemeChangeGroup {\n if (component === 'MuiTypography') return 'typography'\n if (component === 'MuiAppBar' || component === 'MuiToolbar') return 'navigation'\n return 'components'\n}\n\n/**\n * The words that tie a brief to a part of the theme, matched case-insensitively\n * on whole words. A brief can name several parts.\n */\nconst BRIEF_VOCABULARY: Record<AiThemeChangeGroup, RegExp> = {\n color:\n /(#[0-9a-f]{3,8}\\b)|\\b(colou?rs?|palettes?|hues?|warm(er|th|ly)?|cool(er)?|cold(er)?|contrast\\w*|bright(er|ness)?|dark(er|en)?|light(er|en)?|saturat\\w*|desaturat\\w*|muted|vibrant|pastels?|tones?|tints?|shades?|accents?|primary|secondary|tertiary|backgrounds?|surfaces?|brand\\w*|earthy|neon|moody|red|orange|yellow|green|blue|teal|purple|violet|pink|magenta|brown|beige|cream|gold|navy|black|white|gr[ae]y|hex)\\b/i,\n darkScheme: /\\b(dark (mode|scheme|theme)|light (mode|scheme)|always light|night mode)\\b/i,\n typography:\n /\\b(fonts?|typefaces?|typography|serif|sans|monospace|headings?|headlines?|titles?|type ?scale|text size|font size|lettering|weights?|bold(er)?|editorial)\\b/i,\n shape: /\\b(radius|radii|round(ed|er|ness)?|corners?|sharp(er)?|square(d|r)?|pills?|curv\\w*)\\b/i,\n spacing:\n /\\b(spac\\w*|padding|margins?|roomy|airy|tight(er)?|compact|dense|breathing room|white ?space|gaps?)\\b/i,\n navigation: /\\b(nav\\w*|header height|toolbar|app ?bar|menu bar|top bar)\\b/i,\n components:\n /\\b(buttons?|cards?|chips?|inputs?|text ?fields?|links?|tabs?|switch(es)?|sliders?|avatars?|badges?|tooltips?|dividers?|menus?|components?|uppercase|capitali[sz]\\w*|shadows?|elevation|outlined|underlin\\w*)\\b/i,\n}\n\n/**\n * The parts of the theme a job may change. A `create` job is a whole design.\n * A `modify` job may change only what its brief is about, so \"make it feel\n * warmer\" reaches the colors and nothing else; a brief that names no part at\n * all — in another language, or in words this does not know — is taken to\n * be about the whole design rather than refused.\n */\nexport function aiThemeBriefScope(\n brief: string,\n mode: AiThemeProposalMode,\n): ReadonlySet<AiThemeChangeGroup> {\n if (mode === 'create') return new Set(AI_THEME_CHANGE_GROUPS)\n const named = AI_THEME_CHANGE_GROUPS.filter((group) => BRIEF_VOCABULARY[group].test(brief))\n return new Set(named.length ? named : AI_THEME_CHANGE_GROUPS)\n}\n\nconst GROUP_WORDS: Record<AiThemeChangeGroup, string> = {\n color: 'colors',\n darkScheme: 'the dark scheme',\n typography: 'typography',\n shape: 'corners',\n spacing: 'spacing',\n navigation: 'navigation',\n components: 'component styles',\n}\n\n/* ------------------------------------------------------------------------ *\n * Colors as the site renders them, and dark values\n * ------------------------------------------------------------------------ */\n\nconst colorKey = (scheme: HostThemeScheme, token: ThemeColorToken) => `${scheme}:${token}`\n\n/** A color as the site renders it in one scheme: its own value, else the brand's. */\nexport function effectiveThemeColor(\n theme: HostTheme | undefined,\n scheme: HostThemeScheme,\n token: ThemeColorToken,\n): string | undefined {\n return readThemeColor(theme, scheme, token) ?? inheritedThemeColor(scheme, token)\n}\n\n/** The accents: the colors whose dark value can follow their light one. */\nconst ACCENT_TOKENS: ReadonlySet<ThemeColorToken> = new Set(\n THEME_COLOR_FIELDS.filter((field) => field.group === 'palette').map((field) => field.token),\n)\n\n/**\n * The colors a set of changes gives a light value and no dark one, while the\n * site's dark scheme is on. Each is a visitor in dark mode seeing half a\n * change.\n */\nexport function aiThemeMissingDarkValues(\n changes: ReadonlyArray<Pick<AiThemeControlChange, 'control' | 'scheme'>>,\n themeAfter: HostTheme,\n): ThemeColorToken[] {\n if (readDarkScheme(themeAfter) === 'off') return []\n const set = new Set(\n changes\n .filter((change) => aiThemeColorToken(change.control))\n .map((change) =>\n colorKey(change.scheme ?? 'light', aiThemeColorToken(change.control) as ThemeColorToken),\n ),\n )\n return THEME_COLOR_FIELDS.map(({ token }) => token).filter(\n (token) => set.has(colorKey('light', token)) && !set.has(colorKey('dark', token)),\n )\n}\n\n/**\n * The dark value an accent keeps when a proposal gave none: the same hue,\n * lightened only as far as it takes to read on the dark background as a fill\n * or an indicator. Surfaces, text and tints have no such value — a pale light\n * surface lightened is still a light surface — so they go on inheriting the\n * platform's dark palette, which is what a site with no dark design renders.\n */\nexport function deriveAiThemeDarkAccent(light: string, themeAfter: HostTheme): string | null {\n const background = effectiveThemeColor(themeAfter, 'dark', 'background.default')\n if (!background) return null\n try {\n return accessibleShade(light, [background], 'lighten', { minContrast: CONTRAST_AA_LARGE })\n } catch {\n return null\n }\n}\n\n/* ------------------------------------------------------------------------ *\n * Contrast\n * ------------------------------------------------------------------------ */\n\n/** A foreground that has to read on each of its backgrounds. */\nexport interface AiThemeContrastPair {\n foreground: ThemeColorToken\n backgrounds: readonly ThemeColorToken[]\n required: number\n}\n\n/**\n * The pairs a proposal is held to. Body text on the page and on paper, and\n * secondary text on the page, are the pairs the theme publish check\n * (`validateThemeForPublish`) measures, at its bars; the primary color on\n * the page is held to the bar a fill or an indicator owes.\n */\nexport const AI_THEME_CONTRAST_PAIRS: readonly AiThemeContrastPair[] = [\n {\n foreground: 'text.primary',\n backgrounds: ['background.default', 'background.paper'],\n required: CONTRAST_AA,\n },\n {\n foreground: 'text.secondary',\n backgrounds: ['background.default'],\n required: CONTRAST_AA,\n },\n {\n foreground: 'primary',\n backgrounds: ['background.default'],\n required: CONTRAST_AA_LARGE,\n },\n]\n\nconst round2 = (ratio: number) => Math.round(ratio * 100) / 100\n\n/**\n * Whether dark ink reads better than light ink on a background. A hex takes\n * the shared helper; anything else a theme can hold (`rgba()`) is measured\n * against black and white directly, which is the same comparison.\n */\nfunction darkInkReads(background: string): boolean {\n const verdict = prefersDarkInk(background)\n if (verdict !== null) return verdict\n return (contrastRatio('#000000', background) ?? 0) >= (contrastRatio('#ffffff', background) ?? 0)\n}\n\nexport interface AiThemeContrastResult {\n theme: HostTheme\n corrections: AiThemeCorrection[]\n notes: string[]\n}\n\n/**\n * Every pair a set of changes takes below its bar, corrected to the nearest\n * shade of its foreground that clears it, and named.\n *\n * Only pairs the changes touched are corrected. A pair that already fell\n * short with neither of its colors changed is named in `notes` and left\n * alone, because correcting it would change a color the brief did not ask\n * about. A dark scheme the site has switched off is not measured: no visitor\n * sees it.\n */\nexport function correctAiThemeContrast(\n themeAfter: HostTheme,\n touchedChanges: ReadonlyArray<Pick<AiThemeControlChange, 'control' | 'scheme'>>,\n): AiThemeContrastResult {\n const touched = new Set(\n touchedChanges\n .filter((change) => aiThemeColorToken(change.control))\n .map((change) =>\n colorKey(change.scheme ?? 'light', aiThemeColorToken(change.control) as ThemeColorToken),\n ),\n )\n const schemes = THEME_EDITOR_SCHEMES.filter(\n (scheme) => scheme === 'light' || readDarkScheme(themeAfter) !== 'off',\n )\n let theme = themeAfter\n const corrections: AiThemeCorrection[] = []\n const notes: string[] = []\n for (const scheme of schemes) {\n for (const pair of AI_THEME_CONTRAST_PAIRS) {\n const foreground = effectiveThemeColor(theme, scheme, pair.foreground)\n const backgrounds = pair.backgrounds\n .map((token) => effectiveThemeColor(theme, scheme, token))\n .filter((value): value is string => typeof value === 'string')\n if (!foreground || backgrounds.length !== pair.backgrounds.length) continue\n const ratios = backgrounds.map((background) => contrastRatio(foreground, background))\n if (ratios.some((ratio) => ratio === null)) continue\n const worst = Math.min(...(ratios as number[]))\n if (worst >= pair.required) continue\n const involved = [pair.foreground, ...pair.backgrounds].some((token) =>\n touched.has(colorKey(scheme, token)),\n )\n if (!involved) {\n notes.push(\n `${pair.foreground} on ${pair.backgrounds.join(' and ')} in ${scheme} was already ` +\n `${round2(worst)}:1 before this proposal, below ${pair.required}:1.`,\n )\n continue\n }\n let corrected: string\n try {\n corrected = accessibleShade(\n foreground,\n backgrounds,\n darkInkReads(backgrounds[0]) ? 'darken' : 'lighten',\n { minContrast: pair.required },\n )\n } catch {\n continue\n }\n const clears = backgrounds.every(\n (background) => (contrastRatio(corrected, background) ?? 0) >= pair.required,\n )\n if (!clears) {\n notes.push(\n `${pair.foreground} cannot reach ${pair.required}:1 on the ${scheme} background by ` +\n 'changing its shade alone; the background needs to change too.',\n )\n continue\n }\n corrections.push({\n control: `color.${pair.foreground}`,\n scheme,\n from: readThemeColor(theme, scheme, pair.foreground) ?? null,\n to: corrected,\n reason: 'contrast',\n against: backgrounds,\n ratio: round2(worst),\n required: pair.required,\n })\n theme = writeThemeColor(theme, scheme, pair.foreground, corrected)\n }\n }\n return { theme, corrections, notes }\n}\n\n/** Folds a correction into a change list: the change it corrects, or a new one. */\nfunction withCorrection(\n changes: AiThemeControlChange[],\n correction: AiThemeCorrection,\n base: HostTheme | undefined,\n): AiThemeControlChange[] {\n const index = changes.findIndex(\n (change) => change.control === correction.control && change.scheme === correction.scheme,\n )\n if (index >= 0) {\n return changes.map((change, at) => (at === index ? { ...change, value: correction.to } : change))\n }\n return [\n ...changes,\n {\n control: correction.control,\n scheme: correction.scheme,\n value: correction.to,\n before: readAiThemeControl(base, correction.control, correction.scheme),\n },\n ]\n}\n\n/* ------------------------------------------------------------------------ *\n * Building a proposal\n * ------------------------------------------------------------------------ */\n\nexport interface BuildAiThemeProposalInput {\n /** The site's theme as the editor shows it, overrides resolved. */\n base: HostTheme | undefined\n source: HostThemeSource\n mode: AiThemeProposalMode\n brief: string\n summary: string\n changes: ReadonlyArray<Pick<AiThemeControlChange, 'control' | 'scheme' | 'value'>>\n components: readonly ThemeComponentOverrideLeaf[]\n resetComponents: boolean\n /** What reading the model's answer already left out, in words. */\n dropped?: readonly string[]\n notes?: readonly string[]\n}\n\n/**\n * A proposal from what the model proposed, held to the editor and to the\n * doctrine: changes that change nothing are gone, a modify brief reaches\n * only the parts of the theme it names, accents keep a dark value, and every\n * pair the proposal touches clears its contrast bar.\n */\nexport function buildAiThemeProposal(input: BuildAiThemeProposalInput): AiThemeProposal {\n const dropped = [...(input.dropped ?? [])]\n const notes = [...(input.notes ?? [])]\n const scope = aiThemeBriefScope(input.brief, input.mode)\n const outOfScope = (group: AiThemeChangeGroup, what: string) => {\n dropped.push(`${what}: the brief did not ask about ${GROUP_WORDS[group]}`)\n }\n\n let changes: AiThemeControlChange[] = []\n for (const change of input.changes) {\n const before = readAiThemeControl(input.base, change.control, change.scheme)\n if (before === change.value) continue\n const group = aiThemeControlGroup(change.control)\n if (!scope.has(group)) {\n outOfScope(group, change.scheme ? `${change.control} (${change.scheme})` : change.control)\n continue\n }\n changes.push({ ...change, before })\n }\n const components = input.components.filter((leaf) => {\n const group = aiThemeComponentGroup(leaf.component)\n if (scope.has(group)) return true\n outOfScope(group, `${leaf.component}.${leaf.property}`)\n return false\n })\n let resetComponents = input.resetComponents\n if (resetComponents && !scope.has('components')) {\n outOfScope('components', 'Resetting the component overrides')\n resetComponents = false\n }\n\n const corrections: AiThemeCorrection[] = []\n let after = applyAiThemeChanges(input.base, { changes, components, resetComponents })\n for (const token of aiThemeMissingDarkValues(changes, after)) {\n const light = changes.find(\n (change) => change.scheme === 'light' && aiThemeColorToken(change.control) === token,\n )\n if (!ACCENT_TOKENS.has(token) || typeof light?.value !== 'string') {\n notes.push(`${token} keeps its current dark value; only its light value changes.`)\n continue\n }\n const dark = deriveAiThemeDarkAccent(light.value, after)\n if (!dark) continue\n const correction: AiThemeCorrection = {\n control: `color.${token}`,\n scheme: 'dark',\n from: readThemeColor(input.base, 'dark', token) ?? null,\n to: dark,\n reason: 'dark-value',\n }\n corrections.push(correction)\n changes = withCorrection(changes, correction, input.base)\n after = writeThemeColor(after, 'dark', token, dark)\n }\n\n const contrast = correctAiThemeContrast(after, changes)\n for (const correction of contrast.corrections) {\n corrections.push(correction)\n changes = withCorrection(changes, correction, input.base)\n }\n notes.push(...contrast.notes)\n\n return {\n version: AI_THEME_PROPOSAL_VERSION,\n mode: input.mode,\n summary: input.summary,\n source: input.source,\n changes,\n components,\n resetComponents,\n corrections,\n dropped,\n notes,\n }\n}\n\n/**\n * What applying a proposal to the site's CURRENT theme produces, held to the\n * contrast bars again: the theme may have changed since the proposal was\n * made, and a proposal that cleared its bars against the old background can\n * fall short against the new one. The corrections this makes are named\n * beside the proposal's own.\n */\nexport function aiThemeProposalAfter(\n theme: HostTheme | undefined,\n proposal: Pick<AiThemeProposal, 'changes' | 'components' | 'resetComponents'>,\n): AiThemeContrastResult {\n const applied = applyAiThemeChanges(theme, proposal)\n return correctAiThemeContrast(applied, proposal.changes)\n}\n\n/** The changes whose `before` no longer matches the theme a proposal is applied to. */\nexport function aiThemeStaleChanges(\n theme: HostTheme | undefined,\n proposal: Pick<AiThemeProposal, 'changes'>,\n): AiThemeControlChange[] {\n return proposal.changes.filter(\n (change) => readAiThemeControl(theme, change.control, change.scheme) !== change.before,\n )\n}\n\n/* ------------------------------------------------------------------------ *\n * Reading a stored proposal back\n * ------------------------------------------------------------------------ */\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst strings = (value: unknown): string[] =>\n Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : []\n\nconst scalar = (value: unknown): string | number | null =>\n typeof value === 'string' || typeof value === 'number' ? value : null\n\nconst VALUE_CONTROLS: ReadonlySet<string> = new Set(AI_THEME_VALUE_CONTROLS)\n\n/**\n * A proposal as a job output stores it, or `null` for anything that is not\n * one. The job writes these through the Admin SDK and nothing else can, but\n * a reader that applies what it reads to a theme checks the shape first.\n */\nexport function readAiThemeProposal(value: unknown): AiThemeProposal | null {\n if (!isRecord(value) || value['version'] !== AI_THEME_PROPOSAL_VERSION) return null\n const mode = value['mode'] === 'create' ? 'create' : 'modify'\n const source =\n value['source'] === 'installed' || value['source'] === 'custom' ? value['source'] : 'default'\n const changes = (Array.isArray(value['changes']) ? value['changes'] : [])\n .filter(isRecord)\n .filter((change) => VALUE_CONTROLS.has(String(change['control'])))\n .map(\n (change): AiThemeControlChange => ({\n control: change['control'] as AiThemeValueControl,\n scheme: change['scheme'] === 'light' || change['scheme'] === 'dark' ? change['scheme'] : null,\n value: scalar(change['value']),\n before: scalar(change['before']),\n }),\n )\n const components = (Array.isArray(value['components']) ? value['components'] : [])\n .filter(isRecord)\n .filter(\n (leaf) =>\n (THEME_EDITOR_CONTROLS.find((control) => control.id === 'components')?.options ?? []).includes(\n String(leaf['component']),\n ) &&\n (leaf['target'] === 'styleOverrides' || leaf['target'] === 'defaultProps') &&\n typeof leaf['property'] === 'string' &&\n ['string', 'number', 'boolean'].includes(typeof leaf['value']) &&\n (leaf['media'] === null || String(leaf['media']) in THEME_EDITOR_MEDIA_QUERIES),\n )\n .map(\n (leaf): ThemeComponentOverrideLeaf => ({\n component: leaf['component'] as ThemeComponentOverrideLeaf['component'],\n target: leaf['target'] as ThemeComponentOverrideLeaf['target'],\n slot: typeof leaf['slot'] === 'string' ? leaf['slot'] : null,\n property: leaf['property'] as string,\n media: (leaf['media'] as ThemeComponentOverrideLeaf['media']) ?? null,\n value: leaf['value'] as string | number | boolean,\n }),\n )\n const corrections = (Array.isArray(value['corrections']) ? value['corrections'] : [])\n .filter(isRecord)\n .filter(\n (correction) =>\n aiThemeColorToken(String(correction['control'])) !== null &&\n (correction['scheme'] === 'light' || correction['scheme'] === 'dark') &&\n typeof correction['to'] === 'string',\n )\n .map(\n (correction): AiThemeCorrection => ({\n control: correction['control'] as AiThemeCorrection['control'],\n scheme: correction['scheme'] as HostThemeScheme,\n from: typeof correction['from'] === 'string' ? correction['from'] : null,\n to: correction['to'] as string,\n reason: correction['reason'] === 'dark-value' ? 'dark-value' : 'contrast',\n ...(Array.isArray(correction['against']) ? { against: strings(correction['against']) } : {}),\n ...(typeof correction['ratio'] === 'number' ? { ratio: correction['ratio'] } : {}),\n ...(typeof correction['required'] === 'number' ? { required: correction['required'] } : {}),\n }),\n )\n return {\n version: AI_THEME_PROPOSAL_VERSION,\n mode,\n summary: typeof value['summary'] === 'string' ? value['summary'] : '',\n source,\n changes,\n components,\n resetComponents: value['resetComponents'] === true,\n corrections,\n dropped: strings(value['dropped']),\n notes: strings(value['notes']),\n }\n}\n"],"names":["CONTRAST_AA","CONTRAST_AA_LARGE","contrastRatio","accessibleShade","inheritedThemeColor","readDarkScheme","readFontFamily","readThemeColor","readToolbarHeight","resetComponentOverrides","SYSTEM_FONT_VALUE","THEME_COLOR_FIELDS","THEME_EDITOR_CONTROLS","THEME_EDITOR_MEDIA_QUERIES","THEME_EDITOR_SCHEMES","writeBorderRadius","writeComponentOverride","writeDarkScheme","writeFontFamily","writeSpacing","writeThemeColor","writeToolbarHeight","prefersDarkInk","AI_THEME_PROPOSAL_VERSION","AI_THEME_PROPOSAL_MODES","AI_THEME_CHANGE_GROUPS","AI_THEME_VALUE_CONTROLS","filter","control","id","map","aiThemeColorToken","startsWith","slice","length","readAiThemeControl","theme","scheme","token","family","shape","borderRadius","spacing","applyControlChange","change","value","undefined","number","applyAiThemeChanges","proposal","next","changes","resetComponents","leaf","components","aiThemeControlGroup","aiThemeComponentGroup","component","BRIEF_VOCABULARY","color","darkScheme","typography","navigation","aiThemeBriefScope","brief","mode","Set","named","group","test","GROUP_WORDS","colorKey","effectiveThemeColor","ACCENT_TOKENS","field","aiThemeMissingDarkValues","themeAfter","set","has","deriveAiThemeDarkAccent","light","background","minContrast","AI_THEME_CONTRAST_PAIRS","foreground","backgrounds","required","round2","ratio","Math","round","darkInkReads","verdict","correctAiThemeContrast","touchedChanges","touched","schemes","corrections","notes","pair","ratios","some","worst","min","involved","push","join","corrected","clears","every","from","to","reason","against","withCorrection","correction","base","index","findIndex","at","before","buildAiThemeProposal","input","dropped","scope","outOfScope","what","property","after","find","dark","contrast","version","summary","source","aiThemeProposalAfter","applied","aiThemeStaleChanges","isRecord","Array","isArray","strings","entry","scalar","VALUE_CONTROLS","readAiThemeProposal","String","options","includes","target","slot","media"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,WAAW,EACXC,iBAAiB,EACjBC,aAAa,QAER,2CAA0C;AAEjD,SAASC,eAAe,QAAQ,+CAA8C;AAC9E,SAASC,mBAAmB,QAAQ,oDAAmD;AACvF,SACEC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,iBAAiB,EACjBC,uBAAuB,EACvBC,iBAAiB,EACjBC,kBAAkB,EAClBC,qBAAqB,EACrBC,0BAA0B,EAC1BC,oBAAoB,EACpBC,iBAAiB,EACjBC,sBAAsB,EACtBC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,eAAe,EACfC,kBAAkB,QAIb,kDAAiD;AACxD,SAASC,cAAc,QAAQ,oCAAmC;AAElE;;;;;;;;;;;;CAYC,GAED,OAAO,MAAMC,4BAA4B,EAAC;AAQ1C,OAAO,MAAMC,0BAA0D;IAAC;IAAU;CAAS,CAAA;AAY3F,OAAO,MAAMC,yBAAwD;IACnE;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAKD,oDAAoD,GACp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