cozyclay 2.1.1 → 3.0.1

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 (585) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +12 -30
  3. package/bin/agent/agent-routes.mjs +43 -116
  4. package/bin/agent/agent-runner.mjs +14 -15
  5. package/bin/agent/cliproxy-provider.mjs +135 -0
  6. package/bin/agent/credential-store.mjs +30 -7
  7. package/bin/agent/pi-tools.mjs +4 -1
  8. package/bin/agent/provider-keys.mjs +32 -0
  9. package/bin/agent/provider-login.mjs +110 -0
  10. package/bin/agent/provider-routes.mjs +99 -0
  11. package/bin/agent/providers.mjs +19 -97
  12. package/bin/agent/script-tool.mjs +17 -4
  13. package/bin/agent/session-store.mjs +2 -2
  14. package/bin/agent/studio-context-budget.mjs +93 -0
  15. package/bin/agent/studio-motion-reference.mjs +23 -0
  16. package/bin/agent/studio-prompt.mjs +1 -1
  17. package/bin/agent/studio-rebase-text.mjs +32 -0
  18. package/bin/agent/studio-rebase.mjs +26 -39
  19. package/bin/agent/studio-tools.mjs +9 -28
  20. package/bin/agent/tool-arguments.mjs +49 -0
  21. package/bin/agent/turn-frames.mjs +66 -0
  22. package/bin/codex-auth.mjs +9 -2
  23. package/bin/cozyclay.mjs +10 -116
  24. package/bin/live/cli.mjs +3 -3
  25. package/bin/mcp-runtime.mjs +2 -12
  26. package/bin/package-signature.mjs +0 -4
  27. package/dist/app/index.html +7 -6
  28. package/dist/assets/EXRLoader-CvVIvGVE.js +1 -0
  29. package/dist/assets/analytics-BWCqdgWA.js +1 -0
  30. package/dist/assets/app-DfTCxaKk.js +5087 -0
  31. package/dist/assets/app-f-fkV5uP.css +1 -0
  32. package/dist/assets/compile-worker-BxKXh07s.js +5 -0
  33. package/dist/assets/fflate.module-KbGj5-H6.js +5 -0
  34. package/dist/assets/{first-shot-handoff-msLI71g1.js → first-shot-handoff-DNO8kv_N.js} +1 -1
  35. package/dist/assets/{landing-ChUvB_zL.js → landing-yfZaJkWc.js} +1 -1
  36. package/dist/assets/scene-asset-sync-U3kS2rvK.js +20 -0
  37. package/dist/assets/scene-asset-sync-_S8NQl5B.css +1 -0
  38. package/dist/assets/workflow-D78eiKTa.js +179 -0
  39. package/dist/cozyclay-package.json +1 -1
  40. package/dist/index.html +3 -3
  41. package/dist/sw.js +3 -6
  42. package/dist/workflow/index.html +5 -4
  43. package/mcp/LIVE-PROTOCOL.md +7 -47
  44. package/mcp/README.md +16 -26
  45. package/mcp/live-hub.mjs +6 -10
  46. package/mcp/package.json +1 -3
  47. package/mcp/tool-handlers.mjs +4 -168
  48. package/package.json +3 -22
  49. package/src/App.jsx +151 -2625
  50. package/src/agent-progress.js +80 -0
  51. package/src/agent-turn-mark.js +30 -0
  52. package/src/analytics.js +1 -19
  53. package/src/app-context.js +12 -2
  54. package/src/app-stage.jsx +2 -34
  55. package/src/asset-pane.jsx +6 -5
  56. package/src/camera-block.js +21 -0
  57. package/src/camera-direction.js +120 -0
  58. package/src/character-kind.js +3 -9
  59. package/src/command-bus.js +10 -8
  60. package/src/commands/cast.js +5 -34
  61. package/src/commands/elements/character.js +1 -1
  62. package/src/commands/elements/motion.js +1 -6
  63. package/src/commands/elements/object.js +6 -2
  64. package/src/commands/elements/shot.js +4 -1
  65. package/src/commands/elements.js +38 -14
  66. package/src/commands/index.js +3 -1
  67. package/src/commands/kits.js +37 -0
  68. package/src/commands/motion-timing.js +57 -0
  69. package/src/commands/motion.js +9 -152
  70. package/src/commands/motion3-compile.js +65 -0
  71. package/src/commands/motion3.js +214 -0
  72. package/src/commands/objects.js +6 -4
  73. package/src/commands/shot.js +55 -13
  74. package/src/commands/stage.js +14 -1
  75. package/src/commands/view.js +4 -1
  76. package/src/document-mirrors.js +42 -0
  77. package/src/document-store.js +4 -0
  78. package/src/domains/cast.js +19 -194
  79. package/src/domains/motion/motion-range-pin-rules.js +1 -1
  80. package/src/domains/motion/take-source.js +53 -0
  81. package/src/domains/motion.js +60 -1838
  82. package/src/domains/scenes.js +12 -55
  83. package/src/domains/shots.js +2 -2
  84. package/src/domains/stage.js +4 -2
  85. package/src/draft-ghost.js +47 -0
  86. package/src/draft-ghost.jsx +129 -0
  87. package/src/dualview.jsx +4 -3
  88. package/src/effects/EffectsLayer.jsx +112 -0
  89. package/src/effects/effect-meshes.js +232 -0
  90. package/src/effects/effect-record.js +103 -0
  91. package/src/effects/emitter.js +59 -0
  92. package/src/effects/simulate.js +261 -0
  93. package/src/effects/state.js +59 -0
  94. package/src/execution-telemetry.js +2 -3
  95. package/src/first-success-guide.jsx +5 -5
  96. package/src/ghost-set.js +257 -0
  97. package/src/held-object-edit.jsx +113 -0
  98. package/src/held-object-pose.js +175 -0
  99. package/src/hierarchy-model.js +1 -1
  100. package/src/hierarchy-panel.jsx +1 -1
  101. package/src/imported-mesh.jsx +103 -0
  102. package/src/kits/held.js +84 -0
  103. package/src/kits/index.js +70 -0
  104. package/src/kits/smoking.js +57 -0
  105. package/src/light-blockers.js +93 -0
  106. package/src/motion/beat-board-model.js +84 -0
  107. package/src/motion/beat-board.css +124 -0
  108. package/src/motion/beat-board.jsx +60 -0
  109. package/src/motion/center-of-mass.js +66 -0
  110. package/src/motion/fix-collisions.js +850 -0
  111. package/src/motion/physics-review.js +118 -0
  112. package/src/{ardy → motion}/physics-support.js +1 -76
  113. package/src/motion/rig-snapshot.js +22 -0
  114. package/src/motion/take-segments.jsx +140 -0
  115. package/src/{ardy → motion}/timeline-coordinates.js +0 -21
  116. package/src/{ardy → motion}/timeline.css +1 -2
  117. package/src/{ardy → motion}/timeline.jsx +42 -413
  118. package/src/motion/waypoints.js +76 -0
  119. package/src/motion3/beats.js +83 -0
  120. package/src/motion3/body.js +158 -0
  121. package/src/motion3/bones.js +47 -0
  122. package/src/motion3/carried.js +47 -0
  123. package/src/motion3/compile-job.js +79 -0
  124. package/src/motion3/compile-worker.js +10 -0
  125. package/src/motion3/compiler/anchors.js +113 -0
  126. package/src/motion3/compiler/arm-orient.js +128 -0
  127. package/src/motion3/compiler/channels.js +125 -0
  128. package/src/motion3/compiler/compile.js +205 -0
  129. package/src/motion3/compiler/gait-rhythm.js +97 -0
  130. package/src/motion3/compiler/grip.js +171 -0
  131. package/src/motion3/compiler/head-steady.js +48 -0
  132. package/src/motion3/compiler/hold.js +134 -0
  133. package/src/motion3/compiler/idle.js +113 -0
  134. package/src/motion3/compiler/limbs.js +197 -0
  135. package/src/motion3/compiler/math.js +72 -0
  136. package/src/motion3/compiler/pose.js +177 -0
  137. package/src/motion3/compiler/quat.js +49 -0
  138. package/src/motion3/compiler/skeleton.js +74 -0
  139. package/src/motion3/compiler/validate-common.js +32 -0
  140. package/src/motion3/compiler/validate-goals.js +118 -0
  141. package/src/motion3/compiler/validate-objects.js +144 -0
  142. package/src/motion3/compiler/validate-parts.js +118 -0
  143. package/src/motion3/compiler/validate.js +122 -0
  144. package/src/motion3/compiler/vocab.js +74 -0
  145. package/src/motion3/compiler/walk-pelvis.js +275 -0
  146. package/src/motion3/compiler/walk.js +207 -0
  147. package/src/motion3/compiler/wrist-clamp.js +32 -0
  148. package/src/motion3/delta.js +47 -0
  149. package/src/motion3/describe.js +177 -0
  150. package/src/motion3/docs.js +27 -0
  151. package/src/motion3/edit-carry.js +21 -0
  152. package/src/motion3/fix/ease.js +16 -0
  153. package/src/motion3/fix/ground.js +37 -0
  154. package/src/motion3/fix/index.js +52 -0
  155. package/src/motion3/fix/push.js +71 -0
  156. package/src/motion3/fix/reach.js +46 -0
  157. package/src/motion3/fix/retime.js +79 -0
  158. package/src/motion3/fix/self.js +211 -0
  159. package/src/motion3/fix/slide.js +70 -0
  160. package/src/motion3/fix/turn.js +51 -0
  161. package/src/motion3/follow.js +39 -0
  162. package/src/motion3/free-motion.js +204 -0
  163. package/src/motion3/grip-choice.js +130 -0
  164. package/src/motion3/hold-plan.js +157 -0
  165. package/src/motion3/json-patch.js +77 -0
  166. package/src/motion3/key-aim.js +105 -0
  167. package/src/motion3/key-edit.js +82 -0
  168. package/src/motion3/lenient.js +127 -0
  169. package/src/motion3/object-keys.js +236 -0
  170. package/src/motion3/object-pose.js +182 -0
  171. package/src/motion3/object-tracks.js +12 -0
  172. package/src/motion3/people.js +82 -0
  173. package/src/motion3/pipeline.js +102 -0
  174. package/src/motion3/playback.js +51 -0
  175. package/src/motion3/probes.js +91 -0
  176. package/src/motion3/qa/body-checks.js +34 -0
  177. package/src/motion3/qa/check-names.js +14 -0
  178. package/src/motion3/qa/checks.js +125 -0
  179. package/src/motion3/qa/contact-checks.js +51 -0
  180. package/src/motion3/qa/explain.js +80 -0
  181. package/src/motion3/qa/fmt.js +5 -0
  182. package/src/motion3/qa/foot-checks.js +72 -0
  183. package/src/motion3/qa/geometry.js +77 -0
  184. package/src/motion3/qa/goals.js +191 -0
  185. package/src/motion3/qa/ground.js +60 -0
  186. package/src/motion3/qa/hints-contact.js +195 -0
  187. package/src/motion3/qa/hints-goal.js +160 -0
  188. package/src/motion3/qa/hints-knee.js +24 -0
  189. package/src/motion3/qa/hints-motion.js +209 -0
  190. package/src/motion3/qa/hints-object.js +91 -0
  191. package/src/motion3/qa/index.js +44 -0
  192. package/src/motion3/qa/key-checks.js +82 -0
  193. package/src/motion3/qa/near.js +96 -0
  194. package/src/motion3/qa/object-checks.js +135 -0
  195. package/src/motion3/qa/patch.js +161 -0
  196. package/src/motion3/qa/people-checks.js +37 -0
  197. package/src/motion3/qa/severity.js +38 -0
  198. package/src/motion3/qa/spec-checks.js +65 -0
  199. package/src/motion3/qa/style.js +228 -0
  200. package/src/motion3/qa/wrist-checks.js +69 -0
  201. package/src/motion3/qa/wrist-obs.js +60 -0
  202. package/src/motion3/refs.js +129 -0
  203. package/src/motion3/repair-tune.js +121 -0
  204. package/src/motion3/repair.js +83 -0
  205. package/src/motion3/report.js +67 -0
  206. package/src/motion3/rigs/index.js +14 -0
  207. package/src/motion3/rigs/x-bot-tpose-body.json +1 -0
  208. package/src/motion3/rigs/x-bot-tpose.json +1 -0
  209. package/src/motion3/rigs/y-bot-tpose-body.json +1 -0
  210. package/src/motion3/rigs/y-bot-tpose.json +1 -0
  211. package/src/motion3/scene.js +60 -0
  212. package/src/motion3/schema/brief.js +89 -0
  213. package/src/motion3/schema/fields.js +44 -0
  214. package/src/motion3/schema/spec-examples.js +46 -0
  215. package/src/motion3/schema/topics.js +113 -0
  216. package/src/motion3/schema/types.js +149 -0
  217. package/src/motion3/search.js +117 -0
  218. package/src/motion3/second-hand.js +112 -0
  219. package/src/motion3/settle.js +136 -0
  220. package/src/motion3/skills/basic.js +83 -0
  221. package/src/motion3/skills/book.js +76 -0
  222. package/src/motion3/skills/car.js +145 -0
  223. package/src/motion3/skills/flip.js +200 -0
  224. package/src/motion3/skills/frames-auto.js +29 -0
  225. package/src/motion3/skills/impact.js +109 -0
  226. package/src/motion3/skills/index.js +85 -0
  227. package/src/motion3/skills/info.js +80 -0
  228. package/src/motion3/skills/smoke-kit.js +109 -0
  229. package/src/motion3/skills/smoke.js +160 -0
  230. package/src/motion3/spec-store.js +59 -0
  231. package/src/motion3/take-edit.js +155 -0
  232. package/src/motion3/take.js +63 -0
  233. package/src/motion3/timeline.js +127 -0
  234. package/src/motion3/views.js +121 -0
  235. package/src/motion3/walk-plan.js +119 -0
  236. package/src/object-catalog.jsx +7 -1
  237. package/src/object-colors.js +98 -0
  238. package/src/object-gizmo-parts.js +115 -0
  239. package/src/object-gizmo.jsx +37 -122
  240. package/src/object-glow.js +139 -0
  241. package/src/object-hidden.js +33 -0
  242. package/src/object-look.js +196 -0
  243. package/src/object-size.js +10 -0
  244. package/src/object-travel.js +71 -6
  245. package/src/panels/CameraPanel.jsx +7 -7
  246. package/src/panels/HdrEnvironmentControls.jsx +59 -0
  247. package/src/panels/LightPanel.jsx +25 -4
  248. package/src/panels/ObjectLookPanel.jsx +88 -0
  249. package/src/panels/PosePanel.jsx +2 -17
  250. package/src/panels/RigControlPanel.jsx +5 -53
  251. package/src/panels/SubjectBox.jsx +4 -1
  252. package/src/panels/details.css +14 -0
  253. package/src/posestudio.jsx +4 -27
  254. package/src/project-browser.jsx +3 -4
  255. package/src/project-resources.js +18 -31
  256. package/src/project.js +13 -104
  257. package/src/props.jsx +25 -280
  258. package/src/qa-label.js +25 -0
  259. package/src/rail-dot-drag.js +23 -0
  260. package/src/render-passes.js +10 -0
  261. package/src/resource-status.jsx +1 -0
  262. package/src/result-modal.jsx +4 -19
  263. package/src/room.jsx +20 -12
  264. package/src/scene-assets.js +8 -6
  265. package/src/scene-light-place.js +72 -0
  266. package/src/scene-lights.jsx +148 -0
  267. package/src/scene-objects.js +31 -139
  268. package/src/scenes.js +15 -105
  269. package/src/semantic-edit.js +2 -5
  270. package/src/set-pieces.jsx +183 -0
  271. package/src/settings-menu.jsx +3 -11
  272. package/src/shell/BottomDock.jsx +9 -51
  273. package/src/shell/DetailsSlot.jsx +16 -200
  274. package/src/shell/GhostsMenuGroup.jsx +74 -0
  275. package/src/shell/LibrarySlot.jsx +1 -3
  276. package/src/shell/MenuBar.jsx +3 -3
  277. package/src/shell/PreferencesDialog.jsx +15 -264
  278. package/src/shell/PreferencesSlot.jsx +2 -8
  279. package/src/shell/TopBar.jsx +5 -84
  280. package/src/shell/ViewportToolbar.jsx +10 -70
  281. package/src/shell/agent-glass.css +19 -6
  282. package/src/shell/details-selection.js +42 -0
  283. package/src/shell/ghosts-menu.css +22 -0
  284. package/src/shell/glass-regions.css +29 -3
  285. package/src/shell/preferences.css +6 -1
  286. package/src/shot-authoring.js +4 -7
  287. package/src/soft-shadows.js +37 -0
  288. package/src/stage-attach-frames.js +12 -12
  289. package/src/stage-canvas-rigs.jsx +3 -3
  290. package/src/stage-capture.jsx +42 -8
  291. package/src/stage-characters.jsx +22 -216
  292. package/src/stage-editor-gizmos.jsx +6 -6
  293. package/src/stage-environment.js +93 -0
  294. package/src/stage-hdr-builtins.js +107 -0
  295. package/src/stage-hdr-image.js +116 -0
  296. package/src/stage-hdr-library.js +70 -0
  297. package/src/stage-hdr-map.js +94 -0
  298. package/src/stage-hdr.js +130 -0
  299. package/src/stage-lighting.js +149 -0
  300. package/src/stage-occlusion.js +210 -0
  301. package/src/stage-sky.jsx +159 -0
  302. package/src/stage-startup-defaults.js +5 -9
  303. package/src/studio-actions.js +16 -14
  304. package/src/studio-agent-commands.js +19 -16
  305. package/src/studio-agent-motion.js +9 -9
  306. package/src/studio-agent-protocol.js +47 -77
  307. package/src/studio-app-binding.js +27 -47
  308. package/src/studio-asset-list.js +17 -0
  309. package/src/studio-contact-sheet.js +37 -5
  310. package/src/studio-elements.js +27 -7
  311. package/src/studio-entity-bounds.js +18 -0
  312. package/src/studio-error-codes.js +15 -0
  313. package/src/studio-export-framing.js +152 -0
  314. package/src/studio-lighting-check.js +103 -0
  315. package/src/studio-motion-visual.js +150 -0
  316. package/src/studio-schema-errors.js +80 -0
  317. package/src/studio-support-gap.js +74 -0
  318. package/src/styles.css +1 -19
  319. package/src/timeline-defaults.js +5 -0
  320. package/src/timeline-extent.js +8 -20
  321. package/src/tutorial-walk.js +17 -0
  322. package/src/ui-scrub.js +1 -1
  323. package/src/use-shot-camera-tracks.js +12 -0
  324. package/src/view-ghosts.js +97 -0
  325. package/src/view-ghosts.jsx +49 -0
  326. package/src/workflow/AgentPanel.jsx +47 -166
  327. package/src/workflow/AgentProgressCard.jsx +109 -0
  328. package/src/workflow/AgentReplyText.jsx +37 -0
  329. package/src/workflow/AgentTurnSteps.jsx +84 -0
  330. package/src/workflow/LoginPanel.jsx +140 -0
  331. package/src/workflow/WorkflowBuilder.jsx +7 -23
  332. package/src/workflow/agent-client.js +54 -51
  333. package/src/workflow/agent-panel.css +71 -1
  334. package/src/workflow/agent-progress-card.css +167 -0
  335. package/src/workflow/agent-progress-view.js +47 -0
  336. package/src/workflow/agent-turn-steps.css +113 -0
  337. package/src/workflow/agent-turn.js +191 -0
  338. package/src/workflow/login-client.js +34 -0
  339. package/src/workflow/motion-input.js +18 -31
  340. package/src/workflow/node-schema.js +1 -1
  341. package/src/workflow/reply-markdown.js +69 -0
  342. package/src/workflow/scene-asset-sync.js +8 -8
  343. package/tools/agent-session-stats.mjs +61 -0
  344. package/tools/dev-full.mjs +5 -56
  345. package/tools/eslint-baseline.json +12 -13
  346. package/tools/knip-baseline.json +0 -179
  347. package/tools/loc-baseline.json +31 -81
  348. package/tools/motion3/extract-body.mjs +103 -0
  349. package/tools/motion3/extract-rig.mjs +85 -0
  350. package/tools/process-supervisor.mjs +0 -88
  351. package/tools/run-tests.mjs +9 -125
  352. package/bin/agent/motion-runtime.mjs +0 -76
  353. package/dist/ardy/cskel27-rest.json +0 -557
  354. package/dist/assets/analytics-C9pMpW7s.js +0 -1
  355. package/dist/assets/app-B_2XB9rw.css +0 -1
  356. package/dist/assets/app-DAuvKPP8.js +0 -4920
  357. package/dist/assets/config-Bx7pYsD9.js +0 -1
  358. package/dist/assets/config-DeoFTYzb.css +0 -1
  359. package/dist/assets/demo-CvKuBgy5.js +0 -1
  360. package/dist/assets/scene-asset-sync-DKkpjKBV.js +0 -19
  361. package/dist/assets/scene-asset-sync-DjJ_cJ2R.css +0 -1
  362. package/dist/assets/ticket-BPk2Ni95.js +0 -1
  363. package/dist/assets/workflow-jJRBR94Z.js +0 -179
  364. package/dist/demo/walk-then-stop.npz +0 -0
  365. package/mcp/ardy-prompts.mjs +0 -218
  366. package/src/ardy/auto-fix-panel.css +0 -108
  367. package/src/ardy/auto-physics.js +0 -1194
  368. package/src/ardy/client.js +0 -153
  369. package/src/ardy/convert.js +0 -313
  370. package/src/ardy/cskel27-neutral.js +0 -39
  371. package/src/ardy/cskel27.js +0 -77
  372. package/src/ardy/export.js +0 -165
  373. package/src/ardy/fix-collisions.js +0 -2257
  374. package/src/ardy/foot-lock.js +0 -230
  375. package/src/ardy/motion-calibration.js +0 -118
  376. package/src/ardy/motion-edit.js +0 -213
  377. package/src/ardy/motion-url.js +0 -55
  378. package/src/ardy/mp4-duration.js +0 -102
  379. package/src/ardy/npz.js +0 -595
  380. package/src/ardy/physics-panel.css +0 -21
  381. package/src/ardy/physics-panel.jsx +0 -89
  382. package/src/ardy/physics-refine.js +0 -111
  383. package/src/ardy/physics-review.js +0 -567
  384. package/src/ardy/physics-temporal.js +0 -54
  385. package/src/ardy/platform-fit-panel.css +0 -64
  386. package/src/ardy/platform-fit-panel.jsx +0 -41
  387. package/src/ardy/platform-fit.js +0 -326
  388. package/src/ardy/playback.js +0 -711
  389. package/src/ardy/pose-pin.js +0 -97
  390. package/src/ardy/prompt-clips.js +0 -30
  391. package/src/ardy/retime.js +0 -211
  392. package/src/ardy/root-drop.js +0 -369
  393. package/src/ardy/timeline-resize.js +0 -13
  394. package/src/ardy/to-cskel27.js +0 -225
  395. package/src/ardy/trim.js +0 -33
  396. package/src/ardy/waypoints.js +0 -369
  397. package/src/ardy-bridge-contract.js +0 -281
  398. package/src/domains/motion/motion-video-capture.js +0 -664
  399. package/src/i2v-motion-client.js +0 -77
  400. package/src/i2v-motion-studio.jsx +0 -180
  401. package/src/line-edit.js +0 -1348
  402. package/src/motion/generation.js +0 -105
  403. package/src/motion-readiness-ui.jsx +0 -67
  404. package/src/motion-readiness.js +0 -40
  405. package/src/motion-resources.js +0 -177
  406. package/src/motion-store.js +0 -65
  407. package/src/motion-trail.js +0 -601
  408. package/src/multimodel-ingest.js +0 -394
  409. package/src/panels/PromptBlocksPanel.jsx +0 -444
  410. package/src/panels/VideoCapturePanel.jsx +0 -181
  411. package/src/pose-extract/browser.js +0 -42
  412. package/src/pose-extract/detector.js +0 -100
  413. package/src/pose-extract/fit.js +0 -227
  414. package/src/pose-extract/image-frame.js +0 -51
  415. package/src/pose-extract/index.js +0 -58
  416. package/src/pose-extract/keyframes.js +0 -74
  417. package/src/pose-extract/landmarks.js +0 -162
  418. package/src/pose-extract/mirror.js +0 -153
  419. package/src/pose-extract/take.js +0 -131
  420. package/src/pose-extract/video-frames.js +0 -91
  421. package/src/take-recipe.js +0 -165
  422. package/src/trail-key-conflicts.js +0 -39
  423. package/src/trail-pick.js +0 -59
  424. package/src/use-i2v-capture-modal.js +0 -15
  425. package/tools/ardy/BRIDGE.md +0 -37
  426. package/tools/ardy/GVHMR-NPZ.md +0 -68
  427. package/tools/ardy/README.md +0 -124
  428. package/tools/ardy/__pycache__/cclay_gvhmr_worker.cpython-313.pyc +0 -0
  429. package/tools/ardy/artifacts.mjs +0 -34
  430. package/tools/ardy/bridge.mjs +0 -1732
  431. package/tools/ardy/bvh-cskel27.mjs +0 -1265
  432. package/tools/ardy/cclay_constrained_generate.py +0 -561
  433. package/tools/ardy/cclay_gvhmr_worker.py +0 -264
  434. package/tools/ardy/cclay_motion_edit.py +0 -510
  435. package/tools/ardy/cclay_sequence_generate.py +0 -705
  436. package/tools/ardy/cclay_worker.py +0 -304
  437. package/tools/ardy/dump-npz.py +0 -205
  438. package/tools/ardy/extract-rest.mjs +0 -299
  439. package/tools/ardy/extract.mjs +0 -507
  440. package/tools/ardy/footage.mjs +0 -467
  441. package/tools/ardy/gvhmr-floor.mjs +0 -102
  442. package/tools/ardy/gvhmr-to-cskel27.mjs +0 -21
  443. package/tools/ardy/gvhmr_fastpath.py +0 -168
  444. package/tools/ardy/gvhmr_trajectory.py +0 -240
  445. package/tools/ardy/merge-text-encoder.py +0 -160
  446. package/tools/ardy/mocap-metrics.mjs +0 -200
  447. package/tools/ardy/mocap-quality-gate.mjs +0 -110
  448. package/tools/ardy/motion-stabilize.mjs +0 -348
  449. package/tools/ardy/npz.mjs +0 -414
  450. package/tools/ardy/pose-to-npz.mjs +0 -106
  451. package/tools/ardy/prompt-limits.mjs +0 -5
  452. package/tools/ardy/run-edit-on-box.sh +0 -73
  453. package/tools/ardy/run-local.mjs +0 -233
  454. package/tools/ardy/run-on-box.sh +0 -593
  455. package/tools/ardy/run-sequence-on-box.sh +0 -177
  456. package/tools/ardy/runners/gvhmr-worker.mjs +0 -206
  457. package/tools/ardy/runners/index.mjs +0 -18
  458. package/tools/ardy/runners/local.mjs +0 -455
  459. package/tools/ardy/runners/proc.mjs +0 -125
  460. package/tools/ardy/runners/remote.mjs +0 -252
  461. package/tools/ardy/setup-local.mjs +0 -189
  462. package/tools/ardy/setup-text-encoder-on-box.sh +0 -93
  463. package/tools/ardy/setup-text-encoder.py +0 -306
  464. package/tools/ardy/smpl-cskel27.mjs +0 -178
  465. package/tools/ardy/visual-qa.mjs +0 -196
  466. package/tools/ardy/vq-car.mjs +0 -52
  467. package/tools/bench/EXP3.md +0 -61
  468. package/tools/bench/cclay_bench_extract_incam.py +0 -125
  469. package/tools/bench/cclay_bench_extract_obs.py +0 -204
  470. package/tools/bench/cclay_bench_runner.py +0 -42
  471. package/tools/bench/cube-contact.mjs +0 -162
  472. package/tools/bench/exp3.mjs +0 -152
  473. package/tools/bench/extract-bench-lib.mjs +0 -216
  474. package/tools/bench/extract-bench.mjs +0 -302
  475. package/tools/bench/fal-generate.mjs +0 -88
  476. package/tools/bench/fit/README.md +0 -189
  477. package/tools/bench/fit/camera.mjs +0 -59
  478. package/tools/bench/fit/contact.mjs +0 -419
  479. package/tools/bench/fit/footlock.mjs +0 -234
  480. package/tools/bench/fit/motion.mjs +0 -85
  481. package/tools/bench/fit/pin.mjs +0 -27
  482. package/tools/bench/fit/remote.mjs +0 -105
  483. package/tools/bench/fit-bench.mjs +0 -126
  484. package/tools/bench/fit-sanity.mjs +0 -45
  485. package/tools/bench/metrics.mjs +0 -313
  486. package/tools/bench/obs/depth.mjs +0 -258
  487. package/tools/bench/obs/extrinsics.mjs +0 -175
  488. package/tools/bench/obs/fit_mannequin_betas.py +0 -340
  489. package/tools/bench/obs/ground.mjs +0 -294
  490. package/tools/bench/obs/heading.mjs +0 -151
  491. package/tools/bench/obs/ladder.mjs +0 -555
  492. package/tools/bench/obs/mannequin-betas.json +0 -124
  493. package/tools/bench/obs/remote.mjs +0 -83
  494. package/tools/bench/obs/rest_joints.py +0 -52
  495. package/tools/bench/obs/ybot-targets.mjs +0 -49
  496. package/tools/bench/obs-bench.mjs +0 -520
  497. package/tools/bench/score.mjs +0 -343
  498. package/tools/bench/summarize.mjs +0 -86
  499. package/tools/demo-worker/README.md +0 -137
  500. package/tools/demo-worker/api-client.mjs +0 -233
  501. package/tools/demo-worker/generate.mjs +0 -301
  502. package/tools/demo-worker/index.mjs +0 -466
  503. package/tools/demo-worker/sign-core.mjs +0 -112
  504. package/tools/demo-worker/sign.mjs +0 -161
  505. package/tools/gt-render/browser.mjs +0 -182
  506. package/tools/gt-render/camera-math.mjs +0 -276
  507. package/tools/gt-render/page.mjs +0 -267
  508. package/tools/gt-render/render.mjs +0 -514
  509. package/tools/gt-render/scene-box.mjs +0 -31
  510. package/tools/gt-render/take-transform.mjs +0 -87
  511. package/tools/kimodo/compare-seam.mjs +0 -108
  512. package/tools/kimodo/constraints.mjs +0 -244
  513. package/tools/kimodo/edit.mjs +0 -259
  514. package/tools/kimodo/effector-constraints.mjs +0 -200
  515. package/tools/kimodo/generate.mjs +0 -646
  516. package/tools/kimodo/local-output.mjs +0 -265
  517. package/tools/kimodo/measure-pose.mjs +0 -65
  518. package/tools/kimodo/measure-preserve.mjs +0 -899
  519. package/tools/kimodo/measure-waypoints.mjs +0 -55
  520. package/tools/kimodo/mlx-generate.py +0 -111
  521. package/tools/kimodo/pose-constraints.mjs +0 -248
  522. package/tools/kimodo/preserve-mask.mjs +0 -543
  523. package/tools/kimodo/read-npz.mjs +0 -189
  524. package/tools/kimodo/run-edit-on-box.mjs +0 -155
  525. package/tools/kimodo/run-sequence-on-box.mjs +0 -178
  526. package/tools/kimodo/runner.mjs +0 -284
  527. package/tools/kimodo/seam-batch.mjs +0 -77
  528. package/tools/kimodo/setup-local.mjs +0 -30
  529. package/tools/kimodo/setup-on-box.sh +0 -339
  530. package/tools/kimodo/soma77-to-cskel27.mjs +0 -305
  531. package/tools/morphgs/assets/gen_truth.py +0 -39
  532. package/tools/morphgs/assets/mesh_ori_rig.txt +0 -27
  533. package/tools/morphgs/assets/playback-check.mjs +0 -30
  534. package/tools/morphgs/demo-gate.sh +0 -26
  535. package/tools/morphgs/fbx2morphgs.mjs +0 -68
  536. package/tools/morphgs/morphgs-to-cskel27.mjs +0 -105
  537. package/tools/morphgs/patches/preprocess_src-none-mode.patch +0 -76
  538. package/tools/morphgs/setup-on-cluster.sh +0 -126
  539. package/tools/projflow/driver.py +0 -1069
  540. package/tools/projflow/generate.mjs +0 -805
  541. package/tools/projflow/hml22-to-cskel27.mjs +0 -735
  542. package/tools/projflow/line-edit-job.mjs +0 -547
  543. package/tools/projflow/replay.mjs +0 -452
  544. package/tools/projflow/runner.mjs +0 -269
  545. package/tools/projflow/service.mjs +0 -742
  546. package/tools/track/DESIGN.md +0 -513
  547. package/tools/track/backfill-provenance.mjs +0 -116
  548. package/tools/track/budget.mjs +0 -8
  549. package/tools/track/check-rig.mjs +0 -209
  550. package/tools/track/diagnostics.schema.json +0 -60
  551. package/tools/track/export-rig.mjs +0 -256
  552. package/tools/track/fallback.mjs +0 -7
  553. package/tools/track/fk-parity-fixture.mjs +0 -161
  554. package/tools/track/gate.mjs +0 -349
  555. package/tools/track/masks.mjs +0 -318
  556. package/tools/track/metrics.mjs +0 -201
  557. package/tools/track/publish-obs.mjs +0 -108
  558. package/tools/track/py/check_env.py +0 -61
  559. package/tools/track/py/eval_lr.py +0 -229
  560. package/tools/track/py/lr_viterbi.py +0 -294
  561. package/tools/track/py/masks.py +0 -405
  562. package/tools/track/py/objective.py +0 -382
  563. package/tools/track/py/rig.py +0 -508
  564. package/tools/track/py/scene.py +0 -326
  565. package/tools/track/py/test_joint_indices.py +0 -123
  566. package/tools/track/py/test_lr_viterbi.py +0 -195
  567. package/tools/track/py/test_masks.py +0 -229
  568. package/tools/track/py/test_rig.py +0 -288
  569. package/tools/track/py/test_scene.py +0 -354
  570. package/tools/track/py/test_track.py +0 -328
  571. package/tools/track/py/track.py +0 -411
  572. package/tools/track/remote.mjs +0 -140
  573. package/tools/track/rig-dump.mjs +0 -227
  574. package/tools/track/run-box-tests.mjs +0 -14
  575. package/tools/track/run-box.mjs +0 -168
  576. package/tools/track/setup-box.sh +0 -59
  577. package/tools/track/study-2d.mjs +0 -728
  578. /package/src/{ardy → motion}/collision-blockers.js +0 -0
  579. /package/src/{ardy → motion}/ground.js +0 -0
  580. /package/src/{ardy → motion}/ik-drag.js +0 -0
  581. /package/src/{ardy → motion}/ik-key-json.js +0 -0
  582. /package/src/{ardy → motion}/ik.js +0 -0
  583. /package/src/{ardy → motion}/physics-surface.js +0 -0
  584. /package/src/{ardy → motion}/playback-clock.js +0 -0
  585. /package/src/{ardy → motion}/range-pin.js +0 -0
