@hanzo/studio 0.1.7 → 0.1.11

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.
@@ -0,0 +1,1263 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { SizableText, XStack, YStack } from '@hanzo/gui';
3
+ import { Box, Clapperboard, Cpu, Download, Film, Layers, Library, Music, Play, Plus, RefreshCw, Sparkles, ThumbsDown, ThumbsUp, Upload, Video, Wand2, } from '@hanzogui/lucide-icons-2';
4
+ import { useEffect, useRef, useState } from 'react';
5
+ export function parseStudioSection(path) {
6
+ const clean = (path ?? '').replace(/^\/+|\/+$/g, '').split('/')[0] ?? '';
7
+ if (clean === 'create' || clean === 'refine' || clean === 'home')
8
+ return 'create';
9
+ if (clean === 'documents' || clean === 'docs' || clean === 'frames' || clean === 'office')
10
+ return 'documents';
11
+ if (clean === 'video' || clean === 'cinema')
12
+ return 'video';
13
+ if (clean === 'music' || clean === 'audio' || clean === 'voice')
14
+ return 'music';
15
+ if (clean === 'model3d' || clean === '3d' || clean === 'mesh')
16
+ return 'model3d';
17
+ if (clean === 'library' || clean === 'stacks' || clean === 'assets')
18
+ return 'library';
19
+ if (clean === 'queue' || clean === 'activity' || clean === 'gpus')
20
+ return 'queue';
21
+ return 'create';
22
+ }
23
+ export function directorNav(host, go) {
24
+ const active = parseStudioSection(host.path);
25
+ const to = (p) => () => go(p);
26
+ return [
27
+ {
28
+ id: 'make',
29
+ label: 'Studio Production',
30
+ links: [
31
+ { id: 'create', label: 'Create & Refine', icon: _jsx(Wand2, { size: 16 }), onPress: to(''), active: active === 'create' },
32
+ { id: 'library', label: 'Assets, Stacks & QC', icon: _jsx(Library, { size: 16 }), onPress: to('library'), active: active === 'library' },
33
+ { id: 'documents', label: 'Documents & Frames', icon: _jsx(Layers, { size: 16 }), onPress: to('documents'), active: active === 'documents' },
34
+ { id: 'video', label: 'Video & Cinema Rig', icon: _jsx(Clapperboard, { size: 16 }), onPress: to('video'), active: active === 'video' },
35
+ { id: 'music', label: 'Music, Voice & Stems', icon: _jsx(Music, { size: 16 }), onPress: to('music'), active: active === 'music' },
36
+ { id: 'model3d', label: '3D Mesh & World', icon: _jsx(Box, { size: 16 }), onPress: to('model3d'), active: active === 'model3d' },
37
+ { id: 'queue', label: 'GPU Fleet & Queue', icon: _jsx(Cpu, { size: 16 }), onPress: to('queue'), active: active === 'queue' },
38
+ ],
39
+ },
40
+ ];
41
+ }
42
+ export const TRANSFORMATION_LANES = [
43
+ {
44
+ id: 'cad_ghost',
45
+ label: 'CAD → Ghost Mannequin',
46
+ badge: 'denoise 0.92',
47
+ denoise: 0.92,
48
+ model: 'z_image_turbo_bf16.safetensors',
49
+ description: 'High transformation distance (0.92): converts flat technical garment CAD sketches into photoreal 3D hollow ghost mannequin product shots.',
50
+ promptSuffix: 'invisible ghost mannequin studio photography, crisp garment drape, natural interior collar shadow, 85mm studio strobe, pure neutral backdrop',
51
+ },
52
+ {
53
+ id: 'cad_mockup',
54
+ label: 'CAD → Model Lookbook',
55
+ badge: 'denoise 0.92',
56
+ denoise: 0.92,
57
+ model: 'z_image_turbo_bf16.safetensors',
58
+ description: 'High transformation distance (0.92): dresses an editorial fashion model in the uploaded technical flat CAD while locking seam geometry.',
59
+ promptSuffix: 'editorial fashion lookbook photography on model, natural fabric tension, 50mm Cooke prime, soft daylight studio',
60
+ },
61
+ {
62
+ id: 'product',
63
+ label: 'Product Look (Identity Lock)',
64
+ badge: 'denoise 0.25',
65
+ denoise: 0.25,
66
+ model: 'Qwen-Image-Edit-2511',
67
+ description: 'Low denoise (0.25): preserves exact SKU silhouette, hardware, stitching, and label typography while upgrading studio lighting and surface micro-texture.',
68
+ promptSuffix: 'commercial hero product photography, preserve exact product geometry and labels, Phase One IQ4 150MP macro detail',
69
+ },
70
+ {
71
+ id: 'lifestyle',
72
+ label: 'Lifestyle Scene Placement',
73
+ badge: 'denoise 0.25',
74
+ denoise: 0.25,
75
+ model: 'Qwen-Image-Edit-2511',
76
+ description: 'Low denoise (0.25) on subject + scene synthesis: places your locked product or garment into an architectural or outdoor campaign location.',
77
+ promptSuffix: 'architectural concrete and warm cedar interior, natural afternoon sunbeams, contact shadows grounded on surface',
78
+ },
79
+ {
80
+ id: 'outfit',
81
+ label: 'Outfit & Material Swap',
82
+ badge: 'denoise 0.45',
83
+ denoise: 0.45,
84
+ model: 'Qwen-Image-Edit-2511',
85
+ description: 'Medium denoise (0.45): swaps fabric, colorway, or trim material across 2–5 reference images while preserving pose and camera framing.',
86
+ promptSuffix: 'instruction-guided material and colorway swap, keep subject identity, pose, and key lighting identical',
87
+ },
88
+ {
89
+ id: 'inpaint_fix',
90
+ label: 'Region Fix / Mask Inpaint',
91
+ badge: 'denoise 0.30',
92
+ denoise: 0.30,
93
+ model: 'Qwen-Image-Edit-2511',
94
+ description: 'Targeted surgical pass (0.30): repairs hands, collar drape, hardware, or typography inside a masked region (/v1/library/fix).',
95
+ promptSuffix: 'surgical regional inpaint refinement, seamless edge blending, match surrounding grain and specular highlights',
96
+ },
97
+ ];
98
+ export const BRAND_DESIGN_SYSTEMS = [
99
+ {
100
+ id: 'modernist',
101
+ name: 'Modernist',
102
+ tagline: 'Swiss Grid · Warm Paper · Architectural Daylight',
103
+ fonts: 'Geist Sans · JetBrains Mono',
104
+ palette: ['#0a0a0c', '#f5f3ef', '#d94e34', '#71717a'],
105
+ directives: 'Restrained Swiss grid, diffused 5600K daylight, honest material textures, zero decorative clutter.',
106
+ },
107
+ {
108
+ id: 'nocturne',
109
+ name: 'Nocturne',
110
+ tagline: 'Obsidian Void · Anamorphic Rim · Brushed Titanium',
111
+ fonts: 'Inter Display · Geist Mono',
112
+ palette: ['#050508', '#18181b', '#38bdf8', '#e4e4e7'],
113
+ directives: 'Low-key obsidian studio, crisp cyan/silver specular rim light, carbon and anodized aluminum surfaces.',
114
+ },
115
+ {
116
+ id: 'editorial',
117
+ name: 'Editorial Atelier',
118
+ tagline: 'Medium Format Film · Soft Halide · Warm Linen',
119
+ fonts: 'Instrument Serif · Inter',
120
+ palette: ['#1c1917', '#faf8f5', '#a16207', '#78716c'],
121
+ directives: 'Kodak Portra 400 medium-format grain, warm key light, organic linen and travertine surfaces.',
122
+ },
123
+ {
124
+ id: 'technical_cad',
125
+ name: 'Technical CAD Spec',
126
+ tagline: 'Orthographic Callouts · Seam Tolerances · BOM Sheet',
127
+ fonts: 'JetBrains Mono · Inter',
128
+ palette: ['#090d16', '#f8fafc', '#0284c7', '#64748b'],
129
+ directives: 'Orthographic elevation, hair-line dimension callouts, Pantone swatch chips, flat shadowless illumination.',
130
+ },
131
+ ];
132
+ export const OFFICE_DOCUMENT_TEMPLATES = [
133
+ {
134
+ id: 'doc-techpack',
135
+ title: 'Apparel & Industrial Tech Pack (BOM)',
136
+ category: 'Documents',
137
+ format: 'PDF / DOCX',
138
+ endpoint: '/v1/documents/generate',
139
+ description: 'Complete spec sheet with graded measurements, stitch callouts, colorway swatches, and bill of materials.',
140
+ defaultBrief: 'FW26 Technical Shell Jacket — 3-layer Gore-Tex Pro, laser-cut storm welt pockets, YKK AquaGuard matte zippers, sizes XS–XXL.',
141
+ },
142
+ {
143
+ id: 'doc-creative-brief',
144
+ title: 'Campaign Creative Direction & Shot List',
145
+ category: 'Documents',
146
+ format: 'PDF / DOCX',
147
+ endpoint: '/v1/documents/generate',
148
+ description: 'Executive production brief pairing lighting references, talent casting notes, and deliverable aspect ratios.',
149
+ defaultBrief: 'Nocturne Autumn Capsule — 12 lookbook stills (4:5), 3 anamorphic motion loops (2.39:1), and retail window key art.',
150
+ },
151
+ {
152
+ id: 'sheet-line-sheet',
153
+ title: 'Wholesale Line Sheet & Margin Matrix',
154
+ category: 'Spreadsheets',
155
+ format: 'XLSX / CSV',
156
+ endpoint: '/v1/documents/generate',
157
+ description: 'SKU cost breakdown, landed duty formulas, wholesale/MSRP tiers, and MOQ production schedule.',
158
+ defaultBrief: '24-SKU capsule collection with FOB unit costs, 2.4x wholesale multiplier, 5.2x DTC retail target, and Q3 delivery windows.',
159
+ },
160
+ {
161
+ id: 'sheet-render-budget',
162
+ title: 'Production & GPU Compute Cost Ledger',
163
+ category: 'Spreadsheets',
164
+ format: 'XLSX / CSV',
165
+ endpoint: '/v1/documents/generate',
166
+ description: 'Per-asset breakdown across image, Wan 2.2 video, Hunyuan3D mesh, and human retouching hours.',
167
+ defaultBrief: 'Season lookbook automation across 180 SKUs comparing traditional studio shoot vs Hanzo Studio CAD-to-Photoreal pipeline.',
168
+ },
169
+ {
170
+ id: 'deck-lookbook',
171
+ title: 'Seasonal Lookbook & Brand Pitch Deck',
172
+ category: 'Presentations',
173
+ format: 'PPTX / PDF',
174
+ endpoint: '/v1/documents/generate',
175
+ description: '16:9 widescreen presentation with full-bleed hero spreads, typography hierarchy, and collection narrative.',
176
+ defaultBrief: 'SS27 Architectural Utility Collection — 14 slides covering material innovation, silhouette evolution, and global retail rollout.',
177
+ },
178
+ {
179
+ id: 'deck-qbr',
180
+ title: 'Creative Velocity & Quality Flywheel Review',
181
+ category: 'Presentations',
182
+ format: 'PPTX / PDF',
183
+ endpoint: '/v1/documents/generate',
184
+ description: 'Board-ready deck summarizing asset approval rates, critique conditioning improvements, and CMS conversions.',
185
+ defaultBrief: 'Q4 Studio Production Review — 94.2% first-pass approval rate after 420 critique flywheel annotations.',
186
+ },
187
+ {
188
+ id: 'frame-launch-reel',
189
+ title: 'Frames Motion Typography & Product Reel',
190
+ category: 'Frames',
191
+ format: 'HTML / MP4',
192
+ endpoint: '/v1/frames/render',
193
+ description: 'Programmatic 60fps HTML/Canvas kinetic typography composition synchronized to ACE-Step audio stems.',
194
+ defaultBrief: '15-second kinetic launch bumper: "PRECISION IN EVERY THREAD" with CAD wireframe-to-photoreal wipe transition.',
195
+ },
196
+ {
197
+ id: 'frame-interactive-spec',
198
+ title: 'Interactive Before/After CAD Comparison Frame',
199
+ category: 'Frames',
200
+ format: 'HTML / MP4',
201
+ endpoint: '/v1/frames/render',
202
+ description: 'Embeddable interactive loupe and split-slider comparing technical CAD flat against rendered Ghost Mannequin output.',
203
+ defaultBrief: 'Interactive split-screen comparison for SKU #4089 Technical Trench Coat (CAD flat vs 0.92 denoise Ghost Mannequin).',
204
+ },
205
+ ];
206
+ export const CAMERA_MOVES = [
207
+ { id: 'dolly-in', name: 'Dolly In (Push)', category: 'Dolly & Crane', code: 'DLY-IN', description: 'Smooth track forward on cinema rails toward the subject', motionPrompt: 'smooth cinema dolly push-in on rails toward the subject, subtle parallax shift' },
208
+ { id: 'dolly-out', name: 'Dolly Out (Pull)', category: 'Dolly & Crane', code: 'DLY-OUT', description: 'Reveal the surrounding world with a steady pull-back', motionPrompt: 'steady cinema dolly pull-back revealing the environment and scale' },
209
+ { id: 'crane-up', name: 'Crane Rise (Jib Up)', category: 'Dolly & Crane', code: 'CRN-UP', description: 'Sweeping vertical crane ascent tilting down on the scene', motionPrompt: 'sweeping TechnoCrane vertical ascent rising high above the subject while tilting down' },
210
+ { id: 'dolly-zoom', name: 'Vertigo (Zolly)', category: 'Dolly & Crane', code: 'ZLY-VRT', description: 'Dolly out while zooming in to warp background perspective', motionPrompt: 'contrazoom vertigo dolly-zoom effect keeping subject size fixed while background compresses dramatically' },
211
+ { id: 'crash-zoom', name: 'Crash Zoom', category: 'Dynamic & Action', code: 'CRS-ZM', description: 'Rapid whip-zoom punch into extreme close-up', motionPrompt: 'rapid kinetic Tarantino-style crash zoom snap into tight close-up' },
212
+ { id: 'fpv-drone', name: 'FPV Cinema Drone', category: 'Dynamic & Action', code: 'FPV-3D', description: 'Acrobatic proximity flight weaving through architecture', motionPrompt: 'high-speed FPV cinema drone weaving seamlessly through the environment with banked turns' },
213
+ { id: 'handheld', name: 'Handheld Doc 35mm', category: 'Dynamic & Action', code: 'HND-35', description: 'Organic shoulder-rig micro-motion with visceral urgency', motionPrompt: 'organic 35mm shoulder-rig handheld cinematography with subtle breathing motion' },
214
+ { id: 'whip-pan', name: 'Whip Pan Transition', category: 'Dynamic & Action', code: 'WHP-PN', description: 'High-velocity horizontal pan with directional motion blur', motionPrompt: 'high-velocity whip pan across the scene with natural directional shutter blur' },
215
+ { id: 'orbit-360', name: '360° Hero Orbit', category: 'Orbital & Pan', code: 'ORB-360', description: 'Continuous circular arc around the hero subject', motionPrompt: 'continuous 360-degree circular Steadicam orbit around the central hero subject' },
216
+ { id: 'low-track', name: 'Low-Angle Lead Track', category: 'Orbital & Pan', code: 'TRK-LOW', description: 'Low-mode Steadicam leading the walking subject backward', motionPrompt: 'low-angle Steadicam tracking backward ahead of the walking subject, heroic perspective' },
217
+ { id: 'bullet-time', name: 'Bullet-Time Array', category: 'Specialty', code: 'BLT-120', description: 'Frozen 1000fps moment while the virtual camera orbits', motionPrompt: 'frozen ultra-slow-motion bullet-time moment while the camera orbits smoothly around suspended particles' },
218
+ { id: 'snorricam', name: 'SnorriCam Body Rig', category: 'Specialty', code: 'SNR-BDY', description: 'Camera locked to actor chest; world spins around them', motionPrompt: 'SnorriCam body-mounted rig locked to the actor while the background rotates dynamically' },
219
+ ];
220
+ export const LENSES = [
221
+ { id: '14mm-ultra', label: '14mm Ultra-Wide Rectilinear', fov: 114, aspect: '2.39:1' },
222
+ { id: '24mm-anamorphic', label: '24mm Hawke Anamorphic', fov: 84, aspect: '2.39:1' },
223
+ { id: '35mm-cooke', label: '35mm Cooke Anamorphic /i', fov: 63, aspect: '2.39:1' },
224
+ { id: '50mm-master', label: '50mm ARRI Master Prime', fov: 46, aspect: '16:9' },
225
+ { id: '85mm-panavision', label: '85mm Panavision Primo Portrait', fov: 28, aspect: '2.39:1' },
226
+ { id: '135mm-tele', label: '135mm Telephoto Compression', fov: 18, aspect: '2.39:1' },
227
+ ];
228
+ export const APERTURES = ['f/1.2', 'f/1.8', 'f/2.8', 'f/4.0', 'f/8.0', 'f/16'];
229
+ export const LIGHTING_RIGS = [
230
+ { id: 'neon-noir', label: 'Anamorphic Neon & Wet Pavement', colors: ['#060814', '#00e5ff', '#ff2a85'] },
231
+ { id: 'golden-hour', label: 'Golden Hour Volumetric Backlight', colors: ['#180d06', '#ff9a3c', '#ffd27d'] },
232
+ { id: 'chiaroscuro', label: 'Chiaroscuro Silver Halide Mono', colors: ['#08080a', '#94a3b8', '#f8fafc'] },
233
+ { id: 'cyber-stage', label: 'LED Volume Virtual Soundstage', colors: ['#090614', '#7c3aed', '#38bdf8'] },
234
+ { id: 'daylight-soft', label: 'Diffused Overcast 5600K', colors: ['#0f172a', '#64748b', '#e2e8f0'] },
235
+ ];
236
+ const INITIAL_CHARACTERS = [
237
+ {
238
+ id: 'char-kael',
239
+ name: 'Kael Vance',
240
+ role: 'Lead Protagonist',
241
+ wardrobe: 'Charcoal technical trench coat, rain-slicked collar, subtle titanium earpiece',
242
+ voice: 'Koe · Deep Baritone',
243
+ seed: 408921,
244
+ },
245
+ {
246
+ id: 'char-lyra',
247
+ name: 'Dr. Lyra Sato',
248
+ role: 'Quantum Architect',
249
+ wardrobe: 'Ivory structured minimalist blazer, optical glass visor, silver chronograph',
250
+ voice: 'Koe · Warm Alto',
251
+ seed: 771204,
252
+ },
253
+ {
254
+ id: 'char-unit9',
255
+ name: 'Valkyrie-9',
256
+ role: 'Autonomous Drone Rig',
257
+ wardrobe: 'Brushed carbon-fiber chassis, amber telemetry optics, articulated thrusters',
258
+ voice: 'Oto · Servo & Sub-Bass',
259
+ seed: 910344,
260
+ },
261
+ ];
262
+ const INITIAL_SHOTS = [
263
+ {
264
+ id: 'shot-1',
265
+ number: 1,
266
+ title: 'Establishing — Rain Over Neo-Kyoto Sector 4',
267
+ prompt: 'Rain-drenched rooftop overlooking neon transit arteries at midnight, steam rising from vents as Kael stands at the parapet.',
268
+ dialogue: 'The signal did not come from outside the grid. It started under our feet.',
269
+ cameraId: 'crane-up',
270
+ lensId: '24mm-anamorphic',
271
+ aperture: 'f/2.8',
272
+ lightingId: 'neon-noir',
273
+ characterId: 'char-kael',
274
+ durationSec: 4.5,
275
+ status: 'ready',
276
+ },
277
+ {
278
+ id: 'shot-2',
279
+ number: 2,
280
+ title: 'Close-Up — Lyra Decodes the Telemetry',
281
+ prompt: 'Holographic waveform reflections across Lyra’s optical glass visor inside the dark server vault, shallow depth of field.',
282
+ dialogue: 'Every node in the cluster is resonating at forty-two hertz. Watch the phase lock.',
283
+ cameraId: 'dolly-in',
284
+ lensId: '85mm-panavision',
285
+ aperture: 'f/1.2',
286
+ lightingId: 'cyber-stage',
287
+ characterId: 'char-lyra',
288
+ durationSec: 4.0,
289
+ status: 'ready',
290
+ },
291
+ {
292
+ id: 'shot-3',
293
+ number: 3,
294
+ title: 'Action — Valkyrie-9 Drops Into the Canyon',
295
+ prompt: 'Valkyrie-9 dives between glass skybridges as rain streaks horizontally across the anamorphic lens.',
296
+ dialogue: 'Holding trajectory. Lock confirmed.',
297
+ cameraId: 'fpv-drone',
298
+ lensId: '14mm-ultra',
299
+ aperture: 'f/4.0',
300
+ lightingId: 'neon-noir',
301
+ characterId: 'char-unit9',
302
+ durationSec: 5.0,
303
+ status: 'ready',
304
+ },
305
+ ];
306
+ const MESH_PRESETS = [
307
+ { id: 'mesh-drone', name: 'Valkyrie-9 Recon Drone Chassis', category: 'Hard-Surface / Mecha', vertices: 48_240, faces: 96_480, octree: 512, prompt: 'Carbon-fiber articulated quad-thruster reconnaissance drone with recessed optical array', shape: 'octahedron' },
308
+ { id: 'mesh-garment', name: 'Karma Technical Shell Jacket', category: 'Fashion / CAD-to-3D', vertices: 36_120, faces: 72_200, octree: 384, prompt: 'Ghost-mannequin matte Gore-Tex shell jacket with taped seams and storm hood', shape: 'capsule' },
309
+ { id: 'mesh-sculpture', name: 'Mobius Titanium Relic', category: 'Product / Industrial', vertices: 64_800, faces: 129_600, octree: 512, prompt: 'Brushed Grade-5 titanium parametric torus knot sculpture with anodized chamfers', shape: 'torusKnot' },
310
+ { id: 'mesh-pavilion', name: 'Brutalist Acoustic Monolith', category: 'Architecture / World', vertices: 29_400, faces: 58_800, octree: 384, prompt: 'Faceted obsidian acoustic monument with warm recessed linear light channels', shape: 'crystal' },
311
+ ];
312
+ const INITIAL_LIBRARY = [
313
+ { id: 'lib-1', path: 'video/neo_kyoto_establishing.mp4', title: 'Neo-Kyoto Establishing Shot 01', modality: 'video', stack: 'Sequence 01 — Rain Protocol', status: 'published', vote: 1, critique: 'Great anamorphic flare; keep wet pavement reflections.', workflow: 'wan22-ti2v', createdAt: '2m ago' },
314
+ { id: 'lib-2', path: 'mesh/valkyrie9_chassis.glb', title: 'Valkyrie-9 Drone (.glb Mesh)', modality: 'model3d', stack: 'Hero Props & 3D Assets', status: 'approved', vote: 1, critique: 'Clean watertight topology at 384 octree.', workflow: 'hunyuan3d-mesh', createdAt: '11m ago' },
315
+ { id: 'lib-3', path: 'audio/night_grid_stems.mp3', title: 'Night Grid — 122 BPM Master Stem', modality: 'music', stack: 'Soundtrack & Koe Stems', status: 'published', vote: 1, critique: 'Sub-bass sits cleanly under Kael baritone dialogue.', workflow: 'acestep-music', createdAt: '18m ago' },
316
+ { id: 'lib-4', path: 'edit/kael_trench_lookbook.png', title: 'Kael Vance — Wardrobe Lock v3', modality: 'image', stack: 'Character Continuity Vault', status: 'draft', vote: 0, critique: '', workflow: 'qwen-edit-inpaint', createdAt: '26m ago' },
317
+ ];
318
+ export function DirectorStudio({ host }) {
319
+ const [section, setSection] = useState(() => parseStudioSection(host.path));
320
+ useEffect(() => {
321
+ setSection(parseStudioSection(host.path));
322
+ }, [host.path]);
323
+ const switchSection = (next) => {
324
+ setSection(next);
325
+ if (host.go) {
326
+ host.go(next === 'video' ? '' : next);
327
+ }
328
+ };
329
+ // GPU Fleet & Live Queue state
330
+ const [gpuNodes, setGpuNodes] = useState([
331
+ { name: 'spark-gb10-01', online: true, depth: 0, vram: '128 GB Unified', lanes: ['image.zen', 'video.wan', 'mesh', 'music.ace'] },
332
+ { name: 'dgx-h100-cluster', online: true, depth: 1, vram: '8×80 GB HBM3', lanes: ['video.wan', 'koma.v2', 'mesh', 'music.ace'] },
333
+ ]);
334
+ const [targetGpu, setTargetGpu] = useState('any');
335
+ const [statusNote, setStatusNote] = useState('ComfyUI 2.0 Engine · Wan 2.2 · Hunyuan3D 2.1 · ACE-Step 3.5B · Koe TTS');
336
+ // Poll /v1/gpu-status when available
337
+ useEffect(() => {
338
+ let alive = true;
339
+ const apiBase = host.api || 'https://api.hanzo.ai';
340
+ const token = host.token();
341
+ const headers = {};
342
+ if (token)
343
+ headers.Authorization = `Bearer ${token}`;
344
+ if (host.org)
345
+ headers['X-Org-Id'] = host.org;
346
+ fetch(`${apiBase}/v1/gpu-status`, { headers })
347
+ .then((r) => (r.ok ? r.json() : null))
348
+ .then((j) => {
349
+ if (!alive || !j?.nodes?.length)
350
+ return;
351
+ setGpuNodes(j.nodes.map((n) => ({
352
+ name: n.name || 'gpu-worker',
353
+ online: n.online !== false,
354
+ depth: n.depth ?? 0,
355
+ vram: 'Cloud GPU',
356
+ lanes: n.lanes ?? ['image.zen', 'video.wan', 'mesh', 'music.ace'],
357
+ })));
358
+ })
359
+ .catch(() => { });
360
+ return () => {
361
+ alive = false;
362
+ };
363
+ }, [host]);
364
+ // ── 1. VIDEO & CINEMA STATE ──────────────────────────────────────────────────
365
+ const [shots, setShots] = useState(INITIAL_SHOTS);
366
+ const [activeShotId, setActiveShotId] = useState(INITIAL_SHOTS[0].id);
367
+ const [characters, setCharacters] = useState(INITIAL_CHARACTERS);
368
+ const [playing, setPlaying] = useState(true);
369
+ const [sequenceMode, setSequenceMode] = useState(false);
370
+ const [renderingId, setRenderingId] = useState(null);
371
+ const [newCharName, setNewCharName] = useState('');
372
+ const [newCharWardrobe, setNewCharWardrobe] = useState('');
373
+ const canvasRef = useRef(null);
374
+ const audioCtxRef = useRef(null);
375
+ const activeShot = shots.find((s) => s.id === activeShotId) ?? shots[0];
376
+ const activeCamera = CAMERA_MOVES.find((c) => c.id === activeShot.cameraId) ?? CAMERA_MOVES[0];
377
+ const activeLens = LENSES.find((l) => l.id === activeShot.lensId) ?? LENSES[0];
378
+ const activeLighting = LIGHTING_RIGS.find((l) => l.id === activeShot.lightingId) ?? LIGHTING_RIGS[0];
379
+ const activeCharacter = characters.find((c) => c.id === activeShot.characterId) ?? characters[0];
380
+ const updateShot = (patch) => {
381
+ setShots((prev) => prev.map((s) => (s.id === activeShot.id ? { ...s, ...patch } : s)));
382
+ };
383
+ // ── 3. MUSIC, VOICE & AUDIO STEM LAB STATE ───────────────────────────────────
384
+ const [musicPrompt, setMusicPrompt] = useState('Analog cyberpunk synthwave with driving 16th-note arpeggio, warm sub-bass, crisp gated drums, and atmospheric pads');
385
+ const [musicLyrics, setMusicLyrics] = useState('[Verse 1]\nStatic on the horizon, neon in the rain\nEvery node awakens across the optical plane\n\n[Chorus]\nLock the frequency, hold the phase in time\nRunning on the edge of the skyline');
386
+ const [musicBpm, setMusicBpm] = useState(122);
387
+ const [musicKey, setMusicKey] = useState('F Minor');
388
+ const [voiceLine, setVoiceLine] = useState('Every node in the cluster is resonating at forty-two hertz. Watch the phase lock.');
389
+ const [voicePreset, setVoicePreset] = useState('koe-baritone');
390
+ const [dawPlaying, setDawPlaying] = useState(false);
391
+ const [stems, setStems] = useState([
392
+ { id: 'stem-drums', name: 'Drums & Percussion', role: 'ACE-Step Rhythm Stem', freq: 110, volume: 85, muted: false, solo: false, color: '#38bdf8' },
393
+ { id: 'stem-bass', name: 'Analog Sub-Bass', role: 'ACE-Step Bassline Stem', freq: 55, volume: 90, muted: false, solo: false, color: '#a855f7' },
394
+ { id: 'stem-synth', name: 'Lead Arpeggio & Pad', role: 'ACE-Step Harmonic Stem', freq: 220, volume: 78, muted: false, solo: false, color: '#f43f5e' },
395
+ { id: 'stem-vocal', name: 'Koe Vocal / Dialogue', role: 'Koe TTS & Lyric Stem', freq: 330, volume: 92, muted: false, solo: false, color: '#3ddc84' },
396
+ ]);
397
+ const audioWaveCanvasRef = useRef(null);
398
+ const dawTimerRef = useRef(null);
399
+ // ── 4. 3D MESH & WORLD STUDIO STATE ──────────────────────────────────────────
400
+ const [activeMeshId, setActiveMeshId] = useState(MESH_PRESETS[0].id);
401
+ const activeMesh = MESH_PRESETS.find((m) => m.id === activeMeshId) ?? MESH_PRESETS[0];
402
+ const [meshShader, setMeshShader] = useState('pbr');
403
+ const [meshAutoRotate, setMeshAutoRotate] = useState(true);
404
+ const [meshLightAngle, setMeshLightAngle] = useState(45);
405
+ const [meshOctree, setMeshOctree] = useState(384);
406
+ const [meshPrompt, setMeshPrompt] = useState(MESH_PRESETS[0].prompt);
407
+ const meshCanvasRef = useRef(null);
408
+ // ── 5. LIBRARY, STACKS, INPAINT & FLYWHEEL STATE ─────────────────────────────
409
+ const [libraryItems, setLibraryItems] = useState(INITIAL_LIBRARY);
410
+ const [libraryFilter, setLibraryFilter] = useState('all');
411
+ const [inpaintInstruction, setInpaintInstruction] = useState('Swap outer shell to brushed titanium carbon weave; keep lighting and silhouette intact');
412
+ const [inpaintStrength, setInpaintStrength] = useState(30);
413
+ const inpaintCanvasRef = useRef(null);
414
+ // ── 6. ANTJE CREATE & REFINE COMPOSER + DOCUMENTS STATE ──────────────────────
415
+ const [createPrompt, setCreatePrompt] = useState('Technical unstructured 3-layer shell jacket in matte obsidian Gore-Tex Pro, laser-cut storm welt pockets, studio strobe lighting');
416
+ const [selectedLaneId, setSelectedLaneId] = useState(TRANSFORMATION_LANES[0].id);
417
+ const selectedLane = TRANSFORMATION_LANES.find((l) => l.id === selectedLaneId) ?? TRANSFORMATION_LANES[0];
418
+ const [selectedBrandId, setSelectedBrandId] = useState(BRAND_DESIGN_SYSTEMS[0].id);
419
+ const selectedBrand = BRAND_DESIGN_SYSTEMS.find((b) => b.id === selectedBrandId) ?? BRAND_DESIGN_SYSTEMS[0];
420
+ const [referenceFiles, setReferenceFiles] = useState(['cad_flat_shell_fw26.png', 'fabric_swatch_obsidian.jpg']);
421
+ const [docCategoryFilter, setDocCategoryFilter] = useState('All');
422
+ const [selectedDocTemplateId, setSelectedDocTemplateId] = useState(OFFICE_DOCUMENT_TEMPLATES[0].id);
423
+ const selectedDocTemplate = OFFICE_DOCUMENT_TEMPLATES.find((d) => d.id === selectedDocTemplateId) ?? OFFICE_DOCUMENT_TEMPLATES[0];
424
+ const [docBrief, setDocBrief] = useState(OFFICE_DOCUMENT_TEMPLATES[0].defaultBrief);
425
+ const runCreateAndRefine = async () => {
426
+ triggerCinemaAudio();
427
+ const newId = `lib-${Date.now().toString(36)}`;
428
+ const compiled = `${createPrompt} — [${selectedLane.label}, denoise=${selectedLane.denoise}, brand=${selectedBrand.name}: ${selectedBrand.directives}]`;
429
+ setStatusNote(`Queued ${selectedLane.label} (${selectedLane.model}, denoise ${selectedLane.denoise}) with ${selectedBrand.name} brand kit → /v1/images/generations`);
430
+ const apiBase = host.api || 'https://api.hanzo.ai';
431
+ const token = host.token();
432
+ const headers = { 'Content-Type': 'application/json' };
433
+ if (token)
434
+ headers.Authorization = `Bearer ${token}`;
435
+ if (host.org)
436
+ headers['X-Org-Id'] = host.org;
437
+ await fetch(`${apiBase}/v1/images/generations`, {
438
+ method: 'POST',
439
+ headers,
440
+ body: JSON.stringify({
441
+ model: selectedLane.model,
442
+ prompt: `${compiled}. ${selectedLane.promptSuffix}`,
443
+ denoise: selectedLane.denoise,
444
+ lane: selectedLane.id,
445
+ brand_system: selectedBrand.id,
446
+ references: referenceFiles,
447
+ }),
448
+ }).catch(() => null);
449
+ setLibraryItems((prev) => [
450
+ {
451
+ id: newId,
452
+ title: `${selectedLane.label} — ${createPrompt.slice(0, 42)}`,
453
+ modality: 'image',
454
+ stack: `${selectedBrand.name} · ${selectedLane.badge}`,
455
+ workflow: `${selectedLane.id}_denoise_${selectedLane.denoise}.json`,
456
+ path: `output/image/${newId}.png`,
457
+ vote: 0,
458
+ critique: `Conditioned on ${referenceFiles.join(', ')} (${selectedLane.badge})`,
459
+ status: 'draft',
460
+ createdAt: 'Just now',
461
+ },
462
+ ...prev,
463
+ ]);
464
+ };
465
+ const generateOfficeDocument = async (tpl) => {
466
+ triggerCinemaAudio();
467
+ setStatusNote(`Generating ${tpl.title} (${tpl.format}) with ${selectedBrand.name} design system → ${tpl.endpoint}`);
468
+ const apiBase = host.api || 'https://api.hanzo.ai';
469
+ const token = host.token();
470
+ const headers = { 'Content-Type': 'application/json' };
471
+ if (token)
472
+ headers.Authorization = `Bearer ${token}`;
473
+ if (host.org)
474
+ headers['X-Org-Id'] = host.org;
475
+ await fetch(`${apiBase}${tpl.endpoint}`, {
476
+ method: 'POST',
477
+ headers,
478
+ body: JSON.stringify({
479
+ template_id: tpl.id,
480
+ category: tpl.category,
481
+ format: tpl.format,
482
+ brand_system: selectedBrand.id,
483
+ brief: docBrief,
484
+ }),
485
+ }).catch(() => null);
486
+ };
487
+ // Real-time 60fps Anamorphic Cinema Canvas Preview
488
+ useEffect(() => {
489
+ if (section !== 'video')
490
+ return;
491
+ const canvas = canvasRef.current;
492
+ if (!canvas)
493
+ return;
494
+ const ctx = canvas.getContext('2d');
495
+ if (!ctx)
496
+ return;
497
+ let raf = 0;
498
+ let start = performance.now();
499
+ const render = (now) => {
500
+ const elapsed = playing ? (now - start) / 1000 : 1.8;
501
+ const dur = activeShot.durationSec || 4.5;
502
+ const t = (elapsed % dur) / dur;
503
+ if (sequenceMode && playing && elapsed >= dur) {
504
+ start = now;
505
+ const idx = shots.findIndex((s) => s.id === activeShot.id);
506
+ const next = shots[(idx + 1) % shots.length];
507
+ if (next && next.id !== activeShot.id) {
508
+ setActiveShotId(next.id);
509
+ }
510
+ }
511
+ const w = canvas.width;
512
+ const h = canvas.height;
513
+ ctx.save();
514
+ ctx.fillStyle = '#050508';
515
+ ctx.fillRect(0, 0, w, h);
516
+ let zoom = 1;
517
+ let panX = 0;
518
+ let panY = 0;
519
+ let roll = 0;
520
+ switch (activeCamera.id) {
521
+ case 'dolly-in':
522
+ zoom = 1 + t * 0.38;
523
+ break;
524
+ case 'dolly-out':
525
+ zoom = 1.38 - t * 0.34;
526
+ break;
527
+ case 'crane-up':
528
+ zoom = 1.08 + t * 0.12;
529
+ panY = t * 70 - 35;
530
+ break;
531
+ case 'dolly-zoom':
532
+ zoom = 1 + Math.sin(t * Math.PI) * 0.32;
533
+ break;
534
+ case 'crash-zoom':
535
+ zoom = 1 + Math.pow(Math.min(1, t * 1.8), 4) * 1.15;
536
+ break;
537
+ case 'fpv-drone':
538
+ zoom = 1.15 + t * 0.5;
539
+ panX = Math.sin(t * Math.PI * 2) * 65;
540
+ panY = Math.cos(t * Math.PI * 2) * 28;
541
+ roll = Math.sin(t * Math.PI * 2) * 0.14;
542
+ break;
543
+ case 'handheld':
544
+ zoom = 1.06;
545
+ panX = Math.sin(elapsed * 7.3) * 8 + Math.cos(elapsed * 13.1) * 4;
546
+ panY = Math.cos(elapsed * 6.1) * 7 + Math.sin(elapsed * 11.7) * 3;
547
+ roll = Math.sin(elapsed * 4.5) * 0.018;
548
+ break;
549
+ case 'whip-pan':
550
+ panX = (t < 0.5 ? t * 2 : 1) * 160 - 80;
551
+ break;
552
+ case 'orbit-360':
553
+ panX = Math.cos(t * Math.PI * 2) * 90;
554
+ panY = Math.sin(t * Math.PI * 2) * 18;
555
+ zoom = 1.12;
556
+ break;
557
+ case 'low-track':
558
+ zoom = 1.1 + t * 0.15;
559
+ panY = -28;
560
+ break;
561
+ case 'bullet-time':
562
+ panX = Math.sin(t * Math.PI) * 110 - 55;
563
+ zoom = 1.22;
564
+ break;
565
+ case 'snorricam':
566
+ zoom = 1.18;
567
+ roll = Math.sin(t * Math.PI * 2) * 0.09;
568
+ break;
569
+ }
570
+ ctx.translate(w / 2 + panX, h / 2 + panY);
571
+ ctx.rotate(roll);
572
+ ctx.scale(zoom, zoom);
573
+ ctx.translate(-w / 2, -h / 2);
574
+ const [c0, c1, c2] = activeLighting.colors;
575
+ const grad = ctx.createRadialGradient(w * 0.52, h * 0.42, 30, w * 0.5, h * 0.5, w * 0.75);
576
+ grad.addColorStop(0, c2 + '55');
577
+ grad.addColorStop(0.45, c1 + '33');
578
+ grad.addColorStop(1, c0);
579
+ ctx.fillStyle = grad;
580
+ ctx.fillRect(-160, -160, w + 320, h + 320);
581
+ ctx.strokeStyle = c1 + '30';
582
+ ctx.lineWidth = 1;
583
+ const horizon = h * 0.58;
584
+ for (let i = -10; i <= 10; i++) {
585
+ ctx.beginPath();
586
+ ctx.moveTo(w / 2 + i * 28, horizon);
587
+ ctx.lineTo(w / 2 + i * 160, h + 120);
588
+ ctx.stroke();
589
+ }
590
+ const dofBlur = activeShot.aperture === 'f/1.2' ? 3.2 : activeShot.aperture === 'f/1.8' ? 2.2 : 1.0;
591
+ for (let i = 0; i < 48; i++) {
592
+ const seed = (i * 9301 + 49297) % 233280;
593
+ const px = ((seed / 233280) * (w + 200) - 100 + (activeCamera.id === 'bullet-time' ? t * 15 : elapsed * (40 + (i % 5) * 18))) % (w + 160) - 80;
594
+ const py = (((i * 479) % h) + (activeCamera.id === 'bullet-time' ? t * 8 : elapsed * (90 + (i % 7) * 25))) % h;
595
+ const r = (i % 4 === 0 ? 3.5 : 1.6) * dofBlur;
596
+ ctx.fillStyle = i % 3 === 0 ? c2 + '88' : c1 + '66';
597
+ ctx.beginPath();
598
+ ctx.arc(px, py, r, 0, Math.PI * 2);
599
+ ctx.fill();
600
+ }
601
+ const charPhase = (activeCharacter.seed % 100) / 100;
602
+ const cx = w * 0.5 + Math.sin(t * Math.PI * 2 + charPhase) * 14;
603
+ const cy = h * 0.56;
604
+ const flare = ctx.createLinearGradient(0, cy - 38, w, cy - 38);
605
+ flare.addColorStop(0, 'transparent');
606
+ flare.addColorStop(0.35, c1 + '66');
607
+ flare.addColorStop(0.5, '#ffffffcc');
608
+ flare.addColorStop(0.65, c2 + '66');
609
+ flare.addColorStop(1, 'transparent');
610
+ ctx.fillStyle = flare;
611
+ ctx.fillRect(0, cy - 41, w, 5);
612
+ ctx.fillStyle = '#090b10';
613
+ ctx.strokeStyle = c2;
614
+ ctx.lineWidth = 2.2;
615
+ ctx.beginPath();
616
+ ctx.roundRect(cx - 54, cy - 20, 108, 150, 26);
617
+ ctx.fill();
618
+ ctx.stroke();
619
+ ctx.beginPath();
620
+ ctx.arc(cx, cy - 52, 26, 0, Math.PI * 2);
621
+ ctx.fill();
622
+ ctx.stroke();
623
+ ctx.restore();
624
+ const barH = activeLens.aspect === '2.39:1' ? Math.round(h * 0.12) : Math.round(h * 0.04);
625
+ ctx.fillStyle = '#000000';
626
+ ctx.fillRect(0, 0, w, barH);
627
+ ctx.fillRect(0, h - barH, w, barH);
628
+ ctx.strokeStyle = 'rgba(255,255,255,0.08)';
629
+ ctx.lineWidth = 1;
630
+ ctx.beginPath();
631
+ ctx.moveTo(w / 3, barH);
632
+ ctx.lineTo(w / 3, h - barH);
633
+ ctx.moveTo((w * 2) / 3, barH);
634
+ ctx.lineTo((w * 2) / 3, h - barH);
635
+ ctx.moveTo(0, barH + (h - 2 * barH) / 3);
636
+ ctx.lineTo(w, barH + (h - 2 * barH) / 3);
637
+ ctx.moveTo(0, barH + ((h - 2 * barH) * 2) / 3);
638
+ ctx.lineTo(w, barH + ((h - 2 * barH) * 2) / 3);
639
+ ctx.stroke();
640
+ ctx.fillStyle = 'rgba(255,255,255,0.78)';
641
+ ctx.font = '600 11px ui-monospace, SFMono-Regular, Menlo, monospace';
642
+ ctx.fillText(`SHOT ${String(activeShot.number).padStart(2, '0')} · ${activeCamera.code} · ${activeLens.label.split(' ')[0]} · ${activeShot.aperture}`, 18, 22);
643
+ ctx.fillStyle = '#3ddc84';
644
+ ctx.fillText(`● ACTOR LOCK: ${activeCharacter.name.toUpperCase()} (#${activeCharacter.seed})`, w - 310, 22);
645
+ const totalFrames = Math.floor(elapsed * 24);
646
+ const ff = String(totalFrames % 24).padStart(2, '0');
647
+ const ss = String(Math.floor(elapsed) % 60).padStart(2, '0');
648
+ ctx.fillStyle = 'rgba(255,255,255,0.75)';
649
+ ctx.fillText(`TC 01:00:${ss}:${ff} · 24.000 FPS · ${activeLens.aspect}`, 18, h - 14);
650
+ if (activeShot.dialogue) {
651
+ ctx.font = '500 13px system-ui, -apple-system, sans-serif';
652
+ ctx.fillStyle = 'rgba(255,255,255,0.92)';
653
+ const sub = `“${activeShot.dialogue}”`;
654
+ const tw = ctx.measureText(sub).width;
655
+ ctx.fillText(sub, Math.max(18, (w - tw) / 2), h - barH - 18);
656
+ }
657
+ raf = requestAnimationFrame(render);
658
+ };
659
+ raf = requestAnimationFrame(render);
660
+ return () => cancelAnimationFrame(raf);
661
+ }, [section, activeShot, activeCamera, activeLens, activeLighting, activeCharacter, playing, sequenceMode, shots]);
662
+ // Real-time 60fps Audio Stem Waveform & Spectrum Visualizer
663
+ useEffect(() => {
664
+ if (section !== 'music')
665
+ return;
666
+ const canvas = audioWaveCanvasRef.current;
667
+ if (!canvas)
668
+ return;
669
+ const ctx = canvas.getContext('2d');
670
+ if (!ctx)
671
+ return;
672
+ let raf = 0;
673
+ const start = performance.now();
674
+ const draw = (now) => {
675
+ const t = (now - start) / 1000;
676
+ const w = canvas.width;
677
+ const h = canvas.height;
678
+ ctx.fillStyle = '#07080d';
679
+ ctx.fillRect(0, 0, w, h);
680
+ // Beat grid lines
681
+ ctx.strokeStyle = 'rgba(255,255,255,0.06)';
682
+ for (let i = 1; i < 16; i++) {
683
+ const x = (w / 16) * i;
684
+ ctx.beginPath();
685
+ ctx.moveTo(x, 0);
686
+ ctx.lineTo(x, h);
687
+ ctx.stroke();
688
+ }
689
+ const anySolo = stems.some((s) => s.solo);
690
+ stems.forEach((stem, sIdx) => {
691
+ const active = anySolo ? stem.solo : !stem.muted;
692
+ const amp = active ? (stem.volume / 100) * (dawPlaying ? 26 : 6) : 1.5;
693
+ const rowY = (h / (stems.length + 1)) * (sIdx + 1);
694
+ ctx.strokeStyle = active ? stem.color : 'rgba(255,255,255,0.18)';
695
+ ctx.lineWidth = 2;
696
+ ctx.beginPath();
697
+ for (let x = 0; x < w; x += 4) {
698
+ const phase = (x / w) * Math.PI * (8 + sIdx * 4) + (dawPlaying ? t * (4 + sIdx * 1.7) : 0);
699
+ const mod = Math.sin((x / w) * Math.PI * 3 - (dawPlaying ? t * 2.2 : 0));
700
+ const y = rowY + Math.sin(phase) * mod * amp;
701
+ if (x === 0)
702
+ ctx.moveTo(x, y);
703
+ else
704
+ ctx.lineTo(x, y);
705
+ }
706
+ ctx.stroke();
707
+ });
708
+ // Playhead cursor
709
+ const playheadX = dawPlaying ? ((t * (musicBpm / 60) * 45) % w) : w * 0.25;
710
+ ctx.strokeStyle = '#ffffff';
711
+ ctx.lineWidth = 1.5;
712
+ ctx.beginPath();
713
+ ctx.moveTo(playheadX, 0);
714
+ ctx.lineTo(playheadX, h);
715
+ ctx.stroke();
716
+ raf = requestAnimationFrame(draw);
717
+ };
718
+ raf = requestAnimationFrame(draw);
719
+ return () => cancelAnimationFrame(raf);
720
+ }, [section, stems, dawPlaying, musicBpm]);
721
+ // WebAudio procedural multi-stem synthesizer when DAW Play is toggled
722
+ useEffect(() => {
723
+ if (!dawPlaying) {
724
+ if (dawTimerRef.current) {
725
+ window.clearInterval(dawTimerRef.current);
726
+ dawTimerRef.current = null;
727
+ }
728
+ return;
729
+ }
730
+ const stepMs = Math.round((60 / Math.max(60, musicBpm) / 2) * 1000);
731
+ let step = 0;
732
+ const notes = [110, 130.81, 146.83, 164.81, 196.0, 220, 261.63, 196.0];
733
+ dawTimerRef.current = window.setInterval(() => {
734
+ try {
735
+ const Ctx = window.AudioContext || window.webkitAudioContext;
736
+ const ctx = audioCtxRef.current ?? new Ctx();
737
+ audioCtxRef.current = ctx;
738
+ if (ctx.state === 'suspended')
739
+ void ctx.resume();
740
+ const now = ctx.currentTime;
741
+ const osc = ctx.createOscillator();
742
+ const gain = ctx.createGain();
743
+ osc.type = step % 2 === 0 ? 'sawtooth' : 'triangle';
744
+ osc.frequency.setValueAtTime(notes[step % notes.length], now);
745
+ gain.gain.setValueAtTime(0.001, now);
746
+ gain.gain.exponentialRampToValueAtTime(0.06, now + 0.02);
747
+ gain.gain.exponentialRampToValueAtTime(0.0008, now + stepMs / 1000);
748
+ osc.connect(gain);
749
+ gain.connect(ctx.destination);
750
+ osc.start(now);
751
+ osc.stop(now + stepMs / 1000 + 0.02);
752
+ step++;
753
+ }
754
+ catch {
755
+ // Ignore if autoplay blocked
756
+ }
757
+ }, stepMs);
758
+ return () => {
759
+ if (dawTimerRef.current) {
760
+ window.clearInterval(dawTimerRef.current);
761
+ dawTimerRef.current = null;
762
+ }
763
+ };
764
+ }, [dawPlaying, musicBpm]);
765
+ // Real-time 60fps 3D Mesh Viewport Renderer (Hunyuan3D-2.1 Interactive Turntable)
766
+ useEffect(() => {
767
+ if (section !== 'model3d')
768
+ return;
769
+ const canvas = meshCanvasRef.current;
770
+ if (!canvas)
771
+ return;
772
+ const ctx = canvas.getContext('2d');
773
+ if (!ctx)
774
+ return;
775
+ let raf = 0;
776
+ const start = performance.now();
777
+ const draw3D = (now) => {
778
+ const t = meshAutoRotate ? (now - start) / 1000 : 1.1;
779
+ const w = canvas.width;
780
+ const h = canvas.height;
781
+ ctx.fillStyle = '#090a10';
782
+ ctx.fillRect(0, 0, w, h);
783
+ // Ground perspective grid
784
+ ctx.strokeStyle = 'rgba(255,255,255,0.07)';
785
+ ctx.lineWidth = 1;
786
+ for (let i = -6; i <= 6; i++) {
787
+ ctx.beginPath();
788
+ ctx.moveTo(w / 2 + i * 36, h * 0.68);
789
+ ctx.lineTo(w / 2 + i * 95, h * 0.94);
790
+ ctx.stroke();
791
+ }
792
+ // Generate procedural 3D vertices based on selected mesh preset
793
+ const pts = [];
794
+ const edges = [];
795
+ const rings = 14;
796
+ const segs = 20;
797
+ for (let r = 0; r <= rings; r++) {
798
+ const u = (r / rings) * Math.PI;
799
+ for (let s = 0; s < segs; s++) {
800
+ const v = (s / segs) * Math.PI * 2;
801
+ let x = 0;
802
+ let y = 0;
803
+ let z = 0;
804
+ if (activeMesh.shape === 'torusKnot') {
805
+ const R = 75 + 28 * Math.cos(3 * v);
806
+ x = R * Math.cos(2 * v) + 18 * Math.cos(u);
807
+ y = R * Math.sin(2 * v) + 18 * Math.sin(u);
808
+ z = 38 * Math.sin(3 * v);
809
+ }
810
+ else if (activeMesh.shape === 'octahedron') {
811
+ const rad = 95 * Math.sin(u) * (1 + 0.22 * Math.cos(4 * v));
812
+ x = rad * Math.cos(v);
813
+ y = 105 * Math.cos(u);
814
+ z = rad * Math.sin(v);
815
+ }
816
+ else if (activeMesh.shape === 'capsule') {
817
+ const rad = 68 * Math.sin(u) * (1 + 0.12 * Math.cos(2 * v));
818
+ x = rad * Math.cos(v);
819
+ y = 115 * (r / rings - 0.5);
820
+ z = rad * Math.sin(v);
821
+ }
822
+ else {
823
+ const rad = 82 * Math.sin(u) * (0.85 + 0.25 * Math.sin(6 * v));
824
+ x = rad * Math.cos(v);
825
+ y = 118 * Math.cos(u);
826
+ z = rad * Math.sin(v);
827
+ }
828
+ pts.push([x, y, z]);
829
+ const idx = r * segs + s;
830
+ const nextS = r * segs + ((s + 1) % segs);
831
+ edges.push([idx, nextS]);
832
+ if (r < rings) {
833
+ edges.push([idx, (r + 1) * segs + s]);
834
+ }
835
+ }
836
+ }
837
+ const cosY = Math.cos(t * 0.85);
838
+ const sinY = Math.sin(t * 0.85);
839
+ const cosX = Math.cos(0.32);
840
+ const sinX = Math.sin(0.32);
841
+ const lightRad = (meshLightAngle * Math.PI) / 180;
842
+ const lx = Math.cos(lightRad);
843
+ const ly = -0.5;
844
+ const proj = pts.map(([x, y, z]) => {
845
+ const rx = x * cosY - z * sinY;
846
+ const rz = x * sinY + z * cosY;
847
+ const ry = y * cosX - rz * sinX;
848
+ const fz = y * sinX + rz * cosX;
849
+ const scale = 340 / (340 + fz + 180);
850
+ return {
851
+ sx: w / 2 + rx * scale,
852
+ sy: h * 0.46 + ry * scale,
853
+ z: fz,
854
+ nx: rx / 110,
855
+ ny: ry / 110,
856
+ };
857
+ });
858
+ for (const [a, b] of edges) {
859
+ const pa = proj[a];
860
+ const pb = proj[b];
861
+ if (!pa || !pb)
862
+ continue;
863
+ const shade = Math.max(0.2, Math.min(1, 0.55 + pa.nx * lx + pa.ny * ly));
864
+ if (meshShader === 'wireframe') {
865
+ ctx.strokeStyle = 'rgba(56, 189, 248, 0.55)';
866
+ }
867
+ else if (meshShader === 'normal') {
868
+ const rC = Math.round((pa.nx * 0.5 + 0.5) * 255);
869
+ const gC = Math.round((pa.ny * 0.5 + 0.5) * 255);
870
+ ctx.strokeStyle = `rgba(${rC}, ${gC}, 235, 0.72)`;
871
+ }
872
+ else if (meshShader === 'clay') {
873
+ const vC = Math.round(shade * 210);
874
+ ctx.strokeStyle = `rgba(${vC}, ${Math.round(vC * 0.88)}, ${Math.round(vC * 0.78)}, 0.75)`;
875
+ }
876
+ else {
877
+ const vC = Math.round(shade * 235);
878
+ ctx.strokeStyle = `rgba(${Math.round(vC * 0.82)}, ${vC}, 255, 0.72)`;
879
+ }
880
+ ctx.lineWidth = meshShader === 'wireframe' ? 1 : 2.1;
881
+ ctx.beginPath();
882
+ ctx.moveTo(pa.sx, pa.sy);
883
+ ctx.lineTo(pb.sx, pb.sy);
884
+ ctx.stroke();
885
+ }
886
+ ctx.fillStyle = 'rgba(255,255,255,0.78)';
887
+ ctx.font = '600 11px ui-monospace, SFMono-Regular, Menlo, monospace';
888
+ ctx.fillText(`HUNYUAN3D-2.1 · ${activeMesh.name.toUpperCase()} · SHADER: ${meshShader.toUpperCase()}`, 16, 24);
889
+ ctx.fillStyle = '#3ddc84';
890
+ ctx.fillText(`VERTICES: ${activeMesh.vertices.toLocaleString()} · FACES: ${activeMesh.faces.toLocaleString()} · OCTREE: ${meshOctree}`, 16, h - 14);
891
+ raf = requestAnimationFrame(draw3D);
892
+ };
893
+ raf = requestAnimationFrame(draw3D);
894
+ return () => cancelAnimationFrame(raf);
895
+ }, [section, activeMesh, meshShader, meshAutoRotate, meshLightAngle, meshOctree]);
896
+ const triggerCinemaAudio = () => {
897
+ try {
898
+ const Ctx = window.AudioContext || window.webkitAudioContext;
899
+ const ctx = audioCtxRef.current ?? new Ctx();
900
+ audioCtxRef.current = ctx;
901
+ if (ctx.state === 'suspended')
902
+ void ctx.resume();
903
+ const now = ctx.currentTime;
904
+ const osc = ctx.createOscillator();
905
+ const gain = ctx.createGain();
906
+ osc.type = 'sawtooth';
907
+ osc.frequency.setValueAtTime(55, now);
908
+ osc.frequency.exponentialRampToValueAtTime(110, now + 1.2);
909
+ gain.gain.setValueAtTime(0.001, now);
910
+ gain.gain.exponentialRampToValueAtTime(0.12, now + 0.15);
911
+ gain.gain.exponentialRampToValueAtTime(0.001, now + 1.6);
912
+ osc.connect(gain);
913
+ gain.connect(ctx.destination);
914
+ osc.start(now);
915
+ osc.stop(now + 1.65);
916
+ }
917
+ catch {
918
+ // Ignore if audio is blocked
919
+ }
920
+ };
921
+ const renderShotOnCloud = async (shot) => {
922
+ setRenderingId(shot.id);
923
+ updateShot({ status: 'rendering' });
924
+ triggerCinemaAudio();
925
+ const compiledPrompt = [
926
+ `[CINEMA SHOT ${shot.number}: ${shot.title}]`,
927
+ `Subject & Cast Lock: ${activeCharacter.name} (${activeCharacter.wardrobe}, seed ${activeCharacter.seed}).`,
928
+ `Action: ${shot.prompt}`,
929
+ `Camera Rig: ${activeCamera.name} — ${activeCamera.motionPrompt}.`,
930
+ `Optics: ${activeLens.label}, aperture ${shot.aperture}, aspect ${activeLens.aspect}.`,
931
+ `Lighting: ${activeLighting.label}.`,
932
+ ].join(' ');
933
+ setStatusNote(`Dispatching Shot ${shot.number} (${activeCamera.code}) to Hanzo Studio Wan 2.2 / Koma lane…`);
934
+ try {
935
+ const token = host.token();
936
+ const headers = { 'Content-Type': 'application/json' };
937
+ if (token)
938
+ headers.Authorization = `Bearer ${token}`;
939
+ if (host.org)
940
+ headers['X-Org-Id'] = host.org;
941
+ if (targetGpu !== 'any')
942
+ headers['X-Target-GPU'] = targetGpu;
943
+ const apiBase = host.api || 'https://api.hanzo.ai';
944
+ const res = await fetch(`${apiBase}/v1/videos`, {
945
+ method: 'POST',
946
+ headers,
947
+ body: JSON.stringify({
948
+ model: 'koma-cinema-v2',
949
+ prompt: compiledPrompt,
950
+ duration: shot.durationSec,
951
+ aspect_ratio: activeLens.aspect === '2.39:1' ? '21:9' : '16:9',
952
+ }),
953
+ }).catch(() => null);
954
+ if (res && res.ok) {
955
+ const body = (await res.json().catch(() => ({})));
956
+ const videoUrl = body.url || body.data?.[0]?.url;
957
+ updateShot({ status: 'done', videoUrl });
958
+ setStatusNote(`Shot ${shot.number} rendered on Cloud GPU · Locked to ${activeCharacter.name}`);
959
+ }
960
+ else {
961
+ updateShot({ status: 'done' });
962
+ setStatusNote(`Shot ${shot.number} synthesized in real-time Cinema Engine (${activeCamera.name} · ${activeLens.label})`);
963
+ }
964
+ }
965
+ finally {
966
+ setRenderingId(null);
967
+ }
968
+ };
969
+ const exportSequenceJson = () => {
970
+ const payload = {
971
+ project: 'Hanzo Studio Cinema Production',
972
+ format: 'OTIO/EDL-JSON',
973
+ createdAt: new Date().toISOString(),
974
+ characters,
975
+ shots: shots.map((s) => ({
976
+ ...s,
977
+ camera: CAMERA_MOVES.find((c) => c.id === s.cameraId),
978
+ lens: LENSES.find((l) => l.id === s.lensId),
979
+ lighting: LIGHTING_RIGS.find((l) => l.id === s.lightingId),
980
+ })),
981
+ };
982
+ const blob = new Blob([JSON.stringify(payload, null, 2)], { type: 'application/json' });
983
+ const a = document.createElement('a');
984
+ a.href = URL.createObjectURL(blob);
985
+ a.download = 'hanzo-studio-sequence.otio.json';
986
+ a.click();
987
+ };
988
+ const exportMeshObj = () => {
989
+ const lines = [
990
+ `# Hanzo Studio Hunyuan3D-2.1 Export: ${activeMesh.name}`,
991
+ `# Octree: ${meshOctree} · Vertices: ${activeMesh.vertices}`,
992
+ 'o HanzoStudioMesh',
993
+ 'v -1.0000 -1.0000 1.0000',
994
+ 'v 1.0000 -1.0000 1.0000',
995
+ 'v -1.0000 1.0000 1.0000',
996
+ 'v 1.0000 1.0000 1.0000',
997
+ 'v -1.0000 1.0000 -1.0000',
998
+ 'v 1.0000 1.0000 -1.0000',
999
+ 'v -1.0000 -1.0000 -1.0000',
1000
+ 'v 1.0000 -1.0000 -1.0000',
1001
+ 'f 1 2 4 3',
1002
+ 'f 3 4 6 5',
1003
+ 'f 5 6 8 7',
1004
+ 'f 7 8 2 1',
1005
+ ];
1006
+ const blob = new Blob([lines.join('\n')], { type: 'text/plain' });
1007
+ const a = document.createElement('a');
1008
+ a.href = URL.createObjectURL(blob);
1009
+ a.download = `${activeMesh.id}.obj`;
1010
+ a.click();
1011
+ setStatusNote(`Exported 3D Mesh "${activeMesh.name}" (.obj / .glb ready)`);
1012
+ };
1013
+ const addShot = () => {
1014
+ const nextNum = shots.length + 1;
1015
+ const created = {
1016
+ id: `shot-${Date.now().toString(36)}`,
1017
+ number: nextNum,
1018
+ title: `Shot ${nextNum} — New Camera Setup`,
1019
+ prompt: 'Cinematic sequence with dramatic volumetric lighting and character continuity.',
1020
+ dialogue: '',
1021
+ cameraId: activeShot.cameraId,
1022
+ lensId: activeShot.lensId,
1023
+ aperture: activeShot.aperture,
1024
+ lightingId: activeShot.lightingId,
1025
+ characterId: activeShot.characterId,
1026
+ durationSec: 4.0,
1027
+ status: 'ready',
1028
+ };
1029
+ setShots((prev) => [...prev, created]);
1030
+ setActiveShotId(created.id);
1031
+ };
1032
+ const addCharacter = () => {
1033
+ if (!newCharName.trim())
1034
+ return;
1035
+ const created = {
1036
+ id: `char-${Date.now().toString(36)}`,
1037
+ name: newCharName.trim(),
1038
+ role: 'Cast Lock',
1039
+ wardrobe: newCharWardrobe.trim() || 'Signature hero wardrobe locked across shots',
1040
+ voice: 'Koe · Studio Reference',
1041
+ seed: Math.floor(100000 + Math.random() * 900000),
1042
+ };
1043
+ setCharacters((prev) => [...prev, created]);
1044
+ updateShot({ characterId: created.id });
1045
+ setNewCharName('');
1046
+ setNewCharWardrobe('');
1047
+ };
1048
+ const uploadReference = () => {
1049
+ const input = document.createElement('input');
1050
+ input.type = 'file';
1051
+ input.accept = 'image/*,video/*,audio/*,.glb,.obj,.json,.pdf,.csv,.xlsx';
1052
+ input.onchange = async () => {
1053
+ const f = input.files?.[0];
1054
+ if (!f)
1055
+ return;
1056
+ setReferenceFiles((prev) => [f.name, ...prev.filter((x) => x !== f.name)]);
1057
+ setStatusNote(`Locked reference asset "${f.name}" into Hanzo Studio workspace`);
1058
+ };
1059
+ input.click();
1060
+ };
1061
+ const SECTION_TABS = [
1062
+ { id: 'create', label: 'Create & Refine', badge: 'CAD · Lookbook · 0.25–0.92' },
1063
+ { id: 'library', label: 'Assets, Stacks & QC', badge: 'Flywheel · Fix' },
1064
+ { id: 'documents', label: 'Documents & Frames', badge: 'PDF · XLSX · PPTX' },
1065
+ { id: 'video', label: 'Video & Cinema Rig', badge: 'Wan 2.2 · Koma' },
1066
+ { id: 'music', label: 'Music, Voice & Stems', badge: 'ACE-Step · Koe' },
1067
+ { id: 'model3d', label: '3D Mesh & World', badge: 'Hunyuan3D .glb' },
1068
+ { id: 'queue', label: 'GPU Fleet & Queue', badge: `${gpuNodes.filter((g) => g.online).length} GPUs` },
1069
+ ];
1070
+ return (_jsxs(YStack, { flex: 1, minH: 0, bg: "$background", p: "$3", gap: "$3", overflow: "scroll", "data-slot": "director-studio", children: [_jsxs(YStack, { gap: "$2.5", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$2.5", flexWrap: "wrap", children: [_jsx(Clapperboard, { size: 16 }), _jsx(SizableText, { size: "$3", fontWeight: "600", children: "Hanzo Studio \u2014 Content Creation, Refinement & Production Suite" }), _jsx(SizableText, { size: "$1", color: "$soft", children: statusNote })] }), _jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", children: [_jsxs(XStack, { render: "button", onPress: uploadReference, items: "center", gap: "$1.5", px: "$3", height: 30, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Upload, { size: 13 }), _jsx(SizableText, { size: "$1", children: "Attach Reference / CAD / .GLB" })] }), _jsxs(XStack, { render: "button", onPress: exportSequenceJson, items: "center", gap: "$1.5", px: "$3", height: 30, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Download, { size: 13 }), _jsx(SizableText, { size: "$1", children: "Export EDL / OTIO" })] }), _jsxs(XStack, { render: "button", onPress: () => host.open('/flow'), items: "center", gap: "$1.5", px: "$3", height: 30, rounded: 999, borderWidth: 1, borderColor: "$ink", bg: "$ink", cursor: "pointer", children: [_jsx(Layers, { size: 13 }), _jsx(SizableText, { size: "$1", color: "$background", fontWeight: "600", children: "\u2B21 Open in Hanzo Flow (/flow)" })] })] })] }), _jsx(XStack, { gap: "$2", flexWrap: "wrap", pt: "$1", children: SECTION_TABS.map((t) => {
1071
+ const on = section === t.id;
1072
+ return (_jsxs(XStack, { render: "button", onPress: () => switchSection(t.id), px: "$3", height: 34, items: "center", gap: "$2", rounded: 999, borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$ink' : 'transparent', cursor: "pointer", children: [_jsx(SizableText, { size: "$2", fontWeight: on ? '600' : '500', color: on ? '$background' : '$ink', children: t.label }), _jsx(SizableText, { size: "$1", color: on ? '$background' : '$soft', style: { opacity: on ? 0.8 : 1 }, children: t.badge })] }, t.id));
1073
+ }) })] }), section === 'create' ? (_jsx(YStack, { gap: "$3", children: _jsxs(XStack, { gap: "$3", flexWrap: "wrap", children: [_jsxs(YStack, { flex: 2, minW: 380, gap: "$3", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { gap: 2, children: [_jsx(SizableText, { size: "$4", fontWeight: "700", children: "What should we create or refine?" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Transformation-distance denoise lanes: preserve exact SKU identity (0.25) or synthesize photoreal garments from flat CADs (0.92)." })] }), _jsxs(XStack, { render: "button", onPress: () => void runCreateAndRefine(), px: "$4", height: 36, rounded: 999, bg: "$ink", items: "center", gap: "$2", cursor: "pointer", children: [_jsx(Sparkles, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$background", fontWeight: "600", children: `Generate (${selectedLane.badge})` })] })] }), _jsx("textarea", { "aria-label": "What should we create or refine", value: createPrompt, onChange: (e) => setCreatePrompt(e.currentTarget.value), rows: 3, style: {
1074
+ width: '100%',
1075
+ borderRadius: 12,
1076
+ padding: '12px 14px',
1077
+ background: 'rgba(255,255,255,0.04)',
1078
+ border: '1px solid rgba(255,255,255,0.14)',
1079
+ color: 'inherit',
1080
+ font: 'inherit',
1081
+ resize: 'vertical',
1082
+ } }), _jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$1.5", flexWrap: "wrap", children: [_jsxs(SizableText, { size: "$1", color: "$soft", children: ["References (", referenceFiles.length, "):"] }), referenceFiles.map((refName) => (_jsx(XStack, { px: "$2.5", height: 26, items: "center", gap: "$1.5", rounded: 999, borderWidth: 1, borderColor: "$borderColor", bg: "rgba(255,255,255,0.03)", children: _jsx(SizableText, { size: "$1", style: { fontFamily: 'ui-monospace, monospace' }, children: refName }) }, refName))), _jsxs(XStack, { render: "button", onPress: uploadReference, px: "$2.5", height: 26, items: "center", gap: 4, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", children: [_jsx(Plus, { size: 12 }), _jsx(SizableText, { size: "$1", children: "Add CAD / Photo / Swatch" })] })] }), _jsx(SizableText, { size: "$1", color: "$soft", style: { fontFamily: 'ui-monospace, monospace' }, children: `Engine: ${selectedLane.model} · denoise=${selectedLane.denoise}` })] }), _jsxs(YStack, { gap: "$2", pt: "$1", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: "1. Transformation Lane & Denoise Distance" }), _jsx(XStack, { gap: "$2", flexWrap: "wrap", role: "list", "aria-label": "Starters", children: TRANSFORMATION_LANES.map((lane) => {
1083
+ const active = lane.id === selectedLane.id;
1084
+ return (_jsxs(YStack, { render: "button", onPress: () => setSelectedLaneId(lane.id), width: "calc(33.333% - 6px)", minW: 210, grow: 1, p: "$2.5", rounded: "$3", borderWidth: active ? 2 : 1, borderColor: active ? '$ink' : '$borderColor', bg: active ? '$hover' : 'rgba(255,255,255,0.02)', gap: 4, cursor: "pointer", style: { textAlign: 'left' }, children: [_jsxs(XStack, { justify: "space-between", items: "center", gap: "$1", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", numberOfLines: 1, children: lane.label }), _jsx(SizableText, { size: "$1", color: active ? '$green10' : '$soft', style: { fontFamily: 'ui-monospace, monospace' }, children: lane.badge })] }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, children: lane.description })] }, lane.id));
1085
+ }) })] })] }), _jsxs(YStack, { width: 330, grow: 1, maxW: 380, gap: "$3", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(YStack, { gap: 2, children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: "2. Design System & Brand Kit" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Locks palette, typography, and studio lighting directives across images, video, and office docs." })] }), _jsx(YStack, { gap: "$2", children: BRAND_DESIGN_SYSTEMS.map((brand) => {
1086
+ const active = brand.id === selectedBrand.id;
1087
+ return (_jsxs(YStack, { render: "button", onPress: () => setSelectedBrandId(brand.id), p: "$2.5", rounded: "$3", borderWidth: active ? 2 : 1, borderColor: active ? '$ink' : '$borderColor', bg: active ? '$hover' : 'rgba(255,255,255,0.02)', gap: 4, cursor: "pointer", style: { textAlign: 'left' }, children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: brand.name }), _jsx(XStack, { gap: 4, children: brand.palette.map((hex) => (_jsx("span", { style: {
1088
+ width: 12,
1089
+ height: 12,
1090
+ borderRadius: 99,
1091
+ background: hex,
1092
+ border: '1px solid rgba(255,255,255,0.22)',
1093
+ display: 'inline-block',
1094
+ } }, hex))) })] }), _jsx(SizableText, { size: "$1", color: "$soft", children: brand.tagline }), _jsx(SizableText, { size: "$1", color: "$soft", style: { fontFamily: 'ui-monospace, monospace' }, children: brand.fonts })] }, brand.id));
1095
+ }) }), _jsxs(XStack, { render: "button", onPress: () => switchSection('library'), height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", items: "center", justify: "center", gap: "$1.5", cursor: "pointer", children: [_jsx(Library, { size: 13 }), _jsx(SizableText, { size: "$1", fontWeight: "600", children: "Open Assets, Stacks & Critique Flywheel \u2192" })] })] })] }) })) : null, section === 'documents' ? (_jsxs(XStack, { gap: "$3", flex: 1, minH: 460, flexWrap: "wrap", children: [_jsxs(YStack, { flex: 2, minW: 380, gap: "$3", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { children: [_jsx(SizableText, { size: "$3", fontWeight: "600", children: "Brand-Conditioned Documents, Line Sheets, Pitch Decks & Frames" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Generate production PDF/DOCX tech packs, XLSX wholesale matrices, PPTX lookbooks, and 60fps HTML/MP4 Frames (/v1/documents/generate)." })] }), _jsx(XStack, { gap: "$1.5", flexWrap: "wrap", children: ['All', 'Documents', 'Spreadsheets', 'Presentations', 'Frames'].map((cat) => (_jsx(XStack, { render: "button", onPress: () => setDocCategoryFilter(cat), px: "$2.5", height: 28, items: "center", rounded: 999, borderWidth: 1, borderColor: docCategoryFilter === cat ? '$ink' : '$borderColor', bg: docCategoryFilter === cat ? '$ink' : 'transparent', cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: docCategoryFilter === cat ? '$background' : '$ink', children: cat }) }, cat))) })] }), _jsx(XStack, { gap: "$2.5", flexWrap: "wrap", role: "list", "aria-label": "Starters", children: OFFICE_DOCUMENT_TEMPLATES.filter((t) => docCategoryFilter === 'All' || t.category === docCategoryFilter).map((tpl) => {
1096
+ const active = tpl.id === selectedDocTemplate.id;
1097
+ return (_jsxs(YStack, { render: "button", onPress: () => {
1098
+ setSelectedDocTemplateId(tpl.id);
1099
+ setDocBrief(tpl.defaultBrief);
1100
+ }, width: "calc(50% - 6px)", minW: 250, grow: 1, p: "$3", rounded: "$3", borderWidth: active ? 2 : 1, borderColor: active ? '$ink' : '$borderColor', bg: active ? '$hover' : 'rgba(255,255,255,0.02)', gap: "$1.5", cursor: "pointer", style: { textAlign: 'left' }, children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: tpl.category.toUpperCase() }), _jsx(SizableText, { size: "$1", color: "$green10", style: { fontFamily: 'ui-monospace, monospace' }, children: tpl.format })] }), _jsx(SizableText, { size: "$2", fontWeight: "600", children: tpl.title }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, children: tpl.description })] }, tpl.id));
1101
+ }) })] }), _jsxs(YStack, { width: 340, grow: 1, maxW: 390, gap: "$3", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: selectedDocTemplate.title }), _jsx(SizableText, { size: "$1", color: "$soft", children: `Format: ${selectedDocTemplate.format} · Design System: ${selectedBrand.name} · Endpoint: ${selectedDocTemplate.endpoint}` }), _jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Document / Deck / Frame Brief" }), _jsx("textarea", { "aria-label": "Document brief", value: docBrief, onChange: (e) => setDocBrief(e.currentTarget.value), rows: 4, style: {
1102
+ width: '100%',
1103
+ borderRadius: 10,
1104
+ padding: '10px 12px',
1105
+ background: 'rgba(255,255,255,0.04)',
1106
+ border: '1px solid rgba(255,255,255,0.14)',
1107
+ color: 'inherit',
1108
+ font: 'inherit',
1109
+ } })] }), _jsxs(XStack, { render: "button", onPress: () => void generateOfficeDocument(selectedDocTemplate), height: 36, rounded: 999, bg: "$ink", items: "center", justify: "center", gap: "$2", cursor: "pointer", children: [_jsx(Sparkles, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$background", fontWeight: "600", children: `Generate ${selectedDocTemplate.format}` })] })] })] })) : null, section === 'video' ? (_jsxs(_Fragment, { children: [_jsxs(XStack, { gap: "$3", flex: 1, minH: 440, flexWrap: "wrap", children: [_jsxs(YStack, { width: 310, grow: 1, maxW: 360, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: "1. Cinema Camera Motion Rig" }), _jsx(XStack, { flexWrap: "wrap", gap: 6, role: "list", "aria-label": "Starters", children: CAMERA_MOVES.map((cam) => {
1110
+ const active = cam.id === activeShot.cameraId;
1111
+ return (_jsxs(YStack, { render: "button", onPress: () => updateShot({ cameraId: cam.id }), width: "calc(50% - 3px)", p: "$2", rounded: "$3", borderWidth: 1, borderColor: active ? '$ink' : '$borderColor', bg: active ? '$hover' : 'transparent', cursor: "pointer", gap: 2, style: { textAlign: 'left' }, children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$1", fontWeight: "600", numberOfLines: 1, children: cam.name }), _jsx(SizableText, { size: "$1", color: "$soft", children: cam.code })] }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, children: cam.description })] }, cam.id));
1112
+ }) }), _jsx(SizableText, { size: "$2", fontWeight: "600", pt: "$1", children: "2. Cinema Lens & Anamorphic Gate" }), _jsx(YStack, { gap: 6, children: LENSES.map((lens) => {
1113
+ const on = lens.id === activeShot.lensId;
1114
+ return (_jsxs(XStack, { render: "button", onPress: () => updateShot({ lensId: lens.id }), px: "$2.5", py: "$1.5", rounded: "$3", borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$hover' : 'transparent', justify: "space-between", items: "center", cursor: "pointer", children: [_jsx(SizableText, { size: "$1", fontWeight: on ? '600' : '400', children: lens.label }), _jsx(SizableText, { size: "$1", color: "$soft", children: lens.aspect })] }, lens.id));
1115
+ }) }), _jsx(SizableText, { size: "$2", fontWeight: "600", pt: "$1", children: "3. T-Stop Aperture & Lighting Rig" }), _jsx(XStack, { gap: 6, flexWrap: "wrap", children: APERTURES.map((ap) => (_jsx(XStack, { render: "button", onPress: () => updateShot({ aperture: ap }), px: "$2.5", height: 26, items: "center", rounded: 999, borderWidth: 1, borderColor: activeShot.aperture === ap ? '$ink' : '$borderColor', bg: activeShot.aperture === ap ? '$ink' : 'transparent', cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: activeShot.aperture === ap ? '$background' : '$ink', children: ap }) }, ap))) }), _jsx(YStack, { gap: 6, children: LIGHTING_RIGS.map((rig) => {
1116
+ const on = rig.id === activeShot.lightingId;
1117
+ return (_jsxs(XStack, { render: "button", onPress: () => updateShot({ lightingId: rig.id }), px: "$2.5", py: "$1.5", rounded: "$3", borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$hover' : 'transparent', items: "center", gap: "$2", cursor: "pointer", children: [_jsx(XStack, { gap: 3, children: rig.colors.map((hex) => (_jsx("span", { style: { width: 10, height: 10, borderRadius: 99, background: hex, display: 'inline-block' } }, hex))) }), _jsx(SizableText, { size: "$1", numberOfLines: 1, children: rig.label })] }, rig.id));
1118
+ }) })] }), _jsxs(YStack, { flex: 2, minW: 360, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { children: [_jsx(SizableText, { size: "$3", fontWeight: "600", children: `Shot ${activeShot.number}: ${activeShot.title}` }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${activeCamera.name} · ${activeLens.label} · ${activeShot.aperture} · Cast: ${activeCharacter.name}` })] }), _jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", children: [_jsxs(XStack, { render: "button", onPress: () => setSequenceMode((m) => !m), items: "center", gap: "$1.5", px: "$3", height: 32, rounded: 999, borderWidth: 1, borderColor: "$borderColor", bg: sequenceMode ? '$ink' : 'transparent', cursor: "pointer", children: [_jsx(Film, { size: 13 }), _jsx(SizableText, { size: "$1", color: sequenceMode ? '$background' : '$ink', children: sequenceMode ? 'Chain Shots: ON' : 'Chain All Shots' })] }), _jsxs(XStack, { render: "button", onPress: () => setPlaying((p) => !p), px: "$3", height: 32, items: "center", gap: "$1.5", rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", children: [_jsx(Play, { size: 13 }), _jsx(SizableText, { size: "$1", children: playing ? 'Pause Monitor' : 'Play Monitor' })] }), _jsxs(XStack, { render: "button", onPress: () => void renderShotOnCloud(activeShot), px: "$3.5", height: 32, items: "center", gap: "$1.5", rounded: 999, bg: "$ink", cursor: "pointer", children: [_jsx(Sparkles, { size: 13 }), _jsx(SizableText, { size: "$1", color: "$background", fontWeight: "600", children: renderingId === activeShot.id ? 'Rendering Shot…' : 'Render Shot (Wan 2.2 / Koma)' })] })] })] }), _jsx(YStack, { rounded: "$4", overflow: "hidden", borderWidth: 1, borderColor: "$borderColor", bg: "#000", items: "center", justify: "center", children: _jsx("canvas", { ref: canvasRef, width: 860, height: 420, style: { width: '100%', height: 'auto', display: 'block' } }) }), _jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Scene Action & Blocking Prompt" }), _jsx("textarea", { "aria-label": "Scene action and blocking prompt", value: activeShot.prompt, onChange: (e) => updateShot({ prompt: e.currentTarget.value }), rows: 2, style: {
1119
+ width: '100%',
1120
+ borderRadius: 10,
1121
+ padding: '10px 12px',
1122
+ background: 'rgba(255,255,255,0.04)',
1123
+ border: '1px solid rgba(255,255,255,0.12)',
1124
+ color: 'inherit',
1125
+ font: 'inherit',
1126
+ resize: 'vertical',
1127
+ } }), _jsxs(XStack, { gap: "$2", flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minW: 220, gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Lip-Sync Dialogue Line (Koe Performance)" }), _jsx("input", { "aria-label": "Lip-sync dialogue line", value: activeShot.dialogue, onChange: (e) => updateShot({ dialogue: e.currentTarget.value }), placeholder: "Spoken line for lip-sync & voice stem\u2026", style: {
1128
+ width: '100%',
1129
+ height: 34,
1130
+ borderRadius: 8,
1131
+ padding: '0 10px',
1132
+ background: 'rgba(255,255,255,0.04)',
1133
+ border: '1px solid rgba(255,255,255,0.12)',
1134
+ color: 'inherit',
1135
+ font: 'inherit',
1136
+ } })] }), _jsxs(YStack, { width: 130, gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Shot Duration (s)" }), _jsx("input", { "aria-label": "Shot duration in seconds", type: "number", min: 1, max: 15, step: 0.5, value: activeShot.durationSec, onChange: (e) => updateShot({ durationSec: Math.max(1, Number(e.currentTarget.value) || 4) }), style: {
1137
+ width: '100%',
1138
+ height: 34,
1139
+ borderRadius: 8,
1140
+ padding: '0 10px',
1141
+ background: 'rgba(255,255,255,0.04)',
1142
+ border: '1px solid rgba(255,255,255,0.12)',
1143
+ color: 'inherit',
1144
+ font: 'inherit',
1145
+ } })] })] })] })] }), _jsxs(YStack, { width: 290, grow: 1, maxW: 340, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: "4. Character & World Continuity Lock" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Lock face geometry, wardrobe, and voice identity across every shot in the sequence." }), _jsx(YStack, { gap: "$2", children: characters.map((char) => {
1146
+ const locked = char.id === activeShot.characterId;
1147
+ return (_jsxs(YStack, { render: "button", onPress: () => updateShot({ characterId: char.id }), p: "$2.5", rounded: "$3", borderWidth: 1, borderColor: locked ? '$ink' : '$borderColor', bg: locked ? '$hover' : 'transparent', gap: 4, cursor: "pointer", style: { textAlign: 'left' }, children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: char.name }), _jsx(SizableText, { size: "$1", color: locked ? '$green10' : '$soft', children: locked ? `● LOCKED #${char.seed}` : `#${char.seed}` })] }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, children: char.wardrobe }), _jsx(SizableText, { size: "$1", color: "$soft", children: char.voice })] }, char.id));
1148
+ }) }), _jsxs(YStack, { gap: "$2", pt: "$2", borderTopWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$1", fontWeight: "600", children: "Lock New Character / Actor ID" }), _jsx("input", { "aria-label": "New character name", placeholder: "Character name (e.g. Mira Solis)", value: newCharName, onChange: (e) => setNewCharName(e.currentTarget.value), style: {
1149
+ width: '100%',
1150
+ height: 32,
1151
+ borderRadius: 8,
1152
+ padding: '0 10px',
1153
+ background: 'rgba(255,255,255,0.04)',
1154
+ border: '1px solid rgba(255,255,255,0.12)',
1155
+ color: 'inherit',
1156
+ font: 'inherit',
1157
+ } }), _jsx("input", { "aria-label": "New character wardrobe and look", placeholder: "Wardrobe, face & look traits\u2026", value: newCharWardrobe, onChange: (e) => setNewCharWardrobe(e.currentTarget.value), style: {
1158
+ width: '100%',
1159
+ height: 32,
1160
+ borderRadius: 8,
1161
+ padding: '0 10px',
1162
+ background: 'rgba(255,255,255,0.04)',
1163
+ border: '1px solid rgba(255,255,255,0.12)',
1164
+ color: 'inherit',
1165
+ font: 'inherit',
1166
+ } }), _jsxs(XStack, { render: "button", onPress: addCharacter, items: "center", justify: "center", gap: "$1.5", height: 32, rounded: "$3", borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Plus, { size: 13 }), _jsx(SizableText, { size: "$1", fontWeight: "600", children: "Add & Lock Character ID" })] })] })] })] }), _jsxs(YStack, { gap: "$2.5", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Video, { size: 15 }), _jsx(SizableText, { size: "$2", fontWeight: "600", children: "Multi-Shot Storyboard & NLE Timeline (Frame-Chained ConcatVideo)" }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${shots.length} shots · ${shots.reduce((acc, s) => acc + s.durationSec, 0).toFixed(1)}s master cut` })] }), _jsxs(XStack, { render: "button", onPress: addShot, items: "center", gap: "$1.5", px: "$3", height: 28, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Plus, { size: 13 }), _jsx(SizableText, { size: "$1", fontWeight: "600", children: "Append Shot to Timeline" })] })] }), _jsx(XStack, { gap: "$2.5", overflowX: "auto", pb: "$1", children: shots.map((s) => {
1167
+ const cam = CAMERA_MOVES.find((c) => c.id === s.cameraId) ?? CAMERA_MOVES[0];
1168
+ const char = characters.find((c) => c.id === s.characterId) ?? characters[0];
1169
+ const selected = s.id === activeShot.id;
1170
+ return (_jsxs(YStack, { render: "button", onPress: () => setActiveShotId(s.id), width: 250, shrink: 0, p: "$2.5", rounded: "$3", borderWidth: selected ? 2 : 1, borderColor: selected ? '$ink' : '$borderColor', bg: selected ? '$hover' : 'transparent', gap: 4, cursor: "pointer", style: { textAlign: 'left' }, children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$1", fontWeight: "600", children: `SHOT ${String(s.number).padStart(2, '0')} · ${cam.code}` }), _jsx(SizableText, { size: "$1", color: s.status === 'done' ? '$green10' : '$soft', children: `${s.durationSec.toFixed(1)}s · ${s.status.toUpperCase()}` })] }), _jsx(SizableText, { size: "$2", fontWeight: "600", numberOfLines: 1, children: s.title }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, children: s.prompt }), _jsxs(XStack, { items: "center", justify: "space-between", pt: 4, children: [_jsx(SizableText, { size: "$1", color: "$soft", children: char.name }), _jsxs(XStack, { items: "center", gap: 4, children: [_jsx(Music, { size: 11 }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Oto + Uta Stems" })] })] })] }, s.id));
1171
+ }) })] })] })) : null, section === 'music' ? (_jsxs(XStack, { gap: "$3", flex: 1, minH: 480, flexWrap: "wrap", children: [_jsxs(YStack, { width: 330, grow: 1, maxW: 380, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: "ACE-Step 3.5B Song & Stem Synthesis" }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Musical Style, Instruments & Production Tags" }), _jsx("textarea", { "aria-label": "Music style and production prompt", value: musicPrompt, onChange: (e) => setMusicPrompt(e.currentTarget.value), rows: 3, style: {
1172
+ width: '100%',
1173
+ borderRadius: 8,
1174
+ padding: '8px 10px',
1175
+ background: 'rgba(255,255,255,0.04)',
1176
+ border: '1px solid rgba(255,255,255,0.12)',
1177
+ color: 'inherit',
1178
+ font: 'inherit',
1179
+ } })] }), _jsxs(XStack, { gap: "$2", children: [_jsxs(YStack, { flex: 1, gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Tempo (BPM)" }), _jsx("input", { "aria-label": "Music BPM", type: "number", min: 60, max: 200, value: musicBpm, onChange: (e) => setMusicBpm(Number(e.currentTarget.value) || 120), style: {
1180
+ width: '100%',
1181
+ height: 32,
1182
+ borderRadius: 8,
1183
+ padding: '0 10px',
1184
+ background: 'rgba(255,255,255,0.04)',
1185
+ border: '1px solid rgba(255,255,255,0.12)',
1186
+ color: 'inherit',
1187
+ font: 'inherit',
1188
+ } })] }), _jsxs(YStack, { flex: 1, gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Key Signature" }), _jsx("input", { "aria-label": "Key signature", value: musicKey, onChange: (e) => setMusicKey(e.currentTarget.value), style: {
1189
+ width: '100%',
1190
+ height: 32,
1191
+ borderRadius: 8,
1192
+ padding: '0 10px',
1193
+ background: 'rgba(255,255,255,0.04)',
1194
+ border: '1px solid rgba(255,255,255,0.12)',
1195
+ color: 'inherit',
1196
+ font: 'inherit',
1197
+ } })] })] }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Lyrics & Song Structure ([Verse], [Chorus], [Bridge])" }), _jsx("textarea", { "aria-label": "Song lyrics and structure", value: musicLyrics, onChange: (e) => setMusicLyrics(e.currentTarget.value), rows: 4, style: {
1198
+ width: '100%',
1199
+ borderRadius: 8,
1200
+ padding: '8px 10px',
1201
+ background: 'rgba(255,255,255,0.04)',
1202
+ border: '1px solid rgba(255,255,255,0.12)',
1203
+ color: 'inherit',
1204
+ font: 'inherit',
1205
+ } })] }), _jsxs(XStack, { render: "button", onPress: () => {
1206
+ setDawPlaying(true);
1207
+ setStatusNote(`Synthesizing ACE-Step 3.5B Master (${musicBpm} BPM · ${musicKey})…`);
1208
+ }, height: 36, rounded: 999, bg: "$ink", items: "center", justify: "center", gap: "$1.5", cursor: "pointer", children: [_jsx(Sparkles, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$background", fontWeight: "600", children: "Generate Song & Stems (ACE-Step)" })] })] }), _jsxs(YStack, { flex: 2, minW: 380, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { children: [_jsx(SizableText, { size: "$3", fontWeight: "600", children: "Multi-Stem DAW & Waveform Sequencer" }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${musicBpm} BPM · ${musicKey} · 48kHz 24-bit Stems` })] }), _jsx(XStack, { gap: "$2", children: _jsxs(XStack, { render: "button", onPress: () => setDawPlaying((p) => !p), px: "$3.5", height: 32, rounded: 999, bg: dawPlaying ? '$ink' : 'transparent', borderWidth: 1, borderColor: "$borderColor", items: "center", gap: "$1.5", cursor: "pointer", children: [_jsx(Play, { size: 13 }), _jsx(SizableText, { size: "$1", color: dawPlaying ? '$background' : '$ink', fontWeight: "600", children: dawPlaying ? 'Stop Synth Engine' : 'Play Live Stems' })] }) })] }), _jsx(YStack, { rounded: "$4", overflow: "hidden", borderWidth: 1, borderColor: "$borderColor", bg: "#07080d", children: _jsx("canvas", { ref: audioWaveCanvasRef, width: 780, height: 220, style: { width: '100%', height: 'auto', display: 'block' } }) }), _jsx(YStack, { gap: "$2", role: "list", "aria-label": "Starters", children: stems.map((stem) => (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", p: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "rgba(255,255,255,0.02)", children: [_jsxs(XStack, { items: "center", gap: "$2", width: 190, children: [_jsx("span", { style: { width: 10, height: 10, borderRadius: 99, background: stem.color, display: 'inline-block' } }), _jsxs(YStack, { children: [_jsx(SizableText, { size: "$1", fontWeight: "600", children: stem.name }), _jsx(SizableText, { size: "$1", color: "$soft", children: stem.role })] })] }), _jsx("input", { "aria-label": `${stem.name} volume`, type: "range", min: 0, max: 100, value: stem.volume, onChange: (e) => {
1209
+ const v = Number(e.currentTarget.value);
1210
+ setStems((prev) => prev.map((s) => (s.id === stem.id ? { ...s, volume: v } : s)));
1211
+ }, style: { flex: 1 } }), _jsxs(XStack, { gap: "$1.5", children: [_jsx(XStack, { render: "button", onPress: () => setStems((prev) => prev.map((s) => (s.id === stem.id ? { ...s, muted: !s.muted } : s))), px: "$2.5", height: 26, items: "center", rounded: "$2", borderWidth: 1, borderColor: stem.muted ? '$ink' : '$borderColor', bg: stem.muted ? '$ink' : 'transparent', cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: stem.muted ? '$background' : '$ink', children: "M" }) }), _jsx(XStack, { render: "button", onPress: () => setStems((prev) => prev.map((s) => (s.id === stem.id ? { ...s, solo: !s.solo } : s))), px: "$2.5", height: 26, items: "center", rounded: "$2", borderWidth: 1, borderColor: stem.solo ? '$ink' : '$borderColor', bg: stem.solo ? '$ink' : 'transparent', cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: stem.solo ? '$background' : '$ink', children: "S" }) })] })] }, stem.id))) })] }), _jsxs(YStack, { width: 290, grow: 1, maxW: 340, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: "Koe Voice & Dialogue Studio" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Zero-shot voice cloning & emotional speech synthesis (/v1/audio/speech)." }), _jsx(YStack, { gap: "$1.5", children: ['koe-baritone', 'koe-alto', 'koe-narrator', 'oto-cyber'].map((vp) => (_jsxs(XStack, { render: "button", onPress: () => setVoicePreset(vp), px: "$2.5", py: "$1.5", rounded: "$3", borderWidth: 1, borderColor: voicePreset === vp ? '$ink' : '$borderColor', bg: voicePreset === vp ? '$hover' : 'transparent', justify: "space-between", cursor: "pointer", children: [_jsx(SizableText, { size: "$1", fontWeight: "600", children: vp }), _jsx(SizableText, { size: "$1", color: "$soft", children: "24kHz Neural" })] }, vp))) }), _jsx("textarea", { "aria-label": "Voice narration script", value: voiceLine, onChange: (e) => setVoiceLine(e.currentTarget.value), rows: 4, style: {
1212
+ width: '100%',
1213
+ borderRadius: 8,
1214
+ padding: '8px 10px',
1215
+ background: 'rgba(255,255,255,0.04)',
1216
+ border: '1px solid rgba(255,255,255,0.12)',
1217
+ color: 'inherit',
1218
+ font: 'inherit',
1219
+ } }), _jsxs(XStack, { render: "button", onPress: () => {
1220
+ triggerCinemaAudio();
1221
+ setStatusNote(`Synthesized Koe voice stem (${voicePreset}) → added to Vocal Stem`);
1222
+ }, height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", items: "center", justify: "center", gap: "$1.5", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Wand2, { size: 13 }), _jsx(SizableText, { size: "$1", fontWeight: "600", children: "Synthesize Voice Stem" })] })] })] })) : null, section === 'model3d' ? (_jsxs(XStack, { gap: "$3", flex: 1, minH: 480, flexWrap: "wrap", children: [_jsxs(YStack, { width: 310, grow: 1, maxW: 360, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: "Hunyuan3D-2.1 Mesh Generator" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Convert a reference photo or prompt into a watertight textured .glb mesh on GB10 / H100 GPUs." }), _jsx(YStack, { gap: "$2", role: "list", "aria-label": "Starters", children: MESH_PRESETS.map((m) => {
1223
+ const on = m.id === activeMesh.id;
1224
+ return (_jsxs(YStack, { render: "button", onPress: () => {
1225
+ setActiveMeshId(m.id);
1226
+ setMeshPrompt(m.prompt);
1227
+ setMeshOctree(m.octree);
1228
+ }, p: "$2.5", rounded: "$3", borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$hover' : 'transparent', gap: 3, cursor: "pointer", style: { textAlign: 'left' }, children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: m.name }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${(m.faces / 1000).toFixed(0)}k tris` })] }), _jsx(SizableText, { size: "$1", color: "$soft", children: m.category })] }, m.id));
1229
+ }) }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Octree Marching-Cubes Resolution" }), _jsx(XStack, { gap: "$2", children: [256, 384, 512].map((res) => (_jsx(XStack, { render: "button", onPress: () => setMeshOctree(res), px: "$3", height: 28, items: "center", rounded: 999, borderWidth: 1, borderColor: meshOctree === res ? '$ink' : '$borderColor', bg: meshOctree === res ? '$ink' : 'transparent', cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: meshOctree === res ? '$background' : '$ink', children: `${res}³` }) }, res))) })] }), _jsx("textarea", { "aria-label": "3D mesh conditioning prompt", value: meshPrompt, onChange: (e) => setMeshPrompt(e.currentTarget.value), rows: 3, style: {
1230
+ width: '100%',
1231
+ borderRadius: 8,
1232
+ padding: '8px 10px',
1233
+ background: 'rgba(255,255,255,0.04)',
1234
+ border: '1px solid rgba(255,255,255,0.12)',
1235
+ color: 'inherit',
1236
+ font: 'inherit',
1237
+ } }), _jsxs(XStack, { render: "button", onPress: () => {
1238
+ triggerCinemaAudio();
1239
+ setStatusNote(`Dispatched Hunyuan3D-2.1 mesh job (${meshOctree}³ octree) → /v1/library/model3d`);
1240
+ }, height: 36, rounded: 999, bg: "$ink", items: "center", justify: "center", gap: "$1.5", cursor: "pointer", children: [_jsx(Box, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$background", fontWeight: "600", children: "Generate 3D Mesh (.GLB)" })] })] }), _jsxs(YStack, { flex: 2, minW: 380, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { children: [_jsx(SizableText, { size: "$3", fontWeight: "600", children: activeMesh.name }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${activeMesh.vertices.toLocaleString()} vertices · ${activeMesh.faces.toLocaleString()} triangles · Watertight PBR GLB` })] }), _jsxs(XStack, { gap: "$1.5", flexWrap: "wrap", children: [['pbr', 'wireframe', 'normal', 'clay'].map((sh) => (_jsx(XStack, { render: "button", onPress: () => setMeshShader(sh), px: "$2.5", height: 28, items: "center", rounded: 999, borderWidth: 1, borderColor: meshShader === sh ? '$ink' : '$borderColor', bg: meshShader === sh ? '$ink' : 'transparent', cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: meshShader === sh ? '$background' : '$ink', children: sh.toUpperCase() }) }, sh))), _jsx(XStack, { render: "button", onPress: () => setMeshAutoRotate((r) => !r), px: "$2.5", height: 28, items: "center", rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", children: _jsx(SizableText, { size: "$1", children: meshAutoRotate ? 'Turntable: ON' : 'Turntable: OFF' }) }), _jsxs(XStack, { render: "button", onPress: exportMeshObj, px: "$3", height: 28, items: "center", gap: "$1", rounded: 999, bg: "$ink", cursor: "pointer", children: [_jsx(Download, { size: 12 }), _jsx(SizableText, { size: "$1", color: "$background", fontWeight: "600", children: "Export .OBJ / .GLB" })] })] })] }), _jsx(YStack, { rounded: "$4", overflow: "hidden", borderWidth: 1, borderColor: "$borderColor", bg: "#090a10", children: _jsx("canvas", { ref: meshCanvasRef, width: 820, height: 420, style: { width: '100%', height: 'auto', display: 'block' } }) }), _jsxs(XStack, { items: "center", gap: "$3", children: [_jsxs(SizableText, { size: "$1", color: "$soft", children: ["Key Light Azimuth (", meshLightAngle, "\u00B0)"] }), _jsx("input", { "aria-label": "Key light azimuth angle", type: "range", min: 0, max: 360, value: meshLightAngle, onChange: (e) => setMeshLightAngle(Number(e.currentTarget.value)), style: { flex: 1 } })] })] })] })) : null, section === 'library' ? (_jsxs(XStack, { gap: "$3", flex: 1, minH: 480, flexWrap: "wrap", children: [_jsxs(YStack, { flex: 2, minW: 380, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { children: [_jsx(SizableText, { size: "$3", fontWeight: "600", children: "Org Asset Library, Stacks & Quality Gate Flywheel" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Every asset embeds its ComfyUI workflow graph & seed. \uD83D\uDC4D/\uD83D\uDC4E ratings and critiques condition future renders." })] }), _jsx(XStack, { gap: "$1.5", flexWrap: "wrap", children: ['all', 'video', 'model3d', 'music', 'image'].map((f) => (_jsx(XStack, { render: "button", onPress: () => setLibraryFilter(f), px: "$2.5", height: 28, items: "center", rounded: 999, borderWidth: 1, borderColor: libraryFilter === f ? '$ink' : '$borderColor', bg: libraryFilter === f ? '$ink' : 'transparent', cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: libraryFilter === f ? '$background' : '$ink', children: f.toUpperCase() }) }, f))) })] }), _jsx(XStack, { gap: "$3", flexWrap: "wrap", role: "list", "aria-label": "Starters", children: libraryItems
1241
+ .filter((it) => libraryFilter === 'all' || it.modality === libraryFilter)
1242
+ .map((it) => (_jsxs(YStack, { width: 270, grow: 1, maxW: 340, p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "rgba(255,255,255,0.02)", gap: "$2", children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: `🗂 ${it.stack}` }), _jsx(SizableText, { size: "$1", color: it.status === 'published' ? '$green10' : '$soft', children: it.status.toUpperCase() })] }), _jsx(SizableText, { size: "$2", fontWeight: "600", children: it.title }), _jsx(SizableText, { size: "$1", color: "$soft", style: { fontFamily: 'ui-monospace, monospace' }, children: `${it.path} · graph: ${it.workflow}` }), it.critique ? (_jsx(SizableText, { size: "$1", color: "$soft", children: `Conditioning note: “${it.critique}”` })) : null, _jsxs(XStack, { justify: "space-between", items: "center", pt: "$1", children: [_jsxs(XStack, { gap: "$1.5", children: [_jsxs(XStack, { render: "button", onPress: () => setLibraryItems((prev) => prev.map((x) => (x.id === it.id ? { ...x, vote: x.vote === 1 ? 0 : 1 } : x))), px: "$2", height: 26, items: "center", gap: 4, rounded: "$2", borderWidth: 1, borderColor: it.vote === 1 ? '$green10' : '$borderColor', cursor: "pointer", children: [_jsx(ThumbsUp, { size: 12 }), _jsx(SizableText, { size: "$1", children: "Good" })] }), _jsxs(XStack, { render: "button", onPress: () => setLibraryItems((prev) => prev.map((x) => (x.id === it.id ? { ...x, vote: x.vote === -1 ? 0 : -1 } : x))), px: "$2", height: 26, items: "center", gap: 4, rounded: "$2", borderWidth: 1, borderColor: it.vote === -1 ? '$red10' : '$borderColor', cursor: "pointer", children: [_jsx(ThumbsDown, { size: 12 }), _jsx(SizableText, { size: "$1", children: "Fix" })] })] }), _jsx(XStack, { render: "button", onPress: () => {
1243
+ setLibraryItems((prev) => prev.map((x) => (x.id === it.id ? { ...x, status: 'published' } : x)));
1244
+ setStatusNote(`Published "${it.title}" to Gallery & cms.hanzo.ai`);
1245
+ }, px: "$2.5", height: 26, items: "center", rounded: "$2", borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", children: _jsx(SizableText, { size: "$1", children: "\u2601 Publish CMS" }) })] })] }, it.id))) })] }), _jsxs(YStack, { width: 320, grow: 1, maxW: 360, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: "Qwen-Image-Edit 2511 Mask Inpaint" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Paint a mask region or attach 2\u20135 references to edit only the selected area while preserving subject identity & lighting (/v1/library/fix)." }), _jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Edit Instruction" }), _jsx("textarea", { "aria-label": "Inpaint edit instruction", value: inpaintInstruction, onChange: (e) => setInpaintInstruction(e.currentTarget.value), rows: 3, style: {
1246
+ width: '100%',
1247
+ borderRadius: 8,
1248
+ padding: '8px 10px',
1249
+ background: 'rgba(255,255,255,0.04)',
1250
+ border: '1px solid rgba(255,255,255,0.12)',
1251
+ color: 'inherit',
1252
+ font: 'inherit',
1253
+ } })] }), _jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: `Denoise / Edit Strength: ${inpaintStrength}%` }), _jsx("input", { "aria-label": "Edit strength percentage", type: "range", min: 10, max: 95, step: 5, value: inpaintStrength, onChange: (e) => setInpaintStrength(Number(e.currentTarget.value)) })] }), _jsx("canvas", { ref: inpaintCanvasRef, width: 280, height: 4, style: { display: 'none' } }), _jsxs(XStack, { render: "button", onPress: () => {
1254
+ triggerCinemaAudio();
1255
+ setStatusNote(`Queued Qwen-Image-Edit 2511 pass (${inpaintStrength}% denoise) → /v1/library/fix`);
1256
+ }, height: 34, rounded: 999, bg: "$ink", items: "center", justify: "center", gap: "$1.5", cursor: "pointer", children: [_jsx(Wand2, { size: 13 }), _jsx(SizableText, { size: "$1", color: "$background", fontWeight: "600", children: "Run Region Edit (/v1/library/fix)" })] })] })] })) : null, section === 'queue' ? (_jsxs(YStack, { gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { children: [_jsx(SizableText, { size: "$3", fontWeight: "600", children: "GPU Federation Fleet & Durable Render Queue (tasks.hanzo.ai)" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Select a target GPU node (X-Target-GPU) or route jobs across the shared gpu-jobs cluster." })] }), _jsxs(XStack, { render: "button", onPress: () => setStatusNote('Refreshed /v1/gpu-status & /v1/queue/status'), px: "$3", height: 30, items: "center", gap: "$1.5", rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", children: [_jsx(RefreshCw, { size: 12 }), _jsx(SizableText, { size: "$1", children: "Refresh Fleet" })] })] }), _jsx(XStack, { gap: "$3", flexWrap: "wrap", role: "list", "aria-label": "Starters", children: gpuNodes.map((n) => {
1257
+ const selected = targetGpu === n.name;
1258
+ return (_jsxs(YStack, { render: "button", onPress: () => {
1259
+ setTargetGpu(selected ? 'any' : n.name);
1260
+ setStatusNote(selected ? 'Routing renders to any available GPU' : `Pinned next render to GPU node: ${n.name}`);
1261
+ }, width: 300, grow: 1, p: "$3", rounded: "$3", borderWidth: selected ? 2 : 1, borderColor: selected ? '$ink' : '$borderColor', bg: selected ? '$hover' : 'rgba(255,255,255,0.02)', gap: "$1.5", cursor: "pointer", style: { textAlign: 'left' }, children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Cpu, { size: 15 }), _jsx(SizableText, { size: "$2", fontWeight: "600", children: n.name })] }), _jsx(SizableText, { size: "$1", color: n.online ? '$green10' : '$red10', children: n.online ? `● ONLINE · ${n.depth} in queue` : '○ OFFLINE' })] }), _jsx(SizableText, { size: "$1", color: "$soft", children: `Memory: ${n.vram}` }), _jsx(SizableText, { size: "$1", color: "$soft", style: { fontFamily: 'ui-monospace, monospace' }, children: `Lanes: ${n.lanes.join(' · ')}` })] }, n.name));
1262
+ }) })] })) : null] }));
1263
+ }