@nodaro/shared 3.61.0 → 3.62.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 (254) hide show
  1. package/dist/{chunk-IVXSNW2B.cjs → chunk-2D5LQFV4.cjs} +18 -332
  2. package/dist/chunk-2D5LQFV4.cjs.map +1 -0
  3. package/dist/{chunk-XUJC6GHE.cjs → chunk-2HZGDZZN.cjs} +6 -6
  4. package/dist/{chunk-XUJC6GHE.cjs.map → chunk-2HZGDZZN.cjs.map} +1 -1
  5. package/dist/{chunk-43TGSZRJ.js → chunk-2QKF7M2Z.js} +3 -3
  6. package/dist/{chunk-43TGSZRJ.js.map → chunk-2QKF7M2Z.js.map} +1 -1
  7. package/dist/{chunk-7ARKVJTN.cjs → chunk-2W745U4A.cjs} +228 -355
  8. package/dist/chunk-2W745U4A.cjs.map +1 -0
  9. package/dist/{chunk-673E4KYC.js → chunk-3OYO3XCC.js} +70 -6
  10. package/dist/chunk-3OYO3XCC.js.map +1 -0
  11. package/dist/{chunk-FMXFHJWX.cjs → chunk-4ZEFP2FQ.cjs} +4 -4
  12. package/dist/{chunk-FMXFHJWX.cjs.map → chunk-4ZEFP2FQ.cjs.map} +1 -1
  13. package/dist/{chunk-A3FHTSLB.js → chunk-5YYN5X57.js} +302 -27
  14. package/dist/chunk-5YYN5X57.js.map +1 -0
  15. package/dist/{chunk-4KYLNTR7.cjs → chunk-6CSXMWL4.cjs} +4 -4
  16. package/dist/{chunk-4KYLNTR7.cjs.map → chunk-6CSXMWL4.cjs.map} +1 -1
  17. package/dist/{chunk-M3SXUUWC.cjs → chunk-6FQBKI2A.cjs} +4 -11
  18. package/dist/chunk-6FQBKI2A.cjs.map +1 -0
  19. package/dist/{chunk-G4XWVWRI.js → chunk-6G7NN4S4.js} +5 -4
  20. package/dist/chunk-6G7NN4S4.js.map +1 -0
  21. package/dist/{chunk-ZFJN23V4.cjs → chunk-A2PX5IRC.cjs} +4 -4
  22. package/dist/{chunk-ZFJN23V4.cjs.map → chunk-A2PX5IRC.cjs.map} +1 -1
  23. package/dist/{chunk-JHTT2V4A.cjs → chunk-AFYTX4AI.cjs} +52 -43
  24. package/dist/chunk-AFYTX4AI.cjs.map +1 -0
  25. package/dist/chunk-ALRXY4QH.cjs +13 -0
  26. package/dist/chunk-ALRXY4QH.cjs.map +1 -0
  27. package/dist/chunk-AOJ6B7K4.cjs +351 -0
  28. package/dist/chunk-AOJ6B7K4.cjs.map +1 -0
  29. package/dist/{chunk-ZDBPQBAA.js → chunk-C7POAYFE.js} +3 -3
  30. package/dist/{chunk-ZDBPQBAA.js.map → chunk-C7POAYFE.js.map} +1 -1
  31. package/dist/{chunk-B6BG3LV2.js → chunk-CC4V2B7S.js} +3 -3
  32. package/dist/{chunk-B6BG3LV2.js.map → chunk-CC4V2B7S.js.map} +1 -1
  33. package/dist/{chunk-XZKFZMRT.cjs → chunk-CIPPPT7E.cjs} +6 -6
  34. package/dist/{chunk-XZKFZMRT.cjs.map → chunk-CIPPPT7E.cjs.map} +1 -1
  35. package/dist/{chunk-6XVHYD5R.js → chunk-CLAKSLXF.js} +4 -9
  36. package/dist/chunk-CLAKSLXF.js.map +1 -0
  37. package/dist/chunk-CTANEPMY.js +61 -0
  38. package/dist/chunk-CTANEPMY.js.map +1 -0
  39. package/dist/{chunk-WGKAOUEQ.cjs → chunk-D34K455O.cjs} +3 -2
  40. package/dist/chunk-D34K455O.cjs.map +1 -0
  41. package/dist/chunk-E2HZTGYX.js +331 -0
  42. package/dist/chunk-E2HZTGYX.js.map +1 -0
  43. package/dist/{chunk-RQ4F3AJH.cjs → chunk-G3KVK7OU.cjs} +21 -21
  44. package/dist/{chunk-RQ4F3AJH.cjs.map → chunk-G3KVK7OU.cjs.map} +1 -1
  45. package/dist/chunk-G4U3HW6W.js +453 -0
  46. package/dist/chunk-G4U3HW6W.js.map +1 -0
  47. package/dist/{chunk-IRQ3SPX7.js → chunk-GSFB537T.js} +3 -3
  48. package/dist/{chunk-IRQ3SPX7.js.map → chunk-GSFB537T.js.map} +1 -1
  49. package/dist/chunk-HRY7KGAE.cjs +506 -0
  50. package/dist/chunk-HRY7KGAE.cjs.map +1 -0
  51. package/dist/{chunk-VOWJCUMR.js → chunk-I2RQB7VG.js} +3 -3
  52. package/dist/{chunk-VOWJCUMR.js.map → chunk-I2RQB7VG.js.map} +1 -1
  53. package/dist/chunk-IDTKF5EX.cjs +48 -0
  54. package/dist/chunk-IDTKF5EX.cjs.map +1 -0
  55. package/dist/{chunk-5XRRENHD.cjs → chunk-IWWVPR3W.cjs} +88 -11
  56. package/dist/chunk-IWWVPR3W.cjs.map +1 -0
  57. package/dist/{chunk-SCMTN57Y.js → chunk-JJNNM23P.js} +3 -3
  58. package/dist/{chunk-SCMTN57Y.js.map → chunk-JJNNM23P.js.map} +1 -1
  59. package/dist/{chunk-ZZGQRRN7.js → chunk-JZGZ26YB.js} +6 -306
  60. package/dist/chunk-JZGZ26YB.js.map +1 -0
  61. package/dist/{chunk-XROE3CAS.cjs → chunk-KHH54GRP.cjs} +120 -79
  62. package/dist/chunk-KHH54GRP.cjs.map +1 -0
  63. package/dist/{chunk-NJVOJXBS.cjs → chunk-KJSRPHJ2.cjs} +48 -47
  64. package/dist/chunk-KJSRPHJ2.cjs.map +1 -0
  65. package/dist/{chunk-FVVD6XY2.js → chunk-KL6GAYTT.js} +13 -4
  66. package/dist/chunk-KL6GAYTT.js.map +1 -0
  67. package/dist/{chunk-AFQFGZN7.cjs → chunk-KYMHFVAZ.cjs} +8 -6
  68. package/dist/chunk-KYMHFVAZ.cjs.map +1 -0
  69. package/dist/{chunk-F5YEMSNK.cjs → chunk-MYJQELFN.cjs} +320 -26
  70. package/dist/chunk-MYJQELFN.cjs.map +1 -0
  71. package/dist/chunk-N5HH46JF.cjs +68 -0
  72. package/dist/chunk-N5HH46JF.cjs.map +1 -0
  73. package/dist/{chunk-MQZRQ5LM.cjs → chunk-N7OUQK7E.cjs} +8 -8
  74. package/dist/{chunk-MQZRQ5LM.cjs.map → chunk-N7OUQK7E.cjs.map} +1 -1
  75. package/dist/{chunk-UARGJ5IZ.js → chunk-NGKKNSK6.js} +30 -7
  76. package/dist/chunk-NGKKNSK6.js.map +1 -0
  77. package/dist/{chunk-SWVGHAYO.js → chunk-O7RZRUMZ.js} +110 -74
  78. package/dist/chunk-O7RZRUMZ.js.map +1 -0
  79. package/dist/{chunk-C77F4ZTL.js → chunk-PTD6EDUU.js} +3 -3
  80. package/dist/{chunk-C77F4ZTL.js.map → chunk-PTD6EDUU.js.map} +1 -1
  81. package/dist/{chunk-ZNM2LW3D.cjs → chunk-QWYFHQYK.cjs} +78 -53
  82. package/dist/chunk-QWYFHQYK.cjs.map +1 -0
  83. package/dist/{chunk-VB2ARGQ6.js → chunk-RGNHHIMN.js} +3 -3
  84. package/dist/chunk-RGNHHIMN.js.map +1 -0
  85. package/dist/{chunk-MOMFX32D.js → chunk-S24ZBUB4.js} +194 -299
  86. package/dist/chunk-S24ZBUB4.js.map +1 -0
  87. package/dist/{chunk-EWS2VFO4.js → chunk-S5TMRJMX.js} +4 -4
  88. package/dist/{chunk-EWS2VFO4.js.map → chunk-S5TMRJMX.js.map} +1 -1
  89. package/dist/chunk-SMOO5FAH.js +10 -0
  90. package/dist/chunk-SMOO5FAH.js.map +1 -0
  91. package/dist/{chunk-RUHKBEFF.js → chunk-SYWR5G3T.js} +16 -7
  92. package/dist/chunk-SYWR5G3T.js.map +1 -0
  93. package/dist/{chunk-FQXRYPCX.cjs → chunk-TRVWMKNE.cjs} +337 -52
  94. package/dist/chunk-TRVWMKNE.cjs.map +1 -0
  95. package/dist/{chunk-LLOIAGFB.js → chunk-UDDVDQMF.js} +292 -35
  96. package/dist/chunk-UDDVDQMF.js.map +1 -0
  97. package/dist/{chunk-PONP5J5E.cjs → chunk-V24EPI5N.cjs} +13 -3
  98. package/dist/chunk-V24EPI5N.cjs.map +1 -0
  99. package/dist/{chunk-5I4T4QR5.cjs → chunk-VACPZPUA.cjs} +5 -5
  100. package/dist/{chunk-5I4T4QR5.cjs.map → chunk-VACPZPUA.cjs.map} +1 -1
  101. package/dist/{chunk-HGI2VKIV.js → chunk-Y6X7UJSD.js} +10 -9
  102. package/dist/chunk-Y6X7UJSD.js.map +1 -0
  103. package/dist/chunk-YCXRSWCQ.js +42 -0
  104. package/dist/chunk-YCXRSWCQ.js.map +1 -0
  105. package/dist/entries/apps.cjs +44 -44
  106. package/dist/entries/apps.js +9 -9
  107. package/dist/entries/credits.cjs +217 -152
  108. package/dist/entries/credits.d.cts +105 -3
  109. package/dist/entries/credits.d.ts +105 -3
  110. package/dist/entries/credits.js +13 -8
  111. package/dist/entries/entities.cjs +188 -143
  112. package/dist/entries/entities.d.cts +122 -1
  113. package/dist/entries/entities.d.ts +122 -1
  114. package/dist/entries/entities.js +2 -1
  115. package/dist/entries/llm-models.d.cts +2 -1
  116. package/dist/entries/llm-models.d.ts +2 -1
  117. package/dist/entries/media.cjs +92 -87
  118. package/dist/entries/media.d.cts +11 -1
  119. package/dist/entries/media.d.ts +11 -1
  120. package/dist/entries/media.js +3 -2
  121. package/dist/entries/model-catalog.cjs +195 -103
  122. package/dist/entries/model-catalog.d.cts +90 -4
  123. package/dist/entries/model-catalog.d.ts +90 -4
  124. package/dist/entries/model-catalog.js +5 -5
  125. package/dist/entries/models.cjs +407 -294
  126. package/dist/entries/models.d.cts +4 -3
  127. package/dist/entries/models.d.ts +4 -3
  128. package/dist/entries/models.js +6 -5
  129. package/dist/entries/nodes.cjs +241 -233
  130. package/dist/entries/nodes.d.cts +15 -2
  131. package/dist/entries/nodes.d.ts +15 -2
  132. package/dist/entries/nodes.js +10 -10
  133. package/dist/entries/pipeline.cjs +152 -152
  134. package/dist/entries/pipeline.d.cts +2 -1
  135. package/dist/entries/pipeline.d.ts +2 -1
  136. package/dist/entries/pipeline.js +3 -3
  137. package/dist/entries/ugc.cjs +71 -71
  138. package/dist/entries/ugc.js +4 -4
  139. package/dist/entries/video.cjs +308 -204
  140. package/dist/entries/video.d.cts +480 -98
  141. package/dist/entries/video.d.ts +480 -98
  142. package/dist/entries/video.js +8 -4
  143. package/dist/entries/workflow.cjs +102 -102
  144. package/dist/entries/workflow.d.cts +5 -4
  145. package/dist/entries/workflow.d.ts +5 -4
  146. package/dist/entries/workflow.js +2 -2
  147. package/dist/{gpt-image-2-6-BeZdT-pW.d.cts → gpt-image-2-6-jIRQBRag.d.cts} +6 -0
  148. package/dist/{gpt-image-2-6-BeZdT-pW.d.ts → gpt-image-2-6-jIRQBRag.d.ts} +6 -0
  149. package/dist/index.cjs +2309 -1886
  150. package/dist/index.d.cts +9 -9
  151. package/dist/index.d.ts +9 -9
  152. package/dist/index.js +26 -23
  153. package/dist/{model-catalog-BgSvskgY.d.cts → model-catalog-CCEcv08q.d.cts} +128 -14
  154. package/dist/{model-catalog-BgSvskgY.d.ts → model-catalog-CCEcv08q.d.ts} +128 -14
  155. package/dist/{model-constants-DHd9jwQ7.d.ts → model-constants-B88p6XR0.d.ts} +299 -19
  156. package/dist/{model-constants-DHd9jwQ7.d.cts → model-constants-Cf3zaITt.d.cts} +299 -19
  157. package/package.json +1 -1
  158. package/src/__tests__/extend-providers.test.ts +114 -0
  159. package/src/__tests__/fixtures/mask-composite-quote-parity.json +118 -0
  160. package/src/__tests__/fixtures/root-exports.baseline.json +68 -0
  161. package/src/__tests__/gpt-image-2-6-formats.test.ts +4 -1
  162. package/src/__tests__/grok-video-15-catalog.test.ts +189 -0
  163. package/src/__tests__/gvp-supported-providers.test.ts +5 -2
  164. package/src/__tests__/minimax-h3-image.test.ts +140 -0
  165. package/src/__tests__/model-makers.test.ts +49 -11
  166. package/src/__tests__/model-tree.test.ts +13 -0
  167. package/src/__tests__/retired-video-provider.test.ts +15 -5
  168. package/src/__tests__/seedance-25-catalog-modes.test.ts +1 -1
  169. package/src/__tests__/seedance-task-type.test.ts +178 -0
  170. package/src/__tests__/seedream-5-5.test.ts +117 -0
  171. package/src/__tests__/unit-contract-compose.test.ts +27 -1
  172. package/src/__tests__/unit-contracts.test.ts +20 -6
  173. package/src/__tests__/upscale-factors.test.ts +107 -0
  174. package/src/__tests__/video-character-refs.test.ts +20 -2
  175. package/src/__tests__/video-collapse-parity.test.ts +19 -0
  176. package/src/__tests__/video-overlay-geometry.test.ts +68 -0
  177. package/src/__tests__/video-overlay-layer-plan.test.ts +3 -4
  178. package/src/__tests__/video-overlay-layouts.test.ts +529 -0
  179. package/src/__tests__/video-overlay-pricing.test.ts +61 -0
  180. package/src/__tests__/video-overlay-validate.test.ts +128 -0
  181. package/src/__tests__/video-overlay-wired-kind.test.ts +207 -0
  182. package/src/__tests__/video-overlay.test.ts +280 -194
  183. package/src/__tests__/video-ref-limits.test.ts +2 -1
  184. package/src/__tests__/video-reference-only.test.ts +6 -2
  185. package/src/__tests__/video-start-frame-only.test.ts +98 -0
  186. package/src/__tests__/wired-character-names.test.ts +220 -0
  187. package/src/credit-estimators/index.ts +8 -0
  188. package/src/credit-estimators/video-overlay.ts +70 -0
  189. package/src/credit-identifiers.ts +94 -1
  190. package/src/entity-image-url.ts +21 -0
  191. package/src/entries/credits.ts +14 -0
  192. package/src/entries/entities.ts +14 -0
  193. package/src/entries/model-catalog.ts +35 -1
  194. package/src/entries/models.ts +34 -0
  195. package/src/entries/nodes.ts +2 -0
  196. package/src/entries/video.ts +6 -0
  197. package/src/generated/unit-contracts.ts +8 -1
  198. package/src/gpt-image-2-6.ts +6 -0
  199. package/src/input-image-pricing.ts +76 -0
  200. package/src/mask-composite.ts +11 -0
  201. package/src/minimax-h3-image.ts +61 -0
  202. package/src/model-catalog.ts +355 -37
  203. package/src/model-constants.ts +590 -32
  204. package/src/node-default-mappings.ts +12 -2
  205. package/src/node-execution-state.ts +4 -3
  206. package/src/producer-types.ts +23 -1
  207. package/src/seedance-task-type.ts +37 -0
  208. package/src/seedream-5-5.ts +45 -0
  209. package/src/unit-contract-compose.ts +4 -1
  210. package/src/upscale-factors.ts +111 -0
  211. package/src/video-character-refs.ts +7 -4
  212. package/src/video-overlay-geometry.ts +99 -0
  213. package/src/video-overlay-input.ts +25 -0
  214. package/src/video-overlay-layout-ids.ts +48 -0
  215. package/src/video-overlay-layouts.ts +315 -0
  216. package/src/video-overlay-validate.ts +223 -0
  217. package/src/video-overlay-video-layers.ts +304 -0
  218. package/src/video-overlay.ts +165 -297
  219. package/src/video-ui-defaults.ts +8 -6
  220. package/src/wired-character-names.ts +202 -0
  221. package/dist/chunk-5XRRENHD.cjs.map +0 -1
  222. package/dist/chunk-673E4KYC.js.map +0 -1
  223. package/dist/chunk-6XVHYD5R.js.map +0 -1
  224. package/dist/chunk-7ARKVJTN.cjs.map +0 -1
  225. package/dist/chunk-7WGKP3EU.js +0 -23
  226. package/dist/chunk-7WGKP3EU.js.map +0 -1
  227. package/dist/chunk-A3FHTSLB.js.map +0 -1
  228. package/dist/chunk-AFQFGZN7.cjs.map +0 -1
  229. package/dist/chunk-F5YEMSNK.cjs.map +0 -1
  230. package/dist/chunk-FQXRYPCX.cjs.map +0 -1
  231. package/dist/chunk-FVVD6XY2.js.map +0 -1
  232. package/dist/chunk-G4XWVWRI.js.map +0 -1
  233. package/dist/chunk-HGI2VKIV.js.map +0 -1
  234. package/dist/chunk-IVXSNW2B.cjs.map +0 -1
  235. package/dist/chunk-JHTT2V4A.cjs.map +0 -1
  236. package/dist/chunk-KHZAQGRP.js +0 -17
  237. package/dist/chunk-KHZAQGRP.js.map +0 -1
  238. package/dist/chunk-LLOIAGFB.js.map +0 -1
  239. package/dist/chunk-M3SXUUWC.cjs.map +0 -1
  240. package/dist/chunk-MOMFX32D.js.map +0 -1
  241. package/dist/chunk-NCOGGRRP.cjs +0 -27
  242. package/dist/chunk-NCOGGRRP.cjs.map +0 -1
  243. package/dist/chunk-NJVOJXBS.cjs.map +0 -1
  244. package/dist/chunk-PONP5J5E.cjs.map +0 -1
  245. package/dist/chunk-RUHKBEFF.js.map +0 -1
  246. package/dist/chunk-SWVGHAYO.js.map +0 -1
  247. package/dist/chunk-UARGJ5IZ.js.map +0 -1
  248. package/dist/chunk-VB2ARGQ6.js.map +0 -1
  249. package/dist/chunk-WGKAOUEQ.cjs.map +0 -1
  250. package/dist/chunk-XROE3CAS.cjs.map +0 -1
  251. package/dist/chunk-ZLDFPVVI.cjs +0 -19
  252. package/dist/chunk-ZLDFPVVI.cjs.map +0 -1
  253. package/dist/chunk-ZNM2LW3D.cjs.map +0 -1
  254. package/dist/chunk-ZZGQRRN7.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/video-overlay-video-layers.ts","../src/video-overlay-input.ts","../src/video-overlay.ts"],"names":["DYNAMIC_PRODUCER_TYPES","VIDEO_PRODUCER_TYPES","IMAGE_PRODUCER_TYPES","resolveEffectiveSourceType"],"mappings":";;;;;;AAgBA,IAAM,sBAAA,GAAyB,CAAC,MAAA,EAAQ,MAAA,EAAQ,SAAS,MAAM,CAAA;AAE/D,IAAM,sBAAA,GAAyB,CAAC,MAAA,EAAQ,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAS,MAAA,EAAQ,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAS,SAAS,MAAM,CAAA;AAG7H,SAAS,yBAAyB,KAAA,EAAyB;AAChE,EAAA,IAAI,KAAA,KAAU,QAAQ,OAAO,KAAA,KAAU,YAAY,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG,OAAO,KAAA;AAChF,EAAA,MAAM,MAAO,KAAA,CAAiC,QAAA;AAC9C,EAAA,OAAO,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,CAAI,MAAA,GAAS,CAAA;AACjD;AAGO,SAAS,0BACd,MAAA,EACS;AACT,EAAA,OAAO,MAAM,OAAA,CAAQ,MAAM,CAAA,IAAK,MAAA,CAAO,KAAK,wBAAwB,CAAA;AACtE;AAGA,SAAS,UAAU,GAAA,EAAqB;AACtC,EAAA,IAAI;AACF,IAAA,OAAO,IAAI,GAAA,CAAI,GAAG,CAA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A,EAAW,KAAA,CAAM,IAAA,CAAK,EAAE,OAAA,EAAS,CAAA,CAAE,IAAA,CAAK,OAAA,EAAS,QAAQ,CAAA;AAIlG,EAAA,MAAM,aAAa,CAAC,GAAG,IAAI,GAAA,CAAI,EAAE,UAAA,IAAc,EAAE,CAAC,EAAE,IAAA,CAAK,CAAC,CAAA,EAAG,CAAA,KAAM,IAAI,CAAC,CAAA;AACxE,EAAA,IAAI,WAAW,MAAA,GAAS,CAAA,QAAS,IAAA,CAAK,EAAE,YAAY,CAAA;AACpD,EAAA,OAAO,IAAA,CAAK,SAAA,CAAU,cAAA,CAAe,KAAK,CAAC,CAAA;AAC7C","file":"chunk-HRY7KGAE.cjs","sourcesContent":["/**\n * Video Overlay video layers — what makes a layer a video, and what kind of\n * layer a wired source becomes. A sibling of `video-overlay.ts`, which imports\n * from here at run time; this file imports from it for TYPES only, so the\n * dependency stays one-way.\n *\n * A layer is a video layer when it carries a non-empty `videoUrl`: the\n * validator's count, the `animate` default and `videoOverlayHasVideoLayer`\n * all read it through `isVideoOverlayVideoLayer`, so they cannot disagree.\n * Wire contract only — no I/O.\n */\nimport type { VideoOverlayLayerInput } from \"./video-overlay.js\"\nimport { DYNAMIC_PRODUCER_TYPES, IMAGE_PRODUCER_TYPES, VIDEO_PRODUCER_TYPES } from \"./producer-types.js\"\nimport { resolveEffectiveSourceType } from \"./entity-image-handle.js\"\n\n/** File extensions a wired source from a node of no fixed kind is read as a video by. */\nconst LAYER_VIDEO_EXTENSIONS = [\".mp4\", \".mov\", \".webm\", \".m4v\"] as const\n/** File extensions it is read as an image by (a recognisable image stays an image, whatever a List column says). */\nconst LAYER_IMAGE_EXTENSIONS = [\".png\", \".jpg\", \".jpeg\", \".webp\", \".gif\", \".avif\", \".bmp\", \".tif\", \".tiff\", \".heic\", \".heif\", \".svg\"] as const\n\n/** True when the layer is a plain object with a non-empty `videoUrl`. */\nexport function isVideoOverlayVideoLayer(layer: unknown): boolean {\n if (layer === null || typeof layer !== \"object\" || Array.isArray(layer)) return false\n const url = (layer as VideoOverlayLayerInput).videoUrl\n return typeof url === \"string\" && url.length > 0\n}\n\n/** True when any layer is a video layer. Non-array input and non-object entries read as none. */\nexport function videoOverlayHasVideoLayer(\n layers: ReadonlyArray<VideoOverlayLayerInput | null | undefined> | null | undefined,\n): boolean {\n return Array.isArray(layers) && layers.some(isVideoOverlayVideoLayer)\n}\n\n/** The URL's path, lower-cased, without query or fragment; a relative or unparseable URL is cut at `?` / `#`. */\nfunction lowerPath(url: string): string {\n try {\n return new URL(url).pathname.toLowerCase()\n } catch {\n return url.split(/[?#]/, 1)[0]!.toLowerCase()\n }\n}\n\nexport type VideoOverlayWiredLayerKind = \"image\" | \"video\"\n\n/** The wire a layer handle receives, as both engines' resolvers know it. */\nexport interface VideoOverlayWiredSource {\n /** The source node's type. */\n readonly type?: string | null\n /** The source handle the wire leaves (through any teleport). */\n readonly handle?: string | null\n /** The medium the source declares for that handle — a component's or sub-workflow's port (`declaredOutputMediaType`). */\n readonly declaredMediaType?: string | null\n /**\n * The medium a List column's type declares for that handle\n * (`listColumnMediaType`). It ranks BELOW the URL's extension: it only fills\n * the gap for a link with no recognisable one.\n */\n readonly columnMediaType?: string | null\n}\n\n/**\n * Pips whose medium the shared effective-type tables (`resolveEffectiveSourceType`)\n * do not name, kept here so the layer rule reads them without changing how\n * those tables route or validate a wire. 3D Render Pro sits in both producer\n * sets: its `stills` pip carries one PNG per shot, its `video` pip the MP4.\n * The dynamic producers hand on a video or an audio file by pip: their video\n * pips are videos whatever their file's name. A frontend guard holds every\n * image or video pip the editor draws, that a layer handle accepts, to its own\n * medium with an extension-less URL.\n */\nconst LAYER_PIP_KINDS: Readonly<Record<string, Readonly<Record<string, VideoOverlayWiredLayerKind>>>> = {\n \"pro-3d-render\": { stills: \"image\", video: \"video\" },\n \"adjust-volume\": { \"video-out\": \"video\" },\n \"pitch-tempo\": { \"video-out\": \"video\" },\n \"voice-changer\": { video: \"video\" },\n \"voice-changer-pro\": { video: \"video\" },\n dubbing: { video: \"video\" },\n \"split-media\": { video: \"video\" },\n}\n\n/**\n * Layer-plan pips whose plan carries layers of one medium only, so a run\n * estimate can price the node they feed before the plan exists: UGC Cards'\n * plan is its card images. On the `layerPlan` handle nothing else answers\n * `image` before the run (`videoOverlayWireMediumBeforeRun`).\n */\nconst LAYER_PLAN_PIP_KINDS: Readonly<Record<string, Readonly<Record<string, VideoOverlayWiredLayerKind>>>> = {\n \"ugc-cards\": { layerPlan: \"image\" },\n}\n\nconst ownKey = <T>(table: Readonly<Record<string, T>>, key: string): T | undefined => (Object.hasOwn(table, key) ? table[key] : undefined)\n\n/** The kind of a single-medium producer: in exactly one of the image and video producer sets, and not dynamic. */\nfunction producerKind(type: string): VideoOverlayWiredLayerKind | undefined {\n if (DYNAMIC_PRODUCER_TYPES.has(type)) return undefined\n const video = VIDEO_PRODUCER_TYPES.has(type)\n if (video === IMAGE_PRODUCER_TYPES.has(type)) return undefined\n return video ? \"video\" : \"image\"\n}\n\n/**\n * What a source wired to a layer handle draws as — the ONE rule both engines\n * call, in this order:\n * 1. the medium the wire is known to carry: a pip row of its own\n * (`LAYER_PIP_KINDS`), the medium a port declares (`declaredMediaType`:\n * `image` or `video`), or the source's effective type for that handle\n * (an aggregate lane, a scraper's typed pip, an entity's or an output's\n * image pip — `resolveEffectiveSourceType`) when that is a single-medium producer;\n * 2. the producer sets, for a single-medium producer only;\n * 3. the URL path's extension, when it is a recognisable video or image one\n * (a list, a sub-workflow, a producer in both sets);\n * 4. a List column's declared type (`columnMediaType`: `image` or `video`),\n * for a link with no recognisable extension — so a `.png` in a\n * `video-url` column stays an image, as it was before video layers;\n * 5. an image, as every layer was before video layers existed.\n */\nexport function videoOverlayWiredLayerKind(source: VideoOverlayWiredSource, url: string): VideoOverlayWiredLayerKind {\n return kindOfSource(source) ?? kindOfFile(source, url)\n}\n\n/** Steps 3–5 of {@link videoOverlayWiredLayerKind}: what the file says, for a source that does not decide by itself. */\nfunction kindOfFile(source: VideoOverlayWiredSource, url: string): VideoOverlayWiredLayerKind {\n const column = source.columnMediaType === \"image\" || source.columnMediaType === \"video\" ? source.columnMediaType : undefined\n return kindOfUrl(url) ?? column ?? \"image\"\n}\n\n/** Steps 1–2 of {@link videoOverlayWiredLayerKind}: the kind the source decides by itself, or undefined when its file decides. */\nfunction kindOfSource(source: VideoOverlayWiredSource): VideoOverlayWiredLayerKind | undefined {\n const type = source.type ?? \"\"\n const handle = source.handle ?? undefined\n const pip = pipRowKind(LAYER_PIP_KINDS, source)\n if (pip) return pip\n if (source.declaredMediaType === \"image\" || source.declaredMediaType === \"video\") return source.declaredMediaType\n const effective = resolveEffectiveSourceType(type, handle)\n const carried = effective !== type ? producerKind(effective) : undefined\n if (carried) return carried\n return producerKind(type)\n}\n\n/** Step 3: the URL path's recognisable extension, or undefined. */\nfunction kindOfUrl(url: string): VideoOverlayWiredLayerKind | undefined {\n const path = lowerPath(url)\n if (LAYER_VIDEO_EXTENSIONS.some((ext) => path.endsWith(ext))) return \"video\"\n if (LAYER_IMAGE_EXTENSIONS.some((ext) => path.endsWith(ext))) return \"image\"\n return undefined\n}\n\n/** What a wire hands a Video Overlay before the run: an image, a video, or not known yet. */\nexport type VideoOverlayWireMedium = VideoOverlayWiredLayerKind | \"unknown\"\n\n/** Where a wire lands on a Video Overlay: a layer handle, or the `layerPlan` handle. */\nexport interface VideoOverlayWireBeforeRun {\n /** Default `layer`. */\n readonly target?: \"layer\" | \"plan\"\n /** A layer wire's files already known before the run (a List's own cells); none = not known. */\n readonly knownUrls?: readonly string[]\n}\n\n/**\n * What a source wired to a Video Overlay hands it, as far as it is known\n * BEFORE the run: the ONE place a run estimate asks.\n *\n * On a layer handle, by the run's own rule ({@link videoOverlayWiredLayerKind}):\n * a source that decides by itself (a pip row, a declared port, a single-medium\n * producer) answers its kind; one whose kind follows its file answers by the\n * files already known (`knownUrls`, read in the run's order: the extension,\n * then a List column's type), and is `unknown` when none is.\n *\n * On the `layerPlan` handle, only a plan pip row answers `image`\n * (`LAYER_PLAN_PIP_KINDS`: UGC Cards' plan is its card images): a declared\n * port, a producer set or a List column says what a FILE is, not what a\n * plan's layers are, so any other plan is `video` when its source is a video\n * and `unknown` otherwise.\n *\n * A run estimate prices `unknown` as a video run, so a quote is never below\n * what the run is charged; once a file is known, the answer is the run's.\n */\nexport function videoOverlayWireMediumBeforeRun(source: VideoOverlayWiredSource, wire: VideoOverlayWireBeforeRun = {}): VideoOverlayWireMedium {\n if (wire.target === \"plan\") {\n const row = pipRowKind(LAYER_PLAN_PIP_KINDS, source)\n return row ?? (kindOfSource(source) === \"video\" ? \"video\" : \"unknown\")\n }\n const decided = kindOfSource(source)\n if (decided) return decided\n const known = wire.knownUrls ?? []\n if (known.length === 0) return \"unknown\"\n return known.some((url) => kindOfFile(source, url) === \"video\") ? \"video\" : \"image\"\n}\n\n/** The row of `table` naming the source's handle, or undefined. */\nfunction pipRowKind(\n table: Readonly<Record<string, Readonly<Record<string, VideoOverlayWiredLayerKind>>>>,\n source: VideoOverlayWiredSource,\n): VideoOverlayWiredLayerKind | undefined {\n const pips = ownKey(table, source.type ?? \"\")\n const handle = source.handle ?? undefined\n return pips && handle !== undefined ? ownKey(pips, handle) : undefined\n}\n\n/** `list[i]` with `id === id`, its `key` when that is a string. */\nfunction portMedium(list: unknown, id: string, key: \"mediaType\" | \"type\"): string | undefined {\n if (!Array.isArray(list)) return undefined\n const port = list.find((p) => p !== null && typeof p === \"object\" && (p as { id?: unknown }).id === id) as Record<string, unknown> | undefined\n const value = port?.[key]\n return typeof value === \"string\" ? value : undefined\n}\n\nconst field = (v: unknown, key: string): unknown => (v !== null && typeof v === \"object\" ? (v as Record<string, unknown>)[key] : undefined)\n\n/**\n * The medium a component or sub-workflow declares for the handle a wire\n * leaves (`image`, `video`, `audio`, `text`, `any`), or undefined. A\n * sub-workflow (and a component) names its output ports in\n * `routeSnapshot.outputPorts`, its handles `out_<port>`; a component falls back\n * to `componentMetadata.outputs[].type`; a sub-workflow input node names its\n * ports in `ports`, by their own ids. The same fields both engines' input\n * resolvers route these wires by. (A List's column type is not a port\n * declaration: `listColumnMediaType` reads it, and it ranks below the URL's\n * extension.) Untrusted node data: anything malformed declares nothing.\n */\nexport function declaredOutputMediaType(type: string | null | undefined, data: unknown, handle: string | null | undefined): string | undefined {\n if (typeof handle !== \"string\" || data === null || typeof data !== \"object\") return undefined\n if (type === \"sub-workflow-input\") return portMedium(field(data, \"ports\"), handle, \"mediaType\")\n if (type !== \"sub-workflow\" && type !== \"component\") return undefined\n const portId = handle.replace(/^out_/, \"\")\n const fromSnapshot = portMedium(field(field(data, \"routeSnapshot\"), \"outputPorts\"), portId, \"mediaType\")\n if (fromSnapshot !== undefined || type !== \"component\") return fromSnapshot\n return portMedium(field(field(data, \"componentMetadata\"), \"outputs\"), portId, \"type\")\n}\n\n/** A List column type → the medium its cells declare (its text and JSON columns declare none). */\nconst LIST_COLUMN_MEDIA: Readonly<Record<string, string>> = { \"image-url\": \"image\", \"video-url\": \"video\", \"audio-url\": \"audio\" }\n\n/**\n * The medium a List's column type declares for the pip a wire leaves\n * (`image-url` → image, `video-url` → video, `audio-url` → audio): the column\n * whose `handleId` the pip names, else its first column — the column a List's\n * own `list` pip carries, as both engines' input resolvers route it. Undefined\n * for any other source, a text or JSON column, or malformed data. Handed to the\n * wired-kind rule as `columnMediaType`, where it ranks below the URL's extension.\n */\nexport function listColumnMediaType(type: string | null | undefined, data: unknown, handle: string | null | undefined): string | undefined {\n if (type !== \"list\" || data === null || typeof data !== \"object\") return undefined\n const columns = field(data, \"columns\")\n if (!Array.isArray(columns)) return undefined\n const isColumn = (c: unknown): c is Record<string, unknown> => c !== null && typeof c === \"object\"\n const column = columns.find((c) => isColumn(c) && c.handleId === handle) ?? columns[0]\n const columnType = isColumn(column) ? column.type : undefined\n return typeof columnType === \"string\" && Object.hasOwn(LIST_COLUMN_MEDIA, columnType) ? LIST_COLUMN_MEDIA[columnType] : undefined\n}\n\n/**\n * A WIRED slot's layer as it is stored: the expanded layer `expanded`, minus an\n * `animate` its writer did not set (`written`: the stored layer and the edit\n * applied to it). A wired slot's kind is its wire's, known only where the wire\n * is read — the run's assembly and the canvas stage — and the expansion there\n * fills the fade default by that kind (on for an image, off for a video); a\n * default stored here would fix one kind's default on the other, so a video\n * wired in later would fade. `written` itself when the result has the same\n * fields (an idempotent write); `expanded` by reference when nothing is removed.\n */\nexport function withoutImpliedVideoOverlayAnimate(\n expanded: VideoOverlayLayerInput,\n written: VideoOverlayLayerInput | null | undefined,\n): VideoOverlayLayerInput {\n if (written?.animate != null || expanded.animate === undefined) return expanded\n const { animate: _implied, ...rest } = expanded\n const fields = rest as Readonly<Record<string, unknown>>\n const keys = Object.keys(fields)\n const same = written != null && keys.length === Object.keys(written).length && keys.every((k) => fields[k] === (written as Readonly<Record<string, unknown>>)[k])\n return same ? written : rest\n}\n\n/**\n * A WIRED slot's layer as the run reads it when its wire is an image: without\n * a stored `sound`. A wired slot's kind is its wire's, read at the run, so a\n * sound set while the wire was a video (or before a List column's type, a\n * dynamic source's output or an upstream re-run changed it) is skipped rather\n * than refused: the run goes ahead, silent, and its fade default follows the\n * image. Only the assembly calls this, for wired slots; a layer that carries\n * its OWN image (the API, MCP, an unwired slot, a plan) keeps its sound and\n * the validator refuses it (`sound_without_video`). By reference when there is\n * no sound.\n */\nexport function withoutVideoOverlaySound<T extends VideoOverlayLayerInput>(layer: T): T {\n if (!Object.hasOwn(layer, \"sound\")) return layer\n const { sound: _skipped, ...rest } = layer\n return rest as T\n}\n\n/**\n * A layer without an empty-string `imageUrl` / `videoUrl`: every reader treats\n * one as absent, and the REST route's URL schema refuses it, so the assembly\n * drops it and a stored `{ imageUrl, videoUrl: \"\" }` runs as an image layer on\n * both engines. By reference when it has none.\n */\nexport function withoutEmptyVideoOverlaySources<T extends VideoOverlayLayerInput>(layer: T): T {\n if (layer.imageUrl !== \"\" && layer.videoUrl !== \"\") return layer\n const out: Record<string, unknown> = { ...layer }\n if (out.imageUrl === \"\") delete out.imageUrl\n if (out.videoUrl === \"\") delete out.videoUrl\n return out as T\n}\n","/**\n * Video Overlay — internal readers of a value as a writer sent it, shared by\n * `video-overlay.ts` and `video-overlay-validate.ts`. Not exported from any\n * entry, so they add no public names; this file imports types only, so\n * importing it creates no runtime cycle.\n */\nimport type { VideoOverlayFit, VideoOverlayLayerInput } from \"./video-overlay.js\"\n\nexport function isFit(v: unknown): v is VideoOverlayFit {\n return v === \"contain\" || v === \"cover\"\n}\n\n/**\n * A `layers[]` entry as a layer, or null when it is not a plain object. Layer\n * arrays reach this module from untrusted workflow JSON (the MCP write sites\n * type nodes as `record<string, unknown>`), so a bare string / number / array\n * entry is read as an ABSENT layer — never spread, never `in`-probed.\n */\nexport function asLayer(v: unknown): VideoOverlayLayerInput | null {\n return v !== null && typeof v === \"object\" && !Array.isArray(v) ? (v as VideoOverlayLayerInput) : null\n}\n\nexport const nonEmpty = (v: unknown): v is string => typeof v === \"string\" && v.length > 0\n/** A stored `layout`, `\"\"` read as absent like `null` (a cleared layout never refuses a run); anything else as stored, for the validator to judge. */\nexport const storedLayout = (v: string | null | undefined): string | undefined => (v == null || v === \"\" ? undefined : v)\n","/**\n * Video Overlay — timed image and video layers over a video. The wire contract of the\n * `video-overlay` node, `POST /v1/video-overlay`, the `overlay_images` MCP\n * verb, `client.media.videoOverlay` and `nodaro media video-overlay`, defined\n * ONCE:\n * - every numeric bound (the route schema, the validator — which refuses a\n * present box / look field outside `VIDEO_OVERLAY_BOUNDS`, so the DAG path\n * that never meets the route schema is bounded too — both engine\n * assemblies and the canvas read these — never a second copy);\n * - the placement presets, stored as data in the custom box vocabulary: a\n * `preset` is a TAG, the box is the truth — the worker and the preview\n * never switch on the tag;\n * - `expandVideoOverlayLayer` / `expandVideoOverlayPresets`: the one\n * normaliser every write boundary calls;\n * - `resolveVideoOverlayGeometry` (in `video-overlay-geometry.ts`): the one\n * placement function the canvas preview and the ffmpeg worker both call;\n * - `assembleVideoOverlayRequest`: the one node-data → request assembly both\n * workflow engines call;\n * - `videoOverlayCompositionKey` (+ `videoOverlaySlotSources`): the freshness\n * key a run stamps on its result (`resultCompositionKey`) — the canvas\n * single-node Run (which sends it with the request, bounded by\n * `VIDEO_OVERLAY_MAX_COMPOSITION_KEY_LENGTH`) and the DAG payload compute\n * it with this one function, and the node compares it against the key of\n * its current settings;\n * - `validateVideoOverlayRequest` (in `video-overlay-validate.ts`): what a\n * schema cannot express, at every engine entry. It returns a CODE, never\n * English: `formatVideoOverlayError` renders the route / worker text, the\n * canvas renders the code through its dictionaries.\n * The geometry and validator siblings import from this file; it imports\n * nothing from them.\n * Wire contract only — no prompt content, no I/O.\n */\nimport type { OverlayAnchor } from \"./image-overlay-layers.js\"\nimport { asLayer, isFit, nonEmpty, storedLayout } from \"./video-overlay-input.js\"\nimport { isVideoOverlayVideoLayer, withoutEmptyVideoOverlaySources, withoutImpliedVideoOverlayAnimate, withoutVideoOverlaySound } from \"./video-overlay-video-layers.js\"\nimport type { VideoOverlayLayoutId } from \"./video-overlay-layout-ids.js\"\n\n/** Engine + MCP contract: layers per request. */\nexport const VIDEO_OVERLAY_MAX_LAYERS = 20\n/** Ceiling for `start` / `end`, seconds. */\nexport const VIDEO_OVERLAY_MAX_TIME_SEC = 3600\n/**\n * The canvas layer handles, index-aligned with `layers[]` (overlay → layers[0]\n * … overlay12 → layers[11]). Slots 13 and up exist in data only, via `imageUrl`.\n * The same ids Image Overlay renders.\n */\nexport const VIDEO_OVERLAY_HANDLE_IDS = [\n \"overlay\", \"overlay2\", \"overlay3\", \"overlay4\", \"overlay5\", \"overlay6\",\n \"overlay7\", \"overlay8\", \"overlay9\", \"overlay10\", \"overlay11\", \"overlay12\",\n] as const\nexport const VIDEO_OVERLAY_PRESET_IDS = [\"card\", \"corner-badge\", \"full-frame\"] as const\nexport type VideoOverlayPresetId = (typeof VIDEO_OVERLAY_PRESET_IDS)[number]\nexport const VIDEO_OVERLAY_CORNERS = [\"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\"] as const\nexport type VideoOverlayCorner = (typeof VIDEO_OVERLAY_CORNERS)[number]\nexport const VIDEO_OVERLAY_FITS = [\"contain\", \"cover\"] as const\nexport type VideoOverlayFit = (typeof VIDEO_OVERLAY_FITS)[number]\n/** Target aspects; absent = the base's own size and fps. */\nexport const VIDEO_OVERLAY_OUTPUT_ASPECTS = [\"16:9\", \"9:16\", \"1:1\", \"4:5\"] as const\nexport type VideoOverlayOutputAspect = (typeof VIDEO_OVERLAY_OUTPUT_ASPECTS)[number]\n/**\n * Reserved input id for a JSON layer plan. Payload: `VideoOverlayLayer[]` — the\n * same shape as the node's `layers[]`, a `preset` tag allowed and expanded at\n * the boundary. It has a pip on the node; both input resolvers route an edge on\n * it into `inputs.layerPlan`, which `assembleVideoOverlayRequest` reads (plan\n * layers first, then the handle layers).\n */\nexport const VIDEO_OVERLAY_LAYER_PLAN_HANDLE = \"layerPlan\"\n/** Box and look bounds. */\nexport const VIDEO_OVERLAY_BOUNDS = {\n x: [-100, 100],\n y: [-100, 100],\n width: [1, 100],\n height: [1, 100],\n opacity: [0, 1],\n zIndex: [0, 100],\n} as const\n/** Σ downloaded layer bytes per job. */\nexport const VIDEO_OVERLAY_MAX_TOTAL_LAYER_BYTES = 100 * 1024 * 1024\n/** A video layer's `sound.volume` (1 = as recorded). */\nexport const VIDEO_OVERLAY_VOLUME_BOUNDS = [0, 1] as const\n/**\n * Video layers per request. Measured on the pinned ffmpeg: a 60 s base with\n * two video layers renders well inside the 10-minute limit (three times its\n * slowest render), and three video layers do not at 60 s.\n */\nexport const VIDEO_OVERLAY_MAX_VIDEO_LAYERS = 2\n/**\n * The longest base video, seconds, for a run with a video layer — the\n * longest base for which one and two video layers both render within the\n * 10-minute limit with room for three times the slowest measured render.\n */\nexport const VIDEO_OVERLAY_VIDEO_MAX_BASE_SEC = 60\n/** One video layer's file, bytes. */\nexport const VIDEO_OVERLAY_MAX_LAYER_VIDEO_BYTES = 200 * 1024 * 1024\n/** Fade + scale ramp, seconds each way (clamped to half of a short layer). */\nexport const VIDEO_OVERLAY_ANIMATION_SEC = 0.15\n/** The scale a layer grows from and shrinks back to during the ramp. */\nexport const VIDEO_OVERLAY_ANIMATION_MIN_SCALE = 0.96\n/** Corner-badge width and inset, % of the output canvas. */\nexport const VIDEO_OVERLAY_BADGE_WIDTH = 18\nexport const VIDEO_OVERLAY_BADGE_INSET = 4\n/** Pad colour for `baseFit: \"contain\"` when none is given. */\nexport const VIDEO_OVERLAY_DEFAULT_BACKGROUND = \"#000000\"\n/** The six box fields — exactly what a preset writes. */\nexport const VIDEO_OVERLAY_BOX_FIELDS = [\"anchor\", \"x\", \"y\", \"width\", \"height\", \"fit\"] as const\nexport const VIDEO_OVERLAY_WARNING_CODES = [\"clipped\", \"skipped\", \"animated_first_frame\", \"audio_reencoded\", \"layer_no_audio\"] as const\nexport type VideoOverlayWarningCode = (typeof VIDEO_OVERLAY_WARNING_CODES)[number]\nexport const VIDEO_OVERLAY_ERROR_CODES = [\n \"no_layers\", \"too_many_layers\", \"incomplete_box\", \"layer_without_image\",\n \"time_out_of_range\", \"end_before_start\", \"fit_without_aspect\", \"field_out_of_bounds\", \"invalid_layer_plan\",\n \"layer_two_sources\", \"too_many_video_layers\", \"sound_without_video\",\n \"base_box_needs_aspect\", \"layout_needs_aspect\", \"layout_needs_video_layer\", \"layout_conflicts_base_box\",\n] as const\nexport type VideoOverlayErrorCode = (typeof VIDEO_OVERLAY_ERROR_CODES)[number]\n\nexport interface VideoOverlayBox {\n readonly anchor: OverlayAnchor\n readonly x: number\n readonly y: number\n readonly width: number\n readonly height?: number\n readonly fit: VideoOverlayFit\n}\n/** A box as a writer may send it (the base box from workflow JSON): every field optional; `null` means absent. */\nexport type VideoOverlayBoxInput = { readonly [K in keyof VideoOverlayBox]?: VideoOverlayBox[K] | null }\n\n/** A video layer's sound, mixed with the base's during the layer's window. Absent = the layer is silent. */\nexport interface VideoOverlaySound {\n /** 0..1 (`VIDEO_OVERLAY_VOLUME_BOUNDS`). */\n readonly volume: number\n}\n\n/** A layer as stored and enqueued — complete: every box and look field present. */\nexport interface VideoOverlayLayer {\n /**\n * Used when the layer's canvas handle is not wired (MCP, template, layers\n * 13 and up). Wiring the handle CLEARS it — on the canvas by the one `layers[]`\n * writer (D3), on JSON-written workflows by the write-boundary pass (D10) —\n * and the run-time merge is still `wired ?? imageUrl` everywhere.\n */\n imageUrl?: string\n /**\n * The layer's video, instead of `imageUrl` — never both. Cleared by wiring\n * exactly as `imageUrl` is; a wired handle's source is a video when the\n * assembly is told so (`wiredVideoSlots`).\n */\n videoUrl?: string\n /** A video layer only. */\n sound?: VideoOverlaySound\n /** 1-based canvas slot (overlay = 1 … overlay12 = 12; 13 and up handle-less), stamped by both engine assemblies. Messages prefer it. */\n slot?: number\n /** 1-based entry of a wired layer plan, stamped by the assembly. Messages prefer it. */\n planLayer?: number\n /** Seconds, 0..3600, stored ms-precise; rendered on the base's frame grid (±1 frame). */\n start: number\n /** Seconds, 0..3600, > start; absent = until the video ends. */\n end?: number\n /** A TAG only — the box below is the truth. */\n preset?: VideoOverlayPresetId\n /** corner-badge only; default bottom-right. */\n corner?: VideoOverlayCorner\n anchor: OverlayAnchor\n /** Offset from the anchor, % of the output canvas width (−100..100; negative on a right anchor = inward). */\n x: number\n /** Offset from the anchor, % of the output canvas height. */\n y: number\n /** % of the output canvas width (1..100). */\n width: number\n /** % of the output canvas height (1..100); absent = follows the image's (or video's) aspect. */\n height?: number\n fit: VideoOverlayFit\n /** 0..1 */\n opacity: number\n /** Fade + slight scale in and out, 0.15 s each way. Default on for an image, off for a video. */\n animate: boolean\n /** Integer 0..100; absent = its position (slot − 1: layer 1 lowest). */\n zIndex?: number\n}\n\n/** A layer as a WRITER may send it (workflow JSON, a template, the canvas): every field optional; `null` means absent. */\nexport type VideoOverlayLayerInput = { [K in keyof VideoOverlayLayer]?: VideoOverlayLayer[K] | null }\n\n/**\n * A layer on the REST / SDK wire: exactly one of `imageUrl` / `videoUrl`, and\n * `start`, required; the box may be a preset, explicit fields, or nothing\n * (→ the corner-badge default).\n */\nexport type VideoOverlayLayerSpec = { start: number } & Partial<Omit<VideoOverlayLayer, \"imageUrl\" | \"videoUrl\" | \"start\">> &\n ({ imageUrl: string; videoUrl?: never } | { videoUrl: string; imageUrl?: never })\n\n/**\n * A base box on the REST / SDK wire: `anchor` and `width` required; `x` and\n * `y` default to 0 and `fit` to contain (`expandVideoOverlayLayout`), and no\n * `height` follows the base's own aspect.\n */\nexport type VideoOverlayBaseBoxSpec = Pick<VideoOverlayBox, \"anchor\" | \"width\"> & Partial<Omit<VideoOverlayBox, \"anchor\" | \"width\">>\n\n/** The `POST /v1/video-overlay` body. */\nexport interface VideoOverlayRequest {\n videoUrl: string\n /** 1..20, at most `VIDEO_OVERLAY_MAX_VIDEO_LAYERS` (2) of them videos. */\n layers: VideoOverlayLayerSpec[]\n outputAspect?: VideoOverlayOutputAspect\n /** Only with `outputAspect`; default cover. */\n baseFit?: VideoOverlayFit\n /** `#rrggbb`, only with `outputAspect` (drawn under `contain`); default `#000000`. */\n backgroundColor?: string\n /** Where the base sits, in a layer's box vocabulary; only with `outputAspect`. Overrides `baseFit`; uncovered canvas shows `backgroundColor`. Refused with a stack layout. */\n baseBox?: VideoOverlayBaseBoxSpec\n /**\n * A named layout that writes the boxes (`expandVideoOverlayLayout`): an\n * explicit `baseBox` wins over `video-bottom` / `video-top`; a stack places\n * the base itself and takes none; `pip` replaces the first video layer's box.\n */\n layout?: VideoOverlayLayoutId\n}\n\n/** A request whose layers went through `expandVideoOverlayPresets`. */\nexport interface ExpandedVideoOverlayRequest extends Omit<VideoOverlayRequest, \"layers\" | \"baseBox\"> {\n layers: VideoOverlayLayer[]\n /**\n * The base box as stored or sent, its `null` fields dropped — any field may\n * be absent. The validator refuses one without an anchor and a width; the\n * worker fills the rest (`expandVideoOverlayLayout`) after it.\n */\n baseBox?: Partial<VideoOverlayBox>\n /** Set by the assembly when a wired layer plan could not be read; `validateVideoOverlayRequest` reports it first. */\n planError?: \"invalid_layer_plan\"\n}\n\n/** `output_data.warnings[]`: `layer` = 0-based index of the request's layers (absent for a render-wide warning such as `audio_reencoded`), `slot` when known. */\nexport interface VideoOverlayWarning {\n readonly layer?: number\n readonly slot?: number\n /** Set instead of `slot` when the layer came from the layer plan. */\n readonly planLayer?: number\n readonly code: VideoOverlayWarningCode\n readonly detail: string\n}\n\nconst badge = (anchor: VideoOverlayCorner, sx: 1 | -1, sy: 1 | -1): VideoOverlayBox => ({\n anchor,\n x: sx * VIDEO_OVERLAY_BADGE_INSET,\n y: sy * VIDEO_OVERLAY_BADGE_INSET,\n width: VIDEO_OVERLAY_BADGE_WIDTH,\n fit: \"contain\",\n})\n\n/**\n * Placement presets as DATA in the custom vocabulary. `card` sits centred, 4 %\n * above centre, contain into 78 % × 60 % of the frame; `full-frame` covers the\n * frame; `corner-badge` is 18 % wide, 4 % in from its corner.\n */\nexport const VIDEO_OVERLAY_PRESETS: {\n readonly card: VideoOverlayBox\n readonly \"full-frame\": VideoOverlayBox\n readonly \"corner-badge\": Readonly<Record<VideoOverlayCorner, VideoOverlayBox>>\n} = {\n card: { anchor: \"center\", x: 0, y: -4, width: 78, height: 60, fit: \"contain\" },\n \"full-frame\": { anchor: \"center\", x: 0, y: 0, width: 100, height: 100, fit: \"cover\" },\n \"corner-badge\": {\n \"bottom-right\": badge(\"bottom-right\", -1, -1),\n \"bottom-left\": badge(\"bottom-left\", 1, -1),\n \"top-right\": badge(\"top-right\", -1, 1),\n \"top-left\": badge(\"top-left\", 1, 1),\n },\n}\n\n/** D2 — what a wired slot with no settings runs (and previews) with: the bottom-right corner badge, from 0 to the end. */\nexport const DEFAULT_VIDEO_OVERLAY_LAYER: VideoOverlayLayer = Object.freeze({\n start: 0,\n preset: \"corner-badge\" as const,\n corner: \"bottom-right\" as const,\n ...VIDEO_OVERLAY_PRESETS[\"corner-badge\"][\"bottom-right\"],\n opacity: 1,\n animate: true,\n})\n\nconst HEX6 = /^#[0-9a-fA-F]{6}$/\n\nexport function isVideoOverlayPresetId(v: unknown): v is VideoOverlayPresetId {\n return typeof v === \"string\" && (VIDEO_OVERLAY_PRESET_IDS as readonly string[]).includes(v)\n}\nexport function isVideoOverlayCorner(v: unknown): v is VideoOverlayCorner {\n return typeof v === \"string\" && (VIDEO_OVERLAY_CORNERS as readonly string[]).includes(v)\n}\nexport function isVideoOverlayOutputAspect(v: unknown): v is VideoOverlayOutputAspect {\n return typeof v === \"string\" && (VIDEO_OVERLAY_OUTPUT_ASPECTS as readonly string[]).includes(v)\n}\n/** 1-based slot of a layer handle id (`overlay` → 1 … `overlay12` → 12); 0 for anything else. */\nexport function videoOverlaySlotOfHandle(handle: string | null | undefined): number {\n return (VIDEO_OVERLAY_HANDLE_IDS as readonly string[]).indexOf(handle ?? \"\") + 1\n}\n\nexport function videoOverlayPresetBox(preset: VideoOverlayPresetId, corner?: VideoOverlayCorner | null): VideoOverlayBox {\n return preset === \"corner-badge\"\n ? VIDEO_OVERLAY_PRESETS[\"corner-badge\"][isVideoOverlayCorner(corner) ? corner : \"bottom-right\"]\n : VIDEO_OVERLAY_PRESETS[preset]\n}\n\n/** Filled when absent; `animate` too, by the layer's kind (on for an image, off for a video). */\nconst TRAILING_DEFAULTS = { x: 0, y: 0, fit: \"contain\", opacity: 1 } as const\n\nfunction usable(key: string, value: unknown): boolean {\n if (value === null || value === undefined) return false\n if (key === \"preset\") return isVideoOverlayPresetId(value)\n if (key === \"corner\") return isVideoOverlayCorner(value)\n return true\n}\n\n/** `null` / `undefined` / an unknown preset or corner → absent. By reference when nothing is dropped. */\nfunction clean(raw: VideoOverlayLayerInput): Partial<VideoOverlayLayer> {\n const entries = Object.entries(raw)\n if (entries.every(([k, v]) => usable(k, v))) return raw as Partial<VideoOverlayLayer>\n return Object.fromEntries(entries.filter(([k, v]) => usable(k, v))) as Partial<VideoOverlayLayer>\n}\n\nfunction sameShallow(a: Readonly<Record<string, unknown>>, b: unknown): boolean {\n if (!b || typeof b !== \"object\") return false\n const ka = Object.keys(a)\n const kb = Object.keys(b)\n return ka.length === kb.length && ka.every((k) => a[k] === (b as Record<string, unknown>)[k])\n}\n\n/**\n * The ONE normaliser (spec §3.3), called at every write boundary.\n * - `preset` + no box field → the preset's box is copied in, the tag stays.\n * - `preset` + explicit box fields → explicit fields win, the preset fills\n * what is absent; the tag is cleared only when an explicit field DIFFERS\n * from the preset's box (a field the preset does not set — `height` on a\n * corner badge — differs when present).\n * - no `preset` + no box field → the corner badge of the layer's own `corner`\n * (bottom-right when none), the D2 default filling tag / corner / trailing\n * fields, the layer's own fields winning (D8): `{}` → the full default.\n * - no `preset` + a PARTIAL box (not anchor AND width) → returned untouched;\n * the validator answers `incomplete_box`.\n * Trailing defaults x 0, y 0, fit contain, opacity 1, and animate (true for an\n * image, false for a video layer — in every branch, the default layer's included)\n * are filled here and nowhere else. A VIDEO layer with a preset and no `start`\n * starts at 0, like the default layer; an image one is left to the validator\n * (`time_out_of_range`), as it always was. `null` reads as absent. Returned BY\n * REFERENCE when nothing changes; idempotent, tag included.\n */\nexport function expandVideoOverlayLayer(raw: VideoOverlayLayerInput | null | undefined): VideoOverlayLayer {\n const obj = asLayer(raw)\n const layer = obj ? clean(obj) : {}\n const animateDefault = !isVideoOverlayVideoLayer(layer)\n const present = VIDEO_OVERLAY_BOX_FIELDS.filter((f) => layer[f] !== undefined)\n let out: Record<string, unknown>\n if (isVideoOverlayPresetId(layer.preset)) {\n const box = videoOverlayPresetBox(layer.preset, layer.corner)\n // A video layer tagged with a preset starts at 0 when it names no start (as the default layer does); an image layer is left for the validator, as before.\n out = { ...box, ...(animateDefault || layer.start !== undefined ? {} : { start: 0 }), ...layer }\n if (present.some((f) => layer[f] !== box[f])) delete out.preset\n } else if (present.length === 0) {\n out = { ...DEFAULT_VIDEO_OVERLAY_LAYER, animate: animateDefault, ...videoOverlayPresetBox(\"corner-badge\", layer.corner), ...layer }\n } else if (layer.anchor === undefined || layer.width === undefined) {\n return raw as VideoOverlayLayer\n } else {\n out = { ...layer }\n }\n for (const [k, v] of Object.entries(TRAILING_DEFAULTS)) if (out[k] === undefined) out[k] = v\n if (out.animate === undefined) out.animate = animateDefault\n return sameShallow(out, raw) ? (raw as VideoOverlayLayer) : (out as unknown as VideoOverlayLayer)\n}\n\n/** `expandVideoOverlayLayer` over an array; the SAME array when no layer changed. */\nexport function expandVideoOverlayPresets(layers: ReadonlyArray<VideoOverlayLayerInput | null | undefined>): VideoOverlayLayer[] {\n let changed = false\n const out = layers.map((l) => {\n const e = expandVideoOverlayLayer(l)\n if (e !== l) changed = true\n return e\n })\n return changed ? out : (layers as VideoOverlayLayer[])\n}\n\n/** The panel's preset click: REPLACE the six box fields with the preset's (dropping any it does not set), set the tag (+ corner), expand. */\nexport function applyVideoOverlayPreset(\n layer: VideoOverlayLayerInput | null | undefined,\n preset: VideoOverlayPresetId,\n corner?: VideoOverlayCorner,\n): VideoOverlayLayer {\n const base: Record<string, unknown> = { ...expandVideoOverlayLayer(layer) }\n for (const f of VIDEO_OVERLAY_BOX_FIELDS) delete base[f]\n delete base.preset\n const nextCorner = preset === \"corner-badge\" ? (corner ?? (isVideoOverlayCorner(base.corner) ? base.corner : \"bottom-right\")) : undefined\n return expandVideoOverlayLayer({\n ...base,\n ...videoOverlayPresetBox(preset, nextCorner),\n preset,\n ...(nextCorner ? { corner: nextCorner } : {}),\n } as VideoOverlayLayerInput)\n}\n\n/** The panel's \"Custom\": the tag is cleared, the box kept. */\nexport function toCustomVideoOverlayLayer(layer: VideoOverlayLayerInput | null | undefined): VideoOverlayLayer {\n const { preset: _tag, ...rest } = expandVideoOverlayLayer(layer)\n return rest as VideoOverlayLayer\n}\n\n/**\n * D10 — delete `imageUrl` AND `videoUrl` from every layer whose canvas handle\n * is wired (`wiredSlots`: 1-based): the wire is the layer's source, whichever\n * kind it is. Pure over `layers` (the route has no edges, so this is a sibling\n * of the expansion, not part of it). Slots 13 and up have no handle and are\n * never touched. The input array by reference when nothing changes.\n */\nexport function clearWiredVideoOverlayImageUrls<T extends VideoOverlayLayerInput | null | undefined>(\n layers: readonly T[],\n wiredSlots: ReadonlySet<number>,\n): readonly T[] {\n let out: T[] | null = null\n for (const slot of wiredSlots) {\n if (!Number.isInteger(slot) || slot < 1 || slot > VIDEO_OVERLAY_HANDLE_IDS.length) continue\n const layer = layers[slot - 1]\n if (!asLayer(layer) || !(\"imageUrl\" in (layer as object) || \"videoUrl\" in (layer as object))) continue\n out ??= [...layers]\n const { imageUrl: _image, videoUrl: _video, ...rest } = layer as VideoOverlayLayerInput\n out[slot - 1] = rest as T\n }\n return out ?? layers\n}\n\ninterface NodeLike {\n id?: unknown\n type?: unknown\n data?: unknown\n}\ninterface EdgeLike {\n target?: unknown\n targetHandle?: unknown\n}\n\n/**\n * The workflow-JSON write-boundary pass (spec §3.3, D10), beside\n * `normalizeNodeModelParams`: for every `video-overlay` node, clear the\n * `imageUrl` of each layer whose handle the WRITTEN edges wire, then expand\n * presets. Runs on every write, so an edge-only write still clears. A `null`\n * (or missing) slot STAYS `null`: \"no settings\" is stored as such, wired or\n * not — the default corner badge is synthesised only where a wired slot is\n * run or drawn (the two engine assemblies and the stage, D2), so the panel,\n * the reorder and the tail trim see the same empty slot whichever writer\n * stored it. (`{}` is not `null`: it is an explicit empty layer, and the\n * expansion turns it into the full default — spec §3.3.) Nodes and the array\n * are returned by reference when nothing changes.\n */\nexport function normalizeVideoOverlayNodes<T extends NodeLike>(nodes: readonly T[], edges: ReadonlyArray<EdgeLike> | null | undefined): T[] {\n let changed = false\n const out = nodes.map((node) => {\n if (node.type !== \"video-overlay\") return node\n const data = node.data\n if (!data || typeof data !== \"object\" || Array.isArray(data)) return node\n const d = data as Record<string, unknown>\n if (!Array.isArray(d.layers)) return node\n const layers = d.layers as Array<VideoOverlayLayerInput | null>\n const wired = new Set<number>()\n for (const e of edges ?? []) {\n if (e.target !== node.id) continue\n const slot = videoOverlaySlotOfHandle(typeof e.targetHandle === \"string\" ? e.targetHandle : undefined)\n if (slot > 0) wired.add(slot)\n }\n const cleared = clearWiredVideoOverlayImageUrls(layers, wired)\n let layersChanged = cleared !== layers\n const next = cleared.map((l, i) => {\n // null / missing stays as stored; a non-object entry is left untouched so\n // the validator sees it (it reads as an absent layer everywhere).\n if (!asLayer(l)) return l\n // A wired slot's fade default follows its wire's kind, read at the run:\n // only a fade it was written with is stored.\n const expanded = expandVideoOverlayLayer(l)\n const e = wired.has(i + 1) ? withoutImpliedVideoOverlayAnimate(expanded, l) : expanded\n if (e !== l) layersChanged = true\n return e\n })\n if (!layersChanged) return node\n changed = true\n return { ...node, data: { ...d, layers: next } }\n })\n return changed ? out : (nodes as T[])\n}\n\n/** What `videoOverlayRenderOrder` reads from a layer. */\nexport interface VideoOverlayOrderable {\n readonly zIndex?: number | null\n /** 1-based canvas slot (stamped by both engine assemblies). */\n readonly slot?: number | null\n /** 1-based layer-plan entry. Plan layers sit BELOW every slot layer (handle layers draw above the plan), unless they set a `zIndex`. */\n readonly planLayer?: number | null\n /** 0-based index in the request's `layers[]` (the worker's graph layers carry it). */\n readonly index?: number | null\n}\n\n/** A plan layer's default position sits this far below layer 1's (slot 1 = 0), so the whole plan renders under the slot layers. */\nconst PLAN_LAYER_Z_BASE = 1000\nconst isSlot = (v: unknown): v is number => typeof v === \"number\" && Number.isInteger(v) && v >= 1\nconst isIndex = (v: unknown): v is number => typeof v === \"number\" && Number.isInteger(v) && v >= 0\n\n/**\n * Render order, bottom to top, as positions in `layers`: an explicit zIndex\n * wins; a layer without one sits at its OWN position — `slot − 1` when it has\n * a slot, else its request `index`, else its position in the array given —\n * never at its position in whatever (compacted) array it happens to be passed\n * in. The stage passes every slot; the worker passes the request minus empty\n * slots and minus layers skipped for starting after the end — both must agree\n * (spec: the preview and the run use the same numbers). Ties keep array order\n * (layer 1 lowest).\n */\nexport function videoOverlayRenderOrder(layers: ReadonlyArray<VideoOverlayOrderable | null | undefined>): number[] {\n return layers\n .map((l, i) => {\n const own = isSlot(l?.planLayer) ? l.planLayer - 1 - PLAN_LAYER_Z_BASE : isSlot(l?.slot) ? l.slot - 1 : isIndex(l?.index) ? l.index : i\n return { i, z: typeof l?.zIndex === \"number\" && Number.isFinite(l.zIndex) ? l.zIndex : own }\n })\n .sort((a, b) => a.z - b.z || a.i - b.i)\n .map((e) => e.i)\n}\n\n/** The wired `layerPlan` value (a JSON string or an array) → its layers, or `invalid_layer_plan`. */\nexport function parseVideoOverlayLayerPlan(raw: unknown): { layers: VideoOverlayLayerInput[] } | { error: \"invalid_layer_plan\" } {\n let value: unknown = raw\n if (typeof raw === \"string\") {\n try {\n value = JSON.parse(raw)\n } catch {\n return { error: \"invalid_layer_plan\" }\n }\n }\n if (!Array.isArray(value) || !value.every((l) => l !== null && typeof l === \"object\" && !Array.isArray(l))) {\n return { error: \"invalid_layer_plan\" }\n }\n return { layers: value as VideoOverlayLayerInput[] }\n}\n\n/** A stored base box without its `null` fields (by reference when it has none); a non-object as stored, for the validator. */\nconst storedBaseBox = (box: VideoOverlayBoxInput): Partial<VideoOverlayBox> => (asLayer(box) ? clean(box as VideoOverlayLayerInput) : box) as Partial<VideoOverlayBox>\n\n/** The node-data fields the assembly reads. */\nexport interface VideoOverlayNodeFields {\n readonly layers?: ReadonlyArray<VideoOverlayLayerInput | null | undefined> | null\n readonly outputAspect?: string | null\n readonly baseFit?: string | null\n readonly backgroundColor?: string | null\n /** As written, like the fields above: the validator, not the type, refuses a malformed box or an unknown layout. */\n readonly baseBox?: VideoOverlayBoxInput | null\n readonly layout?: string | null\n}\n\n/**\n * The ONE node → request assembly, called by the canvas single-node run AND\n * payload-builder (so both engines refuse identically). Per slot i over\n * max(wired handles (≤ 12), stored layers) — every stored slot, so more than\n * 20 layers that render reach the validator's `too_many_layers` instead of\n * being dropped: the source is the wired handle's — a `videoUrl` when its slot\n * is in `wiredVideoSlots`, else an `imageUrl` (a stored `sound` skipped, so a\n * wire read as an image at the run never refuses it), replacing both stored\n * sources — else the layer's own `imageUrl` / `videoUrl` as stored (both stored reach\n * the validator's `layer_two_sources`; an empty-string one is dropped —\n * `withoutEmptyVideoOverlaySources`, plan layers too); a slot with neither is dropped; a slot with\n * no settings is the default layer (D2 — a `null` / missing / `{}` entry);\n * `slot = i + 1` is stamped; the layer is expanded. `baseFit` /\n * `backgroundColor` ride as stored, WITH or WITHOUT an `outputAspect`: the\n * validator — not this assembly — refuses them without one\n * (`fit_without_aspect`, spec §3.5), so a JSON-written node carrying a fit\n * and no aspect is refused on both engines instead of silently rendering.\n * (The canvas never builds that request: its two aspect writers clear both\n * fields with the aspect.) A value the route's schema would reject — an\n * unknown aspect or fit, a colour that is not `#rrggbb` — is dropped here.\n * `baseBox` and `layout` ride AS STORED (a `\"\"` layout reads as absent, like\n * `null`; a box's `null` fields are dropped, as a layer's are by its\n * expansion — every reader treats them as absent, and the REST route's schema\n * takes no `null`, so the canvas run's request stays one the route accepts): a\n * malformed box or an unknown layout reaches the validator, which refuses it\n * on both engines.\n *\n * A wired layer plan (`planLayers`, a JSON string or an array) contributes its\n * layers FIRST, then the slot layers: plan layers carry `planLayer` (1-based)\n * and never a `slot`, and a plan layer's image is only its own `imageUrl` —\n * never the index-aligned handle's (R18). An unreadable plan sets `planError`,\n * which the validator reports before anything else.\n */\nexport function assembleVideoOverlayRequest(input: {\n readonly videoUrl: string\n readonly data: VideoOverlayNodeFields\n /** Each wired handle's source, by slot (images and videos alike). */\n readonly wiredImageUrls: ReadonlyArray<string | null | undefined>\n /** 1-based slots whose wired source is a video (`videoOverlayWiredLayerKind`); absent = every wire is an image. */\n readonly wiredVideoSlots?: ReadonlySet<number>\n /** The wired `layerPlan` value (string or array); absent when nothing is wired. */\n readonly planLayers?: unknown\n}): ExpandedVideoOverlayRequest {\n const stored = Array.isArray(input.data.layers) ? input.data.layers : []\n const wired = input.wiredImageUrls.slice(0, VIDEO_OVERLAY_HANDLE_IDS.length)\n // Every stored slot, never capped at VIDEO_OVERLAY_MAX_LAYERS: a JSON-written\n // node with 21+ layers must reach the validator's `too_many_layers` on both\n // engines (spec §3.5) — capping here would silently drop layers 21+. Only the\n // wired list is capped (12 handles).\n const slots = Math.max(wired.length, stored.length)\n const layers: VideoOverlayLayer[] = []\n for (let i = 0; i < slots; i++) {\n const own = asLayer(stored[i])\n const raw = own && withoutEmptyVideoOverlaySources(own)\n const wiredUrl = wired[i]\n if (nonEmpty(wiredUrl)) {\n // The wire is the source: the other kind's stored field goes, its own kind's is replaced.\n const video = input.wiredVideoSlots?.has(i + 1) === true\n const [kind, other] = video ? ([\"videoUrl\", \"imageUrl\"] as const) : ([\"imageUrl\", \"videoUrl\"] as const)\n const { [other]: _replaced, ...keep } = raw ?? {}\n // An image wire skips a stored sound (`withoutVideoOverlaySound`); the expansion fills the fade default by the wire's kind.\n layers.push(expandVideoOverlayLayer({ ...(video ? keep : withoutVideoOverlaySound(keep)), [kind]: wiredUrl, slot: i + 1 }))\n } else if (nonEmpty(raw?.imageUrl) || nonEmpty(raw?.videoUrl)) {\n layers.push(expandVideoOverlayLayer({ ...raw, slot: i + 1 }))\n }\n }\n const outputAspect = isVideoOverlayOutputAspect(input.data.outputAspect) ? input.data.outputAspect : undefined\n const baseFit = isFit(input.data.baseFit) ? input.data.baseFit : undefined\n const backgroundColor =\n typeof input.data.backgroundColor === \"string\" && HEX6.test(input.data.backgroundColor) ? input.data.backgroundColor : undefined\n const rest = {\n ...(outputAspect ? { outputAspect } : {}),\n ...(baseFit ? { baseFit } : {}),\n ...(backgroundColor ? { backgroundColor } : {}),\n ...(input.data.baseBox != null ? { baseBox: storedBaseBox(input.data.baseBox) } : {}),\n ...(storedLayout(input.data.layout) !== undefined ? { layout: input.data.layout as VideoOverlayLayoutId } : {}),\n }\n if (input.planLayers === undefined) return { videoUrl: input.videoUrl, layers, ...rest }\n const plan = parseVideoOverlayLayerPlan(input.planLayers)\n if (\"error\" in plan) return { videoUrl: input.videoUrl, layers, ...rest, planError: plan.error }\n const planned = expandVideoOverlayPresets(plan.layers.map(withoutEmptyVideoOverlaySources)).map((l, i) => {\n const { slot: _slot, ...own } = l\n return { ...own, planLayer: i + 1 }\n })\n return { videoUrl: input.videoUrl, layers: [...planned, ...layers], ...rest }\n}\n\n/**\n * Slot i's source: the wired handle's, else the layer's own `imageUrl`, else\n * its own `videoUrl` — the one source rule the stage, the panel, the canvas\n * executor and the DAG payload share (the render's merge is the same\n * `wired ?? imageUrl ?? videoUrl`, spec §3.5). Every stored slot, past 20 too:\n * the limit is the layer COUNT, not the slot (layers 1–4 removed from a\n * 24-layer node leave 20 at slots 5–24). Only the wired list is capped, at the\n * 12 handles.\n */\nexport function videoOverlaySlotSources(\n layers: ReadonlyArray<VideoOverlayLayerInput | null | undefined> | null | undefined,\n wiredImageUrls: ReadonlyArray<string | null | undefined>,\n): Array<string | undefined> {\n const stored = Array.isArray(layers) ? layers : []\n const wired = wiredImageUrls.slice(0, VIDEO_OVERLAY_HANDLE_IDS.length)\n return Array.from({ length: Math.max(stored.length, wired.length) }, (_, i) => {\n const w = wired[i]\n if (nonEmpty(w)) return w\n const own = asLayer(stored[i])\n return nonEmpty(own?.imageUrl) ? own.imageUrl : nonEmpty(own?.videoUrl) ? own.videoUrl : undefined\n })\n}\n\n/** Everything that decides what a Video Overlay run paints. */\nexport interface VideoOverlayComposition {\n /** The resolved base video URL. */\n readonly baseUrl?: string | null\n /** The image or video each slot draws, by slot index (`videoOverlaySlotSources`). */\n readonly sources: ReadonlyArray<string | null | undefined>\n /** The node's stored settings — never the expanded request. */\n readonly data: VideoOverlayNodeFields\n /** The wired `layerPlan` value (string or array); absent when nothing is wired. */\n readonly planLayers?: unknown\n /** The 1-based slots whose wired source is a video (the assembly's `wiredVideoSlots`); absent or empty = every wire is an image. */\n readonly videoSlots?: Iterable<number> | null\n}\n\n/**\n * A value with every object's keys sorted and every null / undefined object\n * field dropped (the assembly reads both as absent); array positions are kept.\n * A jsonb round-trip re-orders object keys, so a node read back from the DB\n * (a schedule / webhook / app run) and the same node in the editor (insertion\n * order) must give one key.\n */\nfunction canonicalValue(v: unknown): unknown {\n if (Array.isArray(v)) return v.map((x) => (x === undefined ? null : canonicalValue(x)))\n if (v !== null && typeof v === \"object\") {\n const out: Record<string, unknown> = {}\n for (const k of Object.keys(v).sort()) {\n const x = (v as Record<string, unknown>)[k]\n if (x !== undefined && x !== null) out[k] = canonicalValue(x)\n }\n return out\n }\n return v\n}\n\n/**\n * The longest `resultCompositionKey` the REST route accepts. The canvas sends\n * its key with a single-node Run so the job's output_data carries it (a result\n * that lands after a page reload reads fresh); the route stores it opaquely and\n * reads it for nothing else. A full 20-layer composition with long signed URLs\n * fits well inside; a canvas key past it is not sent.\n */\nexport const VIDEO_OVERLAY_MAX_COMPOSITION_KEY_LENGTH = 65_536\n\n/**\n * The composition key a run stamps on its result (`resultCompositionKey`): the\n * base, every slot's image, the layers, the output aspect, the fit, the pad\n * colour, the base box, the layout and which wired slots are videos. A later\n * change to any of them marks the result \"Result (old)\".\n * Canonical — independent of object key order, of absent vs undefined vs null\n * fields, and of trailing empty slots — so the canvas (the node and its\n * single-node Run) and the DAG payload give one key for one composition.\n */\nexport function videoOverlayCompositionKey(c: VideoOverlayComposition): string {\n const sources = c.sources.map((s) => (typeof s === \"string\" && s.length > 0 ? s : null))\n while (sources.length > 0 && sources[sources.length - 1] === null) sources.pop()\n const parts: unknown[] = [\n c.baseUrl || null,\n sources,\n Array.isArray(c.data.layers) ? c.data.layers : [],\n c.data.outputAspect ?? null,\n c.data.baseFit ?? null,\n c.data.backgroundColor ?? null,\n ]\n // Appended only when a plan is wired, so a node with no plan keeps today's key.\n // The PARSED plan is hashed: a JSON string and its array give one key.\n if (c.planLayers !== undefined) {\n const plan = parseVideoOverlayLayerPlan(c.planLayers)\n parts.push(\"error\" in plan ? \"invalid\" : plan.layers)\n }\n // Likewise only when set, as ONE object — never confused with the plan (an array or \"invalid\").\n const layout = storedLayout(c.data.layout)\n if (c.data.baseBox != null || layout !== undefined) parts.push({ baseBox: c.data.baseBox, layout })\n // A wired slot's kind can change while its URL does not (an extension-less\n // link, a List column's type); only when a wire is a video, so an\n // image-only node keeps its key.\n const videoSlots = [...new Set(c.videoSlots ?? [])].sort((a, b) => a - b)\n if (videoSlots.length > 0) parts.push({ videoSlots })\n return JSON.stringify(canonicalValue(parts))\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from './chunk-LLOIAGFB.js';
