@nodaro/shared 3.32.0 → 3.33.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 (136) hide show
  1. package/dist/{chunk-ISJDAFKS.js → chunk-23FJQTEA.js} +8 -8
  2. package/dist/{chunk-ISJDAFKS.js.map → chunk-23FJQTEA.js.map} +1 -1
  3. package/dist/{chunk-VWGNPMJZ.cjs → chunk-2NQLSLSN.cjs} +5 -5
  4. package/dist/{chunk-VWGNPMJZ.cjs.map → chunk-2NQLSLSN.cjs.map} +1 -1
  5. package/dist/{chunk-IEBZHTPE.js → chunk-5RYLK3MQ.js} +28 -15
  6. package/dist/chunk-5RYLK3MQ.js.map +1 -0
  7. package/dist/{chunk-Z4AZW6FY.js → chunk-6WZ2VN7V.js} +5 -5
  8. package/dist/{chunk-Z4AZW6FY.js.map → chunk-6WZ2VN7V.js.map} +1 -1
  9. package/dist/{chunk-6DKDOWBL.js → chunk-7Z5LUTGU.js} +3 -3
  10. package/dist/{chunk-6DKDOWBL.js.map → chunk-7Z5LUTGU.js.map} +1 -1
  11. package/dist/{chunk-3CUFITU7.js → chunk-BG5D5CZ6.js} +67 -50
  12. package/dist/chunk-BG5D5CZ6.js.map +1 -0
  13. package/dist/{chunk-XAMC4S53.js → chunk-CUH22J4D.js} +3 -3
  14. package/dist/{chunk-XAMC4S53.js.map → chunk-CUH22J4D.js.map} +1 -1
  15. package/dist/{chunk-E2TGXG6X.cjs → chunk-D26ENTN2.cjs} +43 -43
  16. package/dist/{chunk-E2TGXG6X.cjs.map → chunk-D26ENTN2.cjs.map} +1 -1
  17. package/dist/{chunk-AVQK77G6.cjs → chunk-D6GNRSCV.cjs} +67 -50
  18. package/dist/chunk-D6GNRSCV.cjs.map +1 -0
  19. package/dist/{chunk-KHCBJ7KD.js → chunk-FT5CF6IA.js} +3 -3
  20. package/dist/{chunk-KHCBJ7KD.js.map → chunk-FT5CF6IA.js.map} +1 -1
  21. package/dist/{chunk-JX5YZ4DH.cjs → chunk-HC7VKIV5.cjs} +38 -38
  22. package/dist/{chunk-JX5YZ4DH.cjs.map → chunk-HC7VKIV5.cjs.map} +1 -1
  23. package/dist/{chunk-S5DMKUWK.cjs → chunk-HKFMXNVQ.cjs} +11 -11
  24. package/dist/{chunk-S5DMKUWK.cjs.map → chunk-HKFMXNVQ.cjs.map} +1 -1
  25. package/dist/{chunk-O5MP52U2.cjs → chunk-HRXEZ3SX.cjs} +4 -4
  26. package/dist/{chunk-O5MP52U2.cjs.map → chunk-HRXEZ3SX.cjs.map} +1 -1
  27. package/dist/{chunk-RJL7RCEM.cjs → chunk-HUR6ZJ7S.cjs} +6 -6
  28. package/dist/chunk-HUR6ZJ7S.cjs.map +1 -0
  29. package/dist/{chunk-QELDJGDK.cjs → chunk-JFS3NWZ5.cjs} +4 -4
  30. package/dist/{chunk-QELDJGDK.cjs.map → chunk-JFS3NWZ5.cjs.map} +1 -1
  31. package/dist/{chunk-5AUSSJIM.cjs → chunk-K3LLGRK7.cjs} +175 -2
  32. package/dist/chunk-K3LLGRK7.cjs.map +1 -0
  33. package/dist/{chunk-J6KHW2E5.cjs → chunk-M7GQBRZU.cjs} +16 -16
  34. package/dist/{chunk-J6KHW2E5.cjs.map → chunk-M7GQBRZU.cjs.map} +1 -1
  35. package/dist/{chunk-5U7VLG43.js → chunk-OTATNBMD.js} +3 -3
  36. package/dist/chunk-OTATNBMD.js.map +1 -0
  37. package/dist/{chunk-LPW3XNC2.js → chunk-OZSACQ2V.js} +3 -3
  38. package/dist/{chunk-LPW3XNC2.js.map → chunk-OZSACQ2V.js.map} +1 -1
  39. package/dist/{chunk-VIWSWVAW.js → chunk-PHZ23DP3.js} +3 -3
  40. package/dist/{chunk-VIWSWVAW.js.map → chunk-PHZ23DP3.js.map} +1 -1
  41. package/dist/{chunk-ZT77RY6R.js → chunk-PVJBAPYJ.js} +4 -4
  42. package/dist/{chunk-ZT77RY6R.js.map → chunk-PVJBAPYJ.js.map} +1 -1
  43. package/dist/{chunk-AROWPFO2.js → chunk-PXFQVLBX.js} +7 -4
  44. package/dist/chunk-PXFQVLBX.js.map +1 -0
  45. package/dist/{chunk-Q4CDQ2KO.js → chunk-QA3MVQ32.js} +4 -4
  46. package/dist/{chunk-Q4CDQ2KO.js.map → chunk-QA3MVQ32.js.map} +1 -1
  47. package/dist/{chunk-NB72XWXQ.cjs → chunk-SAW5OK36.cjs} +6 -6
  48. package/dist/{chunk-NB72XWXQ.cjs.map → chunk-SAW5OK36.cjs.map} +1 -1
  49. package/dist/{chunk-YHRG7UOC.js → chunk-SFW3UB2P.js} +4 -4
  50. package/dist/{chunk-YHRG7UOC.js.map → chunk-SFW3UB2P.js.map} +1 -1
  51. package/dist/chunk-TU33KYKW.cjs +25 -0
  52. package/dist/{chunk-WNG7HRVA.cjs.map → chunk-TU33KYKW.cjs.map} +1 -1
  53. package/dist/{chunk-QNGNOU4Z.js → chunk-UCFWI6D4.js} +3 -3
  54. package/dist/{chunk-QNGNOU4Z.js.map → chunk-UCFWI6D4.js.map} +1 -1
  55. package/dist/{chunk-RN3RMBJZ.js → chunk-UTQSSKSG.js} +4 -4
  56. package/dist/{chunk-RN3RMBJZ.js.map → chunk-UTQSSKSG.js.map} +1 -1
  57. package/dist/{chunk-NT6IJH4L.cjs → chunk-VA42637J.cjs} +61 -47
  58. package/dist/chunk-VA42637J.cjs.map +1 -0
  59. package/dist/{chunk-ULXI7A6Q.cjs → chunk-VNQRI2RO.cjs} +11 -11
  60. package/dist/{chunk-ULXI7A6Q.cjs.map → chunk-VNQRI2RO.cjs.map} +1 -1
  61. package/dist/{chunk-O7PUQLJ3.cjs → chunk-VXPLKQWY.cjs} +11 -8
  62. package/dist/chunk-VXPLKQWY.cjs.map +1 -0
  63. package/dist/{chunk-6IJOPRZP.cjs → chunk-WD6HJRBG.cjs} +21 -21
  64. package/dist/{chunk-6IJOPRZP.cjs.map → chunk-WD6HJRBG.cjs.map} +1 -1
  65. package/dist/{chunk-EK362Q45.cjs → chunk-WKOIGLQX.cjs} +8 -8
  66. package/dist/{chunk-EK362Q45.cjs.map → chunk-WKOIGLQX.cjs.map} +1 -1
  67. package/dist/{chunk-LKAIXWK3.js → chunk-XGFTL5XY.js} +3 -3
  68. package/dist/{chunk-LKAIXWK3.js.map → chunk-XGFTL5XY.js.map} +1 -1
  69. package/dist/{chunk-JSNV5O2F.cjs → chunk-ZL7UM6PU.cjs} +4 -4
  70. package/dist/{chunk-JSNV5O2F.cjs.map → chunk-ZL7UM6PU.cjs.map} +1 -1
  71. package/dist/{chunk-C57NEO3X.js → chunk-ZO5PBBFX.js} +173 -3
  72. package/dist/chunk-ZO5PBBFX.js.map +1 -0
  73. package/dist/entries/apps.cjs +42 -42
  74. package/dist/entries/apps.d.cts +10 -1
  75. package/dist/entries/apps.d.ts +10 -1
  76. package/dist/entries/apps.js +7 -7
  77. package/dist/entries/credits.cjs +155 -151
  78. package/dist/entries/credits.d.cts +41 -10
  79. package/dist/entries/credits.d.ts +41 -10
  80. package/dist/entries/credits.js +7 -7
  81. package/dist/entries/model-catalog.cjs +75 -63
  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 +209 -209
  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 +200 -200
  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 +149 -149
  94. package/dist/entries/pipeline.d.cts +6 -6
  95. package/dist/entries/pipeline.d.ts +6 -6
  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 +115 -115
  100. package/dist/entries/video.js +4 -4
  101. package/dist/entries/workflow.cjs +95 -95
  102. package/dist/entries/workflow.d.cts +13 -3
  103. package/dist/entries/workflow.d.ts +13 -3
  104. package/dist/entries/workflow.js +1 -1
  105. package/dist/index.cjs +1087 -1071
  106. package/dist/index.d.cts +4 -4
  107. package/dist/index.d.ts +4 -4
  108. package/dist/index.js +18 -18
  109. package/dist/{model-catalog-flJYaa-g.d.ts → model-catalog-V-ZNzRSd.d.cts} +91 -1
  110. package/dist/{model-catalog-flJYaa-g.d.cts → model-catalog-V-ZNzRSd.d.ts} +91 -1
  111. package/dist/{presentation-utils-BIqiCzSA.d.cts → presentation-utils-D0kxsWf9.d.cts} +2 -0
  112. package/dist/{presentation-utils-BdiObtwq.d.ts → presentation-utils-pZwlEAzo.d.ts} +2 -0
  113. package/dist/{scene-node-types-DjenYFLO.d.ts → scene-node-types-C3kl_zyK.d.cts} +1 -1
  114. package/dist/{scene-node-types-DjenYFLO.d.cts → scene-node-types-C3kl_zyK.d.ts} +1 -1
  115. package/package.json +1 -1
  116. package/src/__tests__/model-makers.test.ts +76 -0
  117. package/src/__tests__/presentation-utils.test.ts +15 -0
  118. package/src/__tests__/private-host.test.ts +53 -0
  119. package/src/component-types.ts +9 -0
  120. package/src/credit-identifiers.ts +62 -17
  121. package/src/entries/credits.ts +1 -0
  122. package/src/entries/model-catalog.ts +6 -0
  123. package/src/model-catalog.ts +207 -0
  124. package/src/presentation-utils.ts +7 -0
  125. package/src/private-host.ts +89 -59
  126. package/dist/chunk-3CUFITU7.js.map +0 -1
  127. package/dist/chunk-5AUSSJIM.cjs.map +0 -1
  128. package/dist/chunk-5U7VLG43.js.map +0 -1
  129. package/dist/chunk-AROWPFO2.js.map +0 -1
  130. package/dist/chunk-AVQK77G6.cjs.map +0 -1
  131. package/dist/chunk-C57NEO3X.js.map +0 -1
  132. package/dist/chunk-IEBZHTPE.js.map +0 -1
  133. package/dist/chunk-NT6IJH4L.cjs.map +0 -1
  134. package/dist/chunk-O7PUQLJ3.cjs.map +0 -1
  135. package/dist/chunk-RJL7RCEM.cjs.map +0 -1
  136. package/dist/chunk-WNG7HRVA.cjs +0 -25
