@nodaro/shared 3.52.1 → 3.54.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 (146) hide show
  1. package/dist/{chunk-6CVY3345.js → chunk-25KAGSPT.js} +3 -3
  2. package/dist/{chunk-6CVY3345.js.map → chunk-25KAGSPT.js.map} +1 -1
  3. package/dist/{chunk-FBLMWA2R.cjs → chunk-2OYV6K7D.cjs} +4 -4
  4. package/dist/{chunk-FBLMWA2R.cjs.map → chunk-2OYV6K7D.cjs.map} +1 -1
  5. package/dist/{chunk-J3HPEKGJ.cjs → chunk-2R74OU76.cjs} +23 -23
  6. package/dist/chunk-2R74OU76.cjs.map +1 -0
  7. package/dist/{chunk-CSPELPDB.cjs → chunk-3633VD2M.cjs} +8 -8
  8. package/dist/{chunk-CSPELPDB.cjs.map → chunk-3633VD2M.cjs.map} +1 -1
  9. package/dist/{chunk-A24LLEXS.js → chunk-3CHOZ573.js} +23 -23
  10. package/dist/chunk-3CHOZ573.js.map +1 -0
  11. package/dist/{chunk-IJ6XNHSD.cjs → chunk-3GMTGX3D.cjs} +27 -27
  12. package/dist/{chunk-IJ6XNHSD.cjs.map → chunk-3GMTGX3D.cjs.map} +1 -1
  13. package/dist/{chunk-AJFQ5242.js → chunk-5DVDHL7Y.js} +5 -5
  14. package/dist/{chunk-AJFQ5242.js.map → chunk-5DVDHL7Y.js.map} +1 -1
  15. package/dist/{chunk-VNHX6TQT.cjs → chunk-5R6LTKE5.cjs} +5 -5
  16. package/dist/{chunk-VNHX6TQT.cjs.map → chunk-5R6LTKE5.cjs.map} +1 -1
  17. package/dist/{chunk-YOH5AUYL.js → chunk-6UR5UE5G.js} +9 -9
  18. package/dist/{chunk-YOH5AUYL.js.map → chunk-6UR5UE5G.js.map} +1 -1
  19. package/dist/{chunk-3RYKIUAE.js → chunk-6XVHYD5R.js} +12 -8
  20. package/dist/chunk-6XVHYD5R.js.map +1 -0
  21. package/dist/{chunk-FRXVOYL2.js → chunk-ADWIAQQS.js} +3 -3
  22. package/dist/{chunk-FRXVOYL2.js.map → chunk-ADWIAQQS.js.map} +1 -1
  23. package/dist/{chunk-VLNOQJDO.cjs → chunk-AGTCHDG5.cjs} +6 -6
  24. package/dist/{chunk-VLNOQJDO.cjs.map → chunk-AGTCHDG5.cjs.map} +1 -1
  25. package/dist/{chunk-MI63SSCJ.cjs → chunk-ATWLKUAI.cjs} +4 -4
  26. package/dist/{chunk-MI63SSCJ.cjs.map → chunk-ATWLKUAI.cjs.map} +1 -1
  27. package/dist/{chunk-FIROF3TM.js → chunk-C5S75476.js} +5 -5
  28. package/dist/{chunk-FIROF3TM.js.map → chunk-C5S75476.js.map} +1 -1
  29. package/dist/{chunk-7HWXJIQ6.cjs → chunk-C6IQCKJT.cjs} +4 -4
  30. package/dist/{chunk-7HWXJIQ6.cjs.map → chunk-C6IQCKJT.cjs.map} +1 -1
  31. package/dist/{chunk-K3QNGRRX.js → chunk-CZCOL3M5.js} +10 -6
  32. package/dist/chunk-CZCOL3M5.js.map +1 -0
  33. package/dist/{chunk-JAGYUDOK.js → chunk-DUL5ZLTJ.js} +3 -3
  34. package/dist/{chunk-JAGYUDOK.js.map → chunk-DUL5ZLTJ.js.map} +1 -1
  35. package/dist/{chunk-BG5272F5.js → chunk-E4YES25K.js} +4 -4
  36. package/dist/{chunk-BG5272F5.js.map → chunk-E4YES25K.js.map} +1 -1
  37. package/dist/{chunk-QBXC3AXS.cjs → chunk-FIYVKW7F.cjs} +12 -12
  38. package/dist/{chunk-QBXC3AXS.cjs.map → chunk-FIYVKW7F.cjs.map} +1 -1
  39. package/dist/{chunk-CQJYKSXF.js → chunk-FVVD6XY2.js} +5 -3
  40. package/dist/chunk-FVVD6XY2.js.map +1 -0
  41. package/dist/chunk-HD45Y7QU.cjs +27 -0
  42. package/dist/{chunk-H7HKLN2W.cjs.map → chunk-HD45Y7QU.cjs.map} +1 -1
  43. package/dist/{chunk-JAD2SBD4.js → chunk-HEF4BIMA.js} +4 -4
  44. package/dist/{chunk-JAD2SBD4.js.map → chunk-HEF4BIMA.js.map} +1 -1
  45. package/dist/{chunk-GL5Z3CC4.js → chunk-HG3KKCJJ.js} +3 -3
  46. package/dist/{chunk-GL5Z3CC4.js.map → chunk-HG3KKCJJ.js.map} +1 -1
  47. package/dist/{chunk-MI6CZQCG.cjs → chunk-IPCWYKX5.cjs} +45 -45
  48. package/dist/{chunk-MI6CZQCG.cjs.map → chunk-IPCWYKX5.cjs.map} +1 -1
  49. package/dist/{chunk-7YFQKR5C.cjs → chunk-KM35K2M5.cjs} +21 -21
  50. package/dist/{chunk-7YFQKR5C.cjs.map → chunk-KM35K2M5.cjs.map} +1 -1
  51. package/dist/{chunk-OWVWV4T2.js → chunk-KMSEU6FK.js} +3 -3
  52. package/dist/{chunk-OWVWV4T2.js.map → chunk-KMSEU6FK.js.map} +1 -1
  53. package/dist/{chunk-2LNQ2MDO.js → chunk-LYWJAXPT.js} +3 -3
  54. package/dist/{chunk-2LNQ2MDO.js.map → chunk-LYWJAXPT.js.map} +1 -1
  55. package/dist/{chunk-6DAWSVX2.cjs → chunk-M3SXUUWC.cjs} +13 -7
  56. package/dist/chunk-M3SXUUWC.cjs.map +1 -0
  57. package/dist/{chunk-JZJRD7RG.js → chunk-MGJR5OXO.js} +5 -5
  58. package/dist/{chunk-JZJRD7RG.js.map → chunk-MGJR5OXO.js.map} +1 -1
  59. package/dist/{chunk-AVUW7XKP.cjs → chunk-MTUNORQB.cjs} +11 -11
  60. package/dist/{chunk-AVUW7XKP.cjs.map → chunk-MTUNORQB.cjs.map} +1 -1
  61. package/dist/{chunk-6LCZPDIF.js → chunk-N3WL6IOJ.js} +3 -3
  62. package/dist/{chunk-6LCZPDIF.js.map → chunk-N3WL6IOJ.js.map} +1 -1
  63. package/dist/{chunk-XRXPWW7P.cjs → chunk-ND3IE3IB.cjs} +47 -47
  64. package/dist/{chunk-XRXPWW7P.cjs.map → chunk-ND3IE3IB.cjs.map} +1 -1
  65. package/dist/{chunk-34EXMNOX.cjs → chunk-NEIWY6CC.cjs} +6 -6
  66. package/dist/{chunk-34EXMNOX.cjs.map → chunk-NEIWY6CC.cjs.map} +1 -1
  67. package/dist/{chunk-AJPV3RZJ.js → chunk-NMX6HQC3.js} +5 -5
  68. package/dist/{chunk-AJPV3RZJ.js.map → chunk-NMX6HQC3.js.map} +1 -1
  69. package/dist/{chunk-66GADQRV.cjs → chunk-OVIIJVXH.cjs} +21 -21
  70. package/dist/{chunk-66GADQRV.cjs.map → chunk-OVIIJVXH.cjs.map} +1 -1
  71. package/dist/{chunk-5PCI6M44.cjs → chunk-PONP5J5E.cjs} +5 -3
  72. package/dist/chunk-PONP5J5E.cjs.map +1 -0
  73. package/dist/{chunk-ETU6NWE2.cjs → chunk-QP5JLSCJ.cjs} +10 -6
  74. package/dist/chunk-QP5JLSCJ.cjs.map +1 -0
  75. package/dist/{chunk-SRLWSI6Q.cjs → chunk-SEEQ3H22.cjs} +5 -5
  76. package/dist/{chunk-SRLWSI6Q.cjs.map → chunk-SEEQ3H22.cjs.map} +1 -1
  77. package/dist/{chunk-25OWMP6B.cjs → chunk-SZUDEFX2.cjs} +41 -41
  78. package/dist/{chunk-25OWMP6B.cjs.map → chunk-SZUDEFX2.cjs.map} +1 -1
  79. package/dist/{chunk-TRZMLQSL.js → chunk-YBZQXZ6A.js} +3 -3
  80. package/dist/{chunk-TRZMLQSL.js.map → chunk-YBZQXZ6A.js.map} +1 -1
  81. package/dist/{chunk-WBPJNXYN.js → chunk-ZKHQSG76.js} +4 -4
  82. package/dist/{chunk-WBPJNXYN.js.map → chunk-ZKHQSG76.js.map} +1 -1
  83. package/dist/{chunk-VSNQLSME.js → chunk-ZWB3NG4M.js} +3 -3
  84. package/dist/{chunk-VSNQLSME.js.map → chunk-ZWB3NG4M.js.map} +1 -1
  85. package/dist/entries/apps.cjs +43 -43
  86. package/dist/entries/apps.js +8 -8
  87. package/dist/entries/credits.cjs +150 -150
  88. package/dist/entries/credits.js +7 -7
  89. package/dist/entries/media.cjs +81 -73
  90. package/dist/entries/media.d.cts +60 -80
  91. package/dist/entries/media.d.ts +60 -80
  92. package/dist/entries/media.js +2 -2
  93. package/dist/entries/model-catalog.cjs +66 -66
  94. package/dist/entries/model-catalog.js +4 -4
  95. package/dist/entries/models.cjs +277 -277
  96. package/dist/entries/models.js +5 -5
  97. package/dist/entries/nodes.cjs +207 -207
  98. package/dist/entries/nodes.js +9 -9
  99. package/dist/entries/pipeline.cjs +149 -149
  100. package/dist/entries/pipeline.js +3 -3
  101. package/dist/entries/types.d.cts +13 -0
  102. package/dist/entries/types.d.ts +13 -0
  103. package/dist/entries/ugc.cjs +71 -71
  104. package/dist/entries/ugc.js +4 -4
  105. package/dist/entries/video.cjs +117 -117
  106. package/dist/entries/video.js +4 -4
  107. package/dist/entries/workflow.cjs +99 -99
  108. package/dist/entries/workflow.js +2 -2
  109. package/dist/index.cjs +1233 -1225
  110. package/dist/index.d.cts +1 -1
  111. package/dist/index.d.ts +1 -1
  112. package/dist/index.js +21 -21
  113. package/package.json +1 -1
  114. package/src/__tests__/priced-clip-seconds.test.ts +193 -0
  115. package/src/__tests__/video-depth.test.ts +61 -19
  116. package/src/__tests__/video-face-mesh.test.ts +3 -2
  117. package/src/__tests__/video-mask.test.ts +1 -1
  118. package/src/catalog-projection.ts +13 -0
  119. package/src/entries/media.ts +1 -0
  120. package/src/generated/unit-contracts.ts +1 -0
  121. package/src/i18n/style.ar.ts +5 -0
  122. package/src/i18n/style.de.ts +5 -0
  123. package/src/i18n/style.es.ts +5 -0
  124. package/src/i18n/style.fr.ts +5 -0
  125. package/src/i18n/style.he.ts +5 -0
  126. package/src/i18n/style.hi.ts +5 -0
  127. package/src/i18n/style.ja.ts +5 -0
  128. package/src/i18n/style.ko.ts +5 -0
  129. package/src/i18n/style.pt-BR.ts +5 -0
  130. package/src/i18n/style.ru.ts +5 -0
  131. package/src/i18n/style.zh-CN.ts +5 -0
  132. package/src/mask-composite.ts +6 -5
  133. package/src/model-catalog.ts +21 -21
  134. package/src/priced-clip-seconds.ts +28 -0
  135. package/src/video-depth.ts +25 -12
  136. package/src/video-face-mesh.ts +10 -4
  137. package/src/video-mask.ts +12 -7
  138. package/dist/chunk-3RYKIUAE.js.map +0 -1
  139. package/dist/chunk-5PCI6M44.cjs.map +0 -1
  140. package/dist/chunk-6DAWSVX2.cjs.map +0 -1
  141. package/dist/chunk-A24LLEXS.js.map +0 -1
  142. package/dist/chunk-CQJYKSXF.js.map +0 -1
  143. package/dist/chunk-ETU6NWE2.cjs.map +0 -1
  144. package/dist/chunk-H7HKLN2W.cjs +0 -27
  145. package/dist/chunk-J3HPEKGJ.cjs.map +0 -1
  146. package/dist/chunk-K3QNGRRX.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk7HWXJIQ6_cjs = require('./chunk-7HWXJIQ6.cjs');
3
+ var chunkC6IQCKJT_cjs = require('./chunk-C6IQCKJT.cjs');
4
4
 
5
5
  // src/ugc-call-body.ts
6
6
  var pick = (a, from, to) => a[from] !== void 0 && a[from] !== null ? { [to]: a[from] } : {};
