@gentbajko/slopify 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension/slopify-studio-chrome.zip +0 -0
- package/dist/extension/slopify-studio-firefox.zip +0 -0
- package/dist/patch-notes/3.3.1.md +7 -0
- package/dist/patch-notes/index.json +6 -0
- package/dist/web/assets/{index-BKn7EPwB.js → index-DmLX0oKs.js} +3 -3
- package/dist/web/assets/{pdf-BPADxYaD.js → pdf-BI8cHr9G.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
|
@@ -101,7 +101,7 @@ Error generating stack: `+e.message+`
|
|
|
101
101
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function dE(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;dE(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var fE=new Set([`type`,`properties`,`required`,`additionalProperties`]),pE=[`oneOf`,`anyOf`];function mE(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function hE(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!fE.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??mE(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}pC(n,r,e.length===1?e[0]:hE(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=mE(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function gE(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of fE)if(t in e)return;let n=t.filter(e=>pE.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=hE(t);else{let e=n[0],i=pE.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>hE([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,aE(e,r))}function _E(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):aE(i,s),aE(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())dE(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])gE(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}aE(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,pC(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:bE(t,`input`,e.processors),output:bE(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function vE(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return vE(r.element,n);if(r.type===`set`)return vE(r.valueType,n);if(r.type===`lazy`)return vE(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return vE(r.innerType,n);if(r.type===`intersection`)return vE(r.left,n)||vE(r.right,n);if(r.type===`record`||r.type===`map`)return vE(r.keyType,n)||vE(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:vE(r.in,n)||vE(r.out,n);if(r.type===`object`){for(let e in r.shape)if(vE(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(vE(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(vE(e,n))return!0;return!!(r.rest&&vE(r.rest,n))}return!1}var yE=(e,t={})=>n=>{let r=oE({...n,processors:t});return cE(e,r),uE(r,e),_E(r,e)},bE=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=oE({...i??{},target:a,io:t,processors:n});return cE(e,o),uE(o,e),_E(o,e)},xE={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},SE=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=xE[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},CE=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(Number.isFinite(c)&&c!==0?i.multipleOf=Math.abs(c):sE(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},wE=(e,t,n,r)=>{n.type=`boolean`},TE=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},EE=(e,t,n,r)=>{n.not={}},DE=(e,t,n,r)=>{let i=e._zod.def,a=oC(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},OE=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(sE(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(sE(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},kE=(e,t,n,r)=>{sE(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},AE=(e,t,n,r)=>{sE(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},jE=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=cE(a.element,t,{...r,path:[...r.path,`items`]})};function ME(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ME(t.out):t.type===`catch`?ME(t.innerType):e._zod.optin}var NE=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&sE(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)pC(i.properties,e,cE(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e];return t.io===`input`?ME(n)===void 0:n._zod.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=cE(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},PE=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>cE(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},FE=(e,t,n,r)=>{let i=e._zod.def,a=cE(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=cE(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},IE=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>cE(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?cE(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?ME(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=e._zod.bag;typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function LE(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=LE(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>LE(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?iT:rT).source),p):p}var RE=new WeakMap;function zE(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of RE.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=LE(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var BE=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=cE(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)pC(i.patternProperties,t.source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=cE(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=RE.get(t);n||(n=[],RE.set(t,n),t.deferred.push(()=>zE(t))),n.push(e)}i.additionalProperties=cE(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&ME(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},VE=(e,t,n,r)=>{let i=e._zod.def,a=cE(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},HE=(e,t,n,r)=>{let i=e._zod.def;cE(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},UE=Symbol();function WE(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(sE(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),UE):JSON.parse(o)}var GE=(e,t,n,r)=>{let i=e._zod.def;cE(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=WE(i.defaultValue,e,t,n,r);o!==UE&&(n.default=o)},KE=(e,t,n,r)=>{let i=e._zod.def;cE(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=WE(i.defaultValue,e,t,n,r);o!==UE&&(n._prefault=o)},qE=(e,t,n,r)=>{let i=e._zod.def;cE(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{sE(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},JE=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;cE(o,t,r);let s=t.seen.get(e);s.ref=o},YE=(e,t,n,r)=>{let i=e._zod.def;cE(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},XE=(e,t,n,r)=>{let i=e._zod.def;cE(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ZE=new WeakSet([Object.prototype,Error.prototype]);function QE(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var $E=U(`ZodError`,(e,t)=>{bw.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);ZE.has(n)||(ZE.add(n),QE(n,`format`,e=>t=>ww(e,t)),QE(n,`flatten`,e=>t=>Cw(e,t)),QE(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,cC,2)}),QE(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,cC,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),eD=Ew($E),tD=Dw($E),nD=Ow($E),rD=Aw($E),iD=Mw($E),aD=Nw($E),oD=Pw($E),sD=Fw($E),cD=Iw($E),lD=Lw($E),uD=Rw($E),dD=zw($E);function fD(){dw.localeError||fw($ne())}function pD(){dw.memoizer||fw({memoizer:Xne()})}var mD=U(`ZodType`,(e,t)=>(fD(),dT.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(mC(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return wC(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(IO(e,t))},superRefine(e,t){return this.check(LO(e,t))},overwrite(e){return this.check(iE(e))},optional(){return vO(this)},exactOptional(){return bO(this)},nullable(){return SO(this)},nullish(){return vO(SO(this))},nonoptional(e){return OO(this,e)},array(){return K(this)},or(e){return nO([this,e])},and(e){return oO(this,e)},transform(e){return MO(this,gO(e))},default(e){return wO(this,e)},prefault(e){return EO(this,e)},catch(e){return AO(this,e)},pipe(e){return MO(this,e)},readonly(){return PO(this)},describe(e){let t=this.clone();return qT.add(t,{description:e}),t},meta(...e){if(e.length===0)return qT.get(this);let t=this.clone();return qT.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return YC(this,`~standard`,{...pT(this),jsonSchema:{input:bE(this,`input`),output:bE(this,`output`)}})},set"~standard"(e){JC(this,`~standard`,e)},parse:function e(t,n){return eD(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await tD(this,t,n,{callee:e})},safeParse(e,t){return nD(this,e,t)},async safeParseAsync(e,t){return rD(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){JC(this,`spa`,e)},encode:function e(t,n){return iD(this,t,n,{callee:e})},decode:function e(t,n){return aD(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await oD(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await sD(this,t,n,{callee:e})},safeEncode(e,t){return cD(this,e,t)},safeDecode(e,t){return lD(this,e,t)},async safeEncodeAsync(e,t){return uD(this,e,t)},async safeDecodeAsync(e,t){return dD(this,e,t)},toJSONSchema(e){return yE(this,{})(e)},get description(){return qT.get(this)?.description},get _def(){return this._zod.def}}),hD=U(`_ZodString`,(e,t)=>{mT.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>SE(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(Nre(...e))},includes(...e){return this.check(Ire(...e))},startsWith(...e){return this.check(Lre(...e))},endsWith(...e){return this.check(Rre(...e))},min(...e){return this.check(nE(...e))},max(...e){return this.check(tE(...e))},length(...e){return this.check(rE(...e))},nonempty(...e){return this.check(nE(1,...e))},lowercase(e){return this.check(Pre(e))},uppercase(e){return this.check(Fre(e))},trim(){return this.check(Bre())},normalize(...e){return this.check(zre(...e))},toLowerCase(){return this.check(Vre())},toUpperCase(){return this.check(Hre())},slugify(){return this.check(Ure())}}),gD=U(`ZodString`,(e,t)=>{mT.init(e,t),hD.init(e,t)},{email(e){return this.check(rre(SD,e))},url(e){return this.check(cre(ED,e))},jwt(e){return this.check(Cre(VD,e))},emoji(e){return this.check(lre(DD,e))},guid(e){return this.check(ire(CD,e))},uuid(e){return this.check(JT(wD,e))},uuidv4(e){return this.check(are(wD,e))},uuidv6(e){return this.check(ore(wD,e))},uuidv7(e){return this.check(sre(wD,e))},nanoid(e){return this.check(ure(OD,e))},cuid(e){return this.check(dre(kD,e))},cuid2(e){return this.check(fre(AD,e))},ulid(e){return this.check(pre(jD,e))},base64(e){return this.check(bre(RD,e))},base64url(e){return this.check(xre(zD,e))},xid(e){return this.check(mre(MD,e))},ksuid(e){return this.check(hre(ND,e))},ipv4(e){return this.check(gre(PD,e))},ipv6(e){return this.check(_re(FD,e))},cidrv4(e){return this.check(vre(ID,e))},cidrv6(e){return this.check(yre(LD,e))},e164(e){return this.check(Sre(BD,e))},datetime(e){return this.check(YT(vD,e))},date(e){return this.check(wre(yD,e))},time(e){return this.check(Tre(bD,e))},duration(e){return this.check(Ere(xD,e))}});function W(e){return nre(gD,e)}var _D=U(`ZodStringFormat`,(e,t)=>{hT.init(e,t),hD.init(e,t)}),vD=U(`ZodISODateTime`,(e,t)=>{one.init(e,t),_D.init(e,t)}),yD=U(`ZodISODate`,(e,t)=>{sne.init(e,t),_D.init(e,t)}),bD=U(`ZodISOTime`,(e,t)=>{cne.init(e,t),_D.init(e,t)}),xD=U(`ZodISODuration`,(e,t)=>{lne.init(e,t),_D.init(e,t)}),SD=U(`ZodEmail`,(e,t)=>{Kte.init(e,t),_D.init(e,t)}),CD=U(`ZodGUID`,(e,t)=>{Wte.init(e,t),_D.init(e,t)}),wD=U(`ZodUUID`,(e,t)=>{Gte.init(e,t),_D.init(e,t)});function TD(e){return JT(wD,e)}var ED=U(`ZodURL`,(e,t)=>{Qte.init(e,t),_D.init(e,t)}),DD=U(`ZodEmoji`,(e,t)=>{$te.init(e,t),_D.init(e,t)}),OD=U(`ZodNanoID`,(e,t)=>{ene.init(e,t),_D.init(e,t)}),kD=U(`ZodCUID`,(e,t)=>{tne.init(e,t),_D.init(e,t)}),AD=U(`ZodCUID2`,(e,t)=>{nne.init(e,t),_D.init(e,t)}),jD=U(`ZodULID`,(e,t)=>{rne.init(e,t),_D.init(e,t)}),MD=U(`ZodXID`,(e,t)=>{ine.init(e,t),_D.init(e,t)}),ND=U(`ZodKSUID`,(e,t)=>{ane.init(e,t),_D.init(e,t)}),PD=U(`ZodIPv4`,(e,t)=>{une.init(e,t),_D.init(e,t)}),FD=U(`ZodIPv6`,(e,t)=>{fne.init(e,t),_D.init(e,t)}),ID=U(`ZodCIDRv4`,(e,t)=>{pne.init(e,t),_D.init(e,t)}),LD=U(`ZodCIDRv6`,(e,t)=>{hne.init(e,t),_D.init(e,t)}),RD=U(`ZodBase64`,(e,t)=>{gne.init(e,t),_D.init(e,t)}),zD=U(`ZodBase64URL`,(e,t)=>{vne.init(e,t),_D.init(e,t)}),BD=U(`ZodE164`,(e,t)=>{yne.init(e,t),_D.init(e,t)}),VD=U(`ZodJWT`,(e,t)=>{xne.init(e,t),_D.init(e,t)}),HD=U(`ZodNumber`,(e,t)=>{vT.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>CE(e,t,n,r);let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(QT(e,t))},gte(e,t){return this.check($T(e,t))},min(e,t){return this.check($T(e,t))},lt(e,t){return this.check(XT(e,t))},lte(e,t){return this.check(ZT(e,t))},max(e,t){return this.check(ZT(e,t))},int(e){return this.check(WD(e))},safe(e){return this.check(WD(e))},positive(e){return this.check(QT(0,e))},nonnegative(e){return this.check($T(0,e))},negative(e){return this.check(XT(0,e))},nonpositive(e){return this.check(ZT(0,e))},multipleOf(e,t){return this.check(eE(e,t))},step(e,t){return this.check(eE(e,t))},finite(){return this}});function G(e){return Dre(HD,e)}var UD=U(`ZodNumberFormat`,(e,t)=>{Sne.init(e,t),HD.init(e,t)});function WD(e){return Ore(UD,e)}var GD=U(`ZodBoolean`,(e,t)=>{Cne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wE(e,t,n,r)});function KD(e){return kre(GD,e)}var qD=U(`ZodNull`,(e,t)=>{wne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>TE(e,t,n,r)});function JD(e){return Are(qD,e)}var YD=U(`ZodUnknown`,(e,t)=>{Tne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function XD(){return jre(YD)}var ZD=U(`ZodNever`,(e,t)=>{Ene.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>EE(e,t,n,r)});function QD(e){return Mre(ZD,e)}var $D=U(`ZodArray`,(e,t)=>{pD(),Dne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jE(e,t,n,r),e.element=t.element},{min(e,t){return this.check(nE(e,t))},nonempty(e){return this.check(nE(1,e))},max(e,t){return this.check(tE(e,t))},length(e,t){return this.check(rE(e,t))},unwrap(){return this.element}});function K(e,t){return Wre($D,e,t)}var eO=U(`ZodObject`,(e,t)=>{pD(),Ane.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>NE(e,t,n,r),nw(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return J(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:XD()})},loose(){return this.clone({...this._zod.def,catchall:XD()})},strict(){return this.clone({...this._zod.def,catchall:QD()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return jC(this,e)},safeExtend(e){return MC(this,e)},merge(e){return NC(this,e)},pick(e){return kC(this,e)},omit(e){return AC(this,e)},partial(...e){return PC(_O,this,e[0])},exactPartial(...e){return PC(yO,this,e[0],`exactPartial`)},required(...e){return FC(DO,this,e[0])}});function q(e,t){return new eO({type:`object`,shape:e??{},...TC(t)})}var tO=U(`ZodUnion`,(e,t)=>{TT.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>PE(e,t,n,r),e.options=t.options});function nO(e,t){return new tO({type:`union`,options:e,...TC(t)})}var rO=U(`ZodDiscriminatedUnion`,(e,t)=>{tO.init(e,t),jne.init(e,t)});function iO(e,t,n){return new rO({type:`union`,options:t,discriminator:e,...TC(n)})}var aO=U(`ZodIntersection`,(e,t)=>{Mne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>FE(e,t,n,r)});function oO(e,t){return new aO({type:`intersection`,left:e,right:t})}var sO=U(`ZodTuple`,(e,t)=>{pD(),Nne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>IE(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new _O({type:`optional`,innerType:e}))})}});function cO(e,t,n){let r=t instanceof dT;return new sO({type:`tuple`,items:e,rest:r?t:null,...TC(r?n:t)})}var lO=U(`ZodRecord`,(e,t)=>{pD(),Pne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>BE(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function uO(e,t,n){return!t||!t._zod?new lO({type:`record`,keyType:W(),valueType:e,...TC(t)}):new lO({type:`record`,keyType:e,valueType:t,...TC(n)})}function dO(e,t,n){return new lO({type:`record`,keyType:e,valueType:t,...TC(n),partial:!0})}var fO=U(`ZodEnum`,(e,t)=>{Fne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>DE(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new fO({...t,checks:[],...TC(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new fO({...t,checks:[],...TC(r),entries:i})}});function J(e,t){return new fO({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...TC(t)})}var pO=U(`ZodLiteral`,(e,t)=>{Ine.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>OE(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function mO(e,t){return new pO({type:`literal`,values:Array.isArray(e)?e:[e],...TC(t)})}var hO=U(`ZodTransform`,(e,t)=>{pD(),Lne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>AE(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new uw(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(KC(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(KC(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function gO(e){return new hO({type:`transform`,transform:e})}var _O=U(`ZodOptional`,(e,t)=>{MT.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>XE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vO(e){return new _O({type:`optional`,innerType:e})}var yO=U(`ZodExactOptional`,(e,t)=>{Rne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>XE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bO(e){return new yO({type:`optional`,innerType:e})}var xO=U(`ZodNullable`,(e,t)=>{zne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>VE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function SO(e){return new xO({type:`nullable`,innerType:e})}var CO=U(`ZodDefault`,(e,t)=>{Bne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>GE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function wO(e,t){return new CO({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():xC(t)}})}var TO=U(`ZodPrefault`,(e,t)=>{Vne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>KE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function EO(e,t){return new TO({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():xC(t)}})}var DO=U(`ZodNonOptional`,(e,t)=>{Hne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>HE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function OO(e,t){return new DO({type:`nonoptional`,innerType:e,...TC(t)})}var kO=U(`ZodCatch`,(e,t)=>{Une.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function AO(e,t){return new kO({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:iw(t)})}var jO=U(`ZodPipe`,(e,t)=>{Wne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JE(e,t,n,r),e.in=t.in,e.out=t.out});function MO(e,t){return new jO({type:`pipe`,in:e,out:t})}var NO=U(`ZodReadonly`,(e,t)=>{Gne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>YE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function PO(e){return new NO({type:`readonly`,innerType:e})}var FO=U(`ZodCustom`,(e,t)=>{Kne.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kE(e,t,n,r)});function IO(e,t={}){return Gre(FO,e,t)}function LO(e,t){return Kre(e,t)}function RO(e){return YT(vD,e)}var zO=[{code:`en`,name:`English`,native:`English`,script:`latin`,timing:`english`},{code:`es`,name:`Spanish`,native:`Español`,script:`latin`,timing:`multilingual`},{code:`de`,name:`German`,native:`Deutsch`,script:`latin`,timing:`multilingual`},{code:`fr`,name:`French`,native:`Français`,script:`latin`,timing:`multilingual`},{code:`it`,name:`Italian`,native:`Italiano`,script:`latin`,timing:`multilingual`},{code:`pt`,name:`Portuguese`,native:`Português`,script:`latin`,timing:`multilingual`},{code:`nl`,name:`Dutch`,native:`Nederlands`,script:`latin`,timing:`multilingual`},{code:`ca`,name:`Catalan`,native:`Català`,script:`latin`,timing:`multilingual`},{code:`pl`,name:`Polish`,native:`Polski`,script:`latin`,timing:`multilingual`},{code:`cs`,name:`Czech`,native:`Čeština`,script:`latin`,timing:`multilingual`},{code:`ro`,name:`Romanian`,native:`Română`,script:`latin`,timing:`sentences`},{code:`sv`,name:`Swedish`,native:`Svenska`,script:`latin`,timing:`sentences`},{code:`da`,name:`Danish`,native:`Dansk`,script:`latin`,timing:`sentences`},{code:`nb`,name:`Norwegian`,native:`Norsk bokmål`,script:`latin`,timing:`sentences`},{code:`fi`,name:`Finnish`,native:`Suomi`,script:`latin`,timing:`sentences`},{code:`hu`,name:`Hungarian`,native:`Magyar`,script:`latin`,timing:`sentences`},{code:`tr`,name:`Turkish`,native:`Türkçe`,script:`latin`,timing:`sentences`},{code:`id`,name:`Indonesian`,native:`Bahasa Indonesia`,script:`latin`,timing:`sentences`},{code:`vi`,name:`Vietnamese`,native:`Tiếng Việt`,script:`latin`,timing:`sentences`},{code:`el`,name:`Greek`,native:`Ελληνικά`,script:`greek`,timing:`sentences`},{code:`ru`,name:`Russian`,native:`Русский`,script:`cyrillic`,timing:`sentences`},{code:`uk`,name:`Ukrainian`,native:`Українська`,script:`cyrillic`,timing:`sentences`},{code:`ar`,name:`Arabic`,native:`العربية`,script:`arabic`,timing:`sentences`},{code:`he`,name:`Hebrew`,native:`עברית`,script:`hebrew`,timing:`sentences`},{code:`hi`,name:`Hindi`,native:`हिन्दी`,script:`devanagari`,timing:`sentences`},{code:`th`,name:`Thai`,native:`ไทย`,script:`thai`,timing:`sentences`},{code:`ja`,name:`Japanese`,native:`日本語`,script:`cjk`,timing:`sentences`},{code:`zh`,name:`Chinese`,native:`中文`,script:`cjk`,timing:`sentences`},{code:`ko`,name:`Korean`,native:`한국어`,script:`hangul`,timing:`sentences`}],BO=J(zO.map(e=>e.code));function VO(e){return zO.find(t=>t.code===(e??`en`))??zO[0]}function HO(e){let t=VO(e);if(t.timing===`sentences`)return`Word timing isn't available for ${t.name} yet, so captions are timed sentence by sentence: each sentence is shown for the part of the narration that reads it. Word-by-word captions and cuts that follow the narration need word timing and are off.`}var UO=[`off`,`low`,`medium`,`high`,`xhigh`,`max`,`ultra`],WO=60/240,GO=1e5,KO=1500;function qO(e){return e.imageScale===void 0?60:240}function JO(e){return e.split(/\s+/).filter(e=>e!==``).length}function YO(e){return e/150}function XO(e){return Math.round(60/e*1e4)/1e4}function ZO(e){let t=60/e.perHour,n=Math.round(t*4);return Math.abs(t*4-n)<.001?{every:`minutes`,value:String(n/4)}:{every:`hour`,value:String(e.perHour)}}function QO(e){let t=YO(e.words)*e.perHour/60;return Math.min(Math.max(Math.ceil(t-1e-9),0),240)}function $O(e){return e.imageScale!==void 0&&e.sources.images===`generate`}function ek(e){let t=e.imagePrompts.map(e=>e.number);if(!$O(e)||t.length===0)return t;let n=t.reduce((e,t)=>e+t,0),r=QO(e.imageScale)-n;for(let e=0;e<r;e+=1){let n=e%t.length;t[n]=(t[n]??0)+1}return t}function tk(e){if(!Number.isFinite(e.perHour)||e.perHour<1||e.perHour>240)return`Enter between 1 and 240 images per hour (one every ${String(WO)} to 60 minutes) under Images → More images for long videos.`;if(!Number.isInteger(e.words)||e.words<1||e.words>1e5)return`Enter the expected words (Review) as a whole number between 1 and ${String(GO)}; the image count for long videos is planned from it.`}var nk={enabled:!0,videoLufs:-14,audioFilesLufs:-18},rk=-1.5,ik=.5;function ak(e){return e===`video`?-14:-18}function ok(e){return e===`video`?rk:-3}function sk(e,t){return _k(e-ak(t),2)}function ck(e,t){return _k(ak(t)+e,2)}function lk(e){return Math.round(10**(e/20)*100)}function uk(e){return _k(20*Math.log10(e/100),2)}function dk(e){if(!Number.isFinite(e))return;let t=Math.round(e/ik)*ik;return Math.min(4,Math.max(-10,t))}function fk(e,t){let n=e-ak(t);return Number.isFinite(n)&&Number.isInteger(_k(n/.5,6))&&n>=-10.000000001&&n<=4.000000001?void 0:`The volume must be between -10 dB and +4 dB of the recommended level, in steps of ${String(ik)} dB. Change it under Level the volume (Play → Video and style, Edit project → Pauses and volume, or Settings → General).`}function pk(e){if(e===void 0)return[];let t=[],n=fk(e.videoLufs,`video`);n!==void 0&&t.push({field:`loudness.videoLufs`,message:n});let r=fk(e.audioFilesLufs,`audioFiles`);return r!==void 0&&t.push({field:`loudness.audioFilesLufs`,message:r}),t}function mk(e,t){if(e?.enabled??t.enabled)return{videoLufs:e?.videoLufs??t.videoLufs,audioFilesLufs:e?.audioFilesLufs??t.audioFilesLufs}}function hk(e){let t=`${String(e.pieces)} ${e.pieces===1?`piece`:`pieces`}`,n=e.skipped===0?``:` (${String(e.skipped)} too short or quiet to measure, left as they were)`;return`Levelled ${t} to ${vk(e.target)} LUFS${n}: the spread was ${vk(e.spreadBefore)} LU, now ${vk(e.spreadAfter)} LU.`}function gk(e){return`Mastered to ${vk(e.target)} LUFS: measured ${vk(e.integrated)} LUFS, peaks ${vk(e.truePeak)} dBTP`}function _k(e,t){let n=10**t;return Math.round(e*n)/n}function vk(e){return String(_k(e,1)).replace(`-`,`−`)}var yk=.4,bk=.05;function xk(e,t){let n=e/bk;return Number.isFinite(e)&&e>=0&&e<=2&&Math.abs(n-Math.round(n))<1e-6?void 0:`The pause between ${t} must be between 0 and 2 seconds, in steps of ${String(bk)}. Change it under Play → Video and style, or Edit project → Pauses and volume.`}function Sk(e){let t=[];if(e.sentencePauseSeconds!==void 0){let n=xk(e.sentencePauseSeconds,`sentences`);n!==void 0&&t.push({field:`sentencePauseSeconds`,message:n})}if(e.paragraphPauseSeconds!==void 0){let n=xk(e.paragraphPauseSeconds,`paragraphs`);n!==void 0&&t.push({field:`paragraphPauseSeconds`,message:n})}return t}function Ck(e){let t=(e,t)=>e===void 0||e.trim()===``?t:Number(e.trim().replace(`,`,`.`)),n=t(e.sentencePause,yk),r=t(e.paragraphPause,0);return{...n===0?{}:{sentencePauseSeconds:n},...r===0?{}:{paragraphPauseSeconds:r}}}var wk=[`article`,`images`,`narration`,`thumbnail`,`shorts`],Tk=[`off`,`flag`,`redo`],Ek={article:`Article`,images:`Images`,narration:`Narration`,thumbnail:`Thumbnail`,shorts:`Shorts`},Dk={off:`Off`,flag:`Flag only`,redo:`Flag and redo`},Ok=[`images`,`thumbnail`,`shorts`],kk=[`claude-code`,`codex`];function Ak(e,t){return e?.stages[t]?.mode??`off`}function jk(e){return`review.${e}`}function Mk(e){return{provider:e.provider,model:e.model,...e.thinking===void 0?{}:{thinking:e.thinking},retries:e.retries===void 0?``:String(e.retries),stages:Object.fromEntries(wk.flatMap(t=>{let n=e.stages[t];return n===void 0?[]:[[t,{mode:n.mode,prompt:n.prompt??``}]]}))}}function Nk(e,t){let n=Object.fromEntries(wk.flatMap(n=>{let r=e.stages[n];return r===void 0||r.mode===`off`||!t(n)?[]:[[n,{mode:r.mode,...r.prompt.trim()?{prompt:r.prompt}:{}}]]}));if(Object.keys(n).length===0)return{settings:void 0};let r=e.retries.trim()===``?void 0:Number(e.retries),i=r===void 0||Number.isFinite(r);return{settings:{provider:e.provider,model:e.model,...e.thinking===void 0?{}:{thinking:e.thinking},...r===void 0||!i?{}:{retries:r},stages:n},...i?{}:{retriesProblem:`Enter a number of redos between 0 and 5 in the Reviews section.`}}}function Pk(e,t){let{sources:n}=e;switch(t){case`article`:return n.article===`generate`;case`images`:return n.images===`generate`;case`narration`:return n.audio===`generate`;case`thumbnail`:return n.thumbnail===`from_prompt`||n.thumbnail===`prompt_by_llm`;case`shorts`:return e.shorts?.enabled===!0&&n.audio!==`off`}}function Fk(e){return wk.filter(t=>Ak(e.reviews,t)!==`off`&&Pk(e,t))}function Ik(e){return kk.includes(e)}function Lk(e){let t=Fk(e),n=e.reviews;if(t.length===0||n===void 0)return[];let r=[];(n.provider.trim()===``||n.model.trim()===``)&&r.push({field:`reviews.provider`,message:`Automatic reviews need a reviewer model. Choose one in the Reviews section, or set every review to Off.`});let i=n.retries;i!==void 0&&(!Number.isInteger(i)||i<0||i>5)&&r.push({field:`reviews.retries`,message:`Enter a number of redos between 0 and 5 in the Reviews section.`});let a=t.filter(e=>Ok.includes(e));return a.length>0&&n.provider.trim()!==``&&!Ik(n.provider)&&r.push({field:`reviews.provider`,message:`The ${a.map(e=>Ek[e]).join(`, `)} ${a.length===1?`review looks`:`reviews look`} at pictures, and Slopify can't show pictures to this reviewer. In the Reviews section, choose Claude Code or Codex as the reviewer, or set ${a.length===1?`that review`:`those reviews`} to Off.`}),r}var Rk={enabled:!1,count:3,minSeconds:60,maxSeconds:120,titleOnScreen:!0},zk=1.25,Bk=.05,Vk=2e3,Hk=`[PASTE THE FULL VIDEO LINK HERE]`;function Uk(e){let t=e?.trim()??``;return`Watch the full video: ${t===``?Hk:t}`}function Wk(e,t){return[e.title,``,`${e.description}\n${Uk(t)}`,``,e.hashtags.join(` `)].join(`
|
|
102
102
|
`)}var Gk=`Built-in`,Kk=[`Pick the moments of this video that work best as vertical shorts on YouTube Shorts, TikTok and Reels.`,``,`- Each short must make sense on its own, to a viewer who has not seen the rest of the video: no references to earlier parts, no setup that pays off outside the clip.`,`- Open on a hook: the first sentence should make someone stop scrolling (a surprising fact, a question, a bold claim). Skip clips that start with filler or a transition.`,`- End on a complete thought, not mid-argument.`,`- Prefer the most surprising, useful or emotional moments over summaries, and don't pick two shorts that say the same thing.`,`- Title: at most 60 characters, plain words, no clickbait and no hashtags.`,`- Description: one line that says what the viewer learns or feels.`,`- Hashtags: 3-5, about the subject of that clip, most specific last.`].join(`
|
|
103
103
|
`);[`Vertical 9:16 images for a short video. Each image illustrates what is being said at that moment of the clip.`,`Cinematic, high-contrast and uncluttered, with the subject large and centred so it reads on a phone screen.`,`Leave the lower half calm: captions are drawn over the middle of the frame.`,`No text, letters, logos or watermarks in the image.`].join(`
|
|
104
|
-
`);function qk(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?1:Math.max(1,Math.ceil(e/t-.001))}function Jk(e){let t=e=>e===void 0||e.trim()===``?void 0:Number(e),n=t(e.musicVolume),r=t(e.speed),i=e.fullVideoLink?.trim()??``;return{...e.titleOnScreen===void 0?{}:{titleOnScreen:e.titleOnScreen},...i===``?{}:{fullVideoLink:i},...n===void 0?{}:{musicVolume:n},...r===void 0?{}:{speed:r}}}function Yk(e){return{...e?.titleOnScreen===void 0?{}:{titleOnScreen:e.titleOnScreen},...e?.fullVideoLink===void 0?{}:{fullVideoLink:e.fullVideoLink},...e?.musicVolume===void 0?{}:{musicVolume:String(e.musicVolume)},...e?.speed===void 0?{}:{speed:e.speed.toFixed(2)}}}function Xk(e){let t=[],n=(e,t,n)=>Number.isInteger(e)&&e>=t&&e<=n;n(e.count,1,10)||t.push({field:`count`,message:`Enter a whole number of shorts between 1 and 10.`});for(let r of[`minSeconds`,`maxSeconds`])n(e[r],15,180)||t.push({field:r,message:`Enter a whole number of seconds between 15 and 180.`});if(t.every(e=>e.field===`count`)&&e.minSeconds>e.maxSeconds)for(let e of[`minSeconds`,`maxSeconds`])t.push({field:e,message:`The longest a short may be must be at least the shortest. Raise the maximum or lower the minimum.`});let r=e.speed;r!==void 0&&(!Number.isFinite(r)||r<.999999999||r>1.250000001||Math.abs((r-1)/.05-Math.round((r-1)/.05))>1e-6)&&t.push({field:`speed`,message:`Choose a speed between 1.00× and 1.25×, in steps of 0.05.`}),e.musicVolume!==void 0&&!n(e.musicVolume,0,100)&&t.push({field:`musicVolume`,message:`Enter the music volume as a whole number of percent between 0 and 100.`});let i=e.fullVideoLink?.trim()??``;return i!==``&&!Zk(i)&&t.push({field:`fullVideoLink`,message:`The full video link must be a whole web address starting with https:// or http://, like https://youtu.be/abc123. Paste it again, or leave the box empty.`}),t}function Zk(e){if(e.length>2e3||/\s/.test(e))return!1;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&t.hostname!==``}catch{return!1}}var Qk=[`rain`,`fire`,`wind`],$k=[...Qk,`upload`],eA={rain:`Rain`,fire:`Fireplace`,wind:`Wind`,upload:`My own file`},tA={levelDb:-18,fadeInSeconds:3,tailSeconds:6};function nA(e){return e.ambientBed!==void 0&&e.mode!==`short`&&e.sources.video===`generate`&&e.sources.audio!==`off`}function rA(e){let t=[];return $k.includes(e.source)||t.push({field:`source`,message:`Choose Rain, Fireplace, Wind or My own file for the ambient sound.`}),Number.isInteger(e.levelDb)&&e.levelDb>=-40&&e.levelDb<=-6||t.push({field:`level`,message:`Enter an ambient sound level between -40 and -6 dB, in whole dB.`}),iA(e.fadeInSeconds,30)||t.push({field:`fadeIn`,message:`Enter a fade-in between 0 and 30 seconds, in steps of 0.5.`}),iA(e.tailSeconds,30)||t.push({field:`tail`,message:`Enter a tail between 0 and 30 seconds, in steps of 0.5.`}),t}function iA(e,t){return Number.isInteger(e*2)&&e>=0&&e<=t}function aA(e){return{source:e.source,level:String(e.levelDb),fadeIn:String(e.fadeInSeconds),tail:String(e.tailSeconds)}}function oA(e){if(e===void 0||e.source===`none`)return;let t=e=>e.trim()===``?NaN:Number(e);return{source:e.source,levelDb:t(e.level),fadeInSeconds:t(e.fadeIn),tailSeconds:t(e.tail)}}var sA=[`interval`,`narration`],cA=[`cut`,`crossfade`,`fadeblack`,`slide`,`wipe`],lA=[`off`,`subtle`,`strong`],uA=[`none`,`warm`,`cold`,`desaturated`,`sepia`],dA=[`none`,`embers`,`dust`,`fog`],fA=[`off`,`chapters`,`every`],pA={cuts:`interval`,transition:`cut`,transitionSeconds:.6,vignette:`off`,grain:`off`,grade:`none`,atmosphere:`none`,chapterCards:!1,animate:`off`,animateEvery:3,animateModel:``},mA={...pA,cuts:`narration`},hA=.2,gA=[.2,.4,.6,.8,1,1.2,1.5,2],_A={interval:`Every N seconds`,narration:`Follow the narration`},vA={cut:`Cut`,crossfade:`Crossfade`,fadeblack:`Fade through black`,slide:`Slide`,wipe:`Wipe`},yA={off:`Off`,subtle:`Subtle`,strong:`Strong`},bA={none:`None`,warm:`Warm fantasy`,cold:`Cold`,desaturated:`Desaturated`,sepia:`Sepia`},xA={none:`None`,embers:`Embers`,dust:`Dust`,fog:`Fog`},SA={off:`Off`,chapters:`Chapter openers`,every:`Every Nth image`};function CA(e){return e.videoEdit??pA}function wA(e){let t=CA(e);return t.animate!==`off`&&e.sources.video===`generate`&&(t.animate===`every`||e.sources.audio!==`off`)}function TA(e){let t=e.videoEdit;if(t===void 0||e.sources.video!==`generate`)return[];let n=[];return t.transition!==`cut`&&!(Number.isFinite(t.transitionSeconds)&&t.transitionSeconds>=.2&&t.transitionSeconds<=2)&&n.push({field:`transitionSeconds`,message:`Choose a transition length between ${String(hA)} and 2 seconds.`}),t.chapterCards&&e.sources.audio===`off`&&n.push({field:`chapterCards`,message:`Chapter cards are placed from the narration. Turn narration on, or turn chapter cards off.`}),t.animate===`chapters`&&e.sources.audio===`off`&&n.push({field:`animate`,message:`Chapter openers are found from the narration. Turn narration on, or choose Every Nth image.`}),t.animate===`every`&&!(Number.isInteger(t.animateEvery)&&t.animateEvery>=2&&t.animateEvery<=10)&&n.push({field:`animateEvery`,message:`Choose every 2nd to every 10th image.`}),t.animate!==`off`&&t.animateModel.trim()===``&&n.push({field:`animateModel`,message:`Choose an image-to-video model to animate images with, or turn Animate images off.`}),n}function EA(e){return[[`Cuts`,_A[e.cuts]],[`Transition`,e.transition===`cut`?vA.cut:`${vA[e.transition]} · ${String(e.transitionSeconds)} s`],[`Vignette`,yA[e.vignette]],[`Film grain`,yA[e.grain]],[`Colour grade`,bA[e.grade]],[`Atmosphere`,xA[e.atmosphere]],[`Chapter cards`,e.chapterCards?`On`:`Off`],[`Animate images`,e.animate===`off`?SA.off:`${e.animate===`every`?`Every ${(e=>e===2?`2nd`:e===3?`3rd`:`${String(e)}th`)(e.animateEvery)} image`:SA.chapters}${e.animateModel.trim()===``?``:` · ${e.animateModel}`}`]]}var DA=[`audiobook`,`podcast`,`drama`,`interview`],OA={audiobook:`Audiobook`,podcast:`Podcast`,drama:`Radio drama`,interview:`Interview`},kA=[`narrator`,`host`,`guest`,`character`],AA=[`script`,`attribute`],jA=[.8,.9,1,1.1,1.2],MA=[0,.2,.35,.5,.8,1.2],NA=.35,PA=q({provider:W(),model:W(),voice:W()}),FA=q({id:W().min(1).max(60).regex(/^[a-z0-9-]+$/),name:W().max(40),role:J(kA),voice:PA,pace:G().optional(),pronunciations:W().max(2e4).optional(),castId:W().max(200).optional(),portrait:W().regex(/^[0-9a-f]{64}$/).optional()}),IA=9999,LA=q({title:W().max(200),chapter:G()}).strict().readonly();function RA(e){return`${e.title.trim()} · Chapter ${String(e.chapter)}`}var zA=q({format:J(DA),source:J(AA),speakers:K(FA).max(10),turnGapSeconds:G(),nameTags:KD(),nativeDialogue:KD(),audioFiles:KD(),book:LA.optional()});function BA(e,t=[]){return{format:e,source:`script`,speakers:VA(e,HA(e),t),turnGapSeconds:NA,nameTags:e===`podcast`||e===`interview`,nativeDialogue:!0,audioFiles:!0}}function VA(e,t,n){if(n.length===0||e!==`podcast`&&e!==`interview`)return[...t];let r=n.slice(0,9).map(e=>({...e,role:`host`})),i=e===`podcast`?t.slice(0,Math.max(0,2-r.length)):t.filter(e=>e.role!==`host`);return[...r,...i.filter(e=>!r.some(t=>t.id===e.id))]}function HA(e){let t={provider:``,model:``,voice:``},n=(e,n,r)=>({id:e,name:n,role:r,voice:t});switch(e){case`audiobook`:return[n(`narrator`,`Narrator`,`narrator`)];case`podcast`:return[n(`host-1`,`Alex`,`host`),n(`host-2`,`Sam`,`host`)];case`drama`:return[n(`narrator`,`Narrator`,`narrator`),n(`character-1`,`Mara`,`character`)];case`interview`:return[n(`host-1`,`Host`,`host`),n(`guest-1`,`Guest`,`guest`)]}}function UA(e){return e.voices!==void 0&&e.sources.audio===`generate`}function WA(e){return UA(e)&&e.voices?.source===`script`}function GA(e){let t=[],{speakers:n}=e;n.length===0&&t.push({field:`voices.speakers`,message:`Add at least one speaker under Speakers (Play → Narration, or Edit project → Providers).`}),e.source===`attribute`&&e.format!==`audiobook`&&t.push({field:`voices.source`,message:`Only audiobooks can hand an existing text's dialogue to speakers. Choose Write a script under Speakers (Play → Narration, or Edit project → Providers).`}),(e.format===`podcast`||e.format===`interview`)&&n.length<2&&t.push({field:`voices.speakers`,message:`A ${OA[e.format].toLowerCase()} needs at least two speakers. Add one under Speakers (Play → Narration, or Edit project → Providers).`}),(e.format===`audiobook`||e.format===`drama`)&&!n.some(e=>e.role===`narrator`)&&t.push({field:`voices.speakers`,message:`An ${e.format===`drama`?`radio drama`:`audiobook`} needs a narrator. Set one speaker's role to Narrator under Speakers (Play → Narration, or Edit project → Providers).`});let r=new Set,i=new Set;for(let[e,a]of n.entries()){let n=`voices.speakers.${String(e)}`,o=a.name.trim();o===``?t.push({field:`${n}.name`,message:`Enter a name for this speaker.`}):/^[\p{L}\p{N}][\p{L}\p{N} .'-]*$/u.test(o)?r.has(o.toLowerCase())&&t.push({field:`${n}.name`,message:`Two speakers are called "${o}". Give each speaker a different name.`}):t.push({field:`${n}.name`,message:`Use only letters, numbers, spaces, dots, apostrophes and hyphens in a speaker name, starting with a letter or number.`}),r.add(o.toLowerCase()),i.has(a.id)&&t.push({field:`${n}.name`,message:`Two speakers share one id. Remove one of them and add it again.`}),i.add(a.id),a.voice.provider.trim()===``||a.voice.model.trim()===``?t.push({field:`${n}.voice`,message:`Choose a voice provider and model for ${o||`this speaker`}.`}):a.voice.voice.trim()===``&&t.push({field:`${n}.voice.voice`,message:`Choose a voice for ${o||`this speaker`}.`}),a.pace!==void 0&&!jA.includes(a.pace)&&t.push({field:`${n}.pace`,message:`Pick a pace from the list for ${o||`this speaker`}.`})}return e.book!==void 0&&(e.book.title.trim()===``&&t.push({field:`voices.book.title`,message:`Enter the book's title under Speakers (Play → Narration), or remove the book to make a project on its own.`}),(!Number.isInteger(e.book.chapter)||e.book.chapter<1||e.book.chapter>9999)&&t.push({field:`voices.book.chapter`,message:`Enter a chapter number from 1 to ${String(IA)} under Speakers (Play → Narration).`})),MA.includes(e.turnGapSeconds)||t.push({field:`voices.turnGapSeconds`,message:`Pick a gap between turns from the list under Speakers (Play → Narration, or Edit project → Providers).`}),t}function KA(e){return e.mode===`short`}function qA(e){if(!KA(e))return[];let t=[];e.format!==`9:16`&&t.push({field:`format`,message:`A short is vertical. Choose the 9:16 format, or make a long video instead.`}),KS(e.sources,`video`)!==`generate`&&t.push({field:`sources.video`,message:`A short is a video. Set Video to Generate.`}),KS(e.sources,`audio`)===`off`&&t.push({field:`sources.audio`,message:`A short's length and captions come from its narration. Set Narration to Generate or Provide.`}),KS(e.sources,`images`)===`off`&&t.push({field:`sources.images`,message:`A short shows images behind its captions. Set Images to Generate or Provide.`});for(let n of[`thumbnail`,`document`])KS(e.sources,n)!==`off`&&t.push({field:`sources.${n}`,message:`A short has no ${n===`thumbnail`?`thumbnail`:`PDF`}. Set ${n===`thumbnail`?`Thumbnail`:`Document`} to Off.`});return e.shorts?.enabled===!0&&t.push({field:`shorts.enabled`,message:`A short isn't cut into more shorts. Turn Shorts off.`}),t}var JA=22.5,YA=`zoom`,XA={zoom:`Zoom in and out`,pan:`Pan across`,mixed:`Mix of both`,still:`Still`};function ZA(e){return Number.isInteger(e)&&e>=1&&e<=600?void 0:`Enter a whole number of seconds between 1 and 600.`}function QA(e){return Number.isInteger(e*2)&&e>=0&&e<=50?void 0:`Enter a zoom between 0 and 50 percent, in steps of 0.5.`}function $A(e){return Number.isInteger(e*2)&&e>=0&&e<=30?void 0:`Enter a number of seconds between 0 and 30, in steps of 0.5.`}var ej={research:[`off`,`generate`,`provide`],article:[`off`,`generate`,`provide`],audio:[`off`,`generate`,`provide`],images:[`off`,`generate`,`provide`],thumbnail:[`off`,`from_prompt`,`prompt_by_llm`,`provide`],video:[`off`,`generate`],document:[`off`,`generate`]};function tj(e){let t=[],n=nj(e.draft),{sources:r}=n;n.title===``?t.push({field:`title`,message:`Enter a title for this video.`}):n.title.length>200&&t.push({field:`title`,message:`Keep the title to 200 characters or fewer.`});for(let e of US)ej[e].includes(KS(r,e))||t.push({field:`sources.${e}`,message:`"${KS(r,e)}" is not an option for ${e}. Reload the page and choose again.`});uj(n)&&!Sj(n.llm)&&t.push({field:`llm`,message:`Choose a text (LLM) provider and model.`}),r.article===`generate`&&cj(n.articlePrompt)&&t.push({field:`articlePrompt`,message:`Pick an article prompt.`});let i=n.audio;t.push(...fj(n)),t.push(...pj(n)),r.audio===`generate`&&(i===void 0||!Sj(i)?t.push({field:`audio`,message:`Choose a narration provider and model.`}):i.voice.trim()===``&&t.push({field:`audio.voice`,message:`Choose a voice for the narration.`})),r.images===`generate`&&rj(n,t),(r.images===`generate`||r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`||vj(n)||wA(n))&&!Sj(n.images)&&t.push({field:`images`,message:`Choose an image provider and model.`}),(r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`)&&cj(n.thumbnailPrompt)&&t.push({field:`thumbnailPrompt`,message:`Pick a thumbnail prompt.`}),r.audio===`off`&&n.subtitles!==void 0&&n.subtitles.mode!==`off`&&t.push({field:`subtitles.mode`,message:`Subtitles need narration. Turn narration on, or turn subtitles off.`}),t.push(...hj(n)),t.push(...yj(n)),t.push(...qA(n)),t.push(...bj(n)),t.push(...xj(n,e.staged)),t.push(...pk(n.loudness)),t.push(...Sk(n)),t.push(..._j(n)),t.push(...Lk(n)),gj(n)&&n.reference?.source===`provide`&&oj(e.staged,n.provided.reference,`images`,`provided.reference`,`Upload the establishing image, or set Establishing image to Off in the Images section.`,t),ij(n,e.staged,t),sj(n,e.requiredSlots,t),(!Number.isFinite(n.silenceGapSeconds)||n.silenceGapSeconds<0||n.silenceGapSeconds>30)&&t.push({field:`silenceGapSeconds`,message:`Enter a silence gap between 0 and 30 seconds.`});let a=r.video===`generate`?ZA(n.imageSeconds):void 0;a!==void 0&&t.push({field:`imageSeconds`,message:a});let o=r.video===`generate`?QA(n.zoomPercent):void 0;o!==void 0&&t.push({field:`zoomPercent`,message:o});let s=r.audio===`off`?void 0:$A(n.edgeSilenceSeconds);return s!==void 0&&t.push({field:`edgeSilenceSeconds`,message:s}),t.length===0?{ok:!0,draft:n}:{ok:!1,fields:t}}function nj(e){let t={...e.sources};t.article!==`generate`&&(t.research=`off`),t.images===`off`&&t.video===`generate`&&(t.video=`off`);let n=Object.create(null);for(let[t,r]of Object.entries(e.values))n[t]=r.trim();return{...e,title:e.title.trim(),subtitles:t.video===`off`&&e.subtitles?.mode===`burn-in`?{...e.subtitles,mode:`files`}:e.subtitles,sources:t,values:n,intro:t.audio===`generate`?e.intro:void 0,outro:t.audio===`generate`?e.outro:void 0}}function rj(e,t){if(e.imagePrompts.length===0){t.push({field:`imagePrompts`,message:`Tick at least one image prompt, or turn images off.`});return}let n=0;for(let[r,i]of e.imagePrompts.entries())n+=i.number,cj(i.name)&&t.push({field:`imagePrompts.${r}.name`,message:`Pick an image prompt.`}),(!Number.isInteger(i.number)||i.number<1||i.number>20)&&t.push({field:`imagePrompts.${r}.number`,message:`Enter a whole number between 1 and 20.`});n>60&&t.push({field:`imagePrompts`,message:`A video can have at most 60 images; these prompts ask for ${n}. Lower the numbers.`});let r=e.imageScale===void 0?void 0:tk(e.imageScale);r!==void 0&&t.push({field:`imageScale`,message:r})}function ij(e,t,n){let{sources:r,provided:i}=e;if(r.research===`provide`&&cj(i.research)&&n.push({field:`provided.research`,message:`Paste the research notes.`}),r.article===`provide`&&cj(i.article)&&n.push({field:`provided.article`,message:`Paste the article.`}),n.push(...wj(e)),r.audio===`provide`&&oj(t,i.audio,`audio`,`provided.audio`,`Pick an audio file.`,n),r.thumbnail===`provide`&&oj(t,i.thumbnail,`thumbnail`,`provided.thumbnail`,`Pick a thumbnail image.`,n),r.images===`provide`){let e=i.images??[];e.length===0?n.push({field:`provided.images`,message:`Pick at least one image.`}):e.length>60&&n.push({field:`provided.images`,message:`A video can have at most 60 images. Remove some.`}),new Set(e).size!==e.length&&n.push({field:`provided.images`,message:`The same image is picked twice. Remove the duplicate.`});for(let[r,i]of e.entries())oj(t,i,`images`,`provided.images.${r}`,`Pick an image.`,n)}aj(e,t,n)}function aj(e,t,n){let r=e.provided.shortsMusic;if(e.shorts?.enabled!==!0||r===void 0)return;let i=`under Outputs → More shorts options → Background music`,a=t.find(e=>e.id===r);a===void 0||a.stageKind!==`audio`?n.push({field:`shorts.music`,message:`The shorts' background music file is no longer available, so it can't be added to the project. Choose the file again ${i}, or remove it.`}):a.state!==`staged`&&n.push({field:`shorts.music`,message:`The shorts' background music is still uploading, so the run can't start yet. Wait for it to finish, or remove it ${i}.`})}function oj(e,t,n,r,i,a){if(t===void 0||t===``){a.push({field:r,message:i});return}let o=e.find(e=>e.id===t);if(o===void 0||o.stageKind!==n){a.push({field:r,message:`That upload is no longer available. Choose the file again.`});return}o.state!==`staged`&&a.push({field:r,message:`This file is still uploading. Wait for it to finish.`})}function sj(e,t,n){for(let r of t){let t=Object.hasOwn(e.values,r)?e.values[r]:void 0;if(t===void 0||t===``){n.push({field:`values.${r}`,message:`Fill in this field.`});continue}t.length>200&&n.push({field:`values.${r}`,message:`Keep this to 200 characters or fewer.`}),/[\n\r]/.test(t)&&n.push({field:`values.${r}`,message:`Keep this to a single line, without line breaks.`})}}function cj(e){return e===void 0||e.trim()===``}function lj(e){let t=e.sources,n=[];return t.research===`generate`&&n.push({section:`article`,label:`researching the topic`}),t.article===`generate`&&n.push({section:`article`,label:`writing the article`}),UA(e)&&e.voices?.source===`attribute`&&n.push({section:`narration`,label:`working out who speaks each line`}),dj(e)&&n.push({section:`narration`,label:`preparing the narration's delivery`}),e.intro?.mode===`llm`&&n.push({section:`narration`,label:`writing the intro`}),e.outro?.mode===`llm`&&n.push({section:`narration`,label:`writing the outro`}),t.thumbnail===`prompt_by_llm`&&n.push({section:`outputs`,label:`writing the thumbnail prompt`}),mj(e)&&n.push({section:`outputs`,label:`writing the YouTube description`}),vj(e)&&n.push({section:`outputs`,label:`picking the shorts`}),n}function uj(e){return lj(e).length>0}function dj(e){return e.sources.audio===`generate`&&!cj(e.narrationPrompt)}function fj(e){return dj(e)&&(e.audio?.provider!==`inworld`||e.audio.model!==`inworld-tts-2`)?[{field:`narrationPrompt`,message:`Narration preparation only works with the Inworld TTS-2 model. Choose that model under Narration, or turn preparation Off.`}]:[]}function pj(e){if(e.voices===void 0||!UA(e))return[];let t=[...GA(e.voices)];return!cj(e.narrationPrompt)&&!e.voices.speakers.some(e=>e.voice.provider===`inworld`&&e.voice.model===`inworld-tts-2`)&&t.push({field:`narrationPrompt`,message:`Narration preparation adds delivery cues only to speakers on Inworld's TTS-2 model, and no speaker uses it. Choose that model for a speaker under Speakers, or clear Narration Preparation under Narration → Audio Advanced.`}),t}function mj(e){return e.youtubeDescription===!0&&e.sources.audio!==`off`}function hj(e){return e.youtubeDescription===!0&&e.sources.audio===`off`?[{field:`youtubeDescription`,message:`The YouTube description is timed from the narration. Turn narration on, or turn the YouTube description off.`}]:[]}function gj(e){return e.reference!==void 0&&e.sources.images===`generate`}function _j(e){return gj(e)&&e.reference?.source===`prompt`&&(e.reference.prompt===void 0||e.reference.prompt.trim()===``)?[{field:`reference.prompt`,message:`Pick an image prompt for the establishing image, upload one instead, or set Establishing image to Off in the Images section.`}]:[]}function vj(e){return e.shorts?.enabled===!0&&e.sources.audio!==`off`}function yj(e){let t=e.shorts;if(t?.enabled!==!0)return[];if(e.sources.audio===`off`)return[{field:`shorts.enabled`,message:`Shorts are cut from the narration. Turn narration on, or turn Shorts off.`}];let n=Xk(t).map(e=>({field:`shorts.${e.field}`,message:e.message})),r=e.sources.video===`generate`?void 0:ZA(e.imageSeconds);return r!==void 0&&n.push({field:`imageSeconds`,message:r}),n}function bj(e){return TA(e).map(e=>({field:`videoEdit.${e.field}`,message:e.message}))}function xj(e,t){let n=e.ambientBed;if(n===void 0||!nA(e))return[];let r=`under Video and style → Ambient sound`,i=rA(n).map(e=>({field:`ambientBed.${e.field}`,message:`${e.message} Change it ${r}.`}));if(n.source!==`upload`)return i;let a=e.provided.ambientBed,o=a===void 0?void 0:t.find(e=>e.id===a);return o===void 0||o.stageKind!==`audio`?i.push({field:`ambientBed.file`,message:`The ambient sound's audio file is missing, so it can't be added to the project. Choose the file ${r}, or pick Rain, Fireplace or Wind instead.`}):o.state!==`staged`&&i.push({field:`ambientBed.file`,message:`The ambient sound's audio file is still uploading, so the run can't start yet. Wait for it to finish ${r}.`}),i}function Sj(e){return e!==void 0&&e.provider.trim()!==``&&e.model.trim()!==``}function Cj(e){return e.sources.audio===`generate`&&e.audio?.usePronunciationGlossary===!0&&e.audio.provider===`inworld`&&(e.audio.model===`inworld-tts-2`||e.audio.model===`inworld-tts-2-flash`)}function wj(e){let{sources:t}=e;if(t.article!==`off`)return[];let n=`Set Article to Generate or Provide`;return[...t.audio===`generate`?[{field:`sources.audio`,message:`Narration reads the article, and Article is Off. ${n}, or set Narration to Off or Provide.`}]:[],...t.document===`generate`?[{field:`sources.document`,message:`The PDF is made from the article, and Article is Off. ${n}, or set PDF to Off.`}]:[],...t.thumbnail===`prompt_by_llm`?[{field:`sources.thumbnail`,message:`The AI writes the thumbnail prompt from the article, and Article is Off. ${n}, or pick From prompt for the thumbnail.`}]:[],...t.audio!==`off`&&e.subtitles!==void 0&&e.subtitles.mode!==`off`?[{field:`subtitles.mode`,message:`Captions are matched to the article's words, and Article is Off. ${n}, or turn captions off.`}]:[],...mj(e)?[{field:`youtubeDescription`,message:`The YouTube description is written from the narration's words, which come from the article, and Article is Off. ${n}, or turn the YouTube description off.`}]:[],...vj(e)?[{field:`shorts.enabled`,message:`Shorts are picked from the narration's words, which come from the article, and Article is Off. ${n}, or turn Shorts off.`}]:[],...t.images===`generate`&&e.imageScenes===!0?[{field:`imageScenes`,message:`Scenes from the article need the article, and Article is Off. ${n}, or turn Scenes from the article off.`}]:[]]}var Tj=[`auto`,`yes`,`no`],Ej={auto:`Automatic`,yes:`Always Yes`,no:`Always No`},Dj={levelDb:G(),fadeInSeconds:G(),tailSeconds:G()},Oj=q({source:J($k),...Dj}).strict(),kj=q({source:J(Qk),...Dj}).strict(),Aj=`Previous video`,jj=2e3,Mj=/\{\{([^{}\n]{1,80})\}\}/gu;function Nj(e){return e.trim().replace(/\s+/gu,` `).toLowerCase()}function Pj(e,t){let n=new Set,r=[];for(let i of[...t,...e]){let e=Nj(i.name);n.has(e)||i.url.trim()===``||(n.add(e),r.push(i))}return r}function Fj(e,t){let n=new Map(t.map(e=>[Nj(e.name),e.url])),r=[],i=0;for(let t of e.matchAll(Mj)){let a=t.index;a>i&&r.push({kind:`text`,text:e.slice(i,a)});let o=(t[1]??``).trim();r.push({kind:`placeholder`,raw:t[0],name:o,url:n.get(Nj(o))}),i=a+t[0].length}return i<e.length&&r.push({kind:`text`,text:e.slice(i)}),r}function Ij(e,t){let n=[];return{text:Fj(e,t).map(e=>e.kind===`text`?e.text:e.url===void 0?(n.some(t=>Nj(t)===Nj(e.name))||n.push(e.name),e.raw):e.url).join(``),unknown:n}}function Lj(e){if(e.length>50)return`Keep at most 50 links. Remove some.`;let t=new Set;for(let[n,r]of e.entries()){let e=`Link ${String(n+1)}`,i=r.name.trim();if(i===``)return`${e} has no name. Give it one, such as Patreon.`;if(i.length>60)return`${e}'s name is over 60 characters. Shorten it.`;if(/[{}]/u.test(i))return`${e}'s name contains { or }. Use the name alone; the description writes it as {{${i.replace(/[{}]/gu,``)}}}.`;if(t.has(Nj(i)))return`Two links are named "${i}". Rename one, since {{${i}}} can only fill with one.`;t.add(Nj(i));let a=r.url.trim();if(a.length>2e3)return`The "${i}" link is over ${String(jj)} characters. Use a shorter address.`;if(a===``)return`The "${i}" link has no address. Paste it, starting with https://.`;if(!Rj(a))return`The "${i}" link is not a web address. Paste the full address, starting with https://.`}}function Rj(e){try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`}catch{return!1}}var zj=TD(),Bj=W().regex(/^#[0-9a-fA-F]{6}$/,`Use a colour like #FFD700.`).transform(e=>e.toUpperCase()),Vj=e=>W().trim().max(e).optional(),Hj=W().max(160).regex(/^[A-Za-z0-9_-]+$/,`Choose a font from the list.`).optional(),Uj=q({captionFontId:Hj,captionColor:Bj.optional(),captionOutlineColor:Bj.optional(),titleFontId:Hj,titleColor:Bj.optional(),intro:Vj(200),outro:Vj(200),endScreenText:Vj(200),documentTheme:Vj(200),ambientBed:kj.superRefine((e,t)=>{for(let n of rA(e))t.addIssue({code:`custom`,path:[n.field],message:`${n.message} Change it under Brand kit → Ambient sound on the channel page.`})}).optional(),language:BO.optional(),links:K(q({name:W().max(240),url:W().max(jj*2)}).strict()).max(100).transform(e=>e.map(e=>({name:e.name.trim(),url:e.url.trim()}))).superRefine((e,t)=>{let n=Lj(e);n!==void 0&&t.addIssue({code:`custom`,message:`The channel's links weren't saved: ${n} Then press Save channel on the channel's Brand tab.`})}).optional()}).strict().transform(e=>Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0&&e!==``))),Wj=W().trim().min(1,`Enter a name.`).max(200,`Keep the name to 200 characters or fewer.`);q({id:zj,name:Wj}).strict().readonly(),q({name:Wj,brand:Uj,seriesBrief:W().max(1e4,`Keep the series brief to 10,000 characters or fewer.`),baseVersion:G().int().positive()}).strict().readonly();var Gj=W().trim().min(1,`Enter a name, and remove empty aliases.`).max(200,`Keep names and aliases to 200 characters or fewer.`),Kj=q({provider:W().trim().min(1,`Choose a voice provider.`).max(100),model:W().trim().min(1,`Choose a voice model.`).max(200),voice:W().trim().min(1,`Choose a voice.`).max(200),pace:G().refine(e=>jA.includes(e),`Pick a pace from the list.`).optional(),pronunciations:W().max(2e4,`Keep the pronunciations to 20,000 characters or fewer.`).optional()}).strict(),qj=q({kind:J($b),name:Gj,aliases:K(Gj).max(20,`Keep to 20 aliases or fewer.`).default([]),description:W().trim().max(2e3,`Keep the description to 2,000 characters or fewer.`).default(``),voice:Kj.nullable().optional(),host:KD().optional()}).strict();qj.extend({id:zj}).strict(),qj.extend({baseVersion:G().int().positive()}).strict(),q({prompt:W().trim().min(1,`Describe the picture to make.`).max(4e3,`Keep the picture's description to 4,000 characters or fewer.`),provider:W().min(1).max(100),model:W().min(1).max(200)}).strict(),q({channelId:zj}).strict(),q({aiDisclosure:J(Tj,`Choose Automatic, Always Yes or Always No.`)}).strict();var Jj=K(q({name:W(),aliases:K(W()).readonly(),description:W(),images:K(W()).readonly()})).readonly(),Yj=W().min(1),Xj=W().regex(/^[a-f0-9]{64}$/),Zj=J([`audio`,`images`,`video`]),Qj=q({projectId:Yj,revisionId:Yj,checkpointId:Yj,stage:Zj,workId:Yj,fingerprint:Xj,state:J([`configured`,`pending-review`,`held`,`released`,`satisfied`,`invalidated`,`canceled`]),createdAt:RO(),approvedAt:RO().nullable()}).strict().readonly();q({projectId:Yj,revisionId:Yj,checkpoints:K(q({checkpointId:Yj,stage:Zj,workId:Yj,fingerprint:Xj,state:J([`configured`,`pending-review`,`held`])}).strict().readonly()).max(3).readonly(),createdAt:RO()}).strict().readonly();var $j=q({projectId:Yj,revisionId:Yj,checkpointId:Yj,fingerprint:Xj,idempotencyKey:TD(),approvedAt:RO()}).strict().readonly(),eM=[`Cinzel`,`Literata`,`times`,`helvetica`,`courier`],tM=[`normal`,`medium`,`bold`,`black`,`italic`,`bolditalic`],nM=(e,t)=>{let n={error:`Use a value from ${String(e)} to ${String(t)}.`};return G({error:`Enter a number.`}).finite(n).min(e,n).max(t,n)},rM=W().regex(/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i,`Use a colour like #8c1e14.`),iM=W().max(300,{error:`Keep this under 300 characters.`}),aM=iM.nullable(),oM=W().max(500,{error:`Keep this under 500 characters.`}).nullable(),sM=q({family:J(eM),style:J(tM),letterSpacing:nM(-.5,2)}).strict(),cM=q({page:q({format:J([`a4`,`letter`]),margin:nM(5,60),contentTop:nM(5,80)}).strict(),background:q({image:J([`parchment`]).nullable(),color:rM}).strict(),colors:q({heading:rM,text:rM,muted:rM,faint:rM}).strict(),fonts:q({body:sM,strong:sM,emphasis:sM,heading:sM,dramatic:sM,decorative:sM,dropCap:sM,footer:sM}).strict(),sizes:q({brand:nM(6,72),title:nM(6,72),section:nM(6,72),heading:nM(6,72),subheading:nM(6,72),body:nM(6,24),footer:nM(5,24),meta:nM(5,24)}).strict(),spacing:q({bodyLine:nM(3,20),headingLine:nM(3,30),subheadingLine:nM(3,30),paragraphGap:nM(0,3),headingGap:nM(0,5),itemGap:nM(0,3),listIndent:nM(0,30),quoteIndent:nM(0,40),ruleWidth:nM(0,150)}).strict(),dropCap:q({enabled:KD(),lines:nO([mO(2),mO(3),mO(4)]),scale:nM(1,5),gap:nM(0,20),minLength:G({error:`Enter a number.`}).int({error:`Use a whole number.`}).min(0,{error:`Use a value from 0 to 2000.`}).max(2e3,{error:`Use a value from 0 to 2000.`}),minRoom:nM(0,1)}).strict(),titlePage:q({brandY:nM(10,200),taglineOffset:nM(0,60),titleY:nM(10,250),titleLine:nM(3,40),metaOffset:nM(0,100),metaLine:nM(3,30),showDate:KD(),showWordCount:KD(),cover:q({enabled:KD(),gap:nM(0,40),maxHeight:nM(20,200)}).strict()}).strict(),contents:q({enabled:KD(),title:iM,depth:nO([mO(1),mO(2),mO(3)]),titleOffset:nM(0,100),firstEntryOffset:nM(0,150),line:nM(3,30),indent:nM(0,30)}).strict(),header:q({enabled:KD(),top:nM(3,60),maxTitleCharacters:G({error:`Enter a number.`}).int({error:`Use a whole number.`}).min(5,{error:`Use a value from 5 to 200.`}).max(200,{error:`Use a value from 5 to 200.`})}).strict(),footer:q({enabled:KD(),bottom:nM(3,60),reserve:nM(0,60),text:iM}).strict(),brand:q({name:aM,url:oM,tagline:aM,linkLabel:aM}).strict(),metadata:q({author:iM,subject:iM,keywords:W().max(1e3),creator:iM}).strict(),sources:q({enabled:KD(),title:iM,titleOffset:nM(0,100),bodyOffset:nM(0,150),line:nM(3,30),gap:nM(0,20)}).strict(),endPage:q({enabled:KD(),title:iM,titleOffset:nM(0,100),bodyOffset:nM(0,150),lines:K(iM).max(60).readonly(),showDocumentDetails:KD(),link:q({text:iM,url:oM}).strict().nullable(),closing:aM}).strict()}).strict(),lM=q({id:W().min(1).max(64),name:W().min(1).max(80),values:cM}).strict(),uM=q({theme:J(eC),custom:lM.optional()}).strict(),dM=K(q({written:W().trim().min(1).max(200),spoken:W().trim().min(1).max(500),wholeWord:KD(),caseSensitive:KD()}).strict().readonly()).max(1e3).readonly(),fM=[`whole`,`paragraph`,`words`,`characters`],pM=[`off`,`files`,`burn-in`],mM=[`top`,`upper-middle`,`center`,`lower-middle`,`bottom`],hM=q({mode:J(pM),language:mO(`en`).default(`en`),fontId:W().max(160).regex(/^[A-Za-z0-9_-]+$/).default(`default`),position:J(mM).default(`bottom`),fontSize:G().int().min(16).max(120).default(48),color:W().regex(/^#[0-9A-Fa-f]{6}$/).optional(),outlineColor:W().regex(/^#[0-9A-Fa-f]{6}$/).optional()}),gM={mode:`off`,language:`en`,fontId:`default`,fontSize:48,position:`bottom`},_M=W().regex(/^#[0-9A-Fa-f]{6}$/),vM=q({provider:W(),model:W(),thinking:J(UO).optional()}),yM=q({name:W(),mode:J(JS)}),bM=q({cuts:J(sA),transition:J(cA),transitionSeconds:G(),vignette:J(lA),grain:J(lA),grade:J(uA),atmosphere:J(dA),chapterCards:KD(),animate:J(fA),animateEvery:G(),animateModel:W()}),xM=q({mode:J(ZS).optional(),checkpoints:K(Zj).max(3).refine(e=>new Set(e).size===e.length).readonly().optional(),title:W(),format:J(HS),sources:q({research:J(GS),article:J(GS),audio:J(GS),images:J(GS),thumbnail:J(GS),video:J(GS),document:J(GS).optional()}),llm:vM.optional(),audio:vM.extend({voice:W(),usePronunciationGlossary:KD().optional(),shareGlossary:KD().optional(),useNarrationAliases:KD().optional(),describeFigures:KD().optional(),skipCode:KD().optional()}).optional(),narrationAliases:dM.optional(),sharedGlossary:K(q({term:W().min(1).max(200),ipa:K(W().min(1).max(200)).min(1).max(20).readonly()})).max(2e4).readonly().optional(),images:vM.optional(),reference:q({source:J(XS),prompt:W().optional(),thumbnail:KD().optional()}).optional(),articlePrompt:W().optional(),narrationPrompt:W().optional(),imagePrompts:K(q({name:W(),number:G()})),imageScale:q({perHour:G(),words:G()}).optional(),imageScenes:KD().optional(),thumbnailPrompt:W().optional(),thumbnailCount:nO([mO(1),mO(3)]).optional(),intro:yM.optional(),outro:yM.optional(),values:uO(W(),W()),provided:q({research:W().optional(),article:W().optional(),audio:W().optional(),images:K(W()).optional(),thumbnail:W().optional(),reference:W().optional(),shortsMusic:W().optional(),ambientBed:W().optional()}),chunking:q({mode:J(fM),words:G().optional(),characters:G().int().min(1).max(1e6).optional()}).optional(),silenceGapSeconds:G(),imageSeconds:G().default(15),zoomPercent:G().default(JA),motionStyle:J(qS).default(YA),edgeSilenceSeconds:G().default(2),subtitles:hM.optional(),document:uM.optional(),youtubeDescription:KD().optional(),showFigures:KD().optional(),descriptionPrompt:W().optional(),shorts:q({enabled:KD(),count:G(),minSeconds:G(),maxSeconds:G(),prompt:W().optional(),imagePrompt:W().optional(),titleOnScreen:KD().optional(),fullVideoLink:W().optional(),musicVolume:G().optional(),speed:G().optional()}).optional(),videoEdit:bM.optional(),channelId:W().optional(),useBrandKit:mO(!1).optional(),cast:Jj.optional(),earlierEpisodes:K(q({title:W(),summary:W()})).readonly().optional(),titleStyle:q({fontId:W().max(160).regex(/^[A-Za-z0-9_-]+$/).optional(),color:_M.optional()}).optional(),endScreen:q({text:W().max(200)}).optional(),reviews:q({provider:W(),model:W(),thinking:J(UO).optional(),retries:G().optional(),stages:dO(J(wk),q({mode:J(Tk),prompt:W().optional()}))}).optional(),voices:zA.optional(),ambientBed:Oj.optional(),loudness:q({videoLufs:G(),audioFilesLufs:G()}).strict().optional(),sentencePauseSeconds:G().optional(),paragraphPauseSeconds:G().optional(),language:BO.optional()}),SM=xM.extend({rendered:uO(W(),W()),titlePattern:W().optional(),subjectTitle:W().optional()}),CM=[`article`,`image`,`thumbnail`,`narration`,`description`,`shorts`,`review`,`script`],wM=[`intro`,`outro`],TM=1e5;q({id:W(),kind:J(CM),name:W(),body:W(),slots:W(),updated_at:W()}),q({id:W(),category:J(wM),mode:J(JS),name:W(),body:W(),slots:W(),updated_at:W()});var EM=q({id:W(),name:W(),body:W(),slots:K(W()).readonly(),updatedAt:W()}),DM=q({prompts:K(EM.extend({kind:J(CM)}).strict().readonly()).readonly(),entries:K(EM.extend({category:J(wM),mode:J(JS)}).strict().readonly()).readonly()}).strict().readonly(),OM=TD(),kM=W(),AM=uO(kM,kM).readonly(),jM=q({provider:kM,model:kM,thinking:J(UO).optional()}).strict(),MM=[`audio`,`images`,`thumbnail`,`reference`],NM=q({attachmentId:OM,name:kM}).strict().readonly(),PM=q({title:kM,checkpoints:xM.shape.checkpoints,format:J(HS),sources:q({research:J(GS),article:J(GS),audio:J(GS),images:J(GS),thumbnail:J(GS),video:J(GS),document:J(GS).optional()}).strict().readonly(),document:uM.readonly().optional(),llm:jM.readonly(),audio:jM.extend({voice:kM,usePronunciationGlossary:KD().optional(),shareGlossary:KD().optional(),useNarrationAliases:KD().optional(),describeFigures:KD().optional(),skipCode:KD().optional()}).readonly(),images:jM.readonly(),reference:q({source:J([`off`,...XS]),prompt:kM,thumbnail:KD()}).strict().readonly().optional(),articlePrompt:kM,narrationPrompt:kM.optional(),thumbnailCount:nO([mO(1),mO(3)]).optional(),loudness:q({enabled:KD(),videoLufs:G().optional(),audioFilesLufs:G().optional()}).strict().readonly().optional(),sentencePause:kM.optional(),paragraphPause:kM.optional(),youtubeDescription:KD().optional(),showFigures:KD().optional(),descriptionPrompt:kM.optional(),language:BO.optional(),shorts:q({enabled:KD(),count:kM,minSeconds:kM,maxSeconds:kM,prompt:kM,imagePrompt:kM,titleOnScreen:KD().optional(),fullVideoLink:kM.optional(),musicVolume:kM.optional(),speed:kM.optional()}).strict().readonly().optional(),reviews:q({provider:kM,model:kM,thinking:J(UO).optional(),retries:kM,stages:dO(J(wk),q({mode:J(Tk),prompt:kM}).strict().readonly()).readonly()}).strict().readonly().optional(),imagePrompts:K(q({name:kM,number:kM}).strict().readonly()).readonly(),imageScale:q({every:J([`minutes`,`hour`]),value:kM}).strict().readonly().optional(),imageScenes:KD().optional(),thumbnailPrompt:kM,intro:kM,outro:kM,chunking:q({mode:J(fM),words:kM,characters:kM}).strict().readonly(),subtitles:q({mode:J(pM),language:mO(`en`),fontId:kM,fontSize:kM,position:J(mM)}).strict().readonly(),imageSeconds:kM.default(`15`),edgeSilenceSeconds:kM.default(`2`),zoomPercent:kM.default(String(JA)),motionStyle:J(qS).default(YA),silenceGapSeconds:kM.optional(),videoEdit:bM.strict().readonly().optional(),useBrandKit:KD().optional(),voices:zA.strict().readonly().optional(),ambientBed:q({source:J([`none`,...$k]),level:kM,fadeIn:kM,tail:kM}).strict().readonly().optional(),values:AM,provided:q({research:kM,article:kM,audio:NM.nullable(),thumbnail:NM.nullable(),images:K(NM).readonly(),reference:NM.nullable().optional(),shortsMusic:NM.nullable().optional(),ambientBed:NM.nullable().optional()}).strict().readonly()}).strict().readonly(),FM=q({schemaVersion:mO(1),librarySnapshot:DM.optional(),templateSource:q({id:OM,version:G().int().positive()}).strict().readonly().optional(),channelId:OM.optional(),form:PM,section:J([`content`,`outputs`,`style`,`review`]),variants:K(q({id:OM,title:kM,values:AM}).strict().readonly()).readonly(),queue:KD().optional(),expectedWords:kM,previewText:kM,fontUpload:q({operationId:OM,name:kM}).strict().readonly().nullable()}).strict().readonly(),IM=q({id:OM,document:FM}).strict().readonly(),LM=IM.unwrap().extend({baseVersion:G().int().positive(),mutationId:OM}).strict().readonly(),RM=IM.unwrap().extend({sourceId:OM}).strict().readonly(),zM=q({id:OM,baseVersion:G().int().positive()}).strict().readonly(),BM=q({id:OM,kind:J(MM),name:kM,state:J([`pending`,`copying`,`ready`,`reattach`]),stagedFileId:kM.nullable(),bytes:G().nonnegative(),error:kM.nullable()}).strict().readonly(),VM=q({id:OM,version:G().int().positive(),createdAt:kM,updatedAt:kM,document:FM}).strict().readonly(),HM=q({checkpointSet:K(Qj.unwrap().extend({reviewedFingerprint:kM}).strict().readonly()).readonly().optional(),requestId:OM,projectIds:K(kM).readonly(),queue:K(q({projectId:kM,batchId:kM,position:G(),state:J([`queued`,`active`,`finished`])}).strict().readonly()).readonly(),replayed:KD()}).strict().readonly(),UM=q({currency:mO(`USD`),rows:K(q({stage:kM,low:G().nullable(),high:G().nullable(),detail:kM,onPlan:KD().optional(),apiLow:G().nullable().optional(),apiHigh:G().nullable().optional()}).strict().readonly()).readonly(),low:G(),high:G(),unknown:G(),apiLow:G().optional(),apiHigh:G().optional(),apiUnknown:G().optional(),expectedWords:G(),catalogueDate:kM.nullable(),assumptions:K(kM).readonly()}).strict().readonly(),WM=q({checkpointSet:K(q({runIndex:G().int().nonnegative(),checkpointId:kM,stage:Zj,fingerprint:kM,workKeys:K(kM).readonly(),dependents:K(J(US)).readonly()}).strict().readonly()).readonly().optional(),id:OM,draftId:OM,draftVersion:G().int().positive(),fingerprint:kM,runs:K(q({draft:xM,rendered:AM,templates:AM}).strict().readonly()).readonly(),estimates:K(UM).readonly()}).strict().readonly(),GM=q({draft:VM,attachments:K(BM).readonly(),review:WM.nullable(),pendingStart:q({reviewId:OM,draftVersion:G().int().positive()}).strict().readonly().nullable(),start:HM.nullable()}).strict().readonly(),KM=q({title:W(),status:G(),detail:W().optional(),reason:W().optional(),currentVersion:G().int().positive().nullable().optional(),reviewId:TD().optional(),fields:K(q({field:W(),message:W()})).optional(),errors:K(q({path:W(),message:W()})).optional()}),qM=q({drafts:K(q({id:TD(),title:W(),version:G().int().positive(),updatedAt:W(),readable:KD()}).strict()).readonly()}).strict(),JM=zM.unwrap().omit({id:!0}).extend({draftId:TD(),reviewId:TD()}).strict();async function YM(e,t){let n;try{n=await e.json()}catch{throw po(e,void 0)}if(e.ok)return{ok:!0,value:So(t,n)};let r=KM.safeParse(n);if(!r.success)throw po(e,void 0);let i=r.data;if(![400,404,409].includes(e.status))throw po(e,{title:i.title,status:i.status,...i.detail===void 0?{}:{detail:i.detail},...i.fields===void 0?{}:{fields:i.fields}});return{ok:!1,reason:i.reason??`invalid-request`,message:i.detail??i.title,currentVersion:i.currentVersion??null,fields:i.fields??i.errors?.map(e=>({field:e.path,message:e.message}))??[],...i.reviewId===void 0?{}:{reviewId:i.reviewId}}}async function XM(e,t,n,r,i){return YM(await e.fetch(`${e.origin}/api/drafts${t}`,{method:n,...i===void 0?{}:{headers:{"content-type":`application/json`},body:JSON.stringify(i)}}),r)}function ZM(e){return`/${encodeURIComponent(TD().parse(e))}`}async function QM(e){return XM(e,``,`GET`,qM)}async function $M(e,t){return XM(e,``,`POST`,GM,IM.parse(t))}async function eN(e,t){return XM(e,ZM(t),`GET`,GM)}async function tN(e,t){let{id:n,...r}=LM.parse(t);return XM(e,ZM(n),`PUT`,GM,r)}async function nN(e,t){let{sourceId:n,...r}=RM.parse(t);return XM(e,`${ZM(n)}/fork`,`POST`,GM,r)}async function rN(e,t){let{id:n,...r}=zM.parse(t);return XM(e,ZM(n),`DELETE`,q({discarded:mO(!0)}).strict(),r)}async function iN(e,t){let{id:n,...r}=zM.parse(t);return XM(e,`${ZM(n)}/review`,`POST`,WM,r)}async function aN(e,t){let{draftId:n,...r}=JM.parse(t);return XM(e,`${ZM(n)}/start`,`POST`,HM,r)}function oN(e,t,n){return`${e.origin}/api/drafts${ZM(t)}/attachments/${encodeURIComponent(TD().parse(n))}/file`}async function sN(e,t,n,r,i){let a=new FormData;return a.set(`file`,r),YM(await e.fetch(oN(e,t,n),{method:`PUT`,body:a,...i?{signal:i}:{}}),BM)}var cN=[`fonts`];async function lN(e){return I(await e.fetch(`${e.origin}/api/fonts`))}async function uN(e,t){let n=new FormData;return n.set(`file`,t),I(await e.fetch(`${e.origin}/api/fonts`,{method:`POST`,body:n}))}function dN(e,t){return`${e.origin}/api/fonts/${encodeURIComponent(t)}/file`}var fN=`slopify.play-draft`;function pN(e){try{e?window.localStorage?.setItem(fN,e):window.localStorage?.removeItem(fN)}catch(e){console.warn(`Active draft browser storage is unavailable`,e)}}function mN(){try{return window.localStorage?.getItem(fN)??null}catch(e){return console.warn(`Active draft browser storage is unavailable`,e),null}}async function hN(e,t){let n=await Promise.allSettled([t.fetchQuery({...cb(e),staleTime:0}),t.fetchQuery({...ub(e),staleTime:0}),t.fetchQuery({...db(e),staleTime:0}),t.fetchQuery({...mb(e),staleTime:0}),t.fetchQuery({...lb(e),staleTime:0}),t.fetchQuery({queryKey:cN,queryFn:()=>lN(e),staleTime:0})]);for(let e of n)e.status===`rejected`&&console.warn(`Draft choices could not refresh`,e.reason)}var gN=`under Video and style → Ambient sound`;`${gN}`,`${gN}`;var _N=FM.parse({schemaVersion:1,form:{title:``,format:`16:9`,sources:{research:`off`,article:`generate`,audio:`generate`,images:`generate`,thumbnail:`off`,video:`generate`},llm:{provider:``,model:``},audio:{provider:``,model:``,voice:``,usePronunciationGlossary:!0,shareGlossary:!0,useNarrationAliases:!0,describeFigures:!0},images:{provider:``,model:``},articlePrompt:``,narrationPrompt:``,imagePrompts:[],thumbnailPrompt:``,intro:``,outro:``,chunking:{mode:`whole`,words:`500`,characters:`3000`},subtitles:{...gM,fontSize:`48`},imageSeconds:`15`,edgeSilenceSeconds:`2`,zoomPercent:String(JA),motionStyle:YA,videoEdit:mA,showFigures:!0,values:{},provided:{research:``,article:``,audio:null,images:[],thumbnail:null}},section:`content`,variants:[],expectedWords:`1500`,previewText:`Every story begins with a word.`,fontUpload:null}),vN={};function yN(e){vN=e}function bN(e,t=vN){let{form:n}=e;return n.llm.provider!==``||n.images.provider!==``||t.llm===void 0&&t.images===void 0?e:{...e,form:{...n,...t.llm===void 0?{}:{llm:{...t.llm}},...t.images===void 0?{}:{images:{...t.images}}}}}function xN(e){let t={...e.sources,...e.sources.article===`generate`?{}:{research:`off`},...e.sources.images===`off`?{video:`off`}:{}},n=t.audio===`off`?`off`:t.video===`off`&&e.subtitles.mode===`burn-in`?`files`:e.subtitles.mode;return{...e,sources:t,subtitles:{...e.subtitles,mode:n}}}function SN(e){let t=FM.parse(e);return JSON.stringify({...t,form:xN(t.form)})}function CN(e,t,n){return{...e,acknowledged:Math.max(e.acknowledged,t),version:n}}function wN(e,t){return t.type===`edit`?{...e,edited:e.edited+1}:CN(e,t.generation,t.version)}function TN(e,t,n){return{mutationId:n,document:FM.parse(JSON.parse(SN(e))),generation:t.edited,baseVersion:t.version}}function EN(){return{document:bN(_N),view:null,clock:{edited:0,acknowledged:0,version:0},id:null,recoveryId:null,pending:null,status:`unsaved`,error:null,reveal:null}}function DN(e,t,n){let r=e.form.provided,i=t.form.provided,a=new Map;for(let[e,t]of[[r.audio,i.audio],[r.thumbnail,i.thumbnail],[r.shortsMusic,i.shortsMusic],[r.ambientBed,i.ambientBed],...r.images.map((e,t)=>[e,i.images[t]])])e&&t&&a.set(e.attachmentId,t.attachmentId);let o=e=>e?{...e,attachmentId:a.get(e.attachmentId)??e.attachmentId}:null;return{...n,form:{...n.form,provided:{...n.form.provided,audio:o(n.form.provided.audio),thumbnail:o(n.form.provided.thumbnail),...n.form.provided.shortsMusic===void 0?{}:{shortsMusic:o(n.form.provided.shortsMusic)},...n.form.provided.ambientBed===void 0?{}:{ambientBed:o(n.form.provided.ambientBed)},images:n.form.provided.images.map(e=>({...e,attachmentId:a.get(e.attachmentId)??e.attachmentId}))}}}}function ON(e,t){if(e.draft.id!==t.id)return e;let n=t.document.form.provided,r=new Set([n.audio,n.thumbnail,n.shortsMusic,n.ambientBed,...n.images].flatMap(e=>e?[e.attachmentId]:[]));return{...e,attachments:e.attachments.filter(e=>r.has(e.id)).map(e=>{let n=t.view?.attachments.find(t=>t.id===e.id);return(e.state===`pending`||e.state===`copying`)&&(n?.state===`ready`||n?.state===`reattach`)?n:e})}}function kN(e,t){let n={...gM,...e},r=t.audio===`off`?`off`:(t.video===`off`||t.images===`off`)&&n.mode===`burn-in`?`files`:n.mode;if(r!==`off`)return{...n,mode:r};let i=hM.shape.fontId.safeParse(n.fontId),a=hM.shape.fontSize.safeParse(n.fontSize);return{...n,mode:r,fontId:i.success?i.data:gM.fontId,fontSize:a.success?a.data:gM.fontSize}}function AN(e){return e.mode===`off`||e.fontId!==``&&Number.isInteger(e.fontSize)&&e.fontSize>=16&&e.fontSize<=120}function jN(e){return e===`shortsMusic`||e===`ambientBed`?`audio`:e}function MN(e){return e.shorts?.enabled===!0&&e.sources.audio!==`off`}function NN(e){return e.ambientBed?.source===`upload`&&e.sources.video===`generate`&&e.sources.audio!==`off`}function PN(e){let t=e=>e.trim()===``?NaN:Number(e);return{enabled:e.enabled,count:t(e.count),minSeconds:t(e.minSeconds),maxSeconds:t(e.maxSeconds),...e.prompt.trim()?{prompt:e.prompt}:{},...e.imagePrompt.trim()?{imagePrompt:e.imagePrompt}:{},...Jk(e)}}({..._N.form}),{..._N.form.sources};var FN={off:`Off`,generate:`Generate`,provide:`Provide`,from_prompt:`From prompt`,prompt_by_llm:`Prompt by LLM`};function IN(e){return ej[e].map(e=>({value:e,label:FN[e]}))}function LN(e,t){return lj(BN({form:e,entries:t,slots:[],silenceGapSeconds:0}))}function RN(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.mode}function zN(e){return[e.audio,e.thumbnail,e.shortsMusic,e.ambientBed,e.reference,...e.images].flatMap(e=>e?.file===void 0?[]:[e.file])}function BN(e){let{form:t}=e;return{...t.checkpoints===void 0?{}:{checkpoints:t.checkpoints},title:t.title,format:t.format,sources:{...t.sources,...t.sources.article===`provide`?{research:`off`}:{},...t.sources.images===`off`?{video:`off`}:{}},llm:t.llm,audio:t.audio,images:t.images,...t.sources.images===`generate`&&t.reference!==void 0&&t.reference.source!==`off`?{reference:{source:t.reference.source,...t.reference.source===`prompt`?{prompt:t.reference.prompt}:{},thumbnail:t.reference.thumbnail}}:{},articlePrompt:t.articlePrompt,...t.narrationPrompt===void 0?{}:{narrationPrompt:t.narrationPrompt},...t.language===void 0||t.language===`en`?{}:{language:t.language},...t.sources.video===`generate`&&t.sources.images!==`off`&&t.sources.audio===`generate`&&t.audio.describeFigures===!0&&t.showFigures===!0?{showFigures:!0}:{},...t.sources.audio!==`off`&&t.youtubeDescription===!0?{youtubeDescription:!0,...t.descriptionPrompt?.trim()?{descriptionPrompt:t.descriptionPrompt}:{}}:{},...MN(t)&&t.shorts!==void 0?{shorts:PN(t.shorts)}:{},imagePrompts:t.imagePrompts,thumbnailPrompt:t.thumbnailPrompt,...t.thumbnailCount===3&&(t.sources.thumbnail===`from_prompt`||t.sources.thumbnail===`prompt_by_llm`)?{thumbnailCount:3}:{},...VN(HN(e,`intro`),e=>({intro:e})),...VN(HN(e,`outro`),e=>({outro:e})),values:UN(t.values,e.slots),provided:{research:t.provided.research,article:t.provided.article,...VN(t.provided.audio?.file,e=>({audio:e.id})),...VN(t.provided.thumbnail?.file,e=>({thumbnail:e.id})),...VN(t.sources.images===`generate`&&t.reference?.source===`provide`?t.provided.reference?.file:void 0,e=>({reference:e.id})),images:t.provided.images.flatMap(e=>e.file===void 0?[]:[e.file.id]),...MN(t)?VN(t.provided.shortsMusic?.file,e=>({shortsMusic:e.id})):{},...t.ambientBed?.source===`upload`?VN(t.provided.ambientBed?.file,e=>({ambientBed:e.id})):{}},chunking:t.chunking,subtitles:kN(t.subtitles,t.sources),silenceGapSeconds:e.silenceGapSeconds,imageSeconds:t.imageSeconds,edgeSilenceSeconds:t.edgeSilenceSeconds,zoomPercent:t.zoomPercent,motionStyle:t.motionStyle,...t.videoEdit===void 0?{}:{videoEdit:t.videoEdit},...t.voices!==void 0&&t.sources.audio===`generate`?{voices:t.voices}:{},...t.sources.document===`generate`?{document:t.document}:{},...VN(t.sources.video===`generate`&&t.sources.audio!==`off`?oA(t.ambientBed):void 0,e=>({ambientBed:e})),...t.sources.audio===`generate`?Ck(t):{},...VN(t.sources.audio===`off`?void 0:mk(t.loudness,e.loudness??nk),e=>({loudness:e}))}}function VN(e,t){return e===void 0?{}:t(e)}function HN(e,t){if(e.form.sources.audio!==`generate`)return;let n=t===`intro`?e.form.intro:e.form.outro,r=RN(e.entries,t,n);return n===``||r===void 0?void 0:{name:n,mode:r}}function UN(e,t){let n=Object.create(null);for(let r of t)n[r]=Object.hasOwn(e,r)?e[r]??``:``;return n}function WN(e,t){return e?.draftId===t.draftId&&e.version===t.version&&e.editGeneration===t.editGeneration}function GN({api:e,queryClient:t,current:n,flush:r,resave:i,render:a}){let o={receipt:null,pending:!1,starting:!1,uncertain:!1,valid:!1,error:null,fields:[],created:null},s,c=0,l=0,u=null,d=e=>{o={...o,...e},a()},f=()=>({draftId:n().id??``,version:n().clock.version,editGeneration:n().clock.edited}),p=()=>WN(s,f())&&n().clock.edited===n().clock.acknowledged&&o.receipt?.runs.length===KN(n().document),m=(e=!1)=>{c++,s=void 0,d({valid:!1,...e?{fields:[],error:null}:{}})},h=e=>d({error:e.message,fields:e.fields,valid:!1}),g=e=>{u=null,d({created:e,uncertain:!1,starting:!1,valid:!1})},_=async()=>{let t=u?.draftId;if(!t)return;let n=await eN(e,t);if(!n.ok){h(n);return}n.value.start&&g(n.value.start)};return{reset:()=>{c++,l++,s=void 0,u=null,o={receipt:null,pending:!1,starting:!1,uncertain:!1,valid:!1,error:null,fields:[],created:null},a()},state:()=>({...o,valid:o.valid&&p()}),invalidate:m,restore:e=>{c++,l++,s=void 0,u=e.pendingStart?{draftId:e.draft.id,baseVersion:e.pendingStart.draftVersion,reviewId:e.pendingStart.reviewId}:null,o={receipt:null,pending:!1,starting:!1,uncertain:u!==null,valid:!1,error:null,fields:[],created:e.start},a()},review:async()=>{if(o.pending||o.starting||o.uncertain||o.created)return;let a=++l;d({pending:!0,valid:!1,error:null,fields:[]});try{if(await Promise.all([hN(e,t),t.refetchQueries({queryKey:[`provider-models`]})]),a!==l||!await r()||!n().id)return;let o=f(),u=c,p=await iN(e,{id:o.draftId,baseVersion:o.version});if(a!==l||u!==c||!WN(o,f()))return;if(!p.ok){h(p);return}if(p.value.draftId!==o.draftId||p.value.draftVersion!==o.version)return;let m=KN(n().document);if(p.value.runs.length!==m){d({receipt:null,valid:!1,error:`The saved draft has ${qN(p.value.runs.length)}, but this page shows ${m}. Slopify saved this page again. Press Refresh review, then start.`}),i();return}s=o,d({receipt:p.value,valid:!0})}catch(e){a===l&&d({error:e instanceof Error?e.message:`This setup couldn't be checked. Press Refresh review to try again.`})}finally{a===l&&d({pending:!1})}},start:async()=>{if(o.starting||o.created||!u&&(!o.valid||!p()||o.pending||!o.receipt||XN(n().document,n().view)!==void 0)||(!u&&o.receipt&&(u={draftId:o.receipt.draftId,baseVersion:o.receipt.draftVersion,reviewId:o.receipt.id}),!u))return;let t=u;pN(t.draftId),d({starting:!0,error:null});try{if(o.uncertain&&(await _(),o.created))return;let n=await aN(e,t);if(n.ok){g(n.value);return}n.reason===`pending-start`||n.reason===`already-started`?(d({uncertain:!0}),await _()):(u=null,d({uncertain:!1}),h(n))}catch(e){d({uncertain:!0,valid:!1,error:`${bo(e instanceof Error?e.message:`Slopify didn't confirm the start`)} The run may already have started. Press Check Start result to find out before trying again.`})}finally{d({starting:!1})}}}}function KN(e){return e.variants.length+1}function qN(e){return e===1?`1 video`:`${e} videos`}function JN(e,t){if(e.starting)return`Starting…`;if(e.uncertain)return`Check Start result`;let n=e.valid&&e.receipt?e.receipt.runs.length:KN(t);return n===1?`Start run`:YN(t)?`Queue ${n} videos`:`Start ${n} videos`}function YN(e){return e.queue!==!1}function XN(e,t){if(e.fontUpload!==null)return`subtitles.fontUpload`;let{sources:n,provided:r}=e.form;return[...n.audio===`provide`&&r.audio?[{ref:r.audio,field:`provided.audio`}]:[],...n.thumbnail===`provide`&&r.thumbnail?[{ref:r.thumbnail,field:`provided.thumbnail`}]:[],...n.images===`provide`?r.images.map((e,t)=>({ref:e,field:`provided.images.${t}`})):[],...MN(e.form)&&r.shortsMusic?[{ref:r.shortsMusic,field:`shorts.music`}]:[],...NN(e.form)&&r.ambientBed?[{ref:r.ambientBed,field:`ambientBed.file`}]:[]].find(({ref:e})=>t?.attachments.find(t=>t.id===e.attachmentId)?.state!==`ready`)?.field}function ZN(e,t){return e?.draftId===t.draftId&&e.attachmentId===t.attachmentId}function QN({api:e,queryClient:t,state:n,edit:r,flush:i,generation:a,publish:o,render:s}){let c=(0,m.useRef)(0),l=(0,m.useRef)(null),u=(0,m.useRef)(null),d=(0,m.useRef)(new Map),f=(0,m.useRef)(new Map),p=e=>{let t=n.current.document.form.provided,r=[t.audio,t.thumbnail,t.shortsMusic,t.ambientBed,t.reference,...t.images].find(t=>t?.attachmentId===e.attachmentId);return ZN(r&&n.current.id?{draftId:n.current.id,attachmentId:r.attachmentId}:void 0,e)};(0,m.useEffect)(()=>{for(let[e,t]of d.current)t!==a()&&d.current.delete(e);for(let[e,t]of f.current)(!p(t.owner)||t.generation!==a())&&(t.controller.abort(),f.current.delete(e))}),(0,m.useEffect)(()=>{let e=f.current,t=d.current;return()=>{c.current++,t.clear();for(let t of e.values())t.controller.abort();e.clear()}},[]);let h=async(t,l,u)=>{if(l.length===0)return;let m=jN(t),h=m===`images`&&!u?l:l.slice(-1),g=h.map(e=>({attachmentId:crypto.randomUUID(),name:e.name})),_=c.current,v=a();for(let e of g)d.current.set(e.attachmentId,v);let y=n.current.document,b=y.form.provided;r({...y,form:{...y.form,provided:m===`images`?{...b,images:u?b.images.flatMap(e=>e.attachmentId===u?g:[e]):[...b.images,...g]}:{...b,[t]:g.at(-1)??null}}});let x=await i();for(let e of g)d.current.delete(e.attachmentId);if(!x||v!==a()||_!==c.current){s();return}let S=n.current.id;S&&await Promise.all(g.map(async(t,r)=>{let i=h[r],s={draftId:S,attachmentId:t.attachmentId};if(!i||!p(s))return;let l=new AbortController;f.current.set(t.attachmentId,{owner:s,controller:l,generation:v});let u=e=>{let r=n.current.view;v===a()&&_===c.current&&r?.draft.id===S&&p(s)&&!l.signal.aborted&&o({view:{...r,review:null,attachments:[...r.attachments.filter(e=>e.id!==t.attachmentId),e]}})};try{let n=await sN(e,S,t.attachmentId,i,l.signal);n.ok?u(n.value):u({id:t.attachmentId,kind:m,name:t.name,state:`reattach`,stagedFileId:null,bytes:0,error:n.message})}catch(e){u({id:t.attachmentId,kind:m,name:t.name,state:`reattach`,stagedFileId:null,bytes:0,error:e instanceof Error?e.message:`Reattach this file`})}finally{f.current.delete(t.attachmentId)}}))},g=e=>{l.current=null;let t=n.current.document;r({...t,fontUpload:null,form:{...t.form,subtitles:{...t.form.subtitles,fontId:e}}})},_=async o=>{let d=crypto.randomUUID();l.current=d,r({...n.current.document,fontUpload:{operationId:d,name:o.name}});let f=c.current,p=a();if(!await i()||p!==a()||f!==c.current){l.current===d&&(l.current=null),s();return}if(n.current.document.fontUpload?.operationId===d)try{let{font:r}=await uN(e,o);if(p!==a()||f!==c.current||n.current.document.fontUpload?.operationId!==d)return;t.setQueryData(cN,e=>({fonts:[...(e?.fonts??[]).filter(e=>e.id!==r.id),r]})),g(r.id),await i()}catch(e){p===a()&&f===c.current&&n.current.document.fontUpload?.operationId===d&&(u.current={operationId:d,message:e instanceof Error?e.message:`Reattach this font`},s())}finally{l.current===d&&(l.current=null,s())}},v=l.current!==null&&l.current===n.current.document.fontUpload?.operationId;return{attachmentUploading:e=>{let t=f.current.get(e);return d.current.get(e)===a()||t!==void 0&&t.generation===a()&&p(t.owner)&&!t.controller.signal.aborted},fontUpload:{pending:v,error:u.current?.operationId===n.current.document.fontUpload?.operationId?u.current?.message:void 0,pick:e=>{_(e)}},attach:h,selectFont:g,uploadSubtitleFont:_,fontUploading:v}}function $N(e,t,n){(0,m.useEffect)(()=>{let r=e=>[`prompts`,`entries`,`providers`,`provider-models`,`fonts`,`settings`].includes(String(e[0])),i=t.getQueryCache().subscribe(e=>{e.type===`updated`&&r(e.query.queryKey)&&(e.action.type===`success`||e.action.type===`invalidate`)&&n.invalidate()}),a=()=>{n.invalidate(),hN(e,t),t.refetchQueries({queryKey:[`provider-models`]})};return window.addEventListener(`focus`,a),()=>{i(),window.removeEventListener(`focus`,a)}},[e,t,n])}function eP(){let{api:e}=z(),t=_(),[,n]=(0,m.useReducer)(e=>e+1,0),r=(0,m.useRef)(EN()),i=(0,m.useMemo)(()=>{let i,a=null,o=!1,s=0,c=!1,l=null,u=!0,d=e=>{r.current={...r.current,...e},u&&n()},f=()=>{clearTimeout(i),i=void 0},p=()=>{t.invalidateQueries({queryKey:[`play-drafts`]})},m=e=>{d({status:`error`,error:e instanceof Error?e.message:`Your latest changes weren't saved. Keep this page open and try again.`})},h=e=>e.ok?!0:(d({status:e.reason===`conflict`?`conflict`:`error`,error:e.message}),!1),g=e=>{b.restore(e),d({...EN(),document:e.draft.document,view:e,id:e.draft.id,clock:{edited:0,acknowledged:0,version:e.draft.version},status:`saved`}),pN(e.draft.id),p()},_=async()=>{let t=s;for(;r.current.clock.edited>r.current.clock.acknowledged;){if(r.current.status===`conflict`||t!==s||l!==null&&l===r.current.id)return!1;let n=r.current,i=n.id??crypto.randomUUID(),a=n.pending??TN(n.document,n.clock,crypto.randomUUID());d({id:i,pending:a,status:`saving`,error:null});try{let n=a.baseVersion===0?await $M(e,{id:i,document:a.document}):await tN(e,{id:i,baseVersion:a.baseVersion,mutationId:a.mutationId,document:a.document});if(t!==s)return!1;if(!h(n))return n.reason!==`conflict`&&d({pending:null}),!1;let c=wN(r.current.clock,{type:`acknowledge`,generation:a.generation,version:n.value.draft.version});if(d({clock:c,view:{...ON(n.value,r.current),review:c.edited>c.acknowledged?null:n.value.review},pending:null,status:c.edited>c.acknowledged?`unsaved`:`saved`,error:null}),pN(i),p(),!o)return!0}catch(e){return t===s&&m(e),!1}}return r.current.status!==`conflict`&&r.current.status!==`error`},v=()=>c?Promise.resolve(!1):a||(r.current.clock.edited===r.current.clock.acknowledged?Promise.resolve(!0):l!==null&&l===r.current.id?Promise.resolve(!1):(a=_().finally(()=>{a=null}),a)),y=()=>(f(),o=!0,v()),b=GN({api:e,queryClient:t,current:()=>r.current,flush:y,resave:()=>x(r.current.document),render:()=>{u&&n()}}),x=e=>{if(b.state().starting||b.state().uncertain||b.state().created)return;b.invalidate(JSON.stringify({...e,section:r.current.document.section})!==JSON.stringify(r.current.document));let t=r.current;d({document:e,clock:wN(t.clock,{type:`edit`}),view:t.view?{...t.view,review:null}:null,status:t.status===`conflict`||t.status===`error`?t.status:`unsaved`}),f(),!(c||l!==null&&l===t.id||t.status===`conflict`||t.status===`error`)&&(t.id?i=setTimeout(()=>{y()},500):(o=!1,v()))},S=async(n,i=()=>!0)=>{if(b.state().starting||b.state().uncertain||b.state().created||(r.current.id!==n||r.current.status!==`conflict`)&&!await y()||!i())return!1;let a=++s,o=r.current.clock.edited;f();try{let c=await eN(e,n);return a!==s||o!==r.current.clock.edited||!i()?!1:h(c)?(T=null,g(c.value),await hN(e,t),i()):(r.current.id||d({recoveryId:n}),!1)}catch(e){return a===s&&o===r.current.clock.edited&&(m(e),r.current.id||d({recoveryId:n})),!1}},C=async()=>{if(b.state().starting||b.state().uncertain||b.state().created)return;let e=s;await y()&&e===s&&(s++,T=null,d(EN()),b.reset(),pN(null))},w=async({id:t,version:n})=>{if(b.state().starting||b.state().uncertain||b.state().created)throw Error(`Resolve the pending Start before discarding a draft`);if(c||l!==null)throw Error(`Wait for the current draft operation before discarding`);let i=s;l=t,(r.current.id??r.current.recoveryId)===t&&f();try{a&&await a;let o=await rN(e,{id:t,baseVersion:n});if(!o.ok&&o.reason!==`not-found`)throw Error(o.message);if(p(),i!==s||(r.current.id??r.current.recoveryId)!==t)return;f(),s++,T=null,d(EN()),b.reset(),pN(null)}finally{l=null}},T=null;return{review:b,takeCreated:()=>{let e=b.state().created;if(!e)return null;s++,d(EN()),b.reset(),pN(null);for(let e of[[`projects`],[`staging`],[`play-drafts`]])t.invalidateQueries({queryKey:e});return e},edit:x,flush:y,open:S,newDraft:C,adoptDefaults:e=>{let t=r.current;if(t.id!==null||t.clock.edited>0||t.view!==null)return;let n=bN(t.document,e);n!==t.document&&d({document:n})},discard:w,saveAsNew:async()=>{if(b.state().starting||b.state().uncertain||b.state().created||(f(),c||l!==null))return;a&&await a;let t=r.current;if(!t.id||!t.view&&t.status!==`conflict`){await y();return}let n=s;T?.sourceId!==t.id&&(T=null),T??={sourceId:t.id,id:crypto.randomUUID(),document:TN(t.document,t.clock,crypto.randomUUID()).document,generation:t.clock.edited};let i=T;c=!0;try{let t=await nN(e,{sourceId:i.sourceId,id:i.id,document:i.document});if(n!==s)return;if(!h(t)){t.reason===`conflict`&&(T=null);return}let a=r.current.clock.edited>i.generation?r.current.document:null;s++,g(t.value),T=null,c=!1,a&&x(DN(i.document,t.value.draft.document,a))}catch(e){n===s&&m(e)}finally{c=!1}},navigate:async(e,t)=>{let n=s,i={...r.current.document,section:e};r.current.id||r.current.clock.edited>0?x(i):d({document:i}),await y()&&n===s&&d({reveal:{section:e,...t===void 0?{}:{field:t},sequence:(r.current.reveal?.sequence??0)+1}})},generation:()=>s,publish:d,start:()=>{u=!0;let e=mN();e&&S(e)},stop:()=>{u=!1,f()}}},[e,t]);(0,m.useEffect)(()=>(i.start(),i.stop),[i]),$N(e,t,i.review);let a=QN({api:e,queryClient:t,state:r,edit:i.edit,flush:i.flush,generation:i.generation,publish:i.publish,render:n}),o=r.current;return{...a,review:i.review.state(),reviewDraft:i.review.review,startRun:i.review.start,invalidateReview:i.review.invalidate,takeCreated:i.takeCreated,document:o.document,section:o.document.section,view:o.view,status:o.status,error:o.error,edited:o.clock.edited,acknowledged:o.clock.acknowledged,reveal:o.reveal,edit:i.edit,flush:i.flush,open:i.open,generation:i.generation,newDraft:i.newDraft,adoptDefaults:i.adoptDefaults,discard:i.discard,saveAsNew:i.saveAsNew,navigate:i.navigate,activeId:o.id??o.recoveryId}}var tP=(0,m.createContext)(null);function nP({children:e}){let t=eP();return(0,h.jsx)(tP.Provider,{value:t,children:e})}function rP(){return(0,m.useContext)(tP)}function iP(){let e=(0,m.useContext)(tP);if(!e)throw Error(`PlayDraftProvider is required`);return e}var aP=(0,m.createContext)(void 0);function oP({children:e}){let[t,n]=(0,m.useState)(()=>new Map),r=(0,m.useCallback)((e,t)=>{n(n=>{let r=n.get(e),i=typeof t==`function`?t(r):t;if(r===i)return n;let a=new Map(n);return i===void 0?a.delete(e):a.set(e,i),a})},[]),i=(0,m.useMemo)(()=>({prompts:t,updatePrompt:r}),[t,r]);return(0,h.jsx)(aP.Provider,{value:i,children:e})}function sP(e){let t=(0,m.useContext)(aP),[n,r]=(0,m.useState)(void 0),i=t?.updatePrompt,a=(0,m.useCallback)(t=>{i?i(e,t):r(t)},[e,i]);return[t?t.prompts.get(e):n,a]}function cP(e){return e.trim()===``?NaN:Number(e)}function lP(){let e=iP(),t=(0,m.useRef)(e);t.current=e;let n=e.document.form,r=t=>{if(!t)return;let n=e.view?.attachments.find(e=>e.id===t.attachmentId),r=n?.state===`ready`&&n.stagedFileId?{id:n.stagedFileId,stageKind:n.kind===`reference`?`images`:n.kind,path:n.stagedFileId,originalFilename:n.name,bytes:n.bytes,state:`staged`,createdAt:e.view?.draft.createdAt??``}:void 0;return{key:t.attachmentId,name:t.name,file:r,error:n?.error??(n?.state===`reattach`||!r&&!e.attachmentUploading(t.attachmentId)?`Reattach this file`:void 0)}},i={...n,sources:{...n.sources,document:KS(n.sources,`document`)},document:{theme:rC(n.document),...n.document?.custom===void 0?{}:{custom:n.document.custom}},imagePrompts:n.imagePrompts.map(e=>({...e,number:Number(e.number)})),chunking:n.chunking.mode===`words`?{mode:`words`,...n.chunking.words===``?{}:{words:Number(n.chunking.words)}}:n.chunking.mode===`characters`?{mode:`characters`,...n.chunking.characters===``?{}:{characters:Number(n.chunking.characters)}}:{mode:n.chunking.mode},subtitles:{...n.subtitles,fontSize:Number(n.subtitles.fontSize)},imageSeconds:cP(n.imageSeconds),edgeSilenceSeconds:cP(n.edgeSilenceSeconds),zoomPercent:cP(n.zoomPercent),provided:{research:n.provided.research,article:n.provided.article,audio:r(n.provided.audio),thumbnail:r(n.provided.thumbnail),...n.provided.reference===void 0?{}:{reference:r(n.provided.reference)},shortsMusic:r(n.provided.shortsMusic),ambientBed:r(n.provided.ambientBed),images:n.provided.images.flatMap(e=>{let t=r(e);return t?[t]:[]})}},a=(0,m.useRef)(i);return a.current=i,[i,(0,m.useCallback)(e=>{let n=t.current.document,r=typeof e==`function`?e(a.current):e;a.current=r;let i=(e,t)=>e===void 0?``:Object.is(e,Number(t))?t:String(e),o=e=>e?{attachmentId:e.key,name:e.name}:null,{document:s,...c}=r.sources,{document:l,...u}=r,{shortsMusic:d,ambientBed:f}=r.provided,p=n.form.sources.document!==void 0||s!==`off`,m=n.form.document!==void 0||l.theme!==rC(n.form.document)||l.custom!==void 0;t.current.edit({...n,form:{...u,sources:p?r.sources:c,...m?{document:l}:{},imagePrompts:r.imagePrompts.map(e=>({...e,number:i(e.number,n.form.imagePrompts.find(t=>t.name===e.name)?.number??String(e.number))})),chunking:{...n.form.chunking,mode:r.chunking.mode,...r.chunking.mode===`words`?{words:i(r.chunking.words,n.form.chunking.words)}:{},...r.chunking.mode===`characters`?{characters:i(r.chunking.characters,n.form.chunking.characters)}:{}},subtitles:{...n.form.subtitles,...r.subtitles,fontSize:i(r.subtitles.fontSize,n.form.subtitles.fontSize)},imageSeconds:Object.is(r.imageSeconds,cP(n.form.imageSeconds))?n.form.imageSeconds:String(r.imageSeconds),edgeSilenceSeconds:Object.is(r.edgeSilenceSeconds,cP(n.form.edgeSilenceSeconds))?n.form.edgeSilenceSeconds:String(r.edgeSilenceSeconds),zoomPercent:Object.is(r.zoomPercent,cP(n.form.zoomPercent))?n.form.zoomPercent:String(r.zoomPercent),provided:{research:r.provided.research,article:r.provided.article,audio:o(r.provided.audio),thumbnail:o(r.provided.thumbnail),...r.provided.reference===void 0&&n.form.provided.reference===void 0?{}:{reference:o(r.provided.reference)},images:r.provided.images.map(e=>({attachmentId:e.key,name:e.name})),...d!==void 0||n.form.provided.shortsMusic!==void 0?{shortsMusic:o(d)}:{},...f!==void 0||n.form.provided.ambientBed!==void 0?{ambientBed:o(f)}:{}}}})},[])]}var uP={newVideo:[`C`],goHome:[`G`,`H`],goProjects:[`G`,`P`],goCalendar:[`G`,`C`],goSchedules:[`G`,`S`],goLibrary:[`G`,`L`],goChannels:[`G`,`K`],goSettings:[`G`,`,`],nextAction:[`Shift`,`N`],copyDescription:[`Shift`,`D`],reviewSetup:[`Ctrl`,`Enter`],save:[`Ctrl`,`S`]},dP=`slopify.notifications.browser`,fP=`slopify.notifications.sent`,pP=6e4,mP=new Set;function hP(){return typeof window<`u`&&`Notification`in window}function gP(){return hP()?Notification.permission:`unsupported`}function _P(){try{return window.localStorage.getItem(dP)===`on`}catch{return!1}}function vP(e){try{e?window.localStorage.setItem(dP,`on`):window.localStorage.removeItem(dP)}catch{}for(let e of mP)e()}function yP(e){mP.add(e);let t=t=>{t.key===dP&&e()};return window.addEventListener(`storage`,t),()=>{mP.delete(e),window.removeEventListener(`storage`,t)}}function bP(){return _P()&&gP()===`granted`}function xP(e){if(e===`unsupported`)return`This browser can't show notifications. Use a current Chrome, Edge, Firefox or Safari, or set a Notification URL below instead.`;if(e===`denied`)return`Notifications are blocked for this site. Allow them in your browser's site settings (the icon left of the address bar), reload, then turn Browser notifications on again.`}async function SP(){return hP()?Notification.permission==="default"?await Notification.requestPermission():Notification.permission:`unsupported`}async function CP(e,t=Date.now){let n=()=>{let n={};try{let e=JSON.parse(window.localStorage.getItem(fP)??`{}`);typeof e==`object`&&e&&(n=Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`number`&&t()-e[1]<pP)))}catch{}if(n[e]!==void 0)return!1;try{window.localStorage.setItem(fP,JSON.stringify({...n,[e]:t()}))}catch{}return!0};try{if(typeof navigator<`u`&&navigator.locks!==void 0)return await navigator.locks.request(`slopify-run-notification`,n)}catch{}return n()}function wP(e,t){let n=new Notification(e.text.headline,{body:e.text.detail,tag:`slopify-run-${e.projectId}`});n.onclick=()=>{window.focus(),t(e.projectId),n.close()}}function TP(e,t){let n=new Notification(e.text.headline,{body:e.text.detail,tag:`slopify-topics-${e.scheduleId}`});n.onclick=()=>{window.focus(),t(),n.close()}}function EP(e,t){let n=e.title.trim()===``?`Untitled project`:e.title.trim(),r=new Notification(`Started: ${n}`,{body:`Slopify is working on it. You'll hear a different chime when it ends.`,tag:`slopify-run-${e.projectId}`});r.onclick=()=>{window.focus(),t(e.projectId),r.close()}}var DP=`slopify.notifications.sound`,OP=new Set;function kP(){try{return window.localStorage.getItem(DP)!==`off`}catch{return!0}}function AP(e){try{e?window.localStorage.removeItem(DP):window.localStorage.setItem(DP,`off`)}catch{}for(let e of OP)e()}function jP(e){OP.add(e);let t=t=>{t.key===DP&&e()};return window.addEventListener(`storage`,t),()=>{OP.delete(e),window.removeEventListener(`storage`,t)}}var MP={start:[[784,0,.16],[1175,.14,.3]],end:[[1047,0,.18],[1319,.16,.18],[1568,.32,.55]]},NP;function PP(){if(typeof window<`u`&&typeof window.AudioContext==`function`)return NP??=new window.AudioContext,NP}function FP(){let e=PP();e?.state===`suspended`&&e.resume().catch(()=>{})}function IP(e){let t=PP();if(t===void 0)return;t.state===`suspended`&&t.resume().catch(()=>{});let n=t.currentTime+.02,r=t.createDynamicsCompressor();r.threshold.value=-3,r.ratio.value=12,r.connect(t.destination);for(let[i,a,o]of MP[e])for(let[e,s,c]of[[1,.9,`sine`],[2,.25,`triangle`]]){let l=t.createOscillator(),u=t.createGain();l.type=c,l.frequency.value=i*e,u.gain.setValueAtTime(1e-4,n+a),u.gain.exponentialRampToValueAtTime(s,n+a+.012),u.gain.exponentialRampToValueAtTime(1e-4,n+a+o),l.connect(u).connect(r),l.start(n+a),l.stop(n+a+o+.05)}}function LP(e,t){if(e===`running`)switch(t){case`done`:return`ready`;case`partial`:return`partial`;case`failed`:return`failed`;case`pending`:return`waiting`;default:return}}var RP={article:`the article`,images:`an image`,narration:`the narration`,thumbnail:`the thumbnail`,shorts:`a short`};function zP(e){let t=e.title.trim()===``?`Untitled project`:e.title.trim(),n=VP(e.reason),r=RP[e.stage]??`an item`,i=`Review needs a decision: ${t}`;return{headline:n===void 0?i:`${i} — ${n}`,detail:`The automatic review flagged ${r} and kept it. Open the project and press Overrule to keep it or Redo to make it again.`}}var BP=140;function VP(e){let t=e?.split(/\r?\n/).map(e=>e.trim()).find(e=>e!==``);if(t!==void 0)return t.length<=BP?t:`${t.slice(0,139).trimEnd()}…`}function HP(e,t){let n=t.title.trim()===``?`Untitled project`:t.title.trim();switch(e){case`ready`:return t.makesVideo?{headline:`Video ready: ${n}`,detail:`Open the project to watch it.`}:{headline:`Run finished: ${n}`,detail:`Open the project to see its files.`};case`partial`:{let e=VP(t.reason),r=t.makesVideo?`Video ready with problems: ${n}`:`Run finished with problems: ${n}`;return{headline:e===void 0?r:`${r} — ${e}`,detail:`Open the project to see which step failed and the button that fixes it.`}}case`failed`:{let e=VP(t.reason);return{headline:e===void 0?`Run failed: ${n}`:`Run failed: ${n} — ${e}`,detail:`Open the project to see what stopped it and press Retry.`}}case`waiting`:return{headline:`Waiting for you: ${n}`,detail:`Open the project to review the held step or press Continue the run.`}}}function UP(e){let t=e.scheduleName.trim()===``?`Untitled schedule`:e.scheduleName.trim(),n=e.added,r=e.waiting>n?` ${String(e.waiting)} are waiting in all.`:``;return{headline:`${String(n)} new ${n===1?`topic is`:`topics are`} waiting for you`,detail:`Open Calendar → Suggested topics → ${t} to queue or reject ${n===1?`it`:`them`}.${r}`}}var WP={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.`},GP=2048;function KP(e){let t=e.trim();if(t===``)return;if(t.length>2048)return`Keep the Notification URL to ${String(GP)} 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 qP=new Set([`done`,`partial`,`failed`,`canceled`]);function JP(e){let t=new Map,n=new Set,r=()=>e.sounds?.()===!0&&e.play!==void 0,i=new Set,a=t=>{let n=t.catch(t=>{e.report(t)}).finally(()=>{i.delete(n)});i.add(n)},o=async(t,n,i)=>{let a=await e.subject(t);a!==void 0&&await e.claim(`${t}:${n}`)&&(r()&&e.play?.(`end`),e.enabled()&&e.show({projectId:t,kind:i,text:HP(i,a)}))},s=async t=>{let n=await e.subject(t);n!==void 0&&await e.claim(`${t}:started`)&&(r()&&e.play?.(`start`),e.enabled()&&e.showStart?.({projectId:t,title:n.title}))};return{observe:i=>{let c=t.get(i.projectId);if(t.set(i.projectId,i.state),c===i.state)return;let l=e.enabled()||r();if(i.state===`running`&&!n.has(i.projectId)){n.add(i.projectId),(r()||e.enabled()&&e.showStart!==void 0)&&a(s(i.projectId));return}qP.has(i.state)&&n.delete(i.projectId);let u=LP(c,i.state);u!==void 0&&l&&a(o(i.projectId,i.state,u))},observeTopics:t=>{if(t.added<=0||!e.enabled()||e.showTopics===void 0)return;let n=e.showTopics;a((async()=>{await e.claim(`topics:${t.scheduleId}:${String(t.waiting)}`)&&n({scheduleId:t.scheduleId,text:UP(t)})})())},observeReview:t=>{if(!e.enabled()||e.showReview===void 0)return;let n=e.showReview;a((async()=>{let r=await e.subject(t.projectId);r!==void 0&&await e.claim(`review:${t.verdictId}`)&&n({projectId:t.projectId,text:zP({title:r.title,stage:t.stage,reason:t.reason})})})())},seed:async()=>{try{for(let r of await e.seed())t.has(r.id)||(t.set(r.id,r.status),(r.status===`running`||r.status===`paused`)&&n.add(r.id))}catch(t){e.report(t)}},settled:async()=>{for(;i.size>0;)await Promise.all([...i])}}}function YP(){let{api:e}=z(),t=_(),n=Xi(),r=(0,m.useRef)(n);r.current=n;let i=(0,m.useMemo)(()=>JP({enabled:bP,sounds:kP,play:IP,showStart:e=>{EP(e,e=>{r.current({to:`/projects/$projectId`,params:{projectId:e}})})},seed:async()=>(await t.fetchQuery({...rb(e),staleTime:5e3})).projects,subject:async t=>{let n=await jo(e,t);return{title:n.project.title,makesVideo:n.project.config.sources.video!==`off`,reason:n.stages.find(e=>e.state===`failed`)?.failureReason??void 0}},claim:e=>CP(e),showTopics:e=>{TP(e,()=>{r.current({to:`/calendar`})})},showReview:e=>{wP(e,e=>{r.current({to:`/projects/$projectId`,params:{projectId:e}})})},show:e=>{wP(e,e=>{r.current({to:`/projects/$projectId`,params:{projectId:e}})})},report:e=>{console.warn(`Slopify couldn't show a run notification.`,e)}}),[e,t]);return(0,m.useEffect)(()=>{let e=()=>bP()||kP();e()&&i.seed();let t=()=>{e()&&i.seed()},n=yP(t),r=jP(t);return window.addEventListener(`pointerdown`,FP,{once:!0}),window.addEventListener(`keydown`,FP,{once:!0}),()=>{n(),r(),window.removeEventListener(`pointerdown`,FP),window.removeEventListener(`keydown`,FP)}},[i]),i}function XP({open:e,title:t,onClose:n,children:r,footer:i,width:a=`wide`,headingRef:o,className:s}){let c=(0,m.useId)(),l=(0,m.useRef)(null),u=o??l,d=(0,m.useRef)(null),f=(0,m.useRef)(null),p=(0,m.useRef)(n);return(0,m.useEffect)(()=>{p.current=n}),(0,m.useEffect)(()=>{if(!e)return;d.current=document.activeElement,f.current?.contains(document.activeElement)||u.current?.focus({preventScroll:!0});let t=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[data-slot="dialog-content"][data-state="open"]`)||p.current()};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t);let e=d.current;e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[e,u]),e?(0,h.jsxs)(`aside`,{ref:f,role:`dialog`,"aria-modal":`false`,"aria-labelledby":c,"data-slot":`drawer`,className:L(`fixed top-0 right-0 bottom-0 z-50 flex w-full flex-col border-l border-line bg-raised shadow-[var(--shadow-dialog)]`,a===`wide`?`sm:w-[min(560px,100vw)]`:`sm:w-[min(440px,100vw)]`,`data-[state=open]:animate-tick-in motion-reduce:animate-none`,s),"data-state":`open`,children:[(0,h.jsxs)(`div`,{className:`flex min-h-12 shrink-0 items-center gap-3 border-b border-line px-4`,children:[(0,h.jsx)(`h2`,{ref:u,id:c,tabIndex:-1,className:`min-w-0 flex-1 truncate text-title-3 font-semibold focus-visible:outline-offset-[-2px]`,children:t}),(0,h.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close`,className:`inline-flex size-8 items-center justify-center rounded-control text-ink-2 hover:bg-raised hover:text-ink`,children:(0,h.jsx)(el,{"aria-hidden":`true`,className:`size-4`})})]}),(0,h.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:r}),i?(0,h.jsx)(`div`,{className:`flex min-h-14 shrink-0 flex-wrap items-center gap-2 border-t border-line px-4 py-2 pb-[max(8px,env(safe-area-inset-bottom))]`,children:i}):null]}):null}var ZP=[{id:`text-key`,title:`1. Connect a text provider`,target:`keys-llm`,page:`settings`},{id:`audio-key`,title:`2. Connect a voice provider`,target:`keys-tts`,page:`settings`},{id:`image-key`,title:`3. Connect an image provider`,target:`keys-image`,page:`settings`},{id:`voice`,title:`4. Add a narration voice`,target:`voices`,page:`settings`},{id:`article-name`,title:`5. Name your article prompt`,target:`prompt-name`,page:`article`},{id:`article-body`,title:`6. Write instructions with keywords`,target:`prompt-body`,page:`article`},{id:`article-keywords`,title:`7. Check the detected keywords`,target:`prompt-slots`,page:`article`},{id:`article-save`,title:`8. Save your article prompt`,target:`prompt-save`,page:`article`},{id:`image-prompt`,title:`9. Create an image prompt`,target:`prompt-editor`,page:`image`},{id:`image-save`,title:`10. Save your image prompt`,target:`prompt-save`,page:`image`},{id:`play-options`,title:`11. Name the project and choose text generation`,target:`play-options`,page:`play`},{id:`play-article`,title:`12. Choose your article`,target:`play-article`,page:`play`},{id:`play-keywords`,title:`13. Fill in your keywords`,target:`play-keywords`,page:`play`},{id:`play-audio`,title:`14. Choose narration`,target:`play-audio`,page:`play`},{id:`play-images`,title:`15. Choose images`,target:`play-images`,page:`play`},{id:`play-video`,title:`16. Choose video output`,target:`play-video`,page:`play`},{id:`play-subtitles`,title:`17. Style optional subtitles`,target:`play-subtitles`,page:`play`},{id:`play-start`,title:`18. Review and start your run`,target:`play-start`,page:`play`},{id:`project`,title:`19. Follow and control the run`,target:`project-controls`,page:`project`},{id:`download`,title:`20. Download your results`,target:`project-video`,page:`project`},{id:`run-cost`,title:`21. See what the run cost`,target:`project-rail-cost`,page:`project`},{id:`studio-prep`,title:`22. Prepare the YouTube upload`,target:`project-rail-video`,page:`project`},{id:`home`,title:`23. Check Home each day`,target:`home`,page:`home`},{id:`channels`,title:`24. Set up a channel`,target:`channels`,page:`channels`},{id:`calendar`,title:`25. Plan uploads on the calendar`,target:`calendar`,page:`calendar`}],QP=`home`;function $P(e,t){return e.active?t.type===`project-created`?{...e,projectId:t.id,step:ZP.findIndex(e=>e.id===`project`)}:t.kind===`article`?{...e,articleId:t.id}:t.kind===`image`?{...e,imageId:t.id}:e:e}function eF(e){let t=ZP.findIndex(t=>t.id===e);return t<0?void 0:t}var tF={"play-options":`content`,"play-article":`content`,"play-keywords":`content`,"play-audio":`outputs`,"play-images":`outputs`,"play-video":`outputs`,"play-subtitles":`style`,"play-start":`content`};function nF(e){return e.kind===`keyed`?e.hasKey:e.kind===`local`?e.available:e.installed&&e.issue===void 0}var rF={research:`Research`,article:`Article`,audio:`Audio`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`,document:`Document`};function iF(e){return e.sources.video===`off`?e.sources.audio===`off`?`article`:`audio`:`video`}function aF(e,t){return e===`video`&&iF(t)===`audio`?`Audio export`:rF[e]}function oF(e,t){return e.kind===`video`&&e.state===`running`&&t.subtitles!==void 0&&t.subtitles.mode!==`off`&&e.progressTotal===100&&(e.progressCurrent??0)<=35}var sF={research:(e,t)=>`chapter ${String(e)} of ${String(t)}`,article:(e,t)=>`${String(e)} of ${String(t)}`,audio:(e,t)=>`chunk ${String(e)} of ${String(t)}`,images:(e,t)=>`image ${String(e)} of ${String(t)}`,thumbnail:(e,t)=>`${String(e)} of ${String(t)}`,video:(e,t)=>`${String(yF(e,t))}% rendered`,document:(e,t)=>`${String(e)} of ${String(t)}`},cF={audio_intro:`intro`,audio_body:`body`,audio_outro:`outro`};function lF(e,t,n,r=!1){let i=t.filter(t=>t.stageKind===e.kind);switch(e.state){case`skipped`:return`Not part of this run`;case`pending`:return n.status===`paused`||r?`Waits until you continue the run`:e.retryAt===void 0?e.kind===`images`||e.kind===`thumbnail`&&e.source===`from_prompt`?`Ready to run`:`Waits for the stages above`:`Trying again at ${pF(e.retryAt)}`;case`provided`:return gF(i)??`Provided`;case`failed`:return`Stopped after ${mF(e)}`;case`canceled`:return`Canceled by user`;case`running`:return oF(e,n.config)?`Preparing subtitles · ${String(yF(e.progressCurrent??0,35))}%`:e.activity===void 0?e.kind===`video`&&iF(n.config)===`audio`?`Exporting combined audio`:e.progressTotal===null||e.progressTotal<=0?`Running`:sF[e.kind](e.progressCurrent??0,e.progressTotal):dF(uF(e)??``);case`done`:return hF(e.kind,i,n)}}function uF(e){let t=e.activity;if(t!==void 0)return t.percent===void 0?t.done!==void 0&&t.total!==void 0?`${t.label} (${String(t.done)} of ${String(t.total)})`:t.label:`${t.label} (${String(t.percent)}%)`}function dF(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function fF(e){let t=e.activity;if(t?.percent!==void 0)return t.percent/100;if(t?.done!==void 0&&t.total!==void 0&&t.total>0)return t.done/t.total;if(t===void 0&&!(e.progressTotal===null||e.progressTotal<=0))return Math.min(1,Math.max(0,(e.progressCurrent??0)/e.progressTotal))}function pF(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function mF(e){return e.attemptCount===1?`1 attempt`:`${String(e.attemptCount)} attempts`}function hF(e,t,n){switch(e){case`research`:return`Notes ready`;case`article`:{let e=t.filter(e=>e.role===`sources`||e.role===`glossary`);return e.length===0?`Article ready`:`Article and ${String(e.length)} end-matter files`}case`audio`:return CF([xF(t.flatMap(e=>{let t=cF[e.role];return t===void 0?[]:[t]})),vF(_F(t))]);case`images`:return bF(t.filter(e=>e.role===`image`).length,`image`);case`thumbnail`:return t.length===0?`Thumbnail ready`:`1 image`;case`video`:return CF([vF(_F(t)),iF(n.config)===`audio`?`WAV · stereo · 48 kHz`:n.format]);case`document`:return`PDF · ${iC(n.config.document)} theme`}}function gF(e){let t=e.flatMap(e=>e.originalFilename===null?[]:[e.originalFilename]);return t.length===0?void 0:t.join(`, `)}function _F(e){let t=Math.max(0,...e.map(e=>e.durationMs??0));return t===0?void 0:t}function vF(e){if(e===void 0||!Number.isFinite(e)||e<=0)return;let t=Math.round(e/1e3),n=[Math.floor(t/60)%60,t%60].map(e=>String(e).padStart(2,`0`)),r=Math.floor(t/3600);return r===0?n.join(`:`):[String(r),...n].join(`:`)}function yF(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function bF(e,t){return e===1?`1 ${t}`:`${String(e)} ${t}s`}function xF(e){if(e.length!==0)return e.length===1?SF(e[0]??``):SF(`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]??``}`)}function SF(e){return e.charAt(0).toUpperCase()+e.slice(1)}function CF(e){return e.filter(e=>e!==void 0&&e!==``).join(` · `)}var wF=12,TF=16;function EF(e,t,n){return Math.max(t,Math.min(e,Math.max(t,n)))}function DF(e,t,n){let r=Math.min(n.width,t.width-24),i=EF(e?.left??(t.width-r)/2,wF,t.width-r-wF),a=EF((e?.top??0)+((e?.height??t.height)-n.height)/2,wF,t.height-n.height-wF),o=t.height-n.height-wF;if(!e)return{left:i,top:a,width:r,docked:!1};let s=e.left+e.width,c=e.top+e.height;return s+TF+r<=t.width-wF?{left:s+TF,top:a,width:r,docked:!1}:e.left-TF-r>=wF?{left:e.left-TF-r,top:a,width:r,docked:!1}:c>=wF&&c+TF+n.height<=t.height-wF?{left:i,top:c+TF,width:r,docked:!1}:e.top-TF-n.height>=wF&&e.top<=t.height-wF?{left:i,top:e.top-TF-n.height,width:r,docked:!1}:{left:t.width-r-wF,top:Math.max(wF,o),width:r,docked:!0}}function OF(e,t,n=t.height){let r=EF(e.left-6,0,t.width),i=EF(e.top-6,0,Math.min(n,t.height)),a=EF(e.left+e.width+6,0,t.width),o=EF(e.top+e.height+6,0,Math.min(n,t.height));return a>r&&o>i?{left:r,top:i,width:a-r,height:o-i}:null}var kF=`[data-slot="select-content"], [data-slot="dropdown-menu-content"], [data-slot="menu-content"]`;function AF(e){try{return document.querySelector(e)}catch{return null}}function jF(){return[...document.querySelectorAll(`[data-slot="dialog-content"][data-state="open"]`)].at(-1)??null}function MF(e){if(!e)return[];let t=[e,...e.querySelectorAll(`[aria-controls]`)],n=new Set(t.flatMap(e=>(e.getAttribute(`aria-controls`)??``).split(` `)));return[...document.querySelectorAll(kF)].filter(e=>n.has(e.id))}function NF(e){let t=e.getBoundingClientRect();return t.width>0&&t.height>0?{left:t.left,top:t.top,width:t.width,height:t.height}:null}var PF=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable="true"]`;function FF(e,t,n,r){let i=(0,m.useRef)(document.activeElement),a=(0,m.useRef)(t);a.current=t,(0,m.useEffect)(()=>{let e=i.current;return()=>{queueMicrotask(()=>{e instanceof HTMLElement&&e.isConnected&&!n.current&&e.focus({preventScroll:!0})})}},[n]),(0,m.useEffect)(()=>{let t=()=>{let t=AF(e);return[t,n.current,...MF(t)].filter(e=>e!==null)},i=e=>e instanceof Node&&t().some(t=>t.contains(e)),o=e=>{jF()||i(e.target)||(e.preventDefault(),e.stopImmediatePropagation())},s=e=>{jF()||i(e.target)||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-radix-focus-guard`)||r.current?.focus({preventScroll:!0})},c=n=>{if(jF())return;let r=MF(AF(e));if(n.key===`Escape`){if(r.length>0)return;n.preventDefault(),n.stopImmediatePropagation(),a.current();return}if(n.key!==`Tab`){i(n.target)||o(n);return}if(r.length>0)return;let s=t().flatMap(e=>[e,...e.querySelectorAll(PF)]).filter((e,t,n)=>n.indexOf(e)===t&&e.tabIndex>=0&&!e.matches(`:disabled, [hidden], [aria-hidden='true']`)&&!e.closest(`[hidden], [inert]`)&&(!e.closest(`details:not([open])`)||e.closest(`summary`)!==null));if(s.length===0)return;let c=s.indexOf(document.activeElement),l=c===-1?n.shiftKey?s.length-1:0:(c+(n.shiftKey?-1:1)+s.length)%s.length;n.preventDefault(),s[l]?.focus()},l=[`pointerdown`,`pointerup`,`mousedown`,`mouseup`,`click`,`dblclick`,`contextmenu`];for(let e of l)window.addEventListener(e,o,!0);return window.addEventListener(`keydown`,c,!0),window.addEventListener(`focusin`,s,!0),()=>{for(let e of l)window.removeEventListener(e,o,!0);window.removeEventListener(`keydown`,c,!0),window.removeEventListener(`focusin`,s,!0)}},[e,n,r])}function IF(e,t,n,r,i,a){let[o,s]=(0,m.useState)(()=>({key:e,target:null,portals:[],width:window.innerWidth,height:window.innerHeight,cardHeight:260,modalOpen:jF()!==null}));return(0,m.useLayoutEffect)(()=>{let o=0,c=0,l=null,u=null,d=new Map,f=new ResizeObserver(()=>h()),p=e=>{for(let[t,n]of d)e.has(t)||(t.style.zIndex=n,d.delete(t))},m=()=>{o=0;let r=AF(t);r!==u&&(u&&f.unobserve(u),r&&f.observe(r),u=r);let i=r?NF(r):null;r&&i&&l!==r&&(l=r,cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,r.isConnected&&(r.scrollIntoView({block:`start`,inline:`nearest`,behavior:`instant`}),m())}));let a=MF(r),h=new Set;for(let e of a){let t=e.closest(`[data-radix-popper-content-wrapper]`)??e;h.add(t),d.has(t)||(d.set(t,t.style.zIndex),t.style.zIndex=`102`)}p(h);let g={key:e,target:i,portals:a.map(NF).filter(e=>e!==null),width:window.innerWidth,height:window.innerHeight,cardHeight:n.current?.getBoundingClientRect().height||260,modalOpen:jF()!==null};s(e=>JSON.stringify(e)===JSON.stringify(g)?e:g)};function h(){o||=requestAnimationFrame(m)}let g=new MutationObserver(e=>{e.some(e=>!i.current?.contains(e.target)&&e.target!==a.current)&&h()});return g.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`id`,`class`,`style`,`hidden`,`aria-controls`,`data-state`,`data-tour`]}),n.current&&f.observe(n.current),f.observe(document.documentElement),window.addEventListener(`resize`,h),window.addEventListener(`scroll`,h,!0),window.visualViewport?.addEventListener(`resize`,h),window.visualViewport?.addEventListener(`scroll`,h),m(),jF()||r.current?.focus({preventScroll:!0}),()=>{cancelAnimationFrame(o),cancelAnimationFrame(c),f.disconnect(),g.disconnect(),window.removeEventListener(`resize`,h),window.removeEventListener(`scroll`,h,!0),window.visualViewport?.removeEventListener(`resize`,h),window.visualViewport?.removeEventListener(`scroll`,h),p(new Set)}},[e,t,n,r,i,a]),o}function LF({stepId:e,target:t,title:n,children:r,progress:i,onNext:a,onBack:o,onClose:s,nextLabel:c=`Next`,nextDisabled:l=!1,onSkip:u,skipLabel:d=`Skip this step`}){let f=(0,m.useId)(),p=`${e}:${t}`,g=(0,m.useRef)(null),_=(0,m.useRef)(null),v=(0,m.useRef)(null),y=(0,m.useRef)(null),b=IF(p,t,g,_,v,y);FF(t,s,g,_);let[x,S]=(0,m.useState)({key:p,height:0}),C=b.key===p?b.target:null,w={width:b.width,height:b.height},T={width:Math.min(360,w.width-24),height:b.cardHeight},E=DF(C,w,T),D=C?OF(C,w,E.docked?E.top-12:w.height):null,O=b.key===p?b.portals.map(e=>OF(e,w)).filter(e=>e!==null):[],k=[...D?[D]:[],...O],A=`M0 0H${w.width}V${w.height}H0Z`+(D?`M${D.left} ${D.top}H${D.left+D.width}V${D.top+D.height}H${D.left}Z`:``);(0,m.useLayoutEffect)(()=>{S(e=>{let t=Math.max(e.key===p?e.height:0,E.docked?T.height+24:0);return e.key===p&&e.height===t?e:{key:p,height:t}})},[p,E.docked,T.height]);let j=x.key===p?x.height:0;return(0,m.useEffect)(()=>{let e=document.documentElement,t=e.style.scrollPaddingBottom;return e.style.scrollPaddingBottom=`${j}px`,()=>{e.style.scrollPaddingBottom=t}},[j]),(0,sd.createPortal)((0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{ref:y,"aria-hidden":`true`,style:{height:j}}),(0,h.jsxs)(`div`,{ref:v,hidden:b.modalOpen,"data-tutorial":`spotlight`,className:`pointer-events-none fixed inset-0 z-[100] font-sans`,children:[(0,h.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 h-full w-full`,width:w.width,height:w.height,children:[(0,h.jsx)(`defs`,{children:(0,h.jsxs)(`mask`,{id:`${f}-mask`,children:[(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`white`}),k.map(e=>(0,h.jsx)(`rect`,{x:e.left,y:e.top,width:e.width,height:e.height,rx:`6`,fill:`black`},`${e.left}:${e.top}:${e.width}:${e.height}`))]})}),(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`rgb(0 0 0 / 0.72)`,mask:`url(#${f}-mask)`}),(0,h.jsx)(`path`,{d:A,fill:`transparent`,fillRule:`evenodd`,pointerEvents:`fill`}),D&&(0,h.jsx)(`rect`,{"data-tutorial":`hole`,x:D.left,y:D.top,width:D.width,height:D.height,rx:`6`,fill:`none`,stroke:`var(--color-accent)`,strokeWidth:`2`})]}),(0,h.jsxs)(`section`,{ref:g,"aria-label":`Interactive getting started guide`,"aria-describedby":`${f}-instructions`,"data-tutorial":`card`,className:`pointer-events-auto fixed z-[101] flex flex-col gap-3 rounded-media border border-line-strong bg-surface p-4 text-body text-ink shadow-[var(--shadow-pop)]`,style:{left:E.left,top:E.top,width:E.width,maxHeight:Math.min(w.height-24,Math.max(160,Math.min(420,w.height*.48)))},children:[(0,h.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,h.jsxs)(`span`,{className:`engraved text-accent-ink`,children:[`Getting started · `,i]}),(0,h.jsx)(R,{variant:`quiet`,onClick:s,"aria-label":`Exit guide`,className:`h-7 px-2`,children:`Exit`})]}),(0,h.jsx)(`h2`,{ref:_,id:`${f}-title`,tabIndex:-1,className:`shrink-0 text-title-3 font-bold outline-none`,children:n}),(0,h.jsxs)(`div`,{id:`${f}-instructions`,className:`min-h-0 overflow-y-auto text-ink-2 [&_p+p]:mt-2 [&_code]:text-ink`,children:[r,!C&&(0,h.jsx)(`p`,{role:`status`,className:`mt-3 text-waiting`,children:`This section is not available yet. Wait for the page to load, go back, or exit the guide.`}),E.docked&&C&&(0,h.jsx)(`p`,{className:`mt-3 text-small`,children:`Scroll the page to work through the highlighted section.`})]}),(0,h.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-line pt-3`,children:[o&&(0,h.jsx)(R,{onClick:o,children:`Back`}),u&&(0,h.jsx)(R,{variant:`quiet`,onClick:u,className:`px-2`,children:d}),(0,h.jsx)(R,{variant:`primary`,onClick:a,disabled:l||!C,className:`ml-auto`,children:c})]})]})]})]}),document.body)}function RF({href:e,children:t}){return(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-ink underline underline-offset-2`,children:t})}function zF({text:e}){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(!1);return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`p`,{className:`select-text rounded-control border border-line-strong bg-raised p-3 text-small leading-relaxed`,children:e}),(0,h.jsx)(R,{onClick:()=>{if(i(!1),!navigator.clipboard){i(!0);return}navigator.clipboard.writeText(e).then(()=>n(!0),()=>i(!0))},children:t?`Copied`:`Copy example`}),r?(0,h.jsx)(`p`,{role:`status`,children:`Select the example above and copy it manually.`}):null]})}var BF={signUp:{label:`platform.openai.com/signup`,url:`https://platform.openai.com/signup`},keyPage:{label:`platform.openai.com/api-keys`,url:`https://platform.openai.com/api-keys`},billing:{label:`Billing`,url:`https://platform.openai.com/settings/organization/billing/overview`},steps:[`Sign up or sign in to the OpenAI platform.`,`Open Billing and buy prepaid credit (new accounts need at least $5 before any call works).`,`Open API keys, choose Create new secret key, and copy it (it is shown once).`,`Paste it here, choose Save, then Test.`],permissions:`A key with All permissions works. A restricted key needs Models: Read (for Test) and Model capabilities: Request (for speech and images). GPT Image models may also need Verify Organization under Settings → Organization → General on the OpenAI platform.`,docs:{label:`OpenAI API docs`,url:`https://developers.openai.com/api/docs/guides/error-codes`}},VF={signUp:{label:`aistudio.google.com`,url:`https://aistudio.google.com`},keyPage:{label:`aistudio.google.com/apikey`,url:`https://aistudio.google.com/apikey`},billing:{label:`Projects → Set up billing`,url:`https://aistudio.google.com/projects`},steps:[`Sign in to Google AI Studio with your Google account.`,`Open Projects and choose Set up billing next to your project: Gemini image models are not available on the free tier.`,`Open API keys, choose Create API key, and copy it.`,`Paste it here, choose Save, then Test.`],permissions:`Use a key made in AI Studio. An older Google Cloud key must be set to Restrict to Gemini API only, or Google rejects it.`,docs:{label:`Gemini API keys`,url:`https://ai.google.dev/gemini-api/docs/api-key`}},HF={openrouter:{signUp:{label:`openrouter.ai/sign-up`,url:`https://openrouter.ai/sign-up`},keyPage:{label:`openrouter.ai/settings/keys`,url:`https://openrouter.ai/settings/keys`},billing:{label:`Credits`,url:`https://openrouter.ai/settings/credits`},steps:[`Sign up at OpenRouter.`,`Open Credits and buy credit (paid models are charged from it; a negative balance stops even free models).`,`Open Keys, choose Create API key, and copy it.`,`Paste it here, choose Save, then Test.`],permissions:`Keys have no scopes. If you set a credit limit on the key, keep it above what a run costs.`,docs:{label:`OpenRouter docs`,url:`https://openrouter.ai/docs/api-reference/limits`}},"openai-tts":BF,"openai-image":BF,"google-image":VF,"google-tts":{...VF,steps:[`Sign in to Google AI Studio with your Google account.`,`Open API keys, choose Create API key, and copy it.`,`Paste it here, choose Save, then Test.`],permissions:`The same Gemini API key as Google images: with one saved there, Gemini voices use it and nothing is needed here. ${VF.permissions}`},fal:{signUp:{label:`fal.ai/login`,url:`https://fal.ai/login`},keyPage:{label:`fal.ai/dashboard/keys`,url:`https://fal.ai/dashboard/keys`},billing:{label:`Billing`,url:`https://fal.ai/dashboard/billing`},steps:[`Sign up at fal.ai.`,`Open Billing and buy credit: fal.ai is prepaid and locks the account when the balance runs out.`,`Open Keys, choose Add key with the API scope, and copy it.`,`Paste it here, choose Save, then Test.`],permissions:`The API scope is enough; Slopify does not need an ADMIN key.`,docs:{label:`fal.ai authentication`,url:`https://fal.ai/docs/model-apis/authentication`}},replicate:{signUp:{label:`replicate.com/signin`,url:`https://replicate.com/signin`},keyPage:{label:`replicate.com/account/api-tokens`,url:`https://replicate.com/account/api-tokens`},billing:{label:`Billing`,url:`https://replicate.com/account/billing`},steps:[`Sign in to Replicate.`,`Open Billing and buy credit: Replicate needs credit up front before it runs paid models.`,`Open API tokens, create a token, and copy it (it starts with r8_).`,`Paste it here, choose Save, then Test.`],permissions:`Tokens have no scopes.`,docs:{label:`Replicate billing`,url:`https://replicate.com/docs/topics/billing`}},elevenlabs:{signUp:{label:`elevenlabs.io/app/sign-up`,url:`https://elevenlabs.io/app/sign-up`},keyPage:{label:`elevenlabs.io/app/developers/api-keys`,url:`https://elevenlabs.io/app/developers/api-keys`},steps:[`Sign up at ElevenLabs.`,`Open Developers → API keys, choose Create key, and copy it.`,`Paste it here, choose Save, then Test.`],permissions:`A restricted key needs Text to Speech access and Models read access (models_read) for Test; Voices read helps when picking voices. Remove any credit quota or IP allowlist that would block this computer.`,docs:{label:`ElevenLabs API keys`,url:`https://elevenlabs.io/docs/api-reference/models/list`}},cartesia:{signUp:{label:`play.cartesia.ai/sign-up`,url:`https://play.cartesia.ai/sign-up`},keyPage:{label:`play.cartesia.ai/keys`,url:`https://play.cartesia.ai/keys`},steps:[`Sign up at Cartesia (the free plan needs no card).`,`Open API Keys, create a key, and copy it (it starts with sk_car_).`,`Paste it here, choose Save, then Test.`],permissions:`Keys have no scopes.`,docs:{label:`Cartesia authentication`,url:`https://docs.cartesia.ai/get-started/authenticate-your-client-applications`}},inworld:{signUp:{label:`platform.inworld.ai/signup`,url:`https://platform.inworld.ai/signup`},keyPage:{label:`platform.inworld.ai/api-keys`,url:`https://platform.inworld.ai/api-keys`},billing:{label:`Billing`,url:`https://platform.inworld.ai/billing`},steps:[`Sign up at the Inworld platform.`,`Open API Keys and choose Generate new key (a Standard key, not Realtime-only).`,`Copy the Base64 credentials value exactly as shown, without encoding it again.`,`Paste it here, choose Save, then Test.`],permissions:`A Standard key covers speech and reading voices. Realtime-only keys do not work.`,docs:{label:`Inworld API keys`,url:`https://docs.inworld.ai/portal/api-keys`}}},UF=[`openrouter`,`claude-code`,`codex`,`gemini`,`elevenlabs`,`openai-tts`,`cartesia`,`inworld`,`system-voice`,`google-tts`,`fal`,`replicate`,`openai-image`,`google-image`,`codex-image`],WF=[{id:`openrouter`,family:`llm`,displayName:`OpenRouter`,auth:`key`},{id:`claude-code`,family:`llm`,displayName:`Claude Code CLI`,auth:`cli`,binary:`claude`,versionArgs:[`--version`]},{id:`codex`,family:`llm`,displayName:`Codex CLI`,auth:`cli`,binary:`codex`,versionArgs:[`--version`]},{id:`gemini`,family:`llm`,displayName:`Gemini CLI`,auth:`cli`,binary:`gemini`,versionArgs:[`--version`]},{id:`elevenlabs`,family:`tts`,displayName:`ElevenLabs`,auth:`key`},{id:`openai-tts`,family:`tts`,displayName:`OpenAI`,auth:`key`},{id:`cartesia`,family:`tts`,displayName:`Cartesia`,auth:`key`},{id:`inworld`,family:`tts`,displayName:`Inworld`,auth:`key`},{id:`system-voice`,family:`tts`,displayName:`System voice`,auth:`local`},{id:`google-tts`,family:`tts`,displayName:`Google Gemini`,auth:`key`},{id:`fal`,family:`image`,displayName:`fal.ai`,auth:`key`},{id:`replicate`,family:`image`,displayName:`Replicate`,auth:`key`},{id:`openai-image`,family:`image`,displayName:`OpenAI`,auth:`key`},{id:`google-image`,family:`image`,displayName:`Google`,auth:`key`},{id:`codex-image`,family:`image`,displayName:`Codex CLI`,auth:`cli`,binary:`codex`,versionArgs:[`--version`]}],GF=[{name:`Zephyr`,style:`Bright`},{name:`Puck`,style:`Upbeat`},{name:`Charon`,style:`Informative`},{name:`Kore`,style:`Firm`},{name:`Fenrir`,style:`Excitable`},{name:`Leda`,style:`Youthful`},{name:`Orus`,style:`Firm`},{name:`Aoede`,style:`Breezy`},{name:`Callirrhoe`,style:`Easy-going`},{name:`Autonoe`,style:`Bright`},{name:`Enceladus`,style:`Breathy`},{name:`Iapetus`,style:`Clear`},{name:`Umbriel`,style:`Easy-going`},{name:`Algieba`,style:`Smooth`},{name:`Despina`,style:`Smooth`},{name:`Erinome`,style:`Clear`},{name:`Algenib`,style:`Gravelly`},{name:`Rasalgethi`,style:`Informative`},{name:`Laomedeia`,style:`Upbeat`},{name:`Achernar`,style:`Soft`},{name:`Alnilam`,style:`Firm`},{name:`Schedar`,style:`Even`},{name:`Gacrux`,style:`Mature`},{name:`Pulcherrima`,style:`Forward`},{name:`Achird`,style:`Friendly`},{name:`Zubenelgenubi`,style:`Casual`},{name:`Vindemiatrix`,style:`Gentle`},{name:`Sadachbia`,style:`Lively`},{name:`Sadaltager`,style:`Knowledgeable`},{name:`Sulafat`,style:`Warm`}];function KF(e){return WF.flatMap(t=>{let n=t.auth===`key`?HF[t.id]:void 0;return t.family===e&&n!==void 0?[{id:t.id,name:t.displayName,url:n.keyPage.url}]:[]})}function qF({family:e}){return(0,h.jsx)(`p`,{children:KF(e).map((e,t)=>(0,h.jsxs)(`span`,{children:[t===0?null:` · `,(0,h.jsx)(RF,{href:e.url,children:`${e.name} keys`})]},e.id))})}function JF(e){let t=KF(e).map(e=>e.name);return t.length<2?t[0]??``:`${t.slice(0,-1).join(`, `)} or ${t.at(-1)??``}`}function YF({step:e}){switch(e){case`text-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`First, choose what will write your scripts. You only need one text provider.`}),(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Sign in to`,` `,(0,h.jsx)(RF,{href:HF.openrouter?.keyPage.url??`https://openrouter.ai`,children:`OpenRouter`}),`, create an API key, and make sure the account can use your chosen model.`]}),(0,h.jsxs)(`li`,{children:[`Paste it into OpenRouter’s `,(0,h.jsx)(`strong`,{children:`API key`}),` field here, press`,` `,(0,h.jsx)(`strong`,{children:`Test`}),` to check it, then `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]})]}),(0,h.jsx)(`p`,{children:`Already using Claude Code, Codex or Gemini CLI? You can use its existing CLI login instead. “Installed” means Slopify found the CLI; sign in through that CLI before generating. If it is missing, enter its executable path and save to check again.`}),(0,h.jsx)(`p`,{className:`text-ink-3`,children:`These are the real Settings controls. The tutorial never reads your key. Skip any step you have already handled.`})]});case`audio-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The voice provider turns the finished article into audio. Choose `,JF(`tts`),`; you only need one.`]}),(0,h.jsxs)(`p`,{children:[`Create a key in your provider’s account, enable the API access or credits it requires, then paste the key into its row, press `,(0,h.jsx)(`strong`,{children:`Test`}),` to check it, and press`,` `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsx)(qF,{family:`tts`}),(0,h.jsx)(`p`,{children:`Next, you’ll add the exact voice that this provider should use. Skip voice setup if you plan to provide your own narration or turn Audio Off.`})]});case`image-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Choose one image provider (`,JF(`image`),`), create a key in its dashboard, paste it into the matching row, press `,(0,h.jsx)(`strong`,{children:`Test`}),` to check it, and press`,` `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsx)(qF,{family:`image`}),(0,h.jsxs)(`p`,{children:[`A saved key is not a billing check. The selected image model needs available quota. If Google reports `,(0,h.jsx)(`strong`,{children:`limit: 0`}),`, check the key’s project, billing and image-model quota before retrying.`]}),(0,h.jsx)(`p`,{children:`OpenAI’s voice and image rows are saved separately, even when you use the same API key. Skip this step if you plan to provide your own images or turn Images and Thumbnail Off.`})]});case`voice`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Voice name`}),` you will recognize, such as “Travel narrator.”`]}),(0,h.jsxs)(`li`,{children:[`Select the `,(0,h.jsx)(`strong`,{children:`Provider`}),` whose voice key you saved.`]}),(0,h.jsxs)(`li`,{children:[`Copy the exact `,(0,h.jsx)(`strong`,{children:`Voice ID`}),` from that provider’s voice library or documentation.`]}),(0,h.jsxs)(`li`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Add voice`}),`.`]})]}),(0,h.jsx)(`p`,{children:`The name is your label; the ID tells the provider which voice to use. Slopify checks the ID with the provider when narration runs. A voice is only required when Audio is set to Generate.`})]})}}var XF=`Write a 150-word narration about {{topic}} for {{audience}}. Open with an interesting fact, explain three highlights, and end with one memorable takeaway. Use natural spoken English. Return only the narration, without headings or stage directions.`,ZF=`A cinematic editorial photograph of {{topic}}, with natural light, a clear focal point, rich detail, and no text or logos. Compose it for a travel video.`;function QF({step:e,output:t=`video`}){switch(e){case`text-key`:case`audio-key`:case`image-key`:case`voice`:return(0,h.jsx)(YF,{step:e});case`article-name`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`A prompt is a reusable set of instructions. This one will write the narration for each video.`}),(0,h.jsxs)(`p`,{children:[`Give it a recognizable name, such as `,(0,h.jsx)(`strong`,{children:`Short travel narration`}),`. This is the prompt’s library name, not your video’s title.`]}),(0,h.jsx)(`p`,{children:`The next steps will add its instructions and reusable keywords.`})]});case`article-body`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Tell the model what to write, who it is for, the length, and the style. Put anything you want to change between runs inside double braces.`}),(0,h.jsx)(zF,{text:XF}),(0,h.jsxs)(`p`,{children:[`Paste or write the instructions in `,(0,h.jsx)(`strong`,{children:`Body`}),`. `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` `,`and `,(0,h.jsx)(`strong`,{children:`{{audience}}`}),` will become fields on Play.`]})]});case`article-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`This panel detects your keywords as you type. With the example, it should list`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`{{topic}}`}),` is a field name, not the value. You will enter “Albania” on Play later. Repeated names use the same value; names are case-sensitive, so`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`Topic`}),` are different.`]}),(0,h.jsxs)(`p`,{children:[`There are no automatic keywords: `,(0,h.jsx)(`strong`,{children:`{{title}}`}),` would also ask you for a value. Fix any keyword warnings in Body before saving.`]})]});case`article-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press the highlighted `,(0,h.jsx)(`strong`,{children:`Save`}),` button in the editor. The prompt will appear in your Article library.`]}),(0,h.jsx)(`p`,{children:`The tour continues when the save succeeds and the editor returns to the prompt list. If a name is already taken, go Back and choose another.`})]});case`image-prompt`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Keep `,(0,h.jsx)(`strong`,{children:`Kind`}),` on `,(0,h.jsx)(`strong`,{children:`Image`}),`. Name this prompt`,` `,(0,h.jsx)(`strong`,{children:`Travel imagery`}),`, then enter this example or your own visual instructions.`]}),(0,h.jsx)(zF,{text:ZF}),(0,h.jsxs)(`p`,{children:[`Using `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` in both prompts creates one shared field on Play. Image prompts describe the picture directly; they do not automatically receive your article.`]})]});case`image-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Save`}),` to add this to your Image library. Next you will combine both prompts on Play.`]}),(0,h.jsx)(`p`,{children:`You can create more prompts later for different subjects, styles, lengths, or languages.`})]});case`play-article`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Play is where you configure one project. Leave `,(0,h.jsx)(`strong`,{children:`Article`}),` on`,` `,(0,h.jsx)(`strong`,{children:`Generate`}),`, then select the article prompt you saved.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`Provide`}),` is for an article you already have. For this first run, use Generate and keep the script short. Article is required; every other stage can be Off.`]}),(0,h.jsx)(`p`,{children:`Research starts Off. You can turn it on in a later run for web-grounded notes that are automatically passed to the article writer.`})]});case`play-audio`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Audio`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Pick your voice`,` `,(0,h.jsx)(`strong`,{children:`TTS`}),` provider, a `,(0,h.jsx)(`strong`,{children:`TTS model`}),`, then the saved`,` `,(0,h.jsx)(`strong`,{children:`Voice`}),`.`]}),(0,h.jsxs)(`p`,{children:[`Keep `,(0,h.jsx)(`strong`,{children:`Chunking`}),` (under `,(0,h.jsx)(`strong`,{children:`Audio Advanced`}),`) on`,` `,(0,h.jsx)(`strong`,{children:`Whole`}),` for the short example: the narration is sent as one request. Other chunking modes split longer text into pieces. `,(0,h.jsx)(`strong`,{children:`Speakers`}),` is where an audiobook or podcast gets more than one voice; leave it on one voice for now.`]}),(0,h.jsx)(`p`,{children:`Use Provide to upload existing narration, including any intro and outro in that file, or Off to skip narration. Video can still run silently, with each image shown for 5 seconds.`})]});case`play-images`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Images`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Choose the image`,` `,(0,h.jsx)(`strong`,{children:`Provider`}),` and `,(0,h.jsx)(`strong`,{children:`Model`}),`, tick your image prompt, and type`,` `,(0,h.jsx)(`strong`,{children:`2`}),` in the number box beside it for a small first run.`]}),(0,h.jsx)(`p`,{children:`The number means separate images made from that same prompt. It does not make one scene per article paragraph. Add more image prompts when you want different scenes.`}),(0,h.jsx)(`p`,{children:`Use Provide for your own images or Off to skip them. Turning Images Off also turns Video Off. Thumbnail remains independent; keep it Off for this first run.`})]});case`play-video`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`On `,(0,h.jsx)(`strong`,{children:`Export`}),`, choose `,(0,h.jsx)(`strong`,{children:`Generate`}),` for an MP4 slideshow. It needs generated or provided images. With Audio Off, the video is silent and each image lasts 5 seconds.`]}),(0,h.jsxs)(`p`,{children:[`Choose `,(0,h.jsx)(`strong`,{children:`Off`}),` to skip video. If Audio is active, Slopify exports one combined `,(0,h.jsx)(`strong`,{children:`WAV`}),` with the intro, body, outro and configured gaps.`]}),(0,h.jsx)(`p`,{children:`If both Audio and Video are Off, download the article and any other enabled outputs individually.`})]});case`play-subtitles`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Subtitles are optional and start `,(0,h.jsx)(`strong`,{children:`Off`}),`. Choose`,` `,(0,h.jsx)(`strong`,{children:`Subtitle files`}),` for SRT and VTT downloads, or`,` `,(0,h.jsx)(`strong`,{children:`Burn into video + files`}),` to keep captions visible in an MP4.`]}),(0,h.jsxs)(`p`,{children:[`English captions are timed locally from your narration with no paid API. First use downloads an approximately `,(0,h.jsx)(`strong`,{children:`95 MB`}),` speech model. Audio must be active; WAV exports support separate subtitle files.`]}),(0,h.jsx)(`p`,{children:`Pick a font or upload a TTF/OTF file, then adjust its size in the preview. Styling applies to burned captions. You can also add or change subtitles on a completed project later without regenerating its narration.`})]});case`play-options`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Project title`}),`, such as “A quick trip to Albania.” Set the title in Content.`]}),(0,h.jsxs)(`p`,{children:[`Select the text `,(0,h.jsx)(`strong`,{children:`LLM`}),` and `,(0,h.jsx)(`strong`,{children:`Text model`}),`. The model list loads for your provider. Use `,(0,h.jsx)(`strong`,{children:`Refresh`}),` for updated choices or`,` `,(0,h.jsx)(`strong`,{children:`Custom ID`}),`to enter an exact model ID when supported.`]}),(0,h.jsx)(`p`,{children:`Intro and Outro are available in Outputs when Audio is Generate. The LLM controls appear only when an enabled stage needs text generation.`})]});case`play-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The prompts you picked created these fields. For the examples, enter`,` `,(0,h.jsx)(`strong`,{children:`Albania`}),` for `,(0,h.jsx)(`strong`,{children:`topic`}),` and`,` `,(0,h.jsx)(`strong`,{children:`first-time travelers`}),` for `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsx)(`p`,{children:`Each keyword is asked once, with the prompts that use it named underneath. A keyword both prompts use feeds the article and the images, so changing it changes both for this run.`}),(0,h.jsx)(`p`,{children:`Fill every visible field. Each value must fit on one line and be no more than 200 characters. Your saved prompt keeps its braces so you can reuse it next time.`})]});case`play-start`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Review the enabled outputs, costs and readiness in Review. If anything is missing, use Back to fix the highlighted section.`}),(0,h.jsxs)(`p`,{children:[`When ready, press the real `,(0,h.jsx)(`strong`,{children:`Start run`}),` or `,(0,h.jsx)(`strong`,{children:`Queue N`}),` `,`button. This creates a project and sends generation requests to your chosen providers, which may charge your account.`]}),(0,h.jsx)(`p`,{children:`The tour will follow you to the project. You can also skip generating and go on to the screens you run a channel from.`})]});case`project`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The rail on the left lists the project's sections: Article, Narration, Images, Video and the rest. The right rail says where the run stands and offers the one thing to do next, named for its result: `,(0,h.jsx)(`strong`,{children:`Pause`}),` while it runs,`,` `,(0,h.jsx)(`strong`,{children:`Continue the run`}),` when it is paused, `,(0,h.jsx)(`strong`,{children:`Try images again`}),` `,`when a step fails.`]}),(0,h.jsxs)(`p`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Edit settings`}),` to change providers, models, voice, prompts or optional steps. `,(0,h.jsx)(`strong`,{children:`Save changes`}),` keeps a new revision without starting generation; what the change made outdated is then offered as the next action, such as`,` `,(0,h.jsx)(`strong`,{children:`Remake 3 outdated images`}),`. Earlier revisions stay in`,` `,(0,h.jsx)(`strong`,{children:`History`}),`.`]}),(0,h.jsxs)(`p`,{children:[`A failed step says why beside it; open `,(0,h.jsx)(`strong`,{children:`Error details`}),` for the provider's own message. Rare actions, such as making a whole stage again, sit behind each section's`,` `,(0,h.jsx)(`strong`,{children:`More`}),` button and in the command palette (Ctrl+K).`]})]});case`download`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[t===`audio`?(0,h.jsxs)(h.Fragment,{children:[`When Audio export finishes, press `,(0,h.jsx)(`strong`,{children:`Download`}),`, then`,` `,(0,h.jsx)(`strong`,{children:`Audio (.wav)`}),` for the combined narration.`]}):t===`article`?(0,h.jsxs)(h.Fragment,{children:[`Use `,(0,h.jsx)(`strong`,{children:`Download`}),` here to save the article. Audio and Video are Off for this project.`]}):(0,h.jsxs)(h.Fragment,{children:[`When Video finishes, press `,(0,h.jsx)(`strong`,{children:`Download`}),`, then`,` `,(0,h.jsx)(`strong`,{children:`Video (.mp4)`}),`.`]}),` `,`The completed project stays in `,(0,h.jsx)(`strong`,{children:`Projects`}),` so you can return to it.`]}),(0,h.jsxs)(`p`,{children:[`Select Article, Audio or Images in the stage list on the `,(0,h.jsx)(`strong`,{children:`Output`}),` tab to download their outputs. `,(0,h.jsx)(`strong`,{children:`Download all`}),` under Images gives an image ZIP, not the video.`]}),(0,h.jsxs)(`p`,{children:[`If subtitles are enabled, download the `,(0,h.jsx)(`strong`,{children:`.srt`}),` or `,(0,h.jsx)(`strong`,{children:`.vtt`}),` `,`files beside the final export. File-mode captions are also available in the video player.`]})]});case`run-cost`:return(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`Cost`}),` in the project's sections shows what this run really cost, per stage and model. Totals for every project are in Settings, `,(0,h.jsx)(`strong`,{children:`Usage`}),`.`]});case`studio-prep`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Slopify never uploads for you. When the video is made, `,(0,h.jsx)(`strong`,{children:`Prepare upload`}),` `,`is the next action: it lists everything YouTube Studio asks for, in the order it asks, from the file and title to the thumbnail, tags and the AI disclosure.`]}),(0,h.jsxs)(`p`,{children:[`The browser extension in Settings, `,(0,h.jsx)(`strong`,{children:`YouTube Studio`}),`, can fill those in for you.`]})]});case`home`:return(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`Home`}),` is the day at a glance: what needs you, what is running and at which step, what is coming up this week and what is ready to upload.`]});case`channels`:return(0,h.jsxs)(`p`,{children:[`A `,(0,h.jsx)(`strong`,{children:`channel`}),` keeps its brand kit, series brief, templates, schedules and a cast that looks the same in every video. It also remembers finished episodes and your existing videos, so new topics do not repeat them.`]});case`calendar`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The `,(0,h.jsx)(`strong`,{children:`Calendar`}),` shows the coming weeks of uploads: what is ready, what needs you, and the topics a schedule suggested, waiting for your approval. Its`,` `,(0,h.jsx)(`strong`,{children:`Schedules`}),` tab is where you create, pause and resume the schedules that fill it.`]}),(0,h.jsx)(`p`,{children:`You have reached the end. Press the question-mark button at the foot of the sidebar anytime to walk through these steps again, or the book beside it for Help → Tutorials, the guides to every screen.`})]})}}function $F(e){return nF(e.readiness)}function eI({session:e,progress:t,update:n}){let{api:r}=z(),i=iP(),a=Xi(),o=Va(),s=P(ob(r)),c=P(cb(r)),l=P(lb(r)),u=P({...ib(r,e.projectId??``),enabled:e.projectId!==void 0}),[d,f]=(0,m.useState)(null),p=(0,m.useRef)(null),g=ZP[e.step],_=s.data?.seen===!0;if((0,m.useEffect)(()=>{if(!_||!g||p.current===e.step)return;if(p.current=e.step,g.page===`settings`){let e=g.id===`voice`?`voices`:`providers`;(o.pathname!==`/settings`||!o.searchStr.includes(`section=${e}`))&&a({to:`/settings`,search:{section:e}})}if(g.page===`article`||g.page===`image`){let t=g.page===`article`?e.articleId:e.imageId,n=o.pathname===`/prompts/new`&&o.searchStr.includes(`kind=${g.page}`);t&&o.pathname!==`/prompts/${t}`?a({to:`/prompts/$promptId`,params:{promptId:t}}):!t&&!n&&a({to:`/prompts/new`,search:{kind:g.page}})}g.page===`play`&&o.pathname!==`/play`&&a({to:`/play`});let t={home:`/`,channels:`/channels`,calendar:`/calendar`};if(g.page===`home`||g.page===`channels`||g.page===`calendar`){let e=t[g.page];o.pathname!==e&&a({to:e})}g.page===`project`&&e.projectId&&o.pathname!==`/projects/${e.projectId}`&&a({to:`/projects/$projectId`,params:{projectId:e.projectId}})},[_,g,e.step,e.articleId,e.imageId,e.projectId,o.pathname,o.searchStr,a]),(0,m.useEffect)(()=>{if(!_||g?.page!==`play`||o.pathname!==`/play`)return;let e=!0;return f(null),i.navigate(tF[g.id]).then(()=>{e&&f(g.id)}),()=>{e=!1}},[_,g,o.pathname,i.navigate]),(0,m.useEffect)(()=>{o.pathname===`/prompts`&&(g?.id===`image-prompt`&&e.imageId?n(e=>({...e,step:ZP.findIndex(e=>e.id===`play-options`)})):(g?.id===`article-save`&&e.articleId||g?.id===`image-save`&&e.imageId)&&n(e=>({...e,step:e.step+1})))},[o.pathname,g?.id,e.articleId,e.imageId,n]),!_||!g||g.page===`play`&&(d!==g.id||i.section!==tF[g.id]))return null;let v=c.data?.providers??[],y=e=>v.some(t=>t.family===e&&$F(t)),b=(l.data?.voices??[]).some(e=>v.some(t=>t.id===e.provider&&$F(t))),x={"text-key":y(`llm`),"audio-key":y(`tts`),"image-key":y(`image`),voice:b,"article-name":t.promptIsArticle===!0&&t.promptNamed===!0,"article-body":t.promptIsArticle===!0&&t.promptBodyReady===!0&&t.promptHasKeywords===!0,"article-keywords":t.promptHasKeywords===!0,"article-save":!1,"image-prompt":t.promptIsImage===!0&&t.promptSaveReady===!0&&t.promptHasKeywords===!0,"image-save":!1,"play-article":t.playArticleReady===!0,"play-audio":t.playAudioReady===!0,"play-images":t.playImagesReady===!0,"play-video":t.playVideoReady===!0,"play-subtitles":t.playSubtitlesReady===!0,"play-options":t.playOptionsReady===!0,"play-keywords":t.playKeywordsReady===!0,"play-start":!1},S=()=>n(e=>({...e,active:!1})),C=ZP.findIndex(e=>e.id===QP),w=e.step===ZP.length-1,T=()=>{w?S():g.id===`play-start`?n(e=>({...e,step:C})):n(e=>({...e,step:e.step+1}))},E=()=>n(t=>({...t,step:g.id===`home`&&e.projectId===void 0?ZP.findIndex(e=>e.id===`play-start`):t.step-1})),D=u.data?iF(u.data.project.config):`video`,O=g.id===`download`&&D===`article`?`project-article`:g.id===`play-keywords`&&t.playHasKeywords===!1?`play-options`:g.id===`studio-prep`&&D!==`video`?`project-controls`:g.target,k=g.id===`article-save`||g.id===`image-save`,A=(g.page===`article`||g.page===`image`)&&t.promptSaving===!0;return(0,h.jsxs)(LF,{stepId:g.id,target:`[data-tour="${O}"]`,title:g.title,progress:`${e.step+1} of ${ZP.length} · First project`,onClose:S,...e.step===0||g.id===`project`||A?{}:{onBack:E},onNext:T,nextDisabled:A||x[g.id]===!1,nextLabel:k?`Use Save in the editor`:g.id===`play-start`?`Use Start run / Queue N on the page`:w?`Finish tutorial`:`Next`,...A?{}:{onSkip:T},skipLabel:g.id===`play-start`?`Skip generating`:k?`Skip without saving`:`Skip this step`,children:[(0,h.jsx)(QF,{step:g.id,output:D}),c.error||l.error?(0,h.jsx)(`p`,{className:`text-danger`,children:c.error?.message??l.error?.message}):null]})}var tI=q({schemaVersion:mO(1),active:KD(),stepId:J([`text-key`,`audio-key`,`image-key`,`voice`,`article-name`,`article-body`,`article-keywords`,`article-save`,`image-prompt`,`image-save`,`play-options`,`play-article`,`play-keywords`,`play-audio`,`play-images`,`play-video`,`play-subtitles`,`play-start`,`project`,`download`,`run-cost`,`studio-prep`,`home`,`channels`,`calendar`]),articleId:W().optional(),imageId:W().optional(),projectId:W().optional()}).strict();q({baseVersion:G().int().nonnegative(),mutationId:TD(),session:tI}).strict();var nI=q({version:G().int().nonnegative(),session:tI,readable:KD()}).strict();async function rI(e){let t=await I(await e.client.tutorial.$get()),n=nI.safeParse(t);return n.success?n.data:{version:0,readable:!1,session:{schemaVersion:1,active:!1,stepId:`text-key`}}}async function iI(e,t){return nI.parse(await I(await e.client.tutorial.$put({json:t})))}async function aI(e){let t=await e.client.tutorial.$delete();if(!t.ok)throw await fo(t)}function oI(){let{api:e}=z(),[t,n]=(0,m.useState)({active:!1,step:0}),[r,i]=(0,m.useState)(null),a=(0,m.useMemo)(()=>{let t={active:!1,step:0},r=0,a=!1,o=!1,s=0,c=!0,l=!1,u=!1,d=null,f=[],p=[],m=e=>i(e instanceof Error?e.message:`Your tutorial progress wasn't saved. You can keep going; it will try again on the next step.`),h=async()=>{if(!u&&a&&c){u=!0;try{for(;d||p.length>0;){if(!d){let e=p.shift();if(!e)break;let t=ZP[e.step];if(!t)throw Error(`This tutorial step isn't recognised. Choose Restart tutorial to start over.`);let{step:n,...i}=e;d={baseVersion:r,mutationId:crypto.randomUUID(),session:{...i,schemaVersion:1,stepId:t.id}}}r=(await iI(e,d)).version,d=null}i(null)}catch(e){m(e)}finally{u=!1}}},g=e=>{if(!a){f.push(e);return}let r=typeof e==`function`?e(t):e;r!==t&&(t=r,n(t),p.push(t),h())},_=()=>{if(!a){l=!0;return}if(!c){i(`Saved tutorial progress cannot be read. Choose Restart tutorial to recover.`);return}g({active:!0,step:0})},v=async()=>{if(o||a)return;o=!0;let u=s;try{let o=await rI(e);if(u!==s)return;if(r=o.version,c=o.readable,c||(a=!0),!c){i(`Saved tutorial progress cannot be read. Choose Restart tutorial to recover.`);return}let{schemaVersion:d,stepId:p,...m}=o.session;if(t={active:m.active,step:eF(p)??0,...m.articleId===void 0?{}:{articleId:m.articleId},...m.imageId===void 0?{}:{imageId:m.imageId},...m.projectId===void 0?{}:{projectId:m.projectId}},t.articleId||t.imageId){let{prompts:n}=await ks(e),{articleId:r,imageId:i,...a}=t;t={...a,...r!==void 0&&n.some(e=>e.id===r&&e.kind===`article`)?{articleId:r}:{},...i!==void 0&&n.some(e=>e.id===i&&e.kind===`image`)?{imageId:i}:{}}}if(t.projectId&&await jo(e,t.projectId),u!==s)return;a=!0,n(t);for(let e of f.splice(0))g(e);l&&_(),i(null)}catch(e){u===s&&m(e)}finally{o=!1}},y=async()=>{if(!u){u=!0,s++,f.length=0,l=!1;try{await aI(e),r=0,c=!0,a=!0,d=null,p.length=0,t={active:!0,step:0},n(t),p.push(t),i(null)}catch(e){m(e)}finally{u=!1}await h()}};return{update:g,start:_,restore:v,retry:()=>{a?h():v()},restart:()=>{y()}}},[e]);return(0,m.useEffect)(()=>{a.restore()},[a]),{session:t,update:a.update,start:a.start,retry:a.retry,restart:a.restart,error:r}}var sI=(0,m.createContext)(void 0);function cI({children:e}){let{session:t,update:n,start:r,retry:i,restart:a,error:o}=oI(),[s,c]=(0,m.useState)({}),l=(0,m.useCallback)(e=>{c(t=>Object.entries(e).every(([e,n])=>t[e]===n)?t:{...t,...e})},[]),u=(0,m.useCallback)(e=>{c(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!e.includes(t))))},[]),d=(0,m.useCallback)(e=>{n(t=>$P(t,e))},[n]),f=ZP[t.step]?.id,p=t.active&&(f===`project`||f===`download`)?f:void 0,g=(0,m.useMemo)(()=>({active:t.active,projectId:t.projectId,projectStep:p,start:r,report:l,clear:u,event:d}),[t.active,t.projectId,p,r,l,u,d]);return(0,h.jsxs)(sI.Provider,{value:g,children:[e,o?(0,h.jsxs)(`div`,{role:`alert`,className:`fixed bottom-4 left-4 z-[100] rounded-media border border-line bg-surface p-4 text-ink`,children:[(0,h.jsx)(`p`,{children:o}),(0,h.jsx)(R,{type:`button`,onClick:i,children:`Retry tutorial save`}),(0,h.jsx)(R,{type:`button`,onClick:a,children:`Restart tutorial`})]}):null,t.active?(0,h.jsx)(eI,{session:t,progress:s,update:n}):null]})}function lI(){return(0,m.useContext)(sI)}function uI(e){let t=(0,m.useContext)(sI),n=t?.report,r=t?.clear,i=(0,m.useRef)(e);i.current=e,(0,m.useEffect)(()=>{n?.(e)},[n,e]),(0,m.useEffect)(()=>()=>{r?.(Object.keys(i.current))},[r])}function dI(){let e=(0,m.useContext)(sI);return(0,m.useCallback)(t=>{e?.event(t)},[e?.event])}function fI(e){let t=(0,m.useContext)(sI);return t?.projectId===e?t.projectStep:void 0}var pI=[`patch-notes`];function mI(e){return st({queryKey:pI,queryFn:async()=>I(await e.client[`patch-notes`].$get()),staleTime:1/0})}function Jre(e,t){return st({queryKey:[...pI,t],queryFn:async()=>lo(await e.client[`patch-notes`][`:id`].$get({param:{id:t}})),staleTime:1/0})}async function Yre(e){await I(await e.client[`patch-notes`].seen.$post())}var hI={3:[{id:`home`,title:`Home`,body:`What is running and at which step, what is coming up, what needs you and what is ready to upload, on one screen.`,to:`/`,place:`Home`},{id:`play`,title:`Play's one path`,body:`Pick a template, type the topic, press Start. Everything else stays folded away until it needs you.`,to:`/play`,place:`Play`},{id:`reviews`,title:`Automatic reviews`,body:`A reviewer model checks the article, images, narration, thumbnail and shorts, and can send a failed item back to be made again. Turn it on in Play's Review step.`,to:`/play`,place:`Play`},{id:`channels`,title:`Channels and cast`,body:`A channel keeps its brand kit, series brief, templates and schedules, and a cast of characters and places that look the same in every video.`,to:`/channels`,place:`Channels`},{id:`memory`,title:`Episodes that remember`,body:`Each finished episode leaves a short summary on its channel's Episodes tab, and a new article reads the related ones. Add your existing video titles on Existing videos, and topic suggestions skip them too.`,to:`/channels`,place:`Channels`},{id:`calendar`,title:`The calendar`,body:`The coming weeks of uploads on one screen: what is ready, what needs you, and the topics still to come. Its Schedules tab holds every schedule.`,to:`/calendar`,place:`Calendar`},{id:`run-cost`,title:`What a run cost`,body:`Every project has a Run cost tab with the real cost per stage and model. Totals for all projects are in Settings, Usage.`,to:`/settings`,search:{section:`usage`},place:`Usage`},{id:`studio`,title:`YouTube Studio prep`,body:`Slopify never uploads. Prepare upload on a finished project lists everything Studio asks for, and the browser extension can fill it in for you.`,to:`/settings`,search:{section:`studio`},place:`YouTube Studio settings`},{id:`voices`,title:`Multiple voices`,body:`Audiobooks, podcasts, radio drama and interviews, with a voice per speaker. Pick the format under Audio, Speakers on Play.`,to:`/play`,place:`Play`},{id:`long-videos`,title:`Long videos stay watchable`,body:`More images for long videos sets images per hour or one every few minutes, with pan and zoom variety. An ambient bed of rain, fire, wind or your own file can play under the narration. Both are on Play; a channel's brand kit can set the ambient sound for all its videos.`,to:`/play`,place:`Play`},{id:`languages`,title:`Other languages`,body:`A project can be made in another language: pick it on Play, and the article, narration and description are written in it.`,to:`/play`,place:`Play`},{id:`trash`,title:`A trash bin`,body:`Deleted projects, prompts, templates and schedules stay in Settings, Trash for 30 days, and Restore brings them back.`,to:`/settings`,search:{section:`trash`},place:`Trash`}]},gI=[`whats-new`];async function Xre(e){return I(await e.client[`whats-new`].$get())}function _I(e){return st({queryKey:gI,queryFn:()=>Xre(e),staleTime:1/0})}async function Zre(e){return I(await e.client[`whats-new`].seen.$post())}function Qre(){let{api:e}=z(),t=_(),n=lI(),r=P(ob(e)),i=P({..._I(e),enabled:r.data?.seen===!0}),[a,o]=(0,m.useState)(0),s=F({mutationFn:()=>Zre(e),onSuccess:e=>{t.setQueryData(gI,e),t.setQueryData(pI,e=>e===void 0?e:{...e,due:null})}}),c=i.data?.major,l=c==null?void 0:hI[c],u=l!==void 0&&a>=l.length-1,d=P({...mI(e),enabled:i.data?.show===!0&&u}).data?.current??void 0;if(i.data?.show!==!0||l===void 0||n?.active===!0)return null;let f=l[Math.min(a,l.length-1)];if(f===void 0)return null;let p=l.indexOf(f),g=p===l.length-1,v=()=>{s.mutate()};return(0,h.jsx)(XP,{open:!0,width:`narrow`,title:`What's new in ${String(c)}.0`,onClose:v,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R,{variant:`quiet`,disabled:s.isPending,onClick:v,children:`Close tour`}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(R,{disabled:p===0,disabledReason:`This is the first step`,onClick:()=>{o(p-1)},children:`Back`}),(0,h.jsx)(R,{variant:`primary`,disabled:s.isPending,onClick:()=>{g?v():o(p+1)},children:g?`Finish tour`:`Next`})]}),children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`p`,{className:`m-0 text-label text-ink-3`,children:`${String(p+1)} of ${String(l.length)}`}),(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:f.title}),(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:f.body}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,h.jsx)(bS,{to:f.to,...f.search===void 0?{}:{search:f.search},children:`Open ${f.place}`}),g?(0,h.jsx)(xS,{to:`/settings`,search:{section:`patch-notes`,...d===void 0?{}:{note:d}},onClick:v,children:`Read the full patch notes`}):null]}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`Slopify could not save that you closed this tour: ${s.error.message} Press Close tour to try again.`})]})})}var $re={danger:(0,h.jsx)(Xc,{"aria-hidden":`true`,strokeWidth:1.75}),waiting:(0,h.jsx)(Cc,{"aria-hidden":`true`,strokeWidth:1.75}),info:(0,h.jsx)(Mc,{"aria-hidden":`true`,strokeWidth:1.75})};function vI({tone:e=`info`,title:t,children:n,actions:r,className:i}){return(0,h.jsxs)(`div`,{role:e===`danger`?`alert`:`status`,"data-tone":e,className:L(`sl-callout`,e!==`info`&&`sl-callout--${e}`,i),children:[$re[e],(0,h.jsx)(`span`,{className:`sl-callout__title`,children:t}),n===void 0?null:(0,h.jsx)(`div`,{className:`sl-callout__body`,children:n}),r===void 0?null:(0,h.jsx)(`div`,{className:`sl-callout__actions`,children:r})]})}function eie(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var tie=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nie=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rie={};function yI(e,t){return((t||rie).jsx?nie:tie).test(e)}var iie=/[ \t\n\f\r]/g;function aie(e){return typeof e==`object`?e.type===`text`&&bI(e.value):bI(e)}function bI(e){return e.replace(iie,``)===``}var xI=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};xI.prototype.normal={},xI.prototype.property={},xI.prototype.space=void 0;function SI(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new xI(n,r,t)}function CI(e){return e.toLowerCase()}var wI=class{constructor(e,t){this.attribute=t,this.property=e}};wI.prototype.attribute=``,wI.prototype.booleanish=!1,wI.prototype.boolean=!1,wI.prototype.commaOrSpaceSeparated=!1,wI.prototype.commaSeparated=!1,wI.prototype.defined=!1,wI.prototype.mustUseProperty=!1,wI.prototype.number=!1,wI.prototype.overloadedBoolean=!1,wI.prototype.property=``,wI.prototype.spaceSeparated=!1,wI.prototype.space=void 0;var TI=s({boolean:()=>EI,booleanish:()=>DI,commaOrSpaceSeparated:()=>jI,commaSeparated:()=>AI,number:()=>Y,overloadedBoolean:()=>OI,spaceSeparated:()=>kI}),oie=0,EI=MI(),DI=MI(),OI=MI(),Y=MI(),kI=MI(),AI=MI(),jI=MI();function MI(){return 2**++oie}var NI=Object.keys(TI),PI=class extends wI{constructor(e,t,n,r){let i=-1;if(super(e,t),FI(this,`space`,r),typeof n==`number`)for(;++i<NI.length;){let e=NI[i];FI(this,NI[i],(n&TI[e])===TI[e])}}};PI.prototype.defined=!0;function FI(e,t,n){n&&(e[t]=n)}function II(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new PI(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[CI(r)]=r,n[CI(a.attribute)]=r}return new xI(t,n,e.space)}var LI=II({properties:{ariaActiveDescendant:null,ariaAtomic:DI,ariaAutoComplete:null,ariaBusy:DI,ariaChecked:DI,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:kI,ariaCurrent:null,ariaDescribedBy:kI,ariaDetails:null,ariaDisabled:DI,ariaDropEffect:kI,ariaErrorMessage:null,ariaExpanded:DI,ariaFlowTo:kI,ariaGrabbed:DI,ariaHasPopup:null,ariaHidden:DI,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:kI,ariaLevel:Y,ariaLive:null,ariaModal:DI,ariaMultiLine:DI,ariaMultiSelectable:DI,ariaOrientation:null,ariaOwns:kI,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:DI,ariaReadOnly:DI,ariaRelevant:null,ariaRequired:DI,ariaRoleDescription:kI,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:DI,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function RI(e,t){return t in e?e[t]:t}function zI(e,t){return RI(e,t.toLowerCase())}var sie=II({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:AI,acceptCharset:kI,accessKey:kI,action:null,allow:null,allowFullScreen:EI,allowPaymentRequest:EI,allowUserMedia:EI,alpha:EI,alt:null,as:null,async:EI,autoCapitalize:null,autoComplete:kI,autoFocus:EI,autoPlay:EI,blocking:kI,capture:null,charSet:null,checked:EI,cite:null,className:kI,closedBy:null,colorSpace:null,cols:Y,colSpan:Y,command:null,commandFor:null,content:null,contentEditable:DI,controls:EI,controlsList:kI,coords:Y|AI,crossOrigin:null,data:null,dateTime:null,decoding:null,default:EI,defer:EI,dir:null,dirName:null,disabled:EI,download:OI,draggable:DI,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:EI,formTarget:null,headers:kI,height:Y,hidden:OI,high:Y,href:null,hrefLang:null,htmlFor:kI,httpEquiv:kI,id:null,imageSizes:null,imageSrcSet:null,inert:EI,inputMode:null,integrity:null,is:null,isMap:EI,itemId:null,itemProp:kI,itemRef:kI,itemScope:EI,itemType:kI,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:EI,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:EI,muted:EI,name:null,nonce:null,noModule:EI,noValidate:EI,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:EI,optimum:Y,pattern:null,ping:kI,placeholder:null,playsInline:EI,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:EI,referrerPolicy:null,rel:kI,required:EI,reversed:EI,rows:Y,rowSpan:Y,sandbox:kI,scope:null,scoped:EI,seamless:EI,selected:EI,shadowRootClonable:EI,shadowRootCustomElementRegistry:EI,shadowRootDelegatesFocus:EI,shadowRootMode:null,shadowRootSerializable:EI,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:DI,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:EI,useMap:null,value:DI,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:kI,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:EI,declare:EI,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:EI,noHref:EI,noShade:EI,noWrap:EI,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:DI,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:EI,disablePictureInPicture:EI,disableRemotePlayback:EI,exportParts:AI,part:kI,prefix:null,property:null,results:Y,security:null,unselectable:null},space:`html`,transform:zI}),cie=II({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:jI,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:kI,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:EI,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:AI,g2:AI,glyphName:AI,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:jI,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Y,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:kI,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:jI,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:jI,rev:jI,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:jI,requiredFeatures:jI,requiredFonts:jI,requiredFormats:jI,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:jI,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:jI,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:jI,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:RI}),BI=II({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),VI=II({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:zI}),HI=II({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),lie={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},uie=/[A-Z]/g,UI=/-[a-z]/g,die=/^data[-\w.:]+$/i;function fie(e,t){let n=CI(t),r=t,i=wI;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&die.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(UI,mie);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!UI.test(e)){let n=e.replace(uie,pie);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=PI}return new i(r,t)}function pie(e){return`-`+e.toLowerCase()}function mie(e){return e.charAt(1).toUpperCase()}var hie=SI([LI,sie,BI,VI,HI],`html`),WI=SI([LI,cie,BI,VI,HI],`svg`);function gie(e){return e.join(` `).trim()}var _ie=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
104
|
+
`);function qk(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?1:Math.max(1,Math.ceil(e/t-.001))}function Jk(e){let t=e=>e===void 0||e.trim()===``?void 0:Number(e),n=t(e.musicVolume),r=t(e.speed),i=e.fullVideoLink?.trim()??``;return{...e.titleOnScreen===void 0?{}:{titleOnScreen:e.titleOnScreen},...i===``?{}:{fullVideoLink:i},...n===void 0?{}:{musicVolume:n},...r===void 0?{}:{speed:r}}}function Yk(e){return{...e?.titleOnScreen===void 0?{}:{titleOnScreen:e.titleOnScreen},...e?.fullVideoLink===void 0?{}:{fullVideoLink:e.fullVideoLink},...e?.musicVolume===void 0?{}:{musicVolume:String(e.musicVolume)},...e?.speed===void 0?{}:{speed:e.speed.toFixed(2)}}}function Xk(e){let t=[],n=(e,t,n)=>Number.isInteger(e)&&e>=t&&e<=n;n(e.count,1,10)||t.push({field:`count`,message:`Enter a whole number of shorts between 1 and 10.`});for(let r of[`minSeconds`,`maxSeconds`])n(e[r],15,180)||t.push({field:r,message:`Enter a whole number of seconds between 15 and 180.`});if(t.every(e=>e.field===`count`)&&e.minSeconds>e.maxSeconds)for(let e of[`minSeconds`,`maxSeconds`])t.push({field:e,message:`The longest a short may be must be at least the shortest. Raise the maximum or lower the minimum.`});let r=e.speed;r!==void 0&&(!Number.isFinite(r)||r<.999999999||r>1.250000001||Math.abs((r-1)/.05-Math.round((r-1)/.05))>1e-6)&&t.push({field:`speed`,message:`Choose a speed between 1.00× and 1.25×, in steps of 0.05.`}),e.musicVolume!==void 0&&!n(e.musicVolume,0,100)&&t.push({field:`musicVolume`,message:`Enter the music volume as a whole number of percent between 0 and 100.`});let i=e.fullVideoLink?.trim()??``;return i!==``&&!Zk(i)&&t.push({field:`fullVideoLink`,message:`The full video link must be a whole web address starting with https:// or http://, like https://youtu.be/abc123. Paste it again, or leave the box empty.`}),t}function Zk(e){if(e.length>2e3||/\s/.test(e))return!1;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&t.hostname!==``}catch{return!1}}var Qk=[`rain`,`fire`,`wind`],$k=[...Qk,`upload`],eA={rain:`Rain`,fire:`Fireplace`,wind:`Wind`,upload:`My own file`},tA={levelDb:-18,fadeInSeconds:3,tailSeconds:6};function nA(e){return e.ambientBed!==void 0&&e.mode!==`short`&&e.sources.video===`generate`&&e.sources.audio!==`off`}function rA(e){let t=[];return $k.includes(e.source)||t.push({field:`source`,message:`Choose Rain, Fireplace, Wind or My own file for the ambient sound.`}),Number.isInteger(e.levelDb)&&e.levelDb>=-40&&e.levelDb<=-6||t.push({field:`level`,message:`Enter an ambient sound level between -40 and -6 dB, in whole dB.`}),iA(e.fadeInSeconds,30)||t.push({field:`fadeIn`,message:`Enter a fade-in between 0 and 30 seconds, in steps of 0.5.`}),iA(e.tailSeconds,30)||t.push({field:`tail`,message:`Enter a tail between 0 and 30 seconds, in steps of 0.5.`}),t}function iA(e,t){return Number.isInteger(e*2)&&e>=0&&e<=t}function aA(e){return{source:e.source,level:String(e.levelDb),fadeIn:String(e.fadeInSeconds),tail:String(e.tailSeconds)}}function oA(e){if(e===void 0||e.source===`none`)return;let t=e=>e.trim()===``?NaN:Number(e);return{source:e.source,levelDb:t(e.level),fadeInSeconds:t(e.fadeIn),tailSeconds:t(e.tail)}}var sA=[`interval`,`narration`],cA=[`cut`,`crossfade`,`fadeblack`,`slide`,`wipe`],lA=[`off`,`subtle`,`strong`],uA=[`none`,`warm`,`cold`,`desaturated`,`sepia`],dA=[`none`,`embers`,`dust`,`fog`],fA=[`off`,`chapters`,`every`],pA={cuts:`interval`,transition:`cut`,transitionSeconds:.6,vignette:`off`,grain:`off`,grade:`none`,atmosphere:`none`,chapterCards:!1,animate:`off`,animateEvery:3,animateModel:``},mA={...pA,cuts:`narration`},hA=.2,gA=[.2,.4,.6,.8,1,1.2,1.5,2],_A={interval:`Every N seconds`,narration:`Follow the narration`},vA={cut:`Cut`,crossfade:`Crossfade`,fadeblack:`Fade through black`,slide:`Slide`,wipe:`Wipe`},yA={off:`Off`,subtle:`Subtle`,strong:`Strong`},bA={none:`None`,warm:`Warm fantasy`,cold:`Cold`,desaturated:`Desaturated`,sepia:`Sepia`},xA={none:`None`,embers:`Embers`,dust:`Dust`,fog:`Fog`},SA={off:`Off`,chapters:`Chapter openers`,every:`Every Nth image`};function CA(e){return e.videoEdit??pA}function wA(e){let t=CA(e);return t.animate!==`off`&&e.sources.video===`generate`&&(t.animate===`every`||e.sources.audio!==`off`)}function TA(e){let t=e.videoEdit;if(t===void 0||e.sources.video!==`generate`)return[];let n=[];return t.transition!==`cut`&&!(Number.isFinite(t.transitionSeconds)&&t.transitionSeconds>=.2&&t.transitionSeconds<=2)&&n.push({field:`transitionSeconds`,message:`Choose a transition length between ${String(hA)} and 2 seconds.`}),t.chapterCards&&e.sources.audio===`off`&&n.push({field:`chapterCards`,message:`Chapter cards are placed from the narration. Turn narration on, or turn chapter cards off.`}),t.animate===`chapters`&&e.sources.audio===`off`&&n.push({field:`animate`,message:`Chapter openers are found from the narration. Turn narration on, or choose Every Nth image.`}),t.animate===`every`&&!(Number.isInteger(t.animateEvery)&&t.animateEvery>=2&&t.animateEvery<=10)&&n.push({field:`animateEvery`,message:`Choose every 2nd to every 10th image.`}),t.animate!==`off`&&t.animateModel.trim()===``&&n.push({field:`animateModel`,message:`Choose an image-to-video model to animate images with, or turn Animate images off.`}),n}function EA(e){return[[`Cuts`,_A[e.cuts]],[`Transition`,e.transition===`cut`?vA.cut:`${vA[e.transition]} · ${String(e.transitionSeconds)} s`],[`Vignette`,yA[e.vignette]],[`Film grain`,yA[e.grain]],[`Colour grade`,bA[e.grade]],[`Atmosphere`,xA[e.atmosphere]],[`Chapter cards`,e.chapterCards?`On`:`Off`],[`Animate images`,e.animate===`off`?SA.off:`${e.animate===`every`?`Every ${(e=>e===2?`2nd`:e===3?`3rd`:`${String(e)}th`)(e.animateEvery)} image`:SA.chapters}${e.animateModel.trim()===``?``:` · ${e.animateModel}`}`]]}var DA=[`audiobook`,`podcast`,`drama`,`interview`],OA={audiobook:`Audiobook`,podcast:`Podcast`,drama:`Radio drama`,interview:`Interview`},kA=[`narrator`,`host`,`guest`,`character`],AA=[`script`,`attribute`],jA=[.8,.9,1,1.1,1.2],MA=[0,.2,.35,.5,.8,1.2],NA=.35,PA=q({provider:W(),model:W(),voice:W()}),FA=q({id:W().min(1).max(60).regex(/^[a-z0-9-]+$/),name:W().max(40),role:J(kA),voice:PA,pace:G().optional(),pronunciations:W().max(2e4).optional(),castId:W().max(200).optional(),portrait:W().regex(/^[0-9a-f]{64}$/).optional()}),IA=9999,LA=q({title:W().max(200),chapter:G()}).strict().readonly();function RA(e){return`${e.title.trim()} · Chapter ${String(e.chapter)}`}var zA=q({format:J(DA),source:J(AA),speakers:K(FA).max(10),turnGapSeconds:G(),nameTags:KD(),nativeDialogue:KD(),audioFiles:KD(),book:LA.optional()});function BA(e,t=[]){return{format:e,source:`script`,speakers:VA(e,HA(e),t),turnGapSeconds:NA,nameTags:e===`podcast`||e===`interview`,nativeDialogue:!0,audioFiles:!0}}function VA(e,t,n){if(n.length===0||e!==`podcast`&&e!==`interview`)return[...t];let r=n.slice(0,9).map(e=>({...e,role:`host`})),i=e===`podcast`?t.slice(0,Math.max(0,2-r.length)):t.filter(e=>e.role!==`host`);return[...r,...i.filter(e=>!r.some(t=>t.id===e.id))]}function HA(e){let t={provider:``,model:``,voice:``},n=(e,n,r)=>({id:e,name:n,role:r,voice:t});switch(e){case`audiobook`:return[n(`narrator`,`Narrator`,`narrator`)];case`podcast`:return[n(`host-1`,`Alex`,`host`),n(`host-2`,`Sam`,`host`)];case`drama`:return[n(`narrator`,`Narrator`,`narrator`),n(`character-1`,`Mara`,`character`)];case`interview`:return[n(`host-1`,`Host`,`host`),n(`guest-1`,`Guest`,`guest`)]}}function UA(e){return e.voices!==void 0&&e.sources.audio===`generate`}function WA(e){return UA(e)&&e.voices?.source===`script`}function GA(e){let t=[],{speakers:n}=e;n.length===0&&t.push({field:`voices.speakers`,message:`Add at least one speaker under Speakers (Play → Narration, or Edit project → Providers).`}),e.source===`attribute`&&e.format!==`audiobook`&&t.push({field:`voices.source`,message:`Only audiobooks can hand an existing text's dialogue to speakers. Choose Write a script under Speakers (Play → Narration, or Edit project → Providers).`}),(e.format===`podcast`||e.format===`interview`)&&n.length<2&&t.push({field:`voices.speakers`,message:`A ${OA[e.format].toLowerCase()} needs at least two speakers. Add one under Speakers (Play → Narration, or Edit project → Providers).`}),(e.format===`audiobook`||e.format===`drama`)&&!n.some(e=>e.role===`narrator`)&&t.push({field:`voices.speakers`,message:`An ${e.format===`drama`?`radio drama`:`audiobook`} needs a narrator. Set one speaker's role to Narrator under Speakers (Play → Narration, or Edit project → Providers).`});let r=new Set,i=new Set;for(let[e,a]of n.entries()){let n=`voices.speakers.${String(e)}`,o=a.name.trim();o===``?t.push({field:`${n}.name`,message:`Enter a name for this speaker.`}):/^[\p{L}\p{N}][\p{L}\p{N} .'-]*$/u.test(o)?r.has(o.toLowerCase())&&t.push({field:`${n}.name`,message:`Two speakers are called "${o}". Give each speaker a different name.`}):t.push({field:`${n}.name`,message:`Use only letters, numbers, spaces, dots, apostrophes and hyphens in a speaker name, starting with a letter or number.`}),r.add(o.toLowerCase()),i.has(a.id)&&t.push({field:`${n}.name`,message:`Two speakers share one id. Remove one of them and add it again.`}),i.add(a.id),a.voice.provider.trim()===``||a.voice.model.trim()===``?t.push({field:`${n}.voice`,message:`Choose a voice provider and model for ${o||`this speaker`}.`}):a.voice.voice.trim()===``&&t.push({field:`${n}.voice.voice`,message:`Choose a voice for ${o||`this speaker`}.`}),a.pace!==void 0&&!jA.includes(a.pace)&&t.push({field:`${n}.pace`,message:`Pick a pace from the list for ${o||`this speaker`}.`})}return e.book!==void 0&&(e.book.title.trim()===``&&t.push({field:`voices.book.title`,message:`Enter the book's title under Speakers (Play → Narration), or remove the book to make a project on its own.`}),(!Number.isInteger(e.book.chapter)||e.book.chapter<1||e.book.chapter>9999)&&t.push({field:`voices.book.chapter`,message:`Enter a chapter number from 1 to ${String(IA)} under Speakers (Play → Narration).`})),MA.includes(e.turnGapSeconds)||t.push({field:`voices.turnGapSeconds`,message:`Pick a gap between turns from the list under Speakers (Play → Narration, or Edit project → Providers).`}),t}function KA(e){return e.mode===`short`}function qA(e){if(!KA(e))return[];let t=[];e.format!==`9:16`&&t.push({field:`format`,message:`A short is vertical. Choose the 9:16 format, or make a long video instead.`}),KS(e.sources,`video`)!==`generate`&&t.push({field:`sources.video`,message:`A short is a video. Set Video to Generate.`}),KS(e.sources,`audio`)===`off`&&t.push({field:`sources.audio`,message:`A short's length and captions come from its narration. Set Narration to Generate or Provide.`}),KS(e.sources,`images`)===`off`&&t.push({field:`sources.images`,message:`A short shows images behind its captions. Set Images to Generate or Provide.`});for(let n of[`thumbnail`,`document`])KS(e.sources,n)!==`off`&&t.push({field:`sources.${n}`,message:`A short has no ${n===`thumbnail`?`thumbnail`:`PDF`}. Set ${n===`thumbnail`?`Thumbnail`:`Document`} to Off.`});return e.shorts?.enabled===!0&&t.push({field:`shorts.enabled`,message:`A short isn't cut into more shorts. Turn Shorts off.`}),t}var JA=22.5,YA=`zoom`,XA={zoom:`Zoom in and out`,pan:`Pan across`,mixed:`Mix of both`,still:`Still`};function ZA(e){return Number.isInteger(e)&&e>=1&&e<=600?void 0:`Enter a whole number of seconds between 1 and 600.`}function QA(e){return Number.isInteger(e*2)&&e>=0&&e<=50?void 0:`Enter a zoom between 0 and 50 percent, in steps of 0.5.`}function $A(e){return Number.isInteger(e*2)&&e>=0&&e<=30?void 0:`Enter a number of seconds between 0 and 30, in steps of 0.5.`}var ej={research:[`off`,`generate`,`provide`],article:[`off`,`generate`,`provide`],audio:[`off`,`generate`,`provide`],images:[`off`,`generate`,`provide`],thumbnail:[`off`,`from_prompt`,`prompt_by_llm`,`provide`],video:[`off`,`generate`],document:[`off`,`generate`]};function tj(e){let t=[],n=nj(e.draft),{sources:r}=n;n.title===``?t.push({field:`title`,message:`Enter a title for this video.`}):n.title.length>200&&t.push({field:`title`,message:`Keep the title to 200 characters or fewer.`});for(let e of US)ej[e].includes(KS(r,e))||t.push({field:`sources.${e}`,message:`"${KS(r,e)}" is not an option for ${e}. Reload the page and choose again.`});uj(n)&&!Sj(n.llm)&&t.push({field:`llm`,message:`Choose a text (LLM) provider and model.`}),r.article===`generate`&&cj(n.articlePrompt)&&t.push({field:`articlePrompt`,message:`Pick an article prompt.`});let i=n.audio;t.push(...fj(n)),t.push(...pj(n)),r.audio===`generate`&&(i===void 0||!Sj(i)?t.push({field:`audio`,message:`Choose a narration provider and model.`}):i.voice.trim()===``&&t.push({field:`audio.voice`,message:`Choose a voice for the narration.`})),r.images===`generate`&&rj(n,t),(r.images===`generate`||r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`||vj(n)||wA(n))&&!Sj(n.images)&&t.push({field:`images`,message:`Choose an image provider and model.`}),(r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`)&&cj(n.thumbnailPrompt)&&t.push({field:`thumbnailPrompt`,message:`Pick a thumbnail prompt.`}),r.audio===`off`&&n.subtitles!==void 0&&n.subtitles.mode!==`off`&&t.push({field:`subtitles.mode`,message:`Subtitles need narration. Turn narration on, or turn subtitles off.`}),t.push(...hj(n)),t.push(...yj(n)),t.push(...qA(n)),t.push(...bj(n)),t.push(...xj(n,e.staged)),t.push(...pk(n.loudness)),t.push(...Sk(n)),t.push(..._j(n)),t.push(...Lk(n)),gj(n)&&n.reference?.source===`provide`&&oj(e.staged,n.provided.reference,`images`,`provided.reference`,`Upload the establishing image, or set Establishing image to Off in the Images section.`,t),ij(n,e.staged,t),sj(n,e.requiredSlots,t),(!Number.isFinite(n.silenceGapSeconds)||n.silenceGapSeconds<0||n.silenceGapSeconds>30)&&t.push({field:`silenceGapSeconds`,message:`Enter a silence gap between 0 and 30 seconds.`});let a=r.video===`generate`?ZA(n.imageSeconds):void 0;a!==void 0&&t.push({field:`imageSeconds`,message:a});let o=r.video===`generate`?QA(n.zoomPercent):void 0;o!==void 0&&t.push({field:`zoomPercent`,message:o});let s=r.audio===`off`?void 0:$A(n.edgeSilenceSeconds);return s!==void 0&&t.push({field:`edgeSilenceSeconds`,message:s}),t.length===0?{ok:!0,draft:n}:{ok:!1,fields:t}}function nj(e){let t={...e.sources};t.article!==`generate`&&(t.research=`off`),t.images===`off`&&t.video===`generate`&&(t.video=`off`);let n=Object.create(null);for(let[t,r]of Object.entries(e.values))n[t]=r.trim();return{...e,title:e.title.trim(),subtitles:t.video===`off`&&e.subtitles?.mode===`burn-in`?{...e.subtitles,mode:`files`}:e.subtitles,sources:t,values:n,intro:t.audio===`generate`?e.intro:void 0,outro:t.audio===`generate`?e.outro:void 0}}function rj(e,t){if(e.imagePrompts.length===0){t.push({field:`imagePrompts`,message:`Tick at least one image prompt, or turn images off.`});return}let n=0;for(let[r,i]of e.imagePrompts.entries())n+=i.number,cj(i.name)&&t.push({field:`imagePrompts.${r}.name`,message:`Pick an image prompt.`}),(!Number.isInteger(i.number)||i.number<1||i.number>20)&&t.push({field:`imagePrompts.${r}.number`,message:`Enter a whole number between 1 and 20.`});n>60&&t.push({field:`imagePrompts`,message:`A video can have at most 60 images; these prompts ask for ${n}. Lower the numbers.`});let r=e.imageScale===void 0?void 0:tk(e.imageScale);r!==void 0&&t.push({field:`imageScale`,message:r})}function ij(e,t,n){let{sources:r,provided:i}=e;if(r.research===`provide`&&cj(i.research)&&n.push({field:`provided.research`,message:`Paste the research notes.`}),r.article===`provide`&&cj(i.article)&&n.push({field:`provided.article`,message:`Paste the article.`}),n.push(...wj(e)),r.audio===`provide`&&oj(t,i.audio,`audio`,`provided.audio`,`Pick an audio file.`,n),r.thumbnail===`provide`&&oj(t,i.thumbnail,`thumbnail`,`provided.thumbnail`,`Pick a thumbnail image.`,n),r.images===`provide`){let e=i.images??[];e.length===0?n.push({field:`provided.images`,message:`Pick at least one image.`}):e.length>60&&n.push({field:`provided.images`,message:`A video can have at most 60 images. Remove some.`}),new Set(e).size!==e.length&&n.push({field:`provided.images`,message:`The same image is picked twice. Remove the duplicate.`});for(let[r,i]of e.entries())oj(t,i,`images`,`provided.images.${r}`,`Pick an image.`,n)}aj(e,t,n)}function aj(e,t,n){let r=e.provided.shortsMusic;if(e.shorts?.enabled!==!0||r===void 0)return;let i=`under Outputs → More shorts options → Background music`,a=t.find(e=>e.id===r);a===void 0||a.stageKind!==`audio`?n.push({field:`shorts.music`,message:`The shorts' background music file is no longer available, so it can't be added to the project. Choose the file again ${i}, or remove it.`}):a.state!==`staged`&&n.push({field:`shorts.music`,message:`The shorts' background music is still uploading, so the run can't start yet. Wait for it to finish, or remove it ${i}.`})}function oj(e,t,n,r,i,a){if(t===void 0||t===``){a.push({field:r,message:i});return}let o=e.find(e=>e.id===t);if(o===void 0||o.stageKind!==n){a.push({field:r,message:`That upload is no longer available. Choose the file again.`});return}o.state!==`staged`&&a.push({field:r,message:`This file is still uploading. Wait for it to finish.`})}function sj(e,t,n){for(let r of t){let t=Object.hasOwn(e.values,r)?e.values[r]:void 0;if(t===void 0||t===``){n.push({field:`values.${r}`,message:`Fill in this field.`});continue}t.length>200&&n.push({field:`values.${r}`,message:`Keep this to 200 characters or fewer.`}),/[\n\r]/.test(t)&&n.push({field:`values.${r}`,message:`Keep this to a single line, without line breaks.`})}}function cj(e){return e===void 0||e.trim()===``}function lj(e){let t=e.sources,n=[];return t.research===`generate`&&n.push({section:`article`,label:`researching the topic`}),t.article===`generate`&&n.push({section:`article`,label:`writing the article`}),UA(e)&&e.voices?.source===`attribute`&&n.push({section:`narration`,label:`working out who speaks each line`}),dj(e)&&n.push({section:`narration`,label:`preparing the narration's delivery`}),e.intro?.mode===`llm`&&n.push({section:`narration`,label:`writing the intro`}),e.outro?.mode===`llm`&&n.push({section:`narration`,label:`writing the outro`}),t.thumbnail===`prompt_by_llm`&&n.push({section:`outputs`,label:`writing the thumbnail prompt`}),mj(e)&&n.push({section:`outputs`,label:`writing the YouTube description`}),vj(e)&&n.push({section:`outputs`,label:`picking the shorts`}),n}function uj(e){return lj(e).length>0}function dj(e){return e.sources.audio===`generate`&&!cj(e.narrationPrompt)}function fj(e){return dj(e)&&(e.audio?.provider!==`inworld`||e.audio.model!==`inworld-tts-2`)?[{field:`narrationPrompt`,message:`Narration preparation only works with the Inworld TTS-2 model. Choose that model under Narration, or turn preparation Off.`}]:[]}function pj(e){if(e.voices===void 0||!UA(e))return[];let t=[...GA(e.voices)];return!cj(e.narrationPrompt)&&!e.voices.speakers.some(e=>e.voice.provider===`inworld`&&e.voice.model===`inworld-tts-2`)&&t.push({field:`narrationPrompt`,message:`Narration preparation adds delivery cues only to speakers on Inworld's TTS-2 model, and no speaker uses it. Choose that model for a speaker under Speakers, or clear Narration Preparation under Narration → Audio Advanced.`}),t}function mj(e){return e.youtubeDescription===!0&&e.sources.audio!==`off`}function hj(e){return e.youtubeDescription===!0&&e.sources.audio===`off`?[{field:`youtubeDescription`,message:`The YouTube description is timed from the narration. Turn narration on, or turn the YouTube description off.`}]:[]}function gj(e){return e.reference!==void 0&&e.sources.images===`generate`}function _j(e){return gj(e)&&e.reference?.source===`prompt`&&(e.reference.prompt===void 0||e.reference.prompt.trim()===``)?[{field:`reference.prompt`,message:`Pick an image prompt for the establishing image, upload one instead, or set Establishing image to Off in the Images section.`}]:[]}function vj(e){return e.shorts?.enabled===!0&&e.sources.audio!==`off`}function yj(e){let t=e.shorts;if(t?.enabled!==!0)return[];if(e.sources.audio===`off`)return[{field:`shorts.enabled`,message:`Shorts are cut from the narration. Turn narration on, or turn Shorts off.`}];let n=Xk(t).map(e=>({field:`shorts.${e.field}`,message:e.message})),r=e.sources.video===`generate`?void 0:ZA(e.imageSeconds);return r!==void 0&&n.push({field:`imageSeconds`,message:r}),n}function bj(e){return TA(e).map(e=>({field:`videoEdit.${e.field}`,message:e.message}))}function xj(e,t){let n=e.ambientBed;if(n===void 0||!nA(e))return[];let r=`under Video and style → Ambient sound`,i=rA(n).map(e=>({field:`ambientBed.${e.field}`,message:`${e.message} Change it ${r}.`}));if(n.source!==`upload`)return i;let a=e.provided.ambientBed,o=a===void 0?void 0:t.find(e=>e.id===a);return o===void 0||o.stageKind!==`audio`?i.push({field:`ambientBed.file`,message:`The ambient sound's audio file is missing, so it can't be added to the project. Choose the file ${r}, or pick Rain, Fireplace or Wind instead.`}):o.state!==`staged`&&i.push({field:`ambientBed.file`,message:`The ambient sound's audio file is still uploading, so the run can't start yet. Wait for it to finish ${r}.`}),i}function Sj(e){return e!==void 0&&e.provider.trim()!==``&&e.model.trim()!==``}function Cj(e){return e.sources.audio===`generate`&&e.audio?.usePronunciationGlossary===!0&&e.audio.provider===`inworld`&&(e.audio.model===`inworld-tts-2`||e.audio.model===`inworld-tts-2-flash`)}function wj(e){let{sources:t}=e;if(t.article!==`off`)return[];let n=`Set Article to Generate or Provide`;return[...t.audio===`generate`?[{field:`sources.audio`,message:`Narration reads the article, and Article is Off. ${n}, or set Narration to Off or Provide.`}]:[],...t.document===`generate`?[{field:`sources.document`,message:`The PDF is made from the article, and Article is Off. ${n}, or set PDF to Off.`}]:[],...t.thumbnail===`prompt_by_llm`?[{field:`sources.thumbnail`,message:`The AI writes the thumbnail prompt from the article, and Article is Off. ${n}, or pick From prompt for the thumbnail.`}]:[],...t.audio!==`off`&&e.subtitles!==void 0&&e.subtitles.mode!==`off`?[{field:`subtitles.mode`,message:`Captions are matched to the article's words, and Article is Off. ${n}, or turn captions off.`}]:[],...mj(e)?[{field:`youtubeDescription`,message:`The YouTube description is written from the narration's words, which come from the article, and Article is Off. ${n}, or turn the YouTube description off.`}]:[],...vj(e)?[{field:`shorts.enabled`,message:`Shorts are picked from the narration's words, which come from the article, and Article is Off. ${n}, or turn Shorts off.`}]:[],...t.images===`generate`&&e.imageScenes===!0?[{field:`imageScenes`,message:`Scenes from the article need the article, and Article is Off. ${n}, or turn Scenes from the article off.`}]:[]]}var Tj=[`auto`,`yes`,`no`],Ej={auto:`Automatic`,yes:`Always Yes`,no:`Always No`},Dj={levelDb:G(),fadeInSeconds:G(),tailSeconds:G()},Oj=q({source:J($k),...Dj}).strict(),kj=q({source:J(Qk),...Dj}).strict(),Aj=`Previous video`,jj=2e3,Mj=/\{\{([^{}\n]{1,80})\}\}/gu;function Nj(e){return e.trim().replace(/\s+/gu,` `).toLowerCase()}function Pj(e,t){let n=new Set,r=[];for(let i of[...t,...e]){let e=Nj(i.name);n.has(e)||i.url.trim()===``||(n.add(e),r.push(i))}return r}function Fj(e,t){let n=new Map(t.map(e=>[Nj(e.name),e.url])),r=[],i=0;for(let t of e.matchAll(Mj)){let a=t.index;a>i&&r.push({kind:`text`,text:e.slice(i,a)});let o=(t[1]??``).trim();r.push({kind:`placeholder`,raw:t[0],name:o,url:n.get(Nj(o))}),i=a+t[0].length}return i<e.length&&r.push({kind:`text`,text:e.slice(i)}),r}function Ij(e,t){let n=[];return{text:Fj(e,t).map(e=>e.kind===`text`?e.text:e.url===void 0?(n.some(t=>Nj(t)===Nj(e.name))||n.push(e.name),e.raw):e.url).join(``),unknown:n}}function Lj(e){if(e.length>50)return`Keep at most 50 links. Remove some.`;let t=new Set;for(let[n,r]of e.entries()){let e=`Link ${String(n+1)}`,i=r.name.trim();if(i===``)return`${e} has no name. Give it one, such as Patreon.`;if(i.length>60)return`${e}'s name is over 60 characters. Shorten it.`;if(/[{}]/u.test(i))return`${e}'s name contains { or }. Use the name alone; the description writes it as {{${i.replace(/[{}]/gu,``)}}}.`;if(t.has(Nj(i)))return`Two links are named "${i}". Rename one, since {{${i}}} can only fill with one.`;t.add(Nj(i));let a=r.url.trim();if(a.length>2e3)return`The "${i}" link is over ${String(jj)} characters. Use a shorter address.`;if(a===``)return`The "${i}" link has no address. Paste it, starting with https://.`;if(!Rj(a))return`The "${i}" link is not a web address. Paste the full address, starting with https://.`}}function Rj(e){try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`}catch{return!1}}var zj=TD(),Bj=W().regex(/^#[0-9a-fA-F]{6}$/,`Use a colour like #FFD700.`).transform(e=>e.toUpperCase()),Vj=e=>W().trim().max(e).optional(),Hj=W().max(160).regex(/^[A-Za-z0-9_-]+$/,`Choose a font from the list.`).optional(),Uj=q({captionFontId:Hj,captionColor:Bj.optional(),captionOutlineColor:Bj.optional(),titleFontId:Hj,titleColor:Bj.optional(),intro:Vj(200),outro:Vj(200),endScreenText:Vj(200),documentTheme:Vj(200),ambientBed:kj.superRefine((e,t)=>{for(let n of rA(e))t.addIssue({code:`custom`,path:[n.field],message:`${n.message} Change it under Brand kit → Ambient sound on the channel page.`})}).optional(),language:BO.optional(),links:K(q({name:W().max(240),url:W().max(jj*2)}).strict()).max(100).transform(e=>e.map(e=>({name:e.name.trim(),url:e.url.trim()}))).superRefine((e,t)=>{let n=Lj(e);n!==void 0&&t.addIssue({code:`custom`,message:`The channel's links weren't saved: ${n} Then press Save channel on the channel's Brand tab.`})}).optional()}).strict().transform(e=>Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0&&e!==``))),Wj=W().trim().min(1,`Enter a name.`).max(200,`Keep the name to 200 characters or fewer.`);q({id:zj,name:Wj}).strict().readonly(),q({name:Wj,brand:Uj,seriesBrief:W().max(1e4,`Keep the series brief to 10,000 characters or fewer.`),baseVersion:G().int().positive()}).strict().readonly();var Gj=W().trim().min(1,`Enter a name, and remove empty aliases.`).max(200,`Keep names and aliases to 200 characters or fewer.`),Kj=q({provider:W().trim().min(1,`Choose a voice provider.`).max(100),model:W().trim().min(1,`Choose a voice model.`).max(200),voice:W().trim().min(1,`Choose a voice.`).max(200),pace:G().refine(e=>jA.includes(e),`Pick a pace from the list.`).optional(),pronunciations:W().max(2e4,`Keep the pronunciations to 20,000 characters or fewer.`).optional()}).strict(),qj=q({kind:J($b),name:Gj,aliases:K(Gj).max(20,`Keep to 20 aliases or fewer.`).default([]),description:W().trim().max(2e3,`Keep the description to 2,000 characters or fewer.`).default(``),voice:Kj.nullable().optional(),host:KD().optional()}).strict();qj.extend({id:zj}).strict(),qj.extend({baseVersion:G().int().positive()}).strict(),q({prompt:W().trim().min(1,`Describe the picture to make.`).max(4e3,`Keep the picture's description to 4,000 characters or fewer.`),provider:W().min(1).max(100),model:W().min(1).max(200)}).strict(),q({channelId:zj}).strict(),q({aiDisclosure:J(Tj,`Choose Automatic, Always Yes or Always No.`)}).strict();var Jj=K(q({name:W(),aliases:K(W()).readonly(),description:W(),images:K(W()).readonly()})).readonly(),Yj=W().min(1),Xj=W().regex(/^[a-f0-9]{64}$/),Zj=J([`audio`,`images`,`video`]),Qj=q({projectId:Yj,revisionId:Yj,checkpointId:Yj,stage:Zj,workId:Yj,fingerprint:Xj,state:J([`configured`,`pending-review`,`held`,`released`,`satisfied`,`invalidated`,`canceled`]),createdAt:RO(),approvedAt:RO().nullable()}).strict().readonly();q({projectId:Yj,revisionId:Yj,checkpoints:K(q({checkpointId:Yj,stage:Zj,workId:Yj,fingerprint:Xj,state:J([`configured`,`pending-review`,`held`])}).strict().readonly()).max(3).readonly(),createdAt:RO()}).strict().readonly();var $j=q({projectId:Yj,revisionId:Yj,checkpointId:Yj,fingerprint:Xj,idempotencyKey:TD(),approvedAt:RO()}).strict().readonly(),eM=[`Cinzel`,`Literata`,`times`,`helvetica`,`courier`],tM=[`normal`,`medium`,`bold`,`black`,`italic`,`bolditalic`],nM=(e,t)=>{let n={error:`Use a value from ${String(e)} to ${String(t)}.`};return G({error:`Enter a number.`}).finite(n).min(e,n).max(t,n)},rM=W().regex(/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i,`Use a colour like #8c1e14.`),iM=W().max(300,{error:`Keep this under 300 characters.`}),aM=iM.nullable(),oM=W().max(500,{error:`Keep this under 500 characters.`}).nullable(),sM=q({family:J(eM),style:J(tM),letterSpacing:nM(-.5,2)}).strict(),cM=q({page:q({format:J([`a4`,`letter`]),margin:nM(5,60),contentTop:nM(5,80)}).strict(),background:q({image:J([`parchment`]).nullable(),color:rM}).strict(),colors:q({heading:rM,text:rM,muted:rM,faint:rM}).strict(),fonts:q({body:sM,strong:sM,emphasis:sM,heading:sM,dramatic:sM,decorative:sM,dropCap:sM,footer:sM}).strict(),sizes:q({brand:nM(6,72),title:nM(6,72),section:nM(6,72),heading:nM(6,72),subheading:nM(6,72),body:nM(6,24),footer:nM(5,24),meta:nM(5,24)}).strict(),spacing:q({bodyLine:nM(3,20),headingLine:nM(3,30),subheadingLine:nM(3,30),paragraphGap:nM(0,3),headingGap:nM(0,5),itemGap:nM(0,3),listIndent:nM(0,30),quoteIndent:nM(0,40),ruleWidth:nM(0,150)}).strict(),dropCap:q({enabled:KD(),lines:nO([mO(2),mO(3),mO(4)]),scale:nM(1,5),gap:nM(0,20),minLength:G({error:`Enter a number.`}).int({error:`Use a whole number.`}).min(0,{error:`Use a value from 0 to 2000.`}).max(2e3,{error:`Use a value from 0 to 2000.`}),minRoom:nM(0,1)}).strict(),titlePage:q({brandY:nM(10,200),taglineOffset:nM(0,60),titleY:nM(10,250),titleLine:nM(3,40),metaOffset:nM(0,100),metaLine:nM(3,30),showDate:KD(),showWordCount:KD(),cover:q({enabled:KD(),gap:nM(0,40),maxHeight:nM(20,200)}).strict()}).strict(),contents:q({enabled:KD(),title:iM,depth:nO([mO(1),mO(2),mO(3)]),titleOffset:nM(0,100),firstEntryOffset:nM(0,150),line:nM(3,30),indent:nM(0,30)}).strict(),header:q({enabled:KD(),top:nM(3,60),maxTitleCharacters:G({error:`Enter a number.`}).int({error:`Use a whole number.`}).min(5,{error:`Use a value from 5 to 200.`}).max(200,{error:`Use a value from 5 to 200.`})}).strict(),footer:q({enabled:KD(),bottom:nM(3,60),reserve:nM(0,60),text:iM}).strict(),brand:q({name:aM,url:oM,tagline:aM,linkLabel:aM}).strict(),metadata:q({author:iM,subject:iM,keywords:W().max(1e3),creator:iM}).strict(),sources:q({enabled:KD(),title:iM,titleOffset:nM(0,100),bodyOffset:nM(0,150),line:nM(3,30),gap:nM(0,20)}).strict(),endPage:q({enabled:KD(),title:iM,titleOffset:nM(0,100),bodyOffset:nM(0,150),lines:K(iM).max(60).readonly(),showDocumentDetails:KD(),link:q({text:iM,url:oM}).strict().nullable(),closing:aM}).strict()}).strict(),lM=q({id:W().min(1).max(64),name:W().min(1).max(80),values:cM}).strict(),uM=q({theme:J(eC),custom:lM.optional()}).strict(),dM=K(q({written:W().trim().min(1).max(200),spoken:W().trim().min(1).max(500),wholeWord:KD(),caseSensitive:KD()}).strict().readonly()).max(1e3).readonly(),fM=[`whole`,`paragraph`,`words`,`characters`],pM=[`off`,`files`,`burn-in`],mM=[`top`,`upper-middle`,`center`,`lower-middle`,`bottom`],hM=q({mode:J(pM),language:mO(`en`).default(`en`),fontId:W().max(160).regex(/^[A-Za-z0-9_-]+$/).default(`default`),position:J(mM).default(`bottom`),fontSize:G().int().min(16).max(120).default(48),color:W().regex(/^#[0-9A-Fa-f]{6}$/).optional(),outlineColor:W().regex(/^#[0-9A-Fa-f]{6}$/).optional()}),gM={mode:`off`,language:`en`,fontId:`default`,fontSize:48,position:`bottom`},_M=W().regex(/^#[0-9A-Fa-f]{6}$/),vM=q({provider:W(),model:W(),thinking:J(UO).optional()}),yM=q({name:W(),mode:J(JS)}),bM=q({cuts:J(sA),transition:J(cA),transitionSeconds:G(),vignette:J(lA),grain:J(lA),grade:J(uA),atmosphere:J(dA),chapterCards:KD(),animate:J(fA),animateEvery:G(),animateModel:W()}),xM=q({mode:J(ZS).optional(),checkpoints:K(Zj).max(3).refine(e=>new Set(e).size===e.length).readonly().optional(),title:W(),format:J(HS),sources:q({research:J(GS),article:J(GS),audio:J(GS),images:J(GS),thumbnail:J(GS),video:J(GS),document:J(GS).optional()}),llm:vM.optional(),audio:vM.extend({voice:W(),usePronunciationGlossary:KD().optional(),shareGlossary:KD().optional(),useNarrationAliases:KD().optional(),describeFigures:KD().optional(),skipCode:KD().optional()}).optional(),narrationAliases:dM.optional(),sharedGlossary:K(q({term:W().min(1).max(200),ipa:K(W().min(1).max(200)).min(1).max(20).readonly()})).max(2e4).readonly().optional(),images:vM.optional(),reference:q({source:J(XS),prompt:W().optional(),thumbnail:KD().optional()}).optional(),articlePrompt:W().optional(),narrationPrompt:W().optional(),imagePrompts:K(q({name:W(),number:G()})),imageScale:q({perHour:G(),words:G()}).optional(),imageScenes:KD().optional(),thumbnailPrompt:W().optional(),thumbnailCount:nO([mO(1),mO(3)]).optional(),intro:yM.optional(),outro:yM.optional(),values:uO(W(),W()),provided:q({research:W().optional(),article:W().optional(),audio:W().optional(),images:K(W()).optional(),thumbnail:W().optional(),reference:W().optional(),shortsMusic:W().optional(),ambientBed:W().optional()}),chunking:q({mode:J(fM),words:G().optional(),characters:G().int().min(1).max(1e6).optional()}).optional(),silenceGapSeconds:G(),imageSeconds:G().default(15),zoomPercent:G().default(JA),motionStyle:J(qS).default(YA),edgeSilenceSeconds:G().default(2),subtitles:hM.optional(),document:uM.optional(),youtubeDescription:KD().optional(),showFigures:KD().optional(),descriptionPrompt:W().optional(),shorts:q({enabled:KD(),count:G(),minSeconds:G(),maxSeconds:G(),prompt:W().optional(),imagePrompt:W().optional(),titleOnScreen:KD().optional(),fullVideoLink:W().optional(),musicVolume:G().optional(),speed:G().optional()}).optional(),videoEdit:bM.optional(),channelId:W().optional(),useBrandKit:mO(!1).optional(),cast:Jj.optional(),earlierEpisodes:K(q({title:W(),summary:W()})).readonly().optional(),titleStyle:q({fontId:W().max(160).regex(/^[A-Za-z0-9_-]+$/).optional(),color:_M.optional()}).optional(),endScreen:q({text:W().max(200)}).optional(),reviews:q({provider:W(),model:W(),thinking:J(UO).optional(),retries:G().optional(),stages:dO(J(wk),q({mode:J(Tk),prompt:W().optional()}))}).optional(),voices:zA.optional(),ambientBed:Oj.optional(),loudness:q({videoLufs:G(),audioFilesLufs:G()}).strict().optional(),sentencePauseSeconds:G().optional(),paragraphPauseSeconds:G().optional(),language:BO.optional()}),SM=xM.extend({rendered:uO(W(),W()),titlePattern:W().optional(),subjectTitle:W().optional()}),CM=[`article`,`image`,`thumbnail`,`narration`,`description`,`shorts`,`review`,`script`],wM=[`intro`,`outro`],TM=1e5;q({id:W(),kind:J(CM),name:W(),body:W(),slots:W(),updated_at:W()}),q({id:W(),category:J(wM),mode:J(JS),name:W(),body:W(),slots:W(),updated_at:W()});var EM=q({id:W(),name:W(),body:W(),slots:K(W()).readonly(),updatedAt:W()}),DM=q({prompts:K(EM.extend({kind:J(CM)}).strict().readonly()).readonly(),entries:K(EM.extend({category:J(wM),mode:J(JS)}).strict().readonly()).readonly()}).strict().readonly(),OM=TD(),kM=W(),AM=uO(kM,kM).readonly(),jM=q({provider:kM,model:kM,thinking:J(UO).optional()}).strict(),MM=[`audio`,`images`,`thumbnail`,`reference`],NM=q({attachmentId:OM,name:kM}).strict().readonly(),PM=q({title:kM,checkpoints:xM.shape.checkpoints,format:J(HS),sources:q({research:J(GS),article:J(GS),audio:J(GS),images:J(GS),thumbnail:J(GS),video:J(GS),document:J(GS).optional()}).strict().readonly(),document:uM.readonly().optional(),llm:jM.readonly(),audio:jM.extend({voice:kM,usePronunciationGlossary:KD().optional(),shareGlossary:KD().optional(),useNarrationAliases:KD().optional(),describeFigures:KD().optional(),skipCode:KD().optional()}).readonly(),images:jM.readonly(),reference:q({source:J([`off`,...XS]),prompt:kM,thumbnail:KD()}).strict().readonly().optional(),articlePrompt:kM,narrationPrompt:kM.optional(),thumbnailCount:nO([mO(1),mO(3)]).optional(),loudness:q({enabled:KD(),videoLufs:G().optional(),audioFilesLufs:G().optional()}).strict().readonly().optional(),sentencePause:kM.optional(),paragraphPause:kM.optional(),youtubeDescription:KD().optional(),showFigures:KD().optional(),descriptionPrompt:kM.optional(),language:BO.optional(),shorts:q({enabled:KD(),count:kM,minSeconds:kM,maxSeconds:kM,prompt:kM,imagePrompt:kM,titleOnScreen:KD().optional(),fullVideoLink:kM.optional(),musicVolume:kM.optional(),speed:kM.optional()}).strict().readonly().optional(),reviews:q({provider:kM,model:kM,thinking:J(UO).optional(),retries:kM,stages:dO(J(wk),q({mode:J(Tk),prompt:kM}).strict().readonly()).readonly()}).strict().readonly().optional(),imagePrompts:K(q({name:kM,number:kM}).strict().readonly()).readonly(),imageScale:q({every:J([`minutes`,`hour`]),value:kM}).strict().readonly().optional(),imageScenes:KD().optional(),thumbnailPrompt:kM,intro:kM,outro:kM,chunking:q({mode:J(fM),words:kM,characters:kM}).strict().readonly(),subtitles:q({mode:J(pM),language:mO(`en`),fontId:kM,fontSize:kM,position:J(mM)}).strict().readonly(),imageSeconds:kM.default(`15`),edgeSilenceSeconds:kM.default(`2`),zoomPercent:kM.default(String(JA)),motionStyle:J(qS).default(YA),silenceGapSeconds:kM.optional(),videoEdit:bM.strict().readonly().optional(),useBrandKit:KD().optional(),voices:zA.strict().readonly().optional(),ambientBed:q({source:J([`none`,...$k]),level:kM,fadeIn:kM,tail:kM}).strict().readonly().optional(),values:AM,provided:q({research:kM,article:kM,audio:NM.nullable(),thumbnail:NM.nullable(),images:K(NM).readonly(),reference:NM.nullable().optional(),shortsMusic:NM.nullable().optional(),ambientBed:NM.nullable().optional()}).strict().readonly()}).strict().readonly(),FM=q({schemaVersion:mO(1),librarySnapshot:DM.optional(),templateSource:q({id:OM,version:G().int().positive()}).strict().readonly().optional(),channelId:OM.optional(),form:PM,section:J([`content`,`outputs`,`style`,`review`]),variants:K(q({id:OM,title:kM,values:AM}).strict().readonly()).readonly(),queue:KD().optional(),expectedWords:kM,previewText:kM,fontUpload:q({operationId:OM,name:kM}).strict().readonly().nullable()}).strict().readonly(),IM=q({id:OM,document:FM}).strict().readonly(),LM=IM.unwrap().extend({baseVersion:G().int().positive(),mutationId:OM}).strict().readonly(),RM=IM.unwrap().extend({sourceId:OM}).strict().readonly(),zM=q({id:OM,baseVersion:G().int().positive()}).strict().readonly(),BM=q({id:OM,kind:J(MM),name:kM,state:J([`pending`,`copying`,`ready`,`reattach`]),stagedFileId:kM.nullable(),bytes:G().nonnegative(),error:kM.nullable()}).strict().readonly(),VM=q({id:OM,version:G().int().positive(),createdAt:kM,updatedAt:kM,document:FM}).strict().readonly(),HM=q({checkpointSet:K(Qj.unwrap().extend({reviewedFingerprint:kM}).strict().readonly()).readonly().optional(),requestId:OM,projectIds:K(kM).readonly(),queue:K(q({projectId:kM,batchId:kM,position:G(),state:J([`queued`,`active`,`finished`])}).strict().readonly()).readonly(),replayed:KD()}).strict().readonly(),UM=q({currency:mO(`USD`),rows:K(q({stage:kM,low:G().nullable(),high:G().nullable(),detail:kM,onPlan:KD().optional(),apiLow:G().nullable().optional(),apiHigh:G().nullable().optional()}).strict().readonly()).readonly(),low:G(),high:G(),unknown:G(),apiLow:G().optional(),apiHigh:G().optional(),apiUnknown:G().optional(),expectedWords:G(),catalogueDate:kM.nullable(),assumptions:K(kM).readonly()}).strict().readonly(),WM=q({checkpointSet:K(q({runIndex:G().int().nonnegative(),checkpointId:kM,stage:Zj,fingerprint:kM,workKeys:K(kM).readonly(),dependents:K(J(US)).readonly()}).strict().readonly()).readonly().optional(),id:OM,draftId:OM,draftVersion:G().int().positive(),fingerprint:kM,runs:K(q({draft:xM,rendered:AM,templates:AM}).strict().readonly()).readonly(),estimates:K(UM).readonly()}).strict().readonly(),GM=q({draft:VM,attachments:K(BM).readonly(),review:WM.nullable(),pendingStart:q({reviewId:OM,draftVersion:G().int().positive()}).strict().readonly().nullable(),start:HM.nullable()}).strict().readonly(),KM=q({title:W(),status:G(),detail:W().optional(),reason:W().optional(),currentVersion:G().int().positive().nullable().optional(),reviewId:TD().optional(),fields:K(q({field:W(),message:W()})).optional(),errors:K(q({path:W(),message:W()})).optional()}),qM=q({drafts:K(q({id:TD(),title:W(),version:G().int().positive(),updatedAt:W(),readable:KD()}).strict()).readonly()}).strict(),JM=zM.unwrap().omit({id:!0}).extend({draftId:TD(),reviewId:TD()}).strict();async function YM(e,t){let n;try{n=await e.json()}catch{throw po(e,void 0)}if(e.ok)return{ok:!0,value:So(t,n)};let r=KM.safeParse(n);if(!r.success)throw po(e,void 0);let i=r.data;if(![400,404,409].includes(e.status))throw po(e,{title:i.title,status:i.status,...i.detail===void 0?{}:{detail:i.detail},...i.fields===void 0?{}:{fields:i.fields}});return{ok:!1,reason:i.reason??`invalid-request`,message:i.detail??i.title,currentVersion:i.currentVersion??null,fields:i.fields??i.errors?.map(e=>({field:e.path,message:e.message}))??[],...i.reviewId===void 0?{}:{reviewId:i.reviewId}}}async function XM(e,t,n,r,i){return YM(await e.fetch(`${e.origin}/api/drafts${t}`,{method:n,...i===void 0?{}:{headers:{"content-type":`application/json`},body:JSON.stringify(i)}}),r)}function ZM(e){return`/${encodeURIComponent(TD().parse(e))}`}async function QM(e){return XM(e,``,`GET`,qM)}async function $M(e,t){return XM(e,``,`POST`,GM,IM.parse(t))}async function eN(e,t){return XM(e,ZM(t),`GET`,GM)}async function tN(e,t){let{id:n,...r}=LM.parse(t);return XM(e,ZM(n),`PUT`,GM,r)}async function nN(e,t){let{sourceId:n,...r}=RM.parse(t);return XM(e,`${ZM(n)}/fork`,`POST`,GM,r)}async function rN(e,t){let{id:n,...r}=zM.parse(t);return XM(e,ZM(n),`DELETE`,q({discarded:mO(!0)}).strict(),r)}async function iN(e,t){let{id:n,...r}=zM.parse(t);return XM(e,`${ZM(n)}/review`,`POST`,WM,r)}async function aN(e,t){let{draftId:n,...r}=JM.parse(t);return XM(e,`${ZM(n)}/start`,`POST`,HM,r)}function oN(e,t,n){return`${e.origin}/api/drafts${ZM(t)}/attachments/${encodeURIComponent(TD().parse(n))}/file`}async function sN(e,t,n,r,i){let a=new FormData;return a.set(`file`,r),YM(await e.fetch(oN(e,t,n),{method:`PUT`,body:a,...i?{signal:i}:{}}),BM)}var cN=[`fonts`];async function lN(e){return I(await e.fetch(`${e.origin}/api/fonts`))}async function uN(e,t){let n=new FormData;return n.set(`file`,t),I(await e.fetch(`${e.origin}/api/fonts`,{method:`POST`,body:n}))}function dN(e,t){return`${e.origin}/api/fonts/${encodeURIComponent(t)}/file`}var fN=`slopify.play-draft`;function pN(e){try{e?window.localStorage?.setItem(fN,e):window.localStorage?.removeItem(fN)}catch(e){console.warn(`Active draft browser storage is unavailable`,e)}}function mN(){try{return window.localStorage?.getItem(fN)??null}catch(e){return console.warn(`Active draft browser storage is unavailable`,e),null}}async function hN(e,t){let n=await Promise.allSettled([t.fetchQuery({...cb(e),staleTime:0}),t.fetchQuery({...ub(e),staleTime:0}),t.fetchQuery({...db(e),staleTime:0}),t.fetchQuery({...mb(e),staleTime:0}),t.fetchQuery({...lb(e),staleTime:0}),t.fetchQuery({queryKey:cN,queryFn:()=>lN(e),staleTime:0})]);for(let e of n)e.status===`rejected`&&console.warn(`Draft choices could not refresh`,e.reason)}var gN=`under Video and style → Ambient sound`;`${gN}`,`${gN}`;var _N=FM.parse({schemaVersion:1,form:{title:``,format:`16:9`,sources:{research:`off`,article:`generate`,audio:`generate`,images:`generate`,thumbnail:`off`,video:`generate`},llm:{provider:``,model:``},audio:{provider:``,model:``,voice:``,usePronunciationGlossary:!0,shareGlossary:!0,useNarrationAliases:!0,describeFigures:!0},images:{provider:``,model:``},articlePrompt:``,narrationPrompt:``,imagePrompts:[],thumbnailPrompt:``,intro:``,outro:``,chunking:{mode:`whole`,words:`500`,characters:`3000`},subtitles:{...gM,fontSize:`48`},imageSeconds:`15`,edgeSilenceSeconds:`2`,zoomPercent:String(JA),motionStyle:YA,videoEdit:mA,showFigures:!0,values:{},provided:{research:``,article:``,audio:null,images:[],thumbnail:null}},section:`content`,variants:[],expectedWords:`1500`,previewText:`Every story begins with a word.`,fontUpload:null}),vN={};function yN(e){vN=e}function bN(e,t=vN){let{form:n}=e;return n.llm.provider!==``||n.images.provider!==``||t.llm===void 0&&t.images===void 0?e:{...e,form:{...n,...t.llm===void 0?{}:{llm:{...t.llm}},...t.images===void 0?{}:{images:{...t.images}}}}}function xN(e){let t={...e.sources,...e.sources.article===`generate`?{}:{research:`off`},...e.sources.images===`off`?{video:`off`}:{}},n=t.audio===`off`?`off`:t.video===`off`&&e.subtitles.mode===`burn-in`?`files`:e.subtitles.mode;return{...e,sources:t,subtitles:{...e.subtitles,mode:n}}}function SN(e){let t=FM.parse(e);return JSON.stringify({...t,form:xN(t.form)})}function CN(e,t,n){return{...e,acknowledged:Math.max(e.acknowledged,t),version:n}}function wN(e,t){return t.type===`edit`?{...e,edited:e.edited+1}:CN(e,t.generation,t.version)}function TN(e,t,n){return{mutationId:n,document:FM.parse(JSON.parse(SN(e))),generation:t.edited,baseVersion:t.version}}function EN(){return{document:bN(_N),view:null,clock:{edited:0,acknowledged:0,version:0},id:null,recoveryId:null,pending:null,status:`unsaved`,error:null,reveal:null}}function DN(e,t,n){let r=e.form.provided,i=t.form.provided,a=new Map;for(let[e,t]of[[r.audio,i.audio],[r.thumbnail,i.thumbnail],[r.shortsMusic,i.shortsMusic],[r.ambientBed,i.ambientBed],...r.images.map((e,t)=>[e,i.images[t]])])e&&t&&a.set(e.attachmentId,t.attachmentId);let o=e=>e?{...e,attachmentId:a.get(e.attachmentId)??e.attachmentId}:null;return{...n,form:{...n.form,provided:{...n.form.provided,audio:o(n.form.provided.audio),thumbnail:o(n.form.provided.thumbnail),...n.form.provided.shortsMusic===void 0?{}:{shortsMusic:o(n.form.provided.shortsMusic)},...n.form.provided.ambientBed===void 0?{}:{ambientBed:o(n.form.provided.ambientBed)},images:n.form.provided.images.map(e=>({...e,attachmentId:a.get(e.attachmentId)??e.attachmentId}))}}}}function ON(e,t){if(e.draft.id!==t.id)return e;let n=t.document.form.provided,r=new Set([n.audio,n.thumbnail,n.shortsMusic,n.ambientBed,...n.images].flatMap(e=>e?[e.attachmentId]:[]));return{...e,attachments:e.attachments.filter(e=>r.has(e.id)).map(e=>{let n=t.view?.attachments.find(t=>t.id===e.id);return(e.state===`pending`||e.state===`copying`)&&(n?.state===`ready`||n?.state===`reattach`)?n:e})}}function kN(e,t){let n={...gM,...e},r=t.audio===`off`?`off`:(t.video===`off`||t.images===`off`)&&n.mode===`burn-in`?`files`:n.mode;if(r!==`off`)return{...n,mode:r};let i=hM.shape.fontId.safeParse(n.fontId),a=hM.shape.fontSize.safeParse(n.fontSize);return{...n,mode:r,fontId:i.success?i.data:gM.fontId,fontSize:a.success?a.data:gM.fontSize}}function AN(e){return e.mode===`off`||e.fontId!==``&&Number.isInteger(e.fontSize)&&e.fontSize>=16&&e.fontSize<=120}function jN(e){return e===`shortsMusic`||e===`ambientBed`?`audio`:e}function MN(e){return e.shorts?.enabled===!0&&e.sources.audio!==`off`}function NN(e){return e.ambientBed?.source===`upload`&&e.sources.video===`generate`&&e.sources.audio!==`off`}function PN(e){let t=e=>e.trim()===``?NaN:Number(e);return{enabled:e.enabled,count:t(e.count),minSeconds:t(e.minSeconds),maxSeconds:t(e.maxSeconds),...e.prompt.trim()?{prompt:e.prompt}:{},...e.imagePrompt.trim()?{imagePrompt:e.imagePrompt}:{},...Jk(e)}}({..._N.form}),{..._N.form.sources};var FN={off:`Off`,generate:`Generate`,provide:`Provide`,from_prompt:`From prompt`,prompt_by_llm:`Prompt by LLM`};function IN(e){return ej[e].map(e=>({value:e,label:FN[e]}))}function LN(e,t){return lj(BN({form:e,entries:t,slots:[],silenceGapSeconds:0}))}function RN(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.mode}function zN(e){return[e.audio,e.thumbnail,e.shortsMusic,e.ambientBed,e.reference,...e.images].flatMap(e=>e?.file===void 0?[]:[e.file])}function BN(e){let{form:t}=e;return{...t.checkpoints===void 0?{}:{checkpoints:t.checkpoints},title:t.title,format:t.format,sources:{...t.sources,...t.sources.article===`provide`?{research:`off`}:{},...t.sources.images===`off`?{video:`off`}:{}},llm:t.llm,audio:t.audio,images:t.images,...t.sources.images===`generate`&&t.reference!==void 0&&t.reference.source!==`off`?{reference:{source:t.reference.source,...t.reference.source===`prompt`?{prompt:t.reference.prompt}:{},thumbnail:t.reference.thumbnail}}:{},articlePrompt:t.articlePrompt,...t.narrationPrompt===void 0?{}:{narrationPrompt:t.narrationPrompt},...t.language===void 0||t.language===`en`?{}:{language:t.language},...t.sources.video===`generate`&&t.sources.images!==`off`&&t.sources.audio===`generate`&&t.audio.describeFigures===!0&&t.showFigures===!0?{showFigures:!0}:{},...t.sources.audio!==`off`&&t.youtubeDescription===!0?{youtubeDescription:!0,...t.descriptionPrompt?.trim()?{descriptionPrompt:t.descriptionPrompt}:{}}:{},...MN(t)&&t.shorts!==void 0?{shorts:PN(t.shorts)}:{},imagePrompts:t.imagePrompts,thumbnailPrompt:t.thumbnailPrompt,...t.thumbnailCount===3&&(t.sources.thumbnail===`from_prompt`||t.sources.thumbnail===`prompt_by_llm`)?{thumbnailCount:3}:{},...VN(HN(e,`intro`),e=>({intro:e})),...VN(HN(e,`outro`),e=>({outro:e})),values:UN(t.values,e.slots),provided:{research:t.provided.research,article:t.provided.article,...VN(t.provided.audio?.file,e=>({audio:e.id})),...VN(t.provided.thumbnail?.file,e=>({thumbnail:e.id})),...VN(t.sources.images===`generate`&&t.reference?.source===`provide`?t.provided.reference?.file:void 0,e=>({reference:e.id})),images:t.provided.images.flatMap(e=>e.file===void 0?[]:[e.file.id]),...MN(t)?VN(t.provided.shortsMusic?.file,e=>({shortsMusic:e.id})):{},...t.ambientBed?.source===`upload`?VN(t.provided.ambientBed?.file,e=>({ambientBed:e.id})):{}},chunking:t.chunking,subtitles:kN(t.subtitles,t.sources),silenceGapSeconds:e.silenceGapSeconds,imageSeconds:t.imageSeconds,edgeSilenceSeconds:t.edgeSilenceSeconds,zoomPercent:t.zoomPercent,motionStyle:t.motionStyle,...t.videoEdit===void 0?{}:{videoEdit:t.videoEdit},...t.voices!==void 0&&t.sources.audio===`generate`?{voices:t.voices}:{},...t.sources.document===`generate`?{document:t.document}:{},...VN(t.sources.video===`generate`&&t.sources.audio!==`off`?oA(t.ambientBed):void 0,e=>({ambientBed:e})),...t.sources.audio===`generate`?Ck(t):{},...VN(t.sources.audio===`off`?void 0:mk(t.loudness,e.loudness??nk),e=>({loudness:e}))}}function VN(e,t){return e===void 0?{}:t(e)}function HN(e,t){if(e.form.sources.audio!==`generate`)return;let n=t===`intro`?e.form.intro:e.form.outro,r=RN(e.entries,t,n);return n===``||r===void 0?void 0:{name:n,mode:r}}function UN(e,t){let n=Object.create(null);for(let r of t)n[r]=Object.hasOwn(e,r)?e[r]??``:``;return n}function WN(e,t){return e?.draftId===t.draftId&&e.version===t.version&&e.editGeneration===t.editGeneration}function GN({api:e,queryClient:t,current:n,flush:r,resave:i,render:a}){let o={receipt:null,pending:!1,starting:!1,uncertain:!1,valid:!1,error:null,fields:[],created:null},s,c=0,l=0,u=null,d=e=>{o={...o,...e},a()},f=()=>({draftId:n().id??``,version:n().clock.version,editGeneration:n().clock.edited}),p=()=>WN(s,f())&&n().clock.edited===n().clock.acknowledged&&o.receipt?.runs.length===KN(n().document),m=(e=!1)=>{c++,s=void 0,d({valid:!1,...e?{fields:[],error:null}:{}})},h=e=>d({error:e.message,fields:e.fields,valid:!1}),g=e=>{u=null,d({created:e,uncertain:!1,starting:!1,valid:!1})},_=async()=>{let t=u?.draftId;if(!t)return;let n=await eN(e,t);if(!n.ok){h(n);return}n.value.start&&g(n.value.start)};return{reset:()=>{c++,l++,s=void 0,u=null,o={receipt:null,pending:!1,starting:!1,uncertain:!1,valid:!1,error:null,fields:[],created:null},a()},state:()=>({...o,valid:o.valid&&p()}),invalidate:m,restore:e=>{c++,l++,s=void 0,u=e.pendingStart?{draftId:e.draft.id,baseVersion:e.pendingStart.draftVersion,reviewId:e.pendingStart.reviewId}:null,o={receipt:null,pending:!1,starting:!1,uncertain:u!==null,valid:!1,error:null,fields:[],created:e.start},a()},review:async()=>{if(o.pending||o.starting||o.uncertain||o.created)return;let a=++l;d({pending:!0,valid:!1,error:null,fields:[]});try{if(await Promise.all([hN(e,t),t.refetchQueries({queryKey:[`provider-models`]})]),a!==l||!await r()||!n().id)return;let o=f(),u=c,p=await iN(e,{id:o.draftId,baseVersion:o.version});if(a!==l||u!==c||!WN(o,f()))return;if(!p.ok){h(p);return}if(p.value.draftId!==o.draftId||p.value.draftVersion!==o.version)return;let m=KN(n().document);if(p.value.runs.length!==m){d({receipt:null,valid:!1,error:`The saved draft has ${qN(p.value.runs.length)}, but this page shows ${m}. Slopify saved this page again. Press Refresh review, then start.`}),i();return}s=o,d({receipt:p.value,valid:!0})}catch(e){a===l&&d({error:e instanceof Error?e.message:`This setup couldn't be checked. Press Refresh review to try again.`})}finally{a===l&&d({pending:!1})}},start:async()=>{if(o.starting||o.created||!u&&(!o.valid||!p()||o.pending||!o.receipt||XN(n().document,n().view)!==void 0)||(!u&&o.receipt&&(u={draftId:o.receipt.draftId,baseVersion:o.receipt.draftVersion,reviewId:o.receipt.id}),!u))return;let t=u;pN(t.draftId),d({starting:!0,error:null});try{if(o.uncertain&&(await _(),o.created))return;let n=await aN(e,t);if(n.ok){g(n.value);return}n.reason===`pending-start`||n.reason===`already-started`?(d({uncertain:!0}),await _()):(u=null,d({uncertain:!1}),h(n))}catch(e){d({uncertain:!0,valid:!1,error:`${bo(e instanceof Error?e.message:`Slopify didn't confirm the start`)} The run may already have started. Press Check Start result to find out before trying again.`})}finally{d({starting:!1})}}}}function KN(e){return e.variants.length+1}function qN(e){return e===1?`1 video`:`${e} videos`}function JN(e,t){if(e.starting)return`Starting…`;if(e.uncertain)return`Check Start result`;let n=e.valid&&e.receipt?e.receipt.runs.length:KN(t);return n===1?`Start run`:YN(t)?`Queue ${n} videos`:`Start ${n} videos`}function YN(e){return e.queue!==!1}function XN(e,t){if(e.fontUpload!==null)return`subtitles.fontUpload`;let{sources:n,provided:r}=e.form;return[...n.audio===`provide`&&r.audio?[{ref:r.audio,field:`provided.audio`}]:[],...n.thumbnail===`provide`&&r.thumbnail?[{ref:r.thumbnail,field:`provided.thumbnail`}]:[],...n.images===`provide`?r.images.map((e,t)=>({ref:e,field:`provided.images.${t}`})):[],...MN(e.form)&&r.shortsMusic?[{ref:r.shortsMusic,field:`shorts.music`}]:[],...NN(e.form)&&r.ambientBed?[{ref:r.ambientBed,field:`ambientBed.file`}]:[]].find(({ref:e})=>t?.attachments.find(t=>t.id===e.attachmentId)?.state!==`ready`)?.field}function ZN(e,t){return e?.draftId===t.draftId&&e.attachmentId===t.attachmentId}function QN({api:e,queryClient:t,state:n,edit:r,flush:i,generation:a,publish:o,render:s}){let c=(0,m.useRef)(0),l=(0,m.useRef)(null),u=(0,m.useRef)(null),d=(0,m.useRef)(new Map),f=(0,m.useRef)(new Map),p=e=>{let t=n.current.document.form.provided,r=[t.audio,t.thumbnail,t.shortsMusic,t.ambientBed,t.reference,...t.images].find(t=>t?.attachmentId===e.attachmentId);return ZN(r&&n.current.id?{draftId:n.current.id,attachmentId:r.attachmentId}:void 0,e)};(0,m.useEffect)(()=>{for(let[e,t]of d.current)t!==a()&&d.current.delete(e);for(let[e,t]of f.current)(!p(t.owner)||t.generation!==a())&&(t.controller.abort(),f.current.delete(e))}),(0,m.useEffect)(()=>{let e=f.current,t=d.current;return()=>{c.current++,t.clear();for(let t of e.values())t.controller.abort();e.clear()}},[]);let h=async(t,l,u)=>{if(l.length===0)return;let m=jN(t),h=m===`images`&&!u?l:l.slice(-1),g=h.map(e=>({attachmentId:crypto.randomUUID(),name:e.name})),_=c.current,v=a();for(let e of g)d.current.set(e.attachmentId,v);let y=n.current.document,b=y.form.provided;r({...y,form:{...y.form,provided:m===`images`?{...b,images:u?b.images.flatMap(e=>e.attachmentId===u?g:[e]):[...b.images,...g]}:{...b,[t]:g.at(-1)??null}}});let x=await i();for(let e of g)d.current.delete(e.attachmentId);if(!x||v!==a()||_!==c.current){s();return}let S=n.current.id;S&&await Promise.all(g.map(async(t,r)=>{let i=h[r],s={draftId:S,attachmentId:t.attachmentId};if(!i||!p(s))return;let l=new AbortController;f.current.set(t.attachmentId,{owner:s,controller:l,generation:v});let u=e=>{let r=n.current.view;v===a()&&_===c.current&&r?.draft.id===S&&p(s)&&!l.signal.aborted&&o({view:{...r,review:null,attachments:[...r.attachments.filter(e=>e.id!==t.attachmentId),e]}})};try{let n=await sN(e,S,t.attachmentId,i,l.signal);n.ok?u(n.value):u({id:t.attachmentId,kind:m,name:t.name,state:`reattach`,stagedFileId:null,bytes:0,error:n.message})}catch(e){u({id:t.attachmentId,kind:m,name:t.name,state:`reattach`,stagedFileId:null,bytes:0,error:e instanceof Error?e.message:`Reattach this file`})}finally{f.current.delete(t.attachmentId)}}))},g=e=>{l.current=null;let t=n.current.document;r({...t,fontUpload:null,form:{...t.form,subtitles:{...t.form.subtitles,fontId:e}}})},_=async o=>{let d=crypto.randomUUID();l.current=d,r({...n.current.document,fontUpload:{operationId:d,name:o.name}});let f=c.current,p=a();if(!await i()||p!==a()||f!==c.current){l.current===d&&(l.current=null),s();return}if(n.current.document.fontUpload?.operationId===d)try{let{font:r}=await uN(e,o);if(p!==a()||f!==c.current||n.current.document.fontUpload?.operationId!==d)return;t.setQueryData(cN,e=>({fonts:[...(e?.fonts??[]).filter(e=>e.id!==r.id),r]})),g(r.id),await i()}catch(e){p===a()&&f===c.current&&n.current.document.fontUpload?.operationId===d&&(u.current={operationId:d,message:e instanceof Error?e.message:`Reattach this font`},s())}finally{l.current===d&&(l.current=null,s())}},v=l.current!==null&&l.current===n.current.document.fontUpload?.operationId;return{attachmentUploading:e=>{let t=f.current.get(e);return d.current.get(e)===a()||t!==void 0&&t.generation===a()&&p(t.owner)&&!t.controller.signal.aborted},fontUpload:{pending:v,error:u.current?.operationId===n.current.document.fontUpload?.operationId?u.current?.message:void 0,pick:e=>{_(e)}},attach:h,selectFont:g,uploadSubtitleFont:_,fontUploading:v}}function $N(e,t,n){(0,m.useEffect)(()=>{let r=e=>[`prompts`,`entries`,`providers`,`provider-models`,`fonts`,`settings`].includes(String(e[0])),i=t.getQueryCache().subscribe(e=>{e.type===`updated`&&r(e.query.queryKey)&&(e.action.type===`success`||e.action.type===`invalidate`)&&n.invalidate()}),a=()=>{n.invalidate(),hN(e,t),t.refetchQueries({queryKey:[`provider-models`]})};return window.addEventListener(`focus`,a),()=>{i(),window.removeEventListener(`focus`,a)}},[e,t,n])}function eP(){let{api:e}=z(),t=_(),[,n]=(0,m.useReducer)(e=>e+1,0),r=(0,m.useRef)(EN()),i=(0,m.useMemo)(()=>{let i,a=null,o=!1,s=0,c=!1,l=null,u=!0,d=e=>{r.current={...r.current,...e},u&&n()},f=()=>{clearTimeout(i),i=void 0},p=()=>{t.invalidateQueries({queryKey:[`play-drafts`]})},m=e=>{d({status:`error`,error:e instanceof Error?e.message:`Your latest changes weren't saved. Keep this page open and try again.`})},h=e=>e.ok?!0:(d({status:e.reason===`conflict`?`conflict`:`error`,error:e.message}),!1),g=e=>{b.restore(e),d({...EN(),document:e.draft.document,view:e,id:e.draft.id,clock:{edited:0,acknowledged:0,version:e.draft.version},status:`saved`}),pN(e.draft.id),p()},_=async()=>{let t=s;for(;r.current.clock.edited>r.current.clock.acknowledged;){if(r.current.status===`conflict`||t!==s||l!==null&&l===r.current.id)return!1;let n=r.current,i=n.id??crypto.randomUUID(),a=n.pending??TN(n.document,n.clock,crypto.randomUUID());d({id:i,pending:a,status:`saving`,error:null});try{let n=a.baseVersion===0?await $M(e,{id:i,document:a.document}):await tN(e,{id:i,baseVersion:a.baseVersion,mutationId:a.mutationId,document:a.document});if(t!==s)return!1;if(!h(n))return n.reason!==`conflict`&&d({pending:null}),!1;let c=wN(r.current.clock,{type:`acknowledge`,generation:a.generation,version:n.value.draft.version});if(d({clock:c,view:{...ON(n.value,r.current),review:c.edited>c.acknowledged?null:n.value.review},pending:null,status:c.edited>c.acknowledged?`unsaved`:`saved`,error:null}),pN(i),p(),!o)return!0}catch(e){return t===s&&m(e),!1}}return r.current.status!==`conflict`&&r.current.status!==`error`},v=()=>c?Promise.resolve(!1):a||(r.current.clock.edited===r.current.clock.acknowledged?Promise.resolve(!0):l!==null&&l===r.current.id?Promise.resolve(!1):(a=_().finally(()=>{a=null}),a)),y=()=>(f(),o=!0,v()),b=GN({api:e,queryClient:t,current:()=>r.current,flush:y,resave:()=>x(r.current.document),render:()=>{u&&n()}}),x=e=>{if(b.state().starting||b.state().uncertain||b.state().created)return;b.invalidate(JSON.stringify({...e,section:r.current.document.section})!==JSON.stringify(r.current.document));let t=r.current;d({document:e,clock:wN(t.clock,{type:`edit`}),view:t.view?{...t.view,review:null}:null,status:t.status===`conflict`||t.status===`error`?t.status:`unsaved`}),f(),!(c||l!==null&&l===t.id||t.status===`conflict`||t.status===`error`)&&(t.id?i=setTimeout(()=>{y()},500):(o=!1,v()))},S=async(n,i=()=>!0)=>{if(b.state().starting||b.state().uncertain||b.state().created||(r.current.id!==n||r.current.status!==`conflict`)&&!await y()||!i())return!1;let a=++s,o=r.current.clock.edited;f();try{let c=await eN(e,n);return a!==s||o!==r.current.clock.edited||!i()?!1:h(c)?(T=null,g(c.value),await hN(e,t),i()):(r.current.id||d({recoveryId:n}),!1)}catch(e){return a===s&&o===r.current.clock.edited&&(m(e),r.current.id||d({recoveryId:n})),!1}},C=async()=>{if(b.state().starting||b.state().uncertain||b.state().created)return;let e=s;await y()&&e===s&&(s++,T=null,d(EN()),b.reset(),pN(null))},w=async({id:t,version:n})=>{if(b.state().starting||b.state().uncertain||b.state().created)throw Error(`Resolve the pending Start before discarding a draft`);if(c||l!==null)throw Error(`Wait for the current draft operation before discarding`);let i=s;l=t,(r.current.id??r.current.recoveryId)===t&&f();try{a&&await a;let o=await rN(e,{id:t,baseVersion:n});if(!o.ok&&o.reason!==`not-found`)throw Error(o.message);if(p(),i!==s||(r.current.id??r.current.recoveryId)!==t)return;f(),s++,T=null,d(EN()),b.reset(),pN(null)}finally{l=null}},T=null;return{review:b,takeCreated:()=>{let e=b.state().created;if(!e)return null;s++,d(EN()),b.reset(),pN(null);for(let e of[[`projects`],[`staging`],[`play-drafts`]])t.invalidateQueries({queryKey:e});return e},edit:x,flush:y,open:S,newDraft:C,adoptDefaults:e=>{let t=r.current;if(t.id!==null||t.clock.edited>0||t.view!==null)return;let n=bN(t.document,e);n!==t.document&&d({document:n})},discard:w,saveAsNew:async()=>{if(b.state().starting||b.state().uncertain||b.state().created||(f(),c||l!==null))return;a&&await a;let t=r.current;if(!t.id||!t.view&&t.status!==`conflict`){await y();return}let n=s;T?.sourceId!==t.id&&(T=null),T??={sourceId:t.id,id:crypto.randomUUID(),document:TN(t.document,t.clock,crypto.randomUUID()).document,generation:t.clock.edited};let i=T;c=!0;try{let t=await nN(e,{sourceId:i.sourceId,id:i.id,document:i.document});if(n!==s)return;if(!h(t)){t.reason===`conflict`&&(T=null);return}let a=r.current.clock.edited>i.generation?r.current.document:null;s++,g(t.value),T=null,c=!1,a&&x(DN(i.document,t.value.draft.document,a))}catch(e){n===s&&m(e)}finally{c=!1}},navigate:async(e,t)=>{let n=s,i={...r.current.document,section:e};r.current.id||r.current.clock.edited>0?x(i):d({document:i}),await y()&&n===s&&d({reveal:{section:e,...t===void 0?{}:{field:t},sequence:(r.current.reveal?.sequence??0)+1}})},generation:()=>s,publish:d,start:()=>{u=!0;let e=mN();e&&S(e)},stop:()=>{u=!1,f()}}},[e,t]);(0,m.useEffect)(()=>(i.start(),i.stop),[i]),$N(e,t,i.review);let a=QN({api:e,queryClient:t,state:r,edit:i.edit,flush:i.flush,generation:i.generation,publish:i.publish,render:n}),o=r.current;return{...a,review:i.review.state(),reviewDraft:i.review.review,startRun:i.review.start,invalidateReview:i.review.invalidate,takeCreated:i.takeCreated,document:o.document,section:o.document.section,view:o.view,status:o.status,error:o.error,edited:o.clock.edited,acknowledged:o.clock.acknowledged,reveal:o.reveal,edit:i.edit,flush:i.flush,open:i.open,generation:i.generation,newDraft:i.newDraft,adoptDefaults:i.adoptDefaults,discard:i.discard,saveAsNew:i.saveAsNew,navigate:i.navigate,activeId:o.id??o.recoveryId}}var tP=(0,m.createContext)(null);function nP({children:e}){let t=eP();return(0,h.jsx)(tP.Provider,{value:t,children:e})}function rP(){return(0,m.useContext)(tP)}function iP(){let e=(0,m.useContext)(tP);if(!e)throw Error(`PlayDraftProvider is required`);return e}var aP=(0,m.createContext)(void 0);function oP({children:e}){let[t,n]=(0,m.useState)(()=>new Map),r=(0,m.useCallback)((e,t)=>{n(n=>{let r=n.get(e),i=typeof t==`function`?t(r):t;if(r===i)return n;let a=new Map(n);return i===void 0?a.delete(e):a.set(e,i),a})},[]),i=(0,m.useMemo)(()=>({prompts:t,updatePrompt:r}),[t,r]);return(0,h.jsx)(aP.Provider,{value:i,children:e})}function sP(e){let t=(0,m.useContext)(aP),[n,r]=(0,m.useState)(void 0),i=t?.updatePrompt,a=(0,m.useCallback)(t=>{i?i(e,t):r(t)},[e,i]);return[t?t.prompts.get(e):n,a]}function cP(e){return e.trim()===``?NaN:Number(e)}function lP(){let e=iP(),t=(0,m.useRef)(e);t.current=e;let n=e.document.form,r=t=>{if(!t)return;let n=e.view?.attachments.find(e=>e.id===t.attachmentId),r=n?.state===`ready`&&n.stagedFileId?{id:n.stagedFileId,stageKind:n.kind===`reference`?`images`:n.kind,path:n.stagedFileId,originalFilename:n.name,bytes:n.bytes,state:`staged`,createdAt:e.view?.draft.createdAt??``}:void 0;return{key:t.attachmentId,name:t.name,file:r,error:n?.error??(n?.state===`reattach`||!r&&!e.attachmentUploading(t.attachmentId)?`Reattach this file`:void 0)}},i={...n,sources:{...n.sources,document:KS(n.sources,`document`)},document:{theme:rC(n.document),...n.document?.custom===void 0?{}:{custom:n.document.custom}},imagePrompts:n.imagePrompts.map(e=>({...e,number:Number(e.number)})),chunking:n.chunking.mode===`words`?{mode:`words`,...n.chunking.words===``?{}:{words:Number(n.chunking.words)}}:n.chunking.mode===`characters`?{mode:`characters`,...n.chunking.characters===``?{}:{characters:Number(n.chunking.characters)}}:{mode:n.chunking.mode},subtitles:{...n.subtitles,fontSize:Number(n.subtitles.fontSize)},imageSeconds:cP(n.imageSeconds),edgeSilenceSeconds:cP(n.edgeSilenceSeconds),zoomPercent:cP(n.zoomPercent),provided:{research:n.provided.research,article:n.provided.article,audio:r(n.provided.audio),thumbnail:r(n.provided.thumbnail),...n.provided.reference===void 0?{}:{reference:r(n.provided.reference)},shortsMusic:r(n.provided.shortsMusic),ambientBed:r(n.provided.ambientBed),images:n.provided.images.flatMap(e=>{let t=r(e);return t?[t]:[]})}},a=(0,m.useRef)(i);return a.current=i,[i,(0,m.useCallback)(e=>{let n=t.current.document,r=typeof e==`function`?e(a.current):e;a.current=r;let i=(e,t)=>e===void 0?``:Object.is(e,Number(t))?t:String(e),o=e=>e?{attachmentId:e.key,name:e.name}:null,{document:s,...c}=r.sources,{document:l,...u}=r,{shortsMusic:d,ambientBed:f}=r.provided,p=n.form.sources.document!==void 0||s!==`off`,m=n.form.document!==void 0||l.theme!==rC(n.form.document)||l.custom!==void 0;t.current.edit({...n,form:{...u,sources:p?r.sources:c,...m?{document:l}:{},imagePrompts:r.imagePrompts.map(e=>({...e,number:i(e.number,n.form.imagePrompts.find(t=>t.name===e.name)?.number??String(e.number))})),chunking:{...n.form.chunking,mode:r.chunking.mode,...r.chunking.mode===`words`?{words:i(r.chunking.words,n.form.chunking.words)}:{},...r.chunking.mode===`characters`?{characters:i(r.chunking.characters,n.form.chunking.characters)}:{}},subtitles:{...n.form.subtitles,...r.subtitles,fontSize:i(r.subtitles.fontSize,n.form.subtitles.fontSize)},imageSeconds:Object.is(r.imageSeconds,cP(n.form.imageSeconds))?n.form.imageSeconds:String(r.imageSeconds),edgeSilenceSeconds:Object.is(r.edgeSilenceSeconds,cP(n.form.edgeSilenceSeconds))?n.form.edgeSilenceSeconds:String(r.edgeSilenceSeconds),zoomPercent:Object.is(r.zoomPercent,cP(n.form.zoomPercent))?n.form.zoomPercent:String(r.zoomPercent),provided:{research:r.provided.research,article:r.provided.article,audio:o(r.provided.audio),thumbnail:o(r.provided.thumbnail),...r.provided.reference===void 0&&n.form.provided.reference===void 0?{}:{reference:o(r.provided.reference)},images:r.provided.images.map(e=>({attachmentId:e.key,name:e.name})),...d!==void 0||n.form.provided.shortsMusic!==void 0?{shortsMusic:o(d)}:{},...f!==void 0||n.form.provided.ambientBed!==void 0?{ambientBed:o(f)}:{}}}})},[])]}var uP={newVideo:[`C`],goHome:[`G`,`H`],goProjects:[`G`,`P`],goCalendar:[`G`,`C`],goSchedules:[`G`,`S`],goLibrary:[`G`,`L`],goChannels:[`G`,`K`],goSettings:[`G`,`,`],nextAction:[`Shift`,`N`],copyDescription:[`Shift`,`D`],reviewSetup:[`Ctrl`,`Enter`],save:[`Ctrl`,`S`]},dP=`slopify.notifications.browser`,fP=`slopify.notifications.sent`,pP=6e4,mP=new Set;function hP(){return typeof window<`u`&&`Notification`in window}function gP(){return hP()?Notification.permission:`unsupported`}function _P(){try{return window.localStorage.getItem(dP)===`on`}catch{return!1}}function vP(e){try{e?window.localStorage.setItem(dP,`on`):window.localStorage.removeItem(dP)}catch{}for(let e of mP)e()}function yP(e){mP.add(e);let t=t=>{t.key===dP&&e()};return window.addEventListener(`storage`,t),()=>{mP.delete(e),window.removeEventListener(`storage`,t)}}function bP(){return _P()&&gP()===`granted`}function xP(e){if(e===`unsupported`)return`This browser can't show notifications. Use a current Chrome, Edge, Firefox or Safari, or set a Notification URL below instead.`;if(e===`denied`)return`Notifications are blocked for this site. Allow them in your browser's site settings (the icon left of the address bar), reload, then turn Browser notifications on again.`}async function SP(){return hP()?Notification.permission==="default"?await Notification.requestPermission():Notification.permission:`unsupported`}async function CP(e,t=Date.now){let n=()=>{let n={};try{let e=JSON.parse(window.localStorage.getItem(fP)??`{}`);typeof e==`object`&&e&&(n=Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`number`&&t()-e[1]<pP)))}catch{}if(n[e]!==void 0)return!1;try{window.localStorage.setItem(fP,JSON.stringify({...n,[e]:t()}))}catch{}return!0};try{if(typeof navigator<`u`&&navigator.locks!==void 0)return await navigator.locks.request(`slopify-run-notification`,n)}catch{}return n()}function wP(e,t){let n=new Notification(e.text.headline,{body:e.text.detail,tag:`slopify-run-${e.projectId}`});n.onclick=()=>{window.focus(),t(e.projectId),n.close()}}function TP(e,t){let n=new Notification(e.text.headline,{body:e.text.detail,tag:`slopify-topics-${e.scheduleId}`});n.onclick=()=>{window.focus(),t(),n.close()}}function EP(e,t){let n=e.title.trim()===``?`Untitled project`:e.title.trim(),r=new Notification(`Started: ${n}`,{body:`Slopify is working on it. You'll hear a different chime when it ends.`,tag:`slopify-run-${e.projectId}`});r.onclick=()=>{window.focus(),t(e.projectId),r.close()}}var DP=`slopify.notifications.sound`,OP=new Set;function kP(){try{return window.localStorage.getItem(DP)!==`off`}catch{return!0}}function AP(e){try{e?window.localStorage.removeItem(DP):window.localStorage.setItem(DP,`off`)}catch{}for(let e of OP)e()}function jP(e){OP.add(e);let t=t=>{t.key===DP&&e()};return window.addEventListener(`storage`,t),()=>{OP.delete(e),window.removeEventListener(`storage`,t)}}var MP={start:[[784,0,.16],[1175,.14,.3]],end:[[1047,0,.18],[1319,.16,.18],[1568,.32,.55]]};function NP(){if(typeof window<`u`&&typeof window.AudioContext==`function`)try{return new window.AudioContext}catch{return}}function PP(){let e=NP();e!==void 0&&e.resume().catch(()=>{}).finally(()=>void e.close().catch(()=>{}))}function FP(e){let t=NP();t!==void 0&&(async()=>{t.state!==`running`&&await Promise.race([t.resume().catch(()=>{}),new Promise(e=>setTimeout(e,400))]);let n=IP(t,e);setTimeout(()=>void t.close().catch(()=>{}),(n+.5)*1e3)})()}function IP(e,t){let n=e.currentTime+.02,r=e.createDynamicsCompressor();r.threshold.value=-3,r.ratio.value=12,r.connect(e.destination);for(let[i,a,o]of MP[t])for(let[t,s,c]of[[1,.9,`sine`],[2,.25,`triangle`]]){let l=e.createOscillator(),u=e.createGain();l.type=c,l.frequency.value=i*t,u.gain.setValueAtTime(1e-4,n+a),u.gain.exponentialRampToValueAtTime(s,n+a+.012),u.gain.exponentialRampToValueAtTime(1e-4,n+a+o),l.connect(u).connect(r),l.start(n+a),l.stop(n+a+o+.05)}return Math.max(...MP[t].map(([,e,t])=>e+t))}function LP(e,t){if(e===`running`)switch(t){case`done`:return`ready`;case`partial`:return`partial`;case`failed`:return`failed`;case`pending`:return`waiting`;default:return}}var RP={article:`the article`,images:`an image`,narration:`the narration`,thumbnail:`the thumbnail`,shorts:`a short`};function zP(e){let t=e.title.trim()===``?`Untitled project`:e.title.trim(),n=VP(e.reason),r=RP[e.stage]??`an item`,i=`Review needs a decision: ${t}`;return{headline:n===void 0?i:`${i} — ${n}`,detail:`The automatic review flagged ${r} and kept it. Open the project and press Overrule to keep it or Redo to make it again.`}}var BP=140;function VP(e){let t=e?.split(/\r?\n/).map(e=>e.trim()).find(e=>e!==``);if(t!==void 0)return t.length<=BP?t:`${t.slice(0,139).trimEnd()}…`}function HP(e,t){let n=t.title.trim()===``?`Untitled project`:t.title.trim();switch(e){case`ready`:return t.makesVideo?{headline:`Video ready: ${n}`,detail:`Open the project to watch it.`}:{headline:`Run finished: ${n}`,detail:`Open the project to see its files.`};case`partial`:{let e=VP(t.reason),r=t.makesVideo?`Video ready with problems: ${n}`:`Run finished with problems: ${n}`;return{headline:e===void 0?r:`${r} — ${e}`,detail:`Open the project to see which step failed and the button that fixes it.`}}case`failed`:{let e=VP(t.reason);return{headline:e===void 0?`Run failed: ${n}`:`Run failed: ${n} — ${e}`,detail:`Open the project to see what stopped it and press Retry.`}}case`waiting`:return{headline:`Waiting for you: ${n}`,detail:`Open the project to review the held step or press Continue the run.`}}}function UP(e){let t=e.scheduleName.trim()===``?`Untitled schedule`:e.scheduleName.trim(),n=e.added,r=e.waiting>n?` ${String(e.waiting)} are waiting in all.`:``;return{headline:`${String(n)} new ${n===1?`topic is`:`topics are`} waiting for you`,detail:`Open Calendar → Suggested topics → ${t} to queue or reject ${n===1?`it`:`them`}.${r}`}}var WP={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.`},GP=2048;function KP(e){let t=e.trim();if(t===``)return;if(t.length>2048)return`Keep the Notification URL to ${String(GP)} 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 qP=new Set([`done`,`partial`,`failed`,`canceled`]);function JP(e){let t=new Map,n=new Set,r=()=>e.sounds?.()===!0&&e.play!==void 0,i=new Set,a=t=>{let n=t.catch(t=>{e.report(t)}).finally(()=>{i.delete(n)});i.add(n)},o=async(t,n,i)=>{let a=await e.subject(t);a!==void 0&&await e.claim(`${t}:${n}`)&&(r()&&e.play?.(`end`),e.enabled()&&e.show({projectId:t,kind:i,text:HP(i,a)}))},s=async t=>{let n=await e.subject(t);n!==void 0&&await e.claim(`${t}:started`)&&(r()&&e.play?.(`start`),e.enabled()&&e.showStart?.({projectId:t,title:n.title}))};return{observe:i=>{let c=t.get(i.projectId);if(t.set(i.projectId,i.state),c===i.state)return;let l=e.enabled()||r();if(i.state===`running`&&!n.has(i.projectId)){n.add(i.projectId),(r()||e.enabled()&&e.showStart!==void 0)&&a(s(i.projectId));return}qP.has(i.state)&&n.delete(i.projectId);let u=LP(c,i.state);u!==void 0&&l&&a(o(i.projectId,i.state,u))},observeTopics:t=>{if(t.added<=0||!e.enabled()||e.showTopics===void 0)return;let n=e.showTopics;a((async()=>{await e.claim(`topics:${t.scheduleId}:${String(t.waiting)}`)&&n({scheduleId:t.scheduleId,text:UP(t)})})())},observeReview:t=>{if(!e.enabled()||e.showReview===void 0)return;let n=e.showReview;a((async()=>{let r=await e.subject(t.projectId);r!==void 0&&await e.claim(`review:${t.verdictId}`)&&n({projectId:t.projectId,text:zP({title:r.title,stage:t.stage,reason:t.reason})})})())},seed:async()=>{try{for(let r of await e.seed())t.has(r.id)||(t.set(r.id,r.status),(r.status===`running`||r.status===`paused`)&&n.add(r.id))}catch(t){e.report(t)}},settled:async()=>{for(;i.size>0;)await Promise.all([...i])}}}function YP(){let{api:e}=z(),t=_(),n=Xi(),r=(0,m.useRef)(n);r.current=n;let i=(0,m.useMemo)(()=>JP({enabled:bP,sounds:kP,play:FP,showStart:e=>{EP(e,e=>{r.current({to:`/projects/$projectId`,params:{projectId:e}})})},seed:async()=>(await t.fetchQuery({...rb(e),staleTime:5e3})).projects,subject:async t=>{let n=await jo(e,t);return{title:n.project.title,makesVideo:n.project.config.sources.video!==`off`,reason:n.stages.find(e=>e.state===`failed`)?.failureReason??void 0}},claim:e=>CP(e),showTopics:e=>{TP(e,()=>{r.current({to:`/calendar`})})},showReview:e=>{wP(e,e=>{r.current({to:`/projects/$projectId`,params:{projectId:e}})})},show:e=>{wP(e,e=>{r.current({to:`/projects/$projectId`,params:{projectId:e}})})},report:e=>{console.warn(`Slopify couldn't show a run notification.`,e)}}),[e,t]);return(0,m.useEffect)(()=>{let e=()=>bP()||kP();e()&&i.seed();let t=()=>{e()&&i.seed()},n=yP(t),r=jP(t);return window.addEventListener(`pointerdown`,PP,{once:!0}),window.addEventListener(`keydown`,PP,{once:!0}),()=>{n(),r(),window.removeEventListener(`pointerdown`,PP),window.removeEventListener(`keydown`,PP)}},[i]),i}function XP({open:e,title:t,onClose:n,children:r,footer:i,width:a=`wide`,headingRef:o,className:s}){let c=(0,m.useId)(),l=(0,m.useRef)(null),u=o??l,d=(0,m.useRef)(null),f=(0,m.useRef)(null),p=(0,m.useRef)(n);return(0,m.useEffect)(()=>{p.current=n}),(0,m.useEffect)(()=>{if(!e)return;d.current=document.activeElement,f.current?.contains(document.activeElement)||u.current?.focus({preventScroll:!0});let t=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[data-slot="dialog-content"][data-state="open"]`)||p.current()};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t);let e=d.current;e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[e,u]),e?(0,h.jsxs)(`aside`,{ref:f,role:`dialog`,"aria-modal":`false`,"aria-labelledby":c,"data-slot":`drawer`,className:L(`fixed top-0 right-0 bottom-0 z-50 flex w-full flex-col border-l border-line bg-raised shadow-[var(--shadow-dialog)]`,a===`wide`?`sm:w-[min(560px,100vw)]`:`sm:w-[min(440px,100vw)]`,`data-[state=open]:animate-tick-in motion-reduce:animate-none`,s),"data-state":`open`,children:[(0,h.jsxs)(`div`,{className:`flex min-h-12 shrink-0 items-center gap-3 border-b border-line px-4`,children:[(0,h.jsx)(`h2`,{ref:u,id:c,tabIndex:-1,className:`min-w-0 flex-1 truncate text-title-3 font-semibold focus-visible:outline-offset-[-2px]`,children:t}),(0,h.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close`,className:`inline-flex size-8 items-center justify-center rounded-control text-ink-2 hover:bg-raised hover:text-ink`,children:(0,h.jsx)(el,{"aria-hidden":`true`,className:`size-4`})})]}),(0,h.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:r}),i?(0,h.jsx)(`div`,{className:`flex min-h-14 shrink-0 flex-wrap items-center gap-2 border-t border-line px-4 py-2 pb-[max(8px,env(safe-area-inset-bottom))]`,children:i}):null]}):null}var ZP=[{id:`text-key`,title:`1. Connect a text provider`,target:`keys-llm`,page:`settings`},{id:`audio-key`,title:`2. Connect a voice provider`,target:`keys-tts`,page:`settings`},{id:`image-key`,title:`3. Connect an image provider`,target:`keys-image`,page:`settings`},{id:`voice`,title:`4. Add a narration voice`,target:`voices`,page:`settings`},{id:`article-name`,title:`5. Name your article prompt`,target:`prompt-name`,page:`article`},{id:`article-body`,title:`6. Write instructions with keywords`,target:`prompt-body`,page:`article`},{id:`article-keywords`,title:`7. Check the detected keywords`,target:`prompt-slots`,page:`article`},{id:`article-save`,title:`8. Save your article prompt`,target:`prompt-save`,page:`article`},{id:`image-prompt`,title:`9. Create an image prompt`,target:`prompt-editor`,page:`image`},{id:`image-save`,title:`10. Save your image prompt`,target:`prompt-save`,page:`image`},{id:`play-options`,title:`11. Name the project and choose text generation`,target:`play-options`,page:`play`},{id:`play-article`,title:`12. Choose your article`,target:`play-article`,page:`play`},{id:`play-keywords`,title:`13. Fill in your keywords`,target:`play-keywords`,page:`play`},{id:`play-audio`,title:`14. Choose narration`,target:`play-audio`,page:`play`},{id:`play-images`,title:`15. Choose images`,target:`play-images`,page:`play`},{id:`play-video`,title:`16. Choose video output`,target:`play-video`,page:`play`},{id:`play-subtitles`,title:`17. Style optional subtitles`,target:`play-subtitles`,page:`play`},{id:`play-start`,title:`18. Review and start your run`,target:`play-start`,page:`play`},{id:`project`,title:`19. Follow and control the run`,target:`project-controls`,page:`project`},{id:`download`,title:`20. Download your results`,target:`project-video`,page:`project`},{id:`run-cost`,title:`21. See what the run cost`,target:`project-rail-cost`,page:`project`},{id:`studio-prep`,title:`22. Prepare the YouTube upload`,target:`project-rail-video`,page:`project`},{id:`home`,title:`23. Check Home each day`,target:`home`,page:`home`},{id:`channels`,title:`24. Set up a channel`,target:`channels`,page:`channels`},{id:`calendar`,title:`25. Plan uploads on the calendar`,target:`calendar`,page:`calendar`}],QP=`home`;function $P(e,t){return e.active?t.type===`project-created`?{...e,projectId:t.id,step:ZP.findIndex(e=>e.id===`project`)}:t.kind===`article`?{...e,articleId:t.id}:t.kind===`image`?{...e,imageId:t.id}:e:e}function eF(e){let t=ZP.findIndex(t=>t.id===e);return t<0?void 0:t}var tF={"play-options":`content`,"play-article":`content`,"play-keywords":`content`,"play-audio":`outputs`,"play-images":`outputs`,"play-video":`outputs`,"play-subtitles":`style`,"play-start":`content`};function nF(e){return e.kind===`keyed`?e.hasKey:e.kind===`local`?e.available:e.installed&&e.issue===void 0}var rF={research:`Research`,article:`Article`,audio:`Audio`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`,document:`Document`};function iF(e){return e.sources.video===`off`?e.sources.audio===`off`?`article`:`audio`:`video`}function aF(e,t){return e===`video`&&iF(t)===`audio`?`Audio export`:rF[e]}function oF(e,t){return e.kind===`video`&&e.state===`running`&&t.subtitles!==void 0&&t.subtitles.mode!==`off`&&e.progressTotal===100&&(e.progressCurrent??0)<=35}var sF={research:(e,t)=>`chapter ${String(e)} of ${String(t)}`,article:(e,t)=>`${String(e)} of ${String(t)}`,audio:(e,t)=>`chunk ${String(e)} of ${String(t)}`,images:(e,t)=>`image ${String(e)} of ${String(t)}`,thumbnail:(e,t)=>`${String(e)} of ${String(t)}`,video:(e,t)=>`${String(yF(e,t))}% rendered`,document:(e,t)=>`${String(e)} of ${String(t)}`},cF={audio_intro:`intro`,audio_body:`body`,audio_outro:`outro`};function lF(e,t,n,r=!1){let i=t.filter(t=>t.stageKind===e.kind);switch(e.state){case`skipped`:return`Not part of this run`;case`pending`:return n.status===`paused`||r?`Waits until you continue the run`:e.retryAt===void 0?e.kind===`images`||e.kind===`thumbnail`&&e.source===`from_prompt`?`Ready to run`:`Waits for the stages above`:`Trying again at ${pF(e.retryAt)}`;case`provided`:return gF(i)??`Provided`;case`failed`:return`Stopped after ${mF(e)}`;case`canceled`:return`Canceled by user`;case`running`:return oF(e,n.config)?`Preparing subtitles · ${String(yF(e.progressCurrent??0,35))}%`:e.activity===void 0?e.kind===`video`&&iF(n.config)===`audio`?`Exporting combined audio`:e.progressTotal===null||e.progressTotal<=0?`Running`:sF[e.kind](e.progressCurrent??0,e.progressTotal):dF(uF(e)??``);case`done`:return hF(e.kind,i,n)}}function uF(e){let t=e.activity;if(t!==void 0)return t.percent===void 0?t.done!==void 0&&t.total!==void 0?`${t.label} (${String(t.done)} of ${String(t.total)})`:t.label:`${t.label} (${String(t.percent)}%)`}function dF(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function fF(e){let t=e.activity;if(t?.percent!==void 0)return t.percent/100;if(t?.done!==void 0&&t.total!==void 0&&t.total>0)return t.done/t.total;if(t===void 0&&!(e.progressTotal===null||e.progressTotal<=0))return Math.min(1,Math.max(0,(e.progressCurrent??0)/e.progressTotal))}function pF(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function mF(e){return e.attemptCount===1?`1 attempt`:`${String(e.attemptCount)} attempts`}function hF(e,t,n){switch(e){case`research`:return`Notes ready`;case`article`:{let e=t.filter(e=>e.role===`sources`||e.role===`glossary`);return e.length===0?`Article ready`:`Article and ${String(e.length)} end-matter files`}case`audio`:return CF([xF(t.flatMap(e=>{let t=cF[e.role];return t===void 0?[]:[t]})),vF(_F(t))]);case`images`:return bF(t.filter(e=>e.role===`image`).length,`image`);case`thumbnail`:return t.length===0?`Thumbnail ready`:`1 image`;case`video`:return CF([vF(_F(t)),iF(n.config)===`audio`?`WAV · stereo · 48 kHz`:n.format]);case`document`:return`PDF · ${iC(n.config.document)} theme`}}function gF(e){let t=e.flatMap(e=>e.originalFilename===null?[]:[e.originalFilename]);return t.length===0?void 0:t.join(`, `)}function _F(e){let t=Math.max(0,...e.map(e=>e.durationMs??0));return t===0?void 0:t}function vF(e){if(e===void 0||!Number.isFinite(e)||e<=0)return;let t=Math.round(e/1e3),n=[Math.floor(t/60)%60,t%60].map(e=>String(e).padStart(2,`0`)),r=Math.floor(t/3600);return r===0?n.join(`:`):[String(r),...n].join(`:`)}function yF(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function bF(e,t){return e===1?`1 ${t}`:`${String(e)} ${t}s`}function xF(e){if(e.length!==0)return e.length===1?SF(e[0]??``):SF(`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]??``}`)}function SF(e){return e.charAt(0).toUpperCase()+e.slice(1)}function CF(e){return e.filter(e=>e!==void 0&&e!==``).join(` · `)}var wF=12,TF=16;function EF(e,t,n){return Math.max(t,Math.min(e,Math.max(t,n)))}function DF(e,t,n){let r=Math.min(n.width,t.width-24),i=EF(e?.left??(t.width-r)/2,wF,t.width-r-wF),a=EF((e?.top??0)+((e?.height??t.height)-n.height)/2,wF,t.height-n.height-wF),o=t.height-n.height-wF;if(!e)return{left:i,top:a,width:r,docked:!1};let s=e.left+e.width,c=e.top+e.height;return s+TF+r<=t.width-wF?{left:s+TF,top:a,width:r,docked:!1}:e.left-TF-r>=wF?{left:e.left-TF-r,top:a,width:r,docked:!1}:c>=wF&&c+TF+n.height<=t.height-wF?{left:i,top:c+TF,width:r,docked:!1}:e.top-TF-n.height>=wF&&e.top<=t.height-wF?{left:i,top:e.top-TF-n.height,width:r,docked:!1}:{left:t.width-r-wF,top:Math.max(wF,o),width:r,docked:!0}}function OF(e,t,n=t.height){let r=EF(e.left-6,0,t.width),i=EF(e.top-6,0,Math.min(n,t.height)),a=EF(e.left+e.width+6,0,t.width),o=EF(e.top+e.height+6,0,Math.min(n,t.height));return a>r&&o>i?{left:r,top:i,width:a-r,height:o-i}:null}var kF=`[data-slot="select-content"], [data-slot="dropdown-menu-content"], [data-slot="menu-content"]`;function AF(e){try{return document.querySelector(e)}catch{return null}}function jF(){return[...document.querySelectorAll(`[data-slot="dialog-content"][data-state="open"]`)].at(-1)??null}function MF(e){if(!e)return[];let t=[e,...e.querySelectorAll(`[aria-controls]`)],n=new Set(t.flatMap(e=>(e.getAttribute(`aria-controls`)??``).split(` `)));return[...document.querySelectorAll(kF)].filter(e=>n.has(e.id))}function NF(e){let t=e.getBoundingClientRect();return t.width>0&&t.height>0?{left:t.left,top:t.top,width:t.width,height:t.height}:null}var PF=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable="true"]`;function FF(e,t,n,r){let i=(0,m.useRef)(document.activeElement),a=(0,m.useRef)(t);a.current=t,(0,m.useEffect)(()=>{let e=i.current;return()=>{queueMicrotask(()=>{e instanceof HTMLElement&&e.isConnected&&!n.current&&e.focus({preventScroll:!0})})}},[n]),(0,m.useEffect)(()=>{let t=()=>{let t=AF(e);return[t,n.current,...MF(t)].filter(e=>e!==null)},i=e=>e instanceof Node&&t().some(t=>t.contains(e)),o=e=>{jF()||i(e.target)||(e.preventDefault(),e.stopImmediatePropagation())},s=e=>{jF()||i(e.target)||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-radix-focus-guard`)||r.current?.focus({preventScroll:!0})},c=n=>{if(jF())return;let r=MF(AF(e));if(n.key===`Escape`){if(r.length>0)return;n.preventDefault(),n.stopImmediatePropagation(),a.current();return}if(n.key!==`Tab`){i(n.target)||o(n);return}if(r.length>0)return;let s=t().flatMap(e=>[e,...e.querySelectorAll(PF)]).filter((e,t,n)=>n.indexOf(e)===t&&e.tabIndex>=0&&!e.matches(`:disabled, [hidden], [aria-hidden='true']`)&&!e.closest(`[hidden], [inert]`)&&(!e.closest(`details:not([open])`)||e.closest(`summary`)!==null));if(s.length===0)return;let c=s.indexOf(document.activeElement),l=c===-1?n.shiftKey?s.length-1:0:(c+(n.shiftKey?-1:1)+s.length)%s.length;n.preventDefault(),s[l]?.focus()},l=[`pointerdown`,`pointerup`,`mousedown`,`mouseup`,`click`,`dblclick`,`contextmenu`];for(let e of l)window.addEventListener(e,o,!0);return window.addEventListener(`keydown`,c,!0),window.addEventListener(`focusin`,s,!0),()=>{for(let e of l)window.removeEventListener(e,o,!0);window.removeEventListener(`keydown`,c,!0),window.removeEventListener(`focusin`,s,!0)}},[e,n,r])}function IF(e,t,n,r,i,a){let[o,s]=(0,m.useState)(()=>({key:e,target:null,portals:[],width:window.innerWidth,height:window.innerHeight,cardHeight:260,modalOpen:jF()!==null}));return(0,m.useLayoutEffect)(()=>{let o=0,c=0,l=null,u=null,d=new Map,f=new ResizeObserver(()=>h()),p=e=>{for(let[t,n]of d)e.has(t)||(t.style.zIndex=n,d.delete(t))},m=()=>{o=0;let r=AF(t);r!==u&&(u&&f.unobserve(u),r&&f.observe(r),u=r);let i=r?NF(r):null;r&&i&&l!==r&&(l=r,cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,r.isConnected&&(r.scrollIntoView({block:`start`,inline:`nearest`,behavior:`instant`}),m())}));let a=MF(r),h=new Set;for(let e of a){let t=e.closest(`[data-radix-popper-content-wrapper]`)??e;h.add(t),d.has(t)||(d.set(t,t.style.zIndex),t.style.zIndex=`102`)}p(h);let g={key:e,target:i,portals:a.map(NF).filter(e=>e!==null),width:window.innerWidth,height:window.innerHeight,cardHeight:n.current?.getBoundingClientRect().height||260,modalOpen:jF()!==null};s(e=>JSON.stringify(e)===JSON.stringify(g)?e:g)};function h(){o||=requestAnimationFrame(m)}let g=new MutationObserver(e=>{e.some(e=>!i.current?.contains(e.target)&&e.target!==a.current)&&h()});return g.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`id`,`class`,`style`,`hidden`,`aria-controls`,`data-state`,`data-tour`]}),n.current&&f.observe(n.current),f.observe(document.documentElement),window.addEventListener(`resize`,h),window.addEventListener(`scroll`,h,!0),window.visualViewport?.addEventListener(`resize`,h),window.visualViewport?.addEventListener(`scroll`,h),m(),jF()||r.current?.focus({preventScroll:!0}),()=>{cancelAnimationFrame(o),cancelAnimationFrame(c),f.disconnect(),g.disconnect(),window.removeEventListener(`resize`,h),window.removeEventListener(`scroll`,h,!0),window.visualViewport?.removeEventListener(`resize`,h),window.visualViewport?.removeEventListener(`scroll`,h),p(new Set)}},[e,t,n,r,i,a]),o}function LF({stepId:e,target:t,title:n,children:r,progress:i,onNext:a,onBack:o,onClose:s,nextLabel:c=`Next`,nextDisabled:l=!1,onSkip:u,skipLabel:d=`Skip this step`}){let f=(0,m.useId)(),p=`${e}:${t}`,g=(0,m.useRef)(null),_=(0,m.useRef)(null),v=(0,m.useRef)(null),y=(0,m.useRef)(null),b=IF(p,t,g,_,v,y);FF(t,s,g,_);let[x,S]=(0,m.useState)({key:p,height:0}),C=b.key===p?b.target:null,w={width:b.width,height:b.height},T={width:Math.min(360,w.width-24),height:b.cardHeight},E=DF(C,w,T),D=C?OF(C,w,E.docked?E.top-12:w.height):null,O=b.key===p?b.portals.map(e=>OF(e,w)).filter(e=>e!==null):[],k=[...D?[D]:[],...O],A=`M0 0H${w.width}V${w.height}H0Z`+(D?`M${D.left} ${D.top}H${D.left+D.width}V${D.top+D.height}H${D.left}Z`:``);(0,m.useLayoutEffect)(()=>{S(e=>{let t=Math.max(e.key===p?e.height:0,E.docked?T.height+24:0);return e.key===p&&e.height===t?e:{key:p,height:t}})},[p,E.docked,T.height]);let j=x.key===p?x.height:0;return(0,m.useEffect)(()=>{let e=document.documentElement,t=e.style.scrollPaddingBottom;return e.style.scrollPaddingBottom=`${j}px`,()=>{e.style.scrollPaddingBottom=t}},[j]),(0,sd.createPortal)((0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{ref:y,"aria-hidden":`true`,style:{height:j}}),(0,h.jsxs)(`div`,{ref:v,hidden:b.modalOpen,"data-tutorial":`spotlight`,className:`pointer-events-none fixed inset-0 z-[100] font-sans`,children:[(0,h.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 h-full w-full`,width:w.width,height:w.height,children:[(0,h.jsx)(`defs`,{children:(0,h.jsxs)(`mask`,{id:`${f}-mask`,children:[(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`white`}),k.map(e=>(0,h.jsx)(`rect`,{x:e.left,y:e.top,width:e.width,height:e.height,rx:`6`,fill:`black`},`${e.left}:${e.top}:${e.width}:${e.height}`))]})}),(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`rgb(0 0 0 / 0.72)`,mask:`url(#${f}-mask)`}),(0,h.jsx)(`path`,{d:A,fill:`transparent`,fillRule:`evenodd`,pointerEvents:`fill`}),D&&(0,h.jsx)(`rect`,{"data-tutorial":`hole`,x:D.left,y:D.top,width:D.width,height:D.height,rx:`6`,fill:`none`,stroke:`var(--color-accent)`,strokeWidth:`2`})]}),(0,h.jsxs)(`section`,{ref:g,"aria-label":`Interactive getting started guide`,"aria-describedby":`${f}-instructions`,"data-tutorial":`card`,className:`pointer-events-auto fixed z-[101] flex flex-col gap-3 rounded-media border border-line-strong bg-surface p-4 text-body text-ink shadow-[var(--shadow-pop)]`,style:{left:E.left,top:E.top,width:E.width,maxHeight:Math.min(w.height-24,Math.max(160,Math.min(420,w.height*.48)))},children:[(0,h.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,h.jsxs)(`span`,{className:`engraved text-accent-ink`,children:[`Getting started · `,i]}),(0,h.jsx)(R,{variant:`quiet`,onClick:s,"aria-label":`Exit guide`,className:`h-7 px-2`,children:`Exit`})]}),(0,h.jsx)(`h2`,{ref:_,id:`${f}-title`,tabIndex:-1,className:`shrink-0 text-title-3 font-bold outline-none`,children:n}),(0,h.jsxs)(`div`,{id:`${f}-instructions`,className:`min-h-0 overflow-y-auto text-ink-2 [&_p+p]:mt-2 [&_code]:text-ink`,children:[r,!C&&(0,h.jsx)(`p`,{role:`status`,className:`mt-3 text-waiting`,children:`This section is not available yet. Wait for the page to load, go back, or exit the guide.`}),E.docked&&C&&(0,h.jsx)(`p`,{className:`mt-3 text-small`,children:`Scroll the page to work through the highlighted section.`})]}),(0,h.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-line pt-3`,children:[o&&(0,h.jsx)(R,{onClick:o,children:`Back`}),u&&(0,h.jsx)(R,{variant:`quiet`,onClick:u,className:`px-2`,children:d}),(0,h.jsx)(R,{variant:`primary`,onClick:a,disabled:l||!C,className:`ml-auto`,children:c})]})]})]})]}),document.body)}function RF({href:e,children:t}){return(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-ink underline underline-offset-2`,children:t})}function zF({text:e}){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(!1);return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`p`,{className:`select-text rounded-control border border-line-strong bg-raised p-3 text-small leading-relaxed`,children:e}),(0,h.jsx)(R,{onClick:()=>{if(i(!1),!navigator.clipboard){i(!0);return}navigator.clipboard.writeText(e).then(()=>n(!0),()=>i(!0))},children:t?`Copied`:`Copy example`}),r?(0,h.jsx)(`p`,{role:`status`,children:`Select the example above and copy it manually.`}):null]})}var BF={signUp:{label:`platform.openai.com/signup`,url:`https://platform.openai.com/signup`},keyPage:{label:`platform.openai.com/api-keys`,url:`https://platform.openai.com/api-keys`},billing:{label:`Billing`,url:`https://platform.openai.com/settings/organization/billing/overview`},steps:[`Sign up or sign in to the OpenAI platform.`,`Open Billing and buy prepaid credit (new accounts need at least $5 before any call works).`,`Open API keys, choose Create new secret key, and copy it (it is shown once).`,`Paste it here, choose Save, then Test.`],permissions:`A key with All permissions works. A restricted key needs Models: Read (for Test) and Model capabilities: Request (for speech and images). GPT Image models may also need Verify Organization under Settings → Organization → General on the OpenAI platform.`,docs:{label:`OpenAI API docs`,url:`https://developers.openai.com/api/docs/guides/error-codes`}},VF={signUp:{label:`aistudio.google.com`,url:`https://aistudio.google.com`},keyPage:{label:`aistudio.google.com/apikey`,url:`https://aistudio.google.com/apikey`},billing:{label:`Projects → Set up billing`,url:`https://aistudio.google.com/projects`},steps:[`Sign in to Google AI Studio with your Google account.`,`Open Projects and choose Set up billing next to your project: Gemini image models are not available on the free tier.`,`Open API keys, choose Create API key, and copy it.`,`Paste it here, choose Save, then Test.`],permissions:`Use a key made in AI Studio. An older Google Cloud key must be set to Restrict to Gemini API only, or Google rejects it.`,docs:{label:`Gemini API keys`,url:`https://ai.google.dev/gemini-api/docs/api-key`}},HF={openrouter:{signUp:{label:`openrouter.ai/sign-up`,url:`https://openrouter.ai/sign-up`},keyPage:{label:`openrouter.ai/settings/keys`,url:`https://openrouter.ai/settings/keys`},billing:{label:`Credits`,url:`https://openrouter.ai/settings/credits`},steps:[`Sign up at OpenRouter.`,`Open Credits and buy credit (paid models are charged from it; a negative balance stops even free models).`,`Open Keys, choose Create API key, and copy it.`,`Paste it here, choose Save, then Test.`],permissions:`Keys have no scopes. If you set a credit limit on the key, keep it above what a run costs.`,docs:{label:`OpenRouter docs`,url:`https://openrouter.ai/docs/api-reference/limits`}},"openai-tts":BF,"openai-image":BF,"google-image":VF,"google-tts":{...VF,steps:[`Sign in to Google AI Studio with your Google account.`,`Open API keys, choose Create API key, and copy it.`,`Paste it here, choose Save, then Test.`],permissions:`The same Gemini API key as Google images: with one saved there, Gemini voices use it and nothing is needed here. ${VF.permissions}`},fal:{signUp:{label:`fal.ai/login`,url:`https://fal.ai/login`},keyPage:{label:`fal.ai/dashboard/keys`,url:`https://fal.ai/dashboard/keys`},billing:{label:`Billing`,url:`https://fal.ai/dashboard/billing`},steps:[`Sign up at fal.ai.`,`Open Billing and buy credit: fal.ai is prepaid and locks the account when the balance runs out.`,`Open Keys, choose Add key with the API scope, and copy it.`,`Paste it here, choose Save, then Test.`],permissions:`The API scope is enough; Slopify does not need an ADMIN key.`,docs:{label:`fal.ai authentication`,url:`https://fal.ai/docs/model-apis/authentication`}},replicate:{signUp:{label:`replicate.com/signin`,url:`https://replicate.com/signin`},keyPage:{label:`replicate.com/account/api-tokens`,url:`https://replicate.com/account/api-tokens`},billing:{label:`Billing`,url:`https://replicate.com/account/billing`},steps:[`Sign in to Replicate.`,`Open Billing and buy credit: Replicate needs credit up front before it runs paid models.`,`Open API tokens, create a token, and copy it (it starts with r8_).`,`Paste it here, choose Save, then Test.`],permissions:`Tokens have no scopes.`,docs:{label:`Replicate billing`,url:`https://replicate.com/docs/topics/billing`}},elevenlabs:{signUp:{label:`elevenlabs.io/app/sign-up`,url:`https://elevenlabs.io/app/sign-up`},keyPage:{label:`elevenlabs.io/app/developers/api-keys`,url:`https://elevenlabs.io/app/developers/api-keys`},steps:[`Sign up at ElevenLabs.`,`Open Developers → API keys, choose Create key, and copy it.`,`Paste it here, choose Save, then Test.`],permissions:`A restricted key needs Text to Speech access and Models read access (models_read) for Test; Voices read helps when picking voices. Remove any credit quota or IP allowlist that would block this computer.`,docs:{label:`ElevenLabs API keys`,url:`https://elevenlabs.io/docs/api-reference/models/list`}},cartesia:{signUp:{label:`play.cartesia.ai/sign-up`,url:`https://play.cartesia.ai/sign-up`},keyPage:{label:`play.cartesia.ai/keys`,url:`https://play.cartesia.ai/keys`},steps:[`Sign up at Cartesia (the free plan needs no card).`,`Open API Keys, create a key, and copy it (it starts with sk_car_).`,`Paste it here, choose Save, then Test.`],permissions:`Keys have no scopes.`,docs:{label:`Cartesia authentication`,url:`https://docs.cartesia.ai/get-started/authenticate-your-client-applications`}},inworld:{signUp:{label:`platform.inworld.ai/signup`,url:`https://platform.inworld.ai/signup`},keyPage:{label:`platform.inworld.ai/api-keys`,url:`https://platform.inworld.ai/api-keys`},billing:{label:`Billing`,url:`https://platform.inworld.ai/billing`},steps:[`Sign up at the Inworld platform.`,`Open API Keys and choose Generate new key (a Standard key, not Realtime-only).`,`Copy the Base64 credentials value exactly as shown, without encoding it again.`,`Paste it here, choose Save, then Test.`],permissions:`A Standard key covers speech and reading voices. Realtime-only keys do not work.`,docs:{label:`Inworld API keys`,url:`https://docs.inworld.ai/portal/api-keys`}}},UF=[`openrouter`,`claude-code`,`codex`,`gemini`,`elevenlabs`,`openai-tts`,`cartesia`,`inworld`,`system-voice`,`google-tts`,`fal`,`replicate`,`openai-image`,`google-image`,`codex-image`],WF=[{id:`openrouter`,family:`llm`,displayName:`OpenRouter`,auth:`key`},{id:`claude-code`,family:`llm`,displayName:`Claude Code CLI`,auth:`cli`,binary:`claude`,versionArgs:[`--version`]},{id:`codex`,family:`llm`,displayName:`Codex CLI`,auth:`cli`,binary:`codex`,versionArgs:[`--version`]},{id:`gemini`,family:`llm`,displayName:`Gemini CLI`,auth:`cli`,binary:`gemini`,versionArgs:[`--version`]},{id:`elevenlabs`,family:`tts`,displayName:`ElevenLabs`,auth:`key`},{id:`openai-tts`,family:`tts`,displayName:`OpenAI`,auth:`key`},{id:`cartesia`,family:`tts`,displayName:`Cartesia`,auth:`key`},{id:`inworld`,family:`tts`,displayName:`Inworld`,auth:`key`},{id:`system-voice`,family:`tts`,displayName:`System voice`,auth:`local`},{id:`google-tts`,family:`tts`,displayName:`Google Gemini`,auth:`key`},{id:`fal`,family:`image`,displayName:`fal.ai`,auth:`key`},{id:`replicate`,family:`image`,displayName:`Replicate`,auth:`key`},{id:`openai-image`,family:`image`,displayName:`OpenAI`,auth:`key`},{id:`google-image`,family:`image`,displayName:`Google`,auth:`key`},{id:`codex-image`,family:`image`,displayName:`Codex CLI`,auth:`cli`,binary:`codex`,versionArgs:[`--version`]}],GF=[{name:`Zephyr`,style:`Bright`},{name:`Puck`,style:`Upbeat`},{name:`Charon`,style:`Informative`},{name:`Kore`,style:`Firm`},{name:`Fenrir`,style:`Excitable`},{name:`Leda`,style:`Youthful`},{name:`Orus`,style:`Firm`},{name:`Aoede`,style:`Breezy`},{name:`Callirrhoe`,style:`Easy-going`},{name:`Autonoe`,style:`Bright`},{name:`Enceladus`,style:`Breathy`},{name:`Iapetus`,style:`Clear`},{name:`Umbriel`,style:`Easy-going`},{name:`Algieba`,style:`Smooth`},{name:`Despina`,style:`Smooth`},{name:`Erinome`,style:`Clear`},{name:`Algenib`,style:`Gravelly`},{name:`Rasalgethi`,style:`Informative`},{name:`Laomedeia`,style:`Upbeat`},{name:`Achernar`,style:`Soft`},{name:`Alnilam`,style:`Firm`},{name:`Schedar`,style:`Even`},{name:`Gacrux`,style:`Mature`},{name:`Pulcherrima`,style:`Forward`},{name:`Achird`,style:`Friendly`},{name:`Zubenelgenubi`,style:`Casual`},{name:`Vindemiatrix`,style:`Gentle`},{name:`Sadachbia`,style:`Lively`},{name:`Sadaltager`,style:`Knowledgeable`},{name:`Sulafat`,style:`Warm`}];function KF(e){return WF.flatMap(t=>{let n=t.auth===`key`?HF[t.id]:void 0;return t.family===e&&n!==void 0?[{id:t.id,name:t.displayName,url:n.keyPage.url}]:[]})}function qF({family:e}){return(0,h.jsx)(`p`,{children:KF(e).map((e,t)=>(0,h.jsxs)(`span`,{children:[t===0?null:` · `,(0,h.jsx)(RF,{href:e.url,children:`${e.name} keys`})]},e.id))})}function JF(e){let t=KF(e).map(e=>e.name);return t.length<2?t[0]??``:`${t.slice(0,-1).join(`, `)} or ${t.at(-1)??``}`}function YF({step:e}){switch(e){case`text-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`First, choose what will write your scripts. You only need one text provider.`}),(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Sign in to`,` `,(0,h.jsx)(RF,{href:HF.openrouter?.keyPage.url??`https://openrouter.ai`,children:`OpenRouter`}),`, create an API key, and make sure the account can use your chosen model.`]}),(0,h.jsxs)(`li`,{children:[`Paste it into OpenRouter’s `,(0,h.jsx)(`strong`,{children:`API key`}),` field here, press`,` `,(0,h.jsx)(`strong`,{children:`Test`}),` to check it, then `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]})]}),(0,h.jsx)(`p`,{children:`Already using Claude Code, Codex or Gemini CLI? You can use its existing CLI login instead. “Installed” means Slopify found the CLI; sign in through that CLI before generating. If it is missing, enter its executable path and save to check again.`}),(0,h.jsx)(`p`,{className:`text-ink-3`,children:`These are the real Settings controls. The tutorial never reads your key. Skip any step you have already handled.`})]});case`audio-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The voice provider turns the finished article into audio. Choose `,JF(`tts`),`; you only need one.`]}),(0,h.jsxs)(`p`,{children:[`Create a key in your provider’s account, enable the API access or credits it requires, then paste the key into its row, press `,(0,h.jsx)(`strong`,{children:`Test`}),` to check it, and press`,` `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsx)(qF,{family:`tts`}),(0,h.jsx)(`p`,{children:`Next, you’ll add the exact voice that this provider should use. Skip voice setup if you plan to provide your own narration or turn Audio Off.`})]});case`image-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Choose one image provider (`,JF(`image`),`), create a key in its dashboard, paste it into the matching row, press `,(0,h.jsx)(`strong`,{children:`Test`}),` to check it, and press`,` `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsx)(qF,{family:`image`}),(0,h.jsxs)(`p`,{children:[`A saved key is not a billing check. The selected image model needs available quota. If Google reports `,(0,h.jsx)(`strong`,{children:`limit: 0`}),`, check the key’s project, billing and image-model quota before retrying.`]}),(0,h.jsx)(`p`,{children:`OpenAI’s voice and image rows are saved separately, even when you use the same API key. Skip this step if you plan to provide your own images or turn Images and Thumbnail Off.`})]});case`voice`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Voice name`}),` you will recognize, such as “Travel narrator.”`]}),(0,h.jsxs)(`li`,{children:[`Select the `,(0,h.jsx)(`strong`,{children:`Provider`}),` whose voice key you saved.`]}),(0,h.jsxs)(`li`,{children:[`Copy the exact `,(0,h.jsx)(`strong`,{children:`Voice ID`}),` from that provider’s voice library or documentation.`]}),(0,h.jsxs)(`li`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Add voice`}),`.`]})]}),(0,h.jsx)(`p`,{children:`The name is your label; the ID tells the provider which voice to use. Slopify checks the ID with the provider when narration runs. A voice is only required when Audio is set to Generate.`})]})}}var XF=`Write a 150-word narration about {{topic}} for {{audience}}. Open with an interesting fact, explain three highlights, and end with one memorable takeaway. Use natural spoken English. Return only the narration, without headings or stage directions.`,ZF=`A cinematic editorial photograph of {{topic}}, with natural light, a clear focal point, rich detail, and no text or logos. Compose it for a travel video.`;function QF({step:e,output:t=`video`}){switch(e){case`text-key`:case`audio-key`:case`image-key`:case`voice`:return(0,h.jsx)(YF,{step:e});case`article-name`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`A prompt is a reusable set of instructions. This one will write the narration for each video.`}),(0,h.jsxs)(`p`,{children:[`Give it a recognizable name, such as `,(0,h.jsx)(`strong`,{children:`Short travel narration`}),`. This is the prompt’s library name, not your video’s title.`]}),(0,h.jsx)(`p`,{children:`The next steps will add its instructions and reusable keywords.`})]});case`article-body`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Tell the model what to write, who it is for, the length, and the style. Put anything you want to change between runs inside double braces.`}),(0,h.jsx)(zF,{text:XF}),(0,h.jsxs)(`p`,{children:[`Paste or write the instructions in `,(0,h.jsx)(`strong`,{children:`Body`}),`. `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` `,`and `,(0,h.jsx)(`strong`,{children:`{{audience}}`}),` will become fields on Play.`]})]});case`article-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`This panel detects your keywords as you type. With the example, it should list`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`{{topic}}`}),` is a field name, not the value. You will enter “Albania” on Play later. Repeated names use the same value; names are case-sensitive, so`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`Topic`}),` are different.`]}),(0,h.jsxs)(`p`,{children:[`There are no automatic keywords: `,(0,h.jsx)(`strong`,{children:`{{title}}`}),` would also ask you for a value. Fix any keyword warnings in Body before saving.`]})]});case`article-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press the highlighted `,(0,h.jsx)(`strong`,{children:`Save`}),` button in the editor. The prompt will appear in your Article library.`]}),(0,h.jsx)(`p`,{children:`The tour continues when the save succeeds and the editor returns to the prompt list. If a name is already taken, go Back and choose another.`})]});case`image-prompt`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Keep `,(0,h.jsx)(`strong`,{children:`Kind`}),` on `,(0,h.jsx)(`strong`,{children:`Image`}),`. Name this prompt`,` `,(0,h.jsx)(`strong`,{children:`Travel imagery`}),`, then enter this example or your own visual instructions.`]}),(0,h.jsx)(zF,{text:ZF}),(0,h.jsxs)(`p`,{children:[`Using `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` in both prompts creates one shared field on Play. Image prompts describe the picture directly; they do not automatically receive your article.`]})]});case`image-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Save`}),` to add this to your Image library. Next you will combine both prompts on Play.`]}),(0,h.jsx)(`p`,{children:`You can create more prompts later for different subjects, styles, lengths, or languages.`})]});case`play-article`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Play is where you configure one project. Leave `,(0,h.jsx)(`strong`,{children:`Article`}),` on`,` `,(0,h.jsx)(`strong`,{children:`Generate`}),`, then select the article prompt you saved.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`Provide`}),` is for an article you already have. For this first run, use Generate and keep the script short. Article is required; every other stage can be Off.`]}),(0,h.jsx)(`p`,{children:`Research starts Off. You can turn it on in a later run for web-grounded notes that are automatically passed to the article writer.`})]});case`play-audio`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Audio`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Pick your voice`,` `,(0,h.jsx)(`strong`,{children:`TTS`}),` provider, a `,(0,h.jsx)(`strong`,{children:`TTS model`}),`, then the saved`,` `,(0,h.jsx)(`strong`,{children:`Voice`}),`.`]}),(0,h.jsxs)(`p`,{children:[`Keep `,(0,h.jsx)(`strong`,{children:`Chunking`}),` (under `,(0,h.jsx)(`strong`,{children:`Audio Advanced`}),`) on`,` `,(0,h.jsx)(`strong`,{children:`Whole`}),` for the short example: the narration is sent as one request. Other chunking modes split longer text into pieces. `,(0,h.jsx)(`strong`,{children:`Speakers`}),` is where an audiobook or podcast gets more than one voice; leave it on one voice for now.`]}),(0,h.jsx)(`p`,{children:`Use Provide to upload existing narration, including any intro and outro in that file, or Off to skip narration. Video can still run silently, with each image shown for 5 seconds.`})]});case`play-images`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Images`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Choose the image`,` `,(0,h.jsx)(`strong`,{children:`Provider`}),` and `,(0,h.jsx)(`strong`,{children:`Model`}),`, tick your image prompt, and type`,` `,(0,h.jsx)(`strong`,{children:`2`}),` in the number box beside it for a small first run.`]}),(0,h.jsx)(`p`,{children:`The number means separate images made from that same prompt. It does not make one scene per article paragraph. Add more image prompts when you want different scenes.`}),(0,h.jsx)(`p`,{children:`Use Provide for your own images or Off to skip them. Turning Images Off also turns Video Off. Thumbnail remains independent; keep it Off for this first run.`})]});case`play-video`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`On `,(0,h.jsx)(`strong`,{children:`Export`}),`, choose `,(0,h.jsx)(`strong`,{children:`Generate`}),` for an MP4 slideshow. It needs generated or provided images. With Audio Off, the video is silent and each image lasts 5 seconds.`]}),(0,h.jsxs)(`p`,{children:[`Choose `,(0,h.jsx)(`strong`,{children:`Off`}),` to skip video. If Audio is active, Slopify exports one combined `,(0,h.jsx)(`strong`,{children:`WAV`}),` with the intro, body, outro and configured gaps.`]}),(0,h.jsx)(`p`,{children:`If both Audio and Video are Off, download the article and any other enabled outputs individually.`})]});case`play-subtitles`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Subtitles are optional and start `,(0,h.jsx)(`strong`,{children:`Off`}),`. Choose`,` `,(0,h.jsx)(`strong`,{children:`Subtitle files`}),` for SRT and VTT downloads, or`,` `,(0,h.jsx)(`strong`,{children:`Burn into video + files`}),` to keep captions visible in an MP4.`]}),(0,h.jsxs)(`p`,{children:[`English captions are timed locally from your narration with no paid API. First use downloads an approximately `,(0,h.jsx)(`strong`,{children:`95 MB`}),` speech model. Audio must be active; WAV exports support separate subtitle files.`]}),(0,h.jsx)(`p`,{children:`Pick a font or upload a TTF/OTF file, then adjust its size in the preview. Styling applies to burned captions. You can also add or change subtitles on a completed project later without regenerating its narration.`})]});case`play-options`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Project title`}),`, such as “A quick trip to Albania.” Set the title in Content.`]}),(0,h.jsxs)(`p`,{children:[`Select the text `,(0,h.jsx)(`strong`,{children:`LLM`}),` and `,(0,h.jsx)(`strong`,{children:`Text model`}),`. The model list loads for your provider. Use `,(0,h.jsx)(`strong`,{children:`Refresh`}),` for updated choices or`,` `,(0,h.jsx)(`strong`,{children:`Custom ID`}),`to enter an exact model ID when supported.`]}),(0,h.jsx)(`p`,{children:`Intro and Outro are available in Outputs when Audio is Generate. The LLM controls appear only when an enabled stage needs text generation.`})]});case`play-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The prompts you picked created these fields. For the examples, enter`,` `,(0,h.jsx)(`strong`,{children:`Albania`}),` for `,(0,h.jsx)(`strong`,{children:`topic`}),` and`,` `,(0,h.jsx)(`strong`,{children:`first-time travelers`}),` for `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsx)(`p`,{children:`Each keyword is asked once, with the prompts that use it named underneath. A keyword both prompts use feeds the article and the images, so changing it changes both for this run.`}),(0,h.jsx)(`p`,{children:`Fill every visible field. Each value must fit on one line and be no more than 200 characters. Your saved prompt keeps its braces so you can reuse it next time.`})]});case`play-start`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Review the enabled outputs, costs and readiness in Review. If anything is missing, use Back to fix the highlighted section.`}),(0,h.jsxs)(`p`,{children:[`When ready, press the real `,(0,h.jsx)(`strong`,{children:`Start run`}),` or `,(0,h.jsx)(`strong`,{children:`Queue N`}),` `,`button. This creates a project and sends generation requests to your chosen providers, which may charge your account.`]}),(0,h.jsx)(`p`,{children:`The tour will follow you to the project. You can also skip generating and go on to the screens you run a channel from.`})]});case`project`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The rail on the left lists the project's sections: Article, Narration, Images, Video and the rest. The right rail says where the run stands and offers the one thing to do next, named for its result: `,(0,h.jsx)(`strong`,{children:`Pause`}),` while it runs,`,` `,(0,h.jsx)(`strong`,{children:`Continue the run`}),` when it is paused, `,(0,h.jsx)(`strong`,{children:`Try images again`}),` `,`when a step fails.`]}),(0,h.jsxs)(`p`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Edit settings`}),` to change providers, models, voice, prompts or optional steps. `,(0,h.jsx)(`strong`,{children:`Save changes`}),` keeps a new revision without starting generation; what the change made outdated is then offered as the next action, such as`,` `,(0,h.jsx)(`strong`,{children:`Remake 3 outdated images`}),`. Earlier revisions stay in`,` `,(0,h.jsx)(`strong`,{children:`History`}),`.`]}),(0,h.jsxs)(`p`,{children:[`A failed step says why beside it; open `,(0,h.jsx)(`strong`,{children:`Error details`}),` for the provider's own message. Rare actions, such as making a whole stage again, sit behind each section's`,` `,(0,h.jsx)(`strong`,{children:`More`}),` button and in the command palette (Ctrl+K).`]})]});case`download`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[t===`audio`?(0,h.jsxs)(h.Fragment,{children:[`When Audio export finishes, press `,(0,h.jsx)(`strong`,{children:`Download`}),`, then`,` `,(0,h.jsx)(`strong`,{children:`Audio (.wav)`}),` for the combined narration.`]}):t===`article`?(0,h.jsxs)(h.Fragment,{children:[`Use `,(0,h.jsx)(`strong`,{children:`Download`}),` here to save the article. Audio and Video are Off for this project.`]}):(0,h.jsxs)(h.Fragment,{children:[`When Video finishes, press `,(0,h.jsx)(`strong`,{children:`Download`}),`, then`,` `,(0,h.jsx)(`strong`,{children:`Video (.mp4)`}),`.`]}),` `,`The completed project stays in `,(0,h.jsx)(`strong`,{children:`Projects`}),` so you can return to it.`]}),(0,h.jsxs)(`p`,{children:[`Select Article, Audio or Images in the stage list on the `,(0,h.jsx)(`strong`,{children:`Output`}),` tab to download their outputs. `,(0,h.jsx)(`strong`,{children:`Download all`}),` under Images gives an image ZIP, not the video.`]}),(0,h.jsxs)(`p`,{children:[`If subtitles are enabled, download the `,(0,h.jsx)(`strong`,{children:`.srt`}),` or `,(0,h.jsx)(`strong`,{children:`.vtt`}),` `,`files beside the final export. File-mode captions are also available in the video player.`]})]});case`run-cost`:return(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`Cost`}),` in the project's sections shows what this run really cost, per stage and model. Totals for every project are in Settings, `,(0,h.jsx)(`strong`,{children:`Usage`}),`.`]});case`studio-prep`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Slopify never uploads for you. When the video is made, `,(0,h.jsx)(`strong`,{children:`Prepare upload`}),` `,`is the next action: it lists everything YouTube Studio asks for, in the order it asks, from the file and title to the thumbnail, tags and the AI disclosure.`]}),(0,h.jsxs)(`p`,{children:[`The browser extension in Settings, `,(0,h.jsx)(`strong`,{children:`YouTube Studio`}),`, can fill those in for you.`]})]});case`home`:return(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`Home`}),` is the day at a glance: what needs you, what is running and at which step, what is coming up this week and what is ready to upload.`]});case`channels`:return(0,h.jsxs)(`p`,{children:[`A `,(0,h.jsx)(`strong`,{children:`channel`}),` keeps its brand kit, series brief, templates, schedules and a cast that looks the same in every video. It also remembers finished episodes and your existing videos, so new topics do not repeat them.`]});case`calendar`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The `,(0,h.jsx)(`strong`,{children:`Calendar`}),` shows the coming weeks of uploads: what is ready, what needs you, and the topics a schedule suggested, waiting for your approval. Its`,` `,(0,h.jsx)(`strong`,{children:`Schedules`}),` tab is where you create, pause and resume the schedules that fill it.`]}),(0,h.jsx)(`p`,{children:`You have reached the end. Press the question-mark button at the foot of the sidebar anytime to walk through these steps again, or the book beside it for Help → Tutorials, the guides to every screen.`})]})}}function $F(e){return nF(e.readiness)}function eI({session:e,progress:t,update:n}){let{api:r}=z(),i=iP(),a=Xi(),o=Va(),s=P(ob(r)),c=P(cb(r)),l=P(lb(r)),u=P({...ib(r,e.projectId??``),enabled:e.projectId!==void 0}),[d,f]=(0,m.useState)(null),p=(0,m.useRef)(null),g=ZP[e.step],_=s.data?.seen===!0;if((0,m.useEffect)(()=>{if(!_||!g||p.current===e.step)return;if(p.current=e.step,g.page===`settings`){let e=g.id===`voice`?`voices`:`providers`;(o.pathname!==`/settings`||!o.searchStr.includes(`section=${e}`))&&a({to:`/settings`,search:{section:e}})}if(g.page===`article`||g.page===`image`){let t=g.page===`article`?e.articleId:e.imageId,n=o.pathname===`/prompts/new`&&o.searchStr.includes(`kind=${g.page}`);t&&o.pathname!==`/prompts/${t}`?a({to:`/prompts/$promptId`,params:{promptId:t}}):!t&&!n&&a({to:`/prompts/new`,search:{kind:g.page}})}g.page===`play`&&o.pathname!==`/play`&&a({to:`/play`});let t={home:`/`,channels:`/channels`,calendar:`/calendar`};if(g.page===`home`||g.page===`channels`||g.page===`calendar`){let e=t[g.page];o.pathname!==e&&a({to:e})}g.page===`project`&&e.projectId&&o.pathname!==`/projects/${e.projectId}`&&a({to:`/projects/$projectId`,params:{projectId:e.projectId}})},[_,g,e.step,e.articleId,e.imageId,e.projectId,o.pathname,o.searchStr,a]),(0,m.useEffect)(()=>{if(!_||g?.page!==`play`||o.pathname!==`/play`)return;let e=!0;return f(null),i.navigate(tF[g.id]).then(()=>{e&&f(g.id)}),()=>{e=!1}},[_,g,o.pathname,i.navigate]),(0,m.useEffect)(()=>{o.pathname===`/prompts`&&(g?.id===`image-prompt`&&e.imageId?n(e=>({...e,step:ZP.findIndex(e=>e.id===`play-options`)})):(g?.id===`article-save`&&e.articleId||g?.id===`image-save`&&e.imageId)&&n(e=>({...e,step:e.step+1})))},[o.pathname,g?.id,e.articleId,e.imageId,n]),!_||!g||g.page===`play`&&(d!==g.id||i.section!==tF[g.id]))return null;let v=c.data?.providers??[],y=e=>v.some(t=>t.family===e&&$F(t)),b=(l.data?.voices??[]).some(e=>v.some(t=>t.id===e.provider&&$F(t))),x={"text-key":y(`llm`),"audio-key":y(`tts`),"image-key":y(`image`),voice:b,"article-name":t.promptIsArticle===!0&&t.promptNamed===!0,"article-body":t.promptIsArticle===!0&&t.promptBodyReady===!0&&t.promptHasKeywords===!0,"article-keywords":t.promptHasKeywords===!0,"article-save":!1,"image-prompt":t.promptIsImage===!0&&t.promptSaveReady===!0&&t.promptHasKeywords===!0,"image-save":!1,"play-article":t.playArticleReady===!0,"play-audio":t.playAudioReady===!0,"play-images":t.playImagesReady===!0,"play-video":t.playVideoReady===!0,"play-subtitles":t.playSubtitlesReady===!0,"play-options":t.playOptionsReady===!0,"play-keywords":t.playKeywordsReady===!0,"play-start":!1},S=()=>n(e=>({...e,active:!1})),C=ZP.findIndex(e=>e.id===QP),w=e.step===ZP.length-1,T=()=>{w?S():g.id===`play-start`?n(e=>({...e,step:C})):n(e=>({...e,step:e.step+1}))},E=()=>n(t=>({...t,step:g.id===`home`&&e.projectId===void 0?ZP.findIndex(e=>e.id===`play-start`):t.step-1})),D=u.data?iF(u.data.project.config):`video`,O=g.id===`download`&&D===`article`?`project-article`:g.id===`play-keywords`&&t.playHasKeywords===!1?`play-options`:g.id===`studio-prep`&&D!==`video`?`project-controls`:g.target,k=g.id===`article-save`||g.id===`image-save`,A=(g.page===`article`||g.page===`image`)&&t.promptSaving===!0;return(0,h.jsxs)(LF,{stepId:g.id,target:`[data-tour="${O}"]`,title:g.title,progress:`${e.step+1} of ${ZP.length} · First project`,onClose:S,...e.step===0||g.id===`project`||A?{}:{onBack:E},onNext:T,nextDisabled:A||x[g.id]===!1,nextLabel:k?`Use Save in the editor`:g.id===`play-start`?`Use Start run / Queue N on the page`:w?`Finish tutorial`:`Next`,...A?{}:{onSkip:T},skipLabel:g.id===`play-start`?`Skip generating`:k?`Skip without saving`:`Skip this step`,children:[(0,h.jsx)(QF,{step:g.id,output:D}),c.error||l.error?(0,h.jsx)(`p`,{className:`text-danger`,children:c.error?.message??l.error?.message}):null]})}var tI=q({schemaVersion:mO(1),active:KD(),stepId:J([`text-key`,`audio-key`,`image-key`,`voice`,`article-name`,`article-body`,`article-keywords`,`article-save`,`image-prompt`,`image-save`,`play-options`,`play-article`,`play-keywords`,`play-audio`,`play-images`,`play-video`,`play-subtitles`,`play-start`,`project`,`download`,`run-cost`,`studio-prep`,`home`,`channels`,`calendar`]),articleId:W().optional(),imageId:W().optional(),projectId:W().optional()}).strict();q({baseVersion:G().int().nonnegative(),mutationId:TD(),session:tI}).strict();var nI=q({version:G().int().nonnegative(),session:tI,readable:KD()}).strict();async function rI(e){let t=await I(await e.client.tutorial.$get()),n=nI.safeParse(t);return n.success?n.data:{version:0,readable:!1,session:{schemaVersion:1,active:!1,stepId:`text-key`}}}async function iI(e,t){return nI.parse(await I(await e.client.tutorial.$put({json:t})))}async function aI(e){let t=await e.client.tutorial.$delete();if(!t.ok)throw await fo(t)}function oI(){let{api:e}=z(),[t,n]=(0,m.useState)({active:!1,step:0}),[r,i]=(0,m.useState)(null),a=(0,m.useMemo)(()=>{let t={active:!1,step:0},r=0,a=!1,o=!1,s=0,c=!0,l=!1,u=!1,d=null,f=[],p=[],m=e=>i(e instanceof Error?e.message:`Your tutorial progress wasn't saved. You can keep going; it will try again on the next step.`),h=async()=>{if(!u&&a&&c){u=!0;try{for(;d||p.length>0;){if(!d){let e=p.shift();if(!e)break;let t=ZP[e.step];if(!t)throw Error(`This tutorial step isn't recognised. Choose Restart tutorial to start over.`);let{step:n,...i}=e;d={baseVersion:r,mutationId:crypto.randomUUID(),session:{...i,schemaVersion:1,stepId:t.id}}}r=(await iI(e,d)).version,d=null}i(null)}catch(e){m(e)}finally{u=!1}}},g=e=>{if(!a){f.push(e);return}let r=typeof e==`function`?e(t):e;r!==t&&(t=r,n(t),p.push(t),h())},_=()=>{if(!a){l=!0;return}if(!c){i(`Saved tutorial progress cannot be read. Choose Restart tutorial to recover.`);return}g({active:!0,step:0})},v=async()=>{if(o||a)return;o=!0;let u=s;try{let o=await rI(e);if(u!==s)return;if(r=o.version,c=o.readable,c||(a=!0),!c){i(`Saved tutorial progress cannot be read. Choose Restart tutorial to recover.`);return}let{schemaVersion:d,stepId:p,...m}=o.session;if(t={active:m.active,step:eF(p)??0,...m.articleId===void 0?{}:{articleId:m.articleId},...m.imageId===void 0?{}:{imageId:m.imageId},...m.projectId===void 0?{}:{projectId:m.projectId}},t.articleId||t.imageId){let{prompts:n}=await ks(e),{articleId:r,imageId:i,...a}=t;t={...a,...r!==void 0&&n.some(e=>e.id===r&&e.kind===`article`)?{articleId:r}:{},...i!==void 0&&n.some(e=>e.id===i&&e.kind===`image`)?{imageId:i}:{}}}if(t.projectId&&await jo(e,t.projectId),u!==s)return;a=!0,n(t);for(let e of f.splice(0))g(e);l&&_(),i(null)}catch(e){u===s&&m(e)}finally{o=!1}},y=async()=>{if(!u){u=!0,s++,f.length=0,l=!1;try{await aI(e),r=0,c=!0,a=!0,d=null,p.length=0,t={active:!0,step:0},n(t),p.push(t),i(null)}catch(e){m(e)}finally{u=!1}await h()}};return{update:g,start:_,restore:v,retry:()=>{a?h():v()},restart:()=>{y()}}},[e]);return(0,m.useEffect)(()=>{a.restore()},[a]),{session:t,update:a.update,start:a.start,retry:a.retry,restart:a.restart,error:r}}var sI=(0,m.createContext)(void 0);function cI({children:e}){let{session:t,update:n,start:r,retry:i,restart:a,error:o}=oI(),[s,c]=(0,m.useState)({}),l=(0,m.useCallback)(e=>{c(t=>Object.entries(e).every(([e,n])=>t[e]===n)?t:{...t,...e})},[]),u=(0,m.useCallback)(e=>{c(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!e.includes(t))))},[]),d=(0,m.useCallback)(e=>{n(t=>$P(t,e))},[n]),f=ZP[t.step]?.id,p=t.active&&(f===`project`||f===`download`)?f:void 0,g=(0,m.useMemo)(()=>({active:t.active,projectId:t.projectId,projectStep:p,start:r,report:l,clear:u,event:d}),[t.active,t.projectId,p,r,l,u,d]);return(0,h.jsxs)(sI.Provider,{value:g,children:[e,o?(0,h.jsxs)(`div`,{role:`alert`,className:`fixed bottom-4 left-4 z-[100] rounded-media border border-line bg-surface p-4 text-ink`,children:[(0,h.jsx)(`p`,{children:o}),(0,h.jsx)(R,{type:`button`,onClick:i,children:`Retry tutorial save`}),(0,h.jsx)(R,{type:`button`,onClick:a,children:`Restart tutorial`})]}):null,t.active?(0,h.jsx)(eI,{session:t,progress:s,update:n}):null]})}function lI(){return(0,m.useContext)(sI)}function uI(e){let t=(0,m.useContext)(sI),n=t?.report,r=t?.clear,i=(0,m.useRef)(e);i.current=e,(0,m.useEffect)(()=>{n?.(e)},[n,e]),(0,m.useEffect)(()=>()=>{r?.(Object.keys(i.current))},[r])}function dI(){let e=(0,m.useContext)(sI);return(0,m.useCallback)(t=>{e?.event(t)},[e?.event])}function fI(e){let t=(0,m.useContext)(sI);return t?.projectId===e?t.projectStep:void 0}var pI=[`patch-notes`];function mI(e){return st({queryKey:pI,queryFn:async()=>I(await e.client[`patch-notes`].$get()),staleTime:1/0})}function Jre(e,t){return st({queryKey:[...pI,t],queryFn:async()=>lo(await e.client[`patch-notes`][`:id`].$get({param:{id:t}})),staleTime:1/0})}async function Yre(e){await I(await e.client[`patch-notes`].seen.$post())}var hI={3:[{id:`home`,title:`Home`,body:`What is running and at which step, what is coming up, what needs you and what is ready to upload, on one screen.`,to:`/`,place:`Home`},{id:`play`,title:`Play's one path`,body:`Pick a template, type the topic, press Start. Everything else stays folded away until it needs you.`,to:`/play`,place:`Play`},{id:`reviews`,title:`Automatic reviews`,body:`A reviewer model checks the article, images, narration, thumbnail and shorts, and can send a failed item back to be made again. Turn it on in Play's Review step.`,to:`/play`,place:`Play`},{id:`channels`,title:`Channels and cast`,body:`A channel keeps its brand kit, series brief, templates and schedules, and a cast of characters and places that look the same in every video.`,to:`/channels`,place:`Channels`},{id:`memory`,title:`Episodes that remember`,body:`Each finished episode leaves a short summary on its channel's Episodes tab, and a new article reads the related ones. Add your existing video titles on Existing videos, and topic suggestions skip them too.`,to:`/channels`,place:`Channels`},{id:`calendar`,title:`The calendar`,body:`The coming weeks of uploads on one screen: what is ready, what needs you, and the topics still to come. Its Schedules tab holds every schedule.`,to:`/calendar`,place:`Calendar`},{id:`run-cost`,title:`What a run cost`,body:`Every project has a Run cost tab with the real cost per stage and model. Totals for all projects are in Settings, Usage.`,to:`/settings`,search:{section:`usage`},place:`Usage`},{id:`studio`,title:`YouTube Studio prep`,body:`Slopify never uploads. Prepare upload on a finished project lists everything Studio asks for, and the browser extension can fill it in for you.`,to:`/settings`,search:{section:`studio`},place:`YouTube Studio settings`},{id:`voices`,title:`Multiple voices`,body:`Audiobooks, podcasts, radio drama and interviews, with a voice per speaker. Pick the format under Audio, Speakers on Play.`,to:`/play`,place:`Play`},{id:`long-videos`,title:`Long videos stay watchable`,body:`More images for long videos sets images per hour or one every few minutes, with pan and zoom variety. An ambient bed of rain, fire, wind or your own file can play under the narration. Both are on Play; a channel's brand kit can set the ambient sound for all its videos.`,to:`/play`,place:`Play`},{id:`languages`,title:`Other languages`,body:`A project can be made in another language: pick it on Play, and the article, narration and description are written in it.`,to:`/play`,place:`Play`},{id:`trash`,title:`A trash bin`,body:`Deleted projects, prompts, templates and schedules stay in Settings, Trash for 30 days, and Restore brings them back.`,to:`/settings`,search:{section:`trash`},place:`Trash`}]},gI=[`whats-new`];async function Xre(e){return I(await e.client[`whats-new`].$get())}function _I(e){return st({queryKey:gI,queryFn:()=>Xre(e),staleTime:1/0})}async function Zre(e){return I(await e.client[`whats-new`].seen.$post())}function Qre(){let{api:e}=z(),t=_(),n=lI(),r=P(ob(e)),i=P({..._I(e),enabled:r.data?.seen===!0}),[a,o]=(0,m.useState)(0),s=F({mutationFn:()=>Zre(e),onSuccess:e=>{t.setQueryData(gI,e),t.setQueryData(pI,e=>e===void 0?e:{...e,due:null})}}),c=i.data?.major,l=c==null?void 0:hI[c],u=l!==void 0&&a>=l.length-1,d=P({...mI(e),enabled:i.data?.show===!0&&u}).data?.current??void 0;if(i.data?.show!==!0||l===void 0||n?.active===!0)return null;let f=l[Math.min(a,l.length-1)];if(f===void 0)return null;let p=l.indexOf(f),g=p===l.length-1,v=()=>{s.mutate()};return(0,h.jsx)(XP,{open:!0,width:`narrow`,title:`What's new in ${String(c)}.0`,onClose:v,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R,{variant:`quiet`,disabled:s.isPending,onClick:v,children:`Close tour`}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(R,{disabled:p===0,disabledReason:`This is the first step`,onClick:()=>{o(p-1)},children:`Back`}),(0,h.jsx)(R,{variant:`primary`,disabled:s.isPending,onClick:()=>{g?v():o(p+1)},children:g?`Finish tour`:`Next`})]}),children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`p`,{className:`m-0 text-label text-ink-3`,children:`${String(p+1)} of ${String(l.length)}`}),(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:f.title}),(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:f.body}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,h.jsx)(bS,{to:f.to,...f.search===void 0?{}:{search:f.search},children:`Open ${f.place}`}),g?(0,h.jsx)(xS,{to:`/settings`,search:{section:`patch-notes`,...d===void 0?{}:{note:d}},onClick:v,children:`Read the full patch notes`}):null]}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`Slopify could not save that you closed this tour: ${s.error.message} Press Close tour to try again.`})]})})}var $re={danger:(0,h.jsx)(Xc,{"aria-hidden":`true`,strokeWidth:1.75}),waiting:(0,h.jsx)(Cc,{"aria-hidden":`true`,strokeWidth:1.75}),info:(0,h.jsx)(Mc,{"aria-hidden":`true`,strokeWidth:1.75})};function vI({tone:e=`info`,title:t,children:n,actions:r,className:i}){return(0,h.jsxs)(`div`,{role:e===`danger`?`alert`:`status`,"data-tone":e,className:L(`sl-callout`,e!==`info`&&`sl-callout--${e}`,i),children:[$re[e],(0,h.jsx)(`span`,{className:`sl-callout__title`,children:t}),n===void 0?null:(0,h.jsx)(`div`,{className:`sl-callout__body`,children:n}),r===void 0?null:(0,h.jsx)(`div`,{className:`sl-callout__actions`,children:r})]})}function eie(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var tie=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nie=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rie={};function yI(e,t){return((t||rie).jsx?nie:tie).test(e)}var iie=/[ \t\n\f\r]/g;function aie(e){return typeof e==`object`?e.type===`text`&&bI(e.value):bI(e)}function bI(e){return e.replace(iie,``)===``}var xI=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};xI.prototype.normal={},xI.prototype.property={},xI.prototype.space=void 0;function SI(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new xI(n,r,t)}function CI(e){return e.toLowerCase()}var wI=class{constructor(e,t){this.attribute=t,this.property=e}};wI.prototype.attribute=``,wI.prototype.booleanish=!1,wI.prototype.boolean=!1,wI.prototype.commaOrSpaceSeparated=!1,wI.prototype.commaSeparated=!1,wI.prototype.defined=!1,wI.prototype.mustUseProperty=!1,wI.prototype.number=!1,wI.prototype.overloadedBoolean=!1,wI.prototype.property=``,wI.prototype.spaceSeparated=!1,wI.prototype.space=void 0;var TI=s({boolean:()=>EI,booleanish:()=>DI,commaOrSpaceSeparated:()=>jI,commaSeparated:()=>AI,number:()=>Y,overloadedBoolean:()=>OI,spaceSeparated:()=>kI}),oie=0,EI=MI(),DI=MI(),OI=MI(),Y=MI(),kI=MI(),AI=MI(),jI=MI();function MI(){return 2**++oie}var NI=Object.keys(TI),PI=class extends wI{constructor(e,t,n,r){let i=-1;if(super(e,t),FI(this,`space`,r),typeof n==`number`)for(;++i<NI.length;){let e=NI[i];FI(this,NI[i],(n&TI[e])===TI[e])}}};PI.prototype.defined=!0;function FI(e,t,n){n&&(e[t]=n)}function II(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new PI(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[CI(r)]=r,n[CI(a.attribute)]=r}return new xI(t,n,e.space)}var LI=II({properties:{ariaActiveDescendant:null,ariaAtomic:DI,ariaAutoComplete:null,ariaBusy:DI,ariaChecked:DI,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:kI,ariaCurrent:null,ariaDescribedBy:kI,ariaDetails:null,ariaDisabled:DI,ariaDropEffect:kI,ariaErrorMessage:null,ariaExpanded:DI,ariaFlowTo:kI,ariaGrabbed:DI,ariaHasPopup:null,ariaHidden:DI,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:kI,ariaLevel:Y,ariaLive:null,ariaModal:DI,ariaMultiLine:DI,ariaMultiSelectable:DI,ariaOrientation:null,ariaOwns:kI,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:DI,ariaReadOnly:DI,ariaRelevant:null,ariaRequired:DI,ariaRoleDescription:kI,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:DI,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function RI(e,t){return t in e?e[t]:t}function zI(e,t){return RI(e,t.toLowerCase())}var sie=II({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:AI,acceptCharset:kI,accessKey:kI,action:null,allow:null,allowFullScreen:EI,allowPaymentRequest:EI,allowUserMedia:EI,alpha:EI,alt:null,as:null,async:EI,autoCapitalize:null,autoComplete:kI,autoFocus:EI,autoPlay:EI,blocking:kI,capture:null,charSet:null,checked:EI,cite:null,className:kI,closedBy:null,colorSpace:null,cols:Y,colSpan:Y,command:null,commandFor:null,content:null,contentEditable:DI,controls:EI,controlsList:kI,coords:Y|AI,crossOrigin:null,data:null,dateTime:null,decoding:null,default:EI,defer:EI,dir:null,dirName:null,disabled:EI,download:OI,draggable:DI,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:EI,formTarget:null,headers:kI,height:Y,hidden:OI,high:Y,href:null,hrefLang:null,htmlFor:kI,httpEquiv:kI,id:null,imageSizes:null,imageSrcSet:null,inert:EI,inputMode:null,integrity:null,is:null,isMap:EI,itemId:null,itemProp:kI,itemRef:kI,itemScope:EI,itemType:kI,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:EI,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:EI,muted:EI,name:null,nonce:null,noModule:EI,noValidate:EI,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:EI,optimum:Y,pattern:null,ping:kI,placeholder:null,playsInline:EI,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:EI,referrerPolicy:null,rel:kI,required:EI,reversed:EI,rows:Y,rowSpan:Y,sandbox:kI,scope:null,scoped:EI,seamless:EI,selected:EI,shadowRootClonable:EI,shadowRootCustomElementRegistry:EI,shadowRootDelegatesFocus:EI,shadowRootMode:null,shadowRootSerializable:EI,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:DI,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:EI,useMap:null,value:DI,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:kI,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:EI,declare:EI,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:EI,noHref:EI,noShade:EI,noWrap:EI,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:DI,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:EI,disablePictureInPicture:EI,disableRemotePlayback:EI,exportParts:AI,part:kI,prefix:null,property:null,results:Y,security:null,unselectable:null},space:`html`,transform:zI}),cie=II({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:jI,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:kI,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:EI,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:AI,g2:AI,glyphName:AI,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:jI,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Y,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:kI,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:jI,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:jI,rev:jI,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:jI,requiredFeatures:jI,requiredFonts:jI,requiredFormats:jI,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:jI,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:jI,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:jI,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:RI}),BI=II({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),VI=II({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:zI}),HI=II({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),lie={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},uie=/[A-Z]/g,UI=/-[a-z]/g,die=/^data[-\w.:]+$/i;function fie(e,t){let n=CI(t),r=t,i=wI;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&die.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(UI,mie);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!UI.test(e)){let n=e.replace(uie,pie);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=PI}return new i(r,t)}function pie(e){return`-`+e.toLowerCase()}function mie(e){return e.charAt(1).toUpperCase()}var hie=SI([LI,sie,BI,VI,HI],`html`),WI=SI([LI,cie,BI,VI,HI],`svg`);function gie(e){return e.join(` `).trim()}var _ie=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
105
105
|
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),vie=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(_ie());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),yie=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),bie=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(vie()),r=yie();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),GI=qI(`end`),KI=qI(`start`);function qI(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function xie(e){let t=KI(e),n=GI(e);if(t&&n)return{start:t,end:n}}function JI(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?XI(e.position):`start`in e||`end`in e?XI(e):`line`in e||`column`in e?YI(e):``}function YI(e){return ZI(e&&e.line)+`:`+ZI(e&&e.column)}function XI(e){return YI(e&&e.start)+`-`+YI(e&&e.end)}function ZI(e){return e&&typeof e==`number`?e:1}var QI=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=JI(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};QI.prototype.file=``,QI.prototype.name=``,QI.prototype.reason=``,QI.prototype.message=``,QI.prototype.stack=``,QI.prototype.column=void 0,QI.prototype.line=void 0,QI.prototype.ancestors=void 0,QI.prototype.cause=void 0,QI.prototype.fatal=void 0,QI.prototype.place=void 0,QI.prototype.ruleId=void 0,QI.prototype.source=void 0;var Sie=l(bie(),1),$I={}.hasOwnProperty,Cie=new Map,wie=/[A-Z]/g,Tie=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Eie=new Set([`td`,`th`]),eL=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function Die(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=Fie(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Pie(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?WI:hie,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=tL(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function tL(e,t,n){if(t.type===`element`)return Oie(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return kie(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return jie(e,t,n);if(t.type===`mdxjsEsm`)return Aie(e,t);if(t.type===`root`)return Mie(e,t,n);if(t.type===`text`)return Nie(e,t)}function Oie(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=WI,e.schema=i),e.ancestors.push(t);let a=aL(e,t.tagName,!1),o=Iie(e,t),s=iL(e,t);return Tie.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!aie(e)})),nL(e,o,a,t),rL(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function kie(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}oL(e,t.position)}function Aie(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);oL(e,t.position)}function jie(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=WI,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:aL(e,t.name,!0),o=Lie(e,t),s=iL(e,t);return nL(e,o,a,t),rL(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Mie(e,t,n){let r={};return rL(r,iL(e,t)),e.create(t,e.Fragment,r,n)}function Nie(e,t){return t.value}function nL(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function rL(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Pie(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function Fie(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=KI(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Iie(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&$I.call(t.properties,i)){let a=Rie(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Eie.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function Lie(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else oL(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else oL(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function iL(e,t){let n=[],r=-1,i=e.passKeys?new Map:Cie;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=tL(e,a,o);s!==void 0&&n.push(s)}return n}function Rie(e,t,n){let r=fie(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?eie(n):gie(n)),r.property===`style`){let t=typeof n==`object`?n:zie(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Bie(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?lie[r.property]||r.property:r.attribute,n]}}function zie(e,t){try{return(0,Sie.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new QI("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=eL+`#cannot-parse-style-attribute`,r}}function aL(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=yI(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=yI(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return $I.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);oL(e)}function oL(e,t){let n=new QI("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=eL+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Bie(e){let t={},n;for(n in e)$I.call(e,n)&&(t[Vie(n)]=e[n]);return t}function Vie(e){let t=e.replace(wie,Hie);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Hie(e){return`-`+e.toLowerCase()}var sL={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},Uie={};function cL(e,t){let n=t||Uie;return lL(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function lL(e,t,n){if(Wie(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return uL(e.children,t,n)}return Array.isArray(e)?uL(e,t,n):``}function uL(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=lL(e[i],t,n);return r.join(``)}function Wie(e){return!!(e&&typeof e==`object`)}var dL=document.createElement(`i`);function fL(e){let t=`&`+e+`;`;dL.innerHTML=t;let n=dL.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function pL(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function mL(e,t){return e.length>0?(pL(e,e.length,0,t),e):t}var hL={}.hasOwnProperty;function gL(e){let t={},n=-1;for(;++n<e.length;)Gie(t,e[n]);return t}function Gie(e,t){let n;for(n in t){let r=(hL.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){hL.call(r,a)||(r[a]=[]);let e=i[a];Kie(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Kie(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);pL(e,0,0,r)}function _L(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function vL(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var yL=OL(/[A-Za-z]/),bL=OL(/[\dA-Za-z]/),qie=OL(/[#-'*+\--9=?A-Z^-~]/);function xL(e){return e!==null&&(e<32||e===127)}var SL=OL(/\d/),Jie=OL(/[\dA-Fa-f]/),Yie=OL(/[!-/:-@[-`{-~]/);function CL(e){return e!==null&&e<-2}function wL(e){return e!==null&&(e<0||e===32)}function TL(e){return e===-2||e===-1||e===32}var EL=OL(/\p{P}|\p{S}/u),DL=OL(/\s/);function OL(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function kL(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&bL(e.charCodeAt(n+1))&&bL(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function AL(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return TL(r)?(e.enter(n),s(r)):t(r)}function s(r){return TL(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Xie={tokenize:Zie};function Zie(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),AL(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return CL(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Qie={tokenize:$ie},jL={tokenize:eae};function $ie(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return pL(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(jL,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(jL,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return CL(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;pL(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function eae(e,t,n){return AL(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function ML(e){if(e===null||wL(e)||DL(e))return 1;if(EL(e))return 2}function NL(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var PL={name:`attention`,resolveAll:tae,tokenize:nae};function tae(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};FL(d,-c),FL(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=mL(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=mL(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=mL(l,NL(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=mL(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=mL(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,pL(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function nae(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=ML(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=ML(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function FL(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var rae={name:`autolink`,tokenize:iae};function iae(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return yL(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||bL(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||bL(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||xL(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):qie(t)?(e.consume(t),l):n(t)}function u(e){return bL(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||bL(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var IL={partial:!0,tokenize:aae};function aae(e,t,n){return r;function r(t){return TL(t)?AL(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||CL(e)?t(e):n(e)}}var LL={continuation:{tokenize:sae},exit:cae,name:`blockQuote`,tokenize:oae};function oae(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return TL(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function sae(e,t,n){let r=this;return i;function i(t){return TL(t)?AL(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(LL,t,n)(r)}}function cae(e){e.exit(`blockQuote`)}var RL={name:`characterEscape`,tokenize:lae};function lae(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Yie(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var zL={name:`characterReference`,tokenize:uae};function uae(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=bL,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Jie,u):(e.enter(`characterReferenceValue`),a=7,o=SL,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===bL&&!fL(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var BL={partial:!0,tokenize:fae},VL={concrete:!0,name:`codeFenced`,tokenize:dae};function dae(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),TL(t)?AL(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||CL(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(BL,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||CL(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):TL(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),AL(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||CL(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||CL(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&TL(t)?AL(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||CL(t)?e.check(BL,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||CL(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),TL(t)?AL(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),TL(t)?AL(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||CL(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function fae(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var HL={name:`codeIndented`,tokenize:mae},pae={partial:!0,tokenize:hae};function mae(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),AL(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):CL(t)?e.attempt(pae,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||CL(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function hae(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):CL(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):AL(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):CL(e)?i(e):n(e)}}var gae={name:`codeText`,previous:vae,resolve:_ae,tokenize:yae};function _ae(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function vae(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function yae(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):CL(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||CL(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var bae=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&UL(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),UL(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),UL(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);UL(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);UL(this.left,t.reverse())}}}};function UL(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function WL(e){let t={},n=-1,r,i,a,o,s,c,l,u=new bae(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,xae(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return pL(e,0,1/0,u.slice(0)),!l}function xae(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Sae={resolve:wae,tokenize:Tae},Cae={partial:!0,tokenize:Eae};function wae(e){return WL(e),e}function Tae(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):CL(t)?e.check(Cae,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Eae(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),AL(e,a,`linePrefix`)}function a(i){if(i===null||CL(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function GL(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||xL(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||CL(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||wL(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||xL(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function KL(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):CL(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||CL(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!TL(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function qL(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):CL(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),AL(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||CL(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function JL(e,t){let n;return r;function r(i){return CL(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):TL(i)?AL(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Dae={name:`definition`,tokenize:kae},Oae={partial:!0,tokenize:Aae};function kae(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return KL.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=vL(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return wL(t)?JL(e,l)(t):l(t)}function l(t){return GL(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Oae,d,d)(t)}function d(t){return TL(t)?AL(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||CL(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Aae(e,t,n){return r;function r(t){return wL(t)?JL(e,i)(t):n(t)}function i(t){return qL(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return TL(t)?AL(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||CL(e)?t(e):n(e)}}var jae={name:`hardBreakEscape`,tokenize:Mae};function Mae(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return CL(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Nae={name:`headingAtx`,resolve:Pae,tokenize:Fae};function Pae(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},pL(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Fae(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||wL(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||CL(n)?(e.exit(`atxHeading`),t(n)):TL(n)?AL(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||wL(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Iae=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),YL=[`pre`,`script`,`style`,`textarea`],Lae={concrete:!0,name:`htmlFlow`,resolveTo:Bae,tokenize:Vae},Rae={partial:!0,tokenize:Uae},zae={partial:!0,tokenize:Hae};function Bae(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Vae(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:N):yL(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):yL(a)?(e.consume(a),i=4,r.interrupt?t:N):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:N):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return yL(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||wL(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&YL.includes(l)?(i=1,r.interrupt?t(s):O(s)):Iae.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||bL(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return TL(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||yL(t)?(e.consume(t),b):TL(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||bL(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):TL(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):TL(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||CL(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||wL(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||TL(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||CL(t)?O(t):TL(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),ee):t===60&&i===1?(e.consume(t),te):t===62&&i===4?(e.consume(t),re):t===63&&i===3?(e.consume(t),N):t===93&&i===5?(e.consume(t),ne):CL(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Rae,ie,k)(t)):t===null||CL(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(zae,A,ie)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||CL(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function ee(t){return t===45?(e.consume(t),N):O(t)}function te(t){return t===47?(e.consume(t),o=``,M):O(t)}function M(t){if(t===62){let n=o.toLowerCase();return YL.includes(n)?(e.consume(t),re):O(t)}return yL(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),M):O(t)}function ne(t){return t===93?(e.consume(t),N):O(t)}function N(t){return t===62?(e.consume(t),re):t===45&&i===2?(e.consume(t),N):O(t)}function re(t){return t===null||CL(t)?(e.exit(`htmlFlowData`),ie(t)):(e.consume(t),re)}function ie(n){return e.exit(`htmlFlow`),t(n)}}function Hae(e,t,n){let r=this;return i;function i(t){return CL(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Uae(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(IL,t,n)}}var Wae={name:`htmlText`,tokenize:Gae};function Gae(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):yL(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):yL(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):CL(t)?(o=d,te(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ee(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):CL(t)?(o=h,te(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ee(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ee(t):CL(t)?(o=v,te(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):CL(t)?(o=y,te(t)):(e.consume(t),y)}function b(e){return e===62?ee(e):y(e)}function x(t){return yL(t)?(e.consume(t),S):n(t)}function S(t){return t===45||bL(t)?(e.consume(t),S):C(t)}function C(t){return CL(t)?(o=C,te(t)):TL(t)?(e.consume(t),C):ee(t)}function w(t){return t===45||bL(t)?(e.consume(t),w):t===47||t===62||wL(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ee):t===58||t===95||yL(t)?(e.consume(t),E):CL(t)?(o=T,te(t)):TL(t)?(e.consume(t),T):ee(t)}function E(t){return t===45||t===46||t===58||t===95||bL(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):CL(t)?(o=D,te(t)):TL(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):CL(t)?(o=O,te(t)):TL(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):CL(t)?(o=k,te(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||wL(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||wL(e)?T(e):n(e)}function ee(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function te(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),M}function M(t){return TL(t)?AL(e,ne,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ne(t)}function ne(t){return e.enter(`htmlTextData`),o(t)}}var XL={name:`labelEnd`,resolveAll:Yae,resolveTo:Xae,tokenize:Zae},Kae={tokenize:Qae},qae={tokenize:$ae},Jae={tokenize:eoe};function Yae(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&pL(e,0,e.length,n),e}function Xae(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=mL(s,e.slice(a+1,a+r+3)),s=mL(s,[[`enter`,u,t]]),s=mL(s,NL(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=mL(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=mL(s,e.slice(o+1)),s=mL(s,[[`exit`,c,t]]),pL(e,a,e.length,s),e}function Zae(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(vL(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Kae,u,o?u:d)(t):t===91?e.attempt(qae,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Jae,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function Qae(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return wL(t)?JL(e,a)(t):a(t)}function a(t){return t===41?u(t):GL(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return wL(t)?JL(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?qL(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return wL(t)?JL(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function $ae(e,t,n){let r=this;return i;function i(t){return KL.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(vL(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function eoe(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var toe={name:`labelStartImage`,resolveAll:XL.resolveAll,tokenize:noe};function noe(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var roe={name:`labelStartLink`,resolveAll:XL.resolveAll,tokenize:ioe};function ioe(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var ZL={name:`lineEnding`,tokenize:aoe};function aoe(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),AL(e,t,`linePrefix`)}}var QL={name:`thematicBreak`,tokenize:ooe};function ooe(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||CL(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),TL(t)?AL(e,s,`whitespace`)(t):s(t))}}var $L={continuation:{tokenize:uoe},exit:foe,name:`list`,tokenize:loe},soe={partial:!0,tokenize:poe},coe={partial:!0,tokenize:doe};function loe(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:SL(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(QL,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return SL(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(IL,r.interrupt?n:u,e.attempt(soe,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return TL(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function uoe(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(IL,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,AL(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!TL(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(coe,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,AL(e,e.attempt($L,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function doe(e,t,n){let r=this;return AL(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function foe(e){e.exit(this.containerState.type)}function poe(e,t,n){let r=this;return AL(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!TL(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var eR={name:`setextUnderline`,resolveTo:moe,tokenize:hoe};function moe(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function hoe(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),TL(t)?AL(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||CL(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var goe={tokenize:_oe};function _oe(e){let t=this,n=e.attempt(IL,r,e.attempt(this.parser.constructs.flowInitial,i,AL(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Sae,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var voe={resolveAll:nR()},yoe=tR(`string`),boe=tR(`text`);function tR(e){return{resolveAll:nR(e===`text`?xoe:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function nR(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function xoe(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var Soe=s({attentionMarkers:()=>Aoe,contentInitial:()=>woe,disable:()=>joe,document:()=>Coe,flow:()=>Eoe,flowInitial:()=>Toe,insideSpan:()=>koe,string:()=>Doe,text:()=>Ooe}),Coe={42:$L,43:$L,45:$L,48:$L,49:$L,50:$L,51:$L,52:$L,53:$L,54:$L,55:$L,56:$L,57:$L,62:LL},woe={91:Dae},Toe={[-2]:HL,[-1]:HL,32:HL},Eoe={35:Nae,42:QL,45:[eR,QL],60:Lae,61:eR,95:QL,96:VL,126:VL},Doe={38:zL,92:RL},Ooe={[-5]:ZL,[-4]:ZL,[-3]:ZL,33:toe,38:zL,42:PL,60:[rae,Wae],91:roe,92:[jae,RL],93:XL,95:PL,96:gae},koe={null:[PL,voe]},Aoe={null:[42,95]},joe={null:[]};function Moe(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=mL(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=NL(a,l.events,l),l.events):[]}function f(e,t){return Poe(p(e),t)}function p(e){return Noe(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){CL(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&pL(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Noe(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Poe(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
106
106
|
`;break;case-3:o=`\r
|
|
107
107
|
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Foe(e){let t={constructs:gL([Soe,...(e||{}).extensions||[]]),content:n(Xie),defined:[],document:n(Qie),flow:n(goe),lazy:{},string:n(yoe),text:n(boe)};return t;function n(e){return n;function n(n){return Moe(t,e,n)}}}function Ioe(e){for(;!WL(e););return e}var rR=/[\0\t\n\r]/g;function Loe(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(rR.lastIndex=u,c=rR.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Roe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function iR(e){return e.replace(Roe,zoe)}function zoe(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return _L(n.slice(t?2:1),t?16:10)}return fL(n)||e}var aR={}.hasOwnProperty;function Boe(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Voe(n)(Ioe(Foe(n).document().write(Loe()(e,t,!0))))}function Voe(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(xe),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(_e),blockQuote:a(fe),characterEscape:T,characterReference:T,codeFenced:a(pe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(pe,o),codeText:a(me,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(he),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(ge),hardBreakEscape:a(ve),hardBreakTrailing:a(ve),htmlFlow:a(ye,o),htmlFlowData:T,htmlText:a(ye,o),htmlTextData:T,image:a(be),label:o,link:a(xe),listItem:a(Ce),listItemValue:f,listOrdered:a(Se,d),listUnordered:a(Se),paragraph:a(we),reference:ae,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(_e),strong:a(Te),thematicBreak:a(De)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:de,autolinkProtocol:ue,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:se,characterReferenceMarkerNumeric:se,characterReferenceValue:ce,characterReference:le,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(te),label:ne,labelText:M,lineEnding:D,link:c(ee),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:oe,resourceDestinationString:N,resourceTitleString:re,resource:ie,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};sR(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];aR.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||cR).call(a,void 0,e[0])}for(r.position={start:oR(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:oR(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:oR(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||cR).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+JI({start:e.start,end:e.end})+`): it’s not open`);n.position.end=oR(e.end)}function u(){return cL(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=vL(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Ee(),n.position={start:oR(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=oR(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=oR(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ee(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function te(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=iR(t),n.identifier=vL(t).toLowerCase()}function ne(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function N(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ie(){this.data.inReference=void 0}function ae(){this.data.referenceType=`collapsed`}function oe(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=vL(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function se(e){this.data.characterReferenceType=e.type}function ce(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=_L(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=fL(t);let i=this.stack[this.stack.length-1];i.value+=r}function le(e){let t=this.stack.pop();t.position.end=oR(e.end)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function fe(){return{type:`blockquote`,children:[]}}function pe(){return{type:`code`,lang:null,meta:null,value:``}}function me(){return{type:`inlineCode`,value:``}}function he(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function ge(){return{type:`emphasis`,children:[]}}function _e(){return{type:`heading`,depth:0,children:[]}}function ve(){return{type:`break`}}function ye(){return{type:`html`,value:``}}function be(){return{type:`image`,title:null,url:``,alt:null}}function xe(){return{type:`link`,title:null,url:``,children:[]}}function Se(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Ce(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function we(){return{type:`paragraph`,children:[]}}function Te(){return{type:`strong`,children:[]}}function Ee(){return{type:`text`,value:``}}function De(){return{type:`thematicBreak`}}}function oR(e){return{line:e.line,column:e.column,offset:e.offset}}function sR(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?sR(e,r):Hoe(e,r)}}function Hoe(e,t){let n;for(n in t)if(aR.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function cR(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+JI({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+JI({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+JI({start:t.start,end:t.end})+`) is still open`)}function lR(e){let t=this;t.parser=n;function n(n){return Boe(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function Uoe(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Woe(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
@@ -270,7 +270,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
270
270
|
Sphinxes
|
|
271
271
|
Obelisks`})}):e.mode===`yaml`?(0,h.jsx)(dV,{id:`schedule-topics-yaml`,label:`Topics as YAML or JSON`,tip:`planning.schedule.topic-yaml`,children:(0,h.jsx)(mV,{rows:10,className:`font-mono`,spellCheck:!1,value:e.yaml,onChange:n=>t({...e,yaml:n.target.value}),placeholder:`- ${f??`Topic`}: Cleopatra\n ${d.find(e=>e!==f)??`Min. Word Count`}: 12000\n- Hypatia`})}):(0,h.jsx)($de,{queue:e,onQueue:t,keyword:f,addable:O,setRow:D,titleOf:b}),k.length===0?null:(0,h.jsx)(vI,{tone:`danger`,title:`These topics can't be saved yet.`,children:(0,h.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:[k.slice(0,8).map(e=>(0,h.jsx)(`li`,{children:e},e)),k.length>8?(0,h.jsx)(`li`,{children:`And ${String(k.length-8)} more.`}):null]})}),e.mode===`yaml`&&v.rows.length>0?(0,h.jsxs)(`section`,{"aria-label":`Project titles`,children:[(0,h.jsx)(`p`,{className:`m-0 mb-1 text-small text-ink-2`,children:`Project titles, in order:`}),(0,h.jsxs)(`ol`,{className:`m-0 flex flex-col gap-1 pl-5 text-small`,children:[v.rows.slice(0,20).map((e,t)=>(0,h.jsx)(`li`,{children:b(e)},t)),v.rows.length>20?(0,h.jsx)(`li`,{className:`list-none text-ink-3`,children:`And ${String(v.rows.length-20)} more.`}):null]})]}):null,a?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Reading the template's keywords…`}):d.length===0?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-3`,children:[`This template has no keywords such as `,`{{Topic}}`,`, so each topic becomes the project's title.`]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`div`,{className:`grid gap-4 min-[700px]:grid-cols-2`,children:(0,h.jsx)(dV,{label:`Each topic fills`,id:`schedule-topic-keyword`,tip:`planning.schedule.topic-keyword`,...f===null?{}:{help:l0({feeds:_(f)})},children:(0,h.jsx)(hV,{value:f??``,onChange:e=>r(e.target.value),children:d.map(e=>(0,h.jsx)(`option`,{value:e,children:`{{${e}}}`},e))})})}),(0,h.jsx)(u0,{keywords:d.filter(e=>e!==f).map(t=>({name:t,value:g[t]??``,feeds:_(t),...e.columns.includes(t)?{note:`Unless a topic sets its own.`}:{}})),onChange:i,fieldPrefix:`everyRun`,label:e=>`${e} (every run)`,inputLabel:e=>`${e} for every run`,tip:`planning.schedule.every-run`,maxLength:1e4})]}),e.mode===`lines`&&S!==void 0&&x!==void 0?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[`Next project: `,(0,h.jsx)(`span`,{className:`font-semibold text-ink`,children:S}),f===null||C?null:(0,h.jsxs)(`span`,{className:`block text-ink-3`,children:[`The template's project title does not use `,`{{${f}}}`,`, so every project gets this title. Edit the template's title to include it.`]})]}):null]})}function $de({queue:e,onQueue:t,keyword:n,addable:r,setRow:i,titleOf:a}){let o=n===null?`Title`:`{{${n}}}`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,...Ib,children:[(0,h.jsx)(`div`,{className:`overflow-x-auto`,children:(0,h.jsxs)(`table`,{className:`sl-table`,"aria-label":`Topics`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{scope:`col`,children:`#`}),(0,h.jsx)(`th`,{scope:`col`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[o,(0,h.jsx)(V,{id:`planning.schedule.topic-table`,className:`-my-1`})]})}),e.columns.map(n=>(0,h.jsx)(`th`,{scope:`col`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`{{${n}}}`,(0,h.jsx)(My,{label:`Use the every-run ${n} for all topics`,size:`small`,onClick:()=>t({...e,columns:e.columns.filter(e=>e!==n),rows:e.rows.map(e=>({title:e.title,values:Object.fromEntries(Object.entries(e.values).filter(([e])=>e!==n))}))}),children:(0,h.jsx)(el,{"aria-hidden":`true`,strokeWidth:1.75})})]})},n)),(0,h.jsx)(`th`,{scope:`col`,children:`Project title`}),(0,h.jsx)(`th`,{scope:`col`,children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:e.rows.map((n,r)=>(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`td`,{className:`num`,children:r+1}),(0,h.jsx)(`td`,{children:(0,h.jsx)(pV,{"aria-label":`Topic ${String(r+1)} ${o}`,maxLength:200,value:n.title,onChange:e=>i(r,{...n,title:e.target.value})})}),e.columns.map(e=>(0,h.jsx)(`td`,{children:(0,h.jsx)(pV,{"aria-label":`Topic ${String(r+1)} ${e}`,maxLength:lq,placeholder:`Every-run value`,value:n.values[e]??``,onChange:t=>i(r,{...n,values:{...n.values,[e]:t.target.value}})})},e)),(0,h.jsx)(`td`,{className:`min-w-[180px] text-small text-ink-2`,children:a(n)??`—`}),(0,h.jsx)(`td`,{children:(0,h.jsx)(My,{label:`Remove topic ${String(r+1)}`,size:`small`,onClick:()=>t({...e,rows:e.rows.filter((e,t)=>t!==r)}),children:(0,h.jsx)(el,{"aria-hidden":`true`,strokeWidth:1.75})})})]},r))})]})}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsxs)(R,{size:`small`,onClick:()=>t({...e,rows:[...e.rows,{title:``,values:{}}]}),children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Add topic`]}),r.length===0?null:(0,h.jsxs)(hV,{"aria-label":`Set a keyword per topic`,value:``,className:`w-auto`,onChange:n=>{let r=n.target.value;r!==``&&t({...e,columns:[...e.columns,r]})},children:[(0,h.jsx)(`option`,{value:``,children:`Set a keyword per topic…`}),r.map(e=>(0,h.jsx)(`option`,{value:e,children:e},e))]})]})]})}var efe=[[1,`Mon`],[2,`Tue`],[3,`Wed`],[4,`Thu`],[5,`Fri`],[6,`Sat`],[0,`Sun`]];function tfe({templates:e,pending:t,onCreated:n,onError:r,editing:i,onCancel:a,error:o,onBusy:s}){let{api:c}=z(),[l,u]=(0,m.useState)(i?.name??``),[d,f]=(0,m.useState)(i?.templateId??``),[p,g]=(0,m.useState)(i?.cadence.kind??`daily`),[_,v]=(0,m.useState)(i?.cadence.kind===`once`?hde(i.cadence.at,i.timezone):``),[y,b]=(0,m.useState)(i&&i.cadence.kind!==`once`?i.cadence.time:`09:00`),[x,S]=(0,m.useState)(i?.cadence.kind===`weekly`?i.cadence.days:[1,3,5]),[C,w]=(0,m.useState)(()=>i?.timezone??(Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`)),[T,E]=(0,m.useState)(i?.missedPolicy??`skip`),[D,O]=(0,m.useState)(i?.spendLimitCents?.toString()??``),[k,A]=(0,m.useState)(()=>f0(i?.items??[])),[j,ee]=(0,m.useState)(i?.topicKeyword??null),[te,M]=(0,m.useState)(i?.values??{}),[ne,N]=(0,m.useState)(i?.brief??``),[re,ie]=(0,m.useState)(i?.topicGeneration??nH),[ae,oe]=(0,m.useState)(!1),[se,ce]=(0,m.useState)(!1),le=(0,m.useRef)(!1),ue=(0,m.useRef)(null),de=i&&!e.some(e=>e.id===i.templateId)?[...e,{id:i.templateId,version:i.templateVersion,name:`Saved template`}]:e,fe=de.find(e=>e.id===d),pe=P({queryKey:[`project-template`,d],enabled:d!==``,queryFn:async()=>{let e=await Iq(c,d);if(!e.ok)throw Error(e.message);return e.value}}),me=pe.data?.document.form,he=me===void 0?void 0:c0({form:me,prompts:pe.data?.document.librarySnapshot?.prompts??[],entries:pe.data?.document.librarySnapshot?.entries??[]}),ge=me===void 0?[]:uq(me),_e=j!==null&&ge.includes(j)?j:ge.find(e=>me?.title.includes(`{{${e}}}`))??ge[0]??null,ve=Object.fromEntries(ge.filter(e=>e!==_e).map(e=>[e,te[e]??me?.values[e]??``])),ye={keywords:ge,topicKeyword:_e,everyRun:ve,form:me,kept:i?.items??[],...he===void 0?{}:{origins:he}},be=h0(k,ye);async function xe(e){if(e.preventDefault(),!(le.current||t)){if(!fe&&!ue.current){r(`Choose a template before saving the schedule.`);return}if(!ue.current&&be.problems.length>0){r(`Fix the topics first. ${be.problems.slice(0,3).join(` `)}`);return}if(be.rows.length>500){r(`Keep the list to 500 topics or fewer.`);return}if(ne.trim().length>4e3){r(`Keep the series brief to ${String(eH)} characters or fewer.`);return}if(re.llm!==null&&(re.llm.provider===``||re.llm.model===``)){r(`Pick both a provider and a model for topic generation, or choose Use the template's LLM.`);return}if(p===`weekly`&&x.length===0){r(`Choose at least one weekday for a weekly schedule.`);return}le.current=!0,oe(!0),s(!0);try{if(!ue.current){if(!fe)throw Error(`Choose a template before saving the schedule.`);let e=C.trim();if(!KV(e))throw Error(`Enter a timezone name like Europe/Tirane or America/New_York.`);let t=p===`once`?{kind:p,at:gde(_,e)}:p===`weekly`?{kind:p,time:y,days:x}:{kind:p,time:y},n=D.trim()===``?null:Number(D);if(n!==null&&(!Number.isInteger(n)||n<0))throw Error(`Enter the spend limit as a whole number of cents, 0 or more (500 is $5.00), or leave it empty.`);let r={id:i?.id??crypto.randomUUID(),name:l.trim(),templateId:fe.id,templateVersion:fe.version,cadence:t,timezone:e,missedPolicy:T,overlapPolicy:`skip`,spendLimitCents:n,items:be.rows,topicKeyword:_e,values:ve,brief:ne.trim()===``?null:ne.trim(),topicGeneration:re};ue.current=i?{...r,baseVersion:i.version,mutationId:crypto.randomUUID()}:r}let e=ue.current,{id:t,...a}=e,o=`mutationId`in a?await SH(c,t,a):await xH(c,e);if(!o.ok){ue.current=null,ce(!1),r(o.reason===`conflict`?`${o.message} Your inputs are kept here. To load the latest saved version, cancel editing and press Edit again.`:o.message);return}ue.current=null,ce(!1),u(``),A(f0([])),n()}catch(e){ce(ue.current!==null),r(e instanceof Error?e.message:`The schedule wasn't saved. Try again.`)}finally{le.current=!1,oe(!1),s(ue.current!==null)}}}return(0,h.jsxs)(`section`,{"aria-label":i?`Edit schedule`:`New schedule`,children:[o?(0,h.jsx)(vI,{tone:`danger`,title:`The schedule wasn't saved.`,className:`mb-4`,children:o}):null,(0,h.jsxs)(`form`,{onSubmit:e=>void xe(e),children:[(0,h.jsxs)(`fieldset`,{disabled:ae||se||t,className:`m-0 grid min-w-0 gap-4 border-0 p-0 min-[700px]:grid-cols-2`,children:[(0,h.jsx)(dV,{label:`Name`,id:`schedule-name`,tip:`planning.schedule.name`,children:(0,h.jsx)(pV,{required:!0,value:l,onChange:e=>u(e.target.value),placeholder:`Monday morning stories`})}),(0,h.jsx)(dV,{label:`Template`,id:`schedule-template`,tip:`planning.schedule.template`,children:(0,h.jsxs)(hV,{required:!0,value:d,onChange:e=>f(e.target.value),disabled:de.length===0,children:[(0,h.jsx)(`option`,{value:``,children:`Choose a template`}),de.map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,` · v`,e.version]},e.id))]})}),(0,h.jsx)(dV,{label:`Cadence`,id:`schedule-cadence`,tip:`planning.schedule.cadence`,children:(0,h.jsxs)(hV,{value:p,onChange:e=>g(e.target.value===`once`?`once`:e.target.value===`weekly`?`weekly`:`daily`),children:[(0,h.jsx)(`option`,{value:`daily`,children:`Every day`}),(0,h.jsx)(`option`,{value:`weekly`,children:`Selected weekdays`}),(0,h.jsx)(`option`,{value:`once`,children:`One time`})]})}),p===`once`?(0,h.jsx)(dV,{label:`Run at`,id:`schedule-once`,tip:`planning.schedule.once-at`,children:(0,h.jsx)(pV,{required:!0,type:`datetime-local`,value:_,onChange:e=>v(e.target.value)})}):(0,h.jsx)(dV,{label:`Local time`,id:`schedule-time`,tip:`planning.schedule.time`,children:(0,h.jsx)(pV,{required:!0,type:`time`,value:y,onChange:e=>b(e.target.value)})}),p===`weekly`?(0,h.jsxs)(`fieldset`,{className:`m-0 min-w-0 border-0 p-0`,...Ib,children:[(0,h.jsxs)(`legend`,{className:`sl-field__label mb-2 flex items-center gap-1`,children:[`Weekdays`,(0,h.jsx)(V,{id:`planning.schedule.weekdays`,className:`-my-1`})]}),(0,h.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:efe.map(([e,t])=>(0,h.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-small`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:x.includes(e),onChange:t=>S(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))}),t]},e))})]}):(0,h.jsx)(`div`,{}),(0,h.jsx)(dV,{label:`Timezone`,id:`schedule-timezone`,tip:p===`once`?`planning.schedule.timezone-once`:`planning.schedule.timezone`,children:(0,h.jsx)(pV,{value:C,onChange:e=>w(e.target.value),placeholder:`Europe/Tirane`})}),(0,h.jsx)(dV,{label:`Missed run`,id:`schedule-missed`,tip:`planning.schedule.missed`,children:(0,h.jsxs)(hV,{value:T,onChange:e=>E(e.target.value===`run-once`?`run-once`:`skip`),children:[(0,h.jsx)(`option`,{value:`skip`,children:`Skip if Slopify was closed`}),(0,h.jsx)(`option`,{value:`run-once`,children:`Run once when Slopify reopens`})]})}),(0,h.jsx)(dV,{label:`Spend ceiling (cents, optional)`,id:`schedule-spend`,tip:`planning.schedule.spend`,tipLabel:`Spend ceiling`,children:(0,h.jsx)(pV,{inputMode:`numeric`,value:D,onChange:e=>O(e.target.value),placeholder:`1000`})}),(0,h.jsx)(Qde,{queue:k,onQueue:A,context:ye,onKeyword:ee,onValue:(e,t)=>M(n=>({...n,[e]:t})),loading:d!==``&&pe.isPending,exportName:l}),(0,h.jsx)(nfe,{brief:ne,onBrief:N,generation:re,onGeneration:ie,templateLlm:me?.llm})]}),(0,h.jsxs)(`div`,{className:`sticky bottom-0 z-10 mt-6 flex flex-wrap gap-2 border-t border-line bg-ground py-3 max-md:bottom-[68px]`,children:[(0,h.jsx)(R,{type:`submit`,variant:`primary`,disabled:t||ae||de.length===0&&!se,children:ae?`Saving…`:se?`Retry save`:i?`Save changes`:`Save schedule`}),(0,h.jsx)(R,{variant:`quiet`,disabled:ae||se,onClick:a,children:i?`Cancel editing`:`Cancel`})]})]})]})}function nfe({brief:e,onBrief:t,generation:n,onGeneration:r,templateLlm:i}){let{api:a}=z(),o=P({...cb(a),enabled:n.mode!==`off`}),s=n.llm;return(0,h.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-3 border-0 border-t border-line p-0 pt-5 min-[700px]:col-span-2`,children:[(0,h.jsxs)(`legend`,{className:`float-left mb-1 flex w-full items-center gap-1 text-title-3 font-semibold`,children:[`Topic generation`,(0,h.jsx)(V,{id:`planning.schedule.generation`})]}),(0,h.jsx)(dV,{label:`Series brief (optional)`,id:`schedule-brief`,tip:`planning.schedule.brief`,tipLabel:`Series brief`,children:(0,h.jsx)(mV,{rows:3,maxLength:eH,value:e,onChange:e=>t(e.target.value),placeholder:`Ancient history, documentary style. Famous rulers and places first.`})}),(0,h.jsxs)(`div`,{className:`grid gap-4 min-[700px]:grid-cols-2`,children:[(0,h.jsx)(dV,{label:`New topics`,id:`schedule-generation`,tip:`planning.schedule.new-topics`,children:(0,h.jsxs)(hV,{value:n.mode,onChange:e=>{let t=e.target.value;r({...n,mode:t===`queue`||t===`hold`?t:`off`})},children:[(0,h.jsx)(`option`,{value:`off`,children:`Off: add topics yourself`}),(0,h.jsx)(`option`,{value:`queue`,children:`Generate and queue directly`}),(0,h.jsx)(`option`,{value:`hold`,children:`Generate and hold for approval`})]})}),n.mode===`off`?null:(0,h.jsx)(dV,{label:`Keep at least this many queued`,id:`schedule-keep`,tip:`planning.schedule.keep-count`,children:(0,h.jsx)(pV,{type:`number`,min:1,max:100,value:String(n.keepAtLeast),onChange:e=>{let t=Math.round(Number(e.target.value));r({...n,keepAtLeast:Number.isFinite(t)?Math.min(100,Math.max(1,t)):1})}})})]}),n.mode===`off`?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,...Ib,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{className:`inline-flex items-center gap-2 text-small`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:s===null,onChange:e=>r({...n,llm:e.target.checked?null:{provider:i?.provider??``,model:i?.model??``}})}),`Use the template's LLM`,s===null&&i!==void 0&&i.provider!==``?` (${i.provider} · ${i.model})`:``]}),(0,h.jsx)(V,{id:`planning.schedule.generation-llm`,className:`-my-1`})]}),s===null?null:(0,h.jsxs)(`div`,{className:`grid gap-4 min-[700px]:grid-cols-2`,children:[(0,h.jsx)(OV,{label:`Provider`,family:`llm`,providers:o.data?.providers??[],value:s.provider,problem:o.error?.message,onPick:e=>r({...n,llm:{provider:e,model:``}})}),(0,h.jsx)(kV,{label:`Model`,provider:s.provider,value:s.model,problem:void 0,onPick:e=>r({...n,llm:{...s,model:e}})})]})]})]})}function rfe({schedule:e}){let{api:t}=z(),n=_(),r=Iy(),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(!1),c=(0,m.useRef)(!1),[l,u]=(0,m.useState)(``),d=(0,m.useRef)(e);e.version>d.current.version&&(d.current=e);let f=d.current.items,p=e.topicKeyword===null?`title`:`{{${e.topicKeyword}}}`,g=async(e,i,o)=>{if(c.current)return!1;c.current=!0;let l=d.current;s(!0),a(null);try{let s=await IH(t,l.id,{baseVersion:l.version,items:e});return s.ok?(d.current=s.value,n.setQueryData(vH,e=>e?.map(e=>e.id===s.value.id?s.value:e)),n.invalidateQueries({queryKey:RH}),r(i,`success`,o?{label:`Undo`,run:()=>void g(l.items,`Put the topics back as they were.`,!1)}:void 0),!0):(a(s.reason===`conflict`?`The topics weren't saved: this schedule changed since the page loaded, possibly because a run just took a topic. The list now shows the latest; make your change again.`:`The topics weren't saved: ${s.message}`),await n.invalidateQueries({queryKey:vH}),!1)}catch(e){return a(`The topics weren't saved: ${e instanceof Error?e.message:`Slopify didn't answer.`} Check that Slopify is running, then try again.`),!1}finally{c.current=!1,s(!1)}},v=async e=>{e.preventDefault();let t=l.trim();if(t===``){a(`Write the new topic's ${p} first, then press Add topic.`);return}await g([...f,{title:t,values:{}}],`Added “${t}”.`,!0)&&u(``)},y=(e,t)=>{let n=f[e];if(n!==void 0&&t.trim()!==n.title){if(t.trim()===``){a(`Topic ${String(e+1)} needs a ${p}. Write one, or press its Remove button.`);return}g(f.map((n,r)=>r===e?{...n,title:t.trim()}:n),`Renamed to “${t.trim()}”.`,!0)}},b=(e,t)=>{let n=f[e];if(n===void 0)return;let r=[...f];r.splice(e,1),r.splice(e+t,0,n),g(r,`Moved “${n.title}” ${t===-1?`up`:`down`}.`,!0)},x=e=>{let t=f[e];t!==void 0&&g(f.filter((t,n)=>n!==e),`Removed “${t.title}”.`,!0)};return(0,h.jsxs)(`section`,{"aria-label":`Queued topics`,className:`mt-6`,...Ib,children:[(0,h.jsx)(H,{as:`h3`,title:`Queued topics · ${String(f.length)}`,info:`planning.schedule.inline-topics`,meta:e.topicKeyword===null?`Each topic becomes the next project's title.`:`Each topic fills ${p}; the next run takes the first.`}),i===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:i}),f.length===0?null:(0,h.jsx)(oU,{label:`Topics of ${e.name}`,className:`mt-2`,children:f.map((e,t)=>(0,h.jsx)(ife,{index:t,title:e.title,count:f.length,busy:o,onRename:e=>y(t,e),onMove:e=>b(t,e),onRemove:()=>x(t)},`${String(t)}:${e.title}`))}),(0,h.jsxs)(`form`,{className:`mt-3 flex flex-wrap items-center gap-2`,onSubmit:e=>void v(e),children:[(0,h.jsx)(pV,{"aria-label":`New topic`,placeholder:e.topicKeyword===null?`New topic`:`New ${p}`,maxLength:200,value:l,className:`min-w-0 flex-1`,onChange:e=>u(e.target.value)}),(0,h.jsxs)(R,{type:`submit`,size:`small`,disabled:o||f.length>=500,disabledReason:o?`Saving the last change`:`A queue holds at most 500 topics`,children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Add topic`]})]})]})}function ife({index:e,title:t,count:n,busy:r,onRename:i,onMove:a,onRemove:o}){let[s,c]=(0,m.useState)(t);(0,m.useEffect)(()=>c(t),[t]);let l=`Topic ${String(e+1)}`;return(0,h.jsx)(sU,{lead:(0,h.jsx)(`span`,{className:`w-6 text-small text-ink-3 tabular-nums`,children:e+1}),title:(0,h.jsx)(pV,{"aria-label":l,maxLength:200,value:s,onChange:e=>c(e.target.value),onBlur:()=>i(s),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i(s)):e.key===`Escape`&&c(t)}}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(My,{size:`small`,label:`Move ${t} up`,disabled:r||e===0,onClick:()=>a(-1),children:(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(My,{size:`small`,label:`Move ${t} down`,disabled:r||e===n-1,onClick:()=>a(1),children:(0,h.jsx)(uc,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(My,{size:`small`,label:`Remove ${t}`,disabled:r,onClick:o,children:(0,h.jsx)(el,{"aria-hidden":`true`,strokeWidth:1.75})})]})})}function afe({pickedId:e,onPick:t}={}){let{api:n}=z(),r=_(),i=P(yH(n)),a=P(Fq(n)),[o,s]=(0,m.useState)(null),c=Iy(),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(null),b=t===void 0?v:e??null,x=e=>{t===void 0?y(e):t(e)},[S,C]=(0,m.useState)(null),w=(0,m.useRef)(!1),T=P(ax(n)),[E]=(0,m.useState)(()=>{let e=new Date;return{from:e.toISOString(),to:new Date(e.valueOf()+79488e5).toISOString()}}),D=P(zH(n,E.from,E.to)),O=new Map;for(let e of D.data?.runs??[])e.renderedTitle!==null&&!O.has(e.scheduleId)&&O.set(e.scheduleId,e.renderedTitle);let[k,A]=(0,m.useState)(``),j=e=>{if(k===``)return!0;let t=a.data?.find(t=>t.id===e.templateId);return(t?$1(t):Qb)===k},ee=i.data?.filter(e=>e.deletedAt===null&&j(e))??[],te=i.data?.filter(e=>e.deletedAt!==null)??[],M=i.data?.find(e=>e.id===b)??ee[0]??null,ne=F({onError:e=>s(e.message),onSettled:async()=>{w.current=!1,await r.invalidateQueries({queryKey:vH})},mutationFn:async e=>e(),onSuccess:async e=>{if(!e.ok){s(e.message);return}s(null)}}),N=e=>{w.current||(w.current=!0,s(null),ne.mutate(e))},re=d||l!==null,ie=()=>{u(null),f(!1),s(null)},ae=a.data?.length===0,oe=()=>{re||ae||(u(null),f(!0),s(null))},se=e=>{f(!1),x(e.id),u(e),s(null)};Ox({id:`schedules.new`,title:`New schedule`,group:`Schedules`,keywords:[`calendar`,`recurring`],run:oe}),rS(Qx.newSchedule,()=>{ae?c(`A schedule runs a project template, and there is none yet. Open a project, choose Save as template, then run New schedule again.`,`error`):oe()},a.data!==void 0);let ce=o?{tone:`error`,text:o}:i.error?{tone:`error`,text:`The schedules couldn't be loaded: ${i.error.message} Reload the page to try again.`}:a.error?{tone:`error`,text:`The templates couldn't be loaded: ${a.error.message} Reload the page to try again.`}:void 0,le=ne.isPending||p||re;return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[(0,h.jsx)(`p`,{className:`m-0 min-w-0 text-small text-ink-2`,children:ae?(0,h.jsxs)(h.Fragment,{children:[`Save a template in`,` `,(0,h.jsx)(ma,{className:`underline`,to:`/templates`,children:`Library → Templates`}),` `,`before creating a schedule.`]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`Runs a saved template on this machine at a local time.`,(0,h.jsx)(V,{id:`planning.schedules`})]})}),(0,h.jsxs)(Py,{children:[(0,h.jsxs)(hV,{"aria-label":`Filter schedules by channel`,value:k,className:`w-auto min-w-[160px]`,onChange:e=>A(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`All channels`}),(T.data??[]).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,h.jsxs)(R,{variant:`primary`,onClick:oe,disabled:re||ae,disabledReason:ae?`Save a template in Library → Templates first`:`Finish or cancel the open form first`,children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`New schedule`]})]})]}),(0,h.jsx)(G1,{tone:re?`info`:ce?.tone??`info`,className:`mb-2`,children:re?void 0:ce?.text}),(0,h.jsx)(wq,{className:`min-[768px]:grid-cols-[minmax(320px,460px)_minmax(0,1fr)]`,list:(0,h.jsxs)(h.Fragment,{children:[i.data&&ee.length===0?(0,h.jsx)(Q1,{title:k===``?te.length===0?`No schedules yet`:`No active schedules`:`No schedules run this channel's templates`,children:k===``?te.length===0?`Your first one can be a one-off run or a recurring series. Press New schedule.`:`Create one with New schedule, or review deleted history below.`:`Pick All channels to see the others, or make one from this channel's templates.`}):null,ee.length>0?(0,h.jsx)(oU,{label:`Saved schedules`,className:`[&_.sl-row__actions]:flex-wrap`,children:ee.map(e=>(0,h.jsxs)(m.Fragment,{children:[(0,h.jsx)(_0,{schedule:e,nextTitle:O.get(e.id),selected:!re&&M?.id===e.id,pending:le,onSelect:()=>x(e.id),onEdit:()=>se(e),onAction:N,onConfirm:t=>C({kind:t,schedule:e})}),(0,h.jsx)(t0,{kind:`schedule`,id:e.id,name:e.name})]},e.id))}):null,te.length>0?(0,h.jsxs)(`details`,{className:`mt-6`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer text-small font-semibold text-ink-2`,children:[`Deleted schedules · `,te.length]}),(0,h.jsx)(`p`,{className:`m-0 mt-2 mb-2 text-small text-ink-2`,children:`Deleted schedules stay in Settings → Trash for 30 days, where Restore brings one back paused. Pick one to see its run history.`}),(0,h.jsx)(oU,{label:`Deleted schedules`,children:te.map(e=>(0,h.jsx)(_0,{schedule:e,nextTitle:void 0,selected:!re&&M?.id===e.id,pending:!1,onSelect:()=>x(e.id),onEdit:()=>void 0,onAction:N,onConfirm:()=>void 0},e.id))})]}):null]}),detail:re?(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{kicker:l?l.name:void 0,title:l?`Edit schedule`:`New schedule`,className:`mb-4`}),(0,h.jsx)(tfe,{onBusy:g,editing:l,onCancel:()=>{p||ie()},templates:a.data??[],pending:ne.isPending,error:o,onCreated:()=>{c(l?`Schedule updated.`:`Schedule saved. It will run automatically while Slopify is open.`,`success`),ie(),r.invalidateQueries({queryKey:vH})},onError:e=>{s(e),r.invalidateQueries({queryKey:vH})}},l?.id??`new`)]}):M?(0,h.jsx)(lfe,{schedule:M,pending:le,onAction:N,onConfirm:e=>C({kind:e,schedule:M})},M.id):null}),(0,h.jsx)(zy,{open:S!==null,title:S?.kind===`delete`?`Delete schedule?`:`Cancel schedule?`,consequence:(S?.kind===`delete`?`Moves this schedule to the trash for 30 days (Settings → Trash). Its run history is kept.`:`Stops future scheduled runs. Existing projects and run history are kept.`)+(o?` ${o}`:``),confirmLabel:S?.kind===`delete`?`Delete schedule`:`Cancel schedule`,cancelLabel:`Keep schedule`,pending:ne.isPending,onCancel:()=>{ne.isPending||C(null)},onConfirm:()=>{if(!S)return;let{kind:e,schedule:t}=S;N(async()=>{let r=e===`delete`?await wH(n,t.id,t.version):await CH(n,t.id,`cancel`,t.version);return r.ok&&C(null),r})}})]})}function ofe(e){return e.cadence.kind===`once`?`One time`:e.cadence.kind===`daily`?`Daily at ${e.cadence.time}`:`Weekly at ${e.cadence.time}`}var sfe={active:`Active`,paused:`Paused`,completed:`Completed`,canceled:`Canceled`},cfe={active:`running`,paused:`waiting`,completed:`done`,canceled:`off`};function g0({schedule:e}){return e.deletedAt===null?(0,h.jsx)(TS,{tone:cfe[e.status],children:sfe[e.status]}):(0,h.jsx)(TS,{tone:`off`,children:`Deleted`})}function _0({schedule:e,nextTitle:t,selected:n,pending:r,onSelect:i,onEdit:a,onAction:o,onConfirm:s}){let{api:c}=z(),l=e.deletedAt===null,u=l&&(e.status===`active`||e.status===`paused`),d=e.status===`canceled`||e.status===`completed`;return(0,h.jsx)(sU,{selected:n,onSelect:i,title:e.name,meta:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(g0,{schedule:e}),` · ${ofe(e)} · ${e.deletedAt===null?e.nextRunAt===null?`No future run`:`Next: ${M1(e.nextRunAt,e.timezone)}${t===void 0?``:` · “${t}”`}`:`Deleted: ${M1(e.deletedAt,e.timezone)}`}${e.topics.held>0?` · ${String(e.topics.held)} waiting for you`:``}`]}),actions:l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Edit ${e.name}`,disabled:r||!u,disabledReason:u?`Finish or cancel the open form first`:`Only a live schedule can change`,onClick:a,children:`Edit`}),e.status===`paused`?(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Resume ${e.name}`,disabled:r,onClick:()=>o(()=>CH(c,e.id,`resume`,e.version)),children:`Resume`}):(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Pause ${e.name}`,disabled:r||e.status!==`active`,disabledReason:`Only an active schedule can pause`,onClick:()=>o(()=>CH(c,e.id,`pause`,e.version)),children:`Pause`}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Delete ${e.name}`,disabled:r||!d,disabledReason:`Cancel the schedule first; a completed or canceled one can be deleted`,onClick:()=>s(`delete`),children:`Delete`})]}):void 0})}function lfe({schedule:e,pending:t,onAction:n,onConfirm:r}){let{api:i}=z(),a=P({queryKey:[`schedule`,e.id],queryFn:async()=>{let t=await bH(i,e.id);if(!t.ok)throw Error(t.message);return t.value},refetchInterval:3e4}),o=e.deletedAt===null,s=o&&(e.status===`active`||e.status===`paused`),c=e.status===`paused`,l=[[`When`,e.cadence.kind===`once`?`Once, ${M1(e.cadence.at,e.timezone)}`:e.cadence.kind===`daily`?`Every day at ${e.cadence.time}`:`Selected weekdays at ${e.cadence.time}`],[`Timezone`,e.timezone],[`Next run`,e.deletedAt!==null||e.nextRunAt===null?`None`:M1(e.nextRunAt,e.timezone)],[`Topics`,e.items.length===0?e.topicGeneration.mode===`off`?`Template as saved`:`No topics queued`:`${String(e.items.length)} ${e.items.length===1?`topic`:`topics`} left`],[`Missed runs`,e.missedPolicy===`skip`?`Skip`:`Run once on reopening`],[`Overlap`,`Skip`],[`Spend ceiling`,e.spendLimitCents===null?`Not set`:`${String(e.spendLimitCents)} cents`]];return(0,h.jsxs)(`section`,{"aria-label":`${e.name} detail`,children:[o&&s?(0,h.jsx)(ufe,{schedule:e,paused:c,onAction:n}):null,(0,h.jsx)(H,{kicker:(0,h.jsx)(g0,{schedule:e}),title:e.name,meta:e.topics.held>0?`${String(e.topics.held)} topics waiting for you`:void 0,children:o?(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Cancel ${e.name}`,disabled:t||!s,disabledReason:`Only an active or paused schedule can be canceled`,onClick:()=>r(`cancel`),children:`Cancel schedule`}):null}),(0,h.jsx)(`dl`,{className:`m-0 mt-4 grid grid-cols-1 gap-x-6 gap-y-3 text-small min-[600px]:grid-cols-2`,children:l.map(([e,t])=>(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`dt`,{className:`sl-kicker`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 break-words text-ink`,children:t})]},e))}),s?(0,h.jsx)(rfe,{schedule:e}):null,(0,h.jsx)(Lde,{schedule:e}),(0,h.jsx)(Tq,{className:`my-6`}),(0,h.jsx)(H,{as:`h3`,title:`Run history`}),(0,h.jsx)(`div`,{className:`mt-3`,children:a.isPending?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Loading history…`}):a.error?(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:`The run history couldn't be loaded: ${a.error.message} It tries again every 30 seconds.`}):a.data.runs.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`No runs yet.`}):(0,h.jsx)(oU,{label:`Runs of ${e.name}`,children:a.data.runs.map(t=>(0,h.jsx)(sU,{title:(0,h.jsx)(`span`,{className:`capitalize`,children:`${t.status} · ${M1(t.scheduledFor,e.timezone)}`}),meta:t.error?t.error:t.projectIds.length>0?(0,h.jsx)(`span`,{className:`inline-flex flex-wrap gap-x-3`,children:t.projectIds.map((e,t)=>(0,h.jsxs)(ma,{className:`underline hover:text-ink`,to:`/projects/$projectId`,params:{projectId:e},children:[`Project `,t+1]},e))}):`No projects`},t.id))})})]})}function ufe({schedule:e,paused:t,onAction:n}){let{api:r}=z();return Ox({id:`schedules.pause-resume`,title:t?`Resume schedule`:`Pause schedule`,group:`Schedules`,context:e.name,run:()=>n(()=>CH(r,e.id,t?`resume`:`pause`,e.version))}),null}var v0=`https://www.youtube.com/upload`,dfe=[`video`,`title`,`description`,`thumbnails`,`playlist`,`audience`,`altered`,`tags`,`schedule`];function ffe(e){return e.join(`, `)}var pfe=[.75,1,1.25,1.5,1.75,2];function y0(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0,n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=String(t%60).padStart(2,`0`);return n>0?`${String(n)}:${String(r).padStart(2,`0`)}:${i}`:`${String(r)}:${i}`}function b0(e){return`${String(e)}×`}function mfe(e,t){return e.filter(e=>e.start<=t).at(-1)}function x0(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n!=null&&(n.current=t)}}var S0=(e,t,n)=>Math.min(n,Math.max(t,e));function C0(){let e=(0,m.useRef)(null),t=(0,m.useId)(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(0),[c,l]=(0,m.useState)(0),[u,d]=(0,m.useState)(1),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(1),[_,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(null),[x,S]=(0,m.useState)(!1),C=Number.isFinite(o)&&o>0,w=()=>{let t=e.current;t!==null&&(t.paused||t.ended?t.play()?.catch(()=>void 0):t.pause())},T=t=>{let n=e.current;if(n===null||!C)return;let r=S0(t,0,o);n.currentTime=r,a(r)},E=t=>T((e.current?.currentTime??i)+t),D=t=>{let n=e.current;if(n===null)return;let r=S0(Math.round(t*100)/100,0,1);n.volume=r,n.muted=r===0,d(r),p(r===0)},O=()=>{let t=e.current;t!==null&&(t.muted=!t.muted,p(t.muted))};return{media:e,menuId:t,playing:n,current:i,duration:o,buffered:c,known:C,volume:u,muted:f,rate:h,menu:_,setMenu:v,hover:y,setHover:b,seeking:x,setSeeking:S,toggle:w,seekTo:T,jump:E,setLevel:D,toggleMute:O,pickRate:n=>{let r=e.current;r!==null&&(r.playbackRate=n),g(n),v(!1),document.getElementById(`${t}-button`)?.focus()},keyAction:e=>{let t=e.length===1?e.toLowerCase():e;if(t===` `||t===`k`)return w;if(t===`j`)return()=>E(-10);if(t===`l`)return()=>E(10);if(t===`ArrowLeft`)return()=>E(-5);if(t===`ArrowRight`)return()=>E(5);if(t===`m`)return O;if(/^[0-9]$/.test(t))return()=>T(Number(t)/10*o)},events:{onPlay:()=>r(!0),onPause:()=>r(!1),onEnded:()=>r(!1),onTimeUpdate:e=>{x||a(e.currentTarget.currentTime)},onDurationChange:e=>s(e.currentTarget.duration),onLoadedMetadata:e=>s(e.currentTarget.duration),onProgress:e=>{let t=e.currentTarget.buffered;l(t.length>0?t.end(t.length-1):0)},onVolumeChange:e=>{d(e.currentTarget.volume),p(e.currentTarget.muted)},onRateChange:e=>g(e.currentTarget.playbackRate)}}}function w0(e,t){let n=e?.getBoundingClientRect();return n===void 0||n.width===0?0:S0((t-n.left)/n.width,0,1)}function T0(e,t){t!==void 0&&(e.preventDefault(),e.stopPropagation(),t())}function E0({controls:e,className:t}){return(0,h.jsx)(My,{size:`small`,label:e.playing?`Pause`:`Play`,className:t,onClick:e.toggle,children:e.playing?(0,h.jsx)(Rc,{"aria-hidden":`true`,strokeWidth:1.75}):(0,h.jsx)(Vc,{"aria-hidden":`true`,strokeWidth:1.75})})}function D0({controls:e}){return(0,h.jsxs)(`span`,{className:`sl-player__time`,children:[(0,h.jsx)(`span`,{className:`sl-player__now`,children:y0(e.current)}),(0,h.jsx)(`span`,{className:`sl-player__total`,children:` / ${e.known?y0(e.duration):`-:--`}`})]})}function O0({controls:e,chapters:t=[],waveform:n}){let r=(0,m.useRef)(null),{known:i,duration:a,current:o,buffered:s,seeking:c,hover:l}=e,u=_fe(r),d=n===void 0?void 0:gfe(n,u),f=i?t.filter(e=>e.start>0&&e.start<a):[],p=t=>{i&&(t.currentTarget.setPointerCapture?.(t.pointerId),e.setSeeking(!0),e.seekTo(w0(r.current,t.clientX)*a))},g=t=>{let n=w0(r.current,t.clientX);e.setHover(n),c&&e.seekTo(n*a)},_=t=>{t.currentTarget.releasePointerCapture?.(t.pointerId),e.setSeeking(!1)},v=t=>{T0(t,{ArrowLeft:()=>e.jump(-5),ArrowDown:()=>e.jump(-5),ArrowRight:()=>e.jump(5),ArrowUp:()=>e.jump(5),PageDown:()=>e.jump(-10),PageUp:()=>e.jump(10),Home:()=>e.seekTo(0),End:()=>e.seekTo(a)}[t.key])},y=i?o/a*100:0,b=i?s/a*100:0,x=l===null||!i?void 0:l*a,S=x===void 0?void 0:mfe(t,x);return(0,h.jsxs)(`div`,{ref:r,role:`slider`,tabIndex:0,"aria-label":`Seek`,"aria-valuemin":0,"aria-valuemax":i?Math.floor(a):0,"aria-valuenow":Math.floor(o),"aria-valuetext":`${y0(o)} of ${i?y0(a):`unknown length`}`,"aria-disabled":!i,className:`sl-player__track`,onPointerDown:p,onPointerMove:g,onPointerUp:_,onPointerCancel:_,onPointerLeave:()=>e.setHover(null),onKeyDown:v,children:[d===void 0||d.length===0?(0,h.jsxs)(`span`,{className:`sl-player__rail`,children:[(0,h.jsx)(`span`,{className:`sl-player__buffered`,style:{width:`${String(b)}%`}}),(0,h.jsx)(`span`,{className:`sl-player__played`,style:{width:`${String(y)}%`}})]}):(0,h.jsx)(`span`,{className:`sl-player__wave`,"data-slot":`waveform`,"aria-hidden":`true`,children:d.map((e,t)=>(0,h.jsx)(`span`,{className:`sl-player__peak`,"data-played":(t+.5)/d.length*100<=y?``:void 0,style:{height:`${String(Math.max(12,Math.round(e*100)))}%`}},t))}),f.map(e=>(0,h.jsx)(`span`,{className:`sl-player__mark`,"data-chapter":e.title,title:e.title,style:{left:`${String(e.start/a*100)}%`}},`${String(e.start)}-${e.title}`)),(0,h.jsx)(`span`,{className:`sl-player__knob`,style:{left:`${String(y)}%`}}),x===void 0||l===null?null:(0,h.jsxs)(`span`,{className:`sl-player__tip`,"aria-hidden":`true`,style:{left:`${String(l*100)}%`},children:[S===void 0?null:(0,h.jsx)(`span`,{className:`sl-player__tip-title`,children:S.title}),y0(x)]})]})}function k0({controls:e}){let t=(0,m.useRef)(null),{muted:n,volume:r}=e,i=n?0:r;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(My,{size:`small`,label:n?`Unmute`:`Mute`,"aria-pressed":n,className:`sl-player__mute`,onClick:e.toggleMute,children:n||r===0?(0,h.jsx)($c,{"aria-hidden":`true`,strokeWidth:1.75}):(0,h.jsx)(Qc,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(`div`,{ref:t,role:`slider`,tabIndex:0,"aria-label":`Volume`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(i*100),"aria-valuetext":n?`Muted`:`${String(Math.round(i*100))}%`,className:`sl-player__volume`,onPointerDown:n=>{n.currentTarget.setPointerCapture?.(n.pointerId),e.setLevel(w0(t.current,n.clientX))},onPointerMove:n=>{n.buttons===1&&e.setLevel(w0(t.current,n.clientX))},onKeyDown:t=>{let n={ArrowLeft:i-.05,ArrowDown:i-.05,ArrowRight:i+.05,ArrowUp:i+.05,Home:0,End:1}[t.key];T0(t,n===void 0?void 0:()=>e.setLevel(n))},children:(0,h.jsx)(`span`,{className:`sl-player__rail`,children:(0,h.jsx)(`span`,{className:`sl-player__played`,style:{width:`${String(i*100)}%`}})})})]})}function A0({controls:e}){let{menuId:t,menu:n,rate:r}=e;return(0,h.jsxs)(`span`,{className:`sl-player__speed`,children:[(0,h.jsx)(R,{id:`${t}-button`,variant:`quiet`,size:`small`,className:`sl-player__rate`,"aria-label":`Playback speed, ${b0(r)}`,"aria-haspopup":`menu`,"aria-expanded":n,"aria-controls":n?`${t}-menu`:void 0,onClick:()=>e.setMenu(e=>!e),children:b0(r)}),n?(0,h.jsx)(`div`,{id:`${t}-menu`,role:`menu`,"aria-label":`Playback speed`,className:`sl-player__menu`,onKeyDown:n=>{if(n.key===`Escape`){T0(n,()=>{e.setMenu(!1),document.getElementById(`${t}-button`)?.focus()});return}if(n.key!==`ArrowDown`&&n.key!==`ArrowUp`)return;let r=[...n.currentTarget.querySelectorAll(`[role=menuitemradio]`)],i=r[(r.indexOf(document.activeElement)+(n.key===`ArrowDown`?1:-1)+r.length)%r.length];T0(n,()=>i?.focus())},children:pfe.map(t=>(0,h.jsx)(R,{variant:`quiet`,size:`small`,role:`menuitemradio`,"aria-checked":t===r,className:L(`sl-player__option`),autoFocus:t===r,onClick:()=>e.pickRate(t),children:t===1?`Normal`:b0(t)},t))}):null]})}var hfe=4;function gfe(e,t){let n=Math.floor(t/hfe);if(n<=0||e.length<=n)return e;let r=[];for(let t=0;t<n;t+=1){let i=Math.floor(t*e.length/n),a=Math.max(i+1,Math.floor((t+1)*e.length/n));r.push(Math.max(...e.slice(i,a)))}return r}function _fe(e){let[t,n]=(0,m.useState)(0);return(0,m.useEffect)(()=>{let t=e.current;if(t===null||(n(t.clientWidth),typeof ResizeObserver>`u`))return;let r=new ResizeObserver(()=>n(t.clientWidth));return r.observe(t),()=>r.disconnect()},[e]),t}var vfe=2500;function j0({src:e,poster:t,label:n,portrait:r=!1,captions:i,chapters:a=[],ref:o,className:s,children:c}){let l=C0(),u=l.media,d=(0,m.useRef)(null),f=(0,m.useRef)(void 0),[p,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(0),[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(!1),[D,O]=(0,m.useState)(!0),{playing:k,menu:A,seeking:j,hover:ee,events:te}=l,M=i!==void 0||y>0,ne=typeof document<`u`&&`pictureInPictureEnabled`in document&&document.pictureInPictureEnabled===!0,N=(0,m.useCallback)(()=>{O(!0),clearTimeout(f.current),f.current=setTimeout(()=>O(!1),vfe)},[]);(0,m.useEffect)(()=>()=>clearTimeout(f.current),[]);let re=k&&!D&&!A&&!T&&!j&&ee===null;(0,m.useEffect)(()=>{let e=()=>S(document.fullscreenElement===d.current);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]),(0,m.useEffect)(()=>{let e=u.current;if(e===null)return;let t=()=>w(!0),n=()=>w(!1);return e.addEventListener(`enterpictureinpicture`,t),e.addEventListener(`leavepictureinpicture`,n),()=>{e.removeEventListener(`enterpictureinpicture`,t),e.removeEventListener(`leavepictureinpicture`,n)}},[u]),(0,m.useEffect)(()=>{let e=u.current?.textTracks;if(e!==void 0)for(let t=0;t<e.length;t+=1){let n=e[t];n!==void 0&&(n.mode=_&&t===0?`showing`:`hidden`)}},[_,u]);let ie=()=>{let e=u.current;e!==null&&(e.paused||e.ended)&&g(!0),l.toggle()},ae=()=>{let e=d.current;e!==null&&(document.fullscreenElement===e?document.exitFullscreen?.():e.requestFullscreen?.()?.catch(()=>void 0))},oe=()=>{let e=u.current;e!==null&&(document.pictureInPictureElement===e?document.exitPictureInPicture?.().catch(()=>void 0):e.requestPictureInPicture?.().catch(()=>void 0))};return(0,h.jsxs)(`div`,{ref:d,"data-slot":`player`,"data-state":k?`playing`:`paused`,className:L(`sl-player`,r&&`sl-player--portrait`,re&&`sl-player--bare`,x&&`sl-player--full`,s),onKeyDown:e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.closest(`button`)!==null,n=e.key.length===1?e.key.toLowerCase():e.key,r=n===` `&&t?void 0:n===` `||n===`k`?ie:n===`f`?ae:n===`c`?M?()=>v(e=>!e):void 0:l.keyAction(n);r!==void 0&&(e.preventDefault(),e.stopPropagation(),N(),r())},onPointerMove:N,onPointerDown:N,onFocus:()=>E(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(E(!1),l.setMenu(!1))},children:[(0,h.jsxs)(`video`,{ref:x0(u,o),src:e,poster:t,preload:`metadata`,playsInline:!0,"aria-label":n,onClick:ie,...te,onPlay:e=>{te.onPlay(e),g(!0),N()},onPause:e=>{te.onPause(e),O(!0)},onEnded:e=>{te.onEnded(e),O(!0)},onLoadedMetadata:e=>{te.onLoadedMetadata(e),b(e.currentTarget.textTracks?.length??0)},children:[i===void 0?null:(0,h.jsx)(`track`,{kind:`captions`,src:i.src,srcLang:i.lang,label:i.label}),c]}),p?null:(0,h.jsx)(My,{label:`Play ${n}`,className:`sl-player__big`,onClick:ie,children:(0,h.jsx)(Vc,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsxs)(`div`,{className:`sl-player__bar`,role:`group`,"aria-label":`${n} controls`,children:[(0,h.jsx)(E0,{controls:{...l,toggle:ie}}),(0,h.jsx)(D0,{controls:l}),(0,h.jsx)(O0,{controls:l,chapters:a}),(0,h.jsx)(k0,{controls:l}),(0,h.jsx)(A0,{controls:l}),M?(0,h.jsx)(My,{size:`small`,label:`Captions`,"aria-pressed":_,onClick:()=>v(e=>!e),children:(0,h.jsx)(_c,{"aria-hidden":`true`,strokeWidth:1.75})}):null,ne?(0,h.jsx)(My,{size:`small`,label:`Picture in picture`,"aria-pressed":C,className:`sl-player__pip`,onClick:oe,children:(0,h.jsx)(Bc,{"aria-hidden":`true`,strokeWidth:1.75})}):null,(0,h.jsx)(My,{size:`small`,label:x?`Exit full screen`:`Full screen`,"aria-pressed":x,onClick:ae,children:x?(0,h.jsx)(Lc,{"aria-hidden":`true`,strokeWidth:1.75}):(0,h.jsx)(Ic,{"aria-hidden":`true`,strokeWidth:1.75})})]})]})}var yfe={landscape:void 0,portrait:`sl-media__frame--portrait`,square:`sl-media__frame--square`};function M0({src:e,alt:t,kind:n=`image`,poster:r,aspect:i=`landscape`,title:a,meta:o,badge:s,actions:c,actionsShown:l=!1,generating:u,onOpen:d,openLabel:f,className:p}){let m=u==null||u===!1;return(0,h.jsxs)(`figure`,{className:L(`sl-media m-0`,p),"data-slot":`media-frame`,children:[(0,h.jsxs)(`div`,{className:L(`sl-media__frame`,yfe[i]),children:[m&&e!==void 0?n===`video`?(0,h.jsx)(`video`,{src:e,poster:r,muted:!0,preload:`metadata`,"aria-label":t}):(0,h.jsx)(`img`,{src:e,alt:t,loading:`lazy`,decoding:`async`}):null,m?null:(0,h.jsxs)(`div`,{className:`sl-media__generating`,role:`status`,children:[(0,h.jsx)(wS,{tone:`running`}),(0,h.jsx)(`span`,{children:u})]}),s===void 0?null:(0,h.jsx)(`span`,{className:`sl-media__badge`,children:s}),c===void 0?null:(0,h.jsx)(`div`,{className:L(`sl-media__actions`,l&&`sl-media__actions--shown`),children:c})]}),d!==void 0&&m&&e!==void 0?(0,h.jsx)(`button`,{type:`button`,className:`sl-media__open`,"aria-label":f??`Open ${t} full size`,onClick:d}):null,a===void 0&&o===void 0?null:(0,h.jsxs)(`figcaption`,{className:`sl-media__caption`,children:[a===void 0?(0,h.jsx)(`span`,{}):(0,h.jsx)(`strong`,{className:`min-w-0 truncate`,children:a}),o===void 0?null:(0,h.jsx)(`span`,{className:`shrink-0`,children:o})]})]})}function N0({shorts:e=!1,density:t=`default`,list:n=!1,className:r,children:i,label:a}){let o=L(`sl-grid`,e&&`sl-grid--shorts`,t===`compact`&&`sl-grid--compact`,n&&`m-0 list-none p-0`,r);return n?(0,h.jsx)(`ul`,{"aria-label":a,className:o,"data-slot":`media-grid`,children:i}):(0,h.jsx)(`section`,{"aria-label":a,className:o,"data-slot":`media-grid`,children:i})}function P0({items:e,index:t,onIndex:n,onClose:r,actions:i}){let a=t===null?void 0:e[t],o=e.length,s=e=>{t!==null&&o!==0&&n((t+e+o)%o)};return(0,h.jsx)(Om,{open:a!==void 0,onOpenChange:e=>{e||r()},children:(0,h.jsx)(Mm,{children:(0,h.jsx)(Rm,{className:`sl-lightbox sl-enter`,onKeyDown:e=>{e.key===`ArrowRight`?(e.preventDefault(),s(1)):e.key===`ArrowLeft`&&(e.preventDefault(),s(-1))},"aria-describedby":void 0,children:a===void 0||t===null?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`sl-lightbox__bar`,children:[(0,h.jsx)(Um,{className:`m-0 text-small font-semibold`,children:`${String(t+1)} of ${String(o)} · ${a.alt}`}),(0,h.jsxs)(`div`,{className:`sl-btn-row`,children:[i?.(a,t),(0,h.jsx)(My,{label:`Previous`,onClick:()=>s(-1),disabled:o<2,children:(0,h.jsx)(bc,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(My,{label:`Next`,onClick:()=>s(1),disabled:o<2,children:(0,h.jsx)(xc,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(ree,{asChild:!0,children:(0,h.jsx)(My,{label:`Close`,children:(0,h.jsx)(el,{"aria-hidden":`true`,strokeWidth:1.75})})})]})]}),(0,h.jsx)(`div`,{className:`sl-lightbox__stage`,children:a.kind===`video`?(0,h.jsx)(j0,{src:a.src,label:a.alt,className:`sl-lightbox__player`,...a.poster===void 0?{}:{poster:a.poster}},a.src):(0,h.jsx)(`img`,{src:a.src,alt:a.alt},a.src)}),a.caption===void 0?(0,h.jsx)(`span`,{}):(0,h.jsx)(`p`,{className:`sl-lightbox__caption`,children:a.caption})]})})})})}var F0={location:mO(`docker-host`),path:W().min(1)},I0=nO([q({opened:mO(!0)}).strict(),q({opened:mO(!0),...F0}).strict(),q({opened:mO(!1),...F0}).strict()]),L0=iO(`kind`,[q({kind:mO(`allAffected`)}).strict(),q({kind:mO(`selected`),workKeys:K(W().min(1).max(200)).min(1).max(1e4)}).strict()]),R0=W().min(1).max(64),bfe=q({baseRevisionId:R0,request:L0}).strict(),xfe=q({baseRevisionId:R0,idempotencyKey:TD(),previewId:W().min(1).max(64),acknowledgeUnknownCosts:KD(),confirmedProvidedWorkKeys:K(W().min(1).max(200)).max(1e4)}).strict(),Sfe=q({stage:W(),low:G().finite().nonnegative().nullable(),high:G().finite().nonnegative().nullable(),detail:W(),onPlan:KD().optional(),apiLow:G().finite().nonnegative().nullable().optional(),apiHigh:G().finite().nonnegative().nullable().optional()}),Cfe=q({currency:mO(`USD`),rows:K(Sfe),low:G().finite().nonnegative(),high:G().finite().nonnegative(),unknown:G().int().nonnegative(),apiLow:G().finite().nonnegative().optional(),apiHigh:G().finite().nonnegative().optional(),apiUnknown:G().int().nonnegative().optional(),expectedWords:G().finite().nonnegative(),catalogueDate:W().nullable(),assumptions:K(W())}),z0=q({revisionId:R0,admissionId:W().min(1).max(64),workIds:K(W().min(1).max(64)),replayed:KD()}),wfe=q({id:W().min(1).max(64),projectId:W().min(1).max(64),baseRevisionId:R0,planFingerprint:W().min(1),selection:L0,changedInputs:K(q({path:W(),before:W().nullable(),after:W().nullable()})),work:K(q({key:W(),stage:J(US),kind:J([`provider`,`local`,`provided`]),disposition:J([`reuse`,`generate`,`local`,`review`,`blocked`]),requestFingerprint:W(),fingerprint:W(),dependsOn:K(W()),reason:W(),inflight:KD(),pieceIds:K(W())})),retained:K(q({slot:W(),outputId:W(),assetId:W(),state:J([`ready`,`outdated`,`review`])})),providedReuseRequired:K(W()),costs:Cfe,wholeRequestNotice:W().nullable(),warnings:K(W()),review:q({inputChanges:K(q({label:W(),before:W().nullable(),after:W().nullable()})),requests:K(q({key:W(),label:W(),text:W().nullable(),settings:W().nullable()}))}).optional()}),B0=[`chapter`,`chunk`,`segment`,`image`,`prompt_written`,`article_written`],V0=[`pending`,`running`,`done`,`failed`];q({id:W(),stage_id:W(),kind:J(B0),idx:G(),state:J(V0),payload:W().nullable()});var Tfe=`notes.article_md.article_txt.narration_txt.tts_script.sources.glossary.audio_body.audio_intro.audio_outro.audio_export.image.thumbnail.video.render_params.subtitles_srt.subtitles_vtt.subtitle_words.subtitle_ass.subtitle_font.instructions.document_pdf.youtube_description.youtube_tags.youtube_pinned_comment.youtube_titles.shorts.short_image.short_video.animated_image.figure_card.reference.script_md.audio_mp3.audio_m4b.audio_levelled`.split(`.`),Efe=[`copying`,`staged`],Dfe=q({segment:J([`body`,`intro`,`outro`]).optional(),subtitleOmissions:K(q({start:G().finite().nonnegative(),text:W()})).optional(),subtitlesMode:J([`off`,`files`,`burn-in`]).optional(),promptName:W().optional(),prompt:W().optional(),index:G().optional(),short:G().optional(),format:J([`16:9`,`9:16`]).optional(),sentences:cO([G(),G()]).optional(),warnings:K(W()).optional(),provider:W().optional(),model:W().optional(),voice:W().optional(),loudness:q({pieces:G(),skipped:G(),spreadBefore:G(),spreadAfter:G(),target:G()}).optional(),master:q({target:G(),integrated:G(),truePeak:G()}).optional()}),Ofe=q({id:W(),projectId:W(),stageKind:J(US),role:J(Tfe),path:W(),originalFilename:W().nullable(),bytes:G().nonnegative(),durationMs:G().nonnegative().nullable(),meta:Dfe,createdAt:W()});q({id:W(),stageKind:J(US),path:W(),originalFilename:W(),bytes:G().nonnegative(),state:J(Efe),createdAt:W()});var H0=W().min(1).max(64).regex(/^[0-9A-Za-z_-]+$/),U0=W().min(1).max(256),kfe=uO(U0,H0),Afe=q({id:H0,text:W().trim().min(1).max(1e4),start:G().finite().nonnegative(),end:G().finite().positive(),speaker:W().min(1).max(60).regex(/^[a-z0-9-]+$/).optional()}).strict().refine(e=>e.end>e.start,{path:[`end`],message:`The end time must be after the start time.`}),W0=q({articleMarkdown:W().max(5e5).optional(),articleEdited:KD().default(!1),provided:q({research:H0.optional(),article:H0.optional(),audio:H0.optional(),thumbnail:H0.optional(),reference:H0.optional()}).strict(),imageOrder:K(H0).max(240),imageDefinitions:uO(H0,q({source:J([`generate`,`provide`]),assetId:H0.nullable(),prompt:W().max(5e5).nullable(),templateKey:W().min(1).max(256).nullable().optional()}).strict()),narrationOverrides:uO(U0,iO(`kind`,[q({kind:mO(`asset`),assetId:H0}).strict(),q({kind:mO(`text`),text:W().trim().min(1).max(5e5),direction:W().trim().min(1).max(2e4).optional()}).strict()])),narrationSources:uO(U0,q({text:W().min(1).max(5e5),start:G().int().nonnegative().max(5e5),bodyFingerprint:W().regex(/^[0-9a-f]{64}$/u),chunkingFingerprint:W().regex(/^[0-9a-f]{64}$/u)}).strict()).refine(e=>Object.keys(e).length<=1e4&&Object.values(e).reduce((e,t)=>e+t.text.length,0)<=5e5,`Narration source bindings exceed the article limit.`).optional(),subtitleCues:q({audioFingerprint:W().min(1),cues:K(Afe)}).strict().optional(),regenerationTokens:kfe,promptTemplates:uO(W().min(1),W().max(5e5).nullable()),shortsMusic:H0.optional(),shortsRanges:uO(W().regex(/^[1-9]\d?$/u),q({first:G().int().positive(),last:G().int().positive(),pick:W().min(1).max(128)}).strict()).optional(),ambientBed:H0.optional()}).strict(),jfe=q({baseRevisionId:H0,idempotencyKey:H0,edit:q({config:SM.strict(),content:W0,regenerate:K(U0).optional(),uploads:K(q({stagedFileId:H0,destination:iO(`kind`,[q({kind:mO(`provided`),stage:J([`audio`,`thumbnail`,`reference`])}).strict(),q({kind:mO(`image`),imageKey:H0}).strict(),q({kind:mO(`narration`),key:U0}).strict(),q({kind:mO(`shortsMusic`)}).strict()])}).strict()).max(1e4).optional()}).strict()}).strict(),Mfe=q({baseRevisionId:H0,idempotencyKey:H0,targetRevisionId:H0}).strict(),Nfe=q({id:H0,projectId:H0,parentId:H0.nullable(),restoredFromId:H0.nullable(),config:SM,content:W0,fingerprints:uO(U0,W()),createdAt:W()}),Pfe=q({id:H0,stageId:H0,kind:J(B0),idx:G().int(),state:J(V0),payload:W().nullable()}),Ffe=q({slot:W(),workKey:U0,assetId:H0,output:Ofe,fingerprint:W(),state:J([`ready`,`outdated`,`review`])}),Ife=q({key:U0,stageKind:J(US),piece:Pfe,assetId:H0.nullable(),fingerprint:W()}),G0={recordId:H0,publicationId:H0.nullable(),selected:KD(),available:KD()},K0=q({articleMarkdown:W().nullable(),revision:Nfe,outputs:K(Ffe.extend(G0)),pieces:K(Ife.extend(G0)),current:KD()}),Lfe=q({id:H0,parentId:H0.nullable(),restoredFromId:H0.nullable(),title:W(),createdAt:W(),current:KD()}),q0=q({ok:mO(!0),view:K0,duplicate:KD()}),Rfe=q({ok:mO(!0),view:K0,created:KD()}),zfe=q({title:W(),status:G(),detail:W().optional(),reason:W().optional(),currentRevisionId:W().nullable().optional(),fields:K(q({field:W(),message:W()})).optional(),errors:K(q({path:W(),message:W()})).optional()});async function J0(e,t){let n;try{n=await e.json()}catch{throw po(e,void 0)}if(e.ok)return{ok:!0,value:So(t,n)};let r=zfe.safeParse(n);if(!r.success)throw po(e,void 0);let i=r.data;if(![400,404,409].includes(e.status))throw po(e,{title:i.title,status:i.status,...i.detail===void 0?{}:{detail:i.detail},...i.fields===void 0?{}:{fields:i.fields}});return{ok:!1,reason:i.reason??`invalid-request`,message:i.detail??i.title,currentRevisionId:i.currentRevisionId??null,fields:i.fields??i.errors?.map(e=>({field:e.path,message:e.message}))??[]}}async function Y0(e,t,n,r,i){return J0(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}${n}`,i===void 0?{method:`GET`}:{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)}),r)}function X0(e,t){return Y0(e,t,`/revisions/prepare`,Rfe,{})}function Z0(e,t,n){return Y0(e,t,`/revisions`,q0,jfe.parse(n))}function Bfe(e,t,n){return Y0(e,t,`/revisions/restore`,q0,Mfe.parse(n))}function Vfe(e,t){return Y0(e,t,`/revisions`,q({revisions:K(Lfe)}))}function Q0(e,t,n){return Y0(e,t,`/revisions/${encodeURIComponent(n)}`,q({view:K0}))}var $0=K(W()).readonly();function Hfe(e,t,n){return Y0(e,t,`/revisions/${encodeURIComponent(n)}/narration-chunks`,q({chunks:q({intro:$0.optional(),body:$0.optional(),outro:$0.optional()}).nullable()}))}function Ufe(e,t,n){return Y0(e,t,`/rebuild/preview`,q({ok:mO(!0),value:wfe}),bfe.parse(n))}function Wfe(e,t,n){return Y0(e,t,`/rebuild`,q({ok:mO(!0),value:z0}),xfe.parse(n))}function e2(e,t,n,r){return`${e.origin}/files/${encodeURIComponent(t)}/revisions/${encodeURIComponent(n)}/${encodeURIComponent(r)}`}async function Gfe(e,t,n,r){let i=await J0(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/revisions/${encodeURIComponent(n)}/${encodeURIComponent(r)}/open-folder`,{method:`POST`}),I0);if(!i.ok)throw Error(i.message);return i.value}function Kfe(e,t,n){return e2(e,t,n,`images.zip`)}async function t2(e,{projectId:t,asset:n,folder:r=null}){if(r)return Gfe(e,t,r.revisionId,r.recordId);let i=await e.client.projects[`:id`][`open-folder`].$post({param:{id:t},json:{asset:n}});if(!i.ok)throw po(i,await mo(i));return I0.parse(await i.json())}var n2=`Slopify runs in Docker, which can't open windows on your desktop. Copy this path into your file manager. To have Open folder open it directly, run the Docker launcher again (npx @gentbajko/slopify@latest --docker) so it sets up the host helper.`;function r2(e){return(0,h.jsx)(qfe,{...e},JSON.stringify([e.projectId,e.asset,e.folder?.revisionId,e.folder?.recordId]))}function qfe(e){let{api:t}=z(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(),[o,s]=(0,m.useState)();async function c(){r(!0),a(void 0),s(void 0);try{let n=await t2(t,e);n.opened||s(n.path)}catch(e){a(e instanceof Error?e.message:`The folder couldn't be opened. Press Open folder to try again.`)}finally{r(!1)}}return(0,h.jsxs)(Ab,{open:o!==void 0||i!==void 0,onOpenChange:e=>{e||(s(void 0),a(void 0))},children:[(0,h.jsx)(Mb,{asChild:!0,children:(0,h.jsxs)(R,{variant:`secondary`,size:e.size??`default`,disabled:n,onClick:()=>void c(),title:`Locate the saved output folder on the machine running Slopify`,children:[(0,h.jsx)(Ac,{"aria-hidden":`true`,strokeWidth:1.75}),n?`Locating…`:o?`Locate folder`:`Open folder`]})}),(0,h.jsxs)(Pb,{className:`flex flex-col gap-2`,children:[o===void 0?null:(0,h.jsxs)(`div`,{role:`status`,className:`flex min-w-0 flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`p`,{className:`m-0`,children:n2}),(0,h.jsx)(`input`,{"aria-label":`Saved folder path`,readOnly:!0,value:o,onFocus:e=>e.currentTarget.select(),className:`sl-input w-full min-w-0 font-mono text-small`})]}),i===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:i})]})]})}var Jfe={chrome:`Chrome, Edge, Brave`,firefox:`Firefox`};function Yfe(){return typeof navigator<`u`&&/firefox/i.test(navigator.userAgent)?`firefox`:`chrome`}function i2(){let{api:e}=z(),[t,n]=(0,m.useState)(Yfe),r=`slopify-studio-${t}.zip`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(Rb,{label:`Browser`,value:t,onChange:n,tip:`settings.studio.install`,options:[`chrome`,`firefox`].map(e=>({value:e,label:Jfe[e]}))}),(0,h.jsxs)(SS,{href:ps(e,t),download:r,children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,className:`size-4 shrink-0`,strokeWidth:1.75}),`Download for ${t===`chrome`?`Chrome`:`Firefox`}`]})]}),(0,h.jsxs)(`ol`,{"aria-label":`Install steps`,className:`m-0 flex list-decimal flex-col gap-1 pl-5`,children:[t===`chrome`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`li`,{children:[`Press Download for Chrome, then unzip `,(0,h.jsx)(gV,{children:r}),` into a folder you keep: the browser loads the extension from there.`]}),(0,h.jsxs)(`li`,{children:[`Open `,(0,h.jsx)(gV,{children:`chrome://extensions`}),` (Edge: `,(0,h.jsx)(gV,{children:`edge://extensions`}),`), turn on Developer mode, press Load unpacked and pick that folder.`]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`li`,{children:`Press Download for Firefox. It needs Firefox 128 or newer; keep the zip, you pick it in the next step.`}),(0,h.jsxs)(`li`,{children:[`Open `,(0,h.jsx)(gV,{children:`about:debugging#/runtime/this-firefox`}),`, press Load Temporary Add-on and pick `,(0,h.jsx)(gV,{children:r}),`. Firefox removes it when it restarts; load it again then.`]})]}),(0,h.jsx)(`li`,{children:`Pair it: press Copy beside the pairing token in Settings → YouTube Studio, click the Slopify extension's toolbar button, paste the token and press Pair.`})]})]})}o(((e,t)=>{t.exports={}}))(),q({key:W()}),q({provider:J(UF)}),q({id:W(),provider:J(UF),name:W(),voice_id:W(),languages_json:W().nullable()}),q({value:W()});var Xfe=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],a2=q({day:G().int().min(0).max(6),time:W().regex(/^([01]\d|2[0-3]):[0-5]\d$/)}),Zfe=q({name:W().trim().min(1).max(20),long:a2,shorts:K(a2).max(10)});q({timeZone:W().min(1).max(100),rows:K(Zfe).max(14)});var o2=[`studio`,`plan`],Qfe=[`America/New_York`,`America/Los_Angeles`,`Europe/London`,`UTC`];function s2({slot:e,label:t,onChange:n}){return(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(hV,{"aria-label":`${t}: day`,className:`w-[72px]`,value:String(e.day),onChange:t=>n({...e,day:Number(t.currentTarget.value)}),options:Xfe.map((e,t)=>({value:String(t),label:e}))}),(0,h.jsx)(pV,{"aria-label":`${t}: time`,type:`time`,className:`w-[96px]`,value:e.time,onChange:t=>n({...e,time:t.currentTarget.value||e.time})})]})}function $fe({autoComment:e}){let{api:t}=z(),n=_(),r=Iy(),i=P({queryKey:o2,queryFn:()=>ss(t)}),[a,o]=(0,m.useState)(),s=a??i.data?.plan,c=F({mutationFn:e=>cs(t,e),onSuccess:e=>{n.setQueryData(o2,e),o(void 0),r(`Saved the posting plan.`,`success`)},onError:e=>r(`The posting plan wasn't saved: ${e.message}`,`error`)}),l=F({mutationFn:e=>ls(t,e),onSuccess:()=>n.invalidateQueries({queryKey:[`studio`,`settings`]}),onError:e=>r(`Not saved: ${e.message}`,`error`)});if(s===void 0)return(0,h.jsx)(`p`,{className:`text-small text-ink-3`,children:`Loading the posting plan…`});let u=Math.max(0,...s.rows.map(e=>e.shorts.length)),d=e=>o(e),f=(e,t)=>d({...s,rows:s.rows.map((n,r)=>r===e?t:n)}),p=[...new Set([s.timeZone,...Qfe])];return(0,h.jsxs)(`section`,{"aria-label":`Posting plan`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(H,{as:`h3`,title:`Posting plan`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Each finished project takes the next free row when you prepare its upload. Each short goes out the first time its day and hour come round after its own video. The extension types the times into Studio; you press Schedule.`}),(0,h.jsx)(`div`,{className:`overflow-x-auto`,children:(0,h.jsxs)(`table`,{className:`border-separate border-spacing-x-2 border-spacing-y-1 text-small`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`text-left text-ink-3`,children:[(0,h.jsx)(`th`,{className:`font-normal`,children:`Video`}),(0,h.jsx)(`th`,{className:`font-normal`,children:`Long video`}),Array.from({length:u},(e,t)=>`Short ${String(t+1)}`).map(e=>(0,h.jsx)(`th`,{className:`font-normal`,children:e},e)),(0,h.jsx)(`th`,{})]})}),(0,h.jsx)(`tbody`,{children:s.rows.map((e,t)=>(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`td`,{className:`font-semibold`,children:e.name}),(0,h.jsx)(`td`,{children:(0,h.jsx)(s2,{slot:e.long,label:`${e.name}, long video`,onChange:n=>f(t,{...e,long:n})})}),e.shorts.map((t,n)=>({short:t,at:n,key:`${e.name}-${String(n+1)}`})).map(({short:n,at:r,key:i})=>(0,h.jsx)(`td`,{children:(0,h.jsx)(s2,{slot:n,label:`${e.name}, short ${String(r+1)}`,onChange:n=>f(t,{...e,shorts:e.shorts.map((e,t)=>t===r?n:e)})})},i)),(0,h.jsx)(`td`,{children:(0,h.jsx)(My,{label:`Remove row ${e.name}`,onClick:()=>d({...s,rows:s.rows.filter((e,n)=>n!==t)}),children:(0,h.jsx)(Yc,{"aria-hidden":`true`,strokeWidth:1.75})})})]},e.name))})]})}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsxs)(R,{type:`button`,variant:`quiet`,disabled:s.rows.length>=14,onClick:()=>{let e=s.rows.at(-1),t=String.fromCharCode(65+s.rows.length);d({...s,rows:[...s.rows,{name:t,long:e?.long??{day:0,time:`20:00`},shorts:e?.shorts??[]}]})},children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,strokeWidth:1.75}),`Add a row`]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-small text-ink-2`,children:[`Times are in`,(0,h.jsx)(hV,{"aria-label":`The plan's time zone`,value:s.timeZone,onChange:e=>d({...s,timeZone:e.currentTarget.value}),options:p.map(e=>({value:e,label:e.replace(/_/g,` `)}))})]}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(R,{type:`button`,disabled:a===void 0||c.isPending,onClick:()=>c.mutate(s),children:`Save posting plan`})]}),(0,h.jsx)(Lb,{checked:e===!0,disabled:l.isPending||e===void 0,onChange:e=>l.mutate(e),label:`Post and pin each video's comment once it is public (the extension posts it in your name)`})]})}var c2=[`studio`,`settings`];function epe(){let{api:e}=z(),t=P({queryKey:c2,queryFn:()=>rs(e)});return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{title:`Upload pack and extension`,info:`settings.studio.extension`}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsx)(tpe,{}),(0,h.jsx)($fe,{autoComment:t.data?.autoComment??!1}),(0,h.jsx)(rpe,{}),(0,h.jsxs)(`section`,{"aria-label":`Install the Studio extension`,children:[(0,h.jsx)(H,{as:`h3`,title:`Install the Studio extension`,className:`mb-3`}),(0,h.jsx)(i2,{})]})]})]})}var l2=``;function tpe(){let{api:e}=z(),t=_(),n=Iy(),r=(0,m.useId)(),i=P({queryKey:c2,queryFn:()=>rs(e)}),a=P(ax(e)),o=(0,m.useId)(),[s,c]=(0,m.useState)(l2),[l,u]=(0,m.useState)(void 0),d=i.data?.playlists??[],f=s===l2?void 0:i.data?.channelPlaylists[s],p=l??(s===l2?d:f??[]),g=npe(p),v=F({mutationFn:t=>is(e,t,s===l2?void 0:s),onSuccess:()=>{u(void 0),t.invalidateQueries({queryKey:c2}),n(`Playlists saved.`,`success`)}}),y=e=>{v.reset(),u(e)},b=g??v.error?.message,x=[{value:l2,label:`Every channel (default)`},...(a.data??[]).map(e=>({value:e.id,label:e.name}))];return(0,h.jsxs)(dV,{label:`Playlists`,tip:`settings.studio.playlist`,help:s===l2?`The playlists upload packs offer, for every channel without its own. Ticked ones are on for every project; Prepare upload changes them for one project.`:f===void 0&&d.length>0?`This channel uses the default list (${(e=>e.map(e=>e.name).join(`, `))(d)}) until you add its own.`:`This channel's own playlists. Ticked ones are on for every project; Prepare upload changes them for one project.`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(hV,{id:o,"aria-label":`Channel`,value:s,options:x,onChange:e=>{v.reset(),u(void 0),c(e.currentTarget.value)},className:`max-w-[260px]`}),p.map((e,t)=>(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(pV,{autoComplete:`off`,"aria-label":`Playlist ${String(t+1)} name`,placeholder:`The playlist's name in Studio`,className:`min-w-0 flex-1 basis-[220px]`,value:e.name,disabled:i.data===void 0,"aria-invalid":e.name.trim().length>150,"aria-describedby":b===void 0?void 0:r,onChange:e=>y(p.map((n,r)=>r===t?{...n,name:e.target.value}:n))}),(0,h.jsxs)(`label`,{className:`flex min-h-9 items-center gap-2 text-small`,children:[(0,h.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-[var(--color-accent)]`,checked:e.byDefault,onChange:e=>{let n=e.currentTarget.checked;y(p.map((e,r)=>r===t?{...e,byDefault:n}:e))}}),`On by default`]}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Remove ${e.name.trim()||`playlist ${String(t+1)}`}`,onClick:()=>y(p.filter((e,n)=>n!==t)),children:`Remove`})]},t)),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsxs)(R,{variant:`secondary`,disabled:i.data===void 0||p.length>=20,onClick:()=>y([...p,{name:``,byDefault:p.length===0}]),children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,strokeWidth:1.75}),`Add playlist`]}),(0,h.jsx)(R,{variant:`primary`,disabled:v.isPending||l===void 0||g!==void 0,onClick:()=>v.mutate(p),children:`Save playlists`})]})]}),b===void 0?null:(0,h.jsx)(`p`,{id:r,role:`alert`,className:`m-0 text-small text-danger`,children:b})]})}function npe(e){if(e.find(e=>e.name.trim().length>150)!==void 0)return`A playlist name is longer than YouTube allows (150 characters). Shorten it.`;let t=new Set;for(let n of e){let e=n.name.trim().toLowerCase();if(e!==``){if(t.has(e))return`"${n.name.trim()}" is listed twice. Remove one.`;t.add(e)}}}function rpe(){let{api:e}=z(),t=_(),n=Iy(),r=P({queryKey:c2,queryFn:()=>rs(e)}),i=F({mutationFn:()=>gs(e),onSuccess:()=>{t.invalidateQueries({queryKey:c2}),n(`New pairing token made. Pair the extension again with it.`,`success`)}}),a=r.data?.pairing;return(0,h.jsxs)(`div`,{className:`sl-field`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,h.jsx)(`span`,{className:`sl-field__label`,children:`Extension pairing token`}),(0,h.jsx)(V,{id:`settings.studio.pairing`,className:`-my-1`})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`code`,{className:`sl-code min-w-0 flex-1 basis-[220px] truncate py-2 select-all`,children:a?.token??`…`}),(0,h.jsxs)(R,{variant:`quiet`,disabled:a===void 0,onClick:()=>{if(a!==void 0){if(!navigator.clipboard){n(`Couldn't copy the token. Select it and copy it.`,`error`);return}navigator.clipboard.writeText(a.token).then(()=>n(`Pairing token copied. Paste it into the extension's options.`,`success`),()=>n(`Couldn't copy the token. Select it and copy it.`,`error`))}},children:[(0,h.jsx)(Tc,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),`Copy`]}),(0,h.jsx)(R,{variant:`quiet`,disabled:i.isPending||a===void 0,onClick:()=>i.mutate(),children:`New pairing token`})]}),(0,h.jsx)(`p`,{className:`sl-field__help m-0`,children:a?.origin==null?`No extension is paired. Paste this token into the Slopify Studio extension's options and press Pair.`:`Paired with the extension at ${a.origin}. A new token unpairs it.`}),i.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:i.error.message})]})}var u2=[`studio`,`queue`];function d2({projectId:e,ready:t,variant:n=`secondary`,size:r=`default`}){let[i,a]=(0,m.useState)(!1);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R,{variant:n,size:r,disabled:!t,disabledReason:`Available once the video has been made`,onClick:()=>a(!0),children:`Prepare upload`}),i?(0,h.jsx)(h2,{projectId:e,onClose:()=>a(!1)}):null]})}var f2={video:`Video file`,title:`Title`,description:`Description`,thumbnails:`Thumbnail`,playlist:`Playlist`,audience:`Audience`,altered:`AI use (under Show more)`,tags:`Tags (under Show more)`,schedule:`Schedule (Visibility)`};function p2(e){return new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e))}function m2(e){return e.kind===`video`?`video`:`short-${String(e.short)}`}function h2({projectId:e,onClose:t}){let{api:n}=z(),r=_(),i=[`studio`,`pack`,e],a=P({queryKey:i,queryFn:()=>_s(n,e)}),[o,s]=(0,m.useState)(`video`),[c,l]=(0,m.useState)(),u=a.data?.items??[],d=u.find(e=>m2(e)===o)??u[0],f=P({queryKey:c2,queryFn:()=>rs(n)}),p=f.data===void 0?void 0:f.data.pairing.origin!==null,g=P({queryKey:u2,queryFn:()=>ms(n)}),v=F({mutationFn:t=>ys(n,e,t.short),onSuccess:e=>{r.setQueryData(u2,e),l({text:e.length>1?`Added; ${String(e.length)} uploads are waiting. Studio is opening: each upload you start there is filled with the next one, in the order under Waiting for Studio. Check everything and publish yourself.`:`Studio is opening. The Slopify Studio extension puts the video into its upload dialog and fills in the details. Check everything and publish yourself.`,tone:`success`})},onError:e=>l({text:`Couldn't hand this to the extension: ${e.message}`,tone:`error`})}),y=F({mutationFn:e=>hs(n,e.projectId,e.short),onSuccess:e=>r.setQueryData(u2,e),onError:e=>l({text:`Couldn't remove it from Waiting for Studio: ${e.message} Press Remove again.`,tone:`error`})}),b=F({mutationFn:t=>vs(n,e,t),onSuccess:e=>{r.setQueryData(i,e),l({text:`Saved. The AI use answer is updated.`,tone:`success`})},onError:e=>l({text:`Couldn't save whether the clips are real footage: ${e.message} Press the switch again.`,tone:`error`})}),x=F({mutationFn:t=>as(n,e,t),onSuccess:e=>{r.setQueryData(i,e),l({text:`Saved this project's playlists.`,tone:`success`})},onError:e=>l({text:`Couldn't save the playlists: ${e.message} Tick the playlist again.`,tone:`error`})}),S=F({mutationFn:t=>us(n,e,t),onSuccess:e=>{r.setQueryData(i,e),l({text:`Saved when this project goes out.`,tone:`success`})},onError:e=>l({text:`Couldn't change the slot: ${e.message} Choose it again.`,tone:`error`})}),C=F({mutationFn:t=>os(n,e,t),onSuccess:e=>{r.setQueryData(i,e),l({text:`Saved what the upload uses.`,tone:`success`})},onError:e=>l({text:`Couldn't save the choice: ${e.message} Choose it again.`,tone:`error`})});return(0,h.jsxs)(XP,{open:!0,title:`Prepare upload`,onClose:t,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(G1,{tone:c?.tone??`info`,children:c?.text}),p===!1?(0,h.jsx)(SS,{href:v0,target:`_blank`,rel:`noopener noreferrer`,variant:`secondary`,children:`Open YouTube Studio`}):null,(0,h.jsx)(R,{variant:`primary`,disabled:d===void 0||v.isPending||p!==!0,disabledReason:p===!1?`Install and pair the Slopify Studio extension first (steps above)`:f.error===null?`Wait for the upload pack to load`:`Couldn't check whether the extension is paired: ${f.error.message} Close Prepare upload and open it again.`,onClick:()=>{d!==void 0&&(window.open(v0,`_blank`,`noopener`),v.mutate(d))},children:`Fill in YouTube Studio`}),(0,h.jsx)(V,{id:`project.upload.fill-studio`})]}),children:[a.error===null?null:(0,h.jsx)(vI,{tone:`danger`,title:`The upload pack couldn't be read.`,children:`${a.error.message} Close Prepare upload and open it again.`}),a.data===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[p===!1?(0,h.jsx)(vI,{tone:`waiting`,title:`The Slopify Studio extension isn't paired.`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(`p`,{className:`m-0`,children:`Without it, the steps below are the upload pack: copy each into Studio's upload dialog. To have Studio filled in for you, install the extension:`}),(0,h.jsx)(i2,{})]})}):null,u.length>1?(0,h.jsx)(Rb,{label:`What to upload`,value:d===void 0?``:m2(d),onChange:s,tip:`project.upload.item`,options:u.map(e=>({value:m2(e),label:e.kind===`video`?`Video`:`Short ${String(e.short)}`})),className:`self-start`}):null,a.data.missing.length===0?null:(0,h.jsx)(vI,{tone:`waiting`,title:`Some of it isn't made yet.`,children:(0,h.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:a.data.missing.map(e=>(0,h.jsx)(`li`,{children:e},e))})}),d===void 0?null:(0,h.jsx)(ape,{projectId:e,item:d,footageSwitch:d.kind===`video`&&a.data.footage!==void 0?(0,h.jsx)(Lb,{checked:b.isPending?b.variables:a.data.footage.real,disabled:b.isPending,onChange:e=>b.mutate(e),tip:`project.upload.real-footage`,label:`The ${a.data.footage.clips===1?`uploaded clip is`:`${String(a.data.footage.clips)} uploaded clips are`} real footage (filmed, not made by AI)`}):void 0,playlistPicker:a.data.playlistChoices.length>1?(0,h.jsx)(`span`,{className:`flex flex-col gap-1`,children:a.data.playlistChoices.map(e=>(0,h.jsxs)(`label`,{className:`flex min-h-8 items-center gap-2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-[var(--color-accent)]`,checked:e.chosen,disabled:x.isPending,onChange:t=>{let n=t.currentTarget.checked;x.mutate(a.data.playlistChoices.filter(t=>t.name===e.name?n:t.chosen).map(e=>e.name))}}),e.name]},e.name))}):void 0,copy:(e,t)=>{if(!navigator.clipboard){l({text:`Couldn't copy the ${t}. Select the text and copy it.`,tone:`error`});return}navigator.clipboard.writeText(e).then(()=>l({text:`Copied the ${t}.`,tone:`success`}),()=>l({text:`Couldn't copy the ${t}. Select the text and copy it.`,tone:`error`}))},onPick:e=>C.mutate(e),slotPicker:d.kind===`video`?(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,...Ib,children:[(0,h.jsx)(hV,{"aria-label":`Posting plan slot`,value:a.data.schedule===void 0?``:`${a.data.schedule.row}|${a.data.schedule.longAt}`,disabled:S.isPending,onChange:e=>{let[t,n]=e.currentTarget.value.split(`|`);S.mutate(t===void 0||n===void 0?null:{row:t,longAt:n})},options:[{value:``,label:`Not scheduled (set it in Studio yourself)`},...a.data.schedule===void 0?[]:[{value:`${a.data.schedule.row}|${a.data.schedule.longAt}`,label:`${a.data.schedule.row} · ${p2(a.data.schedule.longAt)}`}],...(a.data.slotChoices??[]).map(e=>({value:`${e.row}|${e.longAt}`,label:`${e.row} · ${p2(e.longAt)}`}))]}),(0,h.jsx)(V,{id:`project.upload.slot`})]}):void 0,picking:C.isPending,doneKey:`slopify.upload.${e}.${m2(d)}`},m2(d)),(g.data??[]).length===0?null:(0,h.jsxs)(`section`,{"aria-label":`Waiting for Studio`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center gap-1`,children:[(0,h.jsx)(`div`,{className:`sl-kicker`,children:`Waiting for Studio`}),(0,h.jsx)(V,{id:`project.upload.queue`,className:`-my-1`})]}),(0,h.jsx)(oU,{label:`Waiting to be filled`,children:(g.data??[]).map((e,t)=>{let n=e.short===null?`Video`:`Short ${String(e.short)}`;return(0,h.jsx)(sU,{title:`${e.projectTitle} · ${n}`,meta:t===0?`Next: filled in the next upload dialog you open in Studio.`:`Filled after ${String(t)} more upload${t===1?``:`s`}.`,actions:(0,h.jsx)(R,{variant:`quiet`,size:`small`,disabled:y.isPending,"aria-label":`Remove ${e.projectTitle} ${n.toLowerCase()} from Waiting for Studio`,onClick:()=>y.mutate(e),children:`Remove`})},`${e.projectId}-${String(e.short)}`)})})]}),(0,h.jsx)(vI,{title:`Slopify never publishes.`,children:p===!1?`Copy each step into Studio's upload dialog (Open YouTube Studio), check it and press Publish yourself.`:`Fill in YouTube Studio hands this to the Slopify Studio extension, which puts the video into Studio's upload dialog and fills in the details. You check it and press Publish.`})]})]})}function ipe(e){try{let t=JSON.parse(localStorage.getItem(e)??`[]`);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function g2({href:e,filename:t}){return(0,h.jsxs)(SS,{href:e,download:t,"aria-label":`Download ${t}`,variant:`secondary`,size:`small`,children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,className:`size-4 shrink-0`,strokeWidth:1.75}),`Download`]})}function ape({projectId:e,item:t,footageSwitch:n,playlistPicker:r,copy:i,onPick:a,picking:o,slotPicker:s,doneKey:c}){let{api:l}=z(),[u,d]=(0,m.useState)(()=>ipe(c)),[f,p]=(0,m.useState)(null),g=e=>{d(e);try{localStorage.setItem(c,JSON.stringify(e))}catch{}},_=(e,t)=>g(t?[...u,e]:u.filter(t=>t!==e)),v=dfe.filter(e=>e!==`thumbnails`||t.kind===`video`),y=v.filter(e=>u.includes(e)).length,b=e=>{let n=v2(t,e);return(0,h.jsxs)(R,{variant:`quiet`,size:`small`,disabled:n===``,disabledReason:`Nothing to copy yet`,"aria-label":`Copy ${f2[e].toLowerCase()}`,onClick:()=>i(n,f2[e].toLowerCase()),children:[(0,h.jsx)(Tc,{"aria-hidden":`true`,className:`size-4 shrink-0`,strokeWidth:1.75}),`Copy`]})},x=c=>{switch(c){case`video`:return t.video===null?{value:(0,h.jsx)(`span`,{className:`text-ink-3`,children:`Not made yet.`})}:{value:t.video.filename,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(g2,{href:`${l.origin}${t.video.url}`,filename:t.video.filename}),(0,h.jsx)(r2,{projectId:e,asset:t.video.asset,size:`small`})]})};case`thumbnails`:return t.thumbnails.length===0?{value:(0,h.jsx)(`span`,{className:`text-ink-3`,children:`None made.`})}:{value:t.thumbnails.length>1?`${_2(t.pickable?.thumbnail??0)} under Thumbnail (choose below). The A/B test tries all ${String(t.thumbnails.length)} once the video is public.`:t.thumbnails[0]?.filename??``,actions:(0,h.jsx)(r2,{projectId:e,asset:t.thumbnails[0]?.asset??`thumbnail`,size:`small`})};case`audience`:return{value:`No, it's not made for kids`};case`altered`:return{value:(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`span`,{className:`font-semibold`,children:t.alteredContent.altered?`Yes`:`No`}),(0,h.jsx)(`span`,{className:`text-ink-2`,children:t.alteredContent.why}),n]})};case`description`:return{value:t.chapterNotice===void 0?v2(t,c)||(0,h.jsx)(`span`,{className:`text-ink-3`,children:`Not written yet.`}):(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`span`,{children:t.description}),(0,h.jsx)(`span`,{className:`text-waiting`,children:t.chapterNotice})]}),actions:b(c)};case`title`:return t.titles.length===0||t.pickable===void 0?{value:v2(t,c),actions:b(c)}:{value:(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`span`,{role:`radiogroup`,"aria-label":`Title the upload uses`,className:`flex flex-col gap-1`,children:t.pickable.titles.map((n,r)=>(0,h.jsxs)(`label`,{className:`flex min-h-8 items-center gap-2`,children:[(0,h.jsx)(`input`,{type:`radio`,name:`upload-title-${e}`,className:`size-4 accent-[var(--color-accent)]`,checked:r===t.pickable?.title,disabled:o,onChange:()=>a({title:r,thumbnail:t.pickable?.thumbnail??0})}),n]},n))}),(0,h.jsx)(`span`,{className:`text-ink-2`,children:`The upload uses the chosen title; the A/B test tries the others beside it once the video is public.`})]}),actions:(0,h.jsxs)(h.Fragment,{children:[b(c),(0,h.jsxs)(R,{variant:`quiet`,size:`small`,"aria-label":`Copy the other titles`,onClick:()=>i(t.titles.join(`
|
|
272
272
|
`),`other titles`),children:[(0,h.jsx)(Tc,{"aria-hidden":`true`,className:`size-4 shrink-0`,strokeWidth:1.75}),`Copy others`]})]})};case`schedule`:return{value:(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[s,(0,h.jsx)(`span`,{className:`text-ink-2`,children:t.scheduleAt===void 0?`Not scheduled: Slopify has no slot for it. Set the date in Studio's Visibility step.`:`${p2(t.scheduleAt)}, your time. The extension types it into Studio's Visibility step; you press Schedule.`})]})};case`playlist`:return{value:r??(t.playlists.length>0?t.playlists.join(`, `):(0,h.jsx)(`span`,{className:`text-ink-3`,children:`None set (Settings → YouTube Studio).`})),actions:b(c)};default:return{value:v2(t,c)||(0,h.jsx)(`span`,{className:`text-ink-3`,children:`Not written yet.`}),actions:b(c)}}};return(0,h.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,h.jsxs)(`section`,{"aria-label":`In the order Studio asks`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center gap-1`,children:[(0,h.jsx)(`div`,{className:`sl-kicker`,children:`In the order Studio asks`}),(0,h.jsx)(V,{id:`project.upload.steps`,className:`-my-1`}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsxs)(`label`,{className:`flex min-h-8 cursor-pointer items-center gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:y===v.length,ref:e=>{e!==null&&(e.indeterminate=y>0&&y<v.length)},onChange:e=>g(e.currentTarget.checked?[...v]:[]),className:`size-4 shrink-0 accent-[var(--color-accent)]`}),`Select all`]})]}),(0,h.jsx)(oU,{label:`Upload steps`,className:`[&_.sl-row__actions]:flex-wrap`,children:v.map(e=>{let{value:t,actions:n}=x(e);return(0,h.jsx)(sU,{className:`items-start`,lead:(0,h.jsx)(`input`,{type:`checkbox`,checked:u.includes(e),onChange:t=>_(e,t.currentTarget.checked),className:`mt-1 size-4 shrink-0 self-start accent-[var(--color-accent)]`,"aria-label":`${f2[e]} done`}),title:f2[e],meta:(0,h.jsx)(`span`,{className:`line-clamp-4 whitespace-pre-wrap break-words text-ink`,children:t}),actions:n},e)})})]}),t.thumbnails.length===0?null:(0,h.jsxs)(`section`,{"aria-label":`Thumbnails`,children:[(0,h.jsx)(H,{as:`h3`,kicker:`Thumbnails · A/B Testing`,title:`${String(t.thumbnails.length)} ${t.thumbnails.length===1?`thumbnail`:`thumbnails`}`,className:`mb-3`}),(0,h.jsx)(N0,{label:`Thumbnails to upload`,density:`compact`,children:(t.pickable?.thumbnails??t.thumbnails).map((e,n)=>{let r=n===(t.pickable?.thumbnail??0);return(0,h.jsx)(M0,{src:`${l.origin}${e.url}`,alt:`Thumbnail ${_2(n)}`,title:r&&t.thumbnails.length>1?`${_2(n)} · upload`:_2(n),meta:e.filename,onOpen:()=>p(n),openLabel:`Open thumbnail ${_2(n)} full size`,actionsShown:!0,actions:(0,h.jsxs)(h.Fragment,{children:[r||t.pickable===void 0?null:(0,h.jsx)(R,{variant:`quiet`,size:`small`,disabled:o,onClick:()=>a({title:t.pickable?.title??0,thumbnail:n}),children:`Use for upload`}),(0,h.jsx)(g2,{href:`${l.origin}${e.url}`,filename:e.filename})]})},e.asset)})}),(0,h.jsx)(P0,{items:(t.pickable?.thumbnails??t.thumbnails).map((e,t)=>({src:`${l.origin}${e.url}`,alt:`Thumbnail ${String.fromCharCode(65+t)}`,caption:e.filename})),index:f,onIndex:p,onClose:()=>p(null),actions:(e,n)=>{let r=(t.pickable?.thumbnails??t.thumbnails)[n];return r===void 0?null:(0,h.jsx)(g2,{href:`${l.origin}${r.url}`,filename:r.filename})}})]})]})}function _2(e){return String.fromCharCode(65+e)}function v2(e,t){switch(t){case`title`:return e.title;case`description`:return e.description;case`tags`:return ffe(e.tags);case`playlist`:return e.playlists.join(`, `);default:return``}}var y2=4;function ope(e){return e===`schedules`?`schedules`:`weeks`}var b2=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`}),x2=new Intl.DateTimeFormat(void 0,{dateStyle:`full`}),S2=new Intl.DateTimeFormat(void 0,{timeStyle:`short`}),C2=`slopify.calendar.view`;function spe(){try{return window.localStorage.getItem(C2)===`list`?`list`:`weeks`}catch{return`weeks`}}function cpe({tab:e,schedule:t,onTab:n,onSchedule:r}={}){let{api:i}=z(),a=_(),o=wx(),[s]=(0,m.useState)(()=>eU(new Date,y2)),[c,l]=(0,m.useState)(spe),[u,d]=(0,m.useState)(e??`weeks`),f=n===void 0?u:e??`weeks`,p=e=>{n===void 0?d(e):n(e)},[g,v]=(0,m.useState)(!1),y=P(zH(i,s.from,s.to)),b=P(yH(i)),x=P(Fq(i)),S=P(rb(i)),[C,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(null),D=(0,m.useMemo)(()=>new Map((x.data??[]).map(e=>[e.id,e.channelId])),[x.data]),O=(0,m.useMemo)(()=>new Map((S.data?.projects??[]).map(e=>[e.id,e.channelId])),[S.data]),k=(b.data??[]).filter(e=>o.includes(D.get(e.templateId))),A=y.data===void 0?void 0:{...y.data,runs:y.data.runs.filter(e=>o.includes(D.get(e.templateId))),projects:y.data.projects.filter(e=>o.includes(O.get(e.id)))},j=(0,m.useMemo)(()=>A===void 0?new Map:$H(A),[A]),ee=A?.runs??[],te=JH(A?.projects??[]),M=F({mutationFn:e=>e(),onSuccess:e=>w(e.ok?{tone:`info`,text:`Moved.`}:{tone:`error`,text:e.message}),onError:e=>w({tone:`error`,text:`The topic wasn't moved: ${e.message} Reload the calendar and try again.`}),onSettled:async()=>{await Promise.all([a.invalidateQueries({queryKey:RH}),a.invalidateQueries({queryKey:vH})])}}),ne=e=>{if(e.kind!==`none`){if(e.kind===`refused`){w({tone:`error`,text:e.message});return}e.kind===`move`?M.mutate(()=>FH(i,e.scheduleId,{baseVersion:e.baseVersion,from:e.from,to:e.to})):M.mutate(()=>LH(i,e.scheduleId,{baseVersion:e.baseVersion,index:e.index,targetId:e.targetId,...e.position===void 0?{}:{position:e.position}}))}},N=(e,t)=>{let n=nU(ee,e,t);if(n===void 0){w({tone:`error`,text:t===-1?`${rU(e)} is already the next topic of ${e.scheduleName}.`:`${rU(e)} is the last topic on the calendar for ${e.scheduleName}.`});return}ne(tU(e,n,x2.format(new Date(n.at))))},re=e=>{l(e),f!==`weeks`&&p(`weeks`);try{window.localStorage.setItem(C2,e)}catch{}};Ox({id:`calendar.add`,title:`Add to calendar`,group:`Calendar`,keywords:[`topics`,`batch`,`queue`],run:()=>v(!0)}),Ox({id:`calendar.schedules`,title:`Show the schedules`,group:`Calendar`,keywords:[`edit`,`recurring`,`pause`,`resume`],run:()=>p(`schedules`)}),rS(Qx.addToCalendar,()=>v(!0)),Ox({id:`calendar.weeks`,title:`Show the calendar as weeks`,group:`Calendar`,run:()=>re(`weeks`)}),Ox({id:`calendar.list`,title:`Show the calendar as a list`,group:`Calendar`,run:()=>re(`list`)});let ie=k.reduce((e,t)=>e+(t.deletedAt===null?t.items.length:0),0),ae=C?.text??y.error?.message??b.error?.message,oe=XH(new Date),se=(b.data??[]).filter(e=>e.deletedAt===null).length;return(0,h.jsxs)(`div`,{"data-tour":`calendar`,children:[(0,h.jsx)(Sq,{title:`Calendar`,meta:`${o.channel?.name??`Every channel`} · ${String(ee.length)} scheduled ${ee.length===1?`run`:`runs`} in the next ${String(y2)} weeks · ${String(ie)} ${ie===1?`topic`:`topics`} queued`,actions:f===`schedules`?void 0:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Rb,{label:`Calendar view`,tip:`planning.calendar.view`,value:c,onChange:re,options:[{value:`weeks`,label:`Weeks`},{value:`list`,label:`List`}]}),(0,h.jsxs)(R,{variant:`primary`,onClick:()=>v(!0),children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,strokeWidth:1.75}),`Add to calendar`]})]})}),(0,h.jsx)(X1,{items:[{id:`weeks`,label:`Coming weeks`},{id:`schedules`,label:`Schedules`,...b.data===void 0?{}:{badge:String(se)}}],value:f,onChange:p,label:`Calendar sections`,idPrefix:`calendar`,className:`mb-6`}),(0,h.jsx)(Z1,{idPrefix:`calendar`,id:`schedules`,active:f===`schedules`,children:f===`schedules`?(0,h.jsx)(afe,{pickedId:t,onPick:r}):null}),(0,h.jsxs)(Z1,{idPrefix:`calendar`,id:`weeks`,active:f===`weeks`,children:[(0,h.jsx)(G1,{tone:C?.tone===`info`?`info`:ae?`error`:`info`,className:`mb-3`,children:ae}),(0,h.jsxs)(q1,{split:`aside`,className:`mb-6`,children:[(0,h.jsx)(J1,{label:`Needs you`,children:te.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Nothing needs you right now.`}):(0,h.jsxs)(`section`,{"aria-label":`Needs you`,children:[(0,h.jsx)(H,{title:`Needs you`,meta:qH(te)}),(0,h.jsx)(oU,{label:`Needs you`,children:te.map(e=>(0,h.jsx)(E2,{project:e},e.id))})]})}),(0,h.jsx)(J1,{as:`aside`,label:`Suggested topics`,children:(0,h.jsx)(Rde,{schedules:k})})]}),(0,h.jsxs)(`section`,{"aria-label":`Coming weeks`,className:`flex min-w-0 flex-col gap-4`,children:[y.isPending?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Loading the calendar…`}):c===`weeks`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Drag a topic to another day to change when it runs, or onto another schedule's run to move it there. With the keyboard: focus a topic and press Alt+← or Alt+→.`}),QH(new Date(s.from),y2).map(e=>(0,h.jsx)(`div`,{className:`sl-cal-week`,children:e.map(e=>{let t=XH(e),n=j.get(t);return(0,h.jsx)(lpe,{date:e,today:t===oe,day:n,dragging:T,busy:M.isPending,onDragStart:E,onDragEnd:()=>E(null),onDrop:t=>{T!==null&&(ne(tU(T,t,x2.format(e))),E(null))},onStep:N},t)})},XH(e[0]??new Date)))]}):(0,h.jsx)(dpe,{days:j,busy:M.isPending,onStep:N,schedules:k,onTransfer:(e,t)=>{e.index!==null&&ne({kind:`transfer`,scheduleId:e.scheduleId,baseVersion:e.scheduleVersion,index:e.index,targetId:t,position:void 0})}}),A!==void 0&&A.queued.length>0?(0,h.jsxs)(`section`,{"aria-label":`Batch queue`,children:[(0,h.jsx)(H,{title:`Batch queue`,meta:`${String(A.queued.length)} waiting to start`,info:`play.queue`}),(0,h.jsx)(oU,{label:`Batch queue`,children:A.queued.toSorted((e,t)=>e.position-t.position).map((e,t)=>{let n=A.projects.find(t=>t.id===e.projectId)?.state===`paused`;return(0,h.jsx)(sU,{title:(0,h.jsx)(ma,{to:`/projects/$projectId`,params:{projectId:e.projectId},children:e.title}),meta:`${String(t+1)} in line`,actions:(0,h.jsx)(TS,{tone:n?`waiting`:e.state===`active`?`running`:`off`,children:n?`Paused`:e.state===`active`?`Running now`:`Waiting its turn`})},e.projectId)})})]}):null]})]}),(0,h.jsx)(VH,{open:g,onOpenChange:v,schedules:k})]})}function lpe({date:e,today:t,day:n,dragging:r,busy:i,onDragStart:a,onDragEnd:o,onDrop:s,onStep:c}){let[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(!1),p=n?.runs??[],g=n?.projects??[],_=d?g:g.slice(0,w2),v=()=>p.find(e=>e.scheduleId===r?.scheduleId)??p[0];return(0,h.jsxs)(`section`,{"aria-label":x2.format(e),className:L(`sl-cal-day`,t&&`sl-cal-day--today`,l&&`sl-cal-day--over`),onDragOver:e=>{r!==null&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,u(!0))},onDragLeave:()=>u(!1),onDrop:e=>{e.preventDefault(),u(!1),s(v())},children:[(0,h.jsx)(`div`,{className:`sl-kicker`,children:t?`Today · ${b2.format(e)}`:b2.format(e)}),p.map(e=>(0,h.jsx)(upe,{run:e,busy:i,onDragStart:a,onDragEnd:o,onDrop:t=>{t.preventDefault(),t.stopPropagation(),u(!1),s(e)},onStep:c},`${e.scheduleId}-${e.at}`)),_.map(e=>{let t=KH(e);return(0,h.jsxs)(`div`,{className:`sl-cal-item sl-cal-item--project ${iU}`,children:[(0,h.jsx)(ma,{to:`/projects/$projectId`,params:{projectId:e.id},className:`text-small font-semibold ${aU}`,children:e.title}),(0,h.jsx)(TS,{tone:t.tone,children:t.word})]},e.id)}),g.length>w2?(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-expanded":d,className:`self-start`,onClick:()=>f(e=>!e),children:d?`Show fewer`:`+${String(g.length-w2)} more`}):null]})}var w2=3;function upe({run:e,busy:t,onDragStart:n,onDragEnd:r,onDrop:i,onStep:a}){let o=e.index!==null&&!t,s=rU(e);return(0,h.jsxs)(`article`,{tabIndex:e.index===null?void 0:0,"aria-label":`${s}, ${S2.format(new Date(e.at))}, ${e.scheduleName}${e.index===null?``:`. Alt+arrow keys move it.`}`,draggable:o,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,s),n(e)},onDragEnd:r,onDragOver:e=>e.preventDefault(),onDrop:i,onKeyDown:t=>{o&&t.altKey&&(t.key===`ArrowLeft`||t.key===`ArrowUp`?(t.preventDefault(),a(e,-1)):(t.key===`ArrowRight`||t.key===`ArrowDown`)&&(t.preventDefault(),a(e,1)))},className:L(`sl-cal-item`,o&&`sl-cal-item--movable`),children:[(0,h.jsx)(`span`,{className:`text-label text-ink-3 tabular-nums`,children:S2.format(new Date(e.at))}),(0,h.jsx)(`b`,{className:L(`text-small`,e.topic===null&&`font-normal text-ink-2`),children:s}),(0,h.jsx)(`span`,{className:`text-label text-ink-3`,children:e.scheduleName}),e.paused?(0,h.jsx)(TS,{tone:`waiting`,children:`Paused`}):e.topicSource===`held`?(0,h.jsx)(TS,{tone:`info`,children:`Needs a topic`}):e.prepared===null?(0,h.jsx)(TS,{tone:`off`,children:`Queued`}):(0,h.jsx)(TS,{tone:`info`,children:`Prepared`}),(0,h.jsx)(T2,{run:e,compact:!0})]})}function T2({run:e,compact:t=!1}){let{api:n}=z(),r=_(),[i,a]=(0,m.useState)(),o=F({mutationFn:async()=>{if(e.topic===null)throw Error(`This run has no topic to prepare yet.`);let t=await AH(n,e.scheduleId,e.topic);if(!t.ok)throw Error(t.message);return t.value},onSuccess:()=>{a(void 0),r.invalidateQueries({queryKey:RH}),r.invalidateQueries({queryKey:[`projects`]})},onError:e=>a(e.message)});return e.prepared===null?e.index===null||e.topic===null||e.topicSource!==`queued`?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R,{size:`small`,variant:t?`quiet`:`secondary`,disabled:o.isPending,onClick:e=>{e.stopPropagation(),o.mutate()},children:o.isPending?`Preparing…`:`Prepare`}),i===void 0?null:(0,h.jsx)(`span`,{role:`alert`,className:`text-label text-danger`,children:i})]}):(0,h.jsx)(bS,{to:`/projects/$projectId`,params:{projectId:e.prepared},size:`small`,variant:`quiet`,children:t?`Open`:`Open prepared`})}function E2({project:e}){let t=KH(e);return(0,h.jsx)(sU,{title:(0,h.jsx)(ma,{to:`/projects/$projectId`,params:{projectId:e.id},children:e.title}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(TS,{tone:t.tone,children:t.word}),t.action===void 0?null:t.action.kind===`upload`?(0,h.jsx)(d2,{projectId:e.id,ready:!0}):(0,h.jsx)(bS,{to:`/projects/$projectId`,params:{projectId:e.id},size:`small`,variant:`secondary`,children:t.action.label})]})})}function dpe({days:e,busy:t,schedules:n,onStep:r,onTransfer:i}){let a=[...e.values()].sort((e,t)=>e.key.localeCompare(t.key));if(a.length===0)return(0,h.jsxs)(`p`,{className:`m-0 text-ink-2`,children:[`Nothing is planned for the next `,y2,` weeks. Add topics with Add to calendar, or create a schedule on the`,` `,(0,h.jsx)(ma,{to:`/calendar`,search:{tab:`schedules`},children:`Schedules`}),` `,`tab.`]});let o=n.filter(e=>e.deletedAt===null&&(e.status===`active`||e.status===`paused`));return(0,h.jsxs)(`div`,{className:`flex flex-col gap-6`,...Ib,children:[(0,h.jsxs)(`p`,{className:`m-0 flex items-center gap-1 text-small text-ink-2`,children:[`Move a topic earlier, later or to another schedule from its row.`,(0,h.jsx)(V,{id:`planning.calendar.move`,className:`-my-1`})]}),a.map(e=>(0,h.jsxs)(`section`,{"aria-label":x2.format(e.date),children:[(0,h.jsx)(H,{title:x2.format(e.date),as:`h3`}),(0,h.jsxs)(oU,{label:`Planned on ${x2.format(e.date)}`,children:[e.runs.map(e=>{let n=rU(e),a=o.filter(t=>t.id!==e.scheduleId);return(0,h.jsx)(sU,{title:n,meta:`${S2.format(new Date(e.at))} · ${e.scheduleName}${e.templateName===null?``:` · ${e.templateName}`}${e.paused?` · Paused`:``}`,actions:e.index===null?void 0:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(T2,{run:e}),(0,h.jsx)(My,{size:`small`,label:`Move ${n} earlier`,disabled:t,onClick:()=>r(e,-1),children:(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(My,{size:`small`,label:`Move ${n} later`,disabled:t,onClick:()=>r(e,1),children:(0,h.jsx)(uc,{"aria-hidden":`true`,strokeWidth:1.75})}),a.length===0?null:(0,h.jsxs)(`select`,{"aria-label":`Move ${n} to another schedule`,className:`sl-select h-8 w-auto text-small`,value:``,disabled:t,onChange:t=>{t.target.value!==``&&i(e,t.target.value)},children:[(0,h.jsx)(`option`,{value:``,children:`Move to…`}),a.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})},`${e.scheduleId}-${e.at}`)}),e.projects.map(e=>(0,h.jsx)(E2,{project:e},e.id))]})]},e.key))]})}var fpe=Tj.map(e=>({value:e,label:Ej[e]}));function ppe({channel:e}){let{api:t}=z(),n=_(),r=Iy(),i=F({mutationFn:n=>_x(t,e.id,n),onSuccess:async e=>{r(`YouTube AI disclosure set to ${Ej[e.aiDisclosure]}.`,`success`),n.setQueryData(nx(e.id),t=>typeof t==`object`&&t&&`channel`in t?{...t,channel:{...t.channel,aiDisclosure:e.aiDisclosure}}:t),await n.invalidateQueries({queryKey:tx,exact:!0})}});return(0,h.jsxs)(`section`,{"aria-label":`YouTube AI disclosure`,className:`mb-6 max-w-3xl border-b border-line pb-5`,children:[(0,h.jsx)(dV,{label:`YouTube AI disclosure`,tip:`planning.channel.ai-disclosure`,help:`Mark voices in Settings → Voices and Image prompts in Library → Prompts.`,children:(0,h.jsx)(hV,{value:i.isPending?i.variables:e.aiDisclosure,options:fpe,disabled:i.isPending,onChange:e=>{let t=Tj.find(t=>t===e.currentTarget.value);t!==void 0&&i.mutate(t)},className:`max-w-[260px]`})}),(0,h.jsx)(G1,{tone:`error`,children:i.error?`Couldn't save the YouTube AI disclosure: ${i.error.message}`:void 0})]})}function D2({value:e,onChange:t,inherited:n,label:r=`Language`,error:i,disabled:a=!1,tip:o=`play.language`}){let s=e??n?.language;return(0,h.jsx)(dV,{label:r,tip:o,help:mpe(s),error:i,children:(0,h.jsxs)(hV,{"data-play-field":`language`,value:e??(n===void 0?`en`:``),disabled:a,onChange:e=>t(e.target.value===``?void 0:BO.parse(e.target.value)),children:[n===void 0?null:(0,h.jsxs)(`option`,{value:``,children:[n.label,` (`,VO(n.language).name,`)`]}),zO.map(e=>(0,h.jsx)(`option`,{value:e.code,children:e.native===e.name?e.name:`${e.native} · ${e.name}`},e.code))]})})}function mpe(e){let t=VO(e);if(t.code===`en`)return`Everything is written and timed in English.`;let n=`The article, narration, YouTube description and Shorts titles are written in ${t.name}; pick a voice that speaks it.`,r=HO(t.code);return r===void 0?`${n} Captions are timed word by word with a free 248 MB model, downloaded the first time a ${t.name} project makes captions.`:`${n} ${r}`}function hpe({rows:e,onChange:t}){let n=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e));return(0,h.jsxs)(`section`,{"aria-label":`Channel links`,...Ib,children:[(0,h.jsx)(H,{title:`Channel links`,meta:`Write a link's name in braces in a description, such as {{Patreon}}.`,info:`planning.links.named`}),e.length===0?(0,h.jsx)(`p`,{className:`m-0 border-y border-line py-4 text-ink-2`,children:`No channel links yet. Add one, then write its name in braces in a description.`}):(0,h.jsx)(`ul`,{"aria-label":`Channel links`,className:`sl-list m-0 list-none p-0`,children:e.map((r,i)=>(0,h.jsxs)(`li`,{className:`grid grid-cols-[minmax(0,1fr)] items-center gap-2 border-b border-line py-3 md:grid-cols-[220px_minmax(0,1fr)_auto]`,children:[(0,h.jsx)(pV,{"aria-label":`Name of link ${String(i+1)}`,placeholder:`Patreon`,value:r.name,onChange:e=>n(i,{name:e.currentTarget.value})}),(0,h.jsx)(pV,{"aria-label":`Address of link ${String(i+1)}`,type:`url`,placeholder:`https://`,value:r.url,onChange:e=>n(i,{url:e.currentTarget.value})}),(0,h.jsxs)(R,{variant:`quiet`,size:`small`,className:`justify-self-start`,"aria-label":`Remove link ${String(i+1)}`,onClick:()=>t(e.filter((e,t)=>t!==i)),children:[(0,h.jsx)(Yc,{"aria-hidden":`true`,className:`size-[14px]`}),`Remove`]})]},i))}),(0,h.jsx)(`div`,{className:`mt-3`,children:(0,h.jsxs)(R,{onClick:()=>t([...e,{name:``,url:``}]),children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,className:`size-[14px]`}),`Add link`]})})]})}function gpe(){return(0,h.jsxs)(`div`,{...Ib,children:[(0,h.jsx)(H,{title:`Named links`,info:`planning.links.named`}),(0,h.jsx)(`p`,{className:`m-0 max-w-[60ch] text-ink-2`,children:`Each channel keeps its own links now, on its Brand tab under Channel links. Links saved here before fill the default channel's descriptions until you save its Brand tab.`}),(0,h.jsx)(`div`,{className:`mt-3`,children:(0,h.jsx)(bS,{to:`/channels/$channelId`,params:{channelId:Qb},children:`Open the default channel's links`})})]})}function O2({value:e,inherit:t,sources:n,offerNone:r,problem:i,file:a,fieldPrefix:o=`ambientBed`,onChange:s}){let c=e!==void 0&&e.source!==`none`,l={level:e?.level??String(tA.levelDb),fadeIn:e?.fadeIn??String(tA.fadeInSeconds),tail:e?.tail??String(tA.tailSeconds)},u=e=>{if(e===``)s(void 0);else if(e===`none`)s({source:`none`,...l});else{let t=n.find(t=>t===e);t!==void 0&&s({source:t,...l})}},d=(t,n,r,a)=>e===void 0||!c?null:(0,h.jsx)(dV,{label:n,help:r,tip:a,error:i(t),children:(0,h.jsx)(pV,{"data-play-field":`${o}.${t}`,type:`text`,inputMode:`decimal`,className:`sl-input--number`,value:e[t],onChange:n=>s({...e,[t]:n.target.value})})});return(0,h.jsxs)(`div`,{className:`sl-fields`,children:[(0,h.jsx)(dV,{label:`Ambient sound`,tip:`project.ambient.source`,error:i(`source`),children:(0,h.jsxs)(hV,{"data-play-field":`${o}.source`,value:e?.source??``,onChange:e=>u(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:t}),r?(0,h.jsx)(`option`,{value:`none`,children:`None`}):null,n.map(e=>(0,h.jsx)(`option`,{value:e,children:eA[e]},e))]})}),e?.source===`upload`?a:null,c?(0,h.jsxs)(`div`,{className:`contents`,children:[d(`level`,`Level (dB)`,`-40 to -6; 0 is about as loud as the voice.`,`project.ambient.level`),d(`fadeIn`,`Fade in (seconds)`,`0 to 30.`,`project.ambient.fade-in`),d(`tail`,`Tail after the narration (seconds)`,`0 to 30, fading out.`,`project.ambient.tail`)]}):null]})}function _pe({value:e,onChange:t}){let n=oA(e),r=n===void 0?[]:rA(n);return(0,h.jsx)(O2,{value:e,inherit:`Not set`,sources:Qk,offerNone:!1,fieldPrefix:`brand.ambientBed`,problem:e=>r.find(t=>t.field===e)?.message,onChange:t})}function vpe(e){return e.ambientBed===void 0?void 0:aA(e.ambientBed)}function ype(e){let t=oA(e);return t===void 0||t.source===`upload`?{brand:{},blocked:!1}:{brand:{ambientBed:{...t,source:t.source}},blocked:rA(t).length>0}}var k2=[`captionFontId`,`captionColor`,`captionOutlineColor`,`titleFontId`,`titleColor`,`intro`,`outro`,`endScreenText`,`documentTheme`,`language`];function bpe(e){return Object.fromEntries(k2.map(t=>[t,e[t]??``]))}function xpe({channel:e}){let{api:t}=z(),n=_(),r=Iy(),i=P({queryKey:cN,queryFn:()=>lN(t)}),a=P(db(t)),o=P(fb(t)),[s,c]=(0,m.useState)(e.name),[l,u]=(0,m.useState)(e.seriesBrief),[d,f]=(0,m.useState)(bpe(e.brand)),[p,g]=(0,m.useState)(vpe(e.brand)),v=ype(p),y=P({queryKey:B.channelLinks,queryFn:()=>Ns(t),enabled:e.isDefault&&e.brand.links===void 0}),[b,x]=(0,m.useState)(),S=b??e.brand.links??y.data??[],C=b!==void 0||e.brand.links!==void 0||(y.data?.length??0)>0,w=F({mutationFn:()=>cx(t,e.id,{name:s,seriesBrief:l,brand:{...Object.fromEntries(k2.flatMap(e=>d[e].trim()===``?[]:[[e,d[e].trim()]])),...v.brand,...C?{links:S}:{}},baseVersion:e.version}),onSuccess:async e=>{r(`Channel saved.`,`success`),n.setQueryData(nx(e.id),t=>typeof t==`object`&&t?{...t,channel:e}:t),await Promise.all([n.invalidateQueries({queryKey:tx}),n.invalidateQueries({queryKey:B.channelLinks})])}}),T=e=>t=>f({...d,[e]:t}),E=(i.data?.fonts??[]).map(e=>({value:e.id,label:e.name})),D=e=>(a.data?.entries??[]).filter(t=>t.category===e).map(e=>({value:e.name,label:e.name})),O=[...(o.data?.builtIns??[]).map(e=>({value:e.name,label:e.label})),...(o.data?.themes??[]).map(e=>({value:e.id,label:e.name}))];return(0,h.jsxs)(`form`,{"aria-label":`Brand kit`,onSubmit:e=>{e.preventDefault(),w.mutate()},children:[(0,h.jsxs)(`div`,{className:`grid max-w-3xl grid-cols-1 gap-5`,children:[(0,h.jsx)(dV,{label:`Channel name`,tip:`planning.channel.name`,children:(0,h.jsx)(pV,{value:s,maxLength:200,required:!0,onChange:e=>c(e.target.value)})}),(0,h.jsx)(dV,{label:`Series brief`,tip:`planning.channel.brief`,help:`Topic generation reads it for this channel's schedules.`,children:(0,h.jsx)(mV,{rows:4,value:l,maxLength:1e4,onChange:e=>u(e.target.value)})}),(0,h.jsx)(H,{title:`Brand kit`,meta:`Fills what a template leaves at its default. Blank fields add nothing.`,info:`planning.channel.brand-kit`,className:`mt-2 border-t border-line pt-6`}),(0,h.jsx)(`section`,{"aria-label":`Language`,className:`max-w-md`,children:(0,h.jsx)(D2,{label:`Language of new projects`,tip:`planning.channel.language`,value:d.language===``?void 0:d.language,inherited:{label:`Not set`,language:void 0},onChange:e=>T(`language`)(e??``)})}),(0,h.jsxs)(`section`,{"aria-label":`Captions`,className:`grid grid-cols-1 gap-4 min-[700px]:grid-cols-3`,children:[(0,h.jsx)(A2,{label:`Caption font`,tip:`planning.channel.brand.caption-font`,value:d.captionFontId,options:E,onPick:T(`captionFontId`)}),(0,h.jsx)(j2,{label:`Caption colour`,tip:`planning.channel.brand.caption-colour`,value:d.captionColor,onChange:T(`captionColor`)}),(0,h.jsx)(j2,{label:`Caption outline`,tip:`planning.channel.brand.caption-outline`,value:d.captionOutlineColor,onChange:T(`captionOutlineColor`)})]}),(0,h.jsxs)(`section`,{"aria-label":`Chapter cards and end screen`,className:`grid grid-cols-1 gap-4 min-[700px]:grid-cols-3`,children:[(0,h.jsx)(A2,{label:`Title font`,tip:`planning.channel.brand.font`,value:d.titleFontId,options:E,onPick:T(`titleFontId`)}),(0,h.jsx)(j2,{label:`Title colour`,tip:`planning.channel.brand.title-colour`,value:d.titleColor,onChange:T(`titleColor`)}),(0,h.jsx)(dV,{label:`End screen text`,tip:`planning.channel.brand.end-screen`,help:`Shown over the last 5 seconds.`,children:(0,h.jsx)(pV,{value:d.endScreenText,maxLength:200,placeholder:`Subscribe for more`,onChange:e=>T(`endScreenText`)(e.target.value)})})]}),(0,h.jsxs)(`section`,{"aria-label":`Intro, outro and document`,className:`grid grid-cols-1 gap-4 min-[700px]:grid-cols-3`,children:[(0,h.jsx)(A2,{label:`Intro`,tip:`planning.channel.brand.intro`,value:d.intro,options:D(`intro`),onPick:T(`intro`)}),(0,h.jsx)(A2,{label:`Outro`,tip:`planning.channel.brand.outro`,value:d.outro,options:D(`outro`),onPick:T(`outro`)}),(0,h.jsx)(A2,{label:`Document theme`,tip:`planning.channel.brand.document-theme`,value:d.documentTheme,options:O,onPick:T(`documentTheme`)})]}),(0,h.jsx)(_pe,{value:p,onChange:g}),(0,h.jsx)(`div`,{className:`border-t border-line pt-6`,children:(0,h.jsx)(hpe,{rows:S,onChange:x})})]}),(0,h.jsx)(K1,{status:(0,h.jsx)(G1,{tone:w.error?`error`:`info`,children:w.error?.message??(w.isPending?`Saving…`:void 0)}),children:(0,h.jsx)(R,{type:`submit`,variant:`primary`,disabled:w.isPending||s.trim()===``||v.blocked,disabledReason:s.trim()===``?`Give the channel a name`:`Fix the ambient sound settings above`,children:`Save channel`})})]})}function A2({label:e,tip:t,value:n,options:r,onPick:i}){return(0,h.jsx)(dV,{label:e,tip:t,children:(0,h.jsxs)(hV,{value:n,onChange:e=>i(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`Not set`}),n!==``&&!r.some(e=>e.value===n)?(0,h.jsxs)(`option`,{value:n,children:[n,` (no longer in the library)`]}):null,r.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})}function j2({label:e,tip:t,value:n,onChange:r}){let i=/^#[0-9a-fA-F]{6}$/.test(n);return(0,h.jsx)(dV,{label:e,tip:t,...n!==``&&!i?{error:`Write the colour as # and six hex digits.`}:{},children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`size-6 shrink-0 rounded-control border border-line-strong`,style:{background:i?n:`transparent`}}),(0,h.jsx)(pV,{value:n,placeholder:`#FFFFFF`,maxLength:7,onChange:e=>r(e.target.value)})]})})}function M2(e,t){return e.languages===void 0||e.languages.includes(VO(t).code)}function Spe(e,t,n,r){return n?e:e.filter(e=>M2(e,t)||e.voiceId===r)}function Cpe(e,t){if(e===void 0||M2(e,t))return;let n=VO(t).name,r=(e.languages??[]).map(e=>VO(e).code===e?VO(e).name:e);return`${e.name} is listed for ${r.join(`, `)}, not ${n}, so it may read the ${n} narration with the wrong accent. Pick a ${n} voice under Narration, or correct the voice's languages in Settings → Voices.`}function N2(e,t,n){let[r,i]=(0,m.useState)(!1),a=Spe(e,t,r,n);return{listed:a,hidden:e.length-a.length,showAll:r,setShowAll:i}}function P2({language:e,voice:t,hidden:n,showAll:r,onShowAll:i}){let a=(0,m.useId)(),o=Cpe(t,e);return n===0&&!r&&o===void 0?null:(0,h.jsxs)(`div`,{className:`col-span-full grid gap-1`,children:[n>0||r?(0,h.jsxs)(`span`,{className:`flex min-h-8 items-center gap-1`,...Ib,children:[(0,h.jsxs)(`label`,{htmlFor:a,className:`flex items-center gap-2 text-small`,children:[(0,h.jsx)(`input`,{id:a,type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),`Show all voices`,r?``:` (${String(n)} listed for other languages than ${VO(e).name})`]}),(0,h.jsx)(V,{id:`play.show-all-voices`})]}):null,o===void 0?null:(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:o})]})}function wpe({channelId:e,member:t,open:n,onClose:r,onCreated:i}){let{api:a}=z(),o=_(),[s,c]=(0,m.useState)(t?.kind??`character`),[l,u]=(0,m.useState)(t?.name??``),[d,f]=(0,m.useState)(t?.aliases??[]),[p,g]=(0,m.useState)(``),[v,y]=(0,m.useState)(t?.description??``),[b,x]=(0,m.useState)(t?.voice),[S,C]=(0,m.useState)(t?.host===!0),w=()=>Promise.all([o.invalidateQueries({queryKey:nx(e)}),o.invalidateQueries({queryKey:tx})]),T=F({mutationFn:async()=>{let n={kind:s,name:l.trim(),aliases:d,description:v,voice:b!==void 0&&b.provider!==``&&b.model!==``&&b.voice!==``?b:null,host:S};return t===void 0?ux(a,e,crypto.randomUUID(),n):dx(a,t.id,{...n,baseVersion:t.version})},onSuccess:async e=>{await w(),t===void 0&&i(e.id)}}),E=()=>{let e=p.trim();e===``||d.some(t=>t.toLowerCase()===e.toLowerCase())||(f([...d,e]),g(``))};return n?(0,h.jsxs)(`section`,{"aria-label":t===void 0?`Add to cast`:`Edit ${t.name}`,children:[(0,h.jsx)(H,{kicker:t===void 0?`New cast member`:ex[t.kind],title:t===void 0?`Add to cast`:t.name,meta:t===void 0?`Name it first, then give it reference pictures.`:`Used whenever a title or an image brief names it or one of its aliases.`,children:(0,h.jsx)(R,{variant:`quiet`,size:`small`,onClick:r,children:`Close`})}),t!==void 0&&!t.images.some(e=>e.state===`ready`)?(0,h.jsx)(`p`,{className:`m-0 mt-2 text-small text-waiting`,children:`No picture yet, so it is not sent with any image. Upload or generate one below.`}):null,(0,h.jsxs)(`form`,{id:`cast-member-form`,"aria-label":`Cast member`,className:`mt-4 flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),l.trim()!==``&&T.mutate()},children:[(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 min-[600px]:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,h.jsx)(dV,{label:`Kind`,tip:`planning.cast.kind`,children:(0,h.jsx)(hV,{value:s,onChange:e=>c($b.find(t=>t===e.target.value)??`character`),options:$b.map(e=>({value:e,label:ex[e]}))})}),(0,h.jsx)(dV,{label:`Name`,tip:`planning.cast.name`,children:(0,h.jsx)(pV,{value:l,maxLength:200,required:!0,onChange:e=>u(e.target.value)})})]}),(0,h.jsx)(dV,{label:`Aliases`,tip:`planning.cast.aliases`,help:`Press Enter to add each one.`,children:(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(pV,{value:p,maxLength:200,placeholder:`Another name, such as the Last Pharaoh`,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),E())}}),(0,h.jsxs)(R,{onClick:E,disabled:p.trim()===``,children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Add alias`]})]})}),d.length>0?(0,h.jsx)(`ul`,{"aria-label":`Aliases added`,className:`m-0 flex list-none flex-wrap gap-2 p-0`,children:d.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsx)(DS,{removeLabel:`Remove alias ${e}`,onRemove:()=>f(d.filter(t=>t!==e)),children:e})},e))}):null,(0,h.jsx)(dV,{label:`Description for the image model`,tip:`planning.cast.description`,children:(0,h.jsx)(mV,{rows:3,value:v,maxLength:2e3,placeholder:`What they look like, in a sentence.`,onChange:e=>y(e.target.value)})}),(0,h.jsx)(Epe,{channelId:e,value:b,onChange:x}),(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,h.jsx)(Lb,{label:`One of the channel's hosts`,tip:`planning.cast.host`,checked:S,onChange:C}),S&&(b===void 0||b.voice===``)?(0,h.jsx)(`p`,{className:`m-0 text-small text-waiting`,children:`A host joins new podcasts and interviews only with a voice. Pick one under Voice above.`}):null]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(G1,{tone:T.error?`error`:`info`,children:T.error?.message??(T.isPending?`Saving…`:T.isSuccess?`Saved.`:void 0)}),(0,h.jsx)(R,{type:`submit`,form:`cast-member-form`,variant:t===void 0?`primary`:`secondary`,disabled:T.isPending||l.trim()===``,children:t===void 0?`Add to cast`:`Save`})]})]}),t===void 0?null:(0,h.jsx)(Tpe,{channelId:e,member:t})]}):null}function Tpe({channelId:e,member:t}){let{api:n}=z(),r=_(),i=P(cb(n)),a=(0,m.useRef)(null),o=(0,m.useRef)(null),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(`${t.name}${t.description.trim()?`, ${t.description.trim()}`:``}. A clear reference picture on a plain background, the whole ${t.kind===`place`?`place`:t.kind===`object`?`object`:`figure`} in view.`),p=()=>Promise.all([r.invalidateQueries({queryKey:nx(e)}),r.invalidateQueries({queryKey:tx})]),g=F({mutationFn:e=>px(n,t.id,e),onSettled:p}),v=F({mutationFn:()=>mx(n,t.id,{prompt:d,provider:s,model:l}),onSettled:p}),y=F({mutationFn:e=>hx(n,t.id,e),onSettled:p}),b=g.error??v.error??y.error,x=t.images.flatMap((e,t)=>e.state===`ready`&&e.sha256!==null?[{id:e.id,number:t+1,src:vx(n,e.sha256)}]:[]),[S,C]=(0,m.useState)(null);return(0,h.jsxs)(`section`,{"aria-label":`Reference pictures`,className:`mt-6`,children:[(0,h.jsx)(Tq,{className:`mb-6`}),(0,h.jsx)(H,{as:`h3`,title:`Reference pictures`,meta:`Sent with every image whose brief, or the video's title, names ${t.name}.`,info:`planning.cast.pictures`}),t.images.length>0?(0,h.jsx)(N0,{list:!0,density:`compact`,label:`Pictures of ${t.name}`,className:`mt-3`,children:t.images.map((e,r)=>(0,h.jsxs)(`li`,{className:`min-w-0`,children:[(0,h.jsx)(M0,{aspect:`square`,alt:`${t.name}, reference ${String(r+1)}`,...e.state===`ready`&&e.sha256!==null?{src:vx(n,e.sha256)}:{},...e.state===`generating`?{generating:`Making the picture…`}:{},onOpen:()=>C(x.findIndex(t=>t.id===e.id)),openLabel:`Open picture ${String(r+1)} of ${t.name} full size`,...e.state===`failed`?{badge:(0,h.jsx)(ES,{tone:`failed`,children:`Failed`})}:{},actionsShown:!0,actions:(0,h.jsx)(R,{variant:`secondary`,size:`small`,"aria-label":`Delete picture ${String(r+1)} of ${t.name}`,disabled:y.isPending||e.state===`generating`,disabledReason:`Wait until the picture is made`,onClick:()=>y.mutate(e.id),children:`Delete`})}),e.state===`failed`&&e.error?(0,h.jsx)(Dpe,{error:e.error,retry:s===``||l===``||d.trim()===``?void 0:{run:()=>v.mutate(),busy:v.isPending},onReword:()=>o.current?.focus()}):null]},e.id))}):(0,h.jsx)(`p`,{className:`m-0 mt-3 text-small text-ink-3`,children:`No pictures yet.`}),(0,h.jsx)(P0,{items:x.map(e=>({src:e.src,alt:`${t.name}, reference ${String(e.number)}`})),index:S,onIndex:C,onClose:()=>C(null),actions:(e,n)=>{let r=x[n];return r===void 0?null:(0,h.jsx)(SS,{href:r.src,download:!0,size:`small`,"aria-label":`Download picture ${String(r.number)} of ${t.name}`,children:`Download`})}}),(0,h.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`input`,{ref:a,type:`file`,accept:`image/png,image/jpeg`,className:`sr-only`,tabIndex:-1,"aria-hidden":`true`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&g.mutate(t)}}),(0,h.jsx)(R,{disabled:g.isPending,onClick:()=>a.current?.click(),children:`Upload a picture`}),(0,h.jsx)(`span`,{className:`text-small text-ink-3`,children:`PNG or JPEG, up to 10 MB.`})]}),(0,h.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,...Ib,children:[(0,h.jsxs)(`p`,{className:`sl-kicker m-0 flex items-center gap-1`,children:[`Make a picture`,(0,h.jsx)(V,{id:`planning.cast.generate`,className:`-my-1`})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 min-[600px]:grid-cols-2`,children:[(0,h.jsx)(OV,{label:`Image provider`,family:`image`,providers:i.data?.providers??[],value:s,problem:void 0,onPick:e=>{c(e),u(``)}}),(0,h.jsx)(kV,{label:`Image model`,provider:s,value:l,problem:void 0,onPick:u})]})]}),(0,h.jsx)(dV,{label:`Picture to make`,tip:`planning.cast.picture-prompt`,children:(0,h.jsx)(mV,{ref:o,rows:3,value:d,maxLength:4e3,onChange:e=>f(e.target.value)})}),(0,h.jsx)(`div`,{children:(0,h.jsx)(R,{disabled:v.isPending||s===``||l===``||d.trim()===``,disabledReason:`Pick an image provider and model, and describe the picture`,onClick:()=>v.mutate(),children:`Generate a picture`})})]}),(0,h.jsx)(G1,{tone:b?`error`:`info`,className:`mt-2`,children:b?.message??(g.isPending?`Uploading…`:v.isSuccess?`The picture is being made; it appears here when it is ready.`:void 0)})]})}function Epe({channelId:e,value:t,onChange:n}){let{api:r}=z(),i=P(cb(r)),a=P(lb(r)),o=P(ox(r,e)).data?.channel.brand.language??`en`,s=t??{provider:``,model:``,voice:``},c=(a.data?.voices??[]).filter(e=>e.provider===s.provider),l=N2(c,o,s.voice||void 0),u=l.listed;return(0,h.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-3 border-0 border-t border-line p-0 pt-4`,...Ib,children:[(0,h.jsxs)(`legend`,{className:`sl-kicker flex items-center gap-1`,children:[`Voice`,(0,h.jsx)(V,{id:`planning.cast.voice`,label:`Cast voice`,className:`-my-1`})]}),(0,h.jsx)(`p`,{className:`text-small text-ink-2`,children:`For multi-voice runs: pick this member under Speakers on Play.`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 min-[600px]:grid-cols-2`,children:[(0,h.jsx)(OV,{label:`Voice provider`,family:`tts`,providers:i.data?.providers??[],value:s.provider,problem:void 0,onPick:e=>n(e===``?void 0:{provider:e,model:``,voice:``})}),(0,h.jsx)(kV,{label:`Voice model`,provider:s.provider,value:s.model,problem:void 0,onPick:e=>n({...s,model:e})}),(0,h.jsx)(TV,{label:`Voice`,value:s.voice,placeholder:u.length===0?`No voices. Add one in Settings.`:`Pick a voice`,options:u.map(e=>({value:e.voiceId,label:e.name})),problem:void 0,onPick:e=>n({...s,voice:e})}),(0,h.jsx)(P2,{language:o,voice:c.find(e=>e.voiceId===s.voice),hidden:l.hidden,showAll:l.showAll,onShowAll:l.setShowAll}),(0,h.jsx)(TV,{label:`Pace`,value:String(s.pace??1),placeholder:`Pick a pace`,options:jA.map(e=>({value:String(e),label:e===1?`Normal`:`${String(e)}×`})),problem:void 0,onPick:e=>{let{pace:t,...r}=s;n(Number(e)===1?r:{...r,pace:Number(e)})}})]}),t===void 0?null:(0,h.jsx)(R,{variant:`quiet`,onClick:()=>n(void 0),children:`Remove the voice`})]})}function Dpe({error:e,retry:t,onReword:n}){let r=P1({stage:`images`,reason:e});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`m-0 mt-1 text-small text-danger`,children:e}),r===void 0?null:(0,h.jsx)(Py,{className:`mt-2`,children:(0,h.jsx)(H1,{fix:r,retry:t,variant:`secondary`,size:`small`,edit:r.kind===`refused`?(0,h.jsx)(R,{variant:`secondary`,size:`small`,onClick:n,children:`Reword the picture`}):void 0})})]})}function Ope({channelId:e,cast:t,selected:n,onSelect:r}){let{api:i}=z(),a=_(),[o,s]=(0,m.useState)(null),c=n===void 0?o:n,l=r??s,[u,d]=(0,m.useState)(null),f=F({mutationFn:e=>fx(i,e),onSuccess:async(t,n)=>{d(null),c===n&&l(null),await Promise.all([a.invalidateQueries({queryKey:nx(e)}),a.invalidateQueries({queryKey:tx})])}}),p=t.find(e=>e.id===c),g=t.flatMap(e=>{let t=e.images.find(e=>e.state===`ready`)?.sha256;return t?[{member:e,src:vx(i,t)}]:[]}),v=g.map(e=>({src:e.src,alt:e.member.name,caption:`${ex[e.member.kind]} · ${e.member.description||`No description yet`}`})),[y,b]=(0,m.useState)(null),x=c===`new`||p!==void 0;return(0,h.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-8 min-[1024px]:grid-cols-[minmax(0,1fr)_440px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`p`,{className:`m-0 mb-4 max-w-[68ch] text-small text-ink-2`,children:`When a video's title or an image's brief names a member, its pictures go with that image as references, so it looks the same in every video.`}),t.length===0?(0,h.jsx)(Q1,{title:`No cast yet`,actions:(0,h.jsx)(R,{variant:`secondary`,onClick:()=>l(`new`),children:`Add to cast`}),children:`Add the characters, creatures, places and objects this channel keeps coming back to.`}):(0,h.jsx)(N0,{label:`Cast`,children:t.map(e=>{let t=e.images.filter(e=>e.state===`ready`),n=t[0]?.sha256;return(0,h.jsx)(M0,{className:L(e.id===c&&`rounded-media outline-2 outline-accent outline-offset-4 outline-solid`),...n?{src:vx(i,n)}:{},alt:e.name,onOpen:()=>b(g.findIndex(t=>t.member.id===e.id)),openLabel:`Open ${e.name}'s picture full size`,title:e.name,meta:`${ex[e.kind]}${e.host===!0?` · Host`:``} · ${String(t.length)} ${t.length===1?`picture`:`pictures`}`,...t.length===0?{badge:(0,h.jsx)(ES,{tone:`waiting`,children:`No picture`})}:{},actionsShown:!0,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R,{variant:`secondary`,size:`small`,"aria-label":`Edit ${e.name}`,"aria-pressed":e.id===c,onClick:()=>l(e.id),children:`Edit`}),(0,h.jsx)(R,{variant:`secondary`,size:`small`,"aria-label":`Delete ${e.name}`,onClick:()=>{f.reset(),d(e)},children:`Delete`})]})},e.id)})}),(0,h.jsx)(P0,{items:v,index:y,onIndex:b,onClose:()=>b(null),actions:(e,t)=>{let n=g[t];return n===void 0?null:(0,h.jsx)(R,{size:`small`,onClick:()=>{b(null),l(n.member.id)},children:`Edit ${n.member.name}`})}}),(0,h.jsx)(G1,{tone:`error`,className:`mt-2`,children:u?void 0:f.error?.message})]}),(0,h.jsx)(`aside`,{"aria-label":`Cast member editor`,className:`min-w-0`,children:x?(0,h.jsx)(wpe,{channelId:e,member:p,open:!0,onClose:()=>l(null),onCreated:e=>l(e)},c??`closed`):t.length===0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Pick a member's Edit to change its names, description and pictures here.`})}),(0,h.jsx)(zy,{open:u!==null,title:`Delete ${u?.name??`this cast member`}?`,consequence:f.error?.message??`New videos stop using its pictures. Videos already made keep the pictures they were started with.`,confirmLabel:`Delete from cast`,cancelLabel:`Keep it`,pending:f.isPending,onConfirm:()=>{u&&f.mutate(u.id)},onCancel:()=>d(null)})]})}var F2=e=>[`channels`,e,`episodes`],I2=e=>[`channels`,e,`videos`],L2=(e,t)=>`${e.origin}/api/channels/${t}`,R2=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)});function kpe(e,t){return st({queryKey:F2(t),queryFn:async()=>I(await e.fetch(`${L2(e,t)}/episodes`))})}async function Ape(e,t,n){return I(await e.fetch(`${L2(e,t)}/episodes/setting`,R2(`PUT`,{enabled:n})))}async function jpe(e,t,n,r){return I(await e.fetch(`${L2(e,t)}/episodes/${encodeURIComponent(n)}`,R2(`PUT`,{summary:r})))}async function Mpe(e,t,n){let r=await e.fetch(`${L2(e,t)}/episodes/${encodeURIComponent(n)}`,{method:`DELETE`});r.ok||await I(r)}function z2(e,t){return st({queryKey:I2(t),queryFn:async()=>(await I(await e.fetch(`${L2(e,t)}/videos`))).videos})}async function Npe(e,t,n){return I(await e.fetch(`${L2(e,t)}/videos`,R2(`POST`,n)))}async function Ppe(e,t,n){return I(await e.fetch(`${L2(e,t)}/videos/preview`,R2(`POST`,{format:`csv`,text:n})))}async function Fpe(e,t,n){let r=await e.fetch(`${L2(e,t)}/videos/${n}`,{method:`DELETE`});r.ok||await I(r)}async function Ipe(e,t){await I(await e.fetch(`${L2(e,t)}/videos`,{method:`DELETE`}))}var Lpe=e=>e.length>160?`${e.slice(0,160)}…`:e;function Rpe({channelId:e}){let{api:t}=z(),n=_(),r=P(kpe(t,e)),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(null),c=()=>n.invalidateQueries({queryKey:F2(e)}),l=F({mutationFn:n=>Ape(t,e,n),onSuccess:t=>n.setQueryData(F2(e),t)}),u=F({mutationFn:n=>Mpe(t,e,n),onSuccess:async()=>{s(null),await c()}}),d=r.data?.enabled??!1,f=r.data?.memories??[];return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Lb,{checked:d,disabled:r.data===void 0||l.isPending,onChange:e=>l.mutate(e),label:`Episode memory`,tip:`planning.channel.episode-memory`,describedBy:`${e}-memory-help`}),(0,h.jsx)(`p`,{id:`${e}-memory-help`,className:`mt-1 mb-3 text-small text-ink-2`,children:`Finished episodes leave a short summary that new related episodes are written with.`}),(0,h.jsx)(G1,{tone:r.error||l.error||u.error?`error`:`info`,children:r.error?.message??l.error?.message??(o?void 0:u.error?.message)??(r.isPending?`Loading the episodes…`:void 0)}),r.data&&f.length===0?(0,h.jsx)(Q1,{title:`No episodes remembered yet`,children:d?`When a video on this channel finishes, its summary appears here.`:`Turn on episode memory, and the next finished video's summary appears here.`}):null,f.length>0?(0,h.jsx)(oU,{label:`Episode summaries`,children:f.map(e=>(0,h.jsx)(sU,{title:e.title,meta:(0,h.jsxs)(h.Fragment,{children:[e.source===`edited`?`Edited · `:``,e.cast.length>0?`${e.cast.join(`, `)} · `:``,Lpe(e.summary)]}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R,{size:`small`,"aria-label":`Open the summary of ${e.title}`,onClick:()=>a(e),children:`Open`}),(0,h.jsx)(R,{size:`small`,variant:`quiet`,"aria-label":`Delete the summary of ${e.title}`,onClick:()=>{u.reset(),s(e)},children:`Delete`})]})},e.id))}):null,i?(0,h.jsx)(zpe,{channelId:e,memory:i,onClose:()=>a(null)},i.id):null,(0,h.jsx)(zy,{open:o!==null,title:`Delete the summary of ${o?.title??`this episode`}?`,consequence:u.error?.message??`New episodes stop being reminded of it. The video itself is not changed.`,confirmLabel:`Delete summary`,pending:u.isPending,onConfirm:()=>{o&&u.mutate(o.id)},onCancel:()=>s(null)})]})}function zpe({channelId:e,memory:t,onClose:n}){let{api:r}=z(),i=_(),[a,o]=(0,m.useState)(t.summary),s=F({mutationFn:()=>jpe(r,e,t.id,a),onSuccess:async()=>{await i.invalidateQueries({queryKey:F2(e)}),n()}}),c=a.trim()!==t.summary.trim();return(0,h.jsx)(Ry,{open:!0,onOpenChange:e=>{e||n()},title:t.title,description:t.source===`edited`?`You edited this summary; finishing the video again keeps your text.`:`Written by the text model when the video finished. An edit here is kept.`,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R,{onClick:n,children:`Close`}),(0,h.jsx)(R,{variant:`primary`,disabled:!c||s.isPending,onClick:()=>s.mutate(),children:`Save summary`})]}),children:(0,h.jsx)(dV,{label:`Summary`,error:s.error?.message,tip:`planning.channel.episode-summary`,children:(0,h.jsx)(mV,{rows:8,value:a,onChange:e=>o(e.target.value)})})})}var B2=(e,t,n)=>`${e.toLocaleString(`en`)} ${e===1?t:n}`;function V2(e,t){let n=t.trim().toLowerCase();return e.map(e=>n===``||e.toLowerCase().includes(n))}function Bpe({channelId:e}){let{api:t}=z(),n=_(),r=P(z2(t,e)),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(void 0),u=(0,m.useRef)(null),d=()=>n.invalidateQueries({queryKey:I2(e)}),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(``),y=F({mutationFn:n=>Npe(t,e,{format:`lines`,...n}),onSuccess:async(e,t)=>{t.filter===void 0?a(``):p(void 0),l(`Added ${B2(e.added,`title`,`titles`)}${e.skipped>0?`; skipped ${e.skipped.toLocaleString(`en`)} already listed`:``}.`),await d()}}),b=F({mutationFn:n=>Ppe(t,e,n),onSuccess:e=>{v(e.filter),p({titles:e.titles,ticked:V2(e.titles,e.filter)})}}),x=F({mutationFn:n=>Fpe(t,e,n),onSuccess:d}),S=F({mutationFn:()=>Ipe(t,e),onSuccess:async()=>{s(!1),await d()}}),C=r.data??[],w=y.isPending||b.isPending||x.isPending||S.isPending,T=r.error??b.error??y.error??x.error;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{className:`mb-3 text-small text-ink-2`,children:`Topic suggestions and duplicate checks skip these titles, as they skip the videos made here.`}),(0,h.jsx)(dV,{label:`Paste titles`,tip:`planning.channel.videos-paste`,help:`One title per line.`,children:(0,h.jsx)(mV,{rows:5,value:i,onChange:e=>a(e.target.value)})}),(0,h.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(R,{variant:`primary`,disabled:w||i.trim()===``,onClick:()=>{l(void 0),y.mutate({text:i})},children:`Add titles`}),(0,h.jsx)(R,{disabled:w,onClick:()=>{u.current?.click()},children:`Import a YouTube Studio CSV…`}),(0,h.jsx)(V,{id:`planning.channel.videos-csv`}),(0,h.jsx)(`input`,{ref:u,type:`file`,accept:`.csv,text/csv`,className:`hidden`,"aria-label":`YouTube Studio CSV file`,onChange:async e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&(l(void 0),y.reset(),b.mutate(await t.text()))}}),(0,h.jsx)(R,{variant:`quiet`,disabled:w||C.length===0,onClick:()=>{S.reset(),s(!0)},children:`Remove all`})]}),(0,h.jsx)(G1,{tone:T?`error`:c?`success`:`info`,className:`mt-1`,children:T?.message??c??(r.isPending?`Loading the titles…`:b.isPending?`Reading the CSV…`:void 0)}),f===void 0?null:(0,h.jsx)(Vpe,{preview:f,filter:g,busy:w,onFilter:e=>{v(e),p({...f,ticked:V2(f.titles,e)})},onTick:e=>p({...f,ticked:e}),onSave:()=>{l(void 0);let e=f.titles.filter((e,t)=>f.ticked[t]);y.mutate({text:e.join(`
|
|
273
|
-
`),filter:g})},onCancel:()=>{y.reset(),p(void 0)}}),r.data&&C.length===0?(0,h.jsx)(Q1,{title:`No existing videos listed`,children:`In YouTube Studio open Analytics → Content → Advanced mode, export the table as a CSV, and import it here; or paste the titles above.`}):null,C.length>0?(0,h.jsx)(oU,{label:`Existing videos`,children:C.map(e=>(0,h.jsx)(sU,{title:e.title,actions:(0,h.jsx)(R,{size:`small`,variant:`quiet`,disabled:w,"aria-label":`Remove ${e.title}`,onClick:()=>x.mutate(e.id),children:`Remove`})},e.id))}):null,(0,h.jsx)(zy,{open:o,title:`Remove all ${B2(C.length,`title`,`titles`)}?`,consequence:S.error?.message??`Topic suggestions and duplicate checks stop skipping them. Your videos on YouTube are not touched.`,confirmLabel:`Remove all`,pending:S.isPending,onConfirm:()=>S.mutate(),onCancel:()=>s(!1)})]})}function Vpe({preview:e,filter:t,busy:n,onFilter:r,onTick:i,onSave:a,onCancel:o}){let s=(0,m.useId)(),c=e.ticked.filter(Boolean).length;return(0,h.jsxs)(`section`,{"aria-label":`Titles in the CSV`,className:`mt-4`,...Ib,children:[(0,h.jsxs)(H,{as:`h3`,title:`Titles in the CSV`,info:`planning.channel.videos-ticks`,meta:`${c.toLocaleString(`en`)} of ${B2(e.titles.length,`title`,`titles`)} ticked`,children:[(0,h.jsxs)(R,{variant:`primary`,disabled:n||c===0,onClick:a,children:[`Add `,B2(c,`ticked title`,`ticked titles`)]}),(0,h.jsx)(R,{variant:`quiet`,disabled:n,onClick:o,children:`Cancel`})]}),(0,h.jsx)(dV,{label:`Keep only titles containing…`,tip:`planning.channel.videos-filter`,tipLabel:`Keep only titles containing`,children:(0,h.jsx)(pV,{value:t,maxLength:200,onChange:e=>r(e.target.value)})}),(0,h.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(R,{size:`small`,disabled:n,onClick:()=>i(e.titles.map(()=>!0)),children:`Tick all`}),(0,h.jsx)(R,{size:`small`,disabled:n,onClick:()=>i(e.titles.map(()=>!1)),children:`Untick all`})]}),(0,h.jsx)(oU,{label:`Titles in the CSV`,className:`mt-2`,children:e.titles.map((t,r)=>(0,h.jsx)(sU,{lead:(0,h.jsx)(`input`,{id:`${s}-${r}`,type:`checkbox`,checked:e.ticked[r]===!0,disabled:n,className:`size-4 shrink-0 accent-accent`,onChange:t=>i(e.ticked.map((e,n)=>n===r?t.target.checked:e))}),title:(0,h.jsx)(`label`,{htmlFor:`${s}-${r}`,children:t})},r))})]})}var H2=[`brand`,`cast`,`templates`,`schedules`,`episodes`,`videos`],Hpe={brand:`Brand`,cast:`Cast`,templates:`Templates`,schedules:`Schedules`,episodes:`Episodes`,videos:`Existing videos`};function Upe(e){return H2.find(t=>t===e)??`brand`}function Wpe({channelId:e,tab:t,onTab:n}){let{api:r}=z(),i=_(),a=Xi(),o=P(ox(r,e)),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(null),d=F({mutationFn:()=>lx(r,e),onSuccess:async()=>{c(!1),await i.invalidateQueries({queryKey:tx}),await a({to:`/channels`})}}),f=o.data?.channel,p=o.data?.cast??[],g=()=>{n(`cast`),u(`new`)};return Ox({id:`channel.add-to-cast`,title:`Add to cast`,group:`Channel`,...f===void 0?{}:{context:f.name},keywords:[`character`,`creature`,`place`,`object`],run:g}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{crumb:(0,h.jsx)(ma,{to:`/channels`,children:`Channels`}),title:f?.name??`Channel`,meta:f?.isDefault?`Default channel`:void 0,actions:(0,h.jsxs)(h.Fragment,{children:[t===`cast`&&f?(0,h.jsxs)(R,{variant:`primary`,onClick:g,children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Add to cast`]}):null,f&&!f.isDefault?(0,h.jsx)(R,{variant:`quiet`,onClick:()=>{d.reset(),c(!0)},children:`Delete channel`}):null]})}),(0,h.jsx)(X1,{items:H2.map(e=>({id:e,label:Hpe[e],...e===`cast`?{badge:String(p.length)}:{}})),value:t,onChange:n,label:`Channel sections`,idPrefix:`channel`,className:`mb-6`}),(0,h.jsx)(G1,{tone:o.error?`error`:`info`,className:`mb-2`,children:o.error?`The channel couldn't be loaded: ${o.error.message} Go back to Channels and open it again.`:o.isPending?`Loading the channel…`:void 0}),f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Z1,{idPrefix:`channel`,id:`brand`,active:t===`brand`,children:[(0,h.jsx)(ppe,{channel:f}),(0,h.jsx)(xpe,{channel:f},`${f.id}:${String(f.version)}`)]}),(0,h.jsx)(Z1,{idPrefix:`channel`,id:`cast`,active:t===`cast`,children:(0,h.jsx)(Ope,{channelId:f.id,cast:p,selected:l,onSelect:u})}),(0,h.jsx)(Z1,{idPrefix:`channel`,id:`templates`,active:t===`templates`,children:t===`templates`?(0,h.jsx)(Hde,{channelId:f.id}):null}),(0,h.jsx)(Z1,{idPrefix:`channel`,id:`schedules`,active:t===`schedules`,children:t===`schedules`?(0,h.jsx)(Gde,{channelId:f.id}):null}),(0,h.jsx)(Z1,{idPrefix:`channel`,id:`episodes`,active:t===`episodes`,children:t===`episodes`?(0,h.jsx)(Rpe,{channelId:f.id}):null}),(0,h.jsx)(Z1,{idPrefix:`channel`,id:`videos`,active:t===`videos`,children:t===`videos`?(0,h.jsx)(Bpe,{channelId:f.id}):null})]}):null,(0,h.jsx)(zy,{open:s,title:`Delete ${f?.name??`this channel`}?`,consequence:d.error?.message??`Its cast goes with it. Its videos move to the default channel and keep what they were made with.`,confirmLabel:`Delete channel`,cancelLabel:`Keep it`,pending:d.isPending,onConfirm:()=>d.mutate(),onCancel:()=>c(!1)})]})}function U2({className:e,children:t}){return(0,h.jsx)(`dl`,{className:L(`sl-stats m-0`,e),children:t})}function W2({value:e,label:t,children:n}){return(0,h.jsxs)(`div`,{className:`sl-stat`,children:[(0,h.jsx)(`dt`,{className:`sl-stat__label order-2`,children:t}),(0,h.jsx)(`dd`,{className:`sl-stat__value order-1 m-0`,children:e}),n===void 0?null:(0,h.jsx)(`dd`,{className:`order-3 m-0 mt-1`,children:n})]})}function G2({value:e,label:t,valueText:n,tone:r=`accent`,className:i}){let a=Math.round(Math.min(1,Math.max(0,Number.isFinite(e)?e:0))*100);return(0,h.jsx)(`div`,{role:`meter`,"aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":a,"aria-valuetext":n??`${String(a)}%`,className:L(`sl-meter`,r===`waiting`&&`sl-meter--waiting`,i),children:(0,h.jsx)(`span`,{style:{width:`${String(a)}%`}})})}function K2({columns:e,rows:t,rowKey:n,caption:r,empty:i,className:a}){return(0,h.jsxs)(`table`,{className:L(`sl-table`,a),children:[(0,h.jsx)(`caption`,{className:`sr-only`,children:r}),(0,h.jsx)(`thead`,{children:(0,h.jsx)(`tr`,{children:e.map(e=>(0,h.jsx)(`th`,{scope:`col`,className:e.numeric?`num`:void 0,children:e.header},e.id))})}),(0,h.jsx)(`tbody`,{children:t.length===0&&i!==void 0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:e.length,className:`text-ink-2`,children:i})}):t.map(t=>(0,h.jsx)(`tr`,{children:e.map(e=>(0,h.jsx)(`td`,{className:e.numeric?`num`:void 0,children:e.cell(t)},e.id))},n(t)))})]})}function Gpe(){let{api:e}=z(),t=_(),n=Xi(),r=P(ax(e)),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(null),f=r.data?.find(e=>e.id===u)??r.data?.[0],p=F({mutationFn:()=>sx(e,crypto.randomUUID(),c.trim()),onSuccess:async e=>{await t.invalidateQueries({queryKey:tx}),a(null),l(``),await n({to:`/channels/$channelId`,params:{channelId:e.id}})}}),g=F({mutationFn:t=>cx(e,t.id,{name:c.trim(),brand:t.brand,seriesBrief:t.seriesBrief,baseVersion:t.version}),onSuccess:async()=>{await t.invalidateQueries({queryKey:tx}),a(null)}}),v=F({mutationFn:t=>lx(e,t.id),onSuccess:async()=>{s(null),await t.invalidateQueries({queryKey:tx})}}),y=()=>{p.reset(),l(``),a(`new`)};Ox({id:`channels.new`,title:`New channel`,group:`Channels`,run:y});let b=i===`new`?p:g,x=()=>{c.trim()!==``&&i!==null&&(i===`new`?p.mutate():g.mutate(i))};return(0,h.jsxs)(`div`,{"data-tour":`channels`,children:[(0,h.jsx)(Sq,{title:`Channels`,meta:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`A channel keeps its brand kit, cast, series brief, templates and schedules together.`,(0,h.jsx)(V,{id:`planning.channels`})]}),actions:(0,h.jsxs)(R,{variant:`primary`,"aria-expanded":i===`new`,onClick:y,children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`New channel`]})}),(0,h.jsx)(G1,{tone:r.error||v.error?`error`:`info`,className:`mb-2`,children:r.error?`The channels couldn't be loaded: ${r.error.message} Reload the page to try again.`:o===null&&v.error?v.error.message:r.isPending?`Loading channels…`:void 0}),r.data?.length===0?(0,h.jsx)(Q1,{title:`No channels yet`,actions:(0,h.jsx)(R,{variant:`primary`,onClick:y,children:`New channel`}),children:`Make one for each series you run; it keeps that series' look and cast.`}):null,r.data?.length?(0,h.jsx)(wq,{list:(0,h.jsx)(oU,{label:`Channels`,className:`[&_.sl-row__actions]:flex-wrap`,children:r.data.map(e=>(0,h.jsx)(sU,{selected:e.id===f?.id,onSelect:()=>d(e.id),title:e.name,meta:`${e.isDefault?`Default · `:``}${String(e.templates)} ${e.templates===1?`template`:`templates`} · ${String(e.cast)} in the cast`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xS,{to:`/channels/$channelId`,params:{channelId:e.id},"aria-label":`Open ${e.name}`,className:`px-2 text-small`,children:`Open`}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Rename ${e.name}`,onClick:()=>{g.reset(),l(e.name),a(e)},children:`Rename`}),e.isDefault?null:(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Delete ${e.name}`,onClick:()=>{v.reset(),s(e)},children:`Delete`})]})},e.id))}),detail:f===void 0?null:(0,h.jsx)(Kpe,{channel:f})}):null,(0,h.jsx)(Ry,{open:i!==null,onOpenChange:e=>{!e&&!b.isPending&&a(null)},title:i===`new`||i===null?`New channel`:`Rename ${i.name}`,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(G1,{tone:b.error?`error`:`info`,children:b.error?.message??(b.isPending?`Saving…`:void 0)}),(0,h.jsx)(R,{disabled:b.isPending,onClick:()=>a(null),children:`Cancel`}),(0,h.jsx)(R,{type:`submit`,form:`channel-name-form`,variant:`primary`,disabled:b.isPending||c.trim()===``,children:i===`new`?`Create channel`:`Rename channel`})]}),children:(0,h.jsx)(`form`,{id:`channel-name-form`,"aria-label":i===`new`?`New channel`:`Rename channel`,onSubmit:e=>{e.preventDefault(),x()},children:(0,h.jsx)(dV,{label:`Channel name`,tip:`planning.channel.name`,children:(0,h.jsx)(pV,{value:c,maxLength:200,required:!0,disabled:b.isPending,onChange:e=>l(e.target.value)})})})}),(0,h.jsx)(zy,{open:o!==null,title:`Delete ${o?.name??`this channel`}?`,consequence:v.error?.message??`Its cast goes with it. Its videos move to the default channel and keep what they were made with.`,confirmLabel:`Delete channel`,cancelLabel:`Keep it`,pending:v.isPending,onConfirm:()=>{o&&v.mutate(o)},onCancel:()=>s(null)})]})}function Kpe({channel:e}){let t=e.brand,n=[[`Intro`,t.intro??`None`],[`Outro`,t.outro??`None`],[`Document theme`,t.documentTheme??`Default`],[`End screen text`,t.endScreenText??`None`]];return(0,h.jsxs)(`section`,{"aria-label":`About ${e.name}`,children:[(0,h.jsx)(H,{title:`About ${e.name}`,meta:e.isDefault?`The default channel`:void 0,children:(0,h.jsx)(bS,{to:`/channels/$channelId`,params:{channelId:e.id},children:`Open channel`})}),(0,h.jsxs)(U2,{className:`mb-6`,children:[(0,h.jsx)(W2,{value:String(e.templates),label:`Templates`}),(0,h.jsx)(W2,{value:String(e.cast),label:`In the cast`})]}),(0,h.jsx)(H,{as:`h3`,title:`Series brief`,className:`pb-2`}),(0,h.jsx)(`p`,{className:`m-0 mb-6 whitespace-pre-wrap text-body text-ink-2`,children:e.seriesBrief.trim()===``?`No series brief yet. Open the channel to say what it covers.`:e.seriesBrief}),(0,h.jsx)(H,{as:`h3`,title:`Brand kit`,className:`pb-2`}),(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-6 gap-y-2 text-small`,children:n.map(([e,t])=>(0,h.jsxs)(`div`,{className:`contents`,children:[(0,h.jsx)(`dt`,{className:`text-ink-2`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 truncate`,children:t})]},e))})]})}var q2=2e3;function J2(e,t){let n=(0,m.useRef)(t);(0,m.useEffect)(()=>{n.current=t}),(0,m.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{n.current()},q2);return()=>{clearTimeout(t)}},[e])}function Y2(){return(0,h.jsxs)(`span`,{className:`inline-flex animate-tick-in items-center gap-1 text-label text-accent-ink motion-reduce:animate-none`,children:[(0,h.jsx)(vc,{"aria-hidden":`true`,className:`size-[14px]`}),`Saved`]})}function X2({onDelete:e,blocked:t,blockedId:n,pending:r,saved:i,cancel:a,errors:o,onSave:s}){let c=t!==void 0||r||i,l=Iy();Ox({id:`editor.save`,title:`Save`,group:`This editor`,keywords:[`save`,`keep`],shortcut:uP.save,run:()=>{c?t!==void 0&&l(`Not saved yet: ${t}`,`error`):s()}});let u=o.join(` `);return(0,h.jsxs)(`div`,{"data-slot":`editor-actions`,className:`sticky bottom-0 z-10 flex flex-wrap items-center gap-3 border-t border-line bg-ground py-3 max-md:bottom-[calc(48px+max(12px,env(safe-area-inset-bottom)))]`,children:[(0,h.jsx)(R,{variant:`destructive`,onClick:e,disabled:e===void 0,"aria-hidden":e===void 0||void 0,tabIndex:e===void 0?-1:void 0,style:e===void 0?{visibility:`hidden`}:void 0,children:`Delete`}),(0,h.jsx)(G1,{tone:u?`error`:`info`,id:u?void 0:n,children:u||(i?(0,h.jsx)(Y2,{}):t)}),a,(0,h.jsx)(R,{variant:`primary`,"aria-disabled":c,"aria-describedby":t===void 0?void 0:n,"aria-keyshortcuts":Bx(uP.save),onClick:()=>{c||s()},children:`Save`})]})}var qpe=`rounded-media border border-line bg-surface p-4`;function Z2(){return(0,h.jsxs)(`div`,{className:`mx-auto grid max-w-[1440px] grid-cols-[minmax(0,1fr)] gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${qpe} flex flex-col gap-4`,children:[(0,h.jsx)(`span`,{className:`h-8 w-64 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-[520px] rounded-control bg-sunken`})]}),(0,h.jsx)(`div`,{className:`flex flex-col gap-3 pt-1`,children:(0,h.jsx)(`span`,{className:`h-3 w-28 rounded-control bg-sunken`})})]})}var Jpe=`modulepreload`,Ype=function(e){return`/`+e},Q2={},$2=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ype(t,n),t=s(t),t in Q2)return;Q2[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Jpe,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Xpe({data:e,label:t,onDrawn:n}){let r=(0,m.useRef)(null),[i,a]=(0,m.useState)(0);return(0,m.useEffect)(()=>{let e=r.current;if(e===null)return;let t=new ResizeObserver(([e])=>{a(Math.floor(e?.contentRect.width??0))});return t.observe(e),()=>{t.disconnect()}},[]),(0,m.useEffect)(()=>{let t=r.current;if(t===null||e===void 0||i===0)return;let a=!1;return Zpe(e,i).then(e=>{a||(t.replaceChildren(...e),n?.(void 0))},e=>{a||n?.(e instanceof Error?e:Error(String(e)))}),()=>{a=!0}},[e,i,n]),(0,h.jsx)(`div`,{ref:r,role:`img`,"aria-label":t,className:`flex flex-col gap-3 [&>canvas]:w-full [&>canvas]:shadow-[var(--shadow-pop)]`})}async function Zpe(e,t){let n=await $2(()=>import(`./pdf-BPADxYaD.js`),[]),r=await $2(()=>import(`./pdf.worker.min-zC6nfbxG.js`),[]);n.GlobalWorkerOptions.workerSrc=r.default;let i=n.getDocument({data:e.slice()}),a=await i.promise;try{let e=window.devicePixelRatio||1,n=[];for(let r=1;r<=a.numPages;r+=1){let i=await a.getPage(r),o=i.getViewport({scale:t*e/i.getViewport({scale:1}).width}),s=window.document.createElement(`canvas`);s.width=Math.floor(o.width),s.height=Math.floor(o.height),await i.render({canvas:s,viewport:o}).promise,n.push(s)}return n}finally{await i.destroy()}}var e4=(e,t,n)=>({kind:`number`,path:e,label:t,unit:`mm`,step:1,...n===void 0?{}:{help:n}}),t4=(e,t,n)=>({kind:`number`,path:e,label:t,unit:`pt`,step:.5,...n===void 0?{}:{help:n}}),n4=(e,t,n,r)=>({kind:`number`,path:e,label:t,unit:n,step:.05,...r===void 0?{}:{help:r}}),r4=(e,t,n)=>({kind:`toggle`,path:e,label:t,...n===void 0?{}:{help:n}}),i4=(e,t,n)=>({kind:`text`,path:e,label:t,...n===void 0?{}:{help:n}}),a4=(e,t,n)=>({kind:`optional-text`,path:e,label:t,...n===void 0?{}:{help:n}}),o4=(e,t,n)=>({kind:`face`,path:[`fonts`,e],label:t,...n===void 0?{}:{help:n}}),Qpe=[{title:`Page`,fields:[{kind:`choice`,path:[`page`,`format`],label:`Paper size`,options:[{value:`a4`,label:`A4`},{value:`letter`,label:`US Letter`}]},e4([`page`,`margin`],`Margins`),e4([`page`,`contentTop`],`Text starts at`,`From the top, on pages with the header.`),{kind:`choice`,path:[`background`,`image`],label:`Background`,options:[{value:`parchment`,label:`Parchment texture`},{value:null,label:`Flat colour`}]},{kind:`color`,path:[`background`,`color`],label:`Page colour`,help:`Used when the background is a flat colour.`}]},{title:`Colours`,fields:[{kind:`color`,path:[`colors`,`heading`],label:`Headings`,help:`Also drop caps, the brand name and links.`},{kind:`color`,path:[`colors`,`text`],label:`Body text`},{kind:`color`,path:[`colors`,`muted`],label:`Muted`,help:`Dates, bullets, quotes and the dots in the contents.`},{kind:`color`,path:[`colors`,`faint`],label:`Faint`,help:`Running header and page numbers.`}]},{title:`Fonts`,fields:[o4(`body`,`Body`),o4(`strong`,`Bold text`),o4(`emphasis`,`Italic text`),o4(`heading`,`Headings`),o4(`dramatic`,`Chapter numbers and brand`,`The big number of a "Chapter 3:" heading.`),o4(`decorative`,`Tagline and title-page link`),o4(`dropCap`,`Drop caps`),o4(`footer`,`Header and page numbers`)]},{title:`Text sizes`,fields:[t4([`sizes`,`title`],`Title`),t4([`sizes`,`brand`],`Brand`),t4([`sizes`,`section`],`Top-level headings`,`Also the titles of the contents, sources and closing pages.`),t4([`sizes`,`heading`],`Second-level headings`),t4([`sizes`,`subheading`],`Third-level headings`),t4([`sizes`,`body`],`Body`),t4([`sizes`,`meta`],`Date and word count`),t4([`sizes`,`footer`],`Header and page numbers`)]},{title:`Spacing`,fields:[e4([`spacing`,`bodyLine`],`Body line height`),e4([`spacing`,`headingLine`],`Heading line height`),e4([`spacing`,`subheadingLine`],`Subheading line height`),n4([`spacing`,`paragraphGap`],`After a paragraph`,`× line`),n4([`spacing`,`headingGap`],`Before a heading`,`× line`),n4([`spacing`,`itemGap`],`After a list item`,`× line`),e4([`spacing`,`listIndent`],`List indent`),e4([`spacing`,`quoteIndent`],`Quote indent`),e4([`spacing`,`ruleWidth`],`Divider width`,`The short centred line a --- becomes.`)]},{title:`Drop caps`,fields:[r4([`dropCap`,`enabled`],`Drop caps`,`A large first letter after each heading.`),{kind:`choice`,path:[`dropCap`,`lines`],label:`Lines tall`,options:[{value:2,label:`2 lines`},{value:3,label:`3 lines`},{value:4,label:`4 lines`}]},n4([`dropCap`,`scale`],`Letter size`,`× lines`),e4([`dropCap`,`gap`],`Gap beside it`),{kind:`number`,path:[`dropCap`,`minLength`],label:`Shortest paragraph`,unit:`chars`,step:10,help:`Shorter paragraphs start plainly.`},n4([`dropCap`,`minRoom`],`Room needed`,`of page`,`With less room left, the paragraph starts on the next page.`)]},{title:`Title page`,fields:[e4([`titlePage`,`brandY`],`Brand from top`),e4([`titlePage`,`taglineOffset`],`Tagline below brand`),e4([`titlePage`,`titleY`],`Title from top`),e4([`titlePage`,`titleLine`],`Title line height`),e4([`titlePage`,`metaOffset`],`Details below title`),e4([`titlePage`,`metaLine`],`Details line height`),r4([`titlePage`,`showDate`],`Show the date`),r4([`titlePage`,`showWordCount`],`Show the word count`),r4([`titlePage`,`cover`,`enabled`],`Thumbnail as cover`,`When the project has a thumbnail.`),e4([`titlePage`,`cover`,`gap`],`Space around cover`),e4([`titlePage`,`cover`,`maxHeight`],`Cover height at most`)]},{title:`Branding`,fields:[a4([`brand`,`name`],`Brand name`,`Leave empty to hide the brand.`),a4([`brand`,`tagline`],`Tagline`),a4([`brand`,`url`],`Website`,`Where the brand and its link go.`),a4([`brand`,`linkLabel`],`Link text`,`The linked line under the word count.`)]},{title:`Contents page`,fields:[r4([`contents`,`enabled`],`Contents page`),i4([`contents`,`title`],`Title`),{kind:`choice`,path:[`contents`,`depth`],label:`Lists headings down to`,options:[{value:1,label:`Top level`},{value:2,label:`Second level`},{value:3,label:`Third level`}]},e4([`contents`,`titleOffset`],`Title from top margin`),e4([`contents`,`firstEntryOffset`],`First entry from top margin`),e4([`contents`,`line`],`Line height`),e4([`contents`,`indent`],`Indent per level`)]},{title:`Header and footer`,fields:[r4([`header`,`enabled`],`Running header`,`The title at the top of each page.`),e4([`header`,`top`],`Header from top`),{kind:`number`,path:[`header`,`maxTitleCharacters`],label:`Header title at most`,unit:`chars`,step:1},r4([`footer`,`enabled`],`Page numbers`),i4([`footer`,`text`],`Page number text`,`{page} becomes the page number.`),e4([`footer`,`bottom`],`From the bottom`),e4([`footer`,`reserve`],`Space kept above it`)]},{title:`Sources page`,fields:[r4([`sources`,`enabled`],`Sources page`,`The links the article and research used.`),i4([`sources`,`title`],`Title`),e4([`sources`,`titleOffset`],`Title from top margin`),e4([`sources`,`bodyOffset`],`List from top margin`),e4([`sources`,`line`],`Line height`),e4([`sources`,`gap`],`Gap between sources`)]},{title:`Closing page`,fields:[r4([`endPage`,`enabled`],`Closing page`),i4([`endPage`,`title`],`Title`),{kind:`lines`,path:[`endPage`,`lines`],label:`Text`,help:`One line each. Start with "•" for a bullet, end with ":" for a bold label, leave a line empty for a gap.`},r4([`endPage`,`showDocumentDetails`],`Add date, word and page counts`),{kind:`link`,path:[`endPage`,`link`],label:`Link`},a4([`endPage`,`closing`],`Closing line`),e4([`endPage`,`titleOffset`],`Title from top margin`),e4([`endPage`,`bodyOffset`],`Text from top margin`)]},{title:`PDF details`,fields:[i4([`metadata`,`author`],`Author`,`Shown in a PDF reader's document properties. {title} becomes the title.`),i4([`metadata`,`subject`],`Subject`),i4([`metadata`,`keywords`],`Keywords`),i4([`metadata`,`creator`],`Creator`)]}],s4=eM.map(e=>({value:e,label:{Cinzel:`Cinzel`,Literata:`Literata`,times:`Times`,helvetica:`Helvetica`,courier:`Courier`}[e]}));function c4(e){let t={normal:`Regular`,medium:`Medium`,bold:`Bold`,black:`Black`,italic:`Italic`,bolditalic:`Bold italic`};return(e===`Cinzel`?[`normal`,`medium`,`bold`,`black`]:[`normal`,`bold`,`italic`,`bolditalic`]).map(e=>({value:e,label:t[e]}))}function $pe(e,t){let n=e;for(let e of t)n=n?.[e];return n}function l4(e,t,n){let[r,...i]=t;if(r===void 0)return n;let a=e[r];return{...e,[r]:i.length===0?n:l4(a,i,n)}}function eme(e){let t=cM;for(let n of e)t=t?.shape?.[n];return{min:t?.minValue??0,max:t?.maxValue??1e3}}function u4(e){return`values.${e.join(`.`)}`}var d4=`pt-1`,f4=`flex min-w-0 flex-col gap-3 pt-1 lg:sticky lg:top-16`;function p4({children:e}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{children:`Library`}),(0,h.jsx)(xc,{"aria-hidden":`true`}),e]})}function m4({children:e,back:t}){return(0,h.jsxs)(`div`,{className:`mx-auto flex max-w-[1440px] flex-col gap-3`,children:[(0,h.jsx)(vI,{tone:`danger`,title:`This can't be opened.`,children:e}),(0,h.jsx)(`p`,{className:`m-0 text-small text-accent-ink underline underline-offset-[3px]`,children:t})]})}function h4({themeId:e,from:t,onLeave:n}){let{api:r}=z(),i=_(),a=P(fb(r)),o=(0,m.useId)(),[s,c]=(0,m.useState)(void 0),[l,u]=(0,m.useState)([]),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),v=a.data,y=e===void 0?void 0:v?.themes.find(t=>t.id===e),b=e===void 0?v?.themes.find(e=>e.id===t)??v?.builtIns.find(e=>e.name===(t??`plain`))??v?.builtIns[0]:y,x=b===void 0?void 0:{name:e===void 0?`${`label`in b?b.label:b.name} copy`:b.name,values:b.values},S=s??x,C=F({mutationFn:t=>Ws(r,t,e),onSuccess:async e=>{if(!e.ok){u(e.fields);return}f(!0),await i.invalidateQueries({queryKey:fb(r).queryKey})}}),w=F({mutationFn:e=>Gs(r,e),onSuccess:async()=>{g(!1),await i.invalidateQueries({queryKey:fb(r).queryKey}),n()}});J2(d,n);let T=(0,m.useMemo)(()=>S===void 0?void 0:cM.safeParse(S.values),[S]),E=[...S===void 0||S.name.trim()===``?[]:aC(S.name),...T===void 0||T.success?[]:T.error.issues.map(e=>({field:`values.${e.path.join(`.`)}`,message:e.message})),...l];if(a.error!==null)return(0,h.jsx)(v4,{children:a.error.message});if(v===void 0)return(0,h.jsx)(Z2,{});if(S===void 0)return(0,h.jsx)(v4,{children:`That theme is gone. It may have been deleted in another tab.`});let D=(e,t)=>{c(e),u(e=>e.filter(e=>e.field!==t))},O=S.name.trim()===``?`Give the theme a name.`:E.length>0?`Fix the highlighted settings first.`:void 0,k=E.filter(e=>e.field===`name`);return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{crumb:(0,h.jsx)(p4,{children:(0,h.jsx)(ma,{to:`/document-themes`,children:`Documents`})}),title:e===void 0?`New document theme`:`Edit document theme`,meta:`How a project's PDF looks`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(320px,440px)]`,children:[(0,h.jsxs)(`div`,{className:`${d4} flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(dV,{label:`Name`,tip:`library.theme.name`,...k.length===0?{}:{error:k.map(e=>e.message).join(` `)},children:(0,h.jsx)(pV,{value:S.name,onChange:e=>{D({...S,name:e.target.value},`name`)}})}),Qpe.map((e,t)=>(0,h.jsxs)(`details`,{open:t<2||e.fields.some(e=>g4(E,e.path)),className:`group border-t border-line`,children:[(0,h.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 py-3 text-title-3 font-semibold`,onClick:e=>{let t=e.currentTarget.parentElement;requestAnimationFrame(()=>{t instanceof HTMLDetailsElement&&t.open&&t.scrollIntoView?.({block:`nearest`,behavior:`smooth`})})},children:[(0,h.jsx)(xc,{"aria-hidden":`true`,className:`size-[14px] text-ink-2 transition-transform group-open:rotate-90 motion-reduce:transition-none`}),e.title]}),(0,h.jsx)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-x-5 gap-y-4 pb-4 sm:grid-cols-2`,children:e.fields.map(e=>(0,h.jsx)(rme,{field:e,theme:S.values,problem:g4(E,e.path),onChange:t=>{D({...S,values:t},u4(e.path))}},e.path.join(`.`)))})]},e.title)),(0,h.jsx)(X2,{onDelete:e===void 0?void 0:()=>{g(!0)},blocked:O,blockedId:o,pending:C.isPending,saved:d,cancel:(0,h.jsx)(bS,{to:`/document-themes`,variant:`secondary`,children:`Cancel`}),errors:[C.error,w.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{C.mutate(S)}})]}),(0,h.jsx)(nme,{values:T?.success===!0?S.values:void 0})]}),(0,h.jsx)(zy,{open:p,title:`Delete "${S.name}"?`,consequence:`Projects that used it keep their own copy of its settings.`,confirmLabel:`Delete theme`,pending:w.isPending,onConfirm:()=>{e!==void 0&&w.mutate(e)},onCancel:()=>{g(!1)}})]})}var tme={"values.page.format":`library.theme.page.format`,"values.page.margin":`library.theme.page.margin`,"values.page.contentTop":`library.theme.page.content-top`,"values.background.image":`library.theme.background.image`,"values.background.color":`library.theme.background.color`,"values.colors.heading":`library.theme.colors.heading`,"values.colors.text":`library.theme.colors.text`,"values.colors.muted":`library.theme.colors.muted`,"values.colors.faint":`library.theme.colors.faint`,"values.fonts.body":`library.theme.fonts.body`,"values.fonts.strong":`library.theme.fonts.strong`,"values.fonts.emphasis":`library.theme.fonts.emphasis`,"values.fonts.heading":`library.theme.fonts.heading`,"values.fonts.dramatic":`library.theme.fonts.dramatic`,"values.fonts.decorative":`library.theme.fonts.decorative`,"values.fonts.dropCap":`library.theme.fonts.drop-cap`,"values.fonts.footer":`library.theme.fonts.footer`,"values.sizes.title":`library.theme.sizes.title`,"values.sizes.brand":`library.theme.sizes.brand`,"values.sizes.section":`library.theme.sizes.section`,"values.sizes.heading":`library.theme.sizes.heading`,"values.sizes.subheading":`library.theme.sizes.subheading`,"values.sizes.body":`library.theme.sizes.body`,"values.sizes.meta":`library.theme.sizes.meta`,"values.sizes.footer":`library.theme.sizes.footer`,"values.spacing.bodyLine":`library.theme.spacing.body-line`,"values.spacing.headingLine":`library.theme.spacing.heading-line`,"values.spacing.subheadingLine":`library.theme.spacing.subheading-line`,"values.spacing.paragraphGap":`library.theme.spacing.paragraph-gap`,"values.spacing.headingGap":`library.theme.spacing.heading-gap`,"values.spacing.itemGap":`library.theme.spacing.item-gap`,"values.spacing.listIndent":`library.theme.spacing.list-indent`,"values.spacing.quoteIndent":`library.theme.spacing.quote-indent`,"values.spacing.ruleWidth":`library.theme.spacing.rule-width`,"values.dropCap.enabled":`library.theme.drop-cap.enabled`,"values.dropCap.lines":`library.theme.drop-cap.lines`,"values.dropCap.scale":`library.theme.drop-cap.scale`,"values.dropCap.gap":`library.theme.drop-cap.gap`,"values.dropCap.minLength":`library.theme.drop-cap.min-length`,"values.dropCap.minRoom":`library.theme.drop-cap.min-room`,"values.titlePage.brandY":`library.theme.title-page.brand-y`,"values.titlePage.taglineOffset":`library.theme.title-page.tagline-offset`,"values.titlePage.titleY":`library.theme.title-page.title-y`,"values.titlePage.titleLine":`library.theme.title-page.title-line`,"values.titlePage.metaOffset":`library.theme.title-page.meta-offset`,"values.titlePage.metaLine":`library.theme.title-page.meta-line`,"values.titlePage.showDate":`library.theme.title-page.show-date`,"values.titlePage.showWordCount":`library.theme.title-page.show-word-count`,"values.titlePage.cover.enabled":`library.theme.title-page.cover`,"values.titlePage.cover.gap":`library.theme.title-page.cover-gap`,"values.titlePage.cover.maxHeight":`library.theme.title-page.cover-height`,"values.brand.name":`library.theme.brand.name`,"values.brand.tagline":`library.theme.brand.tagline`,"values.brand.url":`library.theme.brand.url`,"values.brand.linkLabel":`library.theme.brand.link-label`,"values.contents.enabled":`library.theme.contents.enabled`,"values.contents.title":`library.theme.contents.title`,"values.contents.depth":`library.theme.contents.depth`,"values.contents.titleOffset":`library.theme.contents.title-offset`,"values.contents.firstEntryOffset":`library.theme.contents.first-entry-offset`,"values.contents.line":`library.theme.contents.line`,"values.contents.indent":`library.theme.contents.indent`,"values.header.enabled":`library.theme.header.enabled`,"values.header.top":`library.theme.header.top`,"values.header.maxTitleCharacters":`library.theme.header.max-title`,"values.footer.enabled":`library.theme.footer.enabled`,"values.footer.text":`library.theme.footer.text`,"values.footer.bottom":`library.theme.footer.bottom`,"values.footer.reserve":`library.theme.footer.reserve`,"values.sources.enabled":`library.theme.sources.enabled`,"values.sources.title":`library.theme.sources.title`,"values.sources.titleOffset":`library.theme.sources.title-offset`,"values.sources.bodyOffset":`library.theme.sources.body-offset`,"values.sources.line":`library.theme.sources.line`,"values.sources.gap":`library.theme.sources.gap`,"values.endPage.enabled":`library.theme.end-page.enabled`,"values.endPage.title":`library.theme.end-page.title`,"values.endPage.lines":`library.theme.end-page.lines`,"values.endPage.showDocumentDetails":`library.theme.end-page.details`,"values.endPage.link":`library.theme.end-page.link`,"values.endPage.closing":`library.theme.end-page.closing`,"values.endPage.titleOffset":`library.theme.end-page.title-offset`,"values.endPage.bodyOffset":`library.theme.end-page.body-offset`,"values.metadata.author":`library.theme.metadata.author`,"values.metadata.subject":`library.theme.metadata.subject`,"values.metadata.keywords":`library.theme.metadata.keywords`,"values.metadata.creator":`library.theme.metadata.creator`};function g4(e,t){let n=u4(t),r=e.filter(e=>e.field===n||e.field.startsWith(`${n}.`));return r.length===0?void 0:r.map(e=>e.message).join(` `)}function nme({values:e}){let{api:t}=z(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(`busy`),[o,s]=(0,m.useState)(void 0),c=e===void 0?void 0:JSON.stringify(e);(0,m.useEffect)(()=>{if(c===void 0)return;let e=new AbortController,n=window.setTimeout(()=>{a(`busy`),Ks(t,JSON.parse(c),e.signal).then(async e=>({bytes:new Uint8Array(await e.arrayBuffer()),blob:e})).then(({bytes:t,blob:n})=>{e.signal.aborted||r({bytes:t,url:URL.createObjectURL(n)})},t=>{e.signal.aborted||(s(t instanceof Error?t.message:String(t)),a(`failed`))})},450);return()=>{window.clearTimeout(n),e.abort()}},[t,c]),(0,m.useEffect)(()=>()=>{n!==void 0&&URL.revokeObjectURL(n.url)},[n]);let l=(0,m.useCallback)(e=>{if(e===void 0){a(`idle`);return}s(e.message),a(`failed`)},[]),u=e===void 0?`Paused until the highlighted settings are fixed.`:i===`busy`?`Updating…`:i===`failed`?`The preview couldn't be made: ${o??`unknown error`}`:`A sample article with this theme. Your projects use their own text and thumbnail.`;return(0,h.jsxs)(`div`,{className:f4,children:[(0,h.jsx)(H,{title:`Preview`,info:`library.theme.preview`,size:`small`,className:`pb-0`,children:n===void 0?null:(0,h.jsxs)(SS,{href:n.url,target:`_blank`,rel:`noreferrer`,variant:`secondary`,size:`small`,children:[(0,h.jsx)(Oc,{"aria-hidden":`true`,strokeWidth:1.75}),`Open full size`]})}),(0,h.jsx)(`div`,{className:`max-h-[calc(100vh-220px)] min-h-[320px] overflow-y-auto rounded-media bg-sunken p-3`,children:(0,h.jsx)(Xpe,{data:n?.bytes,label:`The sample article laid out with this theme`,onDrawn:l})}),(0,h.jsx)(`p`,{role:`status`,className:i===`failed`?`m-0 text-small text-danger`:`m-0 text-small text-ink-2`,children:u})]})}function rme({field:e,theme:t,problem:n,onChange:r}){let i=(0,m.useId)(),a=$pe(t,e.path),o=tme[u4(e.path)],s=o===void 0?null:(0,h.jsx)(V,{id:o,label:e.label,className:`-my-1`}),c=n=>{r(l4(t,e.path,n))},l=[e.help===void 0?``:`${i}-help`,n===void 0?``:`${i}-error`].filter(e=>e!==``).join(` `),u=(0,h.jsxs)(h.Fragment,{children:[e.help===void 0?null:(0,h.jsx)(`p`,{id:`${i}-help`,className:`sl-field__help m-0`,children:e.help}),n===void 0?null:(0,h.jsx)(`p`,{id:`${i}-error`,className:`sl-field__error m-0`,children:n})]}),d={id:i,"aria-invalid":n!==void 0,"aria-describedby":l===``?void 0:l};switch(e.kind){case`toggle`:return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 sm:col-span-2`,...Ib,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:i,className:`flex min-h-8 items-center gap-3 text-small font-semibold`,children:[(0,h.jsx)(`input`,{...d,type:`checkbox`,checked:a===!0,className:`size-4 accent-accent`,onChange:e=>{c(e.currentTarget.checked)}}),e.label]}),s]}),u]});case`number`:{let{min:t,max:n}=eme(e.path);return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(pV,{...d,type:`number`,inputMode:`decimal`,min:t,max:n,step:e.step,className:`w-28`,value:typeof a==`number`&&Number.isFinite(a)?a:``,onChange:e=>{c(e.target.value===``?NaN:Number(e.target.value))}}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:e.unit})]})})}case`color`:{let t=typeof a==`string`?a:``,n=/^#?[0-9a-f]{6}$/i.test(t)?`#${t.replace(`#`,``)}`:/^#?[0-9a-f]{3}$/i.test(t)?`#${[...t.replace(`#`,``)].map(e=>e+e).join(``)}`:`#000000`;return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`input`,{type:`color`,"aria-label":`${e.label} colour`,value:n,className:`h-8 w-10 cursor-pointer rounded-control border border-line-strong bg-transparent p-0.5`,onChange:e=>{c(e.target.value)}}),(0,h.jsx)(pV,{...d,className:`w-28 font-mono`,value:t,onChange:e=>{c(e.target.value)}})]})})}case`text`:return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(pV,{...d,value:typeof a==`string`?a:``,onChange:e=>{c(e.target.value)}})});case`optional-text`:return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(pV,{...d,value:typeof a==`string`?a:``,onChange:e=>{c(e.target.value===``?null:e.target.value)}})});case`choice`:{let t=e.options.findIndex(e=>e.value===a);return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(hV,{...d,value:String(t),onChange:t=>{let n=e.options[Number(t.target.value)];n!==void 0&&c(n.value)},children:e.options.map((e,t)=>(0,h.jsx)(`option`,{value:String(t),children:e.label},e.label))})})}case`face`:{let t=a,n=c4(t.family);return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(hV,{...d,"aria-label":`${e.label} font`,value:t.family,onChange:e=>{let n=s4.find(t=>t.value===e.target.value);if(n===void 0)return;let r=c4(n.value).some(e=>e.value===t.style);c({...t,family:n.value,style:r?t.style:`normal`})},children:s4.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(hV,{"aria-label":`${e.label} style`,value:t.style,onChange:e=>{c({...t,style:e.target.value})},children:n.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(pV,{type:`number`,"aria-label":`${e.label} letter spacing in millimetres`,title:`Letter spacing (mm)`,step:.01,className:`w-20`,value:Number.isFinite(t.letterSpacing)?t.letterSpacing:``,onChange:e=>{c({...t,letterSpacing:e.target.value===``?NaN:Number(e.target.value)})}})]})})}case`lines`:return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 sm:col-span-2`,...Ib,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:i,className:`sl-field__label`,children:e.label}),s]}),(0,h.jsx)(mV,{...d,rows:8,value:Array.isArray(a)?a.join(`
|
|
273
|
+
`),filter:g})},onCancel:()=>{y.reset(),p(void 0)}}),r.data&&C.length===0?(0,h.jsx)(Q1,{title:`No existing videos listed`,children:`In YouTube Studio open Analytics → Content → Advanced mode, export the table as a CSV, and import it here; or paste the titles above.`}):null,C.length>0?(0,h.jsx)(oU,{label:`Existing videos`,children:C.map(e=>(0,h.jsx)(sU,{title:e.title,actions:(0,h.jsx)(R,{size:`small`,variant:`quiet`,disabled:w,"aria-label":`Remove ${e.title}`,onClick:()=>x.mutate(e.id),children:`Remove`})},e.id))}):null,(0,h.jsx)(zy,{open:o,title:`Remove all ${B2(C.length,`title`,`titles`)}?`,consequence:S.error?.message??`Topic suggestions and duplicate checks stop skipping them. Your videos on YouTube are not touched.`,confirmLabel:`Remove all`,pending:S.isPending,onConfirm:()=>S.mutate(),onCancel:()=>s(!1)})]})}function Vpe({preview:e,filter:t,busy:n,onFilter:r,onTick:i,onSave:a,onCancel:o}){let s=(0,m.useId)(),c=e.ticked.filter(Boolean).length;return(0,h.jsxs)(`section`,{"aria-label":`Titles in the CSV`,className:`mt-4`,...Ib,children:[(0,h.jsxs)(H,{as:`h3`,title:`Titles in the CSV`,info:`planning.channel.videos-ticks`,meta:`${c.toLocaleString(`en`)} of ${B2(e.titles.length,`title`,`titles`)} ticked`,children:[(0,h.jsxs)(R,{variant:`primary`,disabled:n||c===0,onClick:a,children:[`Add `,B2(c,`ticked title`,`ticked titles`)]}),(0,h.jsx)(R,{variant:`quiet`,disabled:n,onClick:o,children:`Cancel`})]}),(0,h.jsx)(dV,{label:`Keep only titles containing…`,tip:`planning.channel.videos-filter`,tipLabel:`Keep only titles containing`,children:(0,h.jsx)(pV,{value:t,maxLength:200,onChange:e=>r(e.target.value)})}),(0,h.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(R,{size:`small`,disabled:n,onClick:()=>i(e.titles.map(()=>!0)),children:`Tick all`}),(0,h.jsx)(R,{size:`small`,disabled:n,onClick:()=>i(e.titles.map(()=>!1)),children:`Untick all`})]}),(0,h.jsx)(oU,{label:`Titles in the CSV`,className:`mt-2`,children:e.titles.map((t,r)=>(0,h.jsx)(sU,{lead:(0,h.jsx)(`input`,{id:`${s}-${r}`,type:`checkbox`,checked:e.ticked[r]===!0,disabled:n,className:`size-4 shrink-0 accent-accent`,onChange:t=>i(e.ticked.map((e,n)=>n===r?t.target.checked:e))}),title:(0,h.jsx)(`label`,{htmlFor:`${s}-${r}`,children:t})},r))})]})}var H2=[`brand`,`cast`,`templates`,`schedules`,`episodes`,`videos`],Hpe={brand:`Brand`,cast:`Cast`,templates:`Templates`,schedules:`Schedules`,episodes:`Episodes`,videos:`Existing videos`};function Upe(e){return H2.find(t=>t===e)??`brand`}function Wpe({channelId:e,tab:t,onTab:n}){let{api:r}=z(),i=_(),a=Xi(),o=P(ox(r,e)),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(null),d=F({mutationFn:()=>lx(r,e),onSuccess:async()=>{c(!1),await i.invalidateQueries({queryKey:tx}),await a({to:`/channels`})}}),f=o.data?.channel,p=o.data?.cast??[],g=()=>{n(`cast`),u(`new`)};return Ox({id:`channel.add-to-cast`,title:`Add to cast`,group:`Channel`,...f===void 0?{}:{context:f.name},keywords:[`character`,`creature`,`place`,`object`],run:g}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{crumb:(0,h.jsx)(ma,{to:`/channels`,children:`Channels`}),title:f?.name??`Channel`,meta:f?.isDefault?`Default channel`:void 0,actions:(0,h.jsxs)(h.Fragment,{children:[t===`cast`&&f?(0,h.jsxs)(R,{variant:`primary`,onClick:g,children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Add to cast`]}):null,f&&!f.isDefault?(0,h.jsx)(R,{variant:`quiet`,onClick:()=>{d.reset(),c(!0)},children:`Delete channel`}):null]})}),(0,h.jsx)(X1,{items:H2.map(e=>({id:e,label:Hpe[e],...e===`cast`?{badge:String(p.length)}:{}})),value:t,onChange:n,label:`Channel sections`,idPrefix:`channel`,className:`mb-6`}),(0,h.jsx)(G1,{tone:o.error?`error`:`info`,className:`mb-2`,children:o.error?`The channel couldn't be loaded: ${o.error.message} Go back to Channels and open it again.`:o.isPending?`Loading the channel…`:void 0}),f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Z1,{idPrefix:`channel`,id:`brand`,active:t===`brand`,children:[(0,h.jsx)(ppe,{channel:f}),(0,h.jsx)(xpe,{channel:f},`${f.id}:${String(f.version)}`)]}),(0,h.jsx)(Z1,{idPrefix:`channel`,id:`cast`,active:t===`cast`,children:(0,h.jsx)(Ope,{channelId:f.id,cast:p,selected:l,onSelect:u})}),(0,h.jsx)(Z1,{idPrefix:`channel`,id:`templates`,active:t===`templates`,children:t===`templates`?(0,h.jsx)(Hde,{channelId:f.id}):null}),(0,h.jsx)(Z1,{idPrefix:`channel`,id:`schedules`,active:t===`schedules`,children:t===`schedules`?(0,h.jsx)(Gde,{channelId:f.id}):null}),(0,h.jsx)(Z1,{idPrefix:`channel`,id:`episodes`,active:t===`episodes`,children:t===`episodes`?(0,h.jsx)(Rpe,{channelId:f.id}):null}),(0,h.jsx)(Z1,{idPrefix:`channel`,id:`videos`,active:t===`videos`,children:t===`videos`?(0,h.jsx)(Bpe,{channelId:f.id}):null})]}):null,(0,h.jsx)(zy,{open:s,title:`Delete ${f?.name??`this channel`}?`,consequence:d.error?.message??`Its cast goes with it. Its videos move to the default channel and keep what they were made with.`,confirmLabel:`Delete channel`,cancelLabel:`Keep it`,pending:d.isPending,onConfirm:()=>d.mutate(),onCancel:()=>c(!1)})]})}function U2({className:e,children:t}){return(0,h.jsx)(`dl`,{className:L(`sl-stats m-0`,e),children:t})}function W2({value:e,label:t,children:n}){return(0,h.jsxs)(`div`,{className:`sl-stat`,children:[(0,h.jsx)(`dt`,{className:`sl-stat__label order-2`,children:t}),(0,h.jsx)(`dd`,{className:`sl-stat__value order-1 m-0`,children:e}),n===void 0?null:(0,h.jsx)(`dd`,{className:`order-3 m-0 mt-1`,children:n})]})}function G2({value:e,label:t,valueText:n,tone:r=`accent`,className:i}){let a=Math.round(Math.min(1,Math.max(0,Number.isFinite(e)?e:0))*100);return(0,h.jsx)(`div`,{role:`meter`,"aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":a,"aria-valuetext":n??`${String(a)}%`,className:L(`sl-meter`,r===`waiting`&&`sl-meter--waiting`,i),children:(0,h.jsx)(`span`,{style:{width:`${String(a)}%`}})})}function K2({columns:e,rows:t,rowKey:n,caption:r,empty:i,className:a}){return(0,h.jsxs)(`table`,{className:L(`sl-table`,a),children:[(0,h.jsx)(`caption`,{className:`sr-only`,children:r}),(0,h.jsx)(`thead`,{children:(0,h.jsx)(`tr`,{children:e.map(e=>(0,h.jsx)(`th`,{scope:`col`,className:e.numeric?`num`:void 0,children:e.header},e.id))})}),(0,h.jsx)(`tbody`,{children:t.length===0&&i!==void 0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:e.length,className:`text-ink-2`,children:i})}):t.map(t=>(0,h.jsx)(`tr`,{children:e.map(e=>(0,h.jsx)(`td`,{className:e.numeric?`num`:void 0,children:e.cell(t)},e.id))},n(t)))})]})}function Gpe(){let{api:e}=z(),t=_(),n=Xi(),r=P(ax(e)),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(null),f=r.data?.find(e=>e.id===u)??r.data?.[0],p=F({mutationFn:()=>sx(e,crypto.randomUUID(),c.trim()),onSuccess:async e=>{await t.invalidateQueries({queryKey:tx}),a(null),l(``),await n({to:`/channels/$channelId`,params:{channelId:e.id}})}}),g=F({mutationFn:t=>cx(e,t.id,{name:c.trim(),brand:t.brand,seriesBrief:t.seriesBrief,baseVersion:t.version}),onSuccess:async()=>{await t.invalidateQueries({queryKey:tx}),a(null)}}),v=F({mutationFn:t=>lx(e,t.id),onSuccess:async()=>{s(null),await t.invalidateQueries({queryKey:tx})}}),y=()=>{p.reset(),l(``),a(`new`)};Ox({id:`channels.new`,title:`New channel`,group:`Channels`,run:y});let b=i===`new`?p:g,x=()=>{c.trim()!==``&&i!==null&&(i===`new`?p.mutate():g.mutate(i))};return(0,h.jsxs)(`div`,{"data-tour":`channels`,children:[(0,h.jsx)(Sq,{title:`Channels`,meta:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`A channel keeps its brand kit, cast, series brief, templates and schedules together.`,(0,h.jsx)(V,{id:`planning.channels`})]}),actions:(0,h.jsxs)(R,{variant:`primary`,"aria-expanded":i===`new`,onClick:y,children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`New channel`]})}),(0,h.jsx)(G1,{tone:r.error||v.error?`error`:`info`,className:`mb-2`,children:r.error?`The channels couldn't be loaded: ${r.error.message} Reload the page to try again.`:o===null&&v.error?v.error.message:r.isPending?`Loading channels…`:void 0}),r.data?.length===0?(0,h.jsx)(Q1,{title:`No channels yet`,actions:(0,h.jsx)(R,{variant:`primary`,onClick:y,children:`New channel`}),children:`Make one for each series you run; it keeps that series' look and cast.`}):null,r.data?.length?(0,h.jsx)(wq,{list:(0,h.jsx)(oU,{label:`Channels`,className:`[&_.sl-row__actions]:flex-wrap`,children:r.data.map(e=>(0,h.jsx)(sU,{selected:e.id===f?.id,onSelect:()=>d(e.id),title:e.name,meta:`${e.isDefault?`Default · `:``}${String(e.templates)} ${e.templates===1?`template`:`templates`} · ${String(e.cast)} in the cast`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xS,{to:`/channels/$channelId`,params:{channelId:e.id},"aria-label":`Open ${e.name}`,className:`px-2 text-small`,children:`Open`}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Rename ${e.name}`,onClick:()=>{g.reset(),l(e.name),a(e)},children:`Rename`}),e.isDefault?null:(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Delete ${e.name}`,onClick:()=>{v.reset(),s(e)},children:`Delete`})]})},e.id))}),detail:f===void 0?null:(0,h.jsx)(Kpe,{channel:f})}):null,(0,h.jsx)(Ry,{open:i!==null,onOpenChange:e=>{!e&&!b.isPending&&a(null)},title:i===`new`||i===null?`New channel`:`Rename ${i.name}`,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(G1,{tone:b.error?`error`:`info`,children:b.error?.message??(b.isPending?`Saving…`:void 0)}),(0,h.jsx)(R,{disabled:b.isPending,onClick:()=>a(null),children:`Cancel`}),(0,h.jsx)(R,{type:`submit`,form:`channel-name-form`,variant:`primary`,disabled:b.isPending||c.trim()===``,children:i===`new`?`Create channel`:`Rename channel`})]}),children:(0,h.jsx)(`form`,{id:`channel-name-form`,"aria-label":i===`new`?`New channel`:`Rename channel`,onSubmit:e=>{e.preventDefault(),x()},children:(0,h.jsx)(dV,{label:`Channel name`,tip:`planning.channel.name`,children:(0,h.jsx)(pV,{value:c,maxLength:200,required:!0,disabled:b.isPending,onChange:e=>l(e.target.value)})})})}),(0,h.jsx)(zy,{open:o!==null,title:`Delete ${o?.name??`this channel`}?`,consequence:v.error?.message??`Its cast goes with it. Its videos move to the default channel and keep what they were made with.`,confirmLabel:`Delete channel`,cancelLabel:`Keep it`,pending:v.isPending,onConfirm:()=>{o&&v.mutate(o)},onCancel:()=>s(null)})]})}function Kpe({channel:e}){let t=e.brand,n=[[`Intro`,t.intro??`None`],[`Outro`,t.outro??`None`],[`Document theme`,t.documentTheme??`Default`],[`End screen text`,t.endScreenText??`None`]];return(0,h.jsxs)(`section`,{"aria-label":`About ${e.name}`,children:[(0,h.jsx)(H,{title:`About ${e.name}`,meta:e.isDefault?`The default channel`:void 0,children:(0,h.jsx)(bS,{to:`/channels/$channelId`,params:{channelId:e.id},children:`Open channel`})}),(0,h.jsxs)(U2,{className:`mb-6`,children:[(0,h.jsx)(W2,{value:String(e.templates),label:`Templates`}),(0,h.jsx)(W2,{value:String(e.cast),label:`In the cast`})]}),(0,h.jsx)(H,{as:`h3`,title:`Series brief`,className:`pb-2`}),(0,h.jsx)(`p`,{className:`m-0 mb-6 whitespace-pre-wrap text-body text-ink-2`,children:e.seriesBrief.trim()===``?`No series brief yet. Open the channel to say what it covers.`:e.seriesBrief}),(0,h.jsx)(H,{as:`h3`,title:`Brand kit`,className:`pb-2`}),(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-6 gap-y-2 text-small`,children:n.map(([e,t])=>(0,h.jsxs)(`div`,{className:`contents`,children:[(0,h.jsx)(`dt`,{className:`text-ink-2`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 truncate`,children:t})]},e))})]})}var q2=2e3;function J2(e,t){let n=(0,m.useRef)(t);(0,m.useEffect)(()=>{n.current=t}),(0,m.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{n.current()},q2);return()=>{clearTimeout(t)}},[e])}function Y2(){return(0,h.jsxs)(`span`,{className:`inline-flex animate-tick-in items-center gap-1 text-label text-accent-ink motion-reduce:animate-none`,children:[(0,h.jsx)(vc,{"aria-hidden":`true`,className:`size-[14px]`}),`Saved`]})}function X2({onDelete:e,blocked:t,blockedId:n,pending:r,saved:i,cancel:a,errors:o,onSave:s}){let c=t!==void 0||r||i,l=Iy();Ox({id:`editor.save`,title:`Save`,group:`This editor`,keywords:[`save`,`keep`],shortcut:uP.save,run:()=>{c?t!==void 0&&l(`Not saved yet: ${t}`,`error`):s()}});let u=o.join(` `);return(0,h.jsxs)(`div`,{"data-slot":`editor-actions`,className:`sticky bottom-0 z-10 flex flex-wrap items-center gap-3 border-t border-line bg-ground py-3 max-md:bottom-[calc(48px+max(12px,env(safe-area-inset-bottom)))]`,children:[(0,h.jsx)(R,{variant:`destructive`,onClick:e,disabled:e===void 0,"aria-hidden":e===void 0||void 0,tabIndex:e===void 0?-1:void 0,style:e===void 0?{visibility:`hidden`}:void 0,children:`Delete`}),(0,h.jsx)(G1,{tone:u?`error`:`info`,id:u?void 0:n,children:u||(i?(0,h.jsx)(Y2,{}):t)}),a,(0,h.jsx)(R,{variant:`primary`,"aria-disabled":c,"aria-describedby":t===void 0?void 0:n,"aria-keyshortcuts":Bx(uP.save),onClick:()=>{c||s()},children:`Save`})]})}var qpe=`rounded-media border border-line bg-surface p-4`;function Z2(){return(0,h.jsxs)(`div`,{className:`mx-auto grid max-w-[1440px] grid-cols-[minmax(0,1fr)] gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${qpe} flex flex-col gap-4`,children:[(0,h.jsx)(`span`,{className:`h-8 w-64 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-[520px] rounded-control bg-sunken`})]}),(0,h.jsx)(`div`,{className:`flex flex-col gap-3 pt-1`,children:(0,h.jsx)(`span`,{className:`h-3 w-28 rounded-control bg-sunken`})})]})}var Jpe=`modulepreload`,Ype=function(e){return`/`+e},Q2={},$2=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ype(t,n),t=s(t),t in Q2)return;Q2[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Jpe,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Xpe({data:e,label:t,onDrawn:n}){let r=(0,m.useRef)(null),[i,a]=(0,m.useState)(0);return(0,m.useEffect)(()=>{let e=r.current;if(e===null)return;let t=new ResizeObserver(([e])=>{a(Math.floor(e?.contentRect.width??0))});return t.observe(e),()=>{t.disconnect()}},[]),(0,m.useEffect)(()=>{let t=r.current;if(t===null||e===void 0||i===0)return;let a=!1;return Zpe(e,i).then(e=>{a||(t.replaceChildren(...e),n?.(void 0))},e=>{a||n?.(e instanceof Error?e:Error(String(e)))}),()=>{a=!0}},[e,i,n]),(0,h.jsx)(`div`,{ref:r,role:`img`,"aria-label":t,className:`flex flex-col gap-3 [&>canvas]:w-full [&>canvas]:shadow-[var(--shadow-pop)]`})}async function Zpe(e,t){let n=await $2(()=>import(`./pdf-BI8cHr9G.js`),[]),r=await $2(()=>import(`./pdf.worker.min-zC6nfbxG.js`),[]);n.GlobalWorkerOptions.workerSrc=r.default;let i=n.getDocument({data:e.slice()}),a=await i.promise;try{let e=window.devicePixelRatio||1,n=[];for(let r=1;r<=a.numPages;r+=1){let i=await a.getPage(r),o=i.getViewport({scale:t*e/i.getViewport({scale:1}).width}),s=window.document.createElement(`canvas`);s.width=Math.floor(o.width),s.height=Math.floor(o.height),await i.render({canvas:s,viewport:o}).promise,n.push(s)}return n}finally{await i.destroy()}}var e4=(e,t,n)=>({kind:`number`,path:e,label:t,unit:`mm`,step:1,...n===void 0?{}:{help:n}}),t4=(e,t,n)=>({kind:`number`,path:e,label:t,unit:`pt`,step:.5,...n===void 0?{}:{help:n}}),n4=(e,t,n,r)=>({kind:`number`,path:e,label:t,unit:n,step:.05,...r===void 0?{}:{help:r}}),r4=(e,t,n)=>({kind:`toggle`,path:e,label:t,...n===void 0?{}:{help:n}}),i4=(e,t,n)=>({kind:`text`,path:e,label:t,...n===void 0?{}:{help:n}}),a4=(e,t,n)=>({kind:`optional-text`,path:e,label:t,...n===void 0?{}:{help:n}}),o4=(e,t,n)=>({kind:`face`,path:[`fonts`,e],label:t,...n===void 0?{}:{help:n}}),Qpe=[{title:`Page`,fields:[{kind:`choice`,path:[`page`,`format`],label:`Paper size`,options:[{value:`a4`,label:`A4`},{value:`letter`,label:`US Letter`}]},e4([`page`,`margin`],`Margins`),e4([`page`,`contentTop`],`Text starts at`,`From the top, on pages with the header.`),{kind:`choice`,path:[`background`,`image`],label:`Background`,options:[{value:`parchment`,label:`Parchment texture`},{value:null,label:`Flat colour`}]},{kind:`color`,path:[`background`,`color`],label:`Page colour`,help:`Used when the background is a flat colour.`}]},{title:`Colours`,fields:[{kind:`color`,path:[`colors`,`heading`],label:`Headings`,help:`Also drop caps, the brand name and links.`},{kind:`color`,path:[`colors`,`text`],label:`Body text`},{kind:`color`,path:[`colors`,`muted`],label:`Muted`,help:`Dates, bullets, quotes and the dots in the contents.`},{kind:`color`,path:[`colors`,`faint`],label:`Faint`,help:`Running header and page numbers.`}]},{title:`Fonts`,fields:[o4(`body`,`Body`),o4(`strong`,`Bold text`),o4(`emphasis`,`Italic text`),o4(`heading`,`Headings`),o4(`dramatic`,`Chapter numbers and brand`,`The big number of a "Chapter 3:" heading.`),o4(`decorative`,`Tagline and title-page link`),o4(`dropCap`,`Drop caps`),o4(`footer`,`Header and page numbers`)]},{title:`Text sizes`,fields:[t4([`sizes`,`title`],`Title`),t4([`sizes`,`brand`],`Brand`),t4([`sizes`,`section`],`Top-level headings`,`Also the titles of the contents, sources and closing pages.`),t4([`sizes`,`heading`],`Second-level headings`),t4([`sizes`,`subheading`],`Third-level headings`),t4([`sizes`,`body`],`Body`),t4([`sizes`,`meta`],`Date and word count`),t4([`sizes`,`footer`],`Header and page numbers`)]},{title:`Spacing`,fields:[e4([`spacing`,`bodyLine`],`Body line height`),e4([`spacing`,`headingLine`],`Heading line height`),e4([`spacing`,`subheadingLine`],`Subheading line height`),n4([`spacing`,`paragraphGap`],`After a paragraph`,`× line`),n4([`spacing`,`headingGap`],`Before a heading`,`× line`),n4([`spacing`,`itemGap`],`After a list item`,`× line`),e4([`spacing`,`listIndent`],`List indent`),e4([`spacing`,`quoteIndent`],`Quote indent`),e4([`spacing`,`ruleWidth`],`Divider width`,`The short centred line a --- becomes.`)]},{title:`Drop caps`,fields:[r4([`dropCap`,`enabled`],`Drop caps`,`A large first letter after each heading.`),{kind:`choice`,path:[`dropCap`,`lines`],label:`Lines tall`,options:[{value:2,label:`2 lines`},{value:3,label:`3 lines`},{value:4,label:`4 lines`}]},n4([`dropCap`,`scale`],`Letter size`,`× lines`),e4([`dropCap`,`gap`],`Gap beside it`),{kind:`number`,path:[`dropCap`,`minLength`],label:`Shortest paragraph`,unit:`chars`,step:10,help:`Shorter paragraphs start plainly.`},n4([`dropCap`,`minRoom`],`Room needed`,`of page`,`With less room left, the paragraph starts on the next page.`)]},{title:`Title page`,fields:[e4([`titlePage`,`brandY`],`Brand from top`),e4([`titlePage`,`taglineOffset`],`Tagline below brand`),e4([`titlePage`,`titleY`],`Title from top`),e4([`titlePage`,`titleLine`],`Title line height`),e4([`titlePage`,`metaOffset`],`Details below title`),e4([`titlePage`,`metaLine`],`Details line height`),r4([`titlePage`,`showDate`],`Show the date`),r4([`titlePage`,`showWordCount`],`Show the word count`),r4([`titlePage`,`cover`,`enabled`],`Thumbnail as cover`,`When the project has a thumbnail.`),e4([`titlePage`,`cover`,`gap`],`Space around cover`),e4([`titlePage`,`cover`,`maxHeight`],`Cover height at most`)]},{title:`Branding`,fields:[a4([`brand`,`name`],`Brand name`,`Leave empty to hide the brand.`),a4([`brand`,`tagline`],`Tagline`),a4([`brand`,`url`],`Website`,`Where the brand and its link go.`),a4([`brand`,`linkLabel`],`Link text`,`The linked line under the word count.`)]},{title:`Contents page`,fields:[r4([`contents`,`enabled`],`Contents page`),i4([`contents`,`title`],`Title`),{kind:`choice`,path:[`contents`,`depth`],label:`Lists headings down to`,options:[{value:1,label:`Top level`},{value:2,label:`Second level`},{value:3,label:`Third level`}]},e4([`contents`,`titleOffset`],`Title from top margin`),e4([`contents`,`firstEntryOffset`],`First entry from top margin`),e4([`contents`,`line`],`Line height`),e4([`contents`,`indent`],`Indent per level`)]},{title:`Header and footer`,fields:[r4([`header`,`enabled`],`Running header`,`The title at the top of each page.`),e4([`header`,`top`],`Header from top`),{kind:`number`,path:[`header`,`maxTitleCharacters`],label:`Header title at most`,unit:`chars`,step:1},r4([`footer`,`enabled`],`Page numbers`),i4([`footer`,`text`],`Page number text`,`{page} becomes the page number.`),e4([`footer`,`bottom`],`From the bottom`),e4([`footer`,`reserve`],`Space kept above it`)]},{title:`Sources page`,fields:[r4([`sources`,`enabled`],`Sources page`,`The links the article and research used.`),i4([`sources`,`title`],`Title`),e4([`sources`,`titleOffset`],`Title from top margin`),e4([`sources`,`bodyOffset`],`List from top margin`),e4([`sources`,`line`],`Line height`),e4([`sources`,`gap`],`Gap between sources`)]},{title:`Closing page`,fields:[r4([`endPage`,`enabled`],`Closing page`),i4([`endPage`,`title`],`Title`),{kind:`lines`,path:[`endPage`,`lines`],label:`Text`,help:`One line each. Start with "•" for a bullet, end with ":" for a bold label, leave a line empty for a gap.`},r4([`endPage`,`showDocumentDetails`],`Add date, word and page counts`),{kind:`link`,path:[`endPage`,`link`],label:`Link`},a4([`endPage`,`closing`],`Closing line`),e4([`endPage`,`titleOffset`],`Title from top margin`),e4([`endPage`,`bodyOffset`],`Text from top margin`)]},{title:`PDF details`,fields:[i4([`metadata`,`author`],`Author`,`Shown in a PDF reader's document properties. {title} becomes the title.`),i4([`metadata`,`subject`],`Subject`),i4([`metadata`,`keywords`],`Keywords`),i4([`metadata`,`creator`],`Creator`)]}],s4=eM.map(e=>({value:e,label:{Cinzel:`Cinzel`,Literata:`Literata`,times:`Times`,helvetica:`Helvetica`,courier:`Courier`}[e]}));function c4(e){let t={normal:`Regular`,medium:`Medium`,bold:`Bold`,black:`Black`,italic:`Italic`,bolditalic:`Bold italic`};return(e===`Cinzel`?[`normal`,`medium`,`bold`,`black`]:[`normal`,`bold`,`italic`,`bolditalic`]).map(e=>({value:e,label:t[e]}))}function $pe(e,t){let n=e;for(let e of t)n=n?.[e];return n}function l4(e,t,n){let[r,...i]=t;if(r===void 0)return n;let a=e[r];return{...e,[r]:i.length===0?n:l4(a,i,n)}}function eme(e){let t=cM;for(let n of e)t=t?.shape?.[n];return{min:t?.minValue??0,max:t?.maxValue??1e3}}function u4(e){return`values.${e.join(`.`)}`}var d4=`pt-1`,f4=`flex min-w-0 flex-col gap-3 pt-1 lg:sticky lg:top-16`;function p4({children:e}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{children:`Library`}),(0,h.jsx)(xc,{"aria-hidden":`true`}),e]})}function m4({children:e,back:t}){return(0,h.jsxs)(`div`,{className:`mx-auto flex max-w-[1440px] flex-col gap-3`,children:[(0,h.jsx)(vI,{tone:`danger`,title:`This can't be opened.`,children:e}),(0,h.jsx)(`p`,{className:`m-0 text-small text-accent-ink underline underline-offset-[3px]`,children:t})]})}function h4({themeId:e,from:t,onLeave:n}){let{api:r}=z(),i=_(),a=P(fb(r)),o=(0,m.useId)(),[s,c]=(0,m.useState)(void 0),[l,u]=(0,m.useState)([]),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),v=a.data,y=e===void 0?void 0:v?.themes.find(t=>t.id===e),b=e===void 0?v?.themes.find(e=>e.id===t)??v?.builtIns.find(e=>e.name===(t??`plain`))??v?.builtIns[0]:y,x=b===void 0?void 0:{name:e===void 0?`${`label`in b?b.label:b.name} copy`:b.name,values:b.values},S=s??x,C=F({mutationFn:t=>Ws(r,t,e),onSuccess:async e=>{if(!e.ok){u(e.fields);return}f(!0),await i.invalidateQueries({queryKey:fb(r).queryKey})}}),w=F({mutationFn:e=>Gs(r,e),onSuccess:async()=>{g(!1),await i.invalidateQueries({queryKey:fb(r).queryKey}),n()}});J2(d,n);let T=(0,m.useMemo)(()=>S===void 0?void 0:cM.safeParse(S.values),[S]),E=[...S===void 0||S.name.trim()===``?[]:aC(S.name),...T===void 0||T.success?[]:T.error.issues.map(e=>({field:`values.${e.path.join(`.`)}`,message:e.message})),...l];if(a.error!==null)return(0,h.jsx)(v4,{children:a.error.message});if(v===void 0)return(0,h.jsx)(Z2,{});if(S===void 0)return(0,h.jsx)(v4,{children:`That theme is gone. It may have been deleted in another tab.`});let D=(e,t)=>{c(e),u(e=>e.filter(e=>e.field!==t))},O=S.name.trim()===``?`Give the theme a name.`:E.length>0?`Fix the highlighted settings first.`:void 0,k=E.filter(e=>e.field===`name`);return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{crumb:(0,h.jsx)(p4,{children:(0,h.jsx)(ma,{to:`/document-themes`,children:`Documents`})}),title:e===void 0?`New document theme`:`Edit document theme`,meta:`How a project's PDF looks`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(320px,440px)]`,children:[(0,h.jsxs)(`div`,{className:`${d4} flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(dV,{label:`Name`,tip:`library.theme.name`,...k.length===0?{}:{error:k.map(e=>e.message).join(` `)},children:(0,h.jsx)(pV,{value:S.name,onChange:e=>{D({...S,name:e.target.value},`name`)}})}),Qpe.map((e,t)=>(0,h.jsxs)(`details`,{open:t<2||e.fields.some(e=>g4(E,e.path)),className:`group border-t border-line`,children:[(0,h.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 py-3 text-title-3 font-semibold`,onClick:e=>{let t=e.currentTarget.parentElement;requestAnimationFrame(()=>{t instanceof HTMLDetailsElement&&t.open&&t.scrollIntoView?.({block:`nearest`,behavior:`smooth`})})},children:[(0,h.jsx)(xc,{"aria-hidden":`true`,className:`size-[14px] text-ink-2 transition-transform group-open:rotate-90 motion-reduce:transition-none`}),e.title]}),(0,h.jsx)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-x-5 gap-y-4 pb-4 sm:grid-cols-2`,children:e.fields.map(e=>(0,h.jsx)(rme,{field:e,theme:S.values,problem:g4(E,e.path),onChange:t=>{D({...S,values:t},u4(e.path))}},e.path.join(`.`)))})]},e.title)),(0,h.jsx)(X2,{onDelete:e===void 0?void 0:()=>{g(!0)},blocked:O,blockedId:o,pending:C.isPending,saved:d,cancel:(0,h.jsx)(bS,{to:`/document-themes`,variant:`secondary`,children:`Cancel`}),errors:[C.error,w.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{C.mutate(S)}})]}),(0,h.jsx)(nme,{values:T?.success===!0?S.values:void 0})]}),(0,h.jsx)(zy,{open:p,title:`Delete "${S.name}"?`,consequence:`Projects that used it keep their own copy of its settings.`,confirmLabel:`Delete theme`,pending:w.isPending,onConfirm:()=>{e!==void 0&&w.mutate(e)},onCancel:()=>{g(!1)}})]})}var tme={"values.page.format":`library.theme.page.format`,"values.page.margin":`library.theme.page.margin`,"values.page.contentTop":`library.theme.page.content-top`,"values.background.image":`library.theme.background.image`,"values.background.color":`library.theme.background.color`,"values.colors.heading":`library.theme.colors.heading`,"values.colors.text":`library.theme.colors.text`,"values.colors.muted":`library.theme.colors.muted`,"values.colors.faint":`library.theme.colors.faint`,"values.fonts.body":`library.theme.fonts.body`,"values.fonts.strong":`library.theme.fonts.strong`,"values.fonts.emphasis":`library.theme.fonts.emphasis`,"values.fonts.heading":`library.theme.fonts.heading`,"values.fonts.dramatic":`library.theme.fonts.dramatic`,"values.fonts.decorative":`library.theme.fonts.decorative`,"values.fonts.dropCap":`library.theme.fonts.drop-cap`,"values.fonts.footer":`library.theme.fonts.footer`,"values.sizes.title":`library.theme.sizes.title`,"values.sizes.brand":`library.theme.sizes.brand`,"values.sizes.section":`library.theme.sizes.section`,"values.sizes.heading":`library.theme.sizes.heading`,"values.sizes.subheading":`library.theme.sizes.subheading`,"values.sizes.body":`library.theme.sizes.body`,"values.sizes.meta":`library.theme.sizes.meta`,"values.sizes.footer":`library.theme.sizes.footer`,"values.spacing.bodyLine":`library.theme.spacing.body-line`,"values.spacing.headingLine":`library.theme.spacing.heading-line`,"values.spacing.subheadingLine":`library.theme.spacing.subheading-line`,"values.spacing.paragraphGap":`library.theme.spacing.paragraph-gap`,"values.spacing.headingGap":`library.theme.spacing.heading-gap`,"values.spacing.itemGap":`library.theme.spacing.item-gap`,"values.spacing.listIndent":`library.theme.spacing.list-indent`,"values.spacing.quoteIndent":`library.theme.spacing.quote-indent`,"values.spacing.ruleWidth":`library.theme.spacing.rule-width`,"values.dropCap.enabled":`library.theme.drop-cap.enabled`,"values.dropCap.lines":`library.theme.drop-cap.lines`,"values.dropCap.scale":`library.theme.drop-cap.scale`,"values.dropCap.gap":`library.theme.drop-cap.gap`,"values.dropCap.minLength":`library.theme.drop-cap.min-length`,"values.dropCap.minRoom":`library.theme.drop-cap.min-room`,"values.titlePage.brandY":`library.theme.title-page.brand-y`,"values.titlePage.taglineOffset":`library.theme.title-page.tagline-offset`,"values.titlePage.titleY":`library.theme.title-page.title-y`,"values.titlePage.titleLine":`library.theme.title-page.title-line`,"values.titlePage.metaOffset":`library.theme.title-page.meta-offset`,"values.titlePage.metaLine":`library.theme.title-page.meta-line`,"values.titlePage.showDate":`library.theme.title-page.show-date`,"values.titlePage.showWordCount":`library.theme.title-page.show-word-count`,"values.titlePage.cover.enabled":`library.theme.title-page.cover`,"values.titlePage.cover.gap":`library.theme.title-page.cover-gap`,"values.titlePage.cover.maxHeight":`library.theme.title-page.cover-height`,"values.brand.name":`library.theme.brand.name`,"values.brand.tagline":`library.theme.brand.tagline`,"values.brand.url":`library.theme.brand.url`,"values.brand.linkLabel":`library.theme.brand.link-label`,"values.contents.enabled":`library.theme.contents.enabled`,"values.contents.title":`library.theme.contents.title`,"values.contents.depth":`library.theme.contents.depth`,"values.contents.titleOffset":`library.theme.contents.title-offset`,"values.contents.firstEntryOffset":`library.theme.contents.first-entry-offset`,"values.contents.line":`library.theme.contents.line`,"values.contents.indent":`library.theme.contents.indent`,"values.header.enabled":`library.theme.header.enabled`,"values.header.top":`library.theme.header.top`,"values.header.maxTitleCharacters":`library.theme.header.max-title`,"values.footer.enabled":`library.theme.footer.enabled`,"values.footer.text":`library.theme.footer.text`,"values.footer.bottom":`library.theme.footer.bottom`,"values.footer.reserve":`library.theme.footer.reserve`,"values.sources.enabled":`library.theme.sources.enabled`,"values.sources.title":`library.theme.sources.title`,"values.sources.titleOffset":`library.theme.sources.title-offset`,"values.sources.bodyOffset":`library.theme.sources.body-offset`,"values.sources.line":`library.theme.sources.line`,"values.sources.gap":`library.theme.sources.gap`,"values.endPage.enabled":`library.theme.end-page.enabled`,"values.endPage.title":`library.theme.end-page.title`,"values.endPage.lines":`library.theme.end-page.lines`,"values.endPage.showDocumentDetails":`library.theme.end-page.details`,"values.endPage.link":`library.theme.end-page.link`,"values.endPage.closing":`library.theme.end-page.closing`,"values.endPage.titleOffset":`library.theme.end-page.title-offset`,"values.endPage.bodyOffset":`library.theme.end-page.body-offset`,"values.metadata.author":`library.theme.metadata.author`,"values.metadata.subject":`library.theme.metadata.subject`,"values.metadata.keywords":`library.theme.metadata.keywords`,"values.metadata.creator":`library.theme.metadata.creator`};function g4(e,t){let n=u4(t),r=e.filter(e=>e.field===n||e.field.startsWith(`${n}.`));return r.length===0?void 0:r.map(e=>e.message).join(` `)}function nme({values:e}){let{api:t}=z(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(`busy`),[o,s]=(0,m.useState)(void 0),c=e===void 0?void 0:JSON.stringify(e);(0,m.useEffect)(()=>{if(c===void 0)return;let e=new AbortController,n=window.setTimeout(()=>{a(`busy`),Ks(t,JSON.parse(c),e.signal).then(async e=>({bytes:new Uint8Array(await e.arrayBuffer()),blob:e})).then(({bytes:t,blob:n})=>{e.signal.aborted||r({bytes:t,url:URL.createObjectURL(n)})},t=>{e.signal.aborted||(s(t instanceof Error?t.message:String(t)),a(`failed`))})},450);return()=>{window.clearTimeout(n),e.abort()}},[t,c]),(0,m.useEffect)(()=>()=>{n!==void 0&&URL.revokeObjectURL(n.url)},[n]);let l=(0,m.useCallback)(e=>{if(e===void 0){a(`idle`);return}s(e.message),a(`failed`)},[]),u=e===void 0?`Paused until the highlighted settings are fixed.`:i===`busy`?`Updating…`:i===`failed`?`The preview couldn't be made: ${o??`unknown error`}`:`A sample article with this theme. Your projects use their own text and thumbnail.`;return(0,h.jsxs)(`div`,{className:f4,children:[(0,h.jsx)(H,{title:`Preview`,info:`library.theme.preview`,size:`small`,className:`pb-0`,children:n===void 0?null:(0,h.jsxs)(SS,{href:n.url,target:`_blank`,rel:`noreferrer`,variant:`secondary`,size:`small`,children:[(0,h.jsx)(Oc,{"aria-hidden":`true`,strokeWidth:1.75}),`Open full size`]})}),(0,h.jsx)(`div`,{className:`max-h-[calc(100vh-220px)] min-h-[320px] overflow-y-auto rounded-media bg-sunken p-3`,children:(0,h.jsx)(Xpe,{data:n?.bytes,label:`The sample article laid out with this theme`,onDrawn:l})}),(0,h.jsx)(`p`,{role:`status`,className:i===`failed`?`m-0 text-small text-danger`:`m-0 text-small text-ink-2`,children:u})]})}function rme({field:e,theme:t,problem:n,onChange:r}){let i=(0,m.useId)(),a=$pe(t,e.path),o=tme[u4(e.path)],s=o===void 0?null:(0,h.jsx)(V,{id:o,label:e.label,className:`-my-1`}),c=n=>{r(l4(t,e.path,n))},l=[e.help===void 0?``:`${i}-help`,n===void 0?``:`${i}-error`].filter(e=>e!==``).join(` `),u=(0,h.jsxs)(h.Fragment,{children:[e.help===void 0?null:(0,h.jsx)(`p`,{id:`${i}-help`,className:`sl-field__help m-0`,children:e.help}),n===void 0?null:(0,h.jsx)(`p`,{id:`${i}-error`,className:`sl-field__error m-0`,children:n})]}),d={id:i,"aria-invalid":n!==void 0,"aria-describedby":l===``?void 0:l};switch(e.kind){case`toggle`:return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 sm:col-span-2`,...Ib,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:i,className:`flex min-h-8 items-center gap-3 text-small font-semibold`,children:[(0,h.jsx)(`input`,{...d,type:`checkbox`,checked:a===!0,className:`size-4 accent-accent`,onChange:e=>{c(e.currentTarget.checked)}}),e.label]}),s]}),u]});case`number`:{let{min:t,max:n}=eme(e.path);return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(pV,{...d,type:`number`,inputMode:`decimal`,min:t,max:n,step:e.step,className:`w-28`,value:typeof a==`number`&&Number.isFinite(a)?a:``,onChange:e=>{c(e.target.value===``?NaN:Number(e.target.value))}}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:e.unit})]})})}case`color`:{let t=typeof a==`string`?a:``,n=/^#?[0-9a-f]{6}$/i.test(t)?`#${t.replace(`#`,``)}`:/^#?[0-9a-f]{3}$/i.test(t)?`#${[...t.replace(`#`,``)].map(e=>e+e).join(``)}`:`#000000`;return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`input`,{type:`color`,"aria-label":`${e.label} colour`,value:n,className:`h-8 w-10 cursor-pointer rounded-control border border-line-strong bg-transparent p-0.5`,onChange:e=>{c(e.target.value)}}),(0,h.jsx)(pV,{...d,className:`w-28 font-mono`,value:t,onChange:e=>{c(e.target.value)}})]})})}case`text`:return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(pV,{...d,value:typeof a==`string`?a:``,onChange:e=>{c(e.target.value)}})});case`optional-text`:return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(pV,{...d,value:typeof a==`string`?a:``,onChange:e=>{c(e.target.value===``?null:e.target.value)}})});case`choice`:{let t=e.options.findIndex(e=>e.value===a);return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(hV,{...d,value:String(t),onChange:t=>{let n=e.options[Number(t.target.value)];n!==void 0&&c(n.value)},children:e.options.map((e,t)=>(0,h.jsx)(`option`,{value:String(t),children:e.label},e.label))})})}case`face`:{let t=a,n=c4(t.family);return(0,h.jsx)(_4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(hV,{...d,"aria-label":`${e.label} font`,value:t.family,onChange:e=>{let n=s4.find(t=>t.value===e.target.value);if(n===void 0)return;let r=c4(n.value).some(e=>e.value===t.style);c({...t,family:n.value,style:r?t.style:`normal`})},children:s4.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(hV,{"aria-label":`${e.label} style`,value:t.style,onChange:e=>{c({...t,style:e.target.value})},children:n.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(pV,{type:`number`,"aria-label":`${e.label} letter spacing in millimetres`,title:`Letter spacing (mm)`,step:.01,className:`w-20`,value:Number.isFinite(t.letterSpacing)?t.letterSpacing:``,onChange:e=>{c({...t,letterSpacing:e.target.value===``?NaN:Number(e.target.value)})}})]})})}case`lines`:return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 sm:col-span-2`,...Ib,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:i,className:`sl-field__label`,children:e.label}),s]}),(0,h.jsx)(mV,{...d,rows:8,value:Array.isArray(a)?a.join(`
|
|
274
274
|
`):``,onChange:e=>{c(e.target.value.split(`
|
|
275
275
|
`))}}),u]});case`link`:{let t=a;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 sm:col-span-2`,...Ib,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:i,className:`flex min-h-8 items-center gap-3 text-small font-semibold`,children:[(0,h.jsx)(`input`,{id:i,type:`checkbox`,checked:t!==null,className:`size-4 accent-accent`,onChange:e=>{c(e.currentTarget.checked?{text:`Visit the website`,url:null}:null)}}),e.label]}),s]}),t===null?null:(0,h.jsxs)(`span`,{className:`grid grid-cols-[minmax(0,1fr)] gap-2 sm:grid-cols-2`,children:[(0,h.jsx)(pV,{"aria-label":`Link text`,placeholder:`Link text`,value:t.text,onChange:e=>{c({...t,text:e.target.value})}}),(0,h.jsx)(pV,{"aria-label":`Link address`,placeholder:`https://`,value:t.url??``,onChange:e=>{c({...t,url:e.target.value===``?null:e.target.value})}})]}),u]})}}}function _4({id:e,label:t,notes:n,info:r,children:i}){return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,...Ib,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:e,className:`sl-field__label`,children:t}),r]}),i,n]})}function v4({children:e}){return(0,h.jsx)(m4,{back:(0,h.jsx)(ma,{to:`/document-themes`,children:`Back to Documents`}),children:e})}var ime=4e3;function y4(e){return e.match(/\s+|[^\s]+/gu)??[]}function ame(e,t){let n=y4(e),r=y4(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i+=1;let a=0;for(;a<n.length-i&&a<r.length-i&&n[n.length-1-a]===r[r.length-1-a];)a+=1;let o=[];x4(o,`same`,n.slice(0,i).join(``));let s=n.slice(i,n.length-a),c=r.slice(i,r.length-a);for(let e of sme(s,c))x4(o,e.op,e.text);return x4(o,`same`,n.slice(n.length-a).join(``)),o}function b4(e,t){let n=t===`before`?`added`:`removed`;return e.filter(e=>e.op!==n)}function ome(e){let t=t=>e.filter(e=>e.op===t).reduce((e,t)=>e+y4(t.text).filter(e=>e.trim()!==``).length,0);return{added:t(`added`),removed:t(`removed`)}}function x4(e,t,n){if(n===``)return;let r=e.at(-1);r!==void 0&&r.op===t?e[e.length-1]={op:t,text:r.text+n}:e.push({op:t,text:n})}function sme(e,t){if(e.length===0&&t.length===0)return[];if(e.length===0)return[{op:`added`,text:t.join(``)}];if(t.length===0)return[{op:`removed`,text:e.join(``)}];let n=e.length,r=t.length,i=Math.min(n+r,ime),a=i+1,o=new Int32Array(2*i+3),s=[],c=!1;for(let l=0;l<=i&&!c;l+=1){s.push(o.slice());let i=o.slice();for(let s=-l;s<=l;s+=2){let u=s===-l||s!==l&&(o[a+s-1]??0)<(o[a+s+1]??0)?o[a+s+1]??0:(o[a+s-1]??0)+1,d=u-s;for(;u<n&&d<r&&e[u]===t[d];)u+=1,d+=1;if(i[a+s]=u,u>=n&&d>=r){c=!0;break}}o=i}if(!c)return[{op:`removed`,text:e.join(``)},{op:`added`,text:t.join(``)}];let l=[],u=n,d=r;for(let n=s.length-1;n>=0;--n){let r=s[n]??new Int32Array,i=u-d,o=i===-n||i!==n&&(r[a+i-1]??0)<(r[a+i+1]??0),c=o?i+1:i-1,f=r[a+c]??0,p=f-c;for(;u>f&&d>p;)l.push({op:`same`,text:e[u-1]??``}),--u,--d;n>0&&(o?l.push({op:`added`,text:t[d-1]??``}):l.push({op:`removed`,text:e[u-1]??``}),u=f,d=p)}let f=[];for(let e of l.reverse())x4(f,e.op,e.text);return f}function S4({before:e,after:t,beforeLabel:n,afterLabel:r}){let i=(0,m.useMemo)(()=>ame(e,t),[e,t]),a=ome(i);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:a.added===0&&a.removed===0?`The two texts are the same.`:`${String(a.added)} ${a.added===1?`word`:`words`} added, ${String(a.removed)} removed.`}),(0,h.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,h.jsx)(C4,{label:n,parts:b4(i,`before`)}),(0,h.jsx)(C4,{label:r,parts:b4(i,`after`)})]})]})}function C4({label:e,parts:t}){return(0,h.jsxs)(`section`,{"aria-label":e,className:`flex min-w-0 flex-col gap-1`,children:[(0,h.jsx)(`h4`,{className:`sl-kicker m-0`,children:e}),(0,h.jsx)(`div`,{className:`min-w-0 whitespace-pre-wrap break-words border-l-2 border-line pl-3 text-small leading-relaxed text-ink`,children:cme(t).map(({key:e,part:t})=>t.op===`removed`?(0,h.jsx)(`del`,{className:`rounded-[2px] bg-danger-tint text-danger line-through`,children:t.text},e):t.op===`added`?(0,h.jsx)(`ins`,{className:`rounded-[2px] bg-accent-tint text-accent-ink no-underline`,children:t.text},e):(0,h.jsx)(`span`,{children:t.text},e))})]})}function cme(e){let t=0;return e.map(e=>{let n=`${e.op}-${String(t)}`;return t+=e.text.length,{key:n,part:e}})}var w4={versions:(e,t)=>[`library-history`,e,t],usedBy:(e,t)=>[`library-used-by`,e,t]};function T4(e,t){let{api:n}=z();return P({queryKey:w4.versions(e,t),queryFn:()=>Rs(n,e,t)})}function lme(e,t){let{api:n}=z();return P({queryKey:w4.usedBy(e,t),queryFn:()=>zs(n,e,t)})}function E4({item:e,id:t,name:n,onClose:r}){let{api:i}=z(),a=_(),o=T4(e,t),s=o.data?.versions??[],[c,l]=(0,m.useState)({}),u=c.after??s[0]?.version,d=c.before??s[1]?.version??u,f=s.find(e=>e.version===d),p=s.find(e=>e.version===u),[g,v]=(0,m.useState)(),y=F({mutationFn:n=>Bs(i,e,t,n),onSuccess:async(n,r)=>{v(`Restored version ${String(r)} as a new version.`),l({}),await Promise.all([a.invalidateQueries({queryKey:w4.versions(e,t)}),a.invalidateQueries({queryKey:e===`prompt`?B.prompts:B.entries})])},onError:()=>v(void 0)}),b=s[0]?.version;return(0,h.jsx)(XP,{open:!0,title:`History of ${n}`,onClose:r,className:`sm:w-[min(1080px,100vw)]`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[o.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-body text-danger`,children:`The history couldn't be read: ${o.error.message}`}),(0,h.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(H,{title:`Compare`,as:`h3`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,h.jsx)(dV,{label:`Older`,tip:`library.history.compare`,children:(0,h.jsx)(hV,{value:d===void 0?``:String(d),disabled:s.length===0,onChange:e=>l(t=>({...t,before:Number(e.currentTarget.value)})),children:s.map(e=>(0,h.jsx)(`option`,{value:e.version,children:O4(e,b)},e.version))})}),(0,h.jsx)(dV,{label:`Newer`,tip:`library.history.compare`,children:(0,h.jsx)(hV,{value:u===void 0?``:String(u),disabled:s.length===0,onChange:e=>l(t=>({...t,after:Number(e.currentTarget.value)})),children:s.map(e=>(0,h.jsx)(`option`,{value:e.version,children:O4(e,b)},e.version))})})]}),f===void 0||p===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:o.isPending?`Loading the versions…`:`No versions to compare.`}):(0,h.jsxs)(h.Fragment,{children:[f.name===p.name?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Renamed from "${f.name}" to "${p.name}".`}),(0,h.jsx)(S4,{before:f.body,after:p.body,beforeLabel:`Version ${String(f.version)}`,afterLabel:`Version ${String(p.version)}`})]})]}),(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(H,{title:`Versions`,as:`h3`,info:`library.history.versions`}),(0,h.jsx)(oU,{label:`Versions of ${n}`,children:s.map(e=>(0,h.jsx)(sU,{title:`Version ${String(e.version)}`,meta:D4(e),actions:e.version===b?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Current`}):(0,h.jsx)(R,{size:`small`,"aria-label":`Restore version ${String(e.version)}`,disabled:y.isPending,disabledReason:`Restoring a version`,onClick:()=>{v(void 0),y.mutate(e.version)},children:`Restore`})},e.version))}),(0,h.jsx)(G1,{tone:y.error===null?`success`:`error`,children:y.error?.message??g})]})]})})}function D4(e){return`${e.author} · ${k4(e.createdAt)}${e.restoredFrom===null?``:` · restored from version ${String(e.restoredFrom)}`}`}function O4(e,t){return`Version ${String(e.version)}${e.version===t?` (current)`:``} · ${k4(e.createdAt)}`}function k4(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function A4({item:e,id:t,name:n,kicker:r,meta:i,body:a,slots:o,actions:s,onOpenHistory:c}){return(0,h.jsxs)(`section`,{"aria-label":`${n} details`,className:`flex min-w-0 flex-col gap-6`,children:[(0,h.jsx)(H,{title:n,kicker:r,meta:i,className:`pb-0`,children:s}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(`div`,{className:`m-0 max-h-[420px] min-w-0 overflow-y-auto whitespace-pre-wrap break-words rounded-media bg-sunken p-4 font-mono text-small text-ink-2`,children:a}),o.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No keywords. It runs as written.`}):(0,h.jsx)(`ul`,{"aria-label":`Keywords`,className:`m-0 flex list-none flex-wrap gap-2 p-0`,children:o.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsx)(gV,{children:`{{${e}}}`})},e))})]}),(0,h.jsx)(ume,{item:e,id:t}),(0,h.jsx)(dme,{item:e,id:t,name:n,onOpenHistory:c})]})}function ume({item:e,id:t}){let n=lme(e,t),r=n.data;return(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(H,{title:`Used by`,as:`h3`,className:`pb-0`,info:`library.used-by`,...r===void 0?{}:{meta:fme(r)}}),n.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:`What uses it couldn't be read: ${n.error.message}`}),r===void 0?null:r.templates.length+r.schedules.length+r.projects.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Nothing uses it yet.`}):(0,h.jsxs)(oU,{label:`Used by`,children:[r.templates.map(e=>(0,h.jsx)(sU,{title:(0,h.jsx)(ma,{to:`/templates`,children:e.name}),meta:`Template`},`t-${e.id}`)),r.schedules.map(e=>(0,h.jsx)(sU,{title:(0,h.jsx)(ma,{to:`/calendar`,search:{tab:`schedules`,schedule:e.id},children:e.name}),meta:e.status===`paused`?`Schedule · paused`:`Schedule`},`s-${e.id}`)),r.projects.map(e=>(0,h.jsx)(sU,{title:(0,h.jsx)(ma,{to:`/projects/$projectId`,params:{projectId:e.id},children:e.title}),meta:`Project${e.totalRevisions===0?``:` · ${String(e.revisions)} of ${String(e.totalRevisions)} ${e.totalRevisions===1?`revision`:`revisions`}${e.current?`, including the current one`:`, not the current one`}`}`},`p-${e.id}`))]})]})}function dme({item:e,id:t,name:n,onOpenHistory:r}){let i=T4(e,t),a=i.data?.versions??[],[o,s]=a;return(0,h.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(H,{title:`History`,as:`h3`,className:`pb-0`,info:`library.history`,...o===void 0?{}:{meta:`${j4(a.length,`version`)} · latest ${D4(o)}`},children:(0,h.jsx)(R,{size:`small`,"aria-label":`Compare versions of ${n}`,onClick:r,children:`Compare versions`})}),i.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:`The history couldn't be read: ${i.error.message}`}),o===void 0?null:s===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Only one version so far.`}):(0,h.jsx)(S4,{before:s.body,after:o.body,beforeLabel:`Version ${String(s.version)}`,afterLabel:`Version ${String(o.version)}`})]})}function fme(e){return[j4(e.templates.length,`template`),j4(e.schedules.length,`schedule`),j4(e.projects.length,`project`)].join(`, `)}function j4(e,t){return`${String(e)} ${t}${e===1?``:`s`}`}function M4(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{dateStyle:`medium`})}var N4=`min-[1180px]:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,P4=`grid-cols-1 2xl:grid-cols-[minmax(0,1fr)_auto]`;function F4({label:e}){return(0,h.jsx)(`ul`,{"aria-label":`${e}, loading`,"aria-busy":`true`,className:`sl-list m-0 list-none p-0`,children:[0,1,2].map(e=>(0,h.jsx)(`li`,{className:`sl-row`,"aria-hidden":`true`,children:(0,h.jsxs)(`span`,{className:`flex flex-col gap-2 py-0.5`,children:[(0,h.jsx)(`span`,{className:`h-3 w-40 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-56 rounded-control bg-sunken`})]})},e))})}function I4({what:e,message:t,onRetry:n}){return(0,h.jsx)(vI,{tone:`danger`,title:`The ${e} couldn't be loaded.`,actions:(0,h.jsx)(R,{size:`small`,onClick:n,children:`Try again`}),children:t})}function L4({name:e,edit:t,duplicate:n,play:r,onHistory:i,onDelete:a,className:o}){return(0,h.jsxs)(`div`,{role:`group`,"aria-label":`Actions for ${e}`,className:L(`flex flex-wrap items-center gap-0.5`,o),children:[t,n,r===void 0?null:(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Use ${e} in Play`,title:r.blocked,disabled:r.run===void 0||r.blocked!==void 0,onClick:r.run,children:`Use in Play`}),i===void 0?null:(0,h.jsx)(My,{size:`small`,label:`History of ${e}`,onClick:i,children:(0,h.jsx)(Wc,{"aria-hidden":`true`})}),(0,h.jsx)(My,{size:`small`,label:`Delete ${e}`,onClick:a,children:(0,h.jsx)(Yc,{"aria-hidden":`true`})})]})}var pme=[{to:`/prompts`,label:`Prompts`},{to:`/entries`,label:`Intros & Outros`},{to:`/templates`,label:`Templates`},{to:`/document-themes`,label:`Documents`},{to:`/narration-aliases`,label:`Aliases`},{to:`/ab-results`,label:`A/B results`}];function mme(){return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{title:`Library`,meta:`Prompts, intros and outros, templates, document themes, narration aliases and A/B results`}),(0,h.jsx)(Vde,{items:pme,label:`Library sections`,className:`mb-6`}),(0,h.jsx)(hme,{}),(0,h.jsx)(Aa,{})]})}function hme(){let e=Xi(),t=Ba({select:e=>e.location}),n=t.search,r=cV(t.pathname===`/prompts`?n.kind:void 0),i=aV(t.pathname===`/entries`?n.category:void 0);return Ox({id:`library.new-prompt`,title:`New prompt`,group:`Library`,keywords:[`create`,`article`,`image`,`thumbnail`],run:()=>{e({to:`/prompts/new`,search:{kind:r}})}}),Ox({id:`library.new-entry`,title:`New intro or outro`,group:`Library`,keywords:[`create`,`entry`],run:()=>{e({to:`/entries/new`,search:{category:i}})}}),Ox({id:`library.new-document-theme`,title:`New document theme`,group:`Library`,keywords:[`create`,`pdf`,`theme`],run:()=>{e({to:`/document-themes/new`,search:{from:`plain`}})}}),Ox({id:`library.open-prompts`,title:`Open prompts`,group:`Library`,run:()=>{e({to:`/prompts`,search:{kind:`article`}})}}),Ox({id:`library.open-entries`,title:`Open intros and outros`,group:`Library`,keywords:[`entries`],run:()=>{e({to:`/entries`,search:{category:`intro`}})}}),Ox({id:`library.open-templates`,title:`Open templates`,group:`Library`,keywords:[`setups`],run:()=>{e({to:`/templates`})}}),Ox({id:`library.open-document-themes`,title:`Open document themes`,group:`Library`,keywords:[`pdf`,`documents`],run:()=>{e({to:`/document-themes`})}}),null}function R4({children:e,action:t,className:n}){return(0,h.jsxs)(`div`,{"data-slot":`library-toolbar`,className:L(`mb-5 flex min-h-9 flex-wrap items-center gap-x-4 gap-y-3`,n),children:[(0,h.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-3`,children:e}),t===void 0?null:(0,h.jsx)(Py,{className:`ml-auto shrink-0`,children:t})]})}function gme(){let{api:e}=z(),t=_(),n=P(fb(e)),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(void 0),s=F({mutationFn:t=>Gs(e,t),onSettled:async()=>{o(void 0),await t.invalidateQueries({queryKey:B.documentThemes})}}),c=n.data,l=r!==void 0&&`saved`in r?c?.themes.find(e=>e.id===r.saved):void 0,u=r!==void 0&&`builtIn`in r?c?.builtIns.find(e=>e.name===r.builtIn):void 0,d=l===void 0&&u===void 0?c?.themes[0]:void 0,f=l??d,p=f===void 0?u??c?.builtIns[0]:void 0;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(R4,{action:(0,h.jsx)(bS,{to:`/document-themes/new`,search:{from:`plain`},variant:`primary`,children:`New theme`}),children:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`How a project's PDF looks. Pick one on the Document row in Play or in Edit project.`})}),n.error===null?null:(0,h.jsx)(I4,{what:`document themes`,message:n.error.message,onRetry:()=>void n.refetch()}),c===void 0?n.error===null?(0,h.jsx)(F4,{label:`Document themes`}):null:(0,h.jsx)(wq,{className:N4,list:(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(H,{title:`Your themes`,as:`h3`,className:`pb-0`,info:`library.themes.yours`}),c.themes.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No themes of your own yet. Copy a built-in below to start one.`}):(0,h.jsx)(oU,{label:`Your themes`,children:c.themes.map(e=>(0,h.jsx)(sU,{className:P4,lead:(0,h.jsx)(W4,{colors:e.values.colors}),title:e.name,meta:`${z4(e.values)} · updated ${M4(e.updatedAt)}`,selected:e.id===f?.id,onSelect:()=>i({saved:e.id}),actions:(0,h.jsx)(L4,{name:e.name,edit:(0,h.jsx)(bS,{to:`/document-themes/$themeId`,params:{themeId:e.id},"aria-label":`Edit ${e.name}`,variant:`quiet`,size:`small`,children:`Edit`}),duplicate:(0,h.jsx)(bS,{to:`/document-themes/new`,search:{from:e.id},"aria-label":`Duplicate ${e.name}`,variant:`quiet`,size:`small`,children:`Duplicate`}),onDelete:()=>o(e)})},e.id))})]}),(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(H,{title:`Built in`,as:`h3`,className:`pb-0`,info:`library.themes.built-in`}),(0,h.jsx)(oU,{label:`Built-in themes`,children:c.builtIns.map(e=>(0,h.jsx)(sU,{className:P4,lead:(0,h.jsx)(W4,{colors:e.values.colors}),title:e.label,meta:z4(e.values),selected:e.name===p?.name,onSelect:()=>i({builtIn:e.name}),actions:(0,h.jsx)(bS,{to:`/document-themes/new`,search:{from:e.name},"aria-label":`Copy ${e.label}`,variant:`quiet`,size:`small`,children:`Copy`})},e.name))})]})]}),detail:f===void 0?p===void 0?null:(0,h.jsx)(H4,{name:p.label,kicker:`Built in`,meta:`Built-in themes can't be changed. Copy one to make it yours.`,values:p.values,action:(0,h.jsx)(bS,{to:`/document-themes/new`,search:{from:p.name},size:`small`,children:`Copy theme`})}):(0,h.jsx)(H4,{name:f.name,kicker:`Your theme`,meta:`Updated ${M4(f.updatedAt)}`,values:f.values,action:(0,h.jsx)(bS,{to:`/document-themes/$themeId`,params:{themeId:f.id},size:`small`,children:`Edit theme`})})}),s.error===null?null:(0,h.jsx)(vI,{tone:`danger`,title:`The theme wasn't deleted.`,className:`mt-4`,children:s.error.message}),(0,h.jsx)(zy,{open:a!==void 0,title:`Delete "${a?.name??``}"?`,consequence:`Projects that used it keep their own copy of its settings.`,confirmLabel:`Delete theme`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>o(void 0)})]})}function z4(e){return`${e.page.format===`a4`?`A4`:`Letter`} · ${B4(e.fonts.body.family)} body`}function B4(e){return s4.find(t=>t.value===e)?.label??e}function V4(e){return e.startsWith(`#`)?e:`#${e}`}function H4({name:e,kicker:t,meta:n,values:r,action:i}){let a=[[`Headings`,r.colors.heading],[`Text`,r.colors.text],[`Muted`,r.colors.muted],[`Header and page numbers`,r.colors.faint]],o=[[`Body`,r.fonts.body],[`Headings`,r.fonts.heading],[`Drop cap`,r.fonts.dropCap]];return(0,h.jsxs)(`section`,{"aria-label":`${e} details`,className:`flex min-w-0 flex-col gap-6`,children:[(0,h.jsx)(H,{title:e,kicker:t,meta:n,className:`pb-0`,children:i}),(0,h.jsxs)(`dl`,{className:`m-0 grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-[max-content_minmax(0,1fr)]`,children:[a.map(([e,t])=>(0,h.jsx)(U4,{label:e,children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`size-4 rounded-full border border-line`,style:{backgroundColor:V4(t)}}),(0,h.jsx)(`span`,{className:`font-mono text-small`,children:V4(t)})]})},e)),o.map(([e,t])=>(0,h.jsx)(U4,{label:`${e} font`,children:`${B4(t.family)}, ${t.style}`},`font-${e}`)),(0,h.jsx)(U4,{label:`Page`,children:`${r.page.format===`a4`?`A4`:`Letter`}, ${r.background.image===`parchment`?`parchment`:`flat ${V4(r.background.color)}`} background`})]})]})}function U4({label:e,children:t}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`dt`,{className:`text-small text-ink-2`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 min-w-0 text-body text-ink`,children:t})]})}function W4({colors:e}){return(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`flex shrink-0 gap-1`,children:[e.heading,e.text,e.muted].map((e,t)=>(0,h.jsx)(`span`,{className:`size-3 rounded-full border border-line`,style:{backgroundColor:V4(e)}},t))})}function G4(e){let t=e.map(e=>e.message).join(` `);return`The name wasn't saved. ${t===``?`Pick another name and press Save name again.`:t}`}function K4({name:e,onSelect:t,onRename:n,tip:r=`library.inline-rename`,maxLength:i=200}){let a=Iy(),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(e),[u,d]=(0,m.useState)(null),[f,p]=(0,m.useState)(!1),g=(0,m.useRef)(!1),_=async e=>{try{return await n(e)}catch(e){return`The name wasn't saved: ${e instanceof Error?e.message:`Slopify didn't answer.`} Check that Slopify is running, then press Save name again.`}},v=async()=>{let t=c.trim();if(t===e){s(!1),d(null);return}if(t===``){d(`Write a name first, or press Cancel to keep the old one.`);return}if(g.current)return;g.current=!0,p(!0);let n=await _(t);if(g.current=!1,p(!1),n!==null){d(n);return}s(!1),d(null),a(`Renamed “${e}” to “${t}”.`,`success`,{label:`Undo`,run:()=>void _(e).then(t=>{t===null?a(`Renamed back to “${e}”.`,`success`):a(t,`error`)})})},y=()=>{s(!1),l(e),d(null)};return o?(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,...Ib,children:[(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1`,children:[(0,h.jsx)(pV,{autoFocus:!0,"aria-label":`New name for ${e}`,"aria-invalid":u!==null,maxLength:i,value:c,className:`min-w-0 flex-1`,onChange:e=>{l(e.target.value),d(null)},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),v()):e.key===`Escape`&&(e.preventDefault(),y())}}),(0,h.jsx)(R,{size:`small`,variant:`primary`,disabled:f,onClick:()=>void v(),children:f?`Saving…`:`Save name`}),(0,h.jsx)(R,{size:`small`,variant:`quiet`,disabled:f,onClick:y,children:`Cancel`}),(0,h.jsx)(V,{id:r,label:`Rename`})]}),u===null?null:(0,h.jsx)(`span`,{role:`alert`,className:`text-small font-normal text-danger`,children:u})]}):(0,h.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[t===void 0?(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:e}):(0,h.jsx)(cU,{onSelect:t,className:`min-w-0`,children:e}),(0,h.jsx)(My,{size:`small`,label:`Rename ${e}`,onClick:()=>{l(e),s(!0)},children:(0,h.jsx)(zc,{"aria-hidden":`true`,strokeWidth:1.75})})]})}function _me({category:e,onCategory:t,onUseInPlay:n,playBlocked:r}){let{api:i}=z(),a=_(),o=P(db(i)),[s,c]=(0,m.useState)(``),l=(0,m.useRef)(null),u=kx(l,`intros and outros`),[d,f]=(0,m.useState)(void 0),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)(void 0),b=F({mutationFn:e=>Xs(i,e),onSettled:async()=>{g(void 0),await a.invalidateQueries({queryKey:B.entries})}}),x=async(e,t)=>{let n=await Hs(i,{category:e.category,mode:e.mode,name:t,body:e.body},e.id);return await a.invalidateQueries({queryKey:B.entries}),n.ok?null:G4(n.fields)},S=o.data?.entries.filter(t=>t.category===e),C=s.trim().toLowerCase(),w=C===``?S:S?.filter(e=>e.name.toLowerCase().includes(C)||e.body.toLowerCase().includes(C)),T=w?.find(e=>e.id===d)??w?.[0];return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(R4,{action:(0,h.jsx)(bS,{to:`/entries/new`,search:{category:e},variant:`primary`,children:`New intro or outro`}),children:[(0,h.jsx)(pV,{type:`search`,ref:l,"aria-label":`Search intros and outros`,"aria-keyshortcuts":Bx(u),placeholder:`Search intros and outros`,value:s,className:`w-full min-w-0 sm:w-64`,onChange:e=>c(e.target.value)}),(0,h.jsx)(Rb,{label:`Entry category`,value:e,options:$B.map(e=>({...e,label:`${e.label}s`})),onChange:t,tip:`library.entry.category`})]}),o.error===null?null:(0,h.jsx)(I4,{what:`intros and outros`,message:o.error.message,onRetry:()=>void o.refetch()}),w===void 0||S===void 0?o.error===null?(0,h.jsx)(F4,{label:`Intros and outros`}):null:S.length===0?(0,h.jsx)(yme,{category:e}):(0,h.jsx)(wq,{className:N4,list:w.length===0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`No ${e}s match "${s.trim()}".`}):(0,h.jsx)(oU,{label:`${tV(e)}s`,children:w.map(e=>(0,h.jsx)(sU,{className:P4,title:(0,h.jsx)(K4,{name:e.name,onSelect:()=>f(e.id),onRename:t=>x(e,t)}),meta:vme(e),selected:e.id===T?.id,actions:(0,h.jsx)(L4,{name:e.name,edit:(0,h.jsx)(bS,{to:`/entries/$entryId`,params:{entryId:e.id},"aria-label":`Edit ${e.name}`,variant:`quiet`,size:`small`,children:`Edit`}),duplicate:(0,h.jsx)(bS,{to:`/entries/new`,search:{category:e.category,from:e.id},"aria-label":`Duplicate ${e.name}`,variant:`quiet`,size:`small`,children:`Duplicate`}),play:{run:n===void 0?void 0:()=>n(e),blocked:r},onHistory:()=>y(e),onDelete:()=>g(e)})},e.id))}),detail:T===void 0?null:(0,h.jsx)(A4,{item:`entry`,id:T.id,name:T.name,kicker:`${tV(T.category)} · ${nV(T.mode)}`,meta:`Updated ${M4(T.updatedAt)}`,body:T.body,slots:T.slots,actions:(0,h.jsx)(bS,{to:`/entries/$entryId`,params:{entryId:T.id},size:`small`,children:`Edit ${T.category}`}),onOpenHistory:()=>y(T)},T.id)}),b.error===null?null:(0,h.jsx)(vI,{tone:`danger`,title:`The ${e} wasn't deleted.`,className:`mt-4`,children:b.error.message}),v===void 0?null:(0,h.jsx)(E4,{item:`entry`,id:v.id,name:v.name,onClose:()=>y(void 0)},v.id),(0,h.jsx)(zy,{open:p!==void 0,title:p===void 0?``:`Delete "${p.name}"?`,consequence:`Moves it to the trash for 30 days (Settings → Trash). Projects that used it keep their text.`,confirmLabel:`Delete ${p?.category??e}`,pending:b.isPending,onConfirm:()=>{p!==void 0&&b.mutate(p.id)},onCancel:()=>g(void 0)})]})}function vme(e){return`${nV(e.mode)} · ${j4(e.slots.length,`keyword`)} · updated ${M4(e.updatedAt)}`}function yme({category:e}){let t=e===`intro`?`before`:`after`;return(0,h.jsx)(Q1,{title:`No ${e}s yet`,children:`An ${e} is narrated ${t} the body in the run's voice.`})}function bme({name:e,className:t}){return(0,h.jsx)(`span`,{"data-slot-chip":e,className:L(`animate-tick-in rounded-control border border-line-strong bg-sunken px-2 py-0.5 font-mono text-label text-ink-2 motion-reduce:animate-none`,t),children:e})}function q4({slots:e,body:t,lint:n,lintId:r,noSlots:i=`No slots. This prompt runs as written.`}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(H,{title:`Detected slots`,info:`library.slots`,size:`small`,className:`pb-0`}),e.length>0?(0,h.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,h.jsx)(bme,{name:e,className:`px-2 py-1`},e))}):t.trim()===``?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Slots appear here as you type {{name}}.`}):(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:i}),n.length===0?null:(0,h.jsxs)(`div`,{id:r,className:`flex flex-col gap-2 border-t border-line pt-3`,children:[(0,h.jsx)(`span`,{className:`sl-kicker text-danger`,children:n.length===1?`1 slot error`:`${String(n.length)} slot errors`}),n.map(e=>(0,h.jsx)(`span`,{className:`text-small text-danger`,children:e.message},e.message))]})]})}function J4({className:e,...t}){return(0,h.jsx)(ry,{"data-slot":`label`,className:L(`engraved block select-none text-ink-3`,e),...t})}function Y4({className:e,...t}){return(0,h.jsx)(Qee,{"data-slot":`toggle-group`,className:L(`inline-flex w-fit items-stretch overflow-hidden rounded-control border border-line-strong`,e),...t})}function X4({className:e,...t}){return(0,h.jsx)(rte,{"data-slot":`toggle-group-item`,className:L(`min-h-8 shrink-0 border-r border-line-strong px-3 py-1 text-label text-ink-2 last:border-r-0`,`transition-colors duration-150 ease-out motion-reduce:transition-none hover:bg-raised hover:text-ink`,`data-[state=on]:bg-raised data-[state=on]:text-ink data-[state=on]:shadow-[inset_0_-2px_0_var(--color-accent)]`,`disabled:cursor-not-allowed disabled:opacity-40`,e),...t})}function Z4({label:e,value:t,options:n,describedBy:r,tip:i,onPick:a}){let o=(0,m.useId)();return(0,h.jsxs)(`div`,{...Ib,children:[(0,h.jsxs)(`div`,{className:`mb-1 flex items-center gap-1`,children:[(0,h.jsx)(J4,{id:o,children:e}),i===void 0?null:(0,h.jsx)(V,{id:i,label:e,className:`-my-1`})]}),(0,h.jsx)(Y4,{type:`single`,value:t,"aria-labelledby":o,"aria-describedby":r,onValueChange:e=>{let t=n.find(t=>t.value===e);t!==void 0&&a(t.value)},children:n.map(e=>(0,h.jsx)(X4,{value:e.value,children:e.label},e.value))})]})}function xme(e){return Q4(e.name,e.body)}function Sme(e){return Q4(e.name,e.body)}function Q4(e,t){let n=[],r=e.trim();if(r===``?n.push({field:`name`,message:`Enter a name.`}):r.length>200&&n.push({field:`name`,message:`Keep the name to 200 characters or fewer.`}),t.trim()===``)return n.push({field:`body`,message:`Enter the text.`}),n;if(t.length>1e5)return n.push({field:`body`,message:`The text is too long. Keep it to ${String(TM)} characters or fewer.`}),n;for(let e of iq(t).errors)n.push({field:`body`,message:Cme(e,t)});return n}function Cme(e,t){let n=wme(t,e.at);switch(e.kind){case`unclosed`:return`The \`{{\` at ${n} is never closed. Add \`}}\` after the keyword name.`;case`empty`:return`The keyword at ${n} has no name. Write a name between \`{{\` and \`}}\`.`;case`nested`:return`The keyword at ${n} contains a brace. Keywords cannot be placed inside other keywords.`}}function wme(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`
|
|
276
276
|
`),i=n.split(`
|
|
@@ -305,6 +305,6 @@ Obelisks`})}):e.mode===`yaml`?(0,h.jsx)(dV,{id:`schedule-topics-yaml`,label:`Top
|
|
|
305
305
|
`)}function Xye({cues:e,duration:t,onChange:n,onPending:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(()=>e.map(e=>({...e,start:String(e.start),end:String(e.end)}))),[s,c]=(0,m.useState)(),[l,u]=(0,m.useState)(!1),d=(0,m.useRef)(r);d.current=r,(0,m.useEffect)(()=>{d.current(l)},[l]),(0,m.useEffect)(()=>()=>d.current(!1),[]);function f(){let e=[],r=new Set,i=0;if(!Number.isFinite(t)||t<=0){c(`The narration length isn't known yet, so captions can't be checked. Reload the page and try again.`);return}for(let[n,o]of a.entries()){let a=o.start.trim()===``?NaN:Number(o.start),s=o.end.trim()===``?NaN:Number(o.end);if(r.has(o.id)){c(`Caption ${n+1}: this caption is listed twice. Remove the copy.`);return}if(r.add(o.id),!Number.isFinite(a)||a<0||a<i){c(`Caption ${n+1}: start must be a number of seconds, no earlier than the previous caption's end.`);return}if(!Number.isFinite(s)||s<=a||s>t){c(`Caption ${n+1}: end must be after its start and no later than the end of the narration.`);return}if(o.text.trim()===``){c(`Caption ${n+1}: enter caption text.`);return}e.push({id:o.id,text:o.text,start:a,end:s,...o.speaker===void 0?{}:{speaker:o.speaker}}),i=s}n(e),c(void 0),u(!1)}return(0,h.jsxs)(`section`,{"aria-label":`Edit caption cues`,className:`space-y-3`,...Ib,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`h3`,{children:`Caption text and timing`}),(0,h.jsx)(V,{id:`project.captions.editor`})]}),a.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]}),(0,h.jsxs)(`label`,{htmlFor:`${i}-${e.id}-text`,className:`block text-small`,children:[`Text for caption `,t+1,(0,h.jsx)(mV,{id:`${i}-${e.id}-text`,value:e.text,onChange:n=>{u(!0),o(a.with(t,{...e,text:n.target.value}))}})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`label`,{htmlFor:`${i}-${e.id}-start`,className:`block text-small`,children:[`Start for caption `,t+1,(0,h.jsx)(pV,{id:`${i}-${e.id}-start`,inputMode:`decimal`,value:e.start,onChange:n=>{u(!0),o(a.with(t,{...e,start:n.target.value}))}})]}),(0,h.jsxs)(`label`,{htmlFor:`${i}-${e.id}-end`,className:`block text-small`,children:[`End for caption `,t+1,(0,h.jsx)(pV,{id:`${i}-${e.id}-end`,inputMode:`decimal`,value:e.end,onChange:n=>{u(!0),o(a.with(t,{...e,end:n.target.value}))}})]})]})]},e.id)),s===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-danger`,children:s}),(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(R,{type:`button`,onClick:f,children:`Apply caption edits to draft`}),(0,h.jsx)(V,{id:`project.captions.apply`})]}),l?(0,h.jsx)(`p`,{children:`Apply these caption edits before saving the project.`}):null]})}function l7(e){return`imagePrompts.${String(e)}`}function u7(e){let t=/^imagePrompts\.(\d+)$/.exec(e??``);return t?.[1]===void 0?void 0:Number(t[1])}function Zye(e,t){return e.length===t.length&&e.every((e,n)=>e.name===t[n]?.name&&e.number===t[n]?.number)}function Qye(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))u7(e)===void 0&&(o[e]=t);for(let[t,n]of Object.entries(e.rendered))u7(t)===void 0&&(s[t]=n);for(let[t,c]of n.entries()){let n=l7(t),l=i[t]??-1;if(l>=0){let t=l7(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);if(u===void 0){a.push({field:`imagePrompts.${String(t)}.name`,message:`The image prompt "${c.name}" is not in the Library any more. Untick it under Images, or add it back on Library → Prompts.`});continue}o[n]=u,s[n]=sq(u,e.values)}if(a.length>0)return{ok:!1,fields:a};let c=new Map;for(let e of r.imageOrder){let n=u7(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=l7(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=u7(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===l7(s)?a:{...a,templateKey:l7(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 $ye({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)(q3,{prompts:o,picked:a.imagePrompts,problem:r,onPick:t=>i({...e,config:{...a,imagePrompts:t}})}),(0,h.jsx)(ebe,{edit:e,saved:t,prompts:o,problem:r})]})}function ebe({edit:e,saved:t,prompts:n,problem:r}){let i=e.config.imagePrompts,a=r(`imagePrompts`);if(Zye(t,i))return a===void 0?null:(0,h.jsx)(d7,{children:a});let o=0,s=Qye({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)(d7,{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)(d7,{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 remake outdated outputs.`})]})}function d7({children:e}){return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:e})}function tbe({edit:e,problem:t,onChange:n}){let r=e.config.ambientBed,[i,a]=(0,m.useState)(()=>r===void 0?void 0:aA(r)),o=r?.source===`upload`?[...Qk,`upload`]:Qk,s=i===void 0?[]:[...ibe(i)];return(0,h.jsx)(O2,{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=oA(t),{ambientBed:i,...o}=e.config;n({...e,config:r===void 0?o:{...o,ambientBed:r}})}})}function nbe({edit:e,problem:t,onChange:n}){let r=e.config.loudness,[i,a]=(0,m.useState)(()=>r===void 0?{...nk,enabled:!1}:{...r,enabled:!0});return(0,h.jsx)(D6,{value:i,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 rbe({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=N6(r[e]);return t===void 0?`Enter a number of seconds.`:xk(t,e===`sentencePauseSeconds`?`sentences`:`paragraphs`)};return(0,h.jsx)(M6,{sentence:r.sentencePauseSeconds,paragraph:r.paragraphPauseSeconds,problem:e=>a(e)??t(e),onChange:(t,a)=>{i({...r,[t]:a});let o=N6(a);if(o===void 0)return;let{[t]:s,...c}=e.config;n({...e,config:o===0?c:{...c,[t]:o}})}})}function ibe(e){let t=oA(e);return t===void 0?[]:rA(t)}function abe({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:ZO(a));if(i.sources.images!==`generate`)return null;let c=a?.words??(JO(e.content.articleMarkdown??``)||1500),l=t=>{s(t);let{imageScale:r,...o}=i;if(t===void 0){n({...e,config:o});return}let l=f7(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:ek(i).reduce((e,t)=>e+t,0),f=o===void 0?void 0:f7(o),p=o===void 0?void 0:f===void 0?{problem:!0,text:o.every===`minutes`?`Enter a number of minutes between ${String(WO)} and 60.`:`Enter a number of images per hour between 1 and 240.`}:{problem:!1,text:`For about ${String(Math.max(1,Math.round(YO(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`,...Ib,children:[(0,h.jsx)(Lb,{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)(Rb,{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:obe(o.value,o.every,e)})}),o.every===`minutes`?(0,h.jsx)(`span`,{children:`One image every`}):null,(0,h.jsx)(pV,{"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 f7(e){let t=Number(e.value.trim());if(e.value.trim()!==``&&Number.isFinite(t))return e.every===`minutes`?t>=.25&&t<=60?XO(t):void 0:t>=1&&t<=240?t:void 0}function obe(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 sbe({edit:e,onChange:t}){let{config:n}=e;return n.sources.images!==`generate`||n.sources.article===`off`?null:(0,h.jsx)(`div`,{className:`flex flex-col items-start gap-2`,...Ib,children:(0,h.jsx)(Lb,{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}:{}}})}})})}function cbe({edit:e,view:t,imageKey:n,index:r}){let{api:i}=z(),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)(j0,{className:`max-w-[240px]`,label:`Video clip ${r+1}`,src:e2(i,t.revision.projectId,t.revision.id,l.recordId)}):(0,h.jsx)(M0,{className:`max-w-[240px]`,alt:`Retained scene ${r+1}`,src:e2(i,t.revision.projectId,t.revision.id,l.recordId)}),(0,h.jsx)(`p`,{children:m?`${p} · video clip, played muted`:p})]})}function p7(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 lbe({edit:e,onChange:t,onPending:n,view:r,getEdit:i}){let a=(0,m.useId)(),[o,s]=(0,m.useState)({}),{content:c}=e,l=qO(e.config),u=(0,m.useRef)(e);u.current=e;function d(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`}:{}}}};u.current=i,t(i)}function f(e,t){let n=i?.()??u.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})),d(A5({...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 p(e){let t=i?.()??u.current,n=t.content,r=crypto.randomUUID();d({...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}}]})}return(0,h.jsxs)(`section`,{"aria-label":`Edit images`,className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`h3`,{children:`Images`}),(0,h.jsx)(V,{id:`project.images.editor`})]}),c.imageOrder.map((t,s)=>{let l=c.imageDefinitions[t];return l===void 0?(0,h.jsxs)(`p`,{role:`alert`,children:[`Image definition missing: `,t]},t):(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line-strong p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Image `,s+1]}),(0,h.jsx)(cbe,{edit:e,view:r,imageKey:t,index:s}),l.source===`generate`?(0,h.jsxs)(`div`,{...Ib,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)(V,{id:`project.images.prompt`,label:`prompt for image ${String(s+1)}`})]}),(0,h.jsx)(mV,{id:`${a}-${t}-prompt`,value:l.templateKey===void 0||l.templateKey===null?l.prompt??``:c.promptTemplates[l.templateKey]??l.prompt??``,onChange:e=>f(t,e.target.value)})]}):null,l.source===`generate`&&l.templateKey==null?(0,h.jsxs)(R,{type:`button`,onClick:()=>f(t,l.prompt??``),children:[`Use saved wording as template for image `,s+1]}):null,(0,h.jsx)(j5,{label:`Replace image ${s+1}`,kind:`images`,onPending:e=>n(`image:${t}`,e),onReady:e=>{let n=i?.()??u.current,r=n.content,a=r.imageDefinitions[t];a!==void 0&&r.imageOrder.includes(t)&&d({...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)(R,{type:`button`,disabled:s===0,onClick:()=>d({...e,content:{...c,imageOrder:p7(c.imageOrder,s,-1)}}),children:[`Move image `,s+1,` earlier`]}),(0,h.jsxs)(R,{type:`button`,disabled:s===c.imageOrder.length-1,onClick:()=>d({...e,content:{...c,imageOrder:p7(c.imageOrder,s,1)}}),children:[`Move image `,s+1,` later`]}),(0,h.jsxs)(R,{type:`button`,onClick:()=>{let n=c.imageOrder.filter(e=>e!==t);d({...e,config:n.length===0?{...e.config,sources:{...e.config.sources,images:`off`,video:`off`}}:e.config,content:{...c,imageOrder:n,imageDefinitions:Object.fromEntries(Object.entries(c.imageDefinitions).filter(([e])=>e!==t))},regenerate:(e.regenerate??[]).filter(e=>e!==`image:${t}`),uploads:(e.uploads??[]).filter(e=>e.destination.kind!==`image`||e.destination.imageKey!==t)})},children:[`Delete image `,s+1,c.imageOrder.length===1?` and turn Images and Video Off`:``]}),l.source===`generate`?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e.regenerate?.includes(`image:${t}`)===!0?(0,h.jsxs)(R,{type:`button`,onClick:()=>d({...e,regenerate:(e.regenerate??[]).filter(e=>e!==`image:${t}`)}),children:[`Keep image `,s+1]}):(0,h.jsxs)(R,{type:`button`,onClick:()=>d({...e,regenerate:[...new Set([...e.regenerate??[],`image:${t}`])]}),children:[`Regenerate image `,s+1]}),(0,h.jsx)(V,{id:`project.images.regenerate`})]}):null]},t)}),(0,h.jsx)(R,{type:`button`,disabled:c.imageOrder.length>=l,onClick:()=>{if(c.imageOrder.length>=l)return;let t=crypto.randomUUID();d({...e,config:{...e.config,sources:{...e.config.sources,images:`generate`}},content:{...c,imageOrder:[...c.imageOrder,t],promptTemplates:{...c.promptTemplates,[`image:${t}`]:``},imageDefinitions:{...c.imageDefinitions,[t]:{source:`generate`,assetId:null,prompt:``,templateKey:`image:${t}`}}}})},children:`Add generated image`}),c.imageOrder.length>=l?(0,h.jsxs)(`p`,{children:[`At most `,l,` images can be included.`]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(j5,{label:`Add provided image`,kind:`images`,onPending:e=>n(`image:new`,e),onReady:p},`new-image:${e.config.sources.images===`off`}`),(0,h.jsx)(j5,{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:p},`new-clip:${e.config.sources.images===`off`}`)]})]})}var ube=q({logicalKey:W().min(1),logicalText:W(),segment:J([`body`,`intro`,`outro`]),text:W()});function dbe(e,t){if(t==null)return e;let n=[...t.intro??[],...t.body??[],...t.outro??[]];return n.length===0?e:n.flatMap(t=>e.filter(e=>e.key===t))}function fbe(e){let t=new Map,n=new Set,r=0;for(let i of e.pieces){if(!i.selected||i.stageKind!==`audio`||i.piece.kind!==`chunk`)continue;let e;try{e=i.piece.payload===null?null:JSON.parse(i.piece.payload)}catch{r++;continue}let a=ube.safeParse(e);if(!a.success){r++;continue}let{logicalKey:o,logicalText:s}=a.data;if(n.has(o)){r++;continue}let c=t.get(o);if(c!==void 0&&c.text!==s){r+=c.parts+1,t.delete(o),n.add(o);continue}t.set(o,{key:o,text:s,parts:(c?.parts??0)+1})}return{groups:[...t.values()],unmapped:r}}function pbe({view:e,edit:t,onChange:n,onPending:r,getEdit:i}){let a=(0,m.useId)(),{api:o}=z(),s=P({queryKey:[`narration-chunks`,e.revision.projectId,e.revision.id],queryFn:async()=>{let t=await Hfe(o,e.revision.projectId,e.revision.id);return t.ok?t.value.chunks:null},staleTime:1/0}),c=fbe(e),l=dbe(c.groups,s.data),u=c.unmapped,d=(0,m.useRef)(t);d.current=t;let[f,p]=(0,m.useState)({});function g(e){d.current=e,n(e)}return(0,h.jsxs)(`section`,{"aria-label":`Edit narration`,className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`h3`,{children:`Narration`}),(0,h.jsx)(V,{id:`project.narration.editor`})]}),t.config.chunking?.mode===`whole`||t.config.chunking===void 0?(0,h.jsx)(`p`,{children:`This narration uses one whole request. Editing its text rebuilds the whole narration request.`}):null,u===0?null:(0,h.jsx)(`p`,{children:`Some older audio cannot be matched reliably to its narration text. Replace the provided narration or rebuild from the article to edit those chunks.`}),l.map((e,n)=>{let o=t.content.narrationOverrides[e.key];return(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line-strong p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Narration chunk `,n+1]}),(0,h.jsxs)(`p`,{children:[e.parts,` audio `,e.parts===1?`part`:`parts`,` in this narration chunk.`]}),(0,h.jsxs)(`div`,{className:`text-small`,...Ib,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:`${a}-${e.key}-text`,children:[`Text for narration chunk `,n+1]}),(0,h.jsx)(V,{id:`project.narration.chunk-text`,label:`text for narration chunk ${String(n+1)}`})]}),(0,h.jsx)(mV,{id:`${a}-${e.key}-text`,value:o?.kind===`text`?o.text:e.text,onChange:n=>{p(t=>({...t,[e.key]:(t[e.key]??0)+1})),g({...t,...t.uploads===void 0?{}:{uploads:t.uploads.filter(t=>t.destination.kind!==`narration`||t.destination.key!==e.key)},content:{...t.content,narrationOverrides:{...t.content.narrationOverrides,[e.key]:{kind:`text`,text:n.target.value}}}})}})]}),(0,h.jsx)(j5,{label:`Replace narration chunk ${n+1}`,kind:`audio`,onPending:t=>r(`narration:${e.key}`,t),onReady:t=>{let n=i?.()??d.current;g({...n,regenerate:(n.regenerate??[]).filter(t=>t!==e.key),uploads:[...(n.uploads??[]).filter(t=>t.destination.kind!==`narration`||t.destination.key!==e.key),{stagedFileId:t.id,destination:{kind:`narration`,key:e.key}}]})}},`${e.key}:${f[e.key]??0}`),t.regenerate?.includes(e.key)?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-accent-ink`,children:[`Narration chunk `,n+1,` will be regenerated after you save and press Remake.`,(0,h.jsxs)(R,{type:`button`,variant:`quiet`,onClick:()=>{let t=i?.()??d.current;g({...t,regenerate:(t.regenerate??[]).filter(t=>t!==e.key)})},children:[`Keep narration chunk `,n+1]})]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsxs)(R,{type:`button`,onClick:()=>{let t=i?.()??d.current,n={...t.content.narrationOverrides};n[e.key]?.kind===`asset`&&delete n[e.key],p(t=>({...t,[e.key]:(t[e.key]??0)+1})),g({...t,content:{...t.content,narrationOverrides:n},uploads:t.uploads?.filter(t=>t.destination.kind!==`narration`||t.destination.key!==e.key),regenerate:[...new Set([...t.regenerate??[],e.key])]})},children:[`Regenerate narration chunk `,n+1,` after review`]}),(0,h.jsx)(V,{id:`project.narration.regenerate`})]})]},e.key)})]})}function mbe(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(m7))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`)&&m7(e.output.durationMs))?.output.durationMs;return m7(s)?s/1e3:void 0}function m7(e){return e!=null&&Number.isFinite(e)&&e>0}function hbe({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?g6:{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)(_6,{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:A5(d,`referencePrompt`,u.body);r(n.source===`provide`?f:l(f))},upload:(0,h.jsx)(j5,{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 gbe=q({words:K(q({text:W().trim().min(1),start:G().finite().nonnegative(),end:G().finite().positive(),confidence:G().optional(),speaker:W().min(1).optional()})).min(1)});function h7(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 _be({view:e,edit:t,fields:n,onChange:r,onPending:i,section:a}){let{api:o}=z(),s=P(ub(o)).data?.prompts??[],c=h7(t),l=t.config.sources.audio!==`off`&&c===h7({config:e.revision.config,content:e.revision.content}),u=e.revision.fingerprints[`subtitles:timing`],d=l?mbe(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=(0,m.useRef)(void 0),S=(0,m.useRef)(!0),C=(0,m.useCallback)((e,t)=>{S.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)(()=>(S.current=!0,()=>{S.current=!1,x.current?.abort(),g.current(!1)}),[]),(0,m.useEffect)(()=>{let t=e.revision.id;return()=>{(p.current.revisionId!==t||p.current.identity!==c)&&x.current?.abort()}},[e.revision.id,c]);function w(e){let t=p.current.onChange;p.current={...p.current,edit:e,identity:h7(e)},t(e)}async function T(){if(x.current!==void 0)return;let t=new AbortController;x.current=t;let n=p.current;C(`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 subtitle timing is ready.`);let i=await o.fetch(e2(o,e.revision.projectId,e.revision.id,r.recordId),{signal:t.signal});if(!i.ok)throw Error(`The subtitle timing file couldn't be read. Reload the page and try again; if it still fails, use More → make it again in its section on Audio.`);let a=gbe.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 subtitle timing doesn't match the current narration. Use More → make it again in its section on Audio to rebuild it.`);s=e.end}let c=Yye(a.words).map(e=>({...e,id:crypto.randomUUID()})),l=p.current;if(!S.current||t.signal.aborted||l.revisionId!==n.revisionId||l.identity!==n.identity||l.edit.content.subtitleCues!==n.edit.content.subtitleCues)return;w({...l.edit,content:{...l.edit.content,subtitleCues:{audioFingerprint:u,cues:c}}})}catch(e){S.current&&!t.signal.aborted&&b(e instanceof Error?e.message:String(e))}finally{x.current===t&&(x.current=void 0),C(`captions:load`,!1)}}let E=t.content.subtitleCues,D=e=>a===void 0||a===e;return(0,h.jsxs)(`div`,{className:`space-y-5`,children:[(0,h.jsxs)(`section`,{"aria-label":`Images`,hidden:!D(`images`),className:`space-y-6`,children:[(0,h.jsx)($ye,{edit:t,saved:e.revision.config.imagePrompts,prompts:s,problem:e=>n.find(t=>t.field===e||t.field===`config.${e}`)?.message,onChange:w}),(0,h.jsx)(abe,{edit:t,problem:e=>n.find(t=>t.field===e||t.field===`config.${e}`)?.message,onChange:w}),(0,h.jsx)(sbe,{edit:t,onChange:w}),(0,h.jsx)(hbe,{edit:t,prompts:s,problem:e=>n.find(t=>t.field===e||t.field===`content.${e}`)?.message,getEdit:()=>p.current.edit,onChange:w,onPending:e=>C(`provided:reference`,e)}),t.config.sources.thumbnail===`from_prompt`||t.config.sources.thumbnail===`prompt_by_llm`?(0,h.jsx)(P6,{value:t.config.thumbnailCount===3?3:1,onPick:e=>{let{thumbnailCount:t,...n}=p.current.edit.config;w({...p.current.edit,config:e===3?{...n,thumbnailCount:3}:n})}}):null,[`audio`,`thumbnail`].map(e=>t.config.sources[e]===`provide`?(0,h.jsx)(j5,{label:`Replace provided ${e}`,kind:e,onPending:t=>C(`provided:${e}`,t),onReady:t=>{let n=p.current;n.edit.config.sources[e]===`provide`&&w({...n.edit,uploads:[...(n.edit.uploads??[]).filter(t=>t.destination.kind!==`provided`||t.destination.stage!==e),{stagedFileId:t.id,destination:{kind:`provided`,stage:e}}]})}},e):null),(0,h.jsx)(lbe,{getEdit:()=>p.current.edit,view:e,edit:t,onChange:w,onPending:C})]}),(0,h.jsx)(`section`,{"aria-label":`Narration`,hidden:!D(`narration`),className:`space-y-5`,children:t.config.sources.audio===`generate`?(0,h.jsx)(pbe,{getEdit:()=>p.current.edit,view:e,edit:t,onChange:w,onPending:C}):null}),y===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-danger`,children:y}),(0,h.jsxs)(`section`,{"aria-label":`Captions`,hidden:!D(`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 subtitle timing is ready.`}),E===void 0?(0,h.jsx)(R,{type:`button`,disabled:!f||_.has(`captions:load`),onClick:()=>void T(),children:`Edit existing caption cues`}):(0,h.jsxs)(h.Fragment,{children:[E.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)(Xye,{cues:E.cues,duration:d,onPending:e=>C(`captions:dirty`,e),onChange:e=>{let t=p.current,n=t.edit.content.subtitleCues;n!==void 0&&w({...t.edit,content:{...t.edit.content,subtitleCues:{...n,cues:e}}})}},`${e.revision.id}:${u}`):null,(0,h.jsx)(R,{type:`button`,onClick:()=>w({...t,content:{...t.content,subtitleCues:void 0}}),children:`Discard caption edits`})]})]})]})}function vbe({edit:e,error:t,onChange:n}){return(0,h.jsx)(`div`,{className:`mb-5`,children:(0,h.jsx)(D2,{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}})}})})}function ybe({edit:e,saved:t,problem:n,onChange:r}){let{api:i}=z(),a=P(ax(i)),{config:o}=e,s=e=>e!==void 0&&(a.data?.some(t=>t.id===e)??!0)?e:Qb,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)(dV,{label:`Channel`,tip:`play.channel`,error:n(`channelId`),help:l===void 0?void 0:(0,h.jsxs)(ma,{to:`/channels/$channelId`,params:{channelId:l.id},className:`underline`,children:[`Edit `,l.name]}),children:(0,h.jsxs)(hV,{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)(Lb,{checked:u,label:`Use the channel's brand kit`,tip:`play.brand-kit`,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 colours, title style, end screen, intro, outro and document theme 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 bbe(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=H6([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 xbe({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)(m6,{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:A5(e,`narration`,r.body);i({...o,config:{...o.config,narrationPrompt:t}})}})}function Sbe({edit:e,saved:t=e.config.imagePrompts,prompts:n,entries:r,onChange:i}){let a=(0,m.useId)(),o=[...new Set([...Object.keys(e.config.rendered),...Object.keys(e.content.promptTemplates),...e.config.sources.article===`generate`?[`article`]:[],...dj(e.config)?[`narration`]:[],...mj(e.config)&&e.config.descriptionPrompt?[`description`]:[],...vj(e.config)&&e.config.shorts?.prompt?[`shorts`]:[],...vj(e.config)&&e.config.shorts?.imagePrompt?[`shortsImage`]:[],...[`from_prompt`,`prompt_by_llm`].includes(e.config.sources.thumbnail)?[`thumbnailPrompt`]:[],...gj(e.config)&&e.config.reference?.source===`prompt`?[`referencePrompt`]:[],...e.config.intro===void 0?[]:[`intro`],...e.config.outro===void 0?[]:[`outro`]])].filter(n=>{let r=y7(n);if(r===void 0)return!0;let i=t[r]?.name;return i===void 0||e.config.imagePrompts.some(e=>e.name===i)}),s=e.config.imagePrompts.filter(e=>!t.some(t=>t.name===e.name)),c=e=>Tbe(e,t),l=[...new Set([...Object.keys(e.config.values),...Object.values(e.content.promptTemplates).flatMap(e=>e===null?[]:iq(e).names)])].filter(e=>!aq.includes(e)),u=t=>[...iq(e.config.title).names.includes(t)?[`Project title`]:[],...Object.entries(e.content.promptTemplates).flatMap(([e,n])=>n!==null&&iq(n).names.includes(t)?[c(e)]:[])],d=iq(e.config.title).names;return(0,h.jsxs)(`section`,{"aria-label":`Prompt snapshots`,className:`space-y-6`,children:[o.map(o=>{let s=c(o),l=e.content.promptTemplates[o]??null,u=o===`intro`||o===`outro`?r.filter(e=>e.category===o):n.filter(t=>t.kind===(o===`article`?WA(e.config)?`script`:`article`:o===`narration`?`narration`:o===`description`?`description`:o===`shorts`?`shorts`:o===`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:s}),l===null?(0,h.jsx)(vI,{tone:`info`,title:`Original template unavailable`,actions:(0,h.jsx)(R,{"aria-label":`Use saved wording as template for ${s}`,onClick:()=>i(A5(e,o,e.config.rendered[o]??``)),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)(wbe,{label:s,raw:l,library:Cbe(e,o,u,t),onUse:t=>i(A5(e,o,t))}),(0,h.jsx)(dV,{label:`Use saved template for ${s}`,id:`${a}-library-${o}`,tip:`project.prompts.template`,children:(0,h.jsxs)(hV,{value:``,onChange:t=>{let n=u.find(e=>e.id===t.target.value);if(n===void 0)return;let r=A5(e,o,n.body),a=`category`in n?{...r.config,[n.category]:{name:n.name,mode:n.mode}}:o===`article`?{...r.config,articlePrompt:n.name}:o===`narration`?{...r.config,narrationPrompt:n.name}:o===`description`?{...r.config,descriptionPrompt:n.name}:(o===`shorts`||o===`shortsImage`)&&r.config.shorts!==void 0?{...r.config,shorts:{...r.config.shorts,[o===`shorts`?`prompt`:`imagePrompt`]:n.name}}:o===`thumbnailPrompt`?{...r.config,thumbnailPrompt:n.name}:o===`referencePrompt`&&r.config.reference!==void 0?{...r.config,reference:{...r.config.reference,prompt:n.name}}:r.config;i({...r,config:a})},children:[(0,h.jsx)(`option`,{value:``,children:`Choose a saved template`}),u.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,h.jsx)(dV,{label:`Raw prompt for ${s}`,id:`${a}-raw-${o}`,tip:`project.prompts.raw`,children:(0,h.jsx)(mV,{rows:4,value:l??``,onChange:t=>i(A5(e,o,t.target.value))})}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{className:`text-small text-ink-2`,children:`Saved rendered prompt`}),(0,h.jsx)(`pre`,{className:`m-0 mt-2 whitespace-pre-wrap break-words text-small`,children:e.config.rendered[o]??``})]})]},o)}),s.length===0?null:(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[s.map(e=>`"${e.name}"`).join(`, `),` `,s.length===1?`uses its`:`use their`,` Library wording. Save, then change it here.`]}),l.length?(0,h.jsxs)(`section`,{"aria-label":`Keywords`,className:`space-y-3 pt-3`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:`Keywords`}),(0,h.jsx)(u0,{fieldPrefix:`config.values`,keywords:l.map(t=>({name:t,value:e.config.values[t]??``,feeds:u(t),topic:d.includes(t)})),onChange:(t,n)=>i(k5({...e,config:{...e.config,values:{...e.config.values,[t]:n}}}))})]}):null]})}function Cbe(e,t,n,r){let{config:i}=e,a=y7(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 g7=`slopify.library-kept`;function _7(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 v7(){try{let e=window.localStorage.getItem(g7),t=e===null?[]:JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function wbe({label:e,raw:t,library:n,onUse:r}){let i=n===void 0||t===null?``:`${e}:${_7(t)}:${_7(n.body)}`,[a,o]=(0,m.useState)(()=>v7().includes(i));return n===void 0||t===null||n.body===t||a?null:(0,h.jsx)(vI,{tone:`info`,title:`The Library's "${n.name}" has changed since this project copied it`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R,{"aria-label":`Use the Library version for ${e}`,onClick:()=>{r(n.body)},children:`Use the Library version`}),(0,h.jsx)(R,{variant:`quiet`,"aria-label":`Keep this project's version for ${e}`,onClick:()=>{try{window.localStorage.setItem(g7,JSON.stringify([...v7().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 Library version marks what it wrote as outdated, to remake when you are ready.`})}function y7(e){let t=/^imagePrompts\.(\d+)$/.exec(e);return t?.[1]===void 0?void 0:Number(t[1])}function Tbe(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=y7(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 Ebe(e,t,n){let{api:r}=z(),[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 qs(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)(R,{type:`button`,variant:`quiet`,disabled:i.busy,onClick:()=>void c(),children:i.busy?`Copying…`:`Update from other projects`}),(0,h.jsx)(V,{id:`project.edit.update-glossary`})]}):void 0;return{value:s?.shareGlossary===!0,onChange:e=>{e?c():l()},note:d}}function Dbe(e,t){let{api:n}=z(),[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 Js(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 Library → Aliases.`:`${String(c)} ${c===1?`alias`:`aliases`} copied from Library → Aliases.`:`Couldn't read Library → Aliases: ${r.error} Try Update from Library again.`,(0,h.jsx)(R,{type:`button`,variant:`quiet`,disabled:r.busy,onClick:()=>void s(),children:r.busy?`Copying…`:`Update from Library`}),(0,h.jsx)(V,{id:`project.edit.update-aliases`})]}):void 0}}function Obe({projectId:e,edit:t,providers:n,voices:r,onChange:i}){let{config:a}=t,o=a.llm??{provider:``,model:``},s=a.audio??{provider:``,model:``,voice:``},c=Ebe(e,t,i),l=Dbe(t,i),{api:u}=z(),d=P(ox(u,a.channelId??`00000000-0000-4000-8000-000000000001`)),f=a.images??{provider:``,model:``},p=dj(a)||a.sources.audio===`generate`&&a.audio?.describeFigures===!0||a.sources.research===`generate`||a.sources.article===`generate`||a.sources.thumbnail===`prompt_by_llm`||UA(a)&&a.voices?.source===`attribute`||a.sources.audio===`generate`&&(a.intro?.mode===`llm`||a.outro?.mode===`llm`),m=a.sources.images===`generate`||a.sources.thumbnail===`from_prompt`||a.sources.thumbnail===`prompt_by_llm`,g=r.filter(e=>e.provider===s.provider).map(e=>({value:e.voiceId,label:e.name}));return(0,h.jsxs)(`section`,{"aria-label":`Generation providers`,className:`grid min-w-0 gap-3 sm:grid-cols-2`,children:[p?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(OV,{label:`Text provider`,tip:`play.llm.provider`,family:`llm`,providers:n,value:o.provider,problem:void 0,onPick:e=>i({...t,config:{...a,llm:{provider:e,model:``}}})}),(0,h.jsx)(kV,{label:`Text model`,tip:`play.llm.model`,provider:o.provider,value:o.model,problem:void 0,onPick:e=>i({...t,config:{...a,llm:{...o,model:e}}})}),(0,h.jsx)(v6,{choice:o,onChange:e=>i({...t,config:{...a,llm:e}})})]}):null,a.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[a.voices!==void 0&&a.intro===void 0&&a.outro===void 0?null:(0,h.jsxs)(h.Fragment,{children:[a.voices===void 0?null:(0,h.jsx)(`p`,{className:`col-span-full m-0 text-small text-ink-2`,children:`The voice below reads only the intro and outro. Each speaker's voice is set under Speakers.`}),(0,h.jsx)(OV,{label:a.voices===void 0?`Narration provider`:`Intro and outro provider`,tip:`play.tts.provider`,family:`tts`,providers:n,value:s.provider,problem:void 0,onPick:e=>i({...t,config:{...a,audio:{...s,provider:e,model:``,voice:``}}})}),(0,h.jsx)(kV,{label:a.voices===void 0?`Narration model`:`Intro and outro model`,tip:`play.tts.model`,provider:s.provider,value:s.model,problem:void 0,onPick:e=>i({...t,config:{...a,audio:{...s,model:e}}})}),(0,h.jsx)(TV,{label:a.voices===void 0?`Narration voice`:`Intro and outro voice`,tip:`play.voice`,value:s.voice,problem:void 0,placeholder:`Choose a saved voice`,options:s.voice!==``&&!g.some(e=>e.value===s.voice)?[{value:s.voice,label:`${s.voice} (saved voice)`},...g]:g,onPick:e=>i({...t,config:{...a,audio:{...s,voice:e}}})})]}),(0,h.jsx)(G3,{value:a.chunking??{mode:`whole`},onPick:e=>i({...t,config:{...a,chunking:e}})}),(0,h.jsx)(h6,{shared:c,value:s.usePronunciationGlossary,supported:Cj({sources:a.sources,audio:{...s,usePronunciationGlossary:!0}}),onChange:e=>i({...t,config:{...a,audio:{...s,usePronunciationGlossary:e}}})}),(0,h.jsx)(p6,{...l}),(0,h.jsx)(d6,{tip:`project.edit.describe-figures`,value:s.describeFigures,skipCode:s.skipCode,onChange:({describeFigures:e,skipCode:n})=>{let{describeFigures:r,skipCode:o,...c}=s;i({...t,config:{...a,audio:{...c,...e?{describeFigures:e}:{},...e&&n?{skipCode:n}:{}}}})}}),(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)(u6,{value:a.voices,cast:d.data?.cast??[],language:a.language,providers:n,voices:r,script:t.content.articleMarkdown??void 0,onChange:e=>{let{voices:n,...r}=a;i({...t,config:e===void 0?r:{...r,voices:e}})}})]})]}):null,m?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(OV,{label:`Image provider`,tip:`play.images.provider`,family:`image`,providers:n,value:f.provider,problem:void 0,onPick:e=>i({...t,config:{...a,images:{provider:e,model:``}}})}),(0,h.jsx)(kV,{label:`Image model`,tip:`play.images.model`,provider:f.provider,value:f.model,problem:void 0,onPick:e=>i({...t,config:{...a,images:{...f,model:e}}})}),(0,h.jsx)(v6,{field:`images.thinking`,label:`Effort`,tip:`play.images.effort`,choice:f,onChange:e=>i({...t,config:{...a,images:e}})})]}):null]})}function kbe({edit:e,providers:t,prompts:n,problem:r,onChange:i}){let{config:a}=e,o=a.reviews===void 0?MV:Mk(a.reviews),[s,c]=(0,m.useState)(o),l=a.shorts?.enabled===!0&&a.sources.audio!==`off`,u=e=>Pk({sources:a.sources,shorts:l?{enabled:!0}:void 0},e),d=Nk(s,u).retriesProblem;return(0,h.jsx)(NV,{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}=Nk(t,u),o={...e.content.promptTemplates},s={...a.rendered};for(let e of wk){let t=jk(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(k5({...e,config:{...d,rendered:s,...r===void 0?{}:{reviews:r}},content:{...e.content,promptTemplates:o}}))}})}function Abe({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===b7&&e.state===`ready`),l=e.regenerate?.includes(b7)===!0;return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(x6,{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?jbe(e):A5(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 press Remake.`,(0,h.jsx)(R,{type:`button`,variant:`quiet`,onClick:()=>{i({...e,regenerate:(e.regenerate??[]).filter(e=>e!==b7)})},children:`Keep the current description`})]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(R,{type:`button`,onClick:()=>{i({...e,regenerate:[...new Set([...e.regenerate??[],b7])]})},children:`Write the description again after review`}),(0,h.jsx)(V,{id:`project.edit.rewrite-description`})]}):null]})}var b7=`youtube:description`;function jbe(e){let{description:t,...n}=e.content.promptTemplates,{description:r,...i}=e.config.rendered;return k5({config:{...e.config,rendered:i},content:{...e.content,promptTemplates:n}})}var Mbe={research:`Research source`,article:`Article source`,audio:`Audio source`,images:`Images source`,thumbnail:`Thumbnail source`,video:`Video source`,document:`Document source`},Nbe={research:`play.source.research`,article:`play.source.article`,audio:`play.source.audio`,images:`play.source.images`,thumbnail:`play.source.thumbnail`,video:`play.source.video`,document:`play.source.document`},Pbe=`\0kept:`;function x7({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:L(`grid min-w-0 gap-4`,n&&`md:grid-cols-2`),children:t})]})}function Fbe(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??`inputs`);(0,m.useEffect)(()=>{e.focus!==void 0&&c(e.focus.section)},[e.focus]);let[l,u]=(0,m.useState)({font:!1,content:!1,music:!1});(0,m.useEffect)(()=>{i(l.font||l.content||l.music)},[i,l]);let d=(0,m.useCallback)(e=>{u(t=>t.font===e?t:{...t,font:e})},[]),f=(0,m.useCallback)(e=>{u(t=>t.content===e?t:{...t,content:e})},[]),p=(0,m.useCallback)(e=>{u(t=>t.music===e?t:{...t,music:e})},[]),{api:g}=z(),_=P(cb(g)),v=P(lb(g)),y=P(ub(g)),b=P(db(g)),{config:x}=n,S=bbe(t,n,P(ox(g,x.channelId??`00000000-0000-4000-8000-000000000001`)).data?.cast??[]),C=S?.image.kind===`output`?t.outputs.find(e=>e.selected&&e.available&&S.image.kind===`output`&&e.output.id===S.image.outputId):void 0,w=C===void 0?void 0:e2(g,t.revision.projectId,t.revision.id,C.recordId),T=e=>a.find(t=>t.field===e||t.field===`config.${e}`||t.field===`edit.config.${e}`)?.message,E=S6({value:x.videoEdit,narrated:x.sources.audio!==`off`,imageProvider:x.images?.provider??``,problem:T,language:x.language,onChange:e=>r({...n,config:{...x,videoEdit:e}})}),D=[{id:`inputs`,label:`Inputs`},...x.sources.article===`off`?[]:[{id:`article`,label:`Article`,...n.content.articleEdited?{badge:`edited`}:{}}],{id:`providers`,label:`Providers`},{id:`prompts`,label:`Prompts`},{id:`reviews`,label:`Reviews`,...x.reviews===void 0?{}:{badge:`on`}},...x.sources.audio!==`off`||x.shorts?.enabled===!0?[{id:`shorts`,label:`Shorts`,...x.shorts?.enabled?{badge:`on`}:{}}]:[],...x.sources.article===`off`?[]:[{id:`subtitles`,label:`Subtitles`}],{id:`images`,label:`Images`,badge:String(n.content.imageOrder.length)},...x.sources.audio===`generate`?[{id:`narration`,label:`Narration`}]:[],...x.sources.article===`off`?[]:[{id:`captions`,label:`Captions`,...n.content.subtitleCues===void 0?{}:{badge:String(n.content.subtitleCues.cues.length)}}]],O=D.some(e=>e.id===s)?s:`inputs`,k=e=>L(`min-w-0 space-y-6`,O===e?void 0:`hidden`),A=e=>Number.isFinite(e)?e:``,j=x.sources.video!==`off`;return(0,h.jsxs)(`div`,{className:`grid min-w-0 gap-8 md:grid-cols-[180px_minmax(0,1fr)]`,children:[(0,h.jsx)(`nav`,{"aria-label":`Edit sections`,className:`min-w-0 md:sticky md:top-16 md:self-start`,children:(0,h.jsx)(`ul`,{className:`m-0 flex list-none gap-1 overflow-x-auto p-0 [scrollbar-width:none] md:flex-col`,children:D.map(e=>(0,h.jsx)(`li`,{className:`shrink-0`,children:(0,h.jsx)($6,{current:e.id===O,onClick:()=>c(e.id),meta:e.badge,className:`whitespace-nowrap`,children:e.label})},e.id))})}),(0,h.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[Object.entries({providers:_.error,voices:v.error,prompts:y.error,entries:b.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":`Inputs`,hidden:O!==`inputs`,className:k(`inputs`),children:[(0,h.jsxs)(x7,{title:`Project`,children:[(0,h.jsx)(dV,{label:`Project title`,error:T(`title`),className:`md:col-span-2`,children:(0,h.jsx)(pV,{value:x.title,maxLength:200,onChange:e=>r({...n,config:{...x,title:e.target.value}})})}),(0,h.jsx)(`div`,{className:`md:col-span-2`,children:(0,h.jsx)(V6,{value:x.format,onPick:e=>r({...n,config:{...x,format:e}})})})]}),(0,h.jsx)(Tq,{}),(0,h.jsx)(x7,{title:`Channel`,columns:!1,children:(0,h.jsx)(ybe,{edit:n,saved:t.revision.config,problem:T,onChange:r})}),(0,h.jsx)(Tq,{}),(0,h.jsxs)(x7,{title:`Stages`,children:[US.filter(e=>x.sources.article!==`off`||e!==`research`&&e!==`audio`&&e!==`document`).map(e=>(0,h.jsx)(dV,{label:Mbe[e],tip:Nbe[e],error:T(`sources.${e}`),children:(0,h.jsx)(hV,{value:KS(x.sources,e),onChange:i=>{let a=IN(e).find(e=>e.value===i.target.value);if(a===void 0)return;let o=eye(n,e,a.value);r(e===`article`&&a.value===`provide`&&!n.content.articleEdited?{...o,content:{...o.content,articleMarkdown:t.articleMarkdown??n.content.articleMarkdown}}:o)},children:IN(e).filter(t=>e!==`thumbnail`||t.value!==`prompt_by_llm`||x.sources.article!==`off`).map(t=>(0,h.jsx)(`option`,{value:t.value,disabled:e===`video`&&t.value===`generate`&&x.sources.images===`off`,children:t.label},t.value))})},e)),x.sources.images===`off`?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2 md:col-span-2`,children:`Images are Off. Video is also Off in these changes.`}):null,(0,h.jsx)(dV,{label:`Document theme`,id:`${o}-document-theme`,tip:`play.document-theme`,children:(0,h.jsx)(U3,{id:`${o}-document-theme`,disabled:KS(x.sources,`document`)===`off`,value:x.document,onChange:e=>{r({...n,config:{...x,document:e}})}})})]}),(0,h.jsx)(Tq,{}),(0,h.jsxs)(x7,{title:`Timing`,children:[(0,h.jsx)(dV,{label:`Silence gap (seconds)`,tip:`play.silence-gap`,error:T(`silenceGapSeconds`),children:(0,h.jsx)(pV,{type:`number`,min:0,max:30,step:.1,value:A(x.silenceGapSeconds),onChange:e=>r({...n,config:{...x,silenceGapSeconds:Number(e.target.value)}})})}),x.sources.audio===`off`?null:(0,h.jsx)(dV,{label:`Silence at start and end (seconds)`,tip:`play.edge-silence`,error:T(`edgeSilenceSeconds`),children:(0,h.jsx)(pV,{type:`number`,min:0,max:30,step:.5,value:A(x.edgeSilenceSeconds),onChange:e=>r({...n,config:{...x,edgeSilenceSeconds:Number(e.target.value)}})})}),j?(0,h.jsx)(dV,{label:`Seconds per image`,tip:`play.image-seconds`,error:T(`imageSeconds`),children:(0,h.jsx)(pV,{type:`number`,min:1,max:600,step:1,value:A(x.imageSeconds),onChange:e=>r({...n,config:{...x,imageSeconds:Number(e.target.value)}})})}):null,j?(0,h.jsx)(dV,{label:`Zoom (%)`,tip:`play.zoom`,error:T(`zoomPercent`),children:(0,h.jsx)(pV,{type:`number`,min:0,max:50,step:.5,value:A(x.zoomPercent),onChange:e=>r({...n,config:{...x,zoomPercent:Number(e.target.value)}})})}):null,j?(0,h.jsx)(dV,{label:`Motion`,tip:`play.motion`,children:(0,h.jsx)(hV,{value:x.motionStyle,onChange:e=>r({...n,config:{...x,motionStyle:e.target.value}}),children:qS.map(e=>(0,h.jsx)(`option`,{value:e,children:XA[e]},e))})}):null]}),j?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Tq,{}),(0,h.jsxs)(x7,{title:`Cuts and look`,columns:!1,children:[E.cuts,E.look,x.sources.audio===`generate`&&x.audio?.describeFigures===!0?(0,h.jsx)(f6,{tip:`project.edit.show-figures`,value:x.showFigures,onChange:e=>{let{showFigures:t,...i}=x;r({...n,config:e?{...i,showFigures:!0}:i})}}):null]}),x.sources.audio===`off`?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Tq,{}),(0,h.jsx)(x7,{title:`Ambient sound`,columns:!1,children:(0,h.jsx)(tbe,{edit:n,problem:T,onChange:r})})]})]}):null,x.sources.audio===`off`?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Tq,{}),(0,h.jsxs)(x7,{title:`Pauses and volume`,columns:!1,children:[(0,h.jsx)(rbe,{edit:n,problem:T,onChange:r}),(0,h.jsx)(nbe,{edit:n,problem:T,onChange:r})]})]}),(0,h.jsx)(Tq,{}),(0,h.jsx)(x7,{title:`Intro and outro`,children:[`intro`,`outro`].map(e=>{let i=x[e]?.name,a=t.revision.content.promptTemplates[e],o=b.data?.entries.find(t=>t.category===e&&t.name===i),s=i!==void 0&&o!==void 0&&typeof a==`string`&&t.revision.config[e]?.name===i&&a!==o.body,c=n.content.promptTemplates[e],l=`${Pbe}${i??``}`,u=i===void 0?``:s&&c!==o?.body?l:i;return(0,h.jsx)(dV,{label:e===`intro`?`Intro`:`Outro`,tip:e===`intro`?`play.intro`:`play.outro`,children:(0,h.jsxs)(hV,{value:u,onChange:i=>{if(i.target.value===l&&typeof a==`string`){r(k5({...n,config:{...x,[e]:t.revision.config[e]},content:{...n.content,promptTemplates:{...n.content.promptTemplates,[e]:a}}}));return}let o=b.data?.entries.find(t=>t.category===e&&t.name===i.target.value),s={...x};o===void 0?delete s[e]:s[e]={name:o.name,mode:o.mode},r(k5({...n,config:s,content:o===void 0?n.content:{...n.content,promptTemplates:{...n.content.promptTemplates,[e]:o.body}}}))},children:[(0,h.jsx)(`option`,{value:``,children:`Off`}),i!==void 0&&!b.data?.entries.some(t=>t.category===e&&t.name===i)?(0,h.jsxs)(`option`,{value:i,children:[i,` (saved entry)`]}):null,s?(0,h.jsxs)(`option`,{value:l,children:[i,` · this project's version`]}):null,b.data?.entries.filter(t=>t.category===e).map(e=>(0,h.jsx)(`option`,{value:e.name,children:s&&e.name===i?`${e.name} · Library version (newer)`:e.name},e.id))]})},e)})}),x.sources.research===`provide`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Tq,{}),(0,h.jsx)(x7,{title:`Research`,columns:!1,children:(0,h.jsx)(dV,{label:`Research notes`,tip:`play.provided.research`,error:T(`provided.research`),children:(0,h.jsx)(mV,{rows:6,value:x.provided.research??``,onChange:e=>r({...n,config:{...x,provided:{...x.provided,research:e.target.value}}})})})})]}):null]}),(0,h.jsxs)(`section`,{"aria-label":`Article`,hidden:O!==`article`,className:k(`article`),children:[(0,h.jsx)(dV,{label:`Article text`,tip:`project.edit.article-text`,error:T(`content.articleMarkdown`)??T(`provided.article`),help:n.content.articleEdited?`Your edited article is kept when other settings change. Regenerating it replaces it after the rebuild review.`:void 0,children:(0,h.jsx)(mV,{rows:12,maxLength:5e5,value:(n.content.articleEdited?n.content.articleMarkdown:t.articleMarkdown)??n.content.articleMarkdown??x.provided.article??``,onChange:e=>r({...n,content:{...n.content,articleMarkdown:e.target.value,articleEdited:!0}})})}),x.sources.article===`generate`?(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(R,{onClick:()=>r({...n,regenerate:[...new Set([...n.regenerate??[],`article:body`])]}),children:`Regenerate article after review`}),(0,h.jsx)(V,{id:`project.edit.regenerate-article`})]}):null]}),(0,h.jsxs)(`section`,{"aria-label":`Providers`,hidden:O!==`providers`,className:k(`providers`),children:[(0,h.jsx)(vbe,{edit:n,error:T(`language`),onChange:r}),(0,h.jsx)(Obe,{projectId:t.revision.projectId,edit:n,providers:_.data?.providers??[],voices:v.data?.voices??[],onChange:r}),(0,h.jsx)(xbe,{edit:n,view:t,prompts:y.data?.prompts??[],error:T(`narrationPrompt`),onChange:r})]}),(0,h.jsxs)(`section`,{"aria-label":`Prompts`,hidden:O!==`prompts`,className:k(`prompts`),children:[(0,h.jsx)(Abe,{edit:n,view:t,prompts:y.data?.prompts??[],problem:T,onChange:r}),(0,h.jsx)(Sbe,{edit:n,saved:t.revision.config.imagePrompts,prompts:y.data?.prompts??[],entries:b.data?.entries??[],onChange:r})]}),(0,h.jsx)(`section`,{"aria-label":`Reviews`,hidden:O!==`reviews`,className:k(`reviews`),children:(0,h.jsx)(kbe,{edit:n,providers:_.data?.providers??[],prompts:y.data?.prompts??[],problem:T,onChange:r})}),(0,h.jsx)(`section`,{"aria-label":`Shorts`,hidden:O!==`shorts`,className:k(`shorts`),children:(0,h.jsx)(rye,{edit:n,view:t,prompts:y.data?.prompts??[],problem:T,onChange:r,onPending:p})}),(0,h.jsxs)(`section`,{"aria-label":`Subtitles`,hidden:O!==`subtitles`,className:k(`subtitles`),children:[(0,h.jsx)(`div`,{"data-tour":`project-subtitles`,children:(0,h.jsx)(B6,{value:x.subtitles??gM,format:x.format,audioEnabled:x.sources.audio!==`off`,videoEnabled:j,onChange:e=>r({...n,config:{...x,subtitles:kN(e,x.sources)}}),onUploading:d,problem:T})}),O!==`subtitles`||!j?null:(0,h.jsx)(E6,{drawnOn:S?.drawnOn,poster:w,settings:{format:x.format,subtitles:{mode:(x.subtitles??gM).mode,fontId:(x.subtitles??gM).fontId,fontSize:(x.subtitles??gM).fontSize,position:(x.subtitles??gM).position??`bottom`},videoEdit:x.videoEdit,image:S?.image}})]}),e.renderContent?.({view:t,edit:n,fields:a,onChange:r,onPending:f,section:O})]})]})}var S7={notes:`Research notes`,article_md:`Article (Markdown)`,article_txt:`Article text`,narration_txt:`Clean Narration`,tts_script:`TTS Script`,sources:`Research sources`,glossary:`Glossary`,audio_body:`Narration`,audio_intro:`Intro narration`,audio_outro:`Outro narration`,audio_export:`Audio export`,image:`Image`,thumbnail:`Thumbnail`,video:`Video`,render_params:`Export settings`,subtitles_srt:`Subtitles (SRT)`,subtitles_vtt:`Subtitles (VTT)`,subtitle_words:`Subtitle timing`,subtitle_ass:`Styled subtitles`,subtitle_font:`Subtitle font`,instructions:`Generation instructions`,document_pdf:`Document (PDF)`,youtube_description:`YouTube description`,youtube_tags:`YouTube tags`,youtube_pinned_comment:`Pinned comment`,youtube_titles:`Other titles`,shorts:`Shorts list`,short_image:`Short image`,short_video:`Short`,animated_image:`Animated image`,figure_card:`On-screen card`,reference:`Establishing image (reference)`,script_md:`Script (speaker split)`,audio_mp3:`Audio (MP3 with chapters)`,audio_m4b:`Audiobook (M4B with chapters)`,audio_levelled:`Levelled narration`};function C7(e){return(e.role===`narration_txt`||e.role===`tts_script`)&&e.meta.segment?`${e.meta.segment===`body`?`Body`:e.meta.segment===`intro`?`Intro`:`Outro`} ${S7[e.role]}`:e.role===`short_video`&&typeof e.meta.short==`number`?`Short ${String(e.meta.short)}`:e.role===`short_image`&&typeof e.meta.short==`number`?`Short ${String(e.meta.short)} image ${String(e.meta.index??1)}`:e.role===`figure_card`&&typeof e.meta.index==`number`?`On-screen card ${String(e.meta.index)}`:e.role===`animated_image`&&typeof e.meta.index==`number`?`Animated image ${String(e.meta.index)}`:e.role===`image`&&typeof e.meta.index==`number`?`Image ${e.meta.index}`:S7[e.role]}function Ibe(e){if(e.startsWith(`image:`))return`Image`;if(e.startsWith(`animate:`))return S7.animated_image;if(/^shorts:\d+:render$/.test(e))return S7.short_video;if(/^shorts:\d+:image:\d+$/.test(e))return S7.short_image;if(e===`document:pdf`)return S7.document_pdf;let t=e.split(`:`).at(-1);return Object.entries(S7).find(([e])=>e===t)?.[1]??`Saved output`}function Lbe({preview:e,pending:t,feedback:n,onStart:r,onCancel:i}){let a=Hbe(e),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),u=(0,m.useId)(),d=e.work.filter(e=>e.disposition===`blocked`),f=e.providedReuseRequired.filter(e=>!o.includes(e)),p=e.work.filter(e=>e.disposition===`generate`||e.disposition===`local`||e.disposition===`review`).length,g=p===1?`Remake 1 output`:`Remake ${String(p)} outputs`,_=[...d.length===0?[]:[`${d.length===1?`1 item is`:`${d.length} items are`} unavailable (reasons above)`],...f.map(e=>`tick “Keep the provided content for ${a(e)}”`),...e.costs.unknown===0||c?[]:[`tick “I understand that ${e.costs.unknown} cost estimates are unknown”`]],v=_.length===0,y=zbe.map(t=>({disposition:t,count:e.work.filter(e=>e.disposition===t).length})).filter(e=>e.count>0),b=e.costs.rows.some(e=>e.onPlan===!0),x=e.costs.apiLow,S=e.costs.apiHigh;return(0,h.jsxs)(`section`,{"aria-label":`Review affected rebuild`,className:`flex flex-col gap-5`,children:[(0,h.jsxs)(`dl`,{className:`m-0 grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-3`,children:[y.map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col`,children:[(0,h.jsx)(`dt`,{className:`order-2 text-small text-ink-2`,children:O7[e.disposition]}),(0,h.jsx)(`dd`,{className:`order-1 m-0 font-condensed text-title-2 tabular-nums`,children:e.count})]},e.disposition)),(0,h.jsxs)(`div`,{className:`flex flex-col`,children:[(0,h.jsx)(`dt`,{className:`order-2 text-small text-ink-2`,children:e.costs.unknown>0?`known cost`:`cost`}),(0,h.jsx)(`dd`,{className:`order-1 m-0 font-condensed text-title-2 tabular-nums`,children:D7(e.costs.low,e.costs.high)})]})]}),b?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`CLI work: $0 on your plan${x===void 0||S===void 0?``:` · ~${D7(x,S)} via API`}.`}):null,d.length===0?null:(0,h.jsx)(vI,{tone:`danger`,title:`${d.length===1?`1 item can’t`:`${d.length} items can’t`} run, so this rebuild can’t start`,children:(0,h.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5`,children:Bbe(d,a).map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsxs)(`span`,{className:`font-semibold`,children:[e.what,`:`]}),` `,e.reason]},e.reason))})}),e.wholeRequestNotice===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.wholeRequestNotice}),e.warnings.map(e=>(0,h.jsx)(`p`,{className:`m-0 text-small text-waiting`,children:e},e)),(0,h.jsxs)(`div`,{className:`flex flex-col divide-y divide-line border-y border-line`,children:[e.review?.inputChanges.length?(0,h.jsx)(w7,{summary:`Changed inputs (${String(e.review.inputChanges.length)})`,children:(0,h.jsx)(`dl`,{className:`m-0 flex flex-col gap-3`,children:e.review.inputChanges.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`dt`,{className:`font-semibold`,children:e.label}),(0,h.jsxs)(`dd`,{className:`m-0 grid gap-2 sm:grid-cols-2`,children:[(0,h.jsx)(T7,{label:`Before`,text:e.before}),(0,h.jsx)(T7,{label:`After`,text:e.after})]})]},e.label))})}):null,(0,h.jsxs)(w7,{summary:`Work items (${e.work.length}): ${y.map(e=>`${e.count} ${O7[e.disposition]}`).join(`, `)||`none`}`,children:[e.changedInputs.length===0?null:(0,h.jsx)(`ul`,{className:`m-0 mb-3 flex flex-col gap-1 pl-5`,children:e.changedInputs.map(e=>(0,h.jsxs)(`li`,{children:[a(e.path),`:`,` `,e.after===null?`Removed`:e.before===null?`New output`:`Inputs changed`]},e.path))}),(0,h.jsx)(`ul`,{className:`m-0 flex flex-col gap-2 pl-5`,children:e.work.map(t=>(0,h.jsxs)(`li`,{children:[a(t.key),`: `,O7[t.disposition],`. `,t.reason,t.inflight?` An already submitted request may still be billed.`:``,e.review?.requests.filter(e=>e.key===t.key).map(e=>(0,h.jsxs)(`div`,{children:[e.settings===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.settings}),e.text===null?null:(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small`,children:`View request text`}),(0,h.jsx)(`pre`,{className:`m-0 max-h-56 overflow-auto whitespace-pre-wrap break-words font-mono text-small`,children:e.text})]})]},e.key))]},t.key))}),(0,h.jsxs)(`p`,{className:`m-0 mt-3 text-small text-ink-2`,children:[`Retained outputs:`,` `,e.retained.map(e=>Ibe(e.slot)).join(`, `)||`None`]})]}),e.costs.rows.length===0?null:(0,h.jsx)(w7,{summary:`Cost by step`,children:(0,h.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5`,children:e.costs.rows.map(e=>(0,h.jsxs)(`li`,{children:[a(e.stage),`: `,Rbe(e),`. `,e.detail]},`${e.stage}-${e.detail}`))})})]}),n,(0,h.jsxs)(`div`,{className:`sticky bottom-[-16px] -mx-4 flex flex-col gap-3 border-t border-line bg-raised px-4 py-3`,children:[e.providedReuseRequired.length===0&&e.costs.unknown===0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small`,children:[e.providedReuseRequired.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start gap-1`,...Ib,children:[(0,h.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,className:`mt-1`,disabled:t,checked:o.includes(e),onChange:t=>s(t.target.checked?[...o,e]:o.filter(t=>t!==e))}),(0,h.jsxs)(`span`,{children:[`Keep the provided content for `,a(e)]})]}),(0,h.jsx)(V,{id:`project.rebuild.keep-provided`,className:`-my-1`})]},e)),e.costs.unknown===0?null:(0,h.jsxs)(`div`,{className:`flex items-start gap-1`,...Ib,children:[(0,h.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,className:`mt-1`,disabled:t,checked:c,onChange:e=>l(e.target.checked)}),(0,h.jsxs)(`span`,{children:[`I understand that `,e.costs.unknown,` cost estimates are unknown.`]})]}),(0,h.jsx)(V,{id:`project.rebuild.unknown-costs`,className:`-my-1`})]})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(R,{variant:`primary`,disabled:t||!v,"aria-describedby":v?void 0:u,onClick:()=>r({acknowledgeUnknownCosts:c,confirmedProvidedWorkKeys:o}),children:t?`Starting the remake…`:g}),(0,h.jsx)(R,{disabled:t,onClick:i,children:`Keep things as they are`}),v||t?null:(0,h.jsx)(`p`,{id:u,className:`m-0 min-w-0 text-small text-ink-2`,children:`${g} is off until: ${_.join(`; `)}.`})]})]})]})}function w7({summary:e,children:t}){return(0,h.jsxs)(`details`,{className:`py-3 text-small`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer font-semibold text-ink`,children:e}),(0,h.jsx)(`div`,{className:`mt-3`,children:t})]})}function T7({label:e,text:t}){return(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:e}),(0,h.jsx)(`pre`,{className:`m-0 max-h-40 overflow-auto whitespace-pre-wrap break-words text-small`,children:t??`Not set`})]})}var E7=e=>e===null?`Unknown`:e===0?`$0`:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,maximumFractionDigits:e>0&&e<.01?4:2}).format(e);function D7(e,t){return e===t?E7(e):`${E7(e)}–${E7(t)}`}function Rbe(e){return e.onPlan===!0?`$0 on plan${e.apiLow===void 0||e.apiLow===null||e.apiHigh===void 0?``:` · ~${D7(e.apiLow,e.apiHigh??null)} via API`}`:D7(e.low,e.high)}var zbe=[`generate`,`local`,`review`,`reuse`,`blocked`];function Bbe(e,t){let n=new Map;for(let t of e){let e=t.reason.trim()||`No reason was given.`;n.set(e,[...n.get(e)??[],t.key])}return[...n].map(([e,n])=>({reason:e,what:n.length===1?t(n[0]??``):`${n.length} ${new Set(n.map(A7)).size===1?Vbe(A7(n[0]??``)):`items`}`}))}function Vbe(e){return/s$/u.test(e)?e:`${e.charAt(0).toLowerCase()}${e.slice(1)}s`}var O7={reuse:`kept as they are`,generate:`to make`,local:`built on this computer`,review:`to confirm`,blocked:`can't run`},k7={"export:wav":`Audio export (WAV)`,"export:video":`Video export`,"subtitles:timing":`Subtitle timing`,"subtitles:cues":`Caption text and timing`,"subtitles:files":`Subtitle files`,"article:body":`Article`,"audio:provided":`Provided narration`,"audio:body:concat":`Combined narration`,"audio:intro":`Combined intro narration`,"audio:outro":`Combined outro narration`,"research:planner":`Research plan`,"research:notes":`Research notes`,"entry:intro:text":`Intro text`,"entry:outro:text":`Outro text`};function A7(e){let t=k7[e];return t===void 0?{image:`Image request`,images:`Images`,audio:`Narration request`,article:`Article`,research:`Research`,thumbnail:`Thumbnail`,subtitles:`Subtitles`,video:`Video export`,export:`Export`,entry:`Intro or outro`}[e.split(`:`)[0]??``]??`Output`:t}function Hbe(e){let t=new Map,n=new Map;for(let t of e.work){let e=A7(t.key);n.set(e,(n.get(e)??0)+1)}let r=new Map;for(let i of e.work){let e=A7(i.key),a=(r.get(e)??0)+1;r.set(e,a),t.set(i.key,(n.get(e)??0)>1?`${e} ${a}`:e)}for(let n of e.review?.requests??[])t.set(n.key,n.label);return e=>t.get(e)??A7(e)}var Ube={llm:`Text generation`,image:`Images`,images:`Images`,tts:`Audio`,audio:`Audio`};function j7({error:e,refusal:t}){let n=(0,m.useRef)(null);return(0,m.useEffect)(()=>{(e!==void 0||t!==void 0)&&n.current?.focus()},[e,t]),e===void 0&&t===void 0?null:(0,h.jsxs)(`div`,{ref:n,role:`alert`,tabIndex:-1,"data-tone":`danger`,className:`sl-callout sl-callout--danger outline-none`,children:[(0,h.jsx)(Xc,{"aria-hidden":`true`,strokeWidth:1.75}),(0,h.jsx)(`p`,{className:`sl-callout__title m-0`,children:e??(t?.reason===`readiness`?t.fields.length>0?`This can't start yet. Fix the items below, then try again.`:`Slopify couldn't check your providers. Open Settings → Providers, make sure each one you use is set up, then try again.`:t?.message)}),t?.fields.length?(0,h.jsx)(`ul`,{className:`sl-callout__body m-0 list-disc pl-5`,children:t.fields.map(({field:e,message:t})=>(0,h.jsxs)(`li`,{children:[Ube[e.split(`.`)[0]??``]??`Project`,`: `,t]},`${e}:${t}`))}):null]})}var Wbe=q({text:W().optional(),logicalText:W().optional(),title:W().optional(),notes:W().optional(),outline:K(W()).optional(),prompt:W().optional()});function Gbe(e){if(e===null)return`No text was recorded for this part.`;try{let t=Wbe.safeParse(JSON.parse(e));if(!t.success)return`Recorded text cannot be decoded.`;let{logicalText:n,text:r,title:i,notes:a,outline:o,prompt:s}=t.data;return[n,r,a?.trim()?[i,a].filter(e=>e?.trim()).join(`
|
|
306
306
|
|
|
307
307
|
`):void 0,o?.filter(e=>e.trim()).map((e,t)=>`${t+1}. ${e}`).join(`
|
|
308
|
-
`),s].find(e=>e?.trim())??`No text was recorded for this part.`}catch{return`Recorded text cannot be decoded.`}}function Kbe({projectId:e,pending:t,onRestore:n}){let{api:r}=z(),[i,a]=(0,m.useState)(),o=P({queryKey:B.revisions(e),queryFn:async()=>{let t=await Vfe(r,e);if(!t.ok)throw Error(t.message);return t.value.revisions}}),s=P({queryKey:B.revision(e,i??``),enabled:i!==void 0,queryFn:async()=>{if(i===void 0)throw Error(`Choose a version from History first.`);let t=await Q0(r,e,i);if(!t.ok)throw Error(t.message);return t.value.view}}),c=s.data,l=c?.outputs.find(e=>e.selected&&e.available&&(e.output.role===`image`||e.output.role===`thumbnail`)),u=l??c?.outputs.find(e=>e.available);return(0,h.jsxs)(`section`,{"aria-label":`Project history`,className:`space-y-3`,children:[(0,h.jsx)(H,{title:`Project history`}),o.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:o.error.message}),(0,h.jsx)(`ol`,{className:`space-y-2`,children:o.data?.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(R,{type:`button`,onClick:()=>a(e.id),children:[e.title,` · `,e.createdAt,e.current?` · Current`:``]})},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:s.error.message}),c===void 0?null:(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:c.revision.config.title}),(0,h.jsxs)(Py,{children:[(0,h.jsx)(R,{variant:`primary`,disabled:t,onClick:()=>n(c.revision.id),children:`Restore this revision`}),l===void 0?null:(0,h.jsxs)(SS,{href:Kfe(r,e,c.revision.id),download:!0,children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,strokeWidth:1.75}),`Download all images`]}),u===void 0?null:(0,h.jsx)(r2,{projectId:e,asset:``,folder:{revisionId:c.revision.id,recordId:u.recordId}})]}),(0,h.jsx)(`ul`,{className:`m-0 list-none space-y-3 p-0`,children:c.outputs.map(t=>(0,h.jsxs)(`li`,{className:`space-y-2 border-t border-line pt-3 first:border-t-0 first:pt-0`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,h.jsxs)(`span`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`font-semibold text-ink`,children:C7(t.output)}),(0,h.jsxs)(`span`,{className:`text-small text-ink-2`,children:[` · ${t.state}${t.selected?``:` · Earlier result`}`,t.available?``:` · File missing`]})]}),t.available?(0,h.jsxs)(SS,{href:e2(r,e,c.revision.id,t.recordId),download:!0,size:`small`,"aria-label":`Download ${C7(t.output)}`,children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,strokeWidth:1.75}),`Download`]}):null]}),t.available?(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Preview retained output`}),t.output.role===`video`?(0,h.jsx)(j0,{className:`max-w-[640px]`,label:C7(t.output),src:e2(r,e,c.revision.id,t.recordId)}):[`audio_export`,`audio_body`,`audio_intro`,`audio_outro`].includes(t.output.role)?(0,h.jsx)(Z8,{label:C7(t.output),src:e2(r,e,c.revision.id,t.recordId)}):t.output.role===`image`||t.output.role===`thumbnail`?(0,h.jsx)(M0,{className:`max-w-[480px]`,alt:C7(t.output),title:C7(t.output),meta:t.selected?`Current`:`Earlier result`,src:e2(r,e,c.revision.id,t.recordId)}):(0,h.jsx)(`p`,{children:`Use Download to inspect this retained file.`})]}):null]},t.recordId))}),(0,h.jsx)(`ul`,{"aria-label":`Retained narration parts`,children:c.pieces.filter(e=>e.stageKind===`audio`&&e.assetId!==null).map(t=>(0,h.jsxs)(`li`,{children:[`Narration part `,t.piece.idx,t.selected?``:` · Earlier result`,t.available?(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Preview retained audio part`}),(0,h.jsx)(Z8,{label:`Narration part ${String(t.piece.idx)}`,src:e2(r,e,c.revision.id,t.recordId)}),(0,h.jsxs)(SS,{href:e2(r,e,c.revision.id,t.recordId),download:!0,size:`small`,children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,strokeWidth:1.75}),`Download narration part`]})]}):(0,h.jsx)(`span`,{children:` · File missing`})]},t.recordId))}),(0,h.jsx)(`ul`,{"aria-label":`Retained text parts`,children:c.pieces.filter(e=>e.assetId===null).map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(`details`,{children:[(0,h.jsxs)(`summary`,{children:[e.stageKind,` part `,e.piece.idx]}),(0,h.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:Gbe(e.piece.payload)})]})},e.recordId))})]})]})}function M7(e,t,n){let r=JSON.stringify(t);return e?.payload===r?e:{payload:r,idempotencyKey:n()}}function qbe(e,t,n={}){let{api:r}=z(),i=_(),a=P({queryKey:B.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 Q0(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=(0,m.useRef)(void 0),T=(0,m.useRef)(void 0),E=(0,m.useRef)(void 0),D=(0,m.useRef)(n.onOpenEdit);D.current=n.onOpenEdit;let O=(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]),k=c!==void 0&&o!==void 0&&t!==null&&t!==o.revision.id,A=(0,m.useRef)(!1);async function j(e){if(!A.current){A.current=!0,g(!0),x(void 0),C(void 0);try{await e()}catch(e){x(e instanceof Error?e.message:String(e))}finally{A.current=!1,g(!1)}}}async function ee(t){let n=await X0(r,e);if(!n.ok){C(n);return}return C(void 0),s(n.value.view),t&&l({config:structuredClone(n.value.view.revision.config),content:structuredClone(n.value.view.revision.content)}),n.value.view}async function te(t){let n=await jo(r,e);return i.setQueryData(B.project(e),n),await i.invalidateQueries({queryKey:B.revisions(e)}),!t.current||n.revisionId!==t.revision.id?(C({ok:!1,reason:`conflict`,message:`The project changed again. Your draft is preserved.`,currentRevisionId:n.revisionId,fields:[]}),!1):(s(t),l(void 0),C(void 0),d(void 0),!0)}async function M(){if(v||o===void 0||c===void 0)return;let t={baseRevisionId:o.revision.id,edit:c},n=M7(w.current,t,()=>crypto.randomUUID());w.current=n;let i=await Z0(r,e,{...t,idempotencyKey:n.idempotencyKey});if(!i.ok){C(i);return}await te(i.value.view),w.current=void 0}async function ne(t,n=u){if(n===void 0)return;let a={baseRevisionId:n.baseRevisionId,previewId:n.id,...t},o=M7(E.current,a,()=>crypto.randomUUID());E.current=o;let s=await Wfe(r,e,{...a,idempotencyKey:o.idempotencyKey});if(!s.ok){C(s),(s.reason===`stale-preview`||s.reason===`conflict`)&&d(void 0);return}E.current=void 0,d(void 0),await i.invalidateQueries({queryKey:B.project(e)})}async function N(t,n){let i=await ee(!1);if(i===void 0)return;let a=await Ufe(r,e,{baseRevisionId:i.revision.id,request:t});if(!a.ok){C(a);return}let o=a.value.value;if(E.current=void 0,n&&Jbe(o)){await ne({acknowledgeUnknownCosts:!1,confirmedProvidedWorkKeys:[]},o);return}d(o)}async function re(t){let n=o??a.data??await ee(!1);if(n===void 0)return;let i={baseRevisionId:n.revision.id,targetRevisionId:t},s=M7(T.current,i,()=>crypto.randomUUID());T.current=s;let c=await Bfe(r,e,{...i,idempotencyKey:s.idempotencyKey});if(!c.ok){C(c);return}await te(c.value.view),T.current=void 0}return{saved:a,view:o,edit:c,preview:u,focus:f,pending:h,uploading:v,error:b,refusal:S,unsaved:O,remoteChanged:k,busy:h||v||c!==void 0||u!==void 0,setEdit:l,setUploading:y,openEditor:()=>void j(async()=>{await ee(!0)}),discard:()=>{l(void 0),C(void 0),y(!1),w.current=void 0},save:()=>void j(M),reloadDraft:()=>void j(async()=>{w.current=void 0,y(!1),await ee(!0),C(void 0)}),reloadCurrent:()=>void j(async()=>{T.current=void 0,E.current=void 0,d(void 0),await ee(!1),await i.invalidateQueries({queryKey:B.project(e)})}),requestEdit:e=>void j(async()=>{let t=o,n=c;if(t===void 0||n===void 0){if(t=await ee(!1),t===void 0)return;n={config:structuredClone(t.revision.config),content:structuredClone(t.revision.content)}}l(e.change(n,t)),p({section:e.section}),D.current?.()}),regenerateNow:t=>void j(async()=>{let n=e=>({...e,regenerate:[...new Set([...e.regenerate??[],...t])]});if(c!==void 0&&O){l(n(c)),p({section:`images`}),D.current?.();return}let i=await ee(!1);if(i===void 0)return;let a=await Z0(r,e,{baseRevisionId:i.revision.id,edit:n({config:structuredClone(i.revision.config),content:structuredClone(i.revision.content)}),idempotencyKey:crypto.randomUUID()});if(!a.ok){C(a);return}await te(a.value.view)&&await N({kind:`selected`,workKeys:t},!0)}),review:(e,t)=>void j(()=>N(e,t?.autoStart===!0)),start:e=>void j(()=>ne(e)),closePreview:()=>{h||(d(void 0),E.current=void 0)},restore:e=>void j(()=>re(e))}}function Jbe(e){return!e.work.some(e=>e.disposition===`blocked`)&&e.providedReuseRequired.length===0&&e.costs.unknown===0}function Ybe({controller:e,renderEditor:t,active:n=!0,intro:r}){let i=e;return i.view===void 0||i.edit===void 0?(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[r??(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(H,{title:`Saved revision`,info:`project.saved-revision`}),i.saved.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:i.saved.error.message}),i.saved.data===void 0?null:(0,h.jsx)(`ul`,{"aria-label":`Saved output status`,className:`sl-list m-0 list-none p-0`,children:i.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:C7(e.output)}),(0,h.jsx)(`span`,{className:`sl-row__meta`,children:e.available?e.state===`ready`?`Ready`:e.state===`outdated`?`Outdated; the retained version stays until it is remade`:`Provided content needs review`:`Retained file missing`})]},e.recordId))})]}),i.preview===void 0&&n?(0,h.jsx)(j7,{error:i.error,refusal:i.refusal}):null,(0,h.jsxs)(K1,{children:[i.refusal?.reason===`conflict`&&n?(0,h.jsx)(R,{disabled:i.pending,onClick:i.reloadCurrent,children:`Reload current revision`}):null,(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(R,{disabled:i.busy,onClick:()=>i.review({kind:`allAffected`}),variant:`secondary`,children:`Choose what to remake`}),(0,h.jsx)(V,{id:`project.choose-remake`})]}),(0,h.jsx)(R,{variant:`primary`,disabled:i.busy,onClick:i.openEditor,children:`Edit project`})]})]}):(0,h.jsxs)(`form`,{"aria-label":`Edit project`,onSubmit:e=>{e.preventDefault(),i.save()},children:[(0,h.jsx)(`fieldset`,{disabled:i.pending,className:`m-0 min-w-0 border-0 p-0`,children:t({view:i.view,edit:i.edit,fields:i.refusal?.fields??[],onChange:i.setEdit,onPending:i.setUploading,...i.focus===void 0?{}:{focus:i.focus}})}),i.preview===void 0?(0,h.jsx)(j7,{error:i.error,refusal:i.refusal}):null,(0,h.jsxs)(K1,{status:(0,h.jsx)(G1,{tone:i.remoteChanged?`warning`:`info`,children:i.remoteChanged?`A newer revision is available. Your unsaved changes are kept below.`:i.uploading?`Waiting for uploads to finish…`:void 0}),children:[i.remoteChanged||i.refusal?.reason===`conflict`?(0,h.jsx)(R,{disabled:i.pending||i.uploading,onClick:i.reloadDraft,children:`Reload current revision and discard my draft`}):null,(0,h.jsx)(R,{variant:`quiet`,disabled:i.pending||i.uploading,onClick:i.discard,children:`Discard changes`}),(0,h.jsx)(R,{variant:`primary`,type:`submit`,disabled:i.pending||i.uploading,children:`Save changes`})]})]})}function Xbe({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)(j7,{error:r.error,refusal:r.refusal}),r.edit===void 0&&r.refusal?.reason===`conflict`?(0,h.jsx)(R,{disabled:r.pending,onClick:r.reloadCurrent,className:`self-start`,children:`Reload current revision`}):null]}):null,(0,h.jsx)(Kbe,{projectId:t,pending:r.busy,onRestore:r.restore})]}):null}function Zbe({controller:e}){let t=e;return(0,h.jsx)(XP,{open:t.preview!==void 0,title:`Choose what to remake`,onClose:t.closePreview,children:t.preview===void 0?null:(0,h.jsx)(Lbe,{preview:t.preview,feedback:(0,h.jsx)(j7,{error:t.error,refusal:t.refusal}),pending:t.pending,onStart:t.start,onCancel:t.closePreview},t.preview.id)})}var Qbe=(e,t)=>{if(t)return`waiting`;switch(e.state){case`running`:return`running`;case`done`:case`provided`:return`done`;case`failed`:return e.retryAt===void 0?`failed`:`waiting`;default:return`off`}},$be=(e,t)=>{if(t)return`Held for you`;switch(e.state){case`running`:return`Running`;case`done`:return`Done`;case`provided`:return`Provided`;case`failed`:return e.retryAt===void 0?`Failed`:`Waiting to try again`;case`canceled`:return`Canceled`;case`skipped`:return`Off`;case`pending`:return`Not started`}};function exe(e,t){if(e.startedAt===null)return;let n=Date.parse(e.startedAt),r=e.finishedAt===null?t:Date.parse(e.finishedAt);if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return;let i=Math.round((r-n)/1e3);if(i<1)return;if(i<60)return`${String(i)} s`;let a=Math.round(i/60);return a<60?`${String(a)} min`:`${String(Math.floor(a/60))} h ${String(a%60)} min`}function txe(e,t,n){let r=C3(t,n);return r===void 0?e:e===void 0||e===``?w3(r):`${e} · ${w3(r)}`}function nxe({stages:e,outputs:t,project:n,resumable:r,held:i,now:a}){return e.filter(e=>e.state!==`skipped`).map(e=>{let o=i.some(t=>t.stage===e.kind),s=exe(e,a);return{id:e.id,name:e.kind===`video`&&iF(n.config)===`audio`?`Audio export`:t5[e.kind],tone:Qbe(e,o),state:$be(e,o),...s===void 0?{}:{time:s},detail:o?`Held for your review`:txe(lF(e,t,n,r),e,a)}})}function rxe({stages:e}){return(0,h.jsx)(`div`,{className:`sr-only`,children:e.filter(e=>e.state!==`skipped`).map(e=>(0,h.jsx)(`span`,{role:`status`,"aria-live":`polite`,children:`${t5[e.kind]}: ${e.state}`},e.id))})}function ixe({steps:e}){return(0,h.jsxs)(`section`,{"aria-labelledby":`run-steps-title`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(H,{id:`run-steps-title`,title:`Run`,size:`small`,className:`pb-0`}),(0,h.jsx)(E3,{steps:e,label:`Run steps`,dense:!0})]})}var N7=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function axe({cost:e,onOpen:t}){if(e===void 0||e.calls===0&&e.byStage.length===0)return null;let n=e.plans.flatMap(e=>e.reported?e.windows.map(t=>({key:`${e.account}/${t.kind}`,name:e.name,window:t.kind===`five_hour`?`5-hour`:t.kind===`weekly`?`weekly`:`current`,used:t.usedPercent,now:t.nowPercent})):[]);return(0,h.jsxs)(`section`,{"aria-labelledby":`cost-so-far-title`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(H,{id:`cost-so-far-title`,title:`Cost so far`,size:`small`,className:`pb-0`,children:t===void 0?null:(0,h.jsx)(R,{variant:`quiet`,size:`small`,onClick:t,children:`By stage`})}),(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[(0,h.jsx)(`strong`,{className:`text-ink`,children:a7(e.cost)}),e.unpriced>0?` known, spent`:` spent`,e.apiEquivalent===null?null:` · ~${a7(e.apiEquivalent)} via API`,e.run===null||e.run.running?null:` · ${o7(e.run.workingMs)} of work`]}),n.map(e=>{let t=e.used<1?`under 1%`:`${N7.format(e.used)}%`,n=`${e.window} ${e.name} limit`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`${e.name}: ${t} of your ${e.window} limit`}),(0,h.jsx)(G2,{value:e.used/100,label:`Share of the ${n} this run used`,valueText:`${t} of your ${n}; now at ${N7.format(e.now)}%`,tone:e.now>=80?`waiting`:`accent`})]},e.key)})]})}function oxe({projectId:e,revisionId:t,title:n,open:r,onClose:i}){let{api:a}=z(),o=_(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(null),p=Iy(),g=(0,m.useRef)(!1),v=(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 y(){if(!s||g.current||!s.name.trim())return;g.current=!0,u(!0),f(null);let t=JSON.stringify([e,s.revisionId,s.name.trim()]);v.current?.key!==t&&(v.current={key:t,id:crypto.randomUUID()});try{let t=await Bq(a,e,{id:v.current.id,name:s.name.trim(),revisionId:s.revisionId});if(!t.ok){v.current=null,f(t.message);return}v.current=null,i(),p(`Template saved.`,`success`),await o.invalidateQueries({queryKey:Aq})}catch(e){f(e instanceof Error?e.message:`The template wasn't saved. Press Save template to try again.`)}finally{g.current=!1,u(!1)}}return(0,h.jsx)(Ry,{open:r&&s!==null,onOpenChange:e=>{!e&&!g.current&&i()},title:`Save as template`,description:`Save this revision’s setup for a fresh Play draft. This does not rebuild the project.`,children:(0,h.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,h.jsx)(dV,{label:`Template name`,tip:`play.template-name`,children:(0,h.jsx)(pV,{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)(R,{disabled:l,onClick:i,children:`Cancel`}),(0,h.jsx)(R,{variant:`primary`,type:`submit`,disabled:l||!s?.name.trim(),children:`Save template`})]})]})})}var P7=q({baseRevisionId:W().min(1).max(64),idempotencyKey:TD()}).strict(),sxe=iO(`kind`,[q({kind:mO(`resume`)}).strict(),q({kind:mO(`retry`),stage:J(US)}).strict(),q({kind:mO(`rerun`),stage:J(US)}).strict(),q({kind:mO(`redo`),item:W().min(1).max(200)}).strict()]);P7.extend({action:sxe}).strict();var cxe=iO(`ok`,[q({ok:mO(!0),value:z0.and(q({warnings:K(W()).readonly()}))}),q({ok:mO(!1),reason:J([`no-project`,`no-revision`,`conflict`,`idempotency-conflict`,`invalid-edit`,`stale-preview`,`invalid-selection`,`review-required`,`cost-ack-required`,`readiness`,`running`,`accepted-job`,`control-changed`]),fields:K(q({field:W(),message:W()})).readonly().optional(),intentRevisionId:W().optional(),currentRevisionId:W().nullable().optional()})]),F7=new Set([400,404,409]);async function lxe(e,t,n){return L7(e,t,`cancel`,n)}async function uxe(e,t,n){return L7(e,t,`pause`,n)}function dxe(e,t,n){return R7(e,t,`resume`,n)}function fxe(e,t,n,r){return R7(e,t,`stages/${n}/retry`,r)}function pxe(e,t,n,r){return R7(e,t,`stages/${n}/soften`,r)}function mxe(e,t,n,r){return R7(e,t,`stages/${n}/rerun`,r)}async function hxe(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/providers`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function gxe(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/subtitles`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function _xe(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/article`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({markdown:n})}))}async function vxe(e,t,n){return I7(await e.client.projects[`:id`].images[`:outputId`].$delete({param:{id:t,outputId:n}}))}async function yxe(e,t,n){return I7(await e.client.projects[`:id`].images[`:outputId`].regenerate.$post({param:{id:t,outputId:n}}))}async function I7(e){if(e.ok)return{ok:!0,value:await e.json()};let t=await mo(e);if(t!==void 0&&F7.has(e.status))return{ok:!1,message:po(e,t).message};throw po(e,t)}async function L7(e,t,n,r){let i=P7.parse(r);return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)}))}async function R7(e,t,n,r){let i=await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(P7.parse(r))});if(i.ok){let e=cxe.parse(await i.json());if(!e.ok)throw Error(xo);return{ok:!0,value:e.value,warnings:e.value.warnings}}let a=await mo(i);if(a!==void 0&&F7.has(i.status))return{ok:!1,message:po(i,a).message};throw po(i,a)}function bxe(e){let{api:t}=z(),n=_(),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(),s=(0,m.useRef)(new Map),c=(0,m.useRef)(!1),l=F({mutationFn:async e=>{let r=e.action;if(![`pause`,`cancel`,`resume`,`retry`,`soften`,`rerun`].includes(r.kind))return B7(t,e.projectId,r);let i=r.kind===`retry`||r.kind===`soften`||r.kind===`rerun`?r.stage:``,a=`${e.projectId}:${r.kind}:${i}`,o=s.current.get(a);if(!o){let r=n.getQueryData(B.project(e.projectId))?.revisionId;if(!r){let n=await X0(t,e.projectId);if(!n.ok)return{ok:!1,message:n.message};r=n.value.view.revision.id}o={baseRevisionId:r,idempotencyKey:crypto.randomUUID()},s.current.set(a,o)}let c=await B7(t,e.projectId,r,o);return s.current.delete(a),c.ok&&await jo(t,e.projectId).then(t=>n.setQueryData(B.project(e.projectId),t),e=>console.warn(`Project refresh after an accepted action failed`,e)),c},onMutate:()=>{i(void 0),o(void 0)},onSuccess:async(e,t)=>{e.ok?(o(`warnings`in e&&e.warnings.length>0?e.warnings.join(` `):void 0),n.invalidateQueries({queryKey:B.projects})):i({message:e.message,stage:z7(t.action)}),await n.invalidateQueries({queryKey:B.project(t.projectId)})},onSettled:()=>{c.current=!1},onError:(e,t)=>{i({message:e.message,stage:z7(t.action)})}});return{run:(t,n)=>{c.current||(c.current=!0,l.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok&&n?.()}}))},pending:l.isPending,performing:l.isPending?l.variables?.action:void 0,refusal:r,dismissRefusal:()=>{i(void 0)},notice:a}}function z7(e){switch(e.kind){case`cancel`:case`pause`:case`resume`:case`providers`:return;case`retry`:case`soften`:case`rerun`:return e.stage;case`subtitles`:return`video`;case`save-article`:return`article`;case`delete-image`:case`regenerate-image`:return`images`}}function B7(e,t,n,r){let i=()=>{if(!r)throw Error(`A saved revision and request identity are required.`);return r};switch(n.kind){case`pause`:return uxe(e,t,i());case`cancel`:return lxe(e,t,i());case`resume`:return dxe(e,t,i());case`retry`:return fxe(e,t,n.stage,i());case`soften`:return pxe(e,t,n.stage,i());case`rerun`:return mxe(e,t,n.stage,i());case`providers`:return hxe(e,t,n.choices);case`subtitles`:return gxe(e,t,n.subtitles);case`save-article`:return _xe(e,t,n.markdown);case`delete-image`:return vxe(e,t,n.outputId);case`regenerate-image`:return yxe(e,t,n.outputId)}}var V7=e=>e.state===`done`||e.state===`provided`;function xxe(e){let t=e.find(e=>e.state===`failed`)??e.find(e=>e.state===`running`);if(t)return t.kind;let n=e.find(e=>e.kind===`video`&&V7(e));if(n)return n.kind;let r=e.find(e=>e.state===`pending`);return r?r.kind:e.find(e=>e.kind===`article`&&V7(e))?.kind??e.find(e=>e.state!==`skipped`)?.kind??`article`}function Sxe({projectId:e,openDraft:t}){return(0,h.jsx)(Cxe,{projectId:e,openDraft:t},e)}var H7=e=>{let t=e.filter(e=>e!==void 0);if(!(t.length===0||t.every(e=>e.state===`skipped`)))return t.some(e=>e.state===`failed`&&e.retryAt===void 0)?`failed`:t.some(e=>e.state===`running`)?`running`:t.some(e=>e.state===`failed`)?`waiting`:t.every(e=>e.state===`done`||e.state===`provided`||e.state===`skipped`)?`done`:`off`};function Cxe({projectId:e,openDraft:t}){let{api:n}=z(),r=Iy(),i=Exe(e,t),a=P(ib(n,e)),o=P(ub(n)),s=P(ab(n,e)),c=bxe(e),[l,u]=(0,m.useState)(),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(!1),y=a.data?.revisionId??null,b=qbe(e,y,{onOpenEdit:()=>u(`settings`)}),x=fI(e),S=(0,m.useRef)(void 0);(0,m.useEffect)(()=>{if(x===void 0){S.current=void 0;return}a.data!==void 0&&S.current!==x&&(S.current=x,x===`download`&&u(iF(a.data.project.config)===`article`?`article`:`video`))},[x,a.data]),j3(e,y);let C=P({queryKey:Vy,queryFn:()=>Yy(n)}),w=Xy(C.data,e),T=P({queryKey:u3(e,y??``),queryFn:()=>f3(n,e),enabled:y!==null,retry:!1}),E=T.data?.ok===!0?T.data.value.checkpoints:[],D=b.saved.data?.outputs.filter(e=>e.selected&&e.state===`outdated`).map(e=>({workKey:e.workKey,role:e.output.role}))??[],O=a.data?.project,k=a.data?.stages??[],A=a.data?.outputs??[],j=A.some(e=>e.role===`video`),ee=e=>u(e),te=yve({project:O??wxe,stages:k,resumable:a.data?.resumable??!1,sample:w,gates:E,outdated:D,waits:s.data?.waits??[],uploadReady:j,actions:c,controller:b,openSection:ee,openUpload:()=>f(!0)}),M=l===`settings`,ne=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!M){ne.current=!1;return}b.edit!==void 0&&(ne.current=!0),!(ne.current||b.busy)&&(ne.current=!0,b.openEditor())},[M,b]);let N=k.some(e=>e.state===`running`),re=O?.status===`running`,ie=O?.title??``,ae=te.next?.action;Ox({id:`project.next`,title:ae?.label??`Show the project's next action`,group:`This project`,context:ie,keywords:[`next`,`continue`,`resume`,`approve`,`retry`],shortcut:uP.nextAction,run:()=>{ae===void 0?r(`This project has no next action right now: nothing waits on you.`,`info`):ae.intent.kind===`soften`?r(`Soften and retry asks first: press it in the Next action panel on the right.`):te.run(ae.intent)}}),rS(Qx.showImages(e),()=>{let e=a.data?.stages.find(e=>e.kind===`images`);e===void 0||e.state===`skipped`?r(`${ie} makes no slideshow images, so there is no image to regenerate. To add them, open Settings in this project and choose how its images are made.`,`error`):u(`images`)},a.data!==void 0),Ox({id:`project.pause`,title:O?.status===`paused`?`Continue the run`:`Pause the run`,group:`This project`,context:ie,keywords:[`pause`,`resume`,`continue`,`stop`],run:()=>c.run({kind:O?.status===`paused`?`resume`:`pause`})}),Ox({id:`project.prepare-upload`,title:`Prepare upload`,group:`This project`,context:ie,keywords:[`youtube`,`studio`,`upload`,`publish`],run:()=>{j?f(!0):r(`Prepare upload opens once the video has been made.`,`info`)}}),Ox({id:`project.settings`,title:`Edit project settings`,group:`This project`,context:ie,keywords:[`edit`,`settings`,`prompts`,`providers`,`channel`],run:()=>u(`settings`)}),Ox({id:`project.rebuild-review`,title:`Choose what to remake`,group:`This project`,context:ie,keywords:[`rebuild`,`review`,`remake`,`outdated`,`affected`],run:()=>b.review({kind:`allAffected`})}),Ox({id:`project.template`,title:`Save as template`,group:`This project`,context:ie,keywords:[`template`,`reuse`],run:()=>g(!0)}),Ox({id:`project.cancel`,title:`Cancel the run`,group:`This project`,context:ie,keywords:[`cancel`,`stop`],run:()=>v(!0)});let oe=_ve(D);if(Ox({id:`project.remake-1`,title:oe[0]?.label??`Remake outdated outputs`,group:`This project`,context:ie,keywords:[`remake`,`outdated`,`rebuild`],run:()=>{let e=oe[0];e===void 0?r(`Nothing is outdated in this project.`,`info`):b.review({kind:`selected`,workKeys:e.workKeys},{autoStart:!0})}}),Ox({id:`project.remake-all`,title:`Remake everything outdated`,group:`This project`,context:ie,keywords:[`remake`,`outdated`,`rebuild`,`all`],run:()=>{let e=[...new Set(oe.flatMap(e=>e.workKeys))];e.length===0?r(`Nothing is outdated in this project.`,`info`):b.review({kind:`selected`,workKeys:e},{autoStart:!0})}}),Ox({id:`project.copy`,title:`Make my own copy`,group:`This project`,context:ie,keywords:[`sample`,`copy`,`duplicate`],run:()=>w?te.run({kind:`copy-sample`}):r(`Only the sample project is copied this way.`,`info`)}),a.error!==null)return(0,h.jsx)(vI,{tone:`danger`,title:`The project could not be loaded.`,children:`${a.error.message} Reload the page to try again, or go back to Projects.`});if(a.data===void 0||O===void 0)return(0,h.jsx)(Txe,{});let se=e=>k.find(t=>t.kind===e),ce=se(`article`),le=se(`research`),ue=se(`audio`),de=se(`images`),fe=se(`thumbnail`),pe=se(`video`),me=se(`document`),he=O.config,ge=e=>e!==void 0&&e.state!==`skipped`,_e=he.shorts?.enabled===!0||A.some(e=>e.role===`short_video`||e.role===`shorts`),ve=he.youtubeDescription===!0||A.some(e=>e.role===`youtube_description`),ye=E.filter(e=>e.state===`held`||e.state===`pending-review`),be=[...ge(ce)||ge(le)?[{id:`article`,label:`Article`,tone:H7([ce,le])}]:[],...ge(ue)?[{id:`narration`,label:`Narration`,tone:H7([ue])}]:[],...ge(de)||ge(fe)||he.reference!==void 0?[{id:`images`,label:`Images`,tone:H7([de,fe])}]:[],...ge(pe)?[{id:`video`,label:iF(he)===`audio`?`Audio export`:`Video`,tone:H7([pe])}]:[],...ge(me)?[{id:`document`,label:`PDF`,tone:H7([me])}]:[],{id:`cost`,label:`Cost`},{id:`live`,label:`Live`}].map(e=>{let t=oe.filter(t=>t.section===e.id).reduce((e,t)=>e+t.count,0);return t===0?e:{...e,meta:`${String(t)} outdated`}}),xe=[{id:`settings`,label:`Settings`,...b.unsaved?{meta:`unsaved`}:{}},...y===null?[]:[{id:`checkpoints`,label:`Checkpoints`,...ye.length===0?{}:{meta:`${String(ye.length)} held`}}],{id:`history`,label:`History`}],Se=[...be,...xe],Ce=te.next?.situation,we=te.next?.section!==void 0&&Ce!==`done`&&Ce!==`running`?te.next.section:Ce===`done`&&A.some(e=>e.role===`youtube_description`)?`youtube`:e5(xxe(k)),Te=e=>e===`shorts`||e===`youtube`?`video`:e,Ee=l!==void 0&&Se.some(e=>e.id===Te(l))?Te(l)??`video`:Se.find(e=>e.id===Te(we))?.id??be[0]?.id??`cost`,De=(...e)=>y===null?O.status===`running`||O.status===`paused`||N||c.pending:c.pending||e.some(e=>e?.state===`running`),Oe={project:O,outputs:A,actions:c,next:te,resumable:a.data.resumable},ke=(e,t)=>e===void 0?null:(0,h.jsx)(vye,{stage:e,...t===void 0||t.state===`skipped`?{}:{companion:t},project:O,outputs:A,actions:c,busy:De(e,t)}),Ae=(...e)=>A.some(t=>e.some(e=>e!==void 0&&t.stageKind===e.kind)),je=(...e)=>Ae(...e)||e.some(e=>e!==void 0&&[`running`,`done`,`provided`,`failed`,`canceled`].includes(e.state)),Me=[{id:`rebuild`,label:`Choose what to remake…`,run:()=>b.review({kind:`allAffected`}),disabled:b.busy},{id:`template`,label:`Save as template…`,run:()=>g(!0),disabled:y===null||w},{id:`cancel`,label:`Cancel the run…`,run:()=>v(!0),disabled:!re||c.pending,apart:!0}],Ne=$8({kind:`cancel`}),Pe=c.refusal?.stage===void 0?c.refusal:void 0,Fe=Pe===void 0?c.notice===void 0?b.preview===void 0&&(b.error||b.refusal)&&Ee!==`settings`&&Ee!==`history`?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:b.error??b.refusal?.message}):void 0:(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:c.notice}):(0,h.jsx)(vI,{tone:`danger`,title:Pe.message,children:(0,h.jsx)(R,{variant:`quiet`,size:`small`,className:`mt-1`,onClick:c.dismissRefusal,children:`Dismiss`})}),Ie=nxe({stages:k,outputs:A,project:O,resumable:a.data.resumable,held:ye.map(e=>({checkpointId:e.checkpointId,stage:e.stage,dependents:e.dependents})),now:Date.now()});return(0,h.jsx)(E_e,{projectId:e,revisionId:y,children:(0,h.jsx)(K8,{value:y!==null,children:(0,h.jsx)(m3,{value:e=>u(e===`edit`?`settings`:`article`),children:(0,h.jsx)(q8,{value:b.pending||b.preview!==void 0?void 0:b.requestEdit,children:(0,h.jsxs)(J8,{value:b.pending||b.preview!==void 0?void 0:b.regenerateNow,children:[(0,h.jsxs)(`div`,{className:`sl-project`,children:[(0,h.jsx)(`div`,{"data-tour":`project-controls`,children:(0,h.jsx)(kye,{project:O,prompts:o.data?.prompts,editing:Ee===`settings`,onEdit:()=>u(`settings`),more:Me,nextChapter:i,clock:(0,h.jsx)(Iye,{cost:s.data,status:O.status,measuredAt:s.dataUpdatedAt})})}),(0,h.jsx)(rxe,{stages:k}),(0,h.jsxs)(Cq,{sections:(0,h.jsxs)(Q6,{label:`Project sections`,children:[be.map(e=>(0,h.jsx)(W7,{item:e,selected:Ee,onSelect:ee},e.id)),(0,h.jsx)(`hr`,{className:`sl-rule my-2`}),xe.map(e=>(0,h.jsx)(W7,{item:e,selected:Ee,onSelect:ee},e.id))]}),aside:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xve,{state:te,feedback:Fe}),O===void 0?null:(0,h.jsx)(Oye,{projectId:e,title:O.title,status:O.status,sample:w||C.isPending}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-6 max-[1180px]:hidden`,children:[(0,h.jsx)(ixe,{steps:Ie}),(0,h.jsx)(axe,{cost:s.data,onOpen:()=>ee(`cost`)}),(0,h.jsx)(a_e,{})]})]}),children:[(0,h.jsx)(c5,{id:`article`,title:`Article`,stages:[ce,le].filter(U7),active:Ee===`article`,...Oe,children:ge(ce)||ge(le)?ke(ce,le):(0,h.jsx)(l5,{stage:ce,project:O,name:`Article`})}),(0,h.jsx)(c5,{id:`narration`,title:`Narration`,stages:[ue].filter(U7),active:Ee===`narration`,...Oe,children:je(ue)?ke(ue):(0,h.jsx)(l5,{stage:ue,project:O,name:`Narration`})}),(0,h.jsx)(c5,{id:`images`,title:`Images`,head:!1,stages:[de,fe].filter(U7),active:Ee===`images`,...Oe,children:ke(de,fe)}),(0,h.jsxs)(c5,{id:`video`,title:iF(he)===`audio`?`Audio export`:`Video`,stages:[pe].filter(U7),active:Ee===`video`,...Oe,...j&&te.next?.action?.intent.kind!==`prepare-upload`?{extra:(0,h.jsx)(R,{variant:`secondary`,onClick:()=>f(!0),children:`Prepare upload`})}:{},children:[ke(pe),pe!==void 0&&_e?(0,h.jsx)(lye,{stage:pe,project:O,outputs:A}):null,pe!==void 0&&ve?(0,h.jsx)(yye,{stage:pe,project:O,outputs:A}):null]}),me===void 0?null:(0,h.jsx)(c5,{id:`document`,title:`PDF`,stages:[me],active:Ee===`document`,...Oe,children:je(me)?ke(me):(0,h.jsx)(l5,{stage:me,project:O,name:`PDF`})}),(0,h.jsx)(G7,{id:`cost`,title:`Run cost`,selected:Ee,children:(0,h.jsx)(Pye,{projectId:e})}),(0,h.jsx)(G7,{id:`live`,title:`Live`,selected:Ee,children:Ee===`live`?(0,h.jsx)(Gye,{project:O,revisionId:y,stages:k,outputs:A}):null}),(0,h.jsx)(G7,{id:`settings`,title:`Settings`,selected:Ee,children:(0,h.jsx)(Ybe,{controller:b,active:Ee===`settings`,renderEditor:e=>(0,h.jsx)(Fbe,{...e,renderContent:e=>(0,h.jsx)(_be,{...e},e.view.revision.id)})})}),y===null?null:(0,h.jsx)(G7,{id:`checkpoints`,title:`Checkpoints`,selected:Ee,children:(0,h.jsx)(wye,{projectId:e,revisionId:y,paused:O.status===`paused`,stages:k,approvedInRail:te.next?.action?.intent.kind===`approve`?te.next.action.intent.gate.checkpointId:void 0})}),(0,h.jsx)(G7,{id:`history`,title:`History`,selected:Ee,children:(0,h.jsx)(Xbe,{controller:b,projectId:e,active:Ee===`history`})})]})]}),(0,h.jsx)(Zbe,{controller:b}),d?(0,h.jsx)(h2,{projectId:e,onClose:()=>f(!1)}):null,(0,h.jsx)(oxe,{projectId:e,revisionId:y,title:O.title,open:p,onClose:()=>g(!1)}),(0,h.jsx)(zy,{open:_,title:Ne.title,consequence:Ne.consequence,confirmLabel:Ne.verb,cancelLabel:Ne.dismiss,pending:c.pending,onConfirm:()=>{v(!1),c.run({kind:`cancel`})},onCancel:()=>v(!1)})]})})})})})}var U7=e=>e!==void 0;function W7({item:e,selected:t,onSelect:n}){return(0,h.jsx)($6,{className:`max-md:w-auto`,"data-tour":`project-rail-${e.id}`,current:e.id===t,onClick:()=>n(e.id),...e.tone===void 0?{}:{icon:(0,h.jsx)(wS,{tone:e.tone})},...e.meta===void 0?{}:{meta:e.meta},children:e.label})}function G7({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-5`,children:[(0,h.jsx)(`h2`,{className:`sl-section-head__title m-0`,children:t}),r]})}var wxe={id:``,title:``,format:`16:9`,status:`pending`,createdAt:``,config:{sources:{}}};function Txe(){return(0,h.jsxs)(`div`,{role:`status`,"aria-label":`Loading project`,children:[(0,h.jsxs)(`div`,{className:`mb-6 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)(Cq,{sections:(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))}),aside:(0,h.jsx)(`span`,{className:`h-40 rounded-control bg-sunken`}),children:(0,h.jsx)(`span`,{className:`h-[480px] rounded-control bg-sunken`})})]})}function Exe(e,t){let{api:n}=z(),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),Hq(n,e,r.current).then(async e=>{if(!e.ok){s(e.message);return}await t(e.value.draft.id)?r.current=void 0:s(`The next chapter's draft was made, but Play could not open it because the draft open there is not saved yet. Open Play, let it save, then press Make the next chapter again.`)}).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)))}}}var Dxe=[`all`,`running`,`queued`,`waiting`,`ready`,`failed`];function Oxe(e){return Dxe.find(t=>t===e)}var K7=[{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 q7(e,t){switch(t){case`all`:return!0;case`running`:return e.status===`running`||e.status===`paused`;case`queued`:return S3(e);case`waiting`:return v3(e);case`ready`:return x3(e);case`failed`:return e.status===`failed`||e.status===`partial`}}function kxe(e){let t={running:{tone:`running`,word:`Running`},paused:{tone:`waiting`,word:`Paused`},pending:{tone:`off`,word:`Queued`},failed:{tone:`failed`,word:`Failed`},partial:{tone:`info`,word:`Done with problems`},done:{tone:`done`,word:`Done`},canceled:{tone:`off`,word:`Canceled`}};if(v3(e))return{tone:`waiting`,word:`Waiting for you`};if(e.status===`pending`&&e.setAside===!0)return{tone:`done`,word:`Kept as is`};let n=e.status===`running`?HH(e.limitWaits):void 0;return n===void 0?t[e.status]:{tone:`waiting`,word:n}}function Axe(e){let t=e.config.articlePrompt,n=e.config.voices?.book;return[n===void 0?void 0:RA(n),t===void 0||t===``?void 0:t,e.format].filter(e=>e!==void 0).join(` · `)}function jxe({initialFilter:e=`all`}={}){let{api:t}=z(),n=_(),r=Iy(),i=wx(),a=P(rb(t)),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(e),u=P({queryKey:By,queryFn:()=>Wy(t)}),d=new Set(Object.values(u.data?.samples??{}).filter(e=>e!==null)),[f,p]=(0,m.useState)(``),g=(0,m.useRef)(null),v=kx(g,`projects`),y=F({mutationFn:e=>No(t,e),onSettled:async()=>{s(void 0),await n.invalidateQueries({queryKey:B.projects})}}),b=F({mutationFn:e=>g3(t,e.project.id,e.uploaded),onError:(e,t)=>r(`${t.project.title} wasn't changed: ${e.message} Press the button again.`,`error`),onSettled:async()=>{await n.invalidateQueries({queryKey:B.projects})}});Ox({id:`projects.show.waiting`,title:`Show projects that need you`,group:`Projects`,keywords:[`waiting`,`filter`],run:()=>l(`waiting`)}),Ox({id:`projects.show.ready`,title:`Show videos ready to upload`,group:`Projects`,keywords:[`upload`,`finished`,`filter`],run:()=>l(`ready`)}),Ox({id:`projects.show.failed`,title:`Show failed projects`,group:`Projects`,keywords:[`error`,`filter`],run:()=>l(`failed`)});let x=(a.data?.projects??[]).filter(e=>i.includes(e.channelId)),S=f.trim().toLowerCase(),C=x.filter(e=>q7(e,c)&&(S===``||e.title.toLowerCase().includes(S)));return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{title:`Projects`,meta:a.data===void 0?void 0:`${String(x.length)} ${x.length===1?`project`:`projects`} · ${i.channel?.name??`every channel`}`,actions:(0,h.jsxs)(bS,{to:`/play`,variant:`primary`,children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,strokeWidth:1.75}),`New project`]})}),a.data?.projects.length===0?(0,h.jsx)(xB,{}):null,a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-4 text-danger`,children:a.error.message}),a.data===void 0?a.error===null?(0,h.jsx)(Nxe,{}):null:a.data.projects.length===0?(0,h.jsx)(Q1,{title:`No projects yet`,actions:(0,h.jsx)(bS,{to:`/play`,variant:`primary`,children:`Make your first video`}),children:`Set up a run on Play: pick a template, type a topic and start.`}):(0,h.jsxs)(q1,{split:`aside`,children:[(0,h.jsxs)(J1,{label:`Project list`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsxs)(`div`,{className:`relative w-full max-w-[320px]`,children:[(0,h.jsx)(Gc,{"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:g,"aria-label":`Search projects`,"aria-keyshortcuts":Bx(v),placeholder:`Search projects`,value:f,onChange:e=>p(e.target.value),className:`sl-input pl-9`})]}),(0,h.jsx)(Rb,{label:`Show`,value:c,options:K7,onChange:l,className:`max-w-full overflow-x-auto`})]}),C.length===0?(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:x.length===0?`No projects in ${i.channel?.name??`this channel`} yet. Pick All channels in the rail to see the others.`:`No project matches. Clear the search or pick All.`}):(0,h.jsx)(oU,{label:`Projects`,children:C.map(e=>(0,h.jsx)(Mxe,{project:e,sample:d.has(e.id),onDelete:()=>s(e),onUploaded:t=>b.mutate({project:e,uploaded:t}),busy:b.isPending},e.id))})]}),(0,h.jsxs)(J1,{as:`aside`,label:`Projects at a glance`,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(H,{title:`At a glance`}),(0,h.jsx)(U2,{children:K7.filter(e=>e.value!==`all`).map(e=>(0,h.jsx)(W2,{label:e.label,value:String(x.filter(t=>q7(t,e.value)).length)},e.value))})]}),(0,h.jsxs)(`section`,{"aria-label":`Video queue`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(H,{title:`Video queue`,info:`play.queue`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Videos started together, in the order they run, are on the calendar.`}),(0,h.jsx)(`div`,{children:(0,h.jsx)(xS,{to:`/calendar`,children:`Open calendar`})})]})]})]}),y.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`mt-3 text-small text-danger`,children:y.error.message}),(0,h.jsx)(zy,{open:o!==void 0,title:o===void 0?``:`Delete "${o.title}"?`,consequence:`Moves the project to the trash for 30 days. Restore it or delete it for good in Settings → Trash.`,confirmLabel:`Delete project`,cancelLabel:`Keep it`,pending:y.isPending,onConfirm:()=>{o!==void 0&&y.mutate(o.id)},onCancel:()=>s(void 0)})]})}function Mxe({project:e,sample:t,onDelete:n,onUploaded:r,busy:i}){let a=kxe(e),o=e.status===`running`;return(0,h.jsx)(sU,{title:(0,h.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(ma,{to:`/projects/$projectId`,params:{projectId:e.id},children:e.title}),t?(0,h.jsx)(ES,{children:`Sample`}):null]}),meta:(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,h.jsxs)(`span`,{children:[`${Axe(e)} · started ${zu(e.createdAt)}`,e.views===void 0?``:` · ${e.views.toLocaleString()} views${e.ctr===void 0?``:` · ${String(e.ctr)}% CTR`}`]}),o?(0,h.jsx)(G2,{value:e.progress,label:`${e.title} progress`,valueText:`${String(Math.round(e.progress*100))}% done`,className:`max-w-[240px]`}):null]}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(TS,{tone:a.tone,children:[a.word,(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`${e.title}: ${a.word}`})]}),x3(e)?(0,h.jsx)(R,{variant:`quiet`,size:`small`,disabled:i,disabledReason:`Saving…`,onClick:()=>r(!0),children:`Mark uploaded`}):null,x3(e)?(0,h.jsx)(V,{id:`project.mark-uploaded`}):e.uploadedAt===null?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ES,{children:`Uploaded`}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Mark ${e.title} not uploaded`,disabled:i,disabledReason:`Saving…`,onClick:()=>r(!1),children:`Undo`})]}),(0,h.jsx)(My,{label:`Delete ${e.title}`,size:`small`,disabled:o,disabledReason:`Cancel the run first, then delete it.`,onClick:n,children:(0,h.jsx)(Yc,{"aria-hidden":`true`,strokeWidth:1.75})})]})})}function Nxe(){return(0,h.jsx)(`ul`,{"aria-label":`Loading projects`,className:`sl-list m-0 list-none p-0`,children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(`li`,{className:`sl-row`,"data-slot":`skeleton-row`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`h-3 w-2/5 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-[10px] w-1/4 rounded-control bg-sunken`})]}),(0,h.jsx)(`span`,{className:`h-[10px] w-16 rounded-control bg-sunken`})]},e))})}var Pxe=`Prepare restrained delivery cues for a documentary narrator. Let the facts carry the scene. Use a measured pace and make only occasional changes where the supplied wording clearly calls for emphasis, reflection or tension. Prefer no cue to an unnecessary cue. Avoid theatrical emotion, invented reactions and routine laughter or sighs. Never rewrite, summarize, translate or add spoken words. Return only the cue annotations required by the supplied format contract.`;function J7({promptId:e,kind:t,from:n,onLeave:r}){let{api:i}=z(),a=_(),o=dI(),s=P(ub(i)),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),[d,f]=sP(JSON.stringify(e===void 0?[`new`,t,n??null]:[`prompt`,e])),[p,g]=(0,m.useState)([]),[v,y]=(0,m.useState)(void 0),b=v!==void 0,[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(!1),T=s.data?.prompts,E=e??n,D=E===void 0?void 0:T?.find(e=>e.id===E),O=D===void 0?{kind:t,name:``,body:``}:e===void 0?{kind:D.kind,name:`${D.name} copy`,body:D.body}:{kind:D.kind,name:D.name,body:D.body},k=d??v??O,A=F({mutationFn:t=>As(i,t,e),onSuccess:async(e,t)=>{if(!e.ok){g(e.fields);return}y(e.value),f(e=>e===t?void 0:e),o({type:`prompt-saved`,id:e.value.id,kind:e.value.kind}),await a.invalidateQueries({queryKey:ub(i).queryKey})}}),j=F({mutationFn:e=>Ms(i,e),onSuccess:async()=>{S(!1),f(void 0),await a.invalidateQueries({queryKey:ub(i).queryKey}),r(k.kind)}}),ee=F({mutationFn:({id:e,on:t})=>js(i,e,t),onSettled:async()=>{await a.invalidateQueries({queryKey:ub(i).queryKey})}});J2(b,()=>{r(k.kind)});let te=(e,t)=>{f(e),g(e=>e.filter(e=>e.field!==t))},M=$4(k,p),ne=e3(M),N=r3(k.body),re=k.body.trim()===``?[]:t3(M),ie=k.name.trim()===``?[]:n3(M);return uI({promptNamed:k.name.trim()!==``&&ie.length===0,promptBodyReady:k.body.trim()!==``&&re.length===0,promptHasKeywords:N.length>0&&re.length===0,promptSaveReady:ne===void 0&&!A.isPending&&!b,promptSaving:A.isPending||b,promptIsArticle:k.kind===`article`,promptIsImage:k.kind===`image`}),s.error===null?E!==void 0&&T===void 0?(0,h.jsx)(Z2,{}):E!==void 0&&D===void 0?(0,h.jsx)(X7,{kind:t,children:`That prompt is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{crumb:(0,h.jsx)(p4,{children:(0,h.jsx)(ma,{to:`/prompts`,search:{kind:k.kind},children:`Prompts`})}),title:e===void 0?`New prompt`:`Edit prompt`,meta:`${sV(k.kind)} prompt`}),(0,h.jsxs)(`div`,{"data-tour":`prompt-editor`,className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${d4} flex min-w-0 flex-col gap-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,h.jsx)(`div`,{"data-tour":`prompt-name`,className:`min-w-[min(100%,240px)] flex-1`,children:(0,h.jsx)(dV,{label:`Name`,tip:`library.prompt.name`,...ie.length===0?{}:{error:ie.map(e=>e.message).join(` `)},children:(0,h.jsx)(pV,{value:k.name,onChange:e=>{te({...k,name:e.target.value},`name`)}})})}),(0,h.jsx)(Z4,{label:`Kind`,value:k.kind,options:oV,tip:`library.prompt.kind`,onPick:e=>{te({...k,kind:e},`name`)}})]}),(0,h.jsxs)(`div`,{"data-tour":`prompt-body`,...Ib,children:[(0,h.jsxs)(`div`,{className:`mb-1 flex min-h-8 items-end justify-between gap-3`,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:c,className:`sl-field__label`,children:`Body`}),(0,h.jsx)(V,{id:Fxe[k.kind],label:`${sV(k.kind)} prompt body`,className:`-my-1`})]}),Y7(k.kind)?(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(R,{variant:`quiet`,size:`small`,onClick:()=>{let e=Y7(k.kind);e!==void 0&&(k.body.trim()===``?te({...k,body:e.body},`body`):w(!0))},children:Y7(k.kind)?.label}),(0,h.jsx)(V,{id:`library.prompt.starter`,label:Y7(k.kind)?.label})]}):null]}),(0,h.jsx)(a3,{id:c,value:k.body,invalid:re.length>0,describedBy:re.length===0?void 0:l,onChange:e=>{te({...k,body:e},`body`)}})]}),k.kind===`image`?(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e!==void 0&&D?.kind===`image`?(0,h.jsx)(Lb,{checked:ee.isPending?ee.variables.on:D.photorealistic===!0,disabled:ee.isPending,onChange:t=>ee.mutate({id:e,on:t}),label:`Draws photorealistic pictures`,tip:`library.prompt.photorealistic`}):(0,h.jsxs)(`span`,{className:`flex items-center gap-1 text-small text-ink-2`,children:[`Save this Image prompt first, then choose whether it draws photorealistic pictures.`,(0,h.jsx)(V,{id:`library.prompt.photorealistic`})]}),ee.error===null?null:(0,h.jsx)(`span`,{role:`alert`,className:`text-small text-danger`,children:`Couldn't change Draws photorealistic pictures: ${ee.error.message} Press the switch again.`})]}):null,(0,h.jsx)(`div`,{"data-tour":`prompt-save`,children:(0,h.jsx)(X2,{onDelete:e===void 0?void 0:()=>{S(!0)},blocked:ne,blockedId:u,pending:A.isPending,saved:b,cancel:(0,h.jsx)(bS,{to:`/prompts`,search:{kind:k.kind},onClick:()=>{f(void 0)},variant:`secondary`,children:`Cancel`}),errors:[A.error,j.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{A.mutate(k)}})})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-slots`,className:f4,children:(0,h.jsx)(q4,{slots:N,body:k.body,lint:re,lintId:l})})]}),(0,h.jsx)(zy,{open:C,title:`Replace this prompt body?`,consequence:`The starter replaces the text in this editor. Nothing is saved until you choose Save.`,confirmLabel:`Use starter`,tone:`primary`,onConfirm:()=>{let e=Y7(k.kind);e!==void 0&&te({...k,body:e.body},`body`),w(!1)},onCancel:()=>w(!1)}),(0,h.jsx)(zy,{open:x,title:`Delete "${k.name}"?`,consequence:`Moves it to the trash for 30 days (Settings → Trash). Projects that used it keep their text.`,confirmLabel:`Delete prompt`,pending:j.isPending,onConfirm:()=>{e!==void 0&&j.mutate(e)},onCancel:()=>{S(!1)}})]}):(0,h.jsx)(X7,{kind:k.kind,children:s.error.message})}var Fxe={article:`library.prompt.body.article`,image:`library.prompt.body.image`,thumbnail:`library.prompt.body.thumbnail`,narration:`library.prompt.body.narration`,description:`library.prompt.body.description`,shorts:`library.prompt.body.shorts`,review:`library.prompt.body.review`,script:`library.prompt.body.script`};function Y7(e){if(e===`narration`)return{label:`Use Documentary Starter`,body:Pxe};if(e===`description`)return{label:`Use Built-in Starter`,body:qhe};if(e===`shorts`)return{label:`Use Built-in Starter`,body:Kk}}function X7({kind:e,children:t}){return(0,h.jsx)(m4,{back:(0,h.jsx)(ma,{to:`/prompts`,search:{kind:e},children:`Back to Prompts`}),children:t})}function Ixe({kind:e,onKind:t,onUseInPlay:n,playBlocked:r}){let{api:i}=z(),a=_(),o=P(ub(i)),[s,c]=(0,m.useState)(``),l=(0,m.useRef)(null),u=kx(l,`prompts`),[d,f]=(0,m.useState)(void 0),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)(void 0),b=F({mutationFn:e=>Ms(i,e),onSettled:async()=>{g(void 0),await a.invalidateQueries({queryKey:B.prompts})}}),x=async(e,t)=>{let n=await As(i,{kind:e.kind,name:t,body:e.body},e.id);return await a.invalidateQueries({queryKey:B.prompts}),n.ok?null:G4(n.fields)},S=o.data?.prompts.filter(t=>t.kind===e),C=s.trim().toLowerCase(),w=C===``?S:S?.filter(e=>e.name.toLowerCase().includes(C)||e.body.toLowerCase().includes(C)),T=w?.find(e=>e.id===d)??w?.[0];return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(R4,{action:(0,h.jsx)(Rxe,{kind:e}),children:[(0,h.jsx)(pV,{type:`search`,ref:l,"aria-label":`Search prompts`,"aria-keyshortcuts":Bx(u),placeholder:`Search prompts`,value:s,className:`w-full min-w-0 sm:w-64`,onChange:e=>c(e.target.value)}),(0,h.jsxs)(`span`,{className:`flex w-full items-center gap-1 sm:w-auto`,...Ib,children:[(0,h.jsx)(hV,{"aria-label":`Prompt kind`,value:e,className:`w-full sm:w-56`,options:oV,onChange:e=>{let n=oV.find(t=>t.value===e.target.value);n!==void 0&&t(n.value)}}),(0,h.jsx)(V,{id:`library.prompt.kind`})]})]}),o.error===null?null:(0,h.jsx)(I4,{what:`prompts`,message:o.error.message,onRetry:()=>void o.refetch()}),w===void 0||S===void 0?o.error===null?(0,h.jsx)(F4,{label:`Prompts`}):null:S.length===0?(0,h.jsxs)(Q1,{title:`No ${sV(e).toLowerCase()} prompts yet`,children:[`A prompt is text with `,`{{keywords}}`,`; each keyword becomes a field on Play.`]}):(0,h.jsx)(wq,{className:N4,list:w.length===0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`No ${sV(e).toLowerCase()} prompts match "${s.trim()}".`}):(0,h.jsx)(oU,{label:`Prompts`,children:w.map(e=>(0,h.jsx)(sU,{className:P4,title:(0,h.jsx)(K4,{name:e.name,onSelect:()=>f(e.id),onRename:t=>x(e,t)}),meta:Lxe(e),selected:e.id===T?.id,actions:(0,h.jsx)(L4,{name:e.name,edit:(0,h.jsx)(bS,{to:`/prompts/$promptId`,params:{promptId:e.id},"aria-label":`Edit ${e.name}`,variant:`quiet`,size:`small`,children:`Edit`}),duplicate:(0,h.jsx)(bS,{to:`/prompts/new`,search:{kind:e.kind,from:e.id},"aria-label":`Duplicate ${e.name}`,variant:`quiet`,size:`small`,children:`Duplicate`}),play:{run:n===void 0?void 0:()=>n(e),blocked:r},onHistory:()=>y(e),onDelete:()=>g(e)})},e.id))}),detail:T===void 0?null:(0,h.jsx)(A4,{item:`prompt`,id:T.id,name:T.name,kicker:`${sV(T.kind)} prompt`,meta:`Updated ${M4(T.updatedAt)}`,body:T.body,slots:T.slots,actions:(0,h.jsx)(bS,{to:`/prompts/$promptId`,params:{promptId:T.id},size:`small`,children:`Edit prompt`}),onOpenHistory:()=>y(T)},T.id)}),b.error===null?null:(0,h.jsx)(vI,{tone:`danger`,title:`The prompt wasn't deleted.`,className:`mt-4`,children:b.error.message}),v===void 0?null:(0,h.jsx)(E4,{item:`prompt`,id:v.id,name:v.name,onClose:()=>y(void 0)},v.id),(0,h.jsx)(zy,{open:p!==void 0,title:p===void 0?``:`Delete "${p.name}"?`,consequence:`Moves it to the trash for 30 days (Settings → Trash). Projects that used it keep their text.`,confirmLabel:`Delete prompt`,pending:b.isPending,onConfirm:()=>{p!==void 0&&b.mutate(p.id)},onCancel:()=>g(void 0)})]})}function Lxe(e){return`${sV(e.kind)} · ${j4(e.slots.length,`keyword`)} · updated ${M4(e.updatedAt)}`}function Rxe({kind:e}){return(0,h.jsx)(bS,{to:`/prompts/new`,search:{kind:e},variant:`primary`,children:`New prompt`})}var zxe={template:`Template`,schedule:`Schedule`,draft:`Draft`,project:`Project`};function Z7(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 Bxe(){let{api:e}=z(),t=_(),n=Iy(),r=P({queryKey:F1.catalogue,queryFn:()=>Ode(e),refetchInterval:3e4}),i=P({queryKey:F1.retired,queryFn:()=>R1(e)}),a=async()=>{await Promise.all([t.invalidateQueries({queryKey:[`provider-models`]}),t.invalidateQueries({queryKey:F1.retired})])},o=F({mutationFn:()=>kde(e),onSuccess:async e=>{t.setQueryData(F1.catalogue,e),n(e.sync?.warning??`Model list checked: ${Z7(e.sync?.changes??Vxe)}.`,e.sync?.warning?`error`:`success`),await a()}}),s=F({mutationFn:()=>Ade(e),onSuccess:async e=>{n(`Catalogue replaced with the published file.`,`success`),t.setQueryData(F1.catalogue,e),await a()}}),c=async()=>{await Promise.all([t.invalidateQueries({queryKey:F1.retired}),t.invalidateQueries({queryKey:Aq}),t.invalidateQueries({queryKey:vH}),t.invalidateQueries({queryKey:[`play-drafts`]}),t.invalidateQueries({queryKey:[`projects`]}),t.invalidateQueries({queryKey:[`project`]})])},l=F({mutationFn:t=>z1(e,t),onSuccess:c}),u=F({mutationFn:()=>jde(e),onSuccess:async e=>{n(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 c()}}),d=r.data?.sync,f=i.data??[],p=f.filter(e=>e.blocked===null&&e.replacement!==null),m=o.error?.message??s.error?.message??r.error?.message??r.data?.warning??d?.warning??null;return Ox({id:`settings.check-models`,title:`Check for new models`,group:`Settings`,context:`Models`,keywords:[`catalogue`,`prices`,`retired`],run:()=>{!o.isPending&&r.data?.path&&o.mutate()}}),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(H,{title:`Model catalogue`,info:`settings.models.catalogue`,children:[(0,h.jsx)(R,{disabled:o.isPending||!r.data?.path,onClick:()=>o.mutate(),children:o.isPending?`Checking…`:`Check now`}),(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(R,{variant:`quiet`,disabled:s.isPending||!r.data?.path,onClick:()=>s.mutate(),children:s.isPending?`Replacing…`:`Replace with published file`}),(0,h.jsx)(V,{id:`settings.models.replace`})]})]}),(0,h.jsxs)(`dl`,{className:`m-0 grid gap-x-6 border-t border-line text-small sm:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Catalogue file`}),(0,h.jsx)(`dd`,{className:`m-0 min-w-0 border-b border-line pb-3 break-all font-mono text-ink-2 sm:pt-3`,children:r.data?.path??`Not available`}),(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Verified`}),(0,h.jsx)(`dd`,{className:`m-0 border-b border-line pb-3 text-ink-2 sm:pt-3`,children:r.data?.updatedAt??`date unavailable`}),(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Last checked`}),(0,h.jsx)(`dd`,{className:`m-0 border-b border-line pb-3 text-ink-2 sm:pt-3`,children:d?.checkedAt?`${new Date(d.checkedAt).toLocaleString()} · ${Z7(d.changes)}`:`Not checked yet`})]}),d!==void 0&&d.changes.retired.length+d.changes.added.length>0?(0,h.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1 text-small text-ink-2`,children:[d.changes.added.length>0?(0,h.jsxs)(`span`,{children:[`New: `,d.changes.added.map(e=>e.name).join(`, `)]}):null,d.changes.retired.length>0?(0,h.jsxs)(`span`,{children:[`Retired: `,d.changes.retired.map(e=>e.name).join(`, `)]}):null]}):null,m===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-3 text-body text-danger`,children:m})]}),(0,h.jsxs)(`section`,{"aria-label":`Retired models in use`,children:[(0,h.jsx)(H,{title:`Retired models in use`,info:`settings.models.retired`,children:(0,h.jsx)(R,{variant:`primary`,disabled:u.isPending||p.length===0,onClick:()=>u.mutate(),children:u.isPending?`Switching…`:`Switch all`})}),i.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:i.error.message}):null,l.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:l.error.message}):null,f.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:i.isPending?`Looking…`:`Nothing uses a retired model.`}):(0,h.jsx)(`ul`,{"aria-label":`Retired models in use`,className:`sl-list m-0 list-none p-0`,children:f.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:zxe[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:[e0[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})]}),(0,h.jsx)(Py,{children:(0,h.jsx)(R,{size:`small`,disabled:e.blocked!==null||e.replacement===null||l.isPending,onClick:()=>l.mutate(e),children:e.replacement===null?`No replacement`:`Switch to ${e.replacement.name}`})})]},e.key))})]})]})}var Vxe={added:[],retired:[],priced:[]},Hxe={ok:`Ready`,warning:`Check`,problem:`Needs fixing`,unused:`Not set up`},Uxe={ok:`done`,warning:`waiting`,problem:`failed`,unused:`off`},Wxe={ok:`text-ink-2`,warning:`text-waiting`,problem:`text-danger`,skipped:`text-ink-3`};function Q7(){let{api:e}=z();return F({mutationFn:()=>L1(e)})}function Gxe(e){let{api:t}=z(),[n,r]=(0,m.useState)({byId:new Map});return{one:F({mutationFn:e=>L1(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 Kxe({run:e}={}){let t=Q7(),n=e??t,r=n.data,i=Gxe(r?.checkedAt),a=r?.providers.filter(e=>e.state!==`unused`).map(i.latest)??[],o=r?.providers.filter(e=>e.state===`unused`)??[];return(0,h.jsxs)(`section`,{"aria-label":`Health check`,children:[(0,h.jsx)(H,{title:`Health check`,info:`settings.health`,children:e===void 0?(0,h.jsx)(R,{disabled:n.isPending,onClick:()=>{n.mutate()},children:n.isPending?`Checking…`:`Check all`}):void 0}),n.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:[`The health check didn't finish: `,n.error.message,` Press Check all to try again.`]}),i.one.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:`The check didn't finish: ${i.one.error.message} Press Check again on the provider to try again.`}),r===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:n.isPending?`Checking every provider…`:`Not checked yet.`}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`ul`,{"aria-label":`Health by provider`,className:`sl-list m-0 list-none p-0`,children:a.map(e=>(0,h.jsxs)(`li`,{className:`sl-row grid-cols-1 gap-1`,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:e.displayName}),(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(TS,{tone:Uxe[e.state],children:Hxe[e.state]}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Check ${e.displayName} 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:L(`text-small`,Wxe[e.state]),children:[(0,h.jsxs)(`span`,{className:`font-semibold`,children:[e.label,`:`]}),` `,e.detail]},e.label))})]},e.id))}),(0,h.jsx)(`p`,{className:`m-0 mt-3 text-small text-ink-2`,children:o.length===0?`Checked at ${new Date(r.checkedAt).toLocaleTimeString()}.`:`Not set up and not used anywhere: ${o.map(e=>e.displayName).join(`, `)}.`})]})]})}var $7={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 e9(e){return nF(e)?{tone:`done`,word:`Ready`}:e.installed?{tone:`waiting`,word:`Needs attention`}:{tone:`off`,word:`Not found`}}function qxe({provider:e,readiness:t,kind:n}){let{api:r}=z(),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,p=e.cliPath?.command??f,g=o??u??``,v=nF(t),y=F({mutationFn:t=>Yo(r,e.id,t),onMutate:()=>l(!1),onSuccess:async e=>{i.setQueryData(B.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:B.providers})}});(0,m.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),q2);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.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`h3`,{id:a,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsx)(V,{id:$7[e.id],label:e.displayName})]}),(0,h.jsxs)(`p`,{className:`sl-section-head__meta`,children:[n,` · command line, no key needed`]})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2`,"aria-live":`polite`,children:[(0,h.jsx)(wS,{tone:e9(t).tone}),(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:Jxe(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)(gV,{className:`min-w-0 truncate`,title:p,children:p})]})]}),(0,h.jsxs)(Py,{children:[d?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-small text-ink-2`,children:[`Managed on host`,(0,h.jsx)(V,{id:`settings.cli.managed-on-host`})]}):(0,h.jsx)(R,{"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)(Y2,{}):null})]}),d||!b?null:(0,h.jsx)(`form`,{id:S,onSubmit:e=>{e.preventDefault(),y.isPending||y.mutate(g)},children:(0,h.jsx)(dV,{label:`Executable path`,tip:`settings.cli.path`,help:(0,h.jsxs)(h.Fragment,{children:[`Leave blank to find `,(0,h.jsx)(gV,{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)(pV,{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)(R,{type:`submit`,variant:`primary`,"aria-label":`Save ${e.displayName} path`,disabled:y.isPending,children:y.isPending?`Checking…`:`Save path`})]})})})]})}function Jxe(e,t){return e.issue===void 0?e.installed?e.version===void 0?`Installed`:`Installed, version ${e.version}`:t===null?`Not found on PATH`:`Not found at saved path`:e.issue}var Yxe=[`providers`,`system-voice`,`voices`];async function Xxe(e){return I(await e.fetch(`${e.origin}/api/providers/system-voice/voices`))}function t9(e=!0){let{api:t}=z();return P({queryKey:Yxe,queryFn:()=>Xxe(t),enabled:e})}function n9(e){return e.available?{tone:`done`,word:`Ready`}:{tone:`off`,word:`Not found`}}function Zxe({provider:e,readiness:t}){let n=(0,m.useId)(),r=t9(t.available).data?.engines??[];return(0,h.jsxs)(`section`,{"aria-labelledby":n,"data-ready":t.available,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`h3`,{id:n,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsx)(V,{id:$7[e.id],label:e.displayName})]}),(0,h.jsx)(`p`,{className:`sl-section-head__meta`,children:`Speech · built into this computer, no key needed`})]}),(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2`,"aria-live":`polite`,children:[(0,h.jsx)(wS,{tone:n9(t).tone}),(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:t.available?`Found ${t.engine??`a speech program`}. Narration with it is free; a keyed voice (ElevenLabs, OpenAI) sounds better.`:t.issue??`No speech program was found on this computer.`})]}),r.length===0?null:(0,h.jsx)(`ul`,{className:`m-0 list-none p-0 text-small text-ink-2`,children:r.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)(Py,{children:(0,h.jsx)(bS,{to:`/settings`,search:{section:`voices`},children:`Add a system voice`})}):null]})}function Qxe({value:e,onPick:t}){let n=t9(),r=n.data?.engines??[];return n.data!==void 0&&r.length===0?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:n.data.issue??`No speech program was found on this computer.`}):(0,h.jsxs)(hV,{value:e,onChange:e=>{for(let n of r){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:n.data===void 0?`Looking for voices…`:`Pick a voice`}),r.map(e=>(0,h.jsx)(`optgroup`,{label:e.name,children:e.voices.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.language===void 0?e.name:`${e.name} (${e.language})`},e.id))},e.id))]})}var r9=[`llm`,`tts`,`image`],i9={llm:`Text`,tts:`Speech`,image:`Images`},$xe=`••••••••••••`;function eSe(e){return nF(e.readiness)}function tSe(e){return e.readiness.kind===`cli`?e9(e.readiness):e.readiness.kind===`local`?n9(e.readiness):e.readiness.hasKey?{tone:`done`,word:`Key saved`}:{tone:`off`,word:`No key`}}function nSe(){let{api:e}=z(),t=P(cb(e)),[n,r]=(0,m.useState)(void 0),i=(0,m.useRef)(null),a=(0,m.useRef)(!1);(0,m.useEffect)(()=>{n!==void 0&&a.current&&(a.current=!1,typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: 1023px)`).matches&&i.current?.scrollIntoView?.({block:`start`,behavior:`smooth`}))},[n]);let o=r9.flatMap(e=>(t.data?.providers??[]).filter(t=>t.family===e)),s=o.find(e=>!eSe(e))??o[0];if(n===void 0&&s!==void 0&&r(s.id),t.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:t.error.message});if(t.data===void 0)return(0,h.jsx)(iSe,{});let c=o.find(e=>e.id===n)??s,l=o.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey),u=e=>{a.current=!0,r(e)};return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:[l?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Paste a key to make its provider selectable on Play.`}):null,r9.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,"aria-labelledby":`keys-${e}-title`,className:`grid items-start gap-x-8 gap-y-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(H,{id:`keys-${e}-title`,title:i9[e],size:`small`,className:`pb-2`}),(0,h.jsx)(oU,{label:`${i9[e]} providers`,children:o.filter(t=>t.family===e).map(e=>{let t=tSe(e);return(0,h.jsx)(sU,{title:e.displayName,meta:e.readiness.kind===`cli`?`Command line`:e.readiness.kind===`local`?`Built in, no key`:`API key`,selected:e.id===c?.id,onSelect:()=>u(e.id),actions:(0,h.jsx)(TS,{tone:t.tone,children:t.word})},e.id)})})]}),c===void 0||c.family!==e?null:(0,h.jsx)(`div`,{ref:i,className:`min-w-0 scroll-mt-4`,children:c.readiness.kind===`cli`?(0,h.jsx)(qxe,{provider:c,readiness:c.readiness,kind:i9[c.family]},c.id):c.readiness.kind===`local`?(0,h.jsx)(Zxe,{provider:c,readiness:c.readiness},c.id):(0,h.jsx)(rSe,{provider:c,hasKey:c.readiness.hasKey},c.id)})]},e))]})}function rSe({provider:e,hasKey:t}){let{api:n}=z(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(void 0),C=(0,m.useId)(),w=HF[e.id],T=o.trim(),E=async()=>{b(!0),S(void 0);try{S(await Dde(n,e.id,T===``?void 0:T))}catch(e){p(e instanceof Error?e.message:String(e))}finally{b(!1)}},D=async()=>{l(!0),p(void 0);try{await Jo(n,e.id,o),s(``),d(!0),S(void 0),await r.invalidateQueries({queryKey:B.providers})}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}},O=F({mutationFn:()=>Xo(n,e.id),onSuccess:async()=>{v(!1),p(void 0),await r.invalidateQueries({queryKey:B.providers})},onError:e=>{v(!1),p(e.message)}});(0,m.useEffect)(()=>{if(!u)return;let e=setTimeout(()=>{d(!1)},q2);return()=>{clearTimeout(e)}},[u]);let k=[t?a:void 0,x===void 0?void 0:C].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`section`,{"aria-labelledby":i,"data-ready":t,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsx)(H,{as:`h3`,size:`default`,id:i,title:t?e.displayName:`Set up ${e.displayName}`,info:$7[e.id],infoLabel:e.displayName,meta:`${i9[e.family]} · ${t?`a key is saved`:`needs an API key`}`,className:`pb-0`}),w===void 0?null:t?(0,h.jsxs)(`details`,{className:`text-small text-ink-2`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer`,children:`Where to get a key`}),(0,h.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:(0,h.jsx)(a9,{guide:w})})]}):(0,h.jsx)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:(0,h.jsx)(a9,{guide:w})}),(0,h.jsx)(dV,{label:`${e.displayName} API key`,tip:`settings.providers.api-key`,help:`Stored on this computer only. Never in backups or exports.`,error:f,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(pV,{type:`password`,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 basis-[200px]`,"aria-describedby":k===``?void 0:k,placeholder:t?$xe:`Paste API key`,value:o,onChange:e=>{s(e.target.value)}}),(0,h.jsx)(R,{variant:`primary`,"aria-label":`Save ${e.displayName} key`,disabled:o.trim()===``||c,onClick:()=>{D()},children:`Save`})]})}),t?(0,h.jsx)(`span`,{id:a,className:`sr-only`,children:`A key is stored for this provider.`}):null,x===void 0?null:(0,h.jsx)(`p`,{id:C,role:x.ok?`status`:`alert`,className:L(`m-0 text-small`,x.ok?`text-accent-ink`:`text-danger`),children:x.message}),(0,h.jsxs)(Py,{children:[(0,h.jsx)(R,{"aria-label":`Test ${e.displayName} key`,disabled:!t&&T===``||y,disabledReason:`Paste a key first.`,onClick:()=>{E()},children:y?`Testing…`:`Test`}),(0,h.jsx)(V,{id:`settings.providers.test-key`,label:`Test`}),(0,h.jsx)(R,{variant:`quiet`,"aria-label":`Remove ${e.displayName} key`,disabled:!t,onClick:()=>{v(!0)},children:`Remove`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:u?(0,h.jsx)(Y2,{}):null})]}),(0,h.jsx)(zy,{open:g,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this provider cannot retry until a key is saved.`,confirmLabel:`Remove key`,pending:O.isPending,onConfirm:()=>{O.mutate()},onCancel:()=>{v(!1)}})]})}function a9({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 provider's `,t(e.docs.url,e.docs.label),`. After saving, choose Test.`]})]})}function iSe(){return(0,h.jsxs)(`div`,{className:`grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,role:`status`,"aria-label":`Loading providers`,children:[(0,h.jsx)(`div`,{className:`flex flex-col gap-6`,children:[[`llm`,4],[`tts`,5],[`image`,5]].map(([e,t])=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`span`,{className:`mb-2 block h-3 w-16 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:`sl-row`,children:[(0,h.jsx)(`span`,{className:`h-4 w-32 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-4 w-20 rounded-control bg-raised`})]},e))})]},e))}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`span`,{className:`h-6 w-48 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-10 rounded-control bg-raised`})]})]})}function o9(e){return e.split(/[\s,;]+/).map(e=>e.trim().toLowerCase()).filter(e=>e!==``)}function aSe(e){return e.languages===void 0?`Any (not known)`:e.languages.map(e=>VO(e).code===e?VO(e).name:e).join(`, `)}function oSe({voice:e}){let{api:t}=z(),n=_(),r=(0,m.useId)(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)((e.languages??[]).join(`, `)),[c,l]=(0,m.useState)(void 0),u=F({mutationFn:()=>ws(t,e.id,o9(o)),onSuccess:async e=>{if(e!==void 0){l(e.message);return}a(!1),l(void 0),await n.invalidateQueries({queryKey:B.voices})}});return i?(0,h.jsxs)(`div`,{className:`grid gap-1`,children:[(0,h.jsx)(pV,{id:r,"aria-label":`Languages of ${e.name}`,value:o,placeholder:`es, de`,"aria-invalid":c!==void 0,onChange:e=>{s(e.target.value),l(void 0)}}),c===void 0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:c}),u.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:u.error.message}),(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(R,{size:`small`,disabled:u.isPending,onClick:()=>u.mutate(),children:`Save`}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,onClick:()=>{a(!1),l(void 0),s((e.languages??[]).join(`, `))},children:`Cancel`})]})]}):(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-ink-2`,children:aSe(e)}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Edit the languages of ${e.name}`,onClick:()=>a(!0),children:`Edit`})]})}function sSe(){let{api:e}=z(),t=_(),n=P(lb(e)),r=P(cb(e)),[i,a]=(0,m.useState)(void 0),o=F({mutationFn:t=>Es(e,t),onSettled:async()=>{a(void 0),await t.invalidateQueries({queryKey:B.voices})}}),s=F({mutationFn:({id:t,on:n})=>Ts(e,t,n),onSettled:async()=>{await t.invalidateQueries({queryKey:B.voices})}}),c=(r.data?.providers??[]).filter(e=>e.family===`tts`);if(n.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:n.error.message});let l=n.data?.voices;return(0,h.jsxs)(`div`,{"data-tour":`voices`,className:`flex min-w-0 flex-col gap-10`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 overflow-x-auto`,children:[(0,h.jsxs)(`table`,{className:`sl-table min-w-[640px] table-fixed`,...Ib,children:[(0,h.jsx)(`caption`,{className:`sr-only`,children:`Voices`}),(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{scope:`col`,className:`w-[22%] pr-4`,children:`Name`}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[18%] pr-4`,children:`Provider`}),(0,h.jsx)(`th`,{scope:`col`,className:`pr-4`,children:`Voice ID`}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[22%] pr-4`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`Languages`,(0,h.jsx)(V,{id:`play.voices.languages`,className:`-my-1`})]})}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[20%] pr-4`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`Real person`,(0,h.jsx)(V,{id:`play.voices.real-person`,className:`-my-1`})]})}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[96px]`,children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:l===void 0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:6,children:(0,h.jsx)(`span`,{className:`block h-4 w-64 rounded-control bg-raised`})})}):l.length===0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:6,className:`text-ink-2`,children:`Add a voice ID from your text-to-speech provider. Audio needs one to narrate.`})}):l.map(e=>(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`td`,{className:`truncate pr-4 font-semibold`,children:e.name}),(0,h.jsx)(`td`,{className:`truncate pr-4 text-ink-2`,children:lSe(c,e.provider)}),(0,h.jsx)(`td`,{className:`truncate pr-4 text-ink-2`,children:e.voiceId}),(0,h.jsx)(`td`,{className:`pr-4`,children:(0,h.jsx)(oSe,{voice:e})}),(0,h.jsx)(`td`,{className:`pr-4`,children:(0,h.jsx)(Lb,{checked:s.isPending&&s.variables.id===e.id?s.variables.on:e.imitatesRealPerson===!0,disabled:s.isPending,onChange:t=>s.mutate({id:e.id,on:t}),label:(0,h.jsx)(`span`,{className:`sr-only`,children:`${e.name} imitates a real person`}),className:`text-small`})}),(0,h.jsx)(`td`,{className:`text-right`,children:(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Remove ${e.name}`,onClick:()=>{a(e)},children:`Remove`})})]},e.id))})]}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:`Couldn't change Real person: ${s.error.message} Press the switch again.`}),o.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:o.error.message})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{title:`Add a voice`}),(0,h.jsx)(cSe,{tts:c})]}),(0,h.jsx)(zy,{open:i!==void 0,title:i===void 0?``:`Remove ${i.name}?`,consequence:`Projects that used this voice keep the audio they made with it.`,confirmLabel:`Remove voice`,pending:o.isPending,onConfirm:()=>{i!==void 0&&o.mutate(i.id)},onCancel:()=>{a(void 0)}})]})}function cSe({tts:e}){let{api:t}=z(),n=_(),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(void 0),[d,f]=(0,m.useState)(void 0),p=l??e[0]?.id,g=F({mutationFn:e=>Cs(t,e),onSuccess:async e=>{if(!e.ok){f(e.refusal);return}i(``),o(``),c(``),f(void 0),await n.invalidateQueries({queryKey:B.voices})}}),v=(e,t)=>{t(),d?.field===e&&f(void 0)},y=e=>d?.field===e?d.message:void 0;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`grid items-start gap-4 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,h.jsx)(dV,{label:`Voice name`,tip:`play.voices.name`,error:y(`name`),children:(0,h.jsx)(pV,{value:r,onChange:e=>{let t=e.target.value;v(`name`,()=>{i(t)})}})}),(0,h.jsx)(dV,{label:`Provider`,tip:`play.voices.provider`,error:y(`provider`),children:(0,h.jsxs)(hV,{value:p??``,onChange:t=>{let n=e.find(e=>e.id===t.target.value);n!==void 0&&v(`provider`,()=>{u(n.id)})},children:[e.length===0?(0,h.jsx)(`option`,{value:``,children:`No speech provider`}):null,e.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.displayName},e.id))]})}),(0,h.jsx)(dV,{label:`Voice ID`,tip:`play.voices.voice-id`,error:y(`voiceId`),...p===`inworld`?{help:`Use an Inworld voice ID, such as Dennis, or one from your workspace.`}:{},children:p===`system-voice`?(0,h.jsx)(Qxe,{value:a,onPick:e=>{v(`voiceId`,()=>{o(e.id)}),r.trim()===``&&i(e.name);let t=/^([a-z]{2,3})(?:[-_]|$)/i.exec(e.language??``)?.[1];s.trim()===``&&t!==void 0&&c(t.toLowerCase())}}):p===`google-tts`?(0,h.jsx)(hV,{value:a,options:[{value:``,label:`Pick a Gemini voice`},...GF.map(e=>({value:e.name,label:`${e.name} (${e.style})`}))],onChange:e=>{let t=e.target.value;v(`voiceId`,()=>{o(t),r.trim()===``&&i(t)})}}):(0,h.jsx)(pV,{className:`tabular-nums`,value:a,onChange:e=>{let t=e.target.value;v(`voiceId`,()=>{o(t)})}})}),(0,h.jsx)(dV,{label:`Languages`,tip:`play.voices.languages`,help:`Codes such as es, de.`,error:y(`languages`),children:(0,h.jsx)(pV,{value:s,placeholder:`es, de`,onChange:e=>{let t=e.target.value;v(`languages`,()=>{c(t)})}})}),(0,h.jsx)(R,{variant:`primary`,className:`md:mt-6`,disabled:p===void 0||d!==void 0||g.isPending,onClick:()=>{if(p!==void 0){let e=o9(s);g.mutate({provider:p,name:r,voiceId:a,...e.length===0?{}:{languages:e}})}},children:`Add voice`})]}),g.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:g.error.message})]})}function lSe(e,t){return e.find(e=>e.id===t)?.displayName??t}var s9=[`settings`,`notifications`],uSe=`The test notification couldn't be shown: this browser only allows notifications from installed apps. Set a Notification URL below instead.`;function dSe(){return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{title:`Browser and phone`,info:`settings.notifications`}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsx)(fSe,{}),(0,h.jsx)(pSe,{}),(0,h.jsx)(mSe,{})]})]})}function fSe(){let e=(0,m.useSyncExternalStore)(yP,_P,()=>!1),[t,n]=(0,m.useState)(gP),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=Iy(),c=e&&t===`granted`;async function l(e){if(i(void 0),!e){vP(!1);return}o(!0);try{let e=await SP();n(e);let t=xP(e);e===`granted`?(vP(!0),_P()||i(`Browser 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 Browser notifications on again.`)):i(t??`Browser notifications weren't turned on because the permission prompt was dismissed. Turn Browser notifications 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-center gap-x-6 gap-y-2`,children:[(0,h.jsx)(Lb,{label:`Browser notifications`,tip:`settings.notifications.browser`,checked:c,disabled:a,onChange:e=>void l(e)}),(0,h.jsx)(R,{variant:`quiet`,disabled:!c,disabledReason:`Turn Browser notifications on first.`,onClick:()=>{i(void 0);try{wP({projectId:`test`,text:WP},()=>{}),s(`Test notification sent to this browser.`,`success`)}catch{i(uSe)}},children:`Send test notification`})]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Works while any Slopify tab is open.`}),r===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:r})]})}function pSe(){let e=(0,m.useSyncExternalStore)(jP,kP,()=>!0);return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,h.jsx)(Lb,{label:`Run sounds`,tip:`settings.notifications.sounds`,checked:e,onChange:AP}),(0,h.jsx)(R,{variant:`quiet`,onClick:()=>IP(`start`),children:`Play start`}),(0,h.jsx)(R,{variant:`quiet`,onClick:()=>IP(`end`),children:`Play end`})]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`A chime when a run starts and a different one when it finishes, fails or waits for you. Works while any Slopify tab is open; set your computer's volume for how loud.`})]})}function mSe(){let{api:e}=z(),t=_(),n=Iy(),r=(0,m.useId)(),i=P({queryKey:s9,queryFn:()=>$o(e)}),[a,o]=(0,m.useState)(void 0),s=a??i.data?.url??``,c=KP(s),l=F({mutationFn:t=>ts(e,t),onSuccess:e=>{t.setQueryData(s9,e),o(void 0),n(e.url===null?`Notification URL removed.`:`Notification URL saved.`,`success`)}}),u=F({mutationFn:t=>ns(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;return(0,h.jsxs)(dV,{label:`Notification URL`,tip:`settings.notifications.url`,help:`Works with no tab open, for example an ntfy topic on your phone.`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(pV,{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)(R,{variant:`primary`,disabled:f||c!==void 0||a===void 0,onClick:()=>l.mutate(s),children:`Save`}),(0,h.jsx)(R,{variant:`quiet`,disabled:f||c!==void 0||s.trim()===``,onClick:()=>u.mutate(s),children:`Send test notification`})]}),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})]})}var c9={library:`The Library of Alexandria`,audiobook:`The Wind in the Willows (audiobook)`,podcast:`The Antikythera Mechanism (podcast)`};function hSe(){let{api:e}=z(),t=_(),n=P({queryKey:Vy,queryFn:()=>Yy(e)}),r=F({mutationFn:()=>Zy(e),onSettled:async()=>{await t.invalidateQueries({queryKey:Vy}),await t.invalidateQueries({queryKey:By}),await t.invalidateQueries({queryKey:B.projects})}}),i=r.data?.samples??n.data?.samples;return(0,h.jsxs)(`div`,{className:`mt-8`,children:[(0,h.jsx)(H,{title:`Sample projects`,info:`settings.sample.restore`}),(0,h.jsx)(oU,{label:`Sample projects`,children:Object.keys(c9).map(e=>{let t=i?.[e]??null;return(0,h.jsx)(sU,{title:c9[e],meta:t===null?`Not in your projects`:`In your projects`,actions:t===null?void 0:(0,h.jsx)(xS,{to:`/projects/$projectId`,params:{projectId:t},className:aU,children:`Open`})},e)})}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(R,{disabled:r.isPending,onClick:()=>r.mutate(),children:r.isPending?`Restoring…`:`Restore samples`}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Puts all three back as they shipped.`})]}),(0,h.jsx)(G1,{tone:r.error?`error`:`success`,children:r.error?.message??(r.isSuccess?`The samples are back in Projects.`:void 0)})]})}var gSe=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function _Se(e){let[t,n,r]=e.split(`-`).map(Number),i=gSe[(n??0)-1];return i===void 0||r===void 0?e:`${String(r)} ${i} ${String(t)}`}function l9(e,t){let n=[e.range===void 0?e.version:`Versions ${e.range}`,`released ${_Se(e.date)}`].filter(e=>e!==void 0).join(`, `),r=n.charAt(0).toUpperCase()+n.slice(1);return e.version===t?`${r}. The version you are running.`:`${r}.`}function vSe({note:e,onNote:t}){let{api:n}=z(),r=P(mI(n));if(r.error!==null)return(0,h.jsx)(vI,{tone:`danger`,title:`The patch notes did not load`,actions:(0,h.jsx)(R,{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 the patch notes…`});let{notes:i,version:a}=r.data,[o,...s]=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 c=e===void 0?void 0:i.find(t=>t.id===e),l=c!==void 0&&c.id!==o.id?c:void 0;return l===void 0?(0,h.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e!==void 0&&c===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 latest are below; older ones are under Earlier versions.`}):null,(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(H,{title:`Latest version`,meta:l9(o,a),info:`settings.patch-notes`}),(0,h.jsx)(mB,{id:o.id})]}),s.length===0?null:(0,h.jsxs)(`details`,{className:`max-w-prose border-t border-line py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer font-semibold`,children:`Earlier versions (${String(s.length)})`}),(0,h.jsx)(oU,{label:`Earlier versions`,className:`mt-2`,children:s.map(e=>(0,h.jsx)(sU,{title:e.title,meta:l9(e,a),onSelect:()=>t(e.id),actions:(0,h.jsx)(R,{"aria-label":`Read ${e.title}`,onClick:()=>t(e.id),children:`Read`})},e.id))})]})]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`div`,{children:(0,h.jsxs)(R,{variant:`quiet`,onClick:()=>t(void 0),children:[(0,h.jsx)(dc,{"aria-hidden":`true`,strokeWidth:1.75}),`Back to the latest patch notes`]})}),(0,h.jsx)(H,{title:`Earlier version`,meta:l9(l,a)}),(0,h.jsx)(mB,{id:l.id})]})}var u9=[`trash`];async function ySe(e){return(await I(await e.client.trash.$get())).items}async function bSe(e,t,n){return(await I(await e.client.trash[`:kind`][`:id`].restore.$post({param:{kind:t,id:n}}))).restored}async function xSe(e,t,n){let r=await e.client.trash[`:kind`][`:id`].$delete({param:{kind:t,id:n}});if(!r.ok)throw await fo(r)}var SSe={project:`Project`,prompt:`Prompt`,entry:`Intro/outro`,template:`Template`,schedule:`Schedule`};function CSe(e){return e.kind===`entry`&&e.detail!==null?e.detail===`intro`?`Intro`:`Outro`:e.kind===`prompt`&&e.detail!==null?`Prompt · ${e.detail}`:SSe[e.kind]}function wSe(e){return e<=0?`removed for good today`:e===1?`1 day left`:`${String(e)} days left`}var TSe=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}),ESe={project:[B.projects,[`calendar`]],prompt:[B.prompts],entry:[B.entries],template:[Aq],schedule:[vH,[`calendar`]]};function DSe(){let{api:e}=z(),t=_(),n=Iy(),r=P({queryKey:u9,queryFn:()=>ySe(e)}),[i,a]=(0,m.useState)(void 0),o=async e=>{await Promise.all([u9,...ESe[e.kind]].map(e=>t.invalidateQueries({queryKey:e})))},s=F({mutationFn:t=>bSe(e,t.kind,t.id),onSuccess:async(e,t)=>{await o(t),n(e.renamedFrom===null?`Restored "${e.name}".`:`Restored as "${e.name}": another item is now called "${e.renamedFrom}".`,`success`),e.kind===`schedule`&&n(`The schedule is paused. Press Resume on Schedules to run it again.`,`info`)},onError:e=>n(e.message,`error`)}),c=F({mutationFn:t=>xSe(e,t.kind,t.id),onSuccess:async(e,t)=>{a(void 0),await o(t),n(`Deleted "${t.name}" for good.`,`success`)},onError:e=>{a(void 0),n(e.message,`error`)}}),l=r.data??[];return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{title:`Trash`,info:`settings.trash`}),r.isPending?(0,h.jsx)(`p`,{className:`text-small text-ink-3`,children:`Loading the trash…`}):r.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-danger`,children:r.error.message}):l.length===0?(0,h.jsx)(Q1,{title:`The trash is empty`,children:`Anything you delete stays here for 30 days before it is removed for good.`}):(0,h.jsx)(oU,{label:`Deleted items`,children:l.map(e=>(0,h.jsx)(sU,{title:e.name,meta:`${CSe(e)} · deleted ${TSe.format(new Date(e.deletedAt))} · ${wSe(e.daysLeft)}`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R,{size:`small`,disabled:s.isPending||c.isPending,disabledReason:`Working on it`,onClick:()=>s.mutate(e),children:`Restore`}),(0,h.jsx)(R,{size:`small`,variant:`destructive`,disabled:s.isPending||c.isPending,disabledReason:`Working on it`,onClick:()=>a(e),children:`Delete now`})]})},`${e.kind}:${e.id}`))}),(0,h.jsx)(zy,{open:i!==void 0,title:i===void 0?``:`Delete "${i.name}" for good?`,consequence:i?.kind===`project`?`The project and every file it produced are removed from disk. This cannot be undone.`:i?.kind===`schedule`?`The schedule leaves the trash and cannot be restored. Its run history stays on Schedules.`:`It is removed for good. This cannot be undone.`,confirmLabel:`Delete for good`,cancelLabel:`Keep it`,pending:c.isPending,onConfirm:()=>{i!==void 0&&c.mutate(i)},onCancel:()=>{c.isPending||a(void 0)}})]})}var OSe=`https://github.com/GentBajko/slopify`,kSe=`https://www.patreon.com/cw/GentBajko`,ASe=`https://buymeacoffee.com/gentbajko`;function jSe(){return[{href:OSe,label:`GitHub`,detail:`The code, issues and releases.`,glyph:`github`},{href:kSe,label:`Patreon`,detail:`Monthly support for the project.`,glyph:`patreon`},{href:ASe,label:`Buy Me a Coffee`,detail:`A one-off thank you.`,glyph:`coffee`},{href:`https://slopify.stream/channel.html`,label:`How I run a channel with it`,detail:`A lore channel run on Slopify, start to finish.`}]}function MSe({onWhatsNew:e}){return(0,h.jsxs)(`div`,{className:`max-w-prose`,children:[(0,h.jsx)(H,{title:`About`}),(0,h.jsx)(`p`,{className:`m-0 mb-3 text-ink-2`,children:`Slopify is free and open source, and runs on your machine with your own keys. If it saves you time, you can support it here.`}),(0,h.jsxs)(`p`,{className:`m-0 mb-3 flex items-center gap-1 text-small text-ink-2`,children:[`Updates: the circular-arrows button at the foot of the sidebar (at the top on a phone).`,(0,h.jsx)(V,{id:`settings.updates`})]}),e===void 0?null:(0,h.jsxs)(`p`,{className:`m-0 mb-3 flex items-center gap-1`,children:[(0,h.jsx)(R,{onClick:e,children:`What's new in this version`}),(0,h.jsx)(V,{id:`settings.whats-new`})]}),(0,h.jsx)(`p`,{className:`m-0 mb-4 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)(`ul`,{"aria-label":`Links`,className:`sl-list m-0 list-none p-0`,children:jSe().map(e=>(0,h.jsx)(`li`,{className:`sl-row`,children:(0,h.jsxs)(`div`,{className:`sl-row__lead`,children:[e.glyph===void 0?(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}):(0,h.jsx)(_S,{name:e.glyph,className:`shrink-0 text-ink-2`}),(0,h.jsxs)(`div`,{className:`sl-row__text`,children:[(0,h.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`font-semibold text-ink underline underline-offset-3`,children:e.label}),(0,h.jsx)(`span`,{className:`sl-row__meta`,children:e.detail})]})]})},e.label))})]})}var d9=[`backups`],f9=1,p9=30;function m9(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function NSe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=f9&&Number(t)<=p9?void 0:`Keep between ${f9} and ${p9} backups.`}function PSe(e){return{enabled:e.config.enabled,time:e.config.time,keep:String(e.config.keep),folder:e.config.folder??``}}function h9(){let{api:e}=z(),t=_(),n=Iy();return F({mutationFn:()=>ko(e),onSuccess:e=>{t.setQueryData(d9,e),n(`Backup started. Its result shows here when it finishes.`,`success`)}})}function FSe(){let{api:e}=z(),t=_(),n=P({queryKey:d9,queryFn:()=>Do(e),refetchInterval:e=>e.state.data?.running===!0&&2e3}),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=F({mutationFn:t=>Oo(e,t),onSuccess:e=>{t.setQueryData(d9,e),i(void 0),o(!0)}}),c=h9();(0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),q2);return()=>clearTimeout(e)},[a]);let l=n.data,u=r??(l===void 0?void 0:PSe(l)),d=u===void 0?void 0:NSe(u.keep),f=e=>{u!==void 0&&i({...u,...e})};return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{title:`Daily backup`,info:`settings.backups`,children:(0,h.jsx)(R,{variant:`primary`,disabled:l===void 0||l.running||c.isPending,onClick:()=>c.mutate(),children:`Back up now`})}),(0,h.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-x-4 gap-y-1 text-small text-ink-2`,children:[(0,h.jsx)(`span`,{role:`status`,children:l===void 0?(0,h.jsx)(`span`,{className:`inline-block h-4 w-48 rounded-control bg-raised`}):ISe(l)}),(0,h.jsx)(`span`,{children:l===void 0?null:LSe(l)})]}),l?.status.detail?l.status.lastResult===`failed`?(0,h.jsx)(vI,{tone:`danger`,title:`Why the last backup stopped`,children:l.status.detail}):(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:l.status.detail}):null,c.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:c.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-6`,children:[(0,h.jsx)(Lb,{label:`Back up automatically`,tip:`settings.backups.auto`,checked:u?.enabled===!0,disabled:u===void 0,className:`self-start`,onChange:e=>f({enabled:e})}),(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(dV,{label:`Time of day`,tip:`settings.backups.time`,help:`${m9()} time`,children:(0,h.jsx)(pV,{type:`time`,className:`w-[140px] tabular-nums`,value:u?.time??`03:00`,disabled:u===void 0,onChange:e=>f({time:e.target.value})})}),(0,h.jsx)(dV,{label:`Keep last`,tip:`settings.backups.keep`,help:`Backups kept in the folder.`,error:d,children:(0,h.jsx)(pV,{type:`number`,inputMode:`numeric`,min:f9,max:p9,step:1,className:`w-[88px] tabular-nums`,value:u?.keep??`5`,disabled:u===void 0,onChange:e=>f({keep:e.target.value})})}),(0,h.jsx)(dV,{label:`Folder`,tip:`settings.backups.folder`,className:`md:col-span-2`,...l===void 0?{}:{help:RSe(l)},children:(0,h.jsx)(pV,{value:u?.folder??``,placeholder:l?.defaultFolder??``,disabled:u===void 0,onChange:e=>f({folder:e.target.value})})})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(R,{variant:`primary`,disabled:u===void 0||d!==void 0||s.isPending,onClick:()=>{u!==void 0&&(o(!1),s.mutate({enabled:u.enabled,time:u.time,timeZone:m9(),keep:Number(u.keep.trim()),folder:u.folder.trim()===``?null:u.folder.trim()}))},children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(Y2,{}):null}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 basis-full text-small text-danger`,children:s.error.message})]})]})]})}function g9(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function ISe(e){if(e.running)return`Backing up now…`;let{status:t}=e,n=t.lastSuccessAt===null?`No backup yet.`:`Last backup ${g9(t.lastSuccessAt)}${t.lastSuccessBytes===null?``:`, ${_9(t.lastSuccessBytes)}`}.`;return t.lastResult===`failed`&&t.lastAttemptAt!==null?`${n} The backup at ${g9(t.lastAttemptAt)} failed.`:t.lastResult===`waiting`?`${n} Waiting for projects to finish.`:n}function LSe(e){return e.config.enabled?e.overdue?`Next: shortly.`:e.nextRunAt===null?``:`Next: ${g9(e.nextRunAt)}.`:`Automatic backups are off.`}function RSe(e){let t=`${e.files.length} backup${e.files.length===1?``:`s`} here (${_9(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}`:`${e.config.folder===null?`Empty uses the default: `:`On your computer: `}${e.hostFolder}. ${t}`}function _9(e){if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e,r=t[0]??`KB`;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}`}var v9=[`storage-files`];function zSe({usageQueryKey:e}){let{api:t}=z(),n=_(),r=Iy(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(),u=P({queryKey:v9,queryFn:()=>Io(t),refetchInterval:e=>b9(e.state.data)?1e3:!1}),d=F({mutationFn:e=>Lo(t,e),onMutate:()=>l(void 0),onSuccess:e=>{n.setQueryData(v9,e),a(!1)},onError:e=>l(e.message)}),f=F({mutationFn:()=>Ro(t),onSuccess:e=>{e.opened||r(`Your files are in ${e.path}.`,`info`)},onError:e=>r(e.message,`error`)}),p=u.data,g=b9(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)(H,{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)(H,{title:`Your files`,meta:p.folder??`The Docker project folder isn't set up.`,info:`settings.files.docker`,children:(0,h.jsx)(R,{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)(y9,{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:[`To move your projects to Documents/Slopify, run this on the computer running Docker (or use `,(0,h.jsx)(gV,{children:`--projects-dir <folder>`}),` for another folder):`]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(gV,{className:`min-w-0 break-all`,children:p.dockerCommand}),(0,h.jsx)(R,{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)(H,{title:`Your files`,meta:p.folder,info:`settings.files`,children:[p.inDocuments||p.documentsRoot===null?null:(0,h.jsx)(R,{variant:`primary`,disabled:g||d.isPending,onClick:()=>d.mutate(`documents`),children:`Move to Documents/Slopify`}),(0,h.jsx)(R,{disabled:f.isPending,onClick:()=>f.mutate(),children:`Open folder`}),(0,h.jsx)(R,{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)(y9,{view:p}),i?(0,h.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),d.mutate(o)},children:[(0,h.jsx)(dV,{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)(pV,{value:o,placeholder:p.documentsRoot??`/home/you/Videos/Slopify`,onChange:e=>s(e.target.value)})}),(0,h.jsx)(R,{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 (`,Y5(p.move.bytes),` of `,Y5(p.move.totalBytes),`). Keep Slopify running until it finishes.`]}),(0,h.jsx)(G2,{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)(vI,{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)(R,{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)(vI,{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 y9({view:e}){let t=[[`Projects`,e.projects],[`Automatic backups`,e.backups],[`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 b9(e){return e?.move?.phase===`copying`||e?.move?.phase===`verifying`}function BSe(){let{api:e}=z(),t=P(sb(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)(qSe,{cells:5}),(0,h.jsx)(JSe,{})]}):null:(0,h.jsx)(HSe,{usage:t.data})]})}var VSe=[{id:`stage`,header:`Stage`,cell:e=>rF[e.stage]},{id:`model`,header:`Provider · model`,cell:e=>USe(e)},{id:`in`,header:`Tokens in`,numeric:!0,cell:e=>x9.format(e.tokensIn)},{id:`out`,header:`Tokens out`,numeric:!0,cell:e=>x9.format(e.tokensOut)}];function HSe({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(q1,{split:`even`,children:[(0,h.jsxs)(J1,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(U2,{children:KSe(e).map(e=>(0,h.jsx)(W2,{label:e.label,value:e.value},e.label))}),t?(0,h.jsx)(`p`,{className:`m-0 mt-3 text-body text-ink-2`,children:`Numbers appear after your first run.`}):null]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Machine ID ${e.machineId??`not made yet`} · Slopify ${e.appVersion}`})]}),(0,h.jsx)(J1,{children:(0,h.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,h.jsx)(K2,{caption:`Tokens by stage`,columns:VSe,rows:e.byStage,rowKey:e=>`${e.stage}/${e.provider}/${e.model??``}`,empty:`No stages have run yet.`,className:`min-w-[480px] [&_td]:pr-4 [&_th]:pr-4`})})})]})}function USe(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var x9=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),WSe=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),GSe=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function KSe(e){let t=e.counters;return[{label:`Videos made`,value:x9.format(t.videosMade)},{label:`Hours of audio`,value:WSe.format(t.audioSeconds/3600)},{label:`Images made`,value:x9.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?x9.format(t.tokensUsed):GSe.format(t.tokensUsed)},{label:`Projects`,value:x9.format(t.projects)}]}function qSe({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 JSe(){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))})}var S9=[`storage-usage`],YSe=[S9,B.projects,[`project`],B.usage,B.documentThemes,vH,[`play-drafts`],B.settings,B.providers,B.voices,B.prompts,B.entries,B.staging,Aq,cN,[`provider-models`]];async function XSe(e){await Promise.all(YSe.map(t=>e.invalidateQueries({queryKey:t})))}var C9=30,ZSe=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function QSe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=C9?void 0:`The silence gap is a whole number of seconds between 0 and ${String(C9)}.`}var w9=[{id:`general`,label:`General`,meta:`How Slopify starts on this computer.`},{id:`providers`,label:`Providers`,meta:`Keys stay on this machine and go only to their provider. Readiness is checked again before each run.`},{id:`voices`,label:`Voices`,meta:`A wrong voice ID shows up when the audio stage uses it.`},{id:`models`,label:`Models`,meta:`New models, prices and retirements, checked once a day.`},{id:`playback`,label:`Playback & appearance`,meta:`How narration is paced and how Slopify looks.`},{id:`notifications`,label:`Notifications`,meta:`When a run finishes, fails, waits for you, or a review needs a decision.`},{id:`channel-links`,label:`Channel links`,meta:`The links a YouTube description's {{Name}} placeholders fill from.`},{id:`studio`,label:`YouTube Studio`,meta:`The playlist upload packs name, and the Studio extension's pairing.`},{id:`storage`,label:`Backup & storage`,meta:`Export everything, import a backup, and see what uses disk space.`},{id:`backups`,label:`Backups`,meta:`A daily copy of everything, in a folder you choose.`},{id:`trash`,label:`Trash`,meta:`Deleted projects, prompts, templates and schedules, kept for 30 days.`},{id:`usage`,label:`Usage`,meta:`This machine only. The same counters, anonymised, feed slopify.stream.`},{id:`patch-notes`,label:`Patch notes`,meta:`What changed in each version of Slopify.`},{id:`about`,label:`About`,meta:`Free and open source, running on your machine with your own keys.`}];function $Se(e){return w9.find(t=>t.id===e)?.id??`providers`}function eCe(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 tCe({section:e=`providers`,note:t,onSection:n=()=>{},onNote:r=()=>{}}){let{api:i}=z(),a=_(),o=Iy(),s=Q7(),c=h9(),l=w9.find(t=>t.id===e)??w9[0];return Ox({id:`settings.check-providers`,title:`Check all providers`,group:`Settings`,keywords:[`health`,`keys`,`signed in`],run:()=>{n(`providers`),s.mutate()}}),Ox({id:`settings.back-up-now`,title:`Back up now`,group:`Settings`,keywords:[`backup`],run:()=>{n(`backups`),c.mutate(void 0,{onError:e=>{o(`The backup didn't start: ${e.message} Open Settings → Backups to see its state.`,`error`)}})}}),Ox({id:`settings.download-diagnostics`,title:`Download diagnostics`,group:`Settings`,keywords:[`support`,`bug report`],run:()=>{eCe(i.origin)}}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{crumb:`Settings`,title:l.label,meta:l.meta,actions:(0,h.jsxs)(h.Fragment,{children:[e===`providers`?(0,h.jsx)(R,{disabled:s.isPending,onClick:()=>s.mutate(),children:s.isPending?`Checking…`:`Check all`}):null,(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsxs)(SS,{variant:`secondary`,href:`${i.origin}/api/diagnostics`,download:`slopify-diagnostics.json`,children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,strokeWidth:1.75}),`Download diagnostics`]}),(0,h.jsx)(V,{id:`settings.diagnostics`})]})]})}),(0,h.jsx)(Cq,{sections:(0,h.jsx)(Q6,{label:`Settings sections`,children:w9.map(t=>(0,h.jsx)($6,{current:t.id===e,onClick:()=>n(t.id),className:`whitespace-nowrap max-md:w-auto`,children:t.label},t.id))}),children:(0,h.jsxs)(`section`,{"aria-label":l.label,className:`flex min-w-0 flex-col gap-10`,children:[e===`providers`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R3,{}),(0,h.jsx)(nSe,{}),(0,h.jsx)(Kxe,{run:s})]}):null,e===`general`?(0,h.jsx)(qb,{}):null,e===`voices`?(0,h.jsx)(sSe,{}):null,e===`models`?(0,h.jsx)(Bxe,{}):null,e===`playback`?(0,h.jsx)(aCe,{}):null,e===`notifications`?(0,h.jsx)(dSe,{}):null,e===`channel-links`?(0,h.jsx)(gpe,{}):null,e===`studio`?(0,h.jsx)(epe,{}):null,e===`storage`?(0,h.jsx)(zSe,{usageQueryKey:S9}):null,e===`storage`?(0,h.jsx)(nCe,{}):null,e===`storage`?(0,h.jsx)(hSe,{}):null,e===`backups`?(0,h.jsx)(FSe,{}):null,e===`trash`?(0,h.jsx)(DSe,{}):null,e===`usage`?(0,h.jsx)(BSe,{}):null,e===`patch-notes`?(0,h.jsx)(vSe,{note:t,onNote:r}):null,e===`about`?(0,h.jsx)(MSe,{onWhatsNew:()=>{a.fetchQuery(mI(i)).then(e=>r(e.current??void 0),e=>{o(`The patch notes did not open: ${e instanceof Error?e.message:String(e)} Open Settings → Patch notes to try again.`,`error`)})}}):null]})})]})}var T9=`The backup wasn't imported. Check it is a file made with Export everything (.tar) or Export backup (.zip), then try again.`;function nCe(){let{api:e}=z(),t=_(),n=P({queryKey:S9,queryFn:()=>Fo(e),staleTime:3e4}),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)({phase:`idle`}),[s,c]=(0,m.useState)({phase:`idle`}),[l,u]=(0,m.useState)(null),d=Iy(),[f,p]=(0,m.useState)(null);async function g(){p(null),o({phase:`preparing`});try{let t=await Eo(e);if(!t.ready){o({phase:`idle`}),p(t.detail??`The backup can't be made right now. Try again in a moment.`);return}o({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){o({phase:`idle`}),p(e instanceof Error?e.message:`The backup couldn't be prepared. Try again in a moment.`)}}async function v(n){let r=n.name.toLowerCase().endsWith(`.zip`)||n.type===`application/zip`;if(n.size===0||r&&n.size>104857600){p(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.`);return}i(!0),p(null),u(null),c({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)=>{c(e>=t?{phase:`importing`}:{phase:`uploading`,sent:e,total:t})}),a=await i.json();if(!i.ok)throw Error(a.detail??T9);a.projects===void 0?d(`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`):(u(a),d(`Backup imported.`,`success`)),await XSe(t)}catch(e){p(e instanceof Error?e.message:T9)}finally{c({phase:`idle`}),i(!1)}}async function y(){i(!0),p(null);try{let n=await e.fetch(`${e.origin}/api/storage/cleanup`,{method:`POST`}),r=await n.json();if(!n.ok)throw Error(`Clean orphan files didn't finish. Try again in a moment.`);d(`Removed ${r.orphanFiles??0} orphan project file(s) and ${r.stagedFiles??0} stale staged file(s).`,`success`),await t.invalidateQueries({queryKey:S9})}catch(e){p(e instanceof Error?e.message:`Clean orphan files didn't finish. Try again in a moment.`)}finally{i(!1)}}Ox({id:`settings.export-everything`,title:`Export everything`,group:`Settings`,context:`Backup & storage`,keywords:[`backup`,`download`],run:()=>{!r&&a.phase!==`preparing`&&g()}});let b=r||a.phase===`preparing`,x=(0,m.useRef)(null);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(H,{title:`Export and import`,info:`settings.storage.export`,children:[(0,h.jsx)(R,{disabled:b,onClick:()=>void g(),children:`Export everything`}),(0,h.jsx)(R,{disabled:b,onClick:()=>x.current?.click(),children:`Import a backup`}),(0,h.jsx)(`input`,{ref:x,className:`sr-only`,type:`file`,tabIndex:-1,"aria-label":`Import a backup`,accept:`.tar,application/x-tar,.zip,application/zip`,disabled:b,onChange:e=>{let t=e.target.files?.[0];t&&v(t),e.target.value=``}}),(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(R,{variant:`quiet`,disabled:b,onClick:()=>void y(),children:`Clean orphan files`}),(0,h.jsx)(V,{id:`settings.storage.clean`})]})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`p`,{className:`m-0`,children:`Provider keys are never included in a backup. After importing, enter them again in Settings → Providers.`}),a.phase===`preparing`?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink`,children:`Preparing the backup…`}):null,a.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 `,Y5(a.bytes),` (`,a.projects,` project`,a.projects===1?``:`s`,`). Your browser's downloads show its progress; keep Slopify running until it finishes.`]}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,onClick:()=>o({phase:`idle`}),children:`Dismiss`})]}):null,s.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: `,Y5(s.sent),` of`,` `,Y5(s.total)]}),(0,h.jsx)(G2,{label:`Backup upload`,value:s.total===0?0:s.sent/s.total})]}):null,s.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,f?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-danger`,children:f}):null]})]}),l?(0,h.jsx)(iCe,{result:l,onDismiss:()=>u(null)}):null,(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{title:`Disk space`,info:`settings.storage.disk`,meta:n.data?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`font-semibold text-ink`,children:[Y5(n.data.data),` stored`]}),(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[` `,`· `,Y5(Math.max(0,n.data.projects-n.data.trash.bytes)),` project files · `,Y5(n.data.staging),` staged files`,n.data.trash.projects>0?` · ${Y5(n.data.trash.bytes)} in the trash (${rCe(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)(Dye,{projects:n.data.byProject,queryKey:[...S9]}):null]})]})}function rCe(e){return e===1?`1 deleted project`:`${String(e)} deleted projects`}function E9(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 iCe({result:e,onDismiss:t}){let n=[e.projects.imported.length>0?`Projects: ${e.projects.imported.length} added (${Y5(e.files.bytes)} of files).`:`Projects: none added.`,E9(`Prompts`,e.prompts),E9(`Intros and outros`,e.entries),E9(`Channels`,e.channels),E9(`Cast members`,e.cast),E9(`Episode memories`,e.episodeMemories),E9(`Existing videos`,e.channelVideos),E9(`Document themes`,e.documentThemes),E9(`Templates`,e.templates),E9(`Schedules`,e.schedules),e.schedules.paused>0?`${e.schedules.paused} schedule(s) arrived paused so two installs never run them both; resume them on the Schedules screen.`:null,E9(`Voices`,e.voices),E9(`Play drafts`,e.drafts),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.`,`Provider keys are not in backups: enter them in Settings → Providers.`].filter(e=>e!==null);return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{as:`h3`,title:`Imported the backup from ${e.backup.createdAt.slice(0,10)}`,children:(0,h.jsx)(R,{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:e},e)),e.projects.skipped.map(e=>(0,h.jsxs)(`li`,{className:`py-0.5`,children:[`Skipped “`,e.title,`”: `,e.reason]},e.id))]})]})}function aCe(){let{api:e}=z(),t=_(),n=P(mb(e)),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=F({mutationFn:t=>Qo(e,t),onMutate:e=>{let n=t.getQueryData(B.settings);return t.setQueryData(B.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(B.settings,r.previous)},onSuccess:e=>{t.setQueryData(B.settings,e)}});if((0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>{o(!1)},q2);return()=>{clearTimeout(e)}},[a]),n.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:n.error.message});if(n.data===void 0)return(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`})]});let c=n.data,l=r??String(c.silenceGapSeconds),u=QSe(l);return(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(dV,{label:`Silence between segments`,tip:`settings.playback.silence-gap`,help:`Seconds of quiet between narrated segments.`,error:u??s.error?.message,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(pV,{type:`number`,inputMode:`numeric`,min:0,max:C9,step:1,className:`w-[88px] tabular-nums`,value:l,"aria-invalid":u!==void 0,onChange:e=>{i(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`seconds`}),(0,h.jsx)(R,{variant:`primary`,disabled:u!==void 0||s.isPending,onClick:()=>{o(!1),s.mutate({...c,silenceGapSeconds:Number(l.trim())},{onSuccess:()=>{i(void 0),o(!0)}})},children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(Y2,{}):null})]})}),(0,h.jsxs)(`div`,{className:`sl-field`,...Ib,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,h.jsx)(`span`,{className:`sl-field__label`,children:`Appearance`}),(0,h.jsx)(V,{id:`settings.appearance`,className:`-my-1`})]}),(0,h.jsx)(Rb,{label:`Appearance`,value:c.appearance,options:ZSe,className:`self-start`,onChange:e=>{s.mutate({...c,appearance:e})}})]}),(0,h.jsx)(`div`,{className:`md:col-span-2`,children:(0,h.jsx)(D6,{value:c.loudness??nk,switchLabel:`Level the volume for new runs`,switchTip:`settings.loudness`,onChange:e=>{s.mutate({...c,loudness:e})}})})]})}function oCe({open:e,onClose:t,onInstalled:n}){let{api:r}=z(),i=_(),a=P({queryKey:By,queryFn:()=>Wy(r),enabled:e}),o=F({mutationFn:e=>Ky(r,e),onSuccess:()=>n(),onSettled:()=>i.invalidateQueries({queryKey:By})});return(0,h.jsxs)(XP,{open:e,title:`Add a starter pack`,onClose:t,footer:(0,h.jsx)(G1,{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 pack was already added.`)}),children:[(0,h.jsxs)(`p`,{className:`mb-4 flex items-center gap-1 text-small text-ink-2`,children:[`Prompts, a suggested voice and a template for one kind of channel.`,(0,h.jsx)(V,{id:`welcome.packs`})]}),(0,h.jsxs)(oU,{label:`Starter packs`,className:`[&_.sl-row__meta]:whitespace-normal`,children:[(a.data?.packs??[]).map(e=>(0,h.jsx)(sU,{title:e.name,meta:e.summary,actions:(0,h.jsx)(R,{disabled:e.installed||o.isPending,onClick:()=>o.mutate(e.id),children:e.installed?`Added`:`Add pack`})},e.id)),a.data===void 0?(0,h.jsx)(sU,{title:`Loading packs…`}):null]})]})}function sCe({template:e}){let{api:t}=z(),n=P({queryKey:[...Aq,e.id,e.version],queryFn:async()=>{let n=await Iq(t,e.id);if(!n.ok)throw Error(n.message);return n.value}});if(n.error)return(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The keywords of `,e.name,` didn't load. `,n.error.message,` Press Keywords again.`]});if(!n.data)return(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`Reading the keywords…`});let{form:r,librarySnapshot:i}=n.data.document,a=c0({form:r,prompts:i?.prompts??[],entries:i?.entries??[]}),o=L3(r.title),s=[...new Set([...a.keys(),...Object.keys(r.values)])];return(0,h.jsx)(u0,{keywords:s.map(e=>({name:e,value:r.values[e]??``,feeds:a.get(e)??[],topic:o.includes(e)})),empty:`No keywords: the prompts and the title name none.`})}async function cCe(e,t,n,r){let i=await Rq(e,t.id,{baseVersion:t.version,mutationId:r,...n});if(!i.ok)throw Error(i.message);return i.value}function lCe({template:e}){return e===void 0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`Pick a template to see the keywords it fills.`}):(0,h.jsxs)(`section`,{"aria-label":`Keywords of ${e.name}`,className:`flex flex-col gap-4`,children:[(0,h.jsx)(H,{title:e.name,as:`h3`,info:`templates.edit`,className:`pb-0`}),(0,h.jsx)(sCe,{template:e}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`To change the settings, press Use in Play, change the draft, then Save a setup.`})]})}function uCe({template:e,onClose:t}){let{api:n}=z(),r=_(),i=Array.from({length:e.version},(t,n)=>e.version-n),a=at({queries:i.map(t=>({queryKey:[...Aq,e.id,`version`,t],queryFn:async()=>{let r=await Iq(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=Iy(),f=F({mutationFn:t=>cCe(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:Aq}),t()}}),p=a.find(e=>e.error!==null)?.error;return(0,h.jsx)(XP,{open:!0,title:`History 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 History and open it again.`}):null,(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(H,{title:`Versions`,as:`h3`,info:`templates.history`}),(0,h.jsx)(oU,{label:`Versions of ${e.name}`,children:i.map((t,n)=>{let r=a[n]?.data;return(0,h.jsx)(sU,{title:`Version ${String(t)}`,selected:t===s,onSelect:()=>c(t),meta:r===void 0?`Loading…`:`${r.name} · ${k4(r.updatedAt)}`,actions:t===e.version?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Current`}):(0,h.jsx)(R,{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)(G1,{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)(H,{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)(S4,{before:D9(l),after:D9(o),beforeLabel:`Version ${String(l.version)}`,afterLabel:`Version ${String(o.version)} (current)`})]})]})]})})}function D9(e){return JSON.stringify(e.document,null,1).split(`
|
|
308
|
+
`),s].find(e=>e?.trim())??`No text was recorded for this part.`}catch{return`Recorded text cannot be decoded.`}}function Kbe({projectId:e,pending:t,onRestore:n}){let{api:r}=z(),[i,a]=(0,m.useState)(),o=P({queryKey:B.revisions(e),queryFn:async()=>{let t=await Vfe(r,e);if(!t.ok)throw Error(t.message);return t.value.revisions}}),s=P({queryKey:B.revision(e,i??``),enabled:i!==void 0,queryFn:async()=>{if(i===void 0)throw Error(`Choose a version from History first.`);let t=await Q0(r,e,i);if(!t.ok)throw Error(t.message);return t.value.view}}),c=s.data,l=c?.outputs.find(e=>e.selected&&e.available&&(e.output.role===`image`||e.output.role===`thumbnail`)),u=l??c?.outputs.find(e=>e.available);return(0,h.jsxs)(`section`,{"aria-label":`Project history`,className:`space-y-3`,children:[(0,h.jsx)(H,{title:`Project history`}),o.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:o.error.message}),(0,h.jsx)(`ol`,{className:`space-y-2`,children:o.data?.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(R,{type:`button`,onClick:()=>a(e.id),children:[e.title,` · `,e.createdAt,e.current?` · Current`:``]})},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:s.error.message}),c===void 0?null:(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:c.revision.config.title}),(0,h.jsxs)(Py,{children:[(0,h.jsx)(R,{variant:`primary`,disabled:t,onClick:()=>n(c.revision.id),children:`Restore this revision`}),l===void 0?null:(0,h.jsxs)(SS,{href:Kfe(r,e,c.revision.id),download:!0,children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,strokeWidth:1.75}),`Download all images`]}),u===void 0?null:(0,h.jsx)(r2,{projectId:e,asset:``,folder:{revisionId:c.revision.id,recordId:u.recordId}})]}),(0,h.jsx)(`ul`,{className:`m-0 list-none space-y-3 p-0`,children:c.outputs.map(t=>(0,h.jsxs)(`li`,{className:`space-y-2 border-t border-line pt-3 first:border-t-0 first:pt-0`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,h.jsxs)(`span`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`font-semibold text-ink`,children:C7(t.output)}),(0,h.jsxs)(`span`,{className:`text-small text-ink-2`,children:[` · ${t.state}${t.selected?``:` · Earlier result`}`,t.available?``:` · File missing`]})]}),t.available?(0,h.jsxs)(SS,{href:e2(r,e,c.revision.id,t.recordId),download:!0,size:`small`,"aria-label":`Download ${C7(t.output)}`,children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,strokeWidth:1.75}),`Download`]}):null]}),t.available?(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Preview retained output`}),t.output.role===`video`?(0,h.jsx)(j0,{className:`max-w-[640px]`,label:C7(t.output),src:e2(r,e,c.revision.id,t.recordId)}):[`audio_export`,`audio_body`,`audio_intro`,`audio_outro`].includes(t.output.role)?(0,h.jsx)(Z8,{label:C7(t.output),src:e2(r,e,c.revision.id,t.recordId)}):t.output.role===`image`||t.output.role===`thumbnail`?(0,h.jsx)(M0,{className:`max-w-[480px]`,alt:C7(t.output),title:C7(t.output),meta:t.selected?`Current`:`Earlier result`,src:e2(r,e,c.revision.id,t.recordId)}):(0,h.jsx)(`p`,{children:`Use Download to inspect this retained file.`})]}):null]},t.recordId))}),(0,h.jsx)(`ul`,{"aria-label":`Retained narration parts`,children:c.pieces.filter(e=>e.stageKind===`audio`&&e.assetId!==null).map(t=>(0,h.jsxs)(`li`,{children:[`Narration part `,t.piece.idx,t.selected?``:` · Earlier result`,t.available?(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Preview retained audio part`}),(0,h.jsx)(Z8,{label:`Narration part ${String(t.piece.idx)}`,src:e2(r,e,c.revision.id,t.recordId)}),(0,h.jsxs)(SS,{href:e2(r,e,c.revision.id,t.recordId),download:!0,size:`small`,children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,strokeWidth:1.75}),`Download narration part`]})]}):(0,h.jsx)(`span`,{children:` · File missing`})]},t.recordId))}),(0,h.jsx)(`ul`,{"aria-label":`Retained text parts`,children:c.pieces.filter(e=>e.assetId===null).map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(`details`,{children:[(0,h.jsxs)(`summary`,{children:[e.stageKind,` part `,e.piece.idx]}),(0,h.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:Gbe(e.piece.payload)})]})},e.recordId))})]})]})}function M7(e,t,n){let r=JSON.stringify(t);return e?.payload===r?e:{payload:r,idempotencyKey:n()}}function qbe(e,t,n={}){let{api:r}=z(),i=_(),a=P({queryKey:B.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 Q0(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=(0,m.useRef)(void 0),T=(0,m.useRef)(void 0),E=(0,m.useRef)(void 0),D=(0,m.useRef)(n.onOpenEdit);D.current=n.onOpenEdit;let O=(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]),k=c!==void 0&&o!==void 0&&t!==null&&t!==o.revision.id,A=(0,m.useRef)(!1);async function j(e){if(!A.current){A.current=!0,g(!0),x(void 0),C(void 0);try{await e()}catch(e){x(e instanceof Error?e.message:String(e))}finally{A.current=!1,g(!1)}}}async function ee(t){let n=await X0(r,e);if(!n.ok){C(n);return}return C(void 0),s(n.value.view),t&&l({config:structuredClone(n.value.view.revision.config),content:structuredClone(n.value.view.revision.content)}),n.value.view}async function te(t){let n=await jo(r,e);return i.setQueryData(B.project(e),n),await i.invalidateQueries({queryKey:B.revisions(e)}),!t.current||n.revisionId!==t.revision.id?(C({ok:!1,reason:`conflict`,message:`The project changed again. Your draft is preserved.`,currentRevisionId:n.revisionId,fields:[]}),!1):(s(t),l(void 0),C(void 0),d(void 0),!0)}async function M(){if(v||o===void 0||c===void 0)return;let t={baseRevisionId:o.revision.id,edit:c},n=M7(w.current,t,()=>crypto.randomUUID());w.current=n;let i=await Z0(r,e,{...t,idempotencyKey:n.idempotencyKey});if(!i.ok){C(i);return}await te(i.value.view),w.current=void 0}async function ne(t,n=u){if(n===void 0)return;let a={baseRevisionId:n.baseRevisionId,previewId:n.id,...t},o=M7(E.current,a,()=>crypto.randomUUID());E.current=o;let s=await Wfe(r,e,{...a,idempotencyKey:o.idempotencyKey});if(!s.ok){C(s),(s.reason===`stale-preview`||s.reason===`conflict`)&&d(void 0);return}E.current=void 0,d(void 0),await i.invalidateQueries({queryKey:B.project(e)})}async function N(t,n){let i=await ee(!1);if(i===void 0)return;let a=await Ufe(r,e,{baseRevisionId:i.revision.id,request:t});if(!a.ok){C(a);return}let o=a.value.value;if(E.current=void 0,n&&Jbe(o)){await ne({acknowledgeUnknownCosts:!1,confirmedProvidedWorkKeys:[]},o);return}d(o)}async function re(t){let n=o??a.data??await ee(!1);if(n===void 0)return;let i={baseRevisionId:n.revision.id,targetRevisionId:t},s=M7(T.current,i,()=>crypto.randomUUID());T.current=s;let c=await Bfe(r,e,{...i,idempotencyKey:s.idempotencyKey});if(!c.ok){C(c);return}await te(c.value.view),T.current=void 0}return{saved:a,view:o,edit:c,preview:u,focus:f,pending:h,uploading:v,error:b,refusal:S,unsaved:O,remoteChanged:k,busy:h||v||c!==void 0||u!==void 0,setEdit:l,setUploading:y,openEditor:()=>void j(async()=>{await ee(!0)}),discard:()=>{l(void 0),C(void 0),y(!1),w.current=void 0},save:()=>void j(M),reloadDraft:()=>void j(async()=>{w.current=void 0,y(!1),await ee(!0),C(void 0)}),reloadCurrent:()=>void j(async()=>{T.current=void 0,E.current=void 0,d(void 0),await ee(!1),await i.invalidateQueries({queryKey:B.project(e)})}),requestEdit:e=>void j(async()=>{let t=o,n=c;if(t===void 0||n===void 0){if(t=await ee(!1),t===void 0)return;n={config:structuredClone(t.revision.config),content:structuredClone(t.revision.content)}}l(e.change(n,t)),p({section:e.section}),D.current?.()}),regenerateNow:t=>void j(async()=>{let n=e=>({...e,regenerate:[...new Set([...e.regenerate??[],...t])]});if(c!==void 0&&O){l(n(c)),p({section:`images`}),D.current?.();return}let i=await ee(!1);if(i===void 0)return;let a=await Z0(r,e,{baseRevisionId:i.revision.id,edit:n({config:structuredClone(i.revision.config),content:structuredClone(i.revision.content)}),idempotencyKey:crypto.randomUUID()});if(!a.ok){C(a);return}await te(a.value.view)&&await N({kind:`selected`,workKeys:t},!0)}),review:(e,t)=>void j(()=>N(e,t?.autoStart===!0)),start:e=>void j(()=>ne(e)),closePreview:()=>{h||(d(void 0),E.current=void 0)},restore:e=>void j(()=>re(e))}}function Jbe(e){return!e.work.some(e=>e.disposition===`blocked`)&&e.providedReuseRequired.length===0&&e.costs.unknown===0}function Ybe({controller:e,renderEditor:t,active:n=!0,intro:r}){let i=e;return i.view===void 0||i.edit===void 0?(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[r??(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(H,{title:`Saved revision`,info:`project.saved-revision`}),i.saved.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:i.saved.error.message}),i.saved.data===void 0?null:(0,h.jsx)(`ul`,{"aria-label":`Saved output status`,className:`sl-list m-0 list-none p-0`,children:i.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:C7(e.output)}),(0,h.jsx)(`span`,{className:`sl-row__meta`,children:e.available?e.state===`ready`?`Ready`:e.state===`outdated`?`Outdated; the retained version stays until it is remade`:`Provided content needs review`:`Retained file missing`})]},e.recordId))})]}),i.preview===void 0&&n?(0,h.jsx)(j7,{error:i.error,refusal:i.refusal}):null,(0,h.jsxs)(K1,{children:[i.refusal?.reason===`conflict`&&n?(0,h.jsx)(R,{disabled:i.pending,onClick:i.reloadCurrent,children:`Reload current revision`}):null,(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(R,{disabled:i.busy,onClick:()=>i.review({kind:`allAffected`}),variant:`secondary`,children:`Choose what to remake`}),(0,h.jsx)(V,{id:`project.choose-remake`})]}),(0,h.jsx)(R,{variant:`primary`,disabled:i.busy,onClick:i.openEditor,children:`Edit project`})]})]}):(0,h.jsxs)(`form`,{"aria-label":`Edit project`,onSubmit:e=>{e.preventDefault(),i.save()},children:[(0,h.jsx)(`fieldset`,{disabled:i.pending,className:`m-0 min-w-0 border-0 p-0`,children:t({view:i.view,edit:i.edit,fields:i.refusal?.fields??[],onChange:i.setEdit,onPending:i.setUploading,...i.focus===void 0?{}:{focus:i.focus}})}),i.preview===void 0?(0,h.jsx)(j7,{error:i.error,refusal:i.refusal}):null,(0,h.jsxs)(K1,{status:(0,h.jsx)(G1,{tone:i.remoteChanged?`warning`:`info`,children:i.remoteChanged?`A newer revision is available. Your unsaved changes are kept below.`:i.uploading?`Waiting for uploads to finish…`:void 0}),children:[i.remoteChanged||i.refusal?.reason===`conflict`?(0,h.jsx)(R,{disabled:i.pending||i.uploading,onClick:i.reloadDraft,children:`Reload current revision and discard my draft`}):null,(0,h.jsx)(R,{variant:`quiet`,disabled:i.pending||i.uploading,onClick:i.discard,children:`Discard changes`}),(0,h.jsx)(R,{variant:`primary`,type:`submit`,disabled:i.pending||i.uploading,children:`Save changes`})]})]})}function Xbe({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)(j7,{error:r.error,refusal:r.refusal}),r.edit===void 0&&r.refusal?.reason===`conflict`?(0,h.jsx)(R,{disabled:r.pending,onClick:r.reloadCurrent,className:`self-start`,children:`Reload current revision`}):null]}):null,(0,h.jsx)(Kbe,{projectId:t,pending:r.busy,onRestore:r.restore})]}):null}function Zbe({controller:e}){let t=e;return(0,h.jsx)(XP,{open:t.preview!==void 0,title:`Choose what to remake`,onClose:t.closePreview,children:t.preview===void 0?null:(0,h.jsx)(Lbe,{preview:t.preview,feedback:(0,h.jsx)(j7,{error:t.error,refusal:t.refusal}),pending:t.pending,onStart:t.start,onCancel:t.closePreview},t.preview.id)})}var Qbe=(e,t)=>{if(t)return`waiting`;switch(e.state){case`running`:return`running`;case`done`:case`provided`:return`done`;case`failed`:return e.retryAt===void 0?`failed`:`waiting`;default:return`off`}},$be=(e,t)=>{if(t)return`Held for you`;switch(e.state){case`running`:return`Running`;case`done`:return`Done`;case`provided`:return`Provided`;case`failed`:return e.retryAt===void 0?`Failed`:`Waiting to try again`;case`canceled`:return`Canceled`;case`skipped`:return`Off`;case`pending`:return`Not started`}};function exe(e,t){if(e.startedAt===null)return;let n=Date.parse(e.startedAt),r=e.finishedAt===null?t:Date.parse(e.finishedAt);if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return;let i=Math.round((r-n)/1e3);if(i<1)return;if(i<60)return`${String(i)} s`;let a=Math.round(i/60);return a<60?`${String(a)} min`:`${String(Math.floor(a/60))} h ${String(a%60)} min`}function txe(e,t,n){let r=C3(t,n);return r===void 0?e:e===void 0||e===``?w3(r):`${e} · ${w3(r)}`}function nxe({stages:e,outputs:t,project:n,resumable:r,held:i,now:a}){return e.filter(e=>e.state!==`skipped`).map(e=>{let o=i.some(t=>t.stage===e.kind),s=exe(e,a);return{id:e.id,name:e.kind===`video`&&iF(n.config)===`audio`?`Audio export`:t5[e.kind],tone:Qbe(e,o),state:$be(e,o),...s===void 0?{}:{time:s},detail:o?`Held for your review`:txe(lF(e,t,n,r),e,a)}})}function rxe({stages:e}){return(0,h.jsx)(`div`,{className:`sr-only`,children:e.filter(e=>e.state!==`skipped`).map(e=>(0,h.jsx)(`span`,{role:`status`,"aria-live":`polite`,children:`${t5[e.kind]}: ${e.state}`},e.id))})}function ixe({steps:e}){return(0,h.jsxs)(`section`,{"aria-labelledby":`run-steps-title`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(H,{id:`run-steps-title`,title:`Run`,size:`small`,className:`pb-0`}),(0,h.jsx)(E3,{steps:e,label:`Run steps`,dense:!0})]})}var N7=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function axe({cost:e,onOpen:t}){if(e===void 0||e.calls===0&&e.byStage.length===0)return null;let n=e.plans.flatMap(e=>e.reported?e.windows.map(t=>({key:`${e.account}/${t.kind}`,name:e.name,window:t.kind===`five_hour`?`5-hour`:t.kind===`weekly`?`weekly`:`current`,used:t.usedPercent,now:t.nowPercent})):[]);return(0,h.jsxs)(`section`,{"aria-labelledby":`cost-so-far-title`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(H,{id:`cost-so-far-title`,title:`Cost so far`,size:`small`,className:`pb-0`,children:t===void 0?null:(0,h.jsx)(R,{variant:`quiet`,size:`small`,onClick:t,children:`By stage`})}),(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[(0,h.jsx)(`strong`,{className:`text-ink`,children:a7(e.cost)}),e.unpriced>0?` known, spent`:` spent`,e.apiEquivalent===null?null:` · ~${a7(e.apiEquivalent)} via API`,e.run===null||e.run.running?null:` · ${o7(e.run.workingMs)} of work`]}),n.map(e=>{let t=e.used<1?`under 1%`:`${N7.format(e.used)}%`,n=`${e.window} ${e.name} limit`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`${e.name}: ${t} of your ${e.window} limit`}),(0,h.jsx)(G2,{value:e.used/100,label:`Share of the ${n} this run used`,valueText:`${t} of your ${n}; now at ${N7.format(e.now)}%`,tone:e.now>=80?`waiting`:`accent`})]},e.key)})]})}function oxe({projectId:e,revisionId:t,title:n,open:r,onClose:i}){let{api:a}=z(),o=_(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(null),p=Iy(),g=(0,m.useRef)(!1),v=(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 y(){if(!s||g.current||!s.name.trim())return;g.current=!0,u(!0),f(null);let t=JSON.stringify([e,s.revisionId,s.name.trim()]);v.current?.key!==t&&(v.current={key:t,id:crypto.randomUUID()});try{let t=await Bq(a,e,{id:v.current.id,name:s.name.trim(),revisionId:s.revisionId});if(!t.ok){v.current=null,f(t.message);return}v.current=null,i(),p(`Template saved.`,`success`),await o.invalidateQueries({queryKey:Aq})}catch(e){f(e instanceof Error?e.message:`The template wasn't saved. Press Save template to try again.`)}finally{g.current=!1,u(!1)}}return(0,h.jsx)(Ry,{open:r&&s!==null,onOpenChange:e=>{!e&&!g.current&&i()},title:`Save as template`,description:`Save this revision’s setup for a fresh Play draft. This does not rebuild the project.`,children:(0,h.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,h.jsx)(dV,{label:`Template name`,tip:`play.template-name`,children:(0,h.jsx)(pV,{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)(R,{disabled:l,onClick:i,children:`Cancel`}),(0,h.jsx)(R,{variant:`primary`,type:`submit`,disabled:l||!s?.name.trim(),children:`Save template`})]})]})})}var P7=q({baseRevisionId:W().min(1).max(64),idempotencyKey:TD()}).strict(),sxe=iO(`kind`,[q({kind:mO(`resume`)}).strict(),q({kind:mO(`retry`),stage:J(US)}).strict(),q({kind:mO(`rerun`),stage:J(US)}).strict(),q({kind:mO(`redo`),item:W().min(1).max(200)}).strict()]);P7.extend({action:sxe}).strict();var cxe=iO(`ok`,[q({ok:mO(!0),value:z0.and(q({warnings:K(W()).readonly()}))}),q({ok:mO(!1),reason:J([`no-project`,`no-revision`,`conflict`,`idempotency-conflict`,`invalid-edit`,`stale-preview`,`invalid-selection`,`review-required`,`cost-ack-required`,`readiness`,`running`,`accepted-job`,`control-changed`]),fields:K(q({field:W(),message:W()})).readonly().optional(),intentRevisionId:W().optional(),currentRevisionId:W().nullable().optional()})]),F7=new Set([400,404,409]);async function lxe(e,t,n){return L7(e,t,`cancel`,n)}async function uxe(e,t,n){return L7(e,t,`pause`,n)}function dxe(e,t,n){return R7(e,t,`resume`,n)}function fxe(e,t,n,r){return R7(e,t,`stages/${n}/retry`,r)}function pxe(e,t,n,r){return R7(e,t,`stages/${n}/soften`,r)}function mxe(e,t,n,r){return R7(e,t,`stages/${n}/rerun`,r)}async function hxe(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/providers`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function gxe(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/subtitles`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function _xe(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/article`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({markdown:n})}))}async function vxe(e,t,n){return I7(await e.client.projects[`:id`].images[`:outputId`].$delete({param:{id:t,outputId:n}}))}async function yxe(e,t,n){return I7(await e.client.projects[`:id`].images[`:outputId`].regenerate.$post({param:{id:t,outputId:n}}))}async function I7(e){if(e.ok)return{ok:!0,value:await e.json()};let t=await mo(e);if(t!==void 0&&F7.has(e.status))return{ok:!1,message:po(e,t).message};throw po(e,t)}async function L7(e,t,n,r){let i=P7.parse(r);return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)}))}async function R7(e,t,n,r){let i=await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(P7.parse(r))});if(i.ok){let e=cxe.parse(await i.json());if(!e.ok)throw Error(xo);return{ok:!0,value:e.value,warnings:e.value.warnings}}let a=await mo(i);if(a!==void 0&&F7.has(i.status))return{ok:!1,message:po(i,a).message};throw po(i,a)}function bxe(e){let{api:t}=z(),n=_(),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(),s=(0,m.useRef)(new Map),c=(0,m.useRef)(!1),l=F({mutationFn:async e=>{let r=e.action;if(![`pause`,`cancel`,`resume`,`retry`,`soften`,`rerun`].includes(r.kind))return B7(t,e.projectId,r);let i=r.kind===`retry`||r.kind===`soften`||r.kind===`rerun`?r.stage:``,a=`${e.projectId}:${r.kind}:${i}`,o=s.current.get(a);if(!o){let r=n.getQueryData(B.project(e.projectId))?.revisionId;if(!r){let n=await X0(t,e.projectId);if(!n.ok)return{ok:!1,message:n.message};r=n.value.view.revision.id}o={baseRevisionId:r,idempotencyKey:crypto.randomUUID()},s.current.set(a,o)}let c=await B7(t,e.projectId,r,o);return s.current.delete(a),c.ok&&await jo(t,e.projectId).then(t=>n.setQueryData(B.project(e.projectId),t),e=>console.warn(`Project refresh after an accepted action failed`,e)),c},onMutate:()=>{i(void 0),o(void 0)},onSuccess:async(e,t)=>{e.ok?(o(`warnings`in e&&e.warnings.length>0?e.warnings.join(` `):void 0),n.invalidateQueries({queryKey:B.projects})):i({message:e.message,stage:z7(t.action)}),await n.invalidateQueries({queryKey:B.project(t.projectId)})},onSettled:()=>{c.current=!1},onError:(e,t)=>{i({message:e.message,stage:z7(t.action)})}});return{run:(t,n)=>{c.current||(c.current=!0,l.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok&&n?.()}}))},pending:l.isPending,performing:l.isPending?l.variables?.action:void 0,refusal:r,dismissRefusal:()=>{i(void 0)},notice:a}}function z7(e){switch(e.kind){case`cancel`:case`pause`:case`resume`:case`providers`:return;case`retry`:case`soften`:case`rerun`:return e.stage;case`subtitles`:return`video`;case`save-article`:return`article`;case`delete-image`:case`regenerate-image`:return`images`}}function B7(e,t,n,r){let i=()=>{if(!r)throw Error(`A saved revision and request identity are required.`);return r};switch(n.kind){case`pause`:return uxe(e,t,i());case`cancel`:return lxe(e,t,i());case`resume`:return dxe(e,t,i());case`retry`:return fxe(e,t,n.stage,i());case`soften`:return pxe(e,t,n.stage,i());case`rerun`:return mxe(e,t,n.stage,i());case`providers`:return hxe(e,t,n.choices);case`subtitles`:return gxe(e,t,n.subtitles);case`save-article`:return _xe(e,t,n.markdown);case`delete-image`:return vxe(e,t,n.outputId);case`regenerate-image`:return yxe(e,t,n.outputId)}}var V7=e=>e.state===`done`||e.state===`provided`;function xxe(e){let t=e.find(e=>e.state===`failed`)??e.find(e=>e.state===`running`);if(t)return t.kind;let n=e.find(e=>e.kind===`video`&&V7(e));if(n)return n.kind;let r=e.find(e=>e.state===`pending`);return r?r.kind:e.find(e=>e.kind===`article`&&V7(e))?.kind??e.find(e=>e.state!==`skipped`)?.kind??`article`}function Sxe({projectId:e,openDraft:t}){return(0,h.jsx)(Cxe,{projectId:e,openDraft:t},e)}var H7=e=>{let t=e.filter(e=>e!==void 0);if(!(t.length===0||t.every(e=>e.state===`skipped`)))return t.some(e=>e.state===`failed`&&e.retryAt===void 0)?`failed`:t.some(e=>e.state===`running`)?`running`:t.some(e=>e.state===`failed`)?`waiting`:t.every(e=>e.state===`done`||e.state===`provided`||e.state===`skipped`)?`done`:`off`};function Cxe({projectId:e,openDraft:t}){let{api:n}=z(),r=Iy(),i=Exe(e,t),a=P(ib(n,e)),o=P(ub(n)),s=P(ab(n,e)),c=bxe(e),[l,u]=(0,m.useState)(),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(!1),y=a.data?.revisionId??null,b=qbe(e,y,{onOpenEdit:()=>u(`settings`)}),x=fI(e),S=(0,m.useRef)(void 0);(0,m.useEffect)(()=>{if(x===void 0){S.current=void 0;return}a.data!==void 0&&S.current!==x&&(S.current=x,x===`download`&&u(iF(a.data.project.config)===`article`?`article`:`video`))},[x,a.data]),j3(e,y);let C=P({queryKey:Vy,queryFn:()=>Yy(n)}),w=Xy(C.data,e),T=P({queryKey:u3(e,y??``),queryFn:()=>f3(n,e),enabled:y!==null,retry:!1}),E=T.data?.ok===!0?T.data.value.checkpoints:[],D=b.saved.data?.outputs.filter(e=>e.selected&&e.state===`outdated`).map(e=>({workKey:e.workKey,role:e.output.role}))??[],O=a.data?.project,k=a.data?.stages??[],A=a.data?.outputs??[],j=A.some(e=>e.role===`video`),ee=e=>u(e),te=yve({project:O??wxe,stages:k,resumable:a.data?.resumable??!1,sample:w,gates:E,outdated:D,waits:s.data?.waits??[],uploadReady:j,actions:c,controller:b,openSection:ee,openUpload:()=>f(!0)}),M=l===`settings`,ne=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!M){ne.current=!1;return}b.edit!==void 0&&(ne.current=!0),!(ne.current||b.busy)&&(ne.current=!0,b.openEditor())},[M,b]);let N=k.some(e=>e.state===`running`),re=O?.status===`running`,ie=O?.title??``,ae=te.next?.action;Ox({id:`project.next`,title:ae?.label??`Show the project's next action`,group:`This project`,context:ie,keywords:[`next`,`continue`,`resume`,`approve`,`retry`],shortcut:uP.nextAction,run:()=>{ae===void 0?r(`This project has no next action right now: nothing waits on you.`,`info`):ae.intent.kind===`soften`?r(`Soften and retry asks first: press it in the Next action panel on the right.`):te.run(ae.intent)}}),rS(Qx.showImages(e),()=>{let e=a.data?.stages.find(e=>e.kind===`images`);e===void 0||e.state===`skipped`?r(`${ie} makes no slideshow images, so there is no image to regenerate. To add them, open Settings in this project and choose how its images are made.`,`error`):u(`images`)},a.data!==void 0),Ox({id:`project.pause`,title:O?.status===`paused`?`Continue the run`:`Pause the run`,group:`This project`,context:ie,keywords:[`pause`,`resume`,`continue`,`stop`],run:()=>c.run({kind:O?.status===`paused`?`resume`:`pause`})}),Ox({id:`project.prepare-upload`,title:`Prepare upload`,group:`This project`,context:ie,keywords:[`youtube`,`studio`,`upload`,`publish`],run:()=>{j?f(!0):r(`Prepare upload opens once the video has been made.`,`info`)}}),Ox({id:`project.settings`,title:`Edit project settings`,group:`This project`,context:ie,keywords:[`edit`,`settings`,`prompts`,`providers`,`channel`],run:()=>u(`settings`)}),Ox({id:`project.rebuild-review`,title:`Choose what to remake`,group:`This project`,context:ie,keywords:[`rebuild`,`review`,`remake`,`outdated`,`affected`],run:()=>b.review({kind:`allAffected`})}),Ox({id:`project.template`,title:`Save as template`,group:`This project`,context:ie,keywords:[`template`,`reuse`],run:()=>g(!0)}),Ox({id:`project.cancel`,title:`Cancel the run`,group:`This project`,context:ie,keywords:[`cancel`,`stop`],run:()=>v(!0)});let oe=_ve(D);if(Ox({id:`project.remake-1`,title:oe[0]?.label??`Remake outdated outputs`,group:`This project`,context:ie,keywords:[`remake`,`outdated`,`rebuild`],run:()=>{let e=oe[0];e===void 0?r(`Nothing is outdated in this project.`,`info`):b.review({kind:`selected`,workKeys:e.workKeys},{autoStart:!0})}}),Ox({id:`project.remake-all`,title:`Remake everything outdated`,group:`This project`,context:ie,keywords:[`remake`,`outdated`,`rebuild`,`all`],run:()=>{let e=[...new Set(oe.flatMap(e=>e.workKeys))];e.length===0?r(`Nothing is outdated in this project.`,`info`):b.review({kind:`selected`,workKeys:e},{autoStart:!0})}}),Ox({id:`project.copy`,title:`Make my own copy`,group:`This project`,context:ie,keywords:[`sample`,`copy`,`duplicate`],run:()=>w?te.run({kind:`copy-sample`}):r(`Only the sample project is copied this way.`,`info`)}),a.error!==null)return(0,h.jsx)(vI,{tone:`danger`,title:`The project could not be loaded.`,children:`${a.error.message} Reload the page to try again, or go back to Projects.`});if(a.data===void 0||O===void 0)return(0,h.jsx)(Txe,{});let se=e=>k.find(t=>t.kind===e),ce=se(`article`),le=se(`research`),ue=se(`audio`),de=se(`images`),fe=se(`thumbnail`),pe=se(`video`),me=se(`document`),he=O.config,ge=e=>e!==void 0&&e.state!==`skipped`,_e=he.shorts?.enabled===!0||A.some(e=>e.role===`short_video`||e.role===`shorts`),ve=he.youtubeDescription===!0||A.some(e=>e.role===`youtube_description`),ye=E.filter(e=>e.state===`held`||e.state===`pending-review`),be=[...ge(ce)||ge(le)?[{id:`article`,label:`Article`,tone:H7([ce,le])}]:[],...ge(ue)?[{id:`narration`,label:`Narration`,tone:H7([ue])}]:[],...ge(de)||ge(fe)||he.reference!==void 0?[{id:`images`,label:`Images`,tone:H7([de,fe])}]:[],...ge(pe)?[{id:`video`,label:iF(he)===`audio`?`Audio export`:`Video`,tone:H7([pe])}]:[],...ge(me)?[{id:`document`,label:`PDF`,tone:H7([me])}]:[],{id:`cost`,label:`Cost`},{id:`live`,label:`Live`}].map(e=>{let t=oe.filter(t=>t.section===e.id).reduce((e,t)=>e+t.count,0);return t===0?e:{...e,meta:`${String(t)} outdated`}}),xe=[{id:`settings`,label:`Settings`,...b.unsaved?{meta:`unsaved`}:{}},...y===null?[]:[{id:`checkpoints`,label:`Checkpoints`,...ye.length===0?{}:{meta:`${String(ye.length)} held`}}],{id:`history`,label:`History`}],Se=[...be,...xe],Ce=te.next?.situation,we=te.next?.section!==void 0&&Ce!==`done`&&Ce!==`running`?te.next.section:Ce===`done`&&A.some(e=>e.role===`youtube_description`)?`youtube`:e5(xxe(k)),Te=e=>e===`shorts`||e===`youtube`?`video`:e,Ee=l!==void 0&&Se.some(e=>e.id===Te(l))?Te(l)??`video`:Se.find(e=>e.id===Te(we))?.id??be[0]?.id??`cost`,De=(...e)=>y===null?O.status===`running`||O.status===`paused`||N||c.pending:c.pending||e.some(e=>e?.state===`running`),Oe={project:O,outputs:A,actions:c,next:te,resumable:a.data.resumable},ke=(e,t)=>e===void 0?null:(0,h.jsx)(vye,{stage:e,...t===void 0||t.state===`skipped`?{}:{companion:t},project:O,outputs:A,actions:c,busy:De(e,t)}),Ae=(...e)=>A.some(t=>e.some(e=>e!==void 0&&t.stageKind===e.kind)),je=(...e)=>Ae(...e)||e.some(e=>e!==void 0&&[`running`,`done`,`provided`,`failed`,`canceled`].includes(e.state)),Me=[{id:`rebuild`,label:`Choose what to remake…`,run:()=>b.review({kind:`allAffected`}),disabled:b.busy},{id:`template`,label:`Save as template…`,run:()=>g(!0),disabled:y===null||w},{id:`cancel`,label:`Cancel the run…`,run:()=>v(!0),disabled:!re||c.pending,apart:!0}],Ne=$8({kind:`cancel`}),Pe=c.refusal?.stage===void 0?c.refusal:void 0,Fe=Pe===void 0?c.notice===void 0?b.preview===void 0&&(b.error||b.refusal)&&Ee!==`settings`&&Ee!==`history`?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:b.error??b.refusal?.message}):void 0:(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:c.notice}):(0,h.jsx)(vI,{tone:`danger`,title:Pe.message,children:(0,h.jsx)(R,{variant:`quiet`,size:`small`,className:`mt-1`,onClick:c.dismissRefusal,children:`Dismiss`})}),Ie=nxe({stages:k,outputs:A,project:O,resumable:a.data.resumable,held:ye.map(e=>({checkpointId:e.checkpointId,stage:e.stage,dependents:e.dependents})),now:Date.now()});return(0,h.jsx)(E_e,{projectId:e,revisionId:y,children:(0,h.jsx)(K8,{value:y!==null,children:(0,h.jsx)(m3,{value:e=>u(e===`edit`?`settings`:`article`),children:(0,h.jsx)(q8,{value:b.pending||b.preview!==void 0?void 0:b.requestEdit,children:(0,h.jsxs)(J8,{value:b.pending||b.preview!==void 0?void 0:b.regenerateNow,children:[(0,h.jsxs)(`div`,{className:`sl-project`,children:[(0,h.jsx)(`div`,{"data-tour":`project-controls`,children:(0,h.jsx)(kye,{project:O,prompts:o.data?.prompts,editing:Ee===`settings`,onEdit:()=>u(`settings`),more:Me,nextChapter:i,clock:(0,h.jsx)(Iye,{cost:s.data,status:O.status,measuredAt:s.dataUpdatedAt})})}),(0,h.jsx)(rxe,{stages:k}),(0,h.jsxs)(Cq,{sections:(0,h.jsxs)(Q6,{label:`Project sections`,children:[be.map(e=>(0,h.jsx)(W7,{item:e,selected:Ee,onSelect:ee},e.id)),(0,h.jsx)(`hr`,{className:`sl-rule my-2`}),xe.map(e=>(0,h.jsx)(W7,{item:e,selected:Ee,onSelect:ee},e.id))]}),aside:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xve,{state:te,feedback:Fe}),O===void 0?null:(0,h.jsx)(Oye,{projectId:e,title:O.title,status:O.status,sample:w||C.isPending}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-6 max-[1180px]:hidden`,children:[(0,h.jsx)(ixe,{steps:Ie}),(0,h.jsx)(axe,{cost:s.data,onOpen:()=>ee(`cost`)}),(0,h.jsx)(a_e,{})]})]}),children:[(0,h.jsx)(c5,{id:`article`,title:`Article`,stages:[ce,le].filter(U7),active:Ee===`article`,...Oe,children:ge(ce)||ge(le)?ke(ce,le):(0,h.jsx)(l5,{stage:ce,project:O,name:`Article`})}),(0,h.jsx)(c5,{id:`narration`,title:`Narration`,stages:[ue].filter(U7),active:Ee===`narration`,...Oe,children:je(ue)?ke(ue):(0,h.jsx)(l5,{stage:ue,project:O,name:`Narration`})}),(0,h.jsx)(c5,{id:`images`,title:`Images`,head:!1,stages:[de,fe].filter(U7),active:Ee===`images`,...Oe,children:ke(de,fe)}),(0,h.jsxs)(c5,{id:`video`,title:iF(he)===`audio`?`Audio export`:`Video`,stages:[pe].filter(U7),active:Ee===`video`,...Oe,...j&&te.next?.action?.intent.kind!==`prepare-upload`?{extra:(0,h.jsx)(R,{variant:`secondary`,onClick:()=>f(!0),children:`Prepare upload`})}:{},children:[ke(pe),pe!==void 0&&_e?(0,h.jsx)(lye,{stage:pe,project:O,outputs:A}):null,pe!==void 0&&ve?(0,h.jsx)(yye,{stage:pe,project:O,outputs:A}):null]}),me===void 0?null:(0,h.jsx)(c5,{id:`document`,title:`PDF`,stages:[me],active:Ee===`document`,...Oe,children:je(me)?ke(me):(0,h.jsx)(l5,{stage:me,project:O,name:`PDF`})}),(0,h.jsx)(G7,{id:`cost`,title:`Run cost`,selected:Ee,children:(0,h.jsx)(Pye,{projectId:e})}),(0,h.jsx)(G7,{id:`live`,title:`Live`,selected:Ee,children:Ee===`live`?(0,h.jsx)(Gye,{project:O,revisionId:y,stages:k,outputs:A}):null}),(0,h.jsx)(G7,{id:`settings`,title:`Settings`,selected:Ee,children:(0,h.jsx)(Ybe,{controller:b,active:Ee===`settings`,renderEditor:e=>(0,h.jsx)(Fbe,{...e,renderContent:e=>(0,h.jsx)(_be,{...e},e.view.revision.id)})})}),y===null?null:(0,h.jsx)(G7,{id:`checkpoints`,title:`Checkpoints`,selected:Ee,children:(0,h.jsx)(wye,{projectId:e,revisionId:y,paused:O.status===`paused`,stages:k,approvedInRail:te.next?.action?.intent.kind===`approve`?te.next.action.intent.gate.checkpointId:void 0})}),(0,h.jsx)(G7,{id:`history`,title:`History`,selected:Ee,children:(0,h.jsx)(Xbe,{controller:b,projectId:e,active:Ee===`history`})})]})]}),(0,h.jsx)(Zbe,{controller:b}),d?(0,h.jsx)(h2,{projectId:e,onClose:()=>f(!1)}):null,(0,h.jsx)(oxe,{projectId:e,revisionId:y,title:O.title,open:p,onClose:()=>g(!1)}),(0,h.jsx)(zy,{open:_,title:Ne.title,consequence:Ne.consequence,confirmLabel:Ne.verb,cancelLabel:Ne.dismiss,pending:c.pending,onConfirm:()=>{v(!1),c.run({kind:`cancel`})},onCancel:()=>v(!1)})]})})})})})}var U7=e=>e!==void 0;function W7({item:e,selected:t,onSelect:n}){return(0,h.jsx)($6,{className:`max-md:w-auto`,"data-tour":`project-rail-${e.id}`,current:e.id===t,onClick:()=>n(e.id),...e.tone===void 0?{}:{icon:(0,h.jsx)(wS,{tone:e.tone})},...e.meta===void 0?{}:{meta:e.meta},children:e.label})}function G7({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-5`,children:[(0,h.jsx)(`h2`,{className:`sl-section-head__title m-0`,children:t}),r]})}var wxe={id:``,title:``,format:`16:9`,status:`pending`,createdAt:``,config:{sources:{}}};function Txe(){return(0,h.jsxs)(`div`,{role:`status`,"aria-label":`Loading project`,children:[(0,h.jsxs)(`div`,{className:`mb-6 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)(Cq,{sections:(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))}),aside:(0,h.jsx)(`span`,{className:`h-40 rounded-control bg-sunken`}),children:(0,h.jsx)(`span`,{className:`h-[480px] rounded-control bg-sunken`})})]})}function Exe(e,t){let{api:n}=z(),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),Hq(n,e,r.current).then(async e=>{if(!e.ok){s(e.message);return}await t(e.value.draft.id)?r.current=void 0:s(`The next chapter's draft was made, but Play could not open it because the draft open there is not saved yet. Open Play, let it save, then press Make the next chapter again.`)}).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)))}}}var Dxe=[`all`,`running`,`queued`,`waiting`,`ready`,`failed`];function Oxe(e){return Dxe.find(t=>t===e)}var K7=[{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 q7(e,t){switch(t){case`all`:return!0;case`running`:return e.status===`running`||e.status===`paused`;case`queued`:return S3(e);case`waiting`:return v3(e);case`ready`:return x3(e);case`failed`:return e.status===`failed`||e.status===`partial`}}function kxe(e){let t={running:{tone:`running`,word:`Running`},paused:{tone:`waiting`,word:`Paused`},pending:{tone:`off`,word:`Queued`},failed:{tone:`failed`,word:`Failed`},partial:{tone:`info`,word:`Done with problems`},done:{tone:`done`,word:`Done`},canceled:{tone:`off`,word:`Canceled`}};if(v3(e))return{tone:`waiting`,word:`Waiting for you`};if(e.status===`pending`&&e.setAside===!0)return{tone:`done`,word:`Kept as is`};let n=e.status===`running`?HH(e.limitWaits):void 0;return n===void 0?t[e.status]:{tone:`waiting`,word:n}}function Axe(e){let t=e.config.articlePrompt,n=e.config.voices?.book;return[n===void 0?void 0:RA(n),t===void 0||t===``?void 0:t,e.format].filter(e=>e!==void 0).join(` · `)}function jxe({initialFilter:e=`all`}={}){let{api:t}=z(),n=_(),r=Iy(),i=wx(),a=P(rb(t)),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(e),u=P({queryKey:By,queryFn:()=>Wy(t)}),d=new Set(Object.values(u.data?.samples??{}).filter(e=>e!==null)),[f,p]=(0,m.useState)(``),g=(0,m.useRef)(null),v=kx(g,`projects`),y=F({mutationFn:e=>No(t,e),onSettled:async()=>{s(void 0),await n.invalidateQueries({queryKey:B.projects})}}),b=F({mutationFn:e=>g3(t,e.project.id,e.uploaded),onError:(e,t)=>r(`${t.project.title} wasn't changed: ${e.message} Press the button again.`,`error`),onSettled:async()=>{await n.invalidateQueries({queryKey:B.projects})}});Ox({id:`projects.show.waiting`,title:`Show projects that need you`,group:`Projects`,keywords:[`waiting`,`filter`],run:()=>l(`waiting`)}),Ox({id:`projects.show.ready`,title:`Show videos ready to upload`,group:`Projects`,keywords:[`upload`,`finished`,`filter`],run:()=>l(`ready`)}),Ox({id:`projects.show.failed`,title:`Show failed projects`,group:`Projects`,keywords:[`error`,`filter`],run:()=>l(`failed`)});let x=(a.data?.projects??[]).filter(e=>i.includes(e.channelId)),S=f.trim().toLowerCase(),C=x.filter(e=>q7(e,c)&&(S===``||e.title.toLowerCase().includes(S)));return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{title:`Projects`,meta:a.data===void 0?void 0:`${String(x.length)} ${x.length===1?`project`:`projects`} · ${i.channel?.name??`every channel`}`,actions:(0,h.jsxs)(bS,{to:`/play`,variant:`primary`,children:[(0,h.jsx)(Hc,{"aria-hidden":`true`,strokeWidth:1.75}),`New project`]})}),a.data?.projects.length===0?(0,h.jsx)(xB,{}):null,a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-4 text-danger`,children:a.error.message}),a.data===void 0?a.error===null?(0,h.jsx)(Nxe,{}):null:a.data.projects.length===0?(0,h.jsx)(Q1,{title:`No projects yet`,actions:(0,h.jsx)(bS,{to:`/play`,variant:`primary`,children:`Make your first video`}),children:`Set up a run on Play: pick a template, type a topic and start.`}):(0,h.jsxs)(q1,{split:`aside`,children:[(0,h.jsxs)(J1,{label:`Project list`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsxs)(`div`,{className:`relative w-full max-w-[320px]`,children:[(0,h.jsx)(Gc,{"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:g,"aria-label":`Search projects`,"aria-keyshortcuts":Bx(v),placeholder:`Search projects`,value:f,onChange:e=>p(e.target.value),className:`sl-input pl-9`})]}),(0,h.jsx)(Rb,{label:`Show`,value:c,options:K7,onChange:l,className:`max-w-full overflow-x-auto`})]}),C.length===0?(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:x.length===0?`No projects in ${i.channel?.name??`this channel`} yet. Pick All channels in the rail to see the others.`:`No project matches. Clear the search or pick All.`}):(0,h.jsx)(oU,{label:`Projects`,children:C.map(e=>(0,h.jsx)(Mxe,{project:e,sample:d.has(e.id),onDelete:()=>s(e),onUploaded:t=>b.mutate({project:e,uploaded:t}),busy:b.isPending},e.id))})]}),(0,h.jsxs)(J1,{as:`aside`,label:`Projects at a glance`,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(H,{title:`At a glance`}),(0,h.jsx)(U2,{children:K7.filter(e=>e.value!==`all`).map(e=>(0,h.jsx)(W2,{label:e.label,value:String(x.filter(t=>q7(t,e.value)).length)},e.value))})]}),(0,h.jsxs)(`section`,{"aria-label":`Video queue`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(H,{title:`Video queue`,info:`play.queue`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Videos started together, in the order they run, are on the calendar.`}),(0,h.jsx)(`div`,{children:(0,h.jsx)(xS,{to:`/calendar`,children:`Open calendar`})})]})]})]}),y.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`mt-3 text-small text-danger`,children:y.error.message}),(0,h.jsx)(zy,{open:o!==void 0,title:o===void 0?``:`Delete "${o.title}"?`,consequence:`Moves the project to the trash for 30 days. Restore it or delete it for good in Settings → Trash.`,confirmLabel:`Delete project`,cancelLabel:`Keep it`,pending:y.isPending,onConfirm:()=>{o!==void 0&&y.mutate(o.id)},onCancel:()=>s(void 0)})]})}function Mxe({project:e,sample:t,onDelete:n,onUploaded:r,busy:i}){let a=kxe(e),o=e.status===`running`;return(0,h.jsx)(sU,{title:(0,h.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(ma,{to:`/projects/$projectId`,params:{projectId:e.id},children:e.title}),t?(0,h.jsx)(ES,{children:`Sample`}):null]}),meta:(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,h.jsxs)(`span`,{children:[`${Axe(e)} · started ${zu(e.createdAt)}`,e.views===void 0?``:` · ${e.views.toLocaleString()} views${e.ctr===void 0?``:` · ${String(e.ctr)}% CTR`}`]}),o?(0,h.jsx)(G2,{value:e.progress,label:`${e.title} progress`,valueText:`${String(Math.round(e.progress*100))}% done`,className:`max-w-[240px]`}):null]}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(TS,{tone:a.tone,children:[a.word,(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`${e.title}: ${a.word}`})]}),x3(e)?(0,h.jsx)(R,{variant:`quiet`,size:`small`,disabled:i,disabledReason:`Saving…`,onClick:()=>r(!0),children:`Mark uploaded`}):null,x3(e)?(0,h.jsx)(V,{id:`project.mark-uploaded`}):e.uploadedAt===null?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ES,{children:`Uploaded`}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Mark ${e.title} not uploaded`,disabled:i,disabledReason:`Saving…`,onClick:()=>r(!1),children:`Undo`})]}),(0,h.jsx)(My,{label:`Delete ${e.title}`,size:`small`,disabled:o,disabledReason:`Cancel the run first, then delete it.`,onClick:n,children:(0,h.jsx)(Yc,{"aria-hidden":`true`,strokeWidth:1.75})})]})})}function Nxe(){return(0,h.jsx)(`ul`,{"aria-label":`Loading projects`,className:`sl-list m-0 list-none p-0`,children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(`li`,{className:`sl-row`,"data-slot":`skeleton-row`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`h-3 w-2/5 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-[10px] w-1/4 rounded-control bg-sunken`})]}),(0,h.jsx)(`span`,{className:`h-[10px] w-16 rounded-control bg-sunken`})]},e))})}var Pxe=`Prepare restrained delivery cues for a documentary narrator. Let the facts carry the scene. Use a measured pace and make only occasional changes where the supplied wording clearly calls for emphasis, reflection or tension. Prefer no cue to an unnecessary cue. Avoid theatrical emotion, invented reactions and routine laughter or sighs. Never rewrite, summarize, translate or add spoken words. Return only the cue annotations required by the supplied format contract.`;function J7({promptId:e,kind:t,from:n,onLeave:r}){let{api:i}=z(),a=_(),o=dI(),s=P(ub(i)),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),[d,f]=sP(JSON.stringify(e===void 0?[`new`,t,n??null]:[`prompt`,e])),[p,g]=(0,m.useState)([]),[v,y]=(0,m.useState)(void 0),b=v!==void 0,[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(!1),T=s.data?.prompts,E=e??n,D=E===void 0?void 0:T?.find(e=>e.id===E),O=D===void 0?{kind:t,name:``,body:``}:e===void 0?{kind:D.kind,name:`${D.name} copy`,body:D.body}:{kind:D.kind,name:D.name,body:D.body},k=d??v??O,A=F({mutationFn:t=>As(i,t,e),onSuccess:async(e,t)=>{if(!e.ok){g(e.fields);return}y(e.value),f(e=>e===t?void 0:e),o({type:`prompt-saved`,id:e.value.id,kind:e.value.kind}),await a.invalidateQueries({queryKey:ub(i).queryKey})}}),j=F({mutationFn:e=>Ms(i,e),onSuccess:async()=>{S(!1),f(void 0),await a.invalidateQueries({queryKey:ub(i).queryKey}),r(k.kind)}}),ee=F({mutationFn:({id:e,on:t})=>js(i,e,t),onSettled:async()=>{await a.invalidateQueries({queryKey:ub(i).queryKey})}});J2(b,()=>{r(k.kind)});let te=(e,t)=>{f(e),g(e=>e.filter(e=>e.field!==t))},M=$4(k,p),ne=e3(M),N=r3(k.body),re=k.body.trim()===``?[]:t3(M),ie=k.name.trim()===``?[]:n3(M);return uI({promptNamed:k.name.trim()!==``&&ie.length===0,promptBodyReady:k.body.trim()!==``&&re.length===0,promptHasKeywords:N.length>0&&re.length===0,promptSaveReady:ne===void 0&&!A.isPending&&!b,promptSaving:A.isPending||b,promptIsArticle:k.kind===`article`,promptIsImage:k.kind===`image`}),s.error===null?E!==void 0&&T===void 0?(0,h.jsx)(Z2,{}):E!==void 0&&D===void 0?(0,h.jsx)(X7,{kind:t,children:`That prompt is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{crumb:(0,h.jsx)(p4,{children:(0,h.jsx)(ma,{to:`/prompts`,search:{kind:k.kind},children:`Prompts`})}),title:e===void 0?`New prompt`:`Edit prompt`,meta:`${sV(k.kind)} prompt`}),(0,h.jsxs)(`div`,{"data-tour":`prompt-editor`,className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${d4} flex min-w-0 flex-col gap-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,h.jsx)(`div`,{"data-tour":`prompt-name`,className:`min-w-[min(100%,240px)] flex-1`,children:(0,h.jsx)(dV,{label:`Name`,tip:`library.prompt.name`,...ie.length===0?{}:{error:ie.map(e=>e.message).join(` `)},children:(0,h.jsx)(pV,{value:k.name,onChange:e=>{te({...k,name:e.target.value},`name`)}})})}),(0,h.jsx)(Z4,{label:`Kind`,value:k.kind,options:oV,tip:`library.prompt.kind`,onPick:e=>{te({...k,kind:e},`name`)}})]}),(0,h.jsxs)(`div`,{"data-tour":`prompt-body`,...Ib,children:[(0,h.jsxs)(`div`,{className:`mb-1 flex min-h-8 items-end justify-between gap-3`,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:c,className:`sl-field__label`,children:`Body`}),(0,h.jsx)(V,{id:Fxe[k.kind],label:`${sV(k.kind)} prompt body`,className:`-my-1`})]}),Y7(k.kind)?(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(R,{variant:`quiet`,size:`small`,onClick:()=>{let e=Y7(k.kind);e!==void 0&&(k.body.trim()===``?te({...k,body:e.body},`body`):w(!0))},children:Y7(k.kind)?.label}),(0,h.jsx)(V,{id:`library.prompt.starter`,label:Y7(k.kind)?.label})]}):null]}),(0,h.jsx)(a3,{id:c,value:k.body,invalid:re.length>0,describedBy:re.length===0?void 0:l,onChange:e=>{te({...k,body:e},`body`)}})]}),k.kind===`image`?(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e!==void 0&&D?.kind===`image`?(0,h.jsx)(Lb,{checked:ee.isPending?ee.variables.on:D.photorealistic===!0,disabled:ee.isPending,onChange:t=>ee.mutate({id:e,on:t}),label:`Draws photorealistic pictures`,tip:`library.prompt.photorealistic`}):(0,h.jsxs)(`span`,{className:`flex items-center gap-1 text-small text-ink-2`,children:[`Save this Image prompt first, then choose whether it draws photorealistic pictures.`,(0,h.jsx)(V,{id:`library.prompt.photorealistic`})]}),ee.error===null?null:(0,h.jsx)(`span`,{role:`alert`,className:`text-small text-danger`,children:`Couldn't change Draws photorealistic pictures: ${ee.error.message} Press the switch again.`})]}):null,(0,h.jsx)(`div`,{"data-tour":`prompt-save`,children:(0,h.jsx)(X2,{onDelete:e===void 0?void 0:()=>{S(!0)},blocked:ne,blockedId:u,pending:A.isPending,saved:b,cancel:(0,h.jsx)(bS,{to:`/prompts`,search:{kind:k.kind},onClick:()=>{f(void 0)},variant:`secondary`,children:`Cancel`}),errors:[A.error,j.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{A.mutate(k)}})})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-slots`,className:f4,children:(0,h.jsx)(q4,{slots:N,body:k.body,lint:re,lintId:l})})]}),(0,h.jsx)(zy,{open:C,title:`Replace this prompt body?`,consequence:`The starter replaces the text in this editor. Nothing is saved until you choose Save.`,confirmLabel:`Use starter`,tone:`primary`,onConfirm:()=>{let e=Y7(k.kind);e!==void 0&&te({...k,body:e.body},`body`),w(!1)},onCancel:()=>w(!1)}),(0,h.jsx)(zy,{open:x,title:`Delete "${k.name}"?`,consequence:`Moves it to the trash for 30 days (Settings → Trash). Projects that used it keep their text.`,confirmLabel:`Delete prompt`,pending:j.isPending,onConfirm:()=>{e!==void 0&&j.mutate(e)},onCancel:()=>{S(!1)}})]}):(0,h.jsx)(X7,{kind:k.kind,children:s.error.message})}var Fxe={article:`library.prompt.body.article`,image:`library.prompt.body.image`,thumbnail:`library.prompt.body.thumbnail`,narration:`library.prompt.body.narration`,description:`library.prompt.body.description`,shorts:`library.prompt.body.shorts`,review:`library.prompt.body.review`,script:`library.prompt.body.script`};function Y7(e){if(e===`narration`)return{label:`Use Documentary Starter`,body:Pxe};if(e===`description`)return{label:`Use Built-in Starter`,body:qhe};if(e===`shorts`)return{label:`Use Built-in Starter`,body:Kk}}function X7({kind:e,children:t}){return(0,h.jsx)(m4,{back:(0,h.jsx)(ma,{to:`/prompts`,search:{kind:e},children:`Back to Prompts`}),children:t})}function Ixe({kind:e,onKind:t,onUseInPlay:n,playBlocked:r}){let{api:i}=z(),a=_(),o=P(ub(i)),[s,c]=(0,m.useState)(``),l=(0,m.useRef)(null),u=kx(l,`prompts`),[d,f]=(0,m.useState)(void 0),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)(void 0),b=F({mutationFn:e=>Ms(i,e),onSettled:async()=>{g(void 0),await a.invalidateQueries({queryKey:B.prompts})}}),x=async(e,t)=>{let n=await As(i,{kind:e.kind,name:t,body:e.body},e.id);return await a.invalidateQueries({queryKey:B.prompts}),n.ok?null:G4(n.fields)},S=o.data?.prompts.filter(t=>t.kind===e),C=s.trim().toLowerCase(),w=C===``?S:S?.filter(e=>e.name.toLowerCase().includes(C)||e.body.toLowerCase().includes(C)),T=w?.find(e=>e.id===d)??w?.[0];return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(R4,{action:(0,h.jsx)(Rxe,{kind:e}),children:[(0,h.jsx)(pV,{type:`search`,ref:l,"aria-label":`Search prompts`,"aria-keyshortcuts":Bx(u),placeholder:`Search prompts`,value:s,className:`w-full min-w-0 sm:w-64`,onChange:e=>c(e.target.value)}),(0,h.jsxs)(`span`,{className:`flex w-full items-center gap-1 sm:w-auto`,...Ib,children:[(0,h.jsx)(hV,{"aria-label":`Prompt kind`,value:e,className:`w-full sm:w-56`,options:oV,onChange:e=>{let n=oV.find(t=>t.value===e.target.value);n!==void 0&&t(n.value)}}),(0,h.jsx)(V,{id:`library.prompt.kind`})]})]}),o.error===null?null:(0,h.jsx)(I4,{what:`prompts`,message:o.error.message,onRetry:()=>void o.refetch()}),w===void 0||S===void 0?o.error===null?(0,h.jsx)(F4,{label:`Prompts`}):null:S.length===0?(0,h.jsxs)(Q1,{title:`No ${sV(e).toLowerCase()} prompts yet`,children:[`A prompt is text with `,`{{keywords}}`,`; each keyword becomes a field on Play.`]}):(0,h.jsx)(wq,{className:N4,list:w.length===0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`No ${sV(e).toLowerCase()} prompts match "${s.trim()}".`}):(0,h.jsx)(oU,{label:`Prompts`,children:w.map(e=>(0,h.jsx)(sU,{className:P4,title:(0,h.jsx)(K4,{name:e.name,onSelect:()=>f(e.id),onRename:t=>x(e,t)}),meta:Lxe(e),selected:e.id===T?.id,actions:(0,h.jsx)(L4,{name:e.name,edit:(0,h.jsx)(bS,{to:`/prompts/$promptId`,params:{promptId:e.id},"aria-label":`Edit ${e.name}`,variant:`quiet`,size:`small`,children:`Edit`}),duplicate:(0,h.jsx)(bS,{to:`/prompts/new`,search:{kind:e.kind,from:e.id},"aria-label":`Duplicate ${e.name}`,variant:`quiet`,size:`small`,children:`Duplicate`}),play:{run:n===void 0?void 0:()=>n(e),blocked:r},onHistory:()=>y(e),onDelete:()=>g(e)})},e.id))}),detail:T===void 0?null:(0,h.jsx)(A4,{item:`prompt`,id:T.id,name:T.name,kicker:`${sV(T.kind)} prompt`,meta:`Updated ${M4(T.updatedAt)}`,body:T.body,slots:T.slots,actions:(0,h.jsx)(bS,{to:`/prompts/$promptId`,params:{promptId:T.id},size:`small`,children:`Edit prompt`}),onOpenHistory:()=>y(T)},T.id)}),b.error===null?null:(0,h.jsx)(vI,{tone:`danger`,title:`The prompt wasn't deleted.`,className:`mt-4`,children:b.error.message}),v===void 0?null:(0,h.jsx)(E4,{item:`prompt`,id:v.id,name:v.name,onClose:()=>y(void 0)},v.id),(0,h.jsx)(zy,{open:p!==void 0,title:p===void 0?``:`Delete "${p.name}"?`,consequence:`Moves it to the trash for 30 days (Settings → Trash). Projects that used it keep their text.`,confirmLabel:`Delete prompt`,pending:b.isPending,onConfirm:()=>{p!==void 0&&b.mutate(p.id)},onCancel:()=>g(void 0)})]})}function Lxe(e){return`${sV(e.kind)} · ${j4(e.slots.length,`keyword`)} · updated ${M4(e.updatedAt)}`}function Rxe({kind:e}){return(0,h.jsx)(bS,{to:`/prompts/new`,search:{kind:e},variant:`primary`,children:`New prompt`})}var zxe={template:`Template`,schedule:`Schedule`,draft:`Draft`,project:`Project`};function Z7(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 Bxe(){let{api:e}=z(),t=_(),n=Iy(),r=P({queryKey:F1.catalogue,queryFn:()=>Ode(e),refetchInterval:3e4}),i=P({queryKey:F1.retired,queryFn:()=>R1(e)}),a=async()=>{await Promise.all([t.invalidateQueries({queryKey:[`provider-models`]}),t.invalidateQueries({queryKey:F1.retired})])},o=F({mutationFn:()=>kde(e),onSuccess:async e=>{t.setQueryData(F1.catalogue,e),n(e.sync?.warning??`Model list checked: ${Z7(e.sync?.changes??Vxe)}.`,e.sync?.warning?`error`:`success`),await a()}}),s=F({mutationFn:()=>Ade(e),onSuccess:async e=>{n(`Catalogue replaced with the published file.`,`success`),t.setQueryData(F1.catalogue,e),await a()}}),c=async()=>{await Promise.all([t.invalidateQueries({queryKey:F1.retired}),t.invalidateQueries({queryKey:Aq}),t.invalidateQueries({queryKey:vH}),t.invalidateQueries({queryKey:[`play-drafts`]}),t.invalidateQueries({queryKey:[`projects`]}),t.invalidateQueries({queryKey:[`project`]})])},l=F({mutationFn:t=>z1(e,t),onSuccess:c}),u=F({mutationFn:()=>jde(e),onSuccess:async e=>{n(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 c()}}),d=r.data?.sync,f=i.data??[],p=f.filter(e=>e.blocked===null&&e.replacement!==null),m=o.error?.message??s.error?.message??r.error?.message??r.data?.warning??d?.warning??null;return Ox({id:`settings.check-models`,title:`Check for new models`,group:`Settings`,context:`Models`,keywords:[`catalogue`,`prices`,`retired`],run:()=>{!o.isPending&&r.data?.path&&o.mutate()}}),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(H,{title:`Model catalogue`,info:`settings.models.catalogue`,children:[(0,h.jsx)(R,{disabled:o.isPending||!r.data?.path,onClick:()=>o.mutate(),children:o.isPending?`Checking…`:`Check now`}),(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(R,{variant:`quiet`,disabled:s.isPending||!r.data?.path,onClick:()=>s.mutate(),children:s.isPending?`Replacing…`:`Replace with published file`}),(0,h.jsx)(V,{id:`settings.models.replace`})]})]}),(0,h.jsxs)(`dl`,{className:`m-0 grid gap-x-6 border-t border-line text-small sm:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Catalogue file`}),(0,h.jsx)(`dd`,{className:`m-0 min-w-0 border-b border-line pb-3 break-all font-mono text-ink-2 sm:pt-3`,children:r.data?.path??`Not available`}),(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Verified`}),(0,h.jsx)(`dd`,{className:`m-0 border-b border-line pb-3 text-ink-2 sm:pt-3`,children:r.data?.updatedAt??`date unavailable`}),(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Last checked`}),(0,h.jsx)(`dd`,{className:`m-0 border-b border-line pb-3 text-ink-2 sm:pt-3`,children:d?.checkedAt?`${new Date(d.checkedAt).toLocaleString()} · ${Z7(d.changes)}`:`Not checked yet`})]}),d!==void 0&&d.changes.retired.length+d.changes.added.length>0?(0,h.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1 text-small text-ink-2`,children:[d.changes.added.length>0?(0,h.jsxs)(`span`,{children:[`New: `,d.changes.added.map(e=>e.name).join(`, `)]}):null,d.changes.retired.length>0?(0,h.jsxs)(`span`,{children:[`Retired: `,d.changes.retired.map(e=>e.name).join(`, `)]}):null]}):null,m===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-3 text-body text-danger`,children:m})]}),(0,h.jsxs)(`section`,{"aria-label":`Retired models in use`,children:[(0,h.jsx)(H,{title:`Retired models in use`,info:`settings.models.retired`,children:(0,h.jsx)(R,{variant:`primary`,disabled:u.isPending||p.length===0,onClick:()=>u.mutate(),children:u.isPending?`Switching…`:`Switch all`})}),i.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:i.error.message}):null,l.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:l.error.message}):null,f.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:i.isPending?`Looking…`:`Nothing uses a retired model.`}):(0,h.jsx)(`ul`,{"aria-label":`Retired models in use`,className:`sl-list m-0 list-none p-0`,children:f.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:zxe[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:[e0[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})]}),(0,h.jsx)(Py,{children:(0,h.jsx)(R,{size:`small`,disabled:e.blocked!==null||e.replacement===null||l.isPending,onClick:()=>l.mutate(e),children:e.replacement===null?`No replacement`:`Switch to ${e.replacement.name}`})})]},e.key))})]})]})}var Vxe={added:[],retired:[],priced:[]},Hxe={ok:`Ready`,warning:`Check`,problem:`Needs fixing`,unused:`Not set up`},Uxe={ok:`done`,warning:`waiting`,problem:`failed`,unused:`off`},Wxe={ok:`text-ink-2`,warning:`text-waiting`,problem:`text-danger`,skipped:`text-ink-3`};function Q7(){let{api:e}=z();return F({mutationFn:()=>L1(e)})}function Gxe(e){let{api:t}=z(),[n,r]=(0,m.useState)({byId:new Map});return{one:F({mutationFn:e=>L1(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 Kxe({run:e}={}){let t=Q7(),n=e??t,r=n.data,i=Gxe(r?.checkedAt),a=r?.providers.filter(e=>e.state!==`unused`).map(i.latest)??[],o=r?.providers.filter(e=>e.state===`unused`)??[];return(0,h.jsxs)(`section`,{"aria-label":`Health check`,children:[(0,h.jsx)(H,{title:`Health check`,info:`settings.health`,children:e===void 0?(0,h.jsx)(R,{disabled:n.isPending,onClick:()=>{n.mutate()},children:n.isPending?`Checking…`:`Check all`}):void 0}),n.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:[`The health check didn't finish: `,n.error.message,` Press Check all to try again.`]}),i.one.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:`The check didn't finish: ${i.one.error.message} Press Check again on the provider to try again.`}),r===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:n.isPending?`Checking every provider…`:`Not checked yet.`}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`ul`,{"aria-label":`Health by provider`,className:`sl-list m-0 list-none p-0`,children:a.map(e=>(0,h.jsxs)(`li`,{className:`sl-row grid-cols-1 gap-1`,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:e.displayName}),(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(TS,{tone:Uxe[e.state],children:Hxe[e.state]}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Check ${e.displayName} 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:L(`text-small`,Wxe[e.state]),children:[(0,h.jsxs)(`span`,{className:`font-semibold`,children:[e.label,`:`]}),` `,e.detail]},e.label))})]},e.id))}),(0,h.jsx)(`p`,{className:`m-0 mt-3 text-small text-ink-2`,children:o.length===0?`Checked at ${new Date(r.checkedAt).toLocaleTimeString()}.`:`Not set up and not used anywhere: ${o.map(e=>e.displayName).join(`, `)}.`})]})]})}var $7={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 e9(e){return nF(e)?{tone:`done`,word:`Ready`}:e.installed?{tone:`waiting`,word:`Needs attention`}:{tone:`off`,word:`Not found`}}function qxe({provider:e,readiness:t,kind:n}){let{api:r}=z(),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,p=e.cliPath?.command??f,g=o??u??``,v=nF(t),y=F({mutationFn:t=>Yo(r,e.id,t),onMutate:()=>l(!1),onSuccess:async e=>{i.setQueryData(B.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:B.providers})}});(0,m.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),q2);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.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`h3`,{id:a,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsx)(V,{id:$7[e.id],label:e.displayName})]}),(0,h.jsxs)(`p`,{className:`sl-section-head__meta`,children:[n,` · command line, no key needed`]})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2`,"aria-live":`polite`,children:[(0,h.jsx)(wS,{tone:e9(t).tone}),(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:Jxe(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)(gV,{className:`min-w-0 truncate`,title:p,children:p})]})]}),(0,h.jsxs)(Py,{children:[d?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-small text-ink-2`,children:[`Managed on host`,(0,h.jsx)(V,{id:`settings.cli.managed-on-host`})]}):(0,h.jsx)(R,{"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)(Y2,{}):null})]}),d||!b?null:(0,h.jsx)(`form`,{id:S,onSubmit:e=>{e.preventDefault(),y.isPending||y.mutate(g)},children:(0,h.jsx)(dV,{label:`Executable path`,tip:`settings.cli.path`,help:(0,h.jsxs)(h.Fragment,{children:[`Leave blank to find `,(0,h.jsx)(gV,{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)(pV,{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)(R,{type:`submit`,variant:`primary`,"aria-label":`Save ${e.displayName} path`,disabled:y.isPending,children:y.isPending?`Checking…`:`Save path`})]})})})]})}function Jxe(e,t){return e.issue===void 0?e.installed?e.version===void 0?`Installed`:`Installed, version ${e.version}`:t===null?`Not found on PATH`:`Not found at saved path`:e.issue}var Yxe=[`providers`,`system-voice`,`voices`];async function Xxe(e){return I(await e.fetch(`${e.origin}/api/providers/system-voice/voices`))}function t9(e=!0){let{api:t}=z();return P({queryKey:Yxe,queryFn:()=>Xxe(t),enabled:e})}function n9(e){return e.available?{tone:`done`,word:`Ready`}:{tone:`off`,word:`Not found`}}function Zxe({provider:e,readiness:t}){let n=(0,m.useId)(),r=t9(t.available).data?.engines??[];return(0,h.jsxs)(`section`,{"aria-labelledby":n,"data-ready":t.available,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`h3`,{id:n,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsx)(V,{id:$7[e.id],label:e.displayName})]}),(0,h.jsx)(`p`,{className:`sl-section-head__meta`,children:`Speech · built into this computer, no key needed`})]}),(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2`,"aria-live":`polite`,children:[(0,h.jsx)(wS,{tone:n9(t).tone}),(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:t.available?`Found ${t.engine??`a speech program`}. Narration with it is free; a keyed voice (ElevenLabs, OpenAI) sounds better.`:t.issue??`No speech program was found on this computer.`})]}),r.length===0?null:(0,h.jsx)(`ul`,{className:`m-0 list-none p-0 text-small text-ink-2`,children:r.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)(Py,{children:(0,h.jsx)(bS,{to:`/settings`,search:{section:`voices`},children:`Add a system voice`})}):null]})}function Qxe({value:e,onPick:t}){let n=t9(),r=n.data?.engines??[];return n.data!==void 0&&r.length===0?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:n.data.issue??`No speech program was found on this computer.`}):(0,h.jsxs)(hV,{value:e,onChange:e=>{for(let n of r){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:n.data===void 0?`Looking for voices…`:`Pick a voice`}),r.map(e=>(0,h.jsx)(`optgroup`,{label:e.name,children:e.voices.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.language===void 0?e.name:`${e.name} (${e.language})`},e.id))},e.id))]})}var r9=[`llm`,`tts`,`image`],i9={llm:`Text`,tts:`Speech`,image:`Images`},$xe=`••••••••••••`;function eSe(e){return nF(e.readiness)}function tSe(e){return e.readiness.kind===`cli`?e9(e.readiness):e.readiness.kind===`local`?n9(e.readiness):e.readiness.hasKey?{tone:`done`,word:`Key saved`}:{tone:`off`,word:`No key`}}function nSe(){let{api:e}=z(),t=P(cb(e)),[n,r]=(0,m.useState)(void 0),i=(0,m.useRef)(null),a=(0,m.useRef)(!1);(0,m.useEffect)(()=>{n!==void 0&&a.current&&(a.current=!1,typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: 1023px)`).matches&&i.current?.scrollIntoView?.({block:`start`,behavior:`smooth`}))},[n]);let o=r9.flatMap(e=>(t.data?.providers??[]).filter(t=>t.family===e)),s=o.find(e=>!eSe(e))??o[0];if(n===void 0&&s!==void 0&&r(s.id),t.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:t.error.message});if(t.data===void 0)return(0,h.jsx)(iSe,{});let c=o.find(e=>e.id===n)??s,l=o.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey),u=e=>{a.current=!0,r(e)};return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:[l?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Paste a key to make its provider selectable on Play.`}):null,r9.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,"aria-labelledby":`keys-${e}-title`,className:`grid items-start gap-x-8 gap-y-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(H,{id:`keys-${e}-title`,title:i9[e],size:`small`,className:`pb-2`}),(0,h.jsx)(oU,{label:`${i9[e]} providers`,children:o.filter(t=>t.family===e).map(e=>{let t=tSe(e);return(0,h.jsx)(sU,{title:e.displayName,meta:e.readiness.kind===`cli`?`Command line`:e.readiness.kind===`local`?`Built in, no key`:`API key`,selected:e.id===c?.id,onSelect:()=>u(e.id),actions:(0,h.jsx)(TS,{tone:t.tone,children:t.word})},e.id)})})]}),c===void 0||c.family!==e?null:(0,h.jsx)(`div`,{ref:i,className:`min-w-0 scroll-mt-4`,children:c.readiness.kind===`cli`?(0,h.jsx)(qxe,{provider:c,readiness:c.readiness,kind:i9[c.family]},c.id):c.readiness.kind===`local`?(0,h.jsx)(Zxe,{provider:c,readiness:c.readiness},c.id):(0,h.jsx)(rSe,{provider:c,hasKey:c.readiness.hasKey},c.id)})]},e))]})}function rSe({provider:e,hasKey:t}){let{api:n}=z(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(void 0),C=(0,m.useId)(),w=HF[e.id],T=o.trim(),E=async()=>{b(!0),S(void 0);try{S(await Dde(n,e.id,T===``?void 0:T))}catch(e){p(e instanceof Error?e.message:String(e))}finally{b(!1)}},D=async()=>{l(!0),p(void 0);try{await Jo(n,e.id,o),s(``),d(!0),S(void 0),await r.invalidateQueries({queryKey:B.providers})}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}},O=F({mutationFn:()=>Xo(n,e.id),onSuccess:async()=>{v(!1),p(void 0),await r.invalidateQueries({queryKey:B.providers})},onError:e=>{v(!1),p(e.message)}});(0,m.useEffect)(()=>{if(!u)return;let e=setTimeout(()=>{d(!1)},q2);return()=>{clearTimeout(e)}},[u]);let k=[t?a:void 0,x===void 0?void 0:C].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`section`,{"aria-labelledby":i,"data-ready":t,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsx)(H,{as:`h3`,size:`default`,id:i,title:t?e.displayName:`Set up ${e.displayName}`,info:$7[e.id],infoLabel:e.displayName,meta:`${i9[e.family]} · ${t?`a key is saved`:`needs an API key`}`,className:`pb-0`}),w===void 0?null:t?(0,h.jsxs)(`details`,{className:`text-small text-ink-2`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer`,children:`Where to get a key`}),(0,h.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:(0,h.jsx)(a9,{guide:w})})]}):(0,h.jsx)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:(0,h.jsx)(a9,{guide:w})}),(0,h.jsx)(dV,{label:`${e.displayName} API key`,tip:`settings.providers.api-key`,help:`Stored on this computer only. Never in backups or exports.`,error:f,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(pV,{type:`password`,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 basis-[200px]`,"aria-describedby":k===``?void 0:k,placeholder:t?$xe:`Paste API key`,value:o,onChange:e=>{s(e.target.value)}}),(0,h.jsx)(R,{variant:`primary`,"aria-label":`Save ${e.displayName} key`,disabled:o.trim()===``||c,onClick:()=>{D()},children:`Save`})]})}),t?(0,h.jsx)(`span`,{id:a,className:`sr-only`,children:`A key is stored for this provider.`}):null,x===void 0?null:(0,h.jsx)(`p`,{id:C,role:x.ok?`status`:`alert`,className:L(`m-0 text-small`,x.ok?`text-accent-ink`:`text-danger`),children:x.message}),(0,h.jsxs)(Py,{children:[(0,h.jsx)(R,{"aria-label":`Test ${e.displayName} key`,disabled:!t&&T===``||y,disabledReason:`Paste a key first.`,onClick:()=>{E()},children:y?`Testing…`:`Test`}),(0,h.jsx)(V,{id:`settings.providers.test-key`,label:`Test`}),(0,h.jsx)(R,{variant:`quiet`,"aria-label":`Remove ${e.displayName} key`,disabled:!t,onClick:()=>{v(!0)},children:`Remove`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:u?(0,h.jsx)(Y2,{}):null})]}),(0,h.jsx)(zy,{open:g,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this provider cannot retry until a key is saved.`,confirmLabel:`Remove key`,pending:O.isPending,onConfirm:()=>{O.mutate()},onCancel:()=>{v(!1)}})]})}function a9({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 provider's `,t(e.docs.url,e.docs.label),`. After saving, choose Test.`]})]})}function iSe(){return(0,h.jsxs)(`div`,{className:`grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,role:`status`,"aria-label":`Loading providers`,children:[(0,h.jsx)(`div`,{className:`flex flex-col gap-6`,children:[[`llm`,4],[`tts`,5],[`image`,5]].map(([e,t])=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`span`,{className:`mb-2 block h-3 w-16 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:`sl-row`,children:[(0,h.jsx)(`span`,{className:`h-4 w-32 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-4 w-20 rounded-control bg-raised`})]},e))})]},e))}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`span`,{className:`h-6 w-48 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-10 rounded-control bg-raised`})]})]})}function o9(e){return e.split(/[\s,;]+/).map(e=>e.trim().toLowerCase()).filter(e=>e!==``)}function aSe(e){return e.languages===void 0?`Any (not known)`:e.languages.map(e=>VO(e).code===e?VO(e).name:e).join(`, `)}function oSe({voice:e}){let{api:t}=z(),n=_(),r=(0,m.useId)(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)((e.languages??[]).join(`, `)),[c,l]=(0,m.useState)(void 0),u=F({mutationFn:()=>ws(t,e.id,o9(o)),onSuccess:async e=>{if(e!==void 0){l(e.message);return}a(!1),l(void 0),await n.invalidateQueries({queryKey:B.voices})}});return i?(0,h.jsxs)(`div`,{className:`grid gap-1`,children:[(0,h.jsx)(pV,{id:r,"aria-label":`Languages of ${e.name}`,value:o,placeholder:`es, de`,"aria-invalid":c!==void 0,onChange:e=>{s(e.target.value),l(void 0)}}),c===void 0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:c}),u.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:u.error.message}),(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(R,{size:`small`,disabled:u.isPending,onClick:()=>u.mutate(),children:`Save`}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,onClick:()=>{a(!1),l(void 0),s((e.languages??[]).join(`, `))},children:`Cancel`})]})]}):(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-ink-2`,children:aSe(e)}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Edit the languages of ${e.name}`,onClick:()=>a(!0),children:`Edit`})]})}function sSe(){let{api:e}=z(),t=_(),n=P(lb(e)),r=P(cb(e)),[i,a]=(0,m.useState)(void 0),o=F({mutationFn:t=>Es(e,t),onSettled:async()=>{a(void 0),await t.invalidateQueries({queryKey:B.voices})}}),s=F({mutationFn:({id:t,on:n})=>Ts(e,t,n),onSettled:async()=>{await t.invalidateQueries({queryKey:B.voices})}}),c=(r.data?.providers??[]).filter(e=>e.family===`tts`);if(n.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:n.error.message});let l=n.data?.voices;return(0,h.jsxs)(`div`,{"data-tour":`voices`,className:`flex min-w-0 flex-col gap-10`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 overflow-x-auto`,children:[(0,h.jsxs)(`table`,{className:`sl-table min-w-[640px] table-fixed`,...Ib,children:[(0,h.jsx)(`caption`,{className:`sr-only`,children:`Voices`}),(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{scope:`col`,className:`w-[22%] pr-4`,children:`Name`}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[18%] pr-4`,children:`Provider`}),(0,h.jsx)(`th`,{scope:`col`,className:`pr-4`,children:`Voice ID`}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[22%] pr-4`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`Languages`,(0,h.jsx)(V,{id:`play.voices.languages`,className:`-my-1`})]})}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[20%] pr-4`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`Real person`,(0,h.jsx)(V,{id:`play.voices.real-person`,className:`-my-1`})]})}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[96px]`,children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:l===void 0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:6,children:(0,h.jsx)(`span`,{className:`block h-4 w-64 rounded-control bg-raised`})})}):l.length===0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:6,className:`text-ink-2`,children:`Add a voice ID from your text-to-speech provider. Audio needs one to narrate.`})}):l.map(e=>(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`td`,{className:`truncate pr-4 font-semibold`,children:e.name}),(0,h.jsx)(`td`,{className:`truncate pr-4 text-ink-2`,children:lSe(c,e.provider)}),(0,h.jsx)(`td`,{className:`truncate pr-4 text-ink-2`,children:e.voiceId}),(0,h.jsx)(`td`,{className:`pr-4`,children:(0,h.jsx)(oSe,{voice:e})}),(0,h.jsx)(`td`,{className:`pr-4`,children:(0,h.jsx)(Lb,{checked:s.isPending&&s.variables.id===e.id?s.variables.on:e.imitatesRealPerson===!0,disabled:s.isPending,onChange:t=>s.mutate({id:e.id,on:t}),label:(0,h.jsx)(`span`,{className:`sr-only`,children:`${e.name} imitates a real person`}),className:`text-small`})}),(0,h.jsx)(`td`,{className:`text-right`,children:(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Remove ${e.name}`,onClick:()=>{a(e)},children:`Remove`})})]},e.id))})]}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:`Couldn't change Real person: ${s.error.message} Press the switch again.`}),o.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:o.error.message})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{title:`Add a voice`}),(0,h.jsx)(cSe,{tts:c})]}),(0,h.jsx)(zy,{open:i!==void 0,title:i===void 0?``:`Remove ${i.name}?`,consequence:`Projects that used this voice keep the audio they made with it.`,confirmLabel:`Remove voice`,pending:o.isPending,onConfirm:()=>{i!==void 0&&o.mutate(i.id)},onCancel:()=>{a(void 0)}})]})}function cSe({tts:e}){let{api:t}=z(),n=_(),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(void 0),[d,f]=(0,m.useState)(void 0),p=l??e[0]?.id,g=F({mutationFn:e=>Cs(t,e),onSuccess:async e=>{if(!e.ok){f(e.refusal);return}i(``),o(``),c(``),f(void 0),await n.invalidateQueries({queryKey:B.voices})}}),v=(e,t)=>{t(),d?.field===e&&f(void 0)},y=e=>d?.field===e?d.message:void 0;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`grid items-start gap-4 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,h.jsx)(dV,{label:`Voice name`,tip:`play.voices.name`,error:y(`name`),children:(0,h.jsx)(pV,{value:r,onChange:e=>{let t=e.target.value;v(`name`,()=>{i(t)})}})}),(0,h.jsx)(dV,{label:`Provider`,tip:`play.voices.provider`,error:y(`provider`),children:(0,h.jsxs)(hV,{value:p??``,onChange:t=>{let n=e.find(e=>e.id===t.target.value);n!==void 0&&v(`provider`,()=>{u(n.id)})},children:[e.length===0?(0,h.jsx)(`option`,{value:``,children:`No speech provider`}):null,e.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.displayName},e.id))]})}),(0,h.jsx)(dV,{label:`Voice ID`,tip:`play.voices.voice-id`,error:y(`voiceId`),...p===`inworld`?{help:`Use an Inworld voice ID, such as Dennis, or one from your workspace.`}:{},children:p===`system-voice`?(0,h.jsx)(Qxe,{value:a,onPick:e=>{v(`voiceId`,()=>{o(e.id)}),r.trim()===``&&i(e.name);let t=/^([a-z]{2,3})(?:[-_]|$)/i.exec(e.language??``)?.[1];s.trim()===``&&t!==void 0&&c(t.toLowerCase())}}):p===`google-tts`?(0,h.jsx)(hV,{value:a,options:[{value:``,label:`Pick a Gemini voice`},...GF.map(e=>({value:e.name,label:`${e.name} (${e.style})`}))],onChange:e=>{let t=e.target.value;v(`voiceId`,()=>{o(t),r.trim()===``&&i(t)})}}):(0,h.jsx)(pV,{className:`tabular-nums`,value:a,onChange:e=>{let t=e.target.value;v(`voiceId`,()=>{o(t)})}})}),(0,h.jsx)(dV,{label:`Languages`,tip:`play.voices.languages`,help:`Codes such as es, de.`,error:y(`languages`),children:(0,h.jsx)(pV,{value:s,placeholder:`es, de`,onChange:e=>{let t=e.target.value;v(`languages`,()=>{c(t)})}})}),(0,h.jsx)(R,{variant:`primary`,className:`md:mt-6`,disabled:p===void 0||d!==void 0||g.isPending,onClick:()=>{if(p!==void 0){let e=o9(s);g.mutate({provider:p,name:r,voiceId:a,...e.length===0?{}:{languages:e}})}},children:`Add voice`})]}),g.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:g.error.message})]})}function lSe(e,t){return e.find(e=>e.id===t)?.displayName??t}var s9=[`settings`,`notifications`],uSe=`The test notification couldn't be shown: this browser only allows notifications from installed apps. Set a Notification URL below instead.`;function dSe(){return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{title:`Browser and phone`,info:`settings.notifications`}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsx)(fSe,{}),(0,h.jsx)(pSe,{}),(0,h.jsx)(mSe,{})]})]})}function fSe(){let e=(0,m.useSyncExternalStore)(yP,_P,()=>!1),[t,n]=(0,m.useState)(gP),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=Iy(),c=e&&t===`granted`;async function l(e){if(i(void 0),!e){vP(!1);return}o(!0);try{let e=await SP();n(e);let t=xP(e);e===`granted`?(vP(!0),_P()||i(`Browser 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 Browser notifications on again.`)):i(t??`Browser notifications weren't turned on because the permission prompt was dismissed. Turn Browser notifications 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-center gap-x-6 gap-y-2`,children:[(0,h.jsx)(Lb,{label:`Browser notifications`,tip:`settings.notifications.browser`,checked:c,disabled:a,onChange:e=>void l(e)}),(0,h.jsx)(R,{variant:`quiet`,disabled:!c,disabledReason:`Turn Browser notifications on first.`,onClick:()=>{i(void 0);try{wP({projectId:`test`,text:WP},()=>{}),s(`Test notification sent to this browser.`,`success`)}catch{i(uSe)}},children:`Send test notification`})]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Works while any Slopify tab is open.`}),r===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:r})]})}function pSe(){let e=(0,m.useSyncExternalStore)(jP,kP,()=>!0);return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,h.jsx)(Lb,{label:`Run sounds`,tip:`settings.notifications.sounds`,checked:e,onChange:AP}),(0,h.jsx)(R,{variant:`quiet`,onClick:()=>FP(`start`),children:`Play start`}),(0,h.jsx)(R,{variant:`quiet`,onClick:()=>FP(`end`),children:`Play end`})]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`A chime when a run starts and a different one when it finishes, fails or waits for you. Works while any Slopify tab is open; set your computer's volume for how loud.`})]})}function mSe(){let{api:e}=z(),t=_(),n=Iy(),r=(0,m.useId)(),i=P({queryKey:s9,queryFn:()=>$o(e)}),[a,o]=(0,m.useState)(void 0),s=a??i.data?.url??``,c=KP(s),l=F({mutationFn:t=>ts(e,t),onSuccess:e=>{t.setQueryData(s9,e),o(void 0),n(e.url===null?`Notification URL removed.`:`Notification URL saved.`,`success`)}}),u=F({mutationFn:t=>ns(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;return(0,h.jsxs)(dV,{label:`Notification URL`,tip:`settings.notifications.url`,help:`Works with no tab open, for example an ntfy topic on your phone.`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(pV,{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)(R,{variant:`primary`,disabled:f||c!==void 0||a===void 0,onClick:()=>l.mutate(s),children:`Save`}),(0,h.jsx)(R,{variant:`quiet`,disabled:f||c!==void 0||s.trim()===``,onClick:()=>u.mutate(s),children:`Send test notification`})]}),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})]})}var c9={library:`The Library of Alexandria`,audiobook:`The Wind in the Willows (audiobook)`,podcast:`The Antikythera Mechanism (podcast)`};function hSe(){let{api:e}=z(),t=_(),n=P({queryKey:Vy,queryFn:()=>Yy(e)}),r=F({mutationFn:()=>Zy(e),onSettled:async()=>{await t.invalidateQueries({queryKey:Vy}),await t.invalidateQueries({queryKey:By}),await t.invalidateQueries({queryKey:B.projects})}}),i=r.data?.samples??n.data?.samples;return(0,h.jsxs)(`div`,{className:`mt-8`,children:[(0,h.jsx)(H,{title:`Sample projects`,info:`settings.sample.restore`}),(0,h.jsx)(oU,{label:`Sample projects`,children:Object.keys(c9).map(e=>{let t=i?.[e]??null;return(0,h.jsx)(sU,{title:c9[e],meta:t===null?`Not in your projects`:`In your projects`,actions:t===null?void 0:(0,h.jsx)(xS,{to:`/projects/$projectId`,params:{projectId:t},className:aU,children:`Open`})},e)})}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(R,{disabled:r.isPending,onClick:()=>r.mutate(),children:r.isPending?`Restoring…`:`Restore samples`}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Puts all three back as they shipped.`})]}),(0,h.jsx)(G1,{tone:r.error?`error`:`success`,children:r.error?.message??(r.isSuccess?`The samples are back in Projects.`:void 0)})]})}var gSe=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function _Se(e){let[t,n,r]=e.split(`-`).map(Number),i=gSe[(n??0)-1];return i===void 0||r===void 0?e:`${String(r)} ${i} ${String(t)}`}function l9(e,t){let n=[e.range===void 0?e.version:`Versions ${e.range}`,`released ${_Se(e.date)}`].filter(e=>e!==void 0).join(`, `),r=n.charAt(0).toUpperCase()+n.slice(1);return e.version===t?`${r}. The version you are running.`:`${r}.`}function vSe({note:e,onNote:t}){let{api:n}=z(),r=P(mI(n));if(r.error!==null)return(0,h.jsx)(vI,{tone:`danger`,title:`The patch notes did not load`,actions:(0,h.jsx)(R,{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 the patch notes…`});let{notes:i,version:a}=r.data,[o,...s]=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 c=e===void 0?void 0:i.find(t=>t.id===e),l=c!==void 0&&c.id!==o.id?c:void 0;return l===void 0?(0,h.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e!==void 0&&c===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 latest are below; older ones are under Earlier versions.`}):null,(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(H,{title:`Latest version`,meta:l9(o,a),info:`settings.patch-notes`}),(0,h.jsx)(mB,{id:o.id})]}),s.length===0?null:(0,h.jsxs)(`details`,{className:`max-w-prose border-t border-line py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer font-semibold`,children:`Earlier versions (${String(s.length)})`}),(0,h.jsx)(oU,{label:`Earlier versions`,className:`mt-2`,children:s.map(e=>(0,h.jsx)(sU,{title:e.title,meta:l9(e,a),onSelect:()=>t(e.id),actions:(0,h.jsx)(R,{"aria-label":`Read ${e.title}`,onClick:()=>t(e.id),children:`Read`})},e.id))})]})]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`div`,{children:(0,h.jsxs)(R,{variant:`quiet`,onClick:()=>t(void 0),children:[(0,h.jsx)(dc,{"aria-hidden":`true`,strokeWidth:1.75}),`Back to the latest patch notes`]})}),(0,h.jsx)(H,{title:`Earlier version`,meta:l9(l,a)}),(0,h.jsx)(mB,{id:l.id})]})}var u9=[`trash`];async function ySe(e){return(await I(await e.client.trash.$get())).items}async function bSe(e,t,n){return(await I(await e.client.trash[`:kind`][`:id`].restore.$post({param:{kind:t,id:n}}))).restored}async function xSe(e,t,n){let r=await e.client.trash[`:kind`][`:id`].$delete({param:{kind:t,id:n}});if(!r.ok)throw await fo(r)}var SSe={project:`Project`,prompt:`Prompt`,entry:`Intro/outro`,template:`Template`,schedule:`Schedule`};function CSe(e){return e.kind===`entry`&&e.detail!==null?e.detail===`intro`?`Intro`:`Outro`:e.kind===`prompt`&&e.detail!==null?`Prompt · ${e.detail}`:SSe[e.kind]}function wSe(e){return e<=0?`removed for good today`:e===1?`1 day left`:`${String(e)} days left`}var TSe=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}),ESe={project:[B.projects,[`calendar`]],prompt:[B.prompts],entry:[B.entries],template:[Aq],schedule:[vH,[`calendar`]]};function DSe(){let{api:e}=z(),t=_(),n=Iy(),r=P({queryKey:u9,queryFn:()=>ySe(e)}),[i,a]=(0,m.useState)(void 0),o=async e=>{await Promise.all([u9,...ESe[e.kind]].map(e=>t.invalidateQueries({queryKey:e})))},s=F({mutationFn:t=>bSe(e,t.kind,t.id),onSuccess:async(e,t)=>{await o(t),n(e.renamedFrom===null?`Restored "${e.name}".`:`Restored as "${e.name}": another item is now called "${e.renamedFrom}".`,`success`),e.kind===`schedule`&&n(`The schedule is paused. Press Resume on Schedules to run it again.`,`info`)},onError:e=>n(e.message,`error`)}),c=F({mutationFn:t=>xSe(e,t.kind,t.id),onSuccess:async(e,t)=>{a(void 0),await o(t),n(`Deleted "${t.name}" for good.`,`success`)},onError:e=>{a(void 0),n(e.message,`error`)}}),l=r.data??[];return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{title:`Trash`,info:`settings.trash`}),r.isPending?(0,h.jsx)(`p`,{className:`text-small text-ink-3`,children:`Loading the trash…`}):r.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-danger`,children:r.error.message}):l.length===0?(0,h.jsx)(Q1,{title:`The trash is empty`,children:`Anything you delete stays here for 30 days before it is removed for good.`}):(0,h.jsx)(oU,{label:`Deleted items`,children:l.map(e=>(0,h.jsx)(sU,{title:e.name,meta:`${CSe(e)} · deleted ${TSe.format(new Date(e.deletedAt))} · ${wSe(e.daysLeft)}`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R,{size:`small`,disabled:s.isPending||c.isPending,disabledReason:`Working on it`,onClick:()=>s.mutate(e),children:`Restore`}),(0,h.jsx)(R,{size:`small`,variant:`destructive`,disabled:s.isPending||c.isPending,disabledReason:`Working on it`,onClick:()=>a(e),children:`Delete now`})]})},`${e.kind}:${e.id}`))}),(0,h.jsx)(zy,{open:i!==void 0,title:i===void 0?``:`Delete "${i.name}" for good?`,consequence:i?.kind===`project`?`The project and every file it produced are removed from disk. This cannot be undone.`:i?.kind===`schedule`?`The schedule leaves the trash and cannot be restored. Its run history stays on Schedules.`:`It is removed for good. This cannot be undone.`,confirmLabel:`Delete for good`,cancelLabel:`Keep it`,pending:c.isPending,onConfirm:()=>{i!==void 0&&c.mutate(i)},onCancel:()=>{c.isPending||a(void 0)}})]})}var OSe=`https://github.com/GentBajko/slopify`,kSe=`https://www.patreon.com/cw/GentBajko`,ASe=`https://buymeacoffee.com/gentbajko`;function jSe(){return[{href:OSe,label:`GitHub`,detail:`The code, issues and releases.`,glyph:`github`},{href:kSe,label:`Patreon`,detail:`Monthly support for the project.`,glyph:`patreon`},{href:ASe,label:`Buy Me a Coffee`,detail:`A one-off thank you.`,glyph:`coffee`},{href:`https://slopify.stream/channel.html`,label:`How I run a channel with it`,detail:`A lore channel run on Slopify, start to finish.`}]}function MSe({onWhatsNew:e}){return(0,h.jsxs)(`div`,{className:`max-w-prose`,children:[(0,h.jsx)(H,{title:`About`}),(0,h.jsx)(`p`,{className:`m-0 mb-3 text-ink-2`,children:`Slopify is free and open source, and runs on your machine with your own keys. If it saves you time, you can support it here.`}),(0,h.jsxs)(`p`,{className:`m-0 mb-3 flex items-center gap-1 text-small text-ink-2`,children:[`Updates: the circular-arrows button at the foot of the sidebar (at the top on a phone).`,(0,h.jsx)(V,{id:`settings.updates`})]}),e===void 0?null:(0,h.jsxs)(`p`,{className:`m-0 mb-3 flex items-center gap-1`,children:[(0,h.jsx)(R,{onClick:e,children:`What's new in this version`}),(0,h.jsx)(V,{id:`settings.whats-new`})]}),(0,h.jsx)(`p`,{className:`m-0 mb-4 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)(`ul`,{"aria-label":`Links`,className:`sl-list m-0 list-none p-0`,children:jSe().map(e=>(0,h.jsx)(`li`,{className:`sl-row`,children:(0,h.jsxs)(`div`,{className:`sl-row__lead`,children:[e.glyph===void 0?(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}):(0,h.jsx)(_S,{name:e.glyph,className:`shrink-0 text-ink-2`}),(0,h.jsxs)(`div`,{className:`sl-row__text`,children:[(0,h.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`font-semibold text-ink underline underline-offset-3`,children:e.label}),(0,h.jsx)(`span`,{className:`sl-row__meta`,children:e.detail})]})]})},e.label))})]})}var d9=[`backups`],f9=1,p9=30;function m9(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function NSe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=f9&&Number(t)<=p9?void 0:`Keep between ${f9} and ${p9} backups.`}function PSe(e){return{enabled:e.config.enabled,time:e.config.time,keep:String(e.config.keep),folder:e.config.folder??``}}function h9(){let{api:e}=z(),t=_(),n=Iy();return F({mutationFn:()=>ko(e),onSuccess:e=>{t.setQueryData(d9,e),n(`Backup started. Its result shows here when it finishes.`,`success`)}})}function FSe(){let{api:e}=z(),t=_(),n=P({queryKey:d9,queryFn:()=>Do(e),refetchInterval:e=>e.state.data?.running===!0&&2e3}),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=F({mutationFn:t=>Oo(e,t),onSuccess:e=>{t.setQueryData(d9,e),i(void 0),o(!0)}}),c=h9();(0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),q2);return()=>clearTimeout(e)},[a]);let l=n.data,u=r??(l===void 0?void 0:PSe(l)),d=u===void 0?void 0:NSe(u.keep),f=e=>{u!==void 0&&i({...u,...e})};return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{title:`Daily backup`,info:`settings.backups`,children:(0,h.jsx)(R,{variant:`primary`,disabled:l===void 0||l.running||c.isPending,onClick:()=>c.mutate(),children:`Back up now`})}),(0,h.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-x-4 gap-y-1 text-small text-ink-2`,children:[(0,h.jsx)(`span`,{role:`status`,children:l===void 0?(0,h.jsx)(`span`,{className:`inline-block h-4 w-48 rounded-control bg-raised`}):ISe(l)}),(0,h.jsx)(`span`,{children:l===void 0?null:LSe(l)})]}),l?.status.detail?l.status.lastResult===`failed`?(0,h.jsx)(vI,{tone:`danger`,title:`Why the last backup stopped`,children:l.status.detail}):(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:l.status.detail}):null,c.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:c.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-6`,children:[(0,h.jsx)(Lb,{label:`Back up automatically`,tip:`settings.backups.auto`,checked:u?.enabled===!0,disabled:u===void 0,className:`self-start`,onChange:e=>f({enabled:e})}),(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(dV,{label:`Time of day`,tip:`settings.backups.time`,help:`${m9()} time`,children:(0,h.jsx)(pV,{type:`time`,className:`w-[140px] tabular-nums`,value:u?.time??`03:00`,disabled:u===void 0,onChange:e=>f({time:e.target.value})})}),(0,h.jsx)(dV,{label:`Keep last`,tip:`settings.backups.keep`,help:`Backups kept in the folder.`,error:d,children:(0,h.jsx)(pV,{type:`number`,inputMode:`numeric`,min:f9,max:p9,step:1,className:`w-[88px] tabular-nums`,value:u?.keep??`5`,disabled:u===void 0,onChange:e=>f({keep:e.target.value})})}),(0,h.jsx)(dV,{label:`Folder`,tip:`settings.backups.folder`,className:`md:col-span-2`,...l===void 0?{}:{help:RSe(l)},children:(0,h.jsx)(pV,{value:u?.folder??``,placeholder:l?.defaultFolder??``,disabled:u===void 0,onChange:e=>f({folder:e.target.value})})})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(R,{variant:`primary`,disabled:u===void 0||d!==void 0||s.isPending,onClick:()=>{u!==void 0&&(o(!1),s.mutate({enabled:u.enabled,time:u.time,timeZone:m9(),keep:Number(u.keep.trim()),folder:u.folder.trim()===``?null:u.folder.trim()}))},children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(Y2,{}):null}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 basis-full text-small text-danger`,children:s.error.message})]})]})]})}function g9(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function ISe(e){if(e.running)return`Backing up now…`;let{status:t}=e,n=t.lastSuccessAt===null?`No backup yet.`:`Last backup ${g9(t.lastSuccessAt)}${t.lastSuccessBytes===null?``:`, ${_9(t.lastSuccessBytes)}`}.`;return t.lastResult===`failed`&&t.lastAttemptAt!==null?`${n} The backup at ${g9(t.lastAttemptAt)} failed.`:t.lastResult===`waiting`?`${n} Waiting for projects to finish.`:n}function LSe(e){return e.config.enabled?e.overdue?`Next: shortly.`:e.nextRunAt===null?``:`Next: ${g9(e.nextRunAt)}.`:`Automatic backups are off.`}function RSe(e){let t=`${e.files.length} backup${e.files.length===1?``:`s`} here (${_9(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}`:`${e.config.folder===null?`Empty uses the default: `:`On your computer: `}${e.hostFolder}. ${t}`}function _9(e){if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e,r=t[0]??`KB`;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}`}var v9=[`storage-files`];function zSe({usageQueryKey:e}){let{api:t}=z(),n=_(),r=Iy(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(),u=P({queryKey:v9,queryFn:()=>Io(t),refetchInterval:e=>b9(e.state.data)?1e3:!1}),d=F({mutationFn:e=>Lo(t,e),onMutate:()=>l(void 0),onSuccess:e=>{n.setQueryData(v9,e),a(!1)},onError:e=>l(e.message)}),f=F({mutationFn:()=>Ro(t),onSuccess:e=>{e.opened||r(`Your files are in ${e.path}.`,`info`)},onError:e=>r(e.message,`error`)}),p=u.data,g=b9(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)(H,{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)(H,{title:`Your files`,meta:p.folder??`The Docker project folder isn't set up.`,info:`settings.files.docker`,children:(0,h.jsx)(R,{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)(y9,{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:[`To move your projects to Documents/Slopify, run this on the computer running Docker (or use `,(0,h.jsx)(gV,{children:`--projects-dir <folder>`}),` for another folder):`]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(gV,{className:`min-w-0 break-all`,children:p.dockerCommand}),(0,h.jsx)(R,{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)(H,{title:`Your files`,meta:p.folder,info:`settings.files`,children:[p.inDocuments||p.documentsRoot===null?null:(0,h.jsx)(R,{variant:`primary`,disabled:g||d.isPending,onClick:()=>d.mutate(`documents`),children:`Move to Documents/Slopify`}),(0,h.jsx)(R,{disabled:f.isPending,onClick:()=>f.mutate(),children:`Open folder`}),(0,h.jsx)(R,{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)(y9,{view:p}),i?(0,h.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),d.mutate(o)},children:[(0,h.jsx)(dV,{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)(pV,{value:o,placeholder:p.documentsRoot??`/home/you/Videos/Slopify`,onChange:e=>s(e.target.value)})}),(0,h.jsx)(R,{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 (`,Y5(p.move.bytes),` of `,Y5(p.move.totalBytes),`). Keep Slopify running until it finishes.`]}),(0,h.jsx)(G2,{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)(vI,{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)(R,{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)(vI,{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 y9({view:e}){let t=[[`Projects`,e.projects],[`Automatic backups`,e.backups],[`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 b9(e){return e?.move?.phase===`copying`||e?.move?.phase===`verifying`}function BSe(){let{api:e}=z(),t=P(sb(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)(qSe,{cells:5}),(0,h.jsx)(JSe,{})]}):null:(0,h.jsx)(HSe,{usage:t.data})]})}var VSe=[{id:`stage`,header:`Stage`,cell:e=>rF[e.stage]},{id:`model`,header:`Provider · model`,cell:e=>USe(e)},{id:`in`,header:`Tokens in`,numeric:!0,cell:e=>x9.format(e.tokensIn)},{id:`out`,header:`Tokens out`,numeric:!0,cell:e=>x9.format(e.tokensOut)}];function HSe({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(q1,{split:`even`,children:[(0,h.jsxs)(J1,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(U2,{children:KSe(e).map(e=>(0,h.jsx)(W2,{label:e.label,value:e.value},e.label))}),t?(0,h.jsx)(`p`,{className:`m-0 mt-3 text-body text-ink-2`,children:`Numbers appear after your first run.`}):null]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Machine ID ${e.machineId??`not made yet`} · Slopify ${e.appVersion}`})]}),(0,h.jsx)(J1,{children:(0,h.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,h.jsx)(K2,{caption:`Tokens by stage`,columns:VSe,rows:e.byStage,rowKey:e=>`${e.stage}/${e.provider}/${e.model??``}`,empty:`No stages have run yet.`,className:`min-w-[480px] [&_td]:pr-4 [&_th]:pr-4`})})})]})}function USe(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var x9=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),WSe=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),GSe=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function KSe(e){let t=e.counters;return[{label:`Videos made`,value:x9.format(t.videosMade)},{label:`Hours of audio`,value:WSe.format(t.audioSeconds/3600)},{label:`Images made`,value:x9.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?x9.format(t.tokensUsed):GSe.format(t.tokensUsed)},{label:`Projects`,value:x9.format(t.projects)}]}function qSe({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 JSe(){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))})}var S9=[`storage-usage`],YSe=[S9,B.projects,[`project`],B.usage,B.documentThemes,vH,[`play-drafts`],B.settings,B.providers,B.voices,B.prompts,B.entries,B.staging,Aq,cN,[`provider-models`]];async function XSe(e){await Promise.all(YSe.map(t=>e.invalidateQueries({queryKey:t})))}var C9=30,ZSe=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function QSe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=C9?void 0:`The silence gap is a whole number of seconds between 0 and ${String(C9)}.`}var w9=[{id:`general`,label:`General`,meta:`How Slopify starts on this computer.`},{id:`providers`,label:`Providers`,meta:`Keys stay on this machine and go only to their provider. Readiness is checked again before each run.`},{id:`voices`,label:`Voices`,meta:`A wrong voice ID shows up when the audio stage uses it.`},{id:`models`,label:`Models`,meta:`New models, prices and retirements, checked once a day.`},{id:`playback`,label:`Playback & appearance`,meta:`How narration is paced and how Slopify looks.`},{id:`notifications`,label:`Notifications`,meta:`When a run finishes, fails, waits for you, or a review needs a decision.`},{id:`channel-links`,label:`Channel links`,meta:`The links a YouTube description's {{Name}} placeholders fill from.`},{id:`studio`,label:`YouTube Studio`,meta:`The playlist upload packs name, and the Studio extension's pairing.`},{id:`storage`,label:`Backup & storage`,meta:`Export everything, import a backup, and see what uses disk space.`},{id:`backups`,label:`Backups`,meta:`A daily copy of everything, in a folder you choose.`},{id:`trash`,label:`Trash`,meta:`Deleted projects, prompts, templates and schedules, kept for 30 days.`},{id:`usage`,label:`Usage`,meta:`This machine only. The same counters, anonymised, feed slopify.stream.`},{id:`patch-notes`,label:`Patch notes`,meta:`What changed in each version of Slopify.`},{id:`about`,label:`About`,meta:`Free and open source, running on your machine with your own keys.`}];function $Se(e){return w9.find(t=>t.id===e)?.id??`providers`}function eCe(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 tCe({section:e=`providers`,note:t,onSection:n=()=>{},onNote:r=()=>{}}){let{api:i}=z(),a=_(),o=Iy(),s=Q7(),c=h9(),l=w9.find(t=>t.id===e)??w9[0];return Ox({id:`settings.check-providers`,title:`Check all providers`,group:`Settings`,keywords:[`health`,`keys`,`signed in`],run:()=>{n(`providers`),s.mutate()}}),Ox({id:`settings.back-up-now`,title:`Back up now`,group:`Settings`,keywords:[`backup`],run:()=>{n(`backups`),c.mutate(void 0,{onError:e=>{o(`The backup didn't start: ${e.message} Open Settings → Backups to see its state.`,`error`)}})}}),Ox({id:`settings.download-diagnostics`,title:`Download diagnostics`,group:`Settings`,keywords:[`support`,`bug report`],run:()=>{eCe(i.origin)}}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{crumb:`Settings`,title:l.label,meta:l.meta,actions:(0,h.jsxs)(h.Fragment,{children:[e===`providers`?(0,h.jsx)(R,{disabled:s.isPending,onClick:()=>s.mutate(),children:s.isPending?`Checking…`:`Check all`}):null,(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsxs)(SS,{variant:`secondary`,href:`${i.origin}/api/diagnostics`,download:`slopify-diagnostics.json`,children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,strokeWidth:1.75}),`Download diagnostics`]}),(0,h.jsx)(V,{id:`settings.diagnostics`})]})]})}),(0,h.jsx)(Cq,{sections:(0,h.jsx)(Q6,{label:`Settings sections`,children:w9.map(t=>(0,h.jsx)($6,{current:t.id===e,onClick:()=>n(t.id),className:`whitespace-nowrap max-md:w-auto`,children:t.label},t.id))}),children:(0,h.jsxs)(`section`,{"aria-label":l.label,className:`flex min-w-0 flex-col gap-10`,children:[e===`providers`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R3,{}),(0,h.jsx)(nSe,{}),(0,h.jsx)(Kxe,{run:s})]}):null,e===`general`?(0,h.jsx)(qb,{}):null,e===`voices`?(0,h.jsx)(sSe,{}):null,e===`models`?(0,h.jsx)(Bxe,{}):null,e===`playback`?(0,h.jsx)(aCe,{}):null,e===`notifications`?(0,h.jsx)(dSe,{}):null,e===`channel-links`?(0,h.jsx)(gpe,{}):null,e===`studio`?(0,h.jsx)(epe,{}):null,e===`storage`?(0,h.jsx)(zSe,{usageQueryKey:S9}):null,e===`storage`?(0,h.jsx)(nCe,{}):null,e===`storage`?(0,h.jsx)(hSe,{}):null,e===`backups`?(0,h.jsx)(FSe,{}):null,e===`trash`?(0,h.jsx)(DSe,{}):null,e===`usage`?(0,h.jsx)(BSe,{}):null,e===`patch-notes`?(0,h.jsx)(vSe,{note:t,onNote:r}):null,e===`about`?(0,h.jsx)(MSe,{onWhatsNew:()=>{a.fetchQuery(mI(i)).then(e=>r(e.current??void 0),e=>{o(`The patch notes did not open: ${e instanceof Error?e.message:String(e)} Open Settings → Patch notes to try again.`,`error`)})}}):null]})})]})}var T9=`The backup wasn't imported. Check it is a file made with Export everything (.tar) or Export backup (.zip), then try again.`;function nCe(){let{api:e}=z(),t=_(),n=P({queryKey:S9,queryFn:()=>Fo(e),staleTime:3e4}),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)({phase:`idle`}),[s,c]=(0,m.useState)({phase:`idle`}),[l,u]=(0,m.useState)(null),d=Iy(),[f,p]=(0,m.useState)(null);async function g(){p(null),o({phase:`preparing`});try{let t=await Eo(e);if(!t.ready){o({phase:`idle`}),p(t.detail??`The backup can't be made right now. Try again in a moment.`);return}o({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){o({phase:`idle`}),p(e instanceof Error?e.message:`The backup couldn't be prepared. Try again in a moment.`)}}async function v(n){let r=n.name.toLowerCase().endsWith(`.zip`)||n.type===`application/zip`;if(n.size===0||r&&n.size>104857600){p(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.`);return}i(!0),p(null),u(null),c({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)=>{c(e>=t?{phase:`importing`}:{phase:`uploading`,sent:e,total:t})}),a=await i.json();if(!i.ok)throw Error(a.detail??T9);a.projects===void 0?d(`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`):(u(a),d(`Backup imported.`,`success`)),await XSe(t)}catch(e){p(e instanceof Error?e.message:T9)}finally{c({phase:`idle`}),i(!1)}}async function y(){i(!0),p(null);try{let n=await e.fetch(`${e.origin}/api/storage/cleanup`,{method:`POST`}),r=await n.json();if(!n.ok)throw Error(`Clean orphan files didn't finish. Try again in a moment.`);d(`Removed ${r.orphanFiles??0} orphan project file(s) and ${r.stagedFiles??0} stale staged file(s).`,`success`),await t.invalidateQueries({queryKey:S9})}catch(e){p(e instanceof Error?e.message:`Clean orphan files didn't finish. Try again in a moment.`)}finally{i(!1)}}Ox({id:`settings.export-everything`,title:`Export everything`,group:`Settings`,context:`Backup & storage`,keywords:[`backup`,`download`],run:()=>{!r&&a.phase!==`preparing`&&g()}});let b=r||a.phase===`preparing`,x=(0,m.useRef)(null);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(H,{title:`Export and import`,info:`settings.storage.export`,children:[(0,h.jsx)(R,{disabled:b,onClick:()=>void g(),children:`Export everything`}),(0,h.jsx)(R,{disabled:b,onClick:()=>x.current?.click(),children:`Import a backup`}),(0,h.jsx)(`input`,{ref:x,className:`sr-only`,type:`file`,tabIndex:-1,"aria-label":`Import a backup`,accept:`.tar,application/x-tar,.zip,application/zip`,disabled:b,onChange:e=>{let t=e.target.files?.[0];t&&v(t),e.target.value=``}}),(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(R,{variant:`quiet`,disabled:b,onClick:()=>void y(),children:`Clean orphan files`}),(0,h.jsx)(V,{id:`settings.storage.clean`})]})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`p`,{className:`m-0`,children:`Provider keys are never included in a backup. After importing, enter them again in Settings → Providers.`}),a.phase===`preparing`?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink`,children:`Preparing the backup…`}):null,a.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 `,Y5(a.bytes),` (`,a.projects,` project`,a.projects===1?``:`s`,`). Your browser's downloads show its progress; keep Slopify running until it finishes.`]}),(0,h.jsx)(R,{variant:`quiet`,size:`small`,onClick:()=>o({phase:`idle`}),children:`Dismiss`})]}):null,s.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: `,Y5(s.sent),` of`,` `,Y5(s.total)]}),(0,h.jsx)(G2,{label:`Backup upload`,value:s.total===0?0:s.sent/s.total})]}):null,s.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,f?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-danger`,children:f}):null]})]}),l?(0,h.jsx)(iCe,{result:l,onDismiss:()=>u(null)}):null,(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{title:`Disk space`,info:`settings.storage.disk`,meta:n.data?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`font-semibold text-ink`,children:[Y5(n.data.data),` stored`]}),(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[` `,`· `,Y5(Math.max(0,n.data.projects-n.data.trash.bytes)),` project files · `,Y5(n.data.staging),` staged files`,n.data.trash.projects>0?` · ${Y5(n.data.trash.bytes)} in the trash (${rCe(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)(Dye,{projects:n.data.byProject,queryKey:[...S9]}):null]})]})}function rCe(e){return e===1?`1 deleted project`:`${String(e)} deleted projects`}function E9(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 iCe({result:e,onDismiss:t}){let n=[e.projects.imported.length>0?`Projects: ${e.projects.imported.length} added (${Y5(e.files.bytes)} of files).`:`Projects: none added.`,E9(`Prompts`,e.prompts),E9(`Intros and outros`,e.entries),E9(`Channels`,e.channels),E9(`Cast members`,e.cast),E9(`Episode memories`,e.episodeMemories),E9(`Existing videos`,e.channelVideos),E9(`Document themes`,e.documentThemes),E9(`Templates`,e.templates),E9(`Schedules`,e.schedules),e.schedules.paused>0?`${e.schedules.paused} schedule(s) arrived paused so two installs never run them both; resume them on the Schedules screen.`:null,E9(`Voices`,e.voices),E9(`Play drafts`,e.drafts),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.`,`Provider keys are not in backups: enter them in Settings → Providers.`].filter(e=>e!==null);return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(H,{as:`h3`,title:`Imported the backup from ${e.backup.createdAt.slice(0,10)}`,children:(0,h.jsx)(R,{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:e},e)),e.projects.skipped.map(e=>(0,h.jsxs)(`li`,{className:`py-0.5`,children:[`Skipped “`,e.title,`”: `,e.reason]},e.id))]})]})}function aCe(){let{api:e}=z(),t=_(),n=P(mb(e)),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=F({mutationFn:t=>Qo(e,t),onMutate:e=>{let n=t.getQueryData(B.settings);return t.setQueryData(B.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(B.settings,r.previous)},onSuccess:e=>{t.setQueryData(B.settings,e)}});if((0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>{o(!1)},q2);return()=>{clearTimeout(e)}},[a]),n.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:n.error.message});if(n.data===void 0)return(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`})]});let c=n.data,l=r??String(c.silenceGapSeconds),u=QSe(l);return(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(dV,{label:`Silence between segments`,tip:`settings.playback.silence-gap`,help:`Seconds of quiet between narrated segments.`,error:u??s.error?.message,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(pV,{type:`number`,inputMode:`numeric`,min:0,max:C9,step:1,className:`w-[88px] tabular-nums`,value:l,"aria-invalid":u!==void 0,onChange:e=>{i(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`seconds`}),(0,h.jsx)(R,{variant:`primary`,disabled:u!==void 0||s.isPending,onClick:()=>{o(!1),s.mutate({...c,silenceGapSeconds:Number(l.trim())},{onSuccess:()=>{i(void 0),o(!0)}})},children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(Y2,{}):null})]})}),(0,h.jsxs)(`div`,{className:`sl-field`,...Ib,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,h.jsx)(`span`,{className:`sl-field__label`,children:`Appearance`}),(0,h.jsx)(V,{id:`settings.appearance`,className:`-my-1`})]}),(0,h.jsx)(Rb,{label:`Appearance`,value:c.appearance,options:ZSe,className:`self-start`,onChange:e=>{s.mutate({...c,appearance:e})}})]}),(0,h.jsx)(`div`,{className:`md:col-span-2`,children:(0,h.jsx)(D6,{value:c.loudness??nk,switchLabel:`Level the volume for new runs`,switchTip:`settings.loudness`,onChange:e=>{s.mutate({...c,loudness:e})}})})]})}function oCe({open:e,onClose:t,onInstalled:n}){let{api:r}=z(),i=_(),a=P({queryKey:By,queryFn:()=>Wy(r),enabled:e}),o=F({mutationFn:e=>Ky(r,e),onSuccess:()=>n(),onSettled:()=>i.invalidateQueries({queryKey:By})});return(0,h.jsxs)(XP,{open:e,title:`Add a starter pack`,onClose:t,footer:(0,h.jsx)(G1,{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 pack was already added.`)}),children:[(0,h.jsxs)(`p`,{className:`mb-4 flex items-center gap-1 text-small text-ink-2`,children:[`Prompts, a suggested voice and a template for one kind of channel.`,(0,h.jsx)(V,{id:`welcome.packs`})]}),(0,h.jsxs)(oU,{label:`Starter packs`,className:`[&_.sl-row__meta]:whitespace-normal`,children:[(a.data?.packs??[]).map(e=>(0,h.jsx)(sU,{title:e.name,meta:e.summary,actions:(0,h.jsx)(R,{disabled:e.installed||o.isPending,onClick:()=>o.mutate(e.id),children:e.installed?`Added`:`Add pack`})},e.id)),a.data===void 0?(0,h.jsx)(sU,{title:`Loading packs…`}):null]})]})}function sCe({template:e}){let{api:t}=z(),n=P({queryKey:[...Aq,e.id,e.version],queryFn:async()=>{let n=await Iq(t,e.id);if(!n.ok)throw Error(n.message);return n.value}});if(n.error)return(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The keywords of `,e.name,` didn't load. `,n.error.message,` Press Keywords again.`]});if(!n.data)return(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`Reading the keywords…`});let{form:r,librarySnapshot:i}=n.data.document,a=c0({form:r,prompts:i?.prompts??[],entries:i?.entries??[]}),o=L3(r.title),s=[...new Set([...a.keys(),...Object.keys(r.values)])];return(0,h.jsx)(u0,{keywords:s.map(e=>({name:e,value:r.values[e]??``,feeds:a.get(e)??[],topic:o.includes(e)})),empty:`No keywords: the prompts and the title name none.`})}async function cCe(e,t,n,r){let i=await Rq(e,t.id,{baseVersion:t.version,mutationId:r,...n});if(!i.ok)throw Error(i.message);return i.value}function lCe({template:e}){return e===void 0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`Pick a template to see the keywords it fills.`}):(0,h.jsxs)(`section`,{"aria-label":`Keywords of ${e.name}`,className:`flex flex-col gap-4`,children:[(0,h.jsx)(H,{title:e.name,as:`h3`,info:`templates.edit`,className:`pb-0`}),(0,h.jsx)(sCe,{template:e}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`To change the settings, press Use in Play, change the draft, then Save a setup.`})]})}function uCe({template:e,onClose:t}){let{api:n}=z(),r=_(),i=Array.from({length:e.version},(t,n)=>e.version-n),a=at({queries:i.map(t=>({queryKey:[...Aq,e.id,`version`,t],queryFn:async()=>{let r=await Iq(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=Iy(),f=F({mutationFn:t=>cCe(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:Aq}),t()}}),p=a.find(e=>e.error!==null)?.error;return(0,h.jsx)(XP,{open:!0,title:`History 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 History and open it again.`}):null,(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(H,{title:`Versions`,as:`h3`,info:`templates.history`}),(0,h.jsx)(oU,{label:`Versions of ${e.name}`,children:i.map((t,n)=>{let r=a[n]?.data;return(0,h.jsx)(sU,{title:`Version ${String(t)}`,selected:t===s,onSelect:()=>c(t),meta:r===void 0?`Loading…`:`${r.name} · ${k4(r.updatedAt)}`,actions:t===e.version?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Current`}):(0,h.jsx)(R,{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)(G1,{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)(H,{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)(S4,{before:D9(l),after:D9(o),beforeLabel:`Version ${String(l.version)}`,afterLabel:`Version ${String(o.version)} (current)`})]})]})]})})}function D9(e){return JSON.stringify(e.document,null,1).split(`
|
|
309
309
|
`).map(e=>e.trim()).filter(e=>!/^[[\]{}],?$/u.test(e)).join(`
|
|
310
310
|
`)}function dCe({onApplied:e,beforeApply:t,getGeneration:n,blocked:r=!1}){let{api:i}=z(),a=_(),o=P(Fq(i)),s=P(ax(i)),[c,l]=(0,m.useState)(``),u=o.data?.filter(e=>c===``||$1(e)===c),d=e=>s.data?.find(t=>t.id===$1(e))?.name,f=P({queryKey:[`play-drafts`],queryFn:async()=>{let e=await QM(i);if(!e.ok)throw Error(e.message);return e.value.drafts}}),[p,g]=(0,m.useState)(``),[v,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(null),E=Iy(),[D,O]=(0,m.useState)(!1),[k,A]=(0,m.useState)(!1),[j,ee]=(0,m.useState)(null),[te,M]=(0,m.useState)(null),[ne,N]=(0,m.useState)(null),re=(0,m.useRef)(new Map),ie=(0,m.useRef)(!1),ae=(0,m.useRef)(null),oe=(0,m.useRef)(new Map),se=(0,m.useRef)(!0);(0,m.useEffect)(()=>(se.current=!0,()=>{se.current=!1}),[]);async function ce(e){if(!ie.current){ie.current=!0,C(!0),T(null);try{await e()}catch(e){T(e instanceof Error?e.message:`That didn't finish. Try again.`)}finally{ie.current=!1,C(!1)}}}async function le(){let e=await eN(i,p);if(!e.ok)throw Error(e.message);let t=JSON.stringify([p,e.value.draft.version,v.trim(),b]);ae.current?.key!==t&&(ae.current={key:t,id:crypto.randomUUID()});let n=e.value.draft.document,r=o.data?.find(e=>e.id===n.templateSource?.id),s=b||n.channelId||(r?$1(r):void 0),c=await Lq(i,{id:ae.current.id,name:v.trim(),document:s===void 0?n:{...n,channelId:s}});if(!c.ok)throw ae.current=null,Error(c.message);ae.current=null,y(``),O(!1),E(`Template saved.`,`success`),await a.invalidateQueries({queryKey:Aq})}async function ue(o){let s=n?.();if(r||t&&!await t())throw Error(`Save or discard the draft open in Play first, then apply the template again.`);if(!se.current||s!==void 0&&s!==n?.())return;let c=`${o.id}:${o.version}`,l=oe.current.get(c);l||(l=crypto.randomUUID(),oe.current.set(c,l));let u=await Uq(i,o,l);if(!u.ok)throw oe.current.delete(c),Error(u.message);if(!(!se.current||s!==void 0&&s!==n?.())&&(await a.invalidateQueries({queryKey:[`play-drafts`]}),!(!se.current||s!==void 0&&s!==n?.()))){if(await e(u.value.draft.id,()=>se.current)!==!1)oe.current.delete(c);else throw Error(`The template's draft was created but didn't open. Press Use in Play again to open it.`)}}async function de(e){let t=`${e.id}:${e.version}`,n=re.current.get(t);n||(n=crypto.randomUUID(),re.current.set(t,n));let r=await Iq(i,e.id);if(!r.ok)throw Error(r.message);let o=await Lq(i,{id:n,name:`${e.name} copy`,document:r.value.document});if(!o.ok)throw Error(o.message);re.current.delete(t),E(`Duplicated as ${o.value.name}.`,`success`),await a.invalidateQueries({queryKey:Aq})}async function fe(){if(!j)return;let e=j.id,t=await Vq(i,j);if(!t.ok)throw Error(t.message);ee(null),await a.cancelQueries({queryKey:Aq}),a.setQueryData(Aq,t=>t?.filter(t=>t.id!==e)),E(`Template moved to the trash. Restore it in Settings → Trash within 30 days.`,`success`),await a.invalidateQueries({queryKey:Aq})}Ox({id:`library.save-template`,title:`Save a setup as a template`,group:`Library`,keywords:[`template`,`new template`,`play draft`],run:()=>O(!0)});let pe=w&&!j?{tone:`error`,text:w}:r?{tone:`warning`,text:`A run is still starting in Play. Wait for it to finish (or press Check Start result there), then apply a template.`}:o.error?{tone:`error`,text:o.error.message}:o.isPending?{tone:`info`,text:`Loading templates…`}:void 0;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(oCe,{open:k,onClose:()=>A(!1),onInstalled:()=>void a.invalidateQueries({queryKey:Fq(i).queryKey})}),(0,h.jsxs)(R4,{action:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(R,{variant:`secondary`,onClick:()=>A(!0),"aria-expanded":k,children:`Add pack`}),(0,h.jsx)(V,{id:`welcome.packs`,label:`Add pack`})]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(R,{variant:`primary`,onClick:()=>O(!0),"aria-expanded":D,children:`Save a setup`}),(0,h.jsx)(V,{id:`templates.save`,label:`Save a setup`})]})]}),children:[(0,h.jsxs)(`span`,{className:`flex w-full items-center gap-1 sm:w-auto`,...Ib,children:[(0,h.jsxs)(hV,{"aria-label":`Show templates of`,value:c,className:`w-full sm:w-56`,onChange:e=>l(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`All channels`}),(s.data??[]).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,h.jsx)(V,{id:`templates.show-channel`})]}),(0,h.jsxs)(`p`,{className:`m-0 flex items-center gap-1 text-small text-ink-2`,children:[`Reuse a Play setup and its checkpoint choices. Use in Play creates a fresh draft to review.`,(0,h.jsx)(V,{id:`templates.apply`,label:`Use in Play`})]})]}),(0,h.jsxs)(`div`,{className:`mb-2 flex min-h-8 flex-wrap items-center gap-3`,children:[(0,h.jsx)(G1,{tone:pe?.tone??`info`,children:pe?.text}),o.error?(0,h.jsx)(R,{size:`small`,onClick:()=>void o.refetch(),children:`Reload templates`}):null,(0,h.jsx)(R,{variant:`quiet`,size:`small`,disabled:S||o.isFetching,onClick:()=>void o.refetch(),children:`Refresh templates`})]}),o.data?.length===0?(0,h.jsx)(Q1,{title:`No templates yet`,children:`Use Save a setup to keep a Play draft for reuse.`}):null,o.data?.length&&u?.length===0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`No templates in this channel.`}):null,o.isPending&&!o.error?(0,h.jsx)(F4,{label:`Project templates`}):null,u?.length?(0,h.jsx)(wq,{className:N4,list:(0,h.jsx)(oU,{label:`Project templates`,children:u.map(e=>(0,h.jsxs)(m.Fragment,{children:[(0,h.jsx)(sU,{className:`max-md:grid-cols-1`,title:(0,h.jsx)(K4,{name:e.name,maxLength:120,onSelect:()=>M(e.id),onRename:async t=>{let n=await zq(i,e.id,t);return await a.invalidateQueries({queryKey:Aq}),n}}),selected:e.id===te,meta:(0,h.jsxs)(h.Fragment,{children:[d(e)===void 0?``:`${d(e)} · `,`Version `,e.version,` · updated`,` `,(0,h.jsx)(`time`,{dateTime:e.updatedAt,children:e.updatedAt.slice(0,10)})]}),actions:(0,h.jsx)(L4,{name:e.name,edit:(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Edit ${e.name}`,onClick:()=>M(e.id),children:`Edit`}),duplicate:(0,h.jsx)(R,{variant:`quiet`,size:`small`,"aria-label":`Duplicate ${e.name}`,disabled:S,disabledReason:`Working on the last press`,onClick:()=>void ce(()=>de(e)),children:`Duplicate`}),play:{run:()=>void ce(()=>ue(e)),blocked:r?`A run is still starting in Play. Wait for it, then use the template.`:S?`Working on the last press`:void 0},onHistory:()=>N(e),onDelete:()=>{ee(e),T(null)}})}),(0,h.jsx)(t0,{kind:`template`,id:e.id,name:e.name})]},e.id))}),detail:(0,h.jsx)(lCe,{template:u.find(e=>e.id===te)})}):null,(0,h.jsxs)(XP,{open:D,title:`Save a setup`,width:`narrow`,onClose:()=>O(!1),footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(G1,{tone:w?`error`:`info`,children:w??(S?`Saving…`:void 0)}),(0,h.jsx)(R,{type:`submit`,form:`save-template-form`,variant:`primary`,disabled:S||!p||!v.trim(),children:`Save template`})]}),children:[(0,h.jsxs)(`p`,{className:`m-0 mb-4 text-small text-ink-2`,children:[`Choose a saved Play draft, or`,` `,(0,h.jsx)(ma,{to:`/play`,className:`text-accent-ink underline`,children:`open Play`}),` `,`to prepare one.`]}),(0,h.jsx)(`p`,{className:`mb-4 text-small text-ink-2`,children:`A template keeps the settings, not one video's topic.`}),(0,h.jsxs)(`form`,{id:`save-template-form`,"aria-label":`Save a setup`,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),p&&v.trim()&&ce(le)},children:[(0,h.jsx)(dV,{label:`Saved Play draft`,tip:`templates.save.draft`,help:f.isPending?`Loading saved drafts…`:f.data?.length===0?`No saved drafts yet.`:void 0,children:(0,h.jsxs)(hV,{value:p,required:!0,disabled:S,onChange:e=>g(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`Choose a draft`}),f.data?.filter(e=>e.readable).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.title||`Untitled draft`},e.id))]})}),f.error?(0,h.jsx)(vI,{tone:`danger`,title:`The saved drafts couldn't be loaded.`,actions:(0,h.jsx)(R,{size:`small`,onClick:()=>void f.refetch(),children:`Reload drafts`}),children:f.error.message}):null,(0,h.jsx)(dV,{label:`Template name`,id:`template-name`,tip:`templates.save.name`,children:(0,h.jsx)(pV,{value:v,required:!0,maxLength:120,disabled:S,onChange:e=>y(e.target.value)})}),(0,h.jsx)(dV,{label:`Channel`,id:`template-channel`,tip:`templates.save.channel`,children:(0,h.jsxs)(hV,{value:b,disabled:S,onChange:e=>x(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`The draft's channel`}),(s.data??[]).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]})]}),ne===null?null:(0,h.jsx)(uCe,{template:ne,onClose:()=>N(null)},`${ne.id}:${String(ne.version)}`),(0,h.jsx)(zy,{open:j!==null,title:`Delete ${j?.name??`template`}?`,consequence:w??`Moves it to the trash for 30 days (Settings → Trash). Existing projects and drafts keep their setup.`,confirmLabel:`Delete template`,pending:S,onConfirm:()=>void ce(fe),onCancel:()=>{S||ee(null)}})]})}function fCe({page:e,anchor:t,words:n}){let{api:r}=z(),i=P(CB(r)),a=P(wB(r,e)),o=Xi(),[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)(()=>Db(a.data??``),[a.data]),p=(0,m.useMemo)(()=>a.data===void 0?``:Eb(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:kb(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)(Sq,{crumb:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{children:`Help`}),(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`›`}),(0,h.jsx)(ma,{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}),(0,h.jsx)(Cq,{className:`sl-workspace--tutorials`,sections:(0,h.jsx)(pCe,{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=Ob(n);if(r!==void 0){e.preventDefault(),o({to:`/help/tutorials/$page`,params:{page:r.page},...r.anchor===void 0?{}:{hash:r.anchor}});return}/^https?:/.test(n)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))},children:[(0,h.jsx)(pB,{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)(vI,{tone:`danger`,title:`This tutorial did not load`,actions:(0,h.jsx)(R,{onClick:()=>void a.refetch(),variant:`secondary`,children:`Try again`}),children:`${a.error.message} Press Try again, or pick another page on the left.`})})]})}function pCe({index:e,page:t,onOpenHit:n}){let{api:r}=z(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(``),c=(0,m.useRef)(null),l=(0,m.useId)();kx(c,`the tutorials`),(0,m.useEffect)(()=>{let e=setTimeout(()=>s(i.trim()),200);return()=>clearTimeout(e)},[i]);let u=P(TB(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)(Gc,{"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)(O9,{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)(O9,{id:e.id,title:e.title,current:t},e.id))]},e.title))]}):(0,h.jsx)(mCe,{query:o,hits:u.data?.hits,error:u.error?.message})]})}function O9({id:e,title:t,current:n}){return(0,h.jsx)(ma,{to:`/help/tutorials/$page`,params:{page:e},"aria-current":e===n?`page`:void 0,className:`sl-tutorials-nav__link`,children:t})}function mCe({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)(ma,{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 hCe=[{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`}],k9=[{id:`found`,label:`1 · What you have`},{id:`style`,label:`2 · Pick a style`},{id:`make`,label:`3 · Make your first short`}];function gCe(e){return e.length<=2?e.join(` or `):`${e.slice(0,-1).join(`, `)} or ${e.at(-1)??``}`}function _Ce(e){return e===void 0?{ready:!1,text:`Looking for a voice…`}:e.keyed===null?e.system.available?{ready:!0,text:`Narration uses your computer's built-in voice${e.system.engine===null?``:` (${e.system.engine})`}; add an ElevenLabs or OpenAI key later for a better one.`}:{ready:!1,text:e.system.issue??`No voice can narrate yet. Add an ElevenLabs or OpenAI key in Settings → Providers.`}:{ready:!0,text:`Narration uses your ${e.keyed} voice key.`}}function vCe(){let{api:e}=z(),t=_(),n=Xi(),r=P({queryKey:By,queryFn:()=>Wy(e)}),[i,a]=(0,m.useState)(`found`),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(void 0),f=(0,m.useRef)(void 0),p=F({mutationFn:()=>Gy(e),onSuccess:async()=>{await t.invalidateQueries({queryKey:By}),await n({to:`/`})}}),g=F({mutationFn:t=>Ky(e,t),onSettled:()=>t.invalidateQueries({queryKey:By})}),v=F({mutationFn:()=>(f.current??=crypto.randomUUID(),qy(e,{topic:o,requestId:f.current,...c===``?{}:{packId:c}})),onSuccess:async({projectId:e})=>{f.current=void 0,d(e),await t.invalidateQueries({queryKey:B.projects}),await t.invalidateQueries({queryKey:B.voices})}}),y=e=>{e.preventDefault(),o.trim()!==``&&v.mutate()},b=r.data,x=b?.clis.filter(e=>e.ready)??[],S=_Ce(b?.voice),C=c===``?`General`:b?.packs.find(e=>e.id===c)?.name??c,w=v.error?{tone:`error`,text:v.error.message}:g.error?{tone:`error`,text:g.error.message}:p.error?{tone:`error`,text:p.error.message}:v.isPending?{tone:`info`,text:`Starting your short…`}:void 0,T=k9.findIndex(e=>e.id===i),E=k9[T+1],D=k9[T-1];return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Sq,{title:`Welcome to Slopify`,meta:`Make a video from a topic, with the tools already on this computer.`,actions:(0,h.jsx)(R,{variant:`quiet`,disabled:p.isPending,onClick:()=>p.mutate(),children:u===void 0?`Skip`:`Done`})}),r.error?(0,h.jsx)(vI,{tone:`danger`,title:`Could not read what this computer has`,className:`mb-6`,children:r.error.message}):null,(0,h.jsx)(X1,{items:k9.map(e=>({id:e.id,label:e.label})),value:i,onChange:a,label:`First-run steps`,idPrefix:`welcome`,className:`mb-6`}),(0,h.jsxs)(Z1,{idPrefix:`welcome`,id:`found`,active:i===`found`,children:[(0,h.jsx)(H,{title:`Found on this computer`,info:`welcome.found`}),(0,h.jsxs)(oU,{label:`Tools found on this computer`,className:`mb-4`,children:[(b?.clis??[]).map(e=>(0,h.jsx)(sU,{title:e.name,actions:(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:e.ready?`Ready${e.version===null?``:` · ${e.version}`}${e.draws?` · writes and draws`:` · writes`}`:e.installed?e.issue??`Installed, not usable yet`:`Not found`})},e.id)),b===void 0?(0,h.jsx)(sU,{title:`Looking for installed tools…`}):null]}),b!==void 0&&x.length>0?(0,h.jsx)(`p`,{className:`mb-6 text-small text-ink-2`,children:`You can make a video now: no API keys are needed for ${gCe([`the text`,...x.some(e=>e.draws)?[`the images`]:[],...S.ready&&b.voice.keyed===null?[`the narration`]:[]])}.`}):null,b!==void 0&&x.length===0?(0,h.jsx)(vI,{tone:`waiting`,className:`mb-6`,title:`Nothing on this computer can write the script yet.`,actions:(0,h.jsx)(bS,{to:`/settings`,search:{section:`providers`},children:`Open Settings → Providers`}),children:`Install Claude Code, Codex or Gemini CLI and sign in to it, then press Check again; or add an OpenRouter key in Settings → Providers.`}):null,(0,h.jsx)(H,{title:`Narration voice`,info:`welcome.voice`}),b===void 0?(0,h.jsx)(oU,{label:`Narration voice`,className:`mb-6`,children:(0,h.jsx)(sU,{title:`Looking for a voice…`})}):(0,h.jsx)(A9,{voice:S,checking:r.isFetching,onCheck:()=>void r.refetch()})]}),(0,h.jsxs)(Z1,{idPrefix:`welcome`,id:`style`,active:i===`style`,children:[(0,h.jsx)(H,{title:`Pick a style`,info:`welcome.pack`}),(0,h.jsx)(oU,{label:`Styles`,className:`mb-3 [&_.sl-row__meta]:whitespace-normal`,children:[{id:``,name:`General`,summary:`A neutral explainer style.`,installed:!1,library:!1},...(b?.packs??[]).map(e=>({...e,library:!0}))].map(e=>(0,h.jsx)(sU,{title:e.name,meta:e.summary,selected:c===e.id,actions:(0,h.jsxs)(h.Fragment,{children:[e.library?(0,h.jsx)(R,{variant:`quiet`,disabled:e.installed||g.isPending,"aria-label":e.installed?`${e.name} is in your library`:`Add ${e.name} to library`,onClick:()=>g.mutate(e.id),children:e.installed?`In your library`:`Add to library`}):null,(0,h.jsx)(R,{variant:c===e.id?`primary`:`secondary`,"aria-pressed":c===e.id,"aria-label":`Use ${e.name}`,onClick:()=>l(e.id),children:c===e.id?`Picked`:`Use this style`})]})},e.id===``?`general`:e.id))}),(0,h.jsxs)(`p`,{className:`mb-6 flex items-center gap-1 text-small text-ink-2`,...Ib,children:[`Add to library keeps a pack's prompts and Play template for later videos.`,(0,h.jsx)(V,{id:`welcome.packs`,className:`-my-1`})]})]}),(0,h.jsxs)(Z1,{idPrefix:`welcome`,id:`make`,active:i===`make`,children:[u===void 0?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(H,{title:`Make a 60-second short`,info:`welcome.short`}),(0,h.jsxs)(`p`,{className:`mb-3 text-small text-ink-2`,children:[`Style: ${C}. `,S.text]}),S.ready||b===void 0?null:(0,h.jsx)(`div`,{className:`mb-4`,children:(0,h.jsx)(A9,{voice:S,checking:r.isFetching,onCheck:()=>void r.refetch()})}),(0,h.jsxs)(`form`,{onSubmit:y,className:`mb-6 flex flex-wrap items-end gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-[240px] flex-1 flex-col gap-1`,...Ib,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:`welcome-topic`,className:`text-label text-ink-2`,children:`Topic`}),(0,h.jsx)(V,{id:`welcome.topic`,className:`-my-1`})]}),(0,h.jsx)(I3,{id:`welcome-topic`,value:o,maxLength:200,placeholder:`Why the sea glows at night`,onChange:e=>s(e.target.value)})]}),(0,h.jsx)(R,{type:`submit`,variant:`primary`,disabled:o.trim()===``||v.isPending,disabledReason:`Type a topic first.`,children:`Make a 60-second short`})]})]}):(0,h.jsx)(vI,{tone:`info`,className:`mb-6`,title:`Your short is being made.`,actions:(0,h.jsx)(bS,{variant:`primary`,to:`/projects/$projectId`,params:{projectId:u},children:`Watch it being made`}),children:`It usually takes about five minutes. The live view shows each step as it runs; while you wait, look at a sample or set Slopify to start when you log in.`}),(0,h.jsx)(H,{title:`While you wait: the samples`,info:`welcome.samples`}),(0,h.jsx)(oU,{label:`Samples`,className:`mb-6 [&_.sl-row__meta]:whitespace-normal`,children:hCe.map(e=>{let t=b?.samples[e.id]??null;return(0,h.jsx)(sU,{title:e.name,meta:e.summary,actions:t===null?(0,h.jsx)(xS,{to:`/settings`,search:{section:`storage`},children:`Restore samples in Settings`}):(0,h.jsx)(bS,{to:`/projects/$projectId`,params:{projectId:t},className:aU,children:e.action})},e.id)})}),(0,h.jsx)(Yb,{})]}),(0,h.jsxs)(K1,{status:(0,h.jsx)(G1,{tone:w?.tone??`info`,children:w?.text}),children:[(0,h.jsx)(xS,{to:`/play`,children:`Set up a long video instead`}),D===void 0?null:(0,h.jsx)(R,{onClick:()=>a(D.id),children:`Back`}),E===void 0?null:(0,h.jsx)(R,{variant:`primary`,onClick:()=>a(E.id),children:`Next: ${E.label.replace(/^\d · /,``)}`})]})]})}function A9({voice:e,checking:t,onCheck:n}){return e.ready?(0,h.jsx)(oU,{label:`Narration voice`,className:`mb-6 [&_.sl-row__title]:whitespace-normal`,children:(0,h.jsx)(sU,{lead:(0,h.jsx)(wS,{tone:`done`}),title:e.text,actions:(0,h.jsx)(bS,{variant:`quiet`,to:`/settings`,search:{section:`providers`},children:`Add a voice key`})})}):(0,h.jsx)(vI,{tone:`waiting`,className:`mb-6`,title:`No voice can narrate the short yet.`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(bS,{variant:`primary`,to:`/settings`,search:{section:`providers`},children:`Add a voice key`}),(0,h.jsx)(R,{disabled:t,onClick:n,children:t?`Checking…`:`Check again`})]}),children:e.text})}var j9=ya({component:WB}),yCe=_a({getParentRoute:()=>j9,path:`/`,component:she}),M9=_a({getParentRoute:()=>j9,path:`projects`,validateSearch:e=>{let t=Oxe(e.show);return t===void 0?{}:{show:t}},component:bCe});function bCe(){let{show:e}=M9.useSearch();return(0,h.jsx)(jxe,{initialFilter:e??`all`},e??`all`)}var xCe=_a({getParentRoute:()=>j9,path:`welcome`,component:vCe}),SCe=_a({getParentRoute:()=>j9,path:`play`,component:n_e}),N9=_a({getParentRoute:()=>j9,id:`_library`,component:mme}),CCe=_a({getParentRoute:()=>j9,path:`library`,beforeLoad:()=>{throw un({to:`/prompts`,search:{kind:`article`}})}}),wCe=_a({getParentRoute:()=>j9,path:`channels`,component:Gpe}),P9=_a({getParentRoute:()=>j9,path:`channels/$channelId`,validateSearch:e=>e.tab===void 0?{}:{tab:Upe(e.tab)},component:TCe});function TCe(){let{channelId:e}=P9.useParams(),{tab:t}=P9.useSearch(),n=Xi();return(0,h.jsx)(Wpe,{channelId:e,tab:t??`brand`,onTab:t=>{n({to:`/channels/$channelId`,params:{channelId:e},search:{tab:t},replace:!0})}},e)}var ECe=_a({getParentRoute:()=>N9,path:`templates`,component:jCe}),DCe=/^[0-9A-Za-z-]{1,64}$/;function F9(e){return ope(e.tab)===`schedules`?typeof e.schedule==`string`&&DCe.test(e.schedule)?{tab:`schedules`,schedule:e.schedule}:{tab:`schedules`}:{}}var I9=_a({getParentRoute:()=>j9,path:`calendar`,validateSearch:F9,component:ACe}),OCe=_a({getParentRoute:()=>j9,path:`schedules`,beforeLoad:()=>{throw un({to:`/calendar`,search:{tab:`schedules`},replace:!0})}}),kCe=_a({getParentRoute:()=>j9,path:`schedules/$scheduleId`,beforeLoad:({params:e})=>{throw un({to:`/calendar`,search:F9({tab:`schedules`,schedule:e.scheduleId}),replace:!0})}});function ACe(){let e=F9(I9.useSearch()),t=Xi();return(0,h.jsx)(cpe,{tab:e.tab??`weeks`,schedule:e.schedule,onTab:e=>{t({to:`/calendar`,search:e===`schedules`?{tab:`schedules`}:{},replace:!0})},onSchedule:e=>{t({to:`/calendar`,search:{tab:`schedules`,schedule:e},replace:!0})}})}function jCe(){let e=iP(),t=Xi();return(0,h.jsx)(dCe,{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 L9=_a({getParentRoute:()=>j9,path:`projects/$projectId`,component:VCe}),R9=_a({getParentRoute:()=>N9,path:`prompts`,validateSearch:e=>({kind:cV(e.kind)}),component:HCe}),z9=_a({getParentRoute:()=>j9,path:`prompts/new`,validateSearch:e=>{let t=cV(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:UCe}),B9=_a({getParentRoute:()=>j9,path:`prompts/$promptId`,component:WCe}),V9=_a({getParentRoute:()=>N9,path:`entries`,validateSearch:e=>({category:aV(e.category)}),component:GCe}),H9=_a({getParentRoute:()=>j9,path:`entries/new`,validateSearch:e=>{let t=aV(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:KCe}),U9=_a({getParentRoute:()=>j9,path:`entries/$entryId`,component:qCe}),MCe=_a({getParentRoute:()=>N9,path:`narration-aliases`,component:lhe}),NCe=_a({getParentRoute:()=>N9,path:`ab-results`,component:WV}),PCe=_a({getParentRoute:()=>N9,path:`document-themes`,component:gme}),W9=_a({getParentRoute:()=>j9,path:`document-themes/new`,validateSearch:e=>typeof e.from==`string`?{from:e.from}:{},component:JCe}),G9=_a({getParentRoute:()=>j9,path:`document-themes/$themeId`,component:YCe});function FCe(e){let t=e.section===void 0?void 0:$Se(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;return{...t===void 0?{}:{section:t},...n===void 0?{}:{note:n}}}var K9=_a({getParentRoute:()=>j9,path:`settings`,validateSearch:FCe,component:BCe}),q9=_a({getParentRoute:()=>j9,path:`help/tutorials/$page`,validateSearch:e=>typeof e.q==`string`&&e.q.trim()!==``?{q:e.q.slice(0,200)}:{},component:ICe});function ICe(){let{page:e}=q9.useParams(),{q:t}=q9.useSearch(),n=Va({select:e=>e.hash});return(0,h.jsx)(fCe,{page:e,anchor:n===``?void 0:n,words:t})}var LCe=_a({getParentRoute:()=>j9,path:`help`,beforeLoad:()=>{throw un({to:`/help/tutorials/$page`,params:{page:`Home`}})}}),RCe=_a({getParentRoute:()=>j9,path:`help/tutorials`,beforeLoad:()=>{throw un({to:`/help/tutorials/$page`,params:{page:`Home`}})}}),zCe=_a({getParentRoute:()=>j9,path:`usage`,beforeLoad:()=>{throw un({to:`/settings`,search:{section:`usage`}})}});function BCe(){let{section:e,note:t}=K9.useSearch(),n=Xi();return(0,h.jsx)(tCe,{section:e??`providers`,note:t,onSection:e=>{n({to:`/settings`,search:{section:e},replace:!0})},onNote:e=>{n({to:`/settings`,search:{section:`patch-notes`,...e===void 0?{}:{note:e}}})}})}function VCe(){let{projectId:e}=L9.useParams(),t=iP(),n=Xi();return(0,h.jsx)(Sxe,{projectId:e,openDraft:async e=>!await t.flush()||!await t.open(e)?!1:(await n({to:`/play`}),!0)},e)}function HCe(){let{kind:e}=R9.useSearch(),t=Xi(),n=J9();return(0,h.jsx)(Ixe,{kind:e,onKind:e=>{t({to:`/prompts`,search:{kind:e},replace:!0})},onUseInPlay:n.use,playBlocked:n.blocked})}function J9(){let e=iP(),t=Xi();return{blocked:e.review.starting||e.review.uncertain||e.review.created!==null?`Play is starting a run from its draft. Wait for it to start, then try again.`:void 0,use:n=>{let r=VV(e.document,n);e.edit(r.document),t({to:`/play`}).then(()=>e.navigate(r.section,r.field))}}}function UCe(){let{kind:e,from:t}=z9.useSearch(),n=Y9();return(0,h.jsx)(J7,{promptId:void 0,kind:e,from:t,onLeave:n},`${e}:${t??`new`}`)}function WCe(){let{promptId:e}=B9.useParams(),t=Y9();return(0,h.jsx)(J7,{promptId:e,kind:`article`,from:void 0,onLeave:t},e)}function Y9(){let e=Xi();return t=>{e({to:`/prompts`,search:{kind:t}})}}function GCe(){let{category:e}=V9.useSearch(),t=Xi(),n=J9();return(0,h.jsx)(_me,{category:e,onCategory:e=>{t({to:`/entries`,search:{category:e},replace:!0})},onUseInPlay:n.use,playBlocked:n.blocked})}function KCe(){let{category:e,from:t}=H9.useSearch(),n=Z9();return(0,h.jsx)(o3,{entryId:void 0,category:e,from:t,onLeave:n})}function qCe(){let{entryId:e}=U9.useParams(),t=Z9();return(0,h.jsx)(o3,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function JCe(){let{from:e}=W9.useSearch(),t=X9();return(0,h.jsx)(h4,{themeId:void 0,from:e,onLeave:t})}function YCe(){let{themeId:e}=G9.useParams(),t=X9();return(0,h.jsx)(h4,{themeId:e,from:void 0,onLeave:t})}function X9(){let e=Xi();return()=>{e({to:`/document-themes`})}}function Z9(){let e=Xi();return t=>{e({to:`/entries`,search:{category:t}})}}var XCe=j9.addChildren({homeRoute:yCe,projectsRoute:M9,welcomeRoute:xCe,playRoute:SCe,libraryRoute:N9.addChildren({promptsRoute:R9,entriesRoute:V9,templatesRoute:ECe,documentThemesRoute:PCe,narrationAliasesRoute:MCe,abResultsRoute:NCe}),schedulesRoute:OCe,scheduleRoute:kCe,calendarRoute:I9,libraryIndexRoute:CCe,channelsRoute:wCe,channelRoute:P9,projectRoute:L9,newPromptRoute:z9,promptRoute:B9,newEntryRoute:H9,entryRoute:U9,newDocumentThemeRoute:W9,documentThemeRoute:G9,settingsRoute:K9,usageRoute:zCe,helpRoute:LCe,tutorialsIndexRoute:RCe,tutorialsRoute:q9});function ZCe(){return Ia({routeTree:XCe})}function QCe(){let e,t,n=new Set;return{observe:r=>{if(e===void 0){e=r;for(let e of n)e();return}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 $Ce(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 ewe(){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 Q9=/\/events\/projects\/([^/?#]+)/,twe=/\/events\/global(?:[?#]|$)/,nwe=[`running.count`,`staging.progress`,`staging.failed`,`schedule.topics`,`stage.state`,`stage.progress`,`article.delta`,`llm.preview`,`image.landed`,`narration.piece`,`project.state`,`project.updated`,`review.flagged`];function rwe(e){let t=new Set,n=ewe(),r,i=!1,a=(e,t,n)=>{for(let r of e.listeners.get(t)??[])r({data:n})},o=o=>{if(r!==void 0)return;let s=e(o);r=s,s.addEventListener(`open`,()=>{i=!0;for(let e of[...t])for(let t of e.opens)t()});for(let e of nwe)s.addEventListener(e,r=>{let i;try{let t=JSON.parse(r.data);typeof t.projectId==`string`&&(i=t.projectId),(e===`llm.preview`||e===`stage.state`)&&n.observe(t)}catch{return}for(let n of[...t])(n.projectId===void 0||n.projectId===i)&&a(n,e,r.data)})};return s=>{let c=Q9.exec(s)?.[1];if(c===void 0&&!twe.test(s))return e(s);o(c===void 0?s:s.replace(Q9,`/events/global`));let l={projectId:c===void 0?void 0:decodeURIComponent(c),listeners:new Map,opens:new Set};return t.add(l),i&&queueMicrotask(()=>{if(t.has(l)){for(let e of l.opens)e();if(l.projectId!==void 0)for(let e of n.snapshot(l.projectId))a(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:()=>{t.delete(l),t.size===0&&r!==void 0&&(r.close(),r=void 0,i=!1)}}}}function iwe(e){let t=QCe(),n={api:Co(window.location.origin,$Ce(window.fetch.bind(window),t),To(e=>{let n=e.headers.get(`X-Slopify-Version`);n!==null&&t.observe(n)})),openEvents:rwe(e=>new EventSource(e)),version:t};(0,co.createRoot)(e).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:new qe,children:(0,h.jsx)(cte,{deps:n,children:(0,h.jsx)(za,{router:ZCe()})})})}))}var $9=document.getElementById(`root`);if($9===null)throw Error(`index.html carries no #root element for the app to mount on`);iwe($9);export{$2 as t};
|