@nodaro/shared 3.60.1 → 3.61.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 (132) hide show
  1. package/dist/{chunk-DS2TOM32.js → chunk-43TGSZRJ.js} +27 -3
  2. package/dist/chunk-43TGSZRJ.js.map +1 -0
  3. package/dist/{chunk-RRPPXZ36.cjs → chunk-4KYLNTR7.cjs} +4 -4
  4. package/dist/{chunk-RRPPXZ36.cjs.map → chunk-4KYLNTR7.cjs.map} +1 -1
  5. package/dist/{chunk-HDHLZK7C.cjs → chunk-5I4T4QR5.cjs} +5 -5
  6. package/dist/{chunk-HDHLZK7C.cjs.map → chunk-5I4T4QR5.cjs.map} +1 -1
  7. package/dist/{chunk-DQIJPDHC.cjs → chunk-5XRRENHD.cjs} +11 -11
  8. package/dist/{chunk-DQIJPDHC.cjs.map → chunk-5XRRENHD.cjs.map} +1 -1
  9. package/dist/{chunk-LN3EVFRS.js → chunk-673E4KYC.js} +5 -5
  10. package/dist/{chunk-LN3EVFRS.js.map → chunk-673E4KYC.js.map} +1 -1
  11. package/dist/{chunk-CIOXUPCJ.cjs → chunk-7ARKVJTN.cjs} +12 -12
  12. package/dist/{chunk-CIOXUPCJ.cjs.map → chunk-7ARKVJTN.cjs.map} +1 -1
  13. package/dist/{chunk-MHY47BLL.js → chunk-7WGKP3EU.js} +4 -4
  14. package/dist/{chunk-MHY47BLL.js.map → chunk-7WGKP3EU.js.map} +1 -1
  15. package/dist/{chunk-KOLC7AF2.js → chunk-A3FHTSLB.js} +99 -14
  16. package/dist/chunk-A3FHTSLB.js.map +1 -0
  17. package/dist/{chunk-6Q6SI7AG.js → chunk-B6BG3LV2.js} +3 -3
  18. package/dist/{chunk-6Q6SI7AG.js.map → chunk-B6BG3LV2.js.map} +1 -1
  19. package/dist/{chunk-SCYBGTX6.js → chunk-C77F4ZTL.js} +3 -3
  20. package/dist/{chunk-SCYBGTX6.js.map → chunk-C77F4ZTL.js.map} +1 -1
  21. package/dist/{chunk-IV6IDECY.js → chunk-EWS2VFO4.js} +4 -4
  22. package/dist/{chunk-IV6IDECY.js.map → chunk-EWS2VFO4.js.map} +1 -1
  23. package/dist/{chunk-A6HRY3WF.cjs → chunk-F5YEMSNK.cjs} +102 -13
  24. package/dist/chunk-F5YEMSNK.cjs.map +1 -0
  25. package/dist/{chunk-5HK5Z5OB.cjs → chunk-FMXFHJWX.cjs} +4 -4
  26. package/dist/{chunk-5HK5Z5OB.cjs.map → chunk-FMXFHJWX.cjs.map} +1 -1
  27. package/dist/{chunk-GWBQ3GPO.cjs → chunk-FQXRYPCX.cjs} +27 -22
  28. package/dist/chunk-FQXRYPCX.cjs.map +1 -0
  29. package/dist/{chunk-ICDLYU4I.js → chunk-HGI2VKIV.js} +8 -8
  30. package/dist/{chunk-ICDLYU4I.js.map → chunk-HGI2VKIV.js.map} +1 -1
  31. package/dist/{chunk-EN2YI5TV.js → chunk-IRQ3SPX7.js} +3 -3
  32. package/dist/{chunk-EN2YI5TV.js.map → chunk-IRQ3SPX7.js.map} +1 -1
  33. package/dist/{chunk-5Y42RIGY.cjs → chunk-IVXSNW2B.cjs} +8 -8
  34. package/dist/{chunk-5Y42RIGY.cjs.map → chunk-IVXSNW2B.cjs.map} +1 -1
  35. package/dist/{chunk-W4M7TNXG.cjs → chunk-JHTT2V4A.cjs} +39 -39
  36. package/dist/{chunk-W4M7TNXG.cjs.map → chunk-JHTT2V4A.cjs.map} +1 -1
  37. package/dist/{chunk-VYQ25YQF.js → chunk-KHZAQGRP.js} +3 -3
  38. package/dist/{chunk-VYQ25YQF.js.map → chunk-KHZAQGRP.js.map} +1 -1
  39. package/dist/{chunk-G6GMY5BC.js → chunk-LLOIAGFB.js} +9 -4
  40. package/dist/chunk-LLOIAGFB.js.map +1 -0
  41. package/dist/{chunk-AZGONXWV.js → chunk-MOMFX32D.js} +4 -4
  42. package/dist/{chunk-AZGONXWV.js.map → chunk-MOMFX32D.js.map} +1 -1
  43. package/dist/{chunk-BXNPO3PL.cjs → chunk-MQZRQ5LM.cjs} +8 -8
  44. package/dist/{chunk-BXNPO3PL.cjs.map → chunk-MQZRQ5LM.cjs.map} +1 -1
  45. package/dist/chunk-NCOGGRRP.cjs +27 -0
  46. package/dist/{chunk-G7ZYZQKO.cjs.map → chunk-NCOGGRRP.cjs.map} +1 -1
  47. package/dist/{chunk-AXT7YNOR.cjs → chunk-NJVOJXBS.cjs} +43 -43
  48. package/dist/{chunk-AXT7YNOR.cjs.map → chunk-NJVOJXBS.cjs.map} +1 -1
  49. package/dist/{chunk-SKFJIFEV.cjs → chunk-RQ4F3AJH.cjs} +21 -21
  50. package/dist/{chunk-SKFJIFEV.cjs.map → chunk-RQ4F3AJH.cjs.map} +1 -1
  51. package/dist/{chunk-HYBACFYW.js → chunk-RUHKBEFF.js} +4 -4
  52. package/dist/{chunk-HYBACFYW.js.map → chunk-RUHKBEFF.js.map} +1 -1
  53. package/dist/{chunk-URLDVK67.js → chunk-SCMTN57Y.js} +3 -3
  54. package/dist/{chunk-URLDVK67.js.map → chunk-SCMTN57Y.js.map} +1 -1
  55. package/dist/{chunk-JKZVRKN3.js → chunk-UARGJ5IZ.js} +6 -6
  56. package/dist/chunk-UARGJ5IZ.js.map +1 -0
  57. package/dist/{chunk-6AJOTEVC.js → chunk-VOWJCUMR.js} +3 -3
  58. package/dist/{chunk-6AJOTEVC.js.map → chunk-VOWJCUMR.js.map} +1 -1
  59. package/dist/{chunk-5G23AJBU.cjs → chunk-XUJC6GHE.cjs} +6 -6
  60. package/dist/{chunk-5G23AJBU.cjs.map → chunk-XUJC6GHE.cjs.map} +1 -1
  61. package/dist/{chunk-GNPJ2JLE.cjs → chunk-XZKFZMRT.cjs} +6 -6
  62. package/dist/{chunk-GNPJ2JLE.cjs.map → chunk-XZKFZMRT.cjs.map} +1 -1
  63. package/dist/{chunk-KJZVQIN4.js → chunk-ZDBPQBAA.js} +3 -3
  64. package/dist/{chunk-KJZVQIN4.js.map → chunk-ZDBPQBAA.js.map} +1 -1
  65. package/dist/{chunk-HOKWJXHA.cjs → chunk-ZFJN23V4.cjs} +29 -2
  66. package/dist/chunk-ZFJN23V4.cjs.map +1 -0
  67. package/dist/{chunk-HNEF2N5C.cjs → chunk-ZLDFPVVI.cjs} +5 -5
  68. package/dist/{chunk-HNEF2N5C.cjs.map → chunk-ZLDFPVVI.cjs.map} +1 -1
  69. package/dist/{chunk-BDXXOEBZ.cjs → chunk-ZNM2LW3D.cjs} +47 -47
  70. package/dist/chunk-ZNM2LW3D.cjs.map +1 -0
  71. package/dist/{chunk-YHVEZVAO.js → chunk-ZZGQRRN7.js} +4 -4
  72. package/dist/{chunk-YHVEZVAO.js.map → chunk-ZZGQRRN7.js.map} +1 -1
  73. package/dist/entries/apps.cjs +42 -42
  74. package/dist/entries/apps.js +7 -7
  75. package/dist/entries/credits.cjs +151 -151
  76. package/dist/entries/credits.d.cts +8 -4
  77. package/dist/entries/credits.d.ts +8 -4
  78. package/dist/entries/credits.js +7 -7
  79. package/dist/entries/llm-models.d.cts +1 -1
  80. package/dist/entries/llm-models.d.ts +1 -1
  81. package/dist/entries/model-catalog.cjs +94 -78
  82. package/dist/entries/model-catalog.d.cts +2 -2
  83. package/dist/entries/model-catalog.d.ts +2 -2
  84. package/dist/entries/model-catalog.js +4 -4
  85. package/dist/entries/models.cjs +293 -293
  86. package/dist/entries/models.d.cts +3 -3
  87. package/dist/entries/models.d.ts +3 -3
  88. package/dist/entries/models.js +4 -4
  89. package/dist/entries/nodes.cjs +206 -206
  90. package/dist/entries/nodes.d.cts +1 -1
  91. package/dist/entries/nodes.d.ts +1 -1
  92. package/dist/entries/nodes.js +8 -8
  93. package/dist/entries/pipeline.cjs +152 -152
  94. package/dist/entries/pipeline.d.cts +1 -1
  95. package/dist/entries/pipeline.d.ts +1 -1
  96. package/dist/entries/pipeline.js +3 -3
  97. package/dist/entries/ugc.cjs +71 -71
  98. package/dist/entries/ugc.js +4 -4
  99. package/dist/entries/video.cjs +117 -117
  100. package/dist/entries/video.js +4 -4
  101. package/dist/entries/workflow.cjs +110 -98
  102. package/dist/entries/workflow.d.cts +28 -2
  103. package/dist/entries/workflow.d.ts +28 -2
  104. package/dist/entries/workflow.js +1 -1
  105. package/dist/index.cjs +1212 -1184
  106. package/dist/index.d.cts +3 -3
  107. package/dist/index.d.ts +3 -3
  108. package/dist/index.js +18 -18
  109. package/dist/{model-catalog-D6Es7VG-.d.ts → model-catalog-BgSvskgY.d.cts} +52 -1
  110. package/dist/{model-catalog-D6Es7VG-.d.cts → model-catalog-BgSvskgY.d.ts} +52 -1
  111. package/dist/{model-constants-22k3fjp1.d.cts → model-constants-DHd9jwQ7.d.cts} +6 -1
  112. package/dist/{model-constants-22k3fjp1.d.ts → model-constants-DHd9jwQ7.d.ts} +6 -1
  113. package/package.json +1 -1
  114. package/src/__tests__/gpt-image-2-6.test.ts +7 -0
  115. package/src/__tests__/image-mask-mode.test.ts +34 -1
  116. package/src/__tests__/mask-edit-follows-source.test.ts +150 -0
  117. package/src/credit-identifiers.ts +8 -4
  118. package/src/entries/model-catalog.ts +4 -0
  119. package/src/entries/workflow.ts +1 -0
  120. package/src/model-catalog.ts +157 -11
  121. package/src/model-constants.ts +12 -2
  122. package/src/node-execution-state.ts +3 -1
  123. package/src/wired-image-size.ts +55 -0
  124. package/dist/chunk-A6HRY3WF.cjs.map +0 -1
  125. package/dist/chunk-BDXXOEBZ.cjs.map +0 -1
  126. package/dist/chunk-DS2TOM32.js.map +0 -1
  127. package/dist/chunk-G6GMY5BC.js.map +0 -1
  128. package/dist/chunk-G7ZYZQKO.cjs +0 -27
  129. package/dist/chunk-GWBQ3GPO.cjs.map +0 -1
  130. package/dist/chunk-HOKWJXHA.cjs.map +0 -1
  131. package/dist/chunk-JKZVRKN3.js.map +0 -1
  132. package/dist/chunk-KOLC7AF2.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/credit-identifiers.ts"],"names":[],"mappings":";;;;;;AA+EA,SAA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OAAO,MAAA,CAAO;AAAA,EACnF,cAAA;AAAA,EACA,oBAAA;AAAA,EACA,sBAAA;AAAA,EACA;AACF,CAAU;AAYH,SAAS,mBAAA,CAAoB,SAAkB,IAAA,EAAqC;AACzF,EAAA,MAAM,QAAQ,OAAA,KAAY,OAAA;AAC1B,EAAA,IAAI,IAAA,KAAS,UAAA,EAAY,OAAO,KAAA,GAAQ,oBAAA,GAAuB,cAAA;AAC/D,EAAA,OAAO,QAAQ,4BAAA,GAA+B,sBAAA;AAChD;AAkBO,SAAS,cAAA,CAAe,OAA2B,SAAA,EAA2B;AACnF,EAAA,IAAI,CAAE,8BAAA,CAAqD,QAAA,CAAS,SAAS,CAAA,EAAG;AAC9E,IAAA,OAAO,SAAA;AAAA,EACT;AACA,EAAA,OAAQ,KAAA,IAAS,wBAAA,CAAyB,KAAK,CAAA,IAAM,SAAA;AACvD;AAUO,IAAM,wBAAA,GAA6D;AAAA,EACxE,EAAA,EAAI,SAAA;AAAA,EACJ,OAAA,EAAS,cAAA;AAAA,EACT,OAAA,EAAS,cAAA;AAAA,EACT,IAAA,EAAM,WAAA;AAAA,EACN,EAAA,EAAI;AACN","file":"chunk-UARGJ5IZ.js","sourcesContent":["/**\n * Build composite credit model identifiers for variable pricing.\n * Shared between frontend and backend.\n */\n\nimport {\n HIGH_QUALITY_PROVIDERS,\n TWO_K_RESOLUTION_PROVIDERS,\n RESOLUTION_2K_4K_TIERED_PROVIDERS,\n IDEOGRAM_PROVIDERS,\n DURATION_PRICED_PROVIDERS,\n AUDIO_ADDON_PROVIDERS,\n MODE_ADDON_PROVIDERS,\n RESOLUTION_VIDEO_REF_PRICING,\n RESOLUTION_DURATION_PRICING,\n VEO_RESOLUTION_TIERED_PROVIDERS,\n VIDEO_DURATION_TIERS,\n pricedOutputDurationSec,\n snapToNearestDuration,\n PRICING_DEFAULT_RESOLUTION,\n MOTION_DURATION_TIERS,\n T2I_TO_I2I_VARIANT,\n isVeoProvider,\n isMinimaxH3Provider,\n isGeminiOmniProvider,\n isGeminiOmniPerSecondProvider,\n isWan3Provider,\n isViduQ4Provider,\n isKling4Provider,\n normalizeKling4Resolution,\n VIDEO_REF_RATE_PROVIDERS,\n normalizeMinimaxH3Resolution,\n normalizeWan3Resolution,\n normalizeViduQ4Resolution,\n getVideoAudioCapability,\n canonicalVideoProvider,\n} from \"./model-constants.js\"\nimport { isFlux2Model, FLUX2_RES_MP, type Flux2Model } from \"./flux2-pricing.js\"\nimport {\n GPT_IMAGE_2_6_DEFAULT_QUALITY,\n GPT_IMAGE_2_6_DEFAULT_RESOLUTION,\n GPT_IMAGE_2_6_MAX_INPUT_IMAGES,\n GPT_IMAGE_2_6_QUALITIES,\n GPT_IMAGE_2_6_RESOLUTIONS,\n gptImage26PricedFormat,\n isGptImage26I2i,\n isGptImage26Tiered,\n type GptImage26TieredModel,\n type ImageFormatLevers,\n} from \"./gpt-image-2-6.js\"\nimport { VIDEO_DURATION_AUTO } from \"./video-duration-auto.js\"\nimport { uiResolutionFill } from \"./video-ui-defaults.js\"\nimport { MODEL_CATALOG, autoAspectNeedsSourceImage, normalizeModelInput, normalizeVideoRequestParams, defaultResolutionFor, type ModelInputAdjustment, type SourceImageSize } from \"./model-catalog.js\"\n\n/**\n * The megapixel tier a Flux 2 credit identifier is keyed on, for ANY incoming\n * `resolution` value.\n *\n * Flux 2 is the only family whose identifier INTERPOLATES the resolution\n * instead of matching it against a known set, and its callers are not\n * guaranteed to hand it a Flux 2 value:\n * - the multi-provider cost preview prices one node's data against EVERY\n * selected provider (`frontend/src/ee/hooks/use-providers-credits-sum.ts`),\n * so a node whose `resolution` is \"2K\" (the flux / nano-banana-pro value\n * space) reaches this branch verbatim;\n * - node data written straight into workflow JSON by an agent, an import or\n * a template never ran the config panel's provider-change fail-safe.\n * Interpolating that produced the off-grid id `flux-2-pro:2KMP:0ref`, which no\n * pricing row can answer — every cost badge 503'd `price_not_configured`\n * (18 production app-reports, 2026-09-07..14).\n *\n * A value off the grid snaps to the model's DEFAULT tier — the same `preferred`\n * value `normalizeModelInput` uses — so the preview asks for exactly the id the\n * route will reserve (both routes and the orchestrator normalize through\n * `resolveNormalizedImageGen` first, which makes this snap a no-op for them).\n * An ABSENT resolution keeps its long-standing meaning (\"this caller has no\n * resolution dimension at all\") and stays on 1 MP rather than moving to the\n * model default, which would silently re-price every resolution-less node.\n */\nfunction flux2MegapixelTier(model: Flux2Model, resolution?: string): string {\n const bare = (v: string) => v.replace(/\\s*MP$/i, \"\").trim()\n const raw = typeof resolution === \"string\" ? bare(resolution) : \"\"\n if (raw === \"\") return \"1\"\n // Numeric match so \"2.0\"/\" 2 MP\" land on the same grid point as \"2\", and the\n // GRID's own spelling is what gets emitted — returning the caller's \"2.0\"\n // would build \":2.0MP:\", another id no pricing row carries.\n const tier = FLUX2_RES_MP.find((t) => Number(t) === Number(raw))\n return tier ?? bare(defaultResolutionFor(model) ?? \"1 MP\")\n}\n\n/**\n * The price id of a GPT Image 2.6 Flare or Sunburst run: `<id>:<quality>:<size>`,\n * and on an edit `<id>:<quality>:<size>:<N>ref`, N being the input images.\n * PNG, JPEG and WebP cost the same, so they share those ids. Only a format that\n * prices differently adds a part of its own:\n * - a GIF takes no size (it is 512 pixels a frame) and is priced by its band\n * of frames: `<id>:<quality>:gif-<band>`, on an edit `…:gif-<band>:<N>ref`\n * (`gpt-image-2-6-flare:medium:gif-9-12`);\n * - an SVG is priced at its size and its level of detail:\n * `<id>:<quality>:<size>:svg-<level>`, on an edit `…:svg-<level>:<N>ref`\n * (`gpt-image-2-6-flare-i2i:high:2K:svg-detailed:3ref`).\n *\n * A value off the grid (a stored node, the multi-provider preview pricing one\n * node's data against every model) lands on the default rather than building\n * an id no row answers. A text-to-image id sent input images runs on the edit\n * endpoint, so a caller that does not swap the model first (the entity routes,\n * a pipeline pin) is priced there too. An edit always has at least its source.\n */\nfunction gptImage26CreditId(\n provider: GptImage26TieredModel,\n quality: string | undefined,\n resolution: string | undefined,\n referenceImageCount: number | undefined,\n imageFormat: ImageFormatLevers | undefined,\n): string {\n const q = (GPT_IMAGE_2_6_QUALITIES as readonly string[]).includes(quality ?? \"\") ? quality : GPT_IMAGE_2_6_DEFAULT_QUALITY\n const r = (GPT_IMAGE_2_6_RESOLUTIONS as readonly string[]).includes(resolution ?? \"\") ? resolution : GPT_IMAGE_2_6_DEFAULT_RESOLUTION\n const images = Math.trunc(referenceImageCount ?? 0)\n const model = !isGptImage26I2i(provider) && images > 0 ? T2I_TO_I2I_VARIANT[provider]! : provider\n const format = gptImage26PricedFormat(imageFormat)\n const base = format?.kind === \"gif\"\n ? `${model}:${q}:gif-${format.band}`\n : format?.kind === \"svg\"\n ? `${model}:${q}:${r}:svg-${format.level}`\n : `${model}:${q}:${r}`\n if (!isGptImage26I2i(model)) return base\n return `${base}:${Math.min(Math.max(1, images), GPT_IMAGE_2_6_MAX_INPUT_IMAGES)}ref`\n}\n\n/**\n * Compute composite model identifier for variable credit pricing.\n * Examples: \"gpt-image:high\", \"flux:2K\", \"nano-banana-pro:4K\", \"ideogram:TURBO\",\n * \"flux-2-pro:2MP\", \"flux-2-max:2MP:1ref\" (Flux 2 — billed per megapixel).\n *\n * For image models, uses quality/resolution/renderingSpeed and (Flux 2) the output\n * megapixel count plus (Flux 2 Max) the number of reference images attached at request time.\n * For video models, uses duration/sound params when the model has variable pricing.\n */\nexport function buildCreditModelIdentifier(\n provider: string,\n quality?: string,\n resolution?: string,\n renderingSpeed?: string,\n targetResolution?: string,\n referenceImageCount?: number,\n /** The output format, a GIF's frames and an SVG's level: read only by a model whose price depends on them (GPT Image 2.6). */\n imageFormat?: ImageFormatLevers,\n): string {\n // Flux 2 family: billed per output megapixel AND per reference image (each\n // ref counts as input megapixels). Resolution arrives as \"N MP\" strings (the\n // UI value space); strip the unit. ALL three models encode the ref count\n // (capped at 8): Pro/Klein i2i always carry the source image as a ref and\n // their cost formula charges per input MP, so the reserved identifier must\n // reflect refs (there is no metered true-up to correct an under-reserved tier).\n if (isFlux2Model(provider)) {\n return `${provider}:${flux2MegapixelTier(provider, resolution)}MP:${Math.min(referenceImageCount ?? 0, 8)}ref`\n }\n if (isGptImage26Tiered(provider)) {\n return gptImage26CreditId(provider, quality, resolution, referenceImageCount, imageFormat)\n }\n if (HIGH_QUALITY_PROVIDERS.has(provider) && quality === \"high\") {\n return `${provider}:high`\n }\n if (TWO_K_RESOLUTION_PROVIDERS.has(provider) && resolution === \"2K\") {\n return `${provider}:2K`\n }\n if (provider === \"nano-banana-pro\" && resolution === \"4K\") {\n return `${provider}:4K`\n }\n if (RESOLUTION_2K_4K_TIERED_PROVIDERS.has(provider) && (resolution === \"2K\" || resolution === \"4K\")) {\n return `${provider}:${resolution}`\n }\n // Topaz Image Upscale: 2K is default (no suffix), 4K/8K get composite identifiers\n if (provider === \"topaz-image-upscale\" && targetResolution && targetResolution !== \"2K\") {\n return `${provider}:${targetResolution}`\n }\n if (IDEOGRAM_PROVIDERS.has(provider)) {\n if (renderingSpeed === \"TURBO\") return `${provider}:TURBO`\n if (renderingSpeed === \"QUALITY\") return `${provider}:QUALITY`\n }\n return provider\n}\n\n/**\n * An image request's catalog-snapped parameters PLUS the credit identifier\n * priced off them.\n *\n * `adjustments` is the disclosure channel: every lever this changed, why, and\n * to what. Routes return it in the 200 body so a caller learns their value was\n * corrected instead of silently getting something else.\n */\nexport interface NormalizedImageGen {\n /** Credit identifier, priced off the SNAPPED `resolution` / `quality`. */\n identifier: string\n /** The catalog model id the params were snapped against (post T2I→I2I swap). */\n modelId: string\n aspectRatio?: string\n resolution?: string\n quality?: string\n background?: string\n /** The file the run writes (`outputFormat`); undefined is PNG. */\n outputFormat?: string\n /** A GIF's frames and the time each shows (ms); set only for a GIF. */\n gifFrames?: number\n gifFrameDurationMs?: number\n /** An SVG's level of detail; set only for an SVG. */\n svgLevel?: string\n /** Empty when the caller's values were already valid for `modelId`. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The catalog model `resolveNormalizedImageGen` snaps against: the provider\n * (Nano Banana when none is named), or — with `swapToI2i` and references\n * attached — its i2i sibling, the model the generate-image route and the\n * workflow payload builder then send. That sibling has its OWN catalog entry\n * and lever lists. Exported so a caller that has to decide something about\n * those lists before the snap (whether a photo's size is worth reading) asks\n * about the same model the snap will use.\n */\nexport function normalizedImageGenModelId(opts: {\n provider: unknown\n refCount: number\n swapToI2i?: boolean\n}): string {\n const provider = typeof opts.provider === \"string\" && opts.provider.length > 0 ? opts.provider : \"nano-banana\"\n return opts.swapToI2i && opts.refCount > 0 ? (T2I_TO_I2I_VARIANT[provider] ?? provider) : provider\n}\n\n/**\n * Whether \"auto\" on a Generate Image request can need its photo's size: the\n * model the snap runs against (`normalizedImageGenModelId` with the swap on)\n * has no native auto. Given the ASSEMBLED reference count, it asks about exactly\n * that model; without one — a write boundary, or a run before its references\n * assemble — about both the provider and its i2i sibling, since references may\n * yet attach.\n */\nexport function imageGenAutoAspectNeedsSourceImage(opts: {\n provider: unknown\n aspectRatio: unknown\n refCount?: number\n}): boolean {\n const asks = (refCount: number) =>\n autoAspectNeedsSourceImage(normalizedImageGenModelId({ provider: opts.provider, refCount, swapToI2i: true }), opts.aspectRatio)\n return opts.refCount === undefined ? asks(0) || asks(1) : asks(opts.refCount)\n}\n\n/**\n * The output-format levers of a request body or a node's data, typed for\n * `normalizeModelInput`: a non-string format or level is no value, and a GIF's\n * numbers may arrive as numeric strings (a form field, a FieldMapping).\n */\nexport function imageFormatInputOf(source: object): { outputFormat?: string; gifFrames?: number; gifFrameDurationMs?: number; svgLevel?: string } {\n const record = source as Record<string, unknown>\n const str = (v: unknown): string | undefined => (typeof v === \"string\" && v.length > 0 ? v : undefined)\n const num = (v: unknown): number | undefined => {\n const n = typeof v === \"number\" ? v : typeof v === \"string\" && v.trim() !== \"\" ? Number(v) : Number.NaN\n return Number.isFinite(n) ? n : undefined\n }\n return {\n outputFormat: str(record.outputFormat),\n gifFrames: num(record.gifFrames),\n gifFrameDurationMs: num(record.gifFrameDurationMs),\n svgLevel: str(record.svgLevel),\n }\n}\n\n/**\n * Snap an image request's catalog-governed levers to a combination the model\n * actually accepts, and price the credit identifier off the SNAPPED values.\n *\n * WHY THE SNAP LIVES HERE and not at the call site. Both image routes compute\n * their credit identifier TWICE — once in the `creditGuard` preHandler (the\n * CHECK) and once at the handler's `reserveCreditsForJob` (the DEBIT) — and a\n * dedicated test asserts the two stay byte-identical (see\n * `backend/src/routes/__tests__/generate-image.test.ts`, \"CHECK === DEBIT\").\n * `resolution` and `quality` are pricing dimensions, so a snap applied at only\n * one of those sites breaks that invariant, and `commit_credits` never collects\n * an upward delta — the reserve IS the charge. Putting the snap inside the\n * primitive makes CHECK, DEBIT and the workflow orchestrator agree by\n * construction rather than by everyone remembering to call a normalizer.\n *\n * Inputs are typed `unknown` on purpose: the preHandler runs BEFORE Zod, so a\n * caller can put a number or an object in `resolution`. Non-strings become\n * `undefined` rather than reaching `normalizeModelInput` as a lie.\n *\n * Unknown model ids pass through untouched (same contract as\n * `normalizeModelInput`) — the route's provider enum is the gate for those.\n *\n * `sourceImage` is the size of the photo the request transforms or is drawn\n * from (an image-to-image / edit source, or Generate Image's first wired\n * reference). It decides \"auto\" on a model without a native auto, and the\n * ratio is not a pricing dimension on any such model (pinned across the catalog\n * by `auto-aspect-source.test.ts`). With `masked` on a model whose masked edit\n * follows its photo (`maskEditMatchesSource`) it also decides the SIZE, a\n * pricing dimension: the CHECK and the DEBIT must then both be given it (the\n * image-to-image route reads it once, before its credit check).\n */\nexport function resolveNormalizedImageGen(opts: {\n provider: string | undefined\n aspectRatio?: unknown\n quality?: unknown\n resolution?: unknown\n renderingSpeed?: unknown\n /** Does not price on its own, but a transparent background can move the size. */\n background?: unknown\n /** The file the run writes, and a GIF's frames and speed or an SVG's level: a GIF and an SVG price differently. */\n outputFormat?: unknown\n gifFrames?: unknown\n gifFrameDurationMs?: unknown\n svgLevel?: unknown\n refCount: number\n swapToI2i?: boolean\n sourceImage?: SourceImageSize\n /** The request carries an inpainting mask: on a model whose masked edit follows its photo, the photo's size decides the ratio and the priced size. */\n masked?: boolean\n}): NormalizedImageGen {\n const str = (v: unknown): string | undefined =>\n typeof v === \"string\" && v.length > 0 ? v : undefined\n\n const modelId = normalizedImageGenModelId(opts)\n\n const n = normalizeModelInput(\n modelId,\n {\n aspectRatio: str(opts.aspectRatio),\n resolution: str(opts.resolution),\n quality: str(opts.quality),\n background: str(opts.background),\n ...imageFormatInputOf(opts),\n },\n { sourceImage: opts.sourceImage, masked: opts.masked },\n )\n\n return {\n identifier: buildCreditModelIdentifier(\n modelId,\n n.quality,\n n.resolution,\n str(opts.renderingSpeed),\n undefined,\n opts.refCount,\n { outputFormat: n.outputFormat, gifFrames: n.gifFrames, svgLevel: n.svgLevel },\n ),\n modelId,\n aspectRatio: n.aspectRatio,\n resolution: n.resolution,\n quality: n.quality,\n background: n.background,\n outputFormat: n.outputFormat,\n gifFrames: n.gifFrames,\n gifFrameDurationMs: n.gifFrameDurationMs,\n svgLevel: n.svgLevel,\n adjustments: n.adjustments,\n }\n}\n\n/**\n * Reference-aware image-generation credit identifier — the SINGLE source of\n * truth shared by the single-node routes (`/v1/generate-image`,\n * `/v1/image-to-image`) and the workflow orchestrator\n * (`payload-builder.ts`). It centralises the two pricing dimensions that must\n * match across both paths or a Flux 2 generation is billed the wrong tier\n * (Flux 2 commits non-metered / has no upward true-up, so the reserved\n * identifier IS the final charge):\n * - `refCount`: the number of reference images sent to the provider (Flux 2\n * bills per ref). generate-image passes the assembled count (0 for pure\n * text-to-image); image-to-image passes 1 (the primary `imageUrl`) + extras.\n * - `swapToI2i`: generate-image auto-swaps a bare T2I provider to its i2i\n * sibling (`T2I_TO_I2I_VARIANT`) when refs are attached, so the credit id\n * matches the variant actually invoked. image-to-image is already an i2i\n * provider → pass `false`.\n *\n * The LoRA short-circuit (`flux-lora-character`) stays at the call site because\n * the routing decision needs a DB lookup the routes/orchestrator own.\n */\nexport function resolveImageGenCreditIdentifier(opts: {\n provider: string | undefined\n quality?: string\n resolution?: string\n renderingSpeed?: string\n outputFormat?: unknown\n gifFrames?: unknown\n svgLevel?: unknown\n refCount: number\n swapToI2i?: boolean\n}): string {\n return resolveNormalizedImageGen(opts).identifier\n}\n\n// T2V-specific credit overrides: some providers have different costs for T2V\n// vs I2V/V2V due to different default resolutions or colliding with image model names.\nconst T2V_CREDIT_OVERRIDES: Record<string, string> = {\n \"grok\": \"grok-i2v\", // T2V grok, same as I2V grok (not image grok = 4 cr)\n \"wan\": \"wan-t2v\", // T2V wan 1080p = (V2V wan 720p = 70 cr)\n \"wan-turbo\": \"wan-turbo-t2v\", // T2V wan-turbo 720p = (I2V wan-turbo 480p = 40 cr)\n}\n\n/**\n * Compute composite model identifier for video models with duration/audio-based pricing.\n * Examples: \"kling-3.0:5s\", \"kling-3.0:10s:audio\", \"seedance-2:8s:720p-ref\"\n *\n * @param provider - Video model key (e.g., \"kling-3.0\")\n * @param duration - Video duration in seconds\n * @param sound - Whether audio/sound is enabled\n * @param nodeType - Node type for T2V-specific cost overrides\n * @param mode - Quality variant that affects pricing\n * @param resolution - Output resolution (used by Seedance 2 for 480p/720p pricing)\n * @param hasVideoRef - Whether a reference video is connected (Seedance 2 uses a lower per-second rate when true)\n */\n/**\n * LTX 2.3 (Lightricks via Replicate) credit tiers: priced by\n * (resolution-band × duration-seconds). Keys mirror STATIC_CREDIT_COSTS /\n * model_pricing EXACTLY (lowercase band + raw seconds + \"s\"), e.g.\n * \"ltx-2.3-pro:1080p:6s\". This map is the source of truth for the nearest-tier\n * snap below, so an off-catalog (resolution, duration) from a direct API/SDK\n * call maps to a SEEDED price instead of hard-failing (price_not_configured\n * 503). Pro: 6/8/10s at every band. Fast: up to 20s at 1080p, 6/8/10s at 2k/4k.\n */\nconst LTX_DURATION_TIERS: Record<string, Record<string, number[]>> = {\n \"ltx-2.3-pro\": { \"1080p\": [6, 8, 10], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n \"ltx-2.3-fast\": { \"1080p\": [6, 8, 10, 12, 14, 16, 18, 20], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n}\n\n/**\n * The (band, duration) tier the LTX pricing ladder charges for a request, or\n * `undefined` for a non-LTX provider. Extracted so\n * `buildVideoCreditModelIdentifier` and `pricedVideoSelection` read the ladder\n * ONCE — the routes must send the tier they reserved, and a second copy of this\n * math is exactly how the two drift apart.\n *\n * An unknown/absent band falls back to 1080p (LTX's own default, and the band\n * `snapLtxInput` snaps to at the Replicate call), and an off-tier duration\n * snaps to the NEAREST seeded one so the emitted composite always prices.\n */\nfunction ltxPricedTier(\n provider: string,\n resolution?: string,\n duration?: number | string,\n): { band: string; duration: number } | undefined {\n const bands = LTX_DURATION_TIERS[provider]\n if (!bands) return undefined\n const band = bands[String(resolution)] ? String(resolution) : \"1080p\"\n const allowed = bands[band]!\n // The model's own default (catalog `defaultDuration`) when unset, then the\n // nearest rung of THIS band's ladder — the length LTX renders.\n const dur = snapToNearestDuration(pricedOutputDurationSec(provider, duration), allowed)\n return { band, duration: dur }\n}\n\n/**\n * The resolution a provider whose runner NORMALIZES the lever actually renders,\n * in the lowercase spelling of its credit composites — billing collapses\n * through the very normalizer the runner sends, so render == billed for every\n * spelling. `undefined` passes through untouched for every other provider.\n */\nfunction wireNormalizedResolution(provider: string, resolution: string | undefined): string | undefined {\n if (isWan3Provider(provider)) return normalizeWan3Resolution(resolution).toLowerCase()\n if (isViduQ4Provider(provider)) return normalizeViduQ4Resolution(resolution)\n if (isKling4Provider(provider)) return normalizeKling4Resolution(resolution)\n return resolution\n}\n\nexport function buildVideoCreditModelIdentifier(\n rawProvider: string,\n duration?: number | string,\n sound?: boolean,\n nodeType?: \"image-to-video\" | \"text-to-video\",\n mode?: string,\n resolution?: string,\n hasVideoRef?: boolean,\n): string {\n // A retired model (RETIRED_VIDEO_PROVIDERS) is priced as the model it runs as.\n const provider = canonicalVideoProvider(rawProvider) as string\n // T2V overrides: some providers have different base costs for text-to-video\n let effectiveProvider = provider\n if (nodeType === \"text-to-video\") {\n const override = T2V_CREDIT_OVERRIDES[provider]\n if (override) {\n // If override target also has duration pricing, use it as effective provider\n if (DURATION_PRICED_PROVIDERS.has(override)) {\n effectiveProvider = override\n } else {\n return override\n }\n }\n }\n\n // VEO 3.x resolution-tiered pricing: 720p is the base (no suffix), 1080p gets\n // \":1080p\" (Fast/Lite only), and 4K gets \":4k\" for ALL three tiers — direct-4K\n // generation chains KIE's get-4k-video off the base generation (the base runs\n // at 1080p). Duration is fixed at 8s for VEO so the duration-tier path below\n // does not apply.\n if (isVeoProvider(effectiveProvider)) {\n if (resolution === \"4k\") return `${effectiveProvider}:4k`\n // 1080p tier is Fast/Lite only (Quality has no 1080p surcharge).\n if (resolution === \"1080p\" && VEO_RESOLUTION_TIERED_PROVIDERS.has(effectiveProvider)) return `${effectiveProvider}:1080p`\n return effectiveProvider\n }\n\n // Gemini Omni family (gemini-omni-video + gemini-omni-flash): priced by\n // (resolution-band × duration), with a flat per-generation rate when a source\n // video is supplied (V2V). Lowercase \"4k\". The prefix is TEMPLATED from the\n // provider id, so a further Omni SKU needs no edit here — it only has to join\n // GEMINI_OMNI_PROVIDERS and seed its rows. These models are deliberately NOT\n // in DURATION_PRICED_PROVIDERS; this branch early-returns before that gate.\n // A per-second SKU (Omni Flash 1.2) prices on the `:<N>s:<res>` ladder below.\n if (isGeminiOmniProvider(effectiveProvider) && !isGeminiOmniPerSecondProvider(effectiveProvider)) {\n if (hasVideoRef) {\n return resolution === \"4k\" ? `${effectiveProvider}:4k:vref` : `${effectiveProvider}:vref`\n }\n // The rendered length through the catalog funnel (nearest legal tier, the\n // model's own default when unset) so the composite is always a SEEDED one.\n const d = pricedOutputDurationSec(effectiveProvider, duration)\n return resolution === \"4k\" ? `${effectiveProvider}:4k:${d}` : `${effectiveProvider}:${d}`\n }\n\n // LTX 2.3: priced by (resolution-band × duration-seconds). The RESERVE must be\n // the correct composite — commit_credits (migration 176) only refunds a surplus\n // (actual < reserved) and NEVER collects an upward delta, so an under-reserved\n // LTX run (the bare-id default = cheapest 1080p:6s tier) stays under-charged\n // even with meteredCost:true. Snap to a seeded tier so the id always prices.\n const ltxTier = ltxPricedTier(effectiveProvider, resolution, duration)\n if (ltxTier) {\n return `${effectiveProvider}:${ltxTier.band}:${ltxTier.duration}s`\n }\n\n if (!DURATION_PRICED_PROVIDERS.has(effectiveProvider)) {\n return effectiveProvider\n }\n\n // A named-provider request with NO duration renders the model's own default\n // (kie/models.ts extraParams), so price that default — not the global 5s —\n // for providers whose per-second tiers wouldn't snap 5 up to it\n // (minimax-h3, seedance-2-5). One helper, shared with the dynamic\n // reference-video reservations, so the tier and the scaled reserve agree.\n const durationSec = pricedOutputDurationSec(effectiveProvider, duration)\n const tiers = VIDEO_DURATION_TIERS[effectiveProvider]\n if (!tiers) return effectiveProvider\n\n // Find the matching duration tier\n const tier = tiers.find(t => durationSec <= t.maxSeconds) ?? tiers[tiers.length - 1]\n let identifier = `${effectiveProvider}:${tier.suffix}`\n\n // Append audio suffix if applicable. When the caller expressed no intent\n // (sound === undefined), fall back to the model's own default (capability\n // `defaultOn` — kling-3.0 generates audio unless explicitly disabled), so an\n // intent-less request is billed for the audio it actually produces instead\n // of reserving the cheaper no-audio tier against an audio-on generation.\n const soundOn = sound ?? (getVideoAudioCapability(effectiveProvider).defaultOn === true)\n if (AUDIO_ADDON_PROVIDERS.has(effectiveProvider) && soundOn) {\n identifier += \":audio\"\n }\n\n // Append mode suffix for providers with quality-tiered pricing\n // \"high\" comes from I2V videoSize field, \"pro\" comes from T2V mode field\n if (MODE_ADDON_PROVIDERS.has(effectiveProvider) && (mode === \"high\" || mode === \"pro\")) {\n identifier += \":high\"\n }\n\n // Seedance 2.0 family: per-second billing with resolution + video-ref dimensions.\n // KIE accepts 480p / 720p / 1080p natively; per-second rates rise non-linearly\n // so each tier gets its own composite identifier.\n if (RESOLUTION_VIDEO_REF_PRICING.has(effectiveProvider)) {\n // Clamp to the model's catalog resolutions (single source of truth): e.g.\n // seedance-2-mini exposes only 480p/720p, so a stale/explicit 1080p (or 4k)\n // maps to its top priced tier instead of emitting an unpriced composite\n // (which the hard-fail credit guard would 503 on at runtime).\n const supported = MODEL_CATALOG[effectiveProvider]?.resolutions ?? [\"480p\", \"720p\", \"1080p\"]\n // An OMITTED resolution renders the model's KIE-side default, so price that\n // default rather than the cheapest tier — otherwise an intent-less request\n // reserves 480p against a 720p render and commit_credits (refund-only) can\n // never collect the delta. Providers without an entry keep the historical\n // 480p fallback, so this cannot reprice anything already live.\n const requested = resolution ?? PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const want = requested === \"4k\" ? \"4k\" : requested === \"1080p\" ? \"1080p\" : requested === \"720p\" ? \"720p\" : \"480p\"\n // Unsupported (e.g. a stale 1080p on seedance-2-mini) clamps to the model's\n // top priced tier so the emitted composite is always seeded.\n const res = supported.includes(want) ? want : (supported[supported.length - 1] ?? \"480p\")\n identifier += `:${res}`\n if (hasVideoRef) identifier += \"-ref\"\n }\n\n // Duration × resolution pricing without a -ref dimension. Resolutions\n // outside the provider's priced tiers (or undefined) collapse to the first\n // (default) tier so the emitted composite is always seeded — the hard-fail\n // guard fuzzes the whole resolution space.\n const resTiers = RESOLUTION_DURATION_PRICING[effectiveProvider]\n if (resTiers) {\n // The \"default tier\" is the provider's DECLARED default when it has one\n // (PRICING_DEFAULT_RESOLUTION — wan-3 renders 720p, not the cheapest tier),\n // otherwise the first listed tier. Declaring it explicitly means a cosmetic\n // reorder of the tier list can never reprice a live model, and an OMITTED\n // *or* unsupported resolution both land on what actually renders instead of\n // on the cheapest row (commit_credits refunds a surplus but can never\n // collect a shortfall). Behaviour-neutral for every member without a\n // declared default.\n const declaredDefault = PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const fallback = declaredDefault && resTiers.includes(declaredDefault) ? declaredDefault : resTiers[0]!\n // Wan 3.0 renders through `normalizeWan3Resolution`, which is CASE-INSENSITIVE\n // (\"1080P\" — KIE's own OpenAPI enum spelling, and the natural value for an\n // integrator reading the provider docs — renders 1080P). The tier list here is\n // lowercase and `Array.includes` is case-sensitive, so without this the render\n // path and the billing path disagree: \"1080P\" rendered the top tier and billed\n // the 720p row, a shortfall `commit_credits` (refund-only) can never collect.\n // Collapsing through the SAME normalizer the runner uses makes render == billed\n // by construction for every spelling, including garbage (→ the declared 720p).\n // Scoped to the families whose runner normalizes on purpose (Wan 3.0, Vidu\n // Q4): the other RESOLUTION_DURATION_PRICING members pass `resolution` to\n // their wire verbatim, so case-folding their billing without probing their\n // wire would reprice live models.\n const requested = wireNormalizedResolution(effectiveProvider, resolution)\n const res = requested && resTiers.includes(requested) ? requested : fallback\n identifier += `:${res}`\n // A reference VIDEO bills at its own per-second rate (Kling 4.0).\n if (hasVideoRef && VIDEO_REF_RATE_PROVIDERS.has(effectiveProvider)) identifier += \"-ref\"\n }\n\n // MiniMax Hailuo 3 (768P lever, 2026-08-03): bare duration composites stay\n // the 2K (default) rate — byte-identical to the pre-lever seeded rows, so\n // existing workflows and admin overrides keep their ids — and only a\n // verified 768P selection appends \":768p\". normalizeMinimaxH3Resolution\n // collapses anything else to 2K, matching what KIE renders for an\n // omitted/unknown value, so billing can never undercut the render.\n if (isMinimaxH3Provider(effectiveProvider) && normalizeMinimaxH3Resolution(resolution) === \"768P\") {\n identifier += \":768p\"\n }\n\n return identifier\n}\n\n/**\n * The credit identifier a video GENERATION node is quoted at — Generate Video\n * (and the legacy Image/Text to Video nodes) and the Video to Video Seedance\n * edit lane, on every surface that quotes one: the node's cost pill, the\n * editor's run estimate, the prompt modal and the backend pre-run estimator.\n *\n * It applies the request levers the run applies BEFORE it prices\n * (payload-builder's `resolveVideoRequestNorm`): the model's UI resolution fill\n * when the node names none (`uiResolutionFill` — what the run sends), then the\n * catalog normalizer `normalizeVideoRequestParams`, which also owns the Seedance\n * Draft rule (a draft is priced AND sent at 480p whatever resolution came with\n * it). Without that, a node with no resolution was quoted at the identifier's\n * own default band (720p on Seedance 2.5) while the run sent and reserved 480p.\n *\n * `hasVideoRef` must come from the GRAPH (a wired reference-video edge, e.g.\n * `countRefModalityEdges(edges, id, \"video\") > 0`), never node data: nothing\n * writes `referenceVideoUrls` into a video node, so reading it there always\n * quoted the plain ladder for a run that reserves on the `-ref` one.\n */\nexport function videoGenerationCreditId(args: {\n provider: string\n duration?: number | string\n sound?: boolean\n nodeType?: \"image-to-video\" | \"text-to-video\"\n mode?: string\n resolution?: string\n draft?: boolean\n hasVideoRef?: boolean\n}): string {\n const { resolution } = normalizeVideoRequestParams(args.provider, {\n resolution: args.resolution ?? uiResolutionFill(args.provider),\n draft: args.draft === true,\n })\n return buildVideoCreditModelIdentifier(\n args.provider,\n args.duration,\n args.sound,\n args.nodeType ?? \"image-to-video\",\n args.mode,\n resolution,\n args.hasVideoRef === true,\n )\n}\n\n/**\n * The credit identifier a Video to Video node's Seedance EDIT lane reserves\n * under. Seedance has no v2v endpoint — the lane is a text-to-video job in edit\n * shape with the source clip as reference video 1 — so it prices on the\n * REFERENCE-VIDEO ladder at the model's LONGEST clip (Auto duration), and the\n * measured settlement refunds down to what was actually delivered.\n *\n * A thin call into {@link videoGenerationCreditId}, so a Generate Video node\n * making the same KIE call (Seedance, Auto, a wired reference video) is quoted\n * the same id. FOUR surfaces must agree on it exactly: the orchestrator's\n * reservation (payload-builder.ts), the backend pre-run estimator\n * (ee/billing/credits.ts), the node's cost pill, and the frontend run-level\n * estimate (config-panels/helpers.ts). A quote that disagrees with the reserve\n * is the documented `price_not_configured` / blank-pill trap.\n *\n * `resolution` is the node's one `v2vResolution` field; when unset the model's\n * own UI fill is priced, which is what the lane will send. `draft` is the\n * node's Seedance Draft toggle (priced at 480p).\n */\nexport function seedanceVideoEditCreditId(provider: string, resolution?: string, draft?: boolean): string {\n return videoGenerationCreditId({\n provider,\n duration: VIDEO_DURATION_AUTO,\n nodeType: \"text-to-video\",\n resolution,\n draft,\n hasVideoRef: true,\n })\n}\n\n/** What the video credit identifier PRICES for a request, for the levers whose\n * priced value must also be the value we SEND. */\nexport interface PricedVideoSelection {\n /** The resolution band the reservation is priced at when the request omitted\n * one — and only where the platform DECLARES that band as the provider's own\n * default. `undefined` means \"leave `resolution` exactly as the request had\n * it\": either the caller supplied one, or the provider's real default is not\n * known to be the band the identifier assumes. */\n resolution?: string\n /** The length the reservation is priced at and the wire carries, for a\n * provider whose price follows the clip length (LTX's seeded tier, the KIE\n * ladders, Gemini Omni). `undefined` for every other provider, and for Auto:\n * their duration passes through. */\n duration?: number\n /** Non-empty only for a lever the caller ASKED for and did not get (a 7s\n * request snapped to the 6s tier). Filling an omitted lever is a disclosure of\n * the price already being charged, not a correction, so it reports nothing. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The other half of the video money path: `normalizeVideoRequestParams` snaps a\n * value the CATALOG governs; this returns the value the PRICE ladder governs.\n *\n * Two defects it closes, both of the same shape — the identifier prices one\n * thing and the wire carries another, and `commit_credits` (migration 176) only\n * ever refunds a surplus, so the reservation is the final charge:\n *\n * 1. **Absent resolution.** `buildVideoCreditModelIdentifier` prices an omitted\n * `resolution` as a concrete band (LTX → 1080p; a\n * {@link PRICING_DEFAULT_RESOLUTION} member → its declared default). Leaving\n * the key unset then lets the provider pick — documented for the KIE members\n * (their `extraParams` pin the same band) but UNDOCUMENTED for LTX on\n * Replicate. Sending the band we priced makes the two agree by construction.\n *\n * The fill is deliberately limited to providers with a DECLARED default.\n * `buildVideoCreditModelIdentifier` also has un-declared fallbacks — the\n * cheapest tier for a resolution-priced provider with no\n * `PRICING_DEFAULT_RESOLUTION` row — and those are a HEDGE, not a verified\n * provider default: seedance-2 / -fast / -mini pin `resolution: \"720p\"`\n * KIE-side while the identifier prices 480p, so filling 480p would downgrade\n * the render to match a price we already know is wrong. That mismatch is a\n * pre-existing identifier bug and is fixed by seeding the row, not here.\n *\n * 2. **Duration.** Every provider whose price follows the clip length is\n * charged at the length it RENDERS: its own default when the request named\n * none (catalog `defaultDuration`), the nearest length it offers otherwise\n * (`pricedOutputDurationSec` — the runners' own snap rule). The LTX ladder is\n * seeded per (band × seconds), so a 7s request snaps onto the 6s tier;\n * sending 7s would bill six and render seven. The same value is returned for\n * the other length-priced providers (the KIE ladders, Gemini Omni), so what\n * is priced is what is sent. Auto (-1) is the model's call and is untouched.\n *\n * Pure, and IDEMPOTENT against the identifier: feeding its output back in\n * cannot move the reserved tier. `video-request-normalize.test.ts` proves that\n * over every provider × resolution × duration.\n */\nexport function pricedVideoSelection(opts: {\n provider: string\n resolution?: string\n duration?: number | string\n}): PricedVideoSelection {\n const adjustments: ModelInputAdjustment[] = []\n const ltx = ltxPricedTier(opts.provider, opts.resolution, opts.duration)\n\n // The band the request will be priced AND rendered at. An explicit value\n // always wins — this only ever fills an omission.\n const resolution = opts.resolution\n ?? (ltx ? ltx.band : PRICING_DEFAULT_RESOLUTION[opts.provider])\n\n const requested = typeof opts.duration === \"string\" ? parseInt(opts.duration, 10) : opts.duration\n const asked = requested !== undefined && !Number.isNaN(requested)\n\n // Every provider whose price follows the clip length sends the length it is\n // CHARGED at (the catalog funnel: its own default when unset, the nearest\n // legal length otherwise). Auto (-1) is the model's call and is left alone.\n const lengthPriced = !!ltx || DURATION_PRICED_PROVIDERS.has(opts.provider) || isGeminiOmniProvider(opts.provider)\n if (!lengthPriced || (!ltx && asked && requested! <= 0)) return { resolution, adjustments }\n\n const duration = ltx ? ltx.duration : pricedOutputDurationSec(opts.provider, opts.duration)\n if (asked && requested !== duration) {\n adjustments.push({\n field: \"duration\",\n from: requested!,\n to: duration,\n reason: ltx\n ? `LTX renders ${ltx.band} in ${ltx.duration}s steps — using ${ltx.duration}s instead of ${requested}s.`\n : `${opts.provider} renders ${duration}s clips at the nearest length it offers — using ${duration}s instead of ${requested}s.`,\n })\n }\n return { resolution, duration, adjustments }\n}\n\n/**\n * Compute composite model identifier for motion control with duration-tiered pricing.\n * Examples: \"kling-3.0-motion:10s\", \"kling-3.0-motion:1080p:15s\", \"motion-transfer:5s\"\n *\n * Wan Animate providers use resolution-tiered pricing (not per-second):\n * \"wan-animate-move\" (480p default), \"wan-animate-move:580p\", \"wan-animate-move:720p\"\n *\n * @param provider - Motion control provider key (\"kling\" for 2.6, \"kling-3.0\", \"wan-animate-move\", \"wan-animate-replace\")\n * @param resolution - \"720p\" or \"1080p\" (Kling), \"480p\" or \"580p\" or \"720p\" (Wan Animate)\n * @param videoDuration - Reference video duration in seconds (defaults to 10s, unused for Wan Animate)\n */\nexport function buildMotionCreditModelIdentifier(\n provider: string,\n resolution: string,\n videoDuration?: number,\n): string {\n // Wan Animate providers use resolution-tiered pricing (not duration-based)\n if (provider === \"wan-animate-move\" || provider === \"wan-animate-replace\") {\n // 480p is the default (base identifier), 580p and 720p get composite suffix\n if (resolution === \"580p\" || resolution === \"720p\") {\n return `${provider}:${resolution}`\n }\n return provider\n }\n\n const raw = videoDuration ?? 10\n const durationSec = Math.floor(Number.isNaN(raw) ? 10 : raw) // default 10s; floor to match KIE per-second billing\n const tier = MOTION_DURATION_TIERS.find(t => durationSec <= t.maxSeconds)\n ?? MOTION_DURATION_TIERS[MOTION_DURATION_TIERS.length - 1]\n\n const base = provider === \"kling-3.0\" ? \"kling-3.0-motion\" : \"motion-transfer\"\n const resSuffix = resolution === \"1080p\" ? \":1080p\" : \"\"\n return `${base}${resSuffix}:${tier.suffix}`\n}\n\n/**\n * The Suno operations whose credit key depends on the model VERSION.\n *\n * `/v1/suno/generate`, `/cover` and `/extend` resolve their creditGuard\n * identifier through `sunoCreditType(model, <operation>)` (routes/suno.ts\n * :247-249, :335-337, :407-409). EVERY other Suno route charges a flat\n * per-operation key and ignores the version the node carries — mashup (:648),\n * add-instrumental (:852), add-vocals (:907), upload-extend (:1016),\n * replace-section (:710), style-boost (:771), convert-wav (:962),\n * lyrics (:482), music-video (:594), voice (:1218).\n *\n * Anything that QUOTES a Suno price — a dropdown row, a node badge, the\n * workflow-credit estimator — must follow the same split, or it displays a\n * credit key the route never charges.\n */\nexport const SUNO_VERSION_PRICED_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n] as const\n\n/**\n * The seven Suno operations that appear behind a select/dropdown UI (model\n * pickers, node badges, the credit estimator) — the three version-priced\n * operations above, plus the four flat-key operations exercised by\n * `sunoCreditType`'s own test suite. A readonly tuple so later tasks (the\n * model dropdowns, node badges) can iterate or count it without redeclaring\n * the list and drifting from this one.\n */\nexport const SUNO_SELECT_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-mashup\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-upload-extend\",\n] as const\n\n/**\n * Adjust Speed's price id: motion-compensated (\"smooth\") interpolation is its\n * own, dearer tier. The route, the workflow run, and the editor's badge and\n * run estimate all price through this, so none of them can quote the fast tier\n * for a smooth run.\n */\nexport function speedRampCreditId(quality: unknown): \"speed-ramp\" | \"speed-ramp:smooth\" {\n return quality === \"smooth\" ? \"speed-ramp:smooth\" : \"speed-ramp\"\n}\n\n/**\n * Apply EDL's price id: a `proxy` render (the 720p preview) is its own,\n * cheaper per-output-minute row; a `final` render keeps the bare id. One id per\n * QUALITY, for a video and an audio output alike (decided 2026-10-04). Anything\n * that is not exactly \"proxy\" is the final, as the route and the node default\n * it. The route, the workflow run, and the editor's badge and run estimate all\n * price through this; the job itself is always named `apply-edl`.\n */\nexport function applyEdlCreditId(quality: unknown): \"apply-edl\" | \"apply-edl:proxy\" {\n return quality === \"proxy\" ? \"apply-edl:proxy\" : \"apply-edl\"\n}\n\n/**\n * Speaker View's price tiers (decided 2026-10-10, C4): a render is priced by\n * how many speakers it composites at once. `standard` — at most two tiles on\n * any segment and no zoom; `complex` — three to six tiles, or any zoom. Which\n * tier a render is in is the render rule's to say (the app's\n * `@nodaro/render-rules`), never this vocabulary's.\n */\nexport const SPEAKER_VIEW_PRICE_TIERS = [\"standard\", \"complex\"] as const\nexport type SpeakerViewPriceTier = (typeof SPEAKER_VIEW_PRICE_TIERS)[number]\n\nexport type SpeakerViewCreditId = \"speaker-view\" | \"speaker-view:proxy\" | \"speaker-view:complex\" | \"speaker-view:complex:proxy\"\n\n/** Every id `speakerViewCreditId` can name. */\nexport const SPEAKER_VIEW_CREDIT_IDS: readonly SpeakerViewCreditId[] = Object.freeze([\n \"speaker-view\",\n \"speaker-view:proxy\",\n \"speaker-view:complex\",\n \"speaker-view:complex:proxy\",\n] as const)\n\n/**\n * The credit id of a Speaker View render (F4, decided 2026-09-23; tiers\n * decided 2026-10-10): a Preview (`quality` \"proxy\") reserves on its own row,\n * anything else on the final's, and each in its price tier — `standard` on\n * `speaker-view` / `speaker-view:proxy`, `complex` on `speaker-view:complex` /\n * `speaker-view:complex:proxy`. A tier that is not exactly `standard` (absent\n * included) names the `complex` row: a caller that cannot tell quotes high,\n * never low. The job is always named `speaker-view`; only its credit id\n * follows the quality and the tier.\n */\nexport function speakerViewCreditId(quality: unknown, tier?: unknown): SpeakerViewCreditId {\n const proxy = quality === \"proxy\"\n if (tier === \"standard\") return proxy ? \"speaker-view:proxy\" : \"speaker-view\"\n return proxy ? \"speaker-view:complex:proxy\" : \"speaker-view:complex\"\n}\n\n/**\n * OUR Nodaro credit key for a Suno operation, given the model version and the\n * operation (which is also the node type and the BullMQ job name).\n *\n * This is the single source of truth for the Suno pricing contract, shared by\n * the reservation path (routes/suno.ts creditGuard), the egress seam\n * (workers/handlers/suno.ts `modelKey`, which must match what was reserved),\n * both workflow-credit estimators (ee/billing/credits.ts and the frontend\n * config-panels/helpers.ts), the seven Suno model dropdowns and the three Suno\n * node badges. It is a billing key — NEVER a KIE provider id — which is what\n * satisfies the B3 egress invariant.\n *\n * The version → key map is {@link SUNO_VERSION_CREDIT_KEYS}; a version with no\n * entry (V4 / V4_5 / V4_5ALL / V4_5PLUS) falls back to the operation key, and a\n * non-version-priced operation is returned unchanged.\n */\nexport function sunoCreditType(model: string | undefined, operation: string): string {\n if (!(SUNO_VERSION_PRICED_OPERATIONS as readonly string[]).includes(operation)) {\n return operation\n }\n return (model && SUNO_VERSION_CREDIT_KEYS[model]) || operation\n}\n\n/**\n * Suno version → Nodaro credit key for the version-priced operations. One row\n * per version that has its own `model_pricing` row / `STATIC_CREDIT_COSTS`\n * entry / `MODEL_CATALOG` pricing row, so an admin can reprice one version\n * without touching code. Every ACTIVE version MUST have a row here — guarded\n * by `__tests__/suno-credit-type.test.ts` (a new active version with no key\n * would silently bill at the operation key).\n */\nexport const SUNO_VERSION_CREDIT_KEYS: Readonly<Record<string, string>> = {\n V6: \"suno-v6\",\n V6_WILD: \"suno-v6_wild\",\n V6_MINI: \"suno-v6_mini\",\n V5_5: \"suno-v5_5\",\n V5: \"suno-v5\",\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from './chunk-G6GMY5BC.js';
