@nodaro/shared 3.31.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.
- package/README.md +17 -0
- package/dist/chunk-23FJQTEA.js +1604 -0
- package/dist/chunk-23FJQTEA.js.map +1 -0
- package/dist/chunk-2NIQO2J3.cjs +54 -0
- package/dist/chunk-2NIQO2J3.cjs.map +1 -0
- package/dist/chunk-2NQLSLSN.cjs +19 -0
- package/dist/chunk-2NQLSLSN.cjs.map +1 -0
- package/dist/chunk-2OJIVO7R.cjs +32 -0
- package/dist/chunk-2OJIVO7R.cjs.map +1 -0
- package/dist/chunk-2RF4Z7KG.cjs +803 -0
- package/dist/chunk-2RF4Z7KG.cjs.map +1 -0
- package/dist/chunk-3RYKIUAE.js +86 -0
- package/dist/chunk-3RYKIUAE.js.map +1 -0
- package/dist/chunk-44I73CQS.cjs +194 -0
- package/dist/chunk-44I73CQS.cjs.map +1 -0
- package/dist/chunk-5PC6JBGJ.cjs +1419 -0
- package/dist/chunk-5PC6JBGJ.cjs.map +1 -0
- package/dist/chunk-5RU2HCW2.js +30 -0
- package/dist/chunk-5RU2HCW2.js.map +1 -0
- package/dist/chunk-5RYLK3MQ.js +267 -0
- package/dist/chunk-5RYLK3MQ.js.map +1 -0
- package/dist/chunk-5THUHJ3E.js +46 -0
- package/dist/chunk-5THUHJ3E.js.map +1 -0
- package/dist/chunk-6DAWSVX2.cjs +103 -0
- package/dist/chunk-6DAWSVX2.cjs.map +1 -0
- package/dist/chunk-6WZ2VN7V.js +920 -0
- package/dist/chunk-6WZ2VN7V.js.map +1 -0
- package/dist/chunk-7G7G42KS.js +86 -0
- package/dist/chunk-7G7G42KS.js.map +1 -0
- package/dist/chunk-7Z5LUTGU.js +1567 -0
- package/dist/chunk-7Z5LUTGU.js.map +1 -0
- package/dist/chunk-AINCI23X.js +2171 -0
- package/dist/chunk-AINCI23X.js.map +1 -0
- package/dist/chunk-BG5D5CZ6.js +1922 -0
- package/dist/chunk-BG5D5CZ6.js.map +1 -0
- package/dist/chunk-CK3GK34R.js +1381 -0
- package/dist/chunk-CK3GK34R.js.map +1 -0
- package/dist/chunk-CUH22J4D.js +17 -0
- package/dist/chunk-CUH22J4D.js.map +1 -0
- package/dist/chunk-D26ENTN2.cjs +1770 -0
- package/dist/chunk-D26ENTN2.cjs.map +1 -0
- package/dist/chunk-D6GNRSCV.cjs +2017 -0
- package/dist/chunk-D6GNRSCV.cjs.map +1 -0
- package/dist/chunk-FBV5DF6D.js +95 -0
- package/dist/chunk-FBV5DF6D.js.map +1 -0
- package/dist/chunk-FG4E7MTG.cjs +4 -0
- package/dist/chunk-FG4E7MTG.cjs.map +1 -0
- package/dist/chunk-FT5CF6IA.js +42 -0
- package/dist/chunk-FT5CF6IA.js.map +1 -0
- package/dist/chunk-G6IIVKMO.js +26 -0
- package/dist/chunk-G6IIVKMO.js.map +1 -0
- package/dist/chunk-HC7VKIV5.cjs +430 -0
- package/dist/chunk-HC7VKIV5.cjs.map +1 -0
- package/dist/chunk-HGC5JNVA.cjs +1503 -0
- package/dist/chunk-HGC5JNVA.cjs.map +1 -0
- package/dist/chunk-HKFMXNVQ.cjs +1273 -0
- package/dist/chunk-HKFMXNVQ.cjs.map +1 -0
- package/dist/chunk-HRXEZ3SX.cjs +526 -0
- package/dist/chunk-HRXEZ3SX.cjs.map +1 -0
- package/dist/chunk-HSHCCBIV.js +255 -0
- package/dist/chunk-HSHCCBIV.js.map +1 -0
- package/dist/chunk-HUR6ZJ7S.cjs +159 -0
- package/dist/chunk-HUR6ZJ7S.cjs.map +1 -0
- package/dist/chunk-J7BMO73N.cjs +114 -0
- package/dist/chunk-J7BMO73N.cjs.map +1 -0
- package/dist/chunk-JFS3NWZ5.cjs +1714 -0
- package/dist/chunk-JFS3NWZ5.cjs.map +1 -0
- package/dist/chunk-JL4C5VJ7.cjs +488 -0
- package/dist/chunk-JL4C5VJ7.cjs.map +1 -0
- package/dist/chunk-JSGIEF6Z.cjs +1087 -0
- package/dist/chunk-JSGIEF6Z.cjs.map +1 -0
- package/dist/chunk-JWA5SGCS.js +203 -0
- package/dist/chunk-JWA5SGCS.js.map +1 -0
- package/dist/chunk-K3LLGRK7.cjs +3545 -0
- package/dist/chunk-K3LLGRK7.cjs.map +1 -0
- package/dist/chunk-KU6S7IYV.cjs +210 -0
- package/dist/chunk-KU6S7IYV.cjs.map +1 -0
- package/dist/chunk-M36G6SRP.js +447 -0
- package/dist/chunk-M36G6SRP.js.map +1 -0
- package/dist/chunk-M7GQBRZU.cjs +1963 -0
- package/dist/chunk-M7GQBRZU.cjs.map +1 -0
- package/dist/chunk-MRXGWL42.cjs +4 -0
- package/dist/chunk-MRXGWL42.cjs.map +1 -0
- package/dist/chunk-NEJ2PV4C.cjs +211 -0
- package/dist/chunk-NEJ2PV4C.cjs.map +1 -0
- package/dist/chunk-OTATNBMD.js +141 -0
- package/dist/chunk-OTATNBMD.js.map +1 -0
- package/dist/chunk-OZSACQ2V.js +471 -0
- package/dist/chunk-OZSACQ2V.js.map +1 -0
- package/dist/chunk-PHZ23DP3.js +1782 -0
- package/dist/chunk-PHZ23DP3.js.map +1 -0
- package/dist/chunk-PQHS255G.js +1369 -0
- package/dist/chunk-PQHS255G.js.map +1 -0
- package/dist/chunk-PRYE7AZQ.cjs +1227 -0
- package/dist/chunk-PRYE7AZQ.cjs.map +1 -0
- package/dist/chunk-PVJBAPYJ.js +404 -0
- package/dist/chunk-PVJBAPYJ.js.map +1 -0
- package/dist/chunk-PXFQVLBX.js +776 -0
- package/dist/chunk-PXFQVLBX.js.map +1 -0
- package/dist/chunk-QA3MVQ32.js +21 -0
- package/dist/chunk-QA3MVQ32.js.map +1 -0
- package/dist/chunk-QJRP44ZO.js +769 -0
- package/dist/chunk-QJRP44ZO.js.map +1 -0
- package/dist/chunk-SAW5OK36.cjs +54 -0
- package/dist/chunk-SAW5OK36.cjs.map +1 -0
- package/dist/chunk-SES6GDBQ.cjs +624 -0
- package/dist/chunk-SES6GDBQ.cjs.map +1 -0
- package/dist/chunk-SFW3UB2P.js +31 -0
- package/dist/chunk-SFW3UB2P.js.map +1 -0
- package/dist/chunk-TNPDV7I4.cjs +2346 -0
- package/dist/chunk-TNPDV7I4.cjs.map +1 -0
- package/dist/chunk-TU33KYKW.cjs +25 -0
- package/dist/chunk-TU33KYKW.cjs.map +1 -0
- package/dist/chunk-TZBIY5C3.js +187 -0
- package/dist/chunk-TZBIY5C3.js.map +1 -0
- package/dist/chunk-TZE673G6.js +3 -0
- package/dist/chunk-TZE673G6.js.map +1 -0
- package/dist/chunk-UCFWI6D4.js +29 -0
- package/dist/chunk-UCFWI6D4.js.map +1 -0
- package/dist/chunk-UTQSSKSG.js +1164 -0
- package/dist/chunk-UTQSSKSG.js.map +1 -0
- package/dist/chunk-VA42637J.cjs +287 -0
- package/dist/chunk-VA42637J.cjs.map +1 -0
- package/dist/chunk-VNQRI2RO.cjs +1047 -0
- package/dist/chunk-VNQRI2RO.cjs.map +1 -0
- package/dist/chunk-VXPLKQWY.cjs +821 -0
- package/dist/chunk-VXPLKQWY.cjs.map +1 -0
- package/dist/chunk-WD6HJRBG.cjs +197 -0
- package/dist/chunk-WD6HJRBG.cjs.map +1 -0
- package/dist/chunk-WDIBOWAA.js +1054 -0
- package/dist/chunk-WDIBOWAA.js.map +1 -0
- package/dist/chunk-WKOIGLQX.cjs +38 -0
- package/dist/chunk-WKOIGLQX.cjs.map +1 -0
- package/dist/chunk-WNVQ3SMB.cjs +96 -0
- package/dist/chunk-WNVQ3SMB.cjs.map +1 -0
- package/dist/chunk-WRSWH7US.cjs +285 -0
- package/dist/chunk-WRSWH7US.cjs.map +1 -0
- package/dist/chunk-XGFTL5XY.js +181 -0
- package/dist/chunk-XGFTL5XY.js.map +1 -0
- package/dist/chunk-XNISPHTZ.js +1039 -0
- package/dist/chunk-XNISPHTZ.js.map +1 -0
- package/dist/chunk-Y2PM3FFL.js +3 -0
- package/dist/chunk-Y2PM3FFL.js.map +1 -0
- package/dist/chunk-YBPBK5KI.js +1030 -0
- package/dist/chunk-YBPBK5KI.js.map +1 -0
- package/dist/chunk-YWNYGYI7.cjs +31 -0
- package/dist/chunk-YWNYGYI7.cjs.map +1 -0
- package/dist/chunk-YYV35XOS.js +122 -0
- package/dist/chunk-YYV35XOS.js.map +1 -0
- package/dist/chunk-Z2OL5AJD.cjs +133 -0
- package/dist/chunk-Z2OL5AJD.cjs.map +1 -0
- package/dist/chunk-ZDFHA2EC.js +572 -0
- package/dist/chunk-ZDFHA2EC.js.map +1 -0
- package/dist/chunk-ZL7UM6PU.cjs +34 -0
- package/dist/chunk-ZL7UM6PU.cjs.map +1 -0
- package/dist/chunk-ZNZDQAXN.js +175 -0
- package/dist/chunk-ZNZDQAXN.js.map +1 -0
- package/dist/chunk-ZO5PBBFX.js +3497 -0
- package/dist/chunk-ZO5PBBFX.js.map +1 -0
- package/dist/chunk-ZRL2UFTH.cjs +1073 -0
- package/dist/chunk-ZRL2UFTH.cjs.map +1 -0
- package/dist/entries/apps.cjs +155 -0
- package/dist/entries/apps.cjs.map +1 -0
- package/dist/entries/apps.d.cts +292 -0
- package/dist/entries/apps.d.ts +292 -0
- package/dist/entries/apps.js +10 -0
- package/dist/entries/apps.js.map +1 -0
- package/dist/entries/captions.cjs +124 -0
- package/dist/entries/captions.cjs.map +1 -0
- package/dist/entries/captions.d.cts +354 -0
- package/dist/entries/captions.d.ts +354 -0
- package/dist/entries/captions.js +3 -0
- package/dist/entries/captions.js.map +1 -0
- package/dist/entries/catalogs.cjs +165 -0
- package/dist/entries/catalogs.cjs.map +1 -0
- package/dist/entries/catalogs.d.cts +385 -0
- package/dist/entries/catalogs.d.ts +385 -0
- package/dist/entries/catalogs.js +4 -0
- package/dist/entries/catalogs.js.map +1 -0
- package/dist/entries/credits.cjs +596 -0
- package/dist/entries/credits.cjs.map +1 -0
- package/dist/entries/credits.d.cts +1460 -0
- package/dist/entries/credits.d.ts +1460 -0
- package/dist/entries/credits.js +11 -0
- package/dist/entries/credits.js.map +1 -0
- package/dist/entries/edl.cjs +409 -0
- package/dist/entries/edl.cjs.map +1 -0
- package/dist/entries/edl.d.cts +1199 -0
- package/dist/entries/edl.d.ts +1199 -0
- package/dist/entries/edl.js +4 -0
- package/dist/entries/edl.js.map +1 -0
- package/dist/entries/entities.cjs +530 -0
- package/dist/entries/entities.cjs.map +1 -0
- package/dist/entries/entities.d.cts +1371 -0
- package/dist/entries/entities.d.ts +1371 -0
- package/dist/entries/entities.js +5 -0
- package/dist/entries/entities.js.map +1 -0
- package/dist/entries/i18n.cjs +48 -0
- package/dist/entries/i18n.cjs.map +1 -0
- package/dist/entries/i18n.d.cts +69 -0
- package/dist/entries/i18n.d.ts +69 -0
- package/dist/entries/i18n.js +3 -0
- package/dist/entries/i18n.js.map +1 -0
- package/dist/entries/llm-models.cjs +177 -0
- package/dist/entries/llm-models.cjs.map +1 -0
- package/dist/entries/llm-models.d.cts +435 -0
- package/dist/entries/llm-models.d.ts +435 -0
- package/dist/entries/llm-models.js +4 -0
- package/dist/entries/llm-models.js.map +1 -0
- package/dist/entries/media.cjs +335 -0
- package/dist/entries/media.cjs.map +1 -0
- package/dist/entries/media.d.cts +518 -0
- package/dist/entries/media.d.ts +518 -0
- package/dist/entries/media.js +6 -0
- package/dist/entries/media.js.map +1 -0
- package/dist/entries/model-catalog.cjs +259 -0
- package/dist/entries/model-catalog.cjs.map +1 -0
- package/dist/entries/model-catalog.d.cts +202 -0
- package/dist/entries/model-catalog.d.ts +202 -0
- package/dist/entries/model-catalog.js +6 -0
- package/dist/entries/model-catalog.js.map +1 -0
- package/dist/entries/models.cjs +833 -0
- package/dist/entries/models.cjs.map +1 -0
- package/dist/entries/models.d.cts +287 -0
- package/dist/entries/models.d.ts +287 -0
- package/dist/entries/models.js +8 -0
- package/dist/entries/models.js.map +1 -0
- package/dist/entries/nodes.cjs +789 -0
- package/dist/entries/nodes.cjs.map +1 -0
- package/dist/entries/nodes.d.cts +1600 -0
- package/dist/entries/nodes.d.ts +1600 -0
- package/dist/entries/nodes.js +16 -0
- package/dist/entries/nodes.js.map +1 -0
- package/dist/entries/organizations.cjs +80 -0
- package/dist/entries/organizations.cjs.map +1 -0
- package/dist/entries/organizations.d.cts +466 -0
- package/dist/entries/organizations.d.ts +466 -0
- package/dist/entries/organizations.js +3 -0
- package/dist/entries/organizations.js.map +1 -0
- package/dist/entries/pipeline.cjs +594 -0
- package/dist/entries/pipeline.cjs.map +1 -0
- package/dist/entries/pipeline.d.cts +2617 -0
- package/dist/entries/pipeline.d.ts +2617 -0
- package/dist/entries/pipeline.js +5 -0
- package/dist/entries/pipeline.js.map +1 -0
- package/dist/entries/scene3d.cjs +704 -0
- package/dist/entries/scene3d.cjs.map +1 -0
- package/dist/entries/scene3d.d.cts +4284 -0
- package/dist/entries/scene3d.d.ts +4284 -0
- package/dist/entries/scene3d.js +3 -0
- package/dist/entries/scene3d.js.map +1 -0
- package/dist/entries/social.cjs +714 -0
- package/dist/entries/social.cjs.map +1 -0
- package/dist/entries/social.d.cts +1366 -0
- package/dist/entries/social.d.ts +1366 -0
- package/dist/entries/social.js +5 -0
- package/dist/entries/social.js.map +1 -0
- package/dist/entries/types.cjs +13 -0
- package/dist/entries/types.cjs.map +1 -0
- package/dist/entries/types.d.cts +162 -0
- package/dist/entries/types.d.ts +162 -0
- package/dist/entries/types.js +4 -0
- package/dist/entries/types.js.map +1 -0
- package/dist/entries/ugc.cjs +279 -0
- package/dist/entries/ugc.cjs.map +1 -0
- package/dist/entries/ugc.d.cts +575 -0
- package/dist/entries/ugc.d.ts +575 -0
- package/dist/entries/ugc.js +6 -0
- package/dist/entries/ugc.js.map +1 -0
- package/dist/entries/video.cjs +549 -0
- package/dist/entries/video.cjs.map +1 -0
- package/dist/entries/video.d.cts +1791 -0
- package/dist/entries/video.d.ts +1791 -0
- package/dist/entries/video.js +8 -0
- package/dist/entries/video.js.map +1 -0
- package/dist/entries/workflow.cjs +574 -0
- package/dist/entries/workflow.cjs.map +1 -0
- package/dist/entries/workflow.d.cts +1743 -0
- package/dist/entries/workflow.d.ts +1743 -0
- package/dist/entries/workflow.js +5 -0
- package/dist/entries/workflow.js.map +1 -0
- package/dist/fan-out-meta-Bu6VyXcZ.d.cts +19 -0
- package/dist/fan-out-meta-Bu6VyXcZ.d.ts +19 -0
- package/dist/gemini-omni-voices-zeRXxSbZ.d.cts +174 -0
- package/dist/gemini-omni-voices-zeRXxSbZ.d.ts +174 -0
- package/dist/image-overlay-layers-CyBfRhxJ.d.cts +208 -0
- package/dist/image-overlay-layers-CyBfRhxJ.d.ts +208 -0
- package/dist/index.cjs +7747 -27084
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -24198
- package/dist/index.d.ts +32 -24198
- package/dist/index.js +40 -25220
- package/dist/index.js.map +1 -1
- package/dist/model-catalog-V-ZNzRSd.d.cts +651 -0
- package/dist/model-catalog-V-ZNzRSd.d.ts +651 -0
- package/dist/presentation-types-0ENOCjoj.d.cts +61 -0
- package/dist/presentation-types-0ENOCjoj.d.ts +61 -0
- package/dist/presentation-utils-D0kxsWf9.d.cts +92 -0
- package/dist/presentation-utils-pZwlEAzo.d.ts +92 -0
- package/dist/scene-node-types-C3kl_zyK.d.cts +1949 -0
- package/dist/scene-node-types-C3kl_zyK.d.ts +1949 -0
- package/dist/supported-fonts-CRoF1gOy.d.cts +16 -0
- package/dist/supported-fonts-CRoF1gOy.d.ts +16 -0
- package/dist/types-BRlFPEru.d.cts +511 -0
- package/dist/types-BRlFPEru.d.ts +511 -0
- package/dist/types-DffyGSy5.d.cts +67 -0
- package/dist/types-DffyGSy5.d.ts +67 -0
- package/package.json +102 -1
- package/src/__tests__/add-captions-plan.test.ts +6 -2
- package/src/__tests__/caption-edge-dash.test.ts +23 -0
- package/src/__tests__/fixtures/root-exports.baseline.json +4625 -0
- package/src/__tests__/input-field-extra-keys.test.ts +1 -0
- package/src/__tests__/model-makers.test.ts +76 -0
- package/src/__tests__/no-internal-imports.test.ts +1 -1
- package/src/__tests__/node-aspect-ratio.test.ts +25 -0
- package/src/__tests__/node-runtime-keys.test.ts +9 -0
- package/src/__tests__/package-entries.test.ts +50 -0
- package/src/__tests__/pitch-tempo-pricing.test.ts +21 -0
- package/src/__tests__/presentation-utils.test.ts +15 -0
- package/src/__tests__/preview-gate-use-case.test.ts +151 -0
- package/src/__tests__/private-host.test.ts +53 -0
- package/src/__tests__/run-continuation.test.ts +7 -1
- package/src/__tests__/site-capture-node.test.ts +58 -0
- package/src/__tests__/ugc-lane-wires.test.ts +228 -0
- package/src/__tests__/ugc-node-wires.test.ts +9 -3
- package/src/__tests__/ugc-run-state.test.ts +5 -4
- package/src/__tests__/video-analysis-catalog-sync.test.ts +1 -1
- package/src/__tests__/video-analysis-pricing.test.ts +6 -6
- package/src/__tests__/voice-changer-pro-quote.test.ts +79 -0
- package/src/add-captions-plan.ts +9 -3
- package/src/caption-edge-dash.ts +33 -0
- package/src/component-types.ts +9 -0
- package/src/credit-estimators/index.ts +22 -1
- package/src/credit-estimators/pitch-tempo.ts +15 -1
- package/src/credit-estimators/speech.ts +72 -4
- package/src/credit-estimators/unit-quote.ts +52 -0
- package/src/credit-estimators/video-sfx.ts +15 -0
- package/src/credit-estimators/voice-changer-pro-quote.ts +138 -0
- package/src/credit-identifiers.ts +62 -17
- package/src/entity-image-handle.ts +2 -0
- package/src/entries/apps.ts +63 -0
- package/src/entries/captions.ts +34 -0
- package/src/entries/catalogs.ts +65 -0
- package/src/entries/credits.ts +105 -0
- package/src/entries/edl.ts +42 -0
- package/src/entries/entities.ts +144 -0
- package/src/entries/i18n.ts +31 -0
- package/src/entries/llm-models.ts +63 -0
- package/src/entries/media.ts +36 -0
- package/src/entries/model-catalog.ts +95 -0
- package/src/entries/models.ts +266 -0
- package/src/entries/nodes.ts +245 -0
- package/src/entries/organizations.ts +9 -0
- package/src/entries/pipeline.ts +43 -0
- package/src/entries/scene3d.ts +27 -0
- package/src/entries/social.ts +297 -0
- package/src/entries/types.ts +26 -0
- package/src/entries/ugc.ts +14 -0
- package/src/entries/video.ts +59 -0
- package/src/entries/workflow.ts +172 -0
- package/src/fan-out-rows.ts +2 -0
- package/src/index.ts +25 -1845
- package/src/json-kinds.ts +4 -0
- package/src/model-catalog.ts +243 -34
- package/src/node-mappable-fields.ts +1 -0
- package/src/node-run-routes.ts +2 -0
- package/src/node-runtime-keys.ts +8 -0
- package/src/normalize-node-params.ts +30 -0
- package/src/presentation-utils.ts +12 -0
- package/src/preview-gate.ts +92 -14
- package/src/private-host.ts +89 -59
- package/src/producer-types.ts +16 -2
- package/src/run-continuation.ts +21 -0
- package/src/site-capture-node.ts +82 -0
- package/src/ugc-lane-wires.ts +246 -0
- package/src/ugc-node-wires.ts +37 -7
- package/src/ugc-run-state.ts +5 -3
- package/src/video-analysis-pricing.ts +31 -29
|
@@ -0,0 +1,1273 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk44I73CQS_cjs = require('./chunk-44I73CQS.cjs');
|
|
4
|
+
var chunkM7GQBRZU_cjs = require('./chunk-M7GQBRZU.cjs');
|
|
5
|
+
var chunkK3LLGRK7_cjs = require('./chunk-K3LLGRK7.cjs');
|
|
6
|
+
var zod = require('zod');
|
|
7
|
+
|
|
8
|
+
// src/video-character-refs.ts
|
|
9
|
+
var VIDEO_CHARACTER_REFS_WIRE_MAX = Math.max(
|
|
10
|
+
0,
|
|
11
|
+
...Object.values(chunkM7GQBRZU_cjs.VIDEO_REF_LIMITS_BY_PROVIDER).map((l) => l?.characters ?? 0)
|
|
12
|
+
);
|
|
13
|
+
var VIDEO_CHARACTER_DESCRIPTION_MAX = 2e3;
|
|
14
|
+
var VIDEO_CHARACTER_NAME_MAX = 100;
|
|
15
|
+
var VIDEO_CHARACTER_VOICE_DESCRIPTION_MAX = 2e3;
|
|
16
|
+
var VIDEO_CHARACTER_VOICE_EXAMPLE_MAX = 120;
|
|
17
|
+
function videoCharacterRefCap(provider) {
|
|
18
|
+
return provider ? chunkM7GQBRZU_cjs.VIDEO_REF_LIMITS_BY_PROVIDER[provider]?.characters ?? 0 : 0;
|
|
19
|
+
}
|
|
20
|
+
function videoCharacterVoiceCap(provider) {
|
|
21
|
+
return provider ? chunkM7GQBRZU_cjs.VIDEO_REF_LIMITS_BY_PROVIDER[provider]?.voices ?? 0 : 0;
|
|
22
|
+
}
|
|
23
|
+
function videoCharacterVoiceKey(ref) {
|
|
24
|
+
const voice = ref.voice;
|
|
25
|
+
if (!voice) return null;
|
|
26
|
+
return JSON.stringify([voice.preset, voice.description?.trim() ?? "", voice.exampleLine?.trim() ?? "", ref.name?.trim() ?? ""]);
|
|
27
|
+
}
|
|
28
|
+
function videoCharacterDistinctVoices(characterReferences) {
|
|
29
|
+
const keys = /* @__PURE__ */ new Set();
|
|
30
|
+
for (const c of characterReferences ?? []) {
|
|
31
|
+
const key = videoCharacterVoiceKey(c);
|
|
32
|
+
if (key) keys.add(key);
|
|
33
|
+
}
|
|
34
|
+
return keys.size;
|
|
35
|
+
}
|
|
36
|
+
function videoCharacterRefProviders() {
|
|
37
|
+
return Object.entries(chunkM7GQBRZU_cjs.VIDEO_REF_LIMITS_BY_PROVIDER).filter(([, l]) => (l?.characters ?? 0) > 0).map(([id]) => id);
|
|
38
|
+
}
|
|
39
|
+
function videoCharacterRefUnits(characterReferences) {
|
|
40
|
+
let units = 0;
|
|
41
|
+
for (const c of characterReferences ?? []) units += c.bodyImageUrl ? 2 : 1;
|
|
42
|
+
return units;
|
|
43
|
+
}
|
|
44
|
+
function videoCharacterVoiceProblem(args) {
|
|
45
|
+
const distinct = videoCharacterDistinctVoices(args.characterReferences);
|
|
46
|
+
if (distinct === 0) return null;
|
|
47
|
+
const cap = args.cap ?? videoCharacterVoiceCap(args.provider);
|
|
48
|
+
if (cap === 0) {
|
|
49
|
+
return {
|
|
50
|
+
code: "character_voice_unsupported",
|
|
51
|
+
message: `A character voice is not supported by ${args.provider ?? "the selected model"}. Drop the voice, or pick a model that takes characterReferences.`
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (distinct > cap) {
|
|
55
|
+
return {
|
|
56
|
+
code: "character_voices_over_limit",
|
|
57
|
+
message: `${args.provider} accepts at most ${cap} distinct character voices per video; got ${distinct}. Give some characters the same voice, or drop some.`
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
function videoCharacterRefProblem(args) {
|
|
63
|
+
const { provider, characterReferences } = args;
|
|
64
|
+
if (!characterReferences || characterReferences.length === 0) return null;
|
|
65
|
+
const cap = videoCharacterRefCap(provider);
|
|
66
|
+
if (cap === 0) {
|
|
67
|
+
return {
|
|
68
|
+
code: "character_references_unsupported",
|
|
69
|
+
message: `characterReferences is not supported by ${provider ?? "the selected model"}. Models that take them: ${videoCharacterRefProviders().join(", ")}. Otherwise send the portrait as a reference image instead.`
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (characterReferences.length > cap) {
|
|
73
|
+
return {
|
|
74
|
+
code: "character_references_over_limit",
|
|
75
|
+
message: `${provider} accepts at most ${cap} character references; got ${characterReferences.length}.`
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (args.hasStartFrame) {
|
|
79
|
+
return {
|
|
80
|
+
code: "character_references_with_start_frame",
|
|
81
|
+
message: `${provider} does not yet support combining characterReferences with a start frame (imageUrl) \u2014 the frame and the characters would compete for the same input slots without a defined role. Drop the start frame (the character's portrait carries the face), or drop characterReferences.`
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (args.hasEndFrame) {
|
|
85
|
+
return {
|
|
86
|
+
code: "character_references_with_end_frame",
|
|
87
|
+
message: `${provider} does not use an end frame (endFrameUrl) together with characterReferences. Drop the end frame, or drop characterReferences.`
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const budget = chunkM7GQBRZU_cjs.VIDEO_REF_LIMITS_BY_PROVIDER[provider]?.images ?? 7;
|
|
91
|
+
const used = args.imageCount + args.videoCount * 2 + videoCharacterRefUnits(characterReferences);
|
|
92
|
+
if (used > budget) {
|
|
93
|
+
return {
|
|
94
|
+
code: "character_references_quota",
|
|
95
|
+
message: `${provider} takes at most ${budget} input units: reference images count 1, each reference video 2, each character 1 (2 with a body image). This request uses ${used}. Remove some reference images or characters.`
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return videoCharacterVoiceProblem({ provider, characterReferences });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/video-duration.ts
|
|
102
|
+
function extractVideoDurationFromNode(data) {
|
|
103
|
+
if (!data) return void 0;
|
|
104
|
+
const results = data.generatedResults;
|
|
105
|
+
const idx = data.activeResultIndex ?? 0;
|
|
106
|
+
const fromResult = results?.[idx]?.duration;
|
|
107
|
+
if (typeof fromResult === "number" && Number.isFinite(fromResult) && fromResult > 0) {
|
|
108
|
+
return fromResult;
|
|
109
|
+
}
|
|
110
|
+
const fromConfig = data.duration;
|
|
111
|
+
if (typeof fromConfig === "number" && Number.isFinite(fromConfig) && fromConfig > 0) {
|
|
112
|
+
return fromConfig;
|
|
113
|
+
}
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
116
|
+
function editPlanSourceDurationSec(data) {
|
|
117
|
+
const fromVideo = extractVideoDurationFromNode(data);
|
|
118
|
+
if (fromVideo !== void 0) return fromVideo;
|
|
119
|
+
const meta = data?.metadata;
|
|
120
|
+
if (typeof meta?.mediaUrl === "string" && meta.mediaUrl !== data?.extractedAudioUrl && meta.mediaUrl !== data?.url) {
|
|
121
|
+
return void 0;
|
|
122
|
+
}
|
|
123
|
+
const d = meta?.durationSeconds;
|
|
124
|
+
return typeof d === "number" && Number.isFinite(d) && d > 0 ? d : void 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/video-overlay.ts
|
|
128
|
+
var VIDEO_OVERLAY_MAX_LAYERS = 20;
|
|
129
|
+
var VIDEO_OVERLAY_MAX_TIME_SEC = 3600;
|
|
130
|
+
var VIDEO_OVERLAY_HANDLE_IDS = [
|
|
131
|
+
"overlay",
|
|
132
|
+
"overlay2",
|
|
133
|
+
"overlay3",
|
|
134
|
+
"overlay4",
|
|
135
|
+
"overlay5",
|
|
136
|
+
"overlay6",
|
|
137
|
+
"overlay7",
|
|
138
|
+
"overlay8",
|
|
139
|
+
"overlay9",
|
|
140
|
+
"overlay10",
|
|
141
|
+
"overlay11",
|
|
142
|
+
"overlay12"
|
|
143
|
+
];
|
|
144
|
+
var VIDEO_OVERLAY_PRESET_IDS = ["card", "corner-badge", "full-frame"];
|
|
145
|
+
var VIDEO_OVERLAY_CORNERS = ["top-left", "top-right", "bottom-left", "bottom-right"];
|
|
146
|
+
var VIDEO_OVERLAY_FITS = ["contain", "cover"];
|
|
147
|
+
var VIDEO_OVERLAY_OUTPUT_ASPECTS = ["16:9", "9:16", "1:1", "4:5"];
|
|
148
|
+
var VIDEO_OVERLAY_LAYER_PLAN_HANDLE = "layerPlan";
|
|
149
|
+
var VIDEO_OVERLAY_BOUNDS = {
|
|
150
|
+
x: [-100, 100],
|
|
151
|
+
y: [-100, 100],
|
|
152
|
+
width: [1, 100],
|
|
153
|
+
height: [1, 100],
|
|
154
|
+
opacity: [0, 1],
|
|
155
|
+
zIndex: [0, 100]
|
|
156
|
+
};
|
|
157
|
+
var VIDEO_OVERLAY_MAX_TOTAL_LAYER_BYTES = 100 * 1024 * 1024;
|
|
158
|
+
var VIDEO_OVERLAY_ANIMATION_SEC = 0.15;
|
|
159
|
+
var VIDEO_OVERLAY_ANIMATION_MIN_SCALE = 0.96;
|
|
160
|
+
var VIDEO_OVERLAY_BADGE_WIDTH = 18;
|
|
161
|
+
var VIDEO_OVERLAY_BADGE_INSET = 4;
|
|
162
|
+
var VIDEO_OVERLAY_DEFAULT_BACKGROUND = "#000000";
|
|
163
|
+
var VIDEO_OVERLAY_BOX_FIELDS = ["anchor", "x", "y", "width", "height", "fit"];
|
|
164
|
+
var VIDEO_OVERLAY_WARNING_CODES = ["clipped", "skipped", "animated_first_frame", "audio_reencoded"];
|
|
165
|
+
var VIDEO_OVERLAY_ERROR_CODES = [
|
|
166
|
+
"no_layers",
|
|
167
|
+
"too_many_layers",
|
|
168
|
+
"incomplete_box",
|
|
169
|
+
"layer_without_image",
|
|
170
|
+
"time_out_of_range",
|
|
171
|
+
"end_before_start",
|
|
172
|
+
"fit_without_aspect",
|
|
173
|
+
"field_out_of_bounds",
|
|
174
|
+
"invalid_layer_plan"
|
|
175
|
+
];
|
|
176
|
+
var badge = (anchor, sx, sy) => ({
|
|
177
|
+
anchor,
|
|
178
|
+
x: sx * VIDEO_OVERLAY_BADGE_INSET,
|
|
179
|
+
y: sy * VIDEO_OVERLAY_BADGE_INSET,
|
|
180
|
+
width: VIDEO_OVERLAY_BADGE_WIDTH,
|
|
181
|
+
fit: "contain"
|
|
182
|
+
});
|
|
183
|
+
var VIDEO_OVERLAY_PRESETS = {
|
|
184
|
+
card: { anchor: "center", x: 0, y: -4, width: 78, height: 60, fit: "contain" },
|
|
185
|
+
"full-frame": { anchor: "center", x: 0, y: 0, width: 100, height: 100, fit: "cover" },
|
|
186
|
+
"corner-badge": {
|
|
187
|
+
"bottom-right": badge("bottom-right", -1, -1),
|
|
188
|
+
"bottom-left": badge("bottom-left", 1, -1),
|
|
189
|
+
"top-right": badge("top-right", -1, 1),
|
|
190
|
+
"top-left": badge("top-left", 1, 1)
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
var DEFAULT_VIDEO_OVERLAY_LAYER = Object.freeze({
|
|
194
|
+
start: 0,
|
|
195
|
+
preset: "corner-badge",
|
|
196
|
+
corner: "bottom-right",
|
|
197
|
+
...VIDEO_OVERLAY_PRESETS["corner-badge"]["bottom-right"],
|
|
198
|
+
opacity: 1,
|
|
199
|
+
animate: true
|
|
200
|
+
});
|
|
201
|
+
var HEX6 = /^#[0-9a-fA-F]{6}$/;
|
|
202
|
+
function isVideoOverlayPresetId(v) {
|
|
203
|
+
return typeof v === "string" && VIDEO_OVERLAY_PRESET_IDS.includes(v);
|
|
204
|
+
}
|
|
205
|
+
function isVideoOverlayCorner(v) {
|
|
206
|
+
return typeof v === "string" && VIDEO_OVERLAY_CORNERS.includes(v);
|
|
207
|
+
}
|
|
208
|
+
function isVideoOverlayOutputAspect(v) {
|
|
209
|
+
return typeof v === "string" && VIDEO_OVERLAY_OUTPUT_ASPECTS.includes(v);
|
|
210
|
+
}
|
|
211
|
+
function isFit(v) {
|
|
212
|
+
return v === "contain" || v === "cover";
|
|
213
|
+
}
|
|
214
|
+
function asLayer(v) {
|
|
215
|
+
return v !== null && typeof v === "object" && !Array.isArray(v) ? v : null;
|
|
216
|
+
}
|
|
217
|
+
function videoOverlaySlotOfHandle(handle) {
|
|
218
|
+
return VIDEO_OVERLAY_HANDLE_IDS.indexOf(handle ?? "") + 1;
|
|
219
|
+
}
|
|
220
|
+
function videoOverlayPresetBox(preset, corner) {
|
|
221
|
+
return preset === "corner-badge" ? VIDEO_OVERLAY_PRESETS["corner-badge"][isVideoOverlayCorner(corner) ? corner : "bottom-right"] : VIDEO_OVERLAY_PRESETS[preset];
|
|
222
|
+
}
|
|
223
|
+
var TRAILING_DEFAULTS = { x: 0, y: 0, fit: "contain", opacity: 1, animate: true };
|
|
224
|
+
function usable(key, value) {
|
|
225
|
+
if (value === null || value === void 0) return false;
|
|
226
|
+
if (key === "preset") return isVideoOverlayPresetId(value);
|
|
227
|
+
if (key === "corner") return isVideoOverlayCorner(value);
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
function clean(raw) {
|
|
231
|
+
const entries = Object.entries(raw);
|
|
232
|
+
if (entries.every(([k, v]) => usable(k, v))) return raw;
|
|
233
|
+
return Object.fromEntries(entries.filter(([k, v]) => usable(k, v)));
|
|
234
|
+
}
|
|
235
|
+
function sameShallow(a, b) {
|
|
236
|
+
if (!b || typeof b !== "object") return false;
|
|
237
|
+
const ka = Object.keys(a);
|
|
238
|
+
const kb = Object.keys(b);
|
|
239
|
+
return ka.length === kb.length && ka.every((k) => a[k] === b[k]);
|
|
240
|
+
}
|
|
241
|
+
function expandVideoOverlayLayer(raw) {
|
|
242
|
+
const obj = asLayer(raw);
|
|
243
|
+
const layer = obj ? clean(obj) : {};
|
|
244
|
+
const present = VIDEO_OVERLAY_BOX_FIELDS.filter((f) => layer[f] !== void 0);
|
|
245
|
+
let out;
|
|
246
|
+
if (isVideoOverlayPresetId(layer.preset)) {
|
|
247
|
+
const box = videoOverlayPresetBox(layer.preset, layer.corner);
|
|
248
|
+
out = { ...box, ...layer };
|
|
249
|
+
if (present.some((f) => layer[f] !== box[f])) delete out.preset;
|
|
250
|
+
} else if (present.length === 0) {
|
|
251
|
+
out = { ...DEFAULT_VIDEO_OVERLAY_LAYER, ...videoOverlayPresetBox("corner-badge", layer.corner), ...layer };
|
|
252
|
+
} else if (layer.anchor === void 0 || layer.width === void 0) {
|
|
253
|
+
return raw;
|
|
254
|
+
} else {
|
|
255
|
+
out = { ...layer };
|
|
256
|
+
}
|
|
257
|
+
for (const [k, v] of Object.entries(TRAILING_DEFAULTS)) if (out[k] === void 0) out[k] = v;
|
|
258
|
+
return sameShallow(out, raw) ? raw : out;
|
|
259
|
+
}
|
|
260
|
+
function expandVideoOverlayPresets(layers) {
|
|
261
|
+
let changed = false;
|
|
262
|
+
const out = layers.map((l) => {
|
|
263
|
+
const e = expandVideoOverlayLayer(l);
|
|
264
|
+
if (e !== l) changed = true;
|
|
265
|
+
return e;
|
|
266
|
+
});
|
|
267
|
+
return changed ? out : layers;
|
|
268
|
+
}
|
|
269
|
+
function applyVideoOverlayPreset(layer, preset, corner) {
|
|
270
|
+
const base = { ...expandVideoOverlayLayer(layer) };
|
|
271
|
+
for (const f of VIDEO_OVERLAY_BOX_FIELDS) delete base[f];
|
|
272
|
+
delete base.preset;
|
|
273
|
+
const nextCorner = preset === "corner-badge" ? corner ?? (isVideoOverlayCorner(base.corner) ? base.corner : "bottom-right") : void 0;
|
|
274
|
+
return expandVideoOverlayLayer({
|
|
275
|
+
...base,
|
|
276
|
+
...videoOverlayPresetBox(preset, nextCorner),
|
|
277
|
+
preset,
|
|
278
|
+
...nextCorner ? { corner: nextCorner } : {}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function toCustomVideoOverlayLayer(layer) {
|
|
282
|
+
const { preset: _tag, ...rest } = expandVideoOverlayLayer(layer);
|
|
283
|
+
return rest;
|
|
284
|
+
}
|
|
285
|
+
function clearWiredVideoOverlayImageUrls(layers, wiredSlots) {
|
|
286
|
+
let out = null;
|
|
287
|
+
for (const slot of wiredSlots) {
|
|
288
|
+
if (!Number.isInteger(slot) || slot < 1 || slot > VIDEO_OVERLAY_HANDLE_IDS.length) continue;
|
|
289
|
+
const layer = layers[slot - 1];
|
|
290
|
+
if (!asLayer(layer) || !("imageUrl" in layer)) continue;
|
|
291
|
+
out ??= [...layers];
|
|
292
|
+
const { imageUrl: _cleared, ...rest } = layer;
|
|
293
|
+
out[slot - 1] = rest;
|
|
294
|
+
}
|
|
295
|
+
return out ?? layers;
|
|
296
|
+
}
|
|
297
|
+
function normalizeVideoOverlayNodes(nodes, edges) {
|
|
298
|
+
let changed = false;
|
|
299
|
+
const out = nodes.map((node) => {
|
|
300
|
+
if (node.type !== "video-overlay") return node;
|
|
301
|
+
const data = node.data;
|
|
302
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) return node;
|
|
303
|
+
const d = data;
|
|
304
|
+
if (!Array.isArray(d.layers)) return node;
|
|
305
|
+
const layers = d.layers;
|
|
306
|
+
const wired = /* @__PURE__ */ new Set();
|
|
307
|
+
for (const e of edges ?? []) {
|
|
308
|
+
if (e.target !== node.id) continue;
|
|
309
|
+
const slot = videoOverlaySlotOfHandle(typeof e.targetHandle === "string" ? e.targetHandle : void 0);
|
|
310
|
+
if (slot > 0) wired.add(slot);
|
|
311
|
+
}
|
|
312
|
+
const cleared = clearWiredVideoOverlayImageUrls(layers, wired);
|
|
313
|
+
let layersChanged = cleared !== layers;
|
|
314
|
+
const next = cleared.map((l) => {
|
|
315
|
+
if (!asLayer(l)) return l;
|
|
316
|
+
const e = expandVideoOverlayLayer(l);
|
|
317
|
+
if (e !== l) layersChanged = true;
|
|
318
|
+
return e;
|
|
319
|
+
});
|
|
320
|
+
if (!layersChanged) return node;
|
|
321
|
+
changed = true;
|
|
322
|
+
return { ...node, data: { ...d, layers: next } };
|
|
323
|
+
});
|
|
324
|
+
return changed ? out : nodes;
|
|
325
|
+
}
|
|
326
|
+
var PLAN_LAYER_Z_BASE = 1e3;
|
|
327
|
+
var isSlot = (v) => typeof v === "number" && Number.isInteger(v) && v >= 1;
|
|
328
|
+
var isIndex = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0;
|
|
329
|
+
function videoOverlayRenderOrder(layers) {
|
|
330
|
+
return layers.map((l, i) => {
|
|
331
|
+
const own = isSlot(l?.planLayer) ? l.planLayer - 1 - PLAN_LAYER_Z_BASE : isSlot(l?.slot) ? l.slot - 1 : isIndex(l?.index) ? l.index : i;
|
|
332
|
+
return { i, z: typeof l?.zIndex === "number" && Number.isFinite(l.zIndex) ? l.zIndex : own };
|
|
333
|
+
}).sort((a, b) => a.z - b.z || a.i - b.i).map((e) => e.i);
|
|
334
|
+
}
|
|
335
|
+
var evenFloor = (n) => Math.max(2, Math.floor(n / 2) * 2);
|
|
336
|
+
function videoOverlayCanvas(display, outputAspect) {
|
|
337
|
+
if (isVideoOverlayOutputAspect(outputAspect)) {
|
|
338
|
+
const d = chunkM7GQBRZU_cjs.ASPECT_RATIO_DIMENSIONS[outputAspect];
|
|
339
|
+
return { w: d.width, h: d.height };
|
|
340
|
+
}
|
|
341
|
+
if (!display || !(display.width > 0) || !(display.height > 0)) return null;
|
|
342
|
+
const sar = typeof display.sar === "number" && Number.isFinite(display.sar) && display.sar > 0 ? display.sar : 1;
|
|
343
|
+
return { w: evenFloor(display.width * sar), h: evenFloor(display.height) };
|
|
344
|
+
}
|
|
345
|
+
function anchorFactors(anchor) {
|
|
346
|
+
const h = anchor.endsWith("left") ? 0 : anchor.endsWith("right") ? 1 : 0.5;
|
|
347
|
+
const v = anchor.startsWith("top") ? 0 : anchor.startsWith("bottom") ? 1 : 0.5;
|
|
348
|
+
return [h, v];
|
|
349
|
+
}
|
|
350
|
+
function resolveVideoOverlayGeometry(canvas, layer, imageAspect) {
|
|
351
|
+
const aspect = Number.isFinite(imageAspect) && imageAspect > 0 ? imageAspect : 1;
|
|
352
|
+
let bw = Math.max(1, Math.round(layer.width / 100 * canvas.w));
|
|
353
|
+
let bh = layer.height !== void 0 ? Math.max(1, Math.round(layer.height / 100 * canvas.h)) : Math.max(1, Math.round(bw / aspect));
|
|
354
|
+
if (layer.height === void 0 && bh > canvas.h) {
|
|
355
|
+
bw = Math.max(1, Math.round(bw * (canvas.h / bh)));
|
|
356
|
+
bh = canvas.h;
|
|
357
|
+
}
|
|
358
|
+
const [ax, ay] = anchorFactors(layer.anchor);
|
|
359
|
+
const left = Math.round(ax * (canvas.w - bw) + layer.x / 100 * canvas.w);
|
|
360
|
+
const top = Math.round(ay * (canvas.h - bh) + layer.y / 100 * canvas.h);
|
|
361
|
+
let dw;
|
|
362
|
+
let dh;
|
|
363
|
+
if (layer.fit === "cover") {
|
|
364
|
+
dw = bw;
|
|
365
|
+
dh = bh;
|
|
366
|
+
} else if (bw / bh > aspect) {
|
|
367
|
+
dh = bh;
|
|
368
|
+
dw = bh * aspect;
|
|
369
|
+
} else {
|
|
370
|
+
dw = bw;
|
|
371
|
+
dh = bw / aspect;
|
|
372
|
+
}
|
|
373
|
+
const width = evenFloor(dw);
|
|
374
|
+
const height = evenFloor(dh);
|
|
375
|
+
return {
|
|
376
|
+
box: { left, top, width: bw, height: bh },
|
|
377
|
+
drawn: { left: left + Math.floor((bw - width) / 2), top: top + Math.floor((bh - height) / 2), width, height }
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
var inTimeRange = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= VIDEO_OVERLAY_MAX_TIME_SEC;
|
|
381
|
+
var BOUNDED_FIELDS = Object.keys(VIDEO_OVERLAY_BOUNDS);
|
|
382
|
+
function outOfBounds(l) {
|
|
383
|
+
for (const f of BOUNDED_FIELDS) {
|
|
384
|
+
const v = l[f];
|
|
385
|
+
if (v === void 0 || v === null) continue;
|
|
386
|
+
const [min, max] = VIDEO_OVERLAY_BOUNDS[f];
|
|
387
|
+
const integer = f === "zIndex";
|
|
388
|
+
if (typeof v !== "number" || !Number.isFinite(v) || v < min || v > max || integer && !Number.isInteger(v)) {
|
|
389
|
+
return { field: f, allowed: `${integer ? "integers " : ""}${min}..${max}` };
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (l.anchor != null && !chunk44I73CQS_cjs.OVERLAY_ANCHORS.includes(l.anchor)) {
|
|
393
|
+
return { field: "anchor", allowed: chunk44I73CQS_cjs.OVERLAY_ANCHORS.join(", ") };
|
|
394
|
+
}
|
|
395
|
+
if (l.fit != null && !isFit(l.fit)) return { field: "fit", allowed: VIDEO_OVERLAY_FITS.join(", ") };
|
|
396
|
+
if (l.animate != null && typeof l.animate !== "boolean") return { field: "animate", allowed: "true, false" };
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
function hasDrawableVideoOverlayBox(layer) {
|
|
400
|
+
const l = asLayer(layer);
|
|
401
|
+
if (!l) return false;
|
|
402
|
+
if (!chunk44I73CQS_cjs.OVERLAY_ANCHORS.includes(l.anchor)) return false;
|
|
403
|
+
if (typeof l.width !== "number" || !Number.isFinite(l.width)) return false;
|
|
404
|
+
return outOfBounds(l) === null;
|
|
405
|
+
}
|
|
406
|
+
function validateVideoOverlayRequest(body) {
|
|
407
|
+
if (body.planError) return { ok: false, code: "invalid_layer_plan", params: {} };
|
|
408
|
+
const layers = Array.isArray(body.layers) ? body.layers : [];
|
|
409
|
+
if (layers.length === 0) return { ok: false, code: "no_layers", params: {} };
|
|
410
|
+
if (layers.length > VIDEO_OVERLAY_MAX_LAYERS) {
|
|
411
|
+
return { ok: false, code: "too_many_layers", params: { max: VIDEO_OVERLAY_MAX_LAYERS, count: layers.length } };
|
|
412
|
+
}
|
|
413
|
+
for (let i = 0; i < layers.length; i++) {
|
|
414
|
+
const l = asLayer(layers[i]) ?? {};
|
|
415
|
+
const at = (code, params = {}) => ({
|
|
416
|
+
ok: false,
|
|
417
|
+
code,
|
|
418
|
+
layer: i,
|
|
419
|
+
...typeof l.slot === "number" ? { slot: l.slot } : {},
|
|
420
|
+
...typeof l.planLayer === "number" ? { planLayer: l.planLayer } : {},
|
|
421
|
+
params
|
|
422
|
+
});
|
|
423
|
+
const boxFields = VIDEO_OVERLAY_BOX_FIELDS.filter((f) => l[f] !== void 0 && l[f] !== null);
|
|
424
|
+
if (!isVideoOverlayPresetId(l.preset) && boxFields.length > 0 && (l.anchor == null || l.width == null)) return at("incomplete_box");
|
|
425
|
+
const bad = outOfBounds(l);
|
|
426
|
+
if (bad) return at("field_out_of_bounds", bad);
|
|
427
|
+
if (typeof l.imageUrl !== "string" || l.imageUrl.length === 0) return at("layer_without_image");
|
|
428
|
+
if (!inTimeRange(l.start)) return at("time_out_of_range", { field: "start", max: VIDEO_OVERLAY_MAX_TIME_SEC });
|
|
429
|
+
if (l.end !== void 0 && l.end !== null) {
|
|
430
|
+
if (!inTimeRange(l.end)) return at("time_out_of_range", { field: "end", max: VIDEO_OVERLAY_MAX_TIME_SEC });
|
|
431
|
+
if (!(l.end > l.start)) return at("end_before_start", { start: l.start, end: l.end });
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (!isVideoOverlayOutputAspect(body.outputAspect) && (body.baseFit != null || body.backgroundColor != null)) {
|
|
435
|
+
return { ok: false, code: "fit_without_aspect", params: {} };
|
|
436
|
+
}
|
|
437
|
+
return { ok: true };
|
|
438
|
+
}
|
|
439
|
+
var MESSAGES = {
|
|
440
|
+
no_layers: () => "At least 1 layer is required",
|
|
441
|
+
too_many_layers: (p) => `At most ${p.max} layers (got ${p.count})`,
|
|
442
|
+
incomplete_box: () => "anchor and width are required without a preset",
|
|
443
|
+
layer_without_image: () => "no image \u2014 connect one to the layer's handle or set imageUrl",
|
|
444
|
+
time_out_of_range: (p) => `${p.field} must be between 0 and ${p.max} s`,
|
|
445
|
+
end_before_start: (p) => `end (${p.end} s) must be after start (${p.start} s)`,
|
|
446
|
+
fit_without_aspect: () => "baseFit and backgroundColor need an outputAspect",
|
|
447
|
+
field_out_of_bounds: (p) => `${p.field} is out of range (allowed: ${p.allowed})`,
|
|
448
|
+
invalid_layer_plan: () => "the layer plan must be a list of layers"
|
|
449
|
+
};
|
|
450
|
+
var PLAN_LAYER_WITHOUT_IMAGE = "no image \u2014 set imageUrl on this layer in the plan.";
|
|
451
|
+
function videoOverlayLayerLabel(ref) {
|
|
452
|
+
if (typeof ref.planLayer === "number") return `Plan layer ${ref.planLayer}`;
|
|
453
|
+
return typeof ref.slot === "number" ? `Layer ${ref.slot}` : typeof ref.layer === "number" ? `layers[${ref.layer}]` : "";
|
|
454
|
+
}
|
|
455
|
+
function formatVideoOverlayError(issue) {
|
|
456
|
+
const label = videoOverlayLayerLabel(issue);
|
|
457
|
+
const text = issue.code === "layer_without_image" && typeof issue.planLayer === "number" ? PLAN_LAYER_WITHOUT_IMAGE : MESSAGES[issue.code](issue.params);
|
|
458
|
+
return label ? `${label}: ${text}` : text;
|
|
459
|
+
}
|
|
460
|
+
function parseVideoOverlayLayerPlan(raw) {
|
|
461
|
+
let value = raw;
|
|
462
|
+
if (typeof raw === "string") {
|
|
463
|
+
try {
|
|
464
|
+
value = JSON.parse(raw);
|
|
465
|
+
} catch {
|
|
466
|
+
return { error: "invalid_layer_plan" };
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (!Array.isArray(value) || !value.every((l) => l !== null && typeof l === "object" && !Array.isArray(l))) {
|
|
470
|
+
return { error: "invalid_layer_plan" };
|
|
471
|
+
}
|
|
472
|
+
return { layers: value };
|
|
473
|
+
}
|
|
474
|
+
function assembleVideoOverlayRequest(input) {
|
|
475
|
+
const stored = Array.isArray(input.data.layers) ? input.data.layers : [];
|
|
476
|
+
const wired = input.wiredImageUrls.slice(0, VIDEO_OVERLAY_HANDLE_IDS.length);
|
|
477
|
+
const slots = Math.max(wired.length, stored.length);
|
|
478
|
+
const layers = [];
|
|
479
|
+
for (let i = 0; i < slots; i++) {
|
|
480
|
+
const raw = asLayer(stored[i]);
|
|
481
|
+
const wiredUrl = wired[i];
|
|
482
|
+
const own = raw?.imageUrl;
|
|
483
|
+
const image = typeof wiredUrl === "string" && wiredUrl.length > 0 ? wiredUrl : typeof own === "string" && own.length > 0 ? own : void 0;
|
|
484
|
+
if (!image) continue;
|
|
485
|
+
layers.push(expandVideoOverlayLayer({ ...raw ?? {}, imageUrl: image, slot: i + 1 }));
|
|
486
|
+
}
|
|
487
|
+
const outputAspect = isVideoOverlayOutputAspect(input.data.outputAspect) ? input.data.outputAspect : void 0;
|
|
488
|
+
const baseFit = isFit(input.data.baseFit) ? input.data.baseFit : void 0;
|
|
489
|
+
const backgroundColor = typeof input.data.backgroundColor === "string" && HEX6.test(input.data.backgroundColor) ? input.data.backgroundColor : void 0;
|
|
490
|
+
const rest = {
|
|
491
|
+
...outputAspect ? { outputAspect } : {},
|
|
492
|
+
...baseFit ? { baseFit } : {},
|
|
493
|
+
...backgroundColor ? { backgroundColor } : {}
|
|
494
|
+
};
|
|
495
|
+
if (input.planLayers === void 0) return { videoUrl: input.videoUrl, layers, ...rest };
|
|
496
|
+
const plan = parseVideoOverlayLayerPlan(input.planLayers);
|
|
497
|
+
if ("error" in plan) return { videoUrl: input.videoUrl, layers, ...rest, planError: plan.error };
|
|
498
|
+
const planned = expandVideoOverlayPresets(plan.layers).map((l, i) => {
|
|
499
|
+
const { slot: _slot, ...own } = l;
|
|
500
|
+
return { ...own, planLayer: i + 1 };
|
|
501
|
+
});
|
|
502
|
+
return { videoUrl: input.videoUrl, layers: [...planned, ...layers], ...rest };
|
|
503
|
+
}
|
|
504
|
+
function videoOverlaySlotSources(layers, wiredImageUrls) {
|
|
505
|
+
const stored = Array.isArray(layers) ? layers : [];
|
|
506
|
+
const wired = wiredImageUrls.slice(0, VIDEO_OVERLAY_HANDLE_IDS.length);
|
|
507
|
+
return Array.from({ length: Math.max(stored.length, wired.length) }, (_, i) => {
|
|
508
|
+
const w = wired[i];
|
|
509
|
+
if (typeof w === "string" && w.length > 0) return w;
|
|
510
|
+
const own = asLayer(stored[i])?.imageUrl;
|
|
511
|
+
return typeof own === "string" && own.length > 0 ? own : void 0;
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
function canonicalValue(v) {
|
|
515
|
+
if (Array.isArray(v)) return v.map((x) => x === void 0 ? null : canonicalValue(x));
|
|
516
|
+
if (v !== null && typeof v === "object") {
|
|
517
|
+
const out = {};
|
|
518
|
+
for (const k of Object.keys(v).sort()) {
|
|
519
|
+
const x = v[k];
|
|
520
|
+
if (x !== void 0 && x !== null) out[k] = canonicalValue(x);
|
|
521
|
+
}
|
|
522
|
+
return out;
|
|
523
|
+
}
|
|
524
|
+
return v;
|
|
525
|
+
}
|
|
526
|
+
var VIDEO_OVERLAY_MAX_COMPOSITION_KEY_LENGTH = 65536;
|
|
527
|
+
function videoOverlayCompositionKey(c) {
|
|
528
|
+
const sources = c.sources.map((s) => typeof s === "string" && s.length > 0 ? s : null);
|
|
529
|
+
while (sources.length > 0 && sources[sources.length - 1] === null) sources.pop();
|
|
530
|
+
const parts = [
|
|
531
|
+
c.baseUrl || null,
|
|
532
|
+
sources,
|
|
533
|
+
Array.isArray(c.data.layers) ? c.data.layers : [],
|
|
534
|
+
c.data.outputAspect ?? null,
|
|
535
|
+
c.data.baseFit ?? null,
|
|
536
|
+
c.data.backgroundColor ?? null
|
|
537
|
+
];
|
|
538
|
+
if (c.planLayers !== void 0) {
|
|
539
|
+
const plan = parseVideoOverlayLayerPlan(c.planLayers);
|
|
540
|
+
parts.push("error" in plan ? "invalid" : plan.layers);
|
|
541
|
+
}
|
|
542
|
+
return JSON.stringify(canonicalValue(parts));
|
|
543
|
+
}
|
|
544
|
+
var VIDEO_ANALYSIS_MAX_SCENE_SEC = 8;
|
|
545
|
+
var VIDEO_ANALYSIS_SHOT_ANGLES = [
|
|
546
|
+
// Vertical placement and roll — the classical "angles".
|
|
547
|
+
"eye-level",
|
|
548
|
+
"low",
|
|
549
|
+
"high",
|
|
550
|
+
"overhead",
|
|
551
|
+
"worms-eye",
|
|
552
|
+
"dutch",
|
|
553
|
+
// Relational viewpoints — where the camera sits with respect to the subject.
|
|
554
|
+
"over-the-shoulder",
|
|
555
|
+
"pov",
|
|
556
|
+
"profile",
|
|
557
|
+
"from-behind"
|
|
558
|
+
];
|
|
559
|
+
var VIDEO_ANALYSIS_FACELESS_ANGLES = /* @__PURE__ */ new Set(["over-the-shoulder", "from-behind"]);
|
|
560
|
+
var VIDEO_ANALYSIS_VISUAL_EFFECTS = [
|
|
561
|
+
"blur",
|
|
562
|
+
"pixelate",
|
|
563
|
+
"glitch",
|
|
564
|
+
"grain",
|
|
565
|
+
"vignette",
|
|
566
|
+
"flash",
|
|
567
|
+
"distortion",
|
|
568
|
+
"double-exposure"
|
|
569
|
+
];
|
|
570
|
+
var VIDEO_ANALYSIS_TRANSITIONS = [
|
|
571
|
+
"cut",
|
|
572
|
+
"fade",
|
|
573
|
+
"dissolve",
|
|
574
|
+
"wipe",
|
|
575
|
+
"whip",
|
|
576
|
+
// v2 (2026-08-30, recast shot craft rev 1.5 Appendix F): the common edits a
|
|
577
|
+
// creator actually cuts with. `white-flash` / `digital-glitch` are spelled
|
|
578
|
+
// out because `flash` / `glitch` already name in-shot EFFECTS (the axis test
|
|
579
|
+
// below) — a device is the edit BETWEEN two shots, an effect is on one shot.
|
|
580
|
+
"zoom",
|
|
581
|
+
"slide",
|
|
582
|
+
"white-flash",
|
|
583
|
+
"digital-glitch",
|
|
584
|
+
"morph",
|
|
585
|
+
"match",
|
|
586
|
+
"jump"
|
|
587
|
+
];
|
|
588
|
+
var VIDEO_ANALYSIS_TEXT_KINDS = ["title", "caption", "lower-third", "subtitle", "logo", "other"];
|
|
589
|
+
var VIDEO_ANALYSIS_CLIP_TRANSITIONS_IN = ["fade"];
|
|
590
|
+
var VIDEO_ANALYSIS_SPEED_EFFECTS = ["slow-motion", "ramp-in", "ramp-out", "timelapse", "freeze", "reverse"];
|
|
591
|
+
var VIDEO_ANALYSIS_TIMES_OF_DAY = ["dawn", "day", "dusk", "night", "ambiguous"];
|
|
592
|
+
var VIDEO_ANALYSIS_STORY_JUMPS = ["continuous", "same-day", "another-day", "years-later", "unclear"];
|
|
593
|
+
var clipLookSchema = zod.z.object({
|
|
594
|
+
/**
|
|
595
|
+
* The rendering MEDIUM — "live-action photoreal", "2D anime", "stop-motion
|
|
596
|
+
* claymation", "3D render", "oil painting", "pixel art".
|
|
597
|
+
*
|
|
598
|
+
* The most consequential field in this object, and orthogonal to every other
|
|
599
|
+
* one: two shots with identical grade, lens, lighting and framing still look
|
|
600
|
+
* nothing alike when one is live action and the other is an oil painting. Get
|
|
601
|
+
* this wrong and a recreation renders the whole piece in the wrong medium,
|
|
602
|
+
* which no amount of correct grade or lighting can rescue.
|
|
603
|
+
*
|
|
604
|
+
* Mirrors the product's Style picker, whose catalog defines exactly this axis
|
|
605
|
+
* and states its independence from lighting, colour-look, atmosphere and lens.
|
|
606
|
+
* A clip that genuinely changes medium partway (live action with an animated
|
|
607
|
+
* insert) states the deviation in that scene's `visual`, as with `lighting`.
|
|
608
|
+
*/
|
|
609
|
+
style: zod.z.string().optional(),
|
|
610
|
+
/**
|
|
611
|
+
* The Style picker CATALOG ID the prose in `style` corresponds to — the
|
|
612
|
+
* analyzer's PICK ("pixar-3d" beside "3D stylized animation"), not a second
|
|
613
|
+
* description of it.
|
|
614
|
+
*
|
|
615
|
+
* Worth strictly more than the prose it accompanies: an id addresses the
|
|
616
|
+
* catalog, so a recreation renders the same medium the product's own Style
|
|
617
|
+
* picker would render, instead of re-interpreting a sentence. Absent when the
|
|
618
|
+
* analyzer read a medium it could not place in the catalog — `style` then
|
|
619
|
+
* carries the whole answer, as it always did.
|
|
620
|
+
*
|
|
621
|
+
* A free `string` here on purpose. The PRODUCER validates it against the
|
|
622
|
+
* catalog (the analyzer plugin's wire schema is an enum generated from
|
|
623
|
+
* `STYLES`, so an invented id never leaves it), while this package must not
|
|
624
|
+
* carry the catalog itself. A closed enum here would only add a second copy
|
|
625
|
+
* of the vocabulary to drift out of date — and, worse, would REJECT a
|
|
626
|
+
* catalog entry newer than the installed `@nodaro/shared`, which is exactly
|
|
627
|
+
* the analysis a consumer most wants to read.
|
|
628
|
+
*/
|
|
629
|
+
styleId: zod.z.string().optional(),
|
|
630
|
+
/** Colour grade / palette — "muted teal-and-orange, crushed blacks". */
|
|
631
|
+
grade: zod.z.string().optional(),
|
|
632
|
+
/** Camera or film FORMAT and stock — "anamorphic digital", "16mm film grain". */
|
|
633
|
+
format: zod.z.string().optional(),
|
|
634
|
+
/** Lens character — "wide-angle, shallow depth of field throughout". */
|
|
635
|
+
lens: zod.z.string().optional(),
|
|
636
|
+
/** Overall lighting style — "hard single-source daylight, deep shadow". */
|
|
637
|
+
lighting: zod.z.string().optional(),
|
|
638
|
+
/** What KIND of piece this is — "cinematic trailer", "talking-head vlog". */
|
|
639
|
+
genre: zod.z.string().optional(),
|
|
640
|
+
/**
|
|
641
|
+
* The visual INFLUENCE the piece clearly evokes — a cinematographer, director,
|
|
642
|
+
* photographer or named aesthetic ("shot like Deakins", "Wes Anderson
|
|
643
|
+
* symmetry", "80s Kodachrome editorial").
|
|
644
|
+
*
|
|
645
|
+
* The highest-leverage field here by a distance: a couple of words transfer a
|
|
646
|
+
* whole aesthetic that would otherwise take a paragraph of grade, lens and
|
|
647
|
+
* lighting prose to approximate — which is exactly why the product already
|
|
648
|
+
* exposes it as a curated picker ("Photographer / Artist") whose catalog ships
|
|
649
|
+
* `in the style of …` prompt hints. The analyzer had no way to read it back.
|
|
650
|
+
*
|
|
651
|
+
* Deliberately conservative: OMIT unless the footage genuinely evokes a
|
|
652
|
+
* well-known, nameable style. A confident misattribution is worse than silence,
|
|
653
|
+
* because it drags an entire wrong aesthetic into every regenerated shot — so
|
|
654
|
+
* describing the look in `grade`/`lighting` always beats guessing a name.
|
|
655
|
+
*/
|
|
656
|
+
influence: zod.z.string().optional()
|
|
657
|
+
});
|
|
658
|
+
var VIDEO_ANALYSIS_ENTITY_SOURCES = ["wired-character", "wired-object", "wired-location", "wired-creature"];
|
|
659
|
+
var SLOT_TOKEN_RE = /\{slot:([a-z0-9-]+)\}/g;
|
|
660
|
+
var VIDEO_ANALYSIS_VARIATION_SLUGS = ["dream", "flashback", "disguise", "costume", "transformation", "era", "alt-1", "alt-2"];
|
|
661
|
+
var VIDEO_ANALYSIS_MAX_VARIATIONS = 4;
|
|
662
|
+
var VIDEO_ANALYSIS_DEFAULT_VARIATION = "default";
|
|
663
|
+
var slotVariationSchema = zod.z.object({
|
|
664
|
+
variationId: zod.z.string().min(1).regex(/^[a-z0-9-]+$/).refine((id) => id !== VIDEO_ANALYSIS_DEFAULT_VARIATION, { message: `"${VIDEO_ANALYSIS_DEFAULT_VARIATION}" is reserved for the slot's canonical look` }),
|
|
665
|
+
label: zod.z.string().min(1),
|
|
666
|
+
/** Full STANDALONE casting-sheet look restating the slot's invariant identity
|
|
667
|
+
* core (face, build, age) — the manifest substitutes it wholesale, so a
|
|
668
|
+
* wardrobe-only delta would silently delete identity from the prompt. */
|
|
669
|
+
description: zod.z.string().min(1),
|
|
670
|
+
/** Per-variation identity reference (auto-cast frame or user sheet). In the
|
|
671
|
+
* schema from day one: every strip-mode round-trip must carry it. */
|
|
672
|
+
refImageUrl: zod.z.string().url().optional()
|
|
673
|
+
});
|
|
674
|
+
var entitySlotSchema = zod.z.object({
|
|
675
|
+
slotId: zod.z.string().min(1).regex(/^[a-z0-9-]+$/),
|
|
676
|
+
label: zod.z.string().min(1),
|
|
677
|
+
source: zod.z.enum(VIDEO_ANALYSIS_ENTITY_SOURCES),
|
|
678
|
+
role: zod.z.string().min(1),
|
|
679
|
+
description: zod.z.string().min(1),
|
|
680
|
+
/** Auto-cast visual reference — a hosted frame from the analyzed footage
|
|
681
|
+
* where this entity is clearly visible. Optional/additive: producers may
|
|
682
|
+
* omit it; consumers use it as an identity reference for recreation. */
|
|
683
|
+
refImageUrl: zod.z.string().url().optional(),
|
|
684
|
+
/**
|
|
685
|
+
* Why `refImageUrl` is ABSENT, when the analyzer's vision pass actively
|
|
686
|
+
* refused every candidate frame rather than merely failing to produce one.
|
|
687
|
+
*
|
|
688
|
+
* Present only alongside a missing `refImageUrl`, and only for a real refusal
|
|
689
|
+
* — never for a technical failure, so its presence always carries meaning. The
|
|
690
|
+
* important case reads like "the shots bound to this slot show someone else —
|
|
691
|
+
* cast as X, but on screen: Y", which is the analyzer telling you the casting
|
|
692
|
+
* description and the footage disagree. A consumer should treat that as a
|
|
693
|
+
* reason to review the slot before spending on regeneration, since a wrong
|
|
694
|
+
* identity propagates into every regenerated shot.
|
|
695
|
+
*/
|
|
696
|
+
refRejectedReason: zod.z.string().optional(),
|
|
697
|
+
/** NON-default looks only; present only when at least one exists. */
|
|
698
|
+
variations: zod.z.array(slotVariationSchema).max(VIDEO_ANALYSIS_MAX_VARIATIONS).optional(),
|
|
699
|
+
/**
|
|
700
|
+
* WHOSE THIS OBJECT IS (2026-09-17). An object slot that is worn, held,
|
|
701
|
+
* carried, driven or ridden by a cast person or creature names that slot
|
|
702
|
+
* here, with the relation as a short passive phrase ending in "by" ("worn
|
|
703
|
+
* by", "held by", "driven by"). The link says the object slot IS the one on
|
|
704
|
+
* that person — not a second one: a recast that saw "Man in Blue Silk
|
|
705
|
+
* Shirt" AND "Blue Silk Shirt" as unrelated slots rendered two shirts.
|
|
706
|
+
* Object slots only; a free-standing prop, the product on a table, a place
|
|
707
|
+
* or a person never carries it. Optional/additive: producers may omit it.
|
|
708
|
+
*/
|
|
709
|
+
owner: zod.z.object({
|
|
710
|
+
slotId: zod.z.string().min(1).regex(/^[a-z0-9-]+$/),
|
|
711
|
+
relation: zod.z.string().min(1)
|
|
712
|
+
}).optional()
|
|
713
|
+
});
|
|
714
|
+
var VIDEO_ANALYSIS_AUDIO_MODES = ["speech", "music", "sfx", "ambience"];
|
|
715
|
+
var audioLayerSchema = zod.z.object({
|
|
716
|
+
mode: zod.z.enum(VIDEO_ANALYSIS_AUDIO_MODES),
|
|
717
|
+
content: zod.z.string().min(1),
|
|
718
|
+
voice: zod.z.string().optional(),
|
|
719
|
+
/**
|
|
720
|
+
* SPEECH ONLY — `slotId` of the on-screen speaker saying these words.
|
|
721
|
+
*
|
|
722
|
+
* `voice` casts a voice ("male, proud triumphant shouting"); this says WHO it
|
|
723
|
+
* belongs to, so a recreation can route the line to the right character
|
|
724
|
+
* instead of guessing. Usually one person speaks per scene and the guess is
|
|
725
|
+
* right, which is exactly why the cases with two speakers over one cut fail
|
|
726
|
+
* silently without this field.
|
|
727
|
+
*
|
|
728
|
+
* Optional by design and deliberately NOT refined against `mode` here: the
|
|
729
|
+
* window schema is the enforced decode grammar, and rejecting a whole roll
|
|
730
|
+
* because the model tagged a music layer would be a hair-trigger failure. A
|
|
731
|
+
* speaker on a non-speech layer, or one naming a slot that no longer exists,
|
|
732
|
+
* is stripped structurally by `dropUnknownSpeakers` — the same
|
|
733
|
+
* unwrap/drop/sweep philosophy the slot-token and binding channels use.
|
|
734
|
+
*
|
|
735
|
+
* An unseen narrator gets NO speaker: a voice with no body is never a slot
|
|
736
|
+
* (doctrine §5), so attribution here would resurrect the phantom-entity
|
|
737
|
+
* defect that `stripOrphanSlots` exists to kill.
|
|
738
|
+
*/
|
|
739
|
+
speakerSlot: zod.z.string().optional(),
|
|
740
|
+
/**
|
|
741
|
+
* SPEECH ONLY — WHO says these words, by NAME.
|
|
742
|
+
*
|
|
743
|
+
* The second of two ways to name a speaker, and the one for documents that
|
|
744
|
+
* have no slots: `speakerSlot` addresses an `EntitySlot` of THIS analysis by
|
|
745
|
+
* id, while `speaker` is the plain cast name a production keys its own cast
|
|
746
|
+
* by ("Jack Mercer"). A layer may legitimately carry both — the id for the
|
|
747
|
+
* analysis it came from, the name for the document it is going into — and a
|
|
748
|
+
* consumer that understands only one reads the one it understands.
|
|
749
|
+
*
|
|
750
|
+
* Optional, and not refined against `mode`, for the same reason
|
|
751
|
+
* `speakerSlot` is not: the window schema is the enforced decode grammar and
|
|
752
|
+
* must not throw away a whole roll over one mis-tagged field.
|
|
753
|
+
*
|
|
754
|
+
* NOT swept by `dropUnknownSpeakers`. That function is the SLOT channel's
|
|
755
|
+
* sanitizer — it judges an id against the surviving slot list, and a name has
|
|
756
|
+
* no id space to be unknown in. The asymmetry is deliberate and pinned by
|
|
757
|
+
* test; whoever owns the name's vocabulary sanitizes the name.
|
|
758
|
+
*
|
|
759
|
+
* The residual that leaves: a layer can keep a `speaker` naming someone
|
|
760
|
+
* `stripOrphanSlots` already pruned as a phantom, where the same claim spelled
|
|
761
|
+
* `speakerSlot` would have been dropped — the invented-narrator defect, in the
|
|
762
|
+
* one spelling the sweep cannot see. LATENT today, since nothing in this
|
|
763
|
+
* repo emits `speaker`; the day the analyzer does, that sweep is what has to
|
|
764
|
+
* grow, not this field.
|
|
765
|
+
*/
|
|
766
|
+
speaker: zod.z.string().optional()
|
|
767
|
+
});
|
|
768
|
+
var windowSceneBase = zod.z.object({
|
|
769
|
+
startSec: zod.z.number().min(0),
|
|
770
|
+
endSec: zod.z.number().min(0),
|
|
771
|
+
label: zod.z.string().min(1),
|
|
772
|
+
shotType: zod.z.string().min(1),
|
|
773
|
+
camera: zod.z.string(),
|
|
774
|
+
/** Camera VIEWPOINT. Absent ⇒ eye-level. Keeps `camera` to pure MOVEMENT and
|
|
775
|
+
* frees `shotType` to state the SIZE even on an over-the-shoulder or POV. */
|
|
776
|
+
angle: zod.z.enum(VIDEO_ANALYSIS_SHOT_ANGLES).optional(),
|
|
777
|
+
/** Time manipulation. Absent ⇒ normal speed. */
|
|
778
|
+
speed: zod.z.enum(VIDEO_ANALYSIS_SPEED_EFFECTS).optional(),
|
|
779
|
+
/** CHRONICLE TIME (2026-08-17) — see the consts' docstrings. Both optional:
|
|
780
|
+
* absent on every pre-2.6.0 analysis, and legitimately absent when the
|
|
781
|
+
* analyser cannot read the clock. Enum + optional keeps the window decode
|
|
782
|
+
* grammar congruence-safe (no ints, no maxItems). */
|
|
783
|
+
timeOfDay: zod.z.enum(VIDEO_ANALYSIS_TIMES_OF_DAY).optional(),
|
|
784
|
+
storyJump: zod.z.enum(VIDEO_ANALYSIS_STORY_JUMPS).optional(),
|
|
785
|
+
visual: zod.z.string().min(1),
|
|
786
|
+
/**
|
|
787
|
+
* Text burned into the PICTURE of this shot — titles, captions, lower-thirds,
|
|
788
|
+
* subtitles — verbatim, in its original script. Absent when the frame carries
|
|
789
|
+
* none.
|
|
790
|
+
*
|
|
791
|
+
* Doctrine already asks for on-screen text inside `visual` prose, but a
|
|
792
|
+
* recreation needs to know discretely whether to RENDER text at all, and
|
|
793
|
+
* `translateOnScreenTextToEnglish` had no structured field to land in. It is
|
|
794
|
+
* also the signal the auto-cast frame judge reads: picture text belonging to an
|
|
795
|
+
* earlier scene's speech means the shot is replayed footage under a voice-over.
|
|
796
|
+
*/
|
|
797
|
+
onScreenText: zod.z.string().optional(),
|
|
798
|
+
/** What the on-screen text IS. Meaningful only when `onScreenText` is non-empty. */
|
|
799
|
+
onScreenTextKind: zod.z.enum(VIDEO_ANALYSIS_TEXT_KINDS).optional(),
|
|
800
|
+
/** Effects on this shot's PICTURE. Absent ⇒ a clean image. */
|
|
801
|
+
effects: zod.z.array(zod.z.enum(VIDEO_ANALYSIS_VISUAL_EFFECTS)).optional(),
|
|
802
|
+
transitionOut: zod.z.enum(VIDEO_ANALYSIS_TRANSITIONS).optional(),
|
|
803
|
+
// Round 4 (2026-08-30, recast shot craft rev 1.5 Appendix F.8): the edit into
|
|
804
|
+
// the next scene in the analyser's OWN WORDS — a few words of what it saw
|
|
805
|
+
// ("fast blurred pan left", "fade to black", "zoom-blur warp into the tunnel")
|
|
806
|
+
// — or absent when the take continues through the change or no edit is seen
|
|
807
|
+
// (nothing asserted: the video model decides from story and refs). The closed
|
|
808
|
+
// `transitionOut` vocabulary above is LEGACY from here on: kept so stored
|
|
809
|
+
// blueprints still parse, never emitted again. Readers take
|
|
810
|
+
// `transition ?? transitionOut`.
|
|
811
|
+
transition: zod.z.string().trim().min(1).max(120).optional(),
|
|
812
|
+
// Array of concurrent layers (music + speech + sfx together); [] = silence.
|
|
813
|
+
audio: zod.z.array(audioLayerSchema),
|
|
814
|
+
/** slotId → variationId for slots wearing a NON-default look in this scene
|
|
815
|
+
* (only slots referenced in the scene; absent key ⇒ the default look).
|
|
816
|
+
* Rides windowSceneBase so BOTH the window layer and analyzedSceneSchema
|
|
817
|
+
* inherit it — the out-of-band binding channel (no in-text markers, D6). */
|
|
818
|
+
slotVariations: zod.z.record(zod.z.string(), zod.z.string()).optional()
|
|
819
|
+
});
|
|
820
|
+
var windowSceneSchema = windowSceneBase.refine((s) => s.endSec > s.startSec, { message: "endSec must be > startSec" });
|
|
821
|
+
var windowAnalysisSchema = zod.z.object({
|
|
822
|
+
language: zod.z.string().optional(),
|
|
823
|
+
/** The clip-level look as read from THIS window. Merge folds the windows
|
|
824
|
+
* field-by-field (first non-empty wins), like `language`. */
|
|
825
|
+
look: clipLookSchema.optional(),
|
|
826
|
+
/** The clip opens with a fade-in. Folded from window 0 only. */
|
|
827
|
+
transitionIn: zod.z.enum(VIDEO_ANALYSIS_CLIP_TRANSITIONS_IN).optional(),
|
|
828
|
+
slots: zod.z.array(entitySlotSchema),
|
|
829
|
+
scenes: zod.z.array(windowSceneSchema)
|
|
830
|
+
});
|
|
831
|
+
var analyzedSceneSchema = windowSceneBase.extend({
|
|
832
|
+
sceneNumber: zod.z.number().int().min(1),
|
|
833
|
+
visualResolved: zod.z.string().min(1),
|
|
834
|
+
oversized: zod.z.boolean().optional(),
|
|
835
|
+
slotRefs: zod.z.array(zod.z.string())
|
|
836
|
+
}).refine((s) => s.endSec > s.startSec, { message: "endSec must be > startSec" });
|
|
837
|
+
var videoAnalysisResultSchema = zod.z.object({
|
|
838
|
+
meta: zod.z.object({
|
|
839
|
+
durationSec: zod.z.number().positive(),
|
|
840
|
+
width: zod.z.number().int().positive(),
|
|
841
|
+
height: zod.z.number().int().positive(),
|
|
842
|
+
aspectRatio: zod.z.string(),
|
|
843
|
+
title: zod.z.string().optional(),
|
|
844
|
+
language: zod.z.string().optional()
|
|
845
|
+
}),
|
|
846
|
+
/** Clip-level look, merged across windows. Deliberately a sibling of `meta`
|
|
847
|
+
* rather than a member: `meta` is probed fact (ffprobe dimensions, probed
|
|
848
|
+
* duration), while this is the model's reading of the photography. */
|
|
849
|
+
look: clipLookSchema.optional(),
|
|
850
|
+
/** The clip opens with a fade-in. Folded from window 0 only. */
|
|
851
|
+
transitionIn: zod.z.enum(VIDEO_ANALYSIS_CLIP_TRANSITIONS_IN).optional(),
|
|
852
|
+
slots: zod.z.array(entitySlotSchema),
|
|
853
|
+
scenes: zod.z.array(analyzedSceneSchema).min(1),
|
|
854
|
+
/** CAST VARIATIONS (§4 cap handling): looks the analyzer's merge FOLDED into
|
|
855
|
+
* the default at VIDEO_ANALYSIS_MAX_VARIATIONS — recorded, never silent. In
|
|
856
|
+
* the wire schema so strip-mode consumers (the recast client's validated
|
|
857
|
+
* blueprint view) keep it: the §6 "folded into default look" note is the
|
|
858
|
+
* user's only pre-pay defense against a wrong split. */
|
|
859
|
+
variationFolds: zod.z.array(zod.z.object({
|
|
860
|
+
slotId: zod.z.string(),
|
|
861
|
+
variationId: zod.z.string(),
|
|
862
|
+
label: zod.z.string()
|
|
863
|
+
})).optional(),
|
|
864
|
+
/**
|
|
865
|
+
* Analyzer diagnostics for THIS result — things the analysis noticed about
|
|
866
|
+
* itself that a reader should know before spending on regeneration.
|
|
867
|
+
*
|
|
868
|
+
* Added because there was previously no channel for them at all: the merge
|
|
869
|
+
* layer has always produced a warnings list and the auto-cast pass has always
|
|
870
|
+
* had findings, and every one of them died in a `console.warn` inside a worker
|
|
871
|
+
* the user cannot see. So a run could quietly drop a duplicated line, fold a
|
|
872
|
+
* cast look, or conclude a character is not the person their own description
|
|
873
|
+
* names, and the result looked indistinguishable from a clean one.
|
|
874
|
+
*
|
|
875
|
+
* Prose, not codes, and deliberately so — these are read by a human deciding
|
|
876
|
+
* whether to re-run, not branched on. Absent when there is nothing to report.
|
|
877
|
+
*/
|
|
878
|
+
warnings: zod.z.array(zod.z.string()).optional()
|
|
879
|
+
});
|
|
880
|
+
function deriveSlotRefs(visual) {
|
|
881
|
+
const out = [];
|
|
882
|
+
for (const m of visual.matchAll(SLOT_TOKEN_RE)) if (!out.includes(m[1])) out.push(m[1]);
|
|
883
|
+
return out;
|
|
884
|
+
}
|
|
885
|
+
function rewriteSlotTokens(visual, renames) {
|
|
886
|
+
return visual.replace(SLOT_TOKEN_RE, (whole, id) => renames[id] ? `{slot:${renames[id]}}` : whole);
|
|
887
|
+
}
|
|
888
|
+
function unwrapUnresolvedTokens(text, validIds) {
|
|
889
|
+
const unresolved = [];
|
|
890
|
+
const out = text.replace(SLOT_TOKEN_RE, (whole, id) => {
|
|
891
|
+
if (validIds.has(id)) return whole;
|
|
892
|
+
if (!unresolved.includes(id)) unresolved.push(id);
|
|
893
|
+
return id;
|
|
894
|
+
});
|
|
895
|
+
return { text: out, unresolved };
|
|
896
|
+
}
|
|
897
|
+
function rewriteSceneBindings(sv, slotRenames, variationRenames) {
|
|
898
|
+
if (!sv) return void 0;
|
|
899
|
+
const out = {};
|
|
900
|
+
for (const [slotId, variationId] of Object.entries(sv)) {
|
|
901
|
+
const newSlot = slotRenames[slotId] ?? slotId;
|
|
902
|
+
out[newSlot] = variationRenames?.[newSlot]?.[variationId] ?? variationId;
|
|
903
|
+
}
|
|
904
|
+
return out;
|
|
905
|
+
}
|
|
906
|
+
function dropUnknownBindings(sv, validBySlot) {
|
|
907
|
+
if (!sv) return { dropped: [] };
|
|
908
|
+
const kept = {};
|
|
909
|
+
const dropped = [];
|
|
910
|
+
for (const [slotId, variationId] of Object.entries(sv)) {
|
|
911
|
+
const valid = validBySlot.get(slotId);
|
|
912
|
+
if (valid && (variationId === VIDEO_ANALYSIS_DEFAULT_VARIATION || valid.has(variationId))) kept[slotId] = variationId;
|
|
913
|
+
else dropped.push({ slotId, variationId });
|
|
914
|
+
}
|
|
915
|
+
return { kept: Object.keys(kept).length > 0 ? kept : void 0, dropped };
|
|
916
|
+
}
|
|
917
|
+
function rewriteSpeakerSlots(audio, slotRenames) {
|
|
918
|
+
if (!audio.some((a) => a.speakerSlot !== void 0 && slotRenames[a.speakerSlot])) return audio;
|
|
919
|
+
return audio.map((a) => {
|
|
920
|
+
const to = a.speakerSlot !== void 0 ? slotRenames[a.speakerSlot] : void 0;
|
|
921
|
+
return to ? { ...a, speakerSlot: to } : a;
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
function dropUnknownSpeakers(audio, validSlotIds) {
|
|
925
|
+
const dropped = [];
|
|
926
|
+
const out = audio.map((a) => {
|
|
927
|
+
if (a.speakerSlot === void 0) return a;
|
|
928
|
+
if (a.mode === "speech" && validSlotIds.has(a.speakerSlot)) return a;
|
|
929
|
+
dropped.push(a.speakerSlot);
|
|
930
|
+
const { speakerSlot: _drop, ...rest } = a;
|
|
931
|
+
return rest;
|
|
932
|
+
});
|
|
933
|
+
return { audio: dropped.length > 0 ? out : audio, dropped };
|
|
934
|
+
}
|
|
935
|
+
function mergeClipLook(looks) {
|
|
936
|
+
const out = {};
|
|
937
|
+
for (const look of looks) {
|
|
938
|
+
for (const [k, v] of Object.entries(look ?? {})) {
|
|
939
|
+
if (typeof v === "string" && v.trim() && !out[k]) out[k] = v.trim();
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
943
|
+
}
|
|
944
|
+
function renderAnalyzedScene(scene, slots, castMap) {
|
|
945
|
+
const byId = new Map(slots.map((s) => [s.slotId, s]));
|
|
946
|
+
return scene.visual.replace(SLOT_TOKEN_RE, (_whole, id) => castMap?.[id] ?? byId.get(id)?.description ?? id);
|
|
947
|
+
}
|
|
948
|
+
var OVERSIZE_TOLERANCE_SEC = 1e-6;
|
|
949
|
+
function isOversizedScene(startSec, endSec) {
|
|
950
|
+
return endSec - startSec > VIDEO_ANALYSIS_MAX_SCENE_SEC + OVERSIZE_TOLERANCE_SEC;
|
|
951
|
+
}
|
|
952
|
+
var STANDARD_RATIOS = [
|
|
953
|
+
["16:9", 16 / 9],
|
|
954
|
+
["9:16", 9 / 16],
|
|
955
|
+
["1:1", 1],
|
|
956
|
+
["4:3", 4 / 3],
|
|
957
|
+
["3:4", 3 / 4],
|
|
958
|
+
["21:9", 21 / 9]
|
|
959
|
+
];
|
|
960
|
+
function aspectRatioFromDims(w, h) {
|
|
961
|
+
const r = w / h;
|
|
962
|
+
for (const [label, v] of STANDARD_RATIOS) if (Math.abs(r - v) / v < 0.03) return label;
|
|
963
|
+
const gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
|
|
964
|
+
const g = gcd(Math.round(w), Math.round(h));
|
|
965
|
+
return `${Math.round(w) / g}:${Math.round(h) / g}`;
|
|
966
|
+
}
|
|
967
|
+
var MUSIC_VOCAL_RE = /\b(?:lyrics?|sung|sings?|singing|vocals?|chorus|verse|rap(?:ping|ped)?|a cappella)\b/i;
|
|
968
|
+
var MUSIC_VOCAL_QUOTE_RE = /["\u201c][^"\u201d]{6,}["\u201d]/;
|
|
969
|
+
var MUSIC_NO_VOCAL_RE = /\b(?:no|without|non)[- ](?:vocals?|lyrics?|singing)\b|\binstrumental\b|\bwordless\b/i;
|
|
970
|
+
function inferMusicVideo(analysis) {
|
|
971
|
+
const scenes = analysis?.scenes ?? [];
|
|
972
|
+
if (scenes.length < 4) return false;
|
|
973
|
+
const musicLayers = (sc) => (sc.audio ?? []).filter((a) => a?.mode === "music");
|
|
974
|
+
const withMusic = scenes.filter((sc) => musicLayers(sc).length > 0).length;
|
|
975
|
+
if (withMusic / scenes.length < 0.8) return false;
|
|
976
|
+
return scenes.some(
|
|
977
|
+
(sc) => musicLayers(sc).some((a) => {
|
|
978
|
+
const content = typeof a.content === "string" ? a.content : "";
|
|
979
|
+
if (MUSIC_NO_VOCAL_RE.test(content)) return false;
|
|
980
|
+
return MUSIC_VOCAL_RE.test(content) || MUSIC_VOCAL_QUOTE_RE.test(content);
|
|
981
|
+
})
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
var DERIVED_ANALYSIS_TOP_KEYS = /* @__PURE__ */ new Set(["warnings", "variationFolds"]);
|
|
985
|
+
var DERIVED_ANALYSIS_SCENE_KEYS = /* @__PURE__ */ new Set(["visualResolved", "slotRefs", "oversized"]);
|
|
986
|
+
var asRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : null;
|
|
987
|
+
function stripDerivedAnalysisFields(json) {
|
|
988
|
+
const doc = asRecord(json);
|
|
989
|
+
if (!doc) return json;
|
|
990
|
+
const out = {};
|
|
991
|
+
for (const [key, value] of Object.entries(doc)) {
|
|
992
|
+
if (DERIVED_ANALYSIS_TOP_KEYS.has(key)) continue;
|
|
993
|
+
out[key] = key === "scenes" && Array.isArray(value) ? value.map((scene) => {
|
|
994
|
+
const s = asRecord(scene);
|
|
995
|
+
if (!s) return scene;
|
|
996
|
+
return Object.fromEntries(Object.entries(s).filter(([k]) => !DERIVED_ANALYSIS_SCENE_KEYS.has(k)));
|
|
997
|
+
}) : value;
|
|
998
|
+
}
|
|
999
|
+
return out;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// src/video-output-canvas.ts
|
|
1003
|
+
var VIDEO_OUTPUT_CANVAS = {
|
|
1004
|
+
"seedance-2-5": {
|
|
1005
|
+
"480p": { "16:9": [854, 480], "9:16": [480, 854] },
|
|
1006
|
+
"720p": { "16:9": [1280, 720], "9:16": [720, 1280], "1:1": [960, 960] },
|
|
1007
|
+
"1080p": { "16:9": [1920, 1080] }
|
|
1008
|
+
},
|
|
1009
|
+
// The 2.0 family is NOT the same as 2.5 at 480p — 864x496 vs 854x480.
|
|
1010
|
+
"seedance-2": {
|
|
1011
|
+
"480p": { "16:9": [864, 496], "9:16": [496, 864] },
|
|
1012
|
+
"720p": { "16:9": [1280, 720], "9:16": [720, 1280] }
|
|
1013
|
+
},
|
|
1014
|
+
"seedance-2-fast": {
|
|
1015
|
+
"480p": { "16:9": [864, 496], "9:16": [496, 864] },
|
|
1016
|
+
"720p": { "16:9": [1280, 720], "9:16": [720, 1280] }
|
|
1017
|
+
},
|
|
1018
|
+
"seedance-2-mini": {
|
|
1019
|
+
"480p": { "16:9": [864, 496], "9:16": [496, 864] },
|
|
1020
|
+
"720p": { "16:9": [1280, 720], "9:16": [720, 1280] }
|
|
1021
|
+
},
|
|
1022
|
+
"gemini-omni-video": {
|
|
1023
|
+
"720p": { "16:9": [1280, 720], "9:16": [720, 1280] },
|
|
1024
|
+
"1080p": { "16:9": [1920, 1080] }
|
|
1025
|
+
},
|
|
1026
|
+
"gemini-omni-flash": {
|
|
1027
|
+
"720p": { "16:9": [1280, 720], "9:16": [720, 1280] }
|
|
1028
|
+
},
|
|
1029
|
+
"veo3.1": {
|
|
1030
|
+
"720p": { "9:16": [720, 1280] },
|
|
1031
|
+
"1080p": { "16:9": [1920, 1080] }
|
|
1032
|
+
},
|
|
1033
|
+
"wan-3": {
|
|
1034
|
+
"480p": { "16:9": [832, 480] },
|
|
1035
|
+
"720p": { "16:9": [1280, 720], "9:16": [720, 1280] }
|
|
1036
|
+
},
|
|
1037
|
+
"wan-3-prime": {
|
|
1038
|
+
"720p": { "16:9": [1280, 720] }
|
|
1039
|
+
},
|
|
1040
|
+
// 768P's "9:16" is 0.5714, not 0.5625 — the single clearest reason this table
|
|
1041
|
+
// exists.
|
|
1042
|
+
"minimax-h3": {
|
|
1043
|
+
"768p": { "9:16": [768, 1344] },
|
|
1044
|
+
"2k": { "16:9": [2560, 1440], "9:16": [1440, 2560] }
|
|
1045
|
+
},
|
|
1046
|
+
seedance: {
|
|
1047
|
+
"1080p": {
|
|
1048
|
+
"16:9": [1920, 1080],
|
|
1049
|
+
"9:16": [1080, 1920],
|
|
1050
|
+
"1:1": [1440, 1440],
|
|
1051
|
+
"3:4": [1248, 1664]
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
function resolveOutputCanvas(provider, resolution, aspect) {
|
|
1056
|
+
if (!provider || !resolution || !aspect) return void 0;
|
|
1057
|
+
return VIDEO_OUTPUT_CANVAS[provider]?.[resolution.toLowerCase()]?.[aspect];
|
|
1058
|
+
}
|
|
1059
|
+
function measuredCanvasCombinations() {
|
|
1060
|
+
const out = [];
|
|
1061
|
+
for (const [provider, byResolution] of Object.entries(VIDEO_OUTPUT_CANVAS)) {
|
|
1062
|
+
for (const [resolution, byAspect] of Object.entries(byResolution)) {
|
|
1063
|
+
for (const [aspect, canvas] of Object.entries(byAspect)) {
|
|
1064
|
+
out.push({ provider, resolution, aspect, canvas });
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
return out;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
// src/video-frame-fit.ts
|
|
1072
|
+
var FRAME_FITS = ["original", "ratio", "resolution"];
|
|
1073
|
+
var DEFAULT_FRAME_FIT = "resolution";
|
|
1074
|
+
var FRAME_DELIVERIES = ["auto", "frame", "reference"];
|
|
1075
|
+
var DEFAULT_FRAME_DELIVERY = "auto";
|
|
1076
|
+
var FRAME_FIT_STRETCH_TOLERANCE = 0.05;
|
|
1077
|
+
var FRAME_DELIVERY_BY_PROVIDER = {
|
|
1078
|
+
"seedance-2": "reference",
|
|
1079
|
+
"seedance-2-fast": "reference",
|
|
1080
|
+
"seedance-2-mini": "reference"
|
|
1081
|
+
};
|
|
1082
|
+
var OPEN_ASPECT_TOKENS = /* @__PURE__ */ new Set(["adaptive", "auto"]);
|
|
1083
|
+
function parseAspectToken(token) {
|
|
1084
|
+
if (!token) return void 0;
|
|
1085
|
+
const m = /^(\d+(?:\.\d+)?)\s*[:x/]\s*(\d+(?:\.\d+)?)$/.exec(token.trim());
|
|
1086
|
+
if (!m) return void 0;
|
|
1087
|
+
const w = Number(m[1]);
|
|
1088
|
+
const h = Number(m[2]);
|
|
1089
|
+
if (!(w > 0) || !(h > 0)) return void 0;
|
|
1090
|
+
return w / h;
|
|
1091
|
+
}
|
|
1092
|
+
function resolveFrameFitAspect(args) {
|
|
1093
|
+
const requested = args.requestedAspect?.trim();
|
|
1094
|
+
if (requested && !OPEN_ASPECT_TOKENS.has(requested.toLowerCase())) return requested;
|
|
1095
|
+
const ratios = args.provider ? chunkK3LLGRK7_cjs.getModel(args.provider)?.aspectRatios : void 0;
|
|
1096
|
+
if (!ratios?.length || !(args.sourceWidth > 0) || !(args.sourceHeight > 0)) return void 0;
|
|
1097
|
+
const source = args.sourceWidth / args.sourceHeight;
|
|
1098
|
+
let best;
|
|
1099
|
+
for (const token of ratios) {
|
|
1100
|
+
const value = parseAspectToken(token);
|
|
1101
|
+
if (value === void 0) continue;
|
|
1102
|
+
const gap = Math.abs(Math.log(value / source));
|
|
1103
|
+
if (!best || gap < best.gap) best = { token, gap };
|
|
1104
|
+
}
|
|
1105
|
+
return best?.token;
|
|
1106
|
+
}
|
|
1107
|
+
function even(value) {
|
|
1108
|
+
return Math.max(2, Math.round(value / 2) * 2);
|
|
1109
|
+
}
|
|
1110
|
+
function minimalRatioDimensions(width, height, aspect) {
|
|
1111
|
+
const current = width / height;
|
|
1112
|
+
if (current > aspect) {
|
|
1113
|
+
return { width: even(width), height: even(width / aspect) };
|
|
1114
|
+
}
|
|
1115
|
+
return { width: even(height * aspect), height: even(height) };
|
|
1116
|
+
}
|
|
1117
|
+
function centreCropToAspect(width, height, aspect) {
|
|
1118
|
+
const current = width / height;
|
|
1119
|
+
if (current > aspect) {
|
|
1120
|
+
const w = even(height * aspect);
|
|
1121
|
+
return { left: Math.max(0, Math.round((width - w) / 2)), top: 0, width: Math.min(width, w), height };
|
|
1122
|
+
}
|
|
1123
|
+
const h = even(width / aspect);
|
|
1124
|
+
return { left: 0, top: Math.max(0, Math.round((height - h) / 2)), width, height: Math.min(height, h) };
|
|
1125
|
+
}
|
|
1126
|
+
function computeFrameFitPlan(args) {
|
|
1127
|
+
const { fit, sourceWidth, sourceHeight } = args;
|
|
1128
|
+
if (fit === "original") return null;
|
|
1129
|
+
if (!(sourceWidth > 0) || !(sourceHeight > 0)) return null;
|
|
1130
|
+
const aspectToken = resolveFrameFitAspect({
|
|
1131
|
+
provider: args.provider,
|
|
1132
|
+
requestedAspect: args.aspect,
|
|
1133
|
+
sourceWidth,
|
|
1134
|
+
sourceHeight
|
|
1135
|
+
});
|
|
1136
|
+
const canvas = fit === "resolution" ? args.canvas ?? resolveOutputCanvas(args.provider, args.resolution, aspectToken) : void 0;
|
|
1137
|
+
const targetAspect = canvas ? canvas[0] / canvas[1] : parseAspectToken(aspectToken);
|
|
1138
|
+
if (targetAspect === void 0 || !(targetAspect > 0)) return null;
|
|
1139
|
+
const sourceAspect = sourceWidth / sourceHeight;
|
|
1140
|
+
const gap = Math.abs(sourceAspect - targetAspect) / targetAspect;
|
|
1141
|
+
const tolerance = args.tolerance ?? FRAME_FIT_STRETCH_TOLERANCE;
|
|
1142
|
+
const crop = gap > tolerance ? centreCropToAspect(sourceWidth, sourceHeight, targetAspect) : void 0;
|
|
1143
|
+
const target = canvas ? { width: canvas[0], height: canvas[1] } : minimalRatioDimensions(
|
|
1144
|
+
crop ? crop.width : sourceWidth,
|
|
1145
|
+
crop ? crop.height : sourceHeight,
|
|
1146
|
+
targetAspect
|
|
1147
|
+
);
|
|
1148
|
+
const unchanged = target.width === sourceWidth && target.height === sourceHeight && !crop;
|
|
1149
|
+
if (unchanged) return null;
|
|
1150
|
+
return {
|
|
1151
|
+
width: target.width,
|
|
1152
|
+
height: target.height,
|
|
1153
|
+
...crop ? { crop } : {},
|
|
1154
|
+
reason: canvas ? "resolution" : "ratio"
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
function resolveFrameDelivery(args) {
|
|
1158
|
+
const requested = args.requested ?? DEFAULT_FRAME_DELIVERY;
|
|
1159
|
+
const wanted = requested === "auto" ? args.provider ? FRAME_DELIVERY_BY_PROVIDER[args.provider] ?? "frame" : "frame" : requested;
|
|
1160
|
+
if (wanted === "reference" && !args.supportsReferenceImages) return "frame";
|
|
1161
|
+
return wanted;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
exports.DEFAULT_FRAME_DELIVERY = DEFAULT_FRAME_DELIVERY;
|
|
1165
|
+
exports.DEFAULT_FRAME_FIT = DEFAULT_FRAME_FIT;
|
|
1166
|
+
exports.DEFAULT_VIDEO_OVERLAY_LAYER = DEFAULT_VIDEO_OVERLAY_LAYER;
|
|
1167
|
+
exports.FRAME_DELIVERIES = FRAME_DELIVERIES;
|
|
1168
|
+
exports.FRAME_DELIVERY_BY_PROVIDER = FRAME_DELIVERY_BY_PROVIDER;
|
|
1169
|
+
exports.FRAME_FITS = FRAME_FITS;
|
|
1170
|
+
exports.FRAME_FIT_STRETCH_TOLERANCE = FRAME_FIT_STRETCH_TOLERANCE;
|
|
1171
|
+
exports.SLOT_TOKEN_RE = SLOT_TOKEN_RE;
|
|
1172
|
+
exports.VIDEO_ANALYSIS_AUDIO_MODES = VIDEO_ANALYSIS_AUDIO_MODES;
|
|
1173
|
+
exports.VIDEO_ANALYSIS_CLIP_TRANSITIONS_IN = VIDEO_ANALYSIS_CLIP_TRANSITIONS_IN;
|
|
1174
|
+
exports.VIDEO_ANALYSIS_DEFAULT_VARIATION = VIDEO_ANALYSIS_DEFAULT_VARIATION;
|
|
1175
|
+
exports.VIDEO_ANALYSIS_ENTITY_SOURCES = VIDEO_ANALYSIS_ENTITY_SOURCES;
|
|
1176
|
+
exports.VIDEO_ANALYSIS_FACELESS_ANGLES = VIDEO_ANALYSIS_FACELESS_ANGLES;
|
|
1177
|
+
exports.VIDEO_ANALYSIS_MAX_SCENE_SEC = VIDEO_ANALYSIS_MAX_SCENE_SEC;
|
|
1178
|
+
exports.VIDEO_ANALYSIS_MAX_VARIATIONS = VIDEO_ANALYSIS_MAX_VARIATIONS;
|
|
1179
|
+
exports.VIDEO_ANALYSIS_SHOT_ANGLES = VIDEO_ANALYSIS_SHOT_ANGLES;
|
|
1180
|
+
exports.VIDEO_ANALYSIS_SPEED_EFFECTS = VIDEO_ANALYSIS_SPEED_EFFECTS;
|
|
1181
|
+
exports.VIDEO_ANALYSIS_STORY_JUMPS = VIDEO_ANALYSIS_STORY_JUMPS;
|
|
1182
|
+
exports.VIDEO_ANALYSIS_TEXT_KINDS = VIDEO_ANALYSIS_TEXT_KINDS;
|
|
1183
|
+
exports.VIDEO_ANALYSIS_TIMES_OF_DAY = VIDEO_ANALYSIS_TIMES_OF_DAY;
|
|
1184
|
+
exports.VIDEO_ANALYSIS_TRANSITIONS = VIDEO_ANALYSIS_TRANSITIONS;
|
|
1185
|
+
exports.VIDEO_ANALYSIS_VARIATION_SLUGS = VIDEO_ANALYSIS_VARIATION_SLUGS;
|
|
1186
|
+
exports.VIDEO_ANALYSIS_VISUAL_EFFECTS = VIDEO_ANALYSIS_VISUAL_EFFECTS;
|
|
1187
|
+
exports.VIDEO_CHARACTER_DESCRIPTION_MAX = VIDEO_CHARACTER_DESCRIPTION_MAX;
|
|
1188
|
+
exports.VIDEO_CHARACTER_NAME_MAX = VIDEO_CHARACTER_NAME_MAX;
|
|
1189
|
+
exports.VIDEO_CHARACTER_REFS_WIRE_MAX = VIDEO_CHARACTER_REFS_WIRE_MAX;
|
|
1190
|
+
exports.VIDEO_CHARACTER_VOICE_DESCRIPTION_MAX = VIDEO_CHARACTER_VOICE_DESCRIPTION_MAX;
|
|
1191
|
+
exports.VIDEO_CHARACTER_VOICE_EXAMPLE_MAX = VIDEO_CHARACTER_VOICE_EXAMPLE_MAX;
|
|
1192
|
+
exports.VIDEO_OUTPUT_CANVAS = VIDEO_OUTPUT_CANVAS;
|
|
1193
|
+
exports.VIDEO_OVERLAY_ANIMATION_MIN_SCALE = VIDEO_OVERLAY_ANIMATION_MIN_SCALE;
|
|
1194
|
+
exports.VIDEO_OVERLAY_ANIMATION_SEC = VIDEO_OVERLAY_ANIMATION_SEC;
|
|
1195
|
+
exports.VIDEO_OVERLAY_BADGE_INSET = VIDEO_OVERLAY_BADGE_INSET;
|
|
1196
|
+
exports.VIDEO_OVERLAY_BADGE_WIDTH = VIDEO_OVERLAY_BADGE_WIDTH;
|
|
1197
|
+
exports.VIDEO_OVERLAY_BOUNDS = VIDEO_OVERLAY_BOUNDS;
|
|
1198
|
+
exports.VIDEO_OVERLAY_BOX_FIELDS = VIDEO_OVERLAY_BOX_FIELDS;
|
|
1199
|
+
exports.VIDEO_OVERLAY_CORNERS = VIDEO_OVERLAY_CORNERS;
|
|
1200
|
+
exports.VIDEO_OVERLAY_DEFAULT_BACKGROUND = VIDEO_OVERLAY_DEFAULT_BACKGROUND;
|
|
1201
|
+
exports.VIDEO_OVERLAY_ERROR_CODES = VIDEO_OVERLAY_ERROR_CODES;
|
|
1202
|
+
exports.VIDEO_OVERLAY_FITS = VIDEO_OVERLAY_FITS;
|
|
1203
|
+
exports.VIDEO_OVERLAY_HANDLE_IDS = VIDEO_OVERLAY_HANDLE_IDS;
|
|
1204
|
+
exports.VIDEO_OVERLAY_LAYER_PLAN_HANDLE = VIDEO_OVERLAY_LAYER_PLAN_HANDLE;
|
|
1205
|
+
exports.VIDEO_OVERLAY_MAX_COMPOSITION_KEY_LENGTH = VIDEO_OVERLAY_MAX_COMPOSITION_KEY_LENGTH;
|
|
1206
|
+
exports.VIDEO_OVERLAY_MAX_LAYERS = VIDEO_OVERLAY_MAX_LAYERS;
|
|
1207
|
+
exports.VIDEO_OVERLAY_MAX_TIME_SEC = VIDEO_OVERLAY_MAX_TIME_SEC;
|
|
1208
|
+
exports.VIDEO_OVERLAY_MAX_TOTAL_LAYER_BYTES = VIDEO_OVERLAY_MAX_TOTAL_LAYER_BYTES;
|
|
1209
|
+
exports.VIDEO_OVERLAY_OUTPUT_ASPECTS = VIDEO_OVERLAY_OUTPUT_ASPECTS;
|
|
1210
|
+
exports.VIDEO_OVERLAY_PRESETS = VIDEO_OVERLAY_PRESETS;
|
|
1211
|
+
exports.VIDEO_OVERLAY_PRESET_IDS = VIDEO_OVERLAY_PRESET_IDS;
|
|
1212
|
+
exports.VIDEO_OVERLAY_WARNING_CODES = VIDEO_OVERLAY_WARNING_CODES;
|
|
1213
|
+
exports.analyzedSceneSchema = analyzedSceneSchema;
|
|
1214
|
+
exports.applyVideoOverlayPreset = applyVideoOverlayPreset;
|
|
1215
|
+
exports.aspectRatioFromDims = aspectRatioFromDims;
|
|
1216
|
+
exports.assembleVideoOverlayRequest = assembleVideoOverlayRequest;
|
|
1217
|
+
exports.centreCropToAspect = centreCropToAspect;
|
|
1218
|
+
exports.clearWiredVideoOverlayImageUrls = clearWiredVideoOverlayImageUrls;
|
|
1219
|
+
exports.clipLookSchema = clipLookSchema;
|
|
1220
|
+
exports.computeFrameFitPlan = computeFrameFitPlan;
|
|
1221
|
+
exports.deriveSlotRefs = deriveSlotRefs;
|
|
1222
|
+
exports.dropUnknownBindings = dropUnknownBindings;
|
|
1223
|
+
exports.dropUnknownSpeakers = dropUnknownSpeakers;
|
|
1224
|
+
exports.editPlanSourceDurationSec = editPlanSourceDurationSec;
|
|
1225
|
+
exports.entitySlotSchema = entitySlotSchema;
|
|
1226
|
+
exports.expandVideoOverlayLayer = expandVideoOverlayLayer;
|
|
1227
|
+
exports.expandVideoOverlayPresets = expandVideoOverlayPresets;
|
|
1228
|
+
exports.extractVideoDurationFromNode = extractVideoDurationFromNode;
|
|
1229
|
+
exports.formatVideoOverlayError = formatVideoOverlayError;
|
|
1230
|
+
exports.hasDrawableVideoOverlayBox = hasDrawableVideoOverlayBox;
|
|
1231
|
+
exports.inferMusicVideo = inferMusicVideo;
|
|
1232
|
+
exports.isOversizedScene = isOversizedScene;
|
|
1233
|
+
exports.isVideoOverlayCorner = isVideoOverlayCorner;
|
|
1234
|
+
exports.isVideoOverlayOutputAspect = isVideoOverlayOutputAspect;
|
|
1235
|
+
exports.isVideoOverlayPresetId = isVideoOverlayPresetId;
|
|
1236
|
+
exports.measuredCanvasCombinations = measuredCanvasCombinations;
|
|
1237
|
+
exports.mergeClipLook = mergeClipLook;
|
|
1238
|
+
exports.minimalRatioDimensions = minimalRatioDimensions;
|
|
1239
|
+
exports.normalizeVideoOverlayNodes = normalizeVideoOverlayNodes;
|
|
1240
|
+
exports.parseAspectToken = parseAspectToken;
|
|
1241
|
+
exports.parseVideoOverlayLayerPlan = parseVideoOverlayLayerPlan;
|
|
1242
|
+
exports.renderAnalyzedScene = renderAnalyzedScene;
|
|
1243
|
+
exports.resolveFrameDelivery = resolveFrameDelivery;
|
|
1244
|
+
exports.resolveFrameFitAspect = resolveFrameFitAspect;
|
|
1245
|
+
exports.resolveOutputCanvas = resolveOutputCanvas;
|
|
1246
|
+
exports.resolveVideoOverlayGeometry = resolveVideoOverlayGeometry;
|
|
1247
|
+
exports.rewriteSceneBindings = rewriteSceneBindings;
|
|
1248
|
+
exports.rewriteSlotTokens = rewriteSlotTokens;
|
|
1249
|
+
exports.rewriteSpeakerSlots = rewriteSpeakerSlots;
|
|
1250
|
+
exports.slotVariationSchema = slotVariationSchema;
|
|
1251
|
+
exports.stripDerivedAnalysisFields = stripDerivedAnalysisFields;
|
|
1252
|
+
exports.toCustomVideoOverlayLayer = toCustomVideoOverlayLayer;
|
|
1253
|
+
exports.unwrapUnresolvedTokens = unwrapUnresolvedTokens;
|
|
1254
|
+
exports.validateVideoOverlayRequest = validateVideoOverlayRequest;
|
|
1255
|
+
exports.videoAnalysisResultSchema = videoAnalysisResultSchema;
|
|
1256
|
+
exports.videoCharacterDistinctVoices = videoCharacterDistinctVoices;
|
|
1257
|
+
exports.videoCharacterRefCap = videoCharacterRefCap;
|
|
1258
|
+
exports.videoCharacterRefProblem = videoCharacterRefProblem;
|
|
1259
|
+
exports.videoCharacterRefProviders = videoCharacterRefProviders;
|
|
1260
|
+
exports.videoCharacterRefUnits = videoCharacterRefUnits;
|
|
1261
|
+
exports.videoCharacterVoiceCap = videoCharacterVoiceCap;
|
|
1262
|
+
exports.videoCharacterVoiceKey = videoCharacterVoiceKey;
|
|
1263
|
+
exports.videoCharacterVoiceProblem = videoCharacterVoiceProblem;
|
|
1264
|
+
exports.videoOverlayCanvas = videoOverlayCanvas;
|
|
1265
|
+
exports.videoOverlayCompositionKey = videoOverlayCompositionKey;
|
|
1266
|
+
exports.videoOverlayLayerLabel = videoOverlayLayerLabel;
|
|
1267
|
+
exports.videoOverlayPresetBox = videoOverlayPresetBox;
|
|
1268
|
+
exports.videoOverlayRenderOrder = videoOverlayRenderOrder;
|
|
1269
|
+
exports.videoOverlaySlotOfHandle = videoOverlaySlotOfHandle;
|
|
1270
|
+
exports.videoOverlaySlotSources = videoOverlaySlotSources;
|
|
1271
|
+
exports.windowAnalysisSchema = windowAnalysisSchema;
|
|
1272
|
+
//# sourceMappingURL=chunk-HKFMXNVQ.cjs.map
|
|
1273
|
+
//# sourceMappingURL=chunk-HKFMXNVQ.cjs.map
|