rushes 0.3.0 → 0.5.0

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.
@@ -0,0 +1,3 @@
1
+ (function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?w(e):null}function T(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=v({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),I(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??w(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,ee(i,o,a),n.__e=n.__=null,o.__e!=r&&E(o)}}function E(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),E(e)}function D(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!O.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(O)}function O(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||m,p.__i=d,v=I(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&ne(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),4&p.__u?(c=j(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=M(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),z(s,s));return r}function j(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=j(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=w(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function M(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function N(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function P(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||N(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||N(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function F(e){return function(n){if(this.l){var r=this.l[n.type+e];if(n[c]==null)n[c]=d++;else if(n[c]<r[l])return;return r(t.event?t.event(n):n)}}}function I(e,n,r,i,a,o,s,c,l,u){var d,f,p,m,g,b,x,T,E,D,O,A,j,M,N,P,F=n.type;if(n.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=n.__e=r.__e]),(d=t.__b)&&d(n);n:if(typeof F==`function`){f=s.length;try{if(E=n.props,D=F.prototype&&F.prototype.render,O=(d=F.contextType)&&i[d.__c],A=d?O?O.props.value:d.__:i,r.__c?T=(p=n.__c=r.__c).__=p.__E:(D?n.__c=p=new F(E,A):(n.__c=p=new C(E,A),p.constructor=F,p.render=re),O&&O.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),D&&p.__s==null&&(p.__s=p.state),D&&F.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=v({},p.__s)),v(p.__s,F.getDerivedStateFromProps(E,p.__s))),g=p.props,b=p.state,p.__v=n,m)D&&F.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),D&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(D&&F.getDerivedStateFromProps==null&&E!==g&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(E,A),n.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(E,p.__s,A)){n.__v!=r.__v&&(p.props=E,p.state=p.__s,p.__d=!1),n.__e=r.__e,n.__k=r.__k,n.__k.some(function(e){e&&(e.__=n)}),h.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=w(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(E,p.__s,A),D&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(g,b,x)})}if(p.context=A,p.props=E,p.__P=e,p.__e=!1,j=t.__r,M=0,D)p.state=p.__s,p.__d=!1,j&&j(n),d=p.render(p.props,p.state,p.context),h.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,j&&j(n),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++M<25);p.state=p.__s,p.getChildContext!=null&&(i=v(v({},i),p.getChildContext())),D&&!m&&p.getSnapshotBeforeUpdate!=null&&(x=p.getSnapshotBeforeUpdate(g,b)),N=d!=null&&d.type===S&&d.key==null?te(d.props.children):d,c=k(e,_(N)?N:[N],n,r,i,a,o,s,c,l,u),p.base=n.__e,n.__u&=-161,p.__h.length&&s.push(p),T&&(p.__E=p.__=null)}catch(e){if(s.length=f,n.__v=null,l||o!=null){if(e.then){for(n.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),n.__e=c}else if(o!=null)for(P=o.length;P--;)y(o[P])}else n.__e=r.__e;n.__k??=r.__k||[],e.then||L(n),t.__e(e,n,r)}}else o==null&&n.__v==r.__v?(n.__k=r.__k,n.__e=r.__e):c=n.__e=R(r.__e,n,r,i,a,o,s,l,u);return(d=t.diffed)&&d(n),128&n.__u?void 0:c}function L(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(L))}function ee(e,n,r){for(var i=0;i<r.length;i++)ne(r[i],r[++i],r[++i]);t.__c&&t.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){t.__e(e,n.__v)}})}function te(e){return typeof e!=`object`||!e||e.__b>0?e:_(e)?e.map(te):e.constructor===void 0?v({},e):null}function R(n,r,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){n=g,s[d]=null;break}}if(n==null){if(C==null)return document.createTextNode(S);n=document.createElementNS(o,C,S.is&&S),l&&=(t.__m&&t.__m(r,s),!1),s=null}if(C==null)x===S||l&&n.data==S||(n.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&e.call(n.childNodes),!l&&s!=null)for(x={},d=0;d<n.attributes.length;d++)x[(g=n.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||P(n,d,null,g,o);for(d in S)g=S[d],d==`children`?h=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?v=g:d==`checked`?b=g:l&&typeof g!=`function`||x[d]===g||P(n,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==n.innerHTML)||(n.innerHTML=f.__html),r.__k=[];else if(p&&(n.innerHTML=``),k(r.type==`template`?n.content:n,_(h)?h:[h],r,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&w(i,0),l,u),s!=null)for(d=s.length;d--;)y(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&v==null?n.removeAttribute(`value`):v!=null&&(v!==n[d]||C==`progress`&&!v||C==`option`&&v!=x[d])&&P(n,d,v,x[d],o),d=`checked`,b!=null&&b!=n[d]&&P(n,d,b,x[d],o))}return n}function ne(e,n,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&n==null||(e.__u=e(n))}else e.current=n}catch(e){t.__e(e,r)}}function z(e,n,r){var i,a;if(t.unmount&&t.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||ne(i,null,n)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){t.__e(e,n)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&z(i[a],n,r||typeof e.type!=`function`);r||y(e.__e),e.__c=e.__=e.__e=void 0}function re(e,t,n){return this.constructor(e,n)}function ie(n,r,i){var a,o,s,c;r==document&&(r=document.documentElement),t.__&&t.__(n,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],I(r,n=(!a&&i||r).__k=b(S,null,[n]),o||m,m,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?e.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),ee(s,n,c),n.props.children=null}e=h.slice,t={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},n=0,C.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=v({},this.state);typeof e==`function`&&(e=e(v({},n),this.props)),e&&v(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),D(this))},C.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),D(this))},C.prototype.render=S,r=[],a=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,o=function(e,t){return e.__v.__b-t.__v.__b},O.__r=0,s=Math.random().toString(8),c=`__d`+s,l=`__a`+s,u=/(PointerCapture)$|Capture$/i,d=0,f=F(!1),p=F(!0);var ae=[[1,1],[4,5],[5,4],[4,3],[3,4],[3,2],[2,3],[16,9],[9,16],[21,9],[9,21]],B=[`9x16`,`4x5`,`1x1`,`4x3`,`16x9`];function V(e,t){return[e,t].every(e=>Number.isInteger(e)&&e>=1&&e<=1e5)}function oe(e,t){for(;t;)[e,t]=[t,e%t];return e}var se=e=>String(Number(e.toFixed(2))),ce=Math.log(1.01)+1e-12;function le(e){let t=null,n=1/0;for(let r of ae){let i=Math.abs(Math.log(e/(r[0]/r[1])));i<n&&(n=i,t=r)}return{best:t,err:n}}function H(e,t){if(!V(e,t))throw RangeError(`Not a picture size: ${e}×${t}`);let{best:n,err:r}=le(e/t);if(n&&r<=ce)return`${n[0]}:${n[1]}`;let i=oe(e,t);return e/i<=32&&t/i<=32?`${e/i}:${t/i}`:e>=t?`${se(e/t)}:1`:`1:${se(t/e)}`}var ue=e=>e.replace(`:`,`x`),de=e=>e.replace(`x`,`:`);function U(e){let t=e=>{let t=B.indexOf(e.id);return t===-1?B.length:t};return[...e].sort((e,n)=>t(e)-t(n)||e.width/e.height-n.width/n.height||e.id.localeCompare(n.id))}function fe(e,t){let n=(e.width!==null&&e.height!==null&&V(e.width,e.height)?{width:e.width,height:e.height}:null)??(t&&V(t.width,t.height)?t:null),r=e.formats.map(e=>({id:e.id,label:e.label,file:e.file,width:e.width,height:e.height,duration:e.duration,fps:e.fps,primary:!1}));if(!n)return r;let i=H(n.width,n.height);return[{id:ue(i),label:i,file:e.file,width:n.width,height:n.height,duration:e.duration,fps:e.fps,primary:!0},...r]}function W(e,t,n){return t===null||n===null||Math.abs(t-n)<=.1+1e-9?null:`${e} is ${t.toFixed(1)} s; the cut is ${n.toFixed(1)} s`}function pe(e,t){return t===null||e.format===null||e.format===t}function G(e){let t=Math.round(Math.max(0,e)*100),n=Math.floor(t/6e3);return`${n}:${((t-n*6e3)/100).toFixed(2).padStart(5,`0`)}`}function me(e,t){return Math.round(e*t)}function he(e,t){return Math.round(me(e,t)/t*1e6)/1e6}function ge(e,t,n,r){let i=me(e,t)+n;return Math.min(Math.max(0,i/t),r||1/0)}function _e(e,t){if(e.t===null)return{t:null,tOut:null,from:null};if(!e.version||e.version===t)return{t:e.t,tOut:e.tOut,from:null};let n=`${e.version} at ${G(e.t)}`;if(e.fixT!==null&&e.fixVersion===t){let t=e.tOut===null?null:e.tOut-e.t;return{t:e.fixT,tOut:t===null?null:e.fixT+t,from:n}}return{t:e.t,tOut:e.tOut,from:n}}function ve(e,t){return e===null?`Whole`:t===null?G(e):`${G(e)}–${G(t)}`}function ye(e,t,n){let r=(e.trim().match(/\S+/g)??[]).length,i=r/n,a=t>0?i/t:1/0;return{words:r,seconds:i,ratio:a,state:a>1?`over`:a>.8?`tight`:`ok`}}function be(e){return e.proposed!==null&&e.proposed.trim()!==e.current.trim()}function xe(e){return e?.versions[e.versions.length-1]}function Se(e){if(e?.lockedVersion){let t=e.versions.find(t=>t.id===e.lockedVersion);if(t)return t}return xe(e)}function Ce(e,t,n){let r=e.findIndex(e=>e.id===t);if(r===-1)return null;let i=r+n;return i>=0&&i<e.length?e[i].id:null}var we={script:`Script`,picture:`Picture`,voice:`Voiceover`,music:`Music`,sfx:`Sound effects`,mix:`Mix`},Te={script:{what:`Read the VO line by line and suggest your own wording.`,unlocks:`Your agent adds the script.`,ask:`the script`},picture:{what:`Watch each cut, leave timecoded notes and lock the picture.`,unlocks:`Your agent adds a cut.`,ask:`a cut`},voice:{what:`Compare whole reads in rounds and pick one.`,unlocks:`Your agent adds voice reads.`,ask:`voice reads`},music:{what:`Compare music beds against the picture and pick one.`,unlocks:`Your agent adds music beds.`,ask:`music beds`},sfx:{what:`Compare SFX passes, cue by cue.`,unlocks:`Your agent adds an SFX pass.`,ask:`an SFX pass`},mix:{what:`Balance voice, music and effects and check loudness.`,unlocks:`Unlocks with a cut and any audio.`,ask:`a cut and some audio`},assets:{what:`Every file in the project in one place.`,unlocks:`Unlocks with the first cut, take, track or screenshot.`,ask:`files`}},Ee=(e,t)=>t?` ${e} "${t}"`:``,De={script:(e,t)=>`In Rushes project "${e}", add the voiceover script${Ee(`for`,t)} with rushes_set_script, one section per line with start and end times.`,picture:(e,t)=>`In Rushes project "${e}", add the latest cut${Ee(`of`,t)} with rushes_add_version.`,voice:(e,t)=>`In Rushes project "${e}", record two or three voice reads${Ee(`for`,t)} and add each with rushes_add_variant (stage "voice", round "Round 1 · Voices") with a one-line description.`,music:(e,t)=>`In Rushes project "${e}", make two or three music beds${Ee(`for`,t)} and add each with rushes_add_variant (stage "music") with a one-line description.`,sfx:(e,t)=>`In Rushes project "${e}", make a sound-effects pass${Ee(`for`,t)} and add it with rushes_add_variant (stage "sfx") with its cues.`,mix:(e,t)=>`In Rushes project "${e}", add a cut and at least one voice read, music bed or SFX pass${Ee(`for`,t)}.`,assets:(e,t)=>`In Rushes project "${e}", add the first cut${Ee(`of`,t)} with rushes_add_version.`};function Oe(e,t,n){return De[e](t,n)}var ke=[`brief`,`script`,`storyboard`],Ae=e=>e===`brief`||e===`script`||e===`storyboard`;function je(e,t,n){let r=t.filter(e=>e.status===`approved`).length;return{brief:e.exists&&e.status===`approved`?`ok`:`none`,script:t.length>0&&r===t.length?`ok`:r>0?`part`:`none`,storyboard:n.total>0&&n.approved===n.total?`ok`:n.approved>0?`part`:`none`}}var Me={what:`Write down what this film is for before anything is built, and approve it.`,unlocks:`Your agent starts a brief for this film.`,ask:`a brief`},Ne={what:`See each shot as a still, rewrite what happens, and approve it before anything is built.`,unlocks:`Your agent sketches the shots once the script is approved.`,ask:`a storyboard`};function Pe(e,t){return`In Rushes project "${e}", start a brief${Ee(`for`,t)}: ask me up to three questions, each with a recommended answer, then write brief.md (see "Starting a film" in AGENTS.md).`}function Fe(e,t){return`In Rushes project "${e}", sketch the shots${Ee(`for`,t)} from the approved script: write storyboard.md with one "## Shot 01 · Name" section per shot (Tag, Length, Still and Status: draft lines, then what happens), make a still for each, and save them under storyboard/ (see "Starting a film" in AGENTS.md).`}function Ie(e,t){return`The plan is approved in Rushes project "${e}"${Ee(`for`,t)}. Build the film from brief.md and storyboard.md, name each scene after its planned shot, and register the cut with rushes_add_version.`}function Le(e,t,n){let r=n.status===`approved`,i=n.sections.filter(e=>e.changed).map(e=>e.heading),a=[`In Rushes project "${e}"${Ee(`for`,t)}, the brief is ${r?`approved`:`still a draft`}.`];return i.length&&a.push(`I changed ${i.length===1?`this section`:`these sections`} in brief.md: ${i.join(`, `)}. Read the file again before you go on, and keep my wording.`),a.push(r?`Next: write the script with rushes_set_script.`:`Don't build anything until I approve it.`),a.join(` `)}function Re(e,t,n){let r=n.shots.filter(e=>e.changed).map(e=>`Shot ${String(e.n).padStart(2,`0`)} · ${e.name}`),i=[`In Rushes project "${e}"${Ee(`for`,t)}, ${n.approved} of ${n.total} shots in storyboard.md are approved.`];return r.length&&i.push(`I changed ${r.length===1?`this shot`:`these shots`}: ${r.join(`, `)}. Read storyboard.md again before you go on, keep my wording, and update the still${r.length===1?``:`s`} if what happens has changed.`),i.push(n.approved===n.total&&n.total>0?`Next: build the film.`:`Don't build anything until I approve them all.`),i.join(` `)}function ze(e){let t=e.sections.find(e=>/^length/i.test(e.heading)),n=t?/Length:\s*(\d+(?:\.\d+)?)/i.exec(t.yours):null,r=n?Number(n[1]):NaN;return Number.isFinite(r)&&r>0?r:null}function Be(e,t){return e.find(e=>e.stage===`picture`)?.unlocked?`picture`:t.exists?`brief`:He(e)}function Ve(e,t){return t[e]?e:ke.find(e=>t[e])??e}function He(e){return e.find(e=>e.stage===`picture`)?.unlocked?`picture`:e.find(e=>e.unlocked)?.stage??`picture`}function Ue(e,t){let n=null;for(let r of e)r.start<=t&&(!n||r.start>n.start)&&(n=r);return n?{n:n.n,name:n.name}:null}function We(e){return String(e).padStart(2,`0`)}function Ge(e,t){return Math.ceil(e*t-1e-9)/t}function Ke(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}function qe(e,t){let n=[];if(e&&n.push(e),t)for(let[e,r]of Object.entries(t))n.push(typeof r==`number`?`${r} ${e.toUpperCase()}`:String(r));return n.length>0?n.join(` · `):null}var Je=new Set([`md`,`txt`,`pdf`,`srt`,`vtt`,`png`,`jpg`,`jpeg`,`gif`,`webp`,`mp4`,`mov`,`m4v`,`webm`,`mkv`,`wav`,`mp3`,`m4a`,`aac`,`flac`,`ogg`,`prproj`,`drp`]),Ye=new Set([`mp4`,`mov`,`m4v`,`webm`,`mkv`]);function Xe(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}var Ze=[{id:`screenshot`,title:`Screenshots`,kinds:[`screenshot`],view:`grid`,filmFilter:!0,gridToggle:!0},{id:`cut`,title:`Cuts`,kinds:[`cut`],view:`grid`,filmFilter:!0,gridToggle:!0},{id:`proxy`,title:`Proxies`,kinds:[`proxy`],view:`list`,filmFilter:!0,gridToggle:!1},{id:`voiceover`,title:`Voiceover`,kinds:[`take`,`voice`],view:`list`,filmFilter:!1,gridToggle:!1},{id:`music`,title:`Music`,kinds:[`music`],view:`list`,filmFilter:!1,gridToggle:!1},{id:`sfx`,title:`Sound effects`,kinds:[`sfx`],view:`list`,filmFilter:!1,gridToggle:!1},{id:`doc`,title:`Scripts & docs`,kinds:[`doc`],view:`list`,filmFilter:!1,gridToggle:!1},{id:`image`,title:`Images`,kinds:[`image`],view:`grid`,filmFilter:!1,gridToggle:!0},{id:`caption`,title:`Captions`,kinds:[`caption`],view:`list`,filmFilter:!1,gridToggle:!1},{id:`export`,title:`Exports`,kinds:[`export`],view:`list`,filmFilter:!1,gridToggle:!1},{id:`delivery`,title:`Delivery`,kinds:[`delivery`],view:`grid`,filmFilter:!0,gridToggle:!0},{id:`edit`,title:`Edit files`,kinds:[`edit`],view:`list`,filmFilter:!1,gridToggle:!1}],Qe=new Set([`doc`,`caption`,`export`,`edit`]),$e=new Set([`md`,`txt`,`srt`,`vtt`]);function et(e){return $e.has(Xe(e.path))}function tt(e,t,n={}){let{query:r=``,sort:i=`newest`,film:a,videos:o=[]}=n,s=e.filter(e=>t.kinds.includes(e.kind));a&&(s=s.filter(e=>e.video===a));let c=r.trim().toLowerCase();c&&(s=s.filter(e=>{let t=o.find(t=>t.id===e.video),n=t?.versions.find(t=>t.id===e.version);return[e.name,e.path,e.note,n?.note,t?.name].filter(e=>!!e).some(e=>e.toLowerCase().includes(c))}));let l=e=>e.modified?new Date(e.modified).getTime():0,u=[...s];return i===`name`?u.sort((e,t)=>e.name.localeCompare(t.name)):i===`oldest`?u.sort((e,t)=>l(e)-l(t)):u.sort((e,t)=>l(t)-l(e)),t.kinds.includes(`cut`)?nt(u):u}function nt(e){let t=e=>e.kind===`cut`&&e.format!==void 0,n=e.filter(t),r=new Set,i=[];for(let a of e){if(t(a)){e.some(e=>e.kind===`cut`&&!t(e)&&e.video===a.video&&e.version===a.version)||(i.push(a),r.add(a));continue}if(i.push(a),a.kind!==`cut`)continue;let o=n.filter(e=>e.video===a.video&&e.version===a.version&&!r.has(e));for(let e of U(o.map(e=>({id:e.format,width:e.width??1,height:e.height??1,s:e}))).map(e=>e.s))i.push(e),r.add(e)}return i}function rt(e,t=[]){let n=new Map;for(let r of e){let e=t.find(e=>e.id===r.video),i=e&&r.version?`${e.name} · ${r.version}`:null,a=i??`\0`,o=n.get(a);o||(o={heading:i,items:[]},n.set(a,o)),o.items.push(r)}return[...n.values()]}function it(e,t,n,r){if(!(e>0&&t>0&&n>0&&r>0))return{x:0,y:0,w:Math.max(0,n),h:Math.max(0,r)};let i=Math.min(n/e,r/t),a=e*i,o=t*i;return{x:(n-a)/2,y:(r-o)/2,w:a,h:o}}function at(e,t,n,r,i,a){let o=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4,s=o(Math.min(e,n)/i),c=o(Math.min(t,r)/a),l=o(Math.max(e,n)/i),u=o(Math.max(t,r)/a);return{x:s,y:c,w:Math.round((l-s)*1e4)/1e4,h:Math.round((u-c)*1e4)/1e4}}var ot={point:`Point`,range:`Range`,whole:`Whole`},st=[`point`,`range`,`whole`];function ct(e){return(e??st).filter(e=>e in ot).map(e=>({value:e,label:ot[e]}))}function lt(e){return e.range.in!==null||e.marks.length>0||e.hasText}var ut={voice:[`Speaker`,`Pacing`,`Tone`,`Overall`],music:[`Tempo`,`Key`,`Energy`,`Ending`],sfx:[`Timing`,`Level`,`Swap sound`,`Remove`],mix:[`Level`,`Balance`,`Loudness`]},dt=[1,2,3,6,9],ft=[`rise`,`fall`,`louder`,`quieter`],pt={rise:`fall`,fall:`rise`,louder:`quieter`,quieter:`louder`},mt=e=>e===`louder`||e===`quieter`;function ht(e){let t=e.kind===`rise`?`Rise`:e.kind===`fall`?`Fall`:e.kind===`louder`?`Louder`:`Quieter`;return e.db===void 0?t:`${t} ${e.db} dB`}function gt(e){return e&&e.length>0?e.map(ht).join(` · `):null}function _t(e,t,n=3){let r=e.some(e=>e.kind===t),i=e.filter(e=>e.kind!==t&&e.kind!==pt[t]);return r||i.push(mt(t)?{kind:t,db:n}:{kind:t}),i.sort((e,t)=>ft.indexOf(e.kind)-ft.indexOf(t.kind))}function vt(e,t,n){return e.map(e=>e.kind===t&&mt(t)?{kind:t,db:n}:e)}function yt(e,t=0){let n=[],r=e?.description;return r!==void 0&&String(r).trim()?n.push(String(r)):(e?.bpm!==void 0&&n.push(`${e.bpm} BPM`),e?.key!==void 0&&n.push(String(e.key))),t>0&&n.push(`${t} cue${t===1?``:`s`}`),n.length>0?n.join(` · `):null}function bt(e,t){let n=[];for(let r of e)if(r.stage===t)for(let e of r.variants)n.push({key:`${r.id}/${e.id}`,lane:r.id,laneName:r.name,variant:e.id,name:e.name,meta:yt(e.meta,t===`sfx`?e.cues.length:0),file:e.file,cues:e.cues});return n}function xt(e){let t=[];for(let n of e){let e=t[t.length-1];e&&(e.options[0].groupId??e.group)===(n.groupId??n.group)?e.options.push(n):t.push({group:n.group,options:[n]})}return t}var St=e=>e.key,Ct=(e,t)=>`${e.key}:${t}`;function wt(e,t){let n=e.map(e=>e.t);return n.map((e,r)=>{let i=n.filter((e,t)=>t!==r).map(t=>Math.abs(t-e));return t>0&&i.length?Math.min(.4,Math.min(...i)/t):.4})}function Tt(e,t,n=!1){let r=e.map(e=>({value:`v:${e.key}`,label:t(e),on:St(e),row:e.key}));if(!n)return r;let i=new Set(r.map(e=>e.label));for(let n of e)for(let e of n.cues){let a=`Cue · ${e.name}`;i.has(a)&&(a=`${a} · ${t(n)}`),i.add(a),r.push({value:`c:${n.key}:${e.id}`,label:a,on:Ct(n,e.id),t:e.t,row:n.key})}return r}function Et(e,t){if(t===null||!t.includes(`/`))return null;let n=e.find(e=>St(e)===t);if(n)return{row:n,cue:null};let r=t.indexOf(`:`,t.indexOf(`/`));if(r===-1)return null;let i=t.slice(0,r),a=t.slice(r+1),o=e.find(e=>e.key===i&&e.cues.some(e=>e.id===a));return o?{row:o,cue:a}:null}function Dt(e,t){let n=e.find(e=>e.variant===t);if(n)return{row:n,cue:null};let r=t.indexOf(`:`);if(r>0){let n=t.slice(0,r),i=t.slice(r+1),a=e.find(e=>e.variant===n&&e.cues.some(e=>e.id===i));if(a)return{row:a,cue:i}}let i=e.find(e=>e.cues.some(e=>e.id===t));return i?{row:i,cue:t}:null}function Ot(e,t){if(t===null)return null;let n=Et(e,t)??Dt(e,t);return n?{row:n.row.key,cue:n.cue}:null}function kt(e,t){return Ot(e,t)?.row??null}function At(e,t,n){let r=Ot(e,n);if(!r)return null;let i=r.cue===null?`v:${r.row}`:`c:${r.row}:${r.cue}`;return t.find(e=>e.value===i)?.label??null}function jt(e,t){let n={},r=e.find(e=>e.key===t)?.audition,i=e.map((e,t)=>({r:e,i:t})).sort((e,t)=>(e.r.order??e.i)-(t.r.order??t.i)).map(e=>e.r);for(let t of i){let i=t.audition;i&&n[i.lane]===void 0&&(r&&r.lane===i.lane?n[i.lane]=r.clip:n[i.lane]=(e.find(e=>e.picked&&e.audition?.lane===i.lane)??t).audition.clip)}return n}function Mt(e,t){let n=e=>{let n=(2166136261^t)>>>0;for(let t=0;t<e.length;t++)n=Math.imul(n^e.charCodeAt(t),16777619)>>>0;return n^=n>>>15,n=Math.imul(n,2246822507)>>>0,(n^n>>>13)>>>0};return[...e].sort((e,t)=>n(e)-n(t)||(e<t?-1:+(e>t)))}var Nt=new WeakSet,Pt=!1;function Ft(e){Pt||(Pt=!0,e.addEventListener(`focusin`,e=>It(e.target),!0),e.addEventListener(`pointerdown`,e=>{let t=e.target?.closest?.(`button`);t&&Nt.delete(t)},!0))}function It(e){let t=e;t&&typeof t.matches==`function`&&(t.matches(`:focus-visible`)?Nt.add(t):Nt.delete(t))}function Lt(e){let t=e;if(!t||typeof t.closest!=`function`)return!1;let n=t.closest(`button`);return!!n&&Nt.has(n)&&!t.closest(`[data-player]`)}function Rt(e){let t=new URLSearchParams(e),n=t.get(`test`)===`1`;return{test:n,streamOver:n&&t.get(`streamOver`)===`1`}}function zt(e){return e.toUpperCase()}var Bt=e=>`var:${e}`;function Vt(e,t){let n=e.filter(e=>e.stage===`voice`&&e.variants.length>0);return n.map((e,r)=>{let i=bt([e],`voice`),a=i.some(n=>n.variant===t[e.id])?t[e.id]:null;return{id:e.id,name:e.name,reads:i,pick:a,current:r===n.length-1}})}var Ht=e=>e.reads.find(t=>t.variant===e.pick)??null;function Ut(e){for(let t=e.length-1;t>=0;t--){let n=Ht(e[t]);if(n)return n}return null}function Wt(e){let t=e.find(e=>e.current);return t?Ht(t)??t.reads[0]??null:null}var Gt=e=>`${Bt(e.lane)}/${e.variant}`;function Kt(e,t){let n=e.flatMap(e=>e.reads),r=n.find(e=>e.key===t)??Wt(e),i={},a={};for(let e of n)i[Gt(e)]=e.key,a[Gt(e)]=+(e.key===r?.key);return{select:i,gains:a}}var qt=(e,t)=>!!e.sections?.some(e=>e.id===t);function Jt(e,t){if(t===null)return null;for(let n of e.rounds){let e=n.reads.find(e=>e.key===t);if(e)return{round:n,read:e}}if(t.includes(`/`)||t.includes(`:`)||t===`vo`||qt(e,t))return null;for(let n of e.rounds){let e=n.reads.find(e=>e.variant===t);if(e)return{round:n,read:e}}return null}function Yt(e,t){return Jt(e,t.on)?.read.key??null}function Xt(e,t=e=>e.name){let n=[];for(let r of[...e].reverse())for(let e of r.reads)n.push({value:`v:${e.key}`,label:t(e),full:`${r.name} · ${t(e)}`,group:r.name,groupId:r.id,on:St(e),row:e.key});return n}function Zt(e,t,n=e=>e.name){let r=Jt(e,t);if(r)return r.round.current?n(r.read):`${r.round.name} · ${n(r.read)}`;if(t===null||t===`vo`)return`Assembled read`;if(qt(e,t))return zt(t);for(let n of e.sections??[]){let e=n.takes.findIndex(e=>`${n.id}:${e.id}`===t);if(e!==-1)return`${zt(n.id)} · Take ${e+1}`}return null}var Qt=[`vo`,`music`,`sfx`],$t={vo:`voice`,music:`music`,sfx:`sfx`};function en(e,t){return Qt.filter(n=>e[n]&&(t[n]??1)>0).map(e=>$t[e])}function tn(e,t){for(let n of[`music`,`sfx`]){let r=Et(e.variants[n],t);if(r)return{lane:n,row:r.row}}if(t.includes(`/`))return null;for(let n of[`music`,`sfx`]){let r=e.heard[n].find(e=>e.variant===t);if(r)return{lane:n,row:r}}for(let n of[`music`,`sfx`]){let r=e.variants[n].find(e=>e.variant===t);if(r)return{lane:n,row:r}}return null}function nn(e,t){if(t===null)return`mix`;let n=t.includes(`/`)?tn(e,t):null;return n?n.lane:t===`vo`?`vo`:tn(e,t)?.lane??null}function rn(e,t){let n=nn(e,t);return n===null||n===`mix`?[...Qt]:[n]}var an={vo:`Voiceover`,music:`Music`,sfx:`Sound effects`};function on(e,t){let n=nn(e,t);return n===null?null:n===`mix`?`Whole mix`:n===`vo`?an.vo:`${an[n]} · ${tn(e,t).row.name}`}function sn(e){let t=[{value:`mix`,label:`Whole mix`,on:null}];e.heard.vo&&t.push({value:`vo`,label:an.vo,on:`vo`,row:`vo`});for(let n of[`music`,`sfx`])for(let r of e.heard[n])t.push({value:`${n}:${r.key}`,label:`${an[n]} · ${r.name}`,on:St(r),row:n});return t}var cn=.5;function ln(e){let t=Math.round(e/cn)*cn;return Math.min(6,Math.max(-24,t))}function un(e,t=1){let n=Math.abs(e).toFixed(t);return Number(n)===0?n:`${e<0?`−`:`+`}${n}`}var dn=`—`,fn=`Install ffmpeg for loudness`;function pn(e){let t=(e,t,n)=>[{id:`integrated`,label:`LUFS integrated`,value:e[0],tip:e[1]},{id:`truePeak`,label:`dBTP true peak`,value:t[0],tip:t[1]},{id:`musicUnderVo`,label:`Music under VO`,value:n[0],tip:n[1]}],n=e=>t([dn,e],[dn,e],[dn,e]);if(e.kind===`empty`)return n(`Nothing to measure`);if(e.kind===`waiting`)return n(null);if(e.kind===`timeout`)return n(`Measuring took too long · click to retry`);if(e.kind===`error`)return n(`Couldn't measure loudness · click to retry`);let r=e.result;if(!r.available)return n(fn);let i=e=>r.silent?[`−∞`,`The mix is silent`]:e===null?[dn,`Couldn't measure loudness`]:[un(e),null],a=r.silent?[`−∞`,`The mix is silent`]:r.musicUnderVo===null?[dn,`Needs Voiceover and Music both playing`]:[`${un(r.musicUnderVo,0)} dB`,null];return t(i(r.integrated),i(r.truePeak),a)}function mn(e){return Math.max(10,Math.round((Number.isFinite(e)?e:0)/10)*10)}function hn(e){return`Makes a lightweight 1080p copy on your drive so this cut previews smoothly. About ${mn(e)} MB. Your original isn't changed.`}var gn=(e,t)=>`${e}/${t}`;function _n(e,t){let n={job:e.id,video:e.video,version:e.version,pct:e.pct,state:e.state,at:t};return e.reason!==void 0&&(n.reason=e.reason),n}function vn(e,t){let n=gn(t.video,t.version),r=e[n];if(r&&r.job===t.job){if(r.state!==`running`||t.state===`running`&&t.pct<=r.pct)return e}else if(r&&r.at>t.at)return e;return{...e,[n]:t}}function yn(e,t,n,r){let i=new Set(t.map(e=>e.id)),a=null;for(let[t,o]of Object.entries(e))o.at>=n||(o.state===`running`&&!i.has(o.job)||o.state===`done`&&!r(o.video,o.version))&&(a??={...e},delete a[t]);let o=a??e;for(let e of t)o=vn(o,_n(e,n));return o}function bn(e){return e.ffmpeg?e.starting||e.job?.state===`running`||e.job?.state===`done`&&!e.hasProxy?`working`:e.hasProxy?e.watched&&e.job?.state===`done`?`done`:`none`:e.need||e.broken?`offer`:`none`:`none`}function xn(e,t){return e||(t?`The browser couldn't play this file`:null)}function Sn(e){let t=[Ke(e.size??0)];return e.width&&e.height&&t.push(`${e.width}×${e.height}`),e.version&&t.push(`from ${e.version}`),t.join(` · `)}function Cn(e){return/Mac|iPhone|iPad|iPod/.test(e)?`⌘C`:`Ctrl+C`}var wn=[`voice`,`music`,`sfx`,`other`,`cut`],Tn={voice:`Voiceover`,music:`Music`,sfx:`Sound effects`,other:`Other audio`,cut:`Cut`};function En(e){return e?e.voice+e.music+e.sfx+e.cut+e.other:0}var Dn={voice:{kind:`voice`,one:`voiceover file`,many:`voiceover files`},music:{kind:`music`,one:`music file`,many:`music files`},sfx:{kind:`sfx`,one:`sound effect file`,many:`sound effect files`}};function On(e,t){let n=Dn[e],r=n&&t?t[n.kind]:0;return!n||!(r>0)?null:{kind:n.kind,text:`${r} ${r===1?n.one:n.many} found in this project`,review:`Review ${n.many} in Found`}}function kn(e){if(!e)return null;let t=e.broughtIn.length,n=En(e.counts);return t>0&&n>0?`${t} brought in · ${n} more found`:t>0?`${t} brought in`:n>0?`${n} found`:null}function An(e){return e?e.digest?`d:${e.digest}`:`${e.broughtIn.length}:${wn.map(t=>e.counts[t]).join(`,`)}`:``}var jn=(e,t)=>e.path===t.path&&e.kind===t.kind&&e.folder===t.folder&&e.size===t.size&&e.modified===t.modified&&e.duration===t.duration&&e.score===t.score&&e.suggested===t.suggested&&e.reasons.length===t.reasons.length&&e.reasons.every((e,n)=>e===t.reasons[n]);function Mn(e,t){let n=new Map(e.map(e=>[e.path,e])),r=t.map(e=>{let t=n.get(e.path);return t&&jn(t,e)?t:e});return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r}function Nn(e){return e?e.split(`/`).map(e=>e.replace(/([a-z\d])([A-Z])/g,`$1 $2`).split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)).filter(Boolean).join(` / `):`Project folder`}var Pn=`\0cuts`;function Fn(e){let t=new Map,n=[];for(let r of e){if(r.kind===`cut`){n.push(r);continue}let e=t.get(r.folder);e||t.set(r.folder,e={key:r.folder,title:Nn(r.folder),folder:r.folder,files:[]}),e.files.push(r)}let r=[...t.values()];return n.length&&r.push({key:Pn,title:`Other cuts`,folder:null,files:n}),r}function In(e,t,n){let r=n.trim().toLowerCase();return e.filter(e=>(t===`all`||e.kind===t)&&(!r||e.path.toLowerCase().includes(r)))}function Ln(e){return wn.map(t=>[t,e.filter(e=>e.kind===t).length]).filter(([,e])=>e>0)}function Rn(e){if(e===null||!Number.isFinite(e)||e<0)return`—`;let t=Math.round(e*10),n=Math.floor(t/600);return`${n}:${((t-n*600)/10).toFixed(1).padStart(4,`0`)}`}var zn=e=>e.replace(/\.$/,``).replace(/^(\p{Lu})(?=\p{Ll})/u,e=>e.toLowerCase());function Bn(e,t){let n=e=>`${e} ${e===1?`file`:`files`}`;if(t.length===0)return`Brought in ${n(e)}`;let r=[...new Set(t.map(e=>zn(e.reason)))].join(`; `);return`${e>0?`Brought in ${n(e)}.`:`Nothing was brought in.`} ${t.length} couldn't be added: ${r}.`}function Vn(e,t){return t.map(t=>{let n=t.slice(t.lastIndexOf(`/`)+1);for(let r of e.lanes){let e=r.variants.find(e=>e.file===t);if(!e)continue;let i=e.meta.description;return{path:t,name:n,kind:r.stage,label:r.stage===`voice`&&r.name!==Tn.voice?`Voiceover · ${r.name}`:Tn[r.stage],reasons:typeof i==`string`?i:``,playable:!0}}for(let r of e.videos){let e=r.versions.find(e=>e.file===t);if(e)return{path:t,name:n,kind:`cut`,label:`Cut · ${r.name} ${e.id}`,reasons:``,playable:!1}}return e.files.some(e=>e.file===t)?{path:t,name:n,kind:`doc`,label:`Doc`,reasons:``,playable:!1}:{path:t,name:n,kind:null,label:``,reasons:``,playable:!1}})}function Hn(e,t){return e.item!==t.item||e.kind!==t.kind||e.ticked!==t.ticked||e.playing!==t.playing||e.failure!==t.failure}function Un(e,t){let n=e.versions.findIndex(e=>e.id===t);return n>0?e.versions[n-1]:void 0}function Wn(e,t){return e.length<2?null:t&&e.some(e=>e.id===t)?t:(e.find(e=>e.primary)??e[0]).id}function Gn(e){if(e.views.length===0)return[];let t=e.views.length===1,n=new Set(e.views.map(e=>e.id));return U([...e.views.map(e=>({...e,absent:!1})),...e.previous.filter(e=>!n.has(e.id)).map(e=>({...e,absent:!0}))]).map(n=>{let r=!n.absent&&!t,i=r?e.notes.filter(e=>e.status===`todo`&&(e.format===null||e.format===n.id)).length:0,a=n.absent||n.primary?null:e.missing.has(n.file)?`File not found`:W(n.label,n.duration,e.versionDuration);return{id:n.id,label:n.label,width:n.width,height:n.height,enabled:r,selected:!n.absent&&(t||n.id===e.current),count:i,warn:a,reason:n.absent?`absent`:t?`single`:null}})}function Kn(e,t,n){let r=e.filter(e=>e.enabled),i=r.findIndex(e=>e.id===t);return i===-1?null:r[i+n]?.id??null}function qn(e,t){let n=[e.label];return e.reason===`absent`&&n.push(`not in ${t}`),e.reason===`single`&&n.push(`the only format`),e.count>0&&n.push(`${e.count} open note${e.count===1?``:`s`}`),e.warn&&n.push(e.warn),n.join(`, `)}function Jn(e,t,n=14){let r=n/Math.max(e,t);return{width:Math.max(4,Math.round(e*r)),height:Math.max(4,Math.round(t*r))}}var Yn=e=>`repeat(${e}, minmax(0, 1fr))`;function Xn(e,t,n){return`In Rushes project "${e}", register the other shapes of "${t}" ${n} (the same cut rendered at other aspect ratios, such as 9:16, 1:1 and 4:5) with rushes_add_format, one call per file.`}function Zn(e,t,n){return n||Math.abs(e.width-t.width)<1&&Math.abs(e.height-t.height)<1?null:[{width:`${e.width}px`,height:`${e.height}px`},{width:`${t.width}px`,height:`${t.height}px`}]}var Qn=(e,t)=>e.filter(e=>pe(e,t)),$n=(e,t)=>t===null?[]:e.filter(e=>!pe(e,t));function er(e,t,n){return e.box?t===null?!0:e.format===null?t===n:e.format===t:!1}var tr=`A drawn box belongs to one frame, so this note stays on this format.`;function nr(e,t,n){return n?`A drawn box fixes this note to ${e}.`:t===`this`?`Shows only while you're viewing ${e}.`:`Shows on every format.`}function rr(e,t){return e.format===null?t?`All`:null:de(e.format)}function ir(e,t,n){if(e.format===null)return null;let r=t.find(t=>t.id===e.format);return r?{kind:`show`,id:r.id,label:r.label}:!e.box&&!n.some(t=>t.id===e.format)?{kind:`restore`}:null}var ar,K,or,sr,cr=0,lr=[],ur=t,dr=ur.__b,fr=ur.__r,pr=ur.diffed,mr=ur.__c,hr=ur.unmount,gr=ur.__;function _r(e,t){ur.__h&&ur.__h(K,e,cr||t),cr=0;var n=K.__H||(K.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function q(e){return cr=1,vr(Or,e)}function vr(e,t,n){var r=_r(ar++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Or(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=K,!K.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};K.__f=!0;var a=K.shouldComponentUpdate,o=K.componentWillUpdate;K.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},K.shouldComponentUpdate=i}return r.__N||r.__}function J(e,t){var n=_r(ar++,3);!ur.__s&&Dr(n.__H,t)&&(n.__=e,n.u=t,K.__H.__h.push(n))}function Y(e,t){var n=_r(ar++,4);!ur.__s&&Dr(n.__H,t)&&(n.__=e,n.u=t,K.__h.push(n))}function X(e){return cr=5,yr(function(){return{current:e}},[])}function yr(e,t){var n=_r(ar++,7);return Dr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function br(e,t){return cr=8,yr(function(){return e},t)}function xr(){var e=_r(ar++,11);if(!e.__){for(var t=K.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=`P`+n[0]+`-`+n[1]++}return e.__}function Sr(){for(var e;e=lr.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Tr),t.__h.some(Er),t.__h=[]}catch(n){t.__h=[],ur.__e(n,e.__v)}}}ur.__b=function(e){K=null,dr&&dr(e)},ur.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),gr&&gr(e,t)},ur.__r=function(e){fr&&fr(e),ar=0;var t=(K=e.__c).__H;t&&(or===K?(t.__h=[],K.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Tr),t.__h.some(Er),t.__h=[],ar=0)),or=K},ur.diffed=function(e){pr&&pr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(lr.push(t)!==1&&sr===ur.requestAnimationFrame||((sr=ur.requestAnimationFrame)||wr)(Sr)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),or=K=null},ur.__c=function(e,t){t.some(function(e){try{e.__h.some(Tr),e.__h=e.__h.filter(function(e){return!e.__||Er(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],ur.__e(n,e.__v)}}),mr&&mr(e,t)},ur.unmount=function(e){hr&&hr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Tr(e)}catch(e){t=e}}),n.__H=void 0,t&&ur.__e(t,n.__v))};var Cr=typeof requestAnimationFrame==`function`;function wr(e){var t,n=function(){clearTimeout(r),Cr&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Cr&&(t=requestAnimationFrame(n))}function Tr(e){var t=K,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),K=t}function Er(e){var t=K;e.__c=e.__(),K=t}function Dr(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Or(e,t){return typeof t==`function`?t(e):t}var kr=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}};function Ar(){let e=location.pathname.match(/\/p\/([a-z2-9]{8})\//);return e?e[1]:null}async function jr(e,t,n,r={}){let i=Ar(),a={};n!==void 0&&(a[`content-type`]=`application/json`),i&&(a[`x-rushes-project`]=i);let o=await fetch(t,{method:e,headers:a,body:n===void 0?void 0:JSON.stringify(n),...r.keepalive?{keepalive:!0}:{}}),s=await o.text(),c=s?JSON.parse(s):{};if(!o.ok)throw new kr(o.status,c.error??`error`,c.message??`Request failed (${o.status})`);return c}var Z={get:e=>jr(`GET`,e),post:(e,t={})=>jr(`POST`,e,t),patch:(e,t)=>jr(`PATCH`,e,t),put:(e,t,n)=>jr(`PUT`,e,t,n),del:(e,t={})=>jr(`DELETE`,e,t)};async function Mr(e,t,n,r=null){let i=Ar(),a=await fetch(`/api/videos/${encodeURIComponent(e)}/versions/${encodeURIComponent(t)}/frame?t=${n}${r?`&format=${encodeURIComponent(r)}`:``}`,{headers:i?{"x-rushes-project":i}:{}});if(!a.ok){let e=await a.json().catch(()=>({}));throw new kr(a.status,e.error??`error`,e.message??`Request failed (${a.status})`)}let o=Number(a.headers.get(`x-rushes-frame`)),s=await a.blob(),c=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>t(n.error??Error(`Couldn't read the frame`)),n.readAsDataURL(s)});return{frame:Number.isInteger(o)&&o>=0?o:null,png:c}}function Nr(e){let t=Ar();return`/media?path=${encodeURIComponent(e)}${t?`&project=${t}`:``}`}function Pr(){let e=Ar();return`/api/events${e?`?project=${e}`:``}`}var Fr=[`change`,`proxy`,`corrupt`],Ir=e=>`rushes-sse-v1-${e}`,Lr=e=>`rushes-v1-${e}`,Rr=4e4,zr=5e3;function Br(){return{locks:typeof navigator<`u`?navigator.locks:void 0,BroadcastChannel:typeof BroadcastChannel==`function`?BroadcastChannel:void 0,EventSource,page:typeof window<`u`?{window,document}:void 0}}function Vr(e){if(typeof e!=`object`||!e)return!1;let{v:t,type:n,data:r}=e;return t===1?n===`open`||n===`error`||n===`ping`||Fr.includes(n)&&typeof r==`string`:!1}function Hr(e,t){t.type===`open`?e.open():t.type===`error`?e.error():`data`in t&&e[t.type](t.data)}function Ur(e,t,n,r){let i=new e.EventSource(t),a=e=>{Hr(n,e),r?.(e)};for(let e of Fr)i.addEventListener(e,t=>a({v:1,type:e,data:String(t.data??``)}));return i.addEventListener(`ping`,()=>a({v:1,type:`ping`})),i.onopen=()=>a({v:1,type:`open`}),i.onerror=()=>a({v:1,type:`error`}),i}function Wr(e,t,n,r=Br()){let{locks:i,BroadcastChannel:a}=r;if(!i||!a){let e=Ur(r,t,n);return{role:()=>`own`,close:()=>e.close()}}let o=r.random??Math.random,s=`follower`,c=!1,l=!1,u=null,d=null,f=0,p=0,m=null,h,g=new a(Lr(e)),_=e=>g.postMessage(e),v=()=>{u?.close(),u=null,p=0,s===`leader`&&(s=`follower`);let e=d;d=null,e?.()},y=()=>{clearTimeout(h),!(c||l||s!==`follower`)&&(h=setTimeout(S,Rr+o()*zr))},b=e=>{p=e,s=`leader`,clearTimeout(h),u=Ur(r,t,n,_)},x=(a=!1)=>{let o=++f;m?.abort();let h=new AbortController;m=h;let g=!1;i.request(Ir(e),a?{steal:!0}:{signal:h.signal},()=>new Promise(e=>{if(g=!0,c||l||o!==f)return e();d=e,b(o)})).catch(()=>{p===o?(v(),!c&&!l&&(x(),y())):a&&!g&&o===f&&!c&&!l&&(s=`own`,u=Ur(r,t,n))})},S=()=>{c||l||s!==`follower`||(x(!0),n.resync())};g.onmessage=e=>{s===`follower`&&!l&&Vr(e.data)&&(y(),Hr(n,e.data))};let C=()=>{c||l||(l=!0,clearTimeout(h),f++,m?.abort(),m=null,v(),s===`own`&&(s=`follower`))},w=()=>{!c&&l&&(l=!1,x(),y(),n.resync())},T=e=>{e.persisted&&w()},E=r.page;return E?.window.addEventListener(`pagehide`,C),E?.window.addEventListener(`pageshow`,T),E?.document.addEventListener(`freeze`,C),E?.document.addEventListener(`resume`,w),x(),y(),{role:()=>s,close(){c||(c=!0,clearTimeout(h),m?.abort(),v(),g.close(),E?.window.removeEventListener(`pagehide`,C),E?.window.removeEventListener(`pageshow`,T),E?.document.removeEventListener(`freeze`,C),E?.document.removeEventListener(`resume`,w))}}}function Gr(){let[e,t]=q(null),[n,r]=q([]),[i,a]=q(null),[o,s]=q(!1),[c,l]=q({}),u=X(void 0),d=X(0),f=X(0),p=X(!1),m=X(void 0),h=X(750),g=async()=>{let e=++d.current,n=performance.now(),[i,o]=await Promise.all([Z.get(`/api/state`).then(e=>({ok:!0,data:e}),e=>({ok:!1,error:e})),Z.get(`/api/assets`).then(e=>({ok:!0,assets:e.assets}),e=>({ok:!1,error:e}))]);if(e<f.current)return;f.current=e;let c=!1;if(i.ok){let e=i.data;t(e);let r=(t,n)=>!!e.project.videos.find(e=>e.id===t)?.versions.find(e=>e.id===n)?.proxy;l(t=>yn(t,e.proxies?.jobs??[],n,r)),a(null),s(!1)}else i.error instanceof kr&&i.error.code===`wrong_project`?(s(!0),c=!0):a(i.error.message);o.ok&&r(o.assets),clearTimeout(m.current),c||i.ok&&o.ok?h.current=750:(m.current=window.setTimeout(()=>void g(),h.current),h.current=Math.min(h.current*2,1e4))};return J(()=>{g();let e=Wr(Ar()??``,Pr(),{change(){clearTimeout(u.current),u.current=window.setTimeout(()=>void g(),40)},proxy(e){let t=JSON.parse(e);l(e=>vn(e,{...t,at:performance.now()}))},corrupt(e){let{file:t}=JSON.parse(e);a(`${t} has an error and wasn't loaded. Fix or restore it, and Rushes will pick it up.`)},error(){a(`Lost touch with the Rushes server. Retrying…`),!p.current&&(p.current=!0,g().finally(()=>{p.current=!1}))},open(){p.current=!1,g()},resync(){g()}});return Rt(location.search).test&&(window.__rushesLive={role:()=>e.role()}),()=>{e.close(),clearTimeout(u.current),clearTimeout(m.current)}},[]),{state:e,assets:n,problem:i,wrongProject:o,refresh:g,proxyJobs:c,noteProxyJob:e=>l(t=>vn(t,_n(e,performance.now())))}}function Kr(e){return e.rev?`${e.path}#${e.rev}`:e.path}function qr(e){return e.modified?e.modified:e.size===null?void 0:String(e.size)}var Jr=.05,Yr=6e4;function Xr(e){return 10**(e/20)}function Zr(e){let t=e.some(e=>e.solo),n={};for(let r of e){let e=t?+!!r.solo:+!r.muted;n[r.id]=Xr(r.level??0)*e}return n}function Qr(e,t){return+(e===t)}function $r(e,t){let n={};for(let r of e){let e=t[r.lane];n[r.id]=e===void 0?1:Qr(e,r.id)}return n}function ei(e,t){let n=[];for(let r of e)r.duration>0&&(r.offset+r.duration<=t||(r.offset<=t?n.push({id:r.id,when:0,offset:t-r.offset}):n.push({id:r.id,when:r.offset-t,offset:0})));return n}function ti(e,t,n){return Math.abs(e-t)>1/n+1e-9}function ni(e,t){let n=Math.max(0,Math.floor(t)),r=new Float32Array(n),i=e.length;if(i===0)return r;for(let t=0;t<n;t++){let a=Math.min(i-1,Math.floor(t*i/n)),o=Math.min(i,Math.max(a+1,Math.floor((t+1)*i/n))),s=0;for(let t=a;t<o;t++){let n=Math.abs(e[t]);n>s&&(s=n)}r[t]=s}return r}function ri(e,t){let n=new Float32Array(Math.max(0,Math.floor(t)));for(let r of e){let e=ni(r,t);for(let t=0;t<n.length;t++)e[t]>n[t]&&(n[t]=e[t])}return n}function ii(e){return Math.min(Yr,Math.max(1,Math.round(e*50)))}function ai(e,t){return!t||e!==null&&e>oi}var oi=900;function si(e){oi=e??900}function ci(e){return e!==null&&e>3456e5}function li(e,t,n,r=1/0,i=Jr){return e<0||e>=t?n.paused?`none`:`pause`:n.paused?`play`:n.seeking||n.readyState!==void 0&&n.readyState<3||r<.25?`none`:Math.abs(n.time-e)>i?`seek`:`none`}function ui(e,t){return e.map(e=>e.duration>0?e:{...e,duration:t[Kr(e)]??0})}function di(e,t){if(e!==null&&e>0)return e;let n=0;for(let e of t)e.duration>0&&(n=Math.max(n,e.offset+e.duration));return n}var fi=null;function pi(e,t){let n=fi,r={owner:e,stop:t};if(fi=r,n&&n.owner!==e)try{n.stop()}catch{}return()=>{fi===r&&(fi=null)}}function mi(e){fi&&fi.owner===e&&(fi=null)}function hi(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function gi(e){let t=[],n=e.replace(/`([^`]+)`/g,(e,n)=>(t.push(`<code>${n}</code>`),`\u0000${t.length-1}\u0000`));return n=n.replace(/\[([^\][]*)\]\((?:[^()]|\([^()]*\))*\)/g,`$1`),n=n.replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`),n=n.replace(/\*([^*]+)\*/g,`<em>$1</em>`),n=n.replace(/\u0000(\d+)\u0000/g,(e,n)=>t[Number(n)]),n}function _i(e){let t=/^( *)([-*]|\d+\.)[ \t]+(.*)$/.exec(e);return t?{indent:t[1].length,ordered:/\d/.test(t[2]),content:t[3]}:null}function vi(e){let t=/^&gt;\s?(.*)$/.exec(e);return t?t[1]:null}function yi(e){let t=hi(e).split(/\r\n|\r|\n|\u2028|\u2029/),n=[],r=[],i=null,a=()=>{r.length&&(n.push(`<p>${gi(r.join(` `))}</p>`),r=[])},o=()=>{if(i){let e=i.ordered?`ol`:`ul`;n.push(`<${e}>${i.items.map(e=>`<li>${e}</li>`).join(``)}</${e}>`),i=null}},s=0;for(;s<t.length;){let e=t[s];if(/^```/.test(e)){a(),o();let e=[];for(s++;s<t.length&&!/^```/.test(t[s]);)e.push(t[s]),s++;s++,n.push(`<pre><code>${e.join(`
2
+ `)}</code></pre>`);continue}let c=/^(#{1,3})[ \t]+(.*)$/.exec(e);if(c){a(),o();let e=c[1].length;n.push(`<h${e}>${gi(c[2])}</h${e}>`),s++;continue}let l=vi(e);if(l!==null){a(),o();let e=[l];s++;let r;for(;s<t.length&&(r=vi(t[s]))!==null;)e.push(r),s++;n.push(`<blockquote><p>${gi(e.join(` `))}</p></blockquote>`);continue}let u=_i(e);if(u&&u.indent<2){a(),(!i||i.ordered!==u.ordered)&&(o(),i={ordered:u.ordered,items:[]});let e=gi(u.content);s++;let n=[],r;for(;s<t.length&&(r=_i(t[s]))&&r.indent>=2;)n.push(r),s++;if(n.length){let t=n[0].ordered?`ol`:`ul`;e+=`<${t}>${n.map(e=>`<li>${gi(e.content)}</li>`).join(``)}</${t}>`}i.items.push(e);continue}if(e.trim()===``){a(),o(),s++;continue}o(),r.push(e),s++}return a(),o(),n.join(`
3
+ `)}var bi=/[\p{L}\p{N}]/u,xi=/\s/,Si=/[_\-/]/,Ci=/[\s,;:.\-–—(_/]+$/u,wi=/^[\p{M}\u200d\ufe0f\u{1F3FB}-\u{1F3FF}\u{E0020}-\u{E007F}]$/u,Ti=/^[\u{1F1E6}-\u{1F1FF}]$/u,Ei=/[\uD800-\uDFFF]/gu,Di=/[\p{Cc}\p{Zl}\p{Zp}]+/gu,Oi=/(?![\u200c\u200d\u{E0000}-\u{E007F}])\p{Cf}/gu,ki=/(\u{1F3F4})([\u{E0000}-\u{E007F}]*)|[\u{E0000}-\u{E007F}]+/gu,Ai=/^[\p{Cf}\s\u034f\u115f\u1160\u17b4\u17b5\u2800\u3164\uffa0]*$/u;function ji(e){let t=e.replace(Ei,`�`).replace(Di,` `).replace(Oi,``).replace(ki,(e,t,n)=>t?t+n:``).replace(/\s+/g,` `).trim();return Ai.test(t)?``:t}function Mi(e){let t=[],n=!1,r=0;for(let i of e){let e=t.length-1;e>=0&&(n||wi.test(i)||Ti.test(i)&&r===1)?(t[e]+=i,r=Ti.test(i)?r+1:r):(t.push(i),r=+!!Ti.test(i)),n=i===`‍`}return t}function Ni(e,t){for(let n=e.length-1;n>0;n--)if(t.test(e[n]))return n;return-1}function Pi(e,t){if(e.length<=t)return e;let n=Array.from(e);if(n.length<=t)return e;let r=Mi(n.slice(0,t+32)),i=[],a=0;for(let e of r){let n=Array.from(e).length;if(a+n>t-1)break;i.push(e),a+=n}let o=r.length>0?Array.from(r[0])[0]:``;if(i.length===0&&t>1&&o&&!wi.test(o))return o+`…`;let s=i.length,c=r[i.length];if(c!==void 0&&!xi.test(c)){let e=Ni(i,xi);e<=0&&(e=Ni(i,Si)),e>0&&(s=e)}return i.slice(0,s).join(``).replace(Ci,``)+`…`}var Fi=[`;`,`. `,` — `,` (`],Ii=12;function Li(e,t){let n=0,r=0;for(let i of e){if(r++>=t)break;n+=i.length}return n}function Ri(e,t){let n=Li(e,Math.max(0,Ii-t)),r=e.length;for(let t of Fi){let i=e.indexOf(t,n);i>=0&&i<r&&(r=i)}return e.slice(0,r).trim()}function zi(e){let t=e.split(/[\\/]/).pop()??``,n=t.lastIndexOf(`.`);return ji(n>0?t.slice(0,n):t)}var Bi=new Map;function Vi(e){let t=e.replace(/^0+/,``)||`0`,n=Bi.get(t);return n||(Bi.size>=2e3&&Bi.clear(),n=Hi(t),Bi.set(t,n)),n}function Hi(e){return RegExp(`^v0*${e}(?![\\p{L}\\p{N}])(?:(?:\\s*[:,\\-–—]|\\.(?=\\s|$))[\\s:,.\\-–—]*|\\s*$|\\s+(?=\\(batch\\b))`,`iu`)}var Ui=e=>e!==``&&e!==`…`;function Wi(e){let t=Pi(ji(e.label??``),48);if(Ui(t))return t;let n=ji(e.note??``),r=n,i=/^v(\d+)$/i.exec(e.id)?.[1];i!==void 0&&(r=r.replace(Vi(i),``)),r=r.replace(/^\(batch\b[^)]*\)\s*:?\s*/i,``);let a=Array.from(n.slice(0,n.length-r.length)).length;if(r=Ri(r,a),bi.test(r)){let e=Pi(r,48);if(Ui(e))return e}let o=Pi(zi(e.file),48);if(Ui(o))return o;let s=Pi(ji(e.id),48);return Ui(s)?s:`Untitled`}var Gi={script:`Script`,picture:`Picture`,voice:`Voice`,music:`Music`,sfx:`Sound effects`,mix:`Mix`,notes:`Notes`,assets:`Files`,project:`Project`},Ki=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],qi=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],Ji=e=>String(e).padStart(2,`0`),Yi=e=>Number.isFinite(e.getTime());function Xi(e,t){let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=new Date(n),i=e=>Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())/864e5;return i(t)-i(r)}function Zi(e){return Yi(e)?`${Ji(e.getHours())}:${Ji(e.getMinutes())}`:`--:--`}function Qi(e){return`${e.getFullYear()}-${Ji(e.getMonth()+1)}-${Ji(e.getDate())}`}function $i(e,t,n){if(!Yi(e))return`Date unknown`;if(!n)return`${Ki[e.getDay()]} ${e.getDate()} ${qi[e.getMonth()]} ${e.getFullYear()}`;let r=Xi(e.toISOString(),t);if(r===0)return`Today`;if(r===1)return`Yesterday`;let i=e.getFullYear()===t.getFullYear()?``:` ${e.getFullYear()}`;return`${Ki[e.getDay()].slice(0,3)} ${e.getDate()} ${qi[e.getMonth()].slice(0,3)}${i}`}function ea(e){return!e||!((e.label??``).trim()||e.note.trim())?null:Wi(e)}var ta=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function na(e,t){let n=Xi(e,t);if(n===null)return null;let r=Math.max(0,(t.getTime()-Date.parse(e))/1e3);return r<60?{just:!0}:r<3600?{n:Math.floor(r/60),unit:`minute`}:n<=0?{n:Math.floor(r/3600),unit:`hour`}:n===1?{yesterday:!0}:n<7?{n,unit:`day`}:{date:new Date(Date.parse(e))}}function ra(e,t,n){if(!e)return``;if(`just`in e)return`just now`;if(`yesterday`in e)return`yesterday`;if(`date`in e){let r=e.date,i=n?ta[r.getMonth()].slice(0,3):ta[r.getMonth()];return`${r.getDate()} ${i}${r.getFullYear()===t.getFullYear()?``:` ${r.getFullYear()}`}`}return e.unit===`day`?`${e.n} days ago`:n?`${e.n} ${e.unit===`minute`?`min`:`h`} ago`:`${e.n} ${e.unit}${e.n===1?``:`s`} ago`}function ia(e,t){return ra(na(e,t),t,!0)}function aa(e,t){return ra(na(e,t),t,!1)}function oa(e,t){let n=e=>e.replace(/^v/i,``);return e.find(e=>n(e)===t)??e.find(e=>n(e).startsWith(t))??null}function sa(e,t,n,r=!1){return n<=0?null:e===`ArrowDown`||r&&e===`ArrowRight`?t<0?0:(t+1)%n:e===`ArrowUp`||r&&e===`ArrowLeft`?t<0?n-1:(t-1+n)%n:e===`Home`?0:e===`End`?n-1:null}function ca(e,t){let n=[];e.duration!==null&&n.push(`${e.duration.toFixed(1)} s`),n.push(e.shots.length===0?`no shots`:`${e.shots.length} shot${e.shots.length===1?``:`s`}`);let r=ia(e.addedAt,t);return r&&n.push(r),n.join(` · `)}var la=0;Array.isArray;function Q(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--la,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}var ua={chev:`<path d="M6 9l6 6 6-6"/>`,story:`<rect x="3" y="4" width="11" height="8" rx="1.5"/><rect x="16" y="4" width="5" height="8" rx="1.5"/><rect x="3" y="14" width="5" height="6" rx="1.5"/><rect x="10" y="14" width="11" height="6" rx="1.5"/>`,brief:`<path d="M9 4h6v3H9z"/><path d="M7 5.5H6a1 1 0 0 0-1 1V20a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6.5a1 1 0 0 0-1-1h-1"/><path d="M9 12h6M9 16h4"/>`,kbd:`<rect x="2.5" y="6" width="19" height="12" rx="2.5"/><path d="M6.5 10h1M10.5 10h1M14.5 10h1M8 14h8"/>`,x:`<path d="M6 6l12 12M18 6L6 18"/>`,copy:`<rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V6a2 2 0 0 1 2-2h8"/>`,script:`<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5M9 13h6M9 17h4"/>`,film:`<rect x="3" y="4" width="18" height="16" rx="2.5"/><path d="M7 4v16M17 4v16M3 9h4M3 15h4M17 9h4M17 15h4"/>`,mic:`<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/>`,music:`<path d="M9 18V5l11-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="17" cy="16" r="3"/>`,zap:`<path d="M13 3L5 13h6l-1 8 8-10h-6z"/>`,sliders:`<path d="M5 21v-7M5 10V3M12 21v-9M12 8V3M19 21v-5M19 12V3M2 14h6M9 8h6M16 16h6"/>`,lock:`<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>`,unlock:`<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v1"/>`,play:`<path d="M7 4.5v15l12-7.5z" fill="currentColor" stroke="none"/>`,pause:`<path d="M8 5v14M16 5v14"/>`,prev:`<path d="M15 6l-6 6 6 6"/>`,next:`<path d="M9 6l6 6-6 6"/>`,in:`<path d="M10 5H6v14h4"/><path d="M14 12h6M17 9l3 3-3 3"/>`,out:`<path d="M14 5h4v14h-4"/><path d="M4 12h6M7 9l3 3-3 3"/>`,box:`<path d="M4 8V5a1 1 0 0 1 1-1h3M16 4h3a1 1 0 0 1 1 1v3M20 16v3a1 1 0 0 1-1 1h-3M8 20H5a1 1 0 0 1-1-1v-3"/>`,camera:`<path d="M4 8h3l2-3h6l2 3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1z"/><circle cx="12" cy="13" r="3.5"/>`,check:`<path d="M5 12.5l4.5 4.5L19 7.5"/>`,flag:`<path d="M5 21V4M5 4h11l-2 4 2 4H5"/>`,undo:`<path d="M9 14L4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 0 12h-3"/>`,send:`<path d="M5 12h14M13 6l6 6-6 6"/>`,reply:`<path d="M5 4v7a4 4 0 0 0 4 4h11"/><path d="M16 11l4 4-4 4"/>`,image:`<rect x="3" y="4" width="18" height="16" rx="2.5"/><circle cx="9" cy="10" r="2"/><path d="M21 16l-5-5-9 9"/>`,alert:`<path d="M12 3l9.5 17h-19z"/><path d="M12 10v4M12 17h.01"/>`,new:`<path d="M12 19V5M5 12l7-7 7 7"/>`,grid:`<rect x="3" y="3" width="8" height="8" rx="1.5"/><rect x="13" y="3" width="8" height="8" rx="1.5"/><rect x="3" y="13" width="8" height="8" rx="1.5"/><rect x="13" y="13" width="8" height="8" rx="1.5"/>`,download:`<path d="M12 4v11M7.5 11.5L12 16l4.5-4.5"/><path d="M5 19h14"/>`,save:`<path d="M5 4h11l3 3v13H5z"/><path d="M8 4v5h7V4"/><path d="M8 14h8v6H8z"/>`,folder:`<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>`,list:`<path d="M8 6h13M8 12h13M8 18h13"/><circle cx="3.5" cy="6" r="1.2" fill="currentColor" stroke="none"/><circle cx="3.5" cy="12" r="1.2" fill="currentColor" stroke="none"/><circle cx="3.5" cy="18" r="1.2" fill="currentColor" stroke="none"/>`,open:`<path d="M10 14L20 4"/><path d="M14 4h6v6"/><path d="M19 13v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>`,search:`<circle cx="10.5" cy="10.5" r="6.5"/><path d="M20 20l-5-5"/>`,eyeoff:`<path d="M3 3l18 18M10.6 6.1A10 10 0 0 1 12 6c5 0 9 6 9 6a17 17 0 0 1-3.2 3.7M6.6 6.6A17 17 0 0 0 3 12s4 6 9 6a9 9 0 0 0 4.4-1.1"/><path d="M9.9 9.9a3 3 0 0 0 4.2 4.2"/>`,gauge:`<path d="M4 17a8 8 0 1 1 16 0"/><path d="M12 17l3.5-5"/>`,trash:`<path d="M4 7h16M10 11v6M14 11v6"/><path d="M6 7l1 13h10l1-13M9 7V4h6v3"/>`,refresh:`<path d="M20 12a8 8 0 1 1-2.6-5.9"/><path d="M20 4v4h-4"/>`,stream:`<path d="M3 12h2l2-5 3 10 3-14 3 12 2-3h3"/>`};function $({name:e,class:t}){return Q(`svg`,{class:`ic${t?` ${t}`:``}`,viewBox:`0 0 24 24`,"aria-hidden":`true`,dangerouslySetInnerHTML:{__html:ua[e]??``}})}var da={script:`script`,picture:`film`,voice:`mic`,music:`music`,sfx:`zap`,mix:`sliders`},fa=typeof window<`u`&&`showSaveFilePicker`in window;function pa(){let e=navigator.userAgent;return/Mac/.test(e)?`Show in Finder`:/Windows/.test(e)?`Show in Explorer`:`Open folder`}function ma(e){return e?new Date(e).toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`}):``}function ha({asset:e,toast:t}){let[n,r]=q(!1),i=!e.missing&&Je.has(Xe(e.path)),a=async()=>{if(n)return;r(!0);let i;try{let t=await window.showSaveFilePicker({suggestedName:e.name}),n=await fetch(Nr(e.path));if(!n.ok||!n.body)throw Error(`Couldn't read ${e.name}`);i=await t.createWritable(),await n.body.pipeTo(i)}catch(n){i&&await i.abort().catch(()=>void 0),n.name!==`AbortError`&&t(n.message||`Couldn't save ${e.name}`)}finally{r(!1)}},o=async()=>{try{await Z.post(`/api/reveal`,{path:e.path})}catch(e){t(e.message)}},s=async()=>{try{await navigator.clipboard.writeText(e.abs),t(`Path copied`)}catch{t(`Couldn't reach the clipboard`)}},c=async()=>{try{await Z.post(`/api/open`,{path:e.path})}catch(e){t(e.message)}};return Q(`div`,{class:`aact`,children:[Q(`a`,{class:`btn ghost ib`,"data-tip":`Download`,"aria-label":`Download`,"aria-disabled":e.missing,tabIndex:e.missing?-1:void 0,href:`${Nr(e.path)}&download=1`,download:e.name,onClick:t=>{e.missing&&t.preventDefault()},children:Q($,{name:`download`})}),fa&&Q(`button`,{class:`btn ghost ib`,"data-tip":`Save as…`,"aria-label":`Save as…`,"aria-disabled":e.missing||n,tabIndex:e.missing?-1:void 0,onClick:()=>{e.missing||a()},children:Q($,{name:`save`})}),i&&Q(`button`,{class:`btn ghost ib`,"data-tip":`Open`,"aria-label":`Open`,onClick:()=>void c(),children:Q($,{name:`open`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":pa(),"aria-label":pa(),"aria-disabled":e.missing,tabIndex:e.missing?-1:void 0,onClick:()=>{e.missing||o()},children:Q($,{name:`folder`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Copy path`,"aria-label":`Copy path`,"aria-disabled":e.missing,tabIndex:e.missing?-1:void 0,onClick:()=>{e.missing||s()},children:Q($,{name:`copy`})})]})}function ga({tip:e=`Missing`}){return Q(`span`,{class:`amiss`,"data-tip":e,"aria-label":e,children:`●`})}function _a(e,t){let n=t.find(t=>t.id===e.video),r=n?.versions.find(t=>t.id===e.version),i=n&&e.version?`${n.name} · ${e.version}`:e.label??e.name;return{title:e.formatLabel?`${i} · ${e.formatLabel}`:i,subtitle:va(e)?null:ea(r)}}function va(e){return e.kind===`cut`&&e.format!==void 0}function ya({asset:e,videos:t,toast:n}){let r=e.kind===`cut`||e.kind===`delivery`?_a(e,t):null;return Q(`div`,{class:`arow${e.missing?` missing`:``}${va(e)?` sub`:``}`,children:[Q(`div`,{class:`ainfo`,children:[Q(`div`,{class:`atitle`,children:[r?r.title:e.label??e.name,e.missing&&Q(ga,{})]}),r?.subtitle&&Q(`div`,{class:`asub`,children:r.subtitle}),Q(`div`,{class:`afolder mono`,children:e.path}),!e.missing&&Q(`div`,{class:`ameta`,children:[Ke(e.size??0),` · `,ma(e.modified)]})]}),Q(ha,{asset:e,toast:n})]})}function ba({asset:e,toast:t,onChanged:n}){let[r,i]=q(!1),[a,o]=q(!1),s=X(null);J(()=>{r&&s.current?.focus()},[r]);let c=async()=>{if(!a&&e.video&&e.version){o(!0);try{await Z.del(`/api/videos/${encodeURIComponent(e.video)}/versions/${encodeURIComponent(e.version)}/proxy`),n()}catch(e){t(e.message),i(!1)}finally{o(!1)}}};return Q(`div`,{class:`arow${e.missing?` missing`:``}`,children:[Q(`div`,{class:`ainfo`,children:[Q(`div`,{class:`atitle`,children:[e.name,e.missing&&Q(ga,{})]}),Q(`div`,{class:`afolder mono`,children:e.path}),!e.missing&&Q(`div`,{class:`ameta`,children:Sn(e)})]}),Q(ha,{asset:e,toast:t}),r?Q(`div`,{class:`aconfirm`,role:`group`,"aria-label":`Delete this proxy?`,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),i(!1))},children:[Q(`button`,{ref:s,type:`button`,class:`btn danger`,"aria-disabled":a,onClick:()=>void c(),children:`Delete`}),Q(`button`,{type:`button`,class:`btn ghost`,onClick:()=>i(!1),children:`Keep`})]}):Q(`button`,{type:`button`,class:`btn ghost ib`,"data-tip":`Delete proxy (the original is kept)`,"aria-label":`Delete proxy`,onClick:()=>i(!0),children:Q($,{name:`trash`})})]})}function xa({asset:e,playing:t,paused:n,onToggle:r,videos:i,toast:a}){let o=t&&!n,s=e.label??e.name,c=qe(e.laneName,e.meta);return Q(`div`,{class:`arow${e.missing?` missing`:``}`,children:[Q(`button`,{type:`button`,class:`btn ghost ib`,"data-tip":o?`Pause`:`Play`,"aria-label":`Play ${s}`,"aria-pressed":o,"aria-disabled":e.missing,tabIndex:e.missing?-1:void 0,onClick:()=>{e.missing||r(e)},children:Q($,{name:o?`pause`:`play`})}),Q(`div`,{class:`ainfo`,children:[Q(`div`,{class:`atitle`,children:[s,e.missing&&Q(ga,{})]}),c&&Q(`div`,{class:`atrackmeta`,children:c}),Q(`div`,{class:`afolder mono`,children:e.path}),!e.missing&&Q(`div`,{class:`ameta`,children:[Ke(e.size??0),` · `,ma(e.modified)]})]}),Q(ha,{asset:e,toast:a})]})}function Sa({asset:e,selected:t,onSelect:n,videos:r,toast:i}){return Q(`div`,{class:`arow previewable${e.missing?` missing`:``}${t?` selected`:``}`,children:[Q(`div`,{class:`ainfo`,children:[Q(`button`,{type:`button`,class:`aselect atitle`,"aria-pressed":t,onClick:n,children:[e.label??e.name,e.missing&&Q(ga,{})]}),e.note&&Q(`div`,{class:`asub`,children:e.note}),Q(`div`,{class:`afolder mono`,children:e.path}),!e.missing&&Q(`div`,{class:`ameta`,children:[Ke(e.size??0),` · `,ma(e.modified)]})]}),Q(ha,{asset:e,toast:i})]})}function Ca({asset:e,videos:t,toast:n,onOpen:r}){let i=t.find(t=>t.id===e.video),a=e.t!==void 0&&e.frame!==void 0?`${G(e.t)} · f${e.frame}`:e.label??e.name,o=i&&e.version?`${i.name} · ${e.version}`:null;return Q(`div`,{class:`shot-tile${e.missing?` missing`:``}`,children:[Q(`button`,{type:`button`,class:`shot-thumb`,"aria-label":`Open ${e.name} full size`,onClick:e=>r(e.currentTarget),children:Q(`img`,{src:Nr(e.path),alt:e.name,loading:`lazy`})}),Q(`div`,{class:`shot-meta`,children:[Q(`div`,{class:`mono`,children:[a,e.missing&&Q(ga,{})]}),o&&Q(`div`,{class:`asub`,children:o})]}),Q(ha,{asset:e,toast:n})]})}function wa({asset:e}){let t=X(null),[n,r]=q(!1);return J(()=>{let e=t.current;if(!e)return;if(typeof IntersectionObserver>`u`){r(!0);return}let n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(r(!0),n.disconnect())},{rootMargin:`200px`});return n.observe(e),()=>n.disconnect()},[]),Q(`video`,{ref:t,muted:!0,preload:`metadata`,src:n?`${Nr(e.path)}#t=0.5`:void 0,"aria-label":`${e.name} poster frame`})}function Ta({asset:e,videos:t,toast:n}){let{title:r,subtitle:i}=_a(e,t),a=Ye.has(Xe(e.path));return Q(`div`,{class:`shot-tile${e.missing?` missing`:``}${va(e)?` sub`:``}`,children:[Q(`div`,{class:`shot-thumb poster`,children:!e.missing&&(a?Q(wa,{asset:e}):Q(`div`,{class:`file-tile`,children:Q(`span`,{class:`file-ext mono`,children:Xe(e.path)||`file`})}))}),Q(`div`,{class:`shot-meta`,children:[Q(`div`,{class:`atitle`,children:[r,e.missing&&Q(ga,{})]}),i&&Q(`div`,{class:`asub`,children:i}),Q(`div`,{class:`afolder mono`,children:e.path})]}),Q(ha,{asset:e,toast:n})]})}function Ea(e){return Array.from(e.querySelectorAll(`a[href], button, [tabindex]`)).filter(e=>{if(e.disabled)return!1;let t=e.getAttribute(`tabindex`);return t===null||Number(t)>=0})}function Da({asset:e,onClose:t,toast:n}){let r=X(null),i=X(null);return J(()=>{i.current?.focus()},[]),Q(`div`,{class:`lightbox`,role:`dialog`,"aria-modal":`true`,"aria-label":e.name,ref:r,onKeyDown:e=>{if(e.key===`Escape`){e.stopPropagation(),t();return}if(e.key!==`Tab`||!r.current)return;let n=Ea(r.current);if(n.length===0)return;let i=n[0],a=n[n.length-1];e.shiftKey&&document.activeElement===i?(e.preventDefault(),a.focus()):!e.shiftKey&&document.activeElement===a&&(e.preventDefault(),i.focus())},onClick:e=>{e.target===e.currentTarget&&t()},children:Q(`div`,{class:`lbinner`,children:[Q(`img`,{src:Nr(e.path),alt:e.name}),Q(`div`,{class:`lbactions`,children:[Q(ha,{asset:e,toast:n}),Q(`button`,{ref:i,class:`btn ghost ib`,"aria-label":`Close`,onClick:t,children:Q($,{name:`x`})})]})]})})}var Oa=60,ka=`Up to 12 files of each kind at a time, so the tabs stay quick. Each voiceover folder becomes its own round.`,Aa=wn.filter(e=>e!==`cut`),ja=e=>e.slice(e.lastIndexOf(`/`)+1),Ma=e=>`Couldn't be added: ${e.replace(/\.$/,``).replace(/^(\p{Lu})(?=\p{Ll})/u,e=>e.toLowerCase())}`,Na={voice:`var(--vo)`,music:`var(--music)`,sfx:`var(--sfx)`,other:`var(--text-3)`,cut:`var(--accent)`,doc:`var(--text-3)`};function Pa({kind:e}){return Q(`i`,{class:`kdot`,style:{background:e?Na[e]:`var(--text-3)`}})}function Fa({path:e,name:t,playing:n,onPlay:r}){return Q(`button`,{type:`button`,class:`fplay`,"aria-label":`Play ${t}`,"aria-pressed":n,"data-tip":n?`Pause`:`Play`,onClick:()=>r(e,t),children:Q($,{name:n?`pause`:`play`})})}function Ia({row:e,playing:t,onPlay:n}){return Q(`div`,{class:`frow in`,children:[Q(`span`,{}),e.playable?Q(Fa,{path:e.path,name:e.name,playing:t,onPlay:n}):Q(`span`,{}),Q(`div`,{class:`fnm`,children:[Q(`b`,{class:`fname`,dir:`auto`,title:e.path,children:e.name}),e.reasons&&Q(`small`,{class:`freasons`,children:e.reasons})]}),Q(`span`,{class:`kind static`,title:e.label,children:[Q(Pa,{kind:e.kind}),Q(`span`,{class:`klabel`,children:e.label})]}),Q(`span`,{}),Q(`span`,{})]})}var La=class extends C{shouldComponentUpdate(e){return Hn(this.props,e)}render({item:e,kind:t,ticked:n,playing:r,failure:i,onTick:a,onKind:o,onPlay:s}){let c=ja(e.path),l=e.kind===`cut`;return Q(`div`,{class:`frow${n?` on`:``}`,"data-path":e.path,children:[Q(`input`,{type:`checkbox`,"aria-label":`Tick ${c}`,checked:n,onChange:t=>a(e.path,t.target.checked)}),l?Q(`span`,{}):Q(Fa,{path:e.path,name:c,playing:r,onPlay:s}),Q(`div`,{class:`fnm`,children:[Q(`b`,{class:`fname`,dir:`auto`,title:e.path,children:c}),e.reasons.length>0&&Q(`small`,{class:`freasons`,children:e.reasons.join(` · `)}),i&&Q(`small`,{class:`ffail`,children:Ma(i)})]}),l?Q(`span`,{class:`kind static`,children:[Q(Pa,{kind:`cut`}),Tn.cut]}):Q(`label`,{class:`kind`,children:[Q(Pa,{kind:t}),Q(`select`,{"aria-label":`Kind of ${c}`,value:t,onChange:t=>o(e.path,t.target.value),children:Aa.map(e=>Q(`option`,{value:e,children:Tn[e]}))}),Q($,{name:`chev`,class:`kchev`})]}),Q(`span`,{class:`fdur mono`,children:Rn(e.duration)}),Q(`span`,{class:`fsize mono`,children:Ke(e.size)})]})}};function Ra(e,t){let n=e.findIndex(e=>t.has(e));if(n===-1)return null;for(let r=n+1;r<e.length;r++)if(!t.has(e[r]))return e[r];for(let r=n-1;r>=0;r--)if(!t.has(e[r]))return e[r];return null}function za({state:e,initialKind:t=`all`,playing:n,onPlay:r,onStop:i,toast:a,onChanged:o,onSeen:s}){let c=e.found,[l,u]=q(null),[d,f]=q(null),[p,m]=q(new Set),[h,g]=q({}),[_,v]=q({}),[y,b]=q(``),[x,S]=q(t),[C,w]=q(new Set),[T,E]=q(!0),[D,O]=q(!1),[k,A]=q(!1),[j,M]=q(!1),[N,P]=q([]),F=X(null),I=X(null),L=X(!1),ee=X(null),te=X({onPlay:r,onStop:i});te.current={onPlay:r,onStop:i};let R=br((e,t)=>te.current.onPlay(e,t),[]),ne=X(0),z=X(0),re=async()=>{let e=++ne.current;try{let t=await Z.get(`/api/found`);if(e<z.current)return;z.current=e,u(e=>{let n=Mn(e?.files??[],t.files??[]),r=t.hidden??[];return e&&n===e.files&&JSON.stringify(e.hidden)===JSON.stringify(r)?e:{files:n,hidden:r}}),f(null)}catch(t){e>=z.current&&f(t.message)}};J(()=>{re()},[e]);let ie=An(c);J(()=>s(ie),[ie]);let ae=l?.files??[],B=l?.hidden??[],V=yr(()=>ae.map(e=>({...e,kind:h[e.path]??e.kind,raw:e})),[ae,h]),oe=yr(()=>In(V,x,y),[V,x,y]),se=yr(()=>Fn(oe),[oe]),ce=yr(()=>Ln(V),[V]);J(()=>{x!==`all`&&l&&!c.scanning&&!ce.some(([e])=>e===x)&&S(`all`)},[ce,l,c.scanning]);let le=yr(()=>Vn(e.project,c.broughtIn),[e.project,c.broughtIn]),H=yr(()=>se.filter(e=>!C.has(e.key)).flatMap(e=>e.files.map(e=>e.path)),[se,C]),ue=yr(()=>new Set(H),[H]),de=ae.filter(e=>p.has(e.path)),U=de.length,fe=de.filter(e=>ue.has(e.path)),W=fe.length,pe=yr(()=>new Set([...le.map(e=>e.path),...N]),[le,N]);J(()=>{l&&n.path&&!n.paused&&(ue.has(n.path)||T&&pe.has(n.path)||te.current.onStop())},[l,n.path,n.paused,ue,T,pe]),J(()=>{let e=ee.current;if(!e)return;let t=null;t=e===`search`?I.current:`row`in e?F.current?.querySelector(`.frow[data-path="${CSS.escape(e.row)}"] input[type="checkbox"]`)??null:F.current?.querySelector(`.fhrow[data-path="${CSS.escape(e.restore)}"] button`)??null,t&&(t.focus(),ee.current=null)});let G=br((e,t)=>{m(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),t||me(e)},[]),me=e=>v(t=>{if(!(e in t))return t;let{[e]:n,...r}=t;return r}),he=br((e,t)=>{g(n=>({...n,[e]:t})),me(e)},[]),ge=e=>w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),_e=e=>{let t=new Set(e),n=Ra(H,t);ee.current=n===null?`search`:{row:n},z.current=++ne.current,u(e=>e&&{...e,files:e.files.filter(e=>!t.has(e.path))}),m(e=>new Set([...e].filter(e=>!t.has(e))))},ve=async()=>{if(L.current||U===0)return;L.current=!0,A(!0);let e=de.slice(0,Oa);try{let t=await Z.post(`/api/found/bring-in`,{files:e.map(e=>{let t=h[e.path]??e.kind;return t===`other`?{path:e.path}:{path:e.path,kind:t}})});_e([...t.added.map(e=>e.path),...t.failed.filter(e=>e.code===`already`).map(e=>e.path)]),P(e=>[...e,...t.added.map(e=>e.path)]),v(e=>{let n={...e};for(let e of t.added)delete n[e.path];for(let e of t.failed)e.code!==`already`&&(n[e.path]=e.reason);return n});let n=de.length-e.length,r=Bn(t.added.length,t.failed)+(n>0?` ${n} more ${n===1?`is`:`are`} still ticked.`:``);a(r,r.length>48?6500:void 0),o()}catch(e){a(e.message)}finally{L.current=!1,A(!1)}},ye=async()=>{if(L.current||W===0)return;L.current=!0,A(!0);let e=fe.map(e=>e.path);try{await Z.post(`/api/found/dismiss`,{paths:e}),_e(e),a(`Hid ${e.length} ${e.length===1?`file`:`files`}`),o(),re()}catch(e){a(e.message)}finally{L.current=!1,A(!1)}},be=async e=>{let t=B.map(e=>e.path),n=t.indexOf(e),r=t[n+1]??t[n-1];try{await Z.post(`/api/found/restore`,{paths:[e]}),ee.current=r===void 0?{row:e}:{restore:r},B.length<=1&&O(!1),o(),re()}catch(e){a(e.message)}},xe=async()=>{if(!j){M(!0);try{await Z.post(`/api/found/scan`,{}),o()}catch(e){a(e.message)}finally{M(!1)}}},Se=e=>n.path===e&&!n.paused,Ce=En(c.counts),we=c.scanning;return Q(`section`,{class:`amain found`,"aria-label":`Found files`,ref:F,children:[Q(`header`,{class:`aheader`,children:[Q(`h2`,{children:[`Found `,Q(`span`,{class:`count`,children:Ce})]}),Q(`div`,{class:`acontrols`,children:[Q(`label`,{class:`search-wrap`,children:[Q($,{name:`search`}),Q(`input`,{ref:I,class:`search`,type:`search`,"aria-label":`Search found files`,placeholder:`Search found files`,value:y,onInput:e=>b(e.target.value)})]}),ce.length>0&&Q(`div`,{class:`seg`,role:`group`,"aria-label":`Kind`,children:[Q(`button`,{type:`button`,"aria-pressed":x===`all`,onClick:()=>S(`all`),children:[`All `,Q(`span`,{class:`n`,children:ae.length})]}),ce.map(([e,t])=>Q(`button`,{type:`button`,"aria-pressed":x===e,onClick:()=>S(e),children:[Tn[e],` `,Q(`span`,{class:`n`,children:t})]},e))]}),Q(`button`,{type:`button`,class:`btn ib`,"aria-label":`Look again`,"aria-busy":we||j,"data-tip":`Look through the project folder again`,onClick:()=>void xe(),children:Q($,{name:`refresh`})}),Q(`button`,{type:`button`,class:`btn`,disabled:W===0||k,"data-tip":`Hide the ticked files for good. You can restore them from Hidden.`,onClick:()=>void ye(),children:`Not these`}),Q(`button`,{type:`button`,class:`btn primary`,disabled:U===0||k,onClick:()=>void ve(),children:U>0?`Bring in ${U}`:`Bring in`})]})]}),we&&Q(`p`,{class:`fscan`,"aria-live":`polite`,children:[Q(`span`,{class:`fspin`}),`Looking through the folder…`]}),d&&!l&&Q(`p`,{class:`aempty`,children:d}),le.length>0&&Q(`div`,{class:`fcard in`,children:[Q(`button`,{type:`button`,class:`gh`,"aria-expanded":T,onClick:()=>E(e=>!e),children:[Q($,{name:`chev`,class:`chev`}),Q(`b`,{children:`Brought in with this cut`}),Q(`small`,{children:le.length}),Q(`span`,{class:`fdone`,children:[Q($,{name:`check`}),`in the project`]})]}),T&&le.map(e=>Q(Ia,{row:e,playing:Se(e.path),onPlay:R},e.path))]}),l===null?!d&&Q(`p`,{class:`aempty`,children:`Loading…`}):ae.length===0?!we&&Q(`p`,{class:`aempty`,children:`Nothing else found in this folder.`}):oe.length===0?Q(`p`,{class:`aempty`,children:`Nothing matches.`}):se.map(e=>{let t=!C.has(e.key);return Q(`div`,{class:`fcard fgroup`,children:[Q(`button`,{type:`button`,class:`gh`,"aria-expanded":t,onClick:()=>ge(e.key),title:e.folder??void 0,children:[Q($,{name:`chev`,class:`chev`}),Q(`b`,{children:e.title}),Q(`small`,{children:e.files.length})]}),t&&e.files.map(e=>Q(La,{item:e.raw,kind:e.kind,ticked:p.has(e.path),playing:Se(e.path),failure:_[e.path],onTick:G,onKind:he,onPlay:R},e.path))]},e.key)}),D&&B.length>0&&Q(`div`,{class:`fcard fhidden`,children:[Q(`p`,{class:`fhead`,children:[Q(`b`,{children:`Hidden`}),Q(`small`,{children:B.length})]}),B.map(e=>{let t=ja(e.path);return Q(`div`,{class:`fhrow`,"data-path":e.path,children:[Q(`div`,{class:`fnm`,children:[Q(`b`,{class:`fname`,dir:`auto`,title:e.path,children:t}),Q(`small`,{class:`freasons`,children:Nn(e.folder)})]}),Q(`button`,{type:`button`,class:`btn`,"aria-label":`Restore ${t}`,onClick:()=>void be(e.path),children:[Q($,{name:`undo`}),`Restore`]})]},e.path)})]}),Q(`div`,{class:`ffoot`,children:[Q(`p`,{class:`foot`,children:ka}),B.length>0&&Q(`button`,{type:`button`,class:`flink`,"aria-expanded":D,onClick:()=>O(e=>!e),children:[`Hidden (`,B.length,`)`]})]})]})}var Ba=new Set([`voiceover`,`music`,`sfx`]),Va=new Set([`cut`,`delivery`]),Ha=1048576;function Ua(e){return`rushes.assets.view.${e}`}function Wa(e){try{let t=localStorage.getItem(Ua(e));return t===`grid`||t===`list`?t:null}catch{return null}}function Ga(e,t){try{localStorage.setItem(Ua(e),t)}catch{}}function Ka(e){return e?e.gridToggle?Wa(e.id)??e.view:`list`:`grid`}async function qa(e){let t=await fetch(Nr(e));if(!t.ok)throw Error(`Couldn't load ${e}`);if(!t.body)return{text:await t.text(),truncated:!1};let n=t.body.getReader(),r=new TextDecoder,i=``,a=0,o=!1;for(;;){let{done:e,value:t}=await n.read();if(e)break;if(a+=t.byteLength,a>Ha){let e=t.byteLength-(a-Ha);e>0&&(i+=r.decode(t.subarray(0,e),{stream:!0})),o=!0,await n.cancel().catch(()=>void 0);break}i+=r.decode(t,{stream:!0})}return i+=r.decode(),{text:i,truncated:o}}function Ja({assets:e,videos:t,state:n,foundRequest:r,onFoundRequestUsed:i,onFoundSeen:a,toast:o,onChanged:s}){let c=yr(()=>Ze.filter(t=>t.id===`export`||e.some(e=>t.kinds.includes(e.kind))),[e]),l=c.find(e=>e.id!==`export`)?.id,u=kn(n.found)!==null,[d,f]=q(()=>r.pending?`found`:l??(u?`found`:c[0]?.id??`found`)),p=X(r.pending);J(()=>{if(d===`found`)return;let e=!!d&&c.some(e=>e.id===d);if(p.current&&e)return;let t=l??(e?d:c[0]?.id??`found`);t!==d&&f(t)},[c,d]);let[m,h]=q(()=>({key:0,kind:r.pending?r.kind:void 0})),g=e=>{p.current=!0,f(e)},_=X(r.pending?r.n:-1);J(()=>{r.pending&&(_.current!==r.n&&(_.current=r.n,g(`found`),h(e=>({key:e.key+1,kind:r.kind}))),i())},[r.n,r.pending]);let v=d===`found`,y=v?null:c.find(e=>e.id===d)??null,[b,x]=q(``),[C,w]=q(`newest`),[T,E]=q(null),[D,O]=q(()=>Ka(y)),k=X(y?.id??null);y&&y.id!==k.current&&(k.current=y.id,x(``),E(null),w(`newest`),O(Ka(y)));let A=yr(()=>y?tt(e,y,{query:b,sort:C,film:T,videos:t}):[],[e,y,b,C,T,t]),j=e=>{y&&y.gridToggle&&(O(e),Ga(y.id,e))},[M,N]=q(null),P=X(null),F=(e,t)=>{P.current=t,N(e)},I=()=>{N(null),P.current?.focus()},L=X(null),[ee,te]=q({path:null,paused:!0}),R=X({}),ne=()=>{L.current?.pause(),mi(R.current),te({path:null,paused:!0})},z=(e,t)=>{let n=L.current;if(n){if(ee.path===e&&!ee.paused){n.pause(),mi(R.current),te({path:e,paused:!0});return}ee.path!==e&&(n.src=Nr(e)),pi(R.current,()=>{L.current?.pause(),te(e=>({...e,paused:!0}))}),te({path:e,paused:!1}),n.play().catch(n=>{n instanceof Error&&n.name===`AbortError`||(mi(R.current),te({path:e,paused:!0}),o(`Couldn't play ${t}`))})}},re=e=>z(e.path,e.label??e.name);J(()=>ne,[d,T]),J(()=>ne,[]),J(()=>{s()},[d]),J(()=>{let e=()=>{document.visibilityState===`visible`&&s()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let[ie,ae]=q(null),[B,V]=q(null),oe=!!y&&Qe.has(y.id);J(()=>{if(!oe){ae(null);return}ie&&A.some(e=>e.path===ie&&et(e))||ae(A.find(et)?.path??null)},[oe,A]),J(()=>{if(!ie){V(null);return}let e=!1;return V({loading:!0,text:``,truncated:!1}),qa(ie).then(t=>{e||V({loading:!1,text:t.text,truncated:t.truncated})}).catch(t=>{e||V({loading:!1,text:``,truncated:!1,error:t.message})}),()=>{e=!0}},[ie]);let se=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=e.currentTarget,n=Array.from(t.querySelectorAll(`.afolder-btn`)),r=n.indexOf(document.activeElement);if(r===-1)return;e.preventDefault();let i=n[r+(e.key===`ArrowDown`?1:-1)];i&&(i.focus(),i.click())},ce=async()=>{try{await Z.post(`/api/reveal`,{project:!0})}catch(e){o(e.message)}},le=async()=>{try{let{path:e}=await Z.post(`/api/exports/notes`);o(`Saved to ${e}`),s()}catch(e){o(e.message)}},H=t=>e.filter(e=>t.kinds.includes(e.kind)).length,ue=()=>y?y.id===`screenshot`&&C!==`name`?rt(A,t).map((e,n)=>Q(`section`,{class:`afilm-group`,children:[e.heading&&Q(`h3`,{class:`afilm-heading`,children:e.heading}),Q(`div`,{class:`shots-grid`,children:e.items.map(e=>Q(Ca,{asset:e,videos:t,toast:o,onOpen:t=>F(e,t)},e.path))})]},e.heading??`_${n}`)):Va.has(y.id)?Q(`div`,{class:`shots-grid`,children:A.map(e=>Q(Ta,{asset:e,videos:t,toast:o},e.path))}):Q(`div`,{class:`shots-grid`,children:A.map(e=>Q(Ca,{asset:e,videos:t,toast:o,onOpen:t=>F(e,t)},e.path))}):null,de=()=>y?Ba.has(y.id)?Q(`div`,{class:`arows`,children:A.map(e=>Q(xa,{asset:e,playing:ee.path===e.path,paused:ee.paused,onToggle:re,videos:t,toast:o},e.path))}):y.id===`proxy`?Q(`div`,{class:`arows`,children:A.map(e=>Q(ba,{asset:e,toast:o,onChanged:s},e.path))}):oe?Q(`div`,{class:`arows`,children:A.map(e=>Q(Sa,{asset:e,selected:ie===e.path,onSelect:()=>ae(e.path),videos:t,toast:o},e.path))}):Q(`div`,{class:`arows`,children:A.map(e=>Q(ya,{asset:e,videos:t,toast:o},e.path))}):null,U=ie?(ie.split(`.`).pop()??``).toLowerCase():``,fe=yr(()=>yi(B?.text??``),[B?.text]);return Q(`div`,{class:`assets-lib`,children:[Q(`nav`,{class:`asidebar`,"aria-label":`Folders`,onKeyDown:se,children:[Q(`button`,{type:`button`,class:`afolder-btn afound`,"aria-current":v?`true`:void 0,onClick:()=>{v||h(e=>({key:e.key+1})),g(`found`)},children:[Q(`span`,{children:`Found`}),Q(`span`,{class:`count`,children:En(n.found?.counts)})]}),c.map(e=>Q(`button`,{type:`button`,class:`afolder-btn`,"aria-current":e.id===d?`true`:void 0,onClick:()=>g(e.id),children:[Q(`span`,{children:e.title}),Q(`span`,{class:`count`,children:H(e)})]},e.id)),Q(`button`,{type:`button`,class:`afolder-root`,onClick:()=>void ce(),children:[Q($,{name:`folder`}),`Project folder`]})]}),v?Q(za,{state:n,initialKind:m.kind,playing:ee,onPlay:z,onStop:ne,toast:o,onChanged:s,onSeen:a},m.key):y?Q(`div`,{class:`amain`,children:[Q(`header`,{class:`aheader`,children:[Q(`h2`,{children:[y.title,` `,Q(`span`,{class:`count`,children:A.length})]}),Q(`div`,{class:`acontrols`,children:[Q(`label`,{class:`search-wrap`,children:[Q($,{name:`search`}),Q(`input`,{class:`search`,type:`search`,"aria-label":`Search`,placeholder:`Search`,value:b,onInput:e=>x(e.target.value)})]}),y.filmFilter&&Q(`select`,{class:`sel`,"aria-label":`Film`,value:T??``,onChange:e=>E(e.target.value||null),children:[Q(`option`,{value:``,children:`All films`}),t.map(e=>Q(`option`,{value:e.id,children:e.name},e.id))]}),Q(`select`,{class:`sel`,"aria-label":`Sort`,value:C,onChange:e=>w(e.target.value),children:[Q(`option`,{value:`newest`,children:`Newest`}),Q(`option`,{value:`oldest`,children:`Oldest`}),Q(`option`,{value:`name`,children:`Name`})]}),y.gridToggle&&Q(`div`,{class:`seg`,role:`group`,"aria-label":`View`,children:[Q(`button`,{type:`button`,"aria-pressed":D===`grid`,"aria-label":`Grid view`,"data-tip":`Grid`,onClick:()=>j(`grid`),children:Q($,{name:`grid`})}),Q(`button`,{type:`button`,"aria-pressed":D===`list`,"aria-label":`List view`,"data-tip":`List`,onClick:()=>j(`list`),children:Q($,{name:`list`})})]}),y.id===`export`&&Q(`button`,{type:`button`,class:`btn`,onClick:()=>void le(),children:[Q($,{name:`script`}),`Export notes`]})]})]}),Q(`div`,{class:`abody${oe?` split`:``}`,children:[Q(`div`,{class:`alist`,children:A.length===0?Q(`p`,{class:`aempty`,children:`Nothing here yet.`}):D===`grid`?ue():de()}),oe&&Q(`aside`,{class:`apreview`,children:!ie||!B?Q(`p`,{class:`aempty`,children:`Select a file to preview it here.`}):B.loading?Q(`p`,{class:`aempty`,children:`Loading…`}):B.error?Q(`p`,{class:`aempty`,children:B.error}):Q(S,{children:[U===`md`?Q(`div`,{class:`markdown`,dangerouslySetInnerHTML:{__html:fe}}):Q(`pre`,{class:`plain`,children:B.text}),B.truncated&&Q(`p`,{class:`atrunc`,children:`Showing the first 1 MB`})]})})]})]}):Q(`div`,{class:`empty`,children:[Q($,{name:`grid`}),Q(`h2`,{children:`Nothing to review in Assets yet`})]}),Q(`audio`,{ref:L,onEnded:()=>{mi(R.current),te(e=>({...e,paused:!0}))}}),M&&Q(Da,{asset:M,toast:o,onClose:I})]})}function Ya(e,t,n){let r=X(t.hash),i=X(t);i.current=t;let a=X(Promise.resolve());J(()=>{r.current=t.hash},[t.hash]),J(()=>(n.settle.current=async()=>(await a.current.catch(()=>void 0),(await Z.get(`/api/state`))[e]),()=>{n.settle.current=null}),[]);let o=async t=>{let n=i.current;for(let i=0;;i++){let a=t(n);if(!a)throw Error(`that part is no longer in ${e}.md`);try{let t=await Z.put(a.path,{...a.body,hash:r.current});r.current=t[e].hash;return}catch(t){if(t instanceof kr&&t.code===`${e}_changed`&&i===0){n=(await Z.get(`/api/state`))[e],r.current=n.hash;continue}throw t}}};return{latest:i,enqueue:(e,t)=>{a.current=a.current.catch(()=>void 0).then(()=>o(t)).catch(t=>n.toast(`Couldn't save ${e}: ${t.message}`)).finally(n.onChanged)}}}var Xa=500;function Za(e,t){let n=X(void 0),r=X(e);return r.current=e,J(()=>()=>{n.current!==void 0&&(clearTimeout(n.current),r.current())},[]),{schedule(){clearTimeout(n.current),n.current=window.setTimeout(()=>{n.current=void 0,r.current()},t)},flush(){n.current!==void 0&&(clearTimeout(n.current),n.current=void 0,r.current())}}}function Qa({section:e,save:t}){let[n,r]=q(e.yours),i=X(!1),a=X(null);J(()=>{i.current||r(e.yours)},[e.yours]),Y(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+2}px`)},[n]);let o=Za(()=>{i.current=!1,n.trim()!==e.yours.trim()&&t.section(e,n)},Xa),s=n.trim()!==e.current.trim();return Q(`div`,{class:`srow${s?` changed`:``}`,"data-section":e.heading,children:Q(`div`,{class:`sgrid bgrid`,children:[Q(`div`,{class:`blabel`,children:e.heading}),Q(`div`,{class:`cur`,children:e.current}),Q(`div`,{class:`byours`,children:[Q(`textarea`,{ref:a,class:`input`,"aria-label":`Your version of ${e.heading}`,value:n,onInput:e=>{i.current=!0,r(e.target.value),o.schedule()},onBlur:()=>o.flush()}),s&&Q(`button`,{class:`btn ghost ib`,"data-tip":`Revert to current`,"aria-label":`Revert ${e.heading}`,onClick:()=>{i.current=!1,r(e.current),t.section(e,e.current)},children:Q($,{name:`undo`})})]})]})})}var $a=(e,t)=>e.slice(0,t).filter(n=>n.heading===e[t].heading).length;function eo({brief:e,toast:t,onChanged:n,settle:r}){let{latest:i,enqueue:a}=Ya(`brief`,e,{toast:t,onChanged:n,settle:r}),o={section:(e,t)=>{let n=$a(i.current.sections,e.index);a(e.heading,r=>{let i=r.sections.filter(t=>t.heading===e.heading)[n];return i?{path:`/api/brief/sections/${i.index}`,body:{heading:e.heading,text:t}}:null})},status:e=>a(`the brief's status`,()=>({path:`/api/brief/status`,body:{status:e}}))},s=e.status===`approved`;return Q(`div`,{class:`col`,children:[Q(`div`,{class:`shead`,children:[Q(`h2`,{children:`Brief`}),Q(`span`,{class:`meta`,children:[e.sections.length,` section`,e.sections.length===1?``:`s`,` · `,e.changed,` changed`]})]}),Q(`div`,{class:`sgrid bgrid scols`,children:[Q(`span`,{}),Q(`span`,{children:`Current`}),Q(`span`,{children:`Yours`})]}),Q(`div`,{style:{display:`grid`,gap:`12px`},children:e.sections.map(t=>Q(Qa,{section:t,save:o},`${t.heading}#${$a(e.sections,t.index)}`))}),Q(`div`,{class:`bfoot`,children:Q(`button`,{class:`btn bapprove${s?` approved`:``}`,"aria-pressed":s,onClick:()=>o.status(s?`draft`:`approved`),children:[Q($,{name:`check`}),s?`Approved`:`Approve brief`]})})]})}var to=150;function no({chips:e,versionId:t,prompt:n,onSelect:r,toast:i}){let a=X(null),o=e.some(e=>e.reason===`single`),s=e.filter(e=>e.enabled),c=e.find(e=>e.selected)?.id??null;Y(()=>{let e=a.current,t=document.activeElement;if(!e||!c||!(t instanceof HTMLElement)||!e.contains(t))return;let n=e.querySelector(`[data-format="${c}"]`);n&&n!==t&&n.focus()},[c]);let[l,u]=q(!1),[d,f]=q(!1),[p,m]=q(!1),[h,g]=q(!1),_=X(void 0),v=X(!1),y=()=>{clearTimeout(_.current),u(!0),m(!1)},b=()=>{clearTimeout(_.current),_.current=window.setTimeout(()=>u(!1),to)};J(()=>()=>clearTimeout(_.current),[]);let x=o&&(l||d)&&!p&&!h;if(J(()=>{if(!x)return;let e=e=>{e.key===`Escape`&&m(!0)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[x]),e.length===0)return null;let S=e=>{if(e.altKey||e.metaKey||e.ctrlKey||s.length===0)return;let t=Math.max(0,s.findIndex(e=>e.selected)),n=null;e.key===`ArrowRight`||e.key===`ArrowDown`?n=(t+1)%s.length:e.key===`ArrowLeft`||e.key===`ArrowUp`?n=(t-1+s.length)%s.length:e.key===`Home`?n=0:e.key===`End`&&(n=s.length-1),n!==null&&(e.preventDefault(),e.stopPropagation(),r(s[n].id)!==!1&&a.current?.querySelector(`[data-format="${s[n].id}"]`)?.focus())},C=async()=>{try{await navigator.clipboard.writeText(n),i(`Prompt copied`)}catch{i(`Couldn't reach the clipboard. Ask your agent to register the other shapes with rushes_add_format.`)}};return Q(`div`,{class:`fmtwrap`,children:[Q(`div`,{ref:a,class:`fmts`,role:`radiogroup`,"aria-label":`Format`,style:{gridTemplateColumns:Yn(e.length)},onKeyDown:e=>S(e),children:e.map(e=>{let n=Jn(e.width,e.height),i=e.reason===`absent`?`Not in ${t}`:e.warn??void 0,a=e.reason===`single`;return Q(`button`,{type:`button`,role:`radio`,"data-format":e.id,"aria-checked":e.selected,"aria-disabled":e.enabled?void 0:`true`,tabIndex:e.enabled&&e.selected?0:-1,"aria-label":qn(e,t),class:i?`tip-below`:void 0,"data-tip":i,onMouseEnter:a?y:()=>g(!0),onMouseLeave:a?b:()=>g(!1),onClick:t=>{e.enabled&&(t.detail>0&&t.currentTarget.blur(),r(e.id))},children:[Q(`span`,{class:`shape`,"aria-hidden":`true`,style:{width:`${n.width}px`,height:`${n.height}px`}}),Q(`span`,{class:`lbl`,"data-label":e.label,children:e.label}),e.warn&&Q(`span`,{class:`warn`,"aria-hidden":`true`,children:`!`}),!o&&Q(`span`,{class:`n${e.count>0?``:` none`}`,"aria-hidden":`true`,children:e.count>0?e.count:``})]},e.id)})}),o&&Q(`div`,{class:`fmtpop${x?` open`:``}`,onMouseEnter:y,onMouseLeave:b,children:[Q(`p`,{children:[`One format. Your agent can add more with `,Q(`code`,{children:`rushes_add_format`}),`.`]}),Q(`button`,{type:`button`,class:`btn ghost`,onPointerDown:()=>{v.current=!0},onFocus:()=>{v.current||f(!0),v.current=!1},onBlur:()=>{f(!1),m(!1)},onClick:e=>{v.current=!1,e.detail>0&&e.currentTarget.blur(),C()},children:[Q($,{name:`copy`}),`Copy a prompt for your agent`]})]})]})}var ro=.03,io=.004,ao=15e3;function oo(e){return e.buffer?e.buffer.length*e.buffer.numberOfChannels*4:0}var so=0;function co(){return so}var lo=new Map;function uo(e){let t=lo.get(e);return t&&(lo.delete(e),lo.set(e,t)),t}function fo(e,t){for(lo.delete(e),lo.set(e,t);lo.size>200;)lo.delete(lo.keys().next().value)}function po(){let e=Error(`The load was cancelled`);return e.name=`AbortError`,e}function mo(e){return(t,n)=>new Promise(r=>{let i=e(t),a,o=!1,s=e=>{o||(o=!0,clearTimeout(a),n.removeEventListener(`abort`,c),i.removeAttribute(`src`),i.load(),r(e))},c=()=>s(null);if(n.aborted)return s(null);n.addEventListener(`abort`,c),i.preload=`metadata`,i.addEventListener(`loadedmetadata`,()=>s(Number.isFinite(i.duration)?i.duration:null),{once:!0}),i.addEventListener(`error`,()=>s(null),{once:!0}),a=setTimeout(()=>s(null),ao)})}var ho=class{ctx=null;disposed=!1;opts;clips=[];videoDuration=null;media=new Map;loads=new Map;idle=new Map;holding=new Map;selection={};laneTargets={};laneNodes=new Map;clipNodes=new Map;voices=new Map;serials=new WeakMap;serial=0;_playing=!1;startOffset=0;startedAt=0;frame=null;tickListeners=new Set;endedListeners=new Set;changeListeners=new Set;constructor(e,t={}){let n=t.createMedia??(e=>new Audio(e));this.opts={createContext:t.createContext??(()=>new AudioContext),url:t.url??Nr,fetch:t.fetch??((e,t)=>fetch(e,t)),probe:t.probe??mo(n),createMedia:n,raf:t.raf??(e=>requestAnimationFrame(e)),caf:t.caf??(e=>cancelAnimationFrame(e))},e&&(this.ctx=e,so++)}get playing(){return this._playing}get time(){if(!this._playing||!this.ctx)return this.startOffset;let e=this.startOffset+Math.max(0,this.ctx.currentTime-this.startedAt),t=this.length;return t>0?Math.min(e,t):e}get length(){return di(this.videoDuration,this.resolved())}inspect(){return{playing:this._playing,time:this.time,length:this.length,sources:this.voices.size,gains:$r(this.clips,this.selection),lanes:{...this.laneTargets},media:[...this.media.keys()],streamed:[...this.media].filter(([,e])=>e.streamed).map(([e])=>e),idle:[...this.idle.keys()],voices:Object.fromEntries([...this.voices].map(([e,t])=>[e,this.serials.get(t)??0]))}}onTick(e){return this.tickListeners.add(e),()=>this.tickListeners.delete(e)}onEnded(e){return this.endedListeners.add(e),()=>this.endedListeners.delete(e)}onChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}subscribe(e){let t=this.onTick(e),n=this.onChange(()=>e(this.time));return()=>{t(),n()}}load(e,t){if(this.disposed)return Promise.reject(Error(`The audio engine was disposed`));let n=Kr({path:e,rev:t}),r=this.loads.get(n)??this.idle.get(n)?.load;if(r)return r.promise;let i=new AbortController,a=this.loadOnce(e,n,i.signal),o={path:e,promise:a,abort:i};return this.loads.set(n,o),a.catch(()=>{this.loads.get(n)===o&&this.loads.delete(n);for(let e of this.clips)Kr(e)===n&&this.holding.delete(e.id)}),a}async loadOnce(e,t,n){let r=this.ensureContext(),i=this.opts.url(e),a=new AbortController,o=()=>a.abort();n.addEventListener(`abort`,o);let s=!1,c=()=>{s=!0,a.abort()},l=this.opts.probe(i,n).then(e=>(ai(e,!0)&&c(),e),()=>null),u=null;try{let e=await this.opts.fetch(i,{signal:a.signal});if(!e.ok)throw Error(`HTTP ${e.status}`);let t=e.headers?.get(`content-length`)??null;if(ci(t!==null&&Number.isFinite(Number(t))?Number(t):null)&&c(),!s){let t=await e.arrayBuffer();!s&&!n.aborted&&(u=await r.decodeAudioData(t))}}catch{u=null}finally{n.removeEventListener(`abort`,o)}if(n.aborted||this.disposed)throw po();let d;if(u&&!ai(u.duration,!0)){let e=uo(t);if(!e){let n=[];for(let e=0;e<u.numberOfChannels;e++)n.push(u.getChannelData(e));e=ri(n,ii(u.duration)),fo(t,e)}this.media.set(t,{duration:u.duration,buffer:u,streamed:!1}),d={duration:u.duration,peaks:e,streamed:!1}}else{let r=u?u.duration:await l;if(n.aborted||this.disposed)throw po();if(r===null||!(r>0))throw Error(`Couldn't load ${e}`);this.media.set(t,{duration:r,buffer:null,streamed:!0}),d={duration:r,peaks:new Float32Array,streamed:!0}}return this.afterLoad(t),d}afterLoad(e){for(let t of this.clips)Kr(t)===e&&this.holding.delete(t.id);if(this._playing){for(let t of this.resolved())Kr(t)===e&&!this.voices.has(t.id)&&this.startLate(t);this.syncStreams(this.rawClock())}this.emitChange()}setClips(e){let t=new Map(e.map(e=>[e.id,e])),n=this.resolved(),r=new Map(this.clips.map(e=>[e.id,e]));for(let e of this.clips){let n=t.get(e.id);n&&n.lane===e.lane&&n.path===e.path&&n.rev===e.rev&&n.offset===e.offset&&n.duration===e.duration||this.dropClip(e.id)}for(let e of n){let n=t.get(e.id),i=r.get(e.id);n&&n.path===i.path&&n.rev!==i.rev&&e.duration>0&&this.holding.set(e.id,e.duration)}for(let e of[...this.holding.keys()])t.has(e)||this.holding.delete(e);let i=new Set(e.map(Kr)),a=new Set(e.map(e=>e.path));for(let[e,t]of this.loads){if(i.has(e))continue;let n=this.media.get(e);!n||a.has(t.path)?t.abort.abort():this.idle.set(e,{media:n,load:t}),this.loads.delete(e),this.media.delete(e)}for(let e of[...this.media.keys()])i.has(e)||this.media.delete(e);for(let[e,t]of this.idle)!i.has(e)&&a.has(t.load.path)&&this.idle.delete(e);for(let e of i){let t=this.idle.get(e);t&&(this.idle.delete(e),this.media.set(e,t.media),this.loads.set(e,t.load))}let o=0;for(let e of this.idle.values())o+=oo(e.media);for(;this.idle.size>12||o>268435456;){let[e,t]=this.idle.entries().next().value;o-=oo(t.media),this.idle.delete(e)}if(this.clips=e.slice(),this._playing){for(let e of this.resolved())this.voices.has(e.id)||this.startLate(e);this.syncStreams(this.rawClock())}this.emitChange()}setVideoDuration(e){this.videoDuration=e,this._playing||(this.startOffset=this.clampTime(this.startOffset)),this.emitChange()}setLaneGain(e,t){this.laneTargets[e]=t;let n=this.laneNodes.get(e);n&&this.ramp(n.gain,t)}selectVariant(e,t){t===null?delete this.selection[e]:this.selection[e]=t;let n=$r(this.clips,this.selection);for(let t of this.clips){if(t.lane!==e)continue;let r=this.clipNodes.get(t.id);r&&this.ramp(r.gain.gain,n[t.id])}}play(e=this.time){if(this.disposed)return;let t=this.ensureContext(),n=this.length;if(n<=0)return;let r=this.clampTime(e);r>=n&&(r=0),t.state===`suspended`&&t.resume().catch(()=>{}),pi(this,()=>this.pause()),this._playing=!0,this.restart(r),this.startLoop(),this.emitChange()}pause(){this._playing&&(this.startOffset=this.time,this._playing=!1,this.stopVoices(),this.pauseStreams(),this.stopLoop(),mi(this),this.emitChange())}seek(e){if(this.disposed)return;let t=this.clampTime(e);this._playing?this.restart(t):this.startOffset=t,this.emitChange()}dispose(){if(!this.disposed){this._playing=!1,this.stopLoop(),this.stopVoices();for(let e of this.loads.values())e.abort.abort();this.loads.clear(),this.idle.clear(),this.holding.clear();for(let e of[...this.clipNodes.keys()])this.dropClip(e);for(let e of this.laneNodes.values())e.disconnect();this.laneNodes.clear(),this.media.clear(),mi(this),this.tickListeners.clear(),this.endedListeners.clear(),this.changeListeners.clear(),this.disposed=!0,this.ctx&&(this.ctx.close().catch(()=>{}),this.ctx=null,so--)}}ensureContext(){if(this.disposed)throw Error(`The audio engine was disposed`);return this.ctx||(this.ctx=this.opts.createContext(),so++),this.ctx}resolved(){let e={};for(let[t,n]of this.media)e[t]=n.duration;let t=ui(this.clips,e);return this.holding.size===0?t:t.map(e=>e.duration>0?e:{...e,duration:this.holding.get(e.id)??0})}clampTime(e){let t=this.length,n=Math.max(0,Number.isFinite(e)?e:0);return t>0?Math.min(n,t):n}rawClock(){return!this._playing||!this.ctx?this.startOffset:this.startOffset+(this.ctx.currentTime-this.startedAt)}restart(e){let t=this.ctx;this.stopVoices(),this.startOffset=e,this.startedAt=t.currentTime+ro;let n=this.resolved(),r=new Map(n.map(e=>[e.id,e]));for(let t of ei(n,e))this.startVoice(r.get(t.id),this.startedAt+t.when,t.offset);this.syncStreams(this.rawClock(),!0)}startLate(e){let t=this.ctx;if(!t)return;let n=Math.max(this.startedAt,t.currentTime+ro),r=this.startOffset+(n-this.startedAt);for(let t of ei([e],r))this.startVoice(e,n+t.when,t.offset)}startVoice(e,t,n){let r=this.media.get(Kr(e));if(!this.ctx||!r||r.streamed||!r.buffer)return;let i=this.ctx.createBufferSource();i.buffer=r.buffer,i.connect(this.nodesFor(e).gain),i.onended=()=>{this.voices.get(e.id)===i&&(this.voices.delete(e.id),i.disconnect())},i.start(t,n,e.duration-n),this.voices.set(e.id,i),this.serials.set(i,++this.serial)}stopSource(e){e.onended=null;try{e.stop()}catch{}e.disconnect()}stopVoices(){for(let e of this.voices.values())this.stopSource(e);this.voices.clear()}syncStreams(e,t=!1){let n=this.ctx?.currentTime??0;for(let r of this.resolved()){if(!this.media.get(Kr(r))?.streamed)continue;let i=this.clipNodes.get(r.id),a=i?.el,o=e-r.offset,s=a?{time:a.currentTime,paused:a.paused,seeking:a.seeking,readyState:a.readyState}:{time:0,paused:!0},c=li(o,r.duration,s,i?n-i.seekedAt:1/0);if(t&&o>=0&&o<r.duration&&(c=s.paused?`play`:`seek`),c===`none`)continue;let l=i??this.nodesFor(r),u=l.el;if(c===`pause`){u.pause();continue}u.currentTime=o,l.seekedAt=n,c===`play`&&u.play().catch(()=>{})}}pauseStreams(){for(let e of this.clipNodes.values())e.el?.pause()}laneNode(e){let t=this.laneNodes.get(e);return t||(t=this.ctx.createGain(),t.gain.value=this.laneTargets[e]??1,t.connect(this.ctx.destination),this.laneNodes.set(e,t)),t}nodesFor(e){let t=this.clipNodes.get(e.id);if(!t){let n=this.ctx,r=n.createGain();if(r.gain.value=$r([e],this.selection)[e.id],r.connect(this.laneNode(e.lane)),t={gain:r,seekedAt:-1/0},this.media.get(Kr(e))?.streamed){let i=this.opts.createMedia(this.opts.url(e.path));i.preload=`auto`,t.el=i,t.elSource=n.createMediaElementSource(i),t.elSource.connect(r)}this.clipNodes.set(e.id,t)}return t}dropClip(e){let t=this.voices.get(e);t&&(this.stopSource(t),this.voices.delete(e));let n=this.clipNodes.get(e);n&&(n.elSource?.disconnect(),n.el&&(n.el.pause(),n.el.removeAttribute(`src`),n.el.load()),n.gain.disconnect(),this.clipNodes.delete(e))}ramp(e,t){let n=this.ctx.currentTime,r=e;typeof r.cancelAndHoldAtTime==`function`?r.cancelAndHoldAtTime(n):(e.cancelScheduledValues(n),e.setValueAtTime(e.value,n)),e.linearRampToValueAtTime(t,n+io)}startLoop(){this.frame===null&&(this.frame=this.opts.raf(this.tick))}stopLoop(){this.frame!==null&&this.opts.caf(this.frame),this.frame=null}tick=()=>{if(this.frame=null,!this._playing)return;let e=this.length;if(e<=0){if(this.clips.some(e=>this.loads.has(Kr(e))&&!this.media.has(Kr(e)))){this.frame=this.opts.raf(this.tick);return}this.pause();return}let t=this.time;this.syncStreams(this.rawClock());for(let e of this.tickListeners)go(()=>e(t));if(t>=e){this.pause();for(let e of this.endedListeners)go(e);return}this._playing&&this.frame===null&&(this.frame=this.opts.raf(this.tick))};emitChange(){for(let e of this.changeListeners)go(e)}};function go(e){try{e()}catch(e){console.error(e)}}var _o=new class{el=null;current={path:null,playing:!1};by=null;failed=!1;listeners=new Set;make;url;constructor(e,t){this.make=e,this.url=t}state(){return this.current}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}async toggle(e,t){if(this.current.playing&&this.current.path===e)return this.stop();let n=this.element();n.pause(),(this.current.path!==e||this.failed)&&(n.src=this.url(e)),this.failed=!1,this.by=t??null,n.currentTime=0,pi(this,()=>this.stop()),this.set({path:e,playing:!0});try{await n.play()}catch(t){if(this.current.path===e&&this.current.playing)throw mi(this),this.failed=!0,this.set({path:e,playing:!1}),t}}stopIf(e){this.current.playing&&this.by===e&&this.stop()}stop(){this.el?.pause(),mi(this),this.current.playing&&this.set({...this.current,playing:!1})}element(){if(!this.el){let e=this.make();e.addEventListener(`ended`,()=>{mi(this),this.set({...this.current,playing:!1})}),this.el=e}return this.el}set(e){this.current=e;for(let t of this.listeners)t(e)}}(()=>new Audio,Nr),vo=e=>e.map(e=>[e.id,e.lane,e.path,e.rev??``,e.offset,e.duration].join(`\0`)).join(``);function yo(e,t=null){let n=X(null);n.current||=new ho;let r=n.current,i=X(!0),[a,o]=q(!1),[s,c]=q(0),[l,u]=q({});return J(()=>{i.current=!0;let e=r.onChange(()=>{o(r.playing),c(r.length)});return()=>{i.current=!1,e(),r.dispose(),n.current===r&&(n.current=null)}},[r]),J(()=>{r.setClips(e);let t=new Map(e.map(e=>[Kr(e),e]));u(e=>{let n=Object.fromEntries(Object.entries(e).filter(([e])=>t.has(e)));return Object.keys(n).length===Object.keys(e).length?e:n});for(let[e,n]of t)r.load(n.path,n.rev).then(t=>i.current&&u(n=>n[e]===t?n:{...n,[e]:t}),t=>{i.current&&t.name!==`AbortError`&&u(t=>({...t,[e]:`error`}))})},[r,vo(e)]),J(()=>{r.setVideoDuration(t)},[r,t]),{engine:r,playing:a,length:s,media:l}}function bo(e){return e.map((e,t)=>({c:e,i:t})).sort((e,t)=>e.c.t-t.c.t||e.i-t.i).map(e=>e.c)}function xo(e){return e.name.trim()||`Untitled cue`}function So(e){return`${xo(e)} at ${G(e.t)}`}function Co(e,t){return`cue ${e} of ${t}`}function wo(e){let t=new Map;for(let n of bo(e)){let e=xo(n),r=t.get(e);r||(r={name:e,cues:[],file:null,moreFiles:0},t.set(e,r)),r.cues.push(n)}for(let e of t.values()){let t=[...new Set(e.cues.flatMap(e=>e.file?[e.file]:[]))];e.file=t[0]??null,e.moreFiles=Math.max(0,t.length-1)}return[...t.values()]}function To(e,t,n){return n<=0?null:e===`ArrowLeft`?Math.max(0,t-1):e===`ArrowRight`?Math.min(n-1,t+1):e===`Home`?0:e===`End`?n-1:null}function Eo(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function Do(e,t){return`${((t>0?Math.min(1,Math.max(0,e/t)):0)*100).toFixed(3)}%`}function Oo(e,t){return`clamp(5px, ${Do(e,t)}, calc(100% - 5px))`}function ko(e){let t=new Map;return e.map(e=>{let n=(t.get(e.id)??0)+1;return t.set(e.id,n),n===1?e.id:`${e.id}#${n}`})}function Ao(e,t,n){let r=e.left+e.width/2-t.width/2,i=Math.max(16,Math.min(r,n.width-16-t.width)),a=e.top+e.height+8,o=a+t.height<=n.height-16?a:Math.max(16,e.top-8-t.height);return{left:Math.round(i),top:Math.round(o)}}var jo=`cue-card`;function Mo(){let[e,t]=q(null);return{shown:e,api:{shown:e?.cue.key??null,show:(e,n)=>t(t=>t&&t.anchor===e&&t.cue.key===n.key?t:{anchor:e,cue:n}),hide:()=>t(null)}}}function No(e,t){return{onPointerEnter:n=>e.show(n.currentTarget,t),onPointerLeave:()=>e.hide()}}function Po({shown:e,onHide:t}){let n=X(null),[r,i]=q(null);if(Y(()=>{if(i(null),!e)return;let t=()=>{let t=n.current;if(!t)return;let r=e.anchor.getBoundingClientRect(),a=Ao({left:r.left,top:r.top,width:r.width,height:r.height},{width:t.offsetWidth,height:t.offsetHeight},{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight});i(e=>e&&e.left===a.left&&e.top===a.top?e:a)};return t(),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[e]),Y(()=>{e&&!e.anchor.isConnected&&t()}),!e)return null;let a=e.cue;return Q(`div`,{ref:n,id:jo,class:`cuecard`,role:`tooltip`,style:r?{left:`${r.left}px`,top:`${r.top}px`}:{left:`0px`,top:`0px`,visibility:`hidden`},children:[Q(`b`,{children:a.name}),Q(`span`,{class:`m`,children:[G(a.t),` · `,Co(a.n,a.of)]}),a.file!==null&&Q(`span`,{class:`f`,style:{color:a.color},children:a.file})]})}function Fo(e,t,n){if(e.key===`Escape`){n.shown!==null&&(e.preventDefault(),e.stopPropagation(),n.hide());return}if(e.metaKey||e.ctrlKey||e.altKey)return;let r=e.currentTarget,i=[...r.parentElement?.querySelectorAll(`:scope > ${t}`)??[]],a=To(e.key,i.indexOf(r),i.length);a!==null&&(e.preventDefault(),e.stopPropagation(),i[a].focus())}function Io(){let[e,t]=q(_o.state());return J(()=>_o.subscribe(t),[]),e}function Lo({id:e,name:t,cues:n,length:r,color:i,card:a,onSeek:o,toast:s}){let c=bo(n),l=new Map(c.map((e,t)=>[e,t+1])),u=wo(n),[d,f]=q({}),p=Io();J(()=>()=>_o.stopIf(e),[e]);let m=async t=>{try{await _o.toggle(t,e)}catch{s(`Couldn't play ${Eo(t)}`)}};return Q(`div`,{class:`clayers`,id:e,role:`group`,"aria-label":`Layers for ${t}`,style:`--lane: ${i}`,children:u.map(t=>{let n=Math.min(d[t.name]??0,t.cues.length-1),s=t.file,u=s!==null&&p.playing&&p.path===s;return Q(`div`,{class:`clayer`,"data-layer":t.name,children:[Q(`div`,{class:`clname`,children:[Q(`span`,{children:t.name}),Q(`em`,{children:[`×`,t.cues.length]})]}),Q(`div`,{class:`cltrack`,children:[t.cues.map((s,u)=>{let d={key:`l:${e}:${s.id}`,name:t.name,t:s.t,n:l.get(s)??u+1,of:c.length,file:s.file??null,color:i},p=a.shown===d.key;return Q(`button`,{type:`button`,class:`ltick${p?` hot`:``}`,tabIndex:u===n?0:-1,style:{left:Oo(s.t,r)},"aria-label":So(s),"aria-describedby":p?jo:void 0,...No(a,d),onFocus:e=>{f(e=>e[t.name]===u?e:{...e,[t.name]:u}),a.show(e.currentTarget,d)},onBlur:()=>a.hide(),onKeyDown:e=>Fo(e,`button.ltick`,a),onClick:()=>o(s.t,s.id)},s.id)}),Q(`div`,{class:`playhead`})]}),Q(`div`,{class:`clfile`,children:[s!==null&&Q(`button`,{type:`button`,"aria-pressed":u,"aria-label":`Play ${s}`,onClick:()=>void m(s),children:[Q($,{name:u?`pause`:`play`}),Q(`span`,{children:Eo(s)})]}),t.moreFiles>0&&Q(`small`,{children:[`+`,t.moreFiles]})]})]},t.name)})})}var Ro=0;function zo(){return Ro}var Bo=3,Vo=2;function Ho({segments:e,length:t,color:n}){let r=X(null),[i,a]=q({w:0,h:0,dpr:1});J(()=>{let e=r.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect(),n=window.devicePixelRatio||1;a(e=>e.w===t.width&&e.h===t.height&&e.dpr===n?e:{w:t.width,h:t.height,dpr:n})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let o=[i,t,n];for(let t of e)o.push(t.offset,t.duration,t.peaks);return J(()=>{let a=r.current;if(!a||i.w<=0||i.h<=0)return;Ro++,a.width=Math.round(i.w*i.dpr),a.height=Math.round(i.h*i.dpr);let o=a.getContext(`2d`);if(!o||(o.setTransform(i.dpr,0,0,i.dpr,0,0),o.clearRect(0,0,i.w,i.h),!(t>0)))return;o.fillStyle=n;let s=Math.floor(i.w/Bo),c=t*Bo/i.w;for(let t=0;t<s;t++){let n=t*c,r=n+c,a=-1;for(let t of e){if(!(t.duration>0)||r<=t.offset||n>=t.offset+t.duration)continue;if(!t.peaks||t.peaks.length===0){a=Math.max(a,.04);continue}let e=t.peaks.length,i=Math.max(0,Math.floor((n-t.offset)/t.duration*e)),o=Math.min(e,Math.max(i+1,Math.ceil((r-t.offset)/t.duration*e)));for(let e=i;e<o;e++)a=Math.max(a,t.peaks[e])}if(a<0)continue;let s=Math.max(1.5,Math.min(1,a)*i.h*.92);o.globalAlpha=.9,o.fillRect(t*Bo,(i.h-s)/2,Vo,s)}},o),Q(`canvas`,{ref:r,class:`wave`,"aria-hidden":`true`})}function Uo(e){let t={},n=e=>e!==null&&e.scrollWidth>e.clientWidth;for(let r of e.querySelectorAll(`.lane[data-row]`)){let e=(n(r.querySelector(`[data-name]`))?`n`:``)+(n(r.querySelector(`[data-meta-text]`))?`m`:``);e&&(t[r.dataset.row]=e)}for(let r of e.querySelectorAll(`.rhead[data-heading]`))n(r.querySelector(`.rname`))&&(t[`h:${r.dataset.heading}`]=`h`);for(let r of e.querySelectorAll(`.fold[data-row]`))n(r.querySelector(`.flabel`))&&(t[`f:${r.dataset.row}`]=`f`);return t}var Wo=(e,t)=>{let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])};function Go({rows:e,length:t,media:n,selected:r,marks:i,range:a,onSelect:o,onSeek:s,toast:c}){let l=e=>`${t>0?e/t*100:0}%`,u=X(null),[d,f]=q({}),p=()=>{if(u.current){let e=Uo(u.current);f(t=>Wo(t,e)?t:e)}},m=e.map(e=>{let t=e.clips.map(e=>n[Kr(e)]);return(t.some(e=>e!==void 0&&e!==`error`&&e.streamed)?`s`:``)+(t.some(e=>e===`error`)?`b`:``)});Y(p,[JSON.stringify(e.map((e,t)=>[e.key,e.name,e.meta??``,e.heading??``,e.fold?e.fold.text:null,e.missing??!1,m[t],+!!e.layers]))]),J(()=>(window.addEventListener(`resize`,p),document.fonts?.ready.then(p),()=>window.removeEventListener(`resize`,p)),[]);let{shown:h,api:g}=Mo(),[_,v]=q({});return Q(`div`,{class:`lanes`,ref:u,children:[e.map(e=>{let u=e.heading!==void 0&&Q(`div`,{class:`rhead`,"data-heading":e.key,"data-tip":d[`h:${e.key}`]?e.heading:void 0,children:[Q(`span`,{class:`rname`,children:e.heading}),e.tag&&Q(`span`,{class:`rtag`,children:e.tag})]});if(e.fold){let t=e.fold;return Q(S,{children:[u,Q(`button`,{type:`button`,class:`fold`,"data-row":e.key,"data-tip":d[`f:${e.key}`]?t.text:void 0,"aria-expanded":t.open,"aria-description":t.dot?`Open notes`:void 0,onClick:t.onToggle,children:[Q($,{name:`chev`}),Q(`span`,{class:`flabel`,children:t.label}),t.dot&&Q(`span`,{class:`fdot`,"data-dot":!0,"data-tip":`Open notes`})]})]},e.key)}let f=e.key===r,p=d[e.key]??``,m=bo(e.cues??[]),h=ko(m),y=wt(m,t),b=Math.min(_[e.key]??0,Math.max(0,m.length-1)),x=(t,n)=>({key:`m:${e.key}:${h[n]}`,name:xo(t),t:t.t,n:n+1,of:m.length,file:t.file??null,color:e.color}),C=e.clips.map(e=>n[Kr(e)]),w=C.some(e=>e!==void 0&&e!==`error`&&e.streamed),T=C.some(e=>e===`error`),E=e.clips.map((e,t)=>{let n=C[t],r=n!==void 0&&n!==`error`?n:null;return{offset:e.offset,duration:e.duration>0?e.duration:r?.duration??0,peaks:r?r.peaks:null}}),D=i[e.key]??[],O=Q(`button`,{type:`button`,class:`nm`,"data-player":!0,"aria-current":f?`true`:`false`,"aria-label":e.name,"aria-description":e.missing?typeof e.missing==`string`?e.missing:`Missing`:void 0,onClick:()=>o(e),children:[Q(`b`,{"data-tip":p.includes(`n`)?e.name:void 0,children:[Q(`i`,{style:{background:e.color}}),Q(`span`,{"data-name":!0,children:e.name}),e.missing&&Q(ga,{tip:typeof e.missing==`string`?e.missing:void 0})]}),Q(`small`,{"data-meta":!0,"data-tip":p.includes(`m`)&&e.meta?e.meta:void 0,children:[T?Q(`span`,{class:`smk bad`,"data-tip":`This file won't play in a browser`,children:Q($,{name:`alert`})}):w?Q(`span`,{class:`smk`,"data-tip":`Long file: switching isn't sample-exact`,children:Q($,{name:`stream`})}):null,Q(`span`,{"data-meta-text":!0,children:e.meta??``})]})]});return Q(S,{children:[u,Q(`div`,{class:`lane`,"data-row":e.key,"aria-current":f?`true`:void 0,children:[e.layers?Q(`div`,{class:`nmc`,children:[Q(`button`,{type:`button`,class:`chev tip-start`,"aria-expanded":e.layers.open,"aria-controls":e.layers.open&&m.length>0?`cl-${e.key}`:void 0,"aria-label":`Layers for ${e.name}`,"aria-description":m.length===0?`No cues in this pass`:void 0,"data-tip":m.length===0?`No cues in this pass`:e.layers.open?`Hide the layers`:`Show the layers`,disabled:m.length===0,onClick:e.layers.onToggle,children:Q($,{name:`chev`})}),O]}):O,Q(`div`,{class:`track`,onClick:n=>{let r=n.currentTarget.getBoundingClientRect();s((n.clientX-r.left)/r.width*t,e)},children:[Q(Ho,{segments:E,length:t,color:e.color}),m.map((t,n)=>Q(`i`,{class:`cue-tick${g.shown===`m:${e.key}:${h[n]}`?` hot`:``}`,"aria-hidden":`true`,style:{left:l(t.t),color:e.color},...No(g,x(t,n)),onClick:n=>{n.stopPropagation(),s(t.t,e,t.id)}},`t${h[n]}:${t.t}:${t.name}`)),m.map((t,n)=>{let r=x(t,n),i=g.shown===r.key;return Q(`button`,{type:`button`,class:`cue${i?` hot`:``}`,"data-cue":t.id,tabIndex:n===b?0:-1,"aria-label":So(t),"aria-describedby":i?jo:void 0,style:{left:l(t.t),color:e.color,maxWidth:`calc(${(y[n]*100).toFixed(3)}% - 8px)`},...No(g,r),onFocus:t=>{v(t=>t[e.key]===n?t:{...t,[e.key]:n}),g.show(t.currentTarget,r)},onBlur:()=>g.hide(),onKeyDown:e=>Fo(e,`button.cue`,g),onClick:n=>{n.stopPropagation(),s(t.t,e,t.id)},children:Q(`span`,{children:xo(t)})},`c${h[n]}:${t.t}:${t.name}`)}),D.map(e=>e.tOut!==null&&Q(`div`,{class:`span ${e.status}`,"data-note":e.id,style:{left:l(e.t),width:l(e.tOut-e.t)}})),D.map(e=>Q(`div`,{class:`mk ${e.status}`,"data-note":e.id,style:{left:l(e.t)},title:e.text})),a.in!==null&&Q(`div`,{class:`span live`,style:{left:l(a.in),width:l((a.out??a.in+Math.max(.2,t/200))-a.in)}}),Q(`div`,{class:`playhead`})]}),Q(`div`,{class:`ctl`,children:[e.use&&Q(`button`,{type:`button`,class:`use`,"aria-pressed":e.use.inUse,"aria-label":`Use ${e.name}`,onClick:t=>{t.stopPropagation(),e.use.onUse()},children:e.use.inUse?Q(S,{children:[Q($,{name:`check`}),`In use`]}):`Use`}),e.use?.inUse&&e.use.onUnpick&&Q(`button`,{type:`button`,class:`btn ghost ib sm unpick`,"data-tip":`Unpick`,"aria-label":`Unpick ${e.name}`,onClick:t=>{t.stopPropagation(),e.use.onUnpick()},children:Q($,{name:`x`})}),e.controls]})]}),e.layers?.open&&m.length>0&&Q(Lo,{id:`cl-${e.key}`,name:e.name,cues:m,length:t,color:e.color,card:g,onSeek:(t,n)=>s(t,e,n),toast:c??(()=>void 0)})]},e.key)}),Q(Po,{shown:h,onHide:g.hide})]})}var Ko=[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`];function qo({label:e,width:t,height:n,value:r,onChange:i,lockedReason:a,name:o}){let s=Jn(t,n),c=xr();return Q(`div`,{class:`fscope`,role:`radiogroup`,"aria-label":o,onKeyDown:e=>{if(e.altKey||e.metaKey||e.ctrlKey||!Ko.includes(e.key))return;e.preventDefault(),e.stopPropagation();let t=e.key===`Home`||e.key===`ArrowLeft`||e.key===`ArrowUp`?`this`:`all`;t===`all`&&a||(t!==r&&i(t),e.currentTarget.querySelector(`[data-scope="${t}"]`)?.focus())},children:[[{v:`this`,text:`This format`,disabled:!1},{v:`all`,text:`All formats`,disabled:a!==null}].map(t=>Q(`button`,{type:`button`,role:`radio`,"data-scope":t.v,"aria-checked":r===t.v,"aria-disabled":t.disabled?`true`:void 0,"aria-describedby":t.disabled?c:void 0,tabIndex:r===t.v?0:-1,"aria-label":t.v===`this`?`This format, ${e}`:`All formats`,class:t.disabled?`tip-wrap tip-below tip-end`:void 0,"data-tip":t.disabled?a:void 0,onClick:()=>{!t.disabled&&t.v!==r&&i(t.v)},children:[t.v===`this`&&Q(`span`,{class:`shape`,"aria-hidden":`true`,style:{width:`${s.width}px`,height:`${s.height}px`}}),t.text]},t.v)),a&&Q(`span`,{id:c,hidden:!0,children:a})]})}var Jo=[{kind:`rise`,label:`Rise`},{kind:`fall`,label:`Fall`},{kind:`louder`,label:`Louder`},{kind:`quieter`,label:`Quieter`}],Yo=e=>e.options.find(t=>t.value===e.value)?.full;function Xo({notes:e,version:t,placeholder:n,attachments:r,inputRef:i,toast:a,onAdd:o,onSeek:s,onChanged:c,onTextChange:l,on:u,scope:d,chips:f,marks:p,onLabel:m,fixedTimes:h,selectedId:g,formatTag:_,cardExtra:v,formatScope:y,listFooter:b}){let[x,S]=q(`all`),C=X(null),w=i??C,[T,E]=q(``),[D,O]=q(!1),k=e.filter(e=>e.status===`todo`).length,A=b?.(x)??null,j=e.map(e=>({n:e,at:h?{t:e.t,tOut:e.tOut,from:null}:_e(e,t)})).filter(({n:e})=>x===`all`||e.status===x).sort((e,t)=>(e.at.t??-1)-(t.at.t??-1)),M=async e=>{try{await Z.patch(`/api/notes/${e.id}`,{status:e.status===`done`?`todo`:`done`})}catch(e){a(`Couldn't update that note: ${e.message}`)}c()},N=async()=>{let e=T.trim();if(e&&!D){O(!0);try{await o(e),E(``),l?.(!1)}catch(e){a(`Couldn't add the note: ${e.message}`)}finally{O(!1)}}},P=e=>{E(e),l?.(!0);let t=w.current;t&&(t.value=e,t.focus(),t.setSelectionRange(e.length,e.length))};return Q(`aside`,{class:`panel side`,"aria-label":`Notes`,children:[Q(`div`,{class:`ph`,children:[Q(`h3`,{children:`Notes`}),Q(`span`,{class:`sp`}),Q(`div`,{class:`seg`,role:`group`,"aria-label":`Filter notes`,children:[`all`,`todo`,`done`].map(e=>Q(`button`,{"aria-pressed":x===e,onClick:()=>S(e),children:[e===`all`?`All`:e===`todo`?`To do`:`Done`,e===`todo`&&k>0&&Q(`span`,{class:`n`,children:k})]}))})]}),Q(`div`,{class:`list`,children:[j.length===0&&Q(`div`,{class:`none`,children:x===`all`?A?`None on this format.`:`No notes yet.`:`Nothing here.`}),j.map(({n:e,at:t})=>Q(`div`,{class:`note${e.status===`done`?` done`:``}`,"data-note":e.id,"aria-current":g===e.id?`true`:void 0,children:[Q(`button`,{class:`chk`,"aria-label":e.status===`done`?`Reopen`:`Mark done`,title:e.status===`done`?`Reopen`:`Mark done`,onClick:()=>void M(e),children:Q($,{name:`check`})}),Q(`div`,{class:`nt`,children:[Q(`button`,{class:`t`,onClick:()=>t.t!==null&&s?.(t.t,e),children:ve(t.t,t.tOut)}),m&&m(e)&&Q(`span`,{class:`on`,children:m(e)}),(()=>{let t=_?.(e)??null;return t&&Q(`span`,{class:`ftag${t===`All`?` all`:``}`,children:t})})(),t.from&&Q(`span`,{class:`from`,children:[`from `,t.from]})]}),gt(e.marks)&&Q(`div`,{class:`nmarks`,children:gt(e.marks)}),e.shot&&Q(`div`,{class:`shotref`,children:[`Shot `,We(e.shot.n),` · `,e.shot.name]}),Q(`div`,{class:`nx`,children:e.text}),e.grab&&Q(`div`,{class:`att`,children:Q(`img`,{class:`thumb`,src:Nr(e.grab),alt:`Frame grab`})}),e.reply&&Q(`div`,{class:`rp`,children:[Q($,{name:`reply`}),Q(`span`,{children:e.reply})]}),g===e.id&&v&&Q(`div`,{class:`nfmt`,children:v(e)})]},e.id)),A]}),Q(`div`,{class:`comp`,children:[(u||d)&&Q(`div`,{class:`row`,children:[u&&Q(`span`,{class:`onwrap`,"data-tip":Yo(u),children:[Q(`select`,{class:`sel onsel`,"aria-label":`Note on`,"data-tip":Yo(u),value:u.value??``,onChange:e=>{let t=e.target;u.onChange(t.value),t.blur()},children:xt(u.options).map(e=>e.group===void 0?e.options.map(e=>Q(`option`,{value:e.value,children:e.label})):Q(`optgroup`,{label:e.group,children:e.options.map(e=>Q(`option`,{value:e.value,children:e.label}))}))}),Q($,{name:`chev`})]}),Q(`span`,{class:`sp`}),d&&Q(`div`,{class:`seg`,role:`group`,"aria-label":`Scope`,children:ct(d.options).map(e=>Q(`button`,{type:`button`,"aria-pressed":d.value===e.value,onClick:()=>d.onChange(e.value),children:e.label}))})]}),f&&f.length>0&&!(p&&d?.value===`range`)&&Q(`div`,{class:`row`,role:`group`,"aria-label":`Start a note`,children:f.map(e=>Q(`button`,{type:`button`,class:`chip`,onClick:()=>P(`${e}: `),children:e}))}),p&&d?.value===`range`&&Q(`div`,{class:`row`,role:`group`,"aria-label":`Marks`,children:Jo.map(({kind:e,label:t})=>{let n=p.value.find(t=>t.kind===e);return Q(`span`,{class:`markc`,children:[Q(`button`,{type:`button`,class:`chip`,"aria-pressed":!!n,onClick:()=>p.onChange(_t(p.value,e)),children:t}),n?.db!==void 0&&Q(`span`,{class:`onwrap`,children:[Q(`select`,{class:`sel dbsel`,"aria-label":`${t} by`,value:String(n.db),onChange:t=>{let n=t.target;p.onChange(vt(p.value,e,Number(n.value))),n.blur()},children:dt.map(e=>Q(`option`,{value:String(e),children:[e,` dB`]}))}),Q($,{name:`chev`})]})]})})}),y&&Q(`div`,{class:`row`,children:Q(qo,{name:`This note applies to`,label:y.label,width:y.width,height:y.height,value:y.value,onChange:y.onChange,lockedReason:y.lockedReason})}),r&&Q(`div`,{class:`row`,children:r}),Q(`div`,{class:`cbox`,children:[Q(`textarea`,{ref:w,class:`input`,rows:2,"aria-label":`New note`,placeholder:n,value:T,onInput:e=>{let t=e.target.value;E(t),l?.(t.trim()!==``)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),N()),e.key===`Escape`&&e.target.blur()}}),Q(`button`,{class:`btn primary ib sm send`,"data-tip":`Add note ↵`,"aria-label":`Add note`,onClick:()=>void N(),children:Q($,{name:`send`})})]}),y&&Q(`p`,{class:`fhint`,children:y.hint})]})]})}var Zo=typeof location>`u`?{test:!1,streamOver:!1}:Rt(location.search);Zo.streamOver&&si(1);var Qo=Zo.test?{engine:null,inspect(){return this.engine?this.engine.inspect():null},renders:0,draws:zo,liveContexts:co,sample:()=>_o.state(),clips:[],heard(){let e=this.engine?.inspect();return e?this.clips.filter(t=>(e.gains[t.id]??1)*(e.lanes[t.lane]??1)>0).map(e=>({id:e.id,lane:e.lane,path:e.path,offset:e.offset})):[]}}:null;Qo&&(window.__rushesAudio=Qo);var $o=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),es={in:null,out:null},ts=[`point`,`range`,`whole`];function ns(e){let{stage:t,title:n,headerExtra:r,belowLanes:i,rows:a,preview:o,fps:s,notes:c,onOptions:l,noteRow:u,onLabel:d,toast:f,onChanged:p,onPendingChange:m,listen:h}=e;Qo&&Qo.renders++;let g=e.clips??rs(a.flatMap(e=>e.clips)),[_,v]=q(null),[y,b]=q(16/9);J(()=>{v(null),b(16/9)},[o?.file]);let{engine:x,playing:C,length:w,media:T}=yo(g,o?o.duration??_:null),[E,D]=q(null),[O,k]=q(null),A=X(null),j=a.some(e=>e.key===E)?E:null;Y(()=>{E!==null&&j===null&&(D(null),A.current!==null&&O===A.current&&k(null),A.current=null)},[j]);let[M,N]=q(es),[P,F]=q(e.defaultScope??`point`),[I,L]=q([]),[ee,te]=q(!1),R=(e.scopes??ts).includes(`range`),ne=e.defaultScope??`point`,z=`${e.film===void 0?o?.video??``:e.film??``}/${o?.version??``}`,re=X(z);Y(()=>{re.current!==z&&(re.current=z,F(ne))},[z]);let ie=lt({range:M,marks:I,hasText:ee});Y(()=>{m?.(ie)},[ie]),J(()=>()=>m?.(!1),[]);let ae=e=>h?h(e):{select:jt(a,e),gains:{}},B=X({select:{},gains:{}}),V=e=>{let t=B.current;for(let[n,r]of Object.entries(e.select))(!(n in t.select)||t.select[n]!==r)&&x.selectVariant(n,r);for(let[n,r]of Object.entries(e.gains))t.gains[n]!==r&&x.setLaneGain(n,r);B.current={select:{...t.select,...e.select},gains:{...t.gains,...e.gains}}},oe=ae(j);Y(()=>V(oe),[x,JSON.stringify(oe)]);let se=e.defaultOn??a.find(e=>e.picked)?.on??a[0]?.on??l[0]?.value??null,ce=l.some(e=>e.value===O)?O:se,le=l.find(e=>e.value===ce)??null,H=X(null),ue=X([]),de=X(null),U=X(null),fe=X(null),W=X(!1),pe=X(0),me=X(null),_e=e=>{if(P===`whole`)return t===`voice`?`Note on the whole read`:`Note on the whole track`;if(R){if(M.in!==null&&M.out===null)return`Set an Out point`;if(M.in!==null&&M.out!==null)return`Note on ${ve(M.in,M.out)}`;if(P===`range`)return`Set In and Out`}return`Note at ${G(le?.t??he(e,s))}`},ye=e=>{let t=x.length,n=`${t>0?Math.min(e,t)/t*100:0}%`;for(let e of ue.current)e.style.left=n;let r=G(e);de.current&&(de.current.textContent=r),U.current&&(U.current.textContent=r),me.current&&(me.current.placeholder=_e(e));let i=fe.current;i&&i.readyState>=1&&!i.seeking&&ti(i.currentTime,e,s)&&(i.currentTime=Math.min(e,Number.isFinite(i.duration)?i.duration:e)),i&&x.playing&&!W.current&&e>pe.current&&(W.current=!0,i.play().catch(()=>void 0)),pe.current=e},be=X(ye);be.current=ye,Y(()=>{ue.current=H.current?[...H.current.querySelectorAll(`.playhead`)]:[],ye(x.time)}),J(()=>x.subscribe(e=>be.current(e)),[x]),J(()=>{let e=fe.current;e&&(W.current=!1,C||(e.pause(),be.current(x.time)))},[C,o?.file]);let xe=()=>x.playing?x.pause():x.play(),Se=e=>{x.pause(),x.seek(ge(x.time,s,e,x.length))},Ce=()=>{R&&(N({in:he(x.time,s),out:null}),F(`range`))},we=()=>{if(!R)return;let e=he(x.time,s),t=M.in??0;if(e<=t)return f(`Out has to come after In`);N({in:t,out:e}),F(`range`)},Te=()=>{N(es),L([]),P===`range`&&F(ne)},Ee=e=>{(e!==`range`||R)&&(F(e),e!==`range`&&(N(es),L([])))},De=t=>{D(t.key),V(ae(t.key)),A.current=t.on??null,t.on&&k(t.on),e.onSelect?.(t)},Oe=X(()=>void 0);Oe.current=e=>{if($o(e.target)||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.key.toLowerCase();if(e.key===` `){if(Lt(e.target))return;e.preventDefault(),xe()}else e.key===`ArrowLeft`?(e.preventDefault(),Se(e.shiftKey?-10:-1)):e.key===`ArrowRight`?(e.preventDefault(),Se(e.shiftKey?10:1)):t===`i`?Ce():t===`o`?we():t===`n`&&(e.preventDefault(),me.current?.focus())},Y(()=>{let e=e=>Oe.current(e);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),Y(()=>{Qo&&(Qo.clips=g)}),J(()=>{if(Qo)return Qo.engine=x,()=>{Qo.engine===x&&(Qo.engine=null)}},[x]);let ke=async e=>{let n=null,r=null;if(P===`range`){if(M.in===null||M.out===null)throw Error(`set In and Out for a range`);n=M.in,r=M.out}else P===`point`&&(n=le?.t??he(x.time,s));await Z.post(`/api/notes`,{stage:t,video:o?.video??null,version:o?.version??null,on:le?.on??null,scope:P,t:n,tOut:r,text:e,marks:P===`range`?I:[]}),N(es),L([]),F(ne),p()},Ae=o?.version??null,je={};for(let e of c){if(e.scope===`whole`||e.t===null)continue;let t=u(e);for(let n of t===null?[]:typeof t==`string`?[t]:t)(je[n]??=[]).push({id:e.id,t:e.t,tOut:R?e.tOut:null,status:e.status,text:e.text})}let Me=M.in===null?null:M.out===null?`${G(M.in)} →`:ve(M.in,M.out);return Q(`div`,{class:`astage`,ref:H,children:[Q(`div`,{class:`stack`,children:[Q(`div`,{class:`ahead`,children:[Q(`h2`,{children:n}),r,Q(`span`,{class:`sp`})]}),Q(`div`,{class:`bar`,children:[Q(`button`,{class:`btn ghost ib`,"data-tip":`Back one frame ←`,"aria-label":`Back one frame`,onClick:()=>Se(-1),children:Q($,{name:`prev`})}),Q(`button`,{class:`btn ib`,"data-tip":`Play Space`,"aria-label":C?`Pause`:`Play`,onClick:xe,children:Q($,{name:C?`pause`:`play`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Forward one frame →`,"aria-label":`Forward one frame`,onClick:()=>Se(1),children:Q($,{name:`next`})}),Q(`span`,{class:`tc`,"aria-label":`Timecode`,children:[Q(`span`,{ref:de,children:G(x.time)}),Q(`small`,{children:[`/ `,G(w)]})]}),Q(`span`,{class:`sp`}),Me&&Q(`span`,{class:`chipx`,children:[Q(`span`,{class:`mono`,children:Me}),Q(`button`,{"aria-label":`Clear range`,onClick:Te,children:Q($,{name:`x`})})]}),R&&Q(S,{children:[Q(`button`,{class:`btn ghost ib`,"data-tip":`Set in I`,"aria-label":`Set in point`,onClick:Ce,children:Q($,{name:`in`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Set out O`,"aria-label":`Set out point`,onClick:we,children:Q($,{name:`out`})})]})]}),Q(Go,{rows:a,length:w,media:T,selected:j,marks:je,range:M,onSelect:De,onSeek:(e,t,n)=>{De(t);let r=n===void 0?void 0:l.find(e=>e.value===`c:${t.key}:${n}`);r&&(A.current=r.value,k(r.value)),x.seek(e)},toast:f}),i]}),Q(`div`,{class:`acol`,children:[Q(`div`,{class:`pv`,children:Q(`div`,{class:`frame`,style:{aspectRatio:String(y)},children:[o?Q(`video`,{ref:fe,src:Nr(o.file),muted:!0,playsInline:!0,preload:`auto`,"aria-label":`Picture preview`,onLoadedMetadata:e=>{let t=e.target;Number.isFinite(t.duration)&&v(t.duration),t.videoWidth&&t.videoHeight&&b(t.videoWidth/t.videoHeight),be.current(x.time)},onSeeked:()=>be.current(x.time)}):Q(`div`,{class:`pvempty`,"aria-label":`No cut yet`,children:Q($,{name:`film`})}),Q(`div`,{class:`tcover`,ref:U,children:G(x.time)})]})}),Q(Xo,{notes:c,version:Ae,placeholder:_e(x.time),inputRef:me,toast:f,onAdd:ke,onChanged:p,onTextChange:te,fixedTimes:!0,onSeek:e=>x.seek(e),on:{options:l,value:ce,onChange:k},scope:{value:P,onChange:Ee,options:e.scopes},chips:(e.chipsFor??(()=>ut[t]))(P),marks:e.marks===!1?void 0:{value:I,onChange:L},onLabel:d})]})]})}function rs(e){let t=new Set;return e.filter(e=>!t.has(e.id)&&(t.add(e.id),!0))}var is={vo:`#4FD1C5`,music:`#A78BFA`,sfx:`#FB923C`},as={vo:`Voiceover`,music:`Music`,sfx:`Sound effects`},os={vo:{muted:!1,solo:!1},music:{muted:!1,solo:!1},sfx:{muted:!1,solo:!1}};function ss({state:e,assets:t,video:n,toast:r,onChanged:i,onPendingChange:a}){let o=e=>t.find(t=>t.path===e),s=e=>{let t=o(e);return t?qr(t):void 0},c=e=>o(e)?.missing===!0,l=e.picks.lanes,u=Ut(Vt(e.project.lanes,l)),d=u&&!c(u.file)?[{id:u.key,lane:`vo`,path:u.file,offset:0,duration:0,rev:s(u.file)}]:[],f=u?c(u.file):!1,p={music:bt(e.project.lanes,`music`),sfx:bt(e.project.lanes,`sfx`)},m=e=>e.filter(e=>l[e.lane]===e.variant),h={music:m(p.music),sfx:m(p.sfx)},g={music:h.music.filter(e=>!c(e.file)),sfx:h.sfx.filter(e=>!c(e.file))},_=e=>g[e].map(t=>({id:t.key,lane:e,path:t.file,offset:0,duration:0,rev:s(t.file)})),v={vo:d,music:_(`music`),sfx:_(`sfx`)},y={vo:d.length>0,music:v.music.length>0,sfx:v.sfx.length>0},b={variants:p,heard:{vo:y.vo,music:g.music,sfx:g.sfx}},x=sn(b),[C,w]=q(os),T=(e,t)=>w(n=>({...n,[e]:{...n[e],[t]:!n[e][t]}})),E=e.picks.levels,D=e=>E[$t[e]]??0,[O,k]=q(()=>({vo:D(`vo`),music:D(`music`),sfx:D(`sfx`)})),A=X({});J(()=>{k(e=>{let t=!1,n={...e};for(let e of Qt){if(A.current[e]!==void 0)continue;let r=D(e);n[e]!==r&&(n[e]=r,t=!0)}return t?n:e})},[JSON.stringify(E)]);let j=e=>{let t=A.current;for(let n of Qt){let r=t[n];r&&(window.clearTimeout(r.id),delete t[n],r.send(e))}};J(()=>{let e=()=>j(!0),t=()=>{document.visibilityState===`hidden`&&j(!0)};return window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,t),j(!1)}},[]);let M=(e,t)=>{let n=ln(t);k(t=>t[e]===n?t:{...t,[e]:n});let a=A.current;a[e]!==void 0&&window.clearTimeout(a[e].id);let o=(t=!1)=>void Z.put(`/api/picks`,{levels:{[$t[e]]:n===0?null:n}},{keepalive:t}).then(i,e=>{r(e instanceof kr?e.message:`Couldn't save the level`)});a[e]={id:window.setTimeout(()=>{delete a[e],o()},300),send:o}},N=Zr(Qt.map(e=>({id:e,...C[e],level:O[e]}))),P=e=>e===`vo`?u?`${u.laneName} · ${u.name}`:null:h[e].map(e=>e.name).join(` · `)||null,F=e=>y[e]?null:e===`vo`?f?`Missing`:`Nothing picked`:h[e].length>0?`Missing`:`Nothing picked`,I=Qt.map(e=>({key:e,name:as[e],meta:P(e),color:is[e],clips:v[e],cues:e===`sfx`?g.sfx.flatMap(e=>e.cues):void 0,on:x.find(t=>t.row===e)?.value,missing:F(e)??void 0,controls:Q(S,{children:[Q(`button`,{type:`button`,class:`ms`,"aria-pressed":C[e].muted,"aria-label":`Mute ${as[e]}`,"data-tip":`Mute`,onClick:()=>T(e,`muted`),children:`M`}),Q(`button`,{type:`button`,class:`ms`,"aria-pressed":C[e].solo,"aria-label":`Solo ${as[e]}`,"data-tip":`Solo`,onClick:()=>T(e,`solo`),children:`S`}),Q(`label`,{class:`level`,"data-tip":`Level for ${as[e]}. Double-click to reset.`,children:[Q(`input`,{type:`range`,min:-24,max:6,step:cn,value:O[e],"aria-label":`${as[e]} level`,"aria-valuetext":`${un(O[e])} dB`,onInput:t=>M(e,Number(t.target.value)),onDblClick:()=>M(e,0)}),Q(`span`,{class:`db mono`,children:[un(O[e]),` dB`]})]})]})})),L=en(y,N),ee=JSON.stringify({want:L,levels:E,clips:Qt.map(e=>v[e].map(e=>[e.path,e.rev??``,e.offset]))}),[te,R]=q({kind:`waiting`}),[ne,z]=q(!1),[re,ie]=q(0),ae=te.kind===`timeout`||te.kind===`error`,B=X(0);J(()=>{let e=++B.current;if(L.length===0){R({kind:`empty`}),z(!1);return}R(e=>e.kind===`empty`||e.kind===`timeout`||e.kind===`error`?{kind:`waiting`}:e),z(!0);let t=window.setTimeout(()=>{Z.post(`/api/mix/loudness`,{lanes:L}).then(t=>{e===B.current&&R({kind:`result`,result:t})},t=>{e===B.current&&R({kind:t instanceof kr&&t.status===504?`timeout`:`error`})}).finally(()=>{e===B.current&&z(!1)})},500);return()=>window.clearTimeout(t)},[ee,re]),J(()=>()=>void++B.current,[]);let V=Q(`div`,{class:ae?`meter retry`:`meter`,role:`group`,"aria-label":`Loudness`,"aria-busy":ne,onClick:ae?()=>ie(e=>e+1):void 0,children:[pn(te).map(e=>Q(`div`,{"data-cell":e.id,children:[Q(`b`,{"data-value":!0,"data-tip":e.tip??void 0,"aria-description":e.tip??void 0,children:e.value}),Q(`span`,{children:e.label})]})),ne&&Q(`span`,{class:`smk measuring`,"data-measuring":!0,"data-tip":`Measuring`,"aria-label":`Measuring`,children:Q($,{name:`gauge`})}),ae&&!ne&&Q(`button`,{type:`button`,class:`btn ghost ib`,"data-tip":`Measure again`,"aria-label":`Measure again`,children:Q($,{name:`gauge`})})]}),oe=e.notes.notes.filter(e=>e.stage===`mix`),se=Se(n??void 0),ce=n&&se?{video:n.id,version:se.id,file:se.file,duration:se.duration}:null,le=e.project.fps||30;return Q(ns,{stage:`mix`,title:we.mix,belowLanes:V,rows:I,preview:ce,film:n?.id??null,fps:le,notes:oe,onOptions:x,defaultOn:`mix`,listen:()=>({select:{},gains:N}),noteRow:e=>rn(b,e.on),onLabel:e=>on(b,e.on),toast:r,onChanged:i,onPendingChange:a})}function cs({notes:e,version:t,viewsHere:n,ownViews:r,onShow:i,onRestore:a}){let[o,s]=q(!1);return e.length===0?null:Q(`div`,{class:`otherfmts`,children:[Q(`button`,{type:`button`,class:`otherrow`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[Q(`span`,{children:[`Other formats (`,e.length,`)`]}),Q(`span`,{class:`sp`}),Q(`span`,{class:`act`,"aria-hidden":`true`,children:o?`Hide`:`Show`})]}),o&&e.map(e=>{let o=_e(e,t),s=ir(e,n,r(e));return Q(`div`,{class:`note ro${e.status===`done`?` done`:``}`,"data-note":e.id,children:[Q(`span`,{"aria-hidden":`true`}),Q(`div`,{class:`nt`,children:[Q(`span`,{class:`t mono`,children:ve(o.t,o.tOut)}),Q(`span`,{class:`ftag`,children:e.format?de(e.format):`All`}),o.from&&Q(`span`,{class:`from`,children:[`from `,o.from]})]}),Q(`div`,{class:`nx`,children:e.text}),s?.kind===`show`&&Q(`div`,{class:`nact`,children:Q(`button`,{type:`button`,class:`flink`,onClick:()=>i(s.id,e),children:[`Show on `,s.label]})}),s?.kind===`restore`&&Q(`div`,{class:`nact`,children:Q(`button`,{type:`button`,class:`flink`,onClick:()=>a(e),children:`Restore to all formats`})})]},e.id)})]})}var ls=6e3,us=e=>/[.!?]$/.test(e)?e:`${e}.`;function ds({video:e,version:t,ffmpeg:n,autoProxy:r,job:i,broken:a,duration:o,toast:s,onChanged:c,noteProxyJob:l,hidden:u=!1}){let[d,f]=q(!1),[p,m]=q(!1),[h,g]=q(r);J(()=>g(r),[r]);let _=X(new Set);i?.state===`running`&&_.current.add(i.job);let[v,y]=q(null),b=bn({ffmpeg:n,need:t.proxyNeed,broken:a,hasProxy:!!t.proxy,job:i,starting:d,watched:!!i&&_.current.has(i.job)}),x=b===`done`&&i?i.job:null;if(J(()=>{if(!x)return;let e=window.setTimeout(()=>y(x),ls);return()=>clearTimeout(e)},[x]),!n)return null;let C=x&&v===x?`none`:b,w=xn(t.proxyNeed,a),T=i?.state===`running`?i.pct:i?.state===`done`?100:0,E=i?.state===`running`?i:null,D=async()=>{if(!d){f(!0);try{let{job:n}=await Z.post(`/api/videos/${encodeURIComponent(e.id)}/versions/${encodeURIComponent(t.id)}/proxy`);_.current.add(n.id),l(n)}catch(e){s(e.message)}finally{f(!1)}}},O=async()=>{if(E&&!p){m(!0);try{let{job:e}=await Z.del(`/api/proxy-jobs/${encodeURIComponent(E.job)}`);l(e)}catch(e){e instanceof kr&&e.code===`not_found`?c():s(e.message)}finally{m(!1)}}},k=async e=>{g(e);try{await Z.put(`/api/project/settings`,{autoProxy:e}),c()}catch(t){g(!e),s(t.message)}},A=Q(`label`,{class:`check`,children:[Q(`input`,{type:`checkbox`,checked:h,onChange:e=>{let t=e.currentTarget;t.blur(),k(t.checked)}}),`Create proxies for new cuts like this automatically`]});return Q(`div`,{class:`proxybar${C===`none`?` quiet`:``}`,hidden:u,children:Q(`div`,{class:`proxyrow${C===`none`?``:` ${C}`}`,children:[C===`offer`&&w&&Q(S,{children:[Q(`span`,{class:`why`,children:[Q(`b`,{children:`This cut may play slowly.`}),` `,us(w)]}),Q(`button`,{class:`btn primary tip-wrap tip-end`,"aria-label":`Create proxy`,"data-tip":hn(t.duration??o),onClick:()=>void D(),children:`Create proxy`})]}),C===`working`&&Q(S,{children:[Q(`span`,{children:`Creating proxy`}),Q(`div`,{class:`pbar`,role:`progressbar`,"aria-label":`Proxy progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":T,children:Q(`i`,{style:{width:`${T}%`}})}),Q(`span`,{class:`mono`,children:[T,`%`]}),Q(`button`,{class:`btn`,"aria-disabled":!E||p,onClick:()=>void O(),children:`Cancel`})]}),C===`done`&&t.proxy&&Q(S,{children:[Q(`span`,{class:`ok`,children:`✓ Proxy ready`}),Q(`span`,{class:`why`,children:[`Saved to `,Q(`span`,{class:`mono`,children:t.proxy.file}),` (`,Ke(t.proxy.bytes),`).`]}),Q(`button`,{class:`btn ghost ib`,"aria-label":`Dismiss`,"data-tip":`Dismiss`,onClick:()=>y(x),children:Q($,{name:`x`})})]}),A]})})}var fs=2e3,ps=8e3,ms={kind:`none`},hs={kind:`pending`};async function gs(e,t,n){let r;try{r=await t.fetch(e.peaksUrl,{signal:n})}catch(e){if(n.aborted)throw e;return hs}if(r.status===202)return hs;if(r.status===501)return _s(e,t,n);if(r.status!==200)return ms;try{let e=await r.json(),t=e.peaks;return!Array.isArray(t)||t.length===0||typeof e.duration!=`number`||!(e.duration>0)||!t.every(e=>typeof e==`number`&&Number.isFinite(e))?ms:{kind:`wave`,wave:{peaks:Float32Array.from(t),duration:e.duration}}}catch(e){if(n.aborted)throw e;return ms}}async function _s(e,t,n){if(e.size===null||!(e.size<1e8))return ms;try{let r=await e.duration();if(n.aborted)throw new DOMException(`aborted`,`AbortError`);if(r===null||!(r>0)||r>900)return ms;let i=await t.fetch(e.mediaUrl,{signal:n});if(!i.ok)return ms;let{channels:a,duration:o}=await t.decode(await i.arrayBuffer());if(n.aborted)throw new DOMException(`aborted`,`AbortError`);let s=a[0]?.length??0;return s===0||!(o>0)?ms:{kind:`wave`,wave:{peaks:vs(ri(a,Math.min(fs,s))),duration:o}}}catch(e){if(n.aborted)throw e;return ms}}function vs(e){let t=0;for(let n of e)n>t&&(t=n);if(t>0)for(let n=0;n<e.length;n++)e[n]/=t;return e}var ys=40,bs=new Map;function xs(e,t,n,r){return`${e}/${t}/${n}#${r??``}`}function Ss(e){return bs.has(e)}function Cs(e){return bs.get(e)??null}function ws(e,t){for(bs.delete(e),bs.set(e,t);bs.size>ys;)bs.delete(bs.keys().next().value)}function Ts(e,t){let n=()=>void 0,r=()=>{let i=e.matchMedia(`(resolution: ${e.devicePixelRatio}dppx)`),a=()=>{n(),t(e.devicePixelRatio),r()};i.addEventListener(`change`,a),n=()=>i.removeEventListener(`change`,a)};return r(),()=>n()}var Es=1500,Ds=15e3,Os=15e3,ks={fetch(e,t){let n=Ar();return fetch(e,{signal:t.signal,headers:n?{"x-rushes-project":n}:{}})},async decode(e){let t=await new(window.OfflineAudioContext??window.webkitOfflineAudioContext)(1,1,ps).decodeAudioData(e),n=[];for(let e=0;e<t.numberOfChannels;e++)n.push(t.getChannelData(e));return{channels:n,duration:t.duration}}};function As(e,t,n,r,i){let a=xs(e,t.id,t.file,r),o=X(i),s=X([]);J(()=>{if(o.current=i,i>0)for(let e of s.current.splice(0))e(i)},[i]);let c=()=>o.current>0?Promise.resolve(o.current):new Promise(e=>{s.current.push(e),window.setTimeout(()=>e(null),Os)}),[l,u]=q(()=>Ss(a)?{key:a,wave:Cs(a)}:null),d=X(null);return J(()=>{if(Ss(a)){u({key:a,wave:Cs(a)});return}let r=new AbortController,i,o=Es,s={peaksUrl:`/api/videos/${encodeURIComponent(e)}/versions/${encodeURIComponent(t.id)}/peaks`,mediaUrl:Nr(t.file),size:n,duration:c},l=async()=>{d.current=null,clearTimeout(i);let e;try{e=await gs(s,ks,r.signal)}catch{return}if(r.signal.aborted)return;if(e.kind===`pending`){d.current=()=>void l(),i=window.setTimeout(()=>void l(),o),o=Math.min(o*2,Ds);return}let t=e.kind===`wave`?e.wave:null;ws(a,t),u({key:a,wave:t})};return l(),()=>{r.abort(),clearTimeout(i),d.current=null}},[a]),J(()=>{d.current?.()},[t]),l&&l.key===a?l.wave:null}var js=0;typeof location<`u`&&Rt(location.search).test&&(window.__rushesPicture={waveDraws:()=>js});var Ms=3,Ns=2;function Ps({wave:e,length:t}){let n=X(null),[r,i]=q({w:0,h:0,dpr:1});return J(()=>{let e=n.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect(),n=window.devicePixelRatio||1;i(e=>e.w===t.width&&e.h===t.height&&e.dpr===n?e:{w:t.width,h:t.height,dpr:n})};t();let r=new ResizeObserver(t);r.observe(e);let a=Ts(window,t);return()=>{r.disconnect(),a()}},[]),J(()=>{let i=n.current;if(!i||r.w<=0||r.h<=0)return;js++,i.width=Math.round(r.w*r.dpr),i.height=Math.round(r.h*r.dpr);let a=i.getContext(`2d`);if(!a)return;a.setTransform(r.dpr,0,0,r.dpr,0,0),a.clearRect(0,0,r.w,r.h);let o=t>0?t:e.duration,s=e.peaks.length;if(!(o>0)||!(e.duration>0)||s===0)return;a.fillStyle=getComputedStyle(i).color;let c=e.duration/s;for(let t=0;t<r.w;t+=Ms){let n=t/r.w*o;if(n>=e.duration)break;let i=(t+Ms)/r.w*o,l=Math.min(s-1,Math.floor(n/c)),u=Math.min(s,Math.max(l+1,Math.ceil(i/c))),d=0;for(let t=l;t<u;t++)e.peaks[t]>d&&(d=e.peaks[t]);let f=Math.max(1,Math.min(1,d)*r.h);a.fillRect(t,(r.h-f)/2,Ns,f)}},[r,e,t]),Q(`canvas`,{ref:n,class:`pwave`,"aria-hidden":`true`})}function Fs(e){J(()=>{let t=e.current;if(!t)return;let n=()=>{let e=[...t.children].filter(e=>e.getClientRects().length>0);if(e.length===0)return;let n=e.find(e=>e.classList.contains(`framebox`)),r=Math.min(...e.map(e=>e.getBoundingClientRect().top)),i=Math.max(...e.map(e=>e.getBoundingClientRect().bottom))-r-(n?n.getBoundingClientRect().height:0),a=`${Math.ceil(i+(n?200:0))}px`;t.style.getPropertyValue(`--player-floor`)!==a&&t.style.setProperty(`--player-floor`,a)},r=new ResizeObserver(n),i=()=>{r.disconnect();for(let e of t.children)r.observe(e);n()},a=new MutationObserver(i);return a.observe(t,{childList:!0}),i(),()=>{r.disconnect(),a.disconnect()}},[])}var Is=700,Ls=16,Rs=()=>typeof matchMedia==`function`&&matchMedia(`(hover: none)`).matches;function zs({versions:e,shown:t,lockedVersion:n,onPick:r}){let i=[...e].reverse(),[a,o]=q(!1),[s,c]=q(t.id),[l,u]=q(null),[d,f]=q(!1),[p,m]=q(null),[h,g]=q(0),_=X(null),v=X(null),y=X(null),b=X({}),x=X({text:``,at:-1/0}),S=new Date,C=Wi(t),w=e=>{c(e),u(null),m(null),f(Rs()),o(!0)},T=e=>{o(!1),m(null),e&&v.current?.focus()},E=e=>{T(!0),e!==t.id&&r(e)},D=a&&!e.some(e=>e.id===s);Y(()=>{D?T(!0):a&&b.current[s]?.focus()},[a,s,D]),Y(()=>{if(!a)return;let e=()=>{let e=_.current?.getBoundingClientRect(),t=y.current?.getBoundingClientRect();if(!e||!t)return;let n=document.documentElement.clientWidth-Ls;g(Math.max(0,Math.min(e.left+t.width-n,e.left-Ls)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[a]),J(()=>{if(!a)return;let e=e=>{_.current?.contains(e.target)||T(!1)};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`focusin`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`focusin`,e,!0)}},[a]);let O=e=>{if(e.key===`Tab`){T(!1);return}if(e.metaKey||e.ctrlKey||e.altKey)return;let t=i.findIndex(e=>e.id===s),n=sa(e.key,t,i.length);if(n!==null){e.preventDefault(),e.stopPropagation(),u(null),c(i[n].id);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),T(!0);return}if(e.key===`Enter`||e.key===` `){e.preventDefault(),e.stopPropagation(),E(s);return}if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault(),e.stopPropagation();return}if(/^\d$/.test(e.key)){e.preventDefault(),e.stopPropagation();let t=e.timeStamp-x.current.at<Is?x.current.text+e.key:e.key;x.current={text:t,at:e.timeStamp};let n=oa(i.map(e=>e.id),t);n&&(u(null),c(n));return}e.key.length===1&&e.stopPropagation()},k=e=>{if(d&&p!==e){m(e),c(e);return}E(e)},A=i.find(e=>e.id===(l??s))??t;return Q(`div`,{class:`vwrap`,ref:_,children:[Q(`button`,{ref:v,type:`button`,class:`vbtn`,"data-version":t.id,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-controls":a?`vlist`:void 0,"aria-label":`Version: ${t.id} · ${C}`,onClick:()=>a?T(!1):w(t.id),onKeyDown:e=>{!a&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),e.stopPropagation(),w(t.id))},children:[Q(`span`,{class:`vid`,children:t.id}),Q(`span`,{class:`vlbl`,dir:`auto`,children:C}),Q($,{name:`chev`})]}),a&&Q(`div`,{ref:y,class:`vmenu${d?` touch`:``}`,style:h?{left:`${-h}px`}:void 0,children:[Q(`div`,{class:`vlist`,id:`vlist`,role:`listbox`,"aria-label":`Versions`,onKeyDown:O,onMouseLeave:()=>u(null),children:i.map(e=>Q(`button`,{type:`button`,role:`option`,class:`vrow`,"data-version":e.id,"data-on":e.id===(l??s)?`true`:`false`,"aria-selected":e.id===t.id,"aria-label":Bs(e,n,S),"aria-describedby":!d&&e.id===A.id?`vdetail`:void 0,tabIndex:e.id===s?0:-1,ref:t=>{b.current[e.id]=t},onMouseEnter:()=>u(e.id),onClick:()=>k(e.id),children:[Q(`span`,{class:`vid`,children:e.id}),Q(`span`,{class:`vlbl`,dir:`auto`,children:Wi(e)}),Q(`span`,{class:`vwhen`,children:[e.id===n&&Q($,{name:`lock`}),ia(e.addedAt,S)]}),d&&p===e.id&&Q(`span`,{class:`vinline`,dir:`auto`,children:[ji(e.note)||`No note.`,Q(`span`,{class:`vmeta`,children:ca(e,S)})]})]}))}),!d&&Q(`div`,{class:`vdetail`,id:`vdetail`,children:[Q(`h4`,{children:A.id}),Q(`p`,{dir:`auto`,children:ji(A.note)||`No note.`}),Q(`span`,{class:`vmeta`,children:ca(A,S)})]})]})]})}function Bs(e,t,n){return[e.id,Wi(e),e.id===t?`locked`:``,aa(e.addedAt,n)].filter(Boolean).join(`, `)}function Vs({version:e}){let[t,n]=q(!1),[r,i]=q(!1),a=X(null);Y(()=>{let e=a.current;if(!e)return;let t=()=>i(e.scrollHeight>e.clientHeight+1);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e.id,e.note,t]);let o=ji(e.note);if(!o)return null;let s=`vnote-${e.id}`;return Q(`div`,{class:`vnote`,children:[Q(`span`,{ref:a,id:s,class:t?`vtext`:`vtext vclamp`,dir:`auto`,children:o}),(r||t)&&Q(`button`,{type:`button`,class:`vmore`,"aria-expanded":t,"aria-controls":s,onClick:()=>n(!t),children:t?`Less`:`More`})]})}var Hs=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function Us({video:e,version:t,fps:n,notes:r,toast:i,onChanged:a,onPendingChange:o,startAt:s,grab:c,onGrabChange:l,playerRef:u,ffmpeg:d=!1,autoProxy:f=!1,proxyJob:p,noteProxyJob:m,source:h=`proxy`,onSourceChange:g,fileSize:_=null,fileRev:v,formats:y=[],format:b=null,formatMissing:x=!1,onPrimarySize:C,onBoxPendingChange:w,onFormatChange:T}){let E=X(null),D=X(null),O=X(null),k=X(null),[A,j]=q(0),[M,N]=q(t.duration??0),[P,F]=q(t.duration?t.file:null),I=b?y.find(e=>e.id===b)??null:null,L=!I||I.primary,ee=I??y.find(e=>e.primary)??null,te=ee?ee.width/ee.height:null,R=b!==null&&y.length>=2,ne=y.find(e=>e.primary)?.id??null,z=Qn(r,b),re=$n(r,b),[ie,ae]=q(`this`),[B,V]=q(te??16/9),[oe,se]=q(!1),[ce,le]=q(null),[H,ue]=q({in:null,out:null}),[de,U]=q(!1),[W,pe]=q(null),[ye,be]=q({w:0,h:0}),[xe,Se]=q(null),[Ce,we]=q(null),[Te,Ee]=q(!1),De=X(null);Fs(De);let Oe=As(e.id,t,_,v,P===t.file?M:t.duration??0),ke=X(!1),Ae=X(!1),je=X({}),Me=X(oe);J(()=>{Me.current=oe},[oe]);let Ne=X(!0);J(()=>()=>{Ne.current=!1},[]);let Pe=X(t.id);J(()=>{Pe.current=t.id},[t.id]),J(()=>{let e=H.in!==null||xe!==null||Te;return o?.(e),()=>o?.(!1)},[H.in,xe,Te]),J(()=>(xe!==null&&ae(`this`),w?.(xe!==null),()=>w?.(!1)),[xe]);let Fe=X(void 0);J(()=>{le(null),j(0),V(te??16/9),ue({in:null,out:null}),Se(null),Fe.current!==void 0&&l(e.id,null),Fe.current=t.file,we(null),ae(`this`)},[t.file]);let Ie=xe?`this`:ie,Le=n=>fe(e.versions.find(e=>e.id===n.version)??t),[Re,ze]=q({}),Be=e=>e.id in Re?Re[e.id]:e.format,Ve=e=>ze(t=>{if(!(e in t))return t;let{[e]:n,...r}=t;return r});J(()=>{ze(e=>{let t=Object.keys(e).filter(t=>r.some(n=>n.id===t&&n.format!==e[t]));return t.length===Object.keys(e).length?e:Object.fromEntries(t.map(t=>[t,e[t]]))})},[r]);let He=async(e,t)=>{if(Be(e)!==t){ze(n=>({...n,[e.id]:t}));try{await Z.patch(`/api/notes/${e.id}`,{format:t})}catch(t){Ve(e.id),Ke.current?.id===e.id&&(Ke.current=null),i(`Couldn't change that note: ${t.message}`)}a()}};J(()=>{Ce&&!z.some(e=>e.id===Ce)&&we(null)},[b,r]);let Ke=X(null),qe=X(b);if(qe.current!==b){qe.current=b;let e=document.activeElement,t=e instanceof HTMLElement&&e.closest(`.nfmt`)?e.closest(`.list > .note[data-note]`):null;t&&!Ke.current&&(Ke.current={id:t.dataset.note,fallback:!0})}Y(()=>{let e=Ke.current;if(!e)return;let t=document.activeElement,n=!t||t===document.body||!t.isConnected,r=document.querySelector(`.list > .note[data-note="${CSS.escape(e.id)}"] .t`);r?(Ke.current=null,n&&r.focus()):e.fallback&&(Ke.current=null,n&&document.querySelector(`.otherrow`)?.focus())},[b,r]);let Je=L&&!!t.proxy&&h!==`original`,Ye=Nr(Je?t.proxy.file:L?t.file:I.file),Xe=ce===Ye,Ze=X(null),Qe=X(null);if(Qe.current&&Qe.current.src!==Ye){let e=E.current;Qe.current.cut===t.file?!Ze.current&&e&&(Ze.current={t:e.error?A:e.currentTime,play:!e.paused&&!e.error}):Ze.current=null}Qe.current={cut:t.file,src:Ye};let $e=X(null),et=X(null),tt=I?.id??`primary`,nt=X(!0);Y(()=>{if(nt.current){nt.current=!1;return}let e=D.current;if(!ee||!e)return;let t=ee.width/ee.height;if(t===B)return;let n=e.getBoundingClientRect();$e.current={width:n.width,height:n.height},V(t)},[tt]),Y(()=>{let e=$e.current,t=D.current;if($e.current=null,!e||!t)return;et.current?.cancel(),et.current=null;let n=t.getBoundingClientRect(),r=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=Zn(e,{width:n.width,height:n.height},r);Rt(location.search).test&&(window.__rushesLastReshape={animated:i!==null,ms:i?160:0}),i&&(et.current=t.animate(i,{duration:160,easing:`ease-out`}))},[B]),J(()=>{let e=E.current;if(!e)return;let t=()=>le(Ye);return e.error&&t(),e.addEventListener(`error`,t),()=>e.removeEventListener(`error`,t)},[Ye]);let rt=X(null);rt.current=!L&&M>0?M:null;let ot=e=>{let t=rt.current;t===null||e.paused||e.currentTime<t||(e.pause(),e.currentTime=t)};J(()=>{if(!oe)return;let e=0,t=()=>{E.current&&(ot(E.current),j(E.current.currentTime)),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[oe]);let st=()=>Ze.current?.t??E.current?.currentTime??A,ct=()=>he(st(),n),lt=e=>{let t=E.current;if(!t)return;let n=Math.min(Math.max(0,e),M||t.duration||e);if(Ze.current){Ze.current.t=n,j(n);return}t.currentTime=n,j(t.currentTime)},ut=()=>{let e=E.current;e&&(e.paused?(rt.current!==null&&e.currentTime>=rt.current-.001&&(e.currentTime=0),e.play().catch(()=>i(`Couldn't play this file`))):e.pause())},dt=e=>{E.current?.pause(),lt(ge(st(),n,e,M))},ft=()=>ue({in:ct(),out:null}),pt=()=>{let e=ct(),t=H.in??0;if(e<=t)return i(`Out has to come after In`);ue({in:t,out:e})},mt=()=>ue({in:null,out:null}),ht=X(0),[gt,_t]=q(0),vt=async()=>{let r=E.current,o=ct(),s=e.id,c=t.id,u=L?null:b,f=++ht.current,p=!1;try{let e=me(o,n),t;if(d){p=!0,_t(e=>e+1);let n=await Mr(s,c,o,u);e=n.frame??e,t=n.png}else{if(!r||!r.videoWidth)return i(`Nothing to grab yet`);let e=document.createElement(`canvas`);e.width=r.videoWidth,e.height=r.videoHeight,e.getContext(`2d`).drawImage(r,0,0),t=e.toDataURL(`image/png`)}let m=await Z.post(`/api/grabs`,{video:s,version:c,frame:e,png:t,...u?{format:u}:{}});if(f!==ht.current){a();return}i(`Saved to ${m.grab}`),a(),Ne.current&&c===Pe.current&&l(s,m.grab)}catch(e){f===ht.current&&i(e.message)}finally{p&&Ne.current&&_t(e=>e-1)}},yt=async r=>{let i=H.in!==null&&H.out!==null,o=i?H.in:ct();await Z.post(`/api/notes`,{stage:`picture`,video:e.id,version:t.id,scope:i?`range`:`point`,t:o,tOut:i?H.out:null,frame:me(o,n),text:r,box:xe,grab:c,...R?{format:Ie===`this`?b:null}:{}}),mt(),ae(`this`),Se(null),l(e.id,null),a()},bt=X(()=>void 0);bt.current=e=>{if(Hs(e.target)||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.key.toLowerCase();if(e.key===` `){if(Lt(e.target))return;e.preventDefault(),ut()}else e.key===`ArrowLeft`?(e.preventDefault(),dt(e.shiftKey?-10:-1)):e.key===`ArrowRight`?(e.preventDefault(),dt(e.shiftKey?10:1)):t===`i`?ft():t===`o`?pt():t===`g`&&!e.repeat?vt():t===`b`?U(e=>!e):t===`n`&&(e.preventDefault(),k.current?.focus())},J(()=>{let e=e=>bt.current(e);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let xt=(e,t)=>{let n=E.current;return it(n?.videoWidth??0,n?.videoHeight??0,e,t)},St=e=>{let t=O.current.getBoundingClientRect(),n=xt(t.width,t.height);return{x:e.clientX-t.left-n.x,y:e.clientY-t.top-n.y,w:n.w,h:n.h}};J(()=>{let e=O.current;if(!e)return;let t=()=>be(t=>t.w===e.clientWidth&&t.h===e.clientHeight?t:{w:e.clientWidth,h:e.clientHeight});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let Ct=e=>{if(!de)return;let t=St(e);e.target.setPointerCapture(e.pointerId),pe({x0:t.x,y0:t.y,x1:t.x,y1:t.y,w:t.w,h:t.h})},wt=e=>{if(!W)return;let t=St(e);pe({...W,x1:t.x,y1:t.y})},Tt=e=>{if(!W)return;let t=St(e),n=at(W.x0,W.y0,t.x,t.y,W.w,W.h);pe(null),U(!1),ke.current=!0,n.w>.01&&n.h>.01&&Se(n)},Et=W?at(W.x0,W.y0,W.x1,W.y1,W.w,W.h):null,Dt=xt(ye.w,ye.h),Ot=e=>({left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.w*100}%`,height:`${e.h*100}%`}),kt=e=>`${M?Math.min(100,Math.max(0,e/M*100)):0}%`,At=M?t.shots.filter(e=>e.start<M):t.shots,jt=Ue(At,he(A,n));J(()=>{Me.current&&jt!==null&&je.current[jt.n]?.scrollIntoView({block:`nearest`,inline:`nearest`})},[jt?.n]);let Mt=z.map(e=>({n:e,at:_e(e,t.id)})).filter(({at:e})=>e.t!==null),Nt=z.find(e=>e.id===Ce)??null,Pt=Nt?.box&&(!Nt.version||Nt.version===t.id)&&er(Nt,b,ne)?Nt.box:null,Ft=H.in===null?null:H.out===null?`${G(H.in)} →`:ve(H.in,H.out),It=H.in!==null&&H.out===null?`Set an Out point`:`Note at ${Ft&&H.out!==null?Ft:G(A)}`,zt=e=>{N(L?e.duration||t.duration||0:t.duration??I?.duration??(e.duration||0)),F(t.file),L&&t.width===null&&e.videoWidth&&e.videoHeight&&C?.(t.file,e.videoWidth,e.videoHeight),le(e=>e===Ye?null:e),e.videoWidth&&e.videoHeight&&V(e.videoWidth/e.videoHeight),Ae.current||(Ae.current=!0,s&&(e.currentTime=Math.min(s,e.duration||s),j(e.currentTime)));let n=Ze.current;n&&(Ze.current=null,e.currentTime=Math.min(n.t,e.duration||n.t),j(n.t),n.play&&e.play().catch(()=>void 0))},Bt=t=>{t!==h&&g?.(e.id,t)};return Q(`div`,{class:`split`,children:[Q(`div`,{class:`stack`,ref:De,children:[Q(`div`,{class:`framebox`,style:{height:`min(640px, 70vh, calc(100cqw / ${B}))`},children:Q(`div`,{class:`frame`,ref:D,style:{aspectRatio:String(B),"--ar":String(B)},children:[x&&!L&&Q(`div`,{class:`msg`,children:`File not found`}),Xe&&!L&&!x&&Q(`div`,{class:`msg`,children:`This file won't play in a browser. Ask your agent for an H.264 MP4 of this format.`}),Xe&&L&&!d&&Q(`div`,{class:`msg`,children:`This file won't play in a browser. Ask your agent for an H.264 MP4 of this cut.`}),Xe&&L&&d&&t.proxy&&!Je&&Q(`div`,{class:`msg`,children:`This file won't play in a browser.`}),Q(`video`,{hidden:Xe||x&&!L,ref:e=>{E.current=e,u&&(u.current=e),e&&e.readyState>=1&&zt(e)},src:Ye,preload:`auto`,playsInline:!0,onLoadedMetadata:e=>zt(e.target),onTimeUpdate:e=>{let t=e.target;ot(t),!oe&&!Ze.current&&j(t.currentTime)},onSeeked:e=>!Ze.current&&j(e.target.currentTime),onPlay:()=>se(!0),onPause:()=>se(!1),onEnded:()=>se(!1)}),Q(`div`,{ref:O,class:`overlay${de?` drawing`:``}`,onPointerDown:Ct,onPointerMove:wt,onPointerUp:Tt,onClick:()=>{ke.current?ke.current=!1:de||ut()},children:Q(`div`,{class:`pic`,style:{left:`${Dt.x}px`,top:`${Dt.y}px`,width:`${Dt.w}px`,height:`${Dt.h}px`},children:[Pt&&Q(`div`,{class:`bx saved`,style:Ot(Pt)}),xe&&Q(`div`,{class:`bx`,style:Ot(xe)}),Et&&Q(`div`,{class:`bx`,style:Ot(Et)})]})}),Q(`div`,{class:`tcover`,children:[`f`,me(A,n),jt&&` · shot ${We(jt.n)}`]}),t.proxy&&L&&Q(`div`,{class:`srcswitch`,role:`group`,"aria-label":`Which file plays`,children:[Q(`button`,{type:`button`,class:`tip-below tip-start tip-wrap`,"aria-pressed":Je,"aria-label":`Proxy`,"data-tip":`Playing the lightweight copy. Notes and timings are the same.`,onClick:e=>{e.currentTarget.blur(),Bt(`proxy`)},children:`Proxy`}),Q(`button`,{type:`button`,class:`tip-below tip-start tip-wrap`,"aria-pressed":!Je,"aria-label":`Original`,"data-tip":`Play the full-quality file. It may stutter.`,onClick:e=>{e.currentTarget.blur(),Bt(`original`)},children:`Original`})]})]})}),m&&Q(ds,{hidden:!L,video:e,version:t,ffmpeg:d,autoProxy:f,job:p,broken:Xe&&!Je,duration:M,toast:i,onChanged:a,noteProxyJob:m},t.id),Q(`div`,{class:`bar`,children:[Q(`button`,{class:`btn ghost ib`,"data-tip":`Back one frame ←`,"aria-label":`Back one frame`,onClick:()=>dt(-1),children:Q($,{name:`prev`})}),Q(`button`,{class:`btn ib`,"data-tip":`Play Space`,"aria-label":oe?`Pause`:`Play`,onClick:ut,children:Q($,{name:oe?`pause`:`play`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Forward one frame →`,"aria-label":`Forward one frame`,onClick:()=>dt(1),children:Q($,{name:`next`})}),Q(`span`,{class:`tc`,"aria-label":`Timecode`,children:[G(A),Q(`small`,{children:[`/ `,G(M)]})]}),Q(`span`,{class:`sp`}),Ft&&Q(`span`,{class:`chipx`,children:[Q(`span`,{class:`mono`,children:Ft}),Q(`button`,{"aria-label":`Clear range`,onClick:mt,children:Q($,{name:`x`})})]}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Set in I`,"aria-label":`Set in point`,onClick:ft,children:Q($,{name:`in`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Set out O`,"aria-label":`Set out point`,onClick:pt,children:Q($,{name:`out`})}),Q(`span`,{class:`vsep`}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Draw a box B`,"aria-label":`Draw a box`,"aria-pressed":de,onClick:()=>U(!de),children:Q($,{name:`box`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Grab frame G`,"aria-label":`Grab frame`,"aria-busy":gt>0,onClick:()=>void vt(),children:Q($,{name:`camera`})})]}),Q(`div`,{class:`track`,role:`slider`,"aria-label":`Timeline`,"aria-valuemin":0,"aria-valuemax":M,"aria-valuenow":A,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();lt((e.clientX-t.left)/t.width*M)},children:[Oe&&Q(Ps,{wave:Oe,length:M}),Mt.map(({n:e,at:t})=>t.tOut!==null&&Q(`div`,{class:`span ${e.status}`,style:{left:kt(t.t),width:kt(t.tOut-t.t)}})),H.in!==null&&Q(`div`,{class:`span live`,style:{left:kt(H.in),width:kt((H.out??H.in+.2)-H.in)}}),At.filter(e=>e.start>0).map(e=>Q(`div`,{class:`tick`,style:{left:kt(e.start)}})),Mt.map(({n:e,at:t})=>{let n=rr(e,R);return Q(`div`,{class:`mk ${e.status}${R&&e.format===null?` ring`:``}`,style:{left:kt(t.t)},title:n?`${n} · ${e.text}`:e.text})}),Q(`div`,{class:`playhead`,style:{left:kt(A)}})]}),Q(`div`,{class:`ends`,children:[Q(`span`,{children:`0:00`}),Q(`span`,{children:G(M)})]}),Q(Vs,{version:t},t.id)]}),At.length>0&&Q(`div`,{class:`shots`,"data-player":!0,children:At.map(e=>Q(`button`,{type:`button`,class:`shot`,ref:t=>{je.current[e.n]=t},"aria-current":jt?.n===e.n?`true`:void 0,onClick:()=>{E.current?.pause(),lt(Ge(e.start,n))},children:[Q(`span`,{class:`mono`,children:[We(e.n),` · `,e.start.toFixed(2),`s`]}),Q(`span`,{class:`name`,children:e.name}),e.tag&&Q(`span`,{class:`tag`,children:e.tag})]}))}),Q(Xo,{notes:z,version:t.id,selectedId:Ce,placeholder:It,inputRef:k,toast:i,onAdd:yt,onChanged:a,onTextChange:Ee,formatTag:e=>rr(e,R),cardExtra:R&&I?e=>Q(qo,{name:`Note applies to`,label:I.label,width:I.width,height:I.height,value:Be(e)===null?`all`:`this`,lockedReason:e.box?tr:null,onChange:t=>void He(e,t===`all`?null:I.id)}):void 0,formatScope:R&&I?{label:I.label,width:I.width,height:I.height,value:Ie,onChange:ae,lockedReason:xe?tr:null,hint:nr(I.label,Ie,xe!==null)}:void 0,listFooter:e=>{let n=re.filter(t=>e===`all`||t.status===e);return n.length>0?Q(cs,{notes:n,version:t.id,viewsHere:y,ownViews:Le,onShow:(e,t)=>{xe||(Ke.current={id:t.id,fallback:!1}),T?.(e)},onRestore:e=>{Ke.current={id:e.id,fallback:!1},He(e,null)}}):null},onSeek:(e,t)=>{E.current?.pause(),lt(e),we(t.id)},attachments:(xe||c)&&Q(S,{children:[xe&&Q(`span`,{class:`chipx`,children:[Q($,{name:`box`}),`Box`,Q(`button`,{"aria-label":`Remove box`,onClick:()=>Se(null),children:Q($,{name:`x`})})]}),c&&Q(`span`,{class:`chipx`,children:[Q($,{name:`image`}),`Frame `,c.match(/_f(\d+)\.png$/)?.[1],Q(`button`,{"aria-label":`Remove frame`,onClick:()=>l(e.id,null),children:Q($,{name:`x`})})]})]})})]})}var Ws=500;function Gs(e,t){let n=X(void 0),r=X(e);return r.current=e,J(()=>()=>{n.current!==void 0&&(clearTimeout(n.current),r.current())},[]),{schedule(){clearTimeout(n.current),n.current=window.setTimeout(()=>{n.current=void 0,r.current()},t)},flush(){n.current!==void 0&&(clearTimeout(n.current),n.current=void 0,r.current())}}}var Ks=(e,t)=>e.slice(0,t).filter(n=>n.heading===e[t].heading).length,qs=e=>String(e).padStart(2,`0`);function Js({shot:e,large:t}){let[n,r]=q(null);return!e.still||n===e.still?Q(`span`,{class:`nostill`,children:t?`No still for this shot yet`:`No still`}):Q(`img`,{src:Nr(e.still),alt:`Still for shot ${e.n}, ${e.name}`,onError:()=>r(e.still)})}function Ys({shot:e,save:t,onZoom:n}){let[r,i]=q(e.description),[a,o]=q(e.direction),s=X(!1),c=X(null);J(()=>{s.current||i(e.description)},[e.description]),J(()=>{s.current||o(e.direction)},[e.direction]),Y(()=>{let e=c.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+2}px`)},[r]);let l=Gs(()=>{s.current=!1,r.trim()!==e.description.trim()&&t.shot(e,{description:r})},Ws),u=Gs(()=>{s.current=!1,a.trim()!==e.direction.trim()&&t.shot(e,{direction:a})},Ws),d=r.trim()!==e.current.trim()||a.trim()!==e.directionCurrent.trim(),f=e.status===`approved`;return Q(`div`,{class:`sbrow${d?` changed`:``}`,"data-shot":e.heading,children:[Q(`div`,{class:`sbid`,children:[Q(`button`,{class:`sbstill`,"aria-label":`Enlarge the still for shot ${e.n}`,"data-tip":`Enlarge`,onClick:n,children:Q(Js,{shot:e})}),Q(`div`,{class:`sbmeta`,children:[Q(`b`,{children:qs(e.n)}),Q(`span`,{children:e.length===null?`no length`:`${e.length.toFixed(1)} s`}),e.tag&&Q(`span`,{class:`sbtag`,children:e.tag})]})]}),Q(`div`,{class:`cur`,children:[Q(`b`,{class:`sbname`,children:e.name}),e.current]}),Q(`textarea`,{ref:c,class:`input`,"aria-label":`Your version of shot ${e.n}`,value:r,onInput:e=>{s.current=!0,i(e.target.value),l.schedule()},onBlur:()=>l.flush()}),Q(`div`,{class:`sblow`,children:[Q(`input`,{class:`sbdir`,placeholder:`Direction`,"aria-label":`Direction for shot ${e.n}`,value:a,onInput:e=>{s.current=!0,o(e.target.value),u.schedule()},onBlur:()=>u.flush()}),d&&Q(`button`,{class:`btn ghost ib`,"data-tip":`Revert to current`,"aria-label":`Revert shot ${e.n}`,onClick:()=>{s.current=!1,i(e.current),o(e.directionCurrent),t.shot(e,{description:e.current,direction:e.directionCurrent})},children:Q($,{name:`undo`})}),Q(`button`,{class:`btn ib okd${f?` on`:``}`,"data-tip":f?`Unapprove`:`Approve`,"aria-label":`Approve shot ${e.n}`,"aria-pressed":f,onClick:()=>t.shot(e,{status:f?`draft`:`approved`}),children:Q($,{name:`check`})})]})]})}function Xs({shot:e,onClose:t}){let n=X(null);return Y(()=>{n.current?.focus()},[]),Q(`div`,{class:`sblight`,role:`dialog`,"aria-modal":`true`,"aria-label":`Shot ${e.n}, ${e.name}`,tabIndex:-1,ref:n,onClick:t,onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),t()):e.key===`Tab`&&e.preventDefault()},children:Q(`div`,{class:`sblbx`,children:[Q(`div`,{class:`sbbig`,children:Q(Js,{shot:e,large:!0})}),Q(`div`,{class:`sblcap`,children:[Q(`b`,{children:[qs(e.n),` · `,e.name]}),` `,e.tag&&Q(`span`,{class:`sbtag`,children:e.tag}),Q(`p`,{children:e.description})]})]})})}function Zs({board:e,brief:t,toast:n,onChanged:r,settle:i}){let{latest:a,enqueue:o}=Ya(`storyboard`,e,{toast:n,onChanged:r,settle:i}),[s,c]=q(null),l=X(null),u={shot:(e,t)=>{let n=Ks(a.current.shots,a.current.shots.findIndex(t=>t.index===e.index));o(`shot ${e.n}`,r=>{let i=r.shots.filter(t=>t.heading===e.heading)[n];if(!i){let t=r.shots.filter(t=>t.name===e.name);t.length===1&&(i=t[0])}return i?{path:`/api/storyboard/shots/${i.index}`,body:{heading:i.heading,...t}}:null})}},d=ze(t),f=e.shots.find(e=>e.heading===s);return Q(`div`,{class:`col`,children:[Q(`div`,{class:`shead`,children:[Q(`h2`,{children:`Storyboard`}),Q(`span`,{class:`meta`,children:[e.total,` shot`,e.total===1?``:`s`,` · `,e.changed,` changed`]})]}),Q(`div`,{class:`sbtotal mono`,"aria-label":`Planned length`,children:[Q(`span`,{children:d?`${e.plannedLength.toFixed(1)} / ${d} s planned`:`${e.plannedLength.toFixed(1)} s planned`}),d&&Q(`span`,{class:`bar`,children:Q(`i`,{style:{width:`${Math.min(100,e.plannedLength/d*100)}%`}})})]}),Q(`div`,{class:`sbhead`,children:[Q(`span`,{}),Q(`span`,{children:`Current`}),Q(`span`,{children:`Yours`})]}),Q(`div`,{style:{display:`grid`,gap:`12px`},children:e.shots.map((t,n)=>Q(Ys,{shot:t,save:u,onZoom:()=>{l.current=document.activeElement,c(t.heading)}},`${t.heading}#${Ks(e.shots,n)}`))}),f&&Q(Xs,{shot:f,onClose:()=>{c(null),l.current?.focus()}})]})}function Qs({selected:e,rows:t,marks:n,open:r,locked:i,ready:a,onCopyReady:o,onPick:s}){let[c,l]=q(!1),[u,d]=q(0),[f,p]=q({left:0,top:0}),m=X(null),h=X(null),g=X([]),_=()=>{let n=h.current?.getBoundingClientRect();n&&p({left:Math.max(8,n.left),top:n.bottom}),d(Math.max(0,t.findIndex(t=>t.page===e))),l(!0)},v=e=>{l(!1),e&&h.current?.focus()};Y(()=>{c&&g.current[u]?.focus()},[c,u]),J(()=>{if(!c)return;let e=e=>{m.current?.contains(e.target)||v(!1)};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`focusin`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`focusin`,e,!0)}},[c]);let y=e=>{if(e.key===`Tab`)return v(!1);if(e.metaKey||e.ctrlKey||e.altKey)return;let n=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:e.key===`Home`?-t.length:e.key===`End`?t.length:0;n===0?e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),v(!0)):e.key.length===1&&e.stopPropagation():(e.preventDefault(),e.stopPropagation(),d(e=>Math.min(t.length-1,Math.max(0,e+n))))},b=e=>Q(`i`,{class:`pm ${e}`});return Q(`span`,{class:`plan`,ref:m,children:[Q(`button`,{ref:h,class:`tab`,role:`tab`,"aria-selected":e!==null,"aria-haspopup":`menu`,"aria-expanded":c,"data-locked":i?`true`:void 0,onClick:()=>c?v(!1):_(),onKeyDown:e=>{e.key===`ArrowDown`&&!c&&(e.preventDefault(),_())},children:[Q($,{name:`list`}),`Planning`,n?Q(`span`,{class:`pmarks`,title:a?`Ready to build`:`Brief, script and storyboard`,children:a?Q($,{name:`check`,class:`pready`}):Q(S,{children:[b(n.brief),b(n.script),b(n.storyboard)]})}):i?Q($,{name:`lock`,class:`lk`}):r>0&&Q(`span`,{class:`dot`,title:`${r} open`}),Q($,{name:`chev`,class:`chev`})]}),c&&Q(`div`,{class:`planmenu`,role:`menu`,"aria-label":`Planning`,style:{left:`${f.left}px`,top:`${f.top}px`},onKeyDown:y,children:[t.map((t,n)=>Q(`button`,{ref:e=>{g.current[n]=e},role:`menuitem`,class:`planitem${t.page===e?` cur`:``}`,"data-locked":t.unlocked?void 0:`true`,tabIndex:n===u?0:-1,"data-tip":t.unlocked?void 0:`Locked: ask your agent for ${t.ask}`,onClick:()=>{v(!1),s(t.page)},children:[Q($,{name:t.icon}),Q(`span`,{children:t.name}),t.unlocked?t.progress===null?null:t.progress===`ok`?Q($,{name:`check`,class:`pi`}):Q(`i`,{class:`pm ${t.progress}`}):Q($,{name:`lock`,class:`lk`})]},t.page)),a&&Q(`div`,{class:`planready`,children:[Q(`div`,{class:`rd`,children:[Q($,{name:`check`}),`Ready to build`]}),Q(`button`,{role:`menuitem`,class:`btn`,tabIndex:-1,onClick:()=>{v(!1),o()},children:[Q($,{name:`copy`}),`Copy prompt for your agent`]})]})]})]})}var $s={approved:{color:`var(--done)`,label:`Approved`},flagged:{color:`var(--todo)`,label:`Flagged`},draft:{color:`var(--text-3)`,label:`Draft`}},ec=500;function tc(e,t){let n=X(void 0),r=X(e);return r.current=e,J(()=>()=>{n.current!==void 0&&(clearTimeout(n.current),r.current())},[]),{schedule(){clearTimeout(n.current),n.current=window.setTimeout(()=>r.current(),t)},flush(){n.current!==void 0&&(clearTimeout(n.current),n.current=void 0,r.current())}}}function nc({section:e,wps:t,toast:n,onChanged:r}){let[i,a]=q(e.proposed??e.current),[o,s]=q(e.direction),c=X(!1),l=X(null);J(()=>{c.current||a(e.proposed??e.current)},[e.proposed,e.current]),J(()=>{c.current||s(e.direction)},[e.direction]),Y(()=>{let e=l.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+2}px`)},[i]);let u=async t=>{try{await Z.patch(`/api/script/${encodeURIComponent(e.id)}`,t)}catch(t){n(`Couldn't save ${e.id.toUpperCase()}: ${t.message}`)}r()},d=tc(()=>{c.current=!1,u({proposed:i.trim()===e.current.trim()?null:i})},ec),f=tc(()=>{c.current=!1,u({direction:o})},ec),p=e.end-e.start,m=ye(i,p,t),h=i.trim()!==e.current.trim(),g=$s[e.status];return Q(`div`,{class:`srow${h?` changed`:``}`,"data-section":e.id,children:[Q(`div`,{class:`sgrid`,children:[Q(`div`,{class:`when`,children:[Q(`b`,{children:e.id.toUpperCase()}),Q(`span`,{children:[G(e.start).replace(/\.\d+$/,``),`–`,G(e.end).replace(/\.\d+$/,``)]}),Q(`span`,{class:`stat`,"aria-label":g.label,"data-tip":g.label,title:g.label,children:Q(`i`,{style:{background:g.color}})})]}),Q(`div`,{class:`cur`,children:e.current}),Q(`textarea`,{ref:l,class:`input`,"aria-label":`Your version of ${e.id}`,value:i,onInput:e=>{c.current=!0,a(e.target.value),d.schedule()},onBlur:()=>d.flush()})]}),Q(`div`,{class:`sfoot`,children:[Q(`div`,{class:`fit${m.state===`ok`?``:` ${m.state}`}`,title:`${m.words} words · ${m.seconds.toFixed(1)} s of ${p.toFixed(1)} s`,children:Q(`i`,{style:{width:`${Math.min(100,m.ratio*100)}%`}})}),Q(`input`,{class:`dirin`,placeholder:`Direction`,"aria-label":`Direction for ${e.id}`,value:o,onInput:e=>{c.current=!0,s(e.target.value),f.schedule()},onBlur:()=>f.flush()}),Q(`div`,{class:`sact`,children:[h&&Q(`button`,{class:`btn ghost ib`,"data-tip":`Revert to current`,"aria-label":`Revert`,onClick:()=>{a(e.current),u({proposed:null})},children:Q($,{name:`undo`})}),Q(`button`,{class:`btn ib flagd${e.status===`flagged`?``:` ghost`}`,"data-tip":e.status===`flagged`?`Unflag`:`Flag`,"aria-label":`Flag`,"aria-pressed":e.status===`flagged`,onClick:()=>void u({status:e.status===`flagged`?`draft`:`flagged`}),children:Q($,{name:`flag`})}),Q(`button`,{class:`btn ib okd`,"data-tip":e.status===`approved`?`Unapprove`:`Approve`,"aria-label":`Approve`,"aria-pressed":e.status===`approved`,onClick:()=>void u({status:e.status===`approved`?`draft`:`approved`}),children:Q($,{name:`check`})})]})]})]})}function rc({script:e,toast:t,onChanged:n}){let r=e.sections.filter(be).length;return Q(`div`,{class:`col`,children:[Q(`div`,{class:`shead`,children:[Q(`h2`,{children:`Script`}),Q(`span`,{class:`meta`,children:[e.sections.length,` section`,e.sections.length===1?``:`s`,` · `,r,` changed`]})]}),Q(`div`,{class:`sgrid scols`,children:[Q(`span`,{}),Q(`span`,{children:`Current`}),Q(`span`,{children:`Yours`})]}),Q(`div`,{style:{display:`grid`,gap:`12px`},children:e.sections.map(r=>Q(nc,{section:r,wps:e.wordsPerSecond,toast:t,onChanged:n},r.id))})]})}var ic={music:`#A78BFA`,sfx:`#FB923C`},ac=Math.floor(Math.random()*2**31),oc=!1,sc=new Set;function cc({stage:e,state:t,assets:n,video:r,toast:i,onChanged:a,onPendingChange:o}){let[s,c]=q(e===`music`&&oc),l=e=>{oc=e,c(e)},[,u]=q(0),d=e=>{sc.has(e)?sc.delete(e):sc.add(e),u(e=>e+1)},f=bt(t.project.lanes,e),p=s?Mt(f.map(e=>e.key),ac):f.map(e=>e.key),m=p.map(e=>f.find(t=>t.key===e)),h=e=>s?`Bed ${p.indexOf(e.key)+1}`:e.name,g=t.picks.lanes,_=async(e,t)=>{try{await Z.put(`/api/picks`,{lanes:{[e.lane]:t}})}catch(e){i(`Couldn't ${t===null?`clear`:`set`} the pick: ${e.message}`)}a()},v=m.map(t=>{let r=n.find(e=>e.path===t.file),i={id:t.key,lane:t.lane,path:t.file,offset:0,duration:0,rev:r?qr(r):void 0},a=g[t.lane]===t.variant;return{key:t.key,name:h(t),meta:s?`·····`:t.meta,color:ic[e],clips:[i],cues:e===`sfx`?t.cues:void 0,layers:e===`sfx`?{open:sc.has(t.key),onToggle:()=>d(t.key)}:void 0,audition:{lane:t.lane,clip:t.key},picked:a,order:f.indexOf(t),use:{inUse:a,onUse:()=>void _(t,t.variant),onUnpick:()=>void _(t,null)},on:`v:${t.key}`}}),y=Tt(m,h,e===`sfx`),b=t.notes.notes.filter(t=>t.stage===e),x=Se(r??void 0),S=r&&x?{video:r.id,version:x.id,file:x.file,duration:x.duration}:null,C=t.project.fps||30;return Q(ns,{stage:e,film:r?.id??null,title:we[e],headerExtra:e===`music`&&Q(`button`,{class:`btn ghost ib`,"aria-label":`Blind`,"aria-pressed":s,"data-tip":s?`Show names`:`Blind: hide names`,onClick:()=>l(!s),children:Q($,{name:`eyeoff`})}),rows:v,preview:S,fps:C,notes:b,onOptions:y,noteRow:e=>kt(m,e.on),onLabel:e=>At(m,y,e.on),toast:i,onChanged:a,onPendingChange:o})}var lc=`#4FD1C5`,uc=[`whole`,`point`],dc={whole:ut.voice,point:[`Fix this`,`Keep this`]},fc=Math.floor(Math.random()*2**31),pc=!1,mc=new Map,hc=new Set;function gc({state:e,assets:t,video:n,toast:r,onChanged:i,onPendingChange:a}){let[o,s]=q(pc),c=e=>{pc=e,s(e)},l=n?.id??``,[,u]=q(0),d=mc.get(l)??hc,f=e=>{let t=new Set(d);t.has(e)?t.delete(e):t.add(e),mc.set(l,t),u(e=>e+1)},p=e=>t.find(t=>t.path===e),m=e=>{let t=p(e);return t?qr(t):void 0},h=e=>p(e)?.missing===!0,g=Vt(e.project.lanes,e.picks.lanes),_=g.map(e=>{if(!o)return e;let t=Mt(e.reads.map(e=>e.key),fc);return{...e,reads:t.map(t=>e.reads.find(e=>e.key===t))}}),v=new Map;for(let e of _)e.reads.forEach((e,t)=>v.set(e.key,t+1));let y=e=>o?`Read ${v.get(e.key)}`:e.name,b=async(e,t)=>{try{await Z.put(`/api/picks`,{lanes:{[e.id]:t}})}catch(e){r(`Couldn't ${t===null?`clear`:`set`} the pick: ${e.message}`)}i()},x=e=>({id:e.key,lane:Gt(e),path:e.file,offset:0,duration:0,rev:m(e.file)}),C=g.filter(e=>e.current||d.has(e.id)).flatMap(e=>e.reads.filter(e=>!h(e.file)).map(x)),w=e.notes.notes.filter(e=>e.stage===`voice`),T={rounds:g,sections:e.script.sections},E=(e,t)=>({key:t.key,name:y(t),meta:o?`·····`:t.meta,color:lc,clips:h(t.file)?[]:[x(t)],use:{inUse:e.pick===t.variant,onUse:()=>void b(e,t.variant),onUnpick:()=>void b(e,null)},on:`v:${t.key}`,missing:h(t.file)}),D=[];for(let e of[..._].reverse()){if(e.current){e.reads.forEach((t,n)=>D.push(n===0?{...E(e,t),heading:e.name,tag:`current`}:E(e,t)));continue}let t=d.has(e.id),n=e.reads.find(t=>t.variant===e.pick),r=new Set(e.reads.map(e=>e.key)),i=e.reads.length;if(D.push({key:`round:${e.id}`,name:e.name,color:lc,clips:[],fold:{label:Q(S,{children:[Q(`b`,{children:e.name}),` · `,i,` `,i===1?`read`:`reads`,` ·`,` `,n?Q(`span`,{class:`fpk`,children:[`picked `,o?`a read`:n.name]}):`nothing picked`]}),text:`${e.name} · ${i} ${i===1?`read`:`reads`} · ${n?`picked ${o?`a read`:n.name}`:`nothing picked`}`,open:t,dot:w.some(e=>e.status===`todo`&&r.has(Yt(T,e)??``)),onToggle:()=>f(e.id)}}),t)for(let t of e.reads)D.push(E(e,t))}let O=Xt(_,y),k=Wt(g),A=Se(n??void 0),j=n&&A?{video:n.id,version:A.id,file:A.file,duration:A.duration}:null,M=e.project.fps||30;return Q(ns,{stage:`voice`,film:n?.id??null,title:we.voice,headerExtra:Q(`button`,{class:`btn ghost ib`,"aria-label":`Blind`,"aria-pressed":o,"data-tip":o?`Show names`:`Blind: hide names`,onClick:()=>c(!o),children:Q($,{name:`eyeoff`})}),rows:D,clips:C,preview:j,fps:M,notes:w,onOptions:O,defaultOn:k?`v:${k.key}`:void 0,listen:e=>Kt(g,e),noteRow:e=>Yt(T,e),onLabel:e=>Zt(T,e.on,y),scopes:uc,defaultScope:`whole`,chipsFor:e=>dc[e===`point`?`point`:`whole`],marks:!1,toast:r,onChanged:i,onPendingChange:a})}var _c=[[`all`,`All`],[`picture`,Gi.picture],[`voice`,Gi.voice],[`music`,Gi.music],[`sfx`,Gi.sfx],[`mix`,Gi.mix],[`notes`,Gi.notes],[`assets`,Gi.assets]];function vc(e){return _c.some(([t])=>t===e)}var yc={user:`added by you`,agent:`agent`,rushes:`Rushes`};function bc(e,t){let n=[];for(let r of e){let e=new Date(r.at),i=Qi(e),a=n[n.length-1];a&&a.date===i?a.entries.push(r):n.push({key:i,date:i,heading:$i(e,t,!0),entries:[r]})}let r=new Map;for(let e=n.length-1;e>=0;e--){let t=(r.get(n[e].date)??0)+1;r.set(n[e].date,t),t>1&&(n[e].key=`${n[e].date}~${t}`)}return n.map(({key:e,heading:t,entries:n})=>({key:e,heading:t,entries:n}))}function xc(e,t){return e===`all`||e===t}var Sc=new Set([` `,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`,`PageUp`,`PageDown`]);function Cc(e){return Sc.has(e.key)&&!e.altKey&&!e.ctrlKey&&!e.metaKey}var wc=[`script`,`picture`,`voice`,`music`,`sfx`,`mix`];function Tc(e,t){if(e.kind===`entry`&&!e.video&&!e.version&&!e.ref)return null;let n=e.video?t.videos.find(t=>t.id===e.video):void 0;if(n)return e.version&&n.versions.some(t=>t.id===e.version)?{tab:`picture`,video:n.id,version:e.version}:{tab:`picture`,video:n.id};let r=e.ref?e.ref.indexOf(`/`):-1,i=r>0?t.lanes.find(t=>t.id===e.ref.slice(0,r)):void 0;return i?{tab:i.stage,row:e.ref}:e.tab&&wc.includes(e.tab)?{tab:e.tab}:e.area===`assets`?{tab:`assets`}:wc.includes(e.area)?{tab:e.area}:null}function Ec(e,t){let n=new Set(e.map(e=>`${e.id}@${e.at}`));return t.filter(e=>!n.has(`${e.id}@${e.at}`)).length}function Dc(e){let t=e.entries.length+e.earlier,n=e.earlier>0?`Showing the newest ${e.entries.length} of ${t}`:`${t} entr${t===1?`y`:`ies`}`;return e.dropped>0?`${n} · Earlier entries were removed`:n}function Oc(e,t){let n=e.by===`user`?`added by you`:e.by===`agent`?`by the agent`:`by Rushes`;return`${e.text} (${Gi[e.area]}, ${t}, ${n})`}function kc(e,t){let n=typeof t?.status==`number`?t.status:null,r=`Run rushes doctor to see why.`;return n===null?`${e===`read`?`The Change Log couldn't be loaded`:e===`add`?`That line wasn't added`:`The Markdown wasn't saved`}: Rushes didn't answer. Check it's still running, then try again.`:e===`add`?n<500?`That line wasn't added: it needs a few words of text.`:`That line wasn't added: the Change Log couldn't be written. ${r}`:e===`export`?`The Markdown wasn't saved: the Change Log couldn't be read or written. ${r}`:n<500?`The Change Log couldn't show that filter. Choose All and try again.`:`The Change Log couldn't be read. ${r}`}function Ac(e,t){if(!e||e===t)return!1;if(!t)return!0;let n=e=>Date.parse(e.slice(e.lastIndexOf(`@`)+1)),r=n(e),i=n(t);return!(Number.isFinite(r)&&Number.isFinite(i)&&r<i)}function jc(e,t){return`rushes:${e}:${t}`}function Mc(e,t){try{return e?.getItem(t)??null}catch{return null}}function Nc(e,t,n){try{e?.setItem(t,n)}catch{}}var Pc=1e3,Fc=40,Ic=()=>{try{return window.sessionStorage}catch{return}},Lc=()=>{try{return window.localStorage}catch{return}};function Rc(e,t){let[n,r]=q(()=>Mc(Ic(),jc(e,`log-open`))===`1`),[i,a]=q(!1),[o,s]=q(()=>Mc(Lc(),jc(e,`log-seen`))),c=t?.mark??null,l=X(o);l.current=o;let u=t=>{s(t),Nc(Lc(),jc(e,`log-seen`),t)};return J(()=>{n&&c&&Ac(c,o)&&u(c)},[n,c]),J(()=>{let t=jc(e,`log-seen`),n=e=>{e.key===t&&e.newValue&&s(e.newValue)};return window.addEventListener(`storage`,n),()=>window.removeEventListener(`storage`,n)},[e]),{open:n,focusOnOpen:i,dot:!n&&Ac(c,o),setOpen:t=>{r(t),a(t),Nc(Ic(),jc(e,`log-open`),t?`1`:`0`)},saw:e=>{Ac(e,l.current)&&u(e)}}}function zc(){return Q(`svg`,{class:`ic`,viewBox:`0 0 24 24`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.75`,"stroke-linecap":`round`,"stroke-linejoin":`round`,children:[Q(`path`,{d:`M3 12a9 9 0 1 0 3-6.7L3 8`}),Q(`path`,{d:`M3 3v5h5`}),Q(`path`,{d:`M12 7v5l3 2`})]})}function Bc({log:e,buttonRef:t}){return Q(`button`,{ref:t,type:`button`,class:`btn clog tip-below`,"data-tip":`Change Log`,"aria-label":e.dot?`Change Log (new entries)`:`Change Log`,"aria-expanded":e.open,"aria-controls":e.open?`changelog`:void 0,onClick:()=>e.setOpen(!e.open),children:[Q(zc,{}),Q(`span`,{class:`clabel`,children:`Change Log`}),e.dot&&Q(`span`,{class:`cdot`,"aria-hidden":`true`})]})}function Vc(e){let t=0,n=()=>{let r=document.querySelector(`.lane[data-row="${CSS.escape(e)}"] .nm`);if(r){r.scrollIntoView({block:`nearest`}),r.focus({preventScroll:!0});return}++t<60&&requestAnimationFrame(n)};requestAnimationFrame(n)}function Hc(e){return e.log.open?Q(Wc,{...e}):null}function Uc({entry:e,to:t,onGo:n}){let r=Zi(new Date(e.at)),i=Q(S,{children:[Q(`span`,{class:`ltime`,children:r}),Q(`span`,{class:`ltag ${e.area}`,children:Gi[e.area]}),Q(`span`,{class:`ltext`,dir:`auto`,children:[e.text,Q(`span`,{class:`lby`,children:yc[e.by]})]}),Q(`span`,{class:`lgo`,"aria-hidden":`true`,children:t?`›`:``})]});return t?Q(`button`,{type:`button`,class:`lrow`,"data-entry":e.id,"data-go":``,"aria-label":Oc(e,r),onClick:()=>n(t),children:i}):Q(`div`,{class:`lrow`,"data-entry":e.id,children:i})}function Wc({log:e,projectId:t,head:n,project:r,stage:i,header:a,buttonRef:o,toast:s,onJump:c}){let[l,u]=q(null),[d,f]=q(null),[p,m]=q(null),[h,g]=q(()=>{let e=Mc(Ic(),jc(t,`log-filter`));return vc(e)?e:`all`}),[_,v]=q(``),y=X(null),b=X(null),x=X(null),S=X({}),C=X(null);C.current=l;let w=X(h);w.current=h;let T=X(0),E=()=>(b.current?.scrollTop??0)>Fc,D=t=>{u(t),f(null),w.current===`all`&&t.entries[0]&&e.saw(`${t.entries[0].id}@${t.entries[0].at}`)},O=async(e=!1)=>{let t=++T.current,n=new URLSearchParams({limit:String(Pc)});w.current!==`all`&&n.set(`area`,w.current);try{let r=await Z.get(`/api/log?${n}`);if(t!==T.current)return;m(null),!e&&C.current&&E()?f(r):D(r)}catch(e){if(t!==T.current)return;C.current?s(kc(`read`,e)):m(kc(`read`,e))}};J(()=>{b.current&&(b.current.scrollTop=0),f(null),O(!0)},[h]);let k=X(!0);J(()=>{if(k.current){k.current=!1;return}O()},[n?.rev,n?.mark]),Y(()=>{let e=a.current;if(!e)return;let t=()=>{y.current&&(y.current.style.top=`${Math.max(0,Math.round(e.getBoundingClientRect().bottom))}px`)};t();let n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),window.addEventListener(`scroll`,t,{passive:!0}),()=>{n.disconnect(),window.removeEventListener(`resize`,t),window.removeEventListener(`scroll`,t)}},[]),Y(()=>{e.focusOnOpen&&x.current?.focus()},[]);let A=()=>{e.setOpen(!1),o.current?.focus()};Y(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target;(!t||t===document.body||t===document.documentElement||t===o.current||y.current?.contains(t))&&(e.preventDefault(),A())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let j=async()=>{let e=_.trim();if(e)try{if(await Z.post(`/api/log`,{text:e,area:i}),v(``),!xc(h,i)){let e=Gi[i];s(`Added under ${e}. Choose All${_c.some(([e])=>e===i)?` or ${e}`:``} to see it.`)}b.current&&(b.current.scrollTop=0),await O(!0)}catch(e){s(kc(`add`,e))}},M=e=>{g(e),Nc(Ic(),jc(t,`log-filter`),e)},N=(e,t)=>{let n=sa(e.key,t,_c.length,!0);if(n===null)return;e.preventDefault();let r=_c[n][0];M(r),S.current[r]?.focus()},P=()=>{d&&(D(d),b.current&&(b.current.scrollTop=0),requestAnimationFrame(()=>{let e=b.current?.querySelector(`.lrow`);(e instanceof HTMLButtonElement?e:b.current)?.focus({preventScroll:!0})}))},F=()=>{d&&!E()&&D(d)},I=t=>{c(t),window.innerWidth<560&&(e.setOpen(!1),o.current?.focus())},L=X(I);L.current=I;let ee=X(e=>L.current(e)).current,te=async()=>{try{s(`Saved to ${(await Z.post(`/api/exports/change-log`,{})).path}`)}catch(e){s(kc(`export`,e))}},R=yr(()=>l?bc(l.entries,new Date).map(e=>Q(`div`,{class:`dgroup`,children:[Q(`h3`,{class:`dday`,children:e.heading}),Q(`ul`,{children:e.entries.map(e=>Q(`li`,{children:Q(Uc,{entry:e,to:Tc(e,r),onGo:ee})},e.id))})]},e.key)):null,[l,r,Qi(new Date)]),ne=l&&d?Ec(l.entries,d.entries):0,z=l!==null&&l.total===0&&l.undated.length===0,re=l!==null&&!z&&l.entries.length===0&&l.undated.length===0;return Q(`aside`,{id:`changelog`,class:`drawer`,ref:y,"aria-label":`Change Log`,onKeyDown:e=>{Cc(e)&&e.stopPropagation()},children:[Q(`div`,{class:`dhead`,children:[Q(`h2`,{children:`Change Log`}),Q(`span`,{class:`dquiet`,children:`newest first`}),Q(`button`,{type:`button`,class:`btn dclose`,"aria-label":`Close the change log`,onClick:A,children:`Close`})]}),Q(`form`,{class:`dadd`,onSubmit:e=>{e.preventDefault(),j()},children:[Q(`input`,{ref:x,value:_,maxLength:160,placeholder:`Add a line to the log`,"aria-label":`Add a line to the log`,onInput:e=>v(e.target.value)}),Q(`button`,{type:`submit`,class:`btn`,children:`Add`})]}),Q(`div`,{class:`dchips`,role:`radiogroup`,"aria-label":`Show`,children:_c.map(([e,t],n)=>Q(`button`,{type:`button`,role:`radio`,"aria-checked":h===e,tabIndex:h===e?0:-1,ref:t=>{S.current[e]=t},onClick:()=>M(e),onKeyDown:e=>N(e,n),children:t}))}),Q(`div`,{class:`dwrap`,children:[ne>0&&Q(`button`,{type:`button`,class:`dpill`,onClick:P,children:[ne,` new`]}),Q(`div`,{class:`dlist`,ref:b,tabIndex:0,role:`group`,"aria-label":`Entries`,onScroll:F,children:[l===null&&!p&&Q(`p`,{class:`dempty`,children:`Loading…`}),l===null&&p&&Q(`p`,{class:`dempty dproblem`,role:`alert`,children:p}),z&&Q(`p`,{class:`dempty`,children:`Nothing yet. Rushes writes a line here whenever a cut, a take or a variant is added.`}),re&&Q(`p`,{class:`dempty`,children:`Nothing for this filter.`}),R,l&&l.undated.length>0&&Q(`section`,{class:`dbefore`,"aria-label":`Before the log`,children:[Q(`h3`,{children:`Before the log`}),Q(`ul`,{children:l.undated.map((e,t)=>Q(`li`,{children:e.text},t))})]})]})]}),Q(`div`,{class:`dfoot`,children:[Q(`span`,{children:l?Dc(l):``}),Q(`button`,{type:`button`,class:`btn`,onClick:()=>void te(),children:`Export as Markdown`})]})]})}var Gc=[`script`,`picture`,`voice`,`music`,`sfx`,`mix`],Kc=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function qc({tab:e,projectName:t,filmName:n,found:r,onReview:i,toast:a}){let o=e===`brief`||e===`storyboard`,{what:s,unlocks:c}=e===`brief`?Me:e===`storyboard`?Ne:Te[e],l=e===`assets`?`Assets`:e===`brief`?`Brief`:e===`storyboard`?`Storyboard`:we[e],u=e===`assets`?`grid`:e===`brief`?`brief`:e===`storyboard`?`story`:da[e],d=e===`brief`?Pe(t,n):e===`storyboard`?Fe(t,n):Oe(e,t,n),f=o?null:On(e,r),p=X(null),m=async()=>{try{await navigator.clipboard.writeText(d),a(`Prompt copied`)}catch{p.current?.select(),a(`Prompt selected: press ${Cn(navigator.platform)}`)}};return Q(`div`,{class:`empty locked`,children:[Q($,{name:u}),Q(`h2`,{children:l}),Q(`p`,{children:s}),Q(`p`,{children:c}),Q(`textarea`,{class:`promptbox mono`,readOnly:!0,rows:4,ref:p,value:d,"aria-label":`Prompt for your agent`}),Q(`button`,{class:`btn primary`,onClick:()=>void m(),children:[Q($,{name:`copy`}),`Copy prompt for your agent`]}),f&&Q(`p`,{class:`foundline`,children:[Q(`span`,{children:f.text}),Q(`button`,{type:`button`,class:`btn`,"aria-label":f.review,onClick:()=>i(f.kind),children:`Review`})]})]})}function Jc(){let{state:e,assets:t,problem:n,wrongProject:r,refresh:i,proxyJobs:a,noteProxyJob:o}=Gr(),[s,c]=q(null),[l,u]=q(null),[d,f]=q(null),[p,m]=q(null),[h,g]=q(null),[_,v]=q(`script`),y=X(null),[b,x]=q(!1),[C,w]=q(!1),[T,E]=q(!1),[D,O]=q(!1),[k,A]=q(0),[j,M]=q({}),N=X(void 0),P=X(new Map),F=X(null),I=(e,t)=>M(n=>({...n,[e]:t})),[L,ee]=q({}),te=(e,t)=>ee(n=>({...n,[e]:t})),[R,ne]=q({}),[z,re]=q({}),[ie,ae]=q(!1),B=X(new Set),V=(e,t=2400)=>{m(e),clearTimeout(N.current),N.current=window.setTimeout(()=>m(null),t)},[oe,se]=q({n:0,pending:!1}),[ce,le]=q(null),H=Rc(Ar()??``,e?.log),ue=X(null);J(()=>{for(let e of Object.values(a))e.state!==`failed`||B.current.has(e.job)||(B.current.add(e.job),V(e.reason??`Couldn't make the proxy`))},[a]),J(()=>{if(e){if(s===null){let t=Be(e.tabs,e.brief);c(t),Ae(t)&&v(t)}l===null&&e.project.videos[0]&&u(e.project.videos[0].id)}},[e]),J(()=>{e?.project.name&&(document.title=`${e.project.name} · Rushes`)},[e?.project.name]);let U=e?.project.videos.find(e=>e.id===l)??e?.project.videos[0],W=xe(U),pe=Se(U),G=U?.versions.find(e=>e.id===d)??pe,me=!!U?.lockedVersion,ge=G?.fps??e?.project.fps??30,_e=G?t.find(e=>e.kind===`cut`&&e.path===G.file):void 0,ve=e?.notes.notes.filter(e=>e.stage===`picture`&&(!e.video||e.video===U?.id))??[],ye=G?fe(G,z[G.file]):[],be=U&&G?Un(U,G.id):void 0,Ee=Wn(ye,U?R[U.id]:void 0),De=new Set(t.filter(e=>e.kind===`cut`&&e.missing).map(e=>e.path)),Oe=G?Gn({views:ye,previous:be?fe(be):[],current:Ee,versionDuration:G.duration,notes:ve,missing:De}):[],ke=e=>!U||e===Ee?!1:ie?(V(`Add or clear your box on ${Ee?de(Ee):`this format`} first`),!1):(ne(t=>({...t,[U.id]:e})),!0);J(()=>{T&&d===null&&pe?(f(pe.id),O(!0)):!T&&D&&d===pe?.id&&(f(null),O(!1))},[T,d,pe?.id]),J(()=>{!D&&d!==null&&d===pe?.id&&f(null)},[pe?.id,D,d]);let Pe=W&&G&&W.id!==G.id&&(me||D)?W.id:null,Fe=()=>{W&&f(W.id),O(!1)},ze=e=>{if(!U||e===U.id)return;if(T)return V(`Add or clear your note on ${U.name} first`);let t=F.current;t?.pause();let n=t?he(t.currentTime,ge):P.current.get(U.id)?.t??0;P.current.set(U.id,{versionId:d,held:D,t:n});let r=P.current.get(e);u(e),f(r?.versionId??null),O(r?.held??!1),A(r?.t??0)},He=async()=>{if(U&&G)try{await Z.put(`/api/videos/${U.id}/lock`,{version:U.lockedVersion?null:G.id}),i()}catch(e){V(e.message)}},Ue=t=>{if(T)return V(`Add or clear your note first`);if(t.tab===`assets`)return Xe();if(t.video&&t.video!==U?.id&&ze(t.video),t.version){let n=e?.project.videos.find(e=>e.id===(t.video??U?.id));f(t.version===Se(n)?.id?null:t.version),O(!1)}c(t.tab),g(null),t.row&&Vc(t.row)},We=e?.tabs??[],Ge=e=>We.find(t=>t.stage===e),Ke=kn(e?.found),qe=t.length>0||Ke!==null,Je=e=>{if(T&&e!==s)return V(`Add or clear your note first`);c(e),g(null),Ae(e)&&v(e)},Ye=()=>{let t={brief:!!e?.brief.exists,script:!!Ge(`script`)?.unlocked,storyboard:!!e?.storyboard.exists};Je(Ve(_,t))},Xe=()=>{if(T&&s!==`assets`)return V(`Add or clear your note first`);c(`assets`),g(null)},Ze=e=>{if(T&&s!==`assets`)return V(`Add or clear your note first`);se(t=>({n:t.n+1,kind:e,pending:!0})),c(`assets`),g(null)},Qe=X(Ze);Qe.current=Ze,J(()=>{Rt(location.search).test&&(window.__rushesOpenFound=e=>Qe.current(e))},[]),Y(()=>{let t=t=>{if(t.altKey&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&(t.key===`ArrowLeft`||t.key===`ArrowRight`)){if(s!==`picture`||Kc(t.target))return;t.preventDefault();let e=Kn(Oe,Ee,t.key===`ArrowRight`?1:-1);e&&ke(e);return}if(Kc(t.target)||t.metaKey||t.ctrlKey||t.altKey)return;let n=Number(t.key);if(n===1?Ye():n>=2&&n<=6?Je(Gc[n-1]):n===7&&Xe(),(t.key===`[`||t.key===`]`)&&e){let n=Ce(e.project.videos,l,t.key===`]`?1:-1);n&&ze(n)}t.key===`?`&&x(e=>!e),t.key===`Escape`&&(x(!1),g(null))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)});let $e=X(null),et=X(null),tt=X(null),nt=()=>{let e=$e.current;if(!e)return;let t=`${Math.round(e.getBoundingClientRect().top+window.scrollY)}px`,n=document.documentElement.style;n.getPropertyValue(`--body-top`)!==t&&n.setProperty(`--body-top`,t)};Y(nt),J(()=>{let e=()=>nt();window.addEventListener(`resize`,e);let t=!0;return document.fonts?.ready.then(()=>{t&&nt()}),()=>{t=!1,window.removeEventListener(`resize`,e)}},[]);let rt=!!e&&!!s;J(()=>{if(!rt)return;let e=new ResizeObserver(()=>nt());for(let t of[et.current,tt.current])t&&e.observe(t,{box:`border-box`});return()=>e.disconnect()},[rt]);let it=async()=>{if(s&&s!==`assets`){if(x(!1),s===`brief`){if(!e)return;if(!e.brief.exists)return V(`There's no brief yet: copy the prompt on this page for your agent`);let t=await y.current?.()??e.brief;g({id:`brief`,title:`Message for your agent`,prompt:Le(e.project.name,U?.name??null,t)}),w(!1);return}if(s===`storyboard`){if(!e)return;if(!e.storyboard.exists)return V(`There's no storyboard yet: copy the prompt on this page for your agent`);let t=await y.current?.()??e.storyboard;g({id:`storyboard`,title:`Message for your agent`,prompt:Re(e.project.name,U?.name??null,t)}),w(!1);return}try{let{batch:e}=await Z.post(`/api/batches`,{stage:s});g(e),w(!1),i()}catch(e){V(e instanceof kr&&e.code===`empty_batch`?`Nothing open on ${we[s]} to send`:e.message)}}},at=async()=>{if(h)try{await navigator.clipboard.writeText(h.prompt),w(!0)}catch{V(`Couldn't reach the clipboard. Select the text and copy it.`)}};if(!e||!s)return Q(`div`,{class:`shell`,children:n?Q(`div`,{class:`banner`,children:[Q($,{name:`alert`}),n]}):Q(`div`,{class:`empty`,children:Q(`p`,{children:`Loading…`})})});let ot=e.notes.notes.filter(e=>e.stage===`picture`&&(!e.video||e.video===U?.id)),st=t=>e.notes.notes.some(e=>e.stage===`picture`&&e.status===`todo`&&(!e.video||e.video===t)),ct=s===`assets`?qe:s===`brief`?e.brief.exists:s===`storyboard`?e.storyboard.exists:Ge(s)?.unlocked??!1,lt=s===`assets`?0:s===`brief`?e.brief.changed:s===`storyboard`?e.storyboard.changed:Ge(s)?.todo??0,ut=!!Ge(`picture`)?.unlocked,dt=je(e.brief,e.script.sections,e.storyboard),ft=e.build.started&&!ut,pt=[{page:`brief`,name:`Brief`,icon:`brief`,unlocked:e.brief.exists,progress:ft?dt.brief:null,ask:Me.ask},{page:`script`,name:`Script`,icon:da.script,unlocked:!!Ge(`script`)?.unlocked,progress:ft&&Ge(`script`)?.unlocked?dt.script:null,ask:Te.script.ask},{page:`storyboard`,name:`Storyboard`,icon:`story`,unlocked:e.storyboard.exists,progress:ft&&e.storyboard.exists?dt.storyboard:null,ask:Ne.ask}],mt=e.brief.changed+e.storyboard.changed+(Ge(`script`)?.todo??0),ht=async()=>{try{await navigator.clipboard.writeText(Ie(e.project.name,U?.name??null)),V(`Prompt copied`)}catch{V(`Couldn't reach the clipboard. Ask your agent to build the film from the approved plan.`)}};return Q(`div`,{class:`shell`,children:[Q(`header`,{class:`head`,ref:et,children:[Q(`span`,{class:`logo`,children:Q(`svg`,{viewBox:`0 0 24 24`,children:Q(`path`,{d:`M8 5v14l11-7z`})})}),Q(`nav`,{class:`crumb`,"aria-label":`Project`,children:[Q(`span`,{children:e.project.name}),e.project.id&&Q(`span`,{class:`pid mono`,children:e.project.id}),U&&e.project.videos.length===1&&Q(S,{children:[Q(`span`,{class:`slash`,children:`/`}),Q(`span`,{class:`sel`,children:U.name})]})]}),Ke!==null&&An(e.found)!==ce&&Q(`button`,{type:`button`,class:`foundchip`,"data-tip":`Open the other files found in this project`,onClick:()=>Ze(),children:[Q(`span`,{class:`dot`}),Q(`span`,{class:`ftext`,children:Ke})]}),U&&e.project.videos.length>1&&Q(`nav`,{class:`pack`,"aria-label":`Films`,children:e.project.videos.map((e,t)=>Q(`button`,{class:`pill`,"aria-pressed":e.id===U.id,onClick:()=>ze(e.id),children:[Q(`span`,{class:`n`,children:t+1}),Q(`span`,{class:`pname`,children:e.name}),st(e.id)&&Q(`span`,{class:`dot`})]}))}),U&&Q(S,{children:[Q(`span`,{class:`plabel`,children:`Picture`}),G&&Q(zs,{versions:U.versions,shown:G,lockedVersion:U.lockedVersion,onPick:e=>{f(e===pe?.id?null:e),O(!1)}}),G&&Q(`button`,{class:`btn ib lockbtn`,"aria-pressed":me,"aria-label":me?`Picture locked at ${U.lockedVersion} · unlock`:`Lock picture at ${G.id}`,"data-tip":me?`Picture locked at ${U.lockedVersion} · unlock`:`Lock picture at ${G.id}`,onClick:()=>void He(),children:Q($,{name:me?`lock`:`unlock`})}),Pe&&Q(`button`,{class:`chipx go`,"aria-label":`${Pe} is ready`,"data-tip":`Switch to the newest cut`,onClick:Fe,children:[Q($,{name:`new`}),Pe,` ready`]}),s===`picture`&&G&&Oe.length>0&&Q(no,{chips:Oe,versionId:G.id,prompt:Xn(e.project.name,U.name,G.id),onSelect:ke,toast:V})]}),Q(`span`,{class:`sp`}),Q(`button`,{class:`btn ghost ib tip-below`,"data-tip":`Shortcuts ?`,"aria-label":`Keyboard shortcuts`,onClick:()=>{g(null),x(!b)},children:Q($,{name:`kbd`})}),Q(Bc,{log:H,buttonRef:ue}),Q(`button`,{class:`btn primary`,"aria-disabled":s===`assets`,tabIndex:s===`assets`?-1:void 0,"data-tip":s===`assets`?`Nothing to send from Assets`:void 0,onClick:()=>void it(),children:[`Send to agent`,lt>0&&Q(`span`,{class:`count`,children:lt})]})]}),Q(Hc,{log:H,projectId:Ar()??``,head:e.log,project:e.project,stage:s===`brief`||s===`storyboard`?`script`:s,header:et,buttonRef:ue,toast:V,onJump:Ue}),h&&Q(`div`,{class:`pop`,role:`dialog`,"aria-label":`Sent to agent`,children:[Q(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[Q(`h3`,{children:h.title??`Batch ${h.id} is ready`}),Q(`span`,{class:`sp`}),Q(`button`,{class:`btn ghost ib sm`,"aria-label":`Close`,onClick:()=>g(null),children:Q($,{name:`x`})})]}),Q(`pre`,{children:h.prompt}),Q(`div`,{style:{display:`flex`,justifyContent:`flex-end`},children:Q(`button`,{class:`btn primary`,onClick:()=>void at(),children:[Q($,{name:`copy`}),C?`Copied`:`Copy prompt`]})})]}),b&&Q(`div`,{class:`pop`,role:`dialog`,"aria-label":`Keyboard shortcuts`,style:{width:`300px`},children:[Q(`div`,{style:{display:`flex`,alignItems:`center`},children:[Q(`h3`,{children:`Shortcuts`}),Q(`span`,{class:`sp`}),Q(`button`,{class:`btn ghost ib sm`,"aria-label":`Close`,onClick:()=>x(!1),children:Q($,{name:`x`})})]}),Q(`div`,{class:`keys`,children:[Q(`span`,{children:Q(`kbd`,{children:`Space`})}),Q(`span`,{children:`Play or pause`}),Q(`span`,{children:[Q(`kbd`,{children:`←`}),` `,Q(`kbd`,{children:`→`})]}),Q(`span`,{children:`Step one frame (Shift: ten)`}),Q(`span`,{children:[Q(`kbd`,{children:`I`}),` `,Q(`kbd`,{children:`O`})]}),Q(`span`,{children:`Set in and out`}),Q(`span`,{children:Q(`kbd`,{children:`B`})}),Q(`span`,{children:`Draw a box`}),Q(`span`,{children:Q(`kbd`,{children:`G`})}),Q(`span`,{children:`Grab frame`}),Q(`span`,{children:Q(`kbd`,{children:`N`})}),Q(`span`,{children:`New note`}),Q(`span`,{children:[Q(`kbd`,{children:`1`}),`–`,Q(`kbd`,{children:`7`})]}),Q(`span`,{children:`Switch tab`}),Q(`span`,{children:[Q(`kbd`,{children:`[`}),` `,Q(`kbd`,{children:`]`})]}),Q(`span`,{children:`Previous or next film`}),Q(`span`,{children:[Q(`kbd`,{children:`Alt`}),` `,Q(`kbd`,{children:`←`}),` `,Q(`kbd`,{children:`→`})]}),Q(`span`,{children:`Previous or next format`}),Q(`span`,{children:Q(`kbd`,{children:`?`})}),Q(`span`,{children:`Shortcuts`}),Q(`span`,{children:Q(`kbd`,{children:`Esc`})}),Q(`span`,{children:`Close`})]})]}),p&&Q(`div`,{class:`toast`,role:`status`,children:p}),r&&Q(`div`,{class:`banner lost`,role:`alert`,children:[Q($,{name:`alert`}),`This tab is for ${e.project.name}, which isn't running here any more. Ask your agent to open it again.`]}),Q(`nav`,{class:`tabs`,ref:tt,role:`tablist`,"aria-label":`Stages`,children:[Q(Qs,{selected:Ae(s)?s:null,rows:pt,marks:ft?dt:null,open:mt,locked:pt.every(e=>!e.unlocked),ready:ft&&e.build.ready,onCopyReady:()=>void ht(),onPick:e=>Je(e)}),Gc.filter(e=>e!==`script`).map(e=>{let t=Ge(e);return Q(`button`,{class:`tab`,role:`tab`,"aria-selected":s===e,"data-locked":t?.unlocked?void 0:`true`,"data-tip":t?.unlocked?void 0:`Locked: ask your agent for ${Te[e].ask}`,onClick:()=>Je(e),children:[Q($,{name:da[e]}),we[e],t?.unlocked?t.todo>0&&Q(`span`,{class:`dot`,title:`${t.todo} open`}):Q(S,{children:[Q($,{name:`lock`,class:`lk`}),Q(`span`,{class:`vh`,children:` Locked`})]})]})}),Q(`button`,{class:`tab`,role:`tab`,"aria-selected":s===`assets`,"data-locked":qe?void 0:`true`,"data-tip":qe?void 0:`Locked: ask your agent for ${Te.assets.ask}`,onClick:()=>Xe(),children:[Q($,{name:`grid`}),`Assets`,!qe&&Q(S,{children:[Q($,{name:`lock`,class:`lk`}),Q(`span`,{class:`vh`,children:` Locked`})]})]})]}),n&&!r&&Q(`div`,{class:`banner`,children:[Q($,{name:`alert`}),n]}),Q(`main`,{class:`body`,ref:$e,children:s===`assets`?ct?Q(Ja,{assets:t,videos:e.project.videos,state:e,foundRequest:oe,onFoundRequestUsed:()=>se(e=>e.pending?{n:e.n,pending:!1}:e),onFoundSeen:le,toast:V,onChanged:()=>void i()}):Q(qc,{tab:`assets`,projectName:e.project.name,filmName:U?.name??null,found:e.found?.counts,onReview:Ze,toast:V}):ct?s===`picture`&&U&&G?Q(Us,{video:U,version:G,fps:ge,notes:ot,toast:V,onChanged:()=>void i(),onPendingChange:E,startAt:k,grab:j[U.id]??null,onGrabChange:I,playerRef:F,ffmpeg:e.proxies?.ffmpeg??!1,autoProxy:e.project.autoProxy,proxyJob:a[gn(U.id,G.id)],noteProxyJob:o,source:L[U.id]??`proxy`,onSourceChange:te,fileSize:_e?.size??null,fileRev:_e?qr(_e):void 0,formats:ye,format:Ee,formatMissing:!!Ee&&De.has(ye.find(e=>e.id===Ee)?.file??``),onPrimarySize:(e,t,n)=>re(r=>r[e]?r:{...r,[e]:{width:t,height:n}}),onBoxPendingChange:ae,onFormatChange:ke},U.id):s===`brief`?Q(eo,{brief:e.brief,toast:V,onChanged:()=>void i(),settle:y}):s===`storyboard`?Q(Zs,{board:e.storyboard,brief:e.brief,toast:V,onChanged:()=>void i(),settle:y}):s===`script`?Q(rc,{script:e.script,toast:V,onChanged:()=>void i()}):s===`voice`?Q(gc,{state:e,assets:t,video:U??null,toast:V,onChanged:()=>void i(),onPendingChange:E},`voice`):s===`mix`?Q(ss,{state:e,assets:t,video:U??null,toast:V,onChanged:()=>void i(),onPendingChange:E},`mix`):s===`music`||s===`sfx`?Q(cc,{stage:s,state:e,assets:t,video:U??null,toast:V,onChanged:()=>void i(),onPendingChange:E},s):null:Q(qc,{tab:s,projectName:e.project.name,filmName:U?.name??null,found:e.found?.counts,onReview:Ze,toast:V})})]})}Ft(document),ie(Q(Jc,{}),document.getElementById(`app`));
@@ -5,8 +5,8 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>Rushes</title>
7
7
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect width='24' height='24' rx='6' fill='%237c93ff'/%3E%3Cpath d='M9 7v10l8-5z' fill='%230b1026'/%3E%3C/svg%3E" />
8
- <script type="module" crossorigin src="/assets/index-C9dBtlRy.js"></script>
9
- <link rel="stylesheet" crossorigin href="/assets/index-BDMm5p1-.css">
8
+ <script type="module" crossorigin src="/assets/index-CCD0ugOe.js"></script>
9
+ <link rel="stylesheet" crossorigin href="/assets/index-C-0jcf9a.css">
10
10
  </head>
11
11
  <body>
12
12
  <div id="app"></div>