demoman 0.8.2 → 0.9.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/THIRD_PARTY_NOTICES +2 -1
- package/dist/demoman.mjs +15771 -11384
- package/dist/page/decode-probe-entry.js +44 -0
- package/dist/page/render-entry.js +177 -22
- package/dist/recipe.md +68 -66
- package/dist/studio/assets/editor-BftfYor5.js +4 -0
- package/dist/studio/assets/{editor-inline-d74caea2.css → editor-inline-07bcb316.css} +3 -0
- package/dist/studio/assets/library-Dla_j6K1.js +1 -0
- package/dist/studio/assets/{library-inline-3627d15c.css → library-inline-1ca82571.css} +5 -1
- package/dist/studio/assets/settings-Rqs8YKJU.js +1 -0
- package/dist/studio/assets/state-CuDyMMkG.js +2 -0
- package/dist/studio/assets/{confirm-dialog-F4BR4FU0.js → toast-BbC8Za5V.js} +5 -5
- package/dist/studio/assets/toast-Dg-G_N89.css +1 -0
- package/dist/studio/assets/topbar-DW2VlQMA.js +1 -0
- package/dist/studio/assets/view-CJolq1o6.js +1 -0
- package/dist/studio/editor.html +6 -6
- package/dist/studio/library.html +6 -6
- package/dist/studio/settings.html +5 -5
- package/dist/studio/studio-build.json +3 -3
- package/package.json +2 -1
- package/dist/studio/assets/confirm-dialog-BGEp6bKH.css +0 -1
- package/dist/studio/assets/editor-63atCcDn.js +0 -4
- package/dist/studio/assets/library-L3IU8F5q.js +0 -1
- package/dist/studio/assets/settings-g3t2C3Eo.js +0 -1
- package/dist/studio/assets/state-eyG4SxVq.js +0 -1
- package/dist/studio/assets/topbar-CgsXzkpk.js +0 -1
- package/dist/studio/assets/view-DzaxHB2c.js +0 -1
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{$ as e,A as t,D as n,Dt as r,E as i,Et as a,F as o,O as s,P as c,Q as l,U as u,_t as d,at as f,b as p,bt as m,ct as h,d as g,dt as _,et as v,f as y,ht as b,it as x,k as S,l as C,lt as ee,m as te,nt as ne,ot as w,p as re,r as ie,rt as ae,s as T,st as oe,t as se,tt as ce,u as le,ut as ue,vt as de,x as fe}from"./confirm-dialog-F4BR4FU0.js";import{A as pe,C as me,D as he,E as ge,F as _e,I as ve,M as ye,N as be,O as xe,P as Se,S as Ce,T as we,_ as Te,a as Ee,b as De,c as Oe,d as ke,f as Ae,g as je,h as Me,j as Ne,k as Pe,l as Fe,m as Ie,o as E,p as Le,s as Re,u as ze,v as Be,w as Ve,x as He,y as Ue}from"./view-DzaxHB2c.js";import{_ as We,f as Ge,g as Ke,h as qe,l as Je,p as Ye,s as Xe}from"./state-eyG4SxVq.js";function Ze(e,t){let{bundle:n,scene:r}=ue(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 Qe=64;function $e(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 et(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 tt(e,t,n,r){let i=[];for(let a of Ze(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(Qe,Math.round(a.rect.width))),l=Math.max(1,Math.min(Qe,Math.round(a.rect.height))),u;try{u=et($e(e,a.rect,t.viewport,c,l),$e(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 nt(e){return w.neutral.zoomHoldMs+oe(e).zoomOutMs}nt(de.smoothness);var rt=Math.abs(w.leadInMs)+w.neutral.minPlateauMs+400;function it(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`off`:return`${t}: turned off.`;case`tooClose`:return`${t}: too close to the previous zoom (${n}, minimum ${rt}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 ${at}x).`;case`textTooWide`:return`${t}: target too wide to zoom without cutting text (would be ${e.scale}x, floor ${at}x).`}}w.fitMarginPx;var at=1.2,ot=1e4,st=`__demomanClickProbe`;`${st}${JSON.stringify(`__demomanClickSeen`)}`,`${st}`,`${st}`,globalThis.process?.platform;var ct={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 was not on the page — check the step's target names something the page really shows, or what the step before it does`,ambiguousAnchor:`several elements matched this step, so replay stopped rather than risk clicking the wrong one — name the target more precisely (a stableId, or a role with a fuller name, from a snapshot of the page)`,anchorNotRendered:`an element was in the page's data but not rendered — the page probably needs scrolling further first, so add a scrollTo step before this one`,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 target, so changing the 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; change the step to target an element outside that frame`,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:`what the step waited for (an element to show or hide, or the page to load) did not happen within ${ot/1e3} s — check the target, or what the step before it does`,occlusionTimeout:`the render window stayed covered, so the frames would not have been usable — leave the window uncovered while it runs, then run it again`,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 script, so changing it 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 lt(e){return e in ct?ct[e]:e}function ut(e){if(!e)return`(navigation)`;let t=e.fingerprint;return t.accessibleName??t.textContent??t.stableId??t.dataKey??e.id}function dt(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:ut(e.anchors.find(e=>e.id===n.anchorId))}:null}function ft(e,t){return dt(e,t)}function pt(e){return e.meta.capture.mode===`authored`}function mt(e){return e?`run its script again in Runs`:`re-shoot it in Runs`}var ht=`motion reclaimed to free space`;function gt(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]=vt(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 _t(e,t=2){return String(Number(e.toFixed(t)))}function vt(e,t){for(let n=2;n<4;n++)if(_t(e,n)!==_t(t,n))return[_t(e,n),_t(t,n)];return[_t(e,4),_t(t,4)]}function yt(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 video 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=>gt(e,t))}}function bt(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}}var xt={run:{phase:`idle`},files:[],save:null,error:null};function St(e){return{run:{phase:`encoding`,done:0,total:0},files:e.map(e=>({fileType:e,jobId:null,ended:null})),save:null,error:null}}function Ct(e){return e.find(e=>e.ended===null)??null}var wt=(e,t)=>e===null?t:`${e}; ${t}`;function Tt(e,t){let n=e.findIndex(e=>e.jobId===t);if(n!==-1)return{files:e,index:n};let r=e.findIndex(e=>e.jobId===null&&e.ended===null);return r===-1?{files:e,index:-1}:{files:e.map((e,n)=>n===r?{...e,jobId:t}:e),index:r}}function Et(e,t){if(e?.kind!==`saved`||t.kind!==`saved`)return t;let n=[e.summary,t.summary].filter(e=>e!==null);return{kind:`saved`,names:[...e.names,...t.names],byteLength:e.byteLength+t.byteLength,reveal:e.reveal??t.reveal,summary:n.length===0?null:n.join(` `),outputRefs:[...e.outputRefs,...t.outputRefs]}}function Dt(e,t,n){let r=e.map((e,r)=>r===t?{...e,ended:n}:e);return{files:r,run:Ct(r)===null?{phase:`idle`}:{phase:`encoding`,done:0,total:0}}}function Ot(e,t){let n=e.run.phase===`encoding`||e.run.phase===`queued`;if(t.kind===`outputsChanged`)return{flow:e,effect:`relist`};let{files:r,index:i}=Tt(e.files,t.jobId),a=Ct(r),o=i===-1||r[i]===a;switch(t.kind){case`queued`:return n&&o?{flow:{...e,files:r,run:{phase:`queued`,position:t.position}},effect:`render`}:{flow:{...e,files:r},effect:`none`};case`rendering`:return n&&o?{flow:{...e,files:r,run:{phase:`encoding`,done:t.done,total:t.total}},effect:`progress`}:{flow:{...e,files:r},effect:`none`};case`fileFailed`:return{flow:{...e,files:r,error:wt(e.error,t.line)},effect:`none`};case`saving`:return{flow:{...e,files:r,run:{phase:`saving`}},effect:`render`};case`saved`:return{flow:{...e,...Dt(r,i,`saved`),save:Et(e.save,t.save.kind===`saved`&&t.summary!==null?{...t.save,summary:t.summary}:t.save)},effect:`render`};case`failed`:{let n=r.length>1?r[i]:void 0,a=n===void 0?``:`${Fe[n.fileType]}: `;return{flow:{...e,...Dt(r,i,`failed`),error:t.detail===null?e.error:wt(e.error,`${a}${t.detail}`)},effect:`render`}}}}function kt(e){return e?`Run its script again in Runs`:`Re-shoot this video in Runs`}function At(e){let t=mt(e);return t.charAt(0).toUpperCase()+t.slice(1)}function jt(e){return e.rerun.kind===`line`?e.rerun.text:null}function Mt(e,t,n){return t??`${At(e)} ${n}.`}var D=1,O=e=>({kind:`refusal`,reason:e});function Nt(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 Pt(e){return new Map(e.markers.map(e=>[e.actionId,e.sourceTimeMs]))}function Ft(e,t,n){return It(e,ee(t,n))}function It(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 Lt(e,t,n){let r=Pt(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=Nt(t,e=>c(e.start,-1/0)),u=Nt(t,e=>-c(e.end,1/0));if(l===void 0||u===void 0)continue;let d=h(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:h(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)<D).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=h(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<D||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 Rt(e,t,n,r){if(t===null||n===null)return O(`Nothing has rendered yet, so there is no frame to split at.`);if(r<=0||r>=n.outputDurationMs)return O(`A split at the video's start or end splits nothing.`);let i=Ft(t,n,r);if(i===null)return O(`These frames name no step, so there is nothing to split by.`);let a=Pt(t).get(i.actionId)??0,o=h(n,a+i.sourceOffsetMs),{pieces:s}=Lt(e,t,n);return o<=D||o>=n.outputDurationMs-D||s.some(e=>Math.abs(e.startMs-o)<D)?O(Math.abs(o-r)<D?`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 zt=(e,t)=>e===null||t===null?e===t:e.actionId===t.actionId&&e.sourceOffsetMs===t.sourceOffsetMs;function Bt(e,t,n){let r=e.find(e=>zt(e.start,t));if(r===void 0)return O(`That piece is no longer on the timeline.`);if(e.length===1)return O(`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+D&&e.startMs<n.tailMs-D;if(t(r)&&e.filter(t).length===1)return O(`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 Vt(e,t,n,r,i,a){let o=n.find(e=>zt(e.start,r));if(o===void 0)return O(`That piece is no longer on the timeline.`);if(e===null||t===null)return O(`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 O(`This piece is as short as a piece can be.`);let r=Ft(e,t,n);return r===null?O(`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 O(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-D:u<=l.srcStartMs+D)return{kind:`restorePiece`,id:l.removedId};let d=It(e,u);return d===null?O(`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 Ht=1e3;function Ut(e,t){return`Motion reclaimed to free space. ${Mt(e,t,`to restore`)}`}var Wt=new Set([`Motion reclaimed to free space. Replay to restore.`,`Motion reclaimed to free space. Rebuild to restore.`]);function Gt(e,t,n,r){return e===`motionReclaimed`?Wt.has(t)||t===`Motion reclaimed to free space. Re-shoot it in Runs to restore.`?Ut(n,r):t:`${e}: ${t}`}var Kt=(e,t)=>e.hasBundle?t.outputMs??t.captureMs:t.captureMs;function qt(e){return e.hasBundle&&e.outputDurationMs!==null?e.outputDurationMs:(e.beats[e.beats.length-1]?.captureMs??0)+Ht}var Jt=e=>({actionId:e.actionId,offsetMs:e.sourceOffsetMs});function Yt(e,t){let n=e.beats.find(e=>e.actionId===t.actionId);return(n?Kt(e,n):0)+t.offsetMs}function Xt(e){let{scene:t,view:n,bundle:r,resolved:i}=e,a=pt(t),o=e.rerunLine??null,s=e=>Mt(a,o,e),c=qt(n),l=[],u=new Set(e.hoverReport?.removable??[]),d=new Map(n.beats.map(e=>[e.actionId,Kt(n,e)])),f=new Map(n.beats.map(e=>[e.actionId,e.timing])),p=e=>i===null?`estimated`:e?f.get(e.actionId)??`estimated`:`rendered`,m=n.beats.map(e=>({actionId:e.actionId,atMs:d.get(e.actionId)??0,verb:e.verb,label:e.label,timing:e.timing,flag:u.has(e.actionId)?`unchangedHover`:null,canZoom:e.canZoom,cut:e.cut})),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,Yt(n,g.head)):0,headTiming:g?.head?`estimated`:`rendered`,tailMs:g?.tail?Math.min(c,Yt(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 video'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:b}=t.motion??de,x=nt(b),{zoomInMs:S}=oe(b),C=new Set,ee=t.camera.flatMap(e=>{let t=e.scale??1;if(t<=1)return[];let r=y.get(e.id);r||C.add(e.id);let i=r?r.startMs:Math.max(0,Yt(n,e.marker)),a=r?r.endMs:Math.min(c,e.end?Yt(n,e.end):i+x),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 video'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}]}),te=ee.map(e=>{if(!C.has(e.id))return e;let t=Math.min(...ee.map(e=>e.startMs).filter(t=>t>e.startMs));return e.endMs>t?{...e,endMs:t}:e}),ne=te.map(e=>C.has(e.id)?{...e,departMs:Zt(te,e.startMs,S)}:e),w=ne.map(e=>({...e,drawnEndMs:Qt(ne,e.startMs,e.endMs)})),re=new Set(t.camera.map(e=>e.marker.actionId));for(let e of t.zoomsSkipped??[])re.has(e.actionId)||`afterActionId`in e&&!re.has(e.afterActionId)||l.push(it(e));let ie=new Map((i?.cosmetics??[]).map(e=>[e.id,e])),ae=t.edits.masks.map(e=>{let t=e.start===void 0||e.end===void 0,r=ie.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 video'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,Yt(n,Jt(e.start))):0,u=t?c:a?a.endMs:e.end?Math.min(c,Yt(n,Jt(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}}),T=e=>i?h(i.timeline,e):e,se=(r?.degradations??[]).map(e=>({startMs:T(e.startMs),endMs:T(e.endMs)}));for(let e of r?.degradations??[])l.push(Gt(e.kind,e.note,a,o));let ce=i?.timeline.unplacedPaces??0;if(ce>0){let e=ce===1?`pause`:`pauses`;l.push(`pacingUnplaced: ${ce} recorded ${e} could not be placed. The last render carried no marker for the steps they sit between, so this export is shorter than the video by however long those ${e} were. ${s(`to restore them`)}`)}let le=i?.timeline.nonMonotonicPaces??0;if(le>0){let e=le===1?`pair`:`pairs`;l.push(`pacingBackwards: ${le} step ${e} in this video carry timestamps that run backwards, so the video's order is not its time order. A re-record counts the pause across ${le===1?`it`:`them`} twice and comes out longer than the video. Record it again to straighten the order; the frames you already have are unaffected.`)}let{pieces:ue,joins:fe,unplacedSplits:pe}=r!==null&&i!==null?Lt(t,r,i.timeline):{pieces:[],joins:[],unplacedSplits:[]};for(let e of pe)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:m,degraded:se,pieces:ue,joins:fe},zooms:w,masks:ae,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:x,zoomInMs:S}}function Zt(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 Qt(e,t,n){return Math.min(n,...e.filter(e=>e.startMs>t).map(e=>e.departMs))}function $t(e,t,n){let r=e.clip.ticks,i=r[0];if(!i)throw Error(`a video 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 en(e){let{resolved:n,outputTimeMs:r,presentation:i,target:a,viewport:o}=e;return f(n,r,t(i.frameRect,o),i.frameRect,o,a)}var tn=(e,t,n)=>Math.min(n,Math.max(t,e));function nn(e,t){let n=e.width/2,r=e.height/2;return{x:tn(t.x-n/2,0,e.width-n),y:tn(t.y-r/2,0,e.height-r),width:n,height:r}}function rn(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,c=en({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o});return s(t,c,i.frameRect,o)}function an(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,s=n.plan.viewport,c=en({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:s}),l=o(t,c,i.frameRect,s),u=tn(l.x,0,s.width),d=tn(l.y,0,s.height),f=tn(l.x+l.width,0,s.width),p=tn(l.y+l.height,0,s.height);return{x:u,y:d,width:f-u,height:p-d}}function on(e){let{zoom:t,resolved:n,viewport:r,presentation:i,target:a}=e,s=en({resolved:n,outputTimeMs:(t.startMs+t.endMs)/2,presentation:i,target:a,viewport:r});return o({x:0,y:0,width:a.width,height:a.height},s,i.frameRect,r)}var sn=2e3,cn=e=>e!==null&&e.kind===`refusal`,k=e=>({kind:`refusal`,reason:e});function ln(e,t){if(e.resolved===null||e.bundle===null)return{reason:`nothing has rendered yet`};if(e.bundle.cursorSamples.length===0)return{reason:`this video has no recorded pointer`};let n=ee(e.resolved.timeline,t);if(e.bundle.cursorGaps.some(e=>n>=e.startMs&&n<e.endMs))return{reason:`the pointer was off the page here`};let r=ae(e.resolved.cursor,n);return r?{point:r}:{reason:`the pointer was not observed here`}}var un=(e,t)=>e.zooms.find(e=>e.id===t),dn=(e,t)=>e.masks.find(e=>e.id===t);function fn(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=pn(a,i,n,r);if(e)return{zoom:a,why:e}}}function pn(e,t,n,r){let i=Math.abs(n-e.startMs);if(i<rt&&(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 mn({zoom:e,why:t}){switch(t){case`start`:return k(`That would start it within ${rt}ms of the zoom "${e.id}" at ${hn(e.startMs)}; the camera needs ${rt}ms between two zooms to glide from one to the other.`);case`endsAfter`:return k(`That would end it after the zoom "${e.id}" starts at ${hn(e.startMs)}; a zoom can stay in until the next one, not past it.`);case`startsInside`:return k(`That would start it before the zoom "${e.id}" ends at ${hn(e.endMs)}; drag that zoom's end earlier first.`)}}var hn=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 gn(e){let{leadInMs:t}=w;return{earliestMs:e+t,latestMs:e}}function _n(e,t){let{leadInMs:n}=w,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}=gn(t);return e.zooms.find(e=>pn(e,void 0,n,null)!==void 0||pn(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+rt,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-rt;if(gn(e).earliestMs<0)break;let t=a(e);if(!t)return i(e,{zoom:s,side:`before`});s=t}return k(`There is no room for a zoom here: it would run into the zoom "${o.id}" at ${hn(o.startMs)}, and there is no slot either side of it. Drag that zoom to make space, or remove one.`)}function vn(e,t){let{trim:n}=e.clip;if(t>n.tailMs-200)return k(`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+sn,e.durationMs)}}function yn(e,t,n,r){let i=$t(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(ee(t.resolved.timeline,n)-a.sourceTimeMs)}}var bn=(e,t)=>e.actionId===t.actionId&&t.sourceOffsetMs<=e.sourceOffsetMs;function xn(e,t){return t!==null&&e.actionId===t.actionId&&t.offsetMs<=e.offsetMs}var Sn=e=>k(`That would leave the ${e} no length; drag its end further.`),Cn=e=>k(`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 wn(e,t){let n=e.clip.ticks,r=n.findIndex(e=>e.actionId===t);return r===-1?void 0:n[r+1]}function Tn(e,t,n,r){let{durationMs:i}=e;if(e.clip.ticks.length===0)return k(`This video has no steps to attach an edit to.`);switch(n.kind){case`pieceEdge`:return Vt(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 k(`The cut would leave nothing: the head has to stay at least 200ms before the tail.`);let r=$t(e,n.toMs,n.snapMs);return xn(r,t.tailMarker)?Cn(`head`):{kind:`setTrim`,head:r}}if(n.toMs>=i)return{kind:`setTrim`,tail:null};if(n.toMs<t.headMs+200)return k(`The cut would leave nothing: the tail has to stay at least 200ms after the head.`);let r=$t(e,n.toMs,n.snapMs);return t.headMarker&&xn(t.headMarker,r)?Cn(`tail`):{kind:`setTrim`,tail:r}}case`addZoom`:{let i=_n(e,n.atMs);if(cn(i))return i;let{atMs:a,movedPast:o}=i,s=$t(e,a,o?0:n.snapMs),c=o?`Placed ${o.side} the zoom at ${hn(o.zoom.startMs)}: there was no room at ${hn(n.atMs)}.`:null,l=w.defaultZoomScale,u=ln(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 k(`There is nothing to aim at here: ${u.reason}, and no step on this video 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=un(e,n.id);if(!t)return k(`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 k(`A zoom cannot start before the video does.`);if(a>i)return k(`A zoom cannot end after the video does.`);let o=fn(e,t.id,r,t.endAuthored?a:null);if(o)return mn(o);let s=$t(e,r,n.snapMs),c=t.endAuthored?$t(e,a,n.snapMs):null;return xn(s,c)?Sn(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}case`zoomEdge`:{let t=un(e,n.id);if(!t)return k(`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 k(`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 k(`Zooming in from there, it would land at ${hn(i)}, after its end at ${hn(t.endMs)}. Drag the end later first.`);let a=fn(e,t.id,i,null);if(a)return mn(a);let o=$t(e,r,n.snapMs),s={...o,offsetMs:o.offsetMs+e.zoomInMs},c=t.endMarker;return xn(s,c)?Sn(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}if(n.toMs>i)return k(`A zoom cannot end after the video does.`);if(n.toMs<t.startMs+100)return k(`A zoom's end cannot cross its start; it would end before it starts. Drag the start earlier first.`);let r=fn(e,t.id,t.startMs,n.toMs);if(r)return mn(r);let a=t.marker,o=$t(e,n.toMs,n.snapMs);return xn(a,o)?Sn(`zoom`):{kind:`setZoomRange`,id:t.id,start:a,end:o}}case`addMask`:{let t=vn(e,n.atMs);if(cn(t))return t;let{endMs:i}=t,a=ln(r,n.atMs),o=`point`in a?a.point:{x:r.viewport.width/2,y:r.viewport.height/2},s=nn(r.viewport,o),c=yn(e,r,n.atMs,n.snapMs),l=yn(e,r,i,n.snapMs);if(bn(c,l)){let t=wn(e,c.actionId);if(!t)return k(`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=dn(e,n.id);if(!t)return k(`There is no mask "${n.id}" to move.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return k(`This mask covers the whole video, 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 k(`A mask cannot start before the video does.`);if(o>i)return k(`A mask cannot end after the video does.`);let s=yn(e,r,a,n.snapMs),c=yn(e,r,o,n.snapMs);return bn(s,c)?Sn(`mask`):{kind:`setMaskRange`,id:t.id,start:s,end:c}}case`maskEdge`:{let t=dn(e,n.id);if(!t)return k(`There is no mask "${n.id}" to resize.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return k(`This mask covers the whole video, so it has no ends to move. Add a new mask to cover a stretch.`);if(n.edge===`start`){if(n.toMs<0)return k(`A mask cannot start before the video does.`);if(n.toMs>t.endMs-100)return k(`A mask cannot start after it ends; drag its end later first.`);let i=yn(e,r,n.toMs,n.snapMs),a=t.endMarker;return bn(i,a)?Sn(`mask`):{kind:`setMaskRange`,id:t.id,start:i,end:a}}if(n.toMs>i)return k(`A mask cannot end after the video does.`);if(n.toMs<t.startMs+100)return k(`A mask cannot end before it starts; drag its start earlier first.`);let a=t.startMarker,o=yn(e,r,n.toMs,n.snapMs);return bn(a,o)?Sn(`mask`):{kind:`setMaskRange`,id:t.id,start:a,end:o}}}}function En(e,t,n){let r=e.beats.find(e=>e.actionId===t);return r===void 0?k(`There is no step "${t}" to pace.`):r.isLast?k(`"${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?k(`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}:k(`A pause has to be a number of milliseconds.`)}function Dn(e){return e.actions.map(e=>e.id).join(` `)}function On(e){return{bundle:e.bundle,actionIds:Dn(e.scene)}}function kn(e,t){return e!==null&&t.bundle===e.bundle&&Dn(t.scene)===e.actionIds&&t.hoverReport!==null}var An={removable:[],checked:0,unchecked:0,failed:!0};function jn(e){return e.kind!==`unknown`||e.reason!==`notStyleSignalled`}function Mn(e,t){let n=e.filter(jn).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 Nn={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 Pn(e){return Object.entries(e.uncheckedBy??{}).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]).map(([e,t])=>{let n=Nn[e];return`${t} ${t===1?n.one:n.many}`}).join(`, `)}function Fn(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=Pn(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 In(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 Ln(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 Rn(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 zn(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 Bn(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=zn(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 Vn(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 Hn(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 A(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60;return`${Math.floor(t/60)}:${String(n).padStart(2,`0`)}`}function Un(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 Wn(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 Gn(e,t){return e===null||[...new Set([...Object.keys(t),...Object.keys(e)])].some(n=>t[n]!==e[n])}function Kn(e,t){return e===null||e.smoothness!==t.smoothness||e.blur!==t.blur||e.follow!==t.follow}function qn(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!Be(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 Jn(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 Yn(){let e=new Map;return{isOpen:(t,n)=>e.get(t)??n,set:(t,n)=>{e.set(t,n)}}}var Xn={attachFailed:`Couldn't record the screen, so this video has no motion`,debuggerDetached:`The video stopped partway through`,debuggerLost:`The video stopped and couldn't restart`,debuggerRecovered:`A stretch in the middle is missing`,workerRestarted:`The extension restarted mid-recording, so this video has no motion`,noKeyframes:`Nothing could be photographed, so there's no video`,screencastUnavailable:`Motion couldn't be recorded, so this video is stills`,muxFailed:`The motion couldn't be encoded, so this video is stills`,muxUnavailable:`There was nowhere to encode the motion, so this video is stills`,budgetSpent:`The video 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:`Motion was interrupted, so parts are stills`,spansDiscarded:`Some motion couldn't be encoded, so those moments are stills`,storageRefused:`This video's frames couldn't be saved — free up space and record it again`,bundleInvalid:`This video couldn't be put together`},Zn={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`},Qn=new Set([`debuggerDetached`,`debuggerLost`,`debuggerRecovered`]),$n=e=>Object.hasOwn(Zn,e)?Zn[e]:e;function er(e){let t=Xn[e];if(t!==void 0)return t;let n=e.indexOf(`:`);if(n>0){let t=e.slice(0,n),r=Xn[t],i=e.slice(n+1);if(r!==void 0&&i!==``)return`${r} — ${Qn.has(t)?$n(i):i}`}return e}function tr(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`${er(e.reason)}${n}`}var nr={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 rr(e){return e===null||e.reason===null?!1:nr[e.reason]===!0}function ir(e,t,n){if(e===null||e.reason===null||!t.mayReplay||e.reason===`mutating`)return null;let r=lt(e.reason),i=n!==void 0&&pt(n),a=i?`The script run`:`The re-shoot`,o=i?`performed`:`reconstructed`,s=n?ft(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 ${mt(i)} to try again.`:`${a} ${o} all ${e.total} steps, but: ${r}.`;let l=rr(e)?`and stopped early`:`then stopped`;return`${a} ${o} ${e.completed} of ${e.total} steps ${l}: ${r}.${c}`}function j(e,t){let n=e.actions.findIndex(e=>e.id===t);if(n===-1)throw Error(`unknown action "${t}"`);return n}function ar(e,t){let n=e.camera.find(e=>e.id===t);if(!n)throw Error(`unknown zoom "${t}"`);return n}var or=1,sr=e=>Error(`1:1 is not a zoom — remove the zoom instead of authoring ${e}`);function cr(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]:(j(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(j(e,t.marker.actionId),t.scale<=1)throw sr(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?w.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,source:`author`,...t.note===void 0?{}:{note:t.note}},{zoomsSkipped:o,...s}=e,c=(o??[]).filter(e=>e.actionId!==t.marker.actionId||e.reason!==`off`);return{...s,camera:[...e.camera,a],...c.length>0?{zoomsSkipped:c}:{}}}case`setZoomRange`:{let n=ar(e,t.id);j(e,t.start.actionId),t.end&&j(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 n.source===`click`&&(a.source=`author`),{...e,camera:e.camera.map(e=>e.id===n.id?a:e)}}case`setZoomScale`:{let n=ar(e,t.id);if(t.scale<=1)throw sr(t.scale);return{...e,camera:e.camera.map(e=>e.id===n.id?{...e,scale:t.scale,...e.source===`author`?{}:{scaleSetBy:`author`}}:e)}}case`setZoomTarget`:{let n=ar(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},...n.source===`click`?{source:`author`}:{}}:e)}}case`removeZoom`:{let n=ar(e,t.id),r=e.camera.filter(e=>e.id!==t.id),i=e.actions.find(e=>e.id===n.marker.actionId);return i?.kind!==`click`&&i?.kind!==`drag`||r.some(e=>e.marker.actionId===n.marker.actionId)?{...e,camera:r}:{...e,camera:r,zoomsSkipped:[...(e.zoomsSkipped??[]).filter(e=>e.actionId!==n.marker.actionId),{actionId:n.marker.actionId,reason:`off`}]}}case`addMask`:return j(e,t.start.actionId),j(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(j(e,t.start.actionId),j(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<or||t.rect.height<or)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:je(e.branding,t.patch)};case`setCursor`:return{...e,cursor:{...e.cursor,...t.patch}};case`setMotion`:return{...e,motion:{...e.motion??de,...t.patch}};case`setAspect`:return{...e,canvas:{...e.canvas,aspect:t.aspect}};case`split`:return j(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 video would leave nothing to export.`);return t.start&&j(e,t.start.actionId),t.end&&j(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&&j(e,t.start.actionId),t.end&&j(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 video would leave nothing to export.`);return{...e,edits:{...e.edits,removed:n.map(e=>e.id===t.id?i:e)}}}case`setGap`:{if(j(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 lr(e,t,n){return m.parse(cr(e,t,n))}function ur(e){return{scene:e,past:[],future:[],error:null,dirty:!1,hoverReport:null}}function dr(e,t,n){let r;try{r=lr(e.scene,t,n)}catch(t){return{...e,error:t instanceof Error?t.message:String(t)}}return t.kind===`setBranding`&&Ue(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 fr(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 pr(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 mr(e){return{...e,dirty:!1}}var hr={mayReplay:!0};function gr(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 _r(e,t){return e.meta===void 0||e.flags===void 0?!1:gr(e)===gr(t)}function vr(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(gr(e)),JSON.parse(gr(t)),`scene`)}function yr(e,t){let{renderMode:n,...r}=e.meta;return{...e,meta:t.meta.renderMode===void 0?r:{...r,renderMode:t.meta.renderMode}}}function br(e,t){return{...yr(e,t),flags:{...e.flags,hoverSensitive:t.flags.hoverSensitive}}}function xr(e){let t=ur({}),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:ir(i,hr,t.scene),replayRecoverable:rr(i),captureSentence:a===null||n!==null&&n.source!==`capture`?null:tr(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=yr(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=_r(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 ${vr(t.scene,o)}`),t=c?{...ur(o),past:t.past.map(e=>br(e,o)),future:t.future.map(e=>br(e,o))}:ur(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=dr(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=mr(t),u()})},async undo(){await c(async()=>{let e=fr(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=mr(t),u()})},async redo(){await c(async()=>{let e=pr(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=mr(t),u()})},async settled(){let e;do e=s,await e;while(e!==s)},setHoverReport(e){t={...t,hoverReport:e},u()}}}var Sr=1.2;function Cr(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:Sr}:null:n===`-`||n===`_`?t.hasTimeline?{kind:`zoomTimeline`,factor:1/Sr}: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 wr={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`}},Tr=(e,t)=>typeof e==`string`?e:t?e.mac:e.other;function Er(e,t){let n=wr[e];return n===void 0?e:Tr(n.label,t)}var Dr=new Set([`⌘`,`⇧`,`⌫`,`←`,`→`,`↑`,`↓`]);function Or(e){return Dr.has(e)}function kr(e,t){let n=wr[e];return n===void 0?e:Tr(n.spoken,t)}function Ar(e,t){return e.map(e=>kr(e,t)).join(` plus `)}function jr(e){return/\bMac/i.test(e)}function Mr(e,t){return Tr(e.description,t)}var Nr=[{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 video`,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 Pr(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 Fr=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],Ir=3;function Lr(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 Rr(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 zr(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=Pr(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=E(`div`,`overlay`);a.setAttribute(`data-overlay`,`mask`);let c=rn({rect:i.rect,...s});Lr(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)>Ir&&(l=!0),c=Rr(r,t,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Lr(a,c,o)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),l&&n.onMaskRect(i.id,an({rect:c,...s}))};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)})};l(a,`body`);for(let e of Fr){let t=E(`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=E(`div`,`overlay`);l.setAttribute(`data-overlay`,`zoom`);let u=rn({rect:on({zoom:c,resolved:i,viewport:i.plan.viewport,presentation:a,target:t.target}),...s});Lr(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)>Ir&&(r=!0),u=Rr(t,`body`,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Lr(l,u,o)},a=()=>{if(window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),!r)return;let e=an({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 Br(e){let{scene:t,resolved:n,bundle:i=null}=e,o=new Map(t.anchors.map(e=>[e.id,e])),s=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??w.defaultZoomScale,offsetMs:e.marker.offsetMs}])),c=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??[]):_(t),d=new Map((i?.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),f=(e,t)=>{if(n===null||i===null||!r(i)||a(i,e.id))return!0;let o=d.get(e.id),s=d.get(t.id);return o===void 0||s===void 0||n.timeline.segments.some(e=>e.kind===`idle`&&e.srcEndMs>e.srcStartMs&&o<=e.srcStartMs&&e.srcEndMs<=s)},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},m=(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)},v=t.actions.length-1;return{beats:t.actions.map((e,a)=>{let _=e.anchorId?o.get(e.anchorId):void 0,y=s.get(e.id),b=c.get(e.id),x=l.get(e.id),S=t.actions[a+1],C=d.get(e.id);return{actionId:e.id,index:a,verb:e.kind,anchorId:e.anchorId,label:ut(_),text:e.kind===`type`?e.text:null,redacted:e.kind===`type`&&e.redacted,host:e.kind===`type`&&e.host===!0,strategy:_?.resolution.strategy??null,outputMs:n?h(n.timeline,C??e.timestamp):null,timing:C===void 0?`estimated`:`rendered`,captureMs:e.timestamp,camera:y??null,canZoom:e.anchorId!==null,gap:b?{durationMs:b.durationMs}:null,canPace:S!==void 0&&f(e,S),renderedPauseMs:m(e,S),renderedPaceFreezeMs:g(e,S),renderedFreezeBeforeMs:i!==null&&!r(i)&&C!==void 0&&n!==null&&C<n.timeline.sourceDurationMs?p(C):0,legacyHold:x?{offsetMs:x.marker.offsetMs,durationMs:x.durationMs}:null,cut:u.has(e.id),isLast:a===v}}),outputDurationMs:n?.timeline.outputDurationMs??null,hasBundle:n!==null}}var Vr=(e,t,n)=>Math.min(n,Math.max(t,e)),Hr=e=>({startMs:0,endMs:Math.max(250,e)}),M=(e,t)=>(t-e.startMs)/(e.endMs-e.startMs),Ur=(e,t)=>e.startMs+t*(e.endMs-e.startMs);function Wr(e,t,n,r){let i=Math.max(250,r),a=Vr(n,250,i),o=Vr(e-t*a,0,i-a);return{startMs:o,endMs:o+a}}function Gr(e,t,n,r){return Wr(Ur(e,r),r,(e.endMs-e.startMs)/n,t)}function Kr(e,t,n){let r=e.endMs-e.startMs;return Wr(e.startMs+n,0,r,t)}var qr=(e,t,n,r)=>Wr(Ur(e,r),r,n,t);function Jr(e,t){let n=Math.max(250,e);return n*(250/n)**Vr(t,0,1)}function Yr(e,t){let n=Math.max(250,e);if(n<=250)return 0;let r=Vr(t,250,n);return Math.log(r/n)/Math.log(250/n)}function Xr(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 Zr(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=jr(navigator.userAgent);e.setAttribute(`aria-keyshortcuts`,n.map(e=>Xr(e,r)).join(`+`))}function Qr(e){delete e.dataset.tip,delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`)}var $r=Symbol.for(`demoman.tooltip`);function ei(e=document){let t=e,n=t[$r];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[$r]={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=jr(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=Er(n,r),a=e.createElement(`kbd`);a.className=`keycap`,a.textContent=i,Or(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 ti(){let e=E(`div`,`demo-panel`);e.setAttribute(`data-export-panel`,``),e.append(E(`h2`,void 0,`Export`));let t=E(`div`);return t.setAttribute(`data-panel-export`,``),e.append(t),e}function ni(){let e=E(`div`,`demo-panel`);e.setAttribute(`data-background-panel`,``),e.append(E(`h2`,void 0,`Background`));let t=E(`div`);return t.setAttribute(`data-panel-branding`,``),e.append(t),e}function ri(){let e=E(`div`,`demo-panel`);e.setAttribute(`data-shortcuts-panel`,``),e.append(E(`h2`,void 0,`Keyboard shortcuts`));let t=E(`div`);return t.setAttribute(`data-panel-shortcuts`,``),e.append(t),e}function ii(){let e=E(`div`,`demo-panel`);e.setAttribute(`data-cursor-panel`,``),e.append(E(`h2`,void 0,`Cursor`));let t=E(`div`);return t.setAttribute(`data-panel-cursor`,``),e.append(t),e}function ai(e,t,n){let r=E(`div`,`beat-panel`);r.setAttribute(`data-step-panel`,e.actionId);let i=E(`h2`);if(i.append(E(`span`,`verb`,e.verb),` `,e.label),e.strategy){let t=E(`span`,`chip`,e.strategy);t.setAttribute(`data-health`,e.strategy),i.append(` `,t)}r.append(i);let a=E(`div`);if(e.verb===`type`){if(e.redacted)a.append(E(`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=E(`div`,`control-row`),n=E(`span`,void 0,e.text??``);n.setAttribute(`data-typed-text`,e.actionId),t.append(E(`span`,`control-label`,`Typed text`),n),a.append(t)}}e.timing===`estimated`&&a.append(E(`div`,`muted`,`Not in the video: the frames have no marker for this step, so the timeline places it from the video's own timestamp.`)),a.hasChildNodes()&&r.append(a);let o=E(`div`,`control-actions`);if(!e.canZoom)o.append(E(`span`,`muted`,`No zoom — nothing on screen to aim at`));else{let t=E(`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=E(`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=E(`label`,`control-row`),i=E(`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=E(`span`,`control-inline`);if(a.append(i,E(`span`,void 0,`ms`)),e.gap!==null&&a.append(s()),t.append(E(`span`,`control-label`,`Pause after this step`),a),r.append(t),e.gap!==null&&e.gap.durationMs>0&&e.renderedPaceFreezeMs===0){let t=E(`div`);t.setAttribute(`data-gap-floored`,e.actionId),t.append(E(`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 the original footage from its card on the Flows page, where this number is the pause.`)),r.append(t)}}else if(e.gap!==null){let t=E(`div`);t.setAttribute(`data-gap-inert`,e.actionId),t.append(E(`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=E(`div`);i.setAttribute(`data-legacy-hold`,e.actionId),i.append(E(`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=E(`div`);n.setAttribute(`data-cut-panel`,e.actionId),n.append(E(`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=E(`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=E(`div`,`control-actions`);if(t.hoverReport?.removable.includes(e.actionId)??!1){let t=E(`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 oi(e,t,n){let r=E(`div`,`zoom-panel`);r.setAttribute(`data-zoom-panel`,e.id),r.append(E(`h2`,void 0,`Zoom`));let i=E(`input`);i.type=`range`,i.min=`1.1`,i.max=String(w.maxScale),i.step=`0.05`,i.value=String(e.scale),i.setAttribute(`data-zoom-scale`,e.id),i.setAttribute(`aria-label`,`Zoom level`),Re(i),i.addEventListener(`input`,()=>Re(i)),i.addEventListener(`change`,()=>n.onZoomScale(e.id,Number(i.value)));let a=E(`div`,`slider-row`);a.append(E(`span`,`control-label slider-label`,`Level`),E(`span`,`slider-value`,`${e.scale.toFixed(2)}x`),i),r.append(a);let o=E(`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?ut(r):n}`}else o.textContent=`Aims at the cursor at ${A(e.startMs)}`;if(r.append(o),e.aimFallback!==null){let t=E(`div`,`muted`,e.aimFallback);t.setAttribute(`data-zoom-fallback`,``),r.append(t)}let s=E(`div`);s.setAttribute(`data-zoom-range`,``),s.textContent=`${A(e.startMs)} to ${A(e.endMs)}${e.endAuthored?``:` (end automatic; drag its cap to set one)`}`,r.append(s),e.clamped&&r.append(E(`div`,`muted`,`The end you set could not be reached; see the note under the timeline.`)),e.timing===`estimated`&&r.append(E(`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=E(`button`,`btn btn-quiet`,`Remove zoom`);c.type=`button`,c.setAttribute(`data-remove-zoom`,e.id),Zr(c,`Remove zoom`,[`Delete`]),c.addEventListener(`click`,()=>n.onRemoveZoom(e.id));let l=E(`div`,`control-actions`);return l.append(c),r.append(l),r}function si(e,t,n){let r=E(`div`,`mask-panel`);r.setAttribute(`data-mask-panel`,e.id),r.append(E(`h2`,void 0,`Mask`));let i=E(`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=E(`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=E(`label`,`control-row`);o.append(E(`span`,`control-label`,`Note`),a),r.append(o);let s=E(`div`);s.setAttribute(`data-mask-range`,``),e.wholeTake?(s.setAttribute(`data-mask-whole-take`,``),s.textContent=`Covers the whole video (made before masks had a range).`):s.textContent=`${A(e.startMs)} to ${A(e.endMs)}`,r.append(s),r.append(E(`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=E(`button`,`btn btn-quiet`,`Remove mask`);c.type=`button`,c.setAttribute(`data-remove-mask`,e.id),Zr(c,`Remove mask`,[`Delete`]),c.addEventListener(`click`,()=>n.onRemoveMask(e.id));let l=E(`div`,`control-actions`);return l.append(c),r.append(l),r}function ci(e,t,n){let{selection:r,rail:i}=t;if(i===`shortcuts`&&e.querySelector(`:scope > .inspector > [data-shortcuts-panel]`)!==null)return;let a=E(`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=ai(o,t,n):s?l=oi(s,t,n):c?l=si(c,t,n):(console.error(`[demoman] editor: the rail is on Selection with nothing selected`),l=ti()):l=i===`background`?ni():i===`cursor`?ii():i===`shortcuts`?ri():ti();let u=E(`button`,`btn btn-icon inspector-close`);u.type=`button`,u.setAttribute(`data-inspector-close`,``),u.setAttribute(`aria-label`,`Close panel`),Zr(u,`Close`,[`Esc`]),u.append(T(`close`)),u.addEventListener(`click`,()=>n.onClose()),a.append(u,l),e.replaceChildren(a)}var li=[{entry:`background`,label:`Background`,glyph:`image`},{entry:`cursor`,label:`Cursor`,glyph:`mousePointer2`},{entry:`selection`,label:`Selection`,glyph:`mousePointerClick`}],ui=`Select a step, zoom or mask on the timeline`;function di(e,t,n){let r=li.map(({entry:e,label:r,glyph:i})=>{let a=E(`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?ui:r,a.append(T(i)),a.addEventListener(`click`,()=>n.onPick(e)),a});e.replaceChildren(...r)}function fi(e,t,n){e.querySelector(`svg[data-icon]`)===null&&e.replaceChildren(T(`download`),E(`span`,void 0,`Export`)),e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`export`)),e.onclick=()=>n.onPick(`export`)}function pi(e,t,n){e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`shortcuts`)),e.onclick=()=>n.onPick(`shortcuts`)}function mi(e,t,n,r=null){let i=r===null?``:` ${Fe[r]}`;switch(e.phase){case`idle`:return Ae(t);case`queued`:return e.position===0?`Queued…`:`Queued (${e.position} ahead)`;case`encoding`:return e.total>0?`Exporting${i} · ${Math.floor(e.done*100/e.total)}%`:`Exporting${i}…`;case`saving`:return`Saving${i}…`}}function hi(e){let t=e/1048576;return t>=1?`${Math.round(t*10)/10} MB`:`${Math.max(1,Math.round(e/1024))} KB`}var gi=1e3,_i=new Map;function vi(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=_i.get(t);if(s!==void 0&&o-s.at>gi)_i.delete(t);else if(s!==void 0){let e=s.on===n?o-s.at:0;s.on!==n&&_i.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`),_i.set(t,{on:i.checked,at:performance.now()}),e.onChange(i.checked)}),r}function yi(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 bi(e,t){let n=t.hoverReport===null?null:Fn(t.hoverReport);if(t.notices.length===0&&n===null){e.replaceChildren();return}let r=E(`div`,void 0);r.setAttribute(`data-take-notes`,``);for(let e of t.notices){let t=E(`div`,`notice`);g(t,e),t.setAttribute(`data-take-notice`,``),r.append(t)}if(n!==null){let e=E(`div`,`notice`,n);e.setAttribute(`data-hover-report`,``),r.append(e)}e.replaceChildren(r)}function xi(e,t){if(t.hasFrames){e.replaceChildren();return}let n=E(`div`,`banner`),r=E(`span`);r.append(Si(t.route)),n.append(r),e.replaceChildren(n)}function Si(e){let t=document.createDocumentFragment();return t.append(`This video has no frames — `,Ci(e,mt(e.authored))),t}function Ci(e,t){if(e.rerun.kind===`line`){let t=E(`span`);return g(t,e.rerun.text),t.setAttribute(`data-rerun-line`,``),t}let n=E(`a`,void 0,t);return n.setAttribute(`href`,e.rerun.href),n.setAttribute(`data-runs-route`,``),n}function wi(e,t){let n=[];if(t.openError!=null){let e=E(`div`,`notice`);e.setAttribute(`data-open-error`,``),e.append(E(`strong`,void 0,`This video could not be opened`)),e.append(E(`div`,void 0,t.openError)),n.push(e)}if(t.replaySentence!==null){let e=E(`div`,`notice`);e.setAttribute(`data-replay-failure`,``);let r=t.runsRoute?.authored===!0?`script run`:`re-shoot`;if(e.append(E(`strong`,void 0,t.replayRecoverable===!0?`The last ${r} stopped early`:`The last ${r} did not finish`)),e.append(E(`div`,void 0,t.replaySentence)),t.runsRoute!=null){let n=E(`div`);n.setAttribute(`data-replay-runs-route`,``),n.append(Ci(t.runsRoute,kt(t.runsRoute.authored))),e.append(n)}n.push(e)}if(t.captureSentence!=null){let e=E(`div`,`notice`);e.setAttribute(`data-capture-note`,``),e.append(E(`strong`,void 0,`What this video recorded`)),e.append(E(`div`,void 0,t.captureSentence)),n.push(e)}if(t.renderError!=null){let e=E(`div`,`notice`);e.setAttribute(`data-render-error`,``),e.append(E(`strong`,void 0,`The export did not start`)),e.append(E(`div`,void 0,t.renderError)),n.push(e)}if(t.previewError!=null){let e=E(`div`,`notice`);e.setAttribute(`data-preview-error`,``),e.append(E(`strong`,void 0,`The preview stopped`)),e.append(E(`div`,void 0,t.previewError)),n.push(e)}if(t.logoLoadError!=null){let e=E(`div`,`notice`);e.setAttribute(`data-logo-load-error`,``),e.append(E(`strong`,void 0,`The logo could not be loaded`)),e.append(E(`div`,void 0,t.logoLoadError)),n.push(e)}if(t.wallpaperLoadError!=null){let e=E(`div`,`notice`);e.setAttribute(`data-wallpaper-load-error`,``),e.setAttribute(`role`,`alert`),e.append(E(`strong`,void 0,`The background image could not be loaded`)),e.append(E(`div`,void 0,t.wallpaperLoadError)),n.push(e)}if(t.error!==null){let e=E(`div`,`notice`);e.setAttribute(`data-action-error`,``),e.append(E(`strong`,void 0,`That edit did not go through`)),e.append(E(`div`,void 0,t.error)),n.push(e)}if(t.deleteError!=null){let e=E(`div`,`notice`);e.setAttribute(`data-delete-error`,``),e.append(E(`strong`,void 0,`This video was not deleted`)),e.append(E(`div`,void 0,t.deleteError)),n.push(e)}if(t.navigationError!=null){let e=E(`div`,`notice`);e.setAttribute(`data-navigation-error`,``),e.append(E(`strong`,void 0,`The ${t.navigationError.page} did not open`)),e.append(E(`div`,void 0,t.navigationError.reason)),n.push(e)}e.replaceChildren(...n)}function Ti(e,t,n){Ee(e,t,n)}var Ei={light:`Light`,dark:`Dark`,touch:`Touch`},Di={light:1/16,dark:1/16,touch:0};function Oi(e,t,n){let{height:r,hotspot:i,ink:a}=v[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-Di[e])*o,y:n/2-(s.y-i.y)*o}}var ki=.6;function Ai(e,t,n){return Math.min(Math.min(2,Math.max(.5,t))*ki,n/v[e].height)}function ji(e,t){let n=E(`canvas`);n.width=44,n.height=44;let r=n.getContext(`2d`);if(!r)return console.error(`the cursor panel could not paint its "${e}" preview: no 2D context`),n;let i=Ai(e,t,44);return ne(r,Oi(e,i,44),i,ce,e),n}function Mi(e,t,n,r,i,a,o,s){let c=E(`div`,`slider-row`),l=E(`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=E(`span`,`slider-value`,a(n));Re(l),l.addEventListener(`input`,()=>{Re(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(E(`span`,`control-label slider-label`,t),u,l),c}var Ni=e=>`${Math.round(e*100)}%`,Pi=e=>`${e.toFixed(2)}x`;function Fi(e,t,n,r,i,a,o,s,c){return Mi(e,t,n,r,i,a,{preview:e=>s.onCursorPreview({[o]:e}),commit:e=>s.onCursor({[o]:e}),end:()=>s.onCursorPreviewEnd()},c)}function Ii(e,t,n,r,i){return Mi(e,t,n,0,1,Ni,{preview:e=>i.onMotionPreview({[r]:e}),commit:e=>i.onMotion({[r]:e}),end:()=>i.onMotionPreviewEnd()},!1)}function Li(e,t,n,r,i,a){return yi(t,null,vi({key:r,checked:n,disabled:a,attrs:{[e]:``},onChange:e=>i.onCursor({[r]:e})}))}function Ri(e,t,n,r,i=!1){let a=E(`div`),o=t.hidden;a.append(Li(`data-cursor-hidden`,`Hide cursor`,t.hidden,`hidden`,r,!1));let s=Fi(`data-cursor-scale`,`Size`,t.scale,.5,2,Pi,`scale`,r,o);i&&a.append(s);let c=E(`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=E(`button`,`cursor-style`);n.type=`button`,n.disabled=o,n.setAttribute(`role`,`radio`),n.setAttribute(`data-cursor-style`,e),n.setAttribute(`aria-checked`,String(t.style===e)),n.setAttribute(`aria-label`,Ei[e]),n.title=Ei[e],n.append(ji(e,t.scale)),n.addEventListener(`click`,()=>r.onCursor({style:e})),c.append(n)}i||a.append(E(`div`,`cursor-label`,`Style`),c),i||a.append(s,Fi(`data-cursor-blur`,`Motion blur`,t.motionBlur,0,1,Ni,`motionBlur`,r,o),Fi(`data-cursor-tilt`,`Tilt`,t.tilt??b.tilt,0,1,Ni,`tilt`,r,o),Fi(`data-cursor-bounce`,`Click bounce`,t.clickBounce??b.clickBounce,0,2,Pi,`clickBounce`,r,o),Li(`data-cursor-idle`,`Hide when not moving`,t.hideWhenIdle,`hideWhenIdle`,r,o)),a.append(E(`div`,`cursor-label camera-label`,`Camera`),Ii(`data-motion-smoothness`,`Smoothness`,n.smoothness,`smoothness`,r),Ii(`data-motion-blur`,`Camera blur`,n.blur,`blur`,r),yi(`Follow cursor`,null,vi({key:`motion-follow`,checked:n.follow,attrs:{"data-motion-follow":``},onChange:e=>r.onMotion({follow:e})}))),e.replaceChildren(a)}function zi(){let e=E(`progress`,`export-progress`);return e.setAttribute(`data-export-progress`,``),e.setAttribute(`aria-label`,`Export progress`),e}function Bi(e,t,n){return e.phase!==`idle`||t.kind===`noFrames`||n.length===0}function Vi(e,t,n,r,i=[]){let a=e.querySelector(`[data-export-start]`);if(a===null)return!1;a.textContent=mi(t,n,r,Hi(i)),a.disabled=Bi(t,r,n);let o=Ct(i);if(o!==null&&i.length>1){let n=e.querySelector(`[data-file-status="${o.fileType}"]`);n!==null&&(n.textContent=Wi(o,t,i))}let s=e.querySelector(`[data-export-progress]`);if(t.phase!==`encoding`||t.total===0)return s?.remove(),!0;let c=s??zi();return Ui(c,t,i),s===null&&a.closest(`.control-actions`)?.after(c),!0}function Hi(e){return e.length>1?Ct(e)?.fileType??null:null}function Ui(e,t,n){let r=Math.max(1,n.length),i=Math.max(0,n.findIndex(e=>e.ended===null));e.max=t.total*r,e.value=t.total*i+t.done}function Wi(e,t,n){if(e.ended===`saved`)return`Saved`;if(e.ended===`failed`)return`Failed`;if(e!==Ct(n))return`Waiting`;switch(t.phase){case`idle`:return`Waiting`;case`queued`:return`Queued`;case`encoding`:return t.total>0?`${Math.floor(t.done*100/t.total)}%`:`Exporting`;case`saving`:return`Saving`}}function Gi(e,t,n){let r=E(`div`),i=t.run.phase!==`idle`;if(t.hasReclaimedMotion){let e=E(`p`,`notice`,`This export will use still frames where motion was reclaimed.`);e.setAttribute(`data-reclaimed-motion-notice`,``),r.append(e)}let a=E(`p`,`export-summary`,C(t.durationMs));a.setAttribute(`data-export-summary`,``);let o=E(`p`,`muted`,ze(t.aspect));o.setAttribute(`data-aspect-note`,``),r.append(a,o);let s=E(`p`,`muted`,Ie(t.recording));s.setAttribute(`data-size-readout`,``),r.append(s);let c=i&&t.files.length>1?t.files:[],l=E(`div`,`control-row`);l.append(E(`span`,`control-label`,`Files`));let u=E(`div`,`file-types`);u.setAttribute(`role`,`group`),u.setAttribute(`aria-label`,`Files`),u.setAttribute(`data-file-types`,``);for(let e of Oe){let r=E(`label`,`file-type`),a=E(`input`);a.type=`checkbox`,a.checked=t.fileTypes.includes(e),a.setAttribute(`data-file-type`,e),a.disabled=i,a.addEventListener(`click`,()=>n.onFileType(e,a.checked));let o=c.find(t=>t.fileType===e),s=o===void 0?E(`span`,`file-facts`,Le(e,t.durationMs,t.targets[e])):E(`span`,`file-status`,Wi(o,t.run,t.files));if(o!==void 0&&s.setAttribute(`data-file-status`,e),r.append(a,E(`span`,`file-name`,Fe[e]),s),u.append(r),e===`mp4`&&a.checked&&t.quality!=null){let e=E(`div`,`file-quality`);e.append(E(`span`,`control-aside`,`Quality`));let r=E(`div`,`segmented`);r.setAttribute(`role`,`radiogroup`),r.setAttribute(`aria-label`,`Quality`),r.setAttribute(`data-export-qualities`,``);for(let e of be){let a=E(`button`,`segment`,ye[e]);a.type=`button`,a.setAttribute(`role`,`radio`),a.setAttribute(`data-export-quality`,e),a.setAttribute(`aria-checked`,String(e===t.quality)),a.disabled=i,a.addEventListener(`click`,()=>n.onQuality(e)),r.append(a)}e.append(r),u.append(e)}}l.append(u),r.append(l);let d=E(`button`,`btn btn-primary export-start`,mi(t.run,t.fileTypes,t.readiness,Hi(t.files)));d.type=`button`,d.setAttribute(`data-export-start`,``),d.setAttribute(`data-readiness`,t.readiness.kind),d.disabled=Bi(t.run,t.readiness,t.fileTypes),d.addEventListener(`click`,n.onExport);let f=E(`div`,`control-actions`);if(f.append(d),t.readiness.kind===`noFrames`){let e=E(`p`,`muted`);e.setAttribute(`data-export-no-frames`,``),e.append(Si(t.runsRoute)),r.append(f,e)}else if(t.fileTypes.length===0){let e=E(`p`,`muted`,`Tick at least one file.`);e.setAttribute(`data-export-none-ticked`,``),r.append(f,e)}else r.append(f);if(t.run.phase===`encoding`&&t.run.total>0){let e=zi();Ui(e,t.run,t.files),r.append(e)}if(t.save!==null&&r.append(na(t.save,n)),!i)for(let e of t.files.filter(e=>e.ended===`failed`)){let t=E(`div`,`notice notice-error`);t.setAttribute(`data-file-failed`,e.fileType);let i=E(`button`,`btn btn-quiet`,`Retry`);i.type=`button`,i.addEventListener(`click`,()=>n.onRetry(e.fileType)),t.append(E(`span`,void 0,`${Fe[e.fileType]} failed`),` `,i),r.append(t)}if(t.revealError!=null){let e=E(`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`&&Yi(r,n.output,t)}e.replaceChildren(r)}function Ki(e,t,n){let r=document.createDocumentFragment(),i=t.showAll?t.outputs:t.outputs.slice(0,5);for(let e of i){let i=E(`div`,`output`);if(i.setAttribute(`data-output`,e.kind===`file`?e.key:e.output.ref),r.append(i),e.kind===`file`){ea(i,e,t,n);continue}let a=e.output,o=E(`div`,`beat`),s=a.sceneDigest!==void 0&&a.sceneDigest!==t.currentDigest,c=t.warningsOpen.has(a.ref);o.append(Qi(a.name,[s?Zi(a.ref):null,Ji(a.ref,qi(a),c,n)]));let l=E(`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($i(a.ref,[hi(a.byteLength),Xi(a.renderedAt)],null)),c&&qi(a)>0){let e=E(`div`,`output-warnings`);e.setAttribute(`data-output-warnings-body`,a.ref),Yi(e,a,t.reportContext),i.append(e)}}let a=t.outputs.length-i.length;if(a>0){let e=E(`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 qi(e){return[e.detailViolations.length>0,e.logoWarning!==void 0,(e.unavailableSpans??[]).length>0,(e.unplacedStills??[]).length>0].filter(Boolean).length}function Ji(e,t,n,r){if(t===0)return null;let i=E(`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 Yi(e,t,n){if(t.detailViolations.length>0){let{heading:r,lines:i}=yt(t.detailViolations,n.beatAt),a=E(`div`,`notice`);a.setAttribute(`data-violations`,t.ref),a.append(E(`strong`,void 0,r));for(let e of i)a.append(E(`div`,void 0,e));a.append(E(`div`,`honesty`,`A wider browser 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=E(`div`,`notice`);n.setAttribute(`data-logo-warning`,t.ref),n.append(E(`div`,void 0,t.logoWarning)),e.append(n)}let r=t.unavailableSpans??[];if(r.length>0){let i=E(`div`,`notice`);i.setAttribute(`data-unavailable`,t.ref);let a=r.every(e=>e.reason===ht),o=E(`strong`);g(o,a?`Motion was reclaimed to free space and shown as a still. ${Mt(n.runsRoute.authored,jt(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(E(`div`,void 0,`${e.ref}: ${e.reason}`));e.append(i)}let i=t.unplacedStills??[];if(i.length>0){let n=E(`div`,`notice`);n.setAttribute(`data-unplaced-stills`,t.ref);let r=i.every(e=>e.reason.includes(`cut`));n.append(E(`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(E(`div`,void 0,`${e.actionId}: ${e.reason}`));e.append(n)}}function Xi(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?e:Ge(n,n.getFullYear()!==t.getFullYear())}function Zi(e){let t=E(`span`,`chip`,`Outdated`);return t.setAttribute(`data-stale-export`,e),t.title=`Made before your last edit`,t}function Qi(e,t){let n=E(`span`,`output-head`),r=E(`span`,`output-name`,e);r.title=e,n.append(r);for(let e of t)e!==null&&n.append(e);return n}function $i(e,t,n){let r=E(`div`,`muted output-meta`,t.join(` · `));return r.setAttribute(`data-output-meta`,e),n!==null&&(r.title=n),r}function ea(e,t,n,r){let i=E(`div`,`beat`),a=n.warningsOpen.has(t.key);if(i.append(Qi(t.name,[t.sceneDigest===n.currentDigest?null:Zi(t.key),Ji(t.key,t.caveats.length,a,r)])),t.exists){let e=E(`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=E(`span`,`muted`,`moved or deleted`);e.setAttribute(`data-output-gone`,``),i.append(e)}if(e.append(i),e.append($i(t.key,[hi(t.byteLength),Xi(t.renderedAt)],t.detail)),a&&t.caveats.length>0){let n=E(`div`,`notice output-warnings`);n.setAttribute(`data-output-warnings-body`,t.key);for(let e of t.caveats)n.append(E(`div`,void 0,ta(e)));e.append(n)}}function ta(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return/[.!?]$/.test(t)?t:`${t}.`}function na(e,t){let n=E(`div`,e.kind===`failed`?`notice notice-error`:`notice`);n.setAttribute(`data-save-outcome`,e.kind);let r=(e,n)=>{let r=E(`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]} · ${hi(e.byteLength)}`:`Saved ${e.names.length} files · ${hi(e.byteLength)}`;n.append(E(`span`,void 0,r));let i=e.reveal;if(i!==null){let e=E(`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=E(`div`,`muted`,e.summary);t.setAttribute(`data-save-summary`,``),n.append(t)}}else e.kind===`cancelled`?(n.append(E(`span`,void 0,`You cancelled the save.`)),e.total>1?n.append(E(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)):n.append(` `),n.append(r(e.refs,`Download again`))):(n.append(E(`strong`,void 0,`Exported, but the browser didn't save it.`)),e.total>1&&n.append(E(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)),n.append(E(`div`,void 0,e.error),r(e.refs,`Download again`)));return n}function ra(e,t){let n=E(`button`,`btn btn-icon transport-button`);return n.type=`button`,n.setAttribute(`data-transport-shuttle`,String(e)),n.setAttribute(`aria-label`,t),n.append(T(e===-1?`rewind`:`fastForward`)),n}function ia(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=E(`button`,`btn btn-icon transport-button`),r.type=`button`,r.setAttribute(`data-transport-play`,``),s=E(`button`,`btn btn-icon transport-button`),s.type=`button`,s.setAttribute(`data-transport-skip`,``),s.append(T(`skipBack`)),o=E(`button`,`btn btn-icon transport-button`),o.type=`button`,o.setAttribute(`data-transport-repeat`,``),o.append(T(`repeat`));let t=E(`span`,`transport-pip`);t.setAttribute(`aria-hidden`,`true`),o.append(t),i=E(`span`,`rate`),i.setAttribute(`data-transport-rate`,``),a=E(`div`,`transport-controls`),a.setAttribute(`data-transport-controls`,``),a.append(s,ra(-1,`Rewind`),r,ra(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?Zr(e,o,[r===-1?`J`:`L`]):(Qr(e),e.title=o)}s.onclick=()=>n.onSkipToStart(),s.disabled=!t.enabled;let l=`Jump to start`;s.setAttribute(`aria-label`,l),t.enabled?Zr(s,l,[`Mod`,`Left`]):(Qr(s),s.title=y(`This video has no frames yet, so there is nothing to play. ${Mt(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(T(f)),r.toggleAttribute(`data-playing`,t.playing),r.toggleAttribute(`data-active`,t.playing&&t.rate===1),r.disabled=!t.enabled,t.enabled?Zr(r,d,[`Space`]):(Qr(r),r.title=y(`This video has no frames yet, so there is nothing to play. ${Mt(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 aa(e,t,n,r=e){let i=r.querySelector(`[data-transport-time]`),a=e.querySelector(`[data-stage-actions]`);if(i===null||a===null){i=E(`span`,`stage-clock`),i.setAttribute(`data-transport-time`,``),a=E(`div`,`stage-actions`),a.setAttribute(`data-stage-actions`,``);let t=E(`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=E(`button`,`segment`,e===`auto`?`Auto`:e);n.type=`button`,n.setAttribute(`role`,`radio`),n.setAttribute(`data-aspect`,e),n.title=e===`auto`?`Auto: the export takes the source's shape`:e===`9:16`?`Vertical: the camera follows each step, cropped for a phone`:`Landscape`,t.append(n)}a.append(t);let n=E(`button`,`btn chip`);n.type=`button`,n.setAttribute(`data-stage-zoom`,``),a.append(n);let o=E(`button`,`btn btn-icon chip chip-icon`);o.type=`button`,o.setAttribute(`data-stage-fullscreen`,``),a.append(o);let s=E(`div`,`stage-error`);s.setAttribute(`data-stage-error`,``),s.setAttribute(`role`,`alert`),s.hidden=!0;let c=E(`span`,`stage-error-text`);c.setAttribute(`data-stage-error-text`,``);let l=E(`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(T(`close`)),s.append(c,l),r===e?e.replaceChildren(i,a,s):(r.replaceChildren(i),e.replaceChildren(a,s))}i.textContent=`${A(t.positionMs)} / ${A(t.durationMs)}`;for(let r of e.querySelectorAll(`[data-aspect]`)){let e=r.dataset.aspect;r.setAttribute(`aria-checked`,String(e===t.aspect)),r.onclick=()=>n.onAspect(e)}let o=e.querySelector(`[data-stage-zoom]`);o!==null&&(o.textContent=t.zoom===`fit`?`Fit`:`100%`,o.setAttribute(`aria-label`,`Zoom: ${o.textContent}`),o.disabled=!t.enabled,o.title=t.enabled?`Switch between fitting the window and actual pixels`:y(`This video has no frames yet, so there is nothing to zoom into. ${Mt(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(T(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 oa={undo:[`Mod`,`Z`],redo:[`Shift`,`Mod`,`Z`],"shortcuts-open":[`?`]};function sa(e=document){for(let[t,n,r]of[[`back`,`chevronLeft`,`Back to your flows`],[`undo`,`undo`,`Undo`],[`redo`,`redo`,`Redo`],[`delete`,`trash`,`Delete this video`],[`shortcuts-open`,`circleQuestionMark`,`Keyboard shortcuts`]]){let i=e.querySelector(`#${t}`);if(i===null)continue;i.setAttribute(`aria-label`,r);let a=oa[t];a===void 0?i.title===``&&(i.title=r):Zr(i,r,a),i.querySelector(`svg`)===null&&(i.textContent=``,i.append(T(n)))}}var ca=`#failure > .notice:not([data-capture-note])`;function la(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(ca)===null?`warn`:`error`;e.setAttribute(`data-level`,r);let i=`${n} ${n===1?`note`:`notes`} on this video${r===`error`?`, with an error`:``}`;e.setAttribute(`aria-label`,i),e.title=i,e.querySelector(`svg`)===null&&e.append(T(`circleAlert`));let a=e.querySelector(`[data-count]`);a===null&&(a=E(`span`),a.setAttribute(`data-count`,``),a.setAttribute(`aria-hidden`,`true`),e.append(a)),a.textContent=String(n)}function ua(e,t){let n=[...e.querySelectorAll(ca)].map(e=>e.textContent??``).join(`
|
|
2
|
-
`);return n!==``&&n!==t&&typeof e.showPopover==`function`&&!e.matches(`:popover-open`)&&e.showPopover(),n}function da(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=E(`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=E(`div`,`shortcuts-body`),o=[];for(let e of Nr){let n=o[o.length-1];if(n?.group!==e.group){let t=E(`section`,`shortcuts-section`);t.append(E(`h3`,`shortcuts-group`,e.group)),a.append(t),n={section:t,group:e.group,rows:[]},o.push(n)}let r=E(`div`,`shortcuts-row`);r.setAttribute(`data-shortcut-row`,``),r.append(E(`span`,`shortcuts-what`,Mr(e,t.mac)));let i=E(`span`,`shortcuts-keys`);for(let n of e.combos){let e=E(`span`,`keychord`);e.setAttribute(`data-combo`,``),e.setAttribute(`aria-label`,Ar(n,t.mac));for(let r of n){let n=Er(r,t.mac),i=E(`kbd`,`keycap`,n);i.setAttribute(`aria-hidden`,`true`),Or(n)&&i.setAttribute(`data-symbol`,``),e.append(i)}i.append(e)}r.append(i),n.section.append(r),n.rows.push(r)}let s=E(`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 fa(e){return`${Xe(e)}${Je(e)}`}function pa(e,t,n=!1){let r=E(`div`,`info-row`);r.append(E(`span`,`info-key`,e));let i=E(`span`,n?`info-value mono`:`info-value`,t);return i.title=t,r.append(i),r}function ma(e,t,n,r){let i=pa(e,t,!0),a=E(`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(T(`copy`));let o=E(`div`,`info-error`);o.setAttribute(`data-copy-error`,n),o.hidden=!0,a.addEventListener(`click`,()=>{r(t).then(()=>{o.hidden=!0,a.replaceChildren(T(`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=E(`div`);return s.append(i,o),s}function ha(e,t,n){let r=E(`div`,`info-group`);r.setAttribute(`data-info-facts`,``);let i=`${C(t.durationMs)} · ${t.steps} ${t.steps===1?`step`:`steps`}`,a=t.aspect===`auto`?`Auto`:t.aspect;r.append(pa(`Recorded`,Xi(t.recordedAt)),pa(`Site`,fa(t.site)),pa(`Length`,i),pa(`Source`,`${t.recording.width} × ${t.recording.height}`),pa(`Export`,`${t.target.width} × ${t.target.height} · ${a}`));let o=E(`div`,`info-group`);if(o.setAttribute(`data-info-ids`,``),o.append(ma(`Video ID`,t.takeId,`video ID`,n.onCopy)),t.rerun.kind===`link`){let e=E(`div`,`info-row`);e.append(E(`span`,`info-key`,`Re-record`));let n=E(`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=E(`div`,`info-group info-exports`);if(e.setAttribute(`data-info-exports`,``),e.append(E(`div`,`info-label`,`Exports`)),t.revealError!==null){let n=E(`p`,`notice notice-warn`,t.revealError);n.setAttribute(`data-reveal-error`,``),e.append(n)}let r=E(`div`,`info-history`);Ki(r,t.history,n),e.append(r),s.push(e)}e.replaceChildren(...s)}var ga=.006,N=e=>`${(e*100).toFixed(4)}%`;function _a(e,t,n,r=ga){if(n<e.startMs||t>e.endMs)return null;let i=Math.max(0,M(e,t)),a=Math.min(1,M(e,n)),o=Math.max(r,a-i);return{left:Math.min(i,1-o),width:o,toScale:a-i>=r}}var va=(e,t)=>Math.min(1,Math.max(0,M(e,t))),ya=[100,250,500,1e3,2e3,5e3,1e4,15e3,3e4,6e4],ba=(e,t)=>t>=1e3?A(e):`${A(e)}.${Math.floor(e%1e3/100)}`;function xa(e,t){let n=E(`div`,`ruler`);n.setAttribute(`data-ruler`,``),n.setAttribute(`data-source`,e.timeSource);let r=(t.viewport.endMs-t.viewport.startMs)/10,i=ya.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=M(t.viewport,e),a=E(`span`,`tick`,ba(e,i));a.style.left=N(r),a.dataset.fraction=String(r),n.append(a)}return Ca?.observe(n),n}function Sa(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 Ca=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>{for(let t of e){let e=t.target;e.isConnected?Sa(e):Ca?.unobserve(e)}});function wa(e,t){let n=E(`div`,`lane`);return n.append(e,t),n}function Ta(e,t,n){let r=E(`div`,`lane-label lane-head`),i=E(`span`,`lane-title`),a=E(`span`,`lane-glyph`);return a.append(T(t)),i.append(a,E(`span`,`lane-name`,e)),n&&i.append(n),r.append(i),r}function Ea(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=E(`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 Da=3;function Oa(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 ka=(e,t)=>e!==null&&t!==null&&e.kind===t.kind&&(e.kind===`tick`?e.actionId===t.actionId:e.kind===`piece`?zt(e.start,t.start):e.id===t.id),Aa=(e,t)=>e.snapping?8*t:0;function ja(e,t){let n=e.getBoundingClientRect().width;return n===0?0:(t.endMs-t.startMs)/n}function Ma(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 Na(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=ja(t,n.viewport);return{toMs:Ma(t,n.viewport,e),deltaMs:(e-s)*r,snapMs:Aa(n,r)}},u=e=>{Math.abs(e.clientX-s)>Da&&(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 Pa=e=>Math.max(0,Math.min(1,e));function Fa(e,t,n,r){let i=Pa(r);t.style.left=N(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=N(l),a.style.width=N(Math.max(s,c)-l)}function Ia(e,t,n,r,i){let a=E(`div`,`edge`);return a.setAttribute(`data-edge`,t),a.setAttribute(`aria-label`,t===`start`?`Drag the piece's start`:`Drag the piece's end`),Na(a,n,r,({deltaMs:n})=>({kind:`pieceEdge`,start:e.start,side:t,deltaMs:n}),i,{move:({deltaMs:e})=>{let i=e/ja(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 La(e,t,n,r){let i=E(`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=E(`div`,`join-card-what`),o=E(`b`),s=E(`span`);e.unplaced===void 0?(o.textContent=`${n} removed`,s.textContent=`${Ra(e.srcStartMs)} to ${Ra(e.srcEndMs)}`):(o.textContent=`Removes no frames`,s.textContent=e.unplaced.charAt(0).toUpperCase()+e.unplaced.slice(1)),a.append(o,s);let c=E(`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 Ra(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 za(e,t,n){let r=E(`div`,`track`);r.setAttribute(`data-track`,`clip`);let{clip:i}=e;for(let e of i.degraded){let n=_a(t.viewport,e.startMs,e.endMs,0);if(n===null)continue;let i=E(`div`,`degraded`);i.setAttribute(`data-degraded`,``),i.style.left=N(n.left),i.style.width=N(n.width),r.append(i)}let a=M(t.viewport,i.trim.headMs),o=M(t.viewport,i.trim.tailMs),s=_a(t.viewport,i.trim.headMs,i.trim.tailMs);if(s!==null){let e=E(`div`,`seg`);e.setAttribute(`data-clip-block`,``),e.setAttribute(`data-kind`,`clip`),e.setAttribute(`data-to-scale`,String(s.toScale)),e.style.left=N(s.left),e.style.width=N(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=_a(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=E(`div`,`piece-wrap`);d.style.left=N(o),d.style.width=N(u-o);let f=E(`button`,`piece`);f.type=`button`,f.setAttribute(`data-piece`,String(e.startMs)),f.setAttribute(`aria-label`,`Piece of the clip`),ka(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(Ia(e,`start`,r,t,n)),(!m||e.after!==null)&&d.append(Ia(e,`end`,r,t,n)),c.append(d)}));for(let e of i.joins){let i=M(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(${N(i)} + ${a}px)`,s=t.openJoin===e.removedId,c=`${((e.srcEndMs-e.srcStartMs)/1e3).toFixed(1)}s`,l=E(`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)>Da;u=null,r||n.onOpenJoin(s?null:e.removedId)});let d=E(`span`,`seam`);d.setAttribute(`data-seam`,e.removedId),d.style.left=o,r.append(d,l),s&&r.append(La(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=E(`div`,`handle`);a.setAttribute(`data-trim`,e),a.setAttribute(`data-timing`,c),a.style.left=N(s),Na(a,r,t,({toMs:t,snapMs:n})=>({kind:`trim`,edge:e,toMs:t,snapMs:n}),n,{move:({toMs:n})=>Fa(r,a,e,M(t.viewport,n)),end:()=>Fa(r,a,e,s)}),r.append(a)}for(let e of i.ticks){let a=M(t.viewport,e.atMs);if(a<0||a>1)continue;let o=E(`button`,`tick`);o.type=`button`,o.setAttribute(`data-tick`,e.actionId),o.setAttribute(`data-verb`,e.verb);let s=Ka[e.verb];s!==void 0&&o.append(T(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(Ba(i.ticks,e));o.setAttribute(`data-stack-index`,c),o.style.setProperty(`--tick-stack`,c),ka(t.selection,{kind:`tick`,actionId:e.actionId})&&o.setAttribute(`data-selected`,``),o.style.left=N(a),o.addEventListener(`click`,t=>{t.stopPropagation(),n.onSelect({kind:`tick`,actionId:e.actionId})}),r.append(o)}return r}function Ba(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 Va(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=_a(i.viewport,s,c);if(l===null)return null;let u=E(`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=N(l.left),u.style.width=N(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};ka(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(E(`span`,`seg-label`,`${t.scale.toFixed(1)}x`))}else p&&u.setAttribute(`data-whole-take`,``),u.append(E(`span`,`seg-label`,p?`mask · whole video`:`mask`));if(u.addEventListener(`click`,e=>{e.stopPropagation(),a.onSelect(f)}),!p){let r=(e,t)=>{u.style.left=N(e),u.style.width=N(t)},o=()=>r(l.left,l.width),s=i.viewport.endMs-i.viewport.startMs;for(let s of[`start`,`end`]){let c=E(`div`,`cap`);c.setAttribute(`data-cap`,s),Na(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=Pa(M(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)}Na(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 Ha(e,t,n,r){let i=E(`div`,`track`);i.setAttribute(`data-track`,e);let a=e===`zoom`?t.zooms:t.masks;for(let o of a){let a=Va(o,e,i,t,n,r);a&&i.append(a)}return i.addEventListener(`click`,a=>{if(a.target!==i)return;let o=ja(i,n.viewport);r.onGesture({kind:e===`zoom`?`addZoom`:`addMask`,atMs:Ua(e,t,Ma(i,n.viewport,a.clientX)),snapMs:Aa(n,o)})}),Ga(i,e,t,n),i}function Ua(e,t,n){let r=e===`zoom`?(t.zoomDefaultMs-t.zoomInMs)/2:sn/2;return Math.max(0,Math.min(t.durationMs,n-r))}function Wa(e,t,n){let r=e===`zoom`?_n(t,n):vn(t,n);return cn(r)?null:e===`mask`?{startMs:r.startMs,endMs:r.endMs}:{startMs:Zt(t.zooms,r.startMs,t.zoomInMs),endMs:Qt(t.zooms,r.startMs,r.endMs)}}function Ga(e,t,n,r){let i=null,a=()=>{i?.remove(),i=null};e.addEventListener(`pointermove`,o=>{if(o.target!==e)return a();let s=Wa(t,n,Ua(t,n,Ma(e,r.viewport,o.clientX))),c=s&&_a(r.viewport,s.startMs,s.endMs);if(c===null)return a();i===null&&(i=E(`div`,`seg`),i.setAttribute(`data-ghost`,t),i.setAttribute(`aria-hidden`,`true`),e.append(i)),i.style.left=N(c.left),i.style.width=N(c.width)}),e.addEventListener(`pointerleave`,a)}var Ka={click:`mousePointerClick`,type:`type`,moveTo:`mousePointer2`,scrollTo:`moveVertical`,waitFor:`hourglass`,drag:`handGrab`,press:`type`};function qa(e,t,n,r){let i=E(`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=E(`p`,`muted`);g(e,t.rerunLine===null?`Timing from the video, not from a render — ${mt(t.authored)} to see the timing this video will actually have.`:`Timing from the video, not from a render. ${t.rerunLine}`),i.append(e)}let a=xa(t,n);Oa(a,()=>a.getBoundingClientRect(),n,t.durationMs,r);let o=E(`div`,`lanes`);o.append(wa(E(`b`,`lane-label`),a));let s=E(`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(Gr(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(Kr(n.viewport,t.durationMs,a/i.width*o))});let c=Ta(`Clip`,`film`),l=Ea(t.hoverCheck);l!==null&&c.querySelector(`.lane-glyph`)?.append(l);let u=wa(c,za(t,n,r));u.setAttribute(`data-lane`,`clip`),o.append(u);let d=wa(Ta(`Zoom`,`zoomIn`),Ha(`zoom`,t,n,r));d.setAttribute(`data-lane`,`zoom`),o.append(d);let f=E(`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(T(`plus`)),f.onclick=()=>{let e=i.querySelector(`[data-track="clip"]`),t=e?ja(e,n.viewport):0;r.onGesture({kind:`addMask`,atMs:n.positionMs,snapMs:Aa(n,t)})};let p=wa(Ta(`Mask`,`eyeOff`,f),Ha(`mask`,t,n,r));p.setAttribute(`data-lane`,`mask`),o.append(p);let m=E(`div`,`playhead`);m.setAttribute(`data-playhead`,``),m.style.left=N(va(n.viewport,n.positionMs));let h=E(`div`,`grab`);h.setAttribute(`data-playhead-grab`,``),h.setAttribute(`aria-hidden`,`true`),Oa(h,()=>s.getBoundingClientRect(),n,t.durationMs,r),m.append(h),s.append(m),o.append(s),i.append(o);let _=E(`p`,`refusal`);g(_,n.refusal??``),_.setAttribute(`data-refusal`,``),_.hidden=n.refusal===null,i.append(_);let v=e.ownerDocument.activeElement,y=v instanceof HTMLElement&&e.contains(v)&&v.matches(`[data-lane="mask"] [data-add-mask]`);e.replaceChildren(i),y&&f.focus();let b=i.querySelector(`[data-join-card]`);b!==null&&Ja(b)}function Ja(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 Ya(e){let t=E(`button`,`btn btn-quiet btn-icon tool`);return t.type=`button`,t.append(T(e)),t}function Xa(e,t,n){e.setAttribute(`aria-label`,t),e.disabled?(Qr(e),e.title=t):Zr(e,t,n)}var Za=new WeakMap;function Qa(){let e=E(`div`,`bar-controls`);e.setAttribute(`data-timeline-tools`,`view`);let t=Ya(`magnet`);t.classList.add(`snap`);let n=Ya(`moveHorizontal`);n.classList.add(`fit`),n.setAttribute(`data-fit`,``);let r=Ya(`scissors`);r.setAttribute(`data-split-tool`,``);let i=E(`div`,`zoom-control`);i.setAttribute(`data-zoom-control`,``);let a=E(`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=Ya(`zoomOut`);o.classList.add(`zoom-step`),o.setAttribute(`data-zoom-step`,`out`);let s=Ya(`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 $a(e,t,n,r){let i=Za.get(e);(i===void 0||i.view.parentElement!==e)&&(i=Qa(),Za.set(e,i),e.replaceChildren(i.view));let{split:a,snap:o,fit:s,zoom:c,zoomOut:l,zoomIn:u}=i;Xa(a,`Split at playhead`,[`Mod`,`B`]),a.onclick=()=>r.onSplit(),Xa(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=Hr(t.durationMs),f=n.viewport.startMs===d.startMs&&n.viewport.endMs===d.endMs;s.disabled=f,Xa(s,f?`The whole video is already in view`:`Fit the whole video`,[`Shift`,`Z`]),s.onclick=()=>r.onViewport(d);let p=n.viewport.endMs-n.viewport.startMs,m=Yr(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 video is too short to zoom into.`,c.oninput=()=>{let e=Jr(t.durationMs,Number(c.value)),i=M(n.viewport,n.positionMs);r.onViewport(qr(n.viewport,t.durationMs,e,i>=0&&i<=1?i:.5))};let g=e=>{let i=Math.min(1,Math.max(0,M(n.viewport,n.positionMs)));r.onViewport(Gr(n.viewport,t.durationMs,e,i))};l.disabled=!h||m<=5e-4,l.onclick=()=>g(1/Sr),Xa(l,`Zoom out`,[`−`]),u.disabled=!h||m>=.9995,Xa(u,`Zoom in`,[`+`]),u.onclick=()=>g(Sr)}var P=le();function F(e){console.error(`demoman editor:`,e)}var eo=P.kits,I={state:`ready`,kits:[],defaultId:null,migrationPending:!1},to=null,no=null;function ro(e){let t=I;if(t.state!==`ready`)return null;let n=t.kits.filter(e=>e.read.state===`ready`),r=n.filter(t=>t.read.state===`ready`&&Ue(t.read.kit,e)),i=r.find(e=>e.id===to)??r.find(e=>e.id===t.defaultId)??r[0];if(i!==void 0)return to=i.id,{kit:i,edited:!1};let a=n.find(e=>e.id===to);return a===void 0?null:{kit:a,edited:!0}}var io=P.bundles,L=new URL(location.href).searchParams.get(`scene`)??``,R=e=>{let t=document.getElementById(e);if(!t)throw Error(`editor is missing #${e}`);return t},ao=null,oo=!1,z=xr({sceneId:L,loadScene:async e=>{let t=await P.scenes.get(e);if(t===null)throw Error(`no scene "${e}"`);return is??=t.notes,oo||=(ao=t.revision,!0),t.scene},saveScene:async e=>{ao=(await P.scenes.put(e,ao)).revision},bundles:{active:e=>io.active(e)},newId:()=>crypto.randomUUID()});function B(e){let t=z.snapshot().scene;return z.dispatch(e).catch(F).then(()=>so(t))}function so(e){if(zo===null)return;let t=z.snapshot();t.scene!==e&&t.error===null&&(zo=null,$(t))}var V=xt,co=null,H=null,lo=!1;function uo(e){e!==H&&(lo=!1),H=e}var U=null,fo=null,po=[],mo=null,ho=null,go=null,W=null,_o=null,G=`export`,K=!0,vo=`export`,yo=Yn(),bo=[`mp4`],xo=()=>bo[0]??`mp4`;function So(e,t=xo()){let n=z.snapshot().scene,r=To();return ve(t,n.canvas.aspect,e,Se({...n,branding:js(n)}),r===null?{}:{quality:r})}var Co=P.exportQuality===void 0?null:Ne,wo=null,To=()=>Co===null?null:wo??Co,Eo=!1,Do=null;function Oo(e){return Do?.scene!==e&&(Do={scene:e,digest:We(e)}),Do.digest}var ko=`fit`;function Ao(e){e!==null&&e.kind!==`piece`?(G!==`selection`&&(vo=G),G=`selection`,K=!0):G===`selection`&&(G=vo),W=e}var jo=null,Mo=null,No=0,q=null,Po=!0,Fo=!1,Io=``,Lo=!1,Ro=null,zo=null,Bo=[];function Vo(){return Bo.flatMap(e=>e.kind===`stored`?[e.output]:[])}var Ho=!1,Uo=new Set,J=Rn(u),Wo=null,Y=null,Go=R(`preview`),Ko=new OffscreenCanvas(J.width,J.height),qo=Ko.getContext(`2d`);function Jo(e){let t=So(e),n=mc(e,R(`stage-frame`).getBoundingClientRect().width),r=n.width!==J.width||n.height!==J.height;J=n,r&&(Ko=new OffscreenCanvas(J.width,J.height),qo=Ko.getContext(`2d`)),Wo=null;let i=R(`stage`);i.style.setProperty(`--frame-ratio`,`${t.width} / ${t.height}`),i.style.setProperty(`--frame-px`,String(Rn(t).width))}var Yo=150,Xo=null,Zo=!1,Qo=!1;document.addEventListener(`pointerdown`,()=>{Zo=!0},!0);var $o=()=>{Zo=!1,As?.patch.background!==void 0&&setTimeout(()=>{!Zo&&As?.patch.background!==void 0&&Ws()},0),Qo&&setTimeout(()=>{Qo&&!Zo&&$(z.snapshot())},0)};window.addEventListener(`pointerup`,$o,!0),window.addEventListener(`pointercancel`,$o,!0);var es=new ResizeObserver(()=>{let e=R(`stage`),t=R(`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`),al&&(Xo!==null&&clearTimeout(Xo),Xo=setTimeout(()=>{Xo=null;let e=mc(z.snapshot().bundle,R(`stage-frame`).getBoundingClientRect().width);(e.width!==J.width||e.height!==J.height)&&(Zo&&(As!==null||Os!==null)?(Ws(),Qo=!0):$(z.snapshot()))},Yo))});es.observe(R(`stage-frame`)),es.observe(R(`stage`));var ts=[],ns=null,rs=``,is=null,as=`The video shows the text that was recorded; re-record to type the new text.`;function os(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 ss=null,cs=null,ls=0,us=null,ds=Un(t=>t.motionSpans.length>0?l(t,io.load,{onSpanUnavailable:(e,t)=>console.info(`[demoman] preview: span ${e} could not be decoded (${t})`)}):Promise.resolve(e(t,io.load)));async function fs(e){let{bundle:t,scene:n}=e;if(t===null||kn(ns,e))return;ns=On({scene:n,bundle:t}),ts=[];let r=x(n).retiming.motionDiffThreshold,a=()=>{let e=z.snapshot();return e.scene===n&&e.bundle===t},o;try{o=await ds(t),ts=await i(t,o,r)}catch(e){F(e),a()&&z.setHoverReport(An),$(z.snapshot());return}try{let e=await tt(n,t,o,r);if(a()){let t=_(z.snapshot().scene);z.setHoverReport(Mn(e,t))}}catch(e){F(e),a()&&z.setHoverReport(An)}$(z.snapshot())}var ps=null,ms=null,hs=null,gs=null,_s=``,vs=null,ys=null,bs=null,xs=null,Ss=null,Cs=null,ws=null,Ts=null,Es=null,Ds=null,Os=null,ks=null,As=null;function js(e){let t=Te(As,e,F);return As=t.preview,t.branding}function Ms(e){As={patch:e,scene:z.snapshot().scene},Ws();let t=z.snapshot();Ps(t,So(t.bundle))}function Ns(e){co!==null&&(co=null,$(z.snapshot())),P.files.reveal(e).catch(e=>{let t=Jn(e);t.expected?console.info(`demoman editor: ${t.text}`):F(e),co=t.text,$(z.snapshot())})}function Ps(e,t){let n=Me({durationMs:fc-Z,fileType:xo(),target:t,hasFrames:Ec(e).kind!==`noFrames`}),r=R(`take-meta`);r.textContent=n,r.setAttribute(`aria-label`,`Video info: ${n}`)}var Fs=null;function Is(e){return Os===null?e.cursor:{...e.cursor,...Os}}function Ls(e){let t=e.motion??de;return ks===null?t:{...t,...ks}}var Rs=null,zs=null;function Bs(e){Os=e,Ws()}function Vs(e){ks=e,Ws()}function Hs(){ks!==null&&(ks=null,Ws())}function Us(){Os!==null&&(Os=null,Ws())}function Ws(){zs===null&&(zs=requestAnimationFrame(()=>{zs=null;let e=z.snapshot();Zs(e),Y&&(Fs=Is(e.scene),Rs=Ls(e.scene),us=Wo,Q.seek(Q.positionMs))}))}function Gs(){zs!==null&&cancelAnimationFrame(zs),zs=null,Os=null,ks=null}function Ks(e){return e===null?null:vs?.ref===e?vs.thumb:{kind:`loading`}}function qs(e){return e.kind===`image`&&Ds?.ref!==e.ref?{ref:e.ref,thumb:{kind:`loading`}}:Ds}function Js(e){if(Es=null,Ss===null)return null;let t=Zo&&As?.patch.background!==void 0;try{return De(t?Ce(Ss,J):Ss,e,J)}catch(e){return Es=`it could not be blurred: ${e instanceof Error?e.message:String(e)}`,null}}async function Ys(e){let t=js(e.scene).background;if(!me(t)){if(Cs===null&&ws===null)return;Ss=null,Cs=null,ws=null,Ts=null,$(z.snapshot());return}let n=ge(t,J),r=Cs?.key===n?Cs:null;if(r!==null&&(r.error!==null||Ss!==null&&Ve(J,r.natural).width<=Ss.width)){ws=null;return}if(ws===n)return;ws=n,r===null&&(Ts=null);let i=null,a=null;try{i=await He(t,J,P.wallpapers)}catch(e){a=e instanceof Error?e.message:String(e)}if(ws!==n){i!==null&&`close`in i.image.image&&i.image.image.close();return}if(ws=null,Ss=i?.image??null,Cs={key:n,natural:i?.natural??null,error:a},Ts=a,t.kind===`image`){let e=Ds,n;if(i===null)n={kind:`failed`,reason:a??``};else if(Ds?.ref===t.ref&&Ds.thumb?.kind===`ready`)n=Ds.thumb;else try{n={kind:`ready`,url:await he(i.image)}}catch(e){n={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(Ds!==e)n.kind===`ready`&&n!==e?.thumb&&URL.revokeObjectURL(n.url);else{let e=Ds?.thumb;e?.kind===`ready`&&e!==n&&URL.revokeObjectURL(e.url),Ds={ref:t.ref,thumb:n}}}$(z.snapshot())}async function Xs(e){let t=js(e.scene),n=t.logo?.ref??null;if(n!==ms&&(ms=n,hs=null,gs=null,ps=null,_s=``,n!==null)){let e=await P.logos.load(n);if(ms!==n)return;e.ok?hs=e.source:gs=e.error}let r=c(t,J),i=`${n}@${r}`;if(hs!==null&&r>0&&i!==_s){_s=i;try{let e=await hs.rasterAt(r);if(ms!==n||_s!==i)return;ps=e,gs=null}catch(e){ps=null,gs=e instanceof Error?e.message:String(e)}}let a=null;if(n!==null){if(hs!==null){try{a={kind:`ready`,url:await Pe(hs)}}catch(e){a={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(ms!==n)return}else a=gs===null?{kind:`loading`}:{kind:`failed`,reason:gs}}let o=JSON.stringify(a)!==JSON.stringify(vs?.thumb??null)||(vs?.ref??null)!==n;vs=n===null?null:{ref:n,thumb:a};let s=hs?pe(hs,c(t,So(e.bundle)),ke(xo(),e.scene.canvas.aspect)):null,l=[xs?.ref===n?xs.note:null,s].filter(e=>e!==null),u=o||ps!==ys||gs!==bs||l.join(`
|
|
3
|
-
`)!==po.join(`
|
|
4
|
-
`);po=l,ys=ps,bs=gs,u&&$(z.snapshot())}function Zs(e){Jo(e.bundle);let{scene:t,bundle:r}=e,i=Is(t),a=js(t),o=Wn(t,{cursor:i,branding:a,motion:ks===null?t.motion:Ls(t)}),s=r?n({plan:x(o),bundle:r,scene:o,target:J,detailTarget:So(r),hints:ts,logo:ps,wallpaper:Js(a.background)}):null;Y=s?.resolved??null,Wo=s?.presentation??null,Go.width!==J.width&&(Go.width=J.width),Go.height!==J.height&&(Go.height=J.height)}var Qs=[];function $s(e,t){let n=t.width*t.height/1e6;n<=0||(Qs.push(e/n),Qs.length>60&&Qs.splice(0,Qs.length-30))}var ec=null,tc=null,nc=2e3,rc=!1,X={requestedFrames:0,drawnFrames:0,elapsedMs:0,sourceLookupMs:0,composeMs:0,blitMs:0},ic=0,ac=null,oc=null,sc=0,cc=0;function lc(){X.requestedFrames=0,X.drawnFrames=0,X.elapsedMs=0,X.sourceLookupMs=0,X.composeMs=0,X.blitMs=0,sc=0,cc=0,ic=performance.now()}function uc(){if(Q.playing===rc)return;if(rc=Q.playing,$(z.snapshot()),rc){ac={width:J.width,height:J.height},lc();return}X.elapsedMs=performance.now()-ic;let e=(z.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(Bn({...X,...e===null?{}:{sourceFrame:e},...ac===null?{}:{bitmap:ac},parkedHeight:J.height,msPerMegapixel:oc,...cc>0?{decodeMs:sc}:{}}))}var dc=Vn({schedule:e=>requestAnimationFrame(e),onDrawFailed:e=>{uo(e instanceof Error?e.message:String(e)),Q.pause(),$(z.snapshot())},onDrawRecovered:()=>{H!==null&&(H=null,$(z.snapshot()))},draw:async e=>{let t=z.snapshot(),n={resolved:Y,presentation:Wo,target:J,offscreen:Ko,offscreenCtx:qo};if(!n.resolved||!n.presentation||!t.bundle)return;let r=performance.now(),i=await ds(t.bundle),a=performance.now();rc&&i.warm?.(ee(n.resolved.timeline,e),ee(n.resolved.timeline,e+nc));let o=0;await S({resolved:n.resolved,target:n.target,presentation:n.presentation,frames:i,ctx:n.offscreenCtx,outputTimeMs:e,onStage:(e,t)=>{e===`fetch`&&(o=t,rc&&(sc+=t,cc+=1))}});let s=performance.now();if(n.offscreen===Ko){if($s(s-a-o,n.target),Go.getContext(`2d`)?.drawImage(Ko,0,0),Q.playing&&tc!==null&&(tc+=1,tc>=15)){let e=Qs.slice(-tc),t=ec;ec=null,ec=mc(z.snapshot().bundle,R(`stage-frame`).getBoundingClientRect().width,e).height,tc=null,ec!==t&&($(z.snapshot()),ac={width:J.width,height:J.height})}jo&&(W?.kind===`mask`||W?.kind===`zoom`)&&zr(R(`stage-overlay`),{canvas:Go,selection:W,model:jo,resolved:n.resolved,presentation:n.presentation,target:n.target,outputTimeMs:e},{onMaskRect:(e,t)=>B({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>B({kind:`setZoomTarget`,id:e,point:t})}),rc&&(X.drawnFrames+=1,X.sourceLookupMs+=a-r,X.composeMs+=s-a,X.blitMs+=performance.now()-s)}}}),Z=0,fc=0,pc=!1,Q=Hn({seek:e=>{rc&&(X.requestedFrames+=1),dc.seek(e)},durationMs:()=>pc?fc:0,startMs:()=>Z,looping:()=>Fo,now:()=>performance.now(),schedule:e=>requestAnimationFrame(e),onChange:()=>{uc(),vc()}});function mc(e,t,n=Qs){let r=So(e),i=()=>Ln({target:r,paintedCssWidth:t,devicePixelRatio:window.devicePixelRatio,playing:Q.playing,msPerMegapixel:In(n)});return Q.playing?(ec===null&&(ec=i(),oc=In(n),tc=0),Rn(r,ec)):(ec=null,Rn(r,i()))}function hc(e){e!==z.snapshot().scene.canvas.aspect&&B({kind:`setAspect`,aspect:e}).then(()=>Q.seek(Q.positionMs))}function gc(e){if(e===To())return;let t=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-export-quality`);wo=e,$(z.snapshot()),t&&document.querySelector(`[data-export-quality="${e}"]`)?.focus()}function _c(e,t){if(bo.includes(e)===t)return;let n=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-file-type`);bo=Oe.filter(n=>n===e?t:bo.includes(n)),$(z.snapshot()),n&&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`&&(W?.kind===`mask`||W?.kind===`zoom`)&&Q.seek(Q.positionMs)});function vc(){ia(R(`transport`),{authored:pt(z.snapshot().scene),rerunLine:jt(Dc(z.snapshot())),playing:Q.playing,enabled:pc&&fc>Z,rate:Q.rate,looping:Fo},{onToggle:yc,onSkipToStart:()=>nl({kind:`seekEdge`,edge:`head`},z.snapshot()),onLooping:e=>{Fo=e,vc()},onShuttle:e=>{H=null,Q.shuttle(e)}});for(let[e,t]of[[R(`stage-tools`),R(`toolbar-clock`)],[R(`stage-bar`),R(`stage-bar`)]])aa(e,{authored:pt(z.snapshot().scene),rerunLine:jt(Dc(z.snapshot())),positionMs:Q.positionMs-Z,durationMs:fc-Z,aspect:z.snapshot().scene.canvas.aspect,enabled:pc&&fc>Z,fullscreen:!!document.fullscreenElement,error:lo?null:H,zoom:ko},{onAspect:hc,onFullscreen:xc,onZoom:bc,onDismissError:()=>{lo=!0,vc()}},t);let e=R(`timeline`).querySelector(`[data-playhead]`);e&&q&&(e.style.left=`${(va(q,Q.positionMs)*100).toFixed(4)}%`)}function yc(){H=null,Q.toggle(),$(z.snapshot())}function bc(){ko=ko===`fit`?`actual`:`fit`,document.body.dataset.zoom=ko,vc()}function xc(){H=null;let e=!document.fullscreenElement;(e?R(`stage`).requestFullscreen():document.exitFullscreen()).catch(t=>{uo(`The preview could not ${e?`go full screen`:`exit full screen`}: ${t instanceof Error?t.message:String(t)}`),$(z.snapshot())})}document.addEventListener(`fullscreenchange`,()=>{let e=document.activeElement;H=null,vc();let t=!!document.fullscreenElement;R(`stage`).toggleAttribute(`data-fullscreen`,t);let n=R(t?`stage-tools`:`stage-bar`),r=R(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 Sc(){let e=z.snapshot();Cc(Rt(e.scene,e.bundle,Y?.timeline??null,Q.positionMs))}function Cc(e){if(e!==null){if(cn(e)){zo=e.reason,$(z.snapshot());return}B(e)}}function wc(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);B(e).then(()=>{let r=z.snapshot();n(r.scene)||W?.kind===t&&W.id===e.id&&(Ao(null),$(r))})}function Tc(e){if(F(e),mo=e instanceof Error?e.message:String(e),al){$(z.snapshot());return}wi(R(`failure`),{error:null,replaySentence:null,captureSentence:null,openError:mo})}function Ec(e){return e.bundle===null?{kind:`noFrames`}:{kind:`exact`}}function Dc(e){let t=pt(e.scene);return{takeId:L,authored:t,rerun:P.nav.rerun(L,t)}}function Oc(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){Qo=!1,Gs(),Zs(e);let t=Oc(Y);t!==ss&&(ss=t,console.info(t));let n=Br({scene:e.scene,bundle:e.bundle,resolved:Y}),r=R(`name`);r.value=e.scene.meta.name,r.placeholder=Ke(e.scene.meta),R(`undo`).disabled=!e.canUndo,R(`redo`).disabled=!e.canRedo,xi(R(`banner`),{hasFrames:e.bundle!==null,route:Dc(e)}),U!==null&&e.scene!==fo&&(U=null),wi(R(`failure`),{error:e.error??U,replaySentence:e.replaySentence,replayRecoverable:e.replayRecoverable,captureSentence:e.captureSentence,renderError:V.error,previewError:H,logoLoadError:gs,wallpaperLoadError:Ts??Es,openError:mo,deleteError:ho,navigationError:go,runsRoute:Dc(e)});let i=Xt({scene:e.scene,view:n,bundle:e.bundle,resolved:Y,hoverReport:e.hoverReport,rerunLine:jt(Dc(e))});jo=i,Mo=n,No=i.durationMs,(q===null||Ro!==i.durationMs)&&(q=Hr(i.durationMs),Ro=i.durationMs);let a={resolved:Y,bundle:e.bundle,viewport:e.scene.meta.capture.viewport},o=e=>Cc(Tn(i,n,e,a)),s=e=>{q=e,$(z.snapshot())},c=e=>{Po=e,$(z.snapshot())};qa(R(`timeline`),i,{viewport:q,selection:W,get positionMs(){return Q.positionMs},refusal:zo,hoverReport:e.hoverReport,snapping:Po,openJoin:_o},{onSelect:e=>{Ao(e),$(z.snapshot())},onSeek:e=>Q.seek(e),onSeekStart:()=>Q.pause(),onSplit:Sc,onRestorePiece:e=>{_o=null,B({kind:`restorePiece`,id:e})},onOpenJoin:e=>{_o=e,$(z.snapshot())},onGesture:o,onViewport:s,onSnapping:c}),bi(R(`take-notes`),{notices:[...is??[],...os(e)?[as]:[],...i.notices],hoverReport:e.hoverReport}),$a(R(`timeline-tools`),i,{viewport:q,snapping:Po,get positionMs(){return Q.positionMs}},{onGesture:o,onSplit:Sc,onViewport:s,onSnapping:c});let l=W;l?.kind===`piece`&&!i.clip.pieces.some(e=>zt(e.start,l.start))&&(W=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);G===`selection`&&!u&&(W===null&&F(Error(`the rail was on Selection with nothing selected`)),Ao(null)),document.body.dataset.panel=K?`open`:`closed`,di(R(`rail`),{rail:G,panelOpen:K,hasSelection:u},{onPick:rl}),fi(R(`export-open`),{rail:G,panelOpen:K},{onPick:rl}),pi(R(`shortcuts-open`),{rail:G,panelOpen:K},{onPick:rl});let d=document.activeElement?.matches(`[data-shortcuts-search]`)===!0;ci(R(`inspector`),{selection:W,view:n,model:i,scene:e.scene,hoverReport:e.hoverReport,viewport:e.scene.meta.capture.viewport,rail:G,sections:yo,attachedToCuts:Y?.plan.attachedToCuts??[]},{onClose:il,onGap:(e,t)=>Cc(En(n,e,t)),onGapClear:e=>B({kind:`clearGap`,afterActionId:e}),onKeepHover:kc,onZoomOnStep:e=>{let t=n.beats.find(t=>t.actionId===e);if(!t?.anchorId)return;let r=new Set(z.snapshot().scene.camera.map(e=>e.id));B({kind:`addZoom`,marker:{actionId:e,offsetMs:0},target:{kind:`element`,anchorId:t.anchorId},scale:w.defaultZoomScale}).then(()=>{let e=z.snapshot().scene.camera.find(e=>!r.has(e.id));e&&(Ao({kind:`zoom`,id:e.id}),$(z.snapshot()))})},onZoomScale:(e,t)=>B({kind:`setZoomScale`,id:e,scale:t}),onRemoveZoom:e=>wc({kind:`removeZoom`,id:e}),onMaskNote:(e,t)=>B({kind:`setMaskNote`,id:e,note:t}),onRemoveMask:e=>wc({kind:`removeMask`,id:e})});let f=document.querySelector(`#inspector [data-panel-shortcuts]`);f!==null&&da(f,{mac:jr(navigator.userAgent),query:Io,focus:K&&(Lo||d)},{onClose:il,onQuery:e=>{Io=e}}),Lo=!1,zr(R(`stage-overlay`),{canvas:Go,selection:W,model:i,resolved:Y,presentation:Wo,target:J,outputTimeMs:Q.positionMs},{onMaskRect:(e,t)=>B({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>B({kind:`setZoomTarget`,id:e,point:t})});let p=R(`inspector`);p.querySelector(`.inspector`)===null&&F(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&&G===m[e]&&K&&F(Error(`the inspector's ${e} panel is missing`)),t},g=h(`branding`);g&&Ti(g,{branding:e.scene.branding,logoThumb:Ks(e.scene.branding.logo?.ref??null),logoPlacement:Wo?.logoPlacement??null,formatTitle:ke(xo(),e.scene.canvas.aspect),logoNotes:po,wallpaper:{thumbUrl:xe,custom:qs(e.scene.branding.background),loadError:null},kit:{read:I,standing:ro(e.scene.branding),naming:no,onApply:e=>{let t=I.state===`ready`?I.kits.find(t=>t.id===e):void 0;if(t?.read.state!==`ready`){U=t===void 0?`That brand kit was not applied: it was deleted in another tab.`:`That brand kit was not applied: ${t.read.reason}.`,fo=z.snapshot().scene,$(z.snapshot());return}to=e;let{background:n,logo:r,padding:i}=t.read.kit;B({kind:`setBranding`,patch:{background:n,logo:r,padding:i}}),$(z.snapshot())},onUpdate:()=>void Mc(),onStartNew:()=>{no={text:``,error:null},$(z.snapshot())},onNameInput:e=>{no!==null&&(no={text:e,error:null})},onConfirmNew:e=>void Nc(e),onCancelNew:()=>{no=null,$(z.snapshot())}}},{onCommit:e=>B({kind:`setBranding`,patch:e}),onPreview:Ms,onLogoFile:e=>Ac(e).catch(F),onWallpaperFile:e=>jc(e).catch(F)});let _=h(`cursor`);_&&Ri(_,Is(e.scene),Ls(e.scene),{onCursor:e=>{Gs(),B({kind:`setCursor`,patch:e})},onCursorPreview:Bs,onCursorPreviewEnd:Us,onMotion:e=>{Gs(),B({kind:`setMotion`,patch:e})},onMotionPreview:Vs,onMotionPreviewEnd:Hs},e.scene.meta.capture.device?.touch===!0);let v=So(e.bundle),y=h(`export`);y&&Gi(y,{outputs:Bo,fileTypes:bo,files:V.files,quality:To(),aspect:e.scene.canvas.aspect,targets:{mp4:So(e.bundle,`mp4`),gif:So(e.bundle,`gif`),stills:So(e.bundle,`stills`)},recording:_e(e.bundle,Se(e.scene)),durationMs:i.clip.trim.tailMs-i.clip.trim.headMs,run:V.run,save:V.save,revealError:co,readiness:Ec(e),runsRoute:Dc(e),currentDigest:Oo(e.scene),sections:yo,beatAt:bt(n.beats),hasReclaimedMotion:e.bundle?.degradations.some(e=>e.kind===`motionReclaimed`)??!1},{onExport:()=>Pc().catch(F),onFileType:_c,onRetry:e=>Pc([e]).catch(F),onQuality:gc,onSaveAgain:e=>Fc(e).catch(F),onReveal:Ns}),pc=n.hasBundle,Z=i.clip.trim.headMs,fc=i.clip.trim.tailMs,Ps(e,v),ha(R(`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:_e(e.bundle,Se(e.scene)),target:v,aspect:e.scene.canvas.aspect,takeId:L,rerun:Dc(e).rerun,revealError:co,history:{outputs:Bo,currentDigest:Oo(e.scene),showAll:Ho,warningsOpen:Uo,reportContext:{beatAt:bt(n.beats),runsRoute:Dc(e)}}},{onCopy:e=>navigator.clipboard.writeText(e),onDownload:e=>Fc([e]).catch(F),onReveal:Ns,onShowAll:()=>{Ho=!0,$(z.snapshot())},onWarnings:e=>{Uo.delete(e)||Uo.add(e),$(z.snapshot()),document.querySelector(`#take-info [data-output-warnings="${CSS.escape(e)}"]`)?.focus()}}),Q.positionMs<Z&&Q.seek(Z),Q.positionMs>fc&&Q.seek(fc),vc();let b=Is(e.scene),x=Ls(e.scene),S=JSON.stringify(e.scene.edits.removed??[]);Y&&Wo&&(e.bundle!==cs||J.height!==ls||Gn(Fs,b)||Kn(Rs,x)||qn(us,Wo)||S!==rs)&&(cs=e.bundle,Fs=b,Rs=x,us=Wo,ls=J.height,rs=S,Q.seek(Q.positionMs)),Xs(e).catch(F),Ys(e).catch(F)}function kc(e){let t=z.snapshot().hoverReport;if(t===null){F(Error(`kept hover "${e}" with no hover report`));return}z.setHoverReport({...t,removable:t.removable.filter(t=>t!==e)})}async function Ac(e){U=null;let t=fe(e),n=e=>{U=e,fo=z.snapshot().scene,$(z.snapshot())};if(!t.ok)return n(t.reason);let r=new Uint8Array(await e.arrayBuffer());try{await p(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 P.logos.put(e);xs=t.note===null?null:{ref:i,note:t.note};let a=z.snapshot().scene.branding.logo,o=a?{corner:a.corner,size:a.size,opacity:a.opacity}:d;await z.dispatch({kind:`setBranding`,patch:{logo:{ref:i,...o}}})}async function jc(e){U=null;let t;try{({ref:t}=await P.wallpapers.put(e))}catch(e){U=e instanceof Error?e.message:String(e),fo=z.snapshot().scene,$(z.snapshot());return}await z.dispatch({kind:`setBranding`,patch:{background:we(t,z.snapshot().scene.branding.background)}})}async function Mc(){let e=ro(z.snapshot().scene.branding);if(e===null||!e.edited){U=e===null?`No brand kit was updated: this video is no longer on a kit.`:`No brand kit was updated: this video already matches "${e.kit.name}".`,fo=z.snapshot().scene,$(z.snapshot());return}let t=e.kit,n=`This video's background, logo and padding will replace the brand kit "${t.name}".`;try{if(!await ie({glyph:`refresh`,title:`Replace "${t.name}"`,body:n,confirmLabel:`Replace`,danger:!1,focus:`confirm`}))return;let e=z.snapshot().scene.branding,r=await eo.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);I=await eo.read()}catch(e){U=`The brand kit "${t.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,fo=z.snapshot().scene}$(z.snapshot())}async function Nc(e){let t=I.state===`ready`?I.kits:[],n=re(e,t,null);if(!n.ok){no={text:e,error:n.reason},$(z.snapshot());return}let r=z.snapshot().scene.branding,i=te();try{let t=await eo.update(e=>{let t=re(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){no={text:e,error:t},$(z.snapshot());return}no=null,to=i,I=await eo.read()}catch(e){U=`The brand kit "${n.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,fo=z.snapshot().scene}$(z.snapshot())}async function Pc(e=bo){co=null;let t=z.snapshot().scene;V=St(e),$(z.snapshot());let n=0;try{await z.settled();let r=To();for(let i of e)await P.exports.start(L,{fileType:i,aspect:t.canvas.aspect,revision:ao,...r===null||i!==`mp4`||wo===null&&!Eo?{}:{quality:r}}),n+=1}catch(e){let t=e instanceof Error?e.message:String(e),r=V.files.map((e,t)=>t>=n&&e.ended===null?{...e,ended:`failed`}:e);throw V={...V,files:r,run:Ct(r)===null?{phase:`idle`}:V.run,error:V.error===null?t:`${V.error}; ${t}`},$(z.snapshot()),e}}async function Fc(e){let t=Vo(),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=P.downloads;if(i===void 0)throw Error(`this page cannot save an export again`);V={...V,save:await i.save(n)},$(z.snapshot())}var Ic=!1;function Lc(){let e=document.querySelector(`[data-panel-export]`);e!==null&&!Vi(e,V.run,bo,Ec(z.snapshot()),V.files)&&!Ic&&(Ic=!0,F(Error(`the Export panel has no start button, so progress cannot show`)))}function Rc(e){let t=Ot(V,e);switch(V=t.flow,t.effect){case`render`:$(z.snapshot());return;case`progress`:Lc();return;case`relist`:P.outputs.list(L).then(e=>{Bo=e,$(z.snapshot())}).catch(F);return;case`none`:return}}P.exports.onEvent(Rc),P.nav.onOpen?.(e=>Gc(()=>location.assign(e))),R(`name`).addEventListener(`change`,e=>{B({kind:`rename`,name:e.target.value.trim()})});var zc=e=>()=>{let t=z.snapshot().scene;e().catch(F).then(()=>so(t))};R(`undo`).addEventListener(`click`,zc(()=>z.undo())),R(`redo`).addEventListener(`click`,zc(()=>z.redo()));var Bc={recording:`a video is being recorded`,rendering:`a render is running`,sharing:`a share is in progress`,replaying:`a video is being run in Runs`};function Vc(e){ho=e,Hc()}function Hc(){if(al){$(z.snapshot());return}wi(R(`failure`),{error:null,replaySentence:null,captureSentence:null,deleteError:ho,navigationError:go})}function Uc(e,t,n=``){go=null;try{location.assign(t())}catch(t){F(t),go={page:e,reason:`${n}${t instanceof Error?t.message:String(t)}`},Hc()}}function Wc(e=``,t=null,n=null){let r=P.nav.library(),i=n===null||n===``?r:`${r}${r.includes(`?`)?`&`:`?`}from=${encodeURIComponent(n)}`;Uc(`Flows page`,()=>qe(i,t),e)}function Gc(e){(async()=>{let t=null,n=z.subscribe(e=>{t=e});try{await z.settled()}finally{n()}t?.error??e()})()}R(`back`).addEventListener(`click`,()=>{Gc(()=>Wc(``,null,L))});function Kc(e){let t=qc(e);t&&(e.preventDefault(),Gc(()=>Uc(`Runs page`,()=>t.href)))}R(`banner`).addEventListener(`click`,Kc),R(`inspector`).addEventListener(`click`,Kc),R(`take-info`).addEventListener(`click`,Kc),R(`failure`).addEventListener(`click`,Kc),R(`take-info`).addEventListener(`toggle`,e=>{R(`take-meta`).setAttribute(`aria-expanded`,String(e.newState===`open`))});function qc(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 Jc=null;document.addEventListener(`mousedown`,e=>{let t=qc(e);Jc=t?{link:t,href:t.href}:null},!0),document.addEventListener(`mouseup`,e=>{let t=Jc;if(Jc=null,!t)return;let n=qc(e);!n||n===t.link||n.href===t.href&&Gc(()=>Uc(`Runs page`,()=>n.href))},!0),R(`delete`).addEventListener(`click`,()=>{(async()=>{try{if(!await ie(se))return}catch(e){F(e),Vc(`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`);return}ho=null;let e;try{e=await P.scenes.remove(L)}catch(e){F(e),Vc(`Not deleted: ${e instanceof Error?e.message:String(e)}.`);return}if(!e.ok){Vc(`Not deleted: ${Bc[e.error]??e.detail??e.error}.`);return}if(e.result!==void 0&&!e.result.ok){let t=e.result.steps.find(e=>!e.ok);Vc(`Partly deleted: ${t?.step??`a step`} could not be removed — ${t?.error??`unknown error`}. Open Flows to retry.`);return}let t=e.note??null;Wc(t===null?`This video was deleted. `:`This video was deleted. ${t} `,t===null?Ye:`This video was deleted. ${t}`)})()});var Yc=Symbol.for(`demoman.editor.keydown`),Xc=globalThis,Zc=Xc[Yc];Zc instanceof AbortController&&Zc.abort();var Qc=new AbortController;Xc[Yc]=Qc;var $c=!1,el=null;document.addEventListener(`pointerdown`,()=>{$c=!0},{capture:!0,signal:Qc.signal}),document.addEventListener(`pointerdown`,()=>{_o!==null&&(_o=null,$(z.snapshot()))},{signal:Qc.signal}),document.addEventListener(`keydown`,()=>{$c=!1},{capture:!0,signal:Qc.signal}),document.addEventListener(`focusin`,e=>{el=$c?e.target:null},{signal:Qc.signal});var tl=new WeakMap;document.addEventListener(`focusin`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&tl.set(t,t.value)},{signal:Qc.signal}),document.addEventListener(`change`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&tl.set(t,t.value)},{capture:!0,signal:Qc.signal}),document.addEventListener(`keydown`,e=>{if(document.querySelector(`dialog[open]`)!==null)return;if(e.key===`Escape`&&_o!==null){e.preventDefault(),_o=null,$(z.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=tl.get(t);e!==void 0&&t.value!==e&&(t.value=e)}t?.blur()}return}let r=e.key===`Enter`||e.key===` `&&t!==el;if((n===`BUTTON`||n===`A`)&&r&&t?.hasAttribute(`data-tick`)!==!0)return;let i=z.snapshot(),a=Cr(e,{hasSelection:W!==null,selectionIsBeat:W?.kind===`tick`,canUndo:i.canUndo,canRedo:i.canRedo,panelOpen:K,hasTimeline:q!==null&&No>0});a!==null&&(e.preventDefault(),nl(a,i))},{signal:Qc.signal});function nl(e,t){switch(e.kind){case`playPause`:yc();return;case`shuttle`:H=null,Q.shuttle(e.direction);return;case`stop`:Q.stop();return;case`nudge`:Q.seek(Q.positionMs+e.deltaMs);return;case`seekEdge`:Q.seek(e.edge===`head`?Z:fc);return;case`stepBeat`:{let n=t.scene.actions.map(e=>e.id),r=W?.kind===`tick`?n.indexOf(W.actionId):-1,i=n[r===-1?e.delta>0?0:n.length-1:r+e.delta];if(i===void 0)return;Ao({kind:`tick`,actionId:i}),$(t);return}case`setTrim`:{let n=jo,r=Mo;if(n===null||r===null||Y===null||!pc){let e=Dc(t);zo=`This video has not been rendered yet, so there is nothing to trim to. ${Mt(e.authored,jt(e),`first`)}`,$(t);return}Cc(Tn(n,r,{kind:`trim`,edge:e.edge,toMs:Q.positionMs,snapMs:0},{resolved:Y,bundle:t.bundle,viewport:t.scene.meta.capture.viewport}));return}case`split`:Sc();return;case`undo`:zc(()=>z.undo())();return;case`redo`:zc(()=>z.redo())();return;case`deleteSelection`:if(W===null)return;if(W.kind===`zoom`){wc({kind:`removeZoom`,id:W.id});return}if(W.kind===`mask`){wc({kind:`removeMask`,id:W.id});return}if(W.kind===`piece`){Cc(Bt(jo?.clip.pieces??[],W.start,jo?.clip.trim));return}Cc({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(q===null)return;let n=Math.min(1,Math.max(0,M(q,Q.positionMs)));q=Gr(q,No,e.factor,n),$(t);return}case`zoomFit`:q=Hr(No),$(t);return;case`toggleSnapping`:Po=!Po,$(t);return;case`clearSelection`:Ao(null),$(t);return;case`toggleHelp`:rl(`shortcuts`);return;case`closePanel`:il();return}}function rl(e){G===e&&K?K=!1:(G=e,K=!0,e===`shortcuts`&&(Lo=!0)),e!==`selection`&&(vo=e),$(z.snapshot())}function il(){K=!1,$(z.snapshot())}sa(),ei(),document.body.dataset.zoom=`fit`;{let e=R(`notes`),t=``,n=()=>{la(R(`notes-open`),e),t=ua(e,t)};new MutationObserver(n).observe(e,{childList:!0,subtree:!0,characterData:!0}),n()}var al=!1;z.subscribe(e=>{al=!0,mo=null,$(e)}),z.subscribe(e=>fs(e).catch(F));async function ol(){I=await eo.read(),al&&$(z.snapshot())}ol().catch(F),eo.onChange===void 0?console.info(`demoman: no storage change feed here, so the brand kit is read once`):eo.onChange(()=>{ol().catch(F)});async function sl(){let e=P.exportQuality;if(e===void 0)return;let t=await e.read();Eo=t.unreadable===void 0,t.unreadable!==void 0&&console.info(`demoman editor: the Studio exports at ${ye[t.quality]} quality: ${t.unreadable}`),t.quality!==Co&&(Co=t.quality,al&&$(z.snapshot()))}P.exportQuality!==void 0&&(sl().catch(F),window.addEventListener(`focus`,()=>{sl().catch(F)})),P.outputs.list(L).then(e=>{Bo=e,al&&$(z.snapshot())}).catch(F),z.load().catch(Tc);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,d as r,f as i,g as a,i as o,l as s,n as c,o as l,r as u,s as d,t as f,u as p,v as m}from"./confirm-dialog-F4BR4FU0.js";import{_ as h,a as g,c as _,d as v,i as y,l as b,m as x,n as S,o as C,r as w,t as T,u as E}from"./state-eyG4SxVq.js";import{n as D,r as O,t as k}from"./topbar-CgsXzkpk.js";var A=new Set([`a`,`an`,`the`,`and`,`in`,`on`,`of`,`for`,`by`,`to`,`with`]),j=e=>e.length>3&&e.endsWith(`s`)&&!e.endsWith(`ss`)?e.slice(0,-1):e;function M(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(e=>e&&!A.has(e)).map(j)}function ee(e,t){let n=e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean),r=t&&n.length>0&&/[\p{L}\p{N}]$/u.test(e)?n.pop():null;return{words:n.flatMap(M),prefix:r===null?null:j(r)}}function N(e,t=!1){let{words:n,prefix:r}=ee(e,t);return n.length>0||r!==null}function P(e,t,n){let{words:r,prefix:i}=ee(e,t),a=[...new Set(n.flatMap(M))],o=new Set(r.filter(e=>a.includes(e)));return i!==null&&a.some(e=>e.startsWith(i))&&o.add(i),o}var te=e=>[e.name,...e.pages,...e.steps];function ne(e,t,n=!1){return P(e,n,te(t)).size}function re(e,t,n=!1){if(P(e,n,[t.name]).size>0)return null;let r=t.steps.find(t=>P(e,n,[t]).size>0);if(r!==void 0)return{step:r};let i=t.pages.find(t=>P(e,n,[t]).size>0);return i===void 0?null:{page:i}}function ie(e,t,n=!1){for(let r of t.matchAll(/[\p{L}\p{N}]+/gu))if(P(e,n,[r[0]]).size>0)return r.index;return-1}function ae(){let e=new Map,t=new Map,n=new WeakMap,r=e=>{let t=n.get(e);return t===void 0&&(t=h(e),n.set(e,t)),`${e.meta.id}:${t}`};return{get:t=>e.get(r(t)),measure(n,i){let a=r(n),o=e.get(a);if(o!==void 0)return Promise.resolve(o);let s=t.get(a);return s===void 0&&(s=i().then(n=>(e.set(a,n),t.delete(a),n),e=>{throw t.delete(a),e}),t.set(a,s)),s}}}function oe(e,t){t!==void 0&&(t instanceof Error?(e.textContent=`—`,e.title=t.message):t.kind===`nothing`?(e.textContent=`—`,e.title=t.reason):(e.textContent=s(t.ms),e.removeAttribute(`title`)))}function se(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 ce(e){return e===null?{kind:`noBundle`}:e.keyframes.length===0?{kind:`noKeyframes`}:{kind:`ready`,frames:se(e.keyframes,8)}}function le(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 video has no keyframes.`;case`failed`:return`Preview unavailable — ${e.reason}`}}function ue(e,t){return t<=1?0:(e+1)%t}function de(e,t){let n=e.querySelector(`[data-preview-canvas]`),r=e.querySelector(`[data-preview-note]`),i=le(t);n!==null&&(n.hidden=i!==null),r!==null&&(r.textContent=i??``)}function fe(e){let t=[],n=!1;function r(r,i){let a=i.querySelector(`[data-preview-canvas]`);if(a===null){console.error(`demoman library: preview box for ${r} has no canvas to paint into`),de(i,{kind:`failed`,reason:`this row has no canvas to paint into`});return}let o=[],c=[],l=0,u=null,d=()=>{u!==null&&(clearInterval(u),u=null)};t.push(d);let f=(e,t)=>{d(),console.error(`demoman library: ${e} for ${r} —`,t),de(i,{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=o[t];if(r===void 0)throw Error(`preview frame ${t} is past the end of the video`);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);n||(a.width=t.width,a.height=t.height,a.style.setProperty(`--thumb-ratio`,String(t.width/t.height)),a.getContext(`2d`)?.drawImage(t,0,0))},h=()=>{l=ue(l,o.length),m(l).catch(e=>f(`drawing a keyframe`,e))},g=()=>{u!==null||o.length<=1||(u=setInterval(h,400))},_=()=>{d(),l=0,m(0).catch(e=>f(`drawing the first keyframe`,e))},v=()=>{let e=i.closest(`article`);if(e===null){console.error(`demoman library: preview box for ${r} has no row to hover`);return}e.addEventListener(`mouseenter`,g),e.addEventListener(`mouseleave`,_),e.addEventListener(`focusin`,g),e.addEventListener(`focusout`,_),t.push(()=>{e.removeEventListener(`mouseenter`,g),e.removeEventListener(`mouseleave`,_),e.removeEventListener(`focusin`,g),e.removeEventListener(`focusout`,_)})},y=t=>{let a=i.querySelector(`[data-duration]`);if(a===null){console.error(`demoman library: preview box for ${r} has no duration badge`);return}e.length(r,t).then(e=>{if(!n){if(e.kind===`nothing`){console.info(`demoman library: no length on ${r}'s card — ${e.reason}`);return}a.textContent=s(e.ms),a.title=`Length of the exported video`,a.hidden=!1}}).catch(e=>{console.warn(`demoman library: could not work out ${r}'s length —`,e)})},b=async()=>{let t;try{t=await e.bundle(r)}catch(e){f(`reading the frame bundle`,e);return}if(n)return;let a=ce(t);if(a.kind!==`ready`){de(i,a);return}o=a.frames;try{await m(0)}catch(e){f(`drawing the first keyframe`,e);return}n||(de(i,a),v(),t!==null&&y(t))};t.push(e.whenVisible(i,()=>{b()}))}return{mount:r,dispose(){n=!0;for(let e of t)e();t.length=0}}}function F(e){let t=e.group?.video;return t===void 0?null:t.addedTo===null?`key`in t.repo?t.repo.key:null:t.addedTo}var pe=e=>e.replace(/^local:/,``).split(`/`).filter(e=>e!==``&&e!==`.git`),me=e=>e.startsWith(`local:`);function he(e,t){let n=pe(e),r=n.at(-1)??e;if(me(e))return{owner:t.some(t=>t!==e&&me(t)&&pe(t).at(-1)===r)?n.at(-2)??null:null,name:r,local:!0};let i=e=>{let t=pe(e);return t.length>2?t.slice(1,-1).join(`/`):t[0]??e},a=i(e);return{owner:t.some(e=>!me(e)&&i(e)===a&&pe(e).at(-1)===r&&pe(e)[0]!==n[0])?`${n[0]}/${a}`:a,name:r,local:!1}}var ge=e=>e.owner===null?e.name:`${e.owner}/${e.name}`;function _e(e,t,n){let r=new Map,i=0;for(let t of e){let e=F(t);e===null?i+=1:r.set(e,(r.get(e)??0)+1)}typeof n==`object`&&!r.has(n.project)&&r.set(n.project,0);let a=[...r.keys()],o=a.map(e=>({key:e,...he(e,a),count:r.get(e)})).sort((e,t)=>Number(e.local)-Number(t.local)||ge(e).localeCompare(ge(t)));return{all:e.length,projects:o,none:i,unreadable:t}}var ve=(e,t)=>t===`all`?!0:t===`unreadable`?!1:t===`none`?F(e)===null:F(e)===t.project,ye=e=>e.row.kept!=null,be=(e,t)=>t===`all`||t===`inRepo`===ye(e);function xe(e,t,n){let r=y(e).filter(e=>ve(e,t)&&be(e,n)),i=new Set(r.flatMap(e=>e.group?[e.group]:[])),a=new Set;for(let e of r)if(e.group===null)a.add(e.row.sceneId);else for(let t of e.group.versions)a.add(t.sceneId);return{...e,rows:e.rows.filter(e=>a.has(e.sceneId)),groups:e.groups?.filter(e=>i.has(e))}}function Se(e,t){let n=e.filter(e=>ve(e,t)),r=n.filter(ye).length;return{inRepo:r,notInRepo:n.length-r,all:n.length}}function Ce(e,t){return t===`unreadable`?!1:t!==`none`||e.some(e=>ve(e,t)&&ye(e))}var we=e=>!/\s$/u.test(e),Te=e=>N(e,we(e));function Ee(e){let t=e.group?.video;return t===void 0?{name:e.row.label,pages:[],steps:[]}:{name:t.name||e.row.label,pages:t.pages,steps:t.steps}}var De=(e,t)=>ne(t,Ee(e),we(t));function Oe(e,t){let n=we(t),r=re(t,Ee(e),n);if(r===null)return null;let[i,a]=`step`in r?[`step`,r.step]:[`page`,b(r.page)||`/`],o=`${i}: ${a}`,s=ie(t,a,n),c=i===`page`?a.lastIndexOf(`/`,s):s;return c>0&&o.length>12?{text:`${i}: …${a.slice(c)}`,full:o}:{text:o,full:o}}function ke(e,t){if(!Te(t))return e;let n=y(e).filter(e=>De(e,t)>0),r=new Set(n.flatMap(e=>e.group?[e.group]:[])),i=new Set;for(let e of n)if(e.group===null)i.add(e.row.sceneId);else for(let t of e.group.versions)i.add(t.sceneId);return{...e,rows:e.rows.filter(e=>i.has(e.sceneId)),groups:e.groups?.filter(e=>r.has(e))}}function Ae(e,t,n,r){if(t===`all`||!Te(r))return[];let i=e.filter(e=>be(e,n)&&De(e,r)>0);return[..._e(e,0,`all`).projects.map(e=>({project:e.key})),`none`].flatMap(e=>{if(typeof e==`object`&&typeof t==`object`?e.project===t.project:e===t)return[];let n=i.filter(t=>ve(t,e)).length;return n>0?[{place:e,count:n}]:[]})}var je=()=>({ids:new Set,anchor:null,range:[]});function Me(e,t,n,r,i){let a=e.anchor!==null&&r.includes(e.anchor)?e.anchor:i??null,o=a===null?-1:r.indexOf(a),s=r.indexOf(t);if(n===`range`&&o>=0&&s>=0){let t=new Set(e.ids);for(let n of e.range)r.includes(n)&&t.delete(n);let n=[];for(let e of r.slice(Math.min(o,s),Math.max(o,s)+1))t.has(e)||(t.add(e),n.push(e));return{ids:t,anchor:a,range:n}}let c=new Set(e.ids);return c.has(t)?c.delete(t):c.add(t),{ids:c,anchor:t,range:[]}}function Ne(e,t){return{ids:new Set([...e.ids,...t]),anchor:e.anchor,range:[]}}function Pe(e,t){let n=new Set(e.ids),r=t.length>0&&t.every(e=>n.has(e));for(let e of t)r?n.delete(e):n.add(e);return{ids:n,anchor:e.anchor,range:[]}}function Fe(e,t){return{ids:new Set([...e.ids].filter(e=>t.has(e))),anchor:e.anchor!==null&&t.has(e.anchor)?e.anchor:null,range:e.range.filter(e=>t.has(e))}}function Ie(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 a=document.createElement(`strong`);a.textContent=t;let o=document.createElement(`p`);o.className=`hint`,o.append(...typeof n==`string`?[n]:n);let s=document.createElement(`div`);return s.append(a,o),i.append(d(e),s),i}var Le=new WeakMap;function Re(e,t,n){let r=n.toLocaleLowerCase();for(let n=1;n<=e.length;n++){let i=(t+n+e.length)%e.length;if(e[i].toLocaleLowerCase().startsWith(r))return i}return null}var I=`[role=row][data-key]`,ze=`head`,Be=`[data-list-head] [data-sort]`,Ve=`button, input, a[href]`,He=e=>[...e.querySelectorAll(`${I}:not([hidden])`)],Ue=e=>e.closest(`[role=gridcell], [role=columnheader]`)?.dataset.col??null;function We(e){return[...e.querySelectorAll(`:scope > [role=gridcell]`)].flatMap(e=>{let t=[...e.querySelectorAll(Ve)];return t.length===0||e.dataset.col===`name`?[e,...t]:t}).filter(e=>e.checkVisibility({visibilityProperty:!0}))}var Ge=(e,t)=>t===null?e:We(e).find(e=>Ue(e)===t)??e;function Ke(e){let t=Number(e.getAttribute(`aria-level`));for(let n=e.previousElementSibling;n!==null;){if(Number(n.getAttribute(`aria-level`))<t)return n;n=n.previousElementSibling}return null}function L(e){e!=null&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`nearest`}))}function qe(e,t){for(let t of e.querySelectorAll(`[tabindex="0"]`))t.tabIndex=-1;t.tabIndex=0;let n=t.closest(I);Le.set(e,{key:n===null?ze:n.dataset.key,col:t===n?null:Ue(t)})}function Je(e){let t=e===null?void 0:Le.get(e);if(e===null||t===void 0)return null;let n=He(e).findIndex(e=>e.dataset.key===t.key);return{...t,at:n,inside:e.contains(document.activeElement)}}function Ye(e,t){if(t===null)return;let n=He(e),r=n.find(e=>e.dataset.key===t.key)??n[Math.min(t.at,n.length-1)],i=t.key===`head`?e.querySelector(`[data-list-head] [data-col="${t.col}"] [data-sort]`):r===void 0?null:Ge(r,t.col);i!==null&&(t.inside?i.focus({preventScroll:!0}):qe(e,i))}function Xe(e,t){for(let t of e.querySelectorAll(`${Be}, ${I}, ${I} > [role=gridcell], ${I} :is(${Ve})`))t.tabIndex=-1;let n=He(e)[0];n!==void 0&&(n.tabIndex=0),e.addEventListener(`focusin`,t=>{let n=t.target,r=n.closest(I),i=n.matches(Be);r===null&&!i||n.matches(`[data-name]`)||qe(e,n)}),e.addEventListener(`keydown`,t=>{let n=t.target;if(!n.matches(Be)||t.ctrlKey||t.altKey||t.metaKey||t.shiftKey)return;let r=[...e.querySelectorAll(Be)].filter(e=>e.checkVisibility()),i=r.indexOf(n);switch(t.key){case`ArrowLeft`:L(r[i-1]);break;case`ArrowRight`:L(r[i+1]);break;case`ArrowDown`:L(He(e)[0]);break;case`ArrowUp`:case`Home`:case`End`:break;default:return}t.preventDefault()});let r=``,i=-1/0,a=-1,o=null;e.addEventListener(`keydown`,n=>{let s=n.target,c=s.closest(I);if(c===null||document.activeElement?.matches(`[data-name]`)||n.ctrlKey||n.altKey)return;let{key:l,metaKey:u,shiftKey:d}=n,f=He(e),p=f.indexOf(c),m=s!==c,h=m?Ue(s):null,g=n.timeStamp-i<=500&&document.activeElement===o;if(l.length===1&&!u&&(l!==` `||g)){g||(r=``,a=p),r+=l,i=n.timeStamp;let e=Re(f.map(e=>e.dataset.flow!==void 0||e.dataset.take!==void 0?e.getAttribute(`aria-label`)??``:``),a,r);e!==null&&L(Ge(f[e],h)),o=document.activeElement,n.preventDefault();return}let _=m?We(c):[],v=_.indexOf(s),y=e.closest(`[data-busy]`)!==null,b=c.dataset.flow,x=()=>{h===`actions`&&(b!==void 0||c.dataset.videoRow!==void 0)&&L(c)},S=c.hasAttribute(`aria-expanded`)&&(c.dataset.heading!==void 0||h===`open`);(()=>{if(u&&![`ArrowUp`,`ArrowDown`,`Backspace`,`a`,`A`].includes(l))return!1;switch(l){case`ArrowDown`:case`ArrowUp`:{let n=l===`ArrowDown`?1:-1;if(u){let e=n>0?f[f.length-1]:f[0];return L(e===void 0?null:Ge(e,h)),!0}let r=f[p+n];if(r===void 0&&n<0&&!d)return L(e.querySelector(`[data-list-head] [data-col="${h}"] [data-sort]`)??e.querySelector(`[data-sort="name"]`)),!0;if(d){if(m)return!1;if(y)return!0;L(r);let n=r?.dataset.flow;return n!==void 0&&t.select?.(n,`range`,Dt(e),b),!0}return r!==void 0&&L(Ge(r,h)),!0}case`ArrowRight`:return m?L(_[v+1]):c.getAttribute(`aria-expanded`)===`false`?Et(c,!0):L(We(c)[0]),!0;case`ArrowLeft`:return m?L(v>0?_[v-1]:c):c.getAttribute(`aria-expanded`)===`true`?Et(c,!1):L(Ke(c)),!0;case`Home`:return L(m?_[0]:f[0]),!0;case`End`:return L(m?_.at(-1):f.at(-1)),!0;case`PageDown`:case`PageUp`:{let e=Math.max(1,Math.floor(document.documentElement.clientHeight/Math.max(1,c.offsetHeight))),t=Math.min(f.length-1,Math.max(0,p+(l===`PageDown`?e:-e)));return L(Ge(f[t],h)),!0}case`Enter`:if(m&&s.matches(Ve))return!1;if(S)Et(c,c.getAttribute(`aria-expanded`)===`false`);else if(h===`name`)yt(c);else if(!m){if(e.closest(`[data-selecting]`)!==null)b!==void 0&&!y?t.select?.(b,`toggle`,Dt(e)):c.dataset.videoRow===void 0&&!c.hasAttribute(`data-absent`)&&c.dataset.scene!==void 0&&t.edit(c.dataset.scene);else if(!c.hasAttribute(`data-absent`)){let e=c.dataset.scene;e!==void 0&&t.edit(e)}}return!0;case` `:return m&&s.matches(Ve)?!1:(y||b!==void 0&&(x(),t.select?.(b,`toggle`,Dt(e))),!0);case`a`:case`A`:return y||(x(),t.selectAll?.(Dt(e))),!0;case`Backspace`:return u?(y||(e.closest(`[data-selecting]`)===null?b===void 0?c.dataset.scene!==void 0&&t.remove(c.dataset.scene,`take`):t.remove(b,`video`):t.deleteSelected?.()),!0):!1;case`Escape`:return m?(L(c),n.stopPropagation(),!0):!1;default:return!1}})()&&(n.preventDefault(),i=-1/0)})}var Ze=e=>e!==`name`&&e!==`where`;function Qe(e,t){return e.column===t?{column:t,descending:!e.descending}:{column:t,descending:Ze(t)}}var $e=/^(?:localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;function et(e){return $e.test(e)?`localhost`:e}function tt(e,t,n){let r=!t||e.group===null?null:E(e.group.video.repo),{origin:i,path:a}=e.row,o=n===null?``:n===`short`?et(i):i;return`${r===null?``:`${r} · `}${o}${a||`/`}`}function nt(e,t){let n=new Map;for(let t of e){let e=F(t);e!==null&&n.set(e,(n.get(e)??new Set).add(t.row.origin))}return e=>{let r=F(e);return{text:tt(e,t,r===null||(n.get(r)?.size??0)>1&&!$e.test(e.row.origin)?`short`:null),title:tt(e,t,`whole`)}}}function rt(e){let t=e.group===null?[e.row]:e.group.versions,n=t.flatMap(e=>e.sizeBytes===void 0?[]:[e.sizeBytes]);return n.length===0?{kind:`unknown`}:{kind:`known`,bytes:n.reduce((e,t)=>e+t,0),unmeasured:t.length-n.length}}var it=e=>e.group===null?e.row.label:e.group.video.name||e.row.label,at=e=>{let t=Date.parse(e.row.createdAt);return Number.isNaN(t)?-1/0:t},ot=e=>e.group?.versions.length??1;function st(e,t){switch(t){case`name`:return it(e);case`where`:return[F(e)??``,e.row.path||`/`,e.row.origin];case`videos`:return ot(e);case`recorded`:return Number.isFinite(at(e))?at(e):null;case`size`:{let t=rt(e);return t.kind===`known`?t.bytes:null}}}function ct(e,t){for(let n=0;n<e.length;n++){let r=(e[n]??``).localeCompare(t[n]??``,void 0,{numeric:!0});if(r!==0)return r}return 0}function lt(e,t){let n=t.descending?-1:1;return[...e].sort((e,r)=>{let i=st(e,t.column),a=st(r,t.column);if(i===null||a===null){if(i!==a)return i===null?1:-1}else if(i!==a){let e=typeof i==`number`?i-a:ct(typeof i==`string`?[i]:i,typeof a==`string`?[a]:a);if(e!==0)return e*n}return at(r)-at(e)})}function ut(e,t,n){let r=y(e),i=[],a=(e,t,n)=>{let r=t===null?1:2,{group:a}=e,o=a===null?`t:${e.row.sceneId}`:`f:${a.video.id}`;i.push({kind:`flow`,key:o,parent:t,level:r,card:e,flowId:a===null?null:a.video.id,namesDay:n,size:rt(e)});for(let e of a?.versions??[])i.push({kind:`video`,key:`v:${e.sceneId}`,parent:o,level:r===1?2:3,row:e,flowId:a.video.id})};if(`rank`in t){let e=r.map(e=>[t.rank(e),e]);e.sort((e,t)=>t[0]-e[0]||at(t[1])-at(e[1]));for(let[,t]of e)a(t,null,!1);return i}let o=t;if(o.column===`recorded`&&o.descending){let e=lt(r,o),t=new Map(e.map(e=>[e.row.sceneId,e]));for(let r of v(e.map(e=>e.row),n)){let e=`h:${r.key}`;i.push({kind:`heading`,key:e,parent:null,level:1,section:r});for(let n of r.rows)a(t.get(n.sceneId),e,r.namesDay)}}else for(let e of lt(r,o))a(e,null,!1);return i}var dt=(e,t)=>e.expired===!0?{absent:At(!0,t.rerunLine?.(e.sceneId,e.authored))??`Expired`}:`here`,ft=[[`select`,`Select`,null,!1],[`open`,`Open`,null,!1],[`name`,`Name`,`name`,!0],[`where`,`Where`,`where`,!0],[`videos`,`Videos`,`videos`,!0],[`length`,`Length`,null,!0],[`size`,`Size`,`size`,!0],[`recorded`,`Recorded`,`recorded`,!0],[`actions`,`Actions`,null,!1]];function pt(e){return new Set([...e.querySelectorAll(`[data-list] [role=row][aria-expanded="false"]`)].map(e=>e.dataset.key))}function mt(e,t,n){let r=z(`div`,{role:`row`,"data-list-head":``});for(let[i,a,o,s]of ft){let c=z(`div`,{role:`columnheader`,"data-col":i});s||c.setAttribute(`aria-label`,a),o!==null&&o===n?.column&&c.setAttribute(`aria-sort`,n.descending?`descending`:`ascending`);let l=t.setView;if(o!==null&&l!==void 0){let t=z(`button`,{type:`button`,"data-sort":o},a);c.hasAttribute(`aria-sort`)&&t.append(d(`chevronDown`)),t.addEventListener(`click`,()=>l({...e,sort:n===null?{column:o,descending:Ze(o)}:Qe(n,o)})),c.append(t)}else s&&(c.textContent=a);r.append(c)}return r}function ht(e,t,n,r=n){e[t].textContent=n,e[t].title=r}var gt=()=>{let e=d(`chevronRight`);return e.classList.add(`chev`),e};function _t(e,t,n){let r=`row-menu-${n}`,i=z(`button`,{type:`button`,class:`btn btn-quiet btn-icon row-more`,popovertarget:r,"aria-label":`More for ${t}`,title:`More`});i.append(d(`ellipsis`));let a=z(`div`,{id:r,popover:``,role:`menu`,class:`row-menu`});for(let t of e.querySelectorAll(`button`)){let e=z(`button`,{type:`button`,role:`menuitem`});t.classList.contains(`btn-danger`)&&e.classList.add(`btn-danger`),e.append(...[...t.childNodes].map(e=>e.cloneNode(!0)),t.title.split(` — `)[0]??t.title),e.disabled=t.disabled,e.addEventListener(`click`,()=>{a.hidePopover(),t.click()}),a.append(e)}return[i,a]}var vt=new WeakMap,yt=e=>vt.get(e)?.();function bt(e){let t=z(`button`,{type:`button`,"data-action":`rename`,class:`btn btn-quiet btn-icon`,"aria-label":`Rename ${e}`,title:`Rename`});return t.append(d(`pencilLine`)),t}var xt=e=>z(`p`,{class:`notice notice-error`},e);function St(e,t,n){let r=z(`input`,{type:`checkbox`,class:`select-box`,"data-select-group":JSON.stringify(t),"aria-label":`Select ${e}`});return r.addEventListener(`click`,e=>{e.stopPropagation(),n.selectGroup?.([...t])}),r}function Ct(e,t,n,a,o,s=[],c=()=>null){let l=z(`div`,{role:`row`,"data-key":e.key}),u=Object.fromEntries(ft.map(([e])=>[e,z(`div`,{role:`gridcell`,"data-col":e})])),d=[];if(e.kind===`heading`){let{section:n}=e;l.setAttribute(`data-heading`,n.key),l.id=yn(n.key),l.setAttribute(`aria-label`,n.label),u.open.append(gt()),t.selectGroup!==void 0&&s.length>0&&u.select.append(St(n.label,s,t)),u.name.append(z(`span`,{"data-name-text":``},n.label),z(`span`,{class:`section-count`,"data-section-count":``},String(n.rows.length)))}else if(e.kind===`flow`){let{card:i}=e,s=i.row,f=i.group,p=f===null?s.name||s.label:f.video.name||s.label;l.setAttribute(`data-scene`,s.sceneId),l.setAttribute(`aria-label`,p),dt(s,t)!==`here`&&l.setAttribute(`data-absent`,``),f===null?l.setAttribute(`data-take`,s.sceneId):(l.setAttribute(`data-flow`,f.video.id),a.set(f.video.id,f),u.open.append(gt()),t.select!==void 0&&u.select.append(z(`input`,{type:`checkbox`,class:`select-box`,"data-select":f.video.id,"aria-label":`Select ${p}`}))),u.name.append(z(`span`,{"data-name-text":``,title:p},p));let m=c(i);m!==null&&u.name.append(on(m,`name`));let h=$t(s,t,!1);h!==null&&u.name.append(h);let g=o(i);if(ht(u,`where`,g.text,g.title),m!==null&&u.where.replaceChildren(z(`span`,{"data-where-text":``},g.text),on(m,`where`)),u.videos.textContent=String(f?.versions.length??1),u.recorded.textContent=e.namesDay?s.time:s.when,u.recorded.title=s.when,e.size.kind===`unknown`)u.size.textContent=`—`;else{let t=e.size.unmeasured;u.size.textContent=`${C(e.size.bytes)}${t>0?`+`:``}`,t>0&&(u.size.title=`${t} ${t===1?`video`:`videos`} could not be measured`)}let _=u.name;vt.set(l,()=>{let e=_.querySelector(`[data-name-text]`);if(e===null)return;let n=rn(s,t,f);n.addEventListener(`blur`,()=>{e.textContent=n.value||s.label,e.title=e.textContent,n.replaceWith(e)}),n.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===`Escape`)&&(_.focus({preventScroll:!0}),e.stopPropagation())}),e.replaceWith(n),n.focus({preventScroll:!0}),n.select()});let{buttons:v,rerunLine:y}=sn(s,t,f),b=bt(p);if(b.addEventListener(`click`,()=>yt(l)),v.insertBefore(b,v.querySelector(`[data-action="edit"], [data-action="delete"]`)),u.actions.append(v,..._t(v,p,e.key)),y!==null){let e=z(`p`,{"data-rerun-line":``,class:`row-rerun`});r(e,y),d.push(e)}let x=f===null?n.get(R(`take`,s.sceneId)):n.get(R(`video`,f.video.id));x!==void 0&&d.push(xt(x));for(let e of f?.versions??[]){let t=n.get(R(`take`,e.sceneId));if(t===void 0)continue;let r=xt(e.sceneId===s.sceneId?t:`Video ${e.version??`?`}: ${t}`);r.setAttribute(`data-lead-status`,``),d.push(r)}}else{let o=e.row;l.setAttribute(`data-video-row`,o.sceneId),l.setAttribute(`data-scene`,o.sceneId);let s=`Video ${o.version??`?`}`;l.setAttribute(`aria-label`,s),u.name.append(z(`span`,{"data-name-text":``},s));let c=ln(o);c!==null&&u.name.append(c);let f=dt(o,t);if(f!==`here`&&l.setAttribute(`data-absent`,``),f===`here`){let e=dn(o.exports);e!==null&&u.where.append(e)}else r(u.where,f.absent),u.where.title=i(f.absent);u.recorded.textContent=o.when,u.recorded.title=o.when,u.size.textContent=o.sizeBytes===void 0?`—`:C(o.sizeBytes);let p=un(o,a.get(e.flowId),t,f===`here`);u.actions.append(p,..._t(p,s,e.key));let m=n.get(R(`take`,o.sceneId));m!==void 0&&d.push(xt(m))}if(l.append(...ft.map(([e])=>u[e])),d.length>0){let t=z(`div`,{"data-status":``,id:`list-status-${e.key}`});t.append(...d),l.append(t),l.setAttribute(`aria-describedby`,t.id)}return l}function wt(e,t,n,r,i,a,o,s=!0,c=a.sort,l){let u=ut(t,c,i),d=nt(y(t),s),f=z(`div`,{role:`treegrid`,class:`library-list`,"data-list":``,"aria-multiselectable":`true`,"aria-label":`Flows`,"aria-rowcount":String(u.length+1)});f.append(mt(a,n,`rank`in c?null:c));let p=new Map;for(let e of u)p.set(e.parent,(p.get(e.parent)??0)+1);let m=new Map,h=new Map,g=new Map;for(let e of u)e.kind===`flow`&&e.parent!==null&&e.flowId!==null&&g.set(e.parent,[...g.get(e.parent)??[],e.flowId]);for(let e of u){let t=Ct(e,n,r,h,d,g.get(e.key),l),i=(m.get(e.parent)??0)+1;if(m.set(e.parent,i),t.setAttribute(`aria-level`,String(e.level)),t.setAttribute(`aria-posinset`,String(i)),t.setAttribute(`aria-setsize`,String(p.get(e.parent))),e.kind===`heading`||e.kind===`flow`&&e.flowId!==null){let n=e.kind!==`heading`||e.section.folded,r=o.collapsed.has(e.key)||n&&!(o.drawn?.has(e.key)??!1);t.setAttribute(`aria-expanded`,String(!r))}e.kind===`flow`&&e.flowId!==null&&t.setAttribute(`aria-selected`,`false`),f.append(t)}return Tt(f),Ot(f,n),Xe(f,n),e.append(f),f}function Tt(e){let t=[];for(let n of e.querySelectorAll(`[role=row][data-key]`)){let e=Number(n.getAttribute(`aria-level`));n.hidden=e>1&&t[e-1]!==!0,t[e]=!n.hidden&&n.getAttribute(`aria-expanded`)!==`false`;let r=n.querySelectorAll(`:scope > [data-status] > [data-lead-status]`);if(r.length>0){for(let e of r)e.hidden=n.getAttribute(`aria-expanded`)===`true`;let e=r[0]?.parentElement;e.hidden=[...e.children].every(e=>e.hidden),e.hidden?n.removeAttribute(`aria-describedby`):n.setAttribute(`aria-describedby`,e.id)}}}function Et(e,t){e.setAttribute(`aria-expanded`,String(t));let n=e.closest(`[data-list]`);if(n===null)return;let r=[...n.querySelectorAll(`[data-video-row]`)],i=r.map(e=>e.hidden);Tt(n);for(let[e,t]of r.entries())t.toggleAttribute(`data-opening`,i[e]===!0&&!t.hidden)}var Dt=e=>[...e.querySelectorAll(`[role=row][data-flow]:not([hidden])`)].map(e=>e.dataset.flow);function Ot(e,t){let n=!1;e.addEventListener(`pointerdown`,()=>{let t=document.activeElement;n=t?.matches(`[data-name]`)===!0&&e.contains(t)}),e.addEventListener(`click`,r=>{let i=r.target,a=i.closest(`[role=row][data-key]`),o=n;if(n=!1,a===null||i.closest(`[data-status]`)!==null)return;let s=a.dataset.flow,c=()=>{r.shiftKey&&window.getSelection()?.removeAllRanges(),t.select?.(s,r.shiftKey?`range`:`toggle`,Dt(e))};if(a.hasAttribute(`aria-expanded`)&&(a.dataset.heading!==void 0||i.closest(`[data-col="open"]`)!==null)){Et(a,a.getAttribute(`aria-expanded`)===`false`);return}if(i.matches(`[data-select]`)){c();return}if(o||i.closest(`button, input, a`))return;if(s!==void 0&&t.select!==void 0&&(e.closest(`[data-selecting]`)!==null||r.metaKey||r.shiftKey)){c();return}if(a.dataset.videoRow!==void 0&&e.closest(`[data-selecting]`)!==null||(window.getSelection()?.toString()??``)!==``||a.hasAttribute(`data-absent`))return;let l=a.dataset.scene;l!==void 0&&t.edit(l)})}var kt=e=>e.kind===`upkeep`?null:e.kind===`video`?`record`:`folder`,R=(e,t)=>`${e}:${t}`,At=(e,t)=>t==null?null:e===!0?`Expired — ${t.charAt(0).toLowerCase()}${t.slice(1)}`:t;function jt(e){let t=e.querySelector(`.place-tabs`),n=t?.querySelector(`[aria-pressed="true"]`);if(t==null||n==null||t.scrollWidth<=t.clientWidth)return;let r=Number.parseFloat(getComputedStyle(t).paddingLeft)||0,i=t.getBoundingClientRect(),a=n.getBoundingClientRect();a.left<i.left+r?t.scrollLeft-=i.left+r-a.left:a.right>i.right-r&&(t.scrollLeft+=a.right-(i.right-r))}function Mt(e){return[...(e.closest(`[data-library]`)??e.ownerDocument).querySelectorAll(`:is(details[open], [data-results]) [data-select]`)].map(e=>e.dataset.select)}function Nt(e){let t=z(`div`,{class:`selection-bar`,"data-selection-bar":``}),n=z(`button`,{type:`button`,class:`btn btn-quiet`,"data-action":`cancel-selection`},`Cancel`);n.addEventListener(`click`,()=>e.clearSelection?.());let r=z(`button`,{type:`button`,class:`btn btn-danger`,"data-action":`delete-selected`},`Delete`);return r.addEventListener(`click`,()=>e.deleteSelected?.()),t.append(z(`span`,{class:`selection-count`,"data-selection-count":``}),n,r,z(`p`,{class:`selection-said`,"data-selection-said":``,role:`status`})),t}function Pt(e,t,n){let r=`${t} ${t===1?`flow`:`flows`}`,i=n?.busy===!0;e.querySelector(`[data-selection-count]`).textContent=i?`Deleting ${r}…`:`${r} selected`;for(let t of e.querySelectorAll(`button`))t.disabled=i;let a=e.querySelector(`[data-selection-said]`);a.textContent=n?.said??``,a.hidden=n?.said==null}var Ft=new WeakMap;function It(e,t,n,r){let i=t.select===void 0?new Set:n?.ids??new Set;e.toggleAttribute(`data-selecting`,i.size>0);let a=r?.busy===!0;e.toggleAttribute(`data-busy`,a);for(let t of e.querySelectorAll(`[data-select]`)){let e=i.has(t.dataset.select);t.checked=e,t.disabled=a,t.closest(`article`)?.toggleAttribute(`data-selected`,e),t.closest(`[role=row]`)?.setAttribute(`aria-selected`,String(e))}for(let t of e.querySelectorAll(`[data-select-group]`)){let e=JSON.parse(t.dataset.selectGroup),n=e.filter(e=>i.has(e)).length;t.checked=n>0&&n===e.length,t.indeterminate=n>0&&n<e.length,t.disabled=a}let o=e.querySelector(`[data-selection-bar]`);if(i.size===0){o?.remove(),Ft.get(e)?.disconnect(),e.style.removeProperty(`--selection-bar`);return}if(o===null){let n=Qt.get(e)?.notices;if(n===void 0)return;o=Nt(t),n.after(o)}Pt(o,i.size,r);let s=t=>e.style.setProperty(`--selection-bar`,`${t.getBoundingClientRect().height}px`);s(o);let c=Ft.get(e);c===void 0&&(c=new ResizeObserver(e=>{for(let t of e)s(t.target)}),Ft.set(e,c)),c.disconnect(),c.observe(o)}var Lt=1024**3;function z(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 Rt(e,t,n={}){let r=z(`span`,{class:`tag`,...n});return r.append(d(e),t),r}function zt(){let e=z(`div`,{class:`meter`}),t=z(`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 Bt=`storage-panel`,Vt=`place-menu`,Ht=16,Ut=300;function B(e,t,n=!1,r=!1){let i=t.getBoundingClientRect(),a=document.documentElement.clientWidth,o=Math.min(Ut,a-32),s=!r&&i.right-o>=Ht?i.right-o:i.left,c=Math.max(Ht,Math.min(s,a-Ht-o)),l=t.closest(`[data-header]`),u=l!==null&&getComputedStyle(l).position===`sticky`;e.style.maxHeight=``;let d=e.offsetHeight,f=i.bottom+6,p=window.innerHeight-Ht-f,m=i.top-6-Ht,h=n&&e.dataset.side!==void 0?e.dataset.side===`above`:d>p&&(d<=m||m>p);e.dataset.side=h?`above`:`below`;let g=Math.max(0,h?m:p);d>g&&(e.style.maxHeight=`${Math.round(g)}px`);let _=Math.min(d,g),v=h?i.top-6-_:f;e.style.position=u?`fixed`:`absolute`,e.style.width=`${Math.round(o)}px`,e.style.left=`${Math.round(c+(u?0:window.scrollX))}px`,e.style.top=`${Math.round(v+(u?0:window.scrollY))}px`}var Wt=e=>(e/Lt).toFixed(2).replace(/\.?0+$/,``),Gt=[[`inRepo`,`In repo`],[`notInRepo`,`Not in repo`],[`all`,`All`]],Kt={all:`All flows`,none:`No project`,unreadable:`Couldn't read`};function qt(e){let t=(e,t)=>z(`span`,{class:`proj-dim ${e}`,[`data-${e}`]:``},t);return[...e.owner===null?[]:[t(`place-owner`,`${e.owner}/`)],z(`span`,{class:`place-name`,"data-place-name":``},e.name),...e.local?[t(`place-local`,` local`)]:[]]}function Jt(e,t,n){let r=z(`div`,{class:`side-list`}),i=m(t),a=(e,t,a,o=t.join(``))=>{let s=m(e),c=z(`a`,{href:s,class:`side-item`,"data-place":s,"aria-current":String(s===i),title:o}),l=z(`span`,{class:`side-label`});l.append(...t),c.append(l,z(`span`,{class:`side-count`},String(a))),c.addEventListener(`click`,t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),n.goPlace?.(e))}),r.append(c)};a(`all`,[Kt.all],e.all);for(let t of e.projects)a({project:t.key},qt(t),t.count,t.key);return(e.none>0||t===`none`)&&a(`none`,[Kt.none],e.none),(e.unreadable>0||t===`unreadable`)&&a(`unreadable`,[Kt.unreadable],e.unreadable),r}function Yt(e){if(e===void 0)return[`Flows`];let t=e.place;if(typeof t==`string`)return[Kt[t]];let n=e.rail.projects.find(e=>e.key===t.project);return n===void 0?[z(`span`,{class:`place-name`,"data-place-name":``},t.project)]:qt(n)}function Xt(e){let t=null,n,r=z(`div`,{class:`library`,"data-library":``}),i=z(`aside`,{class:`library-side`,"data-header":``}),a=z(`h1`,{}),o=z(`span`,{"data-place-title":``},`Flows`),s=z(`span`,{class:`place-switch-name`}),c=z(`button`,{type:`button`,class:`place-switch`,"data-place-switch":``,popovertarget:Vt,"aria-controls":Vt,"aria-haspopup":`menu`,"aria-expanded":`false`});c.hidden=!0,c.append(s,d(`chevronDown`)),a.append(c,o);let l=z(`div`,{id:Vt,class:`place-menu`,popover:``,role:`menu`,"aria-label":`Switch project`,"data-place-menu":``}),u=()=>[...l.querySelectorAll(`[data-place]`)],f=null;l.addEventListener(`beforetoggle`,e=>{e.newState===`open`&&B(l,c,!1,!0)}),l.addEventListener(`toggle`,e=>{let t=e.newState===`open`;c.setAttribute(`aria-expanded`,String(t)),f?.abort(),f=null,t&&(B(l,c,!1,!0),(l.querySelector(`[aria-current="true"]`)??u()[0])?.focus(),f=new AbortController,window.addEventListener(`resize`,()=>{c.getClientRects().length===0?l.hidePopover():B(l,c,!1,!0)},{signal:f.signal}))}),l.addEventListener(`keydown`,e=>{let t=u(),n=t.indexOf(document.activeElement),r=t.length,i=e.key===`ArrowDown`?(n+1)%r:e.key===`ArrowUp`?(n-1+r)%r:e.key===`Home`?0:e.key===`End`?r-1:null;i!==null&&r!==0&&(e.preventDefault(),t[i]?.focus())}),l.addEventListener(`click`,e=>{e.defaultPrevented&&(l.hidePopover(),c.focus())}),l.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t!==null&&!l.contains(t)&&l.matches(`:popover-open`)&&l.hidePopover()});let p=z(`nav`,{class:`side-group`,"aria-label":`Projects`,"data-rail":``}),m=z(`div`,{class:`library-content`}),h=zt();h.bar.setAttribute(`aria-hidden`,`true`);let g=z(`span`,{"data-meter":``}),_=z(`button`,{type:`button`,class:`btn btn-quiet storage-trigger`,"data-storage-trigger":``,popovertarget:Bt,"aria-controls":Bt});_.append(z(`span`,{class:`storage-label`},`Storage`),h.bar,g,d(`chevronDown`));let v=z(`div`,{class:`storage`}),y=z(`span`,{"data-total-size":``}),b=z(`span`,{class:`library-total`,"data-library-total":``});b.append(z(`span`,{class:`storage-label`},`Storage`),y);let x=z(`div`,{"data-notices":``}),S=z(`div`,{class:`tabs-row`,"data-tabs-row":``}),w=z(`div`,{class:`place-tabs`}),E=new Map;for(let[e,n]of Gt){let r=z(`span`,{class:`side-count`}),i=z(`button`,{type:`button`,class:`btn btn-quiet`,"data-tab":e},n);i.append(r),i.addEventListener(`click`,()=>t?.goTab?.(e)),E.set(e,r),w.append(i)}let D=z(`label`,{class:`search-field`}),O=z(`input`,{type:`search`,"data-search":``,"aria-label":`Search flows`,placeholder:`Search`});O.addEventListener(`input`,()=>t?.search?.(O.value)),O.addEventListener(`keydown`,e=>{e.key===`Escape`&&O.value!==``&&(e.preventDefault(),t?.search?.(``))}),D.append(d(`search`),O,z(`kbd`,{},`/`));let k=z(`div`,{class:`layout-toggle`,"data-layout-toggle":``});for(let[e,r,i]of[[`list`,`list`,`List`],[`grid`,`layoutGrid`,`Grid`]]){let a=z(`button`,{type:`button`,class:`btn btn-quiet btn-icon`,"data-layout":e,"aria-label":i,title:i});a.append(d(r)),a.addEventListener(`click`,()=>{n!==void 0&&n.layout!==e&&t?.setView?.({...n,layout:e,sort:{...n.sort}})}),k.append(a)}let A=z(`div`,{id:Bt,class:`storage-panel`,popover:``,"data-storage":``,"aria-label":`Storage`}),j=null;A.addEventListener(`beforetoggle`,e=>{e.newState===`open`&&B(A,_)}),A.addEventListener(`toggle`,e=>{let t=e.newState===`open`;_.toggleAttribute(`data-open`,t),j?.abort(),j=null,t&&(B(A,_),j=new AbortController,window.addEventListener(`resize`,()=>B(A,_),{signal:j.signal}),window.addEventListener(`scroll`,()=>B(A,_,!0),{passive:!0,signal:j.signal}))});let M=zt();M.bar.setAttribute(`role`,`progressbar`),M.bar.setAttribute(`aria-label`,`Storage used`),M.bar.setAttribute(`aria-valuemin`,`0`),M.bar.setAttribute(`aria-valuemax`,`1`);let ee=z(`p`,{class:`storage-used`,"data-storage-used":``}),N=z(`input`,{type:`number`,min:`0.25`,step:`0.25`,id:`storage-budget`,"data-storage-budget":``}),P=z(`p`,{class:`notice notice-error hidden`,role:`alert`,"data-budget-note":``});N.addEventListener(`change`,()=>{let e=Number(N.value);if(!Number.isFinite(e)||e<=0){P.textContent=T,P.classList.remove(`hidden`);return}P.classList.add(`hidden`),t?.setBudget?.(Math.round(e*Lt))});let te=z(`div`,{class:`storage-budget-row`});te.append(N,z(`span`,{},`GB`));let ne=z(`div`,{class:`storage-field`});ne.append(z(`label`,{for:`storage-budget`},`Budget`),te,z(`p`,{class:`storage-hint`},`Saves automatically.`),P);let re=z(`button`,{type:`button`,"data-action":`reclaim`,class:`btn btn-quiet storage-reclaim`});re.append(d(`trash`),`Reclaim space`),re.addEventListener(`click`,()=>t?.reclaim?.());let ie=z(`div`,{class:`storage-foot`});ie.append(re,z(`p`,{class:`storage-hint`},`Clears cached exports, then hosted videos' motion, oldest first, until the library fits its budget.`)),A.append(z(`h2`,{class:`storage-title`},`Storage`),M.bar,ee,ne,ie),v.append(_,A),i.append(a,p,l),S.append(w,D,k),m.append(S,x),r.append(i,m);let ae=document.querySelector(`[data-storage-slot]`);return e&&(ae??i).append(v),{box:r,content:m,tabsRow:S,notices:x,update(e,r,a,d){t=r,n=a,k.hidden=n===void 0||r.setView===void 0;for(let e of k.querySelectorAll(`button`))e.setAttribute(`aria-pressed`,String(e.dataset.layout===n?.layout));let f=document.activeElement;f instanceof HTMLElement&&k.contains(f)&&!f.checkVisibility()&&[...k.querySelectorAll(`button`)].find(e=>e.checkVisibility())?.focus(),w.hidden=d?.tabs==null;for(let e of w.querySelectorAll(`[data-tab]`)){let t=e.dataset.tab;e.setAttribute(`aria-pressed`,String(t===d?.tab)),E.get(t).textContent=String(d?.tabs?.[t]??``)}D.hidden=r.search===void 0||d?.place===`unreadable`;let m=d?.search?.query??``;O.value!==m&&(O.value=m),S.hidden=k.hidden&&w.hidden&&D.hidden,o.replaceChildren(...Yt(d)),s.replaceChildren(...d===void 0?[]:Yt(d)),c.hidden=d===void 0;for(let e of[p,l]){let t=document.activeElement?.closest(`[data-place]`),n=e.contains(t??null)?t?.dataset.place:void 0;e.replaceChildren(...d===void 0?[]:[Jt(d.rail,d.place,r)]),n!==void 0&&e.querySelector(`[data-place="${CSS.escape(n)}"]`)?.focus()}l.querySelector(`.side-list`)?.setAttribute(`role`,`none`);for(let e of u())e.setAttribute(`role`,`menuitem`),e.tabIndex=-1;if(e.totalBytes===void 0)b.remove();else{let t=e.unmeasured??0,n=`${C(e.totalBytes)}${t>0?`+`:``}`,r=t>0?`${t} ${t===1?`folder`:`folders`} could not be measured`:null;y.textContent=n,b.setAttribute(`aria-label`,`Storage: ${n}${r===null?``:` (${r})`}`),r===null?b.removeAttribute(`title`):b.setAttribute(`title`,r),b.parentNode===null&&(ae??i).append(b)}let v=C(e.usedBytes),T=C(e.budgetBytes);h.set(e.fraction),M.set(e.fraction),M.bar.setAttribute(`aria-valuenow`,e.fraction.toFixed(3)),g.textContent=`${v} of ${T}`,_.setAttribute(`aria-label`,`Storage: ${v} of ${T} used`),ee.textContent=`${v} used of a ${T} budget`,document.activeElement!==N&&(N.value=Wt(e.budgetBytes)),x.replaceChildren(...Zt(e))}}}function Zt(e){let t=[];return e.migrating&&t.push(z(`p`,{"data-migrating":``,class:`notice`},`Measuring existing videos…`)),e.migrationFailed&&t.push(z(`p`,{"data-migration-failed":``,class:`notice notice-warn`},`Measuring existing videos failed, so sizes below may be wrong. Open the extension's error log if this keeps happening.`)),e.chromeNearLimit&&t.push(z(`p`,{"data-chrome-limit":``,class:`notice notice-warn`},`Chrome is near its storage limit on this drive.`)),e.unwatched!=null&&t.push(z(`p`,{"data-unwatched":``,class:`notice notice-warn`},`New videos will not show until you reload — ${e.unwatched}.`)),e.notice!==null&&t.push(z(`p`,{"data-notice":``,class:`notice notice-error`},e.notice)),t}var Qt=new WeakMap;function $t(e,t,n=!0){let r=z(`div`,{class:`row-tags`}),i=t.openReview;if(e.needsLook&&i!==void 0){let t=z(`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(d(`circleAlert`)),t.addEventListener(`click`,()=>i(e.sceneId)),r.append(t)}return e.kept!=null&&r.append(Rt(`bookmark`,`In repo`,{"data-kept":``,title:`unknown`in e.kept?e.kept.unknown:`${e.kept.root}/${e.kept.file}${e.keptUnder===void 0?``:` — its repo could not be read, so it is listed under ${e.keptUnder}`}`})),e.hosted&&n&&r.append(Rt(`cloud`,`Hosted`,{"data-hosted":``,title:`Hosted copy stays online after a local delete`})),e.state===`Motion reclaimed`?r.append(Rt(`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 video`:`Its motion was reclaimed to free space; Restore re-shoots it in Runs`})):e.state===`Keyframes only`&&r.append(Rt(`image`,e.state,{"data-state-chip":``,title:`No motion was recorded for this video`})),r.childElementCount>0?r:null}function en(e,t){let n=z(`div`,{"data-preview":``}),r=z(`canvas`,{"data-preview-canvas":``,"aria-hidden":`true`,hidden:``});n.append(r,z(`p`,{"data-preview-note":``},le({kind:`loading`})??``));let i=$t(e,t);return i!==null&&n.append(i),n.append(z(`span`,{"data-duration":``,hidden:``})),n}var tn={Complete:`complete`,"Motion reclaimed":`reclaimed`,"Keyframes only":`keyframesOnly`},nn=e=>`name-${e}`;function rn(e,t,n){let r=n===null?e.name:n.video.name,i=z(`input`,{type:`text`,id:nn(e.sceneId),"data-name":``,"aria-label":n===null?`Video name`:`Flow 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 an(e,t,n,i,a,o,s,c,l=null){let u=a?.video.id??null,d=z(`article`,{class:`card`,"data-row":e.sceneId,"data-state":tn[e.state],...a===null?{}:{"data-video":a.video.id},...e.name===``&&a===null?{"aria-label":e.label}:{"aria-labelledby":nn(e.sceneId)}}),f=!1;d.addEventListener(`pointerdown`,()=>{let e=document.activeElement;f=e?.matches(`[data-name]`)===!0&&d.contains(e)}),d.addEventListener(`click`,n=>{let r=n.target;if(!f&&!r.closest(`button, input, a, [data-versions]`)){if(u!==null&&t.select!==void 0&&(d.closest(`[data-selecting]`)!==null||n.metaKey||n.shiftKey)){t.select?.(u,n.shiftKey?`range`:`toggle`,Mt(d));return}(window.getSelection()?.toString()??``)===``&&e.expired!==!0&&t.edit(e.sceneId)}});let p=en(e,t);if(u!==null&&t.select!==void 0){let n=z(`input`,{type:`checkbox`,class:`select-box`,"data-select":u,"aria-label":`Select ${a?.video.name||e.label}`});n.addEventListener(`click`,e=>{t.select?.(u,e.shiftKey?`range`:`toggle`,Mt(n))}),p.append(n)}d.append(p);let{buttons:m,rerunLine:h}=sn(e,t,a),g=z(`div`,{class:`row-text`}),_=z(`div`,{class:`row-title`});_.append(rn(e,t,a),m),g.append(_);let v=c({row:e,group:a}),y=z(`div`,{class:`row-line`}),b=z(`p`,{class:`row-meta`,"data-meta":``,title:l?.full??v.title});if(b.append(l===null?v.text:on(l),` · ${i?e.time:e.when}`),y.append(b),e.sizeBytes===void 0?t.reclaim!==void 0&&y.append(z(`p`,{"data-size":``,class:`row-size`},`${C(e.frameBytes)} frames · ${C(e.outputBytes)} renders`)):y.append(z(`p`,{"data-size":``,class:`row-size`},C(e.sizeBytes))),g.append(y),d.append(g),a!==null&&a.versions.length>1)d.append(cn(a,t,o,s));else if(a!==null){let e=a.versions[0],t=dn(e?.exports),n=e===void 0?null:ln(e);if(t!==null||n!==null){let e=z(`div`,{class:`card-exports`});n!==null&&e.append(n),t!==null&&e.append(t),d.append(e)}}if(h!==null){let e=z(`p`,{"data-rerun-line":``,class:`row-rerun`});r(e,h),d.append(e)}return n!==void 0&&d.append(z(`p`,{"data-status":``,class:`notice notice-error`},n)),d}var on=(e,t=``)=>z(`span`,{class:`match-why`,"data-match-why":t,title:e.full},e.text);function sn(e,t,n){let r=z(`div`,{class:`row-actions`});if(e.servesReshoot){let n=z(`button`,{type:`button`,"data-action":`back-to-recording`,class:`btn btn-quiet btn-icon`,"aria-label":`Back to the original footage: ${e.label}`,title:`Back to the original footage — this video plays its re-shot frames; its original footage is kept`});n.append(d(`undo`)),n.addEventListener(`click`,()=>t.backToRecording(e.sceneId)),r.append(n)}let i=e.canRestore||e.expired===!0?At(e.expired,t.rerunLine?.(e.sceneId,e.authored)):null;if(e.canRestore&&i===null){let n=z(`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 video cannot be re-shot, so this makes a new video`:`Restore motion — re-shoot it in Runs`});n.append(d(`restore`)),n.addEventListener(`click`,()=>t.restore(e.sceneId)),r.append(n)}let a=z(`button`,{type:`button`,"data-action":`edit`,class:`btn btn-quiet btn-icon`,"aria-label":`Edit ${e.label}`,title:`Edit`});a.append(d(`clapperboard`)),a.addEventListener(`click`,()=>t.edit(e.sceneId)),e.expired!==!0&&r.append(a);let o=z(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${e.label}`,title:`Delete`});return o.append(d(`trash`)),o.addEventListener(`click`,()=>n===null?t.remove(e.sceneId,`take`):t.remove(n.video.id,`video`)),r.append(o),{buttons:r,rerunLine:i}}function cn(e,t,n,i){let a=z(`details`,{class:`versions`,"data-versions":e.video.id});a.open=i;let o=z(`summary`,{class:`versions-count`}),s=d(`chevronRight`);s.classList.add(`chev`),o.append(s,`${e.versions.length} videos`),a.append(o);let c=z(`ol`,{class:`versions-list`});for(let i of e.versions){let a=z(`li`,{class:`version`,"data-version-row":i.sceneId,...i.expired===!0?{"data-expired":``}:{}}),o=z(`div`,{class:`version-head`});o.append(z(`span`,{class:`version-number`},`Video ${i.version??`?`}`),z(`span`,{class:`version-when`,title:i.when},i.when));let s=ln(i);s!==null&&o.append(s);let l=i.expired===!0?At(!0,t.rerunLine?.(i.sceneId,i.authored)):null;o.append(un(i,e,t,i.expired!==!0)),a.append(o);let u=dn(i.exports);if(u!==null&&a.append(u),l!==null){let e=z(`p`,{"data-rerun-line":``,class:`row-rerun`});r(e,l),a.append(e)}let d=n.get(R(`take`,i.sceneId));d!==void 0&&a.append(z(`p`,{"data-status":``,class:`notice notice-error`},d)),c.append(a)}return a.append(c),a}function ln(e){let t=g(e.filmedCode);if(t===null)return null;let n=e.filmedCode;return z(`span`,{class:`version-commit`,"data-commit":``,title:n.commit},t)}function un(e,t,n,r){let i=z(`div`,{class:`row-actions`});if(r){let r=z(`button`,{type:`button`,"data-action":`edit`,class:`btn btn-quiet btn-icon`,"aria-label":`Edit video ${e.version??``} of ${t.video.name}`,title:`Edit`});r.append(d(`clapperboard`)),r.addEventListener(`click`,()=>n.edit(e.sceneId)),i.append(r)}let a=z(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete video ${e.version??``} of ${t.video.name}`,title:`Delete`});return a.append(d(`trash`)),a.addEventListener(`click`,()=>n.remove(e.sceneId,`take`)),i.append(a),i}function dn(e){if(e===void 0)return null;if(`unreadable`in e)return z(`p`,{class:`row-rerun`,"data-exports-unreadable":``},`Its exports could not be read: ${e.unreadable}`);if(e.length===0)return null;let t=z(`ul`,{class:`version-exports`});for(let n of e){let e=n.path.slice(n.path.lastIndexOf(`/`)+1)||n.path,r=z(`li`,{"data-export":n.path,title:n.path,...n.exists?{}:{"data-gone":``}});r.append(z(`span`,{class:`export-name`},e),z(`span`,{class:`export-type`},n.exists?n.fileType.toUpperCase():`${n.fileType.toUpperCase()} · gone`)),t.append(r)}return t}var fn=new WeakMap,pn=e=>new Set([...e.querySelectorAll(`[data-versions]`)].filter(e=>e.open).map(e=>e.getAttribute(`data-versions`)));function mn(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`),r=t.closest(`[data-list] [data-key]`)?.dataset.key,i=n?`[data-row="${CSS.escape(n)}"]`:r?`[data-list] [data-key="${CSS.escape(r)}"]`:null;return i===null?null:{row:i,value:t.value,start:t.selectionStart,end:t.selectionEnd}}function hn(e,t){if(t===null)return!1;let n=e.querySelector(t.row);if(n===null)return!1;n.querySelector(`[data-name]`)===null&&yt(n);let r=n.querySelector(`[data-name]`);return r!==null&&(r.value=t.value,r.focus(),t.start!==null&&t.end!==null&&r.setSelectionRange(t.start,t.end),!0)}var gn=e=>`section-${e.replace(/:/g,`-`)}`;function _n(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 vn=`unreadable`,yn=e=>`when-${e.replace(/:/g,`-`)}`,bn=(e,t,n)=>t===null?n.get(R(`take`,e.sceneId)):n.get(R(`video`,t.video.id))??(t.versions.length>1?void 0:n.get(R(`take`,e.sceneId)));function xn(e,t,n,r,i,a,o){let s=gn(e.key),c=z(`details`,{class:`section`,id:yn(e.key),"data-section":e.key,"aria-labelledby":s});c.open=t;let l=z(`summary`,{class:`section-head`}),u=d(`chevronRight`);u.classList.add(`chev`);let f=e.rows.flatMap(e=>i.get(e.sceneId)?.video.id??[]);l.append(u,...f.length>0&&n.selectGroup!==void 0?[St(e.label,f,n)]:[],z(`h2`,{id:s},e.label),z(`span`,{class:`section-count`,"data-section-count":``},String(e.rows.length))),c.append(l);let p=z(`div`,{class:`rows`}),m=e.rows.map(t=>{let s=i.get(t.sceneId)??null,c=an(t,n,bn(t,s,r),e.namesDay,s,r,s!==null&&a.has(s.video.id),o);return p.append(c),[t.sceneId,c]});return c.append(p),{box:c,articles:m}}function Sn(e,t,n,r=!1){let i=z(`section`,{class:`section`,id:vn,"data-unreadable":``,"aria-labelledby":`section-unreadable`}),a=z(`div`,{class:`section-head`});if(a.append(z(`h2`,{id:`section-unreadable`},`Couldn't read`),z(`span`,{class:`section-count`},String(e.length))),i.append(a),r)return i.append(wn(e,t,n)),i;let o=z(`div`,{class:`rows`});for(let r of e){let e=z(`article`,{class:`card`,"data-unreadable-row":r.folder}),i=z(`div`,{class:`row-text`}),a=z(`div`,{class:`row-title`});a.append(z(`p`,{class:`row-meta`,"data-unreadable-name":``},r.folder));let s=kt(r),c=Cn(r,t);c!==null&&a.append(c),i.append(a,z(`p`,{class:`row-meta`,"data-reason":``},r.reason)),r.sizeBytes!==void 0&&i.append(z(`p`,{"data-size":``,class:`row-size`},C(r.sizeBytes))),e.append(i);let l=s===null?void 0:n.get(R(s,r.folder));l!==void 0&&e.append(z(`p`,{"data-status":``,class:`notice notice-error`},l)),o.append(e)}return i.append(o),i}function Cn(e,t){let n=kt(e);if(n===null)return null;let r=z(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${e.folder}`,title:`Delete`});return r.append(d(`trash`)),r.addEventListener(`click`,()=>t.remove(e.folder,n)),r}function wn(e,t,n){let r=z(`div`,{class:`unreadable-list`});for(let i of e){let e=z(`div`,{class:`unreadable-row`,"data-unreadable-row":i.folder}),a=z(`span`,{"data-col":`actions`}),o=Cn(i,t);o!==null&&a.append(o),e.append(z(`span`,{"data-col":`name`,"data-unreadable-name":``,title:i.folder},i.folder),z(`span`,{"data-col":`where`,"data-reason":``,title:i.reason},i.reason),z(`span`,{"data-col":`size`,"data-size":``},i.sizeBytes===void 0?`—`:C(i.sizeBytes)),a);let s=kt(i),c=s===null?void 0:n.get(R(s,i.folder));if(c!==void 0){let t=z(`div`,{"data-status":``});t.append(z(`p`,{class:`notice notice-error`},c)),e.append(t)}r.append(e)}return r}function Tn(e,t,n,r){let i=z(`p`,{class:`none-here`,"data-none-here":``});i.append(`None here.`);for(let[a,{place:o,count:s}]of e.entries()){let e=z(`a`,{href:`${m(o)}&q=${encodeURIComponent(n)}`,"data-place":m(o)});e.append(`${s} in `,...Yt({place:o,rail:t})),e.addEventListener(`click`,e=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),r.goPlace?.(o))}),i.append(a===0?` `:`, `,e)}return e.length>0&&i.append(`.`),i}function En(e,t,n,r,i=new Date,a,o,s,c){let l=mn(e),u=_n(e),d=pn(e),f=new Set([...e.querySelectorAll(`[data-list] [data-key]`)].map(e=>e.dataset.key)),p=fn.get(e),m={collapsed:new Set([...[...p?.collapsed??[]].filter(e=>!f.has(e)),...pt(e)]),drawn:new Set([...p?.drawn??[],...f])};fn.set(e,m);let h=Je(e.querySelector(`[data-list]`)),g=Qt.get(e);g===void 0&&(g=Xt(n.reclaim!==void 0&&n.setBudget!==void 0),Qt.set(e,g)),g.update(t,n,s,c);for(let t of[...e.childNodes])t!==g.box&&t.remove();g.box.parentNode!==e&&e.prepend(g.box),jt(g.tabsRow);for(let e of[...g.content.childNodes])e!==g.notices&&e!==g.tabsRow&&e.remove();let _=g.content,b=c===void 0||c.place===`unreadable`?t.unreadable??[]:[],x=c===void 0||typeof c.place==`string`,S=c?.search,C=S?.query??``,w=S!==void 0&&c!==void 0&&c.place!==`unreadable`&&Te(C),T=()=>{b.length>0&&_.append(Sn(b,n,r,s?.layout===`list`))};if(t.rows.length===0){if(It(e,n,void 0),w){_.append(Tn(S.elsewhere,c.rail,C,n));return}if(b.length>0){T();return}if(c!==void 0&&c.rail.all>0)return;let r=z(`div`,{"data-empty":``,class:`card empty-card`});r.append(Ie(`monitorPlay`,`No flows yet`,t.emptyHint??`Click the Demoman icon in your browser's toolbar and press Record. Each video shows up here, grouped by the day you made it.`)),_.append(r);return}let E=y(t),D=nt(E,x),O=E.map(e=>e.row),k=new Map(E.flatMap(e=>e.group===null?[]:[[e.row.sceneId,e.group]])),A=[],j=w?S.sort??{rank:e=>De(e,C)}:null;if(s?.layout===`list`){let c=wt(_,t,n,r,i,s,m,x,j??s.sort,w?e=>Oe(e,C):void 0);T();for(let e of c.querySelectorAll(`[data-scene]`))n.measure?.(e.dataset.scene,e.querySelector(`[data-col="length"]`));let u=hn(e,l);It(e,n,a,o),u||Ye(c,h);return}if(j!==null){let e=z(`div`,{class:`rows`,"data-results":``});for(let a of ut(t,j,i)){if(a.kind!==`flow`)continue;let{row:t,group:i}=a.card,o=an(t,n,bn(t,i,r),!1,i,r,i!==null&&d.has(i.video.id),D,Oe(a.card,C));e.append(o),A.push([t.sceneId,o])}_.append(e)}for(let e of j===null?v(O,i):[]){let t=xn(e,u.get(e.key)??!e.folded,n,r,k,d,D);_.append(t.box),A.push(...t.articles)}T();for(let[e,t]of A)n.preview(e,t.querySelector(`[data-preview]`));hn(e,l),It(e,n,a,o)}var Dn=document.querySelector(`#root`),On=document.querySelector(`#notice`),V=p(),kn=V.scenes;V.nav.onOpen?.(e=>location.assign(e)),k(V);var H=new Map;function U(e,t){On.textContent=e,On.className=t===`info`?`notice`:`notice notice-${t}`,On.classList.remove(`hidden`)}function An(e){U(e,`error`)}function jn(){On.textContent=``,On.className=`notice notice-error hidden`}function W(e,t){console.error(`demoman library: ${e} —`,t),An(`Something went wrong (${e}). Try again.`)}function Mn(e,t){try{location.assign(e)}catch(e){W(t,e)}}var Nn=V.bundles,Pn=new Map,Fn=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=Pn.get(t.target);e!==void 0&&(Pn.delete(t.target),Fn?.unobserve(t.target),e())}},{rootMargin:`200px`}):null,In=!1,Ln=(e,t)=>Fn===null?(In||(In=!0,console.info(`demoman library: no IntersectionObserver here, so every preview paints at once`)),t(),()=>{}):(Pn.set(e,t),Fn.observe(e),()=>{Pn.delete(e),Fn.unobserve(e)}),Rn=new Map,zn={bundle:async e=>(await Nn.active(e)).bundle,length:async(e,t)=>{let r=Rn.get(e);if(r===void 0)throw Error(`no document for ${e} in the last listing`);return n(r,t,Nn.load)},image:async e=>{if(V.folder!==void 0)return V.folder.thumb(e);let t=await Nn.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:Ln},Bn=null,G=null;function Vn(e){let t=new Set([...e.rows.map(e=>R(`take`,e.sceneId)),...(e.groups??[]).map(e=>R(`video`,e.video.id)),...(e.unreadable??[]).flatMap(e=>{let t=kt(e);return t===null?[]:[R(t,e.folder)]})]);for(let e of H.keys())t.has(e)||H.delete(e)}var K=je(),q,J=a,Hn=V.libraryView.read().then(e=>{J=e.view,e.unreadable!==void 0&&console.warn(`demoman library: the stored view could not be used, so it is the default: ${e.unreadable}`)},e=>{console.warn(`demoman library: the stored view could not be read, so it is the default: ${e instanceof Error?e.message:String(e)}`)}),Y=null,Un=e(location.search),Wn=new URLSearchParams(location.search).get(`from`),Gn=`all`,X=new URLSearchParams(location.search).get(`q`)??``,Kn=null,qn=(e,t)=>ke(xe(e,t,Gn),X);function Jn(t){let n=J.project===null?null:e(`?project=${encodeURIComponent(J.project)}`);return n===null||n===`all`?`all`:(n===`unreadable`?(t.unreadable??[]).length:y(t).filter(e=>F(e)===(n===`none`?null:n.project)).length)>0?n:`all`}function Yn(e){if(Wn!==null){let t=y(e).find(e=>(e.group?.versions??[e.row]).some(e=>e.sceneId===Wn));if(t!==void 0){let e=F(t);return e===null?`none`:{project:e}}}return Un??Jn(e)}function Xn(e){let t=new URL(location.href);t.searchParams.delete(`from`),t.searchParams.delete(`project`);let n=t.searchParams.toString();return`${t.pathname}${m(e)}${n===``?``:`&${n}`}${t.hash}`}function Zn(){K=je(),q=void 0}function Z(e){Vn(e),q?.busy!==!0&&(K=Fe(K,new Set((e.groups??[]).map(e=>e.video.id)))),Bn?.dispose();for(let e of cr.splice(0))e();Bn=fe(zn),Y===null&&(Y=Yn(e),history.replaceState(history.state,``,Xn(Y)));let t=y(e);En(Dn,qn(e,Y),lr,H,void 0,K,q,J,{place:Y,tab:Gn,rail:_e(t,(e.unreadable??[]).length,Y),tabs:Ce(t,Y)?Se(y(ke(e,X)),Y):null,search:{query:X,sort:Kn,elsewhere:Ae(t,Y,`all`,X)}})}function Qn(){It(Dn,lr,K,q)}var $n=O({paint:e=>er({keepNotice:e}),onRefreshFailed:e=>W(`refreshing the library`,e)});function Q(){return $n.render()}async function er({keepNotice:e=!1}={}){e||jn();let[,t]=await Promise.all([Hn,V.folder.read()]),n=t.scenes;Rn=new Map(n.map(e=>[e.meta.id,e]));let r=S({videos:t.videos,videoOf:t.videoOf,sizes:t.sizes,unreadable:t.unreadable,unwatched:t.unwatched,emptyHint:V.nav.firstTakeHint(),scenes:n,migrating:!1,migrationFailed:!1,notice:null,needsLook:new Set});G=r,Z(r)}var tr={recording:`a video is being recorded`,rendering:`a render is running`,sharing:`a share is in progress`,replaying:`a video is being run in Runs`},$=new Map;function nr(e,t,n){let r=$.get(e)??$.get(rr(e)??``);if(r===void 0){Mn(t,n);return}r.then(e=>{e&&Mn(t,n)})}function rr(e){return G?.groups?.find(t=>t.versions.some(t=>t.sceneId===e))?.video.id}function ir(e,t){if(t===`record`)return c;if(t===`video`){let t=G?.groups?.find(t=>t.video.id===e);if(t===void 0)return f;let n=o(t.video.versions),r=_(t.video);return r===null?n:{...n,body:`${n.body} ${r}`}}if(t===`take`){let t=G?.groups?.find(t=>t.versions.some(t=>t.sceneId===e));if(t!==void 0){let n=t.versions.find(t=>t.sceneId===e)?.version;return l(n,t.video.name)}}return f}var ar={video:`Deleted the flow`,take:`Deleted the video`,folder:`Deleted the folder`,record:`Deleted the flow record`};function or(e){return Rn.get(e)?.meta.capture.mode===`authored`}var sr=ae(),cr=[],lr={setView:e=>{if(Te(X)&&e.layout===J.layout){Kn={...e.sort},G!==null&&Z(G);return}J=e,G!==null&&Z(G),V.libraryView.write(e).then(e=>{e.replaced!==void 0&&(console.warn(`demoman library: ${e.replaced}`),U(e.replaced,`warn`))},e=>{let t=e instanceof Error?e.message:String(e);console.warn(`demoman library: the view was not saved: ${t}`),U(`The view was not saved: ${t.replace(/\.$/,``)}.`,`warn`)})},goPlace:e=>{q?.busy!==!0&&(Y=e,Gn=`all`,Zn(),location.search!==new URL(Xn(e),location.href).search&&history.pushState(history.state,``,Xn(e)),G!==null&&Z(G),J={...J,project:typeof e==`string`?e:e.project},V.libraryView.write(J).then(e=>{e.replaced!==void 0&&(console.warn(`demoman library: ${e.replaced}`),U(e.replaced,`warn`))},e=>{console.warn(`demoman library: the project picked was not saved: ${e instanceof Error?e.message:String(e)}`)}))},search:e=>{X=e,Te(e)||(Kn=null),q?.busy!==!0&&G!==null&&Y!==null&&(K=Fe(K,new Set((qn(G,Y).groups??[]).map(e=>e.video.id))));let t=new URL(location.href);e===``?t.searchParams.delete(`q`):t.searchParams.set(`q`,e),history.replaceState(history.state,``,t),G!==null&&Z(G)},goTab:e=>{q?.busy!==!0&&(Gn=e,Zn(),G!==null&&Z(G))},measure:(e,t)=>{let r=n=>{let r=n instanceof Error?n:Error(String(n));console.warn(`demoman library: length of ${e} could not be measured: ${r.message}`),oe(t,r)},i=Rn.get(e);if(i===void 0){r(Error(`no document for ${e} in the last listing`));return}let a=sr.get(i);if(a!==void 0){oe(t,a);return}let o=Ln(t,()=>{Nn.active(e).then(({bundle:e})=>e===null?{kind:`nothing`,reason:`it has no frames`}:sr.measure(i,()=>n(i,e,Nn.load))).then(e=>oe(t,e),r)});cr.push(o)},preview:(e,t)=>{if(Bn===null){console.error(`demoman library: a row asked for a preview before the page had a mounter`);return}Bn.mount(e,t)},edit:e=>{nr(e,V.nav.editor(e),`opening the editor`)},rename:(e,t)=>{let n=(async()=>{try{let n=null;try{let r=await kn.get(e);if(r===null)n=`the video is no longer stored`;else{let e={...r.scene,meta:{...r.scene.meta,name:t}};await kn.put(e,r.revision)}}catch(e){n=e instanceof Error?e.message:String(e)}let r=R(`take`,e);return n===null?H.delete(r):H.set(r,`Couldn't rename: ${n}.`),await Q(),n===null}catch(t){return W(`renaming it`,t),H.set(R(`take`,e),`Couldn't rename: ${t instanceof Error?t.message:String(t)}.`),G!==null&&Z(G),!1}})();$.set(e,n),n.finally(()=>{$.get(e)===n&&$.delete(e)})},renameVideo:(e,t)=>{let n=(async()=>{let n=R(`video`,e),r=null;try{await V.videos.rename(e,t)}catch(e){r=e instanceof Error?e.message:String(e)}r===null?H.delete(n):H.set(n,`Couldn't rename: ${r.replace(/\.$/,``)}.`);try{await Q()}catch(e){W(`refreshing the library`,e)}return r===null})();$.set(e,n),n.finally(()=>{$.get(e)===n&&$.delete(e)})},restore:e=>{let t=V.nav.rerun(e,or(e));if(t.kind===`line`){console.error(`demoman library: Restore was pressed on a platform whose route is a line`);return}nr(e,new URL(t.href,V.nav.library()).href,`opening Runs to restore motion`)},rerunLine:(e,t)=>{let n=V.nav.rerun(e,t);return n.kind===`line`?n.text:null},backToRecording:e=>{(async()=>{let t=null,n=await $.get(e),r=R(`take`,e),i=n===!1?H.get(r):void 0;try{let n=await kn.get(e);if(n===null)throw Error(`the video is no longer stored`);let r={...n.scene,meta:{...n.scene.meta,renderMode:`screen`}};await kn.put(r,n.revision);let i=(await Nn.active(e)).bundle;i?.source!==`capture`&&(t=i===null?`The original footage could not be put back: no frames could be read for this video.`:`There is no original footage of this video to go back to, so it keeps its re-shot frames. Videos rebuilt before original footage was kept have none.`,console.info(`[demoman] library: back to the original footage — not served (${i===null?`no bundle`:`serving ${i.source}`})`))}catch(e){W(`going back to the original footage`,e),t=`Couldn't go back to the original footage: ${e instanceof Error?e.message:String(e)}.`}let a=[i,t].filter(e=>e!=null).join(` `);a===``?H.delete(r):H.set(r,a);try{await Q()}catch(e){W(`refreshing the library`,e)}})()},select:(e,t,n,r)=>{q?.busy!==!0&&(K=Me(K,e,t,n,r),q=void 0,Qn())},selectAll:e=>{q?.busy!==!0&&(K=Ne(K,e),q=void 0,Qn())},selectGroup:e=>{q?.busy!==!0&&(K=Pe(K,e),q=void 0,Qn())},clearSelection:()=>{q?.busy!==!0&&(K=je(),q=void 0,Qn())},deleteSelected:()=>{ur()},remove:(e,t)=>{if(q?.busy===!0)return;let n=R(t,e);(async()=>{try{let r;try{r=await u(ir(e,t))}catch(e){console.error(`demoman library: asking before a delete —`,e),H.set(n,`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`),await Q();return}if(!r)return;let i=G?.groups?.find(t=>t.video.id===e),a=t===`video`&&i!==void 0?_(i.video):null,o=e=>a===null?e:`${e} ${a}`;await $.get(e);let s=t===`video`||t===`record`?await V.videos.remove(e):await kn.remove(e),c=null;if(!s.ok){let e=s.detail??tr[s.error]??s.error;H.set(n,`Not deleted: ${e}.`)}else if(s.partly!==void 0)H.delete(n),c=o(`Partly deleted: ${s.partly}.`);else if(s.result!==void 0&&!s.result.ok){let e=s.result.steps.find(e=>!e.ok),t=`Partly deleted: ${e?.step??`a step`} could not be removed — ${e?.error??`unknown error`}`;s.result.steps.find(e=>e.step===`scene`)?.ok===!0?(H.delete(n),c=t):H.set(n,t)}else H.delete(n);await Q(),c===null?s.ok&&s.note!==void 0?U(o(s.note),`info`):s.ok&&s.partly===void 0&&s.result?.ok!==!1&&D(a===null?ar[t]:`${ar[t]}. ${a}`):An(c)}catch(e){W(`deleting it`,e)}})()}};async function ur(){let e=new Map((G?.groups??[]).map(e=>[e.video.id,e.video])),n=[...K.ids].filter(t=>e.has(t));if(n.length===0||q?.busy===!0)return;let r=n.reduce((t,n)=>t+(e.get(n)?.versions??0),0),i=new Map(n.flatMap(t=>{let n=e.get(t),r=n===void 0?null:_(n);return r===null?[]:[[t,r]]})),a=t(n.length,r),o;try{o=await u(i.size===0?a:{...a,body:[a.body,...i.values()].join(` `)})}catch(e){console.error(`demoman library: asking before a bulk delete —`,e),q={busy:!1,said:`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`},Qn();return}if(!o)return;let s=n.filter(e=>K.ids.has(e));if(s.length===0)return;q={busy:!0,said:null},Qn();let c=[];for(let t of s){let n=e.get(t)?.name??t;try{let e=await V.videos.remove(t),r=[e.ok?e.note:void 0,i.get(t)].filter(e=>e!==void 0),a=r.length===0?{}:{note:r.join(` `)};e.ok&&e.partly!==void 0?c.push({id:t,name:n,stayed:`only part of it went: ${e.partly}`,...a}):e.ok?c.push({id:t,name:n,gone:!0,...a}):e.error===`videoNotFound`?c.push({id:t,name:n,gone:!0}):c.push({id:t,name:n,stayed:e.detail??tr[e.error]??e.error})}catch(e){c.push({id:t,name:n,stayed:e instanceof Error?e.message:String(e)})}}let l=w(c),d=new Set(c.flatMap(e=>`stayed`in e?[e.id]:[]));K=Fe(K,d),q=d.size===0?void 0:{busy:!1,said:l.text};try{await Q()}catch(e){W(`refreshing the library`,e)}d.size===0?c.some(e=>`gone`in e&&e.note!==void 0)?U(l.text,l.level):D(l.text):K.ids.size===0&&U(l.text,l.level)}window.addEventListener(`popstate`,()=>{Y=e(location.search)??`all`,Gn=`all`,X=new URLSearchParams(location.search).get(`q`)??``,Kn=null,q?.busy!==!0&&Zn(),G!==null&&Z(G)}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&K.ids.size!==0&&document.querySelector(`dialog[open]`)===null&&(document.activeElement?.matches(`input:not([type=checkbox]), textarea`)||lr.clearSelection?.())}),document.addEventListener(`keydown`,e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=document.querySelector(`[data-search]`);if(t===null||t.closest(`[hidden]`)!==null||document.querySelector(`dialog[open]`)!==null)return;let n=document.activeElement;n?.matches(`input:not([type=checkbox]), textarea, select`)!==!0&&n?.isContentEditable!==!0&&(e.preventDefault(),t.focus())}),V.folder?.onChange(()=>$n.soon());var dr=x();Q().then(()=>{dr===`Deleted the video`?D(dr):dr!==null&&U(dr,`info`)},e=>{dr!==null&&console.info(`demoman library: ${dr}`),W(`loading your flows`,e)});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,P as t,S as n,_t as r,b as i,ft as a,h as o,m as s,p as c,pt as l,r as u,s as d,u as ee,x as te}from"./confirm-dialog-F4BR4FU0.js";import{C as f,D as ne,E as p,T as re,g as m,i as h,k as ie,n as g,r as ae,t as oe,x as se}from"./view-DzaxHB2c.js";import{n as ce,r as le,t as ue}from"./topbar-CgsXzkpk.js";function de(e,t,n=.3){if(e.length===0)return null;if(t.atFoot)return e[e.length-1]?.id??null;let r=e[0]?.id??null;for(let i of e)i.top<=t.height*n&&(r=i.id);return r}var fe=800;function pe(e){let t=null,n,r=()=>[...e.querySelectorAll(`a[data-nav]`)],i=e=>{for(let t of r())t.setAttribute(`aria-current`,String(t.dataset.nav===e))},a=()=>{if(t!==null)return i(t);let e=document.documentElement,n=r().flatMap(e=>{let t=e.dataset.nav??``,n=document.getElementById(t);return n===null?[]:[{id:t,top:n.getBoundingClientRect().top}]});i(de(n,{height:window.innerHeight,atFoot:window.scrollY+window.innerHeight>=e.scrollHeight-2}))};return e.addEventListener(`click`,e=>{let r=e.target?.closest(`a[data-nav]`);r!=null&&(t=r.dataset.nav??null,i(t),clearTimeout(n),n=setTimeout(()=>{t=null,a()},fe))}),window.addEventListener(`scroll`,a,{passive:!0}),window.addEventListener(`resize`,a),{mark:a}}function me(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`,d(`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(d(`close`)),o.addEventListener(`click`,r),e.className=n===`info`?`notice notice-line`:`notice notice-line notice-${n}`,e.replaceChildren(...n===`info`?[]:[d(`circleAlert`)],i,o)}function _(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 v=document.querySelector(`#root`),he=pe(v),y=document.querySelector(`#notice`),b=ee(),x=b.kits,S={state:`ready`,kits:[],defaultId:null,migrationPending:!1},C=null,w=null,T=null,E=null,D=null,O=new Map,k=new Map,A=Promise.resolve(),j=null;function M(e){let t=p(e,g),n=O.get(t);return n===void 0&&(n=A.then(()=>se(e,g,b.wallpapers)).then(e=>({ok:!0,image:e.image}),e=>({ok:!1,error:W(e)})),A=n,O.set(t,n),n.then(e=>k.set(t,e))),n}function N(e){if(!f(e))return null;let t=k.get(p(e,g));return t?.ok?t.image:null}async function ge(e){let t=e.background,n=f(t)?M(t):null;if(S.state===`ready`)for(let e of S.kits){if(e.read.state!==`ready`)continue;let t=e.read.kit.background;if(!f(t))continue;let n=p(t,g);O.has(n)||M(t).then(()=>ye(e.id))}if(n===null)return;let r=await n;if(t.kind!==`image`||j?.ref===t.ref&&j.thumb?.kind===`ready`)return;let i;if(!r.ok)i={kind:`failed`,reason:r.error};else try{i={kind:`ready`,url:await ne(r.image)}}catch(e){i={kind:`failed`,reason:W(e)}}let a=j?.thumb;a?.kind===`ready`&&a!==i&&URL.revokeObjectURL(a.url),j={ref:t.ref,thumb:i}}var _e=()=>S.state===`ready`?S.kits.find(e=>e.id===C)??null:null,P=()=>{let e=_e();return e?.read.state===`ready`?e.read.kit:a};function F(){S.state===`ready`&&(S.kits.some(e=>e.id===C)||(C=e(S)?.id??S.kits[0]?.id??null))}var I=0;async function L(e){let t=null,n=await x.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?(I+=1,S=await x.read(),F(),t===null?null:{warn:`Your default kit was missing, so "${t}" is the default now.`}):n}async function R(e){let t=null,n=await e(e=>(t=e,e));return typeof n!=`string`&&t!==null&&(C=t,F()),n}var z=null;function B(e,t){return L(async r=>{if(r.kits.length===0){let e=await t(a);if(typeof e==`string`)return e;let n=s();return C=n,z=n,{kits:[{id:n,name:`Brand kit`,branding:e}],defaultId:n}}let i=e??z,o=r.kits.find(e=>e.id===i);if(o===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 c=n(o.branding),l=await t(c.state===`ready`?c.kit:a);return typeof l==`string`?l:{...r,kits:r.kits.map(e=>e.id===i?{...e,branding:l}:e)}})}async function ve(e){let n=e.logo?.ref??null;if(n===null){w=null,T=null,E=null;return}if(w?.ref!==n){let e=await b.logos.load(n);w=e.ok?{ref:n,source:e.source,error:null}:{ref:n,source:null,error:e.error}}if(T=null,w.source!==null)try{T=await w.source.rasterAt(t(e,g))}catch(e){w={ref:n,source:null,error:W(e)}}if(w.source===null)E={kind:`failed`,reason:w.error??`the page did not try to load it`};else try{E={kind:`ready`,url:await ie(w.source)}}catch(e){E={kind:`failed`,reason:W(e)}}}function V(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;h(n,e,T,i,a,N(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!==C)continue;let o=S.state===`ready`?S.kits.find(e=>e.id===r):void 0;o?.read.state===`ready`&&H(n,r===C?e:o.read.kit,i,a)}}function H(e,t,n,r){let i=t.background,a=f(i)?k.get(p(i,g)):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(d(`circleAlert`)),o?.append(t)}else e.removeAttribute(`title`);h(e,t,null,n,r,N(i))||console.info(`demoman settings: a kit tile has no 2D context`)}function ye(e){if(e===C)return;let t=document.querySelector(`[data-kit-thumb="${CSS.escape(e)}"]`),n=S.state===`ready`?S.kits.find(t=>t.id===e):void 0;if(t===null||n?.read.state!==`ready`)return;let r=getComputedStyle(document.documentElement);H(t,n.read.kit,r.getPropertyValue(`--card`).trim()||`#ffffff`,Number.parseFloat(r.getPropertyValue(`--radius`))||0)}b.nav.onOpen?.(e=>we(e,()=>location.assign(e),new URL(e,location.href).searchParams.has(`scene`)?`Open the video`:`Open Flows`)),ue(b);var U=new Map,W=e=>e instanceof Error?e.message:String(e);function be(e,t){me(y,e,t,xe)}function G(e){be(e,`error`)}function xe(){y.replaceChildren(),y.className=`notice notice-error hidden`}function K(e,t){console.error(`demoman settings: ${e} —`,t),G({title:`Couldn't ${e}`,detail:W(t)})}function q(e,t){let n=U.get(e);U.set(e,n===void 0?t:`${n}. ${t}`)}async function Se(e,t,n){try{return await n()}catch(n){for(let r of typeof e==`string`?[e]:e)q(r,`Couldn't read ${t}: ${W(n)}`);return null}}var J=le({paint:e=>Ce({keepNotice:e}),onRefreshFailed:e=>K(`refresh Settings`,e),hold:Oe});function Y(){return J.render()}async function Ce({keepNotice:e=!1}={}){e||xe(),U.clear();let t=I,[n,r,i]=await Promise.all([x.read(),Se(`pullRequests`,`the Pull requests setting`,()=>b.pullRequests.read()),Se(`export`,`the Export quality setting`,()=>b.exportQuality.read())]);i?.unreadable!==void 0&&q(`export`,`Couldn't read the Export quality setting: ${i.unreadable}`),r?.unreadable!==void 0&&q(`pullRequests`,`Couldn't read the Pull requests setting: ${r.unreadable}`),I===t&&(S=n),F();let a=P();await ve(a),await ge(a);let o=a.background,s=f(o)?k.get(p(o,g)):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:x.unwatched(),brandKits:S,selectedKitId:C,brandKitLogo:a.logo===null?null:w?.source==null?{ok:!1,error:w?.error??`the page did not try to load it`}:{ok:!0},brandKitLogoThumb:a.logo===null?null:E,brandKitPlacement:ae(a,T),brandKitNotes:[w?.error?`The logo could not be loaded: ${w.error}`:null,D!==null&&D.ref===a.logo?.ref?D.note:null].filter(e=>e!==null),brandKitWallpaper:{custom:j,loadError:s?.ok===!1?s.error:null}};oe(v,c,Te,U),he.mark(),V(a)}var X=new Set;function Z(e,t){let n=(async()=>{let n;try{n=await t()}catch(t){return K(e,t),`failed`}try{await Y()}catch(t){return K(`show the result of: ${e}`,t),`failed`}return n===null?`done`:typeof n==`string`?(G(`Couldn't ${e}: ${n}.`),`failed`):(`warn`in n?be(n.warn,`warn`):ce(n.info),`done`)})();X.add(n),n.then(()=>X.delete(n))}function we(e,t,n){X.size>0&&console.info(`demoman settings: asked to open ${e}; waiting for ${X.size} change${X.size===1?``:`s`} here to save first`),(async()=>{let r=!1;for(;;){let e=J.pending();if((await Promise.all([...X])).includes(`failed`)&&(r=!0),await e.then(()=>void 0,()=>void 0),X.size===0&&J.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){K(`open ${e}`,t)}}),_(y,r)||(G(`A change here didn't save, so this window stayed on Settings.`),_(y,r));return}try{t()}catch(t){K(`open ${e}`,t)}})()}var Te={setPullRequests:e=>Z(`save the Pull requests setting`,async()=>{let t=await b.pullRequests.write(e);return t.replaced===void 0?null:{warn:t.replaced}}),setExportQuality:e=>Z(`save the Export quality setting`,async()=>{let t=await b.exportQuality.write(e);return t.replaced===void 0?null:{warn:t.replaced}}),setBrandKit:e=>{let t=C;Z(`save the brand kit`,()=>B(t,async t=>{let n=l.safeParse(m(t,e));return n.success?n.data:n.error.issues.map(e=>e.message).join(`; `)}))},previewBrandKit:e=>{try{V(m(P(),e),`selected`)}catch(e){console.info(`demoman settings: a brand kit preview did not apply`,e)}},uploadKitLogo:e=>{let t=C;Z(`add the logo`,async()=>{let n=te(e);if(!n.ok)return n.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: ${W(t)}`}let{ref:o}=await b.logos.put(e);return D=n.note===null?null:{ref:o,note:n.note},B(t,async e=>{let t=e.logo,n=t?{corner:t.corner,size:t.size,opacity:t.opacity}:r;return m(e,{logo:{ref:o,...n}})})})},uploadKitWallpaper:e=>{let t=C;Z(`add the image`,async()=>{let n;try{({ref:n}=await b.wallpapers.put(e))}catch(e){return W(e)}return B(t,async e=>m(e,{background:re(n,e.background)}))})},selectKit:e=>{C=e,Y().catch(e=>K(`select the kit`,e))},newKit:()=>Z(`add a kit`,()=>R(e=>L(async t=>{let n=e(s());return{kits:[...t.kits,{id:n,name:o(`Untitled kit`,t.kits),branding:a}],defaultId:t.defaultId??n}}))),duplicateKit:e=>Z(`duplicate the kit`,()=>R(t=>L(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(s()),name:o(`${r.name} copy`,n.kits),branding:structuredClone(r.branding)};return{...n,kits:[...n.kits,i]}}))),renameKit:(e,t)=>Z(`rename the kit`,()=>L(async n=>{let r=c(t,n.kits,e);return r.ok?{...n,kits:n.kits.map(t=>t.id===e?{...t,name:r.name}:t)}:r.reason})),setDefaultKit:e=>Z(`make the kit the default`,()=>L(async t=>t.kits.some(t=>t.id===e)?{...t,defaultId:e}:`the kit was deleted in another tab`)),deleteKit:e=>Z(`delete the kit`,async()=>{if(S.state!==`ready`)return`the kits could not be read`;let t=S.kits.find(t=>t.id===e);if(t===void 0)return`the kit was deleted in another tab`;if(S.kits.length===1)return`the last kit cannot be deleted`;let n=S.kits.find(t=>t.id!==e),r=S.defaultId===e&&n!==void 0?` "${n.name}" becomes the default kit.`:``;return await u({glyph:`trash`,title:`Delete "${t.name}"`,body:`"${t.name}" will be deleted.${r} Videos already made keep their look.`,confirmLabel:`Delete`,danger:!0,focus:`cancel`})?L(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:()=>Z(`start a fresh kit list`,async()=>{if(!await u({glyph:`trash`,title:`Start a fresh kit list`,body:`Your brand kits could not be read. Starting fresh replaces them with an empty list; videos already made keep their look.`,confirmLabel:`Start fresh`,danger:!0,focus:`cancel`}))return null;let{backup:e}=await x.reset();return I+=1,S=await x.read(),e===null?null:{info:`Started a fresh kit list. The old list is kept at ${e}.`}})},Ee=()=>J.soon(),Q=!1,De=new Set([`button`,`checkbox`,`file`,`radio`,`range`,`reset`,`submit`]);function Oe(){if(Q)return!0;let e=document.activeElement;return e===null||!v.contains(e)?!1:e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!De.has(e.type)}var $=()=>J.resume();v.addEventListener(`pointerdown`,()=>{Q=!0});for(let e of[`pointerup`,`pointercancel`])window.addEventListener(e,()=>{Q=!1,$()});v.addEventListener(`focusout`,()=>setTimeout($,0)),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Ee()}),x.onChange(Ee),Y().catch(e=>K(`load Settings`,e));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./confirm-dialog-F4BR4FU0.js";function e(e){let{toolchain:r,name:i,...a}=e.meta,{canvas:o,...s}=e;return n(t({...s,meta:a})).toString(16)}function t(e){if(typeof e!=`object`||!e)return JSON.stringify(e)??`null`;if(Array.isArray(e))return`[${e.map(t).join(`,`)}]`;let n=e;return`{${Object.keys(n).filter(e=>n[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${t(n[e])}`).join(`,`)}}`}function n(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)}function r(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 i=`note`,a=`Deleted the video`;function o(e,t){if(t===null||t===``)return e;let n=e.indexOf(`#`),r=n<0?e:e.slice(0,n),a=n<0?``:e.slice(n);return`${r}${r.includes(`?`)?`&`:`?`}${i}=${encodeURIComponent(t)}${a}`}function s(e=location,t=history){let n=new URL(e.href),r=n.searchParams.get(i);return r===null?null:(n.searchParams.delete(i),t.replaceState(t.state,``,`${n.pathname}${n.search}${n.hash}`),r===``?null:r)}function c(e){return e==null||`none`in e||e.commit===null?null:`${e.commit.slice(0,7)}${e.dirty?`*`:``}`}function l(e){return e.kept===null?null:`unknown`in e.kept?`"${e.name}" is in the repo, but its recipe could not be read (${e.kept.unknown}); only this machine's videos are deleted.`:`"${e.name}" stays in the repo (${e.kept.file}); only this machine's videos are deleted.`}function u(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 d(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 f(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 p={complete:`Complete`,reclaimed:`Motion reclaimed`,keyframesOnly:`Keyframes only`},m=`A budget has to be a number of GB above zero. Nothing was changed.`;function h(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 g=e=>{try{return new URL(e).host}catch{return e}},_=e=>{try{let t=new URL(e),n=t.hash.startsWith(`#/`)?t.hash.slice(1).split(`?`)[0]:``;return`${t.pathname.replace(/\/$/,``)}${n}`.replace(/\/$/,``)}catch{return``}};function v(e,t){return e.toLocaleString(void 0,{...t?{year:`numeric`}:{},month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}var y=864e5,b=e=>String(e).padStart(2,`0`),x=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function S(e,t){let n=x(t),r=new Map;for(let t of e){let e=new Date(t.createdAt),i,a,o=!0;if(Number.isNaN(e.getTime()))o=!1,i=`undated`,a=`Undated`;else{let t=Math.round((n-x(e))/y);t<=0?(i=`today`,a=`Today`):t===1?(i=`yesterday`,a=`Yesterday`):t<7?(i=`day:${e.getFullYear()}-${b(e.getMonth()+1)}-${b(e.getDate())}`,a=e.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`})):(i=`month:${e.getFullYear()}-${b(e.getMonth()+1)}`,a=e.toLocaleDateString(void 0,{month:`long`,year:`numeric`}),o=!1)}let s=r.get(i);s===void 0?r.set(i,{key:i,label:a,folded:!1,namesDay:o,rows:[t]}):s.rows.push(t)}return[...r.values()]}function C(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 w(e){let t=e.videoOf??{},n=new Map((e.videos??[]).map(e=>[e.id,e])),i=e=>e?.kept==null||`unknown`in e.kept||e.addedTo!==null?{}:{keptUnder:`key`in e.repo&&u(e.repo)||`No project`},a=new Map((e.summary?.demos??[]).map(e=>[e.sceneId,e])),o=[...e.scenes].sort((e,t)=>t.meta.createdAt.localeCompare(e.meta.createdAt)).map(o=>{let s=a.get(o.meta.id),c=s?.motion??(e.summary===void 0?`complete`:`keyframesOnly`),l=new Date(o.meta.createdAt),u=n.get(t[o.meta.id]?.videoId??``);return{sceneId:o.meta.id,name:o.meta.name,label:r(o.meta),origin:g(o.meta.capture.originUrl),path:_(o.meta.capture.originUrl),createdAt:o.meta.createdAt,when:v(l,!1),time:l.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}),hosted:s?.hosted??!1,recoverable:s?.recoverable??!1,frameBytes:s?.frameBytes??0,outputBytes:s?.outputBytes??0,state:p[c],canRestore:c===`reclaimed`,authored:o.meta.capture.mode===`authored`,servesReshoot:o.meta.renderMode===`demo`&&o.meta.capture.mode!==`authored`,needsLook:e.needsLook.has(o.meta.id),...e.sizes?.[o.meta.id]===void 0?{}:{sizeBytes:e.sizes[o.meta.id]},...t[o.meta.id]===void 0?{}:{version:t[o.meta.id]?.version,expired:t[o.meta.id]?.expired,exports:t[o.meta.id]?.exports,filmedCode:t[o.meta.id]?.filmedCode,kept:u?.kept??null,...i(u)}}}),{usedBytes:s,budgetBytes:c}=e.summary??{usedBytes:0,budgetBytes:0},l=null;if(e.notice?.pressureRemains){let t=o.slice().sort((e,t)=>t.frameBytes+t.outputBytes-(e.frameBytes+e.outputBytes)).slice(0,3).map(e=>`${e.label} (${h(e.frameBytes+e.outputBytes)})`).join(`, `);l=C(e.notice,t)}let f=e.sizes,m=new Set(o.map(e=>e.sceneId)),y=e.unreadable?.map(e=>f?.[e.folder]===void 0||m.has(e.folder)?{...e}:{...e,sizeBytes:f[e.folder]}),b=[...o,...y??[]];return{usedBytes:s,budgetBytes:c,fraction:c>0?Math.min(1,s/c):1,chromeNearLimit:e.notice?.reason===`quota`,migrating:e.migrating,migrationFailed:e.migrationFailed,notice:l,rows:o,...f===void 0?{}:{totalBytes:b.reduce((e,t)=>e+(t.sizeBytes??0),0),unmeasured:b.filter(e=>e.sizeBytes===void 0).length},...y===void 0?{}:{unreadable:y},...e.unwatched===void 0?{}:{unwatched:e.unwatched},...e.emptyHint===void 0?{}:{emptyHint:e.emptyHint},...e.videos===void 0?{}:{groups:d(o,t,e.videos)}}}function T(e){let t=e=>`${e} ${e===1?`flow`:`flows`}`,n=e.filter(e=>`gone`in e),r=e.flatMap(e=>`stayed`in e?[`${e.name} stayed: ${e.stayed.replace(/\.$/,``)}.`]:[]),i=e.flatMap(e=>e.note===void 0?[]:[e.note]);return r.length===0?{text:[`Deleted ${t(n.length)}.`,...i].join(` `),level:`info`}:{text:[n.length===0?`No flows were deleted.`:`Deleted ${n.length} of ${t(e.length)}.`,...r,...i].join(` `),level:`warn`}}export{e as _,c as a,l as c,S as d,v as f,r as g,o as h,f as i,_ as l,s as m,w as n,h as o,a as p,T as r,g as s,m as t,u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e}from"./confirm-dialog-F4BR4FU0.js";function t(e){let t=Promise.resolve(),n=0,r=0,i=!1,a=!1,o=!1;function s(i,a){let o=()=>a!==void 0&&r>=a?Promise.resolve():(r=n,e.paint(i));return t=t.then(o,o),t}function c(t){if(i=!0,e.hold?.()===!0){o=!0;return}s(!0,t).catch(e.onRefreshFailed).finally(()=>{i=!1,a&&(a=!1,c(n))})}return{render:()=>s(!1),soon(){let e=++n;if(i){a=!0;return}c(e)},resume(){!o||e.hold?.()===!0||(o=!1,a=!1,c(n))},pending:()=>t}}var n=4e3,r;function i(t){let i=document.querySelector(`[data-toast]`);i===null&&(i=document.createElement(`div`),i.className=`toast`,i.setAttribute(`data-toast`,``),document.body.append(i));let o=document.createElement(`span`);o.setAttribute(`data-toast-text`,``),o.textContent=t.replace(/\.$/,``),a(o.textContent),i.replaceChildren(e(`check`),o),clearTimeout(r);let s=i;r=setTimeout(()=>s.remove(),n)}function a(e){let t=document.querySelector(`[data-toast-said]`);t===null&&(t=document.createElement(`div`),t.className=`toast-said`,t.setAttribute(`data-toast-said`,``),t.setAttribute(`role`,`status`),document.body.append(t)),t.textContent=``;let n=t;setTimeout(()=>{n.textContent=e},50)}function o(e){document.querySelector(`a[data-tab="settings"]`)?.setAttribute(`href`,e.nav.kits())}export{i as n,t as r,o as t};
|