demoman 0.7.3 → 0.8.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 +5 -2
- package/THIRD_PARTY_NOTICES +1 -1
- package/dist/demoman.mjs +15325 -11856
- package/dist/page/decode-probe-entry.js +23071 -0
- package/dist/page/mux-entry.js +171 -52
- package/dist/page/render-entry.js +1143 -472
- package/dist/recipe.md +110 -117
- package/dist/studio/assets/confirm-dialog-B20ZVWlP.css +1 -0
- package/dist/studio/assets/confirm-dialog-DgJ946Hc.js +72 -0
- package/dist/studio/assets/editor-BC4sLdWT.js +4 -0
- package/dist/studio/assets/library-DVubUJtn.js +1 -0
- package/dist/studio/assets/{library-inline-216fd6fd.css → library-inline-ff1b0c15.css} +3 -27
- package/dist/studio/assets/settings-DLH9VoT0.js +1 -0
- package/dist/studio/assets/{settings-inline-ff6d2eee.css → settings-inline-7bb8bf61.css} +8 -0
- package/dist/studio/assets/state-DyL2jOOv.js +1 -0
- package/dist/studio/assets/view-Df6XUnyO.js +1 -0
- package/dist/studio/editor.html +5 -5
- package/dist/studio/library.html +5 -5
- package/dist/studio/settings.html +5 -5
- package/dist/studio/studio-build.json +3 -3
- package/dist/studio/wallpapers/dark-1-landscape.webp +0 -0
- package/dist/studio/wallpapers/dark-1-portrait.webp +0 -0
- package/dist/studio/wallpapers/dark-1-thumb.webp +0 -0
- package/dist/studio/wallpapers/dark-2-landscape.webp +0 -0
- package/dist/studio/wallpapers/dark-2-portrait.webp +0 -0
- package/dist/studio/wallpapers/dark-2-thumb.webp +0 -0
- package/dist/studio/wallpapers/light-1-landscape.webp +0 -0
- package/dist/studio/wallpapers/light-1-portrait.webp +0 -0
- package/dist/studio/wallpapers/light-1-thumb.webp +0 -0
- package/dist/studio/wallpapers/light-2-landscape.webp +0 -0
- package/dist/studio/wallpapers/light-2-portrait.webp +0 -0
- package/dist/studio/wallpapers/light-2-thumb.webp +0 -0
- package/dist/studio/wallpapers/muted-1-landscape.webp +0 -0
- package/dist/studio/wallpapers/muted-1-portrait.webp +0 -0
- package/dist/studio/wallpapers/muted-1-thumb.webp +0 -0
- package/dist/studio/wallpapers/muted-2-landscape.webp +0 -0
- package/dist/studio/wallpapers/muted-2-portrait.webp +0 -0
- package/dist/studio/wallpapers/muted-2-thumb.webp +0 -0
- package/dist/studio/wallpapers/muted-3-landscape.webp +0 -0
- package/dist/studio/wallpapers/muted-3-portrait.webp +0 -0
- package/dist/studio/wallpapers/muted-3-thumb.webp +0 -0
- package/dist/studio/wallpapers/muted-4-landscape.webp +0 -0
- package/dist/studio/wallpapers/muted-4-portrait.webp +0 -0
- package/dist/studio/wallpapers/muted-4-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-1-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-1-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-1-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-2-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-2-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-2-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-3-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-3-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-3-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-4-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-4-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-4-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-5-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-5-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-5-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-6-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-6-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-6-thumb.webp +0 -0
- package/package.json +1 -1
- package/dist/studio/assets/confirm-dialog-DSKBZQdV.css +0 -1
- package/dist/studio/assets/confirm-dialog-DVfQ_GQr.js +0 -72
- package/dist/studio/assets/editor-lILLTndB.js +0 -4
- package/dist/studio/assets/library-CbMXa-ad.js +0 -1
- package/dist/studio/assets/settings-CetO1oeR.js +0 -1
- package/dist/studio/assets/state-tew-ACWl.js +0 -1
- package/dist/studio/assets/view-v5HQTLVP.js +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{$ as e,A as t,C as n,Ct as r,E as i,J as a,Q as o,S as s,St as c,T as l,X as u,Y as d,Z as f,_ as p,at as m,c as h,d as g,dt as _,et as v,f as y,g as ee,gt as te,i as b,it as ne,j as re,l as ie,mt as ae,nt as oe,o as x,ot as se,p as ce,pt as le,rt as S,st as ue,t as de,tt as fe,u as C,w as pe,z as me}from"./confirm-dialog-DgJ946Hc.js";import{A as he,C as ge,D as _e,E as ve,F as ye,M as be,N as xe,O as Se,P as Ce,S as we,T as Te,_ as Ee,a as De,b as Oe,c as ke,d as Ae,f as je,g as Me,h as Ne,j as Pe,k as Fe,l as Ie,m as Le,o as w,p as Re,s as ze,u as Be,v as Ve,w as He,x as Ue,y as We}from"./view-Df6XUnyO.js";import{a as Ge,d as Ke,f as qe,l as Je,o as Ye}from"./state-DyL2jOOv.js";function Xe(e,t){let{bundle:n,scene:r}=v(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 Ze=64;function Qe(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 $e(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 et(e,t,n,r){let i=[];for(let a of Xe(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(Ze,Math.round(a.rect.width))),l=Math.max(1,Math.min(Ze,Math.round(a.rect.height))),u;try{u=$e(Qe(e,a.rect,t.viewport,c,l),Qe(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}function tt(e){return S.neutral.zoomHoldMs+ne(e).zoomOutMs}tt(ae.smoothness);var nt=Math.abs(S.leadInMs)+S.neutral.minPlateauMs+400;function rt(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 ${nt}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 ${it}x).`;case`textTooWide`:return`${t}: target too wide to zoom without cutting text (would be ${e.scale}x, floor ${it}x).`}}S.fitMarginPx;var it=1.2,at=`__demomanClickProbe`;`${at}${JSON.stringify(`__demomanClickSeen`)}`,`${at}`,`${at}`;var ot={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 recorded — 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`,dragEndOutOfView:`a drag's start or end was off the page once its start was in view, and a drag cannot scroll while it moves, so it was not begun; drag to a target on the same screen, or scroll first`,dragNoDistance:`a drag's two ends landed on the same point once measured, which is a click, not a drag, so it was not begun; give the drag's end another target, spot or offset`,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 recorded — 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:`this take has no step that acts on the page, so there is nothing to record`};function st(e){return e in ot?ot[e]:e}function ct(e){if(!e)return`(navigation)`;let t=e.fingerprint;return t.accessibleName??t.textContent??t.stableId??t.dataKey??e.id}function lt(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:ct(e.anchors.find(e=>e.id===n.anchorId))}:null}function ut(e,t){return lt(e,t)}function dt(e){return e.meta.capture.mode===`authored`}function ft(e){return e?`run its script again in Runs`:`re-shoot it in Runs`}function pt(e){let{toolchain:t,name:n,...r}=e.meta,{canvas:i,...a}=e;return ht(mt({...a,meta:r})).toString(16)}function mt(e){if(typeof e!=`object`||!e)return JSON.stringify(e)??`null`;if(Array.isArray(e))return`[${e.map(mt).join(`,`)}]`;let t=e;return`{${Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${mt(t[e])}`).join(`,`)}}`}function ht(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=typeof e==`string`?e.charCodeAt(r):e[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)}var gt={run:{phase:`idle`},save:null,error:null},_t=(e,t)=>e===null?t:`${e}; ${t}`;function vt(e,t){let n=e.run.phase===`encoding`||e.run.phase===`queued`;switch(t.kind){case`queued`:return n?{flow:{...e,run:{phase:`queued`,position:t.position}},effect:`render`}:{flow:e,effect:`none`};case`rendering`:return n?{flow:{...e,run:{phase:`encoding`,done:t.done,total:t.total}},effect:`progress`}:{flow:e,effect:`none`};case`fileFailed`:return{flow:{...e,error:_t(e.error,t.line)},effect:`none`};case`saving`:return{flow:{...e,run:{phase:`saving`}},effect:`render`};case`saved`:return{flow:{...e,run:{phase:`idle`},save:t.save.kind===`saved`&&t.summary!==null?{...t.save,summary:t.summary}:t.save},effect:`render`};case`failed`:return{flow:{...e,run:{phase:`idle`},error:t.detail===null?e.error:_t(e.error,t.detail)},effect:`render`};case`outputsChanged`:return{flow:e,effect:`relist`}}}var yt=`motion reclaimed to free space`;function bt(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]=St(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 xt(e,t=2){return String(Number(e.toFixed(t)))}function St(e,t){for(let n=2;n<4;n++)if(xt(e,n)!==xt(t,n))return[xt(e,n),xt(t,n)];return[xt(e,4),xt(t,4)]}function Ct(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=>bt(e,t))}}function wt(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 Tt(e){return e?`Run its script again in Runs`:`Re-shoot this take in Runs`}function Et(e){let t=ft(e);return t.charAt(0).toUpperCase()+t.slice(1)}function Dt(e){return e.rerun.kind===`line`?e.rerun.text:null}function Ot(e,t,n){return t??`${Et(e)} ${n}.`}var T=1,E=e=>({kind:`refusal`,reason:e});function kt(e,t){let n,r=1/0;for(let i of e){let e=t(i);(n===void 0||e<r)&&(n=i,r=e)}return n}function At(e){return new Map(e.markers.map(e=>[e.actionId,e.sourceTimeMs]))}function jt(e,t,n){return Mt(e,se(t,n))}function Mt(e,t){let n=[...e.markers].sort((e,t)=>e.sourceTimeMs-t.sourceTimeMs),r=n[0];if(r===void 0)return null;let i=r;for(let e of n)e.sourceTimeMs<=t&&(i=e);return{actionId:i.actionId,sourceOffsetMs:Math.round(t-i.sourceTimeMs)}}function Nt(e,t,n){let r=At(t),i=new Map((e.edits.removed??[]).map(e=>[e.id,e])),a=[{atMs:0,left:null,right:null,rank:0},{atMs:n.outputDurationMs,left:null,right:null,rank:2}],o=[],s=e=>{let t=(e,t)=>{if(e===null)return t;let i=r.get(e.actionId);if(i===void 0)return t;let a=i+e.sourceOffsetMs;return Math.max(0,Math.min(n.sourceDurationMs,a))};return{removedId:e.id,srcStartMs:t(e.start,0),srcEndMs:t(e.end,n.sourceDurationMs)}},c=[];for(let e of n.cuts){let t=e.ids.flatMap(e=>{let t=i.get(e);return t===void 0?[]:[t]}),c=(e,t)=>e===null?t:(r.get(e.actionId)??t)+e.sourceOffsetMs,l=kt(t,e=>c(e.start,-1/0)),u=kt(t,e=>-c(e.end,1/0));if(l===void 0||u===void 0)continue;let d=m(n,e.srcStartMs);a.push({atMs:d,left:l.start,right:u.end,rank:1,leftBeside:s(l),rightBeside:s(u)}),e.ids.forEach((t,n)=>{let r=i.get(t),a=r===void 0?null:s(r);o.push({removedId:t,atMs:d,index:n,srcStartMs:a?.srcStartMs??e.srcStartMs,srcEndMs:a?.srcEndMs??e.srcEndMs})})}for(let e of n.unplacedCuts)for(let t of e.ids){let a=i.get(t),s=[a?.start,a?.end].find(e=>e!=null&&r.has(e.actionId)),c=s===void 0?0:m(n,Math.max(0,Math.min(n.sourceDurationMs,(r.get(s.actionId)??0)+s.sourceOffsetMs)));o.push({removedId:t,atMs:c,index:o.filter(e=>Math.abs(e.atMs-c)<T).length,srcStartMs:0,srcEndMs:0,unplaced:e.reason})}for(let t of e.edits.splits??[]){let e=r.get(t.at.actionId);if(e===void 0){c.push(t.id);continue}let i=e+t.at.sourceOffsetMs;if(n.cuts.some(e=>i>=e.srcStartMs&&i<=e.srcEndMs))continue;let o=m(n,i);a.push({atMs:o,left:t.at,right:t.at,rank:1})}a.sort((e,t)=>e.atMs-t.atMs||e.rank-t.rank);let l=[];for(let e=0;e+1<a.length;e++){let t=a[e],n=a[e+1];n.atMs-t.atMs<T||l.push({startMs:t.atMs,endMs:n.atMs,start:t.right,end:n.left,before:t.rightBeside??null,after:n.leftBeside??null})}return{pieces:l,joins:o,unplacedSplits:c}}function Pt(e,t,n,r){if(t===null||n===null)return E(`Nothing has rendered yet, so there is no frame to split at.`);if(r<=0||r>=n.outputDurationMs)return E(`A split at the take's start or end splits nothing.`);let i=jt(t,n,r);if(i===null)return E(`These frames name no step, so there is nothing to split by.`);let a=At(t).get(i.actionId)??0,o=m(n,a+i.sourceOffsetMs),{pieces:s}=Nt(e,t,n);return o<=T||o>=n.outputDurationMs-T||s.some(e=>Math.abs(e.startMs-o)<T)?E(Math.abs(o-r)<T?`The clip is already split here.`:`A pause is one frame, so a split anywhere in it lands at its edge — and the clip is already split there.`):{kind:`split`,at:i}}var Ft=(e,t)=>e===null||t===null?e===t:e.actionId===t.actionId&&e.sourceOffsetMs===t.sourceOffsetMs;function It(e,t,n){let r=e.find(e=>Ft(e.start,t));if(r===void 0)return E(`That piece is no longer on the timeline.`);if(e.length===1)return E(`This is the only piece left, so removing it would leave nothing to export.`);if(n!==void 0){let t=e=>e.endMs>n.headMs+T&&e.startMs<n.tailMs-T;if(t(r)&&e.filter(t).length===1)return E(`This is the only piece inside the trim, so removing it would leave nothing to export.`)}return{kind:`removePiece`,start:r.start,end:r.end}}function Lt(e,t,n,r,i,a){let o=n.find(e=>Ft(e.start,r));if(o===void 0)return E(`That piece is no longer on the timeline.`);if(e===null||t===null)return E(`Nothing has rendered yet, so there is no frame to move the edge to.`);let s=Math.round(a);if(s===0)return null;let c=i===`end`?s<0:s>0,l=i===`end`?o.after:o.before;if(c){let n=i===`end`?Math.max(o.startMs+200,o.endMs+s):Math.min(o.endMs-200,o.startMs+s);if(i===`end`?n>=o.endMs:n<=o.startMs)return E(`This piece is as short as a piece can be.`);let r=jt(e,t,n);return r===null?E(`These frames name no step, so there is nothing to move the edge by.`):l===null?i===`end`?{kind:`removePiece`,start:r,end:o.end}:{kind:`removePiece`,start:o.start,end:r}:i===`end`?{kind:`setRemovedEdge`,id:l.removedId,start:r}:{kind:`setRemovedEdge`,id:l.removedId,end:r}}if(l===null)return E(i===`end`?`Nothing was removed after this piece, so its end can only move in.`:`Nothing was removed before this piece, so its start can only move in.`);let u=i===`end`?l.srcStartMs+s:l.srcEndMs+s;if(i===`end`?u>=l.srcEndMs-T:u<=l.srcStartMs+T)return{kind:`restorePiece`,id:l.removedId};let d=Mt(e,u);return d===null?E(`These frames name no step, so there is nothing to move the edge by.`):i===`end`?{kind:`setRemovedEdge`,id:l.removedId,start:d}:{kind:`setRemovedEdge`,id:l.removedId,end:d}}var Rt=1e3;function zt(e,t){return`Motion reclaimed to free space. ${Ot(e,t,`to restore`)}`}var Bt=new Set([`Motion reclaimed to free space. Replay to restore.`,`Motion reclaimed to free space. Rebuild to restore.`]);function Vt(e,t,n,r){return e===`motionReclaimed`?Bt.has(t)||t===`Motion reclaimed to free space. Re-shoot it in Runs to restore.`?zt(n,r):t:`${e}: ${t}`}var Ht=(e,t)=>e.hasBundle?t.outputMs??t.captureMs:t.captureMs;function Ut(e){return e.hasBundle&&e.outputDurationMs!==null?e.outputDurationMs:(e.beats[e.beats.length-1]?.captureMs??0)+Rt}var Wt=e=>({actionId:e.actionId,offsetMs:e.sourceOffsetMs});function Gt(e,t){let n=e.beats.find(e=>e.actionId===t.actionId);return(n?Ht(e,n):0)+t.offsetMs}function Kt(e){let{scene:t,view:n,bundle:r,resolved:i}=e,a=dt(t),o=e.rerunLine??null,s=e=>Ot(a,o,e),c=Ut(n),l=[],u=new Set(e.hoverReport?.removable??[]),d=new Map(n.beats.map(e=>[e.actionId,Ht(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`,h=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})),g=t.edits.trim,_=i?{headMs:i.range.startMs,headTiming:i.trimUnplaced.includes(`head`)?`estimated`:`rendered`,tailMs:i.range.endMs,tailTiming:i.trimUnplaced.includes(`tail`)?`estimated`:`rendered`,headMarker:g?.head??null,tailMarker:g?.tail??null}:{headMs:g?.head?Math.max(0,Gt(n,g.head)):0,headTiming:g?.head?`estimated`:`rendered`,tailMs:g?.tail?Math.min(c,Gt(n,g.tail)):c,tailTiming:g?.tail?`estimated`:`rendered`,headMarker:g?.head??null,tailMarker:g?.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??[])l.push(`A removed piece removed no frames: ${e.reason}.`);let v=new Set((i?.clampedRanges??[]).filter(e=>e.kind===`zoom`).map(e=>e.id));for(let e of i?.clampedRanges??[])l.push(e.note);let y=new Map((i?.cameraSegments??[]).map(e=>[e.id,e])),{smoothness:ee}=t.motion??ae,te=tt(ee),{zoomInMs:b}=ne(ee),re=new Set,ie=t.camera.flatMap(e=>{let t=e.scale??1;if(t<=1)return[];let r=y.get(e.id);r||re.add(e.id);let i=r?r.startMs:Math.max(0,Gt(n,e.marker)),a=r?r.endMs:Math.min(c,e.end?Gt(n,e.end):i+te),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,departMs:r?.departMs??i,startMs:i,endMs:a,drawnEndMs:a,endAuthored:e.end!==void 0,scale:t,target:o,aimFallback:e.note??null,timing:r?r.endUnplaced?`estimated`:p(e.marker):`estimated`,clamped:v.has(e.id),marker:e.marker,endMarker:e.end??null}]}),oe=ie.map(e=>{if(!re.has(e.id))return e;let t=Math.min(...ie.map(e=>e.startMs).filter(t=>t>e.startMs));return e.endMs>t?{...e,endMs:t}:e}),x=oe.map(e=>re.has(e.id)?{...e,departMs:qt(oe,e.startMs,b)}:e),se=x.map(e=>({...e,drawnEndMs:Jt(x,e.startMs,e.endMs)})),ce=new Set(t.camera.map(e=>e.marker.actionId));for(let e of t.zoomsSkipped??[])ce.has(e.actionId)||`afterActionId`in e&&!ce.has(e.afterActionId)||l.push(rt(e));let le=new Map((i?.cosmetics??[]).map(e=>[e.id,e])),S=t.edits.masks.map(e=>{let t=e.start===void 0||e.end===void 0,r=le.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,Gt(n,Wt(e.start))):0,u=t?c:a?a.endMs:e.end?Math.min(c,Gt(n,Wt(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}}),ue=e=>i?m(i.timeline,e):e,de=(r?.degradations??[]).map(e=>({startMs:ue(e.startMs),endMs:ue(e.endMs)}));for(let e of r?.degradations??[])l.push(Vt(e.kind,e.note,a,o));let fe=i?.timeline.unplacedPaces??0;if(fe>0){let e=fe===1?`pause`:`pauses`;l.push(`pacingUnplaced: ${fe} 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 C=i?.timeline.nonMonotonicPaces??0;if(C>0){let e=C===1?`pair`:`pairs`;l.push(`pacingBackwards: ${C} 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 ${C===1?`it`:`them`} twice and comes out longer than the take. Re-record to straighten the order; the frames you already have are unaffected.`)}let{pieces:pe,joins:me,unplacedSplits:he}=r!==null&&i!==null?Nt(t,r,i.timeline):{pieces:[],joins:[],unplacedSplits:[]};for(let e of he)l.push(`A split is not drawn: the last render carried no marker for its step. ${s(`to place it`)}`);return{clip:{durationMs:c,trim:_,ticks:h,degraded:de,pieces:pe,joins:me},zooms:se,masks:S,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:te,zoomInMs:b}}function qt(e,t,n){let r=0;for(let n of e)n.startMs>=t||(r=Math.max(r,n.endMs<t?n.endMs:n.startMs));return Math.max(r,t-n)}function Jt(e,t,n){return Math.min(n,...e.filter(e=>e.startMs>t).map(e=>e.departMs))}function Yt(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 Xt(e){let{resolved:t,outputTimeMs:n,presentation:r,target:a,viewport:o}=e;return oe(t,n,i(r.frameRect,o),r.frameRect,o,a)}var Zt=(e,t,n)=>Math.min(n,Math.max(t,e));function Qt(e,t){let n=e.width/2,r=e.height/2;return{x:Zt(t.x-n/2,0,e.width-n),y:Zt(t.y-r/2,0,e.height-r),width:n,height:r}}function $t(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,s=Xt({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o});return pe(t,s,i.frameRect,o)}function en(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,s=Xt({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o}),c=re(t,s,i.frameRect,o),l=Zt(c.x,0,o.width),u=Zt(c.y,0,o.height),d=Zt(c.x+c.width,0,o.width),f=Zt(c.y+c.height,0,o.height);return{x:l,y:u,width:d-l,height:f-u}}function tn(e){let{zoom:t,resolved:n,viewport:r,presentation:i,target:a}=e,o=Xt({resolved:n,outputTimeMs:(t.startMs+t.endMs)/2,presentation:i,target:a,viewport:r});return re({x:0,y:0,width:a.width,height:a.height},o,i.frameRect,r)}var nn=2e3,rn=e=>e!==null&&e.kind===`refusal`,D=e=>({kind:`refusal`,reason:e});function an(t,n){if(t.resolved===null||t.bundle===null)return{reason:`nothing has rendered yet`};if(t.bundle.cursorSamples.length===0)return{reason:`this take has no recorded pointer`};let r=se(t.resolved.timeline,n);if(t.bundle.cursorGaps.some(e=>r>=e.startMs&&r<e.endMs))return{reason:`the pointer was off the page here`};let i=e(t.resolved.cursor,r);return i?{point:i}:{reason:`the pointer was not observed here`}}var on=(e,t)=>e.zooms.find(e=>e.id===t),sn=(e,t)=>e.masks.find(e=>e.id===t);function cn(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=ln(a,i,n,r);if(e)return{zoom:a,why:e}}}function ln(e,t,n,r){let i=Math.abs(n-e.startMs);if(i<nt&&(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 un({zoom:e,why:t}){switch(t){case`start`:return D(`That would start it within ${nt}ms of the zoom "${e.id}" at ${dn(e.startMs)}; the camera needs ${nt}ms between two zooms to glide from one to the other.`);case`endsAfter`:return D(`That would end it after the zoom "${e.id}" starts at ${dn(e.startMs)}; a zoom can stay in until the next one, not past it.`);case`startsInside`:return D(`That would start it before the zoom "${e.id}" ends at ${dn(e.endMs)}; drag that zoom's end earlier first.`)}}var dn=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 fn(e){let{leadInMs:t}=S;return{earliestMs:e+t,latestMs:e}}function pn(e,t){let{leadInMs:n}=S,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}=fn(t);return e.zooms.find(e=>ln(e,void 0,n,null)!==void 0||ln(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+nt,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-nt;if(fn(e).earliestMs<0)break;let t=a(e);if(!t)return i(e,{zoom:s,side:`before`});s=t}return D(`There is no room for a zoom here: it would run into the zoom "${o.id}" at ${dn(o.startMs)}, and there is no slot either side of it. Drag that zoom to make space, or remove one.`)}function mn(e,t){let{trim:n}=e.clip;if(t>n.tailMs-200)return D(`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+nn,e.durationMs)}}function hn(e,t,n,r){let i=Yt(e,n,r),a=t.bundle?.markers.find(e=>e.actionId===i.actionId);return i.offsetMs===0||t.resolved===null||a===void 0?{actionId:i.actionId,sourceOffsetMs:i.offsetMs}:{actionId:i.actionId,sourceOffsetMs:Math.round(se(t.resolved.timeline,n)-a.sourceTimeMs)}}var gn=(e,t)=>e.actionId===t.actionId&&t.sourceOffsetMs<=e.sourceOffsetMs;function _n(e,t){return t!==null&&e.actionId===t.actionId&&t.offsetMs<=e.offsetMs}var vn=e=>D(`That would leave the ${e} no length; drag its end further.`),yn=e=>D(`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 bn(e,t){let n=e.clip.ticks,r=n.findIndex(e=>e.actionId===t);return r===-1?void 0:n[r+1]}function xn(e,t,n,r){let{durationMs:i}=e;if(e.clip.ticks.length===0)return D(`This take has no steps to attach an edit to.`);switch(n.kind){case`pieceEdge`:return Lt(r.bundle,r.resolved?.timeline??null,e.clip.pieces,n.start,n.side,n.deltaMs);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 D(`The cut would leave nothing: the head has to stay at least 200ms before the tail.`);let r=Yt(e,n.toMs,n.snapMs);return _n(r,t.tailMarker)?yn(`head`):{kind:`setTrim`,head:r}}if(n.toMs>=i)return{kind:`setTrim`,tail:null};if(n.toMs<t.headMs+200)return D(`The cut would leave nothing: the tail has to stay at least 200ms after the head.`);let r=Yt(e,n.toMs,n.snapMs);return t.headMarker&&_n(t.headMarker,r)?yn(`tail`):{kind:`setTrim`,tail:r}}case`addZoom`:{let i=pn(e,n.atMs);if(rn(i))return i;let{atMs:a,movedPast:o}=i,s=Yt(e,a,o?0:n.snapMs),c=o?`Placed ${o.side} the zoom at ${dn(o.zoom.startMs)}: there was no room at ${dn(n.atMs)}.`:null,l=S.defaultZoomScale,u=an(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 D(`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=on(e,n.id);if(!t)return D(`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 D(`A zoom cannot start before the take does.`);if(a>i)return D(`A zoom cannot end after the take does.`);let o=cn(e,t.id,r,t.endAuthored?a:null);if(o)return un(o);let s=Yt(e,r,n.snapMs),c=t.endAuthored?Yt(e,a,n.snapMs):null;return _n(s,c)?vn(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}case`zoomEdge`:{let t=on(e,n.id);if(!t)return D(`There is no zoom "${n.id}" to resize.`);if(n.edge===`start`){let r=Math.max(0,n.toMs);if(r>t.drawnEndMs-100)return D(`A zoom's start cannot cross its end; it would start after the zoom already ends. Drag the end later first.`);let i=r+e.zoomInMs;if(t.endAuthored&&i>t.endMs-100)return D(`Zooming in from there, it would land at ${dn(i)}, after its end at ${dn(t.endMs)}. Drag the end later first.`);let a=cn(e,t.id,i,null);if(a)return un(a);let o=Yt(e,r,n.snapMs),s={...o,offsetMs:o.offsetMs+e.zoomInMs},c=t.endMarker;return _n(s,c)?vn(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}if(n.toMs>i)return D(`A zoom cannot end after the take does.`);if(n.toMs<t.startMs+100)return D(`A zoom's end cannot cross its start; it would end before it starts. Drag the start earlier first.`);let r=cn(e,t.id,t.startMs,n.toMs);if(r)return un(r);let a=t.marker,o=Yt(e,n.toMs,n.snapMs);return _n(a,o)?vn(`zoom`):{kind:`setZoomRange`,id:t.id,start:a,end:o}}case`addMask`:{let t=mn(e,n.atMs);if(rn(t))return t;let{endMs:i}=t,a=an(r,n.atMs),o=`point`in a?a.point:{x:r.viewport.width/2,y:r.viewport.height/2},s=Qt(r.viewport,o),c=hn(e,r,n.atMs,n.snapMs),l=hn(e,r,i,n.snapMs);if(gn(c,l)){let t=bn(e,c.actionId);if(!t)return D(`That would leave the mask no length; move the playhead earlier.`);l={actionId:t.actionId,sourceOffsetMs: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=sn(e,n.id);if(!t)return D(`There is no mask "${n.id}" to move.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return D(`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 a=t.startMs+n.deltaMs,o=t.endMs+n.deltaMs;if(a<0)return D(`A mask cannot start before the take does.`);if(o>i)return D(`A mask cannot end after the take does.`);let s=hn(e,r,a,n.snapMs),c=hn(e,r,o,n.snapMs);return gn(s,c)?vn(`mask`):{kind:`setMaskRange`,id:t.id,start:s,end:c}}case`maskEdge`:{let t=sn(e,n.id);if(!t)return D(`There is no mask "${n.id}" to resize.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return D(`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 D(`A mask cannot start before the take does.`);if(n.toMs>t.endMs-100)return D(`A mask cannot start after it ends; drag its end later first.`);let i=hn(e,r,n.toMs,n.snapMs),a=t.endMarker;return gn(i,a)?vn(`mask`):{kind:`setMaskRange`,id:t.id,start:i,end:a}}if(n.toMs>i)return D(`A mask cannot end after the take does.`);if(n.toMs<t.startMs+100)return D(`A mask cannot end before it starts; drag its start earlier first.`);let a=t.startMarker,o=hn(e,r,n.toMs,n.snapMs);return gn(a,o)?vn(`mask`):{kind:`setMaskRange`,id:t.id,start:a,end:o}}}}function Sn(e,t,n){let r=e.beats.find(e=>e.actionId===t);return r===void 0?D(`There is no step "${t}" to pace.`):r.isLast?D(`"${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?D(`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}:D(`A pause has to be a number of milliseconds.`)}function Cn(e){return e.actions.map(e=>e.id).join(` `)}function wn(e){return{bundle:e.bundle,actionIds:Cn(e.scene)}}function Tn(e,t){return e!==null&&t.bundle===e.bundle&&Cn(t.scene)===e.actionIds&&t.hoverReport!==null}var En={removable:[],checked:0,unchecked:0,failed:!0};function Dn(e){return e.kind!==`unknown`||e.reason!==`notStyleSignalled`}function On(e,t){let n=e.filter(Dn).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 kn={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 An(e){return Object.entries(e.uncheckedBy??{}).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]).map(([e,t])=>{let n=kn[e];return`${t} ${t===1?n.one:n.many}`}).join(`, `)}function jn(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=An(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 Mn(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 Nn(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 Pn(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 Fn(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 In(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=Fn(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 Ln(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 Rn(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 zn(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60;return`${Math.floor(t/60)}:${String(n).padStart(2,`0`)}`}function Bn(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 Vn(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 Hn(e,t){return e===null||[...new Set([...Object.keys(t),...Object.keys(e)])].some(n=>t[n]!==e[n])}function Un(e,t){return e===null||e.smoothness!==t.smoothness||e.blur!==t.blur||e.follow!==t.follow}function Wn(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!Ee(r,i)||e.cornerRadius!==t.cornerRadius||!n(e.frameRect,t.frameRect)||e.logo?.image!==t.logo?.image||e.wallpaper?.image!==t.wallpaper?.image||e.logo?.opacity!==t.logo?.opacity||!n(e.logo?.rect,t.logo?.rect)}function Gn(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 Kn(){let e=new Map;return{isOpen:(t,n)=>e.get(t)??n,set:(t,n)=>{e.set(t,n)}}}var qn={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`},Jn={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`},Yn=new Set([`debuggerDetached`,`debuggerLost`,`debuggerRecovered`]),Xn=e=>Object.hasOwn(Jn,e)?Jn[e]:e;function Zn(e){let t=qn[e];if(t!==void 0)return t;let n=e.indexOf(`:`);if(n>0){let t=e.slice(0,n),r=qn[t],i=e.slice(n+1);if(r!==void 0&&i!==``)return`${r} — ${Yn.has(t)?Xn(i):i}`}return e}function Qn(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`${Zn(e.reason)}${n}`}var $n={anchorNotRendered:!0,anchorUnreachable:!0,cancelledByAuthor:!0,pageSilent:!0,pageFaulted:!0,clickNotDelivered:!0,mutating:!1,dragEndOutOfView:!1,dragNoDistance:!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 er(e){return e===null||e.reason===null?!1:$n[e.reason]===!0}function tr(e,t,n){if(e===null||e.reason===null||!t.mayReplay||e.reason===`mutating`)return null;let r=st(e.reason),i=n!==void 0&&dt(n),a=i?`The script run`:`The re-shoot`,o=i?`performed`:`reconstructed`,s=n?ut(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 ${ft(i)} to try again.`:`${a} ${o} all ${e.total} steps, but: ${r}.`;let l=er(e)?`and stopped early`:`then stopped`;return`${a} ${o} ${e.completed} of ${e.total} steps ${l}: ${r}.${c}`}function O(e,t){let n=e.actions.findIndex(e=>e.id===t);if(n===-1)throw Error(`unknown action "${t}"`);return n}function nr(e,t){let n=e.camera.find(e=>e.id===t);if(!n)throw Error(`unknown zoom "${t}"`);return n}var rr=1,ir=e=>Error(`1:1 is not a zoom — remove the zoom instead of authoring ${e}`);function ar(e,t,n){switch(t.kind){case`rename`:return{...e,meta:{...e.meta,name:t.name}};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]:(O(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,{...e,edits:r}}case`addZoom`:{if(O(e,t.marker.actionId),t.scale<=1)throw ir(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?S.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{...e,camera:[...e.camera,a]}}case`setZoomRange`:{let n=nr(e,t.id);O(e,t.start.actionId),t.end&&O(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{...e,camera:e.camera.map(e=>e.id===n.id?a:e)}}case`setZoomScale`:{let n=nr(e,t.id);if(t.scale<=1)throw ir(t.scale);return{...e,camera:e.camera.map(e=>e.id===n.id?{...e,scale:t.scale}:e)}}case`setZoomTarget`:{let n=nr(e,t.id),{anchorId:r,note:i,...a}=n;return{...e,camera:e.camera.map(e=>e.id===n.id?{...a,point:{x:t.point.x,y:t.point.y}}:e)}}case`removeZoom`:return nr(e,t.id),{...e,camera:e.camera.filter(e=>e.id!==t.id)};case`addMask`:return O(e,t.start.actionId),O(e,t.end.actionId),{...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(O(e,t.start.actionId),O(e,t.end.actionId),!e.edits.masks.some(e=>e.id===t.id))throw Error(`unknown mask "${t.id}"`);return{...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<rr||t.rect.height<rr)throw Error(`That drag left the mask off the frame — nothing would be covered. Drag it back over the picture.`);return{...e,edits:{...e.edits,masks:e.edits.masks.map(e=>e.id===t.id?{...e,rect:t.rect}:e)}};case`setMaskNote`:return{...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{...e,edits:{...e.edits,masks:e.edits.masks.filter(e=>e.id!==t.id)}};case`setBranding`:return{...e,branding:Ne(e.branding,t.patch)};case`setCursor`:return{...e,cursor:{...e.cursor,...t.patch}};case`setMotion`:return{...e,motion:{...e.motion??ae,...t.patch}};case`setAspect`:return{...e,canvas:{...e.canvas,aspect:t.aspect}};case`split`:return O(e,t.at.actionId),{...e,edits:{...e.edits,splits:[...e.edits.splits??[],{id:n(),at:t.at}]}};case`removePiece`:if(t.start===null&&t.end===null)throw Error(`Removing the whole take would leave nothing to export.`);return t.start&&O(e,t.start.actionId),t.end&&O(e,t.end.actionId),{...e,edits:{...e.edits,removed:[...e.edits.removed??[],{id:n(),start:t.start,end:t.end}]}};case`restorePiece`:{let n=e.edits.removed??[];if(!n.some(e=>e.id===t.id))throw Error(`there is no removed piece "${t.id}" to restore`);return{...e,edits:{...e.edits,removed:n.filter(e=>e.id!==t.id)}}}case`setRemovedEdge`:{let n=e.edits.removed??[],r=n.find(e=>e.id===t.id);if(r===void 0)throw Error(`there is no removed piece "${t.id}" to move`);t.start&&O(e,t.start.actionId),t.end&&O(e,t.end.actionId);let i={...r,...t.start===void 0?{}:{start:t.start},...t.end===void 0?{}:{end:t.end}};if(i.start===null&&i.end===null)throw Error(`Removing the whole take would leave nothing to export.`);return{...e,edits:{...e.edits,removed:n.map(e=>e.id===t.id?i:e)}}}case`setGap`:{if(O(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{...e,edits:{...e.edits,gaps:i?r.map(e=>e.id===i.id?a:e):[...r,a]}}}case`clearGap`:return{...e,edits:{...e.edits,gaps:(e.edits.gaps??[]).filter(e=>e.afterActionId!==t.afterActionId)}}}}function or(e,t,n){return te.parse(ar(e,t,n))}function sr(e){return{scene:e,past:[],future:[],error:null,dirty:!1,hoverReport:null}}function cr(e,t,n){let r;try{r=or(e.scene,t,n)}catch(t){return{...e,error:t instanceof Error?t.message:String(t)}}return t.kind===`setBranding`&&Ve(e.scene.branding,r.branding)?{...e,error:null}:{scene:r,past:[...e.past,e.scene].slice(-50),future:[],error:null,dirty:!0,hoverReport:t.kind===`removePiece`||t.kind===`restorePiece`||t.kind===`setRemovedEdge`?null:e.hoverReport}}function lr(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],error:null,dirty:!0,hoverReport:null}:e}function ur(e){let[t,...n]=e.future;return t?{...e,scene:t,past:[...e.past,e.scene].slice(-50),future:n,error:null,dirty:!0,hoverReport:null}:e}function dr(e){return{...e,dirty:!1}}var fr={mayReplay:!0};function pr(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 mr(e,t){return e.meta===void 0||e.flags===void 0?!1:pr(e)===pr(t)}function hr(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(pr(e)),JSON.parse(pr(t)),`scene`)}function gr(e,t){let{renderMode:n,...r}=e.meta;return{...e,meta:t.meta.renderMode===void 0?r:{...r,renderMode:t.meta.renderMode}}}function _r(e,t){return{...gr(e,t),flags:{...e.flags,hoverSensitive:t.flags.hoverSensitive}}}function vr(e){let t=sr({}),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:tr(i,fr,t.scene),replayRecoverable:er(i),captureSentence:a===null||n!==null&&n.source!==`capture`?null:Qn(a),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=gr(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=mr(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 ${hr(t.scene,o)}`),t=c?{...sr(o),past:t.past.map(e=>_r(e,o)),future:t.future.map(e=>_r(e,o))}:sr(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=cr(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=dr(t),u()})},async undo(){await c(async()=>{let e=lr(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=dr(t),u()})},async redo(){await c(async()=>{let e=ur(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=dr(t),u()})},async settled(){let e;do e=s,await e;while(e!==s)},setHoverReport(e){t={...t,hoverReport:e},u()}}}var yr=1.2;function br(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:r===`b`&&!e.shiftKey?{kind:`split`}:!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`}:null:n===`+`||n===`=`?t.hasTimeline?{kind:`zoomTimeline`,factor:yr}:null:n===`-`||n===`_`?t.hasTimeline?{kind:`zoomTimeline`,factor:1/yr}: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 xr={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`}},Sr=(e,t)=>typeof e==`string`?e:t?e.mac:e.other;function Cr(e,t){let n=xr[e];return n===void 0?e:Sr(n.label,t)}var wr=new Set([`⌘`,`⇧`,`⌫`,`←`,`→`,`↑`,`↓`]);function Tr(e){return wr.has(e)}function Er(e,t){let n=xr[e];return n===void 0?e:Sr(n.spoken,t)}function Dr(e,t){return e.map(e=>Er(e,t)).join(` plus `)}function Or(e){return/\bMac/i.test(e)}function kr(e,t){return Sr(e.description,t)}var Ar=[{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:`Trim`,combos:[[`I`],[`O`]],description:`Trim start / end to playhead`,action:`setTrim`},{group:`Editing`,combos:[[`Mod`,`B`]],description:`Split at playhead`,action:`split`},{group:`Editing`,combos:[[`Delete`]],description:`Delete the selected piece, zoom or mask`,action:`deleteSelection`},{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 jr(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 Mr=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],Nr=3;function Pr(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 Fr(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 Ir(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=jr(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=w(`div`,`overlay`);a.setAttribute(`data-overlay`,`mask`);let c=$t({rect:i.rect,...s});Pr(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)>Nr&&(l=!0),c=Fr(r,t,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Pr(a,c,o)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),l&&n.onMaskRect(i.id,en({rect:c,...s}))};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)})};l(a,`body`);for(let e of Mr){let t=w(`div`,`grip`);t.setAttribute(`data-handle`,e),l(t,e),a.append(t)}e.append(a);return}if(r.kind!==`zoom`)return;let c=t.model.zooms.find(e=>e.id===r.id);if(!c)return;let l=w(`div`,`overlay`);l.setAttribute(`data-overlay`,`zoom`);let u=$t({rect:tn({zoom:c,resolved:i,viewport:i.plan.viewport,presentation:a,target:t.target}),...s});Pr(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)>Nr&&(r=!0),u=Fr(t,`body`,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Pr(l,u,o)},a=()=>{if(window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),!r)return;let e=en({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 Lr(e){let{scene:t,resolved:n,bundle:i=null}=e,a=new Map(t.anchors.map(e=>[e.id,e])),o=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??S.defaultZoomScale,offsetMs:e.marker.offsetMs}])),s=new Map((t.edits.gaps??[]).map(e=>[e.afterActionId,e])),l=new Map((t.edits.holds??[]).map(e=>[e.marker.actionId,e])),u=n?new Set(n.plan.removedSteps??[]):ue(t),d=new Map((i?.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),f=(e,t)=>{if(n===null||i===null||!r(i)||c(i,e.id))return!0;let a=d.get(e.id),o=d.get(t.id);return a===void 0||o===void 0||n.timeline.segments.some(e=>e.kind===`idle`&&e.srcEndMs>e.srcStartMs&&a<=e.srcStartMs&&e.srcEndMs<=o)},p=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},h=(e,t)=>{if(t===void 0)return 0;if(n===null||i===null)return null;let r=d.get(e.id),a=d.get(t.id);if(r===void 0||a===void 0)return null;let o=p(a);for(let e of n.timeline.segments)e.kind===`idle`&&r<=e.srcStartMs&&e.srcEndMs<=a&&(o+=e.outEndMs-e.outStartMs);return o},g=(e,t)=>{if(t===void 0||n===null||i===null||r(i))return null;let a=d.get(t.id);return d.get(e.id)===void 0||a===void 0?null:p(a)},_=t.actions.length-1;return{beats:t.actions.map((e,c)=>{let v=e.anchorId?a.get(e.anchorId):void 0,y=o.get(e.id),ee=s.get(e.id),te=l.get(e.id),b=t.actions[c+1],ne=d.get(e.id);return{actionId:e.id,index:c,verb:e.kind,anchorId:e.anchorId,label:ct(v),text:e.kind===`type`?e.text:null,redacted:e.kind===`type`&&e.redacted,host:e.kind===`type`&&e.host===!0,strategy:v?.resolution.strategy??null,outputMs:n?m(n.timeline,ne??e.timestamp):null,timing:ne===void 0?`estimated`:`rendered`,captureMs:e.timestamp,camera:y??null,canZoom:e.anchorId!==null,gap:ee?{durationMs:ee.durationMs}:null,canPace:b!==void 0&&f(e,b),renderedPauseMs:h(e,b),renderedPaceFreezeMs:g(e,b),renderedFreezeBeforeMs:i!==null&&!r(i)&&ne!==void 0&&n!==null&&ne<n.timeline.sourceDurationMs?p(ne):0,legacyHold:te?{offsetMs:te.marker.offsetMs,durationMs:te.durationMs}:null,cut:u.has(e.id),isLast:c===_}}),outputDurationMs:n?.timeline.outputDurationMs??null,hasBundle:n!==null}}var Rr=(e,t,n)=>Math.min(n,Math.max(t,e)),zr=e=>({startMs:0,endMs:Math.max(250,e)}),k=(e,t)=>(t-e.startMs)/(e.endMs-e.startMs),Br=(e,t)=>e.startMs+t*(e.endMs-e.startMs);function Vr(e,t,n,r){let i=Math.max(250,r),a=Rr(n,250,i),o=Rr(e-t*a,0,i-a);return{startMs:o,endMs:o+a}}function Hr(e,t,n,r){return Vr(Br(e,r),r,(e.endMs-e.startMs)/n,t)}function Ur(e,t,n){let r=e.endMs-e.startMs;return Vr(e.startMs+n,0,r,t)}var Wr=(e,t,n,r)=>Vr(Br(e,r),r,n,t);function Gr(e,t){let n=Math.max(250,e);return n*(250/n)**Rr(t,0,1)}function Kr(e,t){let n=Math.max(250,e);if(n<=250)return 0;let r=Rr(t,250,n);return Math.log(r/n)/Math.log(250/n)}function qr(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`;case`−`:return`-`;default:return e}}function Jr(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=Or(navigator.userAgent);e.setAttribute(`aria-keyshortcuts`,n.map(e=>qr(e,r)).join(`+`))}function Yr(e){delete e.dataset.tip,delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`)}var Xr=Symbol.for(`demoman.tooltip`);function Zr(e=document){let t=e,n=t[Xr];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[Xr]={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=Or(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=Cr(n,r),a=e.createElement(`kbd`);a.className=`keycap`,a.textContent=i,Tr(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 Qr(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-export-panel`,``),e.append(w(`h2`,void 0,`Export`));let t=w(`div`);return t.setAttribute(`data-panel-export`,``),e.append(t),e}function $r(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-background-panel`,``),e.append(w(`h2`,void 0,`Background`));let t=w(`div`);return t.setAttribute(`data-panel-branding`,``),e.append(t),e}function ei(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-shortcuts-panel`,``),e.append(w(`h2`,void 0,`Keyboard shortcuts`));let t=w(`div`);return t.setAttribute(`data-panel-shortcuts`,``),e.append(t),e}function ti(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-cursor-panel`,``),e.append(w(`h2`,void 0,`Cursor`));let t=w(`div`);return t.setAttribute(`data-panel-cursor`,``),e.append(t),e}function ni(e,t,n){let r=w(`div`,`beat-panel`);r.setAttribute(`data-step-panel`,e.actionId);let i=w(`h2`);if(i.append(w(`span`,`verb`,e.verb),` `,e.label),e.strategy){let t=w(`span`,`chip`,e.strategy);t.setAttribute(`data-health`,e.strategy),i.append(` `,t)}r.append(i);let a=w(`div`);if(e.verb===`type`){if(e.redacted)a.append(w(`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.`:`This value was never recorded — a credential field, or text that looked like a secret.`));else{let t=w(`div`,`control-row`),n=w(`span`,void 0,e.text??``);n.setAttribute(`data-typed-text`,e.actionId),t.append(w(`span`,`control-label`,`Typed text`),n),a.append(t)}}e.timing===`estimated`&&a.append(w(`div`,`muted`,`Not in the video: the frames have no marker for this step, so the timeline places it from the take's own timestamp.`)),a.hasChildNodes()&&r.append(a);let o=w(`div`,`control-actions`);if(!e.canZoom)o.append(w(`span`,`muted`,`No zoom — nothing on screen to aim at`));else{let t=w(`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)),o.append(t)}r.append(o);let s=()=>{let t=w(`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},c=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(c===null){let t=w(`label`,`control-row`),i=w(`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=w(`span`,`control-inline`);if(a.append(i,w(`span`,void 0,`ms`)),e.gap!==null&&a.append(s()),t.append(w(`span`,`control-label`,`Pause after this step`),a),r.append(t),e.gap!==null&&e.gap.durationMs>0&&e.renderedPaceFreezeMs===0){let t=w(`div`);t.setAttribute(`data-gap-floored`,e.actionId),t.append(w(`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=w(`div`);t.setAttribute(`data-gap-inert`,e.actionId),t.append(w(`span`,void 0,`A ${e.gap.durationMs}ms pause is set here but is not playing. ${c}`),s()),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=w(`div`);i.setAttribute(`data-legacy-hold`,e.actionId),i.append(w(`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)}if(e.cut){let n=w(`div`);n.setAttribute(`data-cut-panel`,e.actionId),n.append(w(`p`,`honesty`,`This step is in a removed piece, so it is not in the video.`));let i=t.attachedToCuts.filter(t=>t.actionId===e.actionId);if(i.length>0){let t=[...i].map(e=>e.kind).sort(),r=i.length===1,a=w(`p`,`muted`,`${i.length} edit${r?``:`s`} on this step (${t.join(`, `)}) ${r?`is`:`are`} kept and not drawn. Restoring the piece brings ${r?`it`:`them`} back.`);a.setAttribute(`data-cut-attached`,e.actionId),n.append(a)}r.append(n)}let l=w(`div`,`control-actions`);if(t.hoverReport?.removable.includes(e.actionId)??!1){let t=w(`button`,`btn btn-quiet`,`Keep this hover`);t.type=`button`,t.setAttribute(`data-keep-hover`,e.actionId),t.addEventListener(`click`,()=>n.onKeepHover(e.actionId)),l.append(t)}return l.hasChildNodes()&&r.append(l),r}function ri(e,t,n){let r=w(`div`,`zoom-panel`);r.setAttribute(`data-zoom-panel`,e.id),r.append(w(`h2`,void 0,`Zoom`));let i=w(`input`);i.type=`range`,i.min=`1.1`,i.max=String(S.maxScale),i.step=`0.05`,i.value=String(e.scale),i.setAttribute(`data-zoom-scale`,e.id),i.setAttribute(`aria-label`,`Zoom level`),ze(i),i.addEventListener(`input`,()=>ze(i)),i.addEventListener(`change`,()=>n.onZoomScale(e.id,Number(i.value)));let a=w(`div`,`slider-row`);a.append(w(`span`,`control-label slider-label`,`Level`),w(`span`,`slider-value`,`${e.scale.toFixed(2)}x`),i),r.append(a);let o=w(`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?ct(r):n}`}else o.textContent=`Aims at the cursor at ${zn(e.startMs)}`;if(r.append(o),e.aimFallback!==null){let t=w(`div`,`muted`,e.aimFallback);t.setAttribute(`data-zoom-fallback`,``),r.append(t)}let s=w(`div`);s.setAttribute(`data-zoom-range`,``),s.textContent=`${zn(e.startMs)} to ${zn(e.endMs)}${e.endAuthored?``:` (end automatic; drag its cap to set one)`}`,r.append(s),e.clamped&&r.append(w(`div`,`muted`,`The end you set could not be reached; see the note under the timeline.`)),e.timing===`estimated`&&r.append(w(`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=w(`button`,`btn btn-quiet`,`Remove zoom`);c.type=`button`,c.setAttribute(`data-remove-zoom`,e.id),Jr(c,`Remove zoom`,[`Delete`]),c.addEventListener(`click`,()=>n.onRemoveZoom(e.id));let l=w(`div`,`control-actions`);return l.append(c),r.append(l),r}function ii(e,t,n){let r=w(`div`,`mask-panel`);r.setAttribute(`data-mask-panel`,e.id),r.append(w(`h2`,void 0,`Mask`));let i=w(`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=w(`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=w(`label`,`control-row`);o.append(w(`span`,`control-label`,`Note`),a),r.append(o);let s=w(`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=`${zn(e.startMs)} to ${zn(e.endMs)}`,r.append(s),r.append(w(`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=w(`button`,`btn btn-quiet`,`Remove mask`);c.type=`button`,c.setAttribute(`data-remove-mask`,e.id),Jr(c,`Remove mask`,[`Delete`]),c.addEventListener(`click`,()=>n.onRemoveMask(e.id));let l=w(`div`,`control-actions`);return l.append(c),r.append(l),r}function ai(e,t,n){let{selection:r,rail:i}=t;if(i===`shortcuts`&&e.querySelector(`:scope > .inspector > [data-shortcuts-panel]`)!==null)return;let a=w(`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=ni(o,t,n):s?l=ri(s,t,n):c?l=ii(c,t,n):(console.error(`[demoman] editor: the rail is on Selection with nothing selected`),l=Qr()):l=i===`background`?$r():i===`cursor`?ti():i===`shortcuts`?ei():Qr();let u=w(`button`,`btn btn-icon inspector-close`);u.type=`button`,u.setAttribute(`data-inspector-close`,``),u.setAttribute(`aria-label`,`Close panel`),Jr(u,`Close`,[`Esc`]),u.append(x(`close`)),u.addEventListener(`click`,()=>n.onClose()),a.append(u,l),e.replaceChildren(a)}var oi=[{entry:`background`,label:`Background`,glyph:`image`},{entry:`cursor`,label:`Cursor`,glyph:`mousePointer2`},{entry:`selection`,label:`Selection`,glyph:`mousePointerClick`}],si=`Select a step, zoom or mask on the timeline`;function ci(e,t,n){let r=oi.map(({entry:e,label:r,glyph:i})=>{let a=w(`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?si:r,a.append(x(i)),a.addEventListener(`click`,()=>n.onPick(e)),a});e.replaceChildren(...r)}function li(e,t,n){e.querySelector(`svg[data-icon]`)===null&&e.replaceChildren(x(`download`),w(`span`,void 0,`Export`)),e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`export`)),e.onclick=()=>n.onPick(`export`)}function ui(e,t,n){e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`shortcuts`)),e.onclick=()=>n.onPick(`shortcuts`)}function di(e,t,n){switch(e.phase){case`idle`:return ke[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 fi(e){let t=e/1048576;return t>=1?`${Math.round(t*10)/10} MB`:`${Math.max(1,Math.round(e/1024))} KB`}var pi=1e3,mi=new Map;function hi(e){let{key:t,checked:n}=e,r=document.createElement(`span`);r.className=`switch`;let i=document.createElement(`input`);i.type=`checkbox`,i.checked=n,i.disabled=e.disabled??!1,i.setAttribute(`role`,`switch`),i.setAttribute(`aria-checked`,n?`true`:`false`);for(let[t,n]of Object.entries(e.attrs??{}))i.setAttribute(t,n);let a=document.createElement(`span`);a.className=`switch-track`,a.setAttribute(`aria-hidden`,`true`),r.append(i,a);let o=performance.now(),s=mi.get(t);if(s!==void 0&&o-s.at>pi)mi.delete(t);else if(s!==void 0){let e=s.on===n?o-s.at:0;s.on!==n&&mi.set(t,{on:n,at:o}),r.setAttribute(`data-flip`,``),r.style.setProperty(`--switch-elapsed`,`${-e}ms`)}return a.addEventListener(`animationend`,()=>r.removeAttribute(`data-flip`)),i.addEventListener(`click`,()=>{r.removeAttribute(`data-flip`),mi.set(t,{on:i.checked,at:performance.now()}),e.onChange(i.checked)}),r}function gi(e,t,n){let r=document.createElement(`label`);r.className=`switch-row`;let i=document.createElement(`span`);i.className=`switch-text`;let a=document.createElement(`strong`);if(a.textContent=e,i.append(a),t!==null){let e=document.createElement(`span`);e.className=`hint`,e.textContent=t,i.append(e)}return r.append(i,n),r}function _i(e,t){let n=t.hoverReport===null?null:jn(t.hoverReport);if(t.notices.length===0&&n===null){e.replaceChildren();return}let r=w(`div`,void 0);r.setAttribute(`data-take-notes`,``);for(let e of t.notices){let t=w(`div`,`notice`);C(t,e),t.setAttribute(`data-take-notice`,``),r.append(t)}if(n!==null){let e=w(`div`,`notice`,n);e.setAttribute(`data-hover-report`,``),r.append(e)}e.replaceChildren(r)}function vi(e,t){if(t.hasFrames){e.replaceChildren();return}let n=w(`div`,`banner`),r=w(`span`);r.append(yi(t.route)),n.append(r),e.replaceChildren(n)}function yi(e){let t=document.createDocumentFragment();return t.append(`This take has no frames — `,bi(e,ft(e.authored))),t}function bi(e,t){if(e.rerun.kind===`line`){let t=w(`span`);return C(t,e.rerun.text),t.setAttribute(`data-rerun-line`,``),t}let n=w(`a`,void 0,t);return n.setAttribute(`href`,e.rerun.href),n.setAttribute(`data-runs-route`,``),n}function xi(e,t){let n=[];if(t.openError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-open-error`,``),e.append(w(`strong`,void 0,`This take could not be opened`)),e.append(w(`div`,void 0,t.openError)),n.push(e)}if(t.replaySentence!==null){let e=w(`div`,`notice`);e.setAttribute(`data-replay-failure`,``);let r=t.runsRoute?.authored===!0?`script run`:`re-shoot`;if(e.append(w(`strong`,void 0,t.replayRecoverable===!0?`The last ${r} stopped early`:`The last ${r} did not finish`)),e.append(w(`div`,void 0,t.replaySentence)),t.runsRoute!=null){let n=w(`div`);n.setAttribute(`data-replay-runs-route`,``),n.append(bi(t.runsRoute,Tt(t.runsRoute.authored))),e.append(n)}n.push(e)}if(t.captureSentence!=null){let e=w(`div`,`notice`);e.setAttribute(`data-capture-note`,``),e.append(w(`strong`,void 0,`What this take recorded`)),e.append(w(`div`,void 0,t.captureSentence)),n.push(e)}if(t.renderError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-render-error`,``),e.append(w(`strong`,void 0,`The export did not start`)),e.append(w(`div`,void 0,t.renderError)),n.push(e)}if(t.previewError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-preview-error`,``),e.append(w(`strong`,void 0,`The preview stopped`)),e.append(w(`div`,void 0,t.previewError)),n.push(e)}if(t.logoLoadError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-logo-load-error`,``),e.append(w(`strong`,void 0,`The logo could not be loaded`)),e.append(w(`div`,void 0,t.logoLoadError)),n.push(e)}if(t.wallpaperLoadError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-wallpaper-load-error`,``),e.setAttribute(`role`,`alert`),e.append(w(`strong`,void 0,`The background image could not be loaded`)),e.append(w(`div`,void 0,t.wallpaperLoadError)),n.push(e)}if(t.error!==null){let e=w(`div`,`notice`);e.setAttribute(`data-action-error`,``),e.append(w(`strong`,void 0,`That edit did not go through`)),e.append(w(`div`,void 0,t.error)),n.push(e)}if(t.deleteError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-delete-error`,``),e.append(w(`strong`,void 0,`This demo was not deleted`)),e.append(w(`div`,void 0,t.deleteError)),n.push(e)}if(t.navigationError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-navigation-error`,``),e.append(w(`strong`,void 0,`The ${t.navigationError.page} did not open`)),e.append(w(`div`,void 0,t.navigationError.reason)),n.push(e)}e.replaceChildren(...n)}function Si(e,t,n){De(e,t,n)}var Ci={light:`Light`,dark:`Dark`,touch:`Touch`},wi={light:1/16,dark:1/16,touch:0};function Ti(e,t,n){let{height:r,hotspot:i,ink:a}=u[e],o=r*t,s={x:(a.min.x+a.max.x)/2,y:(a.min.y+a.max.y)/2};return{x:n/2-(s.x-i.x-wi[e])*o,y:n/2-(s.y-i.y)*o}}var Ei=.6;function Di(e,t,n){return Math.min(Math.min(2,Math.max(.5,t))*Ei,n/u[e].height)}function Oi(e,t){let n=w(`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=Di(e,t,44);return o(r,Ti(e,i,44),i,f,e),n}function ki(e,t,n,r,i,a,o,s){let c=w(`div`,`slider-row`),l=w(`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=w(`span`,`slider-value`,a(n));ze(l),l.addEventListener(`input`,()=>{ze(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(w(`span`,`control-label slider-label`,t),u,l),c}var Ai=e=>`${Math.round(e*100)}%`,ji=e=>`${e.toFixed(2)}x`;function Mi(e,t,n,r,i,a,o,s,c){return ki(e,t,n,r,i,a,{preview:e=>s.onCursorPreview({[o]:e}),commit:e=>s.onCursor({[o]:e}),end:()=>s.onCursorPreviewEnd()},c)}function Ni(e,t,n,r,i){return ki(e,t,n,0,1,Ai,{preview:e=>i.onMotionPreview({[r]:e}),commit:e=>i.onMotion({[r]:e}),end:()=>i.onMotionPreviewEnd()},!1)}function Pi(e,t,n,r,i,a){return gi(t,null,hi({key:r,checked:n,disabled:a,attrs:{[e]:``},onChange:e=>i.onCursor({[r]:e})}))}function Fi(e,t,n,r,i=!1){let a=w(`div`),o=t.hidden;a.append(Pi(`data-cursor-hidden`,`Hide cursor`,t.hidden,`hidden`,r,!1));let s=Mi(`data-cursor-scale`,`Size`,t.scale,.5,2,ji,`scale`,r,o);i&&a.append(s);let c=w(`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=w(`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`,Ci[e]),n.title=Ci[e],n.append(Oi(e,t.scale)),n.addEventListener(`click`,()=>r.onCursor({style:e})),c.append(n)}i||a.append(w(`div`,`cursor-label`,`Style`),c),i||a.append(s,Mi(`data-cursor-blur`,`Motion blur`,t.motionBlur,0,1,Ai,`motionBlur`,r,o),Mi(`data-cursor-tilt`,`Tilt`,t.tilt??_.tilt,0,1,Ai,`tilt`,r,o),Mi(`data-cursor-bounce`,`Click bounce`,t.clickBounce??_.clickBounce,0,2,ji,`clickBounce`,r,o),Pi(`data-cursor-idle`,`Hide when not moving`,t.hideWhenIdle,`hideWhenIdle`,r,o)),a.append(w(`div`,`cursor-label camera-label`,`Camera`),Ni(`data-motion-smoothness`,`Smoothness`,n.smoothness,`smoothness`,r),Ni(`data-motion-blur`,`Camera blur`,n.blur,`blur`,r),gi(`Follow cursor`,null,hi({key:`motion-follow`,checked:n.follow,attrs:{"data-motion-follow":``},onChange:e=>r.onMotion({follow:e})}))),e.replaceChildren(a)}function Ii(){let e=w(`progress`,`export-progress`);return e.setAttribute(`data-export-progress`,``),e.setAttribute(`aria-label`,`Export progress`),e}function Li(e,t){return e.phase!==`idle`||t.kind===`noFrames`}function Ri(e,t,n,r){let i=e.querySelector(`[data-export-start]`);if(i===null)return!1;i.textContent=di(t,n,r),i.disabled=Li(t,r);let a=e.querySelector(`[data-export-progress]`);if(t.phase!==`encoding`||t.total===0)return a?.remove(),!0;let o=a??Ii();return o.max=t.total,o.value=t.done,a===null&&i.closest(`.control-actions`)?.after(o),!0}function zi(e,t,n){let r=w(`div`),i=t.run.phase!==`idle`;if(t.hasReclaimedMotion){let e=w(`p`,`notice`,`This export will use still frames where motion was reclaimed.`);e.setAttribute(`data-reclaimed-motion-notice`,``),r.append(e)}let a=w(`p`,`export-summary`,je(t.fileType,t.durationMs));a.setAttribute(`data-export-summary`,``);let o=w(`p`,`muted`,Be(t.aspect));o.setAttribute(`data-aspect-note`,``),r.append(a,o);let s=w(`p`,`muted`,Re(t.recording,t.target));s.setAttribute(`data-size-readout`,``),r.append(s);let c=w(`div`,`control-row`);c.append(w(`span`,`control-label`,`File type`));let l=w(`div`,`segmented`);l.setAttribute(`role`,`radiogroup`),l.setAttribute(`aria-label`,`File type`),l.setAttribute(`data-file-types`,``);for(let e of[`mp4`,`gif`,`stills`]){let r=w(`button`,`segment`,Ie[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)),l.append(r)}if(c.append(l),r.append(c),t.quality!=null&&t.fileType===`mp4`){let e=w(`div`,`control-row`);e.append(w(`span`,`control-label`,`Quality`));let a=w(`div`,`segmented`);a.setAttribute(`role`,`radiogroup`),a.setAttribute(`aria-label`,`Quality`),a.setAttribute(`data-export-qualities`,``);for(let e of be){let r=w(`button`,`segment`,Pe[e]);r.type=`button`,r.setAttribute(`role`,`radio`),r.setAttribute(`data-export-quality`,e),r.setAttribute(`aria-checked`,String(e===t.quality)),r.disabled=i,r.addEventListener(`click`,()=>n.onQuality(e)),a.append(r)}e.append(a),r.append(e)}let u=w(`button`,`btn btn-primary export-start`,di(t.run,t.fileType,t.readiness));u.type=`button`,u.setAttribute(`data-export-start`,``),u.setAttribute(`data-readiness`,t.readiness.kind),u.disabled=Li(t.run,t.readiness),u.addEventListener(`click`,n.onExport);let d=w(`div`,`control-actions`);if(d.append(u),t.readiness.kind===`noFrames`){let e=w(`p`,`muted`);e.setAttribute(`data-export-no-frames`,``),e.append(yi(t.runsRoute)),r.append(d,e)}else r.append(d);if(t.run.phase===`encoding`&&t.run.total>0){let e=Ii();e.max=t.run.total,e.value=t.run.done,r.append(e)}if(t.save!==null&&r.append(Xi(t.save,n)),t.revealError!=null){let e=w(`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`&&Ui(r,n.output,t)}e.replaceChildren(r)}function Bi(e,t,n){let r=document.createDocumentFragment(),i=t.showAll?t.outputs:t.outputs.slice(0,5);for(let e of i){let i=w(`div`,`output`);if(i.setAttribute(`data-output`,e.kind===`file`?e.key:e.output.ref),r.append(i),e.kind===`file`){Ji(i,e,t,n);continue}let a=e.output,o=w(`div`,`beat`),s=a.sceneDigest!==void 0&&a.sceneDigest!==t.currentDigest,c=t.warningsOpen.has(a.ref);o.append(Ki(a.name,[s?Gi(a.ref):null,Hi(a.ref,Vi(a),c,n)]));let l=w(`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(qi(a.ref,[fi(a.byteLength),Wi(a.renderedAt)],null)),c&&Vi(a)>0){let e=w(`div`,`output-warnings`);e.setAttribute(`data-output-warnings-body`,a.ref),Ui(e,a,t.reportContext),i.append(e)}}let a=t.outputs.length-i.length;if(a>0){let e=w(`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 Vi(e){return[e.detailViolations.length>0,e.logoWarning!==void 0,(e.unavailableSpans??[]).length>0,(e.unplacedStills??[]).length>0].filter(Boolean).length}function Hi(e,t,n,r){if(t===0)return null;let i=w(`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 Ui(e,t,n){if(t.detailViolations.length>0){let{heading:r,lines:i}=Ct(t.detailViolations,n.beatAt),a=w(`div`,`notice`);a.setAttribute(`data-violations`,t.ref),a.append(w(`strong`,void 0,r));for(let e of i)a.append(w(`div`,void 0,e));a.append(w(`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=w(`div`,`notice`);n.setAttribute(`data-logo-warning`,t.ref),n.append(w(`div`,void 0,t.logoWarning)),e.append(n)}let r=t.unavailableSpans??[];if(r.length>0){let i=w(`div`,`notice`);i.setAttribute(`data-unavailable`,t.ref);let a=r.every(e=>e.reason===yt),o=w(`strong`);C(o,a?`Motion was reclaimed to free space and shown as a still. ${Ot(n.runsRoute.authored,Dt(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(w(`div`,void 0,`${e.ref}: ${e.reason}`));e.append(i)}let i=t.unplacedStills??[];if(i.length>0){let n=w(`div`,`notice`);n.setAttribute(`data-unplaced-stills`,t.ref);let r=i.every(e=>e.reason.includes(`cut`));n.append(w(`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(w(`div`,void 0,`${e.actionId}: ${e.reason}`));e.append(n)}}function Wi(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?e:Je(n,n.getFullYear()!==t.getFullYear())}function Gi(e){let t=w(`span`,`chip`,`Outdated`);return t.setAttribute(`data-stale-export`,e),t.title=`Made before your last edit`,t}function Ki(e,t){let n=w(`span`,`output-head`),r=w(`span`,`output-name`,e);r.title=e,n.append(r);for(let e of t)e!==null&&n.append(e);return n}function qi(e,t,n){let r=w(`div`,`muted output-meta`,t.join(` · `));return r.setAttribute(`data-output-meta`,e),n!==null&&(r.title=n),r}function Ji(e,t,n,r){let i=w(`div`,`beat`),a=n.warningsOpen.has(t.key);if(i.append(Ki(t.name,[t.sceneDigest===n.currentDigest?null:Gi(t.key),Hi(t.key,t.caveats.length,a,r)])),t.exists){let e=w(`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=w(`span`,`muted`,`moved or deleted`);e.setAttribute(`data-output-gone`,``),i.append(e)}if(e.append(i),e.append(qi(t.key,[fi(t.byteLength),Wi(t.renderedAt)],t.detail)),a&&t.caveats.length>0){let n=w(`div`,`notice output-warnings`);n.setAttribute(`data-output-warnings-body`,t.key);for(let e of t.caveats)n.append(w(`div`,void 0,Yi(e)));e.append(n)}}function Yi(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return/[.!?]$/.test(t)?t:`${t}.`}function Xi(e,t){let n=w(`div`,e.kind===`failed`?`notice notice-error`:`notice`);n.setAttribute(`data-save-outcome`,e.kind);let r=(e,n)=>{let r=w(`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]} · ${fi(e.byteLength)}`:`Saved ${e.names.length} files · ${fi(e.byteLength)}`;n.append(w(`span`,void 0,r));let i=e.reveal;if(i!==null){let e=w(`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=w(`div`,`muted`,e.summary);t.setAttribute(`data-save-summary`,``),n.append(t)}}else e.kind===`cancelled`?(n.append(w(`span`,void 0,`You cancelled the save.`)),e.total>1?n.append(w(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)):n.append(` `),n.append(r(e.refs,`Download again`))):(n.append(w(`strong`,void 0,`Exported, but the browser didn't save it.`)),e.total>1&&n.append(w(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)),n.append(w(`div`,void 0,e.error),r(e.refs,`Download again`)));return n}function Zi(e,t){let n=w(`button`,`btn btn-icon transport-button`);return n.type=`button`,n.setAttribute(`data-transport-shuttle`,String(e)),n.setAttribute(`aria-label`,t),n.append(x(e===-1?`rewind`:`fastForward`)),n}function Qi(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=w(`button`,`btn btn-icon transport-button`),r.type=`button`,r.setAttribute(`data-transport-play`,``),s=w(`button`,`btn btn-icon transport-button`),s.type=`button`,s.setAttribute(`data-transport-skip`,``),s.append(x(`skipBack`)),o=w(`button`,`btn btn-icon transport-button`),o.type=`button`,o.setAttribute(`data-transport-repeat`,``),o.append(x(`repeat`));let t=w(`span`,`transport-pip`);t.setAttribute(`aria-hidden`,`true`),o.append(t),i=w(`span`,`rate`),i.setAttribute(`data-transport-rate`,``),a=w(`div`,`transport-controls`),a.setAttribute(`data-transport-controls`,``),a.append(s,Zi(-1,`Rewind`),r,Zi(1,`Fast forward`),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`:`Fast forward`,o=i?`${a}, playing ${r===-1?`backwards`:`forwards`} at ${c}x`:a;e.setAttribute(`aria-label`,o),t.enabled?Jr(e,o,[r===-1?`J`:`L`]):(Yr(e),e.title=o)}s.onclick=()=>n.onSkipToStart(),s.disabled=!t.enabled;let l=`Jump to start`;s.setAttribute(`aria-label`,l),t.enabled?Jr(s,l,[`Mod`,`Left`]):(Yr(s),s.title=g(`This demo has no frames yet, so there is nothing to play. ${Ot(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(x(f)),r.toggleAttribute(`data-playing`,t.playing),r.toggleAttribute(`data-active`,t.playing&&t.rate===1),r.disabled=!t.enabled,t.enabled?Jr(r,d,[`Space`]):(Yr(r),r.title=g(`This demo has no frames yet, so there is nothing to play. ${Ot(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 $i(e,t,n,r=e){let i=r.querySelector(`[data-transport-time]`),a=e.querySelector(`[data-stage-actions]`);if(i===null||a===null){i=w(`span`,`stage-clock`),i.setAttribute(`data-transport-time`,``),a=w(`div`,`stage-actions`),a.setAttribute(`data-stage-actions`,``);let t=w(`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=w(`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=w(`button`,`btn chip`);n.type=`button`,n.setAttribute(`data-stage-zoom`,``),a.append(n);let o=w(`button`,`btn btn-icon chip chip-icon`);o.type=`button`,o.setAttribute(`data-stage-fullscreen`,``),a.append(o);let s=w(`div`,`stage-error`);s.setAttribute(`data-stage-error`,``),s.setAttribute(`role`,`alert`),s.hidden=!0;let c=w(`span`,`stage-error-text`);c.setAttribute(`data-stage-error-text`,``);let l=w(`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(x(`close`)),s.append(c,l),r===e?e.replaceChildren(i,a,s):(r.replaceChildren(i),e.replaceChildren(a,s))}i.textContent=`${zn(t.positionMs)} / ${zn(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`:g(`This demo has no frames yet, so there is nothing to zoom into. ${Ot(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(x(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 ea={undo:[`Mod`,`Z`],redo:[`Shift`,`Mod`,`Z`],"shortcuts-open":[`?`]};function ta(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=ea[t];a===void 0?i.title===``&&(i.title=r):Jr(i,r,a),i.querySelector(`svg`)===null&&(i.textContent=``,i.append(x(n)))}}var na=`#failure > .notice:not([data-capture-note])`;function ra(e,t){let n=[...t.querySelectorAll(`.notice, .banner`)].length;if(e.classList.toggle(`hidden`,n===0),n===0){e.removeAttribute(`data-level`),typeof t.hidePopover==`function`&&t.matches(`:popover-open`)&&t.hidePopover();return}let r=t.querySelector(na)===null?`warn`:`error`;e.setAttribute(`data-level`,r);let i=`${n} ${n===1?`note`:`notes`} on this take${r===`error`?`, with an error`:``}`;e.setAttribute(`aria-label`,i),e.title=i,e.querySelector(`svg`)===null&&e.append(x(`circleAlert`));let a=e.querySelector(`[data-count]`);a===null&&(a=w(`span`),a.setAttribute(`data-count`,``),a.setAttribute(`aria-hidden`,`true`),e.append(a)),a.textContent=String(n)}function ia(e,t){let n=[...e.querySelectorAll(na)].map(e=>e.textContent??``).join(`
|
|
2
|
+
`);return n!==``&&n!==t&&typeof e.showPopover==`function`&&!e.matches(`:popover-open`)&&e.showPopover(),n}function aa(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=w(`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=w(`div`,`shortcuts-body`),o=[];for(let e of Ar){let n=o[o.length-1];if(n?.group!==e.group){let t=w(`section`,`shortcuts-section`);t.append(w(`h3`,`shortcuts-group`,e.group)),a.append(t),n={section:t,group:e.group,rows:[]},o.push(n)}let r=w(`div`,`shortcuts-row`);r.setAttribute(`data-shortcut-row`,``),r.append(w(`span`,`shortcuts-what`,kr(e,t.mac)));let i=w(`span`,`shortcuts-keys`);for(let n of e.combos){let e=w(`span`,`keychord`);e.setAttribute(`data-combo`,``),e.setAttribute(`aria-label`,Dr(n,t.mac));for(let r of n){let n=Cr(r,t.mac),i=w(`kbd`,`keycap`,n);i.setAttribute(`aria-hidden`,`true`),Tr(n)&&i.setAttribute(`data-symbol`,``),e.append(i)}i.append(e)}r.append(i),n.section.append(r),n.rows.push(r)}let s=w(`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 oa(e){return`${Ge(e)}${Ye(e)}`}function sa(e,t,n=!1){let r=w(`div`,`info-row`);r.append(w(`span`,`info-key`,e));let i=w(`span`,n?`info-value mono`:`info-value`,t);return i.title=t,r.append(i),r}function ca(e,t,n,r){let i=sa(e,t,!0),a=w(`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(x(`copy`));let o=w(`div`,`info-error`);o.setAttribute(`data-copy-error`,n),o.hidden=!0,a.addEventListener(`click`,()=>{r(t).then(()=>{o.hidden=!0,a.replaceChildren(x(`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=w(`div`);return s.append(i,o),s}function la(e,t,n){let r=w(`div`,`info-group`);r.setAttribute(`data-info-facts`,``);let i=`${h(t.durationMs)} · ${t.steps} ${t.steps===1?`step`:`steps`}`,a=t.aspect===`auto`?`Auto`:t.aspect;r.append(sa(`Recorded`,Wi(t.recordedAt)),sa(`Site`,oa(t.site)),sa(`Length`,i),sa(`Recording`,`${t.recording.width} × ${t.recording.height}`),sa(`Video`,`${t.target.width} × ${t.target.height} · ${a}`));let o=w(`div`,`info-group`);if(o.setAttribute(`data-info-ids`,``),o.append(ca(`Take ID`,t.takeId,`take ID`,n.onCopy)),t.rerun.kind===`link`){let e=w(`div`,`info-row`);e.append(w(`span`,`info-key`,`Re-record`));let n=w(`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=w(`div`,`info-group info-exports`);if(e.setAttribute(`data-info-exports`,``),e.append(w(`div`,`info-label`,`Exports`)),t.revealError!==null){let n=w(`p`,`notice notice-warn`,t.revealError);n.setAttribute(`data-reveal-error`,``),e.append(n)}let r=w(`div`,`info-history`);Bi(r,t.history,n),e.append(r),s.push(e)}e.replaceChildren(...s)}var ua=.006,A=e=>`${(e*100).toFixed(4)}%`;function da(e,t,n,r=ua){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 fa=(e,t)=>Math.min(1,Math.max(0,k(e,t))),pa=[100,250,500,1e3,2e3,5e3,1e4,15e3,3e4,6e4],ma=(e,t)=>t>=1e3?zn(e):`${zn(e)}.${Math.floor(e%1e3/100)}`;function ha(e,t){let n=w(`div`,`ruler`);n.setAttribute(`data-ruler`,``),n.setAttribute(`data-source`,e.timeSource);let r=(t.viewport.endMs-t.viewport.startMs)/10,i=pa.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=w(`span`,`tick`,ma(e,i));a.style.left=A(r),a.dataset.fraction=String(r),n.append(a)}return _a?.observe(n),n}function ga(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 _a=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>{for(let t of e){let e=t.target;e.isConnected?ga(e):_a?.unobserve(e)}});function va(e,t){let n=w(`div`,`lane`);return n.append(e,t),n}function ya(e,t,n){let r=w(`div`,`lane-label lane-head`),i=w(`span`,`lane-title`),a=w(`span`,`lane-glyph`);return a.append(x(t)),i.append(a,w(`span`,`lane-name`,e)),n&&i.append(n),r.append(i),r}function ba(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=w(`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 xa=3;function Sa(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 Ca=(e,t)=>e!==null&&t!==null&&e.kind===t.kind&&(e.kind===`tick`?e.actionId===t.actionId:e.kind===`piece`?Ft(e.start,t.start):e.id===t.id),wa=(e,t)=>e.snapping?8*t:0;function Ta(e,t){let n=e.getBoundingClientRect().width;return n===0?0:(t.endMs-t.startMs)/n}function Ea(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 Da(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=Ta(t,n.viewport);return{toMs:Ea(t,n.viewport,e),deltaMs:(e-s)*r,snapMs:wa(n,r)}},u=e=>{Math.abs(e.clientX-s)>xa&&(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 Oa=e=>Math.max(0,Math.min(1,e));function ka(e,t,n,r){let i=Oa(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 Aa(e,t,n,r,i){let a=w(`div`,`edge`);return a.setAttribute(`data-edge`,t),a.setAttribute(`aria-label`,t===`start`?`Drag the piece's start`:`Drag the piece's end`),Da(a,n,r,({deltaMs:n})=>({kind:`pieceEdge`,start:e.start,side:t,deltaMs:n}),i,{move:({deltaMs:e})=>{let i=e/Ta(n,r.viewport);a.style.transform=`translateX(${i}px)`;let o=t===`end`?e:-e;a.setAttribute(`data-readout`,`${o<0?`−`:`+`}${(Math.abs(o)/1e3).toFixed(1)}s`)},end:()=>{a.style.transform=``,a.removeAttribute(`data-readout`)}}),a}function ja(e,t,n,r){let i=w(`div`,`join-card`);i.setAttribute(`data-join-card`,e.removedId),i.setAttribute(`role`,`dialog`),i.setAttribute(`aria-label`,`Removed frames`),i.setAttribute(`data-align`,t>.85?`end`:t<.15?`start`:`center`),i.addEventListener(`pointerdown`,e=>e.stopPropagation()),i.addEventListener(`click`,e=>e.stopPropagation());let a=w(`div`,`join-card-what`),o=w(`b`),s=w(`span`);e.unplaced===void 0?(o.textContent=`${n} removed`,s.textContent=`${Ma(e.srcStartMs)} to ${Ma(e.srcEndMs)}`):(o.textContent=`Removes no frames`,s.textContent=e.unplaced.charAt(0).toUpperCase()+e.unplaced.slice(1)),a.append(o,s);let c=w(`button`,`join-card-restore`);return c.type=`button`,c.setAttribute(`data-restore`,e.removedId),c.textContent=e.unplaced===void 0?`Restore`:`Discard`,c.addEventListener(`click`,()=>r.onRestorePiece(e.removedId)),i.append(a,c),i}function Ma(e){let t=Math.max(0,Math.round(e/100)),n=t%600/10;return`${Math.floor(t/600)}:${n.toFixed(1).padStart(4,`0`)}`}function Na(e,t,n){let r=w(`div`,`track`);r.setAttribute(`data-track`,`clip`);let{clip:i}=e;for(let e of i.degraded){let n=da(t.viewport,e.startMs,e.endMs,0);if(n===null)continue;let i=w(`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=da(t.viewport,i.trim.headMs,i.trim.tailMs);if(s!==null){let e=w(`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)}let c=r.querySelector(`[data-clip-block]`),l=i.pieces;c!==null&&s!==null&&s.width>0&&(l.length>1&&c.setAttribute(`data-pieces`,``),l.forEach((e,i)=>{let a=da(t.viewport,e.startMs,e.endMs,0);if(a===null)return;let o=Math.max(0,(a.left-s.left)/s.width),u=Math.min(1,(a.left+a.width-s.left)/s.width);if(u<=o)return;let d=w(`div`,`piece-wrap`);d.style.left=A(o),d.style.width=A(u-o);let f=w(`button`,`piece`);f.type=`button`,f.setAttribute(`data-piece`,String(e.startMs)),f.setAttribute(`aria-label`,`Piece of the clip`),Ca(t.selection,{kind:`piece`,start:e.start})&&(d.setAttribute(`data-selected`,``),f.setAttribute(`data-selected`,``)),f.addEventListener(`click`,t=>{t.stopPropagation(),n.onSelect({kind:`piece`,start:e.start})}),d.append(f);let p=i===0,m=i===l.length-1;(!p||e.before!==null)&&d.append(Aa(e,`start`,r,t,n)),(!m||e.after!==null)&&d.append(Aa(e,`end`,r,t,n)),c.append(d)}));for(let e of i.joins){let i=k(t.viewport,e.atMs);if(i<0||i>1)continue;let a=(i>=1?-1:+(i<=0))+(i>=1?-1:1)*e.index*14,o=`calc(${A(i)} + ${a}px)`,s=t.openJoin===e.removedId,c=`${((e.srcEndMs-e.srcStartMs)/1e3).toFixed(1)}s`,l=w(`button`,`join`);l.type=`button`,l.setAttribute(`data-join`,e.removedId),l.setAttribute(`aria-label`,e.unplaced===void 0?`Removed, ${c}`:`Removed nothing`),l.setAttribute(`aria-expanded`,String(s)),l.style.left=o;let u=null;l.addEventListener(`pointerdown`,e=>{e.stopPropagation(),u={x:e.clientX,y:e.clientY}}),l.addEventListener(`click`,t=>{t.stopPropagation();let r=u!==null&&t.detail>0&&Math.hypot(t.clientX-u.x,t.clientY-u.y)>xa;u=null,r||n.onOpenJoin(s?null:e.removedId)});let d=w(`span`,`seam`);d.setAttribute(`data-seam`,e.removedId),d.style.left=o,r.append(d,l),s&&r.append(ja(e,i,c,n))}let u=l[0],d=l.at(-1);for(let[e,s,c]of[[`head`,a,i.trim.headTiming],[`tail`,o,i.trim.tailTiming]]){if(s<0||s>1||(e===`head`?i.trim.headMarker===null&&(u?.before??null)!==null:i.trim.tailMarker===null&&(d?.after??null)!==null))continue;let a=w(`div`,`handle`);a.setAttribute(`data-trim`,e),a.setAttribute(`data-timing`,c),a.style.left=A(s),Da(a,r,t,({toMs:t,snapMs:n})=>({kind:`trim`,edge:e,toMs:t,snapMs:n}),n,{move:({toMs:n})=>ka(r,a,e,k(t.viewport,n)),end:()=>ka(r,a,e,s)}),r.append(a)}for(let e of i.ticks){let a=k(t.viewport,e.atMs);if(a<0||a>1)continue;let o=w(`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(x(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),Ca(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=t===`zoom`?e:null,s=o?o.departMs:e.startMs,c=o?o.drawnEndMs:e.endMs,l=da(i.viewport,s,c);if(l===null)return null;let u=w(`div`,`seg`);u.setAttribute(`data-segment`,e.id),u.setAttribute(`data-kind`,t),u.setAttribute(`data-timing`,e.timing),u.setAttribute(`data-to-scale`,String(l.toScale)),u.style.left=A(l.left),u.style.width=A(l.width);let{trim:d}=r.clip;(c<=d.headMs||s>=d.tailMs)&&u.setAttribute(`data-outside-trim`,``);let f={kind:t,id:e.id};Ca(i.selection,f)&&u.setAttribute(`data-selected`,``);let p=t===`mask`&&e.wholeTake;if(t===`zoom`){let t=e;u.setAttribute(`data-authored-end`,String(t.endAuthored)),u.setAttribute(`data-clamped`,String(t.clamped)),u.append(w(`span`,`seg-label`,`${t.scale.toFixed(1)}x`))}else p&&u.setAttribute(`data-whole-take`,``),u.append(w(`span`,`seg-label`,p?`mask · whole take`:`mask`));if(u.addEventListener(`click`,e=>{e.stopPropagation(),a.onSelect(f)}),!p){let r=(e,t)=>{u.style.left=A(e),u.style.width=A(t)},o=()=>r(l.left,l.width),s=i.viewport.endMs-i.viewport.startMs;for(let s of[`start`,`end`]){let c=w(`div`,`cap`);c.setAttribute(`data-cap`,s),Da(c,n,i,({toMs:n,snapMs:r})=>t===`zoom`?{kind:`zoomEdge`,id:e.id,edge:s,toMs:n,snapMs:r}:{kind:`maskEdge`,id:e.id,edge:s,toMs:n,snapMs:r},a,{move:({toMs:e})=>{let t=Oa(k(i.viewport,e)),n=l.left+l.width;if(s===`start`){let e=Math.min(t,n);r(e,n-e)}else r(l.left,Math.max(t,l.left)-l.left)},end:o}),u.append(c)}Da(u,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=s===0?0:e/s;r(Math.max(0,Math.min(1-l.width,l.left+t)),l.width)},end:o})}return u}function Ia(e,t,n,r){let i=w(`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=Ta(i,n.viewport);r.onGesture({kind:e===`zoom`?`addZoom`:`addMask`,atMs:La(e,t,Ea(i,n.viewport,a.clientX)),snapMs:wa(n,o)})}),za(i,e,t,n),i}function La(e,t,n){let r=e===`zoom`?(t.zoomDefaultMs-t.zoomInMs)/2:nn/2;return Math.max(0,Math.min(t.durationMs,n-r))}function Ra(e,t,n){let r=e===`zoom`?pn(t,n):mn(t,n);return rn(r)?null:e===`mask`?{startMs:r.startMs,endMs:r.endMs}:{startMs:qt(t.zooms,r.startMs,t.zoomInMs),endMs:Jt(t.zooms,r.startMs,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,Ea(e,r.viewport,o.clientX))),c=s&&da(r.viewport,s.startMs,s.endMs);if(c===null)return a();i===null&&(i=w(`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`,drag:`handGrab`};function Va(e,t,n,r){let i=w(`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=w(`p`,`muted`);C(e,t.rerunLine===null?`Timing from the take, not from a render — ${ft(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=ha(t,n);Sa(a,()=>a.getBoundingClientRect(),n,t.durationMs,r);let o=w(`div`,`lanes`);o.append(va(w(`b`,`lane-label`),a));let s=w(`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(Hr(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(Ur(n.viewport,t.durationMs,a/i.width*o))});let c=ya(`Clip`,`film`),l=ba(t.hoverCheck);l!==null&&c.querySelector(`.lane-glyph`)?.append(l);let u=va(c,Na(t,n,r));u.setAttribute(`data-lane`,`clip`),o.append(u);let d=va(ya(`Zoom`,`zoomIn`),Ia(`zoom`,t,n,r));d.setAttribute(`data-lane`,`zoom`),o.append(d);let f=w(`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(x(`plus`)),f.onclick=()=>{let e=i.querySelector(`[data-track="clip"]`),t=e?Ta(e,n.viewport):0;r.onGesture({kind:`addMask`,atMs:n.positionMs,snapMs:wa(n,t)})};let p=va(ya(`Mask`,`eyeOff`,f),Ia(`mask`,t,n,r));p.setAttribute(`data-lane`,`mask`),o.append(p);let m=w(`div`,`playhead`);m.setAttribute(`data-playhead`,``),m.style.left=A(fa(n.viewport,n.positionMs));let h=w(`div`,`grab`);h.setAttribute(`data-playhead-grab`,``),h.setAttribute(`aria-hidden`,`true`),Sa(h,()=>s.getBoundingClientRect(),n,t.durationMs,r),m.append(h),s.append(m),o.append(s),i.append(o);let g=w(`p`,`refusal`);C(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();let y=i.querySelector(`[data-join-card]`);y!==null&&Ha(y)}function Ha(e){let t=e.getAttribute(`data-join-card`),n=e.parentElement?.querySelector(`[data-join="${t}"]`);if(n==null||typeof e.showPopover!=`function`)return;e.setAttribute(`popover`,`manual`),e.showPopover();let r=n.getBoundingClientRect(),i=e.getBoundingClientRect(),a=r.left+r.width/2,o=Math.max(8,Math.min(innerWidth-i.width-8,a-i.width/2));e.style.left=`${o}px`,e.style.top=`${Math.max(8,r.top-i.height-8)}px`,e.style.setProperty(`--arrow`,`${a-o}px`)}function Ua(e){let t=w(`button`,`btn btn-quiet btn-icon tool`);return t.type=`button`,t.append(x(e)),t}function Wa(e,t,n){e.setAttribute(`aria-label`,t),e.disabled?(Yr(e),e.title=t):Jr(e,t,n)}var Ga=new WeakMap;function Ka(){let e=w(`div`,`bar-controls`);e.setAttribute(`data-timeline-tools`,`view`);let t=Ua(`magnet`);t.classList.add(`snap`);let n=Ua(`moveHorizontal`);n.classList.add(`fit`),n.setAttribute(`data-fit`,``);let r=Ua(`scissors`);r.setAttribute(`data-split-tool`,``);let i=w(`div`,`zoom-control`);i.setAttribute(`data-zoom-control`,``);let a=w(`input`);a.setAttribute(`aria-label`,`Timeline zoom`),a.type=`range`,a.min=`0`,a.max=`1`,a.step=`0.001`,a.setAttribute(`data-zoom-slider`,``);let o=Ua(`zoomOut`);o.classList.add(`zoom-step`),o.setAttribute(`data-zoom-step`,`out`);let s=Ua(`zoomIn`);return s.classList.add(`zoom-step`),s.setAttribute(`data-zoom-step`,`in`),i.append(o,a,s),e.append(r,t,n,i),{view:e,split:r,snap:t,fit:n,zoom:a,zoomOut:o,zoomIn:s}}function qa(e,t,n,r){let i=Ga.get(e);(i===void 0||i.view.parentElement!==e)&&(i=Ka(),Ga.set(e,i),e.replaceChildren(i.view));let{split:a,snap:o,fit:s,zoom:c,zoomOut:l,zoomIn:u}=i;Wa(a,`Split at playhead`,[`Mod`,`B`]),a.onclick=()=>r.onSplit(),Wa(o,n.snapping?`Snapping on — drags land on the nearest step`:`Snapping off — drags land where you drop them`,[`S`]),o.setAttribute(`data-snap`,n.snapping?`on`:`off`),o.setAttribute(`aria-pressed`,n.snapping?`true`:`false`),o.onclick=()=>r.onSnapping(!n.snapping);let d=zr(t.durationMs),f=n.viewport.startMs===d.startMs&&n.viewport.endMs===d.endMs;s.disabled=f,Wa(s,f?`The whole take is already in view`:`Fit the whole take`,[`Shift`,`Z`]),s.onclick=()=>r.onViewport(d);let p=n.viewport.endMs-n.viewport.startMs,m=Kr(t.durationMs,p);c.value=String(m),c.style.setProperty(`--fill`,`${(m*100).toFixed(2)}%`);let h=t.durationMs>250;c.disabled=!h,c.title=h?`Zoom the timeline (⌘-scroll, ⇧Z to fit)`:`This take is too short to zoom into.`,c.oninput=()=>{let e=Gr(t.durationMs,Number(c.value)),i=k(n.viewport,n.positionMs);r.onViewport(Wr(n.viewport,t.durationMs,e,i>=0&&i<=1?i:.5))};let g=e=>{let i=Math.min(1,Math.max(0,k(n.viewport,n.positionMs)));r.onViewport(Hr(n.viewport,t.durationMs,e,i))};l.disabled=!h||m<=5e-4,l.onclick=()=>g(1/yr),Wa(l,`Zoom out`,[`−`]),u.disabled=!h||m>=.9995,Wa(u,`Zoom in`,[`+`]),u.onclick=()=>g(yr)}var j=ie();function M(e){console.error(`demoman editor:`,e)}var Ja=j.kits,Ya={state:`ready`,kits:[],defaultId:null,migrationPending:!1},Xa=null,Za=null;function Qa(e){let t=Ya;if(t.state!==`ready`)return null;let n=t.kits.filter(e=>e.read.state===`ready`),r=n.filter(t=>t.read.state===`ready`&&Ve(t.read.kit,e)),i=r.find(e=>e.id===Xa)??r.find(e=>e.id===t.defaultId)??r[0];if(i!==void 0)return Xa=i.id,{kit:i,edited:!1};let a=n.find(e=>e.id===Xa);return a===void 0?null:{kit:a,edited:!0}}var $a=j.bundles,eo=new URL(location.href).searchParams.get(`scene`)??``,N=e=>{let t=document.getElementById(e);if(!t)throw Error(`editor is missing #${e}`);return t},to=null,no=!1,P=vr({sceneId:eo,loadScene:async e=>{let t=await j.scenes.get(e);if(t===null)throw Error(`no scene "${e}"`);return Zo??=t.notes,no||=(to=t.revision,!0),t.scene},saveScene:async e=>{to=(await j.scenes.put(e,to)).revision},bundles:{active:e=>$a.active(e)},newId:()=>crypto.randomUUID()});function F(e){let t=P.snapshot().scene;return P.dispatch(e).catch(M).then(()=>ro(t))}function ro(e){if(No===null)return;let t=P.snapshot();t.scene!==e&&t.error===null&&(No=null,$(t))}var I=gt,io=null,L=null,ao=!1;function oo(e){e!==L&&(ao=!1),L=e}var R=null,so=null,co=[],lo=null,uo=null,fo=null,z=null,po=null,B=`export`,V=!0,mo=`export`,ho=Kn(),H=`mp4`;function go(e){let t=P.snapshot().scene,n=yo();return ye(H,t.canvas.aspect,e,xe({...t,branding:Ss(t)}),n===null?{}:{quality:n})}var _o=j.exportQuality===void 0?null:he,vo=null,yo=()=>_o===null?null:vo??_o,bo=!1,xo=null;function So(e){return xo?.scene!==e&&(xo={scene:e,digest:pt(e)}),xo.digest}var Co=`fit`;function wo(e){e!==null&&e.kind!==`piece`?(B!==`selection`&&(mo=B),B=`selection`,V=!0):B===`selection`&&(B=mo),z=e}var To=null,Eo=null,Do=0,U=null,Oo=!0,ko=!1,Ao=``,jo=!1,Mo=null,No=null,Po=[];function Fo(){return Po.flatMap(e=>e.kind===`stored`?[e.output]:[])}var Io=!1,Lo=new Set,W=Pn(me),G=null,K=null,Ro=N(`preview`),zo=new OffscreenCanvas(W.width,W.height),Bo=zo.getContext(`2d`);function Vo(e){let t=go(e),n=ic(e,N(`stage-frame`).getBoundingClientRect().width),r=n.width!==W.width||n.height!==W.height;W=n,r&&(zo=new OffscreenCanvas(W.width,W.height),Bo=zo.getContext(`2d`)),G=null;let i=N(`stage`);i.style.setProperty(`--frame-ratio`,`${t.width} / ${t.height}`),i.style.setProperty(`--frame-px`,String(Pn(t).width))}var Ho=150,Uo=null,Wo=!1,Go=!1;document.addEventListener(`pointerdown`,()=>{Wo=!0},!0);var Ko=()=>{Wo=!1,xs?.patch.background!==void 0&&setTimeout(()=>{!Wo&&xs?.patch.background!==void 0&&Fs()},0),Go&&setTimeout(()=>{Go&&!Wo&&$(P.snapshot())},0)};window.addEventListener(`pointerup`,Ko,!0),window.addEventListener(`pointercancel`,Ko,!0);var qo=new ResizeObserver(()=>{let e=N(`stage`),t=N(`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`),Yc&&(Uo!==null&&clearTimeout(Uo),Uo=setTimeout(()=>{Uo=null;let e=ic(P.snapshot().bundle,N(`stage-frame`).getBoundingClientRect().width);(e.width!==W.width||e.height!==W.height)&&(Wo&&(xs!==null||ys!==null)?(Fs(),Go=!0):$(P.snapshot()))},Ho))});qo.observe(N(`stage-frame`)),qo.observe(N(`stage`));var Jo=[],Yo=null,Xo=``,Zo=null,Qo=`The video shows the text that was recorded; re-record to type the new text.`;function $o(e){let t=new Map((e.madeFrom??[]).map(e=>[e.actionId,e]));return e.scene.actions.some(e=>{let n=t.get(e.id);return e.kind===`type`&&n?.kind===`type`&&n.text!==e.text})}var es=null,ts=null,ns=0,rs=null,is=Bn(e=>e.motionSpans.length>0?a(e,$a.load,{onSpanUnavailable:(e,t)=>console.info(`[demoman] preview: span ${e} could not be decoded (${t})`)}):Promise.resolve(d(e,$a.load)));async function as(e){let{bundle:t,scene:n}=e;if(t===null||Tn(Yo,e))return;Yo=wn({scene:n,bundle:t}),Jo=[];let r=fe(n).retiming.motionDiffThreshold,i=()=>{let e=P.snapshot();return e.scene===n&&e.bundle===t},a;try{a=await is(t),Jo=await s(t,a,r)}catch(e){M(e),i()&&P.setHoverReport(En),$(P.snapshot());return}try{let e=await et(n,t,a,r);if(i()){let t=ue(P.snapshot().scene);P.setHoverReport(On(e,t))}}catch(e){M(e),i()&&P.setHoverReport(En)}$(P.snapshot())}var os=null,ss=null,cs=null,q=null,ls=``,us=null,ds=null,fs=null,ps=null,ms=null,hs=null,gs=null,_s=null,vs=null,J=null,ys=null,bs=null,xs=null;function Ss(e){let t=Me(xs,e,M);return xs=t.preview,t.branding}function Cs(e){xs={patch:e,scene:P.snapshot().scene},Fs();let t=P.snapshot();Ts(t,go(t.bundle))}function ws(e){io!==null&&(io=null,$(P.snapshot())),j.files.reveal(e).catch(e=>{let t=Gn(e);t.expected?console.info(`demoman editor: ${t.text}`):M(e),io=t.text,$(P.snapshot())})}function Ts(e,t){let n=Le({durationMs:Z-X,fileType:H,target:t,hasFrames:gc(e).kind!==`noFrames`}),r=N(`take-meta`);r.textContent=n,r.setAttribute(`aria-label`,`Take info: ${n}`)}var Es=null;function Ds(e){return ys===null?e.cursor:{...e.cursor,...ys}}function Os(e){let t=e.motion??ae;return bs===null?t:{...t,...bs}}var ks=null,As=null;function js(e){ys=e,Fs()}function Ms(e){bs=e,Fs()}function Ns(){bs!==null&&(bs=null,Fs())}function Ps(){ys!==null&&(ys=null,Fs())}function Fs(){As===null&&(As=requestAnimationFrame(()=>{As=null;let e=P.snapshot();Hs(e),K&&(Es=Ds(e.scene),ks=Os(e.scene),rs=G,Q.seek(Q.positionMs))}))}function Is(){As!==null&&cancelAnimationFrame(As),As=null,ys=null,bs=null}function Ls(e){return e===null?null:us?.ref===e?us.thumb:{kind:`loading`}}function Rs(e){return e.kind===`image`&&J?.ref!==e.ref?{ref:e.ref,thumb:{kind:`loading`}}:J}function zs(e){if(vs=null,ms===null)return null;let t=Wo&&xs?.patch.background!==void 0;try{return We(t?Ue(ms,W):ms,e,W)}catch(e){return vs=`it could not be blurred: ${e instanceof Error?e.message:String(e)}`,null}}async function Bs(e){let t=Ss(e.scene).background;if(!we(t)){if(hs===null&&gs===null)return;ms=null,hs=null,gs=null,_s=null,$(P.snapshot());return}let n=Te(t,W),r=hs?.key===n?hs:null;if(r!==null&&(r.error!==null||ms!==null&&ge(W,r.natural).width<=ms.width)){gs=null;return}if(gs===n)return;gs=n,r===null&&(_s=null);let i=null,a=null;try{i=await Oe(t,W,j.wallpapers)}catch(e){a=e instanceof Error?e.message:String(e)}if(gs!==n){i!==null&&`close`in i.image.image&&i.image.image.close();return}if(gs=null,ms=i?.image??null,hs={key:n,natural:i?.natural??null,error:a},_s=a,t.kind===`image`){let e=J,n;if(i===null)n={kind:`failed`,reason:a??``};else if(J?.ref===t.ref&&J.thumb?.kind===`ready`)n=J.thumb;else try{n={kind:`ready`,url:await ve(i.image)}}catch(e){n={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(J!==e)n.kind===`ready`&&n!==e?.thumb&&URL.revokeObjectURL(n.url);else{let e=J?.thumb;e?.kind===`ready`&&e!==n&&URL.revokeObjectURL(e.url),J={ref:t.ref,thumb:n}}}$(P.snapshot())}async function Vs(e){let n=Ss(e.scene),r=n.logo?.ref??null;if(r!==ss&&(ss=r,cs=null,q=null,os=null,ls=``,r!==null)){let e=await j.logos.load(r);if(ss!==r)return;e.ok?cs=e.source:q=e.error}let i=t(n,W),a=`${r}@${i}`;if(cs!==null&&i>0&&a!==ls){ls=a;try{let e=await cs.rasterAt(i);if(ss!==r||ls!==a)return;os=e,q=null}catch(e){os=null,q=e instanceof Error?e.message:String(e)}}let o=null;if(r!==null){if(cs!==null){try{o={kind:`ready`,url:await Se(cs)}}catch(e){o={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(ss!==r)return}else o=q===null?{kind:`loading`}:{kind:`failed`,reason:q}}let s=JSON.stringify(o)!==JSON.stringify(us?.thumb??null)||(us?.ref??null)!==r;us=r===null?null:{ref:r,thumb:o};let c=cs?Fe(cs,t(n,go(e.bundle)),Ae(H,e.scene.canvas.aspect)):null,l=[ps?.ref===r?ps.note:null,c].filter(e=>e!==null),u=s||os!==ds||q!==fs||l.join(`
|
|
3
|
+
`)!==co.join(`
|
|
4
|
+
`);co=l,ds=os,fs=q,u&&$(P.snapshot())}function Hs(e){Vo(e.bundle);let{scene:t,bundle:r}=e,i=Ds(t),a=Ss(t),o=Vn(t,{cursor:i,branding:a,motion:bs===null?t.motion:Os(t)}),s=r?n({plan:fe(o),bundle:r,scene:o,target:W,detailTarget:go(r),hints:Jo,logo:os,wallpaper:zs(a.background)}):null;K=s?.resolved??null,G=s?.presentation??null,Ro.width!==W.width&&(Ro.width=W.width),Ro.height!==W.height&&(Ro.height=W.height)}var Us=[];function Ws(e,t){let n=t.width*t.height/1e6;n<=0||(Us.push(e/n),Us.length>60&&Us.splice(0,Us.length-30))}var Gs=null,Ks=null,qs=2e3,Js=!1,Y={requestedFrames:0,drawnFrames:0,elapsedMs:0,sourceLookupMs:0,composeMs:0,blitMs:0},Ys=0,Xs=null,Zs=null,Qs=0,$s=0;function ec(){Y.requestedFrames=0,Y.drawnFrames=0,Y.elapsedMs=0,Y.sourceLookupMs=0,Y.composeMs=0,Y.blitMs=0,Qs=0,$s=0,Ys=performance.now()}function tc(){if(Q.playing===Js)return;if(Js=Q.playing,$(P.snapshot()),Js){Xs={width:W.width,height:W.height},ec();return}Y.elapsedMs=performance.now()-Ys;let e=(P.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(In({...Y,...e===null?{}:{sourceFrame:e},...Xs===null?{}:{bitmap:Xs},parkedHeight:W.height,msPerMegapixel:Zs,...$s>0?{decodeMs:Qs}:{}}))}var nc=Ln({schedule:e=>requestAnimationFrame(e),onDrawFailed:e=>{oo(e instanceof Error?e.message:String(e)),Q.pause(),$(P.snapshot())},onDrawRecovered:()=>{L!==null&&(L=null,$(P.snapshot()))},draw:async e=>{let t=P.snapshot(),n={resolved:K,presentation:G,target:W,offscreen:zo,offscreenCtx:Bo};if(!n.resolved||!n.presentation||!t.bundle)return;let r=performance.now(),i=await is(t.bundle),a=performance.now();Js&&i.warm?.(se(n.resolved.timeline,e),se(n.resolved.timeline,e+qs));let o=0;await l({resolved:n.resolved,target:n.target,presentation:n.presentation,frames:i,ctx:n.offscreenCtx,outputTimeMs:e,onStage:(e,t)=>{e===`fetch`&&(o=t,Js&&(Qs+=t,$s+=1))}});let s=performance.now();if(n.offscreen===zo){if(Ws(s-a-o,n.target),Ro.getContext(`2d`)?.drawImage(zo,0,0),Q.playing&&Ks!==null&&(Ks+=1,Ks>=15)){let e=Us.slice(-Ks),t=Gs;Gs=null,Gs=ic(P.snapshot().bundle,N(`stage-frame`).getBoundingClientRect().width,e).height,Ks=null,Gs!==t&&($(P.snapshot()),Xs={width:W.width,height:W.height})}To&&(z?.kind===`mask`||z?.kind===`zoom`)&&Ir(N(`stage-overlay`),{canvas:Ro,selection:z,model:To,resolved:n.resolved,presentation:n.presentation,target:n.target,outputTimeMs:e},{onMaskRect:(e,t)=>F({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>F({kind:`setZoomTarget`,id:e,point:t})}),Js&&(Y.drawnFrames+=1,Y.sourceLookupMs+=a-r,Y.composeMs+=s-a,Y.blitMs+=performance.now()-s)}}}),X=0,Z=0,rc=!1,Q=Rn({seek:e=>{Js&&(Y.requestedFrames+=1),nc.seek(e)},durationMs:()=>rc?Z:0,startMs:()=>X,looping:()=>ko,now:()=>performance.now(),schedule:e=>requestAnimationFrame(e),onChange:()=>{tc(),cc()}});function ic(e,t,n=Us){let r=go(e),i=()=>Nn({target:r,paintedCssWidth:t,devicePixelRatio:window.devicePixelRatio,playing:Q.playing,msPerMegapixel:Mn(n)});return Q.playing?(Gs===null&&(Gs=i(),Zs=Mn(n),Ks=0),Pn(r,Gs)):(Gs=null,Pn(r,i()))}function ac(e){e!==P.snapshot().scene.canvas.aspect&&F({kind:`setAspect`,aspect:e}).then(()=>Q.seek(Q.positionMs))}function oc(e){if(e===yo())return;let t=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-export-quality`);vo=e,$(P.snapshot()),t&&document.querySelector(`[data-export-quality="${e}"]`)?.focus()}function sc(e){if(e===H)return;let t=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-file-type`);H=e,$(P.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`&&(z?.kind===`mask`||z?.kind===`zoom`)&&Q.seek(Q.positionMs)});function cc(){Qi(N(`transport`),{authored:dt(P.snapshot().scene),rerunLine:Dt(_c(P.snapshot())),playing:Q.playing,enabled:rc&&Z>X,rate:Q.rate,looping:ko},{onToggle:lc,onSkipToStart:()=>Kc({kind:`seekEdge`,edge:`head`},P.snapshot()),onLooping:e=>{ko=e,cc()},onShuttle:e=>{L=null,Q.shuttle(e)}});for(let[e,t]of[[N(`stage-tools`),N(`toolbar-clock`)],[N(`stage-bar`),N(`stage-bar`)]])$i(e,{authored:dt(P.snapshot().scene),rerunLine:Dt(_c(P.snapshot())),positionMs:Q.positionMs-X,durationMs:Z-X,aspect:P.snapshot().scene.canvas.aspect,enabled:rc&&Z>X,fullscreen:!!document.fullscreenElement,error:ao?null:L,zoom:Co},{onAspect:ac,onFullscreen:dc,onZoom:uc,onDismissError:()=>{ao=!0,cc()}},t);let e=N(`timeline`).querySelector(`[data-playhead]`);e&&U&&(e.style.left=`${(fa(U,Q.positionMs)*100).toFixed(4)}%`)}function lc(){L=null,Q.toggle(),$(P.snapshot())}function uc(){Co=Co===`fit`?`actual`:`fit`,document.body.dataset.zoom=Co,cc()}function dc(){L=null;let e=!document.fullscreenElement;(e?N(`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)}`),$(P.snapshot())})}document.addEventListener(`fullscreenchange`,()=>{let e=document.activeElement;L=null,cc();let t=!!document.fullscreenElement;N(`stage`).toggleAttribute(`data-fullscreen`,t);let n=N(t?`stage-tools`:`stage-bar`),r=N(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 fc(){let e=P.snapshot();pc(Pt(e.scene,e.bundle,K?.timeline??null,Q.positionMs))}function pc(e){if(e!==null){if(rn(e)){No=e.reason,$(P.snapshot());return}F(e)}}function mc(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);F(e).then(()=>{let r=P.snapshot();n(r.scene)||z?.kind===t&&z.id===e.id&&(wo(null),$(r))})}function hc(e){if(M(e),lo=e instanceof Error?e.message:String(e),Yc){$(P.snapshot());return}xi(N(`failure`),{error:null,replaySentence:null,captureSentence:null,openError:lo})}function gc(e){return e.bundle===null?{kind:`noFrames`}:{kind:`exact`}}function _c(e){let t=dt(e.scene);return{takeId:eo,authored:t,rerun:j.nav.rerun(eo,t)}}function vc(e){let t=`[demoman] editor: removed pieces — `,n=e?.timeline.cuts??[],r=e?.timeline.unplacedCuts??[];return n.length+r.length===0?`${t}none`:`${t}${[...n.map(e=>`${e.ids.join(`+`)} removed ${Math.round(e.srcStartMs)}-${Math.round(e.srcEndMs)}ms${e.trailing?` (trailing)`:``}`),...r.map(e=>`${e.ids.join(`+`)} removed nothing: ${e.reason}`)].join(`; `)}`}function $(e){Go=!1,Is(),Hs(e);let t=vc(K);t!==es&&(es=t,console.info(t));let n=Lr({scene:e.scene,bundle:e.bundle,resolved:K}),r=N(`name`);r.value=e.scene.meta.name,r.placeholder=qe(e.scene.meta),N(`undo`).disabled=!e.canUndo,N(`redo`).disabled=!e.canRedo,vi(N(`banner`),{hasFrames:e.bundle!==null,route:_c(e)}),R!==null&&e.scene!==so&&(R=null),xi(N(`failure`),{error:e.error??R,replaySentence:e.replaySentence,replayRecoverable:e.replayRecoverable,captureSentence:e.captureSentence,renderError:I.error,previewError:L,logoLoadError:q,wallpaperLoadError:_s??vs,openError:lo,deleteError:uo,navigationError:fo,runsRoute:_c(e)});let i=Kt({scene:e.scene,view:n,bundle:e.bundle,resolved:K,hoverReport:e.hoverReport,rerunLine:Dt(_c(e))});To=i,Eo=n,Do=i.durationMs,(U===null||Mo!==i.durationMs)&&(U=zr(i.durationMs),Mo=i.durationMs);let a={resolved:K,bundle:e.bundle,viewport:e.scene.meta.capture.viewport},o=e=>pc(xn(i,n,e,a)),s=e=>{U=e,$(P.snapshot())},c=e=>{Oo=e,$(P.snapshot())};Va(N(`timeline`),i,{viewport:U,selection:z,get positionMs(){return Q.positionMs},refusal:No,hoverReport:e.hoverReport,snapping:Oo,openJoin:po},{onSelect:e=>{wo(e),$(P.snapshot())},onSeek:e=>Q.seek(e),onSeekStart:()=>Q.pause(),onSplit:fc,onRestorePiece:e=>{po=null,F({kind:`restorePiece`,id:e})},onOpenJoin:e=>{po=e,$(P.snapshot())},onGesture:o,onViewport:s,onSnapping:c}),_i(N(`take-notes`),{notices:[...Zo??[],...$o(e)?[Qo]:[],...i.notices],hoverReport:e.hoverReport}),qa(N(`timeline-tools`),i,{viewport:U,snapping:Oo,get positionMs(){return Q.positionMs}},{onGesture:o,onSplit:fc,onViewport:s,onSnapping:c});let l=z;l?.kind===`piece`&&!i.clip.pieces.some(e=>Ft(e.start,l.start))&&(z=null);let 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);B===`selection`&&!u&&(z===null&&M(Error(`the rail was on Selection with nothing selected`)),wo(null)),document.body.dataset.panel=V?`open`:`closed`,ci(N(`rail`),{rail:B,panelOpen:V,hasSelection:u},{onPick:qc}),li(N(`export-open`),{rail:B,panelOpen:V},{onPick:qc}),ui(N(`shortcuts-open`),{rail:B,panelOpen:V},{onPick:qc});let d=document.activeElement?.matches(`[data-shortcuts-search]`)===!0;ai(N(`inspector`),{selection:z,view:n,model:i,scene:e.scene,hoverReport:e.hoverReport,viewport:e.scene.meta.capture.viewport,rail:B,sections:ho,attachedToCuts:K?.plan.attachedToCuts??[]},{onClose:Jc,onGap:(e,t)=>pc(Sn(n,e,t)),onGapClear:e=>F({kind:`clearGap`,afterActionId:e}),onKeepHover:yc,onZoomOnStep:e=>{let t=n.beats.find(t=>t.actionId===e);if(!t?.anchorId)return;let r=new Set(P.snapshot().scene.camera.map(e=>e.id));F({kind:`addZoom`,marker:{actionId:e,offsetMs:0},target:{kind:`element`,anchorId:t.anchorId},scale:S.defaultZoomScale}).then(()=>{let e=P.snapshot().scene.camera.find(e=>!r.has(e.id));e&&(wo({kind:`zoom`,id:e.id}),$(P.snapshot()))})},onZoomScale:(e,t)=>F({kind:`setZoomScale`,id:e,scale:t}),onRemoveZoom:e=>mc({kind:`removeZoom`,id:e}),onMaskNote:(e,t)=>F({kind:`setMaskNote`,id:e,note:t}),onRemoveMask:e=>mc({kind:`removeMask`,id:e})});let f=document.querySelector(`#inspector [data-panel-shortcuts]`);f!==null&&aa(f,{mac:Or(navigator.userAgent),query:Ao,focus:V&&(jo||d)},{onClose:Jc,onQuery:e=>{Ao=e}}),jo=!1,Ir(N(`stage-overlay`),{canvas:Ro,selection:z,model:i,resolved:K,presentation:G,target:W,outputTimeMs:Q.positionMs},{onMaskRect:(e,t)=>F({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>F({kind:`setZoomTarget`,id:e,point:t})});let p=N(`inspector`);p.querySelector(`.inspector`)===null&&M(Error(`the inspector has not rendered anything`));let m={export:`export`,branding:`background`,cursor:`cursor`},h=e=>{let t=p.querySelector(`[data-panel-${e}]`);return t===null&&B===m[e]&&V&&M(Error(`the inspector's ${e} panel is missing`)),t},g=h(`branding`);g&&Si(g,{branding:e.scene.branding,logoThumb:Ls(e.scene.branding.logo?.ref??null),logoPlacement:G?.logoPlacement??null,formatTitle:Ae(H,e.scene.canvas.aspect),logoNotes:co,wallpaper:{thumbUrl:_e,custom:Rs(e.scene.branding.background),loadError:null},kit:{read:Ya,standing:Qa(e.scene.branding),naming:Za,onApply:e=>{let t=Ya.state===`ready`?Ya.kits.find(t=>t.id===e):void 0;if(t?.read.state!==`ready`){R=t===void 0?`That brand kit was not applied: it was deleted in another tab.`:`That brand kit was not applied: ${t.read.reason}.`,so=P.snapshot().scene,$(P.snapshot());return}Xa=e;let{background:n,logo:r,padding:i}=t.read.kit;F({kind:`setBranding`,patch:{background:n,logo:r,padding:i}}),$(P.snapshot())},onUpdate:()=>void Sc(),onStartNew:()=>{Za={text:``,error:null},$(P.snapshot())},onNameInput:e=>{Za!==null&&(Za={text:e,error:null})},onConfirmNew:e=>void Cc(e),onCancelNew:()=>{Za=null,$(P.snapshot())}}},{onCommit:e=>F({kind:`setBranding`,patch:e}),onPreview:Cs,onLogoFile:e=>bc(e).catch(M),onWallpaperFile:e=>xc(e).catch(M)});let _=h(`cursor`);_&&Fi(_,Ds(e.scene),Os(e.scene),{onCursor:e=>{Is(),F({kind:`setCursor`,patch:e})},onCursorPreview:js,onCursorPreviewEnd:Ps,onMotion:e=>{Is(),F({kind:`setMotion`,patch:e})},onMotionPreview:Ms,onMotionPreviewEnd:Ns},e.scene.meta.capture.device?.touch===!0);let v=go(e.bundle),y=h(`export`);y&&zi(y,{outputs:Po,fileType:H,quality:yo(),aspect:e.scene.canvas.aspect,target:v,recording:Ce(e.bundle,xe(e.scene)),durationMs:i.clip.trim.tailMs-i.clip.trim.headMs,run:I.run,save:I.save,revealError:io,readiness:gc(e),runsRoute:_c(e),currentDigest:So(e.scene),sections:ho,beatAt:wt(n.beats),hasReclaimedMotion:e.bundle?.degradations.some(e=>e.kind===`motionReclaimed`)??!1},{onExport:()=>wc().catch(M),onFileType:sc,onQuality:oc,onSaveAgain:e=>Tc(e).catch(M),onReveal:ws}),rc=n.hasBundle,X=i.clip.trim.headMs,Z=i.clip.trim.tailMs,Ts(e,v),la(N(`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:Ce(e.bundle,xe(e.scene)),target:v,aspect:e.scene.canvas.aspect,takeId:eo,rerun:_c(e).rerun,revealError:io,history:{outputs:Po,currentDigest:So(e.scene),showAll:Io,warningsOpen:Lo,reportContext:{beatAt:wt(n.beats),runsRoute:_c(e)}}},{onCopy:e=>navigator.clipboard.writeText(e),onDownload:e=>Tc([e]).catch(M),onReveal:ws,onShowAll:()=>{Io=!0,$(P.snapshot())},onWarnings:e=>{Lo.delete(e)||Lo.add(e),$(P.snapshot()),document.querySelector(`#take-info [data-output-warnings="${CSS.escape(e)}"]`)?.focus()}}),Q.positionMs<X&&Q.seek(X),Q.positionMs>Z&&Q.seek(Z),cc();let ee=Ds(e.scene),te=Os(e.scene),b=JSON.stringify(e.scene.edits.removed??[]);K&&G&&(e.bundle!==ts||W.height!==ns||Hn(Es,ee)||Un(ks,te)||Wn(rs,G)||b!==Xo)&&(ts=e.bundle,Es=ee,ks=te,rs=G,ns=W.height,Xo=b,Q.seek(Q.positionMs)),Vs(e).catch(M),Bs(e).catch(M)}function yc(e){let t=P.snapshot().hoverReport;if(t===null){M(Error(`kept hover "${e}" with no hover report`));return}P.setHoverReport({...t,removable:t.removable.filter(t=>t!==e)})}async function bc(e){R=null;let t=p(e),n=e=>{R=e,so=P.snapshot().scene,$(P.snapshot())};if(!t.ok)return n(t.reason);let r=new Uint8Array(await e.arrayBuffer());try{await ee(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);ps=t.note===null?null:{ref:i,note:t.note};let a=P.snapshot().scene.branding.logo,o=a?{corner:a.corner,size:a.size,opacity:a.opacity}:le;await P.dispatch({kind:`setBranding`,patch:{logo:{ref:i,...o}}})}async function xc(e){R=null;let t;try{({ref:t}=await j.wallpapers.put(e))}catch(e){R=e instanceof Error?e.message:String(e),so=P.snapshot().scene,$(P.snapshot());return}await P.dispatch({kind:`setBranding`,patch:{background:He(t,P.snapshot().scene.branding.background)}})}async function Sc(){let e=Qa(P.snapshot().scene.branding);if(e===null||!e.edited){R=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}".`,so=P.snapshot().scene,$(P.snapshot());return}let t=e.kit,n=`This demo's background, logo and padding will replace the brand kit "${t.name}".`;try{if(!await b({glyph:`refresh`,title:`Replace "${t.name}"`,body:n,confirmLabel:`Replace`,danger:!1,focus:`confirm`}))return;let e=P.snapshot().scene.branding,r=await Ja.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);Ya=await Ja.read()}catch(e){R=`The brand kit "${t.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,so=P.snapshot().scene}$(P.snapshot())}async function Cc(e){let t=Ya.state===`ready`?Ya.kits:[],n=y(e,t,null);if(!n.ok){Za={text:e,error:n.reason},$(P.snapshot());return}let r=P.snapshot().scene.branding,i=ce();try{let t=await Ja.update(e=>{let t=y(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){Za={text:e,error:t},$(P.snapshot());return}Za=null,Xa=i,Ya=await Ja.read()}catch(e){R=`The brand kit "${n.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,so=P.snapshot().scene}$(P.snapshot())}async function wc(){io=null;let e=P.snapshot().scene;I={run:{phase:`encoding`,done:0,total:0},save:null,error:null},$(P.snapshot());try{await P.settled();let t=yo();await j.exports.start(eo,{fileType:H,aspect:e.canvas.aspect,revision:to,...t===null||H!==`mp4`||vo===null&&!bo?{}:{quality:t}})}catch(e){throw I={...I,run:{phase:`idle`},error:e instanceof Error?e.message:String(e)},$(P.snapshot()),e}}async function Tc(e){let t=Fo(),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`);I={...I,save:await i.save(n)},$(P.snapshot())}var Ec=!1;function Dc(){let e=document.querySelector(`[data-panel-export]`);e!==null&&!Ri(e,I.run,H,gc(P.snapshot()))&&!Ec&&(Ec=!0,M(Error(`the Export panel has no start button, so progress cannot show`)))}function Oc(e){let t=vt(I,e);switch(I=t.flow,t.effect){case`render`:$(P.snapshot());return;case`progress`:Dc();return;case`relist`:j.outputs.list(eo).then(e=>{Po=e,$(P.snapshot())}).catch(M);return;case`none`:return}}j.exports.onEvent(Oc),j.nav.onOpen?.(e=>Fc(()=>location.assign(e))),N(`name`).addEventListener(`change`,e=>{F({kind:`rename`,name:e.target.value.trim()})});var kc=e=>()=>{let t=P.snapshot().scene;e().catch(M).then(()=>ro(t))};N(`undo`).addEventListener(`click`,kc(()=>P.undo())),N(`redo`).addEventListener(`click`,kc(()=>P.redo()));var Ac={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 jc(e){uo=e,Mc()}function Mc(){if(Yc){$(P.snapshot());return}xi(N(`failure`),{error:null,replaySentence:null,captureSentence:null,deleteError:uo,navigationError:fo})}function Nc(e,t,n=``){fo=null;try{location.assign(t())}catch(t){M(t),fo={page:e,reason:`${n}${t instanceof Error?t.message:String(t)}`},Mc()}}function Pc(e=``,t=null){Nc(`Recordings page`,()=>Ke(j.nav.library(),t),e)}function Fc(e){(async()=>{let t=null,n=P.subscribe(e=>{t=e});try{await P.settled()}finally{n()}t?.error??e()})()}N(`back`).addEventListener(`click`,()=>{Fc(()=>Pc())});function Ic(e){let t=Lc(e);t&&(e.preventDefault(),Fc(()=>Nc(`Runs page`,()=>t.href)))}N(`banner`).addEventListener(`click`,Ic),N(`inspector`).addEventListener(`click`,Ic),N(`take-info`).addEventListener(`click`,Ic),N(`failure`).addEventListener(`click`,Ic),N(`take-info`).addEventListener(`toggle`,e=>{N(`take-meta`).setAttribute(`aria-expanded`,String(e.newState===`open`))});function Lc(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 Rc=null;document.addEventListener(`mousedown`,e=>{let t=Lc(e);Rc=t?{link:t,href:t.href}:null},!0),document.addEventListener(`mouseup`,e=>{let t=Rc;if(Rc=null,!t)return;let n=Lc(e);!n||n===t.link||n.href===t.href&&Fc(()=>Nc(`Runs page`,()=>n.href))},!0),N(`delete`).addEventListener(`click`,()=>{(async()=>{try{if(!await b(de))return}catch(e){M(e),jc(`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`);return}uo=null;let e;try{e=await j.scenes.remove(eo)}catch(e){M(e),jc(`Not deleted: ${e instanceof Error?e.message:String(e)}.`);return}if(!e.ok){jc(`Not deleted: ${Ac[e.error]??e.detail??e.error}.`);return}if(e.result!==void 0&&!e.result.ok){let t=e.result.steps.find(e=>!e.ok);jc(`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;Pc(t===null?`This demo was deleted. `:`This demo was deleted. ${t} `,t===null?null:`This demo was deleted. ${t}`)})()});var zc=Symbol.for(`demoman.editor.keydown`),Bc=globalThis,Vc=Bc[zc];Vc instanceof AbortController&&Vc.abort();var Hc=new AbortController;Bc[zc]=Hc;var Uc=!1,Wc=null;document.addEventListener(`pointerdown`,()=>{Uc=!0},{capture:!0,signal:Hc.signal}),document.addEventListener(`pointerdown`,()=>{po!==null&&(po=null,$(P.snapshot()))},{signal:Hc.signal}),document.addEventListener(`keydown`,()=>{Uc=!1},{capture:!0,signal:Hc.signal}),document.addEventListener(`focusin`,e=>{Wc=Uc?e.target:null},{signal:Hc.signal});var Gc=new WeakMap;document.addEventListener(`focusin`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&Gc.set(t,t.value)},{signal:Hc.signal}),document.addEventListener(`change`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&Gc.set(t,t.value)},{capture:!0,signal:Hc.signal}),document.addEventListener(`keydown`,e=>{if(document.querySelector(`dialog[open]`)!==null)return;if(e.key===`Escape`&&po!==null){e.preventDefault(),po=null,$(P.snapshot());return}if(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=Gc.get(t);e!==void 0&&t.value!==e&&(t.value=e)}t?.blur()}return}let r=e.key===`Enter`||e.key===` `&&t!==Wc;if((n===`BUTTON`||n===`A`)&&r&&t?.hasAttribute(`data-tick`)!==!0)return;let i=P.snapshot(),a=br(e,{hasSelection:z!==null,selectionIsBeat:z?.kind===`tick`,canUndo:i.canUndo,canRedo:i.canRedo,panelOpen:V,hasTimeline:U!==null&&Do>0});a!==null&&(e.preventDefault(),Kc(a,i))},{signal:Hc.signal});function Kc(e,t){switch(e.kind){case`playPause`:lc();return;case`shuttle`:L=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`?X:Z);return;case`stepBeat`:{let n=t.scene.actions.map(e=>e.id),r=z?.kind===`tick`?n.indexOf(z.actionId):-1,i=n[r===-1?e.delta>0?0:n.length-1:r+e.delta];if(i===void 0)return;wo({kind:`tick`,actionId:i}),$(t);return}case`setTrim`:{let n=To,r=Eo;if(n===null||r===null||K===null||!rc){let e=_c(t);No=`This take has not been rendered yet, so there is nothing to trim to. ${Ot(e.authored,Dt(e),`first`)}`,$(t);return}pc(xn(n,r,{kind:`trim`,edge:e.edge,toMs:Q.positionMs,snapMs:0},{resolved:K,bundle:t.bundle,viewport:t.scene.meta.capture.viewport}));return}case`split`:fc();return;case`undo`:kc(()=>P.undo())();return;case`redo`:kc(()=>P.redo())();return;case`deleteSelection`:if(z===null)return;if(z.kind===`zoom`){mc({kind:`removeZoom`,id:z.id});return}if(z.kind===`mask`){mc({kind:`removeMask`,id:z.id});return}if(z.kind===`piece`){pc(It(To?.clip.pieces??[],z.start,To?.clip.trim));return}pc({kind:`refusal`,reason:`A step can't be deleted. To take it out of the video, split the clip around it and remove that piece.`});return;case`zoomTimeline`:{if(U===null)return;let n=Math.min(1,Math.max(0,k(U,Q.positionMs)));U=Hr(U,Do,e.factor,n),$(t);return}case`zoomFit`:U=zr(Do),$(t);return;case`toggleSnapping`:Oo=!Oo,$(t);return;case`clearSelection`:wo(null),$(t);return;case`toggleHelp`:qc(`shortcuts`);return;case`closePanel`:Jc();return}}function qc(e){B===e&&V?V=!1:(B=e,V=!0,e===`shortcuts`&&(jo=!0)),e!==`selection`&&(mo=e),$(P.snapshot())}function Jc(){V=!1,$(P.snapshot())}ta(),Zr(),document.body.dataset.zoom=`fit`;{let e=N(`notes`),t=``,n=()=>{ra(N(`notes-open`),e),t=ia(e,t)};new MutationObserver(n).observe(e,{childList:!0,subtree:!0,characterData:!0}),n()}var Yc=!1;P.subscribe(e=>{Yc=!0,lo=null,$(e)}),P.subscribe(e=>as(e).catch(M));async function Xc(){Ya=await Ja.read(),Yc&&$(P.snapshot())}Xc().catch(M),Ja.onChange===void 0?console.info(`demoman: no storage change feed here, so the brand kit is read once`):Ja.onChange(()=>{Xc().catch(M)});async function Zc(){let e=j.exportQuality;if(e===void 0)return;let t=await e.read();bo=t.unreadable===void 0,t.unreadable!==void 0&&console.info(`demoman editor: the Studio exports at ${Pe[t.quality]} quality: ${t.unreadable}`),t.quality!==_o&&(_o=t.quality,Yc&&$(P.snapshot()))}j.exportQuality!==void 0&&(Zc().catch(M),window.addEventListener(`focus`,()=>{Zc().catch(M)})),j.outputs.list(eo).then(e=>{Po=e,Yc&&$(P.snapshot())}).catch(M),P.load().catch(hc);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l}from"./confirm-dialog-DgJ946Hc.js";import{c as u,i as d,n as f,r as p,s as m,t as h,u as g}from"./state-DyL2jOOv.js";import{n as _,r as v,t as y}from"./topbar-sSUyITjl.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}}}function E(e,t,n,r={}){let i=document.createElement(`div`);i.className=`empty`;for(let[e,t]of Object.entries(r))i.setAttribute(e,t);let o=document.createElement(`strong`);o.textContent=t;let s=document.createElement(`p`);s.className=`hint`,s.append(...typeof n==`string`?[n]:n);let c=document.createElement(`div`);return c.append(o,s),i.append(a(e),c),i}var ee=e=>e.kind===`upkeep`?null:e.kind===`video`?`record`:`folder`,D=(e,t)=>`${e}:${t}`,O=1024**3;function k(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 A(e,t,n={}){let r=k(`span`,{class:`tag`,...n});return r.append(a(e),t),r}function te(){let e=k(`div`,{class:`meter`}),t=k(`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 j=`storage-panel`,M=16,ne=300;function N(e,t,n=!1){let r=t.getBoundingClientRect(),i=document.documentElement.clientWidth,a=Math.min(ne,i-32),o=r.right-a>=M?r.right-a:r.left,s=Math.max(M,Math.min(o,i-M-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-M-d,p=r.top-6-M,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/O).toFixed(2).replace(/\.?0+$/,``);function ie(e){let t=null,n=k(`div`,{class:`library`,"data-library":``}),r=k(`aside`,{class:`library-side`,"data-header":``}),i=k(`nav`,{class:`side-group`,"aria-label":`Sections`,"data-jumps":``}),o=k(`div`,{class:`library-content`}),s=te();s.bar.setAttribute(`aria-hidden`,`true`);let c=k(`span`,{"data-meter":``}),l=k(`button`,{type:`button`,class:`btn btn-quiet storage-trigger`,"data-storage-trigger":``,popovertarget:j,"aria-controls":j});l.append(k(`span`,{class:`storage-label`},`Storage`),s.bar,c,a(`chevronDown`));let u=k(`div`,{class:`storage`}),f=k(`span`,{"data-total-size":``}),p=k(`span`,{class:`library-total`,"data-library-total":``});p.append(k(`span`,{class:`storage-label`},`Storage`),f);let m=k(`div`,{"data-notices":``}),g=k(`div`,{id:j,class:`storage-panel`,popover:``,"data-storage":``,"aria-label":`Storage`}),_=null;g.addEventListener(`beforetoggle`,e=>{e.newState===`open`&&N(g,l)}),g.addEventListener(`toggle`,e=>{let t=e.newState===`open`;l.toggleAttribute(`data-open`,t),_?.abort(),_=null,t&&(N(g,l),_=new AbortController,window.addEventListener(`resize`,()=>N(g,l),{signal:_.signal}),window.addEventListener(`scroll`,()=>N(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=k(`p`,{class:`storage-used`,"data-storage-used":``}),b=k(`input`,{type:`number`,min:`0.25`,step:`0.25`,id:`storage-budget`,"data-storage-budget":``}),x=k(`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*O))});let S=k(`div`,{class:`storage-budget-row`});S.append(b,k(`span`,{},`GB`));let C=k(`div`,{class:`storage-field`});C.append(k(`label`,{for:`storage-budget`},`Budget`),S,k(`p`,{class:`storage-hint`},`Saves automatically.`),x);let w=k(`button`,{type:`button`,"data-action":`reclaim`,class:`btn btn-quiet storage-reclaim`});w.append(a(`trash`),`Reclaim space`),w.addEventListener(`click`,()=>t?.reclaim?.());let T=k(`div`,{class:`storage-foot`});T.append(w,k(`p`,{class:`storage-hint`},`Clears cached exports, then hosted takes' motion, oldest first, until the library fits its budget.`)),g.append(k(`h2`,{class:`storage-title`},`Storage`),v.bar,y,C,T),u.append(l,g),r.append(k(`h1`,{},`Recordings`),i),o.append(m),n.append(r,o);let E=document.querySelector(`[data-storage-slot]`);return e&&(E??r).append(u),{box:n,jumps:i,content:o,notices:m,update(e,n){if(t=n,e.totalBytes===void 0)p.remove();else{let t=e.unmeasured??0,n=`${d(e.totalBytes)}${t>0?`+`:``}`,i=t>0?`${t} ${t===1?`folder`:`folders`} could not be measured`:null;f.textContent=n,p.setAttribute(`aria-label`,`Storage: ${n}${i===null?``:` (${i})`}`),i===null?p.removeAttribute(`title`):p.setAttribute(`title`,i),p.parentNode===null&&(E??r).append(p)}let i=d(e.usedBytes),a=d(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(k(`p`,{"data-migrating":``,class:`notice`},`Measuring existing demos…`)),e.migrationFailed&&t.push(k(`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(k(`p`,{"data-chrome-limit":``,class:`notice notice-warn`},`Chrome is near its storage limit on this drive.`)),e.unwatched!=null&&t.push(k(`p`,{"data-unwatched":``,class:`notice notice-warn`},`New takes will not show until you reload — ${e.unwatched}.`)),e.notice!==null&&t.push(k(`p`,{"data-notice":``,class:`notice notice-error`},e.notice)),t}var oe=new WeakMap;function se(e,t){let n=k(`div`,{class:`row-tags`}),r=t.openReview;if(e.needsLook&&r!==void 0){let t=k(`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(a(`circleAlert`)),t.addEventListener(`click`,()=>r(e.sceneId)),n.append(t)}return e.hosted&&n.append(A(`cloud`,`Hosted`,{"data-hosted":``,title:`Hosted copy stays online after a local delete`})),e.state===`Motion reclaimed`?n.append(A(`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(A(`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=k(`div`,{"data-preview":``}),r=k(`canvas`,{"data-preview-canvas":``,"aria-hidden":`true`,hidden:``});n.append(r,k(`p`,{"data-preview-note":``},S({kind:`loading`})??``));let i=se(e,t);return i!==null&&n.append(i),n.append(k(`span`,{"data-duration":``,hidden:``})),n}var le={Complete:`complete`,"Motion reclaimed":`reclaimed`,"Keyframes only":`keyframesOnly`},P=e=>`name-${e}`;function ue(e,t,n){let r=n===null?e.name:n.video.name,i=k(`input`,{type:`text`,id:P(e.sceneId),"data-name":``,"aria-label":n===null?`Demo name`:`Video name`,title:r,placeholder:`Untitled`,spellcheck:`false`,autocomplete:`off`});i.value=r;let a=r;return i.addEventListener(`change`,()=>{let r=i.value.trim();if(r===a||n!==null&&r===``){i.value=a;return}a=r,i.value=r,i.title=r,n===null?t.rename(e.sceneId,r):t.renameVideo(n.video.id,r)}),i.addEventListener(`keydown`,e=>{e.key===`Escape`?(i.value=a,i.blur()):e.key===`Enter`&&i.blur()}),i}function de(e,t,n,r,i,o,s){let c=k(`article`,{class:`card`,"data-row":e.sceneId,"data-state":le[e.state],...i===null?{}:{"data-video":i.video.id},...e.name===``&&i===null?{"aria-label":e.label}:{"aria-labelledby":P(e.sceneId)}}),u=!1;c.addEventListener(`pointerdown`,()=>{let e=document.activeElement;u=e?.matches(`[data-name]`)===!0&&c.contains(e)}),c.addEventListener(`click`,n=>{let r=n.target;u||r.closest(`button, input, a, [data-versions]`)||(window.getSelection()?.toString()??``)===``&&e.expired!==!0&&t.edit(e.sceneId)}),c.append(ce(e,t));let f=k(`div`,{class:`row-actions`});if(e.servesReshoot){let n=k(`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(a(`undo`)),n.addEventListener(`click`,()=>t.backToRecording(e.sceneId)),f.append(n)}let p=e.canRestore||e.expired===!0?t.rerunLine?.(e.sceneId,e.authored)??null:null;if(e.canRestore&&p===null){let n=k(`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(a(`restore`)),n.addEventListener(`click`,()=>t.restore(e.sceneId)),f.append(n)}let h=k(`button`,{type:`button`,"data-action":`edit`,class:`btn btn-quiet btn-icon`,"aria-label":`Edit ${e.label}`,title:`Edit`});h.append(a(`clapperboard`)),h.addEventListener(`click`,()=>t.edit(e.sceneId)),e.expired!==!0&&f.append(h);let g=k(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${e.label}`,title:`Delete`});g.append(a(`trash`)),g.addEventListener(`click`,()=>i===null?t.remove(e.sceneId,`take`):t.remove(i.video.id,`video`)),f.append(g);let _=k(`div`,{class:`row-text`}),v=k(`div`,{class:`row-title`});v.append(ue(e,t,i),f),_.append(v);let y=i===null?null:m(i.video.repo),b=`${y===null?``:`${y} · `}${e.origin}${e.path}`,x=k(`div`,{class:`row-line`});if(x.append(k(`p`,{class:`row-meta`,"data-meta":``,title:b},`${b} · ${r?e.time:e.when}`)),e.sizeBytes===void 0?t.reclaim!==void 0&&x.append(k(`p`,{"data-size":``,class:`row-size`},`${d(e.frameBytes)} frames · ${d(e.outputBytes)} renders`)):x.append(k(`p`,{"data-size":``,class:`row-size`},d(e.sizeBytes))),_.append(x),c.append(_),i!==null&&i.versions.length>1)c.append(fe(i,t,o,s));else if(i!==null){let e=pe(i.versions[0]?.exports);e!==null&&c.append(e)}if(p!==null){let e=k(`p`,{"data-rerun-line":``,class:`row-rerun`});l(e,p),c.append(e)}return n!==void 0&&c.append(k(`p`,{"data-status":``,class:`notice notice-error`},n)),c}function fe(e,t,n,r){let i=k(`details`,{class:`versions`,"data-versions":e.video.id});i.open=r;let o=k(`summary`,{class:`versions-count`}),s=a(`chevronRight`);s.classList.add(`chev`),o.append(s,`${e.versions.length} versions`),i.append(o);let c=k(`ol`,{class:`versions-list`});for(let r of e.versions){let i=k(`li`,{class:`version`,"data-version-row":r.sceneId,...r.expired===!0?{"data-expired":``}:{}}),o=k(`div`,{class:`version-head`});o.append(k(`span`,{class:`version-number`},`v${r.version??`?`}`),k(`span`,{class:`version-when`,title:r.when},r.when));let s=k(`div`,{class:`row-actions`}),u=r.expired===!0?t.rerunLine?.(r.sceneId,r.authored)??null:null;if(r.expired!==!0){let n=k(`button`,{type:`button`,"data-action":`edit`,class:`btn btn-quiet btn-icon`,"aria-label":`Edit version ${r.version??``} of ${e.video.name}`,title:`Edit`});n.append(a(`clapperboard`)),n.addEventListener(`click`,()=>t.edit(r.sceneId)),s.append(n)}let d=k(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete version ${r.version??``} of ${e.video.name}`,title:`Delete`});d.append(a(`trash`)),d.addEventListener(`click`,()=>t.remove(r.sceneId,`take`)),s.append(d),o.append(s),i.append(o);let f=pe(r.exports);if(f!==null&&i.append(f),u!==null){let e=k(`p`,{"data-rerun-line":``,class:`row-rerun`});l(e,u),i.append(e)}let p=n.get(D(`take`,r.sceneId));p!==void 0&&i.append(k(`p`,{"data-status":``,class:`notice notice-error`},p)),c.append(i)}return i.append(c),i}function pe(e){if(e===void 0)return null;if(`unreadable`in e)return k(`p`,{class:`row-rerun`,"data-exports-unreadable":``},`Its exports could not be read: ${e.unreadable}`);if(e.length===0)return null;let t=k(`ul`,{class:`version-exports`});for(let n of e){let e=n.path.slice(n.path.lastIndexOf(`/`)+1)||n.path,r=k(`li`,{"data-export":n.path,title:n.path,...n.exists?{}:{"data-gone":``}});r.append(k(`span`,{class:`export-name`},e),k(`span`,{class:`export-type`},n.exists?n.fileType.toUpperCase():`${n.fileType.toUpperCase()} · gone`)),t.append(r)}return t}var me=e=>new Set([...e.querySelectorAll(`[data-versions]`)].filter(e=>e.open).map(e=>e.getAttribute(`data-versions`)));function he(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 ge(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 _e=e=>`section-${e.replace(/:/g,`-`)}`;function ve(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}var F=`unreadable`,I=e=>`when-${e.replace(/:/g,`-`)}`;function ye(e,t){let n=k(`div`,{class:`side-list`});for(let t of e){let e=I(t.key),r=k(`a`,{href:`#${e}`,class:`side-item`,"data-nav":e,title:t.label});r.append(k(`span`,{class:`side-label`},t.label),k(`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=k(`a`,{href:`#${F}`,class:`side-item`,"data-nav":F,title:`Couldn't read`});e.append(k(`span`,{class:`side-label`},`Couldn't read`),k(`span`,{class:`side-count`},String(t))),n.append(e)}return n}function be(e,t,n,r,i,o){let s=_e(e.key),c=k(`details`,{class:`section`,id:I(e.key),"data-section":e.key,"aria-labelledby":s});c.open=t;let l=k(`summary`,{class:`section-head`}),u=a(`chevronRight`);u.classList.add(`chev`),l.append(u,k(`h2`,{id:s},e.label),k(`span`,{class:`section-count`,"data-section-count":``},String(e.rows.length))),c.append(l);let d=k(`div`,{class:`rows`}),f=e.rows.map(t=>{let a=i.get(t.sceneId)??null,s=de(t,n,a===null?r.get(D(`take`,t.sceneId)):r.get(D(`video`,a.video.id))??(a.versions.length>1?void 0:r.get(D(`take`,t.sceneId))),e.namesDay,a,r,a!==null&&o.has(a.video.id));return d.append(s),[t.sceneId,s]});return c.append(d),{box:c,articles:f}}function xe(e,t,n){let r=k(`section`,{class:`section`,id:F,"data-unreadable":``,"aria-labelledby":`section-unreadable`}),i=k(`div`,{class:`section-head`});i.append(k(`h2`,{id:`section-unreadable`},`Couldn't read`),k(`span`,{class:`section-count`},String(e.length))),r.append(i);let o=k(`div`,{class:`rows`});for(let r of e){let e=k(`article`,{class:`card`,"data-unreadable-row":r.folder}),i=k(`div`,{class:`row-text`}),s=k(`div`,{class:`row-title`});s.append(k(`p`,{class:`row-meta`,"data-unreadable-name":``},r.folder));let c=ee(r);if(c!==null){let e=k(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${r.folder}`,title:`Delete`});e.append(a(`trash`)),e.addEventListener(`click`,()=>t.remove(r.folder,c)),s.append(e)}i.append(s,k(`p`,{class:`row-meta`,"data-reason":``},r.reason)),r.sizeBytes!==void 0&&i.append(k(`p`,{"data-size":``,class:`row-size`},d(r.sizeBytes))),e.append(i);let l=c===null?void 0:n.get(D(c,r.folder));l!==void 0&&e.append(k(`p`,{"data-status":``,class:`notice notice-error`},l)),o.append(e)}return r.append(o),r}function Se(e,t,n,r,i=new Date){let a=he(e),o=ve(e),s=me(e),c=oe.get(e);c===void 0&&(c=ie(n.reclaim!==void 0&&n.setBudget!==void 0),oe.set(e,c)),c.update(t,n);for(let t of[...e.childNodes])t!==c.box&&t.remove();c.box.parentNode!==e&&e.prepend(c.box);for(let e of[...c.content.childNodes])e!==c.notices&&e.remove();c.jumps.replaceChildren();let l=c.content,d=t.unreadable??[],f=()=>{d.length>0&&l.append(xe(d,n,r))};if(t.rows.length===0){if(d.length>0){f();return}let e=k(`div`,{"data-empty":``,class:`card empty-card`});e.append(E(`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.`)),l.append(e);return}let m=p(t),h=m.map(e=>e.row),g=new Map(m.flatMap(e=>e.group===null?[]:[[e.row.sceneId,e.group]])),_=[],v=u(h,i);c.jumps.append(ye(v,d.length));for(let e of v){let t=be(e,o.get(e.key)??!e.folded,n,r,g,s);l.append(t.box),_.push(...t.articles)}f();for(let[e,t]of _)n.preview(e,t.querySelector(`[data-preview]`));ge(e,a)}var L=document.querySelector(`#root`),R=document.querySelector(`#notice`),Ce=v(L),z=r(),B=z.scenes;z.nav.onOpen?.(e=>location.assign(e)),y(z);var V=new Map;function H(e,t){R.textContent=e,R.className=t===`info`?`notice`:`notice notice-${t}`,R.classList.remove(`hidden`)}function we(e){H(e,`error`)}function Te(){R.textContent=``,R.className=`notice notice-error hidden`}function U(e,t){console.error(`demoman library: ${e} —`,t),we(`Something went wrong (${e}). Try again.`)}function Ee(e,t){try{location.assign(e)}catch(e){U(t,e)}}var W=z.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,De=!1,Oe=(e,t)=>K===null?(De||(De=!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,ke={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 s(n,t,W.load)},image:async e=>{if(z.folder!==void 0)return z.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:Oe},J=null,Y=null;function Ae(e){let t=new Set([...e.rows.map(e=>D(`take`,e.sceneId)),...(e.groups??[]).map(e=>D(`video`,e.video.id)),...(e.unreadable??[]).flatMap(e=>{let t=ee(e);return t===null?[]:[D(t,e.folder)]})]);for(let e of V.keys())t.has(e)||V.delete(e)}function je(e){Ae(e),J?.dispose(),J=T(ke),Se(L,e,Re,V),Ce.mark()}var Me=_({paint:e=>Ne({keepNotice:e}),onRefreshFailed:e=>U(`refreshing the library`,e)});function X(){return Me.render()}async function Ne({keepNotice:e=!1}={}){e||Te();let t=await z.folder.read(),n=t.scenes;q=new Map(n.map(e=>[e.meta.id,e]));let r=f({videos:t.videos,videoOf:t.videoOf,sizes:t.sizes,unreadable:t.unreadable,unwatched:t.unwatched,emptyHint:z.nav.firstTakeHint(),scenes:n,migrating:!1,migrationFailed:!1,notice:null,needsLook:new Set});Y=r,je(r)}var Pe={recording:`a take is recording`,rendering:`a render is running`,sharing:`a share is in progress`,replaying:`a take is being run in Runs`},Z=new Map;function Fe(e,t,n){let r=Z.get(e)??Z.get(Q(e)??``);if(r===void 0){Ee(t,n);return}r.then(e=>{e&&Ee(t,n)})}function Q(e){return Y?.groups?.find(t=>t.versions.some(t=>t.sceneId===e))?.video.id}function Ie(t,n){if(n===`record`)return i;if(n===`video`){let n=Y?.groups?.find(e=>e.video.id===t);return n===void 0?c:e(n.video.versions)}return n===`take`&&Q(t)!==void 0?o:c}function Le(e){return q.get(e)?.meta.capture.mode===`authored`}var Re={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=>{Fe(e,z.nav.editor(e),`opening the editor`)},rename:(e,t)=>{let n=(async()=>{try{let n=null;try{let r=await B.get(e);if(r===null)n=`the take is no longer stored`;else{let e={...r.scene,meta:{...r.scene.meta,name:t}};await B.put(e,r.revision)}}catch(e){n=e instanceof Error?e.message:String(e)}let r=D(`take`,e);return n===null?V.delete(r):V.set(r,`Couldn't rename: ${n}.`),await X(),n===null}catch(t){return U(`renaming this demo`,t),V.set(D(`take`,e),`Couldn't rename: ${t instanceof Error?t.message:String(t)}.`),Y!==null&&je(Y),!1}})();Z.set(e,n),n.finally(()=>{Z.get(e)===n&&Z.delete(e)})},renameVideo:(e,t)=>{let n=(async()=>{let n=D(`video`,e),r=null;try{await z.videos.rename(e,t)}catch(e){r=e instanceof Error?e.message:String(e)}r===null?V.delete(n):V.set(n,`Couldn't rename: ${r.replace(/\.$/,``)}.`);try{await X()}catch(e){U(`refreshing the library`,e)}return r===null})();Z.set(e,n),n.finally(()=>{Z.get(e)===n&&Z.delete(e)})},restore:e=>{let t=z.nav.rerun(e,Le(e));if(t.kind===`line`){console.error(`demoman library: Restore was pressed on a platform whose route is a line`);return}Fe(e,new URL(t.href,z.nav.library()).href,`opening Runs to restore motion`)},rerunLine:(e,t)=>{let n=z.nav.rerun(e,t);return n.kind===`line`?n.text:null},backToRecording:e=>{(async()=>{let t=null,n=await Z.get(e),r=D(`take`,e),i=n===!1?V.get(r):void 0;try{let n=await B.get(e);if(n===null)throw Error(`the take is no longer stored`);let r={...n.scene,meta:{...n.scene.meta,renderMode:`screen`}};await B.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){U(`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===``?V.delete(r):V.set(r,a);try{await X()}catch(e){U(`refreshing the library`,e)}})()},remove:(e,t)=>{let r=D(t,e);(async()=>{try{let i;try{i=await n(Ie(e,t))}catch(e){console.error(`demoman library: asking before a delete —`,e),V.set(r,`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`),await X();return}if(!i)return;await Z.get(e);let a=t===`video`||t===`record`?await z.videos.remove(e):await B.remove(e),o=null;if(!a.ok){let e=a.detail??Pe[a.error]??a.error;V.set(r,`Not deleted: ${e}.`)}else if(a.partly!==void 0)V.delete(r),o=`Partly deleted: ${a.partly}.`;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?(V.delete(r),o=t):V.set(r,t)}else V.delete(r);await X(),o===null?a.ok&&a.note!==void 0&&H(a.note,`info`):we(o)}catch(e){U(`deleting this demo`,e)}})()}};z.folder?.onChange(()=>Me.soon());var $=g();X().then(()=>{$!==null&&H($,`info`)},e=>{$!==null&&console.info(`demoman library: ${$}`),U(`loading your demos`,e)});
|
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
/* Settings' shape since 2026-10-08: a left column with the title and
|
|
12
12
|
a jump list of the sections, held in view on a wide window; the
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
page's. One column under 1024px, not Settings' 768: the list is a
|
|
13
|
+
list beside it. The list's column starts the title's height lower
|
|
14
|
+
— its 36px line and 28px under it — so the first section sits
|
|
15
|
+
level with the jump list and the title reads as the page's. One column under 1024px, not Settings' 768: the list is a
|
|
17
16
|
grid of 270px cards, and beside a column at 800px it had room for
|
|
18
17
|
one. The storage trigger is in the top bar. */
|
|
19
18
|
.library { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
|
|
@@ -210,26 +209,6 @@
|
|
|
210
209
|
|
|
211
210
|
[data-notices] > .notice { margin: 0 0 16px; }
|
|
212
211
|
|
|
213
|
-
/* The filter row: pills for hosts and for states over the list they
|
|
214
|
-
narrow, only when the view renders one (there has to be something
|
|
215
|
-
to choose between). On the dotted ground, not a card: the
|
|
216
|
-
ground's opaque control tones, or the dots show through a dark
|
|
217
|
-
theme's translucent ones. */
|
|
218
|
-
.filters {
|
|
219
|
-
display: flex;
|
|
220
|
-
flex-wrap: wrap;
|
|
221
|
-
align-items: center;
|
|
222
|
-
gap: 6px;
|
|
223
|
-
--control: var(--control-ground);
|
|
224
|
-
--control-hover: var(--control-hover-ground);
|
|
225
|
-
}
|
|
226
|
-
.filters-sep {
|
|
227
|
-
width: 1px;
|
|
228
|
-
height: 18px;
|
|
229
|
-
margin: 0 4px;
|
|
230
|
-
background: var(--ring-strong);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
212
|
/* The list, in sections by when the take was made: Today, Yesterday,
|
|
234
213
|
the last week by weekday, then a month at a time (view.ts,
|
|
235
214
|
state.ts's sectionsOf). Each section is a fold whose summary is
|
|
@@ -242,9 +221,6 @@
|
|
|
242
221
|
list of lines. */
|
|
243
222
|
.section { margin-top: 8px; }
|
|
244
223
|
.library-content > .section:first-of-type { margin-top: 0; }
|
|
245
|
-
/* 28px under the filters, as under the title before 2026-10-08. At
|
|
246
|
-
the first section's own specificity, or the rule above wins. */
|
|
247
|
-
.library-content > .filters + .section { margin-top: 28px; }
|
|
248
224
|
.section[open] + .section { margin-top: 40px; }
|
|
249
225
|
|
|
250
226
|
/* A section's summary: Settings' chevron, the heading, its count. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,_ as t,ct as n,f as r,g as i,i as a,l as o,lt as s,m as c,o as l,p as u,pt as ee,v as te,y as ne}from"./confirm-dialog-DgJ946Hc.js";import{E as re,O as ie,S as d,T as f,b as ae,h as p,i as m,n as h,r as oe,t as se,w as ce}from"./view-Df6XUnyO.js";import{n as le,r as ue,t as de}from"./topbar-sSUyITjl.js";function fe(e,t,n,r){let i=document.createElement(`div`);i.className=`notice-body`;let a=document.createElement(`p`);if(a.className=`notice-title`,a.textContent=typeof t==`string`?t:t.title,i.append(a),typeof t!=`string`){let e=document.createElement(`details`);e.className=`notice-details`;let n=document.createElement(`summary`);n.append(`Details`,l(`chevronDown`));let r=document.createElement(`div`);r.className=`notice-reason`,r.dataset.noticeReason=``,r.textContent=t.detail,e.append(n,r),i.append(e)}let o=document.createElement(`button`);o.type=`button`,o.className=`notice-dismiss`,o.dataset.noticeDismiss=``,o.setAttribute(`aria-label`,`Dismiss`),o.title=`Dismiss`,o.append(l(`close`)),o.addEventListener(`click`,r),e.className=n===`info`?`notice notice-line`:`notice notice-line notice-${n}`,e.replaceChildren(...n===`info`?[]:[l(`circleAlert`)],i,o)}function g(e,t){let n=e.querySelector(`:scope > .notice-dismiss`);if(n===null||e.classList.contains(`hidden`))return!1;let r=e.querySelector(`:scope > .notice-actions`);return r===null&&(r=document.createElement(`div`),r.className=`notice-actions`,n.before(r)),r.append(t),!0}var _=document.querySelector(`#root`),pe=ue(_),v=document.querySelector(`#notice`),y=o(),b=y.kits,x={state:`ready`,kits:[],defaultId:null,migrationPending:!1},S=null,C=null,w=null,T=null,E=null,D=new Map,O=new Map,k=Promise.resolve(),A=null;function j(e){let t=f(e,h),n=D.get(t);return n===void 0&&(n=k.then(()=>ae(e,h,y.wallpapers)).then(e=>({ok:!0,image:e.image}),e=>({ok:!1,error:U(e)})),k=n,D.set(t,n),n.then(e=>O.set(t,e))),n}function M(e){if(!d(e))return null;let t=O.get(f(e,h));return t?.ok?t.image:null}async function me(e){let t=e.background,n=d(t)?j(t):null;if(x.state===`ready`)for(let e of x.kits){if(e.read.state!==`ready`)continue;let t=e.read.kit.background;if(!d(t))continue;let n=f(t,h);D.has(n)||j(t).then(()=>_e(e.id))}if(n===null)return;let r=await n;if(t.kind!==`image`||A?.ref===t.ref&&A.thumb?.kind===`ready`)return;let i;if(!r.ok)i={kind:`failed`,reason:r.error};else try{i={kind:`ready`,url:await re(r.image)}}catch(e){i={kind:`failed`,reason:U(e)}}let a=A?.thumb;a?.kind===`ready`&&a!==i&&URL.revokeObjectURL(a.url),A={ref:t.ref,thumb:i}}var he=()=>x.state===`ready`?x.kits.find(e=>e.id===S)??null:null,N=()=>{let e=he();return e?.read.state===`ready`?e.read.kit:n};function P(){x.state===`ready`&&(x.kits.some(e=>e.id===S)||(S=ne(x)?.id??x.kits[0]?.id??null))}var F=0;async function I(e){let t=null,n=await b.update(async n=>{let r=await e(n);if(typeof r==`string`)return r;let i=r.kits[0];return i===void 0||r.kits.some(e=>e.id===r.defaultId)?r:(t=i.name,{...r,defaultId:i.id})});return n===null?(F+=1,x=await b.read(),P(),t===null?null:{warn:`Your default kit was missing, so "${t}" is the default now.`}):n}async function L(e){let t=null,n=await e(e=>(t=e,e));return typeof n!=`string`&&t!==null&&(S=t,P()),n}var R=null;function z(e,t){return I(async r=>{if(r.kits.length===0){let e=await t(n);if(typeof e==`string`)return e;let r=u();return S=r,R=r,{kits:[{id:r,name:`Brand kit`,branding:e}],defaultId:r}}let i=e??R,a=r.kits.find(e=>e.id===i);if(a===void 0)return i===null?`this page's kit list was out of date, so nothing was changed — it now shows your kits as they are`:`the kit was deleted in another tab`;let o=te(a.branding),s=await t(o.state===`ready`?o.kit:n);return typeof s==`string`?s:{...r,kits:r.kits.map(e=>e.id===i?{...e,branding:s}:e)}})}async function ge(t){let n=t.logo?.ref??null;if(n===null){C=null,w=null,T=null;return}if(C?.ref!==n){let e=await y.logos.load(n);C=e.ok?{ref:n,source:e.source,error:null}:{ref:n,source:null,error:e.error}}if(w=null,C.source!==null)try{w=await C.source.rasterAt(e(t,h))}catch(e){C={ref:n,source:null,error:U(e)}}if(C.source===null)T={kind:`failed`,reason:C.error??`the page did not try to load it`};else try{T={kind:`ready`,url:await ie(C.source)}}catch(e){T={kind:`failed`,reason:U(e)}}}function B(e,t=`all`){let n=document.querySelector(`[data-preview-kit]`);if(n===null)return;let r=getComputedStyle(document.documentElement),i=r.getPropertyValue(`--card`).trim()||`#ffffff`,a=Number.parseFloat(r.getPropertyValue(`--radius`))||0;m(n,e,w,i,a,M(e.background))||console.info(`demoman settings: the brand kit preview has no 2D context`);for(let n of document.querySelectorAll(`[data-kit-thumb]`)){let r=n.getAttribute(`data-kit-thumb`);if(t===`selected`&&r!==S)continue;let o=x.state===`ready`?x.kits.find(e=>e.id===r):void 0;o?.read.state===`ready`&&V(n,r===S?e:o.read.kit,i,a)}}function V(e,t,n,r){let i=t.background,a=d(i)?O.get(f(i,h)):void 0,o=e.parentElement;if(o?.querySelector(`[data-kit-thumb-alert]`)?.remove(),a?.ok===!1){e.title=`The image could not be loaded: ${a.error}`;let t=document.createElement(`span`);t.className=`kit-thumb-alert`,t.setAttribute(`data-kit-thumb-alert`,``),t.setAttribute(`role`,`img`),t.setAttribute(`aria-label`,e.title),t.append(l(`circleAlert`)),o?.append(t)}else e.removeAttribute(`title`);m(e,t,null,n,r,M(i))||console.info(`demoman settings: a kit tile has no 2D context`)}function _e(e){if(e===S)return;let t=document.querySelector(`[data-kit-thumb="${CSS.escape(e)}"]`),n=x.state===`ready`?x.kits.find(t=>t.id===e):void 0;if(t===null||n?.read.state!==`ready`)return;let r=getComputedStyle(document.documentElement);V(t,n.read.kit,r.getPropertyValue(`--card`).trim()||`#ffffff`,Number.parseFloat(r.getPropertyValue(`--radius`))||0)}y.nav.onOpen?.(e=>be(e,()=>location.assign(e),new URL(e,location.href).searchParams.has(`scene`)?`Open the take`:`Open Recordings`)),de(y);var H=new Map,U=e=>e instanceof Error?e.message:String(e);function W(e,t){fe(v,e,t,K)}function G(e){W(e,`error`)}function K(){v.replaceChildren(),v.className=`notice notice-error hidden`}function q(e,t){console.error(`demoman settings: ${e} —`,t),G({title:`Couldn't ${e}`,detail:U(t)})}function J(e,t){let n=H.get(e);H.set(e,n===void 0?t:`${n}. ${t}`)}async function ve(e,t,n){try{return await n()}catch(n){for(let r of typeof e==`string`?[e]:e)J(r,`Couldn't read ${t}: ${U(n)}`);return null}}var Y=le({paint:e=>ye({keepNotice:e}),onRefreshFailed:e=>q(`refresh Settings`,e),hold:we});function X(){return Y.render()}async function ye({keepNotice:e=!1}={}){e||K(),H.clear();let t=F,[n,r,i]=await Promise.all([b.read(),ve(`pullRequests`,`the Pull requests setting`,()=>y.pullRequests.read()),ve(`export`,`the Export quality setting`,()=>y.exportQuality.read())]);i?.unreadable!==void 0&&J(`export`,`Couldn't read the Export quality setting: ${i.unreadable}`),r?.unreadable!==void 0&&J(`pullRequests`,`Couldn't read the Pull requests setting: ${r.unreadable}`),F===t&&(x=n),P();let a=N();await ge(a),await me(a);let o=a.background,s=d(o)?O.get(f(o,h)):void 0,c={exportQuality:i===null||i.unreadable!==void 0?null:i.quality,pullRequests:r===null||r.unreadable!==void 0?null:r.value??`ask`,kitsUnwatched:b.unwatched(),brandKits:x,selectedKitId:S,brandKitLogo:a.logo===null?null:C?.source==null?{ok:!1,error:C?.error??`the page did not try to load it`}:{ok:!0},brandKitLogoThumb:a.logo===null?null:T,brandKitPlacement:oe(a,w),brandKitNotes:[C?.error?`The logo could not be loaded: ${C.error}`:null,E!==null&&E.ref===a.logo?.ref?E.note:null].filter(e=>e!==null),brandKitWallpaper:{custom:A,loadError:s?.ok===!1?s.error:null}};se(_,c,xe,H),pe.mark(),B(a)}var Z=new Set;function Q(e,t){let n=(async()=>{let n;try{n=await t()}catch(t){return q(e,t),`failed`}try{await X()}catch(t){return q(`show the result of: ${e}`,t),`failed`}return n===null?`done`:typeof n==`string`?(G(`Couldn't ${e}: ${n}.`),`failed`):(`warn`in n?W(n.warn,`warn`):W(n.info,`info`),`done`)})();Z.add(n),n.then(()=>Z.delete(n))}function be(e,t,n){Z.size>0&&console.info(`demoman settings: asked to open ${e}; waiting for ${Z.size} change${Z.size===1?``:`s`} here to save first`),(async()=>{let r=!1;for(;;){let e=Y.pending();if((await Promise.all([...Z])).includes(`failed`)&&(r=!0),await e.then(()=>void 0,()=>void 0),Z.size===0&&Y.pending()===e)break}if(r){console.info(`demoman settings: stayed on Settings rather than opening ${e}, because a change here did not save`);let r=document.createElement(`button`);r.type=`button`,r.className=`btn btn-quiet`,r.dataset.openAsked=``,r.textContent=n,r.addEventListener(`click`,()=>{try{t()}catch(t){q(`open ${e}`,t)}}),g(v,r)||(G(`A change here didn't save, so this window stayed on Settings.`),g(v,r));return}try{t()}catch(t){q(`open ${e}`,t)}})()}var xe={setPullRequests:e=>Q(`save the Pull requests setting`,async()=>{let t=await y.pullRequests.write(e);return t.replaced===void 0?null:{warn:t.replaced}}),setExportQuality:e=>Q(`save the Export quality setting`,async()=>{let t=await y.exportQuality.write(e);return t.replaced===void 0?null:{warn:t.replaced}}),setBrandKit:e=>{let t=S;Q(`save the brand kit`,()=>z(t,async t=>{let n=s.safeParse(p(t,e));return n.success?n.data:n.error.issues.map(e=>e.message).join(`; `)}))},previewBrandKit:e=>{try{B(p(N(),e),`selected`)}catch(e){console.info(`demoman settings: a brand kit preview did not apply`,e)}},uploadKitLogo:e=>{let n=S;Q(`add the logo`,async()=>{let r=t(e);if(!r.ok)return r.reason;let a=new Uint8Array(await e.arrayBuffer());try{await i(a,e.type)}catch(t){return`the logo "${e.name}" could not be read as an image: ${U(t)}`}let{ref:o}=await y.logos.put(e);return E=r.note===null?null:{ref:o,note:r.note},z(n,async e=>{let t=e.logo,n=t?{corner:t.corner,size:t.size,opacity:t.opacity}:ee;return p(e,{logo:{ref:o,...n}})})})},uploadKitWallpaper:e=>{let t=S;Q(`add the image`,async()=>{let n;try{({ref:n}=await y.wallpapers.put(e))}catch(e){return U(e)}return z(t,async e=>p(e,{background:ce(n,e.background)}))})},selectKit:e=>{S=e,X().catch(e=>q(`select the kit`,e))},newKit:()=>Q(`add a kit`,()=>L(e=>I(async t=>{let r=e(u());return{kits:[...t.kits,{id:r,name:c(`Untitled kit`,t.kits),branding:n}],defaultId:t.defaultId??r}}))),duplicateKit:e=>Q(`duplicate the kit`,()=>L(t=>I(async n=>{let r=n.kits.find(t=>t.id===e);if(r===void 0)return`the kit was deleted in another tab`;let i={id:t(u()),name:c(`${r.name} copy`,n.kits),branding:structuredClone(r.branding)};return{...n,kits:[...n.kits,i]}}))),renameKit:(e,t)=>Q(`rename the kit`,()=>I(async n=>{let i=r(t,n.kits,e);return i.ok?{...n,kits:n.kits.map(t=>t.id===e?{...t,name:i.name}:t)}:i.reason})),setDefaultKit:e=>Q(`make the kit the default`,()=>I(async t=>t.kits.some(t=>t.id===e)?{...t,defaultId:e}:`the kit was deleted in another tab`)),deleteKit:e=>Q(`delete the kit`,async()=>{if(x.state!==`ready`)return`the kits could not be read`;let t=x.kits.find(t=>t.id===e);if(t===void 0)return`the kit was deleted in another tab`;if(x.kits.length===1)return`the last kit cannot be deleted`;let n=x.kits.find(t=>t.id!==e),r=x.defaultId===e&&n!==void 0?` "${n.name}" becomes the default kit.`:``;return await a({glyph:`trash`,title:`Delete "${t.name}"`,body:`"${t.name}" will be deleted.${r} Takes already made keep their look.`,confirmLabel:`Delete`,danger:!0,focus:`cancel`})?I(async t=>{let n=t.kits.filter(t=>t.id!==e);return n.length===0?`the last kit cannot be deleted`:{kits:n,defaultId:t.defaultId===e?n[0]?.id??null:t.defaultId}}):null}),resetKits:()=>Q(`start a fresh kit list`,async()=>{if(!await a({glyph:`trash`,title:`Start a fresh kit list`,body:`Your brand kits could not be read. Starting fresh replaces them with an empty list; takes already made keep their look.`,confirmLabel:`Start fresh`,danger:!0,focus:`cancel`}))return null;let{backup:e}=await b.reset();return F+=1,x=await b.read(),e===null?null:{info:`Started a fresh kit list. The old list is kept at ${e}.`}})},Se=()=>Y.soon(),$=!1,Ce=new Set([`button`,`checkbox`,`file`,`radio`,`range`,`reset`,`submit`]);function we(){if($)return!0;let e=document.activeElement;return e===null||!_.contains(e)?!1:e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!Ce.has(e.type)}var Te=()=>Y.resume();_.addEventListener(`pointerdown`,()=>{$=!0});for(let e of[`pointerup`,`pointercancel`])window.addEventListener(e,()=>{$=!1,Te()});_.addEventListener(`focusout`,()=>setTimeout(Te,0)),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Se()}),b.onChange(Se),X().catch(e=>q(`load Settings`,e));
|
|
@@ -103,6 +103,14 @@
|
|
|
103
103
|
background: var(--error-soft); color: var(--error);
|
|
104
104
|
}
|
|
105
105
|
.kit-thumb-broken svg { width: 20px; height: 20px; }
|
|
106
|
+
/* A kit whose background image did not load: over the neutral the
|
|
107
|
+
tile paints in its place. */
|
|
108
|
+
.kit-thumb-alert {
|
|
109
|
+
position: absolute; top: 12px; left: 12px;
|
|
110
|
+
display: grid; place-items: center; width: 24px; height: 24px;
|
|
111
|
+
border-radius: 6px; background: var(--card); color: var(--error);
|
|
112
|
+
}
|
|
113
|
+
.kit-thumb-alert svg { width: 16px; height: 16px; }
|
|
106
114
|
.kit-tile-name {
|
|
107
115
|
font-size: 12px; font-weight: 600;
|
|
108
116
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){if(e.name.trim()!==``)return e.name;try{let t=new URL(e.capture.originUrl),n=t.pathname===`/`?``:t.pathname;return`${t.host}${n}`}catch{return e.capture.originUrl}}var t=`note`;function n(e,n){if(n===null||n===``)return e;let r=e.indexOf(`#`),i=r<0?e:e.slice(0,r),a=r<0?``:e.slice(r);return`${i}${i.includes(`?`)?`&`:`?`}${t}=${encodeURIComponent(n)}${a}`}function r(e=location,n=history){let r=new URL(e.href),i=r.searchParams.get(t);return i===null?null:(r.searchParams.delete(t),n.replaceState(n.state,``,`${r.pathname}${r.search}${r.hash}`),i===``?null:i)}function i(e){return`unknown`in e?null:`none`in e?`no repo`:e.key.startsWith(`local:`)?e.key.slice(6).split(`/`).filter(e=>e!==``&&e!==`.git`).at(-1)??e.key:e.key.split(`/`).slice(1).join(`/`)||e.key}function a(e,t,n){return n.flatMap(n=>{let r=e.filter(e=>t[e.sceneId]?.videoId===n.id).sort((e,t)=>(t.version??0)-(e.version??0));return r.length===0?[]:[{video:n,current:r.find(e=>e.sceneId===n.current?.takeId)??null,versions:r}]})}function o(e){let t=new Map,n=new Set;for(let r of e.groups??[]){t.set(r.versions[0].sceneId,r);for(let e of r.versions)n.add(e.sceneId)}return e.rows.flatMap(e=>{let r=t.get(e.sceneId);if(r!==void 0){let t=r.current??e,{createdAt:n,when:i,time:a}=e;return[{row:{...t,createdAt:n,when:i,time:a},group:r}]}return n.has(e.sceneId)?[]:[{row:e,group:null}]})}var s={complete:`Complete`,reclaimed:`Motion reclaimed`,keyframesOnly:`Keyframes only`},c=`A budget has to be a number of GB above zero. Nothing was changed.`;function l(e){let t=1024**3,n=1024**2;return e>=t?`${(e/t).toFixed(1).replace(/\.0$/,``)} GB`:e>=n?`${Math.round(e/n)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var u=e=>{try{return new URL(e).host}catch{return e}},d=e=>{try{let t=new URL(e).pathname;return t===`/`?``:t.replace(/\/$/,``)}catch{return``}};function f(e,t){return e.toLocaleString(void 0,{...t?{year:`numeric`}:{},month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}var p=864e5,m=e=>String(e).padStart(2,`0`),h=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function g(e,t){let n=h(t),r=t.getFullYear()*12+t.getMonth(),i=new Map;for(let t of e){let e=new Date(t.createdAt),a,o,s=!1,c=!0;if(Number.isNaN(e.getTime()))c=!1,a=`undated`,o=`Undated`;else{let t=Math.round((n-h(e))/p);t<=0?(a=`today`,o=`Today`):t===1?(a=`yesterday`,o=`Yesterday`):t<7?(a=`day:${e.getFullYear()}-${m(e.getMonth()+1)}-${m(e.getDate())}`,o=e.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`})):(a=`month:${e.getFullYear()}-${m(e.getMonth()+1)}`,o=e.toLocaleDateString(void 0,{month:`long`,year:`numeric`}),s=e.getFullYear()*12+e.getMonth()<r,c=!1)}let l=i.get(a);l===void 0?i.set(a,{key:a,label:o,folded:s,namesDay:c,rows:[t]}):l.rows.push(t)}return[...i.values()]}function _(e,t){return e.failed?e.reason===`quota`?`Chrome is near its storage limit on this drive and the automatic cleanup could not run. Open the extension's error log if this keeps happening. Holding the most: ${t}.`:`Storage is over budget and the automatic cleanup could not run. Open the extension's error log if this keeps happening. Holding the most: ${t}.`:e.reason===`quota`?`Chrome is near its storage limit on this drive. Holding the most: ${t}.`:`Storage is over budget and nothing more can be reclaimed automatically. Holding the most: ${t}.`}function v(t){let n=t.videoOf??{},r=new Map((t.summary?.demos??[]).map(e=>[e.sceneId,e])),i=[...t.scenes].sort((e,t)=>t.meta.createdAt.localeCompare(e.meta.createdAt)).map(i=>{let a=r.get(i.meta.id),o=a?.motion??(t.summary===void 0?`complete`:`keyframesOnly`),c=new Date(i.meta.createdAt);return{sceneId:i.meta.id,name:i.meta.name,label:e(i.meta),origin:u(i.meta.capture.originUrl),path:d(i.meta.capture.originUrl),createdAt:i.meta.createdAt,when:f(c,!1),time:c.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}),hosted:a?.hosted??!1,recoverable:a?.recoverable??!1,frameBytes:a?.frameBytes??0,outputBytes:a?.outputBytes??0,state:s[o],canRestore:o===`reclaimed`,authored:i.meta.capture.mode===`authored`,servesReshoot:i.meta.renderMode===`demo`&&i.meta.capture.mode!==`authored`,needsLook:t.needsLook.has(i.meta.id),...t.sizes?.[i.meta.id]===void 0?{}:{sizeBytes:t.sizes[i.meta.id]},...n[i.meta.id]===void 0?{}:{version:n[i.meta.id]?.version,expired:n[i.meta.id]?.expired,exports:n[i.meta.id]?.exports}}}),{usedBytes:o,budgetBytes:c}=t.summary??{usedBytes:0,budgetBytes:0},p=null;if(t.notice?.pressureRemains){let e=i.slice().sort((e,t)=>t.frameBytes+t.outputBytes-(e.frameBytes+e.outputBytes)).slice(0,3).map(e=>`${e.label} (${l(e.frameBytes+e.outputBytes)})`).join(`, `);p=_(t.notice,e)}let m=t.sizes,h=new Set(i.map(e=>e.sceneId)),g=t.unreadable?.map(e=>m?.[e.folder]===void 0||h.has(e.folder)?{...e}:{...e,sizeBytes:m[e.folder]}),v=[...i,...g??[]];return{usedBytes:o,budgetBytes:c,fraction:c>0?Math.min(1,o/c):1,chromeNearLimit:t.notice?.reason===`quota`,migrating:t.migrating,migrationFailed:t.migrationFailed,notice:p,rows:i,...m===void 0?{}:{totalBytes:v.reduce((e,t)=>e+(t.sizeBytes??0),0),unmeasured:v.filter(e=>e.sizeBytes===void 0).length},...g===void 0?{}:{unreadable:g},...t.unwatched===void 0?{}:{unwatched:t.unwatched},...t.emptyHint===void 0?{}:{emptyHint:t.emptyHint},...t.videos===void 0?{}:{groups:a(i,n,t.videos)}}}export{u as a,g as c,n as d,e as f,l as i,f as l,v as n,d as o,o as r,i as s,c as t,r as u};
|