@@ -0,0 +1,66 @@
1
+ // What the model is doing BETWEEN tool calls, as frames the agent panel shows while a turn runs: the
2
+ // reasoning summary it streams (thinking.delta, batched) and the tool call it is writing (tool.compose: the
3
+ // tool, and for run_action the action and its subject as soon as the streamed arguments name them). A long
4
+ // motion spec or script takes the model many seconds to write; without these the panel could only say
5
+ // "Thinking…". Frames only: nothing here reaches the model or the scene.
6
+
7
+ const FLUSH_MS = 400;
8
+ const MIN_BATCH = 16;
9
+ const SCAN_LIMIT = 8192;
10
+ const SUBJECT_MAX = 80;
11
+
12
+ // Complete JSON strings only: a streamed fragment never names half an action.
13
+ const ACTION = /"action"\s*:\s*"([a-zA-Z0-9_.-]{1,80})"/;
14
+ const LABEL = /"(?:label|caption)"\s*:\s*"((?:[^"\\]|\\.){1,200})"/;
15
+ const SCRIPT_TITLE = /"code"\s*:\s*"\s*\/\/\s*((?:[^"\\]|\\[^n]){1,200})(?:\\n|")/;
16
+
17
+ const unescape = text => { try { return JSON.parse(`"${text}"`); } catch { return text; } };
18
+ const clip = text => { const line = unescape(text).trim(); return line.length > SUBJECT_MAX ? `${line.slice(0, SUBJECT_MAX - 1)}…` : line; };
19
+
20
+ /** The action and subject named by a tool call's raw argument JSON so far: { action?, subject? }. */
21
+ function composedCall(name, raw) {
22
+ const action = name === "run_action" ? ACTION.exec(raw)?.[1] : undefined;
23
+ const subject = name === "script" ? SCRIPT_TITLE.exec(raw)?.[1] : LABEL.exec(raw)?.[1];
24
+ return { ...(action ? { action } : {}), ...(subject ? { subject: clip(subject) } : {}) };
25
+ }
26
+
27
+ /**
28
+ * createReasoningFrames(push, clock) -> { onMessageEvent(event), flush() }
29
+ * onMessageEvent takes pi's assistant message events (thinking_*, toolcall_*, text_*); push gets
30
+ * { type: "thinking.delta", text } at most every FLUSH_MS, and { type: "tool.compose", index, name, action?, subject? }
31
+ * whenever what the call being written names changes.
32
+ */
33
+ export function createReasoningFrames(push, clock = () => Date.now()) {
34
+ let thinking = "", flushedAt = clock();
35
+ const calls = new Map();
36
+ const flush = () => {
37
+ if (!thinking) return;
38
+ push({ type: "thinking.delta", text: thinking });
39
+ thinking = "";
40
+ flushedAt = clock();
41
+ };
42
+ return {
43
+ flush,
44
+ onMessageEvent(event) {
45
+ if (event?.type === "thinking_delta") {
46
+ thinking += event.delta ?? "";
47
+ // a batch says something: not a lone word at the start of a paragraph
48
+ if (clock() - flushedAt >= FLUSH_MS && thinking.length >= MIN_BATCH) flush();
49
+ return;
50
+ }
51
+ flush();
52
+ if (event?.type !== "toolcall_start" && event?.type !== "toolcall_delta") return;
53
+ const call = event.partial?.content?.[event.contentIndex];
54
+ if (call?.type !== "toolCall" || typeof call.name !== "string" || !call.name) return;
55
+ // contentIndex restarts with every assistant message, so a start begins a new call
56
+ const seen = event.type === "toolcall_start" ? { raw: "", key: null } : calls.get(event.contentIndex) ?? { raw: "", key: null };
57
+ if (event.type === "toolcall_delta" && seen.raw.length < SCAN_LIMIT) seen.raw += event.delta ?? "";
58
+ const named = composedCall(call.name, seen.raw);
59
+ const key = `${call.name}|${named.action ?? ""}|${named.subject ?? ""}`;
60
+ calls.set(event.contentIndex, seen);
61
+ if (seen.key === key) return;
62
+ seen.key = key;
63
+ push({ type: "tool.compose", index: event.contentIndex, name: call.name, ...named });
64
+ },
65
+ };
66
+ }
@@ -5,7 +5,7 @@ import { homedir } from "node:os";
5
5
  import { join } from "node:path";
6
6
  import { openBrowser } from "./open-browser.mjs";
7
7
  import { writeSecureJson } from "./agent/secure-file.mjs";
8
- import { readKeys } from "./agent/provider-keys.mjs";
8
+ import { readCredentials, readKeys } from "./agent/provider-keys.mjs";
9
9
  import { PROVIDERS } from "./agent/providers.mjs";
10
10
 
11
11
  const AUTHORIZE_ENDPOINT = "https://auth.openai.com/oauth/authorize";
@@ -54,12 +54,16 @@ function providersConfigured() {
54
54
  const configured = new Set();
55
55
  for (const provider of PROVIDERS) for (const name of provider.env) if (process.env[name]?.trim()) configured.add(provider.id);
56
56
  for (const [id, value] of Object.entries(readKeys())) if (typeof value === "string" && value.trim()) configured.add(id);
57
+ // and every provider a pi login stored a credential for (auth.json: OAuth, or a key with provider env)
58
+ for (const id of Object.keys(readCredentials())) configured.add(id);
57
59
  return configured.size;
58
60
  }
59
61
  export function status() {
60
62
  const claim = claims();
61
63
  const auth = claim["https://api.openai.com/auth"] || {};
62
- return { signedIn: !!readTokens()?.refresh_token, email: claim.email || null, plan: auth.chatgpt_plan_type || null, accountId: auth.chatgpt_account_id || null, expiresAt: readTokens()?.expires_at || null, providersConfigured: providersConfigured() };
64
+ // `pending` keeps the panel on "Waiting for your browser…" while a sign-in page is open, with its link.
65
+ const pending = Boolean(authServer && authState) && !readTokens()?.refresh_token;
66
+ return { signedIn: !!readTokens()?.refresh_token, ...(pending ? { pending, authorizeUrl: authState.result.authorizeUrl } : {}), email: claim.email || null, plan: auth.chatgpt_plan_type || null, accountId: auth.chatgpt_account_id || null, expiresAt: readTokens()?.expires_at || null, providersConfigured: providersConfigured() };
63
67
  }
64
68
  export function readStored() {
65
69
  const current = readTokens();
@@ -124,6 +128,9 @@ export async function startOAuth() {
124
128
  const authorizeUrl = new URL(AUTHORIZE_ENDPOINT);
125
129
  for (const [key, value] of Object.entries({ response_type: "code", client_id: CLIENT_ID, redirect_uri: `http://${"local" + "host"}:${port}/auth/callback`, scope: SCOPE, code_challenge: challenge, code_challenge_method: "S256", state, id_token_add_organizations: "true", codex_cli_simplified_flow: "true", originator: "cozyclay" })) authorizeUrl.searchParams.set(key, value);
126
130
  authState = { result: { ok: true, port, authorizeUrl: authorizeUrl.toString() } };
131
+ // An abandoned sign-in stops listening after ten minutes, so the panel cannot wait on it forever.
132
+ const server = authServer;
133
+ setTimeout(() => { if (authServer === server) { server.close(); authServer = null; authState = null; } }, 10 * 60 * 1000).unref?.();
127
134
  openBrowser(authorizeUrl.toString());
128
135
  return authState.result;
129
136
  }
package/bin/cozyclay.mjs CHANGED
@@ -3,13 +3,9 @@
3
3
  * cozyclay - run the studio from a published package.
4
4
  *
5
5
  * `npx cozyclay` / `bunx cozyclay` should behave like `npm run dev` does in a
6
- * clone: the studio in a browser, with the optional motion sidecar wired up.
7
- * The difference is that nothing is built here. The package ships the built
8
- * `dist/`, so this launcher only has to
9
- *
10
- * - serve those files over loopback,
11
- * - forward /ardy to its dynamically selected sidecar port (the same job Vite's dev proxy does),
12
- * - keep the sidecar's lifetime tied to this process.
6
+ * clone: the studio in a browser. The difference is that nothing is built
7
+ * here. The package ships the built `dist/`, so this launcher only has to
8
+ * serve those files over loopback (plus the OAuth and agent routes).
13
9
  *
14
10
  * The only runtime dependencies are the agent packages
15
11
  * `@earendil-works/pi-ai` and `@earendil-works/pi-agent-core` (MIT), and the
@@ -19,9 +15,8 @@
19
15
  * launcher that will break.
20
16
  */
21
17
  import { spawn } from "node:child_process";
22
- import { startBridge, terminateOwned } from "../tools/process-supervisor.mjs";
23
18
  import { createReadStream, existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
24
- import { createServer, request as httpRequest } from "node:http";
19
+ import { createServer } from "node:http";
25
20
  import { homedir } from "node:os";
26
21
  import { extname, join, normalize, resolve } from "node:path";
27
22
  import { createInterface } from "node:readline";
@@ -54,7 +49,6 @@ try {
54
49
  // An unreadable package is handled by the existing missing-build checks.
55
50
  }
56
51
  const DIST = join(PKG_ROOT, "dist");
57
- const BRIDGE = join(PKG_ROOT, "tools", "ardy", "bridge.mjs");
58
52
  const OFFICIAL_PACKAGE = (
59
53
  packageMetadata.name === "cozyclay"
60
54
  && !SOURCE_CHECKOUT
@@ -64,12 +58,6 @@ const INSTALL_KIND = process.env.npm_config_global === "true"
64
58
  || (PKG_ROOT.includes("/node_modules/") && !PKG_ROOT.includes("/_npx/"))
65
59
  ? "global"
66
60
  : "npx";
67
- // A bridge is optional. Keep the endpoint unset until this launcher owns a
68
- // sidecar; otherwise /ardy requests could accidentally reach an unrelated
69
- // process that happens to be listening on the bridge's historical default
70
- // port (5181).
71
- let bridge = null;
72
- let bridgePort = null;
73
61
 
74
62
  const TYPES = {
75
63
  ".html": "text/html; charset=utf-8",
@@ -80,7 +68,6 @@ const TYPES = {
80
68
  ".wasm": "application/wasm",
81
69
  ".woff2": "font/woff2",
82
70
  ".fbx": "application/octet-stream",
83
- ".npz": "application/octet-stream",
84
71
  ".png": "image/png",
85
72
  ".jpg": "image/jpeg",
86
73
  ".gif": "image/gif",
@@ -89,14 +76,15 @@ const TYPES = {
89
76
  };
90
77
 
91
78
  function parseArgs(argv) {
92
- const opts = { port: 5180, host: "127.0.0.1", motion: true, open: true, star: true, updateCheck: true };
79
+ const opts = { port: 5180, host: "127.0.0.1", open: true, star: true, updateCheck: true };
93
80
  for (let i = 0; i < argv.length; i += 1) {
94
81
  const arg = argv[i];
95
82
  if (arg === "--port" || arg === "-p") opts.port = Number(argv[++i]);
96
83
  else if (arg.startsWith("--port=")) opts.port = Number(arg.slice(7));
97
84
  else if (arg === "--host") opts.host = String(argv[++i]);
98
85
  else if (arg.startsWith("--host=")) opts.host = arg.slice(7);
99
- else if (arg === "--no-motion") opts.motion = false;
86
+ // Accepted for old scripts: there is no motion sidecar any more.
87
+ else if (arg === "--no-motion") continue;
100
88
  else if (arg === "--no-open") opts.open = false;
101
89
  else if (arg === "--scene") opts.scene = String(argv[++i] ?? "");
102
90
  else if (arg.startsWith("--scene=")) opts.scene = arg.slice(8);
@@ -158,7 +146,6 @@ const HELP = `cozyclay - browser-based 3D staging studio
158
146
  (cclay live --help lists every verb)
159
147
  cclay update install the latest cozyclay globally (npm install -g)
160
148
  npx cozyclay --port 5200 serve on another port
161
- npx cozyclay --no-motion skip the optional motion-generation sidecar
162
149
  npx cozyclay --no-open do not open a browser
163
150
  npx cozyclay --scene city-block
164
151
  open the studio on a bundled starter scene
@@ -177,9 +164,8 @@ const HELP = `cozyclay - browser-based 3D staging studio
177
164
 
178
165
  cclay is the same command, shorter: a global install gives you both.
179
166
 
180
- Motion generation needs an SSH-reachable NVIDIA machine running Kimodo; point
181
- the sidecar at it with CCLAY_KIMODO_HOST. Everything else - staging, posing,
182
- paths, cameras, timeline, playback - runs locally with no extra setup.`;
167
+ Everything - staging, posing, compiled motion, cameras, timeline, playback -
168
+ runs locally with no extra setup.`;
183
169
 
184
170
  function serveFile(res, path) {
185
171
  const type = TYPES[extname(path).toLowerCase()] ?? "application/octet-stream";
@@ -193,39 +179,6 @@ function serveFile(res, path) {
193
179
  createReadStream(path).pipe(res);
194
180
  }
195
181
 
196
- // Forward /ardy to the sidecar. Same contract as the Vite dev proxy, so the
197
- // browser code needs no build-time knowledge of how it was launched.
198
- function proxyToBridge(req, res, configured) {
199
- if (!bridge || bridgePort === null || bridge.exitCode !== null || bridge.signalCode !== null) {
200
- req.resume();
201
- res.writeHead(503, { "content-type": "application/json; charset=utf-8" });
202
- if (req.url.split("?")[0] === "/ardy/health") {
203
- res.end(JSON.stringify({ ok: false, backend: configured ? "local_kimodo" : "none", host_configured: configured, reason: configured ? "unreachable" : "unconfigured", capabilities: { lineEdit: false }, error: "motion sidecar is not running" }));
204
- } else {
205
- res.end(JSON.stringify({ error: "motion sidecar is not running" }));
206
- }
207
- return;
208
- }
209
- const upstream = httpRequest(
210
- { host: "127.0.0.1", port: bridgePort, path: req.url, method: req.method, headers: req.headers },
211
- (upstreamRes) => {
212
- res.writeHead(upstreamRes.statusCode ?? 502, upstreamRes.headers);
213
- upstreamRes.pipe(res);
214
- },
215
- );
216
- upstream.on("error", () => {
217
- // An absent sidecar is an expected state, not a crash: the app treats a
218
- // failed probe as "generation unavailable" and carries on.
219
- res.writeHead(503, { "content-type": "application/json; charset=utf-8" });
220
- if (req.url.split("?")[0] === "/ardy/health") {
221
- res.end(JSON.stringify({ ok: false, backend: configured ? "local_kimodo" : "none", host_configured: configured, reason: configured ? "unreachable" : "unconfigured", capabilities: { lineEdit: false }, error: "motion sidecar is not running" }));
222
- } else {
223
- res.end(JSON.stringify({ error: "motion sidecar is not running" }));
224
- }
225
- });
226
- req.pipe(upstream);
227
- }
228
-
229
182
  function readState() {
230
183
  try {
231
184
  return JSON.parse(readFileSync(STATE_FILE, "utf8"));
@@ -383,17 +336,12 @@ if (!existsSync(join(DIST, "app", "index.html"))) {
383
336
  process.exit(1);
384
337
  }
385
338
 
386
- // The sidecar exits immediately without a box to talk to, so starting it
387
- // unconditionally would greet a first-time `npx cozyclay` with an error it
388
- // cannot act on. An unset CCLAY_KIMODO_HOST is the normal case, not a fault.
389
- const kimodoHost = process.env.CCLAY_KIMODO_HOST?.trim();
390
339
  let server = null;
391
340
  const startedAt = Date.now();
392
341
  let shuttingDown = false;
393
342
  async function shutdown(exitCode = 0) {
394
343
  if (shuttingDown) return;
395
344
  shuttingDown = true;
396
- if (bridge) await terminateOwned(bridge);
397
345
  if (server?.listening) await new Promise((resolvePromise) => server.close(() => resolvePromise()));
398
346
  try {
399
347
  await maybeAskForStar(startedAt, opts);
@@ -405,49 +353,9 @@ async function shutdown(exitCode = 0) {
405
353
  process.on("SIGINT", () => shutdown(130));
406
354
  process.on("SIGTERM", () => shutdown(143));
407
355
 
408
- if (opts.motion && kimodoHost && existsSync(BRIDGE)) {
409
- try {
410
- // The package has no three (a devDependency); the bridge runs from the
411
- // staged MCP runtime, which carries three, tools/ and src/.
412
- const bridgeRoot = SOURCE_CHECKOUT ? PKG_ROOT : await ensureMcpRuntime();
413
- ({ child: bridge, port: bridgePort } = await startBridge({
414
- command: process.execPath,
415
- args: [join(bridgeRoot, "tools", "ardy", "bridge.mjs")],
416
- cwd: bridgeRoot,
417
- env: process.env,
418
- mainPort: opts.port,
419
- onSpawn: (child) => {
420
- bridge = child;
421
- },
422
- onReady: (child) => {
423
- child.once("exit", (code, signal) => {
424
- if (shuttingDown) return;
425
- console.error(`cozyclay: motion generation sidecar exited ${signal ? `from ${signal}` : `with code ${code ?? 0}`}.`);
426
- void shutdown(1);
427
- });
428
- child.once("error", (err) => {
429
- if (shuttingDown) return;
430
- console.error(`cozyclay: motion generation sidecar failed: ${err.message}`);
431
- void shutdown(1);
432
- });
433
- },
434
- }));
435
- } catch (err) {
436
- console.error(`cozyclay: motion generation sidecar failed: ${err.message}`);
437
- for (const line of err.lines ?? []) console.error(`cozyclay: ${line}`);
438
- console.error("cozyclay: studio did not start; set COZYCLAY_BRIDGE_PORT to an available port or use --no-motion.");
439
- if (bridge) await terminateOwned(bridge);
440
- process.exit(1);
441
- }
442
- }
443
-
444
- // Task 6 consumes this getter when constructing the Studio runtime. Never
445
- // substitute an environment/default port for a sidecar this launcher owns.
446
- const getBridgeOrigin = () => bridge && bridgePort !== null && bridge.exitCode === null && bridge.signalCode === null
447
- ? `http://127.0.0.1:${bridgePort}` : null;
448
356
  // A source checkout has mcp/node_modules; the package loads the Studio's live
449
357
  // tools from the staged MCP runtime that `cclay mcp` also uses (#576).
450
- const agentHandler = createAgentHandler({ port: () => opts.port, getBridgeOrigin, ...(SOURCE_CHECKOUT ? {} : { mcpRuntime: { ensure: ensureMcpRuntime } }) });
358
+ const agentHandler = createAgentHandler({ port: () => opts.port, ...(SOURCE_CHECKOUT ? {} : { mcpRuntime: { ensure: ensureMcpRuntime } }) });
451
359
  server = createServer((req, res) => {
452
360
  const url = new URL(req.url ?? "/", "http://127.0.0.1");
453
361
  if (/^\/oauth\/(start|status|logout)$/.test(url.pathname)) {
@@ -508,13 +416,6 @@ server = createServer((req, res) => {
508
416
  res.end(JSON.stringify({ error: "method not allowed" }));
509
417
  return;
510
418
  }
511
- // Only the routes the bridge actually owns: /ardy/ is ALSO a public asset
512
- // directory (cskel27-rest.json), and those files live in dist/, not behind
513
- // the sidecar. Same rule as the Vite dev proxy bypass.
514
- if (/^\/ardy\/(health|bases|generate|footage|extract|motions)(\/|$)/.test(url.pathname)) {
515
- proxyToBridge(req, res, opts.motion && Boolean(kimodoHost));
516
- return;
517
- }
518
419
  let rel;
519
420
  try {
520
421
  rel = decodeURIComponent(url.pathname);
@@ -590,13 +491,6 @@ server.listen({ port: opts.port, host: "127.0.0.1", ipv6Only: false }, () => {
590
491
  const url = `http://127.0.0.1:${opts.port}/app/${sceneParam}`;
591
492
  console.log(`CozyClay is running at ${url}`);
592
493
  console.log("Use a Chromium-based browser — Safari and Firefox are not supported.");
593
- if (!opts.motion) console.log("Motion generation: off (--no-motion).");
594
- else if (bridge) console.log(`Motion generation: sidecar running against ${kimodoHost}.`);
595
- else
596
- console.log(
597
- "Motion generation: off. It runs on an SSH-reachable NVIDIA machine with Kimodo;\n" +
598
- "set CCLAY_KIMODO_HOST=user@host to turn it on. Everything else works without it.",
599
- );
600
494
  if (opts.open) openBrowser(url);
601
495
  void updatePending?.then((latest) => {
602
496
  // `cclay` only exists after a global install, so name the command that
package/bin/live/cli.mjs CHANGED
@@ -31,7 +31,7 @@ const USAGE = `cclay live - drive a running CozyClay studio from a terminal
31
31
  [--play | --pause]
32
32
  cclay live verify (--receipt <id> | --targets a,b) --checks placement,framing
33
33
  [--range whole_clip|start:end] [--strict]
34
- [--visual frame|contact_sheet --out check.png]
34
+ [--visual frame|contact_sheet|plan|trace [--frames even|beats] --out check.png]
35
35
  cclay live undo --receipt <id>
36
36
  cclay live commands [--ids a,b] the commands the editor registers; ids add schemas
37
37
  cclay live run <id> [--args '<json>'] any command the editor registers, admitted like
@@ -62,7 +62,7 @@ const VERBS = new Map([
62
62
  ["patch", { flags: ["--target", "--set"], command: "patch_elements" }],
63
63
  ["frame-shot", { flags: ["--subject", "--size", "--view", "--level", "--side", "--focal", "--exact"] }],
64
64
  ["operate", { flags: ["--select", "--frame", "--mode", "--play", "--pause"] }],
65
- ["verify", { flags: ["--receipt", "--targets", "--checks", "--range", "--strict", "--visual", "--out"] }],
65
+ ["verify", { flags: ["--receipt", "--targets", "--checks", "--range", "--strict", "--visual", "--frames", "--out"] }],
66
66
  ["undo", { flags: ["--receipt"] }],
67
67
  ["commands", { flags: ["--ids"] }],
68
68
  ["run", { flags: ["--args"], argument: "command id" }],
@@ -426,7 +426,7 @@ async function runVerb({ client, verb, spec, name, flags }) {
426
426
  const args = { checks: commaList(required(flags, "--checks", verb)), ...(hasReceipt ? { receiptId: required(flags, "--receipt", verb) } : { targets: commaList(required(flags, "--targets", verb)) }) };
427
427
  if (flags.has("--range")) args.range = frameRangeFlag(flags, "--range");
428
428
  const visual = flags.has("--visual") ? String(flags.get("--visual")) : "none";
429
- if (visual !== "none") args.visual = visual;
429
+ if (visual !== "none") Object.assign(args, { visual }, flags.has("--frames") ? { frames: String(flags.get("--frames")) } : {});
430
430
  const out = visual === "none" ? null : resolvePath(required(flags, "--out", verb));
431
431
  const value = await admitted("verify_result", args);
432
432
  if (flags.get("--strict") === true && value?.checks?.framing?.issueFrames?.length) {
@@ -18,7 +18,7 @@ const MCP_RUNTIME = process.env.COZYCLAY_MCP_RUNTIME_DIR || join(
18
18
  function probeMcpRuntime(runtime = MCP_RUNTIME) {
19
19
  const server = join(runtime, "mcp", "server.mjs");
20
20
  if (!existsSync(server)) throw new Error("MCP server is missing");
21
- if (!existsSync(join(runtime, "tools", "ardy", "bridge.mjs"))) throw new Error("motion bridge is missing");
21
+
22
22
  const runtimeRequire = createRequire(join(runtime, "package.json"));
23
23
  for (const dependency of ["@modelcontextprotocol/sdk/server/mcp.js", "jpeg-js", "three", "ws", "zod"]) runtimeRequire.resolve(dependency);
24
24
  return server;
@@ -42,20 +42,10 @@ function installMcpRuntime() {
42
42
  copyFileSync(join(MCP_RUNTIME_SOURCE, "package.json"), join(staging, "package.json"));
43
43
  copyFileSync(join(MCP_RUNTIME_SOURCE, "package-lock.json"), join(staging, "package-lock.json"));
44
44
  cpSync(join(PKG_ROOT, "mcp"), join(staging, "mcp"), { recursive: true });
45
- mkdirSync(join(staging, "bin", "agent"), { recursive: true });
46
- copyFileSync(join(PKG_ROOT, "bin", "agent", "motion-runtime.mjs"), join(staging, "bin", "agent", "motion-runtime.mjs"));
45
+ mkdirSync(join(staging, "bin"), { recursive: true });
47
46
  // The server publishes its live endpoint file from this module.
48
47
  copyFileSync(join(PKG_ROOT, "bin", "live-endpoint.mjs"), join(staging, "bin", "live-endpoint.mjs"));
49
48
  cpSync(join(PKG_ROOT, "src"), join(staging, "src"), { recursive: true });
50
- // The motion bridge imports three, which only this runtime resolves, so the
51
- // package launches it from here; its out/ scratch dirs are never copied.
52
- for (const dir of ["ardy", "kimodo", "projflow"]) {
53
- cpSync(join(PKG_ROOT, "tools", dir), join(staging, "tools", dir), { recursive: true, filter: (path) => basename(path) !== "out" });
54
- }
55
- copyFileSync(join(PKG_ROOT, "tools", "process-supervisor.mjs"), join(staging, "tools", "process-supervisor.mjs"));
56
- // gvhmr-floor.mjs loads its FBX rigs from ../../{public,dist}/models.
57
- const models = join(PKG_ROOT, "dist", "models");
58
- if (existsSync(models)) cpSync(models, join(staging, "dist", "models"), { recursive: true });
59
49
 
60
50
  const npm = process.platform === "win32" ? "npm.cmd" : "npm";
61
51
  const child = spawn(npm, ["ci", "--no-audit", "--no-fund"], {
@@ -13,7 +13,6 @@ const CONTENT_ROOTS = [
13
13
  "mcp/server.mjs",
14
14
  "mcp/tool-handlers.mjs",
15
15
  "mcp/live-hub.mjs",
16
- "mcp/ardy-prompts.mjs",
17
16
  "mcp/package.json",
18
17
  "mcp/README.md",
19
18
  "mcp/LIVE-PROTOCOL.md",
@@ -29,9 +28,6 @@ const CONTENT_ROOTS = [
29
28
  function ignored(relativePath) {
30
29
  return relativePath === "dist/cozyclay-package.json"
31
30
  || (/^dist\/media\/[^/]+\.mp4$/i.test(relativePath))
32
- || relativePath === "dist/demo/index.html"
33
- || relativePath === "dist/d/index.html"
34
- || relativePath.startsWith("tools/ardy/out/")
35
31
  || /^tools\/qa-[^/]+\.mjs$/i.test(relativePath);
36
32
  }
37
33
 
@@ -34,13 +34,14 @@
34
34
  <title>CozyClay Studio — 3D staging and previs in your browser</title>
35
35
 
36
36
  <script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "6a4384d1375d4ffc8a30a6346a8ad1a0"}'></script>
37
- <script type="module" crossorigin src="/assets/app-DAuvKPP8.js"></script>
37
+ <script type="module" crossorigin src="/assets/app-DfTCxaKk.js"></script>
38
38
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
39
- <link rel="modulepreload" crossorigin href="/assets/analytics-C9pMpW7s.js">
40
- <link rel="modulepreload" crossorigin href="/assets/first-shot-handoff-msLI71g1.js">
41
- <link rel="modulepreload" crossorigin href="/assets/scene-asset-sync-DKkpjKBV.js">
42
- <link rel="stylesheet" crossorigin href="/assets/scene-asset-sync-DjJ_cJ2R.css">
43
- <link rel="stylesheet" crossorigin href="/assets/app-B_2XB9rw.css">
39
+ <link rel="modulepreload" crossorigin href="/assets/analytics-BWCqdgWA.js">
40
+ <link rel="modulepreload" crossorigin href="/assets/first-shot-handoff-DNO8kv_N.js">
41
+ <link rel="modulepreload" crossorigin href="/assets/fflate.module-KbGj5-H6.js">
42
+ <link rel="modulepreload" crossorigin href="/assets/scene-asset-sync-U3kS2rvK.js">
43
+ <link rel="stylesheet" crossorigin href="/assets/scene-asset-sync-_S8NQl5B.css">
44
+ <link rel="stylesheet" crossorigin href="/assets/app-f-fkV5uP.css">
44
45
  </head>
45
46
  <body>
46
47
  <div id="root">
@@ -0,0 +1 @@
1
+ import{$r as e,Ni as t,Rn as n,Wn as r,Xt as i,ht as a,mt as o,t as s,zi as c,zt as l}from"./fflate.module-KbGj5-H6.js";var u=class extends o{constructor(t){super(t),this.type=i,this.outputFormat=e,this.part=0}parse(o){let u=65536,d=8192,f=65537,p=16384,m=16383,h=65535,g=2.7182818**2.2,_=null;function v(e,t){let n=0;for(let r=0;r<u;++r)(r==0||e[r>>3]&1<<(r&7))&&(t[n++]=r);let r=n-1;for(;n<u;)t[n++]=0;return r}function y(e){for(let t=0;t<p;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}let b={l:0,c:0,lc:0};function x(e,t,n,r,i){for(;n<e;)t=t<<8|xe(r,i),n+=8;n-=e,b.l=t>>n&(1<<e)-1,b.c=t,b.lc=n}let S=Array(59);function C(e){for(let e=0;e<=58;++e)S[e]=0;for(let t=0;t<f;++t)S[e[t]]+=1;let t=0;for(let e=58;e>0;--e){let n=t+S[e]>>1;S[e]=t,t=n}for(let t=0;t<f;++t){let n=e[t];n>0&&(e[t]=n|S[n]++<<6)}}function ee(e,t,n,r,i,a){let o=t,s=0,c=0;for(;r<=i;r++){if(o.value-t.value>n)return!1;x(6,s,c,e,o);let l=b.l;if(s=b.c,c=b.lc,a[r]=l,l==63){if(o.value-t.value>n)throw Error(`THREE.EXRLoader: Something wrong with hufUnpackEncTable`);x(8,s,c,e,o);let l=b.l+6;if(s=b.c,c=b.lc,r+l>i+1)throw Error(`THREE.EXRLoader: Something wrong with hufUnpackEncTable`);for(;l--;)a[r++]=0;r--}else if(l>=59){let e=l-59+2;if(r+e>i+1)throw Error(`THREE.EXRLoader: Something wrong with hufUnpackEncTable`);for(;e--;)a[r++]=0;r--}}C(a)}function w(e){return e&63}function te(e){return e>>6}function ne(e,t,n,r){for(;t<=n;t++){let n=te(e[t]),i=w(e[t]);if(n>>i)throw Error(`THREE.EXRLoader: Invalid table entry`);if(i>14){let e=r[n>>i-14];if(e.len)throw Error(`THREE.EXRLoader: Invalid table entry`);if(e.lit++,e.p){let t=e.p;e.p=Array(e.lit);for(let n=0;n<e.lit-1;++n)e.p[n]=t[n]}else e.p=[,];e.p[e.lit-1]=t}else if(i){let e=0;for(let a=1<<14-i;a>0;a--){let a=r[(n<<14-i)+e];if(a.len||a.p)throw Error(`THREE.EXRLoader: Invalid table entry`);a.len=i,a.lit=t,e++}}}return!0}let T={c:0,lc:0};function E(e,t,n,r){e=e<<8|xe(n,r),t+=8,T.c=e,T.lc=t}let D={c:0,lc:0};function O(e,t,n,r,i,a,o,s,c){if(e==t){r<8&&(E(n,r,i,a),n=T.c,r=T.lc),r-=8;let e=n>>r;if(e=new Uint8Array([e])[0],s.value+e>c)return!1;let t=o[s.value-1];for(;e-->0;)o[s.value++]=t}else if(s.value<c)o[s.value++]=e;else return!1;D.c=n,D.lc=r}function k(e){return e&65535}function re(e){let t=k(e);return t>32767?t-65536:t}let A={a:0,b:0};function j(e,t){let n=re(e),r=re(t),i=n+(r&1)+(r>>1),a=i,o=i-r;A.a=a,A.b=o}function M(e,t){let n=k(e),r=k(t),i=n-(r>>1)&h,a=r+i-32768&h;A.a=a,A.b=i}function ie(e,t,n,r,i,a,o){let s=o<16384,c=n>i?i:n,l=1,u,d;for(;l<=c;)l<<=1;for(l>>=1,u=l,l>>=1;l>=1;){d=0;let o=d+a*(i-u),c=a*l,f=a*u,p=r*l,m=r*u,h,g,_,v;for(;d<=o;d+=f){let i=d,a=d+r*(n-u);for(;i<=a;i+=m){let n=i+p,r=i+c,a=r+p;s?(j(e[i+t],e[r+t]),h=A.a,_=A.b,j(e[n+t],e[a+t]),g=A.a,v=A.b,j(h,g),e[i+t]=A.a,e[n+t]=A.b,j(_,v),e[r+t]=A.a,e[a+t]=A.b):(M(e[i+t],e[r+t]),h=A.a,_=A.b,M(e[n+t],e[a+t]),g=A.a,v=A.b,M(h,g),e[i+t]=A.a,e[n+t]=A.b,M(_,v),e[r+t]=A.a,e[a+t]=A.b)}if(n&l){let n=i+c;s?j(e[i+t],e[n+t]):M(e[i+t],e[n+t]),h=A.a,e[n+t]=A.b,e[i+t]=h}}if(i&l){let i=d,a=d+r*(n-u);for(;i<=a;i+=m){let n=i+p;s?j(e[i+t],e[n+t]):M(e[i+t],e[n+t]),h=A.a,e[n+t]=A.b,e[i+t]=h}}u=l,l>>=1}return d}function ae(e,t,n,r,i,a,o,s,c){let l=0,u=0,d=o,f=Math.trunc(r.value+(i+7)/8);for(;r.value<f;)for(E(l,u,n,r),l=T.c,u=T.lc;u>=14;){let i=t[l>>u-14&m];if(i.len)u-=i.len,O(i.lit,a,l,u,n,r,s,c,d),l=D.c,u=D.lc;else{if(!i.p)throw Error(`THREE.EXRLoader: hufDecode issues`);let t;for(t=0;t<i.lit;t++){let o=w(e[i.p[t]]);for(;u<o&&r.value<f;)E(l,u,n,r),l=T.c,u=T.lc;if(u>=o&&te(e[i.p[t]])==(l>>u-o&(1<<o)-1)){u-=o,O(i.p[t],a,l,u,n,r,s,c,d),l=D.c,u=D.lc;break}}if(t==i.lit)throw Error(`THREE.EXRLoader: hufDecode issues`)}}let p=8-i&7;for(l>>=p,u-=p;u>0;){let e=t[l<<14-u&m];if(e.len)u-=e.len,O(e.lit,a,l,u,n,r,s,c,d),l=D.c,u=D.lc;else throw Error(`THREE.EXRLoader: hufDecode issues`)}return!0}function N(e,t,n,r,i,a){let o={value:0},s=n.value,c=U(t,n),l=U(t,n);n.value+=4;let u=U(t,n);if(n.value+=4,c<0||c>=f||l<0||l>=f)throw Error(`THREE.EXRLoader: Something wrong with HUF_ENCSIZE`);let d=Array(f),m=Array(p);if(y(m),ee(e,n,r-(n.value-s),c,l,d),u>8*(r-(n.value-s)))throw Error(`THREE.EXRLoader: Something wrong with hufUncompress`);ne(d,c,l,m),ae(d,m,e,n,u,l,a,i,o)}function oe(e,t,n){for(let r=0;r<n;++r)t[r]=e[t[r]]}function P(e){for(let t=1;t<e.length;t++){let n=e[t-1]+e[t]-128;e[t]=n}}function F(e,t){let n=0,r=Math.floor((e.length+1)/2),i=0,a=e.length-1;for(;!(i>a||(t[i++]=e[n++],i>a));)t[i++]=e[r++]}function I(e){let t=e.byteLength,n=[],r=0,i=new DataView(e);for(;t>0;){let e=i.getInt8(r++);if(e<0){let a=-e;t-=a+1;for(let e=0;e<a;e++)n.push(i.getUint8(r++))}else{let a=e;t-=2;let o=i.getUint8(r++);for(let e=0;e<a+1;e++)n.push(o)}}return n}function se(e,t,n,r,i,a){let o=new DataView(a.buffer),s=n[e.idx[0]].width,c=n[e.idx[0]].height,l=Math.floor(s/8),u=Math.ceil(s/8),d=Math.ceil(c/8),f=s-(u-1)*8,p=c-(d-1)*8,m={value:0},h=[,,,],g=[,,,],_=[,,,],v=[,,,],y=[,,,];for(let n=0;n<3;++n)y[n]=t[e.idx[n]],h[n]=n<1?0:h[n-1]+u*d,g[n]=new Float32Array(64),_[n]=new Uint16Array(64),v[n]=new Uint16Array(u*64);for(let t=0;t<d;++t){let a=8;t==d-1&&(a=p);let s=8;for(let e=0;e<u;++e){e==u-1&&(s=f);for(let e=0;e<3;++e)_[e].fill(0),_[e][0]=i[h[e]++],le(m,r,_[e]),ue(_[e],g[e]),L(g[e]);de(g);for(let t=0;t<3;++t)fe(g[t],v[t],e*64)}let c=0;for(let r=0;r<3;++r){let i=n[e.idx[r]].type;for(let e=8*t;e<8*t+a;++e){c=y[r][e];for(let t=0;t<l;++t){let n=t*64+(e&7)*8;o.setUint16(c+0*i,v[r][n+0],!0),o.setUint16(c+2*i,v[r][n+1],!0),o.setUint16(c+4*i,v[r][n+2],!0),o.setUint16(c+6*i,v[r][n+3],!0),o.setUint16(c+8*i,v[r][n+4],!0),o.setUint16(c+10*i,v[r][n+5],!0),o.setUint16(c+12*i,v[r][n+6],!0),o.setUint16(c+14*i,v[r][n+7],!0),c+=16*i}}if(l!=u)for(let e=8*t;e<8*t+a;++e){let t=y[r][e]+8*l*2*i,n=l*64+(e&7)*8;for(let e=0;e<s;++e)o.setUint16(t+e*2*i,v[r][n+e],!0)}}}let b=new Uint16Array(s);o=new DataView(a.buffer);for(let t=0;t<3;++t){n[e.idx[t]].decoded=!0;let r=n[e.idx[t]].type;if(n[t].type==2)for(let e=0;e<c;++e){let n=y[t][e];for(let e=0;e<s;++e)b[e]=o.getUint16(n+e*2*r,!0);for(let e=0;e<s;++e)o.setFloat32(n+e*2*r,q(b[e]),!0)}}}function ce(e,t,n,r,i,a){let o=new DataView(a.buffer),s=n[e],c=s.width,l=s.height,u=Math.ceil(c/8),d=Math.ceil(l/8),f=Math.floor(c/8),p=c-(u-1)*8,m=l-(d-1)*8,h={value:0},g=0,_=new Float32Array(64),v=new Uint16Array(64),y=new Uint16Array(u*64);for(let n=0;n<d;++n){let a=8;n==d-1&&(a=m);for(let e=0;e<u;++e)v.fill(0),v[0]=i[g++],le(h,r,v),ue(v,_),L(_),fe(_,y,e*64);for(let r=8*n;r<8*n+a;++r){let n=t[e][r];for(let e=0;e<f;++e){let t=e*64+(r&7)*8;for(let e=0;e<8;++e)o.setUint16(n+e*2*s.type,y[t+e],!0);n+=16*s.type}if(u!=f){let e=f*64+(r&7)*8;for(let t=0;t<p;++t)o.setUint16(n+t*2*s.type,y[e+t],!0)}}}s.decoded=!0}function le(e,t,n){let r,i=1;for(;i<64;)r=t[e.value],r==65280?i=64:r>>8==255?i+=r&255:(n[i]=r,i++),e.value++}function ue(e,t){t[0]=q(e[0]),t[1]=q(e[1]),t[2]=q(e[5]),t[3]=q(e[6]),t[4]=q(e[14]),t[5]=q(e[15]),t[6]=q(e[27]),t[7]=q(e[28]),t[8]=q(e[2]),t[9]=q(e[4]),t[10]=q(e[7]),t[11]=q(e[13]),t[12]=q(e[16]),t[13]=q(e[26]),t[14]=q(e[29]),t[15]=q(e[42]),t[16]=q(e[3]),t[17]=q(e[8]),t[18]=q(e[12]),t[19]=q(e[17]),t[20]=q(e[25]),t[21]=q(e[30]),t[22]=q(e[41]),t[23]=q(e[43]),t[24]=q(e[9]),t[25]=q(e[11]),t[26]=q(e[18]),t[27]=q(e[24]),t[28]=q(e[31]),t[29]=q(e[40]),t[30]=q(e[44]),t[31]=q(e[53]),t[32]=q(e[10]),t[33]=q(e[19]),t[34]=q(e[23]),t[35]=q(e[32]),t[36]=q(e[39]),t[37]=q(e[45]),t[38]=q(e[52]),t[39]=q(e[54]),t[40]=q(e[20]),t[41]=q(e[22]),t[42]=q(e[33]),t[43]=q(e[38]),t[44]=q(e[46]),t[45]=q(e[51]),t[46]=q(e[55]),t[47]=q(e[60]),t[48]=q(e[21]),t[49]=q(e[34]),t[50]=q(e[37]),t[51]=q(e[47]),t[52]=q(e[50]),t[53]=q(e[56]),t[54]=q(e[59]),t[55]=q(e[61]),t[56]=q(e[35]),t[57]=q(e[36]),t[58]=q(e[48]),t[59]=q(e[49]),t[60]=q(e[57]),t[61]=q(e[58]),t[62]=q(e[62]),t[63]=q(e[63])}function L(e){let t=.5*Math.cos(3.14159/4),n=.5*Math.cos(3.14159/16),r=.5*Math.cos(3.14159/8),i=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(15.70795/16),o=.5*Math.cos(3*3.14159/8),s=.5*Math.cos(21.99113/16),c=[,,,,],l=[,,,,],u=[,,,,],d=[,,,,];for(let f=0;f<8;++f){let p=f*8;c[0]=r*e[p+2],c[1]=o*e[p+2],c[2]=r*e[p+6],c[3]=o*e[p+6],l[0]=n*e[p+1]+i*e[p+3]+a*e[p+5]+s*e[p+7],l[1]=i*e[p+1]-s*e[p+3]-n*e[p+5]-a*e[p+7],l[2]=a*e[p+1]-n*e[p+3]+s*e[p+5]+i*e[p+7],l[3]=s*e[p+1]-a*e[p+3]+i*e[p+5]-n*e[p+7],u[0]=t*(e[p+0]+e[p+4]),u[3]=t*(e[p+0]-e[p+4]),u[1]=c[0]+c[3],u[2]=c[1]-c[2],d[0]=u[0]+u[1],d[1]=u[3]+u[2],d[2]=u[3]-u[2],d[3]=u[0]-u[1],e[p+0]=d[0]+l[0],e[p+1]=d[1]+l[1],e[p+2]=d[2]+l[2],e[p+3]=d[3]+l[3],e[p+4]=d[3]-l[3],e[p+5]=d[2]-l[2],e[p+6]=d[1]-l[1],e[p+7]=d[0]-l[0]}for(let f=0;f<8;++f)c[0]=r*e[16+f],c[1]=o*e[16+f],c[2]=r*e[48+f],c[3]=o*e[48+f],l[0]=n*e[8+f]+i*e[24+f]+a*e[40+f]+s*e[56+f],l[1]=i*e[8+f]-s*e[24+f]-n*e[40+f]-a*e[56+f],l[2]=a*e[8+f]-n*e[24+f]+s*e[40+f]+i*e[56+f],l[3]=s*e[8+f]-a*e[24+f]+i*e[40+f]-n*e[56+f],u[0]=t*(e[f]+e[32+f]),u[3]=t*(e[f]-e[32+f]),u[1]=c[0]+c[3],u[2]=c[1]-c[2],d[0]=u[0]+u[1],d[1]=u[3]+u[2],d[2]=u[3]-u[2],d[3]=u[0]-u[1],e[0+f]=d[0]+l[0],e[8+f]=d[1]+l[1],e[16+f]=d[2]+l[2],e[24+f]=d[3]+l[3],e[32+f]=d[3]-l[3],e[40+f]=d[2]-l[2],e[48+f]=d[1]-l[1],e[56+f]=d[0]-l[0]}function de(e){for(let t=0;t<64;++t){let n=e[0][t],r=e[1][t],i=e[2][t];e[0][t]=n+1.5747*i,e[1][t]=n-.1873*r-.4682*i,e[2][t]=n+1.8556*r}}function fe(e,t,n){for(let r=0;r<64;++r)t[n+r]=a.toHalfFloat(pe(e[r]))}function pe(e){return e<=1?Math.sign(e)*Math.abs(e)**2.2:Math.sign(e)*g**(Math.abs(e)-1)}function R(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function me(e){let t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(I(t)),r=new Uint8Array(n.length);return P(n),F(n,r),new DataView(r.buffer)}function z(e){let t=e.array.slice(e.offset.value,e.offset.value+e.size),n=s(t),r=new Uint8Array(n.length);return P(n),F(n,r),new DataView(r.buffer)}function he(e){let t=e.viewer,n={value:e.offset.value},r=new Uint16Array(e.columns*e.lines*(e.inputChannels.length*e.type)),i=new Uint8Array(d),a=0,o=Array(e.inputChannels.length);for(let t=0,n=e.inputChannels.length;t<n;t++)o[t]={},o[t].start=a,o[t].end=o[t].start,o[t].nx=e.columns,o[t].ny=e.lines,o[t].size=e.type,a+=o[t].nx*o[t].ny*o[t].size;let s=J(t,n),c=J(t,n);if(c>=d)throw Error(`THREE.EXRLoader: Something is wrong with PIZ_COMPRESSION BITMAP_SIZE`);if(s<=c)for(let e=0;e<c-s+1;e++)i[e+s]=W(t,n);let l=new Uint16Array(u),f=v(i,l),p=U(t,n);N(e.array,t,n,p,r,a);for(let t=0;t<e.inputChannels.length;++t){let e=o[t];for(let n=0;n<o[t].size;++n)ie(r,e.start+n,e.nx,e.size,e.ny,e.nx*e.size,f)}oe(l,r,a);let m=0,h=new Uint8Array(r.buffer.byteLength);for(let t=0;t<e.lines;t++)for(let t=0;t<e.inputChannels.length;t++){let e=o[t],n=e.nx*e.size,i=new Uint8Array(r.buffer,e.end*2,n*2);h.set(i,m),m+=n*2,e.end+=n}return new DataView(h.buffer)}function ge(e){let t=e.array.slice(e.offset.value,e.offset.value+e.size),n=s(t),r=e.inputChannels.length*e.lines*e.columns*e.totalBytes,i=new ArrayBuffer(r),a=new DataView(i),o=0,c=0,l=[,,,,];for(let t=0;t<e.lines;t++)for(let t=0;t<e.inputChannels.length;t++){let r=0;switch(e.inputChannels[t].pixelType){case 1:l[0]=o,l[1]=l[0]+e.columns,o=l[1]+e.columns;for(let t=0;t<e.columns;++t){let e=n[l[0]++]<<8|n[l[1]++];r+=e,a.setUint16(c,r,!0),c+=2}break;case 2:l[0]=o,l[1]=l[0]+e.columns,l[2]=l[1]+e.columns,o=l[2]+e.columns;for(let t=0;t<e.columns;++t){let e=n[l[0]++]<<24|n[l[1]++]<<16|n[l[2]++]<<8;r+=e,a.setUint32(c,r,!0),c+=4}}}return a}function _e(e){let t=e.array,n=e.offset.value,r=e.columns,i=e.lines,o=e.inputChannels,s=e.totalBytes,c=Q.compression===`B44A_COMPRESSION`,l=new Uint8Array(i*r*s),u=new Uint16Array(16),d=0;for(let e=0;e<o.length;e++){let f=o[e],p=f.pixelType*2,m=Math.ceil(r/f.xSampling),h=Math.ceil(i/f.ySampling),g=f.xSampling===1&&f.ySampling===1;if(f.pixelType!==1){for(let e=0;e<h;e++)if(g){let i=e*r*s+d*r;for(let e=0;e<m*p;e++)l[i+e]=t[n++]}else n+=m*p;d+=p;continue}let v=Math.ceil(m/4),y=Math.ceil(h/4);for(let e=0;e<y;e++)for(let o=0;o<v;o++){if(c&&t[n+2]>=52){let e=t[n]<<8|t[n+1],r=e&32768?e&32767:~e&65535;u.fill(r),n+=3}else{let e=t[n]<<8|t[n+1],r=t[n+2]>>2,i=32<<r,a=e+((t[n+2]<<4|t[n+3]>>4)&63)*(1<<r)-i&65535,o=a+((t[n+3]<<2|t[n+4]>>6)&63)*(1<<r)-i&65535,s=o+(t[n+4]&63)*(1<<r)-i&65535,c=e+(t[n+5]>>2&63)*(1<<r)-i&65535,l=a+((t[n+5]<<4|t[n+6]>>4)&63)*(1<<r)-i&65535,d=o+((t[n+6]<<2|t[n+7]>>6)&63)*(1<<r)-i&65535,f=s+(t[n+7]&63)*(1<<r)-i&65535,p=c+(t[n+8]>>2&63)*(1<<r)-i&65535,m=l+((t[n+8]<<4|t[n+9]>>4)&63)*(1<<r)-i&65535,h=d+((t[n+9]<<2|t[n+10]>>6)&63)*(1<<r)-i&65535,g=f+(t[n+10]&63)*(1<<r)-i&65535,_=[e,c,p,p+(t[n+11]>>2&63)*(1<<r)-i&65535,a,l,m,m+((t[n+11]<<4|t[n+12]>>4)&63)*(1<<r)-i&65535,o,d,h,h+((t[n+12]<<2|t[n+13]>>6)&63)*(1<<r)-i&65535,s,f,g,g+(t[n+13]&63)*(1<<r)-i&65535];for(let e=0;e<16;e++)u[e]=_[e]&32768?_[e]&32767:~_[e]&65535;n+=14}if(f.pLinear){if(_===null){_=new Uint16Array(65536);for(let e=0;e<65536;e++)if((e&31744)==31744||e>32768)_[e]=0;else{let t=q(e);_[e]=t<=0?0:a.toHalfFloat(8*Math.log(t))}}for(let e=0;e<16;e++)u[e]=_[u[e]]}for(let t=0;t<4;t++){let n=e*4+t;if(!(n>=h))for(let e=0;e<4;e++){let a=o*4+e;if(a>=m)continue;let c=u[t*4+e];for(let e=0;e<f.ySampling;e++){let t=n*f.ySampling+e;if(!(t>=i))for(let e=0;e<f.xSampling;e++){let n=a*f.xSampling+e;if(n>=r)continue;let i=t*r*s+d*r+n*2;l[i]=c&255,l[i+1]=c>>8&255}}}}}d+=2}return new DataView(l.buffer)}function B(e){let t=e.viewer,n={value:e.offset.value},r=new Uint8Array(e.columns*e.lines*(e.inputChannels.length*e.type*2)),i={version:G(t,n),unknownUncompressedSize:G(t,n),unknownCompressedSize:G(t,n),acCompressedSize:G(t,n),dcCompressedSize:G(t,n),rleCompressedSize:G(t,n),rleUncompressedSize:G(t,n),rleRawSize:G(t,n),totalAcUncompressedCount:G(t,n),totalDcUncompressedCount:G(t,n),acCompression:G(t,n)};if(i.version<2)throw Error(`THREE.EXRLoader: `+Q.compression+` version `+i.version+` is unsupported`);let a=[],o=J(t,n)-2;for(;o>0;){let e=V(t.buffer,n),r=W(t,n),i=r>>2&3,s=(r>>4)-1,c=new Int8Array([s])[0],l=W(t,n);a.push({name:e,index:c,type:l,compression:i}),o-=e.length+3}let c=Q.channels,l=Array(e.inputChannels.length);for(let t=0;t<e.inputChannels.length;++t){let n=l[t]={},r=c[t];n.name=r.name,n.compression=0,n.decoded=!1,n.type=r.pixelType,n.pLinear=r.pLinear,n.width=e.columns,n.height=e.lines}let u={idx:[,,,]};for(let t=0;t<e.inputChannels.length;++t){let e=l[t],n=e.name.lastIndexOf(`.`),r=n>=0?e.name.substring(n+1):e.name;for(let n=0;n<a.length;++n){let i=a[n];r===i.name&&e.type===i.type&&(e.compression=i.compression,i.index>=0&&(u.idx[i.index]=t),e.offset=t)}}let d,f,p;if(i.acCompressedSize>0)switch(i.acCompression){case 0:d=new Uint16Array(i.totalAcUncompressedCount),N(e.array,t,n,i.acCompressedSize,d,i.totalAcUncompressedCount);break;case 1:let r=e.array.slice(n.value,n.value+i.totalAcUncompressedCount),a=s(r);d=new Uint16Array(a.buffer),n.value+=i.totalAcUncompressedCount}if(i.dcCompressedSize>0){let t={array:e.array,offset:n,size:i.dcCompressedSize};f=new Uint16Array(z(t).buffer),n.value+=i.dcCompressedSize}if(i.rleRawSize>0){let t=e.array.slice(n.value,n.value+i.rleCompressedSize);p=I(s(t).buffer),n.value+=i.rleCompressedSize}let m=0,h=Array(l.length);for(let e=0;e<h.length;++e)h[e]=[];for(let t=0;t<e.lines;++t)for(let t=0;t<l.length;++t)h[t].push(m),m+=l[t].width*e.type*2;u.idx[0]!==void 0&&l[u.idx[0]]&&se(u,h,l,d,f,r);for(let t=0;t<l.length;++t){let n=l[t];if(!n.decoded)switch(n.compression){case 2:let i=0,a=0;for(let o=0;o<e.lines;++o){let e=h[t][i];for(let t=0;t<n.width;++t){for(let t=0;t<2*n.type;++t)r[e++]=p[a+t*n.width*n.height];a++}i++}break;case 1:ce(t,h,l,d,f,r);break;default:throw Error(`THREE.EXRLoader: unsupported channel compression`)}}return new DataView(r.buffer)}function V(e,t){let n=new Uint8Array(e),r=0;for(;n[t.value+r]!=0;)r+=1;let i=new TextDecoder().decode(n.slice(t.value,t.value+r));return t.value=t.value+r+1,i}function ve(e,t,n){let r=new TextDecoder().decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value+=n,r}function ye(e,t){return[H(e,t),U(e,t)]}function be(e,t){return[U(e,t),U(e,t)]}function H(e,t){let n=e.getInt32(t.value,!0);return t.value+=4,n}function U(e,t){let n=e.getUint32(t.value,!0);return t.value+=4,n}function xe(e,t){let n=e[t.value];return t.value+=1,n}function W(e,t){let n=e.getUint8(t.value);return t.value+=1,n}let G=function(e,t){let n=Number(e.getBigInt64(t.value,!0));return t.value+=8,n};function K(e,t){let n=e.getFloat32(t.value,!0);return t.value+=4,n}function Se(e,t){return a.toHalfFloat(K(e,t))}function q(e){let t=(e&31744)>>10,n=e&1023;return(e>>15?-1:1)*(t?t===31?n?NaN:1/0:2**(t-15)*(1+n/1024):n/1024*6103515625e-14)}function J(e,t){let n=e.getUint16(t.value,!0);return t.value+=2,n}function Ce(e,t){return q(J(e,t))}function we(e,t,n,r){let i=n.value,a=[];for(;n.value<i+r-1;){let r=V(t,n),i=H(e,n),o=W(e,n);n.value+=3;let s=H(e,n),c=H(e,n);a.push({name:r,pixelType:i,pLinear:o,xSampling:s,ySampling:c})}return n.value+=1,a}function Te(e,t){return{redX:K(e,t),redY:K(e,t),greenX:K(e,t),greenY:K(e,t),blueX:K(e,t),blueY:K(e,t),whiteX:K(e,t),whiteY:K(e,t)}}function Ee(e,t){return[`NO_COMPRESSION`,`RLE_COMPRESSION`,`ZIPS_COMPRESSION`,`ZIP_COMPRESSION`,`PIZ_COMPRESSION`,`PXR24_COMPRESSION`,`B44_COMPRESSION`,`B44A_COMPRESSION`,`DWAA_COMPRESSION`,`DWAB_COMPRESSION`][W(e,t)]}function De(e,t){return{xMin:H(e,t),yMin:H(e,t),xMax:H(e,t),yMax:H(e,t)}}function Oe(e,t){return[`INCREASING_Y`,`DECREASING_Y`,`RANDOM_Y`][W(e,t)]}function ke(e,t){return[`ENVMAP_LATLONG`,`ENVMAP_CUBE`][W(e,t)]}function Ae(e,t){let n=[`ONE_LEVEL`,`MIPMAP_LEVELS`,`RIPMAP_LEVELS`],r=[`ROUND_DOWN`,`ROUND_UP`],i=U(e,t),a=U(e,t),o=W(e,t);return{xSize:i,ySize:a,levelMode:n[o&15],roundingMode:r[o>>4]}}function je(e,t){return[K(e,t),K(e,t)]}function Me(e,t){return[K(e,t),K(e,t),K(e,t)]}function Ne(e,t,n,r,i){if(r===`string`||r===`stringvector`||r===`iccProfile`)return ve(t,n,i);if(r===`chlist`)return we(e,t,n,i);if(r===`chromaticities`)return Te(e,n);if(r===`compression`)return Ee(e,n);if(r===`box2i`)return De(e,n);if(r===`envmap`)return ke(e,n);if(r===`tiledesc`)return Ae(e,n);if(r===`lineOrder`)return Oe(e,n);if(r===`float`)return K(e,n);if(r===`v2f`)return je(e,n);if(r===`v3f`)return Me(e,n);if(r===`int`)return H(e,n);if(r===`rational`)return ye(e,n);if(r===`timecode`)return be(e,n);if(r===`preview`||r===`deepImageState`||r===`idmanifest`)return n.value+=i,`skipped`;n.value+=i}function Pe(e,t){let n=Math.log2(e);return t==`ROUND_DOWN`?Math.floor(n):Math.ceil(n)}function Fe(e,t,n){let r=0;switch(e.levelMode){case`ONE_LEVEL`:r=1;break;case`MIPMAP_LEVELS`:r=Pe(Math.max(t,n),e.roundingMode)+1;break;case`RIPMAP_LEVELS`:throw Error(`THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.`)}return r}function Ie(e,t,n,r){let i=Array(e);for(let a=0;a<e;a++){let e=1<<a,o=t/e|0;r==`ROUND_UP`&&o*e<t&&(o+=1),i[a]=(Math.max(o,1)+n-1)/n|0}return i}function Le(){let e=this,t=e.offset,n={value:0};for(let r=0;r<e.tileCount;r++){let r=H(e.viewer,t),i=H(e.viewer,t);t.value+=8,e.size=U(e.viewer,t);let a=r*e.blockWidth,o=i*e.blockHeight;e.columns=a+e.blockWidth>e.width?e.width-a:e.blockWidth,e.lines=o+e.blockHeight>e.height?e.height-o:e.blockHeight;let s=e.columns*e.totalBytes,c=e.size<e.lines*s?e.uncompress(e):R(e);t.value+=e.size;for(let t=0;t<e.lines;t++){let r=t*e.columns*e.totalBytes;for(let i=0;i<e.inputChannels.length;i++){let s=Q.channels[i].name,l=e.channelByteOffsets[s]*e.columns,u=e.decodeChannels[s];if(u===void 0)continue;n.value=r+l;let d=(e.height-(1+o+t))*e.outLineWidth;for(let t=0;t<e.columns;t++){let r=d+(t+a)*e.outputChannels+u;e.byteArray[r]=e.getter(c,n)}}}}}function Re(){let e=this,t=e.offset,n={value:0};for(let r=0;r<e.height/e.blockHeight;r++){let r=H(e.viewer,t)-Q.dataWindow.yMin;e.size=U(e.viewer,t),e.lines=r+e.blockHeight>e.height?e.height-r:e.blockHeight;let i=e.columns*e.totalBytes,a=e.size<e.lines*i?e.uncompress(e):R(e);t.value+=e.size;for(let t=0;t<e.lines;t++){let o=r+t,s=t*i,c=(e.height-1-o)*e.outLineWidth;for(let t=0;t<e.inputChannels.length;t++){let r=Q.channels[t].name,i=e.channelByteOffsets[r]*e.columns,o=e.decodeChannels[r];if(o!==void 0){n.value=s+i;for(let t=0;t<e.columns;t++){let r=c+t*e.outputChannels+o;e.byteArray[r]=e.getter(a,n)}}}}}}function ze(){let e=this,t=e.chunkOffsets,n={value:0};for(let r=0;r<t.length;r++){let i={value:t[r]};i.value+=4;let a=H(e.viewer,i)-Q.dataWindow.yMin;e.size=U(e.viewer,i),e.lines=a+e.blockHeight>e.height?e.height-a:e.blockHeight;let o=e.columns*e.totalBytes,s=e.size<e.lines*o,c=e.offset;e.offset=i;let l=s?e.uncompress(e):R(e);e.offset=c;for(let t=0;t<e.lines;t++){let r=a+t,i=t*o,s=(e.height-1-r)*e.outLineWidth;for(let t=0;t<e.inputChannels.length;t++){let r=Q.channels[t].name,a=e.channelByteOffsets[r]*e.columns,o=e.decodeChannels[r];if(o!==void 0){n.value=i+a;for(let t=0;t<e.columns;t++){let r=s+t*e.outputChannels+o;e.byteArray[r]=e.getter(l,n)}}}}}}function Be(e,t,n,r){if(n===0)return null;let i=e.slice(t,t+n);switch(r){case`NO_COMPRESSION`:return new DataView(i.buffer,i.byteOffset,i.byteLength);case`RLE_COMPRESSION`:{let e=new Uint8Array(I(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength))),t=new Uint8Array(e.length);return P(e),F(e,t),new DataView(t.buffer)}case`ZIPS_COMPRESSION`:{let e=s(i),t=new Uint8Array(e.length);return P(e),F(e,t),new DataView(t.buffer)}default:throw Error(`THREE.EXRLoader: `+r+` is unsupported for deep data`)}}function Ve(){let e=this,t=e.chunkOffsets,n=e.width,r=e.height,i=e.deepChannels,o=Q.compression,s=e.multiPart,c=e.decodeChannels,l=e.outputChannels,u=e.byteArray instanceof Uint16Array,d=-1;for(let e=0;e<i.length;e++)if(i[e].name===`A`){d=e;break}for(let f=0;f<t.length;f++){let p={value:t[f]};s&&(p.value+=4);let m=H(e.viewer,p)-Q.dataWindow.yMin,h=G(e.viewer,p),g=G(e.viewer,p);G(e.viewer,p);let _=Be(e.array,p.value,h,o);if(p.value+=h,_===null)continue;let v=new Uint32Array(n);for(let e=0;e<n;e++)v[e]=_.getUint32(e*4,!0);let y=v[n-1];if(y===0){p.value+=g;continue}let b=Be(e.array,p.value,g,o),x=[],S=0;for(let e=0;e<i.length;e++)x.push(S),S+=y*i[e].bytesPerSample;let C=(r-1-m)*e.outLineWidth;for(let t=0;t<n;t++){let n=t===0?0:v[t-1],r=v[t]-n;if(r===0)continue;let o=new Float32Array(l),s=0;for(let e=0;e<r;e++){let t=n+e,r=1-s;if(r<=0)break;let a=1;if(d>=0){let e=i[d].bytesPerSample,n=x[d]+t*e;a=e===2?q(b.getUint16(n,!0)):b.getFloat32(n,!0)}for(let e=0;e<i.length;e++){let n=i[e],a=c[n.name];if(a===void 0)continue;let s=n.bytesPerSample,l=x[e]+t*s,u=s===2?q(b.getUint16(l,!0)):b.getFloat32(l,!0);o[a]+=u*r}s+=a*r}c.A!==void 0&&(o[c.A]=s);let f=C+t*l;for(let t=0;t<l;t++)e.byteArray[f+t]=u?a.toHalfFloat(o[t]):o[t]}}}function He(e,t,n){let r={},i=!1;for(;;){let a=V(t,n);if(a===``)break;i=!0;let o=V(t,n),s=Ne(e,t,n,o,U(e,n));s===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type \'${o}\'.`):r[a]=s}return i?r:null}function Ue(e,t,n){if(e.getUint32(0,!0)!=20000630)throw Error(`THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.`);let r=e.getUint8(4),i=e.getUint8(5),a={singleTile:!!(i&2),longName:!!(i&4),deepFormat:!!(i&8),multiPart:!!(i&16)};n.value=8;let o=[];if(a.multiPart){for(;;){let i=He(e,t,n);if(i===null)break;i.version=r,i.spec=a,o.push(i)}if(o.length===0)throw Error(`THREE.EXRLoader: No valid part headers found.`)}else{let i=He(e,t,n);i.version=r,i.spec=a,o.push(i)}return o}function We(n,a,o,s,u,d){let f={size:0,viewer:a,array:o,offset:s,width:n.dataWindow.xMax-n.dataWindow.xMin+1,height:n.dataWindow.yMax-n.dataWindow.yMin+1,inputChannels:n.channels,channelByteOffsets:{},shouldExpand:!1,yCbCr:!1,totalBytes:null,columns:null,lines:null,type:null,uncompress:null,getter:null,format:null,colorSpace:r};switch(n.compression){case`NO_COMPRESSION`:f.blockHeight=1,f.uncompress=R;break;case`RLE_COMPRESSION`:f.blockHeight=1,f.uncompress=me;break;case`ZIPS_COMPRESSION`:f.blockHeight=1,f.uncompress=z;break;case`ZIP_COMPRESSION`:f.blockHeight=16,f.uncompress=z;break;case`PIZ_COMPRESSION`:f.blockHeight=32,f.uncompress=he;break;case`PXR24_COMPRESSION`:f.blockHeight=16,f.uncompress=ge;break;case`B44_COMPRESSION`:case`B44A_COMPRESSION`:f.blockHeight=32,f.uncompress=_e;break;case`DWAA_COMPRESSION`:f.blockHeight=32,f.uncompress=B;break;case`DWAB_COMPRESSION`:f.blockHeight=256,f.uncompress=B;break;default:throw Error(`THREE.EXRLoader: `+n.compression+` is unsupported`)}let p={};for(let e of n.channels)switch(e.name){case`BY`:case`RY`:case`Y`:case`R`:case`G`:case`B`:case`A`:p[e.name]=!0,f.type=e.pixelType}let m=!1,h=!1;if(p.Y&&p.RY&&p.BY)f.outputChannels=4,f.yCbCr=!0;else if(p.R&&p.G&&p.B)f.outputChannels=4;else if(p.Y)f.outputChannels=1;else throw Error(`THREE.EXRLoader: file contains unsupported data channels.`);switch(f.outputChannels){case 4:d==1023?(m=!p.A,f.format=e,f.colorSpace=r,f.outputChannels=4,f.decodeChannels={R:0,G:1,B:2,A:3}):d==1030?(f.format=t,f.colorSpace=r,f.outputChannels=2,f.decodeChannels={R:0,G:1}):d==1028?(f.format=c,f.colorSpace=r,f.outputChannels=1,f.decodeChannels={R:0}):h=!0;break;case 1:d==1023?(m=!0,f.format=e,f.colorSpace=r,f.outputChannels=4,f.shouldExpand=!0,f.decodeChannels={Y:0}):d==1030?(f.format=t,f.colorSpace=r,f.outputChannels=2,f.shouldExpand=!0,f.decodeChannels={Y:0}):d==1028?(f.format=c,f.colorSpace=r,f.outputChannels=1,f.decodeChannels={Y:0}):h=!0;break;default:h=!0}if(h)throw Error(`THREE.EXRLoader: invalid output format for specified file.`);if(f.yCbCr&&(f.format=e,f.outputChannels=4,f.decodeChannels={Y:0,RY:1,BY:2},m=!0),f.type==1)switch(u){case l:f.getter=Ce;break;case i:f.getter=J}else if(f.type==2)switch(u){case l:f.getter=K;break;case i:f.getter=Se}else throw Error(`THREE.EXRLoader: unsupported pixelType `+f.type+` for `+n.compression+`.`);f.columns=f.width;let g=f.width*f.height*f.outputChannels;switch(u){case l:f.byteArray=new Float32Array(g),m&&f.byteArray.fill(1,0,g);break;case i:f.byteArray=new Uint16Array(g),m&&f.byteArray.fill(15360,0,g);break;default:console.error(`THREE.EXRLoader: unsupported type: `,u)}let _=0;for(let e of n.channels)f.decodeChannels[e.name]!==void 0&&(f.channelByteOffsets[e.name]=_),_+=e.pixelType*2;if(f.totalBytes=_,f.outLineWidth=f.width*f.outputChannels,n.spec.deepFormat){f.deepChannels=[];let e=0;for(let t of n.channels){let n=t.pixelType===0?4:t.pixelType*2;f.deepChannels.push({name:t.name,pixelType:t.pixelType,bytesPerSample:n}),e+=n}f.deepBytesPerSample=e,f.chunkOffsets=n._chunkOffsets,f.multiPart=n.spec.multiPart,f.decode=Ve.bind(f)}else if(n.spec.singleTile){f.blockHeight=n.tiles.ySize,f.blockWidth=n.tiles.xSize;let e=Fe(n.tiles,f.width,f.height),t=Ie(e,f.width,n.tiles.xSize,n.tiles.roundingMode),r=Ie(e,f.height,n.tiles.ySize,n.tiles.roundingMode);f.tileCount=t[0]*r[0];for(let n=0;n<e;n++)for(let e=0;e<r[n];e++)for(let e=0;e<t[n];e++)G(a,s);f.decode=Le.bind(f)}else if(n.spec.multiPart)f.blockWidth=f.width,f.chunkOffsets=n._chunkOffsets,f.decode=ze.bind(f);else{f.blockWidth=f.width;let e=Math.ceil(f.height/f.blockHeight);for(let t=0;t<e;t++)G(a,s);f.decode=Re.bind(f)}return f}let Y={value:0},X=new DataView(o),Ge=new Uint8Array(o),Z=Ue(X,o,Y),Ke=Math.max(0,Math.min(this.part,Z.length-1)),Q=Z[Ke];if(Q.spec.multiPart||Q.spec.deepFormat)for(let e=0;e<Z.length;e++){let t=Z[e].chunkCount;if(e===Ke){Q._chunkOffsets=[];for(let e=0;e<t;e++)Q._chunkOffsets.push(G(X,Y))}else for(let e=0;e<t;e++)G(X,Y)}let $=We(Q,X,Ge,Y,this.type,this.outputFormat);if($.decode(),$.shouldExpand){let e=$.byteArray;if(this.outputFormat==1023)for(let t=0;t<e.length;t+=4)e[t+2]=e[t+1]=e[t];else if(this.outputFormat==1030)for(let t=0;t<e.length;t+=2)e[t+1]=e[t]}if($.yCbCr){let e=$.byteArray,t=$.width*$.height;if(this.type===1016)for(let n=0;n<t;n++){let t=n*4,r=q(e[t]),i=q(e[t+1]),o=q(e[t+2]),s=(1+i)*r,c=(1+o)*r,l=(r-s*.2126-c*.0722)/.7152;e[t]=a.toHalfFloat(Math.max(0,s)),e[t+1]=a.toHalfFloat(Math.max(0,l)),e[t+2]=a.toHalfFloat(Math.max(0,c))}else for(let n=0;n<t;n++){let t=n*4,r=e[t],i=e[t+1],a=e[t+2],o=(1+i)*r,s=(1+a)*r;e[t]=Math.max(0,o),e[t+1]=Math.max(0,(r-o*.2126-s*.0722)/.7152),e[t+2]=Math.max(0,s)}}return{header:Q,width:$.width,height:$.height,data:$.byteArray,format:$.format,colorSpace:$.colorSpace,type:this.type,minFilter:n,magFilter:n,generateMipmaps:!1,flipY:!1}}setDataType(e){return this.type=e,this}setOutputFormat(e){return this.outputFormat=e,this}setPart(e){return this.part=e,this}};export{u as EXRLoader};