{"schemaVersion":1,"id":"stillmade.single-release-teaser","version":"1.0.2","name":"Single Release Teaser","description":"Combine original cover artwork, a song excerpt and approved release details into an editable social teaser.","license":"MIT","startingChat":"native","summary":{"text":"Combine original cover artwork, a song excerpt and approved release details into an editable social teaser.","origin":"human","generation":"authored","status":"ready"},"defaults":{"aspectRatio":"9:16","brief":"Upload one original cover image and one rights-cleared song. Set the excerpt timing and exact artist/release copy. For lyric excerpts, enter approved lyrics with timings relative to the selected excerpt. Review the full sound and timing before export. No music generation, automatic lyric alignment, or streaming-platform certification is included."},"onboarding":[],"packages":[{"manifest":{"schemaVersion":1,"sdkVersion":"0.1.0","id":"stillmade.release-visuals","version":"1.0.1","name":"Release Visuals","description":"Build an editable social release teaser or timed lyric excerpt from original cover art and a supplied recording.","kind":"task","runtime":"javascript","entry":"src/run.js","license":"MIT","inputs":{"assets":{"type":"asset[]","default":[],"description":"One cover image and one audio recording.","primary":true,"required":true,"semantic":"legacy.asset-list.assets","sources":["upstream","user"]},"purpose":{"type":"text","default":"release-teaser","description":"Release teaser or lyric excerpt.","semantic":"stillmade.release_visuals.purpose","sources":["user","default"],"required":false},"title":{"type":"text","default":"","description":"Exact release title, up to 56 characters.","required":true,"semantic":"stillmade.release_visuals.title","sources":["user","default"]},"artist":{"type":"text","default":"","description":"Exact artist name, up to 56 characters.","required":true,"semantic":"stillmade.release_visuals.artist","sources":["user","default"]},"cta":{"type":"text","default":"","description":"Approved release message or destination. Teasers only; lyrics occupy this space.","semantic":"stillmade.release_visuals.cta","sources":["user","default"],"required":false},"duration":{"type":"number","default":20,"description":"Excerpt duration, 8–60 seconds.","min":8,"max":60,"semantic":"stillmade.release_visuals.duration","sources":["user","default"],"required":false},"songVolume":{"type":"number","default":100,"description":"Song volume, 1–100. Lower for additional headroom; this is not loudness normalization.","min":1,"max":100,"semantic":"stillmade.release_visuals.songvolume","sources":["user","default"],"required":false},"offset":{"type":"number","default":0,"description":"Start time within the original song, in seconds.","min":0,"max":7200,"semantic":"stillmade.release_visuals.offset","sources":["user","default"],"required":false},"lyrics":{"type":"text","default":"","description":"Reviewed lyric lines relative to this excerpt: 0-3.5 | exact words. One line per phrase; no automatic alignment.","semantic":"stillmade.release_visuals.lyrics","sources":["user","default"],"required":false},"aspect":{"type":"text","default":"9:16","description":"Output frame shape.","semantic":"stillmade.release_visuals.aspect","sources":["user","default"],"required":false},"disclosure":{"type":"text","default":"","description":"Optional source or demonstration disclosure.","semantic":"stillmade.release_visuals.disclosure","sources":["user","default"],"required":false},"rightsConfirmed":{"type":"boolean","default":false,"description":"I have rights to the cover art, recording, lyrics and supplied statements.","required":true,"sources":["user"],"semantic":"stillmade.release_visuals.rightsconfirmed"}},"outputs":{"timeline":{"type":"timeline","primary":true,"semantic":"legacy.timeline.updatededitor","description":"Complete editable timeline using original source media."},"review":{"type":"json","semantic":"stillmade.release_visuals.review","description":"Production scope and remaining human review.","schema":{"schemaVersion":"integer","state":"string","humanApproved":"boolean","purpose":"string","durationSec":"number","sourceOffset":"number","lyricCount":"integer","providerCalls":"integer","warnings":"string[]"}}},"permissions":{"project":["asset.read"],"network":[],"filesystem":[],"secrets":[]},"ui":[{"port":"songVolume","control":"slider","min":1,"max":100,"step":1},{"port":"purpose","control":"select","options":["release-teaser","lyric-excerpt"]},{"port":"duration","control":"slider","min":8,"max":60,"step":1},{"port":"aspect","control":"select","options":["9:16","16:9","1:1"]}],"platforms":{"phone":{"supported":true},"browser":{"supported":true},"desktop":{"supported":true}},"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\n\nMIT License\n\nCopyright (c) <year> <copyright holders>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and \nassociated documentation files (the \"Software\"), to deal in the Software without restriction, including \nwithout limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell \ncopies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the \nfollowing conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial \nportions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT \nLIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO \nEVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER \nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE \nUSE OR OTHER DEALINGS IN THE SOFTWARE.\n","portableSources":[{"kind":"original","license":"MIT","paths":["LICENSE","src/run.js"],"evidence":["upstream/0/LICENSE","upstream/0/src/run.js"],"changes":"Original implementation declared by the packager; no reused repository or dependency code."}]},"semantics":[{"name":"stillmade.release_visuals.purpose","description":"Release teaser or lyric excerpt.","parents":[]},{"name":"stillmade.release_visuals.title","description":"Exact release title, up to 56 characters.","parents":[]},{"name":"stillmade.release_visuals.artist","description":"Exact artist name, up to 56 characters.","parents":[]},{"name":"stillmade.release_visuals.cta","description":"Approved release message or destination. Teasers only; lyrics occupy this space.","parents":[]},{"name":"stillmade.release_visuals.duration","description":"Excerpt duration, 8–60 seconds.","parents":[]},{"name":"stillmade.release_visuals.songvolume","description":"Song volume, 1–100. Lower for additional headroom; this is not loudness normalization.","parents":[]},{"name":"stillmade.release_visuals.offset","description":"Start time within the original song, in seconds.","parents":[]},{"name":"stillmade.release_visuals.lyrics","description":"Reviewed lyric lines relative to this excerpt: 0-3.5 | exact words. One line per phrase; no automatic alignment.","parents":[]},{"name":"stillmade.release_visuals.aspect","description":"Output frame shape.","parents":[]},{"name":"stillmade.release_visuals.disclosure","description":"Optional source or demonstration disclosure.","parents":[]},{"name":"stillmade.release_visuals.rightsconfirmed","description":"I have rights to the cover art, recording, lyrics and supplied statements.","parents":[]},{"name":"stillmade.release_visuals.review","description":"Production scope and remaining human review.","parents":[]}]},"code":"// Original release-art and lyric-excerpt composition. No inference or I/O.\nconst copy=x=>JSON.parse(JSON.stringify(x)),check=(ok,message)=>{if(!ok)throw Error(message);};\nconst short=(v,label,n=80)=>{check(typeof v==='string'&&v.length<=n&&!/[\\u0000-\\u0008\\u000b\\u000c\\u000e-\\u001f]/.test(v),label+' must be short plain text.');return v.trim();};\ncheck(input.rightsConfirmed===true,'Confirm rights to the cover art, recording and any lyrics.');\nconst songVolume=input.songVolume??100;check(Number.isFinite(songVolume)&&songVolume>=1&&songVolume<=100,'Song volume must be 1–100.');\nconst assets=input.assets;check(Array.isArray(assets)&&assets.length===2,'Choose exactly one cover image and one audio recording.');\nconst cover=assets.find(a=>a.kind==='image'),song=assets.find(a=>a.kind==='audio');check(cover&&song,'Supply one original cover image and one audio recording.');\nfor(const a of assets)check(typeof a.assetId==='string'&&a.assetId&&typeof a.versionId==='string'&&a.versionId&&typeof a.url==='string'&&/^(https:\\/\\/|http:\\/\\/(localhost|127\\.0\\.0\\.1)(:\\d+)?\\/|\\/api\\/media\\/|sm-media:|blob:)/.test(a.url)&&!/^https?:\\/\\/[^/?#]*@/.test(a.url),'Use exact saved media references.');\ncheck(Number.isFinite(cover.width)&&cover.width>0&&Number.isFinite(cover.height)&&cover.height>0,'Upload cover art again to record its dimensions.');\ncheck(Number.isFinite(song.duration)&&song.duration>0,'Upload the recording again to measure its duration.');\nconst duration=input.duration??20,offset=input.offset??0;\ncheck(Number.isFinite(duration)&&duration>=8&&duration<=60&&Number.isFinite(offset)&&offset>=0&&offset+duration<=song.duration+.02,'Choose an available 8–60 second song excerpt.');\nconst title=short(input.title||'','Release title',56),artist=short(input.artist||'','Artist',56),cta=short(input.cta||'','Release message',64),disclosure=short(input.disclosure||'','Disclosure',100);check(title&&artist,'Supply the release title and artist.');\nconst aspect=input.aspect||'9:16';check(['9:16','1:1','16:9'].includes(aspect),'Choose an output frame shape.');\nconst purpose=input.purpose||'release-teaser';check(['release-teaser','lyric-excerpt'].includes(purpose),'Choose a release teaser or lyric excerpt.');\nconst raw=input.lyrics||'';check(typeof raw==='string'&&raw.length<=8000,'Use up to 8,000 characters of timed lyrics.');\n// Human-approved lyric timing is relative to this excerpt, not the full song.\nconst lyrics=raw.trim()?raw.trim().split('\\n').map(line=>{const m=line.match(/^(\\d+(?:\\.\\d+)?)\\s*-\\s*(\\d+(?:\\.\\d+)?)\\s*\\|\\s*(.+)$/);check(m,'Use lyric lines like 0-3.5 | exact words');const from=+m[1],to=+m[2],value=short(m[3],'Lyric line',100);check(to>from&&from>=0&&to<=duration,'A lyric line is outside the excerpt.');return{from,to,text:value};}):[];\ncheck(lyrics.length<=40,'Use at most 40 lyric lines.');for(let i=1;i<lyrics.length;i++)check(lyrics[i].from>=lyrics[i-1].to,'Lyric lines must be ordered without overlap.');check(purpose!=='lyric-excerpt'||lyrics.length,'Supply reviewed timed lyrics for a lyric excerpt.');\nconst portrait=aspect==='9:16',square=aspect==='1:1',W=369*Number(aspect.split(':')[0])/Number(aspect.split(':')[1]);\nconst fit=Math.min(W/cover.width,369/cover.height),scale=Math.min(W*.84/(cover.width*fit),369*(portrait?.46:.6)/(cover.height*fit));\nconst clips=[{id:'original-cover',kind:'image',trackId:'art',asset:copy(cover),assetId:cover.assetId,versionId:cover.versionId,url:cover.url,title:cover.name||'Original artwork',start:0,duration,trimStart:0,volume:0,speed:1,transform:{fit:'contain',scale,x:0,y:portrait?-22:-10,rotation:0,opacity:1},motion:{type:'zoom',intensity:100,zoomAmount:1.035,zoomDirection:'in',zoomAnchor:'center',easing:'ease-in-out',loop:false,['window']:[0,100]},transition:{type:'Cut',duration:0}}];\nconst overlays=[],stickers=[];\nconst add=(id,value,start,end,y,size,color='#F7F0DB')=>{if(value)overlays.push({id,type:'text',trackId:'copy',text:value,start,end,font:'Hanken Grotesk',size,color,background:'none',width:.84,x:50,y,position:'center',animation:'fade',animIn:.25,animOut:.2});};\nadd('artist',artist,0,duration,portrait?13:9,portrait?10:14);\nadd('release-title',title,0,duration,portrait?70:79,portrait?21:25);\nadd('release-message',lyrics.length?'':cta,0,duration,portrait?86:92,portrait?10:13);\nfor(const [i,line]of lyrics.entries())add('lyric-'+i,line.text,line.from,line.to,portrait?82:91,portrait?12:15);\n// The progress row indicates excerpt time only; it makes no beat-detection claim.\nfor(let i=0;i<16;i++)stickers.push({id:'progress-'+i,trackId:'detail',shape:'underline',color:'#F7F0DB',x:20+i*4,y:portrait?92:97,scale:.04,stretchX:.55,stretchY:.4,opacity:.75,rotation:0,start:duration*i/16,end:duration});\nadd('disclosure',disclosure,0,duration,97,portrait?5:7);\nconst audioItems=[{id:'original-song',trackId:'song',asset:copy(song),assetId:song.assetId,versionId:song.versionId,url:song.url,title:song.name||'Original song',start:0,duration,sourceOffset:offset,trimStart:offset,volume:songVolume,rate:1,fadeIn:.15,fadeOut:.7}];\nconst timeline={schemaVersion:1,activeTimelineId:'release-visuals',name:title,aspect,aspectRatio:aspect,previewH:369,backgroundColor:'#0A0A0A',tracks:[{id:'art',type:'video',label:'Original artwork'},{id:'song',type:'audio',label:'Original recording'},{id:'copy',type:'text',label:'Release copy and lyrics'},{id:'detail',type:'overlay',label:'Excerpt progress'}],trackOrder:['art','song','detail','copy'],clips,audioItems,textOverlays:overlays,captions:[],stickers,effects:[],audio:copy(audioItems),overlays:copy(overlays),targetDuration:duration,exportSettings:{aspect,fps:30,resolution:'1080p',quality:'high'}};\nreturn {timeline,review:{schemaVersion:1,state:'needs-human-review',humanApproved:false,purpose,durationSec:duration,sourceOffset:offset,lyricCount:lyrics.length,providerCalls:0,warnings:['Listen to the export and review the artwork, names, date, exact lyric text and timing.','This is a social release visual, not a generated music video or a certified Spotify/Apple Music asset.','No beat detection, automatic lyric alignment, generated vocals or music licensing is included.']}};\n","tests":[{"name":"Release Visuals original-media example 1","input":{"assets":[{"kind":"image","assetId":"photo-1","versionId":"v1","url":"https://media.example/photo-1.jpg","width":1600,"height":1200},{"kind":"audio","assetId":"original-song","versionId":"v1","url":"https://media.example/song.wav","duration":180}],"title":"A new chapter","artist":"Example artist","cta":"Listen to the release","lyrics":"0-5 | This is an original demo line\n5-10 | Not a copied song","duration":20,"rightsConfirmed":true},"expected":{"timeline":{"schemaVersion":1,"activeTimelineId":"release-visuals","name":"A new chapter","aspect":"9:16","aspectRatio":"9:16","previewH":369,"backgroundColor":"#0A0A0A","tracks":[{"id":"art","type":"video","label":"Original artwork"},{"id":"song","type":"audio","label":"Original recording"},{"id":"copy","type":"text","label":"Release copy and lyrics"},{"id":"detail","type":"overlay","label":"Excerpt progress"}],"trackOrder":["art","song","detail","copy"],"clips":[{"id":"original-cover","kind":"image","trackId":"art","asset":{"kind":"image","assetId":"photo-1","versionId":"v1","url":"https://media.example/photo-1.jpg","width":1600,"height":1200},"assetId":"photo-1","versionId":"v1","url":"https://media.example/photo-1.jpg","title":"Original artwork","start":0,"duration":20,"trimStart":0,"volume":0,"speed":1,"transform":{"fit":"contain","scale":0.84,"x":0,"y":-22,"rotation":0,"opacity":1},"motion":{"type":"zoom","intensity":100,"zoomAmount":1.035,"zoomDirection":"in","zoomAnchor":"center","easing":"ease-in-out","loop":false,"window":[0,100]},"transition":{"type":"Cut","duration":0}}],"audioItems":[{"id":"original-song","trackId":"song","asset":{"kind":"audio","assetId":"original-song","versionId":"v1","url":"https://media.example/song.wav","duration":180},"assetId":"original-song","versionId":"v1","url":"https://media.example/song.wav","title":"Original song","start":0,"duration":20,"sourceOffset":0,"trimStart":0,"volume":100,"rate":1,"fadeIn":0.15,"fadeOut":0.7}],"textOverlays":[{"id":"artist","type":"text","trackId":"copy","text":"Example artist","start":0,"end":20,"font":"Hanken Grotesk","size":10,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":13,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"release-title","type":"text","trackId":"copy","text":"A new chapter","start":0,"end":20,"font":"Hanken Grotesk","size":21,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":70,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"lyric-0","type":"text","trackId":"copy","text":"This is an original demo line","start":0,"end":5,"font":"Hanken Grotesk","size":12,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":82,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"lyric-1","type":"text","trackId":"copy","text":"Not a copied song","start":5,"end":10,"font":"Hanken Grotesk","size":12,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":82,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2}],"captions":[],"stickers":[{"id":"progress-0","trackId":"detail","shape":"underline","color":"#F7F0DB","x":20,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":0,"end":20},{"id":"progress-1","trackId":"detail","shape":"underline","color":"#F7F0DB","x":24,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":1.25,"end":20},{"id":"progress-2","trackId":"detail","shape":"underline","color":"#F7F0DB","x":28,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":2.5,"end":20},{"id":"progress-3","trackId":"detail","shape":"underline","color":"#F7F0DB","x":32,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":3.75,"end":20},{"id":"progress-4","trackId":"detail","shape":"underline","color":"#F7F0DB","x":36,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":5,"end":20},{"id":"progress-5","trackId":"detail","shape":"underline","color":"#F7F0DB","x":40,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":6.25,"end":20},{"id":"progress-6","trackId":"detail","shape":"underline","color":"#F7F0DB","x":44,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":7.5,"end":20},{"id":"progress-7","trackId":"detail","shape":"underline","color":"#F7F0DB","x":48,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":8.75,"end":20},{"id":"progress-8","trackId":"detail","shape":"underline","color":"#F7F0DB","x":52,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":10,"end":20},{"id":"progress-9","trackId":"detail","shape":"underline","color":"#F7F0DB","x":56,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":11.25,"end":20},{"id":"progress-10","trackId":"detail","shape":"underline","color":"#F7F0DB","x":60,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":12.5,"end":20},{"id":"progress-11","trackId":"detail","shape":"underline","color":"#F7F0DB","x":64,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":13.75,"end":20},{"id":"progress-12","trackId":"detail","shape":"underline","color":"#F7F0DB","x":68,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":15,"end":20},{"id":"progress-13","trackId":"detail","shape":"underline","color":"#F7F0DB","x":72,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":16.25,"end":20},{"id":"progress-14","trackId":"detail","shape":"underline","color":"#F7F0DB","x":76,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":17.5,"end":20},{"id":"progress-15","trackId":"detail","shape":"underline","color":"#F7F0DB","x":80,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":18.75,"end":20}],"effects":[],"audio":[{"id":"original-song","trackId":"song","asset":{"kind":"audio","assetId":"original-song","versionId":"v1","url":"https://media.example/song.wav","duration":180},"assetId":"original-song","versionId":"v1","url":"https://media.example/song.wav","title":"Original song","start":0,"duration":20,"sourceOffset":0,"trimStart":0,"volume":100,"rate":1,"fadeIn":0.15,"fadeOut":0.7}],"overlays":[{"id":"artist","type":"text","trackId":"copy","text":"Example artist","start":0,"end":20,"font":"Hanken Grotesk","size":10,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":13,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"release-title","type":"text","trackId":"copy","text":"A new chapter","start":0,"end":20,"font":"Hanken Grotesk","size":21,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":70,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"lyric-0","type":"text","trackId":"copy","text":"This is an original demo line","start":0,"end":5,"font":"Hanken Grotesk","size":12,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":82,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"lyric-1","type":"text","trackId":"copy","text":"Not a copied song","start":5,"end":10,"font":"Hanken Grotesk","size":12,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":82,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2}],"targetDuration":20,"exportSettings":{"aspect":"9:16","fps":30,"resolution":"1080p","quality":"high"}},"review":{"schemaVersion":1,"state":"needs-human-review","humanApproved":false,"purpose":"release-teaser","durationSec":20,"sourceOffset":0,"lyricCount":2,"providerCalls":0,"warnings":["Listen to the export and review the artwork, names, date, exact lyric text and timing.","This is a social release visual, not a generated music video or a certified Spotify/Apple Music asset.","No beat detection, automatic lyric alignment, generated vocals or music licensing is included."]}}},{"name":"Release Visuals original-media example 2","input":{"assets":[{"kind":"image","assetId":"photo-1","versionId":"v1","url":"https://media.example/photo-1.jpg","width":1600,"height":1200},{"kind":"audio","assetId":"original-song","versionId":"v1","url":"https://media.example/song.wav","duration":180}],"title":"A new chapter","artist":"Example artist","purpose":"lyric-excerpt","lyrics":"0-5 | This is an original demo line\n5-10 | Not a copied song","duration":20,"rightsConfirmed":true},"expected":{"timeline":{"schemaVersion":1,"activeTimelineId":"release-visuals","name":"A new chapter","aspect":"9:16","aspectRatio":"9:16","previewH":369,"backgroundColor":"#0A0A0A","tracks":[{"id":"art","type":"video","label":"Original artwork"},{"id":"song","type":"audio","label":"Original recording"},{"id":"copy","type":"text","label":"Release copy and lyrics"},{"id":"detail","type":"overlay","label":"Excerpt progress"}],"trackOrder":["art","song","detail","copy"],"clips":[{"id":"original-cover","kind":"image","trackId":"art","asset":{"kind":"image","assetId":"photo-1","versionId":"v1","url":"https://media.example/photo-1.jpg","width":1600,"height":1200},"assetId":"photo-1","versionId":"v1","url":"https://media.example/photo-1.jpg","title":"Original artwork","start":0,"duration":20,"trimStart":0,"volume":0,"speed":1,"transform":{"fit":"contain","scale":0.84,"x":0,"y":-22,"rotation":0,"opacity":1},"motion":{"type":"zoom","intensity":100,"zoomAmount":1.035,"zoomDirection":"in","zoomAnchor":"center","easing":"ease-in-out","loop":false,"window":[0,100]},"transition":{"type":"Cut","duration":0}}],"audioItems":[{"id":"original-song","trackId":"song","asset":{"kind":"audio","assetId":"original-song","versionId":"v1","url":"https://media.example/song.wav","duration":180},"assetId":"original-song","versionId":"v1","url":"https://media.example/song.wav","title":"Original song","start":0,"duration":20,"sourceOffset":0,"trimStart":0,"volume":100,"rate":1,"fadeIn":0.15,"fadeOut":0.7}],"textOverlays":[{"id":"artist","type":"text","trackId":"copy","text":"Example artist","start":0,"end":20,"font":"Hanken Grotesk","size":10,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":13,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"release-title","type":"text","trackId":"copy","text":"A new chapter","start":0,"end":20,"font":"Hanken Grotesk","size":21,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":70,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"lyric-0","type":"text","trackId":"copy","text":"This is an original demo line","start":0,"end":5,"font":"Hanken Grotesk","size":12,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":82,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"lyric-1","type":"text","trackId":"copy","text":"Not a copied song","start":5,"end":10,"font":"Hanken Grotesk","size":12,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":82,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2}],"captions":[],"stickers":[{"id":"progress-0","trackId":"detail","shape":"underline","color":"#F7F0DB","x":20,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":0,"end":20},{"id":"progress-1","trackId":"detail","shape":"underline","color":"#F7F0DB","x":24,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":1.25,"end":20},{"id":"progress-2","trackId":"detail","shape":"underline","color":"#F7F0DB","x":28,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":2.5,"end":20},{"id":"progress-3","trackId":"detail","shape":"underline","color":"#F7F0DB","x":32,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":3.75,"end":20},{"id":"progress-4","trackId":"detail","shape":"underline","color":"#F7F0DB","x":36,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":5,"end":20},{"id":"progress-5","trackId":"detail","shape":"underline","color":"#F7F0DB","x":40,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":6.25,"end":20},{"id":"progress-6","trackId":"detail","shape":"underline","color":"#F7F0DB","x":44,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":7.5,"end":20},{"id":"progress-7","trackId":"detail","shape":"underline","color":"#F7F0DB","x":48,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":8.75,"end":20},{"id":"progress-8","trackId":"detail","shape":"underline","color":"#F7F0DB","x":52,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":10,"end":20},{"id":"progress-9","trackId":"detail","shape":"underline","color":"#F7F0DB","x":56,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":11.25,"end":20},{"id":"progress-10","trackId":"detail","shape":"underline","color":"#F7F0DB","x":60,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":12.5,"end":20},{"id":"progress-11","trackId":"detail","shape":"underline","color":"#F7F0DB","x":64,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":13.75,"end":20},{"id":"progress-12","trackId":"detail","shape":"underline","color":"#F7F0DB","x":68,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":15,"end":20},{"id":"progress-13","trackId":"detail","shape":"underline","color":"#F7F0DB","x":72,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":16.25,"end":20},{"id":"progress-14","trackId":"detail","shape":"underline","color":"#F7F0DB","x":76,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":17.5,"end":20},{"id":"progress-15","trackId":"detail","shape":"underline","color":"#F7F0DB","x":80,"y":92,"scale":0.04,"stretchX":0.55,"stretchY":0.4,"opacity":0.75,"rotation":0,"start":18.75,"end":20}],"effects":[],"audio":[{"id":"original-song","trackId":"song","asset":{"kind":"audio","assetId":"original-song","versionId":"v1","url":"https://media.example/song.wav","duration":180},"assetId":"original-song","versionId":"v1","url":"https://media.example/song.wav","title":"Original song","start":0,"duration":20,"sourceOffset":0,"trimStart":0,"volume":100,"rate":1,"fadeIn":0.15,"fadeOut":0.7}],"overlays":[{"id":"artist","type":"text","trackId":"copy","text":"Example artist","start":0,"end":20,"font":"Hanken Grotesk","size":10,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":13,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"release-title","type":"text","trackId":"copy","text":"A new chapter","start":0,"end":20,"font":"Hanken Grotesk","size":21,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":70,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"lyric-0","type":"text","trackId":"copy","text":"This is an original demo line","start":0,"end":5,"font":"Hanken Grotesk","size":12,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":82,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2},{"id":"lyric-1","type":"text","trackId":"copy","text":"Not a copied song","start":5,"end":10,"font":"Hanken Grotesk","size":12,"color":"#F7F0DB","background":"none","width":0.84,"x":50,"y":82,"position":"center","animation":"fade","animIn":0.25,"animOut":0.2}],"targetDuration":20,"exportSettings":{"aspect":"9:16","fps":30,"resolution":"1080p","quality":"high"}},"review":{"schemaVersion":1,"state":"needs-human-review","humanApproved":false,"purpose":"lyric-excerpt","durationSec":20,"sourceOffset":0,"lyricCount":2,"providerCalls":0,"warnings":["Listen to the export and review the artwork, names, date, exact lyric text and timing.","This is a social release visual, not a generated music video or a certified Spotify/Apple Music asset.","No beat detection, automatic lyric alignment, generated vocals or music licensing is included."]}}}],"portable":{"format":"stillmade-block/1","dependencies":[],"sources":[{"kind":"original","license":"MIT","paths":["LICENSE","src/run.js"],"evidence":["upstream/0/LICENSE","upstream/0/src/run.js"],"changes":"Original implementation declared by the packager; no reused repository or dependency code."}],"files":{"upstream/0/LICENSE":"MIT License\n\nCopyright (c) <year> <copyright holders>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and \nassociated documentation files (the \"Software\"), to deal in the Software without restriction, including \nwithout limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell \ncopies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the \nfollowing conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial \nportions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT \nLIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO \nEVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER \nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE \nUSE OR OTHER DEALINGS IN THE SOFTWARE.\n","upstream/0/src/run.js":"// Original release-art and lyric-excerpt composition. No inference or I/O.\nconst copy=x=>JSON.parse(JSON.stringify(x)),check=(ok,message)=>{if(!ok)throw Error(message);};\nconst short=(v,label,n=80)=>{check(typeof v==='string'&&v.length<=n&&!/[\\u0000-\\u0008\\u000b\\u000c\\u000e-\\u001f]/.test(v),label+' must be short plain text.');return v.trim();};\ncheck(input.rightsConfirmed===true,'Confirm rights to the cover art, recording and any lyrics.');\nconst songVolume=input.songVolume??100;check(Number.isFinite(songVolume)&&songVolume>=1&&songVolume<=100,'Song volume must be 1–100.');\nconst assets=input.assets;check(Array.isArray(assets)&&assets.length===2,'Choose exactly one cover image and one audio recording.');\nconst cover=assets.find(a=>a.kind==='image'),song=assets.find(a=>a.kind==='audio');check(cover&&song,'Supply one original cover image and one audio recording.');\nfor(const a of assets)check(typeof a.assetId==='string'&&a.assetId&&typeof a.versionId==='string'&&a.versionId&&typeof a.url==='string'&&/^(https:\\/\\/|http:\\/\\/(localhost|127\\.0\\.0\\.1)(:\\d+)?\\/|\\/api\\/media\\/|sm-media:|blob:)/.test(a.url)&&!/^https?:\\/\\/[^/?#]*@/.test(a.url),'Use exact saved media references.');\ncheck(Number.isFinite(cover.width)&&cover.width>0&&Number.isFinite(cover.height)&&cover.height>0,'Upload cover art again to record its dimensions.');\ncheck(Number.isFinite(song.duration)&&song.duration>0,'Upload the recording again to measure its duration.');\nconst duration=input.duration??20,offset=input.offset??0;\ncheck(Number.isFinite(duration)&&duration>=8&&duration<=60&&Number.isFinite(offset)&&offset>=0&&offset+duration<=song.duration+.02,'Choose an available 8–60 second song excerpt.');\nconst title=short(input.title||'','Release title',56),artist=short(input.artist||'','Artist',56),cta=short(input.cta||'','Release message',64),disclosure=short(input.disclosure||'','Disclosure',100);check(title&&artist,'Supply the release title and artist.');\nconst aspect=input.aspect||'9:16';check(['9:16','1:1','16:9'].includes(aspect),'Choose an output frame shape.');\nconst purpose=input.purpose||'release-teaser';check(['release-teaser','lyric-excerpt'].includes(purpose),'Choose a release teaser or lyric excerpt.');\nconst raw=input.lyrics||'';check(typeof raw==='string'&&raw.length<=8000,'Use up to 8,000 characters of timed lyrics.');\n// Human-approved lyric timing is relative to this excerpt, not the full song.\nconst lyrics=raw.trim()?raw.trim().split('\\n').map(line=>{const m=line.match(/^(\\d+(?:\\.\\d+)?)\\s*-\\s*(\\d+(?:\\.\\d+)?)\\s*\\|\\s*(.+)$/);check(m,'Use lyric lines like 0-3.5 | exact words');const from=+m[1],to=+m[2],value=short(m[3],'Lyric line',100);check(to>from&&from>=0&&to<=duration,'A lyric line is outside the excerpt.');return{from,to,text:value};}):[];\ncheck(lyrics.length<=40,'Use at most 40 lyric lines.');for(let i=1;i<lyrics.length;i++)check(lyrics[i].from>=lyrics[i-1].to,'Lyric lines must be ordered without overlap.');check(purpose!=='lyric-excerpt'||lyrics.length,'Supply reviewed timed lyrics for a lyric excerpt.');\nconst portrait=aspect==='9:16',square=aspect==='1:1',W=369*Number(aspect.split(':')[0])/Number(aspect.split(':')[1]);\nconst fit=Math.min(W/cover.width,369/cover.height),scale=Math.min(W*.84/(cover.width*fit),369*(portrait?.46:.6)/(cover.height*fit));\nconst clips=[{id:'original-cover',kind:'image',trackId:'art',asset:copy(cover),assetId:cover.assetId,versionId:cover.versionId,url:cover.url,title:cover.name||'Original artwork',start:0,duration,trimStart:0,volume:0,speed:1,transform:{fit:'contain',scale,x:0,y:portrait?-22:-10,rotation:0,opacity:1},motion:{type:'zoom',intensity:100,zoomAmount:1.035,zoomDirection:'in',zoomAnchor:'center',easing:'ease-in-out',loop:false,['window']:[0,100]},transition:{type:'Cut',duration:0}}];\nconst overlays=[],stickers=[];\nconst add=(id,value,start,end,y,size,color='#F7F0DB')=>{if(value)overlays.push({id,type:'text',trackId:'copy',text:value,start,end,font:'Hanken Grotesk',size,color,background:'none',width:.84,x:50,y,position:'center',animation:'fade',animIn:.25,animOut:.2});};\nadd('artist',artist,0,duration,portrait?13:9,portrait?10:14);\nadd('release-title',title,0,duration,portrait?70:79,portrait?21:25);\nadd('release-message',lyrics.length?'':cta,0,duration,portrait?86:92,portrait?10:13);\nfor(const [i,line]of lyrics.entries())add('lyric-'+i,line.text,line.from,line.to,portrait?82:91,portrait?12:15);\n// The progress row indicates excerpt time only; it makes no beat-detection claim.\nfor(let i=0;i<16;i++)stickers.push({id:'progress-'+i,trackId:'detail',shape:'underline',color:'#F7F0DB',x:20+i*4,y:portrait?92:97,scale:.04,stretchX:.55,stretchY:.4,opacity:.75,rotation:0,start:duration*i/16,end:duration});\nadd('disclosure',disclosure,0,duration,97,portrait?5:7);\nconst audioItems=[{id:'original-song',trackId:'song',asset:copy(song),assetId:song.assetId,versionId:song.versionId,url:song.url,title:song.name||'Original song',start:0,duration,sourceOffset:offset,trimStart:offset,volume:songVolume,rate:1,fadeIn:.15,fadeOut:.7}];\nconst timeline={schemaVersion:1,activeTimelineId:'release-visuals',name:title,aspect,aspectRatio:aspect,previewH:369,backgroundColor:'#0A0A0A',tracks:[{id:'art',type:'video',label:'Original artwork'},{id:'song',type:'audio',label:'Original recording'},{id:'copy',type:'text',label:'Release copy and lyrics'},{id:'detail',type:'overlay',label:'Excerpt progress'}],trackOrder:['art','song','detail','copy'],clips,audioItems,textOverlays:overlays,captions:[],stickers,effects:[],audio:copy(audioItems),overlays:copy(overlays),targetDuration:duration,exportSettings:{aspect,fps:30,resolution:'1080p',quality:'high'}};\nreturn {timeline,review:{schemaVersion:1,state:'needs-human-review',humanApproved:false,purpose,durationSec:duration,sourceOffset:offset,lyricCount:lyrics.length,providerCalls:0,warnings:['Listen to the export and review the artwork, names, date, exact lyric text and timing.','This is a social release visual, not a generated music video or a certified Spotify/Apple Music asset.','No beat detection, automatic lyric alignment, generated vocals or music licensing is included.']}};\n"},"lineage":{"parents":[],"changes":"Packaged original Block source for StillMade."}}},{"manifest":{"schemaVersion":1,"sdkVersion":"0.1.0","id":"sm.editor","version":"2.2.9","name":"Editor","description":"Build and render a complete editable timeline, including coded vector scenes whose transforms may be omitted or retained in the scene document.","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) <year> <copyright holders>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and \nassociated documentation files (the \"Software\"), to deal in the Software without restriction, including \nwithout limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell \ncopies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the \nfollowing conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial \nportions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT \nLIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO \nEVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER \nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE \nUSE 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.","semantic":"editor_timeline","sources":["project"]},"assets":{"type":"asset[]","context":"assets","required":false,"default":[],"description":"Current project media used to assemble an initial editable timeline when the Editor is empty.","semantic":"legacy.asset-list.assets","sources":["project"]},"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.","semantic":"legacy.timeline.updatededitor","sources":["upstream","user","default"]},"commit":{"type":"boolean","default":false,"description":"Prepare the edited Editor document for StillMade review and Apply.","semantic":"legacy.boolean.commit","required":false,"sources":["user","default"]},"action":{"type":"text","required":false,"default":"none","description":"The Block-owned interface selects a declared host action.","semantic":"legacy.text.action","sources":["user","default"]},"renderFps":{"type":"integer","min":12,"max":60,"default":30,"description":"Frames per second sent to the declared final-render service.","semantic":"legacy.integer.renderfps","required":false,"sources":["user","default"]},"renderResolution":{"type":"integer","min":480,"max":2160,"default":1080,"description":"Output height sent to the declared final-render service.","semantic":"legacy.integer.renderresolution","required":false,"sources":["user","default"]},"renderQuality":{"type":"text","default":"high","description":"Output quality sent to the declared final-render service.","semantic":"legacy.text.renderquality","required":false,"sources":["user","default"]}},"outputs":{"editor":{"type":"timeline","primary":true,"role":"editor_timeline","description":"The complete edited timeline for immediate use and downstream Blocks.","semantic":"editor_timeline"},"edit":{"type":"workspace-edit","description":"An exact before/after Editor change reviewed before it updates the project.","semantic":"legacy.workspace-edit.edit"},"mediaAction":{"type":"approval","required":false,"role":"portable_media_action","description":"A bounded final-render request executed only after the user chooses Render and play.","semantic":"portable_media_action"}},"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 || input.action === 'render' ? 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:input.renderFps,resolution:input.renderResolution,quality:input.renderQuality},source:{id:'sm.editor',version:'2.2.9'}},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=\"undo\" type=\"button\" class=\"secondary\">Undo</button><button id=\"redo\" type=\"button\" class=\"secondary\">Redo</button><button id=\"snapshot\" type=\"button\" class=\"secondary\">Save version</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  <p id=\"sharedResult\" class=\"hint\" aria-live=\"polite\"></p>\n  <section id=\"recovery\" hidden><h2>Keep your work safe</h2><p id=\"recoveryMessage\"></p><div class=\"row\"><button id=\"retryShared\" type=\"button\" class=\"secondary\">Retry checked changes</button><button id=\"discardShared\" type=\"button\" class=\"secondary\">Discard my unshared changes</button><button id=\"resetSharedSource\" type=\"button\" class=\"secondary\" hidden>Review updated project timeline</button></div><p>The project source changed. Starting from it replaces the shared timeline draft for everyone. Unfinished JSON is retained for separate review.</p><button id=\"confirmSourceReset\" type=\"button\" hidden>Replace everyone's shared draft with the updated project timeline</button></section>\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><label>Playhead (seconds)<input id=\"playhead\" type=\"range\" min=\"0\" max=\"1\" step=\"0.05\" value=\"0\"></label></div><p id=\"timecode\" class=\"hint\"></p><div id=\"composition\" class=\"cards\"></div></section>\n  <section><h2>Project media</h2><p class=\"hint\">Preview an exact saved version, then add it to this timeline without leaving the Block.</p><img id=\"imagePreview\" alt=\"Selected project media preview\" hidden><video id=\"videoPreview\" controls hidden></video><audio id=\"audioPreview\" controls hidden></audio><div id=\"assets\" class=\"cards media-grid\"></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>Saved timeline versions</h2><div id=\"versions\" 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><div class=\"card-head\"><h2>Effects</h2><button id=\"addEffect\" type=\"button\" class=\"secondary\">Add effect</button></div><div id=\"effects\" class=\"cards\"></div></section>\n  <details id=\"rawDetails\"><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><p id=\"rawNotice\" class=\"hint\"></p><textarea id=\"raw\" class=\"raw\" spellcheck=\"false\" aria-label=\"Complete Editor data\"></textarea><div class=\"row\"><button id=\"applyRaw\" type=\"button\" class=\"secondary\">Apply JSON to workspace</button><button id=\"discardRaw\" type=\"button\" class=\"secondary\">Discard shared JSON draft</button></div></details>\n<section><h2>Final export</h2><p>Render this exact timeline through StillMade’s approved device renderer.</p><div class=\"grid\"><label>Frame rate<select id=\"renderFps\"><option value=\"24\">24 fps</option><option value=\"30\" selected>30 fps</option><option value=\"60\">60 fps</option></select></label><label>Resolution<select id=\"renderResolution\"><option value=\"720\">720p</option><option value=\"1080\" selected>1080p</option><option value=\"2160\">2160p</option></select></label><label>Quality<select id=\"renderQuality\"><option value=\"standard\">Standard</option><option value=\"high\" selected>High</option></select></label></div><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.media-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.media-card p{margin:4px 0;color:var(--fg-muted)}video,audio{display:block;width:100%;margin:10px 0}video[hidden],audio[hidden]{display:none}select{width:100%;background:var(--bg)}\n.card,.grid>*{min-width:0}.card h3,.card strong,.card p{overflow-wrap:anywhere}img{max-width:100%;height:auto}@media(max-width:560px){.media-grid{grid-template-columns:1fr}}\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'),imagePreview=document.getElementById('imagePreview'),videoPreview=document.getElementById('videoPreview'),audioPreview=document.getElementById('audioPreview'),playhead=document.getElementById('playhead'),timecode=document.getElementById('timecode');\nconst empty={schemaVersion:1,activeTimelineId:'timeline-1',tracks:[],clips:[],audioItems:[],captions:[],textOverlays:[],effects:[]};\nlet source=empty,draft=empty,assets=[],previewUrl='',previewSerial=0,busy=false,revision=0;\nlet shared=null,scratchShared=null,optionsShared=null,scratch={text:null,base:null},options={renderFps:30,renderResolution:1080,renderQuality:'high'};\nlet access={canEdit:false,error:null},scratchAccess={canEdit:false,error:null},optionsAccess={canEdit:false,error:null},sourceResetArmed=false,rawBaseline=null,rawStale=false;\nlet undoStack=[],redoStack=[],historyBefore=null,historyAfter=null;\nconst tokens=new Map(),identities=new Map(),pages=new Map();\nconst clone=value=>JSON.parse(JSON.stringify(value));\nconst text=value=>value===undefined||value===null?'':String(value);\nconst uniqueId=prefix=>prefix+'-'+Date.now().toString(36)+'-'+Math.random().toString(36).slice(2,14);\nconst blocked=()=>busy||!shared||!scratchShared||!optionsShared||!access.canEdit||!scratchAccess.canEdit||!optionsAccess.canEdit||!!access.error||!!scratchAccess.error||!!optionsAccess.error;\nconst allowed=()=>access.canEdit&&scratchAccess.canEdit&&optionsAccess.canEdit&&!access.error&&!scratchAccess.error&&!optionsAccess.error;\nconst token=(kind,item)=>{const key=JSON.stringify(kind==='asset'?[kind,item.kind,item.assetId,item.versionId]:[kind,item.id]);if(!tokens.has(key)){const value='i'+String(tokens.size+1);tokens.set(key,value);}const handle=tokens.get(key);identities.set(handle,{kind,item});return handle;};\nconst normalize=value=>({...value,tracks:Array.isArray(value.tracks)?value.tracks:[],clips:Array.isArray(value.clips)?value.clips:[],audioItems:Array.isArray(value.audioItems)?value.audioItems:[],captions:Array.isArray(value.captions)?value.captions:[],textOverlays:Array.isArray(value.textOverlays)?value.textOverlays:[],effects:Array.isArray(value.effects)?value.effects:[]});\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 normalize(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 normalize(next);};\nconst field=(label,action,value,type='text',wide=false)=>({tag:'label',className:wide?'wide':'',children:[{tag:'span',text:label},{tag:'input',id:'control-'+action.replace(':','-'),type,action,value:Number.isFinite(value)?value:text(value),disabled:blocked(),label}]});\nconst remove=action=>({tag:'button',action,text:'Remove',className:'danger',disabled:blocked()});\nconst assetCard=(item,index)=>({tag:'article',id:'card-'+token('asset',item),className:'card media-card',children:[{tag:'strong',text:text(item.name)||text(item.assetId)},{tag:'p',text:text(item.kind)+' · version '+text(item.versionId)},{tag:'div',className:'row',children:[{tag:'button',action:'preview-asset:'+token('asset',item),text:'Preview',className:'secondary',disabled:false},{tag:'button',action:'add-asset:'+token('asset',item),text:item.kind==='audio'?'Add audio':'Add clip',className:'secondary',disabled:blocked()}]}]});\nconst clipCard=(item,index)=>({tag:'article',id:'card-'+token('clip',item),className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.label)||text(item.name)||text(item.id)},{tag:'div',className:'row',children:[{tag:'button',action:'preview-clip:'+token('clip',item),text:'Preview',className:'secondary',disabled:!(item.asset||item.assetId)},{tag:'button',action:'move-clip-up:'+token('clip',item),text:'Up',className:'secondary',disabled:blocked()||index===0},{tag:'button',action:'move-clip-down:'+token('clip',item),text:'Down',className:'secondary',disabled:blocked()||index===draft.clips.length-1},{tag:'button',action:'split-clip:'+token('clip',item),text:'Split',className:'secondary',disabled:blocked()||Number(item.duration)<=0.002},{tag:'button',action:'duplicate-clip:'+token('clip',item),text:'Duplicate',className:'secondary',disabled:blocked()},remove('remove-clip:'+token('clip',item))]}]},{tag:'div',className:'grid',children:[field('Track','clip-track:'+token('clip',item),item.trackId),field('Start (seconds)','clip-start:'+token('clip',item),item.start,'number'),field('Length (seconds)','clip-duration:'+token('clip',item),item.duration,'number'),field('Trim start','clip-trim:'+token('clip',item),item.trimStart,'number'),field('Speed','clip-speed:'+token('clip',item),item.speed,'number'),field('Volume','clip-volume:'+token('clip',item),item.volume,'number'),field('Transition','clip-transition:'+token('clip',item),item.transition&&item.transition.type),field('Transition length','clip-transition-duration:'+token('clip',item),item.transition&&item.transition.duration,'number'),field('Motion','clip-motion:'+token('clip',item),item.motion&&item.motion.type),field('Motion easing','clip-easing:'+token('clip',item),item.motion&&item.motion.easing),field('Opacity','clip-opacity:'+token('clip',item),item.transform&&item.transform.opacity!==undefined?item.transform.opacity:item.opacity,'number'),{tag:'label',children:[{tag:'span',text:'Reverse playback'},{tag:'input',type:'checkbox',id:'control-'+('clip-reverse:'+token('clip',item)).replace(':','-'),action:'clip-reverse:'+token('clip',item),checked:!!item.reverse,disabled:blocked(),label:'Reverse playback'}]}]}]});\nconst audioCard=(item,index)=>({tag:'article',id:'card-'+token('audio',item),className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.label)||text(item.name)||text(item.id)},{tag:'div',className:'row',children:[{tag:'button',action:'preview-audio:'+token('audio',item),text:'Preview',className:'secondary',disabled:!(item.asset||item.assetId)},remove('remove-audio:'+token('audio',item))]}]},{tag:'div',className:'grid',children:[field('Track','audio-track:'+token('audio',item),item.trackId),field('Start (seconds)','audio-start:'+token('audio',item),item.start,'number'),field('Length (seconds)','audio-duration:'+token('audio',item),item.duration,'number'),field('Trim start','audio-trim:'+token('audio',item),item.trimStart===undefined?item.sourceOffset:item.trimStart,'number'),field('Volume','audio-volume:'+token('audio',item),item.volume,'number'),field('Fade in','audio-fade-in:'+token('audio',item),item.fadeIn,'number'),field('Fade out','audio-fade-out:'+token('audio',item),item.fadeOut,'number'),field('Ducking','audio-ducking:'+token('audio',item),item.ducking,'number'),field('Playback speed','audio-rate:'+token('audio',item),item.rate,'number'),{tag:'label',children:[{tag:'span',text:'Loop source'},{tag:'input',type:'checkbox',id:'control-'+('audio-loop:'+token('audio',item)).replace(':','-'),action:'audio-loop:'+token('audio',item),checked:!!item.loop,disabled:blocked(),label:'Loop source'}]},{tag:'label',children:[{tag:'span',text:'Muted'},{tag:'input',type:'checkbox',id:'control-'+('audio-muted:'+token('audio',item)).replace(':','-'),action:'audio-muted:'+token('audio',item),checked:!!item.muted,disabled:blocked(),label:'Muted'}]}]}]});\nconst textCard=(item,index)=>({tag:'article',id:'card-'+token('text',item),className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.id)},remove('remove-text:'+token('text',item))]},{tag:'div',className:'grid',children:[field('Text','text-value:'+token('text',item),item.text,'text',true),field('Track','text-track:'+token('text',item),item.trackId),field('Start (seconds)','text-start:'+token('text',item),item.start,'number'),field('Length (seconds)','text-duration:'+token('text',item),item.duration,'number'),field('Animation','text-animation:'+token('text',item),item.animation)]}]});\nconst captionCard=(item,index)=>({tag:'article',id:'card-'+token('caption',item),className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.id)},remove('remove-caption:'+token('caption',item))]},{tag:'div',className:'grid',children:[field('Caption','caption-value:'+token('caption',item),item.text,'text',true),field('Track','caption-track:'+token('caption',item),item.trackId),field('Start (seconds)','caption-start:'+token('caption',item),item.start,'number'),field('End (seconds)','caption-end:'+token('caption',item),item.end,'number'),field('Animation','caption-animation:'+token('caption',item),item.animation)]}]});\nconst effectCard=(item,index)=>({tag:'article',id:'card-'+token('effect',item),className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.type)||text(item.id)},remove('remove-effect:'+token('effect',item))]},{tag:'div',className:'grid',children:[field('Type','effect-type:'+token('effect',item),item.type),field('Track','effect-track:'+token('effect',item),item.trackId),field('Start (seconds)','effect-start:'+token('effect',item),item.start,'number'),field('Length (seconds)','effect-duration:'+token('effect',item),item.duration,'number'),field('Intensity','effect-intensity:'+token('effect',item),item.intensity,'number')]}]});\nconst largeTimeline=()=>draft.clips.length+draft.audioItems.length+draft.textOverlays.length+draft.captions.length+draft.effects.length>2000;\nconst itemFinish=item=>(Number(item.start)||0)+Math.max(.001,Number(item.duration)||Number(item.end)-(Number(item.start)||0)||.001);\nconst composition=()=>{const at=Number(playhead.value)||0;if(largeTimeline()){StillMade.render('composition',[{tag:'strong',text:'Lightweight preview · large timeline'},{tag:'p',text:'Partial preview: the live composition summary is paused to keep editing responsive. Every timeline item is retained for editing and the complete final render.'},{tag:'p',text:'The personal playhead uses the saved timeline duration, or a 24-hour preview window when none is supplied.'}]);timecode.textContent='Playhead '+at.toFixed(2)+' seconds';return;}const activeClips=draft.clips.filter(item=>at>=(Number(item.start)||0)&&at<itemFinish(item)),activeAudio=draft.audioItems.filter(item=>at>=(Number(item.start)||0)&&at<itemFinish(item)),activeOverlays=[...draft.textOverlays,...draft.captions,...draft.effects].filter(item=>at>=(Number(item.start)||0)&&at<itemFinish(item));StillMade.render('composition',[{tag:'strong',text:'At '+at.toFixed(2)+'s'},{tag:'p',text:(activeClips.length?activeClips.slice(0,12).map(item=>text(item.label)||text(item.id)).join(', '):'No video')+' · '+String(activeAudio.length)+' audio · '+String(activeOverlays.length)+' overlays'}]);timecode.textContent='Playhead '+at.toFixed(2)+' seconds';};\nconst rawIsOpen=()=>document.getElementById('rawDetails').getAttribute('open')!==null;\nconst renderRawPreview=()=>{if(!rawIsOpen())return;if(scratch.text!==null){if(raw.value!==scratch.text)raw.value=scratch.text;return;}rawBaseline=draft;const value=JSON.stringify(draft,null,2);if(raw.value!==value)raw.value=value;};\nconst schedulePreview=()=>{if(rawIsOpen())StillMade.scheduleSharedEdit('editorRawPreview',renderRawPreview);};\nconst drawRecovery=()=>{const states=[access,scratchAccess,optionsAccess],failure=states.find(value=>value.error),sourceMismatch=states.some(value=>value.sourceConflict),waiting=states.some(value=>value.pending),editable=states.every(value=>value.canEdit);document.getElementById('recovery').hidden=!failure;document.getElementById('recoveryMessage').textContent=failure?failure.error:'';document.getElementById('retryShared').disabled=!editable||waiting||sourceMismatch||busy;document.getElementById('discardShared').disabled=!editable||waiting||sourceMismatch||busy;document.getElementById('resetSharedSource').hidden=!sourceMismatch;document.getElementById('resetSharedSource').disabled=!editable||waiting||busy;document.getElementById('confirmSourceReset').hidden=!sourceMismatch||!sourceResetArmed;document.getElementById('confirmSourceReset').disabled=!editable||waiting||busy;document.getElementById('rawNotice').textContent=scratch.text===null?'JSON typing is shared live. Apply checks the original displayed values before updating the timeline.':rawStale?'The timeline changed. Shared JSON text is retained; Apply will check for conflicting edits.':'This unfinished JSON draft is shared live. Apply it when ready, or discard the shared scratch.';save.disabled=blocked()||scratch.text!==null;document.getElementById('renderFinal').disabled=blocked()||scratch.text!==null;document.getElementById('applyRaw').disabled=blocked()||scratch.text===null;document.getElementById('discardRaw').disabled=blocked()||scratch.text===null;document.getElementById('undo').disabled=blocked()||(!undoStack.length&&!historyBefore);document.getElementById('redo').disabled=blocked()||!redoStack.length;};\nconst versionCard=(item,index)=>({tag:'article',id:'card-'+token('version',item),className:'card',children:[{tag:'strong',text:text(item.label)||text(item.id)},{tag:'p',text:text(item.createdAt)},{tag:'button',action:'restore-version:'+token('version',item),text:'Restore this version',className:'secondary',disabled:blocked()}]});\nconst renderPage=(target,rows,card,size,emptyMessage)=>{const last=Math.max(0,Math.ceil(rows.length/size)-1),page=Math.min(last,pages.get(target)||0);pages.set(target,page);const content=rows.length?rows.slice(page*size,(page+1)*size).map((item,index)=>card(item,page*size+index)):[{tag:'p',text:emptyMessage}];if(rows.length>size)content.push({tag:'div',className:'row',children:[{tag:'button',action:'page-prev:'+target,text:'Previous',className:'secondary',disabled:page===0},{tag:'span',text:'Page '+String(page+1)+' of '+String(last+1)+' · '+String(rows.length)+' items'},{tag:'button',action:'page-next:'+target,text:'Next',className:'secondary',disabled:page===last}]});StillMade.render(target,content);};\nconst drawOptions=()=>{document.getElementById('renderFps').value=String(options.renderFps);document.getElementById('renderResolution').value=String(options.renderResolution);document.getElementById('renderQuality').value=options.renderQuality;};\nconst draw=()=>{renderPage('assets',assets,assetCard,12,'No saved project media is available.');renderPage('clips',draft.clips,clipCard,4,'No video clips.');renderPage('audio',draft.audioItems,audioCard,4,'No audio items.');renderPage('text',draft.textOverlays,textCard,8,'No text overlays.');renderPage('captions',draft.captions,captionCard,8,'No captions.');renderPage('effects',draft.effects,effectCard,8,'No effects.');renderPage('versions',Array.isArray(draft.timelineVersions)?draft.timelineVersions:[],versionCard,5,'No saved versions yet.');timelineId.value=text(draft.activeTimelineId);const duration=largeTimeline()?Math.max(1,Number(draft.targetDuration)||86400,Number(playhead.value)||0):Math.max(1,Number(draft.targetDuration)||0,...draft.clips.map(itemFinish),...draft.audioItems.map(itemFinish));playhead.max=String(duration);StillMade.scheduleSharedEdit('editorComposition',composition);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.';summary.textContent=String(draft.clips.length)+' video · '+String(draft.audioItems.length)+' audio · '+String(draft.captions.length)+' captions · '+String(draft.textOverlays.length)+' text';['reset','addText','addCaption','addEffect','snapshot','renderFps','renderResolution','renderQuality'].forEach(id=>{document.getElementById(id).disabled=blocked();});build.disabled=blocked()||!assets.length;aspect.disabled=blocked();raw.disabled=blocked();drawOptions();drawRecovery();schedulePreview();};\nconst captureHistory=()=>{if(!historyBefore)return;const before=historyBefore,after=historyAfter;historyBefore=null;historyAfter=null;try{const forward=StillMade.diffDocument(before,after);if(forward.length){undoStack=[...undoStack,{forward,inverse:StillMade.diffDocument(after,before)}].slice(-50);redoStack=[];}}catch(error){undoStack=[];redoStack=[];status.textContent='This change is too large for local undo. The shared timeline is retained.';}drawRecovery();};\nconst commitEdit=(next,record=true)=>{if(record){if(!historyBefore)historyBefore=draft;historyAfter=next;StillMade.scheduleSharedEdit('editorHistory',captureHistory);}draft=next;revision+=1;sourceResetArmed=false;if(scratch.text!==null)rawStale=true;shared.changed();schedulePreview();StillMade.scheduleSharedEdit('editorComposition',composition);drawRecovery();status.textContent='Sharing timeline changes. Review changes applies the document to your project.';};\nconst replaceRows=(kind,rows)=>{if(kind==='clip')commitEdit({...draft,clips:rows});if(kind==='audio')commitEdit({...draft,audioItems:rows});if(kind==='text')commitEdit({...draft,textOverlays:rows});if(kind==='caption')commitEdit({...draft,captions:rows});if(kind==='effect')commitEdit({...draft,effects:rows});};\nconst rowsFor=kind=>kind==='clip'?draft.clips:kind==='audio'?draft.audioItems:kind==='text'?draft.textOverlays:kind==='caption'?draft.captions:kind==='effect'?draft.effects:kind==='version'?(draft.timelineVersions||[]):[];\nconst previewItem=(item,kind,trim=0)=>{const serial=++previewSerial;if(previewUrl){StillMade.releaseMedia(previewUrl);previewUrl='';}imagePreview.hidden=true;videoPreview.hidden=true;audioPreview.hidden=true;const value=item.asset||item,mediaKind=value.kind||kind,request=mediaKind==='image'?StillMade.previewImage(value):StillMade.previewMedia({...value,kind:mediaKind});request.then(result=>{if(serial!==previewSerial){if(mediaKind!=='image')StillMade.releaseMedia(result.url);return;}if(mediaKind==='image'){imagePreview.src=result.url;imagePreview.hidden=false;}else if(mediaKind==='audio'){previewUrl=result.url;audioPreview.src=result.url;audioPreview.hidden=false;}else{previewUrl=result.url;videoPreview.src=result.url;videoPreview.currentTime=Math.max(0,Number(trim)||0);videoPreview.hidden=false;}status.textContent='Previewing '+text(item.label||item.name||item.id||item.assetId)+'.';}).catch(error=>{if(serial===previewSerial)status.textContent=error.message;});};\naspect.addEventListener('input',()=>{if(blocked())return;commitEdit({...draft,aspect:aspect.value});});\nplayhead.addEventListener('input',()=>{timecode.textContent='Playhead '+(Number(playhead.value)||0).toFixed(2)+' seconds';StillMade.scheduleSharedEdit('editorComposition',composition);});\ndocument.getElementById('rawDetails').addEventListener('toggle',renderRawPreview);\nraw.addEventListener('input',()=>{if(blocked())return;scratch={text:raw.value,base:scratch.text===null?(rawBaseline||draft):scratch.base};scratchShared.changed();drawRecovery();});\ndocument.getElementById('discardRaw').addEventListener('click',()=>{if(blocked())return;scratch={text:null,base:null};rawStale=false;scratchShared.changed();renderRawPreview();drawRecovery();});\nStillMade.onAction(event=>{const parts=event.action.split(':'),kind=parts[0],handle=parts[1];if(kind==='page-prev'||kind==='page-next'){if(!['assets','clips','audio','text','captions','effects','versions'].includes(handle))return;pages.set(handle,Math.max(0,(pages.get(handle)||0)+(kind==='page-prev'?-1:1)));draw();return;}const identity=identities.get(handle);if(!identity)return;const rows=rowsFor(identity.kind),item=(identity.kind==='asset'?assets:rows).includes(identity.item)?identity.item:null,index=rows.indexOf(item);if(!item)return;\n if(kind==='preview-clip'&&identity.kind==='clip'){previewItem(item,'video',item.trimStart);return;}if(kind==='preview-audio'&&identity.kind==='audio'){previewItem(item,'audio');return;}if(kind==='preview-asset'&&identity.kind==='asset'){previewItem(item,item.kind);return;}if(blocked())return;\n if(kind==='restore-version'&&identity.kind==='version'){commitEdit({...draft,clips:clone(item.clips||[]),audioItems:clone(item.audioItems||[]),captions:clone(item.captions||[]),textOverlays:clone(item.textOverlays||[]),effects:clone(item.effects||[])});draw();return;}\n if(kind==='add-asset'&&identity.kind==='asset'){const media=clone(item),duration=Math.max(.001,Number(media.duration)||Number(media.durationSec)||4);if(media.kind==='audio')commitEdit({...draft,audioItems:[...draft.audioItems,{id:uniqueId('audio'),trackId:'audio',start:0,duration,trimStart:0,volume:1,asset:media,url:media.url}]});else{const start=draft.clips.reduce((end,value)=>Math.max(end,itemFinish(value)),0);commitEdit({...draft,clips:[...draft.clips,{id:uniqueId('clip'),trackId:'video',start,duration,trimStart:0,speed:1,volume:1,asset:media,url:media.url}]});}draw();return;}\n if((kind==='move-clip-up'||kind==='move-clip-down')&&identity.kind==='clip'){const targetIndex=index+(kind==='move-clip-up'?-1:1),target=rows.at(targetIndex);if(targetIndex<0||!target)return;const reordered=rows.slice();reordered.splice(targetIndex,1,item);reordered.splice(index,1,target);replaceRows('clip',reordered);draw();return;}\n if(kind==='duplicate-clip'&&identity.kind==='clip'){const next={...clone(item),id:uniqueId('clip-copy'),start:itemFinish(item)};replaceRows('clip',[...rows.slice(0,index+1),next,...rows.slice(index+1)]);draw();return;}\n if(kind==='split-clip'&&identity.kind==='clip'){const half=Math.max(.001,Number(item.duration)||.001)/2;if(half<.001)return;const second={...clone(item),id:uniqueId('clip-split'),start:(Number(item.start)||0)+half,duration:half,trimStart:(Number(item.trimStart)||0)+half};replaceRows('clip',[...rows.slice(0,index),{...item,duration:half},second,...rows.slice(index+1)]);draw();return;}\n if(kind==='remove-'+identity.kind&&['clip','audio','text','caption','effect'].includes(identity.kind)){const remaining=rows.slice();remaining.splice(index,1);replaceRows(identity.kind,remaining);draw();return;}\n const next={...item};let recognized=true;\n if(identity.kind==='clip'){if(kind==='clip-track')next.trackId=event.value;else if(kind==='clip-start')next.start=Math.max(0,Number(event.value)||0);else if(kind==='clip-duration')next.duration=Math.max(.001,Number(event.value)||.001);else if(kind==='clip-trim')next.trimStart=Math.max(0,Number(event.value)||0);else if(kind==='clip-speed')next.speed=Math.max(.01,Number(event.value)||1);else if(kind==='clip-volume')next.volume=Math.max(0,Number(event.value)||0);else if(kind==='clip-transition'||kind==='clip-transition-duration'){const prior=item.transition&&!Array.isArray(item.transition)?item.transition:{type:'Cut',duration:0};next.transition=kind==='clip-transition'?{...prior,type:event.value}:{...prior,duration:Math.max(0,Number(event.value)||0)};}else if(kind==='clip-opacity')next.transform={...(item.transform&&!Array.isArray(item.transform)?item.transform:{}),opacity:Math.max(0,Math.min(1,Number(event.value)||0))};else if(kind==='clip-reverse')next.reverse=event.checked;else if(kind==='clip-motion'||kind==='clip-easing'){const prior=item.motion&&!Array.isArray(item.motion)?item.motion:{type:'none',easing:'ease-in-out'};next.motion=kind==='clip-motion'?{...prior,type:event.value}:{...prior,easing:event.value};}else recognized=false;}\n else if(identity.kind==='audio'){if(kind==='audio-track')next.trackId=event.value;else if(kind==='audio-start')next.start=Math.max(0,Number(event.value)||0);else if(kind==='audio-duration')next.duration=Math.max(.001,Number(event.value)||.001);else if(kind==='audio-trim'){next.trimStart=Math.max(0,Number(event.value)||0);next.sourceOffset=next.trimStart;}else if(kind==='audio-volume')next.volume=Math.max(0,Number(event.value)||0);else if(kind==='audio-fade-in')next.fadeIn=Math.max(0,Number(event.value)||0);else if(kind==='audio-fade-out')next.fadeOut=Math.max(0,Number(event.value)||0);else if(kind==='audio-ducking')next.ducking=Math.max(0,Math.min(1,Number(event.value)||0));else if(kind==='audio-rate')next.rate=Math.max(.05,Math.min(4,Number(event.value)||1));else if(kind==='audio-loop')next.loop=event.checked;else if(kind==='audio-muted')next.muted=event.checked;else recognized=false;}\n else if(identity.kind==='text'){if(kind==='text-value')next.text=event.value;else if(kind==='text-track')next.trackId=event.value;else if(kind==='text-start')next.start=Math.max(0,Number(event.value)||0);else if(kind==='text-duration')next.duration=Math.max(.001,Number(event.value)||.001);else if(kind==='text-animation')next.animation=event.value;else recognized=false;}\n else if(identity.kind==='caption'){if(kind==='caption-value')next.text=event.value;else if(kind==='caption-track')next.trackId=event.value;else if(kind==='caption-start')next.start=Math.max(0,Number(event.value)||0);else if(kind==='caption-end')next.end=Math.max((Number(item.start)||0)+.001,Number(event.value)||(Number(item.start)||0)+.001);else if(kind==='caption-animation')next.animation=event.value;else recognized=false;}\n else if(identity.kind==='effect'){if(kind==='effect-type')next.type=event.value;else if(kind==='effect-track')next.trackId=event.value;else if(kind==='effect-start')next.start=Math.max(0,Number(event.value)||0);else if(kind==='effect-duration')next.duration=Math.max(.001,Number(event.value)||.001);else if(kind==='effect-intensity')next.intensity=Number(event.value)||0;else recognized=false;}\n else recognized=false;if(recognized){const updated=rows.slice();updated.splice(index,1,next);replaceRows(identity.kind,updated);identities.set(handle,{kind:identity.kind,item:next});}\n});\nbuild.addEventListener('click',()=>{if(blocked())return;const assembled=assemble();const next=source.clips?.length||source.audioItems?.length?assembled:{...assembled,clips:assembled.clips.map(item=>({...item,id:uniqueId('clip')})),audioItems:assembled.audioItems.map(item=>({...item,id:uniqueId('audio')}))};commitEdit(next);draw();});\ndocument.getElementById('addText').addEventListener('click',()=>{if(blocked())return;commitEdit({...draft,textOverlays:[...draft.textOverlays,{id:uniqueId('text'),trackId:'text',text:'New text',start:0,duration:2,animation:'none'}]});draw();});\ndocument.getElementById('addCaption').addEventListener('click',()=>{if(blocked())return;commitEdit({...draft,captions:[...draft.captions,{id:uniqueId('caption'),trackId:'captions',text:'New caption',start:0,end:2,font:'Hanken Grotesk',animation:'none'}]});draw();});\ndocument.getElementById('addEffect').addEventListener('click',()=>{if(blocked())return;commitEdit({...draft,effects:[...draft.effects,{id:uniqueId('effect'),trackId:'video',type:'fade',start:0,duration:1,intensity:1}]});draw();});\nconst undoEdit=redo=>{if(blocked())return;captureHistory();const entry=redo?redoStack.at(-1):undoStack.at(-1);if(!entry)return;try{const next=StillMade.applyDocument(draft,redo?entry.forward:entry.inverse);if(redo){redoStack=redoStack.slice(0,-1);undoStack=[...undoStack,entry];}else{undoStack=undoStack.slice(0,-1);redoStack=[...redoStack,entry];}commitEdit(next,false);draw();status.textContent=redo?'Your checked change was restored.':'Your checked change was undone. Teammate edits are retained.';}catch(error){status.textContent='Cannot '+(redo?'redo':'undo')+' because the same content changed. The shared timeline is retained.';}};\ndocument.getElementById('undo').addEventListener('click',()=>undoEdit(false));\ndocument.getElementById('redo').addEventListener('click',()=>undoEdit(true));\ndocument.getElementById('snapshot').addEventListener('click',()=>{if(blocked())return;const version={id:uniqueId('timeline-version'),label:'Timeline version '+String((draft.timelineVersions||[]).length+1),createdAt:new Date().toISOString(),clips:clone(draft.clips),audioItems:clone(draft.audioItems),captions:clone(draft.captions),textOverlays:clone(draft.textOverlays),effects:clone(draft.effects)};commitEdit({...draft,timelineVersions:[...(draft.timelineVersions||[]),version].slice(-50)});draw();});\ndocument.getElementById('reset').addEventListener('click',()=>{if(blocked())return;commitEdit(normalize(clone(source)));draw();status.textContent='Reset to the current project timeline is being shared.';});\nconst validateEditor=value=>{if(!value||Array.isArray(value)||value.schemaVersion!==1||typeof value.activeTimelineId!=='string'||!value.activeTimelineId)throw Error('Editor JSON must be a version 1 document with an active timeline ID.');[value.tracks,value.clips,value.audioItems,value.captions,value.textOverlays,value.stickers,value.effects,value.markers,value.fxEvents,value.liveOverlays,value.mediaItems,value.timelineVersions].forEach(rows=>{if(rows===undefined)return;if(!Array.isArray(rows)||rows.length>10000||rows.some(item=>!item||Array.isArray(item)||typeof item.id!=='string'||!item.id||item.id.length>200)||new Set(rows.map(item=>item.id)).size!==rows.length)throw Error('Each Editor collection needs at most 10,000 items with distinct, nonempty IDs of at most 200 characters.');});return normalize(value);};\ndocument.getElementById('applyRaw').addEventListener('click',async()=>{if(blocked()||scratch.text===null)return;const requested=JSON.stringify(scratch);busy=true;draw();try{await scratchShared.flush();if(JSON.stringify(scratch)!==requested)throw Error('The shared JSON draft changed. Review the latest text before applying it.');if(!allowed())throw Error('Editing access changed. JSON text is retained.');const pending=scratch,value=validateEditor(JSON.parse(pending.text)),edits=StillMade.diffDocument(pending.base||draft,value);commitEdit(StillMade.applyDocument(draft,edits));await shared.flush();if(!allowed())throw Error('Editing access changed. JSON text is retained.');if(JSON.stringify(scratch)===requested){scratch={text:null,base:null};rawStale=false;scratchShared.changed();await scratchShared.flush();}status.textContent='Complete Editor data applied to the shared timeline.';}catch(error){status.textContent=error.message;}finally{busy=false;draw();}});\nconst editOptions=next=>{if(blocked())return;options=next;optionsShared.changed();revision+=1;};\ndocument.getElementById('renderFps').addEventListener('change',()=>editOptions({...options,renderFps:Number(document.getElementById('renderFps').value)}));\ndocument.getElementById('renderResolution').addEventListener('change',()=>editOptions({...options,renderResolution:Number(document.getElementById('renderResolution').value)}));\ndocument.getElementById('renderQuality').addEventListener('change',()=>editOptions({...options,renderQuality:document.getElementById('renderQuality').value}));\nconst runAction=async(render)=>{if(blocked()||scratch.text!==null)return;busy=true;draw();status.textContent=render?'Preparing the exact final render…':'Checking the complete Editor timeline…';try{await shared.flush();await scratchShared.flush();await optionsShared.flush();if(!allowed()||scratch.text!==null)throw Error('Editing access or the shared draft changed. The action was not run.');const started=revision;await StillMade.run({editor:clone(source),updatedEditor:clone(draft),commit:!render,...render?{action:'render',...options}:{}});status.textContent=started!==revision?'A result is ready below; newer shared edits were retained.':render?'Final render is ready below. Choose Render final file to start the device renderer.':'Editor changes are ready below. Review the before and after, then choose Apply.';}catch(error){status.textContent=error.message||'The Editor action could not be prepared.';}finally{busy=false;draw();}};\nsave.addEventListener('click',()=>runAction(false));\ndocument.getElementById('renderFinal').addEventListener('click',()=>runAction(true));\nconst recover=async(action)=>{if(busy||!shared||![access,scratchAccess,optionsAccess].every(value=>value.canEdit&&!value.pending))return;busy=true;draw();try{await action();sourceResetArmed=false;undoStack=[];redoStack=[];historyBefore=null;historyAfter=null;status.textContent='Shared Editor draft recovered.';}catch(error){status.textContent=error.message;}finally{busy=false;draw();}};\ndocument.getElementById('retryShared').addEventListener('click',()=>recover(async()=>{await shared.retry();await scratchShared.retry();await optionsShared.retry();}));\ndocument.getElementById('discardShared').addEventListener('click',()=>recover(async()=>{await shared.discard();await scratchShared.discard();await optionsShared.discard();}));\ndocument.getElementById('resetSharedSource').addEventListener('click',()=>{sourceResetArmed=true;drawRecovery();});\ndocument.getElementById('confirmSourceReset').addEventListener('click',()=>{if(!sourceResetArmed||!access.sourceConflict)return;sourceResetArmed=false;recover(()=>shared.resetSharedSource({discardSharedEdits:true}));});\nStillMade.onShared(value=>{sourceResetArmed=false;drawRecovery();const outputs=value.outputs||{};document.getElementById('sharedResult').textContent=outputs.mediaAction?'A final-render plan is available in the shared result below.':outputs.editor?'The latest reviewed Editor result is available below.':'';});\nStillMade.onInput(values=>{sourceResetArmed=false;source=clone(values.editor||empty);assets=Array.isArray(values.assets)?clone(values.assets):[];previewSerial+=1;if(previewUrl){StillMade.releaseMedia(previewUrl);previewUrl='';}imagePreview.hidden=true;videoPreview.hidden=true;audioPreview.hidden=true;const next=normalize(values.updatedEditor&&(values.updatedEditor.clips?.length||values.updatedEditor.audioItems?.length||values.updatedEditor.timelineVersions?.length)?clone(values.updatedEditor):source.clips?.length||source.audioItems?.length?clone(source):assemble());if(!shared){draft=next;shared=StillMade.connectDocument({key:'editorDocument',source:next,read:()=>draft,replace:value=>{sourceResetArmed=false;captureHistory();draft=value;revision+=1;if(scratch.text!==null)rawStale=true;draw();}});scratchShared=StillMade.connectDocument({key:'editorScratch',source:{text:null,base:null},read:()=>scratch,replace:value=>{scratch=value;rawStale=scratch.text!==null;if(scratch.text!==null&&rawIsOpen()&&raw.value!==scratch.text)raw.value=scratch.text;else schedulePreview();drawRecovery();}});optionsShared=StillMade.connectDocument({key:'editorOptions',source:{renderFps:30,renderResolution:1080,renderQuality:'high'},read:()=>options,replace:value=>{options=value;revision+=1;drawOptions();}});shared.onStatus(value=>{const redraw=access.canEdit!==value.canEdit||access.error!==value.error;access=value;if(redraw)draw();else drawRecovery();});scratchShared.onStatus(value=>{const redraw=scratchAccess.canEdit!==value.canEdit||scratchAccess.error!==value.error;scratchAccess=value;if(redraw)draw();else drawRecovery();});optionsShared.onStatus(value=>{const redraw=optionsAccess.canEdit!==value.canEdit||optionsAccess.error!==value.error;optionsAccess=value;if(redraw)draw();else drawRecovery();});playhead.value='0';}else shared.replaceSource(next);revision+=1;draw();status.textContent=access.error||'Timeline changes, JSON drafts and export settings are shared live. Playback and previews are personal.';});\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}}}},{"name":"Retain valid legacy native IDs and nullable transforms","input":{"editor":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[],"clips":[],"audioItems":[],"captions":[],"textOverlays":[],"effects":[]},"updatedEditor":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[],"clips":[{"id":"界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界\u0001","start":0,"duration":4,"transform":null}],"audioItems":[],"captions":[],"textOverlays":[],"effects":[],"custom":{"keep":true}},"commit":true},"expected":{"editor":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[],"clips":[{"id":"界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界\u0001","start":0,"duration":4,"transform":null}],"audioItems":[],"captions":[],"textOverlays":[],"effects":[],"custom":{"keep":true}},"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":[],"clips":[{"id":"界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界\u0001","start":0,"duration":4,"transform":null}],"audioItems":[],"captions":[],"textOverlays":[],"effects":[],"custom":{"keep":true}}}}}],"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) <year> <copyright holders>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and \nassociated documentation files (the \"Software\"), to deal in the Software without restriction, including \nwithout limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell \ncopies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the \nfollowing conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial \nportions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT \nLIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO \nEVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER \nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE \nUSE 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 || input.action === 'render' ? 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:input.renderFps,resolution:input.renderResolution,quality:input.renderQuality},source:{id:'sm.editor',version:'2.2.9'}},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=\\\"undo\\\" type=\\\"button\\\" class=\\\"secondary\\\">Undo</button><button id=\\\"redo\\\" type=\\\"button\\\" class=\\\"secondary\\\">Redo</button><button id=\\\"snapshot\\\" type=\\\"button\\\" class=\\\"secondary\\\">Save version</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  <p id=\\\"sharedResult\\\" class=\\\"hint\\\" aria-live=\\\"polite\\\"></p>\\n  <section id=\\\"recovery\\\" hidden><h2>Keep your work safe</h2><p id=\\\"recoveryMessage\\\"></p><div class=\\\"row\\\"><button id=\\\"retryShared\\\" type=\\\"button\\\" class=\\\"secondary\\\">Retry checked changes</button><button id=\\\"discardShared\\\" type=\\\"button\\\" class=\\\"secondary\\\">Discard my unshared changes</button><button id=\\\"resetSharedSource\\\" type=\\\"button\\\" class=\\\"secondary\\\" hidden>Review updated project timeline</button></div><p>The project source changed. Starting from it replaces the shared timeline draft for everyone. Unfinished JSON is retained for separate review.</p><button id=\\\"confirmSourceReset\\\" type=\\\"button\\\" hidden>Replace everyone's shared draft with the updated project timeline</button></section>\\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><label>Playhead (seconds)<input id=\\\"playhead\\\" type=\\\"range\\\" min=\\\"0\\\" max=\\\"1\\\" step=\\\"0.05\\\" value=\\\"0\\\"></label></div><p id=\\\"timecode\\\" class=\\\"hint\\\"></p><div id=\\\"composition\\\" class=\\\"cards\\\"></div></section>\\n  <section><h2>Project media</h2><p class=\\\"hint\\\">Preview an exact saved version, then add it to this timeline without leaving the Block.</p><img id=\\\"imagePreview\\\" alt=\\\"Selected project media preview\\\" hidden><video id=\\\"videoPreview\\\" controls hidden></video><audio id=\\\"audioPreview\\\" controls hidden></audio><div id=\\\"assets\\\" class=\\\"cards media-grid\\\"></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>Saved timeline versions</h2><div id=\\\"versions\\\" 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><div class=\\\"card-head\\\"><h2>Effects</h2><button id=\\\"addEffect\\\" type=\\\"button\\\" class=\\\"secondary\\\">Add effect</button></div><div id=\\\"effects\\\" class=\\\"cards\\\"></div></section>\\n  <details id=\\\"rawDetails\\\"><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><p id=\\\"rawNotice\\\" class=\\\"hint\\\"></p><textarea id=\\\"raw\\\" class=\\\"raw\\\" spellcheck=\\\"false\\\" aria-label=\\\"Complete Editor data\\\"></textarea><div class=\\\"row\\\"><button id=\\\"applyRaw\\\" type=\\\"button\\\" class=\\\"secondary\\\">Apply JSON to workspace</button><button id=\\\"discardRaw\\\" type=\\\"button\\\" class=\\\"secondary\\\">Discard shared JSON draft</button></div></details>\\n<section><h2>Final export</h2><p>Render this exact timeline through StillMade’s approved device renderer.</p><div class=\\\"grid\\\"><label>Frame rate<select id=\\\"renderFps\\\"><option value=\\\"24\\\">24 fps</option><option value=\\\"30\\\" selected>30 fps</option><option value=\\\"60\\\">60 fps</option></select></label><label>Resolution<select id=\\\"renderResolution\\\"><option value=\\\"720\\\">720p</option><option value=\\\"1080\\\" selected>1080p</option><option value=\\\"2160\\\">2160p</option></select></label><label>Quality<select id=\\\"renderQuality\\\"><option value=\\\"standard\\\">Standard</option><option value=\\\"high\\\" selected>High</option></select></label></div><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.media-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.media-card p{margin:4px 0;color:var(--fg-muted)}video,audio{display:block;width:100%;margin:10px 0}video[hidden],audio[hidden]{display:none}select{width:100%;background:var(--bg)}\\n.card,.grid>*{min-width:0}.card h3,.card strong,.card p{overflow-wrap:anywhere}img{max-width:100%;height:auto}@media(max-width:560px){.media-grid{grid-template-columns:1fr}}\\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'),imagePreview=document.getElementById('imagePreview'),videoPreview=document.getElementById('videoPreview'),audioPreview=document.getElementById('audioPreview'),playhead=document.getElementById('playhead'),timecode=document.getElementById('timecode');\\nconst empty={schemaVersion:1,activeTimelineId:'timeline-1',tracks:[],clips:[],audioItems:[],captions:[],textOverlays:[],effects:[]};\\nlet source=empty,draft=empty,assets=[],previewUrl='',previewSerial=0,busy=false,revision=0;\\nlet shared=null,scratchShared=null,optionsShared=null,scratch={text:null,base:null},options={renderFps:30,renderResolution:1080,renderQuality:'high'};\\nlet access={canEdit:false,error:null},scratchAccess={canEdit:false,error:null},optionsAccess={canEdit:false,error:null},sourceResetArmed=false,rawBaseline=null,rawStale=false;\\nlet undoStack=[],redoStack=[],historyBefore=null,historyAfter=null;\\nconst tokens=new Map(),identities=new Map(),pages=new Map();\\nconst clone=value=>JSON.parse(JSON.stringify(value));\\nconst text=value=>value===undefined||value===null?'':String(value);\\nconst uniqueId=prefix=>prefix+'-'+Date.now().toString(36)+'-'+Math.random().toString(36).slice(2,14);\\nconst blocked=()=>busy||!shared||!scratchShared||!optionsShared||!access.canEdit||!scratchAccess.canEdit||!optionsAccess.canEdit||!!access.error||!!scratchAccess.error||!!optionsAccess.error;\\nconst allowed=()=>access.canEdit&&scratchAccess.canEdit&&optionsAccess.canEdit&&!access.error&&!scratchAccess.error&&!optionsAccess.error;\\nconst token=(kind,item)=>{const key=JSON.stringify(kind==='asset'?[kind,item.kind,item.assetId,item.versionId]:[kind,item.id]);if(!tokens.has(key)){const value='i'+String(tokens.size+1);tokens.set(key,value);}const handle=tokens.get(key);identities.set(handle,{kind,item});return handle;};\\nconst normalize=value=>({...value,tracks:Array.isArray(value.tracks)?value.tracks:[],clips:Array.isArray(value.clips)?value.clips:[],audioItems:Array.isArray(value.audioItems)?value.audioItems:[],captions:Array.isArray(value.captions)?value.captions:[],textOverlays:Array.isArray(value.textOverlays)?value.textOverlays:[],effects:Array.isArray(value.effects)?value.effects:[]});\\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 normalize(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 normalize(next);};\\nconst field=(label,action,value,type='text',wide=false)=>({tag:'label',className:wide?'wide':'',children:[{tag:'span',text:label},{tag:'input',id:'control-'+action.replace(':','-'),type,action,value:Number.isFinite(value)?value:text(value),disabled:blocked(),label}]});\\nconst remove=action=>({tag:'button',action,text:'Remove',className:'danger',disabled:blocked()});\\nconst assetCard=(item,index)=>({tag:'article',id:'card-'+token('asset',item),className:'card media-card',children:[{tag:'strong',text:text(item.name)||text(item.assetId)},{tag:'p',text:text(item.kind)+' · version '+text(item.versionId)},{tag:'div',className:'row',children:[{tag:'button',action:'preview-asset:'+token('asset',item),text:'Preview',className:'secondary',disabled:false},{tag:'button',action:'add-asset:'+token('asset',item),text:item.kind==='audio'?'Add audio':'Add clip',className:'secondary',disabled:blocked()}]}]});\\nconst clipCard=(item,index)=>({tag:'article',id:'card-'+token('clip',item),className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.label)||text(item.name)||text(item.id)},{tag:'div',className:'row',children:[{tag:'button',action:'preview-clip:'+token('clip',item),text:'Preview',className:'secondary',disabled:!(item.asset||item.assetId)},{tag:'button',action:'move-clip-up:'+token('clip',item),text:'Up',className:'secondary',disabled:blocked()||index===0},{tag:'button',action:'move-clip-down:'+token('clip',item),text:'Down',className:'secondary',disabled:blocked()||index===draft.clips.length-1},{tag:'button',action:'split-clip:'+token('clip',item),text:'Split',className:'secondary',disabled:blocked()||Number(item.duration)<=0.002},{tag:'button',action:'duplicate-clip:'+token('clip',item),text:'Duplicate',className:'secondary',disabled:blocked()},remove('remove-clip:'+token('clip',item))]}]},{tag:'div',className:'grid',children:[field('Track','clip-track:'+token('clip',item),item.trackId),field('Start (seconds)','clip-start:'+token('clip',item),item.start,'number'),field('Length (seconds)','clip-duration:'+token('clip',item),item.duration,'number'),field('Trim start','clip-trim:'+token('clip',item),item.trimStart,'number'),field('Speed','clip-speed:'+token('clip',item),item.speed,'number'),field('Volume','clip-volume:'+token('clip',item),item.volume,'number'),field('Transition','clip-transition:'+token('clip',item),item.transition&&item.transition.type),field('Transition length','clip-transition-duration:'+token('clip',item),item.transition&&item.transition.duration,'number'),field('Motion','clip-motion:'+token('clip',item),item.motion&&item.motion.type),field('Motion easing','clip-easing:'+token('clip',item),item.motion&&item.motion.easing),field('Opacity','clip-opacity:'+token('clip',item),item.transform&&item.transform.opacity!==undefined?item.transform.opacity:item.opacity,'number'),{tag:'label',children:[{tag:'span',text:'Reverse playback'},{tag:'input',type:'checkbox',id:'control-'+('clip-reverse:'+token('clip',item)).replace(':','-'),action:'clip-reverse:'+token('clip',item),checked:!!item.reverse,disabled:blocked(),label:'Reverse playback'}]}]}]});\\nconst audioCard=(item,index)=>({tag:'article',id:'card-'+token('audio',item),className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.label)||text(item.name)||text(item.id)},{tag:'div',className:'row',children:[{tag:'button',action:'preview-audio:'+token('audio',item),text:'Preview',className:'secondary',disabled:!(item.asset||item.assetId)},remove('remove-audio:'+token('audio',item))]}]},{tag:'div',className:'grid',children:[field('Track','audio-track:'+token('audio',item),item.trackId),field('Start (seconds)','audio-start:'+token('audio',item),item.start,'number'),field('Length (seconds)','audio-duration:'+token('audio',item),item.duration,'number'),field('Trim start','audio-trim:'+token('audio',item),item.trimStart===undefined?item.sourceOffset:item.trimStart,'number'),field('Volume','audio-volume:'+token('audio',item),item.volume,'number'),field('Fade in','audio-fade-in:'+token('audio',item),item.fadeIn,'number'),field('Fade out','audio-fade-out:'+token('audio',item),item.fadeOut,'number'),field('Ducking','audio-ducking:'+token('audio',item),item.ducking,'number'),field('Playback speed','audio-rate:'+token('audio',item),item.rate,'number'),{tag:'label',children:[{tag:'span',text:'Loop source'},{tag:'input',type:'checkbox',id:'control-'+('audio-loop:'+token('audio',item)).replace(':','-'),action:'audio-loop:'+token('audio',item),checked:!!item.loop,disabled:blocked(),label:'Loop source'}]},{tag:'label',children:[{tag:'span',text:'Muted'},{tag:'input',type:'checkbox',id:'control-'+('audio-muted:'+token('audio',item)).replace(':','-'),action:'audio-muted:'+token('audio',item),checked:!!item.muted,disabled:blocked(),label:'Muted'}]}]}]});\\nconst textCard=(item,index)=>({tag:'article',id:'card-'+token('text',item),className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.id)},remove('remove-text:'+token('text',item))]},{tag:'div',className:'grid',children:[field('Text','text-value:'+token('text',item),item.text,'text',true),field('Track','text-track:'+token('text',item),item.trackId),field('Start (seconds)','text-start:'+token('text',item),item.start,'number'),field('Length (seconds)','text-duration:'+token('text',item),item.duration,'number'),field('Animation','text-animation:'+token('text',item),item.animation)]}]});\\nconst captionCard=(item,index)=>({tag:'article',id:'card-'+token('caption',item),className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.id)},remove('remove-caption:'+token('caption',item))]},{tag:'div',className:'grid',children:[field('Caption','caption-value:'+token('caption',item),item.text,'text',true),field('Track','caption-track:'+token('caption',item),item.trackId),field('Start (seconds)','caption-start:'+token('caption',item),item.start,'number'),field('End (seconds)','caption-end:'+token('caption',item),item.end,'number'),field('Animation','caption-animation:'+token('caption',item),item.animation)]}]});\\nconst effectCard=(item,index)=>({tag:'article',id:'card-'+token('effect',item),className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h3',text:text(item.type)||text(item.id)},remove('remove-effect:'+token('effect',item))]},{tag:'div',className:'grid',children:[field('Type','effect-type:'+token('effect',item),item.type),field('Track','effect-track:'+token('effect',item),item.trackId),field('Start (seconds)','effect-start:'+token('effect',item),item.start,'number'),field('Length (seconds)','effect-duration:'+token('effect',item),item.duration,'number'),field('Intensity','effect-intensity:'+token('effect',item),item.intensity,'number')]}]});\\nconst largeTimeline=()=>draft.clips.length+draft.audioItems.length+draft.textOverlays.length+draft.captions.length+draft.effects.length>2000;\\nconst itemFinish=item=>(Number(item.start)||0)+Math.max(.001,Number(item.duration)||Number(item.end)-(Number(item.start)||0)||.001);\\nconst composition=()=>{const at=Number(playhead.value)||0;if(largeTimeline()){StillMade.render('composition',[{tag:'strong',text:'Lightweight preview · large timeline'},{tag:'p',text:'Partial preview: the live composition summary is paused to keep editing responsive. Every timeline item is retained for editing and the complete final render.'},{tag:'p',text:'The personal playhead uses the saved timeline duration, or a 24-hour preview window when none is supplied.'}]);timecode.textContent='Playhead '+at.toFixed(2)+' seconds';return;}const activeClips=draft.clips.filter(item=>at>=(Number(item.start)||0)&&at<itemFinish(item)),activeAudio=draft.audioItems.filter(item=>at>=(Number(item.start)||0)&&at<itemFinish(item)),activeOverlays=[...draft.textOverlays,...draft.captions,...draft.effects].filter(item=>at>=(Number(item.start)||0)&&at<itemFinish(item));StillMade.render('composition',[{tag:'strong',text:'At '+at.toFixed(2)+'s'},{tag:'p',text:(activeClips.length?activeClips.slice(0,12).map(item=>text(item.label)||text(item.id)).join(', '):'No video')+' · '+String(activeAudio.length)+' audio · '+String(activeOverlays.length)+' overlays'}]);timecode.textContent='Playhead '+at.toFixed(2)+' seconds';};\\nconst rawIsOpen=()=>document.getElementById('rawDetails').getAttribute('open')!==null;\\nconst renderRawPreview=()=>{if(!rawIsOpen())return;if(scratch.text!==null){if(raw.value!==scratch.text)raw.value=scratch.text;return;}rawBaseline=draft;const value=JSON.stringify(draft,null,2);if(raw.value!==value)raw.value=value;};\\nconst schedulePreview=()=>{if(rawIsOpen())StillMade.scheduleSharedEdit('editorRawPreview',renderRawPreview);};\\nconst drawRecovery=()=>{const states=[access,scratchAccess,optionsAccess],failure=states.find(value=>value.error),sourceMismatch=states.some(value=>value.sourceConflict),waiting=states.some(value=>value.pending),editable=states.every(value=>value.canEdit);document.getElementById('recovery').hidden=!failure;document.getElementById('recoveryMessage').textContent=failure?failure.error:'';document.getElementById('retryShared').disabled=!editable||waiting||sourceMismatch||busy;document.getElementById('discardShared').disabled=!editable||waiting||sourceMismatch||busy;document.getElementById('resetSharedSource').hidden=!sourceMismatch;document.getElementById('resetSharedSource').disabled=!editable||waiting||busy;document.getElementById('confirmSourceReset').hidden=!sourceMismatch||!sourceResetArmed;document.getElementById('confirmSourceReset').disabled=!editable||waiting||busy;document.getElementById('rawNotice').textContent=scratch.text===null?'JSON typing is shared live. Apply checks the original displayed values before updating the timeline.':rawStale?'The timeline changed. Shared JSON text is retained; Apply will check for conflicting edits.':'This unfinished JSON draft is shared live. Apply it when ready, or discard the shared scratch.';save.disabled=blocked()||scratch.text!==null;document.getElementById('renderFinal').disabled=blocked()||scratch.text!==null;document.getElementById('applyRaw').disabled=blocked()||scratch.text===null;document.getElementById('discardRaw').disabled=blocked()||scratch.text===null;document.getElementById('undo').disabled=blocked()||(!undoStack.length&&!historyBefore);document.getElementById('redo').disabled=blocked()||!redoStack.length;};\\nconst versionCard=(item,index)=>({tag:'article',id:'card-'+token('version',item),className:'card',children:[{tag:'strong',text:text(item.label)||text(item.id)},{tag:'p',text:text(item.createdAt)},{tag:'button',action:'restore-version:'+token('version',item),text:'Restore this version',className:'secondary',disabled:blocked()}]});\\nconst renderPage=(target,rows,card,size,emptyMessage)=>{const last=Math.max(0,Math.ceil(rows.length/size)-1),page=Math.min(last,pages.get(target)||0);pages.set(target,page);const content=rows.length?rows.slice(page*size,(page+1)*size).map((item,index)=>card(item,page*size+index)):[{tag:'p',text:emptyMessage}];if(rows.length>size)content.push({tag:'div',className:'row',children:[{tag:'button',action:'page-prev:'+target,text:'Previous',className:'secondary',disabled:page===0},{tag:'span',text:'Page '+String(page+1)+' of '+String(last+1)+' · '+String(rows.length)+' items'},{tag:'button',action:'page-next:'+target,text:'Next',className:'secondary',disabled:page===last}]});StillMade.render(target,content);};\\nconst drawOptions=()=>{document.getElementById('renderFps').value=String(options.renderFps);document.getElementById('renderResolution').value=String(options.renderResolution);document.getElementById('renderQuality').value=options.renderQuality;};\\nconst draw=()=>{renderPage('assets',assets,assetCard,12,'No saved project media is available.');renderPage('clips',draft.clips,clipCard,4,'No video clips.');renderPage('audio',draft.audioItems,audioCard,4,'No audio items.');renderPage('text',draft.textOverlays,textCard,8,'No text overlays.');renderPage('captions',draft.captions,captionCard,8,'No captions.');renderPage('effects',draft.effects,effectCard,8,'No effects.');renderPage('versions',Array.isArray(draft.timelineVersions)?draft.timelineVersions:[],versionCard,5,'No saved versions yet.');timelineId.value=text(draft.activeTimelineId);const duration=largeTimeline()?Math.max(1,Number(draft.targetDuration)||86400,Number(playhead.value)||0):Math.max(1,Number(draft.targetDuration)||0,...draft.clips.map(itemFinish),...draft.audioItems.map(itemFinish));playhead.max=String(duration);StillMade.scheduleSharedEdit('editorComposition',composition);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.';summary.textContent=String(draft.clips.length)+' video · '+String(draft.audioItems.length)+' audio · '+String(draft.captions.length)+' captions · '+String(draft.textOverlays.length)+' text';['reset','addText','addCaption','addEffect','snapshot','renderFps','renderResolution','renderQuality'].forEach(id=>{document.getElementById(id).disabled=blocked();});build.disabled=blocked()||!assets.length;aspect.disabled=blocked();raw.disabled=blocked();drawOptions();drawRecovery();schedulePreview();};\\nconst captureHistory=()=>{if(!historyBefore)return;const before=historyBefore,after=historyAfter;historyBefore=null;historyAfter=null;try{const forward=StillMade.diffDocument(before,after);if(forward.length){undoStack=[...undoStack,{forward,inverse:StillMade.diffDocument(after,before)}].slice(-50);redoStack=[];}}catch(error){undoStack=[];redoStack=[];status.textContent='This change is too large for local undo. The shared timeline is retained.';}drawRecovery();};\\nconst commitEdit=(next,record=true)=>{if(record){if(!historyBefore)historyBefore=draft;historyAfter=next;StillMade.scheduleSharedEdit('editorHistory',captureHistory);}draft=next;revision+=1;sourceResetArmed=false;if(scratch.text!==null)rawStale=true;shared.changed();schedulePreview();StillMade.scheduleSharedEdit('editorComposition',composition);drawRecovery();status.textContent='Sharing timeline changes. Review changes applies the document to your project.';};\\nconst replaceRows=(kind,rows)=>{if(kind==='clip')commitEdit({...draft,clips:rows});if(kind==='audio')commitEdit({...draft,audioItems:rows});if(kind==='text')commitEdit({...draft,textOverlays:rows});if(kind==='caption')commitEdit({...draft,captions:rows});if(kind==='effect')commitEdit({...draft,effects:rows});};\\nconst rowsFor=kind=>kind==='clip'?draft.clips:kind==='audio'?draft.audioItems:kind==='text'?draft.textOverlays:kind==='caption'?draft.captions:kind==='effect'?draft.effects:kind==='version'?(draft.timelineVersions||[]):[];\\nconst previewItem=(item,kind,trim=0)=>{const serial=++previewSerial;if(previewUrl){StillMade.releaseMedia(previewUrl);previewUrl='';}imagePreview.hidden=true;videoPreview.hidden=true;audioPreview.hidden=true;const value=item.asset||item,mediaKind=value.kind||kind,request=mediaKind==='image'?StillMade.previewImage(value):StillMade.previewMedia({...value,kind:mediaKind});request.then(result=>{if(serial!==previewSerial){if(mediaKind!=='image')StillMade.releaseMedia(result.url);return;}if(mediaKind==='image'){imagePreview.src=result.url;imagePreview.hidden=false;}else if(mediaKind==='audio'){previewUrl=result.url;audioPreview.src=result.url;audioPreview.hidden=false;}else{previewUrl=result.url;videoPreview.src=result.url;videoPreview.currentTime=Math.max(0,Number(trim)||0);videoPreview.hidden=false;}status.textContent='Previewing '+text(item.label||item.name||item.id||item.assetId)+'.';}).catch(error=>{if(serial===previewSerial)status.textContent=error.message;});};\\naspect.addEventListener('input',()=>{if(blocked())return;commitEdit({...draft,aspect:aspect.value});});\\nplayhead.addEventListener('input',()=>{timecode.textContent='Playhead '+(Number(playhead.value)||0).toFixed(2)+' seconds';StillMade.scheduleSharedEdit('editorComposition',composition);});\\ndocument.getElementById('rawDetails').addEventListener('toggle',renderRawPreview);\\nraw.addEventListener('input',()=>{if(blocked())return;scratch={text:raw.value,base:scratch.text===null?(rawBaseline||draft):scratch.base};scratchShared.changed();drawRecovery();});\\ndocument.getElementById('discardRaw').addEventListener('click',()=>{if(blocked())return;scratch={text:null,base:null};rawStale=false;scratchShared.changed();renderRawPreview();drawRecovery();});\\nStillMade.onAction(event=>{const parts=event.action.split(':'),kind=parts[0],handle=parts[1];if(kind==='page-prev'||kind==='page-next'){if(!['assets','clips','audio','text','captions','effects','versions'].includes(handle))return;pages.set(handle,Math.max(0,(pages.get(handle)||0)+(kind==='page-prev'?-1:1)));draw();return;}const identity=identities.get(handle);if(!identity)return;const rows=rowsFor(identity.kind),item=(identity.kind==='asset'?assets:rows).includes(identity.item)?identity.item:null,index=rows.indexOf(item);if(!item)return;\\n if(kind==='preview-clip'&&identity.kind==='clip'){previewItem(item,'video',item.trimStart);return;}if(kind==='preview-audio'&&identity.kind==='audio'){previewItem(item,'audio');return;}if(kind==='preview-asset'&&identity.kind==='asset'){previewItem(item,item.kind);return;}if(blocked())return;\\n if(kind==='restore-version'&&identity.kind==='version'){commitEdit({...draft,clips:clone(item.clips||[]),audioItems:clone(item.audioItems||[]),captions:clone(item.captions||[]),textOverlays:clone(item.textOverlays||[]),effects:clone(item.effects||[])});draw();return;}\\n if(kind==='add-asset'&&identity.kind==='asset'){const media=clone(item),duration=Math.max(.001,Number(media.duration)||Number(media.durationSec)||4);if(media.kind==='audio')commitEdit({...draft,audioItems:[...draft.audioItems,{id:uniqueId('audio'),trackId:'audio',start:0,duration,trimStart:0,volume:1,asset:media,url:media.url}]});else{const start=draft.clips.reduce((end,value)=>Math.max(end,itemFinish(value)),0);commitEdit({...draft,clips:[...draft.clips,{id:uniqueId('clip'),trackId:'video',start,duration,trimStart:0,speed:1,volume:1,asset:media,url:media.url}]});}draw();return;}\\n if((kind==='move-clip-up'||kind==='move-clip-down')&&identity.kind==='clip'){const targetIndex=index+(kind==='move-clip-up'?-1:1),target=rows.at(targetIndex);if(targetIndex<0||!target)return;const reordered=rows.slice();reordered.splice(targetIndex,1,item);reordered.splice(index,1,target);replaceRows('clip',reordered);draw();return;}\\n if(kind==='duplicate-clip'&&identity.kind==='clip'){const next={...clone(item),id:uniqueId('clip-copy'),start:itemFinish(item)};replaceRows('clip',[...rows.slice(0,index+1),next,...rows.slice(index+1)]);draw();return;}\\n if(kind==='split-clip'&&identity.kind==='clip'){const half=Math.max(.001,Number(item.duration)||.001)/2;if(half<.001)return;const second={...clone(item),id:uniqueId('clip-split'),start:(Number(item.start)||0)+half,duration:half,trimStart:(Number(item.trimStart)||0)+half};replaceRows('clip',[...rows.slice(0,index),{...item,duration:half},second,...rows.slice(index+1)]);draw();return;}\\n if(kind==='remove-'+identity.kind&&['clip','audio','text','caption','effect'].includes(identity.kind)){const remaining=rows.slice();remaining.splice(index,1);replaceRows(identity.kind,remaining);draw();return;}\\n const next={...item};let recognized=true;\\n if(identity.kind==='clip'){if(kind==='clip-track')next.trackId=event.value;else if(kind==='clip-start')next.start=Math.max(0,Number(event.value)||0);else if(kind==='clip-duration')next.duration=Math.max(.001,Number(event.value)||.001);else if(kind==='clip-trim')next.trimStart=Math.max(0,Number(event.value)||0);else if(kind==='clip-speed')next.speed=Math.max(.01,Number(event.value)||1);else if(kind==='clip-volume')next.volume=Math.max(0,Number(event.value)||0);else if(kind==='clip-transition'||kind==='clip-transition-duration'){const prior=item.transition&&!Array.isArray(item.transition)?item.transition:{type:'Cut',duration:0};next.transition=kind==='clip-transition'?{...prior,type:event.value}:{...prior,duration:Math.max(0,Number(event.value)||0)};}else if(kind==='clip-opacity')next.transform={...(item.transform&&!Array.isArray(item.transform)?item.transform:{}),opacity:Math.max(0,Math.min(1,Number(event.value)||0))};else if(kind==='clip-reverse')next.reverse=event.checked;else if(kind==='clip-motion'||kind==='clip-easing'){const prior=item.motion&&!Array.isArray(item.motion)?item.motion:{type:'none',easing:'ease-in-out'};next.motion=kind==='clip-motion'?{...prior,type:event.value}:{...prior,easing:event.value};}else recognized=false;}\\n else if(identity.kind==='audio'){if(kind==='audio-track')next.trackId=event.value;else if(kind==='audio-start')next.start=Math.max(0,Number(event.value)||0);else if(kind==='audio-duration')next.duration=Math.max(.001,Number(event.value)||.001);else if(kind==='audio-trim'){next.trimStart=Math.max(0,Number(event.value)||0);next.sourceOffset=next.trimStart;}else if(kind==='audio-volume')next.volume=Math.max(0,Number(event.value)||0);else if(kind==='audio-fade-in')next.fadeIn=Math.max(0,Number(event.value)||0);else if(kind==='audio-fade-out')next.fadeOut=Math.max(0,Number(event.value)||0);else if(kind==='audio-ducking')next.ducking=Math.max(0,Math.min(1,Number(event.value)||0));else if(kind==='audio-rate')next.rate=Math.max(.05,Math.min(4,Number(event.value)||1));else if(kind==='audio-loop')next.loop=event.checked;else if(kind==='audio-muted')next.muted=event.checked;else recognized=false;}\\n else if(identity.kind==='text'){if(kind==='text-value')next.text=event.value;else if(kind==='text-track')next.trackId=event.value;else if(kind==='text-start')next.start=Math.max(0,Number(event.value)||0);else if(kind==='text-duration')next.duration=Math.max(.001,Number(event.value)||.001);else if(kind==='text-animation')next.animation=event.value;else recognized=false;}\\n else if(identity.kind==='caption'){if(kind==='caption-value')next.text=event.value;else if(kind==='caption-track')next.trackId=event.value;else if(kind==='caption-start')next.start=Math.max(0,Number(event.value)||0);else if(kind==='caption-end')next.end=Math.max((Number(item.start)||0)+.001,Number(event.value)||(Number(item.start)||0)+.001);else if(kind==='caption-animation')next.animation=event.value;else recognized=false;}\\n else if(identity.kind==='effect'){if(kind==='effect-type')next.type=event.value;else if(kind==='effect-track')next.trackId=event.value;else if(kind==='effect-start')next.start=Math.max(0,Number(event.value)||0);else if(kind==='effect-duration')next.duration=Math.max(.001,Number(event.value)||.001);else if(kind==='effect-intensity')next.intensity=Number(event.value)||0;else recognized=false;}\\n else recognized=false;if(recognized){const updated=rows.slice();updated.splice(index,1,next);replaceRows(identity.kind,updated);identities.set(handle,{kind:identity.kind,item:next});}\\n});\\nbuild.addEventListener('click',()=>{if(blocked())return;const assembled=assemble();const next=source.clips?.length||source.audioItems?.length?assembled:{...assembled,clips:assembled.clips.map(item=>({...item,id:uniqueId('clip')})),audioItems:assembled.audioItems.map(item=>({...item,id:uniqueId('audio')}))};commitEdit(next);draw();});\\ndocument.getElementById('addText').addEventListener('click',()=>{if(blocked())return;commitEdit({...draft,textOverlays:[...draft.textOverlays,{id:uniqueId('text'),trackId:'text',text:'New text',start:0,duration:2,animation:'none'}]});draw();});\\ndocument.getElementById('addCaption').addEventListener('click',()=>{if(blocked())return;commitEdit({...draft,captions:[...draft.captions,{id:uniqueId('caption'),trackId:'captions',text:'New caption',start:0,end:2,font:'Hanken Grotesk',animation:'none'}]});draw();});\\ndocument.getElementById('addEffect').addEventListener('click',()=>{if(blocked())return;commitEdit({...draft,effects:[...draft.effects,{id:uniqueId('effect'),trackId:'video',type:'fade',start:0,duration:1,intensity:1}]});draw();});\\nconst undoEdit=redo=>{if(blocked())return;captureHistory();const entry=redo?redoStack.at(-1):undoStack.at(-1);if(!entry)return;try{const next=StillMade.applyDocument(draft,redo?entry.forward:entry.inverse);if(redo){redoStack=redoStack.slice(0,-1);undoStack=[...undoStack,entry];}else{undoStack=undoStack.slice(0,-1);redoStack=[...redoStack,entry];}commitEdit(next,false);draw();status.textContent=redo?'Your checked change was restored.':'Your checked change was undone. Teammate edits are retained.';}catch(error){status.textContent='Cannot '+(redo?'redo':'undo')+' because the same content changed. The shared timeline is retained.';}};\\ndocument.getElementById('undo').addEventListener('click',()=>undoEdit(false));\\ndocument.getElementById('redo').addEventListener('click',()=>undoEdit(true));\\ndocument.getElementById('snapshot').addEventListener('click',()=>{if(blocked())return;const version={id:uniqueId('timeline-version'),label:'Timeline version '+String((draft.timelineVersions||[]).length+1),createdAt:new Date().toISOString(),clips:clone(draft.clips),audioItems:clone(draft.audioItems),captions:clone(draft.captions),textOverlays:clone(draft.textOverlays),effects:clone(draft.effects)};commitEdit({...draft,timelineVersions:[...(draft.timelineVersions||[]),version].slice(-50)});draw();});\\ndocument.getElementById('reset').addEventListener('click',()=>{if(blocked())return;commitEdit(normalize(clone(source)));draw();status.textContent='Reset to the current project timeline is being shared.';});\\nconst validateEditor=value=>{if(!value||Array.isArray(value)||value.schemaVersion!==1||typeof value.activeTimelineId!=='string'||!value.activeTimelineId)throw Error('Editor JSON must be a version 1 document with an active timeline ID.');[value.tracks,value.clips,value.audioItems,value.captions,value.textOverlays,value.stickers,value.effects,value.markers,value.fxEvents,value.liveOverlays,value.mediaItems,value.timelineVersions].forEach(rows=>{if(rows===undefined)return;if(!Array.isArray(rows)||rows.length>10000||rows.some(item=>!item||Array.isArray(item)||typeof item.id!=='string'||!item.id||item.id.length>200)||new Set(rows.map(item=>item.id)).size!==rows.length)throw Error('Each Editor collection needs at most 10,000 items with distinct, nonempty IDs of at most 200 characters.');});return normalize(value);};\\ndocument.getElementById('applyRaw').addEventListener('click',async()=>{if(blocked()||scratch.text===null)return;const requested=JSON.stringify(scratch);busy=true;draw();try{await scratchShared.flush();if(JSON.stringify(scratch)!==requested)throw Error('The shared JSON draft changed. Review the latest text before applying it.');if(!allowed())throw Error('Editing access changed. JSON text is retained.');const pending=scratch,value=validateEditor(JSON.parse(pending.text)),edits=StillMade.diffDocument(pending.base||draft,value);commitEdit(StillMade.applyDocument(draft,edits));await shared.flush();if(!allowed())throw Error('Editing access changed. JSON text is retained.');if(JSON.stringify(scratch)===requested){scratch={text:null,base:null};rawStale=false;scratchShared.changed();await scratchShared.flush();}status.textContent='Complete Editor data applied to the shared timeline.';}catch(error){status.textContent=error.message;}finally{busy=false;draw();}});\\nconst editOptions=next=>{if(blocked())return;options=next;optionsShared.changed();revision+=1;};\\ndocument.getElementById('renderFps').addEventListener('change',()=>editOptions({...options,renderFps:Number(document.getElementById('renderFps').value)}));\\ndocument.getElementById('renderResolution').addEventListener('change',()=>editOptions({...options,renderResolution:Number(document.getElementById('renderResolution').value)}));\\ndocument.getElementById('renderQuality').addEventListener('change',()=>editOptions({...options,renderQuality:document.getElementById('renderQuality').value}));\\nconst runAction=async(render)=>{if(blocked()||scratch.text!==null)return;busy=true;draw();status.textContent=render?'Preparing the exact final render…':'Checking the complete Editor timeline…';try{await shared.flush();await scratchShared.flush();await optionsShared.flush();if(!allowed()||scratch.text!==null)throw Error('Editing access or the shared draft changed. The action was not run.');const started=revision;await StillMade.run({editor:clone(source),updatedEditor:clone(draft),commit:!render,...render?{action:'render',...options}:{}});status.textContent=started!==revision?'A result is ready below; newer shared edits were retained.':render?'Final render is ready below. Choose Render final file to start the device renderer.':'Editor changes are ready below. Review the before and after, then choose Apply.';}catch(error){status.textContent=error.message||'The Editor action could not be prepared.';}finally{busy=false;draw();}};\\nsave.addEventListener('click',()=>runAction(false));\\ndocument.getElementById('renderFinal').addEventListener('click',()=>runAction(true));\\nconst recover=async(action)=>{if(busy||!shared||![access,scratchAccess,optionsAccess].every(value=>value.canEdit&&!value.pending))return;busy=true;draw();try{await action();sourceResetArmed=false;undoStack=[];redoStack=[];historyBefore=null;historyAfter=null;status.textContent='Shared Editor draft recovered.';}catch(error){status.textContent=error.message;}finally{busy=false;draw();}};\\ndocument.getElementById('retryShared').addEventListener('click',()=>recover(async()=>{await shared.retry();await scratchShared.retry();await optionsShared.retry();}));\\ndocument.getElementById('discardShared').addEventListener('click',()=>recover(async()=>{await shared.discard();await scratchShared.discard();await optionsShared.discard();}));\\ndocument.getElementById('resetSharedSource').addEventListener('click',()=>{sourceResetArmed=true;drawRecovery();});\\ndocument.getElementById('confirmSourceReset').addEventListener('click',()=>{if(!sourceResetArmed||!access.sourceConflict)return;sourceResetArmed=false;recover(()=>shared.resetSharedSource({discardSharedEdits:true}));});\\nStillMade.onShared(value=>{sourceResetArmed=false;drawRecovery();const outputs=value.outputs||{};document.getElementById('sharedResult').textContent=outputs.mediaAction?'A final-render plan is available in the shared result below.':outputs.editor?'The latest reviewed Editor result is available below.':'';});\\nStillMade.onInput(values=>{sourceResetArmed=false;source=clone(values.editor||empty);assets=Array.isArray(values.assets)?clone(values.assets):[];previewSerial+=1;if(previewUrl){StillMade.releaseMedia(previewUrl);previewUrl='';}imagePreview.hidden=true;videoPreview.hidden=true;audioPreview.hidden=true;const next=normalize(values.updatedEditor&&(values.updatedEditor.clips?.length||values.updatedEditor.audioItems?.length||values.updatedEditor.timelineVersions?.length)?clone(values.updatedEditor):source.clips?.length||source.audioItems?.length?clone(source):assemble());if(!shared){draft=next;shared=StillMade.connectDocument({key:'editorDocument',source:next,read:()=>draft,replace:value=>{sourceResetArmed=false;captureHistory();draft=value;revision+=1;if(scratch.text!==null)rawStale=true;draw();}});scratchShared=StillMade.connectDocument({key:'editorScratch',source:{text:null,base:null},read:()=>scratch,replace:value=>{scratch=value;rawStale=scratch.text!==null;if(scratch.text!==null&&rawIsOpen()&&raw.value!==scratch.text)raw.value=scratch.text;else schedulePreview();drawRecovery();}});optionsShared=StillMade.connectDocument({key:'editorOptions',source:{renderFps:30,renderResolution:1080,renderQuality:'high'},read:()=>options,replace:value=>{options=value;revision+=1;drawOptions();}});shared.onStatus(value=>{const redraw=access.canEdit!==value.canEdit||access.error!==value.error;access=value;if(redraw)draw();else drawRecovery();});scratchShared.onStatus(value=>{const redraw=scratchAccess.canEdit!==value.canEdit||scratchAccess.error!==value.error;scratchAccess=value;if(redraw)draw();else drawRecovery();});optionsShared.onStatus(value=>{const redraw=optionsAccess.canEdit!==value.canEdit||optionsAccess.error!==value.error;optionsAccess=value;if(redraw)draw();else drawRecovery();});playhead.value='0';}else shared.replaceSource(next);revision+=1;draw();status.textContent=access.error||'Timeline changes, JSON drafts and export settings are shared live. Playback and previews are personal.';});\\n\"\n}"},"lineage":{"parents":[],"changes":"Packaged original Block source for StillMade."}}}],"stages":[{"id":"make","blockId":"stillmade.release-visuals","version":"1.0.1","label":"Single Release Teaser","config":{"purpose":"release-teaser","aspect":"9:16","duration":20}},{"id":"finish","blockId":"sm.editor","version":"2.2.9","label":"Editor","config":{"commit":true,"renderFps":30,"renderResolution":1080,"renderQuality":"high"}}],"connections":[{"from":{"stage":"make","port":"timeline"},"to":{"stage":"finish","port":"updatedEditor"}}],"outcome":{"type":"export","dedupe":"material_project_state","minimumDurationSec":5}}