1
+ import { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from './chunk-UDDVDQMF.js';
2
2
 
3
3
  // src/fan-out-meta.ts
4
4
  function fanOutItemMeta(output) {
@@ -467,5 +467,5 @@ function ugcCardsOutputs(answer) {
467
467
  }
468
468
 
469
469
  export { UGC_CREATOR_CANDIDATES_KEY, UGC_CREATOR_MISSING_MESSAGE, UGC_CREATOR_PICKER_TYPES, UGC_FINISH_NEEDS_CLIPS_MESSAGE, UGC_FINISH_NOT_READY_MESSAGE, UGC_NEEDS_FINISH_MESSAGE, UGC_NEWER_APP_MESSAGE, UGC_NODE_MESSAGES, UGC_NODE_RUN_STATE_KEYS, UGC_NODE_TYPES, UGC_NOT_SERVED_MESSAGE, UGC_OVERRIDABLE_FIELDS, UGC_OVER_HOLD_MESSAGE, UGC_PICK_FIRST_MESSAGE, UGC_PICK_GONE_MESSAGE, UGC_PRIMARY_HANDLE, UGC_PUBLISH_PRIVATE_FIELDS, UGC_SCREENSHOT_HANDLES, UGC_SCRIPT_DEFAULT_TARGET_SEC, UGC_SCRIPT_LANGUAGES, UGC_SCRIPT_MAX_TARGET_SEC, UGC_SCRIPT_MIN_TARGET_SEC, UGC_SCRIPT_NEEDS_CHANGES, UGC_VERSION_MESSAGE, clipNotesFrom, fanOutItemMeta, findUgcLockedFields, readUgcWire, stripUgcRunState, ugcAwaitsPick, ugcCardsBody, ugcCardsJobs, ugcCardsOutputs, ugcClipBody, ugcClipOutputs, ugcClipSavedList, ugcClipsBody, ugcClipsOutputs, ugcCreatorBody, ugcCreatorCallsToRender, ugcCreatorCandidate, ugcCreatorCandidates, ugcCreatorOutputs, ugcCreatorPick, ugcFailure, ugcKeptOutputs, ugcPickPending, ugcPipValue, ugcPlanLengthSec, ugcPlanScreenshotCount, ugcRunWaitsForPick, ugcScriptBody, ugcScriptOutputs, ugcScriptResult };
470
- //# sourceMappingURL=chunk-VOWJCUMR.js.map
471
- //# sourceMappingURL=chunk-VOWJCUMR.js.map
470
+ //# sourceMappingURL=chunk-I2RQB7VG.js.map
471
+ //# sourceMappingURL=chunk-I2RQB7VG.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/fan-out-meta.ts","../src/ugc-run-state.ts","../src/ugc-node-wires.ts"],"names":[],"mappings":";;;AAKO,SAAS,eAAe,MAAA,EAA8F;AAC3H,EAAA,MAAM,IAAI,MAAA,EAAQ,YAAA;AAClB,EAAA,MAAM,IAAI,MAAA,EAAQ,WAAA;AAClB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,GAAI,CAAA,CAAE,MAAA,CAAO,CAAC,CAAA,KAAmB,OAAO,CAAA,KAAM,QAAQ,IAAI,EAAC;AAAA,IACpF,WAAA,EAAa,OAAO,CAAA,KAAM,QAAA,IAAY,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI;AAAA,GAC1E;AACF;AAGO,SAAS,aAAA,CAAc,MAAoE,MAAA,EAAqC;AACrI,EAAA,MAAM,IAAA,GAAO,IAAA,IAAQ,IAAA,CAAK,MAAA,GAAS,CAAA,GAAI,OAAO,MAAA,GAAS,CAAC,MAAM,CAAA,GAAI,EAAC;AACnE,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,CAAC,CAAA,EAAG,CAAA,MAAO;AAAA,IACzB,MAAM,CAAA,GAAI,CAAA;AAAA,IACV,QAAA,EAAU,CAAA,EAAG,QAAA,IAAY,EAAC;AAAA,IAC1B,GAAI,OAAO,CAAA,EAAG,WAAA,KAAgB,QAAA,GAAW,EAAE,WAAA,EAAa,CAAA,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AAI,SAAA,EAAW,CAAA,EAAG,SAAA,EAAW,CAAA,EAAG,QAAA,EAAU,EAAC,EAAE;AAGhG,SAAS,gBAAgB,MAAA,EAA6C;AAC3E,EAAA,MAAM,SAAS,MAAA,CAAO,aAAA;AACtB,EAAA,MAAM,SAAS,MAAA,CAAO,MAAA;AACtB,EAAA,MAAM,QAAQ,QAAA,CAAS,MAAM,KAAK,KAAA,CAAM,OAAA,CAAQ,OAAO,KAAK,CAAA,GAAI,MAAA,CAAO,KAAA,CAAM,OAAO,CAAC,CAAA,KAAmB,OAAO,CAAA,KAAM,QAAQ,IAAI,EAAC;AAClI,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,IAAA,CAAK,SAAA,CAAU,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,GAAI,MAAA,CAAO,SAAA,GAAY,EAAE,CAAA;AAAA,IACjF,WAAA,EAAa,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,MAAM,CAAA,GAAI,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,MAAA,EAAO,GAAI,kBAAkB,CAAA;AAAA,IACvF,MAAA,EAAQ,KAAA,CAAM,IAAA,CAAK,IAAI;AAAA,GACzB;AACF","file":"chunk-VOWJCUMR.js","sourcesContent":["/** One fan-out item's notes: its warnings and its real length (UGC Clip). */\nexport interface FanOutItemMeta { readonly warnings: readonly string[]; readonly durationSec: number | null }\n/** One row of UGC Cards' `notes` input. */\nexport interface ClipNote { readonly clip: number; readonly warnings: readonly string[]; readonly durationSec?: number }\n\nexport function fanOutItemMeta(output: { clipWarnings?: unknown; durationSec?: unknown } | null | undefined): FanOutItemMeta {\n const w = output?.clipWarnings\n const d = output?.durationSec\n return {\n warnings: Array.isArray(w) ? w.filter((x): x is string => typeof x === \"string\") : [],\n durationSec: typeof d === \"number\" && Number.isFinite(d) && d > 0 ? d : null,\n }\n}\n\n/** Row-aligned meta (or one single output) → the notes UGC Cards reads, clip numbers from 1. */\nexport function clipNotesFrom(meta: ReadonlyArray<FanOutItemMeta | null | undefined> | undefined, single?: FanOutItemMeta): ClipNote[] {\n const rows = meta && meta.length > 0 ? meta : single ? [single] : []\n return rows.map((m, i) => ({\n clip: i + 1,\n warnings: m?.warnings ?? [],\n ...(typeof m?.durationSec === \"number\" ? { durationSec: m.durationSec } : {}),\n }))\n}\n","/** The UGC node types (Cloud only; served by a private plugin). */\nexport const UGC_NODE_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\", \"ugc-clips\", \"ugc-clip\", \"ugc-cards\", \"ugc-finish-clips\"])\n\n/** UGC Creator: the node-data key that holds a round's passing candidates until the person picks one (run state). */\nexport const UGC_CREATOR_CANDIDATES_KEY = \"candidates\"\n\n/** A run that would execute a UGC Creator whose options wait for the person's pick. */\nexport const UGC_PICK_FIRST_MESSAGE = \"Pick a creator first.\"\n\n/**\n * Per UGC type, the node-data keys that are a RUN's state, never a choice. A\n * published app's snapshot is readable by every runner, so publishing strips\n * them (the last plan, the clip tickets, the publisher's kept creator).\n *\n * UGC Creator's image (`generatedImageUrl`) goes from every creator, whatever its\n * source: after a My photo run it IS the author's photo, and a creator switched\n * to another source after such a run, or whose photo was removed, still holds it.\n * UGC Clip's takes and UGC Cards' Notes (`generatedText`, and `text`, the Notes\n * as a run hands them on) are the author's renders: a published node starts empty.\n *\n * A published snapshot is stripped through `stripUgcPublishState`\n * (@nodaro/render-rules), which also empties every run result a lane writes under\n * a generic name, every node made from the UGC video, and every node on a path\n * into a UGC Creator's photo input.\n */\nexport const UGC_NODE_RUN_STATE_KEYS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"result\", \"keepResult\", \"ugcOutputs\", UGC_CREATOR_CANDIDATES_KEY, \"optionFailed\", \"generatedImageUrl\"],\n // `exampleLines`: a template's example run, shown until the node's own first script (display only).\n \"ugc-script\": [\"result\", \"keepResult\", \"ugcOutputs\", \"exampleLines\"],\n \"ugc-clips\": [\"result\", \"quote\", \"__listResults\", \"ugcOutputs\"],\n \"ugc-clip\": [\n \"warnings\", \"rerender\", \"rerenderPending\", \"__listResults\", \"__listResultMeta\", \"clipWarnings\", \"durationSec\", \"ugcOutputs\",\n \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\",\n ],\n \"ugc-cards\": [\"result\", \"ugcOutputs\", \"generatedText\", \"text\"],\n \"ugc-finish-clips\": [\"ugcOutputs\", \"__listResults\", \"__listResultMeta\", \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\"],\n}\n\n/**\n * The ONLY UGC keys a run request's `inputOverrides` may set — an allow-list,\n * so a run-state field added later is locked without anyone listing it.\n *\n * No UGC type may gain a `LEGACY_EXPOSED_FIELD_KEYS` row: the lock reads the\n * stored key, before that table renames it.\n */\nexport const UGC_OVERRIDABLE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"source\", \"gender\", \"photoUrl\"],\n \"ugc-script\": [\"targetDurationSec\", \"language\"],\n \"ugc-clips\": [],\n \"ugc-clip\": [],\n \"ugc-cards\": [],\n \"ugc-finish-clips\": [],\n}\n\nconst KEEP_RESULT_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\"])\n\n/** UGC Creator holds options for the person to pick: the ones a run drew, or the ones a credits stop kept. */\nexport function ugcPickPending(data: unknown): boolean {\n const candidates = data && typeof data === \"object\" ? (data as Record<string, unknown>)[UGC_CREATOR_CANDIDATES_KEY] : undefined\n return Array.isArray(candidates) && candidates.length > 0\n}\n\n/**\n * A run that would execute a UGC Creator whose options wait is refused (\"Pick a creator first.\"),\n * except that creator's own re-draw. One rule for the editor's check before a run and the\n * orchestrator's.\n */\nexport function ugcRunWaitsForPick(\n runNodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,\n opts: { readonly redrawId?: string } = {},\n): boolean {\n return runNodes.some((n) => n.type === \"ugc-creator\" && n.id !== opts.redrawId && ugcPickPending(n.data))\n}\n\n/**\n * Per UGC type, the author's own content a published snapshot never carries: UGC Creator's photo\n * of a person (`photoUrl`). A choice, not run state — so it stays on the author's own workflow —\n * but a runner gives their own photo (or the run is refused for want of one) and a template's\n * cloner adds theirs.\n */\nexport const UGC_PUBLISH_PRIVATE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"photoUrl\"],\n}\n\n/**\n * The UGC types' own strip: a copy of `nodes` with every UGC node's run state and the author's own\n * photo removed (and `keepResult: false`). Other nodes are returned as they are. Publishing, a\n * share link's view and a viewer's run go through `stripUgcPublishState` (@nodaro/render-rules),\n * which starts here.\n */\nexport function stripUgcRunState<T extends { type?: unknown; data?: unknown }>(nodes: readonly T[]): T[] {\n return nodes.map((node) => {\n const type = typeof node.type === \"string\" ? node.type : \"\"\n if (!UGC_NODE_TYPES.has(type) || !node.data || typeof node.data !== \"object\") return node\n const data: Record<string, unknown> = { ...(node.data as Record<string, unknown>) }\n for (const key of UGC_NODE_RUN_STATE_KEYS[type] ?? []) delete data[key]\n for (const key of UGC_PUBLISH_PRIVATE_FIELDS[type] ?? []) delete data[key]\n if (KEEP_RESULT_TYPES.has(type)) data.keepResult = false\n return { ...node, data }\n })\n}\n\n/** Every override entry that would set a non-overridable key on a UGC node, in node then key order. Pure. */\nexport function findUgcLockedFields(\n nodes: ReadonlyArray<{ id: string; type?: string }> | null | undefined,\n inputOverrides: Record<string, Record<string, unknown>> | null | undefined,\n): Array<{ nodeId: string; nodeType: string; field: string }> {\n if (!nodes || !inputOverrides) return []\n const found: Array<{ nodeId: string; nodeType: string; field: string }> = []\n for (const node of nodes) {\n const type = node?.type\n if (typeof type !== \"string\" || !UGC_NODE_TYPES.has(type)) continue\n const allowed = UGC_OVERRIDABLE_FIELDS[type] ?? []\n const fields = inputOverrides[node.id]\n if (!fields || typeof fields !== \"object\") continue\n for (const field of Object.keys(fields)) {\n if (!allowed.includes(field)) found.push({ nodeId: String(node.id), nodeType: type, field })\n }\n }\n return found\n}\n","/**\n * The UGC node wires: every request body the five UGC nodes send and every\n * output they hand on, as ONE pure implementation that both engines (the\n * workflow orchestrator and the editor) call, so the two can never disagree.\n *\n * Content-free. A creator record is read only for `v`, `gender` and\n * `identityImages`, a plan only for `v`, a clip ticket only for `v`, `index`\n * and `durationSec`; every other key is opaque and passes through as it came.\n * Every UGC-private JSON a node emits carries `v: 1`, and a wire with another\n * `v` is refused, never guessed at.\n */\nimport type { CaptionPlan } from \"./caption-plan.js\"\nimport { fanOutItemMeta, type ClipNote } from \"./fan-out-meta.js\"\nimport { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from \"./model-constants.js\"\nimport { ugcPickPending } from \"./ugc-run-state.js\"\n\n/** A UGC call that reached a deployment without the UGC routes (the router's 404). */\nexport const UGC_NOT_SERVED_MESSAGE = \"UGC videos are a Nodaro Cloud feature and are not served on this deployment.\"\n/** A wire whose `v` this app does not read. */\nexport const UGC_VERSION_MESSAGE = \"This workflow was made with a newer version of the UGC nodes.\"\n/** An answer this app cannot run: a tool it does not know, or a shape it cannot read. */\nexport const UGC_NEWER_APP_MESSAGE = \"This step needs a newer app version.\"\n/** A creator pick whose options are gone (another run replaced them, or they were never this node's). */\nexport const UGC_PICK_GONE_MESSAGE = \"These creator options are no longer available. Run UGC Creator again.\"\n/** UGC Clips with no creator on its creator input (UGC Creator has not run, or waits for a pick). */\nexport const UGC_CREATOR_MISSING_MESSAGE = \"UGC Creator has no creator yet. Run it, or pick one of its options.\"\n/** UGC Script's target length in seconds when the node holds none: the node's default (the route requires a length). */\nexport const UGC_SCRIPT_DEFAULT_TARGET_SEC = 15\n/** The range of a UGC script's length, in whole seconds: the script route's, and a plan's own. */\nexport const UGC_SCRIPT_MIN_TARGET_SEC = 4\nexport const UGC_SCRIPT_MAX_TARGET_SEC = 300\n\nconst MINOR_AGE_MESSAGE = \"That age can't be used: UGC creators are adults only.\"\nconst NEEDS_GENDER = \"Choose woman or man.\"\nconst NEEDS_PHOTO = \"Connect or upload a photo of yourself.\"\nconst NEEDS_CATEGORY = \"Run UGC Script first, or pick a product category.\"\nconst NEEDS_SITE = \"Add the product name or website.\"\n/** The opening of the sentence UGC Clips fails with when the plugin refuses the script: \"<this> <each error and its fix>\". */\nexport const UGC_SCRIPT_NEEDS_CHANGES = \"The script needs changes:\"\nconst NEEDS_PLAN_OUT = \"Connect the Script (sized) output of UGC Clips.\"\nconst NEEDS_PLAN = \"Connect the Script output of UGC Script.\"\nconst NEEDS_TICKET = \"Connect the Clips output of UGC Clips.\"\nconst NEEDS_VIDEO = \"Connect the joined video.\"\nconst NEEDS_TRANSCRIPT = \"Connect the Transcript output of UGC Clips.\"\n/**\n * A run of a video whose clips are cut from one recorded speech, on a graph with no UGC Finish on this UGC\n * Clips' Script (sized) output: refused before anything is spent.\n */\nexport const UGC_NEEDS_FINISH_MESSAGE = \"Add a UGC Finish node after UGC Clip, and connect UGC Clips' Script (sized) output to it.\"\n/** UGC Finish with nothing on its clips input. */\nexport const UGC_FINISH_NEEDS_CLIPS_MESSAGE = \"Connect the Video output of UGC Clip.\"\n/** UGC Finish's job answered that a clip does not follow its speech (each clip checks itself first, so this is rare). */\nexport const UGC_FINISH_NOT_READY_MESSAGE = \"A clip did not follow its speech. Re-render it from the UGC Clip node and run again.\"\n/**\n * A video cut from one recorded speech whose clips, priced once the speech is split, would hold more\n * than the run was checked for before it started: the run stops at UGC Clips, before any clip renders.\n */\nexport const UGC_OVER_HOLD_MESSAGE =\n \"The clips for this recording would cost more than this run was checked for, so none was rendered. Run UGC Clips again to record the speech again.\"\n\n/**\n * Every fixed sentence a UGC node fails with, by id: the English both engines write on the node.\n * The editor shows each in the person's language by its id. Not listed: the sentence that opens\n * with `UGC_SCRIPT_NEEDS_CHANGES` (the plugin's own words finish it), a route's own message, and\n * \"UGC step failed (<status>)\".\n */\nexport const UGC_NODE_MESSAGES = Object.freeze({\n notServed: UGC_NOT_SERVED_MESSAGE,\n version: UGC_VERSION_MESSAGE,\n newerApp: UGC_NEWER_APP_MESSAGE,\n pickGone: UGC_PICK_GONE_MESSAGE,\n creatorMissing: UGC_CREATOR_MISSING_MESSAGE,\n minorAge: MINOR_AGE_MESSAGE,\n needsGender: NEEDS_GENDER,\n needsPhoto: NEEDS_PHOTO,\n needsCategory: NEEDS_CATEGORY,\n needsSite: NEEDS_SITE,\n needsPlanOut: NEEDS_PLAN_OUT,\n needsPlan: NEEDS_PLAN,\n needsTicket: NEEDS_TICKET,\n needsVideo: NEEDS_VIDEO,\n needsTranscript: NEEDS_TRANSCRIPT,\n needsFinish: UGC_NEEDS_FINISH_MESSAGE,\n finishNeedsClips: UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n finishNotReady: UGC_FINISH_NOT_READY_MESSAGE,\n overHold: UGC_OVER_HOLD_MESSAGE,\n} as const)\n\n/** The id of a fixed sentence a UGC node fails with (`UGC_NODE_MESSAGES`). */\nexport type UgcNodeMessageId = keyof typeof UGC_NODE_MESSAGES\n\n/** UGC Script's screenshot inputs, in card order. */\nexport const UGC_SCREENSHOT_HANDLES: readonly string[] = [\n \"screenshot\", \"screenshot2\", \"screenshot3\", \"screenshot4\", \"screenshot5\", \"screenshot6\", \"screenshot7\", \"screenshot8\",\n]\n\n/** Per UGC type, the output an edge with no source handle reads. */\nexport const UGC_PRIMARY_HANDLE: Readonly<Record<string, string>> = {\n \"ugc-creator\": \"creator\",\n \"ugc-script\": \"plan\",\n \"ugc-clips\": \"clips\",\n \"ugc-clip\": \"video-out\",\n \"ugc-cards\": \"layerPlan\",\n \"ugc-finish-clips\": \"video-out\",\n}\n\n/** A UGC node's outputs: handle id → the value that handle carries (a JSON string, text or a URL). */\nexport type UgcOutputs = Readonly<Record<string, string>>\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/**\n * The length a saved UGC plan was written to: its own `targetDurationSec`, a whole number of\n * seconds in the script's range. Besides the lines (the opening line, each beat's line, the\n * closing line), one of the two keys of a plan the app reads (the other: whether each beat carries\n * a screenshot, `ugcPlanScreenshotCount`): a script that hands on its saved plan is priced at the\n * plan's length, and shows it, never at the length setting, which may have changed since. Takes\n * the plan or its wire (a JSON string); undefined for anything that is not a plan carrying a length.\n */\nexport function ugcPlanLengthSec(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value) return undefined\n const sec = value.targetDurationSec\n return typeof sec === \"number\" && Number.isInteger(sec) && sec >= UGC_SCRIPT_MIN_TARGET_SEC && sec <= UGC_SCRIPT_MAX_TARGET_SEC ? sec : undefined\n}\n\n/**\n * How many of a saved UGC plan's beats carry a screenshot: the screenshot cards the plan was\n * written with. Read beat by beat: a beat carries one when its `screenshot` is an object, as the\n * plan's own screenshots are (whatever it names); a beat that is not an object, or whose screenshot\n * is anything else, carries none — and never makes the rest unreadable. A plan whose beats carry\n * none is a talking-head plan (0). Read, like its length, so a script that hands on its saved plan\n * is priced at the screenshots that plan holds, never at the script's wires, which may have changed\n * since. Takes the plan or its wire (a JSON string); undefined only for a plan with no beats to read\n * and for anything that is not a plan.\n */\nexport function ugcPlanScreenshotCount(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value || !Array.isArray(value.beats)) return undefined\n return value.beats.filter((beat) => isObject(beat) && isObject(beat.screenshot)).length\n}\n\n/** A saved plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction savedPlanOf(plan: unknown): Obj | undefined {\n let value: unknown = plan\n if (typeof value === \"string\") {\n try {\n value = JSON.parse(value)\n } catch {\n return undefined\n }\n }\n return isObject(value) ? value : undefined\n}\n/** A string with something in it; an empty or blank field or input counts as absent. */\nconst filled = (x: unknown): string | undefined => (typeof x === \"string\" && x.trim() !== \"\" ? x : undefined)\n\n/**\n * What an edge from a UGC node reads, on both engines: the value of the pip it leaves — an edge\n * with no source handle reads the node's primary output — from the node's outputs by pip. Only a\n * pip the outputs hold as a string (\"\" included: an empty transcript is a value); an inherited\n * key or a non-string is no value.\n */\nexport function ugcPipValue(outputs: unknown, sourceType: string, sourceHandle?: string | null): string | undefined {\n const pip = sourceHandle || (Object.hasOwn(UGC_PRIMARY_HANDLE, sourceType) ? UGC_PRIMARY_HANDLE[sourceType] : undefined)\n if (pip === undefined || !isObject(outputs) || !Object.hasOwn(outputs, pip)) return undefined\n const value = outputs[pip]\n return typeof value === \"string\" ? value : undefined\n}\n\n/**\n * A UGC wire (a JSON string or an object) → its value when it is an object with `v: 1`.\n * Another `v` → the version message. Anything that is not a UGC wire at all (nothing\n * connected, not JSON, no `v`) → `unreadable`, which a node words as the input it needs.\n */\nexport function readUgcWire(raw: unknown, unreadable: string = UGC_VERSION_MESSAGE): { value: Record<string, unknown> } | { error: string } {\n let parsed: unknown = raw\n if (typeof raw === \"string\") {\n try {\n parsed = JSON.parse(raw)\n } catch {\n return { error: unreadable }\n }\n }\n if (!isObject(parsed) || parsed.v === undefined) return { error: unreadable }\n if (parsed.v !== 1) return { error: UGC_VERSION_MESSAGE }\n return { value: parsed }\n}\n\n/** The route's `{ error: { code, message } }` (or a framework error's top-level `message`). */\nfunction routeErrorOf(body: string): { code?: string; message?: string } {\n let parsed: unknown\n try {\n parsed = JSON.parse(body)\n } catch {\n return {}\n }\n if (!isObject(parsed)) return {}\n if (isObject(parsed.error)) {\n const { code, message } = parsed.error\n return { code: typeof code === \"string\" ? code : undefined, message: filled(message) }\n }\n return { message: filled(parsed.message) }\n}\n\n/**\n * A failed UGC call → the sentence the node fails with. A 404 that names no error code is\n * the router's (the route is not registered here) → the Cloud sentence; a route's own 404\n * names a code and keeps its message. `minor_age_refused` → the adults-only sentence. A 4xx\n * or 503 → the route's message. Anything else → \"UGC step failed (<status>)\".\n */\nexport function ugcFailure(status: number, body: string): string {\n const error = routeErrorOf(body)\n if (status === 404 && error.code === undefined) return UGC_NOT_SERVED_MESSAGE\n if (error.code === \"minor_age_refused\") return MINOR_AGE_MESSAGE\n if ((status === 503 || (status >= 400 && status < 500)) && error.message) return error.message\n return `UGC step failed (${status})`\n}\n\n// ── UGC Creator ──────────────────────────────────────────────────────────────\n\n/**\n * The pickers whose own set fields shape a sampled creator: the picker types UGC Creator's\n * `pickers` input takes (the route takes no other). One list for the editor's connection rule\n * and both engines' input resolvers.\n */\nexport const UGC_CREATOR_PICKER_TYPES: ReadonlySet<string> = new Set([\"person\", \"styling\", \"setting\", \"lighting\"])\n\n/** The UGC Creator node-data keys its request body reads. */\nexport interface UgcCreatorFields {\n readonly source?: string\n readonly gender?: string\n readonly photoUrl?: string\n readonly categoryOverride?: string\n readonly seed?: number\n readonly keepResult?: boolean\n readonly result?: Readonly<Record<string, unknown>>\n /** The options a draw left waiting for the pick (run state): read only for `previous`. */\n readonly candidates?: unknown\n}\n\n/** The traits of the latest creator the person saw: the first waiting option's, else the last result's (Keep off). */\nfunction previousTraits(data: UgcCreatorFields): unknown {\n if (ugcPickPending(data)) {\n const first: unknown = (data.candidates as readonly unknown[])[0]\n const record = isObject(first) ? first.record : undefined\n return isObject(record) ? record.traits : undefined\n }\n return !data.keepResult && isObject(data.result) ? data.result.traits : undefined\n}\n\n/** The wired pickers that set a field (their own fields, as the resolver read them); undefined when none did. */\nfunction setPickers(pickers: Record<string, Record<string, unknown>> | undefined): Record<string, Record<string, unknown>> | undefined {\n if (!pickers) return undefined\n const set = Object.entries(pickers).filter(([, fields]) => isObject(fields) && Object.keys(fields).length > 0)\n return set.length > 0 ? Object.fromEntries(set) : undefined\n}\n\n/**\n * The `/v1/ugc/creator` body. A photo: the wired photo, else the node's own. A sampled\n * creator: the product category (the node's override, else the wired one), the pickers that\n * set a field, the node's seed, and the traits of the latest creator the person saw as\n * `previous`, so the next one differs: the first option waiting for the pick, else — on a\n * re-run that does not keep the result — the last creator's. Refuses before any call.\n */\nexport function ugcCreatorBody(input: {\n data: UgcCreatorFields\n photoUrl?: string\n category?: string\n pickers?: Record<string, Record<string, unknown>>\n}): { body: Record<string, unknown> } | { error: string } {\n const { data } = input\n const gender = data.gender\n if (gender !== \"woman\" && gender !== \"man\") return { error: NEEDS_GENDER }\n if (data.source === \"photo\") {\n const imageUrl = filled(input.photoUrl) ?? filled(data.photoUrl)\n if (!imageUrl) return { error: NEEDS_PHOTO }\n return { body: { source: { kind: \"photo\", imageUrl, gender } } }\n }\n const productCategory = filled(data.categoryOverride) ?? filled(input.category)\n if (!productCategory) return { error: NEEDS_CATEGORY }\n const pickers = setPickers(input.pickers)\n const traits = previousTraits(data)\n return {\n body: {\n ...(typeof data.seed === \"number\" ? { seed: data.seed } : {}),\n source: {\n kind: \"sampled\",\n gender,\n productCategory,\n ...(pickers ? { pickers } : {}),\n ...(isObject(traits) ? { previous: traits } : {}),\n },\n },\n }\n}\n\n/**\n * The creator the node hands on: the record (`creator`, v1) and its first image (`image`).\n * `identityImages` are the images of the candidate the node hands on — the picked one where\n * a person picked. The record copies the listed fields only, so `candidates`, `fallback`,\n * `pick` and `image` never reach the `creator` wire.\n */\nexport function ugcCreatorOutputs(answer: Record<string, unknown>, identityImages: readonly string[]): { outputs: UgcOutputs; imageUrl: string; record: Record<string, unknown> } {\n const record: Record<string, unknown> = {\n v: 1,\n kind: answer.kind,\n gender: answer.gender,\n identityImages: [...identityImages],\n traits: answer.traits ?? null,\n seed: answer.seed ?? null,\n promptsVersion: answer.promptsVersion,\n productCategory: answer.productCategory ?? null,\n }\n const imageUrl = identityImages[0] ?? \"\"\n return { outputs: { creator: JSON.stringify(record), ...(imageUrl ? { image: imageUrl } : {}) }, imageUrl, record }\n}\n\n/** One builder call as the app runs it: `tool` and `args`, nothing else (a candidate's other keys, its model included, are never read). */\nexport interface UgcCreatorCall { readonly tool: string; readonly args: Readonly<Record<string, unknown>> }\n\n/** What a creator answer asks the node to render. */\nexport interface UgcCreatorCandidateCalls {\n /** Every candidate's image call, the primary first. One call (`image`) for an answer from before candidates; none for a photo. */\n readonly calls: readonly UgcCreatorCall[]\n /** The round's one moderation fallback: it runs once, and only when every candidate the run rendered was blocked. */\n readonly fallback: UgcCreatorCall | null\n /** \"user\": a person picks among `calls` where one can be asked; \"primary\": `calls[0]` alone; null: nothing to render (a photo). */\n readonly pick: \"user\" | \"primary\" | null\n}\n\nconst callOf = (raw: unknown): UgcCreatorCall | undefined => {\n if (!raw || typeof raw !== \"object\") return undefined\n const { tool, args } = raw as { tool?: unknown; args?: unknown }\n if (typeof tool !== \"string\" || !args || typeof args !== \"object\" || Array.isArray(args)) return undefined\n return { tool, args: args as Readonly<Record<string, unknown>> }\n}\nconst fallbackOf = (image: unknown): unknown => (image && typeof image === \"object\" ? (image as { fallback?: unknown }).fallback : undefined)\n\n/**\n * A `/v1/ugc/creator` answer's image calls. Content-free: reads `image` (`tool`, `args`,\n * `fallback`), `candidates[].tool|args`, `fallback` and `pick.how` — never a candidate's\n * model. An answer without `candidates` (an older builder) renders `image` alone, as before.\n */\nexport function ugcCreatorCandidates(answer: Readonly<Record<string, unknown>>): UgcCreatorCandidateCalls | { readonly error: string } {\n const listed = answer.candidates\n const noList = listed === undefined || listed === null || (Array.isArray(listed) && listed.length === 0)\n const noImage = answer.image === undefined || answer.image === null\n if (noList && noImage) return { calls: [], fallback: null, pick: null }\n if (noList) {\n const image = callOf(answer.image)\n if (!image) return { error: UGC_NEWER_APP_MESSAGE }\n return { calls: [image], fallback: callOf(fallbackOf(answer.image)) ?? null, pick: \"primary\" }\n }\n if (!Array.isArray(listed)) return { error: UGC_NEWER_APP_MESSAGE }\n const calls = listed.map(callOf)\n if (calls.some((c) => c === undefined)) return { error: UGC_NEWER_APP_MESSAGE }\n const how = (answer.pick as { how?: unknown } | null | undefined)?.how\n return {\n calls: calls as UgcCreatorCall[],\n fallback: callOf(answer.fallback) ?? callOf(fallbackOf(answer.image)) ?? null,\n pick: how === \"user\" && calls.length > 1 ? \"user\" : \"primary\",\n }\n}\n\n/** The calls a run renders: every candidate where a person is there to pick, else the primary alone. */\nexport function ugcCreatorCallsToRender(c: UgcCreatorCandidateCalls, opts: { readonly personPicks: boolean }): readonly UgcCreatorCall[] {\n return opts.personPicks && c.pick === \"user\" ? c.calls : c.calls.slice(0, 1)\n}\n\n/** One rendered candidate that passed its checks, kept on the node until the person picks (run state, never a wire). */\nexport interface UgcCreatorCandidate { readonly imageUrl: string; readonly record: Readonly<Record<string, unknown>> }\n\nexport function ugcCreatorCandidate(answer: Readonly<Record<string, unknown>>, images: readonly string[]): UgcCreatorCandidate {\n const out = ugcCreatorOutputs(answer as Record<string, unknown>, images)\n return { imageUrl: out.imageUrl, record: out.record }\n}\n\n/** A UGC Creator run output that waits for the person's pick: two or more options (`ugcCandidates`). */\nexport function ugcAwaitsPick(output: unknown): boolean {\n const candidates = isObject(output) ? output.ugcCandidates : undefined\n return Array.isArray(candidates) && candidates.length >= 2\n}\n\n/** The person's pick, read back from node data (untrusted): a stale index, a foreign list or another version is refused. */\nexport function ugcCreatorPick(candidates: unknown, index: number):\n { readonly result: Readonly<Record<string, unknown>>; readonly outputs: UgcOutputs; readonly imageUrl: string } | { readonly error: string } {\n const entry: unknown = Array.isArray(candidates) && Number.isInteger(index) && index >= 0 ? candidates[index] : undefined\n const imageUrl = (entry as { imageUrl?: unknown } | undefined)?.imageUrl\n const record = (entry as { record?: unknown } | undefined)?.record\n if (typeof imageUrl !== \"string\" || !record || typeof record !== \"object\" || Array.isArray(record)) return { error: UGC_PICK_GONE_MESSAGE }\n const r = record as Record<string, unknown>\n if (r.v !== 1) return { error: UGC_VERSION_MESSAGE }\n if (!Array.isArray(r.identityImages) || r.identityImages[0] !== imageUrl) return { error: UGC_PICK_GONE_MESSAGE }\n return { result: r, outputs: { creator: JSON.stringify(r), image: imageUrl }, imageUrl }\n}\n\n// ── UGC Script ───────────────────────────────────────────────────────────────\n\n/** The languages a UGC script can be written in: the node's choice (`UgcScriptData.language`). */\nexport const UGC_SCRIPT_LANGUAGES = [\"en\", \"he\"] as const\nexport type UgcScriptLanguage = (typeof UGC_SCRIPT_LANGUAGES)[number]\n\n/**\n * The `/v1/ugc/script` body: the product name or website (required), the screenshot slots\n * in card order with the empty ones dropped, the product image when set, the target length\n * (`UGC_SCRIPT_DEFAULT_TARGET_SEC` when the node holds no number), and the language (the\n * node's choice; English when it holds none or one this app does not know).\n */\nexport function ugcScriptBody(input: {\n site?: string\n screenshots: ReadonlyArray<string | undefined>\n productImage?: string\n targetDurationSec?: number\n language?: unknown\n}): { body: Record<string, unknown> } | { error: string } {\n const site = filled(input.site)?.trim()\n if (!site) return { error: NEEDS_SITE }\n const productImage = filled(input.productImage)\n return {\n body: {\n site,\n screenshots: input.screenshots.filter((s): s is string => filled(s) !== undefined),\n ...(productImage ? { productImage } : {}),\n targetDurationSec: typeof input.targetDurationSec === \"number\" ? input.targetDurationSec : UGC_SCRIPT_DEFAULT_TARGET_SEC,\n language: (UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(input.language) ? input.language : \"en\",\n },\n }\n}\n\n/** A finished UGC Script job → `plan` (the plan, v1) and `category` (text). */\nexport function ugcScriptOutputs(outputData: Record<string, unknown>): UgcOutputs {\n const plan = outputData.plan\n const category = filled(outputData.productCategory)\n return {\n ...(isObject(plan) ? { plan: JSON.stringify({ v: 1, ...plan }) } : {}),\n ...(category ? { category } : {}),\n }\n}\n\n/** UGC Script's last result, as the node holds it. */\nexport type UgcScriptResult = {\n plan: Record<string, unknown>\n productCategory: string\n warnings: unknown[]\n notes: string[]\n rounds: number\n}\n\n/** A finished UGC Script job → the node's `result`, written the same by both engines; none without a plan. */\nexport function ugcScriptResult(outputData: Readonly<Record<string, unknown>>): UgcScriptResult | undefined {\n const { plan, productCategory, warnings, notes, rounds } = outputData\n if (!isObject(plan)) return undefined\n return {\n plan,\n productCategory: filled(productCategory) ?? \"\",\n warnings: Array.isArray(warnings) ? [...warnings] : [],\n notes: Array.isArray(notes) ? notes.filter((n): n is string => typeof n === \"string\") : [],\n rounds: typeof rounds === \"number\" && Number.isFinite(rounds) ? rounds : 0,\n }\n}\n\n// ── Kept results ─────────────────────────────────────────────────────────────\n\n/**\n * What a UGC Creator or UGC Script with Keep on hands on instead of running: the outputs of\n * the result it holds. Null — the node runs — when Keep is off, when the result holds nothing\n * to hand on (a creator without its image, a script without its plan), and for a creator whose\n * options wait for a pick, whatever Keep says. The creator record goes on unread; whoever reads\n * it refuses another version.\n */\nexport function ugcKeptOutputs(type: \"ugc-creator\" | \"ugc-script\", data: Readonly<Record<string, unknown>>): UgcOutputs | null {\n if (type === \"ugc-creator\" && ugcPickPending(data)) return null\n const result = data.keepResult === true ? data.result : undefined\n if (!isObject(result)) return null\n if (type === \"ugc-creator\") {\n const image = Array.isArray(result.identityImages) ? filled(result.identityImages[0]) : undefined\n return image ? { creator: JSON.stringify(result), image } : null\n }\n if (type === \"ugc-script\") return isObject(result.plan) ? ugcScriptOutputs(result) : null\n return null\n}\n\n// ── UGC Clips ────────────────────────────────────────────────────────────────\n\n/** The `/v1/ugc/clips` canvas body: the plan, the creator's gender, traits and images, and the picked voice. */\nexport function ugcClipsBody(input: { planWire: unknown; creatorWire: unknown; voiceId?: string }): { body: Record<string, unknown> } | { error: string } {\n const plan = readUgcWire(input.planWire, NEEDS_PLAN)\n if (\"error\" in plan) return plan\n const creator = readUgcWire(input.creatorWire, UGC_CREATOR_MISSING_MESSAGE)\n if (\"error\" in creator) return creator\n const voiceId = filled(input.voiceId)\n return {\n body: {\n plan: plan.value,\n gender: creator.value.gender,\n traits: creator.value.traits ?? null,\n identityImages: creator.value.identityImages,\n surface: \"canvas\",\n ...(voiceId ? { voiceId } : {}),\n },\n }\n}\n\n/**\n * The `/v1/ugc/clips` answer → the tickets (one per clip, as JSON strings), `clips` (the\n * first), `plan-out` (`{ v: 1, plan, transcribeArgs }` for UGC Cards), `transcript`, whether\n * the plan has cards, and whether the clips go through UGC Finish's job (`finishes`: the plan-out\n * carries a finish call, which is what UGC Finish reads to run it). An answer with errors → \"The script needs changes: …\" with each\n * error and its fix; an answer without the parts UGC Cards needs fails here, before any clip\n * is paid for.\n */\nexport function ugcClipsOutputs(answer: Record<string, unknown>): { outputs: UgcOutputs; tickets: string[]; hasCards: boolean; finishes: boolean } | { error: string } {\n const errors = Array.isArray(answer.errors) ? answer.errors : []\n if (errors.length > 0) {\n const said = errors.flatMap((e) => (isObject(e) ? [filled(e.message), filled(e.fix)] : [])).filter((s): s is string => s !== undefined)\n return { error: said.length > 0 ? `${UGC_SCRIPT_NEEDS_CHANGES} ${said.join(\" \")}` : UGC_NEWER_APP_MESSAGE }\n }\n const { tickets, sizedPlan, transcript, speechCheckCall } = answer\n if (!Array.isArray(tickets) || tickets.length === 0 || !tickets.every(isObject) || !isObject(sizedPlan) || typeof transcript !== \"string\") {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n const wires = tickets.map((t) => JSON.stringify(t))\n // The speech check's arguments ride to UGC Cards' transcription unread (an answer without them: none).\n const transcribeArgs = isObject(speechCheckCall) && isObject(speechCheckCall.args) ? speechCheckCall.args : {}\n // A video cut from one recorded speech (the segmented lane) also hands UGC Finish its finish call's\n // arguments (the segments with their room), opaque; any other answer's plan-out is unchanged.\n const finish = isObject(answer.finish) && isObject(answer.finish.args) ? { finish: answer.finish.args } : {}\n return {\n outputs: { clips: wires[0]!, \"plan-out\": JSON.stringify({ v: 1, plan: sizedPlan, transcribeArgs, ...finish }), transcript },\n tickets: wires,\n hasCards: answer.hasCards === true,\n finishes: \"finish\" in finish,\n }\n}\n\n// ── UGC Clip ─────────────────────────────────────────────────────────────────\n\n/**\n * The `/v1/ugc/clip` body for one ticket: the ticket, `nonce` = how many times this clip was\n * re-rendered (`rerender[\"<clip number>\"]`, else 0) and `runKey` when one is given.\n */\nexport function ugcClipBody(input: { ticketWire: unknown; rerender?: Readonly<Record<string, number>>; runKey?: string }):\n { body: Record<string, unknown>; clipNumber: number; durationSec: number } | { error: string } {\n const read = readUgcWire(input.ticketWire, NEEDS_TICKET)\n if (\"error\" in read) return read\n const ticket = read.value\n const { index, durationSec } = ticket\n if (typeof index !== \"number\" || !Number.isInteger(index) || index < 0) return { error: NEEDS_TICKET }\n if (typeof durationSec !== \"number\" || !Number.isFinite(durationSec) || durationSec <= 0) return { error: NEEDS_TICKET }\n const clipNumber = index + 1\n const count = input.rerender?.[String(clipNumber)]\n const nonce = typeof count === \"number\" && Number.isInteger(count) && count >= 0 ? count : 0\n const runKey = filled(input.runKey)\n return { body: { ticket, nonce, ...(runKey ? { runKey } : {}) }, clipNumber, durationSec }\n}\n\n/**\n * A finished UGC Clip job (`{ videoUrl, durationSec, clipWarnings, … }`) → `video-out`, the\n * clip's real length (null when unknown) and its warnings ([] when it has none).\n */\nexport function ugcClipOutputs(outputData: Record<string, unknown>): { outputs: UgcOutputs; videoUrl: string; durationSec: number | null; clipWarnings: string[] } {\n const videoUrl = filled(outputData.videoUrl) ?? \"\"\n const meta = fanOutItemMeta(outputData)\n return { outputs: videoUrl ? { \"video-out\": videoUrl } : {}, videoUrl, durationSec: meta.durationSec, clipWarnings: [...meta.warnings] }\n}\n\n/**\n * What a list read (a Bundle edge, a fold) takes from a UGC Clip's saved data, on both engines:\n * its last fanned-out batch — one take per clip, in clip order — when its last run was one; else\n * exactly the take it shows (its active result, else its video). Never the earlier takes it keeps:\n * a video of one clip (one ticket, so no fan-out) would join every take. A single run clears the\n * batch (the editor's job patch), so a batch held is always the last run's. Undefined when it holds\n * no take at all.\n */\nexport function ugcClipSavedList(data: unknown): string[] | undefined {\n if (!isObject(data)) return undefined\n const batch = Array.isArray(data.__listResults) ? data.__listResults.filter((u): u is string => typeof u === \"string\" && u !== \"\") : []\n if (batch.length > 0) return batch\n const results = Array.isArray(data.generatedResults) ? data.generatedResults : []\n const index = typeof data.activeResultIndex === \"number\" && Number.isInteger(data.activeResultIndex) ? data.activeResultIndex : 0\n const active = results[index]\n const url = (isObject(active) ? filled(active.url) : undefined) ?? filled(data.generatedVideoUrl)\n return url ? [url] : undefined\n}\n\n// ── UGC Cards ────────────────────────────────────────────────────────────────\n\n/**\n * UGC Cards' two timing jobs on the joined video, and the plan they time. The plan input must\n * be UGC Clips' `{ v: 1, plan, transcribeArgs }`; anything else is refused before either job.\n * The transcription spreads `transcribeArgs` unread, then sets the node's own fields last, so\n * the wire can add a language but never change the provider or the word timings.\n */\nexport function ugcCardsJobs(input: { planOutWire: unknown; videoUrl?: string; transcript?: string }): {\n alignment: { path: \"/v1/forced-alignment\"; body: Record<string, unknown> }\n transcribe: { path: \"/v1/transcribe\"; body: Record<string, unknown> }\n plan: Record<string, unknown>\n} | { error: string } {\n const read = readUgcWire(input.planOutWire, NEEDS_PLAN_OUT)\n if (\"error\" in read) return read\n const { plan, transcribeArgs } = read.value\n if (!isObject(plan) || !isObject(transcribeArgs)) return { error: NEEDS_PLAN_OUT }\n const videoUrl = filled(input.videoUrl)\n if (!videoUrl) return { error: NEEDS_VIDEO }\n // An empty transcript is what UGC Clips said, not a missing input: it goes on as it came.\n const transcript = input.transcript\n if (typeof transcript !== \"string\") return { error: NEEDS_TRANSCRIPT }\n return {\n alignment: { path: \"/v1/forced-alignment\", body: { audioUrl: videoUrl, transcript } },\n transcribe: { path: \"/v1/transcribe\", body: { ...transcribeArgs, audioUrl: videoUrl, provider: DEFAULT_TRANSCRIBE_NODE_PROVIDER, wordTimestamps: true } },\n plan,\n }\n}\n\n/**\n * The `/v1/ugc/cards` canvas body: the plan, the video, whichever timing came back as a list,\n * the timing jobs that failed, and the clips' notes.\n */\nexport function ugcCardsBody(input: {\n plan: Record<string, unknown>\n videoUrl: string\n alignment?: unknown\n words?: unknown\n failed: ReadonlyArray<\"alignment\" | \"words\">\n clipNotes: ReadonlyArray<ClipNote>\n}): Record<string, unknown> {\n return {\n surface: \"canvas\",\n plan: input.plan,\n videoUrl: input.videoUrl,\n ...(Array.isArray(input.alignment) ? { alignment: input.alignment } : {}),\n ...(Array.isArray(input.words) ? { words: input.words } : {}),\n failed: [...input.failed],\n clipNotes: [...input.clipNotes],\n }\n}\n\n/** The caption plan when nothing could be timed: Add Captions renders no captions from it. */\nconst EMPTY_CAPTION_PLAN: CaptionPlan = { v: 1, hookText: \"\", hookEndMs: 0, bodyEndMs: 0, captions: [] }\n\n/** The `/v1/ugc/cards` answer → `layerPlan`, `captionPlan` (v1; the empty plan when untimed) and `report` (one line per sentence). */\nexport function ugcCardsOutputs(answer: Record<string, unknown>): UgcOutputs {\n const timing = answer.captionTiming\n const report = answer.report\n const lines = isObject(report) && Array.isArray(report.lines) ? report.lines.filter((l): l is string => typeof l === \"string\") : []\n return {\n layerPlan: JSON.stringify(Array.isArray(answer.layerPlan) ? answer.layerPlan : []),\n captionPlan: JSON.stringify(isObject(timing) ? { v: 1, ...timing } : EMPTY_CAPTION_PLAN),\n report: lines.join(\"\\n\"),\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/fan-out-meta.ts","../src/ugc-run-state.ts","../src/ugc-node-wires.ts"],"names":[],"mappings":";;;AAKO,SAAS,eAAe,MAAA,EAA8F;AAC3H,EAAA,MAAM,IAAI,MAAA,EAAQ,YAAA;AAClB,EAAA,MAAM,IAAI,MAAA,EAAQ,WAAA;AAClB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,GAAI,CAAA,CAAE,MAAA,CAAO,CAAC,CAAA,KAAmB,OAAO,CAAA,KAAM,QAAQ,IAAI,EAAC;AAAA,IACpF,WAAA,EAAa,OAAO,CAAA,KAAM,QAAA,IAAY,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI;AAAA,GAC1E;AACF;AAGO,SAAS,aAAA,CAAc,MAAoE,MAAA,EAAqC;AACrI,EAAA,MAAM,IAAA,GAAO,IAAA,IAAQ,IAAA,CAAK,MAAA,GAAS,CAAA,GAAI,OAAO,MAAA,GAAS,CAAC,MAAM,CAAA,GAAI,EAAC;AACnE,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,CAAC,CAAA,EAAG,CAAA,MAAO;AAAA,IACzB,MAAM,CAAA,GAAI,CAAA;AAAA,IACV,QAAA,EAAU,CAAA,EAAG,QAAA,IAAY,EAAC;AAAA,IAC1B,GAAI,OAAO,CAAA,EAAG,WAAA,KAAgB,QAAA,GAAW,EAAE,WAAA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EAAU,EAAA,EAAI,SAAA,EAAW,CAAA,EAAG,SAAA,EAAW,CAAA,EAAG,QAAA,EAAU,EAAC,EAAE;AAGhG,SAAS,gBAAgB,MAAA,EAA6C;AAC3E,EAAA,MAAM,SAAS,MAAA,CAAO,aAAA;AACtB,EAAA,MAAM,SAAS,MAAA,CAAO,MAAA;AACtB,EAAA,MAAM,QAAQ,QAAA,CAAS,MAAM,KAAK,KAAA,CAAM,OAAA,CAAQ,OAAO,KAAK,CAAA,GAAI,MAAA,CAAO,KAAA,CAAM,OAAO,CAAC,CAAA,KAAmB,OAAO,CAAA,KAAM,QAAQ,IAAI,EAAC;AAClI,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,IAAA,CAAK,SAAA,CAAU,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,GAAI,MAAA,CAAO,SAAA,GAAY,EAAE,CAAA;AAAA,IACjF,WAAA,EAAa,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,MAAM,CAAA,GAAI,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,MAAA,EAAO,GAAI,kBAAkB,CAAA;AAAA,IACvF,MAAA,EAAQ,KAAA,CAAM,IAAA,CAAK,IAAI;AAAA,GACzB;AACF","file":"chunk-I2RQB7VG.js","sourcesContent":["/** One fan-out item's notes: its warnings and its real length (UGC Clip). */\nexport interface FanOutItemMeta { readonly warnings: readonly string[]; readonly durationSec: number | null }\n/** One row of UGC Cards' `notes` input. */\nexport interface ClipNote { readonly clip: number; readonly warnings: readonly string[]; readonly durationSec?: number }\n\nexport function fanOutItemMeta(output: { clipWarnings?: unknown; durationSec?: unknown } | null | undefined): FanOutItemMeta {\n const w = output?.clipWarnings\n const d = output?.durationSec\n return {\n warnings: Array.isArray(w) ? w.filter((x): x is string => typeof x === \"string\") : [],\n durationSec: typeof d === \"number\" && Number.isFinite(d) && d > 0 ? d : null,\n }\n}\n\n/** Row-aligned meta (or one single output) → the notes UGC Cards reads, clip numbers from 1. */\nexport function clipNotesFrom(meta: ReadonlyArray<FanOutItemMeta | null | undefined> | undefined, single?: FanOutItemMeta): ClipNote[] {\n const rows = meta && meta.length > 0 ? meta : single ? [single] : []\n return rows.map((m, i) => ({\n clip: i + 1,\n warnings: m?.warnings ?? [],\n ...(typeof m?.durationSec === \"number\" ? { durationSec: m.durationSec } : {}),\n }))\n}\n","/** The UGC node types (Cloud only; served by a private plugin). */\nexport const UGC_NODE_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\", \"ugc-clips\", \"ugc-clip\", \"ugc-cards\", \"ugc-finish-clips\"])\n\n/** UGC Creator: the node-data key that holds a round's passing candidates until the person picks one (run state). */\nexport const UGC_CREATOR_CANDIDATES_KEY = \"candidates\"\n\n/** A run that would execute a UGC Creator whose options wait for the person's pick. */\nexport const UGC_PICK_FIRST_MESSAGE = \"Pick a creator first.\"\n\n/**\n * Per UGC type, the node-data keys that are a RUN's state, never a choice. A\n * published app's snapshot is readable by every runner, so publishing strips\n * them (the last plan, the clip tickets, the publisher's kept creator).\n *\n * UGC Creator's image (`generatedImageUrl`) goes from every creator, whatever its\n * source: after a My photo run it IS the author's photo, and a creator switched\n * to another source after such a run, or whose photo was removed, still holds it.\n * UGC Clip's takes and UGC Cards' Notes (`generatedText`, and `text`, the Notes\n * as a run hands them on) are the author's renders: a published node starts empty.\n *\n * A published snapshot is stripped through `stripUgcPublishState`\n * (@nodaro/render-rules), which also empties every run result a lane writes under\n * a generic name, every node made from the UGC video, and every node on a path\n * into a UGC Creator's photo input.\n */\nexport const UGC_NODE_RUN_STATE_KEYS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"result\", \"keepResult\", \"ugcOutputs\", UGC_CREATOR_CANDIDATES_KEY, \"optionFailed\", \"generatedImageUrl\"],\n // `exampleLines`: a template's example run, shown until the node's own first script (display only).\n \"ugc-script\": [\"result\", \"keepResult\", \"ugcOutputs\", \"exampleLines\"],\n \"ugc-clips\": [\"result\", \"quote\", \"__listResults\", \"ugcOutputs\"],\n \"ugc-clip\": [\n \"warnings\", \"rerender\", \"rerenderPending\", \"__listResults\", \"__listResultMeta\", \"clipWarnings\", \"durationSec\", \"ugcOutputs\",\n \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\",\n ],\n \"ugc-cards\": [\"result\", \"ugcOutputs\", \"generatedText\", \"text\"],\n \"ugc-finish-clips\": [\"ugcOutputs\", \"__listResults\", \"__listResultMeta\", \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\"],\n}\n\n/**\n * The ONLY UGC keys a run request's `inputOverrides` may set — an allow-list,\n * so a run-state field added later is locked without anyone listing it.\n *\n * No UGC type may gain a `LEGACY_EXPOSED_FIELD_KEYS` row: the lock reads the\n * stored key, before that table renames it.\n */\nexport const UGC_OVERRIDABLE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"source\", \"gender\", \"photoUrl\"],\n \"ugc-script\": [\"targetDurationSec\", \"language\"],\n \"ugc-clips\": [],\n \"ugc-clip\": [],\n \"ugc-cards\": [],\n \"ugc-finish-clips\": [],\n}\n\nconst KEEP_RESULT_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\"])\n\n/** UGC Creator holds options for the person to pick: the ones a run drew, or the ones a credits stop kept. */\nexport function ugcPickPending(data: unknown): boolean {\n const candidates = data && typeof data === \"object\" ? (data as Record<string, unknown>)[UGC_CREATOR_CANDIDATES_KEY] : undefined\n return Array.isArray(candidates) && candidates.length > 0\n}\n\n/**\n * A run that would execute a UGC Creator whose options wait is refused (\"Pick a creator first.\"),\n * except that creator's own re-draw. One rule for the editor's check before a run and the\n * orchestrator's.\n */\nexport function ugcRunWaitsForPick(\n runNodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,\n opts: { readonly redrawId?: string } = {},\n): boolean {\n return runNodes.some((n) => n.type === \"ugc-creator\" && n.id !== opts.redrawId && ugcPickPending(n.data))\n}\n\n/**\n * Per UGC type, the author's own content a published snapshot never carries: UGC Creator's photo\n * of a person (`photoUrl`). A choice, not run state — so it stays on the author's own workflow —\n * but a runner gives their own photo (or the run is refused for want of one) and a template's\n * cloner adds theirs.\n */\nexport const UGC_PUBLISH_PRIVATE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"photoUrl\"],\n}\n\n/**\n * The UGC types' own strip: a copy of `nodes` with every UGC node's run state and the author's own\n * photo removed (and `keepResult: false`). Other nodes are returned as they are. Publishing, a\n * share link's view and a viewer's run go through `stripUgcPublishState` (@nodaro/render-rules),\n * which starts here.\n */\nexport function stripUgcRunState<T extends { type?: unknown; data?: unknown }>(nodes: readonly T[]): T[] {\n return nodes.map((node) => {\n const type = typeof node.type === \"string\" ? node.type : \"\"\n if (!UGC_NODE_TYPES.has(type) || !node.data || typeof node.data !== \"object\") return node\n const data: Record<string, unknown> = { ...(node.data as Record<string, unknown>) }\n for (const key of UGC_NODE_RUN_STATE_KEYS[type] ?? []) delete data[key]\n for (const key of UGC_PUBLISH_PRIVATE_FIELDS[type] ?? []) delete data[key]\n if (KEEP_RESULT_TYPES.has(type)) data.keepResult = false\n return { ...node, data }\n })\n}\n\n/** Every override entry that would set a non-overridable key on a UGC node, in node then key order. Pure. */\nexport function findUgcLockedFields(\n nodes: ReadonlyArray<{ id: string; type?: string }> | null | undefined,\n inputOverrides: Record<string, Record<string, unknown>> | null | undefined,\n): Array<{ nodeId: string; nodeType: string; field: string }> {\n if (!nodes || !inputOverrides) return []\n const found: Array<{ nodeId: string; nodeType: string; field: string }> = []\n for (const node of nodes) {\n const type = node?.type\n if (typeof type !== \"string\" || !UGC_NODE_TYPES.has(type)) continue\n const allowed = UGC_OVERRIDABLE_FIELDS[type] ?? []\n const fields = inputOverrides[node.id]\n if (!fields || typeof fields !== \"object\") continue\n for (const field of Object.keys(fields)) {\n if (!allowed.includes(field)) found.push({ nodeId: String(node.id), nodeType: type, field })\n }\n }\n return found\n}\n","/**\n * The UGC node wires: every request body the five UGC nodes send and every\n * output they hand on, as ONE pure implementation that both engines (the\n * workflow orchestrator and the editor) call, so the two can never disagree.\n *\n * Content-free. A creator record is read only for `v`, `gender` and\n * `identityImages`, a plan only for `v`, a clip ticket only for `v`, `index`\n * and `durationSec`; every other key is opaque and passes through as it came.\n * Every UGC-private JSON a node emits carries `v: 1`, and a wire with another\n * `v` is refused, never guessed at.\n */\nimport type { CaptionPlan } from \"./caption-plan.js\"\nimport { fanOutItemMeta, type ClipNote } from \"./fan-out-meta.js\"\nimport { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from \"./model-constants.js\"\nimport { ugcPickPending } from \"./ugc-run-state.js\"\n\n/** A UGC call that reached a deployment without the UGC routes (the router's 404). */\nexport const UGC_NOT_SERVED_MESSAGE = \"UGC videos are a Nodaro Cloud feature and are not served on this deployment.\"\n/** A wire whose `v` this app does not read. */\nexport const UGC_VERSION_MESSAGE = \"This workflow was made with a newer version of the UGC nodes.\"\n/** An answer this app cannot run: a tool it does not know, or a shape it cannot read. */\nexport const UGC_NEWER_APP_MESSAGE = \"This step needs a newer app version.\"\n/** A creator pick whose options are gone (another run replaced them, or they were never this node's). */\nexport const UGC_PICK_GONE_MESSAGE = \"These creator options are no longer available. Run UGC Creator again.\"\n/** UGC Clips with no creator on its creator input (UGC Creator has not run, or waits for a pick). */\nexport const UGC_CREATOR_MISSING_MESSAGE = \"UGC Creator has no creator yet. Run it, or pick one of its options.\"\n/** UGC Script's target length in seconds when the node holds none: the node's default (the route requires a length). */\nexport const UGC_SCRIPT_DEFAULT_TARGET_SEC = 15\n/** The range of a UGC script's length, in whole seconds: the script route's, and a plan's own. */\nexport const UGC_SCRIPT_MIN_TARGET_SEC = 4\nexport const UGC_SCRIPT_MAX_TARGET_SEC = 300\n\nconst MINOR_AGE_MESSAGE = \"That age can't be used: UGC creators are adults only.\"\nconst NEEDS_GENDER = \"Choose woman or man.\"\nconst NEEDS_PHOTO = \"Connect or upload a photo of yourself.\"\nconst NEEDS_CATEGORY = \"Run UGC Script first, or pick a product category.\"\nconst NEEDS_SITE = \"Add the product name or website.\"\n/** The opening of the sentence UGC Clips fails with when the plugin refuses the script: \"<this> <each error and its fix>\". */\nexport const UGC_SCRIPT_NEEDS_CHANGES = \"The script needs changes:\"\nconst NEEDS_PLAN_OUT = \"Connect the Script (sized) output of UGC Clips.\"\nconst NEEDS_PLAN = \"Connect the Script output of UGC Script.\"\nconst NEEDS_TICKET = \"Connect the Clips output of UGC Clips.\"\nconst NEEDS_VIDEO = \"Connect the joined video.\"\nconst NEEDS_TRANSCRIPT = \"Connect the Transcript output of UGC Clips.\"\n/**\n * A run of a video whose clips are cut from one recorded speech, on a graph with no UGC Finish on this UGC\n * Clips' Script (sized) output: refused before anything is spent.\n */\nexport const UGC_NEEDS_FINISH_MESSAGE = \"Add a UGC Finish node after UGC Clip, and connect UGC Clips' Script (sized) output to it.\"\n/** UGC Finish with nothing on its clips input. */\nexport const UGC_FINISH_NEEDS_CLIPS_MESSAGE = \"Connect the Video output of UGC Clip.\"\n/** UGC Finish's job answered that a clip does not follow its speech (each clip checks itself first, so this is rare). */\nexport const UGC_FINISH_NOT_READY_MESSAGE = \"A clip did not follow its speech. Re-render it from the UGC Clip node and run again.\"\n/**\n * A video cut from one recorded speech whose clips, priced once the speech is split, would hold more\n * than the run was checked for before it started: the run stops at UGC Clips, before any clip renders.\n */\nexport const UGC_OVER_HOLD_MESSAGE =\n \"The clips for this recording would cost more than this run was checked for, so none was rendered. Run UGC Clips again to record the speech again.\"\n\n/**\n * Every fixed sentence a UGC node fails with, by id: the English both engines write on the node.\n * The editor shows each in the person's language by its id. Not listed: the sentence that opens\n * with `UGC_SCRIPT_NEEDS_CHANGES` (the plugin's own words finish it), a route's own message, and\n * \"UGC step failed (<status>)\".\n */\nexport const UGC_NODE_MESSAGES = Object.freeze({\n notServed: UGC_NOT_SERVED_MESSAGE,\n version: UGC_VERSION_MESSAGE,\n newerApp: UGC_NEWER_APP_MESSAGE,\n pickGone: UGC_PICK_GONE_MESSAGE,\n creatorMissing: UGC_CREATOR_MISSING_MESSAGE,\n minorAge: MINOR_AGE_MESSAGE,\n needsGender: NEEDS_GENDER,\n needsPhoto: NEEDS_PHOTO,\n needsCategory: NEEDS_CATEGORY,\n needsSite: NEEDS_SITE,\n needsPlanOut: NEEDS_PLAN_OUT,\n needsPlan: NEEDS_PLAN,\n needsTicket: NEEDS_TICKET,\n needsVideo: NEEDS_VIDEO,\n needsTranscript: NEEDS_TRANSCRIPT,\n needsFinish: UGC_NEEDS_FINISH_MESSAGE,\n finishNeedsClips: UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n finishNotReady: UGC_FINISH_NOT_READY_MESSAGE,\n overHold: UGC_OVER_HOLD_MESSAGE,\n} as const)\n\n/** The id of a fixed sentence a UGC node fails with (`UGC_NODE_MESSAGES`). */\nexport type UgcNodeMessageId = keyof typeof UGC_NODE_MESSAGES\n\n/** UGC Script's screenshot inputs, in card order. */\nexport const UGC_SCREENSHOT_HANDLES: readonly string[] = [\n \"screenshot\", \"screenshot2\", \"screenshot3\", \"screenshot4\", \"screenshot5\", \"screenshot6\", \"screenshot7\", \"screenshot8\",\n]\n\n/** Per UGC type, the output an edge with no source handle reads. */\nexport const UGC_PRIMARY_HANDLE: Readonly<Record<string, string>> = {\n \"ugc-creator\": \"creator\",\n \"ugc-script\": \"plan\",\n \"ugc-clips\": \"clips\",\n \"ugc-clip\": \"video-out\",\n \"ugc-cards\": \"layerPlan\",\n \"ugc-finish-clips\": \"video-out\",\n}\n\n/** A UGC node's outputs: handle id → the value that handle carries (a JSON string, text or a URL). */\nexport type UgcOutputs = Readonly<Record<string, string>>\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/**\n * The length a saved UGC plan was written to: its own `targetDurationSec`, a whole number of\n * seconds in the script's range. Besides the lines (the opening line, each beat's line, the\n * closing line), one of the two keys of a plan the app reads (the other: whether each beat carries\n * a screenshot, `ugcPlanScreenshotCount`): a script that hands on its saved plan is priced at the\n * plan's length, and shows it, never at the length setting, which may have changed since. Takes\n * the plan or its wire (a JSON string); undefined for anything that is not a plan carrying a length.\n */\nexport function ugcPlanLengthSec(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value) return undefined\n const sec = value.targetDurationSec\n return typeof sec === \"number\" && Number.isInteger(sec) && sec >= UGC_SCRIPT_MIN_TARGET_SEC && sec <= UGC_SCRIPT_MAX_TARGET_SEC ? sec : undefined\n}\n\n/**\n * How many of a saved UGC plan's beats carry a screenshot: the screenshot cards the plan was\n * written with. Read beat by beat: a beat carries one when its `screenshot` is an object, as the\n * plan's own screenshots are (whatever it names); a beat that is not an object, or whose screenshot\n * is anything else, carries none — and never makes the rest unreadable. A plan whose beats carry\n * none is a talking-head plan (0). Read, like its length, so a script that hands on its saved plan\n * is priced at the screenshots that plan holds, never at the script's wires, which may have changed\n * since. Takes the plan or its wire (a JSON string); undefined only for a plan with no beats to read\n * and for anything that is not a plan.\n */\nexport function ugcPlanScreenshotCount(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value || !Array.isArray(value.beats)) return undefined\n return value.beats.filter((beat) => isObject(beat) && isObject(beat.screenshot)).length\n}\n\n/** A saved plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction savedPlanOf(plan: unknown): Obj | undefined {\n let value: unknown = plan\n if (typeof value === \"string\") {\n try {\n value = JSON.parse(value)\n } catch {\n return undefined\n }\n }\n return isObject(value) ? value : undefined\n}\n/** A string with something in it; an empty or blank field or input counts as absent. */\nconst filled = (x: unknown): string | undefined => (typeof x === \"string\" && x.trim() !== \"\" ? x : undefined)\n\n/**\n * What an edge from a UGC node reads, on both engines: the value of the pip it leaves — an edge\n * with no source handle reads the node's primary output — from the node's outputs by pip. Only a\n * pip the outputs hold as a string (\"\" included: an empty transcript is a value); an inherited\n * key or a non-string is no value.\n */\nexport function ugcPipValue(outputs: unknown, sourceType: string, sourceHandle?: string | null): string | undefined {\n const pip = sourceHandle || (Object.hasOwn(UGC_PRIMARY_HANDLE, sourceType) ? UGC_PRIMARY_HANDLE[sourceType] : undefined)\n if (pip === undefined || !isObject(outputs) || !Object.hasOwn(outputs, pip)) return undefined\n const value = outputs[pip]\n return typeof value === \"string\" ? value : undefined\n}\n\n/**\n * A UGC wire (a JSON string or an object) → its value when it is an object with `v: 1`.\n * Another `v` → the version message. Anything that is not a UGC wire at all (nothing\n * connected, not JSON, no `v`) → `unreadable`, which a node words as the input it needs.\n */\nexport function readUgcWire(raw: unknown, unreadable: string = UGC_VERSION_MESSAGE): { value: Record<string, unknown> } | { error: string } {\n let parsed: unknown = raw\n if (typeof raw === \"string\") {\n try {\n parsed = JSON.parse(raw)\n } catch {\n return { error: unreadable }\n }\n }\n if (!isObject(parsed) || parsed.v === undefined) return { error: unreadable }\n if (parsed.v !== 1) return { error: UGC_VERSION_MESSAGE }\n return { value: parsed }\n}\n\n/** The route's `{ error: { code, message } }` (or a framework error's top-level `message`). */\nfunction routeErrorOf(body: string): { code?: string; message?: string } {\n let parsed: unknown\n try {\n parsed = JSON.parse(body)\n } catch {\n return {}\n }\n if (!isObject(parsed)) return {}\n if (isObject(parsed.error)) {\n const { code, message } = parsed.error\n return { code: typeof code === \"string\" ? code : undefined, message: filled(message) }\n }\n return { message: filled(parsed.message) }\n}\n\n/**\n * A failed UGC call → the sentence the node fails with. A 404 that names no error code is\n * the router's (the route is not registered here) → the Cloud sentence; a route's own 404\n * names a code and keeps its message. `minor_age_refused` → the adults-only sentence. A 4xx\n * or 503 → the route's message. Anything else → \"UGC step failed (<status>)\".\n */\nexport function ugcFailure(status: number, body: string): string {\n const error = routeErrorOf(body)\n if (status === 404 && error.code === undefined) return UGC_NOT_SERVED_MESSAGE\n if (error.code === \"minor_age_refused\") return MINOR_AGE_MESSAGE\n if ((status === 503 || (status >= 400 && status < 500)) && error.message) return error.message\n return `UGC step failed (${status})`\n}\n\n// ── UGC Creator ──────────────────────────────────────────────────────────────\n\n/**\n * The pickers whose own set fields shape a sampled creator: the picker types UGC Creator's\n * `pickers` input takes (the route takes no other). One list for the editor's connection rule\n * and both engines' input resolvers.\n */\nexport const UGC_CREATOR_PICKER_TYPES: ReadonlySet<string> = new Set([\"person\", \"styling\", \"setting\", \"lighting\"])\n\n/** The UGC Creator node-data keys its request body reads. */\nexport interface UgcCreatorFields {\n readonly source?: string\n readonly gender?: string\n readonly photoUrl?: string\n readonly categoryOverride?: string\n readonly seed?: number\n readonly keepResult?: boolean\n readonly result?: Readonly<Record<string, unknown>>\n /** The options a draw left waiting for the pick (run state): read only for `previous`. */\n readonly candidates?: unknown\n}\n\n/** The traits of the latest creator the person saw: the first waiting option's, else the last result's (Keep off). */\nfunction previousTraits(data: UgcCreatorFields): unknown {\n if (ugcPickPending(data)) {\n const first: unknown = (data.candidates as readonly unknown[])[0]\n const record = isObject(first) ? first.record : undefined\n return isObject(record) ? record.traits : undefined\n }\n return !data.keepResult && isObject(data.result) ? data.result.traits : undefined\n}\n\n/** The wired pickers that set a field (their own fields, as the resolver read them); undefined when none did. */\nfunction setPickers(pickers: Record<string, Record<string, unknown>> | undefined): Record<string, Record<string, unknown>> | undefined {\n if (!pickers) return undefined\n const set = Object.entries(pickers).filter(([, fields]) => isObject(fields) && Object.keys(fields).length > 0)\n return set.length > 0 ? Object.fromEntries(set) : undefined\n}\n\n/**\n * The `/v1/ugc/creator` body. A photo: the wired photo, else the node's own. A sampled\n * creator: the product category (the node's override, else the wired one), the pickers that\n * set a field, the node's seed, and the traits of the latest creator the person saw as\n * `previous`, so the next one differs: the first option waiting for the pick, else — on a\n * re-run that does not keep the result — the last creator's. Refuses before any call.\n */\nexport function ugcCreatorBody(input: {\n data: UgcCreatorFields\n photoUrl?: string\n category?: string\n pickers?: Record<string, Record<string, unknown>>\n}): { body: Record<string, unknown> } | { error: string } {\n const { data } = input\n const gender = data.gender\n if (gender !== \"woman\" && gender !== \"man\") return { error: NEEDS_GENDER }\n if (data.source === \"photo\") {\n const imageUrl = filled(input.photoUrl) ?? filled(data.photoUrl)\n if (!imageUrl) return { error: NEEDS_PHOTO }\n return { body: { source: { kind: \"photo\", imageUrl, gender } } }\n }\n const productCategory = filled(data.categoryOverride) ?? filled(input.category)\n if (!productCategory) return { error: NEEDS_CATEGORY }\n const pickers = setPickers(input.pickers)\n const traits = previousTraits(data)\n return {\n body: {\n ...(typeof data.seed === \"number\" ? { seed: data.seed } : {}),\n source: {\n kind: \"sampled\",\n gender,\n productCategory,\n ...(pickers ? { pickers } : {}),\n ...(isObject(traits) ? { previous: traits } : {}),\n },\n },\n }\n}\n\n/**\n * The creator the node hands on: the record (`creator`, v1) and its first image (`image`).\n * `identityImages` are the images of the candidate the node hands on — the picked one where\n * a person picked. The record copies the listed fields only, so `candidates`, `fallback`,\n * `pick` and `image` never reach the `creator` wire.\n */\nexport function ugcCreatorOutputs(answer: Record<string, unknown>, identityImages: readonly string[]): { outputs: UgcOutputs; imageUrl: string; record: Record<string, unknown> } {\n const record: Record<string, unknown> = {\n v: 1,\n kind: answer.kind,\n gender: answer.gender,\n identityImages: [...identityImages],\n traits: answer.traits ?? null,\n seed: answer.seed ?? null,\n promptsVersion: answer.promptsVersion,\n productCategory: answer.productCategory ?? null,\n }\n const imageUrl = identityImages[0] ?? \"\"\n return { outputs: { creator: JSON.stringify(record), ...(imageUrl ? { image: imageUrl } : {}) }, imageUrl, record }\n}\n\n/** One builder call as the app runs it: `tool` and `args`, nothing else (a candidate's other keys, its model included, are never read). */\nexport interface UgcCreatorCall { readonly tool: string; readonly args: Readonly<Record<string, unknown>> }\n\n/** What a creator answer asks the node to render. */\nexport interface UgcCreatorCandidateCalls {\n /** Every candidate's image call, the primary first. One call (`image`) for an answer from before candidates; none for a photo. */\n readonly calls: readonly UgcCreatorCall[]\n /** The round's one moderation fallback: it runs once, and only when every candidate the run rendered was blocked. */\n readonly fallback: UgcCreatorCall | null\n /** \"user\": a person picks among `calls` where one can be asked; \"primary\": `calls[0]` alone; null: nothing to render (a photo). */\n readonly pick: \"user\" | \"primary\" | null\n}\n\nconst callOf = (raw: unknown): UgcCreatorCall | undefined => {\n if (!raw || typeof raw !== \"object\") return undefined\n const { tool, args } = raw as { tool?: unknown; args?: unknown }\n if (typeof tool !== \"string\" || !args || typeof args !== \"object\" || Array.isArray(args)) return undefined\n return { tool, args: args as Readonly<Record<string, unknown>> }\n}\nconst fallbackOf = (image: unknown): unknown => (image && typeof image === \"object\" ? (image as { fallback?: unknown }).fallback : undefined)\n\n/**\n * A `/v1/ugc/creator` answer's image calls. Content-free: reads `image` (`tool`, `args`,\n * `fallback`), `candidates[].tool|args`, `fallback` and `pick.how` — never a candidate's\n * model. An answer without `candidates` (an older builder) renders `image` alone, as before.\n */\nexport function ugcCreatorCandidates(answer: Readonly<Record<string, unknown>>): UgcCreatorCandidateCalls | { readonly error: string } {\n const listed = answer.candidates\n const noList = listed === undefined || listed === null || (Array.isArray(listed) && listed.length === 0)\n const noImage = answer.image === undefined || answer.image === null\n if (noList && noImage) return { calls: [], fallback: null, pick: null }\n if (noList) {\n const image = callOf(answer.image)\n if (!image) return { error: UGC_NEWER_APP_MESSAGE }\n return { calls: [image], fallback: callOf(fallbackOf(answer.image)) ?? null, pick: \"primary\" }\n }\n if (!Array.isArray(listed)) return { error: UGC_NEWER_APP_MESSAGE }\n const calls = listed.map(callOf)\n if (calls.some((c) => c === undefined)) return { error: UGC_NEWER_APP_MESSAGE }\n const how = (answer.pick as { how?: unknown } | null | undefined)?.how\n return {\n calls: calls as UgcCreatorCall[],\n fallback: callOf(answer.fallback) ?? callOf(fallbackOf(answer.image)) ?? null,\n pick: how === \"user\" && calls.length > 1 ? \"user\" : \"primary\",\n }\n}\n\n/** The calls a run renders: every candidate where a person is there to pick, else the primary alone. */\nexport function ugcCreatorCallsToRender(c: UgcCreatorCandidateCalls, opts: { readonly personPicks: boolean }): readonly UgcCreatorCall[] {\n return opts.personPicks && c.pick === \"user\" ? c.calls : c.calls.slice(0, 1)\n}\n\n/** One rendered candidate that passed its checks, kept on the node until the person picks (run state, never a wire). */\nexport interface UgcCreatorCandidate { readonly imageUrl: string; readonly record: Readonly<Record<string, unknown>> }\n\nexport function ugcCreatorCandidate(answer: Readonly<Record<string, unknown>>, images: readonly string[]): UgcCreatorCandidate {\n const out = ugcCreatorOutputs(answer as Record<string, unknown>, images)\n return { imageUrl: out.imageUrl, record: out.record }\n}\n\n/** A UGC Creator run output that waits for the person's pick: two or more options (`ugcCandidates`). */\nexport function ugcAwaitsPick(output: unknown): boolean {\n const candidates = isObject(output) ? output.ugcCandidates : undefined\n return Array.isArray(candidates) && candidates.length >= 2\n}\n\n/** The person's pick, read back from node data (untrusted): a stale index, a foreign list or another version is refused. */\nexport function ugcCreatorPick(candidates: unknown, index: number):\n { readonly result: Readonly<Record<string, unknown>>; readonly outputs: UgcOutputs; readonly imageUrl: string } | { readonly error: string } {\n const entry: unknown = Array.isArray(candidates) && Number.isInteger(index) && index >= 0 ? candidates[index] : undefined\n const imageUrl = (entry as { imageUrl?: unknown } | undefined)?.imageUrl\n const record = (entry as { record?: unknown } | undefined)?.record\n if (typeof imageUrl !== \"string\" || !record || typeof record !== \"object\" || Array.isArray(record)) return { error: UGC_PICK_GONE_MESSAGE }\n const r = record as Record<string, unknown>\n if (r.v !== 1) return { error: UGC_VERSION_MESSAGE }\n if (!Array.isArray(r.identityImages) || r.identityImages[0] !== imageUrl) return { error: UGC_PICK_GONE_MESSAGE }\n return { result: r, outputs: { creator: JSON.stringify(r), image: imageUrl }, imageUrl }\n}\n\n// ── UGC Script ───────────────────────────────────────────────────────────────\n\n/** The languages a UGC script can be written in: the node's choice (`UgcScriptData.language`). */\nexport const UGC_SCRIPT_LANGUAGES = [\"en\", \"he\"] as const\nexport type UgcScriptLanguage = (typeof UGC_SCRIPT_LANGUAGES)[number]\n\n/**\n * The `/v1/ugc/script` body: the product name or website (required), the screenshot slots\n * in card order with the empty ones dropped, the product image when set, the target length\n * (`UGC_SCRIPT_DEFAULT_TARGET_SEC` when the node holds no number), and the language (the\n * node's choice; English when it holds none or one this app does not know).\n */\nexport function ugcScriptBody(input: {\n site?: string\n screenshots: ReadonlyArray<string | undefined>\n productImage?: string\n targetDurationSec?: number\n language?: unknown\n}): { body: Record<string, unknown> } | { error: string } {\n const site = filled(input.site)?.trim()\n if (!site) return { error: NEEDS_SITE }\n const productImage = filled(input.productImage)\n return {\n body: {\n site,\n screenshots: input.screenshots.filter((s): s is string => filled(s) !== undefined),\n ...(productImage ? { productImage } : {}),\n targetDurationSec: typeof input.targetDurationSec === \"number\" ? input.targetDurationSec : UGC_SCRIPT_DEFAULT_TARGET_SEC,\n language: (UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(input.language) ? input.language : \"en\",\n },\n }\n}\n\n/** A finished UGC Script job → `plan` (the plan, v1) and `category` (text). */\nexport function ugcScriptOutputs(outputData: Record<string, unknown>): UgcOutputs {\n const plan = outputData.plan\n const category = filled(outputData.productCategory)\n return {\n ...(isObject(plan) ? { plan: JSON.stringify({ v: 1, ...plan }) } : {}),\n ...(category ? { category } : {}),\n }\n}\n\n/** UGC Script's last result, as the node holds it. */\nexport type UgcScriptResult = {\n plan: Record<string, unknown>\n productCategory: string\n warnings: unknown[]\n notes: string[]\n rounds: number\n}\n\n/** A finished UGC Script job → the node's `result`, written the same by both engines; none without a plan. */\nexport function ugcScriptResult(outputData: Readonly<Record<string, unknown>>): UgcScriptResult | undefined {\n const { plan, productCategory, warnings, notes, rounds } = outputData\n if (!isObject(plan)) return undefined\n return {\n plan,\n productCategory: filled(productCategory) ?? \"\",\n warnings: Array.isArray(warnings) ? [...warnings] : [],\n notes: Array.isArray(notes) ? notes.filter((n): n is string => typeof n === \"string\") : [],\n rounds: typeof rounds === \"number\" && Number.isFinite(rounds) ? rounds : 0,\n }\n}\n\n// ── Kept results ─────────────────────────────────────────────────────────────\n\n/**\n * What a UGC Creator or UGC Script with Keep on hands on instead of running: the outputs of\n * the result it holds. Null — the node runs — when Keep is off, when the result holds nothing\n * to hand on (a creator without its image, a script without its plan), and for a creator whose\n * options wait for a pick, whatever Keep says. The creator record goes on unread; whoever reads\n * it refuses another version.\n */\nexport function ugcKeptOutputs(type: \"ugc-creator\" | \"ugc-script\", data: Readonly<Record<string, unknown>>): UgcOutputs | null {\n if (type === \"ugc-creator\" && ugcPickPending(data)) return null\n const result = data.keepResult === true ? data.result : undefined\n if (!isObject(result)) return null\n if (type === \"ugc-creator\") {\n const image = Array.isArray(result.identityImages) ? filled(result.identityImages[0]) : undefined\n return image ? { creator: JSON.stringify(result), image } : null\n }\n if (type === \"ugc-script\") return isObject(result.plan) ? ugcScriptOutputs(result) : null\n return null\n}\n\n// ── UGC Clips ────────────────────────────────────────────────────────────────\n\n/** The `/v1/ugc/clips` canvas body: the plan, the creator's gender, traits and images, and the picked voice. */\nexport function ugcClipsBody(input: { planWire: unknown; creatorWire: unknown; voiceId?: string }): { body: Record<string, unknown> } | { error: string } {\n const plan = readUgcWire(input.planWire, NEEDS_PLAN)\n if (\"error\" in plan) return plan\n const creator = readUgcWire(input.creatorWire, UGC_CREATOR_MISSING_MESSAGE)\n if (\"error\" in creator) return creator\n const voiceId = filled(input.voiceId)\n return {\n body: {\n plan: plan.value,\n gender: creator.value.gender,\n traits: creator.value.traits ?? null,\n identityImages: creator.value.identityImages,\n surface: \"canvas\",\n ...(voiceId ? { voiceId } : {}),\n },\n }\n}\n\n/**\n * The `/v1/ugc/clips` answer → the tickets (one per clip, as JSON strings), `clips` (the\n * first), `plan-out` (`{ v: 1, plan, transcribeArgs }` for UGC Cards), `transcript`, whether\n * the plan has cards, and whether the clips go through UGC Finish's job (`finishes`: the plan-out\n * carries a finish call, which is what UGC Finish reads to run it). An answer with errors → \"The script needs changes: …\" with each\n * error and its fix; an answer without the parts UGC Cards needs fails here, before any clip\n * is paid for.\n */\nexport function ugcClipsOutputs(answer: Record<string, unknown>): { outputs: UgcOutputs; tickets: string[]; hasCards: boolean; finishes: boolean } | { error: string } {\n const errors = Array.isArray(answer.errors) ? answer.errors : []\n if (errors.length > 0) {\n const said = errors.flatMap((e) => (isObject(e) ? [filled(e.message), filled(e.fix)] : [])).filter((s): s is string => s !== undefined)\n return { error: said.length > 0 ? `${UGC_SCRIPT_NEEDS_CHANGES} ${said.join(\" \")}` : UGC_NEWER_APP_MESSAGE }\n }\n const { tickets, sizedPlan, transcript, speechCheckCall } = answer\n if (!Array.isArray(tickets) || tickets.length === 0 || !tickets.every(isObject) || !isObject(sizedPlan) || typeof transcript !== \"string\") {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n const wires = tickets.map((t) => JSON.stringify(t))\n // The speech check's arguments ride to UGC Cards' transcription unread (an answer without them: none).\n const transcribeArgs = isObject(speechCheckCall) && isObject(speechCheckCall.args) ? speechCheckCall.args : {}\n // A video cut from one recorded speech (the segmented lane) also hands UGC Finish its finish call's\n // arguments (the segments with their room), opaque; any other answer's plan-out is unchanged.\n const finish = isObject(answer.finish) && isObject(answer.finish.args) ? { finish: answer.finish.args } : {}\n return {\n outputs: { clips: wires[0]!, \"plan-out\": JSON.stringify({ v: 1, plan: sizedPlan, transcribeArgs, ...finish }), transcript },\n tickets: wires,\n hasCards: answer.hasCards === true,\n finishes: \"finish\" in finish,\n }\n}\n\n// ── UGC Clip ─────────────────────────────────────────────────────────────────\n\n/**\n * The `/v1/ugc/clip` body for one ticket: the ticket, `nonce` = how many times this clip was\n * re-rendered (`rerender[\"<clip number>\"]`, else 0) and `runKey` when one is given.\n */\nexport function ugcClipBody(input: { ticketWire: unknown; rerender?: Readonly<Record<string, number>>; runKey?: string }):\n { body: Record<string, unknown>; clipNumber: number; durationSec: number } | { error: string } {\n const read = readUgcWire(input.ticketWire, NEEDS_TICKET)\n if (\"error\" in read) return read\n const ticket = read.value\n const { index, durationSec } = ticket\n if (typeof index !== \"number\" || !Number.isInteger(index) || index < 0) return { error: NEEDS_TICKET }\n if (typeof durationSec !== \"number\" || !Number.isFinite(durationSec) || durationSec <= 0) return { error: NEEDS_TICKET }\n const clipNumber = index + 1\n const count = input.rerender?.[String(clipNumber)]\n const nonce = typeof count === \"number\" && Number.isInteger(count) && count >= 0 ? count : 0\n const runKey = filled(input.runKey)\n return { body: { ticket, nonce, ...(runKey ? { runKey } : {}) }, clipNumber, durationSec }\n}\n\n/**\n * A finished UGC Clip job (`{ videoUrl, durationSec, clipWarnings, … }`) → `video-out`, the\n * clip's real length (null when unknown) and its warnings ([] when it has none).\n */\nexport function ugcClipOutputs(outputData: Record<string, unknown>): { outputs: UgcOutputs; videoUrl: string; durationSec: number | null; clipWarnings: string[] } {\n const videoUrl = filled(outputData.videoUrl) ?? \"\"\n const meta = fanOutItemMeta(outputData)\n return { outputs: videoUrl ? { \"video-out\": videoUrl } : {}, videoUrl, durationSec: meta.durationSec, clipWarnings: [...meta.warnings] }\n}\n\n/**\n * What a list read (a Bundle edge, a fold) takes from a UGC Clip's saved data, on both engines:\n * its last fanned-out batch — one take per clip, in clip order — when its last run was one; else\n * exactly the take it shows (its active result, else its video). Never the earlier takes it keeps:\n * a video of one clip (one ticket, so no fan-out) would join every take. A single run clears the\n * batch (the editor's job patch), so a batch held is always the last run's. Undefined when it holds\n * no take at all.\n */\nexport function ugcClipSavedList(data: unknown): string[] | undefined {\n if (!isObject(data)) return undefined\n const batch = Array.isArray(data.__listResults) ? data.__listResults.filter((u): u is string => typeof u === \"string\" && u !== \"\") : []\n if (batch.length > 0) return batch\n const results = Array.isArray(data.generatedResults) ? data.generatedResults : []\n const index = typeof data.activeResultIndex === \"number\" && Number.isInteger(data.activeResultIndex) ? data.activeResultIndex : 0\n const active = results[index]\n const url = (isObject(active) ? filled(active.url) : undefined) ?? filled(data.generatedVideoUrl)\n return url ? [url] : undefined\n}\n\n// ── UGC Cards ────────────────────────────────────────────────────────────────\n\n/**\n * UGC Cards' two timing jobs on the joined video, and the plan they time. The plan input must\n * be UGC Clips' `{ v: 1, plan, transcribeArgs }`; anything else is refused before either job.\n * The transcription spreads `transcribeArgs` unread, then sets the node's own fields last, so\n * the wire can add a language but never change the provider or the word timings.\n */\nexport function ugcCardsJobs(input: { planOutWire: unknown; videoUrl?: string; transcript?: string }): {\n alignment: { path: \"/v1/forced-alignment\"; body: Record<string, unknown> }\n transcribe: { path: \"/v1/transcribe\"; body: Record<string, unknown> }\n plan: Record<string, unknown>\n} | { error: string } {\n const read = readUgcWire(input.planOutWire, NEEDS_PLAN_OUT)\n if (\"error\" in read) return read\n const { plan, transcribeArgs } = read.value\n if (!isObject(plan) || !isObject(transcribeArgs)) return { error: NEEDS_PLAN_OUT }\n const videoUrl = filled(input.videoUrl)\n if (!videoUrl) return { error: NEEDS_VIDEO }\n // An empty transcript is what UGC Clips said, not a missing input: it goes on as it came.\n const transcript = input.transcript\n if (typeof transcript !== \"string\") return { error: NEEDS_TRANSCRIPT }\n return {\n alignment: { path: \"/v1/forced-alignment\", body: { audioUrl: videoUrl, transcript } },\n transcribe: { path: \"/v1/transcribe\", body: { ...transcribeArgs, audioUrl: videoUrl, provider: DEFAULT_TRANSCRIBE_NODE_PROVIDER, wordTimestamps: true } },\n plan,\n }\n}\n\n/**\n * The `/v1/ugc/cards` canvas body: the plan, the video, whichever timing came back as a list,\n * the timing jobs that failed, and the clips' notes.\n */\nexport function ugcCardsBody(input: {\n plan: Record<string, unknown>\n videoUrl: string\n alignment?: unknown\n words?: unknown\n failed: ReadonlyArray<\"alignment\" | \"words\">\n clipNotes: ReadonlyArray<ClipNote>\n}): Record<string, unknown> {\n return {\n surface: \"canvas\",\n plan: input.plan,\n videoUrl: input.videoUrl,\n ...(Array.isArray(input.alignment) ? { alignment: input.alignment } : {}),\n ...(Array.isArray(input.words) ? { words: input.words } : {}),\n failed: [...input.failed],\n clipNotes: [...input.clipNotes],\n }\n}\n\n/** The caption plan when nothing could be timed: Add Captions renders no captions from it. */\nconst EMPTY_CAPTION_PLAN: CaptionPlan = { v: 1, hookText: \"\", hookEndMs: 0, bodyEndMs: 0, captions: [] }\n\n/** The `/v1/ugc/cards` answer → `layerPlan`, `captionPlan` (v1; the empty plan when untimed) and `report` (one line per sentence). */\nexport function ugcCardsOutputs(answer: Record<string, unknown>): UgcOutputs {\n const timing = answer.captionTiming\n const report = answer.report\n const lines = isObject(report) && Array.isArray(report.lines) ? report.lines.filter((l): l is string => typeof l === \"string\") : []\n return {\n layerPlan: JSON.stringify(Array.isArray(answer.layerPlan) ? answer.layerPlan : []),\n captionPlan: JSON.stringify(isObject(timing) ? { v: 1, ...timing } : EMPTY_CAPTION_PLAN),\n report: lines.join(\"\\n\"),\n }\n}\n"]}
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ var chunkD34K455O_cjs = require('./chunk-D34K455O.cjs');
4
+ var chunkMYJQELFN_cjs = require('./chunk-MYJQELFN.cjs');
5
+
6
+ // src/input-image-pricing.ts
7
+ function isPricedPerInputImage(model) {
8
+ return typeof model === "string" && (chunkD34K455O_cjs.isGptImage26Tiered(model) || chunkMYJQELFN_cjs.isMinimaxH3Image(model) || chunkMYJQELFN_cjs.isSeedream55(model));
9
+ }
10
+ function isPricedPerInputImageEdit(model) {
11
+ return typeof model === "string" && (chunkD34K455O_cjs.isGptImage26I2i(model) || chunkMYJQELFN_cjs.isMinimaxH3ImageI2i(model) || chunkMYJQELFN_cjs.isSeedream55I2i(model));
12
+ }
13
+ function pricedSentImages(provider, references, baseImageUrl) {
14
+ const countsBase = isPricedPerInputImage(provider) && typeof baseImageUrl === "string" && baseImageUrl.length > 0 && !references.includes(baseImageUrl);
15
+ return references.length + (countsBase ? 1 : 0);
16
+ }
17
+ function namesMoodboard(direction) {
18
+ if (direction === null || typeof direction !== "object") return false;
19
+ const style = direction.style;
20
+ return (Array.isArray(style) ? style : [style]).some(
21
+ (value) => typeof value === "string" && value.startsWith("moodboard:")
22
+ );
23
+ }
24
+ function pricedEstimatedImages(model, data, wiredImages) {
25
+ const listed = (v) => Array.isArray(v) ? v.length : 0;
26
+ const single = (v) => typeof v === "string" && v.length > 0 ? 1 : 0;
27
+ return listed(data.referenceImageUrls) + listed(data.characterDefinitionIds) + listed(data.extraRefs) + single(data.referenceImageUrl) + single(data.baseImageUrl) + single(data.sourceImageUrl) + wiredImages + (namesMoodboard(data.direction) ? chunkD34K455O_cjs.GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES : 0) + (isPricedPerInputImageEdit(model) ? 1 : 0);
28
+ }
29
+
30
+ // src/safety-retry-policy.ts
31
+ function safetyRetryPolicy(modelId) {
32
+ const entry = chunkMYJQELFN_cjs.getModel(modelId);
33
+ const safetyFilter = entry?.safetyFilter;
34
+ if (!safetyFilter?.stochastic) return { maxAttempts: 1 };
35
+ const fallback = safetyFilter.fallback;
36
+ if (fallback && chunkMYJQELFN_cjs.getModel(fallback)) {
37
+ return { maxAttempts: 2, fallback };
38
+ }
39
+ return { maxAttempts: 2 };
40
+ }
41
+
42
+ exports.isPricedPerInputImage = isPricedPerInputImage;
43
+ exports.isPricedPerInputImageEdit = isPricedPerInputImageEdit;
44
+ exports.pricedEstimatedImages = pricedEstimatedImages;
45
+ exports.pricedSentImages = pricedSentImages;
46
+ exports.safetyRetryPolicy = safetyRetryPolicy;
47
+ //# sourceMappingURL=chunk-IDTKF5EX.cjs.map
48
+ //# sourceMappingURL=chunk-IDTKF5EX.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/input-image-pricing.ts","../src/safety-retry-policy.ts"],"names":["isGptImage26Tiered","isMinimaxH3Image","isSeedream55","isGptImage26I2i","isMinimaxH3ImageI2i","isSeedream55I2i","GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES","getModel"],"mappings":";;;;;;AAeO,SAAS,sBAAsB,KAAA,EAAyB;AAC7D,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,KAAaA,oCAAA,CAAmB,KAAK,KAAKC,kCAAA,CAAiB,KAAK,CAAA,IAAKC,8BAAA,CAAa,KAAK,CAAA,CAAA;AACjH;AAGO,SAAS,0BAA0B,KAAA,EAAyB;AACjE,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,K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,CAAA,GAC7B,MAAA,CAAO,IAAA,CAAK,YAAY,CAAA,GACxB,MAAA,CAAO,IAAA,CAAK,cAAc,IAC1B,WAAA,IACC,cAAA,CAAe,IAAA,CAAK,SAAS,IAAIC,oDAAA,GAAqC,CAAA,CAAA,IACtE,yBAAA,CAA0B,KAAK,IAAI,CAAA,GAAI,CAAA,CAAA;AAE5C;;;ACjDO,SAAS,kBAAkB,OAAA,EAAoC;AACpE,EAAA,MAAM,KAAA,GAAQC,2BAAS,OAAO,CAAA;AAC9B,EAAA,MAAM,eAAe,KAAA,EAAO,YAAA;AAC5B,EAAA,IAAI,CAAC,YAAA,EAAc,UAAA,EAAY,OAAO,EAAE,aAAa,CAAA,EAAE;AAEvD,EAAA,MAAM,WAAW,YAAA,CAAa,QAAA;AAC9B,EAAA,IAAI,QAAA,IAAYA,0BAAA,CAAS,QAAQ,CAAA,EAAG;AAClC,IAAA,OAAO,EAAE,WAAA,EAAa,CAAA,EAAG,QAAA,EAAS;AAAA,EACpC;AACA,EAAA,OAAO,EAAE,aAAa,CAAA,EAAE;AAC1B","file":"chunk-IDTKF5EX.cjs","sourcesContent":["/**\n * The image models whose price depends on how many input images a run sends:\n * GPT Image 2.6 Flare and Sunburst, MiniMax H3 Image and Seedream 5.5. Every place that\n * prices a run counts those images through here, so a model that joins\n * `isPricedPerInputImage` is counted on every path at once.\n */\nimport {\n GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES,\n isGptImage26I2i,\n isGptImage26Tiered,\n} from \"./gpt-image-2-6.js\"\nimport { isMinimaxH3Image, isMinimaxH3ImageI2i } from \"./minimax-h3-image.js\"\nimport { isSeedream55, isSeedream55I2i } from \"./seedream-5-5.js\"\n\n/** True for a model whose price counts the input images a run sends. */\nexport function isPricedPerInputImage(model: unknown): boolean {\n return typeof model === \"string\" && (isGptImage26Tiered(model) || isMinimaxH3Image(model) || isSeedream55(model))\n}\n\n/** True for the edit id of such a model: it always sends at least its source. */\nexport function isPricedPerInputImageEdit(model: unknown): boolean {\n return typeof model === \"string\" && (isGptImage26I2i(model) || isMinimaxH3ImageI2i(model) || isSeedream55I2i(model))\n}\n\n/**\n * The images a Generate Image run sends its provider: its references and, when\n * it edits a base image, that image too (the worker puts it first, unless it is\n * already one of the references). Counted only on a model priced per input\n * image; any other model is priced on its references alone, as before.\n */\nexport function pricedSentImages(\n provider: string | undefined,\n references: readonly string[],\n baseImageUrl: unknown,\n): number {\n const countsBase =\n isPricedPerInputImage(provider) &&\n typeof baseImageUrl === \"string\" &&\n baseImageUrl.length > 0 &&\n !references.includes(baseImageUrl)\n return references.length + (countsBase ? 1 : 0)\n}\n\nfunction namesMoodboard(direction: unknown): boolean {\n if (direction === null || typeof direction !== \"object\") return false\n const style = (direction as Record<string, unknown>).style\n return (Array.isArray(style) ? style : [style]).some(\n (value) => typeof value === \"string\" && value.startsWith(\"moodboard:\"),\n )\n}\n\n/**\n * The input images a workflow estimate counts for one node on a model priced\n * per input image: every list on the node, its source or base image, what is\n * wired in, a moodboard its direction names (at the most a moodboard holds),\n * and an edit model's own source. An estimate may over-quote, never under.\n */\nexport function pricedEstimatedImages(\n model: string,\n data: Record<string, unknown>,\n wiredImages: number,\n): number {\n const listed = (v: unknown) => (Array.isArray(v) ? v.length : 0)\n const single = (v: unknown) => (typeof v === \"string\" && v.length > 0 ? 1 : 0)\n return (\n listed(data.referenceImageUrls) +\n listed(data.characterDefinitionIds) +\n listed(data.extraRefs) +\n single(data.referenceImageUrl) +\n single(data.baseImageUrl) +\n single(data.sourceImageUrl) +\n wiredImages +\n (namesMoodboard(data.direction) ? GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES : 0) +\n (isPricedPerInputImageEdit(model) ? 1 : 0)\n )\n}\n","import { getModel } from \"./model-catalog.js\"\n\n/**\n * Retry/fallback behavior derived from a catalog entry's `safetyFilter`\n * flag (see `ModelCatalogEntry.safetyFilter` in `model-catalog.ts`).\n */\nexport interface SafetyRetryPolicy {\n /** 2 when the model declares `safetyFilter.stochastic`, else 1. */\n maxAttempts: 1 | 2\n /**\n * Catalog model id to offer when the retry also blocks. Only present\n * when the entry declares one AND it resolves to a real catalog entry.\n */\n fallback?: string\n}\n\n/**\n * The provider's safety filter is known to be non-deterministic on some\n * catalog models — a benign prompt can trip it once and pass on an\n * identical retry. For those models the platform retries a blocked\n * request once (`maxAttempts: 2`) before giving up; `fallback` names the\n * catalog model to offer the user when the retry also blocks.\n *\n * Every model not flagged this way — including an unrecognized id —\n * gets a single attempt and no fallback.\n */\nexport function safetyRetryPolicy(modelId: string): SafetyRetryPolicy {\n const entry = getModel(modelId)\n const safetyFilter = entry?.safetyFilter\n if (!safetyFilter?.stochastic) return { maxAttempts: 1 }\n\n const fallback = safetyFilter.fallback\n if (fallback && getModel(fallback)) {\n return { maxAttempts: 2, fallback }\n }\n return { maxAttempts: 2 }\n}\n"]}