@@ -86,7 +86,7 @@ function ugcPrelude(answer) {
86
86
  const speech = callOf(answer.speech, "generate_speech");
87
87
  const align = callOf(answer.align, "forced_alignment");
88
88
  const split = callOf(answer.split, "ugc_split_speech");
89
- if (!speech || !align || !split || typeof speech.text !== "string" || !isObject(split.plan)) return { error: chunk7HWXJIQ6_cjs.UGC_NEWER_APP_MESSAGE };
89
+ if (!speech || !align || !split || typeof speech.text !== "string" || !isObject(split.plan)) return { error: chunkC6IQCKJT_cjs.UGC_NEWER_APP_MESSAGE };
90
90
  return {
91
91
  speech: {
92
92
  text: speech.text,
@@ -102,21 +102,21 @@ function ugcPrelude(answer) {
102
102
  function ugcPreludeOutput(step, output) {
103
103
  const value = step === "speech" ? output?.audioUrl : step === "alignment" ? output?.alignment : output?.segments;
104
104
  const ok = step === "speech" ? typeof value === "string" && value !== "" : Array.isArray(value) && value.length > 0;
105
- return ok ? { value } : { error: chunk7HWXJIQ6_cjs.UGC_NEWER_APP_MESSAGE };
105
+ return ok ? { value } : { error: chunkC6IQCKJT_cjs.UGC_NEWER_APP_MESSAGE };
106
106
  }
107
107
  function ugcClipsPhase2Body(body, segments) {
108
108
  return { ...body, segments: [...segments] };
109
109
  }
110
110
  function ugcRunEstimateInput(plan) {
111
- const targetDurationSec = chunk7HWXJIQ6_cjs.ugcPlanLengthSec(plan);
111
+ const targetDurationSec = chunkC6IQCKJT_cjs.ugcPlanLengthSec(plan);
112
112
  const language = planOf(plan)?.language;
113
- if (targetDurationSec === void 0 || typeof language !== "string" || language === "en" || !chunk7HWXJIQ6_cjs.UGC_SCRIPT_LANGUAGES.includes(language)) {
114
- return { error: chunk7HWXJIQ6_cjs.UGC_NEWER_APP_MESSAGE };
113
+ if (targetDurationSec === void 0 || typeof language !== "string" || language === "en" || !chunkC6IQCKJT_cjs.UGC_SCRIPT_LANGUAGES.includes(language)) {
114
+ return { error: chunkC6IQCKJT_cjs.UGC_NEWER_APP_MESSAGE };
115
115
  }
116
- return { runEstimate: { targetDurationSec, screenshotCount: chunk7HWXJIQ6_cjs.ugcPlanScreenshotCount(plan) ?? 0, source: "sampled", language } };
116
+ return { runEstimate: { targetDurationSec, screenshotCount: chunkC6IQCKJT_cjs.ugcPlanScreenshotCount(plan) ?? 0, source: "sampled", language } };
117
117
  }
118
118
  function ugcRenderHoldBody(input) {
119
- if (!Array.isArray(input.tickets) || input.tickets.length === 0) return { error: chunk7HWXJIQ6_cjs.UGC_NEWER_APP_MESSAGE };
119
+ if (!Array.isArray(input.tickets) || input.tickets.length === 0) return { error: chunkC6IQCKJT_cjs.UGC_NEWER_APP_MESSAGE };
120
120
  return {
121
121
  path: "/v1/ugc/quote",
122
122
  body: {
@@ -138,18 +138,18 @@ function planOf(plan) {
138
138
  }
139
139
  var isCredits = (x) => typeof x === "number" && Number.isFinite(x) && x >= 0;
140
140
  function ugcRenderHoldVerdict(answer) {
141
- if (!isObject(answer) || !isCredits(answer.ceiling) || !isCredits(answer.runHold)) return { error: chunk7HWXJIQ6_cjs.UGC_NEWER_APP_MESSAGE };
142
- return answer.ceiling > answer.runHold ? { error: chunk7HWXJIQ6_cjs.UGC_OVER_HOLD_MESSAGE } : { ok: true };
141
+ if (!isObject(answer) || !isCredits(answer.ceiling) || !isCredits(answer.runHold)) return { error: chunkC6IQCKJT_cjs.UGC_NEWER_APP_MESSAGE };
142
+ return answer.ceiling > answer.runHold ? { error: chunkC6IQCKJT_cjs.UGC_OVER_HOLD_MESSAGE } : { ok: true };
143
143
  }
144
144
  function ugcFinishPlan(input) {
145
145
  const clips = input.clipUrls.filter((u) => typeof u === "string" && u !== "");
146
- if (clips.length === 0) return { error: chunk7HWXJIQ6_cjs.UGC_FINISH_NEEDS_CLIPS_MESSAGE };
147
- const read = chunk7HWXJIQ6_cjs.readUgcWire(input.planOutWire, chunk7HWXJIQ6_cjs.UGC_NODE_MESSAGES.needsPlanOut);
146
+ if (clips.length === 0) return { error: chunkC6IQCKJT_cjs.UGC_FINISH_NEEDS_CLIPS_MESSAGE };
147
+ const read = chunkC6IQCKJT_cjs.readUgcWire(input.planOutWire, chunkC6IQCKJT_cjs.UGC_NODE_MESSAGES.needsPlanOut);
148
148
  if ("error" in read) return read;
149
149
  const finish = read.value.finish;
150
150
  if (finish === void 0) return { kind: "pass", clips };
151
- if (!isObject(finish) || !Array.isArray(finish.segments) || finish.segments.length === 0) return { error: chunk7HWXJIQ6_cjs.UGC_NEWER_APP_MESSAGE };
152
- if (finish.segments.length !== clips.length) return { error: chunk7HWXJIQ6_cjs.UGC_NEWER_APP_MESSAGE };
151
+ if (!isObject(finish) || !Array.isArray(finish.segments) || finish.segments.length === 0) return { error: chunkC6IQCKJT_cjs.UGC_NEWER_APP_MESSAGE };
152
+ if (finish.segments.length !== clips.length) return { error: chunkC6IQCKJT_cjs.UGC_NEWER_APP_MESSAGE };
153
153
  return {
154
154
  kind: "job",
155
155
  path: "/v1/ugc/finish",
@@ -157,12 +157,12 @@ function ugcFinishPlan(input) {
157
157
  };
158
158
  }
159
159
  function ugcFinishOutputs(output) {
160
- if (!output) return { error: chunk7HWXJIQ6_cjs.UGC_NEWER_APP_MESSAGE };
161
- if (output.ready === false) return { error: chunk7HWXJIQ6_cjs.UGC_FINISH_NOT_READY_MESSAGE };
162
- if (output.ready !== true || !Array.isArray(output.clips) || output.clips.length === 0) return { error: chunk7HWXJIQ6_cjs.UGC_NEWER_APP_MESSAGE };
160
+ if (!output) return { error: chunkC6IQCKJT_cjs.UGC_NEWER_APP_MESSAGE };
161
+ if (output.ready === false) return { error: chunkC6IQCKJT_cjs.UGC_FINISH_NOT_READY_MESSAGE };
162
+ if (output.ready !== true || !Array.isArray(output.clips) || output.clips.length === 0) return { error: chunkC6IQCKJT_cjs.UGC_NEWER_APP_MESSAGE };
163
163
  const warnings = Array.isArray(output.warnings) ? output.warnings.flatMap((w) => isObject(w) && typeof w.code === "string" ? [w.code] : typeof w === "string" ? [w] : []) : [];
164
164
  const rows = [...output.clips].filter(isObject).sort((a, b) => Number(a.clip) - Number(b.clip));
165
- if (rows.length !== output.clips.length || rows.some((r, i) => r.clip !== i + 1 || typeof r.url !== "string" || r.url === "")) return { error: chunk7HWXJIQ6_cjs.UGC_NEWER_APP_MESSAGE };
165
+ if (rows.length !== output.clips.length || rows.some((r, i) => r.clip !== i + 1 || typeof r.url !== "string" || r.url === "")) return { error: chunkC6IQCKJT_cjs.UGC_NEWER_APP_MESSAGE };
166
166
  return {
167
167
  clips: rows.map((r) => ({
168
168
  url: r.url,
@@ -175,7 +175,7 @@ function ugcFinishWired(edges, nodes, clipsId) {
175
175
  return edges.some((e) => e.source === clipsId && e.sourceHandle === "plan-out" && e.target !== void 0 && finishIds.has(e.target) && (e.targetHandle ?? "") === "plan");
176
176
  }
177
177
  function ugcLaneNeedsFinish(edges, nodes, clipsId) {
178
- return ugcFinishWired(edges, nodes, clipsId) ? null : chunk7HWXJIQ6_cjs.UGC_NEEDS_FINISH_MESSAGE;
178
+ return ugcFinishWired(edges, nodes, clipsId) ? null : chunkC6IQCKJT_cjs.UGC_NEEDS_FINISH_MESSAGE;
179
179
  }
180
180
 
181
181
  exports.UGC_FINISH_CLIPS_TYPE = UGC_FINISH_CLIPS_TYPE;
@@ -193,5 +193,5 @@ exports.ugcPreludeOutput = ugcPreludeOutput;
193
193
  exports.ugcRenderHoldBody = ugcRenderHoldBody;
194
194
  exports.ugcRenderHoldVerdict = ugcRenderHoldVerdict;
195
195
  exports.ugcRunEstimateInput = ugcRunEstimateInput;
196
- //# sourceMappingURL=chunk-66GADQRV.cjs.map
197
- //# sourceMappingURL=chunk-66GADQRV.cjs.map
196
+ //# sourceMappingURL=chunk-OVIIJVXH.cjs.map
197
+ //# sourceMappingURL=chunk-OVIIJVXH.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ugc-call-body.ts","../src/ugc-lane-wires.ts"],"names":["pick","UGC_NEWER_APP_MESSAGE","ugcPlanLengthSec","UGC_SCRIPT_LANGUAGES","ugcPlanScreenshotCount","UGC_OVER_HOLD_MESSAGE","UGC_FINISH_NEEDS_CLIPS_MESSAGE","readUgcWire","UGC_NODE_MESSAGES","UGC_FINISH_NOT_READY_MESSAGE","UGC_NEEDS_FINISH_MESSAGE"],"mappings":";;;;;AAkBA,IAAM,IAAA,GAAO,CAAC,CAAA,EAAsC,IAAA,EAAc,OAChE,CAAA,CAAE,IAAI,MAAM,MAAA,IAAa,CAAA,CAAE,IAAI,CAAA,KAAM,IAAA,GAAO,EAAE,CAAC,EAAE,GAAG,CAAA,CAAE,IAAI,CAAA,EAAE,GAAI,EAAC;AAGnE,SAAS,UAAU,CAAA,EAA+D;AAChF,EAAA,OAAO;AAAA,IACL,GAAG,IAAA,CAAK,CAAA,EAAG,UAAA,EAAY,UAAU,CAAA;AAAA,IACjC,GAAG,IAAA,CAAK,CAAA,EAAG,kBAAA,EAAoB,iBAAiB,CAAA;AAAA,IAChD,GA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,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,EAAY,CAAC,CAAA;AACtI,EAAA,OAAO,KAAA,CAAM,KAAK,CAAC,CAAA,KAAM,EAAE,MAAA,KAAW,OAAA,IAAW,EAAE,YAAA,KAAiB,UAAA,IAAc,EAAE,MAAA,KAAW,MAAA,IAAa,UAAU,GAAA,CAAI,CAAA,CAAE,MAAM,CAAA,IAAA,CAAM,CAAA,CAAE,YAAA,IAAgB,EAAA,MAAQ,MAAM,CAAA;AAC1K;AAGO,SAAS,kBAAA,CACd,KAAA,EACA,KAAA,EACA,OAAA,EACe;AACf,EAAA,OAAO,cAAA,CAAe,KAAA,EAAO,KAAA,EAAO,OAAO,IAAI,IAAA,GAAOS,0CAAA;AACxD","file":"chunk-66GADQRV.cjs","sourcesContent":["/**\n * A UGC builder call `{ tool, args }` (MCP argument names) → the REST body of\n * the public route that tool dispatches to. The builder sets every price lever;\n * this adds none — its one addition is the image of a call that needs the\n * previous step's image (`imageArg`, or the photo of `image_to_text`). A tool\n * it does not know → undefined, so an app older than the builder fails plainly\n * instead of guessing. Kept equal to the MCP verbs by ugc-call-body-parity.test.ts.\n */\nexport interface UgcToolCall {\n readonly tool: string\n readonly args: Readonly<Record<string, unknown>>\n readonly imageArg?: string\n}\nexport type UgcRouteBody = {\n readonly path: \"/v1/generate-image\" | \"/v1/image-to-image\" | \"/v1/image-to-text/describe\"\n readonly body: Record<string, unknown>\n}\n\nconst pick = (a: Readonly<Record<string, unknown>>, from: string, to: string): Record<string, unknown> =>\n a[from] !== undefined && a[from] !== null ? { [to]: a[from] } : {}\n\n/** The LLM levers image_to_text forwards (the verb's llmPayloadFields). */\nfunction llmFields(a: Readonly<Record<string, unknown>>): Record<string, unknown> {\n return {\n ...pick(a, \"llmModel\", \"llmModel\"),\n ...pick(a, \"reasoning_effort\", \"reasoningEffort\"),\n ...(a.advanced_mode === true ? { advancedMode: true } : {}),\n ...pick(a, \"temperature\", \"temperature\"),\n ...pick(a, \"max_tokens\", \"maxTokens\"),\n }\n}\n\nexport function ugcCallToRouteBody(\n call: UgcToolCall,\n opts: { readonly image?: string } = {},\n): UgcRouteBody | { readonly error: string } | undefined {\n const args: Record<string, unknown> = { ...call.args }\n if (call.imageArg) {\n if (!opts.image) return { error: `${call.tool} needs the previous step's image` }\n args[call.imageArg] = opts.image\n }\n switch (call.tool) {\n case \"generate_image\":\n return {\n path: \"/v1/generate-image\",\n body: {\n ...pick(args, \"prompt\", \"prompt\"),\n ...pick(args, \"model\", \"provider\"),\n ...pick(args, \"aspect_ratio\", \"aspectRatio\"),\n ...pick(args, \"resolution\", \"resolution\"),\n ...pick(args, \"quality\", \"quality\"),\n ...pick(args, \"negative_prompt\", \"negativePrompt\"),\n },\n }\n case \"image_to_image\":\n return {\n path: \"/v1/image-to-image\",\n body: {\n ...pick(args, \"image_url\", \"imageUrl\"),\n ...pick(args, \"prompt\", \"prompt\"),\n ...pick(args, \"model\", \"provider\"),\n ...pick(args, \"resolution\", \"resolution\"),\n ...pick(args, \"quality\", \"quality\"),\n ...pick(args, \"strength\", \"strength\"),\n ...pick(args, \"aspect_ratio\", \"aspectRatio\"),\n ...pick(args, \"negative_prompt\", \"negativePrompt\"),\n ...pick(args, \"seed\", \"seed\"),\n },\n }\n case \"image_to_text\": {\n const image = opts.image ?? (typeof args.image_url === \"string\" ? args.image_url : undefined)\n if (!image) return { error: \"image_to_text needs an image\" }\n return {\n path: \"/v1/image-to-text/describe\",\n body: {\n imageUrl: image,\n ...pick(args, \"detail_level\", \"detailLevel\"),\n ...pick(args, \"custom_prompt\", \"customPrompt\"),\n ...llmFields(args),\n },\n }\n }\n default:\n return undefined\n }\n}\n","/**\n * The UGC wires of a language whose clips are cut from one recorded speech (the\n * segmented lane): UGC Clips' prelude (record the speech, time its words, split\n * it at its pauses, then ask for the clips again with the segments) and UGC\n * Finish (lay the speech back over the rendered clips and trim the dead air,\n * as one job over all of them). One pure implementation both engines call, as\n * the rest of the UGC wires (`ugc-node-wires.ts`).\n *\n * Content-free: an answer is read only for `phase`, its three calls' `tool`\n * and `args` (argument names, never their meaning), the `finish` call's\n * `args`, and a finished job's clip list. Which language takes this lane, which\n * voice speaks and what the calls say are the builder's.\n */\nimport {\n UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n UGC_FINISH_NOT_READY_MESSAGE,\n UGC_NEEDS_FINISH_MESSAGE,\n UGC_NEWER_APP_MESSAGE,\n UGC_NODE_MESSAGES,\n UGC_OVER_HOLD_MESSAGE,\n UGC_SCRIPT_LANGUAGES,\n readUgcWire,\n ugcPlanLengthSec,\n ugcPlanScreenshotCount,\n} from \"./ugc-node-wires.js\"\nimport type { FanOutItemMeta } from \"./fan-out-meta.js\"\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/** UGC Finish's node type. Not the plugin job it runs (`ugc-finish`): a price, a dispatch or a reconcile keyed on a type never confuses the two. */\nexport const UGC_FINISH_CLIPS_TYPE = \"ugc-finish-clips\"\n\n/** The child steps of UGC Clips' prelude, in run order: each is a job of its own, keyed by its step. */\nexport const UGC_PRELUDE_STEPS = [\"speech\", \"alignment\", \"split\"] as const\nexport type UgcPreludeStep = (typeof UGC_PRELUDE_STEPS)[number]\n\n/** The public route each prelude step runs on, and the node type its job is read as. */\nexport const UGC_PRELUDE_ROUTES: Readonly<Record<UgcPreludeStep, { readonly path: string; readonly jobType: string }>> = {\n speech: { path: \"/v1/text-to-speech\", jobType: \"text-to-speech\" },\n alignment: { path: \"/v1/forced-alignment\", jobType: \"forced-alignment\" },\n split: { path: \"/v1/ugc/segments\", jobType: \"ugc-segments\" },\n}\n\n/** The `/v1/ugc/clips` answer's phase: 1 = the prelude must run first, 2 = the clips; null = an answer with no phase (one call, as English). */\nexport function ugcClipsPhase(answer: Readonly<Obj>): 1 | 2 | null {\n return answer.phase === 1 ? 1 : answer.phase === 2 ? 2 : null\n}\n\nconst callOf = (raw: unknown, tool: string): Obj | undefined => {\n if (!isObject(raw) || raw.tool !== tool || !isObject(raw.args)) return undefined\n return raw.args\n}\nconst pick = (a: Readonly<Obj>, from: string, to: string): Obj => (a[from] !== undefined && a[from] !== null ? { [to]: a[from] } : {})\n\n/** What the prelude runs: the speech's route body, and the two that need the step before them. */\nexport interface UgcPrelude {\n readonly speech: Obj\n readonly alignment: (audioUrl: string) => Obj\n readonly split: (audioUrl: string, alignment: unknown) => Obj\n}\n\n/**\n * A phase-1 answer's three calls (`speech`, `align`, `split`, MCP argument names) → the REST bodies of\n * the public routes their MCP tools dispatch to: `generate_speech` → `/v1/text-to-speech` (text, voice,\n * voice type, model as provider, language code, as the verb maps them), `forced_alignment` →\n * `/v1/forced-alignment` (the transcript, with the speech's audio), `ugc_split_speech` →\n * `/v1/ugc/segments` (the plan, with the speech's audio and its word timings). A call that is missing\n * or names another tool → the newer-app sentence: the app never guesses.\n */\nexport function ugcPrelude(answer: Readonly<Obj>): UgcPrelude | { readonly error: string } {\n const speech = callOf(answer.speech, \"generate_speech\")\n const align = callOf(answer.align, \"forced_alignment\")\n const split = callOf(answer.split, \"ugc_split_speech\")\n if (!speech || !align || !split || typeof speech.text !== \"string\" || !isObject(split.plan)) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n speech: {\n text: speech.text,\n ...pick(speech, \"voice_id\", \"voice\"),\n ...pick(speech, \"voice_type\", \"voiceType\"),\n ...pick(speech, \"model\", \"provider\"),\n ...pick(speech, \"language_code\", \"languageCode\"),\n },\n alignment: (audioUrl) => ({ ...pick(align, \"transcript\", \"transcript\"), audioUrl }),\n split: (audioUrl, alignment) => ({ plan: split.plan, audioUrl, alignment }),\n }\n}\n\n/** The finished speech job's audio, its word timings and its segments, as their jobs write them. */\nexport function ugcPreludeOutput(step: UgcPreludeStep, output: Readonly<Obj> | undefined): { value: unknown } | { error: string } {\n const value = step === \"speech\" ? output?.audioUrl : step === \"alignment\" ? output?.alignment : output?.segments\n const ok = step === \"speech\" ? typeof value === \"string\" && value !== \"\" : Array.isArray(value) && value.length > 0\n return ok ? { value } : { error: UGC_NEWER_APP_MESSAGE }\n}\n\n/** The second `/v1/ugc/clips` call: the first call's body with the segments the split returned. */\nexport function ugcClipsPhase2Body(body: Readonly<Obj>, segments: readonly unknown[]): Obj {\n return { ...body, segments: [...segments] }\n}\n\n// ── The hold check once the speech is split ──────────────────────────────────\n\n/** The estimate input of a video cut from one recorded speech, as the hold check names it (`runEstimate`). */\nexport interface UgcRunEstimateInput {\n readonly targetDurationSec: number\n readonly screenshotCount: number\n readonly source: \"sampled\"\n readonly language: string\n}\n\n/**\n * The estimate input of the video a UGC Clips run belongs to, read from the plan the node was sent: its\n * length, its screenshot cards and its language — the reading a kept plan is priced with. Read on a\n * phase-1 answer, before the prelude spends anything, so a plan the check cannot read refuses the run\n * while nothing is paid. The creator's source prices no clip, so it is not read. A plan without a length,\n * or without a language this lane takes → the newer-app sentence: the check never guesses.\n */\nexport function ugcRunEstimateInput(plan: unknown): { runEstimate: UgcRunEstimateInput } | { error: string } {\n const targetDurationSec = ugcPlanLengthSec(plan)\n const language = planOf(plan)?.language\n if (targetDurationSec === undefined || typeof language !== \"string\" || language === \"en\" || !(UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(language)) {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n return { runEstimate: { targetDurationSec, screenshotCount: ugcPlanScreenshotCount(plan) ?? 0, source: \"sampled\", language } }\n}\n\n/**\n * The quote that checks a video cut from one recorded speech before any of its clips renders: the clips\n * the second `/v1/ugc/clips` call handed on, priced as the UGC Clips quote prices them (`tickets`,\n * `hasCards`, `finishes`), with `runEstimate` (`ugcRunEstimateInput`). The route then also answers\n * `runHold`, the most the video's estimate holds for the clips and the steps after them, which the run's\n * balance was checked against before it started (`ugcRenderHoldVerdict`). No clips → the newer-app sentence.\n */\nexport function ugcRenderHoldBody(input: { runEstimate: UgcRunEstimateInput; tickets: unknown; hasCards: boolean; finishes: boolean }): { path: \"/v1/ugc/quote\"; body: Obj } | { error: string } {\n if (!Array.isArray(input.tickets) || input.tickets.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n path: \"/v1/ugc/quote\",\n body: {\n tickets: [...input.tickets],\n hasCards: input.hasCards,\n ...(input.finishes ? { finishes: true } : {}),\n runEstimate: { ...input.runEstimate },\n },\n }\n}\n\n/** A plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction planOf(plan: unknown): Obj | undefined {\n if (typeof plan !== \"string\") return isObject(plan) ? plan : undefined\n try {\n const parsed: unknown = JSON.parse(plan)\n return isObject(parsed) ? parsed : undefined\n } catch {\n return undefined\n }\n}\n\nconst isCredits = (x: unknown): x is number => typeof x === \"number\" && Number.isFinite(x) && x >= 0\n\n/**\n * The hold check's answer → go on, or stop before any clip renders: the clips and the steps after them\n * (`ceiling`, each clip at its hold) over what the run was checked for (`runHold`) → the over-hold\n * sentence. An answer without both figures stops too (the newer-app sentence): a clip never renders\n * on a figure nobody checked.\n */\nexport function ugcRenderHoldVerdict(answer: unknown): { readonly ok: true } | { readonly error: string } {\n if (!isObject(answer) || !isCredits(answer.ceiling) || !isCredits(answer.runHold)) return { error: UGC_NEWER_APP_MESSAGE }\n return answer.ceiling > answer.runHold ? { error: UGC_OVER_HOLD_MESSAGE } : { ok: true }\n}\n\n// ── UGC Finish ───────────────────────────────────────────────────────────────\n\n/** What UGC Finish does with the clips it was handed. */\nexport type UgcFinishPlan =\n /** No finish call on the plan (English): the clips go on as they came, no call, no job. */\n | { readonly kind: \"pass\"; readonly clips: readonly string[] }\n /** The finish job's body: the segments with their room, one roll per clip, in order. */\n | { readonly kind: \"job\"; readonly path: \"/v1/ugc/finish\"; readonly body: Obj }\n\n/**\n * UGC Finish's input → what it does. The `plan` input is UGC Clips' Script (sized) output; a plan\n * carrying `finish` (the segmented lane) asks for the finish job over the clips, in order; any other\n * plan passes the clips through. Clips are the fan-in list (`inputs.inputs`), in clip order.\n */\nexport function ugcFinishPlan(input: { planOutWire: unknown; clipUrls: readonly unknown[] }): UgcFinishPlan | { readonly error: string } {\n const clips = input.clipUrls.filter((u): u is string => typeof u === \"string\" && u !== \"\")\n if (clips.length === 0) return { error: UGC_FINISH_NEEDS_CLIPS_MESSAGE }\n const read = readUgcWire(input.planOutWire, UGC_NODE_MESSAGES.needsPlanOut)\n if (\"error\" in read) return read\n const finish = read.value.finish\n if (finish === undefined) return { kind: \"pass\", clips }\n if (!isObject(finish) || !Array.isArray(finish.segments) || finish.segments.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n if (finish.segments.length !== clips.length) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n kind: \"job\",\n path: \"/v1/ugc/finish\",\n body: { segments: finish.segments, clips: clips.map((url, i) => ({ clip: i + 1, rolls: [url] })) },\n }\n}\n\n/** A finished clip, as UGC Finish hands it on: its URL and the notes its downstream nodes read. */\nexport interface UgcFinishedClip { readonly url: string; readonly meta: FanOutItemMeta }\n\n/**\n * A finished `ugc-finish` job → the finished clips in clip order, each with its real length. `ready: false`\n * (a clip that does not follow its speech) → the not-ready sentence: the node fails, never hands on a\n * partial list. A dry finish's warning rides every clip's notes.\n */\nexport function ugcFinishOutputs(output: Readonly<Obj> | undefined): { clips: UgcFinishedClip[] } | { error: string } {\n if (!output) return { error: UGC_NEWER_APP_MESSAGE }\n if (output.ready === false) return { error: UGC_FINISH_NOT_READY_MESSAGE }\n if (output.ready !== true || !Array.isArray(output.clips) || output.clips.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n const warnings = Array.isArray(output.warnings)\n ? output.warnings.flatMap((w) => (isObject(w) && typeof w.code === \"string\" ? [w.code] : typeof w === \"string\" ? [w] : []))\n : []\n const rows = [...output.clips].filter(isObject).sort((a, b) => Number(a.clip) - Number(b.clip))\n if (rows.length !== output.clips.length || rows.some((r, i) => r.clip !== i + 1 || typeof r.url !== \"string\" || r.url === \"\")) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n clips: rows.map((r) => ({\n url: r.url as string,\n meta: { warnings, durationSec: typeof r.sec === \"number\" && Number.isFinite(r.sec) && r.sec > 0 ? r.sec : null },\n })),\n }\n}\n\n/**\n * Whether a UGC Finish reads this UGC Clips node's Script (sized) output: the graph can finish a video\n * whose clips are cut from one recorded speech. Read before the prelude spends anything.\n */\nexport function ugcFinishWired(\n edges: ReadonlyArray<{ readonly source?: string; readonly target?: string; readonly sourceHandle?: string | null; readonly targetHandle?: string | null }>,\n nodes: ReadonlyArray<{ readonly id?: string; readonly type?: string | null }>,\n clipsId: string,\n): boolean {\n const finishIds = new Set(nodes.filter((n) => n.type === UGC_FINISH_CLIPS_TYPE && typeof n.id === \"string\").map((n) => n.id as string))\n return edges.some((e) => e.source === clipsId && e.sourceHandle === \"plan-out\" && e.target !== undefined && finishIds.has(e.target) && (e.targetHandle ?? \"\") === \"plan\")\n}\n\n/** UGC Clips' refusal before its prelude: the sentence when no UGC Finish reads its Script (sized) output, else null. */\nexport function ugcLaneNeedsFinish(\n edges: Parameters<typeof ugcFinishWired>[0],\n nodes: Parameters<typeof ugcFinishWired>[1],\n clipsId: string,\n): string | null {\n return ugcFinishWired(edges, nodes, clipsId) ? null : UGC_NEEDS_FINISH_MESSAGE\n}\n"]}
1
+ {"version":3,"sources":["../src/ugc-call-body.ts","../src/ugc-lane-wires.ts"],"names":["pick","UGC_NEWER_APP_MESSAGE","ugcPlanLengthSec","UGC_SCRIPT_LANGUAGES","ugcPlanScreenshotCount","UGC_OVER_HOLD_MESSAGE","UGC_FINISH_NEEDS_CLIPS_MESSAGE","readUgcWire","UGC_NODE_MESSAGES","UGC_FINISH_NOT_READY_MESSAGE","UGC_NEEDS_FINISH_MESSAGE"],"mappings":";;;;;AAkBA,IAAM,IAAA,GAAO,CAAC,CAAA,EAAsC,IAAA,EAAc,OAChE,CAAA,CAAE,IAAI,MAAM,MAAA,IAAa,CAAA,CAAE,IAAI,CAAA,KAAM,IAAA,GAAO,EAAE,CAAC,EAAE,GAAG,CAAA,CAAE,IAAI,CAAA,EAAE,GA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ACF;AAMO,SAAS,cAAA,CACd,KAAA,EACA,KAAA,EACA,OAAA,EACS;AACT,EAAA,MAAM,SAAA,GAAY,IAAI,GAAA,CAAI,KAAA,CAAM,OAAO,CAAC,CAAA,KAAM,EAAE,IAAA,KAAS,qBAAA,IAAyB,OAAO,CAAA,CAAE,EAAA,KAAO,QAAQ,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,EAAY,CAAC,CAAA;AACtI,EAAA,OAAO,KAAA,CAAM,KAAK,CAAC,CAAA,KAAM,EAAE,MAAA,KAAW,OAAA,IAAW,EAAE,YAAA,KAAiB,UAAA,IAAc,EAAE,MAAA,KAAW,MAAA,IAAa,UAAU,GAAA,CAAI,CAAA,CAAE,MAAM,CAAA,IAAA,CAAM,CAAA,CAAE,YAAA,IAAgB,EAAA,MAAQ,MAAM,CAAA;AAC1K;AAGO,SAAS,kBAAA,CACd,KAAA,EACA,KAAA,EACA,OAAA,EACe;AACf,EAAA,OAAO,cAAA,CAAe,KAAA,EAAO,KAAA,EAAO,OAAO,IAAI,IAAA,GAAOS,0CAAA;AACxD","file":"chunk-OVIIJVXH.cjs","sourcesContent":["/**\n * A UGC builder call `{ tool, args }` (MCP argument names) → the REST body of\n * the public route that tool dispatches to. The builder sets every price lever;\n * this adds none — its one addition is the image of a call that needs the\n * previous step's image (`imageArg`, or the photo of `image_to_text`). A tool\n * it does not know → undefined, so an app older than the builder fails plainly\n * instead of guessing. Kept equal to the MCP verbs by ugc-call-body-parity.test.ts.\n */\nexport interface UgcToolCall {\n readonly tool: string\n readonly args: Readonly<Record<string, unknown>>\n readonly imageArg?: string\n}\nexport type UgcRouteBody = {\n readonly path: \"/v1/generate-image\" | \"/v1/image-to-image\" | \"/v1/image-to-text/describe\"\n readonly body: Record<string, unknown>\n}\n\nconst pick = (a: Readonly<Record<string, unknown>>, from: string, to: string): Record<string, unknown> =>\n a[from] !== undefined && a[from] !== null ? { [to]: a[from] } : {}\n\n/** The LLM levers image_to_text forwards (the verb's llmPayloadFields). */\nfunction llmFields(a: Readonly<Record<string, unknown>>): Record<string, unknown> {\n return {\n ...pick(a, \"llmModel\", \"llmModel\"),\n ...pick(a, \"reasoning_effort\", \"reasoningEffort\"),\n ...(a.advanced_mode === true ? { advancedMode: true } : {}),\n ...pick(a, \"temperature\", \"temperature\"),\n ...pick(a, \"max_tokens\", \"maxTokens\"),\n }\n}\n\nexport function ugcCallToRouteBody(\n call: UgcToolCall,\n opts: { readonly image?: string } = {},\n): UgcRouteBody | { readonly error: string } | undefined {\n const args: Record<string, unknown> = { ...call.args }\n if (call.imageArg) {\n if (!opts.image) return { error: `${call.tool} needs the previous step's image` }\n args[call.imageArg] = opts.image\n }\n switch (call.tool) {\n case \"generate_image\":\n return {\n path: \"/v1/generate-image\",\n body: {\n ...pick(args, \"prompt\", \"prompt\"),\n ...pick(args, \"model\", \"provider\"),\n ...pick(args, \"aspect_ratio\", \"aspectRatio\"),\n ...pick(args, \"resolution\", \"resolution\"),\n ...pick(args, \"quality\", \"quality\"),\n ...pick(args, \"negative_prompt\", \"negativePrompt\"),\n },\n }\n case \"image_to_image\":\n return {\n path: \"/v1/image-to-image\",\n body: {\n ...pick(args, \"image_url\", \"imageUrl\"),\n ...pick(args, \"prompt\", \"prompt\"),\n ...pick(args, \"model\", \"provider\"),\n ...pick(args, \"resolution\", \"resolution\"),\n ...pick(args, \"quality\", \"quality\"),\n ...pick(args, \"strength\", \"strength\"),\n ...pick(args, \"aspect_ratio\", \"aspectRatio\"),\n ...pick(args, \"negative_prompt\", \"negativePrompt\"),\n ...pick(args, \"seed\", \"seed\"),\n },\n }\n case \"image_to_text\": {\n const image = opts.image ?? (typeof args.image_url === \"string\" ? args.image_url : undefined)\n if (!image) return { error: \"image_to_text needs an image\" }\n return {\n path: \"/v1/image-to-text/describe\",\n body: {\n imageUrl: image,\n ...pick(args, \"detail_level\", \"detailLevel\"),\n ...pick(args, \"custom_prompt\", \"customPrompt\"),\n ...llmFields(args),\n },\n }\n }\n default:\n return undefined\n }\n}\n","/**\n * The UGC wires of a language whose clips are cut from one recorded speech (the\n * segmented lane): UGC Clips' prelude (record the speech, time its words, split\n * it at its pauses, then ask for the clips again with the segments) and UGC\n * Finish (lay the speech back over the rendered clips and trim the dead air,\n * as one job over all of them). One pure implementation both engines call, as\n * the rest of the UGC wires (`ugc-node-wires.ts`).\n *\n * Content-free: an answer is read only for `phase`, its three calls' `tool`\n * and `args` (argument names, never their meaning), the `finish` call's\n * `args`, and a finished job's clip list. Which language takes this lane, which\n * voice speaks and what the calls say are the builder's.\n */\nimport {\n UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n UGC_FINISH_NOT_READY_MESSAGE,\n UGC_NEEDS_FINISH_MESSAGE,\n UGC_NEWER_APP_MESSAGE,\n UGC_NODE_MESSAGES,\n UGC_OVER_HOLD_MESSAGE,\n UGC_SCRIPT_LANGUAGES,\n readUgcWire,\n ugcPlanLengthSec,\n ugcPlanScreenshotCount,\n} from \"./ugc-node-wires.js\"\nimport type { FanOutItemMeta } from \"./fan-out-meta.js\"\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/** UGC Finish's node type. Not the plugin job it runs (`ugc-finish`): a price, a dispatch or a reconcile keyed on a type never confuses the two. */\nexport const UGC_FINISH_CLIPS_TYPE = \"ugc-finish-clips\"\n\n/** The child steps of UGC Clips' prelude, in run order: each is a job of its own, keyed by its step. */\nexport const UGC_PRELUDE_STEPS = [\"speech\", \"alignment\", \"split\"] as const\nexport type UgcPreludeStep = (typeof UGC_PRELUDE_STEPS)[number]\n\n/** The public route each prelude step runs on, and the node type its job is read as. */\nexport const UGC_PRELUDE_ROUTES: Readonly<Record<UgcPreludeStep, { readonly path: string; readonly jobType: string }>> = {\n speech: { path: \"/v1/text-to-speech\", jobType: \"text-to-speech\" },\n alignment: { path: \"/v1/forced-alignment\", jobType: \"forced-alignment\" },\n split: { path: \"/v1/ugc/segments\", jobType: \"ugc-segments\" },\n}\n\n/** The `/v1/ugc/clips` answer's phase: 1 = the prelude must run first, 2 = the clips; null = an answer with no phase (one call, as English). */\nexport function ugcClipsPhase(answer: Readonly<Obj>): 1 | 2 | null {\n return answer.phase === 1 ? 1 : answer.phase === 2 ? 2 : null\n}\n\nconst callOf = (raw: unknown, tool: string): Obj | undefined => {\n if (!isObject(raw) || raw.tool !== tool || !isObject(raw.args)) return undefined\n return raw.args\n}\nconst pick = (a: Readonly<Obj>, from: string, to: string): Obj => (a[from] !== undefined && a[from] !== null ? { [to]: a[from] } : {})\n\n/** What the prelude runs: the speech's route body, and the two that need the step before them. */\nexport interface UgcPrelude {\n readonly speech: Obj\n readonly alignment: (audioUrl: string) => Obj\n readonly split: (audioUrl: string, alignment: unknown) => Obj\n}\n\n/**\n * A phase-1 answer's three calls (`speech`, `align`, `split`, MCP argument names) → the REST bodies of\n * the public routes their MCP tools dispatch to: `generate_speech` → `/v1/text-to-speech` (text, voice,\n * voice type, model as provider, language code, as the verb maps them), `forced_alignment` →\n * `/v1/forced-alignment` (the transcript, with the speech's audio), `ugc_split_speech` →\n * `/v1/ugc/segments` (the plan, with the speech's audio and its word timings). A call that is missing\n * or names another tool → the newer-app sentence: the app never guesses.\n */\nexport function ugcPrelude(answer: Readonly<Obj>): UgcPrelude | { readonly error: string } {\n const speech = callOf(answer.speech, \"generate_speech\")\n const align = callOf(answer.align, \"forced_alignment\")\n const split = callOf(answer.split, \"ugc_split_speech\")\n if (!speech || !align || !split || typeof speech.text !== \"string\" || !isObject(split.plan)) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n speech: {\n text: speech.text,\n ...pick(speech, \"voice_id\", \"voice\"),\n ...pick(speech, \"voice_type\", \"voiceType\"),\n ...pick(speech, \"model\", \"provider\"),\n ...pick(speech, \"language_code\", \"languageCode\"),\n },\n alignment: (audioUrl) => ({ ...pick(align, \"transcript\", \"transcript\"), audioUrl }),\n split: (audioUrl, alignment) => ({ plan: split.plan, audioUrl, alignment }),\n }\n}\n\n/** The finished speech job's audio, its word timings and its segments, as their jobs write them. */\nexport function ugcPreludeOutput(step: UgcPreludeStep, output: Readonly<Obj> | undefined): { value: unknown } | { error: string } {\n const value = step === \"speech\" ? output?.audioUrl : step === \"alignment\" ? output?.alignment : output?.segments\n const ok = step === \"speech\" ? typeof value === \"string\" && value !== \"\" : Array.isArray(value) && value.length > 0\n return ok ? { value } : { error: UGC_NEWER_APP_MESSAGE }\n}\n\n/** The second `/v1/ugc/clips` call: the first call's body with the segments the split returned. */\nexport function ugcClipsPhase2Body(body: Readonly<Obj>, segments: readonly unknown[]): Obj {\n return { ...body, segments: [...segments] }\n}\n\n// ── The hold check once the speech is split ──────────────────────────────────\n\n/** The estimate input of a video cut from one recorded speech, as the hold check names it (`runEstimate`). */\nexport interface UgcRunEstimateInput {\n readonly targetDurationSec: number\n readonly screenshotCount: number\n readonly source: \"sampled\"\n readonly language: string\n}\n\n/**\n * The estimate input of the video a UGC Clips run belongs to, read from the plan the node was sent: its\n * length, its screenshot cards and its language — the reading a kept plan is priced with. Read on a\n * phase-1 answer, before the prelude spends anything, so a plan the check cannot read refuses the run\n * while nothing is paid. The creator's source prices no clip, so it is not read. A plan without a length,\n * or without a language this lane takes → the newer-app sentence: the check never guesses.\n */\nexport function ugcRunEstimateInput(plan: unknown): { runEstimate: UgcRunEstimateInput } | { error: string } {\n const targetDurationSec = ugcPlanLengthSec(plan)\n const language = planOf(plan)?.language\n if (targetDurationSec === undefined || typeof language !== \"string\" || language === \"en\" || !(UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(language)) {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n return { runEstimate: { targetDurationSec, screenshotCount: ugcPlanScreenshotCount(plan) ?? 0, source: \"sampled\", language } }\n}\n\n/**\n * The quote that checks a video cut from one recorded speech before any of its clips renders: the clips\n * the second `/v1/ugc/clips` call handed on, priced as the UGC Clips quote prices them (`tickets`,\n * `hasCards`, `finishes`), with `runEstimate` (`ugcRunEstimateInput`). The route then also answers\n * `runHold`, the most the video's estimate holds for the clips and the steps after them, which the run's\n * balance was checked against before it started (`ugcRenderHoldVerdict`). No clips → the newer-app sentence.\n */\nexport function ugcRenderHoldBody(input: { runEstimate: UgcRunEstimateInput; tickets: unknown; hasCards: boolean; finishes: boolean }): { path: \"/v1/ugc/quote\"; body: Obj } | { error: string } {\n if (!Array.isArray(input.tickets) || input.tickets.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n path: \"/v1/ugc/quote\",\n body: {\n tickets: [...input.tickets],\n hasCards: input.hasCards,\n ...(input.finishes ? { finishes: true } : {}),\n runEstimate: { ...input.runEstimate },\n },\n }\n}\n\n/** A plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction planOf(plan: unknown): Obj | undefined {\n if (typeof plan !== \"string\") return isObject(plan) ? plan : undefined\n try {\n const parsed: unknown = JSON.parse(plan)\n return isObject(parsed) ? parsed : undefined\n } catch {\n return undefined\n }\n}\n\nconst isCredits = (x: unknown): x is number => typeof x === \"number\" && Number.isFinite(x) && x >= 0\n\n/**\n * The hold check's answer → go on, or stop before any clip renders: the clips and the steps after them\n * (`ceiling`, each clip at its hold) over what the run was checked for (`runHold`) → the over-hold\n * sentence. An answer without both figures stops too (the newer-app sentence): a clip never renders\n * on a figure nobody checked.\n */\nexport function ugcRenderHoldVerdict(answer: unknown): { readonly ok: true } | { readonly error: string } {\n if (!isObject(answer) || !isCredits(answer.ceiling) || !isCredits(answer.runHold)) return { error: UGC_NEWER_APP_MESSAGE }\n return answer.ceiling > answer.runHold ? { error: UGC_OVER_HOLD_MESSAGE } : { ok: true }\n}\n\n// ── UGC Finish ───────────────────────────────────────────────────────────────\n\n/** What UGC Finish does with the clips it was handed. */\nexport type UgcFinishPlan =\n /** No finish call on the plan (English): the clips go on as they came, no call, no job. */\n | { readonly kind: \"pass\"; readonly clips: readonly string[] }\n /** The finish job's body: the segments with their room, one roll per clip, in order. */\n | { readonly kind: \"job\"; readonly path: \"/v1/ugc/finish\"; readonly body: Obj }\n\n/**\n * UGC Finish's input → what it does. The `plan` input is UGC Clips' Script (sized) output; a plan\n * carrying `finish` (the segmented lane) asks for the finish job over the clips, in order; any other\n * plan passes the clips through. Clips are the fan-in list (`inputs.inputs`), in clip order.\n */\nexport function ugcFinishPlan(input: { planOutWire: unknown; clipUrls: readonly unknown[] }): UgcFinishPlan | { readonly error: string } {\n const clips = input.clipUrls.filter((u): u is string => typeof u === \"string\" && u !== \"\")\n if (clips.length === 0) return { error: UGC_FINISH_NEEDS_CLIPS_MESSAGE }\n const read = readUgcWire(input.planOutWire, UGC_NODE_MESSAGES.needsPlanOut)\n if (\"error\" in read) return read\n const finish = read.value.finish\n if (finish === undefined) return { kind: \"pass\", clips }\n if (!isObject(finish) || !Array.isArray(finish.segments) || finish.segments.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n if (finish.segments.length !== clips.length) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n kind: \"job\",\n path: \"/v1/ugc/finish\",\n body: { segments: finish.segments, clips: clips.map((url, i) => ({ clip: i + 1, rolls: [url] })) },\n }\n}\n\n/** A finished clip, as UGC Finish hands it on: its URL and the notes its downstream nodes read. */\nexport interface UgcFinishedClip { readonly url: string; readonly meta: FanOutItemMeta }\n\n/**\n * A finished `ugc-finish` job → the finished clips in clip order, each with its real length. `ready: false`\n * (a clip that does not follow its speech) → the not-ready sentence: the node fails, never hands on a\n * partial list. A dry finish's warning rides every clip's notes.\n */\nexport function ugcFinishOutputs(output: Readonly<Obj> | undefined): { clips: UgcFinishedClip[] } | { error: string } {\n if (!output) return { error: UGC_NEWER_APP_MESSAGE }\n if (output.ready === false) return { error: UGC_FINISH_NOT_READY_MESSAGE }\n if (output.ready !== true || !Array.isArray(output.clips) || output.clips.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n const warnings = Array.isArray(output.warnings)\n ? output.warnings.flatMap((w) => (isObject(w) && typeof w.code === \"string\" ? [w.code] : typeof w === \"string\" ? [w] : []))\n : []\n const rows = [...output.clips].filter(isObject).sort((a, b) => Number(a.clip) - Number(b.clip))\n if (rows.length !== output.clips.length || rows.some((r, i) => r.clip !== i + 1 || typeof r.url !== \"string\" || r.url === \"\")) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n clips: rows.map((r) => ({\n url: r.url as string,\n meta: { warnings, durationSec: typeof r.sec === \"number\" && Number.isFinite(r.sec) && r.sec > 0 ? r.sec : null },\n })),\n }\n}\n\n/**\n * Whether a UGC Finish reads this UGC Clips node's Script (sized) output: the graph can finish a video\n * whose clips are cut from one recorded speech. Read before the prelude spends anything.\n */\nexport function ugcFinishWired(\n edges: ReadonlyArray<{ readonly source?: string; readonly target?: string; readonly sourceHandle?: string | null; readonly targetHandle?: string | null }>,\n nodes: ReadonlyArray<{ readonly id?: string; readonly type?: string | null }>,\n clipsId: string,\n): boolean {\n const finishIds = new Set(nodes.filter((n) => n.type === UGC_FINISH_CLIPS_TYPE && typeof n.id === \"string\").map((n) => n.id as string))\n return edges.some((e) => e.source === clipsId && e.sourceHandle === \"plan-out\" && e.target !== undefined && finishIds.has(e.target) && (e.targetHandle ?? \"\") === \"plan\")\n}\n\n/** UGC Clips' refusal before its prelude: the sentence when no UGC Finish reads its Script (sized) output, else null. */\nexport function ugcLaneNeedsFinish(\n edges: Parameters<typeof ugcFinishWired>[0],\n nodes: Parameters<typeof ugcFinishWired>[1],\n clipsId: string,\n): string | null {\n return ugcFinishWired(edges, nodes, clipsId) ? null : UGC_NEEDS_FINISH_MESSAGE\n}\n"]}
@@ -38,8 +38,10 @@ var UNIT_JSON_PIPS = [
38
38
  // unit:clip-pack
39
39
  ["speaker-layout", { "json": "edl" }],
40
40
  // unit:speaker-layout
41
- ["speaker-map", { "edl": "edl", "json": "other" }]
41
+ ["speaker-map", { "edl": "edl", "json": "other" }],
42
42
  // unit:speaker-map
43
+ ["shot-cuts", { "firstFrames": "other", "json": "other", "lastFrames": "other" }]
44
+ // unit:shot-cuts
43
45
  ];
44
46
  var UNIT_NON_PROMPT_INPUTS = [
45
47
  ["tighten-episode", ["music", "masterAudio"]],
@@ -107,5 +109,5 @@ exports.unitNonPromptInputs = unitNonPromptInputs;
107
109
  exports.unitProducers = unitProducers;
108
110
  exports.unitReviewHolds = unitReviewHolds;
109
111
  exports.unitsPresenting = unitsPresenting;
110
- //# sourceMappingURL=chunk-5PCI6M44.cjs.map
111
- //# sourceMappingURL=chunk-5PCI6M44.cjs.map
112
+ //# sourceMappingURL=chunk-PONP5J5E.cjs.map
113
+ //# sourceMappingURL=chunk-PONP5J5E.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generated/unit-contracts.ts","../src/unit-contract-compose.ts"],"names":[],"mappings":";;;AAQO,IAAM,cAAA,GAA4G;AAAA,EACvH,CAAC,mBAAmB,SAAS,CAAA;AAAA;AAAA,EAC7B,CAAC,mBAAmB,OAAO,CAAA;AAAA;AAAA,EAC3B,CAAC,aAAa,SAAS,CAAA;AAAA;AAAA,EACvB,CAAC,kBAAkB,OAAO,CAAA;AAAA;AAAA,EAC1B,CAAC,gBAAgB,OAAO,CAAA;AAAA;AAAA,EACxB,CAAC,gBAAgB,OAAO;AAAA;AAC1B,CAAA;AAGO,IAAM,mBAAA,GAAsB;AAAA,EACjC,iBAAA;AAAA;AAAA,EACA,kBAAA;AAAA;AAAA,EACA,iBAAA;AAAA;AAAA,EACA,WAAA;AAAA;AAAA,EACA;AAAA;AACF;AAGO,IAAM,cAAA,GAAyH;AAAA,EACpI,CAAC,iBAAA,EAAmB,EAAE,MAAA,EAAQ,OAAO,CAAA;AAAA;AAAA,EACrC,CAAC,kBAAA,EAAoB,EAAE,MAAA,EAAQ,SAAS,CAAA;AAAA;AAAA,EACxC,CAAC,iBAAA,EAAmB,EAAE,MAAA,EAAQ,OAAO,CAAA;AAAA;AAAA,EACrC,CAAC,WAAA,EAAa,EAAE,MAAA,EAAQ,OAAO,CAAA;AAAA;AAAA,EAC/B,CAAC,gBAAA,EAAkB,E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,eAAe,MAAkG;AAGvH,IAAM,sBAAsB,MAA+D;AAG3F,IAAM,kBAAkB,MAAyB;AAGjD,IAAM,iBAAiB,MAA4G","file":"chunk-PONP5J5E.cjs","sourcesContent":["// GENERATED by tools/units/gen.mjs — do not edit; run npm run gen:units\n// The unit contract published in @nodaro/shared (decided 2026-10-16, widened 2026-10-18): node type\n// ids with closed vocabularies — each unit's producer kind, the use-case types, what each JSON pip\n// carries, the input pips that are never a prompt lane, the review holds, how a published app\n// presents the result and which outputs fan out item by item. Never a price, credit id, number,\n// prompt or doctrine string. Each block feeds a published table that composes its rows with the\n// hand-written ones (unit-contract-compose.ts); every row is an irrevocable Apache grant.\n\nexport const UNIT_CONTRACTS: ReadonlyArray<readonly [type: string, producer: \"audio\" | \"video\" | \"image\" | \"dynamic\"]> = [\n [\"tighten-episode\", \"dynamic\"], // unit:tighten-episode\n [\"episode-trailer\", \"video\"], // unit:episode-trailer\n [\"clip-pack\", \"dynamic\"], // unit:clip-pack\n [\"speaker-layout\", \"video\"], // unit:speaker-layout\n [\"remove-audio\", \"video\"], // unit:remove-audio\n [\"gif-to-video\", \"video\"], // unit:gif-to-video\n]\n\n// The use-case node units (execution.kind \"use-case\"), in position order — each a route POST /v1/<type> (+ /estimate, /continue).\nexport const UNIT_USE_CASE_TYPES = [\n \"tighten-episode\", // unit:tighten-episode\n \"episode-chapters\", // unit:episode-chapters\n \"episode-trailer\", // unit:episode-trailer\n \"clip-pack\", // unit:clip-pack\n \"speaker-layout\", // unit:speaker-layout\n] as const\n\n// What each JSON (look) output pip carries (contract.jsonPips) — json-kinds.ts composes these.\nexport const UNIT_JSON_PIPS: ReadonlyArray<readonly [type: string, pips: Readonly<Record<string, \"transcript\" | \"edl\" | \"other\">>]> = [\n [\"tighten-episode\", { \"json\": \"edl\" }], // unit:tighten-episode\n [\"episode-chapters\", { \"json\": \"other\" }], // unit:episode-chapters\n [\"episode-trailer\", { \"json\": \"edl\" }], // unit:episode-trailer\n [\"clip-pack\", { \"json\": \"edl\" }], // unit:clip-pack\n [\"speaker-layout\", { \"json\": \"edl\" }], // unit:speaker-layout\n [\"speaker-map\", { \"edl\": \"edl\", \"json\": \"other\" }], // unit:speaker-map\n [\"shot-cuts\", { \"firstFrames\": \"other\", \"json\": \"other\", \"lastFrames\": \"other\" }], // unit:shot-cuts\n]\n\n// Input pips that are never a prompt lane (contract.nonPromptInputs) — fan-out-rows.ts composes these.\nexport const UNIT_NON_PROMPT_INPUTS: ReadonlyArray<readonly [type: string, handles: ReadonlyArray<string>]> = [\n [\"tighten-episode\", [\"music\", \"masterAudio\"]], // unit:tighten-episode\n [\"episode-trailer\", [\"introCard\", \"masterAudio\"]], // unit:episode-trailer\n [\"clip-pack\", [\"masterAudio\"]], // unit:clip-pack\n [\"speaker-layout\", [\"masterAudio\"]], // unit:speaker-layout\n]\n\n// Use-case units whose review-on run ends at a Preview that holds what follows (contract.reviewHold) — preview-gate.ts.\nexport const UNIT_REVIEW_HOLDS: ReadonlyArray<string> = [\n \"tighten-episode\", // unit:tighten-episode\n \"episode-trailer\", // unit:episode-trailer\n \"clip-pack\", // unit:clip-pack\n \"speaker-layout\", // unit:speaker-layout\n]\n\n// How a published app shows each unit's result where the producer sets do not decide it (contract.presents) — presentation-utils.ts.\nexport const UNIT_PRESENTS: ReadonlyArray<readonly [type: string, presents: \"image\" | \"video\" | \"audio\" | \"text\"]> = [\n [\"tighten-episode\", \"video\"], // unit:tighten-episode\n [\"episode-chapters\", \"text\"], // unit:episode-chapters\n [\"clip-pack\", \"video\"], // unit:clip-pack\n]\n\n// The outputs an \"each\" edge reads item by item when the unit ran once per item, and the pip an edge naming none reads (contract.fanOutEach) — producer-types.ts.\nexport const UNIT_FAN_OUT_EACH: ReadonlyArray<readonly [type: string, handles: { readonly each: ReadonlyArray<string>; readonly primary: string }]> = [\n [\"episode-trailer\", { \"each\": [\"media\"], \"primary\": \"media\" }], // unit:episode-trailer\n [\"clip-pack\", { \"each\": [\"clips\"], \"primary\": \"clips\" }], // unit:clip-pack\n]\n","/**\n * The node units' rows in @nodaro/shared (tools/units/README.md): the readers\n * of `generated/unit-contracts.ts` and the one rule every table that composes\n * them keeps — a type is hand-written or a node unit, never both. Internal:\n * no entry exports this module, so it adds nothing to the published surface;\n * the tables that compose its rows (producer-types, presentation-utils,\n * json-kinds, fan-out-rows, preview-gate) are what consumers read.\n */\nimport { UNIT_CONTRACTS, UNIT_FAN_OUT_EACH, UNIT_JSON_PIPS, UNIT_NON_PROMPT_INPUTS, UNIT_PRESENTS, UNIT_REVIEW_HOLDS } from \"./generated/unit-contracts.js\"\n\n/**\n * `legacy ∪ units` as a set, `legacy` first, refusing a type that is in both —\n * a type lives in one place (G1; the editor's and the server's composeSet keep\n * the same rule). Throws at module load, so any import of the set fails.\n */\nexport function composeUnitSet(what: string, legacy: readonly string[], units: readonly string[]): ReadonlySet<string> {\n const clash = units.filter((t) => legacy.includes(t))\n if (clash.length > 0) throw new Error(`${what}: ${clash.join(\", \")} is both hand-written and a node unit — a type lives in one place (tools/units/README.md)`)\n return new Set([...legacy, ...units])\n}\n\n/**\n * `legacy` with each unit row added after it, refusing a type that is in both\n * or a unit row given twice — the record twin of `composeUnitSet`. Throws at\n * module load, so any import of the record fails.\n */\nexport function composeUnitRecord<V>(what: string, legacy: Readonly<Record<string, V>>, units: ReadonlyArray<readonly [string, V]>): Readonly<Record<string, V>> {\n const out: Record<string, V> = { ...legacy }\n for (const [type, value] of units) {\n if (Object.hasOwn(legacy, type)) throw new Error(`${what}: ${type} is both hand-written and a node unit — a type lives in one place (tools/units/README.md)`)\n if (Object.hasOwn(out, type)) throw new Error(`${what}: node unit ${type} has more than one row`)\n out[type] = value\n }\n return out\n}\n\n/** The node units of one producer kind (`contract.producer`), in generated order. */\nexport const unitProducers = (kind: \"audio\" | \"video\" | \"image\" | \"dynamic\"): string[] =>\n UNIT_CONTRACTS.filter(([, producer]) => producer === kind).map(([type]) => type)\n\n/** The node units a published app shows as `kind` (`contract.presents`). */\nexport const unitsPresenting = (kind: \"image\" | \"video\" | \"audio\" | \"text\"): string[] =>\n UNIT_PRESENTS.filter(([, presents]) => presents === kind).map(([type]) => type)\n\n/** What each node unit's JSON (look) output pips carry (`contract.jsonPips`). */\nexport const unitJsonPips = (): ReadonlyArray<readonly [string, Readonly<Record<string, \"transcript\" | \"edl\" | \"other\">>]> => UNIT_JSON_PIPS\n\n/** Each node unit's input pips that are never a prompt lane (`contract.nonPromptInputs`). */\nexport const unitNonPromptInputs = (): ReadonlyArray<readonly [string, ReadonlyArray<string>]> => UNIT_NON_PROMPT_INPUTS\n\n/** The use-case units whose review-on run ends at a Preview that holds what follows (`contract.reviewHold`). */\nexport const unitReviewHolds = (): readonly string[] => UNIT_REVIEW_HOLDS\n\n/** Each node unit's fan-out \"each\" outputs and primary pip (`contract.fanOutEach`), in generated order. */\nexport const unitFanOutEach = (): ReadonlyArray<readonly [string, { readonly each: ReadonlyArray<string>; readonly primary: string }]> => UNIT_FAN_OUT_EACH\n"]}
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var chunkM3SXUUWC_cjs = require('./chunk-M3SXUUWC.cjs');
4
+
3
5
  // src/freecut-protocol.ts
4
6
  var NODARO_LOAD_VIDEO = "NODARO_LOAD_VIDEO";
5
7
  var NODARO_LOAD_TIMELINE = "NODARO_LOAD_TIMELINE";
@@ -484,7 +486,8 @@ function videoMaskBilledSeconds(durationSec, fps) {
484
486
  function videoMaskCreditId(billedSec, provider = DEFAULT_VIDEO_MASK_PROVIDER) {
485
487
  const ids = videoMaskCreditIds(provider);
486
488
  if (typeof billedSec !== "number" || !Number.isFinite(billedSec) || billedSec <= 0) return ids[ids.length - 1];
487
- const i = VIDEO_MASK_BUCKETS_SEC.findIndex((b) => billedSec <= b);
489
+ const priced = chunkM3SXUUWC_cjs.pricedClipSeconds(billedSec);
490
+ const i = VIDEO_MASK_BUCKETS_SEC.findIndex((b) => priced <= b);
488
491
  return ids[i === -1 ? ids.length - 1 : i];
489
492
  }
490
493
  function resolveVideoMaskProvider(value) {
@@ -515,7 +518,7 @@ var VIDEO_FACE_MESH_LIMITS = {
515
518
  ZONE_MARGIN_PCT_MAX: VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MAX
516
519
  };
517
520
  var VIDEO_FACE_MESH_PARTS = ["full", "features", "mouth"];
518
- var VIDEO_FACE_MESH_RECIPE = "2026-11-02";
521
+ var VIDEO_FACE_MESH_RECIPE = "2026-11-03";
519
522
  var VIDEO_FACE_MESH_BUCKETS_SEC = [5, 10, 15, 30, 60, 120, 300];
520
523
  function videoFaceMeshCreditIds() {
521
524
  return VIDEO_FACE_MESH_BUCKETS_SEC.map((sec) => `video-face-mesh:${sec}s`);
@@ -523,7 +526,8 @@ function videoFaceMeshCreditIds() {
523
526
  function videoFaceMeshCreditId(billedSec) {
524
527
  const ids = videoFaceMeshCreditIds();
525
528
  if (typeof billedSec !== "number" || !Number.isFinite(billedSec) || billedSec <= 0) return ids[ids.length - 1];
526
- const i = VIDEO_FACE_MESH_BUCKETS_SEC.findIndex((b) => billedSec <= b);
529
+ const priced = chunkM3SXUUWC_cjs.pricedClipSeconds(billedSec);
530
+ const i = VIDEO_FACE_MESH_BUCKETS_SEC.findIndex((b) => priced <= b);
527
531
  return ids[i === -1 ? ids.length - 1 : i];
528
532
  }
529
533
 
@@ -567,7 +571,7 @@ var MASK_COMPOSITE_BOUNDS = {
567
571
  var MASK_COMPOSITE_UNIT_SEC = 5;
568
572
  function maskCompositeUnits(durationSec) {
569
573
  const sec = typeof durationSec === "number" && Number.isFinite(durationSec) && durationSec > 0 ? Math.min(durationSec, MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC) : MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC;
570
- return Math.max(1, Math.ceil(sec / MASK_COMPOSITE_UNIT_SEC - 1e-6));
574
+ return Math.ceil(chunkM3SXUUWC_cjs.pricedClipSeconds(sec) / MASK_COMPOSITE_UNIT_SEC);
571
575
  }
572
576
  var MASK_COMPOSITE_DEFAULTS = {
573
577
  invertMask: false,
@@ -667,5 +671,5 @@ exports.videoFaceMeshCreditIds = videoFaceMeshCreditIds;
667
671
  exports.videoMaskBilledSeconds = videoMaskBilledSeconds;
668
672
  exports.videoMaskCreditId = videoMaskCreditId;
669
673
  exports.videoMaskCreditIds = videoMaskCreditIds;
670
- //# sourceMappingURL=chunk-ETU6NWE2.cjs.map
671
- //# sourceMappingURL=chunk-ETU6NWE2.cjs.map
674
+ //# sourceMappingURL=chunk-QP5JLSCJ.cjs.map
675
+ //# sourceMappingURL=chunk-QP5JLSCJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/freecut-protocol.ts","../src/inpaint-region.ts","../src/lottie-slots.ts","../src/lottie-overlay-catalog.ts","../src/audio-fx-presets.ts","../src/video-mask.ts","../src/video-face-mesh.ts","../src/generate-mask.ts","../src/mask-composite.ts"],"names":["clamp01","copy","pricedClipSeconds"],"mappings":";;;;;AAMO,IAAM,iBAAA,GAAoB;AAI1B,IAAM,oBAAA,GAAuB;AAC7B,IAAM,mBAAA,GAAsB;AAC5B,IAAM,oBAAA,GAAuB;AAG7B,IAAM,aAAA,GAAgB;AACtB,IAAM,uBAAA,GAA0B;AAChC,IAAM,uBAAA,GAA0B;AAChC,IAAM,sBAAA,GAAyB;;;ACPtC,SAAS,KAAK,MAAA,EAAwC;AACpD,EAAA,IAAI,MAAA,GAAS,CAAA,GAAI,CAAA,EAAG,OAAO,KAAA;AAC3B,EAAA,IAAI,MAAA,GAAS,CAAA,GAAI,CAAA,EAAG,OAAO,MAAA;AAC3B,EAAA,OAAO,KAAA;AACT;AAEA,IAAM,OAAO,EAAE,GAAA,EAAK,SAAS,GAAA,EAAK,QAAA,EAAU,MAAM,OAAA,EAAQ;AAC1D,IAAM,OAAO,EAAE,GAAA,EAAK,QAAQ,GAAA,EAAK,QAAA,EAAU,MAAM,OAAA,EAAQ;AAQlD,SAAS,kBAAA,CAAmB,KAAe,KAAA,EAAgE;AAChH,E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O,YAAA;AACT","file":"chunk-QP5JLSCJ.cjs","sourcesContent":["// Single source of truth for the Nodaro <-> FreeCut iframe postMessage protocol.\n// Imported by app's freecut-editor-modal and Studio's ported modal so the wire\n// format cannot drift. The fork (Nodaro-ai/freecut-fork) mirrors these strings in\n// src/features/embedded/services/embedded-message-handler.ts + use-send-back.ts.\n\n// Nodaro (parent) -> FreeCut (iframe)\nexport const NODARO_LOAD_VIDEO = \"NODARO_LOAD_VIDEO\"\n// Multi-clip analog of NODARO_LOAD_VIDEO: lay N ordered urls on the timeline as\n// sequential clips (FreeCut fetches them itself). Used by Studio's production\n// \"Edit in FreeCut\" to assemble the whole cut.\nexport const NODARO_LOAD_TIMELINE = \"NODARO_LOAD_TIMELINE\"\nexport const NODARO_IMPORT_FILES = \"NODARO_IMPORT_FILES\"\nexport const NODARO_RESET_PROJECT = \"NODARO_RESET_PROJECT\"\n\n// FreeCut (iframe) -> Nodaro (parent)\nexport const FREECUT_READY = \"FREECUT_READY\"\nexport const FREECUT_EXPORT_COMPLETE = \"FREECUT_EXPORT_COMPLETE\"\nexport const FREECUT_EXPORT_PROGRESS = \"FREECUT_EXPORT_PROGRESS\" // reserved; fork emits it, v1 parents ignore it\nexport const FREECUT_REQUEST_IMPORT = \"FREECUT_REQUEST_IMPORT\"\n\nexport interface FreecutImportFile {\n readonly name: string\n readonly type: string\n readonly size: number\n readonly buffer: ArrayBuffer\n}\n\nexport interface NodaroLoadVideoPayload {\n readonly videoUrl: string\n /** Display/file name for the primary video (\"Shot 1.mp4\") — optional; absent = URL-derived name (fork default). */\n readonly videoName?: string\n readonly videoBuffer?: ArrayBuffer\n readonly projectJson?: unknown\n readonly additionalFiles?: ReadonlyArray<FreecutImportFile>\n}\n\nexport interface NodaroLoadTimelinePayload {\n // Ordered clip urls; FreeCut fetches each and lays them end-to-end on the timeline.\n readonly clips: ReadonlyArray<string>\n}\n\nexport interface FreecutExportCompletePayload {\n readonly videoBuffer: ArrayBuffer\n readonly projectJson?: unknown\n}\n\nexport interface FreecutExportProgressPayload {\n readonly percent: number\n}\n\nexport interface FreecutRequestImportPayload {\n readonly accept?: string\n readonly multiple?: boolean\n}\n","export interface PixelBox { x: number; y: number; width: number; height: number }\n\nexport interface MaskRegionDescriptor {\n /** bbox normalized to 0..1 against the image, clamped so x+width ≤ 1 and y+height ≤ 1. */\n normBbox: PixelBox\n /** Natural-language location, e.g. \"the upper-left region\" / \"the center\". */\n location: string\n /** Prompt fragment to PREPEND to the user instruction. */\n fragment: string\n}\n\nfunction band(center: number): \"low\" | \"mid\" | \"high\" {\n if (center < 1 / 3) return \"low\"\n if (center > 2 / 3) return \"high\"\n return \"mid\"\n}\n\nconst VERT = { low: \"upper\", mid: \"middle\", high: \"lower\" } as const\nconst HORZ = { low: \"left\", mid: \"center\", high: \"right\" } as const\n\n/**\n * Turn a pixel bounding box of the masked (edit) region into a normalized bbox\n * + natural-language location + a prompt fragment. Pure — no IO. This is the\n * Tier-B descriptor injected for strong instruction-following editors, and the\n * exact primitive Phase 2 (named regions) will reuse.\n */\nexport function describeMaskRegion(box: PixelBox, image: { width: number; height: number }): MaskRegionDescriptor {\n const clamp01 = (n: number) => Math.max(0, Math.min(1, n))\n const round2 = (n: number) => Math.round(n * 100) / 100\n const nx = clamp01(box.x / image.width)\n const ny = clamp01(box.y / image.height)\n const normBbox: PixelBox = {\n x: round2(nx),\n y: round2(ny),\n width: round2(Math.max(0, Math.min(1 - nx, box.width / image.width))),\n height: round2(Math.max(0, Math.min(1 - ny, box.height / image.height))),\n }\n\n const cx = (box.x + box.width / 2) / image.width\n const cy = (box.y + box.height / 2) / image.height\n const v = VERT[band(cy)]\n const h = HORZ[band(cx)]\n const location = v === \"middle\" && h === \"center\" ? \"the center\" : `the ${v}-${h} region`\n\n const fragment =\n `Apply the following change ONLY to ${location} of the image ` +\n `(normalized region x=${normBbox.x} y=${normBbox.y} w=${normBbox.width} h=${normBbox.height}), ` +\n `leaving everything else unchanged: `\n\n return { normBbox, location, fragment }\n}\n","/**\n * Lottie slot substitution — single source of truth (design §5).\n *\n * A slotted property is an object containing a `sid` key (canonically exactly\n * `{\"sid\": \"name\"}`; tolerantly also the annotation form `{a, k, sid}`). The\n * slot manifest maps sid → { p: <whatever belongs at the reference position> }.\n * Overrides map sid → raw value (what UI controls write).\n *\n * KEY CONVENTION: a slot's `p` is, by design, EXACTLY what belongs at the\n * reference position — and we substitute it VERBATIM, never auto-wrapping it in\n * an `{a:0,k:...}` envelope. At a property position (a fill color, a shape size)\n * that means `p` is a property object like `{\"a\":0,\"k\":[1,0,0,1]}`. At a RAW\n * position inside a text document — `layers[].t.d.k[0].s.t`, where lottie-web's\n * `buildFinalText` iterates string characters — `p` is a BARE string, e.g.\n * `{ \"nameText\": { \"p\": \"John Smith\" } }` substitutes the string `\"John Smith\"`\n * straight onto `s.t`. (Auto-wrapping there produced `{a:0,k:\"John Smith\"}` and\n * broke text rendering — the defect this contract fixes.)\n *\n * An override is wrapped ONLY when it lands on a property-object default: the\n * `{...p, k: override}` form preserves the default's envelope (animated/static\n * flags). On a raw default (or a missing slot) the override is substituted\n * verbatim too — so a raw text override stays a bare string.\n *\n * Substitution is renderer-agnostic: we replace every sid node ourselves and\n * never rely on lottie-web's version-dependent native slot support.\n */\n\ntype JsonRecord = Record<string, unknown>\n\nfunction isPlainObject(v: unknown): v is JsonRecord {\n return typeof v === \"object\" && v !== null && !Array.isArray(v)\n}\n\n/** True when `p` already looks like a lottie animated-property object. */\nfunction isPropertyObject(v: unknown): v is JsonRecord {\n return isPlainObject(v) && \"k\" in v\n}\n\nfunction resolveSlotNode(\n node: JsonRecord,\n slots: JsonRecord,\n overrides: JsonRecord,\n): unknown {\n const sid = node.sid as string\n const slot = slots[sid]\n const slotP = isPlainObject(slot) ? (slot as JsonRecord).p : undefined\n const override = overrides[sid]\n\n if (override !== undefined) {\n // Wrap into the default's property-object envelope when the default IS one\n // (preserves animated/static flags); otherwise substitute the raw override\n // verbatim — a raw text override must stay a bare string at `s.t`.\n if (isPropertyObject(slotP)) return { ...slotP, k: structuredClone(override) }\n return structuredClone(override)\n }\n if (slotP !== undefined) {\n // `p` is by convention exactly what belongs at the reference position —\n // substitute it verbatim, never auto-wrap (a bare string stays a string).\n return structuredClone(slotP)\n }\n // No slot, no override — leave the node as-is (validator rule #6 should\n // prevent this; belt-and-braces for hand-fed documents).\n return node\n}\n\nfunction walk(value: unknown, slots: JsonRecord, overrides: JsonRecord): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => walk(item, slots, overrides))\n }\n if (isPlainObject(value)) {\n if (typeof value.sid === \"string\") {\n const resolved = resolveSlotNode(value, slots, overrides)\n // The original node comes back only in the missing-slot case; replacements\n // are leaf property objects and need no further walking.\n if (resolved === value) {\n const copy: JsonRecord = {}\n for (const [k, v] of Object.entries(value)) copy[k] = walk(v, slots, overrides)\n return copy\n }\n return resolved\n }\n const copy: JsonRecord = {}\n for (const [k, v] of Object.entries(value)) copy[k] = walk(v, slots, overrides)\n return copy\n }\n return value\n}\n\n/** Pure: returns a new document; never mutates inputs. */\nexport function applySlots(\n lottie: JsonRecord,\n slots: JsonRecord | undefined,\n overrides: JsonRecord | undefined,\n): JsonRecord {\n return walk(lottie, slots ?? {}, overrides ?? {}) as JsonRecord\n}\n\n// ── Playback normalization ───────────────────────────────────────────────────\n//\n// lottie-web computes a layer's local time as `frame - layer.st` and gates the\n// layer on `local >= ip && local < op`. A layer missing `st` yields NaN, fails\n// the gate, and stays `display:none` forever — the document \"loads\" (DOMLoaded\n// fires) but every frame renders blank (prod incident 2026-06-12: all authored\n// lottie renders came out as empty frames in headless Chrome). `st` and `sr`\n// are spec-optional with defaults, so documents routinely omit them; complete\n// them at the playback boundary so any source — authored plan, baked export,\n// catalog asset, external URL — renders. Mutates `doc` in place and returns it\n// (callers pass freshly fetched or freshly copied documents).\n\nexport function normalizeLottieLayers<T>(doc: T): T {\n if (!isPlainObject(doc)) return doc\n const fix = (layers: unknown): void => {\n if (!Array.isArray(layers)) return\n for (const layer of layers) {\n if (!isPlainObject(layer)) continue\n if (typeof layer.st !== \"number\") layer.st = 0\n if (typeof layer.sr !== \"number\") layer.sr = 1\n }\n }\n fix((doc as JsonRecord).layers)\n const assets = (doc as JsonRecord).assets\n if (Array.isArray(assets)) {\n for (const asset of assets) {\n if (isPlainObject(asset)) fix(asset.layers)\n }\n }\n return doc\n}\n\n// ── Slot control descriptors (Phase 2 — UI mapping) ──────────────────────────\n//\n// A slot manifest entry is `{ p: <whatever belongs at the reference position> }`\n// (Amendment 1). `describeSlotControl` unwraps that envelope to the editable raw\n// value and classifies it into the control kind the config panel should render.\n// `p` is either a property object `{a, k}` (colors, sizes, scalars) whose `k`\n// holds the value, or a bare raw value (text strings live unwrapped at `s.t`).\n\nexport type SlotControlKind = \"color\" | \"text\" | \"number\" | \"point\"\nexport interface SlotControlDescriptor {\n kind: SlotControlKind\n value: unknown\n}\n\n/**\n * Unwraps a slot entry to its editable raw value and classifies it:\n * {p:{a:0,k:[1,0,0,1]}} → { kind:\"color\", value:[1,0,0,1] }\n * {p:\"John\"} → { kind:\"text\", value:\"John\" }\n * {p:{a:0,k:42}} → { kind:\"number\", value:42 }\n * {p:{a:0,k:[10,20]}} → { kind:\"point\", value:[10,20] }\n * Animated property objects (`a:1`) and anything that doesn't map to a known\n * control kind return null (no editable control).\n */\nexport function describeSlotControl(slot: unknown): SlotControlDescriptor | null {\n if (!isPlainObject(slot)) return null\n const p = (slot as JsonRecord).p\n let value: unknown = p\n if (isPropertyObject(p)) {\n if ((p as JsonRecord).a === 1) return null\n value = (p as JsonRecord).k\n }\n if (typeof value === \"string\") return { kind: \"text\", value }\n if (typeof value === \"number\") return { kind: \"number\", value }\n if (\n Array.isArray(value) &&\n value.length === 4 &&\n value.every((n) => typeof n === \"number\" && n >= 0 && n <= 1)\n ) {\n return { kind: \"color\", value }\n }\n if (Array.isArray(value) && value.length === 2 && value.every((n) => typeof n === \"number\")) {\n return { kind: \"point\", value }\n }\n return null\n}\n\nfunction clamp01(n: number): number {\n if (Number.isNaN(n)) return 0\n return n < 0 ? 0 : n > 1 ? 1 : n\n}\n\nfunction toHexByte(component: number): string {\n return Math.round(clamp01(component) * 255)\n .toString(16)\n .padStart(2, \"0\")\n}\n\n/**\n * RGBA array (components 0..1) → hex string. The alpha component is omitted\n * when it is exactly 1 (`[1,0,0,1]` → `\"#ff0000\"`); otherwise an 8-digit hex is\n * emitted (`[0,1,0,0.5]` → `\"#00ff0080\"`). Output is always lowercase.\n */\nexport function rgbaArrayToHex(rgba: number[]): string {\n const [r = 0, g = 0, b = 0, a = 1] = rgba\n const base = `#${toHexByte(r)}${toHexByte(g)}${toHexByte(b)}`\n return a >= 1 ? base : `${base}${toHexByte(a)}`\n}\n\n/**\n * Hex string → RGBA array (components 0..1). Accepts `#rgb`, `#rrggbb`, and\n * `#rrggbbaa`; alpha defaults to 1 when absent. Leading `#` is optional.\n */\nexport function hexToRgbaArray(hex: string): number[] {\n let h = hex.trim().replace(/^#/, \"\")\n if (h.length === 3) {\n h = h\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n }\n const r = parseInt(h.slice(0, 2), 16) / 255\n const g = parseInt(h.slice(2, 4), 16) / 255\n const b = parseInt(h.slice(4, 6), 16) / 255\n const a = h.length >= 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1\n return [r, g, b, a]\n}\n\n/** Manifest sids in insertion order (drives the slot-control list ordering). */\nexport function listSlotSids(slots: Record<string, unknown>): string[] {\n return Object.keys(slots ?? {})\n}\n\n// ── Slot → app-field derivation (Phase 3 — single source of truth) ────────────\n//\n// `deriveLottieSlotFields` turns a lottie-graphic plan's slot manifest into\n// ExposableField-shaped descriptors. ONE function feeds three surfaces: the\n// editor's publish picker, the published-app runtime, and the backend MCP\n// schema extractor — so the set of slots an app exposes can never drift between\n// them. It deliberately mirrors `describeSlotControl`'s classification (the\n// editor's live slot controls use the same source of truth).\n\n/** Prefix for the synthetic field key of a derived slot field: `slot:<sid>`. */\nexport const LOTTIE_SLOT_FIELD_PREFIX = \"slot:\"\n\n/** \"primaryColor\" → \"Primary Color\"; \"bar_size\" → \"Bar Size\". */\nexport function humanizeSlotSid(sid: string): string {\n return sid\n .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .replace(/[_-]+/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim()\n .replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\n/** ExposableField-shaped descriptor derived from one slot. */\nexport interface LottieSlotField {\n /** Synthetic field key: `slot:<sid>`. */\n key: string\n /** Humanized sid (camelCase / snake_case → Title Case). */\n label: string\n /** Maps onto the `ExposableField.type` members used in apps. */\n type: \"color\" | \"text\" | \"slider\"\n min?: number\n max?: number\n step?: number\n /** Hex string for color; raw value for text/number. */\n defaultValue?: unknown\n}\n\n/**\n * Derive ExposableField-shaped descriptors from a motion-graphics node's plan.\n *\n * Returns [] unless `motionPlan.planType === \"lottie-graphic\"` and `slots` is a\n * non-empty object — the elements engine and absent plans expose nothing.\n *\n * Per slot, via `describeSlotControl`:\n * - color → `{ type: \"color\", defaultValue: rgbaArrayToHex(value) }`\n * - text → `{ type: \"text\", defaultValue: value }`\n * - number → `{ type: \"slider\", min, max, step, defaultValue: value }`\n * (0–1 values → 0..1 step 0.01; larger → 0..ceil(value*2) step 1)\n * - point / null → SKIPPED. Point-kind slots are intentionally not exposed in\n * apps (no paired-number card; positions are rarely end-user-meaningful).\n */\nexport function deriveLottieSlotFields(\n motionPlan: Record<string, unknown> | undefined,\n): LottieSlotField[] {\n if (!motionPlan || motionPlan.planType !== \"lottie-graphic\") return []\n const slots = motionPlan.slots\n if (!isPlainObject(slots)) return []\n\n const fields: LottieSlotField[] = []\n for (const [sid, slot] of Object.entries(slots)) {\n const control = describeSlotControl(slot)\n if (!control) continue\n const base = { key: `${LOTTIE_SLOT_FIELD_PREFIX}${sid}`, label: humanizeSlotSid(sid) }\n\n if (control.kind === \"color\") {\n fields.push({\n ...base,\n type: \"color\",\n defaultValue: rgbaArrayToHex(control.value as number[]),\n })\n } else if (control.kind === \"text\") {\n fields.push({ ...base, type: \"text\", defaultValue: control.value })\n } else if (control.kind === \"number\") {\n const value = Number(control.value)\n const isUnit = value <= 1\n fields.push({\n ...base,\n type: \"slider\",\n min: 0,\n max: isUnit ? 1 : Math.ceil(value * 2) || 100,\n step: isUnit ? 0.01 : 1,\n defaultValue: control.value,\n })\n }\n // point / unrecognized kinds are intentionally not exposed.\n }\n return fields\n}\n","/**\n * Built-in Lottie Overlay catalog — single source of truth.\n *\n * The Lottie Overlay node ships a curated set of 12 animations the overlay LLM\n * can pick from. They were originally served from the third-party lottie.host\n * CDN, which went dead (origin returns 403) and broke every catalog-based\n * overlay render in production. The replacements were authored with our own\n * Lottie engine, baked (slots resolved, no `sid` refs), and are now self-hosted\n * on the Nodaro CDN at `https://cdn.nodaro.ai/lottie-catalog/<slug>.json`.\n *\n * This module is the ONE place the catalog lives:\n * - `LOTTIE_OVERLAY_CATALOG` feeds the overlay system prompt (the LLM's menu).\n * - `LEGACY_LOTTIE_HOST_REMAP` + `resolveLottieOverlaySrc` heal saved overlay\n * plans at render time — a plan authored before the cut-over still points at\n * a dead lottie.host URL, so the renderer rewrites it to its self-hosted\n * replacement before fetching.\n */\n\nexport interface LottieOverlayCatalogEntry {\n /** Stable system key — the R2 object is `lottie-catalog/<slug>.json`. */\n readonly slug: string\n /** Display name — mirrors the original prompt's catalog labels. */\n readonly name: string\n /** Catalog group (drives the grouped layout in the system prompt). */\n readonly group:\n | \"Celebration\"\n | \"Social / Reactions\"\n | \"UI / Indicators\"\n | \"Ambient / Decorative\"\n /** One placement-intent line for the overlay LLM. */\n readonly description: string\n /** Public CDN URL: `https://cdn.nodaro.ai/lottie-catalog/<slug>.json`. */\n readonly url: string\n /** Whether the animation is continuous (loop) or a one-shot effect. */\n readonly loop: boolean\n}\n\nconst CDN_BASE = \"https://cdn.nodaro.ai/lottie-catalog\"\n\nexport const LOTTIE_OVERLAY_CATALOG: readonly LottieOverlayCatalogEntry[] = [\n // ── Celebration ────────────────────────────────────────────────────────────\n {\n slug: \"confetti-burst\",\n name: \"Confetti burst\",\n group: \"Celebration\",\n description: \"Multicolor confetti shower — large coverage at a celebratory peak; one-shot.\",\n url: `${CDN_BASE}/confetti-burst.json`,\n loop: false,\n },\n {\n slug: \"fireworks\",\n name: \"Fireworks\",\n group: \"Celebration\",\n description: \"Bursting fireworks against the sky — big-moment payoff over the upper frame; one-shot.\",\n url: `${CDN_BASE}/fireworks.json`,\n loop: false,\n },\n {\n slug: \"party-popper\",\n name: \"Party popper\",\n group: \"Celebration\",\n description: \"Party popper streamers from a corner — a quick celebratory accent; one-shot.\",\n url: `${CDN_BASE}/party-popper.json`,\n loop: false,\n },\n {\n slug: \"stars-sparkle\",\n name: \"Stars sparkle\",\n group: \"Celebration\",\n description: \"Twinkling stars/sparkles — small accent over a highlight; loops.\",\n url: `${CDN_BASE}/stars-sparkle.json`,\n loop: true,\n },\n // ── Social / Reactions ──────────────────────────────────────────────────────\n {\n slug: \"heart-pulse\",\n name: \"Heart pulse\",\n group: \"Social / Reactions\",\n description: \"Pulsing heart reaction — medium size at a corner or edge; loops.\",\n url: `${CDN_BASE}/heart-pulse.json`,\n loop: true,\n },\n {\n slug: \"thumbs-up\",\n name: \"Thumbs up\",\n group: \"Social / Reactions\",\n description: \"Thumbs-up approval reaction — medium size, pops in once; one-shot.\",\n url: `${CDN_BASE}/thumbs-up.json`,\n loop: false,\n },\n {\n slug: \"fire-flame\",\n name: \"Fire emoji\",\n group: \"Social / Reactions\",\n description: \"Flickering flame reaction (“this is fire”) — small size at an edge; loops.\",\n url: `${CDN_BASE}/fire-flame.json`,\n loop: true,\n },\n // ── UI / Indicators ─────────────────────────────────────────────────────────\n {\n slug: \"loading-spinner\",\n name: \"Loading spinner\",\n group: \"UI / Indicators\",\n description: \"Circular loading spinner — small, centered, signals progress; loops.\",\n url: `${CDN_BASE}/loading-spinner.json`,\n loop: true,\n },\n {\n slug: \"checkmark-success\",\n name: \"Checkmark success\",\n group: \"UI / Indicators\",\n description: \"Animated success checkmark — small, marks a completed/correct moment; one-shot.\",\n url: `${CDN_BASE}/checkmark-success.json`,\n loop: false,\n },\n {\n slug: \"arrow-pointer\",\n name: \"Arrow pointer\",\n group: \"UI / Indicators\",\n description: \"Animated arrow drawing attention to a spot — small, timed to a key area; loops.\",\n url: `${CDN_BASE}/arrow-pointer.json`,\n loop: true,\n },\n // ── Ambient / Decorative ────────────────────────────────────────────────────\n {\n slug: \"floating-particles\",\n name: \"Floating particles\",\n group: \"Ambient / Decorative\",\n description: \"Soft drifting particles — large coverage, low opacity, full-duration ambience; loops.\",\n url: `${CDN_BASE}/floating-particles.json`,\n loop: true,\n },\n {\n slug: \"glowing-ring\",\n name: \"Glowing ring\",\n group: \"Ambient / Decorative\",\n description: \"Pulsing glowing ring/halo — decorative accent around a focal point; loops.\",\n url: `${CDN_BASE}/glowing-ring.json`,\n loop: true,\n },\n] as const\n\n/**\n * Dead lottie.host URLs (origin returns 403) → their replacement catalog URLs.\n * Heals saved plans at render time. The keys are copied EXACTLY from the\n * original `lottie-overlay-system.ts` prompt — they are the literal `src`\n * strings the overlay LLM emitted before the cut-over.\n */\nexport const LEGACY_LOTTIE_HOST_REMAP: Readonly<Record<string, string>> = {\n // Celebration\n \"https://lottie.host/d7313e87-e4c9-4e0d-8e03-c3a59e87d8fb/TjHnrCGBjI.json\": `${CDN_BASE}/confetti-burst.json`,\n \"https://lottie.host/d5cad0dd-4e93-4bbe-b023-e94a04bc1581/JHEZMrqfMk.json\": `${CDN_BASE}/fireworks.json`,\n \"https://lottie.host/0060c9cd-75da-42d5-af7c-1a191fa8a8fd/c1xHMRnGTO.json\": `${CDN_BASE}/party-popper.json`,\n \"https://lottie.host/c04a2758-a1d9-40a9-b81f-6f3e4e13a88c/xKCYDU2w0O.json\": `${CDN_BASE}/stars-sparkle.json`,\n // Social / Reactions\n \"https://lottie.host/44c9e8d1-856c-4641-bfbe-d0e2a5c9850e/GIBsMSIkkq.json\": `${CDN_BASE}/heart-pulse.json`,\n \"https://lottie.host/9a611d56-1f35-4f51-9fa4-6a4daa6b8714/EH71MjHKPD.json\": `${CDN_BASE}/thumbs-up.json`,\n \"https://lottie.host/66db1de9-c1a8-4d0b-bb03-47a8932a8a86/q5JBGQ8fxu.json\": `${CDN_BASE}/fire-flame.json`,\n // UI / Indicators\n \"https://lottie.host/b03d748c-3b4a-4c07-a10c-e9eb3c967349/eMVAVEnb5x.json\": `${CDN_BASE}/loading-spinner.json`,\n \"https://lottie.host/3ffaab4a-58b0-4a72-9f1c-5eaa484d8c88/g27v7IPaJc.json\": `${CDN_BASE}/checkmark-success.json`,\n \"https://lottie.host/6f831c6e-693a-4d1d-90a0-d7e2b3f00e68/PFj0MwSPrj.json\": `${CDN_BASE}/arrow-pointer.json`,\n // Ambient / Decorative\n \"https://lottie.host/9c8e1aef-f8e5-4ce8-bc80-1647ffb0724d/mNDClfKJVB.json\": `${CDN_BASE}/floating-particles.json`,\n \"https://lottie.host/b5d3e7e7-40bc-44fa-9a53-78b98ad66e80/pQVdNsVDmQ.json\": `${CDN_BASE}/glowing-ring.json`,\n}\n\n/**\n * Resolve an overlay `src` through the legacy remap: a dead lottie.host URL is\n * rewritten to its self-hosted replacement; everything else (already-migrated\n * catalog URLs, user-provided assets) passes through unchanged.\n */\nexport function resolveLottieOverlaySrc(src: string): string {\n return LEGACY_LOTTIE_HOST_REMAP[src] ?? src\n}\n","/**\n * Audio FX node — preset id union (single source of truth).\n *\n * Shared so the backend Zod route enum, the frontend config dropdown, and the\n * `AudioFxData` node type can't drift. The per-preset FFmpeg filter chains\n * (IR DUR/SHAPE, delay/EQ knobs) live in the backend provider's PRESET_CHAINS\n * map — this file only fixes the id set + their human labels.\n *\n * Reverb presets are named by ON-SCREEN SCENARIO (where the voice is happening\n * in the scene) rather than abstract size, so a creator picking \"Church\" or\n * \"Car\" gets a believable space for that shot.\n */\n\nexport const AUDIO_FX_PRESETS = [\n // — reverb / spaces (afir + inline-synth IR), ordered small → large —\n \"room\", // ordinary indoor room — bedroom / office dialogue\n \"bathroom\", // small, bright, tiled — hard early reflections\n \"car\", // tight, very damped cabin\n \"hall\", // lobby / corridor / large room\n \"concert-hall\", // big, lush, musical tail\n \"church\", // cathedral — long, dark, reverberant\n \"cave\", // dark, diffuse, long\n \"arena\", // stadium / PA — huge, bright tail\n \"outdoor\", // open air — almost dry, faint early reflections\n // — character / non-reverb —\n \"telephone\", // band-limited phone line\n \"megaphone\", // PA / bullhorn — mid-forward + light grit\n \"echo\", // discrete echo / slap-back\n \"custom\", // manual: reverb wet · delay · EQ\n] as const\n\nexport type AudioFxPreset = (typeof AUDIO_FX_PRESETS)[number]\n\nexport const AUDIO_FX_PRESET_SET: ReadonlySet<string> = new Set(AUDIO_FX_PRESETS)\n\n/** Display labels for the config dropdown. */\nexport const AUDIO_FX_PRESET_LABELS: Record<AudioFxPreset, string> = {\n room: \"Room (indoor)\",\n bathroom: \"Bathroom\",\n car: \"Car interior\",\n hall: \"Hall / Lobby\",\n \"concert-hall\": \"Concert Hall\",\n church: \"Church\",\n cave: \"Cave\",\n arena: \"Arena / Stadium\",\n outdoor: \"Outdoor (open air)\",\n telephone: \"Telephone\",\n megaphone: \"Megaphone / PA\",\n echo: \"Echo / Slap-back\",\n custom: \"Custom\",\n}\n\n/** Presets that apply convolution reverb (afir + inline-synth IR). */\nexport const AUDIO_FX_REVERB_PRESETS: ReadonlySet<AudioFxPreset> = new Set<AudioFxPreset>([\n \"room\",\n \"bathroom\",\n \"car\",\n \"hall\",\n \"concert-hall\",\n \"church\",\n \"cave\",\n \"arena\",\n \"outdoor\",\n])\n","/**\n * Video Mask — text-prompted video segmentation (SAM 3.1 / SAM 3). The wire contract of\n * the `video-mask` node, `POST /v1/video-mask`, the `video_mask` MCP verb,\n * `client.media.videoMask` and `nodaro media video-mask`, defined ONCE:\n * - every bound the route schema, the node panel and the MCP verb read;\n * - `videoMaskBilledSeconds`: the length a run is priced at — the clip's\n * length at the 30 fps basis, so a 60 fps clip is priced at twice its\n * length (the segmentation works per FRAME);\n * - `videoMaskCreditId`: which price row (`model_pricing`) that length is\n * charged from. The credit amounts live in the rows, never here.\n *\n * Worked examples (repeated in docs/nodes/ai-video/video-mask.md):\n * 4 s at 30 fps → `sam-3.1-video:5s`, 5.005 s at 29.97 fps → `sam-3.1-video:5s`, 12 s at 24 fps → `sam-3.1-video:15s`,\n * 10 s at 60 fps (priced as 20 s) → `sam-3.1-video:30s`, 45 s at 30 fps → `sam-3.1-video:60s`,\n * 100 s at 30 fps → `sam-3.1-video:120s`, 4 min at 30 fps on SAM 3 → `sam-3-video:240s`.\n *\n * Wire contract only — no I/O.\n */\nimport { pricedClipSeconds } from \"./priced-clip-seconds.js\"\n\n/** Segmentation models a Video Mask run can use. SAM 3.1 (the default)\n * tracks several objects in one pass and runs faster; SAM 3 costs half. */\nexport const VIDEO_MASK_PROVIDERS = [\"sam-3.1\", \"sam-3\"] as const\nexport type VideoMaskProvider = (typeof VIDEO_MASK_PROVIDERS)[number]\nexport const DEFAULT_VIDEO_MASK_PROVIDER: VideoMaskProvider = \"sam-3.1\"\n\n/**\n * `zone`: keep only the subjects whose bounding-box CENTRE lies inside an\n * inner rectangle, given as margins in % of the frame (each\n * `VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MIN`–`ZONE_MARGIN_PCT_MAX`). All zero, or\n * no zone, = off.\n */\nexport interface VideoMaskZone {\n readonly leftPct: number\n readonly rightPct: number\n readonly topPct: number\n readonly bottomPct: number\n}\n\n/** A new Video Mask node's settings — spread into its node definition. */\nexport const VIDEO_MASK_DEFAULTS = {\n threshold: 0.5,\n provider: \"sam-3.1\" as VideoMaskProvider,\n /** Off: the mask is the model's, frame for frame (see `HOLD_EMPTY_BELOW_FRACTION`). */\n holdLastMask: false,\n /** 0 = off: every region the model finds is kept (see `MIN_SUBJECT_HEIGHT_PCT_*`). */\n minSubjectHeightPct: 0,\n /** 0 = off: no ceiling on a region's height (see `MAX_SUBJECT_HEIGHT_PCT_*`). */\n maxSubjectHeightPct: 0,\n /** Off: subjects anywhere in the frame are kept (see `ZONE_MARGIN_PCT_*`). */\n zone: null as VideoMaskZone | null,\n /**\n * Off: one pass over the whole clip. On: the clip's scene cuts are found\n * first and each shot is segmented on its own — the model starts afresh\n * after every cut (finding the new shot's subjects), and `holdLastMask`\n * never carries a mask across a cut. A clip with no cut (a flash is\n * usually not one) is one shot: the same mask, fitted to the clip's exact\n * frame count.\n */\n perShot: false,\n /**\n * 0 = off: a new detection only where a request starts anyway (the clip's\n * start, every 1,800 frames, and every cut with `perShot`). Above 0: the\n * model is also sent a new request every this many seconds of footage, so a\n * subject that first appears mid-shot is found within that time (see\n * `REDETECT_EVERY_SEC_*`). These boundaries are not cuts: `holdLastMask`\n * keeps holding across them.\n */\n redetectEverySec: 0,\n} as const\n\nexport const VIDEO_MASK_LIMITS = {\n /** The longest input clip a run accepts, in seconds of PRICED length (see `videoMaskBilledSeconds`). */\n MAX_BILLED_SEC: 300,\n /** Frame rate the price rows assume. A faster clip is priced proportionally longer. */\n FPS_BASIS: 30,\n /** Subject description length cap. */\n PROMPT_MAX_LENGTH: 500,\n /** Detection confidence bounds (the model's own range, narrowed to useful values). */\n THRESHOLD_MIN: 0.05,\n THRESHOLD_MAX: 0.95,\n THRESHOLD_STEP: 0.05,\n /** Default detection confidence. Lower finds more (and less precise) regions. */\n THRESHOLD_DEFAULT: VIDEO_MASK_DEFAULTS.threshold,\n /**\n * `holdLastMask`: a frame whose mask covers less than this fraction of the\n * picture (0.002 % — about 41 px at 1080p: a stray speck, never a subject) counts as empty — the subject lost (hidden behind a\n * hand, turned away) — and shows the most recent non-empty frame's mask\n * instead. Frames before the first detection stay as they are.\n */\n HOLD_EMPTY_BELOW_FRACTION: 0.00002,\n /**\n * `holdLastMask`: the longest a mask is held, in seconds of frames (at the\n * clip's rate). The hold is for a subject hidden for a moment; a run of\n * empty frames longer than this shows the held mask for its first second\n * and then nothing, until the model finds the subject again — a mask held\n * on for longer sits where the subject no longer is.\n */\n HOLD_MAX_SEC: 1,\n /**\n * `minSubjectHeightPct`: drop every connected white region (8-connected)\n * whose bounding box is shorter than this % of the frame height — extras'\n * small faces behind the main subject. 0 = off. Applied before\n * `holdLastMask`, so a frame left with only small regions counts as empty\n * and is held from the last frame with a big subject.\n */\n MIN_SUBJECT_HEIGHT_PCT_MIN: 0,\n MIN_SUBJECT_HEIGHT_PCT_MAX: 100,\n /**\n * `maxSubjectHeightPct`, the mirror: drop every region whose bounding box is\n * TALLER than this % of the frame height (keep only the small subjects — a\n * paste-back mask of the background faces). 0 = off. With both set, a\n * region is kept when min ≤ height ≤ max (min > max is refused). Same pass,\n * same order (before `holdLastMask`).\n */\n MAX_SUBJECT_HEIGHT_PCT_MIN: 0,\n MAX_SUBJECT_HEIGHT_PCT_MAX: 100,\n /**\n * `zone` margins (left / right / top / bottom, % of the frame width or\n * height): drop every connected region whose bounding-box centre lies\n * outside `[w·left/100, w·(1−right/100)] × [h·top/100, h·(1−bottom/100)]`\n * — the faces at the edges of the picture. At most 49 % a side, so the\n * inner rectangle is never empty. Applied after the size cut and before\n * `holdLastMask`, so a frame left with nothing inside counts as empty.\n */\n ZONE_MARGIN_PCT_MIN: 0,\n ZONE_MARGIN_PCT_MAX: 49,\n /**\n * `redetectEverySec`: 0 (off) or `REDETECT_EVERY_SEC_MIN`–`MAX` seconds. The\n * model picks up its subjects near the start of each request; a face that\n * turns to the camera, or a person who walks in, partway through a request is\n * never masked. On, the clip (each shot, with `perShot`) is cut into requests\n * of at most this many seconds of frames — counted from the shot's start, a\n * last piece shorter than `VIDEO_MASK_MIN_SHOT_FRAMES` joining the one before\n * — so the subjects are detected again at every such boundary. Each request\n * adds wall time (they run three at a time); the price follows the clip's\n * length and does not change.\n */\n REDETECT_EVERY_SEC_MIN: 1,\n REDETECT_EVERY_SEC_MAX: 10,\n /** The panel's step (the API takes any value in range). */\n REDETECT_EVERY_SEC_STEP: 1,\n} as const\n\n/**\n * The version of what a Video Mask run's mask looks like for a given clip and\n * settings: every finished `video-mask` job reports it as `output_data.recipe`.\n * A mask stored ahead of time and reused (a trend's approved face mask) is\n * held to it, and reads as out of date once it changes.\n *\n * BUMP IT (to the date of the change) whenever the algorithm changes the mask\n * a run produces from the same clip and settings: the cut rule (`perShot`),\n * the hold (`holdLastMask`, `HOLD_*`), the size and zone filters, the\n * rendering. Never for a change that leaves every mask the same (pricing,\n * limits on what is accepted, messages). `\"2026-10-25\"`: the lone-spike cut\n * rule and the 1 s hold cap.\n */\nexport const VIDEO_MASK_RECIPE = \"2026-10-25\"\n\nconst VIDEO_MASK_BUCKETS_SEC = [5, 10, 15, 30, 60, 90, 120, 180, 240, 300] as const\n\n/** Every price row a provider can be charged from, smallest first. */\nexport function videoMaskCreditIds(provider: VideoMaskProvider = DEFAULT_VIDEO_MASK_PROVIDER): string[] {\n return VIDEO_MASK_BUCKETS_SEC.map((sec) => `${provider}-video:${sec}s`)\n}\n\n/**\n * The length a clip is priced at: its duration at the 30 fps basis. A clip\n * at or under 30 fps is priced at its own length; a 60 fps clip at twice it.\n * An unknown frame rate counts as the basis. The cap reads this figure; the\n * price row reads it through `pricedClipSeconds`.\n */\nexport function videoMaskBilledSeconds(durationSec: number, fps?: number | null): number {\n const rate = typeof fps === \"number\" && Number.isFinite(fps) && fps > 0 ? fps : VIDEO_MASK_LIMITS.FPS_BASIS\n return durationSec * Math.max(1, rate / VIDEO_MASK_LIMITS.FPS_BASIS)\n}\n\n/**\n * The price row for a clip priced at `billedSec` seconds: the smallest that\n * holds it, after `pricedClipSeconds` (up to 0.05 s past a row's length stays in\n * that row). An unknown or non-positive length prices the LONGEST row (a clip\n * the route could not measure is refused, so this is only the pre-run quote for\n * a clip whose length is not known yet); anything past the cap prices the last\n * row.\n */\nexport function videoMaskCreditId(\n billedSec: number | null | undefined,\n provider: VideoMaskProvider = DEFAULT_VIDEO_MASK_PROVIDER,\n): string {\n const ids = videoMaskCreditIds(provider)\n if (typeof billedSec !== \"number\" || !Number.isFinite(billedSec) || billedSec <= 0) return ids[ids.length - 1]!\n const priced = pricedClipSeconds(billedSec)\n const i = VIDEO_MASK_BUCKETS_SEC.findIndex((b) => priced <= b)\n return ids[i === -1 ? ids.length - 1 : i]!\n}\n\n/** Narrow an arbitrary value to a known provider, falling back to the default. */\nexport function resolveVideoMaskProvider(value: unknown): VideoMaskProvider {\n return (VIDEO_MASK_PROVIDERS as readonly string[]).includes(value as string)\n ? (value as VideoMaskProvider)\n : DEFAULT_VIDEO_MASK_PROVIDER\n}\n\n/**\n * A zone as the region filter reads it: each margin a finite number clamped\n * to `ZONE_MARGIN_PCT_MIN`–`ZONE_MARGIN_PCT_MAX` (anything else is 0), and\n * null when there is no zone or every margin is 0 (off). The one reading\n * shared by the worker, a workflow run's payload and the node's own run.\n */\nexport function resolveVideoMaskZone(value: unknown): VideoMaskZone | null {\n if (!value || typeof value !== \"object\") return null\n const v = value as Record<string, unknown>\n const margin = (x: unknown) =>\n typeof x === \"number\" && Number.isFinite(x)\n ? Math.min(VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MAX, Math.max(VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MIN, x))\n : 0\n const zone = { leftPct: margin(v.leftPct), rightPct: margin(v.rightPct), topPct: margin(v.topPct), bottomPct: margin(v.bottomPct) }\n return zone.leftPct > 0 || zone.rightPct > 0 || zone.topPct > 0 || zone.bottomPct > 0 ? zone : null\n}\n\n/**\n * `redetectEverySec` as a run reads it: a finite number above 0 clamped to\n * `REDETECT_EVERY_SEC_MIN`–`MAX` (a value between 0 and the minimum snaps up\n * to it — it asked for re-detection); anything else (absent, 0, negative,\n * not a number) is 0 = off. The one reading shared by the worker, a workflow\n * run's payload, the node's own run and its panel (the route refuses a value\n * out of range instead).\n */\nexport function resolveVideoMaskRedetectSec(value: unknown): number {\n if (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0) return 0\n return Math.min(VIDEO_MASK_LIMITS.REDETECT_EVERY_SEC_MAX, Math.max(VIDEO_MASK_LIMITS.REDETECT_EVERY_SEC_MIN, value))\n}\n\n/** `POST /v1/video-mask` request body. */\nexport interface VideoMaskRequest {\n /** The clip to segment. */\n readonly videoUrl: string\n /** What to track: a short noun phrase; separate several with commas. */\n readonly prompt: string\n /** Detection confidence, `VIDEO_MASK_LIMITS.THRESHOLD_MIN`–`THRESHOLD_MAX` (default 0.5). */\n readonly threshold?: number\n readonly provider?: VideoMaskProvider\n /** Hold the last mask where the subject is lost (default false): an empty frame\n * after the first detection repeats the most recent non-empty one. */\n readonly holdLastMask?: boolean\n /** Ignore subjects smaller than this % of the frame height, 0–100 (default 0 = off):\n * connected regions whose bounding box is shorter are dropped from every frame. */\n readonly minSubjectHeightPct?: number\n /** Ignore subjects larger than this % of the frame height, 0–100 (default 0 = off):\n * connected regions whose bounding box is taller are dropped from every frame. */\n readonly maxSubjectHeightPct?: number\n /** Keep only the subjects whose bounding-box centre is inside these margins, each\n * 0–49 % of the frame (a margin left out is 0). null / omitted / all 0 = off. */\n readonly zone?: Partial<VideoMaskZone> | null\n /** Segment each shot on its own (default false): the clip's scene cuts are found\n * first and the subjects are detected again in every shot; `holdLastMask` never\n * carries a mask across a cut. The output then carries `shots`. */\n readonly perShot?: boolean\n /** Detect the subjects again every this many seconds (0 = off, the default, or\n * `VIDEO_MASK_LIMITS.REDETECT_EVERY_SEC_MIN`–`MAX`): the clip — each shot, with\n * `perShot` — is sent to the model in pieces of at most that length, so a subject\n * that first appears mid-shot is masked from the next boundary on. Not a cut:\n * `holdLastMask` holds across these boundaries. Slower (more requests); same price. */\n readonly redetectEverySec?: number\n}\n","/**\n * Video Face Mesh (`POST /v1/video-face-mesh`, job type `video-face-mesh`):\n * thin GRAY face lines — a wireframe, and darker eye and lip outlines, each a\n * tone of the picture under it — drawn on the faces of a clip, frame for\n * frame. An internal step of Nodaro Motion's face masking: the lines go on\n * the masked (or depth) clip so the video model still sees where the mouth\n * and the eyes are. A request may draw only the eye and lip outlines, or\n * only the lip outline (`parts`).\n *\n * Priced by the clip's length at the 30 fps basis Video Mask uses\n * (`videoMaskBilledSeconds`), one row per length bucket.\n */\nimport { pricedClipSeconds } from \"./priced-clip-seconds.js\"\nimport { VIDEO_MASK_LIMITS, type VideoMaskZone } from \"./video-mask.js\"\nimport type { VideoDepthColormap } from \"./video-depth.js\"\n\n/** The route, as the Cast Swap engine calls it. */\nexport const VIDEO_FACE_MESH_PATH = \"/v1/video-face-mesh\"\n\nexport const VIDEO_FACE_MESH_LIMITS = {\n /** The longest clip a run accepts, in seconds of PRICED length (the 30 fps basis): Video Mask's own cap. */\n MAX_BILLED_SEC: VIDEO_MASK_LIMITS.MAX_BILLED_SEC,\n /** `minFaceHeightPct` / `maxFaceHeightPct` bounds (0 = off). */\n FACE_HEIGHT_PCT_MIN: 0,\n FACE_HEIGHT_PCT_MAX: 100,\n /** `zone` margin bounds, as Video Mask's. */\n ZONE_MARGIN_PCT_MIN: VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MIN,\n ZONE_MARGIN_PCT_MAX: VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MAX,\n} as const\n\n/**\n * What a face mesh run draws on each face (`VideoFaceMeshRequest.parts`):\n * `\"full\"` (the default) the thin wireframe and the darker eye and lip\n * outlines; `\"features\"` the eye outlines and the lip outline only, no\n * wireframe; `\"mouth\"` the lip outline only.\n */\nexport const VIDEO_FACE_MESH_PARTS = [\"full\", \"features\", \"mouth\"] as const\nexport type VideoFaceMeshParts = (typeof VIDEO_FACE_MESH_PARTS)[number]\n\n/**\n * The version of what a face mesh run draws for a given clip and settings:\n * every finished `video-face-mesh` job reports it as `output_data.recipe`,\n * for the caller to record beside a clip it stores with the lines on it (a\n * trend's approved face mask). Nothing on the platform compares it yet: a\n * stored mask is held to Video Mask's recipe and the engine's own.\n *\n * BUMP IT (to the date of the change) whenever the drawing changes for the\n * same input: the model, the crop, the smoothing, the filters, the colours or\n * the widths. Never for pricing, limits or messages. 2026-11-02: MediaPipe's\n * refined landmark model (478 points, a 256 × 256 crop) in place of the basic\n * one; the lines' colours and widths are 2026-11-01's. 2026-11-03: a face gets\n * lines only when it is found in at least 3 frames of its track (found faces\n * at the same place in frames at most 2 apart): one found in a frame or two\n * is never drawn.\n */\nexport const VIDEO_FACE_MESH_RECIPE = \"2026-11-03\"\n\nconst VIDEO_FACE_MESH_BUCKETS_SEC = [5, 10, 15, 30, 60, 120, 300] as const\n\n/** Every price row, smallest first (`video-face-mesh:<n>s`). */\nexport function videoFaceMeshCreditIds(): string[] {\n return VIDEO_FACE_MESH_BUCKETS_SEC.map((sec) => `video-face-mesh:${sec}s`)\n}\n\n/**\n * The price row for a clip priced at `billedSec` seconds: the smallest bucket\n * that holds it, after `pricedClipSeconds` (up to 0.05 s past a bucket's length\n * stays in that bucket). An unknown or non-positive length, or one past the cap,\n * prices the LONGEST row (the route measures every clip and refuses one past\n * the cap, so this is only ever a ceiling).\n */\nexport function videoFaceMeshCreditId(billedSec: number | null | undefined): string {\n const ids = videoFaceMeshCreditIds()\n if (typeof billedSec !== \"number\" || !Number.isFinite(billedSec) || billedSec <= 0) return ids[ids.length - 1]!\n const priced = pricedClipSeconds(billedSec)\n const i = VIDEO_FACE_MESH_BUCKETS_SEC.findIndex((b) => priced <= b)\n return ids[i === -1 ? ids.length - 1 : i]!\n}\n\n/** `POST /v1/video-face-mesh` request body. */\nexport interface VideoFaceMeshRequest {\n /** The clip the faces are FOUND in (the original). */\n readonly videoUrl: string\n /** The clip the lines are DRAWN on (default `videoUrl`): the masked or depth clip. Same frame count. */\n readonly drawOnUrl?: string\n /** A mask video (white = covered, same frame count): only faces whose box centre lies inside it are drawn. */\n readonly maskUrl?: string\n /** Draw only faces at least this % of the frame's height (default 0 = off). */\n readonly minFaceHeightPct?: number\n /** Draw only faces at most this % of the frame's height (0 = no cap). */\n readonly maxFaceHeightPct?: number\n /** Margins (% of the frame) where no face is drawn. */\n readonly zone?: Partial<VideoMaskZone> | null\n /**\n * The depth map's colormap (Video Depth's `VIDEO_DEPTH_COLORMAPS`) when the\n * lines go on a depth map: each line is then a colour OF that map — the map\n * at the line's tone of the depth under it. Needs `depthUrl`, except\n * `grayscale` (a gray depth clip is its own depth). Left out with a\n * `depthUrl`: `grayscale`.\n */\n readonly colormap?: VideoDepthColormap\n /**\n * The GRAYSCALE depth render of the clip (Video Depth with `colormap:\n * \"grayscale\"`, same frame count as `videoUrl`, any size): the depth each\n * line's colour is read from. Left out (a blurred mask, a gray depth clip\n * drawn on directly): each line is a gray tone of the pixel under it.\n */\n readonly depthUrl?: string\n /**\n * What is drawn on each face (`VIDEO_FACE_MESH_PARTS`): left out or\n * `\"full\"`, the wireframe and the eye and lip outlines; `\"features\"`, the\n * eye and lip outlines only; `\"mouth\"`, the lip outline only. The outlines\n * are drawn as they are in the full mesh (the same tone and width).\n */\n readonly parts?: VideoFaceMeshParts\n}\n\n/** A finished `video-face-mesh` job's `output_data`. */\nexport interface VideoFaceMeshOutput {\n /** The drawn clip: `drawOnUrl`'s frame count, size and frame rate, its audio copied untouched. */\n readonly videoUrl: string\n readonly width: number\n readonly height: number\n readonly frames: number\n /** Frames with at least one face drawn. */\n readonly framesWithFaces: number\n /** Faces drawn, summed over the frames (0 = nothing drawn; the clip comes back as it was sent). */\n readonly facesDrawn: number\n /** The map the lines were coloured from (a request with `depthUrl`); absent = gray tones of the pixel under them. */\n readonly colormap?: VideoDepthColormap\n /** What was drawn when it was not the full mesh (a request with `parts` `\"features\"` or `\"mouth\"`); absent = the full mesh. */\n readonly parts?: Exclude<VideoFaceMeshParts, \"full\">\n readonly recipe: string\n}\n","/**\n * Generate Mask — text-prompted IMAGE segmentation (Grounded SAM). The wire\n * contract of `POST /v1/generate-mask`, the `generate_mask` MCP verb, the SDK's\n * `nodes.run(\"generate-mask\", …)` and `nodaro media generate-mask`, defined ONCE:\n * every bound the route schema and the SDK/CLI read.\n *\n * The finished job's output is `{ maskUrl, imageUrl }`: `maskUrl` is the\n * black-and-white mask PNG (white = the subject), `imageUrl` is the SOURCE\n * image passed through unchanged, so an inpainting step can take the pair.\n *\n * Wire contract only — no I/O.\n */\n\nexport const GENERATE_MASK_LIMITS = {\n /** Subject description length cap. */\n PROMPT_MAX_LENGTH: 500,\n /** Segmentation confidence bounds. */\n THRESHOLD_MIN: 0,\n THRESHOLD_MAX: 1,\n /** Default segmentation confidence. Lower selects more (and less precise) regions. */\n THRESHOLD_DEFAULT: 0.3,\n} as const\n\n/** `POST /v1/generate-mask` request body. */\nexport interface GenerateMaskRequest {\n /** The image to segment. */\n readonly imageUrl: string\n /** What to select, in plain words (e.g. \"the person\", \"sky and clouds\"). 1–500 characters. */\n readonly prompt: string\n /** Segmentation confidence, `GENERATE_MASK_LIMITS.THRESHOLD_MIN`–`THRESHOLD_MAX` (default 0.3). */\n readonly threshold?: number\n}\n\n/** A completed Generate Mask job's `output_data`. */\nexport interface GenerateMaskOutput {\n /** The mask: a black-and-white PNG, white = the subject. */\n readonly maskUrl: string\n /** The source image, passed through unchanged. */\n readonly imageUrl: string\n}\n","/**\n * Mask Composite — place a foreground video over a background video through a\n * mask video (white = keep the foreground, black = show the background). The\n * wire contract of the `mask-composite` node, `POST /v1/mask-composite`, the\n * `mask_composite` MCP verb, `client.media.maskComposite` and\n * `nodaro media mask-composite`, defined ONCE. Pair it with Video Mask, whose\n * output is exactly such a mask.\n *\n * The render follows the FOREGROUND: its size, frame rate and length. The\n * background is fitted to that frame (`backgroundFit`) and loops when shorter;\n * the mask is stretched to the frame and holds its last frame when shorter.\n *\n * `fill` picks what fills the masked area. `\"video\"` (the default) is the\n * foreground, as above. `\"pixelate\"` and `\"blur\"` fill it with the BACKGROUND\n * itself, pixelated or blurred: there is no foreground then (a sent\n * `foregroundUrl` is ignored), so the render follows the BACKGROUND (its size,\n * frame rate and length; `backgroundFit` has nothing to fit), and the run is\n * priced on the background's length. With no foreground the result always\n * carries the background's sound — `audioSource` is ignored there\n * ({@link maskCompositeEffectiveAudioSource}); the canvas hides the control.\n *\n * Priced per started 5 seconds of the result (the foreground's length), like\n * Trim / Loop / Combine Videos: the node's own `model_pricing` row is ONE unit\n * (`maskCompositeUnits` counts them). Worked examples (repeated in\n * docs/nodes/processing-video/mask-composite.md, at the 10-credit row):\n * 3 s → 1 unit (10), 10 s → 2 units (20), 61 s → 13 units (130), 5 min → 60 units (600).\n *\n * Wire contract only — no I/O.\n */\nimport { pricedClipSeconds } from \"./priced-clip-seconds.js\"\n\n/** How the background is fitted to the foreground's frame. */\nexport const MASK_COMPOSITE_BACKGROUND_FITS = [\"cover\", \"contain\", \"stretch\"] as const\nexport type MaskCompositeBackgroundFit = (typeof MASK_COMPOSITE_BACKGROUND_FITS)[number]\n\n/** What fills the masked area: the foreground video, or the background itself pixelated or blurred. */\nexport const MASK_COMPOSITE_FILLS = [\"video\", \"pixelate\", \"blur\"] as const\nexport type MaskCompositeFill = (typeof MASK_COMPOSITE_FILLS)[number]\n\n/** Which sound the result carries. `mix` blends both tracks at equal level. */\nexport const MASK_COMPOSITE_AUDIO_SOURCES = [\"foreground\", \"background\", \"mix\", \"none\"] as const\nexport type MaskCompositeAudioSource = (typeof MASK_COMPOSITE_AUDIO_SOURCES)[number]\n\nexport const MASK_COMPOSITE_BOUNDS = {\n /** Edge softening, pixels of blur radius on the mask (0 = hard edge). */\n FEATHER_MIN: 0,\n FEATHER_MAX: 20,\n /** Grow (+) or shrink (−) the white region, pixels. */\n GROW_MIN: -10,\n GROW_MAX: 10,\n /** How strongly the foreground covers the background inside the mask\n * (1 = fully, today's output; 0 = not at all). */\n OPACITY_MIN: 0,\n OPACITY_MAX: 1,\n /** Pixelate: the block size as a % of the frame's WIDTH (relative, so a\n * setting looks the same at any resolution); the worker makes the blocks\n * max(2, round(width × pct / 100)) px. 1.25 % = 16 px on a 1280-wide frame. */\n PIXEL_SIZE_PCT_MIN: 0.2,\n PIXEL_SIZE_PCT_MAX: 10,\n /** Blur: the gaussian's sigma as a % of the frame's WIDTH (2 % ≈ sigma 25 px on a 1280-wide frame). */\n BLUR_STRENGTH_PCT_MIN: 0.1,\n BLUR_STRENGTH_PCT_MAX: 5,\n /** The longest leading video (the foreground; the background when `fill` is not video) a run accepts, seconds. */\n MAX_DURATION_SEC: 300,\n} as const\n\n/** Seconds of result one pricing unit covers. */\nexport const MASK_COMPOSITE_UNIT_SEC = 5\n\n/**\n * Pricing units for a result `durationSec` long: one per started 5 seconds,\n * at least one, after `pricedClipSeconds` (up to 0.05 s past a whole second is\n * ignored, so a 10.01 s result is 2 units, not 3). An unknown length counts the\n * longest result a run accepts (an upper bound — the pre-run quote for a clip\n * whose length is not known yet; every run measures its foreground).\n */\nexport function maskCompositeUnits(durationSec: number | null | undefined): number {\n const sec =\n typeof durationSec === \"number\" && Number.isFinite(durationSec) && durationSec > 0\n ? Math.min(durationSec, MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC)\n : MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC\n return Math.ceil(pricedClipSeconds(sec) / MASK_COMPOSITE_UNIT_SEC)\n}\n\nexport const MASK_COMPOSITE_DEFAULTS = {\n invertMask: false,\n feather: 2,\n grow: 0,\n opacity: 1,\n fill: \"video\" as MaskCompositeFill,\n pixelSizePct: 1.25,\n blurStrengthPct: 2,\n backgroundFit: \"cover\" as MaskCompositeBackgroundFit,\n audioSource: \"foreground\" as MaskCompositeAudioSource,\n} as const\n\nexport interface MaskCompositeSettings {\n readonly invertMask: boolean\n readonly feather: number\n readonly grow: number\n /** Inside the mask: opacity × foreground + (1 − opacity) × background. */\n readonly opacity: number\n /** What fills the masked area (`video` = the foreground). */\n readonly fill: MaskCompositeFill\n /** Pixelate block size, % of the frame width (used when `fill` is `pixelate`). */\n readonly pixelSizePct: number\n /** Blur strength: the gaussian's sigma as a % of the frame width (used when `fill` is `blur`). */\n readonly blurStrengthPct: number\n readonly backgroundFit: MaskCompositeBackgroundFit\n readonly audioSource: MaskCompositeAudioSource\n}\n\nconst clampInt = (v: unknown, min: number, max: number, fallback: number): number =>\n typeof v === \"number\" && Number.isFinite(v) ? Math.min(max, Math.max(min, Math.round(v))) : fallback\n\nconst clampNumber = (v: unknown, min: number, max: number, fallback: number): number =>\n typeof v === \"number\" && Number.isFinite(v) ? Math.min(max, Math.max(min, v)) : fallback\n\n/**\n * Node data (or any loose object) → settings every engine renders with.\n * Unknown enum values fall back to the default and numbers are clamped, so a\n * node written straight into workflow JSON renders the same as one set in the\n * panel. The ONE normaliser both workflow engines and the worker call.\n */\nexport function resolveMaskCompositeSettings(data: Readonly<Record<string, unknown>>): MaskCompositeSettings {\n const d = MASK_COMPOSITE_DEFAULTS\n const b = MASK_COMPOSITE_BOUNDS\n return {\n invertMask: typeof data.invertMask === \"boolean\" ? data.invertMask : d.invertMask,\n feather: clampInt(data.feather, b.FEATHER_MIN, b.FEATHER_MAX, d.feather),\n grow: clampInt(data.grow, b.GROW_MIN, b.GROW_MAX, d.grow),\n opacity: clampNumber(data.opacity, b.OPACITY_MIN, b.OPACITY_MAX, d.opacity),\n fill: maskCompositeFillOf(data),\n pixelSizePct: clampNumber(data.pixelSizePct, b.PIXEL_SIZE_PCT_MIN, b.PIXEL_SIZE_PCT_MAX, d.pixelSizePct),\n blurStrengthPct: clampNumber(data.blurStrengthPct, b.BLUR_STRENGTH_PCT_MIN, b.BLUR_STRENGTH_PCT_MAX, d.blurStrengthPct),\n backgroundFit: (MASK_COMPOSITE_BACKGROUND_FITS as readonly string[]).includes(data.backgroundFit as string)\n ? (data.backgroundFit as MaskCompositeBackgroundFit)\n : d.backgroundFit,\n audioSource: (MASK_COMPOSITE_AUDIO_SOURCES as readonly string[]).includes(data.audioSource as string)\n ? (data.audioSource as MaskCompositeAudioSource)\n : d.audioSource,\n }\n}\n\n/** The fill a node, payload or request body asks for: an unknown value is `video` (the default). */\nexport function maskCompositeFillOf(data: Readonly<Record<string, unknown>> | null | undefined): MaskCompositeFill {\n const f = data?.fill\n return (MASK_COMPOSITE_FILLS as readonly string[]).includes(f as string) ? (f as MaskCompositeFill) : MASK_COMPOSITE_DEFAULTS.fill\n}\n\n/** Does this fill take a foreground video? Only `video` does; pixelate and blur fill from the background. */\nexport function maskCompositeUsesForeground(fill: MaskCompositeFill): boolean {\n return fill === \"video\"\n}\n\n/**\n * The input whose size, rate and length the result has (and so the one a run\n * is measured and priced on): the canvas handle — `video` (the foreground) for\n * the video fill, `background-video` for pixelate and blur. The one rule the\n * route, the workflow run, the run estimates and the length walks read.\n */\nexport function maskCompositeLeadHandle(data: Readonly<Record<string, unknown>> | null | undefined): \"video\" | \"background-video\" {\n return maskCompositeUsesForeground(maskCompositeFillOf(data)) ? \"video\" : \"background-video\"\n}\n\n/**\n * The sound a render actually carries. With no foreground (pixelate / blur) it\n * is ALWAYS the background's — the only track there is — whatever\n * `audioSource` says (the canvas hides that control for these fills, so a\n * stored `none` from the Video fill can never silently mute the result).\n */\nexport function maskCompositeEffectiveAudioSource(s: Pick<MaskCompositeSettings, \"fill\" | \"audioSource\">): MaskCompositeAudioSource {\n if (maskCompositeUsesForeground(s.fill)) return s.audioSource\n return \"background\"\n}\n\n/** `POST /v1/mask-composite` request body. */\nexport interface MaskCompositeRequest extends Partial<MaskCompositeSettings> {\n /** The video whose white-masked region is kept (its size, rate and length lead).\n * Required when `fill` is `video` (the default); not used by `pixelate` / `blur`. */\n readonly foregroundUrl?: string\n /** The video shown where the mask is black. */\n readonly backgroundUrl: string\n /** The mask video — white = foreground (Video Mask's output). */\n readonly maskUrl: string\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk7YFQKR5C_cjs = require('./chunk-7YFQKR5C.cjs');
3
+ var chunkKM35K2M5_cjs = require('./chunk-KM35K2M5.cjs');
4
4
  var zod = require('zod');
5
5
 
6
6
  // src/pipeline-defaults.ts
@@ -273,7 +273,7 @@ var SceneNodeDataSchema = zod.z.object({
273
273
  emotional_beat: zod.z.string(),
274
274
  duration_seconds: zod.z.number().positive(),
275
275
  // Input mode — gates which video_model values are valid
276
- shot_input_mode: chunk7YFQKR5C_cjs.SceneInputModeSchema,
276
+ shot_input_mode: chunkKM35K2M5_cjs.SceneInputModeSchema,
277
277
  // Echoed inputs (Scene Director copies from SceneSpec)
278
278
  cast_keys: zod.z.array(zod.z.string()),
279
279
  location_key: zod.z.string(),
@@ -392,7 +392,7 @@ var PIPELINE_ACCEPTED_SCRIPT_LLMS = [
392
392
  ...PIPELINE_LEGACY_PINNED_SCRIPT_LLMS
393
393
  ];
394
394
  var ImageModelEnum = zod.z.enum(PIPELINE_ACCEPTED_IMAGE_MODELS);
395
- var VideoModelEnum = zod.z.preprocess(chunk7YFQKR5C_cjs.canonicalVideoProvider, zod.z.enum(PIPELINE_PINNABLE_VIDEO_MODELS));
395
+ var VideoModelEnum = zod.z.preprocess(chunkKM35K2M5_cjs.canonicalVideoProvider, zod.z.enum(PIPELINE_PINNABLE_VIDEO_MODELS));
396
396
  var ScriptLlmEnum = zod.z.enum(PIPELINE_ACCEPTED_SCRIPT_LLMS);
397
397
  var StageModelsSchema = zod.z.object({
398
398
  characters_image: ImageModelEnum.optional(),
@@ -1712,5 +1712,5 @@ exports.stripStudioTransientSettings = stripStudioTransientSettings;
1712
1712
  exports.validateDurationForFormat = validateDurationForFormat;
1713
1713
  exports.validateModeActivation = validateModeActivation;
1714
1714
  exports.validateObjects = validateObjects;
1715
- //# sourceMappingURL=chunk-SRLWSI6Q.cjs.map
1716
- //# sourceMappingURL=chunk-SRLWSI6Q.cjs.map
1715
+ //# sourceMappingURL=chunk-SEEQ3H22.cjs.map
1716
+ //# sourceMappingURL=chunk-SEEQ3H22.cjs.map