demoman 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES +1 -35
- package/dist/demoman.mjs +1443 -730
- package/dist/page/executor-entry.js +16 -3
- package/dist/page/mux-entry.js +161 -79
- package/dist/page/render-entry.js +573 -611
- package/dist/page/resolve-entry.js +16 -3
- package/dist/recipe.md +61 -50
- package/dist/studio/assets/confirm-dialog-Dd_hs1Bv.css +1 -0
- package/dist/studio/assets/confirm-dialog-DkCVzKzd.js +72 -0
- package/dist/studio/assets/controls-BoAnJbcP.js +1 -0
- package/dist/studio/assets/editor-APtBBZEt.js +4 -0
- package/dist/studio/assets/{editor-inline-3529c61f.css → editor-inline-7e387eed.css} +65 -1
- package/dist/studio/assets/library-C8XIahb7.js +1 -0
- package/dist/studio/assets/settings-Cs1_sqqR.js +1 -0
- package/dist/studio/assets/{settings-inline-081bd3f0.css → settings-inline-ff6d2eee.css} +2 -142
- package/dist/studio/assets/topbar-sSUyITjl.js +1 -0
- package/dist/studio/editor.html +5 -6
- package/dist/studio/library.html +4 -9
- package/dist/studio/settings.html +6 -11
- package/dist/studio/studio-build.json +3 -3
- package/package.json +1 -1
- package/dist/studio/assets/editor-BTGqbeOf.js +0 -4
- package/dist/studio/assets/library-BgPfg1Id.js +0 -1
- package/dist/studio/assets/settings-Bq1e7Iz8.js +0 -1
- package/dist/studio/assets/switch-Bn7Uwnf1.js +0 -1
- package/dist/studio/assets/theme-D59pt_a-.js +0 -72
- package/dist/studio/assets/theme-D6wPSXx4.css +0 -1
- package/dist/studio/assets/topbar-Dq9UrNEm.js +0 -1
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,F as n,G as r,H as i,J as a,K as o,N as s,P as c,Q as l,U as u,V as d,W as f,X as p,Y as m,Z as h,a as g,b as _,c as v,d as y,dt as b,et as x,f as ee,ft as te,h as ne,ht as re,i as ie,l as ae,lt as oe,mt as se,nt as ce,o as S,p as le,q as ue,r as de,rt as fe,st as pe,tt as me,u as he,ut as ge,v as _e,w as ve,x as ye,y as be,z as xe}from"./theme-D59pt_a-.js";import{S as Se,_ as Ce,a as we,b as Te,c as Ee,d as De,f as Oe,g as ke,h as Ae,i as C,l as je,m as Me,n as Ne,o as Pe,p as Fe,r as Ie,s as Le,t as Re,u as ze,v as Be,x as Ve}from"./switch-Bn7Uwnf1.js";import{c as He,f as Ue,p as We,s as Ge,u as Ke}from"./state-COWbBf84.js";function qe(e,t){let{bundle:n,scene:r}=f(t,e),i=new Map(r.anchors.map(e=>[e.id,e])),a=new Map((n.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),o=new Map;for(let e of r.anchors)e.fingerprint.boundingRect&&o.set(e.id,e.fingerprint.boundingRect);let s=new Map;for(let e of n.anchorRects??[])s.set(e.actionId,e.rect);let c=(e,t)=>s.get(t)??o.get(e)??null;return r.actions.flatMap(e=>{if(e.kind!==`moveTo`)return[];let t=e.id;if(e.signal!==`style`)return[{kind:`unknown`,actionId:t,reason:`notStyleSignalled`}];let r=a.get(t);if(r===void 0)return[{kind:`unknown`,actionId:t,reason:`noMarker`}];let o=e.anchorId===null?void 0:i.get(e.anchorId),s=e.anchorId===null?null:c(e.anchorId,t);if(s===null)return[{kind:`unknown`,actionId:t,reason:`noRect`}];if(o?.fingerprint.treePath?.startsWith(`#frame(`)===!0)return[{kind:`unknown`,actionId:t,reason:`crossFrameRect`}];if(s.width<=0||s.height<=0)return[{kind:`unknown`,actionId:t,reason:`degenerateRect`}];let{width:l,height:u}=n.viewport;return s.x<0||s.y<0||s.x+s.width>l||s.y+s.height>u?[{kind:`unknown`,actionId:t,reason:`offFrame`}]:s.width<8||s.height<8?[{kind:`unknown`,actionId:t,reason:`cropTooSmall`}]:[{kind:`probe`,actionId:t,rect:{x:s.x,y:s.y,width:s.width,height:s.height},preMs:r-400,postMs:r+100}]})}var Je=64;function Ye(e,t,n,r,i){let a=e.width/n.width,o=e.height/n.height,s=new OffscreenCanvas(r,i).getContext(`2d`);s.drawImage(e.image,t.x*a,t.y*o,t.width*a,t.height*o,0,0,r,i);let{data:c}=s.getImageData(0,0,r,i),l=new Float32Array(r*i);for(let e=0;e<l.length;e++){let t=c[e*4]??0,n=c[e*4+1]??0,r=c[e*4+2]??0;l[e]=(.2126*t+.7152*n+.0722*r)/255}return l}function Xe(e,t){let n=0;for(let r=0;r<e.length;r++)n+=Math.abs((e[r]??0)-(t[r]??0));return n/e.length}async function Ze(e,t,n,r){let i=[];for(let a of qe(e,t)){if(a.kind===`unknown`){i.push({actionId:a.actionId,kind:`unknown`,reason:a.reason});continue}let e,o;try{e=await n.at(a.preMs),o=await n.at(a.postMs)}catch{i.push({actionId:a.actionId,kind:`unknown`,reason:`decodeFailed`});continue}if(e.sourceTimeMs===o.sourceTimeMs){i.push({actionId:a.actionId,kind:`unknown`,reason:`sameFrame`});continue}if(Math.max(Math.abs(e.sourceTimeMs-a.preMs),Math.abs(o.sourceTimeMs-a.postMs))>250){i.push({actionId:a.actionId,kind:`unknown`,reason:`outOfTolerance`});continue}let s=e=>{let n=e.width/t.viewport.width,r=e.height/t.viewport.height;return a.rect.width*n<8||a.rect.height*r<8};if(s(e)||s(o)){i.push({actionId:a.actionId,kind:`unknown`,reason:`nativeCropTooSmall`});continue}let c=Math.max(1,Math.min(Je,Math.round(a.rect.width))),l=Math.max(1,Math.min(Je,Math.round(a.rect.height))),u;try{u=Xe(Ye(e,a.rect,t.viewport,c,l),Ye(o,a.rect,t.viewport,c,l))}catch{i.push({actionId:a.actionId,kind:`unknown`,reason:`decodeFailed`});continue}i.push({actionId:a.actionId,kind:u>r?`moved`:`still`})}return i}var Qe=e=>e instanceof Error?e.message:String(e);async function $e(e){let{frames:t,bundle:n,range:r,threshold:i}=e,a=n.keyframes[n.keyframes.length-1],o=Math.max(a?.sourceTimeMs??0,...n.motionSpans.map(e=>e.endMs),...n.markers.map(e=>e.sourceTimeMs));if(r.srcStartMs<0||r.srcEndMs>o)return{kind:`unknown`,reason:`this cut covers ${Math.round(r.srcStartMs)}–${Math.round(r.srcEndMs)}ms, which lies outside the frames (they end at ${Math.round(o)}ms), so the two sides could not be compared`};let s,c;try{s=await t.at(r.srcStartMs)}catch(e){return{kind:`unknown`,reason:`the frame before this cut (${Math.round(r.srcStartMs)}ms) could not be read: ${Qe(e)}`}}try{c=await t.at(r.srcEndMs)}catch(e){return{kind:`unknown`,reason:`the frame after this cut (${Math.round(r.srcEndMs)}ms) could not be read: ${Qe(e)}`}}if(s.sourceTimeMs===c.sourceTimeMs)return{kind:`unknown`,reason:`both sides of this cut are served by the same frame (${Math.round(s.sourceTimeMs)}ms) — the stretch it covers has no frames of its own — so nothing was compared`};let l=_(be(s.image),be(c.image));return l>i?{kind:`jump`,diff:l}:{kind:`clean`}}function et(t){return h.neutral.zoomHoldMs+e(t).zoomOutMs}et(ge.smoothness);var tt=Math.abs(h.leadInMs)+h.neutral.minPlateauMs+400;function nt(e){let t=`No zoom on click ${e.actionId}`,n=`gapMs`in e?`${Math.abs(e.gapMs)}ms ${e.gapMs<0?`before`:`after`} ${e.afterActionId}`:``;switch(e.reason){case`tooClose`:return`${t}: too close to the previous zoom (${n}, minimum ${tt}ms).`;case`sameTarget`:return`${t}: same target as the previous zoom, already zoomed in (${n}).`;case`targetTooWide`:return`${t}: target too wide to zoom (fits at ${e.scale}x, floor ${rt}x).`;case`textTooWide`:return`${t}: target too wide to zoom without cutting text (would be ${e.scale}x, floor ${rt}x).`}}h.fitMarginPx;var rt=1.2,it=`__demomanClickProbe`;`${it}${JSON.stringify(`__demomanClickSeen`)}`,`${it}`,`${it}`;function at(e){let t=e.edits.cuts??[];if(t.length===0)return e;let n=new Set(t.map(e=>e.actionId)),r=e=>!n.has(e);return te({...e,actions:e.actions.filter(e=>r(e.id)),camera:e.camera.flatMap(e=>{if(!r(e.marker.actionId))return[];if(e.end!==void 0&&!r(e.end.actionId)){let{end:t,...n}=e;return[n]}return[e]}),edits:{...e.edits,cuts:[],gaps:(e.edits.gaps??[]).filter(e=>r(e.afterActionId)),holds:(e.edits.holds??[]).filter(e=>r(e.marker.actionId)),masks:e.edits.masks.filter(e=>(e.start===void 0||r(e.start.actionId))&&(e.end===void 0||r(e.end.actionId))),trim:ot(e.edits.trim,r)}})}function ot(e,t){if(e===void 0)return e;let n=e.head&&t(e.head.actionId)?e.head:void 0,r=e.tail&&t(e.tail.actionId)?e.tail:void 0;if(n!==void 0||r!==void 0)return{...e,head:n,tail:r}}var st={mutating:`this flow writes data and rebuilding is switched off for it, so what you have is what this take itself recorded — turn on rebuilds for write flows, then rebuild it`,cancelledByAuthor:`you cancelled before it started, so this scene still has what the take itself recorded — re-shoot it in Runs to run it now`,unresolvedAnchor:`an element this demo depends on is no longer on the page — re-record that step, or remap its anchor`,ambiguousAnchor:`several elements matched this step, so replay stopped rather than risk clicking the wrong one — that target needs identifying more precisely`,anchorNotRendered:`an element had not been rendered yet — the page probably just needs scrolling further, and the take itself is likely fine`,pageSilent:`the page did not answer when replay asked it to find an element — the app may be down, offline, or showing a browser error page; check it loads, then run again`,pageFaulted:`the page itself threw an error when replay asked it to find an element, so nothing about the element was measured — the app is up; look at that page's own console for the fault, then run again`,anchorUnreachable:`replay found the element this step needs and then could not reach it to measure — nothing is wrong with the anchor, so re-recording that step will not help; run it again, and say so if it repeats`,anchorFrameMismatch:`replay found the element this step needs and the frame holding it is not the one recorded — the page's frames have changed since the take, so running it again will fail the same way; re-record that step`,redactedWithoutReplacement:`a typed value was withheld — a credential field, a secret-shaped value, or an editor whose text went unknown — and has no demo-safe replacement yet; select that step on the timeline and fill in Replace on-screen text, then run it again`,pageWentElsewhere:`the app moved to a different page partway through this script, and nothing in the script asked it to — either a step navigated, or the session expired and it went to a sign-in page; check the app is still signed in, and add a waitForLoad after any step that navigates, then run it again`,signedOut:`the app sent this browser to its sign-in page, so nothing was filmed — sign in again with demoman signin, then run it again`,unperformableStep:`this script asks for something the run cannot perform — a click with a button other than the left one — so it stopped rather than do something else and report success; change that step to a left click`,clickNotDelivered:`the browser put a click somewhere other than where it was sent, so the page never saw that click and the step did not happen — nothing is wrong with the steps; run it again, and say so if it repeats`,waitTimeout:`the page never reached a state the take was waiting for`,occlusionTimeout:`the render window stayed covered, so the frames would not have been usable`,windowClosed:`the replay window was closed before the run finished — nothing is wrong with the take, run it again`,debuggerUnavailable:`the debugger could not be attached to the replay tab — close DevTools on it and run again`,deviceFailed:`the browser refused to emulate the device, so nothing was filmed — the note says which command and why`,portFailure:`something underneath the run gave way — not a fault in the take, so re-recording will not fix it; run it once more, and if it stops the same way, report it`,noActions:`every step in this take is cut, so there is nothing to re-shoot — restore a step, then re-shoot it in Runs`};function ct(e){return e in st?st[e]:e}function lt(e){if(!e)return`(navigation)`;let t=e.fingerprint;return t.accessibleName??t.textContent??t.stableId??t.dataKey??e.id}function ut(e,t){if(t===null||t.reason===null||t.outcome===`complete`)return null;let n=e.actions[t.completed];return n?{number:t.completed+1,total:e.actions.length,kind:n.kind,label:lt(e.anchors.find(e=>e.id===n.anchorId))}:null}function dt(e,t){return ut(at(e),t)}function ft(e){return e.meta.capture.mode===`authored`}function pt(e){return e?`run its script again in Runs`:`re-shoot it in Runs`}function mt(e,t,n=pt){let r=`${n(t)} to film it`;return e?`these frames were made before the editor recorded what they typed, so a change to this text cannot be drawn over them — ${r}`:`this take has no frames yet, so there is nothing to draw a change to this text over — ${r}`}var ht=`no element was recorded for this step, so there is nowhere on screen to draw the new text`;function gt(e,t,n,r=pt){let i=e.actions.filter(e=>e.kind===`type`);if(t===null){let t=mt(n,ft(e),r);return{overlays:[],unshown:i.map(e=>({actionId:e.id,reason:t}))}}let a=new Map(t.map(e=>[e.actionId,e])),o={overlays:[],unshown:[]};for(let e of i){if(e.kind!==`type`)continue;let t=a.get(e.id);if(t!==void 0&&t.kind===`type`&&t.text!==e.text){if(e.anchorId===null||e.text===null){o.unshown.push({actionId:e.id,reason:ht});continue}o.overlays.push({actionId:e.id,anchorId:e.anchorId,text:e.text})}}return o}var _t=`retext:`,vt=`nothing was recorded where this field is on screen, so the new text has nowhere to be drawn`;function yt(e,t,n){let r=new Map(e.unshown.map(e=>[e.actionId,e.reason])),i=new Set(n);for(let e of t)e.kind!==`retext`||!e.id.startsWith(_t)||i.has(e.id)||r.set(e.id.slice(7),vt);return r}function bt(e){let{toolchain:t,name:n,...r}=e.meta,{canvas:i,...a}=e;return St(xt({...a,meta:r})).toString(16)}function xt(e){if(typeof e!=`object`||!e)return JSON.stringify(e)??`null`;if(Array.isArray(e))return`[${e.map(xt).join(`,`)}]`;let t=e;return`{${Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${xt(t[e])}`).join(`,`)}}`}function St(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}function Ct(e){return e.actions.map(e=>e.id).join(` `)}function wt(e){return{bundle:e.bundle,actionIds:Ct(e.scene)}}function Tt(e,t){return e!==null&&t.bundle===e.bundle&&Ct(t.scene)===e.actionIds&&t.hoverReport!==null}function Et(e,t){if(e.source!==`replay`||e.madeFrom===void 0)return!1;let n=new Set(e.madeFrom.filter(e=>e.cut).map(e=>e.actionId)),r=new Set(e.markers.map(e=>e.actionId));return t.length>0&&t.every(e=>n.has(e)&&!r.has(e))}function Dt(e,t){if(t&&(e.kind===`jump`||e.kind===`unknown`))return`${e.kind===`jump`?`The video jumps here: the frame before this cut and the frame after it are ${Math.round(e.diff*100)}% different.`:`Whether the video joins up here could not be tested — ${e.reason}.`} You kept the jump, so it exports as it looks now.`;switch(e.kind){case`pending`:return`Checking whether the video joins up across this cut.`;case`trailing`:return`This cut runs to the end of the take, so there is nothing after it to join — it is a clean trim.`;case`unplaced`:return`This cut removed no frames: ${e.reason}.`;case`leftOut`:return`The re-shoot left this step out, so the video continues without it — there is no join to check.`;case`clean`:return`The video joins up here — the frame before this cut and the frame after it match.`;case`jump`:return`The video jumps here: the frame before this cut and the frame after it are ${Math.round(e.diff*100)}% different. It exports as it looks now.`;case`unknown`:return`Whether the video joins up here could not be tested — ${e.reason}. It exports as it looks now; check the join by eye.`}}function Ot(e){let t=(e.edits.cuts??[]).map(e=>`${e.actionId}${e.keepJump?`!`:``}`).join(`,`);return`${Ct(e)}|${t}`}function kt(e,t,n){return e!==null&&e.bundle===t&&e.cuts===Ot(n)}function At(e,t,n){return e.some(e=>kt(e,t,n))}var jt=`motion reclaimed to free space`;function Mt(e,t){let n=t(e.outputTimeMs),r=n===null?`at ${(e.outputTimeMs/1e3).toFixed(1)}s`:`on the ${n} beat`,i=Math.round(e.neededWidth),a=e.sourceWidth<e.neededWidth,o=(e.neededWidth/e.sourceWidth).toFixed(2);if(e.grantedScale>=e.requestedScale)return`The picture ${r} is upscaled ${o}x — the source frames were only ${e.sourceWidth}px wide there against the ${i}px it is drawn at.`;let[s,c]=Pt(e.requestedScale,e.grantedScale),l=`The camera zoom ${r} was reduced from ${s}x to ${c}x — the source frames were only ${e.sourceWidth}px wide there and could not back it.`;return a?`${l} Even at ${c}x it is upscaled ${o}x against the ${i}px it is drawn at.`:l}function Nt(e,t=2){return String(Number(e.toFixed(t)))}function Pt(e,t){for(let n=2;n<4;n++)if(Nt(e,n)!==Nt(t,n))return[Nt(e,n),Nt(t,n)];return[Nt(e,4),Nt(t,4)]}function Ft(e,t){let n=e.some(e=>e.grantedScale<e.requestedScale),r=e.some(e=>e.sourceWidth<e.neededWidth),i=n&&r?`This export asked for more detail than the recording holds`:n?`Camera zoom was reduced on this export`:`This export is drawn from fewer pixels than it has`,a=new Map;for(let n of e){let e=t(n.outputTimeMs),r=n.grantedScale<n.requestedScale?`cut`:`short`,i=`${e??Math.floor(n.outputTimeMs/1e3)}|${r}`,o=a.get(i),s=n.sourceWidth/n.neededWidth;(!o||s<o.sourceWidth/o.neededWidth)&&a.set(i,n)}return{heading:i,lines:[...a.values()].map(e=>Mt(e,t))}}function It(e){let t=e.flatMap(e=>e.outputMs===null?[]:[{outputMs:e.outputMs,label:e.label}]).sort((e,t)=>e.outputMs-t.outputMs);return e=>{let n=null;for(let r of t)if(r.outputMs<=e)n=r.label;else break;return n}}function Lt(e){return e?`Run its script again in Runs`:`Re-shoot this take in Runs`}function Rt(e){let t=pt(e);return t.charAt(0).toUpperCase()+t.slice(1)}function zt(e){return e.rerun.kind===`line`?e.rerun.text:null}function Bt(e,t,n){return t??`${Rt(e)} ${n}.`}var Vt=1e3;function Ht(e,t){return`Motion reclaimed to free space. ${Bt(e,t,`to restore`)}`}var Ut=new Set([`Motion reclaimed to free space. Replay to restore.`,`Motion reclaimed to free space. Rebuild to restore.`]);function Wt(e,t,n,r){return e===`motionReclaimed`?Ut.has(t)||t===`Motion reclaimed to free space. Re-shoot it in Runs to restore.`?Ht(n,r):t:`${e}: ${t}`}var Gt=(e,t)=>e.hasBundle?t.outputMs??t.captureMs:t.captureMs;function Kt(e){return e.hasBundle&&e.outputDurationMs!==null?e.outputDurationMs:(e.beats[e.beats.length-1]?.captureMs??0)+Vt}function qt(e,t){let n=e.beats.find(e=>e.actionId===t.actionId);return(n?Gt(e,n):0)+t.offsetMs}function Jt(e){let{scene:t,view:n,bundle:r,resolved:i}=e,a=ft(t),o=e.rerunLine??null,s=e=>Bt(a,o,e),c=Kt(n),l=[],u=new Set(e.hoverReport?.removable??[]),d=new Map(n.beats.map(e=>[e.actionId,Gt(n,e)])),f=new Map(n.beats.map(e=>[e.actionId,e.timing])),p=e=>i===null?`estimated`:e?f.get(e.actionId)??`estimated`:`rendered`,m=n.beats.map(e=>({actionId:e.actionId,atMs:d.get(e.actionId)??0,verb:e.verb,label:e.label,timing:e.timing,flag:u.has(e.actionId)?`unchangedHover`:null,canZoom:e.canZoom,cut:e.cut!==null})),h=t.edits.trim,g=i?{headMs:i.range.startMs,headTiming:i.trimUnplaced.includes(`head`)?`estimated`:`rendered`,tailMs:i.range.endMs,tailTiming:i.trimUnplaced.includes(`tail`)?`estimated`:`rendered`,headMarker:h?.head??null,tailMarker:h?.tail??null}:{headMs:h?.head?Math.max(0,qt(n,h.head)):0,headTiming:h?.head?`estimated`:`rendered`,tailMs:h?.tail?Math.min(c,qt(n,h.tail)):c,tailTiming:h?.tail?`estimated`:`rendered`,headMarker:h?.head??null,tailMarker:h?.tail??null};for(let e of i?.trimUnplaced??[])l.push(`The trim's ${e} is placed from the take's own timestamp: the last render carried no marker for its step. ${s(`to give it measured timing`)}`);for(let e of i?.timeline.unplacedCuts??[]){let t=e.actionIds.join(`, `);l.push(r!==null&&Et(r,e.actionIds)?`The re-shoot left out ${t}, so the video continues without ${e.actionIds.length===1?`it`:`them`}.`:`A cut on ${t} removed no frames: ${e.reason}.`)}let _=new Set((i?.clampedRanges??[]).filter(e=>e.kind===`zoom`).map(e=>e.id));for(let e of i?.clampedRanges??[])l.push(e.note);let v=new Map((i?.cameraSegments??[]).map(e=>[e.id,e])),y=et((t.motion??ge).smoothness),b=new Set,x=t.camera.flatMap(e=>{let t=e.scale??1;if(t<=1)return[];let r=v.get(e.id);r||b.add(e.id);let i=r?r.startMs:Math.max(0,qt(n,e.marker)),a=r?r.endMs:Math.min(c,e.end?qt(n,e.end):i+y),o=e.point?{kind:`point`,x:e.point.x,y:e.point.y}:{kind:`element`,anchorId:e.anchorId??``};return r?.endUnplaced&&l.push(`The end of zoom "${e.id}" is placed from the take's own timestamp: the last render carried no marker for its step. ${s(`to give it measured timing`)}`),[{id:e.id,actionId:e.marker.actionId,startMs:i,endMs:a,endAuthored:e.end!==void 0,scale:t,target:o,aimFallback:e.note??null,timing:r?r.endUnplaced?`estimated`:p(e.marker):`estimated`,clamped:_.has(e.id),marker:e.marker,endMarker:e.end??null}]}),ee=x.map(e=>{if(!b.has(e.id))return e;let t=Math.min(...x.map(e=>e.startMs).filter(t=>t>e.startMs));return e.endMs>t?{...e,endMs:t}:e}),te=new Set(t.camera.map(e=>e.marker.actionId));for(let e of t.zoomsSkipped??[])te.has(e.actionId)||`afterActionId`in e&&!te.has(e.afterActionId)||l.push(nt(e));let ne=new Map((i?.cosmetics??[]).map(e=>[e.id,e])),re=t.edits.masks.map(e=>{let t=e.start===void 0||e.end===void 0,r=ne.get(e.id),a=r?.range??null;for(let t of r?.unplaced??[])l.push(`The ${t} of mask "${e.id}" is placed from the take's own timestamp: the last render carried no marker for its step, so the mask covers more of the video than it was drawn to. ${s(`to give it measured timing`)}`);let o=t?0:a?a.startMs:e.start?Math.max(0,qt(n,e.start)):0,u=t?c:a?a.endMs:e.end?Math.min(c,qt(n,e.end)):c;return{id:e.id,startMs:o,endMs:u,rect:e.rect,wholeTake:t,timing:t||i&&a&&p(e.start)===`rendered`&&p(e.end)===`rendered`?`rendered`:`estimated`,startMarker:e.start??null,endMarker:e.end??null}}),ie=e=>i?ce(i.timeline,e):e,ae=(r?.degradations??[]).map(e=>({startMs:ie(e.startMs),endMs:ie(e.endMs)}));for(let e of r?.degradations??[])l.push(Wt(e.kind,e.note,a,o));let oe=i?.timeline.unplacedPaces??0;if(oe>0){let e=oe===1?`pause`:`pauses`;l.push(`pacingUnplaced: ${oe} recorded ${e} could not be placed. The last render carried no marker for the steps they sit between, so this video is shorter than the take by however long those ${e} were. ${s(`to restore them`)}`)}let se=i?.timeline.nonMonotonicPaces??0;if(se>0){let e=se===1?`pair`:`pairs`;l.push(`pacingBackwards: ${se} step ${e} in this take carry timestamps that run backwards, so the take's order is not its time order. A re-shoot counts the pause across ${se===1?`it`:`them`} twice and comes out longer than the take. Re-record to straighten the order; the frames you already have are unaffected.`)}return{clip:{durationMs:c,trim:g,ticks:m,degraded:ae},zooms:ee,masks:re,durationMs:c,timeSource:n.hasBundle?`rendered`:`captured`,authored:a,rerunLine:o,hoverCheck:{failed:e.hoverReport?.failed??!1,unchecked:e.hoverReport?.unchecked??0},notices:l,zoomDefaultMs:y}}function w(e,t,n){let r=e.clip.ticks,i=r[0];if(!i)throw Error(`a take with no steps has nothing to attach an edit to`);let a=i;for(let e of r){let n=Math.abs(e.atMs-t),r=Math.abs(a.atMs-t);(n<r||n===r&&e.atMs<a.atMs)&&(a=e)}let o=Math.round(t-a.atMs);return{actionId:a.actionId,offsetMs:Math.abs(o)<=n?0:o}}function Yt(e){let{resolved:t,outputTimeMs:r,presentation:i,target:a,viewport:o}=e;return l(x(t.cameraKeys,r),n(i.frameRect,o),i.frameRect,o,a)}var Xt=(e,t,n)=>Math.min(n,Math.max(t,e));function Zt(e,t){let n=e.width/2,r=e.height/2;return{x:Xt(t.x-n/2,0,e.width-n),y:Xt(t.y-r/2,0,e.height-r),width:n,height:r}}function Qt(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,c=Yt({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o});return s(t,c,i.frameRect,o)}function $t(e){let{rect:n,resolved:r,target:i,presentation:a,outputTimeMs:o}=e,s=r.plan.viewport,c=Yt({resolved:r,outputTimeMs:o,presentation:a,target:i,viewport:s}),l=t(n,c,a.frameRect,s),u=Xt(l.x,0,s.width),d=Xt(l.y,0,s.height),f=Xt(l.x+l.width,0,s.width),p=Xt(l.y+l.height,0,s.height);return{x:u,y:d,width:f-u,height:p-d}}function en(e){let{zoom:n,resolved:r,viewport:i,presentation:a,target:o}=e,s=Yt({resolved:r,outputTimeMs:(n.startMs+n.endMs)/2,presentation:a,target:o,viewport:i});return t({x:0,y:0,width:o.width,height:o.height},s,a.frameRect,i)}var tn=2e3,nn=e=>e!==null&&e.kind===`refusal`,T=e=>({kind:`refusal`,reason:e});function rn(e,t){if(e.resolved===null||e.bundle===null)return{reason:`nothing has rendered yet`};if(e.bundle.cursorSamples.length===0)return{reason:`this take has no recorded pointer`};let n=fe(e.resolved.timeline,t);if(e.bundle.cursorGaps.some(e=>n>=e.startMs&&n<e.endMs))return{reason:`the pointer was off the page here`};let r=u(e.resolved.cursor,n);return r?{point:r}:{reason:`the pointer was not observed here`}}var an=(e,t)=>e.zooms.find(e=>e.id===t),on=(e,t)=>e.masks.find(e=>e.id===t);function sn(e,t,n,r){let i=e.zooms.find(e=>e.id===t);for(let a of e.zooms){if(a.id===t)continue;let e=cn(a,i,n,r);if(e)return{zoom:a,why:e}}}function cn(e,t,n,r){let i=Math.abs(n-e.startMs);if(i<tt&&(t===void 0||i<Math.abs(t.startMs-e.startMs)||n<e.startMs!=t.startMs<e.startMs))return`start`;if(r!==null&&e.startMs>n&&r>e.startMs&&(t===void 0||!t.endAuthored||r>t.endMs))return`endsAfter`;if(e.endAuthored&&e.startMs<n&&e.endMs>n&&(t===void 0||n<t.startMs))return`startsInside`}function ln({zoom:e,why:t}){switch(t){case`start`:return T(`That would start it within ${tt}ms of the zoom "${e.id}" at ${un(e.startMs)}; the camera needs ${tt}ms between two zooms to glide from one to the other.`);case`endsAfter`:return T(`That would end it after the zoom "${e.id}" starts at ${un(e.startMs)}; a zoom can stay in until the next one, not past it.`);case`startsInside`:return T(`That would start it before the zoom "${e.id}" ends at ${un(e.endMs)}; drag that zoom's end earlier first.`)}}var un=e=>{let t=Math.max(0,Math.floor(e/100)),n=Math.floor(t/10);return`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}.${t%10}`};function dn(e){let{leadInMs:t}=h;return{earliestMs:e+t,latestMs:e}}function fn(e,t){let{leadInMs:n}=h,r=e.zoomDefaultMs-n,i=(t,n)=>{let r=Math.min(...e.zooms.map(e=>e.startMs).filter(e=>e>t));return{kind:`placed`,atMs:t,startMs:t,endMs:Math.min(t+e.zoomDefaultMs,r),movedPast:n}},a=t=>{let{earliestMs:n,latestMs:r}=dn(t);return e.zooms.find(e=>cn(e,void 0,n,null)!==void 0||cn(e,void 0,r,null)!==void 0)},o=a(t);if(!o)return i(t,null);let s=o;for(let t=0;t<=e.zooms.length&&s;t++){let t=Math.max(s.startMs+tt,s.endAuthored?s.endMs:-1/0)-n;if(t+r+n>e.durationMs)break;let o=a(t);if(!o)return i(t,{zoom:s,side:`after`});s=o}s=o;for(let t=0;t<=e.zooms.length&&s;t++){let e=s.startMs-tt;if(dn(e).earliestMs<0)break;let t=a(e);if(!t)return i(e,{zoom:s,side:`before`});s=t}return T(`There is no room for a zoom here: it would run into the zoom "${o.id}" at ${un(o.startMs)}, and there is no slot either side of it. Drag that zoom to make space, or remove one.`)}function pn(e,t){let{trim:n}=e.clip;if(t>n.tailMs-200)return T(`Move the playhead earlier: a mask needs some of the video after it to cover.`);let r=e.clip.ticks.find(e=>e.atMs>t+1)?.atMs??1/0;return{kind:`span`,startMs:t,endMs:Math.min(r,t+tn,e.durationMs)}}function mn(e,t){return t!==null&&e.actionId===t.actionId&&t.offsetMs<=e.offsetMs}var hn=e=>T(`That would leave the ${e} no length; drag its end further.`),gn=e=>T(`The cut would leave nothing: that puts the ${e} on the same step as the ${e===`head`?`tail`:`head`}. Drag it further away, or move the other end first.`);function _n(e,t){let n=e.clip.ticks,r=n.findIndex(e=>e.actionId===t);return r===-1?void 0:n[r+1]}function vn(e,t,n,r){let{durationMs:i}=e;if(e.clip.ticks.length===0)return T(`This take has no steps to attach an edit to.`);switch(n.kind){case`trim`:{let{trim:t}=e.clip;if(n.edge===`head`){if(n.toMs<=0)return{kind:`setTrim`,head:null};if(n.toMs>t.tailMs-200)return T(`The cut would leave nothing: the head has to stay at least 200ms before the tail.`);let r=w(e,n.toMs,n.snapMs);return mn(r,t.tailMarker)?gn(`head`):{kind:`setTrim`,head:r}}if(n.toMs>=i)return{kind:`setTrim`,tail:null};if(n.toMs<t.headMs+200)return T(`The cut would leave nothing: the tail has to stay at least 200ms after the head.`);let r=w(e,n.toMs,n.snapMs);return t.headMarker&&mn(t.headMarker,r)?gn(`tail`):{kind:`setTrim`,tail:r}}case`addZoom`:{let i=fn(e,n.atMs);if(nn(i))return i;let{atMs:a,movedPast:o}=i,s=w(e,a,o?0:n.snapMs),c=o?`Placed ${o.side} the zoom at ${un(o.zoom.startMs)}: there was no room at ${un(n.atMs)}.`:null,l=h.defaultZoomScale,u=rn(r,a);if(`point`in u)return{kind:`addZoom`,marker:s,target:{kind:`point`,x:u.point.x,y:u.point.y},scale:l,...c===null?{}:{note:c}};let d=[...e.clip.ticks].filter(e=>e.canZoom).sort((e,t)=>Math.abs(e.atMs-a)-Math.abs(t.atMs-a))[0],f=d?t.beats.find(e=>e.actionId===d.actionId)?.anchorId:null;if(!d||!f)return T(`There is nothing to aim at here: ${u.reason}, and no step on this take has an element on screen.`);let p={kind:`element`,anchorId:f},m=`Aimed at "${d.label}" instead of the cursor: ${u.reason}.`;return{kind:`addZoom`,marker:s,target:p,scale:l,note:c?`${c} ${m}`:m}}case`moveZoom`:{let t=an(e,n.id);if(!t)return T(`There is no zoom "${n.id}" to move.`);if(n.deltaMs===0)return null;let r=t.startMs+n.deltaMs,a=t.endMs+n.deltaMs;if(r<0)return T(`A zoom cannot start before the take does.`);if(a>i)return T(`A zoom cannot end after the take does.`);let o=sn(e,t.id,r,t.endAuthored?a:null);if(o)return ln(o);let s=w(e,r,n.snapMs),c=t.endAuthored?w(e,a,n.snapMs):null;return mn(s,c)?hn(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}case`zoomEdge`:{let t=an(e,n.id);if(!t)return T(`There is no zoom "${n.id}" to resize.`);if(n.edge===`start`){if(n.toMs<0)return T(`A zoom cannot start before the take does.`);if(n.toMs>t.endMs-100)return T(`A zoom's start cannot cross its end; it would start after the zoom already ends. Drag the end later first.`);let r=sn(e,t.id,n.toMs,null);if(r)return ln(r);let i=w(e,n.toMs,n.snapMs),a=t.endMarker;return mn(i,a)?hn(`zoom`):{kind:`setZoomRange`,id:t.id,start:i,end:a}}if(n.toMs>i)return T(`A zoom cannot end after the take does.`);if(n.toMs<t.startMs+100)return T(`A zoom's end cannot cross its start; it would end before it starts. Drag the start earlier first.`);let r=sn(e,t.id,t.startMs,n.toMs);if(r)return ln(r);let a=t.marker,o=w(e,n.toMs,n.snapMs);return mn(a,o)?hn(`zoom`):{kind:`setZoomRange`,id:t.id,start:a,end:o}}case`addMask`:{let t=pn(e,n.atMs);if(nn(t))return t;let{endMs:i}=t,a=rn(r,n.atMs),o=`point`in a?a.point:{x:r.viewport.width/2,y:r.viewport.height/2},s=Zt(r.viewport,o),c=w(e,n.atMs,n.snapMs),l=w(e,i,n.snapMs);if(mn(c,l)){let t=_n(e,c.actionId);if(!t)return T(`That would leave the mask no length; move the playhead earlier.`);l={actionId:t.actionId,offsetMs:0}}return`point`in a?{kind:`addMask`,rect:s,start:c,end:l}:{kind:`addMask`,rect:s,start:c,end:l,note:`Placed at the centre of the frame: ${a.reason}. Drag it into place on the preview.`}}case`moveMask`:{let t=on(e,n.id);if(!t)return T(`There is no mask "${n.id}" to move.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return T(`This mask covers the whole take, so it has no ends to move. Add a new mask to cover a stretch.`);if(n.deltaMs===0)return null;let r=t.startMs+n.deltaMs,a=t.endMs+n.deltaMs;if(r<0)return T(`A mask cannot start before the take does.`);if(a>i)return T(`A mask cannot end after the take does.`);let o=w(e,r,n.snapMs),s=w(e,a,n.snapMs);return mn(o,s)?hn(`mask`):{kind:`setMaskRange`,id:t.id,start:o,end:s}}case`maskEdge`:{let t=on(e,n.id);if(!t)return T(`There is no mask "${n.id}" to resize.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return T(`This mask covers the whole take, so it has no ends to move. Add a new mask to cover a stretch.`);if(n.edge===`start`){if(n.toMs<0)return T(`A mask cannot start before the take does.`);if(n.toMs>t.endMs-100)return T(`A mask cannot start after it ends; drag its end later first.`);let r=w(e,n.toMs,n.snapMs),i=t.endMarker;return mn(r,i)?hn(`mask`):{kind:`setMaskRange`,id:t.id,start:r,end:i}}if(n.toMs>i)return T(`A mask cannot end after the take does.`);if(n.toMs<t.startMs+100)return T(`A mask cannot end before it starts; drag its start earlier first.`);let r=t.startMarker,a=w(e,n.toMs,n.snapMs);return mn(r,a)?hn(`mask`):{kind:`setMaskRange`,id:t.id,start:r,end:a}}}}function yn(e,t,n){let r=e.beats.find(e=>e.actionId===t);return r===void 0?T(`There is no step "${t}" to pace.`):r.isLast?T(`"${t}" is the last step, and a pause is the time between two steps. Trim or add a step after it instead.`):Number.isFinite(n)?n<0?T(`A pause cannot be shorter than nothing. Type 0 to cut the dead air here, or use the recorded pause.`):{kind:`setGap`,afterActionId:t,durationMs:n}:T(`A pause has to be a number of milliseconds.`)}function bn(e,t,n){let r=0;for(let i of e.segments){if(i.kind!==`motion`)continue;let e=Math.min(i.outEndMs,n)-Math.max(i.outStartMs,t);e>0&&(r+=e)}return r}function xn(e,t,n){return e.actions.some(e=>e.id===n)?(e.edits.cuts??[]).some(e=>e.actionId===n)?null:t?.markers.some(e=>e.actionId===n)??!1?{kind:`cutStep`,actionId:n}:{kind:`deleteAction`,actionId:n}:T(`There is no step "${n}" to remove.`)}function Sn(e,t,n){let r=e.beats.findIndex(e=>e.actionId===t);if(r===-1)return T(`There is no step "${t}" to remove.`);if(e.beats[r]?.cut!=null)return T(`"${t}" is cut, so it takes no time in the video and there is no pace to keep across it. Restore the step first, or delete it on its own.`);if(r===0)return T(`"${t}" is the first step, so there is no step before it to hold its time. Delete it on its own, or drag the take's head instead.`);if(r===e.beats.length-1)return T(`"${t}" is the last step, and the step before it would become the last — a pause is the time between two steps, so it could not hold one. Delete it on its own, or drag the take's tail instead.`);let i=e.beats[r-1],a=e.beats[r+1];if(i?.outputMs===null||i?.outputMs===void 0||a?.outputMs===null||a?.outputMs===void 0)return T(`This take has not been rendered yet, so there is no measured time to keep. Render it, or delete the step on its own.`);let o=a.outputMs-i.outputMs,s=bn(n.timeline,i.outputMs,a.outputMs);return{kind:`deleteActionKeepingPace`,actionId:t,durationMs:Math.max(0,o-s)}}var Cn={removable:[],checked:0,unchecked:0,failed:!0};function wn(e){return e.kind!==`unknown`||e.reason!==`notStyleSignalled`}function Tn(e,t){let n=e.filter(wn).filter(e=>!t.has(e.actionId)),r={};for(let e of n)e.kind===`unknown`&&(r[e.reason]=(r[e.reason]??0)+1);return{removable:n.flatMap(e=>e.kind===`still`?[e.actionId]:[]),checked:n.filter(e=>e.kind!==`unknown`).length,unchecked:n.filter(e=>e.kind===`unknown`).length,uncheckedBy:r,failed:!1}}var En={notStyleSignalled:{one:`was not a style hover`,many:`were not style hovers`},noMarker:{one:`had no place on the timeline`,many:`had no place on the timeline`},noRect:{one:`had no recorded position`,many:`had no recorded position`},crossFrameRect:{one:`was inside an embedded frame`,many:`were inside an embedded frame`},degenerateRect:{one:`had a zero-size target`,many:`had a zero-size target`},offFrame:{one:`was partly off screen`,many:`were partly off screen`},cropTooSmall:{one:`was too small to compare`,many:`were too small to compare`},nativeCropTooSmall:{one:`was too small in the recorded frames to compare`,many:`were too small in the recorded frames to compare`},sameFrame:{one:`had only one frame around it`,many:`had only one frame around them`},outOfTolerance:{one:`had no frame close enough to the hover`,many:`had no frame close enough to the hover`},decodeFailed:{one:`had a frame that would not decode`,many:`had frames that would not decode`}};function Dn(e){return Object.entries(e.uncheckedBy??{}).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]).map(([e,t])=>{let n=En[e];return`${t} ${t===1?n.one:n.many}`}).join(`, `)}function On(e){if(e.failed)return`The hover check could not run, so nothing here has been checked.`;let t=e.removable.length>0?`${e.removable.length} hover ${e.removable.length===1?`move`:`moves`} changed nothing on screen.`:null,n=Dn(e),r=e.checked+e.unchecked,i=e.unchecked>0?`${e.unchecked} of ${r} ${r===1?`hover`:`hovers`} could not be checked${n===``?``:`: ${n}`}.`:null;return t===null&&i===null?null:[t,i].filter(e=>e!==null).join(` `)}function kn(e){if(e.length<4)return null;let t=e.slice(-30).sort((e,t)=>e-t);return t[Math.min(t.length-1,Math.max(0,Math.ceil(.8*t.length)-1))]??null}function An(e){let{target:t,paintedCssWidth:n,devicePixelRatio:r,playing:i}=e,a=Math.min(t.height,720);if(!Number.isFinite(n)||n<=0)return a;let o=n*r,s=Math.round(o*t.height/t.width),c=Math.max(a,Math.min(t.height,s));if(!i)return c;let l=e.msPerMegapixel;if(l==null||!Number.isFinite(l)||l<0)return a;let u=t.width/t.height,d=Math.sqrt((e.budgetMs??11)/l*1e6/u);if(d>=c)return c;let f=Math.floor(d/90)*90;return Math.min(c,Math.max(a,f))}function jn(e,t=720){let n=t/e.height;return{...e,format:`png`,fps:0,bitrate:0,width:Math.round(e.width*n),height:t,cornerRadius:Math.max(4,Math.round(e.cornerRadius*n))}}function Mn(e){let{bitmap:t,parkedHeight:n}=e;if(!t)return``;let r=e.msPerMegapixel==null?`cost not measured yet`:`${e.msPerMegapixel.toFixed(1)}ms/megapixel`,i=n!=null&&t.height>=n,a=n==null?``:i?` (full resolution)`:`, parked ${n}`;return` | played ${t.width}x${t.height}${a}, ${r}`}function Nn(e){let{requestedFrames:t,drawnFrames:n,elapsedMs:r,sourceLookupMs:i,composeMs:a,blitMs:o}=e;if(n<=0)return`[demoman] preview: no frames drawn in ${Math.round(r)}ms, ${t} asked for`;let s=r/1e3,c=e=>s>0?`${(e/s).toFixed(1)}`:`n/a`,l=e=>(e/n).toFixed(1),u=(100*n/Math.max(1,t)).toFixed(0),d=e.sourceFrame?`, stills ${e.sourceFrame.width}x${e.sourceFrame.height}`:``,f=Mn(e),p=e.decodeMs===void 0?``:` (decode ${l(e.decodeMs)}ms)`,m=i/n>=.05?`, source ${l(i)}ms`:``;return`[demoman] preview: ${c(n)} fps drawn, ${c(t)} asked (${u}% kept) — per drawn frame: compose ${l(a)}ms${p}, blit ${l(o)}ms${m}${d}${f}`}function Pn(e){let{draw:t,schedule:n,onDrawFailed:r,onDrawRecovered:i}=e,a=null,o=!1,s=!1,c=Promise.resolve(),l=()=>{if(s||o||a===null)return;let e=a;a=null,o=!0,c=t(e).then(()=>{i?.()}).catch(e=>{r?.(e)}).then(()=>{o=!1,a!==null&&n(l)})};return{seek(e){s||(a=e,n(l))},async idle(){for(;o||a!==null;)await c},dispose(){s=!0,a=null}}}function Fn(e){let{seek:t,durationMs:n,now:r,schedule:i,onChange:a}=e,o=e.startMs??(()=>0),s=e.looping??(()=>!1),c=0,l=!1,u=!1,d=0,f=0,p=1,m=()=>a?.(),h=e=>{c=e,t(e)},g=e=>{c=e,y(),h(e),m(),i(v)},_=e=>s()&&e>o(),v=()=>{if(u||!l)return;let e=n(),t=d+(r()-f)*p;if(t>=e){if(_(e)){g(o());return}l=!1,p=1,h(e),m();return}if(p<0&&t<=o()){if(_(e)){g(e);return}l=!1,p=1,h(o()),m();return}h(t),m(),i(v)},y=()=>{d=c,f=r()};return{play(){if(u||l)return;let e=n();e<=0||((c>=e||c<o())&&(c=o()),p=1,y(),l=!0,h(c),m(),i(v))},pause(){u||!l||(l=!1,p=1,m())},shuttle(e){if(u)return;let t=n();t<=0||(p=l&&Math.sign(p)===e?e*Math.min(4,Math.abs(p)*2):e,e>0&&c>=t&&(c=o()),e<0&&c<=o()&&(c=t),y(),l=!0,h(c),m(),i(v))},stop(){u||(p=1,l&&(l=!1,m()))},toggle(){l?this.pause():this.play()},seek(e){if(u)return;let t=Math.min(Math.max(e,o()),n());c=t,y(),h(t),m()},get playing(){return l},get rate(){return p},get positionMs(){return c},dispose(){u=!0,l=!1}}}function E(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60;return`${Math.floor(t/60)}:${String(n).padStart(2,`0`)}`}function In(e){let t=null,n=null;return r=>((t===null||r!==n)&&(n=r,t=e(r).catch(e=>{throw t=null,n=null,e})),t)}function Ln(e,t){let{cursor:n,branding:r,motion:i}=t;return n===e.cursor&&r===e.branding&&i===e.motion?e:{...e,cursor:n,branding:r,...i===void 0?{}:{motion:i}}}function Rn(e,t){return e===null||[...new Set([...Object.keys(t),...Object.keys(e)])].some(n=>t[n]!==e[n])}function zn(e,t){return e===null||e.smoothness!==t.smoothness||e.blur!==t.blur||e.follow!==t.follow}function Bn(e,t){if(e===null)return!0;let n=(e,t)=>e===t||e!==void 0&&t!==void 0&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,r=e.background,i=t.background;return!(r.kind===i.kind&&(r.kind===`solid`?r.color===i.color:r.from===i.from&&r.to===i.to&&r.angle===i.angle))||e.cornerRadius!==t.cornerRadius||!n(e.frameRect,t.frameRect)||e.logo?.image!==t.logo?.image||e.logo?.opacity!==t.logo?.opacity||!n(e.logo?.rect,t.logo?.rect)}function Vn(e,t){let n=e.anchors.find(e=>e.id===t);return n===void 0?null:n.fingerprint.textContent??n.fingerprint.accessibleName??null}function Hn(e,t){let{anchorId:n}=t;return n===null||!e.anchors.some(e=>e.id===n)?!1:Vn(e,n)!==null||t.verb===`type`}function Un(e,t,n){let r=e.edits.replacements.filter(e=>e.targetAnchorId!==null);if(r.length===0)return[];let i=new Set((e.edits.cuts??[]).map(e=>e.actionId)),a=t=>{if(!i.has(t.actionId))return t;let n=m(e,t.actionId,i);return n===null?null:{actionId:n,offsetMs:0}},o=e.actions.find(e=>e.kind===`scrollTo`),s=o===void 0?null:{cause:`scroll`,sceneMs:o.timestamp,placement:a({actionId:o.id,offsetMs:0})},c=e.actions[0],l=c===void 0?null:p(e,c.id),u=l===null?void 0:e.actions.find(e=>e.id===l.actionId),d=l===null||u===void 0?null:{cause:`page`,sceneMs:u.timestamp+l.offsetMs,placement:a(l)},f=s===null?d:d===null||s.sceneMs<=d.sceneMs?s:d,h=new Map((n?.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),g=f===null||f.placement===null||t===null?null:me(f.placement,t.timeline,h);return r.flatMap(e=>t?.clampedRanges.some(t=>t.kind===`replacement`&&t.id===e.id)??!1?[{replacementId:e.id,anchorId:e.targetAnchorId,atMs:null,cause:`undrawn`}]:f===null?[]:[{replacementId:e.id,anchorId:e.targetAnchorId,atMs:g,cause:f.cause}])}function Wn(e){return e.cause===`undrawn`?`This replacement is not drawn: nothing recorded where this element is on screen, so the real text shows throughout. Cover the area with a mask.`:`The page ${e.cause===`scroll`?`scrolls`:`changes page`} ${e.atMs===null?`later in the take`:`at ${E(e.atMs)}`}, and after that the real text can show. Check the export, or cover the area with a mask.`}function Gn(e){if(e.length===0)return null;let t=e.length,n=t===1?`its`:`their`,r=e.filter(e=>e.cause===`undrawn`).length;if(r===t)return`${t} replacement${t===1?``:`s`} ${t===1?`is`:`are`} not drawn — check the export.`;if(r>0)return`${t} replacement${t===1?``:`s`} may not cover ${n} text — check the export.`;let i=e.map(e=>e.atMs).filter(e=>e!==null),a=i.length===0?`later in the take`:`after ${E(Math.min(...i))}`;return`${t} replacement${t===1?``:`s`} may not cover ${n} text ${a} — check the export.`}function Kn(e){let t=e instanceof Error?e.message:String(e),n=/[.!?]$/.test(t)?t:`${t}.`,r=typeof e==`object`&&e?e:{};return{text:`Not shown: ${n}`,expected:r.reason===`revealRefused`&&r.status===404}}function qn(){let e=new Map;return{isOpen:(t,n)=>e.get(t)??n,set:(t,n)=>{e.set(t,n)}}}var Jn={attachFailed:`Couldn't record the screen, so this take has no video`,debuggerDetached:`Recording stopped partway through`,debuggerLost:`Recording stopped and couldn't restart`,debuggerRecovered:`A stretch in the middle is missing`,workerRestarted:`The extension restarted mid-take, so this take has no video`,noKeyframes:`Nothing could be photographed, so there's no video`,screencastUnavailable:`Motion couldn't be recorded, so this take is stills`,muxFailed:`The motion couldn't be encoded, so this take is stills`,muxUnavailable:`There was nowhere to encode the motion, so this take is stills`,budgetSpent:`The take outran its motion budget, so the rest is stills`,credentialSuspended:`Motion paused while you typed in a password field`,motionIncomplete:`Some motion couldn't be saved, so parts are stills`,motionInterrupted:`Recording was interrupted, so parts are stills`,spansDiscarded:`Some motion couldn't be encoded, so those moments are stills`,storageRefused:`This take's frames couldn't be saved — free up space and record it again`,bundleInvalid:`This take's video couldn't be put together`},Yn={canceled_by_user:`you cancelled it on the debugging bar`,target_closed:`the page was replaced`,replaced_with_devtools:`DevTools took the tab`,render_process_gone:`the page crashed`},Xn=new Set([`debuggerDetached`,`debuggerLost`,`debuggerRecovered`]),Zn=e=>Object.hasOwn(Yn,e)?Yn[e]:e;function Qn(e){let t=Jn[e];if(t!==void 0)return t;let n=e.indexOf(`:`);if(n>0){let t=e.slice(0,n),r=Jn[t],i=e.slice(n+1);if(r!==void 0&&i!==``)return`${r} — ${Xn.has(t)?Zn(i):i}`}return e}function $n(e){if(e.reason==null)return null;let t=e=>`${e>0?Math.max(1,Math.round(e/1e3)):0}s`,n=e.coveredMs>0?` (${t(e.coveredMs)} of ${t(e.takeMs)} recorded)`:``;return`${Qn(e.reason)}${n}`}var er={anchorNotRendered:!0,anchorUnreachable:!0,cancelledByAuthor:!0,pageSilent:!0,pageFaulted:!0,clickNotDelivered:!0,mutating:!1,redactedWithoutReplacement:!1,unresolvedAnchor:!1,ambiguousAnchor:!1,anchorFrameMismatch:!1,pageWentElsewhere:!1,signedOut:!1,unperformableStep:!1,waitTimeout:!1,occlusionTimeout:!1,debuggerUnavailable:!1,windowClosed:!1,portFailure:!1,deviceFailed:!1,noActions:!1};function tr(e){return e===null||e.reason===null?!1:er[e.reason]===!0}function nr(e,t,n){if(e===null||e.reason===null||!t.mayReplay||e.reason===`mutating`)return null;let r=ct(e.reason),i=n!==void 0&&ft(n),a=i?`The script run`:`The re-shoot`,o=i?`performed`:`reconstructed`,s=n?dt(n,e):null,c=s?` Stopped at step ${s.number}, ${s.kind} ${s.label}.`:``;if(e.reason===`noActions`)return`${a} never started: ${r}.`;if(e.outcome===`complete`)return e.reason===`portFailure`?`${a} ${o} all ${e.total} steps but could not save the frames: ${r}. Nothing from it reached the store, so this page still shows the frames from before it ran — free some space and ${pt(i)} to try again.`:`${a} ${o} all ${e.total} steps, but: ${r}.`;let l=tr(e)?`and stopped early`:`then stopped`;return`${a} ${o} ${e.completed} of ${e.total} steps ${l}: ${r}.${c}`}function D(e,t){let n=e.actions.findIndex(e=>e.id===t);if(n===-1)throw Error(`unknown action "${t}"`);return n}function rr(e,t){let n=e.camera.find(e=>e.id===t);if(!n)throw Error(`unknown zoom "${t}"`);return n}var ir=1,ar=e=>Error(`1:1 is not a zoom — remove the zoom instead of authoring ${e}`);function or(e,t){let n=new Set(t.map(e=>e.id)),r={rehomed:0,dropped:0},i=new Map(e.actions.map(e=>[e.id,e.timestamp])),a=t=>{let r=e.actions.findIndex(e=>e.id===t);for(let t=r-1;t>=0;t--){let r=e.actions[t]?.id;if(r!==void 0&&n.has(r))return r}for(let t=r+1;t<e.actions.length;t++){let r=e.actions[t]?.id;if(r!==void 0&&n.has(r))return r}return null},o=e=>{if(n.has(e.actionId))return e;let t=a(e.actionId);if(t===null)return null;let r=(i.get(e.actionId)??0)-(i.get(t)??0);return{actionId:t,offsetMs:e.offsetMs+r}},s=(...e)=>e.some(e=>e!==void 0&&!n.has(e.actionId)),c=e.camera.flatMap(e=>{let t=o(e.marker),n=e.end===void 0?void 0:o(e.end);return t===null||n===null?(r.dropped+=1,[]):(s(e.marker,e.end)&&(r.rehomed+=1),[n===void 0?{...e,marker:t}:{...e,marker:t,end:n}])}),l=e.edits.masks.flatMap(e=>{if(e.start===void 0||e.end===void 0)return[e];let t=o(e.start),n=o(e.end);return t===null||n===null?(r.dropped+=1,[]):(s(e.start,e.end)&&(r.rehomed+=1),[{...e,start:t,end:n}])}),u={};for(let t of[`head`,`tail`]){let n=e.edits.trim?.[t];if(n===void 0)continue;let i=o(n);if(i===null){r.dropped+=1;continue}s(n)&&(r.rehomed+=1),u[t]=i}let d=e.edits.holds.filter(e=>n.has(e.marker.actionId)?!0:(r.dropped+=1,!1)),f=(e.edits.cuts??[]).filter(e=>n.has(e.actionId)?!0:(r.dropped+=1,!1)),p=e.edits.gaps??[],m=new Set(p.filter(e=>n.has(e.afterActionId)).map(e=>e.afterActionId)),h=p.flatMap(t=>{if(n.has(t.afterActionId))return[t];let i=e.actions.findIndex(e=>e.id===t.afterActionId),a=null;for(let t=i-1;t>=0;t--){let r=e.actions[t]?.id;if(r!==void 0&&n.has(r)){a=r;break}}return a===null||m.has(a)?(r.dropped+=1,[]):(m.add(a),r.rehomed+=1,[{...t,afterActionId:a}])}),g=new Set(t.flatMap(e=>e.anchorId===null?[]:[e.anchorId])),_=e.edits.replacements.filter(e=>e.targetAnchorId===null||g.has(e.targetAnchorId)?!0:(r.dropped+=1,!1)),v={...e.edits,replacements:_,masks:l,holds:d,cuts:f,gaps:h};return u.head===void 0&&u.tail===void 0?delete v.trim:v.trim=u,{scene:te({...e,actions:t,camera:c,edits:v}),report:r}}var sr={rehomed:0,dropped:0};function cr(e,t){return or(e,t)}function O(e){return{scene:e,report:sr}}function lr(e,t,n){switch(t.kind){case`rename`:return O({...e,meta:{...e.meta,name:t.name}});case`retext`:{let n=D(e,t.actionId),r=e.actions[n];if(r?.kind!==`type`)throw Error(`action "${t.actionId}" is not a type action`);let i=[...e.actions];return i[n]={...r,text:t.text,redacted:!1},cr(e,i)}case`deleteAction`:return D(e,t.actionId),cr(e,e.actions.filter(e=>e.id!==t.actionId));case`cutStep`:{D(e,t.actionId);let r=e.edits.cuts??[];if(r.some(e=>e.actionId===t.actionId))throw Error(`"${t.actionId}" is already cut.`);return O({...e,edits:{...e.edits,cuts:[...r,{id:n(),actionId:t.actionId}]}})}case`uncutStep`:{let n=e.edits.cuts??[];if(!n.some(e=>e.actionId===t.actionId))throw Error(`"${t.actionId}" is not cut.`);return O({...e,edits:{...e.edits,cuts:n.filter(e=>e.actionId!==t.actionId)}})}case`deleteActionKeepingPace`:{let r=D(e,t.actionId);if(r===0)throw Error(`"${t.actionId}" is the first step, so there is no step before it to carry its time. Delete it on its own, or trim the take's head instead.`);if(r===e.actions.length-1)throw Error(`"${t.actionId}" is the last step, and the step before it would become the last — a gap is the time between two steps, so it could not carry one. Delete it on its own, or trim the take's tail instead.`);let i=e.actions[r-1];if(i===void 0)throw Error(`unknown action "${t.actionId}"`);let{scene:a,report:o}=cr(e,e.actions.filter(e=>e.id!==t.actionId)),s=a.edits.gaps??[],c=s.find(e=>e.afterActionId===i.id),l={id:c?.id??n(),afterActionId:i.id,durationMs:t.durationMs};return{scene:{...a,edits:{...a.edits,gaps:c?s.map(e=>e.id===c.id?l:e):[...s,l]}},report:o}}case`trimFrom`:{let n=D(e,t.actionId);return cr(e,e.actions.slice(0,n))}case`setTrim`:{let n={...e.edits.trim??{}};for(let r of[`head`,`tail`]){let i=t[r];i!==void 0&&(i===null?delete n[r]:(D(e,i.actionId),n[r]=i))}let r={...e.edits};return n.head===void 0&&n.tail===void 0?delete r.trim:r.trim=n,O({...e,edits:r})}case`addZoom`:{if(D(e,t.marker.actionId),t.scale<=1)throw ar(t.scale);let r=t.target;if(r.kind===`element`&&!e.anchors.some(e=>e.id===r.anchorId))throw Error(`unknown anchor "${r.anchorId}"`);let i=r.kind===`element`&&t.marker.offsetMs===0?h.leadInMs:t.marker.offsetMs,a={id:n(),kind:`zoom`,...r.kind===`element`?{anchorId:r.anchorId}:{point:{x:r.x,y:r.y}},marker:{actionId:t.marker.actionId,offsetMs:i},scale:t.scale,...t.note===void 0?{}:{note:t.note}};return O({...e,camera:[...e.camera,a]})}case`setZoomRange`:{let n=rr(e,t.id);D(e,t.start.actionId),t.end&&D(e,t.end.actionId);let{end:r,...i}=n,a=t.end===null?{...i,marker:t.start}:{...i,marker:t.start,end:t.end};return O({...e,camera:e.camera.map(e=>e.id===n.id?a:e)})}case`setZoomScale`:{let n=rr(e,t.id);if(t.scale<=1)throw ar(t.scale);return O({...e,camera:e.camera.map(e=>e.id===n.id?{...e,scale:t.scale}:e)})}case`setZoomTarget`:{let n=rr(e,t.id),{anchorId:r,note:i,...a}=n;return O({...e,camera:e.camera.map(e=>e.id===n.id?{...a,point:{x:t.point.x,y:t.point.y}}:e)})}case`removeZoom`:return rr(e,t.id),O({...e,camera:e.camera.filter(e=>e.id!==t.id)});case`addReplacement`:if(t.targetAnchorId!==null&&!e.anchors.some(e=>e.id===t.targetAnchorId))throw Error(`unknown anchor "${t.targetAnchorId}"`);return O({...e,edits:{...e.edits,replacements:[...e.edits.replacements,{id:n(),targetAnchorId:t.targetAnchorId,find:t.find,replace:t.replace}]}});case`editReplacement`:return O({...e,edits:{...e.edits,replacements:e.edits.replacements.map(e=>e.id===t.id?{...e,replace:t.replace}:e)}});case`removeReplacement`:return O({...e,edits:{...e.edits,replacements:e.edits.replacements.filter(e=>e.id!==t.id)}});case`addMask`:return D(e,t.start.actionId),D(e,t.end.actionId),O({...e,edits:{...e.edits,masks:[...e.edits.masks,{id:n(),rect:t.rect,start:t.start,end:t.end,...t.note===void 0?{}:{note:t.note}}]}});case`setMaskRange`:if(D(e,t.start.actionId),D(e,t.end.actionId),!e.edits.masks.some(e=>e.id===t.id))throw Error(`unknown mask "${t.id}"`);return O({...e,edits:{...e.edits,masks:e.edits.masks.map(e=>e.id===t.id?{...e,start:t.start,end:t.end}:e)}});case`moveMask`:if(!e.edits.masks.some(e=>e.id===t.id))throw Error(`unknown mask "${t.id}"`);if(t.rect.width<ir||t.rect.height<ir)throw Error(`That drag left the mask off the frame — nothing would be covered. Drag it back over the picture.`);return O({...e,edits:{...e.edits,masks:e.edits.masks.map(e=>e.id===t.id?{...e,rect:t.rect}:e)}});case`setMaskNote`:return O({...e,edits:{...e.edits,masks:e.edits.masks.map(e=>{if(e.id!==t.id)return e;let{note:n,...r}=e;return t.note===``?r:{...r,note:t.note}})}});case`removeMask`:return O({...e,edits:{...e.edits,masks:e.edits.masks.filter(e=>e.id!==t.id)}});case`setBranding`:return O({...e,branding:Fe(e.branding,t.patch)});case`setCursor`:return O({...e,cursor:{...e.cursor,...t.patch}});case`setMotion`:return O({...e,motion:{...e.motion??ge,...t.patch}});case`setAspect`:return O({...e,canvas:{...e.canvas,aspect:t.aspect}});case`setGap`:{if(D(e,t.afterActionId)===e.actions.length-1)throw Error(`there is no step after "${t.afterActionId}" — a gap is the time between two steps, so the last step cannot carry one`);let r=e.edits.gaps??[],i=r.find(e=>e.afterActionId===t.afterActionId),a={id:i?.id??n(),afterActionId:t.afterActionId,durationMs:t.durationMs};return O({...e,edits:{...e.edits,gaps:i?r.map(e=>e.id===i.id?a:e):[...r,a]}})}case`clearGap`:return O({...e,edits:{...e.edits,gaps:(e.edits.gaps??[]).filter(e=>e.afterActionId!==t.afterActionId)}})}}function ur(e,t,n){let r=lr(e,t,n);return{scene:b.parse(r.scene),report:r.report}}function dr(e){return{scene:e,past:[],future:[],report:null,error:null,dirty:!1,hoverReport:null}}function fr(e,t,n){let r,i;try{({scene:r,report:i}=ur(e.scene,t,n))}catch(t){return{...e,error:t instanceof Error?t.message:String(t),report:null}}return t.kind===`setBranding`&&Ae(e.scene.branding,r.branding)?{...e,error:null}:{scene:r,past:[...e.past,e.scene].slice(-50),future:[],report:pr(i),error:null,dirty:!0,hoverReport:mr(t)?null:e.hoverReport}}function pr(e){let t=[];return e.rehomed>0&&t.push(`Moved ${e.rehomed} edit${e.rehomed===1?``:`s`} to a neighbouring step because the step they were attached to was removed.`),e.dropped>0&&t.push(`Removed ${e.dropped} edit${e.dropped===1?``:`s`} that had no step left to attach to.`),t.length===0?null:t.join(` `)}function mr(e){switch(e.kind){case`deleteAction`:case`trimFrom`:case`cutStep`:case`uncutStep`:return!0;default:return!1}}function hr(e){let t=e.past[e.past.length-1];return t?{...e,scene:t,past:e.past.slice(0,-1),future:[e.scene,...e.future],report:null,error:null,dirty:!0,hoverReport:null}:e}function gr(e){let[t,...n]=e.future;return t?{...e,scene:t,past:[...e.past,e.scene].slice(-50),future:n,report:null,error:null,dirty:!0,hoverReport:null}:e}function _r(e){return{...e,dirty:!1}}var vr={mayReplay:!0};function yr(e){let{renderMode:t,...n}=e.meta,r={...e,meta:n,flags:{...e.flags,hoverSensitive:!1}};return JSON.stringify(r,(e,t)=>typeof t==`object`&&t&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:+(e>t))):t)}function br(e,t){return e.meta===void 0||e.flags===void 0?!1:yr(e)===yr(t)}function xr(e,t){let n=(e,t,r)=>{if(JSON.stringify(e)===JSON.stringify(t))return null;if(e!==null&&t!==null&&typeof e==`object`&&typeof t==`object`){let i=new Set([...Object.keys(e),...Object.keys(t)]);for(let a of[...i].sort()){let i=n(e[a],t[a],`${r}.${a}`);if(i!==null)return i}}let i=e=>JSON.stringify(e)?.slice(0,80)??`undefined`;return`${r}: ${i(e)} -> ${i(t)}`};return n(JSON.parse(yr(e)),JSON.parse(yr(t)),`scene`)}function Sr(e,t){let{renderMode:n,...r}=e.meta;return{...e,meta:t.meta.renderMode===void 0?r:{...r,renderMode:t.meta.renderMode}}}function Cr(e,t){return{...Sr(e,t),flags:{...e.flags,hoverSensitive:t.flags.hoverSensitive}}}function wr(e){let t=dr({}),n=null,r=null,i=null,a=null,o=new Set,s=Promise.resolve(),c=e=>{let t=s.then(e,e);return s=t.catch(()=>{}),t},l=()=>({scene:t.scene,bundle:n,madeFrom:n?.madeFrom??null,replaySentence:nr(i,vr,t.scene),replayRecoverable:tr(i),captureSentence:a===null||n!==null&&n.source!==`capture`?null:$n(a),report:t.report,error:t.error,canUndo:t.past.length>0,canRedo:t.future.length>0,hoverReport:t.hoverReport}),u=()=>{let e=l();for(let t of o)t(e)},d=async t=>{let n=await e.loadScene(e.sceneId),i=n.flags.hoverSensitive&&!t.flags.hoverSensitive?{...t,flags:{...t.flags,hoverSensitive:!0}}:t;return r!==null&&t.meta.name===r&&n.meta.name!==r&&(i={...i,meta:{...i.meta,name:n.meta.name}}),i=Sr(i,n),await e.saveScene(i),r=i.meta.name,i};return{load:()=>c(async()=>{let o=await e.loadScene(e.sceneId),s=await e.bundles.active(e.sceneId);n=s.bundle,i=s.replay,a=s.capture;let c=br(t.scene,o);!c&&(t.past.length>0||t.future.length>0)&&console.info(`[demoman] editor: undo history cleared on re-read — the document changed at ${xr(t.scene,o)}`),t=c?{...dr(o),past:t.past.map(e=>Cr(e,o)),future:t.future.map(e=>Cr(e,o))}:dr(o),r=o.meta.name,u()}),snapshot:l,subscribe(e){return o.add(e),()=>o.delete(e)},async dispatch(n){await c(async()=>{let r=t,i=fr(t,n,e.newId);if(i.scene===r.scene){t=i,u();return}t=i;try{t={...t,scene:await d(t.scene)}}catch(e){t={...r,error:e instanceof Error?e.message:String(e)},u();return}t=_r(t),u()})},async undo(){await c(async()=>{let e=hr(t);if(e.scene===t.scene)return;let n=t;t=e;try{t={...t,scene:await d(t.scene)}}catch(e){t={...n,error:e instanceof Error?e.message:String(e)},u();return}t=_r(t),u()})},async redo(){await c(async()=>{let e=gr(t);if(e.scene===t.scene)return;let n=t;t=e;try{t={...t,scene:await d(t.scene)}}catch(e){t={...n,error:e instanceof Error?e.message:String(e)},u();return}t=_r(t),u()})},async settled(){let e;do e=s,await e;while(e!==s)},setHoverReport(e){t={...t,hoverReport:e},u()}}}var Tr=1.2;function Er(e,t){let n=e.key,r=n.toLowerCase();if(e.metaKey||e.ctrlKey)return r===`z`?e.shiftKey?t.canRedo?{kind:`redo`}:null:t.canUndo?{kind:`undo`}:null:r===`y`&&e.ctrlKey&&!e.metaKey?t.canRedo?{kind:`redo`}:null:!e.shiftKey&&(n===`ArrowLeft`||n===`ArrowRight`)?{kind:`seekEdge`,edge:n===`ArrowLeft`?`head`:`tail`}:null;if(n===` `)return{kind:`playPause`};if(r===`j`)return{kind:`shuttle`,direction:-1};if(r===`k`)return{kind:`stop`};if(r===`l`)return{kind:`shuttle`,direction:1};if(n===`ArrowRight`||n===`ArrowLeft`){let t=e.shiftKey?500:100;return{kind:`nudge`,deltaMs:n===`ArrowRight`?t:-t}}return n===`ArrowDown`?{kind:`stepBeat`,delta:1}:n===`ArrowUp`?{kind:`stepBeat`,delta:-1}:n===`Home`?{kind:`seekEdge`,edge:`head`}:n===`End`?{kind:`seekEdge`,edge:`tail`}:r===`i`?{kind:`setTrim`,edge:`head`}:r===`o`?{kind:`setTrim`,edge:`tail`}:n===`Delete`||n===`Backspace`?t.hasSelection?{kind:`deleteSelection`,keepPace:e.shiftKey&&t.selectionIsBeat}:null:n===`+`||n===`=`?t.hasTimeline?{kind:`zoomTimeline`,factor:Tr}:null:n===`-`||n===`_`?t.hasTimeline?{kind:`zoomTimeline`,factor:1/Tr}:null:r===`z`&&e.shiftKey?t.hasTimeline?{kind:`zoomFit`}:null:r===`s`?{kind:`toggleSnapping`}:n===`Escape`?t.hasSelection?{kind:`clearSelection`}:t.panelOpen?{kind:`closePanel`}:null:n===`?`?{kind:`toggleHelp`}:null}var Dr={Mod:{label:{mac:`⌘`,other:`Ctrl`},spoken:{mac:`Command`,other:`Control`}},Shift:{label:{mac:`⇧`,other:`Shift`},spoken:`Shift`},Space:{label:`Space`,spoken:`Space`},Esc:{label:`Esc`,spoken:`Escape`},Delete:{label:{mac:`⌫`,other:`Delete`},spoken:`Delete`},Home:{label:`Home`,spoken:`Home`},End:{label:`End`,spoken:`End`},Left:{label:`←`,spoken:`Left arrow`},Right:{label:`→`,spoken:`Right arrow`},Up:{label:`↑`,spoken:`Up arrow`},Down:{label:`↓`,spoken:`Down arrow`}},Or=(e,t)=>typeof e==`string`?e:t?e.mac:e.other;function kr(e,t){let n=Dr[e];return n===void 0?e:Or(n.label,t)}var Ar=new Set([`⌘`,`⇧`,`⌫`,`←`,`→`,`↑`,`↓`]);function jr(e){return Ar.has(e)}function Mr(e,t){let n=Dr[e];return n===void 0?e:Or(n.spoken,t)}function Nr(e,t){return e.map(e=>Mr(e,t)).join(` plus `)}function Pr(e){return/\bMac/i.test(e)}function Fr(e,t){return Or(e.description,t)}var Ir=[{group:`Playback`,combos:[[`Space`]],description:`Play / pause`,action:`playPause`},{group:`Playback`,combos:[[`J`],[`L`]],description:`Shuttle back / forward`,action:`shuttle`},{group:`Playback`,combos:[[`K`]],description:`Stop`,action:`stop`},{group:`Playback`,combos:[[`Left`],[`Right`]],description:`Nudge playhead`,action:`nudge`},{group:`Playback`,combos:[[`Shift`,`Left`],[`Shift`,`Right`]],description:`Nudge half a second`,action:`nudge`},{group:`Playback`,combos:[[`Mod`,`Left`],[`Mod`,`Right`]],description:`Jump to start / end`,action:`seekEdge`},{group:`Steps`,combos:[[`Up`],[`Down`]],description:`Previous / next step`,action:`stepBeat`},{group:`Steps`,combos:[[`Esc`]],description:`Clear selection`,action:`clearSelection`},{group:`Steps`,combos:[[`Delete`]],description:`Delete and close the gap`,action:`deleteSelection`},{group:`Steps`,combos:[[`Shift`,`Delete`]],description:`Delete, keep the pause`,action:`deleteSelection`},{group:`Trim`,combos:[[`I`],[`O`]],description:`Trim start / end to playhead`,action:`setTrim`},{group:`Editing`,combos:[[`Mod`,`Z`]],description:`Undo`,action:`undo`},{group:`Editing`,combos:[[`Shift`,`Mod`,`Z`]],description:{mac:`Redo`,other:`Redo — or Ctrl+Y`},action:`redo`},{group:`Timeline`,combos:[[`+`],[`−`]],description:`Zoom in / out`,action:`zoomTimeline`},{group:`Timeline`,combos:[[`Shift`,`Z`]],description:`Fit the whole take`,action:`zoomFit`},{group:`Timeline`,combos:[[`S`]],description:`Snapping on / off`,action:`toggleSnapping`},{group:`Panels`,combos:[[`?`]],description:`Show shortcuts`,action:`toggleHelp`},{group:`Panels`,combos:[[`Esc`]],description:`Close the panel`,action:`closePanel`}];function Lr(e){let t=e.getBoundingClientRect(),n=Math.min(t.width/e.width,t.height/e.height);return{left:(t.width-e.width*n)/2,top:(t.height-e.height*n)/2,scale:n}}var Rr=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],zr=3;function Br(e,t,n){e.style.left=`${n.left+t.x*n.scale}px`,e.style.top=`${n.top+t.y*n.scale}px`,e.style.width=`${t.width*n.scale}px`,e.style.height=`${t.height*n.scale}px`}function Vr(e,t,n,r){let{x:i,y:a,width:o,height:s}=e;return t===`body`?{x:i+n,y:a+r,width:o,height:s}:(t.includes(`w`)&&(i+=n,o-=n),t.includes(`e`)&&(o+=n),t.includes(`n`)&&(a+=r,s-=r),t.includes(`s`)&&(s+=r),o<0&&(i+=o,o=-o),s<0&&(a+=s,s=-s),{x:i,y:a,width:o,height:s})}function Hr(e,t,n){e.replaceChildren();let{selection:r,resolved:i,presentation:a}=t;if(r===null||r.kind===`tick`||i===null||a===null)return;let o=Lr(t.canvas),s={resolved:i,target:t.target,presentation:a,outputTimeMs:t.outputTimeMs};if(r.kind===`mask`){let i=t.model.masks.find(e=>e.id===r.id);if(!i)return;let a=C(`div`,`overlay`);a.setAttribute(`data-overlay`,`mask`);let c=Qt({rect:i.rect,...s});Br(a,c,o);let l=(e,t)=>{e.addEventListener(`pointerdown`,e=>{e.preventDefault(),e.stopPropagation();let r=c,l=!1,u=n=>{Math.hypot(n.clientX-e.clientX,n.clientY-e.clientY)>zr&&(l=!0),c=Vr(r,t,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Br(a,c,o)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),l&&n.onMaskRect(i.id,$t({rect:c,...s}))};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)})};l(a,`body`);for(let e of Rr){let t=C(`div`,`grip`);t.setAttribute(`data-handle`,e),l(t,e),a.append(t)}e.append(a);return}let c=t.model.zooms.find(e=>e.id===r.id);if(!c)return;let l=C(`div`,`overlay`);l.setAttribute(`data-overlay`,`zoom`);let u=Qt({rect:en({zoom:c,resolved:i,viewport:i.plan.viewport,presentation:a,target:t.target}),...s});Br(l,u,o),l.addEventListener(`pointerdown`,e=>{e.preventDefault();let t=u,r=!1,i=n=>{Math.hypot(n.clientX-e.clientX,n.clientY-e.clientY)>zr&&(r=!0),u=Vr(t,`body`,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Br(l,u,o)},a=()=>{if(window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),!r)return;let e=$t({rect:u,...s});n.onZoomPoint(c.id,{x:e.x+e.width/2,y:e.y+e.height/2})};window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a)}),e.append(l)}function Ur(e){let{scene:t,resolved:n,bundle:r=null}=e,i=new Map(t.anchors.map(e=>[e.id,e])),a=new Map(n?n.plan.cameraIntents.map(e=>[e.actionId,{id:e.id,scale:e.scale,offsetMs:e.offsetMs}]):t.camera.map(e=>[e.marker.actionId,{id:e.id,scale:e.scale??h.defaultZoomScale,offsetMs:e.marker.offsetMs}])),o=new Map((t.edits.gaps??[]).map(e=>[e.afterActionId,e])),s=new Map((t.edits.holds??[]).map(e=>[e.marker.actionId,e])),c=new Map((t.edits.cuts??[]).map(e=>[e.actionId,e])),l=e=>{let t=c.get(e);return t?{id:t.id,keepJump:t.keepJump===!0}:null},u=new Map((r?.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),d=(e,t)=>{if(n===null||r===null||!re(r)||se(r,e.id))return!0;let i=u.get(e.id),a=u.get(t.id);return i===void 0||a===void 0||n.timeline.segments.some(e=>e.kind===`idle`&&e.srcEndMs>e.srcStartMs&&i<=e.srcStartMs&&e.srcEndMs<=a)},f=e=>{if(n===null)return 0;let t=0;for(let r of n.timeline.segments)r.kind===`pace`&&(Math.abs(r.srcStartMs-e)>1e-6||(t+=r.outEndMs-r.outStartMs));return t},p=(e,t)=>{if(t===void 0)return 0;if(n===null||r===null)return null;let i=u.get(e.id),a=u.get(t.id);if(i===void 0||a===void 0)return null;let o=f(a);for(let e of n.timeline.segments)e.kind===`idle`&&i<=e.srcStartMs&&e.srcEndMs<=a&&(o+=e.outEndMs-e.outStartMs);return o},m=(e,t)=>{if(t===void 0||n===null||r===null||re(r))return null;let i=u.get(t.id);return u.get(e.id)===void 0||i===void 0?null:f(i)},g=t.actions.length-1;return{beats:t.actions.map((e,c)=>{let h=e.anchorId?i.get(e.anchorId):void 0,_=a.get(e.id),v=o.get(e.id),y=s.get(e.id),b=t.actions[c+1],x=u.get(e.id);return{actionId:e.id,index:c,verb:e.kind,anchorId:e.anchorId,label:lt(h),text:e.kind===`type`?e.text:null,redacted:e.kind===`type`&&e.redacted,host:e.kind===`type`&&e.host===!0,strategy:h?.resolution.strategy??null,outputMs:n?ce(n.timeline,x??e.timestamp):null,timing:x===void 0?`estimated`:`rendered`,captureMs:e.timestamp,camera:_??null,canZoom:e.anchorId!==null,gap:v?{durationMs:v.durationMs}:null,canPace:b!==void 0&&d(e,b),renderedPauseMs:p(e,b),renderedPaceFreezeMs:m(e,b),renderedFreezeBeforeMs:r!==null&&!re(r)&&x!==void 0&&n!==null&&x<n.timeline.sourceDurationMs?f(x):0,legacyHold:y?{offsetMs:y.marker.offsetMs,durationMs:y.durationMs}:null,cut:l(e.id),isLast:c===g}}),outputDurationMs:n?.timeline.outputDurationMs??null,hasBundle:n!==null}}var Wr=(e,t,n)=>Math.min(n,Math.max(t,e)),Gr=e=>({startMs:0,endMs:Math.max(250,e)}),k=(e,t)=>(t-e.startMs)/(e.endMs-e.startMs),Kr=(e,t)=>e.startMs+t*(e.endMs-e.startMs);function qr(e,t,n,r){let i=Math.max(250,r),a=Wr(n,250,i),o=Wr(e-t*a,0,i-a);return{startMs:o,endMs:o+a}}function Jr(e,t,n,r){return qr(Kr(e,r),r,(e.endMs-e.startMs)/n,t)}function Yr(e,t,n){let r=e.endMs-e.startMs;return qr(e.startMs+n,0,r,t)}var Xr=(e,t,n,r)=>qr(Kr(e,r),r,n,t);function Zr(e,t){let n=Math.max(250,e);return n*(250/n)**Wr(t,0,1)}function Qr(e,t){let n=Math.max(250,e);if(n<=250)return 0;let r=Wr(t,250,n);return Math.log(r/n)/Math.log(250/n)}function $r(e,t){switch(e){case`Mod`:return t?`Meta`:`Control`;case`Esc`:return`Escape`;case`Left`:return`ArrowLeft`;case`Right`:return`ArrowRight`;case`Up`:return`ArrowUp`;case`Down`:return`ArrowDown`;default:return e}}function ei(e,t,n=[]){if(e.dataset.tip=t,e.removeAttribute(`title`),n.length===0){delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`);return}e.dataset.tipKeys=n.join(` `);let r=Pr(navigator.userAgent);e.setAttribute(`aria-keyshortcuts`,n.map(e=>$r(e,r)).join(`+`))}function ti(e){delete e.dataset.tip,delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`)}var ni=Symbol.for(`demoman.tooltip`);function ri(e=document){let t=e,n=t[ni];n?.abort.abort(),n?.tip.remove();let r=new AbortController,{signal:i}=r,a=e.createElement(`div`);a.className=`tooltip`,a.setAttribute(`role`,`tooltip`),a.setAttribute(`data-tooltip`,``),a.hidden=!0,e.body.append(a),t[ni]={abort:r,tip:a};let o=e.defaultView??window,s=null,c=null,l=null,u=0,d=e=>e instanceof Element?e.closest(`[data-tip]`):null,f=()=>{s!==null&&clearTimeout(s),s=null,c=null},p=t=>{f();let n=t.dataset.tip??``;if(n===``||!t.isConnected)return;let r=Pr(o.navigator.userAgent),i=(t.dataset.tipKeys??``).split(` `).filter(e=>e!==``);if(a.replaceChildren(e.createTextNode(n)),i.length>0){let t=e.createElement(`span`);t.className=`tooltip-keys`;for(let n of i){let i=kr(n,r),a=e.createElement(`kbd`);a.className=`keycap`,a.textContent=i,jr(i)&&a.setAttribute(`data-symbol`,``),t.append(a)}a.append(t)}a.hidden=!1,l=t;let s=t.getBoundingClientRect(),c=a.getBoundingClientRect(),u=Math.min(Math.max(8,s.left+s.width/2-c.width/2),o.innerWidth-c.width-8),d=s.bottom+6,p=d+c.height>o.innerHeight-8?s.top-6-c.height:d;a.style.left=`${Math.round(u)}px`,a.style.top=`${Math.round(p)}px`},m=e=>{f(),!a.hidden&&e&&(u=Date.now()+500),e||(u=0),a.hidden=!0,l=null};return e.addEventListener(`pointerover`,e=>{if(e.pointerType===`touch`)return;let t=d(e.target);if(t===null){(l!==null||c!==null)&&m(!0);return}t!==l&&t!==c&&(f(),l!==null||Date.now()<u?p(t):(c=t,s=setTimeout(()=>p(t),600)))},{signal:i}),e.addEventListener(`pointerout`,e=>{let t=d(e.target);if(t===null)return;let n=e.relatedTarget;n instanceof Node&&t.contains(n)||m(!0)},{signal:i}),e.addEventListener(`pointerdown`,()=>m(!1),{capture:!0,signal:i}),e.addEventListener(`keydown`,e=>{e.key!==`Tab`&&m(!1)},{capture:!0,signal:i}),e.addEventListener(`scroll`,()=>m(!1),{capture:!0,passive:!0,signal:i}),e.addEventListener(`focusin`,e=>{let t=d(e.target);t?.matches(`:focus-visible`)&&p(t)},{signal:i}),e.addEventListener(`focusout`,e=>{l!==null&&d(e.target)===l&&m(!1)},{signal:i}),a}function ii(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-export-panel`,``),e.append(C(`h2`,void 0,`Export`));let t=C(`div`);return t.setAttribute(`data-panel-export`,``),e.append(t),e}function ai(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-background-panel`,``),e.append(C(`h2`,void 0,`Background`));let t=C(`div`);return t.setAttribute(`data-panel-branding`,``),e.append(t),e}function oi(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-shortcuts-panel`,``),e.append(C(`h2`,void 0,`Keyboard shortcuts`));let t=C(`div`);return t.setAttribute(`data-panel-shortcuts`,``),e.append(t),e}function si(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-cursor-panel`,``),e.append(C(`h2`,void 0,`Cursor`));let t=C(`div`);return t.setAttribute(`data-panel-cursor`,``),e.append(t),e}function ci(e,t,n){let r=C(`div`,`beat-panel`);r.setAttribute(`data-step-panel`,e.actionId);let i=C(`h2`);if(i.append(C(`span`,`verb`,e.verb),` `,e.label),e.strategy){let t=C(`span`,`chip`,e.strategy);t.setAttribute(`data-health`,e.strategy),i.append(` `,t)}r.append(i);let a=C(`div`);if(e.verb===`type`){if(e.redacted)a.append(C(`div`,`redacted`,e.host?`This was typed into an editor, and an edit the sensor does not follow landed mid-field, so the text is unknown. Typing a demo value here draws it over the video.`:`This value was never recorded — a credential field, or text that looked like a secret. Typing a demo-safe value here draws it over the video.`));else{let r=C(`input`);r.setAttribute(`data-retext`,e.actionId),r.value=e.text??``,r.addEventListener(`change`,()=>n.onRetext(e.actionId,r.value));let i=C(`label`,`control-row`);i.append(C(`span`,`control-label`,`Typed text`),r),a.append(i);let o=t.retextUnshown.get(e.actionId);if(o!==void 0){let t=C(`div`,`redacted`,o);t.setAttribute(`data-retext-unshown`,e.actionId),a.append(t)}}}e.timing===`estimated`&&a.append(C(`div`,`muted`,e.cut===null?`Not in the video: the frames have no marker for this step, so the timeline places it from the take's own timestamp. Delete removes it from the take.`:`Not in the video: the frames have no marker for this step, so the timeline places it from the take's own timestamp.`));let o=e.anchorId,s=o===null?null:Vn(t.scene,o);if(o!==null&&Hn(t.scene,e)){let r=t.scene.edits.replacements.find(e=>e.targetAnchorId===o),i=C(`label`,`control-row`);i.append(C(`span`,`control-label`,`Replace on-screen text`));let c=C(`input`);c.type=`text`,c.value=r?.replace??``,c.placeholder=s===null?`Replace ${e.text??`the typed text`}`:`Replace ${s}`,c.setAttribute(`data-replace-text`,o),c.setAttribute(`aria-label`,s===null?`Replace the on-screen text this step typed`:`Replace the on-screen text ${s}`),c.addEventListener(`change`,()=>{let e=c.value.trim();e===``?n.onReplaceClear(o):n.onReplace(o,e)}),i.append(c),a.append(i);let l=C(`p`,`honesty`,`Painted over this element in the preview and in every export, in type that only approximates the app's. It stays where the element was first seen, so if the page scrolls or moves on, the real text can show: check the export, or cover the area with a mask.`);l.setAttribute(`data-replace-path`,``),a.append(l);let u=t.replacementExposures.find(e=>e.anchorId===o);if(u!==void 0){let e=C(`p`,`honesty`,Wn(u));e.setAttribute(`data-replace-exposure`,``),a.append(e)}}a.hasChildNodes()&&r.append(a);let c=C(`div`,`control-actions`);if(!e.canZoom)c.append(C(`span`,`muted`,`No zoom — nothing on screen to aim at`));else{let t=C(`button`,`btn btn-quiet`,`Zoom on this step`);t.type=`button`,t.setAttribute(`data-zoom-on-step`,e.actionId),t.addEventListener(`click`,()=>n.onZoomOnStep(e.actionId)),c.append(t)}r.append(c);let l=()=>{let t=C(`button`,`btn btn-quiet`,`Use recorded`);return t.type=`button`,t.setAttribute(`data-gap-clear`,e.actionId),t.setAttribute(`aria-label`,`Restore the recorded pause after ${e.label}`),t.addEventListener(`click`,()=>n.onGapClear(e.actionId)),t},u=e.isLast?`This is the last step, and a pause is the time between two steps.`:e.canPace?null:`This step runs straight into the next one, with no dead air between them to stretch.`;if(u===null){let t=C(`label`,`control-row`),i=C(`input`);i.type=`number`,i.min=`0`,i.step=`100`,i.value=e.gap===null?``:String(e.gap.durationMs),i.placeholder=`recorded`,i.setAttribute(`data-gap`,e.actionId),i.setAttribute(`aria-label`,`Pause after ${e.label}, in milliseconds. Empty plays back the recorded pause.`),i.addEventListener(`change`,()=>{let t=i.value.trim();t===``?n.onGapClear(e.actionId):n.onGap(e.actionId,Number(t))});let a=C(`span`,`control-inline`);if(a.append(i,C(`span`,void 0,`ms`)),e.gap!==null&&a.append(l()),t.append(C(`span`,`control-label`,`Pause after this step`),a),r.append(t),e.gap!==null&&e.gap.durationMs>0&&e.renderedPaceFreezeMs===0){let t=C(`div`);t.setAttribute(`data-gap-floored`,e.actionId),t.append(C(`span`,void 0,`A ${e.gap.durationMs}ms pause is set here, but the re-shot frames already leave at least that long between these two steps, so it adds nothing to this video. Pacing only ever adds time — it never speeds your app up. Raise it, or go back to your recording from its Recordings card, where this number is the pause.`)),r.append(t)}}else if(e.gap!==null){let t=C(`div`);t.setAttribute(`data-gap-inert`,e.actionId),t.append(C(`span`,void 0,`A ${e.gap.durationMs}ms pause is set here but is not playing. ${u}`),l()),r.append(t)}if(e.legacyHold!==null){let t=e.legacyHold.offsetMs===0?`after this step`:`${e.legacyHold.offsetMs}ms into this step`,n=e.timing===`rendered`?`still plays ${t}`:`is set ${t}, but nothing has rendered that step, so it is not in the video you have`,i=C(`div`);i.setAttribute(`data-legacy-hold`,e.actionId),i.append(C(`span`,void 0,`A ${e.legacyHold.durationMs}ms pause from an earlier edit ${n}. There is no control for it: deleting this step removes it, and nothing else in the editor does.`)),r.append(i)}let d=e.cut;if(d!==null){let i=t.cutStatus.get(e.actionId)??{kind:`pending`},a=C(`div`);a.setAttribute(`data-cut-panel`,e.actionId),a.append(C(`p`,`honesty`,Dt(i,d.keepJump===!0)));let o=t.attachedToCuts.filter(t=>t.actionId===e.actionId);if(o.length>0){let t=[...o].map(e=>e.kind).sort(),n=o.length===1,r=C(`p`,`muted`,`${o.length} edit${n?``:`s`} on this step (${t.join(`, `)}) ${n?`is`:`are`} kept and not drawn. Restoring the step brings ${n?`it`:`them`} back.`);r.setAttribute(`data-cut-attached`,e.actionId),a.append(r)}let s=C(`div`,`control-actions`),c=C(`button`,`btn btn-quiet`,`Restore step`);c.type=`button`,c.setAttribute(`data-uncut`,e.actionId),c.addEventListener(`click`,()=>n.onUncut(e.actionId)),s.append(c),a.append(s),r.append(a)}let f=C(`div`,`control-actions`);if(e.index>0&&!e.isLast){let t=C(`button`,`btn btn-quiet`,`Remove this and later steps`);t.type=`button`,t.setAttribute(`data-trim`,e.actionId),t.addEventListener(`click`,()=>n.onTrimFrom(e.actionId)),f.append(t)}let p=t.hoverReport?.removable.includes(e.actionId)??!1;if(p){let t=C(`button`,`btn btn-quiet`,`Keep this hover`);t.type=`button`,t.setAttribute(`data-keep-hover`,e.actionId),t.addEventListener(`click`,()=>n.onKeepHover(e.actionId)),f.append(t)}if(d===null){let t=e.timing===`rendered`,r=t?`Cut`:`Delete`,i=C(`button`,`btn btn-quiet`,p?`${r} (removes this hover)`:r);i.type=`button`,i.setAttribute(`data-delete`,e.actionId),i.title=t?`Remove this step's frames from the video. The step stays in the take, so this can be undone exactly.`:`Remove this step from the take. The video contains no frames of it.`,i.addEventListener(`click`,()=>n.onDelete(e.actionId)),f.append(i)}return r.append(f),r}function li(e,t,n){let r=C(`div`,`zoom-panel`);r.setAttribute(`data-zoom-panel`,e.id),r.append(C(`h2`,void 0,`Zoom`));let i=C(`input`);i.type=`range`,i.min=`1.1`,i.max=String(h.maxScale),i.step=`0.05`,i.value=String(e.scale),i.setAttribute(`data-zoom-scale`,e.id),i.setAttribute(`aria-label`,`Zoom level`),we(i),i.addEventListener(`input`,()=>we(i)),i.addEventListener(`change`,()=>n.onZoomScale(e.id,Number(i.value)));let a=C(`div`,`slider-row`);a.append(C(`span`,`control-label slider-label`,`Level`),C(`span`,`slider-value`,`${e.scale.toFixed(2)}x`),i),r.append(a);let o=C(`div`);if(o.setAttribute(`data-zoom-aim`,``),e.target.kind===`element`){let{anchorId:n}=e.target,r=t.scene.anchors.find(e=>e.id===n);o.textContent=`Aims at ${r?lt(r):n}`}else o.textContent=`Aims at the cursor at ${E(e.startMs)}`;if(r.append(o),e.aimFallback!==null){let t=C(`div`,`muted`,e.aimFallback);t.setAttribute(`data-zoom-fallback`,``),r.append(t)}let s=C(`div`);s.setAttribute(`data-zoom-range`,``),s.textContent=`${E(e.startMs)} to ${E(e.endMs)}${e.endAuthored?``:` (end automatic; drag its cap to set one)`}`,r.append(s),e.clamped&&r.append(C(`div`,`muted`,`The end you set could not be reached; see the note under the timeline.`)),e.timing===`estimated`&&r.append(C(`div`,`muted`,`Estimated position: the last render carried no marker for this zoom's step, or no on-screen rect for its target.`));let c=C(`button`,`btn btn-quiet`,`Remove zoom`);c.type=`button`,c.setAttribute(`data-remove-zoom`,e.id),c.addEventListener(`click`,()=>n.onRemoveZoom(e.id));let l=C(`div`,`control-actions`);return l.append(c),r.append(l),r}function ui(e,t,n){let r=C(`div`,`mask-panel`);r.setAttribute(`data-mask-panel`,e.id),r.append(C(`h2`,void 0,`Mask`));let i=C(`div`);i.setAttribute(`data-mask-rect`,``),i.textContent=`${Math.round(e.rect.width)}x${Math.round(e.rect.height)} at ${Math.round(e.rect.x)}, ${Math.round(e.rect.y)}`,r.append(i);let a=C(`input`);a.type=`text`,a.placeholder=`What this hides`,a.value=t.scene.edits.masks.find(t=>t.id===e.id)?.note??``,a.setAttribute(`data-mask-note`,e.id),a.setAttribute(`aria-label`,`Mask note`),a.addEventListener(`change`,()=>n.onMaskNote(e.id,a.value));let o=C(`label`,`control-row`);o.append(C(`span`,`control-label`,`Note`),a),r.append(o);let s=C(`div`);s.setAttribute(`data-mask-range`,``),e.wholeTake?(s.setAttribute(`data-mask-whole-take`,``),s.textContent=`Covers the whole take (made before masks had a range).`):s.textContent=`${E(e.startMs)} to ${E(e.endMs)}`,r.append(s),r.append(C(`p`,`honesty`,`Masks are opaque fills stored in the page's own coordinates and re-applied on every render — non-destructive as layers, absolute as pixels.`));let c=C(`button`,`btn btn-quiet`,`Remove mask`);c.type=`button`,c.setAttribute(`data-remove-mask`,e.id),c.addEventListener(`click`,()=>n.onRemoveMask(e.id));let l=C(`div`,`control-actions`);return l.append(c),r.append(l),r}function di(e,t,n){let{selection:r,rail:i}=t;if(i===`shortcuts`&&e.querySelector(`:scope > .inspector > [data-shortcuts-panel]`)!==null)return;let a=C(`div`,`inspector`),o=r?.kind===`tick`?t.view.beats.find(e=>e.actionId===r.actionId):void 0,s=r?.kind===`zoom`?t.model.zooms.find(e=>e.id===r.id):void 0,c=r?.kind===`mask`?t.model.masks.find(e=>e.id===r.id):void 0,l;i===`selection`?o?l=ci(o,t,n):s?l=li(s,t,n):c?l=ui(c,t,n):(console.error(`[demoman] editor: the rail is on Selection with nothing selected`),l=ii()):l=i===`background`?ai():i===`cursor`?si():i===`shortcuts`?oi():ii();let u=C(`button`,`btn btn-icon inspector-close`);u.type=`button`,u.setAttribute(`data-inspector-close`,``),u.setAttribute(`aria-label`,`Close panel`),ei(u,`Close`,[`Esc`]),u.append(S(`close`)),u.addEventListener(`click`,()=>n.onClose()),a.append(u,l),e.replaceChildren(a)}var fi=[{entry:`background`,label:`Background`,glyph:`image`},{entry:`cursor`,label:`Cursor`,glyph:`mousePointer2`},{entry:`selection`,label:`Selection`,glyph:`mousePointerClick`}],pi=`Select a step, zoom or mask on the timeline`;function mi(e,t,n){let r=fi.map(({entry:e,label:r,glyph:i})=>{let a=C(`button`,`btn btn-icon`);a.type=`button`,a.setAttribute(`data-rail`,e),a.setAttribute(`aria-label`,r),a.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===e));let o=e===`selection`&&!t.hasSelection;return a.disabled=o,a.title=o?pi:r,a.append(S(i)),a.addEventListener(`click`,()=>n.onPick(e)),a});e.replaceChildren(...r)}function hi(e,t,n){e.querySelector(`svg[data-icon]`)===null&&e.replaceChildren(S(`download`),C(`span`,void 0,`Export`)),e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`export`)),e.onclick=()=>n.onPick(`export`)}function gi(e,t,n){e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`shortcuts`)),e.onclick=()=>n.onPick(`shortcuts`)}function _i(e,t,n){switch(e.phase){case`idle`:return Pe[t];case`queued`:return e.position===0?`Queued…`:`Queued (${e.position} ahead)`;case`encoding`:return e.total>0?`Exporting · ${Math.floor(e.done*100/e.total)}%`:`Exporting…`;case`saving`:return`Saving…`}}function vi(e){let t=e/1048576;return t>=1?`${Math.round(t*10)/10} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function yi(e,t){if(t===null){e.replaceChildren();return}let n=C(`div`,`notice`);n.setAttribute(`data-report`,``),n.append(C(`span`,void 0,t)),e.replaceChildren(n)}function bi(e,t,n){let r=t.hoverReport===null?null:On(t.hoverReport),i=t.hoverReport?.removable??[];if(t.notices.length===0&&r===null){e.replaceChildren();return}let a=C(`div`,void 0);a.setAttribute(`data-take-notes`,``);for(let e of t.notices){let t=C(`div`,`notice`);he(t,e),t.setAttribute(`data-take-notice`,``),a.append(t)}if(r!==null){let e=C(`div`,`notice`,r);if(e.setAttribute(`data-hover-report`,``),a.append(e),i.length>0){let t=C(`button`,`btn btn-quiet`,`Remove ${i.length} unchanged ${i.length===1?`hover`:`hovers`}`);t.type=`button`,t.setAttribute(`data-remove-hovers`,``),t.addEventListener(`click`,()=>n.onRemoveStillHovers());let r=C(`div`,`routes`);r.append(t),e.append(r)}}e.replaceChildren(a)}function xi(e,t){if(t.hasFrames){e.replaceChildren();return}let n=C(`div`,`banner`),r=C(`span`);r.append(Si(t.route)),n.append(r),e.replaceChildren(n)}function Si(e){let t=document.createDocumentFragment();return t.append(`This take has no frames — `,Ci(e,pt(e.authored))),t}function Ci(e,t){if(e.rerun.kind===`line`){let t=C(`span`);return he(t,e.rerun.text),t.setAttribute(`data-rerun-line`,``),t}let n=C(`a`,void 0,t);return n.setAttribute(`href`,e.rerun.href),n.setAttribute(`data-runs-route`,``),n}function wi(e,t){let n=[];if(t.openError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-open-error`,``),e.append(C(`strong`,void 0,`This take could not be opened`)),e.append(C(`div`,void 0,t.openError)),n.push(e)}if(t.replaySentence!==null){let e=C(`div`,`notice`);e.setAttribute(`data-replay-failure`,``);let r=t.runsRoute?.authored===!0?`script run`:`re-shoot`;if(e.append(C(`strong`,void 0,t.replayRecoverable===!0?`The last ${r} stopped early`:`The last ${r} did not finish`)),e.append(C(`div`,void 0,t.replaySentence)),t.runsRoute!=null){let n=C(`div`);n.setAttribute(`data-replay-runs-route`,``),n.append(Ci(t.runsRoute,Lt(t.runsRoute.authored))),e.append(n)}n.push(e)}if(t.captureSentence!=null){let e=C(`div`,`notice`);e.setAttribute(`data-capture-note`,``),e.append(C(`strong`,void 0,`What this take recorded`)),e.append(C(`div`,void 0,t.captureSentence)),n.push(e)}if(t.renderError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-render-error`,``),e.append(C(`strong`,void 0,`The export did not start`)),e.append(C(`div`,void 0,t.renderError)),n.push(e)}if(t.previewError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-preview-error`,``),e.append(C(`strong`,void 0,`The preview stopped`)),e.append(C(`div`,void 0,t.previewError)),n.push(e)}if(t.hoverRemovalError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-hover-removal-error`,``),e.append(C(`strong`,void 0,`Not every hover was removed`)),e.append(C(`div`,void 0,t.hoverRemovalError)),n.push(e)}if(t.logoLoadError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-logo-load-error`,``),e.append(C(`strong`,void 0,`The logo could not be loaded`)),e.append(C(`div`,void 0,t.logoLoadError)),n.push(e)}if(t.error!==null){let e=C(`div`,`notice`);e.setAttribute(`data-action-error`,``),e.append(C(`strong`,void 0,`That edit did not go through`)),e.append(C(`div`,void 0,t.error)),n.push(e)}if(t.deleteError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-delete-error`,``),e.append(C(`strong`,void 0,`This demo was not deleted`)),e.append(C(`div`,void 0,t.deleteError)),n.push(e)}if(t.navigationError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-navigation-error`,``),e.append(C(`strong`,void 0,`The ${t.navigationError.page} did not open`)),e.append(C(`div`,void 0,t.navigationError.reason)),n.push(e)}e.replaceChildren(...n)}function Ti(e,t,n){Ie(e,t,n)}var Ei={light:`Light`,dark:`Dark`,touch:`Touch`},Di={light:1/16,dark:1/16,touch:0};function Oi(e,t,n){let{height:i,hotspot:a,ink:o}=r[e],s=i*t,c={x:(o.min.x+o.max.x)/2,y:(o.min.y+o.max.y)/2};return{x:n/2-(c.x-a.x-Di[e])*s,y:n/2-(c.y-a.y)*s}}var ki=.6;function Ai(e,t,n){return Math.min(Math.min(2,Math.max(.5,t))*ki,n/r[e].height)}function ji(e,t){let n=C(`canvas`);n.width=44,n.height=44;let r=n.getContext(`2d`);if(!r)return console.error(`the cursor panel could not paint its "${e}" preview: no 2D context`),n;let i=Ai(e,t,44);return ue(r,Oi(e,i,44),i,o,e),n}function Mi(e,t,n,r,i,a,o,s){let c=C(`div`,`slider-row`),l=C(`input`);l.type=`range`,l.min=String(r),l.max=String(i),l.step=`0.05`,l.value=String(n),l.disabled=s,l.setAttribute(e,``),l.setAttribute(`aria-label`,t);let u=C(`span`,`slider-value`,a(n));we(l),l.addEventListener(`input`,()=>{we(l),u.textContent=a(Number(l.value)),o.preview(Number(l.value))}),l.addEventListener(`change`,()=>o.commit(Number(l.value)));let d=()=>{Number(l.value)===n&&o.end()};return l.addEventListener(`pointerup`,d),l.addEventListener(`pointercancel`,d),c.append(C(`span`,`control-label slider-label`,t),u,l),c}var Ni=e=>`${Math.round(e*100)}%`,Pi=e=>`${e.toFixed(2)}x`;function Fi(e,t,n,r,i,a,o,s,c){return Mi(e,t,n,r,i,a,{preview:e=>s.onCursorPreview({[o]:e}),commit:e=>s.onCursor({[o]:e}),end:()=>s.onCursorPreviewEnd()},c)}function Ii(e,t,n,r,i){return Mi(e,t,n,0,1,Ni,{preview:e=>i.onMotionPreview({[r]:e}),commit:e=>i.onMotion({[r]:e}),end:()=>i.onMotionPreviewEnd()},!1)}function Li(e,t,n,r,i,a){return Ne(t,null,Re({key:r,checked:n,disabled:a,attrs:{[e]:``},onChange:e=>i.onCursor({[r]:e})}))}function Ri(e,t,n,r,i=!1){let a=C(`div`),o=t.hidden;a.append(Li(`data-cursor-hidden`,`Hide cursor`,t.hidden,`hidden`,r,!1));let s=Fi(`data-cursor-scale`,`Size`,t.scale,.5,2,Pi,`scale`,r,o);i&&a.append(s);let c=C(`div`,`cursor-styles`);c.setAttribute(`role`,`radiogroup`),c.setAttribute(`aria-label`,`Cursor style`),o&&c.setAttribute(`aria-disabled`,`true`);for(let e of[`light`,`dark`,`touch`]){let n=C(`button`,`cursor-style`);n.type=`button`,n.disabled=o,n.setAttribute(`role`,`radio`),n.setAttribute(`data-cursor-style`,e),n.setAttribute(`aria-checked`,String(t.style===e)),n.setAttribute(`aria-label`,Ei[e]),n.title=Ei[e],n.append(ji(e,t.scale)),n.addEventListener(`click`,()=>r.onCursor({style:e})),c.append(n)}i||a.append(C(`div`,`cursor-label`,`Style`),c),i||a.append(s,Fi(`data-cursor-blur`,`Motion blur`,t.motionBlur,0,1,Ni,`motionBlur`,r,o),Fi(`data-cursor-tilt`,`Tilt`,t.tilt??pe.tilt,0,1,Ni,`tilt`,r,o),Fi(`data-cursor-bounce`,`Click bounce`,t.clickBounce??pe.clickBounce,0,2,Pi,`clickBounce`,r,o),Li(`data-cursor-idle`,`Hide when not moving`,t.hideWhenIdle,`hideWhenIdle`,r,o)),a.append(C(`div`,`cursor-label camera-label`,`Camera`),Ii(`data-motion-smoothness`,`Smoothness`,n.smoothness,`smoothness`,r),Ii(`data-motion-blur`,`Camera blur`,n.blur,`blur`,r),Ne(`Follow cursor`,null,Re({key:`motion-follow`,checked:n.follow,attrs:{"data-motion-follow":``},onChange:e=>r.onMotion({follow:e})}))),e.replaceChildren(a)}function zi(){let e=C(`progress`,`export-progress`);return e.setAttribute(`data-export-progress`,``),e.setAttribute(`aria-label`,`Export progress`),e}function Bi(e,t){return e.phase!==`idle`||t.kind===`noFrames`}function Vi(e,t,n,r){let i=e.querySelector(`[data-export-start]`);if(i===null)return!1;i.textContent=_i(t,n,r),i.disabled=Bi(t,r);let a=e.querySelector(`[data-export-progress]`);if(t.phase!==`encoding`||t.total===0)return a?.remove(),!0;let o=a??zi();return o.max=t.total,o.value=t.done,a===null&&i.closest(`.control-actions`)?.after(o),!0}function Hi(e,t,n){let r=C(`div`),i=t.run.phase!==`idle`;if(t.hasReclaimedMotion){let e=C(`p`,`notice`,`This export will use still frames where motion was reclaimed.`);e.setAttribute(`data-reclaimed-motion-notice`,``),r.append(e)}let a=C(`p`,`export-summary`,ze(t.fileType,t.durationMs));a.setAttribute(`data-export-summary`,``);let o=C(`p`,`muted`,Ee(t.aspect));o.setAttribute(`data-aspect-note`,``),r.append(a,o);let s=C(`p`,`muted`,De(t.recording,t.target));s.setAttribute(`data-size-readout`,``),r.append(s);let c=Gn(t.replacementExposures);if(c!==null){let e=C(`p`,`muted`,c);e.setAttribute(`data-export-replacement-exposure`,``),r.append(e)}let l=C(`div`,`control-row`);l.append(C(`span`,`control-label`,`File type`));let u=C(`div`,`segmented`);u.setAttribute(`role`,`radiogroup`),u.setAttribute(`aria-label`,`File type`),u.setAttribute(`data-file-types`,``);for(let e of[`mp4`,`gif`,`stills`]){let r=C(`button`,`segment`,Le[e]);r.type=`button`,r.setAttribute(`role`,`radio`),r.setAttribute(`data-file-type`,e),r.setAttribute(`aria-checked`,String(e===t.fileType)),r.disabled=i,r.addEventListener(`click`,()=>n.onFileType(e)),u.append(r)}l.append(u),r.append(l);let d=C(`button`,`btn btn-primary export-start`,_i(t.run,t.fileType,t.readiness));d.type=`button`,d.setAttribute(`data-export-start`,``),d.setAttribute(`data-readiness`,t.readiness.kind),d.disabled=Bi(t.run,t.readiness),d.addEventListener(`click`,n.onExport);let f=C(`div`,`control-actions`);if(f.append(d),t.readiness.kind===`noFrames`){let e=C(`p`,`muted`);e.setAttribute(`data-export-no-frames`,``),e.append(Si(t.runsRoute)),r.append(f,e)}else r.append(f);if(t.run.phase===`encoding`&&t.run.total>0){let e=zi();e.max=t.run.total,e.value=t.run.done,r.append(e)}if(t.save!==null&&r.append($i(t.save,n)),t.revealError!=null){let e=C(`p`,`notice notice-warn`,t.revealError);e.setAttribute(`data-reveal-error`,``),r.append(e)}if(t.save?.kind===`saved`)for(let e of t.save.outputRefs){let n=t.outputs.find(t=>t.kind===`stored`&&t.output.ref===e);n?.kind===`stored`&&Ki(r,n.output,t)}e.replaceChildren(r)}function Ui(e,t,n){let r=document.createDocumentFragment(),i=t.showAll?t.outputs:t.outputs.slice(0,5);for(let e of i){let i=C(`div`,`output`);if(i.setAttribute(`data-output`,e.kind===`file`?e.key:e.output.ref),r.append(i),e.kind===`file`){Zi(i,e,t,n);continue}let a=e.output,o=C(`div`,`beat`),s=a.sceneDigest!==void 0&&a.sceneDigest!==t.currentDigest,c=t.warningsOpen.has(a.ref);o.append(Yi(a.name,[s?Ji(a.ref):null,Gi(a.ref,Wi(a),c,n)]));let l=C(`button`,`btn btn-quiet`,`Download`);if(l.type=`button`,l.setAttribute(`data-download`,a.ref),l.addEventListener(`click`,()=>n.onDownload(a.ref)),o.append(l),i.append(o),i.append(Xi(a.ref,[vi(a.byteLength),qi(a.renderedAt)],null)),c&&Wi(a)>0){let e=C(`div`,`output-warnings`);e.setAttribute(`data-output-warnings-body`,a.ref),Ki(e,a,t.reportContext),i.append(e)}}let a=t.outputs.length-i.length;if(a>0){let e=C(`button`,`btn btn-quiet`,`Show all ${t.outputs.length}`);e.type=`button`,e.setAttribute(`data-history-all`,``),e.title=`${a} more`,e.addEventListener(`click`,n.onShowAll),r.append(e)}e.replaceChildren(r)}function Wi(e){return[e.detailViolations.length>0,e.logoWarning!==void 0,(e.unavailableSpans??[]).length>0,(e.unplacedStills??[]).length>0].filter(Boolean).length}function Gi(e,t,n,r){if(t===0)return null;let i=C(`button`,`chip chip-warn`,t===1?`1 warning`:`${t} warnings`);return i.type=`button`,i.setAttribute(`data-output-warnings`,e),i.setAttribute(`aria-expanded`,String(n)),i.addEventListener(`click`,()=>r.onWarnings(e)),i}function Ki(e,t,n){if(t.detailViolations.length>0){let{heading:r,lines:i}=Ft(t.detailViolations,n.beatAt),a=C(`div`,`notice`);a.setAttribute(`data-violations`,t.ref),a.append(C(`strong`,void 0,r));for(let e of i)a.append(C(`div`,void 0,e));a.append(C(`div`,`honesty`,`A wider recording window is what gives the camera more to work with: both the stills and the motion scale with it. A smaller export size is the other way to close the gap.`)),e.append(a)}if(t.logoWarning!==void 0){let n=C(`div`,`notice`);n.setAttribute(`data-logo-warning`,t.ref),n.append(C(`div`,void 0,t.logoWarning)),e.append(n)}let r=t.unavailableSpans??[];if(r.length>0){let i=C(`div`,`notice`);i.setAttribute(`data-unavailable`,t.ref);let a=r.every(e=>e.reason===jt),o=C(`strong`);he(o,a?`Motion was reclaimed to free space and shown as a still. ${Bt(n.runsRoute.authored,zt(n.runsRoute),`to restore`)}`:`Some motion could not be decoded and was shown as a still`),i.append(o);for(let e of r)i.append(C(`div`,void 0,`${e.ref}: ${e.reason}`));e.append(i)}let i=t.unplacedStills??[];if(i.length>0){let n=C(`div`,`notice`);n.setAttribute(`data-unplaced-stills`,t.ref);let r=i.every(e=>e.reason.includes(`cut`));n.append(C(`strong`,void 0,r?`No still for ${i.length===1?`a step you cut`:`the steps you cut`}`:`Some steps got no still`));for(let e of i)n.append(C(`div`,void 0,`${e.actionId}: ${e.reason}`));e.append(n)}}function qi(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?e:Ke(n,n.getFullYear()!==t.getFullYear())}function Ji(e){let t=C(`span`,`chip`,`Outdated`);return t.setAttribute(`data-stale-export`,e),t.title=`Made before your last edit`,t}function Yi(e,t){let n=C(`span`,`output-head`),r=C(`span`,`output-name`,e);r.title=e,n.append(r);for(let e of t)e!==null&&n.append(e);return n}function Xi(e,t,n){let r=C(`div`,`muted output-meta`,t.join(` · `));return r.setAttribute(`data-output-meta`,e),n!==null&&(r.title=n),r}function Zi(e,t,n,r){let i=C(`div`,`beat`),a=n.warningsOpen.has(t.key);if(i.append(Yi(t.name,[t.sceneDigest===n.currentDigest?null:Ji(t.key),Gi(t.key,t.caveats.length,a,r)])),t.exists){let e=C(`button`,`btn btn-quiet`,`Show in Finder`);e.type=`button`,e.setAttribute(`data-reveal`,t.key),e.addEventListener(`click`,()=>r.onReveal({kind:`path`,path:t.path})),i.append(e)}else{let e=C(`span`,`muted`,`moved or deleted`);e.setAttribute(`data-output-gone`,``),i.append(e)}if(e.append(i),e.append(Xi(t.key,[vi(t.byteLength),qi(t.renderedAt)],t.detail)),a&&t.caveats.length>0){let n=C(`div`,`notice output-warnings`);n.setAttribute(`data-output-warnings-body`,t.key);for(let e of t.caveats)n.append(C(`div`,void 0,Qi(e)));e.append(n)}}function Qi(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return/[.!?]$/.test(t)?t:`${t}.`}function $i(e,t){let n=C(`div`,e.kind===`failed`?`notice notice-error`:`notice`);n.setAttribute(`data-save-outcome`,e.kind);let r=(e,n)=>{let r=C(`button`,`btn btn-quiet`,n);return r.type=`button`,r.setAttribute(`data-save-again`,``),r.addEventListener(`click`,()=>t.onSaveAgain(e)),r};if(e.kind===`saved`){let r=e.names.length===1?`Saved ${e.names[0]} · ${vi(e.byteLength)}`:`Saved ${e.names.length} files · ${vi(e.byteLength)}`;n.append(C(`span`,void 0,r));let i=e.reveal;if(i!==null){let e=C(`button`,`btn btn-quiet`,i.kind===`path`?`Show in Finder`:`Show in folder`);e.type=`button`,e.setAttribute(`data-show-in-folder`,``),e.addEventListener(`click`,()=>t.onReveal(i)),n.append(` `,e)}if(e.summary!==null){let t=C(`div`,`muted`,e.summary);t.setAttribute(`data-save-summary`,``),n.append(t)}}else e.kind===`cancelled`?(n.append(C(`span`,void 0,`You cancelled the save.`)),e.total>1?n.append(C(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)):n.append(` `),n.append(r(e.refs,`Download again`))):(n.append(C(`strong`,void 0,`Exported, but the browser didn't save it.`)),e.total>1&&n.append(C(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)),n.append(C(`div`,void 0,e.error),r(e.refs,`Download again`)));return n}function ea(e,t){let n=C(`button`,`btn btn-icon transport-button`);return n.type=`button`,n.setAttribute(`data-transport-shuttle`,String(e)),n.setAttribute(`aria-label`,t),n.title=t,n.append(S(e===-1?`rewind`:`fastForward`)),n}function ta(e,t,n){let r=e.querySelector(`[data-transport-play]`),i=e.querySelector(`[data-transport-rate]`),a=e.querySelector(`[data-transport-controls]`),o=e.querySelector(`[data-transport-repeat]`),s=e.querySelector(`[data-transport-skip]`);if(r===null||i===null||a===null||o===null||s===null){r=C(`button`,`btn btn-icon transport-button`),r.type=`button`,r.setAttribute(`data-transport-play`,``),s=C(`button`,`btn btn-icon transport-button`),s.type=`button`,s.setAttribute(`data-transport-skip`,``),s.append(S(`skipBack`)),o=C(`button`,`btn btn-icon transport-button`),o.type=`button`,o.setAttribute(`data-transport-repeat`,``),o.append(S(`repeat`));let t=C(`span`,`transport-pip`);t.setAttribute(`aria-hidden`,`true`),o.append(t),i=C(`span`,`rate`),i.setAttribute(`data-transport-rate`,``),a=C(`div`,`transport-controls`),a.setAttribute(`data-transport-controls`,``),a.append(s,ea(-1,`Rewind (J)`),r,ea(1,`Fast forward (L)`),o,i),e.querySelector(`[data-transport-controls]`)?.remove();let n=e.querySelector(`:scope > .transport-end`);n===null?e.append(a):n.before(a)}let c=Math.abs(t.rate);for(let e of a.querySelectorAll(`[data-transport-shuttle]`)){let r=e.dataset.transportShuttle===`-1`?-1:1;e.onclick=()=>n.onShuttle(r),e.disabled=!t.enabled;let i=r===-1?t.playing&&t.rate<0:t.playing&&t.rate>1;e.toggleAttribute(`data-active`,i);let a=r===-1?`Rewind (J)`:`Fast forward (L)`,o=i?`${a}, playing ${r===-1?`backwards`:`forwards`} at ${c}x`:a;e.setAttribute(`aria-label`,o),e.title=o}s.onclick=()=>n.onSkipToStart(),s.disabled=!t.enabled;let l=`Jump to start (⌘←)`;s.setAttribute(`aria-label`,l),s.title=t.enabled?l:y(`This demo has no frames yet, so there is nothing to play. ${Bt(t.authored,t.rerunLine??null,`first`)}`),o.onclick=()=>n.onLooping(!t.looping),o.toggleAttribute(`data-active`,t.looping),o.setAttribute(`aria-pressed`,t.looping?`true`:`false`);let u=t.looping?`Repeat on — playback loops back to the start`:`Repeat off — playback stops at the end`;o.setAttribute(`aria-label`,u),o.title=u,r.onclick=()=>n.onToggle();let d=t.playing?`Pause`:`Play`;r.setAttribute(`aria-label`,d);let f=t.playing?`pause`:`play`;r.firstElementChild?.getAttribute(`data-icon`)!==f&&r.replaceChildren(S(f)),r.toggleAttribute(`data-playing`,t.playing),r.toggleAttribute(`data-active`,t.playing&&t.rate===1),r.disabled=!t.enabled,t.enabled?ei(r,d,[`Space`]):(ti(r),r.title=y(`This demo has no frames yet, so there is nothing to play. ${Bt(t.authored,t.rerunLine??null,`first`)}`));let p=t.playing&&c!==1;i.textContent=p?`${c}x`:``,i.hidden=!p,i.dataset.side=t.rate<0?`back`:`forward`}function na(e,t,n,r=e){let i=r.querySelector(`[data-transport-time]`),a=e.querySelector(`[data-stage-actions]`);if(i===null||a===null){i=C(`span`,`stage-clock`),i.setAttribute(`data-transport-time`,``),a=C(`div`,`stage-actions`),a.setAttribute(`data-stage-actions`,``);let t=C(`div`,`segmented`);t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,`Aspect ratio`),t.setAttribute(`data-aspect-toggle`,``);for(let e of[`auto`,`16:9`,`9:16`]){let n=C(`button`,`segment`,e===`auto`?`Auto`:e);n.type=`button`,n.setAttribute(`role`,`radio`),n.setAttribute(`data-aspect`,e),n.title=e===`auto`?`Auto: the video takes the recording's shape`:e===`9:16`?`Vertical: the camera follows each step, cropped for a phone`:`Landscape`,t.append(n)}a.append(t);let n=C(`button`,`btn chip`);n.type=`button`,n.setAttribute(`data-stage-zoom`,``),a.append(n);let o=C(`button`,`btn btn-icon chip chip-icon`);o.type=`button`,o.setAttribute(`data-stage-fullscreen`,``),a.append(o);let s=C(`div`,`stage-error`);s.setAttribute(`data-stage-error`,``),s.setAttribute(`role`,`alert`),s.hidden=!0;let c=C(`span`,`stage-error-text`);c.setAttribute(`data-stage-error-text`,``);let l=C(`button`,`btn btn-icon stage-error-dismiss`);l.type=`button`,l.setAttribute(`data-stage-error-dismiss`,``),l.setAttribute(`aria-label`,`Dismiss`),l.title=`Dismiss`,l.append(S(`close`)),s.append(c,l),r===e?e.replaceChildren(i,a,s):(r.replaceChildren(i),e.replaceChildren(a,s))}i.textContent=`${E(t.positionMs)} / ${E(t.durationMs)}`;for(let r of e.querySelectorAll(`[data-aspect]`)){let e=r.dataset.aspect;r.setAttribute(`aria-checked`,String(e===t.aspect)),r.onclick=()=>n.onAspect(e)}let o=e.querySelector(`[data-stage-zoom]`);o!==null&&(o.textContent=t.zoom===`fit`?`Fit`:`100%`,o.setAttribute(`aria-label`,`Zoom: ${o.textContent}`),o.disabled=!t.enabled,o.title=t.enabled?`Switch between fitting the window and actual pixels`:y(`This demo has no frames yet, so there is nothing to zoom into. ${Bt(t.authored,t.rerunLine??null,`first`)}`),o.onclick=()=>n.onZoom());let s=e.querySelector(`[data-stage-fullscreen]`);if(s!==null){let e=t.fullscreen?`Exit full screen`:`Full screen`;s.setAttribute(`aria-label`,e),s.title=e;let r=t.fullscreen?`minimize`:`maximize`;s.firstElementChild?.getAttribute(`data-icon`)!==r&&s.replaceChildren(S(r)),s.onclick=()=>n.onFullscreen()}let c=e.querySelector(`[data-stage-error]`);if(c!==null){c.hidden=t.error===null;let e=c.querySelector(`[data-stage-error-text]`);e!==null&&(e.textContent=t.error??``);let r=c.querySelector(`[data-stage-error-dismiss]`);r!==null&&(r.onclick=()=>n.onDismissError())}}var ra={undo:[`Mod`,`Z`],redo:[`Shift`,`Mod`,`Z`],"shortcuts-open":[`?`]};function ia(e=document){for(let[t,n,r]of[[`back`,`chevronLeft`,`Back to your demos`],[`undo`,`undo`,`Undo`],[`redo`,`redo`,`Redo`],[`delete`,`trash`,`Delete this demo`],[`shortcuts-open`,`circleQuestionMark`,`Keyboard shortcuts`]]){let i=e.querySelector(`#${t}`);if(i===null)continue;i.setAttribute(`aria-label`,r);let a=ra[t];a===void 0?i.title===``&&(i.title=r):ei(i,r,a),i.querySelector(`svg`)===null&&(i.textContent=``,i.append(S(n)))}}var aa=`#failure > .notice:not([data-capture-note])`;function oa(e,t){let n=[...t.querySelectorAll(`.notice, .banner`)],r=n.length;if(e.classList.toggle(`hidden`,r===0),r===0){e.removeAttribute(`data-level`),typeof t.hidePopover==`function`&&t.matches(`:popover-open`)&&t.hidePopover();return}let i=t.querySelector(aa)===null?n.some(e=>!e.hasAttribute(`data-report`))?`warn`:`info`:`error`;e.setAttribute(`data-level`,i);let a=`${r} ${r===1?`note`:`notes`} on this take${i===`error`?`, with an error`:``}`;e.setAttribute(`aria-label`,a),e.title=a,e.querySelector(`svg`)===null&&e.append(S(`circleAlert`));let o=e.querySelector(`[data-count]`);o===null&&(o=C(`span`),o.setAttribute(`data-count`,``),o.setAttribute(`aria-hidden`,`true`),e.append(o)),o.textContent=String(r)}function sa(e,t){let n=[...e.querySelectorAll(aa)].map(e=>e.textContent??``).join(`
|
|
2
|
-
`);return n!==``&&n!==t&&typeof e.showPopover==`function`&&!e.matches(`:popover-open`)&&e.showPopover(),n}function ca(e,t,n){let r=e.querySelector(`[data-shortcuts-search]`);if(r!==null&&r.value===t.query&&e.dataset.shortcutsMac===String(t.mac)){t.focus&&document.activeElement!==r&&r.focus();return}e.setAttribute(`data-shortcuts`,``),e.dataset.shortcutsMac=String(t.mac);let i=C(`input`,`shortcuts-search`);i.type=`search`,i.placeholder=`Search shortcuts`,i.setAttribute(`aria-label`,`Search shortcuts`),i.setAttribute(`data-shortcuts-search`,``),i.autocomplete=`off`,i.spellcheck=!1,i.value=t.query;let a=C(`div`,`shortcuts-body`),o=[];for(let e of Ir){let n=o[o.length-1];if(n?.group!==e.group){let t=C(`section`,`shortcuts-section`);t.append(C(`h3`,`shortcuts-group`,e.group)),a.append(t),n={section:t,group:e.group,rows:[]},o.push(n)}let r=C(`div`,`shortcuts-row`);r.setAttribute(`data-shortcut-row`,``),r.append(C(`span`,`shortcuts-what`,Fr(e,t.mac)));let i=C(`span`,`shortcuts-keys`);for(let n of e.combos){let e=C(`span`,`keychord`);e.setAttribute(`data-combo`,``),e.setAttribute(`aria-label`,Nr(n,t.mac));for(let r of n){let n=kr(r,t.mac),i=C(`kbd`,`keycap`,n);i.setAttribute(`aria-hidden`,`true`),jr(n)&&i.setAttribute(`data-symbol`,``),e.append(i)}i.append(e)}r.append(i),n.section.append(r),n.rows.push(r)}let s=C(`p`,`shortcuts-empty`,`No shortcuts match`);s.setAttribute(`data-shortcuts-empty`,``),a.append(s);let c=()=>{let e=i.value.trim().toLowerCase(),t=0;for(let{section:n,group:r,rows:i}of o){let a=r.toLowerCase().includes(e),o=0;for(let t of i){let n=t.querySelector(`.shortcuts-what`)?.textContent?.toLowerCase()??``;t.hidden=!(a||n.includes(e)),t.hidden||(o+=1)}n.hidden=o===0,t+=o}s.hidden=t>0};c(),i.addEventListener(`input`,()=>{n.onQuery(i.value),c()}),i.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),i.value===``?n.onClose():(i.value=``,n.onQuery(``),c()))}),e.replaceChildren(i,a),t.focus&&i.focus()}function la(e){return`${Ge(e)}${He(e)}`}function ua(e,t,n=!1){let r=C(`div`,`info-row`);r.append(C(`span`,`info-key`,e));let i=C(`span`,n?`info-value mono`:`info-value`,t);return i.title=t,r.append(i),r}function da(e,t,n,r){let i=ua(e,t,!0),a=C(`button`,`btn btn-quiet btn-icon info-copy`);a.type=`button`,a.setAttribute(`aria-label`,`Copy ${n}`),a.title=`Copy ${n}`,a.setAttribute(`data-copy`,n),a.append(S(`copy`));let o=C(`div`,`info-error`);o.setAttribute(`data-copy-error`,n),o.hidden=!0,a.addEventListener(`click`,()=>{r(t).then(()=>{o.hidden=!0,a.replaceChildren(S(`check`)),a.setAttribute(`aria-label`,`Copied`),a.title=`Copied`},e=>{o.textContent=`Couldn't copy: ${e instanceof Error?e.message:String(e)}`,o.hidden=!1})}),i.append(a);let s=C(`div`);return s.append(i,o),s}function fa(e,t,n){let r=C(`div`,`info-group`);r.setAttribute(`data-info-facts`,``);let i=`${v(t.durationMs)} · ${t.steps} ${t.steps===1?`step`:`steps`}`,a=t.aspect===`auto`?`Auto`:t.aspect;r.append(ua(`Recorded`,qi(t.recordedAt)),ua(`Site`,la(t.site)),ua(`Length`,i),ua(`Recording`,`${t.recording.width} × ${t.recording.height}`),ua(`Video`,`${t.target.width} × ${t.target.height} · ${a}`));let o=C(`div`,`info-group`);if(o.setAttribute(`data-info-ids`,``),o.append(da(`Take ID`,t.takeId,`take ID`,n.onCopy)),t.rerun.kind===`link`){let e=C(`div`,`info-row`);e.append(C(`span`,`info-key`,`Re-film`));let n=C(`a`,`info-value`,t.rerun.label);n.setAttribute(`href`,t.rerun.href),n.setAttribute(`data-runs-route`,``),e.append(n),o.append(e)}let s=[r,o];if(t.history.outputs.length>0){let e=C(`div`,`info-group info-exports`);if(e.setAttribute(`data-info-exports`,``),e.append(C(`div`,`info-label`,`Exports`)),t.revealError!==null){let n=C(`p`,`notice notice-warn`,t.revealError);n.setAttribute(`data-reveal-error`,``),e.append(n)}let r=C(`div`,`info-history`);Ui(r,t.history,n),e.append(r),s.push(e)}e.replaceChildren(...s)}var pa=.006,A=e=>`${(e*100).toFixed(4)}%`;function ma(e,t,n,r=pa){if(n<e.startMs||t>e.endMs)return null;let i=Math.max(0,k(e,t)),a=Math.min(1,k(e,n)),o=Math.max(r,a-i);return{left:Math.min(i,1-o),width:o,toScale:a-i>=r}}var ha=(e,t)=>Math.min(1,Math.max(0,k(e,t))),ga=[100,250,500,1e3,2e3,5e3,1e4,15e3,3e4,6e4],_a=(e,t)=>t>=1e3?E(e):`${E(e)}.${Math.floor(e%1e3/100)}`;function va(e,t){let n=C(`div`,`ruler`);n.setAttribute(`data-ruler`,``),n.setAttribute(`data-source`,e.timeSource);let r=(t.viewport.endMs-t.viewport.startMs)/10,i=ga.find(e=>e>=r)??Math.ceil(r/6e4)*6e4;for(let e=Math.ceil(t.viewport.startMs/i)*i;e<=t.viewport.endMs;e+=i){let r=k(t.viewport,e),a=C(`span`,`tick`,_a(e,i));a.style.left=A(r),a.dataset.fraction=String(r),n.append(a)}return ba?.observe(n),n}function ya(e){let t=e.clientWidth;if(t===0)return;let n=[...e.querySelectorAll(`.tick`)].map(e=>({tick:e,w:e.offsetWidth})),r=-1/0;for(let{tick:e,w:i}of n){let n=Number(e.dataset.fraction)*t,a=n+i>t,o=a?n-i:n,s=o<r;e.toggleAttribute(`data-crowded`,s),a?e.setAttribute(`data-edge`,`end`):e.removeAttribute(`data-edge`),s||(r=o+i)}}var ba=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>{for(let t of e){let e=t.target;e.isConnected?ya(e):ba?.unobserve(e)}});function xa(e,t){let n=C(`div`,`lane`);return n.append(e,t),n}function Sa(e,t,n){let r=C(`div`,`lane-label lane-head`),i=C(`span`,`lane-title`),a=C(`span`,`lane-glyph`);return a.append(S(t)),i.append(a,C(`span`,`lane-name`,e)),n&&i.append(n),r.append(i),r}function Ca(e){let t;if(e.failed)t=`The hover check could not run, so nothing here has been checked.`;else if(e.unchecked>0)t=`${e.unchecked} ${e.unchecked===1?`hover`:`hovers`} could not be checked.`;else return null;let n=C(`span`,`lane-flag`);return n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,t),n.title=t,n.setAttribute(`data-hover-check`,e.failed?`failed`:`unchecked`),n}var wa=3;function Ta(e,t,n,r,i){e.addEventListener(`pointerdown`,e=>{e.preventDefault(),e.stopPropagation();let a=e=>{let i=t();if(i.width===0)return n.viewport.startMs;let a=(e-i.left)/i.width,o=n.viewport.startMs+a*(n.viewport.endMs-n.viewport.startMs);return Math.min(Math.max(o,0),r)};i.onSeekStart(),i.onSeek(a(e.clientX));let o=e=>i.onSeek(a(e.clientX)),s=e=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),i.onSeek(a(e.clientX))};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)})}var Ea=(e,t)=>e!==null&&t!==null&&e.kind===t.kind&&(e.kind===`tick`?e.actionId===t.actionId:e.id===t.id),Da=(e,t)=>e.snapping?8*t:0;function Oa(e,t){let n=e.getBoundingClientRect().width;return n===0?0:(t.endMs-t.startMs)/n}function ka(e,t,n){let r=e.getBoundingClientRect(),i=r.width===0?0:(n-r.left)/r.width;return t.startMs+i*(t.endMs-t.startMs)}function Aa(e,t,n,r,i,a){e.addEventListener(`pointerdown`,o=>{o.preventDefault(),o.stopPropagation(),e.setAttribute(`data-dragging`,``);let s=o.clientX,c=!1,l=e=>{let r=Oa(t,n.viewport);return{toMs:ka(t,n.viewport,e),deltaMs:(e-s)*r,snapMs:Da(n,r)}},u=e=>{Math.abs(e.clientX-s)>wa&&(c=!0),c&&a?.move(l(e.clientX))},d=t=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),e.removeAttribute(`data-dragging`),c&&(a?.end(),i.onGesture(r(l(t.clientX))))};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)})}var ja=e=>Math.max(0,Math.min(1,e));function Ma(e,t,n,r){let i=ja(r);t.style.left=A(i);let a=e.querySelector(`[data-clip-block]`);if(a===null)return;let o=Number(a.dataset[n===`head`?`blockTail`:`blockHead`]);if(!Number.isFinite(o))return;let s=n===`head`?i:o,c=n===`head`?o:i,l=Math.min(s,c);a.style.left=A(l),a.style.width=A(Math.max(s,c)-l)}function Na(e,t,n){let r=C(`div`,`track`);r.setAttribute(`data-track`,`clip`);let{clip:i}=e;for(let e of i.degraded){let n=ma(t.viewport,e.startMs,e.endMs,0);if(n===null)continue;let i=C(`div`,`degraded`);i.setAttribute(`data-degraded`,``),i.style.left=A(n.left),i.style.width=A(n.width),r.append(i)}let a=k(t.viewport,i.trim.headMs),o=k(t.viewport,i.trim.tailMs),s=ma(t.viewport,i.trim.headMs,i.trim.tailMs);if(s!==null){let e=C(`div`,`seg`);e.setAttribute(`data-clip-block`,``),e.setAttribute(`data-kind`,`clip`),e.setAttribute(`data-to-scale`,String(s.toScale)),e.style.left=A(s.left),e.style.width=A(s.width),e.dataset.blockHead=String(s.left),e.dataset.blockTail=String(s.left+s.width),r.append(e)}for(let[e,s,c]of[[`head`,a,i.trim.headTiming],[`tail`,o,i.trim.tailTiming]]){if(s<0||s>1)continue;let i=C(`div`,`handle`);i.setAttribute(`data-trim`,e),i.setAttribute(`data-timing`,c),i.style.left=A(s),Aa(i,r,t,({toMs:t,snapMs:n})=>({kind:`trim`,edge:e,toMs:t,snapMs:n}),n,{move:({toMs:n})=>Ma(r,i,e,k(t.viewport,n)),end:()=>Ma(r,i,e,s)}),r.append(i)}for(let e of i.ticks){let a=k(t.viewport,e.atMs);if(a<0||a>1)continue;let o=C(`button`,`tick`);o.type=`button`,o.setAttribute(`data-tick`,e.actionId),o.setAttribute(`data-verb`,e.verb);let s=Ba[e.verb];s!==void 0&&o.append(S(s)),o.setAttribute(`data-timing`,e.timing),o.setAttribute(`aria-label`,`${e.verb} ${e.label}`),o.title=`${e.verb} ${e.label}`,e.timing===`estimated`&&(o.setAttribute(`data-not-in-video`,``),o.title=o.title?`${o.title} — not in the video`:`Not in the video`),e.flag&&o.setAttribute(`data-flag`,e.flag),e.cut&&o.setAttribute(`data-cut`,``);let c=String(Pa(i.ticks,e));o.setAttribute(`data-stack-index`,c),o.style.setProperty(`--tick-stack`,c),Ea(t.selection,{kind:`tick`,actionId:e.actionId})&&o.setAttribute(`data-selected`,``),o.style.left=A(a),o.addEventListener(`click`,t=>{t.stopPropagation(),n.onSelect({kind:`tick`,actionId:e.actionId})}),r.append(o)}return r}function Pa(e,t){let n=e.indexOf(t),r=0;for(let i=0;i<n;i++)e[i]?.atMs===t.atMs&&(r+=1);return r}function Fa(e,t,n,r,i,a){let o=ma(i.viewport,e.startMs,e.endMs);if(o===null)return null;let s=C(`div`,`seg`);s.setAttribute(`data-segment`,e.id),s.setAttribute(`data-kind`,t),s.setAttribute(`data-timing`,e.timing),s.setAttribute(`data-to-scale`,String(o.toScale)),s.style.left=A(o.left),s.style.width=A(o.width);let{trim:c}=r.clip;(e.endMs<=c.headMs||e.startMs>=c.tailMs)&&s.setAttribute(`data-outside-trim`,``);let l={kind:t,id:e.id};Ea(i.selection,l)&&s.setAttribute(`data-selected`,``);let u=t===`mask`&&e.wholeTake;if(t===`zoom`){let t=e;s.setAttribute(`data-authored-end`,String(t.endAuthored)),s.setAttribute(`data-clamped`,String(t.clamped)),s.append(C(`span`,`seg-label`,`${t.scale.toFixed(1)}x`))}else u&&s.setAttribute(`data-whole-take`,``),s.append(C(`span`,`seg-label`,u?`mask · whole take`:`mask`));if(s.addEventListener(`click`,e=>{e.stopPropagation(),a.onSelect(l)}),!u){let r=(e,t)=>{s.style.left=A(e),s.style.width=A(t)},c=()=>r(o.left,o.width),l=i.viewport.endMs-i.viewport.startMs;for(let l of[`start`,`end`]){let u=C(`div`,`cap`);u.setAttribute(`data-cap`,l),Aa(u,n,i,({toMs:n,snapMs:r})=>t===`zoom`?{kind:`zoomEdge`,id:e.id,edge:l,toMs:n,snapMs:r}:{kind:`maskEdge`,id:e.id,edge:l,toMs:n,snapMs:r},a,{move:({toMs:e})=>{let t=ja(k(i.viewport,e)),n=o.left+o.width;if(l===`start`){let e=Math.min(t,n);r(e,n-e)}else r(o.left,Math.max(t,o.left)-o.left)},end:c}),s.append(u)}Aa(s,n,i,({deltaMs:n,snapMs:r})=>t===`zoom`?{kind:`moveZoom`,id:e.id,deltaMs:n,snapMs:r}:{kind:`moveMask`,id:e.id,deltaMs:n,snapMs:r},a,{move:({deltaMs:e})=>{let t=l===0?0:e/l;r(Math.max(0,Math.min(1-o.width,o.left+t)),o.width)},end:c})}return s}function Ia(e,t,n,r){let i=C(`div`,`track`);i.setAttribute(`data-track`,e);let a=e===`zoom`?t.zooms:t.masks;for(let o of a){let a=Fa(o,e,i,t,n,r);a&&i.append(a)}return i.addEventListener(`click`,a=>{if(a.target!==i)return;let o=Oa(i,n.viewport);r.onGesture({kind:e===`zoom`?`addZoom`:`addMask`,atMs:La(e,t,ka(i,n.viewport,a.clientX)),snapMs:Da(n,o)})}),za(i,e,t,n),i}function La(e,t,n){let r=(e===`zoom`?t.zoomDefaultMs:tn)/2;return Math.max(0,Math.min(t.durationMs,n-r))}function Ra(e,t,n){let r=e===`zoom`?fn(t,n):pn(t,n);return nn(r)?null:{startMs:r.startMs,endMs:r.endMs}}function za(e,t,n,r){let i=null,a=()=>{i?.remove(),i=null};e.addEventListener(`pointermove`,o=>{if(o.target!==e)return a();let s=Ra(t,n,La(t,n,ka(e,r.viewport,o.clientX))),c=s&&ma(r.viewport,s.startMs,s.endMs);if(c===null)return a();i===null&&(i=C(`div`,`seg`),i.setAttribute(`data-ghost`,t),i.setAttribute(`aria-hidden`,`true`),e.append(i)),i.style.left=A(c.left),i.style.width=A(c.width)}),e.addEventListener(`pointerleave`,a)}var Ba={click:`mousePointerClick`,type:`type`,moveTo:`mousePointer2`,scrollTo:`moveVertical`,waitFor:`hourglass`};function Va(e,t,n,r){let i=C(`div`,`timeline`);if(i.addEventListener(`click`,e=>{e.target?.closest(`[data-ruler], [data-trim], [data-playhead], [data-track="zoom"], [data-track="mask"], button`)||r.onSelect(null)}),t.timeSource===`captured`){let e=C(`p`,`muted`);he(e,t.rerunLine===null?`Timing from the take, not from a render — ${pt(t.authored)} to see the timing this demo will actually have.`:`Timing from the take, not from a render. ${t.rerunLine}`),i.append(e)}let a=va(t,n);Ta(a,()=>a.getBoundingClientRect(),n,t.durationMs,r);let o=C(`div`,`lanes`);o.append(xa(C(`b`,`lane-label`),a));let s=C(`div`,`axis`);s.setAttribute(`data-axis`,``),i.addEventListener(`wheel`,e=>{let i=s.getBoundingClientRect();if(i.width===0)return;if(e.ctrlKey||e.metaKey){e.preventDefault();let a=(e.clientX-i.left)/i.width;r.onViewport(Jr(n.viewport,t.durationMs,e.deltaY<0?1.2:1/1.2,a));return}let a=e.shiftKey?e.deltaY:e.deltaX;if(a===0)return;e.preventDefault();let o=n.viewport.endMs-n.viewport.startMs;r.onViewport(Yr(n.viewport,t.durationMs,a/i.width*o))});let c=Sa(`Clip`,`film`),l=Ca(t.hoverCheck);l!==null&&c.querySelector(`.lane-glyph`)?.append(l);let u=xa(c,Na(t,n,r));u.setAttribute(`data-lane`,`clip`),o.append(u);let d=xa(Sa(`Zoom`,`zoomIn`),Ia(`zoom`,t,n,r));d.setAttribute(`data-lane`,`zoom`),o.append(d);let f=C(`button`,`btn btn-quiet btn-icon lane-add`);f.type=`button`,f.setAttribute(`data-add-mask`,``),f.setAttribute(`aria-label`,`Add a mask at the playhead`),f.title=`Add a mask at the playhead`,f.append(S(`plus`)),f.onclick=()=>{let e=i.querySelector(`[data-track="clip"]`),t=e?Oa(e,n.viewport):0;r.onGesture({kind:`addMask`,atMs:n.positionMs,snapMs:Da(n,t)})};let p=xa(Sa(`Mask`,`eyeOff`,f),Ia(`mask`,t,n,r));p.setAttribute(`data-lane`,`mask`),o.append(p);let m=C(`div`,`playhead`);m.setAttribute(`data-playhead`,``),m.style.left=A(ha(n.viewport,n.positionMs));let h=C(`div`,`grab`);h.setAttribute(`data-playhead-grab`,``),h.setAttribute(`aria-hidden`,`true`),Ta(h,()=>s.getBoundingClientRect(),n,t.durationMs,r),m.append(h),s.append(m),o.append(s),i.append(o);let g=C(`p`,`refusal`);he(g,n.refusal??``),g.setAttribute(`data-refusal`,``),g.hidden=n.refusal===null,i.append(g);let _=e.ownerDocument.activeElement,v=_ instanceof HTMLElement&&e.contains(_)&&_.matches(`[data-lane="mask"] [data-add-mask]`);e.replaceChildren(i),v&&f.focus()}function Ha(e){let t=C(`button`,`btn btn-quiet btn-icon tool`);return t.type=`button`,t.append(S(e)),t}function Ua(e,t){e.setAttribute(`aria-label`,t),e.title=t}var Wa=new WeakMap;function Ga(){let e=C(`div`,`bar-controls`);e.setAttribute(`data-timeline-tools`,`view`);let t=Ha(`magnet`);t.classList.add(`snap`);let n=Ha(`moveHorizontal`);n.classList.add(`fit`),n.setAttribute(`data-fit`,``);let r=C(`div`,`zoom-control`);r.setAttribute(`data-zoom-control`,``);let i=C(`input`);i.setAttribute(`aria-label`,`Timeline zoom`),i.type=`range`,i.min=`0`,i.max=`1`,i.step=`0.001`,i.setAttribute(`data-zoom-slider`,``);let a=Ha(`zoomOut`);a.classList.add(`zoom-step`),a.setAttribute(`data-zoom-step`,`out`),Ua(a,`Zoom out (−)`);let o=Ha(`zoomIn`);return o.classList.add(`zoom-step`),o.setAttribute(`data-zoom-step`,`in`),Ua(o,`Zoom in (+)`),r.append(a,i,o),e.append(t,n,r),{view:e,snap:t,fit:n,zoom:i,zoomOut:a,zoomIn:o}}function Ka(e,t,n,r){let i=Wa.get(e);(i===void 0||i.view.parentElement!==e)&&(i=Ga(),Wa.set(e,i),e.replaceChildren(i.view));let{snap:a,fit:o,zoom:s,zoomOut:c,zoomIn:l}=i;Ua(a,n.snapping?`Snapping on — drags land on the nearest step (S)`:`Snapping off — drags land where you drop them (S)`),a.setAttribute(`data-snap`,n.snapping?`on`:`off`),a.setAttribute(`aria-pressed`,n.snapping?`true`:`false`),a.onclick=()=>r.onSnapping(!n.snapping);let u=Gr(t.durationMs),d=n.viewport.startMs===u.startMs&&n.viewport.endMs===u.endMs;Ua(o,d?`The whole take is already in view (⇧Z)`:`Fit the whole take (⇧Z)`),o.disabled=d,o.onclick=()=>r.onViewport(u);let f=n.viewport.endMs-n.viewport.startMs,p=Qr(t.durationMs,f);s.value=String(p),s.style.setProperty(`--fill`,`${(p*100).toFixed(2)}%`);let m=t.durationMs>250;s.disabled=!m,s.title=m?`Zoom the timeline (⌘-scroll, ⇧Z to fit)`:`This take is too short to zoom into.`,s.oninput=()=>{let e=Zr(t.durationMs,Number(s.value)),i=k(n.viewport,n.positionMs);r.onViewport(Xr(n.viewport,t.durationMs,e,i>=0&&i<=1?i:.5))};let h=e=>{let i=Math.min(1,Math.max(0,k(n.viewport,n.positionMs)));r.onViewport(Jr(n.viewport,t.durationMs,e,i))};c.disabled=!m||p<=5e-4,c.onclick=()=>h(1/Tr),l.disabled=!m||p>=.9995,l.onclick=()=>h(Tr)}var j=ae();j.theme!==void 0&&de(j.theme,document.documentElement,`editor`);function M(e){console.error(`demoman editor:`,e)}var qa=j.kits,N={state:`ready`,kits:[],defaultId:null,migrationPending:!1},Ja=null,Ya=null;function Xa(e){let t=N;if(t.state!==`ready`)return null;let n=t.kits.filter(e=>e.read.state===`ready`),r=n.filter(t=>t.read.state===`ready`&&Ae(t.read.kit,e)),i=r.find(e=>e.id===Ja)??r.find(e=>e.id===t.defaultId)??r[0];if(i!==void 0)return Ja=i.id,{kit:i,edited:!1};let a=n.find(e=>e.id===Ja);return a===void 0?null:{kit:a,edited:!0}}var Za=j.bundles,Qa=new URL(location.href).searchParams.get(`scene`)??``,P=e=>{let t=document.getElementById(e);if(!t)throw Error(`editor is missing #${e}`);return t},$a=null,eo=!1,F=wr({sceneId:Qa,loadScene:async e=>{let t=await j.scenes.get(e);if(t===null)throw Error(`no scene "${e}"`);return eo||=($a=t.revision,!0),t.scene},saveScene:async e=>{$a=(await j.scenes.put(e,$a)).revision},bundles:{active:e=>Za.active(e)},newId:()=>crypto.randomUUID()});function I(e){let t=F.snapshot().scene;return F.dispatch(e).catch(M).then(()=>to(t))}function to(e){if(Ao===null)return;let t=F.snapshot();t.scene!==e&&t.error===null&&(Ao=null,$(t))}async function no(e){let t=e.hoverReport?.removable??[];so=null;for(let e of t){let t=xn(F.snapshot().scene,F.snapshot().bundle,e);t===null||nn(t)||await I(t)}let n=F.snapshot().scene,r=new Set(n.actions.map(e=>e.id)),i=new Set((n.edits.cuts??[]).map(e=>e.actionId)),a=t.filter(e=>r.has(e)&&!i.has(e));a.length>0&&(so=`${a.length} of ${t.length} removal${t.length===1?``:`s`} did not go through — ${a.length===1?`it is`:`they are`} still in this take.`),$(F.snapshot())}var L={phase:`idle`},ro=null,R=null,io=null,z=null,ao=!1;function oo(e){e!==z&&(ao=!1),z=e}var so=null,B=null,co=null,lo=[],uo=null,fo=null,po=null,V=null,H=`export`,U=!0,mo=`export`,ho=qn(),W=`mp4`;function go(e){let t=F.snapshot().scene;return Se(W,t.canvas.aspect,e,Te({...t,branding:ys(t)}),_o===null?{}:{quality:_o})}var _o=j.exportQuality===void 0?null:`share`,vo=null;function yo(e){return vo?.scene!==e&&(vo={scene:e,digest:bt(e)}),vo.digest}var bo=`fit`;function xo(e){e===null?H===`selection`&&(H=mo):(H!==`selection`&&(mo=H),H=`selection`,U=!0),V=e}var So=null,Co=null,wo=0,G=null,To=!0,Eo=!1,Do=``,Oo=!1,ko=null,Ao=null,jo=[];function Mo(){return jo.flatMap(e=>e.kind===`stored`?[e.output]:[])}var No=!1,Po=new Set,K=jn(ve),q=null,J=null,Fo=P(`preview`),Io=new OffscreenCanvas(K.width,K.height),Lo=Io.getContext(`2d`);function Ro(e){let t=go(e),n=Xs(e,P(`stage-frame`).getBoundingClientRect().width),r=n.width!==K.width||n.height!==K.height;K=n,r&&(Io=new OffscreenCanvas(K.width,K.height),Lo=Io.getContext(`2d`)),q=null;let i=P(`stage`);i.style.setProperty(`--frame-ratio`,`${t.width} / ${t.height}`),i.style.setProperty(`--frame-px`,String(jn(t).width))}var zo=150,Bo=null,Vo=!1,Ho=!1;document.addEventListener(`pointerdown`,()=>{Vo=!0},!0);var Uo=()=>{Vo=!1,Ho&&setTimeout(()=>{Ho&&!Vo&&$(F.snapshot())},0)};window.addEventListener(`pointerup`,Uo,!0),window.addEventListener(`pointercancel`,Uo,!0);var Wo=new ResizeObserver(()=>{let e=P(`stage`),t=P(`stage-frame`).getBoundingClientRect(),n=e.getBoundingClientRect();e.style.setProperty(`--bar-w`,`${t.width}px`),e.style.setProperty(`--bar-lift`,`${Math.max(0,n.bottom-t.bottom)}px`),zc&&(Bo!==null&&clearTimeout(Bo),Bo=setTimeout(()=>{Bo=null;let e=Xs(F.snapshot().bundle,P(`stage-frame`).getBoundingClientRect().width);(e.width!==K.width||e.height!==K.height)&&(Vo&&(vs!==null||gs!==null)?(Ms(),Ho=!0):$(F.snapshot()))},zo))});Wo.observe(P(`stage-frame`)),Wo.observe(P(`stage`));var Go=[],Ko=null,qo=new Map,Jo=[],Yo=null,Xo=null,Zo=[];async function Qo(e,t){let{bundle:n,scene:r}=e;if(n===null||t===null){qo.size>0&&(qo=new Map,Xo=null,$(F.snapshot()));return}let i=Ot(r);if(kt(Xo,n,r)||At(Zo,n,r))return;let a={bundle:n,cuts:i};Zo.push(a);let o=new Map;for(let e of t.timeline.unplacedCuts){let t=Et(n,e.actionIds)?{kind:`leftOut`}:{kind:`unplaced`,reason:e.reason};for(let n of e.actionIds)o.set(n,t)}let s=t.timeline.cuts.filter(e=>{if(!e.trailing)return!0;for(let t of e.actionIds)o.set(t,{kind:`trailing`});return!1}),c=()=>{let e=F.snapshot();return e.bundle===n&&Ot(e.scene)===i},l=()=>{c()&&(qo=o,Xo={bundle:n,cuts:i},console.info(`[demoman] editor: cuts — ${t.timeline.cuts.length+t.timeline.unplacedCuts.length===0?`none`:[...t.timeline.cuts.map(e=>`${e.actionIds.join(`+`)} removed ${Math.round(e.srcStartMs)}-${Math.round(e.srcEndMs)}ms${e.trailing?` (trailing)`:``}${e.keepJump?` (jump kept)`:``}: ${o.get(e.actionIds[0]??``)?.kind??`pending`}`),...t.timeline.unplacedCuts.map(e=>Et(n,e.actionIds)?`${e.actionIds.join(`+`)} left out by the rebuild`:`${e.actionIds.join(`+`)} removed nothing: ${e.reason}`)].join(`; `)}`),$(F.snapshot()))};try{if(s.length>0){let e=t.plan.retiming.motionDiffThreshold,r;try{r=await os(n)}catch(e){M(e);let t=e instanceof Error?e.message:String(e);for(let e of s)for(let n of e.actionIds)o.set(n,{kind:`unknown`,reason:t});l();return}for(let t of s){let i=await $e({frames:r,bundle:n,range:t,threshold:e});for(let e of t.actionIds)o.set(e,i)}}l()}finally{let e=Zo.indexOf(a);e!==-1&&Zo.splice(e,1)}}var $o=null,es=0,ts=null,ns=[],rs=[],is={overlays:[],unshown:[]};function as(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!==void 0&&e.actionId===r.actionId&&e.anchorId===r.anchorId&&e.text===r.text})}var os=In(e=>e.motionSpans.length>0?d(e,Za.load,{onSpanUnavailable:(e,t)=>console.info(`[demoman] preview: span ${e} could not be decoded (${t})`)}):Promise.resolve(i(e,Za.load)));async function ss(e){let{bundle:t,scene:n}=e;if(t===null||Tt(Ko,e))return;Ko=wt({scene:n,bundle:t}),Go=[];let r=a(n).retiming.motionDiffThreshold,i=()=>{let e=F.snapshot();return e.scene===n&&e.bundle===t},o;try{o=await os(t),Go=await _e(t,o,r)}catch(e){M(e),i()&&F.setHoverReport(Cn),$(F.snapshot());return}try{let e=await Ze(n,t,o,r);if(i()){let t=new Set((F.snapshot().scene.edits.cuts??[]).map(e=>e.actionId));F.setHoverReport(Tn(e,t))}}catch(e){M(e),i()&&F.setHoverReport(Cn)}$(F.snapshot())}var cs=null,ls=null,us=null,Y=null,ds=``,fs=null,ps=null,ms=null,hs=null,gs=null,_s=null,vs=null;function ys(e){let t=Me(vs,e,M);return vs=t.preview,t.branding}function bs(e){vs={patch:e,scene:F.snapshot().scene},Ms();let t=F.snapshot();Ss(t,go(t.bundle))}function xs(e){io!==null&&(io=null,$(F.snapshot())),j.files.reveal(e).catch(e=>{let t=Kn(e);t.expected?console.info(`demoman editor: ${t.text}`):M(e),io=t.text,$(F.snapshot())})}function Ss(e,t){let n=Oe({durationMs:Js-Z,fileType:W,target:t,hasFrames:sc(e).kind!==`noFrames`}),r=P(`take-meta`);r.textContent=n,r.setAttribute(`aria-label`,`Take info: ${n}`)}var Cs=null;function ws(e){return gs===null?e.cursor:{...e.cursor,...gs}}function Ts(e){let t=e.motion??ge;return _s===null?t:{...t,..._s}}var Es=null,Ds=null;function Os(e){gs=e,Ms()}function ks(e){_s=e,Ms()}function As(){_s!==null&&(_s=null,Ms())}function js(){gs!==null&&(gs=null,Ms())}function Ms(){Ds===null&&(Ds=requestAnimationFrame(()=>{Ds=null;let e=F.snapshot();Is(e),J&&(Cs=ws(e.scene),Es=Ts(e.scene),ts=q,Q.seek(Q.positionMs))}))}function Ns(){Ds!==null&&cancelAnimationFrame(Ds),Ds=null,gs=null,_s=null}function Ps(e){return e===null?null:fs?.ref===e?fs.thumb:{kind:`loading`}}async function Fs(e){let t=ys(e.scene),n=t.logo?.ref??null;if(n!==ls&&(ls=n,us=null,Y=null,cs=null,ds=``,n!==null)){let e=await j.logos.load(n);if(ls!==n)return;e.ok?us=e.source:Y=e.error}let r=xe(t,K),i=`${n}@${r}`;if(us!==null&&r>0&&i!==ds){ds=i;try{let e=await us.rasterAt(r);if(ls!==n||ds!==i)return;cs=e,Y=null}catch(e){cs=null,Y=e instanceof Error?e.message:String(e)}}let a=null;if(n!==null){if(us!==null){try{a={kind:`ready`,url:await ke(us)}}catch(e){a={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(ls!==n)return}else a=Y===null?{kind:`loading`}:{kind:`failed`,reason:Y}}let o=JSON.stringify(a)!==JSON.stringify(fs?.thumb??null)||(fs?.ref??null)!==n;fs=n===null?null:{ref:n,thumb:a};let s=us?Ce(us,xe(t,go(e.bundle)),je(W,e.scene.canvas.aspect)):null,c=[hs?.ref===n?hs.note:null,s].filter(e=>e!==null),l=o||cs!==ps||Y!==ms||c.join(`
|
|
3
|
-
`)!==lo.join(`
|
|
4
|
-
`);lo=c,ps=cs,ms=Y,l&&$(F.snapshot())}function Is(e){Ro(e.bundle);let{scene:t,bundle:n}=e,r=Ln(t,{cursor:ws(t),branding:ys(t),motion:_s===null?t.motion:Ts(t)});is=gt(r,e.madeFrom,e.bundle!==null),rs=is.overlays;let i=n?ye({plan:a(r,{retexts:rs}),bundle:n,scene:r,target:K,detailTarget:go(n),hints:Go,logo:cs}):null;J=i?.resolved??null,q=i?.presentation??null,Fo.width!==K.width&&(Fo.width=K.width),Fo.height!==K.height&&(Fo.height=K.height)}var Ls=[];function Rs(e,t){let n=t.width*t.height/1e6;n<=0||(Ls.push(e/n),Ls.length>60&&Ls.splice(0,Ls.length-30))}var zs=null,Bs=!1,X={requestedFrames:0,drawnFrames:0,elapsedMs:0,sourceLookupMs:0,composeMs:0,blitMs:0},Vs=0,Hs=null,Us=0,Ws=0;function Gs(){X.requestedFrames=0,X.drawnFrames=0,X.elapsedMs=0,X.sourceLookupMs=0,X.composeMs=0,X.blitMs=0,Us=0,Ws=0,Vs=performance.now()}function Ks(){if(Q.playing===Bs)return;if(Bs=Q.playing,$(F.snapshot()),Bs){Hs={width:K.width,height:K.height},Gs();return}X.elapsedMs=performance.now()-Vs;let e=(F.snapshot().bundle?.keyframes??[]).reduce((e,t)=>e===null||t.width*t.height>e.width*e.height?{width:t.width,height:t.height}:e,null);console.info(Nn({...X,...e===null?{}:{sourceFrame:e},...Hs===null?{}:{bitmap:Hs},parkedHeight:K.height,msPerMegapixel:kn(Ls),...Ws>0?{decodeMs:Us}:{}}))}var qs=Pn({schedule:e=>requestAnimationFrame(e),onDrawFailed:e=>{oo(e instanceof Error?e.message:String(e)),Q.pause(),$(F.snapshot())},onDrawRecovered:()=>{z!==null&&(z=null,$(F.snapshot()))},draw:async e=>{let t=F.snapshot(),n={resolved:J,presentation:q,target:K,offscreen:Io,offscreenCtx:Lo};if(!n.resolved||!n.presentation||!t.bundle)return;let r=performance.now(),i=await os(t.bundle),a=performance.now();await c({resolved:n.resolved,target:n.target,presentation:n.presentation,frames:i,ctx:n.offscreenCtx,outputTimeMs:e,onStage:Bs?(e,t)=>{e===`fetch`&&(Us+=t,Ws+=1)}:void 0});let o=performance.now();n.offscreen===Io&&(Rs(o-a,n.target),Fo.getContext(`2d`)?.drawImage(Io,0,0),So&&(V?.kind===`mask`||V?.kind===`zoom`)&&Hr(P(`stage-overlay`),{canvas:Fo,selection:V,model:So,resolved:n.resolved,presentation:n.presentation,target:n.target,outputTimeMs:e},{onMaskRect:(e,t)=>I({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>I({kind:`setZoomTarget`,id:e,point:t})}),Bs&&(X.drawnFrames+=1,X.sourceLookupMs+=a-r,X.composeMs+=o-a,X.blitMs+=performance.now()-o))}}),Z=0,Js=0,Ys=!1,Q=Fn({seek:e=>{Bs&&(X.requestedFrames+=1),qs.seek(e)},durationMs:()=>Ys?Js:0,startMs:()=>Z,looping:()=>Eo,now:()=>performance.now(),schedule:e=>requestAnimationFrame(e),onChange:()=>{Ks(),$s()}});function Xs(e,t){let n=go(e),r=()=>An({target:n,paintedCssWidth:t,devicePixelRatio:window.devicePixelRatio,playing:Q.playing,msPerMegapixel:kn(Ls)});return Q.playing?(zs??=r(),jn(n,zs)):(zs=null,jn(n,r()))}function Zs(e){e!==F.snapshot().scene.canvas.aspect&&I({kind:`setAspect`,aspect:e}).then(()=>Q.seek(Q.positionMs))}function Qs(e){if(e===W)return;let t=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-file-type`);W=e,$(F.snapshot()),t&&document.querySelector(`[data-file-type="${e}"]`)?.focus(),Q.seek(Q.positionMs)}console.info(`demoman editor: panel transition "${getComputedStyle(document.body).transitionProperty}"`),document.body.addEventListener(`transitionend`,e=>{e.target===document.body&&e.propertyName===`grid-template-columns`&&(V?.kind===`mask`||V?.kind===`zoom`)&&Q.seek(Q.positionMs)});function $s(){ta(P(`transport`),{authored:ft(F.snapshot().scene),rerunLine:zt(cc(F.snapshot())),playing:Q.playing,enabled:Ys&&Js>Z,rate:Q.rate,looping:Eo},{onToggle:ec,onSkipToStart:()=>Ic({kind:`seekEdge`,edge:`head`},F.snapshot()),onLooping:e=>{Eo=e,$s()},onShuttle:e=>{z=null,Q.shuttle(e)}});for(let[e,t]of[[P(`stage-tools`),P(`toolbar-clock`)],[P(`stage-bar`),P(`stage-bar`)]])na(e,{authored:ft(F.snapshot().scene),rerunLine:zt(cc(F.snapshot())),positionMs:Q.positionMs-Z,durationMs:Js-Z,aspect:F.snapshot().scene.canvas.aspect,enabled:Ys&&Js>Z,fullscreen:!!document.fullscreenElement,error:ao?null:z,zoom:bo},{onAspect:Zs,onFullscreen:nc,onZoom:tc,onDismissError:()=>{ao=!0,$s()}},t);let e=P(`timeline`).querySelector(`[data-playhead]`);e&&G&&(e.style.left=`${(ha(G,Q.positionMs)*100).toFixed(4)}%`)}function ec(){z=null,Q.toggle(),$(F.snapshot())}function tc(){bo=bo===`fit`?`actual`:`fit`,document.body.dataset.zoom=bo,$s()}function nc(){z=null;let e=!document.fullscreenElement;(e?P(`stage`).requestFullscreen():document.exitFullscreen()).catch(t=>{oo(`The preview could not ${e?`go full screen`:`exit full screen`}: ${t instanceof Error?t.message:String(t)}`),$(F.snapshot())})}document.addEventListener(`fullscreenchange`,()=>{let e=document.activeElement;z=null,$s();let t=!!document.fullscreenElement;P(`stage`).toggleAttribute(`data-fullscreen`,t);let n=P(t?`stage-tools`:`stage-bar`),r=P(t?`stage-bar`:`stage-tools`);if(e!==null&&e===n.querySelector(`[data-stage-fullscreen]`)){let e=r.querySelector(`[data-stage-fullscreen]`);e?e.focus():console.warn(`demoman editor: no full-screen button in #${r.id} to take the focus; it stays on a control that is no longer shown`)}});function rc(e){if(e!==null){if(nn(e)){Ao=e.reason,$(F.snapshot());return}I(e)}}function ic(e){let t=e.kind===`removeZoom`?`zoom`:`mask`,n=t=>e.kind===`removeZoom`?t.camera.some(t=>t.id===e.id):t.edits.masks.some(t=>t.id===e.id);I(e).then(()=>{let r=F.snapshot();n(r.scene)||V?.kind===t&&V.id===e.id&&(xo(null),$(r))})}function ac(e){let t=xn(F.snapshot().scene,F.snapshot().bundle,e);if(t===null||nn(t)){rc(t);return}let n=t.kind===`deleteAction`;I(t).then(()=>{let t=F.snapshot();n&&(t.scene.actions.some(t=>t.id===e)||V?.kind===`tick`&&V.actionId===e&&(xo(null),$(t)))})}function oc(e){if(M(e),uo=e instanceof Error?e.message:String(e),zc){$(F.snapshot());return}wi(P(`failure`),{error:null,replaySentence:null,captureSentence:null,openError:uo})}function sc(e){return e.bundle===null?{kind:`noFrames`}:{kind:`exact`}}function cc(e){let t=ft(e.scene);return{takeId:Qa,authored:t,rerun:j.nav.rerun(Qa,t)}}function lc(e){let t=`[demoman] editor: replacement exposures — `;return e.length===0?`${t}none`:`${t}${e.map(e=>`${e.replacementId} ${e.cause}${e.atMs===null?` (unplaced)`:` at ${Math.round(e.atMs)}ms`}`).join(`; `)}`}function $(e){Ho=!1,Ns(),Is(e),Jo=Un(e.scene,J,e.bundle);let t=lc(Jo);t!==Yo&&(Yo=t,console.info(t));let n=Ur({scene:e.scene,bundle:e.bundle,resolved:J}),r=P(`name`);r.value=e.scene.meta.name,r.placeholder=We(e.scene.meta),P(`undo`).disabled=!e.canUndo,P(`redo`).disabled=!e.canRedo,xi(P(`banner`),{hasFrames:e.bundle!==null,route:cc(e)}),B!==null&&e.scene!==co&&(B=null),wi(P(`failure`),{error:e.error??B,replaySentence:e.replaySentence,replayRecoverable:e.replayRecoverable,captureSentence:e.captureSentence,renderError:R,previewError:z,hoverRemovalError:so,logoLoadError:Y,openError:uo,deleteError:fo,navigationError:po,runsRoute:cc(e)}),yi(P(`report`),e.report);let i=Jt({scene:e.scene,view:n,bundle:e.bundle,resolved:J,hoverReport:e.hoverReport,rerunLine:zt(cc(e))});So=i,Co=n,wo=i.durationMs,(G===null||ko!==i.durationMs)&&(G=Gr(i.durationMs),ko=i.durationMs);let a={resolved:J,bundle:e.bundle,viewport:e.scene.meta.capture.viewport},o=e=>rc(vn(i,n,e,a)),s=e=>{G=e,$(F.snapshot())},c=e=>{To=e,$(F.snapshot())};Va(P(`timeline`),i,{viewport:G,selection:V,get positionMs(){return Q.positionMs},refusal:Ao,hoverReport:e.hoverReport,snapping:To},{onSelect:e=>{xo(e),$(F.snapshot())},onSeek:e=>Q.seek(e),onSeekStart:()=>Q.pause(),onGesture:o,onViewport:s,onSnapping:c}),bi(P(`take-notes`),{notices:i.notices,hoverReport:e.hoverReport},{onRemoveStillHovers:()=>no(F.snapshot()).catch(M)}),Ka(P(`timeline-tools`),i,{viewport:G,snapping:To,get positionMs(){return Q.positionMs}},{onGesture:o,onViewport:s,onSnapping:c});let l=V,u=l?.kind===`tick`&&n.beats.some(e=>e.actionId===l.actionId)||l?.kind===`zoom`&&i.zooms.some(e=>e.id===l.id)||l?.kind===`mask`&&i.masks.some(e=>e.id===l.id);H===`selection`&&!u&&(V===null&&M(Error(`the rail was on Selection with nothing selected`)),xo(null)),document.body.dataset.panel=U?`open`:`closed`,mi(P(`rail`),{rail:H,panelOpen:U,hasSelection:u},{onPick:Lc}),hi(P(`export-open`),{rail:H,panelOpen:U},{onPick:Lc}),gi(P(`shortcuts-open`),{rail:H,panelOpen:U},{onPick:Lc});let d=document.activeElement?.matches(`[data-shortcuts-search]`)===!0;di(P(`inspector`),{selection:V,view:n,model:i,scene:e.scene,hoverReport:e.hoverReport,viewport:e.scene.meta.capture.viewport,rail:H,sections:ho,cutStatus:qo,attachedToCuts:J?.plan.attachedToCuts??[],replacementExposures:Jo,retextUnshown:yt(is,J?.clampedRanges??[],(J?.cosmetics??[]).map(e=>e.id))},{onClose:Rc,onRetext:(e,t)=>I({kind:`retext`,actionId:e,text:t}),onDelete:ac,onTrimFrom:e=>I({kind:`trimFrom`,actionId:e}),onGap:(e,t)=>rc(yn(n,e,t)),onGapClear:e=>I({kind:`clearGap`,afterActionId:e}),onKeepHover:uc,onZoomOnStep:e=>{let t=n.beats.find(t=>t.actionId===e);if(!t?.anchorId)return;let r=new Set(F.snapshot().scene.camera.map(e=>e.id));I({kind:`addZoom`,marker:{actionId:e,offsetMs:0},target:{kind:`element`,anchorId:t.anchorId},scale:h.defaultZoomScale}).then(()=>{let e=F.snapshot().scene.camera.find(e=>!r.has(e.id));e&&(xo({kind:`zoom`,id:e.id}),$(F.snapshot()))})},onZoomScale:(e,t)=>I({kind:`setZoomScale`,id:e,scale:t}),onRemoveZoom:e=>ic({kind:`removeZoom`,id:e}),onMaskNote:(e,t)=>I({kind:`setMaskNote`,id:e,note:t}),onRemoveMask:e=>ic({kind:`removeMask`,id:e}),onReplace:(e,t)=>{let n=F.snapshot().scene.edits.replacements.find(t=>t.targetAnchorId===e);I(n?{kind:`editReplacement`,id:n.id,replace:t}:{kind:`addReplacement`,targetAnchorId:e,find:null,replace:t})},onReplaceClear:e=>{let t=F.snapshot().scene.edits.replacements.find(t=>t.targetAnchorId===e);t&&I({kind:`removeReplacement`,id:t.id})},onUncut:e=>void I({kind:`uncutStep`,actionId:e})});let f=document.querySelector(`#inspector [data-panel-shortcuts]`);f!==null&&ca(f,{mac:Pr(navigator.userAgent),query:Do,focus:U&&(Oo||d)},{onClose:Rc,onQuery:e=>{Do=e}}),Oo=!1,Hr(P(`stage-overlay`),{canvas:Fo,selection:V,model:i,resolved:J,presentation:q,target:K,outputTimeMs:Q.positionMs},{onMaskRect:(e,t)=>I({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>I({kind:`setZoomTarget`,id:e,point:t})});let p=P(`inspector`);p.querySelector(`.inspector`)===null&&M(Error(`the inspector has not rendered anything`));let m={export:`export`,branding:`background`,cursor:`cursor`},g=e=>{let t=p.querySelector(`[data-panel-${e}]`);return t===null&&H===m[e]&&U&&M(Error(`the inspector's ${e} panel is missing`)),t},_=g(`branding`);_&&Ti(_,{branding:e.scene.branding,logoThumb:Ps(e.scene.branding.logo?.ref??null),logoPlacement:q?.logoPlacement??null,formatTitle:je(W,e.scene.canvas.aspect),logoNotes:lo,kit:{read:N,standing:Xa(e.scene.branding),naming:Ya,onApply:e=>{let t=N.state===`ready`?N.kits.find(t=>t.id===e):void 0;if(t?.read.state!==`ready`){B=t===void 0?`That brand kit was not applied: it was deleted in another tab.`:`That brand kit was not applied: ${t.read.reason}.`,co=F.snapshot().scene,$(F.snapshot());return}Ja=e;let{background:n,logo:r,padding:i}=t.read.kit;I({kind:`setBranding`,patch:{background:n,logo:r,padding:i}}),$(F.snapshot())},onUpdate:()=>void fc(),onStartNew:()=>{Ya={text:``,error:null},$(F.snapshot())},onNameInput:e=>{Ya!==null&&(Ya={text:e,error:null})},onConfirmNew:e=>void pc(e),onCancelNew:()=>{Ya=null,$(F.snapshot())}}},{onCommit:e=>I({kind:`setBranding`,patch:e}),onPreview:bs,onLogoFile:e=>dc(e).catch(M)});let v=g(`cursor`);v&&Ri(v,ws(e.scene),Ts(e.scene),{onCursor:e=>{Ns(),I({kind:`setCursor`,patch:e})},onCursorPreview:Os,onCursorPreviewEnd:js,onMotion:e=>{Ns(),I({kind:`setMotion`,patch:e})},onMotionPreview:ks,onMotionPreviewEnd:As},e.scene.meta.capture.device?.touch===!0);let y=go(e.bundle),b=g(`export`);b&&Hi(b,{outputs:jo,fileType:W,aspect:e.scene.canvas.aspect,target:y,recording:Ve(e.bundle,Te(e.scene)),durationMs:i.clip.trim.tailMs-i.clip.trim.headMs,run:L,save:ro,revealError:io,readiness:sc(e),runsRoute:cc(e),replacementExposures:Jo,currentDigest:yo(e.scene),sections:ho,beatAt:It(n.beats),hasReclaimedMotion:e.bundle?.degradations.some(e=>e.kind===`motionReclaimed`)??!1},{onExport:()=>mc().catch(M),onFileType:Qs,onSaveAgain:e=>hc(e).catch(M),onReveal:xs}),Ys=n.hasBundle,Z=i.clip.trim.headMs,Js=i.clip.trim.tailMs,Ss(e,y),fa(P(`take-info`),{recordedAt:e.scene.meta.createdAt,site:e.scene.meta.capture.originUrl,durationMs:i.clip.trim.tailMs-i.clip.trim.headMs,steps:n.beats.length,recording:Ve(e.bundle,Te(e.scene)),target:y,aspect:e.scene.canvas.aspect,takeId:Qa,rerun:cc(e).rerun,revealError:io,history:{outputs:jo,currentDigest:yo(e.scene),showAll:No,warningsOpen:Po,reportContext:{beatAt:It(n.beats),runsRoute:cc(e)}}},{onCopy:e=>navigator.clipboard.writeText(e),onDownload:e=>hc([e]).catch(M),onReveal:xs,onShowAll:()=>{No=!0,$(F.snapshot())},onWarnings:e=>{Po.delete(e)||Po.add(e),$(F.snapshot()),document.querySelector(`#take-info [data-output-warnings="${CSS.escape(e)}"]`)?.focus()}}),Q.positionMs<Z&&Q.seek(Z),Q.positionMs>Js&&Q.seek(Js),$s();let x=ws(e.scene),ee=Ts(e.scene);J&&q&&(e.bundle!==$o||K.height!==es||Rn(Cs,x)||zn(Es,ee)||Bn(ts,q)||!as(ns,rs))&&($o=e.bundle,Cs=x,Es=ee,ts=q,es=K.height,ns=rs,Q.seek(Q.positionMs)),Fs(e).catch(M)}function uc(e){let t=F.snapshot().hoverReport;if(t===null){M(Error(`kept hover "${e}" with no hover report`));return}F.setHoverReport({...t,removable:t.removable.filter(t=>t!==e)})}async function dc(e){B=null;let t=Be(e),n=e=>{B=e,co=F.snapshot().scene,$(F.snapshot())};if(!t.ok)return n(t.reason);let r=new Uint8Array(await e.arrayBuffer());try{await ne(r,e.type)}catch(t){return n(`The logo "${e.name}" could not be read as an image: ${t instanceof Error?t.message:String(t)}`)}let{ref:i}=await j.logos.put(e);hs=t.note===null?null:{ref:i,note:t.note};let a=F.snapshot().scene.branding.logo,o=a?{corner:a.corner,size:a.size,opacity:a.opacity}:oe;await F.dispatch({kind:`setBranding`,patch:{logo:{ref:i,...o}}})}async function fc(){let e=Xa(F.snapshot().scene.branding);if(e===null||!e.edited){B=e===null?`No brand kit was updated: this demo is no longer on a kit.`:`No brand kit was updated: this demo already matches "${e.kit.name}".`,co=F.snapshot().scene,$(F.snapshot());return}let t=e.kit,n=`This demo's background, logo and padding will replace the brand kit "${t.name}".`;try{if(!await g({glyph:`refresh`,title:`Replace "${t.name}"`,body:n,confirmLabel:`Replace`,danger:!1,focus:`confirm`}))return;let e=F.snapshot().scene.branding,r=await qa.update(n=>n.kits.some(e=>e.id===t.id)?{...n,kits:n.kits.map(n=>n.id===t.id?{...n,branding:e}:n)}:`it was deleted in another tab`);if(r!==null)throw Error(r);N=await qa.read()}catch(e){B=`The brand kit "${t.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,co=F.snapshot().scene}$(F.snapshot())}async function pc(e){let t=N.state===`ready`?N.kits:[],n=ee(e,t,null);if(!n.ok){Ya={text:e,error:n.reason},$(F.snapshot());return}let r=F.snapshot().scene.branding,i=le();try{let t=await qa.update(e=>{let t=ee(n.name,e.kits,null);return t.ok?{kits:[...e.kits,{id:i,name:t.name,branding:r}],defaultId:e.defaultId??i}:t.reason});if(t!==null){Ya={text:e,error:t},$(F.snapshot());return}Ya=null,Ja=i,N=await qa.read()}catch(e){B=`The brand kit "${n.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,co=F.snapshot().scene}$(F.snapshot())}async function mc(){R=null,io=null;let e=F.snapshot(),t=e.scene;L={phase:`encoding`,done:0,total:0},ro=null,$(F.snapshot());try{await F.settled(),await j.exports.start(Qa,{fileType:W,aspect:t.canvas.aspect,retexts:gt(t,e.madeFrom,e.bundle!==null).overlays,revision:$a})}catch(e){throw L={phase:`idle`},R=e instanceof Error?e.message:String(e),$(F.snapshot()),e}}async function hc(e){let t=Mo(),n=e.map(e=>t.find(t=>t.ref===e)),r=e.filter((e,t)=>n[t]===void 0);if(r.length>0)throw Error(`no output row for ${r.map(e=>`"${e}"`).join(`, `)}`);if(n.length===0)return;let i=j.downloads;if(i===void 0)throw Error(`this page cannot save an export again`);ro=await i.save(n),$(F.snapshot())}var gc=!1;function _c(){let e=document.querySelector(`[data-panel-export]`);e!==null&&!Vi(e,L,W,sc(F.snapshot()))&&!gc&&(gc=!0,M(Error(`the Export panel has no start button, so progress cannot show`)))}function vc(e){switch(e.kind){case`queued`:(L.phase===`encoding`||L.phase===`queued`)&&(L={phase:`queued`,position:e.position},$(F.snapshot()));return;case`rendering`:(L.phase===`encoding`||L.phase===`queued`)&&(L={phase:`encoding`,done:e.done,total:e.total},_c());return;case`fileFailed`:R=R===null?e.line:`${R}; ${e.line}`;return;case`saving`:L={phase:`saving`},$(F.snapshot());return;case`saved`:ro=e.save.kind===`saved`&&e.summary!==null?{...e.save,summary:e.summary}:e.save,L={phase:`idle`},$(F.snapshot());return;case`failed`:L={phase:`idle`},e.detail!==null&&(R=R===null?e.detail:`${R}; ${e.detail}`),$(F.snapshot());return;case`outputsChanged`:j.outputs.list(Qa).then(e=>{jo=e,$(F.snapshot())}).catch(M);return}}j.exports.onEvent(vc),j.nav.onOpen?.(e=>Tc(()=>location.assign(e))),P(`name`).addEventListener(`change`,e=>{I({kind:`rename`,name:e.target.value.trim()})});var yc=e=>()=>{let t=F.snapshot().scene;e().catch(M).then(()=>to(t))};P(`undo`).addEventListener(`click`,yc(()=>F.undo())),P(`redo`).addEventListener(`click`,yc(()=>F.redo()));var bc={recording:`a take is recording`,rendering:`a render is running`,sharing:`a share is in progress`,replaying:`a take is being run in Runs`};function xc(e){fo=e,Sc()}function Sc(){if(zc){$(F.snapshot());return}wi(P(`failure`),{error:null,replaySentence:null,captureSentence:null,deleteError:fo,navigationError:po})}function Cc(e,t,n=``){po=null;try{location.assign(t())}catch(t){M(t),po={page:e,reason:`${n}${t instanceof Error?t.message:String(t)}`},Sc()}}function wc(e=``,t=null){Cc(`Recordings page`,()=>Ue(j.nav.library(),t),e)}function Tc(e){(async()=>{let t=null,n=F.subscribe(e=>{t=e});try{await F.settled()}finally{n()}t?.error??e()})()}P(`back`).addEventListener(`click`,()=>{Tc(()=>wc())});function Ec(e){let t=Dc(e);t&&(e.preventDefault(),Tc(()=>Cc(`Runs page`,()=>t.href)))}P(`banner`).addEventListener(`click`,Ec),P(`inspector`).addEventListener(`click`,Ec),P(`take-info`).addEventListener(`click`,Ec),P(`failure`).addEventListener(`click`,Ec),P(`take-info`).addEventListener(`toggle`,e=>{P(`take-meta`).setAttribute(`aria-expanded`,String(e.newState===`open`))});function Dc(e){let t=(e.target instanceof Element?e.target:null)?.closest(`a[data-runs-route]`);return!t||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey?null:t}var Oc=null;document.addEventListener(`mousedown`,e=>{let t=Dc(e);Oc=t?{link:t,href:t.href}:null},!0),document.addEventListener(`mouseup`,e=>{let t=Oc;if(Oc=null,!t)return;let n=Dc(e);!n||n===t.link||n.href===t.href&&Tc(()=>Cc(`Runs page`,()=>n.href))},!0),P(`delete`).addEventListener(`click`,()=>{(async()=>{try{if(!await g(ie))return}catch(e){M(e),xc(`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`);return}fo=null;let e;try{e=await j.scenes.remove(Qa)}catch(e){M(e),xc(`Not deleted: ${e instanceof Error?e.message:String(e)}.`);return}if(!e.ok){xc(`Not deleted: ${bc[e.error]??e.detail??e.error}.`);return}if(e.result!==void 0&&!e.result.ok){let t=e.result.steps.find(e=>!e.ok);xc(`Partly deleted: ${t?.step??`a step`} could not be removed — ${t?.error??`unknown error`}. Open Your demos to retry.`);return}let t=e.note??null;wc(t===null?`This demo was deleted. `:`This demo was deleted. ${t} `,t===null?null:`This demo was deleted. ${t}`)})()});var kc=Symbol.for(`demoman.editor.keydown`),Ac=globalThis,jc=Ac[kc];jc instanceof AbortController&&jc.abort();var Mc=new AbortController;Ac[kc]=Mc;var Nc=!1,Pc=null;document.addEventListener(`pointerdown`,()=>{Nc=!0},{capture:!0,signal:Mc.signal}),document.addEventListener(`keydown`,()=>{Nc=!1},{capture:!0,signal:Mc.signal}),document.addEventListener(`focusin`,e=>{Pc=Nc?e.target:null},{signal:Mc.signal});var Fc=new WeakMap;document.addEventListener(`focusin`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&Fc.set(t,t.value)},{signal:Mc.signal}),document.addEventListener(`change`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&Fc.set(t,t.value)},{capture:!0,signal:Mc.signal}),document.addEventListener(`keydown`,e=>{if(document.querySelector(`dialog[open]`)!==null||e.key===`Escape`&&document.querySelector(`:popover-open`)!==null)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable===!0){if(e.key===`Escape`&&t?.matches(`[data-shortcuts-search]`)!==!0){if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){let e=Fc.get(t);e!==void 0&&t.value!==e&&(t.value=e)}t?.blur()}return}let r=e.key===`Enter`||e.key===` `&&t!==Pc;if((n===`BUTTON`||n===`A`)&&r&&t?.hasAttribute(`data-tick`)!==!0)return;let i=F.snapshot(),a=Er(e,{hasSelection:V!==null,selectionIsBeat:V?.kind===`tick`,canUndo:i.canUndo,canRedo:i.canRedo,panelOpen:U,hasTimeline:G!==null&&wo>0});a!==null&&(e.preventDefault(),Ic(a,i))},{signal:Mc.signal});function Ic(e,t){switch(e.kind){case`playPause`:ec();return;case`shuttle`:z=null,Q.shuttle(e.direction);return;case`stop`:Q.stop();return;case`nudge`:Q.seek(Q.positionMs+e.deltaMs);return;case`seekEdge`:Q.seek(e.edge===`head`?Z:Js);return;case`stepBeat`:{let n=t.scene.actions.map(e=>e.id),r=V?.kind===`tick`?n.indexOf(V.actionId):-1,i=n[r===-1?e.delta>0?0:n.length-1:r+e.delta];if(i===void 0)return;xo({kind:`tick`,actionId:i}),$(t);return}case`setTrim`:{let n=So,r=Co;if(n===null||r===null||J===null||!Ys){let e=cc(t);Ao=`This take has not been rendered yet, so there is nothing to trim to. ${Bt(e.authored,zt(e),`first`)}`,$(t);return}rc(vn(n,r,{kind:`trim`,edge:e.edge,toMs:Q.positionMs,snapMs:0},{resolved:J,bundle:t.bundle,viewport:t.scene.meta.capture.viewport}));return}case`undo`:yc(()=>F.undo())();return;case`redo`:yc(()=>F.redo())();return;case`deleteSelection`:{if(V===null)return;if(V.kind===`zoom`){ic({kind:`removeZoom`,id:V.id});return}if(V.kind===`mask`){ic({kind:`removeMask`,id:V.id});return}if(!e.keepPace){ac(V.actionId);return}let n=Co;if(n===null){Ao=`This take has not been rendered yet, so there is no measured time to keep.`,$(t);return}let r=V.actionId;if(J===null){Ao=`This take has not been rendered yet, so there is no measured time to keep.`,$(t);return}let i=Sn(n,r,J);if(i===null||nn(i)){rc(i);return}I(i).then(()=>{let e=F.snapshot();e.scene.actions.some(e=>e.id===r)||V?.kind===`tick`&&V.actionId===r&&(xo(null),$(e))});return}case`zoomTimeline`:{if(G===null)return;let n=Math.min(1,Math.max(0,k(G,Q.positionMs)));G=Jr(G,wo,e.factor,n),$(t);return}case`zoomFit`:G=Gr(wo),$(t);return;case`toggleSnapping`:To=!To,$(t);return;case`clearSelection`:xo(null),$(t);return;case`toggleHelp`:Lc(`shortcuts`);return;case`closePanel`:Rc();return}}function Lc(e){H===e&&U?U=!1:(H=e,U=!0,e===`shortcuts`&&(Oo=!0)),e!==`selection`&&(mo=e),$(F.snapshot())}function Rc(){U=!1,$(F.snapshot())}ia(),ri(),document.body.dataset.zoom=`fit`;{let e=P(`notes`),t=``,n=()=>{oa(P(`notes-open`),e),t=sa(e,t)};new MutationObserver(n).observe(e,{childList:!0,subtree:!0,characterData:!0}),n()}var zc=!1;F.subscribe(e=>{zc=!0,uo=null,$(e)}),F.subscribe(e=>ss(e).catch(M)),F.subscribe(e=>Qo(e,J).catch(M));async function Bc(){N=await qa.read(),zc&&$(F.snapshot())}Bc().catch(M),qa.onChange===void 0?console.info(`demoman: no storage change feed here, so the brand kit is read once`):qa.onChange(()=>{Bc().catch(M)});async function Vc(){let e=j.exportQuality;if(e===void 0)return;let t=await e.read();t.unreadable!==void 0&&console.info(`demoman editor: the studio exports at Sharing quality: ${t.unreadable}`),t.quality!==_o&&(_o=t.quality,zc&&$(F.snapshot()))}j.exportQuality!==void 0&&(Vc().catch(M),window.addEventListener(`focus`,()=>{Vc().catch(M)})),j.outputs.list(Qa).then(e=>{jo=e,zc&&$(F.snapshot())}).catch(M),F.load().catch(oc);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,l as r,o as i,r as a,s as o,u as s}from"./theme-D59pt_a-.js";import{a as c,d as l,i as u,l as d,n as f,o as p,r as m,t as h}from"./state-COWbBf84.js";import{i as g,n as _,r as v,t as y}from"./topbar-Dq9UrNEm.js";function b(e,t){let n=e=>({ref:e.ref,sourceTimeMs:e.sourceTimeMs});if(e.length<=t)return e.map(n);let r=t>1?(e.length-1)/(t-1):0,i=new Set(Array.from({length:Math.max(0,t)},(e,t)=>Math.round(t*r)));return e.filter((e,t)=>i.has(t)).map(n)}function x(e){return e===null?{kind:`noBundle`}:e.keyframes.length===0?{kind:`noKeyframes`}:{kind:`ready`,frames:b(e.keyframes,8)}}function S(e){switch(e.kind){case`ready`:return null;case`loading`:return`Loading preview…`;case`noBundle`:return`No frames stored — nothing to preview.`;case`noKeyframes`:return`This demo has no keyframes.`;case`failed`:return`Preview unavailable — ${e.reason}`}}function C(e,t){return t<=1?0:(e+1)%t}function w(e,t){let n=e.querySelector(`[data-preview-canvas]`),r=e.querySelector(`[data-preview-note]`),i=S(t);n!==null&&(n.hidden=i!==null),r!==null&&(r.textContent=i??``)}function T(e){let n=[],r=!1;function i(i,a){let o=a.querySelector(`[data-preview-canvas]`);if(o===null){console.error(`demoman library: preview box for ${i} has no canvas to paint into`),w(a,{kind:`failed`,reason:`this row has no canvas to paint into`});return}let s=[],c=[],l=0,u=null,d=()=>{u!==null&&(clearInterval(u),u=null)};n.push(d);let f=(e,t)=>{d(),console.error(`demoman library: ${e} for ${i} —`,t),w(a,{kind:`failed`,reason:t instanceof Error?t.message:String(t)})},p=async t=>{let n=c[t];if(n!==void 0)return n;let r=s[t];if(r===void 0)throw Error(`preview frame ${t} is past the end of the take`);let i=await e.image(r.ref),a=document.createElement(`canvas`);return a.width=320,a.height=Math.max(1,Math.round(320*i.height/i.width)),a.getContext(`2d`)?.drawImage(i,0,0,a.width,a.height),i.close(),c[t]=a,a},m=async e=>{let t=await p(e);r||(o.width=t.width,o.height=t.height,o.style.setProperty(`--thumb-ratio`,String(t.width/t.height)),o.getContext(`2d`)?.drawImage(t,0,0))},h=()=>{l=C(l,s.length),m(l).catch(e=>f(`drawing a keyframe`,e))},g=()=>{u!==null||s.length<=1||(u=setInterval(h,400))},_=()=>{d(),l=0,m(0).catch(e=>f(`drawing the first keyframe`,e))},v=()=>{let e=a.closest(`article`);if(e===null){console.error(`demoman library: preview box for ${i} has no row to hover`);return}e.addEventListener(`mouseenter`,g),e.addEventListener(`mouseleave`,_),e.addEventListener(`focusin`,g),e.addEventListener(`focusout`,_),n.push(()=>{e.removeEventListener(`mouseenter`,g),e.removeEventListener(`mouseleave`,_),e.removeEventListener(`focusin`,g),e.removeEventListener(`focusout`,_)})},y=n=>{let o=a.querySelector(`[data-duration]`);if(o===null){console.error(`demoman library: preview box for ${i} has no duration badge`);return}e.length(i,n).then(e=>{if(!r){if(e.kind===`nothing`){console.info(`demoman library: no length on ${i}'s card — ${e.reason}`);return}o.textContent=t(e.ms),o.title=`Length of the exported video`,o.hidden=!1}}).catch(e=>{console.warn(`demoman library: could not work out ${i}'s length —`,e)})},b=async()=>{let t;try{t=await e.bundle(i)}catch(e){f(`reading the frame bundle`,e);return}if(r)return;let n=x(t);if(n.kind!==`ready`){w(a,n);return}s=n.frames;try{await m(0)}catch(e){f(`drawing the first keyframe`,e);return}r||(w(a,n),v(),t!==null&&y(t))};n.push(e.whenVisible(a,()=>{b()}))}return{mount:i,dispose(){r=!0;for(let e of n)e();n.length=0}}}var E=(e,t)=>`${e}:${t}`,ee=1024**3;function D(e,t={},n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);return n!==void 0&&(r.textContent=n),r}function O(e,t,n={}){let r=D(`span`,{class:`tag`,...n});return r.append(i(e),t),r}function te(){let e=D(`div`,{class:`meter`}),t=D(`div`,{class:`meter-fill`});return e.append(t),{bar:e,set(n){t.style.width=`${(n*100).toFixed(1)}%`,e.toggleAttribute(`data-full`,n>=.9)}}}var k=`storage-panel`,A=16,ne=300;function j(e,t,n=!1){let r=t.getBoundingClientRect(),i=document.documentElement.clientWidth,a=Math.min(ne,i-32),o=r.right-a>=A?r.right-a:r.left,s=Math.max(A,Math.min(o,i-A-a)),c=t.closest(`[data-header]`),l=c!==null&&getComputedStyle(c).position===`sticky`;e.style.maxHeight=``;let u=e.offsetHeight,d=r.bottom+6,f=window.innerHeight-A-d,p=r.top-6-A,m=n&&e.dataset.side!==void 0?e.dataset.side===`above`:u>f&&(u<=p||p>f);e.dataset.side=m?`above`:`below`;let h=Math.max(0,m?p:f);u>h&&(e.style.maxHeight=`${Math.round(h)}px`);let g=Math.min(u,h),_=m?r.top-6-g:d;e.style.position=l?`fixed`:`absolute`,e.style.width=`${Math.round(a)}px`,e.style.left=`${Math.round(s+(l?0:window.scrollX))}px`,e.style.top=`${Math.round(_+(l?0:window.scrollY))}px`}var re=e=>(e/ee).toFixed(2).replace(/\.?0+$/,``);function ie(e){let t=null,n=D(`div`,{class:`library`,"data-library":``}),r=D(`aside`,{class:`library-side`,"data-header":``}),a=D(`nav`,{class:`side-group`,"aria-label":`Sections`,"data-jumps":``}),o=D(`div`,{class:`library-content`}),s=te();s.bar.setAttribute(`aria-hidden`,`true`);let c=D(`span`,{"data-meter":``}),l=D(`button`,{type:`button`,class:`btn btn-quiet storage-trigger`,"data-storage-trigger":``,popovertarget:k,"aria-controls":k});l.append(D(`span`,{class:`storage-label`},`Storage`),s.bar,c,i(`chevronDown`));let u=D(`div`,{class:`storage`}),d=D(`span`,{"data-total-size":``}),f=D(`span`,{class:`library-total`,"data-library-total":``});f.append(D(`span`,{class:`storage-label`},`Storage`),d);let m=D(`div`,{"data-notices":``}),g=D(`div`,{id:k,class:`storage-panel`,popover:``,"data-storage":``,"aria-label":`Storage`}),_=null;g.addEventListener(`beforetoggle`,e=>{e.newState===`open`&&j(g,l)}),g.addEventListener(`toggle`,e=>{let t=e.newState===`open`;l.toggleAttribute(`data-open`,t),_?.abort(),_=null,t&&(j(g,l),_=new AbortController,window.addEventListener(`resize`,()=>j(g,l),{signal:_.signal}),window.addEventListener(`scroll`,()=>j(g,l,!0),{passive:!0,signal:_.signal}))});let v=te();v.bar.setAttribute(`role`,`progressbar`),v.bar.setAttribute(`aria-label`,`Storage used`),v.bar.setAttribute(`aria-valuemin`,`0`),v.bar.setAttribute(`aria-valuemax`,`1`);let y=D(`p`,{class:`storage-used`,"data-storage-used":``}),b=D(`input`,{type:`number`,min:`0.25`,step:`0.25`,id:`storage-budget`,"data-storage-budget":``}),x=D(`p`,{class:`notice notice-error hidden`,role:`alert`,"data-budget-note":``});b.addEventListener(`change`,()=>{let e=Number(b.value);if(!Number.isFinite(e)||e<=0){x.textContent=h,x.classList.remove(`hidden`);return}x.classList.add(`hidden`),t?.setBudget?.(Math.round(e*ee))});let S=D(`div`,{class:`storage-budget-row`});S.append(b,D(`span`,{},`GB`));let C=D(`div`,{class:`storage-field`});C.append(D(`label`,{for:`storage-budget`},`Budget`),S,D(`p`,{class:`storage-hint`},`Saves automatically.`),x);let w=D(`button`,{type:`button`,"data-action":`reclaim`,class:`btn btn-quiet storage-reclaim`});w.append(i(`trash`),`Reclaim space`),w.addEventListener(`click`,()=>t?.reclaim?.());let T=D(`div`,{class:`storage-foot`});T.append(w,D(`p`,{class:`storage-hint`},`Clears cached exports, then hosted takes' motion, oldest first, until the library fits its budget.`)),g.append(D(`h2`,{class:`storage-title`},`Storage`),v.bar,y,C,T),u.append(l,g),r.append(D(`h1`,{},`Recordings`),a),o.append(m),n.append(r,o);let E=document.querySelector(`[data-storage-slot]`);return e&&(E??r).append(u),{box:n,jumps:a,content:o,notices:m,update(e,n){if(t=n,e.totalBytes===void 0)f.remove();else{let t=e.unmeasured??0,n=`${p(e.totalBytes)}${t>0?`+`:``}`,i=t>0?`${t} ${t===1?`folder`:`folders`} could not be measured`:null;d.textContent=n,f.setAttribute(`aria-label`,`Storage: ${n}${i===null?``:` (${i})`}`),i===null?f.removeAttribute(`title`):f.setAttribute(`title`,i),f.parentNode===null&&(E??r).append(f)}let i=p(e.usedBytes),a=p(e.budgetBytes);s.set(e.fraction),v.set(e.fraction),v.bar.setAttribute(`aria-valuenow`,e.fraction.toFixed(3)),c.textContent=`${i} of ${a}`,l.setAttribute(`aria-label`,`Storage: ${i} of ${a} used`),y.textContent=`${i} used of a ${a} budget`,document.activeElement!==b&&(b.value=re(e.budgetBytes)),m.replaceChildren(...ae(e))}}}function ae(e){let t=[];return e.migrating&&t.push(D(`p`,{"data-migrating":``,class:`notice`},`Measuring existing demos…`)),e.migrationFailed&&t.push(D(`p`,{"data-migration-failed":``,class:`notice notice-warn`},`Measuring existing demos failed, so sizes below may be wrong. Open the extension's error log if this keeps happening.`)),e.chromeNearLimit&&t.push(D(`p`,{"data-chrome-limit":``,class:`notice notice-warn`},`Chrome is near its storage limit on this drive.`)),e.unwatched!=null&&t.push(D(`p`,{"data-unwatched":``,class:`notice notice-warn`},`New takes will not show until you reload — ${e.unwatched}.`)),e.notice!==null&&t.push(D(`p`,{"data-notice":``,class:`notice notice-error`},e.notice)),t}var M=new WeakMap;function oe(e,t,n){let r=u(e),i=r.states.filter(e=>e.value!==`Complete`);if(r.hosts.length<=1&&i.length===0)return null;let a=D(`div`,{class:`filters`,role:`group`,"aria-label":`Filter`,"data-filters":``}),o=(e,t,r,i,a)=>{let o=D(`button`,{type:`button`,class:`pill`,"aria-pressed":r?`true`:`false`,...a});return o.append(e),t!==null&&o.append(D(`span`,{class:`pill-count`},String(t))),o.addEventListener(`click`,()=>n.filter(i)),o},s=t.host===null&&t.state===null;if(a.append(o(`All`,e.length,s,f,{"data-filter-all":``})),r.hosts.length>1)for(let e of r.hosts){let n=t.host===e.value;a.append(o(e.value,e.count,n,{...t,host:n?null:e.value},{"data-filter-host":e.value}))}i.length>0&&r.hosts.length>1&&a.append(D(`span`,{class:`filters-sep`,"aria-hidden":`true`}));for(let e of i){let n=t.state===e.value;a.append(o(e.value,e.count,n,{...t,state:n?null:e.value},{"data-filter-state":e.value}))}return a}function se(e,t){let n=D(`div`,{class:`row-tags`}),r=t.openReview;if(e.needsLook&&r!==void 0){let t=D(`button`,{type:`button`,class:`tag tag-warn tag-look`,"data-needs-look":``,"aria-label":`Needs a look: ${e.label}`,title:`Needs a look`});t.append(i(`circleAlert`)),t.addEventListener(`click`,()=>r(e.sceneId)),n.append(t)}return e.hosted&&n.append(O(`cloud`,`Hosted`,{"data-hosted":``,title:`Hosted copy stays online after a local delete`})),e.state===`Motion reclaimed`?n.append(O(`restore`,e.state,{"data-state-chip":``,class:`tag tag-warn`,title:e.authored?`Its motion was reclaimed to free space; Restore opens Runs to run its script again, which makes a new take`:`Its motion was reclaimed to free space; Restore re-shoots it in Runs`})):e.state===`Keyframes only`&&n.append(O(`image`,e.state,{"data-state-chip":``,title:`No motion was recorded for this take`})),n.childElementCount>0?n:null}function ce(e,t){let n=D(`div`,{"data-preview":``}),r=D(`canvas`,{"data-preview-canvas":``,"aria-hidden":`true`,hidden:``});n.append(r,D(`p`,{"data-preview-note":``},S({kind:`loading`})??``));let i=se(e,t);return i!==null&&n.append(i),n.append(D(`span`,{"data-duration":``,hidden:``})),n}var le={Complete:`complete`,"Motion reclaimed":`reclaimed`,"Keyframes only":`keyframesOnly`},ue=e=>`name-${e}`;function de(e,t){let n=D(`input`,{type:`text`,id:ue(e.sceneId),"data-name":``,"aria-label":`Demo name`,title:e.name,placeholder:`Untitled`,spellcheck:`false`,autocomplete:`off`});n.value=e.name;let r=e.name;return n.addEventListener(`change`,()=>{let i=n.value.trim();if(i===r){n.value=r;return}r=i,n.value=i,n.title=i,t.rename(e.sceneId,i)}),n.addEventListener(`keydown`,e=>{e.key===`Escape`?(n.value=r,n.blur()):e.key===`Enter`&&n.blur()}),n}function fe(e,t,n,r){let a=D(`article`,{class:`card`,"data-row":e.sceneId,"data-state":le[e.state],...e.name===``?{"aria-label":e.label}:{"aria-labelledby":ue(e.sceneId)}}),o=!1;a.addEventListener(`pointerdown`,()=>{let e=document.activeElement;o=e?.matches(`[data-name]`)===!0&&a.contains(e)}),a.addEventListener(`click`,n=>{let r=n.target;o||r.closest(`button, input, a`)||(window.getSelection()?.toString()??``)===``&&t.edit(e.sceneId)}),a.append(ce(e,t));let c=D(`div`,{class:`row-actions`});if(e.servesReshoot){let n=D(`button`,{type:`button`,"data-action":`back-to-recording`,class:`btn btn-quiet btn-icon`,"aria-label":`Back to your recording: ${e.label}`,title:`Back to your recording — this take plays its re-shot frames; its recording is kept`});n.append(i(`undo`)),n.addEventListener(`click`,()=>t.backToRecording(e.sceneId)),c.append(n)}let l=e.canRestore?t.rerunLine?.(e.sceneId,e.authored)??null:null;if(e.canRestore&&l===null){let n=D(`button`,{type:`button`,"data-action":`restore`,class:`btn btn-quiet btn-icon`,"aria-label":`Restore motion: ${e.label}`,title:e.authored?`Restore motion — run its script again in Runs; a script-made take cannot be re-shot, so this makes a new take`:`Restore motion — re-shoot it in Runs`});n.append(i(`restore`)),n.addEventListener(`click`,()=>t.restore(e.sceneId)),c.append(n)}let u=D(`button`,{type:`button`,"data-action":`edit`,class:`btn btn-quiet btn-icon`,"aria-label":`Edit ${e.label}`,title:`Edit`});u.append(i(`clapperboard`)),u.addEventListener(`click`,()=>t.edit(e.sceneId)),c.append(u);let d=D(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${e.label}`,title:`Delete`});d.append(i(`trash`)),d.addEventListener(`click`,()=>t.remove(e.sceneId,`take`)),c.append(d);let f=D(`div`,{class:`row-text`}),m=D(`div`,{class:`row-title`});m.append(de(e,t),c),f.append(m);let h=`${e.origin}${e.path}`,g=D(`div`,{class:`row-line`});if(g.append(D(`p`,{class:`row-meta`,title:h},`${h} · ${r?e.time:e.when}`)),e.sizeBytes===void 0?t.reclaim!==void 0&&g.append(D(`p`,{"data-size":``,class:`row-size`},`${p(e.frameBytes)} frames · ${p(e.outputBytes)} renders`)):g.append(D(`p`,{"data-size":``,class:`row-size`},p(e.sizeBytes))),f.append(g),a.append(f),l!==null){let e=D(`p`,{"data-rerun-line":``,class:`row-rerun`});s(e,l),a.append(e)}return n!==void 0&&a.append(D(`p`,{"data-status":``,class:`notice notice-error`},n)),a}function pe(e){let t=document.activeElement;if(!(t instanceof HTMLInputElement)||!t.matches(`[data-name]`)||!e.contains(t))return null;let n=t.closest(`[data-row]`)?.getAttribute(`data-row`);return n?{sceneId:n,value:t.value,start:t.selectionStart,end:t.selectionEnd}:null}function me(e,t){if(t===null)return;let n=e.querySelector(`[data-row="${CSS.escape(t.sceneId)}"] [data-name]`);n!==null&&(n.value=t.value,n.focus(),t.start!==null&&t.end!==null&&n.setSelectionRange(t.start,t.end))}var he=e=>`section-${e.replace(/:/g,`-`)}`;function ge(e){let t=new Map;for(let n of e.querySelectorAll(`[data-section]`)){let e=n.getAttribute(`data-section`);e!==null&&t.set(e,n.open)}return t.size>0?(_e.set(e,t),t):_e.get(e)??t}var _e=new WeakMap,N=`unreadable`,P=e=>`when-${e.replace(/:/g,`-`)}`;function ve(e,t){let n=D(`div`,{class:`side-list`});for(let t of e){let e=P(t.key),r=D(`a`,{href:`#${e}`,class:`side-item`,"data-nav":e,title:t.label});r.append(D(`span`,{class:`side-label`},t.label),D(`span`,{class:`side-count`},String(t.rows.length))),r.addEventListener(`click`,()=>{let t=document.getElementById(e);t instanceof HTMLDetailsElement&&(t.open=!0)}),n.append(r)}if(t>0){let e=D(`a`,{href:`#${N}`,class:`side-item`,"data-nav":N,title:`Couldn't read`});e.append(D(`span`,{class:`side-label`},`Couldn't read`),D(`span`,{class:`side-count`},String(t))),n.append(e)}return n}function ye(e,t,n,r){let a=he(e.key),o=D(`details`,{class:`section`,id:P(e.key),"data-section":e.key,"aria-labelledby":a});o.open=t;let s=D(`summary`,{class:`section-head`}),c=i(`chevronRight`);c.classList.add(`chev`),s.append(c,D(`h2`,{id:a},e.label),D(`span`,{class:`section-count`,"data-section-count":``},String(e.rows.length))),o.append(s);let l=D(`div`,{class:`rows`}),u=e.rows.map(t=>{let i=fe(t,n,r.get(E(`take`,t.sceneId)),e.namesDay);return l.append(i),[t.sceneId,i]});return o.append(l),{box:o,articles:u}}function be(e,t,n){let r=D(`section`,{class:`section`,id:N,"data-unreadable":``,"aria-labelledby":`section-unreadable`}),a=D(`div`,{class:`section-head`});a.append(D(`h2`,{id:`section-unreadable`},`Couldn't read`),D(`span`,{class:`section-count`},String(e.length))),r.append(a);let o=D(`div`,{class:`rows`});for(let r of e){let e=D(`article`,{class:`card`,"data-unreadable-row":r.folder}),a=D(`div`,{class:`row-text`}),s=D(`div`,{class:`row-title`}),c=D(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${r.folder}`,title:`Delete`});c.append(i(`trash`)),c.addEventListener(`click`,()=>t.remove(r.folder,`folder`)),s.append(D(`p`,{class:`row-meta`,"data-unreadable-name":``},r.folder),c),a.append(s,D(`p`,{class:`row-meta`,"data-reason":``},r.reason)),r.sizeBytes!==void 0&&a.append(D(`p`,{"data-size":``,class:`row-size`},p(r.sizeBytes))),e.append(a);let l=n.get(E(`folder`,r.folder));l!==void 0&&e.append(D(`p`,{"data-status":``,class:`notice notice-error`},l)),o.append(e)}return r.append(o),r}function xe(e,t,n,r,i=f,a=new Date){let o=pe(e),s=ge(e),l=M.get(e);l===void 0&&(l=ie(n.reclaim!==void 0&&n.setBudget!==void 0),M.set(e,l)),l.update(t,n);for(let t of[...e.childNodes])t!==l.box&&t.remove();l.box.parentNode!==e&&e.prepend(l.box);for(let e of[...l.content.childNodes])e!==l.notices&&e.remove();l.jumps.replaceChildren();let u=l.content,p=t.unreadable??[],m=()=>{p.length>0&&u.append(be(p,n,r))};if(t.rows.length===0){if(p.length>0){m();return}let e=D(`div`,{"data-empty":``,class:`card empty-card`});e.append(g(`monitorPlay`,`No recordings yet`,t.emptyHint??`Click the Demoman icon in your browser's toolbar and press Record. Each take shows up here, grouped by the day you made it.`)),u.append(e);return}let h=oe(t.rows,i,n);h!==null&&u.append(h);let _=c(t.rows,i);if(_.length===0){let e=D(`button`,{type:`button`,class:`btn btn-link`,"data-filter-all":``},`Show all recordings`);e.addEventListener(`click`,()=>n.filter(f));let t=D(`div`,{"data-empty-filtered":``,class:`card empty-card`});t.append(g(`funnel`,`No recordings match this filter`,[e])),u.append(t),m();return}let v=[],y=d(_,a);l.jumps.append(ve(y,p.length));for(let e of y){let t=ye(e,s.get(e.key)??!e.folded,n,r);u.append(t.box),v.push(...t.articles)}m();for(let[e,t]of v)n.preview(e,t.querySelector(`[data-preview]`));me(e,o)}var F=document.querySelector(`#root`),I=document.querySelector(`#notice`),Se=v(F),L=r(),R=L.scenes;L.nav.onOpen?.(e=>location.assign(e)),L.theme!==void 0&&a(L.theme,document.documentElement,`library`),y(e=>V(e),L);var z=new Map;function B(e,t){I.textContent=e,I.className=t===`info`?`notice`:`notice notice-${t}`,I.classList.remove(`hidden`)}function V(e){B(e,`error`)}function Ce(){I.textContent=``,I.className=`notice notice-error hidden`}function H(e,t){console.error(`demoman library: ${e} —`,t),V(`Something went wrong (${e}). Try again.`)}function U(e,t){try{location.assign(e)}catch(e){H(t,e)}}var W=L.bundles,G=new Map,K=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=G.get(t.target);e!==void 0&&(G.delete(t.target),K?.unobserve(t.target),e())}},{rootMargin:`200px`}):null,we=!1,Te=(e,t)=>K===null?(we||(we=!0,console.info(`demoman library: no IntersectionObserver here, so every preview paints at once`)),t(),()=>{}):(G.set(e,t),K.observe(e),()=>{G.delete(e),K.unobserve(e)}),q=new Map,Ee={bundle:async e=>(await W.active(e)).bundle,length:async(e,t)=>{let n=q.get(e);if(n===void 0)throw Error(`no document for ${e} in the last listing`);return o(n,t,W.load)},image:async e=>{if(L.folder!==void 0)return L.folder.thumb(e);let t=await W.load(e);if(t instanceof Uint8Array)throw Error(`${e} loaded as motion bytes, not a keyframe`);if(!(t.image instanceof ImageBitmap))throw Error(`${e} decoded to something other than an ImageBitmap`);return t.image},whenVisible:Te},J=null,Y=null,De=f;function Oe(e){let t=new Set([...e.rows.map(e=>E(`take`,e.sceneId)),...(e.unreadable??[]).map(e=>E(`folder`,e.folder))]);for(let e of z.keys())t.has(e)||z.delete(e)}function X(e){Oe(e),J?.dispose(),J=T(Ee),xe(F,e,Pe,z,De),Se.mark()}var ke=_({paint:e=>Ae({keepNotice:e}),onRefreshFailed:e=>H(`refreshing the library`,e)});function Z(){return ke.render()}async function Ae({keepNotice:e=!1}={}){e||Ce();let t=await L.folder.read(),n=t.scenes;q=new Map(n.map(e=>[e.meta.id,e]));let r=m({sizes:t.sizes,unreadable:t.unreadable,unwatched:t.unwatched,emptyHint:L.nav.firstTakeHint(),scenes:n,migrating:!1,migrationFailed:!1,notice:null,needsLook:new Set});Y=r,X(r)}var je={recording:`a take is recording`,rendering:`a render is running`,sharing:`a share is in progress`,replaying:`a take is being run in Runs`},Q=new Map;function Me(e,t,n){let r=Q.get(e);if(r===void 0){U(t,n);return}r.then(e=>{e&&U(t,n)})}function Ne(e){return q.get(e)?.meta.capture.mode===`authored`}var Pe={filter:e=>{if(De=e,Y===null){console.error(`demoman library: a filter was picked before the page had rendered`);return}X(Y)},preview:(e,t)=>{if(J===null){console.error(`demoman library: a row asked for a preview before the page had a mounter`);return}J.mount(e,t)},edit:e=>{Me(e,L.nav.editor(e),`opening the editor`)},rename:(e,t)=>{let n=(async()=>{try{let n=null;try{let r=await R.get(e);if(r===null)n=`the take is no longer stored`;else{let e={...r.scene,meta:{...r.scene.meta,name:t}};await R.put(e,r.revision)}}catch(e){n=e instanceof Error?e.message:String(e)}let r=E(`take`,e);return n===null?z.delete(r):z.set(r,`Couldn't rename: ${n}.`),await Z(),n===null}catch(t){return H(`renaming this demo`,t),z.set(E(`take`,e),`Couldn't rename: ${t instanceof Error?t.message:String(t)}.`),Y!==null&&X(Y),!1}})();Q.set(e,n),n.finally(()=>{Q.get(e)===n&&Q.delete(e)})},restore:e=>{let t=L.nav.rerun(e,Ne(e));if(t.kind===`line`){console.error(`demoman library: Restore was pressed on a platform whose route is a line`);return}Me(e,new URL(t.href,L.nav.library()).href,`opening Runs to restore motion`)},rerunLine:(e,t)=>{let n=L.nav.rerun(e,t);return n.kind===`line`?n.text:null},backToRecording:e=>{(async()=>{let t=null,n=await Q.get(e),r=E(`take`,e),i=n===!1?z.get(r):void 0;try{let n=await R.get(e);if(n===null)throw Error(`the take is no longer stored`);let r={...n.scene,meta:{...n.scene.meta,renderMode:`screen`}};await R.put(r,n.revision);let i=(await W.active(e)).bundle;i?.source!==`capture`&&(t=i===null?`Your recording could not be put back: no frames could be read for this take.`:`There is no recording of this take to go back to, so it keeps its re-shot frames. Takes rebuilt before recordings were kept have none.`,console.info(`[demoman] library: back to your recording — not served (${i===null?`no bundle`:`serving ${i.source}`})`))}catch(e){H(`going back to the recording`,e),t=`Couldn't go back to the recording: ${e instanceof Error?e.message:String(e)}.`}let a=[i,t].filter(e=>e!=null).join(` `);a===``?z.delete(r):z.set(r,a);try{await Z()}catch(e){H(`refreshing the library`,e)}})()},remove:(t,r)=>{let i=E(r,t);(async()=>{try{let r;try{r=await e(n)}catch(e){console.error(`demoman library: asking before a delete —`,e),z.set(i,`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`),await Z();return}if(!r)return;await Q.get(t);let a=await R.remove(t),o=null;if(!a.ok){let e=a.detail??je[a.error]??a.error;z.set(i,`Not deleted: ${e}.`)}else if(a.result!==void 0&&!a.result.ok){let e=a.result.steps.find(e=>!e.ok),t=`Partly deleted: ${e?.step??`a step`} could not be removed — ${e?.error??`unknown error`}`;a.result.steps.find(e=>e.step===`scene`)?.ok===!0?(z.delete(i),o=t):z.set(i,t)}else z.delete(i);await Z(),o===null?a.ok&&a.note!==void 0&&B(a.note,`info`):V(o)}catch(e){H(`deleting this demo`,e)}})()}};L.folder?.onChange(()=>ke.soon());var $=l();Z().then(()=>{$!==null&&B($,`info`)},e=>{$!==null&&console.info(`demoman library: ${$}`),H(`loading your demos`,e)});
|