demoman 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/THIRD_PARTY_NOTICES +161 -1
- package/dist/demoman.mjs +749 -412
- package/dist/page/mux-entry.js +31 -2
- package/dist/page/render-entry.js +29 -2
- package/dist/recipe.md +9 -9
- package/dist/studio/assets/{confirm-dialog-DkCVzKzd.js → confirm-dialog-CN_GqXY_.js} +4 -4
- package/dist/studio/assets/editor-Cy1V14-4.js +4 -0
- package/dist/studio/assets/{library-C8XIahb7.js → library-CQtDqEvE.js} +1 -1
- package/dist/studio/assets/settings-C4OPkolR.js +1 -0
- package/dist/studio/assets/view-DsZQo9AJ.js +1 -0
- package/dist/studio/editor.html +3 -3
- package/dist/studio/icon/32.png +0 -0
- package/dist/studio/images/icon.svg +3 -6
- package/dist/studio/images/lockup_dark.svg +10 -13
- package/dist/studio/images/lockup_light.svg +10 -13
- package/dist/studio/images/logomark.svg +2 -8
- package/dist/studio/library.html +2 -2
- package/dist/studio/settings.html +3 -3
- package/dist/studio/studio-build.json +3 -3
- package/package.json +10 -1
- package/dist/studio/assets/controls-BoAnJbcP.js +0 -1
- package/dist/studio/assets/editor-APtBBZEt.js +0 -4
- package/dist/studio/assets/settings-Cs1_sqqR.js +0 -1
- package/dist/studio/icon/128.png +0 -0
- package/dist/studio/icon/16.png +0 -0
- package/dist/studio/icon/48.png +0 -0
- package/dist/studio/icon/recording/128.png +0 -0
- package/dist/studio/icon/recording/16.png +0 -0
- package/dist/studio/icon/recording/32.png +0 -0
- package/dist/studio/icon/recording/48.png +0 -0
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{A as e,B as t,F as n,G as r,H as i,I as a,J as o,K as s,L as c,O as l,P as u,R as d,U as f,V as p,W as m,X as h,Y as g,a as _,c as v,et as y,f as ee,g as b,h as x,it as te,k as ne,l as re,n as ie,nt as ae,o as oe,ot as se,q as ce,r as S,rt as le,s as ue,st as de,t as fe,u as pe,y as me,z as he}from"./confirm-dialog-DkCVzKzd.js";import{a as ge,b as _e,c as ve,d as ye,f as be,g as xe,h as Se,i as Ce,l as we,m as Te,n as C,o as Ee,p as De,r as Oe,s as ke,t as Ae,u as je,v as Me,y as Ne}from"./controls-BoAnJbcP.js";import{c as Pe,f as Fe,p as Ie,s as Le,u as Re}from"./state-COWbBf84.js";function ze(e,t){let{bundle:n,scene:r}=i(t,e),a=new Map(r.anchors.map(e=>[e.id,e])),o=new Map((n.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),s=new Map;for(let e of r.anchors)e.fingerprint.boundingRect&&s.set(e.id,e.fingerprint.boundingRect);let c=new Map;for(let e of n.anchorRects??[])c.set(e.actionId,e.rect);let l=(e,t)=>c.get(t)??s.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=o.get(t);if(r===void 0)return[{kind:`unknown`,actionId:t,reason:`noMarker`}];let i=e.anchorId===null?void 0:a.get(e.anchorId),s=e.anchorId===null?null:l(e.anchorId,t);if(s===null)return[{kind:`unknown`,actionId:t,reason:`noRect`}];if(i?.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:c,height:u}=n.viewport;return s.x<0||s.y<0||s.x+s.width>c||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 Be=64;function Ve(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 He(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 Ue(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(Be,Math.round(a.rect.width))),l=Math.max(1,Math.min(Be,Math.round(a.rect.height))),u;try{u=He(Ve(e,a.rect,t.viewport,c,l),Ve(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 We(e){return r.neutral.zoomHoldMs+ce(e).zoomOutMs}We(le.smoothness);var Ge=Math.abs(r.leadInMs)+r.neutral.minPlateauMs+400;function Ke(e){let t=`No zoom on click ${e.actionId}`,n=`gapMs`in e?`${Math.abs(e.gapMs)}ms ${e.gapMs<0?`before`:`after`} ${e.afterActionId}`:``;switch(e.reason){case`tooClose`:return`${t}: too close to the previous zoom (${n}, minimum ${Ge}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 ${qe}x).`;case`textTooWide`:return`${t}: target too wide to zoom without cutting text (would be ${e.scale}x, floor ${qe}x).`}}r.fitMarginPx;var qe=1.2,Je=`__demomanClickProbe`;`${Je}${JSON.stringify(`__demomanClickSeen`)}`,`${Je}`,`${Je}`;var Ye={mutating:`this flow writes data and rebuilding is switched off for it, so what you have is what this take itself recorded — turn on rebuilds for write flows, then rebuild it`,cancelledByAuthor:`you cancelled before it started, so this scene still has what the take itself recorded — re-shoot it in Runs to run it now`,unresolvedAnchor:`an element this demo depends on is no longer on the page — re-record that step, or remap its anchor`,ambiguousAnchor:`several elements matched this step, so replay stopped rather than risk clicking the wrong one — that target needs identifying more precisely`,anchorNotRendered:`an element had not been rendered yet — the page probably just needs scrolling further, and the take itself is likely fine`,pageSilent:`the page did not answer when replay asked it to find an element — the app may be down, offline, or showing a browser error page; check it loads, then run again`,pageFaulted:`the page itself threw an error when replay asked it to find an element, so nothing about the element was measured — the app is up; look at that page's own console for the fault, then run again`,anchorUnreachable:`replay found the element this step needs and then could not reach it to measure — nothing is wrong with the anchor, so re-recording that step will not help; run it again, and say so if it repeats`,anchorFrameMismatch:`replay found the element this step needs and the frame holding it is not the one recorded — the page's frames have changed since the take, so running it again will fail the same way; re-record that step`,redactedWithoutReplacement:`a typed value was withheld — a credential field, a secret-shaped value, or an editor whose text went unknown — and has no demo-safe replacement yet; select that step on the timeline and fill in Replace on-screen text, then run it again`,pageWentElsewhere:`the app moved to a different page partway through this script, and nothing in the script asked it to — either a step navigated, or the session expired and it went to a sign-in page; check the app is still signed in, and add a waitForLoad after any step that navigates, then run it again`,signedOut:`the app sent this browser to its sign-in page, so nothing was recorded — sign in again with demoman signin, then run it again`,unperformableStep:`this script asks for something the run cannot perform — a click with a button other than the left one — so it stopped rather than do something else and report success; change that step to a left click`,clickNotDelivered:`the browser put a click somewhere other than where it was sent, so the page never saw that click and the step did not happen — nothing is wrong with the steps; run it again, and say so if it repeats`,dragEndOutOfView:`a drag's start or end was off the page once its start was in view, and a drag cannot scroll while it moves, so it was not begun; drag to a target on the same screen, or scroll first`,dragNoDistance:`a drag's two ends landed on the same point once measured, which is a click, not a drag, so it was not begun; give the drag's end another target, spot or offset`,waitTimeout:`the page never reached a state the take was waiting for`,occlusionTimeout:`the render window stayed covered, so the frames would not have been usable`,windowClosed:`the replay window was closed before the run finished — nothing is wrong with the take, run it again`,debuggerUnavailable:`the debugger could not be attached to the replay tab — close DevTools on it and run again`,deviceFailed:`the browser refused to emulate the device, so nothing was recorded — the note says which command and why`,portFailure:`something underneath the run gave way — not a fault in the take, so re-recording will not fix it; run it once more, and if it stops the same way, report it`,noActions:`this take has no step that acts on the page, so there is nothing to record`};function Xe(e){return e in Ye?Ye[e]:e}function Ze(e){if(!e)return`(navigation)`;let t=e.fingerprint;return t.accessibleName??t.textContent??t.stableId??t.dataKey??e.id}function Qe(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:Ze(e.anchors.find(e=>e.id===n.anchorId))}:null}function $e(e,t){return Qe(e,t)}function et(e){return e.meta.capture.mode===`authored`}function tt(e){return e?`run its script again in Runs`:`re-shoot it in Runs`}function nt(e){let{toolchain:t,name:n,...r}=e.meta,{canvas:i,...a}=e;return it(rt({...a,meta:r})).toString(16)}function rt(e){if(typeof e!=`object`||!e)return JSON.stringify(e)??`null`;if(Array.isArray(e))return`[${e.map(rt).join(`,`)}]`;let t=e;return`{${Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${rt(t[e])}`).join(`,`)}}`}function it(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}var at={run:{phase:`idle`},save:null,error:null},ot=(e,t)=>e===null?t:`${e}; ${t}`;function st(e,t){let n=e.run.phase===`encoding`||e.run.phase===`queued`;switch(t.kind){case`queued`:return n?{flow:{...e,run:{phase:`queued`,position:t.position}},effect:`render`}:{flow:e,effect:`none`};case`rendering`:return n?{flow:{...e,run:{phase:`encoding`,done:t.done,total:t.total}},effect:`progress`}:{flow:e,effect:`none`};case`fileFailed`:return{flow:{...e,error:ot(e.error,t.line)},effect:`none`};case`saving`:return{flow:{...e,run:{phase:`saving`}},effect:`render`};case`saved`:return{flow:{...e,run:{phase:`idle`},save:t.save.kind===`saved`&&t.summary!==null?{...t.save,summary:t.summary}:t.save},effect:`render`};case`failed`:return{flow:{...e,run:{phase:`idle`},error:t.detail===null?e.error:ot(e.error,t.detail)},effect:`render`};case`outputsChanged`:return{flow:e,effect:`relist`}}}var ct=`motion reclaimed to free space`;function lt(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]=dt(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 ut(e,t=2){return String(Number(e.toFixed(t)))}function dt(e,t){for(let n=2;n<4;n++)if(ut(e,n)!==ut(t,n))return[ut(e,n),ut(t,n)];return[ut(e,4),ut(t,4)]}function ft(e,t){let n=e.some(e=>e.grantedScale<e.requestedScale),r=e.some(e=>e.sourceWidth<e.neededWidth),i=n&&r?`This export asked for more detail than the recording holds`:n?`Camera zoom was reduced on this export`:`This export is drawn from fewer pixels than it has`,a=new Map;for(let n of e){let e=t(n.outputTimeMs),r=n.grantedScale<n.requestedScale?`cut`:`short`,i=`${e??Math.floor(n.outputTimeMs/1e3)}|${r}`,o=a.get(i),s=n.sourceWidth/n.neededWidth;(!o||s<o.sourceWidth/o.neededWidth)&&a.set(i,n)}return{heading:i,lines:[...a.values()].map(e=>lt(e,t))}}function pt(e){let t=e.flatMap(e=>e.outputMs===null?[]:[{outputMs:e.outputMs,label:e.label}]).sort((e,t)=>e.outputMs-t.outputMs);return e=>{let n=null;for(let r of t)if(r.outputMs<=e)n=r.label;else break;return n}}function mt(e){return e?`Run its script again in Runs`:`Re-shoot this take in Runs`}function ht(e){let t=tt(e);return t.charAt(0).toUpperCase()+t.slice(1)}function gt(e){return e.rerun.kind===`line`?e.rerun.text:null}function _t(e,t,n){return t??`${ht(e)} ${n}.`}var w=1,T=e=>({kind:`refusal`,reason:e});function vt(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 yt(e){return new Map(e.markers.map(e=>[e.actionId,e.sourceTimeMs]))}function bt(e,t,n){return xt(e,g(t,n))}function xt(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 St(e,t,n){let r=yt(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}],s=[],c=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)}},l=[];for(let e of n.cuts){let t=e.ids.flatMap(e=>{let t=i.get(e);return t===void 0?[]:[t]}),l=(e,t)=>e===null?t:(r.get(e.actionId)??t)+e.sourceOffsetMs,u=vt(t,e=>l(e.start,-1/0)),d=vt(t,e=>-l(e.end,1/0));if(u===void 0||d===void 0)continue;let f=o(n,e.srcStartMs);a.push({atMs:f,left:u.start,right:d.end,rank:1,leftBeside:c(u),rightBeside:c(d)}),e.ids.forEach((t,n)=>{let r=i.get(t),a=r===void 0?null:c(r);s.push({removedId:t,atMs:f,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),c=[a?.start,a?.end].find(e=>e!=null&&r.has(e.actionId)),l=c===void 0?0:o(n,Math.max(0,Math.min(n.sourceDurationMs,(r.get(c.actionId)??0)+c.sourceOffsetMs)));s.push({removedId:t,atMs:l,index:s.filter(e=>Math.abs(e.atMs-l)<w).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){l.push(t.id);continue}let i=e+t.at.sourceOffsetMs;if(n.cuts.some(e=>i>=e.srcStartMs&&i<=e.srcEndMs))continue;let s=o(n,i);a.push({atMs:s,left:t.at,right:t.at,rank:1})}a.sort((e,t)=>e.atMs-t.atMs||e.rank-t.rank);let u=[];for(let e=0;e+1<a.length;e++){let t=a[e],n=a[e+1];n.atMs-t.atMs<w||u.push({startMs:t.atMs,endMs:n.atMs,start:t.right,end:n.left,before:t.rightBeside??null,after:n.leftBeside??null})}return{pieces:u,joins:s,unplacedSplits:l}}function Ct(e,t,n,r){if(t===null||n===null)return T(`Nothing has rendered yet, so there is no frame to split at.`);if(r<=0||r>=n.outputDurationMs)return T(`A split at the take's start or end splits nothing.`);let i=bt(t,n,r);if(i===null)return T(`These frames name no step, so there is nothing to split by.`);let a=yt(t).get(i.actionId)??0,s=o(n,a+i.sourceOffsetMs),{pieces:c}=St(e,t,n);return s<=w||s>=n.outputDurationMs-w||c.some(e=>Math.abs(e.startMs-s)<w)?T(Math.abs(s-r)<w?`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 wt=(e,t)=>e===null||t===null?e===t:e.actionId===t.actionId&&e.sourceOffsetMs===t.sourceOffsetMs;function Tt(e,t,n){let r=e.find(e=>wt(e.start,t));if(r===void 0)return T(`That piece is no longer on the timeline.`);if(e.length===1)return T(`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+w&&e.startMs<n.tailMs-w;if(t(r)&&e.filter(t).length===1)return T(`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 Et(e,t,n,r,i,a){let o=n.find(e=>wt(e.start,r));if(o===void 0)return T(`That piece is no longer on the timeline.`);if(e===null||t===null)return T(`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 T(`This piece is as short as a piece can be.`);let r=bt(e,t,n);return r===null?T(`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 T(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-w:u<=l.srcStartMs+w)return{kind:`restorePiece`,id:l.removedId};let d=xt(e,u);return d===null?T(`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 Dt=1e3;function Ot(e,t){return`Motion reclaimed to free space. ${_t(e,t,`to restore`)}`}var kt=new Set([`Motion reclaimed to free space. Replay to restore.`,`Motion reclaimed to free space. Rebuild to restore.`]);function At(e,t,n,r){return e===`motionReclaimed`?kt.has(t)||t===`Motion reclaimed to free space. Re-shoot it in Runs to restore.`?Ot(n,r):t:`${e}: ${t}`}var jt=(e,t)=>e.hasBundle?t.outputMs??t.captureMs:t.captureMs;function Mt(e){return e.hasBundle&&e.outputDurationMs!==null?e.outputDurationMs:(e.beats[e.beats.length-1]?.captureMs??0)+Dt}function Nt(e,t){let n=e.beats.find(e=>e.actionId===t.actionId);return(n?jt(e,n):0)+t.offsetMs}function Pt(e){let{scene:t,view:n,bundle:r,resolved:i}=e,a=et(t),s=e.rerunLine??null,c=e=>_t(a,s,e),l=Mt(n),u=[],d=new Set(e.hoverReport?.removable??[]),f=new Map(n.beats.map(e=>[e.actionId,jt(n,e)])),p=new Map(n.beats.map(e=>[e.actionId,e.timing])),m=e=>i===null?`estimated`:e?p.get(e.actionId)??`estimated`:`rendered`,h=n.beats.map(e=>({actionId:e.actionId,atMs:f.get(e.actionId)??0,verb:e.verb,label:e.label,timing:e.timing,flag:d.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,Nt(n,g.head)):0,headTiming:g?.head?`estimated`:`rendered`,tailMs:g?.tail?Math.min(l,Nt(n,g.tail)):l,tailTiming:g?.tail?`estimated`:`rendered`,headMarker:g?.head??null,tailMarker:g?.tail??null};for(let e of i?.trimUnplaced??[])u.push(`The trim's ${e} is placed from the take's own timestamp: the last render carried no marker for its step. ${c(`to give it measured timing`)}`);for(let e of i?.timeline.unplacedCuts??[])u.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??[])u.push(e.note);let y=new Map((i?.cameraSegments??[]).map(e=>[e.id,e])),{smoothness:ee}=t.motion??le,b=We(ee),{zoomInMs:x}=ce(ee),te=new Set,ne=t.camera.flatMap(e=>{let t=e.scale??1;if(t<=1)return[];let r=y.get(e.id);r||te.add(e.id);let i=r?r.startMs:Math.max(0,Nt(n,e.marker)),a=r?r.endMs:Math.min(l,e.end?Nt(n,e.end):i+b),o=e.point?{kind:`point`,x:e.point.x,y:e.point.y}:{kind:`element`,anchorId:e.anchorId??``};return r?.endUnplaced&&u.push(`The end of zoom "${e.id}" is placed from the take's own timestamp: the last render carried no marker for its step. ${c(`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`:m(e.marker):`estimated`,clamped:v.has(e.id),marker:e.marker,endMarker:e.end??null}]}),re=ne.map(e=>{if(!te.has(e.id))return e;let t=Math.min(...ne.map(e=>e.startMs).filter(t=>t>e.startMs));return e.endMs>t?{...e,endMs:t}:e}),ie=re.map(e=>te.has(e.id)?{...e,departMs:Ft(re,e.startMs,x)}:e),ae=ie.map(e=>({...e,drawnEndMs:It(ie,e.startMs,e.endMs)})),oe=new Set(t.camera.map(e=>e.marker.actionId));for(let e of t.zoomsSkipped??[])oe.has(e.actionId)||`afterActionId`in e&&!oe.has(e.afterActionId)||u.push(Ke(e));let se=new Map((i?.cosmetics??[]).map(e=>[e.id,e])),S=t.edits.masks.map(e=>{let t=e.start===void 0||e.end===void 0,r=se.get(e.id),a=r?.range??null;for(let t of r?.unplaced??[])u.push(`The ${t} of mask "${e.id}" is placed from the take's own timestamp: the last render carried no marker for its step, so the mask covers more of the video than it was drawn to. ${c(`to give it measured timing`)}`);let o=t?0:a?a.startMs:e.start?Math.max(0,Nt(n,e.start)):0,s=t?l:a?a.endMs:e.end?Math.min(l,Nt(n,e.end)):l;return{id:e.id,startMs:o,endMs:s,rect:e.rect,wholeTake:t,timing:t||i&&a&&m(e.start)===`rendered`&&m(e.end)===`rendered`?`rendered`:`estimated`,startMarker:e.start??null,endMarker:e.end??null}}),ue=e=>i?o(i.timeline,e):e,de=(r?.degradations??[]).map(e=>({startMs:ue(e.startMs),endMs:ue(e.endMs)}));for(let e of r?.degradations??[])u.push(At(e.kind,e.note,a,s));let fe=i?.timeline.unplacedPaces??0;if(fe>0){let e=fe===1?`pause`:`pauses`;u.push(`pacingUnplaced: ${fe} recorded ${e} could not be placed. The last render carried no marker for the steps they sit between, so this video is shorter than the take by however long those ${e} were. ${c(`to restore them`)}`)}let pe=i?.timeline.nonMonotonicPaces??0;if(pe>0){let e=pe===1?`pair`:`pairs`;u.push(`pacingBackwards: ${pe} step ${e} in this take carry timestamps that run backwards, so the take's order is not its time order. A re-shoot counts the pause across ${pe===1?`it`:`them`} twice and comes out longer than the take. Re-record to straighten the order; the frames you already have are unaffected.`)}let{pieces:me,joins:he,unplacedSplits:ge}=r!==null&&i!==null?St(t,r,i.timeline):{pieces:[],joins:[],unplacedSplits:[]};for(let e of ge)u.push(`A split is not drawn: the last render carried no marker for its step. ${c(`to place it`)}`);return{clip:{durationMs:l,trim:_,ticks:h,degraded:de,pieces:me,joins:he},zooms:ae,masks:S,durationMs:l,timeSource:n.hasBundle?`rendered`:`captured`,authored:a,rerunLine:s,hoverCheck:{failed:e.hoverReport?.failed??!1,unchecked:e.hoverReport?.unchecked??0},notices:u,zoomDefaultMs:b,zoomInMs:x}}function Ft(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 It(e,t,n){return Math.min(n,...e.filter(e=>e.startMs>t).map(e=>e.departMs))}function E(e,t,n){let r=e.clip.ticks,i=r[0];if(!i)throw Error(`a take with no steps has nothing to attach an edit to`);let a=i;for(let e of r){let n=Math.abs(e.atMs-t),r=Math.abs(a.atMs-t);(n<r||n===r&&e.atMs<a.atMs)&&(a=e)}let o=Math.round(t-a.atMs);return{actionId:a.actionId,offsetMs:Math.abs(o)<=n?0:o}}function Lt(t){let{resolved:n,outputTimeMs:r,presentation:i,target:a,viewport:o}=t;return s(m(n,r),e(i.frameRect,o),i.frameRect,o,a)}var Rt=(e,t,n)=>Math.min(n,Math.max(t,e));function zt(e,t){let n=e.width/2,r=e.height/2;return{x:Rt(t.x-n/2,0,e.width-n),y:Rt(t.y-r/2,0,e.height-r),width:n,height:r}}function Bt(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,s=Lt({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o});return l(t,s,i.frameRect,o)}function Vt(e){let{rect:t,resolved:r,target:i,presentation:a,outputTimeMs:o}=e,s=r.plan.viewport,c=Lt({resolved:r,outputTimeMs:o,presentation:a,target:i,viewport:s}),l=n(t,c,a.frameRect,s),u=Rt(l.x,0,s.width),d=Rt(l.y,0,s.height),f=Rt(l.x+l.width,0,s.width),p=Rt(l.y+l.height,0,s.height);return{x:u,y:d,width:f-u,height:p-d}}function Ht(e){let{zoom:t,resolved:r,viewport:i,presentation:a,target:o}=e,s=Lt({resolved:r,outputTimeMs:(t.startMs+t.endMs)/2,presentation:a,target:o,viewport:i});return n({x:0,y:0,width:o.width,height:o.height},s,a.frameRect,i)}var Ut=2e3,Wt=e=>e!==null&&e.kind===`refusal`,D=e=>({kind:`refusal`,reason:e});function Gt(e,t){if(e.resolved===null||e.bundle===null)return{reason:`nothing has rendered yet`};if(e.bundle.cursorSamples.length===0)return{reason:`this take has no recorded pointer`};let n=g(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=p(e.resolved.cursor,n);return r?{point:r}:{reason:`the pointer was not observed here`}}var Kt=(e,t)=>e.zooms.find(e=>e.id===t),qt=(e,t)=>e.masks.find(e=>e.id===t);function Jt(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=Yt(a,i,n,r);if(e)return{zoom:a,why:e}}}function Yt(e,t,n,r){let i=Math.abs(n-e.startMs);if(i<Ge&&(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 Xt({zoom:e,why:t}){switch(t){case`start`:return D(`That would start it within ${Ge}ms of the zoom "${e.id}" at ${Zt(e.startMs)}; the camera needs ${Ge}ms between two zooms to glide from one to the other.`);case`endsAfter`:return D(`That would end it after the zoom "${e.id}" starts at ${Zt(e.startMs)}; a zoom can stay in until the next one, not past it.`);case`startsInside`:return D(`That would start it before the zoom "${e.id}" ends at ${Zt(e.endMs)}; drag that zoom's end earlier first.`)}}var Zt=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 Qt(e){let{leadInMs:t}=r;return{earliestMs:e+t,latestMs:e}}function $t(e,t){let{leadInMs:n}=r,i=e.zoomDefaultMs-n,a=(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}},o=t=>{let{earliestMs:n,latestMs:r}=Qt(t);return e.zooms.find(e=>Yt(e,void 0,n,null)!==void 0||Yt(e,void 0,r,null)!==void 0)},s=o(t);if(!s)return a(t,null);let c=s;for(let t=0;t<=e.zooms.length&&c;t++){let t=Math.max(c.startMs+Ge,c.endAuthored?c.endMs:-1/0)-n;if(t+i+n>e.durationMs)break;let r=o(t);if(!r)return a(t,{zoom:c,side:`after`});c=r}c=s;for(let t=0;t<=e.zooms.length&&c;t++){let e=c.startMs-Ge;if(Qt(e).earliestMs<0)break;let t=o(e);if(!t)return a(e,{zoom:c,side:`before`});c=t}return D(`There is no room for a zoom here: it would run into the zoom "${s.id}" at ${Zt(s.startMs)}, and there is no slot either side of it. Drag that zoom to make space, or remove one.`)}function en(e,t){let{trim:n}=e.clip;if(t>n.tailMs-200)return D(`Move the playhead earlier: a mask needs some of the video after it to cover.`);let r=e.clip.ticks.find(e=>e.atMs>t+1)?.atMs??1/0;return{kind:`span`,startMs:t,endMs:Math.min(r,t+Ut,e.durationMs)}}function O(e,t){return t!==null&&e.actionId===t.actionId&&t.offsetMs<=e.offsetMs}var tn=e=>D(`That would leave the ${e} no length; drag its end further.`),nn=e=>D(`The cut would leave nothing: that puts the ${e} on the same step as the ${e===`head`?`tail`:`head`}. Drag it further away, or move the other end first.`);function rn(e,t){let n=e.clip.ticks,r=n.findIndex(e=>e.actionId===t);return r===-1?void 0:n[r+1]}function an(e,t,n,i){let{durationMs:a}=e;if(e.clip.ticks.length===0)return D(`This take has no steps to attach an edit to.`);switch(n.kind){case`pieceEdge`:return Et(i.bundle,i.resolved?.timeline??null,e.clip.pieces,n.start,n.side,n.deltaMs);case`trim`:{let{trim:t}=e.clip;if(n.edge===`head`){if(n.toMs<=0)return{kind:`setTrim`,head:null};if(n.toMs>t.tailMs-200)return D(`The cut would leave nothing: the head has to stay at least 200ms before the tail.`);let r=E(e,n.toMs,n.snapMs);return O(r,t.tailMarker)?nn(`head`):{kind:`setTrim`,head:r}}if(n.toMs>=a)return{kind:`setTrim`,tail:null};if(n.toMs<t.headMs+200)return D(`The cut would leave nothing: the tail has to stay at least 200ms after the head.`);let r=E(e,n.toMs,n.snapMs);return t.headMarker&&O(t.headMarker,r)?nn(`tail`):{kind:`setTrim`,tail:r}}case`addZoom`:{let a=$t(e,n.atMs);if(Wt(a))return a;let{atMs:o,movedPast:s}=a,c=E(e,o,s?0:n.snapMs),l=s?`Placed ${s.side} the zoom at ${Zt(s.zoom.startMs)}: there was no room at ${Zt(n.atMs)}.`:null,u=r.defaultZoomScale,d=Gt(i,o);if(`point`in d)return{kind:`addZoom`,marker:c,target:{kind:`point`,x:d.point.x,y:d.point.y},scale:u,...l===null?{}:{note:l}};let f=[...e.clip.ticks].filter(e=>e.canZoom).sort((e,t)=>Math.abs(e.atMs-o)-Math.abs(t.atMs-o))[0],p=f?t.beats.find(e=>e.actionId===f.actionId)?.anchorId:null;if(!f||!p)return D(`There is nothing to aim at here: ${d.reason}, and no step on this take has an element on screen.`);let m={kind:`element`,anchorId:p},h=`Aimed at "${f.label}" instead of the cursor: ${d.reason}.`;return{kind:`addZoom`,marker:c,target:m,scale:u,note:l?`${l} ${h}`:h}}case`moveZoom`:{let t=Kt(e,n.id);if(!t)return D(`There is no zoom "${n.id}" to move.`);if(n.deltaMs===0)return null;let r=t.startMs+n.deltaMs,i=t.endMs+n.deltaMs;if(r<0)return D(`A zoom cannot start before the take does.`);if(i>a)return D(`A zoom cannot end after the take does.`);let o=Jt(e,t.id,r,t.endAuthored?i:null);if(o)return Xt(o);let s=E(e,r,n.snapMs),c=t.endAuthored?E(e,i,n.snapMs):null;return O(s,c)?tn(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}case`zoomEdge`:{let t=Kt(e,n.id);if(!t)return D(`There is no zoom "${n.id}" to resize.`);if(n.edge===`start`){let r=Math.max(0,n.toMs);if(r>t.drawnEndMs-100)return D(`A zoom's start cannot cross its end; it would start after the zoom already ends. Drag the end later first.`);let i=r+e.zoomInMs;if(t.endAuthored&&i>t.endMs-100)return D(`Zooming in from there, it would land at ${Zt(i)}, after its end at ${Zt(t.endMs)}. Drag the end later first.`);let a=Jt(e,t.id,i,null);if(a)return Xt(a);let o=E(e,r,n.snapMs),s={...o,offsetMs:o.offsetMs+e.zoomInMs},c=t.endMarker;return O(s,c)?tn(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}if(n.toMs>a)return D(`A zoom cannot end after the take does.`);if(n.toMs<t.startMs+100)return D(`A zoom's end cannot cross its start; it would end before it starts. Drag the start earlier first.`);let r=Jt(e,t.id,t.startMs,n.toMs);if(r)return Xt(r);let i=t.marker,o=E(e,n.toMs,n.snapMs);return O(i,o)?tn(`zoom`):{kind:`setZoomRange`,id:t.id,start:i,end:o}}case`addMask`:{let t=en(e,n.atMs);if(Wt(t))return t;let{endMs:r}=t,a=Gt(i,n.atMs),o=`point`in a?a.point:{x:i.viewport.width/2,y:i.viewport.height/2},s=zt(i.viewport,o),c=E(e,n.atMs,n.snapMs),l=E(e,r,n.snapMs);if(O(c,l)){let t=rn(e,c.actionId);if(!t)return D(`That would leave the mask no length; move the playhead earlier.`);l={actionId:t.actionId,offsetMs:0}}return`point`in a?{kind:`addMask`,rect:s,start:c,end:l}:{kind:`addMask`,rect:s,start:c,end:l,note:`Placed at the centre of the frame: ${a.reason}. Drag it into place on the preview.`}}case`moveMask`:{let t=qt(e,n.id);if(!t)return D(`There is no mask "${n.id}" to move.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return D(`This mask covers the whole take, so it has no ends to move. Add a new mask to cover a stretch.`);if(n.deltaMs===0)return null;let r=t.startMs+n.deltaMs,i=t.endMs+n.deltaMs;if(r<0)return D(`A mask cannot start before the take does.`);if(i>a)return D(`A mask cannot end after the take does.`);let o=E(e,r,n.snapMs),s=E(e,i,n.snapMs);return O(o,s)?tn(`mask`):{kind:`setMaskRange`,id:t.id,start:o,end:s}}case`maskEdge`:{let t=qt(e,n.id);if(!t)return D(`There is no mask "${n.id}" to resize.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return D(`This mask covers the whole take, so it has no ends to move. Add a new mask to cover a stretch.`);if(n.edge===`start`){if(n.toMs<0)return D(`A mask cannot start before the take does.`);if(n.toMs>t.endMs-100)return D(`A mask cannot start after it ends; drag its end later first.`);let r=E(e,n.toMs,n.snapMs),i=t.endMarker;return O(r,i)?tn(`mask`):{kind:`setMaskRange`,id:t.id,start:r,end:i}}if(n.toMs>a)return D(`A mask cannot end after the take does.`);if(n.toMs<t.startMs+100)return D(`A mask cannot end before it starts; drag its start earlier first.`);let r=t.startMarker,i=E(e,n.toMs,n.snapMs);return O(r,i)?tn(`mask`):{kind:`setMaskRange`,id:t.id,start:r,end:i}}}}function on(e,t,n){let r=e.beats.find(e=>e.actionId===t);return r===void 0?D(`There is no step "${t}" to pace.`):r.isLast?D(`"${t}" is the last step, and a pause is the time between two steps. Trim or add a step after it instead.`):Number.isFinite(n)?n<0?D(`A pause cannot be shorter than nothing. Type 0 to cut the dead air here, or use the recorded pause.`):{kind:`setGap`,afterActionId:t,durationMs:n}:D(`A pause has to be a number of milliseconds.`)}function sn(e){return e.actions.map(e=>e.id).join(` `)}function cn(e){return{bundle:e.bundle,actionIds:sn(e.scene)}}function ln(e,t){return e!==null&&t.bundle===e.bundle&&sn(t.scene)===e.actionIds&&t.hoverReport!==null}var un={removable:[],checked:0,unchecked:0,failed:!0};function dn(e){return e.kind!==`unknown`||e.reason!==`notStyleSignalled`}function fn(e,t){let n=e.filter(dn).filter(e=>!t.has(e.actionId)),r={};for(let e of n)e.kind===`unknown`&&(r[e.reason]=(r[e.reason]??0)+1);return{removable:n.flatMap(e=>e.kind===`still`?[e.actionId]:[]),checked:n.filter(e=>e.kind!==`unknown`).length,unchecked:n.filter(e=>e.kind===`unknown`).length,uncheckedBy:r,failed:!1}}var pn={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 mn(e){return Object.entries(e.uncheckedBy??{}).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]).map(([e,t])=>{let n=pn[e];return`${t} ${t===1?n.one:n.many}`}).join(`, `)}function hn(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=mn(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 gn(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 _n(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 vn(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 yn(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=yn(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 xn(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 Sn(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 k(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60;return`${Math.floor(t/60)}:${String(n).padStart(2,`0`)}`}function Cn(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 Tn(e,t){return e===null||[...new Set([...Object.keys(t),...Object.keys(e)])].some(n=>t[n]!==e[n])}function En(e,t){return e===null||e.smoothness!==t.smoothness||e.blur!==t.blur||e.follow!==t.follow}function Dn(e,t){if(e===null)return!0;let n=(e,t)=>e===t||e!==void 0&&t!==void 0&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,r=e.background,i=t.background;return!(r.kind===i.kind&&(r.kind===`solid`?r.color===i.color:r.from===i.from&&r.to===i.to&&r.angle===i.angle))||e.cornerRadius!==t.cornerRadius||!n(e.frameRect,t.frameRect)||e.logo?.image!==t.logo?.image||e.logo?.opacity!==t.logo?.opacity||!n(e.logo?.rect,t.logo?.rect)}function On(e){let t=e instanceof Error?e.message:String(e),n=/[.!?]$/.test(t)?t:`${t}.`,r=typeof e==`object`&&e?e:{};return{text:`Not shown: ${n}`,expected:r.reason===`revealRefused`&&r.status===404}}function kn(){let e=new Map;return{isOpen:(t,n)=>e.get(t)??n,set:(t,n)=>{e.set(t,n)}}}var An={attachFailed:`Couldn't record the screen, so this take has no video`,debuggerDetached:`Recording stopped partway through`,debuggerLost:`Recording stopped and couldn't restart`,debuggerRecovered:`A stretch in the middle is missing`,workerRestarted:`The extension restarted mid-take, so this take has no video`,noKeyframes:`Nothing could be photographed, so there's no video`,screencastUnavailable:`Motion couldn't be recorded, so this take is stills`,muxFailed:`The motion couldn't be encoded, so this take is stills`,muxUnavailable:`There was nowhere to encode the motion, so this take is stills`,budgetSpent:`The take outran its motion budget, so the rest is stills`,credentialSuspended:`Motion paused while you typed in a password field`,motionIncomplete:`Some motion couldn't be saved, so parts are stills`,motionInterrupted:`Recording was interrupted, so parts are stills`,spansDiscarded:`Some motion couldn't be encoded, so those moments are stills`,storageRefused:`This take's frames couldn't be saved — free up space and record it again`,bundleInvalid:`This take's video couldn't be put together`},jn={canceled_by_user:`you cancelled it on the debugging bar`,target_closed:`the page was replaced`,replaced_with_devtools:`DevTools took the tab`,render_process_gone:`the page crashed`},Mn=new Set([`debuggerDetached`,`debuggerLost`,`debuggerRecovered`]),Nn=e=>Object.hasOwn(jn,e)?jn[e]:e;function Pn(e){let t=An[e];if(t!==void 0)return t;let n=e.indexOf(`:`);if(n>0){let t=e.slice(0,n),r=An[t],i=e.slice(n+1);if(r!==void 0&&i!==``)return`${r} — ${Mn.has(t)?Nn(i):i}`}return e}function Fn(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`${Pn(e.reason)}${n}`}var In={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 Ln(e){return e===null||e.reason===null?!1:In[e.reason]===!0}function Rn(e,t,n){if(e===null||e.reason===null||!t.mayReplay||e.reason===`mutating`)return null;let r=Xe(e.reason),i=n!==void 0&&et(n),a=i?`The script run`:`The re-shoot`,o=i?`performed`:`reconstructed`,s=n?$e(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 ${tt(i)} to try again.`:`${a} ${o} all ${e.total} steps, but: ${r}.`;let l=Ln(e)?`and stopped early`:`then stopped`;return`${a} ${o} ${e.completed} of ${e.total} steps ${l}: ${r}.${c}`}function A(e,t){let n=e.actions.findIndex(e=>e.id===t);if(n===-1)throw Error(`unknown action "${t}"`);return n}function zn(e,t){let n=e.camera.find(e=>e.id===t);if(!n)throw Error(`unknown zoom "${t}"`);return n}var Bn=1,Vn=e=>Error(`1:1 is not a zoom — remove the zoom instead of authoring ${e}`);function Hn(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]:(A(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(A(e,t.marker.actionId),t.scale<=1)throw Vn(t.scale);let i=t.target;if(i.kind===`element`&&!e.anchors.some(e=>e.id===i.anchorId))throw Error(`unknown anchor "${i.anchorId}"`);let a=i.kind===`element`&&t.marker.offsetMs===0?r.leadInMs:t.marker.offsetMs,o={id:n(),kind:`zoom`,...i.kind===`element`?{anchorId:i.anchorId}:{point:{x:i.x,y:i.y}},marker:{actionId:t.marker.actionId,offsetMs:a},scale:t.scale,...t.note===void 0?{}:{note:t.note}};return{...e,camera:[...e.camera,o]}}case`setZoomRange`:{let n=zn(e,t.id);A(e,t.start.actionId),t.end&&A(e,t.end.actionId);let{end:r,...i}=n,a=t.end===null?{...i,marker:t.start}:{...i,marker:t.start,end:t.end};return{...e,camera:e.camera.map(e=>e.id===n.id?a:e)}}case`setZoomScale`:{let n=zn(e,t.id);if(t.scale<=1)throw Vn(t.scale);return{...e,camera:e.camera.map(e=>e.id===n.id?{...e,scale:t.scale}:e)}}case`setZoomTarget`:{let n=zn(e,t.id),{anchorId:r,note:i,...a}=n;return{...e,camera:e.camera.map(e=>e.id===n.id?{...a,point:{x:t.point.x,y:t.point.y}}:e)}}case`removeZoom`:return zn(e,t.id),{...e,camera:e.camera.filter(e=>e.id!==t.id)};case`addMask`:return A(e,t.start.actionId),A(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(A(e,t.start.actionId),A(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<Bn||t.rect.height<Bn)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:ye(e.branding,t.patch)};case`setCursor`:return{...e,cursor:{...e.cursor,...t.patch}};case`setMotion`:return{...e,motion:{...e.motion??le,...t.patch}};case`setAspect`:return{...e,canvas:{...e.canvas,aspect:t.aspect}};case`split`:return A(e,t.at.actionId),{...e,edits:{...e.edits,splits:[...e.edits.splits??[],{id:n(),at:t.at}]}};case`removePiece`:if(t.start===null&&t.end===null)throw Error(`Removing the whole take would leave nothing to export.`);return t.start&&A(e,t.start.actionId),t.end&&A(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&&A(e,t.start.actionId),t.end&&A(e,t.end.actionId);let i={...r,...t.start===void 0?{}:{start:t.start},...t.end===void 0?{}:{end:t.end}};if(i.start===null&&i.end===null)throw Error(`Removing the whole take would leave nothing to export.`);return{...e,edits:{...e.edits,removed:n.map(e=>e.id===t.id?i:e)}}}case`setGap`:{if(A(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 Un(e,t,n){return te.parse(Hn(e,t,n))}function Wn(e){return{scene:e,past:[],future:[],error:null,dirty:!1,hoverReport:null}}function Gn(e,t,n){let r;try{r=Un(e.scene,t,n)}catch(t){return{...e,error:t instanceof Error?t.message:String(t)}}return t.kind===`setBranding`&&De(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 Kn(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 qn(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 Jn(e){return{...e,dirty:!1}}var Yn={mayReplay:!0};function Xn(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 Zn(e,t){return e.meta===void 0||e.flags===void 0?!1:Xn(e)===Xn(t)}function Qn(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(Xn(e)),JSON.parse(Xn(t)),`scene`)}function $n(e,t){let{renderMode:n,...r}=e.meta;return{...e,meta:t.meta.renderMode===void 0?r:{...r,renderMode:t.meta.renderMode}}}function er(e,t){return{...$n(e,t),flags:{...e.flags,hoverSensitive:t.flags.hoverSensitive}}}function tr(e){let t=Wn({}),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:Rn(i,Yn,t.scene),replayRecoverable:Ln(i),captureSentence:a===null||n!==null&&n.source!==`capture`?null:Fn(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=$n(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=Zn(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 ${Qn(t.scene,o)}`),t=c?{...Wn(o),past:t.past.map(e=>er(e,o)),future:t.future.map(e=>er(e,o))}:Wn(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=Gn(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=Jn(t),u()})},async undo(){await c(async()=>{let e=Kn(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=Jn(t),u()})},async redo(){await c(async()=>{let e=qn(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=Jn(t),u()})},async settled(){let e;do e=s,await e;while(e!==s)},setHoverReport(e){t={...t,hoverReport:e},u()}}}var nr=1.2;function rr(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:nr}:null:n===`-`||n===`_`?t.hasTimeline?{kind:`zoomTimeline`,factor:1/nr}: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 ir={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`}},ar=(e,t)=>typeof e==`string`?e:t?e.mac:e.other;function or(e,t){let n=ir[e];return n===void 0?e:ar(n.label,t)}var sr=new Set([`⌘`,`⇧`,`⌫`,`←`,`→`,`↑`,`↓`]);function cr(e){return sr.has(e)}function lr(e,t){let n=ir[e];return n===void 0?e:ar(n.spoken,t)}function ur(e,t){return e.map(e=>lr(e,t)).join(` plus `)}function dr(e){return/\bMac/i.test(e)}function fr(e,t){return ar(e.description,t)}var pr=[{group:`Playback`,combos:[[`Space`]],description:`Play / pause`,action:`playPause`},{group:`Playback`,combos:[[`J`],[`L`]],description:`Shuttle back / forward`,action:`shuttle`},{group:`Playback`,combos:[[`K`]],description:`Stop`,action:`stop`},{group:`Playback`,combos:[[`Left`],[`Right`]],description:`Nudge playhead`,action:`nudge`},{group:`Playback`,combos:[[`Shift`,`Left`],[`Shift`,`Right`]],description:`Nudge half a second`,action:`nudge`},{group:`Playback`,combos:[[`Mod`,`Left`],[`Mod`,`Right`]],description:`Jump to start / end`,action:`seekEdge`},{group:`Steps`,combos:[[`Up`],[`Down`]],description:`Previous / next step`,action:`stepBeat`},{group:`Steps`,combos:[[`Esc`]],description:`Clear selection`,action:`clearSelection`},{group:`Trim`,combos:[[`I`],[`O`]],description:`Trim start / end to playhead`,action:`setTrim`},{group:`Editing`,combos:[[`Mod`,`B`]],description:`Split at playhead`,action:`split`},{group:`Editing`,combos:[[`Delete`]],description:`Delete the selected piece, zoom or mask`,action:`deleteSelection`},{group:`Editing`,combos:[[`Mod`,`Z`]],description:`Undo`,action:`undo`},{group:`Editing`,combos:[[`Shift`,`Mod`,`Z`]],description:{mac:`Redo`,other:`Redo — or Ctrl+Y`},action:`redo`},{group:`Timeline`,combos:[[`+`],[`−`]],description:`Zoom in / out`,action:`zoomTimeline`},{group:`Timeline`,combos:[[`Shift`,`Z`]],description:`Fit the whole take`,action:`zoomFit`},{group:`Timeline`,combos:[[`S`]],description:`Snapping on / off`,action:`toggleSnapping`},{group:`Panels`,combos:[[`?`]],description:`Show shortcuts`,action:`toggleHelp`},{group:`Panels`,combos:[[`Esc`]],description:`Close the panel`,action:`closePanel`}];function mr(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 hr=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],gr=3;function _r(e,t,n){e.style.left=`${n.left+t.x*n.scale}px`,e.style.top=`${n.top+t.y*n.scale}px`,e.style.width=`${t.width*n.scale}px`,e.style.height=`${t.height*n.scale}px`}function vr(e,t,n,r){let{x:i,y:a,width:o,height:s}=e;return t===`body`?{x:i+n,y:a+r,width:o,height:s}:(t.includes(`w`)&&(i+=n,o-=n),t.includes(`e`)&&(o+=n),t.includes(`n`)&&(a+=r,s-=r),t.includes(`s`)&&(s+=r),o<0&&(i+=o,o=-o),s<0&&(a+=s,s=-s),{x:i,y:a,width:o,height:s})}function yr(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=mr(t.canvas),s={resolved:i,target:t.target,presentation:a,outputTimeMs:t.outputTimeMs};if(r.kind===`mask`){let i=t.model.masks.find(e=>e.id===r.id);if(!i)return;let a=C(`div`,`overlay`);a.setAttribute(`data-overlay`,`mask`);let c=Bt({rect:i.rect,...s});_r(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)>gr&&(l=!0),c=vr(r,t,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),_r(a,c,o)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),l&&n.onMaskRect(i.id,Vt({rect:c,...s}))};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)})};l(a,`body`);for(let e of hr){let t=C(`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=C(`div`,`overlay`);l.setAttribute(`data-overlay`,`zoom`);let u=Bt({rect:Ht({zoom:c,resolved:i,viewport:i.plan.viewport,presentation:a,target:t.target}),...s});_r(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)>gr&&(r=!0),u=vr(t,`body`,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),_r(l,u,o)},a=()=>{if(window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),!r)return;let e=Vt({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,a=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??r.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??[]):h(t),d=new Map((i?.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),f=(e,t)=>{if(n===null||i===null||!de(i)||se(i,e.id))return!0;let r=d.get(e.id),a=d.get(t.id);return r===void 0||a===void 0||n.timeline.segments.some(e=>e.kind===`idle`&&e.srcEndMs>e.srcStartMs&&r<=e.srcStartMs&&e.srcEndMs<=a)},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||de(i))return null;let r=d.get(t.id);return d.get(e.id)===void 0||r===void 0?null:p(r)},_=t.actions.length-1;return{beats:t.actions.map((e,r)=>{let h=e.anchorId?a.get(e.anchorId):void 0,v=s.get(e.id),y=c.get(e.id),ee=l.get(e.id),b=t.actions[r+1],x=d.get(e.id);return{actionId:e.id,index:r,verb:e.kind,anchorId:e.anchorId,label:Ze(h),text:e.kind===`type`?e.text:null,redacted:e.kind===`type`&&e.redacted,host:e.kind===`type`&&e.host===!0,strategy:h?.resolution.strategy??null,outputMs:n?o(n.timeline,x??e.timestamp):null,timing:x===void 0?`estimated`:`rendered`,captureMs:e.timestamp,camera:v??null,canZoom:e.anchorId!==null,gap:y?{durationMs:y.durationMs}:null,canPace:b!==void 0&&f(e,b),renderedPauseMs:m(e,b),renderedPaceFreezeMs:g(e,b),renderedFreezeBeforeMs:i!==null&&!de(i)&&x!==void 0&&n!==null&&x<n.timeline.sourceDurationMs?p(x):0,legacyHold:ee?{offsetMs:ee.marker.offsetMs,durationMs:ee.durationMs}:null,cut:u.has(e.id),isLast:r===_}}),outputDurationMs:n?.timeline.outputDurationMs??null,hasBundle:n!==null}}var xr=(e,t,n)=>Math.min(n,Math.max(t,e)),Sr=e=>({startMs:0,endMs:Math.max(250,e)}),j=(e,t)=>(t-e.startMs)/(e.endMs-e.startMs),Cr=(e,t)=>e.startMs+t*(e.endMs-e.startMs);function wr(e,t,n,r){let i=Math.max(250,r),a=xr(n,250,i),o=xr(e-t*a,0,i-a);return{startMs:o,endMs:o+a}}function Tr(e,t,n,r){return wr(Cr(e,r),r,(e.endMs-e.startMs)/n,t)}function Er(e,t,n){let r=e.endMs-e.startMs;return wr(e.startMs+n,0,r,t)}var Dr=(e,t,n,r)=>wr(Cr(e,r),r,n,t);function Or(e,t){let n=Math.max(250,e);return n*(250/n)**xr(t,0,1)}function kr(e,t){let n=Math.max(250,e);if(n<=250)return 0;let r=xr(t,250,n);return Math.log(r/n)/Math.log(250/n)}function Ar(e,t){switch(e){case`Mod`:return t?`Meta`:`Control`;case`Esc`:return`Escape`;case`Left`:return`ArrowLeft`;case`Right`:return`ArrowRight`;case`Up`:return`ArrowUp`;case`Down`:return`ArrowDown`;case`−`:return`-`;default:return e}}function jr(e,t,n=[]){if(e.dataset.tip=t,e.removeAttribute(`title`),n.length===0){delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`);return}e.dataset.tipKeys=n.join(` `);let r=dr(navigator.userAgent);e.setAttribute(`aria-keyshortcuts`,n.map(e=>Ar(e,r)).join(`+`))}function Mr(e){delete e.dataset.tip,delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`)}var Nr=Symbol.for(`demoman.tooltip`);function Pr(e=document){let t=e,n=t[Nr];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[Nr]={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=dr(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=or(n,r),a=e.createElement(`kbd`);a.className=`keycap`,a.textContent=i,cr(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 Fr(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-export-panel`,``),e.append(C(`h2`,void 0,`Export`));let t=C(`div`);return t.setAttribute(`data-panel-export`,``),e.append(t),e}function Ir(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-background-panel`,``),e.append(C(`h2`,void 0,`Background`));let t=C(`div`);return t.setAttribute(`data-panel-branding`,``),e.append(t),e}function Lr(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-shortcuts-panel`,``),e.append(C(`h2`,void 0,`Keyboard shortcuts`));let t=C(`div`);return t.setAttribute(`data-panel-shortcuts`,``),e.append(t),e}function Rr(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-cursor-panel`,``),e.append(C(`h2`,void 0,`Cursor`));let t=C(`div`);return t.setAttribute(`data-panel-cursor`,``),e.append(t),e}function zr(e,t,n){let r=C(`div`,`beat-panel`);r.setAttribute(`data-step-panel`,e.actionId);let i=C(`h2`);if(i.append(C(`span`,`verb`,e.verb),` `,e.label),e.strategy){let t=C(`span`,`chip`,e.strategy);t.setAttribute(`data-health`,e.strategy),i.append(` `,t)}r.append(i);let a=C(`div`);if(e.verb===`type`){if(e.redacted)a.append(C(`div`,`redacted`,e.host?`This was typed into an editor, and an edit the sensor does not follow landed mid-field, so the text is unknown.`:`This value was never recorded — a credential field, or text that looked like a secret.`));else{let t=C(`div`,`control-row`),n=C(`span`,void 0,e.text??``);n.setAttribute(`data-typed-text`,e.actionId),t.append(C(`span`,`control-label`,`Typed text`),n),a.append(t)}}e.timing===`estimated`&&a.append(C(`div`,`muted`,`Not in the video: the frames have no marker for this step, so the timeline places it from the take's own timestamp.`)),a.hasChildNodes()&&r.append(a);let o=C(`div`,`control-actions`);if(!e.canZoom)o.append(C(`span`,`muted`,`No zoom — nothing on screen to aim at`));else{let t=C(`button`,`btn btn-quiet`,`Zoom on this step`);t.type=`button`,t.setAttribute(`data-zoom-on-step`,e.actionId),t.addEventListener(`click`,()=>n.onZoomOnStep(e.actionId)),o.append(t)}r.append(o);let s=()=>{let t=C(`button`,`btn btn-quiet`,`Use recorded`);return t.type=`button`,t.setAttribute(`data-gap-clear`,e.actionId),t.setAttribute(`aria-label`,`Restore the recorded pause after ${e.label}`),t.addEventListener(`click`,()=>n.onGapClear(e.actionId)),t},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=C(`label`,`control-row`),i=C(`input`);i.type=`number`,i.min=`0`,i.step=`100`,i.value=e.gap===null?``:String(e.gap.durationMs),i.placeholder=`recorded`,i.setAttribute(`data-gap`,e.actionId),i.setAttribute(`aria-label`,`Pause after ${e.label}, in milliseconds. Empty plays back the recorded pause.`),i.addEventListener(`change`,()=>{let t=i.value.trim();t===``?n.onGapClear(e.actionId):n.onGap(e.actionId,Number(t))});let a=C(`span`,`control-inline`);if(a.append(i,C(`span`,void 0,`ms`)),e.gap!==null&&a.append(s()),t.append(C(`span`,`control-label`,`Pause after this step`),a),r.append(t),e.gap!==null&&e.gap.durationMs>0&&e.renderedPaceFreezeMs===0){let t=C(`div`);t.setAttribute(`data-gap-floored`,e.actionId),t.append(C(`span`,void 0,`A ${e.gap.durationMs}ms pause is set here, but the re-shot frames already leave at least that long between these two steps, so it adds nothing to this video. Pacing only ever adds time — it never speeds your app up. Raise it, or go back to your recording from its Recordings card, where this number is the pause.`)),r.append(t)}}else if(e.gap!==null){let t=C(`div`);t.setAttribute(`data-gap-inert`,e.actionId),t.append(C(`span`,void 0,`A ${e.gap.durationMs}ms pause is set here but is not playing. ${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=C(`div`);i.setAttribute(`data-legacy-hold`,e.actionId),i.append(C(`span`,void 0,`A ${e.legacyHold.durationMs}ms pause from an earlier edit ${n}. There is no control for it: deleting this step removes it, and nothing else in the editor does.`)),r.append(i)}if(e.cut){let n=C(`div`);n.setAttribute(`data-cut-panel`,e.actionId),n.append(C(`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=C(`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=C(`div`,`control-actions`);if(t.hoverReport?.removable.includes(e.actionId)??!1){let t=C(`button`,`btn btn-quiet`,`Keep this hover`);t.type=`button`,t.setAttribute(`data-keep-hover`,e.actionId),t.addEventListener(`click`,()=>n.onKeepHover(e.actionId)),l.append(t)}return l.hasChildNodes()&&r.append(l),r}function Br(e,t,n){let i=C(`div`,`zoom-panel`);i.setAttribute(`data-zoom-panel`,e.id),i.append(C(`h2`,void 0,`Zoom`));let a=C(`input`);a.type=`range`,a.min=`1.1`,a.max=String(r.maxScale),a.step=`0.05`,a.value=String(e.scale),a.setAttribute(`data-zoom-scale`,e.id),a.setAttribute(`aria-label`,`Zoom level`),Oe(a),a.addEventListener(`input`,()=>Oe(a)),a.addEventListener(`change`,()=>n.onZoomScale(e.id,Number(a.value)));let o=C(`div`,`slider-row`);o.append(C(`span`,`control-label slider-label`,`Level`),C(`span`,`slider-value`,`${e.scale.toFixed(2)}x`),a),i.append(o);let s=C(`div`);if(s.setAttribute(`data-zoom-aim`,``),e.target.kind===`element`){let{anchorId:n}=e.target,r=t.scene.anchors.find(e=>e.id===n);s.textContent=`Aims at ${r?Ze(r):n}`}else s.textContent=`Aims at the cursor at ${k(e.startMs)}`;if(i.append(s),e.aimFallback!==null){let t=C(`div`,`muted`,e.aimFallback);t.setAttribute(`data-zoom-fallback`,``),i.append(t)}let c=C(`div`);c.setAttribute(`data-zoom-range`,``),c.textContent=`${k(e.startMs)} to ${k(e.endMs)}${e.endAuthored?``:` (end automatic; drag its cap to set one)`}`,i.append(c),e.clamped&&i.append(C(`div`,`muted`,`The end you set could not be reached; see the note under the timeline.`)),e.timing===`estimated`&&i.append(C(`div`,`muted`,`Estimated position: the last render carried no marker for this zoom's step, or no on-screen rect for its target.`));let l=C(`button`,`btn btn-quiet`,`Remove zoom`);l.type=`button`,l.setAttribute(`data-remove-zoom`,e.id),jr(l,`Remove zoom`,[`Delete`]),l.addEventListener(`click`,()=>n.onRemoveZoom(e.id));let u=C(`div`,`control-actions`);return u.append(l),i.append(u),i}function Vr(e,t,n){let r=C(`div`,`mask-panel`);r.setAttribute(`data-mask-panel`,e.id),r.append(C(`h2`,void 0,`Mask`));let i=C(`div`);i.setAttribute(`data-mask-rect`,``),i.textContent=`${Math.round(e.rect.width)}x${Math.round(e.rect.height)} at ${Math.round(e.rect.x)}, ${Math.round(e.rect.y)}`,r.append(i);let a=C(`input`);a.type=`text`,a.placeholder=`What this hides`,a.value=t.scene.edits.masks.find(t=>t.id===e.id)?.note??``,a.setAttribute(`data-mask-note`,e.id),a.setAttribute(`aria-label`,`Mask note`),a.addEventListener(`change`,()=>n.onMaskNote(e.id,a.value));let o=C(`label`,`control-row`);o.append(C(`span`,`control-label`,`Note`),a),r.append(o);let s=C(`div`);s.setAttribute(`data-mask-range`,``),e.wholeTake?(s.setAttribute(`data-mask-whole-take`,``),s.textContent=`Covers the whole take (made before masks had a range).`):s.textContent=`${k(e.startMs)} to ${k(e.endMs)}`,r.append(s),r.append(C(`p`,`honesty`,`Masks are opaque fills stored in the page's own coordinates and re-applied on every render — non-destructive as layers, absolute as pixels.`));let c=C(`button`,`btn btn-quiet`,`Remove mask`);c.type=`button`,c.setAttribute(`data-remove-mask`,e.id),jr(c,`Remove mask`,[`Delete`]),c.addEventListener(`click`,()=>n.onRemoveMask(e.id));let l=C(`div`,`control-actions`);return l.append(c),r.append(l),r}function Hr(e,t,n){let{selection:r,rail:i}=t;if(i===`shortcuts`&&e.querySelector(`:scope > .inspector > [data-shortcuts-panel]`)!==null)return;let a=C(`div`,`inspector`),o=r?.kind===`tick`?t.view.beats.find(e=>e.actionId===r.actionId):void 0,s=r?.kind===`zoom`?t.model.zooms.find(e=>e.id===r.id):void 0,c=r?.kind===`mask`?t.model.masks.find(e=>e.id===r.id):void 0,l;i===`selection`?o?l=zr(o,t,n):s?l=Br(s,t,n):c?l=Vr(c,t,n):(console.error(`[demoman] editor: the rail is on Selection with nothing selected`),l=Fr()):l=i===`background`?Ir():i===`cursor`?Rr():i===`shortcuts`?Lr():Fr();let u=C(`button`,`btn btn-icon inspector-close`);u.type=`button`,u.setAttribute(`data-inspector-close`,``),u.setAttribute(`aria-label`,`Close panel`),jr(u,`Close`,[`Esc`]),u.append(S(`close`)),u.addEventListener(`click`,()=>n.onClose()),a.append(u,l),e.replaceChildren(a)}var Ur=[{entry:`background`,label:`Background`,glyph:`image`},{entry:`cursor`,label:`Cursor`,glyph:`mousePointer2`},{entry:`selection`,label:`Selection`,glyph:`mousePointerClick`}],Wr=`Select a step, zoom or mask on the timeline`;function Gr(e,t,n){let r=Ur.map(({entry:e,label:r,glyph:i})=>{let a=C(`button`,`btn btn-icon`);a.type=`button`,a.setAttribute(`data-rail`,e),a.setAttribute(`aria-label`,r),a.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===e));let o=e===`selection`&&!t.hasSelection;return a.disabled=o,a.title=o?Wr:r,a.append(S(i)),a.addEventListener(`click`,()=>n.onPick(e)),a});e.replaceChildren(...r)}function Kr(e,t,n){e.querySelector(`svg[data-icon]`)===null&&e.replaceChildren(S(`download`),C(`span`,void 0,`Export`)),e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`export`)),e.onclick=()=>n.onPick(`export`)}function qr(e,t,n){e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`shortcuts`)),e.onclick=()=>n.onPick(`shortcuts`)}function Jr(e,t,n){switch(e.phase){case`idle`:return Ce[t];case`queued`:return e.position===0?`Queued…`:`Queued (${e.position} ahead)`;case`encoding`:return e.total>0?`Exporting · ${Math.floor(e.done*100/e.total)}%`:`Exporting…`;case`saving`:return`Saving…`}}function Yr(e){let t=e/1048576;return t>=1?`${Math.round(t*10)/10} MB`:`${Math.max(1,Math.round(e/1024))} KB`}var Xr=1e3,Zr=new Map;function Qr(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=Zr.get(t);if(s!==void 0&&o-s.at>Xr)Zr.delete(t);else if(s!==void 0){let e=s.on===n?o-s.at:0;s.on!==n&&Zr.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`),Zr.set(t,{on:i.checked,at:performance.now()}),e.onChange(i.checked)}),r}function $r(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 ei(e,t){let n=t.hoverReport===null?null:hn(t.hoverReport);if(t.notices.length===0&&n===null){e.replaceChildren();return}let r=C(`div`,void 0);r.setAttribute(`data-take-notes`,``);for(let e of t.notices){let t=C(`div`,`notice`);ue(t,e),t.setAttribute(`data-take-notice`,``),r.append(t)}if(n!==null){let e=C(`div`,`notice`,n);e.setAttribute(`data-hover-report`,``),r.append(e)}e.replaceChildren(r)}function ti(e,t){if(t.hasFrames){e.replaceChildren();return}let n=C(`div`,`banner`),r=C(`span`);r.append(ni(t.route)),n.append(r),e.replaceChildren(n)}function ni(e){let t=document.createDocumentFragment();return t.append(`This take has no frames — `,ri(e,tt(e.authored))),t}function ri(e,t){if(e.rerun.kind===`line`){let t=C(`span`);return ue(t,e.rerun.text),t.setAttribute(`data-rerun-line`,``),t}let n=C(`a`,void 0,t);return n.setAttribute(`href`,e.rerun.href),n.setAttribute(`data-runs-route`,``),n}function ii(e,t){let n=[];if(t.openError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-open-error`,``),e.append(C(`strong`,void 0,`This take could not be opened`)),e.append(C(`div`,void 0,t.openError)),n.push(e)}if(t.replaySentence!==null){let e=C(`div`,`notice`);e.setAttribute(`data-replay-failure`,``);let r=t.runsRoute?.authored===!0?`script run`:`re-shoot`;if(e.append(C(`strong`,void 0,t.replayRecoverable===!0?`The last ${r} stopped early`:`The last ${r} did not finish`)),e.append(C(`div`,void 0,t.replaySentence)),t.runsRoute!=null){let n=C(`div`);n.setAttribute(`data-replay-runs-route`,``),n.append(ri(t.runsRoute,mt(t.runsRoute.authored))),e.append(n)}n.push(e)}if(t.captureSentence!=null){let e=C(`div`,`notice`);e.setAttribute(`data-capture-note`,``),e.append(C(`strong`,void 0,`What this take recorded`)),e.append(C(`div`,void 0,t.captureSentence)),n.push(e)}if(t.renderError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-render-error`,``),e.append(C(`strong`,void 0,`The export did not start`)),e.append(C(`div`,void 0,t.renderError)),n.push(e)}if(t.previewError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-preview-error`,``),e.append(C(`strong`,void 0,`The preview stopped`)),e.append(C(`div`,void 0,t.previewError)),n.push(e)}if(t.logoLoadError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-logo-load-error`,``),e.append(C(`strong`,void 0,`The logo could not be loaded`)),e.append(C(`div`,void 0,t.logoLoadError)),n.push(e)}if(t.error!==null){let e=C(`div`,`notice`);e.setAttribute(`data-action-error`,``),e.append(C(`strong`,void 0,`That edit did not go through`)),e.append(C(`div`,void 0,t.error)),n.push(e)}if(t.deleteError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-delete-error`,``),e.append(C(`strong`,void 0,`This demo was not deleted`)),e.append(C(`div`,void 0,t.deleteError)),n.push(e)}if(t.navigationError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-navigation-error`,``),e.append(C(`strong`,void 0,`The ${t.navigationError.page} did not open`)),e.append(C(`div`,void 0,t.navigationError.reason)),n.push(e)}e.replaceChildren(...n)}function ai(e,t,n){Ae(e,t,n)}var oi={light:`Light`,dark:`Dark`,touch:`Touch`},si={light:1/16,dark:1/16,touch:0};function ci(e,t,n){let{height:r,hotspot:i,ink:o}=a[e],s=r*t,c={x:(o.min.x+o.max.x)/2,y:(o.min.y+o.max.y)/2};return{x:n/2-(c.x-i.x-si[e])*s,y:n/2-(c.y-i.y)*s}}var li=.6;function ui(e,t,n){return Math.min(Math.min(2,Math.max(.5,t))*li,n/a[e].height)}function di(e,t){let n=C(`canvas`);n.width=44,n.height=44;let r=n.getContext(`2d`);if(!r)return console.error(`the cursor panel could not paint its "${e}" preview: no 2D context`),n;let i=ui(e,t,44);return d(r,ci(e,i,44),i,c,e),n}function fi(e,t,n,r,i,a,o,s){let c=C(`div`,`slider-row`),l=C(`input`);l.type=`range`,l.min=String(r),l.max=String(i),l.step=`0.05`,l.value=String(n),l.disabled=s,l.setAttribute(e,``),l.setAttribute(`aria-label`,t);let u=C(`span`,`slider-value`,a(n));Oe(l),l.addEventListener(`input`,()=>{Oe(l),u.textContent=a(Number(l.value)),o.preview(Number(l.value))}),l.addEventListener(`change`,()=>o.commit(Number(l.value)));let d=()=>{Number(l.value)===n&&o.end()};return l.addEventListener(`pointerup`,d),l.addEventListener(`pointercancel`,d),c.append(C(`span`,`control-label slider-label`,t),u,l),c}var pi=e=>`${Math.round(e*100)}%`,mi=e=>`${e.toFixed(2)}x`;function hi(e,t,n,r,i,a,o,s,c){return fi(e,t,n,r,i,a,{preview:e=>s.onCursorPreview({[o]:e}),commit:e=>s.onCursor({[o]:e}),end:()=>s.onCursorPreviewEnd()},c)}function gi(e,t,n,r,i){return fi(e,t,n,0,1,pi,{preview:e=>i.onMotionPreview({[r]:e}),commit:e=>i.onMotion({[r]:e}),end:()=>i.onMotionPreviewEnd()},!1)}function _i(e,t,n,r,i,a){return $r(t,null,Qr({key:r,checked:n,disabled:a,attrs:{[e]:``},onChange:e=>i.onCursor({[r]:e})}))}function vi(e,t,n,r,i=!1){let a=C(`div`),o=t.hidden;a.append(_i(`data-cursor-hidden`,`Hide cursor`,t.hidden,`hidden`,r,!1));let s=hi(`data-cursor-scale`,`Size`,t.scale,.5,2,mi,`scale`,r,o);i&&a.append(s);let c=C(`div`,`cursor-styles`);c.setAttribute(`role`,`radiogroup`),c.setAttribute(`aria-label`,`Cursor style`),o&&c.setAttribute(`aria-disabled`,`true`);for(let e of[`light`,`dark`,`touch`]){let n=C(`button`,`cursor-style`);n.type=`button`,n.disabled=o,n.setAttribute(`role`,`radio`),n.setAttribute(`data-cursor-style`,e),n.setAttribute(`aria-checked`,String(t.style===e)),n.setAttribute(`aria-label`,oi[e]),n.title=oi[e],n.append(di(e,t.scale)),n.addEventListener(`click`,()=>r.onCursor({style:e})),c.append(n)}i||a.append(C(`div`,`cursor-label`,`Style`),c),i||a.append(s,hi(`data-cursor-blur`,`Motion blur`,t.motionBlur,0,1,pi,`motionBlur`,r,o),hi(`data-cursor-tilt`,`Tilt`,t.tilt??y.tilt,0,1,pi,`tilt`,r,o),hi(`data-cursor-bounce`,`Click bounce`,t.clickBounce??y.clickBounce,0,2,mi,`clickBounce`,r,o),_i(`data-cursor-idle`,`Hide when not moving`,t.hideWhenIdle,`hideWhenIdle`,r,o)),a.append(C(`div`,`cursor-label camera-label`,`Camera`),gi(`data-motion-smoothness`,`Smoothness`,n.smoothness,`smoothness`,r),gi(`data-motion-blur`,`Camera blur`,n.blur,`blur`,r),$r(`Follow cursor`,null,Qr({key:`motion-follow`,checked:n.follow,attrs:{"data-motion-follow":``},onChange:e=>r.onMotion({follow:e})}))),e.replaceChildren(a)}function yi(){let e=C(`progress`,`export-progress`);return e.setAttribute(`data-export-progress`,``),e.setAttribute(`aria-label`,`Export progress`),e}function bi(e,t){return e.phase!==`idle`||t.kind===`noFrames`}function xi(e,t,n,r){let i=e.querySelector(`[data-export-start]`);if(i===null)return!1;i.textContent=Jr(t,n,r),i.disabled=bi(t,r);let a=e.querySelector(`[data-export-progress]`);if(t.phase!==`encoding`||t.total===0)return a?.remove(),!0;let o=a??yi();return o.max=t.total,o.value=t.done,a===null&&i.closest(`.control-actions`)?.after(o),!0}function Si(e,t,n){let r=C(`div`),i=t.run.phase!==`idle`;if(t.hasReclaimedMotion){let e=C(`p`,`notice`,`This export will use still frames where motion was reclaimed.`);e.setAttribute(`data-reclaimed-motion-notice`,``),r.append(e)}let a=C(`p`,`export-summary`,ve(t.fileType,t.durationMs));a.setAttribute(`data-export-summary`,``);let o=C(`p`,`muted`,Ee(t.aspect));o.setAttribute(`data-aspect-note`,``),r.append(a,o);let s=C(`p`,`muted`,we(t.recording,t.target));s.setAttribute(`data-size-readout`,``),r.append(s);let c=C(`div`,`control-row`);c.append(C(`span`,`control-label`,`File type`));let l=C(`div`,`segmented`);l.setAttribute(`role`,`radiogroup`),l.setAttribute(`aria-label`,`File type`),l.setAttribute(`data-file-types`,``);for(let e of[`mp4`,`gif`,`stills`]){let r=C(`button`,`segment`,ge[e]);r.type=`button`,r.setAttribute(`role`,`radio`),r.setAttribute(`data-file-type`,e),r.setAttribute(`aria-checked`,String(e===t.fileType)),r.disabled=i,r.addEventListener(`click`,()=>n.onFileType(e)),l.append(r)}c.append(l),r.append(c);let u=C(`button`,`btn btn-primary export-start`,Jr(t.run,t.fileType,t.readiness));u.type=`button`,u.setAttribute(`data-export-start`,``),u.setAttribute(`data-readiness`,t.readiness.kind),u.disabled=bi(t.run,t.readiness),u.addEventListener(`click`,n.onExport);let d=C(`div`,`control-actions`);if(d.append(u),t.readiness.kind===`noFrames`){let e=C(`p`,`muted`);e.setAttribute(`data-export-no-frames`,``),e.append(ni(t.runsRoute)),r.append(d,e)}else r.append(d);if(t.run.phase===`encoding`&&t.run.total>0){let e=yi();e.max=t.run.total,e.value=t.run.done,r.append(e)}if(t.save!==null&&r.append(Ni(t.save,n)),t.revealError!=null){let e=C(`p`,`notice notice-warn`,t.revealError);e.setAttribute(`data-reveal-error`,``),r.append(e)}if(t.save?.kind===`saved`)for(let e of t.save.outputRefs){let n=t.outputs.find(t=>t.kind===`stored`&&t.output.ref===e);n?.kind===`stored`&&Ei(r,n.output,t)}e.replaceChildren(r)}function Ci(e,t,n){let r=document.createDocumentFragment(),i=t.showAll?t.outputs:t.outputs.slice(0,5);for(let e of i){let i=C(`div`,`output`);if(i.setAttribute(`data-output`,e.kind===`file`?e.key:e.output.ref),r.append(i),e.kind===`file`){ji(i,e,t,n);continue}let a=e.output,o=C(`div`,`beat`),s=a.sceneDigest!==void 0&&a.sceneDigest!==t.currentDigest,c=t.warningsOpen.has(a.ref);o.append(ki(a.name,[s?Oi(a.ref):null,Ti(a.ref,wi(a),c,n)]));let l=C(`button`,`btn btn-quiet`,`Download`);if(l.type=`button`,l.setAttribute(`data-download`,a.ref),l.addEventListener(`click`,()=>n.onDownload(a.ref)),o.append(l),i.append(o),i.append(Ai(a.ref,[Yr(a.byteLength),Di(a.renderedAt)],null)),c&&wi(a)>0){let e=C(`div`,`output-warnings`);e.setAttribute(`data-output-warnings-body`,a.ref),Ei(e,a,t.reportContext),i.append(e)}}let a=t.outputs.length-i.length;if(a>0){let e=C(`button`,`btn btn-quiet`,`Show all ${t.outputs.length}`);e.type=`button`,e.setAttribute(`data-history-all`,``),e.title=`${a} more`,e.addEventListener(`click`,n.onShowAll),r.append(e)}e.replaceChildren(r)}function wi(e){return[e.detailViolations.length>0,e.logoWarning!==void 0,(e.unavailableSpans??[]).length>0,(e.unplacedStills??[]).length>0].filter(Boolean).length}function Ti(e,t,n,r){if(t===0)return null;let i=C(`button`,`chip chip-warn`,t===1?`1 warning`:`${t} warnings`);return i.type=`button`,i.setAttribute(`data-output-warnings`,e),i.setAttribute(`aria-expanded`,String(n)),i.addEventListener(`click`,()=>r.onWarnings(e)),i}function Ei(e,t,n){if(t.detailViolations.length>0){let{heading:r,lines:i}=ft(t.detailViolations,n.beatAt),a=C(`div`,`notice`);a.setAttribute(`data-violations`,t.ref),a.append(C(`strong`,void 0,r));for(let e of i)a.append(C(`div`,void 0,e));a.append(C(`div`,`honesty`,`A wider recording window is what gives the camera more to work with: both the stills and the motion scale with it. A smaller export size is the other way to close the gap.`)),e.append(a)}if(t.logoWarning!==void 0){let n=C(`div`,`notice`);n.setAttribute(`data-logo-warning`,t.ref),n.append(C(`div`,void 0,t.logoWarning)),e.append(n)}let r=t.unavailableSpans??[];if(r.length>0){let i=C(`div`,`notice`);i.setAttribute(`data-unavailable`,t.ref);let a=r.every(e=>e.reason===ct),o=C(`strong`);ue(o,a?`Motion was reclaimed to free space and shown as a still. ${_t(n.runsRoute.authored,gt(n.runsRoute),`to restore`)}`:`Some motion could not be decoded and was shown as a still`),i.append(o);for(let e of r)i.append(C(`div`,void 0,`${e.ref}: ${e.reason}`));e.append(i)}let i=t.unplacedStills??[];if(i.length>0){let n=C(`div`,`notice`);n.setAttribute(`data-unplaced-stills`,t.ref);let r=i.every(e=>e.reason.includes(`cut`));n.append(C(`strong`,void 0,r?`No still for ${i.length===1?`a step you cut`:`the steps you cut`}`:`Some steps got no still`));for(let e of i)n.append(C(`div`,void 0,`${e.actionId}: ${e.reason}`));e.append(n)}}function Di(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?e:Re(n,n.getFullYear()!==t.getFullYear())}function Oi(e){let t=C(`span`,`chip`,`Outdated`);return t.setAttribute(`data-stale-export`,e),t.title=`Made before your last edit`,t}function ki(e,t){let n=C(`span`,`output-head`),r=C(`span`,`output-name`,e);r.title=e,n.append(r);for(let e of t)e!==null&&n.append(e);return n}function Ai(e,t,n){let r=C(`div`,`muted output-meta`,t.join(` · `));return r.setAttribute(`data-output-meta`,e),n!==null&&(r.title=n),r}function ji(e,t,n,r){let i=C(`div`,`beat`),a=n.warningsOpen.has(t.key);if(i.append(ki(t.name,[t.sceneDigest===n.currentDigest?null:Oi(t.key),Ti(t.key,t.caveats.length,a,r)])),t.exists){let e=C(`button`,`btn btn-quiet`,`Show in Finder`);e.type=`button`,e.setAttribute(`data-reveal`,t.key),e.addEventListener(`click`,()=>r.onReveal({kind:`path`,path:t.path})),i.append(e)}else{let e=C(`span`,`muted`,`moved or deleted`);e.setAttribute(`data-output-gone`,``),i.append(e)}if(e.append(i),e.append(Ai(t.key,[Yr(t.byteLength),Di(t.renderedAt)],t.detail)),a&&t.caveats.length>0){let n=C(`div`,`notice output-warnings`);n.setAttribute(`data-output-warnings-body`,t.key);for(let e of t.caveats)n.append(C(`div`,void 0,Mi(e)));e.append(n)}}function Mi(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return/[.!?]$/.test(t)?t:`${t}.`}function Ni(e,t){let n=C(`div`,e.kind===`failed`?`notice notice-error`:`notice`);n.setAttribute(`data-save-outcome`,e.kind);let r=(e,n)=>{let r=C(`button`,`btn btn-quiet`,n);return r.type=`button`,r.setAttribute(`data-save-again`,``),r.addEventListener(`click`,()=>t.onSaveAgain(e)),r};if(e.kind===`saved`){let r=e.names.length===1?`Saved ${e.names[0]} · ${Yr(e.byteLength)}`:`Saved ${e.names.length} files · ${Yr(e.byteLength)}`;n.append(C(`span`,void 0,r));let i=e.reveal;if(i!==null){let e=C(`button`,`btn btn-quiet`,i.kind===`path`?`Show in Finder`:`Show in folder`);e.type=`button`,e.setAttribute(`data-show-in-folder`,``),e.addEventListener(`click`,()=>t.onReveal(i)),n.append(` `,e)}if(e.summary!==null){let t=C(`div`,`muted`,e.summary);t.setAttribute(`data-save-summary`,``),n.append(t)}}else e.kind===`cancelled`?(n.append(C(`span`,void 0,`You cancelled the save.`)),e.total>1?n.append(C(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)):n.append(` `),n.append(r(e.refs,`Download again`))):(n.append(C(`strong`,void 0,`Exported, but the browser didn't save it.`)),e.total>1&&n.append(C(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)),n.append(C(`div`,void 0,e.error),r(e.refs,`Download again`)));return n}function Pi(e,t){let n=C(`button`,`btn btn-icon transport-button`);return n.type=`button`,n.setAttribute(`data-transport-shuttle`,String(e)),n.setAttribute(`aria-label`,t),n.append(S(e===-1?`rewind`:`fastForward`)),n}function Fi(e,t,n){let r=e.querySelector(`[data-transport-play]`),i=e.querySelector(`[data-transport-rate]`),a=e.querySelector(`[data-transport-controls]`),o=e.querySelector(`[data-transport-repeat]`),s=e.querySelector(`[data-transport-skip]`);if(r===null||i===null||a===null||o===null||s===null){r=C(`button`,`btn btn-icon transport-button`),r.type=`button`,r.setAttribute(`data-transport-play`,``),s=C(`button`,`btn btn-icon transport-button`),s.type=`button`,s.setAttribute(`data-transport-skip`,``),s.append(S(`skipBack`)),o=C(`button`,`btn btn-icon transport-button`),o.type=`button`,o.setAttribute(`data-transport-repeat`,``),o.append(S(`repeat`));let t=C(`span`,`transport-pip`);t.setAttribute(`aria-hidden`,`true`),o.append(t),i=C(`span`,`rate`),i.setAttribute(`data-transport-rate`,``),a=C(`div`,`transport-controls`),a.setAttribute(`data-transport-controls`,``),a.append(s,Pi(-1,`Rewind`),r,Pi(1,`Fast forward`),o,i),e.querySelector(`[data-transport-controls]`)?.remove();let n=e.querySelector(`:scope > .transport-end`);n===null?e.append(a):n.before(a)}let c=Math.abs(t.rate);for(let e of a.querySelectorAll(`[data-transport-shuttle]`)){let r=e.dataset.transportShuttle===`-1`?-1:1;e.onclick=()=>n.onShuttle(r),e.disabled=!t.enabled;let i=r===-1?t.playing&&t.rate<0:t.playing&&t.rate>1;e.toggleAttribute(`data-active`,i);let a=r===-1?`Rewind`:`Fast forward`,o=i?`${a}, playing ${r===-1?`backwards`:`forwards`} at ${c}x`:a;e.setAttribute(`aria-label`,o),t.enabled?jr(e,o,[r===-1?`J`:`L`]):(Mr(e),e.title=o)}s.onclick=()=>n.onSkipToStart(),s.disabled=!t.enabled;let l=`Jump to start`;s.setAttribute(`aria-label`,l),t.enabled?jr(s,l,[`Mod`,`Left`]):(Mr(s),s.title=v(`This demo has no frames yet, so there is nothing to play. ${_t(t.authored,t.rerunLine??null,`first`)}`)),o.onclick=()=>n.onLooping(!t.looping),o.toggleAttribute(`data-active`,t.looping),o.setAttribute(`aria-pressed`,t.looping?`true`:`false`);let u=t.looping?`Repeat on — playback loops back to the start`:`Repeat off — playback stops at the end`;o.setAttribute(`aria-label`,u),o.title=u,r.onclick=()=>n.onToggle();let d=t.playing?`Pause`:`Play`;r.setAttribute(`aria-label`,d);let f=t.playing?`pause`:`play`;r.firstElementChild?.getAttribute(`data-icon`)!==f&&r.replaceChildren(S(f)),r.toggleAttribute(`data-playing`,t.playing),r.toggleAttribute(`data-active`,t.playing&&t.rate===1),r.disabled=!t.enabled,t.enabled?jr(r,d,[`Space`]):(Mr(r),r.title=v(`This demo has no frames yet, so there is nothing to play. ${_t(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 Ii(e,t,n,r=e){let i=r.querySelector(`[data-transport-time]`),a=e.querySelector(`[data-stage-actions]`);if(i===null||a===null){i=C(`span`,`stage-clock`),i.setAttribute(`data-transport-time`,``),a=C(`div`,`stage-actions`),a.setAttribute(`data-stage-actions`,``);let t=C(`div`,`segmented`);t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,`Aspect ratio`),t.setAttribute(`data-aspect-toggle`,``);for(let e of[`auto`,`16:9`,`9:16`]){let n=C(`button`,`segment`,e===`auto`?`Auto`:e);n.type=`button`,n.setAttribute(`role`,`radio`),n.setAttribute(`data-aspect`,e),n.title=e===`auto`?`Auto: the video takes the recording's shape`:e===`9:16`?`Vertical: the camera follows each step, cropped for a phone`:`Landscape`,t.append(n)}a.append(t);let n=C(`button`,`btn chip`);n.type=`button`,n.setAttribute(`data-stage-zoom`,``),a.append(n);let o=C(`button`,`btn btn-icon chip chip-icon`);o.type=`button`,o.setAttribute(`data-stage-fullscreen`,``),a.append(o);let s=C(`div`,`stage-error`);s.setAttribute(`data-stage-error`,``),s.setAttribute(`role`,`alert`),s.hidden=!0;let c=C(`span`,`stage-error-text`);c.setAttribute(`data-stage-error-text`,``);let l=C(`button`,`btn btn-icon stage-error-dismiss`);l.type=`button`,l.setAttribute(`data-stage-error-dismiss`,``),l.setAttribute(`aria-label`,`Dismiss`),l.title=`Dismiss`,l.append(S(`close`)),s.append(c,l),r===e?e.replaceChildren(i,a,s):(r.replaceChildren(i),e.replaceChildren(a,s))}i.textContent=`${k(t.positionMs)} / ${k(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`:v(`This demo has no frames yet, so there is nothing to zoom into. ${_t(t.authored,t.rerunLine??null,`first`)}`),o.onclick=()=>n.onZoom());let s=e.querySelector(`[data-stage-fullscreen]`);if(s!==null){let e=t.fullscreen?`Exit full screen`:`Full screen`;s.setAttribute(`aria-label`,e),s.title=e;let r=t.fullscreen?`minimize`:`maximize`;s.firstElementChild?.getAttribute(`data-icon`)!==r&&s.replaceChildren(S(r)),s.onclick=()=>n.onFullscreen()}let c=e.querySelector(`[data-stage-error]`);if(c!==null){c.hidden=t.error===null;let e=c.querySelector(`[data-stage-error-text]`);e!==null&&(e.textContent=t.error??``);let r=c.querySelector(`[data-stage-error-dismiss]`);r!==null&&(r.onclick=()=>n.onDismissError())}}var Li={undo:[`Mod`,`Z`],redo:[`Shift`,`Mod`,`Z`],"shortcuts-open":[`?`]};function Ri(e=document){for(let[t,n,r]of[[`back`,`chevronLeft`,`Back to your demos`],[`undo`,`undo`,`Undo`],[`redo`,`redo`,`Redo`],[`delete`,`trash`,`Delete this demo`],[`shortcuts-open`,`circleQuestionMark`,`Keyboard shortcuts`]]){let i=e.querySelector(`#${t}`);if(i===null)continue;i.setAttribute(`aria-label`,r);let a=Li[t];a===void 0?i.title===``&&(i.title=r):jr(i,r,a),i.querySelector(`svg`)===null&&(i.textContent=``,i.append(S(n)))}}var zi=`#failure > .notice:not([data-capture-note])`;function Bi(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(zi)===null?`warn`:`error`;e.setAttribute(`data-level`,r);let i=`${n} ${n===1?`note`:`notes`} on this take${r===`error`?`, with an error`:``}`;e.setAttribute(`aria-label`,i),e.title=i,e.querySelector(`svg`)===null&&e.append(S(`circleAlert`));let a=e.querySelector(`[data-count]`);a===null&&(a=C(`span`),a.setAttribute(`data-count`,``),a.setAttribute(`aria-hidden`,`true`),e.append(a)),a.textContent=String(n)}function Vi(e,t){let n=[...e.querySelectorAll(zi)].map(e=>e.textContent??``).join(`
|
|
2
|
-
`);return n!==``&&n!==t&&typeof e.showPopover==`function`&&!e.matches(`:popover-open`)&&e.showPopover(),n}function Hi(e,t,n){let r=e.querySelector(`[data-shortcuts-search]`);if(r!==null&&r.value===t.query&&e.dataset.shortcutsMac===String(t.mac)){t.focus&&document.activeElement!==r&&r.focus();return}e.setAttribute(`data-shortcuts`,``),e.dataset.shortcutsMac=String(t.mac);let i=C(`input`,`shortcuts-search`);i.type=`search`,i.placeholder=`Search shortcuts`,i.setAttribute(`aria-label`,`Search shortcuts`),i.setAttribute(`data-shortcuts-search`,``),i.autocomplete=`off`,i.spellcheck=!1,i.value=t.query;let a=C(`div`,`shortcuts-body`),o=[];for(let e of pr){let n=o[o.length-1];if(n?.group!==e.group){let t=C(`section`,`shortcuts-section`);t.append(C(`h3`,`shortcuts-group`,e.group)),a.append(t),n={section:t,group:e.group,rows:[]},o.push(n)}let r=C(`div`,`shortcuts-row`);r.setAttribute(`data-shortcut-row`,``),r.append(C(`span`,`shortcuts-what`,fr(e,t.mac)));let i=C(`span`,`shortcuts-keys`);for(let n of e.combos){let e=C(`span`,`keychord`);e.setAttribute(`data-combo`,``),e.setAttribute(`aria-label`,ur(n,t.mac));for(let r of n){let n=or(r,t.mac),i=C(`kbd`,`keycap`,n);i.setAttribute(`aria-hidden`,`true`),cr(n)&&i.setAttribute(`data-symbol`,``),e.append(i)}i.append(e)}r.append(i),n.section.append(r),n.rows.push(r)}let s=C(`p`,`shortcuts-empty`,`No shortcuts match`);s.setAttribute(`data-shortcuts-empty`,``),a.append(s);let c=()=>{let e=i.value.trim().toLowerCase(),t=0;for(let{section:n,group:r,rows:i}of o){let a=r.toLowerCase().includes(e),o=0;for(let t of i){let n=t.querySelector(`.shortcuts-what`)?.textContent?.toLowerCase()??``;t.hidden=!(a||n.includes(e)),t.hidden||(o+=1)}n.hidden=o===0,t+=o}s.hidden=t>0};c(),i.addEventListener(`input`,()=>{n.onQuery(i.value),c()}),i.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),i.value===``?n.onClose():(i.value=``,n.onQuery(``),c()))}),e.replaceChildren(i,a),t.focus&&i.focus()}function Ui(e){return`${Le(e)}${Pe(e)}`}function Wi(e,t,n=!1){let r=C(`div`,`info-row`);r.append(C(`span`,`info-key`,e));let i=C(`span`,n?`info-value mono`:`info-value`,t);return i.title=t,r.append(i),r}function Gi(e,t,n,r){let i=Wi(e,t,!0),a=C(`button`,`btn btn-quiet btn-icon info-copy`);a.type=`button`,a.setAttribute(`aria-label`,`Copy ${n}`),a.title=`Copy ${n}`,a.setAttribute(`data-copy`,n),a.append(S(`copy`));let o=C(`div`,`info-error`);o.setAttribute(`data-copy-error`,n),o.hidden=!0,a.addEventListener(`click`,()=>{r(t).then(()=>{o.hidden=!0,a.replaceChildren(S(`check`)),a.setAttribute(`aria-label`,`Copied`),a.title=`Copied`},e=>{o.textContent=`Couldn't copy: ${e instanceof Error?e.message:String(e)}`,o.hidden=!1})}),i.append(a);let s=C(`div`);return s.append(i,o),s}function Ki(e,t,n){let r=C(`div`,`info-group`);r.setAttribute(`data-info-facts`,``);let i=`${_(t.durationMs)} · ${t.steps} ${t.steps===1?`step`:`steps`}`,a=t.aspect===`auto`?`Auto`:t.aspect;r.append(Wi(`Recorded`,Di(t.recordedAt)),Wi(`Site`,Ui(t.site)),Wi(`Length`,i),Wi(`Recording`,`${t.recording.width} × ${t.recording.height}`),Wi(`Video`,`${t.target.width} × ${t.target.height} · ${a}`));let o=C(`div`,`info-group`);if(o.setAttribute(`data-info-ids`,``),o.append(Gi(`Take ID`,t.takeId,`take ID`,n.onCopy)),t.rerun.kind===`link`){let e=C(`div`,`info-row`);e.append(C(`span`,`info-key`,`Re-record`));let n=C(`a`,`info-value`,t.rerun.label);n.setAttribute(`href`,t.rerun.href),n.setAttribute(`data-runs-route`,``),e.append(n),o.append(e)}let s=[r,o];if(t.history.outputs.length>0){let e=C(`div`,`info-group info-exports`);if(e.setAttribute(`data-info-exports`,``),e.append(C(`div`,`info-label`,`Exports`)),t.revealError!==null){let n=C(`p`,`notice notice-warn`,t.revealError);n.setAttribute(`data-reveal-error`,``),e.append(n)}let r=C(`div`,`info-history`);Ci(r,t.history,n),e.append(r),s.push(e)}e.replaceChildren(...s)}var qi=.006,M=e=>`${(e*100).toFixed(4)}%`;function Ji(e,t,n,r=qi){if(n<e.startMs||t>e.endMs)return null;let i=Math.max(0,j(e,t)),a=Math.min(1,j(e,n)),o=Math.max(r,a-i);return{left:Math.min(i,1-o),width:o,toScale:a-i>=r}}var Yi=(e,t)=>Math.min(1,Math.max(0,j(e,t))),Xi=[100,250,500,1e3,2e3,5e3,1e4,15e3,3e4,6e4],Zi=(e,t)=>t>=1e3?k(e):`${k(e)}.${Math.floor(e%1e3/100)}`;function Qi(e,t){let n=C(`div`,`ruler`);n.setAttribute(`data-ruler`,``),n.setAttribute(`data-source`,e.timeSource);let r=(t.viewport.endMs-t.viewport.startMs)/10,i=Xi.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=j(t.viewport,e),a=C(`span`,`tick`,Zi(e,i));a.style.left=M(r),a.dataset.fraction=String(r),n.append(a)}return ea?.observe(n),n}function $i(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 ea=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>{for(let t of e){let e=t.target;e.isConnected?$i(e):ea?.unobserve(e)}});function ta(e,t){let n=C(`div`,`lane`);return n.append(e,t),n}function na(e,t,n){let r=C(`div`,`lane-label lane-head`),i=C(`span`,`lane-title`),a=C(`span`,`lane-glyph`);return a.append(S(t)),i.append(a,C(`span`,`lane-name`,e)),n&&i.append(n),r.append(i),r}function ra(e){let t;if(e.failed)t=`The hover check could not run, so nothing here has been checked.`;else if(e.unchecked>0)t=`${e.unchecked} ${e.unchecked===1?`hover`:`hovers`} could not be checked.`;else return null;let n=C(`span`,`lane-flag`);return n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,t),n.title=t,n.setAttribute(`data-hover-check`,e.failed?`failed`:`unchecked`),n}var ia=3;function aa(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 oa=(e,t)=>e!==null&&t!==null&&e.kind===t.kind&&(e.kind===`tick`?e.actionId===t.actionId:e.kind===`piece`?wt(e.start,t.start):e.id===t.id),sa=(e,t)=>e.snapping?8*t:0;function ca(e,t){let n=e.getBoundingClientRect().width;return n===0?0:(t.endMs-t.startMs)/n}function la(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 ua(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=ca(t,n.viewport);return{toMs:la(t,n.viewport,e),deltaMs:(e-s)*r,snapMs:sa(n,r)}},u=e=>{Math.abs(e.clientX-s)>ia&&(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 da=e=>Math.max(0,Math.min(1,e));function fa(e,t,n,r){let i=da(r);t.style.left=M(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=M(l),a.style.width=M(Math.max(s,c)-l)}function pa(e,t,n,r,i){let a=C(`div`,`edge`);return a.setAttribute(`data-edge`,t),a.setAttribute(`aria-label`,t===`start`?`Drag the piece's start`:`Drag the piece's end`),ua(a,n,r,({deltaMs:n})=>({kind:`pieceEdge`,start:e.start,side:t,deltaMs:n}),i,{move:({deltaMs:e})=>{let i=e/ca(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 ma(e,t,n,r){let i=C(`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=C(`div`,`join-card-what`),o=C(`b`),s=C(`span`);e.unplaced===void 0?(o.textContent=`${n} removed`,s.textContent=`${ha(e.srcStartMs)} to ${ha(e.srcEndMs)}`):(o.textContent=`Removes no frames`,s.textContent=e.unplaced.charAt(0).toUpperCase()+e.unplaced.slice(1)),a.append(o,s);let c=C(`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 ha(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 ga(e,t,n){let r=C(`div`,`track`);r.setAttribute(`data-track`,`clip`);let{clip:i}=e;for(let e of i.degraded){let n=Ji(t.viewport,e.startMs,e.endMs,0);if(n===null)continue;let i=C(`div`,`degraded`);i.setAttribute(`data-degraded`,``),i.style.left=M(n.left),i.style.width=M(n.width),r.append(i)}let a=j(t.viewport,i.trim.headMs),o=j(t.viewport,i.trim.tailMs),s=Ji(t.viewport,i.trim.headMs,i.trim.tailMs);if(s!==null){let e=C(`div`,`seg`);e.setAttribute(`data-clip-block`,``),e.setAttribute(`data-kind`,`clip`),e.setAttribute(`data-to-scale`,String(s.toScale)),e.style.left=M(s.left),e.style.width=M(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=Ji(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=C(`div`,`piece-wrap`);d.style.left=M(o),d.style.width=M(u-o);let f=C(`button`,`piece`);f.type=`button`,f.setAttribute(`data-piece`,String(e.startMs)),f.setAttribute(`aria-label`,`Piece of the clip`),oa(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(pa(e,`start`,r,t,n)),(!m||e.after!==null)&&d.append(pa(e,`end`,r,t,n)),c.append(d)}));for(let e of i.joins){let i=j(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(${M(i)} + ${a}px)`,s=t.openJoin===e.removedId,c=`${((e.srcEndMs-e.srcStartMs)/1e3).toFixed(1)}s`,l=C(`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)>ia;u=null,r||n.onOpenJoin(s?null:e.removedId)});let d=C(`span`,`seam`);d.setAttribute(`data-seam`,e.removedId),d.style.left=o,r.append(d,l),s&&r.append(ma(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=C(`div`,`handle`);a.setAttribute(`data-trim`,e),a.setAttribute(`data-timing`,c),a.style.left=M(s),ua(a,r,t,({toMs:t,snapMs:n})=>({kind:`trim`,edge:e,toMs:t,snapMs:n}),n,{move:({toMs:n})=>fa(r,a,e,j(t.viewport,n)),end:()=>fa(r,a,e,s)}),r.append(a)}for(let e of i.ticks){let a=j(t.viewport,e.atMs);if(a<0||a>1)continue;let o=C(`button`,`tick`);o.type=`button`,o.setAttribute(`data-tick`,e.actionId),o.setAttribute(`data-verb`,e.verb);let s=Ca[e.verb];s!==void 0&&o.append(S(s)),o.setAttribute(`data-timing`,e.timing),o.setAttribute(`aria-label`,`${e.verb} ${e.label}`),o.title=`${e.verb} ${e.label}`,e.timing===`estimated`&&(o.setAttribute(`data-not-in-video`,``),o.title=o.title?`${o.title} — not in the video`:`Not in the video`),e.flag&&o.setAttribute(`data-flag`,e.flag),e.cut&&o.setAttribute(`data-cut`,``);let c=String(_a(i.ticks,e));o.setAttribute(`data-stack-index`,c),o.style.setProperty(`--tick-stack`,c),oa(t.selection,{kind:`tick`,actionId:e.actionId})&&o.setAttribute(`data-selected`,``),o.style.left=M(a),o.addEventListener(`click`,t=>{t.stopPropagation(),n.onSelect({kind:`tick`,actionId:e.actionId})}),r.append(o)}return r}function _a(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=Ji(i.viewport,s,c);if(l===null)return null;let u=C(`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=M(l.left),u.style.width=M(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};oa(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(C(`span`,`seg-label`,`${t.scale.toFixed(1)}x`))}else p&&u.setAttribute(`data-whole-take`,``),u.append(C(`span`,`seg-label`,p?`mask · whole take`:`mask`));if(u.addEventListener(`click`,e=>{e.stopPropagation(),a.onSelect(f)}),!p){let r=(e,t)=>{u.style.left=M(e),u.style.width=M(t)},o=()=>r(l.left,l.width),s=i.viewport.endMs-i.viewport.startMs;for(let s of[`start`,`end`]){let c=C(`div`,`cap`);c.setAttribute(`data-cap`,s),ua(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=da(j(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)}ua(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 ya(e,t,n,r){let i=C(`div`,`track`);i.setAttribute(`data-track`,e);let a=e===`zoom`?t.zooms:t.masks;for(let o of a){let a=va(o,e,i,t,n,r);a&&i.append(a)}return i.addEventListener(`click`,a=>{if(a.target!==i)return;let o=ca(i,n.viewport);r.onGesture({kind:e===`zoom`?`addZoom`:`addMask`,atMs:ba(e,t,la(i,n.viewport,a.clientX)),snapMs:sa(n,o)})}),Sa(i,e,t,n),i}function ba(e,t,n){let r=e===`zoom`?(t.zoomDefaultMs-t.zoomInMs)/2:Ut/2;return Math.max(0,Math.min(t.durationMs,n-r))}function xa(e,t,n){let r=e===`zoom`?$t(t,n):en(t,n);return Wt(r)?null:e===`mask`?{startMs:r.startMs,endMs:r.endMs}:{startMs:Ft(t.zooms,r.startMs,t.zoomInMs),endMs:It(t.zooms,r.startMs,r.endMs)}}function Sa(e,t,n,r){let i=null,a=()=>{i?.remove(),i=null};e.addEventListener(`pointermove`,o=>{if(o.target!==e)return a();let s=xa(t,n,ba(t,n,la(e,r.viewport,o.clientX))),c=s&&Ji(r.viewport,s.startMs,s.endMs);if(c===null)return a();i===null&&(i=C(`div`,`seg`),i.setAttribute(`data-ghost`,t),i.setAttribute(`aria-hidden`,`true`),e.append(i)),i.style.left=M(c.left),i.style.width=M(c.width)}),e.addEventListener(`pointerleave`,a)}var Ca={click:`mousePointerClick`,type:`type`,moveTo:`mousePointer2`,scrollTo:`moveVertical`,waitFor:`hourglass`,drag:`handGrab`};function wa(e,t,n,r){let i=C(`div`,`timeline`);if(i.addEventListener(`click`,e=>{e.target?.closest(`[data-ruler], [data-trim], [data-playhead], [data-track="zoom"], [data-track="mask"], button`)||r.onSelect(null)}),t.timeSource===`captured`){let e=C(`p`,`muted`);ue(e,t.rerunLine===null?`Timing from the take, not from a render — ${tt(t.authored)} to see the timing this demo will actually have.`:`Timing from the take, not from a render. ${t.rerunLine}`),i.append(e)}let a=Qi(t,n);aa(a,()=>a.getBoundingClientRect(),n,t.durationMs,r);let o=C(`div`,`lanes`);o.append(ta(C(`b`,`lane-label`),a));let s=C(`div`,`axis`);s.setAttribute(`data-axis`,``),i.addEventListener(`wheel`,e=>{let i=s.getBoundingClientRect();if(i.width===0)return;if(e.ctrlKey||e.metaKey){e.preventDefault();let a=(e.clientX-i.left)/i.width;r.onViewport(Tr(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(Er(n.viewport,t.durationMs,a/i.width*o))});let c=na(`Clip`,`film`),l=ra(t.hoverCheck);l!==null&&c.querySelector(`.lane-glyph`)?.append(l);let u=ta(c,ga(t,n,r));u.setAttribute(`data-lane`,`clip`),o.append(u);let d=ta(na(`Zoom`,`zoomIn`),ya(`zoom`,t,n,r));d.setAttribute(`data-lane`,`zoom`),o.append(d);let f=C(`button`,`btn btn-quiet btn-icon lane-add`);f.type=`button`,f.setAttribute(`data-add-mask`,``),f.setAttribute(`aria-label`,`Add a mask at the playhead`),f.title=`Add a mask at the playhead`,f.append(S(`plus`)),f.onclick=()=>{let e=i.querySelector(`[data-track="clip"]`),t=e?ca(e,n.viewport):0;r.onGesture({kind:`addMask`,atMs:n.positionMs,snapMs:sa(n,t)})};let p=ta(na(`Mask`,`eyeOff`,f),ya(`mask`,t,n,r));p.setAttribute(`data-lane`,`mask`),o.append(p);let m=C(`div`,`playhead`);m.setAttribute(`data-playhead`,``),m.style.left=M(Yi(n.viewport,n.positionMs));let h=C(`div`,`grab`);h.setAttribute(`data-playhead-grab`,``),h.setAttribute(`aria-hidden`,`true`),aa(h,()=>s.getBoundingClientRect(),n,t.durationMs,r),m.append(h),s.append(m),o.append(s),i.append(o);let g=C(`p`,`refusal`);ue(g,n.refusal??``),g.setAttribute(`data-refusal`,``),g.hidden=n.refusal===null,i.append(g);let _=e.ownerDocument.activeElement,v=_ instanceof HTMLElement&&e.contains(_)&&_.matches(`[data-lane="mask"] [data-add-mask]`);e.replaceChildren(i),v&&f.focus();let y=i.querySelector(`[data-join-card]`);y!==null&&Ta(y)}function Ta(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 Ea(e){let t=C(`button`,`btn btn-quiet btn-icon tool`);return t.type=`button`,t.append(S(e)),t}function Da(e,t,n){e.setAttribute(`aria-label`,t),e.disabled?(Mr(e),e.title=t):jr(e,t,n)}var Oa=new WeakMap;function ka(){let e=C(`div`,`bar-controls`);e.setAttribute(`data-timeline-tools`,`view`);let t=Ea(`magnet`);t.classList.add(`snap`);let n=Ea(`moveHorizontal`);n.classList.add(`fit`),n.setAttribute(`data-fit`,``);let r=Ea(`scissors`);r.setAttribute(`data-split-tool`,``);let i=C(`div`,`zoom-control`);i.setAttribute(`data-zoom-control`,``);let a=C(`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=Ea(`zoomOut`);o.classList.add(`zoom-step`),o.setAttribute(`data-zoom-step`,`out`);let s=Ea(`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 Aa(e,t,n,r){let i=Oa.get(e);(i===void 0||i.view.parentElement!==e)&&(i=ka(),Oa.set(e,i),e.replaceChildren(i.view));let{split:a,snap:o,fit:s,zoom:c,zoomOut:l,zoomIn:u}=i;Da(a,`Split at playhead`,[`Mod`,`B`]),a.onclick=()=>r.onSplit(),Da(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=Sr(t.durationMs),f=n.viewport.startMs===d.startMs&&n.viewport.endMs===d.endMs;s.disabled=f,Da(s,f?`The whole take is already in view`:`Fit the whole take`,[`Shift`,`Z`]),s.onclick=()=>r.onViewport(d);let p=n.viewport.endMs-n.viewport.startMs,m=kr(t.durationMs,p);c.value=String(m),c.style.setProperty(`--fill`,`${(m*100).toFixed(2)}%`);let h=t.durationMs>250;c.disabled=!h,c.title=h?`Zoom the timeline (⌘-scroll, ⇧Z to fit)`:`This take is too short to zoom into.`,c.oninput=()=>{let e=Or(t.durationMs,Number(c.value)),i=j(n.viewport,n.positionMs);r.onViewport(Dr(n.viewport,t.durationMs,e,i>=0&&i<=1?i:.5))};let g=e=>{let i=Math.min(1,Math.max(0,j(n.viewport,n.positionMs)));r.onViewport(Tr(n.viewport,t.durationMs,e,i))};l.disabled=!h||m<=5e-4,l.onclick=()=>g(1/nr),Da(l,`Zoom out`,[`−`]),u.disabled=!h||m>=.9995,Da(u,`Zoom in`,[`+`]),u.onclick=()=>g(nr)}var N=oe();function P(e){console.error(`demoman editor:`,e)}var ja=N.kits,F={state:`ready`,kits:[],defaultId:null,migrationPending:!1},Ma=null,Na=null;function Pa(e){let t=F;if(t.state!==`ready`)return null;let n=t.kits.filter(e=>e.read.state===`ready`),r=n.filter(t=>t.read.state===`ready`&&De(t.read.kit,e)),i=r.find(e=>e.id===Ma)??r.find(e=>e.id===t.defaultId)??r[0];if(i!==void 0)return Ma=i.id,{kit:i,edited:!1};let a=n.find(e=>e.id===Ma);return a===void 0?null:{kit:a,edited:!0}}var Fa=N.bundles,Ia=new URL(location.href).searchParams.get(`scene`)??``,I=e=>{let t=document.getElementById(e);if(!t)throw Error(`editor is missing #${e}`);return t},La=null,Ra=!1,L=tr({sceneId:Ia,loadScene:async e=>{let t=await N.scenes.get(e);if(t===null)throw Error(`no scene "${e}"`);return jo??=t.notes,Ra||=(La=t.revision,!0),t.scene},saveScene:async e=>{La=(await N.scenes.put(e,La)).revision},bundles:{active:e=>Fa.active(e)},newId:()=>crypto.randomUUID()});function R(e){let t=L.snapshot().scene;return L.dispatch(e).catch(P).then(()=>za(t))}function za(e){if(po===null)return;let t=L.snapshot();t.scene!==e&&t.error===null&&(po=null,$(t))}var z=at,Ba=null,B=null,Va=!1;function Ha(e){e!==B&&(Va=!1),B=e}var Ua=null,Wa=null,Ga=[],Ka=null,qa=null,Ja=null,V=null,Ya=null,H=`export`,U=!0,Xa=`export`,Za=kn(),W=`mp4`;function Qa(e){let t=L.snapshot().scene;return _e(W,t.canvas.aspect,e,Me({...t,branding:Zo(t)}),$a===null?{}:{quality:$a})}var $a=N.exportQuality===void 0?null:`share`,eo=null;function to(e){return eo?.scene!==e&&(eo={scene:e,digest:nt(e)}),eo.digest}var no=`fit`;function ro(e){e!==null&&e.kind!==`piece`?(H!==`selection`&&(Xa=H),H=`selection`,U=!0):H===`selection`&&(H=Xa),V=e}var io=null,ao=null,oo=0,G=null,so=!0,co=!1,lo=``,uo=!1,fo=null,po=null,mo=[];function ho(){return mo.flatMap(e=>e.kind===`stored`?[e.output]:[])}var go=!1,_o=new Set,K=vn(me),q=null,J=null,vo=I(`preview`),yo=new OffscreenCanvas(K.width,K.height),bo=yo.getContext(`2d`);function xo(e){let t=Qa(e),n=Os(e,I(`stage-frame`).getBoundingClientRect().width),r=n.width!==K.width||n.height!==K.height;K=n,r&&(yo=new OffscreenCanvas(K.width,K.height),bo=yo.getContext(`2d`)),q=null;let i=I(`stage`);i.style.setProperty(`--frame-ratio`,`${t.width} / ${t.height}`),i.style.setProperty(`--frame-px`,String(vn(t).width))}var So=150,Co=null,wo=!1,To=!1;document.addEventListener(`pointerdown`,()=>{wo=!0},!0);var Eo=()=>{wo=!1,To&&setTimeout(()=>{To&&!wo&&$(L.snapshot())},0)};window.addEventListener(`pointerup`,Eo,!0),window.addEventListener(`pointercancel`,Eo,!0);var Do=new ResizeObserver(()=>{let e=I(`stage`),t=I(`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`),_c&&(Co!==null&&clearTimeout(Co),Co=setTimeout(()=>{Co=null;let e=Os(L.snapshot().bundle,I(`stage-frame`).getBoundingClientRect().width);(e.width!==K.width||e.height!==K.height)&&(wo&&(Xo!==null||Jo!==null)?(us(),To=!0):$(L.snapshot()))},So))});Do.observe(I(`stage-frame`)),Do.observe(I(`stage`));var Oo=[],ko=null,Ao=``,jo=null,Mo=`The video shows the text that was recorded; re-record to type the new text.`;function No(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 Po=null,Fo=null,Io=0,Lo=null,Ro=Cn(e=>e.motionSpans.length>0?he(e,Fa.load,{onSpanUnavailable:(e,t)=>console.info(`[demoman] preview: span ${e} could not be decoded (${t})`)}):Promise.resolve(t(e,Fa.load)));async function zo(e){let{bundle:t,scene:n}=e;if(t===null||ln(ko,e))return;ko=cn({scene:n,bundle:t}),Oo=[];let r=f(n).retiming.motionDiffThreshold,i=()=>{let e=L.snapshot();return e.scene===n&&e.bundle===t},a;try{a=await Ro(t),Oo=await x(t,a,r)}catch(e){P(e),i()&&L.setHoverReport(un),$(L.snapshot());return}try{let e=await Ue(n,t,a,r);if(i()){let t=h(L.snapshot().scene);L.setHoverReport(fn(e,t))}}catch(e){P(e),i()&&L.setHoverReport(un)}$(L.snapshot())}var Bo=null,Vo=null,Ho=null,Y=null,Uo=``,Wo=null,Go=null,Ko=null,qo=null,Jo=null,Yo=null,Xo=null;function Zo(e){let t=be(Xo,e,P);return Xo=t.preview,t.branding}function Qo(e){Xo={patch:e,scene:L.snapshot().scene},us();let t=L.snapshot();es(t,Qa(t.bundle))}function $o(e){Ba!==null&&(Ba=null,$(L.snapshot())),N.files.reveal(e).catch(e=>{let t=On(e);t.expected?console.info(`demoman editor: ${t.text}`):P(e),Ba=t.text,$(L.snapshot())})}function es(e,t){let n=je({durationMs:Es-Z,fileType:W,target:t,hasFrames:zs(e).kind!==`noFrames`}),r=I(`take-meta`);r.textContent=n,r.setAttribute(`aria-label`,`Take info: ${n}`)}var ts=null;function ns(e){return Jo===null?e.cursor:{...e.cursor,...Jo}}function rs(e){let t=e.motion??le;return Yo===null?t:{...t,...Yo}}var is=null,as=null;function os(e){Jo=e,us()}function ss(e){Yo=e,us()}function cs(){Yo!==null&&(Yo=null,us())}function ls(){Jo!==null&&(Jo=null,us())}function us(){as===null&&(as=requestAnimationFrame(()=>{as=null;let e=L.snapshot();ms(e),J&&(ts=ns(e.scene),is=rs(e.scene),Lo=q,Q.seek(Q.positionMs))}))}function ds(){as!==null&&cancelAnimationFrame(as),as=null,Jo=null,Yo=null}function fs(e){return e===null?null:Wo?.ref===e?Wo.thumb:{kind:`loading`}}async function ps(e){let t=Zo(e.scene),n=t.logo?.ref??null;if(n!==Vo&&(Vo=n,Ho=null,Y=null,Bo=null,Uo=``,n!==null)){let e=await N.logos.load(n);if(Vo!==n)return;e.ok?Ho=e.source:Y=e.error}let r=u(t,K),i=`${n}@${r}`;if(Ho!==null&&r>0&&i!==Uo){Uo=i;try{let e=await Ho.rasterAt(r);if(Vo!==n||Uo!==i)return;Bo=e,Y=null}catch(e){Bo=null,Y=e instanceof Error?e.message:String(e)}}let a=null;if(n!==null){if(Ho!==null){try{a={kind:`ready`,url:await Te(Ho)}}catch(e){a={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(Vo!==n)return}else a=Y===null?{kind:`loading`}:{kind:`failed`,reason:Y}}let o=JSON.stringify(a)!==JSON.stringify(Wo?.thumb??null)||(Wo?.ref??null)!==n;Wo=n===null?null:{ref:n,thumb:a};let s=Ho?Se(Ho,u(t,Qa(e.bundle)),ke(W,e.scene.canvas.aspect)):null,c=[qo?.ref===n?qo.note:null,s].filter(e=>e!==null),l=o||Bo!==Go||Y!==Ko||c.join(`
|
|
3
|
-
`)!==Ga.join(`
|
|
4
|
-
`);Ga=c,Go=Bo,Ko=Y,l&&$(L.snapshot())}function ms(e){xo(e.bundle);let{scene:t,bundle:n}=e,r=wn(t,{cursor:ns(t),branding:Zo(t),motion:Yo===null?t.motion:rs(t)}),i=n?b({plan:f(r),bundle:n,scene:r,target:K,detailTarget:Qa(n),hints:Oo,logo:Bo}):null;J=i?.resolved??null,q=i?.presentation??null,vo.width!==K.width&&(vo.width=K.width),vo.height!==K.height&&(vo.height=K.height)}var hs=[];function gs(e,t){let n=t.width*t.height/1e6;n<=0||(hs.push(e/n),hs.length>60&&hs.splice(0,hs.length-30))}var _s=null,vs=!1,X={requestedFrames:0,drawnFrames:0,elapsedMs:0,sourceLookupMs:0,composeMs:0,blitMs:0},ys=0,bs=null,xs=0,Ss=0;function Cs(){X.requestedFrames=0,X.drawnFrames=0,X.elapsedMs=0,X.sourceLookupMs=0,X.composeMs=0,X.blitMs=0,xs=0,Ss=0,ys=performance.now()}function ws(){if(Q.playing===vs)return;if(vs=Q.playing,$(L.snapshot()),vs){bs={width:K.width,height:K.height},Cs();return}X.elapsedMs=performance.now()-ys;let e=(L.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},...bs===null?{}:{bitmap:bs},parkedHeight:K.height,msPerMegapixel:gn(hs),...Ss>0?{decodeMs:xs}:{}}))}var Ts=xn({schedule:e=>requestAnimationFrame(e),onDrawFailed:e=>{Ha(e instanceof Error?e.message:String(e)),Q.pause(),$(L.snapshot())},onDrawRecovered:()=>{B!==null&&(B=null,$(L.snapshot()))},draw:async e=>{let t=L.snapshot(),n={resolved:J,presentation:q,target:K,offscreen:yo,offscreenCtx:bo};if(!n.resolved||!n.presentation||!t.bundle)return;let r=performance.now(),i=await Ro(t.bundle),a=performance.now();await ne({resolved:n.resolved,target:n.target,presentation:n.presentation,frames:i,ctx:n.offscreenCtx,outputTimeMs:e,onStage:vs?(e,t)=>{e===`fetch`&&(xs+=t,Ss+=1)}:void 0});let o=performance.now();n.offscreen===yo&&(gs(o-a,n.target),vo.getContext(`2d`)?.drawImage(yo,0,0),io&&(V?.kind===`mask`||V?.kind===`zoom`)&&yr(I(`stage-overlay`),{canvas:vo,selection:V,model:io,resolved:n.resolved,presentation:n.presentation,target:n.target,outputTimeMs:e},{onMaskRect:(e,t)=>R({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>R({kind:`setZoomTarget`,id:e,point:t})}),vs&&(X.drawnFrames+=1,X.sourceLookupMs+=a-r,X.composeMs+=o-a,X.blitMs+=performance.now()-o))}}),Z=0,Es=0,Ds=!1,Q=Sn({seek:e=>{vs&&(X.requestedFrames+=1),Ts.seek(e)},durationMs:()=>Ds?Es:0,startMs:()=>Z,looping:()=>co,now:()=>performance.now(),schedule:e=>requestAnimationFrame(e),onChange:()=>{ws(),js()}});function Os(e,t){let n=Qa(e),r=()=>_n({target:n,paintedCssWidth:t,devicePixelRatio:window.devicePixelRatio,playing:Q.playing,msPerMegapixel:gn(hs)});return Q.playing?(_s??=r(),vn(n,_s)):(_s=null,vn(n,r()))}function ks(e){e!==L.snapshot().scene.canvas.aspect&&R({kind:`setAspect`,aspect:e}).then(()=>Q.seek(Q.positionMs))}function As(e){if(e===W)return;let t=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-file-type`);W=e,$(L.snapshot()),t&&document.querySelector(`[data-file-type="${e}"]`)?.focus(),Q.seek(Q.positionMs)}console.info(`demoman editor: panel transition "${getComputedStyle(document.body).transitionProperty}"`),document.body.addEventListener(`transitionend`,e=>{e.target===document.body&&e.propertyName===`grid-template-columns`&&(V?.kind===`mask`||V?.kind===`zoom`)&&Q.seek(Q.positionMs)});function js(){Fi(I(`transport`),{authored:et(L.snapshot().scene),rerunLine:gt(Bs(L.snapshot())),playing:Q.playing,enabled:Ds&&Es>Z,rate:Q.rate,looping:co},{onToggle:Ms,onSkipToStart:()=>mc({kind:`seekEdge`,edge:`head`},L.snapshot()),onLooping:e=>{co=e,js()},onShuttle:e=>{B=null,Q.shuttle(e)}});for(let[e,t]of[[I(`stage-tools`),I(`toolbar-clock`)],[I(`stage-bar`),I(`stage-bar`)]])Ii(e,{authored:et(L.snapshot().scene),rerunLine:gt(Bs(L.snapshot())),positionMs:Q.positionMs-Z,durationMs:Es-Z,aspect:L.snapshot().scene.canvas.aspect,enabled:Ds&&Es>Z,fullscreen:!!document.fullscreenElement,error:Va?null:B,zoom:no},{onAspect:ks,onFullscreen:Ps,onZoom:Ns,onDismissError:()=>{Va=!0,js()}},t);let e=I(`timeline`).querySelector(`[data-playhead]`);e&&G&&(e.style.left=`${(Yi(G,Q.positionMs)*100).toFixed(4)}%`)}function Ms(){B=null,Q.toggle(),$(L.snapshot())}function Ns(){no=no===`fit`?`actual`:`fit`,document.body.dataset.zoom=no,js()}function Ps(){B=null;let e=!document.fullscreenElement;(e?I(`stage`).requestFullscreen():document.exitFullscreen()).catch(t=>{Ha(`The preview could not ${e?`go full screen`:`exit full screen`}: ${t instanceof Error?t.message:String(t)}`),$(L.snapshot())})}document.addEventListener(`fullscreenchange`,()=>{let e=document.activeElement;B=null,js();let t=!!document.fullscreenElement;I(`stage`).toggleAttribute(`data-fullscreen`,t);let n=I(t?`stage-tools`:`stage-bar`),r=I(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 Fs(){let e=L.snapshot();Is(Ct(e.scene,e.bundle,J?.timeline??null,Q.positionMs))}function Is(e){if(e!==null){if(Wt(e)){po=e.reason,$(L.snapshot());return}R(e)}}function Ls(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);R(e).then(()=>{let r=L.snapshot();n(r.scene)||V?.kind===t&&V.id===e.id&&(ro(null),$(r))})}function Rs(e){if(P(e),Ka=e instanceof Error?e.message:String(e),_c){$(L.snapshot());return}ii(I(`failure`),{error:null,replaySentence:null,captureSentence:null,openError:Ka})}function zs(e){return e.bundle===null?{kind:`noFrames`}:{kind:`exact`}}function Bs(e){let t=et(e.scene);return{takeId:Ia,authored:t,rerun:N.nav.rerun(Ia,t)}}function Vs(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){To=!1,ds(),ms(e);let t=Vs(J);t!==Po&&(Po=t,console.info(t));let n=br({scene:e.scene,bundle:e.bundle,resolved:J}),i=I(`name`);i.value=e.scene.meta.name,i.placeholder=Ie(e.scene.meta),I(`undo`).disabled=!e.canUndo,I(`redo`).disabled=!e.canRedo,ti(I(`banner`),{hasFrames:e.bundle!==null,route:Bs(e)}),Ua!==null&&e.scene!==Wa&&(Ua=null),ii(I(`failure`),{error:e.error??Ua,replaySentence:e.replaySentence,replayRecoverable:e.replayRecoverable,captureSentence:e.captureSentence,renderError:z.error,previewError:B,logoLoadError:Y,openError:Ka,deleteError:qa,navigationError:Ja,runsRoute:Bs(e)});let a=Pt({scene:e.scene,view:n,bundle:e.bundle,resolved:J,hoverReport:e.hoverReport,rerunLine:gt(Bs(e))});io=a,ao=n,oo=a.durationMs,(G===null||fo!==a.durationMs)&&(G=Sr(a.durationMs),fo=a.durationMs);let o={resolved:J,bundle:e.bundle,viewport:e.scene.meta.capture.viewport},s=e=>Is(an(a,n,e,o)),c=e=>{G=e,$(L.snapshot())},l=e=>{so=e,$(L.snapshot())};wa(I(`timeline`),a,{viewport:G,selection:V,get positionMs(){return Q.positionMs},refusal:po,hoverReport:e.hoverReport,snapping:so,openJoin:Ya},{onSelect:e=>{ro(e),$(L.snapshot())},onSeek:e=>Q.seek(e),onSeekStart:()=>Q.pause(),onSplit:Fs,onRestorePiece:e=>{Ya=null,R({kind:`restorePiece`,id:e})},onOpenJoin:e=>{Ya=e,$(L.snapshot())},onGesture:s,onViewport:c,onSnapping:l}),ei(I(`take-notes`),{notices:[...jo??[],...No(e)?[Mo]:[],...a.notices],hoverReport:e.hoverReport}),Aa(I(`timeline-tools`),a,{viewport:G,snapping:so,get positionMs(){return Q.positionMs}},{onGesture:s,onSplit:Fs,onViewport:c,onSnapping:l});let u=V;u?.kind===`piece`&&!a.clip.pieces.some(e=>wt(e.start,u.start))&&(V=null);let d=u?.kind===`tick`&&n.beats.some(e=>e.actionId===u.actionId)||u?.kind===`zoom`&&a.zooms.some(e=>e.id===u.id)||u?.kind===`mask`&&a.masks.some(e=>e.id===u.id);H===`selection`&&!d&&(V===null&&P(Error(`the rail was on Selection with nothing selected`)),ro(null)),document.body.dataset.panel=U?`open`:`closed`,Gr(I(`rail`),{rail:H,panelOpen:U,hasSelection:d},{onPick:hc}),Kr(I(`export-open`),{rail:H,panelOpen:U},{onPick:hc}),qr(I(`shortcuts-open`),{rail:H,panelOpen:U},{onPick:hc});let f=document.activeElement?.matches(`[data-shortcuts-search]`)===!0;Hr(I(`inspector`),{selection:V,view:n,model:a,scene:e.scene,hoverReport:e.hoverReport,viewport:e.scene.meta.capture.viewport,rail:H,sections:Za,attachedToCuts:J?.plan.attachedToCuts??[]},{onClose:gc,onGap:(e,t)=>Is(on(n,e,t)),onGapClear:e=>R({kind:`clearGap`,afterActionId:e}),onKeepHover:Hs,onZoomOnStep:e=>{let t=n.beats.find(t=>t.actionId===e);if(!t?.anchorId)return;let i=new Set(L.snapshot().scene.camera.map(e=>e.id));R({kind:`addZoom`,marker:{actionId:e,offsetMs:0},target:{kind:`element`,anchorId:t.anchorId},scale:r.defaultZoomScale}).then(()=>{let e=L.snapshot().scene.camera.find(e=>!i.has(e.id));e&&(ro({kind:`zoom`,id:e.id}),$(L.snapshot()))})},onZoomScale:(e,t)=>R({kind:`setZoomScale`,id:e,scale:t}),onRemoveZoom:e=>Ls({kind:`removeZoom`,id:e}),onMaskNote:(e,t)=>R({kind:`setMaskNote`,id:e,note:t}),onRemoveMask:e=>Ls({kind:`removeMask`,id:e})});let p=document.querySelector(`#inspector [data-panel-shortcuts]`);p!==null&&Hi(p,{mac:dr(navigator.userAgent),query:lo,focus:U&&(uo||f)},{onClose:gc,onQuery:e=>{lo=e}}),uo=!1,yr(I(`stage-overlay`),{canvas:vo,selection:V,model:a,resolved:J,presentation:q,target:K,outputTimeMs:Q.positionMs},{onMaskRect:(e,t)=>R({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>R({kind:`setZoomTarget`,id:e,point:t})});let m=I(`inspector`);m.querySelector(`.inspector`)===null&&P(Error(`the inspector has not rendered anything`));let h={export:`export`,branding:`background`,cursor:`cursor`},g=e=>{let t=m.querySelector(`[data-panel-${e}]`);return t===null&&H===h[e]&&U&&P(Error(`the inspector's ${e} panel is missing`)),t},_=g(`branding`);_&&ai(_,{branding:e.scene.branding,logoThumb:fs(e.scene.branding.logo?.ref??null),logoPlacement:q?.logoPlacement??null,formatTitle:ke(W,e.scene.canvas.aspect),logoNotes:Ga,kit:{read:F,standing:Pa(e.scene.branding),naming:Na,onApply:e=>{let t=F.state===`ready`?F.kits.find(t=>t.id===e):void 0;if(t?.read.state!==`ready`){Ua=t===void 0?`That brand kit was not applied: it was deleted in another tab.`:`That brand kit was not applied: ${t.read.reason}.`,Wa=L.snapshot().scene,$(L.snapshot());return}Ma=e;let{background:n,logo:r,padding:i}=t.read.kit;R({kind:`setBranding`,patch:{background:n,logo:r,padding:i}}),$(L.snapshot())},onUpdate:()=>void Ws(),onStartNew:()=>{Na={text:``,error:null},$(L.snapshot())},onNameInput:e=>{Na!==null&&(Na={text:e,error:null})},onConfirmNew:e=>void Gs(e),onCancelNew:()=>{Na=null,$(L.snapshot())}}},{onCommit:e=>R({kind:`setBranding`,patch:e}),onPreview:Qo,onLogoFile:e=>Us(e).catch(P)});let v=g(`cursor`);v&&vi(v,ns(e.scene),rs(e.scene),{onCursor:e=>{ds(),R({kind:`setCursor`,patch:e})},onCursorPreview:os,onCursorPreviewEnd:ls,onMotion:e=>{ds(),R({kind:`setMotion`,patch:e})},onMotionPreview:ss,onMotionPreviewEnd:cs},e.scene.meta.capture.device?.touch===!0);let y=Qa(e.bundle),ee=g(`export`);ee&&Si(ee,{outputs:mo,fileType:W,aspect:e.scene.canvas.aspect,target:y,recording:Ne(e.bundle,Me(e.scene)),durationMs:a.clip.trim.tailMs-a.clip.trim.headMs,run:z.run,save:z.save,revealError:Ba,readiness:zs(e),runsRoute:Bs(e),currentDigest:to(e.scene),sections:Za,beatAt:pt(n.beats),hasReclaimedMotion:e.bundle?.degradations.some(e=>e.kind===`motionReclaimed`)??!1},{onExport:()=>Ks().catch(P),onFileType:As,onSaveAgain:e=>qs(e).catch(P),onReveal:$o}),Ds=n.hasBundle,Z=a.clip.trim.headMs,Es=a.clip.trim.tailMs,es(e,y),Ki(I(`take-info`),{recordedAt:e.scene.meta.createdAt,site:e.scene.meta.capture.originUrl,durationMs:a.clip.trim.tailMs-a.clip.trim.headMs,steps:n.beats.length,recording:Ne(e.bundle,Me(e.scene)),target:y,aspect:e.scene.canvas.aspect,takeId:Ia,rerun:Bs(e).rerun,revealError:Ba,history:{outputs:mo,currentDigest:to(e.scene),showAll:go,warningsOpen:_o,reportContext:{beatAt:pt(n.beats),runsRoute:Bs(e)}}},{onCopy:e=>navigator.clipboard.writeText(e),onDownload:e=>qs([e]).catch(P),onReveal:$o,onShowAll:()=>{go=!0,$(L.snapshot())},onWarnings:e=>{_o.delete(e)||_o.add(e),$(L.snapshot()),document.querySelector(`#take-info [data-output-warnings="${CSS.escape(e)}"]`)?.focus()}}),Q.positionMs<Z&&Q.seek(Z),Q.positionMs>Es&&Q.seek(Es),js();let b=ns(e.scene),x=rs(e.scene),te=JSON.stringify(e.scene.edits.removed??[]);J&&q&&(e.bundle!==Fo||K.height!==Io||Tn(ts,b)||En(is,x)||Dn(Lo,q)||te!==Ao)&&(Fo=e.bundle,ts=b,is=x,Lo=q,Io=K.height,Ao=te,Q.seek(Q.positionMs)),ps(e).catch(P)}function Hs(e){let t=L.snapshot().hoverReport;if(t===null){P(Error(`kept hover "${e}" with no hover report`));return}L.setHoverReport({...t,removable:t.removable.filter(t=>t!==e)})}async function Us(e){Ua=null;let t=xe(e),n=e=>{Ua=e,Wa=L.snapshot().scene,$(L.snapshot())};if(!t.ok)return n(t.reason);let r=new Uint8Array(await e.arrayBuffer());try{await ee(r,e.type)}catch(t){return n(`The logo "${e.name}" could not be read as an image: ${t instanceof Error?t.message:String(t)}`)}let{ref:i}=await N.logos.put(e);qo=t.note===null?null:{ref:i,note:t.note};let a=L.snapshot().scene.branding.logo,o=a?{corner:a.corner,size:a.size,opacity:a.opacity}:ae;await L.dispatch({kind:`setBranding`,patch:{logo:{ref:i,...o}}})}async function Ws(){let e=Pa(L.snapshot().scene.branding);if(e===null||!e.edited){Ua=e===null?`No brand kit was updated: this demo is no longer on a kit.`:`No brand kit was updated: this demo already matches "${e.kit.name}".`,Wa=L.snapshot().scene,$(L.snapshot());return}let t=e.kit,n=`This demo'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=L.snapshot().scene.branding,r=await ja.update(n=>n.kits.some(e=>e.id===t.id)?{...n,kits:n.kits.map(n=>n.id===t.id?{...n,branding:e}:n)}:`it was deleted in another tab`);if(r!==null)throw Error(r);F=await ja.read()}catch(e){Ua=`The brand kit "${t.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,Wa=L.snapshot().scene}$(L.snapshot())}async function Gs(e){let t=F.state===`ready`?F.kits:[],n=re(e,t,null);if(!n.ok){Na={text:e,error:n.reason},$(L.snapshot());return}let r=L.snapshot().scene.branding,i=pe();try{let t=await ja.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){Na={text:e,error:t},$(L.snapshot());return}Na=null,Ma=i,F=await ja.read()}catch(e){Ua=`The brand kit "${n.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,Wa=L.snapshot().scene}$(L.snapshot())}async function Ks(){Ba=null;let e=L.snapshot().scene;z={run:{phase:`encoding`,done:0,total:0},save:null,error:null},$(L.snapshot());try{await L.settled(),await N.exports.start(Ia,{fileType:W,aspect:e.canvas.aspect,revision:La})}catch(e){throw z={...z,run:{phase:`idle`},error:e instanceof Error?e.message:String(e)},$(L.snapshot()),e}}async function qs(e){let t=ho(),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=N.downloads;if(i===void 0)throw Error(`this page cannot save an export again`);z={...z,save:await i.save(n)},$(L.snapshot())}var Js=!1;function Ys(){let e=document.querySelector(`[data-panel-export]`);e!==null&&!xi(e,z.run,W,zs(L.snapshot()))&&!Js&&(Js=!0,P(Error(`the Export panel has no start button, so progress cannot show`)))}function Xs(e){let t=st(z,e);switch(z=t.flow,t.effect){case`render`:$(L.snapshot());return;case`progress`:Ys();return;case`relist`:N.outputs.list(Ia).then(e=>{mo=e,$(L.snapshot())}).catch(P);return;case`none`:return}}N.exports.onEvent(Xs),N.nav.onOpen?.(e=>rc(()=>location.assign(e))),I(`name`).addEventListener(`change`,e=>{R({kind:`rename`,name:e.target.value.trim()})});var Zs=e=>()=>{let t=L.snapshot().scene;e().catch(P).then(()=>za(t))};I(`undo`).addEventListener(`click`,Zs(()=>L.undo())),I(`redo`).addEventListener(`click`,Zs(()=>L.redo()));var Qs={recording:`a take is recording`,rendering:`a render is running`,sharing:`a share is in progress`,replaying:`a take is being run in Runs`};function $s(e){qa=e,ec()}function ec(){if(_c){$(L.snapshot());return}ii(I(`failure`),{error:null,replaySentence:null,captureSentence:null,deleteError:qa,navigationError:Ja})}function tc(e,t,n=``){Ja=null;try{location.assign(t())}catch(t){P(t),Ja={page:e,reason:`${n}${t instanceof Error?t.message:String(t)}`},ec()}}function nc(e=``,t=null){tc(`Recordings page`,()=>Fe(N.nav.library(),t),e)}function rc(e){(async()=>{let t=null,n=L.subscribe(e=>{t=e});try{await L.settled()}finally{n()}t?.error??e()})()}I(`back`).addEventListener(`click`,()=>{rc(()=>nc())});function ic(e){let t=ac(e);t&&(e.preventDefault(),rc(()=>tc(`Runs page`,()=>t.href)))}I(`banner`).addEventListener(`click`,ic),I(`inspector`).addEventListener(`click`,ic),I(`take-info`).addEventListener(`click`,ic),I(`failure`).addEventListener(`click`,ic),I(`take-info`).addEventListener(`toggle`,e=>{I(`take-meta`).setAttribute(`aria-expanded`,String(e.newState===`open`))});function ac(e){let t=(e.target instanceof Element?e.target:null)?.closest(`a[data-runs-route]`);return!t||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey?null:t}var oc=null;document.addEventListener(`mousedown`,e=>{let t=ac(e);oc=t?{link:t,href:t.href}:null},!0),document.addEventListener(`mouseup`,e=>{let t=oc;if(oc=null,!t)return;let n=ac(e);!n||n===t.link||n.href===t.href&&rc(()=>tc(`Runs page`,()=>n.href))},!0),I(`delete`).addEventListener(`click`,()=>{(async()=>{try{if(!await ie(fe))return}catch(e){P(e),$s(`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`);return}qa=null;let e;try{e=await N.scenes.remove(Ia)}catch(e){P(e),$s(`Not deleted: ${e instanceof Error?e.message:String(e)}.`);return}if(!e.ok){$s(`Not deleted: ${Qs[e.error]??e.detail??e.error}.`);return}if(e.result!==void 0&&!e.result.ok){let t=e.result.steps.find(e=>!e.ok);$s(`Partly deleted: ${t?.step??`a step`} could not be removed — ${t?.error??`unknown error`}. Open Your demos to retry.`);return}let t=e.note??null;nc(t===null?`This demo was deleted. `:`This demo was deleted. ${t} `,t===null?null:`This demo was deleted. ${t}`)})()});var sc=Symbol.for(`demoman.editor.keydown`),cc=globalThis,lc=cc[sc];lc instanceof AbortController&&lc.abort();var uc=new AbortController;cc[sc]=uc;var dc=!1,fc=null;document.addEventListener(`pointerdown`,()=>{dc=!0},{capture:!0,signal:uc.signal}),document.addEventListener(`pointerdown`,()=>{Ya!==null&&(Ya=null,$(L.snapshot()))},{signal:uc.signal}),document.addEventListener(`keydown`,()=>{dc=!1},{capture:!0,signal:uc.signal}),document.addEventListener(`focusin`,e=>{fc=dc?e.target:null},{signal:uc.signal});var pc=new WeakMap;document.addEventListener(`focusin`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&pc.set(t,t.value)},{signal:uc.signal}),document.addEventListener(`change`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&pc.set(t,t.value)},{capture:!0,signal:uc.signal}),document.addEventListener(`keydown`,e=>{if(document.querySelector(`dialog[open]`)!==null)return;if(e.key===`Escape`&&Ya!==null){e.preventDefault(),Ya=null,$(L.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=pc.get(t);e!==void 0&&t.value!==e&&(t.value=e)}t?.blur()}return}let r=e.key===`Enter`||e.key===` `&&t!==fc;if((n===`BUTTON`||n===`A`)&&r&&t?.hasAttribute(`data-tick`)!==!0)return;let i=L.snapshot(),a=rr(e,{hasSelection:V!==null,selectionIsBeat:V?.kind===`tick`,canUndo:i.canUndo,canRedo:i.canRedo,panelOpen:U,hasTimeline:G!==null&&oo>0});a!==null&&(e.preventDefault(),mc(a,i))},{signal:uc.signal});function mc(e,t){switch(e.kind){case`playPause`:Ms();return;case`shuttle`:B=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:Es);return;case`stepBeat`:{let n=t.scene.actions.map(e=>e.id),r=V?.kind===`tick`?n.indexOf(V.actionId):-1,i=n[r===-1?e.delta>0?0:n.length-1:r+e.delta];if(i===void 0)return;ro({kind:`tick`,actionId:i}),$(t);return}case`setTrim`:{let n=io,r=ao;if(n===null||r===null||J===null||!Ds){let e=Bs(t);po=`This take has not been rendered yet, so there is nothing to trim to. ${_t(e.authored,gt(e),`first`)}`,$(t);return}Is(an(n,r,{kind:`trim`,edge:e.edge,toMs:Q.positionMs,snapMs:0},{resolved:J,bundle:t.bundle,viewport:t.scene.meta.capture.viewport}));return}case`split`:Fs();return;case`undo`:Zs(()=>L.undo())();return;case`redo`:Zs(()=>L.redo())();return;case`deleteSelection`:if(V===null)return;if(V.kind===`zoom`){Ls({kind:`removeZoom`,id:V.id});return}if(V.kind===`mask`){Ls({kind:`removeMask`,id:V.id});return}if(V.kind===`piece`){Is(Tt(io?.clip.pieces??[],V.start,io?.clip.trim));return}Is({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(G===null)return;let n=Math.min(1,Math.max(0,j(G,Q.positionMs)));G=Tr(G,oo,e.factor,n),$(t);return}case`zoomFit`:G=Sr(oo),$(t);return;case`toggleSnapping`:so=!so,$(t);return;case`clearSelection`:ro(null),$(t);return;case`toggleHelp`:hc(`shortcuts`);return;case`closePanel`:gc();return}}function hc(e){H===e&&U?U=!1:(H=e,U=!0,e===`shortcuts`&&(uo=!0)),e!==`selection`&&(Xa=e),$(L.snapshot())}function gc(){U=!1,$(L.snapshot())}Ri(),Pr(),document.body.dataset.zoom=`fit`;{let e=I(`notes`),t=``,n=()=>{Bi(I(`notes-open`),e),t=Vi(e,t)};new MutationObserver(n).observe(e,{childList:!0,subtree:!0,characterData:!0}),n()}var _c=!1;L.subscribe(e=>{_c=!0,Ka=null,$(e)}),L.subscribe(e=>zo(e).catch(P));async function vc(){F=await ja.read(),_c&&$(L.snapshot())}vc().catch(P),ja.onChange===void 0?console.info(`demoman: no storage change feed here, so the brand kit is read once`):ja.onChange(()=>{vc().catch(P)});async function yc(){let e=N.exportQuality;if(e===void 0)return;let t=await e.read();t.unreadable!==void 0&&console.info(`demoman editor: the studio exports at Sharing quality: ${t.unreadable}`),t.quality!==$a&&($a=t.quality,_c&&$(L.snapshot()))}N.exportQuality!==void 0&&(yc().catch(P),window.addEventListener(`focus`,()=>{yc().catch(P)})),N.outputs.list(Ia).then(e=>{mo=e,_c&&$(L.snapshot())}).catch(P),L.load().catch(Rs);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,M as t,N as n,P as r,Q as i,T as a,Z as o,d as s,f as c,j as l,l as u,m as d,n as f,nt as p,o as ee,p as te,r as m,u as h,y as g}from"./confirm-dialog-DkCVzKzd.js";import{_ as ne,d as _,g as re,m as ie,s as ae,t as oe}from"./controls-BoAnJbcP.js";import{n as se,r as ce,t as le}from"./topbar-sSUyITjl.js";var ue=[`off`,`ask`,`attach`],de={...g,width:480,height:270,cornerRadius:g.cornerRadius*480/g.width},v={width:1280,height:800};function y(e){return a(de,v,e)}var b=i.shape.padding.maxValue;if(b===null)throw Error(`BrandingSchema's padding has no ceiling to size the preview by`);var x=y(b);function fe(e,t){return l(e,y(e.padding),v,t).logoPlacement}function pe(e,r,i,a,o=0){let s=e.getContext(`2d`);if(s===null)return!1;let c=x;e.width!==c.width&&(e.width=c.width),e.height!==c.height&&(e.height=c.height);let u=y(r.padding);s.clearRect(0,0,c.width,c.height),s.save(),s.beginPath(),s.roundRect(0,0,u.width,u.height,o),s.clip();let d=s,f=l(r,u,v,i);t(d,u,f);let p=f.frameRect;return s.save(),s.fillStyle=a,s.beginPath(),s.roundRect(p.x,p.y,p.width,p.height,f.cornerRadius),s.fill(),s.restore(),n(d,u,f),s.restore(),!0}function S(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}var me={off:`Off`,ask:`Ask`,attach:`Attach`},he={share:`Sharing`,full:`Full`},ge=[{section:`brandKit`,id:`brand-kit`,label:`Brand kit`,glyph:`palette`},{section:`export`,id:`export`,label:`Export`,glyph:`download`},{section:`pullRequests`,id:`pull-requests`,label:`Pull requests`,glyph:`upload`}];function C(e,t){let n=S(`section`,{"data-section":e,id:ge.find(t=>t.section===e)?.id??e}),r=S(`div`,{class:`section-head`});r.append(S(`h2`,{},t));let i=S(`div`,{class:`card section-body`});return n.append(r,i),{box:n,body:i}}function _e(){let e=S(`nav`,{class:`section-nav`,"aria-label":`Settings sections`}),t=S(`ul`);for(let e of ge){let n=S(`a`,{href:`#${e.id}`,"data-nav":e.id});n.append(m(e.glyph),S(`span`,{},e.label));let r=S(`li`);r.append(n),t.append(r)}return e.append(t),e}function w(e,t){return S(`button`,{type:`button`,class:`btn btn-quiet`,...t},e)}function T(e){return S(`p`,{class:`notice notice-error`,"data-notice":``},e)}function ve(e,t,n,r){let i=S(`div`,{class:`content`});{let e=C(`brandKit`,`Brand kit`),a=r.get(`brandKit`);a!==void 0&&e.body.append(T(a)),t.kitsUnwatched!==null&&e.body.append(S(`p`,{class:`notice notice-warn`,"data-notice":``,"data-unwatched":``},`Kits changed outside this window will not show until you reload — ${t.kitsUnwatched}.`)),ye(e.body,t,n),i.append(e.box)}{let e=C(`export`,`Export`),a=r.get(`export`);a!==void 0&&e.body.append(T(a));let o=t.exportQuality,s=S(`div`,{class:`switch-row export-quality`}),c=S(`div`,{class:`segmented`,role:`radiogroup`,"aria-label":`Export quality`});for(let e of ne){let t=S(`button`,{type:`button`,class:`segment`,role:`radio`,"data-export-quality":e,"aria-checked":String(e===o)},he[e]);t.addEventListener(`click`,()=>{e!==o&&n.setExportQuality(e)}),c.append(t)}s.append(c),e.body.append(s),i.append(e.box)}{let e=C(`pullRequests`,`Pull requests`),a=r.get(`pullRequests`);a!==void 0&&e.body.append(T(a));let o=t.pullRequests,s=S(`div`,{class:`switch-row pull-requests`}),c=S(`div`,{class:`segmented`,role:`radiogroup`,"aria-label":`Pull requests`});for(let e of ue){let t=S(`button`,{type:`button`,class:`segment`,role:`radio`,"data-pull-requests":e,"aria-checked":String(e===o)},me[e]);t.addEventListener(`click`,()=>{e!==o&&n.setPullRequests(e)}),c.append(t)}s.append(c),e.body.append(s),i.append(e.box)}let a=S(`div`,{class:`settings-side`});a.append(S(`h1`,{},`Settings`),_e());let o=S(`div`,{class:`settings`});o.append(a,i),e.replaceChildren(o)}function ye(t,n,r){let i=n.brandKits;if(i.state===`invalid`){if(t.append(T(`Your brand kits could not be read: ${i.reason}`)),i.storageRefused){t.append(S(`p`,{class:`hint`},`Nothing was changed. Reload this page to try again.`));return}let e=w(`Start a fresh kit list`,{"data-kit-reset-list":``});e.addEventListener(`click`,()=>r.resetKits()),t.append(e);return}let a=i.kits.find(e=>e.id===n.selectedKitId)??null;t.append(be(i,a,r)),a!==null&&t.append(xe(a,i,r)),a?.read.state===`invalid`&&t.append(T(`"${a.name}" could not be read: ${a.read.reason}`));let s=a?.read.state===`ready`?a.read.kit:o,c=S(`div`,{class:`kit-hero`});c.append(S(`canvas`,{"data-preview-kit":``,width:String(x.width),height:String(x.height),class:`kit-preview`}));let l=S(`div`,{class:`kit-controls`});oe(l,{branding:s,logoThumb:n.brandKitLogoThumb,logoPlacement:n.brandKitPlacement,formatTitle:ae(`mp4`,e.aspect),logoNotes:n.brandKitNotes,groupTitles:!0},{onCommit:e=>r.setBrandKit(e),onPreview:e=>r.previewBrandKit(e),onLogoFile:e=>r.uploadKitLogo(e)}),t.append(c,l)}function be(e,t,n){let r=S(`div`,{class:`kit-strip`,role:`list`}),i=d(e);for(let a of e.kits){let e=S(`div`,{class:`kit-tile`,role:`listitem`,"data-kit-tile":a.id}),o=S(`button`,{type:`button`,class:`kit-pick`,"data-kit-select":a.id,"aria-pressed":String(a.id===t?.id)});if(a.read.state===`ready`)o.append(S(`canvas`,{class:`kit-thumb`,"data-kit-thumb":a.id,width:String(x.width),height:String(x.height)}));else{let e=S(`span`,{class:`kit-thumb kit-thumb-broken`});e.append(m(`circleAlert`)),o.append(e),o.title=a.read.reason}o.append(S(`span`,{class:`kit-tile-name`},a.name)),o.addEventListener(`click`,()=>n.selectKit(a.id));let s=a.id===i?.id,c=S(`button`,{type:`button`,class:`kit-star`,"data-kit-star":a.id,"aria-pressed":String(s),"aria-label":s?`"${a.name}" is the default kit`:`Make "${a.name}" the default kit`});c.append(m(`star`)),c.addEventListener(`click`,()=>{s||n.setDefaultKit(a.id)}),e.append(o,c),r.append(e)}let a=S(`button`,{type:`button`,class:`kit-tile kit-new`,"data-kit-new":``});return a.append(m(`plus`),S(`span`,{},`New kit`)),a.addEventListener(`click`,()=>n.newKit()),r.append(a),r}function xe(e,t,n){let r=S(`div`,{class:`kit-head`}),i=S(`input`,{type:`text`,class:`kit-name`,"data-kit-name":``,maxlength:`40`,"aria-label":`Kit name`});i.value=e.name,i.addEventListener(`change`,()=>n.renameKit(e.id,i.value)),i.addEventListener(`keydown`,t=>{t.key===`Escape`&&(i.value=e.name,i.blur())});let a=w(`Duplicate`,{"data-kit-duplicate":``});a.prepend(m(`copy`)),a.addEventListener(`click`,()=>n.duplicateKit(e.id));let o=w(`Delete`,{"data-kit-delete":``});return o.prepend(m(`trash`)),t.kits.length===1&&(o.disabled=!0,o.title=`The last kit cannot be deleted`),o.addEventListener(`click`,()=>n.deleteKit(e.id)),r.append(i,a,o),r}function Se(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`,m(`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(m(`close`)),o.addEventListener(`click`,r),e.className=n===`info`?`notice notice-line`:`notice notice-line notice-${n}`,e.replaceChildren(...n===`info`?[]:[m(`circleAlert`)],i,o)}function Ce(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 E=document.querySelector(`#root`),we=ce(E),D=document.querySelector(`#notice`),O=ee(),k=O.kits,A={state:`ready`,kits:[],defaultId:null,migrationPending:!1},j=null,M=null,N=null,P=null,F=null,Te=()=>A.state===`ready`?A.kits.find(e=>e.id===j)??null:null,I=()=>{let e=Te();return e?.read.state===`ready`?e.read.kit:o};function L(){A.state===`ready`&&(A.kits.some(e=>e.id===j)||(j=d(A)?.id??A.kits[0]?.id??null))}var R=0;async function z(e){let t=null,n=await k.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?(R+=1,A=await k.read(),L(),t===null?null:{warn:`Your default kit was missing, so "${t}" is the default now.`}):n}async function B(e){let t=null,n=await e(e=>(t=e,e));return typeof n!=`string`&&t!==null&&(j=t,L()),n}var V=null;function H(e,t){return z(async n=>{if(n.kits.length===0){let e=await t(o);if(typeof e==`string`)return e;let n=h();return j=n,V=n,{kits:[{id:n,name:`Brand kit`,branding:e}],defaultId:n}}let r=e??V,i=n.kits.find(e=>e.id===r);if(i===void 0)return r===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 a=te(i.branding),s=await t(a.state===`ready`?a.kit:o);return typeof s==`string`?s:{...n,kits:n.kits.map(e=>e.id===r?{...e,branding:s}:e)}})}async function Ee(e){let t=e.logo?.ref??null;if(t===null){M=null,N=null,P=null;return}if(M?.ref!==t){let e=await O.logos.load(t);M=e.ok?{ref:t,source:e.source,error:null}:{ref:t,source:null,error:e.error}}if(N=null,M.source!==null)try{N=await M.source.rasterAt(r(e,x))}catch(e){M={ref:t,source:null,error:W(e)}}if(M.source===null)P={kind:`failed`,reason:M.error??`the page did not try to load it`};else try{P={kind:`ready`,url:await ie(M.source)}}catch(e){P={kind:`failed`,reason:W(e)}}}function De(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;pe(n,e,N,i,a)||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!==j)continue;let o=A.state===`ready`?A.kits.find(e=>e.id===r):void 0;o?.read.state===`ready`&&(pe(n,r===j?e:o.read.kit,null,i,a)||console.info(`demoman settings: a kit tile has no 2D context`))}}O.nav.onOpen?.(e=>je(e,()=>location.assign(e),new URL(e,location.href).searchParams.has(`scene`)?`Open the take`:`Open Recordings`)),le(O);var U=new Map,W=e=>e instanceof Error?e.message:String(e);function G(e,t){Se(D,e,t,Oe)}function K(e){G(e,`error`)}function Oe(){D.replaceChildren(),D.className=`notice notice-error hidden`}function q(e,t){console.error(`demoman settings: ${e} —`,t),K({title:`Couldn't ${e}`,detail:W(t)})}function J(e,t){let n=U.get(e);U.set(e,n===void 0?t:`${n}. ${t}`)}async function ke(e,t,n){try{return await n()}catch(n){for(let r of typeof e==`string`?[e]:e)J(r,`Couldn't read ${t}: ${W(n)}`);return null}}var Y=se({paint:e=>Ae({keepNotice:e}),onRefreshFailed:e=>q(`refresh Settings`,e),hold:Fe});function X(){return Y.render()}async function Ae({keepNotice:e=!1}={}){e||Oe(),U.clear();let t=R,[n,r,i]=await Promise.all([k.read(),ke(`pullRequests`,`the Pull requests setting`,()=>O.pullRequests.read()),ke(`export`,`the Export quality setting`,()=>O.exportQuality.read())]);i?.unreadable!==void 0&&J(`export`,`Couldn't read the Export quality setting: ${i.unreadable}`),r?.unreadable!==void 0&&J(`pullRequests`,`Couldn't read the Pull requests setting: ${r.unreadable}`),R===t&&(A=n),L();let a=I();await Ee(a),ve(E,{exportQuality:i===null||i.unreadable!==void 0?null:i.quality,pullRequests:r===null||r.unreadable!==void 0?null:r.value??`ask`,kitsUnwatched:k.unwatched(),brandKits:A,selectedKitId:j,brandKitLogo:a.logo===null?null:M?.source==null?{ok:!1,error:M?.error??`the page did not try to load it`}:{ok:!0},brandKitLogoThumb:a.logo===null?null:P,brandKitPlacement:fe(a,N),brandKitNotes:[M?.error?`The logo could not be loaded: ${M.error}`:null,F!==null&&F.ref===a.logo?.ref?F.note:null].filter(e=>e!==null)},Me,U),we.mark(),De(a)}var Z=new Set;function Q(e,t){let n=(async()=>{let n;try{n=await t()}catch(t){return q(e,t),`failed`}try{await X()}catch(t){return q(`show the result of: ${e}`,t),`failed`}return n===null?`done`:typeof n==`string`?(K(`Couldn't ${e}: ${n}.`),`failed`):(`warn`in n?G(n.warn,`warn`):G(n.info,`info`),`done`)})();Z.add(n),n.then(()=>Z.delete(n))}function je(e,t,n){Z.size>0&&console.info(`demoman settings: asked to open ${e}; waiting for ${Z.size} change${Z.size===1?``:`s`} here to save first`),(async()=>{let r=!1;for(;;){let e=Y.pending();if((await Promise.all([...Z])).includes(`failed`)&&(r=!0),await e.then(()=>void 0,()=>void 0),Z.size===0&&Y.pending()===e)break}if(r){console.info(`demoman settings: stayed on Settings rather than opening ${e}, because a change here did not save`);let r=document.createElement(`button`);r.type=`button`,r.className=`btn btn-quiet`,r.dataset.openAsked=``,r.textContent=n,r.addEventListener(`click`,()=>{try{t()}catch(t){q(`open ${e}`,t)}}),Ce(D,r)||(K(`A change here didn't save, so this window stayed on Settings.`),Ce(D,r));return}try{t()}catch(t){q(`open ${e}`,t)}})()}var Me={setPullRequests:e=>Q(`save the Pull requests setting`,async()=>{let t=await O.pullRequests.write(e);return t.replaced===void 0?null:{warn:t.replaced}}),setExportQuality:e=>Q(`save the Export quality setting`,async()=>{let t=await O.exportQuality.write(e);return t.replaced===void 0?null:{warn:t.replaced}}),setBrandKit:e=>{let t=j;Q(`save the brand kit`,()=>H(t,async t=>{let n=i.safeParse(_(t,e));return n.success?n.data:n.error.issues.map(e=>e.message).join(`; `)}))},previewBrandKit:e=>{try{De(_(I(),e),`selected`)}catch(e){console.info(`demoman settings: a brand kit preview did not apply`,e)}},uploadKitLogo:e=>{let t=j;Q(`add the logo`,async()=>{let n=re(e);if(!n.ok)return n.reason;let r=new Uint8Array(await e.arrayBuffer());try{await c(r,e.type)}catch(t){return`the logo "${e.name}" could not be read as an image: ${W(t)}`}let{ref:i}=await O.logos.put(e);return F=n.note===null?null:{ref:i,note:n.note},H(t,async e=>{let t=e.logo,n=t?{corner:t.corner,size:t.size,opacity:t.opacity}:p;return _(e,{logo:{ref:i,...n}})})})},selectKit:e=>{j=e,X().catch(e=>q(`select the kit`,e))},newKit:()=>Q(`add a kit`,()=>B(e=>z(async t=>{let n=e(h());return{kits:[...t.kits,{id:n,name:s(`Untitled kit`,t.kits),branding:o}],defaultId:t.defaultId??n}}))),duplicateKit:e=>Q(`duplicate the kit`,()=>B(t=>z(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(h()),name:s(`${r.name} copy`,n.kits),branding:structuredClone(r.branding)};return{...n,kits:[...n.kits,i]}}))),renameKit:(e,t)=>Q(`rename the kit`,()=>z(async n=>{let r=u(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=>Q(`make the kit the default`,()=>z(async t=>t.kits.some(t=>t.id===e)?{...t,defaultId:e}:`the kit was deleted in another tab`)),deleteKit:e=>Q(`delete the kit`,async()=>{if(A.state!==`ready`)return`the kits could not be read`;let t=A.kits.find(t=>t.id===e);if(t===void 0)return`the kit was deleted in another tab`;if(A.kits.length===1)return`the last kit cannot be deleted`;let n=A.kits.find(t=>t.id!==e),r=A.defaultId===e&&n!==void 0?` "${n.name}" becomes the default kit.`:``;return await f({glyph:`trash`,title:`Delete "${t.name}"`,body:`"${t.name}" will be deleted.${r} Takes already made keep their look.`,confirmLabel:`Delete`,danger:!0,focus:`cancel`})?z(async t=>{let n=t.kits.filter(t=>t.id!==e);return n.length===0?`the last kit cannot be deleted`:{kits:n,defaultId:t.defaultId===e?n[0]?.id??null:t.defaultId}}):null}),resetKits:()=>Q(`start a fresh kit list`,async()=>{if(!await f({glyph:`trash`,title:`Start a fresh kit list`,body:`Your brand kits could not be read. Starting fresh replaces them with an empty list; takes already made keep their look.`,confirmLabel:`Start fresh`,danger:!0,focus:`cancel`}))return null;let{backup:e}=await k.reset();return R+=1,A=await k.read(),e===null?null:{info:`Started a fresh kit list. The old list is kept at ${e}.`}})},Ne=()=>Y.soon(),$=!1,Pe=new Set([`button`,`checkbox`,`file`,`radio`,`range`,`reset`,`submit`]);function Fe(){if($)return!0;let e=document.activeElement;return e===null||!E.contains(e)?!1:e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!Pe.has(e.type)}var Ie=()=>Y.resume();E.addEventListener(`pointerdown`,()=>{$=!0});for(let e of[`pointerup`,`pointercancel`])window.addEventListener(e,()=>{$=!1,Ie()});E.addEventListener(`focusout`,()=>setTimeout(Ie,0)),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Ne()}),k.onChange(Ne),X().catch(e=>q(`load Settings`,e));
|
package/dist/studio/icon/128.png
DELETED
|
Binary file
|
package/dist/studio/icon/16.png
DELETED
|
Binary file
|
package/dist/studio/icon/48.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|