@nodaro/shared 3.69.0 → 3.71.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 (198) hide show
  1. package/dist/{chunk-25C2E2GI.cjs → chunk-4A3ITJJB.cjs} +6 -6
  2. package/dist/{chunk-25C2E2GI.cjs.map → chunk-4A3ITJJB.cjs.map} +1 -1
  3. package/dist/{chunk-5EQRIUGI.cjs → chunk-4HV3LY4A.cjs} +78 -78
  4. package/dist/chunk-4HV3LY4A.cjs.map +1 -0
  5. package/dist/{chunk-PERUFUVH.cjs → chunk-5B337MCI.cjs} +15 -15
  6. package/dist/{chunk-PERUFUVH.cjs.map → chunk-5B337MCI.cjs.map} +1 -1
  7. package/dist/{chunk-7EQJIGVT.js → chunk-6FUVGATF.js} +3 -3
  8. package/dist/{chunk-7EQJIGVT.js.map → chunk-6FUVGATF.js.map} +1 -1
  9. package/dist/{chunk-WML66SUV.cjs → chunk-6PEWM2B3.cjs} +18 -18
  10. package/dist/{chunk-WML66SUV.cjs.map → chunk-6PEWM2B3.cjs.map} +1 -1
  11. package/dist/{chunk-KLEKJUQI.js → chunk-BO6IKV24.js} +5 -5
  12. package/dist/{chunk-KLEKJUQI.js.map → chunk-BO6IKV24.js.map} +1 -1
  13. package/dist/{chunk-KSHAAPQF.cjs → chunk-BOCHNFDU.cjs} +4 -4
  14. package/dist/chunk-BOCHNFDU.cjs.map +1 -0
  15. package/dist/{chunk-AH6OQXLW.js → chunk-BQV6NV7E.js} +3 -3
  16. package/dist/{chunk-AH6OQXLW.js.map → chunk-BQV6NV7E.js.map} +1 -1
  17. package/dist/{chunk-BDW25A7Y.js → chunk-BVP4M5AK.js} +247 -11
  18. package/dist/chunk-BVP4M5AK.js.map +1 -0
  19. package/dist/{chunk-ML55U7WM.js → chunk-C2UHX7OF.js} +3 -3
  20. package/dist/{chunk-ML55U7WM.js.map → chunk-C2UHX7OF.js.map} +1 -1
  21. package/dist/{chunk-Q2LEJXLZ.cjs → chunk-C32IL6RD.cjs} +2 -2
  22. package/dist/{chunk-Q2LEJXLZ.cjs.map → chunk-C32IL6RD.cjs.map} +1 -1
  23. package/dist/{chunk-5WHU7CYE.js → chunk-CL7ECTK2.js} +52 -7
  24. package/dist/chunk-CL7ECTK2.js.map +1 -0
  25. package/dist/{chunk-FUYBUT65.js → chunk-COA2OJIH.js} +51 -28
  26. package/dist/chunk-COA2OJIH.js.map +1 -0
  27. package/dist/{chunk-PLANUXQL.cjs → chunk-CV2BEK52.cjs} +25 -3
  28. package/dist/chunk-CV2BEK52.cjs.map +1 -0
  29. package/dist/{chunk-HW6TLOK4.cjs → chunk-DRPHRE4J.cjs} +2 -2
  30. package/dist/{chunk-HW6TLOK4.cjs.map → chunk-DRPHRE4J.cjs.map} +1 -1
  31. package/dist/{chunk-LZPG4XHT.js → chunk-F3XG5J5V.js} +3 -3
  32. package/dist/{chunk-LZPG4XHT.js.map → chunk-F3XG5J5V.js.map} +1 -1
  33. package/dist/{chunk-I6TBKTW3.cjs → chunk-H52P7DD2.cjs} +73 -73
  34. package/dist/{chunk-I6TBKTW3.cjs.map → chunk-H52P7DD2.cjs.map} +1 -1
  35. package/dist/{chunk-AGIG5HUU.cjs → chunk-HUCGHMOI.cjs} +17 -17
  36. package/dist/{chunk-AGIG5HUU.cjs.map → chunk-HUCGHMOI.cjs.map} +1 -1
  37. package/dist/{chunk-3AB3YIFM.cjs → chunk-I4C6ZYU4.cjs} +6 -6
  38. package/dist/{chunk-3AB3YIFM.cjs.map → chunk-I4C6ZYU4.cjs.map} +1 -1
  39. package/dist/{chunk-UVUHVY7F.js → chunk-JCYTTTM2.js} +2 -2
  40. package/dist/{chunk-UVUHVY7F.js.map → chunk-JCYTTTM2.js.map} +1 -1
  41. package/dist/{chunk-7OSUEYZ4.js → chunk-JPSKVBYB.js} +3 -3
  42. package/dist/{chunk-7OSUEYZ4.js.map → chunk-JPSKVBYB.js.map} +1 -1
  43. package/dist/{chunk-TAPBDT47.js → chunk-JVYDKXGY.js} +4 -4
  44. package/dist/{chunk-TAPBDT47.js.map → chunk-JVYDKXGY.js.map} +1 -1
  45. package/dist/{chunk-YT4ZTJVC.js → chunk-K2P7KOIT.js} +11 -11
  46. package/dist/{chunk-YT4ZTJVC.js.map → chunk-K2P7KOIT.js.map} +1 -1
  47. package/dist/{chunk-YVQFYW2U.js → chunk-K3YGI5IW.js} +25 -4
  48. package/dist/chunk-K3YGI5IW.js.map +1 -0
  49. package/dist/{chunk-4IMEJQVQ.cjs → chunk-K5WRF2F3.cjs} +4 -4
  50. package/dist/{chunk-4IMEJQVQ.cjs.map → chunk-K5WRF2F3.cjs.map} +1 -1
  51. package/dist/{chunk-TDU45K6Z.js → chunk-KD4UUCMW.js} +5 -5
  52. package/dist/{chunk-TDU45K6Z.js.map → chunk-KD4UUCMW.js.map} +1 -1
  53. package/dist/{chunk-UJREE6EQ.cjs → chunk-LBKMQAXD.cjs} +9 -9
  54. package/dist/{chunk-UJREE6EQ.cjs.map → chunk-LBKMQAXD.cjs.map} +1 -1
  55. package/dist/{chunk-XZYZYWKG.cjs → chunk-MI4WEFJ4.cjs} +21 -21
  56. package/dist/{chunk-XZYZYWKG.cjs.map → chunk-MI4WEFJ4.cjs.map} +1 -1
  57. package/dist/{chunk-RURPG6IS.cjs → chunk-MN7BUGXF.cjs} +7 -7
  58. package/dist/{chunk-RURPG6IS.cjs.map → chunk-MN7BUGXF.cjs.map} +1 -1
  59. package/dist/{chunk-54E2JO4E.cjs → chunk-NNCHSLFD.cjs} +309 -26
  60. package/dist/chunk-NNCHSLFD.cjs.map +1 -0
  61. package/dist/{chunk-6Q4BS6AR.js → chunk-NT3ZFUNJ.js} +31 -3
  62. package/dist/chunk-NT3ZFUNJ.js.map +1 -0
  63. package/dist/{chunk-G6AOKNAY.js → chunk-PPXUSZJU.js} +3 -3
  64. package/dist/{chunk-G6AOKNAY.js.map → chunk-PPXUSZJU.js.map} +1 -1
  65. package/dist/{chunk-6QJHSN6J.cjs → chunk-QCGSL4CJ.cjs} +4 -4
  66. package/dist/{chunk-6QJHSN6J.cjs.map → chunk-QCGSL4CJ.cjs.map} +1 -1
  67. package/dist/{chunk-DE55SA2X.js → chunk-QME5O4NG.js} +8 -6
  68. package/dist/chunk-QME5O4NG.js.map +1 -0
  69. package/dist/{chunk-KL6GAYTT.js → chunk-S6DXSQCV.js} +5 -3
  70. package/dist/chunk-S6DXSQCV.js.map +1 -0
  71. package/dist/{chunk-LSX2OFNB.js → chunk-SAOIGWA2.js} +3 -3
  72. package/dist/{chunk-LSX2OFNB.js.map → chunk-SAOIGWA2.js.map} +1 -1
  73. package/dist/{chunk-PHQVAPSD.js → chunk-SHSDGAI4.js} +29 -17
  74. package/dist/chunk-SHSDGAI4.js.map +1 -0
  75. package/dist/{chunk-QNPYYSLT.cjs → chunk-SR7WH4FX.cjs} +33 -33
  76. package/dist/{chunk-QNPYYSLT.cjs.map → chunk-SR7WH4FX.cjs.map} +1 -1
  77. package/dist/{chunk-OZA4DE23.js → chunk-SZ7ALYPK.js} +3 -3
  78. package/dist/{chunk-OZA4DE23.js.map → chunk-SZ7ALYPK.js.map} +1 -1
  79. package/dist/{chunk-DNWFFVC6.js → chunk-T4YYUI5Q.js} +3 -3
  80. package/dist/{chunk-DNWFFVC6.js.map → chunk-T4YYUI5Q.js.map} +1 -1
  81. package/dist/{chunk-ZWEVRMFN.cjs → chunk-TOYWEF6E.cjs} +51 -28
  82. package/dist/chunk-TOYWEF6E.cjs.map +1 -0
  83. package/dist/{chunk-V24EPI5N.cjs → chunk-U4DIGIC3.cjs} +5 -3
  84. package/dist/chunk-U4DIGIC3.cjs.map +1 -0
  85. package/dist/{chunk-NTCSXKZ3.cjs → chunk-U6APV2PO.cjs} +5 -5
  86. package/dist/{chunk-NTCSXKZ3.cjs.map → chunk-U6APV2PO.cjs.map} +1 -1
  87. package/dist/{chunk-7PC2YHBN.cjs → chunk-UJIPIVTB.cjs} +48 -48
  88. package/dist/{chunk-7PC2YHBN.cjs.map → chunk-UJIPIVTB.cjs.map} +1 -1
  89. package/dist/{chunk-H5KHWTAE.js → chunk-UY6QZX7H.js} +4 -4
  90. package/dist/chunk-UY6QZX7H.js.map +1 -0
  91. package/dist/{chunk-DBD4BCGH.cjs → chunk-VDFQKLDG.cjs} +33 -2
  92. package/dist/chunk-VDFQKLDG.cjs.map +1 -0
  93. package/dist/{chunk-OEOOXL3F.js → chunk-VZIMLPDC.js} +5 -5
  94. package/dist/chunk-VZIMLPDC.js.map +1 -0
  95. package/dist/{chunk-TWUFC32F.cjs → chunk-W4CJ2P3F.cjs} +8 -8
  96. package/dist/{chunk-TWUFC32F.cjs.map → chunk-W4CJ2P3F.cjs.map} +1 -1
  97. package/dist/{chunk-HP3YIWNJ.js → chunk-WARGPM7P.js} +2 -2
  98. package/dist/{chunk-HP3YIWNJ.js.map → chunk-WARGPM7P.js.map} +1 -1
  99. package/dist/{chunk-3OHRFSQL.cjs → chunk-WHK3HTFY.cjs} +73 -60
  100. package/dist/chunk-WHK3HTFY.cjs.map +1 -0
  101. package/dist/{chunk-5ZCZL73I.js → chunk-X3YRSRHP.js} +3 -3
  102. package/dist/{chunk-5ZCZL73I.js.map → chunk-X3YRSRHP.js.map} +1 -1
  103. package/dist/{chunk-OOUJZR4K.js → chunk-XK75VOEH.js} +5 -5
  104. package/dist/{chunk-OOUJZR4K.js.map → chunk-XK75VOEH.js.map} +1 -1
  105. package/dist/{chunk-LY6IR5LL.cjs → chunk-YHZUTPZL.cjs} +26 -24
  106. package/dist/{chunk-DE55SA2X.js.map → chunk-YHZUTPZL.cjs.map} +1 -1
  107. package/dist/{chunk-MGSGLRHZ.cjs → chunk-ZJQ2L3MI.cjs} +72 -11
  108. package/dist/chunk-ZJQ2L3MI.cjs.map +1 -0
  109. package/dist/entries/apps.cjs +43 -43
  110. package/dist/entries/apps.js +8 -8
  111. package/dist/entries/credits.cjs +426 -238
  112. package/dist/entries/credits.d.cts +277 -1
  113. package/dist/entries/credits.d.ts +277 -1
  114. package/dist/entries/credits.js +11 -11
  115. package/dist/entries/edl.cjs +60 -60
  116. package/dist/entries/edl.d.cts +96 -1
  117. package/dist/entries/edl.d.ts +96 -1
  118. package/dist/entries/edl.js +1 -1
  119. package/dist/entries/llm-models.cjs +76 -72
  120. package/dist/entries/llm-models.d.cts +38 -4
  121. package/dist/entries/llm-models.d.ts +38 -4
  122. package/dist/entries/llm-models.js +2 -2
  123. package/dist/entries/media.cjs +87 -87
  124. package/dist/entries/media.js +1 -1
  125. package/dist/entries/model-catalog.cjs +133 -133
  126. package/dist/entries/model-catalog.js +4 -4
  127. package/dist/entries/models.cjs +431 -415
  128. package/dist/entries/models.d.cts +62 -27
  129. package/dist/entries/models.d.ts +62 -27
  130. package/dist/entries/models.js +7 -7
  131. package/dist/entries/nodes.cjs +215 -215
  132. package/dist/entries/nodes.js +11 -11
  133. package/dist/entries/pipeline.cjs +153 -153
  134. package/dist/entries/pipeline.js +3 -3
  135. package/dist/entries/social.cjs +241 -177
  136. package/dist/entries/social.d.cts +189 -6
  137. package/dist/entries/social.d.ts +189 -6
  138. package/dist/entries/social.js +2 -2
  139. package/dist/entries/ugc.cjs +71 -71
  140. package/dist/entries/ugc.js +4 -4
  141. package/dist/entries/video.cjs +153 -153
  142. package/dist/entries/video.js +7 -7
  143. package/dist/entries/workflow.cjs +152 -152
  144. package/dist/entries/workflow.js +4 -4
  145. package/dist/index.cjs +2203 -1931
  146. package/dist/index.d.cts +5 -5
  147. package/dist/index.d.ts +5 -5
  148. package/dist/index.js +27 -27
  149. package/package.json +1 -1
  150. package/src/__tests__/audio-isolation-pricing.test.ts +49 -0
  151. package/src/__tests__/cast-swap-limits.test.ts +54 -20
  152. package/src/__tests__/competitors.test.ts +69 -0
  153. package/src/__tests__/credit-identifiers.test.ts +9 -10
  154. package/src/__tests__/lip-sync-pricing.test.ts +29 -2
  155. package/src/__tests__/llm-models.test.ts +50 -7
  156. package/src/__tests__/motion-transfer-pricing.test.ts +252 -0
  157. package/src/__tests__/suno-separate.test.ts +32 -0
  158. package/src/__tests__/video-to-video-pricing.test.ts +151 -0
  159. package/src/audio-isolation-pricing.ts +80 -0
  160. package/src/cast-swap-limits.ts +43 -25
  161. package/src/competitors.ts +86 -8
  162. package/src/credit-identifiers.ts +6 -0
  163. package/src/entries/credits.ts +56 -0
  164. package/src/entries/edl.ts +2 -0
  165. package/src/entries/llm-models.ts +2 -0
  166. package/src/entries/models.ts +4 -0
  167. package/src/entries/social.ts +34 -0
  168. package/src/generated/unit-contracts.ts +1 -0
  169. package/src/lip-sync-pricing.ts +25 -0
  170. package/src/llm-models.ts +60 -4
  171. package/src/model-catalog.ts +46 -23
  172. package/src/motion-transfer-pricing.ts +239 -0
  173. package/src/node-runtime-keys.ts +2 -2
  174. package/src/producer-types.ts +2 -0
  175. package/src/suno-separate.ts +51 -0
  176. package/src/topics.ts +162 -0
  177. package/src/use-case-output.ts +102 -0
  178. package/src/video-face-mesh.ts +1 -1
  179. package/src/video-to-video-pricing.ts +248 -0
  180. package/dist/chunk-3OHRFSQL.cjs.map +0 -1
  181. package/dist/chunk-54E2JO4E.cjs.map +0 -1
  182. package/dist/chunk-5EQRIUGI.cjs.map +0 -1
  183. package/dist/chunk-5WHU7CYE.js.map +0 -1
  184. package/dist/chunk-6Q4BS6AR.js.map +0 -1
  185. package/dist/chunk-BDW25A7Y.js.map +0 -1
  186. package/dist/chunk-DBD4BCGH.cjs.map +0 -1
  187. package/dist/chunk-FUYBUT65.js.map +0 -1
  188. package/dist/chunk-H5KHWTAE.js.map +0 -1
  189. package/dist/chunk-KL6GAYTT.js.map +0 -1
  190. package/dist/chunk-KSHAAPQF.cjs.map +0 -1
  191. package/dist/chunk-LY6IR5LL.cjs.map +0 -1
  192. package/dist/chunk-MGSGLRHZ.cjs.map +0 -1
  193. package/dist/chunk-OEOOXL3F.js.map +0 -1
  194. package/dist/chunk-PHQVAPSD.js.map +0 -1
  195. package/dist/chunk-PLANUXQL.cjs.map +0 -1
  196. package/dist/chunk-V24EPI5N.cjs.map +0 -1
  197. package/dist/chunk-YVQFYW2U.js.map +0 -1
  198. package/dist/chunk-ZWEVRMFN.cjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/seedance-extend-rate.ts","../src/gemini-omni-extend-quote.ts","../src/credit-identifiers.ts"],"names":[],"mappings":";;;;;;;AAwCO,IAAM,qCAAA,GAAwC;AAAA,EACnD,qBAAA;AAAA,EACA;AACF;AAUO,IAAM,oCAAA,GAAuC;AAG7C,IAAM,+BAAA,GAAkC;AAGxC,IAAM,4BAAA,GAA+B;AAG5C,SAAS,SAAA,CAAU,UAA4C,UAAA,EAA4B;AACzF,EAAA,OAAO,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,UAAU,QAAQ,4BAA4B,CAAA,CAAA,CAAA;AACtE;AASO,IAAM,8CACX,MAAA,CAAO,WAAA;AAAA,EACL,qCAAA,CAAsC,GAAA,CAAI,CAAC,QAAA,KAAa;AAAA,IACtD,QAAA;AAAA,IACA,OAAO,WAAA,CAAA,CAAa,aAAA,CAAc,QAAQ,CAAA,EAAG,WAAA,IAAe,EAAC,EAAG,GAAA,CAAI,CAAC,UAAA,KAAe,CAAC,UAAA,EAAY,SAAA,CAAU,UAAU,UAAU,CAAC,CAAC,CAAC;AAAA,GACnI;AACH;AAGK,IAAM,+BAAA,GAAuF;AAAA,EAClG,MAAA,EAAQ,iCAAA;AAAA,EACR,MAAA,EAAQ,iCAAA;AAAA,EACR,OAAA,EAAS;AACX;AAGO,SAAS,oCAAoC,QAAA,EAAiE;AACnH,EAAA,OAAO,OAAO,QAAA,KAAa,QAAA,IAAa,qCAAA,CAA4D,SAAS,QAAQ,CAAA;AACvH;AAGO,SAAS,6BAA6B,EAAA,EAAsB;AACjE,EAAA,OAAO,OAAO,EAAA,KAAO,QAAA,IAAY,MAAA,CAAO,MAAA,CAAO,2CAA2C,CAAA,CAAE,IAAA,CAAK,CAAC,IAAA,KAAS,OAAO,MAAA,CAAO,IAAI,CAAA,C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IAAM,wBAAA,GAA2B,CAAC,UAAA,EAAY,SAAS;AAMvD,IAAM,uBAAA,GAA0D,OAAO,MAAA,CAAO;AAAA,EACnF,cAAA;AAAA,EACA,oBAAA;AAAA,EACA,sBAAA;AAAA,EACA;AACF,CAAU;AAYH,SAAS,mBAAA,CAAoB,SAAkB,IAAA,EAAqC;AACzF,EAAA,MAAM,QAAQ,OAAA,KAAY,OAAA;AAC1B,EAAA,IAAI,IAAA,KAAS,UAAA,EAAY,OAAO,KAAA,GAAQ,oBAAA,GAAuB,cAAA;AAC/D,EAAA,OAAO,QAAQ,4BAAA,GAA+B,sBAAA;AAChD;AAkBO,SAAS,cAAA,CAAe,OAA2B,SAAA,EAA2B;AACnF,EAAA,IAAI,CAAE,8BAAA,CAAqD,QAAA,CAAS,SAAS,CAAA,EAAG;AAC9E,IAAA,OAAO,SAAA;AAAA,EACT;AACA,EAAA,OAAQ,KAAA,IAAS,wBAAA,CAAyB,KAAK,CAAA,IAAM,SAAA;AACvD;AAUO,IAAM,wBAAA,GAA6D;AAAA,EACxE,EAAA,EAAI,SAAA;AAAA,EACJ,OAAA,EAAS,cAAA;AAAA,EACT,OAAA,EAAS,cAAA;AAAA,EACT,IAAA,EAAM,WAAA;AAAA,EACN,EAAA,EAAI,SAAA;AAAA;AAAA;AAAA,EAGJ,QAAA,EAAU,eAAA;AAAA,EACV,OAAA,EAAS,cAAA;AAAA,EACT,IAAA,EAAM;AACR","file":"chunk-OEOOXL3F.js","sourcesContent":["/**\n * The price rows of the Extend Video providers priced by the seconds they\n * send (Seedance 2.5 Extend, Seedance 2.5 Flash Extend) — part of the public\n * credit-id contract:\n * the rows a run is charged a multiple of, and so the ids a client names to\n * ask what a run costs (`tailExtendCreditId`, `credit-identifiers.ts`).\n *\n * Such a run sends the source's last\n * {@link SEEDANCE_EXTEND_CONTEXT_MAX_SEC} seconds (all of a shorter source)\n * and is charged per second sent and added. A per-second price is not a\n * whole credit, so each resolution's row is the price of\n * {@link SEEDANCE_EXTEND_RATE_SECONDS} seconds, and a run is that row × (seconds\n * sent + seconds added) ÷ 2, rounded up once.\n *\n * The seconds rule lives here too (decided 2026-11-13), so a client prices a\n * run on a known source by the same rule the server charges it by\n * (`seedanceExtendSourceCreditId`, credit-identifiers.ts): how many seconds of\n * the source are sent ({@link seedanceExtendSentSec}, a picture's length read\n * by the container-overhang rule), how many are added\n * ({@link seedanceExtendAddedSec}) and the units of a rate row they make\n * ({@link seedanceExtendUnits}). `@nodaro/render-rules`\n * (`seedance-extend-pricing.ts`) and the backend read them from here.\n */\nimport { MODEL_CATALOG } from \"./model-catalog.js\"\nimport {\n pricedOutputDurationSec,\n SEEDANCE_2_R2V_MIN_REF_VIDEO_SEC,\n VIDEO_REF_VIDEO_DURATION_LIMITS,\n type SeedanceExtendProvider,\n type TailExtendProvider,\n} from \"./model-constants.js\"\nimport { CONTAINER_OVERHANG_SEC } from \"./video-duration.js\"\n\n/**\n * The Extend Video providers priced by the seconds they send, each on its own\n * rows (decided 2026-11-16: Seedance 2.5 Flash Extend beside Seedance 2.5\n * Extend). The window ({@link SEEDANCE_EXTEND_CONTEXT_MAX_SEC}), the two\n * seconds a row prices and the seconds rule are the same for all of them; the\n * rows are each provider's own, one per resolution its catalog entry offers.\n */\nexport const SEEDANCE_EXTEND_SENT_PRICED_PROVIDERS = [\n \"seedance-2-5-extend\",\n \"seedance-2-5-flash-extend\",\n] as const satisfies readonly SeedanceExtendProvider[]\n\n/** An Extend Video provider priced by the seconds it sends. */\nexport type SentPricedSeedanceExtendProvider = typeof SEEDANCE_EXTEND_SENT_PRICED_PROVIDERS[number]\n\n/**\n * The first provider priced by the seconds it sends, Seedance 2.5 Extend: what\n * the helpers below price when a caller names no provider (their signatures\n * before Seedance 2.5 Flash Extend joined).\n */\nexport const SEEDANCE_EXTEND_SENT_PRICED_PROVIDER = \"seedance-2-5-extend\" satisfies SentPricedSeedanceExtendProvider\n\n/** The most of the source's end a run sends as `@video_1`, in seconds. */\nexport const SEEDANCE_EXTEND_CONTEXT_MAX_SEC = 10\n\n/** The seconds one rate row prices. */\nexport const SEEDANCE_EXTEND_RATE_SECONDS = 2\n\n/** A provider's rate row at `resolution`: `<provider>:<resolution>:per-2s`. */\nfunction rateRowId(provider: SentPricedSeedanceExtendProvider, resolution: string): string {\n return `${provider}:${resolution}:per-${SEEDANCE_EXTEND_RATE_SECONDS}s`\n}\n\n/**\n * Each sent-priced provider's rate rows, by resolution: one per resolution its\n * catalog entry offers (Seedance 2.5 Extend 480p / 720p / 1080p; Seedance 2.5\n * Flash Extend 480p / 720p), each the price of\n * {@link SEEDANCE_EXTEND_RATE_SECONDS} seconds. Read from the catalog, so a\n * provider's rows and the resolutions it renders cannot differ.\n */\nexport const SEEDANCE_EXTEND_RATE_CREDIT_IDS_BY_PROVIDER: Readonly<Record<SentPricedSeedanceExtendProvider, Readonly<Record<string, string>>>> =\n Object.fromEntries(\n SEEDANCE_EXTEND_SENT_PRICED_PROVIDERS.map((provider) => [\n provider,\n Object.fromEntries((MODEL_CATALOG[provider]?.resolutions ?? []).map((resolution) => [resolution, rateRowId(provider, resolution)])),\n ]),\n ) as Record<SentPricedSeedanceExtendProvider, Record<string, string>>\n\n/** Seedance 2.5 Extend's rate row of each resolution: the price of {@link SEEDANCE_EXTEND_RATE_SECONDS} seconds. */\nexport const SEEDANCE_EXTEND_RATE_CREDIT_IDS: Readonly<Record<\"480p\" | \"720p\" | \"1080p\", string>> = {\n \"480p\": \"seedance-2-5-extend:480p:per-2s\",\n \"720p\": \"seedance-2-5-extend:720p:per-2s\",\n \"1080p\": \"seedance-2-5-extend:1080p:per-2s\",\n}\n\n/** Is `provider` an Extend Video provider priced by the seconds it sends? A retired id answers false: pass it through `canonicalVideoProvider` first. */\nexport function isSeedanceExtendPricedBySecondsSent(provider: unknown): provider is SentPricedSeedanceExtendProvider {\n return typeof provider === \"string\" && (SEEDANCE_EXTEND_SENT_PRICED_PROVIDERS as readonly string[]).includes(provider)\n}\n\n/** Is `id` one of the rate rows (of any sent-priced provider)? */\nexport function isSeedanceExtendRateCreditId(id: unknown): boolean {\n return typeof id === \"string\" && Object.values(SEEDANCE_EXTEND_RATE_CREDIT_IDS_BY_PROVIDER).some((rows) => Object.values(rows).includes(id))\n}\n\n/**\n * The seconds a tail-recipe extend run (Seedance 2.5 / 2.0, Kling 4) adds for a requested `duration`: the\n * seconds its price counts (`pricedOutputDurationSec`, the provider's catalog\n * default when unset or unreadable), held in the provider's catalog window.\n * The one reading of the length: the route queues it, the worker generates\n * it, and every price and quote counts it.\n */\nexport function seedanceExtendAddedSec(provider: TailExtendProvider, duration: unknown): number {\n const requested = typeof duration === \"number\" || typeof duration === \"string\" ? duration : undefined\n const offered = MODEL_CATALOG[provider]?.durations ?? []\n const min = offered.length > 0 ? Math.min(...offered) : 1\n const max = offered.length > 0 ? Math.max(...offered) : Number.POSITIVE_INFINITY\n return Math.min(max, Math.max(min, Math.round(pricedOutputDurationSec(provider, requested))))\n}\n\n/**\n * The shortest source (its picture) each sent-priced provider continues, in\n * seconds: the shortest reference video its model takes. Seedance 2.5 Extend:\n * 1.8 s, measured on the 2.0 family (`SEEDANCE_2_R2V_MIN_REF_VIDEO_SEC`; a\n * nominal 2 s clip that probes a frame short still runs). Seedance 2.5 Flash\n * Extend: Flash's documented 2 s (`VIDEO_REF_VIDEO_DURATION_LIMITS`, decided\n * 2026-11-16). The route and a quote refuse a shorter source, and the worker\n * again before it generates.\n */\nexport const SEEDANCE_EXTEND_MIN_SOURCE_SEC: Readonly<Record<SentPricedSeedanceExtendProvider, number>> = {\n \"seedance-2-5-extend\": SEEDANCE_2_R2V_MIN_REF_VIDEO_SEC,\n \"seedance-2-5-flash-extend\": VIDEO_REF_VIDEO_DURATION_LIMITS[\"seedance-2-5-flash\"]!.minSec,\n}\n\n/** A length the source gives, when it is one: finite and above 0. */\nfunction knownSec(sec: number | null | undefined): number | undefined {\n return typeof sec === \"number\" && Number.isFinite(sec) && sec > 0 ? sec : undefined\n}\n\n/**\n * A picture's measured length as the seconds it is charged as — the\n * platform's container-overhang rule: at most `CONTAINER_OVERHANG_SEC` (a\n * quarter second) past a whole second is that whole second (8.04 s is 8 s,\n * 8.25 s is 8 s); anything else is exactly as measured (8.3 s is 8.3 s).\n * Under a second there is no whole second to read it as.\n */\nexport function seedanceExtendSourceSec(pictureSec: number): number {\n const whole = Math.floor(pictureSec)\n return whole >= 1 && pictureSec - whole <= CONTAINER_OVERHANG_SEC ? whole : pictureSec\n}\n\n/**\n * The seconds of the source a run is charged for sending: its last\n * {@link SEEDANCE_EXTEND_CONTEXT_MAX_SEC}, or all of a shorter source, its\n * picture's length read by the container-overhang rule\n * ({@link seedanceExtendSourceSec}). A source whose length is not known (a\n * quote before the upstream video exists, or a length that is not a positive\n * finite number) counts the whole window: the most a run sends.\n */\nexport function seedanceExtendSentSec(sourcePictureSec: number | null | undefined): number {\n const known = knownSec(sourcePictureSec)\n return known === undefined ? SEEDANCE_EXTEND_CONTEXT_MAX_SEC : Math.min(SEEDANCE_EXTEND_CONTEXT_MAX_SEC, seedanceExtendSourceSec(known))\n}\n\n/**\n * Whether a sent-priced extend on `provider` refuses a source of this measured\n * picture length: a known length (positive, finite) under the shortest source\n * the provider takes ({@link SEEDANCE_EXTEND_MIN_SOURCE_SEC}: 1.8 s, 2 s on\n * Seedance 2.5 Flash Extend), compared as measured, as the route refuses it\n * before anything is reserved and the worker before it generates. A length\n * that is not known is never refused here (the run measures the source itself).\n */\nexport function seedanceExtendSourceRefused(provider: SentPricedSeedanceExtendProvider, sourcePictureSec: number | null | undefined): boolean {\n const known = knownSec(sourcePictureSec)\n return known !== undefined && known < SEEDANCE_EXTEND_MIN_SOURCE_SEC[provider]\n}\n\n/** Seedance 2.5 Extend's {@link seedanceExtendSourceRefused} (its 1.8 s floor). */\nexport function seedanceExtendRefusesSource(sourcePictureSec: number | null | undefined): boolean {\n return seedanceExtendSourceRefused(SEEDANCE_EXTEND_SENT_PRICED_PROVIDER, sourcePictureSec)\n}\n\n/** The units of a rate row a run that sends `sentSec` and adds `addedSec` is charged. */\nexport function seedanceExtendUnits(sentSec: number, addedSec: number): number {\n return (sentSec + addedSec) / SEEDANCE_EXTEND_RATE_SECONDS\n}\n","/**\n * The price of ONE Gemini Omni Flash 1.2 Extend run (`gemini-omni-flash-1-2-extend`),\n * as ONE id (decided 2026-11-17) — part of the public credit-id contract.\n *\n * Such a run is charged per second of video it sends and adds, on two rows\n * the server reads, the total rounded up once: no single row × units can name\n * it. `geminiOmniExtendQuoteCreditId` names the whole run instead:\n *\n * `gemini-omni-flash-1-2-extend:<resolution>:sent-<S>s:added-<A>s`\n *\n * - `<resolution>`: the one the run renders at and is priced by (360p / 720p /\n * 1080p / 4k; any other is 720p, as the run reads it);\n * - `<S>`: the seconds of the source sent — its last 10 seconds, or all of a\n * shorter source, read by the platform's container-overhang rule (8.04 s is\n * 8 s, 8.3 s is 8.3 s); with no known source, the whole 10 s window, the\n * most a run sends;\n * - `<A>`: the whole seconds added, held in the engine's 3–10 s window (8\n * when none is asked).\n *\n * `GET /v1/credits/model-cost` and `POST /v1/credits/model-costs` answer it\n * with exactly what such a run is charged; an id the server does not price (a\n * resolution, a length or a source it refuses) lands in `missing`. Numbers are\n * written exactly as JavaScript prints them.\n */\nimport { MODEL_CATALOG } from \"./model-catalog.js\"\nimport { seedanceExtendAddedSec, seedanceExtendSentSec } from \"./seedance-extend-rate.js\"\n\nconst PROVIDER = \"gemini-omni-flash-1-2-extend\"\nconst DEFAULT_RESOLUTION = \"720p\"\nconst PREFIX = `${PROVIDER}:`\nconst NUMBER = String.raw`\\d{1,7}(?:\\.\\d{1,20})?`\nconst QUOTE_ID = new RegExp(`^${PROVIDER}:([0-9a-z]+):sent-(${NUMBER})s:added-(\\\\d{1,3})s$`)\n\n/** A `gemini-omni-flash-1-2-extend:<res>:sent-<S>s:added-<A>s` id, read back. */\nexport interface GeminiOmniExtendQuoteCreditIdParts {\n /** The resolution the run renders at. */\n readonly resolution: string\n /** The seconds of the source sent. */\n readonly sentSec: number\n /** The whole seconds added. */\n readonly addedSec: number\n}\n\n/**\n * The id of the whole price of one Gemini Omni Flash 1.2 Extend run that adds\n * `duration` seconds at `resolution` to a source whose picture lasts\n * `sourcePictureSec` (undefined, or not a positive number: not known — the\n * whole 10 s window, the most a run of that length costs).\n */\nexport function geminiOmniExtendQuoteCreditId(args: {\n readonly sourcePictureSec?: number | null\n readonly duration?: number | string\n readonly resolution?: unknown\n}): string {\n const resolution = typeof args.resolution === \"string\" && MODEL_CATALOG[PROVIDER]?.resolutions?.includes(args.resolution)\n ? args.resolution\n : DEFAULT_RESOLUTION\n const sent = seedanceExtendSentSec(args.sourcePictureSec)\n const added = seedanceExtendAddedSec(PROVIDER, args.duration)\n return `${PREFIX}${resolution}:sent-${String(sent)}s:added-${String(added)}s`\n}\n\n/**\n * The parts of such an id by its shape alone, or undefined. Which\n * resolutions, lengths and sources the server prices is the server's to say:\n * an id it does not price lands in `missing`.\n */\nexport function parseGeminiOmniExtendQuoteCreditId(id: string): GeminiOmniExtendQuoteCreditIdParts | undefined {\n if (typeof id !== \"string\" || !id.startsWith(PREFIX)) return undefined\n const m = QUOTE_ID.exec(id)\n if (!m) return undefined\n const sentSec = Number(m[2])\n const addedSec = Number(m[3])\n if (!Number.isFinite(sentSec) || sentSec <= 0 || !Number.isInteger(addedSec) || addedSec <= 0) return undefined\n return { resolution: m[1]!, sentSec, addedSec }\n}\n","/**\n * Build composite credit model identifiers for variable pricing.\n * Shared between frontend and backend.\n */\n\nimport {\n HIGH_QUALITY_PROVIDERS,\n TWO_K_RESOLUTION_PROVIDERS,\n RESOLUTION_2K_4K_TIERED_PROVIDERS,\n IDEOGRAM_PROVIDERS,\n DURATION_PRICED_PROVIDERS,\n AUDIO_ADDON_PROVIDERS,\n MODE_ADDON_PROVIDERS,\n RESOLUTION_VIDEO_REF_PRICING,\n RESOLUTION_DURATION_PRICING,\n VEO_RESOLUTION_TIERED_PROVIDERS,\n VIDEO_DURATION_TIERS,\n pricedOutputDurationSec,\n snapToNearestDuration,\n PRICING_DEFAULT_RESOLUTION,\n MOTION_DURATION_TIERS,\n T2I_TO_I2I_VARIANT,\n isVeoProvider,\n isMinimaxH3Provider,\n isGeminiOmniProvider,\n isGeminiOmniPerSecondProvider,\n isWan3Provider,\n isViduQ4Provider,\n isKling4Provider,\n normalizeKling4Resolution,\n isKling4FlashProvider,\n KLING_4_FLASH_RESOLUTION,\n isGrokVideo15Provider,\n normalizeGrokVideo15Resolution,\n isPixverseV6MaxProvider,\n normalizePixverseV6MaxQuality,\n VIDEO_REF_RATE_PROVIDERS,\n normalizeMinimaxH3Resolution,\n normalizeWan3Resolution,\n normalizeViduQ4Resolution,\n videoAudioPricedOn,\n type VideoAudioRequest,\n canonicalVideoProvider,\n isTailExtendProvider,\n isPixverseExtendProvider,\n PIXVERSE_V6_EXTEND_PROVIDER,\n isGrokExtendProvider,\n isGrokExtendSourceModel,\n GROK_EXTEND_SOURCE_NODE_TYPES,\n GROK_EXTEND_PROVIDER,\n type CatalogExtendProvider,\n type SeedanceExtendProvider,\n type TailExtendProvider,\n} from \"./model-constants.js\"\nimport {\n SEEDANCE_EXTEND_CONTEXT_MAX_SEC,\n SEEDANCE_EXTEND_RATE_CREDIT_IDS_BY_PROVIDER,\n SEEDANCE_EXTEND_SENT_PRICED_PROVIDER,\n isSeedanceExtendPricedBySecondsSent,\n type SentPricedSeedanceExtendProvider,\n seedanceExtendAddedSec,\n seedanceExtendSourceRefused,\n seedanceExtendSentSec,\n seedanceExtendUnits,\n} from \"./seedance-extend-rate.js\"\nimport { geminiOmniExtendQuoteCreditId } from \"./gemini-omni-extend-quote.js\"\nimport { unitQuoteCreditId } from \"./credit-estimators/unit-quote.js\"\nimport { isFlux2Model, FLUX2_RES_MP, type Flux2Model } from \"./flux2-pricing.js\"\nimport {\n GPT_IMAGE_2_6_DEFAULT_QUALITY,\n GPT_IMAGE_2_6_DEFAULT_RESOLUTION,\n GPT_IMAGE_2_6_MAX_INPUT_IMAGES,\n GPT_IMAGE_2_6_QUALITIES,\n GPT_IMAGE_2_6_RESOLUTIONS,\n gptImage26PricedFormat,\n isGptImage26I2i,\n isGptImage26Tiered,\n type GptImage26TieredModel,\n type ImageFormatLevers,\n} from \"./gpt-image-2-6.js\"\nimport { isMinimaxH3Image, minimaxH3ImageCreditId } from \"./minimax-h3-image.js\"\nimport { flux3KleinCreditId, isFlux3Klein } from \"./flux-3-klein.js\"\nimport {\n SEEDREAM_5_5_I2I,\n SEEDREAM_5_5_MAX_INPUT_IMAGES,\n isSeedream55,\n isSeedream55I2i,\n seedream55Resolution,\n type Seedream55Model,\n} from \"./seedream-5-5.js\"\nimport { VIDEO_DURATION_AUTO } from \"./video-duration-auto.js\"\nimport { uiResolutionFill } from \"./video-ui-defaults.js\"\nimport { MODEL_CATALOG, autoAspectNeedsSourceImage, normalizeModelInput, normalizeVideoRequestParams, defaultResolutionFor, type ModelInputAdjustment, type SourceImageSize } from \"./model-catalog.js\"\n\n/**\n * The megapixel tier a Flux 2 credit identifier is keyed on, for ANY incoming\n * `resolution` value.\n *\n * Flux 2 is the only family whose identifier INTERPOLATES the resolution\n * instead of matching it against a known set, and its callers are not\n * guaranteed to hand it a Flux 2 value:\n * - the multi-provider cost preview prices one node's data against EVERY\n * selected provider (`frontend/src/ee/hooks/use-providers-credits-sum.ts`),\n * so a node whose `resolution` is \"2K\" (the flux / nano-banana-pro value\n * space) reaches this branch verbatim;\n * - node data written straight into workflow JSON by an agent, an import or\n * a template never ran the config panel's provider-change fail-safe.\n * Interpolating that produced the off-grid id `flux-2-pro:2KMP:0ref`, which no\n * pricing row can answer — every cost badge 503'd `price_not_configured`\n * (18 production app-reports, 2026-09-07..14).\n *\n * A value off the grid snaps to the model's DEFAULT tier — the same `preferred`\n * value `normalizeModelInput` uses — so the preview asks for exactly the id the\n * route will reserve (both routes and the orchestrator normalize through\n * `resolveNormalizedImageGen` first, which makes this snap a no-op for them).\n * An ABSENT resolution keeps its long-standing meaning (\"this caller has no\n * resolution dimension at all\") and stays on 1 MP rather than moving to the\n * model default, which would silently re-price every resolution-less node.\n */\nfunction flux2MegapixelTier(model: Flux2Model, resolution?: string): string {\n const bare = (v: string) => v.replace(/\\s*MP$/i, \"\").trim()\n const raw = typeof resolution === \"string\" ? bare(resolution) : \"\"\n if (raw === \"\") return \"1\"\n // Numeric match so \"2.0\"/\" 2 MP\" land on the same grid point as \"2\", and the\n // GRID's own spelling is what gets emitted — returning the caller's \"2.0\"\n // would build \":2.0MP:\", another id no pricing row carries.\n const tier = FLUX2_RES_MP.find((t) => Number(t) === Number(raw))\n return tier ?? bare(defaultResolutionFor(model) ?? \"1 MP\")\n}\n\n/**\n * The price id of a GPT Image 2.6 Flare or Sunburst run: `<id>:<quality>:<size>`,\n * and on an edit `<id>:<quality>:<size>:<N>ref`, N being the input images.\n * PNG, JPEG and WebP cost the same, so they share those ids. Only a format that\n * prices differently adds a part of its own:\n * - a GIF takes no size (it is 512 pixels a frame) and is priced by its band\n * of frames: `<id>:<quality>:gif-<band>`, on an edit `…:gif-<band>:<N>ref`\n * (`gpt-image-2-6-flare:medium:gif-9-12`);\n * - an SVG is priced at its size and its level of detail:\n * `<id>:<quality>:<size>:svg-<level>`, on an edit `…:svg-<level>:<N>ref`\n * (`gpt-image-2-6-flare-i2i:high:2K:svg-detailed:3ref`).\n *\n * A value off the grid (a stored node, the multi-provider preview pricing one\n * node's data against every model) lands on the default rather than building\n * an id no row answers. A text-to-image id sent input images runs on the edit\n * endpoint, so a caller that does not swap the model first (the entity routes,\n * a pipeline pin) is priced there too. An edit always has at least its source.\n */\nfunction gptImage26CreditId(\n provider: GptImage26TieredModel,\n quality: string | undefined,\n resolution: string | undefined,\n referenceImageCount: number | undefined,\n imageFormat: ImageFormatLevers | undefined,\n): string {\n const q = (GPT_IMAGE_2_6_QUALITIES as readonly string[]).includes(quality ?? \"\") ? quality : GPT_IMAGE_2_6_DEFAULT_QUALITY\n const r = (GPT_IMAGE_2_6_RESOLUTIONS as readonly string[]).includes(resolution ?? \"\") ? resolution : GPT_IMAGE_2_6_DEFAULT_RESOLUTION\n const images = Math.trunc(referenceImageCount ?? 0)\n const model = !isGptImage26I2i(provider) && images > 0 ? T2I_TO_I2I_VARIANT[provider]! : provider\n const format = gptImage26PricedFormat(imageFormat)\n const base = format?.kind === \"gif\"\n ? `${model}:${q}:gif-${format.band}`\n : format?.kind === \"svg\"\n ? `${model}:${q}:${r}:svg-${format.level}`\n : `${model}:${q}:${r}`\n if (!isGptImage26I2i(model)) return base\n return `${base}:${Math.min(Math.max(1, images), GPT_IMAGE_2_6_MAX_INPUT_IMAGES)}ref`\n}\n\n/**\n * The price id of a Seedream 5.5 run: `seedream-5-5:<size>`, and on an edit\n * `seedream-5-5-i2i:<size>:<N>ref`, N being the input images (1 to 10). Each\n * size has its own id, 1K and 1.5K at the same price.\n *\n * A size off its list (a stored node, the multi-provider preview pricing one\n * node's data against every model) or none lands on the default, 2K, which is\n * what the provider renders with none. A text-to-image id sent input images\n * runs on the edit endpoint (the provider swaps it), so a caller that does not\n * swap the model first (the entity routes, a pipeline pin) is priced there too.\n * An edit always has at least its source, and is priced for at most the images\n * the provider takes (what a request holds past it is not sent).\n */\nfunction seedream55CreditId(\n provider: Seedream55Model,\n resolution: string | undefined,\n referenceImageCount: number | undefined,\n): string {\n const size = seedream55Resolution(resolution)\n const images = Math.trunc(referenceImageCount ?? 0)\n const model = !isSeedream55I2i(provider) && images > 0 ? SEEDREAM_5_5_I2I : provider\n if (!isSeedream55I2i(model)) return `${model}:${size}`\n return `${model}:${size}:${Math.min(Math.max(1, images), SEEDREAM_5_5_MAX_INPUT_IMAGES)}ref`\n}\n\n/**\n * Compute composite model identifier for variable credit pricing.\n * Examples: \"gpt-image:high\", \"flux:2K\", \"nano-banana-pro:4K\", \"ideogram:TURBO\",\n * \"flux-2-pro:2MP\", \"flux-2-max:2MP:1ref\" (Flux 2 — billed per megapixel).\n *\n * For image models, uses quality/resolution/renderingSpeed and (Flux 2) the output\n * megapixel count plus (Flux 2 Max) the number of reference images attached at request time.\n * For video models, uses duration/sound params when the model has variable pricing.\n */\nexport function buildCreditModelIdentifier(\n provider: string,\n quality?: string,\n resolution?: string,\n renderingSpeed?: string,\n targetResolution?: string,\n referenceImageCount?: number,\n /** The output format, a GIF's frames and an SVG's level: read only by a model whose price depends on them (GPT Image 2.6). */\n imageFormat?: ImageFormatLevers,\n): string {\n // Flux 2 family: billed per output megapixel AND per reference image (each\n // ref counts as input megapixels). Resolution arrives as \"N MP\" strings (the\n // UI value space); strip the unit. ALL three models encode the ref count\n // (capped at 8): Pro/Klein i2i always carry the source image as a ref and\n // their cost formula charges per input MP, so the reserved identifier must\n // reflect refs (there is no metered true-up to correct an under-reserved tier).\n if (isFlux2Model(provider)) {\n return `${provider}:${flux2MegapixelTier(provider, resolution)}MP:${Math.min(referenceImageCount ?? 0, 8)}ref`\n }\n if (isGptImage26Tiered(provider)) {\n return gptImage26CreditId(provider, quality, resolution, referenceImageCount, imageFormat)\n }\n // MiniMax H3 Image: by size, and on an edit by its reference images\n // (`minimax-h3-image:2K`, `minimax-h3-image-i2i:4K:3ref`).\n if (isMinimaxH3Image(provider)) {\n return minimaxH3ImageCreditId(provider, resolution, referenceImageCount)\n }\n if (isSeedream55(provider)) {\n return seedream55CreditId(provider, resolution, referenceImageCount)\n }\n // FLUX 3 Klein: by size alone, the same on both ids (`flux-3-klein:2K`,\n // `flux-3-klein-i2i:4K`); images move a text-to-image id onto the edit id.\n if (isFlux3Klein(provider)) {\n return flux3KleinCreditId(provider, resolution, referenceImageCount)\n }\n if (HIGH_QUALITY_PROVIDERS.has(provider) && quality === \"high\") {\n return `${provider}:high`\n }\n if (TWO_K_RESOLUTION_PROVIDERS.has(provider) && resolution === \"2K\") {\n return `${provider}:2K`\n }\n if (provider === \"nano-banana-pro\" && resolution === \"4K\") {\n return `${provider}:4K`\n }\n if (RESOLUTION_2K_4K_TIERED_PROVIDERS.has(provider) && (resolution === \"2K\" || resolution === \"4K\")) {\n return `${provider}:${resolution}`\n }\n // Topaz Image Upscale: 2K is default (no suffix), 4K/8K get composite identifiers\n if (provider === \"topaz-image-upscale\" && targetResolution && targetResolution !== \"2K\") {\n return `${provider}:${targetResolution}`\n }\n if (IDEOGRAM_PROVIDERS.has(provider)) {\n if (renderingSpeed === \"TURBO\") return `${provider}:TURBO`\n if (renderingSpeed === \"QUALITY\") return `${provider}:QUALITY`\n }\n return provider\n}\n\n/**\n * An image request's catalog-snapped parameters PLUS the credit identifier\n * priced off them.\n *\n * `adjustments` is the disclosure channel: every lever this changed, why, and\n * to what. Routes return it in the 200 body so a caller learns their value was\n * corrected instead of silently getting something else.\n */\nexport interface NormalizedImageGen {\n /** Credit identifier, priced off the SNAPPED `resolution` / `quality`. */\n identifier: string\n /** The catalog model id the params were snapped against (post T2I→I2I swap). */\n modelId: string\n aspectRatio?: string\n resolution?: string\n quality?: string\n background?: string\n /** The file the run writes (`outputFormat`); undefined is PNG. */\n outputFormat?: string\n /** A GIF's frames and the time each shows (ms); set only for a GIF. */\n gifFrames?: number\n gifFrameDurationMs?: number\n /** An SVG's level of detail; set only for an SVG. */\n svgLevel?: string\n /** Empty when the caller's values were already valid for `modelId`. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The catalog model `resolveNormalizedImageGen` snaps against: the provider\n * (Nano Banana when none is named), or — with `swapToI2i` and references\n * attached — its i2i sibling, the model the generate-image route and the\n * workflow payload builder then send. That sibling has its OWN catalog entry\n * and lever lists. Exported so a caller that has to decide something about\n * those lists before the snap (whether a photo's size is worth reading) asks\n * about the same model the snap will use.\n */\nexport function normalizedImageGenModelId(opts: {\n provider: unknown\n refCount: number\n swapToI2i?: boolean\n}): string {\n const provider = typeof opts.provider === \"string\" && opts.provider.length > 0 ? opts.provider : \"nano-banana\"\n return opts.swapToI2i && opts.refCount > 0 ? (T2I_TO_I2I_VARIANT[provider] ?? provider) : provider\n}\n\n/**\n * Whether \"auto\" on a Generate Image request can need its photo's size: the\n * model the snap runs against (`normalizedImageGenModelId` with the swap on)\n * has no native auto. Given the ASSEMBLED reference count, it asks about exactly\n * that model; without one — a write boundary, or a run before its references\n * assemble — about both the provider and its i2i sibling, since references may\n * yet attach.\n */\nexport function imageGenAutoAspectNeedsSourceImage(opts: {\n provider: unknown\n aspectRatio: unknown\n refCount?: number\n}): boolean {\n const asks = (refCount: number) =>\n autoAspectNeedsSourceImage(normalizedImageGenModelId({ provider: opts.provider, refCount, swapToI2i: true }), opts.aspectRatio)\n return opts.refCount === undefined ? asks(0) || asks(1) : asks(opts.refCount)\n}\n\n/**\n * The output-format levers of a request body or a node's data, typed for\n * `normalizeModelInput`: a non-string format or level is no value, and a GIF's\n * numbers may arrive as numeric strings (a form field, a FieldMapping).\n */\nexport function imageFormatInputOf(source: object): { outputFormat?: string; gifFrames?: number; gifFrameDurationMs?: number; svgLevel?: string } {\n const record = source as Record<string, unknown>\n const str = (v: unknown): string | undefined => (typeof v === \"string\" && v.length > 0 ? v : undefined)\n const num = (v: unknown): number | undefined => {\n const n = typeof v === \"number\" ? v : typeof v === \"string\" && v.trim() !== \"\" ? Number(v) : Number.NaN\n return Number.isFinite(n) ? n : undefined\n }\n return {\n outputFormat: str(record.outputFormat),\n gifFrames: num(record.gifFrames),\n gifFrameDurationMs: num(record.gifFrameDurationMs),\n svgLevel: str(record.svgLevel),\n }\n}\n\n/**\n * Snap an image request's catalog-governed levers to a combination the model\n * actually accepts, and price the credit identifier off the SNAPPED values.\n *\n * WHY THE SNAP LIVES HERE and not at the call site. Both image routes compute\n * their credit identifier TWICE — once in the `creditGuard` preHandler (the\n * CHECK) and once at the handler's `reserveCreditsForJob` (the DEBIT) — and a\n * dedicated test asserts the two stay byte-identical (see\n * `backend/src/routes/__tests__/generate-image.test.ts`, \"CHECK === DEBIT\").\n * `resolution` and `quality` are pricing dimensions, so a snap applied at only\n * one of those sites breaks that invariant, and `commit_credits` never collects\n * an upward delta — the reserve IS the charge. Putting the snap inside the\n * primitive makes CHECK, DEBIT and the workflow orchestrator agree by\n * construction rather than by everyone remembering to call a normalizer.\n *\n * Inputs are typed `unknown` on purpose: the preHandler runs BEFORE Zod, so a\n * caller can put a number or an object in `resolution`. Non-strings become\n * `undefined` rather than reaching `normalizeModelInput` as a lie.\n *\n * Unknown model ids pass through untouched (same contract as\n * `normalizeModelInput`) — the route's provider enum is the gate for those.\n *\n * `sourceImage` is the size of the photo the request transforms or is drawn\n * from (an image-to-image / edit source, or Generate Image's first wired\n * reference). It decides \"auto\" on a model without a native auto, and the\n * ratio is not a pricing dimension on any such model (pinned across the catalog\n * by `auto-aspect-source.test.ts`). With `masked` on a model whose masked edit\n * follows its photo (`maskEditMatchesSource`) it also decides the SIZE, a\n * pricing dimension: the CHECK and the DEBIT must then both be given it (the\n * image-to-image route reads it once, before its credit check).\n */\nexport function resolveNormalizedImageGen(opts: {\n provider: string | undefined\n aspectRatio?: unknown\n quality?: unknown\n resolution?: unknown\n renderingSpeed?: unknown\n /** Does not price on its own, but a transparent background can move the size. */\n background?: unknown\n /** The file the run writes, and a GIF's frames and speed or an SVG's level: a GIF and an SVG price differently. */\n outputFormat?: unknown\n gifFrames?: unknown\n gifFrameDurationMs?: unknown\n svgLevel?: unknown\n refCount: number\n swapToI2i?: boolean\n sourceImage?: SourceImageSize\n /** The request carries an inpainting mask: on a model whose masked edit follows its photo, the photo's size decides the ratio and the priced size. */\n masked?: boolean\n}): NormalizedImageGen {\n const str = (v: unknown): string | undefined =>\n typeof v === \"string\" && v.length > 0 ? v : undefined\n\n const modelId = normalizedImageGenModelId(opts)\n\n const n = normalizeModelInput(\n modelId,\n {\n aspectRatio: str(opts.aspectRatio),\n resolution: str(opts.resolution),\n quality: str(opts.quality),\n background: str(opts.background),\n ...imageFormatInputOf(opts),\n },\n { sourceImage: opts.sourceImage, masked: opts.masked },\n )\n\n return {\n identifier: buildCreditModelIdentifier(\n modelId,\n n.quality,\n n.resolution,\n str(opts.renderingSpeed),\n undefined,\n opts.refCount,\n { outputFormat: n.outputFormat, gifFrames: n.gifFrames, svgLevel: n.svgLevel },\n ),\n modelId,\n aspectRatio: n.aspectRatio,\n resolution: n.resolution,\n quality: n.quality,\n background: n.background,\n outputFormat: n.outputFormat,\n gifFrames: n.gifFrames,\n gifFrameDurationMs: n.gifFrameDurationMs,\n svgLevel: n.svgLevel,\n adjustments: n.adjustments,\n }\n}\n\n/**\n * Reference-aware image-generation credit identifier — the SINGLE source of\n * truth shared by the single-node routes (`/v1/generate-image`,\n * `/v1/image-to-image`) and the workflow orchestrator\n * (`payload-builder.ts`). It centralises the two pricing dimensions that must\n * match across both paths or a Flux 2 generation is billed the wrong tier\n * (Flux 2 commits non-metered / has no upward true-up, so the reserved\n * identifier IS the final charge):\n * - `refCount`: the number of reference images sent to the provider (Flux 2\n * bills per ref). generate-image passes the assembled count (0 for pure\n * text-to-image); image-to-image passes 1 (the primary `imageUrl`) + extras.\n * - `swapToI2i`: generate-image auto-swaps a bare T2I provider to its i2i\n * sibling (`T2I_TO_I2I_VARIANT`) when refs are attached, so the credit id\n * matches the variant actually invoked. image-to-image is already an i2i\n * provider → pass `false`.\n *\n * The LoRA short-circuit (`flux-lora-character`) stays at the call site because\n * the routing decision needs a DB lookup the routes/orchestrator own.\n */\nexport function resolveImageGenCreditIdentifier(opts: {\n provider: string | undefined\n quality?: string\n resolution?: string\n renderingSpeed?: string\n outputFormat?: unknown\n gifFrames?: unknown\n svgLevel?: unknown\n refCount: number\n swapToI2i?: boolean\n}): string {\n return resolveNormalizedImageGen(opts).identifier\n}\n\n// T2V-specific credit overrides: some providers have different costs for T2V\n// vs I2V/V2V due to different default resolutions or colliding with image model names.\nconst T2V_CREDIT_OVERRIDES: Record<string, string> = {\n \"grok\": \"grok-i2v\", // T2V grok, same as I2V grok (not image grok = 4 cr)\n \"wan\": \"wan-t2v\", // T2V wan 1080p = (V2V wan 720p = 70 cr)\n \"wan-turbo\": \"wan-turbo-t2v\", // T2V wan-turbo 720p = (I2V wan-turbo 480p = 40 cr)\n}\n\n/**\n * Compute composite model identifier for video models with duration/audio-based pricing.\n * Examples: \"kling-3.0:5s\", \"kling-3.0:10s:audio\", \"seedance-2:8s:720p-ref\"\n *\n * @param provider - Video model key (e.g., \"kling-3.0\")\n * @param duration - Video duration in seconds\n * @param sound - The request's audio: its `sound` flag, or the whole audio\n * request (`{ sound, generateAudio }`) — read through `videoAudioIntent`, the\n * same reading the provider runner sends the model's switch from\n * @param nodeType - Node type for T2V-specific cost overrides\n * @param mode - Quality variant that affects pricing\n * @param resolution - Output resolution (used by Seedance 2 for 480p/720p pricing)\n * @param hasVideoRef - Whether a reference video is connected (Seedance 2 uses a lower per-second rate when true)\n */\n/**\n * LTX 2.3 (Lightricks via Replicate) credit tiers: priced by\n * (resolution-band × duration-seconds). Keys mirror STATIC_CREDIT_COSTS /\n * model_pricing EXACTLY (lowercase band + raw seconds + \"s\"), e.g.\n * \"ltx-2.3-pro:1080p:6s\". This map is the source of truth for the nearest-tier\n * snap below, so an off-catalog (resolution, duration) from a direct API/SDK\n * call maps to a SEEDED price instead of hard-failing (price_not_configured\n * 503). Pro: 6/8/10s at every band. Fast: up to 20s at 1080p, 6/8/10s at 2k/4k.\n */\nconst LTX_DURATION_TIERS: Record<string, Record<string, number[]>> = {\n \"ltx-2.3-pro\": { \"1080p\": [6, 8, 10], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n \"ltx-2.3-fast\": { \"1080p\": [6, 8, 10, 12, 14, 16, 18, 20], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n}\n\n/**\n * The (band, duration) tier the LTX pricing ladder charges for a request, or\n * `undefined` for a non-LTX provider. Extracted so\n * `buildVideoCreditModelIdentifier` and `pricedVideoSelection` read the ladder\n * ONCE — the routes must send the tier they reserved, and a second copy of this\n * math is exactly how the two drift apart.\n *\n * An unknown/absent band falls back to 1080p (LTX's own default, and the band\n * `snapLtxInput` snaps to at the Replicate call), and an off-tier duration\n * snaps to the NEAREST seeded one so the emitted composite always prices.\n */\nfunction ltxPricedTier(\n provider: string,\n resolution?: string,\n duration?: number | string,\n): { band: string; duration: number } | undefined {\n const bands = LTX_DURATION_TIERS[provider]\n if (!bands) return undefined\n const band = bands[String(resolution)] ? String(resolution) : \"1080p\"\n const allowed = bands[band]!\n // The model's own default (catalog `defaultDuration`) when unset, then the\n // nearest rung of THIS band's ladder — the length LTX renders.\n const dur = snapToNearestDuration(pricedOutputDurationSec(provider, duration), allowed)\n return { band, duration: dur }\n}\n\n/**\n * The resolution a provider whose runner NORMALIZES the lever actually renders,\n * in the lowercase spelling of its credit composites — billing collapses\n * through the very normalizer the runner sends, so render == billed for every\n * spelling. `undefined` passes through untouched for every other provider.\n */\nfunction wireNormalizedResolution(provider: string, resolution: string | undefined): string | undefined {\n if (isWan3Provider(provider)) return normalizeWan3Resolution(resolution).toLowerCase()\n if (isViduQ4Provider(provider)) return normalizeViduQ4Resolution(resolution)\n if (isKling4Provider(provider)) return normalizeKling4Resolution(resolution)\n // Kling 4.0 Flash renders 720p whatever it is asked (its runner sends 720p).\n if (isKling4FlashProvider(provider)) return KLING_4_FLASH_RESOLUTION\n if (isGrokVideo15Provider(provider)) return normalizeGrokVideo15Resolution(resolution)\n if (isPixverseV6MaxProvider(provider)) return normalizePixverseV6MaxQuality(resolution)\n return resolution\n}\n\nexport function buildVideoCreditModelIdentifier(\n rawProvider: string,\n duration?: number | string,\n sound?: boolean | VideoAudioRequest,\n nodeType?: \"image-to-video\" | \"text-to-video\",\n mode?: string,\n resolution?: string,\n hasVideoRef?: boolean,\n): string {\n const audio: VideoAudioRequest = typeof sound === \"object\" && sound !== null ? sound : { sound }\n // A retired model (RETIRED_VIDEO_PROVIDERS) is priced as the model it runs as.\n const provider = canonicalVideoProvider(rawProvider) as string\n // A tail-recipe Extend Video provider (Seedance 2.5 / 2.0, Kling 4) is\n // priced through the one builder every surface that prices an extend reads\n // (Seedance 2.5: the most a run of that length costs, the whole 10-second\n // window sent — see tailExtendCreditId).\n if (isTailExtendProvider(provider)) return tailExtendCreditId(provider, duration, resolution)\n // PixVerse V6 Extend on its own rows too, its sound read from the extend's\n // own switch (`generateAudio`), else the request's `sound`.\n if (isPixverseExtendProvider(provider)) return pixverseExtendCreditId(duration, resolution, audio.generateAudio ?? audio.sound)\n // Grok Extend is priced at its SOURCE's resolution, which only its source\n // check knows: a resolution handed here is never read, so the dearer row.\n if (isGrokExtendProvider(provider)) return grokExtendCreditId(duration)\n // T2V overrides: some providers have different base costs for text-to-video\n let effectiveProvider = provider\n if (nodeType === \"text-to-video\") {\n const override = T2V_CREDIT_OVERRIDES[provider]\n if (override) {\n // If override target also has duration pricing, use it as effective provider\n if (DURATION_PRICED_PROVIDERS.has(override)) {\n effectiveProvider = override\n } else {\n return override\n }\n }\n }\n\n // VEO 3.x resolution-tiered pricing: 720p is the base (no suffix), 1080p gets\n // \":1080p\" (Fast/Lite only), and 4K gets \":4k\" for ALL three tiers — direct-4K\n // generation chains KIE's get-4k-video off the base generation (the base runs\n // at 1080p). Duration is fixed at 8s for VEO so the duration-tier path below\n // does not apply.\n if (isVeoProvider(effectiveProvider)) {\n if (resolution === \"4k\") return `${effectiveProvider}:4k`\n // 1080p tier is Fast/Lite only (Quality has no 1080p surcharge).\n if (resolution === \"1080p\" && VEO_RESOLUTION_TIERED_PROVIDERS.has(effectiveProvider)) return `${effectiveProvider}:1080p`\n return effectiveProvider\n }\n\n // Gemini Omni family (gemini-omni-video + gemini-omni-flash): priced by\n // (resolution-band × duration), with a flat per-generation rate when a source\n // video is supplied (V2V). Lowercase \"4k\". The prefix is TEMPLATED from the\n // provider id, so a further Omni SKU needs no edit here — it only has to join\n // GEMINI_OMNI_PROVIDERS and seed its rows. These models are deliberately NOT\n // in DURATION_PRICED_PROVIDERS; this branch early-returns before that gate.\n // A per-second SKU (Omni Flash 1.2) prices on the `:<N>s:<res>` ladder below.\n if (isGeminiOmniProvider(effectiveProvider) && !isGeminiOmniPerSecondProvider(effectiveProvider)) {\n if (hasVideoRef) {\n return resolution === \"4k\" ? `${effectiveProvider}:4k:vref` : `${effectiveProvider}:vref`\n }\n // The rendered length through the catalog funnel (nearest legal tier, the\n // model's own default when unset) so the composite is always a SEEDED one.\n const d = pricedOutputDurationSec(effectiveProvider, duration)\n return resolution === \"4k\" ? `${effectiveProvider}:4k:${d}` : `${effectiveProvider}:${d}`\n }\n\n // LTX 2.3: priced by (resolution-band × duration-seconds). The RESERVE must be\n // the correct composite — commit_credits (migration 176) only refunds a surplus\n // (actual < reserved) and NEVER collects an upward delta, so an under-reserved\n // LTX run (the bare-id default = cheapest 1080p:6s tier) stays under-charged\n // even with meteredCost:true. Snap to a seeded tier so the id always prices.\n const ltxTier = ltxPricedTier(effectiveProvider, resolution, duration)\n if (ltxTier) {\n return `${effectiveProvider}:${ltxTier.band}:${ltxTier.duration}s`\n }\n\n if (!DURATION_PRICED_PROVIDERS.has(effectiveProvider)) {\n return effectiveProvider\n }\n\n // A named-provider request with NO duration renders the model's own default\n // (kie/models.ts extraParams), so price that default — not the global 5s —\n // for providers whose per-second tiers wouldn't snap 5 up to it\n // (minimax-h3, seedance-2-5). One helper, shared with the dynamic\n // reference-video reservations, so the tier and the scaled reserve agree.\n const durationSec = pricedOutputDurationSec(effectiveProvider, duration)\n const tiers = VIDEO_DURATION_TIERS[effectiveProvider]\n if (!tiers) return effectiveProvider\n\n // Find the matching duration tier\n const tier = tiers.find(t => durationSec <= t.maxSeconds) ?? tiers[tiers.length - 1]\n let identifier = `${effectiveProvider}:${tier.suffix}`\n\n // Append mode suffix for providers with quality-tiered pricing\n // \"high\" comes from I2V videoSize field, \"pro\" comes from T2V mode field\n if (MODE_ADDON_PROVIDERS.has(effectiveProvider) && (mode === \"high\" || mode === \"pro\")) {\n identifier += \":high\"\n }\n\n // Seedance 2.0 family: per-second billing with resolution + video-ref dimensions.\n // KIE accepts 480p / 720p / 1080p natively; per-second rates rise non-linearly\n // so each tier gets its own composite identifier.\n if (RESOLUTION_VIDEO_REF_PRICING.has(effectiveProvider)) {\n // Clamp to the model's catalog resolutions (single source of truth): e.g.\n // seedance-2-mini exposes only 480p/720p, so a stale/explicit 1080p (or 4k)\n // maps to its top priced tier instead of emitting an unpriced composite\n // (which the hard-fail credit guard would 503 on at runtime).\n const supported = MODEL_CATALOG[effectiveProvider]?.resolutions ?? [\"480p\", \"720p\", \"1080p\"]\n // An OMITTED resolution renders the model's KIE-side default, so price that\n // default rather than the cheapest tier — otherwise an intent-less request\n // reserves 480p against a 720p render and commit_credits (refund-only) can\n // never collect the delta. Providers without an entry keep the historical\n // 480p fallback, so this cannot reprice anything already live.\n const requested = resolution ?? PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const want = requested === \"4k\" ? \"4k\" : requested === \"1080p\" ? \"1080p\" : requested === \"720p\" ? \"720p\" : \"480p\"\n // Unsupported (e.g. a stale 1080p on seedance-2-mini) clamps to the model's\n // top priced tier so the emitted composite is always seeded.\n const res = supported.includes(want) ? want : (supported[supported.length - 1] ?? \"480p\")\n identifier += `:${res}`\n if (hasVideoRef) identifier += \"-ref\"\n }\n\n // Duration × resolution pricing without a -ref dimension. Resolutions\n // outside the provider's priced tiers (or undefined) collapse to the first\n // (default) tier so the emitted composite is always seeded — the hard-fail\n // guard fuzzes the whole resolution space.\n const resTiers = RESOLUTION_DURATION_PRICING[effectiveProvider]\n if (resTiers) {\n // The \"default tier\" is the provider's DECLARED default when it has one\n // (PRICING_DEFAULT_RESOLUTION — wan-3 renders 720p, not the cheapest tier),\n // otherwise the first listed tier. Declaring it explicitly means a cosmetic\n // reorder of the tier list can never reprice a live model, and an OMITTED\n // *or* unsupported resolution both land on what actually renders instead of\n // on the cheapest row (commit_credits refunds a surplus but can never\n // collect a shortfall). Behaviour-neutral for every member without a\n // declared default.\n const declaredDefault = PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const fallback = declaredDefault && resTiers.includes(declaredDefault) ? declaredDefault : resTiers[0]!\n // Wan 3.0 renders through `normalizeWan3Resolution`, which is CASE-INSENSITIVE\n // (\"1080P\" — KIE's own OpenAPI enum spelling, and the natural value for an\n // integrator reading the provider docs — renders 1080P). The tier list here is\n // lowercase and `Array.includes` is case-sensitive, so without this the render\n // path and the billing path disagree: \"1080P\" rendered the top tier and billed\n // the 720p row, a shortfall `commit_credits` (refund-only) can never collect.\n // Collapsing through the SAME normalizer the runner uses makes render == billed\n // by construction for every spelling, including garbage (→ the declared 720p).\n // Scoped to the families whose runner normalizes on purpose (Wan 3.0, Vidu\n // Q4, Kling 4.0, Grok Imagine Video 1.5, PixVerse V6 Max): the other RESOLUTION_DURATION_PRICING members pass `resolution` to\n // their wire verbatim, so case-folding their billing without probing their\n // wire would reprice live models.\n const requested = wireNormalizedResolution(effectiveProvider, resolution)\n const res = requested && resTiers.includes(requested) ? requested : fallback\n identifier += `:${res}`\n // A reference VIDEO bills at its own per-second rate (Kling 4.0).\n if (hasVideoRef && VIDEO_REF_RATE_PROVIDERS.has(effectiveProvider)) identifier += \"-ref\"\n }\n\n // MiniMax Hailuo 3 (768P lever, 2026-08-03): bare duration composites stay\n // the 2K (default) rate — byte-identical to the pre-lever seeded rows, so\n // existing workflows and admin overrides keep their ids — and only a\n // verified 768P selection appends \":768p\". normalizeMinimaxH3Resolution\n // collapses anything else to 2K, matching what KIE renders for an\n // omitted/unknown value, so billing can never undercut the render.\n if (isMinimaxH3Provider(effectiveProvider) && normalizeMinimaxH3Resolution(resolution) === \"768P\") {\n identifier += \":768p\"\n }\n\n // Append the audio suffix LAST, after every other dimension\n // (`kling-3.0:10s:audio`, `pixverse-v6-max:5s:720p:audio`). The request's\n // audio is read by `videoAudioIntent` — the reading `applyVideoAudioToggle`\n // sends the model's switch from — and with no intent falls back to the\n // model's own default (capability `defaultOn` — kling-3.0 and PixVerse V6 Max\n // generate audio unless explicitly disabled), so a request is billed for the\n // audio it actually produces.\n if (AUDIO_ADDON_PROVIDERS.has(effectiveProvider) && videoAudioPricedOn(effectiveProvider, audio)) {\n identifier += \":audio\"\n }\n\n return identifier\n}\n\n/**\n * The credit identifier a video GENERATION node is quoted at — Generate Video\n * (and the legacy Image/Text to Video nodes) and the Video to Video Seedance\n * edit lane, on every surface that quotes one: the node's cost pill, the\n * editor's run estimate, the prompt modal and the backend pre-run estimator.\n *\n * It applies the request levers the run applies BEFORE it prices\n * (payload-builder's `resolveVideoRequestNorm`): the model's UI resolution fill\n * when the node names none (`uiResolutionFill` — what the run sends), then the\n * catalog normalizer `normalizeVideoRequestParams`, which also owns the Seedance\n * Draft rule (a draft is priced AND sent at 480p whatever resolution came with\n * it). Without that, a node with no resolution was quoted at the identifier's\n * own default band (720p on Seedance 2.5) while the run sent and reserved 480p.\n *\n * `hasVideoRef` must come from the GRAPH (a wired reference-video edge, e.g.\n * `countRefModalityEdges(edges, id, \"video\") > 0`), never node data: nothing\n * writes `referenceVideoUrls` into a video node, so reading it there always\n * quoted the plain ladder for a run that reserves on the `-ref` one.\n */\nexport function videoGenerationCreditId(args: {\n provider: string\n duration?: number | string\n sound?: boolean\n /** The request's `generateAudio`, read after `sound` where the model reads it (`videoAudioIntent`). */\n generateAudio?: boolean\n nodeType?: \"image-to-video\" | \"text-to-video\"\n mode?: string\n resolution?: string\n draft?: boolean\n hasVideoRef?: boolean\n}): string {\n const { resolution } = normalizeVideoRequestParams(args.provider, {\n resolution: args.resolution ?? uiResolutionFill(args.provider),\n draft: args.draft === true,\n })\n return buildVideoCreditModelIdentifier(\n args.provider,\n args.duration,\n { sound: args.sound, generateAudio: args.generateAudio },\n args.nodeType ?? \"image-to-video\",\n args.mode,\n resolution,\n args.hasVideoRef === true,\n )\n}\n\n/**\n * The credit identifier a Video to Video node's Seedance EDIT lane reserves\n * under. Seedance has no v2v endpoint — the lane is a text-to-video job in edit\n * shape with the source clip as reference video 1 — so it prices on the\n * REFERENCE-VIDEO ladder at the model's LONGEST clip (Auto duration), and the\n * measured settlement refunds down to what was actually delivered.\n *\n * A thin call into {@link videoGenerationCreditId}, so a Generate Video node\n * making the same KIE call (Seedance, Auto, a wired reference video) is quoted\n * the same id. FOUR surfaces must agree on it exactly: the orchestrator's\n * reservation (payload-builder.ts), the backend pre-run estimator\n * (ee/billing/credits.ts), the node's cost pill, and the frontend run-level\n * estimate (config-panels/helpers.ts). A quote that disagrees with the reserve\n * is the documented `price_not_configured` / blank-pill trap.\n *\n * `resolution` is the node's one `v2vResolution` field; when unset the model's\n * own UI fill is priced, which is what the lane will send. `draft` is the\n * node's Seedance Draft toggle (priced at 480p).\n */\nexport function seedanceVideoEditCreditId(provider: string, resolution?: string, draft?: boolean): string {\n return videoGenerationCreditId({\n provider,\n duration: VIDEO_DURATION_AUTO,\n nodeType: \"text-to-video\",\n resolution,\n draft,\n hasVideoRef: true,\n })\n}\n\n/** The resolution a tail-recipe extend that names none, or one it does not offer, is priced and run at (every one offers it). */\nconst TAIL_EXTEND_DEFAULT_RESOLUTION = \"720p\"\n\n/**\n * The resolution a tail-recipe Extend Video run (Seedance 2.5 / 2.0, Kling 4)\n * is priced at, and so the one it must render at: the requested one when it is\n * among the provider's catalog `resolutions`, else 720p (also when none is\n * named). The workflow run queues it and the worker holds the job to it, so a\n * stored or sent resolution the model does not offer (`4k`, or `480p` on Kling\n * 4) can never render above, or bill apart from, the row it reserved.\n */\nexport function tailExtendResolution(provider: TailExtendProvider, resolution?: unknown): string {\n return typeof resolution === \"string\" && MODEL_CATALOG[provider]?.resolutions?.includes(resolution)\n ? resolution\n : TAIL_EXTEND_DEFAULT_RESOLUTION\n}\n\n/**\n * The rate row a sent-priced Extend Video run at `resolution` is charged a\n * multiple of: `provider`'s row (Seedance 2.5 Extend when none is named) of the\n * resolution the run is priced and rendered at ({@link tailExtendResolution}:\n * one the model offers, else 720p).\n */\nexport function seedanceExtendRateCreditId(\n resolution: unknown,\n provider: SentPricedSeedanceExtendProvider = SEEDANCE_EXTEND_SENT_PRICED_PROVIDER,\n): string {\n const rows = SEEDANCE_EXTEND_RATE_CREDIT_IDS_BY_PROVIDER[provider]\n return rows[tailExtendResolution(provider, resolution)] ?? rows[TAIL_EXTEND_DEFAULT_RESOLUTION]!\n}\n\n/**\n * The ONE id a sent-priced Extend Video run (Seedance 2.5 Extend, Seedance 2.5\n * Flash Extend) on a known source is charged: the whole-run quote\n * (`<rate row>:<units>u`, {@link unitQuoteCreditId}) of that run, which the\n * price lookups (`GET /v1/credits/model-cost`, `POST /v1/credits/model-costs`)\n * answer with exactly what the run is charged.\n *\n * The units are (seconds sent + seconds added) ÷ 2, by the rule the server\n * charges a run by (seedance-extend-rate.ts): the seconds sent are the\n * source's last {@link SEEDANCE_EXTEND_CONTEXT_MAX_SEC} seconds, or all of a\n * shorter source, its picture's length read by the container-overhang rule\n * (`CONTAINER_OVERHANG_SEC`: 8.04 s counts as 8 s, 8.3 s as 8.3 s); the seconds\n * added snap into the catalog window as {@link tailExtendCreditId} reads them.\n *\n * @param sourcePictureSec the source's measured picture length, in seconds.\n * Not known or unreadable (undefined, null, not a positive finite number):\n * the whole window is counted — {@link seedanceExtendFullWindowCreditId},\n * the most a run of that length costs.\n * @param duration the seconds added (the request's `duration`).\n * @param resolution the request's resolution (one the model does not offer is 720p).\n * @param provider the extend provider (Seedance 2.5 Extend when none is named).\n * @returns the id, or `undefined` for a source the extend refuses: a measured\n * picture shorter than the shortest source it takes\n * (`SEEDANCE_EXTEND_MIN_SOURCE_SEC`: 1.8 s, 2 s on Flash; compared as measured, as the\n * route and the worker compare it), whatever the seconds added. No run on\n * such a source is made or charged, so there is no price to name.\n */\nexport function seedanceExtendSourceCreditId(\n sourcePictureSec: number | null | undefined,\n duration?: number | string,\n resolution?: unknown,\n provider: SentPricedSeedanceExtendProvider = SEEDANCE_EXTEND_SENT_PRICED_PROVIDER,\n): string | undefined {\n if (seedanceExtendSourceRefused(provider, sourcePictureSec)) return undefined\n return seedanceExtendWholeRunCreditId(provider, seedanceExtendSentSec(sourcePictureSec), duration, resolution)\n}\n\n/** The whole-run quote of a sent-priced extend run that sends `sentSec` and adds `duration` at `resolution`. */\nfunction seedanceExtendWholeRunCreditId(\n provider: SentPricedSeedanceExtendProvider,\n sentSec: number,\n duration: number | string | undefined,\n resolution: unknown,\n): string {\n const units = seedanceExtendUnits(sentSec, seedanceExtendAddedSec(provider, duration))\n return unitQuoteCreditId(seedanceExtendRateCreditId(resolution, provider), units)\n}\n\n/**\n * The most a sent-priced Extend Video run that adds `duration` seconds at\n * `resolution` can cost, as ONE id: the whole-run quote\n * (`<rate row>:<units>u`, {@link unitQuoteCreditId}) of a run that sends the\n * whole {@link SEEDANCE_EXTEND_CONTEXT_MAX_SEC}-second window — the units are\n * (10 + the seconds added) ÷ 2. A run sends at most that window, so this is\n * never below what a run of that length is charged; the price lookups answer\n * it at the rate row's current price. A client that knows the source names\n * its run exactly with {@link seedanceExtendSourceCreditId}; this is that id\n * for a source not known. `provider`: Seedance 2.5 Extend when none is named.\n *\n * The seconds added snap into the catalog window exactly as\n * {@link tailExtendCreditId} reads them for every tail-recipe provider.\n */\nexport function seedanceExtendFullWindowCreditId(\n duration?: number | string,\n resolution?: unknown,\n provider: SentPricedSeedanceExtendProvider = SEEDANCE_EXTEND_SENT_PRICED_PROVIDER,\n): string {\n return seedanceExtendWholeRunCreditId(provider, seedanceExtendSentSec(undefined), duration, resolution)\n}\n\n/**\n * The credit identifier a client prices one tail-recipe Extend Video run at —\n * the one builder every surface that prices it reads (the route's guard and\n * reservation, the workflow reservation and estimate, the editor, and every\n * client of this package), so none of them can name a different row.\n *\n * The seconds added snap into the provider's catalog `durations` (its catalog\n * `defaultDuration` when unset, through {@link pricedOutputDurationSec}); the\n * resolution is {@link tailExtendResolution}'s.\n * - Seedance 2.0 Extend (4–15 s) and Kling 4 Extend (3–30 s): their own rows,\n * one per second of the window and resolution, `<provider>:<N>s:<res>`\n * (480p / 720p / 1080p; Kling 4 720p / 1080p) — the price a run is charged.\n * - Seedance 2.5 Extend and Seedance 2.5 Flash Extend (4–30 s) are charged\n * per second they send and add, and how much is sent depends on the\n * source: this names the most a run of that length costs, the whole\n * 10-second window sent ({@link seedanceExtendFullWindowCreditId},\n * `<provider>:<res>:per-2s:<units>u`). A client that knows the\n * source names the run's own id with {@link seedanceExtendSourceCreditId}.\n *\n * A retired id (`seedance-2-extend`) is not a {@link TailExtendProvider}:\n * pass a stored or sent provider through `canonicalVideoProvider` first\n * ({@link buildVideoCreditModelIdentifier} does).\n */\nexport function tailExtendCreditId(\n provider: TailExtendProvider,\n duration?: number | string,\n resolution?: string,\n): string {\n if (isSeedanceExtendPricedBySecondsSent(provider)) return seedanceExtendFullWindowCreditId(duration, resolution, provider)\n // Gemini Omni Flash 1.2 Extend: the whole-run quote of a run that sends the\n // whole 10 s window (`geminiOmniExtendQuoteCreditId`, no source known).\n if (provider === \"gemini-omni-flash-1-2-extend\") return geminiOmniExtendQuoteCreditId({ duration, resolution })\n return `${provider}:${pricedOutputDurationSec(provider, duration)}s:${tailExtendResolution(provider, resolution)}`\n}\n\n/** PixVerse V6 Extend's qualities, ascending: its catalog `resolutions`. */\ntype PixverseExtendQuality = \"360p\" | \"540p\" | \"720p\" | \"1080p\"\n\n/** The quality a PixVerse V6 Extend that names none, or one it cannot map, is priced and run at. */\nconst PIXVERSE_EXTEND_DEFAULT_QUALITY: PixverseExtendQuality = \"720p\"\n\n/**\n * The quality a PixVerse V6 Extend run is priced at, and so the one it must\n * render at: a quality it offers (360p / 540p / 720p / 1080p) as asked; 480p —\n * the lowest the other extends render, which PixVerse does not — at the\n * nearest it offers, 540p; anything else, or none, at 720p. The route refuses\n * 480p and every other value it does not offer; a saved node, a quick-strip\n * switch or a workflow written elsewhere carrying one runs, and is priced, at\n * this quality instead.\n */\nexport function pixverseExtendQuality(resolution?: unknown): PixverseExtendQuality {\n if (resolution === \"480p\") return \"540p\"\n return typeof resolution === \"string\" && MODEL_CATALOG[PIXVERSE_V6_EXTEND_PROVIDER]?.resolutions?.includes(resolution)\n ? (resolution as PixverseExtendQuality)\n : PIXVERSE_EXTEND_DEFAULT_QUALITY\n}\n\n/**\n * The credit identifier one PixVerse V6 Extend run is priced at:\n * `pixverse-v6-extend:<N>s:<quality>`, `:audio` appended with sound. The\n * seconds added snap into its catalog `durations` (1–15, its default 5 when\n * unset, {@link pricedOutputDurationSec}); the quality is\n * {@link pixverseExtendQuality}'s; the sound is on unless `generateAudio` is\n * `false` (the editor's sound switch shows it on until it is turned off).\n */\nexport function pixverseExtendCreditId(duration?: number | string, resolution?: unknown, generateAudio?: boolean): string {\n const seconds = pricedOutputDurationSec(PIXVERSE_V6_EXTEND_PROVIDER, duration)\n return `${PIXVERSE_V6_EXTEND_PROVIDER}:${seconds}s:${pixverseExtendQuality(resolution)}${generateAudio === false ? \"\" : \":audio\"}`\n}\n\n/**\n * The resolution a catalog Extend Video run ({@link CatalogExtendProvider}) is\n * priced at, and so renders at: a tail recipe's {@link tailExtendResolution},\n * PixVerse V6's {@link pixverseExtendQuality}.\n */\nexport function catalogExtendResolution(provider: CatalogExtendProvider, resolution?: unknown): string {\n return isPixverseExtendProvider(provider) ? pixverseExtendQuality(resolution) : tailExtendResolution(provider, resolution)\n}\n\n/**\n * The credit identifier one catalog Extend Video run is priced at — the one\n * builder every surface that prices one reads (the route's guard and\n * reservation, the workflow reservation and estimate, the editor): a tail\n * recipe's {@link tailExtendCreditId} (no sound switch is priced there), and\n * PixVerse V6's {@link pixverseExtendCreditId}.\n */\nexport function catalogExtendCreditId(\n provider: CatalogExtendProvider,\n duration?: number | string,\n resolution?: string,\n generateAudio?: boolean,\n): string {\n return isPixverseExtendProvider(provider)\n ? pixverseExtendCreditId(duration, resolution, generateAudio)\n : tailExtendCreditId(provider, duration, resolution)\n}\n\n/** The source resolutions Grok Extend is priced at (one row each per length added). */\nexport type GrokExtendSourceResolution = \"480p\" | \"720p\"\n\n/**\n * The seconds a Grok Extend run adds for a requested `duration`: 6 or 10 as\n * asked, its default 6 when unset or unreadable, any other length snapped to\n * the nearer of the two ({@link pricedOutputDurationSec} on its catalog\n * `durations`). The route refuses any other length; a saved node, a quick-strip\n * switch or a workflow written elsewhere runs, and is priced, at this one.\n */\nexport function grokExtendSeconds(duration: unknown): number {\n const requested = typeof duration === \"number\" || typeof duration === \"string\" ? duration : undefined\n return pricedOutputDurationSec(GROK_EXTEND_PROVIDER, requested)\n}\n\n/**\n * The credit identifier one Grok Extend run is priced at:\n * `grok-extend:<6|10>s:<480p|720p>`. The resolution is the SOURCE's — what\n * Grok bills an extension at — as the source check answers it (the route's\n * hold, the workflow hold); never a resolution the request names. Anything but\n * `480p` (a source not known yet, an estimate) is priced at the dearer 720p\n * row, so a quote never falls below the charge.\n */\nexport function grokExtendCreditId(duration?: unknown, sourceResolution?: unknown): string {\n const resolution: GrokExtendSourceResolution = sourceResolution === \"480p\" ? \"480p\" : \"720p\"\n return `${GROK_EXTEND_PROVIDER}:${grokExtendSeconds(duration)}s:${resolution}`\n}\n\n/**\n * The resolution a Grok Extend is quoted at from the clip a Grok Imagine node\n * already made — the clip the run extends: the take its task (`kieTaskId`, the\n * task the node hands on) names. The charge reads the resolution the source's\n * JOB recorded (`input_data.resolution`; with none, the KIE config's pin, else\n * Grok's own 480p default — `sourceResolution` in grok-extend-source.ts), and\n * every lane that lands a take records that value on the result row beside\n * the task (`recordedResolution`), so the quote reads the same fact: `480p`\n * (any case) → `480p`; anything else, or none → `720p`, never below the charge\n * — a take with no recorded value may have been charged at a pinned 720p. Also\n * `720p` when no result names the node's task (a result landed before results\n * recorded it, or the take was deleted while the node kept its task).\n * Undefined when the node holds neither a task nor a result (it has not run).\n */\nfunction grokMadeClipResolution(data: Record<string, unknown>): GrokExtendSourceResolution | undefined {\n const rows = (Array.isArray(data.generatedResults) ? (data.generatedResults as ReadonlyArray<unknown>) : []).filter(\n (r): r is Record<string, unknown> =>\n typeof r === \"object\" && r !== null && typeof (r as { url?: unknown }).url === \"string\" && (r as { url: string }).url.trim() !== \"\",\n )\n const task = typeof data.kieTaskId === \"string\" && data.kieTaskId.trim() !== \"\" ? data.kieTaskId.trim() : undefined\n if (task === undefined && rows.length === 0) return undefined\n const named = task !== undefined ? rows.find((r) => typeof r.kieTaskId === \"string\" && r.kieTaskId.trim() === task) : undefined\n const recorded = typeof named?.recordedResolution === \"string\" ? named.recordedResolution.trim().toLowerCase() : undefined\n return recorded === \"480p\" ? \"480p\" : \"720p\"\n}\n\n/**\n * The source resolution a Grok Extend node is QUOTED at (its estimate, its\n * editor price), read off the node wired into its `video` input — `480p` only\n * when the clip the extension continues is surely 480p; `720p`, the dearer\n * row, for anything else (nothing wired, another model, a clip whose\n * resolution is not known):\n *\n * - a Grok Imagine video node (text- or image-to-video) that already made a\n * clip and does not make a new one in the quoted run: THAT clip's\n * resolution ({@link grokMadeClipResolution}) — the run extends it, whatever\n * the node is set to now;\n * - one that has not run yet, or runs again in the quoted run (it is in\n * `rerunIds` and not frozen): its setting — `480p` when set so, which every\n * mode sends as set; unset, Grok may render it at either.\n *\n * `rerunIds`: the nodes the quoted run executes — empty for one node's own\n * price (its pill, its Run button), where nothing upstream runs again. The\n * run is held and charged at the source's own row, read off its job.\n */\nexport function grokExtendWiredSourceResolution(\n nodeId: string | undefined,\n nodes: ReadonlyArray<{ readonly id?: string; readonly type?: string; readonly data?: unknown }>,\n edges: ReadonlyArray<{ readonly source?: string; readonly target?: string; readonly targetHandle?: string | null }> | undefined,\n rerunIds: ReadonlySet<string> = new Set(),\n): GrokExtendSourceResolution {\n if (nodeId === undefined || !edges) return \"720p\"\n const sources = edges\n .filter((e) => e.target === nodeId && (e.targetHandle == null || e.targetHandle === \"video\"))\n .map((e) => nodes.find((n) => n.id !== undefined && n.id === e.source))\n if (sources.length === 0) return \"720p\"\n const surely480p = sources.every((n) => {\n const data = (n?.data ?? {}) as Record<string, unknown>\n if (n?.type === undefined || !GROK_EXTEND_SOURCE_NODE_TYPES.has(n.type) || !isGrokExtendSourceModel(data.provider)) return false\n const runsAgain = n.id !== undefined && rerunIds.has(n.id) && data.skipped !== true\n const made = runsAgain ? undefined : grokMadeClipResolution(data)\n if (made !== undefined) return made === \"480p\"\n return typeof data.resolution === \"string\" && data.resolution.trim().toLowerCase() === \"480p\"\n })\n return surely480p ? \"480p\" : \"720p\"\n}\n\n/** @deprecated Use {@link tailExtendResolution}, which also answers for Kling 4 Extend. */\nexport function seedanceExtendResolution(provider: SeedanceExtendProvider, resolution?: unknown): string {\n return tailExtendResolution(provider, resolution)\n}\n\n/** @deprecated Use {@link tailExtendCreditId}, which also answers for Kling 4 Extend. */\nexport function seedanceExtendCreditId(\n provider: SeedanceExtendProvider,\n duration?: number | string,\n resolution?: string,\n): string {\n return tailExtendCreditId(provider, duration, resolution)\n}\n\n/** What the video credit identifier PRICES for a request, for the levers whose\n * priced value must also be the value we SEND. */\nexport interface PricedVideoSelection {\n /** The resolution band the reservation is priced at when the request omitted\n * one — and only where the platform DECLARES that band as the provider's own\n * default. `undefined` means \"leave `resolution` exactly as the request had\n * it\": either the caller supplied one, or the provider's real default is not\n * known to be the band the identifier assumes. */\n resolution?: string\n /** The length the reservation is priced at and the wire carries, for a\n * provider whose price follows the clip length (LTX's seeded tier, the KIE\n * ladders, Gemini Omni). `undefined` for every other provider, and for Auto:\n * their duration passes through. */\n duration?: number\n /** Non-empty only for a lever the caller ASKED for and did not get (a 7s\n * request snapped to the 6s tier). Filling an omitted lever is a disclosure of\n * the price already being charged, not a correction, so it reports nothing. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The other half of the video money path: `normalizeVideoRequestParams` snaps a\n * value the CATALOG governs; this returns the value the PRICE ladder governs.\n *\n * Two defects it closes, both of the same shape — the identifier prices one\n * thing and the wire carries another, and `commit_credits` (migration 176) only\n * ever refunds a surplus, so the reservation is the final charge:\n *\n * 1. **Absent resolution.** `buildVideoCreditModelIdentifier` prices an omitted\n * `resolution` as a concrete band (LTX → 1080p; a\n * {@link PRICING_DEFAULT_RESOLUTION} member → its declared default). Leaving\n * the key unset then lets the provider pick — documented for the KIE members\n * (their `extraParams` pin the same band) but UNDOCUMENTED for LTX on\n * Replicate. Sending the band we priced makes the two agree by construction.\n *\n * The fill is deliberately limited to providers with a DECLARED default.\n * `buildVideoCreditModelIdentifier` also has un-declared fallbacks — the\n * cheapest tier for a resolution-priced provider with no\n * `PRICING_DEFAULT_RESOLUTION` row — and those are a HEDGE, not a verified\n * provider default: seedance-2 / -fast / -mini pin `resolution: \"720p\"`\n * KIE-side while the identifier prices 480p, so filling 480p would downgrade\n * the render to match a price we already know is wrong. That mismatch is a\n * pre-existing identifier bug and is fixed by seeding the row, not here.\n *\n * 2. **Duration.** Every provider whose price follows the clip length is\n * charged at the length it RENDERS: its own default when the request named\n * none (catalog `defaultDuration`), the nearest length it offers otherwise\n * (`pricedOutputDurationSec` — the runners' own snap rule). The LTX ladder is\n * seeded per (band × seconds), so a 7s request snaps onto the 6s tier;\n * sending 7s would bill six and render seven. The same value is returned for\n * the other length-priced providers (the KIE ladders, Gemini Omni), so what\n * is priced is what is sent. Auto (-1) is the model's call and is untouched.\n *\n * Pure, and IDEMPOTENT against the identifier: feeding its output back in\n * cannot move the reserved tier. `video-request-normalize.test.ts` proves that\n * over every provider × resolution × duration.\n */\nexport function pricedVideoSelection(opts: {\n provider: string\n resolution?: string\n duration?: number | string\n}): PricedVideoSelection {\n const adjustments: ModelInputAdjustment[] = []\n const ltx = ltxPricedTier(opts.provider, opts.resolution, opts.duration)\n\n // The band the request will be priced AND rendered at. An explicit value\n // always wins — this only ever fills an omission.\n const resolution = opts.resolution\n ?? (ltx ? ltx.band : PRICING_DEFAULT_RESOLUTION[opts.provider])\n\n const requested = typeof opts.duration === \"string\" ? parseInt(opts.duration, 10) : opts.duration\n const asked = requested !== undefined && !Number.isNaN(requested)\n\n // Every provider whose price follows the clip length sends the length it is\n // CHARGED at (the catalog funnel: its own default when unset, the nearest\n // legal length otherwise). Auto (-1) is the model's call and is left alone.\n const lengthPriced = !!ltx || DURATION_PRICED_PROVIDERS.has(opts.provider) || isGeminiOmniProvider(opts.provider)\n if (!lengthPriced || (!ltx && asked && requested! <= 0)) return { resolution, adjustments }\n\n const duration = ltx ? ltx.duration : pricedOutputDurationSec(opts.provider, opts.duration)\n if (asked && requested !== duration) {\n adjustments.push({\n field: \"duration\",\n from: requested!,\n to: duration,\n reason: ltx\n ? `LTX renders ${ltx.band} in ${ltx.duration}s steps — using ${ltx.duration}s instead of ${requested}s.`\n : `${opts.provider} renders ${duration}s clips at the nearest length it offers — using ${duration}s instead of ${requested}s.`,\n })\n }\n return { resolution, duration, adjustments }\n}\n\n/**\n * Compute composite model identifier for motion control with duration-tiered pricing.\n * Examples: \"kling-3.0-motion:10s\", \"kling-3.0-motion:1080p:15s\", \"motion-transfer:5s\"\n *\n * Wan Animate providers use resolution-tiered pricing (not per-second):\n * \"wan-animate-move\" (480p default), \"wan-animate-move:580p\", \"wan-animate-move:720p\"\n *\n * @param provider - Motion control provider key (\"kling\" for 2.6, \"kling-3.0\", \"wan-animate-move\", \"wan-animate-replace\")\n * @param resolution - \"720p\" or \"1080p\" (Kling), \"480p\" or \"580p\" or \"720p\" (Wan Animate); a size the\n * model does not have is priced as the size it runs at (`motionTransferResolution`: Wan Animate's 1080p as 720p)\n * @param videoDuration - Reference video duration in seconds (defaults to 10s, unused for Wan Animate)\n */\nexport function buildMotionCreditModelIdentifier(\n provider: string,\n resolution: string,\n videoDuration?: number,\n): string {\n return motionCreditIdentifier(provider, motionTransferResolution(provider, resolution).resolution, videoDuration)\n}\n\n/** The catalog model a Motion Transfer option runs: the base of the id it is billed under. */\nfunction motionModelOf(provider: string): string {\n return motionCreditIdentifier(provider, \"720p\").split(\":\")[0]!\n}\n\n/**\n * Motion models still SENT at a size their catalog entry does not list, as\n * before Wan Animate had entries: Kling 2.6 and Kling 3.0 Motion Control\n * (720p and 1080p). Their price is the same either way (any size but 1080p is\n * charged on the 720p rows), and Kling 3.0's provider already sends such a\n * size as 720p; whether Kling 2.6 should too is not decided. Only shrinks.\n */\nconst MOTION_MODELS_SENT_AS_NAMED: ReadonlySet<string> = new Set([\"motion-transfer\", \"kling-3.0-motion\"])\n\n/** The size a Motion Transfer run is sent and charged at, and what moved. */\nexport interface MotionTransferResolution {\n resolution: string\n /** Empty when the size it names is the one it runs at. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The size a Motion Transfer run is sent and charged at (decided 2026-11-12):\n * the size it names, held to the catalog entry of the model its option runs\n * (`normalizeModelInput`), so a size that model does not have moves to the\n * entry's `defaultResolution` — a Wan Animate request at 1080p runs, and is\n * charged, as 720p. The route, the workflow build, the MCP workflow writes and\n * every price (through `buildMotionCreditModelIdentifier`) read this one rule.\n */\nexport function motionTransferResolution(provider: string, resolution: string): MotionTransferResolution {\n const model = motionModelOf(provider)\n if (MOTION_MODELS_SENT_AS_NAMED.has(model)) return { resolution, adjustments: [] }\n const normalized = normalizeModelInput(model, { resolution })\n if (normalized.resolution === undefined) return { resolution, adjustments: [] }\n return { resolution: normalized.resolution, adjustments: normalized.adjustments }\n}\n\nfunction motionCreditIdentifier(\n provider: string,\n resolution: string,\n videoDuration?: number,\n): string {\n // Wan Animate providers use resolution-tiered pricing (not duration-based)\n if (provider === \"wan-animate-move\" || provider === \"wan-animate-replace\") {\n // 480p is the default (base identifier), 580p and 720p get composite suffix\n if (resolution === \"580p\" || resolution === \"720p\") {\n return `${provider}:${resolution}`\n }\n return provider\n }\n\n const raw = videoDuration ?? 10\n const durationSec = Math.floor(Number.isNaN(raw) ? 10 : raw) // default 10s; floor to match KIE per-second billing\n const tier = MOTION_DURATION_TIERS.find(t => durationSec <= t.maxSeconds)\n ?? MOTION_DURATION_TIERS[MOTION_DURATION_TIERS.length - 1]\n\n const base = provider === \"kling-3.0\" ? \"kling-3.0-motion\" : \"motion-transfer\"\n const resSuffix = resolution === \"1080p\" ? \":1080p\" : \"\"\n return `${base}${resSuffix}:${tier.suffix}`\n}\n\n/**\n * The Suno operations whose credit key depends on the model VERSION.\n *\n * `/v1/suno/generate`, `/cover` and `/extend` resolve their creditGuard\n * identifier through `sunoCreditType(model, <operation>)` (routes/suno.ts\n * :247-249, :335-337, :407-409). EVERY other Suno route charges a flat\n * per-operation key and ignores the version the node carries — mashup (:648),\n * add-instrumental (:852), add-vocals (:907), upload-extend (:1016),\n * replace-section (:710), style-boost (:771), convert-wav (:962),\n * lyrics (:482), music-video (:594), voice (:1218).\n *\n * Anything that QUOTES a Suno price — a dropdown row, a node badge, the\n * workflow-credit estimator — must follow the same split, or it displays a\n * credit key the route never charges.\n */\nexport const SUNO_VERSION_PRICED_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n] as const\n\n/**\n * The seven Suno operations that appear behind a select/dropdown UI (model\n * pickers, node badges, the credit estimator) — the three version-priced\n * operations above, plus the four flat-key operations exercised by\n * `sunoCreditType`'s own test suite. A readonly tuple so later tasks (the\n * model dropdowns, node badges) can iterate or count it without redeclaring\n * the list and drifting from this one.\n */\nexport const SUNO_SELECT_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-mashup\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-upload-extend\",\n] as const\n\n/**\n * Adjust Speed's price id: motion-compensated (\"smooth\") interpolation is its\n * own, dearer tier. The route, the workflow run, and the editor's badge and\n * run estimate all price through this, so none of them can quote the fast tier\n * for a smooth run.\n */\nexport function speedRampCreditId(quality: unknown): \"speed-ramp\" | \"speed-ramp:smooth\" {\n return quality === \"smooth\" ? \"speed-ramp:smooth\" : \"speed-ramp\"\n}\n\n/**\n * Apply EDL's price id: a `proxy` render (the 720p preview) is its own,\n * cheaper per-output-minute row; a `final` render keeps the bare id. One id per\n * QUALITY, for a video and an audio output alike (decided 2026-10-04). Anything\n * that is not exactly \"proxy\" is the final, as the route and the node default\n * it. The route, the workflow run, and the editor's badge and run estimate all\n * price through this; the job itself is always named `apply-edl`.\n */\nexport function applyEdlCreditId(quality: unknown): \"apply-edl\" | \"apply-edl:proxy\" {\n return quality === \"proxy\" ? \"apply-edl:proxy\" : \"apply-edl\"\n}\n\n/**\n * Speaker View's price tiers (decided 2026-10-10, C4): a render is priced by\n * how many speakers it composites at once. `standard` — at most two tiles on\n * any segment and no zoom; `complex` — three to six tiles, or any zoom. Which\n * tier a render is in is the render rule's to say (the app's\n * `@nodaro/render-rules`), never this vocabulary's.\n */\nexport const SPEAKER_VIEW_PRICE_TIERS = [\"standard\", \"complex\"] as const\nexport type SpeakerViewPriceTier = (typeof SPEAKER_VIEW_PRICE_TIERS)[number]\n\nexport type SpeakerViewCreditId = \"speaker-view\" | \"speaker-view:proxy\" | \"speaker-view:complex\" | \"speaker-view:complex:proxy\"\n\n/** Every id `speakerViewCreditId` can name. */\nexport const SPEAKER_VIEW_CREDIT_IDS: readonly SpeakerViewCreditId[] = Object.freeze([\n \"speaker-view\",\n \"speaker-view:proxy\",\n \"speaker-view:complex\",\n \"speaker-view:complex:proxy\",\n] as const)\n\n/**\n * The credit id of a Speaker View render (F4, decided 2026-09-23; tiers\n * decided 2026-10-10): a Preview (`quality` \"proxy\") reserves on its own row,\n * anything else on the final's, and each in its price tier — `standard` on\n * `speaker-view` / `speaker-view:proxy`, `complex` on `speaker-view:complex` /\n * `speaker-view:complex:proxy`. A tier that is not exactly `standard` (absent\n * included) names the `complex` row: a caller that cannot tell quotes high,\n * never low. The job is always named `speaker-view`; only its credit id\n * follows the quality and the tier.\n */\nexport function speakerViewCreditId(quality: unknown, tier?: unknown): SpeakerViewCreditId {\n const proxy = quality === \"proxy\"\n if (tier === \"standard\") return proxy ? \"speaker-view:proxy\" : \"speaker-view\"\n return proxy ? \"speaker-view:complex:proxy\" : \"speaker-view:complex\"\n}\n\n/**\n * OUR Nodaro credit key for a Suno operation, given the model version and the\n * operation (which is also the node type and the BullMQ job name).\n *\n * This is the single source of truth for the Suno pricing contract, shared by\n * the reservation path (routes/suno.ts creditGuard), the egress seam\n * (workers/handlers/suno.ts `modelKey`, which must match what was reserved),\n * both workflow-credit estimators (ee/billing/credits.ts and the frontend\n * config-panels/helpers.ts), the seven Suno model dropdowns and the three Suno\n * node badges. It is a billing key — NEVER a KIE provider id — which is what\n * satisfies the B3 egress invariant.\n *\n * The version → key map is {@link SUNO_VERSION_CREDIT_KEYS}; a version with no\n * entry (V4) falls back to the operation key, and a non-version-priced\n * operation is returned unchanged.\n */\nexport function sunoCreditType(model: string | undefined, operation: string): string {\n if (!(SUNO_VERSION_PRICED_OPERATIONS as readonly string[]).includes(operation)) {\n return operation\n }\n return (model && SUNO_VERSION_CREDIT_KEYS[model]) || operation\n}\n\n/**\n * Suno version → Nodaro credit key for the version-priced operations. One row\n * per version that has its own `model_pricing` row / `STATIC_CREDIT_COSTS`\n * entry / `MODEL_CATALOG` pricing row, so an admin can reprice one version\n * without touching code. Every ACTIVE version MUST have a row here — guarded\n * by `__tests__/suno-credit-type.test.ts` (a new active version with no key\n * would silently bill at the operation key).\n */\nexport const SUNO_VERSION_CREDIT_KEYS: Readonly<Record<string, string>> = {\n V6: \"suno-v6\",\n V6_WILD: \"suno-v6_wild\",\n V6_MINI: \"suno-v6_mini\",\n V5_5: \"suno-v5_5\",\n V5: \"suno-v5\",\n // Their own rows since 2026-11-12, at the price their runs were charged\n // under the operation's row before.\n V4_5PLUS: \"suno-v4_5plus\",\n V4_5ALL: \"suno-v4_5all\",\n V4_5: \"suno-v4_5\",\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cast-swap-limits.ts","../src/gemini-omni-voices.ts","../src/node-default-mappings.ts","../src/tts-neighbour-text.ts","../src/provider-directive-defaults.ts","../src/lora-routing.ts","../src/suno-track-sources.ts","../src/voice-changer-models.ts","../src/model-tree.ts","../src/topaz-video.ts","../src/nodaro-video-upscale.ts","../src/audio-soundtrack.ts","../src/lip-sync-levers.ts"],"names":[],"mappings":";;;;;;AAQO,IAAM,yBAAA,GAA4B;AAkBlC,IAAM,mBAAA,GAAsB;AAAA,EACjC,cAAA,EAAgB,GAAA;AAAA,EAChB,YAAA,EAAc,GAAA;AAAA,EACd,UAAA,EAAY,GAAA;AAAA,EACZ,iBAAA,EAAmB;AACrB;AAGO,IAAM,6BAAA,GAAgC;AAAA;AAAA,EAE3C,aAAA,EA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AK,KAAK,CAAA,KAAM,MAAA,EAAW,KAAA,CAAM,KAAK,CAAA,GAAI,MAAA;AAAA,EAChD;AACA,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,4BAAA,CAA0E,UAAmB,IAAA,EAAY;AACvH,EAAA,MAAM,KAAA,GAAQ,sBAAA,CAAuB,QAAA,EAAU,IAAI,CAAA;AACnD,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,CAAE,MAAA,KAAW,CAAA,GAAI,IAAA,GAAO,EAAE,GAAG,IAAA,EAAM,GAAG,KAAA,EAAM;AACtE","file":"chunk-PHQVAPSD.js","sourcesContent":["/**\n * Cast Swap's input limits, and what a trend built on it may put in its\n * prompts. One definition read by the server (which enforces them) and by\n * every screen that edits them (which holds Save before a refusal), so the two\n * cannot drift apart.\n */\n\n/** The longest `postPrompt` Cast Swap takes. */\nexport const CAST_SWAP_POST_PROMPT_MAX = 4000\n\n/**\n * A trend's prompt limits.\n *\n * - `trendPromptMax` / `prePromptMax`: the longest prompt a trend version may\n * store.\n * - `detailsMax`: the longest details a user may add to a run. They follow the\n * trend prompt in Cast Swap's `postPrompt`, after a blank line, so a new\n * trend prompt is held to `CAST_SWAP_POST_PROMPT_MAX − 2 − detailsMax`.\n * - `engineTextReserve`: the room kept for the text Cast Swap writes around a\n * trend's prompts in the prompt it builds, at its longest (a block for each\n * of the 13 roles a run allows with 200-character role names, five\n * 500-character reference lines, the keep, mask and edit lines and the\n * header: about 16,100 characters, rounded up so a small wording change does\n * not need this moved). The pre prompt, the trend prompt and the details\n * share what is left of Seedance 2.5's prompt cap.\n */\nexport const TREND_PROMPT_LIMITS = {\n trendPromptMax: 3000,\n prePromptMax: 3000,\n detailsMax: 1000,\n engineTextReserve: 17_000,\n} as const\n\n/** Cast Swap's `faceMasking` bounds, each `[min, max]` inclusive. */\nexport const CAST_SWAP_FACE_MASKING_BOUNDS = {\n /** `minFaceHeightPct` and `maxFaceHeightPct`, % of the frame's height (max 0 = no limit). */\n faceHeightPct: [0, 100],\n /** Each `zone` margin, % of the frame. */\n zonePct: [0, 49],\n /** % of the frame's width. */\n blurStrengthPct: [0.1, 5],\n threshold: [0.05, 0.95],\n} as const satisfies Record<string, readonly [number, number]>\n\n/**\n * What a Cast Swap face mask covers (`faceMasking.target`):\n *\n * - `\"head\"` (the default): the whole head, hair included, and people seen\n * from behind or turned away, with a bigger mask.\n * - `\"face\"`: the face only; the hair, and a person turned away, stay visible.\n * - `\"body\"`: the whole person. A face mask that takes it hides everyone in\n * the clip, body and head (the biggest mask); a trend clip that keeps its\n * people as they are (the rest of the frame prepared) keeps them whole. A\n * clip made into depth as a whole takes no target.\n */\nexport const CAST_SWAP_FACE_MASK_TARGETS = [\"face\", \"head\", \"body\"] as const\n\nexport type CastSwapFaceMaskTarget = (typeof CAST_SWAP_FACE_MASK_TARGETS)[number]\n\n/**\n * How a direct Nodaro Motion run follows its clip (`style`, a public run\n * field): `\"precise\"` (the default) follows the clip exactly; `\"motion\"`\n * follows only the clip's movement and takes every look from the photos. A\n * trend run ignores it (its trend decides).\n */\nexport const CAST_SWAP_STYLES = [\"precise\", \"motion\"] as const\n\nexport type CastSwapStyle = (typeof CAST_SWAP_STYLES)[number]\n\n/** What Cast Swap uses for a `faceMasking` setting left out. */\nexport const CAST_SWAP_FACE_MASKING_DEFAULTS = {\n /** What a mask covers: the whole head (`CAST_SWAP_FACE_MASK_TARGETS`). */\n target: \"head\",\n /** What covers a masked face: a blur (`\"depth\"`, a depth-color view of it, is the other fill). */\n fill: \"blur\",\n minFaceHeightPct: 15,\n maxFaceHeightPct: 0,\n /**\n * The frame margins when `zone` is left out: a face centred in the outer 10 %\n * at the left or right is not masked (people walking in at the edge). An\n * explicit `zone: null`, or all four margins 0, means no margins.\n */\n zone: { leftPct: 10, rightPct: 10, topPct: 0, bottomPct: 0 },\n /** A margin left out of a `zone` that is given. */\n zonePct: 0,\n blurStrengthPct: 2,\n threshold: 0.5,\n} as const\n\n/**\n * The video engines Cast Swap runs on. A run or estimate that leaves `engine`\n * out runs on `CAST_SWAP_ENGINE_WHEN_OMITTED`, so callers that predate the\n * choice keep what they had.\n */\nexport const CAST_SWAP_ENGINES = [\"seedance-2-5\", \"kling-4\"] as const\n\nexport type CastSwapEngine = (typeof CAST_SWAP_ENGINES)[number]\n\n/** The engine of a run, estimate or trend that names none. */\nexport const CAST_SWAP_ENGINE_WHEN_OMITTED: CastSwapEngine = \"seedance-2-5\"\n\n/**\n * Nodaro Motion — what people see of Cast Swap. Its two engines' PUBLIC ids,\n * the only ones documented and returned (a trend's `engine`, a run record, a\n * quote): `\"motion-prism\"` (Nodaro Motion Prism) and `\"motion-pulse\"` (Nodaro\n * Motion Pulse).\n *\n * `CAST_SWAP_ENGINES` stays the INTERNAL vocabulary: what a stored trend\n * version names, and what the platform sends the Cast Swap engine (which takes\n * it in every version). A public id is mapped to it at every boundary that\n * reads one (`castSwapEngineFrom`), and back at every boundary a person reads\n * (`nodaroMotionEngineOf`). The engines' earlier public ids\n * (`NODARO_MOTION_LEGACY_ENGINES`) are read the same way and never returned.\n */\nexport const NODARO_MOTION_ENGINES = [\"motion-prism\", \"motion-pulse\"] as const\n\nexport type NodaroMotionEngine = (typeof NODARO_MOTION_ENGINES)[number]\n\n/**\n * The public ids the engines had before (renamed 2026-10-26), each with the\n * id it became. Still read wherever an engine is read — a request, a stored\n * run, an engine's declared engines, an admin setting's keys — and never\n * returned or documented.\n */\nexport const NODARO_MOTION_LEGACY_ENGINES = {\n \"motion-pro\": \"motion-prism\",\n \"motion-lite\": \"motion-pulse\",\n} as const satisfies Record<string, NodaroMotionEngine>\n\nexport type NodaroMotionLegacyEngine = keyof typeof NODARO_MOTION_LEGACY_ENGINES\n\n/** Each public id's earlier id (the inverse of `NODARO_MOTION_LEGACY_ENGINES`). */\nexport const NODARO_MOTION_LEGACY_ENGINE_OF = {\n \"motion-prism\": \"motion-pro\",\n \"motion-pulse\": \"motion-lite\",\n} as const satisfies Record<NodaroMotionEngine, NodaroMotionLegacyEngine>\n\n/**\n * Each public engine's name, as people read it. The earlier ids are keys too,\n * each answering the name of the engine it became, so code written against\n * them keeps reading a name (never undefined); iterate `NODARO_MOTION_ENGINES`,\n * not these keys.\n */\nexport const NODARO_MOTION_ENGINE_NAMES = {\n \"motion-prism\": \"Nodaro Motion Prism\",\n \"motion-pulse\": \"Nodaro Motion Pulse\",\n \"motion-pro\": \"Nodaro Motion Prism\",\n \"motion-lite\": \"Nodaro Motion Pulse\",\n} as const satisfies Record<NodaroMotionEngine | NodaroMotionLegacyEngine, string>\n\n/**\n * The internal engine each public id runs on (and the inverse, below). The\n * earlier ids are keys too, as in `NODARO_MOTION_ENGINE_NAMES`.\n */\nexport const CAST_SWAP_ENGINE_OF_NODARO_MOTION = {\n \"motion-prism\": \"seedance-2-5\",\n \"motion-pulse\": \"kling-4\",\n \"motion-pro\": \"seedance-2-5\",\n \"motion-lite\": \"kling-4\",\n} as const satisfies Record<NodaroMotionEngine | NodaroMotionLegacyEngine, CastSwapEngine>\n\n/** The public id of each internal engine. */\nexport const NODARO_MOTION_ENGINE_OF_CAST_SWAP = {\n \"seedance-2-5\": \"motion-prism\",\n \"kling-4\": \"motion-pulse\",\n} as const satisfies Record<CastSwapEngine, NodaroMotionEngine>\n\n/** The public id of an internal engine. */\nexport function nodaroMotionEngineOf(engine: CastSwapEngine): NodaroMotionEngine {\n return NODARO_MOTION_ENGINE_OF_CAST_SWAP[engine]\n}\n\n/** The name people read for an internal engine (\"Nodaro Motion Prism\" / \"Nodaro Motion Pulse\"). */\nexport function nodaroMotionEngineName(engine: CastSwapEngine): string {\n return NODARO_MOTION_ENGINE_NAMES[nodaroMotionEngineOf(engine)]\n}\n\n/**\n * The internal engine a value names, in any vocabulary: a public id\n * (`\"motion-prism\"`, `\"motion-pulse\"`), an earlier public id (`\"motion-pro\"`,\n * `\"motion-lite\"`) or an internal one (`\"seedance-2-5\"`, `\"kling-4\"`), the\n * last two still accepted from older clients, older engines and stored data.\n * Undefined for anything else.\n */\nexport function castSwapEngineFrom(value: unknown): CastSwapEngine | undefined {\n if (typeof value !== \"string\") return undefined\n // Its keys are the current and the earlier public ids.\n if (Object.hasOwn(CAST_SWAP_ENGINE_OF_NODARO_MOTION, value)) {\n return CAST_SWAP_ENGINE_OF_NODARO_MOTION[value as NodaroMotionEngine | NodaroMotionLegacyEngine]\n }\n return (CAST_SWAP_ENGINES as readonly string[]).includes(value) ? (value as CastSwapEngine) : undefined\n}\n\n/** The public id a value names, in any vocabulary (`castSwapEngineFrom`); undefined for anything else. */\nexport function nodaroMotionEngineFrom(value: unknown): NodaroMotionEngine | undefined {\n const engine = castSwapEngineFrom(value)\n return engine ? nodaroMotionEngineOf(engine) : undefined\n}\n\n/**\n * Every engine id a request may name: the public ids, then the earlier public\n * ids and the internal ones (still accepted, never documented).\n */\nexport const CAST_SWAP_ENGINE_IDS_ACCEPTED = [\n ...NODARO_MOTION_ENGINES,\n \"motion-pro\",\n \"motion-lite\",\n ...CAST_SWAP_ENGINES,\n] as const satisfies readonly (NodaroMotionEngine | NodaroMotionLegacyEngine | CastSwapEngine)[]\n\n/**\n * The resolutions each engine renders, the default first. Seedance 2.5's 480p\n * is plain unless a run asks for a draft (`draft` is 480p only); Kling 4 has\n * no draft and no 480p.\n */\nexport const CAST_SWAP_RESOLUTIONS_BY_ENGINE = {\n \"seedance-2-5\": [\"480p\", \"720p\", \"1080p\"],\n \"kling-4\": [\"720p\", \"1080p\"],\n} as const satisfies Record<CastSwapEngine, readonly (\"480p\" | \"720p\" | \"1080p\")[]>\n\n/** Whether an engine renders drafts (Seedance 2.5's 480p draft; Kling 4 has none). */\nexport function castSwapEngineHasDraft(engine: CastSwapEngine): boolean {\n return engine === \"seedance-2-5\"\n}\n\n/**\n * Where a Kling 4 run cuts the clip to whole seconds (Kling renders whole\n * seconds, and asked for more than the clip it stretches the motion; Seedance\n * 2.5 ignores it): `\"cut-end\"` (the default) drops the fraction of a second at\n * the clip's end, `\"cut-start\"` at its start.\n */\nexport const CAST_SWAP_KLING_LENGTHS = [\"cut-end\", \"cut-start\"] as const\n\nexport type CastSwapKlingLength = (typeof CAST_SWAP_KLING_LENGTHS)[number]\n\n/** The `klingLength` of a run or trend that names none. */\nexport const CAST_SWAP_KLING_LENGTH_WHEN_OMITTED: CastSwapKlingLength = \"cut-end\"\n\n/**\n * The most images one Kling 4 Cast Swap run sends, across every role and fixed\n * reference (a role with prepared references counts its one prepared\n * picture). Over it the route answers `too_many_images`.\n */\nexport const CAST_SWAP_KLING_MAX_IMAGES = 10\n","/**\n * The 30 preset voices Gemini Omni's audio-persona endpoint accepts, with the\n * style labels its documentation gives each one. DATA, so the API docs, the MCP\n * tool text and any client picker list them from one place instead of copying a\n * table that drifts.\n *\n * A preset is the BASE voice; a persona is that voice plus a free-text\n * description (timbre, pace, emotion) and an example line. Pinning a persona to a\n * character is what keeps one voice across separate clips.\n */\nexport interface GeminiOmniVoicePreset {\n id: string\n gender: \"female\" | \"male\" | \"genderless\"\n /** The documented character of the voice (\"soft\", \"raspy\", \"intellectual\"…). */\n style: string\n /** The documented pitch band (\"low\", \"mid-low\", \"mid\", \"mid-high\", \"high\"; \"younger\" for fenrir). */\n pitch: string\n}\n\nexport const GEMINI_OMNI_VOICE_PRESETS = [\n { id: \"achernar\", gender: \"female\", style: \"soft\", pitch: \"high\" },\n { id: \"achird\", gender: \"male\", style: \"friendly\", pitch: \"mid\" },\n { id: \"algenib\", gender: \"male\", style: \"raspy\", pitch: \"low\" },\n { id: \"algieba\", gender: \"male\", style: \"easygoing\", pitch: \"mid-low\" },\n { id: \"alnilam\", gender: \"male\", style: \"steady\", pitch: \"mid-low\" },\n { id: \"aoede\", gender: \"female\", style: \"brisk\", pitch: \"mid\" },\n { id: \"autonoe\", gender: \"female\", style: \"bright\", pitch: \"mid\" },\n { id: \"callirrhoe\", gender: \"female\", style: \"easygoing\", pitch: \"mid\" },\n { id: \"charon\", gender: \"male\", style: \"intellectual\", pitch: \"low\" },\n { id: \"despina\", gender: \"female\", style: \"smooth\", pitch: \"mid\" },\n { id: \"enceladus\", gender: \"male\", style: \"breathy\", pitch: \"low\" },\n { id: \"erinome\", gender: \"female\", style: \"clear\", pitch: \"mid\" },\n { id: \"fenrir\", gender: \"male\", style: \"lively\", pitch: \"younger\" },\n { id: \"gacrux\", gender: \"female\", style: \"mature\", pitch: \"mid\" },\n { id: \"iapetus\", gender: \"male\", style: \"clear\", pitch: \"mid-low\" },\n { id: \"kore\", gender: \"female\", style: \"capable\", pitch: \"mid\" },\n { id: \"laomedeia\", gender: \"female\", style: \"cheerful\", pitch: \"mid-high\" },\n { id: \"leda\", gender: \"female\", style: \"young\", pitch: \"mid-high\" },\n { id: \"orus\", gender: \"male\", style: \"steady\", pitch: \"mid-low\" },\n { id: \"puck\", gender: \"male\", style: \"cheerful\", pitch: \"mid\" },\n { id: \"pulcherrima\", gender: \"genderless\", style: \"forward\", pitch: \"mid-high\" },\n { id: \"rasalgethi\", gender: \"male\", style: \"intellectual\", pitch: \"mid\" },\n { id: \"sadachbia\", gender: \"male\", style: \"vivid\", pitch: \"low\" },\n { id: \"sadaltager\", gender: \"male\", style: \"knowledgeable\", pitch: \"mid\" },\n { id: \"schedar\", gender: \"male\", style: \"smooth\", pitch: \"mid-low\" },\n { id: \"sulafat\", gender: \"female\", style: \"warm\", pitch: \"mid\" },\n { id: \"umbriel\", gender: \"male\", style: \"smooth\", pitch: \"low\" },\n { id: \"vindemiatrix\", gender: \"female\", style: \"gentle\", pitch: \"mid\" },\n { id: \"zephyr\", gender: \"female\", style: \"bright\", pitch: \"mid-high\" },\n { id: \"zubenelgenubi\", gender: \"male\", style: \"casual\", pitch: \"mid-low\" },\n] as const satisfies readonly GeminiOmniVoicePreset[]\n\nexport type GeminiOmniVoicePresetId = (typeof GEMINI_OMNI_VOICE_PRESETS)[number][\"id\"]\n\n/** The preset ids as a non-empty tuple — what `z.enum(...)` takes. */\nexport const GEMINI_OMNI_VOICE_PRESET_IDS = GEMINI_OMNI_VOICE_PRESETS.map((v) => v.id) as unknown as readonly [\n GeminiOmniVoicePresetId,\n ...GeminiOmniVoicePresetId[],\n]\n","import {\n IMAGE_GEN_PROVIDERS,\n IMAGE_I2I_PROVIDERS,\n IMAGE_EDIT_PROVIDERS,\n UPSCALE_IMAGE_PROVIDERS,\n TEXT_TO_VIDEO_PROVIDERS,\n IMAGE_TO_VIDEO_PROVIDERS,\n VIDEO_GEN_PROVIDERS,\n LIP_SYNC_PROVIDERS,\n TTS_PROVIDERS,\n VOICE_DESIGN_MODELS,\n} from \"./model-constants.js\"\nimport { LLM_MODEL_IDS } from \"./llm-models.js\"\nimport { SEEDREAM_5_5_DEFAULT_RESOLUTION } from \"./seedream-5-5.js\"\n\n// ──────────────────────────────────────────────────────────────────────────\n// Types\n// ──────────────────────────────────────────────────────────────────────────\n\nexport type QualityLevel = \"low\" | \"mid\" | \"high\"\nexport type SemanticAspectRatio = \"auto\" | \"1:1\" | \"4:3\" | \"3:4\" | \"16:9\" | \"9:16\"\n\nexport const NODE_DEFAULT_TYPES = [\n // Image\n \"generate-image\",\n \"image-to-image\",\n \"edit-image\",\n \"upscale-image\",\n // Video\n \"text-to-video\",\n \"image-to-video\",\n \"generate-video\",\n // Composition\n \"lip-sync\",\n // Audio / Music\n \"text-to-speech\",\n \"generate-music\",\n \"voice-design\",\n // LLM-driven\n \"ai-writer\",\n \"llm-chat\",\n \"lottie-overlay\",\n \"3d-title\",\n \"motion-graphics\",\n \"image-to-text\",\n \"qa-check\",\n] as const\n\nexport type NodeDefaultType = (typeof NODE_DEFAULT_TYPES)[number]\n\nexport const QUALITY_LEVELS: readonly QualityLevel[] = [\"low\", \"mid\", \"high\"] as const\nexport const SEMANTIC_ASPECT_RATIOS: readonly SemanticAspectRatio[] = [\n \"auto\",\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n] as const\n\n// ──────────────────────────────────────────────────────────────────────────\n// Per-node-type registry\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * Per-node-type metadata: which field on the node carries the admin-set value,\n * the valid value set, and which optional dimensions apply.\n *\n * `field` distinguishes nodes that use `data.provider` (image/video/audio)\n * from nodes that use `data.model` (LLM nodes, voice-design).\n */\ninterface NodeTypeMeta {\n field: \"provider\" | \"model\"\n validValues: readonly string[]\n hasQuality: boolean\n hasAspectRatio: boolean\n}\n\n// Music providers per the runtime: enum currently only lists \"minimax\", but\n// `generate-music.defaultData.provider` is \"suno\" with a separate `modelVersion`.\n// Until that mismatch is fixed, accept both values for admin defaults.\nconst MUSIC_PROVIDERS_FOR_VALIDATION = [\"suno\", \"minimax\"] as const\n\nconst META: Record<NodeDefaultType, NodeTypeMeta> = {\n \"generate-image\": { field: \"provider\", validValues: IMAGE_GEN_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"image-to-image\": { field: \"provider\", validValues: IMAGE_I2I_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"edit-image\": { field: \"provider\", validValues: IMAGE_EDIT_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"upscale-image\": { field: \"provider\", validValues: UPSCALE_IMAGE_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"text-to-video\": { field: \"provider\", validValues: TEXT_TO_VIDEO_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"image-to-video\": { field: \"provider\", validValues: IMAGE_TO_VIDEO_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"generate-video\": { field: \"provider\", validValues: VIDEO_GEN_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"lip-sync\": { field: \"provider\", validValues: LIP_SYNC_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"text-to-speech\": { field: \"provider\", validValues: TTS_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"generate-music\": { field: \"provider\", validValues: MUSIC_PROVIDERS_FOR_VALIDATION, hasQuality: false, hasAspectRatio: false },\n \"voice-design\": { field: \"model\", validValues: VOICE_DESIGN_MODELS, hasQuality: false, hasAspectRatio: false },\n \"ai-writer\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"llm-chat\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"lottie-overlay\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"3d-title\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"motion-graphics\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"image-to-text\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"qa-check\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n}\n\nexport function getTargetField(nodeType: NodeDefaultType): \"provider\" | \"model\" {\n return META[nodeType].field\n}\n\nexport function getValidValues(nodeType: NodeDefaultType): readonly string[] {\n return META[nodeType].validValues\n}\n\nexport function supportedDefaultDimensions(nodeType: NodeDefaultType): {\n quality: boolean\n aspectRatio: boolean\n} {\n const m = META[nodeType]\n return { quality: m.hasQuality, aspectRatio: m.hasAspectRatio }\n}\n\nexport function validateProviderForNodeType(\n nodeType: NodeDefaultType,\n value: string,\n): string | null {\n const valid = META[nodeType].validValues\n if (!valid.includes(value)) {\n return `value \"${value}\" is not valid for node type \"${nodeType}\"`\n }\n return null\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Semantic mappings — quality + aspect ratio per provider\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * Each provider stores its quality lever on a different field of node data:\n * - `resolution` (1K/2K/4K, 720p/1080p, …) — most image + video providers\n * - `quality` (medium/high, basic/high) — gpt-image, seedream\n *\n * Mapping a semantic level (low/mid/high) to a concrete value is meaningless\n * without knowing WHICH field it belongs to, because writing \"medium\" into\n * `resolution` (or \"2K\" into `quality`) trips the route's Zod enum at\n * generate-time. Each entry pairs the field with the per-level values built\n * from frontend/src/components/editor/config-panels/model-options.ts.\n *\n * Providers absent from this table return `undefined` from `mapQuality`,\n * letting the caller fall back to the factory default value.\n *\n * When a provider has fewer than 3 levels, semantic levels collapse onto\n * the closest concrete value (e.g. gpt-image only has medium/high → low maps\n * to medium).\n */\nexport type QualityField = \"resolution\" | \"quality\"\n\ninterface QualityMapping {\n field: QualityField\n values: Partial<Record<QualityLevel, string>>\n}\n\nconst QUALITY_MAP: Record<string, QualityMapping> = {\n // Image gen — resolution-style (1K/2K/4K)\n \"nano-banana-pro\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"nano-banana-2\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"nano-banana-2-1\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"flux\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"flux-flex\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"flux-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"flux-pro-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"gpt-image-2\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-flare\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-flare-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-sunburst\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-sunburst-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-6-flare\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-6-flare-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-6-sunburst\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-6-sunburst-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n // Image gen — quality-style (medium/high or basic/high)\n \"gpt-image\": { field: \"quality\", values: { low: \"medium\", mid: \"medium\", high: \"high\" } },\n \"gpt-image-i2i\": { field: \"quality\", values: { low: \"medium\", mid: \"medium\", high: \"high\" } },\n \"seedream\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-edit\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-lite\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-lite-i2i\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-pro\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-pro-i2i\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n // Seedream 5 Flash's lever is size (sent as KIE `size`), flat-priced — resolution-style.\n \"seedream-5-flash\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"seedream-5-flash-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n // MiniMax H3 Image: 1K and 2K cost the same, 2K is its default.\n \"minimax-h3-image\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"minimax-h3-image-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n // Seedream 5.5's lever is its size too (KIE `size`): mid is its default, 2K;\n // low the cheapest, 1K (1.5K costs the same, and is the panel's to pick).\n \"seedream-5-5\": { field: \"resolution\", values: { low: \"1K\", mid: SEEDREAM_5_5_DEFAULT_RESOLUTION, high: \"2K\" } },\n \"seedream-5-5-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: SEEDREAM_5_5_DEFAULT_RESOLUTION, high: \"2K\" } },\n // FLUX 3 Klein: three sizes, 1K its default and cheapest (as GPT Image 2).\n \"flux-3-klein\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"flux-3-klein-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n // Video gen — resolution-style (720p/1080p)\n \"veo3\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"veo3.1\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"kling\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"kling-3.0\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"seedance-2\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"seedance-2-fast\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"720p\" } },\n \"seedance-2-mini\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"720p\" } },\n // Seedance 2.5 spans 480p/720p/1080p on KIE (1080p accepted since the\n // 2026-08-17 re-probe; 4k still rejected), so each quality rung gets its own tier.\n \"seedance-2-5\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"1080p\" } },\n // Seedance 2.5 Flash — 480p / 720p only, so \"high\" stays at 720p.\n \"seedance-2-5-flash\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"720p\" } },\n // Wan 3.0 family — 480p / 720p / 1080p (lowercase catalog spellings; the\n // uppercase KIE wire form is produced only by normalizeWan3Resolution).\n \"wan-3\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"1080p\" } },\n \"wan-3-prime\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"1080p\" } },\n // Vidu Q4 — five tiers; the quality rungs stop at 1080p so \"high\" never\n // lands on the 2k/4k ladder (4k is closed to the free tier).\n \"vidu-q4\": { field: \"resolution\", values: { low: \"540p\", mid: \"720p\", high: \"1080p\" } },\n // Kling 4.0 — two tiers on both endpoints.\n \"kling-4\": { field: \"resolution\", values: { low: \"720p\", mid: \"720p\", high: \"1080p\" } },\n \"kling-4-keyframes\": { field: \"resolution\", values: { low: \"720p\", mid: \"720p\", high: \"1080p\" } },\n // Kling 4.0 Flash — 720p only, so every level lands on it.\n \"kling-4-flash\": { field: \"resolution\", values: { low: \"720p\", mid: \"720p\", high: \"720p\" } },\n \"wan-2.7-i2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"wan-2.7-t2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse-i2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse-ref2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse-edit\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"kling-3-omni\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"wan-videoedit\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n // Lightricks LTX 2.3 — 1080p / 2k / 4k (lowercase, matching VIDEO_RESOLUTION_OPTIONS).\n // `field: \"resolution\"` is mandatory — see Provider Enum Sync pitfall 4.\n \"ltx-2.3-pro\": { field: \"resolution\", values: { low: \"1080p\", mid: \"2k\", high: \"4k\" } },\n \"ltx-2.3-fast\": { field: \"resolution\", values: { low: \"1080p\", mid: \"2k\", high: \"4k\" } },\n \"gemini-omni-video\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"4k\" } },\n \"gemini-omni-flash\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"4k\" } },\n \"gemini-omni-flash-1-2\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"4k\" } },\n // Grok Imagine Video 1.5 — 480p / 720p / 1080p, each quality rung its own tier.\n \"grok-imagine-video-1.5\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"1080p\" } },\n // PixVerse V6 Max — four tiers; \"low\" stops at 540p (360p is a preview tier,\n // as on Gemini Omni Flash 1.2) and \"mid\" is its declared 720p default.\n \"pixverse-v6-max\": { field: \"resolution\", values: { low: \"540p\", mid: \"720p\", high: \"1080p\" } },\n // Replicate Flux 2 family — MP-based resolution (matching IMAGE_RESOLUTION_OPTIONS[\"flux-2-*\"]).\n // `field: \"resolution\"` is mandatory — see Provider Enum Sync pitfall 4.\n // mid = provider default: 1 MP for Klein, 2 MP for Pro/Max.\n \"flux-2-klein\": { field: \"resolution\", values: { low: \"0.5 MP\", mid: \"1 MP\", high: \"2 MP\" } },\n \"flux-2-pro\": { field: \"resolution\", values: { low: \"1 MP\", mid: \"2 MP\", high: \"4 MP\" } },\n \"flux-2-max\": { field: \"resolution\", values: { low: \"1 MP\", mid: \"2 MP\", high: \"4 MP\" } },\n}\n\nconst ASPECT_PASSTHROUGH_PROVIDERS = new Set([\n ...IMAGE_GEN_PROVIDERS,\n ...IMAGE_I2I_PROVIDERS,\n ...TEXT_TO_VIDEO_PROVIDERS,\n ...IMAGE_TO_VIDEO_PROVIDERS,\n])\n\nexport interface MappedQuality {\n field: QualityField\n value: string\n}\n\nexport function mapQuality(provider: string, level: QualityLevel): MappedQuality | undefined {\n const m = QUALITY_MAP[provider]\n const value = m?.values[level]\n return value === undefined ? undefined : { field: m!.field, value }\n}\n\nexport function mapAspectRatio(\n provider: string,\n ratio: SemanticAspectRatio,\n): string | undefined {\n if (ratio === \"auto\") return undefined\n if (!ASPECT_PASSTHROUGH_PROVIDERS.has(provider as never)) return ratio\n return ratio\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Linked field derivation\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * When admin sets `provider` for a node that has linked fields (e.g.\n * generate-image stores both `provider` AND `model`), derive the linked\n * fields so the resolver writes a coherent snapshot.\n *\n * For unmapped providers, returns `{}` — the runtime config panel applies\n * its own defaulting when needed.\n */\nconst GENERATE_IMAGE_PROVIDER_TO_MODEL: Record<string, string> = {\n \"nano-banana\": \"gemini-2.5-flash-image\",\n \"nano-banana-pro\": \"gemini-2.5-flash-image\",\n \"nano-banana-2\": \"gemini-2.5-flash-image\",\n \"nano-banana-2-lite\": \"gemini-3.1-flash-lite-image\",\n}\n\nexport function deriveLinkedFields(\n nodeType: NodeDefaultType,\n value: string,\n): Record<string, unknown> {\n if (nodeType === \"generate-image\") {\n const model = GENERATE_IMAGE_PROVIDER_TO_MODEL[value]\n return model ? { model } : {}\n }\n return {}\n}\n","/**\n * The neighbour-text rule of Text to Speech — what is spoken just BEFORE and just AFTER a clip in the finished\n * piece — in ONE place, so the editor's run, the provider exits and the REST route cannot drift: a request that\n * the editor sends must be one the route accepts.\n *\n * A string is trimmed; an empty one, or anything that is not a string, is ABSENT. Over the cap the value is\n * TRIMMED, never rejected, by every sender and exit: previous text keeps its LAST characters (what leads into\n * the clip), next text its FIRST (what the clip leads into). The REST route is the one place that rejects an\n * over-cap value — measured on the trimmed text, for a model that stitches only. Whether a model takes the\n * fields at all is its sheet (`ttsSupportsStitching`), never decided here.\n */\n\n/**\n * The most characters of context sent on each side. ElevenLabs documents no limit for the text-to-speech\n * endpoint's fields; this bounds what we send (and what the vendor may count) to about two sentences' worth of\n * run-in and run-out — enough to carry intonation across a cut.\n */\nexport const TTS_NEIGHBOUR_TEXT_MAX_CHARS = 1000\n\n/** The normalised pair: only non-empty strings within the cap; a side that was unusable is not a key. */\nexport interface TtsNeighbourText {\n previousText?: string\n nextText?: string\n}\n\nfunction usableText(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined\n const trimmed = value.trim()\n return trimmed ? trimmed : undefined\n}\n\n/** `previousText` / `nextText` of `options`, normalised. Other keys are not carried over; the input is never mutated. */\nexport function normalizeTtsNeighbourText(\n options: Readonly<{ previousText?: unknown; nextText?: unknown }> | undefined,\n): TtsNeighbourText {\n const out: TtsNeighbourText = {}\n const previous = usableText(options?.previousText)\n if (previous !== undefined) {\n out.previousText = previous.length > TTS_NEIGHBOUR_TEXT_MAX_CHARS ? previous.slice(-TTS_NEIGHBOUR_TEXT_MAX_CHARS) : previous\n }\n const next = usableText(options?.nextText)\n if (next !== undefined) {\n out.nextText = next.length > TTS_NEIGHBOUR_TEXT_MAX_CHARS ? next.slice(0, TTS_NEIGHBOUR_TEXT_MAX_CHARS) : next\n }\n return out\n}\n","import type { ShotSpec } from \"./scene-node-types.js\"\n\n/**\n * Provider-specific directive defaults. Architecture spec §5.14.\n *\n * Each video model can have side-effects the user usually wants (Seedance baking in\n * ambient music, VEO supporting loop seeds, etc.). The engine applies these defaults\n * at provider-call time, allowing them to be overridden by the Scene Director's\n * `shot_intent` field (provider-neutral) which we map below.\n *\n * Keys are canonical provider identifiers (matching VIDEO_MODEL_CAPS in\n * model-constants.ts). Non-canonical keys would silently break downstream\n * route validation + payload building.\n */\nexport const PROVIDER_DIRECTIVE_DEFAULTS = {\n \"seedance-2\": { multishot: true, disable_internal_music: true, allow_sfx: true },\n veo3: { reference_count: \"auto\" as const },\n \"veo3.1\": { reference_count: \"auto\" as const },\n kling: { reference_count: \"auto\" as const },\n \"kling-3-omni\": { reference_count: \"auto\" as const },\n \"kling-turbo\": { reference_count: \"auto\" as const },\n hailuo: {} as Record<string, never>,\n \"hailuo-2.3-pro\": {} as Record<string, never>,\n \"hailuo-standard\": {} as Record<string, never>,\n minimax: {} as Record<string, never>,\n // MiniMax Hailuo 3 — multimodal like seedance-2 but no verified directive\n // semantics yet; empty until probed (NOTE: never match `minimax-h3` with a\n // startsWith(\"seedance\") / startsWith(\"minimax\") prefix check — exact keys only).\n \"minimax-h3\": {} as Record<string, never>,\n \"bytedance-lite\": {} as Record<string, never>,\n} as const\n\n/**\n * Maps a Scene Director's provider-neutral shot_intent to provider-specific directives.\n * Architecture spec §5.14 mapping table.\n *\n * Unknown providers fall through to an empty object — the directive degrades to a text\n * hint in the motion_prompt (Scene Director includes it there as a fallback when\n * `needs_music_suppression: true`).\n */\nexport function mapShotIntentToProviderDirectives(\n provider: string,\n shotIntent: ShotSpec[\"shot_intent\"],\n): Record<string, unknown> {\n const directives: Record<string, unknown> = {\n ...(PROVIDER_DIRECTIVE_DEFAULTS[provider as keyof typeof PROVIDER_DIRECTIVE_DEFAULTS] ?? {}),\n }\n\n if (shotIntent.needs_multishot_reference) {\n if (provider.startsWith(\"seedance\")) {\n directives.multishot = true\n }\n // VEO + Kling: accepts reference_images array — engine attaches the refs separately.\n // Hailuo: only 1 ref — silently ignored at engine layer.\n }\n\n if (shotIntent.is_loopable) {\n if (provider.startsWith(\"veo\")) {\n directives.loop_seed = \"stable\"\n }\n // Other providers: no native loop_seed → degrade to motion_prompt frame-matching hint.\n }\n\n if (shotIntent.needs_music_suppression) {\n if (provider.startsWith(\"seedance\")) {\n directives.disable_internal_music = true\n }\n // VEO / Kling / Hailuo don't bake in music; no directive needed.\n }\n\n return directives\n}\n","/**\n * Character LoRA routing decision + identifier constants.\n *\n * Shared between backend (orchestrator's payload-builder) and frontend\n * (single-node Run's execute-node). MUST agree byte-for-byte — the backend\n * stamps the credit identifier and worker payload off this decision, the\n * frontend stamps the `_internalLora` body hint off it. Mismatches would\n * silently degrade trained-character generations to ref injection.\n */\n\n/**\n * Synthetic Replicate model id selected by the orchestrator (and the\n * single-node Run pre-Zod swap) when a single trained `@character` mention\n * is detected. Routes through `black-forest-labs/flux-dev-lora` with the\n * character's trained version under `extraParams.lora_version`. Never\n * appears in user-facing dropdowns.\n */\nexport const FLUX_LORA_CHARACTER_MODEL_ID = \"flux-lora-character\" as const\n\n/**\n * `jobs.job_type` discriminator + credit identifier for character LoRA\n * training jobs. Used for `STATIC_CREDIT_COSTS`/`model_pricing` lookup,\n * `creditGuard` reservation, refund flow, and webhook job lookup.\n */\nexport const CHARACTER_LORA_TRAINING_JOB_TYPE = \"character-lora-training\" as const\n\n/**\n * The three LoRA fields read off `CharacterNodeData` and stamped onto every\n * `ConnectedReference` produced from a wired character. Shared between the\n * backend's `expandWiredCharacterRefs` and the frontend's\n * `expandCharacterNodeIntoRefs` so both sides emit the same three fields\n * without copy-paste drift.\n */\nexport interface CharacterLoraFields {\n readonly loraReplicateVersion: string | null\n readonly loraTriggerWord: string | null\n readonly loraTrainingStatus: string | null\n}\n\n/**\n * Extract the three LoRA fields from a character node's `data`, normalized\n * to `null` for missing/undefined values so downstream type-checks (e.g.\n * `selectLoraRoutingForMentions`'s `=== \"succeeded\"`) are deterministic.\n */\nexport function extractCharacterLoraFields(charData: {\n loraReplicateVersion?: string | null\n loraTriggerWord?: string | null\n loraTrainingStatus?: string | null\n}): CharacterLoraFields {\n return {\n loraReplicateVersion: charData.loraReplicateVersion ?? null,\n loraTriggerWord: charData.loraTriggerWord ?? null,\n loraTrainingStatus: charData.loraTrainingStatus ?? null,\n }\n}\n\nexport interface LoraRouting {\n readonly characterSlug: string\n readonly triggerWord: string\n readonly loraVersion: string\n}\n\nexport interface LoraEligibleRef {\n readonly characterSlug?: string\n readonly loraReplicateVersion?: string | null\n readonly loraTriggerWord?: string | null\n readonly loraTrainingStatus?: string | null\n}\n\n/**\n * Returns a LoraRouting iff EXACTLY ONE distinct character is mentioned AND\n * that character has a successful LoRA. Returns null otherwise → caller\n * falls back to ref injection. Multi-character LoRA composition is Phase 2.\n */\nexport function selectLoraRoutingForMentions(\n refs: readonly LoraEligibleRef[],\n): LoraRouting | null {\n const distinct = new Set(refs.map((r) => r.characterSlug).filter(Boolean))\n if (distinct.size !== 1) return null\n const slug = [...distinct][0]!\n const match = refs.find((r) => r.characterSlug === slug)\n if (\n !match ||\n !match.loraReplicateVersion ||\n !match.loraTriggerWord ||\n match.loraTrainingStatus !== \"succeeded\"\n ) {\n return null\n }\n return {\n characterSlug: slug,\n triggerWord: match.loraTriggerWord,\n loraVersion: match.loraReplicateVersion,\n }\n}\n","/**\n * Node types whose output carries Suno chaining ids (`sunoTrackId` /\n * `sunoTaskId`) for a downstream Suno node (extend / separate / replace /\n * add-vocals / …) to chain off.\n *\n * One set for the three readers — the canvas resolver, the orchestrator\n * resolver, and the config panels' \"Inherited\" hint (#819). They used to keep\n * their own copies and drifted: the canvas read ids off a `suno-separate`\n * (whose output is stems, not a track) while the orchestrator ignored it, so\n * the same graph resolved on one path and not the other. Structural\n * vocabulary only — node type names, no prompt content.\n */\nexport const SUNO_TRACK_SOURCE_TYPES: ReadonlySet<string> = new Set([\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-mashup\",\n \"suno-replace-section\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-convert-wav\",\n \"suno-upload-extend\",\n])\n","/**\n * ElevenLabs speech-to-speech (voice changer) models — single source of truth\n * for the Voice Changer node's model picker (frontend config panel) AND the\n * `/v1/voice-changer` route Zod enum (backend). Lifting the list here keeps the\n * dropdown and the validation enum from ever drifting apart.\n *\n * These are the two `model_id` values ElevenLabs' `/v1/speech-to-speech/{voiceId}`\n * endpoint accepts with `can_do_voice_conversion`. ElevenLabs' own docs\n * recommend Multilingual v2 even for English source audio (it often\n * outperforms the English-only model), and it's required for non-English\n * audio (e.g. Hebrew), so it's the default — English v2 stays selectable.\n */\nexport const VOICE_CHANGER_MODELS = [\n {\n value: \"eleven_multilingual_sts_v2\",\n label: \"Multilingual v2\",\n desc: \"29 languages; preserves emotion, cadence & timing. Default — ElevenLabs recommends this even for English audio.\",\n },\n {\n value: \"eleven_english_sts_v2\",\n label: \"English v2\",\n desc: \"English-optimized speech-to-speech.\",\n },\n] as const\n\nexport type VoiceChangerModel = (typeof VOICE_CHANGER_MODELS)[number][\"value\"]\n\n/** Plain id list for the route's `z.enum(...)`. */\nexport const VOICE_CHANGER_MODEL_IDS: VoiceChangerModel[] = VOICE_CHANGER_MODELS.map(\n (m) => m.value,\n)\n\n/** ElevenLabs recommends Multilingual v2 even for English source audio (it\n * often outperforms the English-only model), and it's required for\n * non-English audio — so it's the default. English v2 remains selectable. */\nexport const DEFAULT_VOICE_CHANGER_MODEL: VoiceChangerModel = \"eleven_multilingual_sts_v2\"\n","/**\n * Models-tab data source: maps each catalog model to the node it creates\n * (`modelToNodeTarget`) and groups node-creatable models into product lines\n * (`buildModelTree`). Consumed by the add-node popup's Models tab. Pure — derives\n * everything from `MODEL_CATALOG` + the provider enums, so models added to the\n * catalog/enums flow through automatically.\n */\nimport { MODEL_CATALOG, type ModelKind, type ModelMode } from \"./model-catalog.js\"\nimport {\n IMAGE_GEN_PROVIDERS, VIDEO_GEN_PROVIDERS, IMAGE_TO_VIDEO_PROVIDERS, TEXT_TO_VIDEO_PROVIDERS,\n UPSCALE_IMAGE_PROVIDERS, VIDEO_UPSCALE_PROVIDERS, MODIFY_IMAGE_PROVIDERS, IMAGE_EDIT_PROVIDERS,\n VIDEO_TO_VIDEO_PROVIDERS, EXTEND_VIDEO_PROVIDERS, MOTION_TRANSFER_PROVIDERS, LIP_SYNC_PROVIDERS,\n FACE_SWAP_PROVIDERS, TTS_PROVIDERS, DIALOGUE_PROVIDERS, TEXT_TO_AUDIO_PROVIDERS, TRANSCRIBE_PROVIDERS, MUSIC_PROVIDERS,\n} from \"./model-constants.js\"\nimport { VIDEO_DEPTH_PROVIDERS } from \"./video-depth.js\"\n\nexport interface ModelNodeTarget {\n nodeType: string\n field?: \"provider\" | \"model\"\n value?: string\n}\nexport interface ModelTreeVariant extends ModelNodeTarget {\n id: string\n label: string\n kind: ModelKind\n}\nexport interface ModelTreeLine {\n series: string\n family: string\n kind: ModelKind\n models: ModelTreeVariant[]\n}\n\n// A model id that is a valid provider-enum value gets a node + provider preset.\nconst ENUM_TARGETS: ReadonlyArray<readonly [readonly string[], string]> = [\n [IMAGE_GEN_PROVIDERS, \"generate-image\"],\n [VIDEO_GEN_PROVIDERS, \"generate-video\"],\n [IMAGE_TO_VIDEO_PROVIDERS, \"generate-video\"],\n [TEXT_TO_VIDEO_PROVIDERS, \"generate-video\"],\n [UPSCALE_IMAGE_PROVIDERS, \"upscale-image\"],\n [VIDEO_UPSCALE_PROVIDERS, \"video-upscale\"],\n [VIDEO_DEPTH_PROVIDERS, \"video-depth\"],\n [MODIFY_IMAGE_PROVIDERS, \"modify-image\"],\n [IMAGE_EDIT_PROVIDERS, \"modify-image\"],\n [VIDEO_TO_VIDEO_PROVIDERS, \"video-to-video\"],\n [EXTEND_VIDEO_PROVIDERS, \"extend-video\"],\n [MOTION_TRANSFER_PROVIDERS, \"motion-transfer\"],\n [LIP_SYNC_PROVIDERS, \"lip-sync\"],\n [FACE_SWAP_PROVIDERS, \"face-swap\"],\n [TTS_PROVIDERS, \"text-to-speech\"],\n // A dialogue model's id is the node's `provider`: without this row the Models\n // tab would create a BARE dialogue node, which runs as the default (v3) whatever\n // the user picked.\n [DIALOGUE_PROVIDERS, \"text-to-dialogue\"],\n [TEXT_TO_AUDIO_PROVIDERS, \"text-to-audio\"],\n [TRANSCRIBE_PROVIDERS, \"transcribe\"],\n [MUSIC_PROVIDERS, \"suno-generate\"],\n]\n\n// Fallback by the catalog's own `modes`, for models whose id is NOT a provider-enum\n// value — single-provider utility nodes (voice-design, dubbing, …) and catalog models\n// that no node exposes as a provider option. These create a bare node of the right\n// type (no provider preset — the user picks the model inside the node).\nconst MODE_TO_NODE: Readonly<Partial<Record<ModelMode, string>>> = {\n \"t2i\": \"generate-image\", \"i2i\": \"modify-image\", \"edit\": \"modify-image\", \"remove-bg\": \"modify-image\",\n \"t2v\": \"generate-video\", \"i2v\": \"generate-video\", \"v2v\": \"video-to-video\", \"extend\": \"extend-video\",\n \"upscale\": \"upscale-image\", \"video-upscale\": \"video-upscale\", \"motion-transfer\": \"motion-transfer\",\n \"lip-sync\": \"lip-sync\", \"tts\": \"text-to-speech\", \"sfx\": \"text-to-audio\",\n \"music\": \"suno-generate\", \"voice-design\": \"voice-design\", \"voice-changer\": \"voice-changer\",\n \"isolation\": \"audio-isolation\", \"dubbing\": \"dubbing\", \"forced-alignment\": \"forced-alignment\", \"stt\": \"transcribe\",\n \"dialogue\": \"text-to-dialogue\",\n \"video-analysis\": \"video-analysis\",\n}\n\nexport function modelToNodeTarget(modelId: string): ModelNodeTarget | null {\n const entry = MODEL_CATALOG[modelId]\n // A model the platform runs on its own creates no node (`pickerHidden`).\n if (!entry || entry.pickerHidden === true) return null\n // Resolve the target node: a valid provider-enum value wins, else the catalog's modes.\n const enumMatch = ENUM_TARGETS.find(([providers]) => providers.includes(modelId))\n const nodeType = enumMatch?.[1] ?? entry.modes.map((m) => MODE_TO_NODE[m]).find(Boolean)\n if (!nodeType) return null\n // suno-generate stores its model in `data.model` (a V-code carried on the catalog\n // entry as `dataValue`), not as a `provider` id. Every other node takes a `provider`\n // preset when the id is a valid enum value, and a bare node otherwise.\n if (nodeType === \"suno-generate\") {\n return entry.dataValue ? { nodeType, field: \"model\", value: entry.dataValue } : { nodeType }\n }\n return enumMatch ? { nodeType, field: \"provider\", value: modelId } : { nodeType }\n}\n\n/**\n * Flat, query-filtered model variants for the add-node search. The single source\n * of truth shared by the Models tab/category browser and every tab's search\n * (image/video/audio narrow by `kind`; models/all/common pass no kind). Filters\n * by label/id substring; a blank query returns `[]`. Derived from\n * `buildModelTree`, so only node-creatable models appear and new catalog entries\n * flow through automatically.\n */\n// MODEL_CATALOG + the provider enums are static module constants, so the tree\n// never changes at runtime — build it once and reuse for every search keystroke.\nlet _modelTree: ModelTreeLine[] | null = null\nfunction getModelTree(): ModelTreeLine[] {\n return (_modelTree ??= buildModelTree())\n}\n\nexport function searchModelVariants(query: string, kind?: ModelKind): ModelTreeVariant[] {\n const q = query.trim().toLowerCase()\n if (!q) return []\n return getModelTree()\n .flatMap((l) => l.models)\n .filter((m) => (!kind || m.kind === kind) && (m.label.toLowerCase().includes(q) || m.id.toLowerCase().includes(q)))\n}\n\nexport function buildModelTree(): ModelTreeLine[] {\n const bySeries = new Map<string, ModelTreeLine>()\n for (const entry of Object.values(MODEL_CATALOG)) {\n const target = modelToNodeTarget(entry.id)\n if (!target || !entry.series) continue\n let line = bySeries.get(entry.series)\n if (!line) {\n line = { series: entry.series, family: entry.family, kind: entry.kind, models: [] }\n bySeries.set(entry.series, line)\n }\n line.models.push({ id: entry.id, label: entry.label, kind: entry.kind, ...target })\n }\n return [...bySeries.values()].sort((a, b) => a.series.localeCompare(b.series))\n}\n","/**\n * Topaz video upscale — the lever a caller sets and the target it resolves to.\n *\n * Topaz takes an absolute TARGET, never a factor: a resolution (720p, 1080p or\n * 4K — the short side of the frame; a portrait clip keeps its orientation) and\n * an output frame rate (15–60 fps; frames it has to invent are interpolated).\n * The editor used to send a 1×/2×/4× factor, which saved workflows, older API\n * callers and private plugins still do, so a factor is still accepted and is\n * mapped onto the target here: factor × the source's short side, snapped to\n * the nearest target.\n *\n * One resolver for every lane (route, workflow run, plugin toolkit), so the\n * target a run is priced at is the one sent.\n */\n\nexport const TOPAZ_VIDEO_RESOLUTIONS = [\"720p\", \"1080p\", \"4k\"] as const\nexport type TopazVideoResolution = (typeof TOPAZ_VIDEO_RESOLUTIONS)[number]\n\nexport const TOPAZ_VIDEO_DEFAULT_RESOLUTION: TopazVideoResolution = \"1080p\"\n\n/** The short side, in pixels, of each target resolution. */\nexport const TOPAZ_VIDEO_SHORT_SIDE: Readonly<Record<TopazVideoResolution, number>> = {\n \"720p\": 720,\n \"1080p\": 1080,\n \"4k\": 2160,\n}\n\nexport const TOPAZ_VIDEO_FPS_MIN = 15\nexport const TOPAZ_VIDEO_FPS_MAX = 60\n/** The frame rates the editor offers beside \"same as source\". */\nexport const TOPAZ_VIDEO_FPS_CHOICES = [24, 25, 30, 50, 60] as const\n/** The rate used when neither the caller nor the source names one. */\nexport const TOPAZ_VIDEO_FALLBACK_FPS = 30\n\nexport function isTopazVideoResolution(v: unknown): v is TopazVideoResolution {\n return typeof v === \"string\" && (TOPAZ_VIDEO_RESOLUTIONS as readonly string[]).includes(v)\n}\n\n/**\n * The target whose short side is nearest `shortSide` px (4K above it, 720p\n * below; a tie takes the larger). A legacy factor lands here: a 720p clip at\n * 2× (1440 px) renders at 1080p, a 1080p clip at 2× at 4K.\n */\nexport function topazVideoResolutionNearest(shortSide: number): TopazVideoResolution {\n let best: TopazVideoResolution = TOPAZ_VIDEO_RESOLUTIONS[0]\n for (const r of TOPAZ_VIDEO_RESOLUTIONS) {\n if (Math.abs(TOPAZ_VIDEO_SHORT_SIDE[r] - shortSide) <= Math.abs(TOPAZ_VIDEO_SHORT_SIDE[best] - shortSide)) best = r\n }\n return best\n}\n\nexport function clampTopazVideoFps(fps: number): number {\n return Math.min(TOPAZ_VIDEO_FPS_MAX, Math.max(TOPAZ_VIDEO_FPS_MIN, Math.round(fps)))\n}\n\nexport interface TopazVideoSource {\n width: number\n height: number\n /** The source's own frame rate; absent when it has none (variable or unreadable). */\n fps?: number\n}\n\nexport interface TopazVideoTargetInput {\n targetResolution?: string | null\n /** Output frame rate; absent (or \"source\") = the source's own rate. */\n targetFps?: number | string | null\n /** Legacy relative lever (\"1\" | \"2\" | \"4\"): read only when no `targetResolution` is set. */\n upscaleFactor?: string | null\n source?: TopazVideoSource\n}\n\nexport interface TopazVideoTarget {\n resolution: TopazVideoResolution\n fps: number\n /** What was read in place of what was asked, for the job log. Empty when the request was taken as sent. */\n adjustments: string[]\n}\n\nconst LEGACY_FACTORS: Readonly<Record<string, number>> = { \"1\": 1, \"2\": 2, \"4\": 4 }\n\n/**\n * The target a Topaz video upscale renders at. `targetResolution` wins; else a\n * legacy factor over the source's short side; else 1080p. `targetFps` is\n * clamped to 15–60; absent, the source's rate (clamped), else 30.\n */\nexport function resolveTopazVideoTarget(input: TopazVideoTargetInput): TopazVideoTarget {\n const adjustments: string[] = []\n const shortSide = input.source ? Math.min(input.source.width, input.source.height) : undefined\n\n let resolution: TopazVideoResolution\n if (isTopazVideoResolution(input.targetResolution)) {\n resolution = input.targetResolution\n } else {\n if (input.targetResolution != null && input.targetResolution !== \"\") {\n adjustments.push(`targetResolution \"${input.targetResolution}\" is not one of ${TOPAZ_VIDEO_RESOLUTIONS.join(\", \")}`)\n }\n const factor = typeof input.upscaleFactor === \"string\" ? LEGACY_FACTORS[input.upscaleFactor.trim()] : undefined\n if (factor !== undefined && shortSide !== undefined) {\n resolution = topazVideoResolutionNearest(shortSide * factor)\n adjustments.push(`upscaleFactor ${factor}× of a ${shortSide}px short side → ${resolution}`)\n } else {\n resolution = TOPAZ_VIDEO_DEFAULT_RESOLUTION\n if (factor !== undefined) adjustments.push(`upscaleFactor ${factor}× with no readable source size → ${resolution}`)\n }\n }\n\n const asked = typeof input.targetFps === \"number\"\n ? input.targetFps\n : typeof input.targetFps === \"string\" && input.targetFps.trim() !== \"\" && input.targetFps !== \"source\"\n ? Number(input.targetFps)\n : undefined\n let fps: number\n if (asked !== undefined && Number.isFinite(asked)) {\n fps = clampTopazVideoFps(asked)\n if (fps !== asked) adjustments.push(`targetFps ${asked} → ${fps}`)\n } else if (input.source?.fps !== undefined && Number.isFinite(input.source.fps) && input.source.fps > 0) {\n fps = clampTopazVideoFps(input.source.fps)\n } else {\n fps = TOPAZ_VIDEO_FALLBACK_FPS\n }\n\n return { resolution, fps, adjustments }\n}\n\n/**\n * The output frame size a target renders a source at: the short side at the\n * target, the long side scaled by the source's aspect, both even. Without a\n * source, a 16:9 frame.\n */\nexport function topazVideoOutputSize(\n resolution: TopazVideoResolution,\n source?: Pick<TopazVideoSource, \"width\" | \"height\">,\n): { width: number; height: number } {\n const short = TOPAZ_VIDEO_SHORT_SIDE[resolution]\n const ratio = source && source.width > 0 && source.height > 0\n ? Math.max(source.width, source.height) / Math.min(source.width, source.height)\n : 16 / 9\n const long = Math.round((short * ratio) / 2) * 2\n const portrait = source ? source.height > source.width : false\n return portrait ? { width: short, height: long } : { width: long, height: short }\n}\n","/**\n * Nodaro Video Upscale — the Video Upscale node's `nodaro-video-upscale`\n * provider (decided 2026-11-11): what a caller may ask for and what the\n * platform accepts. The pricing rule lives in `@nodaro/render-rules`\n * (`nodaro-video-upscale-pricing.ts`). It is offered under the deployment's\n * own label (`ownLabel` in the catalog), and only where the deployment serves\n * it (the backend's house-model seam).\n *\n * A tier is an output BOX, not a short side: the clip is fitted into\n * 1920×1080, 2560×1440 or 3840×2160 (the box turned for a portrait clip),\n * never cropped, at its own frame rate, length and audio. It has no frame-rate\n * setting and no 720p tier — Topaz has both.\n */\n\nexport const NODARO_VIDEO_UPSCALE_PROVIDER = \"nodaro-video-upscale\" as const\n\n/** The output tiers, cheapest first. */\nexport const NODARO_VIDEO_UPSCALE_TIERS = [\"1080p\", \"2k\", \"4k\"] as const\nexport type NodaroVideoUpscaleTier = (typeof NODARO_VIDEO_UPSCALE_TIERS)[number]\n\n/**\n * The tier a request that names none runs at — the cheapest, as Topaz's\n * default is its 1080p (decided 2026-11-11 by the build; the catalog entry's\n * `defaultResolution` says the same, so the normalizer snaps to it).\n */\nexport const NODARO_VIDEO_UPSCALE_DEFAULT_TIER: NodaroVideoUpscaleTier = \"1080p\"\n\n/** The landscape output box of each tier (a portrait clip gets it turned). */\nexport const NODARO_VIDEO_UPSCALE_BOX: Readonly<Record<NodaroVideoUpscaleTier, { readonly width: number; readonly height: number }>> = {\n \"1080p\": { width: 1920, height: 1080 },\n \"2k\": { width: 2560, height: 1440 },\n \"4k\": { width: 3840, height: 2160 },\n}\n\n/** The longest clip accepted, in seconds. A longer one is refused before anything is held. */\nexport const NODARO_VIDEO_UPSCALE_MAX_SEC = 60\n\n/** The largest clip accepted, in bytes (50 MB, decimal). A larger one is refused before anything is held. */\nexport const NODARO_VIDEO_UPSCALE_MAX_BYTES = 50_000_000\n\nexport function isNodaroVideoUpscaleTier(v: unknown): v is NodaroVideoUpscaleTier {\n return typeof v === \"string\" && (NODARO_VIDEO_UPSCALE_TIERS as readonly string[]).includes(v)\n}\n\n/** Is this Video Upscale `provider` value the Nodaro Video Upscale provider? */\nexport function isNodaroVideoUpscaleProvider(provider: unknown): provider is typeof NODARO_VIDEO_UPSCALE_PROVIDER {\n return provider === NODARO_VIDEO_UPSCALE_PROVIDER\n}\n","import { hasFeature } from \"./model-catalog.js\"\n\n/**\n * Audio soundtrack: a video model whose reference audio clips are VOICE samples\n * (catalog feature `voice-references`, Kling 4.0) cannot play a clip as it is —\n * but it keeps a reference VIDEO's own sound when asked (`keep_original_sound`).\n * A model declaring `audio-soundtrack` therefore plays the FIRST reference audio\n * clip as the result's soundtrack: the platform turns that clip into a short\n * reference video (one still frame carrying the audio) and sends it with the\n * video's sound kept, so the people in the scene perform to the exact track.\n * Any further clips stay voice samples.\n *\n * On by default (`audioSoundtrack` unset = on); a caller turns it off with\n * `audioSoundtrack: false`. The clip then IS a reference video everywhere a run\n * is checked or priced — the reference-video price, the 5-clip and 30-second\n * caps — because the request carries it as one before any of those run.\n */\n\n/** The shortest reference video Kling 4.0 accepts; a shorter clip is padded with silence. */\nexport const AUDIO_SOUNDTRACK_MIN_SEC = 2\n\n/** The soundtrack clip's frame rate: its length is a whole number of these frames. */\nexport const AUDIO_SOUNDTRACK_FPS = 24\n\n/** Whether this run plays its first reference audio clip as the soundtrack. */\nexport function audioSoundtrackActive(args: {\n provider: string | undefined\n /** The node / request lever; unset = on. */\n audioSoundtrack: boolean | undefined\n /** How many reference audio clips the run carries (or has wired). */\n audioRefCount: number\n}): boolean {\n return (\n !!args.provider &&\n hasFeature(args.provider, \"audio-soundtrack\") &&\n args.audioSoundtrack !== false &&\n args.audioRefCount > 0\n )\n}\n\n/**\n * The length of the soundtrack clip a run sends: the audio's own length, at\n * least {@link AUDIO_SOUNDTRACK_MIN_SEC} (padded with silence) and at most the\n * clip being made (the rest of a longer track is not played), on whole frames\n * of {@link AUDIO_SOUNDTRACK_FPS} — the length the rendered file measures, so\n * the quote, the estimate and the run's own reservation all read one number.\n * An audio whose length is unknown counts as the whole clip — the longest it\n * can be, so a price built from it is never below the run's.\n */\nexport function audioSoundtrackClipSec(audioSec: number, outputSec: number): number {\n const sec = !Number.isFinite(audioSec) || audioSec <= 0 ? outputSec : Math.min(outputSec, Math.max(AUDIO_SOUNDTRACK_MIN_SEC, audioSec))\n return Math.round(sec * AUDIO_SOUNDTRACK_FPS) / AUDIO_SOUNDTRACK_FPS\n}\n\n/**\n * The prompt for a soundtrack run: the soundtrack clip is reference video\n * `@video_<videoNumber>` (after the caller's own clips), so a mention of the\n * first audio clip (`@audio_1`) now names it, and the remaining audio clips\n * move down one (`@audio_2` → `@audio_1`). A sentence before the prompt says\n * what that clip is for, when it fits within `maxChars` (the model's prompt\n * limit) — a prompt already near the limit keeps only the renaming.\n */\nexport function audioSoundtrackPrompt(prompt: string, videoNumber: number, maxChars = Number.POSITIVE_INFINITY): string {\n const video = `@video_${videoNumber}`\n const renamed = prompt.replace(/@audio_(\\d+)(?![\\w一-龥])/g, (whole, digits: string) => {\n const n = Number(digits)\n if (n === 1) return video\n return n > 1 ? `@audio_${n - 1}` : whole\n })\n const lead =\n `${video} is the soundtrack: the people in the scene perform to this exact audio, ` +\n \"their lips in sync with any singing or speech. Take only its sound, nothing from its picture.\"\n const withLead = renamed.trim() ? `${lead}\\n${renamed}` : lead\n return withLead.length <= maxChars ? withLead : renamed\n}\n","/**\n * The Lip Sync node's model-specific levers that a model may not take.\n *\n * OmniHuman 2.0 sits beside OmniHuman 1.5 but is not a superset of it: it has\n * no resolution choice (always 720p), no fast mode and no seed (decided\n * 2026-11-11). A node switched from 1.5 keeps those values in its data unless\n * something clears them, and a node written straight into workflow JSON, an\n * API body or an MCP call can carry them too. One table, read by every\n * surface: the config panel (its dropdown and fail-safe effect), the quick\n * strip's model switch, the lip-sync route and the workflow payload.\n *\n * Only models listed here lose anything: every other model's levers are left\n * exactly as they were.\n */\n\n/** The generic levers the Lip Sync node carries beside its inputs and prompt. */\nexport const LIP_SYNC_MODEL_LEVERS = [\"resolution\", \"fastMode\", \"seed\"] as const\nexport type LipSyncModelLever = typeof LIP_SYNC_MODEL_LEVERS[number]\n\nconst LEVERS_NOT_TAKEN: Readonly<Record<string, readonly LipSyncModelLever[]>> = {\n \"omnihuman-2-0\": [\"resolution\", \"fastMode\", \"seed\"],\n}\n\n/** The levers `provider` does not take (none for a model this table does not list). */\nexport function lipSyncLeversNotTaken(provider: unknown): readonly LipSyncModelLever[] {\n return typeof provider === \"string\" && Object.prototype.hasOwnProperty.call(LEVERS_NOT_TAKEN, provider)\n ? LEVERS_NOT_TAKEN[provider]!\n : []\n}\n\n/** Does `provider` take this lever? */\nexport function lipSyncTakesLever(provider: unknown, lever: LipSyncModelLever): boolean {\n return !lipSyncLeversNotTaken(provider).includes(lever)\n}\n\n/**\n * A patch that clears every lever `provider` does not take and `data` still\n * holds (each written as `undefined`). Empty when there is nothing to clear,\n * so a caller can skip the write.\n */\nexport function lipSyncLeverClearPatch(\n provider: unknown,\n data: Readonly<Record<string, unknown>>,\n): Partial<Record<LipSyncModelLever, undefined>> {\n const patch: Partial<Record<LipSyncModelLever, undefined>> = {}\n for (const lever of lipSyncLeversNotTaken(provider)) {\n if (data[lever] !== undefined) patch[lever] = undefined\n }\n return patch\n}\n\n/** `data` without the levers `provider` does not take: a copy when any was dropped, else `data` itself. */\nexport function withoutLipSyncLeversNotTaken<T extends Readonly<Record<string, unknown>>>(provider: unknown, data: T): T {\n const patch = lipSyncLeverClearPatch(provider, data)\n return Object.keys(patch).length === 0 ? data : { ...data, ...patch }\n}\n"]}