rushes 0.2.1 → 0.3.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.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +36 -8
- package/README.md +75 -4
- package/dist/cli/doctor.js +35 -10
- package/dist/cli/main.js +200 -18
- package/dist/core/batches.js +35 -3
- package/dist/core/exportNotes.js +9 -5
- package/dist/core/formats.js +159 -0
- package/dist/core/found.js +333 -0
- package/dist/core/labels.js +192 -0
- package/dist/core/log.js +190 -0
- package/dist/core/logEvents.js +193 -0
- package/dist/core/logText.js +122 -0
- package/dist/core/media.js +119 -13
- package/dist/core/notes.js +35 -4
- package/dist/core/project.js +69 -1
- package/dist/core/schema.js +147 -1
- package/dist/core/store.js +19 -3
- package/dist/mcp/client.js +13 -1
- package/dist/mcp/tools.js +181 -11
- package/dist/server/app.js +495 -38
- package/dist/server/assets.js +19 -7
- package/dist/server/files.js +61 -4
- package/dist/server/found.js +1216 -0
- package/dist/server/logbook.js +208 -0
- package/dist/server/loudness.js +7 -3
- package/dist/server/peaks.js +3 -2
- package/dist/server/proxy.js +16 -4
- package/dist/server/start.js +15 -2
- package/package.json +1 -1
- package/skills/rushes/SKILL.md +9 -4
- package/web-dist/assets/index-BDMm5p1-.css +1 -0
- package/web-dist/assets/index-C9dBtlRy.js +3 -0
- package/web-dist/index.html +2 -2
- package/web-dist/assets/index-ChXjhVC5.js +0 -3
- package/web-dist/assets/index-Cj_tr1I-.css +0 -1
|
@@ -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),F(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,L(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=F(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 ee(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function N(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||ee(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ee(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 P(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 F(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,ee,N,P=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 P==`function`){f=s.length;try{if(E=n.props,D=P.prototype&&P.prototype.render,O=(d=P.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 P(E,A):(n.__c=p=new C(E,A),p.constructor=P,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&&P.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=v({},p.__s)),v(p.__s,P.getDerivedStateFromProps(E,p.__s))),g=p.props,b=p.state,p.__v=n,m)D&&P.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),D&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(D&&P.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)),ee=d!=null&&d.type===S&&d.key==null?te(d.props.children):d,c=k(e,_(ee)?ee:[ee],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(N=o.length;N--;)y(o[N])}else n.__e=r.__e;n.__k??=r.__k||[],e.then||I(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 I(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(I))}function L(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||N(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||N(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])&&N(n,d,v,x[d],o),d=`checked`,b!=null&&b!=n[d]&&N(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 B(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=[],F(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),L(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=P(!1),p=P(!0);var ie=[[1,1],[4,5],[5,4],[4,3],[3,4],[3,2],[2,3],[16,9],[9,16],[21,9],[9,21]],V=[`9x16`,`4x5`,`1x1`,`4x3`,`16x9`];function ae(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 H(e){let t=null,n=1/0;for(let r of ie){let i=Math.abs(Math.log(e/(r[0]/r[1])));i<n&&(n=i,t=r)}return{best:t,err:n}}function U(e,t){if(!ae(e,t))throw RangeError(`Not a picture size: ${e}×${t}`);let{best:n,err:r}=H(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 le=e=>e.replace(`:`,`x`),ue=e=>e.replace(`x`,`:`);function W(e){let t=e=>{let t=V.indexOf(e.id);return t===-1?V.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 de(e,t){let n=(e.width!==null&&e.height!==null&&ae(e.width,e.height)?{width:e.width,height:e.height}:null)??(t&&ae(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=U(n.width,n.height);return[{id:le(i),label:i,file:e.file,width:n.width,height:n.height,duration:e.duration,fps:e.fps,primary:!0},...r]}function G(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 fe(e,t){return t===null||e.format===null||e.format===t}function K(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 pe(e,t){return Math.round(e*t)}function me(e,t){return Math.round(pe(e,t)/t*1e6)/1e6}function he(e,t,n,r){let i=pe(e,t)+n;return Math.min(Math.max(0,i/t),r||1/0)}function ge(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 ${K(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 _e(e,t){return e===null?`Whole`:t===null?K(e):`${K(e)}–${K(t)}`}function ve(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 ye(e){return e.proposed!==null&&e.proposed.trim()!==e.current.trim()}function be(e){return e?.versions[e.versions.length-1]}function xe(e){if(e?.lockedVersion){let t=e.versions.find(t=>t.id===e.lockedVersion);if(t)return t}return be(e)}function Se(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 Ce={script:`Script`,picture:`Picture`,voice:`Voiceover`,music:`Music`,sfx:`Sound effects`,mix:`Mix`},we={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`}},Te=(e,t)=>t?` ${e} "${t}"`:``,Ee={script:(e,t)=>`In Rushes project "${e}", add the voiceover script${Te(`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${Te(`of`,t)} with rushes_add_version.`,voice:(e,t)=>`In Rushes project "${e}", record two or three voice reads${Te(`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${Te(`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${Te(`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${Te(`for`,t)}.`,assets:(e,t)=>`In Rushes project "${e}", add the first cut${Te(`of`,t)} with rushes_add_version.`};function De(e,t,n){return Ee[e](t,n)}function Oe(e){return e.find(e=>e.stage===`picture`)?.unlocked?`picture`:e.find(e=>e.unlocked)?.stage??`picture`}function ke(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 Ae(e){return String(e).padStart(2,`0`)}function je(e,t){return Math.ceil(e*t-1e-9)/t}function Me(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 Ne(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 Pe=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`]),Fe=new Set([`mp4`,`mov`,`m4v`,`webm`,`mkv`]);function Ie(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}var Le=[{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}],Re=new Set([`doc`,`caption`,`export`,`edit`]),ze=new Set([`md`,`txt`,`srt`,`vtt`]);function Be(e){return ze.has(Ie(e.path))}function Ve(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`)?He(u):u}function He(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 W(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 Ue(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 We(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 Ge(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 Ke={point:`Point`,range:`Range`,whole:`Whole`},qe=[`point`,`range`,`whole`];function Je(e){return(e??qe).filter(e=>e in Ke).map(e=>({value:e,label:Ke[e]}))}function Ye(e){return e.range.in!==null||e.marks.length>0||e.hasText}var Xe={voice:[`Speaker`,`Pacing`,`Tone`,`Overall`],music:[`Tempo`,`Key`,`Energy`,`Ending`],sfx:[`Timing`,`Level`,`Swap sound`,`Remove`],mix:[`Level`,`Balance`,`Loudness`]},Ze=[1,2,3,6,9],Qe=[`rise`,`fall`,`louder`,`quieter`],$e={rise:`fall`,fall:`rise`,louder:`quieter`,quieter:`louder`},et=e=>e===`louder`||e===`quieter`;function tt(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 nt(e){return e&&e.length>0?e.map(tt).join(` · `):null}function rt(e,t,n=3){let r=e.some(e=>e.kind===t),i=e.filter(e=>e.kind!==t&&e.kind!==$e[t]);return r||i.push(et(t)?{kind:t,db:n}:{kind:t}),i.sort((e,t)=>Qe.indexOf(e.kind)-Qe.indexOf(t.kind))}function it(e,t,n){return e.map(e=>e.kind===t&&et(t)?{kind:t,db:n}:e)}function at(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 ot(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:at(e.meta,t===`sfx`?e.cues.length:0),file:e.file,cues:e.cues});return n}function st(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 ct=e=>e.key,lt=(e,t)=>`${e.key}:${t}`;function ut(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 dt(e,t,n=!1){let r=e.map(e=>({value:`v:${e.key}`,label:t(e),on:ct(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:lt(n,e.id),t:e.t,row:n.key})}return r}function ft(e,t){if(t===null||!t.includes(`/`))return null;let n=e.find(e=>ct(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 pt(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 mt(e,t){if(t===null)return null;let n=ft(e,t)??pt(e,t);return n?{row:n.row.key,cue:n.cue}:null}function ht(e,t){return mt(e,t)?.row??null}function gt(e,t,n){let r=mt(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 _t(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 vt(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 yt=new WeakSet,bt=!1;function xt(e){bt||(bt=!0,e.addEventListener(`focusin`,e=>St(e.target),!0),e.addEventListener(`pointerdown`,e=>{let t=e.target?.closest?.(`button`);t&&yt.delete(t)},!0))}function St(e){let t=e;t&&typeof t.matches==`function`&&(t.matches(`:focus-visible`)?yt.add(t):yt.delete(t))}function Ct(e){let t=e;if(!t||typeof t.closest!=`function`)return!1;let n=t.closest(`button`);return!!n&&yt.has(n)&&!t.closest(`[data-player]`)}function wt(e){let t=new URLSearchParams(e),n=t.get(`test`)===`1`;return{test:n,streamOver:n&&t.get(`streamOver`)===`1`}}function Tt(e){return e.toUpperCase()}var Et=e=>`var:${e}`;function Dt(e,t){let n=e.filter(e=>e.stage===`voice`&&e.variants.length>0);return n.map((e,r)=>{let i=ot([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 Ot=e=>e.reads.find(t=>t.variant===e.pick)??null;function kt(e){for(let t=e.length-1;t>=0;t--){let n=Ot(e[t]);if(n)return n}return null}function At(e){let t=e.find(e=>e.current);return t?Ot(t)??t.reads[0]??null:null}var jt=e=>`${Et(e.lane)}/${e.variant}`;function Mt(e,t){let n=e.flatMap(e=>e.reads),r=n.find(e=>e.key===t)??At(e),i={},a={};for(let e of n)i[jt(e)]=e.key,a[jt(e)]=+(e.key===r?.key);return{select:i,gains:a}}var Nt=(e,t)=>!!e.sections?.some(e=>e.id===t);function Pt(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`||Nt(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 Ft(e,t){return Pt(e,t.on)?.read.key??null}function It(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:ct(e),row:e.key});return n}function Lt(e,t,n=e=>e.name){let r=Pt(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(Nt(e,t))return Tt(t);for(let n of e.sections??[]){let e=n.takes.findIndex(e=>`${n.id}:${e.id}`===t);if(e!==-1)return`${Tt(n.id)} · Take ${e+1}`}return null}var Rt=[`vo`,`music`,`sfx`],zt={vo:`voice`,music:`music`,sfx:`sfx`};function Bt(e,t){return Rt.filter(n=>e[n]&&(t[n]??1)>0).map(e=>zt[e])}function Vt(e,t){for(let n of[`music`,`sfx`]){let r=ft(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 Ht(e,t){if(t===null)return`mix`;let n=t.includes(`/`)?Vt(e,t):null;return n?n.lane:t===`vo`?`vo`:Vt(e,t)?.lane??null}function Ut(e,t){let n=Ht(e,t);return n===null||n===`mix`?[...Rt]:[n]}var Wt={vo:`Voiceover`,music:`Music`,sfx:`Sound effects`};function Gt(e,t){let n=Ht(e,t);return n===null?null:n===`mix`?`Whole mix`:n===`vo`?Wt.vo:`${Wt[n]} · ${Vt(e,t).row.name}`}function Kt(e){let t=[{value:`mix`,label:`Whole mix`,on:null}];e.heard.vo&&t.push({value:`vo`,label:Wt.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:`${Wt[n]} · ${r.name}`,on:ct(r),row:n});return t}var qt=.5;function Jt(e){let t=Math.round(e/qt)*qt;return Math.min(6,Math.max(-24,t))}function Yt(e,t=1){let n=Math.abs(e).toFixed(t);return Number(n)===0?n:`${e<0?`−`:`+`}${n}`}var Xt=`—`,Zt=`Install ffmpeg for loudness`;function Qt(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([Xt,e],[Xt,e],[Xt,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(Zt);let i=e=>r.silent?[`−∞`,`The mix is silent`]:e===null?[Xt,`Couldn't measure loudness`]:[Yt(e),null],a=r.silent?[`−∞`,`The mix is silent`]:r.musicUnderVo===null?[Xt,`Needs Voiceover and Music both playing`]:[`${Yt(r.musicUnderVo,0)} dB`,null];return t(i(r.integrated),i(r.truePeak),a)}function $t(e){return Math.max(10,Math.round((Number.isFinite(e)?e:0)/10)*10)}function en(e){return`Makes a lightweight 1080p copy on your drive so this cut previews smoothly. About ${$t(e)} MB. Your original isn't changed.`}var tn=(e,t)=>`${e}/${t}`;function nn(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 rn(e,t){let n=tn(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 an(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=rn(o,nn(e,n));return o}function on(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 sn(e,t){return e||(t?`The browser couldn't play this file`:null)}function cn(e){let t=[Me(e.size??0)];return e.width&&e.height&&t.push(`${e.width}×${e.height}`),e.version&&t.push(`from ${e.version}`),t.join(` · `)}function ln(e){return/Mac|iPhone|iPad|iPod/.test(e)?`⌘C`:`Ctrl+C`}var un=[`voice`,`music`,`sfx`,`other`,`cut`],dn={voice:`Voiceover`,music:`Music`,sfx:`Sound effects`,other:`Other audio`,cut:`Cut`};function fn(e){return e?e.voice+e.music+e.sfx+e.cut+e.other:0}var pn={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 mn(e,t){let n=pn[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 hn(e){if(!e)return null;let t=e.broughtIn.length,n=fn(e.counts);return t>0&&n>0?`${t} brought in · ${n} more found`:t>0?`${t} brought in`:n>0?`${n} found`:null}function gn(e){return e?e.digest?`d:${e.digest}`:`${e.broughtIn.length}:${un.map(t=>e.counts[t]).join(`,`)}`:``}var _n=(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 vn(e,t){let n=new Map(e.map(e=>[e.path,e])),r=t.map(e=>{let t=n.get(e.path);return t&&_n(t,e)?t:e});return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r}function yn(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 bn=`\0cuts`;function xn(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:yn(r.folder),folder:r.folder,files:[]}),e.files.push(r)}let r=[...t.values()];return n.length&&r.push({key:bn,title:`Other cuts`,folder:null,files:n}),r}function Sn(e,t,n){let r=n.trim().toLowerCase();return e.filter(e=>(t===`all`||e.kind===t)&&(!r||e.path.toLowerCase().includes(r)))}function Cn(e){return un.map(t=>[t,e.filter(e=>e.kind===t).length]).filter(([,e])=>e>0)}function wn(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 Tn=e=>e.replace(/\.$/,``).replace(/^(\p{Lu})(?=\p{Ll})/u,e=>e.toLowerCase());function En(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=>Tn(e.reason)))].join(`; `);return`${e>0?`Brought in ${n(e)}.`:`Nothing was brought in.`} ${t.length} couldn't be added: ${r}.`}function Dn(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!==dn.voice?`Voiceover · ${r.name}`:dn[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 On(e,t){return e.item!==t.item||e.kind!==t.kind||e.ticked!==t.ticked||e.playing!==t.playing||e.failure!==t.failure}function kn(e,t){let n=e.versions.findIndex(e=>e.id===t);return n>0?e.versions[n-1]:void 0}function An(e,t){return e.length<2?null:t&&e.some(e=>e.id===t)?t:(e.find(e=>e.primary)??e[0]).id}function jn(e){if(e.views.length===0)return[];let t=e.views.length===1,n=new Set(e.views.map(e=>e.id));return W([...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`:G(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 Mn(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 Nn(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 Pn(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 Fn=e=>`repeat(${e}, minmax(0, 1fr))`;function In(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 Ln(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 Rn=(e,t)=>e.filter(e=>fe(e,t)),zn=(e,t)=>t===null?[]:e.filter(e=>!fe(e,t));function Bn(e,t,n){return e.box?t===null?!0:e.format===null?t===n:e.format===t:!1}var Vn=`A drawn box belongs to one frame, so this note stays on this format.`;function Hn(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 Un(e,t){return e.format===null?t?`All`:null:ue(e.format)}function Wn(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 Gn,q,Kn,qn,Jn=0,Yn=[],Xn=t,Zn=Xn.__b,Qn=Xn.__r,$n=Xn.diffed,er=Xn.__c,tr=Xn.unmount,nr=Xn.__;function rr(e,t){Xn.__h&&Xn.__h(q,e,Jn||t),Jn=0;var n=q.__H||(q.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function J(e){return Jn=1,ir(hr,e)}function ir(e,t,n){var r=rr(Gn++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):hr(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=q,!q.__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};q.__f=!0;var a=q.shouldComponentUpdate,o=q.componentWillUpdate;q.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)},q.shouldComponentUpdate=i}return r.__N||r.__}function Y(e,t){var n=rr(Gn++,3);!Xn.__s&&mr(n.__H,t)&&(n.__=e,n.u=t,q.__H.__h.push(n))}function ar(e,t){var n=rr(Gn++,4);!Xn.__s&&mr(n.__H,t)&&(n.__=e,n.u=t,q.__h.push(n))}function X(e){return Jn=5,or(function(){return{current:e}},[])}function or(e,t){var n=rr(Gn++,7);return mr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function sr(e,t){return Jn=8,or(function(){return e},t)}function cr(){var e=rr(Gn++,11);if(!e.__){for(var t=q.__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 lr(){for(var e;e=Yn.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(fr),t.__h.some(pr),t.__h=[]}catch(n){t.__h=[],Xn.__e(n,e.__v)}}}Xn.__b=function(e){q=null,Zn&&Zn(e)},Xn.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),nr&&nr(e,t)},Xn.__r=function(e){Qn&&Qn(e),Gn=0;var t=(q=e.__c).__H;t&&(Kn===q?(t.__h=[],q.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(fr),t.__h.some(pr),t.__h=[],Gn=0)),Kn=q},Xn.diffed=function(e){$n&&$n(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Yn.push(t)!==1&&qn===Xn.requestAnimationFrame||((qn=Xn.requestAnimationFrame)||dr)(lr)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),Kn=q=null},Xn.__c=function(e,t){t.some(function(e){try{e.__h.some(fr),e.__h=e.__h.filter(function(e){return!e.__||pr(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],Xn.__e(n,e.__v)}}),er&&er(e,t)},Xn.unmount=function(e){tr&&tr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{fr(e)}catch(e){t=e}}),n.__H=void 0,t&&Xn.__e(t,n.__v))};var ur=typeof requestAnimationFrame==`function`;function dr(e){var t,n=function(){clearTimeout(r),ur&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ur&&(t=requestAnimationFrame(n))}function fr(e){var t=q,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),q=t}function pr(e){var t=q;e.__c=e.__(),q=t}function mr(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function hr(e,t){return typeof t==`function`?t(e):t}var gr=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}};function _r(){let e=location.pathname.match(/\/p\/([a-z2-9]{8})\//);return e?e[1]:null}async function vr(e,t,n,r={}){let i=_r(),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 gr(o.status,c.error??`error`,c.message??`Request failed (${o.status})`);return c}var Z={get:e=>vr(`GET`,e),post:(e,t={})=>vr(`POST`,e,t),patch:(e,t)=>vr(`PATCH`,e,t),put:(e,t,n)=>vr(`PUT`,e,t,n),del:(e,t={})=>vr(`DELETE`,e,t)};async function yr(e,t,n,r=null){let i=_r(),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 gr(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 br(e){let t=_r();return`/media?path=${encodeURIComponent(e)}${t?`&project=${t}`:``}`}function xr(){let e=_r();return`/api/events${e?`?project=${e}`:``}`}var Sr=[`change`,`proxy`,`corrupt`],Cr=e=>`rushes-sse-v1-${e}`,wr=e=>`rushes-v1-${e}`,Tr=4e4,Er=5e3;function Dr(){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 Or(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`||Sr.includes(n)&&typeof r==`string`:!1}function kr(e,t){t.type===`open`?e.open():t.type===`error`?e.error():`data`in t&&e[t.type](t.data)}function Ar(e,t,n,r){let i=new e.EventSource(t),a=e=>{kr(n,e),r?.(e)};for(let e of Sr)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 jr(e,t,n,r=Dr()){let{locks:i,BroadcastChannel:a}=r;if(!i||!a){let e=Ar(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(wr(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,Tr+o()*Er))},b=e=>{p=e,s=`leader`,clearTimeout(h),u=Ar(r,t,n,_)},x=(a=!1)=>{let o=++f;m?.abort();let h=new AbortController;m=h;let g=!1;i.request(Cr(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=Ar(r,t,n))})},S=()=>{c||l||s!==`follower`||(x(!0),n.resync())};g.onmessage=e=>{s===`follower`&&!l&&Or(e.data)&&(y(),kr(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 Mr(){let[e,t]=J(null),[n,r]=J([]),[i,a]=J(null),[o,s]=J(!1),[c,l]=J({}),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=>an(t,e.proxies?.jobs??[],n,r)),a(null),s(!1)}else i.error instanceof gr&&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 Y(()=>{g();let e=jr(_r()??``,xr(),{change(){clearTimeout(u.current),u.current=window.setTimeout(()=>void g(),40)},proxy(e){let t=JSON.parse(e);l(e=>rn(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 wt(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=>rn(t,nn(e,performance.now())))}}function Nr(e){return e.rev?`${e.path}#${e.rev}`:e.path}function Pr(e){return e.modified?e.modified:e.size===null?void 0:String(e.size)}var Fr=.05,Ir=6e4;function Lr(e){return 10**(e/20)}function Rr(e){let t=e.some(e=>e.solo),n={};for(let r of e){let e=t?+!!r.solo:+!r.muted;n[r.id]=Lr(r.level??0)*e}return n}function zr(e,t){return+(e===t)}function Br(e,t){let n={};for(let r of e){let e=t[r.lane];n[r.id]=e===void 0?1:zr(e,r.id)}return n}function Vr(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 Hr(e,t,n){return Math.abs(e-t)>1/n+1e-9}function Ur(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 Wr(e,t){let n=new Float32Array(Math.max(0,Math.floor(t)));for(let r of e){let e=Ur(r,t);for(let t=0;t<n.length;t++)e[t]>n[t]&&(n[t]=e[t])}return n}function Gr(e){return Math.min(Ir,Math.max(1,Math.round(e*50)))}function Kr(e,t){return!t||e!==null&&e>qr}var qr=900;function Jr(e){qr=e??900}function Yr(e){return e!==null&&e>3456e5}function Xr(e,t,n,r=1/0,i=Fr){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 Zr(e,t){return e.map(e=>e.duration>0?e:{...e,duration:t[Nr(e)]??0})}function Qr(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 $r=null;function ei(e,t){let n=$r,r={owner:e,stop:t};if($r=r,n&&n.owner!==e)try{n.stop()}catch{}return()=>{$r===r&&($r=null)}}function ti(e){$r&&$r.owner===e&&($r=null)}function ni(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function ri(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 ii(e){let t=/^( *)([-*]|\d+\.)[ \t]+(.*)$/.exec(e);return t?{indent:t[1].length,ordered:/\d/.test(t[2]),content:t[3]}:null}function ai(e){let t=/^>\s?(.*)$/.exec(e);return t?t[1]:null}function oi(e){let t=ni(e).split(/\r\n|\r|\n|\u2028|\u2029/),n=[],r=[],i=null,a=()=>{r.length&&(n.push(`<p>${ri(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}>${ri(c[2])}</h${e}>`),s++;continue}let l=ai(e);if(l!==null){a(),o();let e=[l];s++;let r;for(;s<t.length&&(r=ai(t[s]))!==null;)e.push(r),s++;n.push(`<blockquote><p>${ri(e.join(` `))}</p></blockquote>`);continue}let u=ii(e);if(u&&u.indent<2){a(),(!i||i.ordered!==u.ordered)&&(o(),i={ordered:u.ordered,items:[]});let e=ri(u.content);s++;let n=[],r;for(;s<t.length&&(r=ii(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>${ri(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 si=/[\p{L}\p{N}]/u,ci=/\s/,li=/[_\-/]/,ui=/[\s,;:.\-–—(_/]+$/u,di=/^[\p{M}\u200d\ufe0f\u{1F3FB}-\u{1F3FF}\u{E0020}-\u{E007F}]$/u,fi=/^[\u{1F1E6}-\u{1F1FF}]$/u,pi=/[\uD800-\uDFFF]/gu,mi=/[\p{Cc}\p{Zl}\p{Zp}]+/gu,hi=/(?![\u200c\u200d\u{E0000}-\u{E007F}])\p{Cf}/gu,gi=/(\u{1F3F4})([\u{E0000}-\u{E007F}]*)|[\u{E0000}-\u{E007F}]+/gu,_i=/^[\p{Cf}\s\u034f\u115f\u1160\u17b4\u17b5\u2800\u3164\uffa0]*$/u;function vi(e){let t=e.replace(pi,`�`).replace(mi,` `).replace(hi,``).replace(gi,(e,t,n)=>t?t+n:``).replace(/\s+/g,` `).trim();return _i.test(t)?``:t}function yi(e){let t=[],n=!1,r=0;for(let i of e){let e=t.length-1;e>=0&&(n||di.test(i)||fi.test(i)&&r===1)?(t[e]+=i,r=fi.test(i)?r+1:r):(t.push(i),r=+!!fi.test(i)),n=i===``}return t}function bi(e,t){for(let n=e.length-1;n>0;n--)if(t.test(e[n]))return n;return-1}function xi(e,t){if(e.length<=t)return e;let n=Array.from(e);if(n.length<=t)return e;let r=yi(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&&!di.test(o))return o+`…`;let s=i.length,c=r[i.length];if(c!==void 0&&!ci.test(c)){let e=bi(i,ci);e<=0&&(e=bi(i,li)),e>0&&(s=e)}return i.slice(0,s).join(``).replace(ui,``)+`…`}var Si=[`;`,`. `,` — `,` (`],Ci=12;function wi(e,t){let n=0,r=0;for(let i of e){if(r++>=t)break;n+=i.length}return n}function Ti(e,t){let n=wi(e,Math.max(0,Ci-t)),r=e.length;for(let t of Si){let i=e.indexOf(t,n);i>=0&&i<r&&(r=i)}return e.slice(0,r).trim()}function Ei(e){let t=e.split(/[\\/]/).pop()??``,n=t.lastIndexOf(`.`);return vi(n>0?t.slice(0,n):t)}var Di=new Map;function Oi(e){let t=e.replace(/^0+/,``)||`0`,n=Di.get(t);return n||(Di.size>=2e3&&Di.clear(),n=ki(t),Di.set(t,n)),n}function ki(e){return RegExp(`^v0*${e}(?![\\p{L}\\p{N}])(?:(?:\\s*[:,\\-–—]|\\.(?=\\s|$))[\\s:,.\\-–—]*|\\s*$|\\s+(?=\\(batch\\b))`,`iu`)}var Ai=e=>e!==``&&e!==`…`;function ji(e){let t=xi(vi(e.label??``),48);if(Ai(t))return t;let n=vi(e.note??``),r=n,i=/^v(\d+)$/i.exec(e.id)?.[1];i!==void 0&&(r=r.replace(Oi(i),``)),r=r.replace(/^\(batch\b[^)]*\)\s*:?\s*/i,``);let a=Array.from(n.slice(0,n.length-r.length)).length;if(r=Ti(r,a),si.test(r)){let e=xi(r,48);if(Ai(e))return e}let o=xi(Ei(e.file),48);if(Ai(o))return o;let s=xi(vi(e.id),48);return Ai(s)?s:`Untitled`}var Mi={script:`Script`,picture:`Picture`,voice:`Voice`,music:`Music`,sfx:`Sound effects`,mix:`Mix`,notes:`Notes`,assets:`Files`,project:`Project`},Ni=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Pi=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],Fi=e=>String(e).padStart(2,`0`),Ii=e=>Number.isFinite(e.getTime());function Li(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 Ri(e){return Ii(e)?`${Fi(e.getHours())}:${Fi(e.getMinutes())}`:`--:--`}function zi(e){return`${e.getFullYear()}-${Fi(e.getMonth()+1)}-${Fi(e.getDate())}`}function Bi(e,t,n){if(!Ii(e))return`Date unknown`;if(!n)return`${Ni[e.getDay()]} ${e.getDate()} ${Pi[e.getMonth()]} ${e.getFullYear()}`;let r=Li(e.toISOString(),t);if(r===0)return`Today`;if(r===1)return`Yesterday`;let i=e.getFullYear()===t.getFullYear()?``:` ${e.getFullYear()}`;return`${Ni[e.getDay()].slice(0,3)} ${e.getDate()} ${Pi[e.getMonth()].slice(0,3)}${i}`}function Vi(e){return!e||!((e.label??``).trim()||e.note.trim())?null:ji(e)}var Hi=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function Ui(e,t){let n=Li(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 Wi(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?Hi[r.getMonth()].slice(0,3):Hi[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 Gi(e,t){return Wi(Ui(e,t),t,!0)}function Ki(e,t){return Wi(Ui(e,t),t,!1)}function qi(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 Ji(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 Yi(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=Gi(e.addedAt,t);return r&&n.push(r),n.join(` · `)}var Xi=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:--Xi,__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 Zi={chev:`<path d="M6 9l6 6 6-6"/>`,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:Zi[e]??``}})}var Qi={script:`script`,picture:`film`,voice:`mic`,music:`music`,sfx:`zap`,mix:`sliders`},$i=typeof window<`u`&&`showSaveFilePicker`in window;function ea(){let e=navigator.userAgent;return/Mac/.test(e)?`Show in Finder`:/Windows/.test(e)?`Show in Explorer`:`Open folder`}function ta(e){return e?new Date(e).toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`}):``}function na({asset:e,toast:t}){let[n,r]=J(!1),i=!e.missing&&Pe.has(Ie(e.path)),a=async()=>{if(n)return;r(!0);let i;try{let t=await window.showSaveFilePicker({suggestedName:e.name}),n=await fetch(br(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:`${br(e.path)}&download=1`,download:e.name,onClick:t=>{e.missing&&t.preventDefault()},children:Q($,{name:`download`})}),$i&&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":ea(),"aria-label":ea(),"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 ra({tip:e=`Missing`}){return Q(`span`,{class:`amiss`,"data-tip":e,"aria-label":e,children:`●`})}function ia(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:aa(e)?null:Vi(r)}}function aa(e){return e.kind===`cut`&&e.format!==void 0}function oa({asset:e,videos:t,toast:n}){let r=e.kind===`cut`||e.kind===`delivery`?ia(e,t):null;return Q(`div`,{class:`arow${e.missing?` missing`:``}${aa(e)?` sub`:``}`,children:[Q(`div`,{class:`ainfo`,children:[Q(`div`,{class:`atitle`,children:[r?r.title:e.label??e.name,e.missing&&Q(ra,{})]}),r?.subtitle&&Q(`div`,{class:`asub`,children:r.subtitle}),Q(`div`,{class:`afolder mono`,children:e.path}),!e.missing&&Q(`div`,{class:`ameta`,children:[Me(e.size??0),` · `,ta(e.modified)]})]}),Q(na,{asset:e,toast:n})]})}function sa({asset:e,toast:t,onChanged:n}){let[r,i]=J(!1),[a,o]=J(!1),s=X(null);Y(()=>{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(ra,{})]}),Q(`div`,{class:`afolder mono`,children:e.path}),!e.missing&&Q(`div`,{class:`ameta`,children:cn(e)})]}),Q(na,{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 ca({asset:e,playing:t,paused:n,onToggle:r,videos:i,toast:a}){let o=t&&!n,s=e.label??e.name,c=Ne(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(ra,{})]}),c&&Q(`div`,{class:`atrackmeta`,children:c}),Q(`div`,{class:`afolder mono`,children:e.path}),!e.missing&&Q(`div`,{class:`ameta`,children:[Me(e.size??0),` · `,ta(e.modified)]})]}),Q(na,{asset:e,toast:a})]})}function la({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(ra,{})]}),e.note&&Q(`div`,{class:`asub`,children:e.note}),Q(`div`,{class:`afolder mono`,children:e.path}),!e.missing&&Q(`div`,{class:`ameta`,children:[Me(e.size??0),` · `,ta(e.modified)]})]}),Q(na,{asset:e,toast:i})]})}function ua({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?`${K(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:br(e.path),alt:e.name,loading:`lazy`})}),Q(`div`,{class:`shot-meta`,children:[Q(`div`,{class:`mono`,children:[a,e.missing&&Q(ra,{})]}),o&&Q(`div`,{class:`asub`,children:o})]}),Q(na,{asset:e,toast:n})]})}function da({asset:e}){let t=X(null),[n,r]=J(!1);return Y(()=>{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?`${br(e.path)}#t=0.5`:void 0,"aria-label":`${e.name} poster frame`})}function fa({asset:e,videos:t,toast:n}){let{title:r,subtitle:i}=ia(e,t),a=Fe.has(Ie(e.path));return Q(`div`,{class:`shot-tile${e.missing?` missing`:``}${aa(e)?` sub`:``}`,children:[Q(`div`,{class:`shot-thumb poster`,children:!e.missing&&(a?Q(da,{asset:e}):Q(`div`,{class:`file-tile`,children:Q(`span`,{class:`file-ext mono`,children:Ie(e.path)||`file`})}))}),Q(`div`,{class:`shot-meta`,children:[Q(`div`,{class:`atitle`,children:[r,e.missing&&Q(ra,{})]}),i&&Q(`div`,{class:`asub`,children:i}),Q(`div`,{class:`afolder mono`,children:e.path})]}),Q(na,{asset:e,toast:n})]})}function pa(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 ma({asset:e,onClose:t,toast:n}){let r=X(null),i=X(null);return Y(()=>{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=pa(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:br(e.path),alt:e.name}),Q(`div`,{class:`lbactions`,children:[Q(na,{asset:e,toast:n}),Q(`button`,{ref:i,class:`btn ghost ib`,"aria-label":`Close`,onClick:t,children:Q($,{name:`x`})})]})]})})}var ha=60,ga=`Up to 12 files of each kind at a time, so the tabs stay quick. Each voiceover folder becomes its own round.`,_a=un.filter(e=>e!==`cut`),va=e=>e.slice(e.lastIndexOf(`/`)+1),ya=e=>`Couldn't be added: ${e.replace(/\.$/,``).replace(/^(\p{Lu})(?=\p{Ll})/u,e=>e.toLowerCase())}`,ba={voice:`var(--vo)`,music:`var(--music)`,sfx:`var(--sfx)`,other:`var(--text-3)`,cut:`var(--accent)`,doc:`var(--text-3)`};function xa({kind:e}){return Q(`i`,{class:`kdot`,style:{background:e?ba[e]:`var(--text-3)`}})}function Sa({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 Ca({row:e,playing:t,onPlay:n}){return Q(`div`,{class:`frow in`,children:[Q(`span`,{}),e.playable?Q(Sa,{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(xa,{kind:e.kind}),Q(`span`,{class:`klabel`,children:e.label})]}),Q(`span`,{}),Q(`span`,{})]})}var wa=class extends C{shouldComponentUpdate(e){return On(this.props,e)}render({item:e,kind:t,ticked:n,playing:r,failure:i,onTick:a,onKind:o,onPlay:s}){let c=va(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(Sa,{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:ya(i)})]}),l?Q(`span`,{class:`kind static`,children:[Q(xa,{kind:`cut`}),dn.cut]}):Q(`label`,{class:`kind`,children:[Q(xa,{kind:t}),Q(`select`,{"aria-label":`Kind of ${c}`,value:t,onChange:t=>o(e.path,t.target.value),children:_a.map(e=>Q(`option`,{value:e,children:dn[e]}))}),Q($,{name:`chev`,class:`kchev`})]}),Q(`span`,{class:`fdur mono`,children:wn(e.duration)}),Q(`span`,{class:`fsize mono`,children:Me(e.size)})]})}};function Ta(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 Ea({state:e,initialKind:t=`all`,playing:n,onPlay:r,onStop:i,toast:a,onChanged:o,onSeen:s}){let c=e.found,[l,u]=J(null),[d,f]=J(null),[p,m]=J(new Set),[h,g]=J({}),[_,v]=J({}),[y,b]=J(``),[x,S]=J(t),[C,w]=J(new Set),[T,E]=J(!0),[D,O]=J(!1),[k,A]=J(!1),[j,M]=J(!1),[ee,N]=J([]),P=X(null),F=X(null),I=X(!1),L=X(null),te=X({onPlay:r,onStop:i});te.current={onPlay:r,onStop:i};let R=sr((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=vn(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)}};Y(()=>{re()},[e]);let B=gn(c);Y(()=>s(B),[B]);let ie=l?.files??[],V=l?.hidden??[],ae=or(()=>ie.map(e=>({...e,kind:h[e.path]??e.kind,raw:e})),[ie,h]),oe=or(()=>Sn(ae,x,y),[ae,x,y]),se=or(()=>xn(oe),[oe]),ce=or(()=>Cn(ae),[ae]);Y(()=>{x!==`all`&&l&&!c.scanning&&!ce.some(([e])=>e===x)&&S(`all`)},[ce,l,c.scanning]);let H=or(()=>Dn(e.project,c.broughtIn),[e.project,c.broughtIn]),U=or(()=>se.filter(e=>!C.has(e.key)).flatMap(e=>e.files.map(e=>e.path)),[se,C]),le=or(()=>new Set(U),[U]),ue=ie.filter(e=>p.has(e.path)),W=ue.length,de=ue.filter(e=>le.has(e.path)),G=de.length,fe=or(()=>new Set([...H.map(e=>e.path),...ee]),[H,ee]);Y(()=>{l&&n.path&&!n.paused&&(le.has(n.path)||T&&fe.has(n.path)||te.current.onStop())},[l,n.path,n.paused,le,T,fe]),Y(()=>{let e=L.current;if(!e)return;let t=null;t=e===`search`?F.current:`row`in e?P.current?.querySelector(`.frow[data-path="${CSS.escape(e.row)}"] input[type="checkbox"]`)??null:P.current?.querySelector(`.fhrow[data-path="${CSS.escape(e.restore)}"] button`)??null,t&&(t.focus(),L.current=null)});let K=sr((e,t)=>{m(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),t||pe(e)},[]),pe=e=>v(t=>{if(!(e in t))return t;let{[e]:n,...r}=t;return r}),me=sr((e,t)=>{g(n=>({...n,[e]:t})),pe(e)},[]),he=e=>w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),ge=e=>{let t=new Set(e),n=Ta(U,t);L.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))))},_e=async()=>{if(I.current||W===0)return;I.current=!0,A(!0);let e=ue.slice(0,ha);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}})});ge([...t.added.map(e=>e.path),...t.failed.filter(e=>e.code===`already`).map(e=>e.path)]),N(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=ue.length-e.length,r=En(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{I.current=!1,A(!1)}},ve=async()=>{if(I.current||G===0)return;I.current=!0,A(!0);let e=de.map(e=>e.path);try{await Z.post(`/api/found/dismiss`,{paths:e}),ge(e),a(`Hid ${e.length} ${e.length===1?`file`:`files`}`),o(),re()}catch(e){a(e.message)}finally{I.current=!1,A(!1)}},ye=async e=>{let t=V.map(e=>e.path),n=t.indexOf(e),r=t[n+1]??t[n-1];try{await Z.post(`/api/found/restore`,{paths:[e]}),L.current=r===void 0?{row:e}:{restore:r},V.length<=1&&O(!1),o(),re()}catch(e){a(e.message)}},be=async()=>{if(!j){M(!0);try{await Z.post(`/api/found/scan`,{}),o()}catch(e){a(e.message)}finally{M(!1)}}},xe=e=>n.path===e&&!n.paused,Se=fn(c.counts),Ce=c.scanning;return Q(`section`,{class:`amain found`,"aria-label":`Found files`,ref:P,children:[Q(`header`,{class:`aheader`,children:[Q(`h2`,{children:[`Found `,Q(`span`,{class:`count`,children:Se})]}),Q(`div`,{class:`acontrols`,children:[Q(`label`,{class:`search-wrap`,children:[Q($,{name:`search`}),Q(`input`,{ref:F,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:ie.length})]}),ce.map(([e,t])=>Q(`button`,{type:`button`,"aria-pressed":x===e,onClick:()=>S(e),children:[dn[e],` `,Q(`span`,{class:`n`,children:t})]},e))]}),Q(`button`,{type:`button`,class:`btn ib`,"aria-label":`Look again`,"aria-busy":Ce||j,"data-tip":`Look through the project folder again`,onClick:()=>void be(),children:Q($,{name:`refresh`})}),Q(`button`,{type:`button`,class:`btn`,disabled:G===0||k,"data-tip":`Hide the ticked files for good. You can restore them from Hidden.`,onClick:()=>void ve(),children:`Not these`}),Q(`button`,{type:`button`,class:`btn primary`,disabled:W===0||k,onClick:()=>void _e(),children:W>0?`Bring in ${W}`:`Bring in`})]})]}),Ce&&Q(`p`,{class:`fscan`,"aria-live":`polite`,children:[Q(`span`,{class:`fspin`}),`Looking through the folder…`]}),d&&!l&&Q(`p`,{class:`aempty`,children:d}),H.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:H.length}),Q(`span`,{class:`fdone`,children:[Q($,{name:`check`}),`in the project`]})]}),T&&H.map(e=>Q(Ca,{row:e,playing:xe(e.path),onPlay:R},e.path))]}),l===null?!d&&Q(`p`,{class:`aempty`,children:`Loading…`}):ie.length===0?!Ce&&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:()=>he(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(wa,{item:e.raw,kind:e.kind,ticked:p.has(e.path),playing:xe(e.path),failure:_[e.path],onTick:K,onKind:me,onPlay:R},e.path))]},e.key)}),D&&V.length>0&&Q(`div`,{class:`fcard fhidden`,children:[Q(`p`,{class:`fhead`,children:[Q(`b`,{children:`Hidden`}),Q(`small`,{children:V.length})]}),V.map(e=>{let t=va(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:yn(e.folder)})]}),Q(`button`,{type:`button`,class:`btn`,"aria-label":`Restore ${t}`,onClick:()=>void ye(e.path),children:[Q($,{name:`undo`}),`Restore`]})]},e.path)})]}),Q(`div`,{class:`ffoot`,children:[Q(`p`,{class:`foot`,children:ga}),V.length>0&&Q(`button`,{type:`button`,class:`flink`,"aria-expanded":D,onClick:()=>O(e=>!e),children:[`Hidden (`,V.length,`)`]})]})]})}var Da=new Set([`voiceover`,`music`,`sfx`]),Oa=new Set([`cut`,`delivery`]),ka=1048576;function Aa(e){return`rushes.assets.view.${e}`}function ja(e){try{let t=localStorage.getItem(Aa(e));return t===`grid`||t===`list`?t:null}catch{return null}}function Ma(e,t){try{localStorage.setItem(Aa(e),t)}catch{}}function Na(e){return e?e.gridToggle?ja(e.id)??e.view:`list`:`grid`}async function Pa(e){let t=await fetch(br(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>ka){let e=t.byteLength-(a-ka);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 Fa({assets:e,videos:t,state:n,foundRequest:r,onFoundRequestUsed:i,onFoundSeen:a,toast:o,onChanged:s}){let c=or(()=>Le.filter(t=>t.id===`export`||e.some(e=>t.kinds.includes(e.kind))),[e]),l=c.find(e=>e.id!==`export`)?.id,u=hn(n.found)!==null,[d,f]=J(()=>r.pending?`found`:l??(u?`found`:c[0]?.id??`found`)),p=X(r.pending);Y(()=>{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]=J(()=>({key:0,kind:r.pending?r.kind:void 0})),g=e=>{p.current=!0,f(e)},_=X(r.pending?r.n:-1);Y(()=>{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]=J(``),[C,w]=J(`newest`),[T,E]=J(null),[D,O]=J(()=>Na(y)),k=X(y?.id??null);y&&y.id!==k.current&&(k.current=y.id,x(``),E(null),w(`newest`),O(Na(y)));let A=or(()=>y?Ve(e,y,{query:b,sort:C,film:T,videos:t}):[],[e,y,b,C,T,t]),j=e=>{y&&y.gridToggle&&(O(e),Ma(y.id,e))},[M,ee]=J(null),N=X(null),P=(e,t)=>{N.current=t,ee(e)},F=()=>{ee(null),N.current?.focus()},I=X(null),[L,te]=J({path:null,paused:!0}),R=X({}),ne=()=>{I.current?.pause(),ti(R.current),te({path:null,paused:!0})},z=(e,t)=>{let n=I.current;if(n){if(L.path===e&&!L.paused){n.pause(),ti(R.current),te({path:e,paused:!0});return}L.path!==e&&(n.src=br(e)),ei(R.current,()=>{I.current?.pause(),te(e=>({...e,paused:!0}))}),te({path:e,paused:!1}),n.play().catch(n=>{n instanceof Error&&n.name===`AbortError`||(ti(R.current),te({path:e,paused:!0}),o(`Couldn't play ${t}`))})}},re=e=>z(e.path,e.label??e.name);Y(()=>ne,[d,T]),Y(()=>ne,[]),Y(()=>{s()},[d]),Y(()=>{let e=()=>{document.visibilityState===`visible`&&s()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let[B,ie]=J(null),[V,ae]=J(null),oe=!!y&&Re.has(y.id);Y(()=>{if(!oe){ie(null);return}B&&A.some(e=>e.path===B&&Be(e))||ie(A.find(Be)?.path??null)},[oe,A]),Y(()=>{if(!B){ae(null);return}let e=!1;return ae({loading:!0,text:``,truncated:!1}),Pa(B).then(t=>{e||ae({loading:!1,text:t.text,truncated:t.truncated})}).catch(t=>{e||ae({loading:!1,text:``,truncated:!1,error:t.message})}),()=>{e=!0}},[B]);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)}},H=async()=>{try{let{path:e}=await Z.post(`/api/exports/notes`);o(`Saved to ${e}`),s()}catch(e){o(e.message)}},U=t=>e.filter(e=>t.kinds.includes(e.kind)).length,le=()=>y?y.id===`screenshot`&&C!==`name`?Ue(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(ua,{asset:e,videos:t,toast:o,onOpen:t=>P(e,t)},e.path))})]},e.heading??`_${n}`)):Oa.has(y.id)?Q(`div`,{class:`shots-grid`,children:A.map(e=>Q(fa,{asset:e,videos:t,toast:o},e.path))}):Q(`div`,{class:`shots-grid`,children:A.map(e=>Q(ua,{asset:e,videos:t,toast:o,onOpen:t=>P(e,t)},e.path))}):null,ue=()=>y?Da.has(y.id)?Q(`div`,{class:`arows`,children:A.map(e=>Q(ca,{asset:e,playing:L.path===e.path,paused:L.paused,onToggle:re,videos:t,toast:o},e.path))}):y.id===`proxy`?Q(`div`,{class:`arows`,children:A.map(e=>Q(sa,{asset:e,toast:o,onChanged:s},e.path))}):oe?Q(`div`,{class:`arows`,children:A.map(e=>Q(la,{asset:e,selected:B===e.path,onSelect:()=>ie(e.path),videos:t,toast:o},e.path))}):Q(`div`,{class:`arows`,children:A.map(e=>Q(oa,{asset:e,videos:t,toast:o},e.path))}):null,W=B?(B.split(`.`).pop()??``).toLowerCase():``,de=or(()=>oi(V?.text??``),[V?.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:fn(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:U(e)})]},e.id)),Q(`button`,{type:`button`,class:`afolder-root`,onClick:()=>void ce(),children:[Q($,{name:`folder`}),`Project folder`]})]}),v?Q(Ea,{state:n,initialKind:m.kind,playing:L,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 H(),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`?le():ue()}),oe&&Q(`aside`,{class:`apreview`,children:!B||!V?Q(`p`,{class:`aempty`,children:`Select a file to preview it here.`}):V.loading?Q(`p`,{class:`aempty`,children:`Loading…`}):V.error?Q(`p`,{class:`aempty`,children:V.error}):Q(S,{children:[W===`md`?Q(`div`,{class:`markdown`,dangerouslySetInnerHTML:{__html:de}}):Q(`pre`,{class:`plain`,children:V.text}),V.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:I,onEnded:()=>{ti(R.current),te(e=>({...e,paused:!0}))}}),M&&Q(ma,{asset:M,toast:o,onClose:F})]})}var Ia=150;function La({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;ar(()=>{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]=J(!1),[d,f]=J(!1),[p,m]=J(!1),[h,g]=J(!1),_=X(void 0),v=X(!1),y=()=>{clearTimeout(_.current),u(!0),m(!1)},b=()=>{clearTimeout(_.current),_.current=window.setTimeout(()=>u(!1),Ia)};Y(()=>()=>clearTimeout(_.current),[]);let x=o&&(l||d)&&!p&&!h;if(Y(()=>{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:Fn(e.length)},onKeyDown:e=>S(e),children:e.map(e=>{let n=Pn(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":Nn(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 Ra=.03,za=.004,Ba=15e3;function Va(e){return e.buffer?e.buffer.length*e.buffer.numberOfChannels*4:0}var Ha=0;function Ua(){return Ha}var Wa=new Map;function Ga(e){let t=Wa.get(e);return t&&(Wa.delete(e),Wa.set(e,t)),t}function Ka(e,t){for(Wa.delete(e),Wa.set(e,t);Wa.size>200;)Wa.delete(Wa.keys().next().value)}function qa(){let e=Error(`The load was cancelled`);return e.name=`AbortError`,e}function Ja(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),Ba)})}var Ya=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??br,fetch:t.fetch??((e,t)=>fetch(e,t)),probe:t.probe??Ja(n),createMedia:n,raf:t.raf??(e=>requestAnimationFrame(e)),caf:t.caf??(e=>cancelAnimationFrame(e))},e&&(this.ctx=e,Ha++)}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 Qr(this.videoDuration,this.resolved())}inspect(){return{playing:this._playing,time:this.time,length:this.length,sources:this.voices.size,gains:Br(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=Nr({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)Nr(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=>(Kr(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(Yr(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 qa();let d;if(u&&!Kr(u.duration,!0)){let e=Ga(t);if(!e){let n=[];for(let e=0;e<u.numberOfChannels;e++)n.push(u.getChannelData(e));e=Wr(n,Gr(u.duration)),Ka(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 qa();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)Nr(t)===e&&this.holding.delete(t.id);if(this._playing){for(let t of this.resolved())Nr(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(Nr)),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+=Va(e.media);for(;this.idle.size>12||o>268435456;){let[e,t]=this.idle.entries().next().value;o-=Va(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=Br(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(()=>{}),ei(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(),ti(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(),ti(this),this.tickListeners.clear(),this.endedListeners.clear(),this.changeListeners.clear(),this.disposed=!0,this.ctx&&(this.ctx.close().catch(()=>{}),this.ctx=null,Ha--)}}ensureContext(){if(this.disposed)throw Error(`The audio engine was disposed`);return this.ctx||(this.ctx=this.opts.createContext(),Ha++),this.ctx}resolved(){let e={};for(let[t,n]of this.media)e[t]=n.duration;let t=Zr(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+Ra;let n=this.resolved(),r=new Map(n.map(e=>[e.id,e]));for(let t of Vr(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+Ra),r=this.startOffset+(n-this.startedAt);for(let t of Vr([e],r))this.startVoice(e,n+t.when,t.offset)}startVoice(e,t,n){let r=this.media.get(Nr(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(Nr(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=Xr(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=Br([e],this.selection)[e.id],r.connect(this.laneNode(e.lane)),t={gain:r,seekedAt:-1/0},this.media.get(Nr(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+za)}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(Nr(e))&&!this.media.has(Nr(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)Xa(()=>e(t));if(t>=e){this.pause();for(let e of this.endedListeners)Xa(e);return}this._playing&&this.frame===null&&(this.frame=this.opts.raf(this.tick))};emitChange(){for(let e of this.changeListeners)Xa(e)}};function Xa(e){try{e()}catch(e){console.error(e)}}var Za=e=>e.map(e=>[e.id,e.lane,e.path,e.rev??``,e.offset,e.duration].join(`\0`)).join(``);function Qa(e,t=null){let n=X(null);n.current||=new Ya;let r=n.current,i=X(!0),[a,o]=J(!1),[s,c]=J(0),[l,u]=J({});return Y(()=>{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]),Y(()=>{r.setClips(e);let t=new Map(e.map(e=>[Nr(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,Za(e)]),Y(()=>{r.setVideoDuration(t)},[r,t]),{engine:r,playing:a,length:s,media:l}}var $a=0;function eo(){return $a}var to=3,no=2;function ro({segments:e,length:t,color:n}){let r=X(null),[i,a]=J({w:0,h:0,dpr:1});Y(()=>{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 Y(()=>{let a=r.current;if(!a||i.w<=0||i.h<=0)return;$a++,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/to),c=t*to/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*to,(i.h-s)/2,no,s)}},o),Q(`canvas`,{ref:r,class:`wave`,"aria-hidden":`true`})}function io(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 ao=(e,t)=>{let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])};function oo({rows:e,length:t,media:n,selected:r,marks:i,range:a,onSelect:o,onSeek:s}){let c=e=>`${t>0?e/t*100:0}%`,l=X(null),[u,d]=J({}),f=()=>{if(l.current){let e=io(l.current);d(t=>ao(t,e)?t:e)}},p=e.map(e=>{let t=e.clips.map(e=>n[Nr(e)]);return(t.some(e=>e!==void 0&&e!==`error`&&e.streamed)?`s`:``)+(t.some(e=>e===`error`)?`b`:``)});return ar(f,[JSON.stringify(e.map((e,t)=>[e.key,e.name,e.meta??``,e.heading??``,e.fold?e.fold.text:null,e.missing??!1,p[t]]))]),Y(()=>(window.addEventListener(`resize`,f),document.fonts?.ready.then(f),()=>window.removeEventListener(`resize`,f)),[]),Q(`div`,{class:`lanes`,ref:l,children:e.map(e=>{let l=e.heading!==void 0&&Q(`div`,{class:`rhead`,"data-heading":e.key,"data-tip":u[`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:[l,Q(`button`,{type:`button`,class:`fold`,"data-row":e.key,"data-tip":u[`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 d=e.key===r,f=u[e.key]??``,p=ut(e.cues??[],t),m=e.clips.map(e=>n[Nr(e)]),h=m.some(e=>e!==void 0&&e!==`error`&&e.streamed),g=m.some(e=>e===`error`),_=e.clips.map((e,t)=>{let n=m[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}}),v=i[e.key]??[];return Q(S,{children:[l,Q(`div`,{class:`lane`,"data-row":e.key,"aria-current":d?`true`:void 0,children:[Q(`button`,{type:`button`,class:`nm`,"data-player":!0,"aria-current":d?`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":f.includes(`n`)?e.name:void 0,children:[Q(`i`,{style:{background:e.color}}),Q(`span`,{"data-name":!0,children:e.name}),e.missing&&Q(ra,{tip:typeof e.missing==`string`?e.missing:void 0})]}),Q(`small`,{"data-meta":!0,"data-tip":f.includes(`m`)&&e.meta?e.meta:void 0,children:[g?Q(`span`,{class:`smk bad`,"data-tip":`This file won't play in a browser`,children:Q($,{name:`alert`})}):h?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??``})]})]}),Q(`div`,{class:`track`,onClick:n=>{let r=n.currentTarget.getBoundingClientRect();s((n.clientX-r.left)/r.width*t,e)},children:[Q(ro,{segments:_,length:t,color:e.color}),(e.cues??[]).map((t,n)=>Q(`i`,{class:`cue-tick`,style:{left:c(t.t),color:e.color}},`t${n}`)),(e.cues??[]).map((t,n)=>Q(`span`,{class:`cue`,"data-cue":t.id,style:{left:c(t.t),color:e.color,maxWidth:`calc(${(p[n]*100).toFixed(3)}% - 8px)`},children:t.name},`c${n}`)),v.map(e=>e.tOut!==null&&Q(`div`,{class:`span ${e.status}`,"data-note":e.id,style:{left:c(e.t),width:c(e.tOut-e.t)}})),v.map(e=>Q(`div`,{class:`mk ${e.status}`,"data-note":e.id,style:{left:c(e.t)},title:e.text})),a.in!==null&&Q(`div`,{class:`span live`,style:{left:c(a.in),width:c((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.key)})})}var so=[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`];function co({label:e,width:t,height:n,value:r,onChange:i,lockedReason:a,name:o}){let s=Pn(t,n),c=cr();return Q(`div`,{class:`fscope`,role:`radiogroup`,"aria-label":o,onKeyDown:e=>{if(e.altKey||e.metaKey||e.ctrlKey||!so.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 lo=[{kind:`rise`,label:`Rise`},{kind:`fall`,label:`Fall`},{kind:`louder`,label:`Louder`},{kind:`quieter`,label:`Quieter`}],uo=e=>e.options.find(t=>t.value===e.value)?.full;function fo({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]=J(`all`),C=X(null),w=i??C,[T,E]=J(``),[D,O]=J(!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}:ge(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()},ee=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)}}},N=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:_e(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]})]}),nt(e.marks)&&Q(`div`,{class:`nmarks`,children:nt(e.marks)}),e.shot&&Q(`div`,{class:`shotref`,children:[`Shot `,Ae(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:br(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":uo(u),children:[Q(`select`,{class:`sel onsel`,"aria-label":`Note on`,"data-tip":uo(u),value:u.value??``,onChange:e=>{let t=e.target;u.onChange(t.value),t.blur()},children:st(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:Je(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:()=>N(`${e}: `),children:e}))}),p&&d?.value===`range`&&Q(`div`,{class:`row`,role:`group`,"aria-label":`Marks`,children:lo.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(rt(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(it(p.value,e,Number(n.value))),n.blur()},children:Ze.map(e=>Q(`option`,{value:String(e),children:[e,` dB`]}))}),Q($,{name:`chev`})]})]})})}),y&&Q(`div`,{class:`row`,children:Q(co,{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(),ee()),e.key===`Escape`&&e.target.blur()}}),Q(`button`,{class:`btn primary ib sm send`,"data-tip":`Add note ↵`,"aria-label":`Add note`,onClick:()=>void ee(),children:Q($,{name:`send`})})]}),y&&Q(`p`,{class:`fhint`,children:y.hint})]})]})}var po=typeof location>`u`?{test:!1,streamOver:!1}:wt(location.search);po.streamOver&&Jr(1);var mo=po.test?{engine:null,inspect(){return this.engine?this.engine.inspect():null},renders:0,draws:eo,liveContexts:Ua,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;mo&&(window.__rushesAudio=mo);var ho=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),go={in:null,out:null},_o=[`point`,`range`,`whole`];function vo(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;mo&&mo.renders++;let g=e.clips??yo(a.flatMap(e=>e.clips)),[_,v]=J(null),[y,b]=J(16/9);Y(()=>{v(null),b(16/9)},[o?.file]);let{engine:x,playing:C,length:w,media:T}=Qa(g,o?o.duration??_:null),[E,D]=J(null),[O,k]=J(null),A=X(null),j=a.some(e=>e.key===E)?E:null;ar(()=>{E!==null&&j===null&&(D(null),A.current!==null&&O===A.current&&k(null),A.current=null)},[j]);let[M,ee]=J(go),[N,P]=J(e.defaultScope??`point`),[F,I]=J([]),[L,te]=J(!1),R=(e.scopes??_o).includes(`range`),ne=e.defaultScope??`point`,z=`${e.film===void 0?o?.video??``:e.film??``}/${o?.version??``}`,re=X(z);ar(()=>{re.current!==z&&(re.current=z,P(ne))},[z]);let B=Ye({range:M,marks:F,hasText:L});ar(()=>{m?.(B)},[B]),Y(()=>()=>m?.(!1),[]);let ie=e=>h?h(e):{select:_t(a,e),gains:{}},V=X({select:{},gains:{}}),ae=e=>{let t=V.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);V.current={select:{...t.select,...e.select},gains:{...t.gains,...e.gains}}},oe=ie(j);ar(()=>ae(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,H=l.find(e=>e.value===ce)??null,U=X(null),le=X([]),ue=X(null),W=X(null),de=X(null),G=X(!1),fe=X(0),pe=X(null),ge=e=>{if(N===`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 ${_e(M.in,M.out)}`;if(N===`range`)return`Set In and Out`}return`Note at ${K(H?.t??me(e,s))}`},ve=e=>{let t=x.length,n=`${t>0?Math.min(e,t)/t*100:0}%`;for(let e of le.current)e.style.left=n;let r=K(e);ue.current&&(ue.current.textContent=r),W.current&&(W.current.textContent=r),pe.current&&(pe.current.placeholder=ge(e));let i=de.current;i&&i.readyState>=1&&!i.seeking&&Hr(i.currentTime,e,s)&&(i.currentTime=Math.min(e,Number.isFinite(i.duration)?i.duration:e)),i&&x.playing&&!G.current&&e>fe.current&&(G.current=!0,i.play().catch(()=>void 0)),fe.current=e},ye=X(ve);ye.current=ve,ar(()=>{le.current=U.current?[...U.current.querySelectorAll(`.playhead`)]:[],ve(x.time)}),Y(()=>x.subscribe(e=>ye.current(e)),[x]),Y(()=>{let e=de.current;e&&(G.current=!1,C||(e.pause(),ye.current(x.time)))},[C,o?.file]);let be=()=>x.playing?x.pause():x.play(),xe=e=>{x.pause(),x.seek(he(x.time,s,e,x.length))},Se=()=>{R&&(ee({in:me(x.time,s),out:null}),P(`range`))},Ce=()=>{if(!R)return;let e=me(x.time,s),t=M.in??0;if(e<=t)return f(`Out has to come after In`);ee({in:t,out:e}),P(`range`)},we=()=>{ee(go),I([]),N===`range`&&P(ne)},Te=e=>{(e!==`range`||R)&&(P(e),e!==`range`&&(ee(go),I([])))},Ee=t=>{D(t.key),ae(ie(t.key)),A.current=t.on??null,t.on&&k(t.on),e.onSelect?.(t)},De=X(()=>void 0);De.current=e=>{if(ho(e.target)||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.key.toLowerCase();if(e.key===` `){if(Ct(e.target))return;e.preventDefault(),be()}else e.key===`ArrowLeft`?(e.preventDefault(),xe(e.shiftKey?-10:-1)):e.key===`ArrowRight`?(e.preventDefault(),xe(e.shiftKey?10:1)):t===`i`?Se():t===`o`?Ce():t===`n`&&(e.preventDefault(),pe.current?.focus())},ar(()=>{let e=e=>De.current(e);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),ar(()=>{mo&&(mo.clips=g)}),Y(()=>{if(mo)return mo.engine=x,()=>{mo.engine===x&&(mo.engine=null)}},[x]);let Oe=async e=>{let n=null,r=null;if(N===`range`){if(M.in===null||M.out===null)throw Error(`set In and Out for a range`);n=M.in,r=M.out}else N===`point`&&(n=H?.t??me(x.time,s));await Z.post(`/api/notes`,{stage:t,video:o?.video??null,version:o?.version??null,on:H?.on??null,scope:N,t:n,tOut:r,text:e,marks:N===`range`?F:[]}),ee(go),I([]),P(ne),p()},ke=o?.version??null,Ae={};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)(Ae[n]??=[]).push({id:e.id,t:e.t,tOut:R?e.tOut:null,status:e.status,text:e.text})}let je=M.in===null?null:M.out===null?`${K(M.in)} →`:_e(M.in,M.out);return Q(`div`,{class:`astage`,ref:U,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:()=>xe(-1),children:Q($,{name:`prev`})}),Q(`button`,{class:`btn ib`,"data-tip":`Play Space`,"aria-label":C?`Pause`:`Play`,onClick:be,children:Q($,{name:C?`pause`:`play`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Forward one frame →`,"aria-label":`Forward one frame`,onClick:()=>xe(1),children:Q($,{name:`next`})}),Q(`span`,{class:`tc`,"aria-label":`Timecode`,children:[Q(`span`,{ref:ue,children:K(x.time)}),Q(`small`,{children:[`/ `,K(w)]})]}),Q(`span`,{class:`sp`}),je&&Q(`span`,{class:`chipx`,children:[Q(`span`,{class:`mono`,children:je}),Q(`button`,{"aria-label":`Clear range`,onClick:we,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:Se,children:Q($,{name:`in`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Set out O`,"aria-label":`Set out point`,onClick:Ce,children:Q($,{name:`out`})})]})]}),Q(oo,{rows:a,length:w,media:T,selected:j,marks:Ae,range:M,onSelect:Ee,onSeek:(e,t)=>{Ee(t),x.seek(e)}}),i]}),Q(`div`,{class:`acol`,children:[Q(`div`,{class:`pv`,children:Q(`div`,{class:`frame`,style:{aspectRatio:String(y)},children:[o?Q(`video`,{ref:de,src:br(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),ye.current(x.time)},onSeeked:()=>ye.current(x.time)}):Q(`div`,{class:`pvempty`,"aria-label":`No cut yet`,children:Q($,{name:`film`})}),Q(`div`,{class:`tcover`,ref:W,children:K(x.time)})]})}),Q(fo,{notes:c,version:ke,placeholder:ge(x.time),inputRef:pe,toast:f,onAdd:Oe,onChanged:p,onTextChange:te,fixedTimes:!0,onSeek:e=>x.seek(e),on:{options:l,value:ce,onChange:k},scope:{value:N,onChange:Te,options:e.scopes},chips:(e.chipsFor??(()=>Xe[t]))(N),marks:e.marks===!1?void 0:{value:F,onChange:I},onLabel:d})]})]})}function yo(e){let t=new Set;return e.filter(e=>!t.has(e.id)&&(t.add(e.id),!0))}var bo={vo:`#4FD1C5`,music:`#A78BFA`,sfx:`#FB923C`},xo={vo:`Voiceover`,music:`Music`,sfx:`Sound effects`},So={vo:{muted:!1,solo:!1},music:{muted:!1,solo:!1},sfx:{muted:!1,solo:!1}};function Co({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?Pr(t):void 0},c=e=>o(e)?.missing===!0,l=e.picks.lanes,u=kt(Dt(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:ot(e.project.lanes,`music`),sfx:ot(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=Kt(b),[C,w]=J(So),T=(e,t)=>w(n=>({...n,[e]:{...n[e],[t]:!n[e][t]}})),E=e.picks.levels,D=e=>E[zt[e]]??0,[O,k]=J(()=>({vo:D(`vo`),music:D(`music`),sfx:D(`sfx`)})),A=X({});Y(()=>{k(e=>{let t=!1,n={...e};for(let e of Rt){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 Rt){let r=t[n];r&&(window.clearTimeout(r.id),delete t[n],r.send(e))}};Y(()=>{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=Jt(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:{[zt[e]]:n===0?null:n}},{keepalive:t}).then(i,e=>{r(e instanceof gr?e.message:`Couldn't save the level`)});a[e]={id:window.setTimeout(()=>{delete a[e],o()},300),send:o}},ee=Rr(Rt.map(e=>({id:e,...C[e],level:O[e]}))),N=e=>e===`vo`?u?`${u.laneName} · ${u.name}`:null:h[e].map(e=>e.name).join(` · `)||null,P=e=>y[e]?null:e===`vo`?f?`Missing`:`Nothing picked`:h[e].length>0?`Missing`:`Nothing picked`,F=Rt.map(e=>({key:e,name:xo[e],meta:N(e),color:bo[e],clips:v[e],cues:e===`sfx`?g.sfx.flatMap(e=>e.cues):void 0,on:x.find(t=>t.row===e)?.value,missing:P(e)??void 0,controls:Q(S,{children:[Q(`button`,{type:`button`,class:`ms`,"aria-pressed":C[e].muted,"aria-label":`Mute ${xo[e]}`,"data-tip":`Mute`,onClick:()=>T(e,`muted`),children:`M`}),Q(`button`,{type:`button`,class:`ms`,"aria-pressed":C[e].solo,"aria-label":`Solo ${xo[e]}`,"data-tip":`Solo`,onClick:()=>T(e,`solo`),children:`S`}),Q(`label`,{class:`level`,"data-tip":`Level for ${xo[e]}. Double-click to reset.`,children:[Q(`input`,{type:`range`,min:-24,max:6,step:qt,value:O[e],"aria-label":`${xo[e]} level`,"aria-valuetext":`${Yt(O[e])} dB`,onInput:t=>M(e,Number(t.target.value)),onDblClick:()=>M(e,0)}),Q(`span`,{class:`db mono`,children:[Yt(O[e]),` dB`]})]})]})})),I=Bt(y,ee),L=JSON.stringify({want:I,levels:E,clips:Rt.map(e=>v[e].map(e=>[e.path,e.rev??``,e.offset]))}),[te,R]=J({kind:`waiting`}),[ne,z]=J(!1),[re,B]=J(0),ie=te.kind===`timeout`||te.kind===`error`,V=X(0);Y(()=>{let e=++V.current;if(I.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:I}).then(t=>{e===V.current&&R({kind:`result`,result:t})},t=>{e===V.current&&R({kind:t instanceof gr&&t.status===504?`timeout`:`error`})}).finally(()=>{e===V.current&&z(!1)})},500);return()=>window.clearTimeout(t)},[L,re]),Y(()=>()=>void++V.current,[]);let ae=Q(`div`,{class:ie?`meter retry`:`meter`,role:`group`,"aria-label":`Loudness`,"aria-busy":ne,onClick:ie?()=>B(e=>e+1):void 0,children:[Qt(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`})}),ie&&!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=xe(n??void 0),ce=n&&se?{video:n.id,version:se.id,file:se.file,duration:se.duration}:null,H=e.project.fps||30;return Q(vo,{stage:`mix`,title:Ce.mix,belowLanes:ae,rows:F,preview:ce,film:n?.id??null,fps:H,notes:oe,onOptions:x,defaultOn:`mix`,listen:()=>({select:{},gains:ee}),noteRow:e=>Ut(b,e.on),onLabel:e=>Gt(b,e.on),toast:r,onChanged:i,onPendingChange:a})}function wo({notes:e,version:t,viewsHere:n,ownViews:r,onShow:i,onRestore:a}){let[o,s]=J(!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=ge(e,t),s=Wn(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:_e(o.t,o.tOut)}),Q(`span`,{class:`ftag`,children:e.format?ue(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 To=6e3,Eo=e=>/[.!?]$/.test(e)?e:`${e}.`;function Do({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]=J(!1),[p,m]=J(!1),[h,g]=J(r);Y(()=>g(r),[r]);let _=X(new Set);i?.state===`running`&&_.current.add(i.job);let[v,y]=J(null),b=on({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(Y(()=>{if(!x)return;let e=window.setTimeout(()=>y(x),To);return()=>clearTimeout(e)},[x]),!n)return null;let C=x&&v===x?`none`:b,w=sn(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 gr&&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.`}),` `,Eo(w)]}),Q(`button`,{class:`btn primary tip-wrap tip-end`,"aria-label":`Create proxy`,"data-tip":en(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}),` (`,Me(t.proxy.bytes),`).`]}),Q(`button`,{class:`btn ghost ib`,"aria-label":`Dismiss`,"data-tip":`Dismiss`,onClick:()=>y(x),children:Q($,{name:`x`})})]}),A]})})}var Oo=2e3,ko=8e3,Ao={kind:`none`},jo={kind:`pending`};async function Mo(e,t,n){let r;try{r=await t.fetch(e.peaksUrl,{signal:n})}catch(e){if(n.aborted)throw e;return jo}if(r.status===202)return jo;if(r.status===501)return No(e,t,n);if(r.status!==200)return Ao;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))?Ao:{kind:`wave`,wave:{peaks:Float32Array.from(t),duration:e.duration}}}catch(e){if(n.aborted)throw e;return Ao}}async function No(e,t,n){if(e.size===null||!(e.size<1e8))return Ao;try{let r=await e.duration();if(n.aborted)throw new DOMException(`aborted`,`AbortError`);if(r===null||!(r>0)||r>900)return Ao;let i=await t.fetch(e.mediaUrl,{signal:n});if(!i.ok)return Ao;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)?Ao:{kind:`wave`,wave:{peaks:Po(Wr(a,Math.min(Oo,s))),duration:o}}}catch(e){if(n.aborted)throw e;return Ao}}function Po(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 Fo=40,Io=new Map;function Lo(e,t,n,r){return`${e}/${t}/${n}#${r??``}`}function Ro(e){return Io.has(e)}function zo(e){return Io.get(e)??null}function Bo(e,t){for(Io.delete(e),Io.set(e,t);Io.size>Fo;)Io.delete(Io.keys().next().value)}function Vo(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 Ho=1500,Uo=15e3,Wo=15e3,Go={fetch(e,t){let n=_r();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,ko).decodeAudioData(e),n=[];for(let e=0;e<t.numberOfChannels;e++)n.push(t.getChannelData(e));return{channels:n,duration:t.duration}}};function Ko(e,t,n,r,i){let a=Lo(e,t.id,t.file,r),o=X(i),s=X([]);Y(()=>{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),Wo)}),[l,u]=J(()=>Ro(a)?{key:a,wave:zo(a)}:null),d=X(null);return Y(()=>{if(Ro(a)){u({key:a,wave:zo(a)});return}let r=new AbortController,i,o=Ho,s={peaksUrl:`/api/videos/${encodeURIComponent(e)}/versions/${encodeURIComponent(t.id)}/peaks`,mediaUrl:br(t.file),size:n,duration:c},l=async()=>{d.current=null,clearTimeout(i);let e;try{e=await Mo(s,Go,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,Uo);return}let t=e.kind===`wave`?e.wave:null;Bo(a,t),u({key:a,wave:t})};return l(),()=>{r.abort(),clearTimeout(i),d.current=null}},[a]),Y(()=>{d.current?.()},[t]),l&&l.key===a?l.wave:null}var qo=0;typeof location<`u`&&wt(location.search).test&&(window.__rushesPicture={waveDraws:()=>qo});var Jo=3,Yo=2;function Xo({wave:e,length:t}){let n=X(null),[r,i]=J({w:0,h:0,dpr:1});return Y(()=>{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=Vo(window,t);return()=>{r.disconnect(),a()}},[]),Y(()=>{let i=n.current;if(!i||r.w<=0||r.h<=0)return;qo++,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+=Jo){let n=t/r.w*o;if(n>=e.duration)break;let i=(t+Jo)/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,Yo,f)}},[r,e,t]),Q(`canvas`,{ref:n,class:`pwave`,"aria-hidden":`true`})}function Zo(e){Y(()=>{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 Qo=700,$o=16,es=()=>typeof matchMedia==`function`&&matchMedia(`(hover: none)`).matches;function ts({versions:e,shown:t,lockedVersion:n,onPick:r}){let i=[...e].reverse(),[a,o]=J(!1),[s,c]=J(t.id),[l,u]=J(null),[d,f]=J(!1),[p,m]=J(null),[h,g]=J(0),_=X(null),v=X(null),y=X(null),b=X({}),x=X({text:``,at:-1/0}),S=new Date,C=ji(t),w=e=>{c(e),u(null),m(null),f(es()),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);ar(()=>{D?T(!0):a&&b.current[s]?.focus()},[a,s,D]),ar(()=>{if(!a)return;let e=()=>{let e=_.current?.getBoundingClientRect(),t=y.current?.getBoundingClientRect();if(!e||!t)return;let n=document.documentElement.clientWidth-$o;g(Math.max(0,Math.min(e.left+t.width-n,e.left-$o)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[a]),Y(()=>{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=Ji(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<Qo?x.current.text+e.key:e.key;x.current={text:t,at:e.timeStamp};let n=qi(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":ns(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:ji(e)}),Q(`span`,{class:`vwhen`,children:[e.id===n&&Q($,{name:`lock`}),Gi(e.addedAt,S)]}),d&&p===e.id&&Q(`span`,{class:`vinline`,dir:`auto`,children:[vi(e.note)||`No note.`,Q(`span`,{class:`vmeta`,children:Yi(e,S)})]})]}))}),!d&&Q(`div`,{class:`vdetail`,id:`vdetail`,children:[Q(`h4`,{children:A.id}),Q(`p`,{dir:`auto`,children:vi(A.note)||`No note.`}),Q(`span`,{class:`vmeta`,children:Yi(A,S)})]})]})]})}function ns(e,t,n){return[e.id,ji(e),e.id===t?`locked`:``,Ki(e.addedAt,n)].filter(Boolean).join(`, `)}function rs({version:e}){let[t,n]=J(!1),[r,i]=J(!1),a=X(null);ar(()=>{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=vi(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 is=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function as({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]=J(0),[M,ee]=J(t.duration??0),[N,P]=J(t.duration?t.file:null),F=b?y.find(e=>e.id===b)??null:null,I=!F||F.primary,L=F??y.find(e=>e.primary)??null,te=L?L.width/L.height:null,R=b!==null&&y.length>=2,ne=y.find(e=>e.primary)?.id??null,z=Rn(r,b),re=zn(r,b),[B,ie]=J(`this`),[V,ae]=J(te??16/9),[oe,se]=J(!1),[ce,H]=J(null),[U,le]=J({in:null,out:null}),[ue,W]=J(!1),[G,fe]=J(null),[ve,ye]=J({w:0,h:0}),[be,xe]=J(null),[Se,Ce]=J(null),[we,Te]=J(!1),Ee=X(null);Zo(Ee);let De=Ko(e.id,t,_,v,N===t.file?M:t.duration??0),Oe=X(!1),Me=X(!1),Ne=X({}),Pe=X(oe);Y(()=>{Pe.current=oe},[oe]);let Fe=X(!0);Y(()=>()=>{Fe.current=!1},[]);let Ie=X(t.id);Y(()=>{Ie.current=t.id},[t.id]),Y(()=>{let e=U.in!==null||be!==null||we;return o?.(e),()=>o?.(!1)},[U.in,be,we]),Y(()=>(be!==null&&ie(`this`),w?.(be!==null),()=>w?.(!1)),[be]);let Le=X(void 0);Y(()=>{H(null),j(0),ae(te??16/9),le({in:null,out:null}),xe(null),Le.current!==void 0&&l(e.id,null),Le.current=t.file,Ce(null),ie(`this`)},[t.file]);let Re=be?`this`:B,ze=n=>de(e.versions.find(e=>e.id===n.version)??t),[Be,Ve]=J({}),He=e=>e.id in Be?Be[e.id]:e.format,Ue=e=>Ve(t=>{if(!(e in t))return t;let{[e]:n,...r}=t;return r});Y(()=>{Ve(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 Ke=async(e,t)=>{if(He(e)!==t){Ve(n=>({...n,[e.id]:t}));try{await Z.patch(`/api/notes/${e.id}`,{format:t})}catch(t){Ue(e.id),qe.current?.id===e.id&&(qe.current=null),i(`Couldn't change that note: ${t.message}`)}a()}};Y(()=>{Se&&!z.some(e=>e.id===Se)&&Ce(null)},[b,r]);let qe=X(null),Je=X(b);if(Je.current!==b){Je.current=b;let e=document.activeElement,t=e instanceof HTMLElement&&e.closest(`.nfmt`)?e.closest(`.list > .note[data-note]`):null;t&&!qe.current&&(qe.current={id:t.dataset.note,fallback:!0})}ar(()=>{let e=qe.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?(qe.current=null,n&&r.focus()):e.fallback&&(qe.current=null,n&&document.querySelector(`.otherrow`)?.focus())},[b,r]);let Ye=I&&!!t.proxy&&h!==`original`,Xe=br(Ye?t.proxy.file:I?t.file:F.file),Ze=ce===Xe,Qe=X(null),$e=X(null);if($e.current&&$e.current.src!==Xe){let e=E.current;$e.current.cut===t.file?!Qe.current&&e&&(Qe.current={t:e.error?A:e.currentTime,play:!e.paused&&!e.error}):Qe.current=null}$e.current={cut:t.file,src:Xe};let et=X(null),tt=X(null),nt=F?.id??`primary`,rt=X(!0);ar(()=>{if(rt.current){rt.current=!1;return}let e=D.current;if(!L||!e)return;let t=L.width/L.height;if(t===V)return;let n=e.getBoundingClientRect();et.current={width:n.width,height:n.height},ae(t)},[nt]),ar(()=>{let e=et.current,t=D.current;if(et.current=null,!e||!t)return;tt.current?.cancel(),tt.current=null;let n=t.getBoundingClientRect(),r=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=Ln(e,{width:n.width,height:n.height},r);wt(location.search).test&&(window.__rushesLastReshape={animated:i!==null,ms:i?160:0}),i&&(tt.current=t.animate(i,{duration:160,easing:`ease-out`}))},[V]),Y(()=>{let e=E.current;if(!e)return;let t=()=>H(Xe);return e.error&&t(),e.addEventListener(`error`,t),()=>e.removeEventListener(`error`,t)},[Xe]);let it=X(null);it.current=!I&&M>0?M:null;let at=e=>{let t=it.current;t===null||e.paused||e.currentTime<t||(e.pause(),e.currentTime=t)};Y(()=>{if(!oe)return;let e=0,t=()=>{E.current&&(at(E.current),j(E.current.currentTime)),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[oe]);let ot=()=>Qe.current?.t??E.current?.currentTime??A,st=()=>me(ot(),n),ct=e=>{let t=E.current;if(!t)return;let n=Math.min(Math.max(0,e),M||t.duration||e);if(Qe.current){Qe.current.t=n,j(n);return}t.currentTime=n,j(t.currentTime)},lt=()=>{let e=E.current;e&&(e.paused?(it.current!==null&&e.currentTime>=it.current-.001&&(e.currentTime=0),e.play().catch(()=>i(`Couldn't play this file`))):e.pause())},ut=e=>{E.current?.pause(),ct(he(ot(),n,e,M))},dt=()=>le({in:st(),out:null}),ft=()=>{let e=st(),t=U.in??0;if(e<=t)return i(`Out has to come after In`);le({in:t,out:e})},pt=()=>le({in:null,out:null}),mt=X(0),[ht,gt]=J(0),_t=async()=>{let r=E.current,o=st(),s=e.id,c=t.id,u=I?null:b,f=++mt.current,p=!1;try{let e=pe(o,n),t;if(d){p=!0,gt(e=>e+1);let n=await yr(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!==mt.current){a();return}i(`Saved to ${m.grab}`),a(),Fe.current&&c===Ie.current&&l(s,m.grab)}catch(e){f===mt.current&&i(e.message)}finally{p&&Fe.current&>(e=>e-1)}},vt=async r=>{let i=U.in!==null&&U.out!==null,o=i?U.in:st();await Z.post(`/api/notes`,{stage:`picture`,video:e.id,version:t.id,scope:i?`range`:`point`,t:o,tOut:i?U.out:null,frame:pe(o,n),text:r,box:be,grab:c,...R?{format:Re===`this`?b:null}:{}}),pt(),ie(`this`),xe(null),l(e.id,null),a()},yt=X(()=>void 0);yt.current=e=>{if(is(e.target)||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.key.toLowerCase();if(e.key===` `){if(Ct(e.target))return;e.preventDefault(),lt()}else e.key===`ArrowLeft`?(e.preventDefault(),ut(e.shiftKey?-10:-1)):e.key===`ArrowRight`?(e.preventDefault(),ut(e.shiftKey?10:1)):t===`i`?dt():t===`o`?ft():t===`g`&&!e.repeat?_t():t===`b`?W(e=>!e):t===`n`&&(e.preventDefault(),k.current?.focus())},Y(()=>{let e=e=>yt.current(e);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let bt=(e,t)=>{let n=E.current;return We(n?.videoWidth??0,n?.videoHeight??0,e,t)},xt=e=>{let t=O.current.getBoundingClientRect(),n=bt(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}};Y(()=>{let e=O.current;if(!e)return;let t=()=>ye(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 St=e=>{if(!ue)return;let t=xt(e);e.target.setPointerCapture(e.pointerId),fe({x0:t.x,y0:t.y,x1:t.x,y1:t.y,w:t.w,h:t.h})},Tt=e=>{if(!G)return;let t=xt(e);fe({...G,x1:t.x,y1:t.y})},Et=e=>{if(!G)return;let t=xt(e),n=Ge(G.x0,G.y0,t.x,t.y,G.w,G.h);fe(null),W(!1),Oe.current=!0,n.w>.01&&n.h>.01&&xe(n)},Dt=G?Ge(G.x0,G.y0,G.x1,G.y1,G.w,G.h):null,Ot=bt(ve.w,ve.h),kt=e=>({left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.w*100}%`,height:`${e.h*100}%`}),At=e=>`${M?Math.min(100,Math.max(0,e/M*100)):0}%`,jt=M?t.shots.filter(e=>e.start<M):t.shots,Mt=ke(jt,me(A,n));Y(()=>{Pe.current&&Mt!==null&&Ne.current[Mt.n]?.scrollIntoView({block:`nearest`,inline:`nearest`})},[Mt?.n]);let Nt=z.map(e=>({n:e,at:ge(e,t.id)})).filter(({at:e})=>e.t!==null),Pt=z.find(e=>e.id===Se)??null,Ft=Pt?.box&&(!Pt.version||Pt.version===t.id)&&Bn(Pt,b,ne)?Pt.box:null,It=U.in===null?null:U.out===null?`${K(U.in)} →`:_e(U.in,U.out),Lt=U.in!==null&&U.out===null?`Set an Out point`:`Note at ${It&&U.out!==null?It:K(A)}`,Rt=e=>{ee(I?e.duration||t.duration||0:t.duration??F?.duration??(e.duration||0)),P(t.file),I&&t.width===null&&e.videoWidth&&e.videoHeight&&C?.(t.file,e.videoWidth,e.videoHeight),H(e=>e===Xe?null:e),e.videoWidth&&e.videoHeight&&ae(e.videoWidth/e.videoHeight),Me.current||(Me.current=!0,s&&(e.currentTime=Math.min(s,e.duration||s),j(e.currentTime)));let n=Qe.current;n&&(Qe.current=null,e.currentTime=Math.min(n.t,e.duration||n.t),j(n.t),n.play&&e.play().catch(()=>void 0))},zt=t=>{t!==h&&g?.(e.id,t)};return Q(`div`,{class:`split`,children:[Q(`div`,{class:`stack`,ref:Ee,children:[Q(`div`,{class:`framebox`,style:{height:`min(640px, 70vh, calc(100cqw / ${V}))`},children:Q(`div`,{class:`frame`,ref:D,style:{aspectRatio:String(V),"--ar":String(V)},children:[x&&!I&&Q(`div`,{class:`msg`,children:`File not found`}),Ze&&!I&&!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.`}),Ze&&I&&!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.`}),Ze&&I&&d&&t.proxy&&!Ye&&Q(`div`,{class:`msg`,children:`This file won't play in a browser.`}),Q(`video`,{hidden:Ze||x&&!I,ref:e=>{E.current=e,u&&(u.current=e),e&&e.readyState>=1&&Rt(e)},src:Xe,preload:`auto`,playsInline:!0,onLoadedMetadata:e=>Rt(e.target),onTimeUpdate:e=>{let t=e.target;at(t),!oe&&!Qe.current&&j(t.currentTime)},onSeeked:e=>!Qe.current&&j(e.target.currentTime),onPlay:()=>se(!0),onPause:()=>se(!1),onEnded:()=>se(!1)}),Q(`div`,{ref:O,class:`overlay${ue?` drawing`:``}`,onPointerDown:St,onPointerMove:Tt,onPointerUp:Et,onClick:()=>{Oe.current?Oe.current=!1:ue||lt()},children:Q(`div`,{class:`pic`,style:{left:`${Ot.x}px`,top:`${Ot.y}px`,width:`${Ot.w}px`,height:`${Ot.h}px`},children:[Ft&&Q(`div`,{class:`bx saved`,style:kt(Ft)}),be&&Q(`div`,{class:`bx`,style:kt(be)}),Dt&&Q(`div`,{class:`bx`,style:kt(Dt)})]})}),Q(`div`,{class:`tcover`,children:[`f`,pe(A,n),Mt&&` · shot ${Ae(Mt.n)}`]}),t.proxy&&I&&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":Ye,"aria-label":`Proxy`,"data-tip":`Playing the lightweight copy. Notes and timings are the same.`,onClick:e=>{e.currentTarget.blur(),zt(`proxy`)},children:`Proxy`}),Q(`button`,{type:`button`,class:`tip-below tip-start tip-wrap`,"aria-pressed":!Ye,"aria-label":`Original`,"data-tip":`Play the full-quality file. It may stutter.`,onClick:e=>{e.currentTarget.blur(),zt(`original`)},children:`Original`})]})]})}),m&&Q(Do,{hidden:!I,video:e,version:t,ffmpeg:d,autoProxy:f,job:p,broken:Ze&&!Ye,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:()=>ut(-1),children:Q($,{name:`prev`})}),Q(`button`,{class:`btn ib`,"data-tip":`Play Space`,"aria-label":oe?`Pause`:`Play`,onClick:lt,children:Q($,{name:oe?`pause`:`play`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Forward one frame →`,"aria-label":`Forward one frame`,onClick:()=>ut(1),children:Q($,{name:`next`})}),Q(`span`,{class:`tc`,"aria-label":`Timecode`,children:[K(A),Q(`small`,{children:[`/ `,K(M)]})]}),Q(`span`,{class:`sp`}),It&&Q(`span`,{class:`chipx`,children:[Q(`span`,{class:`mono`,children:It}),Q(`button`,{"aria-label":`Clear range`,onClick:pt,children:Q($,{name:`x`})})]}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Set in I`,"aria-label":`Set in point`,onClick:dt,children:Q($,{name:`in`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Set out O`,"aria-label":`Set out point`,onClick:ft,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":ue,onClick:()=>W(!ue),children:Q($,{name:`box`})}),Q(`button`,{class:`btn ghost ib`,"data-tip":`Grab frame G`,"aria-label":`Grab frame`,"aria-busy":ht>0,onClick:()=>void _t(),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();ct((e.clientX-t.left)/t.width*M)},children:[De&&Q(Xo,{wave:De,length:M}),Nt.map(({n:e,at:t})=>t.tOut!==null&&Q(`div`,{class:`span ${e.status}`,style:{left:At(t.t),width:At(t.tOut-t.t)}})),U.in!==null&&Q(`div`,{class:`span live`,style:{left:At(U.in),width:At((U.out??U.in+.2)-U.in)}}),jt.filter(e=>e.start>0).map(e=>Q(`div`,{class:`tick`,style:{left:At(e.start)}})),Nt.map(({n:e,at:t})=>{let n=Un(e,R);return Q(`div`,{class:`mk ${e.status}${R&&e.format===null?` ring`:``}`,style:{left:At(t.t)},title:n?`${n} · ${e.text}`:e.text})}),Q(`div`,{class:`playhead`,style:{left:At(A)}})]}),Q(`div`,{class:`ends`,children:[Q(`span`,{children:`0:00`}),Q(`span`,{children:K(M)})]}),Q(rs,{version:t},t.id)]}),jt.length>0&&Q(`div`,{class:`shots`,"data-player":!0,children:jt.map(e=>Q(`button`,{type:`button`,class:`shot`,ref:t=>{Ne.current[e.n]=t},"aria-current":Mt?.n===e.n?`true`:void 0,onClick:()=>{E.current?.pause(),ct(je(e.start,n))},children:[Q(`span`,{class:`mono`,children:[Ae(e.n),` · `,e.start.toFixed(2),`s`]}),Q(`span`,{class:`name`,children:e.name}),e.tag&&Q(`span`,{class:`tag`,children:e.tag})]}))}),Q(fo,{notes:z,version:t.id,selectedId:Se,placeholder:Lt,inputRef:k,toast:i,onAdd:vt,onChanged:a,onTextChange:Te,formatTag:e=>Un(e,R),cardExtra:R&&F?e=>Q(co,{name:`Note applies to`,label:F.label,width:F.width,height:F.height,value:He(e)===null?`all`:`this`,lockedReason:e.box?Vn:null,onChange:t=>void Ke(e,t===`all`?null:F.id)}):void 0,formatScope:R&&F?{label:F.label,width:F.width,height:F.height,value:Re,onChange:ie,lockedReason:be?Vn:null,hint:Hn(F.label,Re,be!==null)}:void 0,listFooter:e=>{let n=re.filter(t=>e===`all`||t.status===e);return n.length>0?Q(wo,{notes:n,version:t.id,viewsHere:y,ownViews:ze,onShow:(e,t)=>{be||(qe.current={id:t.id,fallback:!1}),T?.(e)},onRestore:e=>{qe.current={id:e.id,fallback:!1},Ke(e,null)}}):null},onSeek:(e,t)=>{E.current?.pause(),ct(e),Ce(t.id)},attachments:(be||c)&&Q(S,{children:[be&&Q(`span`,{class:`chipx`,children:[Q($,{name:`box`}),`Box`,Q(`button`,{"aria-label":`Remove box`,onClick:()=>xe(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 os={approved:{color:`var(--done)`,label:`Approved`},flagged:{color:`var(--todo)`,label:`Flagged`},draft:{color:`var(--text-3)`,label:`Draft`}},ss=500;function cs(e,t){let n=X(void 0),r=X(e);return r.current=e,Y(()=>()=>{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 ls({section:e,wps:t,toast:n,onChanged:r}){let[i,a]=J(e.proposed??e.current),[o,s]=J(e.direction),c=X(!1),l=X(null);Y(()=>{c.current||a(e.proposed??e.current)},[e.proposed,e.current]),Y(()=>{c.current||s(e.direction)},[e.direction]),ar(()=>{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=cs(()=>{c.current=!1,u({proposed:i.trim()===e.current.trim()?null:i})},ss),f=cs(()=>{c.current=!1,u({direction:o})},ss),p=e.end-e.start,m=ve(i,p,t),h=i.trim()!==e.current.trim(),g=os[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:[K(e.start).replace(/\.\d+$/,``),`–`,K(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 us({script:e,toast:t,onChanged:n}){let r=e.sections.filter(ye).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(ls,{section:r,wps:e.wordsPerSecond,toast:t,onChanged:n},r.id))})]})}var ds={music:`#A78BFA`,sfx:`#FB923C`},fs=Math.floor(Math.random()*2**31),ps=!1;function ms({stage:e,state:t,assets:n,video:r,toast:i,onChanged:a,onPendingChange:o}){let[s,c]=J(e===`music`&&ps),l=e=>{ps=e,c(e)},u=ot(t.project.lanes,e),d=s?vt(u.map(e=>e.key),fs):u.map(e=>e.key),f=d.map(e=>u.find(t=>t.key===e)),p=e=>s?`Bed ${d.indexOf(e.key)+1}`:e.name,m=t.picks.lanes,h=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()},g=f.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?Pr(r):void 0},a=m[t.lane]===t.variant;return{key:t.key,name:p(t),meta:s?`·····`:t.meta,color:ds[e],clips:[i],cues:e===`sfx`?t.cues:void 0,audition:{lane:t.lane,clip:t.key},picked:a,order:u.indexOf(t),use:{inUse:a,onUse:()=>void h(t,t.variant),onUnpick:()=>void h(t,null)},on:`v:${t.key}`}}),_=dt(f,p,e===`sfx`),v=t.notes.notes.filter(t=>t.stage===e),y=xe(r??void 0),b=r&&y?{video:r.id,version:y.id,file:y.file,duration:y.duration}:null,x=t.project.fps||30;return Q(vo,{stage:e,film:r?.id??null,title:Ce[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:g,preview:b,fps:x,notes:v,onOptions:_,noteRow:e=>ht(f,e.on),onLabel:e=>gt(f,_,e.on),toast:i,onChanged:a,onPendingChange:o})}var hs=`#4FD1C5`,gs=[`whole`,`point`],_s={whole:Xe.voice,point:[`Fix this`,`Keep this`]},vs=Math.floor(Math.random()*2**31),ys=!1,bs=new Map,xs=new Set;function Ss({state:e,assets:t,video:n,toast:r,onChanged:i,onPendingChange:a}){let[o,s]=J(ys),c=e=>{ys=e,s(e)},l=n?.id??``,[,u]=J(0),d=bs.get(l)??xs,f=e=>{let t=new Set(d);t.has(e)?t.delete(e):t.add(e),bs.set(l,t),u(e=>e+1)},p=e=>t.find(t=>t.path===e),m=e=>{let t=p(e);return t?Pr(t):void 0},h=e=>p(e)?.missing===!0,g=Dt(e.project.lanes,e.picks.lanes),_=g.map(e=>{if(!o)return e;let t=vt(e.reads.map(e=>e.key),vs);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:jt(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:hs,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:hs,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(Ft(T,e)??``)),onToggle:()=>f(e.id)}}),t)for(let t of e.reads)D.push(E(e,t))}let O=It(_,y),k=At(g),A=xe(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(vo,{stage:`voice`,film:n?.id??null,title:Ce.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=>Mt(g,e),noteRow:e=>Ft(T,e),onLabel:e=>Lt(T,e.on,y),scopes:gs,defaultScope:`whole`,chipsFor:e=>_s[e===`point`?`point`:`whole`],marks:!1,toast:r,onChanged:i,onPendingChange:a})}var Cs=[[`all`,`All`],[`picture`,Mi.picture],[`voice`,Mi.voice],[`music`,Mi.music],[`sfx`,Mi.sfx],[`mix`,Mi.mix],[`notes`,Mi.notes],[`assets`,Mi.assets]];function ws(e){return Cs.some(([t])=>t===e)}var Ts={user:`added by you`,agent:`agent`,rushes:`Rushes`};function Es(e,t){let n=[];for(let r of e){let e=new Date(r.at),i=zi(e),a=n[n.length-1];a&&a.date===i?a.entries.push(r):n.push({key:i,date:i,heading:Bi(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 Ds(e,t){return e===`all`||e===t}var Os=new Set([` `,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`,`PageUp`,`PageDown`]);function ks(e){return Os.has(e.key)&&!e.altKey&&!e.ctrlKey&&!e.metaKey}var As=[`script`,`picture`,`voice`,`music`,`sfx`,`mix`];function js(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&&As.includes(e.tab)?{tab:e.tab}:e.area===`assets`?{tab:`assets`}:As.includes(e.area)?{tab:e.area}:null}function Ms(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 Ns(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 Ps(e,t){let n=e.by===`user`?`added by you`:e.by===`agent`?`by the agent`:`by Rushes`;return`${e.text} (${Mi[e.area]}, ${t}, ${n})`}function Fs(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 Is(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 Ls(e,t){return`rushes:${e}:${t}`}function Rs(e,t){try{return e?.getItem(t)??null}catch{return null}}function zs(e,t,n){try{e?.setItem(t,n)}catch{}}var Bs=1e3,Vs=40,Hs=()=>{try{return window.sessionStorage}catch{return}},Us=()=>{try{return window.localStorage}catch{return}};function Ws(e,t){let[n,r]=J(()=>Rs(Hs(),Ls(e,`log-open`))===`1`),[i,a]=J(!1),[o,s]=J(()=>Rs(Us(),Ls(e,`log-seen`))),c=t?.mark??null,l=X(o);l.current=o;let u=t=>{s(t),zs(Us(),Ls(e,`log-seen`),t)};return Y(()=>{n&&c&&Is(c,o)&&u(c)},[n,c]),Y(()=>{let t=Ls(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&&Is(c,o),setOpen:t=>{r(t),a(t),zs(Hs(),Ls(e,`log-open`),t?`1`:`0`)},saw:e=>{Is(e,l.current)&&u(e)}}}function Gs(){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 Ks({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(Gs,{}),Q(`span`,{class:`clabel`,children:`Change Log`}),e.dot&&Q(`span`,{class:`cdot`,"aria-hidden":`true`})]})}function qs(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 Js(e){return e.log.open?Q(Xs,{...e}):null}function Ys({entry:e,to:t,onGo:n}){let r=Ri(new Date(e.at)),i=Q(S,{children:[Q(`span`,{class:`ltime`,children:r}),Q(`span`,{class:`ltag ${e.area}`,children:Mi[e.area]}),Q(`span`,{class:`ltext`,dir:`auto`,children:[e.text,Q(`span`,{class:`lby`,children:Ts[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":Ps(e,r),onClick:()=>n(t),children:i}):Q(`div`,{class:`lrow`,"data-entry":e.id,children:i})}function Xs({log:e,projectId:t,head:n,project:r,stage:i,header:a,buttonRef:o,toast:s,onJump:c}){let[l,u]=J(null),[d,f]=J(null),[p,m]=J(null),[h,g]=J(()=>{let e=Rs(Hs(),Ls(t,`log-filter`));return ws(e)?e:`all`}),[_,v]=J(``),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)>Vs,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(Bs)});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(Fs(`read`,e)):m(Fs(`read`,e))}};Y(()=>{b.current&&(b.current.scrollTop=0),f(null),O(!0)},[h]);let k=X(!0);Y(()=>{if(k.current){k.current=!1;return}O()},[n?.rev,n?.mark]),ar(()=>{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)}},[]),ar(()=>{e.focusOnOpen&&x.current?.focus()},[]);let A=()=>{e.setOpen(!1),o.current?.focus()};ar(()=>{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(``),!Ds(h,i)){let e=Mi[i];s(`Added under ${e}. Choose All${Cs.some(([e])=>e===i)?` or ${e}`:``} to see it.`)}b.current&&(b.current.scrollTop=0),await O(!0)}catch(e){s(Fs(`add`,e))}},M=e=>{g(e),zs(Hs(),Ls(t,`log-filter`),e)},ee=(e,t)=>{let n=Ji(e.key,t,Cs.length,!0);if(n===null)return;e.preventDefault();let r=Cs[n][0];M(r),S.current[r]?.focus()},N=()=>{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})}))},P=()=>{d&&!E()&&D(d)},F=t=>{c(t),window.innerWidth<560&&(e.setOpen(!1),o.current?.focus())},I=X(F);I.current=F;let L=X(e=>I.current(e)).current,te=async()=>{try{s(`Saved to ${(await Z.post(`/api/exports/change-log`,{})).path}`)}catch(e){s(Fs(`export`,e))}},R=or(()=>l?Es(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(Ys,{entry:e,to:js(e,r),onGo:L})},e.id))})]},e.key)):null,[l,r,zi(new Date)]),ne=l&&d?Ms(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=>{ks(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:Cs.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=>ee(e,n),children:t}))}),Q(`div`,{class:`dwrap`,children:[ne>0&&Q(`button`,{type:`button`,class:`dpill`,onClick:N,children:[ne,` new`]}),Q(`div`,{class:`dlist`,ref:b,tabIndex:0,role:`group`,"aria-label":`Entries`,onScroll:P,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?Ns(l):``}),Q(`button`,{type:`button`,class:`btn`,onClick:()=>void te(),children:`Export as Markdown`})]})]})}var Zs=[`script`,`picture`,`voice`,`music`,`sfx`,`mix`],Qs=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function $s({tab:e,projectName:t,filmName:n,found:r,onReview:i,toast:a}){let{what:o,unlocks:s}=we[e],c=e===`assets`?`Assets`:Ce[e],l=e===`assets`?`grid`:Qi[e],u=De(e,t,n),d=mn(e,r),f=X(null),p=async()=>{try{await navigator.clipboard.writeText(u),a(`Prompt copied`)}catch{f.current?.select(),a(`Prompt selected: press ${ln(navigator.platform)}`)}};return Q(`div`,{class:`empty locked`,children:[Q($,{name:l}),Q(`h2`,{children:c}),Q(`p`,{children:o}),Q(`p`,{children:s}),Q(`textarea`,{class:`promptbox mono`,readOnly:!0,rows:4,ref:f,value:u,"aria-label":`Prompt for your agent`}),Q(`button`,{class:`btn primary`,onClick:()=>void p(),children:[Q($,{name:`copy`}),`Copy prompt for your agent`]}),d&&Q(`p`,{class:`foundline`,children:[Q(`span`,{children:d.text}),Q(`button`,{type:`button`,class:`btn`,"aria-label":d.review,onClick:()=>i(d.kind),children:`Review`})]})]})}function ec(){let{state:e,assets:t,problem:n,wrongProject:r,refresh:i,proxyJobs:a,noteProxyJob:o}=Mr(),[s,c]=J(null),[l,u]=J(null),[d,f]=J(null),[p,m]=J(null),[h,g]=J(null),[_,v]=J(!1),[y,b]=J(!1),[x,C]=J(!1),[w,T]=J(!1),[E,D]=J(0),[O,k]=J({}),A=X(void 0),j=X(new Map),M=X(null),ee=(e,t)=>k(n=>({...n,[e]:t})),[N,P]=J({}),F=(e,t)=>P(n=>({...n,[e]:t})),[I,L]=J({}),[te,R]=J({}),[ne,z]=J(!1),re=X(new Set),B=(e,t=2400)=>{m(e),clearTimeout(A.current),A.current=window.setTimeout(()=>m(null),t)},[ie,V]=J({n:0,pending:!1}),[ae,oe]=J(null),se=Ws(_r()??``,e?.log),ce=X(null);Y(()=>{for(let e of Object.values(a))e.state!==`failed`||re.current.has(e.job)||(re.current.add(e.job),B(e.reason??`Couldn't make the proxy`))},[a]),Y(()=>{e&&(s===null&&c(Oe(e.tabs)),l===null&&e.project.videos[0]&&u(e.project.videos[0].id))},[e]),Y(()=>{e?.project.name&&(document.title=`${e.project.name} · Rushes`)},[e?.project.name]);let H=e?.project.videos.find(e=>e.id===l)??e?.project.videos[0],U=be(H),le=xe(H),W=H?.versions.find(e=>e.id===d)??le,G=!!H?.lockedVersion,fe=W?.fps??e?.project.fps??30,K=W?t.find(e=>e.kind===`cut`&&e.path===W.file):void 0,pe=e?.notes.notes.filter(e=>e.stage===`picture`&&(!e.video||e.video===H?.id))??[],he=W?de(W,te[W.file]):[],ge=H&&W?kn(H,W.id):void 0,_e=An(he,H?I[H.id]:void 0),ve=new Set(t.filter(e=>e.kind===`cut`&&e.missing).map(e=>e.path)),ye=W?jn({views:he,previous:ge?de(ge):[],current:_e,versionDuration:W.duration,notes:pe,missing:ve}):[],Te=e=>!H||e===_e?!1:ne?(B(`Add or clear your box on ${_e?ue(_e):`this format`} first`),!1):(L(t=>({...t,[H.id]:e})),!0);Y(()=>{x&&d===null&&le?(f(le.id),T(!0)):!x&&w&&d===le?.id&&(f(null),T(!1))},[x,d,le?.id]),Y(()=>{!w&&d!==null&&d===le?.id&&f(null)},[le?.id,w,d]);let Ee=U&&W&&U.id!==W.id&&(G||w)?U.id:null,De=()=>{U&&f(U.id),T(!1)},ke=e=>{if(!H||e===H.id)return;if(x)return B(`Add or clear your note on ${H.name} first`);let t=M.current;t?.pause();let n=t?me(t.currentTime,fe):j.current.get(H.id)?.t??0;j.current.set(H.id,{versionId:d,held:w,t:n});let r=j.current.get(e);u(e),f(r?.versionId??null),T(r?.held??!1),D(r?.t??0)},Ae=async()=>{if(H&&W)try{await Z.put(`/api/videos/${H.id}/lock`,{version:H.lockedVersion?null:W.id}),i()}catch(e){B(e.message)}},je=t=>{if(x)return B(`Add or clear your note first`);if(t.tab===`assets`)return Le();if(t.video&&t.video!==H?.id&&ke(t.video),t.version){let n=e?.project.videos.find(e=>e.id===(t.video??H?.id));f(t.version===xe(n)?.id?null:t.version),T(!1)}c(t.tab),g(null),t.row&&qs(t.row)},Me=e?.tabs??[],Ne=e=>Me.find(t=>t.stage===e),Pe=hn(e?.found),Fe=t.length>0||Pe!==null,Ie=e=>{if(x&&e!==s)return B(`Add or clear your note first`);c(e),g(null)},Le=()=>{if(x&&s!==`assets`)return B(`Add or clear your note first`);c(`assets`),g(null)},Re=e=>{if(x&&s!==`assets`)return B(`Add or clear your note first`);V(t=>({n:t.n+1,kind:e,pending:!0})),c(`assets`),g(null)},ze=X(Re);ze.current=Re,Y(()=>{wt(location.search).test&&(window.__rushesOpenFound=e=>ze.current(e))},[]),ar(()=>{let t=t=>{if(t.altKey&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&(t.key===`ArrowLeft`||t.key===`ArrowRight`)){if(s!==`picture`||Qs(t.target))return;t.preventDefault();let e=Mn(ye,_e,t.key===`ArrowRight`?1:-1);e&&Te(e);return}if(Qs(t.target)||t.metaKey||t.ctrlKey||t.altKey)return;let n=Number(t.key);if(n>=1&&n<=6?Ie(Zs[n-1]):n===7&&Le(),(t.key===`[`||t.key===`]`)&&e){let n=Se(e.project.videos,l,t.key===`]`?1:-1);n&&ke(n)}t.key===`?`&&v(e=>!e),t.key===`Escape`&&(v(!1),g(null))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)});let Be=X(null),Ve=X(null),He=X(null),Ue=()=>{let e=Be.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)};ar(Ue),Y(()=>{let e=()=>Ue();window.addEventListener(`resize`,e);let t=!0;return document.fonts?.ready.then(()=>{t&&Ue()}),()=>{t=!1,window.removeEventListener(`resize`,e)}},[]);let We=!!e&&!!s;Y(()=>{if(!We)return;let e=new ResizeObserver(()=>Ue());for(let t of[Ve.current,He.current])t&&e.observe(t,{box:`border-box`});return()=>e.disconnect()},[We]);let Ge=async()=>{if(s&&s!==`assets`){v(!1);try{let{batch:e}=await Z.post(`/api/batches`,{stage:s});g(e),b(!1),i()}catch(e){B(e instanceof gr&&e.code===`empty_batch`?`Nothing open on ${Ce[s]} to send`:e.message)}}},Ke=async()=>{if(h)try{await navigator.clipboard.writeText(h.prompt),b(!0)}catch{B(`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 qe=e.notes.notes.filter(e=>e.stage===`picture`&&(!e.video||e.video===H?.id)),Je=t=>e.notes.notes.some(e=>e.stage===`picture`&&e.status===`todo`&&(!e.video||e.video===t)),Ye=s===`assets`?Fe:Ne(s)?.unlocked??!1,Xe=s===`assets`?0:Ne(s)?.todo??0;return Q(`div`,{class:`shell`,children:[Q(`header`,{class:`head`,ref:Ve,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}),H&&e.project.videos.length===1&&Q(S,{children:[Q(`span`,{class:`slash`,children:`/`}),Q(`span`,{class:`sel`,children:H.name})]})]}),Pe!==null&&gn(e.found)!==ae&&Q(`button`,{type:`button`,class:`foundchip`,"data-tip":`Open the other files found in this project`,onClick:()=>Re(),children:[Q(`span`,{class:`dot`}),Q(`span`,{class:`ftext`,children:Pe})]}),H&&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===H.id,onClick:()=>ke(e.id),children:[Q(`span`,{class:`n`,children:t+1}),Q(`span`,{class:`pname`,children:e.name}),Je(e.id)&&Q(`span`,{class:`dot`})]}))}),H&&Q(S,{children:[Q(`span`,{class:`plabel`,children:`Picture`}),W&&Q(ts,{versions:H.versions,shown:W,lockedVersion:H.lockedVersion,onPick:e=>{f(e===le?.id?null:e),T(!1)}}),W&&Q(`button`,{class:`btn ib lockbtn`,"aria-pressed":G,"aria-label":G?`Picture locked at ${H.lockedVersion} · unlock`:`Lock picture at ${W.id}`,"data-tip":G?`Picture locked at ${H.lockedVersion} · unlock`:`Lock picture at ${W.id}`,onClick:()=>void Ae(),children:Q($,{name:G?`lock`:`unlock`})}),Ee&&Q(`button`,{class:`chipx go`,"aria-label":`${Ee} is ready`,"data-tip":`Switch to the newest cut`,onClick:De,children:[Q($,{name:`new`}),Ee,` ready`]}),s===`picture`&&W&&ye.length>0&&Q(La,{chips:ye,versionId:W.id,prompt:In(e.project.name,H.name,W.id),onSelect:Te,toast:B})]}),Q(`span`,{class:`sp`}),Q(`button`,{class:`btn ghost ib tip-below`,"data-tip":`Shortcuts ?`,"aria-label":`Keyboard shortcuts`,onClick:()=>{g(null),v(!_)},children:Q($,{name:`kbd`})}),Q(Ks,{log:se,buttonRef:ce}),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 Ge(),children:[`Send to agent`,Xe>0&&Q(`span`,{class:`count`,children:Xe})]})]}),Q(Js,{log:se,projectId:_r()??``,head:e.log,project:e.project,stage:s,header:Ve,buttonRef:ce,toast:B,onJump:je}),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:[`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 Ke(),children:[Q($,{name:`copy`}),y?`Copied`:`Copy prompt`]})})]}),_&&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:()=>v(!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:He,role:`tablist`,"aria-label":`Stages`,children:[Zs.map(e=>{let t=Ne(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 ${we[e].ask}`,onClick:()=>Ie(e),children:[Q($,{name:Qi[e]}),Ce[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":Fe?void 0:`true`,"data-tip":Fe?void 0:`Locked: ask your agent for ${we.assets.ask}`,onClick:()=>Le(),children:[Q($,{name:`grid`}),`Assets`,!Fe&&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:Be,children:s===`assets`?Ye?Q(Fa,{assets:t,videos:e.project.videos,state:e,foundRequest:ie,onFoundRequestUsed:()=>V(e=>e.pending?{n:e.n,pending:!1}:e),onFoundSeen:oe,toast:B,onChanged:()=>void i()}):Q($s,{tab:`assets`,projectName:e.project.name,filmName:H?.name??null,found:e.found?.counts,onReview:Re,toast:B}):Ye?s===`picture`&&H&&W?Q(as,{video:H,version:W,fps:fe,notes:qe,toast:B,onChanged:()=>void i(),onPendingChange:C,startAt:E,grab:O[H.id]??null,onGrabChange:ee,playerRef:M,ffmpeg:e.proxies?.ffmpeg??!1,autoProxy:e.project.autoProxy,proxyJob:a[tn(H.id,W.id)],noteProxyJob:o,source:N[H.id]??`proxy`,onSourceChange:F,fileSize:K?.size??null,fileRev:K?Pr(K):void 0,formats:he,format:_e,formatMissing:!!_e&&ve.has(he.find(e=>e.id===_e)?.file??``),onPrimarySize:(e,t,n)=>R(r=>r[e]?r:{...r,[e]:{width:t,height:n}}),onBoxPendingChange:z,onFormatChange:Te},H.id):s===`script`?Q(us,{script:e.script,toast:B,onChanged:()=>void i()}):s===`voice`?Q(Ss,{state:e,assets:t,video:H??null,toast:B,onChanged:()=>void i(),onPendingChange:C},`voice`):s===`mix`?Q(Co,{state:e,assets:t,video:H??null,toast:B,onChanged:()=>void i(),onPendingChange:C},`mix`):s===`music`||s===`sfx`?Q(ms,{stage:s,state:e,assets:t,video:H??null,toast:B,onChanged:()=>void i(),onPendingChange:C},s):null:Q($s,{tab:s,projectName:e.project.name,filmName:H?.name??null,found:e.found?.counts,onReview:Re,toast:B})})]})}xt(document),B(Q(ec,{}),document.getElementById(`app`));
|
package/web-dist/index.html
CHANGED
|
@@ -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-
|
|
9
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-C9dBtlRy.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BDMm5p1-.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
12
|
<div id="app"></div>
|