@koda-sl/baker-cli 0.571.0-dev.6a3439a0a → 0.572.0-dev.61ba69c66

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 (1567) hide show
  1. package/README.md +7 -5
  2. package/dist/account-6RJ6ZI3B.js +82 -0
  3. package/dist/account-AIGNJ2RP.js +82 -0
  4. package/dist/account-E5LLPRZ6.js +139 -0
  5. package/dist/account-assets-J6SVHSXR.js +290 -0
  6. package/dist/account-level-FGE33OJT.js +612 -0
  7. package/dist/account-level-FGE33OJT.js.map +1 -0
  8. package/dist/account-reads-BNVCJ37E.js +220 -0
  9. package/dist/account-reads-BNVCJ37E.js.map +1 -0
  10. package/dist/account-users-MFH5CJIA.js +65 -0
  11. package/dist/account-users-MFH5CJIA.js.map +1 -0
  12. package/dist/account-writes-XNS4IKZV.js +68 -0
  13. package/dist/accounts-3ZWYGRVM.js +80 -0
  14. package/dist/accounts-5TLHSEZR.js +119 -0
  15. package/dist/accounts-BAZYYDFV.js +713 -0
  16. package/dist/accounts-L2HVNJUF.js +76 -0
  17. package/dist/accounts-NTBIRB52.js +115 -0
  18. package/dist/actions-N2FBJMT4.js +55 -0
  19. package/dist/active-entities-IJPRN45K.js +103 -0
  20. package/dist/activecampaign-U77COT2F.js +938 -0
  21. package/dist/activities-SS3SUWSS.js +75 -0
  22. package/dist/ad-group-writes-DTQSUNE2.js +172 -0
  23. package/dist/ad-groups-CX23GLVE.js +70 -0
  24. package/dist/ad-writes-HAAUOJCG.js +176 -0
  25. package/dist/add-ABPQTO2M.js +305 -0
  26. package/dist/add-BK6N7KWU.js +97 -0
  27. package/dist/add-ECN2FTMH.js +85 -0
  28. package/dist/add-FH7OVKFF.js +148 -0
  29. package/dist/add-KHY3H54G.js +81 -0
  30. package/dist/add-MZZLFU3M.js +513 -0
  31. package/dist/add-MZZLFU3M.js.map +1 -0
  32. package/dist/add-VDH2VCXR.js +107 -0
  33. package/dist/add-accounts-6JAOSCXK.js +91 -0
  34. package/dist/ads-BEMEXBDJ.js +128 -0
  35. package/dist/ads-GAU2XKNL.js +48 -0
  36. package/dist/ads-HZOXZ3FY.js +79 -0
  37. package/dist/ads-I5OBZ5VI.js +120 -0
  38. package/dist/adsets-PMQGA6TW.js +182 -0
  39. package/dist/advertisers-EOLL3VFQ.js +123 -0
  40. package/dist/advertisers-FNKY2PP4.js +125 -0
  41. package/dist/analytics-DOAUCF2Y.js +2437 -0
  42. package/dist/analytics-MR3T34KN.js +447 -0
  43. package/dist/animate-EKGVDSWM.js +480 -0
  44. package/dist/approved-WQL4Z4EB.js +73 -0
  45. package/dist/asset-writes-A5X2T6LQ.js +51 -0
  46. package/dist/assign-UMNHINRA.js +80 -0
  47. package/dist/audience-size-Q7DZ6TGM.js +76 -0
  48. package/dist/audience-writes-SNFFF2QR.js +328 -0
  49. package/dist/audience-writes-SNFFF2QR.js.map +1 -0
  50. package/dist/audiences-HBJGEGKL.js +106 -0
  51. package/dist/audiences-RDQZNGPI.js +280 -0
  52. package/dist/audiences-TA636UBN.js +85 -0
  53. package/dist/audit-H3F6FZNE.js +154 -0
  54. package/dist/audit-QMCK76AT.js +88 -0
  55. package/dist/autocomplete-DIBJ57VC.js +114 -0
  56. package/dist/avatars-UIXRGLPA.js +38 -0
  57. package/dist/bid-pricing-OMY2F2SB.js +103 -0
  58. package/dist/brand-WV6CAU3M.js +22 -0
  59. package/dist/brief-PNBP56X2.js +543 -0
  60. package/dist/brief-PNBP56X2.js.map +1 -0
  61. package/dist/businesses-56IUB5X4.js +54 -0
  62. package/dist/campaign-groups-PGJIQV4S.js +99 -0
  63. package/dist/campaign-writes-MAJ5FGXG.js +176 -0
  64. package/dist/campaign-writes-WL3YAEGJ.js +168 -0
  65. package/dist/campaigns-5L4ZTGF7.js +130 -0
  66. package/dist/campaigns-EK7EUKZD.js +113 -0
  67. package/dist/campaigns-HCJ3AIDK.js +78 -0
  68. package/dist/campaigns-NHACWGWS.js +111 -0
  69. package/dist/canvas-INL3J7HO.js +46 -0
  70. package/dist/capabilities-Y33EWDMJ.js +147 -0
  71. package/dist/cards-IWWKA5WH.js +85 -0
  72. package/dist/catalog-NSA2FUI2.js +66 -0
  73. package/dist/catalogs-QOE2V4QK.js +783 -0
  74. package/dist/catalogs-QOE2V4QK.js.map +1 -0
  75. package/dist/catalogs-SJMYID7N.js +130 -0
  76. package/dist/changes-2HOF2HSV.js +167 -0
  77. package/dist/chatgpt-J6MNVQVT.js +47 -0
  78. package/dist/chats-4HK6UYD2.js +584 -0
  79. package/dist/check-DJOIL56P.js +169 -0
  80. package/dist/check-DJOIL56P.js.map +1 -0
  81. package/dist/chunk-2B2JFTWI.js +296 -0
  82. package/dist/chunk-2HWX6AWY.js +2235 -0
  83. package/dist/chunk-2HWX6AWY.js.map +1 -0
  84. package/dist/chunk-2O5CCKV7.js +23 -0
  85. package/dist/chunk-2W6DMVGH.js +8954 -0
  86. package/dist/chunk-2W6DMVGH.js.map +1 -0
  87. package/dist/chunk-3BKESS5W.js +66 -0
  88. package/dist/chunk-3VBPJQ7L.js +288 -0
  89. package/dist/chunk-3X262BEG.js +19 -0
  90. package/dist/chunk-4CUBOXBS.js +99 -0
  91. package/dist/chunk-4CUBOXBS.js.map +1 -0
  92. package/dist/chunk-4CYB33V3.js +136 -0
  93. package/dist/chunk-4JB556VC.js +142 -0
  94. package/dist/chunk-4LZNCDHU.js +46 -0
  95. package/dist/chunk-4LZNCDHU.js.map +1 -0
  96. package/dist/chunk-4QYZJPSM.js +207 -0
  97. package/dist/chunk-4WLJYLRL.js +544 -0
  98. package/dist/chunk-55AX6DOP.js +86 -0
  99. package/dist/chunk-55AX6DOP.js.map +1 -0
  100. package/dist/chunk-56ZJO7TM.js +1320 -0
  101. package/dist/chunk-5LQGW5UF.js +138 -0
  102. package/dist/chunk-5U6OL4NN.js +709 -0
  103. package/dist/chunk-6IL7JFX5.js +203 -0
  104. package/dist/chunk-6LNCKT6S.js +35 -0
  105. package/dist/chunk-6LUDG5AB.js +476 -0
  106. package/dist/chunk-6UQV5DOD.js +45 -0
  107. package/dist/chunk-6V4UAC5I.js +2523 -0
  108. package/dist/chunk-6V4UAC5I.js.map +1 -0
  109. package/dist/chunk-6WA7QSCN.js +46 -0
  110. package/dist/chunk-7CHPHER2.js +455 -0
  111. package/dist/chunk-7J7ASYIM.js +225 -0
  112. package/dist/chunk-7MMTIJO3.js +220 -0
  113. package/dist/chunk-7Y3LKR4P.js +5368 -0
  114. package/dist/chunk-7Y3LKR4P.js.map +1 -0
  115. package/dist/chunk-AA3D7GZF.js +125 -0
  116. package/dist/chunk-AGL7EWP2.js +75 -0
  117. package/dist/chunk-AHVD6IEI.js +76 -0
  118. package/dist/chunk-ASJMLTMX.js +106 -0
  119. package/dist/chunk-AWENMEFC.js +297 -0
  120. package/dist/chunk-AYX7PB2L.js +1920 -0
  121. package/dist/chunk-AYX7PB2L.js.map +1 -0
  122. package/dist/chunk-BHZLKLK7.js +69 -0
  123. package/dist/chunk-BVER7I36.js +58 -0
  124. package/dist/chunk-C3RZNVLM.js +98 -0
  125. package/dist/chunk-CA5QBLIZ.js +114 -0
  126. package/dist/chunk-CKIENAAO.js +156 -0
  127. package/dist/chunk-CKIENAAO.js.map +1 -0
  128. package/dist/chunk-CONTVNSN.js +51 -0
  129. package/dist/chunk-EE6NZ6NG.js +225 -0
  130. package/dist/chunk-EG6HMBCF.js +188 -0
  131. package/dist/chunk-EGZM35HT.js +3510 -0
  132. package/dist/chunk-EGZM35HT.js.map +1 -0
  133. package/dist/chunk-ESSA3AWR.js +133 -0
  134. package/dist/chunk-ESSA3AWR.js.map +1 -0
  135. package/dist/chunk-FHLAJYZE.js +225 -0
  136. package/dist/chunk-FSNQFZ2Z.js +718 -0
  137. package/dist/chunk-G67OBCXI.js +91 -0
  138. package/dist/chunk-GFYGVIT3.js +392 -0
  139. package/dist/chunk-GRNHQWSV.js +430 -0
  140. package/dist/chunk-GWQSZWHT.js +42 -0
  141. package/dist/chunk-HBXR26LB.js +1518 -0
  142. package/dist/chunk-HKKHOMEQ.js +180 -0
  143. package/dist/chunk-HKKHOMEQ.js.map +1 -0
  144. package/dist/chunk-HUO5MZ7S.js +962 -0
  145. package/dist/chunk-HVL22WUU.js +930 -0
  146. package/dist/chunk-IA5GLVRV.js +64 -0
  147. package/dist/chunk-IEPCI2EB.js +479 -0
  148. package/dist/chunk-IKSBLQTL.js +5471 -0
  149. package/dist/chunk-IRLMIKI7.js +224 -0
  150. package/dist/chunk-IW4MX7OX.js +399 -0
  151. package/dist/chunk-J4WOF6WK.js +97 -0
  152. package/dist/chunk-J63TN3GR.js +89 -0
  153. package/dist/chunk-JESSFI7R.js +468 -0
  154. package/dist/chunk-K4QPBXV7.js +61 -0
  155. package/dist/chunk-K5VDDKKF.js +219 -0
  156. package/dist/chunk-KM5K47TW.js +152 -0
  157. package/dist/chunk-KPVZ2CZA.js +642 -0
  158. package/dist/chunk-KPVZ2CZA.js.map +1 -0
  159. package/dist/chunk-LGJIJVVH.js +131 -0
  160. package/dist/chunk-LHSSIUU4.js +604 -0
  161. package/dist/chunk-LQMPA4DY.js +685 -0
  162. package/dist/chunk-M3IXPK6U.js +344 -0
  163. package/dist/chunk-MJU5VKX2.js +91 -0
  164. package/dist/chunk-MRGU3NPN.js +163 -0
  165. package/dist/chunk-MSLFPL77.js +454 -0
  166. package/dist/chunk-MX5NQAK6.js +54 -0
  167. package/dist/chunk-MX5NQAK6.js.map +1 -0
  168. package/dist/chunk-NKCWJPMN.js +111 -0
  169. package/dist/chunk-NT7NCSEB.js +24026 -0
  170. package/dist/chunk-O5GZJ6YJ.js +1085 -0
  171. package/dist/chunk-O5GZJ6YJ.js.map +1 -0
  172. package/dist/chunk-OADMSHME.js +334 -0
  173. package/dist/chunk-OGWCLE4W.js +858 -0
  174. package/dist/chunk-OGWCLE4W.js.map +1 -0
  175. package/dist/chunk-ONGZKI5J.js +57 -0
  176. package/dist/chunk-OOZNTJP6.js +26 -0
  177. package/dist/chunk-OP3NHIFH.js +39 -0
  178. package/dist/chunk-OU4KWL6B.js +106 -0
  179. package/dist/chunk-OW3D63SI.js +91 -0
  180. package/dist/chunk-OW3D63SI.js.map +1 -0
  181. package/dist/chunk-PLIGHRIQ.js +312 -0
  182. package/dist/chunk-PLROJ3SX.js +73 -0
  183. package/dist/chunk-PSM3RI4B.js +167 -0
  184. package/dist/chunk-Q4O7ICAK.js +84 -0
  185. package/dist/chunk-Q6XM6ZDB.js +547 -0
  186. package/dist/chunk-QHRUCSRI.js +197 -0
  187. package/dist/chunk-QUDPMIW7.js +74 -0
  188. package/dist/chunk-R2JGUOT6.js +64 -0
  189. package/dist/chunk-R5I4IHJ5.js +494 -0
  190. package/dist/chunk-R5NABIJ4.js +1919 -0
  191. package/dist/chunk-R5NABIJ4.js.map +1 -0
  192. package/dist/chunk-RJXO66C4.js +66 -0
  193. package/dist/chunk-RYNN6UUF.js +69 -0
  194. package/dist/chunk-S4V2GOKV.js +215 -0
  195. package/dist/chunk-S7D4GTYY.js +191 -0
  196. package/dist/chunk-T4RV7XOC.js +217 -0
  197. package/dist/chunk-TDUAGNSQ.js +52 -0
  198. package/dist/chunk-TZRWET3S.js +285 -0
  199. package/dist/chunk-U5V4CIIG.js +274 -0
  200. package/dist/chunk-U625CQ3Y.js +287 -0
  201. package/dist/chunk-UDEVIXKX.js +1254 -0
  202. package/dist/chunk-UNLFRXST.js +126 -0
  203. package/dist/chunk-UNLFRXST.js.map +1 -0
  204. package/dist/chunk-UUDWZIDC.js +246 -0
  205. package/dist/chunk-VAQBBNLD.js +98 -0
  206. package/dist/chunk-VCDFBFPT.js +97 -0
  207. package/dist/chunk-VF3W7CI7.js +325 -0
  208. package/dist/chunk-VHOOAQY4.js +169 -0
  209. package/dist/chunk-VK2VC6A2.js +25 -0
  210. package/dist/chunk-WWPRSJOS.js +94 -0
  211. package/dist/chunk-XKYFNMTB.js +343 -0
  212. package/dist/chunk-XL42ZEVH.js +170 -0
  213. package/dist/chunk-XPUQFPIU.js +831 -0
  214. package/dist/chunk-XQEHLDGP.js +1744 -0
  215. package/dist/chunk-XQWC223L.js +56 -0
  216. package/dist/chunk-XYDHBLZ2.js +103 -0
  217. package/dist/chunk-XZO6ONVI.js +115 -0
  218. package/dist/chunk-YFFQ3HY4.js +139 -0
  219. package/dist/chunk-YGUGL4ZL.js +76 -0
  220. package/dist/chunk-YOHGEF2N.js +7899 -0
  221. package/dist/chunk-YOHGEF2N.js.map +1 -0
  222. package/dist/chunk-YT3S2XFG.js +84 -0
  223. package/dist/chunk-ZPCZ4XDB.js +148 -0
  224. package/dist/cite-2ZJG3FBV.js +191 -0
  225. package/dist/claim-IGU5W4CT.js +200 -0
  226. package/dist/cli.js +48 -47
  227. package/dist/cli.js.map +1 -1
  228. package/dist/client-MSRCSDB7.js +19 -0
  229. package/dist/code-T7Z5JDQ2.js +76 -0
  230. package/dist/companies-HCSBVXCE.js +198 -0
  231. package/dist/company-SSMY4G2T.js +308 -0
  232. package/dist/complete-FQNRXUI5.js +84 -0
  233. package/dist/config-XRPKA5QR.js +88 -0
  234. package/dist/connect-VXEE3QBU.js +45 -0
  235. package/dist/content-2JFP747N.js +85 -0
  236. package/dist/conversation-KKJKZIX5.js +96 -0
  237. package/dist/conversion-report-G65UHQRO.js +127 -0
  238. package/dist/conversion-upload-command-Z7IOS6ZG.js +440 -0
  239. package/dist/conversion-upload-command-Z7IOS6ZG.js.map +1 -0
  240. package/dist/conversion-writes-333V4OVR.js +122 -0
  241. package/dist/conversions-7UHCNIAO.js +140 -0
  242. package/dist/conversions-L6775Q22.js +78 -0
  243. package/dist/copy-writes-G7GJ5RWS.js +171 -0
  244. package/dist/copy-writes-G7GJ5RWS.js.map +1 -0
  245. package/dist/countries-XJVDM635.js +82 -0
  246. package/dist/create-AXWJECPP.js +239 -0
  247. package/dist/create-B24XHUGZ.js +62 -0
  248. package/dist/create-HJKTD5FN.js +218 -0
  249. package/dist/create-V4NGP5KB.js +135 -0
  250. package/dist/creatives-HLWMABYL.js +55 -0
  251. package/dist/creatives-HLWMABYL.js.map +1 -0
  252. package/dist/creatives-OKFLX67Y.js +118 -0
  253. package/dist/creatives-WX6GQ37F.js +229 -0
  254. package/dist/credentials-4JFUH6FN.js +290 -0
  255. package/dist/critique-4SF44VFJ.js +420 -0
  256. package/dist/critique-4SF44VFJ.js.map +1 -0
  257. package/dist/critique-S3PDXLAZ.js +233 -0
  258. package/dist/critique-S3PDXLAZ.js.map +1 -0
  259. package/dist/crm-6MLYUEK7.js +323 -0
  260. package/dist/crm-PUQBWZKE.js +229 -0
  261. package/dist/crop-V5MSIY5F.js +113 -0
  262. package/dist/currency-SCSJ5FW2.js +88 -0
  263. package/dist/custom-conversions-GN4JDS5F.js +128 -0
  264. package/dist/customers-WXD2LTUC.js +65 -0
  265. package/dist/decide-PW2NRMRK.js +199 -0
  266. package/dist/delete-EAJN6ZHT.js +67 -0
  267. package/dist/delete-GDIFIYA2.js +69 -0
  268. package/dist/delete-JQG3ZWQX.js +57 -0
  269. package/dist/delete-L7CGJ23X.js +71 -0
  270. package/dist/delete-OQREQEGN.js +85 -0
  271. package/dist/delete-ZR3DVLWU.js +69 -0
  272. package/dist/demographics-LMRGNO7J.js +141 -0
  273. package/dist/describe-OHWLLBDE.js +97 -0
  274. package/dist/describe-YELOXWHY.js +97 -0
  275. package/dist/dimensions-CLLCVVRY.js +101 -0
  276. package/dist/discard-K2KIIFJQ.js +69 -0
  277. package/dist/discover-SQJLRS4G.js +93 -0
  278. package/dist/discover-UJMDGDQO.js +172 -0
  279. package/dist/domain-CJX5JSLS.js +101 -0
  280. package/dist/download-HFDBP6BO.js +172 -0
  281. package/dist/download-SZ5P3GLV.js +337 -0
  282. package/dist/draft-7QDE2Z3N.js +315 -0
  283. package/dist/draft-A7ZQPUFS.js +579 -0
  284. package/dist/draft-A7ZQPUFS.js.map +1 -0
  285. package/dist/draft-ILXHFWTT.js +134 -0
  286. package/dist/draft-NUFU5YME.js +374 -0
  287. package/dist/draft-QSTD3DH2.js +220 -0
  288. package/dist/draft-TV5IH5U4.js +260 -0
  289. package/dist/draft-WNMHUFAH.js +138 -0
  290. package/dist/draft-XJP3SCZ6.js +333 -0
  291. package/dist/draft-XJP3SCZ6.js.map +1 -0
  292. package/dist/engine/index.js +14 -14
  293. package/dist/env-3256G2OE.js +53 -0
  294. package/dist/experiment-5L5USMAL.js +1397 -0
  295. package/dist/experiments-CFBG5UOT.js +237 -0
  296. package/dist/experiments-CFBG5UOT.js.map +1 -0
  297. package/dist/export-YSOM4E3B.js +168 -0
  298. package/dist/extract-7FYXXEQZ.js +143 -0
  299. package/dist/facets-2FRELYRC.js +117 -0
  300. package/dist/favorites-LTG2F6W2.js +178 -0
  301. package/dist/feed-RSBWEI75.js +177 -0
  302. package/dist/feedback-LZSJR5KL.js +116 -0
  303. package/dist/feedback-LZSJR5KL.js.map +1 -0
  304. package/dist/feedback-PQUM7UBT.js +114 -0
  305. package/dist/feedback-record-4MVI4O3Q.js +270 -0
  306. package/dist/feedback-record-4MVI4O3Q.js.map +1 -0
  307. package/dist/fetch-3PWYTX4R.js +139 -0
  308. package/dist/fetch-FLQYW27W.js +204 -0
  309. package/dist/find-SHHDWCPM.js +144 -0
  310. package/dist/fit-4XCDLF7C.js +65 -0
  311. package/dist/flows-4ALWJVNF.js +340 -0
  312. package/dist/follow-N4TKU3UM.js +94 -0
  313. package/dist/follow-competitors-AHQ57BWS.js +112 -0
  314. package/dist/following-CEYH33DW.js +113 -0
  315. package/dist/fonts-CYJ5EFR4.js +40 -0
  316. package/dist/forecast-AH3AFVJ7.js +170 -0
  317. package/dist/forecast-AH3AFVJ7.js.map +1 -0
  318. package/dist/forecast-SG2VUBZD.js +121 -0
  319. package/dist/funding-X7M5WLDX.js +85 -0
  320. package/dist/funnel-F7DS7PUN.js +397 -0
  321. package/dist/ga4-QPBAKGSH.js +55 -0
  322. package/dist/generate-LVBI3VDD.js +263 -0
  323. package/dist/get-DMV7KG2F.js +92 -0
  324. package/dist/get-EA7AX4NW.js +59 -0
  325. package/dist/get-EOSJWMWT.js +38 -0
  326. package/dist/get-HVQHHDW6.js +74 -0
  327. package/dist/get-KQLCVQCK.js +56 -0
  328. package/dist/get-NAOMB6Q2.js +62 -0
  329. package/dist/get-XYJBQFIT.js +62 -0
  330. package/dist/get-XZ7XPXZE.js +82 -0
  331. package/dist/gif-XJ26IWAP.js +111 -0
  332. package/dist/google-ED4VGLSX.js +3301 -0
  333. package/dist/google-ED4VGLSX.js.map +1 -0
  334. package/dist/google-QOKWSPOA.js +163 -0
  335. package/dist/google-ads-B4FBPQ7O.js +198 -0
  336. package/dist/group-7EYM3PNJ.js +43 -0
  337. package/dist/group-GDTEICRY.js +43 -0
  338. package/dist/gsc-KVIAZMF4.js +30 -0
  339. package/dist/history-22YGILIT.js +69 -0
  340. package/dist/history-E3JGYADF.js +102 -0
  341. package/dist/history-HKCSYH5L.js +153 -0
  342. package/dist/hubspot-LEW2RP5D.js +814 -0
  343. package/dist/icon-JLVEYF34.js +138 -0
  344. package/dist/ideas-JAIU4GC4.js +45 -0
  345. package/dist/images-ZG6RRAEP.js +92 -0
  346. package/dist/improve-XSHWCMZS.js +86 -0
  347. package/dist/ingest-GTXBGUNQ.js +28 -0
  348. package/dist/ingest-SX7K6GNE.js +131 -0
  349. package/dist/insights-IVUUWSQL.js +132 -0
  350. package/dist/insights-PJPQB46E.js +658 -0
  351. package/dist/inspect-55BXSPJG.js +192 -0
  352. package/dist/inspiration-NBOKHPZ5.js +53 -0
  353. package/dist/instant-experiences-ARST4KWB.js +265 -0
  354. package/dist/instant-experiences-ARST4KWB.js.map +1 -0
  355. package/dist/intent-KSVTHFFE.js +95 -0
  356. package/dist/job-4VXDCYSG.js +202 -0
  357. package/dist/job-create-NZEZDOZT.js +109 -0
  358. package/dist/job-status-XI3ENS7D.js +74 -0
  359. package/dist/keep-UYNOC3JZ.js +78 -0
  360. package/dist/keyword-gap-7UVDSID5.js +130 -0
  361. package/dist/keyword-metrics-QFRXZRAQ.js +200 -0
  362. package/dist/keywords-for-site-Q4BCJ4PQ.js +131 -0
  363. package/dist/knowledge-LVE3J3AK.js +195 -0
  364. package/dist/landing-AJYM5GBY.js +28 -0
  365. package/dist/landings-SIN3MTUZ.js +151 -0
  366. package/dist/languages-AIASAINW.js +40 -0
  367. package/dist/languages-RDR6EBNJ.js +55 -0
  368. package/dist/launches-4TVHXAZT.js +19 -0
  369. package/dist/layerize-OLVGZRND.js +190 -0
  370. package/dist/lead-routes-ZOQDPCR3.js +733 -0
  371. package/dist/leads-M57K5EDK.js +542 -0
  372. package/dist/leads-M57K5EDK.js.map +1 -0
  373. package/dist/leads-YSDLFBHN.js +115 -0
  374. package/dist/learn-FDQZNIP3.js +207 -0
  375. package/dist/library-7CLWRDM3.js +212 -0
  376. package/dist/lighthouse-3ACQ3MVG.js +75 -0
  377. package/dist/line-item-writes-JARN73DV.js +211 -0
  378. package/dist/line-items-B5GLDAJ2.js +107 -0
  379. package/dist/link-YAZF34BZ.js +67 -0
  380. package/dist/linkedin-MLPAY7IL.js +1345 -0
  381. package/dist/linkedin-MLPAY7IL.js.map +1 -0
  382. package/dist/linkedin-person-XDH7Q3PB.js +139 -0
  383. package/dist/list-6NYRZXKQ.js +76 -0
  384. package/dist/list-6WISGNQ2.js +65 -0
  385. package/dist/list-6YBIWX44.js +50 -0
  386. package/dist/list-72JQGWNO.js +154 -0
  387. package/dist/list-FX7OG3OJ.js +67 -0
  388. package/dist/list-ITPBLMV3.js +51 -0
  389. package/dist/list-J43GOBOX.js +57 -0
  390. package/dist/list-K4Z3BOWI.js +93 -0
  391. package/dist/list-ONSYTCX2.js +306 -0
  392. package/dist/locations-UNSREUBX.js +69 -0
  393. package/dist/locations-XAC3GME3.js +40 -0
  394. package/dist/log-PPNNFETI.js +95 -0
  395. package/dist/logo-UNVIMA4B.js +19 -0
  396. package/dist/lookup-L5QG3BWH.js +23 -0
  397. package/dist/make-YWW7Q4T5.js +1368 -0
  398. package/dist/make-YWW7Q4T5.js.map +1 -0
  399. package/dist/map-QILMIKS7.js +445 -0
  400. package/dist/mcp-GOKFM4PF.js +729 -0
  401. package/dist/media-BN6B75NF.js +18 -0
  402. package/dist/media-YDDWV32Y.js +89 -0
  403. package/dist/media-sources-HABLVJE3.js +35 -0
  404. package/dist/members-B4UI6ISY.js +47 -0
  405. package/dist/meme-2MERLAVW.js +108 -0
  406. package/dist/meta-7FJQD44L.js +124 -0
  407. package/dist/metrics-SBKBEZJR.js +152 -0
  408. package/dist/models-ZBLBNNEH.js +155 -0
  409. package/dist/normalize-5WVEQJXD.js +806 -0
  410. package/dist/normalize-YPQBHWYS.js +144 -0
  411. package/dist/older-spellings-KGYXGRHU.js +70 -0
  412. package/dist/older-spellings-KGYXGRHU.js.map +1 -0
  413. package/dist/options-BV3TVUCK.js +125 -0
  414. package/dist/organization-4OTGNRHP.js +949 -0
  415. package/dist/output-FX4KJAO5.js +24 -0
  416. package/dist/page-5KWQ7PM3.js +105 -0
  417. package/dist/page-photos-AUTUSCVR.js +119 -0
  418. package/dist/page-photos-AUTUSCVR.js.map +1 -0
  419. package/dist/pages-HKTAGXH3.js +67 -0
  420. package/dist/performance-4MWQVTTA.js +5565 -0
  421. package/dist/performance-TKE7NQF6.js +27 -0
  422. package/dist/pinterest-UDX53CWY.js +105 -0
  423. package/dist/pixels-BSNCVT77.js +109 -0
  424. package/dist/pixels-TR2PAYWV.js +62 -0
  425. package/dist/plan-V57AATQ5.js +208 -0
  426. package/dist/posts-JHMXNHDV.js +36 -0
  427. package/dist/preview-VY7UH2SK.js +245 -0
  428. package/dist/preview-XUG4K4KV.js +101 -0
  429. package/dist/profile-PV3R3BEG.js +159 -0
  430. package/dist/promoted-tweet-writes-O3S5OKUZ.js +183 -0
  431. package/dist/promoted-tweets-4ZKSEC4I.js +119 -0
  432. package/dist/properties-U2XUD2M6.js +101 -0
  433. package/dist/publish-4RAYD7VI.js +350 -0
  434. package/dist/query-4C6UQN42.js +62 -0
  435. package/dist/query-7FWE7GLV.js +231 -0
  436. package/dist/query-7Y2Y6YFI.js +236 -0
  437. package/dist/questionnaire-3IPJXJT7.js +94 -0
  438. package/dist/read-WEQLEI7R.js +141 -0
  439. package/dist/reddit-2FWCB7XY.js +29 -0
  440. package/dist/refresh-SGDB4QOD.js +97 -0
  441. package/dist/refresh-WZBVPKWE.js +42 -0
  442. package/dist/release-YL3ZII3Z.js +63 -0
  443. package/dist/relevant-pages-PF3LLUED.js +99 -0
  444. package/dist/remove-52MSQXSW.js +49 -0
  445. package/dist/remove-EIV7LJUA.js +53 -0
  446. package/dist/reopen-CW27MUJH.js +66 -0
  447. package/dist/rerun-4WUZY4SO.js +98 -0
  448. package/dist/rerun-4WUZY4SO.js.map +1 -0
  449. package/dist/research-234BOCKM.js +265 -0
  450. package/dist/research-RABLL4HR.js +75 -0
  451. package/dist/reset-5KJDDVJL.js +57 -0
  452. package/dist/reset-REUL47CB.js +57 -0
  453. package/dist/resolve-WRDEHLYL.js +124 -0
  454. package/dist/retry-2A5HV4SN.js +63 -0
  455. package/dist/retry-FNT2XVH3.js +65 -0
  456. package/dist/retry-failed-ND7UXYTJ.js +45 -0
  457. package/dist/revenue-YQV2BRGA.js +92 -0
  458. package/dist/revenue-YQV2BRGA.js.map +1 -0
  459. package/dist/rule-writes-L7BRELYW.js +531 -0
  460. package/dist/rule-writes-L7BRELYW.js.map +1 -0
  461. package/dist/rules-2CUG2YG7.js +217 -0
  462. package/dist/rules-5DIOAOOO.js +55 -0
  463. package/dist/rules-5DIOAOOO.js.map +1 -0
  464. package/dist/run-RKLNKV2U.js +73 -0
  465. package/dist/run-YKGN3GQR.js +69 -0
  466. package/dist/scaffold-ad-SPU2HKHU.js +1514 -0
  467. package/dist/scaffold-ad-SPU2HKHU.js.map +1 -0
  468. package/dist/scaffold-static-ad-ENGGU26W.js +1013 -0
  469. package/dist/scaffold-static-ad-ENGGU26W.js.map +1 -0
  470. package/dist/scaffold-video-OZHIU3SZ.js +886 -0
  471. package/dist/scaffold-video-OZHIU3SZ.js.map +1 -0
  472. package/dist/schedule-774JCRVM.js +67 -0
  473. package/dist/schedule-PKKSZ5RX.js +64 -0
  474. package/dist/scheduled-agents-ZI3EWKAT.js +55 -0
  475. package/dist/schema-BXNL4LKR.js +135 -0
  476. package/dist/schema-GFMVUZL2.js +152 -0
  477. package/dist/scrape-KKLE4WAU.js +2209 -0
  478. package/dist/screenshot-K6XOER6Z.js +103 -0
  479. package/dist/search-43ULIJL3.js +91 -0
  480. package/dist/search-AXUNJUWY.js +51 -0
  481. package/dist/search-DLLJEYMB.js +26 -0
  482. package/dist/search-LWWTXBB2.js +92 -0
  483. package/dist/search-VU6GI3U3.js +228 -0
  484. package/dist/search-XO365KES.js +177 -0
  485. package/dist/search-copy-BHNLLCUV.js +168 -0
  486. package/dist/seeds-6ROVZBFB.js +101 -0
  487. package/dist/select-4KMA72MV.js +111 -0
  488. package/dist/select-4KMA72MV.js.map +1 -0
  489. package/dist/sends-P6OPCYH5.js +349 -0
  490. package/dist/sequences-DP4BHM3E.js +146 -0
  491. package/dist/set-prompt-AII24NMX.js +200 -0
  492. package/dist/set-prompt-AII24NMX.js.map +1 -0
  493. package/dist/setup-links-T5TJZA3E.js +144 -0
  494. package/dist/shared-24IPELBM.js +32 -0
  495. package/dist/shopify-OQEKI7HC.js +4009 -0
  496. package/dist/site-QRLBZPEV.js +180 -0
  497. package/dist/sitemaps-SWADO4SI.js +77 -0
  498. package/dist/sites-H3FYJQFO.js +97 -0
  499. package/dist/skills-OYO6Y3DQ.js +47 -0
  500. package/dist/sources-U2WRH6D7.js +457 -0
  501. package/dist/sources-Y2BKZVXA.js +30 -0
  502. package/dist/stale-KE4K36UE.js +91 -0
  503. package/dist/stale-KE4K36UE.js.map +1 -0
  504. package/dist/stats-TTJHXR3E.js +34 -0
  505. package/dist/status-4BSXND3I.js +65 -0
  506. package/dist/sticker-CRIAIO75.js +103 -0
  507. package/dist/stock-TOFKLWSR.js +212 -0
  508. package/dist/studies-VFNWS6ND.js +250 -0
  509. package/dist/studio-WD364TWB.js +49 -0
  510. package/dist/study-writes-R7XYH3VH.js +472 -0
  511. package/dist/study-writes-R7XYH3VH.js.map +1 -0
  512. package/dist/suggest-GX4IROQN.js +66 -0
  513. package/dist/sync-BU7HU3FS.js +55 -0
  514. package/dist/sync-GQL5JX4U.js +57 -0
  515. package/dist/sync-VNBBOVBU.js +279 -0
  516. package/dist/sync-definition-EOARPSBS.js +71 -0
  517. package/dist/tag-SQ5ROLTP.js +57 -0
  518. package/dist/tag-manager-7S7PVYIJ.js +43 -0
  519. package/dist/tags-2226Q3VK.js +23 -0
  520. package/dist/tags-7QIBFIBX.js +227 -0
  521. package/dist/tags-BNWKAV3H.js +23 -0
  522. package/dist/tags-HG5EBHSO.js +23 -0
  523. package/dist/tags-WTN4EBT5.js +26 -0
  524. package/dist/targeting-SSI2F7XM.js +763 -0
  525. package/dist/targeting-SSI2F7XM.js.map +1 -0
  526. package/dist/targeting-constants-6KZXMRNI.js +118 -0
  527. package/dist/targeting-criteria-QSCRW75G.js +113 -0
  528. package/dist/targets-3KT3DO6O.js +106 -0
  529. package/dist/terms-IRLEAMIY.js +102 -0
  530. package/dist/testimonials-35FTFNQ5.js +32 -0
  531. package/dist/themes-WTMD2RE2.js +96 -0
  532. package/dist/themes-WTMD2RE2.js.map +1 -0
  533. package/dist/top-companies-JAWMSK2Q.js +111 -0
  534. package/dist/transcript-OIYU7F4E.js +165 -0
  535. package/dist/translate-S7ZQXQJH.js +604 -0
  536. package/dist/translate-S7ZQXQJH.js.map +1 -0
  537. package/dist/triggers-7QRQFTVM.js +144 -0
  538. package/dist/tweets-7XVF7PJO.js +123 -0
  539. package/dist/unfollow-ZCP6D2SC.js +46 -0
  540. package/dist/unlink-PYCYTYVN.js +70 -0
  541. package/dist/unstage-2OUF6ELM.js +88 -0
  542. package/dist/unstage-YADONHH6.js +96 -0
  543. package/dist/update-DEBDSBDI.js +81 -0
  544. package/dist/update-IDUSNDOI.js +192 -0
  545. package/dist/update-NG3HUYZZ.js +101 -0
  546. package/dist/update-P5IT7AIN.js +155 -0
  547. package/dist/update-U6NU7OXI.js +66 -0
  548. package/dist/upload-4F2JICEH.js +137 -0
  549. package/dist/upload-SS64KHDS.js +155 -0
  550. package/dist/upscale-JNNXDN6X.js +109 -0
  551. package/dist/url-options-EDPKAPPP.js +131 -0
  552. package/dist/url-params-4G26OEOO.js +101 -0
  553. package/dist/use-TKFP6WVP.js +111 -0
  554. package/dist/validate-HER6GMOZ.js +136 -0
  555. package/dist/validate-HER6GMOZ.js.map +1 -0
  556. package/dist/variant-3VTKOQUR.js +338 -0
  557. package/dist/videos-EDTBHLOZ.js +146 -0
  558. package/dist/videos-JRNJH66J.js +41 -0
  559. package/dist/view-6HX3FYMS.js +133 -0
  560. package/dist/viewer-check-OBBBAYV5.js +83 -0
  561. package/dist/web-GPUEUIDT.js +173 -0
  562. package/dist/winners-MEC77MZ4.js +113 -0
  563. package/dist/winning-ads-2DECFON4.js +86 -0
  564. package/dist/write-commands-AU2NJ4MR.js +1525 -0
  565. package/dist/write-commands-AU2NJ4MR.js.map +1 -0
  566. package/dist/write-commands-D5M5A4YI.js +721 -0
  567. package/dist/write-commands-LQVERLAQ.js +206 -0
  568. package/dist/write-commands-Y6U4WABA.js +1170 -0
  569. package/dist/write-commands-Y6U4WABA.js.map +1 -0
  570. package/dist/x-4TM5RET4.js +47 -0
  571. package/package.json +1 -1
  572. package/dist/account-EXGRZIXS.js +0 -82
  573. package/dist/account-JVDP5ERG.js +0 -82
  574. package/dist/account-NSBALYYS.js +0 -139
  575. package/dist/account-assets-EPEYTJFD.js +0 -290
  576. package/dist/account-level-VD4NLB2D.js +0 -611
  577. package/dist/account-level-VD4NLB2D.js.map +0 -1
  578. package/dist/account-reads-Z467VAL4.js +0 -219
  579. package/dist/account-reads-Z467VAL4.js.map +0 -1
  580. package/dist/account-users-342OZALE.js +0 -64
  581. package/dist/account-users-342OZALE.js.map +0 -1
  582. package/dist/account-writes-KEXINJ5D.js +0 -68
  583. package/dist/accounts-A47QUTTB.js +0 -76
  584. package/dist/accounts-E5TF2AFI.js +0 -115
  585. package/dist/accounts-QESGQJGZ.js +0 -713
  586. package/dist/accounts-QR6OQ3GC.js +0 -119
  587. package/dist/accounts-UWC2TT6R.js +0 -80
  588. package/dist/actions-NT3HXFFA.js +0 -55
  589. package/dist/active-entities-XRSJNBOV.js +0 -103
  590. package/dist/activecampaign-EYRHDSXY.js +0 -938
  591. package/dist/activities-ZDWREYR7.js +0 -75
  592. package/dist/ad-group-writes-SVR4RCKB.js +0 -172
  593. package/dist/ad-groups-C726HUXS.js +0 -70
  594. package/dist/ad-writes-RWJIWGEL.js +0 -176
  595. package/dist/add-25YZMFSH.js +0 -85
  596. package/dist/add-7MAL7JRX.js +0 -81
  597. package/dist/add-D44VCDRU.js +0 -148
  598. package/dist/add-EPOHDTUO.js +0 -305
  599. package/dist/add-JO4ZPS23.js +0 -97
  600. package/dist/add-NSW26HIM.js +0 -107
  601. package/dist/add-accounts-EKMSHAA4.js +0 -91
  602. package/dist/ads-3KK7VQPU.js +0 -79
  603. package/dist/ads-4YZYNU66.js +0 -128
  604. package/dist/ads-DGL5SGP3.js +0 -120
  605. package/dist/ads-EWZGIC4T.js +0 -48
  606. package/dist/adsets-PSVCPCE3.js +0 -182
  607. package/dist/advertisers-7NAPI5ZU.js +0 -125
  608. package/dist/advertisers-AHOWL3YL.js +0 -123
  609. package/dist/analytics-7H6NDVUQ.js +0 -447
  610. package/dist/analytics-GFFXCMLV.js +0 -2437
  611. package/dist/animate-GTUI7XX4.js +0 -480
  612. package/dist/approved-E4EZA5RT.js +0 -73
  613. package/dist/asset-writes-NDSHY5OT.js +0 -50
  614. package/dist/assign-SDPPWP3Q.js +0 -80
  615. package/dist/audience-size-LKDDHKED.js +0 -76
  616. package/dist/audience-writes-4KQXVGHO.js +0 -327
  617. package/dist/audience-writes-4KQXVGHO.js.map +0 -1
  618. package/dist/audiences-6L43K2T2.js +0 -280
  619. package/dist/audiences-T5LMTT3B.js +0 -85
  620. package/dist/audiences-UHLVATR6.js +0 -106
  621. package/dist/audit-46DO2HV3.js +0 -88
  622. package/dist/audit-TSZIQTUB.js +0 -154
  623. package/dist/autocomplete-5BSAOAMZ.js +0 -114
  624. package/dist/avatars-S6RRD7M3.js +0 -38
  625. package/dist/bid-pricing-5KUAINH4.js +0 -103
  626. package/dist/brand-KFK2MQWW.js +0 -22
  627. package/dist/brief-6DV2PKAU.js +0 -543
  628. package/dist/brief-6DV2PKAU.js.map +0 -1
  629. package/dist/businesses-TRFYMZ4I.js +0 -54
  630. package/dist/campaign-groups-5RPZPDNW.js +0 -99
  631. package/dist/campaign-writes-FUIGN5OR.js +0 -176
  632. package/dist/campaign-writes-XMYBEVZF.js +0 -168
  633. package/dist/campaigns-2MTON2IE.js +0 -130
  634. package/dist/campaigns-5A3IE735.js +0 -111
  635. package/dist/campaigns-JNP3VDZK.js +0 -113
  636. package/dist/campaigns-N2SWSBYT.js +0 -78
  637. package/dist/canvas-CHFNQTLY.js +0 -46
  638. package/dist/capabilities-2W3SRZ2I.js +0 -147
  639. package/dist/cards-CXKIVM4D.js +0 -85
  640. package/dist/catalog-6BER3SF7.js +0 -66
  641. package/dist/catalogs-4DNLG4AM.js +0 -782
  642. package/dist/catalogs-4DNLG4AM.js.map +0 -1
  643. package/dist/catalogs-G5NOKL4L.js +0 -130
  644. package/dist/changes-AS4RVEAL.js +0 -167
  645. package/dist/chatgpt-O6EEAYLF.js +0 -47
  646. package/dist/chats-4JLWMUAC.js +0 -584
  647. package/dist/check-BOKLY5WG.js +0 -107
  648. package/dist/check-BOKLY5WG.js.map +0 -1
  649. package/dist/chunk-2CC4CPDT.js +0 -225
  650. package/dist/chunk-3GXHML4V.js +0 -106
  651. package/dist/chunk-3KUNRKNV.js +0 -430
  652. package/dist/chunk-3QPG2D27.js +0 -125
  653. package/dist/chunk-3UNMVVSI.js +0 -917
  654. package/dist/chunk-3UNMVVSI.js.map +0 -1
  655. package/dist/chunk-3WN5GWX4.js +0 -94
  656. package/dist/chunk-4AO3LSYM.js +0 -73
  657. package/dist/chunk-4HFM5RCP.js +0 -217
  658. package/dist/chunk-4INBMXUS.js +0 -930
  659. package/dist/chunk-4NZ47VXO.js +0 -137
  660. package/dist/chunk-4NZ47VXO.js.map +0 -1
  661. package/dist/chunk-5NMKNHJI.js +0 -46
  662. package/dist/chunk-5NMKNHJI.js.map +0 -1
  663. package/dist/chunk-5QNW5PCM.js +0 -106
  664. package/dist/chunk-6AMN346B.js +0 -114
  665. package/dist/chunk-6D7WTUF3.js +0 -98
  666. package/dist/chunk-6DSPB6YA.js +0 -7904
  667. package/dist/chunk-6DSPB6YA.js.map +0 -1
  668. package/dist/chunk-6EOWBGGW.js +0 -191
  669. package/dist/chunk-6FQ7CJEX.js +0 -57
  670. package/dist/chunk-6MJKVNLL.js +0 -25
  671. package/dist/chunk-6OZDN2FI.js +0 -19
  672. package/dist/chunk-75OGTGC4.js +0 -89
  673. package/dist/chunk-7NBQQOCU.js +0 -97
  674. package/dist/chunk-AQRBEPZL.js +0 -138
  675. package/dist/chunk-AXLKR3E4.js +0 -66
  676. package/dist/chunk-AZIXX73C.js +0 -64
  677. package/dist/chunk-B64KJW5C.js +0 -476
  678. package/dist/chunk-BEZEZHQ6.js +0 -455
  679. package/dist/chunk-BIBXZJZI.js +0 -97
  680. package/dist/chunk-BMK4F4CU.js +0 -169
  681. package/dist/chunk-C52Q3L4C.js +0 -51
  682. package/dist/chunk-CBVUO7SK.js +0 -1744
  683. package/dist/chunk-CF5I4Q5M.js +0 -69
  684. package/dist/chunk-CST52ZME.js +0 -142
  685. package/dist/chunk-DGHSXHZR.js +0 -136
  686. package/dist/chunk-DHF4FXWS.js +0 -58
  687. package/dist/chunk-DPOUS5DN.js +0 -287
  688. package/dist/chunk-DW3H2XQA.js +0 -91
  689. package/dist/chunk-EAA273XW.js +0 -2250
  690. package/dist/chunk-EAA273XW.js.map +0 -1
  691. package/dist/chunk-EJ6EED6I.js +0 -69
  692. package/dist/chunk-EM5R3BYC.js +0 -131
  693. package/dist/chunk-EMR5KGNY.js +0 -685
  694. package/dist/chunk-EONUZOJV.js +0 -962
  695. package/dist/chunk-FLTAPEVY.js +0 -288
  696. package/dist/chunk-GRX3JXSR.js +0 -843
  697. package/dist/chunk-GRX3JXSR.js.map +0 -1
  698. package/dist/chunk-H25GY4U4.js +0 -139
  699. package/dist/chunk-H4RHZJ65.js +0 -207
  700. package/dist/chunk-H6ASYVQX.js +0 -544
  701. package/dist/chunk-HFIHXIYY.js +0 -547
  702. package/dist/chunk-HOA74TOS.js +0 -249
  703. package/dist/chunk-HOA74TOS.js.map +0 -1
  704. package/dist/chunk-HPF3USL2.js +0 -52
  705. package/dist/chunk-HQDNDKNR.js +0 -5471
  706. package/dist/chunk-HXSYWXLH.js +0 -709
  707. package/dist/chunk-I3QLWGKS.js +0 -64
  708. package/dist/chunk-IYDESWW4.js +0 -74
  709. package/dist/chunk-J4AWNWKN.js +0 -1919
  710. package/dist/chunk-J4AWNWKN.js.map +0 -1
  711. package/dist/chunk-JAK5VDSG.js +0 -103
  712. package/dist/chunk-JAME5NBT.js +0 -42
  713. package/dist/chunk-JGSEHX2Q.js +0 -3107
  714. package/dist/chunk-JGSEHX2Q.js.map +0 -1
  715. package/dist/chunk-JLAFNORO.js +0 -285
  716. package/dist/chunk-KG5VNPKU.js +0 -91
  717. package/dist/chunk-KGJ6EIX3.js +0 -76
  718. package/dist/chunk-KJHG2DWS.js +0 -170
  719. package/dist/chunk-L4QEMWNJ.js +0 -111
  720. package/dist/chunk-L7I47VGM.js +0 -46
  721. package/dist/chunk-LAMSUL26.js +0 -1518
  722. package/dist/chunk-LJEJCIHR.js +0 -246
  723. package/dist/chunk-LLTHDEM2.js +0 -479
  724. package/dist/chunk-M4KFO256.js +0 -188
  725. package/dist/chunk-M5PZ6QQB.js +0 -312
  726. package/dist/chunk-MFGUR5OD.js +0 -334
  727. package/dist/chunk-MIHY534L.js +0 -39
  728. package/dist/chunk-MKOI6QYM.js +0 -225
  729. package/dist/chunk-MPTNN35I.js +0 -325
  730. package/dist/chunk-MSIOGH67.js +0 -66
  731. package/dist/chunk-MTW2NDDD.js +0 -98
  732. package/dist/chunk-MZLPOYCC.js +0 -10058
  733. package/dist/chunk-MZLPOYCC.js.map +0 -1
  734. package/dist/chunk-NOCBNING.js +0 -638
  735. package/dist/chunk-NOCBNING.js.map +0 -1
  736. package/dist/chunk-NWLK5RPA.js +0 -197
  737. package/dist/chunk-NXNOXZGB.js +0 -2523
  738. package/dist/chunk-NXNOXZGB.js.map +0 -1
  739. package/dist/chunk-O5VSYBUA.js +0 -343
  740. package/dist/chunk-PR5OPERY.js +0 -167
  741. package/dist/chunk-Q3G4ZI2U.js +0 -84
  742. package/dist/chunk-Q5XUFN2W.js +0 -35
  743. package/dist/chunk-Q736UFSD.js +0 -75
  744. package/dist/chunk-QGAUDVMR.js +0 -148
  745. package/dist/chunk-QRRAMUKV.js +0 -468
  746. package/dist/chunk-QVQKCVP7.js +0 -85
  747. package/dist/chunk-QVQKCVP7.js.map +0 -1
  748. package/dist/chunk-RGLTITIH.js +0 -494
  749. package/dist/chunk-RIVQ4PQQ.js +0 -225
  750. package/dist/chunk-RLLPY62L.js +0 -163
  751. package/dist/chunk-RQHXWPET.js +0 -61
  752. package/dist/chunk-RRKUXGAU.js +0 -26
  753. package/dist/chunk-RULW4627.js +0 -23
  754. package/dist/chunk-S4RCF3YT.js +0 -156
  755. package/dist/chunk-S4RCF3YT.js.map +0 -1
  756. package/dist/chunk-S5S54J2K.js +0 -56
  757. package/dist/chunk-SIRRBWQ2.js +0 -215
  758. package/dist/chunk-TCLJRWST.js +0 -831
  759. package/dist/chunk-TLQY4QBW.js +0 -84
  760. package/dist/chunk-UK4XSLV2.js +0 -296
  761. package/dist/chunk-URGXEDFV.js +0 -76
  762. package/dist/chunk-UVUY6FLV.js +0 -1254
  763. package/dist/chunk-V4HS5JRL.js +0 -1320
  764. package/dist/chunk-V7EN5LFS.js +0 -115
  765. package/dist/chunk-WTOBG3YL.js +0 -392
  766. package/dist/chunk-WTPID22G.js +0 -152
  767. package/dist/chunk-WYMX3F47.js +0 -399
  768. package/dist/chunk-X5YHMGAT.js +0 -224
  769. package/dist/chunk-X7USE7IA.js +0 -24026
  770. package/dist/chunk-XA76OGSL.js +0 -718
  771. package/dist/chunk-XA7JN7YE.js +0 -297
  772. package/dist/chunk-XHAGX4J4.js +0 -604
  773. package/dist/chunk-XY7W6MQN.js +0 -274
  774. package/dist/chunk-YAINUFSC.js +0 -203
  775. package/dist/chunk-YAMKCMAS.js +0 -219
  776. package/dist/chunk-YRWCXYWW.js +0 -178
  777. package/dist/chunk-YRWCXYWW.js.map +0 -1
  778. package/dist/chunk-Z5BG47PO.js +0 -5752
  779. package/dist/chunk-Z5BG47PO.js.map +0 -1
  780. package/dist/chunk-Z7ICQKC2.js +0 -344
  781. package/dist/chunk-ZBXV2KOQ.js +0 -220
  782. package/dist/chunk-ZCGM7ZWM.js +0 -45
  783. package/dist/chunk-ZMNRSTNV.js +0 -454
  784. package/dist/cite-WCAOCOO5.js +0 -191
  785. package/dist/claim-L4WLCVUL.js +0 -200
  786. package/dist/client-VCKP6WBR.js +0 -19
  787. package/dist/code-VXOTFGD2.js +0 -76
  788. package/dist/companies-HW46BRQG.js +0 -198
  789. package/dist/company-KCIDE7SL.js +0 -308
  790. package/dist/complete-JXM25FVW.js +0 -84
  791. package/dist/config-UR45YCIN.js +0 -88
  792. package/dist/connect-7TX7AAM5.js +0 -45
  793. package/dist/content-EQQIKG5H.js +0 -85
  794. package/dist/conversation-YIDUB6GL.js +0 -96
  795. package/dist/conversion-report-33SG7SHU.js +0 -127
  796. package/dist/conversion-upload-command-N3OMLLF2.js +0 -439
  797. package/dist/conversion-upload-command-N3OMLLF2.js.map +0 -1
  798. package/dist/conversion-writes-XGGTBML5.js +0 -122
  799. package/dist/conversions-F4OZYUCT.js +0 -140
  800. package/dist/conversions-PPP4QK7U.js +0 -78
  801. package/dist/copy-writes-JVUX3YDL.js +0 -170
  802. package/dist/copy-writes-JVUX3YDL.js.map +0 -1
  803. package/dist/countries-GRCU4IGM.js +0 -82
  804. package/dist/create-6EAKNERA.js +0 -239
  805. package/dist/create-772LZHZR.js +0 -218
  806. package/dist/create-FDNMIVFX.js +0 -62
  807. package/dist/create-X2QM7GA7.js +0 -135
  808. package/dist/creatives-4EPM3RHG.js +0 -118
  809. package/dist/creatives-K2AAW6EL.js +0 -58
  810. package/dist/creatives-K2AAW6EL.js.map +0 -1
  811. package/dist/creatives-SNYN4KIM.js +0 -229
  812. package/dist/credentials-KZZVBO42.js +0 -290
  813. package/dist/critique-G5QXRHPF.js +0 -1451
  814. package/dist/critique-G5QXRHPF.js.map +0 -1
  815. package/dist/critique-PUHOJI7V.js +0 -232
  816. package/dist/critique-PUHOJI7V.js.map +0 -1
  817. package/dist/crm-4LZZVT4N.js +0 -229
  818. package/dist/crm-M6NXDU5B.js +0 -323
  819. package/dist/crop-NE7YX4SS.js +0 -113
  820. package/dist/currency-HK2ZW2VW.js +0 -88
  821. package/dist/custom-conversions-GQTU5E6X.js +0 -128
  822. package/dist/customers-V5NT4W7X.js +0 -65
  823. package/dist/decide-6Q5X3V3F.js +0 -199
  824. package/dist/delete-EKKOEB3N.js +0 -69
  825. package/dist/delete-GQIKNO53.js +0 -57
  826. package/dist/delete-LFZIPQEO.js +0 -69
  827. package/dist/delete-QHDDR66K.js +0 -85
  828. package/dist/delete-SP66F7ZV.js +0 -71
  829. package/dist/delete-YOEI63OT.js +0 -67
  830. package/dist/demographics-CEQ74O74.js +0 -141
  831. package/dist/describe-DJPIUEFE.js +0 -97
  832. package/dist/describe-MAGTSOW4.js +0 -97
  833. package/dist/dimensions-IC2H7V3H.js +0 -101
  834. package/dist/discard-5GDF3TP3.js +0 -69
  835. package/dist/discover-PSL2NBJL.js +0 -93
  836. package/dist/discover-Q5PAOIQQ.js +0 -172
  837. package/dist/domain-PKOUPHHF.js +0 -101
  838. package/dist/download-2WNTN7JQ.js +0 -172
  839. package/dist/download-EHDJXBAC.js +0 -337
  840. package/dist/draft-27NMTARB.js +0 -134
  841. package/dist/draft-CF4XNJG5.js +0 -578
  842. package/dist/draft-CF4XNJG5.js.map +0 -1
  843. package/dist/draft-F4CVSL2I.js +0 -332
  844. package/dist/draft-F4CVSL2I.js.map +0 -1
  845. package/dist/draft-JESKGZ6O.js +0 -138
  846. package/dist/draft-L2NXCIYT.js +0 -315
  847. package/dist/draft-MWYKIZC4.js +0 -260
  848. package/dist/draft-RZCTAOI2.js +0 -374
  849. package/dist/draft-UEVBUNKV.js +0 -220
  850. package/dist/env-NZXNMWSD.js +0 -53
  851. package/dist/experiment-XAYSEYTU.js +0 -1397
  852. package/dist/experiments-DWC6L72S.js +0 -236
  853. package/dist/experiments-DWC6L72S.js.map +0 -1
  854. package/dist/export-W54UZ62P.js +0 -168
  855. package/dist/extract-6HJXSOZW.js +0 -143
  856. package/dist/facets-TBOXGYJT.js +0 -117
  857. package/dist/favorites-Y6CT6NSQ.js +0 -178
  858. package/dist/feed-35BRQPTH.js +0 -177
  859. package/dist/feedback-MSMFYAEY.js +0 -114
  860. package/dist/feedback-WAC6S42V.js +0 -115
  861. package/dist/feedback-WAC6S42V.js.map +0 -1
  862. package/dist/feedback-record-XRQ2R2WD.js +0 -269
  863. package/dist/feedback-record-XRQ2R2WD.js.map +0 -1
  864. package/dist/fetch-I6P72CDL.js +0 -139
  865. package/dist/fetch-LGX7B3IC.js +0 -204
  866. package/dist/find-SVGRA7IA.js +0 -144
  867. package/dist/fit-RVWPRBNO.js +0 -65
  868. package/dist/flows-LA6EYMLS.js +0 -340
  869. package/dist/follow-24QSDNAG.js +0 -94
  870. package/dist/follow-competitors-AG4E4XFA.js +0 -112
  871. package/dist/following-YGM6TBK3.js +0 -113
  872. package/dist/fonts-WRC34VSV.js +0 -39
  873. package/dist/forecast-6VHRGBJG.js +0 -121
  874. package/dist/forecast-OVKXBLJB.js +0 -169
  875. package/dist/forecast-OVKXBLJB.js.map +0 -1
  876. package/dist/funding-WZNGXRLJ.js +0 -85
  877. package/dist/funnel-U3GQIGND.js +0 -397
  878. package/dist/ga4-W3U5YTRT.js +0 -55
  879. package/dist/generate-Y4NJEYIH.js +0 -263
  880. package/dist/get-3MTAVNTP.js +0 -56
  881. package/dist/get-5SPNAIUQ.js +0 -62
  882. package/dist/get-AHI247JG.js +0 -82
  883. package/dist/get-GEUSRD5Y.js +0 -59
  884. package/dist/get-JIZPYK3Z.js +0 -74
  885. package/dist/get-PF3HGECD.js +0 -62
  886. package/dist/get-TS2ZJDCQ.js +0 -38
  887. package/dist/get-YWDZYEAC.js +0 -92
  888. package/dist/gif-NP6EDGEE.js +0 -111
  889. package/dist/google-BMUJKAUO.js +0 -3300
  890. package/dist/google-BMUJKAUO.js.map +0 -1
  891. package/dist/google-ZVAIFXQZ.js +0 -163
  892. package/dist/google-ads-6Z7P3SCD.js +0 -198
  893. package/dist/group-3DT4UYSR.js +0 -43
  894. package/dist/group-OEKKCFXT.js +0 -43
  895. package/dist/gsc-4FEFPFPB.js +0 -30
  896. package/dist/history-4QUV45ZJ.js +0 -102
  897. package/dist/history-PD7FCTDD.js +0 -153
  898. package/dist/history-VKRYKQ4C.js +0 -69
  899. package/dist/hubspot-WEFAFKVJ.js +0 -814
  900. package/dist/icon-43UJTGGE.js +0 -138
  901. package/dist/ideas-SMSEXKIA.js +0 -45
  902. package/dist/images-KAT4BPYV.js +0 -92
  903. package/dist/improve-IMXQN6OD.js +0 -86
  904. package/dist/ingest-IHKTSJ4H.js +0 -28
  905. package/dist/ingest-TOHQ6MZA.js +0 -131
  906. package/dist/insights-3IPSEBYW.js +0 -132
  907. package/dist/insights-BR3456EI.js +0 -658
  908. package/dist/inspect-5MZBPDYS.js +0 -192
  909. package/dist/inspiration-XZI5KCQW.js +0 -53
  910. package/dist/instant-experiences-2LKF7XVK.js +0 -264
  911. package/dist/instant-experiences-2LKF7XVK.js.map +0 -1
  912. package/dist/intent-ZM4K623V.js +0 -95
  913. package/dist/job-GOX3KIKG.js +0 -202
  914. package/dist/job-create-F2PQSN3C.js +0 -109
  915. package/dist/job-status-3FMA5D7T.js +0 -74
  916. package/dist/keep-23ZYMWPG.js +0 -78
  917. package/dist/keyword-gap-FAAF2I6V.js +0 -130
  918. package/dist/keyword-metrics-EXNJRJBY.js +0 -200
  919. package/dist/keywords-for-site-5LW77QWF.js +0 -131
  920. package/dist/knowledge-7M7DSRF3.js +0 -195
  921. package/dist/landing-ZH4SD3DW.js +0 -28
  922. package/dist/landings-VNQ4VA2U.js +0 -151
  923. package/dist/languages-2X22HXM3.js +0 -55
  924. package/dist/languages-ZGDTERIQ.js +0 -40
  925. package/dist/launches-L4EUROCJ.js +0 -19
  926. package/dist/layerize-6QHQMA7Q.js +0 -190
  927. package/dist/lead-routes-5TPFJEVH.js +0 -733
  928. package/dist/leads-4TLOH47R.js +0 -541
  929. package/dist/leads-4TLOH47R.js.map +0 -1
  930. package/dist/leads-736RILZN.js +0 -115
  931. package/dist/learn-BESXWXEN.js +0 -207
  932. package/dist/library-MNJC24E4.js +0 -212
  933. package/dist/lighthouse-DJMAXFTD.js +0 -75
  934. package/dist/line-item-writes-FA72DHNQ.js +0 -211
  935. package/dist/line-items-XVYE3IYT.js +0 -107
  936. package/dist/link-6FPKFVC3.js +0 -67
  937. package/dist/linkedin-TE6P4RYN.js +0 -1344
  938. package/dist/linkedin-TE6P4RYN.js.map +0 -1
  939. package/dist/linkedin-person-TZJ6VEXE.js +0 -139
  940. package/dist/list-2277GCPH.js +0 -51
  941. package/dist/list-4R5EMKUQ.js +0 -154
  942. package/dist/list-537S75BZ.js +0 -76
  943. package/dist/list-MN2FPF3T.js +0 -306
  944. package/dist/list-ORO4WDF4.js +0 -67
  945. package/dist/list-Q52FPW3H.js +0 -50
  946. package/dist/list-V4PSDBLX.js +0 -93
  947. package/dist/list-WIXQXNKB.js +0 -65
  948. package/dist/list-XK33NCSC.js +0 -57
  949. package/dist/locations-A65MFB7Q.js +0 -69
  950. package/dist/locations-WN6B3IJK.js +0 -40
  951. package/dist/log-ABBZLPRU.js +0 -95
  952. package/dist/logo-4LSFZ3ZO.js +0 -19
  953. package/dist/lookup-WIM5WR25.js +0 -23
  954. package/dist/make-QAFKU6WO.js +0 -1367
  955. package/dist/make-QAFKU6WO.js.map +0 -1
  956. package/dist/map-52P35OKE.js +0 -445
  957. package/dist/mcp-PZ3VBIF4.js +0 -729
  958. package/dist/media-34I7UB7Z.js +0 -89
  959. package/dist/media-KKI3KWLR.js +0 -18
  960. package/dist/media-sources-TT374PLN.js +0 -35
  961. package/dist/members-CF6VG6ZW.js +0 -47
  962. package/dist/meme-6NFYFQ7T.js +0 -108
  963. package/dist/meta-2UK7KIE4.js +0 -124
  964. package/dist/metrics-3U3ZO2RF.js +0 -152
  965. package/dist/models-VOSJJFO2.js +0 -155
  966. package/dist/normalize-4LZCLMTQ.js +0 -144
  967. package/dist/normalize-G75RDSE4.js +0 -806
  968. package/dist/options-6IRL7CL6.js +0 -125
  969. package/dist/organization-WMLLJE66.js +0 -949
  970. package/dist/output-ELEO2Z6R.js +0 -24
  971. package/dist/page-4X6IBUWG.js +0 -105
  972. package/dist/page-photos-KNBLMFLN.js +0 -118
  973. package/dist/page-photos-KNBLMFLN.js.map +0 -1
  974. package/dist/pages-7HW5YOZV.js +0 -67
  975. package/dist/performance-A7CYFBW2.js +0 -5565
  976. package/dist/performance-HYSTXLTS.js +0 -27
  977. package/dist/pinterest-KA6VFDM4.js +0 -105
  978. package/dist/pixels-D5HF24FI.js +0 -109
  979. package/dist/pixels-U6UA662G.js +0 -62
  980. package/dist/plan-XCA6R3HZ.js +0 -208
  981. package/dist/posts-ALGM6ONV.js +0 -36
  982. package/dist/preview-55TRUF4Q.js +0 -245
  983. package/dist/preview-76ZP2QA3.js +0 -101
  984. package/dist/profile-NHUPUCBR.js +0 -159
  985. package/dist/promoted-tweet-writes-I5G4IDL5.js +0 -183
  986. package/dist/promoted-tweets-X5XNO7IT.js +0 -119
  987. package/dist/properties-2ZXA5BPJ.js +0 -101
  988. package/dist/publish-S2Z4EF4H.js +0 -350
  989. package/dist/query-63CTX2PH.js +0 -231
  990. package/dist/query-DMWY3TDD.js +0 -236
  991. package/dist/query-SAQADBM2.js +0 -62
  992. package/dist/questionnaire-WHE42RD4.js +0 -94
  993. package/dist/read-NESEKULG.js +0 -141
  994. package/dist/reddit-S2L5WDY7.js +0 -29
  995. package/dist/refresh-ILDEPU5A.js +0 -42
  996. package/dist/refresh-K2YTJSH3.js +0 -97
  997. package/dist/release-FX76IIVN.js +0 -63
  998. package/dist/relevant-pages-KTSODNNW.js +0 -99
  999. package/dist/remove-LOVWPLDO.js +0 -53
  1000. package/dist/remove-NHE4UT7G.js +0 -49
  1001. package/dist/reopen-DXV2Y6Z3.js +0 -66
  1002. package/dist/rerun-TFQCRRFK.js +0 -97
  1003. package/dist/rerun-TFQCRRFK.js.map +0 -1
  1004. package/dist/research-7PGDAKC7.js +0 -265
  1005. package/dist/research-HY5PSUCC.js +0 -75
  1006. package/dist/reset-MEHUQJA4.js +0 -57
  1007. package/dist/reset-Y5VZJRDQ.js +0 -57
  1008. package/dist/resolve-FAVABEJW.js +0 -124
  1009. package/dist/retry-5IY4MNDW.js +0 -65
  1010. package/dist/retry-OMJ3C3AX.js +0 -63
  1011. package/dist/retry-failed-R5HPQ3KQ.js +0 -45
  1012. package/dist/revenue-S4KFZCOI.js +0 -91
  1013. package/dist/revenue-S4KFZCOI.js.map +0 -1
  1014. package/dist/rule-writes-QB4IWFCJ.js +0 -530
  1015. package/dist/rule-writes-QB4IWFCJ.js.map +0 -1
  1016. package/dist/rules-66IGR2KA.js +0 -99
  1017. package/dist/rules-66IGR2KA.js.map +0 -1
  1018. package/dist/rules-FYVD2QBB.js +0 -217
  1019. package/dist/rules-add-G7YGOYZJ.js +0 -465
  1020. package/dist/rules-add-G7YGOYZJ.js.map +0 -1
  1021. package/dist/run-LJVBH3JS.js +0 -72
  1022. package/dist/run-XJBWDWN6.js +0 -69
  1023. package/dist/scaffold-ad-GNMCB3QY.js +0 -1513
  1024. package/dist/scaffold-ad-GNMCB3QY.js.map +0 -1
  1025. package/dist/scaffold-static-ad-QIWKWURL.js +0 -1013
  1026. package/dist/scaffold-static-ad-QIWKWURL.js.map +0 -1
  1027. package/dist/scaffold-video-G6G2NPUF.js +0 -885
  1028. package/dist/scaffold-video-G6G2NPUF.js.map +0 -1
  1029. package/dist/schedule-D7EDEM45.js +0 -67
  1030. package/dist/schedule-OX5XHXLH.js +0 -64
  1031. package/dist/scheduled-agents-A5ZFQB5X.js +0 -55
  1032. package/dist/schema-NTGHAPR2.js +0 -135
  1033. package/dist/schema-Z43AJOJ4.js +0 -152
  1034. package/dist/scrape-VL2RWSTW.js +0 -2209
  1035. package/dist/screenshot-Y6EEXS3Q.js +0 -103
  1036. package/dist/search-CXC7N5XJ.js +0 -51
  1037. package/dist/search-JEXYEAPQ.js +0 -228
  1038. package/dist/search-L3GTZYRW.js +0 -92
  1039. package/dist/search-TXBYKNQC.js +0 -91
  1040. package/dist/search-WCXQBMMM.js +0 -177
  1041. package/dist/search-XHSTUBDY.js +0 -26
  1042. package/dist/search-copy-FIPG7OCC.js +0 -168
  1043. package/dist/seeds-ADJKURNG.js +0 -101
  1044. package/dist/select-5ZD7FVBT.js +0 -110
  1045. package/dist/select-5ZD7FVBT.js.map +0 -1
  1046. package/dist/sends-RS4LWRAC.js +0 -349
  1047. package/dist/sequences-2RPKDKGQ.js +0 -146
  1048. package/dist/set-prompt-NGCVMQIQ.js +0 -199
  1049. package/dist/set-prompt-NGCVMQIQ.js.map +0 -1
  1050. package/dist/setup-links-4HCSF55G.js +0 -144
  1051. package/dist/shared-4GGUIOF2.js +0 -32
  1052. package/dist/shopify-GDR5WGHH.js +0 -4009
  1053. package/dist/site-B7LT6KAO.js +0 -180
  1054. package/dist/sitemaps-Z6IELTQV.js +0 -77
  1055. package/dist/sites-KLAKI2EY.js +0 -97
  1056. package/dist/skills-OJP36EVR.js +0 -47
  1057. package/dist/sources-6DPUEROC.js +0 -30
  1058. package/dist/sources-OSUXCLID.js +0 -457
  1059. package/dist/stale-YKFKPPOH.js +0 -90
  1060. package/dist/stale-YKFKPPOH.js.map +0 -1
  1061. package/dist/stats-MIMFX4R7.js +0 -34
  1062. package/dist/status-KIC3P5JV.js +0 -65
  1063. package/dist/sticker-IREEEN7I.js +0 -103
  1064. package/dist/stock-VWFUFRYV.js +0 -212
  1065. package/dist/studies-YGYAH3JI.js +0 -250
  1066. package/dist/studio-XLC37YGX.js +0 -49
  1067. package/dist/study-writes-UPGJB36A.js +0 -471
  1068. package/dist/study-writes-UPGJB36A.js.map +0 -1
  1069. package/dist/suggest-5RTISDLI.js +0 -66
  1070. package/dist/sync-OHIXI4I6.js +0 -55
  1071. package/dist/sync-QBW4XH2H.js +0 -57
  1072. package/dist/sync-VCAFAYW4.js +0 -279
  1073. package/dist/sync-definition-4KMJK46H.js +0 -70
  1074. package/dist/tag-DSCUKNC3.js +0 -57
  1075. package/dist/tag-manager-IINALUEJ.js +0 -43
  1076. package/dist/tags-4F5UBPYG.js +0 -227
  1077. package/dist/tags-4O5FPEEY.js +0 -26
  1078. package/dist/tags-7RKKCQ4X.js +0 -23
  1079. package/dist/tags-CB4MWI3A.js +0 -23
  1080. package/dist/tags-QZJIP4LJ.js +0 -23
  1081. package/dist/targeting-BM72UTI6.js +0 -762
  1082. package/dist/targeting-BM72UTI6.js.map +0 -1
  1083. package/dist/targeting-constants-54S3FXIF.js +0 -118
  1084. package/dist/targeting-criteria-65UU7EYD.js +0 -113
  1085. package/dist/targets-T742OPQI.js +0 -106
  1086. package/dist/terms-OFHNLW6U.js +0 -102
  1087. package/dist/testimonials-HKJJXONO.js +0 -32
  1088. package/dist/themes-Q6LVMEMF.js +0 -95
  1089. package/dist/themes-Q6LVMEMF.js.map +0 -1
  1090. package/dist/top-companies-T6AMU4C6.js +0 -111
  1091. package/dist/transcript-DOUYMZAP.js +0 -165
  1092. package/dist/translate-WKOXFZTQ.js +0 -603
  1093. package/dist/translate-WKOXFZTQ.js.map +0 -1
  1094. package/dist/triggers-EYY4GSUL.js +0 -144
  1095. package/dist/tweets-TRTXC6O4.js +0 -123
  1096. package/dist/unfollow-DATOGPLZ.js +0 -46
  1097. package/dist/unlink-JNM4WRZK.js +0 -70
  1098. package/dist/unstage-LLQCMZ5H.js +0 -96
  1099. package/dist/unstage-QF4JT5YP.js +0 -88
  1100. package/dist/update-6V3RBRIE.js +0 -101
  1101. package/dist/update-J4DURR4K.js +0 -192
  1102. package/dist/update-J7Y6LZC5.js +0 -155
  1103. package/dist/update-MQ4NYIU6.js +0 -66
  1104. package/dist/update-SD5YQIJC.js +0 -81
  1105. package/dist/upload-7PPMVWVA.js +0 -155
  1106. package/dist/upload-CEIYYPID.js +0 -137
  1107. package/dist/upscale-WVJZG76V.js +0 -109
  1108. package/dist/url-options-6WC2XQKB.js +0 -131
  1109. package/dist/url-params-OVBIP6UA.js +0 -101
  1110. package/dist/use-6FADOAFZ.js +0 -111
  1111. package/dist/validate-UHXI2ESE.js +0 -135
  1112. package/dist/validate-UHXI2ESE.js.map +0 -1
  1113. package/dist/variant-RNM36P4J.js +0 -338
  1114. package/dist/videos-GHFCOTT7.js +0 -146
  1115. package/dist/videos-Z72RXCRB.js +0 -41
  1116. package/dist/view-YR6MDLWL.js +0 -133
  1117. package/dist/viewer-check-655BZRML.js +0 -83
  1118. package/dist/web-4QN6QB7L.js +0 -173
  1119. package/dist/winners-4T5RFQXU.js +0 -113
  1120. package/dist/winning-ads-2J2RIOLR.js +0 -86
  1121. package/dist/write-commands-6D55SB56.js +0 -206
  1122. package/dist/write-commands-AIWLEGO2.js +0 -1169
  1123. package/dist/write-commands-AIWLEGO2.js.map +0 -1
  1124. package/dist/write-commands-UO3OQIHH.js +0 -721
  1125. package/dist/write-commands-V7B4FBMX.js +0 -1524
  1126. package/dist/write-commands-V7B4FBMX.js.map +0 -1
  1127. package/dist/x-7KXNCWTJ.js +0 -47
  1128. /package/dist/{account-JVDP5ERG.js.map → account-6RJ6ZI3B.js.map} +0 -0
  1129. /package/dist/{account-EXGRZIXS.js.map → account-AIGNJ2RP.js.map} +0 -0
  1130. /package/dist/{account-NSBALYYS.js.map → account-E5LLPRZ6.js.map} +0 -0
  1131. /package/dist/{account-assets-EPEYTJFD.js.map → account-assets-J6SVHSXR.js.map} +0 -0
  1132. /package/dist/{account-writes-KEXINJ5D.js.map → account-writes-XNS4IKZV.js.map} +0 -0
  1133. /package/dist/{accounts-UWC2TT6R.js.map → accounts-3ZWYGRVM.js.map} +0 -0
  1134. /package/dist/{accounts-QR6OQ3GC.js.map → accounts-5TLHSEZR.js.map} +0 -0
  1135. /package/dist/{accounts-QESGQJGZ.js.map → accounts-BAZYYDFV.js.map} +0 -0
  1136. /package/dist/{accounts-A47QUTTB.js.map → accounts-L2HVNJUF.js.map} +0 -0
  1137. /package/dist/{accounts-E5TF2AFI.js.map → accounts-NTBIRB52.js.map} +0 -0
  1138. /package/dist/{actions-NT3HXFFA.js.map → actions-N2FBJMT4.js.map} +0 -0
  1139. /package/dist/{active-entities-XRSJNBOV.js.map → active-entities-IJPRN45K.js.map} +0 -0
  1140. /package/dist/{activecampaign-EYRHDSXY.js.map → activecampaign-U77COT2F.js.map} +0 -0
  1141. /package/dist/{activities-ZDWREYR7.js.map → activities-SS3SUWSS.js.map} +0 -0
  1142. /package/dist/{ad-group-writes-SVR4RCKB.js.map → ad-group-writes-DTQSUNE2.js.map} +0 -0
  1143. /package/dist/{ad-groups-C726HUXS.js.map → ad-groups-CX23GLVE.js.map} +0 -0
  1144. /package/dist/{ad-writes-RWJIWGEL.js.map → ad-writes-HAAUOJCG.js.map} +0 -0
  1145. /package/dist/{add-EPOHDTUO.js.map → add-ABPQTO2M.js.map} +0 -0
  1146. /package/dist/{add-JO4ZPS23.js.map → add-BK6N7KWU.js.map} +0 -0
  1147. /package/dist/{add-25YZMFSH.js.map → add-ECN2FTMH.js.map} +0 -0
  1148. /package/dist/{add-D44VCDRU.js.map → add-FH7OVKFF.js.map} +0 -0
  1149. /package/dist/{add-7MAL7JRX.js.map → add-KHY3H54G.js.map} +0 -0
  1150. /package/dist/{add-NSW26HIM.js.map → add-VDH2VCXR.js.map} +0 -0
  1151. /package/dist/{add-accounts-EKMSHAA4.js.map → add-accounts-6JAOSCXK.js.map} +0 -0
  1152. /package/dist/{ads-4YZYNU66.js.map → ads-BEMEXBDJ.js.map} +0 -0
  1153. /package/dist/{ads-EWZGIC4T.js.map → ads-GAU2XKNL.js.map} +0 -0
  1154. /package/dist/{ads-3KK7VQPU.js.map → ads-HZOXZ3FY.js.map} +0 -0
  1155. /package/dist/{ads-DGL5SGP3.js.map → ads-I5OBZ5VI.js.map} +0 -0
  1156. /package/dist/{adsets-PSVCPCE3.js.map → adsets-PMQGA6TW.js.map} +0 -0
  1157. /package/dist/{advertisers-AHOWL3YL.js.map → advertisers-EOLL3VFQ.js.map} +0 -0
  1158. /package/dist/{advertisers-7NAPI5ZU.js.map → advertisers-FNKY2PP4.js.map} +0 -0
  1159. /package/dist/{analytics-GFFXCMLV.js.map → analytics-DOAUCF2Y.js.map} +0 -0
  1160. /package/dist/{analytics-7H6NDVUQ.js.map → analytics-MR3T34KN.js.map} +0 -0
  1161. /package/dist/{animate-GTUI7XX4.js.map → animate-EKGVDSWM.js.map} +0 -0
  1162. /package/dist/{approved-E4EZA5RT.js.map → approved-WQL4Z4EB.js.map} +0 -0
  1163. /package/dist/{asset-writes-NDSHY5OT.js.map → asset-writes-A5X2T6LQ.js.map} +0 -0
  1164. /package/dist/{assign-SDPPWP3Q.js.map → assign-UMNHINRA.js.map} +0 -0
  1165. /package/dist/{audience-size-LKDDHKED.js.map → audience-size-Q7DZ6TGM.js.map} +0 -0
  1166. /package/dist/{audiences-UHLVATR6.js.map → audiences-HBJGEGKL.js.map} +0 -0
  1167. /package/dist/{audiences-6L43K2T2.js.map → audiences-RDQZNGPI.js.map} +0 -0
  1168. /package/dist/{audiences-T5LMTT3B.js.map → audiences-TA636UBN.js.map} +0 -0
  1169. /package/dist/{audit-TSZIQTUB.js.map → audit-H3F6FZNE.js.map} +0 -0
  1170. /package/dist/{audit-46DO2HV3.js.map → audit-QMCK76AT.js.map} +0 -0
  1171. /package/dist/{autocomplete-5BSAOAMZ.js.map → autocomplete-DIBJ57VC.js.map} +0 -0
  1172. /package/dist/{avatars-S6RRD7M3.js.map → avatars-UIXRGLPA.js.map} +0 -0
  1173. /package/dist/{bid-pricing-5KUAINH4.js.map → bid-pricing-OMY2F2SB.js.map} +0 -0
  1174. /package/dist/{brand-KFK2MQWW.js.map → brand-WV6CAU3M.js.map} +0 -0
  1175. /package/dist/{businesses-TRFYMZ4I.js.map → businesses-56IUB5X4.js.map} +0 -0
  1176. /package/dist/{campaign-groups-5RPZPDNW.js.map → campaign-groups-PGJIQV4S.js.map} +0 -0
  1177. /package/dist/{campaign-writes-FUIGN5OR.js.map → campaign-writes-MAJ5FGXG.js.map} +0 -0
  1178. /package/dist/{campaign-writes-XMYBEVZF.js.map → campaign-writes-WL3YAEGJ.js.map} +0 -0
  1179. /package/dist/{campaigns-2MTON2IE.js.map → campaigns-5L4ZTGF7.js.map} +0 -0
  1180. /package/dist/{campaigns-JNP3VDZK.js.map → campaigns-EK7EUKZD.js.map} +0 -0
  1181. /package/dist/{campaigns-N2SWSBYT.js.map → campaigns-HCJ3AIDK.js.map} +0 -0
  1182. /package/dist/{campaigns-5A3IE735.js.map → campaigns-NHACWGWS.js.map} +0 -0
  1183. /package/dist/{canvas-CHFNQTLY.js.map → canvas-INL3J7HO.js.map} +0 -0
  1184. /package/dist/{capabilities-2W3SRZ2I.js.map → capabilities-Y33EWDMJ.js.map} +0 -0
  1185. /package/dist/{cards-CXKIVM4D.js.map → cards-IWWKA5WH.js.map} +0 -0
  1186. /package/dist/{catalog-6BER3SF7.js.map → catalog-NSA2FUI2.js.map} +0 -0
  1187. /package/dist/{catalogs-G5NOKL4L.js.map → catalogs-SJMYID7N.js.map} +0 -0
  1188. /package/dist/{changes-AS4RVEAL.js.map → changes-2HOF2HSV.js.map} +0 -0
  1189. /package/dist/{chatgpt-O6EEAYLF.js.map → chatgpt-J6MNVQVT.js.map} +0 -0
  1190. /package/dist/{chats-4JLWMUAC.js.map → chats-4HK6UYD2.js.map} +0 -0
  1191. /package/dist/{chunk-UK4XSLV2.js.map → chunk-2B2JFTWI.js.map} +0 -0
  1192. /package/dist/{chunk-RULW4627.js.map → chunk-2O5CCKV7.js.map} +0 -0
  1193. /package/dist/{chunk-AXLKR3E4.js.map → chunk-3BKESS5W.js.map} +0 -0
  1194. /package/dist/{chunk-FLTAPEVY.js.map → chunk-3VBPJQ7L.js.map} +0 -0
  1195. /package/dist/{chunk-6OZDN2FI.js.map → chunk-3X262BEG.js.map} +0 -0
  1196. /package/dist/{chunk-DGHSXHZR.js.map → chunk-4CYB33V3.js.map} +0 -0
  1197. /package/dist/{chunk-CST52ZME.js.map → chunk-4JB556VC.js.map} +0 -0
  1198. /package/dist/{chunk-H4RHZJ65.js.map → chunk-4QYZJPSM.js.map} +0 -0
  1199. /package/dist/{chunk-H6ASYVQX.js.map → chunk-4WLJYLRL.js.map} +0 -0
  1200. /package/dist/{chunk-V4HS5JRL.js.map → chunk-56ZJO7TM.js.map} +0 -0
  1201. /package/dist/{chunk-AQRBEPZL.js.map → chunk-5LQGW5UF.js.map} +0 -0
  1202. /package/dist/{chunk-HXSYWXLH.js.map → chunk-5U6OL4NN.js.map} +0 -0
  1203. /package/dist/{chunk-YAINUFSC.js.map → chunk-6IL7JFX5.js.map} +0 -0
  1204. /package/dist/{chunk-Q5XUFN2W.js.map → chunk-6LNCKT6S.js.map} +0 -0
  1205. /package/dist/{chunk-B64KJW5C.js.map → chunk-6LUDG5AB.js.map} +0 -0
  1206. /package/dist/{chunk-ZCGM7ZWM.js.map → chunk-6UQV5DOD.js.map} +0 -0
  1207. /package/dist/{chunk-L7I47VGM.js.map → chunk-6WA7QSCN.js.map} +0 -0
  1208. /package/dist/{chunk-BEZEZHQ6.js.map → chunk-7CHPHER2.js.map} +0 -0
  1209. /package/dist/{chunk-RIVQ4PQQ.js.map → chunk-7J7ASYIM.js.map} +0 -0
  1210. /package/dist/{chunk-ZBXV2KOQ.js.map → chunk-7MMTIJO3.js.map} +0 -0
  1211. /package/dist/{chunk-3QPG2D27.js.map → chunk-AA3D7GZF.js.map} +0 -0
  1212. /package/dist/{chunk-Q736UFSD.js.map → chunk-AGL7EWP2.js.map} +0 -0
  1213. /package/dist/{chunk-KGJ6EIX3.js.map → chunk-AHVD6IEI.js.map} +0 -0
  1214. /package/dist/{chunk-3GXHML4V.js.map → chunk-ASJMLTMX.js.map} +0 -0
  1215. /package/dist/{chunk-XA7JN7YE.js.map → chunk-AWENMEFC.js.map} +0 -0
  1216. /package/dist/{chunk-EJ6EED6I.js.map → chunk-BHZLKLK7.js.map} +0 -0
  1217. /package/dist/{chunk-DHF4FXWS.js.map → chunk-BVER7I36.js.map} +0 -0
  1218. /package/dist/{chunk-MTW2NDDD.js.map → chunk-C3RZNVLM.js.map} +0 -0
  1219. /package/dist/{chunk-6AMN346B.js.map → chunk-CA5QBLIZ.js.map} +0 -0
  1220. /package/dist/{chunk-C52Q3L4C.js.map → chunk-CONTVNSN.js.map} +0 -0
  1221. /package/dist/{chunk-2CC4CPDT.js.map → chunk-EE6NZ6NG.js.map} +0 -0
  1222. /package/dist/{chunk-M4KFO256.js.map → chunk-EG6HMBCF.js.map} +0 -0
  1223. /package/dist/{chunk-MKOI6QYM.js.map → chunk-FHLAJYZE.js.map} +0 -0
  1224. /package/dist/{chunk-XA76OGSL.js.map → chunk-FSNQFZ2Z.js.map} +0 -0
  1225. /package/dist/{chunk-DW3H2XQA.js.map → chunk-G67OBCXI.js.map} +0 -0
  1226. /package/dist/{chunk-WTOBG3YL.js.map → chunk-GFYGVIT3.js.map} +0 -0
  1227. /package/dist/{chunk-3KUNRKNV.js.map → chunk-GRNHQWSV.js.map} +0 -0
  1228. /package/dist/{chunk-JAME5NBT.js.map → chunk-GWQSZWHT.js.map} +0 -0
  1229. /package/dist/{chunk-LAMSUL26.js.map → chunk-HBXR26LB.js.map} +0 -0
  1230. /package/dist/{chunk-EONUZOJV.js.map → chunk-HUO5MZ7S.js.map} +0 -0
  1231. /package/dist/{chunk-4INBMXUS.js.map → chunk-HVL22WUU.js.map} +0 -0
  1232. /package/dist/{chunk-AZIXX73C.js.map → chunk-IA5GLVRV.js.map} +0 -0
  1233. /package/dist/{chunk-LLTHDEM2.js.map → chunk-IEPCI2EB.js.map} +0 -0
  1234. /package/dist/{chunk-HQDNDKNR.js.map → chunk-IKSBLQTL.js.map} +0 -0
  1235. /package/dist/{chunk-X5YHMGAT.js.map → chunk-IRLMIKI7.js.map} +0 -0
  1236. /package/dist/{chunk-WYMX3F47.js.map → chunk-IW4MX7OX.js.map} +0 -0
  1237. /package/dist/{chunk-7NBQQOCU.js.map → chunk-J4WOF6WK.js.map} +0 -0
  1238. /package/dist/{chunk-75OGTGC4.js.map → chunk-J63TN3GR.js.map} +0 -0
  1239. /package/dist/{chunk-QRRAMUKV.js.map → chunk-JESSFI7R.js.map} +0 -0
  1240. /package/dist/{chunk-RQHXWPET.js.map → chunk-K4QPBXV7.js.map} +0 -0
  1241. /package/dist/{chunk-YAMKCMAS.js.map → chunk-K5VDDKKF.js.map} +0 -0
  1242. /package/dist/{chunk-WTPID22G.js.map → chunk-KM5K47TW.js.map} +0 -0
  1243. /package/dist/{chunk-EM5R3BYC.js.map → chunk-LGJIJVVH.js.map} +0 -0
  1244. /package/dist/{chunk-XHAGX4J4.js.map → chunk-LHSSIUU4.js.map} +0 -0
  1245. /package/dist/{chunk-EMR5KGNY.js.map → chunk-LQMPA4DY.js.map} +0 -0
  1246. /package/dist/{chunk-Z7ICQKC2.js.map → chunk-M3IXPK6U.js.map} +0 -0
  1247. /package/dist/{chunk-KG5VNPKU.js.map → chunk-MJU5VKX2.js.map} +0 -0
  1248. /package/dist/{chunk-RLLPY62L.js.map → chunk-MRGU3NPN.js.map} +0 -0
  1249. /package/dist/{chunk-ZMNRSTNV.js.map → chunk-MSLFPL77.js.map} +0 -0
  1250. /package/dist/{chunk-L4QEMWNJ.js.map → chunk-NKCWJPMN.js.map} +0 -0
  1251. /package/dist/{chunk-X7USE7IA.js.map → chunk-NT7NCSEB.js.map} +0 -0
  1252. /package/dist/{chunk-MFGUR5OD.js.map → chunk-OADMSHME.js.map} +0 -0
  1253. /package/dist/{chunk-6FQ7CJEX.js.map → chunk-ONGZKI5J.js.map} +0 -0
  1254. /package/dist/{chunk-RRKUXGAU.js.map → chunk-OOZNTJP6.js.map} +0 -0
  1255. /package/dist/{chunk-MIHY534L.js.map → chunk-OP3NHIFH.js.map} +0 -0
  1256. /package/dist/{chunk-5QNW5PCM.js.map → chunk-OU4KWL6B.js.map} +0 -0
  1257. /package/dist/{chunk-M5PZ6QQB.js.map → chunk-PLIGHRIQ.js.map} +0 -0
  1258. /package/dist/{chunk-4AO3LSYM.js.map → chunk-PLROJ3SX.js.map} +0 -0
  1259. /package/dist/{chunk-PR5OPERY.js.map → chunk-PSM3RI4B.js.map} +0 -0
  1260. /package/dist/{chunk-Q3G4ZI2U.js.map → chunk-Q4O7ICAK.js.map} +0 -0
  1261. /package/dist/{chunk-HFIHXIYY.js.map → chunk-Q6XM6ZDB.js.map} +0 -0
  1262. /package/dist/{chunk-NWLK5RPA.js.map → chunk-QHRUCSRI.js.map} +0 -0
  1263. /package/dist/{chunk-IYDESWW4.js.map → chunk-QUDPMIW7.js.map} +0 -0
  1264. /package/dist/{chunk-I3QLWGKS.js.map → chunk-R2JGUOT6.js.map} +0 -0
  1265. /package/dist/{chunk-RGLTITIH.js.map → chunk-R5I4IHJ5.js.map} +0 -0
  1266. /package/dist/{chunk-MSIOGH67.js.map → chunk-RJXO66C4.js.map} +0 -0
  1267. /package/dist/{chunk-CF5I4Q5M.js.map → chunk-RYNN6UUF.js.map} +0 -0
  1268. /package/dist/{chunk-SIRRBWQ2.js.map → chunk-S4V2GOKV.js.map} +0 -0
  1269. /package/dist/{chunk-6EOWBGGW.js.map → chunk-S7D4GTYY.js.map} +0 -0
  1270. /package/dist/{chunk-4HFM5RCP.js.map → chunk-T4RV7XOC.js.map} +0 -0
  1271. /package/dist/{chunk-HPF3USL2.js.map → chunk-TDUAGNSQ.js.map} +0 -0
  1272. /package/dist/{chunk-JLAFNORO.js.map → chunk-TZRWET3S.js.map} +0 -0
  1273. /package/dist/{chunk-XY7W6MQN.js.map → chunk-U5V4CIIG.js.map} +0 -0
  1274. /package/dist/{chunk-DPOUS5DN.js.map → chunk-U625CQ3Y.js.map} +0 -0
  1275. /package/dist/{chunk-UVUY6FLV.js.map → chunk-UDEVIXKX.js.map} +0 -0
  1276. /package/dist/{chunk-LJEJCIHR.js.map → chunk-UUDWZIDC.js.map} +0 -0
  1277. /package/dist/{chunk-6D7WTUF3.js.map → chunk-VAQBBNLD.js.map} +0 -0
  1278. /package/dist/{chunk-BIBXZJZI.js.map → chunk-VCDFBFPT.js.map} +0 -0
  1279. /package/dist/{chunk-MPTNN35I.js.map → chunk-VF3W7CI7.js.map} +0 -0
  1280. /package/dist/{chunk-BMK4F4CU.js.map → chunk-VHOOAQY4.js.map} +0 -0
  1281. /package/dist/{chunk-6MJKVNLL.js.map → chunk-VK2VC6A2.js.map} +0 -0
  1282. /package/dist/{chunk-3WN5GWX4.js.map → chunk-WWPRSJOS.js.map} +0 -0
  1283. /package/dist/{chunk-O5VSYBUA.js.map → chunk-XKYFNMTB.js.map} +0 -0
  1284. /package/dist/{chunk-KJHG2DWS.js.map → chunk-XL42ZEVH.js.map} +0 -0
  1285. /package/dist/{chunk-TCLJRWST.js.map → chunk-XPUQFPIU.js.map} +0 -0
  1286. /package/dist/{chunk-CBVUO7SK.js.map → chunk-XQEHLDGP.js.map} +0 -0
  1287. /package/dist/{chunk-S5S54J2K.js.map → chunk-XQWC223L.js.map} +0 -0
  1288. /package/dist/{chunk-JAK5VDSG.js.map → chunk-XYDHBLZ2.js.map} +0 -0
  1289. /package/dist/{chunk-V7EN5LFS.js.map → chunk-XZO6ONVI.js.map} +0 -0
  1290. /package/dist/{chunk-H25GY4U4.js.map → chunk-YFFQ3HY4.js.map} +0 -0
  1291. /package/dist/{chunk-URGXEDFV.js.map → chunk-YGUGL4ZL.js.map} +0 -0
  1292. /package/dist/{chunk-TLQY4QBW.js.map → chunk-YT3S2XFG.js.map} +0 -0
  1293. /package/dist/{chunk-QGAUDVMR.js.map → chunk-ZPCZ4XDB.js.map} +0 -0
  1294. /package/dist/{cite-WCAOCOO5.js.map → cite-2ZJG3FBV.js.map} +0 -0
  1295. /package/dist/{claim-L4WLCVUL.js.map → claim-IGU5W4CT.js.map} +0 -0
  1296. /package/dist/{client-VCKP6WBR.js.map → client-MSRCSDB7.js.map} +0 -0
  1297. /package/dist/{code-VXOTFGD2.js.map → code-T7Z5JDQ2.js.map} +0 -0
  1298. /package/dist/{companies-HW46BRQG.js.map → companies-HCSBVXCE.js.map} +0 -0
  1299. /package/dist/{company-KCIDE7SL.js.map → company-SSMY4G2T.js.map} +0 -0
  1300. /package/dist/{complete-JXM25FVW.js.map → complete-FQNRXUI5.js.map} +0 -0
  1301. /package/dist/{config-UR45YCIN.js.map → config-XRPKA5QR.js.map} +0 -0
  1302. /package/dist/{connect-7TX7AAM5.js.map → connect-VXEE3QBU.js.map} +0 -0
  1303. /package/dist/{content-EQQIKG5H.js.map → content-2JFP747N.js.map} +0 -0
  1304. /package/dist/{conversation-YIDUB6GL.js.map → conversation-KKJKZIX5.js.map} +0 -0
  1305. /package/dist/{conversion-report-33SG7SHU.js.map → conversion-report-G65UHQRO.js.map} +0 -0
  1306. /package/dist/{conversion-writes-XGGTBML5.js.map → conversion-writes-333V4OVR.js.map} +0 -0
  1307. /package/dist/{conversions-F4OZYUCT.js.map → conversions-7UHCNIAO.js.map} +0 -0
  1308. /package/dist/{conversions-PPP4QK7U.js.map → conversions-L6775Q22.js.map} +0 -0
  1309. /package/dist/{countries-GRCU4IGM.js.map → countries-XJVDM635.js.map} +0 -0
  1310. /package/dist/{create-6EAKNERA.js.map → create-AXWJECPP.js.map} +0 -0
  1311. /package/dist/{create-FDNMIVFX.js.map → create-B24XHUGZ.js.map} +0 -0
  1312. /package/dist/{create-772LZHZR.js.map → create-HJKTD5FN.js.map} +0 -0
  1313. /package/dist/{create-X2QM7GA7.js.map → create-V4NGP5KB.js.map} +0 -0
  1314. /package/dist/{creatives-4EPM3RHG.js.map → creatives-OKFLX67Y.js.map} +0 -0
  1315. /package/dist/{creatives-SNYN4KIM.js.map → creatives-WX6GQ37F.js.map} +0 -0
  1316. /package/dist/{credentials-KZZVBO42.js.map → credentials-4JFUH6FN.js.map} +0 -0
  1317. /package/dist/{crm-M6NXDU5B.js.map → crm-6MLYUEK7.js.map} +0 -0
  1318. /package/dist/{crm-4LZZVT4N.js.map → crm-PUQBWZKE.js.map} +0 -0
  1319. /package/dist/{crop-NE7YX4SS.js.map → crop-V5MSIY5F.js.map} +0 -0
  1320. /package/dist/{currency-HK2ZW2VW.js.map → currency-SCSJ5FW2.js.map} +0 -0
  1321. /package/dist/{custom-conversions-GQTU5E6X.js.map → custom-conversions-GN4JDS5F.js.map} +0 -0
  1322. /package/dist/{customers-V5NT4W7X.js.map → customers-WXD2LTUC.js.map} +0 -0
  1323. /package/dist/{decide-6Q5X3V3F.js.map → decide-PW2NRMRK.js.map} +0 -0
  1324. /package/dist/{delete-YOEI63OT.js.map → delete-EAJN6ZHT.js.map} +0 -0
  1325. /package/dist/{delete-LFZIPQEO.js.map → delete-GDIFIYA2.js.map} +0 -0
  1326. /package/dist/{delete-GQIKNO53.js.map → delete-JQG3ZWQX.js.map} +0 -0
  1327. /package/dist/{delete-SP66F7ZV.js.map → delete-L7CGJ23X.js.map} +0 -0
  1328. /package/dist/{delete-QHDDR66K.js.map → delete-OQREQEGN.js.map} +0 -0
  1329. /package/dist/{delete-EKKOEB3N.js.map → delete-ZR3DVLWU.js.map} +0 -0
  1330. /package/dist/{demographics-CEQ74O74.js.map → demographics-LMRGNO7J.js.map} +0 -0
  1331. /package/dist/{describe-MAGTSOW4.js.map → describe-OHWLLBDE.js.map} +0 -0
  1332. /package/dist/{describe-DJPIUEFE.js.map → describe-YELOXWHY.js.map} +0 -0
  1333. /package/dist/{dimensions-IC2H7V3H.js.map → dimensions-CLLCVVRY.js.map} +0 -0
  1334. /package/dist/{discard-5GDF3TP3.js.map → discard-K2KIIFJQ.js.map} +0 -0
  1335. /package/dist/{discover-PSL2NBJL.js.map → discover-SQJLRS4G.js.map} +0 -0
  1336. /package/dist/{discover-Q5PAOIQQ.js.map → discover-UJMDGDQO.js.map} +0 -0
  1337. /package/dist/{domain-PKOUPHHF.js.map → domain-CJX5JSLS.js.map} +0 -0
  1338. /package/dist/{download-2WNTN7JQ.js.map → download-HFDBP6BO.js.map} +0 -0
  1339. /package/dist/{download-EHDJXBAC.js.map → download-SZ5P3GLV.js.map} +0 -0
  1340. /package/dist/{draft-L2NXCIYT.js.map → draft-7QDE2Z3N.js.map} +0 -0
  1341. /package/dist/{draft-27NMTARB.js.map → draft-ILXHFWTT.js.map} +0 -0
  1342. /package/dist/{draft-RZCTAOI2.js.map → draft-NUFU5YME.js.map} +0 -0
  1343. /package/dist/{draft-UEVBUNKV.js.map → draft-QSTD3DH2.js.map} +0 -0
  1344. /package/dist/{draft-MWYKIZC4.js.map → draft-TV5IH5U4.js.map} +0 -0
  1345. /package/dist/{draft-JESKGZ6O.js.map → draft-WNMHUFAH.js.map} +0 -0
  1346. /package/dist/{env-NZXNMWSD.js.map → env-3256G2OE.js.map} +0 -0
  1347. /package/dist/{experiment-XAYSEYTU.js.map → experiment-5L5USMAL.js.map} +0 -0
  1348. /package/dist/{export-W54UZ62P.js.map → export-YSOM4E3B.js.map} +0 -0
  1349. /package/dist/{extract-6HJXSOZW.js.map → extract-7FYXXEQZ.js.map} +0 -0
  1350. /package/dist/{facets-TBOXGYJT.js.map → facets-2FRELYRC.js.map} +0 -0
  1351. /package/dist/{favorites-Y6CT6NSQ.js.map → favorites-LTG2F6W2.js.map} +0 -0
  1352. /package/dist/{feed-35BRQPTH.js.map → feed-RSBWEI75.js.map} +0 -0
  1353. /package/dist/{feedback-MSMFYAEY.js.map → feedback-PQUM7UBT.js.map} +0 -0
  1354. /package/dist/{fetch-I6P72CDL.js.map → fetch-3PWYTX4R.js.map} +0 -0
  1355. /package/dist/{fetch-LGX7B3IC.js.map → fetch-FLQYW27W.js.map} +0 -0
  1356. /package/dist/{find-SVGRA7IA.js.map → find-SHHDWCPM.js.map} +0 -0
  1357. /package/dist/{fit-RVWPRBNO.js.map → fit-4XCDLF7C.js.map} +0 -0
  1358. /package/dist/{flows-LA6EYMLS.js.map → flows-4ALWJVNF.js.map} +0 -0
  1359. /package/dist/{follow-24QSDNAG.js.map → follow-N4TKU3UM.js.map} +0 -0
  1360. /package/dist/{follow-competitors-AG4E4XFA.js.map → follow-competitors-AHQ57BWS.js.map} +0 -0
  1361. /package/dist/{following-YGM6TBK3.js.map → following-CEYH33DW.js.map} +0 -0
  1362. /package/dist/{fonts-WRC34VSV.js.map → fonts-CYJ5EFR4.js.map} +0 -0
  1363. /package/dist/{forecast-6VHRGBJG.js.map → forecast-SG2VUBZD.js.map} +0 -0
  1364. /package/dist/{funding-WZNGXRLJ.js.map → funding-X7M5WLDX.js.map} +0 -0
  1365. /package/dist/{funnel-U3GQIGND.js.map → funnel-F7DS7PUN.js.map} +0 -0
  1366. /package/dist/{ga4-W3U5YTRT.js.map → ga4-QPBAKGSH.js.map} +0 -0
  1367. /package/dist/{generate-Y4NJEYIH.js.map → generate-LVBI3VDD.js.map} +0 -0
  1368. /package/dist/{get-YWDZYEAC.js.map → get-DMV7KG2F.js.map} +0 -0
  1369. /package/dist/{get-GEUSRD5Y.js.map → get-EA7AX4NW.js.map} +0 -0
  1370. /package/dist/{get-TS2ZJDCQ.js.map → get-EOSJWMWT.js.map} +0 -0
  1371. /package/dist/{get-JIZPYK3Z.js.map → get-HVQHHDW6.js.map} +0 -0
  1372. /package/dist/{get-3MTAVNTP.js.map → get-KQLCVQCK.js.map} +0 -0
  1373. /package/dist/{get-PF3HGECD.js.map → get-NAOMB6Q2.js.map} +0 -0
  1374. /package/dist/{get-5SPNAIUQ.js.map → get-XYJBQFIT.js.map} +0 -0
  1375. /package/dist/{get-AHI247JG.js.map → get-XZ7XPXZE.js.map} +0 -0
  1376. /package/dist/{gif-NP6EDGEE.js.map → gif-XJ26IWAP.js.map} +0 -0
  1377. /package/dist/{google-ZVAIFXQZ.js.map → google-QOKWSPOA.js.map} +0 -0
  1378. /package/dist/{google-ads-6Z7P3SCD.js.map → google-ads-B4FBPQ7O.js.map} +0 -0
  1379. /package/dist/{group-3DT4UYSR.js.map → group-7EYM3PNJ.js.map} +0 -0
  1380. /package/dist/{group-OEKKCFXT.js.map → group-GDTEICRY.js.map} +0 -0
  1381. /package/dist/{gsc-4FEFPFPB.js.map → gsc-KVIAZMF4.js.map} +0 -0
  1382. /package/dist/{history-VKRYKQ4C.js.map → history-22YGILIT.js.map} +0 -0
  1383. /package/dist/{history-4QUV45ZJ.js.map → history-E3JGYADF.js.map} +0 -0
  1384. /package/dist/{history-PD7FCTDD.js.map → history-HKCSYH5L.js.map} +0 -0
  1385. /package/dist/{hubspot-WEFAFKVJ.js.map → hubspot-LEW2RP5D.js.map} +0 -0
  1386. /package/dist/{icon-43UJTGGE.js.map → icon-JLVEYF34.js.map} +0 -0
  1387. /package/dist/{ideas-SMSEXKIA.js.map → ideas-JAIU4GC4.js.map} +0 -0
  1388. /package/dist/{images-KAT4BPYV.js.map → images-ZG6RRAEP.js.map} +0 -0
  1389. /package/dist/{improve-IMXQN6OD.js.map → improve-XSHWCMZS.js.map} +0 -0
  1390. /package/dist/{ingest-IHKTSJ4H.js.map → ingest-GTXBGUNQ.js.map} +0 -0
  1391. /package/dist/{ingest-TOHQ6MZA.js.map → ingest-SX7K6GNE.js.map} +0 -0
  1392. /package/dist/{insights-3IPSEBYW.js.map → insights-IVUUWSQL.js.map} +0 -0
  1393. /package/dist/{insights-BR3456EI.js.map → insights-PJPQB46E.js.map} +0 -0
  1394. /package/dist/{inspect-5MZBPDYS.js.map → inspect-55BXSPJG.js.map} +0 -0
  1395. /package/dist/{inspiration-XZI5KCQW.js.map → inspiration-NBOKHPZ5.js.map} +0 -0
  1396. /package/dist/{intent-ZM4K623V.js.map → intent-KSVTHFFE.js.map} +0 -0
  1397. /package/dist/{job-GOX3KIKG.js.map → job-4VXDCYSG.js.map} +0 -0
  1398. /package/dist/{job-create-F2PQSN3C.js.map → job-create-NZEZDOZT.js.map} +0 -0
  1399. /package/dist/{job-status-3FMA5D7T.js.map → job-status-XI3ENS7D.js.map} +0 -0
  1400. /package/dist/{keep-23ZYMWPG.js.map → keep-UYNOC3JZ.js.map} +0 -0
  1401. /package/dist/{keyword-gap-FAAF2I6V.js.map → keyword-gap-7UVDSID5.js.map} +0 -0
  1402. /package/dist/{keyword-metrics-EXNJRJBY.js.map → keyword-metrics-QFRXZRAQ.js.map} +0 -0
  1403. /package/dist/{keywords-for-site-5LW77QWF.js.map → keywords-for-site-Q4BCJ4PQ.js.map} +0 -0
  1404. /package/dist/{knowledge-7M7DSRF3.js.map → knowledge-LVE3J3AK.js.map} +0 -0
  1405. /package/dist/{landing-ZH4SD3DW.js.map → landing-AJYM5GBY.js.map} +0 -0
  1406. /package/dist/{landings-VNQ4VA2U.js.map → landings-SIN3MTUZ.js.map} +0 -0
  1407. /package/dist/{languages-ZGDTERIQ.js.map → languages-AIASAINW.js.map} +0 -0
  1408. /package/dist/{languages-2X22HXM3.js.map → languages-RDR6EBNJ.js.map} +0 -0
  1409. /package/dist/{launches-L4EUROCJ.js.map → launches-4TVHXAZT.js.map} +0 -0
  1410. /package/dist/{layerize-6QHQMA7Q.js.map → layerize-OLVGZRND.js.map} +0 -0
  1411. /package/dist/{lead-routes-5TPFJEVH.js.map → lead-routes-ZOQDPCR3.js.map} +0 -0
  1412. /package/dist/{leads-736RILZN.js.map → leads-YSDLFBHN.js.map} +0 -0
  1413. /package/dist/{learn-BESXWXEN.js.map → learn-FDQZNIP3.js.map} +0 -0
  1414. /package/dist/{library-MNJC24E4.js.map → library-7CLWRDM3.js.map} +0 -0
  1415. /package/dist/{lighthouse-DJMAXFTD.js.map → lighthouse-3ACQ3MVG.js.map} +0 -0
  1416. /package/dist/{line-item-writes-FA72DHNQ.js.map → line-item-writes-JARN73DV.js.map} +0 -0
  1417. /package/dist/{line-items-XVYE3IYT.js.map → line-items-B5GLDAJ2.js.map} +0 -0
  1418. /package/dist/{link-6FPKFVC3.js.map → link-YAZF34BZ.js.map} +0 -0
  1419. /package/dist/{linkedin-person-TZJ6VEXE.js.map → linkedin-person-XDH7Q3PB.js.map} +0 -0
  1420. /package/dist/{list-537S75BZ.js.map → list-6NYRZXKQ.js.map} +0 -0
  1421. /package/dist/{list-WIXQXNKB.js.map → list-6WISGNQ2.js.map} +0 -0
  1422. /package/dist/{list-Q52FPW3H.js.map → list-6YBIWX44.js.map} +0 -0
  1423. /package/dist/{list-4R5EMKUQ.js.map → list-72JQGWNO.js.map} +0 -0
  1424. /package/dist/{list-ORO4WDF4.js.map → list-FX7OG3OJ.js.map} +0 -0
  1425. /package/dist/{list-2277GCPH.js.map → list-ITPBLMV3.js.map} +0 -0
  1426. /package/dist/{list-XK33NCSC.js.map → list-J43GOBOX.js.map} +0 -0
  1427. /package/dist/{list-V4PSDBLX.js.map → list-K4Z3BOWI.js.map} +0 -0
  1428. /package/dist/{list-MN2FPF3T.js.map → list-ONSYTCX2.js.map} +0 -0
  1429. /package/dist/{locations-A65MFB7Q.js.map → locations-UNSREUBX.js.map} +0 -0
  1430. /package/dist/{locations-WN6B3IJK.js.map → locations-XAC3GME3.js.map} +0 -0
  1431. /package/dist/{log-ABBZLPRU.js.map → log-PPNNFETI.js.map} +0 -0
  1432. /package/dist/{logo-4LSFZ3ZO.js.map → logo-UNVIMA4B.js.map} +0 -0
  1433. /package/dist/{lookup-WIM5WR25.js.map → lookup-L5QG3BWH.js.map} +0 -0
  1434. /package/dist/{map-52P35OKE.js.map → map-QILMIKS7.js.map} +0 -0
  1435. /package/dist/{mcp-PZ3VBIF4.js.map → mcp-GOKFM4PF.js.map} +0 -0
  1436. /package/dist/{media-KKI3KWLR.js.map → media-BN6B75NF.js.map} +0 -0
  1437. /package/dist/{media-34I7UB7Z.js.map → media-YDDWV32Y.js.map} +0 -0
  1438. /package/dist/{media-sources-TT374PLN.js.map → media-sources-HABLVJE3.js.map} +0 -0
  1439. /package/dist/{members-CF6VG6ZW.js.map → members-B4UI6ISY.js.map} +0 -0
  1440. /package/dist/{meme-6NFYFQ7T.js.map → meme-2MERLAVW.js.map} +0 -0
  1441. /package/dist/{meta-2UK7KIE4.js.map → meta-7FJQD44L.js.map} +0 -0
  1442. /package/dist/{metrics-3U3ZO2RF.js.map → metrics-SBKBEZJR.js.map} +0 -0
  1443. /package/dist/{models-VOSJJFO2.js.map → models-ZBLBNNEH.js.map} +0 -0
  1444. /package/dist/{normalize-G75RDSE4.js.map → normalize-5WVEQJXD.js.map} +0 -0
  1445. /package/dist/{normalize-4LZCLMTQ.js.map → normalize-YPQBHWYS.js.map} +0 -0
  1446. /package/dist/{options-6IRL7CL6.js.map → options-BV3TVUCK.js.map} +0 -0
  1447. /package/dist/{organization-WMLLJE66.js.map → organization-4OTGNRHP.js.map} +0 -0
  1448. /package/dist/{output-ELEO2Z6R.js.map → output-FX4KJAO5.js.map} +0 -0
  1449. /package/dist/{page-4X6IBUWG.js.map → page-5KWQ7PM3.js.map} +0 -0
  1450. /package/dist/{pages-7HW5YOZV.js.map → pages-HKTAGXH3.js.map} +0 -0
  1451. /package/dist/{performance-A7CYFBW2.js.map → performance-4MWQVTTA.js.map} +0 -0
  1452. /package/dist/{performance-HYSTXLTS.js.map → performance-TKE7NQF6.js.map} +0 -0
  1453. /package/dist/{pinterest-KA6VFDM4.js.map → pinterest-UDX53CWY.js.map} +0 -0
  1454. /package/dist/{pixels-D5HF24FI.js.map → pixels-BSNCVT77.js.map} +0 -0
  1455. /package/dist/{pixels-U6UA662G.js.map → pixels-TR2PAYWV.js.map} +0 -0
  1456. /package/dist/{plan-XCA6R3HZ.js.map → plan-V57AATQ5.js.map} +0 -0
  1457. /package/dist/{posts-ALGM6ONV.js.map → posts-JHMXNHDV.js.map} +0 -0
  1458. /package/dist/{preview-55TRUF4Q.js.map → preview-VY7UH2SK.js.map} +0 -0
  1459. /package/dist/{preview-76ZP2QA3.js.map → preview-XUG4K4KV.js.map} +0 -0
  1460. /package/dist/{profile-NHUPUCBR.js.map → profile-PV3R3BEG.js.map} +0 -0
  1461. /package/dist/{promoted-tweet-writes-I5G4IDL5.js.map → promoted-tweet-writes-O3S5OKUZ.js.map} +0 -0
  1462. /package/dist/{promoted-tweets-X5XNO7IT.js.map → promoted-tweets-4ZKSEC4I.js.map} +0 -0
  1463. /package/dist/{properties-2ZXA5BPJ.js.map → properties-U2XUD2M6.js.map} +0 -0
  1464. /package/dist/{publish-S2Z4EF4H.js.map → publish-4RAYD7VI.js.map} +0 -0
  1465. /package/dist/{query-SAQADBM2.js.map → query-4C6UQN42.js.map} +0 -0
  1466. /package/dist/{query-63CTX2PH.js.map → query-7FWE7GLV.js.map} +0 -0
  1467. /package/dist/{query-DMWY3TDD.js.map → query-7Y2Y6YFI.js.map} +0 -0
  1468. /package/dist/{questionnaire-WHE42RD4.js.map → questionnaire-3IPJXJT7.js.map} +0 -0
  1469. /package/dist/{read-NESEKULG.js.map → read-WEQLEI7R.js.map} +0 -0
  1470. /package/dist/{reddit-S2L5WDY7.js.map → reddit-2FWCB7XY.js.map} +0 -0
  1471. /package/dist/{refresh-K2YTJSH3.js.map → refresh-SGDB4QOD.js.map} +0 -0
  1472. /package/dist/{refresh-ILDEPU5A.js.map → refresh-WZBVPKWE.js.map} +0 -0
  1473. /package/dist/{release-FX76IIVN.js.map → release-YL3ZII3Z.js.map} +0 -0
  1474. /package/dist/{relevant-pages-KTSODNNW.js.map → relevant-pages-PF3LLUED.js.map} +0 -0
  1475. /package/dist/{remove-NHE4UT7G.js.map → remove-52MSQXSW.js.map} +0 -0
  1476. /package/dist/{remove-LOVWPLDO.js.map → remove-EIV7LJUA.js.map} +0 -0
  1477. /package/dist/{reopen-DXV2Y6Z3.js.map → reopen-CW27MUJH.js.map} +0 -0
  1478. /package/dist/{research-7PGDAKC7.js.map → research-234BOCKM.js.map} +0 -0
  1479. /package/dist/{research-HY5PSUCC.js.map → research-RABLL4HR.js.map} +0 -0
  1480. /package/dist/{reset-Y5VZJRDQ.js.map → reset-5KJDDVJL.js.map} +0 -0
  1481. /package/dist/{reset-MEHUQJA4.js.map → reset-REUL47CB.js.map} +0 -0
  1482. /package/dist/{resolve-FAVABEJW.js.map → resolve-WRDEHLYL.js.map} +0 -0
  1483. /package/dist/{retry-OMJ3C3AX.js.map → retry-2A5HV4SN.js.map} +0 -0
  1484. /package/dist/{retry-5IY4MNDW.js.map → retry-FNT2XVH3.js.map} +0 -0
  1485. /package/dist/{retry-failed-R5HPQ3KQ.js.map → retry-failed-ND7UXYTJ.js.map} +0 -0
  1486. /package/dist/{rules-FYVD2QBB.js.map → rules-2CUG2YG7.js.map} +0 -0
  1487. /package/dist/{run-LJVBH3JS.js.map → run-RKLNKV2U.js.map} +0 -0
  1488. /package/dist/{run-XJBWDWN6.js.map → run-YKGN3GQR.js.map} +0 -0
  1489. /package/dist/{schedule-D7EDEM45.js.map → schedule-774JCRVM.js.map} +0 -0
  1490. /package/dist/{schedule-OX5XHXLH.js.map → schedule-PKKSZ5RX.js.map} +0 -0
  1491. /package/dist/{scheduled-agents-A5ZFQB5X.js.map → scheduled-agents-ZI3EWKAT.js.map} +0 -0
  1492. /package/dist/{schema-NTGHAPR2.js.map → schema-BXNL4LKR.js.map} +0 -0
  1493. /package/dist/{schema-Z43AJOJ4.js.map → schema-GFMVUZL2.js.map} +0 -0
  1494. /package/dist/{scrape-VL2RWSTW.js.map → scrape-KKLE4WAU.js.map} +0 -0
  1495. /package/dist/{screenshot-Y6EEXS3Q.js.map → screenshot-K6XOER6Z.js.map} +0 -0
  1496. /package/dist/{search-TXBYKNQC.js.map → search-43ULIJL3.js.map} +0 -0
  1497. /package/dist/{search-CXC7N5XJ.js.map → search-AXUNJUWY.js.map} +0 -0
  1498. /package/dist/{search-XHSTUBDY.js.map → search-DLLJEYMB.js.map} +0 -0
  1499. /package/dist/{search-L3GTZYRW.js.map → search-LWWTXBB2.js.map} +0 -0
  1500. /package/dist/{search-JEXYEAPQ.js.map → search-VU6GI3U3.js.map} +0 -0
  1501. /package/dist/{search-WCXQBMMM.js.map → search-XO365KES.js.map} +0 -0
  1502. /package/dist/{search-copy-FIPG7OCC.js.map → search-copy-BHNLLCUV.js.map} +0 -0
  1503. /package/dist/{seeds-ADJKURNG.js.map → seeds-6ROVZBFB.js.map} +0 -0
  1504. /package/dist/{sends-RS4LWRAC.js.map → sends-P6OPCYH5.js.map} +0 -0
  1505. /package/dist/{sequences-2RPKDKGQ.js.map → sequences-DP4BHM3E.js.map} +0 -0
  1506. /package/dist/{setup-links-4HCSF55G.js.map → setup-links-T5TJZA3E.js.map} +0 -0
  1507. /package/dist/{shared-4GGUIOF2.js.map → shared-24IPELBM.js.map} +0 -0
  1508. /package/dist/{shopify-GDR5WGHH.js.map → shopify-OQEKI7HC.js.map} +0 -0
  1509. /package/dist/{site-B7LT6KAO.js.map → site-QRLBZPEV.js.map} +0 -0
  1510. /package/dist/{sitemaps-Z6IELTQV.js.map → sitemaps-SWADO4SI.js.map} +0 -0
  1511. /package/dist/{sites-KLAKI2EY.js.map → sites-H3FYJQFO.js.map} +0 -0
  1512. /package/dist/{skills-OJP36EVR.js.map → skills-OYO6Y3DQ.js.map} +0 -0
  1513. /package/dist/{sources-OSUXCLID.js.map → sources-U2WRH6D7.js.map} +0 -0
  1514. /package/dist/{sources-6DPUEROC.js.map → sources-Y2BKZVXA.js.map} +0 -0
  1515. /package/dist/{stats-MIMFX4R7.js.map → stats-TTJHXR3E.js.map} +0 -0
  1516. /package/dist/{status-KIC3P5JV.js.map → status-4BSXND3I.js.map} +0 -0
  1517. /package/dist/{sticker-IREEEN7I.js.map → sticker-CRIAIO75.js.map} +0 -0
  1518. /package/dist/{stock-VWFUFRYV.js.map → stock-TOFKLWSR.js.map} +0 -0
  1519. /package/dist/{studies-YGYAH3JI.js.map → studies-VFNWS6ND.js.map} +0 -0
  1520. /package/dist/{studio-XLC37YGX.js.map → studio-WD364TWB.js.map} +0 -0
  1521. /package/dist/{suggest-5RTISDLI.js.map → suggest-GX4IROQN.js.map} +0 -0
  1522. /package/dist/{sync-OHIXI4I6.js.map → sync-BU7HU3FS.js.map} +0 -0
  1523. /package/dist/{sync-QBW4XH2H.js.map → sync-GQL5JX4U.js.map} +0 -0
  1524. /package/dist/{sync-VCAFAYW4.js.map → sync-VNBBOVBU.js.map} +0 -0
  1525. /package/dist/{sync-definition-4KMJK46H.js.map → sync-definition-EOARPSBS.js.map} +0 -0
  1526. /package/dist/{tag-DSCUKNC3.js.map → tag-SQ5ROLTP.js.map} +0 -0
  1527. /package/dist/{tag-manager-IINALUEJ.js.map → tag-manager-7S7PVYIJ.js.map} +0 -0
  1528. /package/dist/{tags-7RKKCQ4X.js.map → tags-2226Q3VK.js.map} +0 -0
  1529. /package/dist/{tags-4F5UBPYG.js.map → tags-7QIBFIBX.js.map} +0 -0
  1530. /package/dist/{tags-QZJIP4LJ.js.map → tags-BNWKAV3H.js.map} +0 -0
  1531. /package/dist/{tags-CB4MWI3A.js.map → tags-HG5EBHSO.js.map} +0 -0
  1532. /package/dist/{tags-4O5FPEEY.js.map → tags-WTN4EBT5.js.map} +0 -0
  1533. /package/dist/{targeting-constants-54S3FXIF.js.map → targeting-constants-6KZXMRNI.js.map} +0 -0
  1534. /package/dist/{targeting-criteria-65UU7EYD.js.map → targeting-criteria-QSCRW75G.js.map} +0 -0
  1535. /package/dist/{targets-T742OPQI.js.map → targets-3KT3DO6O.js.map} +0 -0
  1536. /package/dist/{terms-OFHNLW6U.js.map → terms-IRLEAMIY.js.map} +0 -0
  1537. /package/dist/{testimonials-HKJJXONO.js.map → testimonials-35FTFNQ5.js.map} +0 -0
  1538. /package/dist/{top-companies-T6AMU4C6.js.map → top-companies-JAWMSK2Q.js.map} +0 -0
  1539. /package/dist/{transcript-DOUYMZAP.js.map → transcript-OIYU7F4E.js.map} +0 -0
  1540. /package/dist/{triggers-EYY4GSUL.js.map → triggers-7QRQFTVM.js.map} +0 -0
  1541. /package/dist/{tweets-TRTXC6O4.js.map → tweets-7XVF7PJO.js.map} +0 -0
  1542. /package/dist/{unfollow-DATOGPLZ.js.map → unfollow-ZCP6D2SC.js.map} +0 -0
  1543. /package/dist/{unlink-JNM4WRZK.js.map → unlink-PYCYTYVN.js.map} +0 -0
  1544. /package/dist/{unstage-QF4JT5YP.js.map → unstage-2OUF6ELM.js.map} +0 -0
  1545. /package/dist/{unstage-LLQCMZ5H.js.map → unstage-YADONHH6.js.map} +0 -0
  1546. /package/dist/{update-SD5YQIJC.js.map → update-DEBDSBDI.js.map} +0 -0
  1547. /package/dist/{update-J4DURR4K.js.map → update-IDUSNDOI.js.map} +0 -0
  1548. /package/dist/{update-6V3RBRIE.js.map → update-NG3HUYZZ.js.map} +0 -0
  1549. /package/dist/{update-J7Y6LZC5.js.map → update-P5IT7AIN.js.map} +0 -0
  1550. /package/dist/{update-MQ4NYIU6.js.map → update-U6NU7OXI.js.map} +0 -0
  1551. /package/dist/{upload-CEIYYPID.js.map → upload-4F2JICEH.js.map} +0 -0
  1552. /package/dist/{upload-7PPMVWVA.js.map → upload-SS64KHDS.js.map} +0 -0
  1553. /package/dist/{upscale-WVJZG76V.js.map → upscale-JNNXDN6X.js.map} +0 -0
  1554. /package/dist/{url-options-6WC2XQKB.js.map → url-options-EDPKAPPP.js.map} +0 -0
  1555. /package/dist/{url-params-OVBIP6UA.js.map → url-params-4G26OEOO.js.map} +0 -0
  1556. /package/dist/{use-6FADOAFZ.js.map → use-TKFP6WVP.js.map} +0 -0
  1557. /package/dist/{variant-RNM36P4J.js.map → variant-3VTKOQUR.js.map} +0 -0
  1558. /package/dist/{videos-GHFCOTT7.js.map → videos-EDTBHLOZ.js.map} +0 -0
  1559. /package/dist/{videos-Z72RXCRB.js.map → videos-JRNJH66J.js.map} +0 -0
  1560. /package/dist/{view-YR6MDLWL.js.map → view-6HX3FYMS.js.map} +0 -0
  1561. /package/dist/{viewer-check-655BZRML.js.map → viewer-check-OBBBAYV5.js.map} +0 -0
  1562. /package/dist/{web-4QN6QB7L.js.map → web-GPUEUIDT.js.map} +0 -0
  1563. /package/dist/{winners-4T5RFQXU.js.map → winners-MEC77MZ4.js.map} +0 -0
  1564. /package/dist/{winning-ads-2J2RIOLR.js.map → winning-ads-2DECFON4.js.map} +0 -0
  1565. /package/dist/{write-commands-UO3OQIHH.js.map → write-commands-D5M5A4YI.js.map} +0 -0
  1566. /package/dist/{write-commands-6D55SB56.js.map → write-commands-LQVERLAQ.js.map} +0 -0
  1567. /package/dist/{x-7KXNCWTJ.js.map → x-4TM5RET4.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/engine/scaffold/static-brief.ts","../src/engine/scaffold/static-plate.ts","../src/engine/scaffold/static-sizes.ts","../src/engine/scaffold/static-adapt.ts","../src/engine/lib/prompt-profiles.ts","../src/engine/scaffold/lib/image-params.ts","../src/engine/scaffold/static-topology.ts","../src/engine/scaffold/ad-brand-source.ts","../src/engine/client/backend-client.ts","../src/engine/engine/validator.ts","../src/engine/schema/canvas.ts","../src/engine/schema/prompts.ts","../src/engine/engine/credits.ts","../src/engine/engine/didyoumean.ts","../src/engine/engine/graph.ts","../src/engine/engine/lint/context.ts","../src/engine/engine/lint/rules/audio.ts","../src/engine/engine/lint/rules/image.ts","../src/engine/engine/lint/rules/video-prompt.ts","../src/engine/engine/lint/rules/video-timeline.ts","../src/engine/lib/speech.ts","../src/engine/lib/spine-input.ts","../src/engine/engine/lint/registry.ts","../src/engine/engine/prompt-limit.ts","../src/engine/engine/scheduler.ts","../src/engine/scaffold/static-logo.ts","../src/engine/nodes/local/lib/variant-prefilter.ts","../src/engine/nodes/local/lib/logo-raster.ts","../src/engine/lib/spell-number.ts"],"sourcesContent":["/**\n * The static ad brief: the ad spec (`static-ad-spec.ts`) compiled into the prompt one image\n * model is sent, following that model's profile (`prompt-profiles.ts`).\n *\n * The agent never writes a model prompt. It writes what the ad is; this writes it the way\n * each model reads best: short labelled sections for gpt-image, sentences that give the\n * reason for Gemini; every line of copy quoted once, lettered its own way, and allow-listed;\n * every picture numbered with one role, what must stay exact first; colours named, tied to\n * an object and taken from the brand; realism as capture cues; the safe area from its one\n * owner; the constraints last. `lintBrief` finds the contradictions an older prompt carried\n * (prompt-audit.md §1a), so the bench can gate on none.\n *\n * Pure: spec in, `{ prompt, references, params }` out.\n */\nimport { marketCountryName } from \"../../viewer-profile.ts\";\nimport type { CreativeRule } from \"../creative-rules/schema.ts\";\nimport { briefRules, rulesBlock } from \"../creative-rules/select.ts\";\nimport type { BriefImageRole, ImageModelProfile } from \"../lib/prompt-profiles.ts\";\nimport { blockingArea, type SafeArea, staticSafeArea } from \"./platform-safe-area.ts\";\nimport {\n type AdBrand,\n type AdCopyLine,\n type AdReference,\n type AdSpec,\n type AdThirdPartyBrand,\n type AdViewer,\n type ConceptCarry,\n HAND_LETTERED,\n HANDWRITING,\n isMemeTemplate,\n isVital,\n plainText,\n seesReferenceStructure,\n type VitalJob,\n withRenderedLettering,\n} from \"./static-ad-spec.ts\";\n\n/**\n * What the render does: a first render of the ad, a re-lay of a finished one to another shape, a\n * correction, or the next ad of a series (the lead's finished picture with only its words changed).\n */\nexport type BriefJob = \"generate\" | \"relay\" | \"fix\" | \"series\";\n\n/**\n * The pictures wired for this render, as the refs the canvas passes them by (or URLs on the\n * bench). `refs` maps a spec reference id (PRODUCT_1) to its picture; a spec reference with\n * no picture is described in the scene only. Omitted: every spec reference is wired under\n * its own id, and there is no logo, type specimen or source ad.\n */\nexport type BriefImages = {\n /** The ad to re-lay or correct. */\n base?: string;\n logo?: string;\n /** The specimen of the brand's typeface. */\n type?: string;\n /** The source ad. Sent only when `sourceLayout` asks for it. */\n layout?: string;\n refs?: Readonly<Record<string, string>>;\n};\n\n/**\n * The master's planned content band, and whether other sizes are cut from the master (the\n * reason the band is firm). `margin`: the render is the whole ad, cut to its format after it\n * renders (a 3:4 render filled to 4:5), so the band is its edge margin mapped onto the\n * rendered frame (`adaptPlan`), stated as edges rather than as a region.\n */\nexport type PlannedBand = { area: SafeArea; cut: boolean; margin?: boolean };\n\nexport type BriefOptions = {\n job?: BriefJob;\n /** Which of the three directions a first render takes (0 as written, 1 another picture, 2 another hook). */\n variant?: number;\n /** A correction's change, or a series ad's new words, in words. */\n instruction?: string;\n /**\n * What the person rejected in earlier versions of this ad, in their words (the case file,\n * `readCaseFile`): a correction is told, so it never brings a rejected direction back.\n */\n rejected?: readonly string[];\n /**\n * The company's rules for its ads (`readCreativeContext`): the ones a picture can keep are told\n * after the brief, outside its word budget, in a block the fingerprint leaves out (`briefRules`).\n */\n rules?: readonly CreativeRule[];\n images?: BriefImages;\n /** The ad set's placements (`staticSafeArea`); none = every placement the format runs in. */\n placements?: readonly string[];\n /**\n * The master's planned content band (`masterContentBand` in static-sizes.ts): stated as the\n * one region every word, the logo and the button sit in. Omitted: the format's own safe area.\n */\n band?: PlannedBand;\n /** The caller states the frame itself (the re-lays' zones, `adaptBrief`): the Layout states no safe area of its own. */\n zoned?: boolean;\n /**\n * The call sets the words and what carries them (a size's words, `wordsBrief`): each line's look (a tag,\n * a pill, the ✗ or ✓ beside it) is told whole at every trim level, and the marks it names are no stray\n * icon. Dev, Oct 2026: trimmed to \"designed\" and told to add no icon, a before/after lost its ✗/✓ proof.\n */\n looksWhole?: boolean;\n /**\n * Send the source ad as a layout-only reference, last. Off by default: with it on, the judge\n * called 35-37% of ads near-clones of the source vs 21% off, shippable fell 21% -> 16% and the\n * off arm won 60% head to head against it numbered last (63 ads, BENCH.md#E2).\n */\n sourceLayout?: boolean;\n};\n\n/** One picture the brief numbers: its place in the request, its one role, and the ref it travels as. */\nexport type BriefReference = { index: number; role: BriefImageRole; label: string; ref: string };\n\nexport type CompiledBrief = {\n prompt: string;\n /** The pictures in request order; `references[i].index === i + 1`. */\n references: BriefReference[];\n /** What the request asks for, before the registry snaps it to the pinned model. */\n params: { n: number; quality?: string; image_size?: string };\n words: number;\n};\n\n// --- Small text helpers. ---\n\nconst wordCount = (s: string): number => s.split(/\\s+/).filter(Boolean).length;\nconst sentence = (s: string): string => {\n const t = s.trim();\n return t && !/[.!?]$/.test(t) ? `${t}.` : t;\n};\nconst capitalize = (s: string): string => (s ? s[0]?.toUpperCase() + s.slice(1) : s);\n\n/**\n * Free text joined from several fields (\"…CTA bottom.\" + \". In the frame\") collapsed to one\n * mark per break: a run of marks keeps a leading ! or ?, else its last mark. An ellipsis\n * becomes \"…\" first so it survives.\n */\nfunction tidy(s: string): string {\n return s\n .replace(/\\.{3,}/g, \"…\")\n .replace(/([.!?,;:])(?:\\s*[.,;:])+/g, (run, first: string) =>\n /[!?]/.test(first) ? first : (run.trim().at(-1) ?? \"\"),\n );\n}\n\n/** A value the describe pass writes for \"nothing here\", never worth a clause. */\nconst EMPTY_CLAUSE = /^(none|null|nil|n a|na|not applicable)$/;\n\n/**\n * The clauses of a free text (split after , ; . ! ? and a space, so \"1.91:1\" and \"S.L.\" hold)\n * without the empty ones, the ones said already, and the ones `drop` rejects. A dropped clause\n * that ended a sentence hands its full stop to the clause before it.\n */\nfunction keepClauses(text: string, drop: (clause: string) => boolean = () => false): string {\n const kept: string[] = [];\n const seen = new Set<string>();\n for (const part of text.split(/(?<=[,;.!?])\\s+/)) {\n const body = normalized(part);\n if (body && !EMPTY_CLAUSE.test(body) && !seen.has(body) && !drop(part)) {\n seen.add(body);\n kept.push(part.trim());\n continue;\n }\n const end = part.trim().match(/[.!?]$/)?.[0];\n const last = kept.length - 1;\n if (end && last >= 0)\n kept[last] = (kept[last] ?? \"\").replace(/[,;:]?$/, (m) => (/[.!?]$/.test(kept[last] ?? \"\") ? m : end));\n }\n return kept.join(\" \");\n}\n\n/** What free text is cleaned against: the quoted copy, whether a logo picture is wired, whether the profile phrases everything positively. */\ntype Clean = { copy: readonly string[]; logo: boolean; positive: boolean };\n\n/** Copy too short to tell apart from an ordinary word or figure (\"1\", \"3x\") is never rewritten or counted. */\nconst MIN_COPY_LETTERS = 3;\nconst escapeRegExp = (s: string): string => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\nconst wordEdge = (ch: string | undefined, look: \"behind\" | \"ahead\"): string =>\n ch && /[\\p{L}\\p{N}]/u.test(ch) ? (look === \"behind\" ? \"(?<![\\\\p{L}\\\\p{N}])\" : \"(?![\\\\p{L}\\\\p{N}])\") : \"\";\n/** `text` as a whole phrase, in any case. */\nconst phrase = (text: string, wrap: (core: string) => string = (core) => core): RegExp =>\n new RegExp(`${wordEdge(text[0], \"behind\")}${wrap(escapeRegExp(text))}${wordEdge(text.at(-1), \"ahead\")}`, \"giu\");\nconst longEnough = (copy: string): boolean => (copy.match(/\\p{L}/gu) ?? []).length >= MIN_COPY_LETTERS;\n\n/**\n * Where free text names a copy line: its words as a phrase, quoted or not, in any case; a one-word\n * line only where it is quoted, since \"Before\" is also the word before a ✗.\n */\nconst copyNamed = (copy: string): RegExp => {\n const quotes = /\\s/.test(copy.trim()) ? \"?\" : \"\";\n return phrase(copy, (core) => `['\"“‘]${quotes}${core}['\"”’]${quotes}`);\n};\n\n/** Each copy line named in free text becomes \"line N\": the words are quoted once, in the Text section (openai §2). */\nfunction copyAsLineRefs(text: string, copy: readonly string[]): string {\n const byLength = copy.map((t, i) => ({ t, n: i + 1 })).sort((a, b) => b.t.length - a.t.length);\n return byLength.reduce((out, { t, n }) => (longEnough(t) ? out.replace(copyNamed(t), `line ${n}`) : out), text);\n}\n\n/**\n * Free text a render must never read: a logo forbidden while one is wired, the source ad or a\n * competitor named, hand-lettering (every line is set as type, `withRenderedLettering`), and (a\n * positive profile) any negation.\n */\nfunction unwanted(clause: string, k: Clean): boolean {\n if (k.logo && /\\bno (logos?|wordmarks?|branding)\\b/i.test(clause)) return true;\n if (HAND_LETTERED.test(clause)) return true;\n if (/\\bsource (ad|composition)\\b|\\bORIGINAL\\b|\\bcompetitor|\\breference ad\\b/.test(clause)) return true;\n return k.positive && NEGATION.test(clause.replace(/\"[^\"\\n]*\"/g, \"\"));\n}\n\nconst NEGATION = /\\b(no|not|never|don't|do not|avoid|without)\\b/i;\n\n/**\n * A free-text spec field as the brief carries it: `plainText`, enum underscores as spaces,\n * copy named by its line, the clauses a render must not read dropped, marks tidied.\n */\nfunction plain(text: unknown, k?: Clean): string {\n let out = plainText(text).replace(/(?<=\\p{L})_(?=\\p{L})/gu, \" \");\n if (k) out = copyAsLineRefs(out, k.copy).replace(/\\bfaithful(ly)?\\b/gi, (_m, ly?: string) => `exact${ly ?? \"\"}`);\n return tidy(keepClauses(out, k ? (clause) => unwanted(clause, k) : undefined)).replace(/\\s*[,;:]+$/, \"\");\n}\n\n/** A text's words, lower-cased with the punctuation gone, to tell a restatement from new detail. */\nconst normalized = (s: string): string =>\n s\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}]+/gu, \" \")\n .trim();\n\n/** The sentences of `text` that `said` does not already contain. */\nfunction unsaid(text: string, said: string): string {\n const known = ` ${normalized(said)} `;\n return (text.match(/[^.!?]+[.!?]*/g) ?? [])\n .map((s) => s.trim())\n .filter((s) => normalized(s) && !known.includes(` ${normalized(s)} `))\n .join(\" \");\n}\n\n/** The first `max` words of a text, cut at a sentence end when one fits, else at the last clause mark. */\nfunction clip(text: string, max: number): string {\n if (wordCount(text) <= max) return text;\n const sentences = text.match(/[^.!?]+[.!?]*/g) ?? [text];\n let out = \"\";\n for (const s of sentences) {\n if (wordCount(out + s) > max) break;\n out += s;\n }\n if (out.trim()) return sentence(out.trim().replace(/[\\s,;:]+$/, \"\"));\n const head = text.split(/\\s+/).slice(0, max).join(\" \");\n // A cut mid-phrase (\"left half dull with.\") reads as a different scene: end on the last clause.\n const clause = head.match(/^(.*?)[,;:—–](?:\\s[^,;:—–]*)?$/)?.[1];\n return sentence((clause?.trim() || head).replace(/[\\s,;:]+$/, \"\"));\n}\n\n/** A colour's lightness name when it carries too little hue to be named by it. */\nfunction neutralName(l: number): string {\n if (l > 0.95) return \"white\";\n if (l > 0.8) return \"off-white\";\n if (l > 0.6) return \"light grey\";\n if (l > 0.35) return \"grey\";\n return l > 0.12 ? \"dark grey\" : \"black\";\n}\n\n/** Hue bands, by their upper edge in degrees. */\nconst HUES: ReadonlyArray<[number, string]> = [\n [15, \"red\"],\n [40, \"orange\"],\n [65, \"yellow\"],\n [165, \"green\"],\n [185, \"teal\"],\n [250, \"blue\"],\n [290, \"purple\"],\n [340, \"pink\"],\n [360, \"red\"],\n];\n\nfunction hueOf(r: number, g: number, b: number, max: number, d: number): number {\n const raw = max === r ? ((g - b) / d) % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4;\n return (raw * 60 + 360) % 360;\n}\n\n/**\n * A plain colour name for a brand hex, so a colour reaches the model as words tied to an\n * object with the hex beside it, never as a bare code (BFL: \"tie each hex to an object\",\n * research §1; OpenAI names colours in words, prompting-openai-gpt-image.md §7).\n */\nexport function colourName(hex: string): string {\n const n = Number.parseInt(hex.slice(1), 16);\n const r = ((n >> 16) & 255) / 255;\n const g = ((n >> 8) & 255) / 255;\n const b = (n & 255) / 255;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (max + min) / 2;\n const d = max - min;\n const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));\n if (s < 0.15 || l > 0.95 || l < 0.07) return neutralName(l);\n const h = hueOf(r, g, b, max, d);\n const band = HUES.find(([edge]) => h < edge)?.[1] ?? \"red\";\n const hue = band === \"orange\" && l < 0.35 ? \"brown\" : band;\n const shade = l < 0.3 ? \"dark \" : l > 0.8 ? \"pale \" : \"\";\n return `${shade}${hue}`;\n}\n\n// --- What the ad is shown on, and the space it keeps clear. ---\n\nconst VERTICAL_NOUN: Record<string, string> = {\n reels: \"full-screen vertical ad for Stories and Reels\",\n stories: \"full-screen vertical Stories ad\",\n feed: \"full-screen vertical ad\",\n};\n\nfunction deliverableNoun(format: string, placements: readonly string[] | undefined): string {\n if (format === \"9:16\") {\n const safe = staticSafeArea(format, placements);\n return safe.placement === \"vertical\"\n ? `full-screen vertical ${safe.surface} ad`\n : (VERTICAL_NOUN[safe.placement] ?? \"full-screen vertical ad\");\n }\n const [w, h] = format.split(\":\").map(Number);\n if (!w || !h) return \"ad\";\n return w < h ? \"vertical feed ad\" : w === h ? \"square feed ad\" : \"landscape ad\";\n}\n\n/** The things the safe area keeps inside it, in words. */\nfunction keptInside(logo: boolean, button: boolean): string {\n const parts = [\"every word\", ...(logo ? [\"the logo\"] : []), ...(button ? [\"the button\"] : [])];\n return parts.length === 1 ? (parts[0] ?? \"\") : `${parts.slice(0, -1).join(\", \")} and ${parts.at(-1)}`;\n}\n\ntype Structure = ImageModelProfile[\"brief\"][\"structure\"];\n\n/**\n * The safe area, stated by what fills each band and with the numbers of its one owner\n * (`platform-safe-area.ts`), never restated here. Gemini gets the reason (gemini §9a).\n */\nfunction safeAreaText(\n format: string,\n placements: readonly string[] | undefined,\n items: string,\n structure: Structure,\n): string {\n const safe = blockingArea(format, placements);\n const pct = (f: number) => `${Math.round(f * 100)}%`;\n const side = pct(Math.max(safe.left, safe.right));\n const sits = items.includes(\" and \") ? \"sit\" : \"sits\";\n if (safe.placement !== \"feed\") {\n const surface = safe.placement === \"reels\" ? \"Stories and Reels\" : safe.surface;\n return structure === \"labelled_sections\"\n ? `Keep ${items} between the top ${pct(safe.top)} and the bottom ${pct(safe.bottom)} of the frame (the app's interface covers them; scene only there), at least ${side} in from each side.`\n : `In ${surface} the app's interface covers the top ${pct(safe.top)} and the bottom ${pct(safe.bottom)} of the screen, so those bands hold only the scene; ${items} ${sits} between them, at least ${side} in from each side.`;\n }\n return edgeText(safe, items, structure);\n}\n\n/** A margin at the frame's edges, stated as edges. */\nfunction edgeText(area: SafeArea, items: string, structure: Structure): string {\n const pct = (f: number) => `${Math.round(f * 100)}%`;\n const side = pct(Math.max(area.left, area.right));\n const sits = items.includes(\" and \") ? \"sit\" : \"sits\";\n const edges =\n pct(area.top) === side && pct(area.bottom) === side\n ? `at least ${side} in from every edge`\n : `at least ${pct(Math.max(area.top, area.bottom))} in from the top and bottom edges and ${side} from the sides`;\n return structure === \"labelled_sections\"\n ? `Keep ${items} ${edges}.`\n : `${capitalize(items)} ${sits} ${edges}, clear of the frame.`;\n}\n\n/**\n * What a whole-ad render's brief asks beyond the edge margin its checks hold it to. Bench E5\n * (.context/static-review/BENCH.md § E5 band master): asked for the 1:1's feed margin, the\n * renders set their words 2-5% from the edge, and the 1:1 passed its margin in 20% of ads.\n */\nconst MARGIN_HEADROOM = 0.03;\n\n/**\n * A whole-ad render's layout: a complete ad at the frame's own shape, its edge margin (plus\n * headroom) kept clear, and a scene that runs to the edges, because the fill to the delivered\n * pixels trims them.\n */\nfunction marginText(planned: PlannedBand, items: string, structure: Structure): string {\n const scene =\n structure === \"labelled_sections\"\n ? \"The scene runs to every edge of the frame, with no border or frame around the ad.\"\n : \"The scene runs to every edge of the frame and continues beyond it.\";\n const { top, bottom, left, right } = planned.area;\n const asked = {\n top: top + MARGIN_HEADROOM,\n bottom: bottom + MARGIN_HEADROOM,\n left: left + MARGIN_HEADROOM,\n right: right + MARGIN_HEADROOM,\n };\n return `${edgeText(asked, items, structure)} ${scene}`;\n}\n\n/**\n * The master's planned content band as one region (`masterContentBand`: the placement's safe\n * area narrowed to what every size cut from the master keeps), stated firmly: the cuts only\n * hold what sits inside it. Gemini gets the reason and positive phrasing (gemini §2, §9a).\n */\nfunction bandText(planned: PlannedBand, items: string, flowing: boolean, appChrome: boolean): string {\n const band = planned.area;\n const pct = (f: number) => `${Math.round(f * 100)}%`;\n const region = `from ${pct(band.top)} to ${pct(1 - band.bottom)} of the height and from ${pct(band.left)} to ${pct(1 - band.right)} of the width`;\n const sits = items.includes(\" and \") ? \"sit\" : \"sits\";\n const reasons = [\n ...(appChrome\n ? [\n flowing\n ? \"the app draws its interface over the top and bottom of the screen\"\n : \"the app's interface covers the top and bottom\",\n ]\n : []),\n ...(planned.cut ? [\"the other sizes are cut from this picture\"] : []),\n ];\n if (reasons.length === 0)\n reasons.push(flowing ? \"the edges of a feed crop tightly\" : \"a feed crops tightly at the edges\");\n if (flowing) {\n return `${capitalize(items)} ${sits} inside one region, ${region}, because ${reasons.join(\" and \")}; the rest of the frame carries the scene only.`;\n }\n return `${items} ${sits} inside one region: ${region}. Outside it the frame carries the scene only: ${reasons.join(\", and \")}.`;\n}\n\n// --- The pictures. ---\n\n/** An identity picture of an animal: by its label, or by what it shows when the label names neither. */\nconst isAnimal = (r: AdReference): boolean =>\n r.id.startsWith(\"ANIMAL_\") || (!r.id.startsWith(\"PERSON_\") && ANIMALS.test(r.what));\nconst personOrAnimal = (r: AdReference): \"person\" | \"animal\" => (isAnimal(r) ? \"animal\" : \"person\");\n\ntype Picture = BriefReference & { spec?: AdReference };\n\ntype PictureContext = {\n job: BriefJob;\n logoPosition?: string;\n designedLines: number[];\n /** Every copy line is designed, so the type picture need not list them. */\n allDesigned: boolean;\n thirdParty: readonly AdThirdPartyBrand[];\n /** The brand colours a logo plate may take, darkest first, tied to their names. */\n plates: readonly ColourUse[];\n flowing: boolean;\n clean: Clean;\n /** The brief is at its last trim level: the logo's instruction takes its short form. */\n short: boolean;\n /** The concept is a native disguise (`brand_presence: native`): the logo is the sender's mark. */\n native: boolean;\n};\n\n/** \"the SEAT logo, on the car the loan is for\": another brand's mark and where it shows. */\nfunction thirdPartyLogo(brand: AdThirdPartyBrand, k: Clean): string {\n const where = brand.what ? plain(brand.what, k) : \"\";\n return `the ${plain(brand.name)} logo${where ? `, on ${where.replace(/^on /i, \"\")}` : \"\"}`;\n}\n\n/** The other brands' logos, as the constraints name them (\"the SEAT logo\"). */\nconst thirdPartyNames = (spec: AdSpec): string =>\n spec.third_party_brands.map((b) => `the ${plain(b.name)} logo`).join(\" and \");\n\n/**\n * The other brands the offer is about, one line: their logos may appear, as those brands draw\n * them. The user asked to keep a car brand's logo on a car-loan ad (BENCH.md § \"E1 v2\").\n */\nfunction otherBrandsText(c: Ctx): string {\n const brands = c.spec.third_party_brands;\n if (brands.length === 0 || c.job !== \"generate\") return \"\";\n const marks = brands.map((b) => thirdPartyLogo(b, c.clean)).join(\"; \");\n return c.flowing\n ? ` ${sentence(capitalize(marks))} Each appears exactly as that brand draws it.`\n : `\\nOther brands: ${marks}, exactly as ${brands.length === 1 ? \"that brand draws it\" : \"each brand draws its own\"}.`;\n}\n\n/** Size words a logo position must not carry: the logo's size is the brief's (`logoInstruction`). */\nconst LOGO_SIZE_WORDS = /\\b(small|smaller|tiny|little|subtle|discreet|faint|minimal)\\b/i;\n\n/**\n * The logo, stated as the user asked (E1 gallery, BENCH.md § \"E1 v2\": \"using real logos is a\n * must\", legible, in a colour that stands out, letters not tiny). It is never recoloured, so\n * its contrast comes from where it sits or from a small plate in a brand colour. E6 found a\n * composited wordmark at 15% of the width unreadable; a fifth is the floor stated here.\n */\nfunction logoInstruction(p: Picture, ctx: PictureContext): string {\n // A native disguise carries the brand as its sender (C6): a big logo would break the disguise.\n if (ctx.native) {\n return ctx.flowing\n ? `the brand's real logo, as the sender's picture or signature where the disguise puts it, small as such a mark is. Reproduce it once, exactly as drawn in Image ${p.index}.`\n : \"the brand's real logo, as the sender's picture or signature where the disguise puts it, small as such a mark is. Reproduce it once, exactly as drawn.\";\n }\n const position = ctx.logoPosition\n ? keepClauses(plain(ctx.logoPosition, ctx.clean), (clause) => LOGO_SIZE_WORDS.test(clause))\n : \"\";\n const at = position ? `, ${position.replace(/[\\s,;:.!?]+$/, \"\")}` : \"\";\n const plate = ctx.plates.length > 0 ? ctx.plates.map((u) => `${u.name} (${u.hex})`).join(\" or \") : \"white or black\";\n const where = `at least a fifth of the frame wide, on an area it contrasts with or a small ${plate} plate`;\n if (ctx.short)\n return \"the brand's real logo. Reproduce it once, apart from the product, exactly as drawn, at least a fifth of the frame wide.\";\n // Once, as its own mark: the Tidal ad printed it on the bottle as well as in its header (BENCH.md § \"Final\").\n return ctx.flowing\n ? `the brand's real logo. Reproduce it once, apart from the product${at}, exactly as drawn in Image ${p.index}, ${where}.`\n : `the brand's real logo. Reproduce it once, never on the product${at}, exactly as drawn, ${where}.`;\n}\n\nfunction identityInstruction(p: Picture, what: string, keep: string, flowing: boolean, short: boolean): string {\n if (p.spec && personOrAnimal(p.spec) === \"person\") {\n if (short) return `${what} Same face, hair, skin tone and build; one person, once.${keep}`;\n return flowing\n ? `${what} Keep their facial features, hair, skin tone and build exactly the same as in Image ${p.index}, and show them once; several views in that picture are all this one person.${keep}`\n : `${what} Keep this exact face, hair, skin tone and build, and show them once; several views in the picture are all this one person.${keep}`;\n }\n return flowing\n ? `${what} Keep its face, markings and colours exactly the same as in Image ${p.index}, and show it once; several views in that picture are all this one animal.${keep}`\n : `${what} Keep its exact face, markings and colours, and show it once; several views in the picture are all this one animal.${keep}`;\n}\n\n/** The type specimen: which lines it sets (gpt-image lists them; Gemini's Text section names the face). */\nfunction typeInstruction(ctx: PictureContext): string {\n if (ctx.flowing) return \"a sample of the brand typeface; its words are only a sample.\";\n if (ctx.allDesigned) return \"a sample of the brand typeface for every line; its words are only a sample.\";\n const lines = `line${ctx.designedLines.length === 1 ? \"\" : \"s\"} ${ctx.designedLines.join(\", \")}`;\n return `a sample of the brand typeface for ${lines}; its words are only a sample.`;\n}\n\n/** What the model does with one picture, by its role (openai §3; gemini §4 for the \"exactly the same as Image N\" lock). */\nfunction pictureInstruction(p: Picture, ctx: PictureContext): string {\n const what = p.spec ? sentence(plain(p.spec.what, ctx.clean)) : \"\";\n const keep = p.spec?.keep ? ` Keep ${plain(p.spec.keep, ctx.clean)}.` : \"\";\n switch (p.role) {\n case \"base\":\n return \"screen content takes priority over other references unless explicitly changed.\";\n case \"identity\":\n return identityInstruction(p, what, keep, ctx.flowing, ctx.short);\n // The user saw one label come back two ways (E4 gallery, BENCH.md § \"E1 v2\"): the label is the product's.\n case \"product\":\n return ctx.flowing\n ? `${what} Keep it and its label, text and design, exactly as in Image ${p.index}.${keep}`\n : `${what} Reproduce this exact product and its label, text and design unchanged.${keep}`;\n case \"logo\":\n return logoInstruction(p, ctx);\n case \"prop\": {\n const brand = ctx.thirdParty.find((b) => b.logo === p.label);\n if (brand) return `${thirdPartyLogo(brand, ctx.clean)}. Reproduce it exactly as drawn, readable.`;\n // Owner, Oct 2026: a meme template shown \"as it looks here\" came back redrawn (Michael Scott, a code block).\n if (p.spec && isMemeTemplate(p.spec)) {\n return ctx.flowing\n ? `${what} Keep it exactly as in Image ${p.index}: the same people, faces, expressions and framing; only its caption areas take our words. Never redraw it.${keep}`\n : `${what} Reproduce this exact template picture unchanged: the same people, faces, expressions and framing; only its caption areas take our words. Never redraw it.${keep}`;\n }\n return `${what} Show it as it looks here.${keep}`;\n }\n case \"type\":\n return typeInstruction(ctx);\n case \"layout\":\n return \"the ad this one is built on, for its structure only: how it is built (its container, its layout, its pacing); never its words, brand, logo, people, products or colours, which belong to another advertiser.\";\n default:\n return `${what} Show it as it looks here.${keep}`;\n }\n}\n\n/** Every picture the render could be handed, before ordering: the edit base, the spec's references, logo, type, layout. */\nfunction wiredPictures(\n spec: AdSpec,\n opts: BriefOptions,\n job: BriefJob,\n designed: boolean,\n): Array<Omit<Picture, \"index\">> {\n const images = opts.images;\n const refs = spec.references.flatMap((r) => {\n const ref = images ? images.refs?.[r.id] : r.id;\n return ref ? [{ role: r.role, label: r.id, ref, spec: r }] : [];\n });\n const optional: Array<[boolean, BriefImageRole, string, string | undefined]> = [\n [job !== \"generate\", \"base\", \"AD\", images?.base],\n [spec.logo, \"logo\", \"LOGO\", images?.logo],\n [designed, \"type\", \"TYPE\", images?.type],\n // The reference, for its structure only, when the ad is built on its concept (C5: the image\n // model never saw the reference, 0/127 renders); `sourceLayout` decides when given.\n [job === \"generate\" && (opts.sourceLayout ?? seesReferenceStructure(spec)), \"layout\", \"LAYOUT\", images?.layout],\n ];\n const extras = optional.flatMap(([wanted, role, label, ref]) => (wanted && ref ? [{ role, label, ref }] : []));\n return [...refs, ...extras];\n}\n\n/** The pictures of this render, in the profile's order, numbered, one role each (a ref wired twice keeps its first role). */\nfunction pictures(\n spec: AdSpec,\n opts: BriefOptions,\n job: BriefJob,\n profile: ImageModelProfile,\n designed: boolean,\n): Picture[] {\n const order = profile.brief.referenceOrder;\n const sorted = wiredPictures(spec, opts, job, designed)\n .map((p, i) => ({ p, i }))\n .sort((a, b) => order.indexOf(a.p.role) - order.indexOf(b.p.role) || a.i - b.i)\n .map(({ p }) => p);\n const seen = new Set<string>();\n const unique: Array<Omit<Picture, \"index\">> = [];\n for (const p of sorted) {\n if (seen.has(p.ref)) continue;\n seen.add(p.ref);\n unique.push(p);\n }\n return unique.map((p, i) => ({ ...p, index: i + 1 }));\n}\n\n// --- The copy. ---\n\nconst SYMBOL_NAMES: Record<string, string> = {\n \"®\": \"a small raised registered-trademark sign\",\n \"™\": \"a small raised trademark sign\",\n \"©\": \"a copyright sign\",\n \"€\": \"the euro sign\",\n \"£\": \"the pound sign\",\n};\n\n/** A copy line as the brief quotes it: on one line, its breaks said in words (a quoted newline would split the numbered list). */\nexport function quotedCopy(text: string): string {\n return text\n .split(/\\s*\\n\\s*/)\n .filter(Boolean)\n .join(\" \");\n}\n\nfunction lineBreaks(text: string): string {\n const lines = text.split(/\\s*\\n\\s*/).filter(Boolean);\n if (lines.length < 2) return \"\";\n const ends = lines.slice(0, -1).map((l) => `“${l.split(/\\s+/).at(-1)}”`);\n return `, on ${lines.length} lines, breaking after ${ends.join(\" and \")}`;\n}\n\n/** The first `max` words of a note, without a dangling mark; nothing at 0. */\nfunction clipNote(text: string, max: number): string {\n if (wordCount(text) <= max) return text;\n return text\n .split(/\\s+/)\n .slice(0, max)\n .join(\" \")\n .replace(/[,;:.]+$/, \"\");\n}\n\n/**\n * A line's role in words, so the model sets each line at its rank (the old prompt carried it on\n * 212/216; BENCH.md § E1). Body text, the default rank, and unknown roles are left unnamed.\n */\nconst ROLE_WORDS: Readonly<Record<string, string>> = {\n headline: \"the headline\",\n title: \"the headline\",\n subhead: \"the subhead\",\n subheadline: \"the subhead\",\n subtitle: \"the subhead\",\n price: \"the price\",\n stat: \"the key figure\",\n figure: \"the key figure\",\n number: \"the key figure\",\n discount: \"the discount\",\n cta: \"the button\",\n button: \"the button\",\n call_to_action: \"the button\",\n caption: \"a caption\",\n fine_print: \"the fine print\",\n legal: \"the fine print\",\n disclaimer: \"the fine print\",\n footnote: \"the fine print\",\n label: \"a label\",\n list_item: \"a list item\",\n bullet: \"a list item\",\n badge: \"a badge\",\n quote: \"the quote\",\n testimonial: \"the quote\",\n attribution: \"who said it\",\n rating: \"the rating\",\n tagline: \"the tagline\",\n};\n\nconst roleKey = (role: string | undefined): string =>\n (role ?? \"\")\n .trim()\n .toLowerCase()\n .replace(/[\\s-]+/g, \"_\");\nconst roleWords = (line: AdCopyLine): string => ROLE_WORDS[roleKey(line.role)] ?? \"\";\n\n/** `face` null: the face is named once, above the lines (`faceOnce`). `lookWhole`: the look is never trimmed. */\nfunction copyLineText(\n line: AdCopyLine,\n n: number,\n face: string | null,\n k: Clean,\n level: number,\n lookWhole = false,\n): string {\n const cap = NOTE_CAP[level] ?? 0;\n const look = line.look ? clipNote(plain(line.look, k), lookWhole ? Number.POSITIVE_INFINITY : cap) : \"\";\n const note = line.position ? clipNote(plain(line.position, k), cap) : \"\";\n const position = note ? `; ${note}` : \"\";\n const text = quotedCopy(line.text);\n const detail = `${look ? (line.lettering === \"in_scene\" ? `: ${look}` : `, ${look}`) : \"\"}${lineBreaks(line.text)}${position}`;\n const lettered =\n line.lettering === \"in_scene\"\n ? line.on\n ? `lettered on ${plain(line.on, k)}`\n : \"lettered on its object in the scene\"\n : face\n ? `set in ${face}`\n : \"\";\n const lead = [roleWords(line), lettered].filter(Boolean).join(\", \") || \"designed\";\n return sentence(`${n}. \"${text}\" — ${lead}${detail}`);\n}\n\n/** Symbols named in words and accents listed, so both survive the render (openai §2). */\nfunction textNotes(copy: AdCopyLine[], profile: ImageModelProfile): string[] {\n const notes = Object.entries(SYMBOL_NAMES).flatMap(([symbol, name]) => {\n const lines = copy.flatMap((line, i) => (line.text.includes(symbol) ? [i + 1] : []));\n if (lines.length === 0) return [];\n const which =\n lines.length === 1 ? `line ${lines[0]}` : `lines ${lines.slice(0, -1).join(\", \")} and ${lines.at(-1)}`;\n return [`The ${symbol} in ${which} is ${name}.`];\n });\n const marks = [...new Set(copy.flatMap((l) => l.text.match(/[À-ÖØ-öø-ÿ¿¡]/g) ?? []))];\n if (profile.brief.text.keepAccents && marks.length > 0)\n notes.push(`Keep every accent and mark exactly: ${marks.join(\" \")}.`);\n return notes;\n}\n\n/** Roles whose line is the ad's button, read through `roleKey` as `ROLE_WORDS` reads them. */\nconst BUTTON_ROLES = new Set([\"cta\", \"button\", \"call_to_action\"]);\nconst isButton = (l: AdCopyLine) => BUTTON_ROLES.has(roleKey(l.role)) || /button/i.test(l.look ?? \"\");\n\n/** Roles whose line is the ad's key figure: it, not the headline, is the largest thing in the ad. */\nconst FIGURE_ROLES = new Set([\"price\", \"stat\", \"figure\", \"number\", \"discount\"]);\nconst HEADLINE_ROLES = new Set([\"headline\", \"title\"]);\nconst FINE_PRINT_ROLES = new Set([\"fine_print\", \"legal\", \"disclaimer\", \"footnote\"]);\n\ntype NumberedLine = { line: AdCopyLine; n: number };\n\n/**\n * The button's size, stated: the user found the call to action too small to see (E1 gallery,\n * BENCH.md § \"E1 v2\"). A third of the width is a thumb-sized button on a phone feed.\n */\nconst BUTTON_SIZE = \"a solid button at least a third of the frame wide, its words large and bold\";\n\n/** The designed lines, numbered as the brief quotes them. */\nconst designedLines = (copy: readonly AdCopyLine[]): NumberedLine[] =>\n copy.flatMap((line, i) => (line.lettering === \"designed\" ? [{ line, n: i + 1 }] : []));\n\n/**\n * The type scale, one sentence: the key figure (a price, a stat) or else the headline is the\n * largest element, at least half the frame wide, and reads first; every line reads at a glance\n * on a phone (the user asked for bigger text again and again); the fine print is smallest. The old prompt won the judge on\n * \"the key figure's size and colour\" and type hierarchy (48% of its wins; BENCH.md § E1). The\n * third version picks its own lead (`hookDirection`), so it keeps only the fine print's rank.\n */\ntype Ranked = ReturnType<typeof rankedLines>;\n\nconst finePrint = (ranked: Ranked): NumberedLine[] =>\n ranked.designed.filter(({ line }) => FINE_PRINT_ROLES.has(roleKey(line.role)));\n\n/** A native disguise's call to action: what the post, the note or the chat would carry, never a big button (C6). */\nconst NATIVE_BUTTON =\n \"as the native element would carry it (a link, a reply, a small button of its own), never a big ad button\";\n\nfunction fullHierarchy(ranked: Ranked, lead: NumberedLine | undefined, native: boolean): string[] {\n const { designed, figure, headline, button } = ranked;\n const size = lead === figure ? \"very large\" : \"at least half the frame wide\";\n return [\n ...(lead ? [`line ${lead.n} largest (${size}), read first`] : []),\n ...(lead && figure && headline ? [`then line ${headline.n}`] : []),\n ...(button ? [`line ${button.n} ${native ? NATIVE_BUTTON : BUTTON_SIZE}`] : []),\n ...(designed.length > 1 ? [\"every line readable at a glance\"] : []),\n ...finePrint(ranked).map(({ n }) => `line ${n} smallest, still legible`),\n ];\n}\n\n/** The hierarchy in the few words a brief at its word budget can spare. */\nfunction shortHierarchy(ranked: Ranked, lead: NumberedLine | undefined, native: boolean): string[] {\n return [\n ...(lead ? [`line ${lead.n} largest, read first`] : []),\n ...(ranked.button\n ? [\n native\n ? `line ${ranked.button.n} as the native element would carry it`\n : `line ${ranked.button.n} a solid button a third of the frame wide`,\n ]\n : []),\n ...finePrint(ranked).map(({ n }) => `line ${n} smallest`),\n ];\n}\n\n/** The designed lines by rank: the key figure, the headline, the line that reads first, the button. */\nfunction rankedLines(copy: readonly AdCopyLine[]) {\n const designed = designedLines(copy);\n const numbered = copy.map((line, i) => ({ line, n: i + 1 }));\n // The figure and the headline lead whether they are set as type or lettered in the scene (C5).\n const byRole = (roles: ReadonlySet<string>) => numbered.find(({ line }) => roles.has(roleKey(line.role)));\n const figure = byRole(FIGURE_ROLES);\n const headline = byRole(HEADLINE_ROLES);\n const lead =\n figure ?? headline ?? designed.find(({ line }) => !isButton(line) && !FINE_PRINT_ROLES.has(roleKey(line.role)));\n return { designed, figure, headline, lead, button: designed.find(({ line }) => isButton(line)) };\n}\n\nfunction hierarchyText(c: Ctx): string {\n const ranked = rankedLines(c.spec.copy);\n // The third version picks its own lead (`hookDirection`).\n const lead = c.opts.variant === 2 ? undefined : ranked.lead;\n const native = c.spec.brand_presence === \"native\";\n const parts =\n c.level >= SHORT_DIRECTION_LEVEL ? shortHierarchy(ranked, lead, native) : fullHierarchy(ranked, lead, native);\n if (parts.length === 0) return \"\";\n return c.flowing ? sentence(capitalize(parts.join(\"; \"))) : `Hierarchy: ${sentence(parts.join(\"; \"))}`;\n}\n\n// --- Colour. ---\n\ntype ColourUse = { object: string; name: string; hex?: string };\n\n/** The colours the brand's roles give the parts this ad has. */\nfunction brandRoleColours(spec: AdSpec, brand: AdBrand): ColourUse[] {\n const designed = designedLines(spec.copy);\n const figure = designed.find(({ line }) => FIGURE_ROLES.has(roleKey(line.role)));\n const panel = spec.scene.look === \"photo\" && !isNativeCapture(spec);\n // Brief v2: a photo ad's band and the emphasised figure lost the brand's colour (BENCH.md § E1,\n // \"What the compiled brief drops\"); a native phone photo keeps no designed panel.\n const roles: Array<[boolean, string, string | undefined]> = [\n [spec.scene.look === \"designed\", \"the background\", brand.ground],\n [panel && designed.length > 0, \"any band or panel behind the words\", brand.ground],\n [designed.length > 0, \"the designed type\", brand.ink],\n [spec.copy.some(isButton), \"the button\", brand.cta],\n [Boolean(figure), figure ? `line ${figure.n} (or the shape it sits on)` : \"\", brand.accent],\n [\n !figure && spec.copy.some((l) => /underline|highlight|arrow/i.test(l.look ?? \"\")),\n \"underlines and highlights\",\n brand.accent,\n ],\n ];\n return roles.flatMap(([applies, object, hex]) => (applies && hex ? [{ object, name: colourName(hex), hex }] : []));\n}\n\n/**\n * A photo a phone takes as a post (a selfie, UGC, a screenshot): only it gets the phone-photo\n * realism cues and no designed panel. The brief once gave those cues to 116/216 ads, studio and\n * hero shots included (BENCH.md § E1, \"What the compiled brief drops\").\n */\nconst NATIVE_CAPTURE =\n /\\b(selfie|phone[- ]camera|phone photo|shot on (?:a )?phone|taken on (?:a )?phone|smartphone photo|ugc|user[- ]generated|webcam|front[- ]camera|snapshot|native caption)\\b/i;\n\n/** In the capture field itself, any phone names the camera (in the scene it may be a prop). */\nconst PHONE_CAMERA = /\\b(phone|smartphone|iphone)\\b/i;\n\nfunction isNativeCapture(spec: AdSpec): boolean {\n if (spec.scene.look !== \"photo\") return false;\n const capture = spec.scene.capture ?? \"\";\n return NATIVE_CAPTURE.test(`${spec.scene.description} ${capture}`) || PHONE_CAMERA.test(capture);\n}\n\n/** Every colour the brief states: tied to an object, and from the brand palette when there is one. */\nfunction colourUses(spec: AdSpec, brand: AdBrand | undefined, k: Clean): ColourUse[] {\n const allowed = brand\n ? new Set(\n [...brand.palette, brand.ground, brand.ink, brand.accent, brand.cta].filter((h): h is string => Boolean(h)),\n )\n : null;\n const own = spec.colors.flatMap((c): ColourUse[] => {\n if (c.hex && allowed && !allowed.has(c.hex)) return [];\n const tied = { object: plain(c.object, k), name: plain(c.name, k) };\n return [c.hex && allowed ? { ...tied, hex: c.hex } : tied];\n });\n if (!brand) return own;\n // A role colour the spec already ties to an object is said once, by the spec's object.\n const said = new Set(own.flatMap((u) => (u.hex ? [u.hex] : [])));\n return [...own, ...brandRoleColours(spec, brand).filter((u) => !u.hex || !said.has(u.hex))];\n}\n\n/** Relative luminance of a hex colour, 0 (black) to 1 (white). */\nfunction luminance(hex: string): number {\n const n = Number.parseInt(hex.slice(1), 16);\n return (0.2126 * ((n >> 16) & 255) + 0.7152 * ((n >> 8) & 255) + 0.0722 * (n & 255)) / 255;\n}\n\n/**\n * The brand's darkest and lightest colours, a plate for a logo of either kind: named as the\n * spec names them when it ties them to something, else by `colourName`.\n */\nfunction plateColours(spec: AdSpec, brand: AdBrand | undefined, k: Clean): ColourUse[] {\n if (!brand) return [];\n const hexes = [...new Set([brand.ink, brand.ground, brand.accent, brand.cta, ...brand.palette])].filter(\n (h): h is string => Boolean(h),\n );\n if (hexes.length === 0) return [];\n const sorted = [...hexes].sort((a, b) => luminance(a) - luminance(b));\n const ends = [...new Set([sorted[0], sorted.at(-1)])].filter((h): h is string => Boolean(h));\n const named = (hex: string) => spec.colors.find((c) => c.hex === hex)?.name;\n return ends.map((hex) => ({ object: \"the logo plate\", name: plain(named(hex) ?? colourName(hex), k), hex }));\n}\n\n// --- Direction. ---\n\n/** What the ad shows, by its picture when one is wired (the product first), else in words. */\nfunction heroOf(pics: readonly Picture[]): string {\n const product = pics.find((p) => p.role === \"product\");\n const identity = pics.find((p) => p.role === \"identity\" && p.spec);\n if (product) return `the product in Image ${product.index}`;\n if (identity?.spec) return `the ${personOrAnimal(identity.spec)} in Image ${identity.index}`;\n return MAIN_SUBJECT;\n}\n\nconst MAIN_SUBJECT = \"the main subject of the scene\";\n\n/**\n * The three versions a first render is asked for, each on its own axis so the person gets\n * options rather than three rolls of one picture: 0 the spec's scene as written (no direction of\n * its own, `directionSection`); 1 a different picture of the same message; 2 a different hook in\n * the same words. This writes 1 and 2. Bench E3\n * (.context/static-review/BENCH.md#E3): with \"the hero larger\" and \"rearranged\" as the second\n * and third, two judge-distinct options came back in 39% of ads. From `SHORT_DIRECTION_LEVEL`\n * a brief over its word budget gets each direction's short form.\n */\nfunction variantDirection(c: Ctx): string {\n const [long, short] = c.opts.variant === 1 ? pictureDirection(c) : hookDirection(c);\n // The other versions vary only what the concept does not rest on (C5).\n const keep = mustKeep(c);\n const kept = keep.length > 0 ? ` Keep ${keep.join(\" and \")} as it is.` : \"\";\n return c.level >= SHORT_DIRECTION_LEVEL ? `${short} ${DEPARTS_SHORT}${kept}` : `${long} ${DEPARTS}${kept}`;\n}\n\n/** The scene and each line's notes describe the first version; the others depart from them on purpose. */\nconst DEPARTS = \"It leads where it differs from the scene and line notes above.\";\nconst DEPARTS_SHORT = \"It leads over the notes above.\";\n\n/** A direction in full, and in the few words a brief at its word budget can spare. */\ntype Direction = [long: string, short: string];\n\n/** Lines that close or qualify an ad rather than hook it: the button, the small print, who said it. */\nconst isSupport = (l: AdCopyLine) =>\n isButton(l) || FINE_PRINT_ROLES.has(roleKey(l.role)) || roleKey(l.role) === \"attribution\";\n\n/**\n * Variant 2: the same words with another hook. The next line leads; with one hook line, that\n * line at a scale the first version does not use. Lines are named by number, so no word changes.\n */\nfunction hookDirection(c: Ctx): Direction {\n const hooks = c.spec.copy.flatMap((l, i) =>\n l.lettering === \"designed\" && !isSupport(l) ? [{ n: i + 1, text: l.text }] : [],\n );\n const [first, ...rest] = hooks;\n // The next line, never one picked for carrying a figure: a price-led hook broke concepts that were not about price.\n const lead = rest[0];\n if (first && lead)\n return [\n `a type-led layout with another hook: line ${lead.n} leads, set as the largest words in the ad and read first; line ${first.n} follows it, smaller; the picture sits behind or beside the words as support, with the same words.`,\n `line ${lead.n} leads, largest; line ${first.n} smaller.`,\n ];\n if (first)\n return [\n `a type-led layout: line ${first.n} set very large, across most of the frame's width, at least three times the size of every other line; the picture sits small behind or beside it as support, with the same words.`,\n `line ${first.n} very large, every other line small.`,\n ];\n const lettered = c.spec.copy.findIndex((l) => l.lettering === \"in_scene\");\n if (lettered >= 0) {\n const on = c.spec.copy[lettered]?.on;\n const object = on ? plain(on, c.clean) : `the object carrying line ${lettered + 1}`;\n return [\n `a closer framing of the words: ${object} seen close and large in the frame, so its words are the first thing read, with the same words.`,\n `${object} close and large.`,\n ];\n }\n const hero = heroOf(c.pics);\n return [\n `another arrangement: ${hero} on the other side of the frame, seen from another angle, with the same words.`,\n `${hero} on the other side, from another angle.`,\n ];\n}\n\n/** A scene the spec already frames close, so its other picture is the wide one. */\nconst CLOSE_FRAMING =\n /\\b(?:close[- ]?up|macro|detail shot|close(?: [a-z-]+){0,2} shot|tight(?:ly)? (?:crop|cropped|framed|shot))\\b/i;\n\n/** Variant 1: the same message in another picture, the other way from how the scene frames it. */\nfunction pictureDirection(c: Ctx): Direction {\n const hero = heroOf(c.pics);\n if (c.spec.scene.look === \"designed\") {\n const shown = hero === MAIN_SUBJECT ? \"the thing the message is about\" : hero;\n return [\n `a picture-led layout: ${shown} shown as one large picture filling most of the frame, the words set compactly over a calm part of it, with the same words.`,\n `a picture-led layout: ${shown} large, the words compact.`,\n ];\n }\n if (c.spec.scene.look === \"illustration\")\n return [\n `a close, simple drawing: ${hero} drawn large, filling most of the frame, on one flat background colour, with the same words.`,\n `a close, simple drawing of ${hero} on one flat colour.`,\n ];\n const scene = `${c.spec.scene.description} ${c.spec.scene.capture ?? \"\"}`;\n if (CLOSE_FRAMING.test(scene))\n return [\n `a wide shot: ${hero} smaller in the frame, in the full place around it, so the setting tells the story, with the same words.`,\n `a wide shot of ${hero} in its full setting.`,\n ];\n return [\n `a close-up: ${hero} fills most of the frame, seen from close, and the setting shrinks to a soft hint of its colour and light, with the same words.`,\n `a close-up of ${hero}, filling the frame.`,\n ];\n}\n\n// --- The compiler. ---\n\n/** Everything one brief is written from, resolved once. `level` trims optional detail to fit the word budget. */\ntype Ctx = {\n spec: AdSpec;\n brand: AdBrand | undefined;\n viewer: AdViewer | undefined;\n format: string;\n profile: ImageModelProfile;\n opts: BriefOptions;\n job: BriefJob;\n flowing: boolean;\n pics: Picture[];\n designedLines: number[];\n level: number;\n clean: Clean;\n};\n\n/**\n * Compile an ad spec into the prompt, the numbered pictures and the request params of one\n * render on one model. `brand` and `viewer` override the spec's own when given (the bench\n * varies them); `format` is the delivered format (\"9:16\", \"4:5\", …).\n */\nexport function compileStaticBrief(\n written: AdSpec,\n brandOverride: AdBrand | undefined,\n format: string,\n viewerOverride: AdViewer | undefined,\n profile: ImageModelProfile,\n opts: BriefOptions = {},\n): CompiledBrief {\n const spec = withRenderedLettering(written);\n const job = opts.job ?? \"generate\";\n const designedLines = spec.copy.flatMap((l, i) => (l.lettering === \"designed\" ? [i + 1] : []));\n const pics = pictures(spec, opts, job, profile, designedLines.length > 0);\n const base: Ctx = {\n spec,\n brand: brandOverride ?? spec.brand,\n viewer: viewerOverride ?? spec.viewer,\n format,\n profile,\n opts,\n job,\n flowing: profile.brief.structure === \"flowing_sentences\",\n pics,\n designedLines,\n level: 0,\n clean: {\n copy: spec.copy.map((l) => quotedCopy(l.text)),\n logo: pics.some((p) => p.role === \"logo\"),\n positive: profile.brief.constraints === \"positive_last\",\n },\n };\n let prompt = assemble(base);\n for (let level = 1; level <= MAX_TRIM && wordCount(prompt) > profile.brief.wordBudget; level++) {\n prompt = assemble({ ...base, level });\n }\n const ruled = rulesBlock(\n briefRules(opts.rules ?? []),\n \"The company's own rules for every ad it makes, each one kept in this picture:\",\n );\n if (ruled) prompt = `${prompt}\\n\\n${ruled}`;\n const p = profile.brief.params;\n return {\n prompt,\n references: base.pics.map(({ index, role, label, ref }) => ({ index, role, label, ref })),\n params: {\n n: job === \"generate\" ? p.n : 1,\n ...(p.quality ? { quality: p.quality } : {}),\n ...(p.imageSize ? { image_size: p.imageSize } : {}),\n },\n words: wordCount(prompt),\n };\n}\n\n/**\n * Trim levels: 1 drops the mood and the idea's device, 2 the arrangement and direction note,\n * 3 the viewer and the message, 4-8 cut the scene, 9 drops the capture, 10-13 shorten each copy\n * line's lettering and position notes (and from 10 the second and third versions' directions\n * and the hierarchy take their short form), 14 shortens a picture's instruction when an earlier\n * picture of its role explained it, 15 drops the screens and fill sentences and shortens the\n * people cue, 16 shortens the logo's instruction and each unwired product's description and drops\n * the concept's idea (what it must keep stays). The copy itself is never cut.\n */\nconst MAX_TRIM = 16;\n/** From this trim level the logo's instruction and an unwired product's description take their short forms. */\nconst LAST_RESORT_LEVEL = 16;\n/** The words an unwired product's description keeps at `LAST_RESORT_LEVEL`. */\nconst PRODUCT_NOTE_WORDS = 10;\n/** From this trim level the brief v2 extras (screens, fill, people) take their short form or go. */\nconst EXTRAS_SHORT_LEVEL = 15;\n/** From this trim level a photo's capture cues go: after the scene, before the directions. */\nconst CAPTURE_LEVEL = 9;\n/** From this trim level the second and third versions' directions take their short form. */\nconst SHORT_DIRECTION_LEVEL = 10;\n/** From this trim level a picture whose role an earlier one explained gets a one-line instruction. */\nconst SHORT_PICTURES_LEVEL = 14;\nconst NOTE_CAP = [...Array<number>(10).fill(Number.POSITIVE_INFINITY), 12, 8, 4, 0];\nconst SCENE_CAP = [\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n 80,\n 50,\n 35,\n 25,\n 15,\n];\n\nfunction audienceText(viewer: AdViewer | undefined, level: number, k: Clean): string {\n if (!viewer || level >= 3) return \"\";\n const warmth: Record<string, string> = {\n cold: \", who are new to the brand\",\n warm: \", who already know the brand\",\n hot: \", who are ready to act\",\n };\n const knows = viewer.knows\n ? ` (what they already know: ${plain(viewer.knows, k)})`\n : (warmth[viewer.temperature ?? \"\"] ?? \"\");\n return `, made for ${plain(viewer.who, k)}${knows}`;\n}\n\n/** The one idea, unless it repeats a line of copy (the model would draw it as another line). */\nfunction ideaText(spec: AdSpec, level: number, k: Clean): string {\n const message = spec.message;\n if (!message || level >= 3) return \"\";\n const m = message.toLowerCase();\n const repeats = spec.copy.some((l) => m.includes(l.text.toLowerCase()) || l.text.toLowerCase().includes(m));\n return repeats ? \"\" : ` Its one idea: ${sentence(plain(message, k))}`;\n}\n\n/** 1. The deliverable, and whose it is and for whom (the intended use sets the polish: openai §1). */\nfunction deliverableSection(c: Ctx): string {\n const noun = deliverableNoun(c.format, c.opts.placements);\n const forBrand = c.brand?.name ? ` for ${plain(c.brand.name)}` : \"\";\n if (c.job === \"fix\") {\n const change = sentence(c.opts.instruction?.trim() || \"correct what is wrong\");\n // Its own sentence after the picture's: read as an instruction, never as the tail of a clause.\n return c.flowing\n ? `Image 1 is the current version of this ad. ${capitalize(change)} Keep everything else in Image 1 exactly the same, preserving its picture, layout, colours, lettering and every word.`\n : `Edit: Image 1 is the current version of this ad. ${capitalize(change)} Keep everything else exactly as it is in Image 1: the picture, the layout, the colours, the lettering and every word.`;\n }\n if (c.job === \"series\") {\n const change = sentence(c.opts.instruction?.trim() || \"set the new words\");\n return c.flowing\n ? `Image 1 is a finished ad of this series. Make the next ad of the same series${forBrand}: ${change} Keep everything else in Image 1 exactly the same, preserving its picture, layout, background, shapes, colours, lettering style and logo, each word in the place and style of the one it replaces.`\n : `Edit: Image 1 is a finished ad of this series. Make the next ad of the same series${forBrand}. ${capitalize(change)} Keep everything else exactly as it is in Image 1: the picture, the layout, the background, the shapes, the colours, the lettering style and the logo, each new line in the place, size and style of the line it replaces.`;\n }\n if (c.job === \"relay\") {\n const ui =\n \"Keep any depicted app interface exact, with marketing overlays visibly separate from its native controls.\";\n return c.flowing\n ? `Image 1 is a finished ad. Adapt this same ad to a ${noun}${forBrand}: move and scale its existing elements, keeping its picture, background, colours, lettering and every word. Extend only its existing background where needed. ${ui}`\n : `Deliverable: the same ad as Image 1, re-laid as a finished ${noun}${forBrand}. Move and scale its existing elements; keep its picture, background, colours, lettering and every word. Extend only its existing background where needed. ${ui}`;\n }\n const lead = c.flowing ? \"Create a finished\" : \"Deliverable: a finished\";\n return `${lead} ${noun}${forBrand}${audienceText(c.viewer, c.level, c.clean)}.${marketText(c)}${recognitionText(c)}${ideaText(c.spec, c.level, c.clean)}${conceptText(c)}${deviceText(c)}`;\n}\n\n/**\n * Where the ad is set (D1, audited Sept 2026: a Mexican WhatsApp ad came back with Spain's\n * people and euros): a one-country ad's places, shops, money and people are that country's; a\n * version that runs in several countries shows none of any one. Never trimmed: it is one line.\n */\nfunction marketText(c: Ctx): string {\n const market = c.viewer?.market;\n if (!market) return \"\";\n if (market.country === \"global\") {\n return c.flowing\n ? \" It is set in no one country: no flags, landmarks, money or shop signs of any country, and people who could live in any of them.\"\n : \"\\nSet in no one country: no flags, landmarks, money or shop signs of any country.\";\n }\n const where = marketCountryName(market) ?? market.country;\n const money = market.currency ? ` (${market.currency})` : \"\";\n return c.flowing\n ? ` It is set in ${where}: its places, shops, money${money} and people are ${where}'s, in everyday details, never a flag or a landmark added to say where.`\n : `\\nSet in ${where}: its places, shops, money${money} and people are ${where}'s, in everyday details, never a flag or a landmark added to say where.`;\n}\n\n/** How a stranger knows in a second what the ad is (D4): one line, never trimmed. */\nfunction recognitionText(c: Ctx): string {\n const what = c.spec.recognition ? plain(c.spec.recognition, c.clean) : \"\";\n if (!what) return \"\";\n return c.flowing\n ? ` A stranger knows at a glance it is ${sentence(what)}`\n : ` A stranger knows at a glance it is ${sentence(what)}`;\n}\n\n/** The concept a spec adapts, when it is one to keep (`use` or `adapt`). */\nconst keptConcept = (spec: AdSpec) => (spec.concept && spec.concept.verdict !== \"reject\" ? spec.concept : undefined);\n\n/** What a stop or proof element does for the ad, as the brief says it beside what of ours carries it. */\nconst VITAL_WORDS: Record<VitalJob, string> = { stop: \"what stops the scroll\", proof: \"the proof\" };\n\n/**\n * The load-bearing elements, each with what of ours carries it: \"the gift (two accounts free forever)\".\n * One the concept replaces is told only by what of ours does its job: the proven ad's own (a celebrity's\n * reaction faces) is drawn when it is named.\n */\nfunction mustKeep(c: Ctx): string[] {\n if (!keptConcept(c.spec)) return [];\n return (c.spec.concept?.load_bearing ?? []).map((l) => {\n const ours = l.ours ? plain(l.ours, c.clean) : \"\";\n if (l.decision === \"replace\" && ours) return isVital(l) ? `${ours} (${VITAL_WORDS[l.job]})` : ours;\n return `${plain(l.element, c.clean)}${ours ? ` (${ours})` : \"\"}`;\n });\n}\n\n/** What the render takes from the proven ad, by what made it win (`concept.carry`). */\nconst CARRIED: Record<ConceptCarry, string> = {\n whole_ad:\n \"Built on a proven ad as a whole: its disguise, its arrangement and its opening, in our words, brand and pictures.\",\n layout: \"Built on a proven ad's layout: the same arrangement, with our words, brand and pictures.\",\n hook: \"Built on a proven ad's hook: it opens on the same pattern, in our words; the look is ours.\",\n angle: \"Built on a proven ad's angle: the same argument, in our words; the look is ours.\",\n};\n\n/**\n * Why the reference won and what must stay of it (C5, audited Sept 2026: 12 of 33 creatives lost\n * the concept, and the brief barely carried it): the idea in its layers (the disguise it wears,\n * the voice, the trigger, what stops the scroll, the logic), then the load-bearing elements with\n * what of ours carries each. The idea goes only at the last trim level, after every cut of the\n * scene and the copy notes; what must stay never does.\n */\nfunction conceptText(c: Ctx): string {\n const kept = keptConcept(c.spec);\n if (!kept) return \"\";\n const w = kept.why_it_wins;\n // What stopped the scroll in the proven ad, replaced with ours, is told only by ours (`mustKeep`):\n // named as it was (a celebrity's reaction faces), it is what the model draws.\n const stopReplaced = kept.load_bearing.some((l) => l.job === \"stop\" && l.decision === \"replace\" && l.ours?.trim());\n // The brief carries every layer; the review checks only the trick (`conceptSummary`).\n const layers = [w.disguise, w.voice, w.trigger, stopReplaced ? undefined : w.attention, w.logic].flatMap((t) =>\n t?.trim() ? [plain(t, c.clean)] : [],\n );\n const continuing = c.job !== \"generate\";\n const idea = layers.length > 0 && (continuing || c.level < LAST_RESORT_LEVEL) ? sentence(layers.join(\"; \")) : \"\";\n const keep = mustKeep(c);\n const keepLine = keep.length > 0 ? sentence(keep.join(\"; \")) : \"\";\n const carry = kept.carry && (continuing || c.level < LAST_RESORT_LEVEL) ? CARRIED[kept.carry] : \"\";\n const parts = [\n carry,\n idea ? `The idea: ${idea}` : \"\",\n keepLine ? `${c.flowing ? \"It must keep\" : \"Must keep:\"} ${keepLine}` : \"\",\n ];\n const separator = c.flowing ? \" \" : \"\\n\";\n return parts.flatMap((part) => (part ? [`${separator}${part}`] : [])).join(\"\");\n}\n\n/**\n * The device the ad is built on (`mechanism[0]`), one line, dropped at the first trim level.\n * The old prompt rebuilt each winning mechanism (201/216 prompts) and the brief printed it on\n * 1/216; adding it back closed part of the judge's gap (BENCH.md § E1, the `brief-idea-m` probe).\n */\nfunction deviceText(c: Ctx): string {\n if (c.job !== \"generate\") {\n const mechanisms = c.spec.mechanism.map((m) =>\n [plain(m.device, c.clean), m.why_it_works ? plain(m.why_it_works, c.clean) : \"\"].filter(Boolean).join(\": \"),\n );\n return mechanisms.length > 0 ? `Keep the persuasion mechanism: ${sentence(mechanisms.join(\"; \"))}` : \"\";\n }\n const device = c.spec.mechanism[0]?.device;\n if (!device || c.level >= 1) return \"\";\n const text = plain(device, c.clean);\n if (!text) return \"\";\n if (!c.flowing) return `\\nIdea: ${sentence(capitalize(text))}`;\n const lower = /^\\p{Lu}\\p{Ll}/u.test(text) ? `${text[0]?.toLowerCase()}${text.slice(1)}` : text;\n return ` The idea it is built on: ${sentence(lower)}`;\n}\n\n/** 2. The pictures, each numbered with one role (openai §3, gemini §4). */\n/** What a spec picture shows, as one noun. */\nfunction pictureNoun(p: Picture): string {\n if (p.role === \"identity\" && p.spec) return personOrAnimal(p.spec);\n return p.role === \"product\" ? \"product\" : \"object\";\n}\n\n/** An earlier picture whose instruction already covers `p` (same role and kind), for the shortest briefs. */\nfunction explainedBefore(p: Picture, pics: readonly Picture[]): Picture | undefined {\n if (!p.spec) return undefined;\n return pics.find((q) => q.index < p.index && q.spec && q.role === p.role && pictureNoun(q) === pictureNoun(p));\n}\n\nfunction picturesSection(c: Ctx): string[] {\n if (c.pics.length === 0) return [];\n const ctx: PictureContext = {\n clean: c.clean,\n job: c.job,\n designedLines: c.designedLines,\n allDesigned: c.designedLines.length === c.spec.copy.length,\n plates: plateColours(c.spec, c.brand, c.clean),\n thirdParty: c.spec.third_party_brands,\n flowing: c.flowing,\n short: c.level >= LAST_RESORT_LEVEL,\n native: c.spec.brand_presence === \"native\",\n ...(c.spec.logo_position ? { logoPosition: c.spec.logo_position } : {}),\n };\n const lines = c.pics.map((p) => {\n const label = p.label ? ` (${p.label})` : \"\";\n const same = c.level >= SHORT_PICTURES_LEVEL ? explainedBefore(p, c.pics) : undefined;\n const instruction = same\n ? `another ${pictureNoun(p)}${c.flowing ? \", under\" : \";\"} the same rules as Image ${same.index}.`\n : pictureInstruction(p, ctx);\n return c.flowing ? `Image ${p.index}${label} is ${instruction}` : `Image ${p.index}${label}: ${instruction}`;\n });\n return [c.flowing ? lines.join(\"\\n\") : `References:\\n${lines.join(\"\\n\")}`];\n}\n\nconst DESIGNED_LOOK = {\n flowing:\n \"It is a clean designed ad graphic with one dominant element and a clear reading order, and its type reads at a glance on a phone.\",\n labelled:\n \"Look: a clean designed ad graphic: one dominant element, a clear reading order, crisp type that reads on a phone.\",\n};\nconst ILLUSTRATION_LOOK = {\n flowing: \"It is an illustration with one dominant element and a clear reading order.\",\n labelled: \"Look: an illustration: one dominant element, a clear reading order.\",\n};\n\n/** A photo's look: the profile's realism vocabulary and the spec's capture cues, never lens figures (openai §5, gemini §6). */\nfunction photoLook(c: Ctx): string {\n const r = isNativeCapture(c.spec) ? c.profile.brief.realism.native : c.profile.brief.realism.produced;\n const capture = c.spec.scene.capture && c.level < CAPTURE_LEVEL ? plain(c.spec.scene.capture, c.clean) : \"\";\n if (!c.flowing) return `Look: ${r.photo}${capture ? ` — ${capture}` : \"\"}; ${r.texture}.`;\n const purpose = r.purpose ? `, ${r.purpose}` : \"\";\n return `It is ${r.photo}${capture ? `, ${capture}` : \"\"}, with ${r.texture}${purpose}.`;\n}\n\n/** The user found a dog \"very AI\" (BENCH.md § \"Fix round\"). Dropped with the other extras at the last trim. */\nfunction animalsText(c: Ctx): string {\n if (!showsAnimals(c.spec) || c.level >= EXTRAS_SHORT_LEVEL) return \"\";\n return c.flowing\n ? \" The animals look real, with real fur, natural light and a candid moment.\"\n : \" Animals look real: real fur, natural light, a candid moment.\";\n}\n\nfunction lookText(c: Ctx): string {\n const people = `${showsPeople(c.spec) ? peopleText(c) : \"\"}${animalsText(c)}`;\n if (c.spec.scene.look === \"photo\") return `${photoLook(c)}${people}`;\n const look = c.spec.scene.look === \"illustration\" ? ILLUSTRATION_LOOK : DESIGNED_LOOK;\n return `${c.flowing ? look.flowing : look.labelled}${people}`;\n}\n\n/** People named in a scene: the real-person cues apply to them (hands alone do not need faces). */\nexport const PEOPLE =\n /\\b(person|people|wom[ae]n|m[ae]n|girls?|boys?|child(?:ren)?|kids?|baby|parents?|mother|father|mum|mom|dad|family|couple|customers?|founder|presenter|technician|nurse|doctor|workers?|students?|friends|athlete|chef|faces?|selfie|portrait|plumbers?|electricians?|drivers?|owners?|managers?|employees?|engineers?|developers?|teachers?|mechanics?|carpenters?|tradesm[ae]n|advis[oe]rs?|agents?|riders?|couriers?)\\b/i;\n\n/**\n * Photoreal people in the ad, in any capture: a person picture is wired, or a photo's scene\n * names someone. The user found the people \"too AI\" and some faces too dark (BENCH.md § \"E1 v2\").\n */\nexport function showsPeople(spec: AdSpec): boolean {\n if (spec.scene.look === \"illustration\") return false;\n // By the role the picture plays (C5): a prop that shows a person (a chat on a phone) is no person.\n if (spec.references.some((r) => r.role === \"identity\" && !isAnimal(r))) return true;\n return (\n spec.scene.look === \"photo\" && PEOPLE.test(withoutAbsences(`${spec.scene.description} ${spec.scene.layout ?? \"\"}`))\n );\n}\n\n/**\n * The ad shows no person at all: nobody is cast (no person picture) and its scene names nobody, in\n * any look. A person in it is then a stranger the image model invented (Permut's card, Oct 2026).\n */\nexport function castsNobody(spec: AdSpec): boolean {\n if (spec.references.some((r) => r.role === \"identity\" && !isAnimal(r))) return false;\n const scene = withoutAbsences(`${spec.scene.description} ${spec.scene.layout ?? \"\"}`);\n return !PEOPLE.test(scene) && !/\\bhands?\\b/i.test(scene);\n}\n\n/** The rest of an absence's clause, up to the next thing the scene names (\"… and a woman cooking\"). */\nconst CLAUSE_REST = String.raw`(?:(?!\\b(?:and|but|while|with|as|where|whereas)\\b)[^.;,])*`;\nconst ABSENCE = new RegExp(\n String.raw`\\b(?:no|without|nor|never any|not a single)\\s+(?:\\w+\\s+){0,2}?(?:people|persons?|humans?|one|hands?|faces?|figures?)\\b${CLAUSE_REST}|\\b(?:nobody|no-one|no one)\\b${CLAUSE_REST}`,\n \"gi\",\n);\n\n/** A manager, an agent or a driver that is software: \"a password manager app\", \"AI agents\", \"USB drivers\". */\nconst SOFTWARE_ROLE =\n /\\b(?:password|file|task|project|package|window|device|usb|printer|graphics|gpu|ai|software|browser|download|display|audio|print)\\s+(?:managers?|agents?|drivers?)\\b|\\b(?:managers?|agents?|drivers?)\\s+(?:apps?|software|tools?|dashboards?|platforms?|programs?|updates?|panels?|screens?|extensions?|plugins?)\\b/gi;\n\n/**\n * A scene's words with what it says is absent taken out: \"no people appear anywhere and no\n * hands\", \"an office without people\", \"nobody at the desks\" name people that are not there, a\n * \"first-person headline\" names a voice, \"a developer's desk\" an owner, and \"a password manager\n * app\" software, not a person. An absence ends at the next thing the scene names.\n */\nfunction withoutAbsences(text: string): string {\n return (\n text\n .replace(/\\b(?:first|second|third)[- ]person\\b/gi, \" \")\n // \"a developer's desk\" says whose the desk is: nobody stands in the picture for it.\n .replace(/\\b\\w+['’]s\\b/g, \" \")\n .replace(SOFTWARE_ROLE, \" \")\n .replace(ABSENCE, \" \")\n );\n}\n\n/**\n * The real-person cue, and where the person's gaze or pose leads: to the button, else to the line\n * that reads first. The user: \"man looking to the CTA maximizes conversion\" (E4 gallery).\n */\nfunction peopleText(c: Ctx): string {\n const cue = c.profile.brief.realism.people;\n if (!cue) return \"\";\n const { button, lead } = rankedLines(c.spec.copy);\n const target = button ?? lead;\n // Red Points (round 6): \"seen only from behind, face never shown\" met \"relaxed expressions\" and\n // \"real faces with lines\"; both men came back facing the camera. A face the scene hides is never asked for.\n if (facesHidden(c.spec)) {\n return ` Every person is seen from behind, as the scene says: no face anywhere in the picture.${target ? ` Their pose leads toward line ${target.n}.` : \"\"}`;\n }\n const said = c.level >= EXTRAS_SHORT_LEVEL ? \"People look real, faces well lit.\" : sentence(capitalize(cue));\n // Tier 1, Oct 2026: a course for 45-60 year olds came back with young, good-looking, \"very AI\" faces.\n const who = c.viewer?.who ? \" Ordinary people the viewer's age: real faces with lines, everyday clothes.\" : \"\";\n return ` ${said}${who}${target ? ` Their gaze or pose leads toward line ${target.n}.` : \"\"}`;\n}\n\n/** A scene that shows its people from behind, their faces never seen. */\nconst FACES_HIDDEN =\n /\\b(?:(?:seen|shot|shown|photographed)\\s+(?:only\\s+)?from\\s+behind|from the back|back to (?:the )?camera|faces? (?:is |are )?(?:never|not) (?:shown|seen|visible)|no faces?\\b|faceless)/i;\n\n/** Whether the scene keeps its people's faces out of the picture. Pure. */\nconst facesHidden = (spec: AdSpec): boolean => FACES_HIDDEN.test(spec.scene.description);\n\n/** Things a render tends to draw glossy and computer-made: people, animals, phone and app screens. */\nconst looksRendered = (spec: AdSpec): boolean => showsPeople(spec) || showsAnimals(spec) || showsScreen(spec);\n\n/** Animals named in a photo, or an animal picture wired. */\nconst ANIMALS = /\\b(dogs?|puppy|puppies|cats?|kittens?|pets?|horses?|birds?|rabbits?|animals?)\\b/i;\n\nfunction showsAnimals(spec: AdSpec): boolean {\n if (spec.scene.look === \"illustration\") return false;\n if (spec.references.some((r) => r.role === \"identity\" && isAnimal(r))) return true;\n return spec.scene.look === \"photo\" && ANIMALS.test(`${spec.scene.description} ${spec.scene.layout ?? \"\"}`);\n}\n\n/** A phone, app or web screen in the ad. */\nconst SCREEN =\n /\\b(apps?|screens?|lock[- ]screen|dashboard|interface|mockup|notification|laptop|tablet|browser|website|chat bubbles?|ui)\\b/i;\n\nfunction showsScreen(spec: AdSpec): boolean {\n const ons = spec.copy.map((l) => l.on ?? \"\").join(\" \");\n return SCREEN.test(`${spec.scene.description} ${spec.scene.layout ?? \"\"} ${ons}`);\n}\n\n/**\n * A device's screen drawn as a real one: the user found the old prompt's app mockups more\n * polished (E1 gallery, BENCH.md § \"E1 v2\"), then the brief's phone screenshot \"very AI\"\n * (§ \"Fix round\"): a real phone photographed or a real screenshot, never a glossy render. Its\n * words stay inside the allow-list.\n */\nconst SCREENS = {\n labelled:\n \"Screens: a real phone photographed, or a real screenshot: real app density, a real status bar, flat true-to-life colours; any words on them from the quoted lines.\",\n flowing:\n \"Every phone or app screen looks like a real phone photographed or a real screenshot, with real app density, a real status bar and flat true-to-life colours, any words on it from the quoted lines.\",\n};\n\n/** A picture of the company's own screen, wired: what every screen in the ad shows. */\nconst SCREENSHOT = /\\b(screenshots?|screen ?grabs?|screens?)\\b/i;\nconst screenshotOf = (pics: readonly Picture[]): Picture | undefined =>\n pics.find((p) => p.spec && p.role !== \"identity\" && SCREENSHOT.test(p.spec.what));\n\nfunction screensText(c: Ctx): string {\n const laptop = /\\b(laptops?|notebook computers?|macbooks?)\\b/i.test(c.spec.scene.description);\n const device = laptop ? \"laptop\" : \"phone\";\n const shot = screenshotOf(c.pics);\n if (shot) {\n return c.flowing\n ? ` Every screen shows Image ${shot.index} exactly as it is, on a real ${device}, photographed.`\n : `\\nScreens: every screen shows Image ${shot.index} exactly as it is, on a real ${device}, photographed.`;\n }\n if (!showsScreen(c.spec)) return \"\";\n if (c.level >= EXTRAS_SHORT_LEVEL)\n return c.flowing\n ? ` Every ${device} or app screen looks like a real ${device} photographed or a real screenshot.`\n : `\\nScreens: a real ${device} photographed, or a real screenshot.`;\n if (laptop) {\n const screen =\n \"a real laptop photographed, or a real screenshot; display, keyboard and hinge in consistent perspective; any words on it from the quoted lines.\";\n return c.flowing ? ` Every laptop screen looks like ${screen}` : `\\nScreens: ${screen}`;\n }\n return c.flowing ? ` ${SCREENS.flowing}` : `\\n${SCREENS.labelled}`;\n}\n\n/**\n * A product the spec names but no picture is wired for, stated on its own so trimming the scene\n * never drops it: the serum bottle went with the scene from two of three versions, and the pick\n * had none (BENCH.md § \"Final\").\n */\nfunction unwiredProductsText(c: Ctx): string {\n const wired = new Set(c.pics.map((p) => p.label));\n return c.spec.references\n .filter((r) => r.role === \"product\" && !wired.has(r.id))\n .map((r) => {\n const what = plain(r.what, c.clean).replace(/[.!?]+$/, \"\");\n const told = c.level >= LAST_RESORT_LEVEL ? clipNote(what.split(/[,;]/)[0] ?? what, PRODUCT_NOTE_WORDS) : what;\n return ` The product, ${told}, is in the frame, whole and clearly visible.`;\n })\n .join(\"\");\n}\n\n/**\n * A person nobody cast (no Avatar, so no picture wired): stated in the scene so a trimmed\n * description cannot drop them, and stated as somebody real, because a person the model\n * invents unprompted comes back as a glossy model (AV1, scripts/creative-evals).\n */\nfunction unwiredPeopleText(c: Ctx): string {\n const wired = new Set(c.pics.map((p) => p.label));\n return c.spec.references\n .filter((r) => r.role === \"identity\" && r.id.startsWith(\"PERSON_\") && !wired.has(r.id))\n .map((r) => {\n const what = plain(r.what, c.clean).replace(/[.!?]+$/, \"\");\n const told = c.level >= LAST_RESORT_LEVEL ? clipNote(what.split(/[,;]/)[0] ?? what, PRODUCT_NOTE_WORDS) : what;\n return ` The person, ${told}, is an invented, ordinary real person — real skin, unposed, never a model.`;\n })\n .join(\"\");\n}\n\n/** An ad that shows a before and an after (a split, two days, two states), in any of the corpus's languages. */\nexport const BEFORE_AFTER =\n /\\bbefore\\b[^.]{0,40}\\bafter\\b|\\bantes\\b[^.]{0,30}\\bdespu[eé]s\\b|\\bavant\\b[^.]{0,30}\\bapr[eè]s\\b|\\bvorher\\b[^.]{0,30}\\bnachher\\b|\\bprima\\b[^.]{0,30}\\bdopo\\b/i;\n\nexport function isBeforeAfter(spec: AdSpec): boolean {\n const told = [spec.scene.description, spec.scene.layout, spec.direction, ...spec.mechanism.map((m) => m.device)];\n return BEFORE_AFTER.test(told.filter(Boolean).join(\" \\n \"));\n}\n\n/** The serum's two faces barely differed, in every size (BENCH.md § \"Final\"). */\nconst BEFORE_AFTER_TEXT =\n \" The two states it compares differ clearly at a glance, even as a thumbnail; only the result changes between them.\";\n\n/** What a scene rules out (\"no people\", \"without a phone\"), clause by clause. */\nconst RULED_OUT = /\\b(?:no|without)\\b[^.,;:!?]*|(?:\\b[\\p{L}]+\\s+)?\\bnever\\b[^.,;:!?]*/giu;\n\n/**\n * A trimmed scene with what the whole one ruled out said again: Permut's card ad (dev, Oct 2026)\n * kept \"A flat light warm grey ground.\" and lost \"no people\", and came back with an invented person.\n */\nfunction withRuledOut(trimmed: string, whole: string): string {\n const kept = normalized(trimmed);\n const lost = (whole.match(RULED_OUT) ?? []).map((m) => m.trim()).filter((m) => !kept.includes(normalized(m)));\n return lost.length > 0 ? `${trimmed} ${sentence(capitalize(lost.join(\", \")))}` : trimmed;\n}\n\n/** 3. The scene and its look, for a first render only: a re-lay and a fix take them from Image 1. */\nfunction sceneSection(c: Ctx): string[] {\n if (c.job !== \"generate\") return [];\n const scene = c.spec.scene;\n const products = `${unwiredProductsText(c)}${unwiredPeopleText(c)}${isBeforeAfter(c.spec) ? BEFORE_AFTER_TEXT : \"\"}`;\n // The scene's own sentence about an unwired product goes: the product line says it whole.\n const told = normalized(products);\n const own = (sentence(plain(scene.description, c.clean)).match(/[^.!?]+[.!?]*/g) ?? [])\n .filter((s) => !products || !told.includes(normalized(s.replace(/^\\s*in the frame:?/i, \"\"))))\n .join(\"\")\n .trim();\n const whole = own || sentence(plain(scene.description, c.clean));\n const description = withRuledOut(capitalize(clip(whole, SCENE_CAP[c.level] ?? 15)), whole);\n const mood = scene.mood && c.level < 1 ? ` The mood is ${sentence(plain(scene.mood, c.clean))}` : \"\";\n const out = [\n c.flowing\n ? `${description}${products}${mood} ${lookText(c)}${screensText(c)}${otherBrandsText(c)}`\n : `Scene: ${description}${products}${mood}\\n${lookText(c)}${screensText(c)}${otherBrandsText(c)}`,\n ];\n const layout =\n scene.layout && c.level < 2 ? unsaid(plain(scene.layout, c.clean), plain(scene.description, c.clean)) : \"\";\n if (layout) out.push(c.flowing ? sentence(capitalize(layout)) : `Arrangement: ${sentence(layout)}`);\n return out;\n}\n\n/** 4. The words: numbered, quoted, each once, lettered per line, allow-listed (openai §2, gemini §3). */\nfunction textSection(c: Ctx): string {\n const copy = c.spec.copy;\n if (copy.length === 0)\n return c.flowing ? \"The picture carries the whole ad on its own.\" : \"Text: none; the picture is the ad.\";\n const typePic = c.pics.find((p) => p.role === \"type\");\n const face = typePic\n ? `the brand typeface (Image ${typePic.index})`\n : c.brand?.typeface\n ? plain(c.brand.typeface, c.clean)\n : \"a clean, bold sans-serif\";\n // Lines that share one face name it once, above them (brief v2 spends the words on the logo\n // and the button); in-scene lines still say what they are lettered on. gpt-image's type picture\n // lists its lines itself; Gemini's names the face here.\n const faceOnce = c.designedLines.length > 1;\n const named = faceOnce && (!typePic || c.flowing);\n const label = productLabel(c);\n const header = c.flowing\n ? `The ad carries exactly these ${copy.length} lines of text, each once and spelled exactly as quoted${named ? `, the designed type set in ${face}` : \"\"}:`\n : `Text: exactly these ${copy.length} lines, each once, spelled exactly as quoted; they are the only words in the image${label}${named ? `; designed type in ${face}` : \"\"}:`;\n return [\n header,\n ...copy.map((l, i) => copyLineText(l, i + 1, faceOnce ? null : face, c.clean, c.level, c.opts.looksWhole === true)),\n ...[hierarchyText(c)].filter(Boolean),\n ...textNotes(copy, c.profile),\n ].join(\"\\n\");\n}\n\n/** A wired product keeps its own label's words, a wired screenshot its screen's: the allow-list makes room for them. */\nfunction productLabel(c: Ctx): string {\n const shot = screenshotOf(c.pics);\n if (shot) return ` besides the words on Image ${shot.index}'s screen`;\n // Zernio (round 6): the 9:16 kept the template's \"Panik\" and \"Kalm\", the 4:5 lost them; they are the meme.\n if (c.spec.references.some(isMemeTemplate))\n return \" besides the meme template's own captions, kept exactly as it prints them\";\n return c.pics.some((p) => p.role === \"product\") ? \" besides the product's own label\" : \"\";\n}\n\n/** 5. Colour, named and tied to objects, brand palette only (research §1 BFL; openai §7). */\nfunction colourSection(c: Ctx): string[] {\n if (c.job !== \"generate\") return [];\n const uses = colourUses(c.spec, c.brand, c.clean);\n if (uses.length === 0) return [];\n const list = uses.map((u) => `${u.object} in ${u.name}${u.hex ? ` (${u.hex})` : \"\"}`).join(\"; \");\n return [c.flowing ? sentence(capitalize(list)) : `Colour: ${sentence(list)}`];\n}\n\n/** 6. The safe area, by what fills each band, from its one owner. */\nfunction layoutSection(c: Ctx): string {\n const items = keptInside(\n c.pics.some((p) => p.role === \"logo\"),\n c.spec.copy.some(isButton),\n );\n const safe = c.opts.zoned\n ? \"\"\n : c.opts.band?.margin\n ? marginText(c.opts.band, items, c.profile.brief.structure)\n : c.opts.band\n ? bandText(c.opts.band, items, c.flowing, staticSafeArea(c.format, c.opts.placements).placement !== \"feed\")\n : safeAreaText(c.format, c.opts.placements, items, c.profile.brief.structure);\n const out = [safe, legibilityText(c), fillText(c)].filter(Boolean).join(\" \");\n return c.flowing ? out : `Layout: ${out}`;\n}\n\n/**\n * One legibility sentence: \"every line sits on a ground it reads against\" was on every old\n * prompt and on 2/216 briefs, and contrast and the logo dark on dark were the judge's reasons\n * (BENCH.md § E1). The logo is never recoloured, so its ground is where it goes.\n */\nfunction legibilityText(c: Ctx): string {\n const logo = c.pics.some((p) => p.role === \"logo\");\n if (c.spec.copy.length === 0) return logo ? \"The logo sits on a ground it reads against.\" : \"\";\n return logo\n ? \"Every line and the logo sit on a ground they read against.\"\n : \"Every line sits on a ground it reads against.\";\n}\n\n/** A concept that is meant to be sparse: it keeps its empty space. */\nconst MINIMAL = /\\b(minimal(?:ist)?|negative space|white space|empty space|sparse|airy)\\b/i;\n\n/**\n * The frame filled on purpose: the user found the briefs' ads emptier than the old prompt's\n * (\"less empty white space\", E1 gallery, BENCH.md § \"E1 v2\"), unless the concept is minimal.\n */\nfunction fillText(c: Ctx): string {\n // The second and third versions' directions say how they fill the frame.\n if (c.job !== \"generate\" || c.level >= EXTRAS_SHORT_LEVEL || c.opts.variant === 1 || c.opts.variant === 2) return \"\";\n const { scene, direction } = c.spec;\n if (MINIMAL.test([scene.description, scene.mood, scene.layout, direction].join(\" \"))) return \"\";\n return c.flowing ? \"The subject and the words fill the frame with purpose.\" : \"Fill the frame; no large empty areas.\";\n}\n\n/** 7. Direction: which of the three reads this render takes, and the concept's own note. */\nfunction directionSection(c: Ctx): string[] {\n if (c.job !== \"generate\") return [];\n const note = c.spec.direction && c.level < 2 ? sentence(plain(c.spec.direction, c.clean)) : \"\";\n const variant = c.opts.variant ?? 0;\n // The first version is the brief as written: it needs no direction of its own.\n if (variant !== 1 && variant !== 2) return note ? [c.flowing ? capitalize(note) : `Direction: ${note}`] : [];\n const direction = variantDirection(c);\n return [c.flowing ? `This version is ${direction} ${note}`.trim() : `Direction: ${direction} ${note}`.trim()];\n}\n\n/** Gemini's closing allow-list, phrased positively (gemini §2). */\nfunction positiveConstraints(c: Ctx): string {\n const n = c.spec.copy.length;\n const logo = c.pics.find((p) => p.role === \"logo\");\n const others = thirdPartyNames(c.spec);\n if (n === 0)\n return `The only words in the finished image are none at all: it is picture only${logo ? `, with the one logo from Image ${logo.index}` : \"\"}.`;\n const label = productLabel(c) ? `,${productLabel(c)}` : \"\";\n const onlyLogo = !logo\n ? \"\"\n : others\n ? `, and the logos are the one in Image ${logo.index} and ${others}, the only brand marks anywhere, vehicles, packaging and clothing included`\n : `, and the one logo is the one in Image ${logo.index}, the only brand mark anywhere, vehicles, packaging and clothing included`;\n return `The only words in the finished image are the ${n} quoted lines above, each exactly once; every other surface carries picture only${label}${onlyLogo}.`;\n}\n\n/** The marks the picture may show besides the copy: the logo, the brands the offer is about, the marks the lines' looks name. */\nfunction allowedMarks(c: Ctx): string[] {\n const logo = c.pics.find((p) => p.role === \"logo\");\n const looked = c.opts.looksWhole === true && c.spec.copy.some((l) => l.lettering === \"designed\" && l.look);\n return [\n ...(logo ? [`Image ${logo.index}`] : []),\n ...(thirdPartyNames(c.spec) ? [thirdPartyNames(c.spec)] : []),\n // The words call draws what each line's look names beside it: a ✗, a ✓, a dot, a tag.\n ...(looked ? [\"the marks the lines' looks name\"] : []),\n ];\n}\n\n/** 8. The constraints, last (openai §7; Gemini phrased positively, gemini §2). */\nfunction constraintsSection(c: Ctx): string {\n if (c.profile.brief.constraints === \"positive_last\") return positiveConstraints(c);\n const n = c.spec.copy.length;\n const logos = allowedMarks(c);\n const repeatedWordLimit = n > 0 && c.level >= LAST_RESORT_LEVEL;\n const wordLimit = n > 0 ? `any words other than the ${n} quoted lines` : \"any words or letters\";\n const avoid = [\n // At the final trim level the Text section already states the complete word allow-list.\n ...(repeatedWordLimit ? [] : [wordLimit]),\n // A Toyota badge appeared on a car-loan ad's SUV (BENCH.md § \"Final\"): the allow-list covers the scene's things too.\n // The words and the identity's \"show them once\" are said above; brief v2 spends the words on the logo and the button.\n `${logos.length > 0 ? `any logo, badge, icon, seal or sticker other than ${logos.join(\" and \")}` : \"any logo or wordmark, badge, icon, seal or sticker\"}, on vehicles, packaging and clothing too`,\n \"watermarks\",\n ...(c.job === \"generate\" && isNativeCapture(c.spec) ? [\"a staged, retouched or studio-lit look\"] : []),\n ...renderedLookAvoid(c),\n ];\n return `Avoid: ${avoid.join(\"; \")}.`;\n}\n\n/** The rendered look a first render avoids: the user found the people, a dog and a phone screen \"very AI\" (BENCH.md § \"Fix round\"). */\nfunction renderedLookAvoid(c: Ctx): string[] {\n if (c.job !== \"generate\") return [];\n if (showsPeople(c.spec)) {\n const faces = facesHidden(c.spec) ? \"any face turned to the camera\" : \"faces in shadow\";\n return [`glossy, CGI or airbrushed skin; ${faces}`];\n }\n return looksRendered(c.spec) ? [\"a glossy CGI look\"] : [];\n}\n\n/** A correction's brief keeps this many of the person's rejections, each this long: the newest say most. */\nconst REJECTED_NOTES = 4;\nconst REJECTED_NOTE_CHARS = 240;\n\n/** What the person rejected in earlier versions of this ad, for a correction only. */\nfunction rejectedSection(c: Ctx): string[] {\n const notes = c.job === \"fix\" ? (c.opts.rejected ?? []).slice(0, REJECTED_NOTES) : [];\n if (notes.length === 0) return [];\n const lines = notes.map((n) => `- ${n.length > REJECTED_NOTE_CHARS ? `${n.slice(0, REJECTED_NOTE_CHARS - 1)}…` : n}`);\n return [\n `What the person rejected in earlier versions of this ad, in their words; never bring any of it back:\\n${lines.join(\"\\n\")}`,\n ];\n}\n\nfunction assemble(c: Ctx): string {\n const continuity = c.job !== \"generate\" ? (conceptText(c) || deviceText(c)).trim() : \"\";\n return [\n deliverableSection(c),\n ...rejectedSection(c),\n \"Real-world anatomy, devices, scale, perspective and supports stay plausible. Scale proportionally; reflow text; preserve letter shapes.\",\n // A continuation needs the original idea as well as the previous picture. Keep this\n // separate: the per-format adapter replaces the deliverable paragraph.\n ...(continuity ? [continuity] : []),\n ...(c.job === \"fix\" || c.job === \"series\"\n ? [\"Keep any depicted app interface exact, with marketing overlays visibly separate from its native controls.\"]\n : []),\n ...picturesSection(c),\n ...sceneSection(c),\n textSection(c),\n ...colourSection(c),\n layoutSection(c),\n ...directionSection(c),\n constraintsSection(c),\n ].join(\"\\n\\n\");\n}\n\n/** The copy lines a compiled brief quotes, in order (critique, set-prompt and the review read them back). */\nexport function briefCopyLines(prompt: string): string[] {\n return [...prompt.matchAll(/^\\d+\\. \"(.*)\" — /gm)].map((m) => m[1] ?? \"\");\n}\n\n// --- The judge. ---\n\n/**\n * The criteria the static judge (`image_select`) compares the candidates on: the brief they\n * were rendered from, pairwise and in both orders, checks first. VLMs rank but cannot score\n * (research §5), so it ranks. Given the brand and the viewer, so \"reads as the brand's\" and\n * \"one idea for this viewer\" are judged against someone rather than no one.\n *\n * Kept as is after E9 (BENCH.md § \"E9 — judge calibrated to the user\"): on 100 pairs the user\n * rated blind, four rewrites around what the user named (logo, button, text size, people,\n * polish; ranked gates, an overall call, no brief, a line per image) and Gemini Pro never beat\n * it; on the held-out third it picks the user's ad in 13 of the 20 pairs it decides, as often\n * as Claude Opus, and the best tuned rewrite fell to 10 of 17.\n */\nexport function judgeBrief(\n brief: string,\n opts: { brand?: string; viewer?: string; mechanisms?: readonly string[]; rules?: readonly CreativeRule[] } = {},\n): string {\n // In a rules block, as the brief's own: the fingerprint leaves the company's rules out (`withoutRulesDeep`).\n const rules = rulesBlock(\n briefRules(opts.rules ?? []),\n \"Rules: the company's rules for every ad hold too; a candidate that breaks one of them loses to one that keeps it:\",\n );\n const whose = opts.brand ? ` for ${opts.brand}` : \"\";\n const forWhom = opts.viewer ? `, made for ${opts.viewer}` : \"\";\n const mechanism =\n opts.mechanisms && opts.mechanisms.length > 0 ? `; the ad still rests on ${opts.mechanisms.join(\"; \")}` : \"\";\n return [\n `You compare candidate versions of ONE static ad${whose}${forWhom}, all rendered from the BRIEF below. Compare the candidates with each other and pick the one that best delivers the brief; a candidate that fails an earlier check loses to one that passes it:`,\n \"1. Words: every quoted line of the brief is printed exactly once, spelled exactly (accents and symbols included), and no other words appear.\",\n \"2. Picture: no AI artifacts on people, animals or products (hands, faces, mouths, warped objects), no seams or smears.\",\n \"3. Space: every word, the logo and the button sit where the brief's Layout keeps them; nothing is clipped or overlapping.\",\n \"4. One idea: one dominant element carries the idea and still reads at a glance shrunk to a phone-feed thumbnail.\",\n `5. Brief: the scene, the lettering of each line, the colours and the pictures are the ones the brief asks for${mechanism}.`,\n `6. Brand: with any logo covered, the ad still reads as ${opts.brand ? `${opts.brand}'s` : \"the brand's\"}.`,\n ...(rules ? [rules] : []),\n 'Compare every pair both ways before deciding. Begin `reasoning` with one line per criterion, exactly \"<criterion>: Image X > Image Y > …\" (best first), then one sentence on why the winner won.',\n \"\",\n \"BRIEF:\",\n brief,\n ].join(\"\\n\");\n}\n\n// --- The lint. ---\n\nexport type BriefIssue = { code: string; detail: string };\n\ntype LintOptions = { profile?: ImageModelProfile; copy?: readonly string[] };\n/** `p` is the brief with its numbered copy blanked (`\"\"`): what the brief itself says. `raw` is the brief as sent. */\ntype Check = (p: string, opts: LintOptions, raw: string) => BriefIssue | null;\n\nconst NUMBERED_COPY = /^(\\d+\\. )\"(.*)\"( — )/gm;\n\n/** The brief with every numbered copy line's words blanked, so a claim, a figure or quotes in the copy are not read as the brief's own text. */\nconst withoutCopy = (prompt: string): string => prompt.replace(NUMBERED_COPY, '$1\"\"$3');\n\n/** The words a brief spends on its own text, its quoted copy aside: what `over_word_budget` counts. */\nexport const briefWords = (prompt: string): number => wordCount(withoutCopy(prompt));\n\n/** How often `text` occurs in `p` as a whole phrase. */\nconst occurrences = (p: string, text: string): number => (p.match(copyNamed(text)) ?? []).length;\n\nconst ROLE_LABEL = /^(PERSON|ANIMAL|PRODUCT|BADGE|PROP)_\\d+$/;\nconst issue = (code: string, detail: string): BriefIssue => ({ code, detail });\nconst when = (test: boolean, code: string, detail: string): BriefIssue | null => (test ? issue(code, detail) : null);\n\n/** The copy a prompt allow-lists: given, its numbered lines, or (an older prompt) every quoted phrase. */\nfunction copyOf(prompt: string, opts: LintOptions): readonly string[] {\n if (opts.copy) return opts.copy;\n const numbered = briefCopyLines(prompt);\n return numbered.length > 0 ? numbered : [...prompt.matchAll(/\"([^\"\\n]+ [^\"\\n]+)\"/g)].map((m) => m[1] ?? \"\");\n}\n\nconst CHECKS: readonly Check[] = [\n (p, o) => {\n const budget = o.profile?.brief.wordBudget ?? 400;\n const words = wordCount(p);\n return when(words > budget, \"over_word_budget\", `${words} words, over the ${budget}-word budget`);\n },\n (p) => when(/\\{\\{|\"[a-z_]+\":\\s/.test(p), \"json_in_prompt\", \"a JSON blob or template slot is sent to the model\"),\n (p) =>\n when(\n /match the hex|hex precisely|exact hex/i.test(p),\n \"hex_precision\",\n \"asks the model to match hex codes precisely\",\n ),\n (p) => {\n const bare = (p.match(/#[0-9a-f]{6}\\b/gi) ?? []).length - (p.match(/[a-z]+ \\(#[0-9a-f]{6}\\)/gi) ?? []).length;\n return when(bare > 0, \"untied_hex\", `${bare} hex code(s) not tied to a named colour and object`);\n },\n (p) => {\n const tops = new Set([...p.matchAll(/\\btop (\\d+)%/gi)].map((m) => m[1]));\n const bottoms = new Set([...p.matchAll(/\\bbottom (\\d+)%/gi)].map((m) => m[1]));\n return when(\n tops.size > 1 || bottoms.size > 1,\n \"conflicting_safe_area\",\n `safe areas disagree: top ${[...tops].join(\"/\")}%, bottom ${[...bottoms].join(\"/\")}%`,\n );\n },\n (p) =>\n when(\n /\\bsource (ad|composition)\\b|\\bORIGINAL\\b|faithful|reference ad's|competitor/i.test(p),\n \"source_ad\",\n \"the source ad is named or followed\",\n ),\n (p) => {\n const labels = [...new Set(p.match(/\\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\\b/g) ?? [])].filter((l) => !ROLE_LABEL.test(l));\n return when(\n labels.length > 0,\n \"advertiser_label\",\n `labels that are not role-based: ${labels.slice(0, 5).join(\", \")}`,\n );\n },\n (p) =>\n when(\n /every word[^.\\n]*typeface|typeface[^.\\n]*every word/i.test(p) && /handwrit|in_scene|in-scene|marker/i.test(p),\n \"one_face_for_every_word\",\n \"one typeface is asked for every word while some lines are lettered in the scene\",\n ),\n (p) =>\n when(\n /print-ready/i.test(p) && /phone photo|unedited|not an ad|smartphone|a post\\b/i.test(p),\n \"polish_vs_native\",\n \"asks for a print-ready ad and a native, unedited photo at once\",\n ),\n (p) =>\n when(\n /\\d\\s?mm\\b|f\\/\\s?\\d|\\bISO\\s?\\d|focal_length|aperture/i.test(p),\n \"pseudo_precise_numbers\",\n \"lens or exposure figures a model cannot follow\",\n ),\n (p) =>\n when(\n /\\b(8k|hyper-?realistic|masterpiece|ultra-detailed|award-winning)\\b/i.test(p),\n \"buzzwords\",\n \"quality buzzwords instead of capture cues\",\n ),\n (p, o, raw) => {\n // A numbered line's own words are blanked in `p`, so any occurrence left restates it; an\n // older prompt quotes its copy once and repeats it elsewhere (the blueprint JSON).\n const own = briefCopyLines(raw).length > 0 ? 0 : 1;\n const repeated = [...new Set(copyOf(raw, o))].filter((c) => longEnough(c) && occurrences(p, c) > own);\n return when(\n repeated.length > 0,\n \"copy_repeated\",\n `copy stated more than once: ${repeated.slice(0, 3).join(\" / \")}`,\n );\n },\n (p, o, raw) => {\n if (briefCopyLines(raw).length === 0 && !o.copy) return null;\n const allowed = new Set(copyOf(raw, o));\n const stray = [...p.matchAll(/\"([^\"\\n]+)\"/g)].map((m) => m[1] ?? \"\").filter((q) => q && !allowed.has(q));\n return when(\n stray.length > 0,\n \"unlisted_quoted_text\",\n `quoted text that is not copy: ${stray.slice(0, 3).join(\" / \")}`,\n );\n },\n (p) => {\n const heads = [...p.matchAll(/^(Avoid|Exclusions|Constraints):.*$/gm)];\n const last = heads.at(-1);\n const after = last ? p.slice((last.index ?? 0) + last[0].length).trim() : \"\";\n return when(\n heads.length > 1 || after !== \"\",\n \"constraints_not_last\",\n \"the constraints are not one closing section\",\n );\n },\n (p, o) => {\n if (o.profile?.brief.constraints !== \"positive_last\") return null;\n const negatives = p.replace(/\"[^\"\\n]*\"/g, \"\").match(/\\b(no|not|never|don't|do not|avoid|without)\\b/gi);\n return when(\n Boolean(negatives),\n \"negative_phrasing\",\n `negative phrasing for a model that wants it positive: ${(negatives ?? []).slice(0, 3).join(\", \")}`,\n );\n },\n (p) => {\n const images = [...p.matchAll(/^Image (\\d+)\\b/gm)].map((m) => m[1]);\n return when(new Set(images).size !== images.length, \"reference_roles\", \"a picture is given more than one role\");\n },\n (p) =>\n when(\n /draw no logo|no logo\\b/i.test(p) && /\\bLOGO\\b/.test(p),\n \"logo_conflict\",\n \"a logo is both wired and forbidden\",\n ),\n (p, _o, raw) => {\n // The user found every hand-lettered surface odd (§ \"Fix round\"): the compiler sets it as type.\n const lettered = [...raw.matchAll(/^\\d+\\. \".*\" — [^\\n]*?lettered on ([^\\n]+)$/gm)].map((m) => m[1] ?? \"\");\n const own = p.replace(/^\\d+\\. \"\" — [^\\n]*$/gm, \"\");\n const found = lettered.join(\"\\n\").match(HANDWRITING)?.[0] ?? own.match(HAND_LETTERED)?.[0];\n return when(Boolean(found), \"handwritten_text\", `asks for handwriting: ${found}`);\n },\n (p) => {\n const runs = p.replace(/\"[^\"\\n]*\"/g, '\"\"').match(/[.!?,;:](?:\\s*[.,;:])+/g) ?? [];\n const doubled = runs.filter((r) => !/^\\.{3,}$/.test(r));\n return when(doubled.length > 0, \"doubled_punctuation\", `punctuation doubled: ${doubled.slice(0, 3).join(\" \")}`);\n },\n (p) => {\n const repeated = briefSentences(p).filter((s, i, all) =>\n all.some((other, j) => j !== i && (other === s ? j < i : ` ${other} `.includes(` ${s} `))),\n );\n return when(repeated.length > 0, \"repeated_sentence\", `said twice: ${repeated.slice(0, 2).join(\" / \")}`);\n },\n];\n\n/** Minimum words for a sentence to count as a restatement (shorter ones recur legitimately). */\nconst REPEAT_MIN_WORDS = 5;\n\n/**\n * The brief's own sentences, normalized, section labels off, for the repeat check. Picture\n * lines (\"Image 2 …\") repeat their role's instruction per picture by design, and quoted copy\n * is checked by `copy_repeated`, so both are left out.\n */\nfunction briefSentences(prompt: string): string[] {\n return prompt\n .split(\"\\n\")\n .filter((line) => !/^(Image \\d|\\d+\\. \")/.test(line))\n .map((line) => line.replace(/^[A-Z][a-z]+: /, \"\").replace(/\"[^\"\\n]*\"/g, \"\"))\n .flatMap((line) => line.match(/[^.!?]+[.!?]*/g) ?? [])\n .map((s) => normalized(s.replace(/^[A-Z][a-z ]+: /, \"\")))\n .filter((s) => wordCount(s) >= REPEAT_MIN_WORDS);\n}\n\n/**\n * The contradictions an image prompt can carry (prompt-audit.md §1a, §4), found by reading\n * it. A compiled brief has none; the bench gates on that (\"0 contradictions by lint\").\n */\nexport function lintBrief(prompt: string, opts: LintOptions = {}): BriefIssue[] {\n const own = withoutCopy(prompt);\n return CHECKS.flatMap((check) => {\n const found = check(own, opts, prompt);\n return found ? [found] : [];\n });\n}\n","/**\n * The picture a static ad's sizes are cut from (master shape `plate`): one picture per variant,\n * drawn without the ad's designed words, at the shape every tall size can be cut from; the words\n * are set on each size afterwards (`static_format`).\n *\n * Pure: the model and the delivered formats in, the plate's shape, its zones and the plan of\n * every size out.\n */\nimport { supportedAspectRatios } from \"@baker/canvas-contract\";\nimport { blockingArea, type SafeArea } from \"./platform-safe-area.ts\";\n\n/** A rectangle as fractions of the plate, origin top-left. */\nexport type ZoneSpan = { x0: number; y0: number; x1: number; y1: number };\n\n/**\n * Where things go on the plate, as fractions of it: `subjectCore`, the part every size's cut keeps\n * (every person, face and product inside it stays whole in every size); `wordsZone`, the part\n * every size shows clear of its placement's interface (the words are set there, so it is kept calm).\n */\nexport type PlateZones = { subjectCore: ZoneSpan; wordsZone: ZoneSpan };\n\nfunction ratioValue(ratio: string): number {\n const [w, h] = ratio.split(\":\").map(Number);\n if (!w || !h || !Number.isFinite(w) || !Number.isFinite(h)) throw new Error(`not a W:H ratio: \"${ratio}\"`);\n return w / h;\n}\n\n/** A size cut from the tall plate (a square counts), not the wide one. */\nexport const isPortrait = (format: string): boolean => ratioValue(format) <= 1;\n\n/**\n * The plate's shape: the widest ratio the model draws that is no wider than the narrowest tall\n * size (9:16 for 4:5 and 9:16, 3:4 for 4:5 and 1:1), so every tall size is a cut of it. A set of\n * only wide sizes takes the narrowest ratio the model draws that is no narrower than its widest.\n */\nexport function plateRatio(genModel: string, formats: readonly string[]): string {\n if (formats.length === 0) throw new Error(\"a plate needs at least one format\");\n const ratios = supportedAspectRatios(\"image_generate\", genModel) ?? formats;\n const byWidth = [...ratios].sort((a, b) => ratioValue(a) - ratioValue(b));\n const portrait = formats.filter(isPortrait);\n if (portrait.length > 0) {\n const narrowest = Math.min(...portrait.map(ratioValue));\n const fits = byWidth.filter((r) => ratioValue(r) <= narrowest + 1e-9);\n return (fits[fits.length - 1] ?? byWidth[0]) as string;\n }\n const widest = Math.max(...formats.map(ratioValue));\n return (byWidth.find((r) => ratioValue(r) >= widest - 1e-9) ?? byWidth[byWidth.length - 1]) as string;\n}\n\n/**\n * The shape of the wide picture extended from the tall one, for the wide sizes beside it: the widest\n * ratio the model draws that is no wider than the widest of them (16:9 for 1.91:1), so the model can\n * be shown each wide size inside a frame of its own ratio. The widest size itself when the model\n * draws nothing narrower.\n */\nexport function wideRatio(genModel: string, wide: readonly string[]): string {\n const widest = Math.max(...wide.map(ratioValue));\n const ratios = supportedAspectRatios(\"image_generate\", genModel) ?? wide;\n const fits = [...ratios].filter((r) => ratioValue(r) > 1 && ratioValue(r) <= widest + 1e-9);\n const best = fits.sort((a, b) => ratioValue(b) - ratioValue(a))[0];\n return best ?? (wide.find((f) => ratioValue(f) === widest) as string);\n}\n\n/** A format's cut of a plate of `plate` ratio about its centre, as fractions of the plate. */\nfunction centredCut(plate: string, format: string): ZoneSpan {\n const p = ratioValue(plate);\n const f = ratioValue(format);\n const w = f >= p ? 1 : f / p;\n const h = f >= p ? p / f : 1;\n return { x0: (1 - w) / 2, y0: (1 - h) / 2, x1: (1 + w) / 2, y1: (1 + h) / 2 };\n}\n\n/** The part of `cut` its placement's interface leaves clear (`blockingArea`), as fractions of the plate. */\nfunction clearOf(cut: ZoneSpan, safe: SafeArea): ZoneSpan {\n const w = cut.x1 - cut.x0;\n const h = cut.y1 - cut.y0;\n return {\n x0: cut.x0 + safe.left * w,\n y0: cut.y0 + safe.top * h,\n x1: cut.x1 - safe.right * w,\n y1: cut.y1 - safe.bottom * h,\n };\n}\n\nfunction intersect(spans: readonly ZoneSpan[]): ZoneSpan {\n return {\n x0: Math.max(...spans.map((s) => s.x0)),\n y0: Math.max(...spans.map((s) => s.y0)),\n x1: Math.min(...spans.map((s) => s.x1)),\n y1: Math.min(...spans.map((s) => s.y1)),\n };\n}\n\n/**\n * The plate's zones for the sizes cut from it (`formats` of its family; the others come from the\n * wide plate): what every cut about the centre keeps, and what every cut shows clear of its\n * placement's interface (`placements`, as the sizes were planned). A cut placed around the\n * subjects moves, so these are the zones the brief asks for, never the cut itself.\n */\nexport function plateZones(ratio: string, formats: readonly string[], placements?: readonly string[]): PlateZones {\n const cuts = formats.map((f) => ({ format: f, cut: centredCut(ratio, f) }));\n if (cuts.length === 0) {\n const all = { x0: 0, y0: 0, x1: 1, y1: 1 };\n return { subjectCore: all, wordsZone: all };\n }\n return {\n subjectCore: intersect(cuts.map((c) => c.cut)),\n wordsZone: intersect(cuts.map((c) => clearOf(c.cut, blockingArea(c.format, placements)))),\n };\n}\n","/**\n * Every size of a static ad, from one picture.\n *\n * The ad is generated once, at the master shape. By default (`relayout`) the master is the\n * lead size, delivered as it is, and every other size is the chosen ad re-laid out for its own\n * frame by one image request (`static-adapt.ts`). The other shapes, kept for the bench, cut\n * each size from the master instead, keeping its content band (where every word, the logo and\n * the button sit) inside the target's safe area, and adapt a shape no cut reaches.\n *\n * Pure: formats and sizes in, geometry and plans out.\n */\nimport { nearestSupportedAspectRatio } from \"@baker/canvas-contract\";\nimport { type SafeArea, staticSafeArea } from \"./platform-safe-area.ts\";\nimport { isPortrait, type PlateZones, plateRatio, plateZones, wideRatio } from \"./static-plate.ts\";\n\nexport type Size = { width: number; height: number };\n\n/** A crop in master pixels, and whether it keeps the content band inside the target's safe area. */\nexport type BandCrop = { x: number; y: number; width: number; height: number; fits: boolean };\n\nexport function ratioValue(ratio: string): number {\n const [w, h] = ratio.split(\":\").map(Number);\n if (!w || !h || !Number.isFinite(w) || !Number.isFinite(h)) throw new Error(`not a W:H ratio: \"${ratio}\"`);\n return w / h;\n}\n\n/** One axis: where the crop starts so the band sits inside the target's margins, centred when it can. */\nfunction place(\n full: number,\n length: number,\n band: { start: number; end: number },\n margin: { start: number; end: number },\n): { at: number; fits: boolean } {\n // Float noise (0.94 × 1080 = 1015.1999…) must not decide a pixel either way.\n const lo = Math.max(0, Math.ceil(band.end - length * (1 - margin.end) - 1e-6));\n const hi = Math.min(full - length, Math.floor(band.start - length * margin.start + 1e-6));\n const centred = Math.round((band.start + band.end) / 2 - (length * (margin.start + 1 - margin.end)) / 2);\n if (lo > hi) return { at: Math.min(full - length, Math.max(0, centred)), fits: false };\n return { at: Math.min(hi, Math.max(lo, centred)), fits: true };\n}\n\n/**\n * The largest `target`-shaped crop of the master that keeps the master's content `band`\n * (fractions lost at each edge of the master) inside `targetSafe` (the target's safe area,\n * fractions of the crop), centred on the band. `fits` is false when no such crop exists:\n * the size must then be adapted, not cut.\n */\nexport function bandCropGeometry(\n master: Size,\n target: string,\n band: SafeArea,\n targetSafe: SafeArea = staticSafeArea(target),\n): BandCrop {\n const r = ratioValue(target);\n let width = master.width;\n let height = Math.round(master.width / r);\n if (height > master.height) {\n height = master.height;\n width = Math.round(master.height * r);\n }\n const y = place(\n master.height,\n height,\n { start: band.top * master.height, end: (1 - band.bottom) * master.height },\n { start: targetSafe.top, end: targetSafe.bottom },\n );\n const x = place(\n master.width,\n width,\n { start: band.left * master.width, end: (1 - band.right) * master.width },\n { start: targetSafe.left, end: targetSafe.right },\n );\n return { x: x.at, y: y.at, width, height, fits: x.fits && y.fits };\n}\n\n/**\n * How the master is shaped, one decision for every static ad (`relayout`; the cut shapes are\n * the bench's baselines):\n * - `relayout`: the ad is rendered once at the format the ad set leans on most (4:5 for feed,\n * else the square, else the first portrait size), delivered as it is, and every other size is\n * the chosen ad re-laid out for its own frame by one image request (`static-adapt.ts`): the\n * same words, people, product and logo, recomposed and re-scaled, never cut or pasted.\n * - `9x16_band`: the master is the tallest portrait size (9:16 on Meta) with everything in\n * its Reels band, and the shorter sizes are cuts of it. Zero extra generations.\n * - `4x5_adapt`: the master is the 4:5 feed ad, the square is a cut of it, and the 9:16 is\n * adapted from it by the reframe model (one billed adapt call).\n * - `plate`: one picture per variant is drawn without the ad's designed words at the shape every\n * tall size is cut from (`static-plate.ts`), and each size is a cut of the chosen one with its\n * words set for that size (`static_format`); a wide size beside tall ones is cut from the same\n * picture extended sideways (`static_plate`). Asked for with `--master-shape plate` (ADR 0014).\n */\nexport const MASTER_SHAPES = [\"relayout\", \"9x16_band\", \"4x5_adapt\", \"plate\"] as const;\nexport type MasterShape = (typeof MASTER_SHAPES)[number];\n/**\n * Every new ad is drawn whole and laid out again for each size. ADR 0014 made one picture (`plate`)\n * the default for photo-led ads in Oct 2026, to stop re-laid-out sizes doubling people and boxing\n * the 4:5 in a wider scene; in production its ads came back worse (words set by a second call over a\n * wordless picture, the logo pasted on), as the ADR's first comparison had found (re-laid out 3-0).\n * `--master-shape plate` still asks for it; a canvas keeps the shape it was made on.\n * Tried and reverted three times (docs/marketing-intelligence.md § \"Tried and failed\"): do not flip\n * it without beating the drawn ad on production work.\n */\nexport const DEFAULT_MASTER_SHAPE: MasterShape = \"relayout\";\n\n/** Meta's delivery pixels per format; any other shape is 1080 on its short side. */\nconst META_PIXELS: Readonly<Record<string, Size>> = {\n \"9:16\": { width: 1080, height: 1920 },\n \"4:5\": { width: 1080, height: 1350 },\n \"1:1\": { width: 1080, height: 1080 },\n \"16:9\": { width: 1920, height: 1080 },\n \"1.91:1\": { width: 1200, height: 628 },\n};\n\nexport function deliveredSize(format: string): Size {\n const known = META_PIXELS[format];\n if (known) return known;\n const r = ratioValue(format);\n return r <= 1 ? { width: 1080, height: Math.round(1080 / r) } : { width: Math.round(1080 * r), height: 1080 };\n}\n\n/**\n * The shapes `image_aspect_adapt` renders: ad-format ratios only (the extreme banner ratios are\n * excluded, and the registry cannot gate array elements per model). Anything else is adapted\n * to its nearest and cut.\n */\nexport const ASPECT_ADAPT_FORMATS = [\"1:1\", \"2:3\", \"3:2\", \"3:4\", \"4:3\", \"4:5\", \"5:4\", \"9:16\", \"16:9\", \"21:9\"] as const;\n\nfunction nearestAdaptFormat(format: string): string {\n if ((ASPECT_ADAPT_FORMATS as readonly string[]).includes(format)) return format;\n const wanted = ratioValue(format);\n return [...ASPECT_ADAPT_FORMATS].sort(\n (a, b) => Math.abs(Math.log(ratioValue(a) / wanted)) - Math.abs(Math.log(ratioValue(b) / wanted)),\n )[0] as string;\n}\n\nexport type SizePlan = {\n format: string;\n /** The delivered pixels. */\n size: Size;\n /**\n * `master`: the master itself. `relayout`: the chosen ad re-laid out for this frame (one\n * billed request). `crop`: cut from the master (free). `adapt`: reframed from the master\n * (one billed call). `plate`: cut from the chosen picture, its words set for it (one billed\n * request; the lead's is the variant's own).\n */\n from: \"master\" | \"relayout\" | \"crop\" | \"adapt\" | \"plate\";\n /** For a size cut from a picture: the tall one the variants draw, or the wide one it is extended to. */\n plate?: \"primary\" | \"wide\";\n /** For a cut, the rectangle in the master's pixels. */\n crop?: BandCrop;\n /** For an adapted size, the shape the reframe node renders before it is cut to `size`. */\n adaptFormat?: string;\n};\n\nexport type StaticFormatPlan = {\n masterShape: MasterShape;\n /** The ad set's placements the plan keeps clear of (`staticSafeArea`); absent = Advantage+ (Reels included). */\n placements?: readonly string[];\n /** The size its platform designs first (`deliveryPlan`), when one was named: the relayout master. */\n lead?: string;\n /** The platforms the sizes were planned for, when named: a definition naming others re-plans them. */\n platforms?: readonly string[];\n master: { format: string; renderRatio: string; size: Size };\n /** Where every word, the logo and the button sit on the master, as fractions lost at each edge: inside every cut's safe area. */\n band: SafeArea;\n /** Every delivered size, in the order delivered. */\n sizes: SizePlan[];\n /**\n * `plate`: the picture's shape (what the variants draw, `master.renderRatio`), its zones, and\n * the shape of the wide picture extended from it when wide sizes sit beside tall ones.\n */\n plate?: { ratio: string; zones: PlateZones; wide?: string };\n};\n\nfunction masterFormat(formats: readonly string[], shape: MasterShape): string {\n const portrait = formats.filter((f) => ratioValue(f) <= 1);\n if (portrait.length === 0) return formats[0] as string;\n if (shape === \"4x5_adapt\" && portrait.includes(\"4:5\")) return \"4:5\";\n return [...portrait].sort((a, b) => ratioValue(a) - ratioValue(b))[0] as string;\n}\n\n/**\n * The master's content band: its own safe area, with the sides pulled in to the widest\n * margin any cut needs and the height shrunk (about its centre) to fit the shortest cut's\n * safe height, so every cut can hold it.\n */\nexport function masterContentBand(master: string, cuts: readonly string[], placements?: readonly string[]): SafeArea {\n const own = staticSafeArea(master, placements);\n const band: SafeArea = { top: own.top, bottom: own.bottom, left: own.left, right: own.right };\n const m = ratioValue(master);\n for (const cut of cuts) {\n const safe = staticSafeArea(cut, placements);\n band.left = Math.max(band.left, safe.left);\n band.right = Math.max(band.right, safe.right);\n // A cut wider than the master takes its full width and this share of its height.\n const share = m / ratioValue(cut);\n // Less a pixel's worth at each edge, so the cut's whole-pixel offset still holds it.\n const room = share * (1 - safe.top - safe.bottom) - 0.002;\n const height = 1 - band.top - band.bottom;\n if (height > room) {\n const shrink = (height - room) / 2;\n band.top += shrink;\n band.bottom += shrink;\n }\n }\n return band;\n}\n\n/**\n * How each delivered format is made from the one master: the master itself, the chosen ad\n * re-laid out for that frame (`relayout`, the default), or, on the cut shapes, a cut that keeps\n * the content band inside the size's safe area or an adapt for a shape no cut reaches\n * (landscape from a portrait master; the 9:16 of a `4x5_adapt` master). `placements` are the\n * ad set's (see `staticSafeArea`).\n */\nexport function planStaticFormats(\n genModel: string,\n formats: readonly string[],\n opts: {\n masterShape?: MasterShape;\n placements?: readonly string[];\n lead?: string;\n platforms?: readonly string[];\n } = {},\n): StaticFormatPlan {\n if (formats.length === 0) throw new Error(\"a static ad needs at least one format\");\n const masterShape = opts.masterShape ?? DEFAULT_MASTER_SHAPE;\n const platforms = opts.platforms && opts.platforms.length > 0 ? { platforms: [...opts.platforms] } : {};\n if (masterShape === \"relayout\")\n return { ...planRelayout(genModel, formats, opts.placements, opts.lead), ...platforms };\n if (masterShape === \"plate\") return { ...planPlate(genModel, formats, opts.placements, opts.lead), ...platforms };\n const format = masterFormat(formats, masterShape);\n const size = deliveredSize(format);\n const m = ratioValue(format);\n const cuts = formats.filter((f) => f !== format && ratioValue(f) >= m && ratioValue(f) <= Math.max(1, m));\n const band = masterContentBand(format, cuts, opts.placements);\n const sizes = formats.map((f): SizePlan => {\n if (f === format) return { format: f, size, from: \"master\" };\n if (cuts.includes(f)) {\n const crop = bandCropGeometry(size, f, band, staticSafeArea(f, opts.placements));\n if (crop.fits) return { format: f, size: deliveredSize(f), from: \"crop\", crop };\n }\n return { format: f, size: deliveredSize(f), from: \"adapt\", adaptFormat: nearestAdaptFormat(f) };\n });\n return {\n masterShape,\n ...(opts.placements && opts.placements.length > 0 ? { placements: [...opts.placements] } : {}),\n ...platforms,\n master: { format, renderRatio: nearestSupportedAspectRatio(\"image_generate\", genModel, format), size },\n band,\n sizes,\n };\n}\n\n/**\n * The master of a canvas that recorded no lead (made before platforms decided it): the 4:5 feed,\n * else the square, else the first portrait size, else the first. Kept so those canvases re-plan\n * to the master they were made with.\n */\nfunction leadFormat(formats: readonly string[]): string {\n for (const lead of [\"4:5\", \"1:1\"]) if (formats.includes(lead)) return lead;\n return formats.find((f) => ratioValue(f) <= 1) ?? (formats[0] as string);\n}\n\n/**\n * `relayout`: the master is the lead format (its platform's, else `leadFormat`), delivered as it\n * is, its own safe area its band; every other size is re-laid out from it. Nothing is cut.\n */\nfunction planRelayout(\n genModel: string,\n formats: readonly string[],\n placements: readonly string[] | undefined,\n lead: string | undefined,\n): StaticFormatPlan {\n const named = lead !== undefined && formats.includes(lead) ? lead : undefined;\n const format = named ?? leadFormat(formats);\n const size = deliveredSize(format);\n const { top, bottom, left, right } = staticSafeArea(format, placements);\n return {\n masterShape: \"relayout\",\n ...(placements && placements.length > 0 ? { placements: [...placements] } : {}),\n ...(named ? { lead: named } : {}),\n master: { format, renderRatio: nearestSupportedAspectRatio(\"image_generate\", genModel, format), size },\n band: { top, bottom, left, right },\n sizes: formats.map(\n (f): SizePlan =>\n f === format ? { format: f, size, from: \"master\" } : { format: f, size: deliveredSize(f), from: \"relayout\" },\n ),\n };\n}\n\n/** The lead a one-picture ad draws its variants at: a wide lead beside tall sizes gives way to the first tall size. */\nexport function plateDrawnLead(formats: readonly string[], lead: string | undefined): string | undefined {\n const tall = formats.filter(isPortrait);\n return lead !== undefined && tall.length > 0 && formats.includes(lead) && !isPortrait(lead) ? tall[0] : lead;\n}\n\n/**\n * `plate`: the master is the lead format, as `relayout` names it, each variant a picture at the\n * plate's shape with the lead's words set on it; every other size is cut from the chosen picture,\n * a wide size beside tall ones from that picture extended to the widest wide size. A wide lead\n * beside tall sizes gives way to the first tall size: the variants are drawn tall, and a wide\n * size is only ever the chosen picture extended.\n */\nfunction planPlate(\n genModel: string,\n formats: readonly string[],\n placements: readonly string[] | undefined,\n lead: string | undefined,\n): StaticFormatPlan {\n const tall = formats.filter(isPortrait);\n const wide = tall.length > 0 ? formats.filter((f) => !isPortrait(f)) : [];\n const drawnLead = plateDrawnLead(formats, lead);\n const relaid = planRelayout(genModel, formats, placements, drawnLead);\n const ratio = plateRatio(genModel, tall.length > 0 ? tall : formats);\n const widest = wide.length > 0 ? wideRatio(genModel, wide) : undefined;\n return {\n ...relaid,\n masterShape: \"plate\",\n master: { ...relaid.master, renderRatio: ratio },\n sizes: formats.map((f) => ({\n format: f,\n size: deliveredSize(f),\n from: \"plate\",\n plate: wide.includes(f) ? \"wide\" : \"primary\",\n })),\n plate: {\n ratio,\n zones: plateZones(ratio, tall.length > 0 ? tall : formats, placements),\n ...(widest ? { wide: widest } : {}),\n },\n };\n}\n","/**\n * One size of a static ad, re-laid out for its frame from the chosen ad.\n *\n * The chosen ad (the master) is the reference of one image request per other size: the same\n * message, words, people, product, logo and background, moved and scaled for the frame,\n * inside its safe area. Never a crop, a shrink onto a\n * background or a pasted panel: the user rated every geometric way of making the sizes\n * (crops, re-frames, the square on a painted or coloured ground) and rejected them as \"an\n * image on top of another thing\" (.context/static-review/BENCH.md § \"E5 — true per-format\n * adaptation\").\n *\n * Pure: formats in, the request's plan, its brief and the argv of the fill to the delivered\n * pixels out.\n */\nimport { nearestSupportedAspectRatio } from \"@baker/canvas-contract\";\nimport type { CreativeRule } from \"../creative-rules/schema.ts\";\nimport type { ImageModelProfile } from \"../lib/prompt-profiles.ts\";\nimport { blockingArea, type SafeArea, staticSafeArea } from \"./platform-safe-area.ts\";\nimport { type AdSpec, isMemeTemplate } from \"./static-ad-spec.ts\";\nimport {\n briefWords,\n type CompiledBrief,\n compileStaticBrief,\n isBeforeAfter,\n PEOPLE,\n type PlannedBand,\n quotedCopy,\n} from \"./static-brief.ts\";\nimport { deliveredSize, ratioValue, type Size } from \"./static-sizes.ts\";\n\n/** One size re-laid out from the chosen ad by one image request (`relayout`): its brief is projected from prompt.json. */\nexport const STATIC_ADAPT_FORMAT_ROLE = \"static_adapt_format\";\n\nexport type AdaptPlan = {\n /** The delivered format. */\n format: string;\n /** The ad set's placements the size keeps clear of (`staticSafeArea`); absent = Advantage+. */\n placements?: readonly string[];\n /** The ratio the model renders: the format, or the model's nearest when it has no such ratio. */\n renderRatio: string;\n /** The delivered pixels. */\n size: Size;\n /** The format's safe area on the rendered frame, so it holds once the render is cut to the format. */\n safe: SafeArea;\n};\n\n/**\n * How one size is rendered: at the model's nearest ratio to the format, then filled (cut at\n * the centre) to the delivered pixels. The safe area is stated on the rendered frame, so a\n * 3:4 GPT render cut to 4:5 still keeps the feed margin after the cut.\n */\nexport function adaptPlan(model: string, format: string, placements?: readonly string[]): AdaptPlan {\n const renderRatio = nearestSupportedAspectRatio(\"image_generate\", model, format);\n return {\n format,\n ...(placements && placements.length > 0 ? { placements: [...placements] } : {}),\n renderRatio,\n size: deliveredSize(format),\n safe: safeAreaOnFrame(renderRatio, format, placements),\n };\n}\n\n/**\n * `format`'s safe area stated on a frame of ratio `frame` that is filled (cut at the centre) to\n * it: the strip the fill trims, then the format's own margin on what it keeps.\n */\nexport function safeAreaOnFrame(frame: string, format: string, placements?: readonly string[]): SafeArea {\n const own = blockingArea(format, placements);\n const rendered = ratioValue(frame);\n const delivered = ratioValue(format);\n // The share of the rendered frame's height (or width) the fill keeps, centred.\n const keepH = rendered < delivered ? rendered / delivered : 1;\n const keepW = rendered > delivered ? delivered / rendered : 1;\n return {\n top: (1 - keepH) / 2 + own.top * keepH,\n bottom: (1 - keepH) / 2 + own.bottom * keepH,\n left: (1 - keepW) / 2 + own.left * keepW,\n right: (1 - keepW) / 2 + own.right * keepW,\n };\n}\n\n/**\n * The margin a render keeps when the fill to its format trims it (a 3:4 GPT render filled to\n * 4:5): the format's safe area mapped onto the rendered frame, stated as edges. Undefined when\n * the model renders the format itself and its own safe area holds.\n */\nexport function trimmedRenderBand(plan: AdaptPlan): PlannedBand | undefined {\n const own = blockingArea(plan.format, plan.placements);\n const trimmed = ([\"top\", \"bottom\", \"left\", \"right\"] as const).some(\n (edge) => Math.abs(own[edge] - plan.safe[edge]) > 1e-9,\n );\n return trimmed ? { area: plan.safe, cut: false, margin: true } : undefined;\n}\n\n/** Fill `size` exactly (Lanczos, centred): what the master and every re-laid-out size go through. */\nexport function fillArgs(size: Size): string[] {\n const px = `${size.width}x${size.height}`;\n return [\n \"{{in.image}}\",\n \"-filter\",\n \"Lanczos\",\n \"-resize\",\n `${px}^`,\n \"-gravity\",\n \"center\",\n \"-extent\",\n px,\n \"+repage\",\n \"{{out.image}}\",\n ];\n}\n\n/** The pictures one adapt request is handed, as the refs the canvas passes them by. */\nexport type AdaptImages = {\n /** The chosen ad: what is re-laid out. */\n base: string;\n logo?: string;\n /** The specimen of the brand's typeface. */\n type?: string;\n /** The spec's own pictures (PRODUCT_1, PERSON_1 …) by reference id, so every size keeps them exactly. */\n refs?: Readonly<Record<string, string>>;\n};\n\n/** What the size is, in the words of the deliverable. */\nfunction adaptNoun(plan: AdaptPlan): string {\n const r = ratioValue(plan.format);\n if (plan.format === \"9:16\") {\n const safe = staticSafeArea(plan.format, plan.placements);\n return safe.placement === \"stories\"\n ? \"full-screen vertical ad for Stories\"\n : safe.placement === \"vertical\"\n ? `full-screen vertical ad for ${safe.surface}`\n : \"full-screen vertical ad for Stories and Reels\";\n }\n if (r === 1) return \"square feed ad\";\n return r < 1 ? \"vertical feed ad\" : \"landscape ad\";\n}\n\n/** The deliverable: this ad, re-laid out for the frame; never the ad shrunk onto a background. */\nfunction adaptDeliverable(plan: AdaptPlan, spec: AdSpec, flowing: boolean, ground: boolean, short: boolean): string {\n const brand = spec.brand?.name;\n const noun = `${adaptNoun(plan)}${brand ? ` for ${brand}` : \"\"}`;\n const background = \"Extend only the background at Image 1's outer edges; textures stay on their existing surfaces.\";\n if (short && !flowing) {\n const keep = [\n ...(showsPeople(spec) ? [\"each person the same face and clothes\"] : []),\n ...(isBeforeAfter(spec) ? [\"the two states as different\"] : []),\n ];\n return `Deliverable: adapt Image 1 to a ${noun}. Move and scale existing elements first; reflow the contents for this frame, keeping its words, people, product, logo, colours and typeface. ${background} Keep any depicted app interface exact, with marketing overlays visibly separate from its native controls. Every person, product and line appears whole and once${keep.length > 0 ? `, ${keep.join(\", \")}` : \"\"}; add nothing new; never Image 1 shrunk onto a background.`;\n }\n const cast = [\n SAME_CAST,\n ...(showsPeople(spec) ? [SAME_PERSON] : []),\n ...(isBeforeAfter(spec) ? [SAME_CHANGE] : []),\n ...(ground ? [GROUND_ONLY] : []),\n ].join(\" \");\n const continuity = `Move and scale existing elements first; reflow the contents for this frame instead of pasting a smaller copy on a backdrop. Keep the visual hierarchy. ${background} Keep any depicted app interface exact, with marketing overlays visibly separate from its native controls.`;\n return flowing\n ? `Image 1 is a finished ad. Adapt this same ad to a ${noun}, keeping its message, words, people, product, logo, colours and typeface. ${continuity} ${cast}`\n : `Deliverable: the ad in Image 1, re-laid out as a finished ${noun}, keeping its message, words, people, product, logo, colours and typeface; never Image 1 shrunk onto a background. ${continuity} ${cast}`;\n}\n\n/**\n * Every size shows the same cast. Bench E5: the room a new frame adds was filled with a new\n * scene, often a new person, and the 4:5 and the 9:16 of one ad could show different people.\n */\nconst SAME_CAST =\n \"Every person, product and line appears whole and once, the same individuals as in Image 1; add no person, animal, product or object that Image 1 does not show.\";\n/** The headphones ad's man looked different on its 9:16 (BENCH.md § \"Final\"). */\nconst SAME_PERSON = \"Each person is the same person as in Image 1: same face, same hair, same clothes.\";\n/** The serum's two faces barely differed in its re-laid sizes (BENCH.md § \"Final\"). */\nconst SAME_CHANGE = \"The two states it compares stay as clearly different as in Image 1.\";\n\nconst showsPeople = (spec: AdSpec): boolean =>\n spec.references.some((r) => r.id.startsWith(\"PERSON_\")) ||\n (spec.scene.look !== \"illustration\" && PEOPLE.test(`${spec.scene.description} ${spec.scene.layout ?? \"\"}`));\n\n/** What the room a new frame adds carries when Image 1 is its words on a ground (the zones say it when they are stated). */\nconst GROUND_ONLY =\n \"Image 1 shows no people and no product, so the room this frame adds carries only Image 1's own background and the brand's colours already present there, never a new scene.\";\n\n/** The chosen ad is its words on the brand's ground: no picture of anyone or anything is wired, and its scene names no one. */\nfunction wordsOnly(spec: AdSpec): boolean {\n return (\n spec.references.length === 0 &&\n spec.scene.look !== \"photo\" &&\n !PEOPLE.test(`${spec.scene.description} ${spec.scene.layout ?? \"\"}`)\n );\n}\n\n/** A frame much taller than it is wide (9:16): the one whose words a middle band holds. */\nconst isTall = (plan: AdaptPlan): boolean => ratioValue(plan.format) < 0.7;\n\n/** Copy laid out as a list or a table: rows a tall frame restacks rather than shrinks. */\nconst LIST_ROLES = /^(list_item|bullet|row|item)$/i;\nconst TABLE = /\\b(tables?|columns?|rows?|checklists?|lists?)\\b/i;\nconst hasRows = (spec: AdSpec): boolean =>\n spec.copy.some((l) => LIST_ROLES.test(l.role ?? \"\")) ||\n TABLE.test(`${spec.scene.description} ${spec.scene.layout ?? \"\"}`);\n\n/**\n * The words set for the frame, not at Image 1's size. On a tall frame they are set large: the\n * user found the final 9:16s' words small in their middle band, with \"too much empty space\"\n * around them (BENCH.md § \"Fix round\"); a list or a table is restacked rather than shrunk. Large,\n * but one block inside the band with the button under it: told to spread the words through the\n * band's height, Zernio's 9:16s (prod, Oct 2026) set the button below it, where Stories covers it.\n */\nfunction scaleText(plan: AdaptPlan, spec: AdSpec, flowing: boolean, zoned: boolean, short: boolean): string {\n if (short && !flowing) {\n return isTall(plan) && zoned\n ? \"Scale: larger than Image 1, the headline across most of the band's width; one block, the button at its foot.\"\n : \"Scale: larger than in Image 1, the largest line across most of the width.\";\n }\n if (!(isTall(plan) && zoned)) {\n return flowing\n ? \"Every line is set at the size this frame needs rather than at its size in Image 1: the largest line spans most of the width between the margins, and the words fill their space.\"\n : \"Scale: set every line for this frame, not at its size in Image 1: the largest line spans most of the width between the margins; no small text in a large empty area.\";\n }\n const rows = hasRows(spec)\n ? flowing\n ? \" Rows, columns and lists are restacked for the tall frame, one item per line, each larger.\"\n : \" Rows, columns and lists are restacked for the tall frame, one item per line, each larger, rather than shrunk.\"\n : \"\";\n return flowing\n ? `The words are set for this frame, larger than in Image 1: the headline large enough to fill most of the band's width; the words and the button one block inside the band, the button under the last line, nothing below the band.${rows}`\n : `Scale: larger than in Image 1: the headline set large enough to fill most of the band's width; the words one block inside the band, nothing below it.${rows}`;\n}\n\n/**\n * Room the zones ask inside the safe area of a tall frame the app covers. Asked for exactly the\n * checked band (16-78%), the model set the button at the bottom as in a feed ad: 0 of 6\n * re-layouts kept inside it and every ad paid a repair round (dev, Oct 2026). Asked for 22-70%,\n * 5 of 9 did, and the rest overshot by less. Held to Reels' caption as well (Advantage+), the band\n * is 22-55%, the same room short of what the review blocks. Any other frame is asked for its own band.\n */\nconst COVERED_HEADROOM = { top: 0.06, bottom: 0.08, side: 0.02 };\n/** A framed card carries its words on the card, so the card itself must fill the band: less headroom around it. */\nconst CARD_HEADROOM = { top: 0.02, bottom: 0.03, side: 0.04 };\n\n/** The ad is a designed block whose words all sit on its own card or windows (only a button may stand off it). */\nfunction isFramedCard(spec: AdSpec): boolean {\n const words = spec.copy.filter((l) => !/cta|button/i.test(l.role ?? \"\"));\n return spec.scene.look === \"designed\" && words.length > 1 && words.every((l) => l.lettering === \"in_scene\");\n}\nconst NO_HEADROOM = { top: 0, bottom: 0, side: 0 };\n\nconst pct = (share: number): string => `${Math.round(share * 100)}%`;\n\n/**\n * The frame as zones: the words' band (every word, the logo and the button), and around it the\n * ad's existing background treatment. A flat ground or native screenshot must not gain a\n * photographic setting merely to fill a taller frame. The covered bands are named as\n * carrying neither words nor the logo: without it, the fix round's first 9:16s set the logo above\n * the band and none passed the Stories area. One statement of the frame: the Layout states no\n * safe area of its own (`zoned`).\n */\nfunction zonesText(plan: AdaptPlan, flowing: boolean, short: boolean, card = false): string {\n const covered = staticSafeArea(plan.format, plan.placements).placement !== \"feed\";\n const room = isTall(plan) && covered ? (card ? CARD_HEADROOM : COVERED_HEADROOM) : NO_HEADROOM;\n const top = plan.safe.top + room.top;\n const bottom = plan.safe.bottom + room.bottom;\n const side = Math.max(plan.safe.left, plan.safe.right) + room.side;\n const band = `from ${pct(top)} to ${pct(1 - bottom)} of the height, at least ${pct(side)} in from each side`;\n if (short && !flowing) {\n const around = \"Image 1's existing background treatment, including any intentional flat colour\";\n return `Zones: every word, the logo and the button sit ${band}; around them, ${around}.`;\n }\n if (!(isTall(plan) && covered)) {\n return flowing\n ? `The logo, every line and the button sit ${band}; around them the frame shows only the ad's own picture.`\n : `Zones: the logo, every line and the button sit ${band}; around them, only the ad's own picture.`;\n }\n const picture = card\n ? \"Image 1's flat ground colour only, never a scene a picture inside the card shows\"\n : \"Image 1's existing background treatment, including any intentional flat colour\";\n const fill = card ? \" The framed card is enlarged to fill the band's width and height, its contents with it.\" : \"\";\n return flowing\n ? `The words' band runs ${band}, holding the logo, every line and the button. Above and below it the placement's interface covers the frame: continue only ${picture}.${fill}`\n : `Zones: the app's buttons and captions cover the top and the bottom of this frame, hiding any word there. The logo, every line and the button sit in one band, ${band}: the headline starts below the top fifth, and the button ends directly under the last line, never at the bottom edge where a feed ad puts it. Above and below it, where the placement's interface covers the frame, continue only ${picture}.${fill}`;\n}\n\n/**\n * A meme's panels on a tall frame: one picture, stacked as the ad has them, the button under the\n * last. Zernio's 9:16 (round 6) set its button between the panic row and the calm row. Pure.\n */\nfunction memePanelsText(plan: AdaptPlan, spec: AdSpec): string[] {\n return isTall(plan) && spec.references.some(isMemeTemplate)\n ? [\n \"The meme's panels stay together, stacked as in Image 1 with nothing between them; the button sits below the last panel.\",\n ]\n : [];\n}\n\n/**\n * The brief of one adapt request: the compiled re-lay brief for the format (the exact copy,\n * its hierarchy, the logo, the typeface and the safe area, from `compileStaticBrief`) with the\n * square's own per-line positions dropped (they place the words for Image 1's shape), led by\n * the re-layout deliverable, with the words re-scaled for the frame and the frame stated as\n * zones (`zones: false` leaves them out: the bench's arm without them).\n */\nexport function adaptBrief(\n spec: AdSpec,\n profile: ImageModelProfile,\n opts: {\n plan: AdaptPlan;\n images: AdaptImages;\n zones?: boolean;\n rules?: readonly CreativeRule[];\n /** Each line's look told whole and its marks allowed (`BriefOptions.looksWhole`): a size's words call. */\n looksWhole?: boolean;\n },\n): CompiledBrief {\n const { plan, images } = opts;\n const flowing = profile.brief.structure === \"flowing_sentences\";\n const { logo_position: _logoPosition, ...rest } = spec;\n const unplaced: AdSpec = { ...rest, copy: spec.copy.map(({ position: _position, ...line }) => line) };\n const band = trimmedRenderBand(plan);\n const zoned = opts.zones !== false;\n const ground = wordsOnly(spec);\n const framed = isFramedCard(spec);\n const compile = (wordBudget: number) =>\n compileStaticBrief(\n unplaced,\n undefined,\n plan.format,\n undefined,\n { ...profile, brief: { ...profile.brief, wordBudget } },\n {\n job: \"relay\",\n images: {\n base: images.base,\n ...(images.logo ? { logo: images.logo } : {}),\n ...(images.type ? { type: images.type } : {}),\n refs: images.refs ?? {},\n },\n ...(plan.placements ? { placements: plan.placements } : {}),\n ...(band ? { band } : {}),\n ...(zoned ? { zoned } : {}),\n ...(opts.rules ? { rules: opts.rules } : {}),\n ...(opts.looksWhole ? { looksWhole: true } : {}),\n },\n );\n const relaid = (compiled: CompiledBrief, short = false): string => {\n const paragraphs = compiled.prompt.split(\"\\n\\n\");\n paragraphs[0] = adaptDeliverable(plan, spec, flowing, ground && !zoned, short);\n const first = spec.copy[0] ? quotedCopy(spec.copy[0].text) : undefined;\n const textAt = first ? paragraphs.findIndex((p) => p.includes(first)) : -1;\n if (textAt >= 0) {\n const added = [\n ...(zoned ? [zonesText(plan, flowing, short, framed)] : []),\n scaleText(plan, spec, flowing, zoned, short),\n ...memePanelsText(plan, spec),\n ];\n paragraphs.splice(textAt + 1, 0, ...added);\n } else if (zoned) {\n // No line to anchor on (an ad of only a logo or a picture): the zones are still its only safe area.\n const layoutAt = paragraphs.findIndex((p) => p.startsWith(\"Layout:\"));\n paragraphs.splice(layoutAt > 0 ? layoutAt : 1, 0, zonesText(plan, flowing, short, framed));\n }\n return paragraphs.join(\"\\n\\n\");\n };\n // The re-layout's own sentences count against the profile's budget: the relay brief under\n // them is trimmed (never its copy) until the whole fits, and then, a crowded ad, they take\n // their short forms.\n const budget = profile.brief.wordBudget;\n let compiled = compile(budget);\n let prompt = relaid(compiled);\n for (let pass = 0; pass < 3 && briefWords(prompt) > budget; pass++) {\n compiled = compile(compiled.words - (briefWords(prompt) - budget));\n prompt = relaid(compiled);\n }\n if (briefWords(prompt) > budget) prompt = relaid(compiled, true);\n return { ...compiled, prompt, words: wordsIn(prompt) };\n}\n\nconst wordsIn = (text: string): number => text.split(/\\s+/).filter(Boolean).length;\n","/**\n * Per-model GENERATION PROFILES. Each model we call — video (Seedance, Veo) and\n * image (gpt-image, Gemini, Recraft) — has a documented best-practice prompt\n * structure, length budget, dialogue/audio convention, negative-prompt mechanism,\n * and request-param set. The scaffolder used to emit ONE prompt shape and set none\n * of the param levers; these profiles are the single seam where each model's rules\n * live, read by BOTH the prompt builders and the validator so the two can't drift.\n *\n * Sources (see the session research briefs): fal.ai/learn + BytePlus ModelArk for\n * Seedance; ai.google.dev + cloud.google.com for Veo; OpenAI Cookbook + OpenRouter\n * image docs for gpt-image; ai.google.dev for Gemini image.\n */\nimport {\n canonicalModelId,\n type IMAGE_GENERATE_MODELS,\n MODEL_REGISTRY,\n type VIDEO_GENERATE_MODELS,\n} from \"@baker/canvas-contract\";\n\n/** Veo permits generating adult humans from a keyframe — the sanctioned escape from\n * ByteDance's real-person filter; it is also the ONLY legal value for image-to-video\n * in the EU/UK/CH/MENA. Set on every Veo clip. */\nconst VEO_PERSON_GENERATION = \"allow_adult\";\n/** Veo frequently burns in captions/subtitles even when unasked (a known model\n * artifact); the dedicated negative_prompt param is the real suppression lever\n * (an inline \"no subtitles\" line alone is unreliable). Phrased as absences. */\nconst VEO_NEGATIVE_PROMPT =\n \"subtitles, captions, on-screen text, watermark, logo, warped face, distorted hands, extra fingers, low quality\";\n/** Kling has a real `negative_prompt` param (forwarded top-level by the backend);\n * phrase as absences, same family as Veo's. */\nconst KLING_NEGATIVE_PROMPT =\n \"warped face, distorted hands, extra fingers, morphing, flicker, on-screen text, watermark, low quality\";\n/** Kling's prompt-adherence dial — higher hugs the prompt (good for a scripted\n * scroll-stopper), lower gives the model more motion freedom. */\nconst KLING_CFG_SCALE = 0.7;\n\n/**\n * A video model's clip-prompt + request-param profile. `dialogueDirective` and the\n * literal `Dialogue: \"…\"` marker it emits are the parse contract `nativeDialogueOf`\n * (and the validator's speech-fit gates) read — both profiles MUST keep that marker.\n */\nexport type ClipPromptProfile = {\n id: \"seedance\" | \"veo\" | \"kling\" | \"omni\";\n /** The talking-head directive carrying the verbatim spoken line. */\n dialogueDirective(line: string, accent?: string): string;\n /** Model-specific hard rules appended to every clip prompt (may be empty). */\n extraDirectives: string[];\n /** Affirmative quality/stability directives for models with NO negative_prompt param\n * (Seedance). Emitted as a positive \"keep it stable\" tail, NOT an \"Avoid:\" list: Seedance\n * has no negative field, and inline negation (\"no warped hands\") is weak grammar around a\n * strong activation that tends to SUMMON the very artifact — the fal.ai guide's rule is\n * \"phrase everything positively\" (see seedance-mechanics.md §3). Empty for models that take\n * a real negative_prompt param (Veo, Kling), which parse literal exclusions correctly. */\n stabilityDirectives: string[];\n /** The image-to-video instruction to hold the source frame's framing/palette. */\n keyframeInstruction: string;\n /** Soft word budget for one clip prompt — the validator warns above it. */\n wordBudget: number;\n /** Request params merged onto every `video_generate` node for this model. */\n paramDefaults: Record<string, unknown>;\n};\n\n// Both video profiles now put delivery in PROSE, not [brackets]: the Seedance 2.0\n// guide (and Veo's) carry emotion in the wording around the quoted line; Seedance\n// renders literal brackets and Veo burns them as on-screen text.\nconst SPEAKS_PROSE = (line: string, accent?: string) =>\n `The person speaks to camera; lip-sync follows the dialogue verbatim, with delivery and emotion carried in the wording itself (no bracketed cues).` +\n // The model picks a variety of the language on its own, and picks the commonest one:\n // three ads set in Spain came back in Latin American Spanish. Pinning a peninsular voice\n // does not fix it — the re-voicing is speech-to-speech, so it carries the delivery across\n // and swaps only the timbre, and the accent lives in the delivery. It has to be said HERE,\n // where the speech is made.\n `${accent ? ` The speech is in ${accent}.` : \"\"} Dialogue: \"${line}\"`;\n\nexport const SEEDANCE_PROFILE: ClipPromptProfile = {\n id: \"seedance\",\n dialogueDirective: SPEAKS_PROSE,\n extraDirectives: [],\n // Seedance has no negative_prompt field. Phrase the anti-artifact intent as the POSITIVE\n // state we want (crisp hands, one stable face, smooth coherent motion, locked identity) —\n // an \"Avoid: warped fingers, morphing faces\" list tends to plant those very artifacts.\n stabilityDirectives: [\n \"hands and fingers crisp and anatomically correct\",\n \"one consistent face and identity across every frame\",\n \"smooth, temporally coherent motion that holds steady frame to frame\",\n ],\n keyframeInstruction: \"Preserve the composition and colors of the first frame; change only the motion described.\",\n // ~120 words is the Seedance quality sweet spot: past it the model starts dropping beats and\n // the attention budget dilutes. The validator warns above this; composite scenes that stack\n // many brief `parts` are the usual offenders.\n wordBudget: 120,\n paramDefaults: {},\n};\n\nexport const VEO_PROFILE: ClipPromptProfile = {\n id: \"veo\",\n dialogueDirective: SPEAKS_PROSE,\n // Veo's known failure mode: quoted dialogue triggers burned-in subtitles. Belt\n // (inline) and braces (the negative_prompt param, below) — the param is the real lever.\n extraDirectives: [\"No subtitles, no captions, no on-screen text of any kind.\"],\n stabilityDirectives: [], // Veo takes a negative_prompt PARAM instead (paramDefaults).\n keyframeInstruction: \"Describe the transition and camera move between the frames; the frames fix the content.\",\n wordBudget: 200,\n paramDefaults: { person_generation: VEO_PERSON_GENERATION, negative_prompt: VEO_NEGATIVE_PROMPT },\n};\n\nexport const KLING_PROFILE: ClipPromptProfile = {\n id: \"kling\",\n dialogueDirective: SPEAKS_PROSE,\n // Belt (inline) and braces (the negative_prompt param) — the param is the real lever.\n extraDirectives: [\"Single, deliberate camera move — no whip pans or rapid cuts within the clip.\"],\n stabilityDirectives: [], // Kling takes a negative_prompt PARAM instead (paramDefaults).\n keyframeInstruction: \"Preserve the composition and colors of the first frame; animate the motion described.\",\n wordBudget: 200,\n paramDefaults: { negative_prompt: KLING_NEGATIVE_PROMPT, cfg_scale: KLING_CFG_SCALE },\n};\n\nexport const OMNI_PROFILE: ClipPromptProfile = {\n id: \"omni\",\n dialogueDirective: SPEAKS_PROSE,\n // Omni renders speech and ambience natively in the same pass, so the prompt\n // carries the audio direction; there is no separate audio toggle to set.\n extraDirectives: [\"No subtitles, no captions, no on-screen text of any kind.\"],\n // Omni exposes NO negative_prompt param — the API rejects the field outright —\n // so the anti-artifact intent has to be carried positively, Seedance-style,\n // rather than as an \"Avoid:\" list Veo would have taken as a param.\n stabilityDirectives: [\n \"hands and fingers crisp and anatomically correct\",\n \"one consistent face and identity across every frame\",\n \"smooth, temporally coherent motion that holds steady frame to frame\",\n ],\n keyframeInstruction: \"Preserve the composition and colors of the first frame; change only the motion described.\",\n // Omni reasons over a 1M-token context and rewards a fuller brief than the\n // diffusion-style models, which dilute past their sweet spot.\n wordBudget: 200,\n // Nothing to set. Every knob the other profiles use (negative_prompt,\n // person_generation, cfg_scale) is a pre-dispatch 400 on this model.\n paramDefaults: {},\n};\n\n/**\n * The prompt profile of every curated video model, by exact registry id. `null` is a\n * deliberate \"no profile yet\": the scaffolder falls back to the Seedance prompt shape\n * and the lint rule says so. Typed over the whole roster, so a model added to the\n * registry does not compile until someone decides which profile it gets.\n *\n * Omni has its own entry although it shares Google's namespace with Veo: it takes\n * none of Veo's params, and Veo's negative_prompt default is a 400 there.\n */\nexport const CLIP_PROFILES: Readonly<Record<(typeof VIDEO_GENERATE_MODELS)[number], ClipPromptProfile | null>> = {\n \"bytedance/seedance-2.0\": SEEDANCE_PROFILE,\n \"bytedance/seedance-2.5\": SEEDANCE_PROFILE,\n \"google/gemini-omni-1.1-flash\": OMNI_PROFILE,\n \"google/gemini-omni-flash\": OMNI_PROFILE,\n \"google/veo-3.1\": VEO_PROFILE,\n \"google/veo-3.1-fast\": VEO_PROFILE,\n \"google/veo-3.1-lite\": VEO_PROFILE,\n \"kwaivgi/kling-v3.0-pro\": KLING_PROFILE,\n \"x-ai/grok-imagine-video\": null,\n \"x-ai/grok-imagine-video-1.5\": null,\n \"alibaba/wan-2.7\": null,\n \"alibaba/wan-3.0\": null,\n \"runway/gen-4.5\": null,\n \"alibaba/happyhorse-1.1\": null,\n};\n\n/** The profile for a video model id; undefined = unprofiled or unregistered model. */\nexport function clipProfileFor(modelId: string): ClipPromptProfile | undefined {\n return (CLIP_PROFILES as Readonly<Record<string, ClipPromptProfile | null>>)[modelId] ?? undefined;\n}\n\n/**\n * A clip's persuasion INTENT, derived by the scaffolder from the scene's role.\n * The recipe layer keys \"astonishing default\" param overrides off this so an\n * operator doesn't have to know each model's knobs.\n */\nexport type ClipIntent = \"hook\" | \"hero\" | \"cta\" | \"body\";\n\n/**\n * Opinionated per-intent param overrides, merged AFTER a clip's base params so\n * they can intentionally raise the quality dial for the beats that earn it.\n * Only emits params the backend actually forwards for the model — never an inert\n * knob. Currently: hero beats claim the photoreal resolution ceiling; hook beats\n * on Kling max out prompt adherence so the scripted scroll-stopper renders exactly.\n *\n * Takes the MODEL ID, not just the profile, because the two Omni versions share\n * one profile and disagree about exactly this: 1.1 declares a `resolution` enum\n * and the legacy preview has no such param, so a hero beat scaffolded onto the\n * preview would fail `baker canvas validate` as an unknown_param. Asking the\n * registry is also what keeps this honest for whatever the roster holds next —\n * a hardcoded family test was what got the previous version of this wrong.\n */\nexport function clipParamRecipe(\n model: string,\n profile: ClipPromptProfile,\n intent: ClipIntent,\n): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n // The hero/reveal beat is where cine quality matters most — pay for 1080p, on\n // every model that renders it.\n if (intent === \"hero\" && videoModelRenders(model, \"1080p\")) {\n out.resolution = \"1080p\";\n }\n if (intent === \"hook\" && profile.id === \"kling\") {\n out.cfg_scale = 0.85;\n }\n return out;\n}\n\n/** Whether the model's registry entry lists this resolution. */\nfunction videoModelRenders(model: string, resolution: string): boolean {\n const schema = MODEL_REGISTRY.video_generate[model]?.params.resolution;\n return schema?.kind === \"string\" && (schema.enum ?? []).includes(resolution);\n}\n\n/** The native line a scaffolded clip prompt asks the video model to speak, when present. */\nexport function nativeDialogueOf(prompt: unknown): string | undefined {\n if (typeof prompt !== \"string\") return undefined;\n const m = prompt.match(/Dialogue: \"(.*)\"/);\n return m?.[1]?.trim() || undefined;\n}\n\n/**\n * The job a picture in a static brief does, and so where it goes: the model reads the images\n * before the text and gives the first the most weight, so what must stay exact leads and a\n * layout reference, when there is one at all, trails.\n */\nexport type BriefImageRole = \"base\" | \"identity\" | \"product\" | \"prop\" | \"logo\" | \"type\" | \"layout\";\n\n/**\n * How a static ad brief is written for one family of image models (`static-brief.ts`\n * compiles every brief through these). Each rule names its source in the research notes\n * (`.context/prompting-*.md`, `.context/image-prompting-research-2026.md`); the bench\n * results that confirm or change them are added beside each rule as they land.\n */\nexport type ImageBriefRules = {\n /** Short labelled sections (gpt-image), or sentences that give the reason (Gemini). */\n structure: \"labelled_sections\" | \"flowing_sentences\";\n /** The most words one brief may take; the compiler trims the scene to fit and never the copy. */\n wordBudget: number;\n /** The order pictures are attached and numbered in (\"Image 1\", \"Image 2\", …), one role each. */\n referenceOrder: readonly BriefImageRole[];\n /** How the exact text is given. */\n text: {\n /** One numbered, quoted line per string, each asked for once, then an allow-list. */\n numberedQuotes: true;\n /** Symbols (®, ™, €) are quoted inline and also named in words. */\n nameSymbols: true;\n /** Accented letters are listed as letters to keep. */\n keepAccents: boolean;\n };\n /** How exclusions are phrased: one closing \"Avoid:\" list, or a positive closing sentence. */\n constraints: \"avoid_list_last\" | \"positive_last\";\n /**\n * The realism vocabulary for a photo: capture cues in plain words, never lens figures. A phone\n * capture (selfie, UGC) gets the unpolished cues; any other photo keeps its own light; people\n * in any photo get the real-person cues.\n */\n realism: {\n native: PhotoRealism;\n produced: PhotoRealism;\n /** How people in a photo look: real skin, lit faces, ordinary expressions. */\n people: string;\n };\n /** What a brief asks the request for, before the registry snaps it to the pinned model. */\n params: { n: number; quality?: string; imageSize?: string };\n};\n\n/** One kind of photo's realism cues. */\nexport type PhotoRealism = {\n /** The phrase that switches the model into photo mode. */\n photo: string;\n /** Texture and honesty cues, phrased as the profile phrases constraints. */\n texture: string;\n /** Why the photo looks the way it does, for a model that reasons from purpose (empty when it does not help). */\n purpose: string;\n};\n\n/**\n * An image model's frame-prompt + request-param profile. The motion-brief skeleton\n * is model-agnostic, but constraint PLACEMENT and the realism cue are not: OpenAI's\n * gpt-image weights early text as compositional guidance, so exclusions must come\n * LAST and \"photorealistic\" must be stated explicitly; Gemini reads exclusions fine\n * inline; Recraft renders vector art, so no photoreal cue. `brief` is how a static ad\n * brief is written for the family.\n */\nexport type ImageModelProfile = {\n id: \"gpt-image\" | \"gemini\" | \"recraft\";\n /** Where the clean-plate / no-text exclusions block sits in the prompt. */\n constraintPlacement: \"last\" | \"inline\";\n /** Emit an explicit \"photorealistic\" cue (photoreal models only). */\n photorealCue: boolean;\n /** Request params merged onto every `image_generate` node for this model. */\n paramDefaults: Record<string, unknown>;\n brief: ImageBriefRules;\n};\n\n// Identity and product first, a layout reference last or not at all: OpenAI staff, \"the\n// images come before the text prompt\" and only the first gets \"extra richness\"\n// (prompting-openai-gpt-image.md §0.7, §3); Google, \"Keep the person's facial features exactly\n// the same as Image 1\" (prompting-google-gemini-image.md §4). The edit base leads an edit\n// because a mask and the \"change only\" instruction apply to the first image (openai §4).\nconst REFERENCE_ORDER: readonly BriefImageRole[] = [\"base\", \"identity\", \"product\", \"prop\", \"logo\", \"type\", \"layout\"];\n\nconst GPT_IMAGE_BRIEF: ImageBriefRules = {\n // \"organize the prompt as scene, subject, details, and constraints, using labeled sections\";\n // \"written like a creative brief\" (openai §1, S1/S5 §4.6).\n structure: \"labelled_sections\",\n // Bench E1: this structure vs the pre-rebuild wrapper + blueprint JSON on 181 paired ads:\n // shippable 8.3% vs 4.4%, near-clone of the source 7% vs 17%, 0 lint contradictions vs 11 codes on\n // every legacy prompt, 15% cheaper (BENCH.md#E1; pairwise pending).\n // Official examples run 40-150 words; the synthesis caps briefs at 150-400\n // (image-prompting-research-2026.md §6, openai §1). Ours carried 1,615 (prompt-audit.md §1).\n wordBudget: 400,\n referenceOrder: REFERENCE_ORDER,\n // Quote each line, say how many times it appears, allow-list it, spell symbols out, keep\n // accents: openai §2 (\"Render the tagline exactly once\", \"Include ONLY this card text\").\n text: { numberedQuotes: true, nameSymbols: true, keepAccents: true },\n // Official prompts close on a Constraints block or a \"No…\" sentence (openai §7).\n constraints: \"avoid_list_last\",\n realism: {\n // \"include the word 'photorealistic' directly in the prompt\" (openai §5, S5).\n // \"real texture (pores, wrinkles, fabric wear, imperfections)\"; camera specs are \"cues,\n // not a guarantee\" (openai §5), so capture is described in words, never figures.\n native: {\n photo: \"photorealistic: a real, unedited phone photo\",\n texture: \"real texture and wear on every surface, natural light, light sensor noise, unposed and unretouched\",\n purpose: \"\",\n },\n // Brief v2: a studio or hero shot keeps its own light; the phone cues made them candid and busy\n // (BENCH.md § E1, the judge's remaining reasons), and the user found the old prompt's more polished.\n produced: {\n photo: \"photorealistic: a real photograph\",\n texture: \"real textures, true-to-life light and colour\",\n purpose: \"\",\n },\n // The user: people look \"too AI\", faces too dark; wants natural, real-looking people (BENCH.md § \"E1 v2\"),\n // and again on the final sets, \"more natural please\" (§ \"Fix round\"); and real people's photos are\n // taken on a phone, not a professional camera (AV2, scripts/creative-evals/avatar-realism.mjs).\n people: \"candid people shot on a phone: real skin, natural light, relaxed expressions\",\n },\n // n 1: the variants are one call per direction, not one n=3 call. Same cost (n is billed per\n // image, E0) and returns 3/3 either way, but one n=3 call gave >=2 distinct options in 25% of\n // ads vs 39% for three calls (n=99/100; n=2 + 1 call: 31% vs 36% on 39 shared ads)\n // (.context/static-review/BENCH.md#E3).\n // quality max: the deterministic checks tie (shippable 9-12% on every step, n=100), but on the\n // E4 gallery (30 rated pairs) the user's win rate is max 69%, xhigh 54%, high 47%, Flare 34%,\n // and the judge's on the same pairs 73%, 65%, 39%, 31%. Max costs $0.166 per image vs $0.085\n // for xhigh and 80 s vs 44 s (BENCH.md#E4, § \"E1 v2\"); a round renders twice in a row (the\n // options, then each size), so three ads took most of an hour. Oct 2026 the user chose xhigh.\n params: { n: 1, quality: \"xhigh\", imageSize: \"2K\" },\n};\n\nconst GEMINI_IMAGE_BRIEF: ImageBriefRules = {\n // \"Use Natural Language & Full Sentences… as if you were briefing a human artist\", and\n // give the why (prompting-google-gemini-image.md §2). Bench E1 on Gemini 3 Pro Image, 182 paired\n // ads: shippable 6.0% vs 7.1% for the legacy prompt (within the -2pp gate), near-clone 6% vs 15%\n // (BENCH.md#E1; pairwise pending).\n structure: \"flowing_sentences\",\n // Google gives no limit; the synthesis budget holds (research §6).\n wordBudget: 400,\n referenceOrder: REFERENCE_ORDER,\n // Quote each string and name the font per line (gemini §3, Cloud guide per-line pattern).\n text: { numberedQuotes: true, nameSymbols: true, keepAccents: true },\n // \"Use positive framing … 'empty street' instead of 'no cars'\" (gemini §2).\n constraints: \"positive_last\",\n realism: {\n // Capture-device language, never \"hyperrealistic\"/\"8k\" tag soup (gemini §6).\n native: {\n photo: \"a candid photo taken on a phone\",\n texture: \"real texture and wear on every surface, natural light, a little sensor grain, unposed and unretouched\",\n // Pro reasons from purpose: say why it is lo-fi (gemini §2, §6).\n purpose: \"because a polished picture reads as an ad and this one has to read as a real post\",\n },\n produced: { photo: \"a real photograph\", texture: \"real textures and true-to-life light and colour\", purpose: \"\" },\n people:\n \"the people look real and candid, shot on a phone, with natural skin, natural light and relaxed expressions\",\n },\n // No `n` on Gemini image (gemini §0.4); Pro 2K costs the same as 1K and small text blurs\n // at 1K (gemini §0.3).\n params: { n: 1, imageSize: \"2K\" },\n};\n\n// Recraft: \"Quote all text and define the typographic system\", poster order format →\n// background → typography (research §1, Recraft V4). Vector art, so no photo vocabulary.\nconst RECRAFT_BRIEF: ImageBriefRules = {\n structure: \"labelled_sections\",\n wordBudget: 400,\n referenceOrder: REFERENCE_ORDER,\n text: { numberedQuotes: true, nameSymbols: true, keepAccents: true },\n constraints: \"positive_last\",\n realism: {\n native: { photo: \"a flat vector illustration\", texture: \"clean shapes and even fills\", purpose: \"\" },\n produced: { photo: \"a flat vector illustration\", texture: \"clean shapes and even fills\", purpose: \"\" },\n people: \"\",\n },\n params: { n: 1 },\n};\n\nexport const GPT_IMAGE_PROFILE: ImageModelProfile = {\n id: \"gpt-image\",\n constraintPlacement: \"last\",\n photorealCue: true,\n // OpenRouter forwards `quality`; gpt-image already processes inputs at high fidelity\n // automatically, so we deliberately do NOT send `input_fidelity`.\n //\n // No `quality` here any more: it is the one default that depends on WHICH gpt-image is\n // pinned. 2.5 added `xhigh` and `max` above `high`, and the older entries would refuse\n // them at validate — so callers ask for the step they want through\n // `bestSupportedQuality` and get the best the chosen model actually has.\n paramDefaults: {},\n // gpt-image-2 has no `xhigh` (openai §0.2): the brief asks for `high`, its top step.\n brief: { ...GPT_IMAGE_BRIEF, params: { n: 1, quality: \"high\" } },\n};\n\n/** gpt-image-2.5 (Sunburst, and Flare once registered): same prompt rules, the 2.5 quality ladder. */\nexport const GPT_IMAGE_25_PROFILE: ImageModelProfile = {\n ...GPT_IMAGE_PROFILE,\n brief: GPT_IMAGE_BRIEF,\n};\n\nexport const GEMINI_IMAGE_PROFILE: ImageModelProfile = {\n id: \"gemini\",\n constraintPlacement: \"inline\",\n photorealCue: true,\n // NO `quality`. OpenRouter accepts the field on a Gemini image call and returns\n // 200 — but its per-endpoint schema does not list it and the cost is identical\n // with and without, so Google drops it: an inert knob. Worse, the registry\n // (correctly) does not declare it for Gemini, so emitting it fails `baker canvas\n // validate` with `unknown_param` before the call is ever made.\n paramDefaults: {},\n brief: GEMINI_IMAGE_BRIEF,\n};\n\nexport const RECRAFT_IMAGE_PROFILE: ImageModelProfile = {\n id: \"recraft\",\n constraintPlacement: \"inline\",\n photorealCue: false,\n paramDefaults: {},\n brief: RECRAFT_BRIEF,\n};\n\n/** The prompt profile of every curated image model, by exact registry id. */\nexport const IMAGE_PROFILES: Readonly<Record<(typeof IMAGE_GENERATE_MODELS)[number], ImageModelProfile | null>> = {\n \"openai/gpt-image-2.5-sunburst\": GPT_IMAGE_25_PROFILE,\n \"openai/gpt-image-2\": GPT_IMAGE_PROFILE,\n \"google/gemini-3.1-flash-image\": GEMINI_IMAGE_PROFILE,\n \"google/gemini-3.1-flash-lite-image\": GEMINI_IMAGE_PROFILE,\n \"google/gemini-3-pro-image\": GEMINI_IMAGE_PROFILE,\n \"recraft/recraft-v4.1-pro-vector\": RECRAFT_IMAGE_PROFILE,\n};\n\n/** The profile for an image model id (a superseded id gets its successor's); undefined = unprofiled or unregistered model. */\nexport function imageProfileFor(modelId: string): ImageModelProfile | undefined {\n return (IMAGE_PROFILES as Readonly<Record<string, ImageModelProfile | null>>)[canonicalModelId(modelId)] ?? undefined;\n}\n","import { bestSupportedQuality, nearestSupportedImageSize, supportsParam } from \"@baker/canvas-contract\";\nimport { imageProfileFor } from \"../../lib/prompt-profiles.ts\";\n\n/**\n * What every scaffolded `image_generate` render asks its model for besides the prompt and\n * the shape: a size tier and a quality step, each snapped to what the model accepts, plus\n * the model's profile defaults.\n *\n * Snapped rather than pinned, because one scaffold writes one canvas for whichever model is\n * chosen: gpt-image has no size knob at all (asking for one is `unknown_param`), Nano Banana\n * 2 Lite renders 1K only, and the older gpt-image entries stop at `high`.\n */\nexport function imageRenderParams(model: string, want: { size: string; quality: string }): Record<string, unknown> {\n const quality = bestSupportedQuality(\"image_generate\", model, want.quality);\n return {\n ...(supportsParam(\"image_generate\", model, \"image_size\")\n ? { image_size: nearestSupportedImageSize(\"image_generate\", model, want.size) }\n : {}),\n ...(imageProfileFor(model)?.paramDefaults ?? {}),\n ...(quality ? { quality } : {}),\n };\n}\n","/**\n * The render graph of a static ad, and the roles every reader finds its nodes by.\n *\n * gen_1..3 (image_generate, one call per variant, each on its own direction) role static_variant_call\n * → gen (collect: the variants as one list; a single variant is gen itself) role static_variants\n * → prefilter (static_prefilter: ranks the variants by the checks and passes the first as\n * `image`; it asks the judge only on a real tie) role variant_prefilter\n * → master (imagemagick: the chosen picture at the master's delivered pixels) role static_master\n * → plate (photo-led ads, ADR 0014): each variant is plate_<i> (a picture without the designed\n * words) and its lead's words lead_<i> (static_format, role static_lead); every size is\n * format_<size> (static_format: the chosen picture cut for it, its words set) role static_format\n * → relayout (designed and interface ads, `staticShapeFor`): adapt_<size> (image_generate: the\n * chosen ad re-laid out for that frame) role static_adapt_format → size_<size> (imagemagick:\n * filled to its pixels) role static_size\n * → the cut shapes (bench): a band-anchored cut of the master, or an adapt of it\n * (image_aspect_adapt, landscape) role static_size / static_adapt\n * → safe_<size> (static_safe_fit, every 9:16 Reels or Stories covers: the words and logo\n * brought inside the band by a small shrink and shift, free) role static_safe_fit\n * → optional logo composite per size role logo_composite\n * → final (collect, one label per format)\n *\n * Readers (the run review, `--fix`, the render budget, the lint, `--regenerate`, the\n * dashboard) go by `tags.role`, never by node id: tags never enter the cache key, and ids\n * change with the topology. `scaffoldStaticAd` and `upgradeStaticCanvas` both build the\n * graph here, so a new creative and an upgraded one are the same graph.\n *\n * Pure.\n */\nimport { bestSupportedQuality, nearestSupportedImageSize, supportsParam } from \"@baker/canvas-contract\";\nimport type { NodeDecl } from \"../schema/canvas.ts\";\nimport { imageRenderParams } from \"./lib/image-params.ts\";\nimport { type SafeArea, staticSafeArea } from \"./platform-safe-area.ts\";\nimport { adaptPlan, fillArgs, STATIC_ADAPT_FORMAT_ROLE, safeAreaOnFrame } from \"./static-adapt.ts\";\nimport {\n ASPECT_ADAPT_FORMATS,\n deliveredSize,\n type Size,\n type SizePlan,\n type StaticFormatPlan,\n} from \"./static-sizes.ts\";\n\n/** The node whose `images` are the variants of a version (the dashboard's options). */\nexport const STATIC_VARIANTS_ROLE = \"static_variants\";\n/** One call of a variants node fanned out, for a model that returns one picture per call (`tags.region` = variant). */\nexport const STATIC_VARIANT_CALL_ROLE = \"static_variant_call\";\n/** Drops variants that fail the deterministic checks before the judge sees them. */\nexport const VARIANT_PREFILTER_ROLE = \"variant_prefilter\";\n/**\n * The judge node of an older graph; its image output was the variant the sizes were made from.\n * The current graph has none: the prefilter passes the chosen picture as `image` and asks the\n * judge only on a tie. Still read on older run records, and carried by a person's own choice.\n */\nexport const STATIC_PICK_ROLE = \"pick\";\n/** The chosen picture at the master's delivered pixels: what `--fix` edits and every size is made from. */\nexport const STATIC_MASTER_ROLE = \"static_master\";\n/** One delivered size cut (or resized) from the master or its adapt. */\nexport const STATIC_SIZE_ROLE = \"static_size\";\nexport { STATIC_ADAPT_FORMAT_ROLE };\n/** The reframe of the master into the shapes a cut cannot reach. */\nexport const STATIC_ADAPT_ROLE = \"static_adapt\";\n/** A 9:16 shrunk and shifted (free) so its words and logo sit inside the band Reels or Stories leave clear. */\nexport const STATIC_SAFE_FIT_ROLE = \"static_safe_fit\";\n/** An autofix round's placing of one size inside its band, for its margins to be painted (`static_place`). */\nexport const STATIC_PLACE_ROLE = \"static_place\";\n/** The brand's logo file composited onto one size. */\nexport const LOGO_COMPOSITE_ROLE = \"logo_composite\";\n/** The ingest of a picture of the lead ad a series ad is made from (`seriesMemberAd`): `lead_ad`, `lead_ad_9x16`. */\nexport const SERIES_LEAD_ROLE = \"series_lead\";\n/** The correction render `--fix` puts in place of the variants. */\nexport const STATIC_FIX_ROLE = \"static_fix\";\n/**\n * Master shape `plate`: one variant's lead size, its words set on that variant's picture\n * (`static_format`, `tags.region` = variant). The variants the dashboard shows are these.\n */\nexport const STATIC_LEAD_ROLE = \"static_lead\";\n/** Master shape `plate`: one delivered size cut from the chosen picture, its words set for it (`static_format`). */\nexport const STATIC_FORMAT_ROLE = \"static_format\";\n/**\n * Master shape `plate`: a picture made from one that exists (`static_plate`): the chosen one\n * extended sideways for the wide sizes (`plate_wide`), or an approved ad's with its words painted out.\n */\nexport const STATIC_PLATE_ROLE = \"static_plate\";\n\n/**\n * Composite the logo file instead of having the model draw it: off. The model draws it from the\n * file, beside the reference, so the ad is designed around it (bench E6: a drawn logo looked\n * natural in 61% of sizes, a pasted one in 8%). Turned on in Oct 2026 after one redrawn wordmark\n * (Red Points' \"POIПTS\"), the pasted logo left every ad with a stamped corner the picture was never\n * drawn around; the review still holds a drawn logo to its file (`deliveredLogoFindings`).\n * Tried and reverted three times (docs/marketing-intelligence.md § \"Tried and failed\"): do not flip\n * it without beating the drawn ad on production work.\n */\nexport const LOGO_COMPOSITE_DEFAULT = false;\n\n/** The reframe tier: 2K is the same price as 1K on Nano Banana Pro. */\nconst ADAPT_IMAGE_SIZE = \"2K\";\n\ntype Node = {\n id?: unknown;\n type?: unknown;\n params?: Record<string, unknown>;\n inputs?: Record<string, unknown>;\n tags?: { role?: unknown; region?: unknown };\n};\n\nfunction nodesOf(canvas: unknown): Node[] {\n const nodes = (canvas as { nodes?: unknown } | null)?.nodes;\n return Array.isArray(nodes) ? (nodes as Node[]) : [];\n}\n\n/** Whether a static canvas is on the `plate` master shape: its sizes are `static_format` nodes. */\nexport function isPlateCanvas(canvas: unknown): boolean {\n return nodesOf(canvas).some((n) => n.type === \"static_format\");\n}\n\n/** The nodes of a canvas carrying `role`, in canvas order. */\nexport function nodesWithRole(canvas: unknown, role: string): Array<{ id: string; type: string } & Node> {\n return nodesOf(canvas).filter(\n (n): n is { id: string; type: string } & Node =>\n n?.tags?.role === role && typeof n.id === \"string\" && typeof n.type === \"string\",\n );\n}\n\n/** Each node id of a canvas with its role, for readers that only hold outputs keyed by id. */\nexport function rolesById(canvas: unknown): Record<string, string> {\n const out: Record<string, string> = {};\n for (const n of nodesOf(canvas)) {\n if (typeof n?.id === \"string\" && typeof n.tags?.role === \"string\") out[n.id] = n.tags.role;\n }\n return out;\n}\n\n/**\n * A version made by a round that only placed its sizes again delivers each size from the last\n * version's file (`last_<size>`, `withDeliveredSizes`): the one of the size the chosen picture is\n * delivered as is that picture. Empty for a canvas that delivers no size from its master. Pure.\n */\nexport function relaidPictureRole(canvas: unknown): Record<string, string> {\n const roles = rolesById(canvas);\n const final = nodesOf(canvas).find((n) => n.id === \"final\" && n.type === \"collect\");\n const labels = final?.params?.labels;\n const images = final?.inputs?.images;\n if (!Array.isArray(labels) || !Array.isArray(images)) return {};\n const nodes = nodesOf(canvas);\n const idOf = (ref: unknown) => (typeof ref === \"string\" ? /^\\$ref:([^.]+)\\./.exec(ref)?.[1] : undefined);\n const at = images.findIndex((ref) => {\n const from = idOf(ref);\n // The logo file placed on a size reads the size under it.\n const under =\n from !== undefined && roles[from] === LOGO_COMPOSITE_ROLE\n ? idOf(nodes.find((n) => n.id === from)?.inputs?.image)\n : from;\n return under !== undefined && roles[under] === STATIC_MASTER_ROLE;\n });\n const format = labels[at];\n return typeof format === \"string\" ? { [`last_${formatSlug(format)}`]: STATIC_MASTER_ROLE } : {};\n}\n\n/** A format as a node-id fragment: `4:5` → `4x5`, `1.91:1` → `1_91x1`. */\nexport function formatSlug(format: string): string {\n return format.replace(\":\", \"x\").replace(\".\", \"_\");\n}\n\nconst EXTENT = /^(\\d+)x(\\d+)$/;\n\n/** The master's delivered format, read off the master node's pixels; null when the canvas has none. */\nexport function staticMasterFormat(canvas: unknown): string | null {\n const master = nodesWithRole(canvas, STATIC_MASTER_ROLE)[0];\n const args = master?.params?.args;\n if (!Array.isArray(args)) return null;\n const at = args.indexOf(\"-extent\");\n const match = typeof args[at + 1] === \"string\" ? (args[at + 1] as string).match(EXTENT) : null;\n if (at < 0 || !match) return null;\n return formatOfSize({ width: Number(match[1]), height: Number(match[2]) });\n}\n\n/** Every format a canvas plans, so one whose ratio is not in lowest terms (21:9) reads back as itself. */\nconst KNOWN_FORMATS = [\"9:16\", \"4:5\", \"1:1\", \"16:9\", \"1.91:1\", ...ASPECT_ADAPT_FORMATS];\n\nfunction formatOfSize(size: Size): string {\n for (const format of KNOWN_FORMATS) {\n const d = deliveredSize(format);\n if (d.width === size.width && d.height === size.height) return format;\n }\n const gcd = (a: number, b: number): number => (b === 0 ? a : gcd(b, a % b));\n const g = gcd(size.width, size.height);\n return `${size.width / g}:${size.height / g}`;\n}\n\n/** A format's safe area as the reframe node takes it (fractions only). */\n/**\n * The safe area the reframe keeps on one of its formats: its own, widened by the strip the fill\n * to each size cut from it trims (a 1.91:1 filled from the 16:9 loses its top and bottom), so a\n * line at the edge still clears each delivered size's margin.\n */\nfunction safeAreaOf(adaptFormat: string, delivered: readonly string[]): SafeArea {\n const { top, bottom, left, right } = staticSafeArea(adaptFormat);\n return delivered\n .map((f) => safeAreaOnFrame(adaptFormat, f))\n .reduce(\n (a, b) => ({\n top: Math.max(a.top, b.top),\n bottom: Math.max(a.bottom, b.bottom),\n left: Math.max(a.left, b.left),\n right: Math.max(a.right, b.right),\n }),\n { top, bottom, left, right },\n );\n}\n\nfunction magick(id: string, role: string, image: string, args: string[], extra: Record<string, string> = {}): NodeDecl {\n return {\n id,\n type: \"imagemagick\",\n inputs: { image, ...extra },\n params: { args, outputs: { image: { kind: \"image\", ext: \"png\" } } },\n tags: { role },\n };\n}\n\n/**\n * The brand's logo as every size places it (`static_logo`): its files (`files[0]` the one the brand\n * names, then the same artwork in its other colours, refs to their ingests) and its shape\n * (width over height, measured off the file), which sizes the slot each size keeps empty for it.\n */\nexport type CompositeLogo = { files: string[]; aspect: number };\n\nexport type StaticRenderGraph = {\n /** The generation model and its request params (quality, size), without prompt, shape or `n`. */\n genModel: string;\n genParams: Record<string, unknown>;\n /** Variants rendered: 1-3. */\n takes: number;\n /** The pictures each render is given (element slots, the logo when the model draws it, the type specimen). */\n reference: string[];\n /** The ad spec the prefilter checks the variants against (`$ref:prompt.asset`). */\n specRef: string;\n judgeModel: string;\n /** The reframe model: adapts a size a cut cannot reach (the cut shapes). */\n adaptModel: string;\n /** The model that re-lays out each other size from the chosen ad (`relayout`). */\n relayoutModel: string;\n /** The brand's logo file when the model draws it: each re-laid-out size gets it too. */\n logoRef?: string;\n plan: StaticFormatPlan;\n /** The logo file, composited on every size (never also given to the model). */\n compositeLogo?: CompositeLogo;\n /** The placeholder every compiled prompt starts as (the brief projection writes the real one). */\n prompt: string;\n};\n\n/**\n * The variants: one call per variant, gathered into one list; never one call with `n`, even\n * on a model that takes it. Bench E3 (.context/static-review/BENCH.md#E3): same price and wall\n * time, and 1.5x the distinct options, because each call keeps its own direction of the brief.\n */\nfunction variantNodes(g: StaticRenderGraph): NodeDecl[] {\n const render = (id: string, extra: Record<string, unknown>, tags: NodeDecl[\"tags\"]): NodeDecl => ({\n id,\n type: \"image_generate\",\n ...(g.reference.length > 0 ? { inputs: { reference: [...g.reference] } } : {}),\n params: { model: g.genModel, aspect_ratio: g.plan.master.renderRatio, ...g.genParams, ...extra, prompt: g.prompt },\n tags,\n });\n if (g.takes === 1) return [render(\"gen\", {}, { role: STATIC_VARIANTS_ROLE })];\n // The calls run in parallel and cost what one n-call would (n is billed per picture); each\n // keeps its own cache key, so a failed variant re-runs alone.\n const calls = Array.from({ length: g.takes }, (_, i) =>\n render(`gen_${i + 1}`, {}, { role: STATIC_VARIANT_CALL_ROLE, region: i }),\n );\n return [\n ...calls,\n {\n id: \"gen\",\n type: \"collect\",\n inputs: { images: calls.map((c) => `$ref:${c.id}.images#0`) },\n tags: { role: STATIC_VARIANTS_ROLE },\n },\n ];\n}\n\n/** The prefilter's params, as planned: the formats, the shape, the placements, the lead, the platforms and the judge. */\nfunction prefilterParams(g: StaticRenderGraph): Record<string, unknown> {\n const { plan } = g;\n return {\n formats: plan.sizes.map((s) => s.format),\n master_shape: plan.masterShape,\n ...(plan.placements ? { placements: [...plan.placements] } : {}),\n // The size its platform designs first: re-planned from these params, the master stays it.\n ...(plan.lead ? { lead: plan.lead } : {}),\n // Where it runs, as planned: a definition naming other platforms re-plans the sizes (`static-replan.ts`).\n ...(plan.platforms ? { platforms: [...plan.platforms] } : {}),\n // The judge breaks a real tie only; one variant never asks it.\n ...(g.takes > 1 ? { judge_model: g.judgeModel, judge_prompt: g.prompt } : {}),\n };\n}\n\n/**\n * Everything from the variants to the delivered sizes: the static ad's render graph, ending\n * in the `final` collect labelled by format (in `plan.sizes` order).\n */\nexport function staticRenderNodes(g: StaticRenderGraph): NodeDecl[] {\n const { plan } = g;\n if (plan.masterShape === \"plate\") return plateRenderNodes(g);\n const nodes: NodeDecl[] = [\n ...variantNodes(g),\n {\n id: \"prefilter\",\n type: \"static_prefilter\",\n inputs: { images: \"$ref:gen.images\", spec: g.specRef },\n params: prefilterParams(g),\n tags: { role: VARIANT_PREFILTER_ROLE },\n },\n magick(\"master\", STATIC_MASTER_ROLE, \"$ref:prefilter.image\", fillArgs(plan.master.size)),\n ];\n const adapted = plan.sizes.filter((s) => s.from === \"adapt\");\n const adaptFormats = [...new Set(adapted.map((s) => s.adaptFormat ?? s.format))];\n if (adaptFormats.length > 0) {\n nodes.push({\n id: \"adapt\",\n type: \"image_aspect_adapt\",\n inputs: { source: \"$ref:master.image\" },\n params: {\n model: g.adaptModel,\n formats: adaptFormats,\n image_size: ADAPT_IMAGE_SIZE,\n safe_areas: Object.fromEntries(\n adaptFormats.map((f) => [\n f,\n safeAreaOf(\n f,\n adapted.filter((s) => (s.adaptFormat ?? s.format) === f).map((s) => s.format),\n ),\n ]),\n ),\n },\n tags: { role: STATIC_ADAPT_ROLE },\n });\n }\n nodes.push(...relayoutNodes(g));\n const refs = plan.sizes.map((s) => {\n const made = sizeNodes(s, plan, adaptFormats);\n nodes.push(...made);\n const last = made[made.length - 1];\n return withLogo(nodes, s, last ? `$ref:${last.id}.image` : \"$ref:master.image\", g.compositeLogo, plan.placements);\n });\n nodes.push({\n id: \"final\",\n type: \"collect\",\n inputs: { images: refs },\n params: { labels: plan.sizes.map((s) => s.format) },\n });\n return nodes;\n}\n\n/**\n * `ref`, or the brand's logo file placed on it (`static_logo`, pushed onto `nodes`): what the size\n * delivers. `slot` is the slot the size's words left empty (a `static_format`'s `logo_slot`); with\n * none, the composite plans it from the size, as the size's brief reserved it.\n */\nfunction withLogo(\n nodes: NodeDecl[],\n s: SizePlan,\n ref: string,\n logo: CompositeLogo | undefined,\n placements: readonly string[] | undefined,\n slot?: string,\n): string {\n if (!logo) return ref;\n const slug = formatSlug(s.format);\n nodes.push({\n id: `logo_${slug}`,\n type: \"static_logo\",\n inputs: { image: ref, logos: [...logo.files], ...(slot ? { slot } : {}) },\n params: { format: s.format, aspect: logo.aspect, ...(placements ? { placements: [...placements] } : {}) },\n tags: { role: LOGO_COMPOSITE_ROLE },\n });\n return `$ref:logo_${slug}.image`;\n}\n\n/**\n * A static canvas moved onto its logo file placed on every size (`static_logo`), from one whose\n * model drew it (or whose older composite pasted it): the file leaves every model's references,\n * every words call on one picture keeps a slot empty for it (`logo_slot`), and each delivered size\n * gets its composite last, in the slot its words left empty. A composite already there keeps its\n * id, position and copy and is handed the files and shape given. Pure.\n */\nexport function placeLogoFromFile<C extends { nodes?: unknown }>(\n input: C,\n logo: CompositeLogo,\n): { canvas: C & { nodes: NodeDecl[] }; changed: boolean } {\n const before = (Array.isArray(input.nodes) ? input.nodes : []) as NodeDecl[];\n const nodes: NodeDecl[] = structuredClone(before);\n const unchanged = { canvas: { ...input, nodes: before }, changed: false };\n const final = nodes.find((n) => n.id === \"final\" && n.type === \"collect\");\n const labels = final?.params?.labels;\n const images = final?.inputs?.images;\n if (!final || !Array.isArray(labels) || !Array.isArray(images)) return unchanged;\n const files = new Set(logo.files);\n const raw = nodes.find((n) => n.tags?.role === VARIANT_PREFILTER_ROLE)?.params?.placements;\n const placements = Array.isArray(raw) && raw.every((p) => typeof p === \"string\") ? (raw as string[]) : undefined;\n for (const n of nodes) unwireDrawnLogo(n, files, logo.aspect);\n const delivered = images.map((ref, i) => {\n const format = labels[i];\n if (typeof format !== \"string\" || typeof ref !== \"string\") return ref;\n const composite = compositeFor(nodes, ref, format, logo, placements);\n const existing = nodes.find((n) => n.id === composite.id);\n if (existing) nodes.splice(nodes.indexOf(existing), 1, composite);\n else nodes.splice(nodes.indexOf(final), 0, composite);\n return `$ref:${composite.id}.image`;\n });\n final.inputs = { ...final.inputs, images: delivered };\n const changed = JSON.stringify(nodes) !== JSON.stringify(before);\n return changed ? { canvas: { ...input, nodes }, changed } : unchanged;\n}\n\n/** One node as the logo is placed from its file: no model handed the file, every words call keeping its slot. In place. */\nfunction unwireDrawnLogo(n: NodeDecl, files: ReadonlySet<string>, aspect: number): void {\n const reference = n.inputs?.reference;\n if (n.type === \"image_generate\" && Array.isArray(reference)) {\n const kept = reference.filter((r) => !files.has(String(r)));\n const { reference: _gone, ...rest } = n.inputs ?? {};\n if (kept.length > 0) n.inputs = { ...rest, reference: kept };\n else if (Object.keys(rest).length > 0) n.inputs = rest;\n else delete n.inputs;\n }\n if (n.type !== \"static_format\") return;\n const held = (n.params?.logo_slot ?? {}) as Record<string, unknown>;\n n.params = { ...n.params, logo_slot: { ...held, aspect } };\n if (typeof n.inputs?.logo === \"string\" && files.has(n.inputs.logo)) {\n const { logo: _drawn, ...rest } = n.inputs;\n n.inputs = rest;\n }\n}\n\n/**\n * The composite that places the logo on the size the final reads at `ref`: the one already there\n * (its id, position and copy kept, an older paste made a `static_logo`), else a new `logo_<size>`\n * reading `ref`; on one picture, in the slot that size's words left empty.\n */\nfunction compositeFor(\n nodes: readonly NodeDecl[],\n ref: string,\n format: string,\n logo: CompositeLogo,\n placements: readonly string[] | undefined,\n): NodeDecl {\n const reads = nodes.find((n) => n.id === /^\\$ref:([^.]+)\\./.exec(ref)?.[1]);\n const existing = reads?.tags?.role === LOGO_COMPOSITE_ROLE ? reads : undefined;\n const slug = formatSlug(format);\n const slot = nodes.some((n) => n.id === `format_${slug}` && n.type === \"static_format\")\n ? { slot: `$ref:format_${slug}.logo_slot` }\n : {};\n const kept = existing?.type === \"static_logo\" ? (existing.params ?? {}) : {};\n return {\n id: existing?.id ?? `logo_${slug}`,\n type: \"static_logo\",\n inputs: { image: existing ? existing.inputs?.image : ref, logos: [...logo.files], ...slot },\n params: { ...kept, format, aspect: logo.aspect, ...(placements ? { placements: [...placements] } : {}) },\n tags: { role: LOGO_COMPOSITE_ROLE },\n };\n}\n\n/** The quality every size's words call asks for (and the wide picture's painting): xhigh, as the re-layouts, snapped to the model's. */\nfunction wordsQuality(model: string): { quality?: string } {\n const quality = bestSupportedQuality(\"image_generate\", model, \"xhigh\");\n return quality ? { quality } : {};\n}\n\n/** The size a picture every size is cut from is asked at: the largest a model draws, so a cut is enlarged least. */\nconst PLATE_IMAGE_SIZE = \"4K\";\n\n/**\n * The model's largest picture, where it takes a size (`image_size`). None for a model that sizes its\n * picture from the ratio alone (GPT Image): there a 4:5 cut from a 9:16 stays a 1.25 times enlargement.\n */\nfunction largestPicture(model: string): { image_size?: string } {\n return supportsParam(\"image_generate\", model, \"image_size\")\n ? { image_size: nearestSupportedImageSize(\"image_generate\", model, PLATE_IMAGE_SIZE) }\n : {};\n}\n\n/**\n * Master shape `plate`: a picture per variant (`plate_<i>`, no designed words), the lead's words\n * set on each (`lead_<i>`, the options the dashboard shows), the prefilter choosing among those\n * and passing on the chosen one's picture (`plate`), the master its lead size as it is, the\n * chosen picture extended sideways when wide sizes sit beside tall ones (`plate_wide`), and one\n * `format_<size>` per other size: cut from the picture, its words set in the lead's style. The\n * briefs, the words, the logo, the type and the references are projected from prompt.json on\n * every run (`projectFormatBriefs`).\n */\nfunction plateRenderNodes(g: StaticRenderGraph): NodeDecl[] {\n const { plan } = g;\n const lead = plan.master.format;\n const placements = plan.placements ? { placements: [...plan.placements] } : {};\n const quality = wordsQuality(g.relayoutModel);\n const words = { model: g.relayoutModel, ...quality, prompt: g.prompt };\n const core = plan.plate ? { core: plan.plate.zones.subjectCore } : {};\n // A logo placed from its file afterwards: every words call keeps its slot empty and draws none.\n const slot = g.compositeLogo ? { logo_slot: { aspect: g.compositeLogo.aspect } } : {};\n // Every tall size is checked on each picture before its lead's words are paid for.\n const tall = plan.sizes.filter((s) => s.plate !== \"wide\" && s.format !== lead).map((s) => s.format);\n const plates: NodeDecl[] = Array.from({ length: Math.max(1, g.takes) }, (_, i) => ({\n id: `plate_${i + 1}`,\n type: \"image_generate\",\n ...(g.reference.length > 0 ? { inputs: { reference: [...g.reference] } } : {}),\n params: {\n model: g.genModel,\n aspect_ratio: plan.master.renderRatio,\n ...g.genParams,\n ...largestPicture(g.genModel),\n prompt: g.prompt,\n },\n tags: { role: STATIC_VARIANT_CALL_ROLE, region: i },\n }));\n const leads: NodeDecl[] = plates.map((p, i) => ({\n id: `lead_${i + 1}`,\n type: \"static_format\",\n inputs: { plate: `$ref:${p.id}.images#0` },\n params: {\n format: lead,\n lead: true,\n ...placements,\n words,\n ...core,\n ...slot,\n ...(tall.length > 0 ? { check_formats: tall } : {}),\n },\n tags: { role: STATIC_LEAD_ROLE, region: i },\n }));\n const nodes: NodeDecl[] = [\n ...plates,\n ...leads,\n {\n id: \"gen\",\n type: \"collect\",\n inputs: { images: leads.map((l) => `$ref:${l.id}.image`) },\n tags: { role: STATIC_VARIANTS_ROLE },\n },\n {\n id: \"prefilter\",\n type: \"static_prefilter\",\n inputs: {\n images: \"$ref:gen.images\",\n plates: plates.map((p) => `$ref:${p.id}.images#0`),\n facts: leads.map((l) => `$ref:${l.id}.facts`),\n spec: g.specRef,\n },\n params: prefilterParams(g),\n tags: { role: VARIANT_PREFILTER_ROLE },\n },\n // The lead set again on the chosen picture: the same call as its variant's (replayed from the\n // step cache, free), and the size a change of its words edits without choosing again.\n {\n id: `format_${formatSlug(lead)}`,\n type: \"static_format\",\n inputs: { plate: \"$ref:prefilter.plate\" },\n params: { format: lead, lead: true, ...placements, words, ...core, ...slot },\n tags: { role: STATIC_FORMAT_ROLE },\n },\n magick(\"master\", STATIC_MASTER_ROLE, `$ref:format_${formatSlug(lead)}.image`, fillArgs(plan.master.size)),\n ];\n if (plan.plate?.wide) {\n nodes.push({\n id: \"plate_wide\",\n type: \"static_plate\",\n inputs: { image: \"$ref:prefilter.plate\" },\n params: {\n mode: \"widen\",\n aspect_ratio: plan.plate.wide,\n paint: { model: g.relayoutModel, ...quality },\n },\n tags: { role: STATIC_PLATE_ROLE },\n });\n }\n const refs = plan.sizes.map((s) => {\n const slug = formatSlug(s.format);\n if (s.format === lead)\n return withLogo(nodes, s, \"$ref:master.image\", g.compositeLogo, plan.placements, `$ref:format_${slug}.logo_slot`);\n const wide = s.plate === \"wide\";\n const id = `format_${slug}`;\n nodes.push({\n id,\n type: \"static_format\",\n inputs: wide\n ? { plate: \"$ref:plate_wide.image\", subjects: \"$ref:plate_wide.subjects\", style: \"$ref:master.image\" }\n : { plate: \"$ref:prefilter.plate\", style: \"$ref:master.image\" },\n params: { format: s.format, ...placements, words, ...(wide ? {} : core), ...slot },\n tags: { role: STATIC_FORMAT_ROLE },\n });\n return withLogo(nodes, s, `$ref:${id}.image`, g.compositeLogo, plan.placements, `$ref:${id}.logo_slot`);\n });\n nodes.push({\n id: \"final\",\n type: \"collect\",\n inputs: { images: refs },\n params: { labels: plan.sizes.map((s) => s.format) },\n });\n return nodes;\n}\n\n/** The nodes that deliver one size after the renders, in order: its size node (none for the master itself) and the free safe fit an interface asks for. */\nfunction sizeNodes(s: SizePlan, plan: StaticFormatPlan, adaptFormats: readonly string[]): NodeDecl[] {\n const size = sizeNode(s, adaptFormats);\n const fit = safeFitNode(s.format, size ? `$ref:${size.id}.image` : \"$ref:master.image\", plan.placements);\n return [...(size ? [size] : []), ...(fit ? [fit] : [])];\n}\n\n/**\n * The free correction after a size an interface covers (a 9:16 in Reels or Stories): the\n * image model cannot move an element a few points on request, so a word or logo a little\n * past the band is brought inside it by a shrink and shift instead of another render. One too\n * far past it for that is passed on unchanged: the review names what the app covers and the run\n * lays that size out again (never the ad framed over its own blur: \"the faded background looks bad\").\n * Null for a size nothing covers.\n */\nexport function safeFitNode(format: string, image: string, placements: readonly string[] | undefined): NodeDecl | null {\n if (staticSafeArea(format, placements).placement === \"feed\") return null;\n return {\n id: `safe_${formatSlug(format)}`,\n type: \"static_safe_fit\",\n inputs: { image },\n params: { format, ...(placements ? { placements: [...placements] } : {}) },\n tags: { role: STATIC_SAFE_FIT_ROLE },\n };\n}\n\n/**\n * The node that makes one size, when it is not the master itself: a re-laid-out size or an\n * adapted one brought to its exact pixels, or a cut of the master.\n */\nfunction sizeNode(s: SizePlan, adaptFormats: readonly string[]): NodeDecl | null {\n const id = `size_${formatSlug(s.format)}`;\n if (s.from === \"crop\" && s.crop) {\n const c = s.crop;\n const exact = c.width === s.size.width && c.height === s.size.height;\n return magick(id, STATIC_SIZE_ROLE, \"$ref:master.image\", [\n \"{{in.image}}\",\n \"-crop\",\n `${c.width}x${c.height}+${c.x}+${c.y}`,\n \"+repage\",\n ...(exact ? [] : [\"-filter\", \"Lanczos\", \"-resize\", `${s.size.width}x${s.size.height}!`]),\n \"{{out.image}}\",\n ]);\n }\n if (s.from === \"relayout\") {\n return magick(id, STATIC_SIZE_ROLE, `$ref:adapt_${formatSlug(s.format)}.images#0`, fillArgs(s.size));\n }\n if (s.from !== \"adapt\") return null;\n const index = adaptFormats.indexOf(s.adaptFormat ?? s.format);\n return magick(id, STATIC_SIZE_ROLE, `$ref:adapt.images#${index}`, fillArgs(s.size));\n}\n\n/** The quality every re-laid-out size asks for: the variants' own step (`prompt-profiles.ts`), xhigh for speed. */\nconst RELAYOUT_QUALITY = \"xhigh\";\n\n/**\n * relayout: one request per other size, each handed the chosen ad (and the logo file the model\n * draws) and rendered at the model's nearest ratio to its format; the brief is projected from\n * prompt.json on every run (`projectAdaptBriefs`).\n */\nfunction relayoutNodes(g: StaticRenderGraph): NodeDecl[] {\n return g.plan.sizes.filter((s) => s.from === \"relayout\").map((s) => relayoutNode(s, g));\n}\n\nfunction relayoutNode(s: SizePlan, g: StaticRenderGraph): NodeDecl {\n return {\n id: `adapt_${formatSlug(s.format)}`,\n type: \"image_generate\",\n inputs: { reference: [\"$ref:master.image\", ...(g.logoRef ? [g.logoRef] : [])] },\n params: {\n model: g.relayoutModel,\n aspect_ratio: adaptPlan(g.relayoutModel, s.format, g.plan.placements).renderRatio,\n ...imageRenderParams(g.relayoutModel, { size: ADAPT_IMAGE_SIZE, quality: RELAYOUT_QUALITY }),\n prompt: g.prompt,\n },\n tags: { role: STATIC_ADAPT_FORMAT_ROLE },\n };\n}\n\n/** The ids the render graph takes, so no element slot collides with them. */\nexport const RENDER_GRAPH_IDS = [\n \"gen\",\n \"prefilter\",\n \"pick\",\n \"master\",\n \"adapt\",\n \"final\",\n \"fix\",\n \"previous\",\n \"plate_wide\",\n] as const;\n\n/** The ids an older static graph gave its renders: a take, a re-lay, a centred crop. */\nconst LEGACY_RENDER_ID = /^(?:ad(?:_[a-c])?|ad_\\d+x\\d+|fit_\\d+x\\d+)$/;\n\n/** The renders a static ad's variants come from: the one request, or each request of a fanned-out one. */\nfunction variantRenders(canvas: unknown): string[] {\n const fanned = nodesWithRole(canvas, STATIC_VARIANT_CALL_ROLE).map((n) => n.id);\n if (fanned.length > 0) return fanned;\n return nodesWithRole(canvas, STATIC_VARIANTS_ROLE)\n .filter((n) => n.type === \"image_generate\")\n .map((n) => n.id);\n}\n\n/**\n * What `--regenerate` names, as node ids: an id as it is; a role as every node that carries\n * it (`static_variants` is the renders the variants come from, whatever their ids); and, on a\n * static ad, the id of the collect that gathers the variants (`gen`) or an id from the older\n * graph (`ad_a`, `ad_9x16`, `fit_4x5`) as the variants, since every size is now made from the\n * pick. Names that match nothing come back in `unknown`.\n */\nexport function regenerateTargets(canvas: unknown, requested: readonly string[]): { ids: string[]; unknown: string[] } {\n const known = new Set(nodesOf(canvas).flatMap((n) => (typeof n?.id === \"string\" ? [n.id] : [])));\n const gathered = new Set(\n nodesWithRole(canvas, STATIC_VARIANTS_ROLE)\n .filter((n) => n.type === \"collect\")\n .map((n) => n.id),\n );\n const ids: string[] = [];\n const unknown: string[] = [];\n for (const name of requested) {\n const variants =\n name === STATIC_VARIANTS_ROLE || gathered.has(name) || (!known.has(name) && LEGACY_RENDER_ID.test(name));\n const found = variants\n ? variantRenders(canvas)\n : known.has(name)\n ? [name]\n : nodesWithRole(canvas, name).map((n) => n.id);\n if (found.length === 0) unknown.push(name);\n for (const id of found) if (!ids.includes(id)) ids.push(id);\n }\n return { ids, unknown };\n}\n","import { readdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport sharp from \"sharp\";\n\n/**\n * The client's brand, read from the workspace instead of asked for.\n *\n * `scaffold-ad` takes `brand.logo` and `brand.palette` in the spec, and the spec is\n * written by an agent. Asked three times for an ad \"with our logo\", it supplied one\n * once: two of the three ads rendered with no mark anywhere and no closing card, which\n * is not a model being careless so much as a design that made the correct outcome\n * depend on somebody remembering.\n *\n * Both values already exist at a fixed place in every workspace — `src/brand/BRAND.md`\n * and `src/brand/logos/`. Reading them is deterministic, costs nothing, and cannot be\n * forgotten. The spec still wins when it says something: this fills the silence.\n *\n * The same move that fixed the voice. A Spanish ad was cast from English stock voices\n * because nobody declared a language; reading it off the script removed the whole class\n * of failure rather than adding another reminder.\n */\n\n/** Where a workspace keeps its brand. Fixed by the scaffold, not by convention. */\nexport const BRAND_DIR = \"src/brand\";\n\n/**\n * Brand hexes in the order the document introduces them.\n *\n * Order matters: the first is used as the closing plate and the CTA fill, and a brand\n * document leads with its primary. Deduplicated case-insensitively so `#1F6F43` and\n * `#1f6f43` are one colour, and near-white/near-black are dropped — they are page\n * furniture in every brand doc and make a terrible plate.\n */\nexport function paletteFromBrandDoc(markdown: string): string[] {\n const seen = new Set<string>();\n const out: string[] = [];\n for (const match of markdown.matchAll(/#([0-9a-fA-F]{6})\\b/g)) {\n const hex = `#${(match[1] as string).toLowerCase()}`;\n if (seen.has(hex)) continue;\n seen.add(hex);\n const luma = hexLuma(hex);\n if (luma === null || luma > 236 || luma < 14) continue;\n out.push(hex);\n }\n return out;\n}\n\n/** How light a `#rrggbb` is, on the same 0–255 scale as `inkLuma`. Null if it is not one. */\nexport function hexLuma(hex: string): number | null {\n const m = hex.trim().match(/^#?([0-9a-fA-F]{6})$/);\n if (!m) return null;\n const v = m[1] as string;\n const r = Number.parseInt(v.slice(0, 2), 16);\n const g = Number.parseInt(v.slice(2, 4), 16);\n const b = Number.parseInt(v.slice(4, 6), 16);\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n}\n\n/** The first `#rrggbb` a palette actually holds, normalised, or null when it holds none. */\nexport function firstHex(palette: string[] | undefined): string | null {\n const hex = (palette ?? []).find((h) => /^#?[0-9a-fA-F]{6}$/.test(h.trim()));\n if (!hex) return null;\n const trimmed = hex.trim();\n return trimmed.startsWith(\"#\") ? trimmed : `#${trimmed}`;\n}\n\n/**\n * Whether the closing PLATE is dark, which is what the card's own colours are chosen\n * against.\n *\n * The engine fills that plate with the palette's dominant hex, and with **no palette it\n * fills it black** (`brandPlateColor`, engine/scaffold/video/routes/brand-card.ts) — so \"nothing to go on\"\n * means dark here, not light. Getting that backwards is the whole failure this answers: the\n * card's button carried a fixed near-black fill, which on a black or near-black plate is a\n * button nobody can see.\n */\nexport function plateIsDark(palette: string[] | undefined): boolean {\n const luma = hexLuma(firstHex(palette) ?? \"\");\n return luma === null || luma < PLATE_DARK_LUMA;\n}\n\n/**\n * Below this a plate takes the light button, above it the near-black one.\n *\n * Set at the midpoint rather than at a contrast-ratio threshold, because the choice is\n * between two opposites and one of them always wins: measured against the brand green this\n * was reported on (`#1d5d47`, luma 78), white-on-green scores 7.8:1 and black-on-green\n * 2.7:1, so the light button is not merely safe there, it is the better of the two.\n */\nconst PLATE_DARK_LUMA = 140;\n\n/**\n * Names that mean \"this is the variant for some OTHER context\", in both languages the\n * client repos are written in.\n *\n * `dark` / `light` and their Spanish equivalents are the ones this list was missing, and\n * the omission chose the wrong file for a real client: `\\blogo\\b` matches `logo-dark.svg`\n * exactly as well as `logo.svg`, so the two tied and the tie went alphabetically —\n * `logo-dark.svg` first, because `-` sorts before `.`. Cubicup's correct mark was sitting\n * beside it, and the ad went out wearing the one drawn for a dark background.\n *\n * `dark`/`light` name the BACKGROUND the variant is for in most kits and the ink itself in\n * some, which is exactly why neither belongs in the default pick: whichever it means, it is\n * a variant, and the plain name beside it is the mark.\n */\nconst MARK_VARIANT_NAMES =\n /\\b(mono|white|black|blanco|negro|negra|dark|light|oscuro|oscura|claro|clara|negativo|negativa|positivo|inverse|inverso|inversa|inv|reverse|reversed|alt|outline|transparent|watermark|icon|favicon|mark-only|isotipo|isotype)\\b/;\n\n/**\n * The file most likely to BE the mark, out of whatever the logos folder holds.\n *\n * A plain \"logo\"-ish name beats a variant (mono, white, dark, icon, favicon), because a\n * variant is for a context this is not — and a raster takes the tie over a vector of the\n * same mark, for the reason spelled out below.\n */\nexport function pickBrandMark(files: string[]): string | null {\n const usable = files.filter((f) => /\\.(svg|png|webp)$/i.test(f));\n if (usable.length === 0) return null;\n const score = (f: string): number => {\n const name = f.toLowerCase();\n let s = 0;\n // A raster wins a tie with a vector of the same mark. The vector used to win outright,\n // for staying crisp at any size — right for a mark made of outlines, ruinous for one\n // whose wordmark is live `<text>`: the render browser has no brand font, substitutes\n // glyphs, and a closing card came back reading \"ChEENLEVI\" while the PNG next to it\n // would have been exact. A raster cannot be wrong about its own letterforms.\n if (/\\.(png|webp)$/.test(name)) s += 1;\n if (/\\b(logo|wordmark|lockup)\\b/.test(name)) s += 2;\n if (MARK_VARIANT_NAMES.test(name)) s -= 3;\n return s;\n };\n // Ties break on the SHORTER name, not alphabetically. A variant's name is its base plus\n // a qualifier, so the shorter of two equally-scored files is the plainer mark — and\n // alphabetical order actively preferred the qualified one, since `logo-x.svg` sorts\n // before `logo.svg`. This is the net that catches a qualifier nobody listed above.\n return [...usable].sort((a, b) => score(b) - score(a) || a.length - b.length || a.localeCompare(b))[0] ?? null;\n}\n\n/** What the workspace can supply on its own, for the fields a spec left empty. */\nexport type BrandFromWorkspace = { logo?: string; palette?: string[] };\n\n/**\n * Read the brand out of the workspace. Never throws — a workspace with no brand yet is\n * an ordinary state, and the command says so in its hints rather than failing.\n */\nexport async function readBrandFromWorkspace(root = \".\"): Promise<BrandFromWorkspace> {\n const found: BrandFromWorkspace = {};\n\n const doc = await readFile(path.join(root, BRAND_DIR, \"BRAND.md\"), \"utf-8\").catch(() => null);\n if (doc) {\n const palette = paletteFromBrandDoc(doc);\n if (palette.length > 0) found.palette = palette;\n }\n\n const dir = path.join(root, BRAND_DIR, \"logos\");\n const files = await readdir(dir).catch(() => null);\n if (files) {\n const mark = pickBrandMark(files);\n if (mark) found.logo = path.join(BRAND_DIR, \"logos\", mark);\n }\n\n return found;\n}\n\n/**\n * Whether an SVG mark is live TEXT rather than outlines.\n *\n * A real brand mark ships as paths: outlined type renders identically on every machine,\n * and that is the whole point of a logo. An SVG that draws its wordmark with `<text>`\n * depends on a font being installed wherever it is rendered, and is almost always a\n * stand-in somebody typed out.\n *\n * The one that reached a client repo did both: `<text>greenleaf</text>` in a font the\n * renderer did not have, with a decorative leaf parked on top of the last letter — so\n * every ad it appeared in read \"greenleá\". Existence was not enough to check; the file\n * was there, and it was still not the company's logo.\n */\nexport function svgIsLiveText(svg: string): boolean {\n return /<text[\\s>]/i.test(svg);\n}\n\n/**\n * Whether the mark this ad is about to wear can be trusted.\n *\n * Asked of the DIRECTORY, not of the file the spec happens to point at. The earlier gate\n * inspected only the resolved `.svg`, so a PNG rasterised from a typed stand-in walked\n * past it — and the refusal's own advice (\"or a PNG at 1000px or wider\") is what pushed an\n * agent to produce one. Rasterised on a machine without the brand font, it bakes the\n * substituted glyphs into pixels, where no check can read them back: a closing card came\n * out reading \"ChEENLEVI\" and nothing in the pipeline could tell.\n *\n * So the question is about the source material. A raster is only trusted when the marks it\n * could have come from are trustworthy: with a typed SVG sitting beside it, it is far more\n * likely to be a render of that than an asset the client sent.\n *\n * Asked of the workspace's OWN brand folder first, because that folder is what vouches for\n * anything derived from it. Narrowing this to \"the folder the chosen file happens to sit\n * in\" is how a rasterised stand-in got through: the agent exported the typed SVG to a PNG\n * inside its own run directory, where nothing sat beside it to give it away, and the\n * closing card came out wearing #1D5D47 — the stand-in's own fill — instead of the logo's\n * real green. A raster cannot be read back, so the question has to be asked upstream of it.\n *\n * With no brand folder, the file's own folder is all there is to go on, and that is fine:\n * a spec may point outside the workspace, and neither case is evidence of a stand-in.\n */\nexport async function markIsReal(markPath: string, root = \".\"): Promise<boolean> {\n const brandLogos = await findBrandLogosDir(markPath, root);\n if (brandLogos) return await markDirectoryIsReal(brandLogos);\n return await markDirectoryIsReal(path.dirname(markPath));\n}\n\n/**\n * The brand folder this mark belongs to, found by walking UP from the mark itself.\n *\n * Keyed to the caller's cwd once, and that is all it took: run from `src/creatives/<slug>/`\n * with an absolute logo path — exactly what the sandbox agent produces — and the audit\n * looked for `src/brand/logos` under THAT directory, found nothing, and fell back to\n * judging the file by its own neighbours. A raster of the typed stand-in sat alone in a run\n * folder with nothing beside it to give it away, so the whole gate answered `ok: true`.\n *\n * The cwd is still consulted, because a mark can legitimately live outside the workspace;\n * it is simply no longer the only place looked.\n */\nasync function findBrandLogosDir(markPath: string, root: string): Promise<string | null> {\n const candidates: string[] = [];\n let dir = path.resolve(path.dirname(markPath));\n for (;;) {\n candidates.push(path.join(dir, BRAND_DIR, \"logos\"));\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n candidates.push(path.join(root, BRAND_DIR, \"logos\"));\n for (const candidate of candidates) {\n if (\n await readdir(candidate).then(\n () => true,\n () => false,\n )\n )\n return candidate;\n }\n return null;\n}\n\nexport async function markDirectoryIsReal(dir: string): Promise<boolean> {\n const files = await readdir(dir).catch(() => null);\n if (!files) return false;\n const marks = files.filter((f) => /\\.(svg|png|webp)$/i.test(f));\n if (marks.length === 0) return false;\n for (const f of marks.filter((f) => /\\.svg$/i.test(f))) {\n const svg = await readFile(path.join(dir, f), \"utf-8\").catch(() => null);\n // Unreadable is not clean: a mark nobody can open cannot vouch for the rasters beside it.\n if (svg === null || svgIsLiveText(svg)) return false;\n }\n return true;\n}\n\n/**\n * Whether a mark's own INK is light — a white or near-white logo, drawn to sit on colour.\n *\n * Asked because the layer that draws a mark has to put something behind it, and a panel\n * that fits one mark erases the other. The brand layer used to back every mark with a\n * near-white panel, which is right for the usual case (a mark is designed against white)\n * and ruinous for a light one: a client's `logo-dark.svg` — white ink, made for a dark\n * background — rendered as an empty white box in the corner and again, 300px tall, in the\n * middle of the closing card. White on white cannot be fixed by anything downstream.\n *\n * Measured off the pixels rather than guessed from the filename. `logo-dark` names the\n * BACKGROUND it is for in one kit and the ink itself in the next, so the name is not\n * evidence; the file is.\n *\n * Only the ink counts. A mark is mostly transparent — a logo on a transparent canvas is\n * 80% nothing — so averaging every pixel measures the emptiness around it and calls\n * everything dark. Pixels under `INK_ALPHA` are dropped before the average.\n */\nconst INK_ALPHA = 128;\n\n/**\n * The mean luminance of the opaque pixels in an RGBA buffer, or null when there are none.\n *\n * Pure, and exported for tests: the decision this feeds is one threshold on one number,\n * and a number is worth testing without a file on disk.\n */\nexport function inkLuma(rgba: Uint8Array | Buffer): number | null {\n let sum = 0;\n let count = 0;\n for (let i = 0; i + 3 < rgba.length; i += 4) {\n if ((rgba[i + 3] as number) < INK_ALPHA) continue;\n sum += 0.2126 * (rgba[i] as number) + 0.7152 * (rgba[i + 1] as number) + 0.0722 * (rgba[i + 2] as number);\n count += 1;\n }\n return count === 0 ? null : sum / count;\n}\n\n/**\n * Above this the ink is light enough that a near-white panel would swallow it.\n *\n * Deliberately high: a dark panel behind a mid-tone mark is the worse mistake of the two,\n * because a mid-tone mark reads on white and most marks are mid-tone or darker.\n */\nconst LIGHT_INK_LUMA = 170;\n\n/**\n * Whether the mark at `markPath` is light-inked. False for anything unreadable — the\n * near-white panel is the right default, and a mark this cannot open is not a reason to\n * change the backing of every ad.\n */\nexport async function markInkIsLight(markPath: string): Promise<boolean> {\n try {\n // Downscaled first: the decision is one average, and a 4000px wordmark is 64MB of\n // pixels to compute it from. `density` is what makes an SVG rasterise at a usable\n // size — sharp renders one at 72dpi by default, which for a small viewBox is a\n // handful of pixels to average.\n const { data } = await sharp(markPath, { density: 144 })\n .resize(96, 96, { fit: \"inside\", withoutEnlargement: true })\n .ensureAlpha()\n .raw()\n .toBuffer({ resolveWithObject: true });\n const luma = inkLuma(data);\n return luma !== null && luma > LIGHT_INK_LUMA;\n } catch {\n return false;\n }\n}\n","import { BackendHttpError, classifyBackendError, HttpClient } from \"./http.ts\";\n\nexport type RawAssetOutput = {\n kind: \"image\" | \"video\" | \"audio\" | \"json\" | \"text\" | \"font\";\n url: string;\n sha256: string;\n mime: string;\n metadata?: Record<string, unknown>;\n};\n\ntype ExecRequest = {\n nodeType: string;\n nodeVersion: string;\n params: unknown;\n inputs: Record<string, unknown>;\n /** Run-scoped dedupe key: the backend replays the stored response for a\n * repeated key instead of re-dispatching to the provider (and re-charging). */\n idempotency_key?: string;\n /** Run + node identity, so a completed async job can be mapped back to its\n * frozen run's node by the backend stale-run reconciliation sweep. */\n canvas_run_id?: string;\n node_id?: string;\n};\n\ntype ExecResponse = {\n outputs: Record<string, RawAssetOutput | RawAssetOutput[] | unknown>;\n credits_charged?: number;\n duration_ms?: number;\n};\n\n/** A long-running node accepted as a background job (HTTP 202). */\ntype AsyncJobAccepted = { job_id: string; status: \"running\" };\n\n/** Poll response for `GET /api/canvas/jobs/{id}`. */\ntype JobStatus =\n | { status: \"running\" }\n | { status: \"completed\"; result: ExecResponse }\n | { status: \"failed\"; error: JobError };\n\nfunction isAsyncJob(res: ExecResponse | AsyncJobAccepted): res is AsyncJobAccepted {\n return typeof (res as AsyncJobAccepted).job_id === \"string\";\n}\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\ntype JobError = { code?: string; message?: string; provider?: string; retryable?: boolean; status?: number };\n\n// A failed job goes through the SAME classifier as an HTTP error from the sync\n// path, using the status and body the backend stored, so one failure maps to one\n// kind whichever path the node took. A job failure is terminal unless the\n// backend said otherwise: the poll already waited for it, and replaying the\n// node is the engine's decision, made on `retryable`.\nfunction failedJobError(error: JobError): BackendHttpError {\n const message = error.message ?? \"the node failed on the server without saying why\";\n return new BackendHttpError(\n classifyBackendError(error.status ?? 502, { ...error, retryable: error.retryable ?? false }, message),\n );\n}\n\n/**\n * Adaptive poll cadence: hit the status row fast for the first ~15 attempts so a\n * quick node (a cache hit, a short generation) surfaces in ~1s instead of ~3s,\n * then ease to 3s so a multi-minute video job is not hammered. Attempt-indexed\n * and pure so the schedule is unit-testable.\n */\nexport function pollInterval(attempt: number): number {\n return attempt < 15 ? 1_000 : 3_000;\n}\n/** Outer safety bound before giving up polling an async job. */\nconst JOB_POLL_MAX_MS = 20 * 60 * 1000;\n\n/** A resumable run as reported by `GET /api/canvas/runs/active`. */\nexport type ActiveRunInfo = {\n runId: string;\n status: \"running\" | \"completed\" | \"failed\" | \"awaiting_approval\";\n interrupted?: boolean;\n /** The backend's verdict: an unfinished run another sandbox may take over. */\n adoptable?: boolean;\n updatedAt?: number;\n canvasSha?: string;\n canvasSnapshotUrl?: string;\n};\n\n/** The newest snapshot-bearing run for a creative — `GET /api/canvas/runs/latest`. */\nexport type SnapshotRunInfo = {\n runId: string;\n status: \"running\" | \"completed\" | \"failed\" | \"awaiting_approval\";\n interrupted?: boolean;\n canvasSha?: string;\n canvasSnapshotUrl: string;\n};\n\ntype ArtifactResponse = {\n artifact: {\n kind: string;\n name: string;\n version: string;\n description?: string;\n tags?: string[];\n slots: Record<string, RawAssetOutput | RawAssetOutput[]>;\n };\n manifest_sha: string;\n};\n\nexport class BackendClient {\n private readonly http: HttpClient;\n\n constructor(opts: {\n baseUrl: string;\n apiKey: string;\n fetchFn?: typeof fetch;\n timeoutMs?: number;\n maxRetries?: number;\n }) {\n this.http = new HttpClient(opts);\n }\n\n async exec(req: ExecRequest, signal?: AbortSignal): Promise<ExecResponse> {\n const res = await this.http.postJson<ExecResponse | AsyncJobAccepted>(\"/api/canvas/nodes/exec\", req, signal);\n // Long-running nodes (video_deconstruct) return a job id instead of running\n // synchronously, so no HTTP connection is held for their multi-minute\n // duration. Poll the cheap status endpoint until the job is terminal; each\n // poll is a fast request, so a stalled provider can never drop the work.\n if (isAsyncJob(res)) {\n return await this.pollJob(res.job_id, signal);\n }\n return res;\n }\n\n private async pollJob(jobId: string, signal?: AbortSignal): Promise<ExecResponse> {\n const deadline = Date.now() + JOB_POLL_MAX_MS;\n const path = `/api/canvas/jobs/${encodeURIComponent(jobId)}`;\n for (let attempt = 0; ; attempt++) {\n if (signal?.aborted) {\n throw new BackendHttpError({ kind: \"network\", cause: signal.reason ?? new Error(\"aborted\") });\n }\n const job = await this.http.getJson<JobStatus>(path, signal);\n if (job.status === \"completed\") return job.result;\n if (job.status === \"failed\") throw failedJobError(job.error);\n if (Date.now() > deadline) {\n throw new BackendHttpError({ kind: \"timeout\", message: `job ${jobId} did not finish in time` });\n }\n await sleep(pollInterval(attempt));\n }\n }\n\n presignAssetUpload(\n sha256: string,\n mime: string,\n signal?: AbortSignal,\n // GC-registry attribution: \"source\" marks bytes wired into COMMITTED repo\n // files (never sweepable), \"blueprint\" a portable run snapshot; omitted →\n // ordinary node output.\n purpose?: \"output\" | \"source\" | \"blueprint\",\n // Ask for an `If-None-Match: *` write, so an object already stored at this\n // content address is never overwritten. The header is SIGNED into the URL, so\n // only a caller that sends it exactly may ask; the backend echoes\n // `conditional: true` when it signed the URL that way (an older backend does\n // not, and then the header must not be sent).\n conditional?: boolean,\n ): Promise<{ putUrl: string; publicUrl: string; conditional?: boolean }> {\n return this.http.postJson<{ putUrl: string; publicUrl: string; conditional?: boolean }>(\n \"/api/canvas/assets/presign\",\n { sha256, mime, purpose, ...(conditional ? { conditional: true } : {}) },\n signal,\n );\n }\n\n /** Remote cache lookup. A miss (404) — or an old backend without the route — returns null. */\n async getCacheEntry<T>(cacheKey: string, signal?: AbortSignal): Promise<T | null> {\n try {\n const res = await this.http.getJson<{ entry: T }>(`/api/canvas/cache/${encodeURIComponent(cacheKey)}`, signal);\n return res.entry;\n } catch (e) {\n if (e instanceof BackendHttpError && \"status\" in e.detail && e.detail.status === 404) return null;\n throw e;\n }\n }\n\n async putCacheEntry(entry: { cacheKey: string }, signal?: AbortSignal): Promise<void> {\n await this.http.putJson<{ success: boolean }>(\n `/api/canvas/cache/${encodeURIComponent(entry.cacheKey)}`,\n entry,\n signal,\n );\n }\n\n /** Durable run-history record — POST /api/canvas/runs (idempotent server-side on runId). */\n async recordRun(payload: unknown, signal?: AbortSignal): Promise<void> {\n await this.http.postJson<{ success: boolean }>(\"/api/canvas/runs\", payload, signal);\n }\n\n /**\n * Resumable-run lookup — GET /api/canvas/runs/active. Returns the newest\n * still-running/interrupted run for the creative (pinned to the exact canvas\n * sha), so a fresh sandbox can adopt its run id and re-attach billed\n * in-flight jobs. Null on no active run — or an older backend without the\n * route (both 404).\n */\n async getActiveRun(creativeSlug: string, canvasSha?: string, signal?: AbortSignal): Promise<ActiveRunInfo | null> {\n const params = new URLSearchParams({ slug: creativeSlug });\n if (canvasSha) params.set(\"sha\", canvasSha);\n try {\n const res = await this.http.getJson<{ run: ActiveRunInfo }>(`/api/canvas/runs/active?${params}`, signal);\n return res.run;\n } catch (e) {\n if (e instanceof BackendHttpError && \"status\" in e.detail && e.detail.status === 404) return null;\n throw e;\n }\n }\n\n /**\n * Portable-rerun lookup — GET /api/canvas/runs/latest. The newest run for\n * the creative that recorded a canvas snapshot manifest; null when none\n * exists (or the backend predates the route — both 404).\n */\n async getLatestSnapshotRun(creativeSlug: string, signal?: AbortSignal): Promise<SnapshotRunInfo | null> {\n const params = new URLSearchParams({ slug: creativeSlug });\n try {\n const res = await this.http.getJson<{ run: SnapshotRunInfo }>(`/api/canvas/runs/latest?${params}`, signal);\n return res.run;\n } catch (e) {\n if (e instanceof BackendHttpError && \"status\" in e.detail && e.detail.status === 404) return null;\n throw e;\n }\n }\n\n /**\n * Chat-scoped blueprint sync — POST /api/creatives/definition. Lets the\n * dashboard draw a scaffolded creative's workflow graph BEFORE the first run.\n * Additive on the backend (never archives siblings, never sets definitionPath).\n */\n async syncCreativeDefinition(payload: unknown, signal?: AbortSignal): Promise<void> {\n await this.http.postJson<{ success: boolean }>(\"/api/creatives/definition\", payload, signal);\n }\n\n getArtifact(kind: string, name: string, version?: string, signal?: AbortSignal): Promise<ArtifactResponse> {\n const path = version\n ? `/api/canvas/artifacts/${encodeURIComponent(kind)}/${encodeURIComponent(name)}/${encodeURIComponent(version)}`\n : `/api/canvas/artifacts/${encodeURIComponent(kind)}/${encodeURIComponent(name)}`;\n return this.http.getJson<ArtifactResponse>(path, signal);\n }\n}\n","import path from \"node:path\";\nimport { type InputKind, isManagedNodeKind, validateModelInputs, validateModelParams } from \"@baker/canvas-contract\";\nimport { z } from \"zod\";\nimport { forEachString } from \"../lib/json-walk.ts\";\nimport { looksLikeHttpUrl } from \"../lib/url.ts\";\nimport { type Canvas, CanvasSchema, type NodeDecl, parseRefExpr, REF_PREFIX, type RefExpr } from \"../schema/canvas.ts\";\nimport { extractSlots } from \"../schema/prompts.ts\";\nimport { ASSET_KINDS } from \"../schema/refs.ts\";\nimport { estimateCanvasCredits, type NodeCredits, sumCredits } from \"./credits.ts\";\nimport { type AnyNodeDefinition, type InputSource, resolveOutputKinds, type StaticInputKind } from \"./define.ts\";\nimport { didYouMean } from \"./didyoumean.ts\";\nimport { isBlocking, type ValidationIssue } from \"./errors.ts\";\nimport { buildDependencyGraph } from \"./graph.ts\";\nimport type { LintContext as Ctx } from \"./lint/context.ts\";\nimport { runDeepLintRules, runLintRules } from \"./lint/registry.ts\";\nimport { elementMentionKeywords } from \"./lint/rules/video-prompt.ts\";\nimport { overlayTimingIssues } from \"./lint/rules/video-timeline.ts\";\nimport { filledPromptLimitIssues } from \"./prompt-limit.ts\";\nimport type { NodeRegistry } from \"./registry.ts\";\nimport { findCycle } from \"./scheduler.ts\";\n\n// Pure helpers of the domain rules that other modules import from the validator.\nexport { elementMentionKeywords, overlayTimingIssues };\n\nconst MODEL_INPUT_KINDS = new Set<InputKind>([\"image\", \"video\", \"audio\"]);\n\ntype ValidationResult =\n | { ok: true; canvas: Canvas; estimatedCredits: number; warnings?: ValidationIssue[] }\n | { ok: false; issues: ValidationIssue[] };\n\ntype ValidationDeep = ValidationResult & {\n /** Per-node credit estimate, in canvas order. Useful for `validate` cost previews. */\n perNodeCredits?: NodeCredits[];\n};\n\nconst STAGE_CODES = {\n PARSE: \"PARSE_ERROR\",\n SHAPE: \"SHAPE_ERROR\",\n UNKNOWN_NODE: \"UNKNOWN_NODE_TYPE\",\n PARAMS: \"INVALID_PARAMS\",\n PARAMS_EXTRA: \"INVALID_PARAMS_EXTRA\",\n MODEL_PARAMS: \"MODEL_INVALID_PARAMS\",\n MODEL_INPUTS: \"MODEL_INVALID_INPUTS\",\n REF_UNRESOLVED: \"UNRESOLVED_REF\",\n REF_OUT_OF_BOUNDS: \"REF_INDEX_OUT_OF_BOUNDS\",\n REF_TYPE: \"REF_TYPE_MISMATCH\",\n DUPLICATE_ID: \"DUPLICATE_NODE_ID\",\n CYCLE: \"GRAPH_CYCLE\",\n SLOT: \"PROMPT_SLOT_UNRESOLVED\",\n OUTPUT: \"OUTPUT_REF_INVALID\",\n ORPHAN_NODE: \"ORPHAN_NODE\",\n INGEST_PATH_URL_HEALED: \"INGEST_PATH_URL_HEALED\",\n} as const;\n\nexport function validateCanvas(input: unknown, registry: NodeRegistry): ValidationResult {\n const issues: ValidationIssue[] = [];\n const shape = CanvasSchema.safeParse(input);\n if (!shape.success) {\n pushZodIssues(issues, shape.error, \"\", STAGE_CODES.SHAPE);\n return { ok: false, issues };\n }\n const canvas = shape.data;\n const idToIndex = buildIdToIndex(canvas);\n const ctx: Ctx = { canvas, registry, issues, idToIndex };\n\n checkDuplicateIds(ctx);\n checkUnknownNodeTypes(ctx);\n if (issues.some((i) => i.code === STAGE_CODES.UNKNOWN_NODE)) return { ok: false, issues };\n\n checkAllParams(ctx);\n checkIngestPathUrlHeals(ctx);\n checkAllModelParams(ctx);\n checkAllRefs(ctx);\n checkAllModelInputs(ctx);\n checkCycle(ctx);\n checkAllSlots(ctx);\n const estimatedCredits = sumCredits(estimateCanvasCredits(canvas, registry));\n checkOutputRef(ctx);\n checkOrphanNodes(ctx);\n runLintRules(ctx);\n\n // Warnings are advisory: they never block. Only error-severity issues make the\n // canvas invalid; on failure we still return every issue (warnings included) so\n // nothing is dropped from the report.\n const hasBlocking = issues.some(isBlocking);\n if (hasBlocking) return { ok: false, issues };\n const warnings = issues.filter((i) => !isBlocking(i));\n return { ok: true, canvas, estimatedCredits, warnings: warnings.length > 0 ? warnings : undefined };\n}\n\n/**\n * Async second pass that lets each node run its own `validateExtra` hook.\n * Use this from `canvas validate` so composition-meta checks (and any\n * future async validators) surface as standard validation issues.\n *\n * Returns the same result the sync pass would, with `perNodeCredits` added\n * when the canvas is structurally OK.\n */\nexport async function validateCanvasDeep(input: unknown, registry: NodeRegistry): Promise<ValidationDeep> {\n const shallow = validateCanvas(input, registry);\n if (!shallow.ok) return shallow;\n const canvas = shallow.canvas;\n const issues: ValidationIssue[] = [];\n const ctx: Ctx = { canvas, registry, issues, idToIndex: buildIdToIndex(canvas) };\n const inputKindOf = (value: unknown) => staticInputKind(ctx, value);\n const inputSourceOf = (value: unknown) => staticInputSource(ctx, value);\n\n for (let i = 0; i < canvas.nodes.length; i++) {\n const n = canvas.nodes[i];\n if (!n) continue;\n const def = registry.get(n.type);\n if (!def?.validateExtra) continue;\n let extra: Awaited<ReturnType<typeof def.validateExtra>>;\n try {\n extra = await def.validateExtra({\n rawParams: n.params,\n rawInputs: n.inputs,\n nodeId: n.id,\n inputKindOf,\n inputSourceOf,\n });\n } catch (e) {\n issues.push({\n path: `nodes[${i}].params`,\n code: STAGE_CODES.PARAMS_EXTRA,\n message: (e as Error).message,\n node_id: n.id,\n node_type: n.type,\n });\n continue;\n }\n for (const item of extra) {\n issues.push({\n path: `nodes[${i}].${item.path}`,\n code: STAGE_CODES.PARAMS_EXTRA,\n message: item.message,\n node_id: n.id,\n node_type: n.type,\n });\n }\n }\n\n await runDeepLintRules(canvas, issues);\n issues.push(...(await filledPromptLimitIssues(canvas)));\n\n const hasBlocking = issues.some(isBlocking);\n if (hasBlocking) return { ok: false, issues };\n // Carry the shallow pass's advisory warnings through, plus any warning-severity\n // deep-validator issues, onto the ok result.\n const warnings = [...(shallow.warnings ?? []), ...issues.filter((i) => !isBlocking(i))];\n\n const perNodeCredits = estimateCanvasCredits(canvas, registry);\n\n return {\n ok: true,\n canvas,\n estimatedCredits: shallow.estimatedCredits,\n perNodeCredits,\n warnings: warnings.length > 0 ? warnings : undefined,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Stage helpers\n// ---------------------------------------------------------------------------\n\nfunction buildIdToIndex(canvas: Canvas): Map<string, number> {\n const m = new Map<string, number>();\n for (let i = 0; i < canvas.nodes.length; i++) {\n const n = canvas.nodes[i];\n if (n) m.set(n.id, i);\n }\n return m;\n}\n\nfunction checkDuplicateIds(ctx: Ctx): void {\n const seen = new Set<string>();\n for (let i = 0; i < ctx.canvas.nodes.length; i++) {\n const n = ctx.canvas.nodes[i];\n if (!n) continue;\n if (seen.has(n.id)) {\n ctx.issues.push({\n path: `nodes[${i}].id`,\n code: STAGE_CODES.DUPLICATE_ID,\n message: `duplicate node id \"${n.id}\"`,\n node_id: n.id,\n });\n }\n seen.add(n.id);\n }\n}\n\nfunction checkUnknownNodeTypes(ctx: Ctx): void {\n const known = ctx.registry.ids();\n for (let i = 0; i < ctx.canvas.nodes.length; i++) {\n const n = ctx.canvas.nodes[i];\n if (!n || ctx.registry.has(n.type)) continue;\n ctx.issues.push({\n path: `nodes[${i}].type`,\n code: STAGE_CODES.UNKNOWN_NODE,\n message: `unknown node type \"${n.type}\"`,\n received: n.type,\n did_you_mean: didYouMean(n.type, known),\n node_id: n.id,\n node_type: n.type,\n });\n }\n}\n\nfunction checkAllParams(ctx: Ctx): void {\n for (let i = 0; i < ctx.canvas.nodes.length; i++) {\n const n = ctx.canvas.nodes[i];\n if (!n) continue;\n const def = ctx.registry.get(n.type);\n if (!def) continue;\n const parsed = def.params.safeParse(n.params ?? {});\n if (parsed.success) continue;\n pushZodIssues(ctx.issues, parsed.error, `nodes[${i}].params`, STAGE_CODES.PARAMS, n.id, n.type);\n }\n}\n\n/**\n * The ingest schema silently heals a `source:\"path\"` node whose value is an http(s) URL into a\n * `source:\"url\"` ingest (so the run works instead of dying at execute with file_not_found). Surface\n * that heal as an advisory: the run behaves correctly, but the on-disk canvas JSON still literally\n * says `source:\"path\"`, so the operator should correct it. Non-blocking — the canvas stays runnable.\n */\nfunction checkIngestPathUrlHeals(ctx: Ctx): void {\n for (let i = 0; i < ctx.canvas.nodes.length; i++) {\n const n = ctx.canvas.nodes[i];\n if (n?.type !== \"ingest\") continue;\n const params = (n.params ?? {}) as Record<string, unknown>;\n if (params.source !== \"path\" || !looksLikeHttpUrl(params.path)) continue;\n ctx.issues.push({\n path: `nodes[${i}].params.source`,\n code: STAGE_CODES.INGEST_PATH_URL_HEALED,\n message: `ingest \"${n.id}\" declares source:\"path\" but its value is a URL — running it as source:\"url\". Update the canvas JSON to source:\"url\" so it matches what baker runs.`,\n severity: \"warning\",\n node_id: n.id,\n node_type: n.type,\n });\n }\n}\n\nfunction checkAllModelParams(ctx: Ctx): void {\n for (let i = 0; i < ctx.canvas.nodes.length; i++) {\n const n = ctx.canvas.nodes[i];\n if (!n || !isManagedNodeKind(n.type)) continue;\n const params = (n.params ?? {}) as Record<string, unknown>;\n const model = params.model;\n if (typeof model !== \"string\" || model.length === 0) continue; // shape validator will have flagged this\n const r = validateModelParams(n.type, model, params);\n if (r.ok) continue;\n for (const err of r.errors) {\n ctx.issues.push({\n path: `nodes[${i}].params${\"param\" in err ? `.${err.param}` : \"\"}`,\n code: STAGE_CODES.MODEL_PARAMS,\n message: err.message,\n node_id: n.id,\n node_type: n.type,\n });\n }\n }\n}\n\nfunction checkAllRefs(ctx: Ctx): void {\n for (let i = 0; i < ctx.canvas.nodes.length; i++) {\n const n = ctx.canvas.nodes[i];\n if (!n) continue;\n walkRefs(n.inputs, (refStr, jsonPath) => {\n checkOneRef(ctx, n, i, refStr, jsonPath, \"inputs\");\n });\n walkRefs(n.params, (refStr, jsonPath) => {\n checkOneRef(ctx, n, i, refStr, jsonPath, \"params\");\n });\n }\n}\n\n/**\n * For every managed-kind node (image_generate / video_generate / video_lipsync\n * / tts / music / dialogue / sound_effect), confirm the model's REQUIRED input\n * kinds are wired. The kind of each wired ref comes from the target node's\n * declared `outputKinds[slot]`. Refs that can't be resolved (missing target,\n * bad output, etc.) are skipped — `checkAllRefs` already surfaced those.\n */\nfunction checkAllModelInputs(ctx: Ctx): void {\n for (let i = 0; i < ctx.canvas.nodes.length; i++) {\n const n = ctx.canvas.nodes[i];\n if (!n || !isManagedNodeKind(n.type)) continue;\n const params = (n.params ?? {}) as Record<string, unknown>;\n const model = params.model;\n if (typeof model !== \"string\" || model.length === 0) continue;\n const providedKinds = collectProvidedKinds(ctx, n);\n const r = validateModelInputs(n.type, model, providedKinds);\n if (r.ok) continue;\n for (const err of r.errors) {\n ctx.issues.push({\n path: `nodes[${i}].inputs`,\n code: STAGE_CODES.MODEL_INPUTS,\n message: err.message,\n node_id: n.id,\n node_type: n.type,\n });\n }\n }\n}\n\nfunction collectProvidedKinds(ctx: Ctx, n: NodeDecl): InputKind[] {\n const kinds = new Set<InputKind>();\n walkRefs(n.inputs, (refStr) => {\n const kind = resolveRefKind(ctx, refStr);\n if (kind) kinds.add(kind);\n });\n return [...kinds];\n}\n\nfunction resolveRefKind(ctx: Ctx, refStr: string): InputKind | null {\n const target = refTarget(ctx, refStr);\n const kind = target ? refOutputKind(target) : undefined;\n return kind && MODEL_INPUT_KINDS.has(kind as InputKind) ? (kind as InputKind) : null;\n}\n\ntype RefTarget = { expr: RefExpr; node: NodeDecl; def: AnyNodeDefinition };\n\n/** The node and definition a `$ref:` string points at, when both exist. */\nfunction refTarget(ctx: Ctx, refStr: string): RefTarget | null {\n const expr = parseRefExpr(refStr);\n if (!expr) return null;\n const targetIdx = ctx.idToIndex.get(expr.nodeId);\n const node = targetIdx === undefined ? undefined : ctx.canvas.nodes[targetIdx];\n const def = node ? ctx.registry.get(node.type) : undefined;\n return node && def ? { expr, node, def } : null;\n}\n\n/** The asset kind a ref's output carries, as its node declares it. */\nfunction refOutputKind({ expr, node, def }: RefTarget): string | undefined {\n const targetParams = def.params.safeParse(node.params ?? {});\n const resolvedKinds = resolveOutputKinds(def.outputKinds, targetParams.success ? targetParams.data : {});\n // Nodes with dynamic outputs (ffmpeg) declare each output's kind on the instance\n // (`params.outputs.<name>.kind`); honor that so an ffmpeg-produced audio/video can\n // satisfy a typed model input (e.g. audio_voice_convert reading extracted audio).\n const declaredKind = (node.params as { outputs?: Record<string, { kind?: string }> } | undefined)?.outputs?.[\n expr.output\n ]?.kind;\n return resolvedKinds[expr.output] ?? declaredKind;\n}\n\n/**\n * What a raw input value will hold at run time, read off the node it references:\n * a whole list output wired without `#<index>` arrives as a list, not one asset,\n * and a plain-value output (a `text` node's string) is no asset at all.\n */\nfunction staticInputKind(ctx: Ctx, value: unknown): StaticInputKind {\n if (Array.isArray(value)) return \"list\";\n if (typeof value !== \"string\") return value && typeof value === \"object\" ? \"unknown\" : \"value\";\n if (!value.startsWith(REF_PREFIX)) return \"value\";\n const target = refTarget(ctx, value);\n if (!target) return \"unknown\";\n const outputSchema = unwrap(shapeOf(target.def.outputs)?.[target.expr.output] ?? z.unknown());\n if (outputSchema instanceof z.ZodArray && target.expr.index === undefined) return \"list\";\n const kind = refOutputKind(target);\n if (kind && ASSET_KINDS.has(kind)) return kind as StaticInputKind;\n const plain = outputSchema instanceof z.ZodString || outputSchema instanceof z.ZodNumber;\n return plain || outputSchema instanceof z.ZodBoolean ? \"value\" : \"unknown\";\n}\n\n/**\n * Where a raw input's file comes from before the run: the workspace file or URL an\n * `ingest` reads (a relative path resolves against the working directory, as the ingest\n * does). Undefined for anything a node produces while the run is under way.\n */\nfunction staticInputSource(ctx: Ctx, value: unknown): InputSource | undefined {\n if (typeof value !== \"string\" || !value.startsWith(REF_PREFIX)) return undefined;\n const target = refTarget(ctx, value);\n if (target?.node.type !== \"ingest\" || target.expr.output !== \"asset\" || target.expr.index !== undefined)\n return undefined;\n const parsed = target.def.params.safeParse(target.node.params ?? {});\n if (!parsed.success) return undefined;\n const params = parsed.data as { source?: unknown; path?: unknown; url?: unknown };\n if (params.source === \"path\" && typeof params.path === \"string\") return { path: path.resolve(params.path) };\n if (params.source === \"url\" && typeof params.url === \"string\") return { url: params.url };\n return undefined;\n}\n\nfunction checkOneRef(\n ctx: Ctx,\n n: NodeDecl,\n i: number,\n refStr: string,\n jsonPath: string,\n field: \"inputs\" | \"params\",\n): void {\n if (!refStr.startsWith(REF_PREFIX)) return;\n const expr = parseRefExpr(refStr);\n if (expr?.kind !== \"ref\") {\n ctx.issues.push({\n path: `nodes[${i}].${field}.${jsonPath}`,\n code: STAGE_CODES.REF_UNRESOLVED,\n message: `malformed ref \"${refStr}\"`,\n node_id: n.id,\n node_type: n.type,\n });\n return;\n }\n const targetIdx = ctx.idToIndex.get(expr.nodeId);\n if (targetIdx === undefined) {\n ctx.issues.push({\n path: `nodes[${i}].${field}.${jsonPath}`,\n code: STAGE_CODES.REF_UNRESOLVED,\n message: `ref \"${refStr}\" — no node with id \"${expr.nodeId}\"`,\n did_you_mean: didYouMean(expr.nodeId, [...ctx.idToIndex.keys()]),\n node_id: n.id,\n node_type: n.type,\n });\n return;\n }\n checkRefOutput(ctx, n, i, jsonPath, field, refStr, expr.nodeId, expr.output, targetIdx);\n}\n\nfunction checkRefOutput(\n ctx: Ctx,\n n: NodeDecl,\n i: number,\n jsonPath: string,\n field: \"inputs\" | \"params\",\n refStr: string,\n nodeId: string,\n output: string,\n targetIdx: number,\n): void {\n const target = ctx.canvas.nodes[targetIdx];\n if (!target) return;\n const targetDef = ctx.registry.get(target.type);\n if (!targetDef) return;\n const outputNames = listShapeKeys(targetDef.outputs);\n if (!outputNames || outputNames.includes(output)) return;\n ctx.issues.push({\n path: `nodes[${i}].${field}.${jsonPath}`,\n code: STAGE_CODES.REF_UNRESOLVED,\n message: `ref \"${refStr}\" — node \"${nodeId}\" (${target.type}) has no output \"${output}\"`,\n did_you_mean: didYouMean(output, outputNames),\n node_id: n.id,\n node_type: n.type,\n });\n}\n\nfunction checkCycle(ctx: Ctx): void {\n const graph = buildDependencyGraph(ctx.canvas);\n const cycle = findCycle(graph);\n if (cycle) {\n ctx.issues.push({ path: \"nodes\", code: STAGE_CODES.CYCLE, message: `cycle detected: ${cycle.join(\" → \")}` });\n }\n}\n\nfunction checkAllSlots(ctx: Ctx): void {\n for (let i = 0; i < ctx.canvas.nodes.length; i++) {\n const n = ctx.canvas.nodes[i];\n if (!n) continue;\n if (!ctx.registry.get(n.type)) continue;\n checkSlotsForNode(ctx, n, i);\n }\n}\n\nfunction checkSlotsForNode(ctx: Ctx, n: NodeDecl, _i: number): void {\n const slots = new Set<string>();\n forEachString(n.params, (text) => {\n for (const s of extractSlots(text)) slots.add(s);\n });\n if (slots.size === 0) return;\n const inputKeys = Object.keys(n.inputs ?? {});\n for (const slot of slots) {\n if (inputKeys.includes(slot)) continue;\n ctx.issues.push({\n path: `nodes[${_i}].params`,\n code: STAGE_CODES.SLOT,\n message: `prompt slot \"{{${slot}}}\" has no matching input on node \"${n.id}\"`,\n did_you_mean: didYouMean(slot, inputKeys),\n node_id: n.id,\n node_type: n.type,\n });\n }\n}\n\n/**\n * Warn on nodes unreachable from `output` — every ref edge walked backward from the\n * output node. A run skips them (`pruneToOutput`), so an orphan is almost always a wiring\n * bug: a step the author meant to use that nothing reads.\n * `ingest` nodes are exempt: parking a free ingest (the scaffold's editable `prompt`\n * blueprint, an operator's spare asset) is a legitimate pattern.\n */\nfunction checkOrphanNodes(ctx: Ctx): void {\n const out = ctx.canvas.output;\n if (!out || !ctx.idToIndex.has(out.node)) return;\n const graph = buildDependencyGraph(ctx.canvas);\n const reachable = new Set<string>();\n const stack = [out.node];\n while (stack.length > 0) {\n const id = stack.pop();\n if (id === undefined || reachable.has(id)) continue;\n reachable.add(id);\n for (const dep of graph.get(id) ?? []) stack.push(dep);\n }\n for (const n of ctx.canvas.nodes) {\n if (reachable.has(n.id) || n.type === \"ingest\") continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id)}]`,\n code: STAGE_CODES.ORPHAN_NODE,\n severity: \"warning\",\n message: `node \"${n.id}\" (${n.type}) is not reachable from output \"${out.node}\": a run skips it, so nothing it would make is used; wire it in or remove it`,\n });\n }\n}\n\nfunction checkOutputRef(ctx: Ctx): void {\n const out = ctx.canvas.output;\n if (!out) return;\n const targetIdx = ctx.idToIndex.get(out.node);\n if (targetIdx === undefined) {\n ctx.issues.push({\n path: \"output.node\",\n code: STAGE_CODES.OUTPUT,\n message: `output references unknown node \"${out.node}\"`,\n did_you_mean: didYouMean(out.node, [...ctx.idToIndex.keys()]),\n });\n return;\n }\n const target = ctx.canvas.nodes[targetIdx];\n if (!target) return;\n const targetDef = ctx.registry.get(target.type);\n if (!targetDef) return;\n const outs = listShapeKeys(targetDef.outputs);\n if (!outs || outs.includes(out.output)) return;\n ctx.issues.push({\n path: \"output.output\",\n code: STAGE_CODES.OUTPUT,\n message: `node \"${out.node}\" (${target.type}) has no output \"${out.output}\"`,\n did_you_mean: didYouMean(out.output, outs),\n });\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction pushZodIssues(\n issues: ValidationIssue[],\n err: z.ZodError,\n pathPrefix: string,\n code: string,\n nodeId?: string,\n nodeType?: string,\n): void {\n for (const issue of err.issues) {\n const tail = pathToString(issue.path);\n const path = pathPrefix ? (tail ? `${pathPrefix}.${tail}` : pathPrefix) : tail;\n issues.push({\n path,\n code,\n message: issue.message,\n received: issue.code === \"invalid_type\" ? (issue as { received?: unknown }).received : undefined,\n node_id: nodeId,\n node_type: nodeType,\n });\n }\n}\n\nfunction pathToString(path: ReadonlyArray<PropertyKey>): string {\n return path\n .map((p) => (typeof p === \"number\" ? `[${p}]` : `.${String(p)}`))\n .join(\"\")\n .replace(/^\\./, \"\");\n}\n\n/** Every `$ref:` string in a value, with its dotted path. */\nfunction walkRefs(value: unknown, cb: (refStr: string, path: string) => void): void {\n forEachString(value, (s, path) => {\n if (s.startsWith(REF_PREFIX)) cb(s, path);\n });\n}\n\nfunction listShapeKeys(schema: z.ZodType): string[] | undefined {\n const shape = shapeOf(schema);\n return shape ? Object.keys(shape) : undefined;\n}\n\nfunction shapeOf(schema: z.ZodType): Record<string, z.ZodType> | undefined {\n const obj = unwrap(schema);\n return obj instanceof z.ZodObject ? (obj.shape as Record<string, z.ZodType>) : undefined;\n}\n\nfunction unwrap(schema: z.ZodType): z.ZodType {\n let cur: z.ZodType = schema;\n for (let i = 0; i < 8; i++) {\n const inner = (cur as unknown as { _def?: { innerType?: z.ZodType } })._def?.innerType;\n if (!inner) return cur;\n cur = inner;\n }\n return cur;\n}\n","import { z } from \"zod\";\n\n// $ref:<node_id>.<output> — pass-through the full output (often a list)\n// $ref:<node_id>.<output>#<index> — pick a static index\nexport const REF_PREFIX = \"$ref:\";\n\nexport type RefExpr = { kind: \"ref\"; nodeId: string; output: string; index?: number };\n\nexport function parseRefExpr(input: string): RefExpr | null {\n if (!input.startsWith(REF_PREFIX)) return null;\n const rest = input.slice(REF_PREFIX.length);\n const hashIdx = rest.indexOf(\"#\");\n const head = hashIdx === -1 ? rest : rest.slice(0, hashIdx);\n const tail = hashIdx === -1 ? null : rest.slice(hashIdx + 1);\n const dot = head.indexOf(\".\");\n if (dot <= 0) return null;\n const nodeId = head.slice(0, dot);\n const output = head.slice(dot + 1);\n if (!nodeId || !output) return null;\n let index: number | undefined;\n if (tail !== null) {\n // Reject an empty index (`...#`): Number(\"\") is 0 and would silently\n // resolve to element 0 instead of failing on the malformed ref.\n const n = Number(tail);\n if (tail === \"\" || !Number.isInteger(n) || n < 0) return null;\n index = n;\n }\n return { kind: \"ref\", nodeId, output, index };\n}\n\nconst NodeIdRe = /^[a-z][a-z0-9_]*$/;\n\n/**\n * What a node IS in the ad, stated instead of encoded in its id. A scaffold stamps\n * these so `canvas validate` and the scaffold's own post-passes read \"scene 3, region\n * 1, the presenter's clip\" off the node rather than parsing `s3_r1_clip`. Descriptive\n * only: the engine never reads them and they never enter the cache key, so stamping\n * or editing tags never re-renders (or re-bills) anything. Canvases without tags keep\n * the id conventions they were written with.\n */\nexport const NodeTags = z\n .object({\n /** The scene (0-based, in blueprint order) this node renders or voices. */\n scene: z.number().int().min(0).optional(),\n /** The node's job in the assembly, e.g. `clip`, `frame`, `composite`, `spine`, `overlay`, `mux`. */\n role: z.string().min(1).optional(),\n /** The region index inside a composited (split / picture-in-picture) scene. */\n region: z.number().int().min(0).optional(),\n /** True for a speaker's own on-camera voice (lip-synced), false for a voice read over the picture. */\n on_camera: z.boolean().optional(),\n /** The logo files a scaffold wired on its own, so a rebuild tells its wiring from a logo chosen by hand. */\n wired: z.array(z.string()).optional(),\n })\n .strict();\nexport type NodeTags = z.infer<typeof NodeTags>;\n\nexport const NodeDecl = z\n .object({\n id: z.string().regex(NodeIdRe, \"node id must be lower_snake_case\"),\n type: z.string().min(1),\n version: z.string().min(1).optional(),\n inputs: z.record(z.string(), z.unknown()).optional(),\n params: z.record(z.string(), z.unknown()).optional(),\n // Regenerate knob. The engine is content-addressed: identical params + inputs\n // return the cached render, so re-running an unchanged node NEVER re-bills or\n // produces a new result. Bump this token (any string/number — a `2`, a `\"v3\"`,\n // a note) and re-run to force THIS node to render fresh; because its new output\n // changes downstream input hashes, everything depending on it regenerates too.\n // This is the declarative \"change a value, re-run, get a new render\" affordance.\n regenerate: z.union([z.string(), z.number()]).optional(),\n tags: NodeTags.optional(),\n })\n .strict();\nexport type NodeDecl = z.infer<typeof NodeDecl>;\n\nconst OutputRef = z\n .object({\n node: z.string(),\n output: z.string(),\n })\n .strict();\n\n/**\n * The timing plan a video scaffold emits so `validate` can prove audio/lip-sync\n * invariants STATICALLY — before any billed render. The engine ignores it at run\n * time; only the validator reads it (see engine/lint/rules/video-timeline.ts). Hand-authored\n * video canvases can add this block to opt into the same checks.\n */\nconst VideoMeta = z\n .object({\n duration_s: z.number(),\n // The one-clock contract: the spine's summed clip lengths and every audio\n // timeline reachable from the final mux must equal `expected_total_s` — the\n // validator recomputes both from the LIVE graph (`-shortest` at the final mux\n // silently truncates the longer stream on any mismatch). Emitted by\n // scaffold-video; optional so hand-authored canvases still parse.\n timeline: z\n .object({\n spine_node: z.string(),\n expected_total_s: z.number(),\n audio_mix_node: z.string().optional(),\n })\n .strict()\n .optional(),\n // Each sequenced voiceover turn on the absolute timeline.\n vo_segments: z\n .array(\n z.object({\n slot: z.string(),\n start_s: z.number(),\n end_s: z.number(),\n scene: z.number().optional(),\n speaker: z.string().optional(),\n }),\n )\n .default([]),\n // Scenes with a single on-camera speaker, voiced NATIVELY by the video model\n // (Seedance generate_audio) then re-voiced to one brand voice. Each entry names\n // the `audio_voice_convert` node the validator confirms is present — the\n // native-audio replacement for the retired post-hoc lipsync check. A bare scene\n // index (legacy) or `{ scene, lipsync_node }` (legacy veed canvases) still parse.\n talking_scenes: z\n .array(\n z.union([\n z.number(),\n z.object({\n scene: z.number(),\n voice_convert_node: z.string(),\n // Advisory: the scene's visual length vs the estimated spoken length, so\n // a reviewer can see a native line that may run past its cut. Not gated.\n scene_s: z.number().optional(),\n est_speech_s: z.number().optional(),\n // Word count of the line est_speech_s was measured for. Together they carry\n // the speaker's OBSERVED pace (from the deconstruct's word timings), so the\n // overrun check budgets re-authored lines at the real rate, not a wps guess.\n speech_words: z.number().optional(),\n }),\n z.object({ scene: z.number(), lipsync_node: z.string() }),\n ]),\n )\n .default([]),\n // Advisory, NOT gated: scenes where a presenter's later same-shot turns play as\n // `tts` over their one native clip (a held shot can hold only ONE lip-synced clip,\n // and voiceover turns can't overlap), so the lips may not match those words. The\n // scaffold surfaces it so the agent can cut away or rely on the burned-in captions.\n lip_sync_caution: z\n .array(z.object({ scene: z.number(), speaker: z.string(), tts_over_native: z.array(z.string()) }))\n .optional(),\n // Advisory, NOT gated by the validator: the reviewable \"which graphic fires\n // on which spoken beat\" map emitted by scaffold-video (per-scene window,\n // spoken line, storyboard frames, scheduled graphics). Free-form rows so the\n // schema stays decoupled from the scaffold's exact shape.\n motion_board: z.array(z.unknown()).optional(),\n // The recurring identity elements the scaffold wired (one shared reference slot\n // per cast member / pet / product / logo). The reference-completeness check reads\n // this to warn when a frame's description mentions an element whose ref isn't\n // wired on that frame node (the wrong-identity-animal failure).\n elements: z\n .array(\n z.object({\n ref: z.string(),\n label: z.string(),\n type: z.string(),\n description: z.string().optional(),\n }),\n )\n .optional(),\n // Per video_generate node: the scene's natural visual span. The validator warns\n // when a clip's span exceeds the assigned model's max clip duration (e.g. a 9.2s\n // scene on Veo, which caps at 8s) — the clip would truncate.\n clip_spans: z.array(z.object({ node: z.string(), span_s: z.number() })).optional(),\n // WHY the graph has the nodes it has: one route per scene (clip / still_hold /\n // screen_still / graphic_plate / brand_card / phrase_slice / phrase_run /\n // composite) + a node-type histogram, stamped by scaffold-video. Read this first\n // when a canvas looks big.\n graph_stats: z\n .object({\n nodes_total: z.number(),\n nodes_billable: z.number(),\n node_types: z.record(z.string(), z.number()),\n scene_routes: z.array(z.object({ scene: z.number(), route: z.string(), window_s: z.number() })),\n })\n .strict()\n .optional(),\n })\n .strict()\n .optional();\n\nconst CanvasMetadata = z\n .object({\n name: z.string().optional(),\n description: z.string().optional(),\n // Free-form, human-facing next-steps guide embedded by scaffolds (e.g.\n // `scaffold-video`) so the editable checklist travels inside the canvas\n // instead of only printing to stdout. Ignored by the engine.\n todo: z.unknown().optional(),\n video: VideoMeta,\n // The master shape a static ad was scaffolded on by choice (`--master-shape`): it stays on it.\n // Absent, an existing creative stays on the shape its graph has; a run never moves it. Ignored by the engine.\n master_shape: z.string().min(1).optional(),\n // Why a static ad is on its master shape: chosen, or routed from its spec's kind (`staticShapeFor`).\n master_shape_reason: z.string().min(1).optional(),\n // A static ad of a series (`seriesMemberAd`): the lead ad its picture is an edit of, the\n // lead's version, and the lead's words as that version drew them, which this ad's replace.\n // Ignored by the engine; the brief projection reads it.\n series: z\n .object({\n lead: z.string().min(1),\n run_id: z.string().min(1),\n copy: z.array(z.object({ text: z.string(), role: z.string().optional() }).strict()),\n design: z.string().optional(),\n // A translation of the lead: the language (BCP-47) its words are in.\n language: z.string().min(2).optional(),\n })\n .strict()\n .optional(),\n })\n .strict()\n .optional();\n\nexport const CanvasSchema = z\n .object({\n schema: z.literal(\"baker-canvas/1\"),\n cache_salt: z.string().optional(),\n metadata: CanvasMetadata,\n nodes: z.array(NodeDecl).min(1),\n output: OutputRef.optional(),\n })\n .strict();\n\nexport type Canvas = z.infer<typeof CanvasSchema>;\n","const SLOT_RE = /\\{\\{\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\}\\}/g;\n\nexport function extractSlots(template: string): string[] {\n const out = new Set<string>();\n for (const match of template.matchAll(SLOT_RE)) {\n const name = match[1];\n if (name) out.add(name);\n }\n return [...out];\n}\n\nexport function renderTemplate(template: string, values: Record<string, string>): string {\n return template.replace(SLOT_RE, (_full, name: string) => {\n if (Object.hasOwn(values, name)) {\n return values[name] ?? \"\";\n }\n return \"\";\n });\n}\n\nexport function hasUnresolvedSlots(template: string, values: Record<string, string>): string[] {\n const slots = extractSlots(template);\n return slots.filter((s) => !Object.hasOwn(values, s));\n}\n","import type { AnyNodeDefinition } from \"./define.ts\";\n\ntype Priceable = Pick<AnyNodeDefinition, \"cost\" | \"params\">;\n\nexport type NodeCredits = { node_id: string; node_type: string; credits: number };\n\ntype CostEstimate = ReturnType<NonNullable<AnyNodeDefinition[\"cost\"]>>;\n\n/**\n * The one place a node's `cost` is called, with params its schema already parsed.\n * Null when the node declares no cost, or its cost throws or is not a number.\n */\nexport function priceNode(def: Priceable, params: unknown): CostEstimate | null {\n if (!def.cost) return null;\n try {\n const estimate = def.cost({ params });\n return Number.isFinite(estimate.credits) ? estimate : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The credit ESTIMATE for a node declaration: its raw params parsed through the\n * node's own schema (defaults applied), then priced. 0 when it declares no cost or\n * its params do not parse (validation reports those). What a run actually spent is\n * what the backend charged; this is only the number known before the call.\n */\nexport function estimateNodeCredits(def: Priceable | undefined, params: unknown): number {\n if (!def?.cost) return 0;\n const parsed = def.params.safeParse(params ?? {});\n if (!parsed.success) return 0;\n return priceNode(def, parsed.data)?.credits ?? 0;\n}\n\n/** Each node's estimate, in canvas order. */\nexport function estimateCanvasCredits(\n canvas: { nodes: readonly { id: string; type: string; params?: unknown }[] },\n registry: { get: (type: string) => Priceable | undefined },\n): NodeCredits[] {\n return canvas.nodes.map((n) => ({\n node_id: n.id,\n node_type: n.type,\n credits: estimateNodeCredits(registry.get(n.type), n.params),\n }));\n}\n\nexport function sumCredits(perNode: readonly NodeCredits[]): number {\n return perNode.reduce((total, n) => total + n.credits, 0);\n}\n","/** Damerau-Levenshtein distance with single-edit awareness. */\nfunction distance(a: string, b: string): number {\n const m = a.length;\n const n = b.length;\n if (m === 0) return n;\n if (n === 0) return m;\n const dp = makeDp(m, n);\n for (let i = 1; i <= m; i++) fillRow(dp, a, b, i, n);\n return (dp[m] as number[])[n] ?? 0;\n}\n\nfunction makeDp(m: number, n: number): number[][] {\n const dp: number[][] = Array.from({ length: m + 1 }, () => new Array<number>(n + 1).fill(0));\n for (let i = 0; i <= m; i++) (dp[i] as number[])[0] = i;\n for (let j = 0; j <= n; j++) (dp[0] as number[])[j] = j;\n return dp;\n}\n\nfunction fillRow(dp: number[][], a: string, b: string, i: number, n: number): void {\n const rowI = dp[i] as number[];\n const rowPrev = dp[i - 1] as number[];\n const rowPrev2 = i >= 2 ? (dp[i - 2] as number[]) : undefined;\n for (let j = 1; j <= n; j++) {\n rowI[j] = stepCost(a, b, i, j, rowI, rowPrev, rowPrev2);\n }\n}\n\nfunction stepCost(\n a: string,\n b: string,\n i: number,\n j: number,\n rowI: number[],\n rowPrev: number[],\n rowPrev2: number[] | undefined,\n): number {\n const cost = a.charCodeAt(i - 1) === b.charCodeAt(j - 1) ? 0 : 1;\n const del = (rowPrev[j] ?? 0) + 1;\n const ins = (rowI[j - 1] ?? 0) + 1;\n const sub = (rowPrev[j - 1] ?? 0) + cost;\n let best = Math.min(del, ins, sub);\n if (\n i > 1 &&\n j > 1 &&\n rowPrev2 &&\n a.charCodeAt(i - 1) === b.charCodeAt(j - 2) &&\n a.charCodeAt(i - 2) === b.charCodeAt(j - 1)\n ) {\n best = Math.min(best, (rowPrev2[j - 2] ?? 0) + 1);\n }\n return best;\n}\n\nexport function didYouMean(query: string, candidates: readonly string[], max = 3): string[] {\n if (candidates.length === 0 || !query) return [];\n const threshold = Math.max(1, Math.floor(query.length / 3) + 1);\n const scored: { c: string; d: number }[] = [];\n for (const c of candidates) {\n const d = distance(query.toLowerCase(), c.toLowerCase());\n if (d <= threshold) scored.push({ c, d });\n }\n scored.sort((a, b) => a.d - b.d || a.c.localeCompare(b.c));\n return scored.slice(0, max).map((s) => s.c);\n}\n","import { forEachString } from \"../lib/json-walk.ts\";\nimport { parseRefExpr } from \"../schema/canvas.ts\";\n\ntype GraphNode = { id: string; inputs?: unknown; params?: unknown };\n\n/**\n * The ids a node depends on: every `$ref:` in its inputs AND params that names a\n * node in `known`, in the order they appear. A self-reference is kept, so a cycle\n * check can see it.\n */\nexport function nodeDependencies(node: GraphNode, known: ReadonlySet<string>): Set<string> {\n const deps = new Set<string>();\n const collect = (s: string) => {\n const expr = parseRefExpr(s);\n if (expr && known.has(expr.nodeId)) deps.add(expr.nodeId);\n };\n forEachString(node.inputs, collect);\n forEachString(node.params, collect);\n return deps;\n}\n\n/**\n * Node id → the ids it depends on. The one graph the validator checks for cycles\n * and orphans, the executor schedules, and the dashboard draws before a run.\n */\nexport function buildDependencyGraph(canvas: { nodes: readonly GraphNode[] }): Map<string, Set<string>> {\n const known = new Set(canvas.nodes.map((n) => n.id));\n const graph = new Map<string, Set<string>>();\n for (const n of canvas.nodes) graph.set(n.id, new Set());\n for (const n of canvas.nodes) {\n const deps = graph.get(n.id);\n if (deps) for (const dep of nodeDependencies(n, known)) deps.add(dep);\n }\n return graph;\n}\n","import type { Canvas, NodeDecl } from \"../../schema/canvas.ts\";\nimport { parseRefExpr, REF_PREFIX } from \"../../schema/canvas.ts\";\nimport type { ValidationIssue } from \"../errors.ts\";\nimport type { NodeRegistry } from \"../registry.ts\";\n\n/** What a validation check reads, and the issue list it appends to. */\nexport type LintContext = {\n canvas: Canvas;\n registry: NodeRegistry;\n issues: ValidationIssue[];\n idToIndex: Map<string, number>;\n};\n\ntype Severity = \"error\" | \"warning\";\n\n/**\n * A domain rule: what it knows about making a video, an image or a mix, as opposed\n * to whether the canvas is a well-formed graph. Declares every issue code it can\n * raise and that code's severity; the runner holds it to that declaration.\n */\nexport type LintRule = {\n name: string;\n codes: Readonly<Record<string, Severity>>;\n check: (ctx: LintContext) => void;\n};\n\n/** A rule that reads files the canvas points at, so it only runs in the deep pass. */\nexport type DeepLintRule = {\n name: string;\n codes: Readonly<Record<string, Severity>>;\n check: (canvas: Canvas, issues: ValidationIssue[]) => Promise<void>;\n};\n\n/** The node a `$ref:<id>.<output>` expression points at, when it is one. */\nexport function refNodeOf(ctx: LintContext, value: unknown): NodeDecl | null {\n if (typeof value !== \"string\" || !value.startsWith(REF_PREFIX)) return null;\n const parsed = parseRefExpr(value);\n if (!parsed) return null;\n const idx = ctx.idToIndex.get(parsed.nodeId);\n return idx === undefined ? null : (ctx.canvas.nodes[idx] as NodeDecl);\n}\n\n/**\n * Whether the canvas states what its nodes are (`tags`). A tagged canvas is read by\n * its tags; only an untagged one (written before tags existed) falls back to the\n * `s<scene>_…` id conventions its scaffold used.\n */\nexport function isTagged(ctx: LintContext): boolean {\n return ctx.canvas.nodes.some((n) => n.tags !== undefined);\n}\n\nexport type VideoMetaT = NonNullable<NonNullable<Canvas[\"metadata\"]>[\"video\"]>;\n\n/** A check that only applies to a canvas carrying a video scaffold's timing plan. */\nexport function onVideoCanvas(check: (ctx: LintContext, meta: VideoMetaT) => void): (ctx: LintContext) => void {\n return (ctx) => {\n const meta = ctx.canvas.metadata?.video;\n if (meta) check(ctx, meta);\n };\n}\n","import type { NodeDecl } from \"../../../schema/canvas.ts\";\nimport { type LintContext, type LintRule, refNodeOf } from \"../context.ts\";\n\nconst CODES = {\n DUCK_UNITS: \"AUDIO_DUCK_UNITS\",\n MUSIC_BED_TOO_LOUD: \"AUDIO_MUSIC_BED_TOO_LOUD\",\n MUSIC_BED_NOT_DUCKED: \"AUDIO_MUSIC_BED_NOT_DUCKED\",\n MUSIC_BED_SCORED_TO_ARC: \"AUDIO_MUSIC_BED_SCORED_TO_ARC\",\n} as const;\n\n// ---------------------------------------------------------------------------\n// The music bed under a voice: a level, and a ducker that knows its units.\n//\n// Both numbers below were paid for. A bed at -12 dB crowded the voice, so the\n// scaffolder pinned -20 dB; an agent hand-building a finishing canvas then\n// measured the mix across a window that included the SILENT end card, read\n// \"too quiet\", raised the whole bed to -13 dB, and the client rejected the ad as\n// \"la musica esta demasiada alta\". The same canvas passed `attack: 0.05,\n// release: 0.45` to the sidechain ducker — seconds, where ffmpeg takes\n// milliseconds — so the bed snapped back to full level between syllables, which\n// is what \"too loud\" sounds like even at a correct static level.\n//\n// These checks run on ANY canvas carrying an `audio_timeline`, not just a\n// scaffolded one, because a hand-built finishing canvas is exactly where the\n// scaffolder's settled numbers are re-derived from scratch.\n// ---------------------------------------------------------------------------\n\n/** A music bed under speech lives at or below this. See the note above. */\nconst MUSIC_BED_MAX_GAIN_DB = -18;\n\n/** Below this many ms, a sidechain attack can only be a seconds value. */\nconst DUCK_MIN_ATTACK_MS = 0.5;\n\n/** Below this many ms, the release lets the bed pump back up between words. */\nconst DUCK_MIN_RELEASE_MS = 10;\n\n/** Node types whose audio output IS someone speaking. */\nconst SPEECH_NODE_TYPES = new Set([\"tts\", \"dialogue\", \"audio_voice_convert\", \"video_lipsync\"]);\n\n/** A slot named for what it carries, for speech extracted by a bare ffmpeg node. */\nconst SPEECH_SLOT_RE = /voice|speech|\\bvo\\b|^vo|_vo|dialog|narration/i;\n\nconst MUSIC_SLOT_RE = /music|score|\\bbed\\b/i;\n\ntype MixTrack = { slot: string; gain_db?: number; duration_s?: number };\n\ntype DuckSpec = { track?: unknown; attack?: unknown; release?: unknown };\n\nfunction audioTimelineTracks(node: NodeDecl): MixTrack[] {\n const tracks = (node.params as Record<string, unknown> | undefined)?.tracks;\n if (!Array.isArray(tracks)) return [];\n return tracks.filter(\n (t): t is MixTrack => typeof t === \"object\" && t !== null && typeof (t as MixTrack).slot === \"string\",\n );\n}\n\n/** Every `audio_timeline` in the canvas, checked on its own. */\nfunction checkAudioBedMix(ctx: LintContext): void {\n for (const n of ctx.canvas.nodes) {\n if (n.type === \"audio_timeline\") checkOneAudioMix(ctx, n);\n }\n}\n\n/**\n * The three checks on one `audio_timeline`. Track kinds are read from the WIRING\n * (which node feeds the slot) and fall back to the slot's name, so a bed\n * ingested from a file still counts as music.\n */\nfunction checkOneAudioMix(ctx: LintContext, node: NodeDecl): void {\n const tracks = audioTimelineTracks(node);\n if (tracks.length === 0) return;\n const duck = (node.params as Record<string, unknown> | undefined)?.duck as DuckSpec | undefined;\n checkDuckUnits(ctx, node, duck);\n\n const sourceType = (slot: string): string | null => refNodeOf(ctx, node.inputs?.[slot])?.type ?? null;\n const speech = tracks.filter((t) => {\n const type = sourceType(t.slot);\n return (type !== null && SPEECH_NODE_TYPES.has(type)) || SPEECH_SLOT_RE.test(t.slot);\n });\n if (speech.length === 0) return;\n // A WINDOWED music track is the sanctioned way to lift the bed over a silent\n // tail (an end card), so it is exempt from both checks below — the rule is\n // about the bed that runs under the speech.\n const beds = tracks.filter(\n (t) => (sourceType(t.slot) === \"music\" || MUSIC_SLOT_RE.test(t.slot)) && t.duration_s === undefined,\n );\n if (beds.length === 0) return;\n\n checkBedLevels(ctx, node, beds);\n checkBedDucked(ctx, node, beds, speech, duck);\n for (const bed of beds) checkBedNotScored(ctx, node, refNodeOf(ctx, node.inputs?.[bed.slot]));\n}\n\n// A bed BRIEFED AS A SCORE: movement asked for in the music prompt of a bed that\n// plays under somebody talking. `video-background-music-v1` watches the cut, so a\n// description that tracks the speaker's emotion (\"quiet and slightly tense while\n// she is overwhelmed … resolving warm and confident\") comes back as film score,\n// and the client's verdict on that exact cut was \"muy dramática\". Narrow on\n// purpose: these words are only wrong UNDER SPEECH, which is the only case this\n// runs in.\nconst MUSIC_ARC_RE =\n /\\b(?:emotional arc|follows? (?:her|his|their|the) arc|swell(?:s|ing)?|crescendo|climax|build(?:s|ing) (?:to|into)|resolv(?:e|es|ing)|dramatic|epic|tense|tension)\\b/i;\n\n/** Advisory: the bed under a voice was briefed to move with the speaker's emotion. */\nfunction checkBedNotScored(ctx: LintContext, node: NodeDecl, source: NodeDecl | null): void {\n if (source?.type !== \"music\") return;\n const params = source.params as Record<string, unknown> | undefined;\n // Scoped to the model that WATCHES the cut. `music-v1` composes blind from a\n // prompt, and `scaffold-video` deliberately briefs it with the reference ad's\n // own arc (`musicArcDigest`) — a considered decision, not a defect to warn on.\n if (params?.model !== \"elevenlabs/video-background-music-v1\") return;\n const brief = [params?.description, params?.prompt].filter((v): v is string => typeof v === \"string\").join(\" \");\n const found = MUSIC_ARC_RE.exec(brief);\n if (!found) return;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(source.id) ?? -1}].params.description`,\n code: CODES.MUSIC_BED_SCORED_TO_ARC,\n severity: \"warning\",\n node_id: source.id,\n node_type: source.type,\n message: `\"${source.id}\" briefs the bed with \"${found[0]}\", and \"${node.id}\" mixes it under speech — this model watches the cut, so movement asked for here comes back as a film score (a testimonial briefed that way was rejected as \"muy dramática\"). Under a voice, name ONE steady character and forbid movement: no build, no drop, no climax, nothing that follows the arc`,\n });\n}\n\n/** Blocking: a sidechain attack/release given in seconds, where ffmpeg takes ms. */\nfunction checkDuckUnits(ctx: LintContext, node: NodeDecl, duck: DuckSpec | undefined): void {\n const index = ctx.idToIndex.get(node.id) ?? -1;\n if (typeof duck?.attack === \"number\" && duck.attack < DUCK_MIN_ATTACK_MS) {\n ctx.issues.push({\n path: `nodes[${index}].params.duck.attack`,\n code: CODES.DUCK_UNITS,\n node_id: node.id,\n node_type: node.type,\n message: `\"${node.id}\" ducks with attack ${duck.attack} — this parameter is MILLISECONDS, so that is instantaneous. Use 5-50 (default 5)`,\n });\n }\n if (typeof duck?.release === \"number\" && duck.release < DUCK_MIN_RELEASE_MS) {\n ctx.issues.push({\n path: `nodes[${index}].params.duck.release`,\n code: CODES.DUCK_UNITS,\n node_id: node.id,\n node_type: node.type,\n message: `\"${node.id}\" ducks with release ${duck.release} — this parameter is MILLISECONDS, so the bed jumps back to full level between syllables and the mix sounds like the music is too loud. Use 200-800 (default 300); 0.45 is a seconds value`,\n });\n }\n}\n\n/** Advisory: the bed under the voice is louder than the settled ceiling. */\nfunction checkBedLevels(ctx: LintContext, node: NodeDecl, beds: readonly MixTrack[]): void {\n const index = ctx.idToIndex.get(node.id) ?? -1;\n for (const bed of beds) {\n if ((bed.gain_db ?? 0) <= MUSIC_BED_MAX_GAIN_DB) continue;\n const level = bed.gain_db === undefined ? \"full level (no gain_db)\" : `${bed.gain_db} dB`;\n ctx.issues.push({\n path: `nodes[${index}].params.tracks`,\n code: CODES.MUSIC_BED_TOO_LOUD,\n severity: \"warning\",\n node_id: node.id,\n node_type: node.type,\n message: `\"${node.id}\" runs the music bed \"${bed.slot}\" at ${level} under speech — a bed belongs at ${MUSIC_BED_MAX_GAIN_DB} dB or below (the scaffolder pins -20; -13 was rejected by a client as too loud). If a silent tail sounds empty, add the same bed as a SECOND windowed track (start_s + duration_s) with its own higher gain instead of raising this one`,\n });\n }\n}\n\n/** Advisory: a bed mixed flat under a voice, with no sidechain duck naming it. */\nfunction checkBedDucked(\n ctx: LintContext,\n node: NodeDecl,\n beds: readonly MixTrack[],\n speech: readonly MixTrack[],\n duck: DuckSpec | undefined,\n): void {\n if (beds.some((bed) => bed.slot === duck?.track)) return;\n const quoted = (list: readonly MixTrack[]) => list.map((t) => `\"${t.slot}\"`).join(\", \");\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(node.id) ?? -1}].params.duck`,\n code: CODES.MUSIC_BED_NOT_DUCKED,\n severity: \"warning\",\n node_id: node.id,\n node_type: node.type,\n message: `\"${node.id}\" mixes a music bed (${quoted(beds)}) under speech (${quoted(speech)}) with no sidechain duck on it — a flat bed fights the voice in every gap. Add params.duck { track: \"${beds[0]?.slot}\", against: [${quoted(speech)}] }`,\n });\n}\n\n/** One rule, because its four checks run per mix and report in that order. */\nexport const audioBedMixRule: LintRule = {\n name: \"audio-bed-mix\",\n codes: {\n [CODES.DUCK_UNITS]: \"error\",\n [CODES.MUSIC_BED_TOO_LOUD]: \"warning\",\n [CODES.MUSIC_BED_NOT_DUCKED]: \"warning\",\n [CODES.MUSIC_BED_SCORED_TO_ARC]: \"warning\",\n },\n check: checkAudioBedMix,\n};\n","import { imageProfileFor } from \"../../../lib/prompt-profiles.ts\";\nimport {\n SERIES_LEAD_ROLE,\n STATIC_ADAPT_FORMAT_ROLE,\n STATIC_FIX_ROLE,\n STATIC_PLACE_ROLE,\n STATIC_PLATE_ROLE,\n STATIC_SAFE_FIT_ROLE,\n STATIC_VARIANT_CALL_ROLE,\n STATIC_VARIANTS_ROLE,\n} from \"../../../scaffold/static-topology.ts\";\nimport { parseRefExpr } from \"../../../schema/canvas.ts\";\nimport { type LintContext, type LintRule, refNodeOf } from \"../context.ts\";\n\nconst CODES = {\n IMAGE_PROFILE_MISSING: \"IMAGE_PROMPT_PROFILE_MISSING\",\n PARALLEL_FORMAT_RENDERS: \"IMAGE_PARALLEL_FORMAT_RENDERS\",\n FORMAT_PLATE_SOURCE: \"STATIC_FORMAT_PLATE_SOURCE\",\n MIXED_SIZE_PIPELINE: \"STATIC_MIXED_SIZE_PIPELINE\",\n} as const;\n\n/** Advisory: an image frame renders on a model with no per-model prompt profile, so\n * it got the generic frame template (exclusion placement / photoreal cue not tuned). */\nfunction checkImageProfile(ctx: LintContext): void {\n for (const n of ctx.canvas.nodes) {\n if (n.type !== \"image_generate\") continue;\n const model = (n.params as Record<string, unknown> | undefined)?.model;\n if (typeof model !== \"string\" || imageProfileFor(model)) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}].params.model`,\n code: CODES.IMAGE_PROFILE_MISSING,\n severity: \"warning\",\n node_id: n.id,\n message: `\"${n.id}\" renders on \"${model}\", an image model with no frame-prompt profile — it got the generic template (constraint placement / photoreal cue not tuned). Add an ImageModelProfile for this model`,\n });\n }\n}\n\n// Two prompts this similar (Jaccard over their word sets) are the SAME creative — a\n// per-ratio copy, not a second concept. Deliberately high: variants of one concept\n// share wording too, and they're only flagged when the RATIOS also differ.\nconst SAME_CREATIVE_PROMPT_SIMILARITY = 0.6;\n\nfunction promptWordSet(text: string): Set<string> {\n return new Set(\n text\n .toLowerCase()\n .split(/[^a-z0-9']+/)\n .filter((w) => w.length >= 3),\n );\n}\n\nfunction jaccard(a: Set<string>, b: Set<string>): number {\n if (a.size === 0 || b.size === 0) return 0;\n let shared = 0;\n for (const w of a) if (b.has(w)) shared++;\n return shared / (a.size + b.size - shared);\n}\n\ntype FormatRenderNode = { id: string; prompt: string; ratio: string };\n\n/**\n * Groups of `image_generate` nodes that render the SAME creative once per aspect\n * ratio (near-identical prompts, different `aspect_ratio`). Pure, so the clustering\n * is testable on its own. Single-link clustering: any two similar-prompt nodes with\n * different ratios join the same group.\n */\nexport function parallelFormatRenderGroups(nodes: readonly FormatRenderNode[]): FormatRenderNode[][] {\n const parent = nodes.map((_, i) => i);\n const find = (i: number): number => {\n let root = i;\n while (parent[root] !== root) root = parent[root] as number;\n return root;\n };\n const words = nodes.map((n) => promptWordSet(n.prompt));\n for (let i = 0; i < nodes.length; i++) {\n for (let j = i + 1; j < nodes.length; j++) {\n const a = nodes[i] as FormatRenderNode;\n const b = nodes[j] as FormatRenderNode;\n if (a.ratio === b.ratio) continue;\n if (jaccard(words[i] as Set<string>, words[j] as Set<string>) < SAME_CREATIVE_PROMPT_SIMILARITY) continue;\n parent[find(i)] = find(j);\n }\n }\n const groups = new Map<number, FormatRenderNode[]>();\n for (let i = 0; i < nodes.length; i++) {\n const root = find(i);\n const group = groups.get(root) ?? [];\n group.push(nodes[i] as FormatRenderNode);\n groups.set(root, group);\n }\n return [...groups.values()].filter((g) => g.length > 1);\n}\n\n/**\n * The roles of a static ad's own renders (`static-topology.ts`): its variants are one render\n * whatever requests they take, its correction replaces them, each other size is the chosen\n * picture re-laid out for its frame with that picture as the reference. None is an\n * independent render per format.\n */\nconst STATIC_RENDER_ROLES: ReadonlySet<string> = new Set([\n STATIC_VARIANTS_ROLE,\n STATIC_VARIANT_CALL_ROLE,\n STATIC_FIX_ROLE,\n STATIC_ADAPT_FORMAT_ROLE,\n STATIC_PLATE_ROLE,\n]);\n\n/**\n * Advisory: the same creative generated once per placement ratio instead of once,\n * then fanned out. Each render is an independent generation, so the \"same\" ad comes\n * back with different type, crop, and color per format — the set stops looking like\n * one campaign. A render fed a sibling's output (a re-lay) is no exception: it is\n * still a new picture per format. The fix is ONE render and every other ratio made\n * from it (the static scaffold re-lays them out from its chosen picture; anything else ends in a\n * terminal `image_aspect_adapt` node). Read by role, a static ad's variants are one render.\n */\nfunction checkParallelFormatRenders(ctx: LintContext): void {\n const candidates: FormatRenderNode[] = [];\n for (const n of ctx.canvas.nodes) {\n if (n.type !== \"image_generate\" || STATIC_RENDER_ROLES.has(n.tags?.role ?? \"\")) continue;\n const params = n.params as Record<string, unknown> | undefined;\n const prompt = params?.prompt;\n if (typeof prompt !== \"string\" || prompt.length === 0) continue;\n candidates.push({ id: n.id, prompt, ratio: String(params?.aspect_ratio ?? \"(unset)\") });\n }\n if (candidates.length < 2) return;\n for (const group of parallelFormatRenderGroups(candidates)) {\n const ids = group.map((g) => g.id);\n const ratios = [...new Set(group.map((g) => g.ratio))].sort();\n ctx.issues.push({\n path: \"nodes\",\n code: CODES.PARALLEL_FORMAT_RENDERS,\n severity: \"warning\",\n message: `${ids.join(\", \")} render the same creative once per aspect ratio (${ratios.join(\", \")}) — each is an independent generation, so the formats come back with different type, crop, and color and stop reading as one ad. Keep ONE hero render and add a terminal image_aspect_adapt node fed from it (params.formats or params.platform) so every ratio is re-framed from the same image`,\n });\n }\n}\n\nexport const parallelFormatRendersRule: LintRule = {\n name: \"parallel-format-renders\",\n codes: { [CODES.PARALLEL_FORMAT_RENDERS]: \"warning\" },\n check: checkParallelFormatRenders,\n};\n\nexport const imageProfileRule: LintRule = {\n name: \"image-profile\",\n codes: { [CODES.IMAGE_PROFILE_MISSING]: \"warning\" },\n check: checkImageProfile,\n};\n\n/** The renders and files a size's words may be set on: a picture drawn without the ad's words. */\nconst PICTURE_SOURCE_ROLES: ReadonlySet<string> = new Set([\n STATIC_VARIANT_CALL_ROLE,\n STATIC_VARIANTS_ROLE,\n STATIC_FIX_ROLE,\n STATIC_PLATE_ROLE,\n SERIES_LEAD_ROLE,\n]);\n\n/**\n * A size's words (`static_format`) are set on a picture without the ad's words: a variant's\n * picture, its correction, the prefilter's chosen `plate`, a picture extended from it\n * (`static_plate`) or a lead's picture a series ad is made from. Set on a finished ad, its words\n * land on the ad's own.\n */\nfunction checkFormatPlateSource(ctx: LintContext): void {\n for (const n of ctx.canvas.nodes) {\n if (n.type !== \"static_format\") continue;\n const ref = (n.inputs as Record<string, unknown> | undefined)?.plate;\n const from = refNodeOf(ctx, ref);\n if (!from) continue;\n const output = parseRefExpr(String(ref))?.output;\n const ok =\n (from.type === \"static_prefilter\" && output === \"plate\") ||\n from.type === \"static_plate\" ||\n PICTURE_SOURCE_ROLES.has(from.tags?.role ?? \"\");\n if (ok) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}].inputs.plate`,\n code: CODES.FORMAT_PLATE_SOURCE,\n severity: \"error\",\n node_id: n.id,\n message: `\"${n.id}\" sets a size's words on ${String(ref)}, which is not a picture without the ad's words: wire a variant's picture, the prefilter's \\`plate\\`, a \\`static_plate\\` or the correction of the picture`,\n });\n }\n}\n\n/** The steps that re-lay out or place a finished ad: a size cut from a picture never goes through them. */\nconst FINISHED_AD_SIZE_ROLES: ReadonlySet<string> = new Set([\n STATIC_ADAPT_FORMAT_ROLE,\n STATIC_SAFE_FIT_ROLE,\n STATIC_PLACE_ROLE,\n]);\nconst FINISHED_AD_SIZE_TYPES: ReadonlySet<string> = new Set([\"static_safe_fit\", \"static_place\", \"static_extend_merge\"]);\n\n/** A canvas whose sizes are cut from a picture (`static_format`) has no step that re-lays or places a finished ad. */\nfunction checkMixedSizePipeline(ctx: LintContext): void {\n if (!ctx.canvas.nodes.some((n) => n.type === \"static_format\")) return;\n for (const n of ctx.canvas.nodes) {\n if (!FINISHED_AD_SIZE_TYPES.has(n.type) && !FINISHED_AD_SIZE_ROLES.has(n.tags?.role ?? \"\")) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}]`,\n code: CODES.MIXED_SIZE_PIPELINE,\n severity: \"error\",\n node_id: n.id,\n message: `\"${n.id}\" re-lays out or places a finished ad, but this canvas cuts its sizes from one picture and sets their words (static_format): remove it, the size nodes keep their words inside the band themselves`,\n });\n }\n}\n\nexport const formatPlateSourceRule: LintRule = {\n name: \"static-format-plate-source\",\n codes: { [CODES.FORMAT_PLATE_SOURCE]: \"error\" },\n check: checkFormatPlateSource,\n};\n\nexport const mixedSizePipelineRule: LintRule = {\n name: \"static-mixed-size-pipeline\",\n codes: { [CODES.MIXED_SIZE_PIPELINE]: \"error\" },\n check: checkMixedSizePipeline,\n};\n","import { supportsLastFrame } from \"@baker/canvas-contract\";\nimport { clipProfileFor } from \"../../../lib/prompt-profiles.ts\";\nimport type { NodeDecl } from \"../../../schema/canvas.ts\";\nimport { isTagged, type LintContext, type LintRule, onVideoCanvas, refNodeOf, type VideoMetaT } from \"../context.ts\";\n\n// Checks that read one clip's or frame's prompt and params against what its model\n// does with them. The first group runs on ANY canvas (a hand-edited canvas that lost\n// its metadata still gets the prompt/param advisories); the rest only on a canvas\n// carrying a video scaffold's timing plan.\n\nconst CODES = {\n PROMPT_PROFILE_MISSING: \"VIDEO_PROMPT_PROFILE_MISSING\",\n PROMPT_DECISION_MISSING: \"VIDEO_PROMPT_DECISION_MISSING\",\n HOOK_LAYER_MISSING: \"VIDEO_HOOK_LAYER_MISSING\",\n PERSON_GENERATION_MISSING: \"VIDEO_PERSON_GENERATION_MISSING\",\n PROMPT_OVER_BUDGET: \"VIDEO_PROMPT_OVER_BUDGET\",\n RAW_FACE_KEYFRAME: \"VIDEO_RAW_FACE_KEYFRAME\",\n REFERENCE_MISSING: \"VIDEO_REFERENCE_MISSING\",\n MODEL_IGNORES_INPUT: \"VIDEO_MODEL_IGNORES_INPUT\",\n UI_IN_PROMPT: \"VIDEO_UI_IN_PROMPT\",\n BRANDMARK_IN_PROMPT: \"VIDEO_BRANDMARK_IN_PROMPT\",\n} as const;\n\n/**\n * Advisory: a clip on a video model with NO prompt profile was authored with the\n * default Seedance syntax — its dialogue/emotion markup may not carry over (Veo,\n * for one, renders [brackets] as literal text). Review before billing.\n */\nfunction checkPromptProfile(ctx: LintContext): void {\n for (const n of ctx.canvas.nodes) {\n if (n.type !== \"video_generate\") continue;\n const model = (n.params as Record<string, unknown> | undefined)?.model;\n if (typeof model !== \"string\" || clipProfileFor(model)) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}].params.model`,\n code: CODES.PROMPT_PROFILE_MISSING,\n severity: \"warning\",\n node_id: n.id,\n message: `\"${n.id}\" runs on \"${model}\", a model with no clip-prompt profile — its prompt was authored with the default Seedance syntax. Review the dialogue/emotion markup for this model before billing`,\n });\n }\n}\n\n// A clip prompt that made the TECHNIQUE decision names a camera/motion move.\nconst TECHNIQUE_CUE =\n /\\b(camera|push[- ]?in|pull[- ]?out|pan|dolly|zoom|tilt|track|handheld|locked|orbit|crane|whip|motion|move)\\b/i;\n\n// A clip prompt that made the NEGATIVES/constraints decision: Seedance phrases it as an\n// affirmative stability line (\"Keep it clean and stable: …\"), Veo/Kling take a real\n// `negative_prompt` param, and a hand-written prompt may still use a literal `Avoid:` tail.\nconst NEGATIVES_CUE = /\\bavoid:|\\bno subtitles|\\bnegative\\b|keep it clean and stable/i;\n\n// The VIBE layer: lighting / grade / tone words in the hook's frame or clip prompt.\nconst VIBE_CUE =\n /\\b(light|lighting|golden|moody|warm|cool|tone|grade|contrast|shadow|glow|rim|backlit|neon|soft|harsh)\\b/i;\n\n/**\n * Advisory (T3.1): mechanizes the skill's \"six decisions\" (route / spec / beats /\n * copy / technique / negatives) at the two that are checkable from a single clip\n * node — TECHNIQUE (a named camera/motion move) and NEGATIVES (an `Avoid:` line or\n * a `negative_prompt` param). A clip prompt missing BOTH is a thin prompt the model\n * will fill with its own defaults; warn so the operator decides the missing beats.\n * Doctrine: `creative-canvas-ads/references/prompt-anatomy.md`.\n */\nfunction checkPromptDecisions(ctx: LintContext): void {\n for (const n of ctx.canvas.nodes) {\n if (n.type !== \"video_generate\") continue;\n const params = n.params as Record<string, unknown> | undefined;\n const prompt = typeof params?.prompt === \"string\" ? params.prompt : \"\";\n if (!prompt) continue;\n const hasTechnique = TECHNIQUE_CUE.test(prompt);\n const hasNegatives = NEGATIVES_CUE.test(prompt) || typeof params?.negative_prompt === \"string\";\n if (hasTechnique || hasNegatives) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}].params.prompt`,\n code: CODES.PROMPT_DECISION_MISSING,\n severity: \"warning\",\n node_id: n.id,\n message: `\"${n.id}\" is a thin clip prompt — it names no camera/motion move (TECHNIQUE) and no constraints (NEGATIVES: an affirmative \"Keep it clean and stable\" line, a negative_prompt param, or an \"Avoid:\" tail). Make the six decisions (route / spec / beats / copy / technique / negatives) so the model doesn't fill the gaps with drift. See prompt-anatomy.md`,\n });\n }\n}\n\n/**\n * Advisory (T3.1): a strong hook works on all FOUR layers — text (overlay), sound\n * (line/SFX), visual (the frame), vibe (lighting+tone). This scans scene 0's nodes\n * and warns when two or more layers are absent, so a bare hook doesn't ship. Only\n * fires on scene-based video canvases (a node tagged scene 0, or on an untagged canvas\n * a node id starting `s0`). Doctrine:\n * `creative-canvas-ads/references/hook-craft.md`.\n */\nfunction checkHookLayers(ctx: LintContext): void {\n const scene0 = isTagged(ctx)\n ? ctx.canvas.nodes.filter((n) => n.tags?.scene === 0)\n : ctx.canvas.nodes.filter((n) => /^s0(?:[_a-z0-9])*_/.test(n.id) || n.id === \"s0\");\n const hookClip = scene0.find((n) => n.type === \"video_generate\");\n if (!hookClip) return;\n const scene0Text = scene0\n .map((n) => {\n const p = (n.params as Record<string, unknown> | undefined)?.prompt;\n return typeof p === \"string\" ? p : \"\";\n })\n .join(\"\\n\");\n const hookParams = hookClip.params as Record<string, unknown> | undefined;\n\n const hasOverlayLayer = ctx.canvas.nodes.some((n) => /hyperframe/.test(n.type));\n const hasSound =\n hookParams?.generate_audio === true ||\n /Dialogue:|Audio:/.test(scene0Text) ||\n ctx.canvas.nodes.some((n) => n.type === \"tts\" || n.type === \"dialogue\" || n.type === \"music\");\n const hasVisual = scene0Text.trim().length > 40;\n const hasVibe = VIBE_CUE.test(scene0Text);\n\n const missing: string[] = [];\n if (!hasOverlayLayer) missing.push(\"text (overlay)\");\n if (!hasSound) missing.push(\"sound (line/SFX)\");\n if (!hasVisual) missing.push(\"visual (the frame)\");\n if (!hasVibe) missing.push(\"vibe (lighting/tone)\");\n if (missing.length < 2) return;\n\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(hookClip.id) ?? -1}]`,\n code: CODES.HOOK_LAYER_MISSING,\n severity: \"warning\",\n node_id: hookClip.id,\n message: `the hook (scene 0) is thin across layers — missing ${missing.join(\", \")}. A scroll-stopping hook works on all four layers (text / sound / visual / vibe); strengthen the missing ones. See hook-craft.md`,\n });\n}\n\n/** Advisory: a Veo image-to-video clip must set `person_generation` (only `allow_adult`\n * is legal for image-driven modes, and the sole legal value in the EU/UK). */\nfunction checkPersonGeneration(ctx: LintContext): void {\n for (const n of ctx.canvas.nodes) {\n if (n.type !== \"video_generate\") continue;\n const params = n.params as Record<string, unknown> | undefined;\n const model = params?.model;\n if (clipProfileFor(typeof model === \"string\" ? model : \"\")?.id !== \"veo\") continue;\n const hasKeyframe = Boolean(n.inputs?.first_frame ?? n.inputs?.reference);\n if (!hasKeyframe || params?.person_generation) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}].params`,\n code: CODES.PERSON_GENERATION_MISSING,\n severity: \"warning\",\n node_id: n.id,\n message: `Veo clip \"${n.id}\" drives from a keyframe but sets no person_generation — set \"allow_adult\" (the only legal value for image-to-video, and the only one allowed in the EU/UK)`,\n });\n }\n}\n\n/** Advisory: a clip prompt runs past the model's quality word budget — long prompts\n * pack conflicting instructions and the model starts dropping beats. */\nfunction checkPromptBudget(ctx: LintContext): void {\n for (const n of ctx.canvas.nodes) {\n if (n.type !== \"video_generate\") continue;\n const params = n.params as Record<string, unknown> | undefined;\n const model = params?.model;\n const prompt = params?.prompt;\n const profile = typeof model === \"string\" ? clipProfileFor(model) : undefined;\n if (!profile || typeof prompt !== \"string\") continue;\n const words = prompt.trim().split(/\\s+/).filter(Boolean).length;\n if (words <= profile.wordBudget) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}].params.prompt`,\n code: CODES.PROMPT_OVER_BUDGET,\n severity: \"warning\",\n node_id: n.id,\n message: `\"${n.id}\" prompt is ${words} words — over ${model}'s ~${profile.wordBudget}-word budget; trim it (the frames carry the content, so keep the clip prompt to motion + audio)`,\n });\n }\n}\n\n/** Advisory: a Seedance image-to-video clip whose first frame is a RAW ingested image\n * (reuse mode, or a dropped photo) rather than a generated frame. If it contains a real\n * human face, ByteDance's real-person filter rejects it (a non-retryable 422) — the fix\n * is an AI-generated portrait keyframe (recast), or route the clip to Veo. */\nfunction checkRawFaceKeyframe(ctx: LintContext): void {\n for (const n of ctx.canvas.nodes) {\n if (n.type !== \"video_generate\") continue;\n const model = (n.params as Record<string, unknown> | undefined)?.model;\n if (clipProfileFor(typeof model === \"string\" ? model : \"\")?.id !== \"seedance\") continue;\n const src = refNodeOf(ctx, n.inputs?.first_frame ?? n.inputs?.reference);\n if (src?.type !== \"ingest\") continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}].inputs.first_frame`,\n code: CODES.RAW_FACE_KEYFRAME,\n severity: \"warning\",\n node_id: n.id,\n message: `Seedance clip \"${n.id}\" animates a RAW ingested image (\"${src.id}\"), not a generated frame — if it shows a real human face, ByteDance's real-person filter rejects it (422). Anchor on an AI-generated portrait (recast), or route this clip to Veo`,\n });\n }\n}\n\n// Type-noun synonyms per element type — the low-false-positive nouns whose presence\n// in a frame description strongly implies the element is on screen. Person is\n// deliberately excluded: pronouns/role-words are too noisy and identity is already\n// locked by the multi-view sheet.\nconst ELEMENT_TYPE_KEYWORDS: Record<string, string[]> = {\n animal: [\"dog\", \"puppy\", \"pup\", \"cat\", \"kitten\", \"kitty\", \"pet\", \"canine\", \"feline\"],\n logo: [\"logo\", \"wordmark\"],\n badge: [\"badge\", \"seal\"],\n product: [],\n};\n\nconst CHECKED_ELEMENT_TYPES = new Set(Object.keys(ELEMENT_TYPE_KEYWORDS));\n\n// Tokens too generic to signal a specific element in a frame description.\nconst KEYWORD_STOPWORDS = new Set([\n \"the\",\n \"and\",\n \"with\",\n \"for\",\n \"brand\",\n \"logo\",\n \"image\",\n \"shot\",\n \"main\",\n \"hero\",\n \"element\",\n \"product\",\n \"reference\",\n]);\n\n/** Significant lowercase tokens (len ≥ 3, non-stopword) of a label/description. */\nfunction keywordTokens(text: string | undefined): string[] {\n if (!text) return [];\n return text\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((t) => t.length >= 3 && !KEYWORD_STOPWORDS.has(t));\n}\n\n/**\n * The keyword set that, in a frame description, implies an element of this\n * type/label/description is on screen. Shared with the scaffold's wiring pass so a\n * frame the validator would flag is wired by construction (same matcher both sides).\n */\nexport function elementMentionKeywords(el: { type: string; label?: string; description?: string }): string[] {\n const typeWords = ELEMENT_TYPE_KEYWORDS[el.type.toLowerCase()] ?? [];\n return [...new Set([...typeWords, ...keywordTokens(el.label), ...keywordTokens(el.description)])];\n}\n\ntype VideoElement = NonNullable<VideoMetaT[\"elements\"]>[number];\n\n/** The keyword set that, in a frame description, implies this element is on screen. */\nfunction keywordsForElement(el: VideoElement): string[] {\n return elementMentionKeywords(el);\n}\n\n/** Does `text` contain `word` as a whole word (avoids \"cat\" ⊂ \"category\")? */\nfunction containsWord(text: string, word: string): boolean {\n const esc = word.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(`\\\\b${esc}\\\\b`, \"i\").test(text);\n}\n\n/**\n * Advisory (§13, the wrong-dog defect): every `image_generate` frame whose FRAME\n * DESCRIPTION plausibly includes a recurring element (a pet, product, logo, badge)\n * must wire that element's reference. When it doesn't, the frame model has nothing to\n * lock the element's identity to — its own system prompt forbids trusting prose — so\n * it invents a generic one (a different breed of dog). Scoped to non-person elements,\n * where a keyword→missing-ref match is high-signal; person identity is sheet-backed.\n */\ntype KeywordedElement = { el: VideoElement; keywords: string[] };\n\n// The scaffold's frame prompts wrap the editable FRAME DESCRIPTION in boilerplate\n// that itself mentions element keywords (\"If a reference image (a logo, a desk…)\",\n// \"do not invent brand logos\") — matching the whole prompt false-positived on every\n// scaffolded frame. Only the description between these markers is the frame's OWN\n// content; a hand-authored prompt (no marker) is matched whole.\nconst FRAME_DESCRIPTION_START = \"FRAME DESCRIPTION (this frame's editable prompt):\";\n\nconst FRAME_DESCRIPTION_END = \"Render exactly what the FRAME DESCRIPTION\";\n\nexport function frameDescriptionOf(prompt: string): string {\n const i = prompt.indexOf(FRAME_DESCRIPTION_START);\n if (i < 0) return prompt;\n const rest = prompt.slice(i + FRAME_DESCRIPTION_START.length);\n const j = rest.indexOf(FRAME_DESCRIPTION_END);\n return j < 0 ? rest : rest.slice(0, j);\n}\n\n/** Warn for each keyworded element a frame describes but doesn't wire. */\nfunction checkFrameReferences(ctx: LintContext, node: NodeDecl, index: number, keyworded: KeywordedElement[]): void {\n const rawPrompt = (node.params as Record<string, unknown> | undefined)?.prompt;\n if (typeof rawPrompt !== \"string\" || rawPrompt.length === 0) return;\n const prompt = frameDescriptionOf(rawPrompt);\n const inputsBlob = JSON.stringify(node.inputs ?? {});\n for (const { el, keywords } of keyworded) {\n if (inputsBlob.includes(el.ref)) continue; // element already wired on this frame\n const hit = keywords.find((kw) => containsWord(prompt, kw));\n if (!hit) continue;\n ctx.issues.push({\n path: `nodes[${index}].inputs.reference`,\n code: CODES.REFERENCE_MISSING,\n severity: \"warning\",\n message: `frame \"${node.id}\" describes a \"${hit}\" but the \"${el.label}\" reference (${el.ref}) isn't wired on this node — the generator will invent a wrong-identity ${el.type} from prose. Add ${el.ref} to inputs.reference`,\n node_id: node.id,\n node_type: node.type,\n });\n }\n}\n\nfunction checkReferenceCompleteness(ctx: LintContext, meta: VideoMetaT): void {\n const elements = (meta.elements ?? []).filter((el) => CHECKED_ELEMENT_TYPES.has(el.type.toLowerCase()));\n const keyworded = elements\n .map((el) => ({ el, keywords: keywordsForElement(el) }))\n .filter((e) => e.keywords.length > 0);\n if (keyworded.length === 0) return;\n\n // A picture a reference sheet is fused from (an invented person's portrait) is an\n // element's source, not a scene frame: it shows that one subject alone, so it wires no\n // logo, product or pet by design.\n const sheetSources = JSON.stringify(\n ctx.canvas.nodes.filter((n) => n.type === \"image_reference_sheet\").map((n) => n.inputs ?? {}),\n );\n for (let i = 0; i < ctx.canvas.nodes.length; i++) {\n const n = ctx.canvas.nodes[i];\n if (n?.type !== \"image_generate\" || sheetSources.includes(`\"$ref:${n.id}.`)) continue;\n checkFrameReferences(ctx, n, i, keyworded);\n }\n}\n\n/**\n * Advisory: a clip wiring a `last_frame` into a model that takes only ONE\n * conditioning image (Omni — its Interactions API has no end-keyframe concept), so\n * the backend drops the second frame. The canvas still renders, which is exactly\n * the problem: the author paid to GENERATE that keyframe image and it silently does\n * nothing. Free to catch here, a billed image per clip to discover afterwards.\n */\nfunction checkUnusableLastFrame(ctx: LintContext): void {\n for (const n of ctx.canvas.nodes) {\n if (n.type !== \"video_generate\") continue;\n const model = (n.params as Record<string, unknown> | undefined)?.model;\n if (typeof model !== \"string\" || supportsLastFrame(model)) continue;\n const inputs = n.inputs as Record<string, unknown> | undefined;\n if (!inputs?.last_frame) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}].inputs.last_frame`,\n code: CODES.MODEL_IGNORES_INPUT,\n severity: \"warning\",\n node_id: n.id,\n node_type: \"video_generate\",\n message: `\"${n.id}\" wires a last_frame but runs on ${model}, which takes only ONE conditioning image — the end keyframe is dropped and the image generated for it is wasted. Drop the last_frame, or move this clip to Veo/Seedance, which honour both frames`,\n });\n }\n}\n\n// A screen/UI surface narrated in a video_generate prompt: a generative model garbles\n// UI text and brand chrome, so a screen surface must be composited as a REAL asset on\n// the overlay layer, never described into a clip. Narrow on purpose (screen-recording\n// language, not any mention of a phone) — advisory, not blocking.\nconst UI_IN_PROMPT_RE =\n /\\bscreen[- ]?(?:recording|capture|grab|share)\\b|\\bapp (?:interface|screen)\\b|\\bphone screen overlay\\b/i;\n\n/** Advisory: a clip prompt asking the video model to render a screen/UI surface. */\nfunction checkUiInPrompt(ctx: LintContext): void {\n for (const n of ctx.canvas.nodes) {\n if (n.type !== \"video_generate\") continue;\n const prompt = (n.params as Record<string, unknown> | undefined)?.prompt;\n if (typeof prompt !== \"string\" || !UI_IN_PROMPT_RE.test(prompt)) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}].params.prompt`,\n code: CODES.UI_IN_PROMPT,\n severity: \"warning\",\n message: `\"${n.id}\" asks the video model to render a screen/UI surface — generative video garbles UI text and chrome. Composite the real screen on the overlay layer (screenshot / brand HTML) and keep this prompt to the background plate`,\n node_id: n.id,\n node_type: \"video_generate\",\n });\n }\n}\n\n// A brand mark REQUESTED as picture content: \"…logo overlay/animation/sting\", or a\n// named third-party mark. A logo merely worn/present in the filmed scene (on a polo,\n// a storefront) is part of the picture and stays — the pattern needs the mark to be\n// the rendered element itself. Generative models garble wordmarks, and a real mark\n// belongs on the overlay layer as a sourced asset. Advisory, not blocking.\nconst BRANDMARK_IN_PROMPT_RE =\n /\\b(?:logo|wordmark) (?:overlay|animation|sting|card|reveal)\\b|\\b(?:google|facebook|instagram|tiktok|youtube|amazon|apple|microsoft|whatsapp|netflix|spotify|excel|trustpilot) (?:logo|wordmark|branding)\\b/i;\n\n/** Advisory: a generate prompt asking the model to paint a brand logo/wordmark. */\nfunction checkBrandmarkInPrompt(ctx: LintContext): void {\n for (const n of ctx.canvas.nodes) {\n if (n.type !== \"video_generate\" && n.type !== \"image_generate\") continue;\n const prompt = (n.params as Record<string, unknown> | undefined)?.prompt;\n if (typeof prompt !== \"string\" || !BRANDMARK_IN_PROMPT_RE.test(prompt)) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}].params.prompt`,\n code: CODES.BRANDMARK_IN_PROMPT,\n severity: \"warning\",\n message: `\"${n.id}\" asks the model to render a brand logo/wordmark — generation garbles marks and third-party logos carry IP exposure. Source the real mark (baker images logo <domain>) and composite it on the overlay layer`,\n node_id: n.id,\n node_type: n.type,\n });\n }\n}\n\nexport const promptProfileRule: LintRule = {\n name: \"video-prompt-profile\",\n codes: { [CODES.PROMPT_PROFILE_MISSING]: \"warning\" },\n check: checkPromptProfile,\n};\n\nexport const personGenerationRule: LintRule = {\n name: \"video-person-generation\",\n codes: { [CODES.PERSON_GENERATION_MISSING]: \"warning\" },\n check: checkPersonGeneration,\n};\n\nexport const promptBudgetRule: LintRule = {\n name: \"video-prompt-budget\",\n codes: { [CODES.PROMPT_OVER_BUDGET]: \"warning\" },\n check: checkPromptBudget,\n};\n\nexport const rawFaceKeyframeRule: LintRule = {\n name: \"video-raw-face-keyframe\",\n codes: { [CODES.RAW_FACE_KEYFRAME]: \"warning\" },\n check: checkRawFaceKeyframe,\n};\n\nexport const promptDecisionsRule: LintRule = {\n name: \"video-prompt-decisions\",\n codes: { [CODES.PROMPT_DECISION_MISSING]: \"warning\" },\n check: checkPromptDecisions,\n};\n\nexport const hookLayersRule: LintRule = {\n name: \"video-hook-layers\",\n codes: { [CODES.HOOK_LAYER_MISSING]: \"warning\" },\n check: checkHookLayers,\n};\n\n/** No clip prompt should narrate a screen/UI surface (garbled UI). */\nexport const uiInPromptRule: LintRule = {\n name: \"video-ui-in-prompt\",\n codes: { [CODES.UI_IN_PROMPT]: \"warning\" },\n check: onVideoCanvas((ctx) => checkUiInPrompt(ctx)),\n};\n\n/** No generate prompt should request a brand logo/wordmark as content. */\nexport const brandmarkInPromptRule: LintRule = {\n name: \"video-brandmark-in-prompt\",\n codes: { [CODES.BRANDMARK_IN_PROMPT]: \"warning\" },\n check: onVideoCanvas((ctx) => checkBrandmarkInPrompt(ctx)),\n};\n\n/**\n * A frame that describes a recurring element (a pet, product, logo) must WIRE that\n * element's reference, or the generator invents a wrong-identity one.\n */\nexport const referenceCompletenessRule: LintRule = {\n name: \"video-reference-completeness\",\n codes: { [CODES.REFERENCE_MISSING]: \"warning\" },\n check: onVideoCanvas(checkReferenceCompleteness),\n};\n\nexport const unusableLastFrameRule: LintRule = {\n name: \"video-unusable-last-frame\",\n codes: { [CODES.MODEL_IGNORES_INPUT]: \"warning\" },\n check: onVideoCanvas((ctx) => checkUnusableLastFrame(ctx)),\n};\n","import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { maxClipSeconds, supportsParam } from \"@baker/canvas-contract\";\n// The Dialogue-marker parser lives with the prompt profiles so the emitter and this\n// validator can never drift on the parse contract.\nimport { nativeDialogueOf } from \"../../../lib/prompt-profiles.ts\";\nimport { NATIVE_CLIP_WORDS_PER_SECOND, OBSERVED_WPS_MAX, OBSERVED_WPS_MIN, wordCount } from \"../../../lib/speech.ts\";\nimport { parseSpineInputLens } from \"../../../lib/spine-input.ts\";\nimport type { Canvas, NodeDecl } from \"../../../schema/canvas.ts\";\nimport type { StaticTiming } from \"../../define.ts\";\nimport type { ValidationIssue } from \"../../errors.ts\";\nimport {\n type DeepLintRule,\n isTagged,\n type LintContext,\n type LintRule,\n onVideoCanvas,\n refNodeOf,\n type VideoMetaT,\n} from \"../context.ts\";\n\n// Whole-canvas video invariants, proven STATICALLY from the timing plan a video\n// scaffold records in `metadata.video` (per-node `validateExtra` can't see across\n// nodes). These catch the failure modes that otherwise only surface after a\n// ~50cr/clip render: voiceover turns playing on top of each other, an audio mix\n// that runs well past the picture, and a talking subject whose clip was never\n// natively voiced. Silent when no `metadata.video` is present (non-video canvases).\n\nconst CODES = {\n VO_OVERLAP: \"VIDEO_VO_OVERLAP\",\n AUDIO_DURATION: \"VIDEO_AUDIO_DURATION\",\n LIPSYNC_MISSING: \"VIDEO_LIPSYNC_MISSING\",\n SPEECH_OVERRUN: \"VIDEO_SPEECH_OVERRUN\",\n SPEECH_EXCEEDS_EXTRACT: \"VIDEO_SPEECH_EXCEEDS_EXTRACT\",\n ASPECT_MISMATCH: \"VIDEO_ASPECT_MISMATCH\",\n SPAN_EXCEEDS_MODEL: \"VIDEO_SPAN_EXCEEDS_MODEL\",\n TIMELINE_TOTAL: \"VIDEO_TIMELINE_TOTAL_MISMATCH\",\n NATIVE_SEG_OVERLAP: \"VIDEO_NATIVE_SEG_OVERLAP\",\n SPINE_UNNORMALIZED: \"VIDEO_SPINE_UNNORMALIZED\",\n ODD_DIMENSIONS: \"VIDEO_ODD_DIMENSIONS\",\n REGION_DROPPED: \"VIDEO_REGION_DROPPED\",\n OVERLAY_OUT_OF_BOUNDS: \"VIDEO_OVERLAY_OUT_OF_BOUNDS\",\n} as const;\n\n// A clip span may sit a hair above a model's max after rounding; only warn on a real gap.\nconst SPAN_MODEL_SLACK_S = 0.25;\n\n// A voiceover turn may legitimately spill slightly past the next turn's start (tts\n// length is approximate), and the audio mix may run a touch past the video. Only\n// flag clear breakage beyond this slack.\nconst VIDEO_TIME_SLACK_S = 0.75;\n\n// Conversational speech pace used to estimate a native line's spoken length from its\n// word count: the scaffold's own planning rate (`NATIVE_CLIP_WORDS_PER_SECOND`). The\n// overrun ratio is deliberately LOOSER than the scaffold's 1.3 advisory: word count is\n// the only signal here (no real timings survive a script re-craft), and real fast UGC\n// speech runs 3.5–4 words/s, so flagging above 2.5×1.6 = 4 words/s catches only lines\n// that physically cannot fit their clip (the audit's 4.3 w/s render-killer) without\n// false-positives on energetic-but-renderable reads.\n\nconst SPEECH_OVERRUN_RATIO = 1.6;\n\n/** The duration an ffmpeg node's output carries: the LAST `-t` value in its args. */\nexport function ffmpegTrimSeconds(node: NodeDecl): number | null {\n const args = (node.params as Record<string, unknown> | undefined)?.args;\n if (!Array.isArray(args)) return null;\n let t: number | null = null;\n for (let i = 0; i < args.length - 1; i++) {\n if (args[i] === \"-t\") {\n const v = Number(args[i + 1]);\n if (Number.isFinite(v)) t = v;\n }\n }\n return t;\n}\n\n/**\n * A node's on-timeline video duration, recomputed from the LIVE graph: an ffmpeg\n * trim's `-t`, a `video_generate`'s `duration` param, or — for a composite/passthrough\n * ffmpeg with no `-t` — its first video input's duration (bounded recursion). Null\n * when the graph doesn't say (the caller skips the check rather than guessing).\n */\nfunction liveNodeDurationS(ctx: LintContext, node: NodeDecl | null, depth = 0): number | null {\n if (!node || depth > 3) return null;\n if (node.type === \"video_generate\") {\n const d = (node.params as Record<string, unknown> | undefined)?.duration;\n return typeof d === \"number\" ? d : null;\n }\n if (node.type === \"ffmpeg\") {\n const t = ffmpegTrimSeconds(node);\n if (t !== null) return t;\n for (const v of Object.values(node.inputs ?? {})) {\n const upstream = refNodeOf(ctx, v);\n const d = liveNodeDurationS(ctx, upstream, depth + 1);\n if (d !== null) return d;\n }\n return null;\n }\n return null;\n}\n\n/**\n * The seeded overlay windows in a composition's index.html, flagged when they run\n * past the video end. An out-of-bounds element simply never hides — the \"stuck last\n * overlay\" render bug — and re-timed scenes are exactly when it happens. Pure.\n */\nexport function overlayTimingIssues(html: string, durationS: number): Array<{ start: number; dur: number }> {\n const out: Array<{ start: number; dur: number }> = [];\n for (const m of html.matchAll(/<[^>]*\\bdata-start=\"([\\d.]+)\"[^>]*\\bdata-dur=\"([\\d.]+)\"[^>]*>/g)) {\n const start = Number(m[1]);\n const dur = Number(m[2]);\n if (!Number.isFinite(start) || !Number.isFinite(dur)) continue;\n if (start >= durationS || start + dur > durationS + 0.25) out.push({ start, dur });\n }\n return out;\n}\n\n/** Deep advisory: every hyperframe composition's seeded overlay windows fit the video. */\nasync function checkOverlayTimingBounds(canvas: Canvas, issues: ValidationIssue[]): Promise<void> {\n const durationS = canvas.metadata?.video?.duration_s;\n if (typeof durationS !== \"number\") return;\n for (let i = 0; i < canvas.nodes.length; i++) {\n const n = canvas.nodes[i];\n if (n?.type !== \"hyperframe_render\") continue;\n const composition = (n.params as Record<string, unknown> | undefined)?.composition;\n if (typeof composition !== \"string\" || !path.isAbsolute(composition)) continue;\n const html = await readFile(path.join(composition, \"index.html\"), \"utf8\").catch(() => null);\n if (!html) continue;\n for (const w of overlayTimingIssues(html, durationS)) {\n issues.push({\n path: `nodes[${i}].params.composition`,\n code: CODES.OVERLAY_OUT_OF_BOUNDS,\n severity: \"warning\",\n node_id: n.id,\n node_type: n.type,\n message: `an overlay in ${path.basename(composition)}/index.html runs [${w.start}s, ${w.start + w.dur}s] but the video ends at ${durationS}s — it never hides on screen. Re-time its data-start/data-dur to fit the video`,\n });\n }\n }\n}\n\n/**\n * A scene's generated clips: every `video_generate` tagged with the scene, or on an\n * untagged canvas the full-frame `s<scene>_clip` and region `s<scene>_r<n>_clip` ids.\n */\nfunction sceneClips(ctx: LintContext, scene: number): NodeDecl[] {\n if (isTagged(ctx)) return ctx.canvas.nodes.filter((n) => n.type === \"video_generate\" && n.tags?.scene === scene);\n const nativeClipRe = new RegExp(`^s${scene}(_r\\\\d+)?_clip$`);\n return ctx.canvas.nodes.filter((n) => nativeClipRe.test(n.id) && n.type === \"video_generate\");\n}\n\ntype TalkingSceneEntry =\n | number\n | { scene: number; voice_convert_node: string; est_speech_s?: number; speech_words?: number }\n | { scene: number; lipsync_node: string };\n\n/**\n * Does the scene's native clip audio (or its extraction) reach the audio mix\n * directly, without the STS convert node? This is the valid fallback config when\n * the one-brand-voice convert chain is intentionally bypassed: the native clip\n * already carries lip-matched speech, so routing it straight to the mix keeps the\n * lips correct (only brand-voice normalization is given up). Accepts the scene's\n * voice extract or clip audio (by tag; untagged canvases by the `s<scene>_voextract` /\n * `s<scene>_clip` / region-clip ids) wired into any `audio_timeline`.\n */\nfunction nativeAudioReachesMix(ctx: LintContext, scene: number): boolean {\n if (isTagged(ctx)) {\n return ctx.canvas.nodes.some(\n (n) =>\n n.type === \"audio_timeline\" &&\n Object.values(n.inputs ?? {}).some((v) => {\n const source = refNodeOf(ctx, v);\n return source?.tags?.scene === scene && (source.tags.role === \"voice_extract\" || source.tags.role === \"clip\");\n }),\n );\n }\n const wanted = [\n `$ref:s${scene}_voextract.audio`,\n `$ref:s${scene}_clip.audio`,\n new RegExp(`\\\\$ref:s${scene}_r\\\\d+_(voextract|clip)\\\\.audio`),\n ];\n return ctx.canvas.nodes.some((n) => {\n if (n.type !== \"audio_timeline\") return false;\n const blob = JSON.stringify(n.inputs ?? {});\n return wanted.some((w) => (typeof w === \"string\" ? blob.includes(w) : w.test(blob)));\n });\n}\n\n/**\n * Is a single-on-camera-speaker scene correctly voiced? Native scaffold output\n * (`{ scene, voice_convert_node }`) requires the clip to carry native audio\n * (`generate_audio: true`) — the invariant that keeps lips matched — AND that the\n * native audio reaches the mix, EITHER through the `audio_voice_convert` node\n * (one-brand-voice, the default) OR routed directly (native-audio fallback).\n * Legacy veed forms (`{ scene, lipsync_node }` / bare index) require a\n * `video_lipsync` node.\n */\nfunction talkingSceneSatisfied(ctx: LintContext, entry: TalkingSceneEntry, scene: number): boolean {\n const nodes = ctx.canvas.nodes;\n if (typeof entry === \"object\" && \"voice_convert_node\" in entry) {\n // The scene's native clip is its full-frame clip, or the PRESENTER region's clip\n // for a composited scene: either one carrying the generated speech is what the\n // voice-convert node re-voices.\n const clipNativeAudio = sceneClips(ctx, scene).some((n) => {\n const params = n.params as Record<string, unknown> | undefined;\n // A model with no audio toggle renders speech unconditionally, so an ABSENT\n // `generate_audio` is a satisfied requirement there, not a missing one —\n // demanding `=== true` would fail every talking scene on the default model,\n // which cannot express the flag at all.\n if (typeof params?.model === \"string\" && !supportsParam(\"video_generate\", params.model, \"generate_audio\")) {\n return true;\n }\n return params?.generate_audio === true;\n });\n const converted = nodes.some((n) => n.id === entry.voice_convert_node && n.type === \"audio_voice_convert\");\n return clipNativeAudio && (converted || nativeAudioReachesMix(ctx, scene));\n }\n if (typeof entry === \"object\") {\n return nodes.some((n) => n.id === entry.lipsync_node && n.type === \"video_lipsync\");\n }\n return nodes.some((n) => {\n if (n.type !== \"video_lipsync\") return false;\n const video = (n.inputs as Record<string, unknown>)?.video;\n return video === `$ref:s${scene}_trim.video` || video === `$ref:s${scene}_clip.video`;\n });\n}\n\n// Deep enough to size a typed spine's clip through a passthrough composite to its\n// generated clip, the same reach the legacy spine sizing has.\nconst TIMING_MAX_DEPTH = 4;\n\n/**\n * A node's static timing, when its definition declares one: the node's own params\n * plus the timing of everything wired into it, computed without running anything.\n * Upstream nodes without a hook are sized the legacy way (a `video_generate`'s\n * duration, an ffmpeg `-t`). Null when the node has no hook or its params don't parse.\n */\nfunction typedTiming(ctx: LintContext, node: NodeDecl, depth = 0): StaticTiming | null {\n const def = ctx.registry.get(node.type);\n if (!def?.staticTiming || depth > TIMING_MAX_DEPTH) return null;\n const parsed = def.params.safeParse(node.params ?? {});\n if (!parsed.success) return null;\n const inputs: Record<string, StaticTiming> = {};\n for (const [slot, value] of Object.entries(node.inputs ?? {})) {\n const upstream = refNodeOf(ctx, value);\n if (!upstream) continue;\n const timing = typedTiming(ctx, upstream, depth + 1) ?? legacyTiming(ctx, upstream);\n if (timing) inputs[slot] = timing;\n }\n return def.staticTiming({ params: parsed.data, inputs });\n}\n\nfunction legacyTiming(ctx: LintContext, node: NodeDecl): StaticTiming | null {\n const d = liveNodeDurationS(ctx, node);\n return d === null ? null : { duration_s: d };\n}\n\n/** The spine: the stamped node, else the node tagged as the spine, else the legacy `spine` id. */\nfunction spineIdOf(ctx: LintContext, meta: VideoMetaT): string | null {\n if (meta.timeline?.spine_node) return meta.timeline.spine_node;\n const tagged = ctx.canvas.nodes.find((n) => n.tags?.role === \"spine\");\n if (tagged) return tagged.id;\n return ctx.idToIndex.has(\"spine\") ? \"spine\" : null;\n}\n\n/** The spine's LIVE total: Σ input clip durations, minus any xfade overlap it eats. */\nfunction spineTotalS(ctx: LintContext, spine: NodeDecl): number | null {\n let total = 0;\n const inputs = Object.entries(spine.inputs ?? {}).filter(([k]) => /^c\\d+$/.test(k));\n if (inputs.length === 0) return null;\n // The spine's own per-input chain is the authority when it absorbs a length (a\n // trim= cut or a looped still's input-side -t — spine-input.ts); only an input\n // with no absorbed length falls back to sizing the upstream node.\n const rawArgs = (spine.params as Record<string, unknown>).args;\n const absorbed = Array.isArray(rawArgs) ? parseSpineInputLens(rawArgs.map(String)) : new Map<number, number>();\n for (const [k, v] of inputs) {\n const inputIdx = Number(k.slice(1));\n const d = absorbed.get(inputIdx) ?? liveNodeDurationS(ctx, refNodeOf(ctx, v));\n if (d === null) return null; // an input the graph can't size — skip, don't guess\n total += d;\n }\n const graph = ((spine.params as Record<string, unknown>).args as unknown[])?.join?.(\" \") ?? \"\";\n for (const m of String(graph).matchAll(/xfade=transition=[^:]+:duration=([\\d.]+)/g)) {\n total -= Number(m[1]);\n }\n return total;\n}\n\n/**\n * The one-clock length gate: the spine's live total, every per-speaker voice track,\n * and the final mix must all equal the stamped `expected_total_s` — a mismatch means\n * `-shortest` truncates real content (a cut CTA) with no error at render time.\n */\nfunction checkTimelineContract(ctx: LintContext, meta: VideoMetaT): void {\n const stamp = meta.timeline;\n const spineId = spineIdOf(ctx, meta);\n if (!spineId) return;\n const expected = stamp?.expected_total_s ?? meta.duration_s;\n checkSpineTotal(ctx, spineId, expected);\n checkAudioTimelineTotals(ctx, stamp?.audio_mix_node, expected);\n}\n\n/** The spine's live summed length must equal the stamped total. */\nfunction checkSpineTotal(ctx: LintContext, spineId: string, expected: number): void {\n const spineIdx = ctx.idToIndex.get(spineId);\n const spine = spineIdx === undefined ? undefined : ctx.canvas.nodes[spineIdx];\n if (!spine || spineIdx === undefined) return;\n if (ctx.registry.get(spine.type)?.staticTiming) {\n checkTypedSpineTotal(ctx, spine, spineIdx, expected);\n return;\n }\n const spineLen = spineTotalS(ctx, spine);\n if (spineLen === null || Math.abs(spineLen - expected) <= VIDEO_TIME_SLACK_S) return;\n ctx.issues.push({\n path: `nodes[${spineIdx}].params.args`,\n code: CODES.TIMELINE_TOTAL,\n node_id: spineId,\n message: `the picture sums to ${round2(spineLen)}s but the timeline is pinned to ${expected}s — \\`-shortest\\` at the final mux will silently cut the longer stream. Re-time the seg trims (or the audio total_ms) so both match`,\n });\n}\n\n/** A typed spine's length comes from its own params (and its sized inputs), not argv. */\nfunction checkTypedSpineTotal(ctx: LintContext, spine: NodeDecl, spineIdx: number, expected: number): void {\n const spineLen = typedTiming(ctx, spine)?.duration_s;\n if (spineLen === undefined || Math.abs(spineLen - expected) <= VIDEO_TIME_SLACK_S) return;\n ctx.issues.push({\n path: `nodes[${spineIdx}].params.clips`,\n code: CODES.TIMELINE_TOTAL,\n node_id: spine.id,\n message: `the picture sums to ${round2(spineLen)}s but the timeline is pinned to ${expected}s. The final mux ends at the shorter stream and silently cuts the longer one. Re-time the clips' duration_s (or the audio total_ms) so both match`,\n });\n}\n\n/**\n * Full-length audio timelines must equal the stamped total: the mix, plus every\n * per-speaker voice track (their absolute placement collapses if the track isn't\n * timeline-length).\n */\nfunction checkAudioTimelineTotals(ctx: LintContext, audioMixNode: string | undefined, expected: number): void {\n const mustBeFullLength = new Set<string>();\n if (audioMixNode) mustBeFullLength.add(audioMixNode);\n ctx.canvas.nodes.forEach((n) => {\n if (n.type !== \"audio_voice_convert\") return;\n const track = refNodeOf(ctx, n.inputs?.audio);\n if (track?.type === \"audio_timeline\") mustBeFullLength.add(track.id);\n });\n for (const id of mustBeFullLength) {\n const idx = ctx.idToIndex.get(id);\n const node = idx === undefined ? null : (ctx.canvas.nodes[idx] as NodeDecl);\n const totalMs = (node?.params as Record<string, unknown> | undefined)?.total_ms;\n if (typeof totalMs !== \"number\") continue;\n if (Math.abs(totalMs / 1000 - expected) > VIDEO_TIME_SLACK_S) {\n ctx.issues.push({\n path: `nodes[${idx}].params.total_ms`,\n code: CODES.TIMELINE_TOTAL,\n node_id: id,\n message: `audio timeline \"${id}\" is pinned to ${totalMs}ms but the picture timeline is ${expected}s — \\`-shortest\\` at the final mux will silently cut the longer stream. Pin total_ms to ${Math.round(expected * 1000)}`,\n });\n }\n }\n}\n\n/**\n * No two windows on a per-speaker voice track may overlap: both extracts PLAY — the\n * voice doubles into an echo. Windows come from the LIVE graph: each track entry's\n * `duration_s` cap, else its extract node's `-t`. (The frozen vo_segments check has a\n * 0.75s slack for tts estimates; native extract windows are exact, so 10ms is real.)\n */\nfunction checkNativeSegOverlap(ctx: LintContext): void {\n for (const conv of ctx.canvas.nodes) {\n if (conv.type !== \"audio_voice_convert\") continue;\n const track = refNodeOf(ctx, conv.inputs?.audio);\n if (track?.type !== \"audio_timeline\") continue;\n const params = track.params as { tracks?: Array<{ slot: string; start_s: number; duration_s?: number }> };\n const windows = (params.tracks ?? [])\n .map((t) => {\n const extract = refNodeOf(ctx, track.inputs?.[t.slot]);\n const len = t.duration_s ?? (extract ? ffmpegTrimSeconds(extract) : null);\n return len === null ? null : { slot: t.slot, start: t.start_s, end: t.start_s + len };\n })\n .filter((w): w is { slot: string; start: number; end: number } => w !== null)\n .sort((a, b) => a.start - b.start);\n for (let i = 1; i < windows.length; i++) {\n const prev = windows[i - 1];\n const cur = windows[i];\n if (!prev || !cur || cur.start >= prev.end - 0.01) continue;\n const trackIdx = ctx.idToIndex.get(track.id);\n ctx.issues.push({\n path: `nodes[${trackIdx}].params.tracks`,\n code: CODES.NATIVE_SEG_OVERLAP,\n node_id: track.id,\n message: `voice track \"${track.id}\": \"${prev.slot}\" runs to ${round2(prev.end)}s but \"${cur.slot}\" starts at ${cur.start}s — both play at once (echo). Cap the first with duration_s: ${round2(cur.start - prev.start)} or re-time the windows`,\n });\n }\n }\n}\n\n/**\n * Warn when a legacy ffmpeg concat spine feeds bare `[i:v]` labels (inputs with\n * unproven fps/SAR). A `video_concat` spine normalizes every input by construction.\n */\nfunction checkSpineNormalized(ctx: LintContext, meta: VideoMetaT): void {\n const spineId = spineIdOf(ctx, meta);\n const idx = spineId === null ? undefined : ctx.idToIndex.get(spineId);\n const spine = idx === undefined ? undefined : ctx.canvas.nodes[idx];\n if (spine?.type !== \"ffmpeg\") return;\n const args = (spine.params as Record<string, unknown>).args;\n const graph = Array.isArray(args) ? args.join(\" \") : \"\";\n if (!graph.includes(\"concat=n=\")) return;\n if (/\\[\\d+:v\\](?:\\[|concat)/.test(graph)) {\n ctx.issues.push({\n path: `nodes[${idx}].params.args`,\n code: CODES.SPINE_UNNORMALIZED,\n severity: \"warning\",\n node_id: spine.id,\n message: `the spine concat feeds raw input labels — generated clips carry no fps/SAR guarantee, and one 24fps clip silently stretches the picture off the audio/overlay clock. Chain \\`format=yuv420p,fps=30,setsar=1,settb=AVTB\\` on every input before the concat`,\n });\n }\n}\n\n/** Warn on odd scale/crop/pad dimensions in any ffmpeg node — libx264 yuv420p hard-fails. */\nfunction checkOddDimensions(ctx: LintContext): void {\n ctx.canvas.nodes.forEach((node, idx) => {\n if (node.type !== \"ffmpeg\") return;\n const args = (node.params as Record<string, unknown>).args;\n const blob = Array.isArray(args) ? args.join(\" \") : \"\";\n for (const m of blob.matchAll(/(?:scale|crop|pad)=(\\d+):(\\d+)/g)) {\n const w = Number(m[1]);\n const h = Number(m[2]);\n if (w % 2 === 0 && h % 2 === 0) continue;\n ctx.issues.push({\n path: `nodes[${idx}].params.args`,\n code: CODES.ODD_DIMENSIONS,\n severity: \"warning\",\n node_id: node.id,\n message: `\"${m[0]}\" produces an odd dimension — libx264 yuv420p rejects odd sizes, so this node fails at render time. Round both to even numbers`,\n });\n return; // one warning per node is enough\n }\n });\n}\n\n/** Warn when a scene generated more region clips than its composite consumes — billed, then dropped. */\nfunction checkRegionDropped(ctx: LintContext): void {\n if (isTagged(ctx)) {\n checkTaggedRegionDropped(ctx);\n return;\n }\n const regionClips = new Map<string, number>();\n for (const node of ctx.canvas.nodes) {\n const m = /^s(\\d+)_r\\d+_clip$/.exec(node.id);\n if (m && node.type === \"video_generate\")\n regionClips.set(m[1] as string, (regionClips.get(m[1] as string) ?? 0) + 1);\n }\n for (const [scene, billed] of regionClips) {\n const idx = ctx.idToIndex.get(`s${scene}_composite`);\n if (idx === undefined) continue;\n const composite = ctx.canvas.nodes[idx] as NodeDecl;\n const consumed = Object.keys(composite.inputs ?? {}).filter((k) => /^c\\d+$/.test(k)).length;\n if (billed > consumed) {\n ctx.issues.push({\n path: `nodes[${idx}].inputs`,\n code: CODES.REGION_DROPPED,\n severity: \"warning\",\n node_id: composite.id,\n message: `scene s${scene} bills ${billed} region clips but its composite consumes ${consumed} — the extra generation is paid for and never reaches the frame. Wire every region into the composite or delete the unused clip node`,\n });\n }\n }\n}\n\n/**\n * The tagged form: a scene's region clips are its `video_generate` nodes tagged with a\n * region; the composite consumes the ones it reaches through its inputs (directly, or\n * through a cut-out or trim in between).\n */\nfunction checkTaggedRegionDropped(ctx: LintContext): void {\n for (const composite of ctx.canvas.nodes) {\n const scene = composite.tags?.scene;\n if (composite.tags?.role !== \"composite\" || scene === undefined) continue;\n const billed = ctx.canvas.nodes.filter(\n (n) => n.type === \"video_generate\" && n.tags?.scene === scene && n.tags.region !== undefined,\n );\n const reached = upstreamIds(ctx, composite);\n const consumed = billed.filter((n) => reached.has(n.id)).length;\n if (billed.length <= consumed) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(composite.id) ?? -1}].inputs`,\n code: CODES.REGION_DROPPED,\n severity: \"warning\",\n node_id: composite.id,\n message: `scene s${scene} bills ${billed.length} region clips but its composite consumes ${consumed} — the extra generation is paid for and never reaches the frame. Wire every region into the composite or delete the unused clip node`,\n });\n }\n}\n\n/** The nodes a node's inputs reference directly (a list input counts each element). */\nfunction wiredNodes(ctx: LintContext, node: NodeDecl): NodeDecl[] {\n return Object.values(node.inputs ?? {})\n .flatMap((v) => (Array.isArray(v) ? v : [v]))\n .map((ref) => refNodeOf(ctx, ref))\n .filter((up): up is NodeDecl => up !== null);\n}\n\n/** Every node id a node reads from, transitively. */\nfunction upstreamIds(ctx: LintContext, node: NodeDecl): Set<string> {\n const seen = new Set<string>();\n const stack = [node];\n for (let cur = stack.pop(); cur; cur = stack.pop()) {\n for (const up of wiredNodes(ctx, cur)) {\n if (seen.has(up.id)) continue;\n seen.add(up.id);\n stack.push(up);\n }\n }\n return seen;\n}\n\nfunction round2(n: number): number {\n return Math.round(n * 100) / 100;\n}\n\n/**\n * Advisory (§2): a scene's natural visual span must fit the assigned model's max clip\n * length. Switching a subset of clips to a shorter-max model (Seedance's 15s → Veo's\n * 8s) leaves any >8s scene unable to render its full content — it truncates. Caught\n * from the scaffold's recorded `clip_spans` BEFORE a billed run, not after.\n */\nfunction checkClipSpanFitsModel(ctx: LintContext, meta: VideoMetaT): void {\n for (const { node, span_s } of meta.clip_spans ?? []) {\n const target = ctx.canvas.nodes.find((n) => n.id === node && n.type === \"video_generate\");\n if (!target) continue;\n const model = (target.params as Record<string, unknown> | undefined)?.model;\n if (typeof model !== \"string\") continue;\n const max = maxClipSeconds(model);\n if (max === undefined || span_s <= max + SPAN_MODEL_SLACK_S) continue;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(node) ?? -1}].params.duration`,\n code: CODES.SPAN_EXCEEDS_MODEL,\n severity: \"warning\",\n message: `scene for clip \"${node}\" needs ~${span_s}s but ${model} caps clips at ${max}s — the clip will truncate. Split the scene, or keep it on a model whose max duration covers the span`,\n node_id: node,\n node_type: \"video_generate\",\n });\n }\n}\n\n/**\n * Seconds per word to budget a native line at. Prefers the speaker's OBSERVED pace —\n * the scaffold stamps `est_speech_s` (measured from the deconstruct's word timings)\n * with `speech_words` (the word count it was measured for) — so a fast talker's line\n * isn't failed by the generic wps guess, and a re-authored line still scales at the\n * real rate. Falls back to the guess when no plausible stamp exists.\n */\nfunction secondsPerWord(stamped?: { est_speech_s?: number; speech_words?: number }): number {\n const est = stamped?.est_speech_s;\n const words = stamped?.speech_words;\n if (est && words && est > 0 && words > 0) {\n const wps = words / est;\n if (wps >= OBSERVED_WPS_MIN && wps <= OBSERVED_WPS_MAX) return est / words;\n }\n return 1 / NATIVE_CLIP_WORDS_PER_SECOND;\n}\n\n/** The overrun of one candidate native clip node, or null when it fits / isn't one. */\nfunction speechOverrunOf(\n node: Canvas[\"nodes\"][number],\n secPerWord: number,\n): { estSpeechS: number; duration: number } | null {\n const params = node.params as Record<string, unknown> | undefined;\n if (params?.generate_audio !== true) return null;\n const line = nativeDialogueOf(params.prompt);\n const duration = typeof params.duration === \"number\" ? params.duration : undefined;\n if (!line || !duration) return null;\n const estSpeechS = wordCount(line) * secPerWord;\n return estSpeechS > duration * SPEECH_OVERRUN_RATIO ? { estSpeechS, duration } : null;\n}\n\n/** Invariant 4: est. speech from each native clip's prompt vs its generated duration. */\nfunction checkSpeechOverrun(ctx: LintContext, talkingScenes: TalkingSceneEntry[]): void {\n for (const entry of talkingScenes) {\n if (typeof entry !== \"object\" || !(\"voice_convert_node\" in entry)) continue;\n for (const n of sceneClips(ctx, entry.scene)) {\n const overrun = speechOverrunOf(n, secondsPerWord(entry));\n if (overrun) {\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(n.id) ?? -1}].params.prompt`,\n code: CODES.SPEECH_OVERRUN,\n message: `\"${n.id}\" asks Seedance to speak ~${Math.round(overrun.estSpeechS * 10) / 10}s of dialogue inside a ${overrun.duration}s clip — the line cannot fit (>${SPEECH_OVERRUN_RATIO}× the clip). Shorten the line, split the scene, or lengthen the clip duration`,\n });\n continue;\n }\n checkSpeechExceedsExtract(ctx, n, entry);\n }\n }\n}\n\n/**\n * The voice extract cut from a scene's native clip, and the name to report it by: on a\n * tagged canvas the scene's `voice_extract` (the clip's own region first); on an\n * untagged one the `s<scene>[_r<n>]_voextract` id, reported as `s<scene>_voextract`.\n */\nfunction sceneExtract(ctx: LintContext, clip: NodeDecl, scene: number): { extract: NodeDecl; label: string } | null {\n if (isTagged(ctx)) {\n const extracts = ctx.canvas.nodes.filter((n) => n.tags?.role === \"voice_extract\" && n.tags.scene === scene);\n const extract = extracts.find((n) => n.tags?.region === clip.tags?.region) ?? extracts[0];\n return extract ? { extract, label: extract.id } : null;\n }\n const regionTag = /^s\\d+(_r\\d+)?_clip$/.exec(clip.id)?.[1] ?? \"\";\n const extractIdx = ctx.idToIndex.get(`s${scene}${regionTag}_voextract`) ?? ctx.idToIndex.get(`s${scene}_voextract`);\n const extract = extractIdx === undefined ? undefined : ctx.canvas.nodes[extractIdx];\n return extract ? { extract, label: `s${scene}_voextract` } : null;\n}\n\n/**\n * The REAL audio budget for a re-authored native line is the extract window (the\n * `s<i>_voextract` `-t`), not the padded ≥4s generated clip: the picture is trimmed\n * back to the scene window on the spine, so a 3s line in a 1s window passes the clip\n * check and then gets cut mid-word at render. Compared against the extract — not the\n * seg — because a voiceover deliberately carries over b-roll cutaways (the extract\n * window IS that full spoken span). Blocking: the cut is certain, not stylistic.\n */\nfunction checkSpeechExceedsExtract(\n ctx: LintContext,\n clip: NodeDecl,\n entry: { scene: number; est_speech_s?: number; speech_words?: number },\n): void {\n const params = clip.params as Record<string, unknown> | undefined;\n if (params?.generate_audio !== true) return;\n const line = nativeDialogueOf(params.prompt);\n if (!line) return;\n const found = sceneExtract(ctx, clip, entry.scene);\n const windowS = found ? ffmpegTrimSeconds(found.extract) : null;\n if (!found || windowS === null) return;\n const estSpeechS = wordCount(line) * secondsPerWord(entry);\n if (estSpeechS <= windowS * SPEECH_OVERRUN_RATIO) return;\n ctx.issues.push({\n path: `nodes[${ctx.idToIndex.get(clip.id) ?? -1}].params.prompt`,\n code: CODES.SPEECH_EXCEEDS_EXTRACT,\n node_id: clip.id,\n message: `\"${clip.id}\"'s line is ~${Math.round(estSpeechS * 10) / 10}s of speech but its extract window (${found.label}) is ${windowS}s — the read gets cut mid-word on the spine. Shorten the Dialogue line, lengthen the scene in prompt.json and re-scaffold, or raise the voextract \\`-t\\` when the read should carry over the next cutaway`,\n });\n}\n\n/** Invariant 5: all video_generate nodes agree on one aspect_ratio (none silently defaulted). */\nfunction checkAspectConsistency(ctx: LintContext): void {\n const clips = ctx.canvas.nodes.filter((n) => n.type === \"video_generate\");\n if (clips.length < 2) return;\n const ratios = new Set(clips.map((n) => String((n.params as Record<string, unknown>)?.aspect_ratio ?? \"(unset)\")));\n if (ratios.size <= 1) return;\n ctx.issues.push({\n path: \"nodes\",\n code: CODES.ASPECT_MISMATCH,\n message: `video_generate nodes disagree on aspect_ratio (${[...ratios].sort().join(\", \")}) — the spine's segments would render at different shapes and the composite silently crops. Pin every clip to the same aspect_ratio`,\n });\n}\n\n/** The voiceover turns in start order. */\nfunction sortedVoSegments(meta: VideoMetaT): VideoMetaT[\"vo_segments\"] {\n return [...meta.vo_segments].sort((a, b) => a.start_s - b.start_s);\n}\n\n/** Invariant 1: no two voiceover turns overlap in time (the parallel-monologue symptom). */\nfunction checkVoOverlap(ctx: LintContext, meta: VideoMetaT): void {\n const segments = sortedVoSegments(meta);\n for (let i = 1; i < segments.length; i++) {\n const prev = segments[i - 1];\n const cur = segments[i];\n if (!prev || !cur) continue;\n if (cur.start_s < prev.end_s - VIDEO_TIME_SLACK_S) {\n ctx.issues.push({\n path: \"metadata.video.vo_segments\",\n code: CODES.VO_OVERLAP,\n message: `voiceover turns overlap: \"${prev.slot}\" runs to ${prev.end_s}s but \"${cur.slot}\" starts at ${cur.start_s}s — sequence them so dialogue alternates instead of stacking`,\n });\n }\n }\n}\n\n/** Invariant 2: the audio timeline should not run materially longer than the video. */\nfunction checkAudioDuration(ctx: LintContext, meta: VideoMetaT): void {\n const audioEnd = sortedVoSegments(meta).reduce((m, s) => Math.max(m, s.end_s), 0);\n if (audioEnd > meta.duration_s + VIDEO_TIME_SLACK_S) {\n ctx.issues.push({\n path: \"metadata.video.duration_s\",\n code: CODES.AUDIO_DURATION,\n message: `audio runs to ${audioEnd}s but the video is ${meta.duration_s}s — trim the voiceover or extend the video so audio ≈ video length`,\n });\n }\n}\n\n/**\n * Invariant 3: every single-on-camera-speaker scene must be a NATIVELY-voiced talking\n * head: the Seedance clip generates the speech+lips (`generate_audio: true` + the line\n * in its prompt) and an `audio_voice_convert` node re-voices it to the brand voice. We\n * confirm both — the clip carries native audio AND the convert node is wired — so the\n * lips can't drift (they were generated with the audio). Entry forms:\n * { scene, voice_convert_node } — native (current scaffold)\n * { scene, lipsync_node } / bare index — legacy veed canvases (still accepted)\n */\nfunction checkTalkingScenes(ctx: LintContext, meta: VideoMetaT): void {\n for (const entry of meta.talking_scenes) {\n const scene = typeof entry === \"number\" ? entry : entry.scene;\n if (!talkingSceneSatisfied(ctx, entry, scene)) {\n ctx.issues.push({\n path: \"metadata.video.talking_scenes\",\n code: CODES.LIPSYNC_MISSING,\n message: `scene ${scene} is a single-on-camera-speaker talking head but its clip lacks native audio (generate_audio: true) — the lips would drift. Generate the clip with native audio, then route it to the mix via either the audio_voice_convert node (one brand voice) or directly (s${scene}_voextract → audio_mix)`,\n });\n }\n }\n}\n\nexport const voOverlapRule: LintRule = {\n name: \"video-vo-overlap\",\n codes: { [CODES.VO_OVERLAP]: \"error\" },\n check: onVideoCanvas(checkVoOverlap),\n};\n\nexport const audioDurationRule: LintRule = {\n name: \"video-audio-duration\",\n codes: { [CODES.AUDIO_DURATION]: \"error\" },\n check: onVideoCanvas(checkAudioDuration),\n};\n\nexport const talkingScenesRule: LintRule = {\n name: \"video-talking-scenes\",\n codes: { [CODES.LIPSYNC_MISSING]: \"error\" },\n check: onVideoCanvas(checkTalkingScenes),\n};\n\n/**\n * Invariant 4: a native line must physically FIT its generated clip. The scaffold's\n * overstuff advisories ran against the ORIGINAL blueprint; the operator then re-crafts\n * the script inside the canvas, so re-derive the spoken length from each native clip's\n * CURRENT prompt and fail when it clearly overruns the clip duration (the render either\n * fails or crams — either way lips and timeline break).\n */\nexport const speechOverrunRule: LintRule = {\n name: \"video-speech-overrun\",\n codes: { [CODES.SPEECH_OVERRUN]: \"error\", [CODES.SPEECH_EXCEEDS_EXTRACT]: \"error\" },\n check: onVideoCanvas((ctx, meta) => checkSpeechOverrun(ctx, meta.talking_scenes)),\n};\n\n/**\n * Invariant 5: every clip must land on ONE canvas geometry. Mixed (or\n * partially-defaulted) aspect_ratio params across video_generate nodes ship a spine\n * whose segments disagree in shape — the composite silently crops/letterboxes.\n */\nexport const aspectConsistencyRule: LintRule = {\n name: \"video-aspect-consistency\",\n codes: { [CODES.ASPECT_MISMATCH]: \"error\" },\n check: onVideoCanvas((ctx) => checkAspectConsistency(ctx)),\n};\n\n/**\n * A scene's natural span must fit the assigned model's max clip length (a 9.2s scene\n * on Veo, which caps at 8s, would truncate). Caught before a run.\n */\nexport const clipSpanRule: LintRule = {\n name: \"video-clip-span\",\n codes: { [CODES.SPAN_EXCEEDS_MODEL]: \"warning\" },\n check: onVideoCanvas(checkClipSpanFitsModel),\n};\n\n// The one-clock contract, recomputed from the LIVE graph — the frozen metadata plan\n// catches scaffold-time breakage, but operators re-craft the canvas by hand and\n// `-shortest` at the final mux silently truncates whichever stream runs longer, so the\n// REAL node params are what must agree.\n\nexport const timelineContractRule: LintRule = {\n name: \"video-timeline-contract\",\n codes: { [CODES.TIMELINE_TOTAL]: \"error\" },\n check: onVideoCanvas(checkTimelineContract),\n};\n\nexport const nativeSegOverlapRule: LintRule = {\n name: \"video-native-seg-overlap\",\n codes: { [CODES.NATIVE_SEG_OVERLAP]: \"error\" },\n check: onVideoCanvas((ctx) => checkNativeSegOverlap(ctx)),\n};\n\nexport const spineNormalizedRule: LintRule = {\n name: \"video-spine-normalized\",\n codes: { [CODES.SPINE_UNNORMALIZED]: \"warning\" },\n check: onVideoCanvas(checkSpineNormalized),\n};\n\nexport const oddDimensionsRule: LintRule = {\n name: \"video-odd-dimensions\",\n codes: { [CODES.ODD_DIMENSIONS]: \"warning\" },\n check: onVideoCanvas((ctx) => checkOddDimensions(ctx)),\n};\n\nexport const regionDroppedRule: LintRule = {\n name: \"video-region-dropped\",\n codes: { [CODES.REGION_DROPPED]: \"warning\" },\n check: onVideoCanvas((ctx) => checkRegionDropped(ctx)),\n};\n\nexport const overlayTimingRule: DeepLintRule = {\n name: \"video-overlay-timing\",\n codes: { [CODES.OVERLAY_OUT_OF_BOUNDS]: \"warning\" },\n check: checkOverlayTimingBounds,\n};\n","/**\n * How long a line takes to say. Two rates, on purpose — they answer different questions:\n *\n * - `NATIVE_CLIP_WORDS_PER_SECOND` (2.5, ~150 wpm) is a PLANNING rate for speech the video\n * model voices itself. It errs slow: a clip sized at it is long enough that the model\n * never has to cram the line, and a scene whose lines overrun it is flagged as\n * over-stuffed, by the scaffold and by the validator's speech-fit gates alike. A\n * reproduced ad's actual timing comes from the deconstruct's word stamps\n * (`estSpeechWindowS`); this is only the fallback.\n * - `READ_WORDS_PER_SECOND` (3.06) is a MEASURED rate for an ElevenLabs read, off a real\n * Spanish ad (81 words in 26.48s; the previous 2.6 over-predicted every beat by 18%). An\n * authored ad (`scaffold-ad`) lays its beat clock on it, so the picture tracks the read.\n *\n * One rate for both would either cram native lines into clips too short to say them, or\n * pad every authored beat with dead air.\n */\nexport const NATIVE_CLIP_WORDS_PER_SECOND = 2.5;\nexport const READ_WORDS_PER_SECOND = 3.06;\n\nexport function wordCount(text: string): number {\n return text.trim().split(/\\s+/).filter(Boolean).length;\n}\n\n/** A model-voiced line's planning length (see `NATIVE_CLIP_WORDS_PER_SECOND`). */\nexport function estSpeechS(text: string): number {\n return wordCount(text) / NATIVE_CLIP_WORDS_PER_SECOND;\n}\n\n// Sanity band for an OBSERVED speech rate (deconstruct word timings, or a stamp the\n// validator reads back): real speech sits well inside 1–6 words/s. Inside it the observed\n// window is the truth (a fast talker's long line genuinely fits its clip — the 2.5wps\n// guess fatally flagged exactly that); outside it the timing is junk (a line\n// over-attributed to a scene) and the guess wins.\nexport const OBSERVED_WPS_MIN = 1;\nexport const OBSERVED_WPS_MAX = 6;\n\n/** A line's length: its observed window when the stamps are plausible, else the planning estimate. */\nexport function estSpeechWindowS(text: string, startS: number | undefined, endS: number | undefined): number {\n const words = wordCount(text);\n const window = (endS ?? 0) - (startS ?? 0);\n if (words > 0 && window > 0.3) {\n const wps = words / window;\n if (wps >= OBSERVED_WPS_MIN && wps <= OBSERVED_WPS_MAX) return window;\n }\n return estSpeechS(text);\n}\n","/**\n * Reading a LEGACY spine: the raw `ffmpeg` concat node canvases carried before the\n * spine became a typed `video_concat`. Those canvases are still on disk in client\n * workspaces and must keep validating, so the validator re-derives each input's\n * on-timeline length from the argv they froze. A `video_concat` spine states its\n * lengths in its params and never comes through here.\n *\n * The legacy spine absorbed per-scene length work into each input's chain:\n * - a TRIM: a generated clip or a phrase-clip window cut inside the spine's filter\n * chain (`trim=[start=<s>:]duration=<len>`);\n * - a STILL: a held keyframe / real screenshot looped via input flags\n * (`-loop 1 -t <len>` before its `-i`).\n */\n\n/**\n * Re-derive each legacy spine input's on-timeline length from the spine node's own\n * args. Returns a per-input-index map; an input with no absorbed length (a clip\n * generated at its exact scene length) is absent, and the caller falls back to\n * sizing the upstream node.\n */\nexport function parseSpineInputLens(args: readonly string[]): Map<number, number> {\n const lens = new Map<number, number>();\n // Input-side `-t` (stills): the flags immediately precede that input's `-i`.\n let inputIndex = 0;\n for (let i = 0; i < args.length; i++) {\n if (args[i] !== \"-i\") continue;\n if (args[i - 2] === \"-t\") {\n const v = Number(args[i - 1]);\n if (Number.isFinite(v)) lens.set(inputIndex, v);\n }\n inputIndex++;\n }\n // Filter-side `trim=` on a `[N:v]…` chain (clips cut inside the spine).\n const graph = args.join(\" \");\n for (const m of graph.matchAll(/\\[(\\d+):v\\][^;[]*?trim=(?:start=[\\d.]+:)?duration=([\\d.]+)/g)) {\n const idx = Number(m[1]);\n const v = Number(m[2]);\n if (Number.isFinite(idx) && Number.isFinite(v)) lens.set(idx, v);\n }\n return lens;\n}\n","import type { Canvas } from \"../../schema/canvas.ts\";\nimport type { ValidationIssue } from \"../errors.ts\";\nimport type { DeepLintRule, LintContext, LintRule } from \"./context.ts\";\nimport { audioBedMixRule } from \"./rules/audio.ts\";\nimport {\n formatPlateSourceRule,\n imageProfileRule,\n mixedSizePipelineRule,\n parallelFormatRendersRule,\n} from \"./rules/image.ts\";\nimport {\n brandmarkInPromptRule,\n hookLayersRule,\n personGenerationRule,\n promptBudgetRule,\n promptDecisionsRule,\n promptProfileRule,\n rawFaceKeyframeRule,\n referenceCompletenessRule,\n uiInPromptRule,\n unusableLastFrameRule,\n} from \"./rules/video-prompt.ts\";\nimport {\n aspectConsistencyRule,\n audioDurationRule,\n clipSpanRule,\n nativeSegOverlapRule,\n oddDimensionsRule,\n overlayTimingRule,\n regionDroppedRule,\n speechOverrunRule,\n spineNormalizedRule,\n talkingScenesRule,\n timelineContractRule,\n voOverlapRule,\n} from \"./rules/video-timeline.ts\";\n\n/**\n * Every domain rule the validator runs after its structural checks, in the order\n * their issues are reported. Adding a rule is adding an entry here.\n */\nconst LINT_RULES: readonly LintRule[] = [\n parallelFormatRendersRule,\n formatPlateSourceRule,\n mixedSizePipelineRule,\n audioBedMixRule,\n promptProfileRule,\n imageProfileRule,\n personGenerationRule,\n promptBudgetRule,\n rawFaceKeyframeRule,\n promptDecisionsRule,\n hookLayersRule,\n voOverlapRule,\n audioDurationRule,\n talkingScenesRule,\n speechOverrunRule,\n aspectConsistencyRule,\n uiInPromptRule,\n brandmarkInPromptRule,\n referenceCompletenessRule,\n clipSpanRule,\n timelineContractRule,\n unusableLastFrameRule,\n nativeSegOverlapRule,\n spineNormalizedRule,\n oddDimensionsRule,\n regionDroppedRule,\n];\n\n/** Rules that read files the canvas points at, run by the deep pass only. */\nconst DEEP_LINT_RULES: readonly DeepLintRule[] = [overlayTimingRule];\n\n/**\n * A rule may only raise the codes it declares, at the severity it declares: the\n * registry is what says which codes exist and whether they block, so it cannot be\n * allowed to drift from what the rules actually report.\n */\nfunction assertDeclared(rule: LintRule | DeepLintRule, raised: readonly ValidationIssue[]): void {\n for (const issue of raised) {\n const declared = rule.codes[issue.code];\n const severity = issue.severity ?? \"error\";\n if (declared !== severity) {\n throw new Error(\n `lint rule \"${rule.name}\" raised ${issue.code} as ${severity}, but declares ${declared ?? \"no such code\"}`,\n );\n }\n }\n}\n\nexport function runLintRules(ctx: LintContext): void {\n for (const rule of LINT_RULES) {\n const before = ctx.issues.length;\n rule.check(ctx);\n assertDeclared(rule, ctx.issues.slice(before));\n }\n}\n\nexport async function runDeepLintRules(canvas: Canvas, issues: ValidationIssue[]): Promise<void> {\n for (const rule of DEEP_LINT_RULES) {\n const before = issues.length;\n await rule.check(canvas, issues);\n assertDeclared(rule, issues.slice(before));\n }\n}\n","import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { canonicalModelId, isManagedNodeKind, MODEL_REGISTRY } from \"@baker/canvas-contract\";\nimport { type Canvas, type NodeDecl, parseRefExpr, REF_PREFIX } from \"../schema/canvas.ts\";\nimport { extractSlots, renderTemplate } from \"../schema/prompts.ts\";\nimport type { ValidationIssue } from \"./errors.ts\";\n\nconst PROMPT_OVER_MODEL_LIMIT = \"PROMPT_OVER_MODEL_LIMIT\";\n\ntype Nodes = ReadonlyMap<string, NodeDecl>;\n\n/**\n * The text a slot or param will carry at run time, when it is already on disk or in\n * the canvas: a literal, a `text` node's value, or a local text/json file an `ingest`\n * reads verbatim. Anything a node generates during the run is unknown (undefined).\n */\nasync function staticTextOf(value: unknown, nodes: Nodes): Promise<string | undefined> {\n if (typeof value !== \"string\") return undefined;\n if (!value.startsWith(REF_PREFIX)) return value;\n const expr = parseRefExpr(value);\n if (expr?.kind !== \"ref\" || expr.index !== undefined) return undefined;\n const target = nodes.get(expr.nodeId);\n const params = (target?.params ?? {}) as Record<string, unknown>;\n if (target?.type === \"text\" && expr.output === \"text\" && typeof params.value === \"string\") return params.value;\n if (\n target?.type === \"ingest\" &&\n expr.output === \"asset\" &&\n params.source === \"path\" &&\n (params.expect === \"json\" || params.expect === \"text\") &&\n typeof params.path === \"string\" &&\n path.isAbsolute(params.path)\n ) {\n try {\n return await readFile(params.path, \"utf8\");\n } catch {\n return undefined; // the ingest's own execute reports a missing file\n }\n }\n return undefined;\n}\n\n/** The model's capped string params (`prompt`, `negative_prompt`, `text`) and their caps. */\nfunction modelStringCaps(nodeType: string, params: unknown): Array<{ key: string; max: number; model: string }> {\n if (!isManagedNodeKind(nodeType)) return [];\n const model = (params as Record<string, unknown> | undefined)?.model;\n if (typeof model !== \"string\") return [];\n const spec = MODEL_REGISTRY[nodeType][canonicalModelId(model)];\n if (!spec) return [];\n return Object.entries(spec.params).flatMap(([key, schema]) =>\n schema.kind === \"string\" && schema.maxLength !== undefined ? [{ key, max: schema.maxLength, model }] : [],\n );\n}\n\n/**\n * The run-time half of the same check: the node's params as the executor is about to\n * send them, every `{{slot}}` already filled from what upstream nodes produced. Only\n * validate's figure is a floor (a slot a node generates mid-run is unknown to it);\n * this one is the prompt itself. One message per capped param over its limit.\n */\nexport function renderedPromptOverLimit(nodeId: string, nodeType: string, renderedParams: unknown): string[] {\n const params = (renderedParams ?? {}) as Record<string, unknown>;\n return modelStringCaps(nodeType, params).flatMap(({ key, max, model }) => {\n const value = params[key];\n if (typeof value !== \"string\" || value.length <= max) return [];\n return [\n `\"${nodeId}\" ${key} is ${value.length} characters once its slots are filled, ${value.length - max} over the ${max} that \"${model}\" accepts. ` +\n \"Shorten what feeds its {{slots}} (or the prompt around them) and run again; nothing was sent to the model.\",\n ];\n });\n}\n\n/**\n * One param's text as the model will receive it, with every slot known before the run\n * filled; undefined when it cannot be read or holds no slot (a plain literal is the\n * registry's own MODEL_INVALID_PARAMS check).\n */\nasync function filledParam(\n n: NodeDecl,\n raw: unknown,\n nodes: Nodes,\n): Promise<{ length: number; slots: Record<string, string> } | undefined> {\n const template = await staticTextOf(raw, nodes);\n if (template === undefined) return undefined;\n const names = extractSlots(template);\n if (names.length === 0 && template === raw) return undefined;\n const inputs = (n.inputs ?? {}) as Record<string, unknown>;\n const slots: Record<string, string> = {};\n for (const name of names) {\n const text = await staticTextOf(inputs[name], nodes);\n if (text !== undefined) slots[name] = text;\n }\n return { length: renderTemplate(template, slots).length, slots };\n}\n\nfunction largestSlotNote(slots: Record<string, string>): string {\n const largest = Object.entries(slots).sort((a, b) => b[1].length - a[1].length)[0];\n return largest ? `; {{${largest[0]}}} alone is ${largest[1].length}` : \"\";\n}\n\n/**\n * The length of each capped string param once its `{{slots}}` are filled, checked\n * against the model's own limit. The param alone is already checked by the model\n * registry; the filled-in prompt was not, and the provider only refused it after\n * every node upstream of the generator had run and been paid for. Unknown slots count\n * as empty, so the figure is a floor: a refusal here is certain, never a guess.\n */\nexport async function filledPromptLimitIssues(canvas: Canvas): Promise<ValidationIssue[]> {\n const nodes: Nodes = new Map(canvas.nodes.map((n) => [n.id, n]));\n const issues: ValidationIssue[] = [];\n for (const [i, n] of canvas.nodes.entries()) {\n for (const { key, max, model } of modelStringCaps(n.type, n.params)) {\n const filled = await filledParam(n, (n.params as Record<string, unknown> | undefined)?.[key], nodes);\n if (!filled || filled.length <= max) continue;\n issues.push({\n path: `nodes[${i}].params.${key}`,\n code: PROMPT_OVER_MODEL_LIMIT,\n message:\n `\"${n.id}\" ${key} is ${filled.length} characters once its slots are filled — ${filled.length - max} over the ${max} that \"${model}\" accepts` +\n largestSlotNote(filled.slots) +\n `. Shorten it before running: the model refuses it, after every node before \"${n.id}\" has already been paid for.`,\n received: filled.length,\n expected: `<= ${max} characters`,\n node_id: n.id,\n node_type: n.type,\n });\n }\n }\n return issues;\n}\n","/**\n * Kahn's algorithm: produce execution layers from a dependency graph.\n * Each layer contains node ids whose dependencies are all in earlier layers.\n *\n * Throws if the graph has a cycle. The caller should run cycle detection in\n * the validator stage, but we double-check here as a safety net.\n */\nexport function topologicalLayers(graph: ReadonlyMap<string, ReadonlySet<string>>): string[][] {\n const remaining = cloneGraph(graph);\n const layers: string[][] = [];\n while (remaining.size > 0) {\n const ready = collectReady(remaining);\n if (ready.length === 0) {\n throw new Error(`scheduler: cycle detected among ${[...remaining.keys()].join(\", \")}`);\n }\n layers.push(ready);\n removeNodes(remaining, ready);\n }\n return layers;\n}\n\n/**\n * Node ids reachable from `roots` by following dependency edges (each node maps\n * to the set of nodes it depends on). Used for dead-node elimination: only the\n * transitive dependencies of the canvas output need to execute — orphaned nodes\n * left behind by an edit (or a `--out` rewire) would otherwise still run, bill,\n * and abort the whole run on their own failure.\n */\nexport function reachableNodes(graph: ReadonlyMap<string, ReadonlySet<string>>, roots: readonly string[]): Set<string> {\n const reachable = new Set<string>();\n const stack = [...roots];\n while (stack.length > 0) {\n const id = stack.pop();\n if (id === undefined || reachable.has(id) || !graph.has(id)) continue;\n reachable.add(id);\n for (const dep of graph.get(id) ?? []) stack.push(dep);\n }\n return reachable;\n}\n\n/**\n * Restrict a dependency graph to `keep`, dropping nodes outside the set and any\n * edges to dropped nodes. Returns a new graph; the input is untouched.\n */\nexport function subgraph(\n graph: ReadonlyMap<string, ReadonlySet<string>>,\n keep: ReadonlySet<string>,\n): Map<string, Set<string>> {\n const out = new Map<string, Set<string>>();\n for (const [id, deps] of graph) {\n if (!keep.has(id)) continue;\n out.set(id, new Set([...deps].filter((d) => keep.has(d))));\n }\n return out;\n}\n\nfunction cloneGraph(graph: ReadonlyMap<string, ReadonlySet<string>>): Map<string, Set<string>> {\n const out = new Map<string, Set<string>>();\n for (const [k, deps] of graph) out.set(k, new Set(deps));\n return out;\n}\n\nfunction collectReady(remaining: Map<string, Set<string>>): string[] {\n const ready: string[] = [];\n for (const [id, deps] of remaining) if (deps.size === 0) ready.push(id);\n ready.sort();\n return ready;\n}\n\nfunction removeNodes(remaining: Map<string, Set<string>>, ready: readonly string[]): void {\n for (const id of ready) remaining.delete(id);\n for (const deps of remaining.values()) {\n for (const id of ready) deps.delete(id);\n }\n}\n\nexport function findCycle(graph: ReadonlyMap<string, ReadonlySet<string>>): string[] | null {\n const reverseAdj = buildReverseAdj(graph);\n const color = new Map<string, number>();\n for (const k of graph.keys()) color.set(k, 0);\n const stack: string[] = [];\n for (const id of graph.keys()) {\n if ((color.get(id) ?? 0) !== 0) continue;\n const found = dfsCycle(id, color, stack, reverseAdj);\n if (found) return found;\n }\n return null;\n}\n\nfunction buildReverseAdj(graph: ReadonlyMap<string, ReadonlySet<string>>): Map<string, string[]> {\n const reverseAdj = new Map<string, string[]>();\n for (const [node, deps] of graph) {\n for (const dep of deps) {\n const arr = reverseAdj.get(dep) ?? [];\n arr.push(node);\n reverseAdj.set(dep, arr);\n }\n }\n return reverseAdj;\n}\n\nfunction dfsCycle(\n u: string,\n color: Map<string, number>,\n stack: string[],\n reverseAdj: Map<string, string[]>,\n): string[] | null {\n color.set(u, 1);\n stack.push(u);\n const children = reverseAdj.get(u) ?? [];\n for (const v of children) {\n const c = color.get(v) ?? 0;\n if (c === 1) {\n const idx = stack.indexOf(v);\n return [...stack.slice(idx), v];\n }\n if (c === 0) {\n const r = dfsCycle(v, color, stack, reverseAdj);\n if (r) return r;\n }\n }\n color.set(u, 2);\n stack.pop();\n return null;\n}\n","/**\n * Where the brand's logo file is placed on a static ad, decided before anything is drawn.\n *\n * The image model redraws a logo it is handed: Red Points' stylised lowercase-n \"POIПTS\" came\n * back as a plain \"POINTS\", and a cut made after the words were set took the logo off the top\n * of a 4:5 (Oct 2026). So the logo is never drawn: each size reserves an empty slot inside the\n * area its placements leave clear, the render is told to keep it plain, and the file itself is\n * composited there pixel for pixel (`static_logo`). The brief and the composite choose the place by\n * one function (`chooseLogoSpot`), among the places a designer sets a logo (`designerSpots`): round 6\n * set it mid-picture, across two men's chests and against a phone's edge, wherever a box was free.\n *\n * Pure: the frame, its safe area and the logo's shape in, the slot out.\n */\nimport { type PixelRect, type SafeArea, type StaticSafeArea, safeRectPx } from \"./platform-safe-area.ts\";\nimport type { Size } from \"./static-sizes.ts\";\n\n/** Where on the frame the logo sits, as the concept places it (`logo_position`). */\nexport const LOGO_POSITIONS = [\n \"top_left\",\n \"top_right\",\n \"bottom_left\",\n \"bottom_right\",\n \"top_centre\",\n \"bottom_centre\",\n] as const;\nexport type LogoPosition = (typeof LOGO_POSITIONS)[number];\n\n/** The logo's width, as a share of the frame's: a wordmark reads at a quarter of the width. */\nconst LOGO_WIDTH_SHARE = 0.24;\n/** Its height, as a share of the frame's width: a square mark is never a stamp, a long wordmark never a sliver. */\nconst LOGO_MIN_HEIGHT = 0.05;\nconst LOGO_MAX_HEIGHT = 0.09;\n/** No logo is wider than this share of the frame. */\nconst LOGO_MAX_WIDTH = 0.3;\n/** The clear space kept around the logo, as a share of its height. */\nconst CLEAR_SPACE = 0.35;\n\nexport type LogoSlot = {\n /** Where the logo file is placed, in the frame's pixels. */\n rect: PixelRect;\n /** The slot with its clear space: what the words keep out of. */\n clear: PixelRect;\n position: LogoPosition;\n};\n\n/**\n * The position a concept's free text (`logo_position`: \"small, bottom right corner\") puts the\n * logo in: its edge (top unless it says bottom) and side (left unless it says right or centre). Pure.\n */\nexport function placedLogoPosition(text: string | undefined): LogoPosition {\n const t = (text ?? \"\").toLowerCase();\n const v = /\\b(bottom|lower|foot|footer|base)\\b/.test(t) ? \"bottom\" : \"top\";\n const h = /\\bright\\b/.test(t) ? \"right\" : /\\b(cent(?:er|re|red|ered)|middle)\\b/.test(t) ? \"centre\" : \"left\";\n return `${v}_${h}`;\n}\n\n/** A rectangle as fractions of a frame, origin top-left. */\nexport type Span = { x0: number; y0: number; x1: number; y1: number };\n\nfunction ratioOf(format: string): number {\n const [w, h] = format.split(\":\").map(Number);\n return w && h ? w / h : 1;\n}\n\n/**\n * A span of the delivered `format` stated on the frame of ratio `drawn` that is filled (cut at the\n * centre) to it, as `safeAreaOnFrame` states the safe area. Pure.\n */\nfunction spanOnDrawnFrame(span: Span, drawn: string, format: string): Span {\n const rendered = ratioOf(drawn);\n const delivered = ratioOf(format);\n const keepH = rendered < delivered ? rendered / delivered : 1;\n const keepW = rendered > delivered ? delivered / rendered : 1;\n const x = (v: number) => (1 - keepW) / 2 + v * keepW;\n const y = (v: number) => (1 - keepH) / 2 + v * keepH;\n return { x0: x(span.x0), y0: y(span.y0), x1: x(span.x1), y1: y(span.y1) };\n}\n\n/** A pixel rectangle of a frame as fractions of it. */\nexport function spanOf(rect: PixelRect, frame: Size): Span {\n return {\n x0: rect.x / frame.width,\n y0: rect.y / frame.height,\n x1: (rect.x + rect.width) / frame.width,\n y1: (rect.y + rect.height) / frame.height,\n };\n}\n\nconst POSITION_WORDS: Record<LogoPosition, string> = {\n top_left: \"top-left corner\",\n top_right: \"top-right corner\",\n bottom_left: \"bottom-left corner\",\n bottom_right: \"bottom-right corner\",\n top_centre: \"top centre\",\n bottom_centre: \"bottom centre\",\n};\n\n/** A position as the briefs and the review say it (\"top-right corner\"); the concept's top-left when it names none or an unknown one. */\nexport function logoCornerWords(position: unknown): string {\n return POSITION_WORDS[\n (LOGO_POSITIONS as readonly unknown[]).includes(position) ? (position as LogoPosition) : \"top_left\"\n ];\n}\n\nconst pct = (v: number) => `${Math.round(Math.max(0, Math.min(1, v)) * 100)}%`;\n\n/**\n * The line a render is told when the logo file is placed on it afterwards: draw no logo, and keep\n * the slot (with its clear space, `clear`) plain, stated on the frame the model draws (`frame`: the\n * ratio drawn and the format it is filled to; omitted when the span is already on it). Pure.\n */\nexport function logoSlotLine(clear: Span, position: LogoPosition, frame?: { drawn: string; format: string }): string {\n const s = frame ? spanOnDrawnFrame(clear, frame.drawn, frame.format) : clear;\n const words = position.startsWith(\"top\")\n ? `The headline and every other word start below ${pct(s.y1)} of the height.`\n : `Every word ends above ${pct(s.y0)} of the height; only the button may sit on its row, beside it.`;\n return `Logo: Draw no logo, wordmark or brand mark anywhere; the brand's own logo file is placed afterwards in the ${POSITION_WORDS[position]}. Keep that place plain, from ${pct(s.x0)} to ${pct(s.x1)} of the width and from ${pct(s.y0)} to ${pct(s.y1)} of the height: no word, button, card, face or product in it, only calm background the logo reads on. ${words}`;\n}\n\n/** A grey level (0-255, sRGB) as relative luminance. */\nfunction relativeLuminance(grey: number): number {\n const c = Math.max(0, Math.min(255, grey)) / 255;\n return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n}\n\n/** The contrast ratio of two grey levels (1-21). */\nexport function contrastRatio(a: number, b: number): number {\n const [hi, lo] = [relativeLuminance(a), relativeLuminance(b)].sort((x, y) => y - x) as [number, number];\n return (hi + 0.05) / (lo + 0.05);\n}\n\n/** The contrast a logo reads at on its ground (WCAG's large-type and graphics line). */\nexport const MIN_LOGO_CONTRAST = 3;\n\n/** A logo reads when this share of its solid pixels sit on ground it stands out from. */\nexport const MIN_LEGIBLE_SHARE = 0.9;\n\n/**\n * The share of the logo's solid pixels (`art` set at `at` on the picture `table`) whose own local\n * ground (a 3x3 mean under the pixel) reaches `MIN_LOGO_CONTRAST` against the logo's ink (`inkLuma`,\n * 0-255; null when unreadable). A mean over the whole logo hides that half of a white logo sits on\n * white paper; this does not. `stride` reads every nth pixel, for scanning many places. Pure.\n */\nexport function legibleShare(\n table: GreyTable,\n art: { data: ArrayLike<number>; width: number; height: number },\n at: { x: number; y: number },\n inkLuma: number | null,\n stride = 1,\n): number {\n if (inkLuma === null) return 0;\n let solid = 0;\n let reads = 0;\n for (let j = 0; j < art.height; j += stride) {\n for (let i = 0; i < art.width; i += stride) {\n const u = at.x + i;\n const v = at.y + j;\n if (!isSolid(art, i, j) || u < 0 || v < 0 || u >= table.width || v >= table.height) continue;\n solid++;\n if (contrastRatio(localGround(table, u, v), inkLuma) >= MIN_LOGO_CONTRAST) reads++;\n }\n }\n return solid === 0 ? 1 : reads / solid;\n}\n\nconst isSolid = (art: { data: ArrayLike<number>; width: number }, i: number, j: number) =>\n (art.data[(j * art.width + i) * 4 + 3] ?? 0) >= 128;\n\n/** The mean grey of the 3x3 around a pixel. */\nfunction localGround(table: GreyTable, x: number, y: number): number {\n let sum = 0;\n let n = 0;\n for (let dy = -1; dy <= 1; dy++) {\n for (let dx = -1; dx <= 1; dx++) {\n const u = x + dx;\n const v = y + dy;\n if (u < 0 || v < 0 || u >= table.width || v >= table.height) continue;\n sum += table.grey[v * table.width + u] ?? 0;\n n++;\n }\n }\n return n === 0 ? 255 : sum / n;\n}\n\n/**\n * Which version of the logo is placed (`shares`: for each version, in the brand's order with its own\n * file and colour first, the `legibleShare` it reaches at the slot): the first that reads\n * (`MIN_LEGIBLE_SHARE`), else the one that reads best. The files are measured, never read by name:\n * `logo-dark` names the ground in one kit and the ink in the next. Pure.\n */\nexport function pickLogoVariant(shares: readonly number[]): number {\n const reads = shares.findIndex((s) => s >= MIN_LEGIBLE_SHARE);\n if (reads >= 0) return reads;\n return Math.max(0, shares.indexOf(Math.max(...shares)));\n}\n\nexport const PLACEMENT_EDGES = [\"top\", \"bottom\", \"left\", \"right\"] as const;\nexport const PLACEMENT_ELEMENTS = [\"logo\", \"headline\", \"copy\"] as const;\n/**\n * `cut`: past the frame's edge; `outside_safe_area`: where the app's interface or the feed's margin is;\n * `under_logo`: the logo covers it; `illegible`: the logo is lost on the ground under it; `no_room`:\n * no place on the size holds the logo, not even on a plate of its own.\n */\nexport const PLACEMENT_DEFECTS = [\"cut\", \"outside_safe_area\", \"under_logo\", \"illegible\", \"no_room\"] as const;\ntype PlacementEdge = (typeof PLACEMENT_EDGES)[number];\nexport type PlacementProblem = {\n element: (typeof PLACEMENT_ELEMENTS)[number];\n defect: (typeof PLACEMENT_DEFECTS)[number];\n edges: PlacementEdge[];\n};\n\n/** The edges of `outer` that `box` reaches past. */\nfunction edgesPast(box: PixelRect, outer: PixelRect): PlacementEdge[] {\n return [\n ...(box.y < outer.y ? ([\"top\"] as const) : []),\n ...(box.y + box.height > outer.y + outer.height ? ([\"bottom\"] as const) : []),\n ...(box.x < outer.x ? ([\"left\"] as const) : []),\n ...(box.x + box.width > outer.x + outer.width ? ([\"right\"] as const) : []),\n ];\n}\n\n/**\n * The deterministic check of a delivered size: the composited logo's box and the headline's are\n * each wholly inside the frame and inside its safe area, and the logo covers no part of the\n * headline. Every problem blocks: the size is set again, never shipped cut. Pure.\n */\nexport function placementProblems(input: {\n frame: Size;\n safe: SafeArea;\n logo?: PixelRect | null;\n headline?: PixelRect | null;\n /** The other lines of the copy, as read on the size. */\n copy?: readonly PixelRect[];\n /** Every words box read on the size (a button, a checklist, a line the copy does not name): the logo covers none. */\n words?: readonly PixelRect[];\n /** The share (0-1) of the logo that reads on the ground under it (`legibleShare`), when it was measured. */\n legible?: number;\n /** The logo sits on a plate of its own, which it reads on whatever is behind it. */\n plated?: boolean;\n}): PlacementProblem[] {\n const whole = { x: 0, y: 0, width: input.frame.width, height: input.frame.height };\n const area = safeRectPx(input.safe, input.frame.width, input.frame.height);\n const placed = (element: PlacementProblem[\"element\"], box: PixelRect): PlacementProblem[] => {\n const cut = edgesPast(box, whole);\n if (cut.length > 0) return [{ element, defect: \"cut\", edges: cut }];\n const outside = edgesPast(box, area);\n return outside.length > 0 ? [{ element, defect: \"outside_safe_area\", edges: outside }] : [];\n };\n const { logo, headline } = input;\n const lines = [...(input.copy ?? []), ...(input.words ?? [])];\n const lost = logo && !input.plated && (input.legible ?? 1) < MIN_LEGIBLE_SHARE;\n return [\n ...(logo ? placed(\"logo\", logo) : []),\n ...(headline ? placed(\"headline\", headline) : []),\n ...(logo && headline && overlaps(logo, headline)\n ? [{ element: \"headline\" as const, defect: \"under_logo\" as const, edges: [] }]\n : []),\n ...(logo && lines.some((line) => overlaps(logo, line))\n ? [{ element: \"copy\" as const, defect: \"under_logo\" as const, edges: [] }]\n : []),\n ...(lost ? [{ element: \"logo\" as const, defect: \"illegible\" as const, edges: [] }] : []),\n ];\n}\n\n/**\n * Where the logo's artwork (`art`, fitted inside the slot) is set in the slot: against the slot's\n * outer side (its left on the left, its right on the right, centred in the centre), centred on its height. Pure.\n */\nexport function placeInSlot(\n slot: PixelRect,\n art: { width: number; height: number },\n position: LogoPosition,\n): { x: number; y: number } {\n const side = position.split(\"_\")[1];\n const spare = slot.width - art.width;\n const x = slot.x + (side === \"left\" ? 0 : side === \"right\" ? spare : Math.round(spare / 2));\n return { x, y: slot.y + Math.round((slot.height - art.height) / 2) };\n}\n\n/** The words a logo file's name uses for its colours, never for its artwork. */\nconst COLOUR_WORDS =\n /(?:^|[-_ .])(light|dark|white|black|mono|inverse|inverted|negative|positive|reverse|reversed|colou?r|on-dark|on-light|blanco|negro|claro|oscuro)(?=$|[-_ .])/gi;\n\n/** A file's name without its folder, extension and colour words: the artwork it holds. */\nfunction artworkOf(file: string): string {\n const base = file.split(\"/\").pop() ?? file;\n return base\n .replace(/\\.[a-z0-9]+$/i, \"\")\n .replace(COLOUR_WORDS, \"\")\n .replace(/[-_ .]+/g, \"-\")\n .replace(/^-|-$/g, \"\")\n .toLowerCase();\n}\n\n/**\n * The other colourways of the logo file `chosen` among `files` (`logo-light.svg` → `logo-dark.svg`):\n * the same artwork, named apart only by its colour. The composite measures each and places the\n * one that reads on the ground behind its slot (`pickLogoVariant`). Pure.\n */\nexport function logoColourways(chosen: string, files: readonly string[]): string[] {\n const artwork = artworkOf(chosen);\n return files.filter((f) => f !== chosen && artworkOf(f) === artwork);\n}\n\n/** The logo's box on a frame: a quarter of its width, held between a small and a large height (an asked-for width is held to as it is). */\nfunction logoBox(frame: Size, aspect: number, share: number | undefined): { width: number; height: number } {\n const wanted = (frame.width * (share ?? LOGO_WIDTH_SHARE)) / aspect;\n const smallest = share === undefined ? frame.width * LOGO_MIN_HEIGHT : 0;\n const tall = Math.min(Math.max(wanted, smallest), frame.width * LOGO_MAX_HEIGHT);\n const width = Math.min(tall * aspect, frame.width * LOGO_MAX_WIDTH);\n return { width: Math.round(width), height: Math.round(width / aspect) };\n}\n\n/** The logo's box as `planLogoSlot` sets it on a frame, for reading the artwork at that size beforehand. */\nexport function logoBoxOn(frame: Size, aspect: number, share?: number): { width: number; height: number } {\n return logoBox(frame, aspect, share);\n}\n\n/** The position a slot sits at on its frame: its edge by its middle's height, its side by its middle's third. Pure. */\nexport function slotPosition(rect: PixelRect, frame: Size): LogoPosition {\n const cx = (rect.x + rect.width / 2) / frame.width;\n const v = rect.y + rect.height / 2 < frame.height / 2 ? \"top\" : \"bottom\";\n const h = cx < 1 / 3 ? \"left\" : cx > 2 / 3 ? \"right\" : \"centre\";\n return `${v}_${h}`;\n}\n\n/** The slot around a logo set at `rect`: the logo with its clear space, as the slot was planned. Pure. */\nexport function slotAround(rect: PixelRect, position: LogoPosition): LogoSlot {\n const pad = Math.round(rect.height * CLEAR_SPACE);\n return {\n rect,\n clear: { x: rect.x - pad, y: rect.y - pad, width: rect.width + 2 * pad, height: rect.height + 2 * pad },\n position,\n };\n}\n\n/** What a logo is placed among on one size, every box in the size's pixels. */\nexport type LogoScene = {\n /** The words read on the size, each grown by its clear space (`inflatedWords`). */\n words?: readonly PixelRect[];\n /** The faces, people, products and animals: the placed box keeps its clear space off each. */\n subjects?: readonly PixelRect[];\n /** The button, when read: the logo may sit on its row, at the margin. */\n cta?: PixelRect | null;\n /** Whether a straight edge (a card's, a window's, a phone's bezel) runs through a box. */\n crossesEdge?: (r: PixelRect) => boolean;\n /** Whether the picture is plain under a box. */\n calm?: (r: PixelRect) => boolean;\n /** Whether the logo reads at a box. */\n legible?: (r: PixelRect) => boolean;\n};\n\n/** Where the logo goes on a size: its slot, whether it needs a plate of its own, and the width share it was fitted at (the default when none). */\ntype LogoSpot = { slot: LogoSlot; plate: boolean; share: number | undefined };\n\n/** The widths a logo is tried at, widest first: its own, then a fifth and a sixth of the frame. */\nconst SPOT_SHARES = [undefined, 0.2, 0.16] as const;\n\n/** The button's row counts as the foot of the frame when its middle is in this lower share of the safe area. */\nconst CTA_ROW_SHARE = 0.4;\n\n/**\n * The places a designer sets a logo on a size, in the order they are tried: the concept's corner,\n * the rest of the corners (its edge first, its side first), the top centre, and beside the button\n * on its row at the margin when the button sits at the foot. Each inside the safe area, clear space\n * and all, off the right-hand buttons of a 9:16. Never anywhere else. Pure.\n */\nexport function designerSpots(\n frame: Size,\n safe: StaticSafeArea | SafeArea,\n opts: { aspect: number; position?: LogoPosition; share?: number; cta?: PixelRect | null },\n): LogoSlot[] {\n const area = safeRectPx(safe, frame.width, frame.height);\n const box = logoBox(frame, opts.aspect, opts.share);\n const pad = Math.round(box.height * CLEAR_SPACE);\n const outer = { width: box.width + 2 * pad, height: box.height + 2 * pad };\n const rail = \"rail\" in safe ? safe.rail : undefined;\n const left = area.x;\n const right = (y: number) => {\n const edge = area.x + area.width - outer.width;\n return rail && y + outer.height > rail.from * frame.height\n ? Math.min(edge, Math.floor((1 - rail.width) * frame.width) - outer.width)\n : edge;\n };\n const slotAt = (x: number, y: number, position: LogoPosition): LogoSlot => ({\n rect: { x: x + pad, y: y + pad, ...box },\n clear: { x, y, ...outer },\n position,\n });\n const top = area.y;\n const bottom = area.y + area.height - outer.height;\n const at: Record<\"top_left\" | \"top_right\" | \"top_centre\" | \"bottom_left\" | \"bottom_right\", LogoSlot> = {\n top_left: slotAt(left, top, \"top_left\"),\n top_right: slotAt(right(top), top, \"top_right\"),\n top_centre: slotAt(area.x + Math.round((area.width - outer.width) / 2), top, \"top_centre\"),\n bottom_left: slotAt(left, bottom, \"bottom_left\"),\n bottom_right: slotAt(right(bottom), bottom, \"bottom_right\"),\n };\n const cta = opts.cta;\n const middle = cta ? cta.y + cta.height / 2 : null;\n const onRow =\n middle !== null && middle >= area.y + (1 - CTA_ROW_SHARE) * area.height && middle <= area.y + area.height;\n const row = onRow ? Math.min(bottom, Math.max(top, Math.round((middle as number) - outer.height / 2))) : null;\n const besideCta =\n row === null\n ? { left: [], right: [] }\n : { left: [slotAt(left, row, \"bottom_left\")], right: [slotAt(right(row), row, \"bottom_right\")] };\n const [v, h] = (opts.position ?? \"top_left\").split(\"_\") as [\"top\" | \"bottom\", \"left\" | \"right\" | \"centre\"];\n const near = h === \"right\" ? \"right\" : \"left\";\n const far = near === \"right\" ? \"left\" : \"right\";\n const tops =\n h === \"centre\" ? [at.top_centre, at.top_left, at.top_right] : [at[`top_${near}`], at[`top_${far}`], at.top_centre];\n const bottoms = [at[`bottom_${near}`], at[`bottom_${far}`], ...besideCta[near], ...besideCta[far]];\n const ordered = v === \"top\" ? [...tops, ...bottoms] : [...bottoms, ...tops];\n return ordered.filter((s, i) => ordered.findIndex((o) => o.clear.x === s.clear.x && o.clear.y === s.clear.y) === i);\n}\n\nconst grown = (r: PixelRect, by: number): PixelRect => ({\n x: r.x - by,\n y: r.y - by,\n width: r.width + 2 * by,\n height: r.height + 2 * by,\n});\n\n/**\n * Whether a logo's whole placed box (`slot.clear`: the logo, its clear space, and the plate when it\n * has one) is clean on the size: off every words box, its clear space off every face, person and\n * product, and no straight edge through it or at its side. Pure.\n */\nexport function logoSpotClean(slot: LogoSlot, scene: LogoScene): boolean {\n const space = slot.clear.height - slot.rect.height;\n const crowd = grown(slot.clear, Math.round(space / 2));\n return (\n !(scene.words ?? []).some((w) => overlaps(slot.clear, w)) &&\n !(scene.subjects ?? []).some((s) => overlaps(crowd, s)) &&\n !(scene.crossesEdge?.(crowd) ?? false)\n );\n}\n\n/**\n * Where the logo goes on a size, the one function the brief and the composite both decide it by: the\n * first of the designer's places (`designerSpots`) that is clean (`logoSpotClean`) on plain ground\n * where the logo reads, at its own width then a fifth and a sixth; else the first clean one, on a\n * plate of its own; else none, and the size's words are set again with the corner kept clear. Pure.\n */\nexport function chooseLogoSpot(\n frame: Size,\n safe: StaticSafeArea | SafeArea,\n opts: { aspect: number; position?: LogoPosition } & LogoScene,\n): LogoSpot | null {\n const spots = SPOT_SHARES.map((share) => ({\n share,\n slots: designerSpots(frame, safe, { ...opts, ...(share ? { share } : {}) }),\n }));\n for (const { share, slots } of spots) {\n const plain = slots.find(\n (s) => logoSpotClean(s, opts) && (opts.calm?.(s.clear) ?? true) && (opts.legible?.(s.rect) ?? true),\n );\n if (plain) return { slot: plain, plate: false, share };\n }\n for (const { share, slots } of spots) {\n const plated = slots.find((s) => logoSpotClean(s, opts));\n if (plated) return { slot: plated, plate: true, share };\n }\n return null;\n}\n\ntype PlateChoice = { colour: string; variant: number; contrast: number };\n\n/** The colours a plate may take when the brand names none that reads. */\nconst NEUTRAL_PLATES = [\n { colour: \"#000000\", luma: 0 },\n { colour: \"#FFFFFF\", luma: 255 },\n];\n\n/** The pair of a plate colour and a logo file (`inks`: each file's ink grey level, null when unreadable) that stand out most from each other. */\nfunction bestPlate(\n plates: ReadonlyArray<{ colour: string; luma: number }>,\n inks: ReadonlyArray<number | null>,\n): PlateChoice | null {\n const pairs = plates.flatMap(({ colour, luma }) =>\n inks.map((ink, variant) => ({ colour, variant, contrast: ink === null ? 0 : contrastRatio(luma, ink) })),\n );\n return pairs.reduce<PlateChoice | null>((top, p) => (p.contrast > (top?.contrast ?? 0) ? p : top), null);\n}\n\n/**\n * The plate colour and the logo file placed on it (`variant`, an index into `inks`): the pair among\n * the brand's colours (`plates`, with their grey level) that stand out most from each other, else\n * black or white when none reaches `MIN_LOGO_CONTRAST`. Null when no file can be read. Pure.\n */\nexport function plateColour(\n plates: ReadonlyArray<{ colour: string; luma: number }>,\n inks: ReadonlyArray<number | null>,\n): PlateChoice | null {\n const brand = bestPlate(plates, inks);\n return brand && brand.contrast >= MIN_LOGO_CONTRAST ? brand : bestPlate(NEUTRAL_PLATES, inks);\n}\n\n/**\n * The words boxes the logo keeps clear of, each grown so the clear space never touches them: by half\n * its height, and a button's (`cta`: the text boxes cover its label, not the button) by four fifths. Pure.\n */\nexport function inflatedWords(words: ReadonlyArray<{ box: PixelRect; cta: boolean }>): PixelRect[] {\n return words.map(({ box, cta }) => {\n const by = Math.round(box.height * (cta ? 0.8 : 0.5));\n return { x: box.x - by, y: box.y - by, width: box.width + 2 * by, height: box.height + 2 * by };\n });\n}\n\nfunction overlaps(a: PixelRect, b: PixelRect): boolean {\n return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;\n}\n\n/** A picture's grey levels, one byte a pixel, read from its RGBA pixels. */\nexport type GreyTable = { grey: Uint8Array; width: number; height: number };\n\nexport function greyTable(image: {\n data: ArrayLike<number>;\n width: number;\n height: number;\n /** Bytes a pixel: 4 for RGBA (the default), 3 for RGB. */\n channels?: number;\n}): GreyTable {\n const grey = new Uint8Array(image.width * image.height);\n const c = image.channels ?? 4;\n for (let i = 0; i < grey.length; i++) {\n const r = image.data[i * c] ?? 0;\n const g = image.data[i * c + 1] ?? 0;\n const b = image.data[i * c + 2] ?? 0;\n grey[i] = Math.round(0.299 * r + 0.587 * g + 0.114 * b);\n }\n return { grey, width: image.width, height: image.height };\n}\n\n/** How far the grey level spreads under a rectangle (standard deviation, 0-255): low is flat ground, high is type or a photo. */\nexport function spreadUnder(table: GreyTable, r: PixelRect): number {\n let n = 0;\n let sum = 0;\n let squares = 0;\n const step = 3;\n for (let y = Math.max(0, r.y); y < Math.min(table.height, r.y + r.height); y += step) {\n for (let x = Math.max(0, r.x); x < Math.min(table.width, r.x + r.width); x += step) {\n const v = table.grey[y * table.width + x] ?? 0;\n sum += v;\n squares += v * v;\n n++;\n }\n }\n if (n === 0) return 255;\n const mean = sum / n;\n return Math.sqrt(Math.max(0, squares / n - mean * mean));\n}\n\n/** The grey step (0-255) across a pixel that counts as an edge. */\nconst EDGE_STEP = 40;\n/** A straight edge runs along this share of a box's width or height, every step the same way. */\nconst EDGE_RUN = 0.6;\n\n/**\n * Whether a straight edge runs through the box `r` of the picture: a row or a column along which at\n * least `EDGE_RUN` of the pixels step by `EDGE_STEP` the same way (a card's border, a window's frame,\n * a phone's bezel). A photo's texture steps both ways and a flat ground not at all. Pure.\n */\nexport function straightEdgeIn(table: GreyTable, r: PixelRect): boolean {\n const x0 = Math.max(1, r.x);\n const y0 = Math.max(1, r.y);\n const x1 = Math.min(table.width - 1, r.x + r.width);\n const y1 = Math.min(table.height - 1, r.y + r.height);\n const at = (x: number, y: number) => table.grey[y * table.width + x] ?? 0;\n const runs = (count: number, step: (i: number) => number): boolean => {\n let up = 0;\n let down = 0;\n let n = 0;\n for (let i = 0; i < count; i += 2) {\n const d = step(i);\n n++;\n if (d >= EDGE_STEP) up++;\n else if (d <= -EDGE_STEP) down++;\n }\n return n > 0 && Math.max(up, down) >= EDGE_RUN * n;\n };\n for (let y = y0; y < y1; y++) {\n if (runs(x1 - x0, (i) => at(x0 + i, y + 1) - at(x0 + i, y - 1))) return true;\n }\n for (let x = x0; x < x1; x++) {\n if (runs(y1 - y0, (i) => at(x + 1, y0 + i) - at(x - 1, y0 + i))) return true;\n }\n return false;\n}\n","/**\n * The deterministic checks a static ad's variants pass before the judge sees them: the slot\n * the variants node feeds (`static_prefilter`, role `variant_prefilter`).\n *\n * Each variant's words and logo are read with their boxes (`checkStaticImage`): a line\n * missing, misspelt or joined by words nobody asked for, or any word or the logo where the\n * review of the finished sizes would block it (outside the band a cut master keeps clear;\n * under a placement's interface or cut by the frame on a relaid-out one), is a blocking defect. The variants are then ranked by the checks (blocking\n * defects, lines printed exactly, the brand's logo found, the button's words, the band) and\n * only the best-ranked go on, so the judge only breaks an exact tie. Bench E9\n * (.context/static-review/BENCH.md § \"E9 — judge calibrated to the user\"): no judge rubric or\n * model agreed with the person beyond chance, and the judge partly reads position, so the tied\n * variants reach it in an order seeded by the pictures, never the render order.\n *\n * Never leaves the judge with nothing: when every variant fails, the one with the fewest\n * defects is kept and `flagged` with them, so the round still has something to show and the\n * review names what is wrong. A variant the reader could not read (an outage) is kept\n * unchecked, tied with the best: the review of the finished sizes falls back to the review model.\n */\nimport { createHash } from \"node:crypto\";\nimport { AD_IMAGE_MODEL } from \"@baker/canvas-contract\";\nimport sharp from \"sharp\";\nimport type { SafeArea } from \"../../../scaffold/platform-safe-area.ts\";\nimport { readAdSpec } from \"../../../scaffold/static-ad-spec.ts\";\nimport {\n DEFAULT_MASTER_SHAPE,\n type MasterShape,\n planStaticFormats,\n type Size,\n} from \"../../../scaffold/static-sizes.ts\";\nimport { bandViolations } from \"./band-check.ts\";\nimport { type ExpectedLine, normalizeCopy, textMismatch } from \"./copy-match.ts\";\nimport { boxesOfLine } from \"./must-show.ts\";\nimport { askAboutImages, type ReviewUsage } from \"./render-review.ts\";\nimport { bytesOf, checkStaticImage } from \"./static-review.ts\";\nimport type { TextBox, TextBoxReading } from \"./text-boxes.ts\";\n\n/** One variant as the node hands it over: its position among the variants and where its pixels are. */\nexport type VariantImage = { index: number; path?: string; url?: string; sha256: string };\n\nexport type PrefilterResult = {\n /** Indexes of the variants the judge breaks the tie between, in the seeded order it sees them. */\n kept: number[];\n /** Every variant set aside, with the reasons in product words (its blocking defects, else what the best ones have). */\n dropped: Array<{ index: number; reasons: string[] }>;\n /** Every variant failed: the one kept anyway, with what is wrong with it. */\n flagged?: { index: number; reasons: string[] };\n /** Variants kept because the reader could not read them. */\n unchecked?: number[];\n /** Where a variant is cut to the master's frame when its centre would cut a word (`frameKeeping`). */\n frames?: Record<number, Frame>;\n /** The master's frame `frames` are placed on. */\n masterSize?: Size;\n};\n\n/** Where the master's frame sits on a picture scaled to cover it: pixels from the scaled picture's left and top. */\nexport type Frame = { left: number; top: number };\n\n/** How a picture of `from` pixels is scaled to cover `to`, and the frame cut about its centre. Pure. */\nfunction coverOf(from: Size, to: Size) {\n const scale = Math.max(to.width / from.width, to.height / from.height);\n const width = from.width * scale;\n const height = from.height * scale;\n return { scale, width, height, centre: { left: (width - to.width) / 2, top: (height - to.height) / 2 } };\n}\n\n/** Places a variant's boxes on the frame that keeps them whole, and says where that frame moved to, if anywhere. */\nfunction framingOf(from: Size, to: Size) {\n let frame: Frame | undefined;\n return {\n place: (boxes: TextBox[]) => {\n frame = frameKeeping(boxes, from, to);\n return coverFitBoxes(boxes, from, to, frame);\n },\n moved: (): Frame | undefined => {\n const { centre } = coverOf(from, to);\n return frame && (Math.abs(frame.left - centre.left) >= 1 || Math.abs(frame.top - centre.top) >= 1)\n ? frame\n : undefined;\n },\n };\n}\n\n/** The picture cut at `frame` to the `to` shape, at its own resolution (the master scales it). */\nexport async function cutToFrame(bytes: Buffer, frame: Frame, to: Size): Promise<Buffer> {\n const { width = 0, height = 0 } = await sharp(bytes).metadata();\n const { scale } = coverOf({ width, height }, to);\n const w = Math.min(width, Math.round(to.width / scale));\n const h = Math.min(height, Math.round(to.height / scale));\n const left = Math.min(width - w, Math.max(0, Math.round(frame.left / scale)));\n const top = Math.min(height - h, Math.max(0, Math.round(frame.top / scale)));\n return sharp(bytes).extract({ left, top, width: w, height: h }).png().toBuffer();\n}\n\n/** The margin a moved frame leaves past the outermost word, when the picture has room for it. */\nconst FRAME_MARGIN = 0.02;\n\n/**\n * The frame closest to the centre that keeps every word and the logo whole, with a small margin\n * when there is room: a 3:4 render cut to 4:5 loses 3% at top and bottom, which about the centre\n * cut the button off ads whose top had room to give (dev, Oct 2026). The centre when nothing\n * would be cut, or when the words span more than the frame holds. Pure.\n */\nexport function frameKeeping(boxes: readonly TextBox[], from: Size, to: Size): Frame {\n const cover = coverOf(from, to);\n if (boxes.length === 0) return cover.centre;\n const along = (offset: number, extent: number, frame: number, lo: number, hi: number) => {\n const low = lo * extent;\n const high = hi * extent;\n const room = extent - frame;\n const margin = FRAME_MARGIN * frame;\n for (const m of [margin, 0]) {\n const min = Math.max(0, high + m - frame);\n const max = Math.min(room, low - m);\n if (min <= max) return Math.min(max, Math.max(min, offset));\n }\n return offset;\n };\n const x0 = Math.min(...boxes.map((b) => b.x0));\n const x1 = Math.max(...boxes.map((b) => b.x1));\n const y0 = Math.min(...boxes.map((b) => b.y0));\n const y1 = Math.max(...boxes.map((b) => b.y1));\n return {\n left: along(cover.centre.left, cover.width, to.width, x0, x1),\n top: along(cover.centre.top, cover.height, to.height, y0, y1),\n };\n}\n\n/**\n * Boxes read on a picture of `from` pixels, placed on the `to` frame it becomes: the picture\n * fills the frame and the overflow is cut at `frame` (about the centre unless given), so a\n * variant rendered at a nearby supported ratio loses a sliver at two edges. Pure.\n */\nexport function coverFitBoxes(boxes: readonly TextBox[], from: Size, to: Size, frame?: Frame): TextBox[] {\n const cover = coverOf(from, to);\n const { left: offX, top: offY } = frame ?? cover.centre;\n const x = (f: number) => (f * cover.width - offX) / to.width;\n const y = (f: number) => (f * cover.height - offY) / to.height;\n return boxes.map((b) => ({ ...b, x0: x(b.x0), y0: y(b.y0), x1: x(b.x1), y1: y(b.y1) }));\n}\n\n/**\n * How the checks rank one variant, most important first, each a count (lower is better):\n * blocking defects, lines not printed exactly, the brand's logo not found (when the ad carries\n * one), the button's words not printed exactly, words or the logo outside the band.\n */\ntype Rank = readonly [blocking: number, linesOff: number, noLogo: number, noButton: number, outOfBand: number];\n\ntype Checked =\n | { index: number; blocking: string[]; rank: Rank; shortfalls: string[]; frame?: Frame }\n | { index: number; blocking: null };\n\nconst NO_LOGO = \"The brand's logo was not found on it.\";\n\n/** What one variant's boxes say against the spec, as its rank and what it lacks beyond its blocking defects. Pure. */\nfunction rankOf(\n boxes: readonly TextBox[],\n blocking: readonly string[],\n want: {\n lines: readonly ExpectedLine[];\n buttons: ReadonlySet<string>;\n brand?: string;\n logo: boolean;\n format: string;\n grade: BandGrade;\n },\n): { rank: Rank; shortfalls: string[] } {\n const allowed = want.brand ? [want.brand] : [];\n const off = textMismatch(want.lines, boxes, { allowed }).lines;\n const brand = want.brand ? normalizeCopy(want.brand) : null;\n const logoFound = boxes.some((b) => b.kind === \"logo\" || (brand !== null && normalizeCopy(b.text) === brand));\n const noLogo = want.logo && !logoFound ? 1 : 0;\n const noButton = off.some((l) => want.buttons.has(l.text)) ? 1 : 0;\n const outOfBand = bandViolations(boxes, want.format, want.grade).length;\n return {\n rank: [blocking.length, off.length, noLogo, noButton, outOfBand],\n shortfalls: noLogo ? [NO_LOGO] : [],\n };\n}\n\n/**\n * What a variant's boxes are held against. On the cut shapes, the band every size cut from the\n * master keeps clear. On `relayout` the master is the lead format delivered as it is and every\n * other size is laid out anew, so it is graded by its own placement exactly as the review of the\n * finished sizes grades it (close to a feed image's edge is a note there, not a defect).\n */\ntype BandGrade = { band: SafeArea } | { placements?: readonly string[] };\n\nconst isButton = (line: { role?: string; look?: string }): boolean =>\n /cta|button/i.test(`${line.role ?? \"\"} ${line.look ?? \"\"}`);\n\n/**\n * The part of the ad spec the variant checks read: its lines, which are buttons, the brand's\n * name and whether a logo is drawn. Projected into the canvas (`params.checks`) so an edit of\n * anything else in prompt.json (a note, the concept's transfer note) changes no step.\n */\nexport type StaticChecks = {\n kind: \"static_checks\";\n lines: ExpectedLine[];\n buttons: string[];\n brand?: string;\n logo: boolean;\n /**\n * Where the brand's logo file is placed on the master afterwards (its slot with clear space,\n * fractions of the master's frame): a line set there would sit under the logo, a blocking defect.\n */\n logo_slot?: { x0: number; y0: number; x1: number; y1: number };\n};\n\n/** The lines a variant set where the logo file is placed (`slot`), as blocking defects. Pure. */\nfunction linesUnderLogo(\n boxes: readonly TextBox[],\n lines: readonly ExpectedLine[],\n slot: { x0: number; y0: number; x1: number; y1: number } | undefined,\n): string[] {\n if (!slot) return [];\n const under = boxes.filter(\n (b) => b.kind === \"text\" && b.x0 < slot.x1 && b.x1 > slot.x0 && b.y0 < slot.y1 && b.y1 > slot.y0,\n );\n const named = under.map((b) => lines.find((l) => boxesOfLine(l, [b]).length > 0)?.text ?? b.text);\n return [...new Set(named)].map((text) => `\"${text}\" sits where the logo file is placed.`);\n}\n\n/** The checks a spec (or an already-projected `StaticChecks`) asks for; null when unreadable. Pure. */\nexport function staticChecksOf(spec: unknown): StaticChecks | null {\n if (spec && typeof spec === \"object\" && (spec as { kind?: unknown }).kind === \"static_checks\")\n return spec as StaticChecks;\n try {\n const parsed = readAdSpec(spec);\n // A native disguise carries the logo as its sender and no big button (C6): neither is ranked.\n const native = parsed.brand_presence === \"native\";\n return {\n kind: \"static_checks\",\n lines: parsed.copy.map((l) => ({ text: l.text, lettering: l.lettering, ...(l.role ? { role: l.role } : {}) })),\n buttons: native ? [] : parsed.copy.filter(isButton).map((l) => l.text),\n ...(parsed.brand?.name ? { brand: parsed.brand.name } : {}),\n logo: parsed.logo === true && !native,\n };\n } catch {\n return null;\n }\n}\n\n/**\n * Check each variant against the ad spec (prompt.json's content or its projected `StaticChecks`, null when unreadable) and the\n * formats it will be cut to. `read` is the box reader (the gateway's vision model unless given);\n * `masterShape`, `placements` and `lead` must be the ones the canvas was planned with.\n */\nexport async function prefilterVariants(\n variants: readonly VariantImage[],\n spec: unknown,\n formats: readonly string[],\n opts: {\n read?: (image: Buffer) => Promise<TextBoxReading>;\n masterShape?: MasterShape;\n placements?: readonly string[];\n lead?: string;\n onSpend?: (usage: ReviewUsage) => void;\n } = {},\n): Promise<PrefilterResult> {\n const everything: PrefilterResult = {\n kept: seededOrder(\n variants.map((v) => v.index),\n variants,\n ),\n dropped: [],\n };\n const checks = spec === null || spec === undefined ? null : staticChecksOf(spec);\n if (!checks) return everything;\n const { lines, brand, logo, logo_slot: slot } = checks;\n const buttons = new Set(checks.buttons);\n if (formats.length === 0 || variants.length === 0) return everything;\n // The model only sets the render ratio, which this does not read; the band is the model's too.\n const plan = planStaticFormats(AD_IMAGE_MODEL, formats, {\n masterShape: opts.masterShape ?? DEFAULT_MASTER_SHAPE,\n ...(opts.placements ? { placements: opts.placements } : {}),\n ...(opts.lead ? { lead: opts.lead } : {}),\n });\n const format = plan.master.format;\n // Re-laid out, or a variant's lead set on its own picture: the lead is delivered as it is, graded by its placement.\n const asDelivered = plan.masterShape === \"relayout\" || plan.masterShape === \"plate\";\n const grade: BandGrade = asDelivered ? (plan.placements ? { placements: plan.placements } : {}) : { band: plan.band };\n const want = { lines, buttons, ...(brand ? { brand } : {}), logo, format, grade };\n const checked = await Promise.all(\n variants.map((variant) =>\n checkVariant(variant, {\n format,\n size: plan.master.size,\n lines,\n brand,\n grade,\n want,\n opts,\n ...(slot ? { slot } : {}),\n }),\n ),\n );\n const outcome = prefilterOutcome(checked);\n const frames = Object.fromEntries(checked.flatMap((c) => (\"frame\" in c && c.frame ? [[c.index, c.frame]] : [])));\n return {\n ...outcome,\n kept: seededOrder(outcome.kept, variants),\n ...(Object.keys(frames).length > 0 ? { frames, masterSize: plan.master.size } : {}),\n };\n}\n\ntype VariantCheck = {\n format: string;\n size: Size;\n lines: readonly ExpectedLine[];\n brand: string | undefined;\n grade: BandGrade;\n want: Parameters<typeof rankOf>[2];\n opts: { read?: (image: Buffer) => Promise<TextBoxReading>; onSpend?: (usage: ReviewUsage) => void };\n /** Where the logo file is placed on the master (`StaticChecks.logo_slot`). */\n slot?: { x0: number; y0: number; x1: number; y1: number };\n};\n\n/** One variant's checks on the master's frame, cut where its words stay whole; unchecked when unreadable. */\nasync function checkVariant(variant: VariantImage, c: VariantCheck): Promise<Checked> {\n const { format, lines, brand, grade, want, opts } = c;\n const source = variant.path ?? variant.url;\n if (!source) return { index: variant.index, blocking: null };\n try {\n const bytes = await bytesOf(source);\n const { width = 0, height = 0 } = await sharp(bytes).metadata();\n const framing = framingOf({ width, height }, c.size);\n const check = await checkStaticImage(bytes, {\n format,\n lines,\n allowed: brand ? [brand] : [],\n ...grade,\n toFrame: framing.place,\n ...(opts.read ? { read: opts.read } : {}),\n ...(opts.onSpend ? { onSpend: opts.onSpend } : {}),\n });\n if (check.status === \"not_checked\") return { index: variant.index, blocking: null };\n const prefix = `${format}: `;\n const blocking = [\n ...check.findings\n .filter((f) => f.severity === \"blocking\")\n .map((f) => (f.what.startsWith(prefix) ? f.what.slice(prefix.length) : f.what)),\n ...linesUnderLogo(check.boxes, lines, c.slot),\n ];\n const frame = framing.moved();\n return { index: variant.index, blocking, ...rankOf(check.boxes, blocking, want), ...(frame ? { frame } : {}) };\n } catch {\n return { index: variant.index, blocking: null };\n }\n}\n\n/**\n * The variants the judge compares, in an order drawn from the pictures themselves (each one's\n * sha256 hashed with all of theirs): the same pictures always come in the same order, and that\n * order owes nothing to which was rendered first. Bench E9: the judge partly reads position,\n * crediting \"Image 1\" with the same feature whichever picture it is. Pure.\n */\nfunction seededOrder(indexes: readonly number[], variants: readonly VariantImage[]): number[] {\n const shaOf = new Map(variants.map((v) => [v.index, v.sha256] as const));\n const seed = [...variants.map((v) => v.sha256)].sort().join(\":\");\n const key = (index: number) =>\n createHash(\"sha256\")\n .update(`${seed}|${shaOf.get(index) ?? index}`)\n .digest(\"hex\");\n return [...indexes].sort((a, b) => (key(a) < key(b) ? -1 : key(a) > key(b) ? 1 : a - b));\n}\n\nconst compareRanks = (a: Rank, b: Rank): number => {\n for (let i = 0; i < a.length; i++) {\n const d = (a[i] ?? 0) - (b[i] ?? 0);\n if (d !== 0) return d;\n }\n return 0;\n};\n\n/**\n * Which variants go on to the judge, from each one's checks (blocking null = not read): the\n * ones the checks rank best, so the judge only breaks an exact tie; a variant the reader could\n * not read ties with the best that was read. Pure.\n */\nfunction prefilterOutcome(checked: readonly Checked[]): PrefilterResult {\n const unchecked = checked.filter((c) => c.blocking === null).map((c) => c.index);\n const read = checked.flatMap((c) => (c.blocking === null ? [] : [c]));\n const extra = unchecked.length > 0 ? { unchecked } : {};\n const clean = read.filter((c) => c.blocking.length === 0);\n if (clean.length === 0 && unchecked.length === 0) {\n const best = [...read].sort((a, b) => compareRanks(a.rank, b.rank) || a.index - b.index)[0];\n if (!best) return { kept: [], dropped: [], ...extra };\n const dropped = read.filter((c) => c.index !== best.index).map((c) => ({ index: c.index, reasons: c.blocking }));\n return { kept: [best.index], dropped, flagged: { index: best.index, reasons: best.blocking }, ...extra };\n }\n const top = [...clean].sort((a, b) => compareRanks(a.rank, b.rank))[0]?.rank;\n const kept = checked\n .filter((c) => c.blocking === null || (top !== undefined && compareRanks(c.rank, top) === 0))\n .map((c) => c.index);\n const dropped = read\n .filter((c) => !kept.includes(c.index))\n .map((c) => ({ index: c.index, reasons: c.blocking.length > 0 ? c.blocking : c.shortfalls }));\n return { kept, dropped, ...extra };\n}\n\n/** The judge's answer on a tie: its ranking lines (`judgeBrief`), and the image number it puts first. */\ntype JudgeAnswer = { reasoning: string; best: number };\n\nfunction judgeAnswerOf(raw: unknown): JudgeAnswer | null {\n const answer = raw as { reasoning?: unknown; best?: unknown } | null;\n const best = Number(answer?.best);\n if (typeof answer?.reasoning !== \"string\" || !Number.isInteger(best)) return null;\n return { reasoning: answer.reasoning, best };\n}\n\n/**\n * The judge, asked only when the checks leave a real tie (bench, Sept 2026: it decided 5 of 59\n * runs, and every other run paid a node for nothing): the tied variants shown in the seeded\n * order, the criteria `judgeBrief` compiled from the brief. Returns which of `tied` it puts\n * first and its reasoning; null when it did not answer (the caller keeps the checks' first).\n */\nexport async function judgeTie(\n tied: ReadonlyArray<{ index: number; path?: string; url?: string }>,\n opts: {\n model: string;\n prompt: string;\n onSpend?: (usage: ReviewUsage) => void;\n ask?: (model: string, images: string[], prompt: string) => Promise<unknown>;\n },\n): Promise<{ chosen: number; reasoning: string } | null> {\n const jpegs: string[] = [];\n for (const variant of tied) {\n const source = variant.path ?? variant.url;\n if (!source) return null;\n try {\n const bytes = await bytesOf(source);\n jpegs.push(\n (await sharp(bytes).resize(1024, 1024, { fit: \"inside\" }).jpeg({ quality: 85 }).toBuffer()).toString(\"base64\"),\n );\n } catch {\n return null;\n }\n }\n const prompt = `${opts.prompt}\\n\\nThe candidates are Image 1 to Image ${jpegs.length}, in the order shown. Reply with only this JSON: {\"reasoning\":\"<the ranking lines, then one sentence>\",\"best\":<the number of the image that wins>}`;\n const ask =\n opts.ask ?? ((model: string, images: string[], text: string) => askAboutImages(model, images, text, opts.onSpend));\n for (let attempt = 0; attempt < 2; attempt++) {\n const answer = judgeAnswerOf(await ask(opts.model, jpegs, prompt));\n const winner = answer ? tied[answer.best - 1] : undefined;\n if (answer && winner) return { chosen: winner.index, reasoning: answer.reasoning };\n }\n return null;\n}\n","/**\n * The brand's logo file as pixels, at the size it is placed at: an SVG drawn at a density that\n * makes it sharp there (sharp renders one at 72dpi by default, a handful of pixels for a small\n * viewBox), any file cut to its artwork (exports pad their logos), its shape always kept.\n */\nimport { readFile } from \"node:fs/promises\";\nimport sharp from \"sharp\";\nimport type { Rgba } from \"./logo-match.ts\";\n\n/** The long edge the artwork is drawn at before it is sized: sharp at any slot an ad has. */\nconst WORK_EDGE = 2048;\n/** A pixel at least this opaque is part of the artwork, for the cut to it. */\nconst ARTWORK_ALPHA = 8;\n\n/**\n * The logo file a picture was drawn from, when it is an SVG inked in the text colour: the ingest\n * hands it on as a PNG with `currentColor` already black (Zernio's coral wordmark came out black),\n * so the colour it is placed in can only come from the file it read (`source_path`). Null otherwise.\n */\nexport async function textColourSource(metadata: unknown): Promise<Buffer | null> {\n const source = (metadata as { source_path?: unknown } | undefined)?.source_path;\n if (typeof source !== \"string\" || !/\\.svg$/i.test(source)) return null;\n const svg = await readFile(source).catch(() => null);\n return svg && usesTextColour(svg) ? svg : null;\n}\n\n/** Whether an SVG logo is inked in the text colour (`currentColor`): the page it sits on colours it. */\nexport function usesTextColour(bytes: Buffer): boolean {\n const head = bytes.subarray(0, 512 * 1024).toString(\"utf8\");\n return /<svg/i.test(head) && /currentColor/i.test(head);\n}\n\n/**\n * The logo file drawn large and cut to its artwork (`WORK_EDGE` on its long side, before the cut).\n * An SVG inked in the text colour is drawn in `currentColor` (black when none is given).\n */\nexport async function logoArtwork(input: Buffer, opts: { currentColor?: string } = {}): Promise<Rgba> {\n const bytes = usesTextColour(input)\n ? Buffer.from(input.toString(\"utf8\").replace(/currentColor/gi, opts.currentColor ?? \"#000000\"))\n : input;\n const meta = await sharp(bytes).metadata();\n const long = Math.max(meta.width ?? 0, meta.height ?? 0) || WORK_EDGE;\n const density = meta.format === \"svg\" ? Math.min(2400, Math.max(1, (72 * WORK_EDGE) / long)) : undefined;\n const { data, info } = await sharp(bytes, density ? { density } : {})\n .ensureAlpha()\n .raw()\n .toBuffer({ resolveWithObject: true });\n let [x0, y0, x1, y1] = [info.width, info.height, -1, -1];\n for (let y = 0; y < info.height; y++) {\n for (let x = 0; x < info.width; x++) {\n if ((data[(y * info.width + x) * 4 + 3] ?? 0) < ARTWORK_ALPHA) continue;\n x0 = Math.min(x0, x);\n y0 = Math.min(y0, y);\n x1 = Math.max(x1, x);\n y1 = Math.max(y1, y);\n }\n }\n if (x1 < 0) throw new Error(\"the logo file has no visible artwork\");\n const width = x1 - x0 + 1;\n const height = y1 - y0 + 1;\n const cut = await sharp(data, { raw: { width: info.width, height: info.height, channels: 4 } })\n .extract({ left: x0, top: y0, width, height })\n .raw()\n .toBuffer();\n return { data: cut, width, height };\n}\n\n/** The artwork sized to fit inside `fit`, its shape kept. */\nexport async function fitArtwork(art: Rgba, fit: { width: number; height: number }): Promise<Rgba> {\n const { data, info } = await sharp(art.data, { raw: { width: art.width, height: art.height, channels: 4 } })\n .resize({ width: fit.width, height: fit.height, fit: \"inside\", kernel: \"lanczos3\" })\n .raw()\n .toBuffer({ resolveWithObject: true });\n return { data, width: info.width, height: info.height };\n}\n","/**\n * Integers spelled as words in the language they are spoken in.\n *\n * Two readers: native (Seedance) dialogue, where a bare \"6930\" in a French line is read\n * in English unless it is spelled out, and caption timing, where the script writes \"9\"\n * and the recogniser hears \"nueve\". One speller per language the blueprint can resolve\n * (the same set as its ISO table), via n2words, tree-shaken per language.\n */\nimport { toCardinal as nwAr } from \"n2words/ar-SA\";\nimport { toCardinal as nwDe } from \"n2words/de-DE\";\nimport { toCardinal as nwEn } from \"n2words/en-US\";\nimport { toCardinal as nwEs } from \"n2words/es-ES\";\nimport { toCardinal as nwFr } from \"n2words/fr-FR\";\nimport { toCardinal as nwHi } from \"n2words/hi-IN\";\nimport { toCardinal as nwIt } from \"n2words/it-IT\";\nimport { toCardinal as nwJa } from \"n2words/ja-JP\";\nimport { toCardinal as nwKo } from \"n2words/ko-KR\";\nimport { toCardinal as nwNl } from \"n2words/nl-NL\";\nimport { toCardinal as nwPl } from \"n2words/pl-PL\";\nimport { toCardinal as nwPt } from \"n2words/pt-PT\";\n\nconst INTEGER_SPELLERS: Record<string, (n: number) => string> = {\n fr: nwFr,\n es: nwEs,\n en: nwEn,\n de: nwDe,\n it: nwIt,\n pt: nwPt,\n nl: nwNl,\n pl: nwPl,\n ar: nwAr,\n ja: nwJa,\n ko: nwKo,\n hi: nwHi,\n};\n\n/** Whether integers can be spelled in this ISO 639-1 language. */\nexport function canSpellNumbers(langCode: string): boolean {\n return langCode in INTEGER_SPELLERS;\n}\n\n/**\n * Spell a non-negative integer into `langCode` words, or return the original digits\n * when the language is unsupported or the spelling fails.\n */\nexport function spellNumber(langCode: string | undefined, n: number): string {\n const spell = langCode ? INTEGER_SPELLERS[langCode] : undefined;\n if (!spell || !Number.isFinite(n)) return String(n);\n try {\n return spell(n);\n } catch {\n return String(n);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0HA,IAAM,YAAY,CAAC,MAAsB,EAAE,MAAM,KAAK,EAAE,OAAO,OAAO,EAAE;AACxE,IAAM,WAAW,CAAC,MAAsB;AACtC,QAAM,IAAI,EAAE,KA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;AACtD,MAAI,CAAC,SAAS,CAAC,OAAO,SAAS,CAAC,EAAG,QAAO,OAAO,CAAC;AAClD,MAAI;AACF,WAAO,MAAM,CAAC;AAAA,EAChB,QAAQ;AACN,WAAO,OAAO,CAAC;AAAA,EACjB;AACF;","names":["pct","designedLines","p","ratioValue","ratioValue","showsPeople","compiled","f","path","path","z","CODES","CODES","readFile","path","wordCount","CODES","path","readFile","estSpeechS","wordCount","clip","extract","readFile","path","path","readFile","z","plain","path","pct","inkLuma","plain","sharp","sharp","isButton","dropped","readFile","sharp"]}