1
+ import { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from './chunk-LLOIAGFB.js';
2
2
 
3
3
  // src/fan-out-meta.ts
4
4
  function fanOutItemMeta(output) {
@@ -467,5 +467,5 @@ function ugcCardsOutputs(answer) {
467
467
  }
468
468
 
469
469
  export { UGC_CREATOR_CANDIDATES_KEY, UGC_CREATOR_MISSING_MESSAGE, UGC_CREATOR_PICKER_TYPES, UGC_FINISH_NEEDS_CLIPS_MESSAGE, UGC_FINISH_NOT_READY_MESSAGE, UGC_NEEDS_FINISH_MESSAGE, UGC_NEWER_APP_MESSAGE, UGC_NODE_MESSAGES, UGC_NODE_RUN_STATE_KEYS, UGC_NODE_TYPES, UGC_NOT_SERVED_MESSAGE, UGC_OVERRIDABLE_FIELDS, UGC_OVER_HOLD_MESSAGE, UGC_PICK_FIRST_MESSAGE, UGC_PICK_GONE_MESSAGE, UGC_PRIMARY_HANDLE, UGC_PUBLISH_PRIVATE_FIELDS, UGC_SCREENSHOT_HANDLES, UGC_SCRIPT_DEFAULT_TARGET_SEC, UGC_SCRIPT_LANGUAGES, UGC_SCRIPT_MAX_TARGET_SEC, UGC_SCRIPT_MIN_TARGET_SEC, UGC_SCRIPT_NEEDS_CHANGES, UGC_VERSION_MESSAGE, clipNotesFrom, fanOutItemMeta, findUgcLockedFields, readUgcWire, stripUgcRunState, ugcAwaitsPick, ugcCardsBody, ugcCardsJobs, ugcCardsOutputs, ugcClipBody, ugcClipOutputs, ugcClipSavedList, ugcClipsBody, ugcClipsOutputs, ugcCreatorBody, ugcCreatorCallsToRender, ugcCreatorCandidate, ugcCreatorCandidates, ugcCreatorOutputs, ugcCreatorPick, ugcFailure, ugcKeptOutputs, ugcPickPending, ugcPipValue, ugcPlanLengthSec, ugcPlanScreenshotCount, ugcRunWaitsForPick, ugcScriptBody, ugcScriptOutputs, ugcScriptResult };
470
- //# sourceMappingURL=chunk-6AJOTEVC.js.map
471
- //# sourceMappingURL=chunk-6AJOTEVC.js.map
470
+ //# sourceMappingURL=chunk-VOWJCUMR.js.map
471
+ //# sourceMappingURL=chunk-VOWJCUMR.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/fan-out-meta.ts","../src/ugc-run-state.ts","../src/ugc-node-wires.ts"],"names":[],"mappings":";;;AAKO,SAAS,eAAe,MAAA,EAA8F;AAC3H,EAAA,MAAM,IAAI,MAAA,EAAQ,YAAA;AAClB,EAAA,MAAM,IAAI,MAAA,EAAQ,WAAA;AAClB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,GAAI,CAAA,CAAE,MAAA,CAAO,CAAC,CAAA,KAAmB,OAAO,CAAA,KAAM,QAAQ,IAAI,EAAC;AAAA,IACpF,WAAA,EAAa,OAAO,CAAA,KAAM,QAAA,IAAY,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI;AAAA,GAC1E;AACF;AAGO,SAAS,aAAA,CAAc,MAAoE,MAAA,EAAqC;AACrI,EAAA,MAAM,IAAA,GAAO,IAAA,IAAQ,IAAA,CAAK,MAAA,GAAS,CAAA,GAAI,OAAO,MAAA,GAAS,CAAC,MAAM,CAAA,GAAI,EAAC;AACnE,EAAA,OAAO,IAAA,CAAK,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I,EAAC;AAAA,IAC3D,MAAA,EAAQ,CAAC,GAAG,KAAA,CAAM,MAAM,CAAA;AAAA,IACxB,SAAA,EAAW,CAAC,GAAG,KAAA,CAAM,SAAS;AAAA,GAChC;AACF;AAGA,IAAM,kBAAA,GAAkC,EAAE,CAAA,EAAG,CAAA,EAAG,QAAA,EAAU,EAAA,EAAI,SAAA,EAAW,CAAA,EAAG,SAAA,EAAW,CAAA,EAAG,QAAA,EAAU,EAAC,EAAE;AAGhG,SAAS,gBAAgB,MAAA,EAA6C;AAC3E,EAAA,MAAM,SAAS,MAAA,CAAO,aAAA;AACtB,EAAA,MAAM,SAAS,MAAA,CAAO,MAAA;AACtB,EAAA,MAAM,QAAQ,QAAA,CAAS,MAAM,KAAK,KAAA,CAAM,OAAA,CAAQ,OAAO,KAAK,CAAA,GAAI,MAAA,CAAO,KAAA,CAAM,OAAO,CAAC,CAAA,KAAmB,OAAO,CAAA,KAAM,QAAQ,IAAI,EAAC;AAClI,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,IAAA,CAAK,SAAA,CAAU,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,GAAI,MAAA,CAAO,SAAA,GAAY,EAAE,CAAA;AAAA,IACjF,WAAA,EAAa,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,MAAM,CAAA,GAAI,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,MAAA,EAAO,GAAI,kBAAkB,CAAA;AAAA,IACvF,MAAA,EAAQ,KAAA,CAAM,IAAA,CAAK,IAAI;AAAA,GACzB;AACF","file":"chunk-6AJOTEVC.js","sourcesContent":["/** One fan-out item's notes: its warnings and its real length (UGC Clip). */\nexport interface FanOutItemMeta { readonly warnings: readonly string[]; readonly durationSec: number | null }\n/** One row of UGC Cards' `notes` input. */\nexport interface ClipNote { readonly clip: number; readonly warnings: readonly string[]; readonly durationSec?: number }\n\nexport function fanOutItemMeta(output: { clipWarnings?: unknown; durationSec?: unknown } | null | undefined): FanOutItemMeta {\n const w = output?.clipWarnings\n const d = output?.durationSec\n return {\n warnings: Array.isArray(w) ? w.filter((x): x is string => typeof x === \"string\") : [],\n durationSec: typeof d === \"number\" && Number.isFinite(d) && d > 0 ? d : null,\n }\n}\n\n/** Row-aligned meta (or one single output) → the notes UGC Cards reads, clip numbers from 1. */\nexport function clipNotesFrom(meta: ReadonlyArray<FanOutItemMeta | null | undefined> | undefined, single?: FanOutItemMeta): ClipNote[] {\n const rows = meta && meta.length > 0 ? meta : single ? [single] : []\n return rows.map((m, i) => ({\n clip: i + 1,\n warnings: m?.warnings ?? [],\n ...(typeof m?.durationSec === \"number\" ? { durationSec: m.durationSec } : {}),\n }))\n}\n","/** The UGC node types (Cloud only; served by a private plugin). */\nexport const UGC_NODE_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\", \"ugc-clips\", \"ugc-clip\", \"ugc-cards\", \"ugc-finish-clips\"])\n\n/** UGC Creator: the node-data key that holds a round's passing candidates until the person picks one (run state). */\nexport const UGC_CREATOR_CANDIDATES_KEY = \"candidates\"\n\n/** A run that would execute a UGC Creator whose options wait for the person's pick. */\nexport const UGC_PICK_FIRST_MESSAGE = \"Pick a creator first.\"\n\n/**\n * Per UGC type, the node-data keys that are a RUN's state, never a choice. A\n * published app's snapshot is readable by every runner, so publishing strips\n * them (the last plan, the clip tickets, the publisher's kept creator).\n *\n * UGC Creator's image (`generatedImageUrl`) goes from every creator, whatever its\n * source: after a My photo run it IS the author's photo, and a creator switched\n * to another source after such a run, or whose photo was removed, still holds it.\n * UGC Clip's takes and UGC Cards' Notes (`generatedText`, and `text`, the Notes\n * as a run hands them on) are the author's renders: a published node starts empty.\n *\n * A published snapshot is stripped through `stripUgcPublishState`\n * (@nodaro/render-rules), which also empties every run result a lane writes under\n * a generic name, every node made from the UGC video, and every node on a path\n * into a UGC Creator's photo input.\n */\nexport const UGC_NODE_RUN_STATE_KEYS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"result\", \"keepResult\", \"ugcOutputs\", UGC_CREATOR_CANDIDATES_KEY, \"optionFailed\", \"generatedImageUrl\"],\n // `exampleLines`: a template's example run, shown until the node's own first script (display only).\n \"ugc-script\": [\"result\", \"keepResult\", \"ugcOutputs\", \"exampleLines\"],\n \"ugc-clips\": [\"result\", \"quote\", \"__listResults\", \"ugcOutputs\"],\n \"ugc-clip\": [\n \"warnings\", \"rerender\", \"rerenderPending\", \"__listResults\", \"__listResultMeta\", \"clipWarnings\", \"durationSec\", \"ugcOutputs\",\n \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\",\n ],\n \"ugc-cards\": [\"result\", \"ugcOutputs\", \"generatedText\", \"text\"],\n \"ugc-finish-clips\": [\"ugcOutputs\", \"__listResults\", \"__listResultMeta\", \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\"],\n}\n\n/**\n * The ONLY UGC keys a run request's `inputOverrides` may set — an allow-list,\n * so a run-state field added later is locked without anyone listing it.\n *\n * No UGC type may gain a `LEGACY_EXPOSED_FIELD_KEYS` row: the lock reads the\n * stored key, before that table renames it.\n */\nexport const UGC_OVERRIDABLE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"source\", \"gender\", \"photoUrl\"],\n \"ugc-script\": [\"targetDurationSec\", \"language\"],\n \"ugc-clips\": [],\n \"ugc-clip\": [],\n \"ugc-cards\": [],\n \"ugc-finish-clips\": [],\n}\n\nconst KEEP_RESULT_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\"])\n\n/** UGC Creator holds options for the person to pick: the ones a run drew, or the ones a credits stop kept. */\nexport function ugcPickPending(data: unknown): boolean {\n const candidates = data && typeof data === \"object\" ? (data as Record<string, unknown>)[UGC_CREATOR_CANDIDATES_KEY] : undefined\n return Array.isArray(candidates) && candidates.length > 0\n}\n\n/**\n * A run that would execute a UGC Creator whose options wait is refused (\"Pick a creator first.\"),\n * except that creator's own re-draw. One rule for the editor's check before a run and the\n * orchestrator's.\n */\nexport function ugcRunWaitsForPick(\n runNodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,\n opts: { readonly redrawId?: string } = {},\n): boolean {\n return runNodes.some((n) => n.type === \"ugc-creator\" && n.id !== opts.redrawId && ugcPickPending(n.data))\n}\n\n/**\n * Per UGC type, the author's own content a published snapshot never carries: UGC Creator's photo\n * of a person (`photoUrl`). A choice, not run state — so it stays on the author's own workflow —\n * but a runner gives their own photo (or the run is refused for want of one) and a template's\n * cloner adds theirs.\n */\nexport const UGC_PUBLISH_PRIVATE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"photoUrl\"],\n}\n\n/**\n * The UGC types' own strip: a copy of `nodes` with every UGC node's run state and the author's own\n * photo removed (and `keepResult: false`). Other nodes are returned as they are. Publishing, a\n * share link's view and a viewer's run go through `stripUgcPublishState` (@nodaro/render-rules),\n * which starts here.\n */\nexport function stripUgcRunState<T extends { type?: unknown; data?: unknown }>(nodes: readonly T[]): T[] {\n return nodes.map((node) => {\n const type = typeof node.type === \"string\" ? node.type : \"\"\n if (!UGC_NODE_TYPES.has(type) || !node.data || typeof node.data !== \"object\") return node\n const data: Record<string, unknown> = { ...(node.data as Record<string, unknown>) }\n for (const key of UGC_NODE_RUN_STATE_KEYS[type] ?? []) delete data[key]\n for (const key of UGC_PUBLISH_PRIVATE_FIELDS[type] ?? []) delete data[key]\n if (KEEP_RESULT_TYPES.has(type)) data.keepResult = false\n return { ...node, data }\n })\n}\n\n/** Every override entry that would set a non-overridable key on a UGC node, in node then key order. Pure. */\nexport function findUgcLockedFields(\n nodes: ReadonlyArray<{ id: string; type?: string }> | null | undefined,\n inputOverrides: Record<string, Record<string, unknown>> | null | undefined,\n): Array<{ nodeId: string; nodeType: string; field: string }> {\n if (!nodes || !inputOverrides) return []\n const found: Array<{ nodeId: string; nodeType: string; field: string }> = []\n for (const node of nodes) {\n const type = node?.type\n if (typeof type !== \"string\" || !UGC_NODE_TYPES.has(type)) continue\n const allowed = UGC_OVERRIDABLE_FIELDS[type] ?? []\n const fields = inputOverrides[node.id]\n if (!fields || typeof fields !== \"object\") continue\n for (const field of Object.keys(fields)) {\n if (!allowed.includes(field)) found.push({ nodeId: String(node.id), nodeType: type, field })\n }\n }\n return found\n}\n","/**\n * The UGC node wires: every request body the five UGC nodes send and every\n * output they hand on, as ONE pure implementation that both engines (the\n * workflow orchestrator and the editor) call, so the two can never disagree.\n *\n * Content-free. A creator record is read only for `v`, `gender` and\n * `identityImages`, a plan only for `v`, a clip ticket only for `v`, `index`\n * and `durationSec`; every other key is opaque and passes through as it came.\n * Every UGC-private JSON a node emits carries `v: 1`, and a wire with another\n * `v` is refused, never guessed at.\n */\nimport type { CaptionPlan } from \"./caption-plan.js\"\nimport { fanOutItemMeta, type ClipNote } from \"./fan-out-meta.js\"\nimport { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from \"./model-constants.js\"\nimport { ugcPickPending } from \"./ugc-run-state.js\"\n\n/** A UGC call that reached a deployment without the UGC routes (the router's 404). */\nexport const UGC_NOT_SERVED_MESSAGE = \"UGC videos are a Nodaro Cloud feature and are not served on this deployment.\"\n/** A wire whose `v` this app does not read. */\nexport const UGC_VERSION_MESSAGE = \"This workflow was made with a newer version of the UGC nodes.\"\n/** An answer this app cannot run: a tool it does not know, or a shape it cannot read. */\nexport const UGC_NEWER_APP_MESSAGE = \"This step needs a newer app version.\"\n/** A creator pick whose options are gone (another run replaced them, or they were never this node's). */\nexport const UGC_PICK_GONE_MESSAGE = \"These creator options are no longer available. Run UGC Creator again.\"\n/** UGC Clips with no creator on its creator input (UGC Creator has not run, or waits for a pick). */\nexport const UGC_CREATOR_MISSING_MESSAGE = \"UGC Creator has no creator yet. Run it, or pick one of its options.\"\n/** UGC Script's target length in seconds when the node holds none: the node's default (the route requires a length). */\nexport const UGC_SCRIPT_DEFAULT_TARGET_SEC = 15\n/** The range of a UGC script's length, in whole seconds: the script route's, and a plan's own. */\nexport const UGC_SCRIPT_MIN_TARGET_SEC = 4\nexport const UGC_SCRIPT_MAX_TARGET_SEC = 300\n\nconst MINOR_AGE_MESSAGE = \"That age can't be used: UGC creators are adults only.\"\nconst NEEDS_GENDER = \"Choose woman or man.\"\nconst NEEDS_PHOTO = \"Connect or upload a photo of yourself.\"\nconst NEEDS_CATEGORY = \"Run UGC Script first, or pick a product category.\"\nconst NEEDS_SITE = \"Add the product name or website.\"\n/** The opening of the sentence UGC Clips fails with when the plugin refuses the script: \"<this> <each error and its fix>\". */\nexport const UGC_SCRIPT_NEEDS_CHANGES = \"The script needs changes:\"\nconst NEEDS_PLAN_OUT = \"Connect the Script (sized) output of UGC Clips.\"\nconst NEEDS_PLAN = \"Connect the Script output of UGC Script.\"\nconst NEEDS_TICKET = \"Connect the Clips output of UGC Clips.\"\nconst NEEDS_VIDEO = \"Connect the joined video.\"\nconst NEEDS_TRANSCRIPT = \"Connect the Transcript output of UGC Clips.\"\n/**\n * A run of a video whose clips are cut from one recorded speech, on a graph with no UGC Finish on this UGC\n * Clips' Script (sized) output: refused before anything is spent.\n */\nexport const UGC_NEEDS_FINISH_MESSAGE = \"Add a UGC Finish node after UGC Clip, and connect UGC Clips' Script (sized) output to it.\"\n/** UGC Finish with nothing on its clips input. */\nexport const UGC_FINISH_NEEDS_CLIPS_MESSAGE = \"Connect the Video output of UGC Clip.\"\n/** UGC Finish's job answered that a clip does not follow its speech (each clip checks itself first, so this is rare). */\nexport const UGC_FINISH_NOT_READY_MESSAGE = \"A clip did not follow its speech. Re-render it from the UGC Clip node and run again.\"\n/**\n * A video cut from one recorded speech whose clips, priced once the speech is split, would hold more\n * than the run was checked for before it started: the run stops at UGC Clips, before any clip renders.\n */\nexport const UGC_OVER_HOLD_MESSAGE =\n \"The clips for this recording would cost more than this run was checked for, so none was rendered. Run UGC Clips again to record the speech again.\"\n\n/**\n * Every fixed sentence a UGC node fails with, by id: the English both engines write on the node.\n * The editor shows each in the person's language by its id. Not listed: the sentence that opens\n * with `UGC_SCRIPT_NEEDS_CHANGES` (the plugin's own words finish it), a route's own message, and\n * \"UGC step failed (<status>)\".\n */\nexport const UGC_NODE_MESSAGES = Object.freeze({\n notServed: UGC_NOT_SERVED_MESSAGE,\n version: UGC_VERSION_MESSAGE,\n newerApp: UGC_NEWER_APP_MESSAGE,\n pickGone: UGC_PICK_GONE_MESSAGE,\n creatorMissing: UGC_CREATOR_MISSING_MESSAGE,\n minorAge: MINOR_AGE_MESSAGE,\n needsGender: NEEDS_GENDER,\n needsPhoto: NEEDS_PHOTO,\n needsCategory: NEEDS_CATEGORY,\n needsSite: NEEDS_SITE,\n needsPlanOut: NEEDS_PLAN_OUT,\n needsPlan: NEEDS_PLAN,\n needsTicket: NEEDS_TICKET,\n needsVideo: NEEDS_VIDEO,\n needsTranscript: NEEDS_TRANSCRIPT,\n needsFinish: UGC_NEEDS_FINISH_MESSAGE,\n finishNeedsClips: UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n finishNotReady: UGC_FINISH_NOT_READY_MESSAGE,\n overHold: UGC_OVER_HOLD_MESSAGE,\n} as const)\n\n/** The id of a fixed sentence a UGC node fails with (`UGC_NODE_MESSAGES`). */\nexport type UgcNodeMessageId = keyof typeof UGC_NODE_MESSAGES\n\n/** UGC Script's screenshot inputs, in card order. */\nexport const UGC_SCREENSHOT_HANDLES: readonly string[] = [\n \"screenshot\", \"screenshot2\", \"screenshot3\", \"screenshot4\", \"screenshot5\", \"screenshot6\", \"screenshot7\", \"screenshot8\",\n]\n\n/** Per UGC type, the output an edge with no source handle reads. */\nexport const UGC_PRIMARY_HANDLE: Readonly<Record<string, string>> = {\n \"ugc-creator\": \"creator\",\n \"ugc-script\": \"plan\",\n \"ugc-clips\": \"clips\",\n \"ugc-clip\": \"video-out\",\n \"ugc-cards\": \"layerPlan\",\n \"ugc-finish-clips\": \"video-out\",\n}\n\n/** A UGC node's outputs: handle id → the value that handle carries (a JSON string, text or a URL). */\nexport type UgcOutputs = Readonly<Record<string, string>>\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/**\n * The length a saved UGC plan was written to: its own `targetDurationSec`, a whole number of\n * seconds in the script's range. Besides the lines (the opening line, each beat's line, the\n * closing line), one of the two keys of a plan the app reads (the other: whether each beat carries\n * a screenshot, `ugcPlanScreenshotCount`): a script that hands on its saved plan is priced at the\n * plan's length, and shows it, never at the length setting, which may have changed since. Takes\n * the plan or its wire (a JSON string); undefined for anything that is not a plan carrying a length.\n */\nexport function ugcPlanLengthSec(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value) return undefined\n const sec = value.targetDurationSec\n return typeof sec === \"number\" && Number.isInteger(sec) && sec >= UGC_SCRIPT_MIN_TARGET_SEC && sec <= UGC_SCRIPT_MAX_TARGET_SEC ? sec : undefined\n}\n\n/**\n * How many of a saved UGC plan's beats carry a screenshot: the screenshot cards the plan was\n * written with. Read beat by beat: a beat carries one when its `screenshot` is an object, as the\n * plan's own screenshots are (whatever it names); a beat that is not an object, or whose screenshot\n * is anything else, carries none — and never makes the rest unreadable. A plan whose beats carry\n * none is a talking-head plan (0). Read, like its length, so a script that hands on its saved plan\n * is priced at the screenshots that plan holds, never at the script's wires, which may have changed\n * since. Takes the plan or its wire (a JSON string); undefined only for a plan with no beats to read\n * and for anything that is not a plan.\n */\nexport function ugcPlanScreenshotCount(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value || !Array.isArray(value.beats)) return undefined\n return value.beats.filter((beat) => isObject(beat) && isObject(beat.screenshot)).length\n}\n\n/** A saved plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction savedPlanOf(plan: unknown): Obj | undefined {\n let value: unknown = plan\n if (typeof value === \"string\") {\n try {\n value = JSON.parse(value)\n } catch {\n return undefined\n }\n }\n return isObject(value) ? value : undefined\n}\n/** A string with something in it; an empty or blank field or input counts as absent. */\nconst filled = (x: unknown): string | undefined => (typeof x === \"string\" && x.trim() !== \"\" ? x : undefined)\n\n/**\n * What an edge from a UGC node reads, on both engines: the value of the pip it leaves — an edge\n * with no source handle reads the node's primary output — from the node's outputs by pip. Only a\n * pip the outputs hold as a string (\"\" included: an empty transcript is a value); an inherited\n * key or a non-string is no value.\n */\nexport function ugcPipValue(outputs: unknown, sourceType: string, sourceHandle?: string | null): string | undefined {\n const pip = sourceHandle || (Object.hasOwn(UGC_PRIMARY_HANDLE, sourceType) ? UGC_PRIMARY_HANDLE[sourceType] : undefined)\n if (pip === undefined || !isObject(outputs) || !Object.hasOwn(outputs, pip)) return undefined\n const value = outputs[pip]\n return typeof value === \"string\" ? value : undefined\n}\n\n/**\n * A UGC wire (a JSON string or an object) → its value when it is an object with `v: 1`.\n * Another `v` → the version message. Anything that is not a UGC wire at all (nothing\n * connected, not JSON, no `v`) → `unreadable`, which a node words as the input it needs.\n */\nexport function readUgcWire(raw: unknown, unreadable: string = UGC_VERSION_MESSAGE): { value: Record<string, unknown> } | { error: string } {\n let parsed: unknown = raw\n if (typeof raw === \"string\") {\n try {\n parsed = JSON.parse(raw)\n } catch {\n return { error: unreadable }\n }\n }\n if (!isObject(parsed) || parsed.v === undefined) return { error: unreadable }\n if (parsed.v !== 1) return { error: UGC_VERSION_MESSAGE }\n return { value: parsed }\n}\n\n/** The route's `{ error: { code, message } }` (or a framework error's top-level `message`). */\nfunction routeErrorOf(body: string): { code?: string; message?: string } {\n let parsed: unknown\n try {\n parsed = JSON.parse(body)\n } catch {\n return {}\n }\n if (!isObject(parsed)) return {}\n if (isObject(parsed.error)) {\n const { code, message } = parsed.error\n return { code: typeof code === \"string\" ? code : undefined, message: filled(message) }\n }\n return { message: filled(parsed.message) }\n}\n\n/**\n * A failed UGC call → the sentence the node fails with. A 404 that names no error code is\n * the router's (the route is not registered here) → the Cloud sentence; a route's own 404\n * names a code and keeps its message. `minor_age_refused` → the adults-only sentence. A 4xx\n * or 503 → the route's message. Anything else → \"UGC step failed (<status>)\".\n */\nexport function ugcFailure(status: number, body: string): string {\n const error = routeErrorOf(body)\n if (status === 404 && error.code === undefined) return UGC_NOT_SERVED_MESSAGE\n if (error.code === \"minor_age_refused\") return MINOR_AGE_MESSAGE\n if ((status === 503 || (status >= 400 && status < 500)) && error.message) return error.message\n return `UGC step failed (${status})`\n}\n\n// ── UGC Creator ──────────────────────────────────────────────────────────────\n\n/**\n * The pickers whose own set fields shape a sampled creator: the picker types UGC Creator's\n * `pickers` input takes (the route takes no other). One list for the editor's connection rule\n * and both engines' input resolvers.\n */\nexport const UGC_CREATOR_PICKER_TYPES: ReadonlySet<string> = new Set([\"person\", \"styling\", \"setting\", \"lighting\"])\n\n/** The UGC Creator node-data keys its request body reads. */\nexport interface UgcCreatorFields {\n readonly source?: string\n readonly gender?: string\n readonly photoUrl?: string\n readonly categoryOverride?: string\n readonly seed?: number\n readonly keepResult?: boolean\n readonly result?: Readonly<Record<string, unknown>>\n /** The options a draw left waiting for the pick (run state): read only for `previous`. */\n readonly candidates?: unknown\n}\n\n/** The traits of the latest creator the person saw: the first waiting option's, else the last result's (Keep off). */\nfunction previousTraits(data: UgcCreatorFields): unknown {\n if (ugcPickPending(data)) {\n const first: unknown = (data.candidates as readonly unknown[])[0]\n const record = isObject(first) ? first.record : undefined\n return isObject(record) ? record.traits : undefined\n }\n return !data.keepResult && isObject(data.result) ? data.result.traits : undefined\n}\n\n/** The wired pickers that set a field (their own fields, as the resolver read them); undefined when none did. */\nfunction setPickers(pickers: Record<string, Record<string, unknown>> | undefined): Record<string, Record<string, unknown>> | undefined {\n if (!pickers) return undefined\n const set = Object.entries(pickers).filter(([, fields]) => isObject(fields) && Object.keys(fields).length > 0)\n return set.length > 0 ? Object.fromEntries(set) : undefined\n}\n\n/**\n * The `/v1/ugc/creator` body. A photo: the wired photo, else the node's own. A sampled\n * creator: the product category (the node's override, else the wired one), the pickers that\n * set a field, the node's seed, and the traits of the latest creator the person saw as\n * `previous`, so the next one differs: the first option waiting for the pick, else — on a\n * re-run that does not keep the result — the last creator's. Refuses before any call.\n */\nexport function ugcCreatorBody(input: {\n data: UgcCreatorFields\n photoUrl?: string\n category?: string\n pickers?: Record<string, Record<string, unknown>>\n}): { body: Record<string, unknown> } | { error: string } {\n const { data } = input\n const gender = data.gender\n if (gender !== \"woman\" && gender !== \"man\") return { error: NEEDS_GENDER }\n if (data.source === \"photo\") {\n const imageUrl = filled(input.photoUrl) ?? filled(data.photoUrl)\n if (!imageUrl) return { error: NEEDS_PHOTO }\n return { body: { source: { kind: \"photo\", imageUrl, gender } } }\n }\n const productCategory = filled(data.categoryOverride) ?? filled(input.category)\n if (!productCategory) return { error: NEEDS_CATEGORY }\n const pickers = setPickers(input.pickers)\n const traits = previousTraits(data)\n return {\n body: {\n ...(typeof data.seed === \"number\" ? { seed: data.seed } : {}),\n source: {\n kind: \"sampled\",\n gender,\n productCategory,\n ...(pickers ? { pickers } : {}),\n ...(isObject(traits) ? { previous: traits } : {}),\n },\n },\n }\n}\n\n/**\n * The creator the node hands on: the record (`creator`, v1) and its first image (`image`).\n * `identityImages` are the images of the candidate the node hands on — the picked one where\n * a person picked. The record copies the listed fields only, so `candidates`, `fallback`,\n * `pick` and `image` never reach the `creator` wire.\n */\nexport function ugcCreatorOutputs(answer: Record<string, unknown>, identityImages: readonly string[]): { outputs: UgcOutputs; imageUrl: string; record: Record<string, unknown> } {\n const record: Record<string, unknown> = {\n v: 1,\n kind: answer.kind,\n gender: answer.gender,\n identityImages: [...identityImages],\n traits: answer.traits ?? null,\n seed: answer.seed ?? null,\n promptsVersion: answer.promptsVersion,\n productCategory: answer.productCategory ?? null,\n }\n const imageUrl = identityImages[0] ?? \"\"\n return { outputs: { creator: JSON.stringify(record), ...(imageUrl ? { image: imageUrl } : {}) }, imageUrl, record }\n}\n\n/** One builder call as the app runs it: `tool` and `args`, nothing else (a candidate's other keys, its model included, are never read). */\nexport interface UgcCreatorCall { readonly tool: string; readonly args: Readonly<Record<string, unknown>> }\n\n/** What a creator answer asks the node to render. */\nexport interface UgcCreatorCandidateCalls {\n /** Every candidate's image call, the primary first. One call (`image`) for an answer from before candidates; none for a photo. */\n readonly calls: readonly UgcCreatorCall[]\n /** The round's one moderation fallback: it runs once, and only when every candidate the run rendered was blocked. */\n readonly fallback: UgcCreatorCall | null\n /** \"user\": a person picks among `calls` where one can be asked; \"primary\": `calls[0]` alone; null: nothing to render (a photo). */\n readonly pick: \"user\" | \"primary\" | null\n}\n\nconst callOf = (raw: unknown): UgcCreatorCall | undefined => {\n if (!raw || typeof raw !== \"object\") return undefined\n const { tool, args } = raw as { tool?: unknown; args?: unknown }\n if (typeof tool !== \"string\" || !args || typeof args !== \"object\" || Array.isArray(args)) return undefined\n return { tool, args: args as Readonly<Record<string, unknown>> }\n}\nconst fallbackOf = (image: unknown): unknown => (image && typeof image === \"object\" ? (image as { fallback?: unknown }).fallback : undefined)\n\n/**\n * A `/v1/ugc/creator` answer's image calls. Content-free: reads `image` (`tool`, `args`,\n * `fallback`), `candidates[].tool|args`, `fallback` and `pick.how` — never a candidate's\n * model. An answer without `candidates` (an older builder) renders `image` alone, as before.\n */\nexport function ugcCreatorCandidates(answer: Readonly<Record<string, unknown>>): UgcCreatorCandidateCalls | { readonly error: string } {\n const listed = answer.candidates\n const noList = listed === undefined || listed === null || (Array.isArray(listed) && listed.length === 0)\n const noImage = answer.image === undefined || answer.image === null\n if (noList && noImage) return { calls: [], fallback: null, pick: null }\n if (noList) {\n const image = callOf(answer.image)\n if (!image) return { error: UGC_NEWER_APP_MESSAGE }\n return { calls: [image], fallback: callOf(fallbackOf(answer.image)) ?? null, pick: \"primary\" }\n }\n if (!Array.isArray(listed)) return { error: UGC_NEWER_APP_MESSAGE }\n const calls = listed.map(callOf)\n if (calls.some((c) => c === undefined)) return { error: UGC_NEWER_APP_MESSAGE }\n const how = (answer.pick as { how?: unknown } | null | undefined)?.how\n return {\n calls: calls as UgcCreatorCall[],\n fallback: callOf(answer.fallback) ?? callOf(fallbackOf(answer.image)) ?? null,\n pick: how === \"user\" && calls.length > 1 ? \"user\" : \"primary\",\n }\n}\n\n/** The calls a run renders: every candidate where a person is there to pick, else the primary alone. */\nexport function ugcCreatorCallsToRender(c: UgcCreatorCandidateCalls, opts: { readonly personPicks: boolean }): readonly UgcCreatorCall[] {\n return opts.personPicks && c.pick === \"user\" ? c.calls : c.calls.slice(0, 1)\n}\n\n/** One rendered candidate that passed its checks, kept on the node until the person picks (run state, never a wire). */\nexport interface UgcCreatorCandidate { readonly imageUrl: string; readonly record: Readonly<Record<string, unknown>> }\n\nexport function ugcCreatorCandidate(answer: Readonly<Record<string, unknown>>, images: readonly string[]): UgcCreatorCandidate {\n const out = ugcCreatorOutputs(answer as Record<string, unknown>, images)\n return { imageUrl: out.imageUrl, record: out.record }\n}\n\n/** A UGC Creator run output that waits for the person's pick: two or more options (`ugcCandidates`). */\nexport function ugcAwaitsPick(output: unknown): boolean {\n const candidates = isObject(output) ? output.ugcCandidates : undefined\n return Array.isArray(candidates) && candidates.length >= 2\n}\n\n/** The person's pick, read back from node data (untrusted): a stale index, a foreign list or another version is refused. */\nexport function ugcCreatorPick(candidates: unknown, index: number):\n { readonly result: Readonly<Record<string, unknown>>; readonly outputs: UgcOutputs; readonly imageUrl: string } | { readonly error: string } {\n const entry: unknown = Array.isArray(candidates) && Number.isInteger(index) && index >= 0 ? candidates[index] : undefined\n const imageUrl = (entry as { imageUrl?: unknown } | undefined)?.imageUrl\n const record = (entry as { record?: unknown } | undefined)?.record\n if (typeof imageUrl !== \"string\" || !record || typeof record !== \"object\" || Array.isArray(record)) return { error: UGC_PICK_GONE_MESSAGE }\n const r = record as Record<string, unknown>\n if (r.v !== 1) return { error: UGC_VERSION_MESSAGE }\n if (!Array.isArray(r.identityImages) || r.identityImages[0] !== imageUrl) return { error: UGC_PICK_GONE_MESSAGE }\n return { result: r, outputs: { creator: JSON.stringify(r), image: imageUrl }, imageUrl }\n}\n\n// ── UGC Script ───────────────────────────────────────────────────────────────\n\n/** The languages a UGC script can be written in: the node's choice (`UgcScriptData.language`). */\nexport const UGC_SCRIPT_LANGUAGES = [\"en\", \"he\"] as const\nexport type UgcScriptLanguage = (typeof UGC_SCRIPT_LANGUAGES)[number]\n\n/**\n * The `/v1/ugc/script` body: the product name or website (required), the screenshot slots\n * in card order with the empty ones dropped, the product image when set, the target length\n * (`UGC_SCRIPT_DEFAULT_TARGET_SEC` when the node holds no number), and the language (the\n * node's choice; English when it holds none or one this app does not know).\n */\nexport function ugcScriptBody(input: {\n site?: string\n screenshots: ReadonlyArray<string | undefined>\n productImage?: string\n targetDurationSec?: number\n language?: unknown\n}): { body: Record<string, unknown> } | { error: string } {\n const site = filled(input.site)?.trim()\n if (!site) return { error: NEEDS_SITE }\n const productImage = filled(input.productImage)\n return {\n body: {\n site,\n screenshots: input.screenshots.filter((s): s is string => filled(s) !== undefined),\n ...(productImage ? { productImage } : {}),\n targetDurationSec: typeof input.targetDurationSec === \"number\" ? input.targetDurationSec : UGC_SCRIPT_DEFAULT_TARGET_SEC,\n language: (UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(input.language) ? input.language : \"en\",\n },\n }\n}\n\n/** A finished UGC Script job → `plan` (the plan, v1) and `category` (text). */\nexport function ugcScriptOutputs(outputData: Record<string, unknown>): UgcOutputs {\n const plan = outputData.plan\n const category = filled(outputData.productCategory)\n return {\n ...(isObject(plan) ? { plan: JSON.stringify({ v: 1, ...plan }) } : {}),\n ...(category ? { category } : {}),\n }\n}\n\n/** UGC Script's last result, as the node holds it. */\nexport type UgcScriptResult = {\n plan: Record<string, unknown>\n productCategory: string\n warnings: unknown[]\n notes: string[]\n rounds: number\n}\n\n/** A finished UGC Script job → the node's `result`, written the same by both engines; none without a plan. */\nexport function ugcScriptResult(outputData: Readonly<Record<string, unknown>>): UgcScriptResult | undefined {\n const { plan, productCategory, warnings, notes, rounds } = outputData\n if (!isObject(plan)) return undefined\n return {\n plan,\n productCategory: filled(productCategory) ?? \"\",\n warnings: Array.isArray(warnings) ? [...warnings] : [],\n notes: Array.isArray(notes) ? notes.filter((n): n is string => typeof n === \"string\") : [],\n rounds: typeof rounds === \"number\" && Number.isFinite(rounds) ? rounds : 0,\n }\n}\n\n// ── Kept results ─────────────────────────────────────────────────────────────\n\n/**\n * What a UGC Creator or UGC Script with Keep on hands on instead of running: the outputs of\n * the result it holds. Null — the node runs — when Keep is off, when the result holds nothing\n * to hand on (a creator without its image, a script without its plan), and for a creator whose\n * options wait for a pick, whatever Keep says. The creator record goes on unread; whoever reads\n * it refuses another version.\n */\nexport function ugcKeptOutputs(type: \"ugc-creator\" | \"ugc-script\", data: Readonly<Record<string, unknown>>): UgcOutputs | null {\n if (type === \"ugc-creator\" && ugcPickPending(data)) return null\n const result = data.keepResult === true ? data.result : undefined\n if (!isObject(result)) return null\n if (type === \"ugc-creator\") {\n const image = Array.isArray(result.identityImages) ? filled(result.identityImages[0]) : undefined\n return image ? { creator: JSON.stringify(result), image } : null\n }\n if (type === \"ugc-script\") return isObject(result.plan) ? ugcScriptOutputs(result) : null\n return null\n}\n\n// ── UGC Clips ────────────────────────────────────────────────────────────────\n\n/** The `/v1/ugc/clips` canvas body: the plan, the creator's gender, traits and images, and the picked voice. */\nexport function ugcClipsBody(input: { planWire: unknown; creatorWire: unknown; voiceId?: string }): { body: Record<string, unknown> } | { error: string } {\n const plan = readUgcWire(input.planWire, NEEDS_PLAN)\n if (\"error\" in plan) return plan\n const creator = readUgcWire(input.creatorWire, UGC_CREATOR_MISSING_MESSAGE)\n if (\"error\" in creator) return creator\n const voiceId = filled(input.voiceId)\n return {\n body: {\n plan: plan.value,\n gender: creator.value.gender,\n traits: creator.value.traits ?? null,\n identityImages: creator.value.identityImages,\n surface: \"canvas\",\n ...(voiceId ? { voiceId } : {}),\n },\n }\n}\n\n/**\n * The `/v1/ugc/clips` answer → the tickets (one per clip, as JSON strings), `clips` (the\n * first), `plan-out` (`{ v: 1, plan, transcribeArgs }` for UGC Cards), `transcript`, whether\n * the plan has cards, and whether the clips go through UGC Finish's job (`finishes`: the plan-out\n * carries a finish call, which is what UGC Finish reads to run it). An answer with errors → \"The script needs changes: …\" with each\n * error and its fix; an answer without the parts UGC Cards needs fails here, before any clip\n * is paid for.\n */\nexport function ugcClipsOutputs(answer: Record<string, unknown>): { outputs: UgcOutputs; tickets: string[]; hasCards: boolean; finishes: boolean } | { error: string } {\n const errors = Array.isArray(answer.errors) ? answer.errors : []\n if (errors.length > 0) {\n const said = errors.flatMap((e) => (isObject(e) ? [filled(e.message), filled(e.fix)] : [])).filter((s): s is string => s !== undefined)\n return { error: said.length > 0 ? `${UGC_SCRIPT_NEEDS_CHANGES} ${said.join(\" \")}` : UGC_NEWER_APP_MESSAGE }\n }\n const { tickets, sizedPlan, transcript, speechCheckCall } = answer\n if (!Array.isArray(tickets) || tickets.length === 0 || !tickets.every(isObject) || !isObject(sizedPlan) || typeof transcript !== \"string\") {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n const wires = tickets.map((t) => JSON.stringify(t))\n // The speech check's arguments ride to UGC Cards' transcription unread (an answer without them: none).\n const transcribeArgs = isObject(speechCheckCall) && isObject(speechCheckCall.args) ? speechCheckCall.args : {}\n // A video cut from one recorded speech (the segmented lane) also hands UGC Finish its finish call's\n // arguments (the segments with their room), opaque; any other answer's plan-out is unchanged.\n const finish = isObject(answer.finish) && isObject(answer.finish.args) ? { finish: answer.finish.args } : {}\n return {\n outputs: { clips: wires[0]!, \"plan-out\": JSON.stringify({ v: 1, plan: sizedPlan, transcribeArgs, ...finish }), transcript },\n tickets: wires,\n hasCards: answer.hasCards === true,\n finishes: \"finish\" in finish,\n }\n}\n\n// ── UGC Clip ─────────────────────────────────────────────────────────────────\n\n/**\n * The `/v1/ugc/clip` body for one ticket: the ticket, `nonce` = how many times this clip was\n * re-rendered (`rerender[\"<clip number>\"]`, else 0) and `runKey` when one is given.\n */\nexport function ugcClipBody(input: { ticketWire: unknown; rerender?: Readonly<Record<string, number>>; runKey?: string }):\n { body: Record<string, unknown>; clipNumber: number; durationSec: number } | { error: string } {\n const read = readUgcWire(input.ticketWire, NEEDS_TICKET)\n if (\"error\" in read) return read\n const ticket = read.value\n const { index, durationSec } = ticket\n if (typeof index !== \"number\" || !Number.isInteger(index) || index < 0) return { error: NEEDS_TICKET }\n if (typeof durationSec !== \"number\" || !Number.isFinite(durationSec) || durationSec <= 0) return { error: NEEDS_TICKET }\n const clipNumber = index + 1\n const count = input.rerender?.[String(clipNumber)]\n const nonce = typeof count === \"number\" && Number.isInteger(count) && count >= 0 ? count : 0\n const runKey = filled(input.runKey)\n return { body: { ticket, nonce, ...(runKey ? { runKey } : {}) }, clipNumber, durationSec }\n}\n\n/**\n * A finished UGC Clip job (`{ videoUrl, durationSec, clipWarnings, … }`) → `video-out`, the\n * clip's real length (null when unknown) and its warnings ([] when it has none).\n */\nexport function ugcClipOutputs(outputData: Record<string, unknown>): { outputs: UgcOutputs; videoUrl: string; durationSec: number | null; clipWarnings: string[] } {\n const videoUrl = filled(outputData.videoUrl) ?? \"\"\n const meta = fanOutItemMeta(outputData)\n return { outputs: videoUrl ? { \"video-out\": videoUrl } : {}, videoUrl, durationSec: meta.durationSec, clipWarnings: [...meta.warnings] }\n}\n\n/**\n * What a list read (a Bundle edge, a fold) takes from a UGC Clip's saved data, on both engines:\n * its last fanned-out batch — one take per clip, in clip order — when its last run was one; else\n * exactly the take it shows (its active result, else its video). Never the earlier takes it keeps:\n * a video of one clip (one ticket, so no fan-out) would join every take. A single run clears the\n * batch (the editor's job patch), so a batch held is always the last run's. Undefined when it holds\n * no take at all.\n */\nexport function ugcClipSavedList(data: unknown): string[] | undefined {\n if (!isObject(data)) return undefined\n const batch = Array.isArray(data.__listResults) ? data.__listResults.filter((u): u is string => typeof u === \"string\" && u !== \"\") : []\n if (batch.length > 0) return batch\n const results = Array.isArray(data.generatedResults) ? data.generatedResults : []\n const index = typeof data.activeResultIndex === \"number\" && Number.isInteger(data.activeResultIndex) ? data.activeResultIndex : 0\n const active = results[index]\n const url = (isObject(active) ? filled(active.url) : undefined) ?? filled(data.generatedVideoUrl)\n return url ? [url] : undefined\n}\n\n// ── UGC Cards ────────────────────────────────────────────────────────────────\n\n/**\n * UGC Cards' two timing jobs on the joined video, and the plan they time. The plan input must\n * be UGC Clips' `{ v: 1, plan, transcribeArgs }`; anything else is refused before either job.\n * The transcription spreads `transcribeArgs` unread, then sets the node's own fields last, so\n * the wire can add a language but never change the provider or the word timings.\n */\nexport function ugcCardsJobs(input: { planOutWire: unknown; videoUrl?: string; transcript?: string }): {\n alignment: { path: \"/v1/forced-alignment\"; body: Record<string, unknown> }\n transcribe: { path: \"/v1/transcribe\"; body: Record<string, unknown> }\n plan: Record<string, unknown>\n} | { error: string } {\n const read = readUgcWire(input.planOutWire, NEEDS_PLAN_OUT)\n if (\"error\" in read) return read\n const { plan, transcribeArgs } = read.value\n if (!isObject(plan) || !isObject(transcribeArgs)) return { error: NEEDS_PLAN_OUT }\n const videoUrl = filled(input.videoUrl)\n if (!videoUrl) return { error: NEEDS_VIDEO }\n // An empty transcript is what UGC Clips said, not a missing input: it goes on as it came.\n const transcript = input.transcript\n if (typeof transcript !== \"string\") return { error: NEEDS_TRANSCRIPT }\n return {\n alignment: { path: \"/v1/forced-alignment\", body: { audioUrl: videoUrl, transcript } },\n transcribe: { path: \"/v1/transcribe\", body: { ...transcribeArgs, audioUrl: videoUrl, provider: DEFAULT_TRANSCRIBE_NODE_PROVIDER, wordTimestamps: true } },\n plan,\n }\n}\n\n/**\n * The `/v1/ugc/cards` canvas body: the plan, the video, whichever timing came back as a list,\n * the timing jobs that failed, and the clips' notes.\n */\nexport function ugcCardsBody(input: {\n plan: Record<string, unknown>\n videoUrl: string\n alignment?: unknown\n words?: unknown\n failed: ReadonlyArray<\"alignment\" | \"words\">\n clipNotes: ReadonlyArray<ClipNote>\n}): Record<string, unknown> {\n return {\n surface: \"canvas\",\n plan: input.plan,\n videoUrl: input.videoUrl,\n ...(Array.isArray(input.alignment) ? { alignment: input.alignment } : {}),\n ...(Array.isArray(input.words) ? { words: input.words } : {}),\n failed: [...input.failed],\n clipNotes: [...input.clipNotes],\n }\n}\n\n/** The caption plan when nothing could be timed: Add Captions renders no captions from it. */\nconst EMPTY_CAPTION_PLAN: CaptionPlan = { v: 1, hookText: \"\", hookEndMs: 0, bodyEndMs: 0, captions: [] }\n\n/** The `/v1/ugc/cards` answer → `layerPlan`, `captionPlan` (v1; the empty plan when untimed) and `report` (one line per sentence). */\nexport function ugcCardsOutputs(answer: Record<string, unknown>): UgcOutputs {\n const timing = answer.captionTiming\n const report = answer.report\n const lines = isObject(report) && Array.isArray(report.lines) ? report.lines.filter((l): l is string => typeof l === \"string\") : []\n return {\n layerPlan: JSON.stringify(Array.isArray(answer.layerPlan) ? answer.layerPlan : []),\n captionPlan: JSON.stringify(isObject(timing) ? { v: 1, ...timing } : EMPTY_CAPTION_PLAN),\n report: lines.join(\"\\n\"),\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/fan-out-meta.ts","../src/ugc-run-state.ts","../src/ugc-node-wires.ts"],"names":[],"mappings":";;;AAKO,SAAS,eAAe,MAAA,EAA8F;AAC3H,EAAA,MAAM,IAAI,MAAA,EAAQ,YAAA;AAClB,EAAA,MAAM,IAAI,MAAA,EAAQ,WAAA;AAClB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,GAAI,CAAA,CAAE,MAAA,CAAO,CAAC,CAAA,KAAmB,OAAO,CAAA,KAAM,QAAQ,IAAI,EAAC;AAAA,IACpF,WAAA,EAAa,OAAO,CAAA,KAAM,QAAA,IAAY,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI;AAAA,GAC1E;AACF;AAGO,SAAS,aAAA,CAAc,MAAoE,MAAA,EAAqC;AACrI,EAAA,MAAM,IAAA,GAAO,IAAA,IAAQ,IAAA,CAAK,MAAA,GAAS,CAAA,GAAI,OAAO,MAAA,GAAS,CAAC,MAAM,CAAA,GAAI,EAAC;AACnE,EAAA,OAAO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AA,EAAM,GAAI,EAAC;AAAA,IAC3D,MAAA,EAAQ,CAAC,GAAG,KAAA,CAAM,MAAM,CAAA;AAAA,IACxB,SAAA,EAAW,CAAC,GAAG,KAAA,CAAM,SAAS;AAAA,GAChC;AACF;AAGA,IAAM,kBAAA,GAAkC,EAAE,CAAA,EAAG,CAAA,EAAG,QAAA,EAAU,EAAA,EAAI,SAAA,EAAW,CAAA,EAAG,SAAA,EAAW,CAAA,EAAG,QAAA,EAAU,EAAC,EAAE;AAGhG,SAAS,gBAAgB,MAAA,EAA6C;AAC3E,EAAA,MAAM,SAAS,MAAA,CAAO,aAAA;AACtB,EAAA,MAAM,SAAS,MAAA,CAAO,MAAA;AACtB,EAAA,MAAM,QAAQ,QAAA,CAAS,MAAM,KAAK,KAAA,CAAM,OAAA,CAAQ,OAAO,KAAK,CAAA,GAAI,MAAA,CAAO,KAAA,CAAM,OAAO,CAAC,CAAA,KAAmB,OAAO,CAAA,KAAM,QAAQ,IAAI,EAAC;AAClI,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,IAAA,CAAK,SAAA,CAAU,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO,SAAS,CAAA,GAAI,MAAA,CAAO,SAAA,GAAY,EAAE,CAAA;AAAA,IACjF,WAAA,EAAa,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,MAAM,CAAA,GAAI,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,MAAA,EAAO,GAAI,kBAAkB,CAAA;AAAA,IACvF,MAAA,EAAQ,KAAA,CAAM,IAAA,CAAK,IAAI;AAAA,GACzB;AACF","file":"chunk-VOWJCUMR.js","sourcesContent":["/** One fan-out item's notes: its warnings and its real length (UGC Clip). */\nexport interface FanOutItemMeta { readonly warnings: readonly string[]; readonly durationSec: number | null }\n/** One row of UGC Cards' `notes` input. */\nexport interface ClipNote { readonly clip: number; readonly warnings: readonly string[]; readonly durationSec?: number }\n\nexport function fanOutItemMeta(output: { clipWarnings?: unknown; durationSec?: unknown } | null | undefined): FanOutItemMeta {\n const w = output?.clipWarnings\n const d = output?.durationSec\n return {\n warnings: Array.isArray(w) ? w.filter((x): x is string => typeof x === \"string\") : [],\n durationSec: typeof d === \"number\" && Number.isFinite(d) && d > 0 ? d : null,\n }\n}\n\n/** Row-aligned meta (or one single output) → the notes UGC Cards reads, clip numbers from 1. */\nexport function clipNotesFrom(meta: ReadonlyArray<FanOutItemMeta | null | undefined> | undefined, single?: FanOutItemMeta): ClipNote[] {\n const rows = meta && meta.length > 0 ? meta : single ? [single] : []\n return rows.map((m, i) => ({\n clip: i + 1,\n warnings: m?.warnings ?? [],\n ...(typeof m?.durationSec === \"number\" ? { durationSec: m.durationSec } : {}),\n }))\n}\n","/** The UGC node types (Cloud only; served by a private plugin). */\nexport const UGC_NODE_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\", \"ugc-clips\", \"ugc-clip\", \"ugc-cards\", \"ugc-finish-clips\"])\n\n/** UGC Creator: the node-data key that holds a round's passing candidates until the person picks one (run state). */\nexport const UGC_CREATOR_CANDIDATES_KEY = \"candidates\"\n\n/** A run that would execute a UGC Creator whose options wait for the person's pick. */\nexport const UGC_PICK_FIRST_MESSAGE = \"Pick a creator first.\"\n\n/**\n * Per UGC type, the node-data keys that are a RUN's state, never a choice. A\n * published app's snapshot is readable by every runner, so publishing strips\n * them (the last plan, the clip tickets, the publisher's kept creator).\n *\n * UGC Creator's image (`generatedImageUrl`) goes from every creator, whatever its\n * source: after a My photo run it IS the author's photo, and a creator switched\n * to another source after such a run, or whose photo was removed, still holds it.\n * UGC Clip's takes and UGC Cards' Notes (`generatedText`, and `text`, the Notes\n * as a run hands them on) are the author's renders: a published node starts empty.\n *\n * A published snapshot is stripped through `stripUgcPublishState`\n * (@nodaro/render-rules), which also empties every run result a lane writes under\n * a generic name, every node made from the UGC video, and every node on a path\n * into a UGC Creator's photo input.\n */\nexport const UGC_NODE_RUN_STATE_KEYS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"result\", \"keepResult\", \"ugcOutputs\", UGC_CREATOR_CANDIDATES_KEY, \"optionFailed\", \"generatedImageUrl\"],\n // `exampleLines`: a template's example run, shown until the node's own first script (display only).\n \"ugc-script\": [\"result\", \"keepResult\", \"ugcOutputs\", \"exampleLines\"],\n \"ugc-clips\": [\"result\", \"quote\", \"__listResults\", \"ugcOutputs\"],\n \"ugc-clip\": [\n \"warnings\", \"rerender\", \"rerenderPending\", \"__listResults\", \"__listResultMeta\", \"clipWarnings\", \"durationSec\", \"ugcOutputs\",\n \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\",\n ],\n \"ugc-cards\": [\"result\", \"ugcOutputs\", \"generatedText\", \"text\"],\n \"ugc-finish-clips\": [\"ugcOutputs\", \"__listResults\", \"__listResultMeta\", \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\"],\n}\n\n/**\n * The ONLY UGC keys a run request's `inputOverrides` may set — an allow-list,\n * so a run-state field added later is locked without anyone listing it.\n *\n * No UGC type may gain a `LEGACY_EXPOSED_FIELD_KEYS` row: the lock reads the\n * stored key, before that table renames it.\n */\nexport const UGC_OVERRIDABLE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"source\", \"gender\", \"photoUrl\"],\n \"ugc-script\": [\"targetDurationSec\", \"language\"],\n \"ugc-clips\": [],\n \"ugc-clip\": [],\n \"ugc-cards\": [],\n \"ugc-finish-clips\": [],\n}\n\nconst KEEP_RESULT_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\"])\n\n/** UGC Creator holds options for the person to pick: the ones a run drew, or the ones a credits stop kept. */\nexport function ugcPickPending(data: unknown): boolean {\n const candidates = data && typeof data === \"object\" ? (data as Record<string, unknown>)[UGC_CREATOR_CANDIDATES_KEY] : undefined\n return Array.isArray(candidates) && candidates.length > 0\n}\n\n/**\n * A run that would execute a UGC Creator whose options wait is refused (\"Pick a creator first.\"),\n * except that creator's own re-draw. One rule for the editor's check before a run and the\n * orchestrator's.\n */\nexport function ugcRunWaitsForPick(\n runNodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,\n opts: { readonly redrawId?: string } = {},\n): boolean {\n return runNodes.some((n) => n.type === \"ugc-creator\" && n.id !== opts.redrawId && ugcPickPending(n.data))\n}\n\n/**\n * Per UGC type, the author's own content a published snapshot never carries: UGC Creator's photo\n * of a person (`photoUrl`). A choice, not run state — so it stays on the author's own workflow —\n * but a runner gives their own photo (or the run is refused for want of one) and a template's\n * cloner adds theirs.\n */\nexport const UGC_PUBLISH_PRIVATE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"photoUrl\"],\n}\n\n/**\n * The UGC types' own strip: a copy of `nodes` with every UGC node's run state and the author's own\n * photo removed (and `keepResult: false`). Other nodes are returned as they are. Publishing, a\n * share link's view and a viewer's run go through `stripUgcPublishState` (@nodaro/render-rules),\n * which starts here.\n */\nexport function stripUgcRunState<T extends { type?: unknown; data?: unknown }>(nodes: readonly T[]): T[] {\n return nodes.map((node) => {\n const type = typeof node.type === \"string\" ? node.type : \"\"\n if (!UGC_NODE_TYPES.has(type) || !node.data || typeof node.data !== \"object\") return node\n const data: Record<string, unknown> = { ...(node.data as Record<string, unknown>) }\n for (const key of UGC_NODE_RUN_STATE_KEYS[type] ?? []) delete data[key]\n for (const key of UGC_PUBLISH_PRIVATE_FIELDS[type] ?? []) delete data[key]\n if (KEEP_RESULT_TYPES.has(type)) data.keepResult = false\n return { ...node, data }\n })\n}\n\n/** Every override entry that would set a non-overridable key on a UGC node, in node then key order. Pure. */\nexport function findUgcLockedFields(\n nodes: ReadonlyArray<{ id: string; type?: string }> | null | undefined,\n inputOverrides: Record<string, Record<string, unknown>> | null | undefined,\n): Array<{ nodeId: string; nodeType: string; field: string }> {\n if (!nodes || !inputOverrides) return []\n const found: Array<{ nodeId: string; nodeType: string; field: string }> = []\n for (const node of nodes) {\n const type = node?.type\n if (typeof type !== \"string\" || !UGC_NODE_TYPES.has(type)) continue\n const allowed = UGC_OVERRIDABLE_FIELDS[type] ?? []\n const fields = inputOverrides[node.id]\n if (!fields || typeof fields !== \"object\") continue\n for (const field of Object.keys(fields)) {\n if (!allowed.includes(field)) found.push({ nodeId: String(node.id), nodeType: type, field })\n }\n }\n return found\n}\n","/**\n * The UGC node wires: every request body the five UGC nodes send and every\n * output they hand on, as ONE pure implementation that both engines (the\n * workflow orchestrator and the editor) call, so the two can never disagree.\n *\n * Content-free. A creator record is read only for `v`, `gender` and\n * `identityImages`, a plan only for `v`, a clip ticket only for `v`, `index`\n * and `durationSec`; every other key is opaque and passes through as it came.\n * Every UGC-private JSON a node emits carries `v: 1`, and a wire with another\n * `v` is refused, never guessed at.\n */\nimport type { CaptionPlan } from \"./caption-plan.js\"\nimport { fanOutItemMeta, type ClipNote } from \"./fan-out-meta.js\"\nimport { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from \"./model-constants.js\"\nimport { ugcPickPending } from \"./ugc-run-state.js\"\n\n/** A UGC call that reached a deployment without the UGC routes (the router's 404). */\nexport const UGC_NOT_SERVED_MESSAGE = \"UGC videos are a Nodaro Cloud feature and are not served on this deployment.\"\n/** A wire whose `v` this app does not read. */\nexport const UGC_VERSION_MESSAGE = \"This workflow was made with a newer version of the UGC nodes.\"\n/** An answer this app cannot run: a tool it does not know, or a shape it cannot read. */\nexport const UGC_NEWER_APP_MESSAGE = \"This step needs a newer app version.\"\n/** A creator pick whose options are gone (another run replaced them, or they were never this node's). */\nexport const UGC_PICK_GONE_MESSAGE = \"These creator options are no longer available. Run UGC Creator again.\"\n/** UGC Clips with no creator on its creator input (UGC Creator has not run, or waits for a pick). */\nexport const UGC_CREATOR_MISSING_MESSAGE = \"UGC Creator has no creator yet. Run it, or pick one of its options.\"\n/** UGC Script's target length in seconds when the node holds none: the node's default (the route requires a length). */\nexport const UGC_SCRIPT_DEFAULT_TARGET_SEC = 15\n/** The range of a UGC script's length, in whole seconds: the script route's, and a plan's own. */\nexport const UGC_SCRIPT_MIN_TARGET_SEC = 4\nexport const UGC_SCRIPT_MAX_TARGET_SEC = 300\n\nconst MINOR_AGE_MESSAGE = \"That age can't be used: UGC creators are adults only.\"\nconst NEEDS_GENDER = \"Choose woman or man.\"\nconst NEEDS_PHOTO = \"Connect or upload a photo of yourself.\"\nconst NEEDS_CATEGORY = \"Run UGC Script first, or pick a product category.\"\nconst NEEDS_SITE = \"Add the product name or website.\"\n/** The opening of the sentence UGC Clips fails with when the plugin refuses the script: \"<this> <each error and its fix>\". */\nexport const UGC_SCRIPT_NEEDS_CHANGES = \"The script needs changes:\"\nconst NEEDS_PLAN_OUT = \"Connect the Script (sized) output of UGC Clips.\"\nconst NEEDS_PLAN = \"Connect the Script output of UGC Script.\"\nconst NEEDS_TICKET = \"Connect the Clips output of UGC Clips.\"\nconst NEEDS_VIDEO = \"Connect the joined video.\"\nconst NEEDS_TRANSCRIPT = \"Connect the Transcript output of UGC Clips.\"\n/**\n * A run of a video whose clips are cut from one recorded speech, on a graph with no UGC Finish on this UGC\n * Clips' Script (sized) output: refused before anything is spent.\n */\nexport const UGC_NEEDS_FINISH_MESSAGE = \"Add a UGC Finish node after UGC Clip, and connect UGC Clips' Script (sized) output to it.\"\n/** UGC Finish with nothing on its clips input. */\nexport const UGC_FINISH_NEEDS_CLIPS_MESSAGE = \"Connect the Video output of UGC Clip.\"\n/** UGC Finish's job answered that a clip does not follow its speech (each clip checks itself first, so this is rare). */\nexport const UGC_FINISH_NOT_READY_MESSAGE = \"A clip did not follow its speech. Re-render it from the UGC Clip node and run again.\"\n/**\n * A video cut from one recorded speech whose clips, priced once the speech is split, would hold more\n * than the run was checked for before it started: the run stops at UGC Clips, before any clip renders.\n */\nexport const UGC_OVER_HOLD_MESSAGE =\n \"The clips for this recording would cost more than this run was checked for, so none was rendered. Run UGC Clips again to record the speech again.\"\n\n/**\n * Every fixed sentence a UGC node fails with, by id: the English both engines write on the node.\n * The editor shows each in the person's language by its id. Not listed: the sentence that opens\n * with `UGC_SCRIPT_NEEDS_CHANGES` (the plugin's own words finish it), a route's own message, and\n * \"UGC step failed (<status>)\".\n */\nexport const UGC_NODE_MESSAGES = Object.freeze({\n notServed: UGC_NOT_SERVED_MESSAGE,\n version: UGC_VERSION_MESSAGE,\n newerApp: UGC_NEWER_APP_MESSAGE,\n pickGone: UGC_PICK_GONE_MESSAGE,\n creatorMissing: UGC_CREATOR_MISSING_MESSAGE,\n minorAge: MINOR_AGE_MESSAGE,\n needsGender: NEEDS_GENDER,\n needsPhoto: NEEDS_PHOTO,\n needsCategory: NEEDS_CATEGORY,\n needsSite: NEEDS_SITE,\n needsPlanOut: NEEDS_PLAN_OUT,\n needsPlan: NEEDS_PLAN,\n needsTicket: NEEDS_TICKET,\n needsVideo: NEEDS_VIDEO,\n needsTranscript: NEEDS_TRANSCRIPT,\n needsFinish: UGC_NEEDS_FINISH_MESSAGE,\n finishNeedsClips: UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n finishNotReady: UGC_FINISH_NOT_READY_MESSAGE,\n overHold: UGC_OVER_HOLD_MESSAGE,\n} as const)\n\n/** The id of a fixed sentence a UGC node fails with (`UGC_NODE_MESSAGES`). */\nexport type UgcNodeMessageId = keyof typeof UGC_NODE_MESSAGES\n\n/** UGC Script's screenshot inputs, in card order. */\nexport const UGC_SCREENSHOT_HANDLES: readonly string[] = [\n \"screenshot\", \"screenshot2\", \"screenshot3\", \"screenshot4\", \"screenshot5\", \"screenshot6\", \"screenshot7\", \"screenshot8\",\n]\n\n/** Per UGC type, the output an edge with no source handle reads. */\nexport const UGC_PRIMARY_HANDLE: Readonly<Record<string, string>> = {\n \"ugc-creator\": \"creator\",\n \"ugc-script\": \"plan\",\n \"ugc-clips\": \"clips\",\n \"ugc-clip\": \"video-out\",\n \"ugc-cards\": \"layerPlan\",\n \"ugc-finish-clips\": \"video-out\",\n}\n\n/** A UGC node's outputs: handle id → the value that handle carries (a JSON string, text or a URL). */\nexport type UgcOutputs = Readonly<Record<string, string>>\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/**\n * The length a saved UGC plan was written to: its own `targetDurationSec`, a whole number of\n * seconds in the script's range. Besides the lines (the opening line, each beat's line, the\n * closing line), one of the two keys of a plan the app reads (the other: whether each beat carries\n * a screenshot, `ugcPlanScreenshotCount`): a script that hands on its saved plan is priced at the\n * plan's length, and shows it, never at the length setting, which may have changed since. Takes\n * the plan or its wire (a JSON string); undefined for anything that is not a plan carrying a length.\n */\nexport function ugcPlanLengthSec(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value) return undefined\n const sec = value.targetDurationSec\n return typeof sec === \"number\" && Number.isInteger(sec) && sec >= UGC_SCRIPT_MIN_TARGET_SEC && sec <= UGC_SCRIPT_MAX_TARGET_SEC ? sec : undefined\n}\n\n/**\n * How many of a saved UGC plan's beats carry a screenshot: the screenshot cards the plan was\n * written with. Read beat by beat: a beat carries one when its `screenshot` is an object, as the\n * plan's own screenshots are (whatever it names); a beat that is not an object, or whose screenshot\n * is anything else, carries none — and never makes the rest unreadable. A plan whose beats carry\n * none is a talking-head plan (0). Read, like its length, so a script that hands on its saved plan\n * is priced at the screenshots that plan holds, never at the script's wires, which may have changed\n * since. Takes the plan or its wire (a JSON string); undefined only for a plan with no beats to read\n * and for anything that is not a plan.\n */\nexport function ugcPlanScreenshotCount(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value || !Array.isArray(value.beats)) return undefined\n return value.beats.filter((beat) => isObject(beat) && isObject(beat.screenshot)).length\n}\n\n/** A saved plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction savedPlanOf(plan: unknown): Obj | undefined {\n let value: unknown = plan\n if (typeof value === \"string\") {\n try {\n value = JSON.parse(value)\n } catch {\n return undefined\n }\n }\n return isObject(value) ? value : undefined\n}\n/** A string with something in it; an empty or blank field or input counts as absent. */\nconst filled = (x: unknown): string | undefined => (typeof x === \"string\" && x.trim() !== \"\" ? x : undefined)\n\n/**\n * What an edge from a UGC node reads, on both engines: the value of the pip it leaves — an edge\n * with no source handle reads the node's primary output — from the node's outputs by pip. Only a\n * pip the outputs hold as a string (\"\" included: an empty transcript is a value); an inherited\n * key or a non-string is no value.\n */\nexport function ugcPipValue(outputs: unknown, sourceType: string, sourceHandle?: string | null): string | undefined {\n const pip = sourceHandle || (Object.hasOwn(UGC_PRIMARY_HANDLE, sourceType) ? UGC_PRIMARY_HANDLE[sourceType] : undefined)\n if (pip === undefined || !isObject(outputs) || !Object.hasOwn(outputs, pip)) return undefined\n const value = outputs[pip]\n return typeof value === \"string\" ? value : undefined\n}\n\n/**\n * A UGC wire (a JSON string or an object) → its value when it is an object with `v: 1`.\n * Another `v` → the version message. Anything that is not a UGC wire at all (nothing\n * connected, not JSON, no `v`) → `unreadable`, which a node words as the input it needs.\n */\nexport function readUgcWire(raw: unknown, unreadable: string = UGC_VERSION_MESSAGE): { value: Record<string, unknown> } | { error: string } {\n let parsed: unknown = raw\n if (typeof raw === \"string\") {\n try {\n parsed = JSON.parse(raw)\n } catch {\n return { error: unreadable }\n }\n }\n if (!isObject(parsed) || parsed.v === undefined) return { error: unreadable }\n if (parsed.v !== 1) return { error: UGC_VERSION_MESSAGE }\n return { value: parsed }\n}\n\n/** The route's `{ error: { code, message } }` (or a framework error's top-level `message`). */\nfunction routeErrorOf(body: string): { code?: string; message?: string } {\n let parsed: unknown\n try {\n parsed = JSON.parse(body)\n } catch {\n return {}\n }\n if (!isObject(parsed)) return {}\n if (isObject(parsed.error)) {\n const { code, message } = parsed.error\n return { code: typeof code === \"string\" ? code : undefined, message: filled(message) }\n }\n return { message: filled(parsed.message) }\n}\n\n/**\n * A failed UGC call → the sentence the node fails with. A 404 that names no error code is\n * the router's (the route is not registered here) → the Cloud sentence; a route's own 404\n * names a code and keeps its message. `minor_age_refused` → the adults-only sentence. A 4xx\n * or 503 → the route's message. Anything else → \"UGC step failed (<status>)\".\n */\nexport function ugcFailure(status: number, body: string): string {\n const error = routeErrorOf(body)\n if (status === 404 && error.code === undefined) return UGC_NOT_SERVED_MESSAGE\n if (error.code === \"minor_age_refused\") return MINOR_AGE_MESSAGE\n if ((status === 503 || (status >= 400 && status < 500)) && error.message) return error.message\n return `UGC step failed (${status})`\n}\n\n// ── UGC Creator ──────────────────────────────────────────────────────────────\n\n/**\n * The pickers whose own set fields shape a sampled creator: the picker types UGC Creator's\n * `pickers` input takes (the route takes no other). One list for the editor's connection rule\n * and both engines' input resolvers.\n */\nexport const UGC_CREATOR_PICKER_TYPES: ReadonlySet<string> = new Set([\"person\", \"styling\", \"setting\", \"lighting\"])\n\n/** The UGC Creator node-data keys its request body reads. */\nexport interface UgcCreatorFields {\n readonly source?: string\n readonly gender?: string\n readonly photoUrl?: string\n readonly categoryOverride?: string\n readonly seed?: number\n readonly keepResult?: boolean\n readonly result?: Readonly<Record<string, unknown>>\n /** The options a draw left waiting for the pick (run state): read only for `previous`. */\n readonly candidates?: unknown\n}\n\n/** The traits of the latest creator the person saw: the first waiting option's, else the last result's (Keep off). */\nfunction previousTraits(data: UgcCreatorFields): unknown {\n if (ugcPickPending(data)) {\n const first: unknown = (data.candidates as readonly unknown[])[0]\n const record = isObject(first) ? first.record : undefined\n return isObject(record) ? record.traits : undefined\n }\n return !data.keepResult && isObject(data.result) ? data.result.traits : undefined\n}\n\n/** The wired pickers that set a field (their own fields, as the resolver read them); undefined when none did. */\nfunction setPickers(pickers: Record<string, Record<string, unknown>> | undefined): Record<string, Record<string, unknown>> | undefined {\n if (!pickers) return undefined\n const set = Object.entries(pickers).filter(([, fields]) => isObject(fields) && Object.keys(fields).length > 0)\n return set.length > 0 ? Object.fromEntries(set) : undefined\n}\n\n/**\n * The `/v1/ugc/creator` body. A photo: the wired photo, else the node's own. A sampled\n * creator: the product category (the node's override, else the wired one), the pickers that\n * set a field, the node's seed, and the traits of the latest creator the person saw as\n * `previous`, so the next one differs: the first option waiting for the pick, else — on a\n * re-run that does not keep the result — the last creator's. Refuses before any call.\n */\nexport function ugcCreatorBody(input: {\n data: UgcCreatorFields\n photoUrl?: string\n category?: string\n pickers?: Record<string, Record<string, unknown>>\n}): { body: Record<string, unknown> } | { error: string } {\n const { data } = input\n const gender = data.gender\n if (gender !== \"woman\" && gender !== \"man\") return { error: NEEDS_GENDER }\n if (data.source === \"photo\") {\n const imageUrl = filled(input.photoUrl) ?? filled(data.photoUrl)\n if (!imageUrl) return { error: NEEDS_PHOTO }\n return { body: { source: { kind: \"photo\", imageUrl, gender } } }\n }\n const productCategory = filled(data.categoryOverride) ?? filled(input.category)\n if (!productCategory) return { error: NEEDS_CATEGORY }\n const pickers = setPickers(input.pickers)\n const traits = previousTraits(data)\n return {\n body: {\n ...(typeof data.seed === \"number\" ? { seed: data.seed } : {}),\n source: {\n kind: \"sampled\",\n gender,\n productCategory,\n ...(pickers ? { pickers } : {}),\n ...(isObject(traits) ? { previous: traits } : {}),\n },\n },\n }\n}\n\n/**\n * The creator the node hands on: the record (`creator`, v1) and its first image (`image`).\n * `identityImages` are the images of the candidate the node hands on — the picked one where\n * a person picked. The record copies the listed fields only, so `candidates`, `fallback`,\n * `pick` and `image` never reach the `creator` wire.\n */\nexport function ugcCreatorOutputs(answer: Record<string, unknown>, identityImages: readonly string[]): { outputs: UgcOutputs; imageUrl: string; record: Record<string, unknown> } {\n const record: Record<string, unknown> = {\n v: 1,\n kind: answer.kind,\n gender: answer.gender,\n identityImages: [...identityImages],\n traits: answer.traits ?? null,\n seed: answer.seed ?? null,\n promptsVersion: answer.promptsVersion,\n productCategory: answer.productCategory ?? null,\n }\n const imageUrl = identityImages[0] ?? \"\"\n return { outputs: { creator: JSON.stringify(record), ...(imageUrl ? { image: imageUrl } : {}) }, imageUrl, record }\n}\n\n/** One builder call as the app runs it: `tool` and `args`, nothing else (a candidate's other keys, its model included, are never read). */\nexport interface UgcCreatorCall { readonly tool: string; readonly args: Readonly<Record<string, unknown>> }\n\n/** What a creator answer asks the node to render. */\nexport interface UgcCreatorCandidateCalls {\n /** Every candidate's image call, the primary first. One call (`image`) for an answer from before candidates; none for a photo. */\n readonly calls: readonly UgcCreatorCall[]\n /** The round's one moderation fallback: it runs once, and only when every candidate the run rendered was blocked. */\n readonly fallback: UgcCreatorCall | null\n /** \"user\": a person picks among `calls` where one can be asked; \"primary\": `calls[0]` alone; null: nothing to render (a photo). */\n readonly pick: \"user\" | \"primary\" | null\n}\n\nconst callOf = (raw: unknown): UgcCreatorCall | undefined => {\n if (!raw || typeof raw !== \"object\") return undefined\n const { tool, args } = raw as { tool?: unknown; args?: unknown }\n if (typeof tool !== \"string\" || !args || typeof args !== \"object\" || Array.isArray(args)) return undefined\n return { tool, args: args as Readonly<Record<string, unknown>> }\n}\nconst fallbackOf = (image: unknown): unknown => (image && typeof image === \"object\" ? (image as { fallback?: unknown }).fallback : undefined)\n\n/**\n * A `/v1/ugc/creator` answer's image calls. Content-free: reads `image` (`tool`, `args`,\n * `fallback`), `candidates[].tool|args`, `fallback` and `pick.how` — never a candidate's\n * model. An answer without `candidates` (an older builder) renders `image` alone, as before.\n */\nexport function ugcCreatorCandidates(answer: Readonly<Record<string, unknown>>): UgcCreatorCandidateCalls | { readonly error: string } {\n const listed = answer.candidates\n const noList = listed === undefined || listed === null || (Array.isArray(listed) && listed.length === 0)\n const noImage = answer.image === undefined || answer.image === null\n if (noList && noImage) return { calls: [], fallback: null, pick: null }\n if (noList) {\n const image = callOf(answer.image)\n if (!image) return { error: UGC_NEWER_APP_MESSAGE }\n return { calls: [image], fallback: callOf(fallbackOf(answer.image)) ?? null, pick: \"primary\" }\n }\n if (!Array.isArray(listed)) return { error: UGC_NEWER_APP_MESSAGE }\n const calls = listed.map(callOf)\n if (calls.some((c) => c === undefined)) return { error: UGC_NEWER_APP_MESSAGE }\n const how = (answer.pick as { how?: unknown } | null | undefined)?.how\n return {\n calls: calls as UgcCreatorCall[],\n fallback: callOf(answer.fallback) ?? callOf(fallbackOf(answer.image)) ?? null,\n pick: how === \"user\" && calls.length > 1 ? \"user\" : \"primary\",\n }\n}\n\n/** The calls a run renders: every candidate where a person is there to pick, else the primary alone. */\nexport function ugcCreatorCallsToRender(c: UgcCreatorCandidateCalls, opts: { readonly personPicks: boolean }): readonly UgcCreatorCall[] {\n return opts.personPicks && c.pick === \"user\" ? c.calls : c.calls.slice(0, 1)\n}\n\n/** One rendered candidate that passed its checks, kept on the node until the person picks (run state, never a wire). */\nexport interface UgcCreatorCandidate { readonly imageUrl: string; readonly record: Readonly<Record<string, unknown>> }\n\nexport function ugcCreatorCandidate(answer: Readonly<Record<string, unknown>>, images: readonly string[]): UgcCreatorCandidate {\n const out = ugcCreatorOutputs(answer as Record<string, unknown>, images)\n return { imageUrl: out.imageUrl, record: out.record }\n}\n\n/** A UGC Creator run output that waits for the person's pick: two or more options (`ugcCandidates`). */\nexport function ugcAwaitsPick(output: unknown): boolean {\n const candidates = isObject(output) ? output.ugcCandidates : undefined\n return Array.isArray(candidates) && candidates.length >= 2\n}\n\n/** The person's pick, read back from node data (untrusted): a stale index, a foreign list or another version is refused. */\nexport function ugcCreatorPick(candidates: unknown, index: number):\n { readonly result: Readonly<Record<string, unknown>>; readonly outputs: UgcOutputs; readonly imageUrl: string } | { readonly error: string } {\n const entry: unknown = Array.isArray(candidates) && Number.isInteger(index) && index >= 0 ? candidates[index] : undefined\n const imageUrl = (entry as { imageUrl?: unknown } | undefined)?.imageUrl\n const record = (entry as { record?: unknown } | undefined)?.record\n if (typeof imageUrl !== \"string\" || !record || typeof record !== \"object\" || Array.isArray(record)) return { error: UGC_PICK_GONE_MESSAGE }\n const r = record as Record<string, unknown>\n if (r.v !== 1) return { error: UGC_VERSION_MESSAGE }\n if (!Array.isArray(r.identityImages) || r.identityImages[0] !== imageUrl) return { error: UGC_PICK_GONE_MESSAGE }\n return { result: r, outputs: { creator: JSON.stringify(r), image: imageUrl }, imageUrl }\n}\n\n// ── UGC Script ───────────────────────────────────────────────────────────────\n\n/** The languages a UGC script can be written in: the node's choice (`UgcScriptData.language`). */\nexport const UGC_SCRIPT_LANGUAGES = [\"en\", \"he\"] as const\nexport type UgcScriptLanguage = (typeof UGC_SCRIPT_LANGUAGES)[number]\n\n/**\n * The `/v1/ugc/script` body: the product name or website (required), the screenshot slots\n * in card order with the empty ones dropped, the product image when set, the target length\n * (`UGC_SCRIPT_DEFAULT_TARGET_SEC` when the node holds no number), and the language (the\n * node's choice; English when it holds none or one this app does not know).\n */\nexport function ugcScriptBody(input: {\n site?: string\n screenshots: ReadonlyArray<string | undefined>\n productImage?: string\n targetDurationSec?: number\n language?: unknown\n}): { body: Record<string, unknown> } | { error: string } {\n const site = filled(input.site)?.trim()\n if (!site) return { error: NEEDS_SITE }\n const productImage = filled(input.productImage)\n return {\n body: {\n site,\n screenshots: input.screenshots.filter((s): s is string => filled(s) !== undefined),\n ...(productImage ? { productImage } : {}),\n targetDurationSec: typeof input.targetDurationSec === \"number\" ? input.targetDurationSec : UGC_SCRIPT_DEFAULT_TARGET_SEC,\n language: (UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(input.language) ? input.language : \"en\",\n },\n }\n}\n\n/** A finished UGC Script job → `plan` (the plan, v1) and `category` (text). */\nexport function ugcScriptOutputs(outputData: Record<string, unknown>): UgcOutputs {\n const plan = outputData.plan\n const category = filled(outputData.productCategory)\n return {\n ...(isObject(plan) ? { plan: JSON.stringify({ v: 1, ...plan }) } : {}),\n ...(category ? { category } : {}),\n }\n}\n\n/** UGC Script's last result, as the node holds it. */\nexport type UgcScriptResult = {\n plan: Record<string, unknown>\n productCategory: string\n warnings: unknown[]\n notes: string[]\n rounds: number\n}\n\n/** A finished UGC Script job → the node's `result`, written the same by both engines; none without a plan. */\nexport function ugcScriptResult(outputData: Readonly<Record<string, unknown>>): UgcScriptResult | undefined {\n const { plan, productCategory, warnings, notes, rounds } = outputData\n if (!isObject(plan)) return undefined\n return {\n plan,\n productCategory: filled(productCategory) ?? \"\",\n warnings: Array.isArray(warnings) ? [...warnings] : [],\n notes: Array.isArray(notes) ? notes.filter((n): n is string => typeof n === \"string\") : [],\n rounds: typeof rounds === \"number\" && Number.isFinite(rounds) ? rounds : 0,\n }\n}\n\n// ── Kept results ─────────────────────────────────────────────────────────────\n\n/**\n * What a UGC Creator or UGC Script with Keep on hands on instead of running: the outputs of\n * the result it holds. Null — the node runs — when Keep is off, when the result holds nothing\n * to hand on (a creator without its image, a script without its plan), and for a creator whose\n * options wait for a pick, whatever Keep says. The creator record goes on unread; whoever reads\n * it refuses another version.\n */\nexport function ugcKeptOutputs(type: \"ugc-creator\" | \"ugc-script\", data: Readonly<Record<string, unknown>>): UgcOutputs | null {\n if (type === \"ugc-creator\" && ugcPickPending(data)) return null\n const result = data.keepResult === true ? data.result : undefined\n if (!isObject(result)) return null\n if (type === \"ugc-creator\") {\n const image = Array.isArray(result.identityImages) ? filled(result.identityImages[0]) : undefined\n return image ? { creator: JSON.stringify(result), image } : null\n }\n if (type === \"ugc-script\") return isObject(result.plan) ? ugcScriptOutputs(result) : null\n return null\n}\n\n// ── UGC Clips ────────────────────────────────────────────────────────────────\n\n/** The `/v1/ugc/clips` canvas body: the plan, the creator's gender, traits and images, and the picked voice. */\nexport function ugcClipsBody(input: { planWire: unknown; creatorWire: unknown; voiceId?: string }): { body: Record<string, unknown> } | { error: string } {\n const plan = readUgcWire(input.planWire, NEEDS_PLAN)\n if (\"error\" in plan) return plan\n const creator = readUgcWire(input.creatorWire, UGC_CREATOR_MISSING_MESSAGE)\n if (\"error\" in creator) return creator\n const voiceId = filled(input.voiceId)\n return {\n body: {\n plan: plan.value,\n gender: creator.value.gender,\n traits: creator.value.traits ?? null,\n identityImages: creator.value.identityImages,\n surface: \"canvas\",\n ...(voiceId ? { voiceId } : {}),\n },\n }\n}\n\n/**\n * The `/v1/ugc/clips` answer → the tickets (one per clip, as JSON strings), `clips` (the\n * first), `plan-out` (`{ v: 1, plan, transcribeArgs }` for UGC Cards), `transcript`, whether\n * the plan has cards, and whether the clips go through UGC Finish's job (`finishes`: the plan-out\n * carries a finish call, which is what UGC Finish reads to run it). An answer with errors → \"The script needs changes: …\" with each\n * error and its fix; an answer without the parts UGC Cards needs fails here, before any clip\n * is paid for.\n */\nexport function ugcClipsOutputs(answer: Record<string, unknown>): { outputs: UgcOutputs; tickets: string[]; hasCards: boolean; finishes: boolean } | { error: string } {\n const errors = Array.isArray(answer.errors) ? answer.errors : []\n if (errors.length > 0) {\n const said = errors.flatMap((e) => (isObject(e) ? [filled(e.message), filled(e.fix)] : [])).filter((s): s is string => s !== undefined)\n return { error: said.length > 0 ? `${UGC_SCRIPT_NEEDS_CHANGES} ${said.join(\" \")}` : UGC_NEWER_APP_MESSAGE }\n }\n const { tickets, sizedPlan, transcript, speechCheckCall } = answer\n if (!Array.isArray(tickets) || tickets.length === 0 || !tickets.every(isObject) || !isObject(sizedPlan) || typeof transcript !== \"string\") {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n const wires = tickets.map((t) => JSON.stringify(t))\n // The speech check's arguments ride to UGC Cards' transcription unread (an answer without them: none).\n const transcribeArgs = isObject(speechCheckCall) && isObject(speechCheckCall.args) ? speechCheckCall.args : {}\n // A video cut from one recorded speech (the segmented lane) also hands UGC Finish its finish call's\n // arguments (the segments with their room), opaque; any other answer's plan-out is unchanged.\n const finish = isObject(answer.finish) && isObject(answer.finish.args) ? { finish: answer.finish.args } : {}\n return {\n outputs: { clips: wires[0]!, \"plan-out\": JSON.stringify({ v: 1, plan: sizedPlan, transcribeArgs, ...finish }), transcript },\n tickets: wires,\n hasCards: answer.hasCards === true,\n finishes: \"finish\" in finish,\n }\n}\n\n// ── UGC Clip ─────────────────────────────────────────────────────────────────\n\n/**\n * The `/v1/ugc/clip` body for one ticket: the ticket, `nonce` = how many times this clip was\n * re-rendered (`rerender[\"<clip number>\"]`, else 0) and `runKey` when one is given.\n */\nexport function ugcClipBody(input: { ticketWire: unknown; rerender?: Readonly<Record<string, number>>; runKey?: string }):\n { body: Record<string, unknown>; clipNumber: number; durationSec: number } | { error: string } {\n const read = readUgcWire(input.ticketWire, NEEDS_TICKET)\n if (\"error\" in read) return read\n const ticket = read.value\n const { index, durationSec } = ticket\n if (typeof index !== \"number\" || !Number.isInteger(index) || index < 0) return { error: NEEDS_TICKET }\n if (typeof durationSec !== \"number\" || !Number.isFinite(durationSec) || durationSec <= 0) return { error: NEEDS_TICKET }\n const clipNumber = index + 1\n const count = input.rerender?.[String(clipNumber)]\n const nonce = typeof count === \"number\" && Number.isInteger(count) && count >= 0 ? count : 0\n const runKey = filled(input.runKey)\n return { body: { ticket, nonce, ...(runKey ? { runKey } : {}) }, clipNumber, durationSec }\n}\n\n/**\n * A finished UGC Clip job (`{ videoUrl, durationSec, clipWarnings, … }`) → `video-out`, the\n * clip's real length (null when unknown) and its warnings ([] when it has none).\n */\nexport function ugcClipOutputs(outputData: Record<string, unknown>): { outputs: UgcOutputs; videoUrl: string; durationSec: number | null; clipWarnings: string[] } {\n const videoUrl = filled(outputData.videoUrl) ?? \"\"\n const meta = fanOutItemMeta(outputData)\n return { outputs: videoUrl ? { \"video-out\": videoUrl } : {}, videoUrl, durationSec: meta.durationSec, clipWarnings: [...meta.warnings] }\n}\n\n/**\n * What a list read (a Bundle edge, a fold) takes from a UGC Clip's saved data, on both engines:\n * its last fanned-out batch — one take per clip, in clip order — when its last run was one; else\n * exactly the take it shows (its active result, else its video). Never the earlier takes it keeps:\n * a video of one clip (one ticket, so no fan-out) would join every take. A single run clears the\n * batch (the editor's job patch), so a batch held is always the last run's. Undefined when it holds\n * no take at all.\n */\nexport function ugcClipSavedList(data: unknown): string[] | undefined {\n if (!isObject(data)) return undefined\n const batch = Array.isArray(data.__listResults) ? data.__listResults.filter((u): u is string => typeof u === \"string\" && u !== \"\") : []\n if (batch.length > 0) return batch\n const results = Array.isArray(data.generatedResults) ? data.generatedResults : []\n const index = typeof data.activeResultIndex === \"number\" && Number.isInteger(data.activeResultIndex) ? data.activeResultIndex : 0\n const active = results[index]\n const url = (isObject(active) ? filled(active.url) : undefined) ?? filled(data.generatedVideoUrl)\n return url ? [url] : undefined\n}\n\n// ── UGC Cards ────────────────────────────────────────────────────────────────\n\n/**\n * UGC Cards' two timing jobs on the joined video, and the plan they time. The plan input must\n * be UGC Clips' `{ v: 1, plan, transcribeArgs }`; anything else is refused before either job.\n * The transcription spreads `transcribeArgs` unread, then sets the node's own fields last, so\n * the wire can add a language but never change the provider or the word timings.\n */\nexport function ugcCardsJobs(input: { planOutWire: unknown; videoUrl?: string; transcript?: string }): {\n alignment: { path: \"/v1/forced-alignment\"; body: Record<string, unknown> }\n transcribe: { path: \"/v1/transcribe\"; body: Record<string, unknown> }\n plan: Record<string, unknown>\n} | { error: string } {\n const read = readUgcWire(input.planOutWire, NEEDS_PLAN_OUT)\n if (\"error\" in read) return read\n const { plan, transcribeArgs } = read.value\n if (!isObject(plan) || !isObject(transcribeArgs)) return { error: NEEDS_PLAN_OUT }\n const videoUrl = filled(input.videoUrl)\n if (!videoUrl) return { error: NEEDS_VIDEO }\n // An empty transcript is what UGC Clips said, not a missing input: it goes on as it came.\n const transcript = input.transcript\n if (typeof transcript !== \"string\") return { error: NEEDS_TRANSCRIPT }\n return {\n alignment: { path: \"/v1/forced-alignment\", body: { audioUrl: videoUrl, transcript } },\n transcribe: { path: \"/v1/transcribe\", body: { ...transcribeArgs, audioUrl: videoUrl, provider: DEFAULT_TRANSCRIBE_NODE_PROVIDER, wordTimestamps: true } },\n plan,\n }\n}\n\n/**\n * The `/v1/ugc/cards` canvas body: the plan, the video, whichever timing came back as a list,\n * the timing jobs that failed, and the clips' notes.\n */\nexport function ugcCardsBody(input: {\n plan: Record<string, unknown>\n videoUrl: string\n alignment?: unknown\n words?: unknown\n failed: ReadonlyArray<\"alignment\" | \"words\">\n clipNotes: ReadonlyArray<ClipNote>\n}): Record<string, unknown> {\n return {\n surface: \"canvas\",\n plan: input.plan,\n videoUrl: input.videoUrl,\n ...(Array.isArray(input.alignment) ? { alignment: input.alignment } : {}),\n ...(Array.isArray(input.words) ? { words: input.words } : {}),\n failed: [...input.failed],\n clipNotes: [...input.clipNotes],\n }\n}\n\n/** The caption plan when nothing could be timed: Add Captions renders no captions from it. */\nconst EMPTY_CAPTION_PLAN: CaptionPlan = { v: 1, hookText: \"\", hookEndMs: 0, bodyEndMs: 0, captions: [] }\n\n/** The `/v1/ugc/cards` answer → `layerPlan`, `captionPlan` (v1; the empty plan when untimed) and `report` (one line per sentence). */\nexport function ugcCardsOutputs(answer: Record<string, unknown>): UgcOutputs {\n const timing = answer.captionTiming\n const report = answer.report\n const lines = isObject(report) && Array.isArray(report.lines) ? report.lines.filter((l): l is string => typeof l === \"string\") : []\n return {\n layerPlan: JSON.stringify(Array.isArray(answer.layerPlan) ? answer.layerPlan : []),\n captionPlan: JSON.stringify(isObject(timing) ? { v: 1, ...timing } : EMPTY_CAPTION_PLAN),\n report: lines.join(\"\\n\"),\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkA6HRY3WF_cjs = require('./chunk-A6HRY3WF.cjs');
3
+ var chunkF5YEMSNK_cjs = require('./chunk-F5YEMSNK.cjs');
4
4
 
5
5
  // src/tts-capabilities.ts
6
6
  var TTS_PROVIDER_ALIASES = {
@@ -13,12 +13,12 @@ function canonicalTtsProvider(provider) {
13
13
  function findTtsCapabilities(provider) {
14
14
  if (typeof provider !== "string" || !provider) return void 0;
15
15
  const id = canonicalTtsProvider(provider);
16
- if (!Object.hasOwn(chunkA6HRY3WF_cjs.MODEL_CATALOG, id)) return void 0;
17
- const entry = chunkA6HRY3WF_cjs.MODEL_CATALOG[id];
16
+ if (!Object.hasOwn(chunkF5YEMSNK_cjs.MODEL_CATALOG, id)) return void 0;
17
+ const entry = chunkF5YEMSNK_cjs.MODEL_CATALOG[id];
18
18
  return entry.modes.includes("tts") ? entry.tts : void 0;
19
19
  }
20
20
  function getTtsCapabilities(provider) {
21
- return findTtsCapabilities(provider) ?? chunkA6HRY3WF_cjs.MODEL_CATALOG[TTS_FALLBACK_PROVIDER].tts;
21
+ return findTtsCapabilities(provider) ?? chunkF5YEMSNK_cjs.MODEL_CATALOG[TTS_FALLBACK_PROVIDER].tts;
22
22
  }
23
23
  function ttsSupportsAudioTags(provider) {
24
24
  return getTtsCapabilities(provider).audioTags;
@@ -50,5 +50,5 @@ exports.ttsSupportsAudioTags = ttsSupportsAudioTags;
50
50
  exports.ttsSupportsSsmlBreaks = ttsSupportsSsmlBreaks;
51
51
  exports.ttsSupportsStitching = ttsSupportsStitching;
52
52
  exports.ttsSupportsTimestamps = ttsSupportsTimestamps;
53
- //# sourceMappingURL=chunk-5G23AJBU.cjs.map
54
- //# sourceMappingURL=chunk-5G23AJBU.cjs.map
53
+ //# sourceMappingURL=chunk-XUJC6GHE.cjs.map
54
+ //# sourceMappingURL=chunk-XUJC6GHE.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tts-capabilities.ts"],"names":["MODEL_CATALOG"],"mappings":";;;;;AAkBO,IAAM,oBAAA,GAAyD;AAAA,EACpE,UAAA,EAAY;AACd;AAGO,IAAM,qBAAA,GAAwB;AAQ9B,SAAS,qBAAqB,QAAA,EAA0B;AAC7D,EAAA,OAAO,OAAO,QAAA,KAAa,QAAA,IAAY,MAAA,CAAO,MAAA,CAAO,sBAAsB,QAAQ,CAAA,GAAI,oBAAA,CAAqB,QAAQ,CAAA,GAAK,QAAA;AAC3H;AAGO,SAAS,oBAAoB,QAAA,EAA2D;AAG7F,EAAA,IAAI,OAAO,QAAA,KAAa,QAAA,IAAY,CAAC,UAAU,OAAO,MAAA;AACtD,EAAA,MAAM,EAAA,GAAK,qBAAqB,QAAQ,CAAA;AACxC,EAAA,IAAI,CAAC,MAAA,CAAO,MAAA,CAAOA,+BAAA,EAAe,EAAE,GAAG,OAAO,MAAA;AAC9C,EAAA,MAAM,KAAA,GAAQA,gCAAc,EAAE,CAAA;AAC9B,EAAA,OAAO,MAAM,KAAA,CAAM,QAAA,CAAS,KAAK,CAAA,GAAI,MAAM,GAAA,GAAM,MAAA;AACnD;AAQO,SAAS,mBAAmB,QAAA,EAA+C;AAChF,EAAA,OAAO,mBAAA,CAAoB,QAAQ,CAAA,IAAKA,+BAAA,CAAc,qBAAqB,CAAA,CAAG,GAAA;AAChF;AAGO,SAAS,qBAAqB,QAAA,EAAuC;AAC1E,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,SAAA;AACtC;AAGO,SAAS,sBAAsB,QAAA,EAAuC;AAC3E,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,UAAA;AACtC;AAOO,SAAS,qBAAqB,QAAA,EAAuC;AAC1E,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,SAAA;AACtC;AAGO,SAAS,WAAA,CAAY,UAA8B,KAAA,EAAiC;AACzF,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,MAAA,CAAO,SAAS,KAAK,CAAA;AAC3D;AAGO,SAAS,sBAAsB,QAAA,EAAuC;AAC3E,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,UAAA;AACtC;AAGO,SAAS,iBAAiB,QAAA,EAAiD;AAChF,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,SAAA;AACtC","file":"chunk-5G23AJBU.cjs","sourcesContent":["/**\n * Capability lookups for the text-to-speech lane.\n *\n * Every \"does this model do X\" decision on that lane reads the model's `tts`\n * sheet in `MODEL_CATALOG` through these helpers — tag stripping, which voice\n * settings are sent and shown, the language picker, whether neighbouring text\n * is sent. Declare the sheet honestly\n * on the catalog entry and a new model is covered everywhere; do not compare a\n * provider id by hand.\n *\n * \"The text-to-speech lane\" means the models that list the `tts` mode. The\n * dialogue models carry a sheet too, read by `dialogue-capabilities.ts`; a\n * text-to-speech request that names one runs as the fallback model, so these\n * helpers answer for the fallback there.\n */\nimport { MODEL_CATALOG, type TtsCapabilities, type TtsSettingLever } from \"./model-catalog.js\"\n\n/** Legacy provider ids that are another model under an old name. They have no catalog entry of their own. */\nexport const TTS_PROVIDER_ALIASES: Readonly<Record<string, string>> = {\n elevenlabs: \"elevenlabs-turbo\",\n}\n\n/** The model a request runs on when its provider id is missing or unknown. */\nexport const TTS_FALLBACK_PROVIDER = \"elevenlabs-turbo\"\n\n/**\n * Resolve a legacy alias to the catalog id it runs as. Any other id passes\n * through unchanged. Own properties only: an id that happens to be the name of\n * an inherited object member (`constructor`, `__proto__`, `toString`) is an\n * unknown id like any other, never a function.\n */\nexport function canonicalTtsProvider(provider: string): string {\n return typeof provider === \"string\" && Object.hasOwn(TTS_PROVIDER_ALIASES, provider) ? TTS_PROVIDER_ALIASES[provider]! : provider\n}\n\n/** The capability sheet of a text-to-speech model, or `undefined` when the id is not one. */\nexport function findTtsCapabilities(provider: string | undefined): TtsCapabilities | undefined {\n // `typeof`: node data can be written straight into workflow JSON, so the \"string\" is not guaranteed — and\n // `Object.hasOwn` would coerce an array like [\"elevenlabs-v3\"] into that model's id. A non-string is an unknown id.\n if (typeof provider !== \"string\" || !provider) return undefined\n const id = canonicalTtsProvider(provider)\n if (!Object.hasOwn(MODEL_CATALOG, id)) return undefined\n const entry = MODEL_CATALOG[id]!\n return entry.modes.includes(\"tts\") ? entry.tts : undefined\n}\n\n/**\n * The capability sheet a text-to-speech request will actually run under: a\n * missing or unknown provider id runs as {@link TTS_FALLBACK_PROVIDER}, so it\n * gets that sheet — including its `maxChars` (turbo's 40,000), where\n * `getMaxTtsChars` keeps answering its 5,000 default for such ids.\n */\nexport function getTtsCapabilities(provider: string | undefined): TtsCapabilities {\n return findTtsCapabilities(provider) ?? MODEL_CATALOG[TTS_FALLBACK_PROVIDER]!.tts!\n}\n\n/** The model performs inline `[audio tags]`. false ⇒ strip them before sending. */\nexport function ttsSupportsAudioTags(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).audioTags\n}\n\n/** The model honours SSML `<break time=\"…\"/>` tags. */\nexport function ttsSupportsSsmlBreaks(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).ssmlBreaks\n}\n\n/**\n * The model conditions on neighbouring text (`previous_text` / `next_text`).\n * false ⇒ the provider funnel never puts the fields on the wire, whatever the\n * request carries — the model would reject them.\n */\nexport function ttsSupportsStitching(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).stitching\n}\n\n/** The model honours this voice-setting lever. */\nexport function ttsHasLever(provider: string | undefined, lever: TtsSettingLever): boolean {\n return getTtsCapabilities(provider).levers.includes(lever)\n}\n\n/** The model answers `/v1/text-to-speech/{voice}/with-timestamps` (character timings). */\nexport function ttsSupportsTimestamps(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).timestamps\n}\n\n/** Language codes offered for the model, in catalog order. */\nexport function ttsLanguageCodes(provider: string | undefined): readonly string[] {\n return getTtsCapabilities(provider).languages\n}\n"]}
1
+ {"version":3,"sources":["../src/tts-capabilities.ts"],"names":["MODEL_CATALOG"],"mappings":";;;;;AAkBO,IAAM,oBAAA,GAAyD;AAAA,EACpE,UAAA,EAAY;AACd;AAGO,IAAM,qBAAA,GAAwB;AAQ9B,SAAS,qBAAqB,QAAA,EAA0B;AAC7D,EAAA,OAAO,OAAO,QAAA,KAAa,QAAA,IAAY,MAAA,CAAO,MAAA,CAAO,sBAAsB,QAAQ,CAAA,GAAI,oBAAA,CAAqB,QAAQ,CAAA,GAAK,QAAA;AAC3H;AAGO,SAAS,oBAAoB,QAAA,EAA2D;AAG7F,EAAA,IAAI,OAAO,QAAA,KAAa,QAAA,IAAY,CAAC,UAAU,OAAO,MAAA;AACtD,EAAA,MAAM,EAAA,GAAK,qBAAqB,QAAQ,CAAA;AACxC,EAAA,IAAI,CAAC,MAAA,CAAO,MAAA,CAAOA,+BAAA,EAAe,EAAE,GAAG,OAAO,MAAA;AAC9C,EAAA,MAAM,KAAA,GAAQA,gCAAc,EAAE,CAAA;AAC9B,EAAA,OAAO,MAAM,KAAA,CAAM,QAAA,CAAS,KAAK,CAAA,GAAI,MAAM,GAAA,GAAM,MAAA;AACnD;AAQO,SAAS,mBAAmB,QAAA,EAA+C;AAChF,EAAA,OAAO,mBAAA,CAAoB,QAAQ,CAAA,IAAKA,+BAAA,CAAc,qBAAqB,CAAA,CAAG,GAAA;AAChF;AAGO,SAAS,qBAAqB,QAAA,EAAuC;AAC1E,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,SAAA;AACtC;AAGO,SAAS,sBAAsB,QAAA,EAAuC;AAC3E,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,UAAA;AACtC;AAOO,SAAS,qBAAqB,QAAA,EAAuC;AAC1E,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,SAAA;AACtC;AAGO,SAAS,WAAA,CAAY,UAA8B,KAAA,EAAiC;AACzF,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,MAAA,CAAO,SAAS,KAAK,CAAA;AAC3D;AAGO,SAAS,sBAAsB,QAAA,EAAuC;AAC3E,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,UAAA;AACtC;AAGO,SAAS,iBAAiB,QAAA,EAAiD;AAChF,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,CAAE,SAAA;AACtC","file":"chunk-XUJC6GHE.cjs","sourcesContent":["/**\n * Capability lookups for the text-to-speech lane.\n *\n * Every \"does this model do X\" decision on that lane reads the model's `tts`\n * sheet in `MODEL_CATALOG` through these helpers — tag stripping, which voice\n * settings are sent and shown, the language picker, whether neighbouring text\n * is sent. Declare the sheet honestly\n * on the catalog entry and a new model is covered everywhere; do not compare a\n * provider id by hand.\n *\n * \"The text-to-speech lane\" means the models that list the `tts` mode. The\n * dialogue models carry a sheet too, read by `dialogue-capabilities.ts`; a\n * text-to-speech request that names one runs as the fallback model, so these\n * helpers answer for the fallback there.\n */\nimport { MODEL_CATALOG, type TtsCapabilities, type TtsSettingLever } from \"./model-catalog.js\"\n\n/** Legacy provider ids that are another model under an old name. They have no catalog entry of their own. */\nexport const TTS_PROVIDER_ALIASES: Readonly<Record<string, string>> = {\n elevenlabs: \"elevenlabs-turbo\",\n}\n\n/** The model a request runs on when its provider id is missing or unknown. */\nexport const TTS_FALLBACK_PROVIDER = \"elevenlabs-turbo\"\n\n/**\n * Resolve a legacy alias to the catalog id it runs as. Any other id passes\n * through unchanged. Own properties only: an id that happens to be the name of\n * an inherited object member (`constructor`, `__proto__`, `toString`) is an\n * unknown id like any other, never a function.\n */\nexport function canonicalTtsProvider(provider: string): string {\n return typeof provider === \"string\" && Object.hasOwn(TTS_PROVIDER_ALIASES, provider) ? TTS_PROVIDER_ALIASES[provider]! : provider\n}\n\n/** The capability sheet of a text-to-speech model, or `undefined` when the id is not one. */\nexport function findTtsCapabilities(provider: string | undefined): TtsCapabilities | undefined {\n // `typeof`: node data can be written straight into workflow JSON, so the \"string\" is not guaranteed — and\n // `Object.hasOwn` would coerce an array like [\"elevenlabs-v3\"] into that model's id. A non-string is an unknown id.\n if (typeof provider !== \"string\" || !provider) return undefined\n const id = canonicalTtsProvider(provider)\n if (!Object.hasOwn(MODEL_CATALOG, id)) return undefined\n const entry = MODEL_CATALOG[id]!\n return entry.modes.includes(\"tts\") ? entry.tts : undefined\n}\n\n/**\n * The capability sheet a text-to-speech request will actually run under: a\n * missing or unknown provider id runs as {@link TTS_FALLBACK_PROVIDER}, so it\n * gets that sheet — including its `maxChars` (turbo's 40,000), where\n * `getMaxTtsChars` keeps answering its 5,000 default for such ids.\n */\nexport function getTtsCapabilities(provider: string | undefined): TtsCapabilities {\n return findTtsCapabilities(provider) ?? MODEL_CATALOG[TTS_FALLBACK_PROVIDER]!.tts!\n}\n\n/** The model performs inline `[audio tags]`. false ⇒ strip them before sending. */\nexport function ttsSupportsAudioTags(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).audioTags\n}\n\n/** The model honours SSML `<break time=\"…\"/>` tags. */\nexport function ttsSupportsSsmlBreaks(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).ssmlBreaks\n}\n\n/**\n * The model conditions on neighbouring text (`previous_text` / `next_text`).\n * false ⇒ the provider funnel never puts the fields on the wire, whatever the\n * request carries — the model would reject them.\n */\nexport function ttsSupportsStitching(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).stitching\n}\n\n/** The model honours this voice-setting lever. */\nexport function ttsHasLever(provider: string | undefined, lever: TtsSettingLever): boolean {\n return getTtsCapabilities(provider).levers.includes(lever)\n}\n\n/** The model answers `/v1/text-to-speech/{voice}/with-timestamps` (character timings). */\nexport function ttsSupportsTimestamps(provider: string | undefined): boolean {\n return getTtsCapabilities(provider).timestamps\n}\n\n/** Language codes offered for the model, in catalog order. */\nexport function ttsLanguageCodes(provider: string | undefined): readonly string[] {\n return getTtsCapabilities(provider).languages\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk5Y42RIGY_cjs = require('./chunk-5Y42RIGY.cjs');
3
+ var chunkIVXSNW2B_cjs = require('./chunk-IVXSNW2B.cjs');
4
4
 
5
5
  // src/picker-restrictions.ts
6
6
  var valuesOf = (v) => (Array.isArray(v) ? v : [v]).filter((x) => x !== void 0 && x !== null && x !== "").map(String);
@@ -11,14 +11,14 @@ function findRestrictedPickerValue(input) {
11
11
  const submitted = input.inputValues[node.id];
12
12
  if (!meta || !submitted) continue;
13
13
  const rules = [];
14
- const rep = node.type ? chunk5Y42RIGY_cjs.INPUT_FIELD_MAP[node.type]?.key : void 0;
14
+ const rep = node.type ? chunkIVXSNW2B_cjs.INPUT_FIELD_MAP[node.type]?.key : void 0;
15
15
  if (rep && meta.pickerAllowedValues && meta.pickerAllowedValues.length > 0) rules.push([rep, meta.pickerAllowedValues]);
16
16
  for (const [field, allowed] of Object.entries(meta.pickerAllowedValuesByField ?? {})) {
17
17
  if (allowed.length > 0) rules.push([field, allowed]);
18
18
  }
19
19
  for (const [field, allowed] of rules) {
20
20
  for (const [key, raw] of Object.entries(submitted)) {
21
- if (chunk5Y42RIGY_cjs.canonicalExposedFieldKey(node.type, key) !== field) continue;
21
+ if (chunkIVXSNW2B_cjs.canonicalExposedFieldKey(node.type, key) !== field) continue;
22
22
  for (const value of valuesOf(raw)) {
23
23
  if (!allowed.includes(value)) return `Invalid value for ${field}: ${value}. Allowed: ${allowed.join(", ")}`;
24
24
  }
@@ -30,7 +30,7 @@ function findRestrictedPickerValue(input) {
30
30
 
31
31
  // src/component-types.ts
32
32
  var INPUT_FIELD_MAP2 = Object.fromEntries(
33
- Object.entries(chunk5Y42RIGY_cjs.INPUT_FIELD_MAP).map(([k, v]) => [k, v.key])
33
+ Object.entries(chunkIVXSNW2B_cjs.INPUT_FIELD_MAP).map(([k, v]) => [k, v.key])
34
34
  );
35
35
  var HANDLE_PORT_SEPARATOR = "::";
36
36
  function parseHandleId(handleId) {
@@ -157,5 +157,5 @@ exports.normalizeTemplateCategory = normalizeTemplateCategory;
157
157
  exports.parseHandleId = parseHandleId;
158
158
  exports.resolveTemplateCategory = resolveTemplateCategory;
159
159
  exports.templateCategoryStoredValues = templateCategoryStoredValues;
160
- //# sourceMappingURL=chunk-GNPJ2JLE.cjs.map
161
- //# sourceMappingURL=chunk-GNPJ2JLE.cjs.map
160
+ //# sourceMappingURL=chunk-XZKFZMRT.cjs.map
161
+ //# sourceMappingURL=chunk-XZKFZMRT.cjs.map