@gentbajko/slopify 4.3.3 → 4.3.5
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/dist/edge/http/settings.js +2 -0
- package/dist/extension/slopify-studio-chrome.zip +0 -0
- package/dist/extension/slopify-studio-firefox.zip +0 -0
- package/dist/main.js +8 -1
- package/dist/patch-notes/4.3.4.md +11 -0
- package/dist/patch-notes/4.3.5.md +30 -0
- package/dist/patch-notes/index.json +12 -0
- package/dist/slices/rebuild/runtime-export-short.js +4 -2
- package/dist/slices/rebuild/runtime-export.js +5 -2
- package/dist/slices/rebuild/runtime-plan.js +56 -0
- package/dist/slices/rebuild/runtime-provider.js +14 -0
- package/dist/slices/settings/model.js +1 -0
- package/dist/slices/settings/playback.js +11 -1
- package/dist/slices/studio/videos.js +20 -6
- package/dist/slices/video/encoding.js +5 -0
- package/dist/slices/video/plan.js +58 -11
- package/dist/slices/video/render-gate.js +45 -0
- package/dist/web/assets/{index-BwKV_9F3.js → index-Bvtq2QTE.js} +3 -3
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
|
@@ -454,7 +454,7 @@ St. = Saint`,"aria-describedby":o.skipped.length===0?void 0:`${a}-skipped`,onCha
|
|
|
454
454
|
`)}function Y5(e){return W5(e)&&W5(e.config)&&W5(e.content)}function X5(e,t={}){if(e.work.some(e=>e.disposition===`blocked`)||e.providedReuseRequired.length>0)return!1;let n=t.unknownPrices===!0;return e.costs.unknown>0&&!n?!1:e.costs.high>0||e.work.some(e=>e.disposition===`generate`&&e.kind===`provider`)?t.approvedUpTo===void 0?n:e.costs.high<=t.approvedUpTo:!0}function Z5(e,t,n){let r=JSON.stringify(t);return e?.payload===r?e:{payload:r,idempotencyKey:n()}}var MGe=400;function NGe(e){return`project-revision:${e}`}function PGe(e,t,n,r){let i=NGe(e),a=(0,m.useRef)(void 0),o=(0,m.useRef)(void 0);return(0,m.useEffect)(()=>{if(n===void 0||t===void 0)return;if(!r){o.current=void 0,ZF(i);return}let e=t.revision.id,a=()=>{o.current=void 0,swe(i,n,e)};o.current=a;let s=setTimeout(a,MGe);return()=>clearTimeout(s)},[i,n,t,r]),(0,m.useEffect)(()=>{let e=()=>o.current?.(),t=lwe(e);return window.addEventListener(`pagehide`,e),()=>{t(),window.removeEventListener(`pagehide`,e),e()}},[]),{waiting:()=>a.current===i?!1:XF(i,Y5)!==void 0||(a.current=i,!1),take:()=>{if(a.current!==i)return a.current=i,XF(i,Y5)},clear:()=>{o.current=void 0,ZF(i)}}}var Q5=e=>({config:structuredClone(e.revision.config),content:structuredClone(e.revision.content)});function FGe(e,t,n={}){let{api:r}=q(),i=_(),a=I({queryKey:X.revision(e,t??``),enabled:t!==null,queryFn:async()=>{if(t===null)throw Error(`This project has no saved settings to show yet. Reload the page and try again.`);let n=await TJ(r,e,t);if(!n.ok)throw Error(n.message);return n.value.view}}),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(),[f,p]=(0,m.useState)(),[h,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(!1),[b,x]=(0,m.useState)(),[S,C]=(0,m.useState)(),[w,T]=(0,m.useState)(),[E,D]=(0,m.useState)(),O=(0,m.useRef)(void 0),k=(0,m.useRef)(void 0),A=(0,m.useRef)(void 0),j=(0,m.useRef)(void 0),M=(0,m.useRef)(n.onOpenEdit);M.current=n.onOpenEdit;let N=(0,m.useMemo)(()=>c!==void 0&&(o===void 0||(c.regenerate?.length??0)>0||(c.uploads?.length??0)>0||JSON.stringify(c.config)!==JSON.stringify(o.revision.config)||JSON.stringify(c.content)!==JSON.stringify(o.revision.content)),[c,o]),P=PGe(e,o,c,N),ee=c!==void 0&&o!==void 0&&t!==null&&t!==o.revision.id,F=(0,m.useRef)(!1);async function te(e){if(!F.current){F.current=!0,g(!0),x(void 0),C(void 0);try{await e()}catch(e){x(e instanceof Error?e.message:String(e))}finally{F.current=!1,g(!1)}}}async function ne(t){let n=await CJ(r,e);if(!n.ok)C(n);else return C(void 0),s(n.value.view),t&&l(Q5(n.value.view)),n.value.view}async function re(){let t=P.take();if(t===void 0)return!1;let n=await TJ(r,e,t.base),i=n.ok?n.value.view:await ne(!1);return i!==void 0&&(s(i),l(t.value),T({kind:`restored`,savedAt:t.savedAt}),M.current?.(),!0)}(0,m.useEffect)(()=>{t!==null&&!F.current&&P.waiting()&&te(async()=>{await re()})});async function ie(t){let n=await Am(r,e);return i.setQueryData(X.project(e),n),await i.invalidateQueries({queryKey:X.revisions(e)}),!t.current||n.revisionId!==t.revision.id?(C({ok:!1,reason:`conflict`,message:`The project changed again while saving. Your edit is kept: press Reload latest and re-apply my edit, check it, then Save changes.`,currentRevisionId:n.revisionId,fields:[]}),!1):(P.clear(),s(t),l(void 0),C(void 0),d(void 0),T(void 0),!0)}async function ae(){if(v||o===void 0||c===void 0)return;let t={baseRevisionId:o.revision.id,edit:c},n=Z5(O.current,t,()=>crypto.randomUUID());O.current=n;let i=await wJ(r,e,{...t,idempotencyKey:n.idempotencyKey});i.ok?(await ie(i.value.view)&&T({kind:`saved`}),O.current=void 0):C(i)}async function oe(t,n=u){if(n===void 0)return;let a={baseRevisionId:n.baseRevisionId,previewId:n.id,...t},o=Z5(A.current,a,()=>crypto.randomUUID());A.current=o;let s=await kJ(r,e,{...a,idempotencyKey:o.idempotencyKey});if(!s.ok)return C(s),(s.reason===`stale-preview`||s.reason===`conflict`)&&d(void 0),s;A.current=void 0,j.current=void 0,d(void 0),await i.invalidateQueries({queryKey:X.project(e)})}async function se(t,n,i){let a=await ne(!1);if(a===void 0)return;let o=await OJ(r,e,{baseRevisionId:a.revision.id,request:t});if(!o.ok){i!==void 0&&await le(i,a),C(o);return}let s=o.value.value;if(A.current=void 0,n!==void 0&&X5(s,n)){let e=await oe({acknowledgeUnknownCosts:n.unknownPrices===!0&&s.costs.unknown>0,confirmedProvidedWorkKeys:[]},s);e!==void 0&&i!==void 0&&(await le(i,a),C(e))}else j.current=i===void 0?void 0:{previewId:s.id,revisionId:i},d(s)}async function ce(t,n){let i=e=>{let r=n.change?.(e)??e;return{...r,regenerate:[...new Set([...r.regenerate??[],...t])]}};if(c!==void 0&&N){l(i(c)),p({section:n.section??`images`}),M.current?.();return}let a=await ne(!1);if(a===void 0)return;let o=await wJ(r,e,{baseRevisionId:a.revision.id,edit:i(Q5(a)),idempotencyKey:crypto.randomUUID()});if(!o.ok){C(o);return}let s=o.value.view;if(!await ie(s))return;let u=n.starts,d=u===void 0?t:[...new Set([...s.pieces.filter(e=>e.selected).map(e=>({key:e.key,outdated:!1})),...s.outputs.filter(e=>e.selected).map(e=>({key:e.workKey,role:e.output.role,outdated:e.state===`outdated`}))].filter(e=>u(e)).map(e=>e.key))];await se(d.length===0?{kind:`allAffected`}:{kind:`selected`,workKeys:d},d.length===0?void 0:n,a.revision.id)}async function le(t,n){let i=n??o??a.data??await ne(!1);if(i===void 0)return;let s={baseRevisionId:i.revision.id,targetRevisionId:t},c=Z5(k.current,s,()=>crypto.randomUUID());k.current=c;let l=await gAe(r,e,{...s,idempotencyKey:c.idempotencyKey});l.ok?(await ie(l.value.view),k.current=void 0):C(l)}return{saved:a,view:o,edit:c,preview:u,focus:f,pending:h,uploading:v,error:b,refusal:S,unsaved:N,remoteChanged:ee,notice:w,busy:h||v||c!==void 0||u!==void 0,setEdit:e=>{l(e),w?.kind!==`restored`&&w?.kind!==`reapplied`&&T(void 0)},setUploading:y,openEditor:()=>void te(async()=>{T(e=>e?.kind===`saved`?e:void 0),D(void 0),await re()||await ne(!0)}),discard:()=>{o!==void 0&&c!==void 0&&N?(D({view:o,edit:c}),T({kind:`discarded`})):T(void 0),P.clear(),l(void 0),C(void 0),y(!1),O.current=void 0},undoDiscard:()=>{E!==void 0&&c===void 0&&(s(E.view),l(E.edit),D(void 0),T(void 0),M.current?.())},dismissNotice:()=>{T(void 0),D(void 0)},save:()=>void te(ae),reapply:()=>void te(async()=>{if(c===void 0||o===void 0)return;let e=c,t=o;O.current=void 0;let n=await ne(!1);n!==void 0&&(l(q5(t.revision,e,n.revision)),T({kind:`reapplied`}))}),copyEdit:()=>{c!==void 0&&o!==void 0&&oJ(jGe(o.revision,c)).then(e=>T({kind:`copied`,ok:e}))},reloadCurrent:()=>void te(async()=>{k.current=void 0,A.current=void 0,d(void 0),await ne(!1),await i.invalidateQueries({queryKey:X.project(e)})}),requestEdit:e=>void te(async()=>{let t=o,n=c;if(t===void 0||n===void 0){if(await re()){p({section:e.section});return}if(t=await ne(!1),t===void 0)return;n=Q5(t)}l(e.change(n,t)),p({section:e.section}),M.current?.()}),regenerateNow:(e,t)=>void te(()=>ce(e,t??{})),review:(e,t)=>void te(()=>se(e,t?.autoStart===!0?{approvedUpTo:t.approvedUpTo,unknownPrices:t.unknownPrices}:void 0)),start:e=>void te(async()=>{await oe(e)}),closePreview:()=>{if(h)return;let e=j.current;j.current=void 0,d(void 0),A.current=void 0,e!==void 0&&e.previewId===u?.id&&te(()=>le(e.revisionId))},restore:e=>void te(()=>le(e))}}function IGe({projectId:e,dirty:t}){let n=`/projects/${e}`;return(0,h.jsx)(M2,{dirty:t,leaves:e=>e!==n&&!e.startsWith(`${n}/`),askOnUnload:()=>!dwe(),tone:`primary`,title:`Leave with unsaved changes?`,consequence:`Your edit stays in this browser and comes back when you open this project again. It is not saved to the project until you press Save changes.`,confirmLabel:`Leave, keep my edit for later`,cancelLabel:`Stay and keep editing`})}var LGe=e=>kg(e);function RGe({c:e}){let t=(e,t,n)=>(0,h.jsxs)(lL,{tone:e,children:[(0,h.jsx)(`span`,{className:`min-w-0 truncate`,title:t,children:t}),n]});if(e.uploading)return t(`info`,`Waiting for uploads to finish…`);let n=e.notice;return n?.kind===`saved`?t(`success`,`Saved as a new version. Nothing is made again until you choose to.`):n?.kind===`restored`?t(`info`,`Restored your unsaved edit from ${LGe(n.savedAt)}.`,(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(K,{size:`small`,variant:`quiet`,onClick:e.dismissNotice,children:`Keep`}),(0,h.jsx)(K,{size:`small`,variant:`quiet`,onClick:e.discard,children:`Discard`})]})):n?.kind===`reapplied`?t(`info`,`Your edit is laid over the latest version. Check it, then press Save changes.`):n?.kind===`copied`?n.ok?t(`success`,`Your edit is on the clipboard.`):t(`error`,`Couldn't copy: the browser blocked the clipboard. Your edit is still kept here and in this browser.`):e.remoteChanged?t(`warning`,`A newer version is available. Your unsaved changes are kept below and in this browser.`):e.unsaved?(0,h.jsx)(lL,{}):t(`info`,`Nothing to save yet: change a setting first.`)}function zGe({controller:e,renderEditor:t,active:n=!0,intro:r,projectId:i}){let a=e,o=Y6(i??a.view?.revision.projectId??``),s=i===void 0?null:(0,h.jsx)(IGe,{projectId:i,dirty:a.unsaved});if(a.view===void 0||a.edit===void 0)return(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[s,r??(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,...GT,children:[(0,h.jsx)(lD,{title:`Saved version`,className:`pb-0`}),(0,h.jsx)(KT,{children:`Each save is a version, listed under Versions. Saving never starts work.`})]}),a.saved.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:a.saved.error.message}),a.saved.data===void 0?null:(0,h.jsx)(`ul`,{"aria-label":`Saved output status`,className:`sl-list m-0 list-none p-0`,children:a.saved.data.outputs.filter(e=>e.selected).map(e=>(0,h.jsxs)(`li`,{className:`sl-row`,children:[(0,h.jsx)(`span`,{className:`sl-row__title`,children:q3(e.output)}),(0,h.jsx)(`span`,{className:`sl-row__meta`,children:I3(e.state,e.output.role,e.available)})]},e.recordId))})]}),a.preview===void 0&&n?(0,h.jsx)(M5,{error:a.error,refusal:a.refusal}):null,(0,h.jsxs)(uL,{status:a.notice?.kind===`discarded`?(0,h.jsxs)(lL,{children:[(0,h.jsx)(`span`,{className:`min-w-0 truncate`,children:`Changes discarded.`}),(0,h.jsx)(K,{size:`small`,variant:`quiet`,onClick:a.undoDiscard,children:`Undo`})]}):void 0,children:[a.refusal?.reason===`conflict`&&n?(0,h.jsx)(K,{disabled:a.pending,onClick:a.reloadCurrent,children:`Reload the current version`}):null,(0,h.jsx)(K,{disabled:a.busy,onClick:()=>a.review({kind:`allAffected`}),variant:`secondary`,children:`Choose what to make again`}),(0,h.jsx)(K,{variant:`primary`,disabled:a.busy,onClick:a.openEditor,children:`Edit settings again`})]})]});let c=a.remoteChanged||a.refusal?.reason===`conflict`;return(0,h.jsxs)(`form`,{"aria-label":`Edit settings`,onSubmit:e=>{e.preventDefault(),a.save()},children:[s,o?(0,h.jsx)(`p`,{className:`m-0 mb-3 text-small text-ink-2`,children:J6}):null,(0,h.jsx)(`fieldset`,{disabled:a.pending,className:`m-0 min-w-0 border-0 p-0`,children:t({view:a.view,edit:a.edit,fields:a.refusal?.fields??[],onChange:a.setEdit,onPending:a.setUploading,readOnly:o,...a.focus===void 0?{}:{focus:a.focus}})}),a.preview===void 0?(0,h.jsx)(M5,{error:a.error,refusal:a.refusal}):null,(0,h.jsxs)(uL,{status:o?void 0:(0,h.jsx)(RGe,{c:a}),children:[c?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(K,{variant:`quiet`,disabled:a.pending,onClick:a.copyEdit,children:`Copy my edit`}),(0,h.jsx)(K,{disabled:a.pending||a.uploading,onClick:a.reapply,children:`Reload latest and re-apply my edit`})]}):null,(0,h.jsx)(K,{variant:`quiet`,disabled:a.pending||a.uploading||o,onClick:a.discard,children:`Discard changes`}),(0,h.jsx)(K,{variant:`primary`,type:`submit`,disabled:a.pending||a.uploading||o||!a.unsaved,focusableWhenDisabled:o||!a.unsaved,disabledReason:o?J6:`Change a setting first`,children:`Save changes`})]})]})}function BGe({controller:e,projectId:t,active:n}){let r=e;return n?(0,h.jsxs)(h.Fragment,{children:[r.preview===void 0&&(r.error||r.refusal)?(0,h.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3`,children:[(0,h.jsx)(M5,{error:r.error,refusal:r.refusal}),r.edit===void 0&&r.refusal?.reason===`conflict`?(0,h.jsx)(K,{disabled:r.pending,onClick:r.reloadCurrent,className:`self-start`,children:`Reload the current version`}):null]}):null,(0,h.jsx)(AGe,{projectId:t,pending:r.busy,onRestore:r.restore})]}):null}function VGe({controller:e}){let t=e;return(0,h.jsx)(LT,{open:t.preview!==void 0,title:`Choose what to make again`,onClose:t.closePreview,children:t.preview===void 0?null:(0,h.jsx)(SGe,{preview:t.preview,feedback:(0,h.jsx)(M5,{error:t.error,refusal:t.refusal}),pending:t.pending,onStart:t.start,onCancel:t.closePreview},t.preview.id)})}function HGe({projectId:e,revisionId:t,title:n,open:r,onClose:i}){let{api:a}=q(),o=_(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(null),p=Vx(),g=Ji(),v=(0,m.useRef)(!1),y=(0,m.useRef)(null);(0,m.useEffect)(()=>{r&&t!==null&&(c({revisionId:t,name:n}),f(null)),r||c(null)},[r,t,n]);async function b(){if(!s||v.current||!s.name.trim())return;v.current=!0,u(!0),f(null);let t=JSON.stringify([e,s.revisionId,s.name.trim()]);y.current?.key!==t&&(y.current={key:t,id:crypto.randomUUID()});try{let t=await ixe(a,e,{id:y.current.id,name:s.name.trim(),revisionId:s.revisionId});if(!t.ok){y.current=null,f(t.message);return}y.current=null,i(),p(`Template saved. Look it over section by section in Edit template.`,`success`),await o.invalidateQueries({queryKey:PM}),await g({to:`/templates/$templateId`,params:{templateId:t.value.id}})}catch(e){f(e instanceof Error?e.message:`The template wasn't saved. Press Save template to try again.`)}finally{v.current=!1,u(!1)}}return(0,h.jsx)(jE,{open:r&&s!==null,onOpenChange:e=>{!e&&!v.current&&i()},title:`Save as template`,description:`Saves how this project was made (its prompts, voice, images and style) as a template new projects can start from. This project stays as it is.`,children:(0,h.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,h.jsx)(J,{label:`Template name`,tip:`play.template-name`,children:(0,h.jsx)(Y,{autoFocus:!0,required:!0,maxLength:200,disabled:l,value:s?.name??``,onChange:e=>{let t=e.target.value;c(e=>e&&{...e,name:t})}})}),d?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:d}):null,(0,h.jsxs)(`div`,{className:`sl-dialog__foot`,children:[(0,h.jsx)(K,{disabled:l,onClick:i,children:`Cancel`}),(0,h.jsx)(K,{variant:`primary`,type:`submit`,disabled:l||!s?.name.trim(),children:`Save template`})]})]})})}var $5=[{stage:`audio`},{stage:`images`},{stage:`video`}];function UGe({projectId:e,revisionId:t,gates:n,stages:r,reload:i,saved:a}){let{api:o}=q(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(null),p=(0,m.useRef)(!1),g=(0,m.useRef)(!0),_=(0,m.useRef)(null),v=(0,m.useRef)(null),y=JSON.stringify([t,n.map(e=>[e.stage,e.checkpointId]).toSorted()]),b=s!==null&&s.baseIdentity!==y,x=s?.stages??n.map(e=>e.stage),S=$5.some(({stage:e})=>x.includes(e)!==n.some(t=>t.stage===e)),C=b||d!==null&&d.kind!==`success`,w=b?{kind:`refused`,message:`The pauses changed elsewhere. Press Load the pauses again before saving, then make your change again.`}:d;(0,m.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]),(0,m.useEffect)(()=>{(d||b)&&_.current?.focus()},[d,b]);async function T(){if(!(p.current||!S||C)){p.current=!0,u(!0);try{let n=await WIe(o,e,{revisionId:t,stages:x});if(!g.current)return;n.ok?n.value.revisionId===t?(a(n.value),c(null),f({kind:`success`,message:`Pauses saved.`})):f({kind:`refused`,message:`The project was edited elsewhere. Press Load the pauses again to see its current ones.`}):f({kind:`refused`,message:n.message})}catch(e){g.current&&f({kind:`transport`,message:`${Cm(e instanceof Error?e.message:`Slopify didn't confirm the change`)} It may or may not have saved. Press Load the pauses again before changing anything else.`})}finally{p.current=!1,g.current&&u(!1)}}}async function E(){if(!p.current){p.current=!0,u(!0);try{let e=await i();g.current&&e&&(c(null),f(null),v.current?.focus())}finally{p.current=!1,g.current&&u(!1)}}}let D=e=>{let t=r.find(t=>t.kind===e);return t?.state===`pending`&&(e===`video`?t.source!==`off`||r.some(e=>e.kind===`audio`&&e.source!==`off`&&e.state!==`skipped`):(t.source??`generate`)===`generate`)};if(!S&&$5.every(({stage:e})=>!D(e))&&r.every(e=>e.state!==`running`&&e.state!==`failed`))return(0,h.jsxs)(`section`,{"aria-label":`Pauses for this run`,className:`space-y-1`,...GT,children:[(0,h.jsx)(`p`,{className:`m-0 font-semibold`,children:`Pauses for this run`}),(0,h.jsx)(KT,{children:`Nothing is left to pause: every step a pause can hold has run. Making something again starts once you have seen what it costs, without a pause.`})]});let O=e=>{let t=r.find(t=>t.kind===e);return t===void 0?`off`:t.source??`generate`},k={audio:O(`audio`),images:O(`images`),video:O(`video`)};return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`fieldset`,{ref:v,tabIndex:-1,className:`space-y-1`,...GT,children:[(0,h.jsx)(`legend`,{className:`font-semibold`,children:`Pauses for this run`}),(0,h.jsx)(KT,{children:`The run waits under Home → Needs you until you approve what it made.`}),$5.map(({stage:e})=>{let t=D(e);return(0,h.jsxs)(`label`,{className:`flex min-h-10 items-center gap-3`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:x.includes(e),disabled:!t||l||C,onChange:t=>{c({baseIdentity:s?.baseIdentity??y,stages:t.target.checked?[...x,e]:x.filter(t=>t!==e)}),f(null)}}),CP(e,{sources:k})]},e)})]}),w?(0,h.jsx)(`p`,{ref:_,tabIndex:-1,role:w.kind===`success`?`status`:`alert`,children:w.message}):null,S?(0,h.jsx)(K,{type:`button`,disabled:l||C,onClick:()=>void T(),children:l?`Saving…`:`Save pauses`}):null,C?(0,h.jsx)(K,{type:`button`,disabled:l,onClick:()=>void E(),children:`Load the pauses again`}):null]})}var WGe=e=>ZD[e],e7=e=>ZD[e].toLowerCase();function GGe(e){return e.revisionId===null?null:(0,h.jsx)(KGe,{...e,revisionId:e.revisionId},`${e.projectId}:${e.revisionId}`)}function KGe({projectId:e,revisionId:t,paused:n,stages:r}){let{api:i}=q(),a=_(),o=I({queryKey:a2(e,t),queryFn:()=>s2(i,e),retry:!1}),s=o.data,c=async()=>{let e=await o.refetch();return!e.isError&&e.data?.ok===!0&&e.data.value.revisionId===t?e.data.value:void 0},l=async()=>{let e=await o.refetch();return!e.isError&&e.data?.ok===!0&&e.data.value.revisionId===t};return o.isPending?null:o.error||s?.ok===!1?(0,h.jsxs)(`section`,{"aria-label":`Pauses`,className:`flex flex-col items-start gap-3`,children:[(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:o.error?.message??(s?.ok===!1?s.message:`The pauses couldn't be loaded. Press Load the pauses again.`)}),(0,h.jsx)(K,{onClick:()=>void l(),children:`Load the pauses again`})]}):s?.ok?s.value.revisionId===t?(0,h.jsxs)(`section`,{"aria-label":`Pauses`,className:`flex flex-col gap-4`,children:[n?(0,h.jsx)(`p`,{className:`m-0 text-small text-waiting`,children:`The project is paused. Continue the run before approving held work.`}):null,(0,h.jsx)(UGe,{projectId:e,revisionId:t,gates:s.value.checkpoints,stages:r,reload:c,saved:n=>{a.setQueryData(a2(e,t),{ok:!0,value:n}),a.invalidateQueries({queryKey:X.project(e)}),a.invalidateQueries({queryKey:X.projects})}}),s.value.checkpoints.filter(qGe).map(i=>(0,h.jsx)(JGe,{gate:i,disabled:n||i.projectId!==e||i.revisionId!==t||r.some(e=>e.kind===i.stage&&[`running`,`canceled`].includes(e.state)),reload:l,current:i.revisionId===t},`${i.checkpointId}:${i.fingerprint}`))]}):(0,h.jsx)(`section`,{"aria-label":`Pauses`,className:`flex flex-col items-start gap-3`,children:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The project was edited after these pauses loaded. Press Load the pauses again before approving.`})}):null}function qGe(e){return e.state!==`configured`||e.fingerprint!==e.currentFingerprint}function JGe({gate:e,disabled:t,reload:n,current:r}){let{api:i}=q(),a=_(),o=(0,m.useRef)(null),s=(0,m.useRef)(!1),c=(0,m.useRef)(!0),l=(0,m.useRef)(null),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null);(0,m.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]),(0,m.useEffect)(()=>{f!==null&&l.current?.focus()},[f]);let g=[`configured`,`pending-review`,`held`].includes(e.state)&&e.fingerprint===e.currentFingerprint;async function v(){if(!(s.current||t||!g||f?.kind===`refused`||f?.kind===`success`)){s.current=!0,d(!0),o.current??={revisionId:e.revisionId,fingerprint:e.fingerprint,idempotencyKey:crypto.randomUUID()};try{let t=await c2(i,e.projectId,e.checkpointId,o.current);o.current=null,c.current&&p(t.ok?{kind:`success`,message:t.value.replayed?`It was already approved.`:`Approved. What comes after it runs once what it needs is ready.`}:{kind:`refused`,message:t.message}),a.invalidateQueries({queryKey:i2(e.projectId)}),a.invalidateQueries({queryKey:X.project(e.projectId)}),a.invalidateQueries({queryKey:X.projects})}catch(e){c.current&&p({kind:`transport`,message:`${Cm(e instanceof Error?e.message:`Slopify didn't confirm the approval`)} Press Retry approval to check whether it went through.`})}finally{s.current=!1,c.current&&d(!1)}}}return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-line pt-3`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:`Paused after the ${t7(e.stage)}`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.state===`released`&&e.approvedAt!==null?`Approved for this version. What comes after it runs once what it needs is ready and the run goes on.`:e.state===`satisfied`?`Approved, and what came after it is made.`:e.state===`invalidated`||e.fingerprint!==e.currentFingerprint?`What it was made from has changed. Look at the current version before approving.`:g?`The ${t7(e.stage)} ${YGe(e.stage)} ready for your review. The ${e7(e.stage)} and what follows wait for your approval; other work goes on.`:`Not reached yet.`}),r?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,title:`Version ${e.revisionId}`,children:`Set on an earlier version. Press Load the pauses again to see the current one.`}),e.dependents.length===0?null:(0,h.jsx)(`ul`,{"aria-label":`Waits for this approval`,className:`m-0 flex list-none flex-wrap gap-2 p-0`,children:e.dependents.map(e=>(0,h.jsx)(`li`,{className:`sl-chip`,children:WGe(e)},e))}),f?(0,h.jsx)(`p`,{ref:l,tabIndex:-1,role:f.kind===`success`?`status`:`alert`,className:f.kind===`success`?`m-0 text-small`:`m-0 text-small text-danger`,children:f.message}):null,g?(0,h.jsx)(K,{className:`self-start`,disabled:t||u||f?.kind===`refused`||f?.kind===`success`,disabledReason:t?`Continue the run first, then approve`:`Working on the last press`,onClick:()=>void v(),children:u?`Approving…`:f?.kind===`transport`?`Retry approval`:`Approve and make the ${e7(e.stage)}`}):null,f?.kind===`refused`?(0,h.jsx)(K,{className:`self-start`,onClick:async()=>{await n()&&p(null)},children:`Load the pauses again`}):null]})}function t7(e){switch(e){case`audio`:return`article`;case`images`:return`narration`;case`video`:return`images`;default:return e7(e)}}var YGe=e=>e===`video`?`are`:`is`;function n7(e){if(e<1024)return`${String(e)} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e,r=t[0];for(let e of t)if(n/=1024,r=e,n<1024||e===t.at(-1))break;return`${n>=10?n.toFixed(0):n.toFixed(1).replace(/\.0$/,``)} ${r}`}function r7(e,t=`projects`){return`This deletes ${e===void 0?`the older versions`:`${String(e.files)} file(s) of older versions and frees ${n7(e.bytes)}`}: what is in ${t===`project`?`this project's History folder`:`the projects' History folders`} (earlier renders, narration before a change). The current video, shorts, thumbnails and everything in Upload stay, and so does anything you uploaded or put there yourself. Going back to one of those older versions makes its files again, which takes time and uses provider credits.`}function XGe({projects:e,samples:t=new Set,queryKey:n}){let{api:r}=q(),i=_(),a=Vx(),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(),u=(e,t,n,r)=>e===0?`Nothing left to remove ${r}.`:`Freed ${n7(t)} ${r} (${String(e)} ${n}${e===1?``:`s`}).`,d=L({mutationFn:async e=>{switch(e.kind){case`old`:return{...await Nm(r,e.project.id),skipped:0};case`trim`:return{...await Pm(r,e.project.id),skipped:0};case`all-old`:{let e=await hte(r);return{...e,skipped:e.busy}}case`cleanup`:return gte(r)}},onMutate:()=>l(void 0),onSuccess:(e,t)=>{let n=t.kind===`old`||t.kind===`trim`?`from "${t.project.title}"`:`across your projects`,r=t.kind===`trim`?`working file`:`file`,i=e.skipped===0?``:` ${String(e.skipped)} project${e.skipped===1?` was`:`s were`} running or not finished and kept everything.`;a(`${u(e.files,e.bytesFreed,r,n)}${i}`,`success`)},onError:e=>l(e.message),onSettled:()=>i.invalidateQueries({queryKey:n})}),f=e.toSorted((e,t)=>t.bytes-e.bytes),p=e.reduce((e,t)=>e+t.historyBytes,0),g=e.reduce((e,t)=>e+t.historyFiles,0),v=e.reduce((e,t)=>e+(t.finished?t.removableBytes:0),0),y=e.reduce((e,t)=>e+(t.finished?t.removableFiles:0),0),b=d.isPending,x=(e,t)=>b&&d.variables?.kind===e&&(t===void 0||`project`in d.variables&&d.variables.project.id===t);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[p===0?null:(0,h.jsx)(K,{variant:`secondary`,size:`small`,disabled:b,onClick:()=>s({kind:`all-old`}),children:x(`all-old`)?`Deleting…`:`Delete all old versions (${n7(p)})`}),p+v===0?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Nothing to clean up.`}):(0,h.jsx)(K,{variant:`secondary`,size:`small`,disabled:b,onClick:()=>s({kind:`cleanup`}),children:x(`cleanup`)?`Cleaning up…`:`Clean up everything (${n7(p+v)})`})]}),(0,h.jsx)(BL,{label:`Storage by project`,children:f.map(e=>{let n=t.has(e.id);return(0,h.jsx)(VL,{title:e.title,meta:(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[n?`Sample · `:``,n7(e.bytes),` · outputs `,n7(e.outputsBytes),` · working files `,n7(e.workingBytes),e.historyBytes>0?` · old versions ${n7(e.historyBytes)}`:``,!n&&!e.finished?` · not finished yet`:``]}),actions:(0,h.jsxs)(h.Fragment,{children:[n?(0,h.jsx)(eE,{to:`/projects/$projectId`,params:{projectId:e.id},className:`text-small`,children:`Open`}):null,e.historyBytes>0&&!n?(0,h.jsx)(K,{variant:`quiet`,size:`small`,disabled:b,title:`Frees ${n7(e.historyBytes)}.`,onClick:()=>s({kind:`old`,project:e}),children:x(`old`,e.id)?`Deleting…`:`Delete old versions`}):null,n||!e.finished||e.removableBytes===0?null:(0,h.jsx)(K,{variant:`quiet`,size:`small`,disabled:b,title:`Frees ${n7(e.removableBytes)}.`,onClick:()=>s({kind:`trim`,project:e}),children:x(`trim`,e.id)?`Removing…`:`Keep outputs only`})]})},e.id)})}),c===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:c}),(0,h.jsx)(ME,{open:o!==void 0,title:o?.kind===`old`?`Delete the old versions of "${o.project.title}"?`:o?.kind===`trim`?`Keep only the outputs of "${o.project.title}"?`:o?.kind===`all-old`?`Delete every project's old versions?`:`Clean up every project?`,consequence:o?.kind===`old`?r7({files:o.project.historyFiles,bytes:o.project.historyBytes}):o?.kind===`trim`?i7(o.project.removableFiles,o.project.removableBytes):o?.kind===`all-old`?r7({files:g,bytes:p}):`${r7({files:g,bytes:p})} ${i7(y,v)} Projects that are running or not finished keep everything.`,confirmLabel:o?.kind===`trim`?`Keep outputs only`:o?.kind===`cleanup`?`Clean up everything`:`Delete old versions`,cancelLabel:`Keep everything`,pending:b,onConfirm:()=>{let e=o;s(void 0),e!==void 0&&d.mutate(e)},onCancel:()=>s(void 0)})]})}function i7(e,t){return`This removes ${String(e)} working file(s) and frees ${n7(t)}: the narration parts, caption timing and render settings the project was made from. The video, shorts, their images, thumbnail, article, description and document stay, and so does anything you uploaded. If you change this project later (a caption style or the narration, or re-render), Slopify has to make those files again first, which takes time and may cost money again.`}var a7=X.projectStorage;function ZGe({projectId:e,title:t,status:n,sample:r}){let{api:i}=q(),a=_(),o=Vx(),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),d=n===`done`||n===`partial`,f=I({queryKey:[...a7(e),n],queryFn:()=>mte(i,e),enabled:d&&!r}),p=L({mutationFn:()=>Pm(i,e),onSuccess:e=>o(e.files===0?`"${t}" had no working files left to remove.`:`Freed ${n7(e.bytesFreed)} from "${t}". The outputs are all still here.`,`success`),onError:e=>o(`The working files of "${t}" weren't removed: ${e.message}`,`error`),onSettled:async()=>{await Promise.all([a.invalidateQueries({queryKey:a7(e)}),a.invalidateQueries({queryKey:X.storageUsage}),a.invalidateQueries({queryKey:X.project(e)})])}}),g=L({mutationFn:()=>Nm(i,e),onSuccess:e=>o(e.files===0?`"${t}" had no old versions left to delete.`:`Freed ${n7(e.bytesFreed)} from "${t}". The current version is all still here.`,`success`),onError:e=>o(`The old versions of "${t}" weren't deleted: ${e.message}`,`error`),onSettled:async()=>{await Promise.all([a.invalidateQueries({queryKey:a7(e)}),a.invalidateQueries({queryKey:X.storageUsage}),a.invalidateQueries({queryKey:X.project(e)})])}}),v=f.data;if(!d||r||v===void 0||!v.finished||v.removableBytes===0&&v.historyBytes===0)return null;let y=n7(v.removableBytes),b=n7(v.historyBytes);return(0,h.jsxs)(`section`,{"aria-label":`Free space`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(lD,{as:`h3`,title:`Free space`,meta:`Outputs ${n7(v.outputsBytes)} · working files ${n7(v.workingBytes)}${v.historyBytes>0?` · old versions ${b}`:``}`,children:v.removableBytes>0?(0,h.jsx)(K,{variant:`secondary`,size:`small`,"aria-label":`Free ${y}: keep the outputs, drop the working files`,disabled:p.isPending,disabledReason:`Removing the working files…`,onClick:()=>c(!0),children:p.isPending?`Removing…`:`Free ${y}`}):null}),v.historyBytes>0?(0,h.jsx)(K,{variant:`quiet`,size:`small`,className:`self-start`,disabled:g.isPending,disabledReason:`Deleting the old versions…`,onClick:()=>u(!0),children:g.isPending?`Deleting…`:`Delete old versions (${b})`}):null,(0,h.jsx)(ME,{open:l,title:`Delete the old versions of "${t}"?`,consequence:r7({files:v.historyFiles,bytes:v.historyBytes}),confirmLabel:`Free ${b}`,cancelLabel:`Keep the old versions`,pending:g.isPending,onConfirm:()=>{u(!1),g.mutate()},onCancel:()=>u(!1)}),(0,h.jsx)(ME,{open:s,title:`Free ${y} from "${t}"?`,consequence:i7(v.removableFiles,v.removableBytes),confirmLabel:`Free ${y}`,cancelLabel:`Keep the working files`,pending:p.isPending,onConfirm:()=>{c(!1),p.mutate()},onCancel:()=>c(!1)})]})}function QGe({cues:e,duration:t,onChange:n,onPending:r,audition:i}){let a=(0,m.useId)(),[o,s]=(0,m.useState)(()=>e.map(e=>({...e,start:String(e.start),end:String(e.end)}))),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(r);f.current=r,(0,m.useEffect)(()=>{f.current(u)},[u]),(0,m.useEffect)(()=>()=>f.current(!1),[]);function p(){let e=[],r=new Set,i=0;if(!Number.isFinite(t)||t<=0)l(`The narration length isn't known yet, so captions can't be checked. Reload the page and try again.`);else{for(let[n,a]of o.entries()){let o=a.start.trim()===``?NaN:Number(a.start),s=a.end.trim()===``?NaN:Number(a.end);if(r.has(a.id)){l(`Caption ${n+1}: this caption is listed twice. Remove the copy.`);return}if(r.add(a.id),!Number.isFinite(o)||o<0||o<i){l(`Caption ${n+1}: start must be a number of seconds, no earlier than the previous caption's end.`);return}if(!Number.isFinite(s)||s<=o||s>t){l(`Caption ${n+1}: end must be after its start and no later than the end of the narration.`);return}if(a.text.trim()===``){l(`Caption ${n+1}: enter caption text.`);return}e.push({id:a.id,text:a.text,start:o,end:s,...a.speaker===void 0?{}:{speaker:a.speaker}}),i=s}n(e),l(void 0),d(!1)}}return(0,h.jsxs)(`section`,{"aria-label":`Edit caption cues`,className:`space-y-3`,...GT,children:[(0,h.jsx)(`h3`,{children:`Caption text and timing`}),(0,h.jsx)(KT,{children:`Times are seconds from the start of the narration; edits are free and only the captions and the video are made again.`}),o.map((e,t)=>(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line-strong p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Caption `,t+1]}),i?.play===void 0?null:(0,h.jsx)($Ge,{audition:i,id:e.id,number:t+1,start:Number(e.start),end:Number(e.end)}),(0,h.jsxs)(`label`,{htmlFor:`${a}-${e.id}-text`,className:`block text-small`,children:[`Text for caption `,t+1,(0,h.jsx)(XT,{id:`${a}-${e.id}-text`,value:e.text,onChange:n=>{d(!0),s(o.with(t,{...e,text:n.target.value}))}})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`label`,{htmlFor:`${a}-${e.id}-start`,className:`block text-small`,children:[`Start for caption `,t+1,(0,h.jsx)(Y,{id:`${a}-${e.id}-start`,inputMode:`decimal`,value:e.start,onChange:n=>{d(!0),s(o.with(t,{...e,start:n.target.value}))}})]}),(0,h.jsxs)(`label`,{htmlFor:`${a}-${e.id}-end`,className:`block text-small`,children:[`End for caption `,t+1,(0,h.jsx)(Y,{id:`${a}-${e.id}-end`,inputMode:`decimal`,value:e.end,onChange:n=>{d(!0),s(o.with(t,{...e,end:n.target.value}))}})]})]})]},e.id)),c===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-danger`,children:c}),(0,h.jsx)(K,{type:`button`,onClick:p,children:`Apply caption edits to draft`}),u?(0,h.jsx)(`p`,{children:`Apply these caption edits before saving the project.`}):null]})}function $Ge({audition:e,id:t,number:n,start:r,end:i}){let a=e.playing===t;return(0,h.jsx)(K,{type:`button`,size:`small`,variant:`quiet`,disabled:!(Number.isFinite(r)&&Number.isFinite(i)&&i>r&&r>=0),disabledReason:`Enter a start and an end in seconds to play this caption`,"aria-label":a?`Stop caption ${String(n)}`:`Play caption ${String(n)}`,onClick:()=>a?e.stop():e.play?.(r,i,t),children:a?`Stop`:`Play`})}function o7(e){return`imagePrompts.${String(e)}`}function s7(e){let t=/^imagePrompts\.(\d+)$/.exec(e??``);return t?.[1]===void 0?void 0:Number(t[1])}function eKe(e,t){return e.length===t.length&&e.every((e,n)=>e.name===t[n]?.name&&e.number===t[n]?.number)}function tKe(e){let{from:t,to:n,content:r}=e,i=n.map(e=>t.findIndex(t=>t.name===e.name)),a=[],o={},s={};for(let[e,t]of Object.entries(r.promptTemplates))s7(e)===void 0&&(o[e]=t);for(let[t,n]of Object.entries(e.rendered))s7(t)===void 0&&(s[t]=n);for(let[t,c]of n.entries()){let n=o7(t),l=i[t]??-1;if(l>=0){let t=o7(l);Object.hasOwn(r.promptTemplates,t)&&(o[n]=r.promptTemplates[t]??null);let i=e.rendered[t];i!==void 0&&(s[n]=i);continue}let u=e.body(c.name);u===void 0?a.push({field:`imagePrompts.${String(t)}.name`,message:`The image prompt "${c.name}" is not in Prompts any more. Untick it under Images, or add it back in Prompts → Image.`}):(o[n]=u,s[n]=Ok(u,e.values))}if(a.length>0)return{ok:!1,fields:a};let c=new Map;for(let e of r.imageOrder){let n=s7(r.imageDefinitions[e]?.templateKey);n===void 0||n>=t.length||c.set(n,[...c.get(n)??[],e])}let l={},u=[],d=[],f=(e,t)=>{let n=o7(e),r=o[n];return t===void 0?{source:`generate`,assetId:null,prompt:s[n]??null,templateKey:r==null?null:n}:{...t,source:`generate`,assetId:null,templateKey:t.templateKey??null}},p=(t,n,r)=>Array.from({length:Math.max(0,n)},()=>{let n=e.key();return l[n]=f(t,r),u.push(n),n}),m=[];for(let e of r.imageOrder){let a=r.imageDefinitions[e];if(a===void 0)continue;let o=s7(a.templateKey);if(o===void 0||o>=t.length){l[e]=a,m.push(e);continue}let s=i.indexOf(o);if(s===-1){d.push(e);continue}let u=c.get(o)??[],f=t[o]?.number!==n[s]?.number,h=f?n[s]?.number??0:u.length,g=u.indexOf(e);if(g>=h){d.push(e);continue}let _=a.templateKey===o7(s)?a:{...a,templateKey:o7(s)};l[e]=_,m.push(e),f&&g===Math.min(u.length,h)-1&&m.push(...p(s,h-u.length,_))}for(let[e,r]of n.entries()){let n=i[e]??-1,a=n>=0?c.get(n)??[]:[];n>=0&&(a.length>0||t[n]?.number===r.number)||m.push(...p(e,r.number,void 0))}return{ok:!0,content:{...r,imageOrder:m,imageDefinitions:l,promptTemplates:o},rendered:s,added:u,removed:d}}function nKe({edit:e,saved:t,prompts:n,problem:r,onChange:i}){let{config:a}=e;if(a.sources.images!==`generate`)return null;let o=n.filter(e=>e.kind===`image`);return(0,h.jsxs)(`section`,{"aria-label":`Image prompts`,className:`space-y-3`,children:[(0,h.jsx)(DB,{prompts:o,picked:a.imagePrompts,problem:r,onPick:t=>i({...e,config:{...a,imagePrompts:t}})}),(0,h.jsx)(rKe,{edit:e,saved:t,prompts:o,problem:r})]})}function rKe({edit:e,saved:t,prompts:n,problem:r}){let i=e.config.imagePrompts,a=r(`imagePrompts`);if(eKe(t,i))return a===void 0?null:(0,h.jsx)(c7,{children:a});let o=0,s=tKe({from:t,to:i,content:e.content,rendered:e.config.rendered,values:e.config.values,body:e=>n.find(t=>t.name===e)?.body,key:()=>`planned-${String(++o)}`});if(!s.ok)return(0,h.jsx)(c7,{children:s.fields.map(e=>e.message).join(` `)});let c=e=>`${String(e)} ${e===1?`image`:`images`}`,l=[...s.added.length>0?[`adds ${c(s.added.length)} to make`]:[],...s.removed.length>0?[`removes ${c(s.removed.length)}`]:[]];return(0,h.jsxs)(h.Fragment,{children:[a===void 0?null:(0,h.jsx)(c7,{children:a}),(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:l.length===0?`Saving keeps every image as it is.`:`Saving ${l.join(` and `)}. The other images are kept; the new ones are made when you make the outdated images again.`})]})}function c7({children:e}){return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:e})}function iKe({edit:e,problem:t,onChange:n}){let r=e.config.ambientBed,[i,a]=(0,m.useState)(()=>r===void 0?void 0:wA(r)),o=r?.source===`upload`?[...yA,`upload`]:yA,s=i===void 0?[]:[...sKe(i)];return(0,h.jsx)(k$,{value:i,inherit:`None`,sources:o,offerNone:!1,problem:e=>t(`ambientBed.${e}`)??s.find(t=>t.field===e)?.message,onChange:t=>{a(t);let r=TA(t),{ambientBed:i,...o}=e.config;n({...e,config:r===void 0?o:{...o,ambientBed:r}})}})}function aKe({edit:e,problem:t,onChange:n}){let r=e.config.loudness,[i,a]=(0,m.useState)(()=>r===void 0?{...zk,enabled:!1}:{...r,enabled:!0});return(0,h.jsx)(U4,{value:i,video:e.config.sources.video!==`off`,problem:e=>t(`loudness.${e}`),onChange:t=>{a(t);let{loudness:r,...i}=e.config;n({...e,config:t.enabled?{...i,loudness:{videoLufs:t.videoLufs,audioFilesLufs:t.audioFilesLufs}}:i})}})}function oKe({edit:e,problem:t,onChange:n}){let[r,i]=(0,m.useState)(()=>({sentencePauseSeconds:String(e.config.sentencePauseSeconds??0),paragraphPauseSeconds:String(e.config.paragraphPauseSeconds??0)}));if(e.config.sources.audio!==`generate`)return null;let a=e=>{let t=Q4(r[e]);return t===void 0?`Enter a number of seconds.`:Xk(t,e===`sentencePauseSeconds`?`sentences`:`paragraphs`)};return(0,h.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-3`,children:[(0,h.jsx)(q4,{sentence:r.sentencePauseSeconds,paragraph:r.paragraphPauseSeconds,problem:e=>a(e)??t(e),onChange:(t,a)=>{i({...r,[t]:a});let o=Q4(a);if(o===void 0)return;let{[t]:s,...c}=e.config;n({...e,config:o===0?c:{...c,[t]:o}})}}),(0,h.jsx)(J4,{value:e.config.removeBreaths===!0,onChange:t=>{let{removeBreaths:r,...i}=e.config;n({...e,config:t?{...i,removeBreaths:!0}:i})}}),(0,h.jsx)(Y4,{value:e.config.deEss===!0,onChange:t=>{let{deEss:r,...i}=e.config;n({...e,config:t?{...i,deEss:!0}:i})}}),(0,h.jsx)(X4,{value:e.config.levelSentences===!0,onChange:t=>{let{levelSentences:r,...i}=e.config;n({...e,config:t?{...i,levelSentences:!0}:i})}})]})}function sKe(e){let t=TA(e);return t===void 0?[]:SA(t)}function cKe({edit:e,problem:t,onChange:n}){let r=(0,m.useId)(),{config:i}=e,a=i.imageScale,[o,s]=(0,m.useState)(()=>a===void 0?void 0:zve(a));if(i.sources.images!==`generate`)return null;let c=a?.words??(ck(e.content.articleMarkdown??``)||1500),l=t=>{s(t);let{imageScale:r,...o}=i;if(t===void 0){n({...e,config:o});return}let l=l7(t);l!==void 0&&n({...e,config:{...o,imageScale:{perHour:l,words:c},...a===void 0&&i.motionStyle===`zoom`?{motionStyle:`mixed`}:{}}})},u=i.imagePrompts.reduce((e,t)=>e+t.number,0),d=a===void 0?u:fk(i).reduce((e,t)=>e+t,0),f=o===void 0?void 0:l7(o),p=o===void 0?void 0:f===void 0?{problem:!0,text:o.every===`minutes`?`Enter a number of minutes between ${String(sk)} and 60.`:`Enter a number of images per hour between 1 and 240.`}:{problem:!1,text:`For about ${String(Math.max(1,Math.round(lk(c))))} minutes of narration: ${String(d)} images${d>u?`, ${String(d-u)} more than the prompts' ${String(u)}`:`, which the prompts' Numbers already cover`}.`},g=t(`imageScale`)??void 0;return(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,...GT,children:[(0,h.jsx)(dD,{checked:o!==void 0,label:`More images for long videos`,describedBy:`${r}-line`,tip:`play.image-scale`,onChange:e=>l(e?{every:`minutes`,value:`2`}:void 0)}),o===void 0?null:(0,h.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-small`,children:[(0,h.jsx)(fD,{label:`How the rate is given`,value:o.every,options:[{value:`minutes`,label:`Every N minutes`},{value:`hour`,label:`N per hour`}],onChange:e=>l({every:e,value:lKe(o.value,o.every,e)})}),o.every===`minutes`?(0,h.jsx)(`span`,{children:`One image every`}):null,(0,h.jsx)(Y,{"aria-label":o.every===`minutes`?`Minutes per image`:`Images per hour`,inputMode:`decimal`,className:`w-[72px] tabular-nums`,"aria-invalid":p?.problem===!0,"aria-describedby":`${r}-line`,value:o.value,onChange:e=>l({every:o.every,value:e.target.value})}),(0,h.jsx)(`span`,{children:o.every===`minutes`?`minutes`:`images per hour`})]}),g===void 0&&p===void 0?null:(0,h.jsx)(`p`,{id:`${r}-line`,className:g!==void 0||p?.problem?`m-0 text-label text-danger`:`m-0 text-label text-ink-3`,children:g??p?.text})]})}function l7(e){let t=Number(e.value.trim());if(e.value.trim()!==``&&Number.isFinite(t))return e.every===`minutes`?t>=.25&&t<=60?uk(t):void 0:t>=1&&t<=240?t:void 0}function lKe(e,t,n){if(t===n)return e;let r=Number(e.trim());return e.trim()===``||!Number.isFinite(r)||r<=0?e:String(Math.round(60/r*100)/100)}function uKe({edit:e,onChange:t}){let{config:n,content:r}=e;if(n.sources.images!==`generate`||n.sources.article===`off`)return null;let i=e=>r.promptTemplates[e]??n.rendered[e],a=n.imageScenes===!0?[]:V4([...n.imagePrompts.map((e,t)=>({label:`"${e.name}"`,body:i(`imagePrompts.${String(t)}`)})),...n.sources.thumbnail===`from_prompt`||n.sources.thumbnail===`prompt_by_llm`?[{label:`the thumbnail`,body:i(`thumbnailPrompt`)}]:[]]);return(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,...GT,children:[(0,h.jsx)(dD,{checked:n.imageScenes===!0,label:`Scenes from the article`,tip:`play.image-scenes`,onChange:r=>{let{imageScenes:i,...a}=n;t({...e,config:{...a,...r?{imageScenes:!0}:{}}})}}),(0,h.jsx)(H4,{uses:a})]})}function dKe({edit:e,view:t,imageKey:n,index:r}){let{api:i}=q(),a=e.content.imageDefinitions[n];if(a===void 0)return null;let o=t?.outputs.filter(e=>e.output.stageKind===`images`&&e.output.role===`image`)??[],s=o.find(e=>e.selected&&e.workKey===`image:${n}`),c=e.uploads?.some(e=>e.destination.kind===`image`&&e.destination.imageKey===n)??!1,l=a.source===`generate`||c||s?.assetId===a.assetId?s:o.find(e=>e.assetId===a.assetId&&e.available),u=l?.available===!0,d=!u&&(l!==void 0||a.source===`provide`&&a.assetId!==null),f=e.regenerate?.includes(`image:${n}`)===!0,p=c?u?`Replacement ready to save; previous image shown until Save`:`Replacement ready to save; preview available after Save`:f?`Made again after you press Save changes; the current image stays until then`:d?`Image file unavailable`:u?a.source===`provide`&&l!==s?`Provided image selected`:l.state===`review`?`Image retained; review required`:l.state===`outdated`?`Outdated image retained until rebuilt`:`Current image retained`:`No completed image yet`,m=u&&/\.(mp4|mov|m4v|webm|mkv)$/i.test(l.output.path);return(0,h.jsxs)(h.Fragment,{children:[!u||t===void 0?null:m?(0,h.jsx)(sR,{className:`max-w-[240px]`,label:`Video clip ${r+1}`,src:AJ(i,t.revision.projectId,t.revision.id,l.recordId)}):(0,h.jsx)(uR,{className:`max-w-[240px]`,alt:`Retained scene ${r+1}`,src:AJ(i,t.revision.projectId,t.revision.id,l.recordId)}),(0,h.jsx)(`p`,{children:m?`${p} · video clip, played muted`:p})]})}var u7=e=>t=>t.destination.kind===`image`&&t.destination.imageKey===e;function fKe(e,t){let{content:n}=e,r=n.imageDefinitions[t],i=n.imageOrder.indexOf(t),a=n.imageOrder.filter(e=>e!==t);return{next:{...e,config:a.length===0?{...e.config,sources:{...e.config.sources,images:`off`,video:`off`}}:e.config,content:{...n,imageOrder:a,imageDefinitions:Object.fromEntries(Object.entries(n.imageDefinitions).filter(([e])=>e!==t))},regenerate:(e.regenerate??[]).filter(e=>e!==`image:${t}`),uploads:(e.uploads??[]).filter(e=>!u7(t)(e))},removed:r===void 0||i===-1?void 0:{key:t,index:i,definition:r,uploads:(e.uploads??[]).filter(u7(t)),regenerate:e.regenerate?.includes(`image:${t}`)===!0,sources:e.config.sources}}}function pKe(e,t){if(e.content.imageOrder.includes(t.key))return;let n=[...e.content.imageOrder];return n.splice(Math.min(t.index,n.length),0,t.key),{...e,config:{...e.config,sources:n.length===1?t.sources:e.config.sources},content:{...e.content,imageOrder:n,imageDefinitions:{...e.content.imageDefinitions,[t.key]:t.definition}},uploads:[...e.uploads??[],...t.uploads],regenerate:t.regenerate?[...new Set([...e.regenerate??[],`image:${t.key}`])]:e.regenerate}}function mKe({imageKey:e,children:t}){let n=(0,m.useRef)(null);return t8(`image:${e}`,n),(0,h.jsx)(`fieldset`,{ref:n,tabIndex:-1,className:`space-y-2 rounded-control border border-line-strong p-3`,children:t})}function d7(e,t,n){let r=t+n,i=e[t],a=e[r];if(i===void 0||a===void 0)return e;let o=[...e];return o[t]=a,o[r]=i,o}function hKe({edit:e,onChange:t,onPending:n,view:r,getEdit:i}){let a=(0,m.useId)(),[o,s]=(0,m.useState)({}),[c,l]=(0,m.useState)(),{content:u}=e,d=Rve(e.config),f=(0,m.useRef)(e);f.current=e;function p(e){let n=e.content.imageOrder.flatMap(t=>{let n=e.content.imageDefinitions[t];return n===void 0?[]:[n]}),r=e.content.imageOrder.length===0||e.config.sources.images===`off`?`off`:n.some(e=>e.source===`generate`)?`generate`:`provide`,i={...e,config:{...e.config,sources:{...e.config.sources,images:r,...r===`off`?{video:`off`}:{}}}};f.current=i,t(i)}function g(e,t){let n=i?.()??f.current,r=n.content.imageDefinitions[e];if(r===void 0)return;let a=r.templateKey??`image:${e}`;s(t=>({...t,[e]:(t[e]??0)+1})),p(z8({...n,...n.uploads===void 0?{}:{uploads:n.uploads.filter(t=>t.destination.kind!==`image`||t.destination.imageKey!==e)},content:{...n.content,imageDefinitions:{...n.content.imageDefinitions,[e]:{...r,templateKey:a}}}},a,t))}function _(e){let t=i?.()??f.current,n=t.content,r=crypto.randomUUID();p({...t,config:{...t.config,sources:{...t.config.sources,images:t.config.sources.images===`off`?`provide`:t.config.sources.images}},content:{...n,imageOrder:[...n.imageOrder,r],imageDefinitions:{...n.imageDefinitions,[r]:{source:`provide`,assetId:null,prompt:null}}},uploads:[...t.uploads??[],{stagedFileId:e.id,destination:{kind:`image`,imageKey:r}}]})}function v(){let e=c;l(void 0);let t=e===void 0?void 0:pKe(i?.()??f.current,e);t!==void 0&&p(t)}let y=c===void 0?null:(0,h.jsxs)(`p`,{role:`status`,className:`flex flex-wrap items-center gap-2 text-small text-ink-2`,children:[`Image `,c.index+1,` is deleted from this draft; it goes when you save.`,(0,h.jsx)(K,{type:`button`,variant:`quiet`,size:`small`,onClick:v,children:`Undo`})]});return(0,h.jsxs)(`section`,{"aria-label":`Edit images`,className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`h3`,{children:`Images`}),(0,h.jsx)(KT,{children:`Change an image's prompt, replace it with your own picture or clip, move it, delete it, or mark it to be made again. Nothing is made until you save and choose what to make again.`})]}),u.imageOrder.map((t,s)=>{let d=u.imageDefinitions[t];return d===void 0?(0,h.jsxs)(`p`,{role:`alert`,children:[`Image definition missing: `,t]},t):(0,h.jsxs)(m.Fragment,{children:[c?.index===s?y:null,(0,h.jsxs)(mKe,{imageKey:t,children:[(0,h.jsxs)(`legend`,{children:[`Image `,s+1]}),(0,h.jsx)(dKe,{edit:e,view:r,imageKey:t,index:s}),d.source===`generate`?(0,h.jsxs)(`div`,{...GT,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:`${a}-${t}-prompt`,children:[`Prompt for image `,s+1]}),(0,h.jsx)(WT,{id:`project.images.prompt`,label:`prompt for image ${String(s+1)}`})]}),(0,h.jsx)(XT,{id:`${a}-${t}-prompt`,value:d.templateKey===void 0||d.templateKey===null?d.prompt??``:u.promptTemplates[d.templateKey]??d.prompt??``,onChange:e=>g(t,e.target.value)})]}):null,d.source===`generate`&&d.templateKey==null?(0,h.jsxs)(K,{type:`button`,onClick:()=>g(t,d.prompt??``),children:[`Use saved wording as template for image `,s+1]}):null,(0,h.jsx)(n8,{label:`Replace image ${s+1}`,kind:`images`,onPending:e=>n(`image:${t}`,e),onReady:e=>{let n=i?.()??f.current,r=n.content,a=r.imageDefinitions[t];a!==void 0&&r.imageOrder.includes(t)&&p({...n,regenerate:(n.regenerate??[]).filter(e=>e!==`image:${t}`),uploads:[...(n.uploads??[]).filter(e=>e.destination.kind!==`image`||e.destination.imageKey!==t),{stagedFileId:e.id,destination:{kind:`image`,imageKey:t}}],content:{...r,imageDefinitions:{...r.imageDefinitions,[t]:{...a,source:`provide`,prompt:null,templateKey:null}}}})}},`${t}:${o[t]??0}:${e.config.sources.images===`off`}`),(0,h.jsxs)(K,{type:`button`,disabled:s===0,onClick:()=>p({...e,content:{...u,imageOrder:d7(u.imageOrder,s,-1)}}),children:[`Move image `,s+1,` earlier`]}),(0,h.jsxs)(K,{type:`button`,disabled:s===u.imageOrder.length-1,onClick:()=>p({...e,content:{...u,imageOrder:d7(u.imageOrder,s,1)}}),children:[`Move image `,s+1,` later`]}),(0,h.jsxs)(K,{type:`button`,onClick:()=>{let{next:n,removed:r}=fKe(e,t);l(r),p(n)},children:[`Delete image `,s+1,u.imageOrder.length===1?` and turn Images and Video Off`:``]}),d.source===`generate`?(0,h.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.regenerate?.includes(`image:${t}`)===!0?(0,h.jsxs)(K,{type:`button`,onClick:()=>p({...e,regenerate:(e.regenerate??[]).filter(e=>e!==`image:${t}`)}),children:[`Keep image `,s+1]}):(0,h.jsxs)(K,{type:`button`,onClick:()=>p({...e,regenerate:[...new Set([...e.regenerate??[],`image:${t}`])]}),children:[`Make image `,s+1,` again · 1 image call`]})}):null]})]},t)}),c!==void 0&&c.index>=u.imageOrder.length?y:null,(0,h.jsx)(K,{type:`button`,disabled:u.imageOrder.length>=d,onClick:()=>{if(u.imageOrder.length>=d)return;let t=crypto.randomUUID();p({...e,config:{...e.config,sources:{...e.config.sources,images:`generate`}},content:{...u,imageOrder:[...u.imageOrder,t],promptTemplates:{...u.promptTemplates,[`image:${t}`]:``},imageDefinitions:{...u.imageDefinitions,[t]:{source:`generate`,assetId:null,prompt:``,templateKey:`image:${t}`}}}})},children:`Add generated image`}),u.imageOrder.length>=d?(0,h.jsxs)(`p`,{children:[`At most `,d,` images can be included.`]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n8,{label:`Add provided image`,kind:`images`,onPending:e=>n(`image:new`,e),onReady:_},`new-image:${e.config.sources.images===`off`}`),(0,h.jsx)(n8,{label:`Add a video clip`,kind:`images`,accept:`video/mp4,video/quicktime,video/webm,video/x-matroska,.mp4,.mov,.m4v,.webm,.mkv`,onPending:e=>n(`clip:new`,e),onReady:_},`new-clip:${e.config.sources.images===`off`}`)]})]})}function gKe(e){let{config:t,fingerprints:n}=e.revision;if(t.sources.audio===`off`)return;let r=t.sources.audio===`provide`?[{key:`audio:provided`,role:`audio_body`}]:[...t.intro===void 0?[]:[{key:`audio:intro`,role:`audio_intro`}],{key:`audio:body:concat`,role:`audio_body`},...t.outro===void 0?[]:[{key:`audio:outro`,role:`audio_outro`}]],i=e.outputs.filter(e=>e.selected&&e.state===`ready`&&e.available&&e.fingerprint===n[e.workKey]),a=r.map(({key:e,role:t})=>i.find(n=>n.workKey===e&&n.output.role===t));if(a.some(e=>e===void 0))return;let o=a.map(e=>e?.output.durationMs);if(o.every(f7))return o.reduce((e,t)=>e+t,0)/1e3+Math.max(0,r.length-1)*t.silenceGapSeconds+2*t.edgeSilenceSeconds;let s=i.find(e=>(e.output.role===`audio_export`||e.output.role===`video`)&&f7(e.output.durationMs))?.output.durationMs;return f7(s)?s/1e3:void 0}function f7(e){return e!=null&&Number.isFinite(e)&&e>0}function _Ke({edit:e,prompts:t,problem:n,onChange:r,onPending:i,getEdit:a}){let{config:o}=e;if(o.sources.images!==`generate`)return null;let s=o.reference,c=s===void 0?h4:{source:s.source,prompt:s.prompt??``,thumbnail:s.thumbnail!==!1},l=e=>({...e,uploads:(e.uploads??[]).filter(e=>e.destination.kind!==`provided`||e.destination.stage!==`reference`)});return(0,h.jsx)(`section`,{"aria-label":`Establishing image`,className:`space-y-3`,children:(0,h.jsx)(g4,{value:c,prompts:t,problem:n,onChange:n=>{let{reference:i,...a}=o;if(n.source===`off`){r(l({...e,config:a}));return}let s={source:n.source,...n.source===`prompt`?{prompt:n.prompt}:{},...n.thumbnail?{}:{thumbnail:!1}},u=n.source===`prompt`&&n.prompt!==c.prompt?t.find(e=>e.kind===`image`&&e.name===n.prompt):void 0,d={...e,config:{...a,reference:s}},f=u===void 0?d:z8(d,`referencePrompt`,u.body);r(n.source===`provide`?f:l(f))},upload:(0,h.jsx)(n8,{label:e.content.provided.reference===void 0?`Upload the establishing image`:`Replace the establishing image`,kind:`images`,accept:`image/png,image/jpeg`,onPending:i,onReady:t=>{let n=l(a?.()??e);n.config.reference?.source===`provide`&&r({...n,uploads:[...n.uploads??[],{stagedFileId:t.id,destination:{kind:`provided`,stage:`reference`}}]})}})})})}var vKe=H({words:V(H({text:z().trim().min(1),start:B().finite().nonnegative(),end:B().finite().positive(),confidence:B().optional(),speaker:z().min(1).optional()})).min(1)});function p7(e){let{config:t,content:n}=e;return JSON.stringify({source:t.sources.audio,audio:n.provided.audio,uploads:e.uploads?.filter(e=>e.destination.kind===`narration`||e.destination.kind===`provided`&&e.destination.stage===`audio`)??[],edge:t.edgeSilenceSeconds,...t.sources.audio===`generate`?{choice:t.audio,chunking:t.chunking,article:n.articleMarkdown??t.provided.article,articleSource:t.sources.article,renderedArticle:t.rendered.article,intro:t.intro,outro:t.outro,renderedIntro:t.rendered.intro,renderedOutro:t.rendered.outro,gap:t.silenceGapSeconds,overrides:n.narrationOverrides,regenerate:e.regenerate?.filter(e=>/^(audio:|article:|entry:)/.test(e))??[]}:{}})}function yKe({view:e,edit:t,fields:n,onChange:r,onPending:i,section:a}){let{api:o}=q(),s=I(eD(o)).data?.prompts??[],c=p7(t),l=t.config.sources.audio!==`off`&&c===p7({config:e.revision.config,content:e.revision.content}),u=e.revision.fingerprints[`subtitles:timing`],d=l?gKe(e):void 0,f=d!==void 0&&u!==void 0&&u!==``,p=(0,m.useRef)({edit:t,onChange:r,revisionId:e.revision.id,identity:c});p.current={edit:t,onChange:r,revisionId:e.revision.id,identity:c};let g=(0,m.useRef)(i);g.current=i;let[_,v]=(0,m.useState)(new Set),[y,b]=(0,m.useState)(),[x,S]=(0,m.useState)(),C=I8(e),w=(0,m.useRef)(void 0),T=(0,m.useRef)(!0),E=(0,m.useCallback)((e,t)=>{T.current&&v(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,m.useEffect)(()=>{g.current(_.size>0)},[_]),(0,m.useEffect)(()=>(T.current=!0,()=>{T.current=!1,w.current?.abort(),g.current(!1)}),[]),(0,m.useEffect)(()=>{let t=e.revision.id;return()=>{(p.current.revisionId!==t||p.current.identity!==c)&&w.current?.abort()}},[e.revision.id,c]);function D(e){let t=p.current.onChange;p.current={...p.current,edit:e,identity:p7(e)},t(e)}async function O(){if(w.current!==void 0)return;let t=new AbortController;w.current=t;let n=p.current;E(`captions:load`,!0),b(void 0);try{let r=e.outputs.find(e=>e.selected&&e.state===`ready`&&e.output.role===`subtitle_words`&&e.available);if(!f||d===void 0||u===void 0||r===void 0)throw Error(`Captions can't be edited until the current narration has finished and its caption timing is ready.`);let i=await o.fetch(AJ(o,e.revision.projectId,e.revision.id,r.recordId),{signal:t.signal});if(!i.ok)throw Error(`The caption timing file couldn't be read. Reload the page and try again; if it still fails, make the video again from the Video section, which times the captions again.`);let a=vKe.parse(await i.json()),s=0;for(let e of a.words){if(e.start<s||e.end<=e.start||e.end>d)throw Error(`The saved caption timing doesn't match the current narration. Make the video again from the Video section, which times the captions again.`);s=e.end}let c=D6(a.words).map(e=>({...e,id:crypto.randomUUID()})),l=p.current;if(!T.current||t.signal.aborted||l.revisionId!==n.revisionId||l.identity!==n.identity||l.edit.content.subtitleCues!==n.edit.content.subtitleCues)return;D({...l.edit,content:{...l.edit.content,subtitleCues:{audioFingerprint:u,cues:c}}})}catch(e){T.current&&!t.signal.aborted&&b(e instanceof Error?e.message:String(e))}finally{w.current===t&&(w.current=void 0),E(`captions:load`,!1)}}let k=t.content.subtitleCues,A=e=>a===void 0||a===e,j=e=>t.config.sources[e]===`provide`?(0,h.jsx)(n8,{label:e===`audio`?`Replace provided narration`:`Replace provided thumbnail`,kind:e,onPending:t=>E(`provided:${e}`,t),onReady:t=>{let n=p.current;if(n.edit.config.sources[e]===`provide`){if(e===`thumbnail`){let e=u8(t.bytes);if(S(e),e!==void 0)return}D({...n.edit,uploads:[...(n.edit.uploads??[]).filter(t=>t.destination.kind!==`provided`||t.destination.stage!==e),{stagedFileId:t.id,destination:{kind:`provided`,stage:e}}]})}}}):null;return(0,h.jsxs)(`div`,{className:`space-y-5`,children:[C.element,(0,h.jsxs)(`section`,{"aria-label":`Image list`,hidden:!A(`images`),className:`space-y-6`,children:[(0,h.jsx)(nKe,{edit:t,saved:e.revision.config.imagePrompts,prompts:s,problem:e=>n.find(t=>t.field===e||t.field===`config.${e}`)?.message,onChange:D}),(0,h.jsx)(cKe,{edit:t,problem:e=>n.find(t=>t.field===e||t.field===`config.${e}`)?.message,onChange:D}),(0,h.jsx)(uKe,{edit:t,onChange:D}),(0,h.jsx)(_Ke,{edit:t,prompts:s,problem:e=>n.find(t=>t.field===e||t.field===`content.${e}`)?.message,getEdit:()=>p.current.edit,onChange:D,onPending:e=>E(`provided:reference`,e)}),(0,h.jsx)(hKe,{getEdit:()=>p.current.edit,view:e,edit:t,onChange:D,onPending:E})]}),(0,h.jsxs)(`section`,{"aria-label":`Narration text`,hidden:!A(`narration`),className:`space-y-5`,children:[j(`audio`),t.config.sources.audio===`generate`?(0,h.jsx)(hHe,{getEdit:()=>p.current.edit,view:e,edit:t,onChange:D,onPending:E}):null]}),(0,h.jsxs)(`section`,{"aria-label":`Thumbnail files`,hidden:!A(`outputs`),className:`space-y-5`,children:[t.config.sources.thumbnail===`from_prompt`||t.config.sources.thumbnail===`prompt_by_llm`?(0,h.jsx)(k4,{value:t.config.thumbnailCount===3?3:1,onPick:e=>{let{thumbnailCount:t,...n}=p.current.edit.config;D({...p.current.edit,config:e===3?{...n,thumbnailCount:3}:n})}}):null,(0,h.jsx)(IHe,{edit:t,getEdit:()=>p.current.edit,onChange:D,onPending:E}),j(`thumbnail`),x===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-danger`,children:x})]}),y===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-danger`,children:y}),(0,h.jsxs)(`section`,{"aria-label":`Caption text`,hidden:!A(`captions`),className:`space-y-5`,children:[f?null:(0,h.jsx)(`p`,{children:`Captions can be edited once the current narration has finished and its caption timing is ready.`}),k===void 0?(0,h.jsx)(K,{type:`button`,disabled:!f||_.has(`captions:load`),onClick:()=>void O(),children:`Edit existing caption cues`}):(0,h.jsxs)(h.Fragment,{children:[k.audioFingerprint===u?null:(0,h.jsx)(`p`,{children:`These caption edits belong to an earlier narration. Review their text and timing against the current narration, then apply your corrections and save the project.`}),f&&d!==void 0?(0,h.jsx)(QGe,{audition:C,cues:k.cues,duration:d,onPending:e=>E(`captions:dirty`,e),onChange:e=>{let t=p.current,n=t.edit.content.subtitleCues;n!==void 0&&D({...t.edit,content:{...t.edit.content,subtitleCues:{...n,cues:e}}})}},`${e.revision.id}:${u}`):null,(0,h.jsx)(K,{type:`button`,onClick:()=>D({...t,content:{...t.content,subtitleCues:void 0}}),children:`Discard caption edits`})]})]})]})}function bKe({edit:e,error:t,onChange:n}){return(0,h.jsx)(`div`,{className:`mb-5`,children:(0,h.jsx)(D$,{value:e.config.language,error:t,onChange:t=>{let{language:r,...i}=e.config;n({...e,config:t===void 0||t===`en`?i:{...i,language:t}})}})})}var m7=5e5;function xKe({value:e,error:t,help:n,onChange:r}){let i=e.length-m7;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(J,{label:`Article text`,tip:`project.edit.article-text`,error:t??(i>0?`The article is ${aE.format(i)} characters over the ${aE.format(5e5)} limit. Shorten it, then press Save changes; nothing was cut.`:void 0),help:n,children:(0,h.jsx)(XT,{rows:12,value:e,onChange:e=>r(e.target.value)})}),(0,h.jsx)(`p`,{className:`m-0 text-small tabular-nums ${i>0?`text-danger`:`text-ink-2`}`,children:`${aE.format(e.length)} of ${aE.format(m7)} characters`})]})}function SKe({edit:e,saved:t,problem:n,onChange:r}){let{api:i}=q(),a=I(xD(i)),{config:o}=e,s=e=>e!==void 0&&(a.data?.some(t=>t.id===e)??!0)?e:mD,c=s(o.channelId),l=a.data?.find(e=>e.id===c),u=o.useBrandKit!==!1,d=c!==s(t.channelId),f=u!==(t.useBrandKit!==!1);return(0,h.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,h.jsx)(J,{label:`Channel`,error:n(`channelId`),help:(0,h.jsxs)(h.Fragment,{children:[`Its cast goes with the images.`,` `,l===void 0?null:(0,h.jsxs)(pa,{to:`/channels/$channelId`,params:{channelId:l.id},className:`underline`,children:[`Edit `,l.name]})]}),children:(0,h.jsxs)(ZT,{value:c,onChange:t=>r({...e,config:{...o,channelId:t.target.value}}),children:[a.data===void 0?(0,h.jsx)(`option`,{value:c,children:`Loading channels…`}):null,(a.data??[]).map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,e.cast>0?` · ${String(e.cast)} in the cast`:``]},e.id))]})}),(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-end gap-1`,children:[(0,h.jsx)(dD,{checked:u,label:`Use the channel's brand kit`,help:`Fills the caption font, intro, outro, PDF look and ambient sound you leave at their default.`,onChange:t=>{let{useBrandKit:n,...i}=o;r({...e,config:t?i:{...i,useBrandKit:!1}})}}),u?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Its cast is still used.`})]}),a.error===null?null:(0,h.jsxs)(`p`,{className:`m-0 text-small text-danger md:col-span-2`,children:[`The channels couldn't be loaded: `,a.error.message,`. Reload the page to pick a channel.`]}),d||f?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2 md:col-span-2`,children:[d?`Saving moves the project to this channel and takes its cast as it is now. `:``,u?`The brand kit fills the caption font and colors, title style, end screen, intro, outro and PDF look where they are at their default or were set by the old kit.`:`What the old brand kit had set is taken off.`]}):null]})}function CKe(e,t,n){let r=e.outputs.find(e=>e.selected&&e.available&&e.output.role===`reference`);if(t.config.reference!==void 0&&r!==void 0)return{image:{kind:`output`,outputId:r.output.id},drawnOn:`the establishing image`};let i=n.flatMap(e=>{let t=e.images.find(e=>e.state===`ready`&&e.sha256!==null);return t?.sha256?[{...e,images:[t.sha256]}]:[]}),a=p3([t.config.title,...Object.values(t.config.values??{})].join(` `),i)[0]??i[0],o=a?.images[0];if(a!==void 0&&o!==void 0)return{image:{kind:`picture`,sha256:o},drawnOn:`${a.name}'s picture`}}function wKe({edit:e,view:t,prompts:n,error:r,onChange:i}){let a=(0,m.useRef)(e.config.narrationPrompt);if(e.config.sources.audio!==`generate`)return null;let o=t.revision.config.narrationPrompt,s=t.revision.content.promptTemplates.narration??t.revision.config.rendered.narration,c=o&&s!==void 0&&!n.some(e=>e.kind===`narration`&&e.name===o)?[...n,{id:`saved-narration`,kind:`narration`,name:o,body:s,slots:[],updatedAt:t.revision.createdAt}]:n;return(0,h.jsx)(p4,{value:e.config.narrationPrompt??``,prompts:c,libraryLinks:!1,supported:e.config.audio?.provider===`inworld`&&e.config.audio.model===`inworld-tts-2`,error:r,onChange:t=>{let n=e.config.narrationPrompt||a.current;t===``&&(a.current=e.config.narrationPrompt);let r=c.find(e=>e.kind===`narration`&&e.name===t),o=r===void 0||t===n?e:z8(e,`narration`,r.body);i({...o,config:{...o.config,narrationPrompt:t}})}})}function TKe(e){let t=Object.values(e.content.promptTemplates).flatMap(e=>e==null?[]:[e]);return e.config.keywordFacts!==void 0||rye(t)}function EKe({projectId:e,edit:t,getEdit:n,onChange:r}){let{api:i}=q(),[a,o]=(0,m.useState)({kind:`idle`});if(!TKe(t))return null;let s=async()=>{o({kind:`busy`});try{let{keywordFacts:t}=await une(i,e),a=n();r({...a,config:{...a.config,keywordFacts:t}}),o({kind:`done`})}catch(e){o({kind:`failed`,why:e instanceof Error?e.message:String(e)})}};return(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,h.jsx)(K,{variant:`quiet`,size:`small`,disabled:a.kind===`busy`,onClick:()=>{s()},children:a.kind===`busy`?`Refreshing keyword facts…`:`Refresh keyword facts`}),(0,h.jsx)(KT,{children:`Copies the channel's name, series brief, links and cast again, free; saving then makes again only what uses a changed fact.`}),a.kind===`done`?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`Keyword facts copied again. Save to make again only the steps whose prompts use a fact that changed.`}):a.kind===`failed`?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`Couldn't refresh the keyword facts: ${a.why} Press Refresh keyword facts to try again.`}):null]})}function DKe({id:e,name:t,promptKey:n,script:r,textEntry:i,value:a,onChange:o}){let s=tye(n,{script:r===!0}),c=a.trim()!==``&&a.length<=1e5,l=!c||s===void 0?[]:jk(a,s).filter(e=>e.kind===`wrong-place`).map(e=>e.message),u=c&&i===!0&&(s===`intro`||s===`outro`)?Ik(a,s).map(e=>e.message):[],d=[...OKe(a,t,s,c),...l,...u],f=d.length===0?void 0:d.join(` `);return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[s===void 0||s===`title`?null:(0,h.jsx)(gz,{place:s,targetId:e,value:a,onChange:o}),(0,h.jsx)(J,{label:`Prompt for ${t}`,id:e,help:`This project's own copy: editing it changes this project, not your saved prompt.`,error:f,children:(0,h.jsx)(Rz,{id:e,value:a,place:s,invalid:f!==void 0,describedBy:f===void 0?void 0:`${e}-error`,onChange:o})}),c&&AKe(n,a)?(0,h.jsx)(IT,{tone:`waiting`,title:`The scene keyword has no effect here`,children:(0,h.jsx)(`p`,{className:`m-0`,children:n===`referencePrompt`?`The establishing image is drawn without a scene of its own, so any line holding {{Slopify_Scene}}, {{Slopify_Setting}} or {{Slopify_Mood}} is left out. Remove it, or keep the line for the pictures that use it.`:`A short's picture is drawn from what its clip says, so any line holding a scene keyword is left out. Remove it, or keep the line for the video's pictures.`})}):null,s===void 0?null:(0,h.jsx)(Oz,{body:a,place:s,onChange:o})]})}function OKe(e,t,n,r){if(!r||Ek(e).errors.length===0)return[];let i=new Set(jk(e,n??`article`).filter(e=>e.kind===`unknown`).map(e=>e.message));return(n===`intro`||n===`outro`?yz({category:n,mode:`text`,name:t,body:e}):vz({kind:kKe(n),name:t,body:e})).filter(e=>e.field===`body`&&!i.has(e.message)).map(e=>e.message)}function kKe(e){return e===void 0||e===`title`||e===`intro`||e===`outro`?`article`:e}function AKe(e,t){return e===`referencePrompt`?B4(t):e===`shortsImage`?Cze(t)||B4(t):!1}function jKe(e){return e===`article`?`article`:e===`narration`||e===`intro`||e===`outro`?`narration`:e===`referencePrompt`||v7(e)!==void 0?`images`:e.startsWith(`review.`)?`checks`:`outputs`}function MKe({part:e,edit:t,saved:n=t.config.imagePrompts,prompts:r,entries:i,projectId:a,onChange:o}){let s=(0,m.useId)(),c=Vx(),l=(0,m.useRef)(t);l.current=t;let u=(e,n)=>{let r=t;o(e),c(n,`info`,{label:`Undo`,run:()=>{let t=q5(e,r,l.current);o({...l.current,config:t.config,content:t.content})}})},d=[...new Set([...Object.keys(t.config.rendered),...Object.keys(t.content.promptTemplates),...t.config.sources.article===`generate`?[`article`]:[],...lj(t.config)?[`narration`]:[],...uj(t.config)&&t.config.descriptionPrompt?[`description`]:[],...fj(t.config)&&t.config.shorts?.prompt?[`shorts`]:[],...fj(t.config)&&t.config.shorts?.imagePrompt?[`shortsImage`]:[],...[`from_prompt`,`prompt_by_llm`].includes(t.config.sources.thumbnail)?[`thumbnailPrompt`]:[],...dj(t.config)&&t.config.reference?.source===`prompt`?[`referencePrompt`]:[],...t.config.intro===void 0?[]:[`intro`],...t.config.outro===void 0?[]:[`outro`]])].filter(r=>{if(e===`keywords`||jKe(r)!==e)return!1;let i=v7(r);if(i===void 0)return!0;let a=n[i]?.name;return a===void 0||t.config.imagePrompts.some(e=>e.name===a)}),f=t.config.imagePrompts.filter(e=>!n.some(t=>t.name===e.name)),p=e=>IKe(e,n),g=[...new Set([...Object.keys(t.config.values),...Object.values(t.content.promptTemplates).flatMap(e=>e===null?[]:Ek(e).names)])].filter(e=>!Dk.includes(e)),_=e=>[...Ek(t.config.title).names.includes(e)?[`Project title`]:[],...Object.entries(t.content.promptTemplates).flatMap(([t,n])=>n!==null&&Ek(n).names.includes(e)?[p(t)]:[])],v=Ek(t.config.title).names;return e===`keywords`?(0,h.jsxs)(h.Fragment,{children:[a===void 0?null:(0,h.jsx)(EKe,{projectId:a,edit:t,getEdit:()=>l.current,onChange:o}),g.length?(0,h.jsxs)(`section`,{"aria-label":`Keywords`,className:`space-y-3`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:`Keywords`}),(0,h.jsx)(zQ,{fieldPrefix:`config.values`,keywords:g.map(e=>({name:e,value:t.config.values[e]??``,feeds:_(e),topic:v.includes(e)})),onChange:(e,n)=>o(L8({...t,config:{...t.config,values:{...t.config.values,[e]:n}}}))})]}):null]}):d.length===0&&(e!==`images`||f.length===0)?null:(0,h.jsxs)(`section`,{"aria-label":`${NKe[e]} prompts`,className:`space-y-6`,children:[d.map(e=>{let a=p(e),c=t.content.promptTemplates[e]??null,l=e===`intro`||e===`outro`?i.filter(t=>t.category===e):r.filter(n=>n.kind===(e===`article`?$A(t.config)?`script`:`article`:e===`narration`?`narration`:e===`description`?`description`:e===`shorts`?`shorts`:e===`thumbnailPrompt`?`thumbnail`:`image`));return(0,h.jsxs)(`div`,{className:`min-w-0 space-y-4 border-t border-line pt-6 first:border-t-0 first:pt-0`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:a}),c===null?(0,h.jsx)(IT,{tone:`info`,title:`Original template unavailable`,actions:(0,h.jsx)(K,{"aria-label":`Use saved wording as template for ${a}`,onClick:()=>o(z8(t,e,t.config.rendered[e]??``)),children:`Use saved wording as template`}),children:`The saved prompt below stays as it is until you choose or write a template.`}):null,(0,h.jsx)(FKe,{label:a,raw:c,library:PKe(t,e,l,n),onUse:n=>u(z8(t,e,n),`${a} now uses the new wording from Prompts.`)}),(0,h.jsx)(J,{label:`Use a saved prompt for ${a}`,id:`${s}-library-${e}`,help:`Copies it into this project in place of the prompt below.`,children:(0,h.jsxs)(ZT,{value:``,onChange:n=>{let r=l.find(e=>e.id===n.target.value);if(r===void 0)return;let i=z8(t,e,r.body),o=`category`in r?{...i.config,[r.category]:{name:r.name,mode:r.mode}}:e===`article`?{...i.config,articlePrompt:r.name}:e===`narration`?{...i.config,narrationPrompt:r.name}:e===`description`?{...i.config,descriptionPrompt:r.name}:(e===`shorts`||e===`shortsImage`)&&i.config.shorts!==void 0?{...i.config,shorts:{...i.config.shorts,[e===`shorts`?`prompt`:`imagePrompt`]:r.name}}:e===`thumbnailPrompt`?{...i.config,thumbnailPrompt:r.name}:e===`referencePrompt`&&i.config.reference!==void 0?{...i.config,reference:{...i.config.reference,prompt:r.name}}:i.config;u({...i,config:o},`${a} now uses "${r.name}".`)},children:[(0,h.jsx)(`option`,{value:``,children:`Choose a saved prompt`}),l.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,h.jsx)(DKe,{id:`${s}-raw-${e}`,name:a,promptKey:e,script:$A(t.config),textEntry:(e===`intro`||e===`outro`)&&t.config.sources.audio===`generate`&&t.config[e]?.mode===`text`,value:c??``,onChange:n=>o(z8(t,e,n))}),(0,h.jsx)(SR,{summary:`As it was sent, keywords filled in`,children:(0,h.jsx)(`pre`,{className:`m-0 mt-2 whitespace-pre-wrap break-words text-small`,children:t.config.rendered[e]??``})})]},e)}),e!==`images`||f.length===0?null:(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[f.map(e=>`"${e.name}"`).join(`, `),` `,f.length===1?`uses its`:`use their`,` wording from Prompts. Save, then change it here.`]})]})}var NKe={keywords:`Keyword`,article:`Article`,narration:`Narration`,images:`Image`,outputs:`Output`,checks:`Check`};function PKe(e,t,n,r){let{config:i}=e,a=v7(t);if(t===`intro`||t===`outro`){let e=i[t]?.name;return e===void 0||e===``?void 0:n.find(t=>`category`in t&&t.name===e)}let o=t===`article`?i.articlePrompt:t===`narration`?i.narrationPrompt:t===`description`?i.descriptionPrompt:t===`shorts`?i.shorts?.prompt:t===`shortsImage`?i.shorts?.imagePrompt:t===`thumbnailPrompt`?i.thumbnailPrompt:t===`referencePrompt`?i.reference?.prompt:a===void 0?void 0:r[a]?.name;if(o!==void 0&&o!==``)return n.find(e=>!(`category`in e)&&e.name===o)}var h7=`slopify.library-kept`;function g7(e){let t=5381;for(let n=0;n<e.length;n+=1)t=(t*33^e.charCodeAt(n))>>>0;return t.toString(36)}function _7(){try{let e=window.localStorage.getItem(h7),t=e===null?[]:JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function FKe({label:e,raw:t,library:n,onUse:r}){let i=n===void 0||t===null?``:`${e}:${g7(t)}:${g7(n.body)}`,[a,o]=(0,m.useState)(()=>_7().includes(i));return n===void 0||t===null||n.body===t||a?null:(0,h.jsx)(IT,{tone:`info`,title:`"${n.name}" in Prompts has changed since this project copied it`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(K,{"aria-label":`Use the new wording for ${e}`,onClick:()=>{r(n.body)},children:`Use the new wording`}),(0,h.jsx)(K,{variant:`quiet`,"aria-label":`Keep this project's version for ${e}`,onClick:()=>{try{window.localStorage.setItem(h7,JSON.stringify([..._7().filter(e=>e!==i),i].slice(-200)))}catch{}o(!0)},children:`Keep this project's version`})]}),children:`The project uses its own copy below until you choose. Using the new wording marks what it wrote as outdated, to make again when you are ready.`})}function v7(e){let t=/^imagePrompts\.(\d+)$/.exec(e);return t?.[1]===void 0?void 0:Number(t[1])}function IKe(e,t){if(e===`article`)return`Article`;if(e===`narration`)return`Narration preparation`;if(e===`description`)return`YouTube description`;if(e===`shorts`)return`Shorts`;if(e===`shortsImage`)return`Shorts image style`;if(e===`thumbnailPrompt`)return`Thumbnail`;if(e===`referencePrompt`)return`Establishing image`;if(e===`intro`)return`Intro`;if(e===`outro`)return`Outro`;let n=v7(e);if(n!==void 0){let e=t[n]?.name;return e===void 0||e===``?`Image prompt ${String(n+1)}`:`Image prompt "${e}"`}return e.replace(/[._-]/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`)}function LKe(e,t,n){let{api:r}=q(),[i,a]=(0,m.useState)({busy:!1}),{config:o}=t,s=o.audio,c=async()=>{if(s!==void 0){a({busy:!0});try{let i=await lne(r,e),{sharedGlossary:c,...l}=o;n({...t,config:{...l,audio:{...s,shareGlossary:!0},...i.entries.length===0?{}:{sharedGlossary:i.entries}}}),a({busy:!1,projects:i.projects})}catch(e){a({busy:!1,error:e instanceof Error?e.message:String(e)})}}},l=()=>{if(s===void 0)return;let{sharedGlossary:e,...r}=o;n({...t,config:{...r,audio:{...s,shareGlossary:!1}}})},u=o.sharedGlossary?.length??0,d=s?.shareGlossary===!0?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-label text-ink-2`,children:[i.error===void 0?u===0?`No pronunciations from other projects are copied yet.`:`${String(u)} ${u===1?`term`:`terms`} copied from ${i.projects===void 0?`your other projects`:`${String(i.projects)} other ${i.projects===1?`project`:`projects`}`}.`:`Couldn't read your other projects' pronunciations: ${i.error}`,(0,h.jsx)(K,{type:`button`,variant:`quiet`,disabled:i.busy,onClick:()=>void c(),children:i.busy?`Copying…`:`Update from other projects`})]}):void 0;return{value:s?.shareGlossary===!0,onChange:e=>{e?c():l()},note:d}}function RKe(e,t){let{api:n}=q(),[r,i]=(0,m.useState)({busy:!1}),{config:a}=e,o=async()=>{i({busy:!0});try{let r=await th(n),{libraryPronunciations:o,...s}=a;t({...e,config:{...s,...r.text===``?{}:{libraryPronunciations:r.text}}}),i({busy:!1})}catch(e){i({busy:!1,error:e instanceof Error?e.message:String(e)})}},s=aM(a.libraryPronunciations??``),c={terms:s.ok?s.entries.length:0};return(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-label text-ink-2`,children:[r.error===void 0?c.terms===0?`No names are copied yet. Add some in Settings → Voices → Name pronunciations.`:`${String(c.terms)} ${c.terms===1?`name`:`names`} copied from Settings → Voices → Name pronunciations, said this way before the article's glossary.`:`Couldn't read your Name pronunciations: ${r.error} Press Copy the list again.`,(0,h.jsx)(K,{type:`button`,variant:`quiet`,disabled:r.busy,onClick:()=>void o(),children:r.busy?`Copying…`:`Copy the list again`})]})}function zKe(e,t){let{api:n}=q(),[r,i]=(0,m.useState)({busy:!1}),{config:a}=e,o=a.audio,s=async()=>{if(o!==void 0){i({busy:!0});try{let{aliases:r}=await eh(n),{narrationAliases:s,...c}=a;t({...e,config:{...c,audio:{...o,useNarrationAliases:!0},...r.length===0?{}:{narrationAliases:r}}}),i({busy:!1})}catch(e){i({busy:!1,error:e instanceof Error?e.message:String(e)})}}},c=a.narrationAliases?.length??0;return{value:o?.useNarrationAliases===!0,onChange:n=>{if(o!==void 0){if(n)s();else{let{narrationAliases:n,...r}=a;t({...e,config:{...r,audio:{...o,useNarrationAliases:!1}}})}}},note:o?.useNarrationAliases===!0?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-label text-ink-2`,children:[r.error===void 0?c===0?`No aliases are copied yet. Add some in Settings → Voices → Pronunciation.`:`${String(c)} ${c===1?`alias`:`aliases`} copied from Settings → Voices → Pronunciation.`:`Couldn't read your Pronunciation list: ${r.error} Press Copy the list again.`,(0,h.jsx)(K,{type:`button`,variant:`quiet`,disabled:r.busy,onClick:()=>void s(),children:r.busy?`Copying…`:`Copy the list again`})]}):void 0}}function BKe({part:e,projectId:t,edit:n,providers:r,voices:i,onChange:a}){let{config:o}=n,s=o.llm??{provider:``,model:``},c=o.audio??{provider:``,model:``,voice:``},l=LKe(t,n,a),u=RKe(n,a),d=zKe(n,a),{api:f}=q(),p=I(SD(f,o.channelId??`00000000-0000-4000-8000-000000000001`)),m=o.images??{provider:``,model:``},g=lj(o)||o.sources.audio===`generate`&&o.audio?.describeFigures===!0||o.sources.research===`generate`||o.sources.article===`generate`||o.sources.thumbnail===`prompt_by_llm`||QA(o)&&(o.voices?.source===`attribute`||o.voices?.source===`adapt`)||o.sources.audio===`generate`&&(o.intro?.mode===`llm`||o.outro?.mode===`llm`),_=o.sources.images===`generate`||o.sources.thumbnail===`from_prompt`||o.sources.thumbnail===`prompt_by_llm`,v=i.filter(e=>e.provider===c.provider).map(e=>({value:e.voiceId,label:e.name}));return e===`text`&&!g||e===`voice`&&o.sources.audio!==`generate`||e===`images`&&!_?null:(0,h.jsxs)(`section`,{"aria-label":e===`text`?`Written by`:e===`voice`?`Read by`:`Images by`,className:`grid min-w-0 gap-3 sm:grid-cols-2`,children:[e===`text`?(0,h.jsx)(AB,{family:`llm`,providers:r,provider:s.provider,model:s.model,serviceField:`llm.provider`,modelField:`llm.model`,serviceProblem:void 0,modelProblem:void 0,onService:e=>a({...n,config:{...o,llm:{provider:e,model:``}}}),onModel:e=>a({...n,config:{...o,llm:{...s,model:e}}}),children:(0,h.jsx)(v4,{choice:s,onChange:e=>a({...n,config:{...o,llm:e}})})}):null,e===`voice`?(0,h.jsxs)(h.Fragment,{children:[o.voices!==void 0&&o.intro===void 0&&o.outro===void 0?null:(0,h.jsxs)(AB,{family:`tts`,label:o.voices===void 0?`Read by`:`Intro and outro read by`,className:`[grid-template-columns:repeat(auto-fill,minmax(min(100%,20rem),1fr))]`,providers:r,provider:c.provider,model:c.model,serviceField:`audio.provider`,modelField:`audio.model`,serviceProblem:void 0,modelProblem:void 0,leaveOut:{label:`Set Narration to Off`,onLeave:()=>a(R8(n,`audio`,`off`))},onService:e=>a({...n,config:{...o,audio:{...c,provider:e,model:``,voice:``}}}),onModel:e=>a({...n,config:{...o,audio:{...c,model:e}}}),children:[(0,h.jsx)(qR,{label:o.voices===void 0?`Voice`:`Intro and outro voice`,value:c.voice,problem:void 0,placeholder:`Choose a saved voice`,options:c.voice!==``&&!v.some(e=>e.value===c.voice)?[{value:c.voice,label:`${c.voice} (saved voice)`},...v]:v,onPick:e=>a({...n,config:{...o,audio:{...c,voice:e}}})}),o.voices===void 0?null:(0,h.jsx)(`p`,{className:`sl-fields__wide m-0 text-small text-ink-2`,children:`This voice reads only the intro and outro. Each speaker's voice is set under Speakers.`})]}),(0,h.jsx)(t4,{value:o.chunking??{mode:`whole`},onPick:e=>a({...n,config:{...o,chunking:e}})}),(0,h.jsx)(m4,{shared:l,list:u,value:c.usePronunciationGlossary,supported:mj({sources:o.sources,audio:{...c,usePronunciationGlossary:!0}}),onChange:e=>a({...n,config:{...o,audio:{...c,usePronunciationGlossary:e}}})}),(0,h.jsx)(f4,{...d}),(0,h.jsx)(u4,{tip:`project.edit.describe-figures`,value:c.describeFigures,skipCode:c.skipCode,onChange:({describeFigures:e,skipCode:t})=>{let{describeFigures:r,skipCode:i,...s}=c;a({...n,config:{...o,audio:{...s,...e?{describeFigures:e}:{},...e&&t?{skipCode:t}:{}}}})}}),(0,h.jsxs)(`section`,{"aria-label":`Speakers`,className:`col-span-full border-t border-line pt-3`,children:[(0,h.jsx)(`h3`,{className:`mb-2 text-small font-semibold`,children:`Speakers`}),(0,h.jsx)(c4,{value:o.voices,cast:p.data?.cast??[],language:o.language,providers:r,voices:i,script:n.content.articleMarkdown??void 0,onChange:e=>{let{voices:t,...r}=o;a({...n,config:e===void 0?r:{...r,voices:e}})}})]})]}):null,e===`images`?(0,h.jsx)(AB,{family:`image`,providers:r,provider:m.provider,model:m.model,serviceField:`images.provider`,modelField:`images.model`,serviceProblem:void 0,modelProblem:void 0,leaveOut:o.sources.images===`generate`?{label:`Set Images to None`,onLeave:()=>a(R8(n,`images`,`off`))}:void 0,onService:e=>a({...n,config:{...o,images:{provider:e,model:``}}}),onModel:e=>a({...n,config:{...o,images:{...m,model:e}}}),children:(0,h.jsx)(v4,{field:`images.thinking`,label:`Effort`,tip:`play.images.effort`,choice:m,onChange:e=>a({...n,config:{...o,images:e}})})}):null]})}function VKe({edit:e,providers:t,prompts:n,problem:r,onChange:i}){let{config:a}=e,o=a.reviews===void 0?NB:gye(a.reviews),[s,c]=(0,m.useState)(o),l=a.shorts?.enabled===!0&&a.sources.audio!==`off`,u=e=>oA({sources:a.sources,shorts:l?{enabled:!0}:void 0},e),d=aA(s,u).retriesProblem;return(0,h.jsx)(PB,{value:s,providers:t,prompts:n,makes:u,problem:e=>e===`reviews.retries`&&d!==void 0?d:r(e),onChange:t=>{c(t);let{settings:r}=aA(t,u),o={...e.content.promptTemplates},s={...a.rendered};for(let e of Zk){let t=mye(e),i=r?.stages[e]?.prompt??``,c=n.find(e=>e.kind===`review`&&e.name===i);if(i===``){let{[t]:e,...n}=o,{[t]:r,...i}=s;o=n,s=i}else c!==void 0&&i!==(a.reviews?.stages[e]?.prompt??``)&&(o={...o,[t]:c.body})}let{reviews:l,...d}=a;i(L8({...e,config:{...d,rendered:s,...r===void 0?{}:{reviews:r}},content:{...e.content,promptTemplates:o}}))}})}function HKe({kind:e,edit:t,articleMarkdown:n,problem:r,onChange:i}){let{sources:a}=t.config;if(a.article===`off`&&(e===`research`||e===`audio`||e===`document`))return null;let o=JN(e,a.audio!==`off`).filter(t=>e!==`thumbnail`||t.value!==`prompt_by_llm`||a.article!==`off`).map(t=>({...t,disabled:e===`video`&&t.value===`generate`&&a.images===`off`})),s=UKe(e,a),c=r(`sources.${e}`),l=r=>{let a=R8(t,e,r);i(e===`article`&&r===`provide`&&!t.content.articleEdited?{...a,content:{...a.content,articleMarkdown:n??t.content.articleMarkdown}}:a)};return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,...s===void 0?{}:GT,children:[(0,h.jsx)(IB,{field:`sources.${e}`,label:ZD[e],className:BB,value:eO(a,e),options:o,onPick:l}),s===void 0?null:(0,h.jsx)(KT,{children:s}),c===void 0?null:(0,h.jsx)(`p`,{className:`sl-field__error m-0`,children:c})]})}function UKe(e,t){switch(e){case`research`:return t.research===`generate`?`The AI plans chapters and looks each one up on the web before it writes: a few more AI calls.`:void 0;case`video`:{let e=t.audio!==`off`,n=t.video===`generate`&&t.images!==`off`?e?`The narration over the images, put together on this computer · free.`:`A silent video, each image shown once, put together on this computer · free.`:e?`Sound only: the narration as one audio file.`:`Each finished stage downloads on its own.`;return t.images===`off`?`${n} A video needs images first.`:n}case`thumbnail`:return`The picture people see before they press play. A drawn one is one image call each.`;case`document`:return`Laid out on this computer from the article and title · free.`;default:return}}function WKe({edit:e,view:t,prompts:n,problem:r,onChange:i}){let a=t.revision.config.descriptionPrompt,o=t.revision.content.promptTemplates.description??t.revision.config.rendered.description,s=a&&o!==void 0&&!n.some(e=>e.kind===`description`&&e.name===a)?[...n,{id:`saved-description`,kind:`description`,name:a,body:o,slots:[],updatedAt:t.revision.createdAt}]:n,c=t.outputs.some(e=>e.selected&&e.workKey===y7&&e.state===`ready`),l=e.regenerate?.includes(y7)===!0;return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(b4,{enabled:e.config.youtubeDescription===!0,prompt:e.config.descriptionPrompt??``,prompts:s,narrated:e.config.sources.audio!==`off`,problem:r,onChange:({youtubeDescription:t,descriptionPrompt:n})=>{let r=s.find(e=>e.kind===`description`&&e.name===n),a=n===(e.config.descriptionPrompt??``)?e:r===void 0?GKe(e):z8(e,`description`,r.body),{descriptionPrompt:o,...c}=a.config;i({...a,config:{...c,youtubeDescription:t,...n===``?{}:{descriptionPrompt:n}}})}}),c&&e.config.youtubeDescription===!0?l?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-accent-ink`,children:[`The YouTube description will be written again after you save and make the outdated description again.`,(0,h.jsx)(K,{type:`button`,variant:`quiet`,onClick:()=>{i({...e,regenerate:(e.regenerate??[]).filter(e=>e!==y7)})},children:`Keep the current description`})]}):(0,h.jsxs)(`span`,{className:`flex flex-col items-start gap-1`,...GT,children:[(0,h.jsx)(K,{type:`button`,onClick:()=>{i({...e,regenerate:[...new Set([...e.regenerate??[],y7])]})},children:`Write the description again after review`}),(0,h.jsx)(KT,{children:`One paid writing call when you make it again; the description you have now is replaced.`})]}):null]})}var y7=`youtube:description`;function GKe(e){let{description:t,...n}=e.content.promptTemplates,{description:r,...i}=e.config.rendered;return L8({config:{...e.config,rendered:i},content:{...e.content,promptTemplates:n}})}var KKe=`\0kept:`;function b7({title:e,children:t,columns:n=!0}){return(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:e}),(0,h.jsx)(`div`,{className:G(`grid min-w-0 gap-4`,n&&`md:grid-cols-2`),children:t})]})}function qKe(e){let{view:t,edit:n,onChange:r,onPending:i,fields:a}=e,o=(0,m.useId)(),[s,c]=(0,m.useState)(e.focus?.section??e.opening??`title`),l=(0,m.useRef)(null),[u,d]=(0,m.useState)(0);(0,m.useEffect)(()=>{e.focus!==void 0&&(c(e.focus.section),e.focus.section===`title`&&d(e=>e+1))},[e.focus]),(0,m.useEffect)(()=>{u>0&&l.current?.focus()},[u]),(0,m.useEffect)(()=>{e.opening!==void 0&&c(e.opening)},[e.opening]);let{onSection:f}=e;(0,m.useEffect)(()=>{f?.(s)},[f,s]);let[p,g]=(0,m.useState)({font:!1,content:!1,music:!1});(0,m.useEffect)(()=>{i(p.font||p.content||p.music)},[i,p]);let _=(0,m.useCallback)(e=>{g(t=>t.font===e?t:{...t,font:e})},[]),v=(0,m.useCallback)(e=>{g(t=>t.content===e?t:{...t,content:e})},[]),y=(0,m.useCallback)(e=>{g(t=>t.music===e?t:{...t,music:e})},[]),{api:b}=q(),x=I(QE(b)),S=I($E(b)),C=I(eD(b)),w=I(tD(b)),{config:T}=n,E=CKe(t,n,I(SD(b,T.channelId??`00000000-0000-4000-8000-000000000001`)).data?.cast??[]),D=E?.image.kind===`output`?t.outputs.find(e=>e.selected&&e.available&&E.image.kind===`output`&&e.output.id===E.image.outputId):void 0,O=D===void 0?void 0:AJ(b,t.revision.projectId,t.revision.id,D.recordId),k=e=>a.find(t=>t.field===e||t.field===`config.${e}`||t.field===`edit.config.${e}`)?.message,A=w4({value:T.videoEdit,narrated:T.sources.audio!==`off`,imageProvider:T.images?.provider??``,problem:k,language:T.language,onChange:e=>r({...n,config:{...T,videoEdit:e}})}),j=[{id:`title`,label:Ux.topic},{id:`article`,label:Ux.article,...n.content.articleEdited?{badge:`edited`}:{}},{id:`narration`,label:Ux.narration},{id:`images`,label:Ux.images,badge:String(n.content.imageOrder.length)},{id:`video`,label:Ux.video},...T.sources.article===`off`?[]:[{id:`captions`,label:`Captions`,...n.content.subtitleCues===void 0?{}:{badge:String(n.content.subtitleCues.cues.length)}}],{id:`outputs`,label:Wx},{id:`checks`,label:Ux.checks,...T.reviews===void 0?{}:{badge:`on`}},{id:`channel`,label:Gx}],M=j.some(e=>e.id===s)?s:`title`,N=e=>G(`min-w-0 space-y-6`,M===e?void 0:`hidden`),P=e=>Number.isFinite(e)?e:``,ee=T.sources.video!==`off`,F=C.data?.prompts??[],te=w.data?.entries??[],ne=e=>(0,h.jsx)(HKe,{kind:e,edit:n,articleMarkdown:t.articleMarkdown,problem:k,onChange:r}),re=e=>(0,h.jsx)(BKe,{part:e,projectId:t.revision.projectId,edit:n,providers:x.data?.providers??[],voices:S.data?.voices??[],onChange:r}),ie=e=>(0,h.jsx)(MKe,{part:e,edit:n,projectId:t.revision.projectId,saved:t.revision.config.imagePrompts,prompts:F,entries:te,onChange:r});return(0,h.jsxs)(`div`,{className:`grid min-w-0 gap-6 md:grid-cols-[180px_minmax(0,1fr)]`,children:[(0,h.jsx)(`nav`,{"aria-label":`Edit sections`,className:`min-w-0 md:sticky md:top-4 md:self-start`,children:(0,h.jsx)(`ul`,{className:`m-0 flex list-none flex-wrap gap-1 p-0 md:flex-col md:flex-nowrap`,children:j.map(e=>(0,h.jsx)(`li`,{className:`shrink-0`,children:(0,h.jsx)(iz,{current:e.id===M,onClick:()=>c(e.id),meta:e.badge,className:`whitespace-nowrap`,children:e.label})},e.id))})}),(0,h.jsxs)(`fieldset`,{disabled:e.readOnly===!0,className:`m-0 min-w-0 space-y-6 border-0 p-0`,children:[Object.entries({providers:x.error,voices:S.error,prompts:C.error,entries:w.error}).flatMap(([e,t])=>t===null?[]:[(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:t.message},e)]),a.length===0?null:(0,h.jsx)(`ul`,{role:`alert`,className:`m-0 space-y-1 pl-5 text-small text-danger`,children:a.map(e=>(0,h.jsx)(`li`,{children:e.message},`${e.field}-${e.message}`))}),(0,h.jsxs)(`section`,{"aria-label":Ux.topic,hidden:M!==`title`,className:N(`title`),children:[(0,h.jsx)(J,{label:`Project title`,error:k(`title`),children:(0,h.jsx)(Y,{ref:l,value:T.title,maxLength:200,onChange:e=>r({...n,config:{...T,title:e.target.value}})})}),ie(`keywords`)]}),(0,h.jsxs)(`section`,{"aria-label":Ux.article,hidden:M!==`article`,className:N(`article`),children:[ne(`research`),ne(`article`),T.sources.research===`provide`?(0,h.jsx)(J,{label:`Research notes`,help:`Given to the writer with the article prompt, in place of web research.`,error:k(`provided.research`),children:(0,h.jsx)(XT,{rows:6,value:T.provided.research??``,onChange:e=>r({...n,config:{...T,provided:{...T.provided,research:e.target.value}}})})}):null,re(`text`),ie(`article`),T.sources.article===`off`?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xKe,{error:k(`content.articleMarkdown`)??k(`provided.article`),help:n.content.articleEdited?`Your edited article is kept when other settings change. Writing the article again replaces it.`:void 0,value:(n.content.articleEdited?n.content.articleMarkdown:t.articleMarkdown)??n.content.articleMarkdown??T.provided.article??``,onChange:e=>r({...n,content:{...n.content,articleMarkdown:e,articleEdited:!0}})}),T.sources.article===`generate`?(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,...GT,children:[(0,h.jsx)(K,{onClick:()=>r({...n,regenerate:[...new Set([...n.regenerate??[],`article:body`])]}),children:`Write the article again after review`}),(0,h.jsx)(KT,{children:`Paid writing calls when you make it again, with their cost shown first. It replaces your edits to the article.`})]}):null]})]}),(0,h.jsxs)(`section`,{"aria-label":Ux.narration,hidden:M!==`narration`,className:N(`narration`),children:[ne(`audio`),re(`voice`),(0,h.jsx)(wKe,{edit:n,view:t,prompts:F,error:k(`narrationPrompt`),onChange:r}),(0,h.jsx)(b7,{title:`Intro and outro`,children:[`intro`,`outro`].map(e=>(0,h.jsx)(JKe,{category:e,view:t,edit:n,entries:te,onChange:r},e))}),ie(`narration`)]}),(0,h.jsxs)(`section`,{"aria-label":Ux.images,hidden:M!==`images`,className:N(`images`),children:[ne(`images`),re(`images`),ie(`images`)]}),(0,h.jsxs)(`section`,{"aria-label":Ux.video,hidden:M!==`video`,className:N(`video`),children:[ne(`video`),(0,h.jsx)(l3,{value:T.format,onPick:e=>r({...n,config:{...T,format:e}})}),ee?(0,h.jsxs)(b7,{title:`Images and cuts`,children:[(0,h.jsx)(J,{label:`Seconds per image`,help:`How long each image stays on screen, 1 to 600 seconds.`,error:k(`imageSeconds`),children:(0,h.jsx)(Y,{type:`number`,min:1,max:600,step:1,value:P(T.imageSeconds),onChange:e=>r({...n,config:{...T,imageSeconds:Number(e.target.value)}})})}),(0,h.jsx)(J,{label:`Zoom (%)`,help:`How far each image zooms over its time on screen; 0 keeps it still.`,error:k(`zoomPercent`),children:(0,h.jsx)(Y,{type:`number`,min:0,max:50,step:.5,value:P(T.zoomPercent),onChange:e=>r({...n,config:{...T,zoomPercent:Number(e.target.value)}})})}),(0,h.jsx)(J,{label:`Motion`,help:`A mix of zooms and pans keeps a long video watchable.`,children:(0,h.jsx)(ZT,{value:T.motionStyle,onChange:e=>r({...n,config:{...T,motionStyle:e.target.value}}),children:tO.map(e=>(0,h.jsx)(`option`,{value:e,children:nj[e]},e))})}),(0,h.jsxs)(`div`,{className:`space-y-4 md:col-span-2`,children:[A.cuts,A.look,T.sources.audio===`generate`&&T.audio?.describeFigures===!0?(0,h.jsx)(d4,{tip:`project.edit.show-figures`,value:T.showFigures,onChange:e=>{let{showFigures:t,...i}=T;r({...n,config:e?{...i,showFigures:!0}:i})}}):null]})]}):null,(0,h.jsx)(SR,{summary:`Sound polish`,state:T.sources.audio===`off`?`Silence only`:`Pauses, volume and silences`,children:(0,h.jsxs)(`div`,{className:`mt-3 space-y-6`,children:[(0,h.jsxs)(`div`,{className:`grid min-w-0 gap-4 md:grid-cols-2`,children:[(0,h.jsx)(J,{label:`Silence gap (seconds)`,help:`Quiet between the intro, the narration and the outro, when either is set.`,error:k(`silenceGapSeconds`),children:(0,h.jsx)(Y,{type:`number`,min:0,max:30,step:.1,value:P(T.silenceGapSeconds),onChange:e=>r({...n,config:{...T,silenceGapSeconds:Number(e.target.value)}})})}),T.sources.audio===`off`?null:(0,h.jsx)(J,{label:`Silence at start and end (seconds)`,help:`Quiet before the narration starts and after it ends.`,error:k(`edgeSilenceSeconds`),children:(0,h.jsx)(Y,{type:`number`,min:0,max:30,step:.5,value:P(T.edgeSilenceSeconds),onChange:e=>r({...n,config:{...T,edgeSilenceSeconds:Number(e.target.value)}})})})]}),T.sources.audio===`off`?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(oKe,{edit:n,problem:k,onChange:r}),(0,h.jsx)(aKe,{edit:n,problem:k,onChange:r}),ee?(0,h.jsx)(iKe,{edit:n,problem:k,onChange:r}):null]})]})})]}),(0,h.jsxs)(`section`,{"aria-label":`Captions`,hidden:M!==`captions`,className:N(`captions`),children:[(0,h.jsx)(`div`,{"data-tour":`project-subtitles`,children:(0,h.jsx)(s3,{value:T.subtitles??fM,format:T.format,language:T.language,audioEnabled:T.sources.audio!==`off`,videoEnabled:ee,showPreview:!ee,onChange:e=>r({...n,config:{...T,subtitles:HN(e,T.sources)}}),onUploading:_,problem:k})}),M!==`captions`||!ee?null:(0,h.jsx)(O4,{drawnOn:E?.drawnOn,poster:O,settings:{format:T.format,subtitles:{mode:(T.subtitles??fM).mode,fontId:(T.subtitles??fM).fontId,fontSize:(T.subtitles??fM).fontSize,position:(T.subtitles??fM).position??`bottom`},videoEdit:T.videoEdit,image:E?.image}})]}),(0,h.jsxs)(`section`,{"aria-label":Wx,hidden:M!==`outputs`,className:N(`outputs`),children:[ne(`thumbnail`),(0,h.jsx)(WKe,{edit:n,view:t,prompts:F,problem:k,onChange:r}),T.sources.audio!==`off`||T.shorts?.enabled===!0?(0,h.jsxs)(`section`,{"aria-label":`Shorts`,className:`space-y-4`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:`Shorts`}),(0,h.jsx)(MUe,{edit:n,view:t,prompts:F,problem:k,onChange:r,onPending:y})]}):null,ne(`document`),T.sources.article===`off`||eO(T.sources,`document`)===`off`?null:(0,h.jsx)(`div`,{className:`grid min-w-0 gap-4 md:grid-cols-2`,children:(0,h.jsx)(J,{label:`PDF look`,id:`${o}-document-theme`,help:`One of the three ready looks, or one of your PDF looks.`,children:(0,h.jsx)(e4,{id:`${o}-document-theme`,disabled:!1,value:T.document,onChange:e=>{r({...n,config:{...T,document:e}})}})})}),ie(`outputs`)]}),(0,h.jsxs)(`section`,{"aria-label":Ux.checks,hidden:M!==`checks`,className:N(`checks`),children:[e.checks,(0,h.jsx)(VKe,{edit:n,providers:x.data?.providers??[],prompts:F,problem:k,onChange:r}),ie(`checks`)]}),(0,h.jsxs)(`section`,{"aria-label":Gx,hidden:M!==`channel`,className:N(`channel`),children:[(0,h.jsx)(SKe,{edit:n,saved:t.revision.config,problem:k,onChange:r}),(0,h.jsx)(bKe,{edit:n,error:k(`language`),onChange:r})]}),e.renderContent?.({view:t,edit:n,fields:a,onChange:r,onPending:v,section:M})]})]})}function JKe({category:e,view:t,edit:n,entries:r,onChange:i}){let{config:a}=n,o=a[e]?.name,s=t.revision.content.promptTemplates[e],c=r.find(t=>t.category===e&&t.name===o),l=o!==void 0&&c!==void 0&&typeof s==`string`&&t.revision.config[e]?.name===o&&s!==c.body,u=n.content.promptTemplates[e],d=`${KKe}${o??``}`,f=o===void 0?``:l&&u!==c?.body?d:o;return(0,h.jsx)(J,{label:e===`intro`?`Intro`:`Outro`,tip:e===`intro`?`play.intro`:`play.outro`,children:(0,h.jsxs)(ZT,{value:f,onChange:o=>{if(o.target.value===d&&typeof s==`string`){i(L8({...n,config:{...a,[e]:t.revision.config[e]},content:{...n.content,promptTemplates:{...n.content.promptTemplates,[e]:s}}}));return}let c=r.find(t=>t.category===e&&t.name===o.target.value),l={...a};c===void 0?delete l[e]:l[e]={name:c.name,mode:c.mode},i(L8({...n,config:l,content:c===void 0?n.content:{...n.content,promptTemplates:{...n.content.promptTemplates,[e]:c.body}}}))},children:[(0,h.jsx)(`option`,{value:``,children:`Off`}),o!==void 0&&!r.some(t=>t.category===e&&t.name===o)?(0,h.jsxs)(`option`,{value:o,children:[o,` (saved entry)`]}):null,l?(0,h.jsxs)(`option`,{value:d,children:[o,` · this project's version`]}):null,r.filter(t=>t.category===e).map(e=>(0,h.jsx)(`option`,{value:e.name,children:l&&e.name===o?`${e.name} · newer wording from Prompts`:e.name},e.id))]})})}function YKe({shown:e,tab:t,opening:n,onTab:r,controller:i,projectId:a,project:o,revisionId:s,stages:c,sample:l,onCopyId:u}){let[d,f]=(0,m.useState)(n);return(0,m.useEffect)(()=>{n!==void 0&&f(n)},[n]),(0,h.jsxs)(`section`,{hidden:!e,"aria-label":`Settings`,"data-slot":`project-settings`,className:`flex min-w-0 flex-col gap-3`,children:[(0,h.jsx)(gL,{items:[{id:`settings`,label:`Settings`,...i.unsaved?{badge:`· unsaved`}:{}},{id:`versions`,label:`Versions`}],value:t,onChange:r,label:`Settings views`,idPrefix:`project-settings`}),(0,h.jsx)(_L,{idPrefix:`project-settings`,id:`settings`,active:t===`settings`,children:(0,h.jsx)(zGe,{controller:i,projectId:a,active:e&&t===`settings`,intro:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`The settings are as last saved.`}),renderEditor:e=>(0,h.jsx)(qKe,{...e,opening:d,onSection:f,checks:(0,h.jsx)(GGe,{projectId:a,revisionId:s,paused:o.status===`paused`,stages:c}),renderContent:e=>(0,h.jsx)(yKe,{...e},e.view.revision.id)})})}),(0,h.jsxs)(_L,{idPrefix:`project-settings`,id:`versions`,active:t===`versions`,className:`flex flex-col gap-4`,children:[(0,h.jsx)(BGe,{controller:i,projectId:a,active:e&&t===`versions`}),(0,h.jsx)(ZGe,{projectId:a,title:o.title,status:o.status,sample:l}),(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-2 text-small text-ink-2`,children:[(0,h.jsxs)(`span`,{children:[`Project ID `,(0,h.jsx)(`span`,{className:`font-mono text-ink`,children:a})]}),(0,h.jsx)(K,{variant:`quiet`,size:`small`,onClick:u,children:`Copy project ID`})]})]})]})}var XKe=new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`numeric`}),x7=e=>XKe.format(new Date(e));function ZKe({projectId:e,error:t,retry:n,retrying:r}){let{api:i}=q(),a=I({queryKey:xQ,queryFn:()=>SQ(i),retry:!1}).data?.find(t=>t.kind===`project`&&t.id===e),o=(0,h.jsx)(eE,{to:`/projects`,children:`Projects`});return a===void 0?(0,h.jsxs)(`div`,{children:[(0,h.jsx)(fL,{crumb:o,title:`Project not opened`}),(0,h.jsx)(ZR,{title:`The project could not be opened`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)($T,{to:`/projects`,variant:`primary`,children:`Open Projects`}),(0,h.jsx)(K,{disabled:r,disabledReason:`Trying again…`,onClick:n,children:`Try again`})]}),children:`${t.message} If it was deleted more than 30 days ago it is gone for good; otherwise press Try again, or pick it from Projects.`})]}):(0,h.jsxs)(`div`,{children:[(0,h.jsx)(fL,{crumb:o,title:a.name}),(0,h.jsx)(ZR,{title:`This project is in Trash`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)($T,{to:`/settings`,search:{section:`trash`},variant:`primary`,children:`Open Trash`}),(0,h.jsx)($T,{to:`/projects`,variant:`secondary`,children:`Back to Projects`})]}),children:`It was deleted on ${x7(a.deletedAt)} and stays in the trash until ${x7(a.purgeAt)}. Open Trash and restore it to open it again.`})]})}async function S7(e,t){let n=[],r=[];for(let i of e)try{await t(i),n.push(i)}catch(e){r.push({project:i,reason:e instanceof Error?e.message:String(e)})}return{done:n,failed:r}}function C7(e,t){return`${String(e)} ${e===1?t[0]:t[1]}`}function QKe({noun:e,onSettled:t}){let{api:n}=q(),r=_(),i=Vx(),a=L({mutationFn:e=>S7(e.list,t=>$J(n,t.id,e.on)),onSuccess:({done:t,failed:n},r)=>{t.length>0&&i(r.on?`Marked ${C7(t.length,e)} uploaded.`:`${C7(t.length,e)} back on Ready to upload. ${t.length===1?`Any YouTube link saved for it is`:`Any YouTube links saved for them are`} forgotten.`,`success`,{label:`Undo`,run:()=>a.mutate({list:t,on:!r.on})});let o=n[0];o!==void 0&&i(`${C7(n.length,e)} ${n.length===1?`wasn't`:`weren't`} ${r.on?`marked uploaded`:`marked not uploaded`}: "${o.project.title}": ${o.reason} Press the button again.`,`error`)},onError:e=>i(`Nothing was marked: ${e.message} Press the button again.`,`error`),onSettled:async()=>{t?.(),await r.invalidateQueries({queryKey:X.projects})}});return a}function $Ke(e){return e.filter(e=>e.disposition===`generate`||e.disposition===`local`||e.disposition===`review`)}function eqe(e,t){if(e===`running`)return`It is running now. Make its outdated parts again once the run has finished.`;if(t)return`It is a sample project, which stays as it came with Slopify. Open it, press Make my own copy at the top of its page, then change the copy.`}function tqe(e,t){if($Ke(e.work).length===0)return`Nothing in it is outdated, so there is nothing to make again.`;let n=e.work.find(e=>e.disposition===`blocked`);if(n!==void 0)return`${t(n.key)} can't run: ${n.reason.trim()||`no reason was given.`} Open the project and press Choose what to make again to see what to fix.`;if(e.providedReuseRequired.length>0)return`It uses content you supplied, which you confirm on the project itself: open it and press Choose what to make again.`}function nqe(e){return{low:e.reduce((e,t)=>e+t.low,0),high:e.reduce((e,t)=>e+t.high,0),unknown:e.reduce((e,t)=>e+t.unknown,0)}}function w7(e){return e instanceof Error?e.message:String(e)}async function rqe(e,t,n,r){let i=eqe(t.status,n);if(i!==void 0)return{project:t,reason:i};try{let n=await CJ(e,t.id);if(!n.ok)return{project:t,reason:`It couldn't be checked: ${n.message}`};let i=await OJ(e,t.id,{baseRevisionId:n.value.view.revision.id,request:{kind:`allAffected`}});if(!i.ok)return{project:t,reason:`It couldn't be checked: ${i.message}`};let a=i.value.value,o=tqe(a,P5(a));return o===void 0?{project:t,preview:a,idempotencyKey:r()}:{project:t,reason:o}}catch(e){return{project:t,reason:`It couldn't be checked: ${w7(e)} Tick it and press Make outdated parts again.`}}}async function iqe(e,t,n,r=()=>crypto.randomUUID()){let i=await Promise.all(t.map(t=>rqe(e,t,n.has(t.id),r)));return{plans:i.filter(e=>`preview`in e),skipped:i.filter(e=>!(`preview`in e))}}function aqe({plans:e,skipped:t}){return e.length>0&&t.length===0&&e.every(e=>X5(e.preview))}async function oqe(e,t,n){let r=[],i=[];for(let a of t)try{let t=await kJ(e,a.project.id,{baseRevisionId:a.preview.baseRevisionId,previewId:a.preview.id,idempotencyKey:a.idempotencyKey,acknowledgeUnknownCosts:n&&a.preview.costs.unknown>0,confirmedProvidedWorkKeys:[]});t.ok?r.push(a):i.push({plan:a,reason:t.reason===`stale-preview`||t.reason===`conflict`?`It changed since this review was opened. Close the review and press Make outdated parts again.`:`${t.message}`})}catch(e){i.push({plan:a,reason:`${w7(e)} Press Try again.`})}return{started:r,failed:i}}function sqe(e){let t=P5(e),n=t=>e.work.filter(e=>e.disposition===t).map(e=>e.key),r=[...n(`generate`),...n(`review`)],i=n(`local`);return[r.length===0?void 0:`Made again: ${F5(r,t)}.`,i.length===0?void 0:`${r.length===0?`Rebuilt`:`Then rebuilt`} on this computer, free: ${F5(i,t)}.`].filter(e=>e!==void 0)}var cqe=(e,t)=>e===t?nE(e):`${nE(e)}–${nE(t)}`;function T7(e){let{low:t,high:n,unknown:r}=nqe(e),i=e.some(e=>e.rows.some(e=>e.onPlan===!0)),a=n===0?i?`$0 on your plan`:`No charge`:`About ${cqe(t,n)}`;return r===0?a:`${a}, plus ${String(r)} unknown ${r===1?`estimate`:`estimates`}`}var E7=e=>oE(e,`project`,`projects`);function lqe({chosen:e,samples:t,busy:n,onDone:r}){let{api:i}=q(),a=_(),o=Vx(),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(),[p,g]=(0,m.useState)([]),[v,y]=(0,m.useState)(new Set),[b,x]=(0,m.useState)(!1),S=e.filter(e=>e.status!==`running`&&!t.has(e.id)),C=()=>{l||(f(void 0),g([]),y(new Set),x(!1))},w=async(e,t)=>{u(!0);try{let n=await oqe(i,e,t);await Promise.all([a.invalidateQueries({queryKey:X.projects}),...n.started.map(e=>a.invalidateQueries({queryKey:X.project(e.project.id)}))]);let r=new Set([...v,...n.started.map(e=>e.project.id)]);return y(r),g(n.failed),n.started.length>0&&o(`Started making the outdated parts of ${E7(n.started.length)} again. Each project's page shows its progress.`,`success`),n}finally{u(!1)}},T=async()=>{c(!0);try{let n=await iqe(i,e,t);if(aqe(n)&&(await w(n.plans,!1)).failed.length===0){r(),C();return}f(n)}finally{c(!1)}},E=d?.plans??[],D=new Set(p.map(e=>e.plan.project.id)),O=E.filter(e=>!v.has(e.project.id)),k=O.reduce((e,t)=>e+t.preview.costs.unknown,0),A=k>0&&!b,j=p.length>0,M=E.length>0&&O.length===0;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(K,{size:`small`,disabled:n||s||S.length===0,disabledReason:e.length===0?`Nothing is selected`:n||s?`Working on it`:`Running and sample projects can't be made again from here`,onClick:()=>void T(),children:s?`Checking ${E7(e.length)}…`:`Make outdated parts again`}),(0,h.jsx)(LT,{open:d!==void 0,title:`Make outdated parts again: ${E7(E.length+(d?.skipped.length??0))}`,onClose:()=>{M&&r(),C()},footer:(0,h.jsxs)(h.Fragment,{children:[M?(0,h.jsx)(K,{variant:`primary`,onClick:()=>{r(),C()},children:`Done`}):(0,h.jsx)(K,{variant:`primary`,disabled:l||O.length===0||A,disabledReason:O.length===0?`None of the selected projects can be made again from here (reasons above)`:A?`Tick the box about unknown estimates first`:`Starting…`,onClick:()=>void w(O,b),children:l?`Starting…`:j?`Try ${E7(O.length)} again`:`Make ${E7(O.length)} again`}),M?null:(0,h.jsx)(K,{disabled:l,onClick:C,children:`Keep things as they are`})]}),children:d===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,h.jsxs)(`section`,{"aria-label":`What it costs`,className:`flex flex-col gap-1`,children:[(0,h.jsx)(`p`,{className:`m-0 font-condensed text-title-2 tabular-nums`,children:O.length===0?`Nothing to start`:T7(O.map(e=>e.preview.costs))}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`${E7(E.length)} to make again${d.skipped.length===0?``:`, ${String(d.skipped.length)} left out`}. If a step fails, that project keeps its current version.`})]}),E.length===0?null:(0,h.jsxs)(`section`,{"aria-label":`Projects to make again`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(lD,{as:`h3`,size:`small`,title:`To make again`}),(0,h.jsx)(BL,{label:`Projects to make again`,children:E.map(e=>(0,h.jsx)(uqe,{plan:e,started:v.has(e.project.id),failure:D.has(e.project.id)?p.find(t=>t.plan.project.id===e.project.id)?.reason:void 0},e.project.id))})]}),d.skipped.length===0?null:(0,h.jsxs)(`section`,{"aria-label":`Left out`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(lD,{as:`h3`,size:`small`,title:`Left out`}),(0,h.jsx)(BL,{label:`Left out`,children:d.skipped.map(e=>(0,h.jsx)(VL,{title:(0,h.jsx)(pa,{to:`/projects/$projectId`,params:{projectId:e.project.id},children:e.project.title}),meta:e.reason},e.project.id))})]}),k===0?null:(0,h.jsxs)(`div`,{className:`flex items-start gap-1 text-small`,...GT,children:[(0,h.jsxs)(`label`,{className:`flex items-start gap-2 text-small`,children:[(0,h.jsx)(`input`,{type:`checkbox`,className:`mt-1`,disabled:l,checked:b,onChange:e=>x(e.target.checked)}),(0,h.jsx)(`span`,{children:`I understand that ${String(k)} cost ${k===1?`estimate is`:`estimates are`} unknown.`})]}),(0,h.jsx)(WT,{id:`project.rebuild.unknown-costs`,className:`-my-1`})]}),p.length===0?null:(0,h.jsx)(lL,{tone:`error`,children:`${E7(p.length)} didn't start (reasons on ${p.length===1?`its row`:`their rows`}). Press Try again, or open the project.`})]})})]})}function uqe({plan:e,started:t,failure:n}){return(0,h.jsxs)(VL,{title:(0,h.jsx)(pa,{to:`/projects/$projectId`,params:{projectId:e.project.id},children:e.project.title}),meta:t?`Started`:T7([e.preview.costs]),children:[(0,h.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5 text-small text-ink-2`,children:sqe(e.preview).map(e=>(0,h.jsx)(`li`,{children:e},e))}),n===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-1 text-small text-danger`,children:`Didn't start: ${n}`})]})}var D7=e=>oE(e,`project`,`projects`);async function O7(e){await Promise.all([e.invalidateQueries({queryKey:X.projects}),e.invalidateQueries({queryKey:xQ})])}async function k7(e,t,n,r,i){try{let t=await wQ(e,r.map(e=>({kind:`project`,id:e.id})));if(t.failed.length>0){let e=t.failed[0];n(`${D7(t.failed.length)} couldn't be restored: ${e?.reason??``} Restore ${t.failed.length===1?`it`:`them`} in Settings → Trash.`,`error`,i)}else n(`Restored ${D7(t.restored.length)}.`,`success`)}catch(e){n(`The projects weren't restored: ${e instanceof Error?e.message:String(e)} Restore them in Settings → Trash.`,`error`,i)}finally{await O7(t)}}function dqe({selection:e,rows:t,scope:n}){let{api:r}=q(),i=_(),a=Vx(),o=TQ(),s=AD(),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(!1),f=t.filter(t=>e.has(t.id)),p=f.filter(e=>e.status!==`running`),g=f.filter(mV),v=f.filter(e=>e.uploadedAt!==null),y=new Set(t.filter(e=>e.sample===!0).map(e=>e.id)),b=f.some(e=>e.outdated===!0),x=(e,t,n)=>{let r=e[0];r!==void 0&&a(`${D7(e.length)} ${e.length===1?`wasn't`:`weren't`} ${t}: "${r.project.title}": ${r.reason} ${n}`,`error`)},S=L({mutationFn:e=>S7(e,e=>Mm(r,e.id)),onSuccess:({done:e,failed:t})=>{e.length>0&&a(`Moved ${D7(e.length)} to the trash.`,`success`,{label:`Undo`,run:()=>void k7(r,i,a,e,o)}),x(t,`deleted`,`Cancel a running project first, then press Delete again.`)},onSettled:async()=>{d(!1),e.clear(),await O7(i)}}),C=QKe({noun:[`project`,`projects`],onSettled:e.clear}),w=L({mutationFn:async e=>jm(r,e.list.map(e=>e.id),e.to),onSuccess:(e,t)=>{let n=s.channels.find(e=>e.id===t.to)?.name??`the channel`,r=new Map;for(let e of t.list){let n=e.channelId??s.channels[0]?.id;n!==void 0&&n!==t.to&&r.set(n,[...r.get(n)??[],e])}a(`Moved ${D7(e.moved)} to ${n}.`,`success`,r.size===0?void 0:{label:`Undo`,run:()=>{for(let[e,t]of r)w.mutate({list:t,to:e})}}),l(``)},onError:e=>{l(``),a(`The projects weren't moved: ${e.message} Pick the channel again under Move to channel.`,`error`)},onSettled:async()=>{e.clear(),await i.invalidateQueries({queryKey:X.projects})}}),T=S.isPending||C.isPending||w.isPending,E=f.length-p.length;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(uQ,{selection:e,total:t.length,noun:[`project`,`projects`],...e.count===0?{}:{className:`sticky top-0 z-10 border-b border-line bg-ground py-1`},...n===void 0?{}:{scope:n},actions:(0,h.jsxs)(h.Fragment,{children:[g.length===0?null:(0,h.jsx)(K,{size:`small`,disabled:T,disabledReason:`Working on it`,onClick:()=>C.mutate({list:g,on:!0}),children:`Mark uploaded`}),v.length===0?null:(0,h.jsx)(K,{size:`small`,variant:`quiet`,disabled:T,disabledReason:`Working on it`,onClick:()=>C.mutate({list:v,on:!1}),children:`Mark not uploaded`}),s.channels.length<2?null:(0,h.jsx)(ZT,{"aria-label":`Move the selected projects to a channel`,className:`w-[180px] max-md:w-[168px]`,value:c,disabled:T,onChange:e=>{let t=e.currentTarget.value;l(t),t!==``&&w.mutate({list:f,to:t})},options:[{value:``,label:`Move to channel…`},...s.channels.map(e=>({value:e.id,label:e.name}))]}),b?(0,h.jsx)(lqe,{chosen:f,samples:y,busy:T,onDone:e.clear}):null,p.length===0?null:(0,h.jsx)(K,{size:`small`,variant:`destructive`,disabled:T,disabledReason:`Working on it`,onClick:()=>d(!0),children:`Delete`})]})}),(0,h.jsx)(ME,{open:u,title:`Delete ${D7(p.length)}?`,consequence:`Moves ${p.length===1?`"${p[0]?.title??``}"`:`these ${String(p.length)} projects`} to the trash for 30 days. Undo brings them back, or restore them later in Settings → Trash.${E===0?``:` ${D7(E)} still running ${E===1?`stays`:`stay`}: cancel the run first.`}`,confirmLabel:`Delete ${D7(p.length)}`,cancelLabel:`Keep them`,pending:S.isPending,onConfirm:()=>S.mutate(p),onCancel:()=>d(!1)})]})}function fqe({projectId:e,openDraft:t}){return(0,h.jsx)(_qe,{projectId:e,openDraft:t},e)}var pqe=[`outputs`,`article`,`narration`,`images`,`video`,`shorts`,`youtube`,`document`,`cost`,`live`,`settings`,`history`,`checkpoints`];function A7(e){return pqe.find(t=>t===e)}var mqe={outputs:`All files`,article:`Article`,narration:`Narration`,images:`Images`,video:`Video`,shorts:`Shorts`,youtube:`YouTube`,document:`PDF`,cost:`Cost`,live:`Progress`,settings:`Settings`,history:`Versions`,checkpoints:`Pauses and checks`},hqe={settings:`settings`,checkpoints:`settings`,history:`versions`},gqe={settings:`settings`,versions:`history`};function _qe({projectId:e,openDraft:t}){let{api:n}=q(),r=Vx(),i=TQ(),a=_(),o=bqe(e,t),s=I(YE(n,e)),c=I({...XE(n,e),refetchInterval:e=>s.data?.project.status===`running`&&e.state.status===`success`&&2e4}),l=I(JE(n)).data?.projects.find(t=>t.id===e),u=AD().channels,d=T2(e),f=Ji(),p=A7(Ha({select:e=>e.search.section})),g=(0,m.useCallback)(t=>{f({to:`/projects/$projectId`,params:{projectId:e},search:{section:t},resetScroll:!1})},[f,e]),[v,y]=(0,m.useState)(!1),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(!1),O=MBe(e),[k,A]=(0,m.useState)(!1),j=(0,m.useRef)({}),M=s.data?.revisionId??null,N=FGe(e,M,{onOpenEdit:()=>g(`settings`)}),P=UCe(e),ee=(0,m.useRef)(void 0);(0,m.useEffect)(()=>{P===void 0?ee.current=void 0:s.data!==void 0&&ee.current!==P&&(ee.current=P,P===`download`&&g(uF(s.data.project.config)===`article`?`article`:`video`))},[P,s.data,g]),p2(e,M);let F=I({queryKey:IE,queryFn:()=>UE(n)}),te=WE(F.data,e),ne=I({queryKey:a2(e,M??``),queryFn:()=>s2(n,e),enabled:M!==null,retry:!1}),re=ne.data?.ok===!0?ne.data.value.checkpoints:[],ie=N.saved.data?.outputs.filter(e=>e.selected&&e.state===`outdated`).map(e=>({workKey:e.workKey,role:e.output.role}))??[],ae=s.data?.project,oe=s.data?.stages??[],se=s.data?.outputs??[],ce=se.some(e=>e.role===`video`),le=ae!==void 0&&ce&&OVe(ae.config,se),ue=XHe({project:ae??vqe,stages:oe,resumable:s.data?.resumable??!1,holding:s.data?.holding??[],sample:te,gates:re,outdated:ie,waits:c.data?.waits??[],videoReady:ce,listening:ae===void 0?void 0:JUe(ae,se),actions:d,controller:N,openSection:e=>g(e)}),de=p===`settings`||p===`checkpoints`,fe=(0,m.useRef)(!1),pe=(0,m.useRef)(!1);(0,m.useEffect)(()=>{de?N.edit===void 0?(pe.current&&(pe.current=!1,N.notice?.kind!==`discarded`&&(fe.current=!1)),fe.current||N.busy||(fe.current=!0,N.openEditor())):(fe.current=!0,pe.current=!0):fe.current=!1},[de,N]);let me=ae?.title??``,he=L({mutationFn:async t=>{if(t.link!==void 0){await Um(n,e,null,t.link);return}let r=t.mark?void 0:iY(await Hm(n,e).catch(()=>void 0));return await $J(n,e,t.mark),r},onSuccess:(e,t)=>r(t.mark?`Marked uploaded: ${me}.`:e===void 0?`${me} is back on Ready to upload.`:`${me} is back on Ready to upload, and its YouTube link is forgotten.`,`success`,{label:`Undo`,run:()=>he.mutate(t.mark?{mark:!1}:e===void 0?{mark:!0}:{mark:!0,link:e})}),onError:e=>r(`${me} wasn't changed: ${e.message} Press it again under the project's status.`,`error`),onSettled:async()=>{await Promise.all([a.invalidateQueries({queryKey:X.projects}),a.invalidateQueries({queryKey:[`project`,e,`youtube-videos`]}),a.invalidateQueries({queryKey:PJ(e)}),a.invalidateQueries({queryKey:X.studioReleases})])}}),ge=L({mutationFn:()=>Mm(n,e),onSuccess:async()=>{r(`Moved "${me}" to the trash.`,`success`,{label:`Undo`,run:()=>void(l===void 0?void 0:k7(n,a,r,[l],i))}),await a.invalidateQueries({queryKey:X.projects}),await f({to:`/projects`})},onError:e=>r(`"${me}" wasn't deleted: ${e.message} Choose Delete project again.`,`error`),onSettled:()=>D(!1)}),_e=oe.some(e=>e.state===`running`),ve=ae?.status===`running`;$x(me===``?void 0:p===void 0?me:`${me} · ${mqe[p]}`);let ye=ue.next?.action;ND({id:`project.next`,title:ye?.label??`Show the project's next action`,group:`This project`,context:me,keywords:[`next`,`continue`,`resume`,`approve`,`retry`],shortcut:rN.nextAction,run:()=>{ye===void 0?r(`This project has no next action right now: nothing waits on you.`,`info`):ye.intent.kind===`soften`?r(`Soften and retry asks first: press it at the top of the project.`):ue.run(ye.intent)}}),KM(HM.showImages(e),()=>{let e=s.data?.stages.find(e=>e.kind===`images`);e===void 0||e.state===`skipped`?r(`${me} makes no slideshow images, so there is no image to make again. To add them, open Edit settings in this project and choose how its images are made.`,`error`):g(`images`)},s.data!==void 0),ND({id:`project.pause`,title:ae?.status===`paused`?`Continue the run`:`Pause the run`,group:`This project`,context:me,keywords:[`pause`,`resume`,`continue`,`stop`],run:()=>d.run({kind:ae?.status===`paused`?`resume`:`pause`})}),ND({id:`project.prepare-upload`,title:`Copy for YouTube Studio`,group:`This project`,context:me,keywords:[`youtube`,`studio`,`upload`,`publish`,`prepare`],run:()=>{le?y(!0):r(`Copy for YouTube Studio opens once the video has been made.`,`info`)}}),ND({id:`project.settings`,title:`Edit settings`,group:`This project`,context:me,keywords:[`edit`,`settings`,`prompts`,`providers`,`channel`],run:()=>g(`settings`)}),ND({id:`project.rebuild-review`,title:`Choose what to make again`,group:`This project`,context:me,keywords:[`rebuild`,`review`,`remake`,`again`,`outdated`,`affected`],run:()=>N.review({kind:`allAffected`})}),ND({id:`project.template`,title:`Save as template`,group:`This project`,context:me,keywords:[`template`,`reuse`],run:()=>x(!0)}),ND({id:`project.cancel`,title:`Cancel the run`,group:`This project`,context:me,keywords:[`cancel`,`stop`],run:()=>A(!0)}),ND({id:`project.copy-id`,title:`Copy project ID`,group:`This project`,context:me,keywords:[`id`,`bug`,`script`,`api`],run:()=>M7(e,r)});let be=SOe(ie);if(ND({id:`project.remake-1`,title:be[0]?.label??`Make the outdated files again`,group:`This project`,context:me,keywords:[`remake`,`outdated`,`rebuild`],run:()=>{let e=be[0];e===void 0?r(`Nothing is outdated in this project.`,`info`):N.review({kind:`selected`,workKeys:e.workKeys},{autoStart:!0})}}),ND({id:`project.remake-all`,title:`Make everything outdated again`,group:`This project`,context:me,keywords:[`remake`,`outdated`,`rebuild`,`all`],run:()=>{let e=[...new Set(be.flatMap(e=>e.workKeys))];e.length===0?r(`Nothing is outdated in this project.`,`info`):N.review({kind:`selected`,workKeys:e},{autoStart:!0})}}),ND({id:`project.copy`,title:`Make my own copy`,group:`This project`,context:me,keywords:[`sample`,`copy`,`duplicate`],run:()=>te?ue.run({kind:`copy-sample`}):r(`Only the sample project is copied this way.`,`info`)}),s.error!==null&&s.data===void 0)return(0,h.jsx)(ZKe,{projectId:e,error:s.error,retry:()=>void s.refetch(),retrying:s.isFetching});if(s.data===void 0||ae===void 0)return(0,h.jsx)(yqe,{});let xe=e=>oe.find(t=>t.kind===e),Se=xe(`article`),Ce=xe(`research`),we=xe(`audio`),Te=xe(`images`),Ee=xe(`thumbnail`),De=xe(`video`),Oe=xe(`document`),ke=ae.config,Ae=e=>e!==void 0&&e.state!==`skipped`,je=De!==void 0&&(ke.shorts?.enabled===!0||se.some(e=>e.role===`short_video`||e.role===`shorts`)),Me=De!==void 0&&(ke.youtubeDescription===!0||se.some(e=>e.role===`youtube_description`)),Ne=ae.status===`running`||ae.status===`paused`||_e,Pe=e=>be.filter(t=>t.section===e).reduce((e,t)=>e+t.count,0),Fe=YWe({stages:oe,outputs:se,project:ae,resumable:s.data.resumable,holding:s.data.holding,now:Date.now(),shorts:je,youtube:Me,outdated:Pe,files:aVe({config:ke,stages:oe,outputs:se})}),Ie=[`cost`,`settings`,`checkpoints`,`history`],Le=e=>e!==void 0&&(Ie.includes(e)||Fe.some(t=>t.id===e)),Re=ue.next?.situation,ze=ue.next?.section!==void 0&&Re!==`done`&&Re!==`running`?ue.next.section:tV(lWe(oe)),Be=p!==void 0&&Le(p)?p:Le(ze)?ze:Fe[0]?.id??`outputs`,Ve=hqe[Be],He=(...e)=>M===null?ae.status===`running`||ae.status===`paused`||_e||d.pending:d.pending||e.some(e=>e?.state===`running`),Ue={project:ae,outputs:se,actions:d,next:ue,resumable:s.data.resumable},We=(e,t)=>e===void 0?null:(0,h.jsx)(QUe,{stage:e,...t===void 0||t.state===`skipped`?{}:{companion:t},project:ae,outputs:se,actions:d,busy:He(e,t)}),Ge=(...e)=>se.some(t=>e.some(e=>e!==void 0&&t.stageKind===e.kind)),Ke=(...e)=>Ge(...e)||e.some(e=>e!==void 0&&[`running`,`done`,`provided`,`failed`,`canceled`].includes(e.state)),qe=[...l!==void 0&&!te&&mV(l)&&le?[{id:`uploaded`,label:`Mark uploaded`,run:()=>he.mutate({mark:!0})}]:l?.uploadedAt!==null&&l?.uploadedAt!==void 0&&!te?[{id:`uploaded`,label:`Mark not uploaded`,run:()=>he.mutate({mark:!1})}]:[],...be.length===0||N.busy?[]:[{id:`rebuild`,label:`Choose what to make again…`,run:()=>N.review({kind:`allAffected`})}],...te||M===null?[]:[{id:`rename`,label:`Rename…`,run:()=>N.requestEdit({section:`title`,change:e=>e})},{id:`template`,label:`Save as template…`,run:()=>x(!0)}],...te||u.length<2?[]:[{id:`channel`,label:`Move to channel…`,run:()=>C(!0)}],...te?[]:[{id:`designs`,label:O===void 0||O===0?`${j3}…`:`${j3} (${String(O)})…`,run:()=>T(!0)}],ve?{id:`cancel`,label:`Cancel the run…`,run:()=>A(!0),disabledReason:d.pending?`Working on the last press`:void 0,apart:!0}:{id:`delete`,label:`Delete project…`,run:()=>D(!0),apart:!0}],Je=c8({kind:`cancel`}),Ye=d.refusal?.stage===void 0?d.refusal:void 0,Xe=Ye===void 0?d.notice===void 0?N.preview===void 0&&(N.error||N.refusal)&&Ve===void 0?(0,h.jsx)(M5,{error:N.error,refusal:N.refusal}):void 0:(0,h.jsx)(`p`,{role:`status`,className:`m-0`,children:d.notice}):(0,h.jsx)(IT,{tone:`danger`,title:Ye.message,children:(0,h.jsx)(K,{variant:`quiet`,size:`small`,className:`mt-1`,onClick:d.dismissRefusal,children:`Dismiss`})}),Ze=u.length<2||l===void 0?void 0:u.find(e=>e.id===l.channelId)?.name,Qe=o!==void 0&&pWe(ae)?o:void 0,$e=le?(0,h.jsx)(K,{variant:`secondary`,size:`small`,onClick:()=>y(!0),children:`Copy for YouTube Studio`}):null;return(0,h.jsx)(LBe,{projectId:e,revisionId:M,children:(0,h.jsx)(z6,{value:M!==null,children:(0,h.jsx)(v2,{value:e=>g(e===`edit`?`settings`:`article`),children:(0,h.jsx)(B6,{value:N.pending||N.preview!==void 0?void 0:N.requestEdit,children:(0,h.jsxs)(V6,{value:N.pending||N.preview!==void 0?void 0:N.regenerateNow,children:[(0,h.jsx)(Z8,{value:j,children:(0,h.jsxs)(`div`,{className:`sl-project`,children:[(0,h.jsxs)(`div`,{"data-tour":`project-controls`,children:[(0,h.jsx)(fWe,{project:ae,progress:mCe(oe),stages:oe,holding:s.data.holding,channel:Ze,uploadedAt:te?null:l?.uploadedAt,primary:(0,h.jsx)(QHe,{state:ue}),editing:Ve!==void 0,unsaved:N.unsaved,onEdit:()=>g(Ve===void 0?`settings`:ze),clock:(0,h.jsx)(kWe,{cost:c.data,status:ae.status,measuredAt:c.dataUpdatedAt})}),(0,h.jsx)(eUe,{state:ue,feedback:Xe})]}),(0,h.jsx)(GWe,{stages:oe}),(0,h.jsxs)(pL,{asideLabel:`Project status`,aside:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(KWe,{rows:Fe,projectId:e,selected:Be}),(0,h.jsx)(qWe,{cost:c.data,running:ve,projectId:e,breakdownShown:Be===`cost`}),Qe===void 0?null:(0,h.jsx)(tUe,{nextChapter:Qe,primary:ue.next?.action===void 0}),(0,h.jsx)(vNe,{projectId:e}),(0,h.jsx)(mWe,{actions:qe})]}),children:[(0,h.jsx)(x8,{id:`article`,title:`Article`,stages:[Se,Ce].filter(j7),active:Be===`article`,...Ue,children:Ae(Se)||Ae(Ce)?We(Se,Ce):(0,h.jsx)(S8,{stage:Se,project:ae,name:`Article`})}),(0,h.jsxs)(x8,{id:`narration`,title:`Narration`,stages:[we].filter(j7),active:Be===`narration`,...Ue,children:[(0,h.jsx)(nWe,{projectId:e}),Ke(we)?We(we):(0,h.jsx)(S8,{stage:we,project:ae,name:`Narration`})]}),(0,h.jsx)(x8,{id:`images`,title:`Images`,head:!1,stages:[Te,Ee].filter(j7),active:Be===`images`,...Ue,children:We(Te,Ee)}),(0,h.jsx)(x8,{id:`video`,title:dF(`video`,ke),stages:[De].filter(j7),active:Be===`video`,...Ue,...$e===null?{}:{extra:$e},children:We(De)}),De===void 0||!je?null:(0,h.jsx)(x8,{id:`shorts`,title:`Shorts`,stages:[],active:Be===`shorts`,...Ue,children:(0,h.jsx)(RUe,{stage:De,project:ae,outputs:se})}),De===void 0||!Me?null:(0,h.jsx)(x8,{id:`youtube`,title:`YouTube`,stages:[],active:Be===`youtube`,...Ue,...$e===null?{}:{extra:$e},children:(0,h.jsx)(sWe,{stage:De,project:ae,outputs:se})}),Oe===void 0?null:(0,h.jsx)(x8,{id:`document`,title:`PDF`,stages:[Oe],active:Be===`document`,...Ue,children:Ke(Oe)?We(Oe):(0,h.jsx)(S8,{stage:Oe,project:ae,name:`PDF`})}),(0,h.jsx)(N7,{id:`outputs`,title:`All files`,selected:Be,children:(0,h.jsx)(cGe,{projectId:e,revisionId:M,config:ke,stages:oe,outputs:se,controller:N})}),(0,h.jsx)(N7,{id:`cost`,title:`Cost`,selected:Be,children:(0,h.jsx)(DWe,{projectId:e})}),Ne?(0,h.jsx)(N7,{id:`live`,title:`Progress`,selected:Be,children:Be===`live`?(0,h.jsx)(XWe,{project:ae,revisionId:M,stages:oe,outputs:se,resumable:s.data.resumable,holding:s.data.holding,outdated:Pe}):null}):null,(0,h.jsx)(YKe,{shown:Ve!==void 0,tab:Ve??`settings`,opening:Be===`checkpoints`?`checks`:void 0,onTab:e=>g(gqe[e]),controller:N,projectId:e,project:ae,revisionId:M,stages:oe,sample:te||F.isPending,onCopyId:()=>M7(e,r)})]})]})}),(0,h.jsx)(VGe,{controller:N}),v?(0,h.jsx)(dY,{projectId:e,onClose:()=>y(!1)}):null,(0,h.jsx)(NBe,{projectId:e,open:w,onClose:()=>T(!1)}),(0,h.jsx)(iGe,{projectId:e,title:ae.title,open:S,onClose:()=>C(!1)}),(0,h.jsx)(HGe,{projectId:e,revisionId:M,title:ae.title,open:b,onClose:()=>x(!1)}),(0,h.jsx)(ME,{open:k,title:Je.title,consequence:Je.consequence,confirmLabel:Je.verb,cancelLabel:Je.dismiss,pending:d.pending,onConfirm:()=>{A(!1),d.run({kind:`cancel`})},onCancel:()=>A(!1)}),(0,h.jsx)(ME,{open:E,title:`Delete "${ae.title}"?`,consequence:`Moves the project to the trash for 30 days. Undo brings it back, or restore it later in Settings → Trash.`,confirmLabel:`Delete project`,cancelLabel:`Keep it`,pending:ge.isPending,onConfirm:()=>ge.mutate(),onCancel:()=>D(!1)})]})})})})})}var j7=e=>e!==void 0;function M7(e,t){oJ(e).then(n=>t(n?`Copied the project ID ${e}.`:`The browser blocked copying. The project ID is ${e}.`,n?`success`:`info`))}function N7({id:e,title:t,selected:n,children:r}){return(0,h.jsxs)(`section`,{hidden:n!==e,"aria-label":t,className:`flex min-w-0 flex-col gap-3`,children:[(0,h.jsx)(`h2`,{className:`sl-section-head__title m-0`,children:t}),r]})}var vqe={id:``,title:``,format:`16:9`,status:`pending`,createdAt:``,config:{sources:{}}};function yqe(){return(0,h.jsxs)(`div`,{role:`status`,"aria-label":`Loading project`,className:`sl-project`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-8 w-80 max-w-full rounded-control bg-sunken`})]}),(0,h.jsx)(pL,{aside:(0,h.jsx)(`div`,{className:`flex flex-col gap-2`,children:[`a`,`b`,`c`,`d`,`e`].map(e=>(0,h.jsx)(`span`,{className:`h-8 rounded-control bg-sunken`},e))}),children:(0,h.jsx)(`span`,{className:`h-[480px] rounded-control bg-sunken`})})]})}function bqe(e,t){let{api:n}=q(),r=(0,m.useRef)(void 0),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(void 0);if(t!==void 0)return{pending:i,error:o,run:()=>{i||(r.current??=crypto.randomUUID(),a(!0),s(void 0),oxe(n,e,r.current).then(async e=>{e.ok?await t(e.value.draft.id)?r.current=void 0:s(`The next chapter's draft was made, but Create could not open it because the draft open there is not saved yet. Open Create, let it save, then press Make the next chapter again.`):s(e.message)}).catch(e=>s(`The next chapter could not be made (${e instanceof Error?e.message:`the connection dropped`}). Press Make the next chapter again.`)).finally(()=>a(!1)))}}}function xqe(){let e=HF();return!e||e.active?null:(0,h.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-4 rounded-media border border-line bg-surface px-4 py-4`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`font-semibold`,children:`Make your first video`}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink-2`,children:`A guided tour of keys, your own prompts, keywords and Create. Each step points at the real control you will use.`})]}),(0,h.jsx)(K,{variant:`secondary`,onClick:e.start,children:`Start the tour`})]})}var P7=[`all`,`running`,`queued`,`waiting`,`ready`,`failed`];function Sqe(e){return P7.find(t=>t===e)}var F7=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`queued`,label:`Queued`},{value:`waiting`,label:`Needs you`},{value:`ready`,label:`Ready to upload`},{value:`failed`,label:`Failed`}];function I7(e,t){switch(t){case`all`:return!0;case`running`:return aF(e);case`queued`:return oF(e);case`waiting`:return lF(e);case`ready`:return mV(e);case`failed`:return cF(e)}}function Cqe(e){let t=Object.fromEntries(P7.map(e=>[e,0]));for(let n of e)for(let e of P7)I7(n,e)&&(t[e]+=1);return t}var wqe=[`newest`,`finished`,`changed`,`name`,`status`];function Tqe(e){return wqe.find(t=>t===e)}var L7=[{value:`newest`,label:`Newest first`},{value:`finished`,label:`Finished first`},{value:`changed`,label:`Recently changed`},{value:`name`,label:`Name (A–Z)`},{value:`status`,label:`Status`}],Eqe={running:1,paused:2,pending:3,failed:4,partial:5,done:6,canceled:7};function R7(e){return lF(e)?0:Eqe[e.status]}var z7=(e,t)=>t.createdAt.localeCompare(e.createdAt);function Dqe(e,t){let n={newest:z7,finished:(e,t)=>(t.finishedAt??``).localeCompare(e.finishedAt??``)||z7(e,t),changed:(e,t)=>t.updatedAt.localeCompare(e.updatedAt)||z7(e,t),name:(e,t)=>e.title.localeCompare(t.title,void 0,{sensitivity:`base`,numeric:!0})||z7(e,t),status:(e,t)=>R7(e)-R7(t)||z7(e,t)};return[...e].sort(n[t])}function Oqe(e,t){let n=e=>{let n=t.indexOf(e.id);return n===-1?t.length:n};return[...e].sort((e,t)=>n(e)-n(t))}var B7=`(max-width: 767px)`;function kqe(e){if(typeof window.matchMedia!=`function`)return()=>{};let t=window.matchMedia(B7);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function Aqe(){return typeof window.matchMedia==`function`&&window.matchMedia(B7).matches}function jqe(e,t){let n=[{channel:void 0,projects:e}];if(t.channel!==void 0||t.channels.length<2)return n;let r=t.channels.map(n=>({channel:n,projects:e.filter(e=>(e.channelId??t.channels[0]?.id)===n.id)})).filter(e=>e.projects.length>0);return r.length<2?n:r}function Mqe({initialFilter:e=`all`,filter:t,query:n,sort:r,onFilter:i,onQuery:a,onSort:o}={}){let{api:s}=q(),c=_(),l=Vx(),u=TQ(),d=AD(),f=I(JE(s)),p=DQ(),g=(0,m.useSyncExternalStore)(kqe,Aqe,()=>!1),[v,y]=(0,m.useState)(void 0),[b,x]=(0,m.useState)(e),S=t??b,C=e=>{x(e),i?.(e)},[w,T]=(0,m.useState)(n??``),E=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>clearTimeout(E.current),[]);let D=e=>{T(e),a!==void 0&&(clearTimeout(E.current),E.current=setTimeout(()=>a(e),300))},[O,k]=(0,m.useState)(`newest`),A=r??O,j=e=>{k(e),o?.(e)},[M,N]=(0,m.useState)(50),P=(0,m.useRef)(null),ee=PD(P,`projects`),F=L({mutationFn:e=>Mm(s,e.id),onSuccess:(e,t)=>l(`Moved "${t.title}" to the trash.`,`success`,{label:`Undo`,run:()=>void k7(s,c,l,[t],u)}),onSettled:async()=>{y(void 0),await Promise.all([c.invalidateQueries({queryKey:X.projects}),c.invalidateQueries({queryKey:xQ})])}}),te=L({mutationFn:e=>$J(s,e.project.id,e.uploaded),onSuccess:(e,t)=>l(t.uploaded?`Marked uploaded: ${t.project.title}.`:`${t.project.title} is back on Ready to upload, and any YouTube link saved for its video is forgotten.`,`success`,t.uploaded?{label:`Undo`,run:()=>te.mutate({...t,uploaded:!1})}:void 0),onError:(e,t)=>l(`${t.project.title} wasn't changed: ${e.message} Press the button again.`,`error`),onSettled:async()=>{await c.invalidateQueries({queryKey:X.projects})}});ND({id:`projects.show.waiting`,title:`Show projects that need you`,group:`Projects`,keywords:[`waiting`,`filter`],run:()=>C(`waiting`)}),ND({id:`projects.show.ready`,title:`Show videos ready to upload`,group:`Projects`,keywords:[`upload`,`finished`,`filter`],run:()=>C(`ready`)}),ND({id:`projects.show.failed`,title:`Show failed projects`,group:`Projects`,keywords:[`error`,`filter`],run:()=>C(`failed`)});let ne=(f.data?.projects??[]).filter(e=>d.includes(e.channelId)),re=Cqe(ne),ie=OQ(p.data?.queue).map(e=>e.projectId),ae=w.trim().toLowerCase(),oe=Dqe(ne.filter(e=>I7(e,S)&&(ae===``||e.title.toLowerCase().includes(ae))),A),se=S===`queued`?Oqe(oe,ie):oe;(0,m.useEffect)(()=>N(50),[S,ae,A]);let ce=se.slice(0,M),le=ce.map(e=>e.id).join(`
|
|
455
455
|
`),ue=sQ((0,m.useMemo)(()=>le===``?[]:le.split(`
|
|
456
456
|
`),[le]));Ige(`project`,ce.filter(e=>ue.has(e.id)).map(e=>({id:e.id,label:e.title})));let de=F7.filter(e=>e.value===`all`||e.value===S||re[e.value]>0);return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(fL,{title:`Projects`,meta:f.data===void 0?void 0:oE(ne.length,`project`,`projects`),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(P0,{kinds:[`project`]}),(0,h.jsx)(jD,{})]})}),f.data?.projects.length===0?(0,h.jsx)(xqe,{}):null,f.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-4 text-danger`,children:f.error.message}),f.data===void 0?f.error===null?(0,h.jsx)(mFe,{}):null:f.data.projects.length===0?(0,h.jsx)(ZR,{title:`No projects yet`,actions:(0,h.jsx)($T,{to:`/play`,variant:`primary`,children:`Make your first video`}),children:`Every video you make is kept here with its files.`}):ne.length===0?(0,h.jsx)(ZR,{title:`No projects in ${d.channel?.name??`this channel`} yet`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)($T,{to:`/play`,variant:`primary`,children:`Make a video`}),(0,h.jsx)(K,{onClick:()=>d.setChannelId(null),children:`Show all channels`})]}),children:`Every video made in this channel is kept here with its files.`}):(0,h.jsxs)(`section`,{"aria-label":`Project list`,className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsxs)(`div`,{className:`relative min-w-[12rem] max-w-[320px] flex-1 max-md:max-w-none`,children:[(0,h.jsx)(Nh,{"aria-hidden":`true`,strokeWidth:1.75,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-3`}),(0,h.jsx)(`input`,{type:`search`,ref:P,"aria-label":`Search projects`,"aria-keyshortcuts":KD(ee),placeholder:`Search projects`,value:w,onChange:e=>D(e.target.value),className:`sl-input pl-9`})]}),de.length<2?null:g?(0,h.jsx)(ZT,{"aria-label":`Show`,className:`w-auto min-w-0 flex-1`,value:S,onChange:e=>{let t=F7.find(t=>t.value===e.currentTarget.value);t!==void 0&&C(t.value)},options:de.map(e=>({value:e.value,label:`${e.label} (${String(re[e.value])})`}))}):(0,h.jsx)(fD,{label:`Show`,value:S,options:de.map(e=>({value:e.value,label:(0,h.jsxs)(h.Fragment,{children:[e.label,` `,(0,h.jsx)(`span`,{className:`sl-tab__count ml-0 tabular-nums`,children:String(re[e.value])})]})})),onChange:C,className:`max-w-full overflow-x-auto`}),(0,h.jsx)(ZT,{"aria-label":`Sort projects`,className:`w-auto`,value:A,onChange:e=>{let t=L7.find(t=>t.value===e.currentTarget.value);t!==void 0&&j(t.value)},options:L7})]}),ce.length===0?(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:`No project matches. Clear the search or pick All.`}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{onKeyDown:ue.onKeyDown,className:`flex flex-col gap-2`,children:[(0,h.jsx)(dqe,{selection:ue,rows:ce,...ce.length<ne.length?{scope:`Select all ${String(ce.length)} shown`}:{}}),jqe(ce,d).map(e=>(0,h.jsxs)(`section`,{"aria-label":e.channel?.name??`Projects`,className:`flex flex-col gap-2`,children:[e.channel===void 0?null:(0,h.jsx)(lD,{as:`h3`,size:`small`,title:e.channel.name,meta:oE(e.projects.length,`project`,`projects`)}),(0,h.jsx)(BL,{label:e.channel?.name??`Projects`,className:`sl-projects`,children:e.projects.map(e=>(0,h.jsx)(fFe,{project:e,...ie.includes(e.id)?{queue:{place:ie.indexOf(e.id),waiting:ie.length}}:{},check:(0,h.jsx)(lQ,{selection:ue,value:e.id,label:e.title}),onDelete:()=>y(e),onUploaded:t=>te.mutate({project:e,uploaded:t}),busy:te.isPending},e.id))})]},e.channel?.id??`all`))]}),se.length>ce.length?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(K,{size:`small`,onClick:()=>N(e=>e+50),children:`Show ${String(Math.min(50,se.length-ce.length))} more`}),(0,h.jsx)(`span`,{className:`text-small text-ink-2 tabular-nums`,children:`${String(ce.length)} of ${String(se.length)} shown`})]}):null]})]}),F.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`mt-3 text-small text-danger`,children:F.error.message}),(0,h.jsx)(ME,{open:v!==void 0,title:v===void 0?``:`Delete "${v.title}"?`,consequence:`Moves the project to the trash for 30 days. Undo brings it back, or restore it later in Settings → Trash.`,confirmLabel:`Delete project`,cancelLabel:`Keep it`,pending:F.isPending,onConfirm:()=>{v!==void 0&&F.mutate(v)},onCancel:()=>y(void 0)})]})}function Nqe({kind:e,onMakeVideo:t,makeBlocked:n}){let{api:r}=q(),i=I(eD(r)),a=B0(e),o=(0,m.useRef)(null),[s,c]=t0(`prompt`),l=V0(a.needle),u=i.data?.prompts??[],d=i.data?.prompts.filter(t=>t.kind===e),f=a.searching?l:d?.map(e=>({type:`prompt`,item:e})),p=M0({section:`prompts`,pack:e=>({prompts:e}),stem:`prompts`,noun:[`prompt`,`prompts`],listKey:X.prompts,existing:u,groupOf:e=>e.kind,nameMax:200,save:e=>Km(r,e,void 0)}),g=d!==void 0&&d.length===0&&!a.searching;return(0,h.jsxs)(I0,{shown:{kind:e},search:a,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(m0,{what:`prompts`,disabled:i.data===void 0||p.importing,exports:[{label:`Export all ${oE(u.length,`prompt`)}`,run:()=>p.exportItems(u),disabled:u.length===0}],accept:`.json,application/json`,onFile:p.importFile}),g?null:(0,h.jsx)(V7,{kind:e})]}),children:[(0,h.jsx)(R0,{title:a.searching?H0(f?.length??0,a.query):`${fO(e)} prompts`,about:a.searching?U0:g?void 0:hO(e),tools:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(W0,{search:a,input:o}),g?null:(0,h.jsx)(n0,{what:`prompts`,sort:s,onSort:c})]})}),i.error===null?null:(0,h.jsx)(Y1,{what:`prompts`,message:i.error.message,onRetry:()=>void i.refetch()}),f===void 0?i.error===null?(0,h.jsx)(J1,{label:`Prompts`}):null:g?(0,h.jsx)(ZR,{title:`No ${pO(e)} prompts yet`,actions:(0,h.jsx)(V7,{kind:e}),children:mO(e)}):f.length===0?null:(0,h.jsx)(G0,{rows:f,sort:s,noun:a.searching?[`match`,`matches`]:[`prompt`,`prompts`],searching:a.searching,onMakeVideo:t,makeBlocked:n})]})}function V7({kind:e}){return(0,h.jsx)($T,{to:`/prompts/new`,search:{kind:e},variant:`primary`,children:`New ${pO(e)} prompt`})}var Pqe=`/mcp`;function Fqe(e){return`${e.replace(/\/+$/,``)}${Pqe}`}function Iqe(e){return`claude mcp add --transport http slopify ${e}`}function Lqe(e){return`[mcp_servers.slopify]\nurl = "${e}"`}H({projectIds:V(z()).optional(),projectId:z().optional()}).loose();var H7=[`settings`,`remote-access`],U7=e=>`${e.origin}/api/settings/remote-access`;async function W7(e){return W(await e.fetch(U7(e)))}async function Rqe(e,t){return W(await e.fetch(U7(e),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}))}var zqe=[`agent-connection`],Bqe=H({lastConnectedAt:z().nullable(),recent:V(H({id:z(),title:z(),subject:z().nullable(),createdAt:z(),actor:U([`agent`,`assistant`]).default(`agent`)}))});async function Vqe(e){let t=await e.fetch(`${e.origin}/api/settings/agents`);if(!t.ok)throw ym(t,await bm(t));return Tm(Bqe,await t.json())}function Hqe(){let{api:e}=q(),t=Vx(),n=I({queryKey:zqe,queryFn:()=>Vqe(e)}),r=I({queryKey:H7,queryFn:()=>W7(e),retry:!1}),i=r.data?.available===!0&&r.data.changeable===!1,a=Fqe(i&&r.data!==void 0?r.data.local:e.origin),o=[{label:`Claude Code`,where:`Run it once in a terminal.`,text:Iqe(a)},{label:`Codex`,where:`Add it to ~/.codex/config.toml.`,text:Lqe(a)}],s=async e=>{await oJ(e.text)?t(`${e.label} setup copied. ${e.where}`,`success`):t(`The ${e.label} setup wasn't copied: this browser blocked the clipboard. Select the line and copy it yourself.`,`error`)};return(0,h.jsxs)(`div`,{className:`flex max-w-prose flex-col gap-4`,...GT,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:BT(`settings.agents`).body}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold`,children:`Address for agents (MCP)`}),(0,h.jsx)(`code`,{className:`sl-code py-2 select-all`,children:a}),i?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Agents connect on the computer Slopify runs on, never through the remote address: this is the address there.`}):null]}),o.map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold`,children:e.label}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,h.jsx)(`code`,{className:`sl-code min-w-0 flex-1 basis-[220px] py-2 whitespace-pre-wrap select-all`,children:e.text}),(0,h.jsxs)(K,{variant:`quiet`,"aria-label":`Copy the ${e.label} setup`,onClick:()=>void s(e),children:[(0,h.jsx)(_h,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),`Copy`]})]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.where})]},e.label)),(0,h.jsx)(pE,{query:n,what:`Agent activity`,loading:(0,h.jsx)(uE,{label:`Loading agent activity…`,rows:3,rowClassName:`h-5`}),children:e=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.lastConnectedAt===null?`No agent has connected yet.`:(0,h.jsxs)(h.Fragment,{children:[`Last connected`,` `,(0,h.jsx)(p0,{iso:e.lastConnectedAt,children:kg(e.lastConnectedAt)}),`.`]})}),(0,h.jsxs)(`section`,{"aria-label":`What agents did`,className:`flex flex-col gap-1`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:`What agents did`}),e.recent.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No agent has changed anything yet.`}):(0,h.jsx)(`ul`,{className:`m-0 list-none space-y-1 p-0 text-small text-ink-2`,children:e.recent.map(e=>(0,h.jsxs)(`li`,{children:[e.title,e.subject===null?``:` · ${e.subject}`,e.actor===`assistant`?` · by assistant`:``,` ·`,` `,(0,h.jsx)(p0,{iso:e.createdAt,children:kg(e.createdAt)})]},e.id))})]})]})})]})}var Uqe={template:`Template`,schedule:`Schedule`,draft:`Draft`,project:`Project`};function G7(e){let t=[e.added.length>0?`${e.added.length} new`:null,e.priced.length>0?`${e.priced.length} repriced`:null,e.retired.length>0?`${e.retired.length} retired`:null].filter(e=>e!==null);return t.length===0?`No changes`:t.join(`, `)}function Wqe(){let e=_();return async()=>{await Promise.all([e.invalidateQueries({queryKey:uN.retired}),e.invalidateQueries({queryKey:PM}),e.invalidateQueries({queryKey:BO}),e.invalidateQueries({queryKey:X.playDrafts}),e.invalidateQueries({queryKey:[`projects`]}),e.invalidateQueries({queryKey:[`project`]})])}}function Gqe(){let{api:e}=q(),t=Vx(),n=Wqe(),r=I({queryKey:uN.retired,queryFn:()=>pN(e)}),i=L({mutationFn:t=>mN(e,t),onSuccess:n}),a=L({mutationFn:()=>Lxe(e),onSuccess:async e=>{t(e.failed.length===0?`Switched ${e.switched} ${e.switched===1?`use`:`uses`}.`:`Switched ${e.switched}; ${e.failed.length} could not be switched: ${e.failed[0]?.message??``}`,e.failed.length===0?`success`:`error`),await n()}}),o=r.data??[],s=o.filter(e=>e.blocked===null&&e.replacement!==null);return r.error===null?o.length===0?null:(0,h.jsxs)(`section`,{"aria-label":`Retired models in use`,children:[(0,h.jsx)(lD,{title:`Retired models in use`,meta:`A run that reaches one of these stops. Switch picks the suggested model instead.`,children:s.length>1?(0,h.jsx)(K,{variant:`primary`,disabled:a.isPending,onClick:()=>a.mutate(),children:a.isPending?`Switching…`:`Switch all ${String(s.length)}`}):null}),i.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:i.error.message}):null,(0,h.jsx)(`ul`,{"aria-label":`Retired models in use`,className:`sl-list m-0 list-none p-0`,children:o.map(e=>(0,h.jsxs)(`li`,{className:`sl-row max-sm:grid-cols-1`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`p`,{className:`m-0`,children:[(0,h.jsx)(`span`,{className:`sl-kicker`,children:Uqe[e.kind]}),` `,(0,h.jsx)(`span`,{className:`font-semibold`,children:e.name})]}),(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[l$[e.slot],`: `,e.model,` (`,e.why===`retired`?`retired`:`no longer listed`,`)`]}),e.blocked===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-waiting`,children:e.blocked}),e.replacement===null?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[`No replacement is suggested: pick another model in its `,e.kind,`.`]}):null]}),e.replacement===null||e.blocked!==null?null:(0,h.jsx)(zx,{children:(0,h.jsx)(K,{size:`small`,disabled:i.isPending,onClick:()=>i.mutate(e),children:`Switch to ${e.replacement.name}`})})]},e.key))})]}):(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:r.error.message})}function Kqe(){let{api:e}=q(),t=_(),n=Vx(),r=I({queryKey:uN.catalogue,queryFn:()=>Pxe(e),refetchInterval:3e4}),i=async()=>{await Promise.all([t.invalidateQueries({queryKey:X.providerModels}),t.invalidateQueries({queryKey:uN.retired})])},a=L({mutationFn:()=>Fxe(e),onSuccess:async e=>{t.setQueryData(uN.catalogue,e),n(e.sync?.warning??`Model list checked: ${G7(e.sync?.changes??qqe)}.`,e.sync?.warning?`error`:`success`),await i()}}),o=L({mutationFn:()=>Ixe(e),onSuccess:async e=>{n(`The model list was replaced with the published one.`,`success`),t.setQueryData(uN.catalogue,e),await i()}}),s=r.data?.sync,c=a.error?.message??o.error?.message??r.error?.message??r.data?.warning??s?.warning??null;return ND({id:`settings.check-models`,title:`Check for new models`,group:`Settings`,context:`Models`,keywords:[`catalog`,`catalogue`,`prices`,`retired`],run:()=>{!a.isPending&&r.data?.path&&a.mutate()}}),(0,h.jsxs)(`section`,{"aria-label":`Model list`,children:[(0,h.jsx)(lD,{title:`Model list`,meta:s?.checkedAt?`New models, prices and retirements, checked once a day. Last checked ${kg(s.checkedAt)}: ${G7(s.changes).toLowerCase()}.`:`New models, prices and retirements, checked once a day.`,children:r.data?.path===void 0?null:(0,h.jsx)(K,{disabled:a.isPending,onClick:()=>a.mutate(),children:a.isPending?`Checking…`:`Check for new models`})}),s!==void 0&&s.changes.retired.length+s.changes.added.length>0?(0,h.jsxs)(`div`,{className:`mb-3 flex flex-col gap-1 text-small text-ink-2`,children:[s.changes.added.length>0?(0,h.jsxs)(`span`,{children:[`New: `,s.changes.added.map(e=>e.name).join(`, `)]}):null,s.changes.retired.length>0?(0,h.jsxs)(`span`,{children:[`Retired: `,s.changes.retired.map(e=>e.name).join(`, `)]}):null]}):null,c===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-3 text-body text-danger`,children:c}),(0,h.jsx)(SR,{summary:`Catalog file`,state:r.data?.updatedAt===void 0?void 0:`Published ${r.data.updatedAt}`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2 text-small text-ink-2`,children:[(0,h.jsx)(`p`,{className:`m-0 min-w-0 break-all font-mono`,children:r.data?.path??`Not available`}),(0,h.jsx)(`p`,{className:`m-0`,children:`The local copy of the published list the pickers and cost estimates use. Your own edits to it are kept when it is checked.`}),r.data?.path===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(K,{variant:`quiet`,disabled:o.isPending,onClick:()=>o.mutate(),children:o.isPending?`Replacing…`:`Replace with the published file`}),(0,h.jsx)(`span`,{children:`Drops your edits; the old file is kept beside it.`})]})]})})]})}var qqe={added:[],retired:[],priced:[]},Jqe={ok:`Ready`,warning:`May need fixing`,problem:`Needs fixing`,unused:`Not set up`,"no-key":`No key`},Yqe={ok:`done`,warning:`waiting`,problem:`failed`,unused:`off`,"no-key":`waiting`},Xqe={llm:`writing`,tts:`voices`,image:`images`};function K7(e,t){return e.some(e=>e.id!==t.id&&e.displayName===t.displayName)?`${t.displayName} (${Xqe[t.family]})`:t.displayName}var Zqe={ok:`text-ink-2`,warning:`text-waiting`,problem:`text-danger`,skipped:`text-ink-3`};function q7(){let{api:e}=q();return L({mutationFn:()=>fN(e)})}function Qqe(e){let{api:t}=q(),[n,r]=(0,m.useState)({byId:new Map});return{one:L({mutationFn:e=>fN(t,e),onSuccess:t=>{r(n=>{let r=new Map(n.after===e?n.byId:[]);for(let e of t.providers)r.set(e.id,e);return{after:e,byId:r}})}}),latest:t=>n.after===e?n.byId.get(t.id)??t:t}}function $qe({run:e}={}){let t=q7(),n=e??t,r=n.data,i=Qqe(r?.checkedAt),a=r?.providers.map(i.latest)??[],o=a.filter(e=>e.state!==`unused`&&e.state!==`ok`),s=a.filter(e=>e.state===`ok`),c=a.filter(e=>e.state===`unused`);return(0,h.jsxs)(`section`,{"aria-label":`Check every service`,className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-small`,children:[(0,h.jsx)(`span`,{className:`text-ink-2`,"aria-live":`polite`,children:n.isPending?`Checking every service…`:r===void 0?`Last checked: not yet.`:`Last checked at ${new Date(r.checkedAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}.`}),(0,h.jsx)(K,{size:`small`,disabled:n.isPending,onClick:()=>{n.mutate()},children:n.isPending?`Checking…`:`Check every service`}),(0,h.jsx)(`span`,{className:`text-ink-2`,children:`Asks each tool whether you are signed in and tries each saved key with a free call.`})]}),n.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:[`The check didn't finish: `,n.error.message,` Press Check every service to try again.`]}),i.one.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:`The check didn't finish: ${i.one.error.message} Press Check again on the service to try again.`}),r===void 0?null:(0,h.jsxs)(h.Fragment,{children:[o.length===0?null:(0,h.jsx)(`ul`,{"aria-label":`Check by service`,className:`sl-list m-0 list-none p-0`,children:o.map(e=>(0,h.jsxs)(`li`,{className:`sl-row grid-cols-1 gap-1 py-2`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`sl-row__title`,children:K7(a,e)}),(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(hE,{tone:Yqe[e.state],children:Jqe[e.state]}),(0,h.jsx)(K,{variant:`quiet`,size:`small`,"aria-label":`Check ${K7(a,e)} again`,disabled:i.one.isPending,onClick:()=>{i.one.mutate(e.id)},children:i.one.isPending&&i.one.variables===e.id?`Checking…`:`Check again`})]})]}),(0,h.jsx)(`ul`,{className:`m-0 list-none space-y-1 p-0`,children:e.checks.map(e=>(0,h.jsxs)(`li`,{className:G(`text-small`,Zqe[e.state]),children:[(0,h.jsxs)(`span`,{className:`font-semibold`,children:[e.label,`:`]}),` `,e.detail]},e.label))})]},e.id))}),s.length===0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Ready: ${s.map(e=>K7(a,e)).join(`, `)}.`}),c.length===0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Not set up and not used anywhere: ${c.map(e=>K7(a,e)).join(`, `)}.`})]})]})}var eJe={openrouter:`settings.provider.openrouter`,"claude-code":`settings.provider.claude-code`,codex:`settings.provider.codex`,gemini:`settings.provider.gemini`,elevenlabs:`settings.provider.elevenlabs`,"openai-tts":`settings.provider.openai-tts`,cartesia:`settings.provider.cartesia`,inworld:`settings.provider.inworld`,"system-voice":`settings.provider.system-voice`,"google-tts":`settings.provider.google-tts`,fal:`settings.provider.fal`,replicate:`settings.provider.replicate`,"openai-image":`settings.provider.openai-image`,"google-image":`settings.provider.google-image`,"codex-image":`settings.provider.codex-image`};function J7({provider:e}){return(0,h.jsx)(`p`,{className:`m-0 max-w-[var(--measure)] text-small text-ink-2`,children:BT(eJe[e.id]).body})}function Y7(e){return oN(e)?{tone:`done`,word:`Ready`}:e.installed?e.issueKind===`login`?{tone:`waiting`,word:`Signed out`}:{tone:`failed`,word:`Needs fixing`}:{tone:`off`,word:`Not found`}}function tJe({provider:e,readiness:t,kind:n}){let{api:r}=q(),i=_(),a=(0,m.useId)(),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(!1),u=e.cliPath?.configured??null,d=e.cliPath?.managedOnHost===!0,f=e.id===`claude-code`?`claude`:e.id===`codex-image`?`codex`:e.id===`gemini`?`agy`:e.id,p=e.cliPath?.command??f,g=o??u??``,v=oN(t),y=L({mutationFn:t=>wte(r,e.id,t),onMutate:()=>l(!1),onSuccess:async e=>{i.setQueryData(X.providers,t=>t?{...t,providers:t.providers.map(t=>t.id===e.id?e:t)}:void 0),s(void 0),l(!0),await i.invalidateQueries({queryKey:X.providers})}});(0,m.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),oB);return()=>clearTimeout(e)},[c]);let[b,x]=(0,m.useState)(!1),S=(0,m.useId)();return(0,h.jsxs)(`section`,{"aria-labelledby":a,"data-ready":v,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h3`,{id:a,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsxs)(`p`,{className:`sl-section-head__meta`,children:[n,` · runs on this computer with your sign-in`]})]}),(0,h.jsx)(J7,{provider:e}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 flex-wrap items-center gap-x-2`,"aria-live":`polite`,children:[(0,h.jsx)(hE,{tone:Y7(t).tone,children:Y7(t).word}),(0,h.jsx)(`span`,{className:`min-w-0 break-words text-ink-2`,children:nJe(t,u)})]}),(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`span`,{children:`Command`}),(0,h.jsx)(QT,{className:`min-w-0 truncate`,title:p,children:p})]})]}),(0,h.jsxs)(zx,{children:[d?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Slopify runs in Docker, so this tool runs on your computer with the sign-in it has there. After installing or updating it, run the Docker launcher again.`}):(0,h.jsx)(K,{"aria-expanded":b,"aria-controls":S,onClick:()=>x(e=>!e),children:b?`Close path`:`Change path`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:c?(0,h.jsx)(cB,{}):null})]}),d||!b?null:(0,h.jsx)(`form`,{id:S,onSubmit:e=>{e.preventDefault(),y.isPending||y.mutate(g)},children:(0,h.jsx)(J,{label:`Executable path`,help:(0,h.jsxs)(h.Fragment,{children:[`Leave blank to find `,(0,h.jsx)(QT,{children:f}),` on PATH. Use an absolute path without quotes or arguments.`]}),error:y.error?.message,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(Y,{autoComplete:`off`,spellCheck:!1,maxLength:4096,"aria-label":`${e.displayName} Executable path`,className:`min-w-0 flex-1 basis-[220px]`,placeholder:f,value:g,disabled:y.isPending,onChange:e=>{s(e.target.value),l(!1),y.reset()}}),(0,h.jsx)(K,{type:`submit`,variant:`primary`,"aria-label":`Save ${e.displayName} path`,disabled:y.isPending,children:y.isPending?`Checking…`:`Save path`})]})})})]})}function nJe(e,t){return e.issue===void 0?e.installed?e.version===void 0?`Installed`:`Installed, version ${e.version}`:t===null?`Not found in the folders your terminal searches (PATH)`:`Not found at the saved path`:e.issue}var rJe=[`providers`,`system-voice`,`voices`];async function iJe(e){return W(await e.fetch(`${e.origin}/api/providers/system-voice/voices`))}function X7(e=!0){let{api:t}=q();return I({queryKey:rJe,queryFn:()=>iJe(t),enabled:e})}function Z7(e){return e.available?{tone:`done`,word:`Ready`}:{tone:`off`,word:`Not installed`}}function aJe({provider:e,readiness:t,onUseKey:n}){let r=(0,m.useId)(),i=X7(),a=t.available?i.data?.engines??[]:[],o=i.data?.install??void 0,s=sJe();return(0,h.jsxs)(`section`,{"aria-labelledby":r,"data-ready":t.available,className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h3`,{id:r,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsx)(`p`,{className:`sl-section-head__meta`,children:`Voice service · built into this computer, no key`})]}),(0,h.jsx)(J7,{provider:e}),(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 flex-wrap items-center gap-x-2`,"aria-live":`polite`,children:[(0,h.jsx)(hE,{tone:Z7(t).tone,children:Z7(t).word}),(0,h.jsx)(`span`,{className:`min-w-0 break-words text-ink-2`,children:t.available?`Found ${t.engine??`a speech program`}. Narration with it is free; a voice service with a key sounds better.`:i.isPending||o!==void 0?Q7:t.issue??Q7})]}),a.length===0?null:(0,h.jsx)(`ul`,{className:`m-0 list-none p-0 text-small text-ink-2`,children:a.map(e=>{let t=e.voices.length;return(0,h.jsx)(`li`,{children:`${e.name}: ${t} voice${t===1?``:`s`}`},e.id)})}),t.available?(0,h.jsx)(zx,{children:(0,h.jsx)($T,{to:`/settings`,search:{section:`voices`},children:`Add a system voice`})}):(0,h.jsxs)(h.Fragment,{children:[o===void 0?null:(0,h.jsx)(oJe,{install:o}),(0,h.jsxs)(zx,{children:[(0,h.jsx)(K,{disabled:s.isPending,onClick:()=>s.mutate(),children:s.isPending?`Checking…`:`Check again`}),n===void 0?null:(0,h.jsx)(K,{variant:`quiet`,onClick:n,children:`Add an OpenAI key instead`})]}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`Slopify couldn't look again: ${s.error.message}`}),s.isSuccess?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`Looked again just now: still no speech program.`}):null]})]})}var Q7=`No speech program was found on this computer, so it can't narrate.`;function oJe({install:e}){return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.text}),(0,h.jsx)(`pre`,{className:`m-0 overflow-x-auto rounded-sm bg-sunken px-3 py-2 font-mono text-small text-ink`,children:e.commands.join(`
|
|
457
|
-
`)})]})}function sJe(){let{api:e}=q(),t=_();return L({mutationFn:()=>BE(e),onSuccess:async e=>{t.setQueryData(FE,e),await t.invalidateQueries({queryKey:X.providers})}})}function cJe({value:e,onPick:t}){let{api:n}=q(),r=X7(),i=r.data?.engines??[],a=i.find(t=>t.voices.some(t=>t.id===e)),[o,s]=(0,m.useState)(``),c=(0,m.useId)(),l=o.trim().toLowerCase(),u=i.reduce((e,t)=>e+t.voices.length,0),d=t=>l===``||t.id===e||`${t.name} ${t.language??``}`.toLowerCase().includes(l),[f,p]=(0,m.useState)(void 0);(0,m.useEffect)(()=>()=>{f!==void 0&&URL.revokeObjectURL(f)},[f]);let g=L({mutationFn:e=>ah(n,{provider:sN,model:e.engine,voice:e.id,text:lJe}),onSuccess:e=>{let t=URL.createObjectURL(e);p(t),new Audio(t).play().catch(()=>{})}});if(r.data!==void 0&&i.length===0){let e=r.data.install??void 0;return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:e===void 0?r.data.issue??Q7:Q7}),e===void 0?null:(0,h.jsx)(oJe,{install:e}),(0,h.jsx)(`p`,{className:`m-0 text-small`,children:(0,h.jsx)(eE,{to:`/settings`,search:{section:`providers`,provider:sN},children:`Check again on Keys & services`})})]})}return(0,h.jsxs)(`div`,{className:`grid gap-1`,children:[u>12?(0,h.jsx)(Y,{id:c,type:`search`,"aria-label":`Filter voices`,placeholder:`Filter ${String(u)} voices by name or language`,value:o,onChange:e=>s(e.target.value)}):null,(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,h.jsxs)(ZT,{className:`min-w-0 flex-1`,value:e,onChange:e=>{g.reset();for(let n of i){let r=n.voices.find(t=>t.id===e.target.value);if(r!==void 0)return t(r)}},children:[(0,h.jsx)(`option`,{value:``,children:r.data===void 0?`Looking for voices…`:`Pick a voice`}),i.map(e=>(0,h.jsx)(`optgroup`,{label:e.name,children:e.voices.filter(d).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.language===void 0?e.name:`${e.name} (${e.language})`},e.id))},e.id))]}),(0,h.jsxs)(K,{variant:`quiet`,disabled:a===void 0||g.isPending,disabledReason:`Pick a voice first.`,onClick:()=>{a!==void 0&&g.mutate({engine:a.id,id:e})},children:[(0,h.jsx)(zh,{"aria-hidden":`true`,className:`size-[14px]`}),g.isPending?`Speaking…`:`Listen`]})]}),g.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The sample couldn't be spoken: ${g.error.message}`})]})}var lJe=`This is how your narration will sound in this voice.`,$7=[`llm`,`tts`,`image`],uJe={llm:`Writing services`,tts:`Voice services`,image:`Image services`},dJe={llm:`Writing service`,tts:`Voice service`,image:`Image service`},fJe=`••••••••••••`,e9=`openai-tts`;function pJe(e){return/^[aeiou]/i.test(e)?`an`:`a`}function t9(e){return oN(e.readiness)}function mJe(e){return e.readiness.kind===`cli`?Y7(e.readiness):e.readiness.kind===`local`?Z7(e.readiness):e.readiness.hasKey?{tone:`done`,word:`Ready`}:{tone:`off`,word:`No key`}}function hJe(e){return e.readiness.kind===`cli`?`Sign-in`:e.readiness.kind===`local`?`Built in`:`API key`}function n9(e,t,n){let r=e.find(e=>e.id===t.provider);if(r!==void 0)return r;if(t.family===void 0)return;let i=e.filter(e=>e.family===t.family);return i.some(t9)?i.find(t9):n.map(e=>i.find(t=>t.id===e.provider)).find(e=>e!==void 0)??i[0]}function gJe(e,t){let n=$7.find(t=>{let n=e.filter(e=>e.family===t);return n.length>0&&!n.some(t9)});return n===void 0?void 0:n9(e,{family:n,provider:void 0,arrival:!1},t)}function _Je(){let e=window.innerHeight;for(let t of document.querySelectorAll(`[data-slot="usage-notice"], .sl-bottomnav`)){let n=t.getBoundingClientRect();n.height>0&&n.top<e&&(e=n.top)}return e}function vJe(e,t){t===`arrival`&&window.scrollTo({top:0,left:0});let n=_Je(),r=e.getBoundingClientRect().top,i=[...e.querySelectorAll(`[data-setup-key]`)],a=Math.max(...(i.length===0?[e]:i).map(e=>e.getBoundingClientRect().bottom));if(r>=0&&a+16<=n)return;let o=Math.min(a+16-n,r-16);window.scrollBy({top:o,behavior:t===`press`?`smooth`:`auto`})}var yJe=1500;function bJe(e){if(typeof ResizeObserver>`u`)return()=>{};let t=[`wheel`,`touchstart`,`pointerdown`,`keydown`],n=new ResizeObserver(()=>{e.isConnected?vJe(e,`settle`):i()}),r=window.setTimeout(()=>i(),yJe);function i(){n.disconnect(),window.clearTimeout(r);for(let e of t)window.removeEventListener(e,i)}for(let e of t)window.addEventListener(e,i,{passive:!0});return n.observe(document.body),i}var xJe=860;function SJe(e){let t=`(min-width: 1024px)`,[n,r]=(0,m.useState)(()=>typeof window.matchMedia!=`function`||window.matchMedia(t).matches);return(0,m.useLayoutEffect)(()=>{if(e!==null&&typeof ResizeObserver<`u`){let t=()=>{let t=e.getBoundingClientRect().width;t>0&&r(t>=xJe)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()}if(typeof window.matchMedia!=`function`)return;let n=window.matchMedia(t),i=()=>r(n.matches);return n.addEventListener?.(`change`,i),()=>n.removeEventListener?.(`change`,i)},[e]),n}function CJe({focus:e,back:t}={}){let{api:n}=q(),r=I(QE(n)),i=I($E(n)),[a,o]=(0,m.useState)(null),s=SJe(a),[c,l]=(0,m.useState)(void 0),[u,d]=(0,m.useState)(void 0),f=(0,m.useRef)(null),p=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>p.current?.(),[]);let g=$7.flatMap(e=>(r.data?.providers??[]).filter(t=>t.family===e)),_=i.data?.voices??[],[v,y]=(0,m.useState)(!1);if(c===void 0&&r.data!==void 0){let t=e===void 0?s?gJe(g,_):void 0:n9(g,e,_);l(t?.id??null),y(e===void 0&&t!==void 0)}(0,m.useEffect)(()=>{!s&&v&&(y(!1),l(null),u!==void 0&&(d(void 0),window.scrollTo({top:0,left:0})))},[s,v]);let b=I(ZE(n)),x=r.data!==void 0&&!i.isPending&&!b.isPending;(0,m.useEffect)(()=>{if(e===void 0||!x)return;let t=n9(g,e,_);t===void 0?e.arrival&&window.scrollTo({top:0,left:0}):(y(!1),l(t.id),d({id:t.id,arrival:e.arrival}))},[e,x]);let[S,C]=(0,m.useState)(!1);if((0,m.useEffect)(()=>{e===void 0&&x&&!S&&(C(!0),v&&typeof c==`string`?d({id:c,arrival:!0}):window.scrollTo({top:0,left:0}))},[e,x,S,v,c]),(0,m.useEffect)(()=>{if(u===void 0||c!==u.id)return;let e=!0,t=0;return(document.fonts?.ready??Promise.resolve()).then(()=>{e&&(t=requestAnimationFrame(()=>{let e=f.current;e!==null&&e.isConnected&&(vJe(e,u.arrival?`arrival`:`press`),p.current?.(),p.current=u.arrival?bJe(e):void 0,d(void 0))}))}),()=>{e=!1,cancelAnimationFrame(t)}},[u,c,s]),r.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:r.error.message});if(r.data===void 0)return(0,h.jsx)(DJe,{});let w=g.find(e=>e.id===c),T=e=>(0,h.jsx)(`div`,{ref:f,className:`min-w-0 scroll-mt-4`,children:D(e)}),E=e=>g.some(t=>t.id!==e.id&&t.displayName===e.displayName&&t.readiness.kind===`keyed`&&t.readiness.hasKey),D=e=>e.readiness.kind===`cli`?(0,h.jsx)(tJe,{provider:e,readiness:e.readiness,kind:dJe[e.family]},e.id):e.readiness.kind===`local`?(0,h.jsx)(aJe,{provider:e,readiness:e.readiness,...g.some(e=>e.id===e9&&e.readiness.kind===`keyed`&&!e.readiness.hasKey)?{onUseKey:()=>l(e9)}:{}},e.id):(0,h.jsx)(TJe,{provider:e,hasKey:e.readiness.hasKey,voiceless:e.family===`tts`&&i.data!==void 0&&!_.some(t=>t.provider===e.id),twinKeyed:E(e),back:t},e.id);return(0,h.jsx)(`div`,{ref:o,className:`@container flex min-w-0 flex-col gap-6`,children:$7.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,"aria-labelledby":`keys-${e}-title`,className:`grid scroll-mt-4 items-start gap-x-8 gap-y-4 @min-[860px]:grid-cols-[minmax(0,400px)_minmax(0,1fr)]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(lD,{id:`keys-${e}-title`,title:uJe[e],size:`small`,className:`pb-2`}),(0,h.jsx)(`ul`,{"aria-label":uJe[e],className:`sl-list m-0 list-none p-0`,children:g.filter(t=>t.family===e).map(e=>(0,h.jsx)(wJe,{provider:e,selected:e.id===w?.id,expands:!s,onSelect:()=>{y(!1),l(t=>!s&&t===e.id?null:e.id)},children:!s&&e.id===w?.id?T(e):null},e.id))})]}),s&&w!==void 0&&w.family===e?T(w):null]},e))})}function wJe({provider:e,selected:t,expands:n,onSelect:r,children:i}){let a=mJe(e);return(0,h.jsxs)(`li`,{"data-selected":t?`true`:void 0,"aria-current":t?`true`:void 0,className:`border-b border-line`,children:[(0,h.jsxs)(`div`,{className:G(RL,`grid min-h-10 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 px-3 py-2 hover:bg-raised`,t&&`bg-accent-tint hover:bg-accent-tint`),children:[(0,h.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,h.jsx)(HL,{onSelect:r,expanded:n?t:void 0,className:`min-w-0`,children:e.displayName}),(0,h.jsx)(`span`,{className:`shrink-0 text-small text-ink-2`,children:hJe(e)})]}),(0,h.jsx)(hE,{tone:a.tone,children:a.word})]}),i===null?null:(0,h.jsx)(`div`,{className:`px-3 pt-2 pb-5`,children:i})]})}function TJe({provider:e,hasKey:t,voiceless:n,twinKeyed:r,back:i}){let{api:a}=q(),o=_(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(void 0),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(void 0),E=(0,m.useId)(),D=PF[e.id],O=l.trim(),k=async()=>{C(!0),T(void 0);try{T(await Nxe(a,e.id,O===``?void 0:O))}catch(e){y(e instanceof Error?e.message:String(e))}finally{C(!1)}},A=async()=>{f(!0),y(void 0);try{await Cte(a,e.id,l),u(``),g(!0),T(void 0),await o.invalidateQueries({queryKey:X.providers})}catch(e){y(e instanceof Error?e.message:String(e))}finally{f(!1)}},j=L({mutationFn:()=>Tte(a,e.id),onSuccess:async()=>{x(!1),y(void 0),await o.invalidateQueries({queryKey:X.providers})},onError:e=>{x(!1),y(e.message)}});(0,m.useEffect)(()=>{if(!p)return;let e=setTimeout(()=>{g(!1)},oB);return()=>{clearTimeout(e)}},[p]);let M=[t?c:void 0,w===void 0?void 0:E].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`section`,{"aria-labelledby":s,"data-ready":t,className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h3`,{id:s,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsx)(`p`,{className:`sl-section-head__meta`,children:`${dJe[e.family]} · ${t?`a key is saved`:`needs an API key`}`})]}),(0,h.jsx)(J7,{provider:e}),(0,h.jsx)(`div`,{"data-setup-key":``,className:`min-w-0`,children:(0,h.jsx)(J,{label:`${e.displayName} API key`,help:!t&&r?`Your ${e.displayName} key for ${e.family===`image`?`voices`:`images`} is saved, and the same key works here: paste it again. Stored on this computer only.`:`Stored on this computer only, sent only to this service, never in backups or exports.`,error:v,children:(0,h.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),l.trim()!==``&&!d&&A()},children:[(0,h.jsx)(QAe,{autoComplete:`off`,spellCheck:!1,className:`flex-1 basis-[200px]`,"aria-describedby":M===``?void 0:M,placeholder:t?fJe:`Paste API key`,value:l,onChange:e=>{u(e.target.value)}}),(0,h.jsx)(K,{type:`submit`,variant:`primary`,"aria-label":`Save ${e.displayName} key`,disabled:l.trim()===``||d,children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:p?(0,h.jsx)(cB,{}):null})]})})}),t?(0,h.jsx)(`span`,{id:c,className:`sr-only`,children:`A key is stored for this provider.`}):null,w===void 0?null:(0,h.jsx)(`p`,{id:E,role:w.ok?`status`:`alert`,className:G(`m-0 text-small`,w.ok?`text-accent-ink`:`text-danger`),children:w.message}),!t&&O===``&&i===void 0?null:(0,h.jsxs)(zx,{"data-setup-key":``,children:[i===void 0?null:t?(0,h.jsx)(VR,{back:i,variant:`primary`,children:`Done · back to ${RR(i)}`}):(0,h.jsx)(VR,{back:i,children:`Back to ${RR(i)}`}),!t&&O===``?null:(0,h.jsx)(K,{disabled:S,onClick:()=>{k()},children:S?`Testing…`:`Test the key (free)`}),t?(0,h.jsx)(K,{variant:`quiet`,onClick:()=>{x(!0)},children:`Remove the key`}):null]}),t&&n?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[e.id===e9?`Your first short saves an OpenAI voice by itself. To pick one now: `:`No ${e.displayName} voice is saved yet, so narration can't use it. `,(0,h.jsx)(eE,{to:`/settings`,search:{section:`voices`,provider:e.id,...zR(i)},children:`Add ${pJe(e.displayName)} ${e.displayName} voice`})]}):null,D===void 0?null:(0,h.jsx)(SR,{summary:`Where to get a key`,state:`${String(D.steps.length)} steps`,children:(0,h.jsx)(`div`,{className:`flex flex-col gap-2 pt-2 text-small text-ink-2`,children:(0,h.jsx)(EJe,{guide:D})})}),(0,h.jsx)(ME,{open:b,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this service cannot retry until a key is saved.`,confirmLabel:`Remove key`,pending:j.isPending,onConfirm:()=>{j.mutate()},onCancel:()=>{x(!1)}})]})}function EJe({guide:e}){let t=(e,t)=>(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`underline`,children:t});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`ol`,{className:`m-0 list-decimal space-y-1 pl-5`,children:e.steps.map(e=>(0,h.jsx)(`li`,{children:e},e))}),(0,h.jsxs)(`p`,{className:`m-0`,children:[`Sign up: `,t(e.signUp.url,e.signUp.label),`. Make the key:`,` `,t(e.keyPage.url,e.keyPage.label),`.`,e.billing===void 0?null:(0,h.jsxs)(h.Fragment,{children:[` Credit: `,t(e.billing.url,e.billing.label),`.`]})]}),(0,h.jsx)(`p`,{className:`m-0`,children:e.permissions}),(0,h.jsxs)(`p`,{className:`m-0`,children:[`More in the service's `,t(e.docs.url,e.docs.label),`. After saving, press Test the key.`]})]})}function DJe(){return(0,h.jsx)(`div`,{className:`flex flex-col gap-6`,role:`status`,"aria-label":`Loading services`,children:[[`llm`,4],[`tts`,6],[`image`,5]].map(([e,t])=>(0,h.jsxs)(`div`,{className:`max-w-[400px]`,children:[(0,h.jsx)(`span`,{className:`mb-2 block h-3 w-24 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`sl-list`,children:Array.from({length:t},(t,n)=>`${e}-${n}`).map(e=>(0,h.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b border-line px-3`,children:[(0,h.jsx)(`span`,{className:`h-4 w-32 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-4 w-16 rounded-control bg-raised`})]},e))})]},e))})}function OJe(e){return ak(e).code===e?ak(e).name:e}function kJe({value:e,onChange:t,label:n,disabled:r=!1}){let i=rk.filter(t=>!e.includes(t.code));return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[e.map(n=>(0,h.jsxs)(`span`,{className:`sl-chip h-8 gap-1 pr-1`,children:[OJe(n),(0,h.jsx)(Lx,{label:`Remove ${OJe(n)}`,size:`small`,tip:!1,disabled:r,onClick:()=>t(e.filter(e=>e!==n)),children:(0,h.jsx)(Bh,{"aria-hidden":`true`,className:`size-3.5`,strokeWidth:2})})]},n)),i.length===0?null:(0,h.jsx)(ZT,{"aria-label":n,className:`sl-select--compact`,value:``,disabled:r,options:[{value:``,label:e.length===0?`Any language`:`Add a language`},...i.map(e=>({value:e.code,label:e.name}))],onChange:n=>{n.target.value!==``&&t([...e,n.target.value])}})]})}function AJe({voice:e}){let{api:t}=q(),n=_(),r=L({mutationFn:n=>Xte(t,e.id,n),onSettled:async()=>{await n.invalidateQueries({queryKey:X.voices})}}),i=r.isPending&&r.variables!==void 0?r.variables:e.languages??[],a=r.error?.message??r.data?.message;return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,h.jsx)(kJe,{value:i,label:`Languages ${e.name} speaks`,disabled:r.isPending,onChange:e=>r.mutate(e)}),a===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:a})]})}var jJe=[`alloy`,`ash`,`ballad`,`coral`,`echo`,`fable`,`nova`,`onyx`,`sage`,`shimmer`,`verse`],MJe=`__paste__`,NJe={elevenlabs:{label:`ElevenLabs voice library`,url:`https://elevenlabs.io/app/voice-library`},cartesia:{label:`Cartesia voice library`,url:`https://play.cartesia.ai/voices`}};function r9(e){return e!==void 0&&oN(e.readiness)}function i9(e){return e.readiness.kind===`local`?`Not installed`:`No key`}function a9({provider:e,back:t}){return(0,h.jsx)($T,{size:`small`,to:`/settings`,search:{section:`providers`,family:`tts`,provider:e.id,...zR(t)},children:e.readiness.kind===`local`?`Set up the system voice`:`Add ${pJe(e.displayName)} ${e.displayName} key`})}function PJe({provider:e,back:t}={}){let{api:n}=q(),r=_(),i=I($E(n)),a=I(QE(n)),[o,s]=(0,m.useState)(void 0),c=L({mutationFn:e=>Qte(n,e),onSettled:async()=>{s(void 0),await r.invalidateQueries({queryKey:X.voices})}}),l=L({mutationFn:({id:e,on:t})=>Zte(n,e,t),onSettled:async()=>{await r.invalidateQueries({queryKey:X.voices})}}),u=(a.data?.providers??[]).filter(e=>e.family===`tts`),d=e=>u.find(t=>t.id===e.provider);if(i.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:i.error.message});let f=i.data?.voices,p=u.filter(e=>a.data!==void 0&&!r9(e)&&(f??[]).some(t=>t.provider===e.id));return(0,h.jsxs)(`div`,{"data-tour":`voices`,className:`flex min-w-0 flex-col gap-6`,children:[p.map(e=>{let n=(f??[]).filter(t=>t.provider===e.id).length;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-control bg-raised px-3 py-2`,children:[(0,h.jsx)(hE,{tone:`waiting`,children:i9(e)}),(0,h.jsx)(`span`,{className:`min-w-0 flex-1 text-small text-ink`,children:`${e.readiness.kind===`local`?`The ${e.displayName.toLowerCase()} isn't installed`:`${e.displayName} has no key yet`}, so ${n===1?`its voice`:`its ${String(n)} voices`} can't narrate.`}),(0,h.jsx)(a9,{provider:e,back:t})]},e.id)}),(0,h.jsxs)(`div`,{className:`@container min-w-0`,...GT,children:[f===void 0?(0,h.jsx)(`span`,{className:`block h-10 w-64 rounded-control bg-raised`}):f.length===0?(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:`No voices yet. Add one below: narration reads your script in it.`}):(0,h.jsx)(BL,{label:`Voices`,children:f.map(e=>{let t=d(e),n=r9(t);return(0,h.jsx)(VL,{className:`relative`,title:e.name,meta:(0,h.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`truncate`,children:t?.displayName??e.provider}),t===void 0||a.data===void 0?null:n?(0,h.jsx)(hE,{tone:`done`,children:`Ready`}):(0,h.jsx)(hE,{tone:`off`,children:i9(t)}),(0,h.jsx)(`span`,{className:`truncate`,children:`· ${e.voiceId}`})]}),actions:(0,h.jsxs)(h.Fragment,{children:[n?(0,h.jsx)(FJe,{voice:e}):null,(0,h.jsx)(K,{variant:`quiet`,size:`small`,"aria-label":`Remove ${e.name}`,onClick:()=>{s(e)},children:`Remove`})]}),children:(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Speaks`}),(0,h.jsx)(AJe,{voice:e})]}),(0,h.jsx)(dD,{checked:l.isPending&&l.variables.id===e.id?l.variables.on:e.imitatesRealPerson===!0,disabled:l.isPending,onChange:t=>l.mutate({id:e.id,on:t}),label:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`sr-only`,children:`${e.name} sounds like a real person`}),(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`Sounds like a real person`})]}),className:`text-small`})]})},e.id)})}),l.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:`Couldn't save Sounds like a real person: ${l.error.message} Press the switch again.`}),c.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:c.error.message}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1`,children:[(0,h.jsx)(KT,{children:`Sounds like a real person: turn it on for a voice cloned from, or made to sound like, someone real. YouTube asks you to say so when you upload; Copy for YouTube Studio answers Yes for you.`}),(f??[]).some(e=>r9(d(e)))?(0,h.jsx)(KT,{children:`Listen reads one sentence aloud: free with the system voice, one short paid request with a service that has a key.`}):null,(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[`How names and words are said:`,` `,(0,h.jsx)(eE,{to:`/name-pronunciations`,children:`Name pronunciations ↗`}),` for the names every video says the same way, `,(0,h.jsx)(eE,{to:`/narration-aliases`,children:`Pronunciation ↗`}),` `,`for words said as other words.`]})]})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Add a voice`}),(0,h.jsx)(IJe,{tts:u,asked:u.find(t=>t.id===e)?.id,needed:(f??[]).map(e=>e.provider),said:p.map(e=>e.id),back:t})]}),(0,h.jsx)(ME,{open:o!==void 0,title:o===void 0?``:`Remove ${o.name}?`,consequence:`Projects that used this voice keep the narration they made with it.`,confirmLabel:`Remove voice`,pending:c.isPending,onConfirm:()=>{o!==void 0&&c.mutate(o.id)},onCancel:()=>{s(void 0)}})]})}function FJe({voice:e}){let{api:t}=q(),n=X7(e.provider===sN),[r,i]=(0,m.useState)(void 0);(0,m.useEffect)(()=>()=>{r!==void 0&&URL.revokeObjectURL(r)},[r]);let a=L({mutationFn:async()=>{let r=e.provider===`system-voice`?n.data?.engines.find(t=>t.voices.some(t=>t.id===e.voiceId))?.id:(await vN(t,e.provider)).models[0]?.id;if(r===void 0)throw Error(`No voice model was found for this service. Check it on Models.`);return ah(t,{provider:e.provider,model:r,voice:e.voiceId,text:lJe})},onSuccess:e=>{let t=URL.createObjectURL(e);i(t),new Audio(t).play().catch(()=>{})}});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(K,{variant:`quiet`,size:`small`,"aria-label":`Listen to ${e.name}`,disabled:a.isPending,onClick:()=>a.mutate(),children:[(0,h.jsx)(zh,{"aria-hidden":`true`,className:`size-[14px]`}),a.isPending?`Speaking…`:`Listen`]}),a.error===null?null:(0,h.jsx)(`span`,{role:`alert`,className:`basis-full text-left text-small text-danger`,children:`${e.name} couldn't be spoken: ${a.error.message}`})]})}function IJe({tts:e,asked:t,needed:n,said:r,back:i}){let{api:a}=q(),o=_(),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)([]),[v,y]=(0,m.useState)(void 0),[b,x]=(0,m.useState)(void 0),S=v??t??(e.find(r9)??e.find(e=>n.includes(e.id))??e[0])?.id,C=e.find(e=>e.id===S),w=L({mutationFn:e=>Yte(a,e),onSuccess:async e=>{e.ok?(c(``),u(``),f(!1),g([]),x(void 0),await o.invalidateQueries({queryKey:X.voices})):x(e.refusal)}}),T=(e,t)=>{t(),b?.field===e&&x(void 0)},E=e=>b?.field===e?b.message:void 0,D=S!==`system-voice`&&S!==`google-tts`&&(S!==`openai-tts`||d),O=S===void 0?`Pick a voice service first`:l.trim()===``?D?`Paste a voice ID first`:`Pick a voice first`:s.trim()===``?`Type a name first`:void 0,k=C!==void 0&&C.readiness.kind===`local`&&!r9(C),A=()=>{S===void 0||O!==void 0||b!==void 0||w.isPending||w.mutate({provider:S,name:s,voiceId:l,...p.length===0?{}:{languages:p}})},j=e=>{T(`voiceId`,()=>{u(e),s.trim()===``&&c(e)})},M=S===void 0?void 0:NJe[S],N=S===`inworld`?`Use an Inworld voice ID, such as Dennis, or one from your workspace.`:M===void 0?S===`openai-tts`&&d?`A voice made in your OpenAI account starts with voice_.`:void 0:(0,h.jsxs)(h.Fragment,{children:[`Copy a voice's ID from the`,` `,(0,h.jsx)(`a`,{href:M.url,target:`_blank`,rel:`noreferrer`,className:`sl-link`,children:`${M.label} ↗`}),` `,`or your own voices there.`]});return(0,h.jsxs)(`form`,{className:`@container flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),A()},children:[(0,h.jsxs)(`div`,{className:`grid items-start gap-4 @min-[36rem]:grid-cols-2 @min-[60rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.2fr)_minmax(0,1fr)_minmax(0,1.2fr)_auto]`,children:[(0,h.jsx)(J,{label:`Voice service`,error:E(`provider`),children:(0,h.jsxs)(ZT,{value:S??``,onChange:t=>{let n=e.find(e=>e.id===t.target.value);n!==void 0&&T(`provider`,()=>{y(n.id),u(``),f(!1)})},children:[e.length===0?(0,h.jsx)(`option`,{value:``,children:`No voice service`}):null,e.map(e=>(0,h.jsx)(`option`,{value:e.id,children:r9(e)?e.displayName:`${e.displayName} (${i9(e).toLowerCase()})`},e.id))]})}),k?(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-2 self-center text-small text-ink-2 @min-[36rem]:col-span-full @min-[60rem]:col-span-4 @min-[60rem]:mt-6`,children:[`The system voice isn't installed on this computer, so it has no voices to add yet.`,r.includes(C.id)?null:(0,h.jsx)(a9,{provider:C,back:i})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(J,{label:D?`Voice ID`:`Voice`,error:E(`voiceId`),...N===void 0?{}:{help:N},children:S===`system-voice`?(0,h.jsx)(cJe,{value:l,onPick:e=>{T(`voiceId`,()=>{u(e.id)}),s.trim()===``&&c(e.name);let t=/^([a-z]{2,3})(?:[-_]|$)/i.exec(e.language??``)?.[1];p.length===0&&t!==void 0&&g([t.toLowerCase()])}}):S===`google-tts`?(0,h.jsx)(ZT,{value:l,options:[{value:``,label:`Pick a Gemini voice`},...Mxe.map(e=>({value:e.name,label:`${e.name} (${e.style})`}))],onChange:e=>j(e.target.value)}):S===`openai-tts`&&!d?(0,h.jsx)(ZT,{value:l,options:[{value:``,label:`Pick an OpenAI voice`},...jJe.map(e=>({value:e,label:e})),{value:MJe,label:`A voice of my own (paste its ID)`}],onChange:e=>{e.target.value===MJe?(f(!0),T(`voiceId`,()=>u(``))):j(e.target.value)}}):(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,h.jsx)(Y,{className:`tabular-nums`,value:l,onChange:e=>{let t=e.target.value;T(`voiceId`,()=>{u(t)})}}),S===`openai-tts`?(0,h.jsx)(K,{variant:`quiet`,size:`small`,onClick:()=>{f(!1),T(`voiceId`,()=>u(``))},children:`Pick from OpenAI's voices`}):null]})}),(0,h.jsx)(J,{label:`Name`,help:`How you pick it on Create.`,error:E(`name`),children:(0,h.jsx)(Y,{value:s,onChange:e=>{let t=e.target.value;T(`name`,()=>{c(t)})}})}),(0,h.jsx)(J,{label:`Languages it speaks`,help:`Create lists the voice for projects in these languages.`,error:E(`languages`),children:(0,h.jsx)(kJe,{value:p,label:`Languages it speaks`,onChange:e=>T(`languages`,()=>g(e))})}),(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-1 @min-[60rem]:mt-6`,children:[(0,h.jsx)(K,{type:`submit`,variant:`primary`,disabled:O!==void 0||b!==void 0||w.isPending,children:`Add voice`}),O===void 0?null:(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:O})]})]})]}),C===void 0||r9(C)||k||r.includes(C.id)?null:(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-2 text-small text-ink-2`,children:[`${C.displayName} has no key yet: you can add the voice now, but it can't narrate until the key is saved.`,(0,h.jsx)(a9,{provider:C,back:i})]}),w.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:w.error.message})]})}var LJe={headline:`Slopify test notification`,detail:`Notifications work. You'll get one when a run finishes, fails or waits for you, and when a review needs your decision.`},RJe=2048;function zJe(e){let t=e.trim();if(t===``)return;if(t.length>2048)return`Keep the Notification URL to ${String(RJe)} characters or fewer.`;let n;try{n=new URL(t)}catch{return`Enter a full address starting with https:// or http://, for example https://ntfy.sh/your-topic.`}if(n.protocol!==`https:`&&n.protocol!==`http:`)return`The Notification URL must start with https:// or http://.`;if(n.username!==``||n.password!==``)return`Remove the user name and password from the Notification URL; Slopify can't send them.`}var BJe=[`settings`,`notifications`],VJe=`The test notification couldn't be shown: this browser only allows notifications from installed apps. Set a Notification URL below instead.`;function HJe(){return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Browser and phone`,meta:`When a run finishes, fails or waits for your review, Slopify sends the project's title and a link, never your keys.`}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsx)(UJe,{}),(0,h.jsx)(WJe,{}),(0,h.jsx)(GJe,{}),(0,h.jsx)(KJe,{})]})]})}function UJe(){let e=(0,m.useSyncExternalStore)(Ewe,pI,()=>!1),[t,n]=(0,m.useState)(fI),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=Vx(),c=e&&t===`granted`;async function l(e){if(i(void 0),!e)mI(!1);else{o(!0);try{let e=await kwe();n(e);let t=Owe(e);e===`granted`?(mI(!0),pI()||i(`Notifications couldn't be turned on because this browser blocks site storage for Slopify. Allow site data for this address in your browser's settings, then turn ${o9} on again.`)):i(t??`Notifications weren't turned on because the permission prompt was dismissed. Turn ${o9} on again and choose Allow.`)}finally{o(!1)}}}return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-2`,children:[(0,h.jsx)(dD,{label:o9,help:`Shows a notification on this computer when a run finishes, fails or waits for you, while any Slopify tab is open. Turning it on asks the browser's permission.`,checked:c,disabled:a,onChange:e=>void l(e)}),c?(0,h.jsx)(K,{variant:`quiet`,onClick:()=>{i(void 0);try{_I({projectId:`test`,text:LJe},()=>{}),s(`Test notification sent to this browser.`,`success`)}catch{i(VJe)}},children:`Send test notification`}):null]}),r===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:r})]})}function WJe(){let e=(0,m.useSyncExternalStore)(Fwe,bI,()=>!0);return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-2`,children:[(0,h.jsx)(dD,{label:`Play a sound when a run starts and ends`,help:`The end sound also plays when a run fails or waits for you. You hear them in this browser while a Slopify tab is open and has been clicked once.`,checked:e,onChange:Pwe}),(0,h.jsx)(K,{variant:`quiet`,onClick:()=>wI(`start`),children:`Hear the start sound`}),(0,h.jsx)(K,{variant:`quiet`,onClick:()=>wI(`end`),children:`Hear the end sound`})]})}var o9=`Notify me in this browser`;function GJe(){let{api:e}=q(),t=_(),n=Vx(),r=(0,m.useId)(),i=I({queryKey:BJe,queryFn:()=>kte(e)}),[a,o]=(0,m.useState)(void 0),s=a??i.data?.url??``,c=zJe(s),l=L({mutationFn:t=>Ate(e,t),onSuccess:e=>{t.setQueryData(BJe,e),o(void 0),n(e.url===null?`Notification URL removed.`:`Notification URL saved.`,`success`)}}),u=L({mutationFn:t=>jte(e,t),onSuccess:()=>{n(`Test notification sent. Check the app or page behind your Notification URL.`,`success`)}}),d=c??l.error?.message??u.error?.message,f=l.isPending||u.isPending||i.data===void 0,p=a!==void 0&&a!==(i.data?.url??``);return(0,h.jsxs)(J,{label:`Notification URL`,tip:`settings.notifications.url`,help:`Works with no tab open, for example an ntfy topic on your phone. Saved only when you press Save.`,children:[(0,h.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),!f&&c===void 0&&p&&l.mutate(s)},children:[(0,h.jsx)(Y,{type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:`https://ntfy.sh/your-topic`,className:`min-w-0 flex-1 basis-[220px]`,value:s,disabled:i.data===void 0,"aria-invalid":c!==void 0,"aria-describedby":d===void 0?void 0:r,onChange:e=>{l.reset(),u.reset(),o(e.target.value)}}),(0,h.jsx)(K,{type:`submit`,variant:`primary`,disabled:f||c!==void 0||!p,disabledReason:`Type a new address first, or fix the one shown.`,children:`Save`}),s.trim()===``?null:(0,h.jsx)(K,{variant:`quiet`,disabled:f||c!==void 0,disabledReason:`Fix the address first.`,onClick:()=>u.mutate(s),children:`Send test notification`})]}),(0,h.jsx)(KJ,{dirty:p,onDiscard:()=>{l.reset(),u.reset(),o(void 0)}}),i.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The saved Notification URL couldn't be read: `,i.error.message]}),d===void 0?null:(0,h.jsx)(`p`,{id:r,role:`alert`,className:`m-0 text-small text-danger`,children:d})]})}function KJe(){let{api:e}=q(),t=_(),n=I({queryKey:tY,queryFn:()=>uje(e)}),r=L({mutationFn:t=>dje(e,t),onSuccess:async e=>{t.setQueryData(tY,e),await t.invalidateQueries({queryKey:eY})}});return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(dD,{label:`Weekly report`,help:`Each Monday from 09:00, what was made, what failed and what it cost last week go to the Notification URL above.`,checked:n.data?.enabled===!0,disabled:n.data===void 0||r.isPending,onChange:e=>r.mutate(e)}),n.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:`The Weekly report setting didn't load: ${n.error.message}. Reload the page to try again.`}),r.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`Weekly report wasn't changed: ${r.error.message}. Try the switch again.`})]})}function qJe({note:e,onNote:t}){let{api:n}=q(),r=I(NI(n));if(r.error!==null)return(0,h.jsx)(IT,{tone:`danger`,title:`What's new did not load`,actions:(0,h.jsx)(K,{onClick:()=>void r.refetch(),children:`Try again`}),children:`${r.error.message} Press Try again, or reload the page.`});if(r.data===void 0)return(0,h.jsx)(`p`,{className:`m-0 text-ink-3`,children:`Loading what's new…`});let{notes:i,version:a}=r.data,[o]=i;if(o===void 0)return(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:`This version of Slopify has no patch notes.`});let s=e===void 0?void 0:i.find(t=>t.id===e),c=s??o;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e!==void 0&&s===void 0?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`There are no patch notes called "${e}" in this version. The newest are below.`}):null,(0,h.jsx)(J,{label:`Version`,...c.version===a?{help:`The version you are running.`}:{},className:`max-w-[360px]`,children:(0,h.jsx)(ZT,{value:c.id,options:i.map(e=>({value:e.id,label:e.version===a?`${e.title} (yours)`:e.title})),onChange:e=>t(e.target.value===o.id?void 0:e.target.value)})}),(0,h.jsx)(VI,{id:c.id,untitled:!0})]})}var JJe=new Set([`tailscale`,`npx`]),YJe=new Set([`serve`,`funnel`,`status`,`off`,`on`,`up`,`reset`]);function XJe(e,t){return t?!0:YJe.has(e)||/^--[\w-]+(?:=\S+)?$/u.test(e)||/^https?:\/\/\S+$/u.test(e)||/^@[\w./@-]+$/u.test(e)||/^<[^>]*>?$/u.test(e)||/^\d+$/u.test(e)}function ZJe(e){let t=e.split(/( )/u),n=[],r=(e,t)=>{let r=n.at(-1);r!==void 0&&r.command===t?r.text+=e:n.push({text:e,command:t})},i=0;for(;i<t.length;){let e=t[i]??``;if(!JJe.has(e)||t[i+2]===void 0){r(e,!1),i+=1;continue}let n=e,a=i+2,o=!1,s=``;for(;a<t.length;){let e=t[a]??``,r=e.replace(/[.,;:)]+$/u,``);if(r===``||!XJe(r,o))break;if(n+=` ${r}`,o=(o||r.includes(`<`))&&!r.includes(`>`),a+=2,r!==e){s=e.slice(r.length);break}}n===e?(r(e,!1),i+=1):(r(n,!0),s!==``&&r(s,!1),i=a-1)}return n}function s9({text:e}){let t=ZJe(e).map((e,t)=>e.command?(0,h.jsx)(`code`,{className:`sl-code sl-command`,children:e.text},t):(0,h.jsx)(m.Fragment,{children:e.text},t));return(0,h.jsx)(h.Fragment,{children:t})}var c9=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(c9||{}),QJe=[0,1],$Je=[1,0],eYe=[2,3],tYe=[3,2],nYe={L:QJe,M:$Je,Q:eYe,H:tYe},rYe=/^\d*$/,iYe=/^[A-Z0-9 $%*+./:-]*$/,l9=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,u9=1,d9=40,aYe=3,oYe=3,f9=40,sYe=10,cYe=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],lYe=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],uYe=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<u9||e>d9)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,c9.Timing),this.setFunctionModule(e,6,e%2==0,c9.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,m9(r,e));this.setFunctionModule(8,7,m9(r,6)),this.setFunctionModule(8,8,m9(r,7)),this.setFunctionModule(7,8,m9(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,m9(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,m9(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,m9(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=m9(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,c9.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,c9.Alignment)}setFunctionModule(e,t,n,r=c9.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==_9(t,n))throw RangeError(`Invalid argument`);let r=lYe[n[0]][t],i=cYe[n[0]][t],a=Math.floor(g9(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=CYe(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=wYe(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(g9(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=m9(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=aYe:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*f9),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*f9}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=aYe:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*f9),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*f9}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=oYe)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*sYe,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function p9(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function m9(e,t){return!!(e>>>t&1)}var h9=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},dYe=[1,10,12,14],fYe=[2,9,11,13],pYe=[4,8,16,16];function mYe(e,t){return e[Math.floor((t+7)/17)+1]}function hYe(e){let t=[];for(let n of e)p9(n,8,t);return new h9(pYe,e.length,t)}function gYe(e){if(!yYe(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);p9(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new h9(dYe,e.length,t)}function _Ye(e){if(!bYe(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=l9.indexOf(e.charAt(n))*45;r+=l9.indexOf(e.charAt(n+1)),p9(r,11,t)}return n<e.length&&p9(l9.indexOf(e.charAt(n)),6,t),new h9(fYe,e.length,t)}function vYe(e){return e===``?[]:yYe(e)?[gYe(e)]:bYe(e)?[_Ye(e)]:[hYe(SYe(e))]}function yYe(e){return rYe.test(e)}function bYe(e){return iYe.test(e)}function xYe(e,t){let n=0;for(let r of e){let e=mYe(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function SYe(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function g9(e){if(e<u9||e>d9)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function _9(e,t){return Math.floor(g9(e)/8)-cYe[t[0]][e]*lYe[t[0]][e]}function CYe(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=v9(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=v9(n,2)}return t}function wYe(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=v9(t,e))}return n}function v9(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function TYe(e,t,n=1,r=40,i=-1,a=!0){if(!(u9<=n&&n<=r&&r<=d9)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=_9(o,t)*8,i=xYe(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[$Je,eYe,tYe])a&&s<=_9(o,e)*8&&(t=e);let c=[];for(let t of e){p9(t.mode[0],4,c),p9(t.numChars,mYe(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=_9(o,t)*8;p9(0,Math.min(4,l-c.length),c),p9(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)p9(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new uYe(o,t,u,i)}function EYe(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?vYe(e):Array.isArray(e)?[hYe(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=TYe(c,nYe[n],i,a,o,r),u=DYe({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function DYe(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=c9.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}function OYe({text:e,label:t,size:n=168}){let{data:r}=EYe(e,{ecc:`M`,border:2}),i=r.length,a=r.flatMap((e,t)=>e.map((e,n)=>e?`M${n} ${t}h1v1h-1z`:``)).join(``);return(0,h.jsxs)(`svg`,{role:`img`,"aria-label":t,width:n,height:n,viewBox:`0 0 ${i} ${i}`,shapeRendering:`crispEdges`,className:`shrink-0 rounded-sm`,children:[(0,h.jsx)(`rect`,{width:i,height:i,fill:`white`}),(0,h.jsx)(`path`,{d:a,fill:`black`})]})}var kYe=`Open on my other devices (Tailscale)`,AYe={failed:`danger`,denied:`danger`,funnel:`danger`},jYe=e=>e.includes(`admin`)?`Open the Tailscale admin console`:`Download Tailscale`;function MYe(){let{api:e}=q(),t=Vx(),n=_(),r=I({queryKey:H7,queryFn:()=>W7(e)}),i=L({mutationFn:t=>Rqe(e,t),onSuccess:e=>n.setQueryData(H7,e)}),a=r.data,o=async e=>{await oJ(e)?t(`Address copied.`,`success`):t(`The address wasn't copied: this browser blocked the clipboard. Select it and copy it yourself.`,`error`)},s=i.isPending,c=a!==void 0&&a.fix!==null&&a.state!==`docker`;return(0,h.jsxs)(`section`,{className:`flex max-w-prose flex-col gap-3`,children:[r.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:[`Remote access couldn't be checked: `,r.error.message]}),a===void 0?r.error===null?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink-2`,children:`Checking Tailscale…`}):null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(dD,{label:kYe,tip:`settings.remote-access`,checked:a.enabled,disabled:!a.available||!a.changeable||s,describedBy:`remote-access-summary`,onChange:e=>i.mutate({enabled:e})}),(0,h.jsxs)(`p`,{id:`remote-access-summary`,role:`status`,className:`m-0 text-small text-ink-2`,children:[s?`Asking Tailscale…`:c?``:(0,h.jsx)(s9,{text:a.summary}),!a.changeable&&a.available?` Turn it on or off on the computer Slopify runs on.`:``]}),a.state===`docker`&&a.fix!==null?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:(0,h.jsx)(s9,{text:a.fix})}):null,a.address===null?null:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,h.jsx)(OYe,{text:a.address,label:`QR code for ${a.address}`}),(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-[220px] flex-col gap-2`,children:[(0,h.jsx)(`code`,{className:`sl-code py-2 break-all select-all`,children:a.address}),(0,h.jsx)(`div`,{children:(0,h.jsxs)(K,{variant:`secondary`,"aria-label":`Copy the remote address`,onClick:()=>void o(a.address??``),children:[(0,h.jsx)(_h,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),`Copy address`]})}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Scan it with your phone's camera. The device must be signed in to the same tailnet.`})]})]}),c?(0,h.jsx)(IT,{tone:AYe[a.state]??`waiting`,title:(0,h.jsx)(s9,{text:a.summary}),actions:a.changeable?(0,h.jsxs)(h.Fragment,{children:[a.suggestedPort===null?null:(0,h.jsxs)(K,{variant:`primary`,disabled:s,onClick:()=>i.mutate({enabled:!0,httpsPort:a.suggestedPort??443}),children:[`Use port `,a.suggestedPort]}),a.link===null?null:(0,h.jsx)(tE,{href:a.link,target:`_blank`,rel:`noreferrer`,children:jYe(a.link)}),(0,h.jsx)(K,{variant:a.suggestedPort===null?`primary`:`secondary`,disabled:s,onClick:()=>i.mutate({enabled:a.enabled}),children:`Check again`})]}):void 0,children:a.fix===null?null:(0,h.jsx)(s9,{text:a.fix})}):null,i.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:i.error.message})]})]})}var NYe=H({id:U([`keywords`,`providers`,`voice`,`release-slots`,`monthly-cost`,`answerers`]),ok:$p(),sentence:z(),fix:H({label:z(),href:z()}).strict().readonly().optional()}).strict().readonly(),PYe=H({id:U(Kx),label:z(),state:U(ile),sentence:z()}).strict().readonly(),y9=H({state:U([`current`,`making`,`waiting`,`needs-fix`,`stale`,`off`]),sentence:z(),url:z().nullable()}).strict().readonly(),FYe=H({video:y9,loudness:y9.unwrap().extend({beforeUrl:z().nullable(),beforeLufs:B().nullable(),afterLufs:B().nullable(),targetLufs:B().nullable(),ceiling:B().nullable()}).strict().readonly(),document:y9}).strict().readonly(),IYe=H({runs:V(H({at:z(),scheduleId:z(),scheduleName:z(),title:z(),topic:$p(),paused:$p()}).strict().readonly()).readonly(),cost:H({runs:B(),high:B(),unknown:B(),unpriced:V(z()).readonly(),problem:z().nullable(),paused:H({schedules:B(),runs:B(),high:B()}).strict().readonly()}).strict().readonly().nullable()}).strict().readonly(),LYe=H({id:z(),name:z(),kind:U([`checkpoint`,`review`]),by:U([`you`,`model`,`agent`]),detail:z()}).strict().readonly(),RYe=H({projectId:z().nullable(),revisionId:z().nullable(),state:U(Jx).nullable(),sentence:z().nullable(),quotedHigh:B().nullable(),article:z().nullable(),outputs:V(H({section:U(Kx),role:z(),url:z(),name:z()}).strict().readonly()).readonly(),versions:V(H({version:B().int().positive(),state:U(Jx),updatedAt:z()}).strict().readonly()).readonly()}).strict().readonly(),zYe=H({template:txe,gate:U([...ale,`unchecked`]),runnableVersion:B().int().positive().nullable(),gated:$p(),checkedVersion:B().int().positive().nullable(),sample:H({topic:z(),topicSource:U([`fixed`,`queued`]),fullScript:$p()}).strict().readonly(),sections:V(PYe).readonly(),free:FYe,schedule:IYe,reviews:V(LYe).readonly(),paid:RYe}).strict().readonly(),BYe=H({version:B().int().positive(),checks:V(NYe).readonly()}).strict().readonly(),VYe=H({stage:z(),low:B().nullable(),high:B().nullable(),detail:z(),onPlan:$p().optional(),apiLow:B().nullable().optional(),apiHigh:B().nullable().optional()}).strict().readonly(),HYe=H({version:B().int().positive(),first:$p(),sections:V(U(Kx)).readonly(),rows:V(VYe).readonly(),low:B(),high:B(),unknown:B().int().nonnegative(),onPlan:$p(),usesPlan:$p(),budget:H({budget:B(),spent:B(),unpriced:B().int().nonnegative(),left:B(),plans:$p()}).strict().readonly(),fits:$p(),problem:z().nullable()}).strict().readonly(),UYe=H({section:U(Kx),items:V(H({key:z(),label:z()}).strict().readonly()).readonly(),item:z().nullable(),segments:V(H({origin:U([`yours`,`keyword`,`slopify`,`setting`]),text:z(),name:z().optional(),unfilled:cm(!0).optional()}).strict().readonly()).readonly(),fromSample:$p(),problem:z().nullable()}).strict().readonly(),WYe=H({cards:V(H({id:z(),still:z().nullable(),format:U([`16:9`,`9:16`,`1:1`]),video:$p(),words:B().int().nonnegative().nullable(),voice:H({provider:z(),voiceId:z(),name:z()}).strict().nullable(),captions:U([`off`,`burn-in`,`files`]),shorts:B().int().nonnegative(),pdf:$p(),asks:V(z()),schedules:B().int().nonnegative()}).strict())}).strict(),b9=e=>[`template-studio`,e];function GYe(e){return{queryKey:[`project-templates`,`cards`],queryFn:async()=>{let t=await e.fetch(`${e.origin}/api/template-studio/cards`);if(!t.ok)throw await vm(t);return Tm(WYe,await t.json()).cards}}}var KYe=class extends Error{};async function qYe(e,t){let n=await e.fetch(`${e.origin}/api/template-studio/${encodeURIComponent(t)}`);if(n.status===404)throw new KYe((await vm(n)).message);if(!n.ok)throw await vm(n);return Tm(zYe,await n.json())}function JYe(e,t){return{queryKey:b9(t),queryFn:()=>qYe(e,t),retry:(e,t)=>!(t instanceof KYe)&&e<3}}function x9(e,t){return{queryKey:[...b9(t),`checks`],queryFn:async()=>{let n=await e.fetch(`${e.origin}/api/template-studio/${encodeURIComponent(t)}/checks`);if(!n.ok)throw await vm(n);return Tm(BYe,await n.json())}}}async function YYe(e,t){let n=await e.fetch(`${e.origin}/api/template-studio/${encodeURIComponent(t)}/free-samples`,{method:`POST`});if(!n.ok)throw await vm(n)}var S9={statuses:[400,409]};function C9(e,t,n){let r=H({[t]:n}).loose().safeParse(e);return r.success?r.data[t]:void 0}async function w9(e,t){let n=await Em(e);if(e.ok)return{ok:!0,value:Tm(t,n)};let r=Dm(e,n,S9);return{ok:!1,reason:r.reason??`conflict`,message:r.message,quote:C9(n,`quote`,HYe)??null}}var T9=(e,t)=>`${e.origin}/api/template-studio/${encodeURIComponent(t)}`,E9=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)});async function D9(e,t,n){let r=await e.fetch(`${T9(e,t)}/quote`,E9(`POST`,n));if(!r.ok)throw await vm(r);return Tm(HYe,await r.json())}var XYe=H({template:H({version:B()}).loose(),sample:U([`queued`,`skipped`]),replayed:$p()}).loose();function ZYe(e,t,n){return e.fetch(`${T9(e,t)}/save`,E9(`POST`,n)).then(e=>w9(e,XYe))}function QYe(e,t,n){return e.fetch(`${T9(e,t)}/samples/make`,E9(`POST`,n)).then(e=>w9(e,H({queued:cm(!0)}).loose()))}var $Ye=H({topic:z(),topicSource:U([`fixed`,`queued`]),fullScript:$p()}).loose();function eXe(e,t,n){return e.fetch(`${T9(e,t)}/topic`,E9(`PUT`,n)).then(e=>w9(e,$Ye))}function tXe(e,t,n){return e.fetch(`${T9(e,t)}/full-script`,E9(`POST`,n)).then(e=>w9(e,$Ye))}function nXe(e,t,n,r,i){return{queryKey:[...b9(t),`anatomy`,n,r??``,i],queryFn:async()=>{let i=new URLSearchParams({section:n,...r===void 0?{}:{item:r}}),a=await e.fetch(`${T9(e,t)}/anatomy?${i.toString()}`);if(!a.ok)throw await vm(a);return Tm(UYe,await a.json())}}}var rXe=H({dailyBudget:B(),samplesUsePlans:$p(),today:H({budget:B(),spent:B(),unpriced:B().default(0),left:B(),plans:$p()}),designDailyBudget:B().default(1),designToday:H({budget:B(),spent:B(),left:B()}).optional()}).loose(),iXe=[`template-studio`,`settings`];async function aXe(e){let t=await e.fetch(`${e.origin}/api/template-studio/settings`);if(!t.ok)throw await vm(t);return Tm(rXe,await t.json())}async function oXe(e,t){let n=await e.fetch(`${e.origin}/api/template-studio/settings`,E9(`PUT`,t));if(!n.ok)throw await vm(n);return Tm(rXe,await n.json())}function O9(e){return`about ${nE(e)}`}var sXe=H({items:V(H({templateId:z(),name:z(),version:B(),high:B(),unknown:B(),fits:$p(),problem:z().nullable()}).loose()),total:B(),fitting:B(),sentence:z()}).loose(),cXe=[`template-studio`,`samples-for-all`];async function lXe(e){let t=await e.fetch(`${e.origin}/api/template-studio/samples-for-all/quote`,{method:`POST`});if(!t.ok)throw await vm(t);return Tm(sXe,await t.json())}async function uXe(e,t){let n=await e.fetch(`${e.origin}/api/template-studio/samples-for-all`,E9(`POST`,t)),r=await Em(n);if(n.ok){let e=Tm(H({queued:V(z()),held:V(z())}).loose(),r);return{ok:!0,queued:e.queued.length,held:e.held.length}}return{ok:!1,message:Dm(n,r,S9).message,quote:C9(r,`quote`,sXe)??null}}var dXe=H({label:z(),sentence:z(),fix:H({label:z(),href:z()}).optional(),section:z().optional()}).loose();async function fXe(e,t,n){let r=await e.fetch(`${T9(e,t)}/ready`,E9(`POST`,{version:n}));if(r.ok)return{ok:!0};let i=await Em(r);return{ok:!1,message:Dm(r,i,S9).message,problems:C9(i,`problems`,V(dXe))??[]}}var pXe=H({names:V(H({term:z(),ipa:V(z()),line:z().nullable(),spokenAs:z().nullable()}).loose()),aliasesOn:$p(),voice:H({provider:z(),model:z(),voice:z()}).nullable(),problem:z().nullable()}).loose();function mXe(e,t,n){return{queryKey:[...b9(t),`pronunciations`,n??``],queryFn:async()=>{let n=await e.fetch(`${T9(e,t)}/pronunciations`);if(!n.ok)throw await vm(n);return Tm(pXe,await n.json())}}}var hXe=H({lines:B(),high:B(),unknown:B(),fits:$p(),problem:z().nullable()}).loose();async function gXe(e,t,n){let r=await e.fetch(`${T9(e,t)}/say-it-as/quote`,E9(`POST`,n));if(!r.ok)throw await vm(r);return Tm(hXe,await r.json())}function _Xe(e,t,n){return e.fetch(`${T9(e,t)}/say-it-as`,E9(`POST`,n)).then(e=>w9(e,H({queued:$p()}).loose()))}async function vXe(e,t){let n=await e.fetch(`${T9(e,t)}/pack`);return n.ok?{ok:!0,filename:/filename="([^"]+)"/.exec(n.headers.get(`content-disposition`)??``)?.[1]??`template.slopify-template.zip`,blob:await n.blob()}:{ok:!1,message:Dm(n,await Em(n),S9).message}}var yXe=H({templateId:z(),name:z(),added:B(),renamed:V(H({from:z(),to:z()}).loose()),voiceKnown:$p(),samples:B()}).loose();async function bXe(e,t){let n=new FormData;n.set(`file`,t);let r=await e.fetch(`${e.origin}/api/template-studio/packs/import`,{method:`POST`,body:n}),i=await Em(r);return r.ok?{ok:!0,value:Tm(yXe,i)}:{ok:!1,message:Dm(r,i,{statuses:[400,409,413]}).message}}var xXe=H({samples:V(H({role:U([`thumbnail`,`picture`,`narration`]),name:z(),url:z()}).loose())}).loose();function SXe(e,t){return{queryKey:[...b9(t),`pack-samples`],queryFn:async()=>{let n=await e.fetch(`${T9(e,t)}/pack-samples`);if(!n.ok)throw await vm(n);return Tm(xXe,await n.json())}}}var CXe=H({version:B(),section:U([`script`,`voice`,`pictures`]),current:H({provider:z(),model:z()}).loose(),models:V(H({provider:z(),model:z(),high:B(),unknown:B(),onPlan:$p(),problem:z().nullable()}).loose()),high:B(),unknown:B(),usesPlan:$p().optional(),budget:H({budget:B(),spent:B(),left:B(),plans:$p().optional()}).loose(),fits:$p(),problem:z().nullable()}).loose(),wXe=H({provider:z(),model:z(),slot:B().nullable(),state:U([`current`,`queued`,`making`,`done`,`failed`]),quotedHigh:B().nullable(),cost:B().nullable(),seconds:B().nullable(),failure:z().nullable(),outputs:V(H({role:z(),url:z(),name:z()}).loose()),article:z().nullable()}).loose(),TXe=H({bakeoff:H({id:z(),section:U([`script`,`voice`,`pictures`]),version:B(),stale:$p(),state:U([`queued`,`making`,`done`,`held`,`failed`]),sentence:z().nullable(),entries:V(wXe)}).loose().nullable()}).loose();function EXe(e,t){return{queryKey:[...b9(t),`bakeoff`],queryFn:async()=>{let n=await e.fetch(`${T9(e,t)}/bakeoff`);if(!n.ok)throw await vm(n);return Tm(TXe,await n.json())},refetchInterval:e=>{let t=e.state.data?.bakeoff?.state;return t===`queued`||t===`making`?5e3:!1}}}async function DXe(e,t,n){return w9(await e.fetch(`${T9(e,t)}/bakeoff/quote`,E9(`POST`,n)),CXe)}async function OXe(e,t,n){let r=await e.fetch(`${T9(e,t)}/bakeoff`,E9(`POST`,n)),i=await Em(r);return r.ok?{ok:!0}:{ok:!1,message:Dm(r,i,S9).message,quote:C9(i,`quote`,CXe)??null}}async function kXe(e,t){let n=await e.fetch(`${T9(e,t)}/bakeoff`,{method:`DELETE`}),r=await Em(n);return n.ok?{ok:!0}:{ok:!1,message:Dm(n,r,S9).message}}var AXe=`Let samples use my Claude Code or Codex plan`;function jXe(e){return e.usesPlan===!0&&e.budget.plans!==!0}function MXe(e){return jXe(e)?`Samples may not use your Claude Code or Codex plan`:`Today's sample budget can't cover it`}function NXe(e,t){return jXe(e)?`${t} runs on your Claude Code or Codex plan, and samples may not use it. Turn on ${AXe} in `:`${t} costs about ${nE(e.high)} and ${nE(e.budget.left)} of today's ${nE(e.budget.budget)} sample budget is left. Raise it in `}function PXe(){return(0,h.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,h.jsx)(FXe,{}),(0,h.jsx)(LXe,{})]})}function FXe(){let{api:e}=q(),t=_(),n=I({queryKey:iXe,queryFn:()=>aXe(e)}),r=L({mutationFn:t=>oXe(e,t),onSuccess:e=>t.setQueryData(iXe,e)});if(n.error)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:`The template samples' settings didn't load: ${n.error.message} Reload the page to try again.`});let i=n.data;if(i===void 0)return(0,h.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`h-20 rounded-control bg-raised`});let a=i.today.unpriced>0?` plus ${String(i.today.unpriced)} ${i.today.unpriced===1?`call`:`calls`} with no known price`:``,o=r.variables;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(IXe,{label:`Video templates: daily budget`,saveLabel:`Save video budget`,help:`The most video template samples may spend in one day, in US dollars; one over it waits for tomorrow or a higher budget. Spent today: ${nE(i.today.spent)}${a}; left: ${nE(i.today.left)}.`,stored:i.dailyBudget,pending:r.isPending,error:r.error&&o?.dailyBudget!==void 0?`The budget wasn't saved: ${r.error.message}`:void 0,onSave:(e,t)=>r.mutate({dailyBudget:e},{onSuccess:t})}),(0,h.jsx)(IXe,{label:`Poster templates: daily budget`,saveLabel:`Save poster budget`,help:`The most poster template samples may spend in one day, in US dollars; one over it waits for tomorrow or a higher budget.${i.designToday===void 0?``:` Spent today: ${nE(i.designToday.spent)}; left: ${nE(i.designToday.left)}.`}`,stored:i.designDailyBudget,pending:r.isPending,error:r.error&&o?.designDailyBudget!==void 0?`The poster budget wasn't saved: ${r.error.message}`:void 0,onSave:(e,t)=>r.mutate({designDailyBudget:e},{onSuccess:t})}),(0,h.jsx)(dD,{label:AXe,help:i.samplesUsePlans?`On: samples, poster samples included, may run steps on your plan. That usage has no dollar price, so the budgets above don't limit it.`:`Off: a sample that needs your plan, poster samples included, waits until you turn this on.`,checked:i.samplesUsePlans,disabled:r.isPending,onChange:e=>r.mutate({dailyBudget:i.dailyBudget,samplesUsePlans:e})})]})}function IXe(e){let[t,n]=(0,m.useState)(),r=t??e.stored.toFixed(2),i=Number(r.trim()),a=r.trim()===``||!Number.isFinite(i)||i<0||i>1e3?`Enter an amount between $0.00 and $1,000.00.`:void 0;return(0,h.jsx)(J,{label:e.label,help:e.help,error:a??e.error,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`$`}),(0,h.jsx)(Y,{type:`number`,inputMode:`decimal`,min:0,max:1e3,step:.5,className:`w-[112px] tabular-nums`,value:r,"aria-invalid":a!==void 0,onChange:e=>n(e.target.value)}),(0,h.jsx)(K,{variant:`primary`,disabled:a!==void 0||e.pending||t===void 0,disabledReason:e.pending?`Saving`:t===void 0?`Nothing changed`:a??``,onClick:()=>e.onSave(i,()=>n(void 0)),children:e.saveLabel})]})})}function LXe(){let{api:e}=q(),t=_(),n=I({queryKey:cXe,queryFn:()=>lXe(e),staleTime:6e4}),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(),s=L({mutationFn:t=>uXe(e,{acknowledgedTotal:t,acknowledgedUnknown:r}),onSuccess:async e=>{e.ok?o({error:!1,text:`Queued ${String(e.queued)} ${e.queued===1?`sample`:`samples`}${e.held>0?`; ${String(e.held)} wait, as each template's Edit template page says`:``}. They are made one at a time in the background.`}):(o({error:!0,text:e.message}),e.quote!==null&&t.setQueryData(cXe,e.quote)),e.ok&&await t.invalidateQueries({queryKey:[`template-studio`]})},onError:e=>o({error:!0,text:`The samples weren't asked for: ${e.message} Press Make samples for all again.`})});if(n.error)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:`The samples for all couldn't be priced: ${n.error.message} Reload the page to try again.`});let c=n.data,l=c?.items.some(e=>e.unknown>0&&e.fits)??!1,u=c?.items.filter(e=>e.problem===null).length??0,d=c!==void 0&&c.fitting===0?`No sample fits today's budget or plan setting: change them above, or press this tomorrow`:s.isPending?`Asking for the samples`:void 0;return(0,h.jsxs)(`section`,{"aria-label":`Samples for all templates`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-body font-medium text-ink`,children:`Samples for all templates`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:c===void 0?`Pricing the sample of every template…`:c.sentence}),l?(0,h.jsxs)(`label`,{className:`flex items-center gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),`Accept steps with no known price`]}):null,c===void 0||u===0?null:(0,h.jsx)(`div`,{children:(0,h.jsx)(K,{variant:`secondary`,disabled:d!==void 0,disabledReason:d,focusableWhenDisabled:!0,onClick:()=>s.mutate(c.total),children:`Make samples for all · ${O9(c.total)}`})}),a===void 0?null:(0,h.jsx)(`p`,{role:a.error?`alert`:`status`,className:a.error?`m-0 text-small text-danger`:`m-0 text-small text-ink-2`,children:a.text})]})}var RXe={project:`Project`,prompt:`Prompt`,entry:`Intro/outro`,template:`Template`,schedule:`Schedule`,design:`Design`,"design-template":`Poster template`},zXe=[{value:`project`,label:`Projects`},{value:`prompt`,label:`Prompts`},{value:`entry`,label:`Intros and outros`},{value:`template`,label:`Templates`},{value:`schedule`,label:`Schedules`},{value:`design`,label:`Designs`},{value:`design-template`,label:`Poster templates`}],BXe=`Deleted projects, prompts, intros and outros, templates, schedules and designs stay here for 30 days.`,VXe=`Channels, cast members, PDF looks and episode summaries are deleted permanently and never come here.`;function HXe(e){return e.kind===`entry`&&e.detail!==null?e.detail===`intro`?`Intro`:`Outro`:e.kind===`prompt`&&e.detail!==null?`Prompt · ${e.detail}`:RXe[e.kind]}function UXe(e){return e<=0?`removed for good today`:e===1?`1 day left`:`${String(e)} days left`}var WXe=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),GXe=new Intl.DateTimeFormat(void 0,{dateStyle:`full`,timeStyle:`long`});function KXe(e){let t=new Date(e.deletedAt);return{short:WXe.format(t),full:`Deleted ${GXe.format(t)}. Removed for good ${GXe.format(new Date(e.purgeAt))}.`}}function k9(e){return`${e.kind}:${e.id}`}var qXe={project:[X.projects,X.calendar],prompt:[X.prompts],entry:[X.entries],template:[PM],schedule:[BO,X.calendar],design:[X.designs],"design-template":[X.designTemplates]};function JXe(e){let t=e.filter(e=>e.kind===`project`).length,n=e.some(e=>e.kind===`schedule`);return[t===0?void 0:t===1&&e.length===1?`The project and every file it produced are removed from disk.`:`${String(t)} ${t===1?`project and every file it`:`projects and every file they`} produced are removed from disk.`,n?`Deleted schedules keep their run history on Schedules.`:void 0,`Nothing removed here can be restored. This cannot be undone.`].filter(e=>e!==void 0).join(` `)}function YXe(e,t,n,r){let i=t[0];if(i===void 0)return``;let a=r.find(e=>e.kind===i.kind&&e.id===i.id)?.name;return`Could not ${e} ${String(t.length)} of ${oE(n,`item`,`items`)}. ${a===void 0?``:`"${a}": `}${i.detail}`}function XXe(){let{api:e}=q(),t=_(),n=Vx(),r=async e=>{let n=new Map([[xQ.join(`/`),xQ]]);for(let t of e)for(let e of qXe[t.kind])n.set(e.join(`/`),e);await Promise.all([...n.values()].map(e=>t.invalidateQueries({queryKey:e})))};return{restore:L({mutationFn:async t=>{let[n]=t;return t.length===1&&n!==void 0?{restored:[await CQ(e,n.kind,n.id)],failed:[]}:wQ(e,t)},onSuccess:async({restored:e,failed:t},i)=>{await r(i);let[a]=e;if(e.length===1&&a!==void 0)n(a.renamedFrom===null?`Restored "${a.name}".`:`Restored as "${a.name}": another item is now called "${a.renamedFrom}".`,`success`);else if(e.length>1){let t=e.filter(e=>e.renamedFrom!==null).length;n(`Restored ${oE(e.length,`item`,`items`)}.${t===0?``:` ${oE(t,`came`,`came`)} back renamed because the name was taken.`}`,`success`)}e.some(e=>e.kind===`schedule`)&&n(e.filter(e=>e.kind===`schedule`).length===1?`The schedule is paused. Press Resume on Schedules to run it again.`:`The schedules are paused. Press Resume on Schedules to run each again.`,`info`),t.length>0&&n(YXe(`restore`,t,i.length,i),`error`)},onError:async(e,t)=>{n(e.message,`error`),await r(t)}}),remove:L({mutationFn:async t=>{let[n]=t;return t.length===1&&n!==void 0?(await gNe(e,n.kind,n.id),{deleted:[n],failed:[]}):_Ne(e,t)},onSuccess:async({deleted:e,failed:t},i)=>{await r(i);let[a]=i;i.length===1&&a!==void 0&&t.length===0?n(`Deleted "${a.name}" for good.`,`success`):e.length>0&&n(`Deleted ${oE(e.length,`item`,`items`)} for good.`,`success`),t.length>0&&n(YXe(`delete`,t,i.length,i),`error`)},onError:async(e,t)=>{n(e.message,`error`),await r(t)}})}}function ZXe(){let{api:e}=q(),t=I({queryKey:xQ,queryFn:()=>SQ(e)}),{restore:n,remove:r}=XXe(),[i,a]=(0,m.useState)(`all`),[o,s]=(0,m.useState)(void 0),c=t.data??[],l=zXe.filter(e=>c.some(t=>t.kind===e.value)),u=l.some(e=>e.value===i)?i:`all`,d=(0,m.useMemo)(()=>u===`all`?c:c.filter(e=>e.kind===u),[c,u]),f=sQ((0,m.useMemo)(()=>d.map(k9),[d])),p=d.filter(e=>f.has(k9(e))),g=n.isPending||r.isPending,_=(e,t,n)=>s({title:e,label:t,items:n}),v=()=>{o!==void 0&&r.mutate(o.items,{onSettled:()=>{s(void 0),f.clear()}})};return(0,h.jsxs)(`div`,{children:[c.length===0?null:(0,h.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,h.jsx)(`p`,{className:`m-0 min-w-0 flex-1 text-small text-ink-2`,children:`${BXe} ${VXe}`}),(0,h.jsxs)(zx,{children:[(0,h.jsx)(K,{size:`small`,disabled:g,disabledReason:`Working on it`,onClick:()=>n.mutate(c,{onSuccess:f.clear}),children:`Restore all`}),(0,h.jsx)(K,{size:`small`,variant:`destructive`,disabled:g,disabledReason:`Working on it`,onClick:()=>_(`Empty the trash: delete all ${oE(c.length,`item`,`items`)} for good?`,`Empty trash`,c),children:`Empty trash`})]})]}),t.isPending?(0,h.jsx)(`p`,{className:`text-small text-ink-3`,children:`Loading the trash…`}):t.error?(0,h.jsx)(dE,{what:`The trash`,error:t.error,onRetry:()=>void t.refetch(),retrying:t.isFetching,compact:!0}):c.length===0?(0,h.jsxs)(ZR,{title:`The trash is empty`,children:[BXe,` `,VXe]}):(0,h.jsxs)(`div`,{onKeyDown:f.onKeyDown,children:[l.length>1?(0,h.jsx)(fD,{label:`Filter by kind`,value:u,onChange:a,options:[{value:`all`,label:`All`},...l],className:`mb-2`}):null,(0,h.jsx)(uQ,{selection:f,total:d.length,noun:[`item`,`items`],...u===`all`?{}:{scope:`Select all ${String(d.length)} shown`},actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(K,{size:`small`,disabled:g||f.count===0,disabledReason:f.count===0?`Nothing is selected`:`Working on it`,onClick:()=>n.mutate(p,{onSuccess:f.clear}),children:`Restore selected`}),(0,h.jsx)(K,{size:`small`,variant:`destructive`,disabled:g||f.count===0,disabledReason:f.count===0?`Nothing is selected`:`Working on it`,onClick:()=>_(`Delete ${oE(p.length,`selected item`,`selected items`)} for good?`,`Delete for good`,p),children:`Delete selected`})]})}),(0,h.jsx)(BL,{label:`Deleted items`,children:d.map(e=>{let t=KXe(e);return(0,h.jsx)(VL,{lead:(0,h.jsx)(lQ,{selection:f,value:k9(e),label:e.name}),title:e.name,meta:(0,h.jsxs)(h.Fragment,{children:[HXe(e),` · deleted`,` `,(0,h.jsx)(`time`,{dateTime:e.deletedAt,title:t.full,children:t.short}),` `,`· `,UXe(e.daysLeft)]}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(K,{size:`small`,disabled:g,disabledReason:`Working on it`,onClick:()=>n.mutate([e]),children:`Restore`}),(0,h.jsx)(K,{size:`small`,variant:`destructive`,disabled:g,disabledReason:`Working on it`,onClick:()=>_(`Delete "${e.name}" for good?`,`Delete for good`,[e]),children:`Delete now`})]})},k9(e))})})]}),(0,h.jsx)(ME,{open:o!==void 0,title:o?.title??``,consequence:o===void 0?``:JXe(o.items),confirmLabel:o?.label??`Delete for good`,cancelLabel:o?.items.length===1?`Keep it`:`Keep them`,pending:r.isPending,onConfirm:v,onCancel:()=>{r.isPending||s(void 0)}})]})}var QXe=`https://slopify.stream/channel.html`;function $Xe(e){let t=document.createElement(`a`);t.href=`${e}/api/diagnostics`,t.download=`slopify-diagnostics.json`,document.body.append(t),t.click(),t.remove()}function eZe({onWhatsNew:e}){let{api:t,version:n}=q(),r=JI(()=>window.location.reload()),i=r.info,a=i?.currentVersion??n.loadedAt(),o=i?.status===`waiting`,s=r.updating||r.installing,c=o?void 0:i?.blockedReason,l=s?{tone:`running`,word:`Updating…`}:r.checking?{tone:`running`,word:`Checking for updates…`}:i===void 0?void 0:i.available?{tone:`info`,word:`Version ${i.latestVersion??``} is ready`}:{tone:`done`,word:`Up to date`};return(0,h.jsxs)(`div`,{className:`flex max-w-prose flex-col gap-6`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,h.jsx)(`p`,{className:`m-0 text-title-3 font-semibold text-ink`,children:a===void 0?`Slopify`:`Slopify ${a}`}),l===void 0?null:(0,h.jsx)(hE,{tone:l.tone,children:l.word})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i?.available===!0&&i.canUpdate&&!o?(0,h.jsx)(K,{variant:`primary`,disabled:s||c!==void 0,disabledReason:c,onClick:()=>r.install(),children:`Update to ${i.latestVersion??`the new version`}`}):o?(0,h.jsx)(K,{onClick:()=>r.cancel(),children:`Cancel the update`}):(0,h.jsx)(K,{disabled:s||r.checking,onClick:()=>r.refresh(),children:`Check for updates`}),e===void 0?null:(0,h.jsx)(K,{onClick:e,children:`Read what's new`})]}),r.error===void 0&&c===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-waiting`,children:r.error??c}),o?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`The update installs once the video being made finishes; Slopify then restarts and this page reconnects.`}):null]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`p`,{className:`m-0 font-semibold text-ink`,children:`Free. Your keys, your machine.`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Made by Gent Bajko. Apache License 2.0: anyone who redistributes Slopify or builds on it keeps this credit.`}),(0,h.jsx)(`p`,{className:`m-0 text-small`,children:(0,h.jsx)(`a`,{href:QXe,target:`_blank`,rel:`noreferrer`,className:`sl-link`,children:`How I run a channel with it ↗`})})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Something wrong?`,size:`small`,className:`pb-2`,children:(0,h.jsxs)(tE,{variant:`secondary`,href:`${t.origin}/api/diagnostics`,download:`slopify-diagnostics.json`,children:[(0,h.jsx)(vh,{"aria-hidden":`true`,strokeWidth:1.75}),`Download diagnostics`]})}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:BT(`settings.diagnostics`).body})]})]})}var A9=[`backups`],j9=1,M9=30;function N9(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function tZe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=j9&&Number(t)<=M9?void 0:`Keep between ${j9} and ${M9} backups.`}function nZe(e){return{enabled:e.config.enabled,time:e.config.time,keep:String(e.config.keep),folder:e.config.folder??``}}function rZe(){let{api:e}=q(),t=_(),n=Vx();return L({mutationFn:()=>ite(e),onSuccess:e=>{t.setQueryData(A9,e),n(`Backup started. Its result shows here when it finishes.`,`success`)}})}function iZe(){let{api:e}=q(),t=_(),n=I({queryKey:A9,queryFn:()=>rte(e),refetchInterval:e=>e.state.data?.running===!0&&2e3}),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=L({mutationFn:t=>km(e,t),onSuccess:e=>{t.setQueryData(A9,e),i(void 0),o(!0)}}),c=L({mutationFn:t=>km(e,t),onSuccess:e=>{t.setQueryData(A9,e),i(t=>t===void 0?void 0:{...t,enabled:e.config.enabled})}}),l=rZe();(0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),oB);return()=>clearTimeout(e)},[a]);let u=n.data,d=r??(u===void 0?void 0:nZe(u)),f=d===void 0?void 0:tZe(d.keep),p=r!==void 0&&u!==void 0&&!aZe(r,nZe(u)),g=()=>{d===void 0||f!==void 0||s.isPending||(o(!1),s.mutate({enabled:d.enabled,time:d.time,timeZone:N9(),keep:Number(d.keep.trim()),folder:d.folder.trim()===``?null:d.folder.trim()}))},v=e=>{d!==void 0&&i({...d,...e})},y=c.isPending?c.variables.enabled:u?.config.enabled===!0;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Daily backup`,meta:u===void 0?(0,h.jsx)(`span`,{className:`inline-block h-4 w-48 rounded-control bg-raised`}):(0,h.jsx)(`span`,{role:`status`,children:`${oZe(u)} ${sZe(u)}`.trim()}),children:(0,h.jsx)(K,{disabled:u===void 0||u.running||l.isPending,onClick:()=>l.mutate(),children:`Back up now`})}),(0,h.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3`,children:[u?.status.detail?u.status.lastResult===`failed`?(0,h.jsx)(IT,{tone:`danger`,title:`Why the last backup stopped`,children:u.status.detail}):(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:u.status.detail}):null,l.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:l.error.message}):null]}),n.error?(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The backup settings couldn't be read: `,n.error.message]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(dD,{label:`Back up automatically`,help:`Each backup holds every project with its videos, so it can be many gigabytes.`,checked:y,disabled:u===void 0||c.isPending,className:`self-start`,onChange:e=>{u!==void 0&&c.mutate({enabled:e,time:u.config.time,timeZone:N9(),keep:u.config.keep,folder:u.config.folder})}}),c.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The switch wasn't saved: ${c.error.message} Press it again.`}),y?(0,h.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(J,{label:`Time of day`,help:`${N9()} time. A backup waits while videos are being made.`,children:(0,h.jsx)(Y,{type:`time`,className:`w-[140px] tabular-nums`,value:d?.time??`03:00`,disabled:d===void 0,onChange:e=>v({time:e.target.value})})}),(0,h.jsx)(J,{label:`Keep last`,help:`The oldest backups beyond this number are deleted.`,error:f,children:(0,h.jsx)(Y,{type:`number`,inputMode:`numeric`,min:j9,max:M9,step:1,className:`w-[88px] tabular-nums`,value:d?.keep??`5`,disabled:d===void 0,onChange:e=>v({keep:e.target.value})})}),(0,h.jsx)(J,{label:`Folder`,className:`md:col-span-2`,...u===void 0?{}:{help:cZe(u)},children:(0,h.jsx)(Y,{value:d?.folder??``,placeholder:`Default folder`,disabled:d===void 0,onChange:e=>v({folder:e.target.value})})})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(K,{type:`submit`,variant:`primary`,disabled:!p||f!==void 0||s.isPending,disabledReason:f===void 0?`Nothing changed since the last save.`:f,children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(cB,{}):null}),(0,h.jsx)(KJ,{dirty:p,onDiscard:()=>{s.reset(),i(void 0)}}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 basis-full text-small text-danger`,children:s.error.message})]})]}):null]})]})}function aZe(e,t){return e.enabled===t.enabled&&e.time===t.time&&e.keep.trim()===t.keep.trim()&&e.folder.trim()===t.folder.trim()}function P9(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function oZe(e){if(e.running)return`Backing up now…`;let{status:t}=e,n=t.lastSuccessAt===null?`No backup yet.`:`Last backup ${P9(t.lastSuccessAt)}${t.lastSuccessBytes===null?``:`, ${n7(t.lastSuccessBytes)}`}.`;return t.lastResult===`failed`&&t.lastAttemptAt!==null?`${n} The backup at ${P9(t.lastAttemptAt)} failed.`:t.lastResult===`waiting`?`${n} Waiting for projects to finish.`:n}function sZe(e){return e.config.enabled?e.overdue?`Next: shortly.`:e.nextRunAt===null?``:`Next: ${P9(e.nextRunAt)}.`:``}function cZe(e){let t=e.files.length===0?``:`${e.files.length} backup${e.files.length===1?``:`s`} here (${n7(e.files.reduce((e,t)=>e+t.bytes,0))}).`;return e.hostFolder===null?`Inside Slopify's Docker volume, not on your computer. Leave Folder empty to save backups in the Backups folder on your computer. ${t}`.trim():`${e.config.folder===null?`Empty uses the default: `:`On your computer: `}${e.hostFolder}. ${t}`.trim()}var F9=X.storageUsage,lZe=[F9,X.projects,[`project`],X.usage,X.documentThemes,BO,X.playDrafts,X.settings,X.providers,X.voices,X.prompts,X.entries,X.staging,PM,wN,X.providerModels];async function uZe(e){await Promise.all(lZe.map(t=>e.invalidateQueries({queryKey:t})))}var dZe=`The backup wasn't imported. Check it is a file made with Export everything (.tar) or Export backup (.zip), then try again.`;function fZe(){let{api:e}=q(),t=_(),n=I({queryKey:F9,queryFn:()=>ute(e),staleTime:3e4}),r=I({queryKey:IE,queryFn:()=>UE(e)}),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)({phase:`idle`}),[c,l]=(0,m.useState)({phase:`idle`}),[u,d]=(0,m.useState)(null),f=Vx(),[p,g]=(0,m.useState)(null);async function v(){g(null),s({phase:`preparing`});try{let t=await nte(e);if(!t.ready){s({phase:`idle`}),g(t.detail??`The backup can't be made right now. Try again in a moment.`);return}s({phase:`downloading`,bytes:t.bytes??0,projects:t.projects??0});let n=document.createElement(`a`);n.href=`${e.origin}/api/storage/export`,n.download=``,document.body.append(n),n.click(),n.remove()}catch(e){s({phase:`idle`}),g(e instanceof Error?e.message:`The backup couldn't be prepared. Try again in a moment.`)}}async function y(n){let r=n.name.toLowerCase().endsWith(`.zip`)||n.type===`application/zip`;if(n.size===0||r&&n.size>104857600)g(r?`This file is empty or larger than 100 MB. Choose a .zip made with Export backup, or a .tar made with Export everything.`:`This file is empty. Choose the .tar made with Export everything.`);else{a(!0),g(null),d(null),l({phase:`uploading`,sent:0,total:n.size});try{let i=await e.upload(`${e.origin}/api/storage/import`,n,r?`application/zip`:`application/x-tar`,(e,t)=>{l(e>=t?{phase:`importing`}:{phase:`uploading`,sent:e,total:t})}),a=await i.json();if(!i.ok)throw Error(a.detail??dZe);a.projects===void 0?f(`Imported ${a.templates??0} template(s), ${a.fonts??0} uploaded font(s), and ${a.stagedFiles??0} staged file(s).${a.fontFallbacks?` ${a.fontFallbacks} missing legacy font reference(s) now use the default font.`:``}`,`success`):(d(a),f(`Backup imported.`,`success`)),await uZe(t)}catch(e){g(e instanceof Error?e.message:dZe)}finally{l({phase:`idle`}),a(!1)}}}async function b(){a(!0),g(null);try{let n=await e.fetch(`${e.origin}/api/storage/cleanup`,{method:`POST`}),r=await n.json();if(!n.ok)throw Error(`Clear leftover files didn't finish. Try again in a moment.`);f(`Cleared ${r.orphanFiles??0} leftover project file(s) and ${r.stagedFiles??0} unused upload(s).`,`success`),await t.invalidateQueries({queryKey:F9})}catch(e){g(e instanceof Error?e.message:`Clear leftover files didn't finish. Try again in a moment.`)}finally{a(!1)}}ND({id:`settings.export-everything`,title:`Export everything`,group:`Settings`,context:`Backup & storage`,keywords:[`backup`,`download`],run:()=>{!i&&o.phase!==`preparing`&&v()}});let x=i||o.phase===`preparing`,S=(0,m.useRef)(null);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(lD,{title:`Export and import`,meta:`Everything in one .tar file: projects, prompts, templates, schedules and settings.`,children:[(0,h.jsx)(K,{disabled:x,onClick:()=>void v(),children:`Export everything`}),(0,h.jsx)(K,{disabled:x,onClick:()=>S.current?.click(),children:`Import a backup`}),(0,h.jsx)(`input`,{ref:S,className:`sr-only`,type:`file`,tabIndex:-1,"aria-label":`Import a backup`,accept:`.tar,application/x-tar,.zip,application/zip`,disabled:x,onChange:e=>{let t=e.target.files?.[0];t&&y(t),e.target.value=``}}),(0,h.jsx)(K,{variant:`quiet`,disabled:x,onClick:()=>void b(),children:`Clear leftover files`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsxs)(`p`,{className:`m-0`,children:[`Keys are never in a backup: after importing, add them again on`,` `,(0,h.jsx)(eE,{to:`/settings`,search:{section:`providers`},children:`Keys & services`}),`. Importing only adds: it replaces nothing. Clear leftover files removes files no project uses.`]}),o.phase===`preparing`?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink`,children:`Preparing the backup…`}):null,o.phase===`downloading`?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 min-w-0 flex-1 text-ink`,children:[`Downloading `,n7(o.bytes),` (`,o.projects,` project`,o.projects===1?``:`s`,`). Your browser's downloads show its progress; keep Slopify running until it finishes.`]}),(0,h.jsx)(K,{variant:`quiet`,size:`small`,onClick:()=>s({phase:`idle`}),children:`Dismiss`})]}):null,c.phase===`uploading`?(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 text-ink tabular-nums`,children:[`Uploading the backup: `,n7(c.sent),` of `,n7(c.total)]}),(0,h.jsx)(o1,{progress:!0,label:`Backup upload`,value:c.total===0?0:c.sent/c.total})]}):null,c.phase===`importing`?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink`,children:`Checking and importing the backup… large projects can take a minute.`}):null,p?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-danger`,children:p}):null]})]}),u?(0,h.jsx)(gZe,{result:u,onDismiss:()=>d(null)}):null,(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Disk space`,meta:n.data?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`font-semibold text-ink`,children:[n7(n.data.data),` stored`]}),(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[` `,`· `,n7(Math.max(0,n.data.projects-n.data.trash.bytes)),` project files`,n.data.staging>0?` · ${n7(n.data.staging)} of uploads not used yet`:null,n.data.trash.projects>0?` · ${n7(n.data.trash.bytes)} in the trash (${hZe(n.data.trash.projects)}), freed when removed for good`:null]})]}):n.error?`Storage usage is unavailable. Reload the page to try again.`:(0,h.jsx)(`span`,{className:`inline-block h-4 w-48 rounded-control bg-raised`})}),n.data&&n.data.byProject.length>0?(0,h.jsx)(XGe,{projects:n.data.byProject,samples:new Set(Object.values(r.data?.samples??{}).filter(e=>e!==null)),queryKey:[...F9]}):null,(0,h.jsx)(mZe,{})]})]})}var pZe={library:`The Library of Alexandria`,audiobook:`The Wind in the Willows`,podcast:`The Antikythera Mechanism`};function mZe(){let{api:e}=q(),t=_(),n=I({queryKey:IE,queryFn:()=>UE(e)}),r=L({mutationFn:()=>i_e(e),onSettled:async()=>{await t.invalidateQueries({queryKey:IE}),await t.invalidateQueries({queryKey:FE}),await t.invalidateQueries({queryKey:X.projects}),await t.invalidateQueries({queryKey:F9})}}),i=r.data?.samples??n.data?.samples,a=i===void 0?[]:Object.keys(pZe).filter(e=>i[e]===null).map(e=>pZe[e]);return(0,h.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(K,{size:`small`,disabled:r.isPending,onClick:()=>r.mutate(),children:r.isPending?`Restoring…`:`Restore samples`}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:a.length===0?`Puts the three finished examples back as they shipped.`:`Brings back ${a.join(`, `)}, and the others as they shipped.`})]}),(0,h.jsx)(lL,{tone:r.error?`error`:`success`,children:r.error?.message??(r.isSuccess?`The samples are back in Projects.`:void 0)})]})}function hZe(e){return e===1?`1 deleted project`:`${String(e)} deleted projects`}function I9(e,t){if(t===void 0)return null;let n=[t.added>0?`${t.added} added`:null,t.renamed>0?`${t.renamed} added as “(imported)” because the name was taken`:null,t.skipped>0?`${t.skipped} already here`:null].filter(e=>e!==null);return n.length===0?null:`${e}: ${n.join(`, `)}.`}function gZe({result:e,onDismiss:t}){let n=[e.projects.imported.length>0?`Projects: ${e.projects.imported.length} added (${n7(e.files.bytes)} of files).`:`Projects: none added.`,I9(`Prompts`,e.prompts),I9(`Intros and outros`,e.entries),I9(`Channels`,e.channels),I9(`Cast members`,e.cast),I9(`Episode memories`,e.episodeMemories),I9(`Titles to avoid`,e.channelVideos),I9(`PDF looks`,e.documentThemes),I9(`Templates`,e.templates),I9(`Schedules`,e.schedules),e.schedules.paused>0?`${e.schedules.paused} schedule(s) arrived paused so two installs never run them both; resume them in Calendar → Schedules.`:null,I9(`Voices`,e.voices),I9(`Saved drafts`,e.drafts),I9(`Designs`,e.designs),I9(`Poster templates`,e.designTemplates),e.settings.added+e.settings.kept>0?`Settings: ${e.settings.added} filled in${e.settings.kept>0?`, ${e.settings.kept} kept as this install has them`:``}.`:null,e.fonts>0?`Uploaded fonts: ${e.fonts} added.`:null,e.usage.alreadyImported?`Usage: this backup's history was already added before, so it wasn't counted twice.`:`Usage: ${e.usage.events} recorded event(s) added to the totals.`,`Keys are not in backups: add them again in Settings → Keys & services.`].filter(e=>e!==null);return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{as:`h3`,title:`Imported the backup from ${e.backup.createdAt.slice(0,10)}`,children:(0,h.jsx)(K,{variant:`quiet`,size:`small`,onClick:t,children:`Dismiss`})}),(0,h.jsxs)(`ul`,{"aria-label":`Import result`,className:`m-0 list-disc pl-5 text-small text-ink-2`,children:[n.map(e=>(0,h.jsx)(`li`,{className:`py-0.5`,children:(0,h.jsx)(AE,{text:e})},e)),e.projects.skipped.map(e=>(0,h.jsxs)(`li`,{className:`py-0.5`,children:[`Skipped “`,e.title,`”: `,e.reason]},e.id))]})]})}var _Ze=[`storage-files`];function vZe({usageQueryKey:e}){let{api:t}=q(),n=_(),r=Vx(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(),u=I({queryKey:_Ze,queryFn:()=>dte(t),refetchInterval:e=>bZe(e.state.data)?1e3:!1}),d=L({mutationFn:e=>fte(t,e),onMutate:()=>l(void 0),onSuccess:e=>{n.setQueryData(_Ze,e),a(!1)},onError:e=>l(e.message)}),f=L({mutationFn:()=>pte(t),onSuccess:e=>{e.opened||r(`Your files are in ${e.path}.`,`info`)},onError:e=>r(e.message,`error`)}),p=u.data,g=bZe(p),v=p?.move?.phase;if((0,m.useEffect)(()=>{v===`done`&&n.invalidateQueries({queryKey:e})},[v,n,e]),p===void 0)return(0,h.jsx)(`div`,{children:(0,h.jsx)(lD,{title:`Your files`,meta:u.error?`Where your files are is unavailable. Reload the page to try again.`:`Loading…`})});if(p.docker)return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Your files`,meta:p.folder===null?`The Docker project folder isn't set up.`:`Where your projects and exports are kept.`,children:(0,h.jsx)(K,{disabled:p.folder===null||f.isPending,onClick:()=>f.mutate(),children:`Open folder`})}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsx)(yZe,{view:p}),p.dockerCommand===null?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{className:`m-0`,children:[`Slopify runs in Docker, which can't move its own folders. To move your projects to Documents/Slopify, run this on the computer running Docker (or use`,` `,(0,h.jsx)(QT,{children:`--projects-dir <folder>`}),` for another folder):`]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(QT,{className:`min-w-0 break-all`,children:p.dockerCommand}),(0,h.jsx)(K,{variant:`quiet`,size:`small`,onClick:()=>{let e=p.dockerCommand??``;navigator.clipboard.writeText(e).then(()=>r(`Command copied.`,`success`)).catch(()=>r(`Copying failed: this browser doesn't allow it here. Select the command and copy it yourself.`,`error`))},children:`Copy command`})]})]})]})]});let y=v===`failed`||v===`interrupted`;return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(lD,{title:`Your files`,meta:`Where your projects and exports are kept.`,children:[p.inDocuments||p.documentsRoot===null?null:(0,h.jsx)(K,{variant:`secondary`,disabled:g||d.isPending,onClick:()=>d.mutate(`documents`),children:`Move to Documents/Slopify`}),(0,h.jsx)(K,{disabled:f.isPending,onClick:()=>f.mutate(),children:`Open folder`}),(0,h.jsx)(K,{variant:`quiet`,disabled:g||d.isPending,onClick:()=>{a(e=>!e),l(void 0)},children:`Choose another folder`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 text-small text-ink-2`,children:[(0,h.jsx)(yZe,{view:p}),(0,h.jsx)(`p`,{className:`m-0`,children:`Your keys, settings and the database stay in Slopify's own folder. A move copies every file and checks it before switching, and keeps the old folder until you delete it.`}),i?(0,h.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),d.mutate(o)},children:[(0,h.jsx)(J,{label:`New folder`,tip:`settings.files.new-folder`,help:`The full path; it must be empty or new.`,error:c,className:`min-w-0 flex-1 basis-80`,children:(0,h.jsx)(Y,{value:o,placeholder:p.documentsRoot??`/home/you/Videos/Slopify`,onChange:e=>s(e.target.value)})}),(0,h.jsx)(K,{type:`submit`,disabled:o.trim()===``||d.isPending,children:`Move here`})]}):c===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-danger`,children:c}),p.move===null?null:g?(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 text-ink tabular-nums`,children:[p.move.phase===`copying`?`Copying`:`Checking the copy of`,` your files to`,` `,p.move.target,`: `,p.move.files,` of `,p.move.totalFiles,` files (`,n7(p.move.bytes),` of `,n7(p.move.totalBytes),`). Keep Slopify running until it finishes.`]}),(0,h.jsx)(o1,{progress:!0,label:p.move.phase===`copying`?`Files copied`:`Files checked`,value:p.move.totalBytes===0?0:p.move.bytes/p.move.totalBytes})]}):y?(0,h.jsx)(IT,{tone:v===`failed`?`danger`:`waiting`,title:v===`failed`?`Moving your files to ${p.move.target} stopped`:`Moving your files to ${p.move.target} didn't finish`,actions:(0,h.jsx)(K,{disabled:d.isPending,onClick:()=>d.mutate(p.move?.target??``),children:`Continue moving`}),children:p.move.error??`Slopify was stopped before the copy was checked, so it still uses the old folder. Continue moving picks up where it left off.`}):v===`done`&&p.move.oldFolder!==null?(0,h.jsxs)(IT,{tone:`info`,title:`Your files are now in ${p.move.target}`,children:[`Every file was copied and checked. The old folder `,p.move.oldFolder,` still has a copy; once your projects open fine, you can delete it to free the space.`]}):null]})]})}function yZe({view:e}){let t=[[`Projects`,e.projects],[`Exports`,e.exports]].filter(e=>e[1]!==null);return(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:t.map(([e,t])=>(0,h.jsxs)(`div`,{className:`contents`,children:[(0,h.jsx)(`dt`,{className:`text-ink-3`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 break-all`,children:t})]},e))})}function bZe(e){return e?.move?.phase===`copying`||e?.move?.phase===`verifying`}var L9=30,xZe=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}],SZe=[{value:`cpu`,label:`Processor (x264)`},{value:`nvidia`,label:`NVIDIA graphics card (NVENC)`}],CZe=[{value:`thorough`,label:`Thorough`},{value:`fast`,label:`Fast`}],wZe=[{value:`normal`,label:`Normal`},{value:`background`,label:`Background (your other programs come first)`}];function TZe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=L9?void 0:`The silence gap is a whole number of seconds between 0 and ${String(L9)}.`}function EZe(){let{api:e}=q(),t=_();return L({mutationFn:t=>Dte(e,t),onMutate:e=>{let n=t.getQueryData(X.settings);return t.setQueryData(X.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(X.settings,r.previous)},onSuccess:e=>{t.setQueryData(X.settings,e)}})}function DZe(){let{api:e}=q(),t=I(aD(e));return t.error===null?t.data===void 0?{view:(0,h.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,role:`status`,"aria-label":`Loading settings`,children:[(0,h.jsx)(`span`,{className:`h-16 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-16 rounded-control bg-raised`})]})}:{data:t.data}:{view:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:t.error.message})}}function OZe(){let{data:e,view:t}=DZe(),n=EZe(),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1);if((0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),oB);return()=>clearTimeout(e)},[a]),e===void 0)return t??(0,h.jsx)(`span`,{});let s=e,c=r??String(s.silenceGapSeconds),l=TZe(c);return(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(J,{label:`Silence between segments`,help:`Seconds of quiet between the intro, the narration and the outro of new videos; 0 runs them together.`,error:l??n.error?.message,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(Y,{type:`number`,inputMode:`numeric`,min:0,max:L9,step:1,className:`w-[88px] tabular-nums`,value:c,"aria-invalid":l!==void 0,onChange:e=>{i(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`seconds`}),(0,h.jsx)(K,{variant:`primary`,disabled:l!==void 0||n.isPending||Number(c.trim())===s.silenceGapSeconds,disabledReason:l??`Nothing changed since the last save.`,onClick:()=>{o(!1),n.mutate({...s,silenceGapSeconds:Number(c.trim())},{onSuccess:()=>{i(void 0),o(!0)}})},children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(cB,{}):null})]})}),(0,h.jsx)(J,{label:`Caption timing model`,help:`Bigger hears the narration more accurately and, on most computers, is also faster. It downloads once, the first time captions are timed.`,error:n.error&&n.variables?.subtitleModel!==s.subtitleModel?`The caption timing model wasn't saved. ${n.error.message}`:void 0,children:(0,h.jsx)(ZT,{className:`self-start`,value:s.subtitleModel??`fp32`,options:i3,onChange:e=>{let t=i3.find(t=>t.value===e.target.value);t!==void 0&&n.mutate({...s,subtitleModel:t.value})}})}),(0,h.jsx)(`div`,{className:`md:col-span-2`,children:(0,h.jsx)(U4,{value:s.loudness??zk,switchLabel:`Level the volume for new runs`,switchTip:null,switchHelp:`Evens out the narration and sets new videos to the loudness YouTube plays at. A project keeps what it started with.`,onChange:e=>{n.mutate({...s,loudness:e})}})}),(0,h.jsx)(kZe,{current:s,save:n})]})}function kZe({current:e,save:t}){let{api:n}=q(),r=I(u_e(n)),i=e.videoEncoder??`cpu`,a=r.data?.nvidia,o=SZe.filter(e=>e.value===`cpu`||a?.available===!0||i===`nvidia`),s=a===void 0?`Checking for an NVIDIA graphics card…`:a.available?`The graphics card takes most of the work off the processor, for a slightly softer picture than x264.`:i===`nvidia`?`Videos are encoded on the processor until this is fixed. ${a.reason}`:`${a.reason} Videos are encoded on the processor.`,c=a?.available===!1?a.detail:void 0,l=(n,r)=>t.error&&t.variables?.[n]!==e[n]?`The ${r} wasn't saved. ${t.error.message}`:void 0;return(0,h.jsxs)(`div`,{className:`grid gap-4 md:col-span-2`,...GT,children:[(0,h.jsx)(lD,{as:`h3`,title:`Encoding`,meta:`How this computer turns videos and shorts into files. Changing these never marks anything outdated.`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-3`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,h.jsx)(J,{label:`Video encoder`,help:s,error:l(`videoEncoder`,`video encoder`),children:(0,h.jsx)(ZT,{className:`self-start`,value:i,options:o,onChange:n=>{let r=SZe.find(e=>e.value===n.target.value);r!==void 0&&t.mutate({...e,videoEncoder:r.value})}})}),c===void 0?null:(0,h.jsx)(SR,{summary:`Details`,children:(0,h.jsx)(`p`,{className:`m-0 pt-1 font-mono text-small break-words text-ink-2`,children:c})})]}),(0,h.jsx)(J,{label:`Clip encoding`,help:AZe,error:l(`clipEncodeSpeed`,`clip encoding`),children:(0,h.jsx)(ZT,{className:`self-start`,value:e.clipEncodeSpeed??`thorough`,options:CZe,onChange:n=>{let r=CZe.find(e=>e.value===n.target.value);r!==void 0&&t.mutate({...e,clipEncodeSpeed:r.value})}})}),(0,h.jsx)(J,{label:`Encoding priority`,help:`Background lets your other programs run first; a video takes longer to make while they are busy.`,error:l(`renderPriority`,`encoding priority`),children:(0,h.jsx)(ZT,{className:`self-start`,value:e.renderPriority??`background`,options:wZe,onChange:n=>{let r=wZe.find(e=>e.value===n.target.value);r!==void 0&&t.mutate({...e,renderPriority:r.value})}})})]})]})}var AZe=`Fast uses about half the processor time for the clips under burned-in captions, for a slightly softer picture.`;function jZe(){let{data:e,view:t}=DZe(),n=EZe();if(e===void 0)return t??(0,h.jsx)(`span`,{});let r=e;return(0,h.jsxs)(`div`,{className:`sl-field`,children:[(0,h.jsx)(`span`,{className:`sl-field__label`,children:`Appearance`}),(0,h.jsx)(fD,{label:`Appearance`,help:`System follows your computer's light or dark setting. Your videos are not affected.`,value:r.appearance,options:xZe,className:`self-start`,onChange:e=>{n.mutate({...r,appearance:e})}}),n.error?(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The appearance wasn't saved. `,n.error.message]}):null]})}var MZe=[{family:`llm`,label:ZD.article,setUp:`Set up a writing service`,lacking:`No writing service yet, so nothing can write the article, title or description.`},{family:`tts`,label:ZD.audio,setUp:`Set up a voice service`,lacking:`No voice service yet, so videos have no narration.`},{family:`image`,label:ZD.images,setUp:`Set up an image service`,lacking:`No image service yet, so videos have no pictures.`}],NZe=`openai-tts`,PZe={ready:`Ready`,"no-key":`No key`,"no-voice":`No voice saved`};function FZe(e,t,n){let r=e===`llm`?n?.llm:e===`image`?n?.images:void 0;return t.find(e=>e.id===r?.provider)?.displayName}function IZe(e,t){return e.readiness.kind===`local`||e.id===NZe||t.some(t=>t.provider===e.id)}function LZe(e,t,n=[]){return MZe.map(({family:r,label:i,setUp:a,lacking:o})=>{let s=e.filter(e=>e.family===r&&oN(e.readiness)),c=r===`tts`?s.filter(e=>IZe(e,n)):s;if(c.length===0){let e=r===`tts`?s:[],t=e[0];return t===void 0?{family:r,label:i,state:`no-key`,text:o,action:{kind:`set-up`,words:a}}:{family:r,label:i,state:`no-voice`,text:`${e.map(e=>e.displayName).join(`, `)} ${e.length===1?`has`:`have`} a key but no voice saved yet, so videos have no narration.`,action:{kind:`voices`,words:`Save a voice`,provider:t.id}}}let l=FZe(r,c,t);return{family:r,label:i,state:`ready`,text:[...l===void 0?[]:[`${l} (Create picks it)`],...c.map(e=>e.displayName).filter(e=>e!==l)].join(`, `)}})}function RZe({health:e,onShow:t,back:n}){let{api:r}=q(),i=I(QE(r)),a=I($E(r)),o=I(Rxe(r));return i.data===void 0||a.isPending?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(`ul`,{"aria-label":`What your videos have`,className:`sl-list m-0 list-none p-0`,children:LZe(i.data.providers,o.data?.defaults,a.data?.voices??[]).map(e=>(0,h.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1 border-b border-line py-2 md:grid md:grid-cols-[88px_136px_minmax(0,1fr)_auto]`,children:[(0,h.jsx)(`span`,{className:`w-[88px] shrink-0 font-semibold text-ink md:w-auto`,children:e.label}),(0,h.jsx)(hE,{tone:e.state===`ready`?`done`:`waiting`,children:PZe[e.state]}),(0,h.jsx)(`span`,{className:G(`min-w-0 text-small text-ink-2 max-md:hidden`,e.state===`ready`&&`truncate`),title:e.state===`ready`?e.text:void 0,children:e.text}),e.action===void 0?null:e.action.kind===`voices`?(0,h.jsx)($T,{size:`small`,className:`justify-self-start max-md:ml-auto`,to:`/settings`,search:{section:`voices`,provider:e.action.provider,...zR(n)},children:e.action.words}):t===void 0?null:(0,h.jsx)(K,{size:`small`,className:`justify-self-start max-md:ml-auto`,onClick:()=>t(e.family),children:e.action.words})]},e.family))}),e===void 0?null:(0,h.jsx)($qe,{run:e})]})}function zZe(){let{api:e}=q(),t=I(l_e(e));return(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[t.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:t.error.message}),t.data===void 0?t.error===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(qZe,{cells:5}),(0,h.jsx)(JZe,{})]}):null:(0,h.jsx)(HZe,{usage:t.data})]})}var BZe=[{id:`stage`,header:`Part`,cell:e=>ZD[e.stage]},{id:`model`,header:`Service · model`,cell:e=>UZe(e)},{id:`in`,header:`Read`,numeric:!0,cell:e=>iE.format(e.tokensIn)},{id:`out`,header:`Written`,numeric:!0,cell:e=>iE.format(e.tokensOut)}];function VZe(e){return e.machineId===null?`Nothing is counted until you press Start counting · Slopify ${e.appVersion}`:`This computer's random number: ${e.machineId} · Slopify ${e.appVersion}`}function HZe({usage:e}){return Object.values(e.counters).every(e=>e===0)&&e.byStage.length===0?(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(ZR,{title:`Nothing made yet`,actions:(0,h.jsx)($T,{variant:`primary`,to:`/play`,children:`Make your first video`}),children:`After your first video, this page shows what this computer made and how much text the AI read and wrote for it.`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:VZe(e)})]}):(0,h.jsxs)(Z0,{split:`even`,children:[(0,h.jsxs)(Q0,{children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(i1,{children:KZe(e).map(e=>(0,h.jsx)(a1,{label:e.label,value:e.value},e.label))}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`AI text is counted in tokens: pieces of about three quarters of a word.`})]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:VZe(e)})]}),e.byStage.length===0?null:(0,h.jsx)(Q0,{children:(0,h.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,h.jsx)(s1,{caption:`AI text by part of the video`,columns:BZe,rows:e.byStage,rowKey:e=>`${e.stage}/${e.provider}/${e.model??``}`,className:`min-w-[480px] [&_td]:pr-4 [&_th]:pr-4`})})})]})}function UZe(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var WZe=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),GZe=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function KZe(e){let t=e.counters;return[{label:`Videos made`,value:iE.format(t.videosMade)},{label:`Hours of narration`,value:WZe.format(t.audioSeconds/3600)},{label:`Images made`,value:iE.format(t.imagesMade)},{label:`AI text read and written`,value:t.tokensUsed<1e6?iE.format(t.tokensUsed):GZe.format(t.tokensUsed)},{label:`Projects`,value:iE.format(t.projects)}]}function qZe({cells:e}){return(0,h.jsx)(`div`,{className:`sl-stats`,children:Array.from({length:e},(e,t)=>t).map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`h-8 w-20 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-sunken`})]},e))})}function JZe(){return(0,h.jsx)(`div`,{className:`border-t border-line`,children:[0,1,2,3].map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-line py-3`,children:[(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-56 max-w-[40%] rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-20 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-sunken`})]},e))})}function YZe({section:e=`providers`,note:t,family:n,provider:r,back:i,onSection:a=()=>{},onNote:o=()=>{}}){let{api:s}=q(),c=_(),l=Ji(),u=Vx(),d=I(xD(s)),f=d.data!==void 0&&d.data.length<2,p=q7(),g=rZe(),v=OE(e),y=EE.find(e=>e.id===v)??EE[0];return ND({id:`settings.check-providers`,title:`Check every service`,group:`Settings`,keywords:[`health`,`keys`,`signed in`,`providers`],run:()=>{a(`providers`),p.mutate()}}),ND({id:`settings.back-up-now`,title:`Back up now`,group:`Settings`,keywords:[`backup`],run:()=>{a(`storage`),g.mutate(void 0,{onError:e=>{u(`The backup didn't start: ${e.message} Open Settings → Backup & storage to see its state.`,`error`)}})}}),ND({id:`settings.download-diagnostics`,title:`Download diagnostics`,group:`Settings`,keywords:[`support`,`bug report`],run:()=>{$Xe(s.origin)}}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(fL,{crumb:`Settings`,title:y.label,meta:y.meta,actions:i===void 0?void 0:(0,h.jsx)(VR,{back:i,children:`Back to ${RR(i)}`})}),(0,h.jsx)(pL,{sections:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(tz,{label:`Settings pages`,className:`max-md:hidden`,children:EE.map((e,t)=>(0,h.jsxs)(m.Fragment,{children:[(0,h.jsx)(iz,{current:e.id===v,onClick:()=>a(e.id),className:G(XZe,t>0&&EE[t-1]?.run!==e.run&&`mt-3`),children:e.label}),f&&e.id===ZZe?(0,h.jsx)(rz,{to:`/channels`,className:XZe,children:$Ze}):null]},e.id))}),(0,h.jsx)(ZT,{"aria-label":`Settings page`,className:`w-full md:hidden`,value:v,options:EE.flatMap(e=>[{value:e.id,label:e.label},...f&&e.id===ZZe?[{value:QZe,label:$Ze}]:[]]),onChange:e=>{e.target.value===QZe?l({to:`/channels`}):a(OE(e.target.value))}})]}),children:(0,h.jsxs)(`section`,{"aria-label":y.label,className:`flex min-w-0 flex-col gap-4`,children:[v===`providers`?(0,h.jsx)(eQe,{family:n,provider:r,back:i,health:p}):null,v===`voices`?(0,h.jsx)(PJe,{provider:r,back:i}):null,v===`models`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(AIe,{}),(0,h.jsx)(Gqe,{}),(0,h.jsx)(Kqe,{})]}):null,v===`playback`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(OZe,{}),(0,h.jsx)(lD,{title:`PDF look`,meta:`The fonts, colors and page layout of the PDFs Slopify makes.`,children:(0,h.jsx)($T,{to:`/document-themes`,children:`Edit PDF looks`})}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Template samples`,meta:`What a template's samples may spend while you edit it.`}),(0,h.jsx)(PXe,{})]})]}):null,v===`notifications`?(0,h.jsx)(HJe,{}):null,v===`studio`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(nje,{}),(0,h.jsx)(CPe,{})]}):null,v===`storage`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(iZe,{}),(0,h.jsx)(vZe,{usageQueryKey:F9}),(0,h.jsx)(fZe,{})]}):null,v===`trash`?(0,h.jsx)(ZXe,{}):null,v===`general`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(jZe,{}),(0,h.jsx)(h_e,{})]}):null,v===`remote-access`?(0,h.jsx)(MYe,{}):null,v===`agents`?(0,h.jsx)(Hqe,{}):null,v===`about`?(0,h.jsx)(eZe,{onWhatsNew:()=>{c.fetchQuery(NI(s)).then(e=>o(e.current??void 0),e=>{u(`What's new did not open: ${e instanceof Error?e.message:String(e)} Open Settings → What's new to try again.`,`error`)})}}):null,v===`usage`?(0,h.jsx)(zZe,{}):null,v===`patch-notes`?(0,h.jsx)(qJe,{note:t,onNote:o}):null]})})]})}var XZe=`h-auto min-h-9 py-1.5 [&>.truncate]:whitespace-normal`,ZZe=`studio`,QZe=`your-channel`,$Ze=`Your channel ↗`;function eQe({family:e,provider:t,back:n,health:r}){let[i,a]=(0,m.useState)(()=>e===void 0&&t===void 0?void 0:{family:e,provider:t,arrival:!0});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(RZe,{health:r,back:n,onShow:e=>a({family:e,provider:void 0,arrival:!1})}),(0,h.jsx)(CJe,{focus:i,back:n})]})}function tQe({open:e,onClose:t,onInstalled:n}){let{api:r}=q(),i=_(),a=I({queryKey:FE,queryFn:()=>zE(r),enabled:e}),o=L({mutationFn:e=>HE(r,e),onSuccess:()=>n(),onSettled:()=>i.invalidateQueries({queryKey:FE})});return(0,h.jsxs)(LT,{open:e,title:`Add starter templates`,onClose:t,footer:(0,h.jsx)(lL,{tone:o.error||a.error?`error`:`success`,children:o.error?.message??a.error?.message??(o.data===void 0?void 0:o.data.added?`Added: its prompts are in Prompts and its template is in this list.`:`That starter template was already added.`)}),children:[(0,h.jsx)(`p`,{className:`m-0 mb-4 text-small text-ink-2`,children:`Each adds prompts, a suggested voice and a template for one kind of channel. It never replaces a prompt or template of yours.`}),(0,h.jsxs)(BL,{label:`Starter templates`,className:`sl-list--wrap-meta`,children:[(a.data?.packs??[]).map(e=>(0,h.jsx)(VL,{title:e.name,meta:e.summary,actions:e.installed?(0,h.jsx)(hE,{tone:`done`,children:`Added`}):(0,h.jsx)(K,{disabled:o.isPending,onClick:()=>o.mutate(e.id),children:`Add template`})},e.id)),a.data===void 0?(0,h.jsx)(VL,{title:`Loading starter templates…`}):null]})]})}function nQe(e,t){let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),URL.revokeObjectURL(n)}function rQe(e,t){let{api:n}=q(),[r,i]=(0,m.useState)(!1),a=e.runnableVersion,o=a===null||a===e.template.version?`Export as a file (.zip)`:`Export version ${String(a)} as a file (.zip)`,s=r?`making it`:a===null?`approve a version first`:void 0;async function c(){i(!0),t(void 0);try{let r=await vXe(n,e.template.id);r.ok?nQe(r.filename,r.blob):t(r.message)}catch(e){t(`The file wasn't made: ${e instanceof Error?e.message:String(e)} Choose Export as a file again.`)}finally{i(!1)}}return{label:o,blocker:s,save:c}}function iQe(e){let t=e.renamed.length===0?``:` ${e.renamed.map(e=>`"${e.from}" came in as "${e.to}"`).join(`, `)}, because Prompts already has other text under ${e.renamed.length===1?`that name`:`those names`}.`,n=e.voiceKnown?``:` Its voice isn't in your Settings → Voices: its Narration check says what to do.`;return`Imported ${e.name}. Look over its samples, then press Make a video.${t}${n}`}function aQe(){let{api:e}=q(),t=_(),n=Ji(),r=Vx(),i=(0,m.useRef)(null),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(null);async function l(a){o(!0),c(null);try{let i=await bXe(e,a);if(!i.ok){c(i.message);return}await t.invalidateQueries({queryKey:PM}),r(iQe(i.value),`success`),await n({to:`/templates/$templateId`,params:{templateId:i.value.templateId},search:{}})}catch(e){c(`The template wasn't imported: ${e instanceof Error?e.message:String(e)} Choose the file again.`)}finally{o(!1),i.current!==null&&(i.current.value=``)}}return{choose:()=>i.current?.click(),busy:a,problem:s,input:(0,h.jsx)(`input`,{ref:i,type:`file`,accept:`.zip,application/zip`,"aria-hidden":`true`,className:`sr-only`,tabIndex:-1,onChange:e=>{let t=e.target.files?.[0];t!==void 0&&l(t)}})}}function oQe({templateId:e}){let{api:t}=q(),n=I(SXe(t,e)).data?.samples??[];if(n.length===0)return null;let r=e=>`${t.origin}${e}`,i=n.filter(e=>e.role!==`narration`),a=n.find(e=>e.role===`narration`);return(0,h.jsxs)(`section`,{"aria-label":`Samples it came with`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(lD,{title:`Samples it came with`,as:`h3`,size:`small`,meta:`Made by whoever shared it. Your own samples replace these once you make them.`}),i.length===0?null:(0,h.jsx)(dR,{density:`compact`,list:!0,label:`Images it came with`,children:i.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsx)(uR,{src:r(e.url),alt:e.role===`thumbnail`?`The thumbnail it came with`:`An image it came with: ${e.name}`,title:e.role===`thumbnail`?`Thumbnail`:`Image`})},e.url))}),a===void 0?null:(0,h.jsx)(w6,{src:r(a.url),label:`The narration it came with`,compact:!0})]})}var sQe={"16:9":`Landscape 16:9`,"9:16":`Vertical 9:16`,"1:1":`Square 1:1`},cQe={off:`no captions`,"burn-in":`captions on the video`,files:`captions as a file`};function lQe(e,t){return[e.video?sQe[e.format]:`Narration only`,e.voice===null?void 0:`Voice: ${e.voice.name}, ${t(e.voice.provider)}`,e.words===null?void 0:`about ${e.words.toLocaleString(`en-US`)} words`,e.video?cQe[e.captions]:void 0,e.shorts===0?void 0:`${String(e.shorts)} ${e.shorts===1?`short`:`shorts`}`,e.pdf?`a PDF`:void 0].filter(e=>e!==void 0).join(` · `)}async function uQe(e,t,n,r){let i=await rxe(e,t.id,{baseVersion:t.version,mutationId:r,...n});if(!i.ok)throw Error(i.message);return i.value}function dQe({template:e,onClose:t}){let{api:n}=q(),r=_(),i=Array.from({length:e.version},(t,n)=>e.version-n),a=rt({queries:i.map(t=>({queryKey:[...PM,e.id,`version`,t],queryFn:async()=>{let r=await zM(n,e.id,t);if(!r.ok)throw Error(r.message);return r.value},staleTime:1/0}))}),o=a[0]?.data,[s,c]=(0,m.useState)(i[1]??e.version),l=a[i.indexOf(s)]?.data,u=(0,m.useRef)(crypto.randomUUID()),d=Vx(),f=L({mutationFn:t=>uQe(n,e,{name:t.name,document:t.document},u.current),onSuccess:async(n,i)=>{u.current=crypto.randomUUID(),d(`Restored version ${String(i.version)} of ${e.name} as version ${String(n.version)}.`,`success`),await r.invalidateQueries({queryKey:PM}),t()}}),p=a.find(e=>e.error!==null)?.error;return(0,h.jsx)(LT,{open:!0,title:`Versions of ${e.name}`,onClose:t,className:`sm:w-[min(1080px,100vw)]`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[p?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:`A version couldn't be read: ${p.message} Close Versions and open it again.`}):null,(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(lD,{title:`Versions`,as:`h3`,meta:`Restore saves an older one again as a new version, so nothing is lost.`}),(0,h.jsx)(BL,{label:`Versions of ${e.name}`,children:i.map((t,n)=>{let r=a[n]?.data;return(0,h.jsx)(VL,{title:`Version ${String(t)}`,selected:t===s,onSelect:()=>c(t),meta:r===void 0?`Loading…`:(0,h.jsxs)(h.Fragment,{children:[`${r.name} · `,(0,h.jsx)(p0,{iso:r.updatedAt,children:d0(r.updatedAt)})]}),actions:t===e.version?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Current`}):(0,h.jsx)(K,{size:`small`,"aria-label":`Restore version ${String(t)}`,disabled:r===void 0||f.isPending,disabledReason:r===void 0?`Reading the version`:`Restoring`,onClick:()=>{r!==void 0&&f.mutate(r)},children:`Restore`})},t)})}),(0,h.jsx)(lL,{tone:`error`,children:f.error===null?void 0:`The version wasn't restored: ${f.error.message}`})]}),(0,h.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(lD,{title:`Compare with the current version`,as:`h3`}),o===void 0||l===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Loading the versions…`}):l.version===o.version?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.version===1?`This is the only version so far.`:`Pick an older version in the list to compare it.`}):(0,h.jsxs)(h.Fragment,{children:[l.name===o.name?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Renamed from "${l.name}" to "${o.name}".`}),(0,h.jsx)(o0,{before:fQe(l),after:fQe(o),beforeLabel:`Version ${String(l.version)}`,afterLabel:`Version ${String(o.version)} (current)`})]})]})]})})}function fQe(e){return JSON.stringify(e.document,null,1).split(`
|
|
457
|
+
`)})]})}function sJe(){let{api:e}=q(),t=_();return L({mutationFn:()=>BE(e),onSuccess:async e=>{t.setQueryData(FE,e),await t.invalidateQueries({queryKey:X.providers})}})}function cJe({value:e,onPick:t}){let{api:n}=q(),r=X7(),i=r.data?.engines??[],a=i.find(t=>t.voices.some(t=>t.id===e)),[o,s]=(0,m.useState)(``),c=(0,m.useId)(),l=o.trim().toLowerCase(),u=i.reduce((e,t)=>e+t.voices.length,0),d=t=>l===``||t.id===e||`${t.name} ${t.language??``}`.toLowerCase().includes(l),[f,p]=(0,m.useState)(void 0);(0,m.useEffect)(()=>()=>{f!==void 0&&URL.revokeObjectURL(f)},[f]);let g=L({mutationFn:e=>ah(n,{provider:sN,model:e.engine,voice:e.id,text:lJe}),onSuccess:e=>{let t=URL.createObjectURL(e);p(t),new Audio(t).play().catch(()=>{})}});if(r.data!==void 0&&i.length===0){let e=r.data.install??void 0;return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:e===void 0?r.data.issue??Q7:Q7}),e===void 0?null:(0,h.jsx)(oJe,{install:e}),(0,h.jsx)(`p`,{className:`m-0 text-small`,children:(0,h.jsx)(eE,{to:`/settings`,search:{section:`providers`,provider:sN},children:`Check again on Keys & services`})})]})}return(0,h.jsxs)(`div`,{className:`grid gap-1`,children:[u>12?(0,h.jsx)(Y,{id:c,type:`search`,"aria-label":`Filter voices`,placeholder:`Filter ${String(u)} voices by name or language`,value:o,onChange:e=>s(e.target.value)}):null,(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,h.jsxs)(ZT,{className:`min-w-0 flex-1`,value:e,onChange:e=>{g.reset();for(let n of i){let r=n.voices.find(t=>t.id===e.target.value);if(r!==void 0)return t(r)}},children:[(0,h.jsx)(`option`,{value:``,children:r.data===void 0?`Looking for voices…`:`Pick a voice`}),i.map(e=>(0,h.jsx)(`optgroup`,{label:e.name,children:e.voices.filter(d).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.language===void 0?e.name:`${e.name} (${e.language})`},e.id))},e.id))]}),(0,h.jsxs)(K,{variant:`quiet`,disabled:a===void 0||g.isPending,disabledReason:`Pick a voice first.`,onClick:()=>{a!==void 0&&g.mutate({engine:a.id,id:e})},children:[(0,h.jsx)(zh,{"aria-hidden":`true`,className:`size-[14px]`}),g.isPending?`Speaking…`:`Listen`]})]}),g.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The sample couldn't be spoken: ${g.error.message}`})]})}var lJe=`This is how your narration will sound in this voice.`,$7=[`llm`,`tts`,`image`],uJe={llm:`Writing services`,tts:`Voice services`,image:`Image services`},dJe={llm:`Writing service`,tts:`Voice service`,image:`Image service`},fJe=`••••••••••••`,e9=`openai-tts`;function pJe(e){return/^[aeiou]/i.test(e)?`an`:`a`}function t9(e){return oN(e.readiness)}function mJe(e){return e.readiness.kind===`cli`?Y7(e.readiness):e.readiness.kind===`local`?Z7(e.readiness):e.readiness.hasKey?{tone:`done`,word:`Ready`}:{tone:`off`,word:`No key`}}function hJe(e){return e.readiness.kind===`cli`?`Sign-in`:e.readiness.kind===`local`?`Built in`:`API key`}function n9(e,t,n){let r=e.find(e=>e.id===t.provider);if(r!==void 0)return r;if(t.family===void 0)return;let i=e.filter(e=>e.family===t.family);return i.some(t9)?i.find(t9):n.map(e=>i.find(t=>t.id===e.provider)).find(e=>e!==void 0)??i[0]}function gJe(e,t){let n=$7.find(t=>{let n=e.filter(e=>e.family===t);return n.length>0&&!n.some(t9)});return n===void 0?void 0:n9(e,{family:n,provider:void 0,arrival:!1},t)}function _Je(){let e=window.innerHeight;for(let t of document.querySelectorAll(`[data-slot="usage-notice"], .sl-bottomnav`)){let n=t.getBoundingClientRect();n.height>0&&n.top<e&&(e=n.top)}return e}function vJe(e,t){t===`arrival`&&window.scrollTo({top:0,left:0});let n=_Je(),r=e.getBoundingClientRect().top,i=[...e.querySelectorAll(`[data-setup-key]`)],a=Math.max(...(i.length===0?[e]:i).map(e=>e.getBoundingClientRect().bottom));if(r>=0&&a+16<=n)return;let o=Math.min(a+16-n,r-16);window.scrollBy({top:o,behavior:t===`press`?`smooth`:`auto`})}var yJe=1500;function bJe(e){if(typeof ResizeObserver>`u`)return()=>{};let t=[`wheel`,`touchstart`,`pointerdown`,`keydown`],n=new ResizeObserver(()=>{e.isConnected?vJe(e,`settle`):i()}),r=window.setTimeout(()=>i(),yJe);function i(){n.disconnect(),window.clearTimeout(r);for(let e of t)window.removeEventListener(e,i)}for(let e of t)window.addEventListener(e,i,{passive:!0});return n.observe(document.body),i}var xJe=860;function SJe(e){let t=`(min-width: 1024px)`,[n,r]=(0,m.useState)(()=>typeof window.matchMedia!=`function`||window.matchMedia(t).matches);return(0,m.useLayoutEffect)(()=>{if(e!==null&&typeof ResizeObserver<`u`){let t=()=>{let t=e.getBoundingClientRect().width;t>0&&r(t>=xJe)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()}if(typeof window.matchMedia!=`function`)return;let n=window.matchMedia(t),i=()=>r(n.matches);return n.addEventListener?.(`change`,i),()=>n.removeEventListener?.(`change`,i)},[e]),n}function CJe({focus:e,back:t}={}){let{api:n}=q(),r=I(QE(n)),i=I($E(n)),[a,o]=(0,m.useState)(null),s=SJe(a),[c,l]=(0,m.useState)(void 0),[u,d]=(0,m.useState)(void 0),f=(0,m.useRef)(null),p=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>p.current?.(),[]);let g=$7.flatMap(e=>(r.data?.providers??[]).filter(t=>t.family===e)),_=i.data?.voices??[],[v,y]=(0,m.useState)(!1);if(c===void 0&&r.data!==void 0){let t=e===void 0?s?gJe(g,_):void 0:n9(g,e,_);l(t?.id??null),y(e===void 0&&t!==void 0)}(0,m.useEffect)(()=>{!s&&v&&(y(!1),l(null),u!==void 0&&(d(void 0),window.scrollTo({top:0,left:0})))},[s,v]);let b=I(ZE(n)),x=r.data!==void 0&&!i.isPending&&!b.isPending;(0,m.useEffect)(()=>{if(e===void 0||!x)return;let t=n9(g,e,_);t===void 0?e.arrival&&window.scrollTo({top:0,left:0}):(y(!1),l(t.id),d({id:t.id,arrival:e.arrival}))},[e,x]);let[S,C]=(0,m.useState)(!1);if((0,m.useEffect)(()=>{e===void 0&&x&&!S&&(C(!0),v&&typeof c==`string`?d({id:c,arrival:!0}):window.scrollTo({top:0,left:0}))},[e,x,S,v,c]),(0,m.useEffect)(()=>{if(u===void 0||c!==u.id)return;let e=!0,t=0;return(document.fonts?.ready??Promise.resolve()).then(()=>{e&&(t=requestAnimationFrame(()=>{let e=f.current;e!==null&&e.isConnected&&(vJe(e,u.arrival?`arrival`:`press`),p.current?.(),p.current=u.arrival?bJe(e):void 0,d(void 0))}))}),()=>{e=!1,cancelAnimationFrame(t)}},[u,c,s]),r.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:r.error.message});if(r.data===void 0)return(0,h.jsx)(DJe,{});let w=g.find(e=>e.id===c),T=e=>(0,h.jsx)(`div`,{ref:f,className:`min-w-0 scroll-mt-4`,children:D(e)}),E=e=>g.some(t=>t.id!==e.id&&t.displayName===e.displayName&&t.readiness.kind===`keyed`&&t.readiness.hasKey),D=e=>e.readiness.kind===`cli`?(0,h.jsx)(tJe,{provider:e,readiness:e.readiness,kind:dJe[e.family]},e.id):e.readiness.kind===`local`?(0,h.jsx)(aJe,{provider:e,readiness:e.readiness,...g.some(e=>e.id===e9&&e.readiness.kind===`keyed`&&!e.readiness.hasKey)?{onUseKey:()=>l(e9)}:{}},e.id):(0,h.jsx)(TJe,{provider:e,hasKey:e.readiness.hasKey,voiceless:e.family===`tts`&&i.data!==void 0&&!_.some(t=>t.provider===e.id),twinKeyed:E(e),back:t},e.id);return(0,h.jsx)(`div`,{ref:o,className:`@container flex min-w-0 flex-col gap-6`,children:$7.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,"aria-labelledby":`keys-${e}-title`,className:`grid scroll-mt-4 items-start gap-x-8 gap-y-4 @min-[860px]:grid-cols-[minmax(0,400px)_minmax(0,1fr)]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(lD,{id:`keys-${e}-title`,title:uJe[e],size:`small`,className:`pb-2`}),(0,h.jsx)(`ul`,{"aria-label":uJe[e],className:`sl-list m-0 list-none p-0`,children:g.filter(t=>t.family===e).map(e=>(0,h.jsx)(wJe,{provider:e,selected:e.id===w?.id,expands:!s,onSelect:()=>{y(!1),l(t=>!s&&t===e.id?null:e.id)},children:!s&&e.id===w?.id?T(e):null},e.id))})]}),s&&w!==void 0&&w.family===e?T(w):null]},e))})}function wJe({provider:e,selected:t,expands:n,onSelect:r,children:i}){let a=mJe(e);return(0,h.jsxs)(`li`,{"data-selected":t?`true`:void 0,"aria-current":t?`true`:void 0,className:`border-b border-line`,children:[(0,h.jsxs)(`div`,{className:G(RL,`grid min-h-10 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 px-3 py-2 hover:bg-raised`,t&&`bg-accent-tint hover:bg-accent-tint`),children:[(0,h.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,h.jsx)(HL,{onSelect:r,expanded:n?t:void 0,className:`min-w-0`,children:e.displayName}),(0,h.jsx)(`span`,{className:`shrink-0 text-small text-ink-2`,children:hJe(e)})]}),(0,h.jsx)(hE,{tone:a.tone,children:a.word})]}),i===null?null:(0,h.jsx)(`div`,{className:`px-3 pt-2 pb-5`,children:i})]})}function TJe({provider:e,hasKey:t,voiceless:n,twinKeyed:r,back:i}){let{api:a}=q(),o=_(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(void 0),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(void 0),E=(0,m.useId)(),D=PF[e.id],O=l.trim(),k=async()=>{C(!0),T(void 0);try{T(await Nxe(a,e.id,O===``?void 0:O))}catch(e){y(e instanceof Error?e.message:String(e))}finally{C(!1)}},A=async()=>{f(!0),y(void 0);try{await Cte(a,e.id,l),u(``),g(!0),T(void 0),await o.invalidateQueries({queryKey:X.providers})}catch(e){y(e instanceof Error?e.message:String(e))}finally{f(!1)}},j=L({mutationFn:()=>Tte(a,e.id),onSuccess:async()=>{x(!1),y(void 0),await o.invalidateQueries({queryKey:X.providers})},onError:e=>{x(!1),y(e.message)}});(0,m.useEffect)(()=>{if(!p)return;let e=setTimeout(()=>{g(!1)},oB);return()=>{clearTimeout(e)}},[p]);let M=[t?c:void 0,w===void 0?void 0:E].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`section`,{"aria-labelledby":s,"data-ready":t,className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h3`,{id:s,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsx)(`p`,{className:`sl-section-head__meta`,children:`${dJe[e.family]} · ${t?`a key is saved`:`needs an API key`}`})]}),(0,h.jsx)(J7,{provider:e}),(0,h.jsx)(`div`,{"data-setup-key":``,className:`min-w-0`,children:(0,h.jsx)(J,{label:`${e.displayName} API key`,help:!t&&r?`Your ${e.displayName} key for ${e.family===`image`?`voices`:`images`} is saved, and the same key works here: paste it again. Stored on this computer only.`:`Stored on this computer only, sent only to this service, never in backups or exports.`,error:v,children:(0,h.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),l.trim()!==``&&!d&&A()},children:[(0,h.jsx)(QAe,{autoComplete:`off`,spellCheck:!1,className:`flex-1 basis-[200px]`,"aria-describedby":M===``?void 0:M,placeholder:t?fJe:`Paste API key`,value:l,onChange:e=>{u(e.target.value)}}),(0,h.jsx)(K,{type:`submit`,variant:`primary`,"aria-label":`Save ${e.displayName} key`,disabled:l.trim()===``||d,children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:p?(0,h.jsx)(cB,{}):null})]})})}),t?(0,h.jsx)(`span`,{id:c,className:`sr-only`,children:`A key is stored for this provider.`}):null,w===void 0?null:(0,h.jsx)(`p`,{id:E,role:w.ok?`status`:`alert`,className:G(`m-0 text-small`,w.ok?`text-accent-ink`:`text-danger`),children:w.message}),!t&&O===``&&i===void 0?null:(0,h.jsxs)(zx,{"data-setup-key":``,children:[i===void 0?null:t?(0,h.jsx)(VR,{back:i,variant:`primary`,children:`Done · back to ${RR(i)}`}):(0,h.jsx)(VR,{back:i,children:`Back to ${RR(i)}`}),!t&&O===``?null:(0,h.jsx)(K,{disabled:S,onClick:()=>{k()},children:S?`Testing…`:`Test the key (free)`}),t?(0,h.jsx)(K,{variant:`quiet`,onClick:()=>{x(!0)},children:`Remove the key`}):null]}),t&&n?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[e.id===e9?`Your first short saves an OpenAI voice by itself. To pick one now: `:`No ${e.displayName} voice is saved yet, so narration can't use it. `,(0,h.jsx)(eE,{to:`/settings`,search:{section:`voices`,provider:e.id,...zR(i)},children:`Add ${pJe(e.displayName)} ${e.displayName} voice`})]}):null,D===void 0?null:(0,h.jsx)(SR,{summary:`Where to get a key`,state:`${String(D.steps.length)} steps`,children:(0,h.jsx)(`div`,{className:`flex flex-col gap-2 pt-2 text-small text-ink-2`,children:(0,h.jsx)(EJe,{guide:D})})}),(0,h.jsx)(ME,{open:b,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this service cannot retry until a key is saved.`,confirmLabel:`Remove key`,pending:j.isPending,onConfirm:()=>{j.mutate()},onCancel:()=>{x(!1)}})]})}function EJe({guide:e}){let t=(e,t)=>(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`underline`,children:t});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`ol`,{className:`m-0 list-decimal space-y-1 pl-5`,children:e.steps.map(e=>(0,h.jsx)(`li`,{children:e},e))}),(0,h.jsxs)(`p`,{className:`m-0`,children:[`Sign up: `,t(e.signUp.url,e.signUp.label),`. Make the key:`,` `,t(e.keyPage.url,e.keyPage.label),`.`,e.billing===void 0?null:(0,h.jsxs)(h.Fragment,{children:[` Credit: `,t(e.billing.url,e.billing.label),`.`]})]}),(0,h.jsx)(`p`,{className:`m-0`,children:e.permissions}),(0,h.jsxs)(`p`,{className:`m-0`,children:[`More in the service's `,t(e.docs.url,e.docs.label),`. After saving, press Test the key.`]})]})}function DJe(){return(0,h.jsx)(`div`,{className:`flex flex-col gap-6`,role:`status`,"aria-label":`Loading services`,children:[[`llm`,4],[`tts`,6],[`image`,5]].map(([e,t])=>(0,h.jsxs)(`div`,{className:`max-w-[400px]`,children:[(0,h.jsx)(`span`,{className:`mb-2 block h-3 w-24 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`sl-list`,children:Array.from({length:t},(t,n)=>`${e}-${n}`).map(e=>(0,h.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b border-line px-3`,children:[(0,h.jsx)(`span`,{className:`h-4 w-32 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-4 w-16 rounded-control bg-raised`})]},e))})]},e))})}function OJe(e){return ak(e).code===e?ak(e).name:e}function kJe({value:e,onChange:t,label:n,disabled:r=!1}){let i=rk.filter(t=>!e.includes(t.code));return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[e.map(n=>(0,h.jsxs)(`span`,{className:`sl-chip h-8 gap-1 pr-1`,children:[OJe(n),(0,h.jsx)(Lx,{label:`Remove ${OJe(n)}`,size:`small`,tip:!1,disabled:r,onClick:()=>t(e.filter(e=>e!==n)),children:(0,h.jsx)(Bh,{"aria-hidden":`true`,className:`size-3.5`,strokeWidth:2})})]},n)),i.length===0?null:(0,h.jsx)(ZT,{"aria-label":n,className:`sl-select--compact`,value:``,disabled:r,options:[{value:``,label:e.length===0?`Any language`:`Add a language`},...i.map(e=>({value:e.code,label:e.name}))],onChange:n=>{n.target.value!==``&&t([...e,n.target.value])}})]})}function AJe({voice:e}){let{api:t}=q(),n=_(),r=L({mutationFn:n=>Xte(t,e.id,n),onSettled:async()=>{await n.invalidateQueries({queryKey:X.voices})}}),i=r.isPending&&r.variables!==void 0?r.variables:e.languages??[],a=r.error?.message??r.data?.message;return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,h.jsx)(kJe,{value:i,label:`Languages ${e.name} speaks`,disabled:r.isPending,onChange:e=>r.mutate(e)}),a===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:a})]})}var jJe=[`alloy`,`ash`,`ballad`,`coral`,`echo`,`fable`,`nova`,`onyx`,`sage`,`shimmer`,`verse`],MJe=`__paste__`,NJe={elevenlabs:{label:`ElevenLabs voice library`,url:`https://elevenlabs.io/app/voice-library`},cartesia:{label:`Cartesia voice library`,url:`https://play.cartesia.ai/voices`}};function r9(e){return e!==void 0&&oN(e.readiness)}function i9(e){return e.readiness.kind===`local`?`Not installed`:`No key`}function a9({provider:e,back:t}){return(0,h.jsx)($T,{size:`small`,to:`/settings`,search:{section:`providers`,family:`tts`,provider:e.id,...zR(t)},children:e.readiness.kind===`local`?`Set up the system voice`:`Add ${pJe(e.displayName)} ${e.displayName} key`})}function PJe({provider:e,back:t}={}){let{api:n}=q(),r=_(),i=I($E(n)),a=I(QE(n)),[o,s]=(0,m.useState)(void 0),c=L({mutationFn:e=>Qte(n,e),onSettled:async()=>{s(void 0),await r.invalidateQueries({queryKey:X.voices})}}),l=L({mutationFn:({id:e,on:t})=>Zte(n,e,t),onSettled:async()=>{await r.invalidateQueries({queryKey:X.voices})}}),u=(a.data?.providers??[]).filter(e=>e.family===`tts`),d=e=>u.find(t=>t.id===e.provider);if(i.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:i.error.message});let f=i.data?.voices,p=u.filter(e=>a.data!==void 0&&!r9(e)&&(f??[]).some(t=>t.provider===e.id));return(0,h.jsxs)(`div`,{"data-tour":`voices`,className:`flex min-w-0 flex-col gap-6`,children:[p.map(e=>{let n=(f??[]).filter(t=>t.provider===e.id).length;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-control bg-raised px-3 py-2`,children:[(0,h.jsx)(hE,{tone:`waiting`,children:i9(e)}),(0,h.jsx)(`span`,{className:`min-w-0 flex-1 text-small text-ink`,children:`${e.readiness.kind===`local`?`The ${e.displayName.toLowerCase()} isn't installed`:`${e.displayName} has no key yet`}, so ${n===1?`its voice`:`its ${String(n)} voices`} can't narrate.`}),(0,h.jsx)(a9,{provider:e,back:t})]},e.id)}),(0,h.jsxs)(`div`,{className:`@container min-w-0`,...GT,children:[f===void 0?(0,h.jsx)(`span`,{className:`block h-10 w-64 rounded-control bg-raised`}):f.length===0?(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:`No voices yet. Add one below: narration reads your script in it.`}):(0,h.jsx)(BL,{label:`Voices`,children:f.map(e=>{let t=d(e),n=r9(t);return(0,h.jsx)(VL,{className:`relative`,title:e.name,meta:(0,h.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`truncate`,children:t?.displayName??e.provider}),t===void 0||a.data===void 0?null:n?(0,h.jsx)(hE,{tone:`done`,children:`Ready`}):(0,h.jsx)(hE,{tone:`off`,children:i9(t)}),(0,h.jsx)(`span`,{className:`truncate`,children:`· ${e.voiceId}`})]}),actions:(0,h.jsxs)(h.Fragment,{children:[n?(0,h.jsx)(FJe,{voice:e}):null,(0,h.jsx)(K,{variant:`quiet`,size:`small`,"aria-label":`Remove ${e.name}`,onClick:()=>{s(e)},children:`Remove`})]}),children:(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Speaks`}),(0,h.jsx)(AJe,{voice:e})]}),(0,h.jsx)(dD,{checked:l.isPending&&l.variables.id===e.id?l.variables.on:e.imitatesRealPerson===!0,disabled:l.isPending,onChange:t=>l.mutate({id:e.id,on:t}),label:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`sr-only`,children:`${e.name} sounds like a real person`}),(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`Sounds like a real person`})]}),className:`text-small`})]})},e.id)})}),l.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:`Couldn't save Sounds like a real person: ${l.error.message} Press the switch again.`}),c.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:c.error.message}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1`,children:[(0,h.jsx)(KT,{children:`Sounds like a real person: turn it on for a voice cloned from, or made to sound like, someone real. YouTube asks you to say so when you upload; Copy for YouTube Studio answers Yes for you.`}),(f??[]).some(e=>r9(d(e)))?(0,h.jsx)(KT,{children:`Listen reads one sentence aloud: free with the system voice, one short paid request with a service that has a key.`}):null,(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[`How names and words are said:`,` `,(0,h.jsx)(eE,{to:`/name-pronunciations`,children:`Name pronunciations ↗`}),` for the names every video says the same way, `,(0,h.jsx)(eE,{to:`/narration-aliases`,children:`Pronunciation ↗`}),` `,`for words said as other words.`]})]})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Add a voice`}),(0,h.jsx)(IJe,{tts:u,asked:u.find(t=>t.id===e)?.id,needed:(f??[]).map(e=>e.provider),said:p.map(e=>e.id),back:t})]}),(0,h.jsx)(ME,{open:o!==void 0,title:o===void 0?``:`Remove ${o.name}?`,consequence:`Projects that used this voice keep the narration they made with it.`,confirmLabel:`Remove voice`,pending:c.isPending,onConfirm:()=>{o!==void 0&&c.mutate(o.id)},onCancel:()=>{s(void 0)}})]})}function FJe({voice:e}){let{api:t}=q(),n=X7(e.provider===sN),[r,i]=(0,m.useState)(void 0);(0,m.useEffect)(()=>()=>{r!==void 0&&URL.revokeObjectURL(r)},[r]);let a=L({mutationFn:async()=>{let r=e.provider===`system-voice`?n.data?.engines.find(t=>t.voices.some(t=>t.id===e.voiceId))?.id:(await vN(t,e.provider)).models[0]?.id;if(r===void 0)throw Error(`No voice model was found for this service. Check it on Models.`);return ah(t,{provider:e.provider,model:r,voice:e.voiceId,text:lJe})},onSuccess:e=>{let t=URL.createObjectURL(e);i(t),new Audio(t).play().catch(()=>{})}});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(K,{variant:`quiet`,size:`small`,"aria-label":`Listen to ${e.name}`,disabled:a.isPending,onClick:()=>a.mutate(),children:[(0,h.jsx)(zh,{"aria-hidden":`true`,className:`size-[14px]`}),a.isPending?`Speaking…`:`Listen`]}),a.error===null?null:(0,h.jsx)(`span`,{role:`alert`,className:`basis-full text-left text-small text-danger`,children:`${e.name} couldn't be spoken: ${a.error.message}`})]})}function IJe({tts:e,asked:t,needed:n,said:r,back:i}){let{api:a}=q(),o=_(),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)([]),[v,y]=(0,m.useState)(void 0),[b,x]=(0,m.useState)(void 0),S=v??t??(e.find(r9)??e.find(e=>n.includes(e.id))??e[0])?.id,C=e.find(e=>e.id===S),w=L({mutationFn:e=>Yte(a,e),onSuccess:async e=>{e.ok?(c(``),u(``),f(!1),g([]),x(void 0),await o.invalidateQueries({queryKey:X.voices})):x(e.refusal)}}),T=(e,t)=>{t(),b?.field===e&&x(void 0)},E=e=>b?.field===e?b.message:void 0,D=S!==`system-voice`&&S!==`google-tts`&&(S!==`openai-tts`||d),O=S===void 0?`Pick a voice service first`:l.trim()===``?D?`Paste a voice ID first`:`Pick a voice first`:s.trim()===``?`Type a name first`:void 0,k=C!==void 0&&C.readiness.kind===`local`&&!r9(C),A=()=>{S===void 0||O!==void 0||b!==void 0||w.isPending||w.mutate({provider:S,name:s,voiceId:l,...p.length===0?{}:{languages:p}})},j=e=>{T(`voiceId`,()=>{u(e),s.trim()===``&&c(e)})},M=S===void 0?void 0:NJe[S],N=S===`inworld`?`Use an Inworld voice ID, such as Dennis, or one from your workspace.`:M===void 0?S===`openai-tts`&&d?`A voice made in your OpenAI account starts with voice_.`:void 0:(0,h.jsxs)(h.Fragment,{children:[`Copy a voice's ID from the`,` `,(0,h.jsx)(`a`,{href:M.url,target:`_blank`,rel:`noreferrer`,className:`sl-link`,children:`${M.label} ↗`}),` `,`or your own voices there.`]});return(0,h.jsxs)(`form`,{className:`@container flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),A()},children:[(0,h.jsxs)(`div`,{className:`grid items-start gap-4 @min-[36rem]:grid-cols-2 @min-[60rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.2fr)_minmax(0,1fr)_minmax(0,1.2fr)_auto]`,children:[(0,h.jsx)(J,{label:`Voice service`,error:E(`provider`),children:(0,h.jsxs)(ZT,{value:S??``,onChange:t=>{let n=e.find(e=>e.id===t.target.value);n!==void 0&&T(`provider`,()=>{y(n.id),u(``),f(!1)})},children:[e.length===0?(0,h.jsx)(`option`,{value:``,children:`No voice service`}):null,e.map(e=>(0,h.jsx)(`option`,{value:e.id,children:r9(e)?e.displayName:`${e.displayName} (${i9(e).toLowerCase()})`},e.id))]})}),k?(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-2 self-center text-small text-ink-2 @min-[36rem]:col-span-full @min-[60rem]:col-span-4 @min-[60rem]:mt-6`,children:[`The system voice isn't installed on this computer, so it has no voices to add yet.`,r.includes(C.id)?null:(0,h.jsx)(a9,{provider:C,back:i})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(J,{label:D?`Voice ID`:`Voice`,error:E(`voiceId`),...N===void 0?{}:{help:N},children:S===`system-voice`?(0,h.jsx)(cJe,{value:l,onPick:e=>{T(`voiceId`,()=>{u(e.id)}),s.trim()===``&&c(e.name);let t=/^([a-z]{2,3})(?:[-_]|$)/i.exec(e.language??``)?.[1];p.length===0&&t!==void 0&&g([t.toLowerCase()])}}):S===`google-tts`?(0,h.jsx)(ZT,{value:l,options:[{value:``,label:`Pick a Gemini voice`},...Mxe.map(e=>({value:e.name,label:`${e.name} (${e.style})`}))],onChange:e=>j(e.target.value)}):S===`openai-tts`&&!d?(0,h.jsx)(ZT,{value:l,options:[{value:``,label:`Pick an OpenAI voice`},...jJe.map(e=>({value:e,label:e})),{value:MJe,label:`A voice of my own (paste its ID)`}],onChange:e=>{e.target.value===MJe?(f(!0),T(`voiceId`,()=>u(``))):j(e.target.value)}}):(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,h.jsx)(Y,{className:`tabular-nums`,value:l,onChange:e=>{let t=e.target.value;T(`voiceId`,()=>{u(t)})}}),S===`openai-tts`?(0,h.jsx)(K,{variant:`quiet`,size:`small`,onClick:()=>{f(!1),T(`voiceId`,()=>u(``))},children:`Pick from OpenAI's voices`}):null]})}),(0,h.jsx)(J,{label:`Name`,help:`How you pick it on Create.`,error:E(`name`),children:(0,h.jsx)(Y,{value:s,onChange:e=>{let t=e.target.value;T(`name`,()=>{c(t)})}})}),(0,h.jsx)(J,{label:`Languages it speaks`,help:`Create lists the voice for projects in these languages.`,error:E(`languages`),children:(0,h.jsx)(kJe,{value:p,label:`Languages it speaks`,onChange:e=>T(`languages`,()=>g(e))})}),(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-1 @min-[60rem]:mt-6`,children:[(0,h.jsx)(K,{type:`submit`,variant:`primary`,disabled:O!==void 0||b!==void 0||w.isPending,children:`Add voice`}),O===void 0?null:(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:O})]})]})]}),C===void 0||r9(C)||k||r.includes(C.id)?null:(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-2 text-small text-ink-2`,children:[`${C.displayName} has no key yet: you can add the voice now, but it can't narrate until the key is saved.`,(0,h.jsx)(a9,{provider:C,back:i})]}),w.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:w.error.message})]})}var LJe={headline:`Slopify test notification`,detail:`Notifications work. You'll get one when a run finishes, fails or waits for you, and when a review needs your decision.`},RJe=2048;function zJe(e){let t=e.trim();if(t===``)return;if(t.length>2048)return`Keep the Notification URL to ${String(RJe)} characters or fewer.`;let n;try{n=new URL(t)}catch{return`Enter a full address starting with https:// or http://, for example https://ntfy.sh/your-topic.`}if(n.protocol!==`https:`&&n.protocol!==`http:`)return`The Notification URL must start with https:// or http://.`;if(n.username!==``||n.password!==``)return`Remove the user name and password from the Notification URL; Slopify can't send them.`}var BJe=[`settings`,`notifications`],VJe=`The test notification couldn't be shown: this browser only allows notifications from installed apps. Set a Notification URL below instead.`;function HJe(){return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Browser and phone`,meta:`When a run finishes, fails or waits for your review, Slopify sends the project's title and a link, never your keys.`}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsx)(UJe,{}),(0,h.jsx)(WJe,{}),(0,h.jsx)(GJe,{}),(0,h.jsx)(KJe,{})]})]})}function UJe(){let e=(0,m.useSyncExternalStore)(Ewe,pI,()=>!1),[t,n]=(0,m.useState)(fI),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=Vx(),c=e&&t===`granted`;async function l(e){if(i(void 0),!e)mI(!1);else{o(!0);try{let e=await kwe();n(e);let t=Owe(e);e===`granted`?(mI(!0),pI()||i(`Notifications couldn't be turned on because this browser blocks site storage for Slopify. Allow site data for this address in your browser's settings, then turn ${o9} on again.`)):i(t??`Notifications weren't turned on because the permission prompt was dismissed. Turn ${o9} on again and choose Allow.`)}finally{o(!1)}}}return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-2`,children:[(0,h.jsx)(dD,{label:o9,help:`Shows a notification on this computer when a run finishes, fails or waits for you, while any Slopify tab is open. Turning it on asks the browser's permission.`,checked:c,disabled:a,onChange:e=>void l(e)}),c?(0,h.jsx)(K,{variant:`quiet`,onClick:()=>{i(void 0);try{_I({projectId:`test`,text:LJe},()=>{}),s(`Test notification sent to this browser.`,`success`)}catch{i(VJe)}},children:`Send test notification`}):null]}),r===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:r})]})}function WJe(){let e=(0,m.useSyncExternalStore)(Fwe,bI,()=>!0);return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-2`,children:[(0,h.jsx)(dD,{label:`Play a sound when a run starts and ends`,help:`The end sound also plays when a run fails or waits for you. You hear them in this browser while a Slopify tab is open and has been clicked once.`,checked:e,onChange:Pwe}),(0,h.jsx)(K,{variant:`quiet`,onClick:()=>wI(`start`),children:`Hear the start sound`}),(0,h.jsx)(K,{variant:`quiet`,onClick:()=>wI(`end`),children:`Hear the end sound`})]})}var o9=`Notify me in this browser`;function GJe(){let{api:e}=q(),t=_(),n=Vx(),r=(0,m.useId)(),i=I({queryKey:BJe,queryFn:()=>kte(e)}),[a,o]=(0,m.useState)(void 0),s=a??i.data?.url??``,c=zJe(s),l=L({mutationFn:t=>Ate(e,t),onSuccess:e=>{t.setQueryData(BJe,e),o(void 0),n(e.url===null?`Notification URL removed.`:`Notification URL saved.`,`success`)}}),u=L({mutationFn:t=>jte(e,t),onSuccess:()=>{n(`Test notification sent. Check the app or page behind your Notification URL.`,`success`)}}),d=c??l.error?.message??u.error?.message,f=l.isPending||u.isPending||i.data===void 0,p=a!==void 0&&a!==(i.data?.url??``);return(0,h.jsxs)(J,{label:`Notification URL`,tip:`settings.notifications.url`,help:`Works with no tab open, for example an ntfy topic on your phone. Saved only when you press Save.`,children:[(0,h.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),!f&&c===void 0&&p&&l.mutate(s)},children:[(0,h.jsx)(Y,{type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:`https://ntfy.sh/your-topic`,className:`min-w-0 flex-1 basis-[220px]`,value:s,disabled:i.data===void 0,"aria-invalid":c!==void 0,"aria-describedby":d===void 0?void 0:r,onChange:e=>{l.reset(),u.reset(),o(e.target.value)}}),(0,h.jsx)(K,{type:`submit`,variant:`primary`,disabled:f||c!==void 0||!p,disabledReason:`Type a new address first, or fix the one shown.`,children:`Save`}),s.trim()===``?null:(0,h.jsx)(K,{variant:`quiet`,disabled:f||c!==void 0,disabledReason:`Fix the address first.`,onClick:()=>u.mutate(s),children:`Send test notification`})]}),(0,h.jsx)(KJ,{dirty:p,onDiscard:()=>{l.reset(),u.reset(),o(void 0)}}),i.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The saved Notification URL couldn't be read: `,i.error.message]}),d===void 0?null:(0,h.jsx)(`p`,{id:r,role:`alert`,className:`m-0 text-small text-danger`,children:d})]})}function KJe(){let{api:e}=q(),t=_(),n=I({queryKey:tY,queryFn:()=>uje(e)}),r=L({mutationFn:t=>dje(e,t),onSuccess:async e=>{t.setQueryData(tY,e),await t.invalidateQueries({queryKey:eY})}});return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(dD,{label:`Weekly report`,help:`Each Monday from 09:00, what was made, what failed and what it cost last week go to the Notification URL above.`,checked:n.data?.enabled===!0,disabled:n.data===void 0||r.isPending,onChange:e=>r.mutate(e)}),n.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:`The Weekly report setting didn't load: ${n.error.message}. Reload the page to try again.`}),r.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`Weekly report wasn't changed: ${r.error.message}. Try the switch again.`})]})}function qJe({note:e,onNote:t}){let{api:n}=q(),r=I(NI(n));if(r.error!==null)return(0,h.jsx)(IT,{tone:`danger`,title:`What's new did not load`,actions:(0,h.jsx)(K,{onClick:()=>void r.refetch(),children:`Try again`}),children:`${r.error.message} Press Try again, or reload the page.`});if(r.data===void 0)return(0,h.jsx)(`p`,{className:`m-0 text-ink-3`,children:`Loading what's new…`});let{notes:i,version:a}=r.data,[o]=i;if(o===void 0)return(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:`This version of Slopify has no patch notes.`});let s=e===void 0?void 0:i.find(t=>t.id===e),c=s??o;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e!==void 0&&s===void 0?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`There are no patch notes called "${e}" in this version. The newest are below.`}):null,(0,h.jsx)(J,{label:`Version`,...c.version===a?{help:`The version you are running.`}:{},className:`max-w-[360px]`,children:(0,h.jsx)(ZT,{value:c.id,options:i.map(e=>({value:e.id,label:e.version===a?`${e.title} (yours)`:e.title})),onChange:e=>t(e.target.value===o.id?void 0:e.target.value)})}),(0,h.jsx)(VI,{id:c.id,untitled:!0})]})}var JJe=new Set([`tailscale`,`npx`]),YJe=new Set([`serve`,`funnel`,`status`,`off`,`on`,`up`,`reset`]);function XJe(e,t){return t?!0:YJe.has(e)||/^--[\w-]+(?:=\S+)?$/u.test(e)||/^https?:\/\/\S+$/u.test(e)||/^@[\w./@-]+$/u.test(e)||/^<[^>]*>?$/u.test(e)||/^\d+$/u.test(e)}function ZJe(e){let t=e.split(/( )/u),n=[],r=(e,t)=>{let r=n.at(-1);r!==void 0&&r.command===t?r.text+=e:n.push({text:e,command:t})},i=0;for(;i<t.length;){let e=t[i]??``;if(!JJe.has(e)||t[i+2]===void 0){r(e,!1),i+=1;continue}let n=e,a=i+2,o=!1,s=``;for(;a<t.length;){let e=t[a]??``,r=e.replace(/[.,;:)]+$/u,``);if(r===``||!XJe(r,o))break;if(n+=` ${r}`,o=(o||r.includes(`<`))&&!r.includes(`>`),a+=2,r!==e){s=e.slice(r.length);break}}n===e?(r(e,!1),i+=1):(r(n,!0),s!==``&&r(s,!1),i=a-1)}return n}function s9({text:e}){let t=ZJe(e).map((e,t)=>e.command?(0,h.jsx)(`code`,{className:`sl-code sl-command`,children:e.text},t):(0,h.jsx)(m.Fragment,{children:e.text},t));return(0,h.jsx)(h.Fragment,{children:t})}var c9=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(c9||{}),QJe=[0,1],$Je=[1,0],eYe=[2,3],tYe=[3,2],nYe={L:QJe,M:$Je,Q:eYe,H:tYe},rYe=/^\d*$/,iYe=/^[A-Z0-9 $%*+./:-]*$/,l9=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,u9=1,d9=40,aYe=3,oYe=3,f9=40,sYe=10,cYe=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],lYe=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],uYe=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<u9||e>d9)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,c9.Timing),this.setFunctionModule(e,6,e%2==0,c9.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,m9(r,e));this.setFunctionModule(8,7,m9(r,6)),this.setFunctionModule(8,8,m9(r,7)),this.setFunctionModule(7,8,m9(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,m9(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,m9(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,m9(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=m9(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,c9.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,c9.Alignment)}setFunctionModule(e,t,n,r=c9.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==_9(t,n))throw RangeError(`Invalid argument`);let r=lYe[n[0]][t],i=cYe[n[0]][t],a=Math.floor(g9(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=CYe(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=wYe(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(g9(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=m9(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=aYe:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*f9),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*f9}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=aYe:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*f9),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*f9}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=oYe)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*sYe,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function p9(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function m9(e,t){return!!(e>>>t&1)}var h9=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},dYe=[1,10,12,14],fYe=[2,9,11,13],pYe=[4,8,16,16];function mYe(e,t){return e[Math.floor((t+7)/17)+1]}function hYe(e){let t=[];for(let n of e)p9(n,8,t);return new h9(pYe,e.length,t)}function gYe(e){if(!yYe(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);p9(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new h9(dYe,e.length,t)}function _Ye(e){if(!bYe(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=l9.indexOf(e.charAt(n))*45;r+=l9.indexOf(e.charAt(n+1)),p9(r,11,t)}return n<e.length&&p9(l9.indexOf(e.charAt(n)),6,t),new h9(fYe,e.length,t)}function vYe(e){return e===``?[]:yYe(e)?[gYe(e)]:bYe(e)?[_Ye(e)]:[hYe(SYe(e))]}function yYe(e){return rYe.test(e)}function bYe(e){return iYe.test(e)}function xYe(e,t){let n=0;for(let r of e){let e=mYe(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function SYe(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function g9(e){if(e<u9||e>d9)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function _9(e,t){return Math.floor(g9(e)/8)-cYe[t[0]][e]*lYe[t[0]][e]}function CYe(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=v9(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=v9(n,2)}return t}function wYe(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=v9(t,e))}return n}function v9(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function TYe(e,t,n=1,r=40,i=-1,a=!0){if(!(u9<=n&&n<=r&&r<=d9)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=_9(o,t)*8,i=xYe(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[$Je,eYe,tYe])a&&s<=_9(o,e)*8&&(t=e);let c=[];for(let t of e){p9(t.mode[0],4,c),p9(t.numChars,mYe(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=_9(o,t)*8;p9(0,Math.min(4,l-c.length),c),p9(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)p9(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new uYe(o,t,u,i)}function EYe(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?vYe(e):Array.isArray(e)?[hYe(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=TYe(c,nYe[n],i,a,o,r),u=DYe({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function DYe(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=c9.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}function OYe({text:e,label:t,size:n=168}){let{data:r}=EYe(e,{ecc:`M`,border:2}),i=r.length,a=r.flatMap((e,t)=>e.map((e,n)=>e?`M${n} ${t}h1v1h-1z`:``)).join(``);return(0,h.jsxs)(`svg`,{role:`img`,"aria-label":t,width:n,height:n,viewBox:`0 0 ${i} ${i}`,shapeRendering:`crispEdges`,className:`shrink-0 rounded-sm`,children:[(0,h.jsx)(`rect`,{width:i,height:i,fill:`white`}),(0,h.jsx)(`path`,{d:a,fill:`black`})]})}var kYe=`Open on my other devices (Tailscale)`,AYe={failed:`danger`,denied:`danger`,funnel:`danger`},jYe=e=>e.includes(`admin`)?`Open the Tailscale admin console`:`Download Tailscale`;function MYe(){let{api:e}=q(),t=Vx(),n=_(),r=I({queryKey:H7,queryFn:()=>W7(e)}),i=L({mutationFn:t=>Rqe(e,t),onSuccess:e=>n.setQueryData(H7,e)}),a=r.data,o=async e=>{await oJ(e)?t(`Address copied.`,`success`):t(`The address wasn't copied: this browser blocked the clipboard. Select it and copy it yourself.`,`error`)},s=i.isPending,c=a!==void 0&&a.fix!==null&&a.state!==`docker`;return(0,h.jsxs)(`section`,{className:`flex max-w-prose flex-col gap-3`,children:[r.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:[`Remote access couldn't be checked: `,r.error.message]}),a===void 0?r.error===null?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink-2`,children:`Checking Tailscale…`}):null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(dD,{label:kYe,tip:`settings.remote-access`,checked:a.enabled,disabled:!a.available||!a.changeable||s,describedBy:`remote-access-summary`,onChange:e=>i.mutate({enabled:e})}),(0,h.jsxs)(`p`,{id:`remote-access-summary`,role:`status`,className:`m-0 text-small text-ink-2`,children:[s?`Asking Tailscale…`:c?``:(0,h.jsx)(s9,{text:a.summary}),!a.changeable&&a.available?` Turn it on or off on the computer Slopify runs on.`:``]}),a.state===`docker`&&a.fix!==null?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:(0,h.jsx)(s9,{text:a.fix})}):null,a.address===null?null:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,h.jsx)(OYe,{text:a.address,label:`QR code for ${a.address}`}),(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-[220px] flex-col gap-2`,children:[(0,h.jsx)(`code`,{className:`sl-code py-2 break-all select-all`,children:a.address}),(0,h.jsx)(`div`,{children:(0,h.jsxs)(K,{variant:`secondary`,"aria-label":`Copy the remote address`,onClick:()=>void o(a.address??``),children:[(0,h.jsx)(_h,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),`Copy address`]})}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Scan it with your phone's camera. The device must be signed in to the same tailnet.`})]})]}),c?(0,h.jsx)(IT,{tone:AYe[a.state]??`waiting`,title:(0,h.jsx)(s9,{text:a.summary}),actions:a.changeable?(0,h.jsxs)(h.Fragment,{children:[a.suggestedPort===null?null:(0,h.jsxs)(K,{variant:`primary`,disabled:s,onClick:()=>i.mutate({enabled:!0,httpsPort:a.suggestedPort??443}),children:[`Use port `,a.suggestedPort]}),a.link===null?null:(0,h.jsx)(tE,{href:a.link,target:`_blank`,rel:`noreferrer`,children:jYe(a.link)}),(0,h.jsx)(K,{variant:a.suggestedPort===null?`primary`:`secondary`,disabled:s,onClick:()=>i.mutate({enabled:a.enabled}),children:`Check again`})]}):void 0,children:a.fix===null?null:(0,h.jsx)(s9,{text:a.fix})}):null,i.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:i.error.message})]})]})}var NYe=H({id:U([`keywords`,`providers`,`voice`,`release-slots`,`monthly-cost`,`answerers`]),ok:$p(),sentence:z(),fix:H({label:z(),href:z()}).strict().readonly().optional()}).strict().readonly(),PYe=H({id:U(Kx),label:z(),state:U(ile),sentence:z()}).strict().readonly(),y9=H({state:U([`current`,`making`,`waiting`,`needs-fix`,`stale`,`off`]),sentence:z(),url:z().nullable()}).strict().readonly(),FYe=H({video:y9,loudness:y9.unwrap().extend({beforeUrl:z().nullable(),beforeLufs:B().nullable(),afterLufs:B().nullable(),targetLufs:B().nullable(),ceiling:B().nullable()}).strict().readonly(),document:y9}).strict().readonly(),IYe=H({runs:V(H({at:z(),scheduleId:z(),scheduleName:z(),title:z(),topic:$p(),paused:$p()}).strict().readonly()).readonly(),cost:H({runs:B(),high:B(),unknown:B(),unpriced:V(z()).readonly(),problem:z().nullable(),paused:H({schedules:B(),runs:B(),high:B()}).strict().readonly()}).strict().readonly().nullable()}).strict().readonly(),LYe=H({id:z(),name:z(),kind:U([`checkpoint`,`review`]),by:U([`you`,`model`,`agent`]),detail:z()}).strict().readonly(),RYe=H({projectId:z().nullable(),revisionId:z().nullable(),state:U(Jx).nullable(),sentence:z().nullable(),quotedHigh:B().nullable(),article:z().nullable(),outputs:V(H({section:U(Kx),role:z(),url:z(),name:z()}).strict().readonly()).readonly(),versions:V(H({version:B().int().positive(),state:U(Jx),updatedAt:z()}).strict().readonly()).readonly()}).strict().readonly(),zYe=H({template:txe,gate:U([...ale,`unchecked`]),runnableVersion:B().int().positive().nullable(),gated:$p(),checkedVersion:B().int().positive().nullable(),sample:H({topic:z(),topicSource:U([`fixed`,`queued`]),fullScript:$p()}).strict().readonly(),sections:V(PYe).readonly(),free:FYe,schedule:IYe,reviews:V(LYe).readonly(),paid:RYe}).strict().readonly(),BYe=H({version:B().int().positive(),checks:V(NYe).readonly()}).strict().readonly(),VYe=H({stage:z(),low:B().nullable(),high:B().nullable(),detail:z(),onPlan:$p().optional(),apiLow:B().nullable().optional(),apiHigh:B().nullable().optional()}).strict().readonly(),HYe=H({version:B().int().positive(),first:$p(),sections:V(U(Kx)).readonly(),rows:V(VYe).readonly(),low:B(),high:B(),unknown:B().int().nonnegative(),onPlan:$p(),usesPlan:$p(),budget:H({budget:B(),spent:B(),unpriced:B().int().nonnegative(),left:B(),plans:$p()}).strict().readonly(),fits:$p(),problem:z().nullable()}).strict().readonly(),UYe=H({section:U(Kx),items:V(H({key:z(),label:z()}).strict().readonly()).readonly(),item:z().nullable(),segments:V(H({origin:U([`yours`,`keyword`,`slopify`,`setting`]),text:z(),name:z().optional(),unfilled:cm(!0).optional()}).strict().readonly()).readonly(),fromSample:$p(),problem:z().nullable()}).strict().readonly(),WYe=H({cards:V(H({id:z(),still:z().nullable(),format:U([`16:9`,`9:16`,`1:1`]),video:$p(),words:B().int().nonnegative().nullable(),voice:H({provider:z(),voiceId:z(),name:z()}).strict().nullable(),captions:U([`off`,`burn-in`,`files`]),shorts:B().int().nonnegative(),pdf:$p(),asks:V(z()),schedules:B().int().nonnegative()}).strict())}).strict(),b9=e=>[`template-studio`,e];function GYe(e){return{queryKey:[`project-templates`,`cards`],queryFn:async()=>{let t=await e.fetch(`${e.origin}/api/template-studio/cards`);if(!t.ok)throw await vm(t);return Tm(WYe,await t.json()).cards}}}var KYe=class extends Error{};async function qYe(e,t){let n=await e.fetch(`${e.origin}/api/template-studio/${encodeURIComponent(t)}`);if(n.status===404)throw new KYe((await vm(n)).message);if(!n.ok)throw await vm(n);return Tm(zYe,await n.json())}function JYe(e,t){return{queryKey:b9(t),queryFn:()=>qYe(e,t),retry:(e,t)=>!(t instanceof KYe)&&e<3}}function x9(e,t){return{queryKey:[...b9(t),`checks`],queryFn:async()=>{let n=await e.fetch(`${e.origin}/api/template-studio/${encodeURIComponent(t)}/checks`);if(!n.ok)throw await vm(n);return Tm(BYe,await n.json())}}}async function YYe(e,t){let n=await e.fetch(`${e.origin}/api/template-studio/${encodeURIComponent(t)}/free-samples`,{method:`POST`});if(!n.ok)throw await vm(n)}var S9={statuses:[400,409]};function C9(e,t,n){let r=H({[t]:n}).loose().safeParse(e);return r.success?r.data[t]:void 0}async function w9(e,t){let n=await Em(e);if(e.ok)return{ok:!0,value:Tm(t,n)};let r=Dm(e,n,S9);return{ok:!1,reason:r.reason??`conflict`,message:r.message,quote:C9(n,`quote`,HYe)??null}}var T9=(e,t)=>`${e.origin}/api/template-studio/${encodeURIComponent(t)}`,E9=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)});async function D9(e,t,n){let r=await e.fetch(`${T9(e,t)}/quote`,E9(`POST`,n));if(!r.ok)throw await vm(r);return Tm(HYe,await r.json())}var XYe=H({template:H({version:B()}).loose(),sample:U([`queued`,`skipped`]),replayed:$p()}).loose();function ZYe(e,t,n){return e.fetch(`${T9(e,t)}/save`,E9(`POST`,n)).then(e=>w9(e,XYe))}function QYe(e,t,n){return e.fetch(`${T9(e,t)}/samples/make`,E9(`POST`,n)).then(e=>w9(e,H({queued:cm(!0)}).loose()))}var $Ye=H({topic:z(),topicSource:U([`fixed`,`queued`]),fullScript:$p()}).loose();function eXe(e,t,n){return e.fetch(`${T9(e,t)}/topic`,E9(`PUT`,n)).then(e=>w9(e,$Ye))}function tXe(e,t,n){return e.fetch(`${T9(e,t)}/full-script`,E9(`POST`,n)).then(e=>w9(e,$Ye))}function nXe(e,t,n,r,i){return{queryKey:[...b9(t),`anatomy`,n,r??``,i],queryFn:async()=>{let i=new URLSearchParams({section:n,...r===void 0?{}:{item:r}}),a=await e.fetch(`${T9(e,t)}/anatomy?${i.toString()}`);if(!a.ok)throw await vm(a);return Tm(UYe,await a.json())}}}var rXe=H({dailyBudget:B(),samplesUsePlans:$p(),today:H({budget:B(),spent:B(),unpriced:B().default(0),left:B(),plans:$p()}),designDailyBudget:B().default(1),designToday:H({budget:B(),spent:B(),left:B()}).optional()}).loose(),iXe=[`template-studio`,`settings`];async function aXe(e){let t=await e.fetch(`${e.origin}/api/template-studio/settings`);if(!t.ok)throw await vm(t);return Tm(rXe,await t.json())}async function oXe(e,t){let n=await e.fetch(`${e.origin}/api/template-studio/settings`,E9(`PUT`,t));if(!n.ok)throw await vm(n);return Tm(rXe,await n.json())}function O9(e){return`about ${nE(e)}`}var sXe=H({items:V(H({templateId:z(),name:z(),version:B(),high:B(),unknown:B(),fits:$p(),problem:z().nullable()}).loose()),total:B(),fitting:B(),sentence:z()}).loose(),cXe=[`template-studio`,`samples-for-all`];async function lXe(e){let t=await e.fetch(`${e.origin}/api/template-studio/samples-for-all/quote`,{method:`POST`});if(!t.ok)throw await vm(t);return Tm(sXe,await t.json())}async function uXe(e,t){let n=await e.fetch(`${e.origin}/api/template-studio/samples-for-all`,E9(`POST`,t)),r=await Em(n);if(n.ok){let e=Tm(H({queued:V(z()),held:V(z())}).loose(),r);return{ok:!0,queued:e.queued.length,held:e.held.length}}return{ok:!1,message:Dm(n,r,S9).message,quote:C9(r,`quote`,sXe)??null}}var dXe=H({label:z(),sentence:z(),fix:H({label:z(),href:z()}).optional(),section:z().optional()}).loose();async function fXe(e,t,n){let r=await e.fetch(`${T9(e,t)}/ready`,E9(`POST`,{version:n}));if(r.ok)return{ok:!0};let i=await Em(r);return{ok:!1,message:Dm(r,i,S9).message,problems:C9(i,`problems`,V(dXe))??[]}}var pXe=H({names:V(H({term:z(),ipa:V(z()),line:z().nullable(),spokenAs:z().nullable()}).loose()),aliasesOn:$p(),voice:H({provider:z(),model:z(),voice:z()}).nullable(),problem:z().nullable()}).loose();function mXe(e,t,n){return{queryKey:[...b9(t),`pronunciations`,n??``],queryFn:async()=>{let n=await e.fetch(`${T9(e,t)}/pronunciations`);if(!n.ok)throw await vm(n);return Tm(pXe,await n.json())}}}var hXe=H({lines:B(),high:B(),unknown:B(),fits:$p(),problem:z().nullable()}).loose();async function gXe(e,t,n){let r=await e.fetch(`${T9(e,t)}/say-it-as/quote`,E9(`POST`,n));if(!r.ok)throw await vm(r);return Tm(hXe,await r.json())}function _Xe(e,t,n){return e.fetch(`${T9(e,t)}/say-it-as`,E9(`POST`,n)).then(e=>w9(e,H({queued:$p()}).loose()))}async function vXe(e,t){let n=await e.fetch(`${T9(e,t)}/pack`);return n.ok?{ok:!0,filename:/filename="([^"]+)"/.exec(n.headers.get(`content-disposition`)??``)?.[1]??`template.slopify-template.zip`,blob:await n.blob()}:{ok:!1,message:Dm(n,await Em(n),S9).message}}var yXe=H({templateId:z(),name:z(),added:B(),renamed:V(H({from:z(),to:z()}).loose()),voiceKnown:$p(),samples:B()}).loose();async function bXe(e,t){let n=new FormData;n.set(`file`,t);let r=await e.fetch(`${e.origin}/api/template-studio/packs/import`,{method:`POST`,body:n}),i=await Em(r);return r.ok?{ok:!0,value:Tm(yXe,i)}:{ok:!1,message:Dm(r,i,{statuses:[400,409,413]}).message}}var xXe=H({samples:V(H({role:U([`thumbnail`,`picture`,`narration`]),name:z(),url:z()}).loose())}).loose();function SXe(e,t){return{queryKey:[...b9(t),`pack-samples`],queryFn:async()=>{let n=await e.fetch(`${T9(e,t)}/pack-samples`);if(!n.ok)throw await vm(n);return Tm(xXe,await n.json())}}}var CXe=H({version:B(),section:U([`script`,`voice`,`pictures`]),current:H({provider:z(),model:z()}).loose(),models:V(H({provider:z(),model:z(),high:B(),unknown:B(),onPlan:$p(),problem:z().nullable()}).loose()),high:B(),unknown:B(),usesPlan:$p().optional(),budget:H({budget:B(),spent:B(),left:B(),plans:$p().optional()}).loose(),fits:$p(),problem:z().nullable()}).loose(),wXe=H({provider:z(),model:z(),slot:B().nullable(),state:U([`current`,`queued`,`making`,`done`,`failed`]),quotedHigh:B().nullable(),cost:B().nullable(),seconds:B().nullable(),failure:z().nullable(),outputs:V(H({role:z(),url:z(),name:z()}).loose()),article:z().nullable()}).loose(),TXe=H({bakeoff:H({id:z(),section:U([`script`,`voice`,`pictures`]),version:B(),stale:$p(),state:U([`queued`,`making`,`done`,`held`,`failed`]),sentence:z().nullable(),entries:V(wXe)}).loose().nullable()}).loose();function EXe(e,t){return{queryKey:[...b9(t),`bakeoff`],queryFn:async()=>{let n=await e.fetch(`${T9(e,t)}/bakeoff`);if(!n.ok)throw await vm(n);return Tm(TXe,await n.json())},refetchInterval:e=>{let t=e.state.data?.bakeoff?.state;return t===`queued`||t===`making`?5e3:!1}}}async function DXe(e,t,n){return w9(await e.fetch(`${T9(e,t)}/bakeoff/quote`,E9(`POST`,n)),CXe)}async function OXe(e,t,n){let r=await e.fetch(`${T9(e,t)}/bakeoff`,E9(`POST`,n)),i=await Em(r);return r.ok?{ok:!0}:{ok:!1,message:Dm(r,i,S9).message,quote:C9(i,`quote`,CXe)??null}}async function kXe(e,t){let n=await e.fetch(`${T9(e,t)}/bakeoff`,{method:`DELETE`}),r=await Em(n);return n.ok?{ok:!0}:{ok:!1,message:Dm(n,r,S9).message}}var AXe=`Let samples use my Claude Code or Codex plan`;function jXe(e){return e.usesPlan===!0&&e.budget.plans!==!0}function MXe(e){return jXe(e)?`Samples may not use your Claude Code or Codex plan`:`Today's sample budget can't cover it`}function NXe(e,t){return jXe(e)?`${t} runs on your Claude Code or Codex plan, and samples may not use it. Turn on ${AXe} in `:`${t} costs about ${nE(e.high)} and ${nE(e.budget.left)} of today's ${nE(e.budget.budget)} sample budget is left. Raise it in `}function PXe(){return(0,h.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,h.jsx)(FXe,{}),(0,h.jsx)(LXe,{})]})}function FXe(){let{api:e}=q(),t=_(),n=I({queryKey:iXe,queryFn:()=>aXe(e)}),r=L({mutationFn:t=>oXe(e,t),onSuccess:e=>t.setQueryData(iXe,e)});if(n.error)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:`The template samples' settings didn't load: ${n.error.message} Reload the page to try again.`});let i=n.data;if(i===void 0)return(0,h.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`h-20 rounded-control bg-raised`});let a=i.today.unpriced>0?` plus ${String(i.today.unpriced)} ${i.today.unpriced===1?`call`:`calls`} with no known price`:``,o=r.variables;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(IXe,{label:`Video templates: daily budget`,saveLabel:`Save video budget`,help:`The most video template samples may spend in one day, in US dollars; one over it waits for tomorrow or a higher budget. Spent today: ${nE(i.today.spent)}${a}; left: ${nE(i.today.left)}.`,stored:i.dailyBudget,pending:r.isPending,error:r.error&&o?.dailyBudget!==void 0?`The budget wasn't saved: ${r.error.message}`:void 0,onSave:(e,t)=>r.mutate({dailyBudget:e},{onSuccess:t})}),(0,h.jsx)(IXe,{label:`Poster templates: daily budget`,saveLabel:`Save poster budget`,help:`The most poster template samples may spend in one day, in US dollars; one over it waits for tomorrow or a higher budget.${i.designToday===void 0?``:` Spent today: ${nE(i.designToday.spent)}; left: ${nE(i.designToday.left)}.`}`,stored:i.designDailyBudget,pending:r.isPending,error:r.error&&o?.designDailyBudget!==void 0?`The poster budget wasn't saved: ${r.error.message}`:void 0,onSave:(e,t)=>r.mutate({designDailyBudget:e},{onSuccess:t})}),(0,h.jsx)(dD,{label:AXe,help:i.samplesUsePlans?`On: samples, poster samples included, may run steps on your plan. That usage has no dollar price, so the budgets above don't limit it.`:`Off: a sample that needs your plan, poster samples included, waits until you turn this on.`,checked:i.samplesUsePlans,disabled:r.isPending,onChange:e=>r.mutate({dailyBudget:i.dailyBudget,samplesUsePlans:e})})]})}function IXe(e){let[t,n]=(0,m.useState)(),r=t??e.stored.toFixed(2),i=Number(r.trim()),a=r.trim()===``||!Number.isFinite(i)||i<0||i>1e3?`Enter an amount between $0.00 and $1,000.00.`:void 0;return(0,h.jsx)(J,{label:e.label,help:e.help,error:a??e.error,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`$`}),(0,h.jsx)(Y,{type:`number`,inputMode:`decimal`,min:0,max:1e3,step:.5,className:`w-[112px] tabular-nums`,value:r,"aria-invalid":a!==void 0,onChange:e=>n(e.target.value)}),(0,h.jsx)(K,{variant:`primary`,disabled:a!==void 0||e.pending||t===void 0,disabledReason:e.pending?`Saving`:t===void 0?`Nothing changed`:a??``,onClick:()=>e.onSave(i,()=>n(void 0)),children:e.saveLabel})]})})}function LXe(){let{api:e}=q(),t=_(),n=I({queryKey:cXe,queryFn:()=>lXe(e),staleTime:6e4}),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(),s=L({mutationFn:t=>uXe(e,{acknowledgedTotal:t,acknowledgedUnknown:r}),onSuccess:async e=>{e.ok?o({error:!1,text:`Queued ${String(e.queued)} ${e.queued===1?`sample`:`samples`}${e.held>0?`; ${String(e.held)} wait, as each template's Edit template page says`:``}. They are made one at a time in the background.`}):(o({error:!0,text:e.message}),e.quote!==null&&t.setQueryData(cXe,e.quote)),e.ok&&await t.invalidateQueries({queryKey:[`template-studio`]})},onError:e=>o({error:!0,text:`The samples weren't asked for: ${e.message} Press Make samples for all again.`})});if(n.error)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:`The samples for all couldn't be priced: ${n.error.message} Reload the page to try again.`});let c=n.data,l=c?.items.some(e=>e.unknown>0&&e.fits)??!1,u=c?.items.filter(e=>e.problem===null).length??0,d=c!==void 0&&c.fitting===0?`No sample fits today's budget or plan setting: change them above, or press this tomorrow`:s.isPending?`Asking for the samples`:void 0;return(0,h.jsxs)(`section`,{"aria-label":`Samples for all templates`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-body font-medium text-ink`,children:`Samples for all templates`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:c===void 0?`Pricing the sample of every template…`:c.sentence}),l?(0,h.jsxs)(`label`,{className:`flex items-center gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),`Accept steps with no known price`]}):null,c===void 0||u===0?null:(0,h.jsx)(`div`,{children:(0,h.jsx)(K,{variant:`secondary`,disabled:d!==void 0,disabledReason:d,focusableWhenDisabled:!0,onClick:()=>s.mutate(c.total),children:`Make samples for all · ${O9(c.total)}`})}),a===void 0?null:(0,h.jsx)(`p`,{role:a.error?`alert`:`status`,className:a.error?`m-0 text-small text-danger`:`m-0 text-small text-ink-2`,children:a.text})]})}var RXe={project:`Project`,prompt:`Prompt`,entry:`Intro/outro`,template:`Template`,schedule:`Schedule`,design:`Design`,"design-template":`Poster template`},zXe=[{value:`project`,label:`Projects`},{value:`prompt`,label:`Prompts`},{value:`entry`,label:`Intros and outros`},{value:`template`,label:`Templates`},{value:`schedule`,label:`Schedules`},{value:`design`,label:`Designs`},{value:`design-template`,label:`Poster templates`}],BXe=`Deleted projects, prompts, intros and outros, templates, schedules and designs stay here for 30 days.`,VXe=`Channels, cast members, PDF looks and episode summaries are deleted permanently and never come here.`;function HXe(e){return e.kind===`entry`&&e.detail!==null?e.detail===`intro`?`Intro`:`Outro`:e.kind===`prompt`&&e.detail!==null?`Prompt · ${e.detail}`:RXe[e.kind]}function UXe(e){return e<=0?`removed for good today`:e===1?`1 day left`:`${String(e)} days left`}var WXe=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),GXe=new Intl.DateTimeFormat(void 0,{dateStyle:`full`,timeStyle:`long`});function KXe(e){let t=new Date(e.deletedAt);return{short:WXe.format(t),full:`Deleted ${GXe.format(t)}. Removed for good ${GXe.format(new Date(e.purgeAt))}.`}}function k9(e){return`${e.kind}:${e.id}`}var qXe={project:[X.projects,X.calendar],prompt:[X.prompts],entry:[X.entries],template:[PM],schedule:[BO,X.calendar],design:[X.designs],"design-template":[X.designTemplates]};function JXe(e){let t=e.filter(e=>e.kind===`project`).length,n=e.some(e=>e.kind===`schedule`);return[t===0?void 0:t===1&&e.length===1?`The project and every file it produced are removed from disk.`:`${String(t)} ${t===1?`project and every file it`:`projects and every file they`} produced are removed from disk.`,n?`Deleted schedules keep their run history on Schedules.`:void 0,`Nothing removed here can be restored. This cannot be undone.`].filter(e=>e!==void 0).join(` `)}function YXe(e,t,n,r){let i=t[0];if(i===void 0)return``;let a=r.find(e=>e.kind===i.kind&&e.id===i.id)?.name;return`Could not ${e} ${String(t.length)} of ${oE(n,`item`,`items`)}. ${a===void 0?``:`"${a}": `}${i.detail}`}function XXe(){let{api:e}=q(),t=_(),n=Vx(),r=async e=>{let n=new Map([[xQ.join(`/`),xQ]]);for(let t of e)for(let e of qXe[t.kind])n.set(e.join(`/`),e);await Promise.all([...n.values()].map(e=>t.invalidateQueries({queryKey:e})))};return{restore:L({mutationFn:async t=>{let[n]=t;return t.length===1&&n!==void 0?{restored:[await CQ(e,n.kind,n.id)],failed:[]}:wQ(e,t)},onSuccess:async({restored:e,failed:t},i)=>{await r(i);let[a]=e;if(e.length===1&&a!==void 0)n(a.renamedFrom===null?`Restored "${a.name}".`:`Restored as "${a.name}": another item is now called "${a.renamedFrom}".`,`success`);else if(e.length>1){let t=e.filter(e=>e.renamedFrom!==null).length;n(`Restored ${oE(e.length,`item`,`items`)}.${t===0?``:` ${oE(t,`came`,`came`)} back renamed because the name was taken.`}`,`success`)}e.some(e=>e.kind===`schedule`)&&n(e.filter(e=>e.kind===`schedule`).length===1?`The schedule is paused. Press Resume on Schedules to run it again.`:`The schedules are paused. Press Resume on Schedules to run each again.`,`info`),t.length>0&&n(YXe(`restore`,t,i.length,i),`error`)},onError:async(e,t)=>{n(e.message,`error`),await r(t)}}),remove:L({mutationFn:async t=>{let[n]=t;return t.length===1&&n!==void 0?(await gNe(e,n.kind,n.id),{deleted:[n],failed:[]}):_Ne(e,t)},onSuccess:async({deleted:e,failed:t},i)=>{await r(i);let[a]=i;i.length===1&&a!==void 0&&t.length===0?n(`Deleted "${a.name}" for good.`,`success`):e.length>0&&n(`Deleted ${oE(e.length,`item`,`items`)} for good.`,`success`),t.length>0&&n(YXe(`delete`,t,i.length,i),`error`)},onError:async(e,t)=>{n(e.message,`error`),await r(t)}})}}function ZXe(){let{api:e}=q(),t=I({queryKey:xQ,queryFn:()=>SQ(e)}),{restore:n,remove:r}=XXe(),[i,a]=(0,m.useState)(`all`),[o,s]=(0,m.useState)(void 0),c=t.data??[],l=zXe.filter(e=>c.some(t=>t.kind===e.value)),u=l.some(e=>e.value===i)?i:`all`,d=(0,m.useMemo)(()=>u===`all`?c:c.filter(e=>e.kind===u),[c,u]),f=sQ((0,m.useMemo)(()=>d.map(k9),[d])),p=d.filter(e=>f.has(k9(e))),g=n.isPending||r.isPending,_=(e,t,n)=>s({title:e,label:t,items:n}),v=()=>{o!==void 0&&r.mutate(o.items,{onSettled:()=>{s(void 0),f.clear()}})};return(0,h.jsxs)(`div`,{children:[c.length===0?null:(0,h.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,h.jsx)(`p`,{className:`m-0 min-w-0 flex-1 text-small text-ink-2`,children:`${BXe} ${VXe}`}),(0,h.jsxs)(zx,{children:[(0,h.jsx)(K,{size:`small`,disabled:g,disabledReason:`Working on it`,onClick:()=>n.mutate(c,{onSuccess:f.clear}),children:`Restore all`}),(0,h.jsx)(K,{size:`small`,variant:`destructive`,disabled:g,disabledReason:`Working on it`,onClick:()=>_(`Empty the trash: delete all ${oE(c.length,`item`,`items`)} for good?`,`Empty trash`,c),children:`Empty trash`})]})]}),t.isPending?(0,h.jsx)(`p`,{className:`text-small text-ink-3`,children:`Loading the trash…`}):t.error?(0,h.jsx)(dE,{what:`The trash`,error:t.error,onRetry:()=>void t.refetch(),retrying:t.isFetching,compact:!0}):c.length===0?(0,h.jsxs)(ZR,{title:`The trash is empty`,children:[BXe,` `,VXe]}):(0,h.jsxs)(`div`,{onKeyDown:f.onKeyDown,children:[l.length>1?(0,h.jsx)(fD,{label:`Filter by kind`,value:u,onChange:a,options:[{value:`all`,label:`All`},...l],className:`mb-2`}):null,(0,h.jsx)(uQ,{selection:f,total:d.length,noun:[`item`,`items`],...u===`all`?{}:{scope:`Select all ${String(d.length)} shown`},actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(K,{size:`small`,disabled:g||f.count===0,disabledReason:f.count===0?`Nothing is selected`:`Working on it`,onClick:()=>n.mutate(p,{onSuccess:f.clear}),children:`Restore selected`}),(0,h.jsx)(K,{size:`small`,variant:`destructive`,disabled:g||f.count===0,disabledReason:f.count===0?`Nothing is selected`:`Working on it`,onClick:()=>_(`Delete ${oE(p.length,`selected item`,`selected items`)} for good?`,`Delete for good`,p),children:`Delete selected`})]})}),(0,h.jsx)(BL,{label:`Deleted items`,children:d.map(e=>{let t=KXe(e);return(0,h.jsx)(VL,{lead:(0,h.jsx)(lQ,{selection:f,value:k9(e),label:e.name}),title:e.name,meta:(0,h.jsxs)(h.Fragment,{children:[HXe(e),` · deleted`,` `,(0,h.jsx)(`time`,{dateTime:e.deletedAt,title:t.full,children:t.short}),` `,`· `,UXe(e.daysLeft)]}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(K,{size:`small`,disabled:g,disabledReason:`Working on it`,onClick:()=>n.mutate([e]),children:`Restore`}),(0,h.jsx)(K,{size:`small`,variant:`destructive`,disabled:g,disabledReason:`Working on it`,onClick:()=>_(`Delete "${e.name}" for good?`,`Delete for good`,[e]),children:`Delete now`})]})},k9(e))})})]}),(0,h.jsx)(ME,{open:o!==void 0,title:o?.title??``,consequence:o===void 0?``:JXe(o.items),confirmLabel:o?.label??`Delete for good`,cancelLabel:o?.items.length===1?`Keep it`:`Keep them`,pending:r.isPending,onConfirm:v,onCancel:()=>{r.isPending||s(void 0)}})]})}var QXe=`https://slopify.stream/channel.html`;function $Xe(e){let t=document.createElement(`a`);t.href=`${e}/api/diagnostics`,t.download=`slopify-diagnostics.json`,document.body.append(t),t.click(),t.remove()}function eZe({onWhatsNew:e}){let{api:t,version:n}=q(),r=JI(()=>window.location.reload()),i=r.info,a=i?.currentVersion??n.loadedAt(),o=i?.status===`waiting`,s=r.updating||r.installing,c=o?void 0:i?.blockedReason,l=s?{tone:`running`,word:`Updating…`}:r.checking?{tone:`running`,word:`Checking for updates…`}:i===void 0?void 0:i.available?{tone:`info`,word:`Version ${i.latestVersion??``} is ready`}:{tone:`done`,word:`Up to date`};return(0,h.jsxs)(`div`,{className:`flex max-w-prose flex-col gap-6`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,h.jsx)(`p`,{className:`m-0 text-title-3 font-semibold text-ink`,children:a===void 0?`Slopify`:`Slopify ${a}`}),l===void 0?null:(0,h.jsx)(hE,{tone:l.tone,children:l.word})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i?.available===!0&&i.canUpdate&&!o?(0,h.jsx)(K,{variant:`primary`,disabled:s||c!==void 0,disabledReason:c,onClick:()=>r.install(),children:`Update to ${i.latestVersion??`the new version`}`}):o?(0,h.jsx)(K,{onClick:()=>r.cancel(),children:`Cancel the update`}):(0,h.jsx)(K,{disabled:s||r.checking,onClick:()=>r.refresh(),children:`Check for updates`}),e===void 0?null:(0,h.jsx)(K,{onClick:e,children:`Read what's new`})]}),r.error===void 0&&c===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-waiting`,children:r.error??c}),o?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`The update installs once the video being made finishes; Slopify then restarts and this page reconnects.`}):null]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`p`,{className:`m-0 font-semibold text-ink`,children:`Free. Your keys, your machine.`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Made by Gent Bajko. Apache License 2.0: anyone who redistributes Slopify or builds on it keeps this credit.`}),(0,h.jsx)(`p`,{className:`m-0 text-small`,children:(0,h.jsx)(`a`,{href:QXe,target:`_blank`,rel:`noreferrer`,className:`sl-link`,children:`How I run a channel with it ↗`})})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Something wrong?`,size:`small`,className:`pb-2`,children:(0,h.jsxs)(tE,{variant:`secondary`,href:`${t.origin}/api/diagnostics`,download:`slopify-diagnostics.json`,children:[(0,h.jsx)(vh,{"aria-hidden":`true`,strokeWidth:1.75}),`Download diagnostics`]})}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:BT(`settings.diagnostics`).body})]})]})}var A9=[`backups`],j9=1,M9=30;function N9(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function tZe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=j9&&Number(t)<=M9?void 0:`Keep between ${j9} and ${M9} backups.`}function nZe(e){return{enabled:e.config.enabled,time:e.config.time,keep:String(e.config.keep),folder:e.config.folder??``}}function rZe(){let{api:e}=q(),t=_(),n=Vx();return L({mutationFn:()=>ite(e),onSuccess:e=>{t.setQueryData(A9,e),n(`Backup started. Its result shows here when it finishes.`,`success`)}})}function iZe(){let{api:e}=q(),t=_(),n=I({queryKey:A9,queryFn:()=>rte(e),refetchInterval:e=>e.state.data?.running===!0&&2e3}),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=L({mutationFn:t=>km(e,t),onSuccess:e=>{t.setQueryData(A9,e),i(void 0),o(!0)}}),c=L({mutationFn:t=>km(e,t),onSuccess:e=>{t.setQueryData(A9,e),i(t=>t===void 0?void 0:{...t,enabled:e.config.enabled})}}),l=rZe();(0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),oB);return()=>clearTimeout(e)},[a]);let u=n.data,d=r??(u===void 0?void 0:nZe(u)),f=d===void 0?void 0:tZe(d.keep),p=r!==void 0&&u!==void 0&&!aZe(r,nZe(u)),g=()=>{d===void 0||f!==void 0||s.isPending||(o(!1),s.mutate({enabled:d.enabled,time:d.time,timeZone:N9(),keep:Number(d.keep.trim()),folder:d.folder.trim()===``?null:d.folder.trim()}))},v=e=>{d!==void 0&&i({...d,...e})},y=c.isPending?c.variables.enabled:u?.config.enabled===!0;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Daily backup`,meta:u===void 0?(0,h.jsx)(`span`,{className:`inline-block h-4 w-48 rounded-control bg-raised`}):(0,h.jsx)(`span`,{role:`status`,children:`${oZe(u)} ${sZe(u)}`.trim()}),children:(0,h.jsx)(K,{disabled:u===void 0||u.running||l.isPending,onClick:()=>l.mutate(),children:`Back up now`})}),(0,h.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3`,children:[u?.status.detail?u.status.lastResult===`failed`?(0,h.jsx)(IT,{tone:`danger`,title:`Why the last backup stopped`,children:u.status.detail}):(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:u.status.detail}):null,l.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:l.error.message}):null]}),n.error?(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The backup settings couldn't be read: `,n.error.message]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(dD,{label:`Back up automatically`,help:`Each backup holds every project with its videos, so it can be many gigabytes.`,checked:y,disabled:u===void 0||c.isPending,className:`self-start`,onChange:e=>{u!==void 0&&c.mutate({enabled:e,time:u.config.time,timeZone:N9(),keep:u.config.keep,folder:u.config.folder})}}),c.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The switch wasn't saved: ${c.error.message} Press it again.`}),y?(0,h.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(J,{label:`Time of day`,help:`${N9()} time. A backup waits while videos are being made.`,children:(0,h.jsx)(Y,{type:`time`,className:`w-[140px] tabular-nums`,value:d?.time??`03:00`,disabled:d===void 0,onChange:e=>v({time:e.target.value})})}),(0,h.jsx)(J,{label:`Keep last`,help:`The oldest backups beyond this number are deleted.`,error:f,children:(0,h.jsx)(Y,{type:`number`,inputMode:`numeric`,min:j9,max:M9,step:1,className:`w-[88px] tabular-nums`,value:d?.keep??`5`,disabled:d===void 0,onChange:e=>v({keep:e.target.value})})}),(0,h.jsx)(J,{label:`Folder`,className:`md:col-span-2`,...u===void 0?{}:{help:cZe(u)},children:(0,h.jsx)(Y,{value:d?.folder??``,placeholder:`Default folder`,disabled:d===void 0,onChange:e=>v({folder:e.target.value})})})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(K,{type:`submit`,variant:`primary`,disabled:!p||f!==void 0||s.isPending,disabledReason:f===void 0?`Nothing changed since the last save.`:f,children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(cB,{}):null}),(0,h.jsx)(KJ,{dirty:p,onDiscard:()=>{s.reset(),i(void 0)}}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 basis-full text-small text-danger`,children:s.error.message})]})]}):null]})]})}function aZe(e,t){return e.enabled===t.enabled&&e.time===t.time&&e.keep.trim()===t.keep.trim()&&e.folder.trim()===t.folder.trim()}function P9(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function oZe(e){if(e.running)return`Backing up now…`;let{status:t}=e,n=t.lastSuccessAt===null?`No backup yet.`:`Last backup ${P9(t.lastSuccessAt)}${t.lastSuccessBytes===null?``:`, ${n7(t.lastSuccessBytes)}`}.`;return t.lastResult===`failed`&&t.lastAttemptAt!==null?`${n} The backup at ${P9(t.lastAttemptAt)} failed.`:t.lastResult===`waiting`?`${n} Waiting for projects to finish.`:n}function sZe(e){return e.config.enabled?e.overdue?`Next: shortly.`:e.nextRunAt===null?``:`Next: ${P9(e.nextRunAt)}.`:``}function cZe(e){let t=e.files.length===0?``:`${e.files.length} backup${e.files.length===1?``:`s`} here (${n7(e.files.reduce((e,t)=>e+t.bytes,0))}).`;return e.hostFolder===null?`Inside Slopify's Docker volume, not on your computer. Leave Folder empty to save backups in the Backups folder on your computer. ${t}`.trim():`${e.config.folder===null?`Empty uses the default: `:`On your computer: `}${e.hostFolder}. ${t}`.trim()}var F9=X.storageUsage,lZe=[F9,X.projects,[`project`],X.usage,X.documentThemes,BO,X.playDrafts,X.settings,X.providers,X.voices,X.prompts,X.entries,X.staging,PM,wN,X.providerModels];async function uZe(e){await Promise.all(lZe.map(t=>e.invalidateQueries({queryKey:t})))}var dZe=`The backup wasn't imported. Check it is a file made with Export everything (.tar) or Export backup (.zip), then try again.`;function fZe(){let{api:e}=q(),t=_(),n=I({queryKey:F9,queryFn:()=>ute(e),staleTime:3e4}),r=I({queryKey:IE,queryFn:()=>UE(e)}),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)({phase:`idle`}),[c,l]=(0,m.useState)({phase:`idle`}),[u,d]=(0,m.useState)(null),f=Vx(),[p,g]=(0,m.useState)(null);async function v(){g(null),s({phase:`preparing`});try{let t=await nte(e);if(!t.ready){s({phase:`idle`}),g(t.detail??`The backup can't be made right now. Try again in a moment.`);return}s({phase:`downloading`,bytes:t.bytes??0,projects:t.projects??0});let n=document.createElement(`a`);n.href=`${e.origin}/api/storage/export`,n.download=``,document.body.append(n),n.click(),n.remove()}catch(e){s({phase:`idle`}),g(e instanceof Error?e.message:`The backup couldn't be prepared. Try again in a moment.`)}}async function y(n){let r=n.name.toLowerCase().endsWith(`.zip`)||n.type===`application/zip`;if(n.size===0||r&&n.size>104857600)g(r?`This file is empty or larger than 100 MB. Choose a .zip made with Export backup, or a .tar made with Export everything.`:`This file is empty. Choose the .tar made with Export everything.`);else{a(!0),g(null),d(null),l({phase:`uploading`,sent:0,total:n.size});try{let i=await e.upload(`${e.origin}/api/storage/import`,n,r?`application/zip`:`application/x-tar`,(e,t)=>{l(e>=t?{phase:`importing`}:{phase:`uploading`,sent:e,total:t})}),a=await i.json();if(!i.ok)throw Error(a.detail??dZe);a.projects===void 0?f(`Imported ${a.templates??0} template(s), ${a.fonts??0} uploaded font(s), and ${a.stagedFiles??0} staged file(s).${a.fontFallbacks?` ${a.fontFallbacks} missing legacy font reference(s) now use the default font.`:``}`,`success`):(d(a),f(`Backup imported.`,`success`)),await uZe(t)}catch(e){g(e instanceof Error?e.message:dZe)}finally{l({phase:`idle`}),a(!1)}}}async function b(){a(!0),g(null);try{let n=await e.fetch(`${e.origin}/api/storage/cleanup`,{method:`POST`}),r=await n.json();if(!n.ok)throw Error(`Clear leftover files didn't finish. Try again in a moment.`);f(`Cleared ${r.orphanFiles??0} leftover project file(s) and ${r.stagedFiles??0} unused upload(s).`,`success`),await t.invalidateQueries({queryKey:F9})}catch(e){g(e instanceof Error?e.message:`Clear leftover files didn't finish. Try again in a moment.`)}finally{a(!1)}}ND({id:`settings.export-everything`,title:`Export everything`,group:`Settings`,context:`Backup & storage`,keywords:[`backup`,`download`],run:()=>{!i&&o.phase!==`preparing`&&v()}});let x=i||o.phase===`preparing`,S=(0,m.useRef)(null);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(lD,{title:`Export and import`,meta:`Everything in one .tar file: projects, prompts, templates, schedules and settings.`,children:[(0,h.jsx)(K,{disabled:x,onClick:()=>void v(),children:`Export everything`}),(0,h.jsx)(K,{disabled:x,onClick:()=>S.current?.click(),children:`Import a backup`}),(0,h.jsx)(`input`,{ref:S,className:`sr-only`,type:`file`,tabIndex:-1,"aria-label":`Import a backup`,accept:`.tar,application/x-tar,.zip,application/zip`,disabled:x,onChange:e=>{let t=e.target.files?.[0];t&&y(t),e.target.value=``}}),(0,h.jsx)(K,{variant:`quiet`,disabled:x,onClick:()=>void b(),children:`Clear leftover files`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsxs)(`p`,{className:`m-0`,children:[`Keys are never in a backup: after importing, add them again on`,` `,(0,h.jsx)(eE,{to:`/settings`,search:{section:`providers`},children:`Keys & services`}),`. Importing only adds: it replaces nothing. Clear leftover files removes files no project uses.`]}),o.phase===`preparing`?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink`,children:`Preparing the backup…`}):null,o.phase===`downloading`?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 min-w-0 flex-1 text-ink`,children:[`Downloading `,n7(o.bytes),` (`,o.projects,` project`,o.projects===1?``:`s`,`). Your browser's downloads show its progress; keep Slopify running until it finishes.`]}),(0,h.jsx)(K,{variant:`quiet`,size:`small`,onClick:()=>s({phase:`idle`}),children:`Dismiss`})]}):null,c.phase===`uploading`?(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 text-ink tabular-nums`,children:[`Uploading the backup: `,n7(c.sent),` of `,n7(c.total)]}),(0,h.jsx)(o1,{progress:!0,label:`Backup upload`,value:c.total===0?0:c.sent/c.total})]}):null,c.phase===`importing`?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink`,children:`Checking and importing the backup… large projects can take a minute.`}):null,p?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-danger`,children:p}):null]})]}),u?(0,h.jsx)(gZe,{result:u,onDismiss:()=>d(null)}):null,(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Disk space`,meta:n.data?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`font-semibold text-ink`,children:[n7(n.data.data),` stored`]}),(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[` `,`· `,n7(Math.max(0,n.data.projects-n.data.trash.bytes)),` project files`,n.data.staging>0?` · ${n7(n.data.staging)} of uploads not used yet`:null,n.data.trash.projects>0?` · ${n7(n.data.trash.bytes)} in the trash (${hZe(n.data.trash.projects)}), freed when removed for good`:null]})]}):n.error?`Storage usage is unavailable. Reload the page to try again.`:(0,h.jsx)(`span`,{className:`inline-block h-4 w-48 rounded-control bg-raised`})}),n.data&&n.data.byProject.length>0?(0,h.jsx)(XGe,{projects:n.data.byProject,samples:new Set(Object.values(r.data?.samples??{}).filter(e=>e!==null)),queryKey:[...F9]}):null,(0,h.jsx)(mZe,{})]})]})}var pZe={library:`The Library of Alexandria`,audiobook:`The Wind in the Willows`,podcast:`The Antikythera Mechanism`};function mZe(){let{api:e}=q(),t=_(),n=I({queryKey:IE,queryFn:()=>UE(e)}),r=L({mutationFn:()=>i_e(e),onSettled:async()=>{await t.invalidateQueries({queryKey:IE}),await t.invalidateQueries({queryKey:FE}),await t.invalidateQueries({queryKey:X.projects}),await t.invalidateQueries({queryKey:F9})}}),i=r.data?.samples??n.data?.samples,a=i===void 0?[]:Object.keys(pZe).filter(e=>i[e]===null).map(e=>pZe[e]);return(0,h.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(K,{size:`small`,disabled:r.isPending,onClick:()=>r.mutate(),children:r.isPending?`Restoring…`:`Restore samples`}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:a.length===0?`Puts the three finished examples back as they shipped.`:`Brings back ${a.join(`, `)}, and the others as they shipped.`})]}),(0,h.jsx)(lL,{tone:r.error?`error`:`success`,children:r.error?.message??(r.isSuccess?`The samples are back in Projects.`:void 0)})]})}function hZe(e){return e===1?`1 deleted project`:`${String(e)} deleted projects`}function I9(e,t){if(t===void 0)return null;let n=[t.added>0?`${t.added} added`:null,t.renamed>0?`${t.renamed} added as “(imported)” because the name was taken`:null,t.skipped>0?`${t.skipped} already here`:null].filter(e=>e!==null);return n.length===0?null:`${e}: ${n.join(`, `)}.`}function gZe({result:e,onDismiss:t}){let n=[e.projects.imported.length>0?`Projects: ${e.projects.imported.length} added (${n7(e.files.bytes)} of files).`:`Projects: none added.`,I9(`Prompts`,e.prompts),I9(`Intros and outros`,e.entries),I9(`Channels`,e.channels),I9(`Cast members`,e.cast),I9(`Episode memories`,e.episodeMemories),I9(`Titles to avoid`,e.channelVideos),I9(`PDF looks`,e.documentThemes),I9(`Templates`,e.templates),I9(`Schedules`,e.schedules),e.schedules.paused>0?`${e.schedules.paused} schedule(s) arrived paused so two installs never run them both; resume them in Calendar → Schedules.`:null,I9(`Voices`,e.voices),I9(`Saved drafts`,e.drafts),I9(`Designs`,e.designs),I9(`Poster templates`,e.designTemplates),e.settings.added+e.settings.kept>0?`Settings: ${e.settings.added} filled in${e.settings.kept>0?`, ${e.settings.kept} kept as this install has them`:``}.`:null,e.fonts>0?`Uploaded fonts: ${e.fonts} added.`:null,e.usage.alreadyImported?`Usage: this backup's history was already added before, so it wasn't counted twice.`:`Usage: ${e.usage.events} recorded event(s) added to the totals.`,`Keys are not in backups: add them again in Settings → Keys & services.`].filter(e=>e!==null);return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{as:`h3`,title:`Imported the backup from ${e.backup.createdAt.slice(0,10)}`,children:(0,h.jsx)(K,{variant:`quiet`,size:`small`,onClick:t,children:`Dismiss`})}),(0,h.jsxs)(`ul`,{"aria-label":`Import result`,className:`m-0 list-disc pl-5 text-small text-ink-2`,children:[n.map(e=>(0,h.jsx)(`li`,{className:`py-0.5`,children:(0,h.jsx)(AE,{text:e})},e)),e.projects.skipped.map(e=>(0,h.jsxs)(`li`,{className:`py-0.5`,children:[`Skipped “`,e.title,`”: `,e.reason]},e.id))]})]})}var _Ze=[`storage-files`];function vZe({usageQueryKey:e}){let{api:t}=q(),n=_(),r=Vx(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(),u=I({queryKey:_Ze,queryFn:()=>dte(t),refetchInterval:e=>bZe(e.state.data)?1e3:!1}),d=L({mutationFn:e=>fte(t,e),onMutate:()=>l(void 0),onSuccess:e=>{n.setQueryData(_Ze,e),a(!1)},onError:e=>l(e.message)}),f=L({mutationFn:()=>pte(t),onSuccess:e=>{e.opened||r(`Your files are in ${e.path}.`,`info`)},onError:e=>r(e.message,`error`)}),p=u.data,g=bZe(p),v=p?.move?.phase;if((0,m.useEffect)(()=>{v===`done`&&n.invalidateQueries({queryKey:e})},[v,n,e]),p===void 0)return(0,h.jsx)(`div`,{children:(0,h.jsx)(lD,{title:`Your files`,meta:u.error?`Where your files are is unavailable. Reload the page to try again.`:`Loading…`})});if(p.docker)return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Your files`,meta:p.folder===null?`The Docker project folder isn't set up.`:`Where your projects and exports are kept.`,children:(0,h.jsx)(K,{disabled:p.folder===null||f.isPending,onClick:()=>f.mutate(),children:`Open folder`})}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsx)(yZe,{view:p}),p.dockerCommand===null?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{className:`m-0`,children:[`Slopify runs in Docker, which can't move its own folders. To move your projects to Documents/Slopify, run this on the computer running Docker (or use`,` `,(0,h.jsx)(QT,{children:`--projects-dir <folder>`}),` for another folder):`]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(QT,{className:`min-w-0 break-all`,children:p.dockerCommand}),(0,h.jsx)(K,{variant:`quiet`,size:`small`,onClick:()=>{let e=p.dockerCommand??``;navigator.clipboard.writeText(e).then(()=>r(`Command copied.`,`success`)).catch(()=>r(`Copying failed: this browser doesn't allow it here. Select the command and copy it yourself.`,`error`))},children:`Copy command`})]})]})]})]});let y=v===`failed`||v===`interrupted`;return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(lD,{title:`Your files`,meta:`Where your projects and exports are kept.`,children:[p.inDocuments||p.documentsRoot===null?null:(0,h.jsx)(K,{variant:`secondary`,disabled:g||d.isPending,onClick:()=>d.mutate(`documents`),children:`Move to Documents/Slopify`}),(0,h.jsx)(K,{disabled:f.isPending,onClick:()=>f.mutate(),children:`Open folder`}),(0,h.jsx)(K,{variant:`quiet`,disabled:g||d.isPending,onClick:()=>{a(e=>!e),l(void 0)},children:`Choose another folder`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 text-small text-ink-2`,children:[(0,h.jsx)(yZe,{view:p}),(0,h.jsx)(`p`,{className:`m-0`,children:`Your keys, settings and the database stay in Slopify's own folder. A move copies every file and checks it before switching, and keeps the old folder until you delete it.`}),i?(0,h.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),d.mutate(o)},children:[(0,h.jsx)(J,{label:`New folder`,tip:`settings.files.new-folder`,help:`The full path; it must be empty or new.`,error:c,className:`min-w-0 flex-1 basis-80`,children:(0,h.jsx)(Y,{value:o,placeholder:p.documentsRoot??`/home/you/Videos/Slopify`,onChange:e=>s(e.target.value)})}),(0,h.jsx)(K,{type:`submit`,disabled:o.trim()===``||d.isPending,children:`Move here`})]}):c===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-danger`,children:c}),p.move===null?null:g?(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 text-ink tabular-nums`,children:[p.move.phase===`copying`?`Copying`:`Checking the copy of`,` your files to`,` `,p.move.target,`: `,p.move.files,` of `,p.move.totalFiles,` files (`,n7(p.move.bytes),` of `,n7(p.move.totalBytes),`). Keep Slopify running until it finishes.`]}),(0,h.jsx)(o1,{progress:!0,label:p.move.phase===`copying`?`Files copied`:`Files checked`,value:p.move.totalBytes===0?0:p.move.bytes/p.move.totalBytes})]}):y?(0,h.jsx)(IT,{tone:v===`failed`?`danger`:`waiting`,title:v===`failed`?`Moving your files to ${p.move.target} stopped`:`Moving your files to ${p.move.target} didn't finish`,actions:(0,h.jsx)(K,{disabled:d.isPending,onClick:()=>d.mutate(p.move?.target??``),children:`Continue moving`}),children:p.move.error??`Slopify was stopped before the copy was checked, so it still uses the old folder. Continue moving picks up where it left off.`}):v===`done`&&p.move.oldFolder!==null?(0,h.jsxs)(IT,{tone:`info`,title:`Your files are now in ${p.move.target}`,children:[`Every file was copied and checked. The old folder `,p.move.oldFolder,` still has a copy; once your projects open fine, you can delete it to free the space.`]}):null]})]})}function yZe({view:e}){let t=[[`Projects`,e.projects],[`Exports`,e.exports]].filter(e=>e[1]!==null);return(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:t.map(([e,t])=>(0,h.jsxs)(`div`,{className:`contents`,children:[(0,h.jsx)(`dt`,{className:`text-ink-3`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 break-all`,children:t})]},e))})}function bZe(e){return e?.move?.phase===`copying`||e?.move?.phase===`verifying`}var L9=30,xZe=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}],SZe=[{value:`cpu`,label:`Processor (x264)`},{value:`nvidia`,label:`NVIDIA graphics card (NVENC)`}],CZe=[{value:`thorough`,label:`Thorough`},{value:`fast`,label:`Fast`}],wZe=[{value:`normal`,label:`Normal`},{value:`background`,label:`Background (your other programs come first)`}],TZe=[{value:1,label:`One at a time (recommended)`},{value:2,label:`Two`},{value:3,label:`Three`},{value:4,label:`Four`}];function EZe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=L9?void 0:`The silence gap is a whole number of seconds between 0 and ${String(L9)}.`}function DZe(){let{api:e}=q(),t=_();return L({mutationFn:t=>Dte(e,t),onMutate:e=>{let n=t.getQueryData(X.settings);return t.setQueryData(X.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(X.settings,r.previous)},onSuccess:e=>{t.setQueryData(X.settings,e)}})}function OZe(){let{api:e}=q(),t=I(aD(e));return t.error===null?t.data===void 0?{view:(0,h.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,role:`status`,"aria-label":`Loading settings`,children:[(0,h.jsx)(`span`,{className:`h-16 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-16 rounded-control bg-raised`})]})}:{data:t.data}:{view:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:t.error.message})}}function kZe(){let{data:e,view:t}=OZe(),n=DZe(),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1);if((0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),oB);return()=>clearTimeout(e)},[a]),e===void 0)return t??(0,h.jsx)(`span`,{});let s=e,c=r??String(s.silenceGapSeconds),l=EZe(c);return(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(J,{label:`Silence between segments`,help:`Seconds of quiet between the intro, the narration and the outro of new videos; 0 runs them together.`,error:l??n.error?.message,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(Y,{type:`number`,inputMode:`numeric`,min:0,max:L9,step:1,className:`w-[88px] tabular-nums`,value:c,"aria-invalid":l!==void 0,onChange:e=>{i(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`seconds`}),(0,h.jsx)(K,{variant:`primary`,disabled:l!==void 0||n.isPending||Number(c.trim())===s.silenceGapSeconds,disabledReason:l??`Nothing changed since the last save.`,onClick:()=>{o(!1),n.mutate({...s,silenceGapSeconds:Number(c.trim())},{onSuccess:()=>{i(void 0),o(!0)}})},children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(cB,{}):null})]})}),(0,h.jsx)(J,{label:`Caption timing model`,help:`Bigger hears the narration more accurately and, on most computers, is also faster. It downloads once, the first time captions are timed.`,error:n.error&&n.variables?.subtitleModel!==s.subtitleModel?`The caption timing model wasn't saved. ${n.error.message}`:void 0,children:(0,h.jsx)(ZT,{className:`self-start`,value:s.subtitleModel??`fp32`,options:i3,onChange:e=>{let t=i3.find(t=>t.value===e.target.value);t!==void 0&&n.mutate({...s,subtitleModel:t.value})}})}),(0,h.jsx)(`div`,{className:`md:col-span-2`,children:(0,h.jsx)(U4,{value:s.loudness??zk,switchLabel:`Level the volume for new runs`,switchTip:null,switchHelp:`Evens out the narration and sets new videos to the loudness YouTube plays at. A project keeps what it started with.`,onChange:e=>{n.mutate({...s,loudness:e})}})}),(0,h.jsx)(AZe,{current:s,save:n})]})}function AZe({current:e,save:t}){let{api:n}=q(),r=I(u_e(n)),i=e.videoEncoder??`cpu`,a=r.data?.nvidia,o=SZe.filter(e=>e.value===`cpu`||a?.available===!0||i===`nvidia`),s=a===void 0?`Checking for an NVIDIA graphics card…`:a.available?`The graphics card takes most of the work off the processor, for a slightly softer picture than x264.`:i===`nvidia`?`Videos are encoded on the processor until this is fixed. ${a.reason}`:`${a.reason} Videos are encoded on the processor.`,c=a?.available===!1?a.detail:void 0,l=(n,r)=>t.error&&t.variables?.[n]!==e[n]?`The ${r} wasn't saved. ${t.error.message}`:void 0;return(0,h.jsxs)(`div`,{className:`grid gap-4 md:col-span-2`,...GT,children:[(0,h.jsx)(lD,{as:`h3`,title:`Encoding`,meta:`How this computer turns videos and shorts into files. Changing these never marks anything outdated.`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-3`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,h.jsx)(J,{label:`Video encoder`,help:s,error:l(`videoEncoder`,`video encoder`),children:(0,h.jsx)(ZT,{className:`self-start`,value:i,options:o,onChange:n=>{let r=SZe.find(e=>e.value===n.target.value);r!==void 0&&t.mutate({...e,videoEncoder:r.value})}})}),c===void 0?null:(0,h.jsx)(SR,{summary:`Details`,children:(0,h.jsx)(`p`,{className:`m-0 pt-1 font-mono text-small break-words text-ink-2`,children:c})})]}),(0,h.jsx)(J,{label:`Clip encoding`,help:jZe,error:l(`clipEncodeSpeed`,`clip encoding`),children:(0,h.jsx)(ZT,{className:`self-start`,value:e.clipEncodeSpeed??`thorough`,options:CZe,onChange:n=>{let r=CZe.find(e=>e.value===n.target.value);r!==void 0&&t.mutate({...e,clipEncodeSpeed:r.value})}})}),(0,h.jsx)(J,{label:`Videos rendered at once`,help:`A second video waits until the first has finished. More at once share one computer, so each takes longer and the app has less left to answer with.`,error:l(`videoRenderConcurrency`,`videos rendered at once`),children:(0,h.jsx)(ZT,{className:`self-start`,value:String(e.videoRenderConcurrency??1),options:TZe.map(e=>({value:String(e.value),label:e.label})),onChange:n=>{let r=TZe.find(e=>String(e.value)===n.target.value);r!==void 0&&t.mutate({...e,videoRenderConcurrency:r.value})}})}),(0,h.jsx)(J,{label:`Encoding priority`,help:`Background lets your other programs run first; a video takes longer to make while they are busy.`,error:l(`renderPriority`,`encoding priority`),children:(0,h.jsx)(ZT,{className:`self-start`,value:e.renderPriority??`background`,options:wZe,onChange:n=>{let r=wZe.find(e=>e.value===n.target.value);r!==void 0&&t.mutate({...e,renderPriority:r.value})}})})]})]})}var jZe=`Fast uses about half the processor time for the clips under burned-in captions, for a slightly softer picture.`;function MZe(){let{data:e,view:t}=OZe(),n=DZe();if(e===void 0)return t??(0,h.jsx)(`span`,{});let r=e;return(0,h.jsxs)(`div`,{className:`sl-field`,children:[(0,h.jsx)(`span`,{className:`sl-field__label`,children:`Appearance`}),(0,h.jsx)(fD,{label:`Appearance`,help:`System follows your computer's light or dark setting. Your videos are not affected.`,value:r.appearance,options:xZe,className:`self-start`,onChange:e=>{n.mutate({...r,appearance:e})}}),n.error?(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The appearance wasn't saved. `,n.error.message]}):null]})}var NZe=[{family:`llm`,label:ZD.article,setUp:`Set up a writing service`,lacking:`No writing service yet, so nothing can write the article, title or description.`},{family:`tts`,label:ZD.audio,setUp:`Set up a voice service`,lacking:`No voice service yet, so videos have no narration.`},{family:`image`,label:ZD.images,setUp:`Set up an image service`,lacking:`No image service yet, so videos have no pictures.`}],PZe=`openai-tts`,FZe={ready:`Ready`,"no-key":`No key`,"no-voice":`No voice saved`};function IZe(e,t,n){let r=e===`llm`?n?.llm:e===`image`?n?.images:void 0;return t.find(e=>e.id===r?.provider)?.displayName}function LZe(e,t){return e.readiness.kind===`local`||e.id===PZe||t.some(t=>t.provider===e.id)}function RZe(e,t,n=[]){return NZe.map(({family:r,label:i,setUp:a,lacking:o})=>{let s=e.filter(e=>e.family===r&&oN(e.readiness)),c=r===`tts`?s.filter(e=>LZe(e,n)):s;if(c.length===0){let e=r===`tts`?s:[],t=e[0];return t===void 0?{family:r,label:i,state:`no-key`,text:o,action:{kind:`set-up`,words:a}}:{family:r,label:i,state:`no-voice`,text:`${e.map(e=>e.displayName).join(`, `)} ${e.length===1?`has`:`have`} a key but no voice saved yet, so videos have no narration.`,action:{kind:`voices`,words:`Save a voice`,provider:t.id}}}let l=IZe(r,c,t);return{family:r,label:i,state:`ready`,text:[...l===void 0?[]:[`${l} (Create picks it)`],...c.map(e=>e.displayName).filter(e=>e!==l)].join(`, `)}})}function zZe({health:e,onShow:t,back:n}){let{api:r}=q(),i=I(QE(r)),a=I($E(r)),o=I(Rxe(r));return i.data===void 0||a.isPending?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(`ul`,{"aria-label":`What your videos have`,className:`sl-list m-0 list-none p-0`,children:RZe(i.data.providers,o.data?.defaults,a.data?.voices??[]).map(e=>(0,h.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1 border-b border-line py-2 md:grid md:grid-cols-[88px_136px_minmax(0,1fr)_auto]`,children:[(0,h.jsx)(`span`,{className:`w-[88px] shrink-0 font-semibold text-ink md:w-auto`,children:e.label}),(0,h.jsx)(hE,{tone:e.state===`ready`?`done`:`waiting`,children:FZe[e.state]}),(0,h.jsx)(`span`,{className:G(`min-w-0 text-small text-ink-2 max-md:hidden`,e.state===`ready`&&`truncate`),title:e.state===`ready`?e.text:void 0,children:e.text}),e.action===void 0?null:e.action.kind===`voices`?(0,h.jsx)($T,{size:`small`,className:`justify-self-start max-md:ml-auto`,to:`/settings`,search:{section:`voices`,provider:e.action.provider,...zR(n)},children:e.action.words}):t===void 0?null:(0,h.jsx)(K,{size:`small`,className:`justify-self-start max-md:ml-auto`,onClick:()=>t(e.family),children:e.action.words})]},e.family))}),e===void 0?null:(0,h.jsx)($qe,{run:e})]})}function BZe(){let{api:e}=q(),t=I(l_e(e));return(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[t.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:t.error.message}),t.data===void 0?t.error===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(JZe,{cells:5}),(0,h.jsx)(YZe,{})]}):null:(0,h.jsx)(UZe,{usage:t.data})]})}var VZe=[{id:`stage`,header:`Part`,cell:e=>ZD[e.stage]},{id:`model`,header:`Service · model`,cell:e=>WZe(e)},{id:`in`,header:`Read`,numeric:!0,cell:e=>iE.format(e.tokensIn)},{id:`out`,header:`Written`,numeric:!0,cell:e=>iE.format(e.tokensOut)}];function HZe(e){return e.machineId===null?`Nothing is counted until you press Start counting · Slopify ${e.appVersion}`:`This computer's random number: ${e.machineId} · Slopify ${e.appVersion}`}function UZe({usage:e}){return Object.values(e.counters).every(e=>e===0)&&e.byStage.length===0?(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(ZR,{title:`Nothing made yet`,actions:(0,h.jsx)($T,{variant:`primary`,to:`/play`,children:`Make your first video`}),children:`After your first video, this page shows what this computer made and how much text the AI read and wrote for it.`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:HZe(e)})]}):(0,h.jsxs)(Z0,{split:`even`,children:[(0,h.jsxs)(Q0,{children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(i1,{children:qZe(e).map(e=>(0,h.jsx)(a1,{label:e.label,value:e.value},e.label))}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`AI text is counted in tokens: pieces of about three quarters of a word.`})]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:HZe(e)})]}),e.byStage.length===0?null:(0,h.jsx)(Q0,{children:(0,h.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,h.jsx)(s1,{caption:`AI text by part of the video`,columns:VZe,rows:e.byStage,rowKey:e=>`${e.stage}/${e.provider}/${e.model??``}`,className:`min-w-[480px] [&_td]:pr-4 [&_th]:pr-4`})})})]})}function WZe(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var GZe=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),KZe=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function qZe(e){let t=e.counters;return[{label:`Videos made`,value:iE.format(t.videosMade)},{label:`Hours of narration`,value:GZe.format(t.audioSeconds/3600)},{label:`Images made`,value:iE.format(t.imagesMade)},{label:`AI text read and written`,value:t.tokensUsed<1e6?iE.format(t.tokensUsed):KZe.format(t.tokensUsed)},{label:`Projects`,value:iE.format(t.projects)}]}function JZe({cells:e}){return(0,h.jsx)(`div`,{className:`sl-stats`,children:Array.from({length:e},(e,t)=>t).map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`h-8 w-20 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-sunken`})]},e))})}function YZe(){return(0,h.jsx)(`div`,{className:`border-t border-line`,children:[0,1,2,3].map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-line py-3`,children:[(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-56 max-w-[40%] rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-20 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-sunken`})]},e))})}function XZe({section:e=`providers`,note:t,family:n,provider:r,back:i,onSection:a=()=>{},onNote:o=()=>{}}){let{api:s}=q(),c=_(),l=Ji(),u=Vx(),d=I(xD(s)),f=d.data!==void 0&&d.data.length<2,p=q7(),g=rZe(),v=OE(e),y=EE.find(e=>e.id===v)??EE[0];return ND({id:`settings.check-providers`,title:`Check every service`,group:`Settings`,keywords:[`health`,`keys`,`signed in`,`providers`],run:()=>{a(`providers`),p.mutate()}}),ND({id:`settings.back-up-now`,title:`Back up now`,group:`Settings`,keywords:[`backup`],run:()=>{a(`storage`),g.mutate(void 0,{onError:e=>{u(`The backup didn't start: ${e.message} Open Settings → Backup & storage to see its state.`,`error`)}})}}),ND({id:`settings.download-diagnostics`,title:`Download diagnostics`,group:`Settings`,keywords:[`support`,`bug report`],run:()=>{$Xe(s.origin)}}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(fL,{crumb:`Settings`,title:y.label,meta:y.meta,actions:i===void 0?void 0:(0,h.jsx)(VR,{back:i,children:`Back to ${RR(i)}`})}),(0,h.jsx)(pL,{sections:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(tz,{label:`Settings pages`,className:`max-md:hidden`,children:EE.map((e,t)=>(0,h.jsxs)(m.Fragment,{children:[(0,h.jsx)(iz,{current:e.id===v,onClick:()=>a(e.id),className:G(ZZe,t>0&&EE[t-1]?.run!==e.run&&`mt-3`),children:e.label}),f&&e.id===QZe?(0,h.jsx)(rz,{to:`/channels`,className:ZZe,children:eQe}):null]},e.id))}),(0,h.jsx)(ZT,{"aria-label":`Settings page`,className:`w-full md:hidden`,value:v,options:EE.flatMap(e=>[{value:e.id,label:e.label},...f&&e.id===QZe?[{value:$Ze,label:eQe}]:[]]),onChange:e=>{e.target.value===$Ze?l({to:`/channels`}):a(OE(e.target.value))}})]}),children:(0,h.jsxs)(`section`,{"aria-label":y.label,className:`flex min-w-0 flex-col gap-4`,children:[v===`providers`?(0,h.jsx)(tQe,{family:n,provider:r,back:i,health:p}):null,v===`voices`?(0,h.jsx)(PJe,{provider:r,back:i}):null,v===`models`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(AIe,{}),(0,h.jsx)(Gqe,{}),(0,h.jsx)(Kqe,{})]}):null,v===`playback`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(kZe,{}),(0,h.jsx)(lD,{title:`PDF look`,meta:`The fonts, colors and page layout of the PDFs Slopify makes.`,children:(0,h.jsx)($T,{to:`/document-themes`,children:`Edit PDF looks`})}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(lD,{title:`Template samples`,meta:`What a template's samples may spend while you edit it.`}),(0,h.jsx)(PXe,{})]})]}):null,v===`notifications`?(0,h.jsx)(HJe,{}):null,v===`studio`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(nje,{}),(0,h.jsx)(CPe,{})]}):null,v===`storage`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(iZe,{}),(0,h.jsx)(vZe,{usageQueryKey:F9}),(0,h.jsx)(fZe,{})]}):null,v===`trash`?(0,h.jsx)(ZXe,{}):null,v===`general`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(MZe,{}),(0,h.jsx)(h_e,{})]}):null,v===`remote-access`?(0,h.jsx)(MYe,{}):null,v===`agents`?(0,h.jsx)(Hqe,{}):null,v===`about`?(0,h.jsx)(eZe,{onWhatsNew:()=>{c.fetchQuery(NI(s)).then(e=>o(e.current??void 0),e=>{u(`What's new did not open: ${e instanceof Error?e.message:String(e)} Open Settings → What's new to try again.`,`error`)})}}):null,v===`usage`?(0,h.jsx)(BZe,{}):null,v===`patch-notes`?(0,h.jsx)(qJe,{note:t,onNote:o}):null]})})]})}var ZZe=`h-auto min-h-9 py-1.5 [&>.truncate]:whitespace-normal`,QZe=`studio`,$Ze=`your-channel`,eQe=`Your channel ↗`;function tQe({family:e,provider:t,back:n,health:r}){let[i,a]=(0,m.useState)(()=>e===void 0&&t===void 0?void 0:{family:e,provider:t,arrival:!0});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(zZe,{health:r,back:n,onShow:e=>a({family:e,provider:void 0,arrival:!1})}),(0,h.jsx)(CJe,{focus:i,back:n})]})}function nQe({open:e,onClose:t,onInstalled:n}){let{api:r}=q(),i=_(),a=I({queryKey:FE,queryFn:()=>zE(r),enabled:e}),o=L({mutationFn:e=>HE(r,e),onSuccess:()=>n(),onSettled:()=>i.invalidateQueries({queryKey:FE})});return(0,h.jsxs)(LT,{open:e,title:`Add starter templates`,onClose:t,footer:(0,h.jsx)(lL,{tone:o.error||a.error?`error`:`success`,children:o.error?.message??a.error?.message??(o.data===void 0?void 0:o.data.added?`Added: its prompts are in Prompts and its template is in this list.`:`That starter template was already added.`)}),children:[(0,h.jsx)(`p`,{className:`m-0 mb-4 text-small text-ink-2`,children:`Each adds prompts, a suggested voice and a template for one kind of channel. It never replaces a prompt or template of yours.`}),(0,h.jsxs)(BL,{label:`Starter templates`,className:`sl-list--wrap-meta`,children:[(a.data?.packs??[]).map(e=>(0,h.jsx)(VL,{title:e.name,meta:e.summary,actions:e.installed?(0,h.jsx)(hE,{tone:`done`,children:`Added`}):(0,h.jsx)(K,{disabled:o.isPending,onClick:()=>o.mutate(e.id),children:`Add template`})},e.id)),a.data===void 0?(0,h.jsx)(VL,{title:`Loading starter templates…`}):null]})]})}function rQe(e,t){let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),URL.revokeObjectURL(n)}function iQe(e,t){let{api:n}=q(),[r,i]=(0,m.useState)(!1),a=e.runnableVersion,o=a===null||a===e.template.version?`Export as a file (.zip)`:`Export version ${String(a)} as a file (.zip)`,s=r?`making it`:a===null?`approve a version first`:void 0;async function c(){i(!0),t(void 0);try{let r=await vXe(n,e.template.id);r.ok?rQe(r.filename,r.blob):t(r.message)}catch(e){t(`The file wasn't made: ${e instanceof Error?e.message:String(e)} Choose Export as a file again.`)}finally{i(!1)}}return{label:o,blocker:s,save:c}}function aQe(e){let t=e.renamed.length===0?``:` ${e.renamed.map(e=>`"${e.from}" came in as "${e.to}"`).join(`, `)}, because Prompts already has other text under ${e.renamed.length===1?`that name`:`those names`}.`,n=e.voiceKnown?``:` Its voice isn't in your Settings → Voices: its Narration check says what to do.`;return`Imported ${e.name}. Look over its samples, then press Make a video.${t}${n}`}function oQe(){let{api:e}=q(),t=_(),n=Ji(),r=Vx(),i=(0,m.useRef)(null),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(null);async function l(a){o(!0),c(null);try{let i=await bXe(e,a);if(!i.ok){c(i.message);return}await t.invalidateQueries({queryKey:PM}),r(aQe(i.value),`success`),await n({to:`/templates/$templateId`,params:{templateId:i.value.templateId},search:{}})}catch(e){c(`The template wasn't imported: ${e instanceof Error?e.message:String(e)} Choose the file again.`)}finally{o(!1),i.current!==null&&(i.current.value=``)}}return{choose:()=>i.current?.click(),busy:a,problem:s,input:(0,h.jsx)(`input`,{ref:i,type:`file`,accept:`.zip,application/zip`,"aria-hidden":`true`,className:`sr-only`,tabIndex:-1,onChange:e=>{let t=e.target.files?.[0];t!==void 0&&l(t)}})}}function sQe({templateId:e}){let{api:t}=q(),n=I(SXe(t,e)).data?.samples??[];if(n.length===0)return null;let r=e=>`${t.origin}${e}`,i=n.filter(e=>e.role!==`narration`),a=n.find(e=>e.role===`narration`);return(0,h.jsxs)(`section`,{"aria-label":`Samples it came with`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(lD,{title:`Samples it came with`,as:`h3`,size:`small`,meta:`Made by whoever shared it. Your own samples replace these once you make them.`}),i.length===0?null:(0,h.jsx)(dR,{density:`compact`,list:!0,label:`Images it came with`,children:i.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsx)(uR,{src:r(e.url),alt:e.role===`thumbnail`?`The thumbnail it came with`:`An image it came with: ${e.name}`,title:e.role===`thumbnail`?`Thumbnail`:`Image`})},e.url))}),a===void 0?null:(0,h.jsx)(w6,{src:r(a.url),label:`The narration it came with`,compact:!0})]})}var cQe={"16:9":`Landscape 16:9`,"9:16":`Vertical 9:16`,"1:1":`Square 1:1`},lQe={off:`no captions`,"burn-in":`captions on the video`,files:`captions as a file`};function uQe(e,t){return[e.video?cQe[e.format]:`Narration only`,e.voice===null?void 0:`Voice: ${e.voice.name}, ${t(e.voice.provider)}`,e.words===null?void 0:`about ${e.words.toLocaleString(`en-US`)} words`,e.video?lQe[e.captions]:void 0,e.shorts===0?void 0:`${String(e.shorts)} ${e.shorts===1?`short`:`shorts`}`,e.pdf?`a PDF`:void 0].filter(e=>e!==void 0).join(` · `)}async function dQe(e,t,n,r){let i=await rxe(e,t.id,{baseVersion:t.version,mutationId:r,...n});if(!i.ok)throw Error(i.message);return i.value}function fQe({template:e,onClose:t}){let{api:n}=q(),r=_(),i=Array.from({length:e.version},(t,n)=>e.version-n),a=rt({queries:i.map(t=>({queryKey:[...PM,e.id,`version`,t],queryFn:async()=>{let r=await zM(n,e.id,t);if(!r.ok)throw Error(r.message);return r.value},staleTime:1/0}))}),o=a[0]?.data,[s,c]=(0,m.useState)(i[1]??e.version),l=a[i.indexOf(s)]?.data,u=(0,m.useRef)(crypto.randomUUID()),d=Vx(),f=L({mutationFn:t=>dQe(n,e,{name:t.name,document:t.document},u.current),onSuccess:async(n,i)=>{u.current=crypto.randomUUID(),d(`Restored version ${String(i.version)} of ${e.name} as version ${String(n.version)}.`,`success`),await r.invalidateQueries({queryKey:PM}),t()}}),p=a.find(e=>e.error!==null)?.error;return(0,h.jsx)(LT,{open:!0,title:`Versions of ${e.name}`,onClose:t,className:`sm:w-[min(1080px,100vw)]`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[p?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:`A version couldn't be read: ${p.message} Close Versions and open it again.`}):null,(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(lD,{title:`Versions`,as:`h3`,meta:`Restore saves an older one again as a new version, so nothing is lost.`}),(0,h.jsx)(BL,{label:`Versions of ${e.name}`,children:i.map((t,n)=>{let r=a[n]?.data;return(0,h.jsx)(VL,{title:`Version ${String(t)}`,selected:t===s,onSelect:()=>c(t),meta:r===void 0?`Loading…`:(0,h.jsxs)(h.Fragment,{children:[`${r.name} · `,(0,h.jsx)(p0,{iso:r.updatedAt,children:d0(r.updatedAt)})]}),actions:t===e.version?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Current`}):(0,h.jsx)(K,{size:`small`,"aria-label":`Restore version ${String(t)}`,disabled:r===void 0||f.isPending,disabledReason:r===void 0?`Reading the version`:`Restoring`,onClick:()=>{r!==void 0&&f.mutate(r)},children:`Restore`})},t)})}),(0,h.jsx)(lL,{tone:`error`,children:f.error===null?void 0:`The version wasn't restored: ${f.error.message}`})]}),(0,h.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(lD,{title:`Compare with the current version`,as:`h3`}),o===void 0||l===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Loading the versions…`}):l.version===o.version?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.version===1?`This is the only version so far.`:`Pick an older version in the list to compare it.`}):(0,h.jsxs)(h.Fragment,{children:[l.name===o.name?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Renamed from "${l.name}" to "${o.name}".`}),(0,h.jsx)(o0,{before:pQe(l),after:pQe(o),beforeLabel:`Version ${String(l.version)}`,afterLabel:`Version ${String(o.version)} (current)`})]})]})]})})}function pQe(e){return JSON.stringify(e.document,null,1).split(`
|
|
458
458
|
`).map(e=>e.trim()).filter(e=>!/^[[\]{}],?$/u.test(e)).join(`
|
|
459
|
-
`)}function pQe(e){return e===`posters`?`posters`:`videos`}var mQe=7;function hQe({tab:e=`videos`,onTab:t,item:n,...r}){let{api:i}=q(),a=_(),o=I(RM(i)),s=I(GYe(i)),c=I(xD(i)),l=$R(),[u,d]=(0,m.useState)(!1),f=aQe(),[p,g]=(0,m.useState)(e),v=t===void 0?p:e,y=e=>t===void 0?g(e):t(e);ND({id:`templates.add-starters`,title:`Add starter templates`,group:`Templates`,keywords:[`template`,`starter`,`pack`],run:()=>d(!0)});let b=o.data?.length,x=I(NL(i)),S=I({queryKey:FE,queryFn:()=>zE(i)}).data?.packs.every(e=>e.installed)===!0;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(fL,{title:`Templates`,meta:v===`videos`?`A template is a saved setup. Make a video from one, or edit what it makes.`:`A poster template is a saved poster with keywords. Make a poster from one, or edit what it makes.`,actions:v===`videos`?(0,h.jsxs)(h.Fragment,{children:[b===0||S?null:(0,h.jsx)(K,{onClick:()=>d(!0),"aria-expanded":u,children:`Add starter templates`}),(0,h.jsx)(K,{disabled:f.busy,onClick:f.choose,children:`Import a template file (.zip)`})]}):x.data?.length===0?void 0:(0,h.jsx)(K,{disabled:l.busy,onClick:l.startTemplate,children:`New poster template`})}),f.input,l.input,(0,h.jsx)(tQe,{open:u,onClose:()=>d(!1),onInstalled:()=>void a.invalidateQueries({queryKey:PM})}),(0,h.jsx)(gL,{label:`Kinds of template`,idPrefix:`templates`,value:v,onChange:y,items:[{id:`videos`,label:b===void 0?`Video templates`:`Video templates (${String(b)})`},{id:`posters`,label:`Poster templates`}],className:`mb-4`}),(0,h.jsxs)(`div`,{role:`tabpanel`,id:`templates-panel-${v}`,"aria-labelledby":`templates-tab-${v}`,children:[f.problem===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-3 text-small text-danger`,children:f.problem}),v===`videos`?(0,h.jsx)(gQe,{templates:o,cards:s.data,channels:c.data??[],play:r,item:n,onAdd:()=>d(!0)}):(0,h.jsx)(vQe,{problem:l.problem,onNew:l.startTemplate})]})]})}function gQe({templates:e,cards:t,channels:n,play:r,item:i,onAdd:a}){let{api:o}=q(),s=_(),c=Vx(),l=TQ(),u=I(QE(o)),d=AD().channelId,[f,p]=(0,m.useState)(n.length>1?d??``:``),[g,v]=(0,m.useState)(``),[y,b]=t0(`template`),[x,S]=(0,m.useState)(null),[C,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(null),[D,O]=(0,m.useState)(!1),k=(0,m.useRef)(!1),A=r1(r),j=e.data??[],M=j.length>=mQe,N=M?g.trim().toLowerCase():``,P=$1(j.filter(e=>n.length<2||f===``||jQ(e)===f).filter(e=>e.name.toLowerCase().includes(N)),M?y:`name`);async function ee(e){if(!k.current){k.current=!0,O(!0),S(null);try{await e()}catch(e){S(e instanceof Error?e.message:`That didn't finish. Try again.`)}finally{k.current=!1,O(!1)}}}async function F(){if(C===null)return;let e=C.id,t=await axe(o,C);if(!t.ok)throw Error(t.message);w(null),await s.cancelQueries({queryKey:PM}),s.setQueryData(PM,t=>t?.filter(t=>t.id!==e));let n=C.name;c(`Moved "${n}" to the trash.`,`success`,{label:`Undo`,run:()=>void CQ(o,`template`,e).then(async()=>{c(`Restored "${n}".`,`success`),await s.invalidateQueries({queryKey:PM})},e=>c(`"${n}" wasn't restored: ${e.message} Restore it in Settings → Trash.`,`error`,l))}),await s.invalidateQueries({queryKey:PM})}async function te(e){let t=await vXe(o,e.id);if(!t.ok)throw Error(t.message);let n=URL.createObjectURL(t.blob),r=document.createElement(`a`);r.href=n,r.download=t.filename,r.click(),URL.revokeObjectURL(n)}return e.error?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(lL,{tone:`error`,children:`The templates didn't load: ${e.error.message}`}),(0,h.jsx)(K,{size:`small`,onClick:()=>void e.refetch(),children:`Reload templates`})]}):e.data===void 0?(0,h.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Loading templates`,className:`sl-template-cards`,children:[(0,h.jsx)(`div`,{className:`h-72 rounded-media bg-raised`}),(0,h.jsx)(`div`,{className:`h-72 rounded-media bg-raised`}),(0,h.jsx)(`div`,{className:`h-72 rounded-media bg-raised`})]}):j.length===0?(0,h.jsx)(ZR,{title:`No templates yet`,actions:(0,h.jsx)(K,{variant:`primary`,onClick:a,children:`Add starter templates`}),children:`A template keeps a whole setup, so a video takes only a topic. Start from a starter template, or save one from Create with Save as template.`}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[M||n.length>1?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[M?(0,h.jsx)(Y,{type:`search`,"aria-label":`Search templates`,placeholder:`Search templates`,value:g,className:`w-full min-w-0 sm:w-56`,onChange:e=>v(e.target.value)}):null,n.length>1?(0,h.jsxs)(ZT,{"aria-label":`Show templates of`,value:f,className:`w-full sm:w-56`,onChange:e=>p(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`All channels`}),n.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]}):null,M?(0,h.jsx)(n0,{what:`templates`,sort:y,onSort:b}):null]}):null,(0,h.jsx)(lL,{tone:r.blocked?`warning`:`error`,children:(C===null?x:null)??(r.blocked?`A video is still starting on Create. Wait for it, then make the next one.`:void 0)}),P.length===0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:N===``?`No templates in this channel.`:`No templates match "${g.trim()}"${f===``?``:` in this channel`}.`}):(0,h.jsx)(`ul`,{"aria-label":`Video templates`,className:`sl-template-cards m-0 list-none p-0`,children:P.map(e=>(0,h.jsx)(_Qe,{template:e,picked:e.id===i,card:t?.find(t=>t.id===e.id),channel:n.length>1?n.find(t=>t.id===jQ(e))?.name:void 0,providerName:e=>u.data?.providers.find(t=>t.id===e)?.displayName??e,pending:D,onMake:()=>void ee(()=>A.apply(e)),onDuplicate:()=>void ee(()=>A.duplicate(e)),onExport:()=>void ee(()=>te(e)),onVersions:()=>E(e),onDelete:()=>{w(e),S(null)}},e.id))}),T===null?null:(0,h.jsx)(dQe,{template:T,onClose:()=>E(null)},`${T.id}:${String(T.version)}`),(0,h.jsx)(ME,{open:C!==null,title:`Delete ${C?.name??`template`}?`,consequence:x??`Moves it to the trash for 30 days (Settings → Trash). Projects already made from it keep their setup.`,confirmLabel:`Delete template`,pending:D,onConfirm:()=>void ee(F),onCancel:()=>{D||w(null)}})]})}function _Qe({template:e,picked:t,card:n,channel:r,providerName:i,pending:a,onMake:o,onDuplicate:s,onExport:c,onVersions:l,onDelete:u}){let{api:d}=q(),f=JNe(e.gate,n?.schedules??0),p=n?.format??`16:9`,g=(0,m.useRef)(null);return(0,m.useEffect)(()=>{t&&g.current?.scrollIntoView?.({block:`nearest`})},[t]),(0,h.jsxs)(`li`,{ref:g,className:`sl-template-card`,"aria-label":e.name,"aria-current":t?`true`:void 0,children:[n?.still==null?null:(0,h.jsx)(pa,{to:`/templates/$templateId`,params:{templateId:e.id},search:{},tabIndex:-1,className:`sl-template-card__still`,"data-format":p,children:(0,h.jsx)(`img`,{src:`${d.origin}${n.still}`,alt:`A still from ${e.name}'s sample`})}),(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3 [overflow-wrap:anywhere]`,children:(0,h.jsx)(pa,{to:`/templates/$templateId`,params:{templateId:e.id},search:{},className:`text-ink no-underline hover:underline`,children:e.name})}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:n===void 0?`Reading what it makes…`:lQe(n,i)}),n===void 0||n.asks.length===0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Asks for: ${n.asks.join(`, `)}`}),f===void 0&&r===void 0?null:(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-x-2 gap-y-1 text-small text-ink-2`,children:[f===void 0?null:(0,h.jsx)(gE,{tone:f.tone,children:f.word}),r===void 0?null:(0,h.jsx)(`span`,{children:r})]}),f===void 0||f.tone!==`waiting`?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:f.detail})]}),(0,h.jsxs)(`div`,{className:`sl-template-card__actions`,children:[(0,h.jsx)(K,{variant:`primary`,size:`small`,"aria-label":`Make a video with ${e.name}`,disabled:a,disabledReason:`Working on the last press`,onClick:o,children:`Make a video`}),(0,h.jsx)($T,{to:`/templates/$templateId`,params:{templateId:e.id},search:{},size:`small`,"aria-label":`Edit template ${e.name}`,children:`Edit template`}),(0,h.jsxs)(YM,{children:[(0,h.jsx)(XM,{asChild:!0,children:(0,h.jsx)(K,{size:`small`,variant:`quiet`,"aria-label":`More for ${e.name}`,children:(0,h.jsx)(yh,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75})})}),(0,h.jsxs)(ZM,{children:[(0,h.jsx)(QM,{"aria-label":`Duplicate ${e.name}`,disabled:a,onSelect:s,children:`Duplicate`}),(0,h.jsx)(QM,{"aria-label":`Versions of ${e.name}`,onSelect:l,children:`Versions`}),(0,h.jsx)(QM,{"aria-label":`Export ${e.name} as a file (.zip)`,disabled:a,onSelect:c,children:`Export as a file (.zip)`}),(0,h.jsx)(eN,{}),(0,h.jsx)(QM,{"aria-label":`Delete ${e.name}`,onSelect:u,children:`Delete…`})]})]})]}),(0,h.jsx)(u$,{kind:`template`,id:e.id,name:e.name})]})}function vQe({problem:e,onNew:t}){return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[`A poster with keywords such as `,`{{Event}}`,`, made again by hand or ahead of each date by a schedule. Your posters and picture edits are under`,` `,(0,h.jsx)(eE,{to:`/designs`,children:`Designs`}),`.`]}),e===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:e}),(0,h.jsx)(UEe,{onNew:t})]})}function yQe({page:e,anchor:t,words:n}){let{api:r}=q(),i=I(WI(r)),a=I(uTe(r,e)),o=Ji(),[s,c]=(0,m.useState)(n??``);(0,m.useEffect)(()=>{c(n??``)},[n]);let l=(0,m.useRef)(null),u=(0,m.useMemo)(()=>new Set((i.data?.pages??[]).map(e=>e.id)),[i.data]),d=i.data?.pages.find(t=>t.id===e)?.title??e.replace(/-/g,` `),f=(0,m.useMemo)(()=>sge(a.data??``),[a.data]),p=(0,m.useMemo)(()=>a.data===void 0?``:oge(f.body,u,e),[a.data,f.body,u,e]);(0,m.useEffect)(()=>{if(p===``)return;let e=l.current;if(e===null)return;let n=t===void 0?void 0:lge(e,t,f.title===void 0?[]:[f.title]);n===void 0?window.scrollTo?.({top:0}):n.scrollIntoView?.({block:`start`})},[p,t,f.title]);let g=i.data?.groups.find(t=>t.pages.some(t=>t.id===e));return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(fL,{crumb:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{children:`Help`}),(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`›`}),(0,h.jsx)(pa,{to:`/help/tutorials/$page`,params:{page:i.data?.home.id??`Home`},children:`Tutorials`})]}),title:d,meta:g===void 0?`Guides to every screen of Slopify, for the version you are running.`:g.title,actions:(0,h.jsx)($T,{to:`/welcome`,variant:`quiet`,children:`Welcome screen`})}),(0,h.jsx)(pL,{className:`sl-workspace--tutorials`,sections:(0,h.jsx)(bQe,{index:i.data,page:e,onOpenHit:(e,t)=>{o({to:`/help/tutorials/$page`,params:{page:e.page},search:{q:t},...e.anchor===``?{}:{hash:e.anchor}})}}),children:a.error===null?(0,h.jsxs)(`div`,{ref:l,onClick:e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey)return;let t=e.target.closest(`a`),n=t?.getAttribute(`href`);if(t===null||n==null)return;let r=cge(n);r===void 0?/^https?:/.test(n)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`)):(e.preventDefault(),o({to:`/help/tutorials/$page`,params:{page:r.page},...r.anchor===void 0?{}:{hash:r.anchor}}))},children:[(0,h.jsx)(BI,{markdown:p,label:`Tutorial`,what:`tutorial`,query:s,onQuery:c,anchorPrefix:`tutorial-`,children:(0,h.jsx)(`p`,{className:`m-0 text-ink-3`,children:`Loading the tutorial…`})}),i.data?.footer?(0,h.jsx)(`p`,{className:`mt-8 border-t border-line pt-4 text-small text-ink-3`,children:i.data.footer.replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`)}):null]}):(0,h.jsx)(IT,{tone:`danger`,title:`This tutorial did not load`,actions:(0,h.jsx)(K,{onClick:()=>void a.refetch(),variant:`secondary`,children:`Try again`}),children:`${a.error.message} Press Try again, or pick another page on the left.`})})]})}function bQe({index:e,page:t,onOpenHit:n}){let{api:r}=q(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(``),c=(0,m.useRef)(null),l=(0,m.useId)();PD(c,`the tutorials`),(0,m.useEffect)(()=>{let e=setTimeout(()=>s(i.trim()),200);return()=>clearTimeout(e)},[i]);let u=I(dTe(r,o));return(0,h.jsxs)(`nav`,{"aria-label":`Tutorials`,className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsxs)(`div`,{className:`relative`,children:[(0,h.jsx)(`label`,{htmlFor:l,className:`sr-only`,children:`Search all tutorials`}),(0,h.jsx)(Nh,{"aria-hidden":`true`,strokeWidth:1.75,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-3`}),(0,h.jsx)(`input`,{ref:c,id:l,type:`search`,value:i,placeholder:`Search all tutorials`,onChange:e=>a(e.target.value),onKeyDown:e=>{let t=u.data?.hits[0];e.key===`Enter`&&t!==void 0&&(e.preventDefault(),n(t,o))},className:`sl-input pl-9`})]}),o===``?e===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Loading the tutorials…`}):(0,h.jsxs)(`div`,{className:`sl-tutorials-nav flex flex-col gap-4`,children:[(0,h.jsx)(xQe,{id:e.home.id,title:e.home.title,current:t}),e.groups.map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,h.jsx)(`div`,{className:`sl-kicker px-2.5 pb-1`,children:e.title}),e.pages.map(e=>(0,h.jsx)(xQe,{id:e.id,title:e.title,current:t},e.id))]},e.title))]}):(0,h.jsx)(SQe,{query:o,hits:u.data?.hits,error:u.error?.message})]})}function xQe({id:e,title:t,current:n}){return(0,h.jsx)(pa,{to:`/help/tutorials/$page`,params:{page:e},"aria-current":e===n?`page`:void 0,className:`sl-tutorials-nav__link`,children:t})}function SQe({query:e,hits:t,error:n}){return n===void 0?t===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Searching…`}):t.length===0?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`No tutorial mentions "${e}". Try fewer or other words.`}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`p`,{role:`status`,className:`m-0 px-2.5 text-small text-ink-3`,children:t.length===1?`1 section`:`${String(t.length)} sections`}),(0,h.jsx)(`ul`,{"aria-label":`Search results`,className:`m-0 flex list-none flex-col gap-1 p-0`,children:t.map(t=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(pa,{to:`/help/tutorials/$page`,params:{page:t.page},search:{q:e},...t.anchor===``?{}:{hash:t.anchor},className:`sl-tutorials-hit`,children:[(0,h.jsx)(`span`,{className:`block font-semibold text-ink`,children:t.heading===void 0?t.pageTitle:t.heading}),t.heading===void 0?null:(0,h.jsx)(`span`,{className:`block text-label text-ink-3`,children:t.pageTitle}),(0,h.jsx)(`span`,{className:`mt-0.5 block text-small text-ink-2`,children:t.snippet})]})},`${t.page}#${t.anchor}`))})]}):(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The search didn't run: ${n} Change the words or reload the page.`})}var CQe=[{id:`library`,name:`The Library of Alexandria`,summary:`A narrated video with its two shorts, article, PDF, description and images.`,action:`Explore the sample`},{id:`audiobook`,name:`The Wind in the Willows`,summary:`An audiobook: a narrator and two character voices, captions tagged with who speaks, MP3 and M4B with chapters.`,action:`See an audiobook`},{id:`podcast`,name:`The Antikythera Mechanism`,summary:`A two-host podcast with the speaker panel, name tags and portraits, and its MP3 and M4B.`,action:`Hear a podcast`}];function wQe({title:e,made:t}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(lD,{title:e,size:`small`,as:`h3`,className:`mt-6`}),(0,h.jsx)(BL,{label:`Samples`,className:`sl-list--wrap-meta`,children:CQe.map(e=>{let n=t[e.id];return(0,h.jsx)(VL,{title:e.name,meta:e.summary,actions:n===null?(0,h.jsx)(eE,{to:`/settings`,search:{section:`storage`},children:`Restore samples in Settings`}):(0,h.jsx)($T,{variant:`quiet`,to:`/projects/$projectId`,params:{projectId:n},className:zL,children:e.action})},e.id)})})]})}var R9=[`found`,`style`,`make`],TQe={found:`What a short needs`,style:`Pick a style`,make:`Make your first short`},EQe={read(e){try{return window.sessionStorage.getItem(`slopify.welcome.${e}`)??``}catch{return``}},write(e,t){try{window.sessionStorage.setItem(`slopify.welcome.${e}`,t)}catch{}}};function DQe(e){let[t,n]=(0,m.useState)(()=>EQe.read(e));return[t,t=>{n(t),EQe.write(e,t)}]}function z9({id:e,at:t,children:n}){if(e!==t)return null;let r=R9.indexOf(e);return(0,h.jsxs)(`section`,{id:`welcome-step-${e}`,"aria-labelledby":`welcome-step-${e}-title`,tabIndex:-1,className:`outline-none`,children:[(0,h.jsx)(lD,{id:`welcome-step-${e}-title`,title:TQe[e],row:!0,meta:`Step ${String(r+1)} of ${String(R9.length)}`}),n]})}function OQe(e,t){let n=e=>m2(e.by??``),r=[t?.text.by==null?void 0:`${n(t.text)} writes it`,t?.voice.by==null?void 0:t.voice.how===`computer`?`your computer's voice reads it aloud`:`${n(t.voice)} reads it aloud`,t?.images.by==null?void 0:`${n(t.images)} makes the images`].filter(e=>e!==void 0);return`${e} style${r.length===0?``:`: ${r.join(`, `)}`}. About five minutes.`}function kQe({step:e,onStep:t}){let{api:n}=q(),r=_(),i=Ji(),a=I({queryKey:FE,queryFn:()=>zE(n)}),[o,s]=(0,m.useState)(e??`found`),c=t===void 0?o:e??`found`,[l,u]=DQe(`topic`),[d,f]=DQe(`pack`),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(!1),S=(0,m.useRef)(null),C=(0,m.useRef)(void 0),w=L({mutationFn:()=>VE(n),onSuccess:async()=>{await r.invalidateQueries({queryKey:oD}),await r.invalidateQueries({queryKey:FE}),await i({to:`/`})}}),T=L({mutationFn:()=>(C.current??=crypto.randomUUID(),n_e(n,{topic:l,requestId:C.current,...d===``?{}:{packId:d}})),onSuccess:async e=>{e.ok?(C.current=void 0,y([]),g(e.projectId),u(``),await r.invalidateQueries({queryKey:oD}),await r.invalidateQueries({queryKey:X.projects}),await r.invalidateQueries({queryKey:X.voices})):(y(e.gaps),await r.invalidateQueries({queryKey:FE}))}}),E=e=>{e?.preventDefault(),l.trim()===``?(x(!0),S.current?.focus()):(x(!1),T.mutate())},D=a.data,O=d===``?`General`:D?.packs.find(e=>e.id===d)?.name??d,k=D?.needs.gaps??[],A=T.error?{tone:`error`,text:T.error.message}:w.error?{tone:`error`,text:w.error.message}:T.isPending?{tone:`info`,text:`Starting your short…`}:b?{tone:`error`,text:`Type a topic first.`}:v.length===0?void 0:{tone:`error`,text:k.length>0?`The short didn't start. Fix the lines above that are not Ready, then press Make a 60-second short again.`:v.map(e=>e.message).join(` `)},j=R9.indexOf(c),M=(0,m.useRef)(!1),N=e=>{M.current=!0,t===void 0?s(e):t(e)};(0,m.useEffect)(()=>{M.current&&(M.current=!1,document.getElementById(`welcome-step-${c}`)?.focus({preventScroll:!0}))},[c]);let P=R9[j+1],ee=R9[j-1];return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fL,{title:`Welcome to Slopify`,className:`max-sm:[&>div:first-child]:basis-0`,meta:(0,h.jsx)(`span`,{className:`max-sm:hidden`,children:`Make a video from a topic, with the tools already on this computer.`}),actions:(0,h.jsx)(K,{variant:`quiet`,disabled:w.isPending,onClick:()=>w.mutate(),children:p===void 0?`Skip`:`Done`})}),a.error?(0,h.jsx)(IT,{tone:`danger`,title:`Could not read what this computer has`,className:`mb-4`,children:a.error.message}):null,(0,h.jsxs)(z9,{id:`found`,at:c,children:[(0,h.jsx)(_2,{back:{return:`welcome`,step:`found`}}),D===void 0?null:(0,h.jsx)(wQe,{title:`What Slopify makes: finished samples`,made:D.samples})]}),(0,h.jsx)(z9,{id:`style`,at:c,children:(0,h.jsx)(BL,{label:`Styles`,className:`sl-list--wrap-meta`,children:[{id:``,name:`General`,summary:`A neutral explainer style.`},...D?.packs??[]].map(e=>{let t=d===e.id;return(0,h.jsx)(VL,{title:e.name,meta:e.summary,selected:t,onSelect:()=>f(e.id),actions:t?(0,h.jsxs)(`span`,{className:`flex items-center gap-1 text-small font-semibold text-accent-ink`,children:[(0,h.jsx)(ph,{"aria-hidden":`true`,className:`size-4`,strokeWidth:2.5}),`Picked`]}):void 0},e.id===``?`general`:e.id)})})}),(0,h.jsxs)(z9,{id:`make`,at:c,children:[p===void 0?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`form`,{id:`welcome-short`,onSubmit:E,className:`mb-4`,children:(0,h.jsx)(J,{label:`Topic`,help:OQe(O,D?.needs),children:(0,h.jsx)(Y,{ref:S,value:l,maxLength:200,placeholder:`For example: why the sea glows at night`,onChange:e=>{u(e.target.value),e.target.value.trim()!==``&&x(!1)}})})}),k.length===0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`m-0 mb-2 text-small font-semibold text-waiting`,children:`The short needs every line Ready before it can start.`}),(0,h.jsx)(_2,{back:{return:`welcome`,step:`make`},className:`mb-4`})]})]}):(0,h.jsxs)(IT,{tone:`info`,className:`mb-4`,title:`Your short is being made.`,children:[`It usually takes about five minutes. Watch each step as it runs, or look at a sample while you wait. `,d===``?`Its prompts are`:`Its ${O} prompts are`,` now in`,` `,(0,h.jsx)(eE,{to:`/prompts`,search:{kind:`article`},children:`Prompts`}),`, for your next video.`]}),(0,h.jsx)(__e,{}),p===void 0||D===void 0?null:(0,h.jsx)(wQe,{title:`While you wait: finished samples`,made:D.samples})]}),(0,h.jsxs)(uL,{status:(0,h.jsx)(lL,{wrap:!0,tone:A?.tone??`info`,children:A?.text}),children:[c===`make`?null:(0,h.jsx)(eE,{to:`/play`,className:`max-sm:hidden`,children:`Make a long video instead`}),ee===void 0?null:(0,h.jsx)(K,{onClick:()=>N(ee),children:`Back`}),P===void 0?p===void 0?(0,h.jsx)(K,{type:`submit`,form:`welcome-short`,variant:(D?.needs.gaps.length??0)>0?`secondary`:`primary`,disabled:T.isPending,children:`Make a 60-second short`},`make`):(0,h.jsx)($T,{variant:`primary`,to:`/projects/$projectId`,params:{projectId:p},children:`Watch it being made`}):(0,h.jsx)(K,{variant:`primary`,onClick:()=>N(P),children:`Next: ${TQe[P]}`},`next-${P}`)]})]})}var AQe=[`script`,`voice`,`pictures`,`thumbnail`,`shorts`,`upload`,`reviews`],B9={yours:`Your words`,keyword:`Your keywords`,slopify:`Filled by Slopify`,setting:`Added by a setting`},jQe={yours:``,keyword:`rounded-sm bg-accent-tint px-0.5`,slopify:`rounded-sm bg-waiting-tint px-0.5`,setting:`rounded-sm bg-info-tint px-0.5 italic`},MQe={script:`What the writer is sent`,voice:`What the voice is sent`,pictures:`What the image service is sent`,thumbnail:`What the image service is sent for the thumbnail`,shorts:`What the writer is sent for the shorts`,upload:`What the writer is sent for the description and posts`,reviews:`What the AI checks are sent`};function NQe({view:e,section:t}){let n=MQe[t];return!AQe.includes(t)||n===void 0?null:(0,h.jsx)(SR,{summary:n,children:(0,h.jsx)(PQe,{children:(0,h.jsx)(FQe,{view:e,section:t})})})}function PQe({children:e}){let t=(0,m.useRef)(null),[n,r]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=t.current?.closest(`details`);if(e==null)return;let n=()=>r(e.open);return n(),e.addEventListener(`toggle`,n),()=>e.removeEventListener(`toggle`,n)},[]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{ref:t,hidden:!0}),n?e:null]})}function FQe({view:e,section:t}){let{api:n}=q(),[r,i]=(0,m.useState)(),a=I(nXe(n,e.template.id,t,r,e.template.version));if(a.error)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 pb-3 text-small text-danger`,children:`The prompt anatomy didn't load: ${a.error.message}`});let o=a.data;if(o===void 0)return(0,h.jsx)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Working out the prompt`,className:`pb-3`,children:(0,h.jsx)(`div`,{className:`h-16 rounded-control bg-raised`})});if(o.problem!==null)return(0,h.jsx)(`p`,{className:`m-0 pb-3 text-small text-danger`,children:o.problem});if(o.item===null)return(0,h.jsx)(`p`,{className:`m-0 pb-3 text-small text-ink-2`,children:`This section sends no prompt.`});let s=new Set(o.segments.map(e=>e.origin));return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 pb-3`,children:[o.items.length>1?(0,h.jsx)(ZT,{"aria-label":`Prompt`,value:o.item,onChange:e=>i(e.target.value),options:o.items.map(e=>({value:e.key,label:e.label}))}):(0,h.jsx)(`p`,{className:`m-0 text-small font-semibold`,children:o.items[0]?.label}),(0,h.jsx)(`p`,{className:`m-0 whitespace-pre-wrap text-small leading-relaxed`,children:o.segments.map((e,t)=>(0,h.jsx)(`span`,{className:G(jQe[e.origin],e.unfilled===!0&&`opacity-70`),title:e.name===void 0?B9[e.origin]:`${B9[e.origin]}: ${e.name}${e.unfilled===!0?` (filled when the step runs)`:``}`,children:e.text},t))}),(0,h.jsx)(`ul`,{"aria-label":`What the marks mean`,className:`m-0 flex list-none flex-wrap gap-3 p-0 text-small`,children:[`yours`,`keyword`,`slopify`,`setting`].filter(e=>s.has(e)).map(e=>(0,h.jsx)(`li`,{className:G(`text-ink-2`,jQe[e]),children:B9[e]},e))}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:o.fromSample?`As the sample sent it.`:`As the sample would send it: no sample was made from this setup yet.`})]})}var IQe={script:`llm`,voice:`tts`,pictures:`image`},LQe={script:`writing model`,voice:`voice model`,pictures:`image model`};function RQe(e){return e===`script`||e===`voice`||e===`pictures`?e:void 0}function zQe(e,t){let{form:n}=e,r=t===`script`?n.sources.article===`generate`?n.llm:void 0:t===`voice`?n.sources.audio===`generate`?n.audio:void 0:n.sources.images===`generate`?n.images:void 0;return r===void 0||r.provider===``||r.model===``?void 0:{provider:r.provider,model:r.model}}function BQe(e,t,n){let{form:r}=e;switch(t){case`script`:{let{thinking:t,...i}=r.llm;return{...e,form:{...r,llm:{...i,provider:n.provider,model:n.model,...t!==void 0&&n.provider===r.llm.provider?{thinking:t}:{}}}}}case`voice`:return{...e,form:{...r,audio:{...r.audio,model:n.model}}};case`pictures`:return{...e,form:{...r,images:{...r.images,provider:n.provider,model:n.model}}}}}var VQe={current:[`done`,`In use now`],queued:[`waiting`,`Waiting`],making:[`running`,`Making`],done:[`done`,`Made`],failed:[`failed`,`Failed`]},HQe=e=>e===null?`time not known`:e<60?`${Math.round(e)} s`:`${Math.round(e/60)} min`;function UQe({entry:e,origin:t}){let n=e.outputs.find(e=>e.role.startsWith(`audio`)),r=e.outputs.filter(e=>e.role===`image`);return e.article===null?n===void 0?r.length>0?(0,h.jsx)(dR,{density:`compact`,list:!0,label:`Pictures by ${e.model}`,children:r.slice(0,4).map(n=>(0,h.jsx)(`li`,{children:(0,h.jsx)(uR,{src:`${t}${n.url}`,alt:`A picture by ${e.model}`})},n.url))}):null:(0,h.jsx)(w6,{src:`${t}${n.url}`,label:`Narration by ${e.model}`,compact:!0}):(0,h.jsx)(`p`,{className:`m-0 line-clamp-6 whitespace-pre-line text-small text-ink-2`,children:e.article})}function WQe({templateId:e,section:t,onUse:n}){let{api:r}=q(),i=_(),a=I(EXe(r,e)),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(null),u=a.data?.bakeoff;if(u==null||u.section!==t)return null;let d=u.state===`queued`||u.state===`making`;async function f(){s(!0),l(null);try{let t=await kXe(r,e);return t.ok?(await i.invalidateQueries({queryKey:b9(e)}),!0):(l(t.message),!1)}catch(e){return l(`The bake-off wasn't discarded: ${e instanceof Error?e.message:String(e)} Press Discard again.`),!1}finally{s(!1)}}return(0,h.jsxs)(`section`,{"aria-label":`Compared models`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(lD,{title:`Compared models`,as:`h3`,size:`small`,meta:u.stale?`Made for version ${String(u.version)}; the template was saved since.`:d?`Being made on copies of the sample. Your template doesn't change.`:`Made on copies of the sample, each with what it was charged and how long it took. Your template doesn't change until you use a model and Save.`,children:(0,h.jsx)(K,{variant:`quiet`,size:`small`,disabled:o||d,disabledReason:d?`Work already going is never stopped: discard it once it finishes`:`Discarding`,focusableWhenDisabled:!0,onClick:()=>void f(),children:`Discard`})}),u.sentence===null?null:(0,h.jsx)(`p`,{className:u.state===`failed`||u.state===`held`?`m-0 text-body text-waiting`:`m-0 text-small text-ink-2`,children:u.sentence}),c===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:c}),(0,h.jsx)(`ul`,{"aria-label":`Models compared`,className:`sl-list m-0 list-none p-0`,children:u.entries.map(e=>{let[t,i]=VQe[e.state],a=e.cost===null?e.quotedHigh===null?`cost not known`:`${O9(e.quotedHigh)}`:`${nE(e.cost)} charged`;return(0,h.jsxs)(`li`,{className:`sl-row max-sm:grid-cols-1`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,h.jsx)(`p`,{className:`m-0 font-semibold`,children:e.model}),(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-x-2 text-small text-ink-2`,children:[(0,h.jsx)(hE,{tone:t,children:i}),`· ${a} · ${HQe(e.seconds)}`]}),e.failure===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:e.failure}),(0,h.jsx)(UQe,{entry:e,origin:r.origin})]}),e.state===`done`&&!u.stale?(0,h.jsx)(zx,{children:(0,h.jsx)(K,{size:`small`,variant:`secondary`,disabled:o,onClick:async()=>{await f()&&n({provider:e.provider,model:e.model},`Switched to ${e.model}; the compared copies were discarded. Press Save, then Make sample to see the template's own sample with it.`)},children:`Use this model`})}):null]},`${e.provider}:${e.model}`)})})]})}function GQe({templateId:e,section:t,document:n,dirty:r,preset:i}){let[a,o]=(0,m.useState)(i!==void 0),s=zQe(n,t);return s===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[r?null:(0,h.jsx)(K,{size:`small`,onClick:()=>o(!0),children:`Compare models`}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:r?`Save to compare other models: they are compared on the saved version's sample.`:`Makes this section's sample with other models, side by side, priced first.`}),a?(0,h.jsx)(KQe,{templateId:e,section:t,current:s,preset:i,onClose:()=>o(!1)}):null]})}function KQe({templateId:e,section:t,current:n,preset:r,onClose:i}){let{api:a}=q(),o=_(),s=I(QE(a)),c=IQe[t],l={provider:n.provider,model:``},[u,d]=(0,m.useState)([r??l]),[f,p]=(0,m.useState)(!1),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(null),x=u.filter(e=>e.provider!==``&&e.model!==``),S=x.length===u.length,C=I({queryKey:[...b9(e),`bakeoff-quote`,t,JSON.stringify(x)],queryFn:async()=>{let n=await DXe(a,e,{section:t,models:x});if(!n.ok)throw Error(n.message);return n.value},enabled:S&&x.length>0,retry:!1}),w=C.data?.unknown??0,T=S?C.isPending?`Working out the price`:C.error===null?C.data?.problem!==null&&C.data?.problem!==void 0?`No sample can be made with this model`:C.data?.fits===!1?MXe(C.data):w>0&&!f?`Accept the steps with no known price first`:void 0:`This can't be compared as picked`:`Pick the ${LQe[t]} to compare first`;async function E(){if(C.data!==void 0){v(!0),b(null);try{let n=await OXe(a,e,{section:t,models:x,acknowledgedHigh:C.data.high,acknowledgedUnknown:f});if(!n.ok){b(`Nothing was started: ${n.message}`),n.quote!==null&&o.setQueryData([...b9(e),`bakeoff-quote`,t,JSON.stringify(x)],n.quote);return}await o.invalidateQueries({queryKey:b9(e)}),i()}catch(e){b(`Nothing was started: ${e instanceof Error?e.message:String(e)} Press Compare again.`)}finally{v(!1)}}}let D=(e,t)=>d(u.map((n,r)=>r===e?t:n)),O=C.error?.message??C.data?.problem??null;return(0,h.jsx)(LT,{open:!0,onClose:i,title:`Compare models`,footer:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,h.jsx)(K,{onClick:i,children:`Cancel`}),(0,h.jsx)(K,{variant:`primary`,disabled:g||T!==void 0,disabledReason:g?`Starting the comparison`:T??``,focusableWhenDisabled:!0,onClick:()=>void E(),children:C.data===void 0?`Compare`:`Compare · ${O9(C.data.high)}`})]}),children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Makes this section's sample again with each model, on copies of the sample, so you can compare what each makes, costs and takes. In use now: ${n.model}. Your template doesn't change until you press Use this model and Save.`}),u.map((e,n)=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t===`voice`?null:(0,h.jsx)(YR,{label:`Service ${String(n+1)}`,family:c,providers:s.data?.providers??[],value:e.provider,problem:void 0,tip:`template-studio.compare-provider`,onPick:e=>D(n,{provider:e,model:``})}),(0,h.jsx)(GR,{label:`Model ${String(n+1)}`,provider:e.provider,value:e.model,problem:void 0,tip:`template-studio.compare-model`,onPick:t=>D(n,{...e,model:t})}),u.length>1?(0,h.jsx)(K,{size:`small`,variant:`quiet`,className:`self-start`,onClick:()=>d(u.filter((e,t)=>t!==n)),children:`Remove model ${String(n+1)}`}):null]},String(n))),u.length<2?(0,h.jsx)(K,{size:`small`,className:`self-start`,onClick:()=>d([...u,l]),children:`Add another model`}):null,w>0?(0,h.jsx)(dD,{label:`Accept ${String(w)} ${w===1?`step`:`steps`} with no known price`,tip:`template-studio.accept-unknown`,tipLabel:`Steps with no known price`,checked:f,onChange:p}):null,(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,role:`status`,children:C.data===void 0?S?`Working out the price…`:``:`${C.data.models.map(e=>`${e.model}: ${O9(e.high)}`).join(` · `)} · ${nE(C.data.budget.left)} of today's ${nE(C.data.budget.budget)} sample budget left`}),C.data?.fits===!1?(0,h.jsxs)(`p`,{className:`m-0 text-body text-waiting`,children:[NXe(C.data,`Comparing`),(0,h.jsx)(eE,{to:`/settings`,search:{section:`playback`},children:`Settings → Production defaults`}),`.`]}):null,O===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:O}),y===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:y})]})})}function qQe({templateId:e,dirty:t}){let{api:n}=q(),r=I(x9(n,e)),i=r.data?.checks,a=i?.filter(e=>!e.ok),o=i?.filter(e=>e.ok)??[];return(0,h.jsxs)(`section`,{"aria-label":`Checks`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(lD,{title:`Checks`,as:`h3`,className:`pb-0`,meta:a===void 0?void 0:a.length===0?`All pass`:`${String(a.length)} to fix`}),t?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Checked on the saved version: Save to check your changes.`}):null,r.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The checks didn't load: ${r.error.message} Reload the page to look again.`}):a===void 0?(0,h.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Checking the template`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(`div`,{className:`h-4 w-3/4 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`h-4 w-2/3 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`h-4 w-1/2 rounded-control bg-raised`})]}):(0,h.jsxs)(h.Fragment,{children:[a.length===0?null:(0,h.jsx)(JQe,{label:`To fix`,checks:a}),o.length===0?null:(0,h.jsx)(SR,{summary:`What passes`,state:String(o.length),children:(0,h.jsx)(JQe,{label:`What passes`,checks:o})})]})]})}function JQe({label:e,checks:t}){return(0,h.jsx)(`ul`,{"aria-label":e,className:`m-0 flex list-none flex-col gap-3 p-0`,children:t.map((e,t)=>(0,h.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(hE,{tone:e.ok?`done`:`failed`,children:(0,h.jsx)(`span`,{className:`text-small`,children:e.sentence})}),e.fix===void 0?null:(0,h.jsx)(eE,{to:e.fix.href,className:`text-small`,children:e.fix.label})]},`${e.id}:${String(t)}`))})}function YQe({section:e,defaults:t,onFiles:n}){let{api:r}=q(),i=I(QE(r)),a=I(eD(r)),o=I(tD(r)),s=I($E(r)),c=I(aD(r)),[l,u]=iI(),{document:d}=GP(),f={...l,...l.llm.provider===``&&t.llm!==void 0?{llm:{...l.llm,...t.llm}}:{},...l.images.provider===``&&t.images!==void 0?{images:{...l.images,...t.images}}:{}},p=A3(d.librarySnapshot,a.data?.prompts??[],o.data?.entries??[]),m=c.data?.silenceGapSeconds??3,g={form:f,prompts:p.prompts,entries:p.entries,silenceGapSeconds:m},{fields:_,result:v}=pP(g),y=v.ok?[]:v.fields,b=e=>y.find(t=>t.field===e||t.field.startsWith(`${e}.`))?.message,x=e=>u(t=>{let n={...t,...e};return{...n,subtitles:HN(n.subtitles,n.sources)}}),S=(e,t)=>u(n=>({...n,provided:e===`images`?{...n.provided,images:n.provided.images.filter(e=>e.key!==t)}:{...n.provided,[e]:void 0}})),C={form:f,providers:i.data?.providers??[],prompts:p.prompts,voices:s.data?.voices??[],silenceGapSeconds:m,problem:b,update:x,onPickFiles:n,onRemoveFile:S,onReattachFile:n},w=VN(f.title),T=f.sources.article!==`off`;switch(e){case`subject`:return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4 py-2`,children:[(0,h.jsx)(R4,{fields:_,origins:xP(g),topics:w,hide:w,values:f.values,problem:b,onChange:(e,t)=>x({values:{...f.values,[e]:t}})}),(0,h.jsx)(V2,{})]});case`script`:return(0,h.jsx)(F4,{...C,entries:p.entries});case`voice`:return(0,h.jsx)(u3,{...C,entries:p.entries,onKeyword:()=>void 0});case`pictures`:return(0,h.jsx)(d3,{...C});case`video`:return(0,h.jsx)(f3,{...C,problemOf:b});case`thumbnail`:return(0,h.jsx)(A4,{...C});case`shorts`:return T?(0,h.jsx)(qB,{value:f.shorts??WB,prompts:p.prompts,narrated:f.sources.audio!==`off`,problem:b,musicName:f.provided.shortsMusic?.name,music:(0,h.jsx)(`div`,{className:`basis-full`,children:(0,h.jsx)(r4,{field:`shorts.music`,label:`Background music (optional): an audio file, looped if shorter than a short`,accept:`audio/*`,disabled:!GN(f),uploads:f.provided.shortsMusic===void 0?[]:[f.provided.shortsMusic],problem:b(`shorts.music`),onPick:()=>n(),onReattach:()=>n(),onRemove:e=>S(`shortsMusic`,e)})}),preview:(0,h.jsx)(O4,{settings:GB(f.shorts??WB,f.subtitles.fontId)}),onChange:e=>x({shorts:e})}):(0,h.jsx)(V9,{what:`Shorts are cut from the narrated article`});case`upload`:return T?(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(b4,{enabled:f.youtubeDescription===!0,prompt:f.descriptionPrompt??``,prompts:p.prompts,narrated:f.sources.audio!==`off`,problem:b,onChange:e=>x(e)}),(0,h.jsx)(`div`,{"data-play-field":`social`,children:(0,h.jsx)(x4,{value:f.social,prompts:p.prompts,shorts:S4(f.shorts),onChange:e=>x({social:C4(e)})})})]}):(0,h.jsx)(V9,{what:`The description and the posts are written from the article`});case`reviews`:return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(wP,{problem:b}),(0,h.jsx)(MB,{problem:b})]});case`document`:return T?(0,h.jsx)(N4,{...C}):(0,h.jsx)(V9,{what:`The PDF lays out the article`});case`schedule`:return null}}function V9({what:e}){return(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`${e}: turn the article on in Article.`})}function H9(){let{api:e}=q();return I({queryKey:uN.firstRun,queryFn:()=>hN(e),retry:!1,staleTime:1/0}).data?.defaults??{}}function XQe(e){let{api:t}=q(),n=I(QE(t)),r=I({...yN(t,e.provider),enabled:e.provider!==``}),i=n.data?.providers.find(t=>t.id===e.provider),a=i?.displayName??e.provider,o=e.model===``?void 0:r.data?.models.find(t=>t.id===e.model)?.name??e.model;return{name:o===void 0?a:`${a} (${o})`,service:a,unusable:i===void 0?void 0:_R(i.readiness)}}function ZQe({section:e,document:t}){let n=H9(),{form:r}=t,i=e===`script`&&r.sources.article===`generate`&&r.llm.provider===``?`llm`:e===`pictures`&&r.sources.images===`generate`&&r.images.provider===``?`images`:void 0,a=i===void 0?void 0:n[i],{name:o}=XQe(a??{provider:``,model:``});return i===void 0||a===void 0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:i===`llm`?`Each video is written by your default, ${o}: no writer is saved with this template yet.`:`Each video's images are made by your default, ${o}: no image service is saved with this template yet.`})}function QQe({templateId:e,document:t}){let n=H9(),{form:r}=t,i=r.images,a=i.provider===``?n.images??i:i,{name:o,service:s,unusable:c}=XQe(a);if(r.sources.thumbnail!==`from_prompt`&&r.sources.thumbnail!==`prompt_by_llm`||r.sources.images!==`generate`)return null;let l=a.provider===``;return(0,h.jsxs)(`p`,{className:G(`m-0 flex flex-wrap items-center gap-x-2 text-small`,l||c!==void 0?`text-danger`:`text-ink-2`),children:[l?`No image service is chosen, so a run can't start.`:`Thumbnail by ${o}${i.provider===``?` (your default)`:``}${c===void 0?``:` (${s}: ${c.toLowerCase()})`}`,(0,h.jsx)(eE,{to:`/templates/$templateId`,params:{templateId:e},search:{section:`pictures`},className:`text-small`,children:`${l?`Choose one`:`Change it`} in ${qx.pictures}`})]})}var $Qe=new Set([`current`,`off`,`provided`]);function e$e(e,t,n){if(e.gate===`ready`)return`it is approved already`;if(t)return`save your changes`;if(n===void 0)return`wait for the checks`;if(n>0)return`fix ${String(n)} ${n===1?`check`:`checks`}`;let r=e.sections.filter(e=>!$Qe.has(e.state));if(r.length>0)return`look over a current sample of ${r.map(e=>e.label).join(`, `)}`}function t$e(e,t){let{api:n}=q(),r=I(x9(n,e.template.id));return e$e(e,t,r.data===void 0||r.data.version!==e.template.version?void 0:r.data.checks.filter(e=>!e.ok).length)}function n$e(e){return e.gated?e.gate===`ready`||e.gate===`carried`?{word:`Ready for schedules`}:{word:`Not ready for schedules`,line:e.runnableVersion===null?`No schedule runs it until you approve a version: More → Approve for schedules.`:`Schedules run version ${String(e.runnableVersion)} until you approve this one: More → Approve for schedules.`}:{word:`Schedules run each version you save`}}function r$e({view:e,dirty:t,scheduled:n,play:r,onProblem:i}){let{api:a}=q(),o=_(),s=Ji(),c=t$e(e,t),l=rQe(e,i),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(!1),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),x=(0,m.useRef)(!1),S=r1(r??{onApplied:()=>!1}),C=String(e.template.version),w=e.runnableVersion===null||e.runnableVersion===e.template.version?` Until now none of their runs started.`:` Until now they ran version ${String(e.runnableVersion)}.`,T=e.gated?`Its schedules run this version from their next run.${w}`:`Its schedules keep running this version. From now on a version you save waits for your approval before they run it, so an edit never changes the next run by itself.`;async function E(){p(!0);try{let t=await fXe(a,e.template.id,e.template.version);i(t.ok?void 0:t.message),await o.invalidateQueries({queryKey:b9(e.template.id)})}catch(e){i(`Version ${C} wasn't approved: ${e instanceof Error?e.message:String(e)} Choose Approve for schedules again.`)}finally{p(!1),d(!1)}}async function D(){if(!x.current){x.current=!0,b(!0),i(void 0);try{await S.apply(e.template)}catch(e){i(e instanceof Error?e.message:String(e))}finally{x.current=!1,b(!1)}}}return(0,h.jsxs)(h.Fragment,{children:[r===void 0?null:(0,h.jsx)(K,{variant:`primary`,disabled:t||y,disabledReason:t?`Save your changes first`:`Opening Create`,onClick:()=>void D(),children:`Make a video`}),(0,h.jsx)(K,{onClick:()=>{qM(e.template.id),s({to:`/calendar`,search:{tab:`schedules`}})},children:`New schedule`}),(0,h.jsxs)(YM,{children:[(0,h.jsx)(XM,{asChild:!0,children:(0,h.jsxs)(K,{"aria-label":`More for this template`,children:[`More`,(0,h.jsx)(mh,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75})]})}),(0,h.jsxs)(ZM,{children:[(0,h.jsx)(QM,{onSelect:()=>v(!0),children:`Versions`}),(0,h.jsx)(QM,{disabled:l.blocker!==void 0,onSelect:()=>void l.save(),children:l.blocker===void 0?l.label:`${l.label} (${l.blocker})`}),n&&e.gate!==`ready`?(0,h.jsx)(QM,{disabled:c!==void 0,onSelect:()=>d(!0),children:c===void 0?`Approve for schedules`:`Approve for schedules (${c} first)`}):null]})]}),(0,h.jsx)(ME,{open:u,title:`Approve version ${C} for schedules?`,consequence:T,confirmLabel:`Approve for schedules`,cancelLabel:`Not yet`,tone:`primary`,pending:f,onConfirm:()=>void E(),onCancel:()=>d(!1)}),g?(0,h.jsx)(dQe,{template:e.template,onClose:()=>v(!1)},`${e.template.id}:${C}`):null]})}var i$e=[`subject`,`script`,`voice`,`pictures`,`thumbnail`,`shorts`,`upload`],a$e=[`audio_levelled`,`audio_body`,`audio_mp3`,`audio_export`];function o$e(e){let t=e.paid.outputs.filter(e=>e.section===`voice`);return a$e.map(e=>t.find(t=>t.role===e)).find(e=>e!==void 0)}function s$e({view:e,section:t}){let{api:n}=q(),r=e=>`${n.origin}${e}`,i=e.paid.outputs.filter(e=>e.section===t),a=e.template.document.form.format,o=a===`9:16`?`portrait`:a===`1:1`?`square`:`landscape`,s=(...e)=>i.filter(t=>e.includes(t.role));switch(t){case`script`:return e.paid.article===null?null:(0,h.jsx)(l$e,{markdown:e.paid.article});case`pictures`:{let e=s(`image`,`reference`);return e.length===0?null:(0,h.jsx)(dR,{density:`compact`,label:`Sample images`,children:e.map(e=>(0,h.jsx)(uR,{src:r(e.url),alt:e.name,aspect:o},e.url))})}case`thumbnail`:{let[t]=s(`thumbnail`);return t===void 0?null:(0,h.jsxs)(`div`,{className:`flex max-w-[320px] flex-col gap-2`,children:[(0,h.jsx)(uR,{src:r(t.url),alt:`Sample thumbnail`,aspect:`landscape`}),(0,h.jsx)(`p`,{className:`m-0 text-body font-semibold`,children:u$e(e)})]})}case`video`:{let[t]=s(`video`);return t===void 0?null:(0,h.jsx)(sR,{src:r(t.url),label:`${e.template.name}: sample video`,portrait:a===`9:16`,square:a===`1:1`})}case`shorts`:{let[t]=s(`short_video`);return t===void 0?null:(0,h.jsx)(`div`,{className:`max-w-[240px]`,children:(0,h.jsx)(sR,{src:r(t.url),label:`${e.template.name}: sample short`,portrait:!0})})}case`upload`:return(0,h.jsx)(d$e,{outputs:i,projectId:e.paid.projectId});case`document`:{let[e]=s(`document_pdf`);return e===void 0?null:(0,h.jsx)(tE,{href:r(e.url),target:`_blank`,rel:`noreferrer`,size:`small`,className:`self-start`,children:`Open the PDF of the sample's article`})}default:return null}}function c$e(e,t=480){let n=e.split(`
|
|
460
|
-
`).map(e=>e.replace(/^#+\s*/u,``).replace(/[*_`>]/gu,``).trim()).filter(e=>e!==``).join(` `);if(n.length<=t)return n;let r=n.slice(0,t);return`${r.slice(0,Math.max(r.lastIndexOf(` `),t-40))}…`}function l$e({markdown:e}){let[t,n]=(0,m.useState)(!1);return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:c$e(e)}),(0,h.jsx)(K,{size:`small`,className:`self-start`,onClick:()=>n(!0),children:`Read the whole article`}),(0,h.jsx)(LT,{open:t,title:`Sample article`,onClose:()=>n(!1),children:(0,h.jsx)(BI,{markdown:e,label:`Sample article`,copyAll:!1})})]})}function u$e(e){let{form:t}=e.template.document;return t.title.replace(/\{\{([^{}\n]*)\}\}/g,(n,r)=>{let i=t.values[r.trim()];return i===void 0||i===``?e.sample.topic:i})}function d$e({outputs:e,projectId:t}){let{api:n}=q(),r=e.find(e=>e.role===`youtube_description`),i=I({queryKey:[`template-studio`,`upload`,r?.url??``],queryFn:async()=>r===void 0?``:gm(await n.fetch(`${n.origin}${r.url}`)),enabled:r!==void 0}),a=I({queryKey:LJ(t??``),queryFn:()=>RJ(n,t??``),enabled:t!==null,retry:!1}).data?.packs??[],o=e.filter(e=>e.role!==`social_post`);return o.length===0&&a.length===0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[i.data===void 0||i.data===``?null:(0,h.jsx)(`p`,{className:`m-0 whitespace-pre-wrap rounded-media border border-line p-3 text-small`,children:i.data}),o.length===0?null:(0,h.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:o.map(e=>(0,h.jsx)(tE,{href:`${n.origin}${e.url}`,target:`_blank`,rel:`noreferrer`,size:`small`,children:e.name},e.url))}),a.map(e=>(0,h.jsx)(HJ,{pack:e},e.platform))]})}function U9(e){return e.unknown>0?e.high===0?`price not known`:`at least ${nE(e.high)}`:e.high===0?e.onPlan?`plan usage`:`free`:O9(e.high)}function f$e({view:e,onDone:t}){let{api:n}=q(),r=_(),[i,a]=(0,m.useState)(!1),o=e.paid.quotedHigh,s=e.paid.state===`held`,c=I({queryKey:[...b9(e.template.id),`quote`,`whole`,e.sample.topic],queryFn:()=>D9(n,e.template.id,{topic:e.sample.topic}),enabled:o===null||s}),l=o??c.data?.high,u=o===null?(c.data?.unknown??0)>0:s,d=o===null?c.data?.problem??null:null;async function f(){if(l!==void 0){a(!0);try{let i=await QYe(n,e.template.id,{version:e.template.version,acknowledgedHigh:l,acknowledgedUnknown:u});t(i.ok?null:i.message),await r.invalidateQueries({queryKey:b9(e.template.id)})}catch(e){t(`The sample wasn't asked for: ${e instanceof Error?e.message:String(e)} Press Make sample again.`)}finally{a(!1)}}}return d===null?(o===null||s)&&c.data!==void 0&&!c.data.fits?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[NXe(c.data,`This sample`),(0,h.jsx)(eE,{to:`/settings`,search:{section:`playback`},children:`Settings → Production defaults`}),`.`]}):(0,h.jsx)(K,{size:`small`,disabled:i||l===void 0,disabledReason:i?`Asking for the sample`:`Pricing the sample`,onClick:()=>void f(),children:l===void 0?`Make sample · pricing…`:`Make sample · ${o===null&&c.data!==void 0?U9(c.data):U9({high:l,unknown:+!!u,onPlan:c.data?.onPlan===!0})}`}):(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:d})}function p$e({view:e,onDone:t}){let{api:n}=q(),r=_(),i=!e.sample.fullScript,a=I({queryKey:[...b9(e.template.id),`quote`,`full-script`,i],queryFn:()=>D9(n,e.template.id,{fullScript:i})}),[o,s]=(0,m.useState)(!1);async function c(){if(a.data!==void 0){s(!0);try{let o=await tXe(n,e.template.id,{fullScript:i,acknowledgedHigh:a.data.high,acknowledgedUnknown:a.data.unknown>0});t(o.ok?null:o.message),await r.invalidateQueries({queryKey:b9(e.template.id)})}finally{s(!1)}}}return a.data!==void 0&&a.data.problem!==null?null:(0,h.jsx)(dD,{checked:e.sample.fullScript,disabled:o||a.data===void 0,onChange:()=>void c(),className:`text-left`,label:`Write the whole article in the sample${a.data===void 0?``:` (${U9(a.data)})`}`,help:`Off, the sample writes the outline and the first chapter. Your videos always get the whole article.`})}var m$e={queued:`Queued`,making:`Being made`,done:`Made`,failed:`Failed`,skipped:`No sample made`,held:`Waiting`};function h$e({view:e}){let t=e.paid.versions.filter(t=>t.version!==e.template.version);if(t.length===0)return null;let n=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});return(0,h.jsx)(SR,{summary:`Earlier samples`,state:String(t.length),children:(0,h.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 pb-3 text-small`,children:t.map(e=>(0,h.jsxs)(`li`,{className:`flex justify-between gap-3`,children:[(0,h.jsx)(`span`,{children:`Version ${String(e.version)} · ${m$e[e.state]}`}),(0,h.jsx)(`span`,{className:`text-ink-2`,children:n.format(new Date(e.updatedAt))})]},e.version))})})}function g$e(e){return e>0&&e<.005?`under $0.01`:`about ${nE(e)}`}var _$e=e=>e.replace(/[.*+?^${}()|[\]\\]/gu,`\\$&`);function v$e(e,t,n){return n===null||n.trim()===``?e:e.replace(RegExp(`(?<![\\p{L}\\p{N}])${_$e(t)}(?![\\p{L}\\p{N}])`,`giu`),n.trim())}function y$e({templateId:e,revisionId:t,aliasesOn:n,onAliasesOn:r}){let{api:i}=q(),a=I(mXe(i,e,t)),[o,s]=(0,m.useState)(``);if(a.error)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The names to check didn't load: ${a.error.message} Reload the page to try again.`});let c=a.data;if(c===void 0||c.names.length===0)return null;let l=o.trim(),u=c===void 0?[]:l===``||c.names.some(e=>e.term.toLowerCase()===l.toLowerCase())?c.names:[...c.names,{term:l,ipa:[],line:null,spokenAs:null}];return(0,h.jsxs)(`section`,{"aria-label":`Say it as`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(`h4`,{className:`m-0 text-small font-semibold text-ink`,children:`Names the voice may say wrong`}),c.problem===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:c.problem}),c.aliasesOn?null:n?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Save to have the narration use your pronunciations, then say a name another way.`}):(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-x-2 text-small text-ink-2`,children:[`The narration doesn't use your pronunciations yet.`,(0,h.jsx)(K,{size:`small`,onClick:r,children:`Use them`})]}),u.length===0?null:(0,h.jsx)(`ul`,{"aria-label":`Names to check`,className:`m-0 flex list-none flex-col gap-3 p-0`,children:u.map(t=>(0,h.jsx)(b$e,{templateId:e,name:t,voice:c.voice,enabled:c.aliasesOn},t.term))}),t===null?null:(0,h.jsx)(J,{label:`Another word to check`,help:`Type a name the article says to hear it in the template's voice.`,children:(0,h.jsx)(Y,{value:o,maxLength:100,placeholder:`A name the script says`,onChange:e=>s(e.target.value)})})]})}function b$e({templateId:e,name:t,voice:n,enabled:r}){let{api:i}=q(),a=_(),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(),[f,p]=(0,m.useState)(!1),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)();(0,m.useEffect)(()=>()=>{y!==void 0&&URL.revokeObjectURL(y)},[y]),(0,m.useEffect)(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);let x=v$e(t.line??t.term,t.term,o.trim()||t.spokenAs),S=I({queryKey:[`audition-quote`,n?.provider??``,n?.model??``,x],queryFn:()=>ih(i,[{speaker:`Sample`,provider:n?.provider??``,model:n?.model??``,text:x}]),enabled:n!==null,staleTime:6e4}),C=I({queryKey:[...b9(e),`say-it-as`,t.term,c],queryFn:()=>gXe(i,e,{written:t.term,spoken:c}),enabled:r&&c!==``});async function w(){if(n!==null){v(!0);try{let e=await ah(i,{...n,text:x}),t=URL.createObjectURL(e);b(t),new Audio(t).play().catch(()=>void 0)}catch(e){d({error:!0,text:`The line wasn't spoken: ${e instanceof Error?e.message:String(e)} Press Play again.`})}finally{v(!1)}}}async function T(){let n=C.data;if(n!==void 0){p(!0);try{let r=await _Xe(i,e,{written:t.term,spoken:c,acknowledgedHigh:n.high,acknowledgedUnknown:n.unknown>0});if(!r.ok){d({error:!0,text:r.message});return}d({error:!1,text:`Saved in your pronunciations: “${t.term}” is said “${c}”.${r.value.queued?` Re-voicing the sample's lines that say it.`:` The sample's article doesn't say it, so nothing is re-voiced.`}`}),s(``),await a.invalidateQueries({queryKey:b9(e)})}catch(e){d({error:!0,text:`“Say it as” wasn't saved: ${e instanceof Error?e.message:String(e)} Press Save again.`})}finally{p(!1)}}}let E=S.data?.estimate,D=E==null?`Play ${t.term}`:`Play ${t.term} · ${E.unknown>0?`price unknown`:g$e(E.high)}`,O=C.data?.lines??0,k=C.data===void 0?`Save`:O===0?`Save · nothing to re-voice`:`Save · re-voice ${String(O)} ${O===1?`line`:`lines`} · ${g$e(C.data.high)}`,A=r?c===``?`Type how to say it first`:C.data===void 0?`Pricing the re-voicing`:C.data.problem===null?f?`Saving`:void 0:C.data.problem:`Use your pronunciations first`;return(0,h.jsxs)(`li`,{"aria-label":t.term,className:`flex flex-col gap-2 border-line border-b pb-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,h.jsx)(`span`,{className:`text-body font-semibold text-ink`,children:t.term}),t.ipa.length===0?null:(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`/${t.ipa.join(` `)}/`}),t.spokenAs===null?null:(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Said as “${t.spokenAs}”`})]}),t.line===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:t.line}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,...GT,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(K,{size:`small`,variant:`quiet`,disabled:n===null||g,disabledReason:n===null?`Choose a voice in Narration first`:`Speaking`,onClick:()=>void w(),children:D}),(0,h.jsx)(Y,{"aria-label":`Say ${t.term} as`,className:`min-w-0 flex-1 basis-40`,value:o,maxLength:200,placeholder:`Say it as…`,disabled:!r,onChange:e=>s(e.target.value)}),(0,h.jsx)(K,{size:`small`,disabled:A!==void 0,disabledReason:A,focusableWhenDisabled:!0,onClick:()=>void T(),children:k})]}),(0,h.jsx)(KT,{children:`Save keeps it for every video and re-voices only the sample's lines with it.`})]}),u===void 0?null:(0,h.jsx)(`p`,{role:u.error?`alert`:`status`,className:u.error?`m-0 text-small text-danger`:`m-0 text-small text-ink-2`,children:u.text})]})}function x$e({view:e}){let[t,n]=(0,m.useState)(!1);return(0,h.jsxs)(`div`,{className:`flex items-end justify-between gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`div`,{className:`sl-kicker`,children:`Sample topic`}),(0,h.jsx)(`p`,{className:`m-0 text-body text-ink`,children:e.sample.topic})]}),(0,h.jsx)(K,{size:`small`,"aria-label":`Change the sample topic`,onClick:()=>n(!0),children:`Change`}),(0,h.jsx)(S$e,{view:e,open:t,onClose:()=>n(!1)})]})}function S$e({view:e,open:t,onClose:n}){let{api:r}=q(),i=_(),[a,o]=(0,m.useState)(`typed`),[s,c]=(0,m.useState)(e.sample.topic),[l,u]=(0,m.useState)(e.sample.topic),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(null),[v,y]=(0,m.useState)(!1),b=(0,m.useRef)(void 0);(0,m.useEffect)(()=>{let e=setTimeout(()=>u(s.trim()),400);return()=>clearTimeout(e)},[s]);let x=a===`typed`?l:a,S=I({queryKey:[...b9(e.template.id),`quote`,`topic`,x],queryFn:()=>D9(r,e.template.id,{topic:x}),enabled:t&&x!==``,retry:!1}),C=S.data?.unknown??0,w=x===``?`Type a topic first`:S.data===void 0?`Pricing the new topic`:S.data.problem===null?S.data.fits?C>0&&!d?`Accept the steps with no known price first`:void 0:MXe(S.data):`No sample can be made of this setup`;async function T(){if(S.data!==void 0){y(!0),g(null);try{let t={topic:x,acknowledgedHigh:S.data.high,acknowledgedUnknown:d},a=JSON.stringify(t);b.current?.key!==a&&(b.current={key:a,id:crypto.randomUUID()});let o=await eXe(r,e.template.id,{...t,mutationId:b.current.id});if(!o.ok){g(`The topic wasn't changed: ${o.message}`),o.quote!==null&&i.setQueryData([...b9(e.template.id),`quote`,`topic`,x],o.quote);return}b.current=void 0,await i.invalidateQueries({queryKey:b9(e.template.id)}),n()}catch(e){g(`The topic wasn't changed: ${e instanceof Error?e.message:String(e)} Press Use this topic again.`)}finally{y(!1)}}}let E=S.error?.message??S.data?.problem??null;return(0,h.jsx)(LT,{open:t,onClose:n,title:`Sample topic`,footer:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,h.jsx)(K,{onClick:n,children:`Cancel`}),(0,h.jsx)(K,{variant:`primary`,disabled:v||w!==void 0,disabledReason:v?`Changing the topic`:w??``,onClick:()=>void T(),children:S.data===void 0||S.data.problem!==null?`Use this topic`:`Use this topic · ${U9(S.data)}`})]}),children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Every section's sample is made about this topic. A new topic makes every sample again, at the price on the button; going back to the fixed topic is free.`}),(0,h.jsx)(fD,{label:`Topic`,help:`The next queued topic is the one a schedule makes its next video about.`,value:a,onChange:o,options:[{value:`typed`,label:`Type one`},{value:`next-queued`,label:`Next queued topic`},{value:`fixed`,label:`The fixed topic`}]}),a===`typed`?(0,h.jsx)(J,{label:`Your topic`,children:(0,h.jsx)(Y,{value:s,maxLength:300,onChange:e=>c(e.target.value)})}):null,C>0?(0,h.jsx)(dD,{checked:d,onChange:f,label:`Accept ${String(C)} ${C===1?`step`:`steps`} with no known price`,tip:`template-studio.accept-unknown`,tipLabel:`Steps with no known price`}):null,E===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:E}),p===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:p})]})})}var C$e=(e,t)=>t===`video`?e.free.video:t===`voice`?e.free.loudness:t===`document`?e.free.document:void 0,w$e=new Set([`keywords`,`providers`,`voice`]);function T$e({view:e,section:t,making:n,onMake:r,aliasesOn:i,onAliasesOn:a}){let{api:o}=q(),[s,c]=(0,m.useState)(null),l=I(x9(o,e.template.id)),u=C$e(e,t.id),d=i$e.includes(t.id),f=u!==void 0&&(u.state===`stale`||u.state===`needs-fix`),p=d&&[`stale`,`needs-fix`,`waiting`].includes(t.state)&&e.paid.state!==`queued`&&e.paid.state!==`making`,g=`/templates/${encodeURIComponent(e.template.id)}?section=${t.id}`,_=l.data?.version===e.template.version?l.data.checks.filter(e=>!e.ok&&w$e.has(e.id)):[],v=_.find(e=>e.fix?.href===g)??_[0],y=v?.fix,b=y!==void 0&&y.href===g,x=p?y===void 0?(0,h.jsx)(f$e,{view:e,onDone:c}):b?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`${v?.sentence??``} ${(e=>{let n=` in ${t.label}`;return e.endsWith(n)?`${e.slice(0,-n.length)} in this section's settings`:`Fix it in this section's settings`})(y.label)}, then Save.`}):(0,h.jsx)(eE,{to:y.href,className:`text-small`,children:`${y.label} first`}):u!==void 0&&!d&&f?(0,h.jsx)(K,{size:`small`,disabled:n,disabledReason:`Asking for the sample`,onClick:r,children:`Make sample · free`}):null;return(0,h.jsxs)(`section`,{"aria-label":`${t.label} sample`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(x$e,{view:e}),(0,h.jsx)(lD,{title:`Sample`,as:`h3`,className:`pb-0`,status:(0,h.jsx)(hE,{tone:az[t.state],children:oz(t)})}),(0,h.jsx)(`p`,{className:G(`m-0 text-small`,t.state===`needs-fix`?`text-danger`:`text-ink-2`),children:t.sentence}),x===null?null:(0,h.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:x}),s===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:s}),t.id===`script`&&e.template.document.form.sources.article===`generate`?(0,h.jsx)(p$e,{view:e,onDone:c}):null,(0,h.jsx)(s$e,{view:e,section:t.id}),t.id===`voice`&&t.state!==`off`&&t.state!==`provided`?(0,h.jsx)(y$e,{templateId:e.template.id,revisionId:e.paid.revisionId,aliasesOn:i,onAliasesOn:a}):null,(0,h.jsx)(E$e,{view:e,section:t.id}),d?(0,h.jsx)(h$e,{view:e}):null]})}function E$e({view:e,section:t}){let{api:n}=q(),r=e=>`${n.origin}${e}`,i=e.template.document.form.format;switch(t){case`video`:return e.free.video.url===null?null:(0,h.jsx)(O$e,{children:(0,h.jsx)(sR,{src:r(e.free.video.url),label:`${e.template.name}: 30-second video sample`,portrait:i===`9:16`,square:i===`1:1`})});case`voice`:return(0,h.jsx)(D$e,{view:e,at:r});case`document`:return e.free.document.url===null?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(O$e,{className:`max-md:hidden`,children:(0,h.jsx)(`iframe`,{title:`${e.template.name}: PDF sample`,src:`${r(e.free.document.url)}#page=1&view=FitH`,className:`block h-[520px] w-full border-0 bg-surface`})}),(0,h.jsx)(tE,{href:r(e.free.document.url),target:`_blank`,rel:`noreferrer`,size:`small`,className:`self-start`,children:`Open the PDF sample`})]});case`reviews`:return e.reviews.length===0?null:(0,h.jsx)(n2,{label:`Where a run pauses`,steps:e.reviews.map(e=>({id:e.id,name:e.name,tone:e.kind===`checkpoint`?`waiting`:`info`,state:e.kind===`checkpoint`?`Waits for you`:`Checked by AI`,time:e.by===`you`?`You`:e.by===`agent`?`Agent`:`Model`,detail:e.detail}))});default:return null}}function D$e({view:e,at:t}){let n=o$e(e),{loudness:r}=e.free,i=r.beforeUrl!==null&&r.url!==null,[a,o]=(0,m.useState)(n===void 0?`after`:`sample`),s=[...n===void 0?[]:[{value:`sample`,label:`Your voice's sample`,url:n.url,name:`${e.template.name}: sample narration`}],...i?[{value:`before`,label:(0,h.jsx)(`span`,{title:k$e(r.beforeLufs),children:`Before levelling`}),url:r.beforeUrl??``,name:`Sample narration before levelling`},{value:`after`,label:(0,h.jsx)(`span`,{title:k$e(r.afterLufs),children:`After levelling (YouTube loudness)`}),url:r.url??``,name:`Sample narration after levelling`}]:[]],c=s.find(e=>e.value===a)??s[0];return c===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[s.length>1?(0,h.jsx)(fD,{label:`Hear`,help:`Levelling evens the narration out to YouTube's loudness.`,value:c.value,options:s.map(({value:e,label:t})=>({value:e,label:t})),onChange:o}):null,(0,h.jsx)(w6,{src:t(c.url),label:c.name},c.value),i&&A$e(r)!==``?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:A$e(r)}):null]})}function O$e({children:e,className:t}){return(0,h.jsx)(`div`,{className:G(`overflow-hidden rounded-media border border-line`,t),children:e})}var k$e=e=>e===null?void 0:`${e.toFixed(1)} LUFS`;function A$e(e){let{afterLufs:t,targetLufs:n,ceiling:r}=e;if(t===null||n===null||r===null)return``;let i=n-t;return Math.abs(i)<=.5?``:i<0?`It comes out ${Math.abs(i).toFixed(1)} LU louder than YouTube's ${n.toFixed(1)} LUFS.`:`Held back ${i.toFixed(1)} LU from YouTube's ${n.toFixed(1)} LUFS so its peaks stay under ${r.toFixed(1)} dBTP.`}function j$e({view:e,document:t,name:n,dirty:r,note:i}){let{api:a}=q(),o=_(),s=e.template.id,[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(crypto.randomUUID());async function p(){d(!0),l({tone:`info`,text:`Saving…`});try{let r=await ZYe(a,s,{mutationId:f.current,baseVersion:e.template.version,name:n.trim()===``?e.template.name:n.trim(),document:t,sample:`skip`,acknowledgedHigh:0,acknowledgedUnknown:!1});if(!r.ok){l({tone:`error`,text:`The template wasn't saved: ${r.message}`});return}f.current=crypto.randomUUID(),l(void 0),await o.invalidateQueries({queryKey:PM}),await o.invalidateQueries({queryKey:b9(s)})}catch(e){l({tone:`error`,text:`The template wasn't saved: ${e instanceof Error?e.message:String(e)} Press Save again.`})}finally{d(!1)}}let g=c??i??(r?{tone:`info`,text:`Unsaved changes. Save them before you make a video.`}:void 0);return!r&&g===void 0?null:(0,h.jsx)(uL,{status:(0,h.jsx)(lL,{tone:g?.tone??`info`,wrap:!0,children:g?.text}),children:r?(0,h.jsx)(K,{variant:`primary`,disabled:u,onClick:()=>void p(),children:`Save`}):null})}function M$e({view:e}){let{runs:t,cost:n}=e.schedule,r=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`});return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[t.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No schedule runs this template yet. A schedule makes a video from it on the days and at the times you pick, each about the next topic in its queue. New schedule, above, starts one with this template.`}):(0,h.jsx)(s1,{caption:`The next runs`,rowKey:e=>`${e.scheduleId}:${e.at}`,rows:t,empty:`No run is coming up.`,columns:[{id:`when`,header:`When`,cell:e=>r.format(new Date(e.at))},{id:`title`,header:`Title`,cell:e=>e.topic?e.title:`No topic queued yet`},{id:`schedule`,header:`Schedule`,cell:e=>e.paused?`${e.scheduleName} (paused)`:e.scheduleName}]}),n===null?null:(0,h.jsx)(`p`,{className:n.problem===null?`m-0 text-small text-ink-2`:`m-0 text-small text-danger`,children:n.problem??P$e(n)}),(0,h.jsx)(eE,{to:`/calendar`,search:{tab:`schedules`},className:`self-start text-small`,children:`Schedules in the calendar`})]})}var N$e=e=>{let t=Math.round(e);return t===0?`less than one run`:`about ${String(t)} ${t===1?`run`:`runs`}`};function P$e(e){let t=e.unknown===0?``:e.unpriced.length===0?` ${String(e.unknown)} ${e.unknown===1?`step has`:`steps have`} no known price and ${e.unknown===1?`isn't`:`aren't`} counted.`:` Not counted, with no known price: ${I$e(e.unpriced)}.`,n=t=>e.unknown===0?`about ${nE(t)} a month at most`:`at least ${nE(t)} a month`,r=`${F$e(n(e.high))}, for ${N$e(e.runs)}.`,{paused:i}=e;if(i.schedules===0)return`${r}${t}`;let a=`${n(i.high)}, for ${N$e(i.runs)}`;return e.runs===0?`${i.schedules===1?`1 paused schedule uses this template: nothing runs while it is paused. Resumed, ${a}.`:`${String(i.schedules)} paused schedules use this template: nothing runs while they are paused. Resumed, ${a}.`}${t}`:`${r} ${i.schedules===1?`1 paused schedule`:`${String(i.schedules)} paused schedules`} would add ${a}, once resumed.${t}`}var F$e=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function I$e(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e.at(-1)??``}`}var L$e={receipt:null,pending:!1,starting:!1,uncertain:!1,valid:!1,error:null,fields:[],created:null};function R$e({document:e,onEdit:t,onFiles:n,children:r}){let i=(0,m.useMemo)(()=>({section:`content`,navigate:async()=>void 0,review:L$e,reviewDraft:async()=>void 0,startRun:async()=>void 0,invalidateReview:()=>void 0,takeCreated:()=>null,activeId:null,fontUpload:{pending:!1,error:void 0,pick:n},fontUploading:!1,attachmentUploading:()=>!1,selectFont:n=>t({...e,form:{...e.form,subtitles:{...e.form.subtitles,fontId:n}}}),uploadSubtitleFont:async()=>n(),document:e,view:null,status:`saved`,error:null,edited:0,acknowledged:0,reveal:null,attach:async()=>n(),edit:t,flush:async()=>!0,open:async()=>!1,generation:()=>0,newDraft:async()=>void 0,discard:async()=>void 0,saveAsNew:async()=>void 0}),[e,t,n]);return(0,h.jsx)(sCe,{value:i,children:r})}function z$e({section:e,document:t,name:n,onEdit:r,onName:i}){let{form:a}=t;return e===`subject`?(0,h.jsxs)(`div`,{"data-slot":`studio-controls`,className:`sl-fields`,children:[(0,h.jsx)(J,{label:`Template name`,children:(0,h.jsx)(Y,{value:n,maxLength:120,onChange:e=>i(e.target.value)})}),(0,h.jsx)(J,{label:`Video title`,help:`{{Topic}} is filled with each video's topic.`,children:(0,h.jsx)(Y,{value:a.title,maxLength:200,onChange:e=>r({...t,form:{...a,title:e.target.value}})})})]}):e===`script`&&a.sources.article===`generate`?(0,h.jsx)(`div`,{"data-slot":`studio-controls`,className:`sl-fields`,children:(0,h.jsx)(J,{label:`Words per video`,help:`About 150 words is one minute. The article prompt decides the real length.`,children:(0,h.jsx)(Y,{inputMode:`numeric`,className:`sl-input--number`,value:t.expectedWords,onChange:e=>r({...t,expectedWords:e.target.value})})})}):null}function B$e({templateId:e,section:t,compare:n,play:r}){let{api:i}=q();Lge({templateId:e,section:qx[t]});let a=I(JYe(i,e)),o=I({...PL(i,e),enabled:a.error!==null,retry:!1});return a.error&&o.data!==void 0?(0,h.jsx)(Yi,{to:`/design-templates/$templateId`,params:{templateId:e},search:{},replace:!0}):a.error&&o.isFetching?(0,h.jsx)(W9,{}):a.error?(0,h.jsxs)(`div`,{children:[(0,h.jsx)(fL,{title:`Edit template`,crumb:(0,h.jsx)(eE,{to:`/templates`,children:`Templates`})}),(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:`This template didn't open: ${a.error.message}`})]}):a.data===void 0?(0,h.jsx)(W9,{}):(0,h.jsx)(V$e,{view:a.data,section:t,compare:n,play:r},`${a.data.template.id}:${String(a.data.template.version)}`)}function V$e({view:e,section:t,compare:n,play:r}){let{api:i}=q(),a=_();$x(`${e.template.name} · Edit template`);let o=e.template.document,[s,c]=(0,m.useState)(o),[l,u]=(0,m.useState)(e.template.name),[d,f]=(0,m.useState)(`settings`),[p,g]=(0,m.useState)(),[v,y]=(0,m.useState)(!1),b=(0,m.useRef)(!1),x=H9(),S=I(x9(i,e.template.id)),C=S.data?.version===e.template.version?S.data.checks.filter(e=>!e.ok).length:0;async function w(){y(!0);try{await YYe(i,e.template.id),await a.invalidateQueries({queryKey:b9(e.template.id)})}catch(e){g({tone:`error`,text:`The samples weren't asked for: ${e instanceof Error?e.message:String(e)} Press Make sample again.`})}finally{y(!1)}}(0,m.useEffect)(()=>{let t=[e.free.video,e.free.loudness,e.free.document],n=e.schedule.cost!==null&&e.schedule.cost.problem!==null;!b.current&&(n||t.some(e=>e.state===`stale`))&&(b.current=!0,w())},[e]);let T=l.trim(),E=JSON.stringify(s)!==JSON.stringify(o)||T!==``&&T!==e.template.name,D=e.sections.find(e=>e.id===t)??e.sections[0],O=t$e(e,E),k=(0,m.useCallback)(()=>g({tone:`info`,text:`Files are added to each video on Create: the template keeps only that the video provides them.`}),[]),A=(0,m.useCallback)(e=>{c(e),g(void 0)},[]);if(D===void 0)return(0,h.jsx)(W9,{});let j=RQe(D.id),M=e=>d===e?void 0:`max-md:hidden`,N=e.gated||e.schedule.cost!==null,P=N?n$e(e):void 0,ee=P?.line===void 0?void 0:O===void 0?P.line:`${P.line} First ${O}.`;return(0,h.jsxs)(R$e,{document:s,onEdit:A,onFiles:k,children:[(0,h.jsx)(N2,{dirty:E,what:`your template changes`,saveLabel:`Save`}),(0,h.jsx)(fL,{crumb:(0,h.jsx)(eE,{to:`/templates`,children:`Templates`}),title:`Edit template`,meta:`${e.template.name} · version ${String(e.template.version)}${P===void 0?``:` · ${P.word}`}`,actions:(0,h.jsx)(r$e,{view:e,dirty:E,scheduled:N,play:r,onProblem:e=>g(e===void 0?void 0:{tone:`error`,text:e})})}),ee===void 0?null:(0,h.jsx)(`p`,{className:`m-0 -mt-2 mb-3 text-small text-ink-2`,children:ee}),(0,h.jsx)(gL,{className:`mb-4 md:hidden`,label:`Edit template panes`,idPrefix:`studio`,value:d,onChange:f,items:[{id:`sections`,label:`Sections`},{id:`settings`,label:`Settings`},{id:`sample`,label:C===0?`Sample`:`Sample · ${String(C)} to fix`}]}),(0,h.jsx)(pL,{className:`sl-workspace--studio`,asideLabel:`Sample and checks`,sections:(0,h.jsx)(`div`,{className:M(`sections`),children:(0,h.jsx)(qEe,{templateId:e.template.id,sections:e.sections,current:D.id})}),aside:(0,h.jsxs)(`div`,{className:G(`flex flex-col gap-5`,M(`sample`)),children:[D.id===`schedule`?null:(0,h.jsx)(T$e,{view:e,section:D,making:v,onMake:()=>void w(),aliasesOn:s.form.audio.useNarrationAliases===!0,onAliasesOn:()=>A({...s,form:{...s.form,audio:{...s.form.audio,useNarrationAliases:!0}}})}),(0,h.jsx)(oQe,{templateId:e.template.id}),(0,h.jsx)(qQe,{templateId:e.template.id,dirty:E})]}),children:(0,h.jsxs)(`section`,{"aria-label":`${D.label} settings`,className:G(`flex min-w-0 flex-col gap-4`,M(`settings`)),children:[(0,h.jsx)(lD,{title:D.label,as:`h2`,className:`pb-0`}),j===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(GQe,{templateId:e.template.id,section:j,document:s,dirty:E,preset:n}),(0,h.jsx)(WQe,{templateId:e.template.id,section:j,onUse:(e,t)=>{A(BQe(s,j,e)),g({tone:`success`,text:t})}})]}),D.id===`schedule`?(0,h.jsx)(M$e,{view:e}):(0,h.jsxs)(h.Fragment,{children:[D.id===`subject`?(0,h.jsx)(z$e,{section:`subject`,document:s,name:l,onEdit:A,onName:u}):null,(0,h.jsx)(ZQe,{section:D.id,document:s}),(0,h.jsx)(YQe,{section:D.id,defaults:x,onFiles:k}),D.id===`script`?(0,h.jsx)(z$e,{section:`script`,document:s,name:l,onEdit:A,onName:u}):null,D.id===`thumbnail`?(0,h.jsx)(QQe,{templateId:e.template.id,document:s}):null]}),(0,h.jsx)(NQe,{view:e,section:D.id})]})}),(0,h.jsx)(j$e,{view:e,document:s,name:l,dirty:E,note:p})]})}function W9(){return(0,h.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Loading the template`,children:[(0,h.jsx)(`div`,{className:`mb-4 h-8 w-72 rounded-control bg-raised`}),(0,h.jsxs)(`div`,{className:`sl-workspace sl-workspace--studio`,children:[(0,h.jsx)(`div`,{className:`h-96 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`h-96 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`h-96 rounded-control bg-raised`})]})]})}function H$e(){let e=GP(),t=Ji();return{getGeneration:e.generation,blocked:e.review.starting||e.review.uncertain||e.review.created!==null,beforeApply:e.flush,onApplied:async(n,r)=>!r()||!await e.open(n,r)||!r()?!1:(await t({to:`/play`}),r())}}var G9=va({component:CTe,notFoundComponent:nRe}),U$e=ga({getParentRoute:()=>G9,path:`/`,component:W$e});function W$e(){let e=GP(),t=Ji();return(0,h.jsx)(RLe,{startFrom:{getGeneration:e.generation,blocked:e.review.starting||e.review.uncertain||e.review.created!==null,beforeApply:e.flush,onApplied:async(n,r)=>!r()||!await e.open(n,r)||!r()?!1:(await t({to:`/play`}),r())}})}function K9(e){let t=Sqe(e.show),n=typeof e.q==`string`&&e.q.trim()!==``?e.q.slice(0,200):``,r=Tqe(e.sort);return{...t===void 0||t===`all`?{}:{show:t},...n===``?{}:{q:n},...r===void 0||r===`newest`?{}:{sort:r}}}var G$e=ga({getParentRoute:()=>G9,path:`projects`,validateSearch:K9,component:K$e});function K$e(){let{show:e,q:t,sort:n}=G$e.useSearch(),r=Ji();return(0,h.jsx)(Mqe,{filter:e??`all`,query:t??``,sort:n??`newest`,onFilter:e=>{r({to:`/projects`,search:K9({show:e,q:t,sort:n}),replace:!0,resetScroll:!1})},onQuery:t=>{r({to:`/projects`,search:K9({show:e,q:t,sort:n}),replace:!0,resetScroll:!1})},onSort:n=>{r({to:`/projects`,search:K9({show:e,q:t,sort:n}),replace:!0,resetScroll:!1})}})}function q$e(e){let t=R9.find(t=>t===e.step);return t===void 0||t===`found`?{}:{step:t}}var J$e=ga({getParentRoute:()=>G9,path:`welcome`,validateSearch:q$e,component:Y$e});function Y$e(){let{step:e}=J$e.useSearch(),t=Ji();return(0,h.jsx)(kQe,{step:e??`found`,onStep:e=>{t({to:`/welcome`,search:q$e({step:e}),replace:!0})}})}var X$e=ga({getParentRoute:()=>G9,path:`play`,component:OBe}),q9=ga({getParentRoute:()=>G9,id:`_library`,component:zLe}),Z$e=ga({getParentRoute:()=>G9,path:`library`,beforeLoad:()=>{throw cn({to:`/prompts`,search:{kind:`article`}})}}),Q$e=ga({getParentRoute:()=>G9,path:`channels`,validateSearch:e=>e.tab===void 0?{}:{tab:h1(e.tab)},component:$$e});function $$e(){let{tab:e}=Q$e.useSearch(),t=Ji();return(0,h.jsx)(yFe,{tab:e??`brand`,onTab:e=>{t({to:`/channels`,search:{tab:e},resetScroll:!1})}})}var J9=ga({getParentRoute:()=>G9,path:`channels/$channelId`,validateSearch:e=>e.tab===void 0?{}:{tab:h1(e.tab)},component:e1e});function e1e(){let{channelId:e}=J9.useParams(),{tab:t}=J9.useSearch(),n=Ji();return(0,h.jsx)(g1,{channelId:e,tab:t??`brand`,onTab:t=>{n({to:`/channels/$channelId`,params:{channelId:e},search:{tab:t},resetScroll:!1})}},e)}var t1e=ga({getParentRoute:()=>G9,path:`designs`,beforeLoad:({search:e})=>{if(e.tab===`templates`)throw cn({to:`/templates`,search:{tab:`posters`},replace:!0})},component:VEe}),n1e=ga({getParentRoute:()=>G9,path:`designs/$designId`,component:r1e});function r1e(){let{designId:e}=n1e.useParams();return(0,h.jsx)(LEe,{designId:e},e)}var i1e=ga({getParentRoute:()=>G9,path:`design-templates/$templateId`,component:a1e});function a1e(){let{templateId:e}=i1e.useParams();return(0,h.jsx)(cDe,{templateId:e},e)}var o1e=ga({getParentRoute:()=>G9,path:`templates`,validateSearch:e=>({...pQe(e.tab)===`posters`?{tab:`posters`}:{},...pz(e.item)}),component:f1e}),s1e=/^[0-9A-Za-z-]{1,64}$/;function Y9(e){let t=pPe(e.tab);return t===`releases`?{tab:t}:t===`schedules`?typeof e.schedule==`string`&&s1e.test(e.schedule)?{tab:`schedules`,schedule:e.schedule}:{tab:`schedules`}:{}}var c1e=ga({getParentRoute:()=>G9,path:`calendar`,validateSearch:Y9,component:d1e}),l1e=ga({getParentRoute:()=>G9,path:`schedules`,beforeLoad:()=>{throw cn({to:`/calendar`,search:{tab:`schedules`},replace:!0})}}),u1e=ga({getParentRoute:()=>G9,path:`schedules/$scheduleId`,beforeLoad:({params:e})=>{throw cn({to:`/calendar`,search:Y9({tab:`schedules`,schedule:e.scheduleId}),replace:!0})}});function d1e(){let e=Y9(c1e.useSearch()),t=Ji();return(0,h.jsx)(gPe,{tab:e.tab??`weeks`,schedule:e.schedule,onTab:e=>{t({to:`/calendar`,search:e===`weeks`?{}:{tab:e},resetScroll:!1})},onSchedule:e=>{t({to:`/calendar`,search:{tab:`schedules`,schedule:e},replace:!0})}})}function f1e(){let{tab:e,item:t}=o1e.useSearch(),n=Ji();return(0,h.jsx)(hQe,{...H$e(),tab:e??`videos`,item:t,onTab:e=>{n({to:`/templates`,search:e===`posters`?{tab:`posters`}:{},resetScroll:!1})}})}var X9=ga({getParentRoute:()=>G9,path:`templates/$templateId`,validateSearch:e=>{let t=Kx.find(t=>t===e.section),n=e=>typeof e==`string`&&e.trim()!==``&&e.length<=200?e:void 0,r=n(e.compareProvider),i=n(e.compareModel);return{...t===void 0?{}:{section:t},...r===void 0||i===void 0?{}:{compareProvider:r,compareModel:i}}},component:p1e});function p1e(){let{templateId:e}=X9.useParams(),{section:t,compareProvider:n,compareModel:r}=X9.useSearch();return(0,h.jsx)(B$e,{templateId:e,play:H$e(),section:t??`subject`,compare:n===void 0||r===void 0?void 0:{provider:n,model:r}},e)}var m1e=ga({getParentRoute:()=>G9,path:`projects/$projectId`,validateSearch:e=>{let t=A7(e.section);return t===void 0?{}:{section:t}},component:P1e}),h1e=ga({getParentRoute:()=>q9,path:`prompts`,validateSearch:e=>({kind:vO(e.kind),...pz(e.item)}),component:F1e}),g1e=ga({getParentRoute:()=>G9,path:`prompts/new`,validateSearch:e=>{let t=vO(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:I1e}),_1e=ga({getParentRoute:()=>G9,path:`prompts/$promptId`,component:L1e}),v1e=ga({getParentRoute:()=>q9,path:`entries`,validateSearch:e=>({category:dO(e.category),...pz(e.item)}),component:z1e}),y1e=ga({getParentRoute:()=>G9,path:`entries/new`,validateSearch:e=>{let t=dO(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:B1e}),b1e=ga({getParentRoute:()=>G9,path:`entries/$entryId`,component:V1e}),x1e=ga({getParentRoute:()=>q9,path:`narration-aliases`,component:tRe}),S1e=ga({getParentRoute:()=>q9,path:`name-pronunciations`,component:HLe}),C1e=ga({getParentRoute:()=>q9,path:`ab-results`,component:lOe}),w1e=ga({getParentRoute:()=>q9,path:`document-themes`,validateSearch:e=>pz(e.item),component:uIe}),T1e=ga({getParentRoute:()=>G9,path:`document-themes/new`,validateSearch:e=>typeof e.from==`string`?{from:e.from}:{},component:H1e}),E1e=ga({getParentRoute:()=>G9,path:`document-themes/$themeId`,component:U1e});function D1e(e){let t=e.section===void 0?void 0:OE(e.section),n=t===`patch-notes`&&typeof e.note==`string`&&/^[0-9A-Za-z][0-9A-Za-z.-]{0,63}$/.test(e.note)?e.note:void 0,r=[`llm`,`tts`,`image`].find(t=>t===e.family),i=typeof e.provider==`string`&&/^[a-z0-9-]{1,40}$/.test(e.provider)?e.provider:void 0,a=[`welcome`,`play`].find(t=>t===e.return),o=a!==void 0&&typeof e.step==`string`&&/^[a-z-]{1,20}$/.test(e.step)?e.step:void 0;return{...t===void 0?{}:{section:t},...n===void 0?{}:{note:n},...r===void 0?{}:{family:r},...i===void 0?{}:{provider:i},...a===void 0?{}:{return:a},...o===void 0?{}:{step:o}}}var O1e=ga({getParentRoute:()=>G9,path:`settings`,validateSearch:D1e,component:N1e}),Z9=ga({getParentRoute:()=>G9,path:`help/tutorials/$page`,validateSearch:e=>typeof e.q==`string`&&e.q.trim()!==``?{q:e.q.slice(0,200)}:{},component:k1e});function k1e(){let{page:e}=Z9.useParams(),{q:t}=Z9.useSearch(),n=Ha({select:e=>e.hash});return(0,h.jsx)(yQe,{page:e,anchor:n===``?void 0:n,words:t})}var A1e=ga({getParentRoute:()=>G9,path:`help`,beforeLoad:()=>{throw cn({to:`/help/tutorials/$page`,params:{page:`Home`}})}}),j1e=ga({getParentRoute:()=>G9,path:`help/tutorials`,beforeLoad:()=>{throw cn({to:`/help/tutorials/$page`,params:{page:`Home`}})}}),M1e=ga({getParentRoute:()=>G9,path:`usage`,beforeLoad:()=>{throw cn({to:`/settings`,search:{section:`usage`}})}});function N1e(){let{section:e,note:t,family:n,provider:r,return:i,step:a}=O1e.useSearch(),o=Ji(),s=EE.find(t=>t.id===(e??`providers`));return $x(s===void 0?`Settings`:`Settings · ${s.label}`),(0,h.jsx)(YZe,{section:e??`providers`,note:t,family:n,provider:r,back:i===void 0?void 0:{to:i,step:a},onSection:e=>{o({to:`/settings`,search:{section:e,...i===void 0?{}:{return:i},...a===void 0?{}:{step:a}},resetScroll:!1})},onNote:e=>{o({to:`/settings`,search:{section:`patch-notes`,...e===void 0?{}:{note:e}}})}})}function P1e(){let{projectId:e}=m1e.useParams(),t=GP(),n=Ji();return(0,h.jsx)(fqe,{projectId:e,openDraft:async e=>!await t.flush()||!await t.open(e)?!1:(await n({to:`/play`}),!0)},e)}function F1e(){let{kind:e}=h1e.useSearch(),t=Q9();return(0,h.jsx)(Nqe,{kind:e,onMakeVideo:t.use,makeBlocked:t.blocked})}function Q9(){let e=GP(),t=Ji();return{blocked:e.review.starting||e.review.uncertain||e.review.created!==null?`Create is starting a video from its draft. Wait for it to start, then try again.`:void 0,use:n=>{let r=oOe(e.document,n);e.edit(r.document),t({to:`/play`}).then(()=>e.navigate(r.section,r.field))}}}function I1e(){let{kind:e,from:t}=g1e.useSearch(),n=R1e(),r=Q9();return(0,h.jsx)(yB,{promptId:void 0,kind:e,from:t,onLeave:n,onMakeVideo:r.blocked===void 0?r.use:void 0},`${e}:${t??`new`}`)}function L1e(){let{promptId:e}=_1e.useParams(),t=R1e(),n=Q9();return(0,h.jsx)(yB,{promptId:e,kind:`article`,from:void 0,onLeave:t,onMakeVideo:n.blocked===void 0?n.use:void 0},e)}function R1e(){let e=Ji();return t=>{e({to:`/prompts`,search:{kind:t}})}}function z1e(){let{category:e}=v1e.useSearch(),t=Q9();return(0,h.jsx)(xIe,{category:e,onMakeVideo:t.use,makeBlocked:t.blocked})}function B1e(){let{category:e,from:t}=y1e.useSearch(),n=G1e();return(0,h.jsx)(Y0,{entryId:void 0,category:e,from:t,onLeave:n})}function V1e(){let{entryId:e}=b1e.useParams(),t=G1e();return(0,h.jsx)(Y0,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function H1e(){let{from:e}=T1e.useSearch(),t=W1e();return(0,h.jsx)(L1,{themeId:void 0,from:e,onLeave:t})}function U1e(){let{themeId:e}=E1e.useParams(),t=W1e();return(0,h.jsx)(L1,{themeId:e,from:void 0,onLeave:t})}function W1e(){let e=Ji();return()=>{e({to:`/document-themes`})}}function G1e(){let e=Ji();return t=>{e({to:`/entries`,search:{category:t}})}}var K1e=G9.addChildren({homeRoute:U$e,projectsRoute:G$e,welcomeRoute:J$e,playRoute:X$e,libraryRoute:q9.addChildren({promptsRoute:h1e,entriesRoute:v1e,documentThemesRoute:w1e,narrationAliasesRoute:x1e,namePronunciationsRoute:S1e,abResultsRoute:C1e}),templatesRoute:o1e,templateStudioRoute:X9,designsRoute:t1e,schedulesRoute:l1e,scheduleRoute:u1e,calendarRoute:c1e,libraryIndexRoute:Z$e,channelsRoute:Q$e,channelRoute:J9,designPageRoute:n1e,designTemplateRoute:i1e,projectRoute:m1e,newPromptRoute:g1e,promptRoute:_1e,newEntryRoute:y1e,entryRoute:b1e,newDocumentThemeRoute:T1e,documentThemeRoute:E1e,settingsRoute:O1e,usageRoute:M1e,helpRoute:A1e,tutorialsIndexRoute:j1e,tutorialsRoute:Z9});function q1e(){return Fa({routeTree:K1e,defaultErrorComponent:rRe,scrollRestoration:({location:e})=>!Kge(e.pathname,e.search)})}function J1e(){let e,t,n=new Set;return{observe:r=>{if(e===void 0){e=r;for(let e of n)e()}else if(r!==e&&r!==t){t=r;for(let e of n)e()}},staleAt:()=>t,loadedAt:()=>e,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function Y1e(e,t){return async(n,r)=>{let i=await e(n,r),a=i.headers.get(`X-Slopify-Version`);return a!==null&&t.observe(a),i}}function X1e(){let e=new Map;return{observe:t=>{if(t.type===`stage.state`){let n=e.get(t.projectId);if(n){for(let[e,r]of n)r.stage===t.stage&&r.revisionId===t.revisionId&&r.workId===t.workId&&n.delete(e);n.size===0&&e.delete(t.projectId)}return}if(t.type!==`llm.preview`)return;let n=e.get(t.projectId)??new Map,r=JSON.stringify([t.revisionId,t.workId,t.callId]),i=n.get(r),a=(t.reset?t.text:`${i?.text??``}${t.text}`).slice(-65536);for(n.delete(r),n.set(r,{...t,text:a,reset:!0});n.size>8;){let e=n.keys().next().value;e!==void 0&&n.delete(e)}for(e.delete(t.projectId),e.set(t.projectId,n);e.size>16;){let t=e.keys().next().value;t!==void 0&&e.delete(t)}},snapshot:t=>[...e.get(t)?.values()??[]],snapshotAll:()=>[...e.values()].flatMap(e=>[...e.values()])}}var Z1e=/\/events\/projects\/([^/?#]+)/,Q1e=/\/events\/global(?:[?#]|$)/,$1e=[`running.count`,`staging.progress`,`staging.failed`,`schedule.topics`,`template.sample`,`stage.state`,`stage.progress`,`article.delta`,`llm.preview`,`image.landed`,`narration.piece`,`project.state`,`project.updated`,`review.flagged`,`review.auto-passed`,`assistant.delta`,`assistant.tool`,`assistant.ask`,`assistant.turn`,`design.changed`,`design-template.sample`],e0e=2,t0e=e=>Math.min(3e4,1e3*2**e);function n0e(e,t=(e,t)=>setTimeout(e,t)){let n=new Set,r=X1e(),i,a=!1,o=0,s=(e,t,n)=>{for(let r of e.listeners.get(t)??[])r({data:n})},c=l=>{if(i!==void 0)return;let u=e(l);i=u,u.addEventListener(`open`,()=>{a=!0,o=0;for(let e of[...n])for(let t of e.opens)t()}),u.addEventListener(`error`,()=>{if(i!==u)return;for(let e of[...n])s(e,`error`,``);if(u.readyState!==e0e)return;u.close(),i=void 0;let e=t0e(o);o+=1,t(()=>{i===void 0&&n.size>0&&c(l)},e)});for(let e of $1e)u.addEventListener(e,t=>{let i;try{let n=JSON.parse(t.data);typeof n.projectId==`string`&&(i=n.projectId),(e===`llm.preview`||e===`stage.state`)&&r.observe(n)}catch{return}for(let r of[...n])(r.projectId===void 0||r.projectId===i)&&s(r,e,t.data)})};return t=>{let o=Z1e.exec(t)?.[1];if(o===void 0&&!Q1e.test(t))return e(t);c(o===void 0?t:t.replace(Z1e,`/events/global`));let l={projectId:o===void 0?void 0:decodeURIComponent(o),listeners:new Map,opens:new Set};return n.add(l),a&&queueMicrotask(()=>{if(n.has(l)){for(let e of l.opens)e();if(l.projectId!==void 0)for(let e of r.snapshot(l.projectId))s(l,`llm.preview`,JSON.stringify(e))}}),{addEventListener:(e,t)=>{if(e===`open`){l.opens.add(t);return}let n=l.listeners.get(e)??new Set;n.add(t),l.listeners.set(e,n)},close:()=>{n.delete(l),n.size===0&&i!==void 0&&(i.close(),i=void 0,a=!1)}}}}function r0e(e){let t=J1e(),n={api:$ee(window.location.origin,Y1e(window.fetch.bind(window),t),tte(e=>{let n=e.headers.get(`X-Slopify-Version`);n!==null&&t.observe(n)})),openEvents:n0e(e=>new EventSource(e)),version:t};(0,qee.createRoot)(e).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:new Ge,children:(0,h.jsx)(nle,{deps:n,children:(0,h.jsx)(Ra,{router:q1e()})})})}))}var $9=document.getElementById(`root`);if($9===null)throw Error(`index.html carries no #root element for the app to mount on`);r0e($9);
|
|
459
|
+
`)}function mQe(e){return e===`posters`?`posters`:`videos`}var hQe=7;function gQe({tab:e=`videos`,onTab:t,item:n,...r}){let{api:i}=q(),a=_(),o=I(RM(i)),s=I(GYe(i)),c=I(xD(i)),l=$R(),[u,d]=(0,m.useState)(!1),f=oQe(),[p,g]=(0,m.useState)(e),v=t===void 0?p:e,y=e=>t===void 0?g(e):t(e);ND({id:`templates.add-starters`,title:`Add starter templates`,group:`Templates`,keywords:[`template`,`starter`,`pack`],run:()=>d(!0)});let b=o.data?.length,x=I(NL(i)),S=I({queryKey:FE,queryFn:()=>zE(i)}).data?.packs.every(e=>e.installed)===!0;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(fL,{title:`Templates`,meta:v===`videos`?`A template is a saved setup. Make a video from one, or edit what it makes.`:`A poster template is a saved poster with keywords. Make a poster from one, or edit what it makes.`,actions:v===`videos`?(0,h.jsxs)(h.Fragment,{children:[b===0||S?null:(0,h.jsx)(K,{onClick:()=>d(!0),"aria-expanded":u,children:`Add starter templates`}),(0,h.jsx)(K,{disabled:f.busy,onClick:f.choose,children:`Import a template file (.zip)`})]}):x.data?.length===0?void 0:(0,h.jsx)(K,{disabled:l.busy,onClick:l.startTemplate,children:`New poster template`})}),f.input,l.input,(0,h.jsx)(nQe,{open:u,onClose:()=>d(!1),onInstalled:()=>void a.invalidateQueries({queryKey:PM})}),(0,h.jsx)(gL,{label:`Kinds of template`,idPrefix:`templates`,value:v,onChange:y,items:[{id:`videos`,label:b===void 0?`Video templates`:`Video templates (${String(b)})`},{id:`posters`,label:`Poster templates`}],className:`mb-4`}),(0,h.jsxs)(`div`,{role:`tabpanel`,id:`templates-panel-${v}`,"aria-labelledby":`templates-tab-${v}`,children:[f.problem===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-3 text-small text-danger`,children:f.problem}),v===`videos`?(0,h.jsx)(_Qe,{templates:o,cards:s.data,channels:c.data??[],play:r,item:n,onAdd:()=>d(!0)}):(0,h.jsx)(yQe,{problem:l.problem,onNew:l.startTemplate})]})]})}function _Qe({templates:e,cards:t,channels:n,play:r,item:i,onAdd:a}){let{api:o}=q(),s=_(),c=Vx(),l=TQ(),u=I(QE(o)),d=AD().channelId,[f,p]=(0,m.useState)(n.length>1?d??``:``),[g,v]=(0,m.useState)(``),[y,b]=t0(`template`),[x,S]=(0,m.useState)(null),[C,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(null),[D,O]=(0,m.useState)(!1),k=(0,m.useRef)(!1),A=r1(r),j=e.data??[],M=j.length>=hQe,N=M?g.trim().toLowerCase():``,P=$1(j.filter(e=>n.length<2||f===``||jQ(e)===f).filter(e=>e.name.toLowerCase().includes(N)),M?y:`name`);async function ee(e){if(!k.current){k.current=!0,O(!0),S(null);try{await e()}catch(e){S(e instanceof Error?e.message:`That didn't finish. Try again.`)}finally{k.current=!1,O(!1)}}}async function F(){if(C===null)return;let e=C.id,t=await axe(o,C);if(!t.ok)throw Error(t.message);w(null),await s.cancelQueries({queryKey:PM}),s.setQueryData(PM,t=>t?.filter(t=>t.id!==e));let n=C.name;c(`Moved "${n}" to the trash.`,`success`,{label:`Undo`,run:()=>void CQ(o,`template`,e).then(async()=>{c(`Restored "${n}".`,`success`),await s.invalidateQueries({queryKey:PM})},e=>c(`"${n}" wasn't restored: ${e.message} Restore it in Settings → Trash.`,`error`,l))}),await s.invalidateQueries({queryKey:PM})}async function te(e){let t=await vXe(o,e.id);if(!t.ok)throw Error(t.message);let n=URL.createObjectURL(t.blob),r=document.createElement(`a`);r.href=n,r.download=t.filename,r.click(),URL.revokeObjectURL(n)}return e.error?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(lL,{tone:`error`,children:`The templates didn't load: ${e.error.message}`}),(0,h.jsx)(K,{size:`small`,onClick:()=>void e.refetch(),children:`Reload templates`})]}):e.data===void 0?(0,h.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Loading templates`,className:`sl-template-cards`,children:[(0,h.jsx)(`div`,{className:`h-72 rounded-media bg-raised`}),(0,h.jsx)(`div`,{className:`h-72 rounded-media bg-raised`}),(0,h.jsx)(`div`,{className:`h-72 rounded-media bg-raised`})]}):j.length===0?(0,h.jsx)(ZR,{title:`No templates yet`,actions:(0,h.jsx)(K,{variant:`primary`,onClick:a,children:`Add starter templates`}),children:`A template keeps a whole setup, so a video takes only a topic. Start from a starter template, or save one from Create with Save as template.`}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[M||n.length>1?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[M?(0,h.jsx)(Y,{type:`search`,"aria-label":`Search templates`,placeholder:`Search templates`,value:g,className:`w-full min-w-0 sm:w-56`,onChange:e=>v(e.target.value)}):null,n.length>1?(0,h.jsxs)(ZT,{"aria-label":`Show templates of`,value:f,className:`w-full sm:w-56`,onChange:e=>p(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`All channels`}),n.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]}):null,M?(0,h.jsx)(n0,{what:`templates`,sort:y,onSort:b}):null]}):null,(0,h.jsx)(lL,{tone:r.blocked?`warning`:`error`,children:(C===null?x:null)??(r.blocked?`A video is still starting on Create. Wait for it, then make the next one.`:void 0)}),P.length===0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:N===``?`No templates in this channel.`:`No templates match "${g.trim()}"${f===``?``:` in this channel`}.`}):(0,h.jsx)(`ul`,{"aria-label":`Video templates`,className:`sl-template-cards m-0 list-none p-0`,children:P.map(e=>(0,h.jsx)(vQe,{template:e,picked:e.id===i,card:t?.find(t=>t.id===e.id),channel:n.length>1?n.find(t=>t.id===jQ(e))?.name:void 0,providerName:e=>u.data?.providers.find(t=>t.id===e)?.displayName??e,pending:D,onMake:()=>void ee(()=>A.apply(e)),onDuplicate:()=>void ee(()=>A.duplicate(e)),onExport:()=>void ee(()=>te(e)),onVersions:()=>E(e),onDelete:()=>{w(e),S(null)}},e.id))}),T===null?null:(0,h.jsx)(fQe,{template:T,onClose:()=>E(null)},`${T.id}:${String(T.version)}`),(0,h.jsx)(ME,{open:C!==null,title:`Delete ${C?.name??`template`}?`,consequence:x??`Moves it to the trash for 30 days (Settings → Trash). Projects already made from it keep their setup.`,confirmLabel:`Delete template`,pending:D,onConfirm:()=>void ee(F),onCancel:()=>{D||w(null)}})]})}function vQe({template:e,picked:t,card:n,channel:r,providerName:i,pending:a,onMake:o,onDuplicate:s,onExport:c,onVersions:l,onDelete:u}){let{api:d}=q(),f=JNe(e.gate,n?.schedules??0),p=n?.format??`16:9`,g=(0,m.useRef)(null);return(0,m.useEffect)(()=>{t&&g.current?.scrollIntoView?.({block:`nearest`})},[t]),(0,h.jsxs)(`li`,{ref:g,className:`sl-template-card`,"aria-label":e.name,"aria-current":t?`true`:void 0,children:[n?.still==null?null:(0,h.jsx)(pa,{to:`/templates/$templateId`,params:{templateId:e.id},search:{},tabIndex:-1,className:`sl-template-card__still`,"data-format":p,children:(0,h.jsx)(`img`,{src:`${d.origin}${n.still}`,alt:`A still from ${e.name}'s sample`})}),(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3 [overflow-wrap:anywhere]`,children:(0,h.jsx)(pa,{to:`/templates/$templateId`,params:{templateId:e.id},search:{},className:`text-ink no-underline hover:underline`,children:e.name})}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:n===void 0?`Reading what it makes…`:uQe(n,i)}),n===void 0||n.asks.length===0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Asks for: ${n.asks.join(`, `)}`}),f===void 0&&r===void 0?null:(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-x-2 gap-y-1 text-small text-ink-2`,children:[f===void 0?null:(0,h.jsx)(gE,{tone:f.tone,children:f.word}),r===void 0?null:(0,h.jsx)(`span`,{children:r})]}),f===void 0||f.tone!==`waiting`?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:f.detail})]}),(0,h.jsxs)(`div`,{className:`sl-template-card__actions`,children:[(0,h.jsx)(K,{variant:`primary`,size:`small`,"aria-label":`Make a video with ${e.name}`,disabled:a,disabledReason:`Working on the last press`,onClick:o,children:`Make a video`}),(0,h.jsx)($T,{to:`/templates/$templateId`,params:{templateId:e.id},search:{},size:`small`,"aria-label":`Edit template ${e.name}`,children:`Edit template`}),(0,h.jsxs)(YM,{children:[(0,h.jsx)(XM,{asChild:!0,children:(0,h.jsx)(K,{size:`small`,variant:`quiet`,"aria-label":`More for ${e.name}`,children:(0,h.jsx)(yh,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75})})}),(0,h.jsxs)(ZM,{children:[(0,h.jsx)(QM,{"aria-label":`Duplicate ${e.name}`,disabled:a,onSelect:s,children:`Duplicate`}),(0,h.jsx)(QM,{"aria-label":`Versions of ${e.name}`,onSelect:l,children:`Versions`}),(0,h.jsx)(QM,{"aria-label":`Export ${e.name} as a file (.zip)`,disabled:a,onSelect:c,children:`Export as a file (.zip)`}),(0,h.jsx)(eN,{}),(0,h.jsx)(QM,{"aria-label":`Delete ${e.name}`,onSelect:u,children:`Delete…`})]})]})]}),(0,h.jsx)(u$,{kind:`template`,id:e.id,name:e.name})]})}function yQe({problem:e,onNew:t}){return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[`A poster with keywords such as `,`{{Event}}`,`, made again by hand or ahead of each date by a schedule. Your posters and picture edits are under`,` `,(0,h.jsx)(eE,{to:`/designs`,children:`Designs`}),`.`]}),e===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:e}),(0,h.jsx)(UEe,{onNew:t})]})}function bQe({page:e,anchor:t,words:n}){let{api:r}=q(),i=I(WI(r)),a=I(uTe(r,e)),o=Ji(),[s,c]=(0,m.useState)(n??``);(0,m.useEffect)(()=>{c(n??``)},[n]);let l=(0,m.useRef)(null),u=(0,m.useMemo)(()=>new Set((i.data?.pages??[]).map(e=>e.id)),[i.data]),d=i.data?.pages.find(t=>t.id===e)?.title??e.replace(/-/g,` `),f=(0,m.useMemo)(()=>sge(a.data??``),[a.data]),p=(0,m.useMemo)(()=>a.data===void 0?``:oge(f.body,u,e),[a.data,f.body,u,e]);(0,m.useEffect)(()=>{if(p===``)return;let e=l.current;if(e===null)return;let n=t===void 0?void 0:lge(e,t,f.title===void 0?[]:[f.title]);n===void 0?window.scrollTo?.({top:0}):n.scrollIntoView?.({block:`start`})},[p,t,f.title]);let g=i.data?.groups.find(t=>t.pages.some(t=>t.id===e));return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(fL,{crumb:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{children:`Help`}),(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`›`}),(0,h.jsx)(pa,{to:`/help/tutorials/$page`,params:{page:i.data?.home.id??`Home`},children:`Tutorials`})]}),title:d,meta:g===void 0?`Guides to every screen of Slopify, for the version you are running.`:g.title,actions:(0,h.jsx)($T,{to:`/welcome`,variant:`quiet`,children:`Welcome screen`})}),(0,h.jsx)(pL,{className:`sl-workspace--tutorials`,sections:(0,h.jsx)(xQe,{index:i.data,page:e,onOpenHit:(e,t)=>{o({to:`/help/tutorials/$page`,params:{page:e.page},search:{q:t},...e.anchor===``?{}:{hash:e.anchor}})}}),children:a.error===null?(0,h.jsxs)(`div`,{ref:l,onClick:e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey)return;let t=e.target.closest(`a`),n=t?.getAttribute(`href`);if(t===null||n==null)return;let r=cge(n);r===void 0?/^https?:/.test(n)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`)):(e.preventDefault(),o({to:`/help/tutorials/$page`,params:{page:r.page},...r.anchor===void 0?{}:{hash:r.anchor}}))},children:[(0,h.jsx)(BI,{markdown:p,label:`Tutorial`,what:`tutorial`,query:s,onQuery:c,anchorPrefix:`tutorial-`,children:(0,h.jsx)(`p`,{className:`m-0 text-ink-3`,children:`Loading the tutorial…`})}),i.data?.footer?(0,h.jsx)(`p`,{className:`mt-8 border-t border-line pt-4 text-small text-ink-3`,children:i.data.footer.replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`)}):null]}):(0,h.jsx)(IT,{tone:`danger`,title:`This tutorial did not load`,actions:(0,h.jsx)(K,{onClick:()=>void a.refetch(),variant:`secondary`,children:`Try again`}),children:`${a.error.message} Press Try again, or pick another page on the left.`})})]})}function xQe({index:e,page:t,onOpenHit:n}){let{api:r}=q(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(``),c=(0,m.useRef)(null),l=(0,m.useId)();PD(c,`the tutorials`),(0,m.useEffect)(()=>{let e=setTimeout(()=>s(i.trim()),200);return()=>clearTimeout(e)},[i]);let u=I(dTe(r,o));return(0,h.jsxs)(`nav`,{"aria-label":`Tutorials`,className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsxs)(`div`,{className:`relative`,children:[(0,h.jsx)(`label`,{htmlFor:l,className:`sr-only`,children:`Search all tutorials`}),(0,h.jsx)(Nh,{"aria-hidden":`true`,strokeWidth:1.75,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-3`}),(0,h.jsx)(`input`,{ref:c,id:l,type:`search`,value:i,placeholder:`Search all tutorials`,onChange:e=>a(e.target.value),onKeyDown:e=>{let t=u.data?.hits[0];e.key===`Enter`&&t!==void 0&&(e.preventDefault(),n(t,o))},className:`sl-input pl-9`})]}),o===``?e===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Loading the tutorials…`}):(0,h.jsxs)(`div`,{className:`sl-tutorials-nav flex flex-col gap-4`,children:[(0,h.jsx)(SQe,{id:e.home.id,title:e.home.title,current:t}),e.groups.map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,h.jsx)(`div`,{className:`sl-kicker px-2.5 pb-1`,children:e.title}),e.pages.map(e=>(0,h.jsx)(SQe,{id:e.id,title:e.title,current:t},e.id))]},e.title))]}):(0,h.jsx)(CQe,{query:o,hits:u.data?.hits,error:u.error?.message})]})}function SQe({id:e,title:t,current:n}){return(0,h.jsx)(pa,{to:`/help/tutorials/$page`,params:{page:e},"aria-current":e===n?`page`:void 0,className:`sl-tutorials-nav__link`,children:t})}function CQe({query:e,hits:t,error:n}){return n===void 0?t===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Searching…`}):t.length===0?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`No tutorial mentions "${e}". Try fewer or other words.`}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`p`,{role:`status`,className:`m-0 px-2.5 text-small text-ink-3`,children:t.length===1?`1 section`:`${String(t.length)} sections`}),(0,h.jsx)(`ul`,{"aria-label":`Search results`,className:`m-0 flex list-none flex-col gap-1 p-0`,children:t.map(t=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(pa,{to:`/help/tutorials/$page`,params:{page:t.page},search:{q:e},...t.anchor===``?{}:{hash:t.anchor},className:`sl-tutorials-hit`,children:[(0,h.jsx)(`span`,{className:`block font-semibold text-ink`,children:t.heading===void 0?t.pageTitle:t.heading}),t.heading===void 0?null:(0,h.jsx)(`span`,{className:`block text-label text-ink-3`,children:t.pageTitle}),(0,h.jsx)(`span`,{className:`mt-0.5 block text-small text-ink-2`,children:t.snippet})]})},`${t.page}#${t.anchor}`))})]}):(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The search didn't run: ${n} Change the words or reload the page.`})}var wQe=[{id:`library`,name:`The Library of Alexandria`,summary:`A narrated video with its two shorts, article, PDF, description and images.`,action:`Explore the sample`},{id:`audiobook`,name:`The Wind in the Willows`,summary:`An audiobook: a narrator and two character voices, captions tagged with who speaks, MP3 and M4B with chapters.`,action:`See an audiobook`},{id:`podcast`,name:`The Antikythera Mechanism`,summary:`A two-host podcast with the speaker panel, name tags and portraits, and its MP3 and M4B.`,action:`Hear a podcast`}];function TQe({title:e,made:t}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(lD,{title:e,size:`small`,as:`h3`,className:`mt-6`}),(0,h.jsx)(BL,{label:`Samples`,className:`sl-list--wrap-meta`,children:wQe.map(e=>{let n=t[e.id];return(0,h.jsx)(VL,{title:e.name,meta:e.summary,actions:n===null?(0,h.jsx)(eE,{to:`/settings`,search:{section:`storage`},children:`Restore samples in Settings`}):(0,h.jsx)($T,{variant:`quiet`,to:`/projects/$projectId`,params:{projectId:n},className:zL,children:e.action})},e.id)})})]})}var R9=[`found`,`style`,`make`],EQe={found:`What a short needs`,style:`Pick a style`,make:`Make your first short`},DQe={read(e){try{return window.sessionStorage.getItem(`slopify.welcome.${e}`)??``}catch{return``}},write(e,t){try{window.sessionStorage.setItem(`slopify.welcome.${e}`,t)}catch{}}};function OQe(e){let[t,n]=(0,m.useState)(()=>DQe.read(e));return[t,t=>{n(t),DQe.write(e,t)}]}function z9({id:e,at:t,children:n}){if(e!==t)return null;let r=R9.indexOf(e);return(0,h.jsxs)(`section`,{id:`welcome-step-${e}`,"aria-labelledby":`welcome-step-${e}-title`,tabIndex:-1,className:`outline-none`,children:[(0,h.jsx)(lD,{id:`welcome-step-${e}-title`,title:EQe[e],row:!0,meta:`Step ${String(r+1)} of ${String(R9.length)}`}),n]})}function kQe(e,t){let n=e=>m2(e.by??``),r=[t?.text.by==null?void 0:`${n(t.text)} writes it`,t?.voice.by==null?void 0:t.voice.how===`computer`?`your computer's voice reads it aloud`:`${n(t.voice)} reads it aloud`,t?.images.by==null?void 0:`${n(t.images)} makes the images`].filter(e=>e!==void 0);return`${e} style${r.length===0?``:`: ${r.join(`, `)}`}. About five minutes.`}function AQe({step:e,onStep:t}){let{api:n}=q(),r=_(),i=Ji(),a=I({queryKey:FE,queryFn:()=>zE(n)}),[o,s]=(0,m.useState)(e??`found`),c=t===void 0?o:e??`found`,[l,u]=OQe(`topic`),[d,f]=OQe(`pack`),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(!1),S=(0,m.useRef)(null),C=(0,m.useRef)(void 0),w=L({mutationFn:()=>VE(n),onSuccess:async()=>{await r.invalidateQueries({queryKey:oD}),await r.invalidateQueries({queryKey:FE}),await i({to:`/`})}}),T=L({mutationFn:()=>(C.current??=crypto.randomUUID(),n_e(n,{topic:l,requestId:C.current,...d===``?{}:{packId:d}})),onSuccess:async e=>{e.ok?(C.current=void 0,y([]),g(e.projectId),u(``),await r.invalidateQueries({queryKey:oD}),await r.invalidateQueries({queryKey:X.projects}),await r.invalidateQueries({queryKey:X.voices})):(y(e.gaps),await r.invalidateQueries({queryKey:FE}))}}),E=e=>{e?.preventDefault(),l.trim()===``?(x(!0),S.current?.focus()):(x(!1),T.mutate())},D=a.data,O=d===``?`General`:D?.packs.find(e=>e.id===d)?.name??d,k=D?.needs.gaps??[],A=T.error?{tone:`error`,text:T.error.message}:w.error?{tone:`error`,text:w.error.message}:T.isPending?{tone:`info`,text:`Starting your short…`}:b?{tone:`error`,text:`Type a topic first.`}:v.length===0?void 0:{tone:`error`,text:k.length>0?`The short didn't start. Fix the lines above that are not Ready, then press Make a 60-second short again.`:v.map(e=>e.message).join(` `)},j=R9.indexOf(c),M=(0,m.useRef)(!1),N=e=>{M.current=!0,t===void 0?s(e):t(e)};(0,m.useEffect)(()=>{M.current&&(M.current=!1,document.getElementById(`welcome-step-${c}`)?.focus({preventScroll:!0}))},[c]);let P=R9[j+1],ee=R9[j-1];return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fL,{title:`Welcome to Slopify`,className:`max-sm:[&>div:first-child]:basis-0`,meta:(0,h.jsx)(`span`,{className:`max-sm:hidden`,children:`Make a video from a topic, with the tools already on this computer.`}),actions:(0,h.jsx)(K,{variant:`quiet`,disabled:w.isPending,onClick:()=>w.mutate(),children:p===void 0?`Skip`:`Done`})}),a.error?(0,h.jsx)(IT,{tone:`danger`,title:`Could not read what this computer has`,className:`mb-4`,children:a.error.message}):null,(0,h.jsxs)(z9,{id:`found`,at:c,children:[(0,h.jsx)(_2,{back:{return:`welcome`,step:`found`}}),D===void 0?null:(0,h.jsx)(TQe,{title:`What Slopify makes: finished samples`,made:D.samples})]}),(0,h.jsx)(z9,{id:`style`,at:c,children:(0,h.jsx)(BL,{label:`Styles`,className:`sl-list--wrap-meta`,children:[{id:``,name:`General`,summary:`A neutral explainer style.`},...D?.packs??[]].map(e=>{let t=d===e.id;return(0,h.jsx)(VL,{title:e.name,meta:e.summary,selected:t,onSelect:()=>f(e.id),actions:t?(0,h.jsxs)(`span`,{className:`flex items-center gap-1 text-small font-semibold text-accent-ink`,children:[(0,h.jsx)(ph,{"aria-hidden":`true`,className:`size-4`,strokeWidth:2.5}),`Picked`]}):void 0},e.id===``?`general`:e.id)})})}),(0,h.jsxs)(z9,{id:`make`,at:c,children:[p===void 0?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`form`,{id:`welcome-short`,onSubmit:E,className:`mb-4`,children:(0,h.jsx)(J,{label:`Topic`,help:kQe(O,D?.needs),children:(0,h.jsx)(Y,{ref:S,value:l,maxLength:200,placeholder:`For example: why the sea glows at night`,onChange:e=>{u(e.target.value),e.target.value.trim()!==``&&x(!1)}})})}),k.length===0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`m-0 mb-2 text-small font-semibold text-waiting`,children:`The short needs every line Ready before it can start.`}),(0,h.jsx)(_2,{back:{return:`welcome`,step:`make`},className:`mb-4`})]})]}):(0,h.jsxs)(IT,{tone:`info`,className:`mb-4`,title:`Your short is being made.`,children:[`It usually takes about five minutes. Watch each step as it runs, or look at a sample while you wait. `,d===``?`Its prompts are`:`Its ${O} prompts are`,` now in`,` `,(0,h.jsx)(eE,{to:`/prompts`,search:{kind:`article`},children:`Prompts`}),`, for your next video.`]}),(0,h.jsx)(__e,{}),p===void 0||D===void 0?null:(0,h.jsx)(TQe,{title:`While you wait: finished samples`,made:D.samples})]}),(0,h.jsxs)(uL,{status:(0,h.jsx)(lL,{wrap:!0,tone:A?.tone??`info`,children:A?.text}),children:[c===`make`?null:(0,h.jsx)(eE,{to:`/play`,className:`max-sm:hidden`,children:`Make a long video instead`}),ee===void 0?null:(0,h.jsx)(K,{onClick:()=>N(ee),children:`Back`}),P===void 0?p===void 0?(0,h.jsx)(K,{type:`submit`,form:`welcome-short`,variant:(D?.needs.gaps.length??0)>0?`secondary`:`primary`,disabled:T.isPending,children:`Make a 60-second short`},`make`):(0,h.jsx)($T,{variant:`primary`,to:`/projects/$projectId`,params:{projectId:p},children:`Watch it being made`}):(0,h.jsx)(K,{variant:`primary`,onClick:()=>N(P),children:`Next: ${EQe[P]}`},`next-${P}`)]})]})}var jQe=[`script`,`voice`,`pictures`,`thumbnail`,`shorts`,`upload`,`reviews`],B9={yours:`Your words`,keyword:`Your keywords`,slopify:`Filled by Slopify`,setting:`Added by a setting`},MQe={yours:``,keyword:`rounded-sm bg-accent-tint px-0.5`,slopify:`rounded-sm bg-waiting-tint px-0.5`,setting:`rounded-sm bg-info-tint px-0.5 italic`},NQe={script:`What the writer is sent`,voice:`What the voice is sent`,pictures:`What the image service is sent`,thumbnail:`What the image service is sent for the thumbnail`,shorts:`What the writer is sent for the shorts`,upload:`What the writer is sent for the description and posts`,reviews:`What the AI checks are sent`};function PQe({view:e,section:t}){let n=NQe[t];return!jQe.includes(t)||n===void 0?null:(0,h.jsx)(SR,{summary:n,children:(0,h.jsx)(FQe,{children:(0,h.jsx)(IQe,{view:e,section:t})})})}function FQe({children:e}){let t=(0,m.useRef)(null),[n,r]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=t.current?.closest(`details`);if(e==null)return;let n=()=>r(e.open);return n(),e.addEventListener(`toggle`,n),()=>e.removeEventListener(`toggle`,n)},[]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{ref:t,hidden:!0}),n?e:null]})}function IQe({view:e,section:t}){let{api:n}=q(),[r,i]=(0,m.useState)(),a=I(nXe(n,e.template.id,t,r,e.template.version));if(a.error)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 pb-3 text-small text-danger`,children:`The prompt anatomy didn't load: ${a.error.message}`});let o=a.data;if(o===void 0)return(0,h.jsx)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Working out the prompt`,className:`pb-3`,children:(0,h.jsx)(`div`,{className:`h-16 rounded-control bg-raised`})});if(o.problem!==null)return(0,h.jsx)(`p`,{className:`m-0 pb-3 text-small text-danger`,children:o.problem});if(o.item===null)return(0,h.jsx)(`p`,{className:`m-0 pb-3 text-small text-ink-2`,children:`This section sends no prompt.`});let s=new Set(o.segments.map(e=>e.origin));return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 pb-3`,children:[o.items.length>1?(0,h.jsx)(ZT,{"aria-label":`Prompt`,value:o.item,onChange:e=>i(e.target.value),options:o.items.map(e=>({value:e.key,label:e.label}))}):(0,h.jsx)(`p`,{className:`m-0 text-small font-semibold`,children:o.items[0]?.label}),(0,h.jsx)(`p`,{className:`m-0 whitespace-pre-wrap text-small leading-relaxed`,children:o.segments.map((e,t)=>(0,h.jsx)(`span`,{className:G(MQe[e.origin],e.unfilled===!0&&`opacity-70`),title:e.name===void 0?B9[e.origin]:`${B9[e.origin]}: ${e.name}${e.unfilled===!0?` (filled when the step runs)`:``}`,children:e.text},t))}),(0,h.jsx)(`ul`,{"aria-label":`What the marks mean`,className:`m-0 flex list-none flex-wrap gap-3 p-0 text-small`,children:[`yours`,`keyword`,`slopify`,`setting`].filter(e=>s.has(e)).map(e=>(0,h.jsx)(`li`,{className:G(`text-ink-2`,MQe[e]),children:B9[e]},e))}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:o.fromSample?`As the sample sent it.`:`As the sample would send it: no sample was made from this setup yet.`})]})}var LQe={script:`llm`,voice:`tts`,pictures:`image`},RQe={script:`writing model`,voice:`voice model`,pictures:`image model`};function zQe(e){return e===`script`||e===`voice`||e===`pictures`?e:void 0}function BQe(e,t){let{form:n}=e,r=t===`script`?n.sources.article===`generate`?n.llm:void 0:t===`voice`?n.sources.audio===`generate`?n.audio:void 0:n.sources.images===`generate`?n.images:void 0;return r===void 0||r.provider===``||r.model===``?void 0:{provider:r.provider,model:r.model}}function VQe(e,t,n){let{form:r}=e;switch(t){case`script`:{let{thinking:t,...i}=r.llm;return{...e,form:{...r,llm:{...i,provider:n.provider,model:n.model,...t!==void 0&&n.provider===r.llm.provider?{thinking:t}:{}}}}}case`voice`:return{...e,form:{...r,audio:{...r.audio,model:n.model}}};case`pictures`:return{...e,form:{...r,images:{...r.images,provider:n.provider,model:n.model}}}}}var HQe={current:[`done`,`In use now`],queued:[`waiting`,`Waiting`],making:[`running`,`Making`],done:[`done`,`Made`],failed:[`failed`,`Failed`]},UQe=e=>e===null?`time not known`:e<60?`${Math.round(e)} s`:`${Math.round(e/60)} min`;function WQe({entry:e,origin:t}){let n=e.outputs.find(e=>e.role.startsWith(`audio`)),r=e.outputs.filter(e=>e.role===`image`);return e.article===null?n===void 0?r.length>0?(0,h.jsx)(dR,{density:`compact`,list:!0,label:`Pictures by ${e.model}`,children:r.slice(0,4).map(n=>(0,h.jsx)(`li`,{children:(0,h.jsx)(uR,{src:`${t}${n.url}`,alt:`A picture by ${e.model}`})},n.url))}):null:(0,h.jsx)(w6,{src:`${t}${n.url}`,label:`Narration by ${e.model}`,compact:!0}):(0,h.jsx)(`p`,{className:`m-0 line-clamp-6 whitespace-pre-line text-small text-ink-2`,children:e.article})}function GQe({templateId:e,section:t,onUse:n}){let{api:r}=q(),i=_(),a=I(EXe(r,e)),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(null),u=a.data?.bakeoff;if(u==null||u.section!==t)return null;let d=u.state===`queued`||u.state===`making`;async function f(){s(!0),l(null);try{let t=await kXe(r,e);return t.ok?(await i.invalidateQueries({queryKey:b9(e)}),!0):(l(t.message),!1)}catch(e){return l(`The bake-off wasn't discarded: ${e instanceof Error?e.message:String(e)} Press Discard again.`),!1}finally{s(!1)}}return(0,h.jsxs)(`section`,{"aria-label":`Compared models`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(lD,{title:`Compared models`,as:`h3`,size:`small`,meta:u.stale?`Made for version ${String(u.version)}; the template was saved since.`:d?`Being made on copies of the sample. Your template doesn't change.`:`Made on copies of the sample, each with what it was charged and how long it took. Your template doesn't change until you use a model and Save.`,children:(0,h.jsx)(K,{variant:`quiet`,size:`small`,disabled:o||d,disabledReason:d?`Work already going is never stopped: discard it once it finishes`:`Discarding`,focusableWhenDisabled:!0,onClick:()=>void f(),children:`Discard`})}),u.sentence===null?null:(0,h.jsx)(`p`,{className:u.state===`failed`||u.state===`held`?`m-0 text-body text-waiting`:`m-0 text-small text-ink-2`,children:u.sentence}),c===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:c}),(0,h.jsx)(`ul`,{"aria-label":`Models compared`,className:`sl-list m-0 list-none p-0`,children:u.entries.map(e=>{let[t,i]=HQe[e.state],a=e.cost===null?e.quotedHigh===null?`cost not known`:`${O9(e.quotedHigh)}`:`${nE(e.cost)} charged`;return(0,h.jsxs)(`li`,{className:`sl-row max-sm:grid-cols-1`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,h.jsx)(`p`,{className:`m-0 font-semibold`,children:e.model}),(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-x-2 text-small text-ink-2`,children:[(0,h.jsx)(hE,{tone:t,children:i}),`· ${a} · ${UQe(e.seconds)}`]}),e.failure===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:e.failure}),(0,h.jsx)(WQe,{entry:e,origin:r.origin})]}),e.state===`done`&&!u.stale?(0,h.jsx)(zx,{children:(0,h.jsx)(K,{size:`small`,variant:`secondary`,disabled:o,onClick:async()=>{await f()&&n({provider:e.provider,model:e.model},`Switched to ${e.model}; the compared copies were discarded. Press Save, then Make sample to see the template's own sample with it.`)},children:`Use this model`})}):null]},`${e.provider}:${e.model}`)})})]})}function KQe({templateId:e,section:t,document:n,dirty:r,preset:i}){let[a,o]=(0,m.useState)(i!==void 0),s=BQe(n,t);return s===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[r?null:(0,h.jsx)(K,{size:`small`,onClick:()=>o(!0),children:`Compare models`}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:r?`Save to compare other models: they are compared on the saved version's sample.`:`Makes this section's sample with other models, side by side, priced first.`}),a?(0,h.jsx)(qQe,{templateId:e,section:t,current:s,preset:i,onClose:()=>o(!1)}):null]})}function qQe({templateId:e,section:t,current:n,preset:r,onClose:i}){let{api:a}=q(),o=_(),s=I(QE(a)),c=LQe[t],l={provider:n.provider,model:``},[u,d]=(0,m.useState)([r??l]),[f,p]=(0,m.useState)(!1),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(null),x=u.filter(e=>e.provider!==``&&e.model!==``),S=x.length===u.length,C=I({queryKey:[...b9(e),`bakeoff-quote`,t,JSON.stringify(x)],queryFn:async()=>{let n=await DXe(a,e,{section:t,models:x});if(!n.ok)throw Error(n.message);return n.value},enabled:S&&x.length>0,retry:!1}),w=C.data?.unknown??0,T=S?C.isPending?`Working out the price`:C.error===null?C.data?.problem!==null&&C.data?.problem!==void 0?`No sample can be made with this model`:C.data?.fits===!1?MXe(C.data):w>0&&!f?`Accept the steps with no known price first`:void 0:`This can't be compared as picked`:`Pick the ${RQe[t]} to compare first`;async function E(){if(C.data!==void 0){v(!0),b(null);try{let n=await OXe(a,e,{section:t,models:x,acknowledgedHigh:C.data.high,acknowledgedUnknown:f});if(!n.ok){b(`Nothing was started: ${n.message}`),n.quote!==null&&o.setQueryData([...b9(e),`bakeoff-quote`,t,JSON.stringify(x)],n.quote);return}await o.invalidateQueries({queryKey:b9(e)}),i()}catch(e){b(`Nothing was started: ${e instanceof Error?e.message:String(e)} Press Compare again.`)}finally{v(!1)}}}let D=(e,t)=>d(u.map((n,r)=>r===e?t:n)),O=C.error?.message??C.data?.problem??null;return(0,h.jsx)(LT,{open:!0,onClose:i,title:`Compare models`,footer:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,h.jsx)(K,{onClick:i,children:`Cancel`}),(0,h.jsx)(K,{variant:`primary`,disabled:g||T!==void 0,disabledReason:g?`Starting the comparison`:T??``,focusableWhenDisabled:!0,onClick:()=>void E(),children:C.data===void 0?`Compare`:`Compare · ${O9(C.data.high)}`})]}),children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Makes this section's sample again with each model, on copies of the sample, so you can compare what each makes, costs and takes. In use now: ${n.model}. Your template doesn't change until you press Use this model and Save.`}),u.map((e,n)=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t===`voice`?null:(0,h.jsx)(YR,{label:`Service ${String(n+1)}`,family:c,providers:s.data?.providers??[],value:e.provider,problem:void 0,tip:`template-studio.compare-provider`,onPick:e=>D(n,{provider:e,model:``})}),(0,h.jsx)(GR,{label:`Model ${String(n+1)}`,provider:e.provider,value:e.model,problem:void 0,tip:`template-studio.compare-model`,onPick:t=>D(n,{...e,model:t})}),u.length>1?(0,h.jsx)(K,{size:`small`,variant:`quiet`,className:`self-start`,onClick:()=>d(u.filter((e,t)=>t!==n)),children:`Remove model ${String(n+1)}`}):null]},String(n))),u.length<2?(0,h.jsx)(K,{size:`small`,className:`self-start`,onClick:()=>d([...u,l]),children:`Add another model`}):null,w>0?(0,h.jsx)(dD,{label:`Accept ${String(w)} ${w===1?`step`:`steps`} with no known price`,tip:`template-studio.accept-unknown`,tipLabel:`Steps with no known price`,checked:f,onChange:p}):null,(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,role:`status`,children:C.data===void 0?S?`Working out the price…`:``:`${C.data.models.map(e=>`${e.model}: ${O9(e.high)}`).join(` · `)} · ${nE(C.data.budget.left)} of today's ${nE(C.data.budget.budget)} sample budget left`}),C.data?.fits===!1?(0,h.jsxs)(`p`,{className:`m-0 text-body text-waiting`,children:[NXe(C.data,`Comparing`),(0,h.jsx)(eE,{to:`/settings`,search:{section:`playback`},children:`Settings → Production defaults`}),`.`]}):null,O===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:O}),y===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:y})]})})}function JQe({templateId:e,dirty:t}){let{api:n}=q(),r=I(x9(n,e)),i=r.data?.checks,a=i?.filter(e=>!e.ok),o=i?.filter(e=>e.ok)??[];return(0,h.jsxs)(`section`,{"aria-label":`Checks`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(lD,{title:`Checks`,as:`h3`,className:`pb-0`,meta:a===void 0?void 0:a.length===0?`All pass`:`${String(a.length)} to fix`}),t?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Checked on the saved version: Save to check your changes.`}):null,r.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The checks didn't load: ${r.error.message} Reload the page to look again.`}):a===void 0?(0,h.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Checking the template`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(`div`,{className:`h-4 w-3/4 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`h-4 w-2/3 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`h-4 w-1/2 rounded-control bg-raised`})]}):(0,h.jsxs)(h.Fragment,{children:[a.length===0?null:(0,h.jsx)(YQe,{label:`To fix`,checks:a}),o.length===0?null:(0,h.jsx)(SR,{summary:`What passes`,state:String(o.length),children:(0,h.jsx)(YQe,{label:`What passes`,checks:o})})]})]})}function YQe({label:e,checks:t}){return(0,h.jsx)(`ul`,{"aria-label":e,className:`m-0 flex list-none flex-col gap-3 p-0`,children:t.map((e,t)=>(0,h.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(hE,{tone:e.ok?`done`:`failed`,children:(0,h.jsx)(`span`,{className:`text-small`,children:e.sentence})}),e.fix===void 0?null:(0,h.jsx)(eE,{to:e.fix.href,className:`text-small`,children:e.fix.label})]},`${e.id}:${String(t)}`))})}function XQe({section:e,defaults:t,onFiles:n}){let{api:r}=q(),i=I(QE(r)),a=I(eD(r)),o=I(tD(r)),s=I($E(r)),c=I(aD(r)),[l,u]=iI(),{document:d}=GP(),f={...l,...l.llm.provider===``&&t.llm!==void 0?{llm:{...l.llm,...t.llm}}:{},...l.images.provider===``&&t.images!==void 0?{images:{...l.images,...t.images}}:{}},p=A3(d.librarySnapshot,a.data?.prompts??[],o.data?.entries??[]),m=c.data?.silenceGapSeconds??3,g={form:f,prompts:p.prompts,entries:p.entries,silenceGapSeconds:m},{fields:_,result:v}=pP(g),y=v.ok?[]:v.fields,b=e=>y.find(t=>t.field===e||t.field.startsWith(`${e}.`))?.message,x=e=>u(t=>{let n={...t,...e};return{...n,subtitles:HN(n.subtitles,n.sources)}}),S=(e,t)=>u(n=>({...n,provided:e===`images`?{...n.provided,images:n.provided.images.filter(e=>e.key!==t)}:{...n.provided,[e]:void 0}})),C={form:f,providers:i.data?.providers??[],prompts:p.prompts,voices:s.data?.voices??[],silenceGapSeconds:m,problem:b,update:x,onPickFiles:n,onRemoveFile:S,onReattachFile:n},w=VN(f.title),T=f.sources.article!==`off`;switch(e){case`subject`:return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4 py-2`,children:[(0,h.jsx)(R4,{fields:_,origins:xP(g),topics:w,hide:w,values:f.values,problem:b,onChange:(e,t)=>x({values:{...f.values,[e]:t}})}),(0,h.jsx)(V2,{})]});case`script`:return(0,h.jsx)(F4,{...C,entries:p.entries});case`voice`:return(0,h.jsx)(u3,{...C,entries:p.entries,onKeyword:()=>void 0});case`pictures`:return(0,h.jsx)(d3,{...C});case`video`:return(0,h.jsx)(f3,{...C,problemOf:b});case`thumbnail`:return(0,h.jsx)(A4,{...C});case`shorts`:return T?(0,h.jsx)(qB,{value:f.shorts??WB,prompts:p.prompts,narrated:f.sources.audio!==`off`,problem:b,musicName:f.provided.shortsMusic?.name,music:(0,h.jsx)(`div`,{className:`basis-full`,children:(0,h.jsx)(r4,{field:`shorts.music`,label:`Background music (optional): an audio file, looped if shorter than a short`,accept:`audio/*`,disabled:!GN(f),uploads:f.provided.shortsMusic===void 0?[]:[f.provided.shortsMusic],problem:b(`shorts.music`),onPick:()=>n(),onReattach:()=>n(),onRemove:e=>S(`shortsMusic`,e)})}),preview:(0,h.jsx)(O4,{settings:GB(f.shorts??WB,f.subtitles.fontId)}),onChange:e=>x({shorts:e})}):(0,h.jsx)(V9,{what:`Shorts are cut from the narrated article`});case`upload`:return T?(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(b4,{enabled:f.youtubeDescription===!0,prompt:f.descriptionPrompt??``,prompts:p.prompts,narrated:f.sources.audio!==`off`,problem:b,onChange:e=>x(e)}),(0,h.jsx)(`div`,{"data-play-field":`social`,children:(0,h.jsx)(x4,{value:f.social,prompts:p.prompts,shorts:S4(f.shorts),onChange:e=>x({social:C4(e)})})})]}):(0,h.jsx)(V9,{what:`The description and the posts are written from the article`});case`reviews`:return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(wP,{problem:b}),(0,h.jsx)(MB,{problem:b})]});case`document`:return T?(0,h.jsx)(N4,{...C}):(0,h.jsx)(V9,{what:`The PDF lays out the article`});case`schedule`:return null}}function V9({what:e}){return(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`${e}: turn the article on in Article.`})}function H9(){let{api:e}=q();return I({queryKey:uN.firstRun,queryFn:()=>hN(e),retry:!1,staleTime:1/0}).data?.defaults??{}}function ZQe(e){let{api:t}=q(),n=I(QE(t)),r=I({...yN(t,e.provider),enabled:e.provider!==``}),i=n.data?.providers.find(t=>t.id===e.provider),a=i?.displayName??e.provider,o=e.model===``?void 0:r.data?.models.find(t=>t.id===e.model)?.name??e.model;return{name:o===void 0?a:`${a} (${o})`,service:a,unusable:i===void 0?void 0:_R(i.readiness)}}function QQe({section:e,document:t}){let n=H9(),{form:r}=t,i=e===`script`&&r.sources.article===`generate`&&r.llm.provider===``?`llm`:e===`pictures`&&r.sources.images===`generate`&&r.images.provider===``?`images`:void 0,a=i===void 0?void 0:n[i],{name:o}=ZQe(a??{provider:``,model:``});return i===void 0||a===void 0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:i===`llm`?`Each video is written by your default, ${o}: no writer is saved with this template yet.`:`Each video's images are made by your default, ${o}: no image service is saved with this template yet.`})}function $Qe({templateId:e,document:t}){let n=H9(),{form:r}=t,i=r.images,a=i.provider===``?n.images??i:i,{name:o,service:s,unusable:c}=ZQe(a);if(r.sources.thumbnail!==`from_prompt`&&r.sources.thumbnail!==`prompt_by_llm`||r.sources.images!==`generate`)return null;let l=a.provider===``;return(0,h.jsxs)(`p`,{className:G(`m-0 flex flex-wrap items-center gap-x-2 text-small`,l||c!==void 0?`text-danger`:`text-ink-2`),children:[l?`No image service is chosen, so a run can't start.`:`Thumbnail by ${o}${i.provider===``?` (your default)`:``}${c===void 0?``:` (${s}: ${c.toLowerCase()})`}`,(0,h.jsx)(eE,{to:`/templates/$templateId`,params:{templateId:e},search:{section:`pictures`},className:`text-small`,children:`${l?`Choose one`:`Change it`} in ${qx.pictures}`})]})}var e$e=new Set([`current`,`off`,`provided`]);function t$e(e,t,n){if(e.gate===`ready`)return`it is approved already`;if(t)return`save your changes`;if(n===void 0)return`wait for the checks`;if(n>0)return`fix ${String(n)} ${n===1?`check`:`checks`}`;let r=e.sections.filter(e=>!e$e.has(e.state));if(r.length>0)return`look over a current sample of ${r.map(e=>e.label).join(`, `)}`}function n$e(e,t){let{api:n}=q(),r=I(x9(n,e.template.id));return t$e(e,t,r.data===void 0||r.data.version!==e.template.version?void 0:r.data.checks.filter(e=>!e.ok).length)}function r$e(e){return e.gated?e.gate===`ready`||e.gate===`carried`?{word:`Ready for schedules`}:{word:`Not ready for schedules`,line:e.runnableVersion===null?`No schedule runs it until you approve a version: More → Approve for schedules.`:`Schedules run version ${String(e.runnableVersion)} until you approve this one: More → Approve for schedules.`}:{word:`Schedules run each version you save`}}function i$e({view:e,dirty:t,scheduled:n,play:r,onProblem:i}){let{api:a}=q(),o=_(),s=Ji(),c=n$e(e,t),l=iQe(e,i),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(!1),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),x=(0,m.useRef)(!1),S=r1(r??{onApplied:()=>!1}),C=String(e.template.version),w=e.runnableVersion===null||e.runnableVersion===e.template.version?` Until now none of their runs started.`:` Until now they ran version ${String(e.runnableVersion)}.`,T=e.gated?`Its schedules run this version from their next run.${w}`:`Its schedules keep running this version. From now on a version you save waits for your approval before they run it, so an edit never changes the next run by itself.`;async function E(){p(!0);try{let t=await fXe(a,e.template.id,e.template.version);i(t.ok?void 0:t.message),await o.invalidateQueries({queryKey:b9(e.template.id)})}catch(e){i(`Version ${C} wasn't approved: ${e instanceof Error?e.message:String(e)} Choose Approve for schedules again.`)}finally{p(!1),d(!1)}}async function D(){if(!x.current){x.current=!0,b(!0),i(void 0);try{await S.apply(e.template)}catch(e){i(e instanceof Error?e.message:String(e))}finally{x.current=!1,b(!1)}}}return(0,h.jsxs)(h.Fragment,{children:[r===void 0?null:(0,h.jsx)(K,{variant:`primary`,disabled:t||y,disabledReason:t?`Save your changes first`:`Opening Create`,onClick:()=>void D(),children:`Make a video`}),(0,h.jsx)(K,{onClick:()=>{qM(e.template.id),s({to:`/calendar`,search:{tab:`schedules`}})},children:`New schedule`}),(0,h.jsxs)(YM,{children:[(0,h.jsx)(XM,{asChild:!0,children:(0,h.jsxs)(K,{"aria-label":`More for this template`,children:[`More`,(0,h.jsx)(mh,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75})]})}),(0,h.jsxs)(ZM,{children:[(0,h.jsx)(QM,{onSelect:()=>v(!0),children:`Versions`}),(0,h.jsx)(QM,{disabled:l.blocker!==void 0,onSelect:()=>void l.save(),children:l.blocker===void 0?l.label:`${l.label} (${l.blocker})`}),n&&e.gate!==`ready`?(0,h.jsx)(QM,{disabled:c!==void 0,onSelect:()=>d(!0),children:c===void 0?`Approve for schedules`:`Approve for schedules (${c} first)`}):null]})]}),(0,h.jsx)(ME,{open:u,title:`Approve version ${C} for schedules?`,consequence:T,confirmLabel:`Approve for schedules`,cancelLabel:`Not yet`,tone:`primary`,pending:f,onConfirm:()=>void E(),onCancel:()=>d(!1)}),g?(0,h.jsx)(fQe,{template:e.template,onClose:()=>v(!1)},`${e.template.id}:${C}`):null]})}var a$e=[`subject`,`script`,`voice`,`pictures`,`thumbnail`,`shorts`,`upload`],o$e=[`audio_levelled`,`audio_body`,`audio_mp3`,`audio_export`];function s$e(e){let t=e.paid.outputs.filter(e=>e.section===`voice`);return o$e.map(e=>t.find(t=>t.role===e)).find(e=>e!==void 0)}function c$e({view:e,section:t}){let{api:n}=q(),r=e=>`${n.origin}${e}`,i=e.paid.outputs.filter(e=>e.section===t),a=e.template.document.form.format,o=a===`9:16`?`portrait`:a===`1:1`?`square`:`landscape`,s=(...e)=>i.filter(t=>e.includes(t.role));switch(t){case`script`:return e.paid.article===null?null:(0,h.jsx)(u$e,{markdown:e.paid.article});case`pictures`:{let e=s(`image`,`reference`);return e.length===0?null:(0,h.jsx)(dR,{density:`compact`,label:`Sample images`,children:e.map(e=>(0,h.jsx)(uR,{src:r(e.url),alt:e.name,aspect:o},e.url))})}case`thumbnail`:{let[t]=s(`thumbnail`);return t===void 0?null:(0,h.jsxs)(`div`,{className:`flex max-w-[320px] flex-col gap-2`,children:[(0,h.jsx)(uR,{src:r(t.url),alt:`Sample thumbnail`,aspect:`landscape`}),(0,h.jsx)(`p`,{className:`m-0 text-body font-semibold`,children:d$e(e)})]})}case`video`:{let[t]=s(`video`);return t===void 0?null:(0,h.jsx)(sR,{src:r(t.url),label:`${e.template.name}: sample video`,portrait:a===`9:16`,square:a===`1:1`})}case`shorts`:{let[t]=s(`short_video`);return t===void 0?null:(0,h.jsx)(`div`,{className:`max-w-[240px]`,children:(0,h.jsx)(sR,{src:r(t.url),label:`${e.template.name}: sample short`,portrait:!0})})}case`upload`:return(0,h.jsx)(f$e,{outputs:i,projectId:e.paid.projectId});case`document`:{let[e]=s(`document_pdf`);return e===void 0?null:(0,h.jsx)(tE,{href:r(e.url),target:`_blank`,rel:`noreferrer`,size:`small`,className:`self-start`,children:`Open the PDF of the sample's article`})}default:return null}}function l$e(e,t=480){let n=e.split(`
|
|
460
|
+
`).map(e=>e.replace(/^#+\s*/u,``).replace(/[*_`>]/gu,``).trim()).filter(e=>e!==``).join(` `);if(n.length<=t)return n;let r=n.slice(0,t);return`${r.slice(0,Math.max(r.lastIndexOf(` `),t-40))}…`}function u$e({markdown:e}){let[t,n]=(0,m.useState)(!1);return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:l$e(e)}),(0,h.jsx)(K,{size:`small`,className:`self-start`,onClick:()=>n(!0),children:`Read the whole article`}),(0,h.jsx)(LT,{open:t,title:`Sample article`,onClose:()=>n(!1),children:(0,h.jsx)(BI,{markdown:e,label:`Sample article`,copyAll:!1})})]})}function d$e(e){let{form:t}=e.template.document;return t.title.replace(/\{\{([^{}\n]*)\}\}/g,(n,r)=>{let i=t.values[r.trim()];return i===void 0||i===``?e.sample.topic:i})}function f$e({outputs:e,projectId:t}){let{api:n}=q(),r=e.find(e=>e.role===`youtube_description`),i=I({queryKey:[`template-studio`,`upload`,r?.url??``],queryFn:async()=>r===void 0?``:gm(await n.fetch(`${n.origin}${r.url}`)),enabled:r!==void 0}),a=I({queryKey:LJ(t??``),queryFn:()=>RJ(n,t??``),enabled:t!==null,retry:!1}).data?.packs??[],o=e.filter(e=>e.role!==`social_post`);return o.length===0&&a.length===0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[i.data===void 0||i.data===``?null:(0,h.jsx)(`p`,{className:`m-0 whitespace-pre-wrap rounded-media border border-line p-3 text-small`,children:i.data}),o.length===0?null:(0,h.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:o.map(e=>(0,h.jsx)(tE,{href:`${n.origin}${e.url}`,target:`_blank`,rel:`noreferrer`,size:`small`,children:e.name},e.url))}),a.map(e=>(0,h.jsx)(HJ,{pack:e},e.platform))]})}function U9(e){return e.unknown>0?e.high===0?`price not known`:`at least ${nE(e.high)}`:e.high===0?e.onPlan?`plan usage`:`free`:O9(e.high)}function p$e({view:e,onDone:t}){let{api:n}=q(),r=_(),[i,a]=(0,m.useState)(!1),o=e.paid.quotedHigh,s=e.paid.state===`held`,c=I({queryKey:[...b9(e.template.id),`quote`,`whole`,e.sample.topic],queryFn:()=>D9(n,e.template.id,{topic:e.sample.topic}),enabled:o===null||s}),l=o??c.data?.high,u=o===null?(c.data?.unknown??0)>0:s,d=o===null?c.data?.problem??null:null;async function f(){if(l!==void 0){a(!0);try{let i=await QYe(n,e.template.id,{version:e.template.version,acknowledgedHigh:l,acknowledgedUnknown:u});t(i.ok?null:i.message),await r.invalidateQueries({queryKey:b9(e.template.id)})}catch(e){t(`The sample wasn't asked for: ${e instanceof Error?e.message:String(e)} Press Make sample again.`)}finally{a(!1)}}}return d===null?(o===null||s)&&c.data!==void 0&&!c.data.fits?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[NXe(c.data,`This sample`),(0,h.jsx)(eE,{to:`/settings`,search:{section:`playback`},children:`Settings → Production defaults`}),`.`]}):(0,h.jsx)(K,{size:`small`,disabled:i||l===void 0,disabledReason:i?`Asking for the sample`:`Pricing the sample`,onClick:()=>void f(),children:l===void 0?`Make sample · pricing…`:`Make sample · ${o===null&&c.data!==void 0?U9(c.data):U9({high:l,unknown:+!!u,onPlan:c.data?.onPlan===!0})}`}):(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:d})}function m$e({view:e,onDone:t}){let{api:n}=q(),r=_(),i=!e.sample.fullScript,a=I({queryKey:[...b9(e.template.id),`quote`,`full-script`,i],queryFn:()=>D9(n,e.template.id,{fullScript:i})}),[o,s]=(0,m.useState)(!1);async function c(){if(a.data!==void 0){s(!0);try{let o=await tXe(n,e.template.id,{fullScript:i,acknowledgedHigh:a.data.high,acknowledgedUnknown:a.data.unknown>0});t(o.ok?null:o.message),await r.invalidateQueries({queryKey:b9(e.template.id)})}finally{s(!1)}}}return a.data!==void 0&&a.data.problem!==null?null:(0,h.jsx)(dD,{checked:e.sample.fullScript,disabled:o||a.data===void 0,onChange:()=>void c(),className:`text-left`,label:`Write the whole article in the sample${a.data===void 0?``:` (${U9(a.data)})`}`,help:`Off, the sample writes the outline and the first chapter. Your videos always get the whole article.`})}var h$e={queued:`Queued`,making:`Being made`,done:`Made`,failed:`Failed`,skipped:`No sample made`,held:`Waiting`};function g$e({view:e}){let t=e.paid.versions.filter(t=>t.version!==e.template.version);if(t.length===0)return null;let n=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});return(0,h.jsx)(SR,{summary:`Earlier samples`,state:String(t.length),children:(0,h.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 pb-3 text-small`,children:t.map(e=>(0,h.jsxs)(`li`,{className:`flex justify-between gap-3`,children:[(0,h.jsx)(`span`,{children:`Version ${String(e.version)} · ${h$e[e.state]}`}),(0,h.jsx)(`span`,{className:`text-ink-2`,children:n.format(new Date(e.updatedAt))})]},e.version))})})}function _$e(e){return e>0&&e<.005?`under $0.01`:`about ${nE(e)}`}var v$e=e=>e.replace(/[.*+?^${}()|[\]\\]/gu,`\\$&`);function y$e(e,t,n){return n===null||n.trim()===``?e:e.replace(RegExp(`(?<![\\p{L}\\p{N}])${v$e(t)}(?![\\p{L}\\p{N}])`,`giu`),n.trim())}function b$e({templateId:e,revisionId:t,aliasesOn:n,onAliasesOn:r}){let{api:i}=q(),a=I(mXe(i,e,t)),[o,s]=(0,m.useState)(``);if(a.error)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The names to check didn't load: ${a.error.message} Reload the page to try again.`});let c=a.data;if(c===void 0||c.names.length===0)return null;let l=o.trim(),u=c===void 0?[]:l===``||c.names.some(e=>e.term.toLowerCase()===l.toLowerCase())?c.names:[...c.names,{term:l,ipa:[],line:null,spokenAs:null}];return(0,h.jsxs)(`section`,{"aria-label":`Say it as`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(`h4`,{className:`m-0 text-small font-semibold text-ink`,children:`Names the voice may say wrong`}),c.problem===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:c.problem}),c.aliasesOn?null:n?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Save to have the narration use your pronunciations, then say a name another way.`}):(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-x-2 text-small text-ink-2`,children:[`The narration doesn't use your pronunciations yet.`,(0,h.jsx)(K,{size:`small`,onClick:r,children:`Use them`})]}),u.length===0?null:(0,h.jsx)(`ul`,{"aria-label":`Names to check`,className:`m-0 flex list-none flex-col gap-3 p-0`,children:u.map(t=>(0,h.jsx)(x$e,{templateId:e,name:t,voice:c.voice,enabled:c.aliasesOn},t.term))}),t===null?null:(0,h.jsx)(J,{label:`Another word to check`,help:`Type a name the article says to hear it in the template's voice.`,children:(0,h.jsx)(Y,{value:o,maxLength:100,placeholder:`A name the script says`,onChange:e=>s(e.target.value)})})]})}function x$e({templateId:e,name:t,voice:n,enabled:r}){let{api:i}=q(),a=_(),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(),[f,p]=(0,m.useState)(!1),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)();(0,m.useEffect)(()=>()=>{y!==void 0&&URL.revokeObjectURL(y)},[y]),(0,m.useEffect)(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);let x=y$e(t.line??t.term,t.term,o.trim()||t.spokenAs),S=I({queryKey:[`audition-quote`,n?.provider??``,n?.model??``,x],queryFn:()=>ih(i,[{speaker:`Sample`,provider:n?.provider??``,model:n?.model??``,text:x}]),enabled:n!==null,staleTime:6e4}),C=I({queryKey:[...b9(e),`say-it-as`,t.term,c],queryFn:()=>gXe(i,e,{written:t.term,spoken:c}),enabled:r&&c!==``});async function w(){if(n!==null){v(!0);try{let e=await ah(i,{...n,text:x}),t=URL.createObjectURL(e);b(t),new Audio(t).play().catch(()=>void 0)}catch(e){d({error:!0,text:`The line wasn't spoken: ${e instanceof Error?e.message:String(e)} Press Play again.`})}finally{v(!1)}}}async function T(){let n=C.data;if(n!==void 0){p(!0);try{let r=await _Xe(i,e,{written:t.term,spoken:c,acknowledgedHigh:n.high,acknowledgedUnknown:n.unknown>0});if(!r.ok){d({error:!0,text:r.message});return}d({error:!1,text:`Saved in your pronunciations: “${t.term}” is said “${c}”.${r.value.queued?` Re-voicing the sample's lines that say it.`:` The sample's article doesn't say it, so nothing is re-voiced.`}`}),s(``),await a.invalidateQueries({queryKey:b9(e)})}catch(e){d({error:!0,text:`“Say it as” wasn't saved: ${e instanceof Error?e.message:String(e)} Press Save again.`})}finally{p(!1)}}}let E=S.data?.estimate,D=E==null?`Play ${t.term}`:`Play ${t.term} · ${E.unknown>0?`price unknown`:_$e(E.high)}`,O=C.data?.lines??0,k=C.data===void 0?`Save`:O===0?`Save · nothing to re-voice`:`Save · re-voice ${String(O)} ${O===1?`line`:`lines`} · ${_$e(C.data.high)}`,A=r?c===``?`Type how to say it first`:C.data===void 0?`Pricing the re-voicing`:C.data.problem===null?f?`Saving`:void 0:C.data.problem:`Use your pronunciations first`;return(0,h.jsxs)(`li`,{"aria-label":t.term,className:`flex flex-col gap-2 border-line border-b pb-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,h.jsx)(`span`,{className:`text-body font-semibold text-ink`,children:t.term}),t.ipa.length===0?null:(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`/${t.ipa.join(` `)}/`}),t.spokenAs===null?null:(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Said as “${t.spokenAs}”`})]}),t.line===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:t.line}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,...GT,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(K,{size:`small`,variant:`quiet`,disabled:n===null||g,disabledReason:n===null?`Choose a voice in Narration first`:`Speaking`,onClick:()=>void w(),children:D}),(0,h.jsx)(Y,{"aria-label":`Say ${t.term} as`,className:`min-w-0 flex-1 basis-40`,value:o,maxLength:200,placeholder:`Say it as…`,disabled:!r,onChange:e=>s(e.target.value)}),(0,h.jsx)(K,{size:`small`,disabled:A!==void 0,disabledReason:A,focusableWhenDisabled:!0,onClick:()=>void T(),children:k})]}),(0,h.jsx)(KT,{children:`Save keeps it for every video and re-voices only the sample's lines with it.`})]}),u===void 0?null:(0,h.jsx)(`p`,{role:u.error?`alert`:`status`,className:u.error?`m-0 text-small text-danger`:`m-0 text-small text-ink-2`,children:u.text})]})}function S$e({view:e}){let[t,n]=(0,m.useState)(!1);return(0,h.jsxs)(`div`,{className:`flex items-end justify-between gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`div`,{className:`sl-kicker`,children:`Sample topic`}),(0,h.jsx)(`p`,{className:`m-0 text-body text-ink`,children:e.sample.topic})]}),(0,h.jsx)(K,{size:`small`,"aria-label":`Change the sample topic`,onClick:()=>n(!0),children:`Change`}),(0,h.jsx)(C$e,{view:e,open:t,onClose:()=>n(!1)})]})}function C$e({view:e,open:t,onClose:n}){let{api:r}=q(),i=_(),[a,o]=(0,m.useState)(`typed`),[s,c]=(0,m.useState)(e.sample.topic),[l,u]=(0,m.useState)(e.sample.topic),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(null),[v,y]=(0,m.useState)(!1),b=(0,m.useRef)(void 0);(0,m.useEffect)(()=>{let e=setTimeout(()=>u(s.trim()),400);return()=>clearTimeout(e)},[s]);let x=a===`typed`?l:a,S=I({queryKey:[...b9(e.template.id),`quote`,`topic`,x],queryFn:()=>D9(r,e.template.id,{topic:x}),enabled:t&&x!==``,retry:!1}),C=S.data?.unknown??0,w=x===``?`Type a topic first`:S.data===void 0?`Pricing the new topic`:S.data.problem===null?S.data.fits?C>0&&!d?`Accept the steps with no known price first`:void 0:MXe(S.data):`No sample can be made of this setup`;async function T(){if(S.data!==void 0){y(!0),g(null);try{let t={topic:x,acknowledgedHigh:S.data.high,acknowledgedUnknown:d},a=JSON.stringify(t);b.current?.key!==a&&(b.current={key:a,id:crypto.randomUUID()});let o=await eXe(r,e.template.id,{...t,mutationId:b.current.id});if(!o.ok){g(`The topic wasn't changed: ${o.message}`),o.quote!==null&&i.setQueryData([...b9(e.template.id),`quote`,`topic`,x],o.quote);return}b.current=void 0,await i.invalidateQueries({queryKey:b9(e.template.id)}),n()}catch(e){g(`The topic wasn't changed: ${e instanceof Error?e.message:String(e)} Press Use this topic again.`)}finally{y(!1)}}}let E=S.error?.message??S.data?.problem??null;return(0,h.jsx)(LT,{open:t,onClose:n,title:`Sample topic`,footer:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,h.jsx)(K,{onClick:n,children:`Cancel`}),(0,h.jsx)(K,{variant:`primary`,disabled:v||w!==void 0,disabledReason:v?`Changing the topic`:w??``,onClick:()=>void T(),children:S.data===void 0||S.data.problem!==null?`Use this topic`:`Use this topic · ${U9(S.data)}`})]}),children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Every section's sample is made about this topic. A new topic makes every sample again, at the price on the button; going back to the fixed topic is free.`}),(0,h.jsx)(fD,{label:`Topic`,help:`The next queued topic is the one a schedule makes its next video about.`,value:a,onChange:o,options:[{value:`typed`,label:`Type one`},{value:`next-queued`,label:`Next queued topic`},{value:`fixed`,label:`The fixed topic`}]}),a===`typed`?(0,h.jsx)(J,{label:`Your topic`,children:(0,h.jsx)(Y,{value:s,maxLength:300,onChange:e=>c(e.target.value)})}):null,C>0?(0,h.jsx)(dD,{checked:d,onChange:f,label:`Accept ${String(C)} ${C===1?`step`:`steps`} with no known price`,tip:`template-studio.accept-unknown`,tipLabel:`Steps with no known price`}):null,E===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:E}),p===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:p})]})})}var w$e=(e,t)=>t===`video`?e.free.video:t===`voice`?e.free.loudness:t===`document`?e.free.document:void 0,T$e=new Set([`keywords`,`providers`,`voice`]);function E$e({view:e,section:t,making:n,onMake:r,aliasesOn:i,onAliasesOn:a}){let{api:o}=q(),[s,c]=(0,m.useState)(null),l=I(x9(o,e.template.id)),u=w$e(e,t.id),d=a$e.includes(t.id),f=u!==void 0&&(u.state===`stale`||u.state===`needs-fix`),p=d&&[`stale`,`needs-fix`,`waiting`].includes(t.state)&&e.paid.state!==`queued`&&e.paid.state!==`making`,g=`/templates/${encodeURIComponent(e.template.id)}?section=${t.id}`,_=l.data?.version===e.template.version?l.data.checks.filter(e=>!e.ok&&T$e.has(e.id)):[],v=_.find(e=>e.fix?.href===g)??_[0],y=v?.fix,b=y!==void 0&&y.href===g,x=p?y===void 0?(0,h.jsx)(p$e,{view:e,onDone:c}):b?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`${v?.sentence??``} ${(e=>{let n=` in ${t.label}`;return e.endsWith(n)?`${e.slice(0,-n.length)} in this section's settings`:`Fix it in this section's settings`})(y.label)}, then Save.`}):(0,h.jsx)(eE,{to:y.href,className:`text-small`,children:`${y.label} first`}):u!==void 0&&!d&&f?(0,h.jsx)(K,{size:`small`,disabled:n,disabledReason:`Asking for the sample`,onClick:r,children:`Make sample · free`}):null;return(0,h.jsxs)(`section`,{"aria-label":`${t.label} sample`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(S$e,{view:e}),(0,h.jsx)(lD,{title:`Sample`,as:`h3`,className:`pb-0`,status:(0,h.jsx)(hE,{tone:az[t.state],children:oz(t)})}),(0,h.jsx)(`p`,{className:G(`m-0 text-small`,t.state===`needs-fix`?`text-danger`:`text-ink-2`),children:t.sentence}),x===null?null:(0,h.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:x}),s===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:s}),t.id===`script`&&e.template.document.form.sources.article===`generate`?(0,h.jsx)(m$e,{view:e,onDone:c}):null,(0,h.jsx)(c$e,{view:e,section:t.id}),t.id===`voice`&&t.state!==`off`&&t.state!==`provided`?(0,h.jsx)(b$e,{templateId:e.template.id,revisionId:e.paid.revisionId,aliasesOn:i,onAliasesOn:a}):null,(0,h.jsx)(D$e,{view:e,section:t.id}),d?(0,h.jsx)(g$e,{view:e}):null]})}function D$e({view:e,section:t}){let{api:n}=q(),r=e=>`${n.origin}${e}`,i=e.template.document.form.format;switch(t){case`video`:return e.free.video.url===null?null:(0,h.jsx)(k$e,{children:(0,h.jsx)(sR,{src:r(e.free.video.url),label:`${e.template.name}: 30-second video sample`,portrait:i===`9:16`,square:i===`1:1`})});case`voice`:return(0,h.jsx)(O$e,{view:e,at:r});case`document`:return e.free.document.url===null?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(k$e,{className:`max-md:hidden`,children:(0,h.jsx)(`iframe`,{title:`${e.template.name}: PDF sample`,src:`${r(e.free.document.url)}#page=1&view=FitH`,className:`block h-[520px] w-full border-0 bg-surface`})}),(0,h.jsx)(tE,{href:r(e.free.document.url),target:`_blank`,rel:`noreferrer`,size:`small`,className:`self-start`,children:`Open the PDF sample`})]});case`reviews`:return e.reviews.length===0?null:(0,h.jsx)(n2,{label:`Where a run pauses`,steps:e.reviews.map(e=>({id:e.id,name:e.name,tone:e.kind===`checkpoint`?`waiting`:`info`,state:e.kind===`checkpoint`?`Waits for you`:`Checked by AI`,time:e.by===`you`?`You`:e.by===`agent`?`Agent`:`Model`,detail:e.detail}))});default:return null}}function O$e({view:e,at:t}){let n=s$e(e),{loudness:r}=e.free,i=r.beforeUrl!==null&&r.url!==null,[a,o]=(0,m.useState)(n===void 0?`after`:`sample`),s=[...n===void 0?[]:[{value:`sample`,label:`Your voice's sample`,url:n.url,name:`${e.template.name}: sample narration`}],...i?[{value:`before`,label:(0,h.jsx)(`span`,{title:A$e(r.beforeLufs),children:`Before levelling`}),url:r.beforeUrl??``,name:`Sample narration before levelling`},{value:`after`,label:(0,h.jsx)(`span`,{title:A$e(r.afterLufs),children:`After levelling (YouTube loudness)`}),url:r.url??``,name:`Sample narration after levelling`}]:[]],c=s.find(e=>e.value===a)??s[0];return c===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[s.length>1?(0,h.jsx)(fD,{label:`Hear`,help:`Levelling evens the narration out to YouTube's loudness.`,value:c.value,options:s.map(({value:e,label:t})=>({value:e,label:t})),onChange:o}):null,(0,h.jsx)(w6,{src:t(c.url),label:c.name},c.value),i&&j$e(r)!==``?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:j$e(r)}):null]})}function k$e({children:e,className:t}){return(0,h.jsx)(`div`,{className:G(`overflow-hidden rounded-media border border-line`,t),children:e})}var A$e=e=>e===null?void 0:`${e.toFixed(1)} LUFS`;function j$e(e){let{afterLufs:t,targetLufs:n,ceiling:r}=e;if(t===null||n===null||r===null)return``;let i=n-t;return Math.abs(i)<=.5?``:i<0?`It comes out ${Math.abs(i).toFixed(1)} LU louder than YouTube's ${n.toFixed(1)} LUFS.`:`Held back ${i.toFixed(1)} LU from YouTube's ${n.toFixed(1)} LUFS so its peaks stay under ${r.toFixed(1)} dBTP.`}function M$e({view:e,document:t,name:n,dirty:r,note:i}){let{api:a}=q(),o=_(),s=e.template.id,[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(crypto.randomUUID());async function p(){d(!0),l({tone:`info`,text:`Saving…`});try{let r=await ZYe(a,s,{mutationId:f.current,baseVersion:e.template.version,name:n.trim()===``?e.template.name:n.trim(),document:t,sample:`skip`,acknowledgedHigh:0,acknowledgedUnknown:!1});if(!r.ok){l({tone:`error`,text:`The template wasn't saved: ${r.message}`});return}f.current=crypto.randomUUID(),l(void 0),await o.invalidateQueries({queryKey:PM}),await o.invalidateQueries({queryKey:b9(s)})}catch(e){l({tone:`error`,text:`The template wasn't saved: ${e instanceof Error?e.message:String(e)} Press Save again.`})}finally{d(!1)}}let g=c??i??(r?{tone:`info`,text:`Unsaved changes. Save them before you make a video.`}:void 0);return!r&&g===void 0?null:(0,h.jsx)(uL,{status:(0,h.jsx)(lL,{tone:g?.tone??`info`,wrap:!0,children:g?.text}),children:r?(0,h.jsx)(K,{variant:`primary`,disabled:u,onClick:()=>void p(),children:`Save`}):null})}function N$e({view:e}){let{runs:t,cost:n}=e.schedule,r=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`});return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[t.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No schedule runs this template yet. A schedule makes a video from it on the days and at the times you pick, each about the next topic in its queue. New schedule, above, starts one with this template.`}):(0,h.jsx)(s1,{caption:`The next runs`,rowKey:e=>`${e.scheduleId}:${e.at}`,rows:t,empty:`No run is coming up.`,columns:[{id:`when`,header:`When`,cell:e=>r.format(new Date(e.at))},{id:`title`,header:`Title`,cell:e=>e.topic?e.title:`No topic queued yet`},{id:`schedule`,header:`Schedule`,cell:e=>e.paused?`${e.scheduleName} (paused)`:e.scheduleName}]}),n===null?null:(0,h.jsx)(`p`,{className:n.problem===null?`m-0 text-small text-ink-2`:`m-0 text-small text-danger`,children:n.problem??F$e(n)}),(0,h.jsx)(eE,{to:`/calendar`,search:{tab:`schedules`},className:`self-start text-small`,children:`Schedules in the calendar`})]})}var P$e=e=>{let t=Math.round(e);return t===0?`less than one run`:`about ${String(t)} ${t===1?`run`:`runs`}`};function F$e(e){let t=e.unknown===0?``:e.unpriced.length===0?` ${String(e.unknown)} ${e.unknown===1?`step has`:`steps have`} no known price and ${e.unknown===1?`isn't`:`aren't`} counted.`:` Not counted, with no known price: ${L$e(e.unpriced)}.`,n=t=>e.unknown===0?`about ${nE(t)} a month at most`:`at least ${nE(t)} a month`,r=`${I$e(n(e.high))}, for ${P$e(e.runs)}.`,{paused:i}=e;if(i.schedules===0)return`${r}${t}`;let a=`${n(i.high)}, for ${P$e(i.runs)}`;return e.runs===0?`${i.schedules===1?`1 paused schedule uses this template: nothing runs while it is paused. Resumed, ${a}.`:`${String(i.schedules)} paused schedules use this template: nothing runs while they are paused. Resumed, ${a}.`}${t}`:`${r} ${i.schedules===1?`1 paused schedule`:`${String(i.schedules)} paused schedules`} would add ${a}, once resumed.${t}`}var I$e=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function L$e(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e.at(-1)??``}`}var R$e={receipt:null,pending:!1,starting:!1,uncertain:!1,valid:!1,error:null,fields:[],created:null};function z$e({document:e,onEdit:t,onFiles:n,children:r}){let i=(0,m.useMemo)(()=>({section:`content`,navigate:async()=>void 0,review:R$e,reviewDraft:async()=>void 0,startRun:async()=>void 0,invalidateReview:()=>void 0,takeCreated:()=>null,activeId:null,fontUpload:{pending:!1,error:void 0,pick:n},fontUploading:!1,attachmentUploading:()=>!1,selectFont:n=>t({...e,form:{...e.form,subtitles:{...e.form.subtitles,fontId:n}}}),uploadSubtitleFont:async()=>n(),document:e,view:null,status:`saved`,error:null,edited:0,acknowledged:0,reveal:null,attach:async()=>n(),edit:t,flush:async()=>!0,open:async()=>!1,generation:()=>0,newDraft:async()=>void 0,discard:async()=>void 0,saveAsNew:async()=>void 0}),[e,t,n]);return(0,h.jsx)(sCe,{value:i,children:r})}function B$e({section:e,document:t,name:n,onEdit:r,onName:i}){let{form:a}=t;return e===`subject`?(0,h.jsxs)(`div`,{"data-slot":`studio-controls`,className:`sl-fields`,children:[(0,h.jsx)(J,{label:`Template name`,children:(0,h.jsx)(Y,{value:n,maxLength:120,onChange:e=>i(e.target.value)})}),(0,h.jsx)(J,{label:`Video title`,help:`{{Topic}} is filled with each video's topic.`,children:(0,h.jsx)(Y,{value:a.title,maxLength:200,onChange:e=>r({...t,form:{...a,title:e.target.value}})})})]}):e===`script`&&a.sources.article===`generate`?(0,h.jsx)(`div`,{"data-slot":`studio-controls`,className:`sl-fields`,children:(0,h.jsx)(J,{label:`Words per video`,help:`About 150 words is one minute. The article prompt decides the real length.`,children:(0,h.jsx)(Y,{inputMode:`numeric`,className:`sl-input--number`,value:t.expectedWords,onChange:e=>r({...t,expectedWords:e.target.value})})})}):null}function V$e({templateId:e,section:t,compare:n,play:r}){let{api:i}=q();Lge({templateId:e,section:qx[t]});let a=I(JYe(i,e)),o=I({...PL(i,e),enabled:a.error!==null,retry:!1});return a.error&&o.data!==void 0?(0,h.jsx)(Yi,{to:`/design-templates/$templateId`,params:{templateId:e},search:{},replace:!0}):a.error&&o.isFetching?(0,h.jsx)(W9,{}):a.error?(0,h.jsxs)(`div`,{children:[(0,h.jsx)(fL,{title:`Edit template`,crumb:(0,h.jsx)(eE,{to:`/templates`,children:`Templates`})}),(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:`This template didn't open: ${a.error.message}`})]}):a.data===void 0?(0,h.jsx)(W9,{}):(0,h.jsx)(H$e,{view:a.data,section:t,compare:n,play:r},`${a.data.template.id}:${String(a.data.template.version)}`)}function H$e({view:e,section:t,compare:n,play:r}){let{api:i}=q(),a=_();$x(`${e.template.name} · Edit template`);let o=e.template.document,[s,c]=(0,m.useState)(o),[l,u]=(0,m.useState)(e.template.name),[d,f]=(0,m.useState)(`settings`),[p,g]=(0,m.useState)(),[v,y]=(0,m.useState)(!1),b=(0,m.useRef)(!1),x=H9(),S=I(x9(i,e.template.id)),C=S.data?.version===e.template.version?S.data.checks.filter(e=>!e.ok).length:0;async function w(){y(!0);try{await YYe(i,e.template.id),await a.invalidateQueries({queryKey:b9(e.template.id)})}catch(e){g({tone:`error`,text:`The samples weren't asked for: ${e instanceof Error?e.message:String(e)} Press Make sample again.`})}finally{y(!1)}}(0,m.useEffect)(()=>{let t=[e.free.video,e.free.loudness,e.free.document],n=e.schedule.cost!==null&&e.schedule.cost.problem!==null;!b.current&&(n||t.some(e=>e.state===`stale`))&&(b.current=!0,w())},[e]);let T=l.trim(),E=JSON.stringify(s)!==JSON.stringify(o)||T!==``&&T!==e.template.name,D=e.sections.find(e=>e.id===t)??e.sections[0],O=n$e(e,E),k=(0,m.useCallback)(()=>g({tone:`info`,text:`Files are added to each video on Create: the template keeps only that the video provides them.`}),[]),A=(0,m.useCallback)(e=>{c(e),g(void 0)},[]);if(D===void 0)return(0,h.jsx)(W9,{});let j=zQe(D.id),M=e=>d===e?void 0:`max-md:hidden`,N=e.gated||e.schedule.cost!==null,P=N?r$e(e):void 0,ee=P?.line===void 0?void 0:O===void 0?P.line:`${P.line} First ${O}.`;return(0,h.jsxs)(z$e,{document:s,onEdit:A,onFiles:k,children:[(0,h.jsx)(N2,{dirty:E,what:`your template changes`,saveLabel:`Save`}),(0,h.jsx)(fL,{crumb:(0,h.jsx)(eE,{to:`/templates`,children:`Templates`}),title:`Edit template`,meta:`${e.template.name} · version ${String(e.template.version)}${P===void 0?``:` · ${P.word}`}`,actions:(0,h.jsx)(i$e,{view:e,dirty:E,scheduled:N,play:r,onProblem:e=>g(e===void 0?void 0:{tone:`error`,text:e})})}),ee===void 0?null:(0,h.jsx)(`p`,{className:`m-0 -mt-2 mb-3 text-small text-ink-2`,children:ee}),(0,h.jsx)(gL,{className:`mb-4 md:hidden`,label:`Edit template panes`,idPrefix:`studio`,value:d,onChange:f,items:[{id:`sections`,label:`Sections`},{id:`settings`,label:`Settings`},{id:`sample`,label:C===0?`Sample`:`Sample · ${String(C)} to fix`}]}),(0,h.jsx)(pL,{className:`sl-workspace--studio`,asideLabel:`Sample and checks`,sections:(0,h.jsx)(`div`,{className:M(`sections`),children:(0,h.jsx)(qEe,{templateId:e.template.id,sections:e.sections,current:D.id})}),aside:(0,h.jsxs)(`div`,{className:G(`flex flex-col gap-5`,M(`sample`)),children:[D.id===`schedule`?null:(0,h.jsx)(E$e,{view:e,section:D,making:v,onMake:()=>void w(),aliasesOn:s.form.audio.useNarrationAliases===!0,onAliasesOn:()=>A({...s,form:{...s.form,audio:{...s.form.audio,useNarrationAliases:!0}}})}),(0,h.jsx)(sQe,{templateId:e.template.id}),(0,h.jsx)(JQe,{templateId:e.template.id,dirty:E})]}),children:(0,h.jsxs)(`section`,{"aria-label":`${D.label} settings`,className:G(`flex min-w-0 flex-col gap-4`,M(`settings`)),children:[(0,h.jsx)(lD,{title:D.label,as:`h2`,className:`pb-0`}),j===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(KQe,{templateId:e.template.id,section:j,document:s,dirty:E,preset:n}),(0,h.jsx)(GQe,{templateId:e.template.id,section:j,onUse:(e,t)=>{A(VQe(s,j,e)),g({tone:`success`,text:t})}})]}),D.id===`schedule`?(0,h.jsx)(N$e,{view:e}):(0,h.jsxs)(h.Fragment,{children:[D.id===`subject`?(0,h.jsx)(B$e,{section:`subject`,document:s,name:l,onEdit:A,onName:u}):null,(0,h.jsx)(QQe,{section:D.id,document:s}),(0,h.jsx)(XQe,{section:D.id,defaults:x,onFiles:k}),D.id===`script`?(0,h.jsx)(B$e,{section:`script`,document:s,name:l,onEdit:A,onName:u}):null,D.id===`thumbnail`?(0,h.jsx)($Qe,{templateId:e.template.id,document:s}):null]}),(0,h.jsx)(PQe,{view:e,section:D.id})]})}),(0,h.jsx)(M$e,{view:e,document:s,name:l,dirty:E,note:p})]})}function W9(){return(0,h.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Loading the template`,children:[(0,h.jsx)(`div`,{className:`mb-4 h-8 w-72 rounded-control bg-raised`}),(0,h.jsxs)(`div`,{className:`sl-workspace sl-workspace--studio`,children:[(0,h.jsx)(`div`,{className:`h-96 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`h-96 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`h-96 rounded-control bg-raised`})]})]})}function U$e(){let e=GP(),t=Ji();return{getGeneration:e.generation,blocked:e.review.starting||e.review.uncertain||e.review.created!==null,beforeApply:e.flush,onApplied:async(n,r)=>!r()||!await e.open(n,r)||!r()?!1:(await t({to:`/play`}),r())}}var G9=va({component:CTe,notFoundComponent:nRe}),W$e=ga({getParentRoute:()=>G9,path:`/`,component:G$e});function G$e(){let e=GP(),t=Ji();return(0,h.jsx)(RLe,{startFrom:{getGeneration:e.generation,blocked:e.review.starting||e.review.uncertain||e.review.created!==null,beforeApply:e.flush,onApplied:async(n,r)=>!r()||!await e.open(n,r)||!r()?!1:(await t({to:`/play`}),r())}})}function K9(e){let t=Sqe(e.show),n=typeof e.q==`string`&&e.q.trim()!==``?e.q.slice(0,200):``,r=Tqe(e.sort);return{...t===void 0||t===`all`?{}:{show:t},...n===``?{}:{q:n},...r===void 0||r===`newest`?{}:{sort:r}}}var K$e=ga({getParentRoute:()=>G9,path:`projects`,validateSearch:K9,component:q$e});function q$e(){let{show:e,q:t,sort:n}=K$e.useSearch(),r=Ji();return(0,h.jsx)(Mqe,{filter:e??`all`,query:t??``,sort:n??`newest`,onFilter:e=>{r({to:`/projects`,search:K9({show:e,q:t,sort:n}),replace:!0,resetScroll:!1})},onQuery:t=>{r({to:`/projects`,search:K9({show:e,q:t,sort:n}),replace:!0,resetScroll:!1})},onSort:n=>{r({to:`/projects`,search:K9({show:e,q:t,sort:n}),replace:!0,resetScroll:!1})}})}function J$e(e){let t=R9.find(t=>t===e.step);return t===void 0||t===`found`?{}:{step:t}}var Y$e=ga({getParentRoute:()=>G9,path:`welcome`,validateSearch:J$e,component:X$e});function X$e(){let{step:e}=Y$e.useSearch(),t=Ji();return(0,h.jsx)(AQe,{step:e??`found`,onStep:e=>{t({to:`/welcome`,search:J$e({step:e}),replace:!0})}})}var Z$e=ga({getParentRoute:()=>G9,path:`play`,component:OBe}),q9=ga({getParentRoute:()=>G9,id:`_library`,component:zLe}),Q$e=ga({getParentRoute:()=>G9,path:`library`,beforeLoad:()=>{throw cn({to:`/prompts`,search:{kind:`article`}})}}),$$e=ga({getParentRoute:()=>G9,path:`channels`,validateSearch:e=>e.tab===void 0?{}:{tab:h1(e.tab)},component:e1e});function e1e(){let{tab:e}=$$e.useSearch(),t=Ji();return(0,h.jsx)(yFe,{tab:e??`brand`,onTab:e=>{t({to:`/channels`,search:{tab:e},resetScroll:!1})}})}var J9=ga({getParentRoute:()=>G9,path:`channels/$channelId`,validateSearch:e=>e.tab===void 0?{}:{tab:h1(e.tab)},component:t1e});function t1e(){let{channelId:e}=J9.useParams(),{tab:t}=J9.useSearch(),n=Ji();return(0,h.jsx)(g1,{channelId:e,tab:t??`brand`,onTab:t=>{n({to:`/channels/$channelId`,params:{channelId:e},search:{tab:t},resetScroll:!1})}},e)}var n1e=ga({getParentRoute:()=>G9,path:`designs`,beforeLoad:({search:e})=>{if(e.tab===`templates`)throw cn({to:`/templates`,search:{tab:`posters`},replace:!0})},component:VEe}),r1e=ga({getParentRoute:()=>G9,path:`designs/$designId`,component:i1e});function i1e(){let{designId:e}=r1e.useParams();return(0,h.jsx)(LEe,{designId:e},e)}var a1e=ga({getParentRoute:()=>G9,path:`design-templates/$templateId`,component:o1e});function o1e(){let{templateId:e}=a1e.useParams();return(0,h.jsx)(cDe,{templateId:e},e)}var s1e=ga({getParentRoute:()=>G9,path:`templates`,validateSearch:e=>({...mQe(e.tab)===`posters`?{tab:`posters`}:{},...pz(e.item)}),component:p1e}),c1e=/^[0-9A-Za-z-]{1,64}$/;function Y9(e){let t=pPe(e.tab);return t===`releases`?{tab:t}:t===`schedules`?typeof e.schedule==`string`&&c1e.test(e.schedule)?{tab:`schedules`,schedule:e.schedule}:{tab:`schedules`}:{}}var l1e=ga({getParentRoute:()=>G9,path:`calendar`,validateSearch:Y9,component:f1e}),u1e=ga({getParentRoute:()=>G9,path:`schedules`,beforeLoad:()=>{throw cn({to:`/calendar`,search:{tab:`schedules`},replace:!0})}}),d1e=ga({getParentRoute:()=>G9,path:`schedules/$scheduleId`,beforeLoad:({params:e})=>{throw cn({to:`/calendar`,search:Y9({tab:`schedules`,schedule:e.scheduleId}),replace:!0})}});function f1e(){let e=Y9(l1e.useSearch()),t=Ji();return(0,h.jsx)(gPe,{tab:e.tab??`weeks`,schedule:e.schedule,onTab:e=>{t({to:`/calendar`,search:e===`weeks`?{}:{tab:e},resetScroll:!1})},onSchedule:e=>{t({to:`/calendar`,search:{tab:`schedules`,schedule:e},replace:!0})}})}function p1e(){let{tab:e,item:t}=s1e.useSearch(),n=Ji();return(0,h.jsx)(gQe,{...U$e(),tab:e??`videos`,item:t,onTab:e=>{n({to:`/templates`,search:e===`posters`?{tab:`posters`}:{},resetScroll:!1})}})}var X9=ga({getParentRoute:()=>G9,path:`templates/$templateId`,validateSearch:e=>{let t=Kx.find(t=>t===e.section),n=e=>typeof e==`string`&&e.trim()!==``&&e.length<=200?e:void 0,r=n(e.compareProvider),i=n(e.compareModel);return{...t===void 0?{}:{section:t},...r===void 0||i===void 0?{}:{compareProvider:r,compareModel:i}}},component:m1e});function m1e(){let{templateId:e}=X9.useParams(),{section:t,compareProvider:n,compareModel:r}=X9.useSearch();return(0,h.jsx)(V$e,{templateId:e,play:U$e(),section:t??`subject`,compare:n===void 0||r===void 0?void 0:{provider:n,model:r}},e)}var h1e=ga({getParentRoute:()=>G9,path:`projects/$projectId`,validateSearch:e=>{let t=A7(e.section);return t===void 0?{}:{section:t}},component:F1e}),g1e=ga({getParentRoute:()=>q9,path:`prompts`,validateSearch:e=>({kind:vO(e.kind),...pz(e.item)}),component:I1e}),_1e=ga({getParentRoute:()=>G9,path:`prompts/new`,validateSearch:e=>{let t=vO(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:L1e}),v1e=ga({getParentRoute:()=>G9,path:`prompts/$promptId`,component:R1e}),y1e=ga({getParentRoute:()=>q9,path:`entries`,validateSearch:e=>({category:dO(e.category),...pz(e.item)}),component:B1e}),b1e=ga({getParentRoute:()=>G9,path:`entries/new`,validateSearch:e=>{let t=dO(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:V1e}),x1e=ga({getParentRoute:()=>G9,path:`entries/$entryId`,component:H1e}),S1e=ga({getParentRoute:()=>q9,path:`narration-aliases`,component:tRe}),C1e=ga({getParentRoute:()=>q9,path:`name-pronunciations`,component:HLe}),w1e=ga({getParentRoute:()=>q9,path:`ab-results`,component:lOe}),T1e=ga({getParentRoute:()=>q9,path:`document-themes`,validateSearch:e=>pz(e.item),component:uIe}),E1e=ga({getParentRoute:()=>G9,path:`document-themes/new`,validateSearch:e=>typeof e.from==`string`?{from:e.from}:{},component:U1e}),D1e=ga({getParentRoute:()=>G9,path:`document-themes/$themeId`,component:W1e});function O1e(e){let t=e.section===void 0?void 0:OE(e.section),n=t===`patch-notes`&&typeof e.note==`string`&&/^[0-9A-Za-z][0-9A-Za-z.-]{0,63}$/.test(e.note)?e.note:void 0,r=[`llm`,`tts`,`image`].find(t=>t===e.family),i=typeof e.provider==`string`&&/^[a-z0-9-]{1,40}$/.test(e.provider)?e.provider:void 0,a=[`welcome`,`play`].find(t=>t===e.return),o=a!==void 0&&typeof e.step==`string`&&/^[a-z-]{1,20}$/.test(e.step)?e.step:void 0;return{...t===void 0?{}:{section:t},...n===void 0?{}:{note:n},...r===void 0?{}:{family:r},...i===void 0?{}:{provider:i},...a===void 0?{}:{return:a},...o===void 0?{}:{step:o}}}var k1e=ga({getParentRoute:()=>G9,path:`settings`,validateSearch:O1e,component:P1e}),Z9=ga({getParentRoute:()=>G9,path:`help/tutorials/$page`,validateSearch:e=>typeof e.q==`string`&&e.q.trim()!==``?{q:e.q.slice(0,200)}:{},component:A1e});function A1e(){let{page:e}=Z9.useParams(),{q:t}=Z9.useSearch(),n=Ha({select:e=>e.hash});return(0,h.jsx)(bQe,{page:e,anchor:n===``?void 0:n,words:t})}var j1e=ga({getParentRoute:()=>G9,path:`help`,beforeLoad:()=>{throw cn({to:`/help/tutorials/$page`,params:{page:`Home`}})}}),M1e=ga({getParentRoute:()=>G9,path:`help/tutorials`,beforeLoad:()=>{throw cn({to:`/help/tutorials/$page`,params:{page:`Home`}})}}),N1e=ga({getParentRoute:()=>G9,path:`usage`,beforeLoad:()=>{throw cn({to:`/settings`,search:{section:`usage`}})}});function P1e(){let{section:e,note:t,family:n,provider:r,return:i,step:a}=k1e.useSearch(),o=Ji(),s=EE.find(t=>t.id===(e??`providers`));return $x(s===void 0?`Settings`:`Settings · ${s.label}`),(0,h.jsx)(XZe,{section:e??`providers`,note:t,family:n,provider:r,back:i===void 0?void 0:{to:i,step:a},onSection:e=>{o({to:`/settings`,search:{section:e,...i===void 0?{}:{return:i},...a===void 0?{}:{step:a}},resetScroll:!1})},onNote:e=>{o({to:`/settings`,search:{section:`patch-notes`,...e===void 0?{}:{note:e}}})}})}function F1e(){let{projectId:e}=h1e.useParams(),t=GP(),n=Ji();return(0,h.jsx)(fqe,{projectId:e,openDraft:async e=>!await t.flush()||!await t.open(e)?!1:(await n({to:`/play`}),!0)},e)}function I1e(){let{kind:e}=g1e.useSearch(),t=Q9();return(0,h.jsx)(Nqe,{kind:e,onMakeVideo:t.use,makeBlocked:t.blocked})}function Q9(){let e=GP(),t=Ji();return{blocked:e.review.starting||e.review.uncertain||e.review.created!==null?`Create is starting a video from its draft. Wait for it to start, then try again.`:void 0,use:n=>{let r=oOe(e.document,n);e.edit(r.document),t({to:`/play`}).then(()=>e.navigate(r.section,r.field))}}}function L1e(){let{kind:e,from:t}=_1e.useSearch(),n=z1e(),r=Q9();return(0,h.jsx)(yB,{promptId:void 0,kind:e,from:t,onLeave:n,onMakeVideo:r.blocked===void 0?r.use:void 0},`${e}:${t??`new`}`)}function R1e(){let{promptId:e}=v1e.useParams(),t=z1e(),n=Q9();return(0,h.jsx)(yB,{promptId:e,kind:`article`,from:void 0,onLeave:t,onMakeVideo:n.blocked===void 0?n.use:void 0},e)}function z1e(){let e=Ji();return t=>{e({to:`/prompts`,search:{kind:t}})}}function B1e(){let{category:e}=y1e.useSearch(),t=Q9();return(0,h.jsx)(xIe,{category:e,onMakeVideo:t.use,makeBlocked:t.blocked})}function V1e(){let{category:e,from:t}=b1e.useSearch(),n=K1e();return(0,h.jsx)(Y0,{entryId:void 0,category:e,from:t,onLeave:n})}function H1e(){let{entryId:e}=x1e.useParams(),t=K1e();return(0,h.jsx)(Y0,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function U1e(){let{from:e}=E1e.useSearch(),t=G1e();return(0,h.jsx)(L1,{themeId:void 0,from:e,onLeave:t})}function W1e(){let{themeId:e}=D1e.useParams(),t=G1e();return(0,h.jsx)(L1,{themeId:e,from:void 0,onLeave:t})}function G1e(){let e=Ji();return()=>{e({to:`/document-themes`})}}function K1e(){let e=Ji();return t=>{e({to:`/entries`,search:{category:t}})}}var q1e=G9.addChildren({homeRoute:W$e,projectsRoute:K$e,welcomeRoute:Y$e,playRoute:Z$e,libraryRoute:q9.addChildren({promptsRoute:g1e,entriesRoute:y1e,documentThemesRoute:T1e,narrationAliasesRoute:S1e,namePronunciationsRoute:C1e,abResultsRoute:w1e}),templatesRoute:s1e,templateStudioRoute:X9,designsRoute:n1e,schedulesRoute:u1e,scheduleRoute:d1e,calendarRoute:l1e,libraryIndexRoute:Q$e,channelsRoute:$$e,channelRoute:J9,designPageRoute:r1e,designTemplateRoute:a1e,projectRoute:h1e,newPromptRoute:_1e,promptRoute:v1e,newEntryRoute:b1e,entryRoute:x1e,newDocumentThemeRoute:E1e,documentThemeRoute:D1e,settingsRoute:k1e,usageRoute:N1e,helpRoute:j1e,tutorialsIndexRoute:M1e,tutorialsRoute:Z9});function J1e(){return Fa({routeTree:q1e,defaultErrorComponent:rRe,scrollRestoration:({location:e})=>!Kge(e.pathname,e.search)})}function Y1e(){let e,t,n=new Set;return{observe:r=>{if(e===void 0){e=r;for(let e of n)e()}else if(r!==e&&r!==t){t=r;for(let e of n)e()}},staleAt:()=>t,loadedAt:()=>e,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function X1e(e,t){return async(n,r)=>{let i=await e(n,r),a=i.headers.get(`X-Slopify-Version`);return a!==null&&t.observe(a),i}}function Z1e(){let e=new Map;return{observe:t=>{if(t.type===`stage.state`){let n=e.get(t.projectId);if(n){for(let[e,r]of n)r.stage===t.stage&&r.revisionId===t.revisionId&&r.workId===t.workId&&n.delete(e);n.size===0&&e.delete(t.projectId)}return}if(t.type!==`llm.preview`)return;let n=e.get(t.projectId)??new Map,r=JSON.stringify([t.revisionId,t.workId,t.callId]),i=n.get(r),a=(t.reset?t.text:`${i?.text??``}${t.text}`).slice(-65536);for(n.delete(r),n.set(r,{...t,text:a,reset:!0});n.size>8;){let e=n.keys().next().value;e!==void 0&&n.delete(e)}for(e.delete(t.projectId),e.set(t.projectId,n);e.size>16;){let t=e.keys().next().value;t!==void 0&&e.delete(t)}},snapshot:t=>[...e.get(t)?.values()??[]],snapshotAll:()=>[...e.values()].flatMap(e=>[...e.values()])}}var Q1e=/\/events\/projects\/([^/?#]+)/,$1e=/\/events\/global(?:[?#]|$)/,e0e=[`running.count`,`staging.progress`,`staging.failed`,`schedule.topics`,`template.sample`,`stage.state`,`stage.progress`,`article.delta`,`llm.preview`,`image.landed`,`narration.piece`,`project.state`,`project.updated`,`review.flagged`,`review.auto-passed`,`assistant.delta`,`assistant.tool`,`assistant.ask`,`assistant.turn`,`design.changed`,`design-template.sample`],t0e=2,n0e=e=>Math.min(3e4,1e3*2**e);function r0e(e,t=(e,t)=>setTimeout(e,t)){let n=new Set,r=Z1e(),i,a=!1,o=0,s=(e,t,n)=>{for(let r of e.listeners.get(t)??[])r({data:n})},c=l=>{if(i!==void 0)return;let u=e(l);i=u,u.addEventListener(`open`,()=>{a=!0,o=0;for(let e of[...n])for(let t of e.opens)t()}),u.addEventListener(`error`,()=>{if(i!==u)return;for(let e of[...n])s(e,`error`,``);if(u.readyState!==t0e)return;u.close(),i=void 0;let e=n0e(o);o+=1,t(()=>{i===void 0&&n.size>0&&c(l)},e)});for(let e of e0e)u.addEventListener(e,t=>{let i;try{let n=JSON.parse(t.data);typeof n.projectId==`string`&&(i=n.projectId),(e===`llm.preview`||e===`stage.state`)&&r.observe(n)}catch{return}for(let r of[...n])(r.projectId===void 0||r.projectId===i)&&s(r,e,t.data)})};return t=>{let o=Q1e.exec(t)?.[1];if(o===void 0&&!$1e.test(t))return e(t);c(o===void 0?t:t.replace(Q1e,`/events/global`));let l={projectId:o===void 0?void 0:decodeURIComponent(o),listeners:new Map,opens:new Set};return n.add(l),a&&queueMicrotask(()=>{if(n.has(l)){for(let e of l.opens)e();if(l.projectId!==void 0)for(let e of r.snapshot(l.projectId))s(l,`llm.preview`,JSON.stringify(e))}}),{addEventListener:(e,t)=>{if(e===`open`){l.opens.add(t);return}let n=l.listeners.get(e)??new Set;n.add(t),l.listeners.set(e,n)},close:()=>{n.delete(l),n.size===0&&i!==void 0&&(i.close(),i=void 0,a=!1)}}}}function i0e(e){let t=Y1e(),n={api:$ee(window.location.origin,X1e(window.fetch.bind(window),t),tte(e=>{let n=e.headers.get(`X-Slopify-Version`);n!==null&&t.observe(n)})),openEvents:r0e(e=>new EventSource(e)),version:t};(0,qee.createRoot)(e).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:new Ge,children:(0,h.jsx)(nle,{deps:n,children:(0,h.jsx)(Ra,{router:J1e()})})})}))}var $9=document.getElementById(`root`);if($9===null)throw Error(`index.html carries no #root element for the app to mount on`);i0e($9);
|