@@ -1,4 +1,4 @@
1
- import { INPUT_FIELD_MAP, canonicalExposedFieldKey } from './chunk-AROWPFO2.js';
1
+ import { INPUT_FIELD_MAP, canonicalExposedFieldKey } from './chunk-PXFQVLBX.js';
2
2
 
3
3
  // src/picker-restrictions.ts
4
4
  var valuesOf = (v) => (Array.isArray(v) ? v : [v]).filter((x) => x !== void 0 && x !== null && x !== "").map(String);
@@ -137,5 +137,5 @@ function templateCategoryStoredValues(category) {
137
137
  }
138
138
 
139
139
  export { DEFAULT_TEMPLATE_CATEGORY, HANDLE_PORT_SEPARATOR, INPUT_FIELD_MAP2 as INPUT_FIELD_MAP, LEGACY_TEMPLATE_CATEGORIES, OAUTH_SCOPES, OUTPUT_FIELD_MAP, RECAST_SEGMENT_PACKS, TEMPLATE_CATEGORIES, applyHandleInputOverride, findRestrictedPickerValue, isHandleInputWired, isTemplateCategory, mergeExposedSettings, normalizeTemplateCategory, parseHandleId, resolveTemplateCategory, templateCategoryStoredValues };
140
- //# sourceMappingURL=chunk-5U7VLG43.js.map
141
- //# sourceMappingURL=chunk-5U7VLG43.js.map
140
+ //# sourceMappingURL=chunk-OTATNBMD.js.map
141
+ //# sourceMappingURL=chunk-OTATNBMD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/picker-restrictions.ts","../src/component-types.ts","../src/oauth-scopes.ts","../src/recast-segment-packs.ts","../src/template-categories.ts"],"names":["INPUT_FIELD_MAP"],"mappings":";;;AAYA,IAAM,QAAA,GAAW,CAAC,CAAA,KAAA,CACf,KAAA,CAAM,QAAQ,CAAC,CAAA,GAAI,CAAA,GAAI,CAAC,CAAC,CAAA,EAAG,OAAO,CAAC,CAAA,KAAM,MAAM,MAAA,IAAa,CAAA,KAAM,QAAQ,CAAA,KAAM,EAAE,CAAA,CAAE,GAAA,CAAI,MAAM,CAAA;AAS3F,SAAS,0BAA0B,KAAA,EAIxB;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AmB,KAAK,CAAA,EAAG,OAAO,KAAA;AACtC,EAAA,OAAO,2BAA2B,KAAK,CAAA;AACzC;AAGO,SAAS,0BAA0B,KAAA,EAAoD;AAC5F,EAAA,OAAO,uBAAA,CAAwB,KAAK,CAAA,IAAK,yBAAA;AAC3C;AAOO,SAAS,6BAA6B,QAAA,EAAsC;AACjF,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,IAAA,CAAK,0BAA0B,CAAA,CAAE,MAAA,CAAO,CAAC,KAAA,KAAU,0BAAA,CAA2B,KAAK,CAAA,KAAM,QAAQ,CAAA;AACvH,EAAA,OAAO,CAAC,QAAA,EAAU,GAAG,MAAM,CAAA;AAC7B","file":"chunk-OTATNBMD.js","sourcesContent":["import { canonicalExposedFieldKey } from \"./exposed-field-keys.js\"\nimport { INPUT_FIELD_MAP } from \"./presentation-utils.js\"\n\n/** What an app's picker card may restrict (stored in `presentationSettings.cardMeta[nodeId]`). */\nexport interface PickerCardRestrictions {\n readonly pickerAllowedValues?: readonly string[]\n readonly pickerAllowedValuesByField?: Readonly<Record<string, readonly string[]>>\n}\n\n// Every submitted value is checked, whatever its type — a number or object where a\n// catalog id belongs must be refused, not skipped. An unset / cleared pick (\"\" , null)\n// is no selection and passes (the node falls back to its default).\nconst valuesOf = (v: unknown): string[] =>\n (Array.isArray(v) ? v : [v]).filter((x) => x !== undefined && x !== null && x !== \"\").map(String)\n\n/**\n * The first submitted picker value an app's card restrictions forbid, as the\n * runner's 400 text; null when all pass. Runs on every app run — `run_app`,\n * the SDK and a hand-built body included — so a restriction is never UI-only.\n * A submitted key is read through `canonicalExposedFieldKey`, so a legacy\n * spelling cannot slip past a restriction written against the current field.\n */\nexport function findRestrictedPickerValue(input: {\n readonly cardMeta: Readonly<Record<string, PickerCardRestrictions | undefined>> | undefined\n readonly nodes: ReadonlyArray<{ readonly id: string; readonly type?: string }>\n readonly inputValues: Readonly<Record<string, Readonly<Record<string, unknown>>>> | undefined\n}): string | null {\n if (!input.cardMeta || !input.inputValues) return null\n for (const node of input.nodes) {\n const meta = input.cardMeta[node.id]\n const submitted = input.inputValues[node.id]\n if (!meta || !submitted) continue\n const rules: Array<[string, readonly string[]]> = []\n const rep = node.type ? INPUT_FIELD_MAP[node.type]?.key : undefined\n if (rep && meta.pickerAllowedValues && meta.pickerAllowedValues.length > 0) rules.push([rep, meta.pickerAllowedValues])\n for (const [field, allowed] of Object.entries(meta.pickerAllowedValuesByField ?? {})) {\n if (allowed.length > 0) rules.push([field, allowed])\n }\n for (const [field, allowed] of rules) {\n for (const [key, raw] of Object.entries(submitted)) {\n if (canonicalExposedFieldKey(node.type, key) !== field) continue\n for (const value of valuesOf(raw)) {\n if (!allowed.includes(value)) return `Invalid value for ${field}: ${value}. Allowed: ${allowed.join(\", \")}`\n }\n }\n }\n }\n return null\n}\n","import { INPUT_FIELD_MAP as PRESENTATION_INPUT_MAP } from \"./presentation-utils.js\"\n\nexport interface ComponentHandle {\n id: string\n name: string\n type: \"image\" | \"video\" | \"audio\" | \"text\"\n required: boolean\n mediaPreview?: boolean\n fieldKey: string\n}\n\nexport interface ExposedSetting {\n nodeId: string\n field: string\n label: string\n type: \"select\" | \"text\" | \"number\" | \"toggle\" | \"aspect-ratio\"\n allowedValues?: unknown[]\n /** Full option list with labels for select fields (preferred over allowedValues). */\n options?: Array<{ value: string; label: string }>\n defaultValue: unknown\n /**\n * Set when the setting is one of the node's quick settings (the editor's bottom-bar levers): the node type,\n * so the consuming workflow can render the same control, and the node's own lever values its choices depend\n * on (its model, Draft, …), so the control offers what that model takes. Never prompts or results.\n */\n quick?: {\n nodeType: string\n context?: Record<string, string | number | boolean>\n }\n}\n\nexport interface ComponentMetadata {\n inputs: ComponentHandle[]\n outputs: ComponentHandle[]\n exposedSettings: ExposedSetting[]\n}\n\n/** Maps input node types to their data field key for inputOverrides (derived from presentation-utils) */\nexport const INPUT_FIELD_MAP: Record<string, string> = Object.fromEntries(\n Object.entries(PRESENTATION_INPUT_MAP).map(([k, v]) => [k, v.key]),\n)\n\n/** Separator used in component handle ids that target a specific port on a sub-workflow-input / sub-workflow-output node. */\nexport const HANDLE_PORT_SEPARATOR = \"::\"\n\n/**\n * Split a component handle id of the form `nodeId` or `nodeId::portId`.\n * Returns the literal nodeId when no separator is present.\n */\nexport function parseHandleId(handleId: string): { nodeId: string; portId?: string } {\n const sep = handleId.indexOf(HANDLE_PORT_SEPARATOR)\n if (sep < 0) return { nodeId: handleId }\n const portId = handleId.slice(sep + HANDLE_PORT_SEPARATOR.length)\n return { nodeId: handleId.slice(0, sep), portId: portId || undefined }\n}\n\n/**\n * Apply a value for a component input handle to the inputOverrides map.\n *\n * - Plain handles (id = nodeId) write to `inputOverrides[nodeId][fieldKey]`,\n * which the orchestrator shallow-merges into `node.data` at execution.\n * - Compound handles (id = nodeId::portId) write into\n * `inputOverrides[nodeId].__injectedPortValues[portId]`, the slot that\n * sub-workflow-input nodes read at runtime via output-extractor.\n *\n * Mutates the map in place so multi-port accumulation merges correctly when\n * iterating handles in a loop.\n */\nexport function applyHandleInputOverride(\n inputOverrides: Record<string, Record<string, unknown>>,\n handle: { id: string; fieldKey: string },\n value: unknown,\n): void {\n const { nodeId, portId } = parseHandleId(handle.id)\n if (portId) {\n const existing = (inputOverrides[nodeId]?.__injectedPortValues as Record<string, unknown> | undefined) ?? {}\n inputOverrides[nodeId] = {\n ...inputOverrides[nodeId],\n __injectedPortValues: { ...existing, [portId]: value },\n }\n } else {\n inputOverrides[nodeId] = { ...inputOverrides[nodeId], [handle.fieldKey]: value }\n }\n}\n\n/**\n * Has a value already been recorded for this handle in the inputOverrides map?\n * Used to skip fallback wiring when an upstream connection already supplied\n * the input.\n */\nexport function isHandleInputWired(\n inputOverrides: Record<string, Record<string, unknown>>,\n handle: { id: string; fieldKey: string },\n): boolean {\n const { nodeId, portId } = parseHandleId(handle.id)\n if (portId) {\n const injected = inputOverrides[nodeId]?.__injectedPortValues as Record<string, unknown> | undefined\n return injected?.[portId] !== undefined\n }\n return inputOverrides[nodeId]?.[handle.fieldKey] !== undefined\n}\n\n/** Maps output media types to NodeOutput field keys */\nexport const OUTPUT_FIELD_MAP: Record<string, string> = {\n image: \"imageUrl\",\n video: \"videoUrl\",\n audio: \"audioUrl\",\n text: \"text\",\n}\n\n/**\n * Merge exposed settings into inputOverrides format.\n * exposedSettings is keyed by \"nodeId:field\" -> value on the component node data.\n *\n * Connected inputs (already present in inputOverrides) always take priority\n * over exposed settings for the same node+field combination. This ensures\n * that mandatory upstream wires are never silently overwritten by stale\n * default / user-configured exposed-setting values.\n */\nexport function mergeExposedSettings(\n inputOverrides: Record<string, Record<string, unknown>>,\n exposedSettings: Record<string, unknown>,\n metadata: ComponentMetadata,\n): Record<string, Record<string, unknown>> {\n const merged = { ...inputOverrides }\n for (const setting of metadata.exposedSettings) {\n const key = `${setting.nodeId}:${setting.field}`\n const value = exposedSettings[key]\n if (value !== undefined) {\n // Skip if a connected input already provided this field\n if (merged[setting.nodeId]?.[setting.field] !== undefined) continue\n merged[setting.nodeId] = { ...merged[setting.nodeId], [setting.field]: value }\n }\n }\n return merged\n}\n","/**\n * The OAuth scopes a Nodaro token can carry — part of the public API contract\n * (published in the authorization server's `scopes_supported`, requested by\n * developer apps, typed in `@nodaro/sdk`). The server validates against this\n * list and the SDK types against it, so the two cannot drift.\n *\n * A scope in this list is published and handed to any Dynamic Client\n * Registration client that asks for everything, so add one in the same change\n * that makes something check it (see backend/src/lib/scopes.ts).\n */\nexport const OAUTH_SCOPES = [\n \"workflows:read\",\n \"workflows:write\",\n \"workflows:execute\",\n \"jobs:read\",\n \"assets:read\",\n \"assets:write\",\n \"credits:read\",\n \"apps:read\",\n \"pipelines:read\",\n \"pipelines:execute\",\n \"pipelines:approve\",\n \"presets:read\",\n \"workspaces:read\",\n \"workspaces:write\",\n] as const\n\nexport type OAuthScope = (typeof OAUTH_SCOPES)[number]\n","/**\n * How a recast render packs scenes into parts — the values `segmentSec` takes\n * on `POST /v1/recast`, `/v1/recast/estimate` and `/v1/recast/:id/start`. A\n * name, not seconds, despite the field's name:\n *\n * - `\"scenes-max\"` (Long): whole scenes grouped into as few parts as fit, the\n * fewest seams.\n * - `\"scenes\"` (Short): whole scenes in shorter parts.\n * - `\"max\"`: the longest parts the model allows, not grouped by scene.\n */\nexport const RECAST_SEGMENT_PACKS = [\"max\", \"scenes-max\", \"scenes\"] as const\n\nexport type RecastSegmentPack = (typeof RECAST_SEGMENT_PACKS)[number]\n","/**\n * The use cases a marketplace template is filed under — exactly one each.\n * Shared by the publish/browse routes (the `category` enum), the Templates\n * page (tiles, URL filter, labels) and the publish dialog, so the list can\n * only change in one place. Labels live with the frontend's i18n\n * (`lib/template-categories.ts`), keyed by these values.\n */\nexport const TEMPLATE_CATEGORIES = [\n \"product-imagery\",\n \"static-ads\",\n \"user-generated-content\",\n \"video-ads\",\n \"brand-assets\",\n \"automations\",\n \"campaign-concepts\",\n \"social-creatives\",\n] as const\n\nexport type TemplateCategory = (typeof TEMPLATE_CATEGORIES)[number]\n\n/** Where a template with no usable category is filed: the plain \"it is a workflow\" bucket. */\nexport const DEFAULT_TEMPLATE_CATEGORY: TemplateCategory = \"automations\"\n\n/**\n * The categories templates were filed under before September 2026, each\n * read as its new home. Migration 423 rewrites the rows with the same map;\n * this keeps an old link (`?category=video-production`), a cached card and a\n * row the migration has not reached yet resolving in the meantime.\n */\nexport const LEGACY_TEMPLATE_CATEGORIES: Readonly<Record<string, TemplateCategory>> = {\n \"image-generation\": \"product-imagery\",\n \"video-production\": \"video-ads\",\n \"audio-music\": \"social-creatives\",\n \"content-writing\": \"campaign-concepts\",\n \"social-media\": \"social-creatives\",\n \"data-processing\": \"automations\",\n \"multi-step\": \"automations\",\n other: \"automations\",\n}\n\nconst CURRENT = new Set<string>(TEMPLATE_CATEGORIES)\n\nexport function isTemplateCategory(value: unknown): value is TemplateCategory {\n return typeof value === \"string\" && CURRENT.has(value)\n}\n\n/** A current category as is, a legacy one as its new home, anything else as undefined. */\nexport function resolveTemplateCategory(value: string | null | undefined): TemplateCategory | undefined {\n if (value == null) return undefined\n if (isTemplateCategory(value)) return value\n return LEGACY_TEMPLATE_CATEGORIES[value]\n}\n\n/** The category a stored row reads as: resolved, else the default bucket. */\nexport function normalizeTemplateCategory(value: string | null | undefined): TemplateCategory {\n return resolveTemplateCategory(value) ?? DEFAULT_TEMPLATE_CATEGORY\n}\n\n/**\n * Every stored value that reads as `category` — the value itself and the\n * legacy ones that map to it — so a database filter matches rows the\n * migration has not rewritten yet.\n */\nexport function templateCategoryStoredValues(category: TemplateCategory): string[] {\n const legacy = Object.keys(LEGACY_TEMPLATE_CATEGORIES).filter((value) => LEGACY_TEMPLATE_CATEGORIES[value] === category)\n return [category, ...legacy]\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from './chunk-VIWSWVAW.js';
1
+ import { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from './chunk-PHZ23DP3.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-LPW3XNC2.js.map
471
- //# sourceMappingURL=chunk-LPW3XNC2.js.map
470
+ //# sourceMappingURL=chunk-OZSACQ2V.js.map
471
+ //# sourceMappingURL=chunk-OZSACQ2V.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,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,OAAA,CAAQ,KAAA,CAAM,KAAK,CAAA,GAAI,EAAE,KAAA,EAAO,KAAA,CAAM,KAAA,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-LPW3XNC2.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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I,KAAA,CAAM,OAAA,CAAQ,KAAA,CAAM,KAAK,CAAA,GAAI,EAAE,KAAA,EAAO,KAAA,CAAM,KAAA,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-OZSACQ2V.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,4 +1,4 @@
1
- import { MODEL_CATALOG, VIDEO_DURATION_AUTO, isAutoVideoDuration } from './chunk-C57NEO3X.js';
1
+ import { MODEL_CATALOG, VIDEO_DURATION_AUTO, isAutoVideoDuration } from './chunk-ZO5PBBFX.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  var CREDIT_BASE_USD = 2e-3;
@@ -1778,5 +1778,5 @@ function applyDefaultVideoSelection(input) {
1778
1778
  }
1779
1779
 
1780
1780
  export { AI_WRITER_PROVIDERS, ASPECT_RATIO_DIMENSIONS, AUDIO_ADDON_PROVIDERS, CHARACTER_MOTION_PROVIDERS, COMPOSER_PLAN_FIELDS, COMPOSER_PLAN_MAP, CREDIT_BASE_USD, DEFAULT_DIALOGUE_PROVIDER, DEFAULT_MUSIC_PROVIDER, DEFAULT_REF_IMAGE_MAX, DEFAULT_SUNO_MODEL, DEFAULT_TEXT_TO_AUDIO_PROVIDER, DEFAULT_TRANSCRIBE_NODE_PROVIDER, DEFAULT_TRANSCRIBE_PROVIDER, DEFAULT_TTS_PROVIDER, DEFAULT_VIDEO_DURATION_SEC, DEFAULT_VIDEO_PROVIDER, DEFAULT_VOICE_DESIGN_MODEL, DIALOGUE_PROVIDERS, DURATION_PRICED_PROVIDERS, EXTEND_VIDEO_PROVIDERS, FACE_SWAP_PROVIDERS, FAL_LIP_SYNC_PROVIDERS, FLEXIBLE_INPUT_LIP_SYNC_PROVIDERS, FRAME_MODE_ADAPTIVE_ONLY_ASPECT, GEMINI_OMNI_PROVIDERS, GUIDANCE_SCALE_SUPPORT, GVP_ANCHOR_CHOICES, GVP_DEFAULT_PROVIDER, GVP_END_FRAME_PROVIDERS, GVP_EXTEND_PROVIDERS, GVP_SUPPORTED_PROVIDERS, HIGH_QUALITY_PROVIDERS, I2I_MASK_SUPPORT, I2I_STRENGTH_SUPPORT, IDEOGRAM_PROVIDERS, IMAGE_ASPECT_RATIO_VALUES, IMAGE_EDIT_PROVIDERS, IMAGE_GEN_PROVIDERS, IMAGE_I2I_PROVIDERS, IMAGE_MASK_MODE, IMAGE_PROMPT_MAX, IMAGE_TO_VIDEO_PROVIDERS, LIP_SYNC_PROVIDERS, LLM_TEXT_INPUT_MAX, LOCATION_ATMOSPHERE_PROVIDERS, MAX_IMAGE_PROMPT_CHARS_BY_PROVIDER, MAX_NEGATIVE_PROMPT_CHARS_BY_PROVIDER, MAX_TTS_CHARS_BY_PROVIDER, MAX_VIDEO_PROMPT_CHARS_BY_PROVIDER, MINIMAX_H3_DEFAULT_RESOLUTION, MINIMAX_H3_PROVIDERS, MODELS_WITH_REFERENCE_IMAGE_SUPPORT, MODE_ADDON_PROVIDERS, MODIFY_IMAGE_PROVIDERS, MOTION_DURATION_TIERS, MOTION_TRANSFER_PROVIDERS, MUSIC_CREDIT_ID, MUSIC_PROVIDERS, MUSIC_PROVIDER_LABELS, NATIVE_ADAPTIVE_ASPECT, NATIVE_NEGATIVE_PROMPT_MODELS, NATIVE_NEGATIVE_VIDEO_PROVIDERS, NEGATIVE_PROMPT_MAX, OBJECT_MOTION_PROVIDERS, PRICING_DEFAULT_DURATION_SEC, PRICING_DEFAULT_RESOLUTION, PROMPT_HARD_CEILING, QA_CHECK_PROVIDERS, REF_IMAGE_MAX_LIMITS, RENDERING_SPEED_SUPPORT, REPLICATE_LIP_SYNC_PROVIDERS, RESOLUTION_2K_4K_TIERED_PROVIDERS, RESOLUTION_DURATION_PRICING, RESOLUTION_VIDEO_REF_PRICING, SCRIPT_PROVIDERS, SEEDANCE_2_5_REF_LIMITS, SEEDANCE_2_CONTINUATION_REF_SEC, SEEDANCE_2_EXTEND_STITCH, SEEDANCE_2_PROVIDERS, SEEDANCE_2_R2V_MAX_AUDIO_SEC_BY_PROVIDER, SEEDANCE_2_R2V_MIN_REF_VIDEO_SEC, SEEDANCE_2_REF_LIMITS, SEEDANCE_LIP_SYNC_PROVIDERS, SEEDANCE_VIDEO_EDIT_PROVIDERS, SEEDANCE_VIDEO_EDIT_SHAPE, SEED_SUPPORT, SUNO_ACTIVE_MODELS, SUNO_ADD_TRACK_MODELS, SUNO_DURATION_MODELS, SUNO_HARD_CEILING, SUNO_LEGACY_MODELS, SUNO_MODELS, SUNO_TEXT_MAX, SUNO_TITLE_MAX, SceneInputModeSchema, T2I_TO_I2I_VARIANT, TASK_CHAINED_EDIT_PROVIDERS, TEXT_TO_AUDIO_PROVIDERS, TEXT_TO_VIDEO_PROVIDERS, TRANSCRIBE_LANES, TRANSCRIBE_PROVIDERS, TRANSCRIBE_PROVIDER_CAPABILITIES, TTS_PROVIDERS, TTS_TEXT_MAX, TWO_K_RESOLUTION_PROVIDERS, UPSCALE_IMAGE_PROVIDERS, VARIABLE_PRICING_MODELS, VEO_PROVIDERS, VEO_RESOLUTION_TIERED_PROVIDERS, VIDEO_AUDIO_CAPABILITY, VIDEO_DURATION_TIERS, VIDEO_GEN_COLLAPSED_T2V_IDS, VIDEO_GEN_PROVIDERS, VIDEO_INPUT_LIP_SYNC_PROVIDERS, VIDEO_MODEL_CAPS, VIDEO_MODE_ALIASES, VIDEO_PROMPT_MAX, VIDEO_PROVIDERS_REQUIRING_IMAGE, VIDEO_PROVIDERS_WITHOUT_DISPATCH, VIDEO_REF_LIMITS_BY_PROVIDER, VIDEO_REF_VIDEO_DURATION_LIMITS, VIDEO_TO_VIDEO_NODE_PROVIDERS, VIDEO_TO_VIDEO_PROVIDERS, VIDEO_UPSCALE_PROVIDERS, VIDEO_VARIABLE_PRICING, VOICE_DESIGN_MODELS, WAN_3_DEFAULT_RESOLUTION, WAN_3_PROVIDERS, applyDefaultVideoSelection, applyVideoAudioToggle, applyVideoNegativePrompt, checkRefVideoDurations, defaultVideoAspectRatio, findSeedance2AudioOverLimit, getMaxImagePromptChars, getMaxNegativePromptChars, getMaxSunoPromptChars, getMaxSunoStyleChars, getMaxTtsChars, getMaxVideoPromptChars, getVideoAudioCapability, hasContiguousSegmentDurations, imageReferenceLimit, isGeminiOmniProvider, isGvpSupportedProvider, isLegacySunoModel, isMinimaxH3Provider, isSeedance2Provider, isSeedanceVideoEditProvider, isVeoProvider, isWan3Provider, maxSegmentSecFor, maxSegmentsFor, maxVideoDurationSec, minSegmentSecFor, modelsForInputMode, normalizeMinimaxH3Resolution, normalizeWan3Resolution, preferredInputModeForModel, pricedOutputDurationSec, resolveGvpAnchorWire, resolveMusicProvider, resolveVideoModeForInputs, resolveVideoProviderForMode, seedance2AudioLimitSec, segmentDurationsFor, snapToNearestDuration, sunoModelHonoursDuration, supportsAutoVideoDuration, supportsEndAnchor, supportsExtendRender, transcribeLaneSupportsWordTimestamps, transcribeProvidersWithWordTimestamps, videoDefaultDurationSec, videoModelCanSpeakDialogue, videoModelSupportsAudio, videoNegativeSuffix, videoProviderFoldsLoneEndFrame, videoProviderRequiresImage };
1781
- //# sourceMappingURL=chunk-VIWSWVAW.js.map
1782
- //# sourceMappingURL=chunk-VIWSWVAW.js.map
1781
+ //# sourceMappingURL=chunk-PHZ23DP3.js.map
1782
+ //# sourceMappingURL=chunk-PHZ23DP3.js.map