{"schemaVersion":1,"id":"recommended.sm-editor","version":"1.0.0","name":"Editor workflow","description":"An editable production workflow using Editor v2.2.0.","stages":[{"id":"main","blockId":"sm.editor","version":"2.2.0","label":"Editor"}],"connections":[],"packages":[{"manifest":{"schemaVersion":1,"sdkVersion":"0.1.0","id":"sm.editor","version":"2.2.0","name":"Editor","description":"Build a timeline from current project media, then edit complete video, audio, captions, text, grading, transitions, motion graphics, scoring, effects, versions, and export settings in one portable workspace.","kind":"workspace","runtime":"javascript","entry":"src/run.js","license":"MIT","provenance":{"notice":"Original source (authorship declared by the packager)\nLicense: MIT\nChanges: Original implementation declared by the packager; no reused repository or dependency code.\nFiles: LICENSE, src/run.js, src/view.json\n\nMIT License\n\nCopyright (c) 2026 StillMade contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","portableSources":[{"kind":"original","license":"MIT","paths":["LICENSE","src/run.js","src/view.json"],"evidence":["upstream/0/LICENSE","upstream/0/src/run.js","upstream/0/src/view.json"],"changes":"Original implementation declared by the packager; no reused repository or dependency code."}]},"inputs":{"editor":{"type":"timeline","context":"editor","primary":true,"required":false,"default":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[],"clips":[],"audioItems":[],"captions":[],"textOverlays":[],"effects":[]},"description":"The complete current Editor document. All internal editing tools and retained media/version data remain together."},"assets":{"type":"asset[]","context":"assets","required":false,"default":[],"description":"Current project media used to assemble an initial editable timeline when the Editor is empty."},"updatedEditor":{"type":"timeline","required":false,"default":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[],"clips":[],"audioItems":[],"captions":[],"textOverlays":[],"effects":[]},"description":"The complete edited timeline prepared in this workspace."},"commit":{"type":"boolean","default":false,"description":"Prepare the edited Editor document for StillMade review and Apply."},"action":{"type":"text","required":false,"default":"none","description":"The Block-owned interface selects a declared host action."}},"outputs":{"editor":{"type":"timeline","primary":true,"role":"editor_timeline","description":"The complete edited timeline for immediate use and downstream Blocks."},"edit":{"type":"workspace-edit","description":"An exact before/after Editor change reviewed before it updates the project."},"mediaAction":{"type":"approval","required":false,"role":"portable_media_action","description":"A bounded final-render request executed only after the user chooses Render."}},"permissions":{"project":["context.editor.read","context.assets.read","workspace.editor.propose"],"network":[],"filesystem":[],"secrets":[],"actions":["final.render"]},"ui":[],"platforms":{"phone":{"supported":true},"browser":{"supported":true},"desktop":{"supported":true}}},"code":"const copy = value => JSON.parse(JSON.stringify(value));\nconst source = copy(input.editor || {schemaVersion:1,activeTimelineId:'timeline-1',tracks:[],clips:[],audioItems:[],captions:[],textOverlays:[],effects:[]});\nconst assets=Array.isArray(input.assets)?input.assets.filter(asset=>asset&&['image','video','audio'].includes(asset.kind)&&asset.assetId&&asset.versionId&&asset.url).slice(0,500):[];\nconst assembled=copy(source);if(!assembled.clips?.length&&!assembled.audioItems?.length&&assets.length){assembled.tracks=[{id:'video',kind:'video',label:'Video'},{id:'audio',kind:'audio',label:'Audio'}];let cursor=0;assembled.clips=assets.filter(asset=>asset.kind!=='audio').map((asset,index)=>{const duration=Math.max(.001,Number(asset.duration)||Number(asset.durationSec)||4),clip={id:'clip-'+String(index+1)+'-'+String(asset.assetId),trackId:'video',start:cursor,duration,trimStart:0,speed:1,volume:1,asset:copy(asset),url:asset.url};cursor+=duration;return clip});assembled.audioItems=assets.filter(asset=>asset.kind==='audio').map((asset,index)=>({id:'audio-'+String(index+1)+'-'+String(asset.assetId),trackId:'audio',start:0,duration:Math.max(.001,Number(asset.duration)||Number(asset.durationSec)||cursor||1),trimStart:0,volume:1,asset:copy(asset),url:asset.url}));assembled.targetDuration=Math.max(cursor,...assembled.audioItems.map(item=>item.duration));}\nconst candidate = input.commit ? copy(input.updatedEditor) : assembled;\nif (!candidate || Array.isArray(candidate) || candidate.schemaVersion !== 1 || typeof candidate.activeTimelineId !== 'string' || !candidate.activeTimelineId) throw new Error('Keep the complete version 1 Editor document and active timeline identity.');\nconst names=['tracks','clips','audioItems','captions','textOverlays','stickers','effects','markers','fxEvents','liveOverlays','mediaItems','timelineVersions'];\nif (!names.every(name => candidate[name] === undefined || Array.isArray(candidate[name]) && candidate[name].length <= 10000 && candidate[name].every(item => item && typeof item === 'object' && !Array.isArray(item) && typeof item.id === 'string' && item.id.length > 0 && item.id.length <= 200) && new Set(candidate[name].map(item => item.id)).size === candidate[name].length)) throw new Error('Editor collections need valid distinct retained item IDs.');\nconst itemEnd=item=>Math.max(0,Number(item.start)||0)+Math.max(.001,Number(item.duration)||Number(item.durationMs)/1000||.001);\nconst outputs={editor:candidate,edit:{schemaVersion:1,title:`Update Editor timeline ${candidate.activeTimelineId}`,field:'editor',before:source,after:candidate}};\nif(input.action==='render'){const clips=Array.isArray(candidate.clips)?candidate.clips:[],audio=Array.isArray(candidate.audioItems)?candidate.audioItems:[],overlays=[...(candidate.captions||[]),...(candidate.textOverlays||[]),...(candidate.effects||[])],targetDuration=Math.max(.001,Number(candidate.targetDuration)||0,...clips.map(itemEnd),...audio.map(itemEnd),...overlays.map(itemEnd));outputs.mediaAction={schemaVersion:1,kind:'stillmade.media-action',operation:'final.render',request:{schemaVersion:1,kind:'video',timeline:{...candidate,clips,audio,overlays,targetDuration},settings:{fps:30,resolution:1080,quality:'high'},source:{id:'sm.editor',version:'2.2.0'}},resultPort:null};}\nreturn outputs;\n","view":{"html":"<main class=\"editor-workspace\">\n  <header><div><small>Production workspace</small><h1>Editor</h1><p id=\"summary\">Loading the complete timeline…</p></div><div class=\"actions\"><button id=\"build\" type=\"button\" class=\"secondary\">Build from project media</button><button id=\"reset\" type=\"button\" class=\"secondary\">Reset changes</button><button id=\"addText\" type=\"button\" class=\"secondary\">Add text</button><button id=\"addCaption\" type=\"button\" class=\"secondary\">Add caption</button><button id=\"save\" type=\"button\" data-stillmade-action=\"run\">Review changes</button></div></header>\n  <output id=\"status\" role=\"status\" aria-live=\"polite\"></output>\n  <section><h2>Timeline</h2><div class=\"grid\"><label>Active timeline<input id=\"timelineId\" type=\"text\" disabled></label><label>Aspect ratio<input id=\"aspect\" type=\"text\"></label></div></section>\n  <section><h2>Video</h2><div id=\"clips\" class=\"cards\"></div></section>\n  <section><h2>Audio and scoring</h2><div id=\"audio\" class=\"cards\"></div></section>\n  <section><h2>Text and motion graphics</h2><div id=\"text\" class=\"cards\"></div><p id=\"graphics\" class=\"hint\"></p></section>\n  <section><h2>Captions</h2><div id=\"captions\" class=\"cards\"></div></section>\n  <section><h2>Effects</h2><div id=\"effects\" class=\"cards\"></div></section>\n  <details><summary>Complete Editor data</summary><p>All timeline lanes, motion graphics, grade settings, transitions, scoring, versions, and export settings are retained. Use this editor for fields not shown on the lane cards.</p><textarea id=\"raw\" class=\"raw\" spellcheck=\"false\"></textarea><button id=\"applyRaw\" type=\"button\" class=\"secondary\">Apply JSON to workspace</button></details>\n<section><h2>Final export</h2><p>Render this exact timeline through StillMade’s approved device renderer.</p><button id=\"renderFinal\" type=\"button\">Render final video</button></section></main>\n","css":".editor-workspace{max-width:1160px;margin:0 auto;padding:8px;color:var(--fg)}header,.actions,.card-head,.row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}header{justify-content:space-between;margin-bottom:14px}header h1{margin:2px 0}header p,header small,details p,output,.hint{color:var(--fg-muted)}section,details{margin:12px 0;padding:16px;border:1px solid var(--border-tok);border-radius:var(--r-3);background:var(--bg-elev-1)}section h2{margin:0 0 10px}.cards{display:grid;gap:10px}.card{padding:12px;border:1px solid var(--border-tok);border-radius:var(--r-2);background:var(--bg)}.card-head{justify-content:space-between}.card h3{margin:0;font-size:16px}.grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px}label{display:grid;gap:5px;margin:7px 0;font-size:13px;font-weight:600}input,textarea{width:100%;background:var(--bg)}textarea{min-height:70px;resize:vertical}.wide{grid-column:1/-1}.secondary{background:transparent;color:var(--fg)}.danger{background:transparent;color:var(--signal)}.raw{min-height:440px;font-family:var(--font-mono);font-size:12px}output{display:block;min-height:24px;margin:8px 2px}\n@media(max-width:900px){.grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:560px){.editor-workspace{padding:0}.grid{grid-template-columns:1fr}.actions{width:100%}.actions button{flex:1}section,details{padding:12px}}\n","javascript":"const status=document.getElementById('status'),summary=document.getElementById('summary'),raw=document.getElementById('raw'),save=document.getElementById('save'),aspect=document.getElementById('aspect'),timelineId=document.getElementById('timelineId'),graphics=document.getElementById('graphics'),build=document.getElementById('build');\nlet source={schemaVersion:1,activeTimelineId:'timeline-1',tracks:[],clips:[],audioItems:[],captions:[],textOverlays:[],effects:[]},draft={schemaVersion:1,activeTimelineId:'timeline-1',tracks:[],clips:[],audioItems:[],captions:[],textOverlays:[],effects:[]},assets=[],busy=false,revision=0;\nconst clone=value=>JSON.parse(JSON.stringify(value));\nconst text=value=>value===undefined||value===null?'':String(value);\nconst assemble=()=>{const next=clone(source),media=assets.filter(asset=>asset&&['image','video','audio'].includes(asset.kind)&&asset.assetId&&asset.versionId&&asset.url).slice(0,500);if(next.clips?.length||next.audioItems?.length||!media.length)return next;next.tracks=[{id:'video',kind:'video',label:'Video'},{id:'audio',kind:'audio',label:'Audio'}];let cursor=0;next.clips=media.filter(asset=>asset.kind!=='audio').map((asset,index)=>{const duration=Math.max(.001,Number(asset.duration)||Number(asset.durationSec)||4),clip={id:'clip-'+String(index+1)+'-'+text(asset.assetId),trackId:'video',start:cursor,duration,trimStart:0,speed:1,volume:1,asset:clone(asset),url:asset.url};cursor+=duration;return clip});next.audioItems=media.filter(asset=>asset.kind==='audio').map((asset,index)=>({id:'audio-'+String(index+1)+'-'+text(asset.assetId),trackId:'audio',start:0,duration:Math.max(.001,Number(asset.duration)||Number(asset.durationSec)||cursor||1),trimStart:0,volume:1,asset:clone(asset),url:asset.url}));next.targetDuration=Math.max(cursor,...next.audioItems.map(item=>item.duration));return next};\nconst field=(label,action,value,type='text',wide=false)=>({tag:'label',className:wide?'wide':'',children:[{tag:'span',text:label},{tag:'input',type,action,value:Number.isFinite(value)?value:text(value),disabled:busy,label}]});\nconst remove=action=>({tag:'button',action,text:'Remove',className:'danger',disabled:busy});\nconst clipCard=(item,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.label)||text(item.name)||text(item.id)},remove('remove-clip:'+String(index))]},{tag:'div',className:'grid',children:[field('Track','clip-track:'+String(index),item.trackId),field('Start (seconds)','clip-start:'+String(index),item.start,'number'),field('Length (seconds)','clip-duration:'+String(index),item.duration,'number'),field('Trim start','clip-trim:'+String(index),item.trimStart,'number'),field('Speed','clip-speed:'+String(index),item.speed,'number'),field('Volume','clip-volume:'+String(index),item.volume,'number'),field('Transition','clip-transition:'+String(index),item.transition&&item.transition.type),field('Transition length','clip-transition-duration:'+String(index),item.transition&&item.transition.duration,'number'),field('Motion','clip-motion:'+String(index),item.motion&&item.motion.type),field('Motion easing','clip-easing:'+String(index),item.motion&&item.motion.easing)]}]});\nconst audioCard=(item,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.label)||text(item.name)||text(item.id)},remove('remove-audio:'+String(index))]},{tag:'div',className:'grid',children:[field('Track','audio-track:'+String(index),item.trackId),field('Start (seconds)','audio-start:'+String(index),item.start,'number'),field('Length (seconds)','audio-duration:'+String(index),item.duration,'number'),field('Trim start','audio-trim:'+String(index),item.trimStart===undefined?item.sourceOffset:item.trimStart,'number'),field('Volume','audio-volume:'+String(index),item.volume,'number'),{tag:'label',children:[{tag:'span',text:'Muted'},{tag:'input',type:'checkbox',action:'audio-muted:'+String(index),checked:!!item.muted,disabled:busy,label:'Muted'}]}]}]});\nconst textCard=(item,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.id)},remove('remove-text:'+String(index))]},{tag:'div',className:'grid',children:[field('Text','text-value:'+String(index),item.text,'text',true),field('Track','text-track:'+String(index),item.trackId),field('Start (seconds)','text-start:'+String(index),item.start,'number'),field('Length (seconds)','text-duration:'+String(index),item.duration,'number'),field('Animation','text-animation:'+String(index),item.animation)]}]});\nconst captionCard=(item,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.id)},remove('remove-caption:'+String(index))]},{tag:'div',className:'grid',children:[field('Caption','caption-value:'+String(index),item.text,'text',true),field('Track','caption-track:'+String(index),item.trackId),field('Start (seconds)','caption-start:'+String(index),item.start,'number'),field('End (seconds)','caption-end:'+String(index),item.end,'number'),field('Animation','caption-animation:'+String(index),item.animation)]}]});\nconst effectCard=(item,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.type)||text(item.id)},remove('remove-effect:'+String(index))]},{tag:'div',className:'grid',children:[field('Type','effect-type:'+String(index),item.type),field('Track','effect-track:'+String(index),item.trackId),field('Start (seconds)','effect-start:'+String(index),item.start,'number'),field('Length (seconds)','effect-duration:'+String(index),item.duration,'number'),field('Intensity','effect-intensity:'+String(index),item.intensity,'number')]}]});\nconst ensure=()=>{if(!draft||Array.isArray(draft)||draft.schemaVersion!==1)draft=clone(source);if(!Array.isArray(draft.tracks))draft.tracks=[];if(!Array.isArray(draft.clips))draft.clips=[];if(!Array.isArray(draft.audioItems))draft.audioItems=[];if(!Array.isArray(draft.captions))draft.captions=[];if(!Array.isArray(draft.textOverlays))draft.textOverlays=[];if(!Array.isArray(draft.effects))draft.effects=[]};\nconst draw=()=>{ensure();StillMade.render('clips',draft.clips.length?draft.clips.map(clipCard):[{tag:'p',text:'No video clips.'}]);StillMade.render('audio',draft.audioItems.length?draft.audioItems.map(audioCard):[{tag:'p',text:'No audio items.'}]);StillMade.render('text',draft.textOverlays.length?draft.textOverlays.map(textCard):[{tag:'p',text:'No text overlays.'}]);StillMade.render('captions',draft.captions.length?draft.captions.map(captionCard):[{tag:'p',text:'No captions.'}]);StillMade.render('effects',draft.effects.length?draft.effects.map(effectCard):[{tag:'p',text:'No effects.'}]);timelineId.value=text(draft.activeTimelineId);aspect.value=text(draft.aspect);const mg=(Array.isArray(draft.fullscreenFrames)?draft.fullscreenFrames.length:0)+(Array.isArray(draft.figureSweeps)?draft.figureSweeps.length:0)+(Array.isArray(draft.graphs)?draft.graphs.length:0);graphics.textContent=String(mg)+' motion graphic item'+(mg===1?'':'s')+' retained in this Editor Block. Use Complete Editor data for advanced motion-graphics fields.';raw.value=JSON.stringify(draft,null,2);summary.textContent=String(draft.clips.length)+' video · '+String(draft.audioItems.length)+' audio · '+String(draft.captions.length)+' captions · '+String(draft.textOverlays.length)+' text';save.disabled=busy;build.disabled=busy||!assets.length;document.getElementById('reset').disabled=busy;document.getElementById('addText').disabled=busy;document.getElementById('addCaption').disabled=busy};\nconst changed=()=>{revision+=1;raw.value=JSON.stringify(draft,null,2);status.textContent='Changes are local until you choose Review changes.'};\naspect.addEventListener('input',()=>{draft.aspect=aspect.value;changed()});\nStillMade.onAction(event=>{if(busy)return;ensure();const parts=event.action.split(':'),kind=parts[0],index=Number(parts[1]),clip=draft.clips.find((item,position)=>position===index),audio=draft.audioItems.find((item,position)=>position===index),title=draft.textOverlays.find((item,position)=>position===index),caption=draft.captions.find((item,position)=>position===index),effect=draft.effects.find((item,position)=>position===index);\n if(kind==='remove-clip'){draft.clips=draft.clips.filter((item,position)=>position!==index);changed();draw();return}if(kind==='remove-audio'){draft.audioItems=draft.audioItems.filter((item,position)=>position!==index);changed();draw();return}if(kind==='remove-text'){draft.textOverlays=draft.textOverlays.filter((item,position)=>position!==index);changed();draw();return}if(kind==='remove-caption'){draft.captions=draft.captions.filter((item,position)=>position!==index);changed();draw();return}if(kind==='remove-effect'){draft.effects=draft.effects.filter((item,position)=>position!==index);changed();draw();return}\n if(clip){if(kind==='clip-track')clip.trackId=event.value;if(kind==='clip-start')clip.start=Math.max(0,Number(event.value)||0);if(kind==='clip-duration')clip.duration=Math.max(0.001,Number(event.value)||0.001);if(kind==='clip-trim')clip.trimStart=Math.max(0,Number(event.value)||0);if(kind==='clip-speed')clip.speed=Math.max(0.01,Number(event.value)||1);if(kind==='clip-volume')clip.volume=Math.max(0,Number(event.value)||0);if(kind==='clip-transition'||kind==='clip-transition-duration'){if(!clip.transition||Array.isArray(clip.transition))clip.transition={type:'Cut',duration:0};if(kind==='clip-transition')clip.transition.type=event.value;else clip.transition.duration=Math.max(0,Number(event.value)||0)}if(kind==='clip-motion'||kind==='clip-easing'){if(!clip.motion||Array.isArray(clip.motion))clip.motion={type:'none',easing:'ease-in-out'};if(kind==='clip-motion')clip.motion.type=event.value;else clip.motion.easing=event.value}}\n if(audio){if(kind==='audio-track')audio.trackId=event.value;if(kind==='audio-start')audio.start=Math.max(0,Number(event.value)||0);if(kind==='audio-duration')audio.duration=Math.max(0.001,Number(event.value)||0.001);if(kind==='audio-trim'){audio.trimStart=Math.max(0,Number(event.value)||0);audio.sourceOffset=audio.trimStart}if(kind==='audio-volume')audio.volume=Math.max(0,Number(event.value)||0);if(kind==='audio-muted')audio.muted=event.checked}\n if(title){if(kind==='text-value')title.text=event.value;if(kind==='text-track')title.trackId=event.value;if(kind==='text-start')title.start=Math.max(0,Number(event.value)||0);if(kind==='text-duration')title.duration=Math.max(0.001,Number(event.value)||0.001);if(kind==='text-animation')title.animation=event.value}\n if(caption){if(kind==='caption-value')caption.text=event.value;if(kind==='caption-track')caption.trackId=event.value;if(kind==='caption-start')caption.start=Math.max(0,Number(event.value)||0);if(kind==='caption-end')caption.end=Math.max(caption.start+0.001,Number(event.value)||caption.start+0.001);if(kind==='caption-animation')caption.animation=event.value}\n if(effect){if(kind==='effect-type')effect.type=event.value;if(kind==='effect-track')effect.trackId=event.value;if(kind==='effect-start')effect.start=Math.max(0,Number(event.value)||0);if(kind==='effect-duration')effect.duration=Math.max(0.001,Number(event.value)||0.001);if(kind==='effect-intensity')effect.intensity=Number(event.value)}changed()});\nbuild.addEventListener('click',()=>{if(!busy){draft=assemble();changed();draw();status.textContent='Built an editable timeline from current project media.'}});\ndocument.getElementById('addText').addEventListener('click',()=>{if(busy)return;ensure();draft.textOverlays=[...draft.textOverlays,{id:'portable-text-'+String(draft.textOverlays.length+1)+'-'+String(revision+1),trackId:'text',text:'New text',start:0,duration:2,animation:'none'}];changed();draw()});\ndocument.getElementById('addCaption').addEventListener('click',()=>{if(busy)return;ensure();draft.captions=[...draft.captions,{id:'portable-caption-'+String(draft.captions.length+1)+'-'+String(revision+1),trackId:'captions',text:'New caption',start:0,end:2,font:'Hanken Grotesk',animation:'none'}];changed();draw()});\ndocument.getElementById('applyRaw').addEventListener('click',()=>{if(busy)return;try{const value=JSON.parse(raw.value);if(!value||Array.isArray(value)||value.schemaVersion!==1||typeof value.activeTimelineId!=='string')throw Error('Editor JSON must be a version 1 document with an active timeline ID.');draft=clone(value);changed();draw();status.textContent='Complete Editor data applied locally.'}catch(error){status.textContent=error.message}});\ndocument.getElementById('reset').addEventListener('click',()=>{if(!busy){draft=clone(source);revision+=1;draw();status.textContent='Changes reset to the current Editor timeline.'}});\nsave.addEventListener('click',async()=>{if(busy)return;const started=revision;busy=true;draw();status.textContent='Checking the complete Editor timeline…';try{const result=await StillMade.run({editor:source,updatedEditor:draft,commit:true});draft=clone(result.editor);if(started===revision)status.textContent='Editor changes are ready below. Review the before and after, then choose Apply.'}catch(error){status.textContent=error.message||'Editor changes could not be prepared.'}finally{busy=false;draw()}});\nStillMade.onInput(values=>{source=clone(values.editor||source);assets=clone(values.assets||[]);draft=source.clips?.length||source.audioItems?.length?clone(source):assemble();revision+=1;draw();status.textContent='Edit the complete timeline. Motion graphics and every other Editor tool stay inside this Block.'});\n\ndocument.getElementById('renderFinal').addEventListener('click',async()=>{if(busy)return;busy=true;draw();status.textContent='Preparing the exact final render…';try{await StillMade.run({editor:source,updatedEditor:draft,commit:false,action:'render'});status.textContent='Final render is ready below. Choose Render final file to start the device renderer.'}catch(error){status.textContent=error.message||'The render plan could not be prepared.'}finally{busy=false;draw()}});\n"},"tests":[{"name":"Retain the complete Editor and all internal tools","input":{"editor":{"schemaVersion":1,"activeTimelineId":"timeline-1","aspect":"16:9","tracks":[{"id":"video","type":"video"},{"id":"audio","type":"audio"}],"clips":[{"id":"clip-1","trackId":"video","start":0,"duration":4,"url":"https://media.example/clip.mp4","motion":{"type":"push-in"},"color":{"brightness":5},"transition":{"type":"Fade","duration":0.5}}],"audioItems":[{"id":"music-1","trackId":"audio","start":0,"duration":4,"url":"https://media.example/music.mp3","volume":70}],"captions":[{"id":"caption-1","trackId":"captions","text":"Hello","start":0,"end":1}],"textOverlays":[{"id":"title-1","text":"Opening","start":0,"duration":2}],"effects":[{"id":"effect-1","type":"grain","start":0,"duration":4}],"fullscreenFrames":[{"id":"mg-frame-1","title":"Motion graphic"}],"figureSweeps":[{"id":"mg-figure-1","value":42}],"audioScore":{"wholeMusic":{"versions":[{"url":"https://media.example/score.mp3"}],"idx":0}},"timelineVersions":[{"id":"timeline-1","name":"Main","clips":[]}],"exportSettings":{"resolution":"1080p"},"custom":{"keep":true}},"updatedEditor":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[],"clips":[],"audioItems":[],"captions":[],"textOverlays":[],"effects":[]},"commit":false},"expected":{"editor":{"schemaVersion":1,"activeTimelineId":"timeline-1","aspect":"16:9","tracks":[{"id":"video","type":"video"},{"id":"audio","type":"audio"}],"clips":[{"id":"clip-1","trackId":"video","start":0,"duration":4,"url":"https://media.example/clip.mp4","motion":{"type":"push-in"},"color":{"brightness":5},"transition":{"type":"Fade","duration":0.5}}],"audioItems":[{"id":"music-1","trackId":"audio","start":0,"duration":4,"url":"https://media.example/music.mp3","volume":70}],"captions":[{"id":"caption-1","trackId":"captions","text":"Hello","start":0,"end":1}],"textOverlays":[{"id":"title-1","text":"Opening","start":0,"duration":2}],"effects":[{"id":"effect-1","type":"grain","start":0,"duration":4}],"fullscreenFrames":[{"id":"mg-frame-1","title":"Motion graphic"}],"figureSweeps":[{"id":"mg-figure-1","value":42}],"audioScore":{"wholeMusic":{"versions":[{"url":"https://media.example/score.mp3"}],"idx":0}},"timelineVersions":[{"id":"timeline-1","name":"Main","clips":[]}],"exportSettings":{"resolution":"1080p"},"custom":{"keep":true}},"edit":{"schemaVersion":1,"title":"Update Editor timeline timeline-1","field":"editor","before":{"schemaVersion":1,"activeTimelineId":"timeline-1","aspect":"16:9","tracks":[{"id":"video","type":"video"},{"id":"audio","type":"audio"}],"clips":[{"id":"clip-1","trackId":"video","start":0,"duration":4,"url":"https://media.example/clip.mp4","motion":{"type":"push-in"},"color":{"brightness":5},"transition":{"type":"Fade","duration":0.5}}],"audioItems":[{"id":"music-1","trackId":"audio","start":0,"duration":4,"url":"https://media.example/music.mp3","volume":70}],"captions":[{"id":"caption-1","trackId":"captions","text":"Hello","start":0,"end":1}],"textOverlays":[{"id":"title-1","text":"Opening","start":0,"duration":2}],"effects":[{"id":"effect-1","type":"grain","start":0,"duration":4}],"fullscreenFrames":[{"id":"mg-frame-1","title":"Motion graphic"}],"figureSweeps":[{"id":"mg-figure-1","value":42}],"audioScore":{"wholeMusic":{"versions":[{"url":"https://media.example/score.mp3"}],"idx":0}},"timelineVersions":[{"id":"timeline-1","name":"Main","clips":[]}],"exportSettings":{"resolution":"1080p"},"custom":{"keep":true}},"after":{"schemaVersion":1,"activeTimelineId":"timeline-1","aspect":"16:9","tracks":[{"id":"video","type":"video"},{"id":"audio","type":"audio"}],"clips":[{"id":"clip-1","trackId":"video","start":0,"duration":4,"url":"https://media.example/clip.mp4","motion":{"type":"push-in"},"color":{"brightness":5},"transition":{"type":"Fade","duration":0.5}}],"audioItems":[{"id":"music-1","trackId":"audio","start":0,"duration":4,"url":"https://media.example/music.mp3","volume":70}],"captions":[{"id":"caption-1","trackId":"captions","text":"Hello","start":0,"end":1}],"textOverlays":[{"id":"title-1","text":"Opening","start":0,"duration":2}],"effects":[{"id":"effect-1","type":"grain","start":0,"duration":4}],"fullscreenFrames":[{"id":"mg-frame-1","title":"Motion graphic"}],"figureSweeps":[{"id":"mg-figure-1","value":42}],"audioScore":{"wholeMusic":{"versions":[{"url":"https://media.example/score.mp3"}],"idx":0}},"timelineVersions":[{"id":"timeline-1","name":"Main","clips":[]}],"exportSettings":{"resolution":"1080p"},"custom":{"keep":true}}}}},{"name":"Prepare one exact complete Editor update","input":{"editor":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[{"id":"video","type":"video"}],"clips":[{"id":"clip-1","trackId":"video","start":0,"duration":4,"url":"https://media.example/clip.mp4","volume":100}],"audioItems":[],"captions":[],"textOverlays":[{"id":"title-1","text":"Old","start":0,"duration":2}],"effects":[]},"updatedEditor":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[{"id":"video","type":"video"}],"clips":[{"id":"clip-1","trackId":"video","start":1,"duration":3,"url":"https://media.example/clip.mp4","volume":80}],"audioItems":[],"captions":[],"textOverlays":[{"id":"title-1","text":"New","start":1,"duration":2}],"effects":[]},"commit":true},"expected":{"editor":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[{"id":"video","type":"video"}],"clips":[{"id":"clip-1","trackId":"video","start":1,"duration":3,"url":"https://media.example/clip.mp4","volume":80}],"audioItems":[],"captions":[],"textOverlays":[{"id":"title-1","text":"New","start":1,"duration":2}],"effects":[]},"edit":{"schemaVersion":1,"title":"Update Editor timeline timeline-1","field":"editor","before":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[{"id":"video","type":"video"}],"clips":[{"id":"clip-1","trackId":"video","start":0,"duration":4,"url":"https://media.example/clip.mp4","volume":100}],"audioItems":[],"captions":[],"textOverlays":[{"id":"title-1","text":"Old","start":0,"duration":2}],"effects":[]},"after":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[{"id":"video","type":"video"}],"clips":[{"id":"clip-1","trackId":"video","start":1,"duration":3,"url":"https://media.example/clip.mp4","volume":80}],"audioItems":[],"captions":[],"textOverlays":[{"id":"title-1","text":"New","start":1,"duration":2}],"effects":[]}}}},{"name":"Build initial timeline from exact project media versions","input":{"editor":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[],"clips":[],"audioItems":[],"captions":[],"textOverlays":[],"effects":[]},"assets":[{"kind":"video","assetId":"video-1","versionId":"v1","url":"https://media.example/video.mp4","duration":5},{"kind":"image","assetId":"image-1","versionId":"v2","url":"https://media.example/image.png"},{"kind":"audio","assetId":"music-1","versionId":"v1","url":"https://media.example/music.mp3","duration":9}],"updatedEditor":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[],"clips":[],"audioItems":[],"captions":[],"textOverlays":[],"effects":[]},"commit":false,"action":"none"},"expected":{"editor":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[{"id":"video","kind":"video","label":"Video"},{"id":"audio","kind":"audio","label":"Audio"}],"clips":[{"id":"clip-1-video-1","trackId":"video","start":0,"duration":5,"trimStart":0,"speed":1,"volume":1,"asset":{"kind":"video","assetId":"video-1","versionId":"v1","url":"https://media.example/video.mp4","duration":5},"url":"https://media.example/video.mp4"},{"id":"clip-2-image-1","trackId":"video","start":5,"duration":4,"trimStart":0,"speed":1,"volume":1,"asset":{"kind":"image","assetId":"image-1","versionId":"v2","url":"https://media.example/image.png"},"url":"https://media.example/image.png"}],"audioItems":[{"id":"audio-1-music-1","trackId":"audio","start":0,"duration":9,"trimStart":0,"volume":1,"asset":{"kind":"audio","assetId":"music-1","versionId":"v1","url":"https://media.example/music.mp3","duration":9},"url":"https://media.example/music.mp3"}],"captions":[],"textOverlays":[],"effects":[],"targetDuration":9},"edit":{"schemaVersion":1,"title":"Update Editor timeline timeline-1","field":"editor","before":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[],"clips":[],"audioItems":[],"captions":[],"textOverlays":[],"effects":[]},"after":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[{"id":"video","kind":"video","label":"Video"},{"id":"audio","kind":"audio","label":"Audio"}],"clips":[{"id":"clip-1-video-1","trackId":"video","start":0,"duration":5,"trimStart":0,"speed":1,"volume":1,"asset":{"kind":"video","assetId":"video-1","versionId":"v1","url":"https://media.example/video.mp4","duration":5},"url":"https://media.example/video.mp4"},{"id":"clip-2-image-1","trackId":"video","start":5,"duration":4,"trimStart":0,"speed":1,"volume":1,"asset":{"kind":"image","assetId":"image-1","versionId":"v2","url":"https://media.example/image.png"},"url":"https://media.example/image.png"}],"audioItems":[{"id":"audio-1-music-1","trackId":"audio","start":0,"duration":9,"trimStart":0,"volume":1,"asset":{"kind":"audio","assetId":"music-1","versionId":"v1","url":"https://media.example/music.mp3","duration":9},"url":"https://media.example/music.mp3"}],"captions":[],"textOverlays":[],"effects":[],"targetDuration":9}}}}],"portable":{"format":"stillmade-block/1","dependencies":[],"sources":[{"kind":"original","license":"MIT","paths":["LICENSE","src/run.js","src/view.json"],"evidence":["upstream/0/LICENSE","upstream/0/src/run.js","upstream/0/src/view.json"],"changes":"Original implementation declared by the packager; no reused repository or dependency code."}],"files":{"upstream/0/LICENSE":"MIT License\n\nCopyright (c) 2026 StillMade contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","upstream/0/src/run.js":"const copy = value => JSON.parse(JSON.stringify(value));\nconst source = copy(input.editor || {schemaVersion:1,activeTimelineId:'timeline-1',tracks:[],clips:[],audioItems:[],captions:[],textOverlays:[],effects:[]});\nconst assets=Array.isArray(input.assets)?input.assets.filter(asset=>asset&&['image','video','audio'].includes(asset.kind)&&asset.assetId&&asset.versionId&&asset.url).slice(0,500):[];\nconst assembled=copy(source);if(!assembled.clips?.length&&!assembled.audioItems?.length&&assets.length){assembled.tracks=[{id:'video',kind:'video',label:'Video'},{id:'audio',kind:'audio',label:'Audio'}];let cursor=0;assembled.clips=assets.filter(asset=>asset.kind!=='audio').map((asset,index)=>{const duration=Math.max(.001,Number(asset.duration)||Number(asset.durationSec)||4),clip={id:'clip-'+String(index+1)+'-'+String(asset.assetId),trackId:'video',start:cursor,duration,trimStart:0,speed:1,volume:1,asset:copy(asset),url:asset.url};cursor+=duration;return clip});assembled.audioItems=assets.filter(asset=>asset.kind==='audio').map((asset,index)=>({id:'audio-'+String(index+1)+'-'+String(asset.assetId),trackId:'audio',start:0,duration:Math.max(.001,Number(asset.duration)||Number(asset.durationSec)||cursor||1),trimStart:0,volume:1,asset:copy(asset),url:asset.url}));assembled.targetDuration=Math.max(cursor,...assembled.audioItems.map(item=>item.duration));}\nconst candidate = input.commit ? copy(input.updatedEditor) : assembled;\nif (!candidate || Array.isArray(candidate) || candidate.schemaVersion !== 1 || typeof candidate.activeTimelineId !== 'string' || !candidate.activeTimelineId) throw new Error('Keep the complete version 1 Editor document and active timeline identity.');\nconst names=['tracks','clips','audioItems','captions','textOverlays','stickers','effects','markers','fxEvents','liveOverlays','mediaItems','timelineVersions'];\nif (!names.every(name => candidate[name] === undefined || Array.isArray(candidate[name]) && candidate[name].length <= 10000 && candidate[name].every(item => item && typeof item === 'object' && !Array.isArray(item) && typeof item.id === 'string' && item.id.length > 0 && item.id.length <= 200) && new Set(candidate[name].map(item => item.id)).size === candidate[name].length)) throw new Error('Editor collections need valid distinct retained item IDs.');\nconst itemEnd=item=>Math.max(0,Number(item.start)||0)+Math.max(.001,Number(item.duration)||Number(item.durationMs)/1000||.001);\nconst outputs={editor:candidate,edit:{schemaVersion:1,title:`Update Editor timeline ${candidate.activeTimelineId}`,field:'editor',before:source,after:candidate}};\nif(input.action==='render'){const clips=Array.isArray(candidate.clips)?candidate.clips:[],audio=Array.isArray(candidate.audioItems)?candidate.audioItems:[],overlays=[...(candidate.captions||[]),...(candidate.textOverlays||[]),...(candidate.effects||[])],targetDuration=Math.max(.001,Number(candidate.targetDuration)||0,...clips.map(itemEnd),...audio.map(itemEnd),...overlays.map(itemEnd));outputs.mediaAction={schemaVersion:1,kind:'stillmade.media-action',operation:'final.render',request:{schemaVersion:1,kind:'video',timeline:{...candidate,clips,audio,overlays,targetDuration},settings:{fps:30,resolution:1080,quality:'high'},source:{id:'sm.editor',version:'2.2.0'}},resultPort:null};}\nreturn outputs;\n","upstream/0/src/view.json":"{\n  \"html\": \"<main class=\\\"editor-workspace\\\">\\n  <header><div><small>Production workspace</small><h1>Editor</h1><p id=\\\"summary\\\">Loading the complete timeline…</p></div><div class=\\\"actions\\\"><button id=\\\"build\\\" type=\\\"button\\\" class=\\\"secondary\\\">Build from project media</button><button id=\\\"reset\\\" type=\\\"button\\\" class=\\\"secondary\\\">Reset changes</button><button id=\\\"addText\\\" type=\\\"button\\\" class=\\\"secondary\\\">Add text</button><button id=\\\"addCaption\\\" type=\\\"button\\\" class=\\\"secondary\\\">Add caption</button><button id=\\\"save\\\" type=\\\"button\\\" data-stillmade-action=\\\"run\\\">Review changes</button></div></header>\\n  <output id=\\\"status\\\" role=\\\"status\\\" aria-live=\\\"polite\\\"></output>\\n  <section><h2>Timeline</h2><div class=\\\"grid\\\"><label>Active timeline<input id=\\\"timelineId\\\" type=\\\"text\\\" disabled></label><label>Aspect ratio<input id=\\\"aspect\\\" type=\\\"text\\\"></label></div></section>\\n  <section><h2>Video</h2><div id=\\\"clips\\\" class=\\\"cards\\\"></div></section>\\n  <section><h2>Audio and scoring</h2><div id=\\\"audio\\\" class=\\\"cards\\\"></div></section>\\n  <section><h2>Text and motion graphics</h2><div id=\\\"text\\\" class=\\\"cards\\\"></div><p id=\\\"graphics\\\" class=\\\"hint\\\"></p></section>\\n  <section><h2>Captions</h2><div id=\\\"captions\\\" class=\\\"cards\\\"></div></section>\\n  <section><h2>Effects</h2><div id=\\\"effects\\\" class=\\\"cards\\\"></div></section>\\n  <details><summary>Complete Editor data</summary><p>All timeline lanes, motion graphics, grade settings, transitions, scoring, versions, and export settings are retained. Use this editor for fields not shown on the lane cards.</p><textarea id=\\\"raw\\\" class=\\\"raw\\\" spellcheck=\\\"false\\\"></textarea><button id=\\\"applyRaw\\\" type=\\\"button\\\" class=\\\"secondary\\\">Apply JSON to workspace</button></details>\\n<section><h2>Final export</h2><p>Render this exact timeline through StillMade’s approved device renderer.</p><button id=\\\"renderFinal\\\" type=\\\"button\\\">Render final video</button></section></main>\\n\",\n  \"css\": \".editor-workspace{max-width:1160px;margin:0 auto;padding:8px;color:var(--fg)}header,.actions,.card-head,.row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}header{justify-content:space-between;margin-bottom:14px}header h1{margin:2px 0}header p,header small,details p,output,.hint{color:var(--fg-muted)}section,details{margin:12px 0;padding:16px;border:1px solid var(--border-tok);border-radius:var(--r-3);background:var(--bg-elev-1)}section h2{margin:0 0 10px}.cards{display:grid;gap:10px}.card{padding:12px;border:1px solid var(--border-tok);border-radius:var(--r-2);background:var(--bg)}.card-head{justify-content:space-between}.card h3{margin:0;font-size:16px}.grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px}label{display:grid;gap:5px;margin:7px 0;font-size:13px;font-weight:600}input,textarea{width:100%;background:var(--bg)}textarea{min-height:70px;resize:vertical}.wide{grid-column:1/-1}.secondary{background:transparent;color:var(--fg)}.danger{background:transparent;color:var(--signal)}.raw{min-height:440px;font-family:var(--font-mono);font-size:12px}output{display:block;min-height:24px;margin:8px 2px}\\n@media(max-width:900px){.grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:560px){.editor-workspace{padding:0}.grid{grid-template-columns:1fr}.actions{width:100%}.actions button{flex:1}section,details{padding:12px}}\\n\",\n  \"javascript\": \"const status=document.getElementById('status'),summary=document.getElementById('summary'),raw=document.getElementById('raw'),save=document.getElementById('save'),aspect=document.getElementById('aspect'),timelineId=document.getElementById('timelineId'),graphics=document.getElementById('graphics'),build=document.getElementById('build');\\nlet source={schemaVersion:1,activeTimelineId:'timeline-1',tracks:[],clips:[],audioItems:[],captions:[],textOverlays:[],effects:[]},draft={schemaVersion:1,activeTimelineId:'timeline-1',tracks:[],clips:[],audioItems:[],captions:[],textOverlays:[],effects:[]},assets=[],busy=false,revision=0;\\nconst clone=value=>JSON.parse(JSON.stringify(value));\\nconst text=value=>value===undefined||value===null?'':String(value);\\nconst assemble=()=>{const next=clone(source),media=assets.filter(asset=>asset&&['image','video','audio'].includes(asset.kind)&&asset.assetId&&asset.versionId&&asset.url).slice(0,500);if(next.clips?.length||next.audioItems?.length||!media.length)return next;next.tracks=[{id:'video',kind:'video',label:'Video'},{id:'audio',kind:'audio',label:'Audio'}];let cursor=0;next.clips=media.filter(asset=>asset.kind!=='audio').map((asset,index)=>{const duration=Math.max(.001,Number(asset.duration)||Number(asset.durationSec)||4),clip={id:'clip-'+String(index+1)+'-'+text(asset.assetId),trackId:'video',start:cursor,duration,trimStart:0,speed:1,volume:1,asset:clone(asset),url:asset.url};cursor+=duration;return clip});next.audioItems=media.filter(asset=>asset.kind==='audio').map((asset,index)=>({id:'audio-'+String(index+1)+'-'+text(asset.assetId),trackId:'audio',start:0,duration:Math.max(.001,Number(asset.duration)||Number(asset.durationSec)||cursor||1),trimStart:0,volume:1,asset:clone(asset),url:asset.url}));next.targetDuration=Math.max(cursor,...next.audioItems.map(item=>item.duration));return next};\\nconst field=(label,action,value,type='text',wide=false)=>({tag:'label',className:wide?'wide':'',children:[{tag:'span',text:label},{tag:'input',type,action,value:Number.isFinite(value)?value:text(value),disabled:busy,label}]});\\nconst remove=action=>({tag:'button',action,text:'Remove',className:'danger',disabled:busy});\\nconst clipCard=(item,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.label)||text(item.name)||text(item.id)},remove('remove-clip:'+String(index))]},{tag:'div',className:'grid',children:[field('Track','clip-track:'+String(index),item.trackId),field('Start (seconds)','clip-start:'+String(index),item.start,'number'),field('Length (seconds)','clip-duration:'+String(index),item.duration,'number'),field('Trim start','clip-trim:'+String(index),item.trimStart,'number'),field('Speed','clip-speed:'+String(index),item.speed,'number'),field('Volume','clip-volume:'+String(index),item.volume,'number'),field('Transition','clip-transition:'+String(index),item.transition&&item.transition.type),field('Transition length','clip-transition-duration:'+String(index),item.transition&&item.transition.duration,'number'),field('Motion','clip-motion:'+String(index),item.motion&&item.motion.type),field('Motion easing','clip-easing:'+String(index),item.motion&&item.motion.easing)]}]});\\nconst audioCard=(item,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.label)||text(item.name)||text(item.id)},remove('remove-audio:'+String(index))]},{tag:'div',className:'grid',children:[field('Track','audio-track:'+String(index),item.trackId),field('Start (seconds)','audio-start:'+String(index),item.start,'number'),field('Length (seconds)','audio-duration:'+String(index),item.duration,'number'),field('Trim start','audio-trim:'+String(index),item.trimStart===undefined?item.sourceOffset:item.trimStart,'number'),field('Volume','audio-volume:'+String(index),item.volume,'number'),{tag:'label',children:[{tag:'span',text:'Muted'},{tag:'input',type:'checkbox',action:'audio-muted:'+String(index),checked:!!item.muted,disabled:busy,label:'Muted'}]}]}]});\\nconst textCard=(item,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.id)},remove('remove-text:'+String(index))]},{tag:'div',className:'grid',children:[field('Text','text-value:'+String(index),item.text,'text',true),field('Track','text-track:'+String(index),item.trackId),field('Start (seconds)','text-start:'+String(index),item.start,'number'),field('Length (seconds)','text-duration:'+String(index),item.duration,'number'),field('Animation','text-animation:'+String(index),item.animation)]}]});\\nconst captionCard=(item,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.id)},remove('remove-caption:'+String(index))]},{tag:'div',className:'grid',children:[field('Caption','caption-value:'+String(index),item.text,'text',true),field('Track','caption-track:'+String(index),item.trackId),field('Start (seconds)','caption-start:'+String(index),item.start,'number'),field('End (seconds)','caption-end:'+String(index),item.end,'number'),field('Animation','caption-animation:'+String(index),item.animation)]}]});\\nconst effectCard=(item,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.type)||text(item.id)},remove('remove-effect:'+String(index))]},{tag:'div',className:'grid',children:[field('Type','effect-type:'+String(index),item.type),field('Track','effect-track:'+String(index),item.trackId),field('Start (seconds)','effect-start:'+String(index),item.start,'number'),field('Length (seconds)','effect-duration:'+String(index),item.duration,'number'),field('Intensity','effect-intensity:'+String(index),item.intensity,'number')]}]});\\nconst ensure=()=>{if(!draft||Array.isArray(draft)||draft.schemaVersion!==1)draft=clone(source);if(!Array.isArray(draft.tracks))draft.tracks=[];if(!Array.isArray(draft.clips))draft.clips=[];if(!Array.isArray(draft.audioItems))draft.audioItems=[];if(!Array.isArray(draft.captions))draft.captions=[];if(!Array.isArray(draft.textOverlays))draft.textOverlays=[];if(!Array.isArray(draft.effects))draft.effects=[]};\\nconst draw=()=>{ensure();StillMade.render('clips',draft.clips.length?draft.clips.map(clipCard):[{tag:'p',text:'No video clips.'}]);StillMade.render('audio',draft.audioItems.length?draft.audioItems.map(audioCard):[{tag:'p',text:'No audio items.'}]);StillMade.render('text',draft.textOverlays.length?draft.textOverlays.map(textCard):[{tag:'p',text:'No text overlays.'}]);StillMade.render('captions',draft.captions.length?draft.captions.map(captionCard):[{tag:'p',text:'No captions.'}]);StillMade.render('effects',draft.effects.length?draft.effects.map(effectCard):[{tag:'p',text:'No effects.'}]);timelineId.value=text(draft.activeTimelineId);aspect.value=text(draft.aspect);const mg=(Array.isArray(draft.fullscreenFrames)?draft.fullscreenFrames.length:0)+(Array.isArray(draft.figureSweeps)?draft.figureSweeps.length:0)+(Array.isArray(draft.graphs)?draft.graphs.length:0);graphics.textContent=String(mg)+' motion graphic item'+(mg===1?'':'s')+' retained in this Editor Block. Use Complete Editor data for advanced motion-graphics fields.';raw.value=JSON.stringify(draft,null,2);summary.textContent=String(draft.clips.length)+' video · '+String(draft.audioItems.length)+' audio · '+String(draft.captions.length)+' captions · '+String(draft.textOverlays.length)+' text';save.disabled=busy;build.disabled=busy||!assets.length;document.getElementById('reset').disabled=busy;document.getElementById('addText').disabled=busy;document.getElementById('addCaption').disabled=busy};\\nconst changed=()=>{revision+=1;raw.value=JSON.stringify(draft,null,2);status.textContent='Changes are local until you choose Review changes.'};\\naspect.addEventListener('input',()=>{draft.aspect=aspect.value;changed()});\\nStillMade.onAction(event=>{if(busy)return;ensure();const parts=event.action.split(':'),kind=parts[0],index=Number(parts[1]),clip=draft.clips.find((item,position)=>position===index),audio=draft.audioItems.find((item,position)=>position===index),title=draft.textOverlays.find((item,position)=>position===index),caption=draft.captions.find((item,position)=>position===index),effect=draft.effects.find((item,position)=>position===index);\\n if(kind==='remove-clip'){draft.clips=draft.clips.filter((item,position)=>position!==index);changed();draw();return}if(kind==='remove-audio'){draft.audioItems=draft.audioItems.filter((item,position)=>position!==index);changed();draw();return}if(kind==='remove-text'){draft.textOverlays=draft.textOverlays.filter((item,position)=>position!==index);changed();draw();return}if(kind==='remove-caption'){draft.captions=draft.captions.filter((item,position)=>position!==index);changed();draw();return}if(kind==='remove-effect'){draft.effects=draft.effects.filter((item,position)=>position!==index);changed();draw();return}\\n if(clip){if(kind==='clip-track')clip.trackId=event.value;if(kind==='clip-start')clip.start=Math.max(0,Number(event.value)||0);if(kind==='clip-duration')clip.duration=Math.max(0.001,Number(event.value)||0.001);if(kind==='clip-trim')clip.trimStart=Math.max(0,Number(event.value)||0);if(kind==='clip-speed')clip.speed=Math.max(0.01,Number(event.value)||1);if(kind==='clip-volume')clip.volume=Math.max(0,Number(event.value)||0);if(kind==='clip-transition'||kind==='clip-transition-duration'){if(!clip.transition||Array.isArray(clip.transition))clip.transition={type:'Cut',duration:0};if(kind==='clip-transition')clip.transition.type=event.value;else clip.transition.duration=Math.max(0,Number(event.value)||0)}if(kind==='clip-motion'||kind==='clip-easing'){if(!clip.motion||Array.isArray(clip.motion))clip.motion={type:'none',easing:'ease-in-out'};if(kind==='clip-motion')clip.motion.type=event.value;else clip.motion.easing=event.value}}\\n if(audio){if(kind==='audio-track')audio.trackId=event.value;if(kind==='audio-start')audio.start=Math.max(0,Number(event.value)||0);if(kind==='audio-duration')audio.duration=Math.max(0.001,Number(event.value)||0.001);if(kind==='audio-trim'){audio.trimStart=Math.max(0,Number(event.value)||0);audio.sourceOffset=audio.trimStart}if(kind==='audio-volume')audio.volume=Math.max(0,Number(event.value)||0);if(kind==='audio-muted')audio.muted=event.checked}\\n if(title){if(kind==='text-value')title.text=event.value;if(kind==='text-track')title.trackId=event.value;if(kind==='text-start')title.start=Math.max(0,Number(event.value)||0);if(kind==='text-duration')title.duration=Math.max(0.001,Number(event.value)||0.001);if(kind==='text-animation')title.animation=event.value}\\n if(caption){if(kind==='caption-value')caption.text=event.value;if(kind==='caption-track')caption.trackId=event.value;if(kind==='caption-start')caption.start=Math.max(0,Number(event.value)||0);if(kind==='caption-end')caption.end=Math.max(caption.start+0.001,Number(event.value)||caption.start+0.001);if(kind==='caption-animation')caption.animation=event.value}\\n if(effect){if(kind==='effect-type')effect.type=event.value;if(kind==='effect-track')effect.trackId=event.value;if(kind==='effect-start')effect.start=Math.max(0,Number(event.value)||0);if(kind==='effect-duration')effect.duration=Math.max(0.001,Number(event.value)||0.001);if(kind==='effect-intensity')effect.intensity=Number(event.value)}changed()});\\nbuild.addEventListener('click',()=>{if(!busy){draft=assemble();changed();draw();status.textContent='Built an editable timeline from current project media.'}});\\ndocument.getElementById('addText').addEventListener('click',()=>{if(busy)return;ensure();draft.textOverlays=[...draft.textOverlays,{id:'portable-text-'+String(draft.textOverlays.length+1)+'-'+String(revision+1),trackId:'text',text:'New text',start:0,duration:2,animation:'none'}];changed();draw()});\\ndocument.getElementById('addCaption').addEventListener('click',()=>{if(busy)return;ensure();draft.captions=[...draft.captions,{id:'portable-caption-'+String(draft.captions.length+1)+'-'+String(revision+1),trackId:'captions',text:'New caption',start:0,end:2,font:'Hanken Grotesk',animation:'none'}];changed();draw()});\\ndocument.getElementById('applyRaw').addEventListener('click',()=>{if(busy)return;try{const value=JSON.parse(raw.value);if(!value||Array.isArray(value)||value.schemaVersion!==1||typeof value.activeTimelineId!=='string')throw Error('Editor JSON must be a version 1 document with an active timeline ID.');draft=clone(value);changed();draw();status.textContent='Complete Editor data applied locally.'}catch(error){status.textContent=error.message}});\\ndocument.getElementById('reset').addEventListener('click',()=>{if(!busy){draft=clone(source);revision+=1;draw();status.textContent='Changes reset to the current Editor timeline.'}});\\nsave.addEventListener('click',async()=>{if(busy)return;const started=revision;busy=true;draw();status.textContent='Checking the complete Editor timeline…';try{const result=await StillMade.run({editor:source,updatedEditor:draft,commit:true});draft=clone(result.editor);if(started===revision)status.textContent='Editor changes are ready below. Review the before and after, then choose Apply.'}catch(error){status.textContent=error.message||'Editor changes could not be prepared.'}finally{busy=false;draw()}});\\nStillMade.onInput(values=>{source=clone(values.editor||source);assets=clone(values.assets||[]);draft=source.clips?.length||source.audioItems?.length?clone(source):assemble();revision+=1;draw();status.textContent='Edit the complete timeline. Motion graphics and every other Editor tool stay inside this Block.'});\\n\\ndocument.getElementById('renderFinal').addEventListener('click',async()=>{if(busy)return;busy=true;draw();status.textContent='Preparing the exact final render…';try{await StillMade.run({editor:source,updatedEditor:draft,commit:false,action:'render'});status.textContent='Final render is ready below. Choose Render final file to start the device renderer.'}catch(error){status.textContent=error.message||'The render plan could not be prepared.'}finally{busy=false;draw()}});\\n\"\n}"},"lineage":{"parents":[],"changes":"Packaged original Block source for StillMade."}}}],"license":"MIT"}