@nodaro/shared 3.33.0 → 3.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/dist/{chunk-2NQLSLSN.cjs → chunk-24ZKPE33.cjs} +5 -5
  2. package/dist/{chunk-2NQLSLSN.cjs.map → chunk-24ZKPE33.cjs.map} +1 -1
  3. package/dist/{chunk-CK3GK34R.js → chunk-2HIDE3QV.js} +9 -3
  4. package/dist/chunk-2HIDE3QV.js.map +1 -0
  5. package/dist/{chunk-WDIBOWAA.js → chunk-2HVFF5SS.js} +6 -6
  6. package/dist/chunk-2HVFF5SS.js.map +1 -0
  7. package/dist/{chunk-FT5CF6IA.js → chunk-2QWNPYDG.js} +3 -3
  8. package/dist/{chunk-FT5CF6IA.js.map → chunk-2QWNPYDG.js.map} +1 -1
  9. package/dist/{chunk-M7GQBRZU.cjs → chunk-3YG3MYDE.cjs} +153 -24
  10. package/dist/chunk-3YG3MYDE.cjs.map +1 -0
  11. package/dist/{chunk-VNQRI2RO.cjs → chunk-5VNBQ4QK.cjs} +16 -16
  12. package/dist/{chunk-VNQRI2RO.cjs.map → chunk-5VNBQ4QK.cjs.map} +1 -1
  13. package/dist/{chunk-K3LLGRK7.cjs → chunk-5ZCXWA7J.cjs} +59 -15
  14. package/dist/chunk-5ZCXWA7J.cjs.map +1 -0
  15. package/dist/{chunk-Z2OL5AJD.cjs → chunk-6F6GGX2W.cjs} +4 -3
  16. package/dist/chunk-6F6GGX2W.cjs.map +1 -0
  17. package/dist/{chunk-D26ENTN2.cjs → chunk-72IFMNJE.cjs} +80 -52
  18. package/dist/chunk-72IFMNJE.cjs.map +1 -0
  19. package/dist/{chunk-SAW5OK36.cjs → chunk-A5Z3IMSJ.cjs} +6 -6
  20. package/dist/{chunk-SAW5OK36.cjs.map → chunk-A5Z3IMSJ.cjs.map} +1 -1
  21. package/dist/{chunk-VA42637J.cjs → chunk-AGEZY4LL.cjs} +46 -41
  22. package/dist/chunk-AGEZY4LL.cjs.map +1 -0
  23. package/dist/{chunk-BG5D5CZ6.js → chunk-ANOQWAMU.js} +23 -6
  24. package/dist/chunk-ANOQWAMU.js.map +1 -0
  25. package/dist/{chunk-PRYE7AZQ.cjs → chunk-AWWOQH46.cjs} +7 -7
  26. package/dist/chunk-AWWOQH46.cjs.map +1 -0
  27. package/dist/{chunk-JFS3NWZ5.cjs → chunk-B7WJJHJS.cjs} +7 -4
  28. package/dist/chunk-B7WJJHJS.cjs.map +1 -0
  29. package/dist/{chunk-D6GNRSCV.cjs → chunk-BBLE4UTG.cjs} +23 -6
  30. package/dist/chunk-BBLE4UTG.cjs.map +1 -0
  31. package/dist/{chunk-HGC5JNVA.cjs → chunk-BVVKMQKR.cjs} +9 -2
  32. package/dist/chunk-BVVKMQKR.cjs.map +1 -0
  33. package/dist/{chunk-YYV35XOS.js → chunk-C4R7BTBQ.js} +4 -3
  34. package/dist/chunk-C4R7BTBQ.js.map +1 -0
  35. package/dist/{chunk-PXFQVLBX.js → chunk-ETXUOETU.js} +26 -36
  36. package/dist/chunk-ETXUOETU.js.map +1 -0
  37. package/dist/{chunk-HKFMXNVQ.cjs → chunk-F4ZT5X2S.cjs} +11 -11
  38. package/dist/{chunk-HKFMXNVQ.cjs.map → chunk-F4ZT5X2S.cjs.map} +1 -1
  39. package/dist/{chunk-YBPBK5KI.js → chunk-FKQJYMCO.js} +97 -23
  40. package/dist/chunk-FKQJYMCO.js.map +1 -0
  41. package/dist/{chunk-ZDFHA2EC.js → chunk-FVKCNAEQ.js} +51 -7
  42. package/dist/chunk-FVKCNAEQ.js.map +1 -0
  43. package/dist/{chunk-ZL7UM6PU.cjs → chunk-GHBXS5RT.cjs} +4 -4
  44. package/dist/{chunk-ZL7UM6PU.cjs.map → chunk-GHBXS5RT.cjs.map} +1 -1
  45. package/dist/{chunk-ZO5PBBFX.js → chunk-GKJRNIP4.js} +59 -15
  46. package/dist/chunk-GKJRNIP4.js.map +1 -0
  47. package/dist/{chunk-UCFWI6D4.js → chunk-GRIMIJJ3.js} +3 -3
  48. package/dist/{chunk-UCFWI6D4.js.map → chunk-GRIMIJJ3.js.map} +1 -1
  49. package/dist/{chunk-5RYLK3MQ.js → chunk-GVHBHUFV.js} +11 -6
  50. package/dist/chunk-GVHBHUFV.js.map +1 -0
  51. package/dist/chunk-GZH2SIOF.cjs +99 -0
  52. package/dist/chunk-GZH2SIOF.cjs.map +1 -0
  53. package/dist/{chunk-SFW3UB2P.js → chunk-IJNQYMN7.js} +4 -4
  54. package/dist/{chunk-SFW3UB2P.js.map → chunk-IJNQYMN7.js.map} +1 -1
  55. package/dist/{chunk-HC7VKIV5.cjs → chunk-IRUPCNW2.cjs} +49 -46
  56. package/dist/chunk-IRUPCNW2.cjs.map +1 -0
  57. package/dist/{chunk-JL4C5VJ7.cjs → chunk-J65CAOUV.cjs} +14 -2
  58. package/dist/chunk-J65CAOUV.cjs.map +1 -0
  59. package/dist/{chunk-23FJQTEA.js → chunk-LJMNCSDG.js} +38 -15
  60. package/dist/chunk-LJMNCSDG.js.map +1 -0
  61. package/dist/{chunk-PVJBAPYJ.js → chunk-MEN7VLQ5.js} +8 -5
  62. package/dist/chunk-MEN7VLQ5.js.map +1 -0
  63. package/dist/{chunk-PHZ23DP3.js → chunk-MUA5L25B.js} +125 -12
  64. package/dist/chunk-MUA5L25B.js.map +1 -0
  65. package/dist/{chunk-WD6HJRBG.cjs → chunk-NWXB4F6D.cjs} +21 -21
  66. package/dist/{chunk-WD6HJRBG.cjs.map → chunk-NWXB4F6D.cjs.map} +1 -1
  67. package/dist/{chunk-PQHS255G.js → chunk-OHSIVNJO.js} +3 -3
  68. package/dist/chunk-OHSIVNJO.js.map +1 -0
  69. package/dist/{chunk-XGFTL5XY.js → chunk-PVVO23LZ.js} +3 -3
  70. package/dist/{chunk-XGFTL5XY.js.map → chunk-PVVO23LZ.js.map} +1 -1
  71. package/dist/{chunk-CUH22J4D.js → chunk-Q4ZXDDWA.js} +3 -3
  72. package/dist/{chunk-CUH22J4D.js.map → chunk-Q4ZXDDWA.js.map} +1 -1
  73. package/dist/{chunk-WKOIGLQX.cjs → chunk-QIIG2QDP.cjs} +8 -8
  74. package/dist/{chunk-WKOIGLQX.cjs.map → chunk-QIIG2QDP.cjs.map} +1 -1
  75. package/dist/{chunk-QA3MVQ32.js → chunk-QXW6O56Z.js} +6 -6
  76. package/dist/chunk-QXW6O56Z.js.map +1 -0
  77. package/dist/{chunk-5PC6JBGJ.cjs → chunk-R2VF5NQG.cjs} +3 -3
  78. package/dist/chunk-R2VF5NQG.cjs.map +1 -0
  79. package/dist/{chunk-7Z5LUTGU.js → chunk-RRI5YBUK.js} +6 -3
  80. package/dist/{chunk-JFS3NWZ5.cjs.map → chunk-RRI5YBUK.js.map} +1 -1
  81. package/dist/{chunk-HUR6ZJ7S.cjs → chunk-RUKFN3LJ.cjs} +6 -6
  82. package/dist/{chunk-HUR6ZJ7S.cjs.map → chunk-RUKFN3LJ.cjs.map} +1 -1
  83. package/dist/chunk-TCBHVIMD.js +89 -0
  84. package/dist/chunk-TCBHVIMD.js.map +1 -0
  85. package/dist/{chunk-SES6GDBQ.cjs → chunk-UJJUX6NW.cjs} +59 -8
  86. package/dist/chunk-UJJUX6NW.cjs.map +1 -0
  87. package/dist/{chunk-ZRL2UFTH.cjs → chunk-V3N56Z2S.cjs} +101 -22
  88. package/dist/chunk-V3N56Z2S.cjs.map +1 -0
  89. package/dist/{chunk-6WZ2VN7V.js → chunk-W36WCZS2.js} +6 -6
  90. package/dist/{chunk-6WZ2VN7V.js.map → chunk-W36WCZS2.js.map} +1 -1
  91. package/dist/{chunk-M36G6SRP.js → chunk-WXNQMJ67.js} +14 -3
  92. package/dist/chunk-WXNQMJ67.js.map +1 -0
  93. package/dist/{chunk-VXPLKQWY.cjs → chunk-XE5PE54B.cjs} +30 -40
  94. package/dist/chunk-XE5PE54B.cjs.map +1 -0
  95. package/dist/{chunk-OZSACQ2V.js → chunk-XJOBMAWW.js} +3 -3
  96. package/dist/{chunk-OZSACQ2V.js.map → chunk-XJOBMAWW.js.map} +1 -1
  97. package/dist/{chunk-OTATNBMD.js → chunk-XS7FI4JA.js} +3 -3
  98. package/dist/{chunk-OTATNBMD.js.map → chunk-XS7FI4JA.js.map} +1 -1
  99. package/dist/{chunk-HRXEZ3SX.cjs → chunk-YD3JA36S.cjs} +4 -4
  100. package/dist/{chunk-HRXEZ3SX.cjs.map → chunk-YD3JA36S.cjs.map} +1 -1
  101. package/dist/chunk-YYODFQEU.cjs +25 -0
  102. package/dist/chunk-YYODFQEU.cjs.map +1 -0
  103. package/dist/{chunk-UTQSSKSG.js → chunk-ZXBSARZX.js} +4 -4
  104. package/dist/{chunk-UTQSSKSG.js.map → chunk-ZXBSARZX.js.map} +1 -1
  105. package/dist/entries/apps.cjs +43 -42
  106. package/dist/entries/apps.d.cts +2 -2
  107. package/dist/entries/apps.d.ts +2 -2
  108. package/dist/entries/apps.js +8 -7
  109. package/dist/entries/catalogs.d.cts +1 -1
  110. package/dist/entries/catalogs.d.ts +1 -1
  111. package/dist/entries/credits.cjs +153 -153
  112. package/dist/entries/credits.d.cts +1 -1
  113. package/dist/entries/credits.d.ts +1 -1
  114. package/dist/entries/credits.js +8 -8
  115. package/dist/entries/edl.cjs +130 -102
  116. package/dist/entries/edl.d.cts +74 -3
  117. package/dist/entries/edl.d.ts +74 -3
  118. package/dist/entries/edl.js +2 -2
  119. package/dist/entries/entities.cjs +126 -122
  120. package/dist/entries/entities.d.cts +2 -2
  121. package/dist/entries/entities.d.ts +2 -2
  122. package/dist/entries/entities.js +1 -1
  123. package/dist/entries/i18n.cjs +11 -11
  124. package/dist/entries/i18n.d.cts +2 -2
  125. package/dist/entries/i18n.d.ts +2 -2
  126. package/dist/entries/i18n.js +1 -1
  127. package/dist/entries/llm-models.cjs +63 -43
  128. package/dist/entries/llm-models.d.cts +71 -4
  129. package/dist/entries/llm-models.d.ts +71 -4
  130. package/dist/entries/llm-models.js +1 -1
  131. package/dist/entries/media.cjs +45 -41
  132. package/dist/entries/media.d.cts +39 -1
  133. package/dist/entries/media.d.ts +39 -1
  134. package/dist/entries/media.js +1 -1
  135. package/dist/entries/model-catalog.cjs +66 -66
  136. package/dist/entries/model-catalog.d.cts +2 -2
  137. package/dist/entries/model-catalog.d.ts +2 -2
  138. package/dist/entries/model-catalog.js +4 -4
  139. package/dist/entries/models.cjs +274 -210
  140. package/dist/entries/models.d.cts +3 -3
  141. package/dist/entries/models.d.ts +3 -3
  142. package/dist/entries/models.js +5 -5
  143. package/dist/entries/nodes.cjs +222 -201
  144. package/dist/entries/nodes.d.cts +48 -8
  145. package/dist/entries/nodes.d.ts +48 -8
  146. package/dist/entries/nodes.js +10 -9
  147. package/dist/entries/pipeline.cjs +149 -149
  148. package/dist/entries/pipeline.d.cts +8 -4
  149. package/dist/entries/pipeline.d.ts +8 -4
  150. package/dist/entries/pipeline.js +3 -3
  151. package/dist/entries/social.cjs +174 -174
  152. package/dist/entries/social.d.cts +13 -5
  153. package/dist/entries/social.d.ts +13 -5
  154. package/dist/entries/social.js +2 -2
  155. package/dist/entries/types.d.cts +1 -1
  156. package/dist/entries/types.d.ts +1 -1
  157. package/dist/entries/ugc.cjs +71 -71
  158. package/dist/entries/ugc.js +4 -4
  159. package/dist/entries/video.cjs +115 -115
  160. package/dist/entries/video.d.cts +4 -3
  161. package/dist/entries/video.d.ts +4 -3
  162. package/dist/entries/video.js +4 -4
  163. package/dist/entries/workflow.cjs +96 -95
  164. package/dist/entries/workflow.d.cts +7 -18
  165. package/dist/entries/workflow.d.ts +7 -18
  166. package/dist/entries/workflow.js +2 -1
  167. package/dist/index.cjs +1708 -1567
  168. package/dist/index.d.cts +9 -9
  169. package/dist/index.d.ts +9 -9
  170. package/dist/index.js +26 -25
  171. package/dist/{model-catalog-V-ZNzRSd.d.ts → model-catalog-VIHGmQL2.d.cts} +22 -0
  172. package/dist/{model-catalog-V-ZNzRSd.d.cts → model-catalog-VIHGmQL2.d.ts} +22 -0
  173. package/dist/{presentation-utils-D0kxsWf9.d.cts → presentation-utils-A4i92SYo.d.cts} +1 -1
  174. package/dist/{presentation-utils-pZwlEAzo.d.ts → presentation-utils-DjdPtM9k.d.ts} +1 -1
  175. package/dist/{scene-node-types-C3kl_zyK.d.ts → scene-node-types-Cvbtf-0a.d.cts} +147 -6
  176. package/dist/{scene-node-types-C3kl_zyK.d.cts → scene-node-types-Cvbtf-0a.d.ts} +147 -6
  177. package/dist/{types-DffyGSy5.d.cts → types-CU6SQnMS.d.cts} +0 -5
  178. package/dist/{types-DffyGSy5.d.ts → types-CU6SQnMS.d.ts} +0 -5
  179. package/dist/{types-BRlFPEru.d.ts → types-DzUBR7yr.d.cts} +8 -1
  180. package/dist/{types-BRlFPEru.d.cts → types-DzUBR7yr.d.ts} +8 -1
  181. package/package.json +1 -1
  182. package/src/__tests__/camera-switch-contract.test.ts +33 -1
  183. package/src/__tests__/character-mention-slug.test.ts +0 -8
  184. package/src/__tests__/effective-tier.test.ts +3 -14
  185. package/src/__tests__/fixtures/camera-switch-speaker-map-parity.json +178 -0
  186. package/src/__tests__/fixtures/root-exports.baseline.json +21 -0
  187. package/src/__tests__/fixtures/speaker-map-camera-ids.json +26 -0
  188. package/src/__tests__/gvp-supported-providers.test.ts +1 -0
  189. package/src/__tests__/i18n-locale-completeness.test.ts +38 -3
  190. package/src/__tests__/llm-models.test.ts +200 -20
  191. package/src/__tests__/node-preset-extract.test.ts +10 -0
  192. package/src/__tests__/preview-gate-use-case.test.ts +16 -1
  193. package/src/__tests__/producer-types.test.ts +19 -0
  194. package/src/__tests__/run-continuation.test.ts +4 -1
  195. package/src/__tests__/speaker-map-contract.test.ts +48 -0
  196. package/src/__tests__/unit-contract-compose.test.ts +129 -0
  197. package/src/__tests__/unit-contracts.test.ts +134 -0
  198. package/src/__tests__/use-case-types.test.ts +33 -0
  199. package/src/__tests__/video-collapse-parity.test.ts +10 -0
  200. package/src/__tests__/video-frame-slot.test.ts +85 -0
  201. package/src/__tests__/video-mode-aliases.test.ts +1 -0
  202. package/src/__tests__/video-reference-only.test.ts +117 -0
  203. package/src/__tests__/vidu-q4-catalog.test.ts +230 -0
  204. package/src/camera-switch-contract.ts +36 -2
  205. package/src/credit-identifiers.ts +19 -6
  206. package/src/entity-asset-types.ts +13 -0
  207. package/src/entries/edl.ts +2 -0
  208. package/src/entries/llm-models.ts +5 -0
  209. package/src/entries/media.ts +1 -0
  210. package/src/entries/models.ts +25 -0
  211. package/src/entries/nodes.ts +5 -1
  212. package/src/fan-out-rows.ts +36 -3
  213. package/src/generate-mask.ts +40 -0
  214. package/src/generated/unit-contracts.ts +58 -0
  215. package/src/i18n/types.ts +13 -2
  216. package/src/json-kinds.ts +24 -4
  217. package/src/llm-models.ts +184 -31
  218. package/src/meta-ads-scrape.ts +16 -8
  219. package/src/model-catalog.ts +78 -13
  220. package/src/model-constants.ts +260 -5
  221. package/src/node-default-mappings.ts +3 -0
  222. package/src/node-preset-extract.ts +8 -0
  223. package/src/pipeline-types.ts +3 -0
  224. package/src/presentation-utils.ts +12 -12
  225. package/src/preview-gate.ts +4 -2
  226. package/src/producer-types.ts +19 -19
  227. package/src/run-continuation.ts +26 -4
  228. package/src/speaker-layouts.ts +8 -3
  229. package/src/speaker-map-contract.ts +77 -0
  230. package/src/unit-contract-compose.ts +55 -0
  231. package/src/use-case-types.ts +19 -0
  232. package/src/video-ui-defaults.ts +7 -5
  233. package/dist/chunk-23FJQTEA.js.map +0 -1
  234. package/dist/chunk-5PC6JBGJ.cjs.map +0 -1
  235. package/dist/chunk-5RYLK3MQ.js.map +0 -1
  236. package/dist/chunk-7Z5LUTGU.js.map +0 -1
  237. package/dist/chunk-BG5D5CZ6.js.map +0 -1
  238. package/dist/chunk-CK3GK34R.js.map +0 -1
  239. package/dist/chunk-D26ENTN2.cjs.map +0 -1
  240. package/dist/chunk-D6GNRSCV.cjs.map +0 -1
  241. package/dist/chunk-HC7VKIV5.cjs.map +0 -1
  242. package/dist/chunk-HGC5JNVA.cjs.map +0 -1
  243. package/dist/chunk-JL4C5VJ7.cjs.map +0 -1
  244. package/dist/chunk-K3LLGRK7.cjs.map +0 -1
  245. package/dist/chunk-M36G6SRP.js.map +0 -1
  246. package/dist/chunk-M7GQBRZU.cjs.map +0 -1
  247. package/dist/chunk-PHZ23DP3.js.map +0 -1
  248. package/dist/chunk-PQHS255G.js.map +0 -1
  249. package/dist/chunk-PRYE7AZQ.cjs.map +0 -1
  250. package/dist/chunk-PVJBAPYJ.js.map +0 -1
  251. package/dist/chunk-PXFQVLBX.js.map +0 -1
  252. package/dist/chunk-QA3MVQ32.js.map +0 -1
  253. package/dist/chunk-SES6GDBQ.cjs.map +0 -1
  254. package/dist/chunk-TU33KYKW.cjs +0 -25
  255. package/dist/chunk-TU33KYKW.cjs.map +0 -1
  256. package/dist/chunk-VA42637J.cjs.map +0 -1
  257. package/dist/chunk-VXPLKQWY.cjs.map +0 -1
  258. package/dist/chunk-WDIBOWAA.js.map +0 -1
  259. package/dist/chunk-YBPBK5KI.js.map +0 -1
  260. package/dist/chunk-YYV35XOS.js.map +0 -1
  261. package/dist/chunk-Z2OL5AJD.cjs.map +0 -1
  262. package/dist/chunk-ZDFHA2EC.js.map +0 -1
  263. package/dist/chunk-ZO5PBBFX.js.map +0 -1
  264. package/dist/chunk-ZRL2UFTH.cjs.map +0 -1
  265. package/src/__tests__/__snapshots__/prompt-builder-segments.test.ts.snap +0 -65
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/combine-transitions.ts","../src/edl-multicam.ts","../src/speaker-layouts.ts","../src/edl.ts","../src/edit-plan-review.ts"],"names":[],"mappings":";;;AAiCO,IAAM,mBAAA,GAAoD;AAAA;AAAA,EAE/D;AAAA,IACE,EAAA,EAAI,KAAA;AAAA,IACJ,KAAA,EAAO,KAAA;AAAA,IACP,KAAA,EAAO,IAAA;AAAA,IACP,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,IAAA;AAAA,IACR,WAAA,EAAa;AAAA,GACf;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AA,GAAiB,OAAO,KAAA,KAAU,QAAA,IAAY,MAAM,MAAA,GAAS,CAAA,IAAK,KAAA,KAAU,aAAA,CAAc,IAAI,CAAA;AACpG,EAAA,OAAO,cAAA,GAAiB,EAAE,aAAA,EAAe,IAAA,KAAS,EAAE,aAAA,EAAe,IAAA,EAAM,SAAA,EAAW,MAAA,EAAU;AAChG;AASO,SAAS,iBAAA,CAAkB,WAAoB,IAAA,EAA8B;AAClF,EAAA,MAAM,KAAA,GAAQ,aAAA,CAAc,SAAA,EAAW,IAAI,CAAA;AAC3C,EAAA,IAAI,KAAA,CAAM,MAAA,KAAW,MAAA,EAAQ,OAAO,EAAE,EAAA,EAAI,KAAA,EAAO,MAAA,EAAQ,CAAC,kBAAkB,CAAA,EAAG,QAAA,EAAU,EAAC,EAAE;AAC5F,EAAA,IAAI,KAAA,CAAM,MAAA,KAAW,SAAA,EAAW,OAAO,EAAE,EAAA,EAAI,KAAA,EAAO,MAAA,EAAQ,CAAC,KAAA,CAAM,KAAK,CAAA,EAAG,QAAA,EAAU,EAAC,EAAE;AACxF,EAAA,IAAI,KAAA,CAAM,MAAA,CAAO,IAAA,KAAS,OAAA,EAAS,OAAO,EAAE,EAAA,EAAI,IAAA,EAAM,MAAA,EAAQ,EAAC,EAAG,QAAA,EAAU,EAAC,EAAE;AAC/E,EAAA,MAAM,QAAA,GAAW,qBAAA,CAAsB,IAAA,EAAM,SAAS,CAAA,CAAE,IAAA;AACxD,EAAA,OAAO,YAAY,QAAQ,CAAA;AAC7B","file":"chunk-5PC6JBGJ.cjs","sourcesContent":["/**\n * Catalog of every transition the combine-videos node supports.\n *\n * `id` is the stable identifier used in workflow JSON, Zod validation, and\n * the preview-CSS class suffix. `xfade` is the FFmpeg `xfade transition=`\n * name (or `null` for `cut`, which goes through the concat demuxer).\n *\n * The 5 original ids (`cut`, `fade`, `dissolve`, `dip-to-black`,\n * `dip-to-white`) are kept for back-compat with workflows saved before the\n * picker shipped.\n */\n\nexport type CombineTransitionGroup =\n | \"fades\"\n | \"wipes\"\n | \"slides\"\n | \"shapes\"\n | \"smooth\"\n | \"slices\"\n | \"reveals\"\n | \"covers\"\n | \"effects\"\n\nexport interface CombineTransition {\n readonly id: string\n readonly label: string\n /** FFmpeg `xfade transition=` name. `null` = special path (concat demuxer for cut). */\n readonly xfade: string | null\n readonly group: CombineTransitionGroup\n readonly common?: boolean\n readonly description: string\n}\n\nexport const COMBINE_TRANSITIONS: readonly CombineTransition[] = [\n // ===== Fades & Dips =====\n {\n id: \"cut\",\n label: \"Cut\",\n xfade: null,\n group: \"fades\",\n common: true,\n description: \"Hard cut — instant switch with no blend. Default, fastest.\",\n },\n {\n id: \"fade\",\n label: \"Fade\",\n xfade: \"fade\",\n group: \"fades\",\n common: true,\n description: \"Smooth alpha cross-fade between two clips. Classic clean blend.\",\n },\n {\n id: \"dissolve\",\n label: \"Dissolve\",\n xfade: \"dissolve\",\n group: \"fades\",\n common: true,\n description: \"Random-pixel dissolve. Grainy, organic feel — good for memory beats.\",\n },\n {\n id: \"dip-to-black\",\n label: \"Dip to Black\",\n xfade: \"fadeblack\",\n group: \"fades\",\n common: true,\n description: \"Fade through black. Use between scenes or time jumps.\",\n },\n {\n id: \"dip-to-white\",\n label: \"Dip to White\",\n xfade: \"fadewhite\",\n group: \"fades\",\n common: true,\n description: \"Fade through white. Bright, ethereal — flashbacks, dream beats.\",\n },\n {\n id: \"fadegrays\",\n label: \"Fade through Greys\",\n xfade: \"fadegrays\",\n group: \"fades\",\n description: \"Desaturates to grey at the midpoint, then re-saturates into B.\",\n },\n\n // ===== Wipes =====\n {\n id: \"wipe-left\",\n label: \"Wipe Left\",\n xfade: \"wipeleft\",\n group: \"wipes\",\n common: true,\n description: \"Hard edge sweeps from right to left, revealing the next clip.\",\n },\n {\n id: \"wipe-right\",\n label: \"Wipe Right\",\n xfade: \"wiperight\",\n group: \"wipes\",\n common: true,\n description: \"Hard edge sweeps from left to right.\",\n },\n {\n id: \"wipe-up\",\n label: \"Wipe Up\",\n xfade: \"wipeup\",\n group: \"wipes\",\n description: \"Edge sweeps from bottom to top.\",\n },\n {\n id: \"wipe-down\",\n label: \"Wipe Down\",\n xfade: \"wipedown\",\n group: \"wipes\",\n description: \"Edge sweeps from top to bottom.\",\n },\n {\n id: \"wipe-tl\",\n label: \"Wipe Top-Left\",\n xfade: \"wipetl\",\n group: \"wipes\",\n description: \"Diagonal wipe from top-left corner.\",\n },\n {\n id: \"wipe-tr\",\n label: \"Wipe Top-Right\",\n xfade: \"wipetr\",\n group: \"wipes\",\n description: \"Diagonal wipe from top-right corner.\",\n },\n {\n id: \"wipe-bl\",\n label: \"Wipe Bottom-Left\",\n xfade: \"wipebl\",\n group: \"wipes\",\n description: \"Diagonal wipe from bottom-left corner.\",\n },\n {\n id: \"wipe-br\",\n label: \"Wipe Bottom-Right\",\n xfade: \"wipebr\",\n group: \"wipes\",\n description: \"Diagonal wipe from bottom-right corner.\",\n },\n\n // ===== Slides =====\n {\n id: \"slide-left\",\n label: \"Slide Left\",\n xfade: \"slideleft\",\n group: \"slides\",\n common: true,\n description: \"Next clip pushes A off-screen, sliding in from the right.\",\n },\n {\n id: \"slide-right\",\n label: \"Slide Right\",\n xfade: \"slideright\",\n group: \"slides\",\n common: true,\n description: \"Next clip pushes A off-screen, sliding in from the left.\",\n },\n {\n id: \"slide-up\",\n label: \"Slide Up\",\n xfade: \"slideup\",\n group: \"slides\",\n description: \"Next clip pushes A upward off-screen.\",\n },\n {\n id: \"slide-down\",\n label: \"Slide Down\",\n xfade: \"slidedown\",\n group: \"slides\",\n description: \"Next clip pushes A downward off-screen.\",\n },\n\n // ===== Smooth (gradient-edge wipes) =====\n {\n id: \"smooth-left\",\n label: \"Smooth Left\",\n xfade: \"smoothleft\",\n group: \"smooth\",\n description: \"Soft-edged wipe sweeping leftward — gentler than a hard wipe.\",\n },\n {\n id: \"smooth-right\",\n label: \"Smooth Right\",\n xfade: \"smoothright\",\n group: \"smooth\",\n description: \"Soft-edged wipe sweeping rightward.\",\n },\n {\n id: \"smooth-up\",\n label: \"Smooth Up\",\n xfade: \"smoothup\",\n group: \"smooth\",\n description: \"Soft-edged wipe sweeping upward.\",\n },\n {\n id: \"smooth-down\",\n label: \"Smooth Down\",\n xfade: \"smoothdown\",\n group: \"smooth\",\n description: \"Soft-edged wipe sweeping downward.\",\n },\n\n // ===== Shapes (circles, rectangles, openings) =====\n {\n id: \"circle-open\",\n label: \"Circle Open\",\n xfade: \"circleopen\",\n group: \"shapes\",\n common: true,\n description: \"Circular iris opens to reveal next clip from the center.\",\n },\n {\n id: \"circle-close\",\n label: \"Circle Close\",\n xfade: \"circleclose\",\n group: \"shapes\",\n description: \"Circular iris closes inward over the current clip.\",\n },\n {\n id: \"circle-crop\",\n label: \"Circle Crop\",\n xfade: \"circlecrop\",\n group: \"shapes\",\n description: \"Circular mask crops A then expands as B.\",\n },\n {\n id: \"rect-crop\",\n label: \"Rectangle Crop\",\n xfade: \"rectcrop\",\n group: \"shapes\",\n description: \"Rectangular mask crops A then expands as B.\",\n },\n {\n id: \"horz-open\",\n label: \"Horizontal Open\",\n xfade: \"horzopen\",\n group: \"shapes\",\n description: \"Two horizontal bars split apart from the center to reveal B.\",\n },\n {\n id: \"horz-close\",\n label: \"Horizontal Close\",\n xfade: \"horzclose\",\n group: \"shapes\",\n description: \"Top and bottom bars meet at the center.\",\n },\n {\n id: \"vert-open\",\n label: \"Vertical Open\",\n xfade: \"vertopen\",\n group: \"shapes\",\n description: \"Two vertical bars split apart from the center to reveal B.\",\n },\n {\n id: \"vert-close\",\n label: \"Vertical Close\",\n xfade: \"vertclose\",\n group: \"shapes\",\n description: \"Left and right bars meet at the center.\",\n },\n {\n id: \"diag-tl\",\n label: \"Diagonal Top-Left\",\n xfade: \"diagtl\",\n group: \"shapes\",\n description: \"Diagonal slash sweep originating top-left.\",\n },\n {\n id: \"diag-tr\",\n label: \"Diagonal Top-Right\",\n xfade: \"diagtr\",\n group: \"shapes\",\n description: \"Diagonal slash sweep originating top-right.\",\n },\n {\n id: \"diag-bl\",\n label: \"Diagonal Bottom-Left\",\n xfade: \"diagbl\",\n group: \"shapes\",\n description: \"Diagonal slash sweep originating bottom-left.\",\n },\n {\n id: \"diag-br\",\n label: \"Diagonal Bottom-Right\",\n xfade: \"diagbr\",\n group: \"shapes\",\n description: \"Diagonal slash sweep originating bottom-right.\",\n },\n\n // ===== Slices =====\n {\n id: \"hl-slice\",\n label: \"Horizontal Left Slice\",\n xfade: \"hlslice\",\n group: \"slices\",\n description: \"Horizontal strips slice in from the left.\",\n },\n {\n id: \"hr-slice\",\n label: \"Horizontal Right Slice\",\n xfade: \"hrslice\",\n group: \"slices\",\n description: \"Horizontal strips slice in from the right.\",\n },\n {\n id: \"vu-slice\",\n label: \"Vertical Up Slice\",\n xfade: \"vuslice\",\n group: \"slices\",\n description: \"Vertical strips slice in from the bottom.\",\n },\n {\n id: \"vd-slice\",\n label: \"Vertical Down Slice\",\n xfade: \"vdslice\",\n group: \"slices\",\n description: \"Vertical strips slice in from the top.\",\n },\n\n // ===== Reveals =====\n {\n id: \"reveal-left\",\n label: \"Reveal Left\",\n xfade: \"revealleft\",\n group: \"reveals\",\n description: \"A slides leftward off-screen, revealing the static B underneath.\",\n },\n {\n id: \"reveal-right\",\n label: \"Reveal Right\",\n xfade: \"revealright\",\n group: \"reveals\",\n description: \"A slides rightward off-screen, revealing B.\",\n },\n {\n id: \"reveal-up\",\n label: \"Reveal Up\",\n xfade: \"revealup\",\n group: \"reveals\",\n description: \"A slides upward, revealing B.\",\n },\n {\n id: \"reveal-down\",\n label: \"Reveal Down\",\n xfade: \"revealdown\",\n group: \"reveals\",\n description: \"A slides downward, revealing B.\",\n },\n\n // ===== Covers =====\n {\n id: \"cover-left\",\n label: \"Cover Left\",\n xfade: \"coverleft\",\n group: \"covers\",\n description: \"B slides in from the right and covers A in place.\",\n },\n {\n id: \"cover-right\",\n label: \"Cover Right\",\n xfade: \"coverright\",\n group: \"covers\",\n description: \"B slides in from the left and covers A.\",\n },\n {\n id: \"cover-up\",\n label: \"Cover Up\",\n xfade: \"coverup\",\n group: \"covers\",\n description: \"B slides up from below and covers A.\",\n },\n {\n id: \"cover-down\",\n label: \"Cover Down\",\n xfade: \"coverdown\",\n group: \"covers\",\n description: \"B slides down from above and covers A.\",\n },\n\n // ===== Effects =====\n {\n id: \"pixelize\",\n label: \"Pixelize\",\n xfade: \"pixelize\",\n group: \"effects\",\n description: \"Both clips pixelate to chunky blocks at the midpoint, then sharpen into B.\",\n },\n {\n id: \"radial\",\n label: \"Radial Wipe\",\n xfade: \"radial\",\n group: \"effects\",\n description: \"Clock-hand sweep around the center.\",\n },\n {\n id: \"hblur\",\n label: \"Blur\",\n xfade: \"hblur\",\n group: \"effects\",\n description: \"Heavy horizontal blur at midpoint — dreamy speed-blur look.\",\n },\n {\n id: \"distance\",\n label: \"Distance\",\n xfade: \"distance\",\n group: \"effects\",\n description: \"Distance-field morph between A and B. Subtle dimensional warp.\",\n },\n {\n id: \"zoom-in\",\n label: \"Zoom In\",\n xfade: \"zoomin\",\n group: \"effects\",\n description: \"B zooms outward from a point in A.\",\n },\n {\n id: \"squeeze-h\",\n label: \"Squeeze Horizontal\",\n xfade: \"squeezeh\",\n group: \"effects\",\n description: \"A squeezes horizontally to a line, then B expands.\",\n },\n {\n id: \"squeeze-v\",\n label: \"Squeeze Vertical\",\n xfade: \"squeezev\",\n group: \"effects\",\n description: \"A squeezes vertically to a line, then B expands.\",\n },\n]\n\n/** All valid transition ids, sorted in catalog order. Use this for Zod enums. */\nexport const COMBINE_TRANSITION_IDS: readonly string[] = COMBINE_TRANSITIONS.map((t) => t.id)\n\n/** Ordered list of group tab keys. `common` is a virtual tab, prepended in UI. */\nexport const COMBINE_TRANSITION_GROUP_ORDER: readonly CombineTransitionGroup[] = [\n \"fades\",\n \"wipes\",\n \"slides\",\n \"smooth\",\n \"shapes\",\n \"slices\",\n \"reveals\",\n \"covers\",\n \"effects\",\n]\n\nexport const COMBINE_TRANSITION_GROUP_LABELS: Record<CombineTransitionGroup, string> = {\n fades: \"Fades & Dips\",\n wipes: \"Wipes\",\n slides: \"Slides\",\n smooth: \"Smooth\",\n shapes: \"Shapes\",\n slices: \"Slices\",\n reveals: \"Reveals\",\n covers: \"Covers\",\n effects: \"Effects\",\n}\n\nconst TRANSITIONS_BY_ID: ReadonlyMap<string, CombineTransition> = new Map(\n COMBINE_TRANSITIONS.map((t) => [t.id, t]),\n)\n\nexport function getCombineTransition(id: string): CombineTransition | undefined {\n return TRANSITIONS_BY_ID.get(id)\n}\n\n/**\n * Resolve the FFmpeg `xfade transition=` name for a given transition id.\n * Returns `null` for `cut` (handled via the concat demuxer instead of xfade).\n * Throws for unknown ids — callers validate input via Zod first.\n */\nexport function resolveXfadeName(id: string): string | null {\n const entry = TRANSITIONS_BY_ID.get(id)\n if (!entry) {\n throw new Error(`Unknown combine-videos transition: ${id}`)\n }\n return entry.xfade\n}\n\n/**\n * Map a `transition` PARAMETER-NODE pick (the @nodaro/prompts creative\n * catalog — prose-hint transitions for AI video prompts) onto the ffmpeg\n * xfade vocabulary above. The two vocabularies are deliberately different\n * (the picker describes shots, this table describes blends); only the\n * visually-faithful subset maps — everything else falls back to `cut`.\n *\n * Consumed by the slideshow node (its transition TYPE comes from a wired\n * transition parameter node; unwired defaults to cut). Kept here — not in\n * @nodaro/prompts — because the dependency points prompts → shared, and the\n * ids are plain strings on both sides.\n */\nexport const PICKER_TO_COMBINE_TRANSITION: Readonly<Record<string, string>> = {\n \"none\": \"cut\",\n \"auto\": \"dissolve\", // an explicitly wired \"auto\" wants A blend — the classic slideshow default\n \"cross-dissolve\": \"dissolve\",\n \"fade-to-black\": \"dip-to-black\",\n \"fade-to-white\": \"dip-to-white\",\n \"iris\": \"circle-open\",\n \"wipe\": \"wipe-left\",\n \"pixelate-reform\": \"pixelize\",\n \"dissolve-to-mist\": \"hblur\",\n \"match-cut\": \"cut\",\n \"smash-cut\": \"cut\",\n \"freeze-frame-jump\": \"cut\",\n}\n\n/**\n * Resolve ANY transition string a slideshow may receive — a combine id\n * (already valid), a picker id (mapped), or anything else (→ cut).\n */\nexport function resolveSlideshowTransition(value: string | undefined | null): string {\n if (!value) return \"cut\"\n if (COMBINE_TRANSITION_IDS.includes(value)) return value\n return PICKER_TO_COMBINE_TRANSITION[value] ?? \"cut\"\n}\n\n","/**\n * Multicam helpers over the EDL contract (`edl.ts`): folding measured source\n * offsets into an EDL (D19) and resolving what each on-screen slot of a\n * segment shows (D20). Pure — no I/O. Type-only imports from `edl.ts` keep the\n * module graph free of runtime cycles.\n */\nimport type { Edl, EdlRegion, EdlSegment, EdlSource } from \"./edl.js\"\n\n// ─────────────────────────────────────────────────────────────────────────\n// D19 — source offsets\n// ─────────────────────────────────────────────────────────────────────────\n\nconst hasOwn = (o: object, k: string): boolean => Object.prototype.hasOwnProperty.call(o, k)\nconst isFiniteNumber = (v: unknown): v is number => typeof v === \"number\" && Number.isFinite(v)\n\n/** audio-sync → EDL source offsets (D19: masterMs = sourceMs + offsetMs).\n * `offsets` are measured against ONE common reference (audio-sync's `reference`, which need not be the master).\n * ANCHORED SET: anchor = opts.anchor ?? the unique role:\"master-audio\" source ?? none.\n * - The anchor's own offsetMs is NEVER changed (the segments are on its clock).\n * - Every other provided source s: offsetMs = round((anchor.offsetMs ?? 0) + offsets[s] − (offsets[anchor] ?? 0)).\n * - No anchor: offsetMs = round(offsets[s]) verbatim (offsets already relative to the master clock).\n * SET, never ADD (re-running is idempotent). Returns a new Edl; never mutates; never throws.\n * `ignored[].reason` is a documented open string: \"unknown-source\" | \"not-finite\" | \"anchor-unknown\" | \"anchor-not-finite\".\n * opts.anchor not in edl.sources → NOTHING applied, ignored = [{ sourceId: anchor, reason: \"anchor-unknown\" }].\n * offsets[anchor] present but non-finite → NOTHING applied, ignored = [{ sourceId: anchor, reason: \"anchor-not-finite\" }]. */\nexport function mergeEdlSourceOffsets(\n edl: Edl,\n offsets: Readonly<Record<string, number>>,\n opts?: { readonly anchor?: string },\n): {\n readonly edl: Edl\n /** The source the offsets were anchored to — present whenever one resolved (it exists in `edl.sources`). */\n readonly anchor?: string\n /** Source ids whose `offsetMs` was set, in `offsets` key order. */\n readonly applied: readonly string[]\n readonly ignored: ReadonlyArray<{ readonly sourceId: string; readonly reason: string }>\n} {\n const sources: readonly EdlSource[] = Array.isArray(edl?.sources) ? edl.sources : []\n const rows: Readonly<Record<string, unknown>> = offsets && typeof offsets === \"object\" ? offsets : {}\n const byId = new Map<string, EdlSource>()\n for (const s of sources) if (s && typeof s === \"object\" && !byId.has(s.id)) byId.set(s.id, s)\n\n let anchor: string | undefined\n if (opts?.anchor !== undefined) {\n if (!byId.has(opts.anchor)) {\n return { edl: { ...edl }, applied: [], ignored: [{ sourceId: opts.anchor, reason: \"anchor-unknown\" }] }\n }\n anchor = opts.anchor\n } else {\n const masters = sources.filter((s) => s && typeof s === \"object\" && s.role === \"master-audio\")\n if (masters.length === 1) anchor = masters[0].id\n }\n\n // The anchor's own measurement is the rebase point; an absent one reads as 0.\n let reference = 0\n if (anchor !== undefined && hasOwn(rows, anchor)) {\n const a = rows[anchor]\n if (!isFiniteNumber(a)) {\n return { edl: { ...edl }, anchor, applied: [], ignored: [{ sourceId: anchor, reason: \"anchor-not-finite\" }] }\n }\n reference = a\n }\n const anchorOffsetMs = anchor !== undefined ? (byId.get(anchor)?.offsetMs ?? 0) : 0\n\n const next = new Map<string, number>()\n const applied: string[] = []\n const ignored: Array<{ sourceId: string; reason: string }> = []\n for (const sourceId of Object.keys(rows)) {\n if (sourceId === anchor) continue // never changed: the segments are on its clock\n if (!byId.has(sourceId)) {\n ignored.push({ sourceId, reason: \"unknown-source\" })\n continue\n }\n const measured = rows[sourceId]\n const offsetMs = isFiniteNumber(measured)\n ? Math.round(anchor !== undefined ? anchorOffsetMs + measured - reference : measured)\n : Number.NaN\n // A non-finite result (the measurement, or a non-finite anchor offsetMs it\n // is rebased onto) is never written.\n if (!Number.isFinite(offsetMs)) {\n ignored.push({ sourceId, reason: \"not-finite\" })\n continue\n }\n next.set(sourceId, offsetMs)\n applied.push(sourceId)\n }\n\n const merged: Edl = Array.isArray(edl?.sources)\n ? { ...edl, sources: edl.sources.map((s) => (s && typeof s === \"object\" && next.has(s.id) ? { ...s, offsetMs: next.get(s.id)! } : s)) }\n : { ...edl }\n return { edl: merged, ...(anchor !== undefined ? { anchor } : {}), applied, ignored }\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// B4 — audio-sync offsets onto a planner's sources\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Below this, a measured offset is not trusted (audio-sync's own\n * \"check it by ear\" line). */\nexport const AUDIO_SYNC_MIN_CONFIDENCE = 0.5\n\n/** One source row as a planner (edit-plan) sends it. */\nexport interface AudioSyncOffsetSource {\n readonly id: string\n readonly role?: string\n /** Set = a hand-set offset, which always wins over a measured one. */\n readonly offsetMs?: number\n}\n\n/** Why measured offsets could not be applied. Every code names the source to\n * fix, so a caller can phrase it with its own label (`describeAudioSyncOffsetIssue`). */\nexport type AudioSyncOffsetIssue =\n | { readonly code: \"not-audio-sync\" }\n | { readonly code: \"invalid-offset\"; readonly sourceId: string }\n | { readonly code: \"anchor-offset\"; readonly sourceId: string; readonly offsetMs: number }\n | { readonly code: \"anchor-unmeasured\"; readonly sourceId: string }\n | { readonly code: \"weak-match\"; readonly sourceId: string; readonly confidence: number; readonly anchor: boolean }\n | { readonly code: \"unmeasured\"; readonly sourceId: string }\n\nexport type AudioSyncOffsetsResult<S> =\n | {\n readonly ok: true\n /** The sources, with the measured offsets written onto `offsetMs`. */\n readonly sources: S[]\n /** The source whose clock the offsets are anchored to. */\n readonly anchor?: string\n /** Source ids that took a measured offset. */\n readonly applied: readonly string[]\n }\n | { readonly ok: false; readonly issues: readonly AudioSyncOffsetIssue[] }\n\ninterface SyncRow { readonly offsetMs: number; readonly confidence: number }\n\n/** audio-sync's result (an object, or the JSON string a canvas handle carries)\n * → its rows by source id, the reference included; null when it is not one. */\nfunction readAudioSyncRows(sync: unknown): Map<string, SyncRow> | null {\n let value = sync\n if (typeof value === \"string\") {\n try { value = JSON.parse(value) } catch { return null }\n }\n if (!value || typeof value !== \"object\") return null\n const { reference, offsets } = value as { reference?: unknown; offsets?: unknown }\n if (!Array.isArray(offsets)) return null\n const rows = new Map<string, SyncRow>()\n for (const row of offsets) {\n if (!row || typeof row !== \"object\") return null\n const { sourceId, offsetMs, confidence } = row as Record<string, unknown>\n if (typeof sourceId !== \"string\" || !isFiniteNumber(offsetMs)) return null\n if (!rows.has(sourceId)) rows.set(sourceId, { offsetMs, confidence: isFiniteNumber(confidence) ? confidence : 0 })\n }\n // The reference is measured by definition (its own offset is 0).\n if (typeof reference === \"string\" && reference && !rows.has(reference)) rows.set(reference, { offsetMs: 0, confidence: 1 })\n return rows\n}\n\nconst handSet = (s: AudioSyncOffsetSource): boolean => isFiniteNumber(s.offsetMs)\n\n/** The source whose clock a planner's plan is on: the `master-audio` source,\n * else the first (edit-plan's `masterProbeSource`). */\nfunction plannerClockSource<S extends AudioSyncOffsetSource>(sources: readonly S[]): S | undefined {\n return sources.find((s) => s.role === \"master-audio\") ?? sources[0]\n}\n\n/** B4 — audio-sync's measured offsets → a planner's `sources[].offsetMs`\n * (decided 2026-09-25). The planner makes its plan on its MASTER's clock:\n * the `master-audio` source, else its first source (edit-plan's own rule) —\n * the ANCHOR. Every other source gets `offsetMs = measured(s) − measured(anchor)`\n * (D19 via `mergeEdlSourceOffsets`), so audio-sync's reference need not be the\n * master. Never out of sync silently — each of these is an issue instead:\n * - a source with a hand-set `offsetMs` keeps it (it always wins);\n * - a source audio-sync did not measure → \"unmeasured\";\n * - a measured source under `AUDIO_SYNC_MIN_CONFIDENCE` → \"weak-match\";\n * - the anchor unmeasured / weak, when any source needs it → \"anchor-…\";\n * - a hand-set non-zero offset on the anchor → \"anchor-offset\" (its clock is the plan's).\n * Rows for sources the planner does not have are ignored. Pure; never throws. */\nexport function applyAudioSyncOffsets<S extends AudioSyncOffsetSource>(\n sources: readonly S[],\n sync: unknown,\n): AudioSyncOffsetsResult<S> {\n const rows = readAudioSyncRows(sync)\n if (!rows) return { ok: false, issues: [{ code: \"not-audio-sync\" }] }\n const list = Array.isArray(sources) ? sources.filter((s): s is S => !!s && typeof s === \"object\") : []\n const anchor = plannerClockSource(list)\n if (!anchor) return { ok: true, sources: [...list], applied: [] }\n\n const issues: AudioSyncOffsetIssue[] = []\n // A hand-set offset that is not a number (a \"500\" from a JSON file) would\n // otherwise be read as absent, or summed as a string.\n for (const s of list) if (s.offsetMs !== undefined && !handSet(s)) issues.push({ code: \"invalid-offset\", sourceId: s.id })\n if (handSet(anchor) && anchor.offsetMs !== 0) {\n issues.push({ code: \"anchor-offset\", sourceId: anchor.id, offsetMs: anchor.offsetMs! })\n }\n const measured: Record<string, number> = {}\n for (const s of list) {\n if (s.id === anchor.id || handSet(s)) continue\n const row = rows.get(s.id)\n if (!row) issues.push({ code: \"unmeasured\", sourceId: s.id })\n else if (!(row.confidence >= AUDIO_SYNC_MIN_CONFIDENCE)) issues.push({ code: \"weak-match\", sourceId: s.id, confidence: row.confidence, anchor: false })\n else measured[s.id] = row.offsetMs\n }\n // The anchor's own measurement is the rebase point — needed only when some\n // source takes a measured offset.\n if (Object.keys(measured).length > 0) {\n const row = rows.get(anchor.id)\n if (!row) issues.push({ code: \"anchor-unmeasured\", sourceId: anchor.id })\n else if (!(row.confidence >= AUDIO_SYNC_MIN_CONFIDENCE)) issues.push({ code: \"weak-match\", sourceId: anchor.id, confidence: row.confidence, anchor: true })\n else measured[anchor.id] = row.offsetMs\n }\n if (issues.length > 0) return { ok: false, issues }\n if (Object.keys(measured).length === 0) return { ok: true, sources: [...list], anchor: anchor.id, applied: [] }\n\n // One arithmetic implementation: the D19 anchored SET.\n const pseudo = { version: 1, clock: \"master\", sources: list, segments: [] } as unknown as Edl\n const merged = mergeEdlSourceOffsets(pseudo, measured, { anchor: anchor.id })\n const byId = new Map(merged.edl.sources.map((s) => [s.id, s.offsetMs]))\n const applied = new Set(merged.applied)\n return {\n ok: true,\n sources: list.map((s) => (applied.has(s.id) ? { ...s, offsetMs: byId.get(s.id)! } : s)),\n anchor: anchor.id,\n applied: merged.applied,\n }\n}\n\n/** Why edit-plan's sources cannot be planned as given: an audio-sync issue,\n * or a transcript made from a recording that is off the plan's clock. */\nexport type EditPlanSourceIssue =\n | AudioSyncOffsetIssue\n | { readonly code: \"transcript-off-clock\"; readonly sourceId: string; readonly masterId: string; readonly offsetMs: number }\n\n/** B4 — the ONE check every edit-plan caller runs before dispatch (the\n * orchestrator, the editor, MCP, the SDK), so a plan that would render out of\n * sync fails before charging (decided 2026-09-25):\n * - `offsets` given (audio-sync's result; null/\"\" when wired but empty) →\n * `applyAudioSyncOffsets`;\n * - the master's own offset must be 0 (the plan follows its clock);\n * - `transcriptSourceId` (the recording the transcript was made from, when\n * known) must be on the master's clock: the master itself, or a source\n * whose offset is 0. Unknown → assumed the master's.\n * `transcriptSourceId` is echoed back only when it names one of the sources,\n * for the caller to stamp on the transcript. Pure; never throws. */\nexport function resolveEditPlanSources<S extends AudioSyncOffsetSource>(\n sources: readonly S[],\n opts: { readonly offsets?: unknown; readonly transcriptSourceId?: string } = {},\n):\n | { readonly ok: true; readonly sources: S[]; readonly transcriptSourceId?: string }\n | { readonly ok: false; readonly issues: readonly EditPlanSourceIssue[] } {\n const list = Array.isArray(sources) ? sources.filter((s): s is S => !!s && typeof s === \"object\") : []\n const anchor = plannerClockSource(list)\n const issues: EditPlanSourceIssue[] = []\n let planned: S[] = [...list]\n if (opts.offsets !== undefined) {\n const synced = applyAudioSyncOffsets(list, opts.offsets)\n if (synced.ok) planned = synced.sources\n else issues.push(...synced.issues)\n } else {\n for (const s of list) if (s.offsetMs !== undefined && !handSet(s)) issues.push({ code: \"invalid-offset\", sourceId: s.id })\n if (anchor && handSet(anchor) && anchor.offsetMs !== 0) {\n issues.push({ code: \"anchor-offset\", sourceId: anchor.id, offsetMs: anchor.offsetMs! })\n }\n }\n const spoken = opts.transcriptSourceId ? planned.find((s) => s.id === opts.transcriptSourceId) : undefined\n if (spoken && anchor && spoken.id !== anchor.id && handSet(spoken) && spoken.offsetMs !== 0) {\n issues.push({ code: \"transcript-off-clock\", sourceId: spoken.id, masterId: anchor.id, offsetMs: spoken.offsetMs! })\n }\n if (issues.length > 0) return { ok: false, issues }\n return { ok: true, sources: planned, ...(spoken ? { transcriptSourceId: spoken.id } : {}) }\n}\n\n/** The recording a transcript was made from, traced on a canvas: the node\n * feeding the transcribing node, through clock-preserving hops (extract-audio).\n * Undefined when the producer is not a transcriber or the trace is ambiguous\n * (more than one upstream) — the caller then assumes the master's clock. */\nexport function editPlanTranscriptOrigin(\n producerId: string,\n typeOf: (nodeId: string) => string | undefined,\n edges: ReadonlyArray<{ readonly source: string; readonly target: string }>,\n): string | undefined {\n if (typeOf(producerId) !== \"transcribe\") return undefined\n let current = producerId\n for (let hop = 0; hop < 4; hop++) {\n const upstream = [...new Set(edges.filter((e) => e.target === current).map((e) => e.source))]\n if (upstream.length !== 1) return undefined\n const up = upstream[0]!\n if (typeOf(up) !== \"extract-audio\") return up\n current = up\n }\n return undefined\n}\n\n/** A plain-language line for one issue; `labelOf` turns a source id into the\n * name the user sees (a canvas node's label, say). */\nexport function describeAudioSyncOffsetIssue(issue: EditPlanSourceIssue, labelOf: (sourceId: string) => string = (id) => id): string {\n switch (issue.code) {\n case \"transcript-off-clock\":\n return `the transcript was made from \"${labelOf(issue.sourceId)}\", which is ${issue.offsetMs} ms off the master \"${labelOf(issue.masterId)}\" — the plan follows the master's clock, so transcribe \"${labelOf(issue.masterId)}\", or mark \"${labelOf(issue.sourceId)}\" as master audio`\n case \"not-audio-sync\":\n return \"the offsets carry no Audio Sync result — pass its job's output_data.json (on the canvas: connect Audio Sync's Offsets output and run it)\"\n case \"invalid-offset\":\n return `the offset set on \"${labelOf(issue.sourceId)}\" is not a number of milliseconds`\n case \"anchor-offset\":\n return `\"${labelOf(issue.sourceId)}\" is the master (the plan follows its clock), so its offset must be 0, not ${issue.offsetMs} ms`\n case \"anchor-unmeasured\":\n return `audio-sync did not measure \"${labelOf(issue.sourceId)}\", the master the other sources are timed against — add it to audio-sync's sources`\n case \"weak-match\":\n return issue.anchor\n ? `audio-sync's match for \"${labelOf(issue.sourceId)}\", the master the other sources are timed against, is too weak to trust (confidence ${issue.confidence}; ${AUDIO_SYNC_MIN_CONFIDENCE} needed) — set the other sources' offsets by hand, or mark a better-recorded source as master audio`\n : `audio-sync's match for \"${labelOf(issue.sourceId)}\" is too weak to trust (confidence ${issue.confidence}; ${AUDIO_SYNC_MIN_CONFIDENCE} needed) — set its offset by hand`\n case \"unmeasured\":\n return `\"${labelOf(issue.sourceId)}\" was not measured by audio-sync — wire it into audio-sync, or set its offset by hand (0 if it started with the master)`\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// D20 — slot resolution\n// ─────────────────────────────────────────────────────────────────────────\n\nexport const EDL_FULL_FRAME: EdlRegion = Object.freeze({ x: 0, y: 0, w: 1, h: 1 })\n\nexport interface EdlResolvedSlot {\n readonly source: string\n readonly region: EdlRegion\n /** \"resolver\" = the caller's `regionFor` (v3 per-segment tracks). */\n readonly regionFrom: \"slot\" | \"segment\" | \"resolver\" | \"speaker\" | \"source\" | \"full\"\n readonly speaker?: string\n readonly weight?: number\n}\n\nexport interface ResolveEdlSlotsOptions {\n /** speaker-view's per-speaker framing table (a node SETTING, not an EDL field), keyed by (source, speaker) so a\n * wide-shot region never lands on a close-up camera framing the same person. */\n readonly speakerRegions?: ReadonlyArray<{ readonly source: string; readonly speaker: string; readonly region: EdlRegion }>\n /** v3 hook: a per-(segment, slot) region, e.g. from a face track. Undefined = no opinion. */\n readonly regionFor?: (q: { readonly segment: EdlSegment; readonly source: string; readonly speaker?: string }) => EdlRegion | undefined\n}\n\n/** A valid in-frame box: finite, 0..1, w/h > 0, x+w ≤ 1, y+h ≤ 1 — with the\n * same edge tolerance `validateEdl` accepts, so the two never disagree. */\nfunction isInFrameRegion(r: unknown): r is EdlRegion {\n if (!r || typeof r !== \"object\") return false\n const { x, y, w, h } = r as Record<string, unknown>\n for (const v of [x, y, w, h]) if (!isFiniteNumber(v) || v < 0 || v > 1) return false\n const box = r as EdlRegion\n return box.w > 0 && box.h > 0 && box.x + box.w <= 1 + 1e-9 && box.y + box.h <= 1 + 1e-9\n}\n\ntype Rung = EdlResolvedSlot[\"regionFrom\"]\n\n/** D20 — the ONE region-precedence implementation:\n * slot.region ▷ segment.region (single-slot only) ▷ regionFor ▷ speakerRegions[(source, speaker)] ▷ source.region ▷ full frame.\n * Slots = layout.slots when non-empty, else ONE implicit slot from segment.video (no video → []).\n * A slot's speaker = slot.speaker ?? (single slot ? segment.speaker : undefined); no speaker → the speaker rung is skipped.\n * A rung whose region is not a valid in-frame box (finite, 0..1, w/h > 0, x+w ≤ 1, y+h ≤ 1) falls through to the next.\n * Unknown source id → the source rung is skipped. Pure; never throws on its own. */\nexport function resolveEdlSegmentSlots(edl: Edl, segment: EdlSegment, opts?: ResolveEdlSlotsOptions): readonly EdlResolvedSlot[] {\n if (!segment || typeof segment !== \"object\") return []\n const sources: readonly EdlSource[] = Array.isArray(edl?.sources) ? edl.sources : []\n const layoutSlots = Array.isArray(segment.layout?.slots) ? segment.layout!.slots! : []\n const slots: NonNullable<NonNullable<EdlSegment[\"layout\"]>[\"slots\"]> =\n layoutSlots.length > 0\n ? layoutSlots\n : typeof segment.video === \"string\" && segment.video\n ? [{ source: segment.video }]\n : []\n const single = slots.length === 1\n\n const out: EdlResolvedSlot[] = []\n for (const slot of slots) {\n if (!slot || typeof slot !== \"object\") continue\n const source = slot.source\n const speaker = slot.speaker ?? (single ? segment.speaker : undefined)\n\n // Each rung is evaluated lazily, top-down; the first valid box wins.\n const rungs: ReadonlyArray<readonly [Rung, () => unknown]> = [\n [\"slot\", () => slot.region],\n [\"segment\", () => (single ? segment.region : undefined)],\n [\"resolver\", () => opts?.regionFor?.({ segment, source, ...(speaker !== undefined ? { speaker } : {}) })],\n [\"speaker\", () =>\n speaker === undefined\n ? undefined\n : Array.isArray(opts?.speakerRegions)\n ? opts.speakerRegions.find((row) => row && row.source === source && row.speaker === speaker)?.region\n : undefined],\n [\"source\", () => sources.find((s) => s && typeof s === \"object\" && s.id === source)?.region],\n ]\n let region: EdlRegion = EDL_FULL_FRAME\n let regionFrom: Rung = \"full\"\n for (const [from, read] of rungs) {\n const candidate = read()\n if (isInFrameRegion(candidate)) {\n region = candidate\n regionFrom = from\n break\n }\n }\n out.push({\n source,\n region,\n regionFrom,\n ...(speaker !== undefined ? { speaker } : {}),\n ...(slot.weight !== undefined ? { weight: slot.weight } : {}),\n })\n }\n return out\n}\n","/**\n * Speaker-view presentation registries — the STRUCTURAL vocabulary behind an\n * EDL segment's `layout` (see `EdlLayout` in `edl.ts`).\n *\n * What lives here is structure only: which layout ids exist, how many slots\n * each takes, which output aspects a renderer exists for, which speaker-switch\n * ids exist and whether they consume output time, and the atomic emphasis\n * styles. Taste — default emphasis, which transitions are allowed or preferred\n * for a show, timing defaults — is deliberately NOT here.\n *\n * Every list is widened ADDITIVELY. That is why a finding judged against one of\n * these registries is a validation WARNING, never an issue: an older validator\n * must never reject an EDL written by a newer producer that knows more ids.\n * An executor that cannot honour an id refuses it itself.\n */\nimport type { Edl } from \"./edl.js\"\nimport { COMBINE_TRANSITIONS } from \"./combine-transitions.js\"\nimport { resolveEdlSegmentSlots } from \"./edl-multicam.js\"\n\nexport const EDL_TARGET_ASPECTS = [\"16:9\", \"9:16\", \"1:1\", \"4:5\"] as const\nexport type EdlTargetAspect = (typeof EDL_TARGET_ASPECTS)[number]\n\nconst TARGET_ASPECT_SET: ReadonlySet<string> = new Set(EDL_TARGET_ASPECTS)\n\n/** Narrow an open `Edl.meta.targetAspect` (or any value) to a known aspect. */\nexport function isEdlTargetAspect(v: unknown): v is EdlTargetAspect {\n return typeof v === \"string\" && TARGET_ASPECT_SET.has(v)\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Layouts\n// ─────────────────────────────────────────────────────────────────────────\n\nexport interface SpeakerLayoutSheet {\n readonly id: string\n /** Inclusive slot-count range when a segment lists `layout.slots`. */\n readonly minSlots: number\n readonly maxSlots: number\n /** The output aspects this layout is DRAWN for (a renderer exists) — not \"looks good\". Widened additively. */\n readonly aspects: readonly EdlTargetAspect[]\n}\n\nexport const SPEAKER_LAYOUTS: readonly SpeakerLayoutSheet[] = [\n { id: \"single\", minSlots: 1, maxSlots: 1, aspects: EDL_TARGET_ASPECTS },\n { id: \"side-by-side\", minSlots: 2, maxSlots: 2, aspects: [\"16:9\", \"1:1\"] },\n { id: \"stacked\", minSlots: 2, maxSlots: 2, aspects: [\"9:16\", \"4:5\", \"1:1\"] },\n { id: \"grid\", minSlots: 2, maxSlots: 6, aspects: EDL_TARGET_ASPECTS },\n { id: \"pip\", minSlots: 2, maxSlots: 2, aspects: EDL_TARGET_ASPECTS },\n]\n\nexport const SPEAKER_LAYOUT_IDS: readonly string[] = SPEAKER_LAYOUTS.map((l) => l.id)\n\nconst LAYOUTS_BY_ID: ReadonlyMap<string, SpeakerLayoutSheet> = new Map(SPEAKER_LAYOUTS.map((l) => [l.id, l]))\n\nexport function getSpeakerLayout(id: string): SpeakerLayoutSheet | undefined {\n return LAYOUTS_BY_ID.get(id)\n}\n\n/** Omitted query fields are unconstrained. */\nexport function speakerLayoutAllows(\n sheet: SpeakerLayoutSheet,\n q: { readonly aspect?: EdlTargetAspect; readonly slotCount?: number },\n): boolean {\n if (q.aspect !== undefined && !sheet.aspects.includes(q.aspect)) return false\n if (q.slotCount !== undefined && !(q.slotCount >= sheet.minSlots && q.slotCount <= sheet.maxSlots)) return false\n return true\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Speaker switches (EdlLayout.transition.type)\n// ─────────────────────────────────────────────────────────────────────────\n\n/** The one prefix of the time-consuming (cross-source blend) switch family. */\nconst XFADE_SWITCH_PREFIX = \"xfade:\"\n\n/** D17: a switch consumes output time iff it is in the `xfade:*` family. THE one overlap rule (edl.ts uses it). */\nexport function speakerSwitchOverlaps(type: string): boolean {\n return typeof type === \"string\" && type.startsWith(XFADE_SWITCH_PREFIX)\n}\n\nexport interface SpeakerSwitchSheet {\n /** \"cut\" | \"pan\" | \"zoom\" | `xfade:${combine id}` */\n readonly id: string\n /** = `speakerSwitchOverlaps(id)`, derived, never hand-set. */\n readonly overlaps: boolean\n /** true only for `pan`: an eased sweep between two regions of ONE picture source. */\n readonly requiresSameSource: boolean\n}\n\nconst switchSheet = (id: string, requiresSameSource: boolean): SpeakerSwitchSheet => ({\n id,\n overlaps: speakerSwitchOverlaps(id),\n requiresSameSource,\n})\n\n/** `cut` / `pan` / `zoom` consume no time (pan: a geometry tween inside ONE\n * source; zoom: a tween inside each segment). The `xfade:*` family is DERIVED\n * from every combine-videos transition that is a real ffmpeg xfade (so never\n * `cut`, which has no xfade) — it is never hand-listed here. */\nexport const SPEAKER_SWITCHES: readonly SpeakerSwitchSheet[] = [\n switchSheet(\"cut\", false),\n switchSheet(\"pan\", true),\n switchSheet(\"zoom\", false),\n ...COMBINE_TRANSITIONS.filter((t) => t.xfade !== null).map((t) => switchSheet(XFADE_SWITCH_PREFIX + t.id, false)),\n]\n\nexport const SPEAKER_SWITCH_IDS: readonly string[] = SPEAKER_SWITCHES.map((s) => s.id)\n\nconst SWITCHES_BY_ID: ReadonlyMap<string, SpeakerSwitchSheet> = new Map(SPEAKER_SWITCHES.map((s) => [s.id, s]))\n\n/** A plain lookup: `undefined` for an unknown id (never throws). */\nexport function getSpeakerSwitch(id: string): SpeakerSwitchSheet | undefined {\n return SWITCHES_BY_ID.get(id)\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Emphasis (EdlLayout.emphasis.style)\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Atomic emphasis styles; `layout.emphasis.style` is a \"+\"-joined set of\n * them. `none` stands alone (it means \"no emphasis\"), and an atom appears at\n * most once. */\nexport const SPEAKER_EMPHASIS_STYLES = [\"none\", \"scale\", \"border\", \"dim\"] as const\nexport type SpeakerEmphasisStyle = (typeof SPEAKER_EMPHASIS_STYLES)[number]\n\nconst EMPHASIS_STYLE_SET: ReadonlySet<string> = new Set(SPEAKER_EMPHASIS_STYLES)\n\n/** Split a `+`-joined style into its atoms: trimmed, empties dropped. */\nexport function parseSpeakerEmphasisStyle(style: string): readonly string[] {\n if (typeof style !== \"string\") return []\n return style\n .split(\"+\")\n .map((atom) => atom.trim())\n .filter((atom) => atom.length > 0)\n}\n\n/** At least one atom, every atom a known `SPEAKER_EMPHASIS_STYLES` id, no\n * atom repeated, and `none` only on its own (\"none+scale\" contradicts itself). */\nexport function isKnownSpeakerEmphasisStyle(style: string): boolean {\n const atoms = parseSpeakerEmphasisStyle(style)\n if (atoms.length === 0 || !atoms.every((atom) => EMPHASIS_STYLE_SET.has(atom))) return false\n if (new Set(atoms).size !== atoms.length) return false\n return !(atoms.includes(\"none\") && atoms.length > 1)\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Registry-derived findings\n// ─────────────────────────────────────────────────────────────────────────\n\nconst isObject = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\"\n\n/** Registry-derived findings — ALL warning-class. Pure; never throws (guard non-array sources/segments the\n * way validateEdl does). `validateEdl` already includes these in its `warnings`; call this directly only\n * when you want the presentation findings alone. */\nexport function speakerPresentationWarnings(edl: Edl): readonly string[] {\n const warnings: string[] = []\n if (!isObject(edl)) return warnings\n // Guard a raw object that skipped normalizeEdl, exactly as validateEdl does.\n const safe: Edl = {\n ...edl,\n sources: Array.isArray(edl.sources) ? edl.sources : [],\n segments: Array.isArray(edl.segments) ? edl.segments : [],\n }\n\n const rawAspect = isObject(safe.meta) ? safe.meta.targetAspect : undefined\n const aspect = isEdlTargetAspect(rawAspect) ? rawAspect : undefined\n if (rawAspect != null && aspect === undefined) {\n warnings.push(`meta.targetAspect \"${String(rawAspect)}\" is not a known target aspect (known: ${EDL_TARGET_ASPECTS.join(\", \")})`)\n }\n\n safe.segments.forEach((seg, i) => {\n if (!isObject(seg) || !isObject(seg.layout)) return\n const at = `segment[${i}] \"${seg.id}\"`\n const layout = seg.layout\n\n // 1. The layout mode, its slot count, and the output aspect.\n const sheet = typeof layout.mode === \"string\" ? getSpeakerLayout(layout.mode) : undefined\n if (!sheet) {\n warnings.push(`${at}: unknown layout mode \"${String(layout.mode)}\" (known: ${SPEAKER_LAYOUT_IDS.join(\", \")})`)\n } else {\n const slotCount = Array.isArray(layout.slots) ? layout.slots.length : 0\n if (slotCount > 0 && !speakerLayoutAllows(sheet, { slotCount })) {\n const range = sheet.minSlots === sheet.maxSlots ? `${sheet.minSlots}` : `${sheet.minSlots}–${sheet.maxSlots}`\n warnings.push(`${at}: layout \"${sheet.id}\" takes ${range} slot(s), got ${slotCount}`)\n }\n if (aspect !== undefined && !speakerLayoutAllows(sheet, { aspect })) {\n warnings.push(`${at}: layout \"${sheet.id}\" is not drawn for targetAspect ${aspect} (drawn for: ${sheet.aspects.join(\", \")})`)\n }\n }\n\n // 2. The switch into this segment.\n if (isObject(layout.transition)) {\n const type = layout.transition.type\n const sw = typeof type === \"string\" ? getSpeakerSwitch(type) : undefined\n if (!sw) {\n warnings.push(`${at}: unknown layout transition \"${String(type)}\" (known: ${SPEAKER_SWITCHES.filter((s) => !s.overlaps).map((s) => s.id).join(\", \")}, or ${XFADE_SWITCH_PREFIX}<id> for a combine-videos transition that is a real ffmpeg xfade — never ${XFADE_SWITCH_PREFIX}cut)`)\n } else if (sw.requiresSameSource && i > 0) {\n // Only a one-picture → one-picture boundary has a defined \"picture\n // source\"; any other shape (multi-slot, no video) is not judged here.\n const prev = safe.segments[i - 1]\n const cur = resolveEdlSegmentSlots(safe, seg)\n const before = isObject(prev) ? resolveEdlSegmentSlots(safe, prev) : []\n if (cur.length === 1 && before.length === 1 && cur[0].source !== before[0].source) {\n warnings.push(`${at}: switch \"${sw.id}\" moves within ONE picture source, but the previous segment shows \"${before[0].source}\" and this one \"${cur[0].source}\"`)\n }\n }\n }\n\n // 3. The emphasis style.\n if (isObject(layout.emphasis) && !isKnownSpeakerEmphasisStyle(layout.emphasis.style as string)) {\n const style = String(layout.emphasis.style)\n const atoms = parseSpeakerEmphasisStyle(layout.emphasis.style as string)\n warnings.push(atoms.length > 0 && atoms.every((a) => EMPHASIS_STYLE_SET.has(a))\n ? `${at}: emphasis style \"${style}\" — \"none\" must stand alone and no style may repeat`\n : `${at}: unknown emphasis style \"${style}\" (a \"+\"-joined set of: ${SPEAKER_EMPHASIS_STYLES.join(\", \")})`)\n }\n })\n\n return warnings\n}\n","import { speakerSwitchOverlaps, speakerPresentationWarnings } from \"./speaker-layouts.js\"\nimport type { EdlTargetAspect } from \"./speaker-layouts.js\"\n\n/**\n * EDL — the edit decision list contract.\n *\n * WHY THIS EXISTS\n * The podcast-editing primitives (transcript-driven cut, clip finding,\n * multicam, speaker view) compose because they share ONE data shape: every\n * analysis node produces an EDL, every render node consumes one. This module\n * is that shape plus the pure functions that read it. It is structural\n * vocabulary — no prompts, no heuristics, no editorial judgment — which is why\n * it lives in the Apache-licensed `@nodaro/shared` (the wire shape of\n * `/v1/edl/*`, an SDK type, an MCP output). Every published version is an\n * irrevocable grant, so the three resolved decisions (see below) all land in\n * version 1: renaming a field, or adding a REQUIRED one, later would be a\n * breaking major bump — so every later field is optional and additive.\n *\n * This module is PURE — no I/O, no ffmpeg, no network. The executors\n * (`apply-edl`, `speaker-view`) turn an EDL into pixels; they live in the app\n * and the plugins.\n *\n * DESIGN DECISIONS baked into v1 (so multicam and speaker view extend the\n * contract additively rather than with a breaking bump):\n * - D17 OVERLAP: a crossfade consumes time from the outgoing segment (ffmpeg\n * `xfade`, as combine-videos already does), so the rendered timeline is\n * SHORTER than the sum of segment durations. `edlDurationMs` subtracts the\n * overlap transitions; cut/pan/zoom consume no time (pan: a geometry tween\n * inside ONE source; zoom: a tween inside each segment); only the `xfade:*`\n * family and a segment `crossfade` overlap.\n * - D19 CLOCK/SOURCE/SIGN: `Edl.clock` says whether `segments` are on the\n * source master clock or an output clock; `Transcript.sourceId` says which\n * source a transcript came from; the offset sign is `masterMs = sourceMs +\n * offsetMs(source)`, applied by the remap functions.\n * - D20 PRECEDENCE/RENAME: region precedence\n * `slot.region ▷ segment.region (single-slot only) ▷ a caller's per-slot\n * resolver (v3 tracks) ▷ regions[(source, speaker)] ▷ source.region ▷ full\n * frame`, implemented ONCE by `resolveEdlSegmentSlots` (edl-multicam.ts);\n * `segment.region` is invalid when the segment's layout has more than one\n * slot; `slots[].weight` (0..1, active = 1) replaces the design's\n * `slots[].emphasis` so it no longer collides with `layout.emphasis`\n * ({ style, durationMs }).\n * - P3-8 FOLLOW (decided 2026-10-06, field added decided 2026-10-09): a\n * slot a renderer framed on a face track names that track in\n * `slots[].follow` (`EdlSlotFollow`). It records what the render followed;\n * the path itself is recomputed from the tracks, and `slot.region` keeps a\n * static region, so a reader that ignores `follow` still gets a sane frame.\n *\n * Time is INTEGER MILLISECONDS everywhere. There is no seconds→ms guessing\n * (`normalizeEdl` never reinterprets a unit — an implausible value is a\n * validation error, not a silent 1000× edit).\n */\n\nexport const EDL_VERSION = 1 as const\n\n/** A crop region, as fractions 0..1 of the source frame. */\nexport interface EdlRegion {\n readonly x: number\n readonly y: number\n readonly w: number\n readonly h: number\n}\n\nexport const EDL_SOURCE_ROLES = [\"master-audio\", \"camera\", \"wide\", \"screen\"] as const\nexport type EdlSourceRole = (typeof EDL_SOURCE_ROLES)[number]\n\nconst KNOWN_SOURCE_ROLES: ReadonlySet<string> = new Set(EDL_SOURCE_ROLES)\n\n/** A media input to the edit. Ids are minted once (by `edit-plan`) and never\n * re-derived, so downstream nodes resolve media from `url` in the data, not\n * from canvas handle order. Keep the `url` key: the cloud relay re-hosts\n * private media by walking `url`-suffixed fields. */\nexport interface EdlSource {\n readonly id: string\n readonly url: string\n readonly kind: \"video\" | \"audio\"\n /** This source's origin on the master clock. `masterMs = sourceMs + offsetMs`. Default 0. */\n readonly offsetMs?: number\n /** Known roles: EDL_SOURCE_ROLES. Open (`string & {}`) so an EDL written by a newer producer still type-checks\n * and still validates — an unknown role is a WARNING (validateEdl); an executor that cannot honour it refuses it. */\n readonly role?: EdlSourceRole | (string & {})\n /** Speaker labels this source frames (multicam). Empty = unknown. */\n readonly speakers?: readonly string[]\n /** A static crop for this source (speaker-view v1 framing). */\n readonly region?: EdlRegion\n}\n\nexport type EdlSlotFollowMotion = \"static\" | \"glide\"\n\n/** Module-private on purpose: the follow contract is types only (decided\n * 2026-10-09), so no runtime value joins the published surface. */\nconst FOLLOW_MOTIONS = [\"static\", \"glide\"] as const satisfies readonly EdlSlotFollowMotion[]\nconst KNOWN_FOLLOW_MOTIONS: ReadonlySet<string> = new Set(FOLLOW_MOTIONS)\n\n/** The face track a slot followed (P3-8). `sourceId` is the slot's own video\n * source; `trackId` is a track id of the speaker-track set the render read\n * (unique in that set); `motion` is how it followed: `static` = one region\n * per segment from the track, `glide` = a moving crop along it. Additive and\n * optional: an EDL without it is unchanged. */\nexport interface EdlSlotFollow {\n readonly sourceId: string\n readonly trackId: string\n readonly motion: EdlSlotFollowMotion\n}\n\n/** How a segment is presented on screen (speaker-view, phase 2). `mode` and\n * `transition.type` are ids from the `SPEAKER_LAYOUTS` / `SPEAKER_SWITCHES`\n * registries (speaker-layouts.ts); `emphasis.style` is a `+`-joined set of\n * atomic `SPEAKER_EMPHASIS_STYLES` (e.g. \"scale+border\"). Unknown ids are\n * validation WARNINGS, and `mode` stays an open string on purpose. v1 leaves\n * layout undefined (single camera). */\nexport interface EdlLayout {\n /** \"single\" | \"side-by-side\" | \"stacked\" | \"grid\" | \"pip\" | … */\n readonly mode: string\n readonly slots?: ReadonlyArray<{\n readonly source: string\n readonly region?: EdlRegion\n readonly speaker?: string\n /** D20: 0..1, the active slot = 1. (Was `emphasis`; renamed to avoid\n * colliding with `layout.emphasis`.) */\n readonly weight?: number\n /** P3-8: the face track this slot followed. `region` then holds the\n * static region an older reader draws. */\n readonly follow?: EdlSlotFollow\n }>\n /** A \"+\"-joined set of \"none\" | \"scale\" | \"border\" | \"dim\" | …, eased over durationMs. */\n readonly emphasis?: { readonly style: string; readonly durationMs: number }\n /** Into THIS segment. \"cut\" | \"pan\" | \"zoom\" consume no time; \"xfade:<id>\" overlaps (D17).\n * `durationMs` never consumes timeline time for the non-overlap types: it\n * is the tween length for `pan` / `zoom` and is ignored for `cut`. */\n readonly transition?: { readonly type: string; readonly durationMs?: number }\n}\n\nexport interface EdlSegment {\n readonly id: string\n /** On the MASTER clock. */\n readonly inMs: number\n /** Exclusive, > inMs. */\n readonly outMs: number\n /** `EdlSource.id` supplying picture. Omit = audio-only EDL. */\n readonly video?: string\n /** `EdlSource.id` supplying sound. Default: the unique `role:\"master-audio\"` source, else `video`. */\n readonly audio?: string\n /** Dominant speaker label (informational). */\n readonly speaker?: string\n /** Into THIS segment. Only \"crossfade\" consumes time (D17); never on segments[0].\n * `durationMs` is optional and inert for \"cut\". */\n readonly transition?: { readonly type: \"cut\" | \"crossfade\"; readonly durationMs?: number }\n /** Per-segment crop override — SINGLE-slot only (D20). */\n readonly region?: EdlRegion\n readonly layout?: EdlLayout\n /** Free tags: \"hook\", \"chapter:2\", … (removed spans live in `Edl.dropped`). */\n readonly labels?: readonly string[]\n}\n\nexport interface EdlDropped {\n readonly inMs: number\n readonly outMs: number\n readonly reason: \"silence\" | \"filler\" | \"false-start\" | \"tangent\" | \"manual\" | string\n}\n\nexport interface Edl {\n readonly version: 1\n /** D19: are `segments` on the source master clock, or an already-rendered output clock? */\n readonly clock: \"master\" | \"output\"\n readonly sources: readonly EdlSource[]\n /** The ordered output timeline. Output time = cumulative segment durations, less overlap transitions. */\n readonly segments: readonly EdlSegment[]\n readonly dropped?: readonly EdlDropped[]\n /** Set when this EDL was re-cut from a rendered output (speaker-view after apply-edl). */\n readonly derivedFrom?: { readonly edlId: string; readonly clock: \"output\" }\n readonly meta?: {\n readonly title?: string\n readonly hook?: string\n /** Known aspects: `EDL_TARGET_ASPECTS`. Open (`string & {}`) so an EDL\n * written by a newer producer still type-checks — an unknown aspect is a\n * validation WARNING (validateEdl), never an issue. */\n readonly targetAspect?: EdlTargetAspect | (string & {})\n readonly platform?: string\n readonly notes?: string\n }\n}\n\n/** The `clips` mode's response/SDK shape. On the canvas the node emits a bare\n * `Edl[]` (T5: the `list` fan-out reads a top-level JSON array), and the\n * cloud relay writes `output_data` as this object — the unwrap to the bare\n * array happens in the output extractors, never in `output_data`. */\nexport interface EdlClipSet {\n readonly version: 1\n readonly clips: readonly Edl[]\n}\n\n/** The `chapters` mode's `output_data` shape — a plain `data` list. */\nexport interface ChapterSet {\n readonly version: 1\n readonly chapters: ReadonlyArray<{ readonly startMs: number; readonly title: string }>\n}\n\n/** The normalized JSON form of a transcribe result. */\nexport interface Transcript {\n readonly version: 1\n /** D19: which `EdlSource` this transcript was made from (drives the offset in remap). */\n readonly sourceId?: string\n readonly language?: string\n readonly words: ReadonlyArray<{\n readonly text: string\n readonly startMs: number\n readonly endMs: number\n readonly speaker?: string\n readonly confidence?: number\n }>\n readonly segments?: ReadonlyArray<{\n readonly startMs: number\n readonly endMs: number\n readonly text: string\n readonly speaker?: string\n }>\n /** Raw speaker label → the display name the words and segments now carry,\n * published by a node that renamed the speakers (Camera Switch), so a later\n * node can still find a speaker's original label. Absent = not renamed. */\n readonly speakerNames?: Readonly<Record<string, string>>\n}\n\n/** Duration (seconds) implied by a transcript — the LATEST word/segment `endMs`\n * across the whole transcript, in seconds. The edit-plan reserve's duration\n * fallback BENEATH the master-source ffprobe (`computeEditPlanReserveId`): the\n * authoritative reserve basis is a probe of the master media, exactly like the\n * plugin route; this transcript clock is used only in `buildPayload` (which\n * cannot ffprobe) and when that probe can't run, for a MASTER source node that\n * exposes no length of its own (a `reference-audio`/youtube or direct-URL\n * master carries its length in neither `data.duration` nor\n * `metadata.durationSeconds` — see `editPlanSourceDurationSec` — and its live\n * orchestrator output is a bare URL). The transcript is a REQUIRED edit-plan\n * input and is the timing map of that same master, so its last word's `endMs`\n * is a lower bound on the source's own clock.\n *\n * Accepts `unknown` because the cloud plugin's Zod is the transcript's schema\n * authority; this reads defensively and returns `undefined` for any shape it\n * can't measure (so the caller falls back to the ceiling bucket — the safe\n * over-reserve direction). Takes the MAX endMs rather than the last element so\n * an out-of-order words array can't under-report. NOTE the direction: a\n * transcript's last spoken word ends at or before the true media end (trailing\n * music/silence is not transcribed), so this can UNDER-estimate; bucket\n * round-up is the headroom, and the cloud re-probe money-gate refuses (never\n * overcharges) if the probed master still exceeds the reserved bucket. */\nexport function transcriptDurationSec(transcript: unknown): number | undefined {\n if (!transcript || typeof transcript !== \"object\") return undefined\n const t = transcript as { words?: unknown; segments?: unknown }\n let maxEndMs = 0\n const scan = (rows: unknown): void => {\n if (!Array.isArray(rows)) return\n for (const row of rows) {\n const endMs = (row as { endMs?: unknown } | null)?.endMs\n if (typeof endMs === \"number\" && Number.isFinite(endMs) && endMs > maxEndMs) {\n maxEndMs = endMs\n }\n }\n }\n // Max over BOTH words AND segments — a segment tail can extend past the last\n // word (mirrors the plugin's own `transcriptDurationMs`, which maxes both), so\n // scanning segments only when words is empty would under-report.\n scan(t.words)\n scan(t.segments)\n return maxEndMs > 0 ? maxEndMs / 1000 : undefined\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Pure functions\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Is this segment-transition an OVERLAP (time-consuming) one? Only a\n * crossfade is. */\nfunction segmentTransitionOverlaps(t: EdlSegment[\"transition\"]): boolean {\n return !!t && t.type === \"crossfade\" && (t.durationMs ?? 0) > 0\n}\n\n/** Is this layout-transition an OVERLAP one? Only the `xfade:*` family\n * (a real cross-source blend) — THE one rule, `speakerSwitchOverlaps`;\n * `cut`/`pan`/`zoom` consume no output time. */\nfunction layoutTransitionOverlaps(t: EdlLayout[\"transition\"]): boolean {\n return !!t && speakerSwitchOverlaps(t.type) && (t.durationMs ?? 0) > 0\n}\n\n/** The overlap duration consumed at the boundary INTO this segment (D17).\n * A segment may carry at most one of the two transition fields\n * (validated), so we take whichever is present. */\nfunction overlapMsInto(seg: EdlSegment): number {\n if (segmentTransitionOverlaps(seg.transition)) return seg.transition!.durationMs ?? 0\n if (layoutTransitionOverlaps(seg.layout?.transition)) return seg.layout!.transition!.durationMs ?? 0\n return 0\n}\n\n/** Rendered duration of the edit, in ms. Σ segment durations minus the\n * overlap transitions (D17: an `xfade`/`crossfade` compresses the timeline\n * by its duration per boundary; `cut`/`pan`/`zoom` do not). Total over BOTH\n * the segment- and layout-transition fields.\n *\n * Derived FROM `segmentOutputStarts` so the invariant\n * `outputStart(last) + dur(last) === edlDurationMs` holds by construction on\n * every input — including a normalized-but-not-yet-validated EDL (the reserve\n * runs this before validate). The two must never be two independent overlap\n * implementations that can drift. */\nexport function edlDurationMs(edl: Edl): number {\n const starts = segmentOutputStarts(edl)\n if (starts.length === 0) return 0\n const last = edl.segments[edl.segments.length - 1]\n return Math.max(0, Math.round(starts[starts.length - 1] + Math.max(0, last.outMs - last.inMs)))\n}\n\n/** The output-clock start time of each segment (index-aligned to\n * `edl.segments`), accounting for D17 overlap: the transition INTO segment k\n * pulls its duration back from the boundary. `outputStart(0) = 0`;\n * `outputStart(n) + dur(n) === edlDurationMs`. The one output clock every\n * remap reads — a player seeking a rendered cut reads it too. */\nexport function edlSegmentOutputStarts(edl: Edl): number[] {\n return segmentOutputStarts(edl)\n}\n\nfunction segmentOutputStarts(edl: Edl): number[] {\n const starts: number[] = []\n let cursor = 0\n edl.segments.forEach((seg, i) => {\n // The transition into THIS segment overlaps the previous one.\n if (i > 0) cursor -= overlapMsInto(seg)\n starts.push(Math.max(0, Math.round(cursor)))\n cursor += Math.max(0, seg.outMs - seg.inMs)\n })\n return starts\n}\n\nconst inRange = (v: number, lo = 0, hi = 1) => v >= lo && v <= hi\n\nfunction regionIssues(r: EdlRegion, where: string): string[] {\n const out: string[] = []\n for (const [k, v] of Object.entries(r) as Array<[keyof EdlRegion, number]>) {\n if (!Number.isFinite(v) || !inRange(v)) out.push(`${where}: region.${k}=${v} out of 0..1`)\n }\n if (r.w <= 0 || r.h <= 0) out.push(`${where}: region has non-positive w/h`)\n if (r.x + r.w > 1 + 1e-9) out.push(`${where}: region extends past right edge (x+w>1)`)\n if (r.y + r.h > 1 + 1e-9) out.push(`${where}: region extends past bottom edge (y+h>1)`)\n return out\n}\n\n/** Library-produced (never construct one yourself — fields may be added). `ok` is `issues.length === 0`;\n * warnings never flip it. Issues = facts intrinsic to the EDL. Warnings = judgements against a REGISTRY\n * (source roles, speaker layouts/switches/emphasis, target aspects) that a newer version may widen — so an\n * older validator never rejects a newer EDL. */\nexport interface EdlValidation {\n readonly ok: boolean\n readonly issues: readonly string[]\n readonly warnings: readonly string[]\n}\n\n/** Structural validation. Coercion (defaults, clamping) is `normalizeEdl`'s\n * job; this reports what is still wrong after normalization. Segment ORDER is\n * the output timeline order and is NOT required to be monotonic on the master\n * clock — a legitimate multicam/clips EDL revisits earlier source time — so\n * the only per-segment ordering rule is `outMs > inMs`.\n *\n * The transition duration bound is the per-boundary ffmpeg-`xfade` limit: the\n * blend must be shorter than the adjacent material, so we validate at\n * `0.9 · min(the two adjacent segments)`. (combine-videos uses a more\n * conservative GLOBAL `0.9 · min(all clips)`; the per-boundary bound here is\n * the correct one, and the `apply-edl` executor must clamp per-boundary too —\n * copying combine's global-min would let validate pass a transition the\n * renderer then silently shortens, the R5 silent-edit this bound prevents.)\n * It applies only to overlap transitions; `cut`/`pan`/`zoom` are unbounded. */\nexport function validateEdl(edl: Edl): EdlValidation {\n const issues: string[] = []\n const warnings: string[] = []\n\n // A public validator reports, it does not throw: guard a raw object that\n // skipped normalizeEdl (missing/typed-wrong sources/segments).\n if (!Array.isArray(edl.segments) || !Array.isArray(edl.sources)) {\n edl = {\n ...edl,\n sources: Array.isArray(edl.sources) ? edl.sources : [],\n segments: Array.isArray(edl.segments) ? edl.segments : [],\n }\n }\n\n if (edl.version !== EDL_VERSION) issues.push(`version must be ${EDL_VERSION}`)\n if (edl.clock !== \"master\" && edl.clock !== \"output\") issues.push(`clock must be \"master\" or \"output\"`)\n\n const sourceIds = new Set<string>()\n let masterAudioCount = 0\n for (const s of edl.sources) {\n if (sourceIds.has(s.id)) issues.push(`duplicate source id \"${s.id}\"`)\n sourceIds.add(s.id)\n if (!s.url || !s.url.trim()) issues.push(`source \"${s.id}\": url is empty (media resolves from url)`)\n if (s.role === \"master-audio\") masterAudioCount++\n else if (s.role != null && !KNOWN_SOURCE_ROLES.has(s.role)) {\n warnings.push(`source \"${s.id}\": unknown role \"${s.role}\" (known: ${EDL_SOURCE_ROLES.join(\", \")})`)\n }\n if (s.region) issues.push(...regionIssues(s.region, `source \"${s.id}\"`))\n if (s.offsetMs !== undefined && !Number.isFinite(s.offsetMs)) issues.push(`source \"${s.id}\": offsetMs not finite`)\n }\n if (masterAudioCount > 1) issues.push(`more than one source has role:\"master-audio\" (${masterAudioCount})`)\n\n if (edl.segments.length === 0) issues.push(\"segments is empty\")\n\n edl.segments.forEach((seg, i) => {\n const at = `segment[${i}] \"${seg.id}\"`\n if (!(seg.outMs > seg.inMs)) issues.push(`${at}: outMs (${seg.outMs}) must be > inMs (${seg.inMs})`)\n if (seg.inMs < 0) issues.push(`${at}: inMs negative`)\n if (seg.video && !sourceIds.has(seg.video)) issues.push(`${at}: video source \"${seg.video}\" not in sources`)\n else if (seg.video) {\n const vs = edl.sources.find(s => s.id === seg.video)\n if (vs && vs.kind !== \"video\") issues.push(`${at}: video source \"${seg.video}\" is kind:\"${vs.kind}\", must be video`)\n }\n if (seg.audio && !sourceIds.has(seg.audio)) issues.push(`${at}: audio source \"${seg.audio}\" not in sources`)\n // A segment with no explicit audio must have a fallback: a master-audio source or its own video.\n if (!seg.audio && masterAudioCount === 0 && !seg.video) {\n issues.push(`${at}: no audio source and no master-audio/video fallback`)\n }\n\n // Transition rules.\n if (i === 0 && (seg.transition || seg.layout?.transition)) {\n issues.push(`${at}: segments[0] cannot have a transition (\"into this segment\" has no predecessor)`)\n }\n if (seg.transition && seg.layout?.transition) {\n issues.push(`${at}: both EdlSegment.transition and EdlLayout.transition set (pick one)`)\n }\n // The 0.9·min(adjacent) bound is the ffmpeg-xfade constraint and applies\n // ONLY to overlap transitions (crossfade / xfade:*). `cut`/`pan`/`zoom`\n // consume no time (overlapMsInto === 0) and their durationMs is inert, so\n // they are never bounded here.\n const ov = overlapMsInto(seg)\n if (ov > 0 && i > 0) {\n const prev = edl.segments[i - 1]\n const minAdj = Math.min(seg.outMs - seg.inMs, prev.outMs - prev.inMs)\n if (ov > 0.9 * minAdj + 1e-9) {\n issues.push(`${at}: overlap transition durationMs (${ov}) exceeds 0.9·min(adjacent segment)=${(0.9 * minAdj).toFixed(1)} — ffmpeg xfade would error / be clamped`)\n }\n }\n\n // Region rules (D20).\n if (seg.region) {\n issues.push(...regionIssues(seg.region, at))\n if (seg.layout?.slots && seg.layout.slots.length > 1) {\n issues.push(`${at}: segment.region is invalid when the layout has >1 slot (put the region on the slot)`)\n }\n }\n\n // Layout slot rules.\n for (const slot of seg.layout?.slots ?? []) {\n if (!sourceIds.has(slot.source)) issues.push(`${at}: slot source \"${slot.source}\" not in sources`)\n else {\n const src = edl.sources.find(s => s.id === slot.source)\n if (src && src.kind !== \"video\") issues.push(`${at}: slot source \"${slot.source}\" is kind:\"${src.kind}\", slots must be video`)\n }\n if (slot.weight !== undefined && !inRange(slot.weight)) issues.push(`${at}: slot.weight=${slot.weight} out of 0..1`)\n if (slot.region) issues.push(...regionIssues(slot.region, `${at} slot \"${slot.source}\"`))\n if (slot.follow) issues.push(...followIssues(slot.follow, slot.source, `${at} slot \"${slot.source}\"`))\n }\n })\n\n // segments ∩ dropped = ∅ (on the master clock).\n for (const d of edl.dropped ?? []) {\n if (!(d.outMs > d.inMs)) issues.push(`dropped range [${d.inMs},${d.outMs}) is not positive`)\n for (const seg of edl.segments) {\n if (seg.inMs < d.outMs && d.inMs < seg.outMs) {\n issues.push(`dropped range [${d.inMs},${d.outMs}) overlaps kept segment \"${seg.id}\" [${seg.inMs},${seg.outMs})`)\n break\n }\n }\n }\n\n // Registry-class findings (layouts, switches, emphasis, target aspect).\n warnings.push(...speakerPresentationWarnings(edl))\n\n return { ok: issues.length === 0, issues, warnings }\n}\n\n/** Validate a clip set (the `clips` mode output). */\nexport function validateEdlClipSet(set: EdlClipSet): EdlValidation {\n const issues: string[] = []\n const warnings: string[] = []\n if (set.version !== EDL_VERSION) issues.push(`clipset version must be ${EDL_VERSION}`)\n if (set.clips.length === 0) issues.push(\"clipset has no clips\")\n set.clips.forEach((clip, i) => {\n const r = validateEdl(clip)\n if (!r.ok) issues.push(...r.issues.map(m => `clip[${i}]: ${m}`))\n warnings.push(...r.warnings.map(m => `clip[${i}]: ${m}`))\n })\n return { ok: issues.length === 0, issues, warnings }\n}\n\nfunction offsetFor(edl: Edl, sourceId: string | undefined): number {\n if (!sourceId) return 0\n return edl.sources.find(s => s.id === sourceId)?.offsetMs ?? 0\n}\n\n/**\n * Map an instant on `sourceId`'s clock to the rendered output clock, or `null`\n * if that instant was dropped (falls in no kept segment). Applies the D19\n * offset (`masterMs = sourceMs + offsetMs`) and the D17 overlap compression.\n * `sourceId` omitted ⇒ the instant is already on the master clock.\n */\nexport function remapMsThroughEdl(edl: Edl, sourceMs: number, sourceId?: string): number | null {\n const masterMs = sourceMs + offsetFor(edl, sourceId)\n const starts = segmentOutputStarts(edl)\n for (let i = 0; i < edl.segments.length; i++) {\n const seg = edl.segments[i]\n if (masterMs >= seg.inMs && masterMs < seg.outMs) {\n return Math.round(starts[i] + (masterMs - seg.inMs))\n }\n }\n return null\n}\n\n/**\n * The inverse of `remapMsThroughEdl`: the master-clock instant the rendered\n * output plays at `outputMs`, or `null` before the start, at or past the end,\n * and for a non-finite time. Inside a crossfade both segments play; the\n * INCOMING one (the later segment) is the one named, since the cut has moved\n * to it. On an EDL that never revisits master time (a Tighten cut),\n * `remapMsThroughEdl(edl, outputMsToMasterMs(edl, t)) === t` for every output\n * instant `t`; an EDL that re-reads a span maps two output instants to one\n * master instant, and the remap names the first.\n */\nexport function outputMsToMasterMs(edl: Edl, outputMs: number): number | null {\n if (!Number.isFinite(outputMs) || outputMs < 0) return null\n const starts = segmentOutputStarts(edl)\n for (let i = edl.segments.length - 1; i >= 0; i--) {\n const seg = edl.segments[i]\n const dur = Math.max(0, seg.outMs - seg.inMs)\n if (outputMs >= starts[i] && outputMs < starts[i] + dur) return Math.round(seg.inMs + (outputMs - starts[i]))\n }\n return null\n}\n\n/**\n * Remap a transcript onto the rendered output: drop words that fall entirely\n * in removed material, clip a word that straddles a cut to its kept part (a\n * word running across two TOUCHING segments — contiguous on both the master\n * and the output clock — is not cut, and keeps its full length), and apply\n * the source offset (via `transcript.sourceId`). Captions, chapters and\n * clip offsets all depend on this one function.\n */\nexport function remapTranscriptThroughEdl(edl: Edl, transcript: Transcript): Transcript {\n const off = offsetFor(edl, transcript.sourceId)\n const starts = segmentOutputStarts(edl)\n /** Segment `j + 1` continues segment `j` on BOTH clocks: master time with no\n * jump, output time with no overlap. */\n const touches = (j: number): boolean => {\n const a = edl.segments[j]\n const b = edl.segments[j + 1]\n return b.inMs === a.outMs && starts[j + 1] === starts[j] + Math.max(0, a.outMs - a.inMs)\n }\n\n const mapWord = (w: Transcript[\"words\"][number]): (Transcript[\"words\"][number]) | null => {\n const startMaster = w.startMs + off\n const endMaster = w.endMs + off\n // A zero-width word is a point: keep it if the instant is kept (consistent\n // with remapMsThroughEdl, which returns non-null for a kept instant).\n if (startMaster === endMaster) {\n for (let i = 0; i < edl.segments.length; i++) {\n const seg = edl.segments[i]\n if (startMaster >= seg.inMs && startMaster < seg.outMs) {\n const out = Math.round(starts[i] + (startMaster - seg.inMs))\n return { ...w, startMs: out, endMs: out }\n }\n }\n return null\n }\n // Find the first kept segment that intersects [startMaster, endMaster) and\n // clip the word to that kept part — extended across every following\n // segment that TOUCHES it (decided 2026-10-08): the next segment resumes\n // the master clock exactly where this one ends and starts on the output\n // exactly where this one ends (no overlap into it), so the word plays\n // through unbroken and keeps its full length. A Speaker View turn split is\n // the common case. A jump in the master clock, or a crossfade / xfade into\n // the next segment, still clips the word to its first kept part.\n for (let i = 0; i < edl.segments.length; i++) {\n const seg = edl.segments[i]\n const lo = Math.max(startMaster, seg.inMs)\n let hi = Math.min(endMaster, seg.outMs)\n if (lo < hi) {\n for (let j = i; hi < endMaster && j + 1 < edl.segments.length && touches(j); j++) {\n hi = Math.min(endMaster, edl.segments[j + 1].outMs)\n }\n return {\n ...w,\n startMs: Math.round(starts[i] + (lo - seg.inMs)),\n endMs: Math.round(starts[i] + (hi - seg.inMs)),\n }\n }\n }\n return null\n }\n\n const words: Transcript[\"words\"][number][] = []\n for (const w of transcript.words) {\n const mapped = mapWord(w)\n if (mapped) words.push(mapped)\n }\n\n // A transcript SEGMENT (chapter-ish span) can straddle a cut and/or several\n // kept ranges. Take the ENVELOPE of every kept intersection: the earliest\n // kept output start to the latest kept output end. Endpoint-probing (map\n // start and end independently) inverts across a crossfade and collapses a\n // straddler to ~1ms; the envelope avoids both.\n const mapSegment = (s: NonNullable<Transcript[\"segments\"]>[number]) => {\n const startMaster = s.startMs + off\n const endMaster = s.endMs + off\n let outLo: number | null = null\n let outHi: number | null = null\n for (let i = 0; i < edl.segments.length; i++) {\n const seg = edl.segments[i]\n const lo = Math.max(startMaster, seg.inMs)\n const hi = Math.min(endMaster, seg.outMs)\n if (lo < hi) {\n const a = Math.round(starts[i] + (lo - seg.inMs))\n const b = Math.round(starts[i] + (hi - seg.inMs))\n if (outLo === null || a < outLo) outLo = a\n if (outHi === null || b > outHi) outHi = b\n }\n }\n if (outLo === null || outHi === null) return null\n return { ...s, startMs: outLo, endMs: outHi }\n }\n\n const segments = transcript.segments\n ?.map(mapSegment)\n .filter((s): s is NonNullable<typeof s> => s !== null)\n\n return { ...transcript, words, ...(segments ? { segments } : {}) }\n}\n\n/** Speaker turns: consecutive same-speaker words merged across gaps shorter\n * than `mergeGapMs`, then turns shorter than `minTurnMs` dropped. */\nexport function speakerTurns(\n transcript: Transcript,\n opts: { minTurnMs: number; mergeGapMs: number },\n): Array<{ speaker: string; startMs: number; endMs: number }> {\n const turns: Array<{ speaker: string; startMs: number; endMs: number }> = []\n for (const w of transcript.words) {\n const speaker = w.speaker ?? \"spk\"\n const last = turns[turns.length - 1]\n if (last && last.speaker === speaker && w.startMs - last.endMs <= opts.mergeGapMs) {\n last.endMs = Math.max(last.endMs, w.endMs)\n } else {\n turns.push({ speaker, startMs: w.startMs, endMs: w.endMs })\n }\n }\n return turns.filter(t => t.endMs - t.startMs >= opts.minTurnMs)\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Normalization (coerce, never reject; runs at every write site)\n// ─────────────────────────────────────────────────────────────────────────\n\nconst num = (v: unknown, fallback = 0): number => (typeof v === \"number\" && Number.isFinite(v) ? v : fallback)\nconst clamp01 = (v: number) => Math.min(1, Math.max(0, v))\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" ? v : undefined)\n\nfunction normalizeRegion(r: unknown): EdlRegion | undefined {\n if (!r || typeof r !== \"object\") return undefined\n const o = r as Record<string, unknown>\n if ([\"x\", \"y\", \"w\", \"h\"].some(k => typeof o[k] !== \"number\")) return undefined\n const x = clamp01(num(o.x))\n const y = clamp01(num(o.y))\n // Fit the box inside the frame so the result always passes validateEdl\n // (per-axis clamping alone can leave x+w>1). A degenerate box is dropped.\n const w = Math.min(clamp01(num(o.w)), 1 - x)\n const h = Math.min(clamp01(num(o.h)), 1 - y)\n if (w <= 0 || h <= 0) return undefined\n return { x, y, w, h }\n}\n\n/**\n * Coerce an unknown value into a well-formed `Edl`: fill defaults, drop unknown\n * fields, clamp regions to 0..1. All times are integer ms — there is NO\n * seconds→ms guessing (an integer-seconds EDL would silently become a\n * 1000×-longer edit; the contract is ms-only and a value that cannot be a\n * plausible ms EDL is a validation error, not a reinterpretation).\n *\n * Segment ORDER is preserved verbatim: it is the output timeline order, and a\n * multicam/clips EDL legitimately revisits earlier source time, so re-sorting\n * would corrupt it. (`dropped` has no ordering semantics and is left as-is.)\n */\nexport function normalizeEdl(input: unknown): Edl {\n const o = (input && typeof input === \"object\" ? input : {}) as Record<string, unknown>\n\n const sources: EdlSource[] = Array.isArray(o.sources)\n ? o.sources.map((raw, i) => {\n const s = (raw ?? {}) as Record<string, unknown>\n const src: EdlSource = {\n id: str(s.id) ?? `src-${i}`,\n url: str(s.url) ?? \"\",\n kind: s.kind === \"audio\" ? \"audio\" : \"video\",\n ...(s.offsetMs !== undefined ? { offsetMs: Math.round(num(s.offsetMs)) } : {}),\n ...(str(s.role) ? { role: s.role as EdlSource[\"role\"] } : {}),\n ...(Array.isArray(s.speakers) ? { speakers: s.speakers.filter((x): x is string => typeof x === \"string\") } : {}),\n ...(normalizeRegion(s.region) ? { region: normalizeRegion(s.region) } : {}),\n }\n return src\n })\n : []\n\n const segments: EdlSegment[] = Array.isArray(o.segments)\n ? o.segments.map((raw, i) => {\n const s = (raw ?? {}) as Record<string, unknown>\n const region = normalizeRegion(s.region)\n // A transition \"into\" segments[0] carries no information (no\n // predecessor), so strip it here rather than letting validateEdl 400 a\n // fixable EDL — LLM/hand-written EDLs routinely attach one to every\n // segment. Same for a layout transition on the first segment.\n const isFirst = i === 0\n const t = isFirst ? undefined : (s.transition as Record<string, unknown> | undefined)\n const layout = normalizeLayout(s.layout, isFirst)\n const seg: EdlSegment = {\n id: str(s.id) ?? `seg-${i}`,\n inMs: Math.round(num(s.inMs)),\n outMs: Math.round(num(s.outMs)),\n ...(str(s.video) ? { video: str(s.video) } : {}),\n ...(str(s.audio) ? { audio: str(s.audio) } : {}),\n ...(str(s.speaker) ? { speaker: str(s.speaker) } : {}),\n ...(t && (t.type === \"cut\" || t.type === \"crossfade\")\n ? { transition: { type: t.type as \"cut\" | \"crossfade\", durationMs: t.type === \"cut\" ? 0 : Math.round(num(t.durationMs)) } }\n : {}),\n ...(region ? { region } : {}),\n ...(layout ? { layout } : {}),\n ...(Array.isArray(s.labels) ? { labels: s.labels.filter((x): x is string => typeof x === \"string\") } : {}),\n }\n return seg\n })\n : []\n\n const dropped: EdlDropped[] | undefined = Array.isArray(o.dropped)\n ? o.dropped.map(raw => {\n const d = (raw ?? {}) as Record<string, unknown>\n return { inMs: Math.round(num(d.inMs)), outMs: Math.round(num(d.outMs)), reason: str(d.reason) ?? \"manual\" }\n })\n : undefined\n\n const meta = o.meta && typeof o.meta === \"object\" ? (o.meta as Edl[\"meta\"]) : undefined\n\n return {\n version: EDL_VERSION,\n clock: o.clock === \"output\" ? \"output\" : \"master\",\n sources,\n segments,\n ...(dropped ? { dropped } : {}),\n ...(o.derivedFrom && typeof o.derivedFrom === \"object\"\n ? { derivedFrom: { edlId: str((o.derivedFrom as Record<string, unknown>).edlId) ?? \"\", clock: \"output\" } }\n : {}),\n ...(meta ? { meta } : {}),\n }\n}\n\n/** A slot's `follow` is structurally sound: the slot's own source (the crop\n * is on that frame — a follow of another camera cannot describe the render),\n * a track id, a known motion. */\nfunction followIssues(follow: EdlSlotFollow, slotSource: string, at: string): string[] {\n const f = follow as unknown as Record<string, unknown>\n const issues: string[] = []\n if (f.sourceId !== slotSource) issues.push(`${at}: follow.sourceId ${JSON.stringify(f.sourceId)} is not the slot's source \"${slotSource}\"`)\n if (typeof f.trackId !== \"string\" || !f.trackId.trim()) issues.push(`${at}: follow.trackId is empty`)\n if (typeof f.motion !== \"string\" || !KNOWN_FOLLOW_MOTIONS.has(f.motion)) {\n issues.push(`${at}: follow.motion ${JSON.stringify(f.motion)} is not one of ${FOLLOW_MOTIONS.join(\", \")}`)\n }\n return issues\n}\n\n/** `follow` with its three fields, unknown keys dropped; undefined when any\n * field is missing or malformed (never guessed: an unknown motion is not a\n * motion this contract can describe). */\nfunction normalizeFollow(input: unknown): EdlSlotFollow | undefined {\n if (!input || typeof input !== \"object\") return undefined\n const o = input as Record<string, unknown>\n const sourceId = str(o.sourceId)\n const trackId = str(o.trackId)\n if (!sourceId || !trackId || typeof o.motion !== \"string\" || !KNOWN_FOLLOW_MOTIONS.has(o.motion)) return undefined\n return { sourceId, trackId, motion: o.motion as EdlSlotFollowMotion }\n}\n\nfunction normalizeLayout(input: unknown, dropTransition = false): EdlLayout | undefined {\n if (!input || typeof input !== \"object\") return undefined\n const o = input as Record<string, unknown>\n // Default the mode to \"single\" rather than dropping the whole layout — a\n // layout with slots/transition but no mode would otherwise lose them (and an\n // omitted xfade would silently lengthen the timeline).\n const mode = str(o.mode) || \"single\"\n const slots = Array.isArray(o.slots)\n ? o.slots\n .map(raw => {\n const s = (raw ?? {}) as Record<string, unknown>\n const source = str(s.source)\n if (!source) return null\n const region = normalizeRegion(s.region)\n const follow = normalizeFollow(s.follow)\n return {\n source,\n ...(region ? { region } : {}),\n ...(str(s.speaker) ? { speaker: str(s.speaker) } : {}),\n ...(s.weight !== undefined ? { weight: clamp01(num(s.weight)) } : {}),\n ...(follow ? { follow } : {}),\n }\n })\n .filter((x): x is NonNullable<typeof x> => x !== null)\n : undefined\n const emphasis = o.emphasis && typeof o.emphasis === \"object\"\n ? { style: str((o.emphasis as Record<string, unknown>).style) ?? \"none\", durationMs: Math.round(num((o.emphasis as Record<string, unknown>).durationMs)) }\n : undefined\n const transition = !dropTransition && o.transition && typeof o.transition === \"object\"\n ? { type: str((o.transition as Record<string, unknown>).type) ?? \"cut\", durationMs: Math.round(num((o.transition as Record<string, unknown>).durationMs)) }\n : undefined\n return {\n mode,\n ...(slots ? { slots } : {}),\n ...(emphasis ? { emphasis } : {}),\n ...(transition ? { transition } : {}),\n }\n}\n\n/** A time field as integer ms: a finite, non-negative number or numeric\n * string; `undefined` for anything else. */\nfunction timeMs(v: unknown): number | undefined {\n const n = typeof v === \"number\" ? v : typeof v === \"string\" && v.trim() !== \"\" ? Number(v) : Number.NaN\n return Number.isFinite(n) && n >= 0 ? Math.round(n) : undefined\n}\n\n/** A word's or segment's span: `startMs`/`endMs` (or the `start`/`end`\n * aliases). A zero-width span is a point and is kept; `undefined` only for a\n * broken one — a missing or unusable time, or an end before its start. */\nfunction spanMs(o: Record<string, unknown>): { startMs: number; endMs: number } | undefined {\n const startMs = timeMs(o.startMs ?? o.start)\n const endMs = timeMs(o.endMs ?? o.end)\n if (startMs === undefined || endMs === undefined || endMs < startMs) return undefined\n return { startMs, endMs }\n}\n\n/**\n * Coerce an unknown value into a `Transcript` — THE transcript reader\n * (decided 2026-10-08). The Cloud plugin's `coerceTranscript` reads by the\n * same rule, so the app and the plugin read one transcript the same way.\n * ms-only, as `normalizeEdl`; the `start`/`end` aliases are read when\n * `startMs`/`endMs` are absent. A zero-width word or segment (also one that\n * rounds to zero width) is a POINT and is kept, as before. Only a broken one\n * is dropped, never clamped: a missing start or end, a time that is not a\n * finite, non-negative number, or an end before its start. Words come out\n * sorted by start time (stable). A renamed transcript's `speakerNames` map is\n * kept (its non-empty string entries).\n */\nexport function normalizeTranscript(input: unknown): Transcript {\n const o = (input && typeof input === \"object\" ? input : {}) as Record<string, unknown>\n const words: Transcript[\"words\"][number][] = []\n if (Array.isArray(o.words)) {\n for (const raw of o.words) {\n if (!raw || typeof raw !== \"object\") continue\n const w = raw as Record<string, unknown>\n const span = spanMs(w)\n if (!span) continue\n words.push({\n text: str(w.text) ?? \"\",\n ...span,\n ...(str(w.speaker) ? { speaker: str(w.speaker) } : {}),\n ...(typeof w.confidence === \"number\" ? { confidence: w.confidence } : {}),\n })\n }\n words.sort((a, b) => a.startMs - b.startMs)\n }\n const segments = Array.isArray(o.segments)\n ? o.segments.flatMap(raw => {\n if (!raw || typeof raw !== \"object\") return []\n const s = raw as Record<string, unknown>\n const span = spanMs(s)\n return span ? [{ ...span, text: str(s.text) ?? \"\", ...(str(s.speaker) ? { speaker: str(s.speaker) } : {}) }] : []\n })\n : undefined\n const speakerNames = speakerNamesOf(o.speakerNames)\n return {\n version: EDL_VERSION,\n ...(str(o.sourceId) ? { sourceId: str(o.sourceId) } : {}),\n ...(str(o.language) ? { language: str(o.language) } : {}),\n words,\n ...(segments ? { segments } : {}),\n ...(speakerNames ? { speakerNames } : {}),\n }\n}\n\n/** A renamed transcript's raw → display map: entries whose label and name are\n * both non-empty strings; undefined when none is left. Built with\n * `Object.fromEntries`, so every label (even `__proto__`) stays an own entry. */\nfunction speakerNamesOf(v: unknown): Record<string, string> | undefined {\n if (!v || typeof v !== \"object\" || Array.isArray(v)) return undefined\n const entries = Object.entries(v as Record<string, unknown>).filter(\n (e): e is [string, string] => e[0].length > 0 && typeof e[1] === \"string\" && e[1].length > 0,\n )\n return entries.length > 0 ? Object.fromEntries(entries) : undefined\n}\n","/**\n * A person's review of an Edit Plan, and the ONE rule that makes it win.\n *\n * The planner's output stays on `data.generatedJson`, untouched. A review edit\n * lives beside it on `data.editedEdl` (TA13, decided 2026-10-04), tagged by\n * `kind` and fingerprinted with `basis` — the hash of the plan it was made\n * against. An edit whose basis no longer matches (the plan was re-run) is\n * ignored by construction, so no writer has to remember to clear it for the\n * read to be right. The edit is run-result data (TA14, decided 2026-10-04):\n * `editedEdl` is in `EXECUTION_DATA_KEYS`, so it stays out of undo, presets,\n * templates and exports, and Clear results wipes it.\n *\n * - Tighten: `{v:1, kind:\"edl\", basis, edl:{segments, dropped}}`. The resolved\n * plan is the planner's EDL with the edit's segments and dropped spans;\n * sources, clock and meta always come from the plan (an edit never stores\n * sources).\n * - Clips: `{v:1, kind:\"clips\", basis, clips:[{keep, hook?}]}`, index-aligned\n * with the plan's clips, holding decisions only. The list a fan-out reads\n * stays on the PLAN's indices, with `\"\"` at every dropped clip (TA16,\n * decided 2026-10-04), so an edge selector picks the same clips it picked\n * for the preview. `json` holds the kept clips only, so a scalar read (the\n * first item) is the first kept clip. An edited hook travels as `meta.hook`\n * (TA20, decided 2026-10-04: text only).\n * - Chapters have no review: an edit never applies.\n *\n * Every read of an Edit Plan's saved output calls `editPlanSavedOutput`, on\n * both engines; `extractGeneratedJsonAsList` stays generic.\n */\nimport { validateEdl, type Edl, type EdlDropped, type EdlSegment, type EdlValidation } from \"./edl.js\"\n\nexport const EDITED_EDL_VERSION = 1 as const\n\n/** A Tighten plan's review: the kept segments and the dropped spans. */\nexport interface EditedEdlCut {\n readonly v: typeof EDITED_EDL_VERSION\n readonly kind: \"edl\"\n /** `editPlanBasis` of the `generatedJson` this edit was made against. */\n readonly basis: string\n readonly edl: {\n readonly segments: readonly EdlSegment[]\n readonly dropped: readonly EdlDropped[]\n }\n}\n\n/** One clip's review decision, at the clip's index in the plan. */\nexport interface EditedClipDecision {\n readonly keep: boolean\n /** The clip's hook as the person rewrote it (text only); absent = the plan's. */\n readonly hook?: string\n}\n\n/** A clip set's review: one decision per planned clip, index-aligned. */\nexport interface EditedClipSet {\n readonly v: typeof EDITED_EDL_VERSION\n readonly kind: \"clips\"\n /** `editPlanBasis` of the `generatedJson` this edit was made against. */\n readonly basis: string\n readonly clips: readonly EditedClipDecision[]\n}\n\n/** What `data.editedEdl` on an Edit Plan holds. */\nexport type EditedEdl = EditedEdlCut | EditedClipSet\n\n/**\n * How the review edit stood when the plan was resolved:\n * - `none`: there is no edit;\n * - `applied`: the edit was made on this plan and wins;\n * - `stale`: it was made on another plan (a re-run, including one that\n * changed the clip count or the plan's mode) and is ignored;\n * - `invalid`: it is malformed, or, made on this plan, it does not fit its\n * kind or shape; it is ignored.\n */\nexport type EditPlanEditStatus = \"none\" | \"applied\" | \"stale\" | \"invalid\"\n\n/** An Edit Plan's output as every reader receives it. */\nexport interface EditPlanSavedOutput {\n /** Tighten: the EDL. Clips: the kept clips. Chapters: the chapter set. */\n readonly json: unknown\n /** Clips only: one JSON string per PLANNED clip, `\"\"` where a clip is dropped. */\n readonly listResults?: string[]\n}\n\nexport interface ResolvedEditPlanOutput extends EditPlanSavedOutput {\n readonly status: EditPlanEditStatus\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// basis: FNV-1a-64 over the key-sorted JSON\n// ─────────────────────────────────────────────────────────────────────────\n\n/** JSON text with every object's keys sorted, at every depth. `workflows.nodes`\n * is JSONB, which does not keep key order, so the stored plan can come back\n * with its keys in another order; its canonical text does not. Values follow\n * `JSON.stringify`: an undefined or function value drops its key (and is\n * `null` inside an array), and a non-finite number is `null`. */\nfunction canonicalJson(value: unknown): string | undefined {\n if (value === null) return \"null\"\n switch (typeof value) {\n case \"string\":\n case \"boolean\":\n return JSON.stringify(value)\n case \"number\":\n return Number.isFinite(value) ? JSON.stringify(value) : \"null\"\n case \"object\": {\n const toJSON = (value as { toJSON?: unknown }).toJSON\n if (typeof toJSON === \"function\") return canonicalJson((value as { toJSON: () => unknown }).toJSON())\n if (Array.isArray(value)) return `[${value.map((item) => canonicalJson(item) ?? \"null\").join(\",\")}]`\n const parts: string[] = []\n for (const key of Object.keys(value).sort()) {\n const text = canonicalJson((value as Record<string, unknown>)[key])\n if (text !== undefined) parts.push(`${JSON.stringify(key)}:${text}`)\n }\n return `{${parts.join(\",\")}}`\n }\n default:\n return undefined\n }\n}\n\n/** FNV-1a-64 over the UTF-8 bytes of `text`, as 16 lowercase hex digits. The\n * 64-bit state is two 32-bit halves: the prime is 2^40 + 435, so\n * `h × prime = h × 435 + (h << 40)` (mod 2^64), and every partial product\n * stays an exact double. */\nfunction fnv1a64(text: string): string {\n let hi = 0xcbf29ce4\n let lo = 0x84222325\n const mix = (byte: number): void => {\n lo = (lo ^ byte) >>> 0\n const loProduct = lo * 435\n const carry = Math.floor(loProduct / 0x1_0000_0000)\n hi = (hi * 435 + carry + ((lo << 8) >>> 0)) >>> 0\n lo = loProduct >>> 0\n }\n for (let i = 0; i < text.length; i++) {\n let code = text.charCodeAt(i)\n // A surrogate pair is one code point; a lone surrogate encodes as U+FFFD,\n // as TextEncoder does.\n if (code >= 0xd800 && code <= 0xdbff) {\n const next = i + 1 < text.length ? text.charCodeAt(i + 1) : 0\n if (next >= 0xdc00 && next <= 0xdfff) {\n code = 0x10000 + ((code - 0xd800) << 10) + (next - 0xdc00)\n i++\n } else code = 0xfffd\n } else if (code >= 0xdc00 && code <= 0xdfff) code = 0xfffd\n if (code < 0x80) mix(code)\n else if (code < 0x800) {\n mix(0xc0 | (code >> 6))\n mix(0x80 | (code & 0x3f))\n } else if (code < 0x10000) {\n mix(0xe0 | (code >> 12))\n mix(0x80 | ((code >> 6) & 0x3f))\n mix(0x80 | (code & 0x3f))\n } else {\n mix(0xf0 | (code >> 18))\n mix(0x80 | ((code >> 12) & 0x3f))\n mix(0x80 | ((code >> 6) & 0x3f))\n mix(0x80 | (code & 0x3f))\n }\n }\n return hi.toString(16).padStart(8, \"0\") + lo.toString(16).padStart(8, \"0\")\n}\n\n/**\n * The basis of every plan object already hashed. Hashing walks the whole plan\n * (about 20 ms on a large one), and both engines read the same saved plan\n * object many times: each review edit is a new `editedEdl` object over an\n * unchanged plan, and a run reads a seeded plan at every wire. Keyed by the\n * plan OBJECT, so it relies on a plan never being mutated in place: the editor\n * never mutates node data (a new plan is a new object), and the server reads\n * `generatedJson` as stored. A copy of a plan is another object and is hashed\n * on its own.\n */\nconst basisByPlan = new WeakMap<object, string>()\n\n/**\n * The fingerprint of an Edit Plan's stored output (`data.generatedJson`, as\n * unwrapped): FNV-1a-64 of the UTF-8 bytes of its key-sorted JSON, as 16\n * lowercase hex digits. Equal for any key order, so a JSONB round trip keeps\n * it; any change to a value, or to array order, changes it.\n */\nexport function editPlanBasis(plan: unknown): string {\n if (typeof plan !== \"object\" || plan === null) return fnv1a64(canonicalJson(plan) ?? \"\")\n const cached = basisByPlan.get(plan)\n if (cached !== undefined) return cached\n const basis = fnv1a64(canonicalJson(plan) ?? \"\")\n basisByPlan.set(plan, basis)\n return basis\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// The envelope\n// ─────────────────────────────────────────────────────────────────────────\n\ntype PlanShape = \"edl\" | \"clips\" | \"other\"\n\nconst isRecord = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v)\n\nfunction planShape(plan: unknown): PlanShape {\n if (Array.isArray(plan)) return \"clips\"\n if (isRecord(plan) && Array.isArray(plan.segments)) return \"edl\"\n return \"other\"\n}\n\ntype EnvelopeCheck =\n | { readonly status: \"none\" }\n | { readonly status: \"applied\"; readonly edited: EditedEdl }\n | { readonly status: \"stale\" | \"invalid\"; readonly issue: string }\n\n/** Is `edited` an edit of THIS plan? The envelope (version, basis, kind),\n * then the basis, then the plan's shape and the alignment. The basis comes\n * before the shape and the clip count because a re-run that changes the clip\n * count or the plan's mode is a re-plan (`stale`), not a malformed edit; once\n * the basis matches, a shape or count mismatch really is `invalid`. Never\n * looks inside the cut's segments (that is `validateEdl`'s). */\nfunction checkEnvelope(edited: unknown, plan: unknown): EnvelopeCheck {\n if (edited === undefined || edited === null) return { status: \"none\" }\n if (!isRecord(edited)) return { status: \"invalid\", issue: \"editedEdl must be an object\" }\n if (edited.v !== EDITED_EDL_VERSION) return { status: \"invalid\", issue: `editedEdl.v must be ${EDITED_EDL_VERSION}` }\n if (typeof edited.basis !== \"string\" || edited.basis.length === 0) {\n return { status: \"invalid\", issue: \"editedEdl.basis must be a non-empty string\" }\n }\n if (edited.kind !== \"edl\" && edited.kind !== \"clips\") {\n return { status: \"invalid\", issue: `editedEdl.kind must be \"edl\" or \"clips\"` }\n }\n if (edited.basis !== editPlanBasis(plan)) {\n return { status: \"stale\", issue: \"editedEdl.basis does not match the plan: the plan changed since this edit was made\" }\n }\n const shape = planShape(plan)\n if (edited.kind === \"edl\") {\n if (shape !== \"edl\") return { status: \"invalid\", issue: `an \"edl\" edit needs a Tighten plan (one EDL); this plan is ${describeShape(shape)}` }\n const edl = edited.edl\n if (!isRecord(edl) || !Array.isArray(edl.segments) || !Array.isArray(edl.dropped)) {\n return { status: \"invalid\", issue: \"editedEdl.edl must hold a segments array and a dropped array\" }\n }\n } else if (edited.kind === \"clips\") {\n if (shape !== \"clips\") return { status: \"invalid\", issue: `a \"clips\" edit needs a clip set; this plan is ${describeShape(shape)}` }\n const clips = edited.clips\n if (!Array.isArray(clips)) return { status: \"invalid\", issue: \"editedEdl.clips must be an array\" }\n const planned = (plan as readonly unknown[]).length\n if (clips.length !== planned) {\n return { status: \"invalid\", issue: `editedEdl.clips holds ${clips.length} decisions; the plan has ${planned} clips` }\n }\n const bad = clips.findIndex(\n (c) => !isRecord(c) || typeof c.keep !== \"boolean\" || (c.hook !== undefined && typeof c.hook !== \"string\"),\n )\n if (bad >= 0) return { status: \"invalid\", issue: `editedEdl.clips[${bad}] must be {keep: boolean, hook?: string}` }\n }\n return { status: \"applied\", edited: edited as unknown as EditedEdl }\n}\n\nfunction describeShape(shape: PlanShape): string {\n return shape === \"edl\" ? \"a Tighten plan\" : shape === \"clips\" ? \"a clip set\" : \"neither (a chapter list, or no plan)\"\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// The resolver\n// ─────────────────────────────────────────────────────────────────────────\n\n/** The plan's clip set as one JSON string per clip — today's list output. */\nfunction plannedList(plan: readonly unknown[]): string[] {\n return plan.map((clip) => (typeof clip === \"string\" ? clip : JSON.stringify(clip)))\n}\n\nfunction asOutput(plan: unknown): EditPlanSavedOutput {\n return Array.isArray(plan) ? { json: plan, listResults: plannedList(plan) } : { json: plan }\n}\n\n/** A clip with the person's hook, never mutating the plan's clip. */\nfunction withHook(clip: unknown, hook: string | undefined): unknown {\n if (hook === undefined) return clip\n let value = clip\n if (typeof clip === \"string\") {\n try {\n value = JSON.parse(clip)\n } catch {\n return clip\n }\n }\n if (!isRecord(value)) return clip\n const meta = isRecord(value.meta) ? value.meta : {}\n return { ...value, meta: { ...meta, hook } }\n}\n\n/**\n * An Edit Plan's output with the person's review applied: what every edit-plan\n * read hands downstream, on both engines.\n *\n * The edit applies when its shape matches the plan's kind and its `basis` is\n * this plan's. It applies even when the cut it holds is not a well-formed EDL:\n * the render then refuses it with its own issues, where falling back to the\n * planner's cut would silently render what the person removed. A stale or\n * invalid edit is ignored, and the plan is read as planned.\n */\nexport function resolveEditPlanOutput(plan: unknown, editedEdl: unknown): ResolvedEditPlanOutput {\n const check = checkEnvelope(editedEdl, plan)\n if (check.status !== \"applied\") return { status: check.status, ...asOutput(plan) }\n const edited = check.edited\n if (edited.kind === \"edl\") {\n const json = { ...(plan as Record<string, unknown>), segments: edited.edl.segments, dropped: edited.edl.dropped }\n return { status: \"applied\", json }\n }\n const rows = (plan as readonly unknown[]).map((clip, i) => {\n const decision = edited.clips[i]!\n return decision.keep ? withHook(clip, decision.hook) : undefined\n })\n return {\n status: \"applied\",\n json: rows.filter((clip) => clip !== undefined),\n listResults: rows.map((clip) => (clip === undefined ? \"\" : typeof clip === \"string\" ? clip : JSON.stringify(clip))),\n }\n}\n\n/**\n * An Edit Plan node's SAVED output — the one read every edit-plan reader makes\n * of `data` (a node outside the run, the editor's own read of the canvas).\n * `undefined` when the node holds no plan. With no edit it is exactly the plan:\n * `{json}`, plus `listResults` (one JSON string per clip) for a clip set.\n */\nexport function editPlanSavedOutput(data: Readonly<Record<string, unknown>>): EditPlanSavedOutput | undefined {\n const plan = data.generatedJson\n if (plan === undefined) return undefined\n const { status: _status, ...output } = resolveEditPlanOutput(plan, data.editedEdl)\n return output\n}\n\n/**\n * What a result writer writes when a plan lands on an Edit Plan node: the plan\n * itself, and `editedEdl: undefined` ONLY when the plan is not the one the\n * person's review was made on (its `editPlanBasis` differs from\n * `editedEdl.basis`; an edit that names no plan counts as different). The same\n * plan landing again, for example a reopen while the run is still live after\n * the plan finished, keeps the review (decided 2026-10-05). On a keep the patch\n * does not name `editedEdl` at all, so a merging write leaves the review as it\n * is. Pass the review the node holds now.\n *\n * The one place a review is cleared: `frontend/src/lib/__tests__/\n * edit-plan-saved-output-sites.test.ts` fails on a clearing write anywhere else.\n */\nexport function editPlanResultPatch(\n plan: unknown,\n editedEdl: unknown,\n): { readonly generatedJson: unknown; readonly editedEdl?: undefined } {\n const basis = isRecord(editedEdl) ? editedEdl.basis : undefined\n const madeOnThisPlan = typeof basis === \"string\" && basis.length > 0 && basis === editPlanBasis(plan)\n return madeOnThisPlan ? { generatedJson: plan } : { generatedJson: plan, editedEdl: undefined }\n}\n\n/**\n * Check a review edit before it is saved. The envelope (version, kind), the\n * basis, then the plan's shape and one decision per clip, and, for a Tighten edit,\n * the structural `validateEdl` of the edited cut — the Edit Plan's own\n * \"well-formed\" rule (TA1 a, decided 2026-10-04); what a given render can draw\n * is the render's rule, not this one. Issues are English, like `validateEdl`'s.\n */\nexport function validateEditedEdl(editedEdl: unknown, plan: unknown): EdlValidation {\n const check = checkEnvelope(editedEdl, plan)\n if (check.status === \"none\") return { ok: false, issues: [\"there is no edit\"], warnings: [] }\n if (check.status !== \"applied\") return { ok: false, issues: [check.issue], warnings: [] }\n if (check.edited.kind === \"clips\") return { ok: true, issues: [], warnings: [] }\n const resolved = resolveEditPlanOutput(plan, editedEdl).json as Edl\n return validateEdl(resolved)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/credit-identifiers.ts"],"names":[],"mappings":";;;;;AA4DA,SAAS,kBAAA,CAAmB,OAAmB,UAAA,EAA6B;AAC1E,EAAA,MAAM,IAAA,GAAO,CAAC,CAAA,KAAc,CAAA,CAAE,QAAQ,SAAA,EAAW,EAAE,EAAE,IAAA,EAAK;AAC1D,EAAA,MAAM,MAAM,OAAO,UAAA,KAAe,QAAA,GAAW,IAAA,CAAK,UAAU,CAAA,GAAI,EAAA;AAChE,EAAA,IAAI,GAAA,KAAQ,IAAI,OAAO,GAAA;AAIvB,EAAA,MAAM,IAAA,GAAO,YAAA,CAAa,IAAA,CAAK,CAAC,CAAA,KAAM,OAAO,CAAC,CAAA,KAAM,MAAA,CAAO,GAAG,CAAC,CAAA;AAC/D,EAAA,OAAO,IAAA,IAAQ,IAAA,CAAK,oBAAA,CAAqB,KAAK,KAAK,MAAM,CAAA;AAC3D;AAWO,SAAS,2BACd,QAAA,EACA,OAAA,EACA,UAAA,EACA,cAAA,EACA,kBACA,mBAAA,EACQ;AAOR,EAAA,IAAI,YAAA,CAAa,QAAQ,CAAA,EAAG;AAC1B,IAAA,OAAO,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,kBAAA,CAAmB,QAAA,EAAU,UAAU,CAAC,CAAA,GAAA,EAAM,IAAA,CAAK,GAAA,CAAI,mBAAA,IAAuB,CAAA,EAAG,CAAC,C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U;AAYH,SAAS,mBAAA,CAAoB,SAAkB,IAAA,EAAqC;AACzF,EAAA,MAAM,QAAQ,OAAA,KAAY,OAAA;AAC1B,EAAA,IAAI,IAAA,KAAS,UAAA,EAAY,OAAO,KAAA,GAAQ,oBAAA,GAAuB,cAAA;AAC/D,EAAA,OAAO,QAAQ,4BAAA,GAA+B,sBAAA;AAChD;AAkBO,SAAS,cAAA,CAAe,OAA2B,SAAA,EAA2B;AACnF,EAAA,IAAI,CAAE,8BAAA,CAAqD,QAAA,CAAS,SAAS,CAAA,EAAG;AAC9E,IAAA,OAAO,SAAA;AAAA,EACT;AACA,EAAA,OAAQ,KAAA,IAAS,wBAAA,CAAyB,KAAK,CAAA,IAAM,SAAA;AACvD;AAUO,IAAM,wBAAA,GAA6D;AAAA,EACxE,EAAA,EAAI,SAAA;AAAA,EACJ,OAAA,EAAS,cAAA;AAAA,EACT,OAAA,EAAS,cAAA;AAAA,EACT,IAAA,EAAM,WAAA;AAAA,EACN,EAAA,EAAI;AACN","file":"chunk-5RYLK3MQ.js","sourcesContent":["/**\n * Build composite credit model identifiers for variable pricing.\n * Shared between frontend and backend.\n */\n\nimport {\n HIGH_QUALITY_PROVIDERS,\n TWO_K_RESOLUTION_PROVIDERS,\n RESOLUTION_2K_4K_TIERED_PROVIDERS,\n IDEOGRAM_PROVIDERS,\n DURATION_PRICED_PROVIDERS,\n AUDIO_ADDON_PROVIDERS,\n MODE_ADDON_PROVIDERS,\n RESOLUTION_VIDEO_REF_PRICING,\n RESOLUTION_DURATION_PRICING,\n VEO_RESOLUTION_TIERED_PROVIDERS,\n VIDEO_DURATION_TIERS,\n pricedOutputDurationSec,\n snapToNearestDuration,\n PRICING_DEFAULT_RESOLUTION,\n MOTION_DURATION_TIERS,\n T2I_TO_I2I_VARIANT,\n isVeoProvider,\n isMinimaxH3Provider,\n isGeminiOmniProvider,\n isWan3Provider,\n normalizeMinimaxH3Resolution,\n normalizeWan3Resolution,\n getVideoAudioCapability,\n} from \"./model-constants.js\"\nimport { isFlux2Model, FLUX2_RES_MP, type Flux2Model } from \"./flux2-pricing.js\"\nimport { VIDEO_DURATION_AUTO } from \"./video-duration-auto.js\"\nimport { uiResolutionFill } from \"./video-ui-defaults.js\"\nimport { MODEL_CATALOG, autoAspectNeedsSourceImage, normalizeModelInput, normalizeVideoRequestParams, defaultResolutionFor, type ModelInputAdjustment, type SourceImageSize } from \"./model-catalog.js\"\n\n/**\n * The megapixel tier a Flux 2 credit identifier is keyed on, for ANY incoming\n * `resolution` value.\n *\n * Flux 2 is the only family whose identifier INTERPOLATES the resolution\n * instead of matching it against a known set, and its callers are not\n * guaranteed to hand it a Flux 2 value:\n * - the multi-provider cost preview prices one node's data against EVERY\n * selected provider (`frontend/src/ee/hooks/use-providers-credits-sum.ts`),\n * so a node whose `resolution` is \"2K\" (the flux / nano-banana-pro value\n * space) reaches this branch verbatim;\n * - node data written straight into workflow JSON by an agent, an import or\n * a template never ran the config panel's provider-change fail-safe.\n * Interpolating that produced the off-grid id `flux-2-pro:2KMP:0ref`, which no\n * pricing row can answer — every cost badge 503'd `price_not_configured`\n * (18 production app-reports, 2026-09-07..14).\n *\n * A value off the grid snaps to the model's DEFAULT tier — the same `preferred`\n * value `normalizeModelInput` uses — so the preview asks for exactly the id the\n * route will reserve (both routes and the orchestrator normalize through\n * `resolveNormalizedImageGen` first, which makes this snap a no-op for them).\n * An ABSENT resolution keeps its long-standing meaning (\"this caller has no\n * resolution dimension at all\") and stays on 1 MP rather than moving to the\n * model default, which would silently re-price every resolution-less node.\n */\nfunction flux2MegapixelTier(model: Flux2Model, resolution?: string): string {\n const bare = (v: string) => v.replace(/\\s*MP$/i, \"\").trim()\n const raw = typeof resolution === \"string\" ? bare(resolution) : \"\"\n if (raw === \"\") return \"1\"\n // Numeric match so \"2.0\"/\" 2 MP\" land on the same grid point as \"2\", and the\n // GRID's own spelling is what gets emitted — returning the caller's \"2.0\"\n // would build \":2.0MP:\", another id no pricing row carries.\n const tier = FLUX2_RES_MP.find((t) => Number(t) === Number(raw))\n return tier ?? bare(defaultResolutionFor(model) ?? \"1 MP\")\n}\n\n/**\n * Compute composite model identifier for variable credit pricing.\n * Examples: \"gpt-image:high\", \"flux:2K\", \"nano-banana-pro:4K\", \"ideogram:TURBO\",\n * \"flux-2-pro:2MP\", \"flux-2-max:2MP:1ref\" (Flux 2 — billed per megapixel).\n *\n * For image models, uses quality/resolution/renderingSpeed and (Flux 2) the output\n * megapixel count plus (Flux 2 Max) the number of reference images attached at request time.\n * For video models, uses duration/sound params when the model has variable pricing.\n */\nexport function buildCreditModelIdentifier(\n provider: string,\n quality?: string,\n resolution?: string,\n renderingSpeed?: string,\n targetResolution?: string,\n referenceImageCount?: number,\n): string {\n // Flux 2 family: billed per output megapixel AND per reference image (each\n // ref counts as input megapixels). Resolution arrives as \"N MP\" strings (the\n // UI value space); strip the unit. ALL three models encode the ref count\n // (capped at 8): Pro/Klein i2i always carry the source image as a ref and\n // their cost formula charges per input MP, so the reserved identifier must\n // reflect refs (there is no metered true-up to correct an under-reserved tier).\n if (isFlux2Model(provider)) {\n return `${provider}:${flux2MegapixelTier(provider, resolution)}MP:${Math.min(referenceImageCount ?? 0, 8)}ref`\n }\n if (HIGH_QUALITY_PROVIDERS.has(provider) && quality === \"high\") {\n return `${provider}:high`\n }\n if (TWO_K_RESOLUTION_PROVIDERS.has(provider) && resolution === \"2K\") {\n return `${provider}:2K`\n }\n if (provider === \"nano-banana-pro\" && resolution === \"4K\") {\n return `${provider}:4K`\n }\n if (RESOLUTION_2K_4K_TIERED_PROVIDERS.has(provider) && (resolution === \"2K\" || resolution === \"4K\")) {\n return `${provider}:${resolution}`\n }\n // Topaz Image Upscale: 2K is default (no suffix), 4K/8K get composite identifiers\n if (provider === \"topaz-image-upscale\" && targetResolution && targetResolution !== \"2K\") {\n return `${provider}:${targetResolution}`\n }\n if (IDEOGRAM_PROVIDERS.has(provider)) {\n if (renderingSpeed === \"TURBO\") return `${provider}:TURBO`\n if (renderingSpeed === \"QUALITY\") return `${provider}:QUALITY`\n }\n return provider\n}\n\n/**\n * An image request's catalog-snapped parameters PLUS the credit identifier\n * priced off them.\n *\n * `adjustments` is the disclosure channel: every lever this changed, why, and\n * to what. Routes return it in the 200 body so a caller learns their value was\n * corrected instead of silently getting something else.\n */\nexport interface NormalizedImageGen {\n /** Credit identifier, priced off the SNAPPED `resolution` / `quality`. */\n identifier: string\n /** The catalog model id the params were snapped against (post T2I→I2I swap). */\n modelId: string\n aspectRatio?: string\n resolution?: string\n quality?: string\n /** Empty when the caller's values were already valid for `modelId`. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The catalog model `resolveNormalizedImageGen` snaps against: the provider\n * (Nano Banana when none is named), or — with `swapToI2i` and references\n * attached — its i2i sibling, the model the generate-image route and the\n * workflow payload builder then send. That sibling has its OWN catalog entry\n * and lever lists. Exported so a caller that has to decide something about\n * those lists before the snap (whether a photo's size is worth reading) asks\n * about the same model the snap will use.\n */\nexport function normalizedImageGenModelId(opts: {\n provider: unknown\n refCount: number\n swapToI2i?: boolean\n}): string {\n const provider = typeof opts.provider === \"string\" && opts.provider.length > 0 ? opts.provider : \"nano-banana\"\n return opts.swapToI2i && opts.refCount > 0 ? (T2I_TO_I2I_VARIANT[provider] ?? provider) : provider\n}\n\n/**\n * Whether \"auto\" on a Generate Image request can need its photo's size: the\n * model the snap runs against (`normalizedImageGenModelId` with the swap on)\n * has no native auto. Given the ASSEMBLED reference count, it asks about exactly\n * that model; without one — a write boundary, or a run before its references\n * assemble — about both the provider and its i2i sibling, since references may\n * yet attach.\n */\nexport function imageGenAutoAspectNeedsSourceImage(opts: {\n provider: unknown\n aspectRatio: unknown\n refCount?: number\n}): boolean {\n const asks = (refCount: number) =>\n autoAspectNeedsSourceImage(normalizedImageGenModelId({ provider: opts.provider, refCount, swapToI2i: true }), opts.aspectRatio)\n return opts.refCount === undefined ? asks(0) || asks(1) : asks(opts.refCount)\n}\n\n/**\n * Snap an image request's catalog-governed levers to a combination the model\n * actually accepts, and price the credit identifier off the SNAPPED values.\n *\n * WHY THE SNAP LIVES HERE and not at the call site. Both image routes compute\n * their credit identifier TWICE — once in the `creditGuard` preHandler (the\n * CHECK) and once at the handler's `reserveCreditsForJob` (the DEBIT) — and a\n * dedicated test asserts the two stay byte-identical (see\n * `backend/src/routes/__tests__/generate-image.test.ts`, \"CHECK === DEBIT\").\n * `resolution` and `quality` are pricing dimensions, so a snap applied at only\n * one of those sites breaks that invariant, and `commit_credits` never collects\n * an upward delta — the reserve IS the charge. Putting the snap inside the\n * primitive makes CHECK, DEBIT and the workflow orchestrator agree by\n * construction rather than by everyone remembering to call a normalizer.\n *\n * Inputs are typed `unknown` on purpose: the preHandler runs BEFORE Zod, so a\n * caller can put a number or an object in `resolution`. Non-strings become\n * `undefined` rather than reaching `normalizeModelInput` as a lie.\n *\n * Unknown model ids pass through untouched (same contract as\n * `normalizeModelInput`) — the route's provider enum is the gate for those.\n *\n * `sourceImage` is the size of the photo the request transforms or is drawn\n * from (an image-to-image / edit source, or Generate Image's first wired\n * reference). It only decides \"auto\" on a model without a native auto, and the\n * ratio is not a pricing dimension on any such model (pinned across the catalog\n * by `auto-aspect-source.test.ts`), so a CHECK that runs before the size is\n * known prices the same identifier as the DEBIT that knows it.\n */\nexport function resolveNormalizedImageGen(opts: {\n provider: string | undefined\n aspectRatio?: unknown\n quality?: unknown\n resolution?: unknown\n renderingSpeed?: unknown\n refCount: number\n swapToI2i?: boolean\n sourceImage?: SourceImageSize\n}): NormalizedImageGen {\n const str = (v: unknown): string | undefined =>\n typeof v === \"string\" && v.length > 0 ? v : undefined\n\n const modelId = normalizedImageGenModelId(opts)\n\n const n = normalizeModelInput(\n modelId,\n {\n aspectRatio: str(opts.aspectRatio),\n resolution: str(opts.resolution),\n quality: str(opts.quality),\n },\n { sourceImage: opts.sourceImage },\n )\n\n return {\n identifier: buildCreditModelIdentifier(\n modelId,\n n.quality,\n n.resolution,\n str(opts.renderingSpeed),\n undefined,\n opts.refCount,\n ),\n modelId,\n aspectRatio: n.aspectRatio,\n resolution: n.resolution,\n quality: n.quality,\n adjustments: n.adjustments,\n }\n}\n\n/**\n * Reference-aware image-generation credit identifier — the SINGLE source of\n * truth shared by the single-node routes (`/v1/generate-image`,\n * `/v1/image-to-image`) and the workflow orchestrator\n * (`payload-builder.ts`). It centralises the two pricing dimensions that must\n * match across both paths or a Flux 2 generation is billed the wrong tier\n * (Flux 2 commits non-metered / has no upward true-up, so the reserved\n * identifier IS the final charge):\n * - `refCount`: the number of reference images sent to the provider (Flux 2\n * bills per ref). generate-image passes the assembled count (0 for pure\n * text-to-image); image-to-image passes 1 (the primary `imageUrl`) + extras.\n * - `swapToI2i`: generate-image auto-swaps a bare T2I provider to its i2i\n * sibling (`T2I_TO_I2I_VARIANT`) when refs are attached, so the credit id\n * matches the variant actually invoked. image-to-image is already an i2i\n * provider → pass `false`.\n *\n * The LoRA short-circuit (`flux-lora-character`) stays at the call site because\n * the routing decision needs a DB lookup the routes/orchestrator own.\n */\nexport function resolveImageGenCreditIdentifier(opts: {\n provider: string | undefined\n quality?: string\n resolution?: string\n renderingSpeed?: string\n refCount: number\n swapToI2i?: boolean\n}): string {\n return resolveNormalizedImageGen(opts).identifier\n}\n\n// T2V-specific credit overrides: some providers have different costs for T2V\n// vs I2V/V2V due to different default resolutions or colliding with image model names.\nconst T2V_CREDIT_OVERRIDES: Record<string, string> = {\n \"grok\": \"grok-i2v\", // T2V grok, same as I2V grok (not image grok = 4 cr)\n \"wan\": \"wan-t2v\", // T2V wan 1080p = (V2V wan 720p = 70 cr)\n \"wan-turbo\": \"wan-turbo-t2v\", // T2V wan-turbo 720p = (I2V wan-turbo 480p = 40 cr)\n}\n\n/**\n * Compute composite model identifier for video models with duration/audio-based pricing.\n * Examples: \"kling-3.0:5s\", \"kling-3.0:10s:audio\", \"seedance-2:8s:720p-ref\"\n *\n * @param provider - Video model key (e.g., \"kling-3.0\")\n * @param duration - Video duration in seconds\n * @param sound - Whether audio/sound is enabled\n * @param nodeType - Node type for T2V-specific cost overrides\n * @param mode - Quality variant that affects pricing\n * @param resolution - Output resolution (used by Seedance 2 for 480p/720p pricing)\n * @param hasVideoRef - Whether a reference video is connected (Seedance 2 uses a lower per-second rate when true)\n */\n/**\n * LTX 2.3 (Lightricks via Replicate) credit tiers: priced by\n * (resolution-band × duration-seconds). Keys mirror STATIC_CREDIT_COSTS /\n * model_pricing EXACTLY (lowercase band + raw seconds + \"s\"), e.g.\n * \"ltx-2.3-pro:1080p:6s\". This map is the source of truth for the nearest-tier\n * snap below, so an off-catalog (resolution, duration) from a direct API/SDK\n * call maps to a SEEDED price instead of hard-failing (price_not_configured\n * 503). Pro: 6/8/10s at every band. Fast: up to 20s at 1080p, 6/8/10s at 2k/4k.\n */\nconst LTX_DURATION_TIERS: Record<string, Record<string, number[]>> = {\n \"ltx-2.3-pro\": { \"1080p\": [6, 8, 10], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n \"ltx-2.3-fast\": { \"1080p\": [6, 8, 10, 12, 14, 16, 18, 20], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n}\n\n/**\n * The (band, duration) tier the LTX pricing ladder charges for a request, or\n * `undefined` for a non-LTX provider. Extracted so\n * `buildVideoCreditModelIdentifier` and `pricedVideoSelection` read the ladder\n * ONCE — the routes must send the tier they reserved, and a second copy of this\n * math is exactly how the two drift apart.\n *\n * An unknown/absent band falls back to 1080p (LTX's own default, and the band\n * `snapLtxInput` snaps to at the Replicate call), and an off-tier duration\n * snaps to the NEAREST seeded one so the emitted composite always prices.\n */\nfunction ltxPricedTier(\n provider: string,\n resolution?: string,\n duration?: number | string,\n): { band: string; duration: number } | undefined {\n const bands = LTX_DURATION_TIERS[provider]\n if (!bands) return undefined\n const band = bands[String(resolution)] ? String(resolution) : \"1080p\"\n const allowed = bands[band]!\n // The model's own default (catalog `defaultDuration`) when unset, then the\n // nearest rung of THIS band's ladder — the length LTX renders.\n const dur = snapToNearestDuration(pricedOutputDurationSec(provider, duration), allowed)\n return { band, duration: dur }\n}\n\nexport function buildVideoCreditModelIdentifier(\n provider: string,\n duration?: number | string,\n sound?: boolean,\n nodeType?: \"image-to-video\" | \"text-to-video\",\n mode?: string,\n resolution?: string,\n hasVideoRef?: boolean,\n): string {\n // T2V overrides: some providers have different base costs for text-to-video\n let effectiveProvider = provider\n if (nodeType === \"text-to-video\") {\n const override = T2V_CREDIT_OVERRIDES[provider]\n if (override) {\n // If override target also has duration pricing, use it as effective provider\n if (DURATION_PRICED_PROVIDERS.has(override)) {\n effectiveProvider = override\n } else {\n return override\n }\n }\n }\n\n // VEO 3.x resolution-tiered pricing: 720p is the base (no suffix), 1080p gets\n // \":1080p\" (Fast/Lite only), and 4K gets \":4k\" for ALL three tiers — direct-4K\n // generation chains KIE's get-4k-video off the base generation (the base runs\n // at 1080p). Duration is fixed at 8s for VEO so the duration-tier path below\n // does not apply.\n if (isVeoProvider(effectiveProvider)) {\n if (resolution === \"4k\") return `${effectiveProvider}:4k`\n // 1080p tier is Fast/Lite only (Quality has no 1080p surcharge).\n if (resolution === \"1080p\" && VEO_RESOLUTION_TIERED_PROVIDERS.has(effectiveProvider)) return `${effectiveProvider}:1080p`\n return effectiveProvider\n }\n\n // Gemini Omni family (gemini-omni-video + gemini-omni-flash): priced by\n // (resolution-band × duration), with a flat per-generation rate when a source\n // video is supplied (V2V). Lowercase \"4k\". The prefix is TEMPLATED from the\n // provider id, so a further Omni SKU needs no edit here — it only has to join\n // GEMINI_OMNI_PROVIDERS and seed its rows. These models are deliberately NOT\n // in DURATION_PRICED_PROVIDERS; this branch early-returns before that gate.\n if (isGeminiOmniProvider(effectiveProvider)) {\n if (hasVideoRef) {\n return resolution === \"4k\" ? `${effectiveProvider}:4k:vref` : `${effectiveProvider}:vref`\n }\n // The rendered length through the catalog funnel (nearest legal tier, the\n // model's own default when unset) so the composite is always a SEEDED one.\n const d = pricedOutputDurationSec(effectiveProvider, duration)\n return resolution === \"4k\" ? `${effectiveProvider}:4k:${d}` : `${effectiveProvider}:${d}`\n }\n\n // LTX 2.3: priced by (resolution-band × duration-seconds). The RESERVE must be\n // the correct composite — commit_credits (migration 176) only refunds a surplus\n // (actual < reserved) and NEVER collects an upward delta, so an under-reserved\n // LTX run (the bare-id default = cheapest 1080p:6s tier) stays under-charged\n // even with meteredCost:true. Snap to a seeded tier so the id always prices.\n const ltxTier = ltxPricedTier(effectiveProvider, resolution, duration)\n if (ltxTier) {\n return `${effectiveProvider}:${ltxTier.band}:${ltxTier.duration}s`\n }\n\n if (!DURATION_PRICED_PROVIDERS.has(effectiveProvider)) {\n return effectiveProvider\n }\n\n // A named-provider request with NO duration renders the model's own default\n // (kie/models.ts extraParams), so price that default — not the global 5s —\n // for providers whose per-second tiers wouldn't snap 5 up to it\n // (minimax-h3, seedance-2-5). One helper, shared with the dynamic\n // reference-video reservations, so the tier and the scaled reserve agree.\n const durationSec = pricedOutputDurationSec(effectiveProvider, duration)\n const tiers = VIDEO_DURATION_TIERS[effectiveProvider]\n if (!tiers) return effectiveProvider\n\n // Find the matching duration tier\n const tier = tiers.find(t => durationSec <= t.maxSeconds) ?? tiers[tiers.length - 1]\n let identifier = `${effectiveProvider}:${tier.suffix}`\n\n // Append audio suffix if applicable. When the caller expressed no intent\n // (sound === undefined), fall back to the model's own default (capability\n // `defaultOn` — kling-3.0 generates audio unless explicitly disabled), so an\n // intent-less request is billed for the audio it actually produces instead\n // of reserving the cheaper no-audio tier against an audio-on generation.\n const soundOn = sound ?? (getVideoAudioCapability(effectiveProvider).defaultOn === true)\n if (AUDIO_ADDON_PROVIDERS.has(effectiveProvider) && soundOn) {\n identifier += \":audio\"\n }\n\n // Append mode suffix for providers with quality-tiered pricing\n // \"high\" comes from I2V videoSize field, \"pro\" comes from T2V mode field\n if (MODE_ADDON_PROVIDERS.has(effectiveProvider) && (mode === \"high\" || mode === \"pro\")) {\n identifier += \":high\"\n }\n\n // Seedance 2.0 family: per-second billing with resolution + video-ref dimensions.\n // KIE accepts 480p / 720p / 1080p natively; per-second rates rise non-linearly\n // so each tier gets its own composite identifier.\n if (RESOLUTION_VIDEO_REF_PRICING.has(effectiveProvider)) {\n // Clamp to the model's catalog resolutions (single source of truth): e.g.\n // seedance-2-mini exposes only 480p/720p, so a stale/explicit 1080p (or 4k)\n // maps to its top priced tier instead of emitting an unpriced composite\n // (which the hard-fail credit guard would 503 on at runtime).\n const supported = MODEL_CATALOG[effectiveProvider]?.resolutions ?? [\"480p\", \"720p\", \"1080p\"]\n // An OMITTED resolution renders the model's KIE-side default, so price that\n // default rather than the cheapest tier — otherwise an intent-less request\n // reserves 480p against a 720p render and commit_credits (refund-only) can\n // never collect the delta. Providers without an entry keep the historical\n // 480p fallback, so this cannot reprice anything already live.\n const requested = resolution ?? PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const want = requested === \"4k\" ? \"4k\" : requested === \"1080p\" ? \"1080p\" : requested === \"720p\" ? \"720p\" : \"480p\"\n // Unsupported (e.g. a stale 1080p on seedance-2-mini) clamps to the model's\n // top priced tier so the emitted composite is always seeded.\n const res = supported.includes(want) ? want : (supported[supported.length - 1] ?? \"480p\")\n identifier += `:${res}`\n if (hasVideoRef) identifier += \"-ref\"\n }\n\n // Duration × resolution pricing without a -ref dimension. Resolutions\n // outside the provider's priced tiers (or undefined) collapse to the first\n // (default) tier so the emitted composite is always seeded — the hard-fail\n // guard fuzzes the whole resolution space.\n const resTiers = RESOLUTION_DURATION_PRICING[effectiveProvider]\n if (resTiers) {\n // The \"default tier\" is the provider's DECLARED default when it has one\n // (PRICING_DEFAULT_RESOLUTION — wan-3 renders 720p, not the cheapest tier),\n // otherwise the first listed tier. Declaring it explicitly means a cosmetic\n // reorder of the tier list can never reprice a live model, and an OMITTED\n // *or* unsupported resolution both land on what actually renders instead of\n // on the cheapest row (commit_credits refunds a surplus but can never\n // collect a shortfall). Behaviour-neutral for every member without a\n // declared default.\n const declaredDefault = PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const fallback = declaredDefault && resTiers.includes(declaredDefault) ? declaredDefault : resTiers[0]!\n // Wan 3.0 renders through `normalizeWan3Resolution`, which is CASE-INSENSITIVE\n // (\"1080P\" — KIE's own OpenAPI enum spelling, and the natural value for an\n // integrator reading the provider docs — renders 1080P). The tier list here is\n // lowercase and `Array.includes` is case-sensitive, so without this the render\n // path and the billing path disagree: \"1080P\" rendered the top tier and billed\n // the 720p row, a shortfall `commit_credits` (refund-only) can never collect.\n // Collapsing through the SAME normalizer the runner uses makes render == billed\n // by construction for every spelling, including garbage (→ the declared 720p).\n // Scoped to the wan family on purpose: the other RESOLUTION_DURATION_PRICING\n // members pass `resolution` to their wire verbatim, so case-folding their\n // billing without probing their wire would reprice live models.\n const requested = isWan3Provider(effectiveProvider)\n ? normalizeWan3Resolution(resolution).toLowerCase()\n : resolution\n const res = requested && resTiers.includes(requested) ? requested : fallback\n identifier += `:${res}`\n }\n\n // MiniMax Hailuo 3 (768P lever, 2026-08-03): bare duration composites stay\n // the 2K (default) rate — byte-identical to the pre-lever seeded rows, so\n // existing workflows and admin overrides keep their ids — and only a\n // verified 768P selection appends \":768p\". normalizeMinimaxH3Resolution\n // collapses anything else to 2K, matching what KIE renders for an\n // omitted/unknown value, so billing can never undercut the render.\n if (isMinimaxH3Provider(effectiveProvider) && normalizeMinimaxH3Resolution(resolution) === \"768P\") {\n identifier += \":768p\"\n }\n\n return identifier\n}\n\n/**\n * The credit identifier a video GENERATION node is quoted at — Generate Video\n * (and the legacy Image/Text to Video nodes) and the Video to Video Seedance\n * edit lane, on every surface that quotes one: the node's cost pill, the\n * editor's run estimate, the prompt modal and the backend pre-run estimator.\n *\n * It applies the request levers the run applies BEFORE it prices\n * (payload-builder's `resolveVideoRequestNorm`): the model's UI resolution fill\n * when the node names none (`uiResolutionFill` — what the run sends), then the\n * catalog normalizer `normalizeVideoRequestParams`, which also owns the Seedance\n * Draft rule (a draft is priced AND sent at 480p whatever resolution came with\n * it). Without that, a node with no resolution was quoted at the identifier's\n * own default band (720p on Seedance 2.5) while the run sent and reserved 480p.\n *\n * `hasVideoRef` must come from the GRAPH (a wired reference-video edge, e.g.\n * `countRefModalityEdges(edges, id, \"video\") > 0`), never node data: nothing\n * writes `referenceVideoUrls` into a video node, so reading it there always\n * quoted the plain ladder for a run that reserves on the `-ref` one.\n */\nexport function videoGenerationCreditId(args: {\n provider: string\n duration?: number | string\n sound?: boolean\n nodeType?: \"image-to-video\" | \"text-to-video\"\n mode?: string\n resolution?: string\n draft?: boolean\n hasVideoRef?: boolean\n}): string {\n const { resolution } = normalizeVideoRequestParams(args.provider, {\n resolution: args.resolution ?? uiResolutionFill(args.provider),\n draft: args.draft === true,\n })\n return buildVideoCreditModelIdentifier(\n args.provider,\n args.duration,\n args.sound,\n args.nodeType ?? \"image-to-video\",\n args.mode,\n resolution,\n args.hasVideoRef === true,\n )\n}\n\n/**\n * The credit identifier a Video to Video node's Seedance EDIT lane reserves\n * under. Seedance has no v2v endpoint — the lane is a text-to-video job in edit\n * shape with the source clip as reference video 1 — so it prices on the\n * REFERENCE-VIDEO ladder at the model's LONGEST clip (Auto duration), and the\n * measured settlement refunds down to what was actually delivered.\n *\n * A thin call into {@link videoGenerationCreditId}, so a Generate Video node\n * making the same KIE call (Seedance, Auto, a wired reference video) is quoted\n * the same id. FOUR surfaces must agree on it exactly: the orchestrator's\n * reservation (payload-builder.ts), the backend pre-run estimator\n * (ee/billing/credits.ts), the node's cost pill, and the frontend run-level\n * estimate (config-panels/helpers.ts). A quote that disagrees with the reserve\n * is the documented `price_not_configured` / blank-pill trap.\n *\n * `resolution` is the node's one `v2vResolution` field; when unset the model's\n * own UI fill is priced, which is what the lane will send. `draft` is the\n * node's Seedance Draft toggle (priced at 480p).\n */\nexport function seedanceVideoEditCreditId(provider: string, resolution?: string, draft?: boolean): string {\n return videoGenerationCreditId({\n provider,\n duration: VIDEO_DURATION_AUTO,\n nodeType: \"text-to-video\",\n resolution,\n draft,\n hasVideoRef: true,\n })\n}\n\n/** What the video credit identifier PRICES for a request, for the levers whose\n * priced value must also be the value we SEND. */\nexport interface PricedVideoSelection {\n /** The resolution band the reservation is priced at when the request omitted\n * one — and only where the platform DECLARES that band as the provider's own\n * default. `undefined` means \"leave `resolution` exactly as the request had\n * it\": either the caller supplied one, or the provider's real default is not\n * known to be the band the identifier assumes. */\n resolution?: string\n /** The length the reservation is priced at and the wire carries, for a\n * provider whose price follows the clip length (LTX's seeded tier, the KIE\n * ladders, Gemini Omni). `undefined` for every other provider, and for Auto:\n * their duration passes through. */\n duration?: number\n /** Non-empty only for a lever the caller ASKED for and did not get (a 7s\n * request snapped to the 6s tier). Filling an omitted lever is a disclosure of\n * the price already being charged, not a correction, so it reports nothing. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The other half of the video money path: `normalizeVideoRequestParams` snaps a\n * value the CATALOG governs; this returns the value the PRICE ladder governs.\n *\n * Two defects it closes, both of the same shape — the identifier prices one\n * thing and the wire carries another, and `commit_credits` (migration 176) only\n * ever refunds a surplus, so the reservation is the final charge:\n *\n * 1. **Absent resolution.** `buildVideoCreditModelIdentifier` prices an omitted\n * `resolution` as a concrete band (LTX → 1080p; a\n * {@link PRICING_DEFAULT_RESOLUTION} member → its declared default). Leaving\n * the key unset then lets the provider pick — documented for the KIE members\n * (their `extraParams` pin the same band) but UNDOCUMENTED for LTX on\n * Replicate. Sending the band we priced makes the two agree by construction.\n *\n * The fill is deliberately limited to providers with a DECLARED default.\n * `buildVideoCreditModelIdentifier` also has un-declared fallbacks — the\n * cheapest tier for a resolution-priced provider with no\n * `PRICING_DEFAULT_RESOLUTION` row — and those are a HEDGE, not a verified\n * provider default: seedance-2 / -fast / -mini pin `resolution: \"720p\"`\n * KIE-side while the identifier prices 480p, so filling 480p would downgrade\n * the render to match a price we already know is wrong. That mismatch is a\n * pre-existing identifier bug and is fixed by seeding the row, not here.\n *\n * 2. **Duration.** Every provider whose price follows the clip length is\n * charged at the length it RENDERS: its own default when the request named\n * none (catalog `defaultDuration`), the nearest length it offers otherwise\n * (`pricedOutputDurationSec` — the runners' own snap rule). The LTX ladder is\n * seeded per (band × seconds), so a 7s request snaps onto the 6s tier;\n * sending 7s would bill six and render seven. The same value is returned for\n * the other length-priced providers (the KIE ladders, Gemini Omni), so what\n * is priced is what is sent. Auto (-1) is the model's call and is untouched.\n *\n * Pure, and IDEMPOTENT against the identifier: feeding its output back in\n * cannot move the reserved tier. `video-request-normalize.test.ts` proves that\n * over every provider × resolution × duration.\n */\nexport function pricedVideoSelection(opts: {\n provider: string\n resolution?: string\n duration?: number | string\n}): PricedVideoSelection {\n const adjustments: ModelInputAdjustment[] = []\n const ltx = ltxPricedTier(opts.provider, opts.resolution, opts.duration)\n\n // The band the request will be priced AND rendered at. An explicit value\n // always wins — this only ever fills an omission.\n const resolution = opts.resolution\n ?? (ltx ? ltx.band : PRICING_DEFAULT_RESOLUTION[opts.provider])\n\n const requested = typeof opts.duration === \"string\" ? parseInt(opts.duration, 10) : opts.duration\n const asked = requested !== undefined && !Number.isNaN(requested)\n\n // Every provider whose price follows the clip length sends the length it is\n // CHARGED at (the catalog funnel: its own default when unset, the nearest\n // legal length otherwise). Auto (-1) is the model's call and is left alone.\n const lengthPriced = !!ltx || DURATION_PRICED_PROVIDERS.has(opts.provider) || isGeminiOmniProvider(opts.provider)\n if (!lengthPriced || (!ltx && asked && requested! <= 0)) return { resolution, adjustments }\n\n const duration = ltx ? ltx.duration : pricedOutputDurationSec(opts.provider, opts.duration)\n if (asked && requested !== duration) {\n adjustments.push({\n field: \"duration\",\n from: requested!,\n to: duration,\n reason: ltx\n ? `LTX renders ${ltx.band} in ${ltx.duration}s steps — using ${ltx.duration}s instead of ${requested}s.`\n : `${opts.provider} renders ${duration}s clips at the nearest length it offers — using ${duration}s instead of ${requested}s.`,\n })\n }\n return { resolution, duration, adjustments }\n}\n\n/**\n * Compute composite model identifier for motion control with duration-tiered pricing.\n * Examples: \"kling-3.0-motion:10s\", \"kling-3.0-motion:1080p:15s\", \"motion-transfer:5s\"\n *\n * Wan Animate providers use resolution-tiered pricing (not per-second):\n * \"wan-animate-move\" (480p default), \"wan-animate-move:580p\", \"wan-animate-move:720p\"\n *\n * @param provider - Motion control provider key (\"kling\" for 2.6, \"kling-3.0\", \"wan-animate-move\", \"wan-animate-replace\")\n * @param resolution - \"720p\" or \"1080p\" (Kling), \"480p\" or \"580p\" or \"720p\" (Wan Animate)\n * @param videoDuration - Reference video duration in seconds (defaults to 10s, unused for Wan Animate)\n */\nexport function buildMotionCreditModelIdentifier(\n provider: string,\n resolution: string,\n videoDuration?: number,\n): string {\n // Wan Animate providers use resolution-tiered pricing (not duration-based)\n if (provider === \"wan-animate-move\" || provider === \"wan-animate-replace\") {\n // 480p is the default (base identifier), 580p and 720p get composite suffix\n if (resolution === \"580p\" || resolution === \"720p\") {\n return `${provider}:${resolution}`\n }\n return provider\n }\n\n const raw = videoDuration ?? 10\n const durationSec = Math.floor(Number.isNaN(raw) ? 10 : raw) // default 10s; floor to match KIE per-second billing\n const tier = MOTION_DURATION_TIERS.find(t => durationSec <= t.maxSeconds)\n ?? MOTION_DURATION_TIERS[MOTION_DURATION_TIERS.length - 1]\n\n const base = provider === \"kling-3.0\" ? \"kling-3.0-motion\" : \"motion-transfer\"\n const resSuffix = resolution === \"1080p\" ? \":1080p\" : \"\"\n return `${base}${resSuffix}:${tier.suffix}`\n}\n\n/**\n * The Suno operations whose credit key depends on the model VERSION.\n *\n * `/v1/suno/generate`, `/cover` and `/extend` resolve their creditGuard\n * identifier through `sunoCreditType(model, <operation>)` (routes/suno.ts\n * :247-249, :335-337, :407-409). EVERY other Suno route charges a flat\n * per-operation key and ignores the version the node carries — mashup (:648),\n * add-instrumental (:852), add-vocals (:907), upload-extend (:1016),\n * replace-section (:710), style-boost (:771), convert-wav (:962),\n * lyrics (:482), music-video (:594), voice (:1218).\n *\n * Anything that QUOTES a Suno price — a dropdown row, a node badge, the\n * workflow-credit estimator — must follow the same split, or it displays a\n * credit key the route never charges.\n */\nexport const SUNO_VERSION_PRICED_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n] as const\n\n/**\n * The seven Suno operations that appear behind a select/dropdown UI (model\n * pickers, node badges, the credit estimator) — the three version-priced\n * operations above, plus the four flat-key operations exercised by\n * `sunoCreditType`'s own test suite. A readonly tuple so later tasks (the\n * model dropdowns, node badges) can iterate or count it without redeclaring\n * the list and drifting from this one.\n */\nexport const SUNO_SELECT_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-mashup\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-upload-extend\",\n] as const\n\n/**\n * Adjust Speed's price id: motion-compensated (\"smooth\") interpolation is its\n * own, dearer tier. The route, the workflow run, and the editor's badge and\n * run estimate all price through this, so none of them can quote the fast tier\n * for a smooth run.\n */\nexport function speedRampCreditId(quality: unknown): \"speed-ramp\" | \"speed-ramp:smooth\" {\n return quality === \"smooth\" ? \"speed-ramp:smooth\" : \"speed-ramp\"\n}\n\n/**\n * Apply EDL's price id: a `proxy` render (the 720p preview) is its own,\n * cheaper per-output-minute row; a `final` render keeps the bare id. One id per\n * QUALITY, for a video and an audio output alike (decided 2026-10-04). Anything\n * that is not exactly \"proxy\" is the final, as the route and the node default\n * it. The route, the workflow run, and the editor's badge and run estimate all\n * price through this; the job itself is always named `apply-edl`.\n */\nexport function applyEdlCreditId(quality: unknown): \"apply-edl\" | \"apply-edl:proxy\" {\n return quality === \"proxy\" ? \"apply-edl:proxy\" : \"apply-edl\"\n}\n\n/**\n * Speaker View's price tiers (decided 2026-10-10, C4): a render is priced by\n * how many speakers it composites at once. `standard` — at most two tiles on\n * any segment and no zoom; `complex` — three to six tiles, or any zoom. Which\n * tier a render is in is the render rule's to say (the app's\n * `@nodaro/render-rules`), never this vocabulary's.\n */\nexport const SPEAKER_VIEW_PRICE_TIERS = [\"standard\", \"complex\"] as const\nexport type SpeakerViewPriceTier = (typeof SPEAKER_VIEW_PRICE_TIERS)[number]\n\nexport type SpeakerViewCreditId = \"speaker-view\" | \"speaker-view:proxy\" | \"speaker-view:complex\" | \"speaker-view:complex:proxy\"\n\n/** Every id `speakerViewCreditId` can name. */\nexport const SPEAKER_VIEW_CREDIT_IDS: readonly SpeakerViewCreditId[] = Object.freeze([\n \"speaker-view\",\n \"speaker-view:proxy\",\n \"speaker-view:complex\",\n \"speaker-view:complex:proxy\",\n] as const)\n\n/**\n * The credit id of a Speaker View render (F4, decided 2026-09-23; tiers\n * decided 2026-10-10): a Preview (`quality` \"proxy\") reserves on its own row,\n * anything else on the final's, and each in its price tier — `standard` on\n * `speaker-view` / `speaker-view:proxy`, `complex` on `speaker-view:complex` /\n * `speaker-view:complex:proxy`. A tier that is not exactly `standard` (absent\n * included) names the `complex` row: a caller that cannot tell quotes high,\n * never low. The job is always named `speaker-view`; only its credit id\n * follows the quality and the tier.\n */\nexport function speakerViewCreditId(quality: unknown, tier?: unknown): SpeakerViewCreditId {\n const proxy = quality === \"proxy\"\n if (tier === \"standard\") return proxy ? \"speaker-view:proxy\" : \"speaker-view\"\n return proxy ? \"speaker-view:complex:proxy\" : \"speaker-view:complex\"\n}\n\n/**\n * OUR Nodaro credit key for a Suno operation, given the model version and the\n * operation (which is also the node type and the BullMQ job name).\n *\n * This is the single source of truth for the Suno pricing contract, shared by\n * the reservation path (routes/suno.ts creditGuard), the egress seam\n * (workers/handlers/suno.ts `modelKey`, which must match what was reserved),\n * both workflow-credit estimators (ee/billing/credits.ts and the frontend\n * config-panels/helpers.ts), the seven Suno model dropdowns and the three Suno\n * node badges. It is a billing key — NEVER a KIE provider id — which is what\n * satisfies the B3 egress invariant.\n *\n * The version → key map is {@link SUNO_VERSION_CREDIT_KEYS}; a version with no\n * entry (V4 / V4_5 / V4_5ALL / V4_5PLUS) falls back to the operation key, and a\n * non-version-priced operation is returned unchanged.\n */\nexport function sunoCreditType(model: string | undefined, operation: string): string {\n if (!(SUNO_VERSION_PRICED_OPERATIONS as readonly string[]).includes(operation)) {\n return operation\n }\n return (model && SUNO_VERSION_CREDIT_KEYS[model]) || operation\n}\n\n/**\n * Suno version → Nodaro credit key for the version-priced operations. One row\n * per version that has its own `model_pricing` row / `STATIC_CREDIT_COSTS`\n * entry / `MODEL_CATALOG` pricing row, so an admin can reprice one version\n * without touching code. Every ACTIVE version MUST have a row here — guarded\n * by `__tests__/suno-credit-type.test.ts` (a new active version with no key\n * would silently bill at the operation key).\n */\nexport const SUNO_VERSION_CREDIT_KEYS: Readonly<Record<string, string>> = {\n V6: \"suno-v6\",\n V6_WILD: \"suno-v6_wild\",\n V6_MINI: \"suno-v6_mini\",\n V5_5: \"suno-v5_5\",\n V5: \"suno-v5\",\n}\n"]}