@gentbajko/slopify 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95,7 +95,7 @@ Error generating stack: `+e.message+`
95
95
 
96
96
  `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Sb,c=!mx.jitless,l=c&&Cb.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?FC([],p,i,f,d,e):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function zC(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!zb(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Wb(e,r,hx())))}),t)}var BC=X(`$ZodUnion`,(e,t)=>{VS.init(e,t),ix(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),ix(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),ix(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),ix(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>hb(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>zC(t,r,e,i)):zC(o,r,e,i)}}),VC=X(`$ZodIntersection`,(e,t)=>{VS.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>UC(e,t,n)):UC(e,i,a)}});function HC(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(wb(e)&&wb(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=HC(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=HC(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function UC(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=HC(t.value,n.value);if(!c.valid){if(zb(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var WC=X(`$ZodEnum`,(e,t)=>{VS.init(e,t);let n=ub(t.entries),r=new Set(n);e._zod.values=r;let i=n.filter(e=>Eb.has(typeof e));e._zod.pattern=RegExp(i.length?`^(${i.map(e=>Db(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),GC=X(`$ZodLiteral`,(e,t)=>{VS.init(e,t);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(t.values.length?`^(${t.values.map(e=>typeof e==`string`?Db(e):e?Db(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),KC=X(`$ZodTransform`,(e,t)=>{VS.init(e,t),e._zod.optin=`optional`,mx.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new px(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new fx;return n.value=i,n}});function qC(e,t){return e.value=t.issues.length?void 0:t.value,e}var JC=X(`$ZodOptional`,(e,t)=>{VS.init(e,t),ix(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,ix(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),ix(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${hb(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>qC(e,t)):qC(e,r)}return t.innerType._zod.run(e,n)}}),YC=X(`$ZodExactOptional`,(e,t)=>{JC.init(e,t),ix(e,`values`,e=>e.def.innerType._zod.values),ix(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),XC=X(`$ZodNullable`,(e,t)=>{VS.init(e,t),ix(e,`optin`,e=>e.def.innerType._zod.optin),ix(e,`optout`,e=>e.def.innerType._zod.optout),ix(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${hb(t.source)}|null)$`):void 0}),ix(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ZC=X(`$ZodDefault`,(e,t)=>{VS.init(e,t),e._zod.optin=`defaulted`,ix(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>QC(e,t)):QC(r,t)}});function QC(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var $C=X(`$ZodPrefault`,(e,t)=>{VS.init(e,t),e._zod.optin=`defaulted`,ix(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),ew=X(`$ZodNonOptional`,(e,t)=>{VS.init(e,t),ix(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>tw(t,e)):tw(i,e)}});function tw(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function nw(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Wb(e,r,hx()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var rw=X(`$ZodCatch`,(e,t)=>{VS.init(e,t),ix(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),ix(e,`optout`,e=>e.def.innerType._zod.optout),ix(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>nw(e,r,t,n)):nw(e,r,t,n)}}),iw=X(`$ZodPipe`,(e,t)=>{VS.init(e,t),ix(e,`values`,e=>e.def.in._zod.values),ix(e,`optin`,e=>e.def.in._zod.optin),ix(e,`optout`,e=>e.def.out._zod.optout),ix(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>aw(e,t.in,n)):aw(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>aw(e,t.out,n)):aw(r,t.out,n)}});function aw(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var ow=X(`$ZodReadonly`,(e,t)=>{VS.init(e,t),ix(e,`propValues`,e=>e.def.innerType._zod.propValues),ix(e,`values`,e=>e.def.innerType._zod.values),ix(e,`optin`,e=>e.def.innerType?._zod?.optin),ix(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(sw):sw(r)}});function sw(e){return e.memo||(e.value=Object.freeze(e.value)),e}var cw=X(`$ZodCustom`,(e,t)=>{xS.init(e,t),VS.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>lw(t,n,r,e));lw(i,n,r,e)}});function lw(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Yb(e))}}var uw=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},dw=`~memo`,fw=[];function pw(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var mw=new WeakMap;function hw(e,t){let n=mw.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1,i=e=>{!r&&e?._zod&&hw(e,t)&&(r=!0)},a=e._zod.def;switch(a.type){case`object`:for(let e of Reflect.ownKeys(a.shape))i(a.shape[e]);i(a.catchall);break;case`array`:i(a.element);break;case`tuple`:for(let e of a.items)i(e);i(a.rest);break;case`record`:case`map`:i(a.keyType),i(a.valueType);break;case`set`:i(a.valueType);break;case`union`:for(let e of a.options)i(e);break;case`intersection`:i(a.left),i(a.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:i(a.innerType);break;case`pipe`:i(a.in),i(a.out);break;case`function`:i(a.input),i(a.output);break;case`lazy`:i(e._zod.innerType);break;case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in a){let t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)i(n);else if(Array.isArray(n))for(let e of n)i(e)}}}return t.delete(e),mw.set(e,r),r}function gw(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}var _w,vw=[],yw={alloc(e,t,n){let r=_w;if(!r)return n;_w=void 0;let i={value:n,issues:null};return r.set(t.value,i),vw.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&xw(n,e.value))throw new uw;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,a=(o,s)=>{if(n===void 0&&(n=hw(e,new Set),!n))return e._zod.parse=t,e._zod.run===a&&(e._zod.run=t),t(o,s);let c=o.value;if(typeof c!=`object`||!c)return t(o,s);let l=s[dw];l||(l={buckets:new Map,backEdges:void 0},s[dw]=l);let u;r===s?u=i:(u=gw(l,e),r=s,i=u);let d=u.get(c);if(d)return o.value=d.value,d.issues?d.issues.length&&o.issues.push(...pw(d.issues)):(o.memo=!0,l.backEdges??(l.backEdges=new Set),l.backEdges.add(d.value)),o;_w=u;let f=vw.length,p=t(o,s);_w=void 0;let m=vw.length>f?vw.pop():void 0;return p instanceof Promise?p.then(e=>(m&&(m.issues=e.issues.length?pw(e.issues):fw),e)):(m&&(m.issues=p.issues.length?pw(p.issues):fw),p)};e._zod.parse=a,e._zod.run===t&&(e._zod.run=a)})}};function bw(){return yw}function xw(e,t){let n=e[dw]?.backEdges;return n!==void 0&&typeof t==`object`&&!!t&&n.has(t)}var Sw=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,credit_card:`credit card number`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Jb(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${kb(e.values[0])}`:`Invalid option: expected one of ${db(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${db(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Cw(){return{localeError:Sw()}}var ww,Tw=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ew(){return new Tw}(ww=globalThis).__zod_globalRegistry??(ww.__zod_globalRegistry=Ew());var Dw=globalThis.__zod_globalRegistry;function Ow(e,t){return new e({type:`string`,...Y(t)})}function kw(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Y(t)})}function Aw(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Y(t)})}function jw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Y(t)})}function Mw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Y(t)})}function Nw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Y(t)})}function Pw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Y(t)})}function Fw(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Y(t)})}function Iw(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Y(t)})}function Lw(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Y(t)})}function Rw(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Y(t)})}function zw(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Y(t)})}function Bw(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Y(t)})}function Vw(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Y(t)})}function Hw(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Y(t)})}function Uw(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Y(t)})}function Ww(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Y(t)})}function Gw(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Y(t)})}function Kw(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Y(t)})}function qw(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Y(t)})}function Jw(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Y(t)})}function Yw(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Y(t)})}function Xw(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Y(t)})}function Zw(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Y(t)})}function Qw(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Y(t)})}function $w(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Y(t)})}function eT(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Y(t)})}function tT(e,t){return new e({type:`number`,checks:[],...Y(t)})}function nT(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Y(t)})}function rT(e){return new e({type:`unknown`})}function iT(e,t){return new e({type:`never`,...Y(t)})}function aT(e,t){return new wS({check:`less_than`,...Y(t),value:e,inclusive:!1})}function oT(e,t){return new wS({check:`less_than`,...Y(t),value:e,inclusive:!0})}function sT(e,t){return new TS({check:`greater_than`,...Y(t),value:e,inclusive:!1})}function cT(e,t){return new TS({check:`greater_than`,...Y(t),value:e,inclusive:!0})}function lT(e,t){return new ES({check:`multiple_of`,...Y(t),value:e})}function uT(e,t){return new OS({check:`max_length`,...Y(t),maximum:e})}function dT(e,t){return new kS({check:`min_length`,...Y(t),minimum:e})}function fT(e,t){return new AS({check:`length_equals`,...Y(t),length:e})}function pT(e,t){return new MS({check:`string_format`,format:`regex`,...Y(t),pattern:e})}function mT(e){return new NS({check:`string_format`,format:`lowercase`,...Y(e)})}function hT(e){return new PS({check:`string_format`,format:`uppercase`,...Y(e)})}function gT(e,t){return new FS({check:`string_format`,format:`includes`,...Y(t),includes:e})}function _T(e,t){return new IS({check:`string_format`,format:`starts_with`,...Y(t),prefix:e})}function vT(e,t){return new LS({check:`string_format`,format:`ends_with`,...Y(t),suffix:e})}function yT(e){return new RS({check:`overwrite`,tx:e})}function bT(e){return yT(t=>t.normalize(e))}function xT(){return yT(e=>e.trim())}function ST(){return yT(e=>e.toLowerCase())}function CT(){return yT(e=>e.toUpperCase())}function wT(){return yT(e=>bb(e))}function TT(e,t,n){return new e({type:`array`,element:t,...Y(n)})}function ET(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Y(n)})}function DT(e,t){let n=OT(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Yb(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Yb(r))}},e(t.value,t)),t);return n}function OT(e,t){let n=new xS({check:`custom`,...Y(t)});return n._zod.check=e,n}function kT(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&_b(e,t,n[t]);return e}function AT(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Dw,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function jT(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function MT(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,MT(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&kT(o.schema,c),t.io===`input`&&HT(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function NT(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function PT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${NT(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+NT(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
97
97
 
98
- 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 FT(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;FT(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 IT=new Set([`type`,`properties`,`required`,`additionalProperties`]),LT=[`oneOf`,`anyOf`];function RT(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function zT(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!IT.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]??RT(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}_b(n,r,e.length===1?e[0]:zT(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=RT(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 BT(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of IT)if(t in e)return;let n=t.filter(e=>LT.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=zT(t);else{let e=n[0],i=LT.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=>zT([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,kT(e,r))}function VT(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)):kT(i,s),kT(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())FT(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)??[])BT(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)}kT(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,_b(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:WT(t,`input`,e.processors),output:WT(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function HT(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 HT(r.element,n);if(r.type===`set`)return HT(r.valueType,n);if(r.type===`lazy`)return HT(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 HT(r.innerType,n);if(r.type===`intersection`)return HT(r.left,n)||HT(r.right,n);if(r.type===`record`||r.type===`map`)return HT(r.keyType,n)||HT(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:HT(r.in,n)||HT(r.out,n);if(r.type===`object`){for(let e in r.shape)if(HT(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(HT(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(HT(e,n))return!0;return!!(r.rest&&HT(r.rest,n))}return!1}var UT=(e,t={})=>n=>{let r=AT({...n,processors:t});return MT(e,r),PT(r,e),VT(r,e)},WT=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=AT({...i??{},target:a,io:t,processors:n});return MT(e,o),PT(o,e),VT(o,e)},GT={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},KT=(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=GT[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}))])}},qT=(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):jT(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},JT=(e,t,n,r)=>{n.not={}},YT=(e,t,n,r)=>{let i=e._zod.def,a=ub(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},XT=(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(jT(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(jT(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}},ZT=(e,t,n,r)=>{jT(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},QT=(e,t,n,r)=>{jT(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},$T=(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=MT(a.element,t,{...r,path:[...r.path,`items`]})};function eE(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?eE(t.out):t.type===`catch`?eE(t.innerType):e._zod.optin}var tE=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&jT(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)_b(i.properties,e,MT(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`?eE(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=MT(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},nE=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>MT(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},rE=(e,t,n,r)=>{let i=e._zod.def,a=MT(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=MT(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=e._zod.def,a=MT(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`}]},aE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},oE=Symbol();function sE(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(jT(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),oE):JSON.parse(o)}var cE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=sE(i.defaultValue,e,t,n,r);o!==oE&&(n.default=o)},lE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=sE(i.defaultValue,e,t,n,r);o!==oE&&(n._prefault=o)},uE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{jT(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},dE=(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;MT(o,t,r);let s=t.seen.get(e);s.ref=o},fE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},pE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},mE=new WeakSet([Object.prototype,Error.prototype]);function hE(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 gE=X(`ZodError`,(e,t)=>{Cx.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);mE.has(n)||(mE.add(n),hE(n,`format`,e=>t=>Dx(e,t)),hE(n,`flatten`,e=>t=>Ex(e,t)),hE(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,fb,2)}),hE(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,fb,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),_E=kx(gE),vE=Ax(gE),yE=jx(gE),bE=Nx(gE),xE=Fx(gE),SE=Ix(gE),CE=Lx(gE),wE=Rx(gE),TE=zx(gE),EE=Bx(gE),DE=Vx(gE),OE=Hx(gE);function kE(){mx.localeError||hx(Cw())}function AE(){mx.memoizer||hx({memoizer:bw()})}var jE=X(`ZodType`,(e,t)=>(kE(),VS.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(vb(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 Ob(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(KD(e,t))},superRefine(e,t){return this.check(qD(e,t))},overwrite(e){return this.check(yT(e))},optional(){return OD(this)},exactOptional(){return AD(this)},nullable(){return MD(this)},nullish(){return OD(MD(this))},nonoptional(e){return RD(this,e)},array(){return mD(this)},or(e){return vD([this,e])},and(e){return bD(this,e)},transform(e){return HD(this,ED(e))},default(e){return PD(this,e)},prefault(e){return ID(this,e)},catch(e){return BD(this,e)},pipe(e){return HD(this,e)},readonly(){return WD(this)},describe(e){let t=this.clone();return Dw.add(t,{description:e}),t},meta(...e){if(e.length===0)return Dw.get(this);let t=this.clone();return Dw.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 Qb(this,`~standard`,{...US(this),jsonSchema:{input:WT(this,`input`),output:WT(this,`output`)}})},set"~standard"(e){Zb(this,`~standard`,e)},parse:function e(t,n){return _E(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await vE(this,t,n,{callee:e})},safeParse(e,t){return yE(this,e,t)},async safeParseAsync(e,t){return bE(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Zb(this,`spa`,e)},encode:function e(t,n){return xE(this,t,n,{callee:e})},decode:function e(t,n){return SE(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await CE(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await wE(this,t,n,{callee:e})},safeEncode(e,t){return TE(this,e,t)},safeDecode(e,t){return EE(this,e,t)},async safeEncodeAsync(e,t){return DE(this,e,t)},async safeDecodeAsync(e,t){return OE(this,e,t)},toJSONSchema(e){return UT(this,{})(e)},get description(){return Dw.get(this)?.description},get _def(){return this._zod.def}}),ME=X(`_ZodString`,(e,t)=>{WS.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>KT(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(pT(...e))},includes(...e){return this.check(gT(...e))},startsWith(...e){return this.check(_T(...e))},endsWith(...e){return this.check(vT(...e))},min(...e){return this.check(dT(...e))},max(...e){return this.check(uT(...e))},length(...e){return this.check(fT(...e))},nonempty(...e){return this.check(dT(1,...e))},lowercase(e){return this.check(mT(e))},uppercase(e){return this.check(hT(e))},trim(){return this.check(xT())},normalize(...e){return this.check(bT(...e))},toLowerCase(){return this.check(ST())},toUpperCase(){return this.check(CT())},slugify(){return this.check(wT())}}),NE=X(`ZodString`,(e,t)=>{WS.init(e,t),ME.init(e,t)},{email(e){return this.check(kw(BE,e))},url(e){return this.check(Fw(UE,e))},jwt(e){return this.check(Xw(iD,e))},emoji(e){return this.check(Iw(WE,e))},guid(e){return this.check(Aw(VE,e))},uuid(e){return this.check(jw(HE,e))},uuidv4(e){return this.check(Mw(HE,e))},uuidv6(e){return this.check(Nw(HE,e))},uuidv7(e){return this.check(Pw(HE,e))},nanoid(e){return this.check(Lw(GE,e))},cuid(e){return this.check(Rw(KE,e))},cuid2(e){return this.check(zw(qE,e))},ulid(e){return this.check(Bw(JE,e))},base64(e){return this.check(qw(tD,e))},base64url(e){return this.check(Jw(nD,e))},xid(e){return this.check(Vw(YE,e))},ksuid(e){return this.check(Hw(XE,e))},ipv4(e){return this.check(Uw(ZE,e))},ipv6(e){return this.check(Ww(QE,e))},cidrv4(e){return this.check(Gw($E,e))},cidrv6(e){return this.check(Kw(eD,e))},e164(e){return this.check(Yw(rD,e))},datetime(e){return this.check(Zw(IE,e))},date(e){return this.check(Qw(LE,e))},time(e){return this.check($w(RE,e))},duration(e){return this.check(eT(zE,e))}});function PE(e){return Ow(NE,e)}var FE=X(`ZodStringFormat`,(e,t)=>{GS.init(e,t),ME.init(e,t)}),IE=X(`ZodISODateTime`,(e,t)=>{cC.init(e,t),FE.init(e,t)}),LE=X(`ZodISODate`,(e,t)=>{lC.init(e,t),FE.init(e,t)}),RE=X(`ZodISOTime`,(e,t)=>{uC.init(e,t),FE.init(e,t)}),zE=X(`ZodISODuration`,(e,t)=>{dC.init(e,t),FE.init(e,t)}),BE=X(`ZodEmail`,(e,t)=>{JS.init(e,t),FE.init(e,t)}),VE=X(`ZodGUID`,(e,t)=>{KS.init(e,t),FE.init(e,t)}),HE=X(`ZodUUID`,(e,t)=>{qS.init(e,t),FE.init(e,t)}),UE=X(`ZodURL`,(e,t)=>{eC.init(e,t),FE.init(e,t)}),WE=X(`ZodEmoji`,(e,t)=>{tC.init(e,t),FE.init(e,t)}),GE=X(`ZodNanoID`,(e,t)=>{nC.init(e,t),FE.init(e,t)}),KE=X(`ZodCUID`,(e,t)=>{rC.init(e,t),FE.init(e,t)}),qE=X(`ZodCUID2`,(e,t)=>{iC.init(e,t),FE.init(e,t)}),JE=X(`ZodULID`,(e,t)=>{aC.init(e,t),FE.init(e,t)}),YE=X(`ZodXID`,(e,t)=>{oC.init(e,t),FE.init(e,t)}),XE=X(`ZodKSUID`,(e,t)=>{sC.init(e,t),FE.init(e,t)}),ZE=X(`ZodIPv4`,(e,t)=>{fC.init(e,t),FE.init(e,t)}),QE=X(`ZodIPv6`,(e,t)=>{hC.init(e,t),FE.init(e,t)}),$E=X(`ZodCIDRv4`,(e,t)=>{gC.init(e,t),FE.init(e,t)}),eD=X(`ZodCIDRv6`,(e,t)=>{vC.init(e,t),FE.init(e,t)}),tD=X(`ZodBase64`,(e,t)=>{bC.init(e,t),FE.init(e,t)}),nD=X(`ZodBase64URL`,(e,t)=>{SC.init(e,t),FE.init(e,t)}),rD=X(`ZodE164`,(e,t)=>{CC.init(e,t),FE.init(e,t)}),iD=X(`ZodJWT`,(e,t)=>{TC.init(e,t),FE.init(e,t)}),aD=X(`ZodNumber`,(e,t)=>{EC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qT(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(sT(e,t))},gte(e,t){return this.check(cT(e,t))},min(e,t){return this.check(cT(e,t))},lt(e,t){return this.check(aT(e,t))},lte(e,t){return this.check(oT(e,t))},max(e,t){return this.check(oT(e,t))},int(e){return this.check(cD(e))},safe(e){return this.check(cD(e))},positive(e){return this.check(sT(0,e))},nonnegative(e){return this.check(cT(0,e))},negative(e){return this.check(aT(0,e))},nonpositive(e){return this.check(oT(0,e))},multipleOf(e,t){return this.check(lT(e,t))},step(e,t){return this.check(lT(e,t))},finite(){return this}});function oD(e){return tT(aD,e)}var sD=X(`ZodNumberFormat`,(e,t)=>{DC.init(e,t),aD.init(e,t)});function cD(e){return nT(sD,e)}var lD=X(`ZodUnknown`,(e,t)=>{OC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function uD(){return rT(lD)}var dD=X(`ZodNever`,(e,t)=>{kC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JT(e,t,n,r)});function fD(e){return iT(dD,e)}var pD=X(`ZodArray`,(e,t)=>{AE(),jC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$T(e,t,n,r),e.element=t.element},{min(e,t){return this.check(dT(e,t))},nonempty(e){return this.check(dT(1,e))},max(e,t){return this.check(uT(e,t))},length(e,t){return this.check(fT(e,t))},unwrap(){return this.element}});function mD(e,t){return TT(pD,e,t)}var hD=X(`ZodObject`,(e,t)=>{AE(),RC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tE(e,t,n,r),ax(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return SD(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:uD()})},loose(){return this.clone({...this._zod.def,catchall:uD()})},strict(){return this.clone({...this._zod.def,catchall:fD()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Pb(this,e)},safeExtend(e){return Fb(this,e)},merge(e){return Ib(this,e)},pick(e){return Mb(this,e)},omit(e){return Nb(this,e)},partial(...e){return Lb(DD,this,e[0])},exactPartial(...e){return Lb(kD,this,e[0],`exactPartial`)},required(...e){return Rb(LD,this,e[0])}});function gD(e,t){return new hD({type:`object`,shape:e??{},...Y(t)})}var _D=X(`ZodUnion`,(e,t)=>{BC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nE(e,t,n,r),e.options=t.options});function vD(e,t){return new _D({type:`union`,options:e,...Y(t)})}var yD=X(`ZodIntersection`,(e,t)=>{VC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rE(e,t,n,r)});function bD(e,t){return new yD({type:`intersection`,left:e,right:t})}var xD=X(`ZodEnum`,(e,t)=>{WC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>YT(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 xD({...t,checks:[],...Y(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 xD({...t,checks:[],...Y(r),entries:i})}});function SD(e,t){return new xD({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Y(t)})}var CD=X(`ZodLiteral`,(e,t)=>{GC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>XT(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 wD(e,t){return new CD({type:`literal`,values:Array.isArray(e)?e:[e],...Y(t)})}var TD=X(`ZodTransform`,(e,t)=>{AE(),KC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>QT(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new px(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Yb(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(Yb(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ED(e){return new TD({type:`transform`,transform:e})}var DD=X(`ZodOptional`,(e,t)=>{JC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function OD(e){return new DD({type:`optional`,innerType:e})}var kD=X(`ZodExactOptional`,(e,t)=>{YC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function AD(e){return new kD({type:`optional`,innerType:e})}var jD=X(`ZodNullable`,(e,t)=>{XC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function MD(e){return new jD({type:`nullable`,innerType:e})}var ND=X(`ZodDefault`,(e,t)=>{ZC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function PD(e,t){return new ND({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Tb(t)}})}var FD=X(`ZodPrefault`,(e,t)=>{$C.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ID(e,t){return new FD({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Tb(t)}})}var LD=X(`ZodNonOptional`,(e,t)=>{ew.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function RD(e,t){return new LD({type:`nonoptional`,innerType:e,...Y(t)})}var zD=X(`ZodCatch`,(e,t)=>{rw.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function BD(e,t){return new zD({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:sx(t)})}var VD=X(`ZodPipe`,(e,t)=>{iw.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dE(e,t,n,r),e.in=t.in,e.out=t.out});function HD(e,t){return new VD({type:`pipe`,in:e,out:t})}var UD=X(`ZodReadonly`,(e,t)=>{ow.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function WD(e){return new UD({type:`readonly`,innerType:e})}var GD=X(`ZodCustom`,(e,t)=>{cw.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ZT(e,t,n,r)});function KD(e,t={}){return ET(GD,e,t)}function qD(e,t){return DT(e,t)}var JD=[`off`,`files`,`burn-in`],YD=[`top`,`upper-middle`,`center`,`lower-middle`,`bottom`],XD=gD({mode:SD(JD),language:wD(`en`).default(`en`),fontId:PE().max(160).regex(/^[A-Za-z0-9_-]+$/).default(`default`),position:SD(YD).default(`bottom`),fontSize:oD().int().min(16).max(120).default(48)}),ZD={mode:`off`,language:`en`,fontId:`default`,fontSize:48,position:`bottom`};function QD(e,t){let n={...ZD,...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=XD.shape.fontId.safeParse(n.fontId),a=XD.shape.fontSize.safeParse(n.fontSize);return{...n,mode:r,fontId:i.success?i.data:ZD.fontId,fontSize:a.success?a.data:ZD.fontSize}}function $D(e,t){return e.mode===t.mode&&e.language===t.language&&e.fontId===t.fontId&&e.fontSize===t.fontSize&&(e.position??`bottom`)===(t.position??`bottom`)}function eO(e){return e.mode===`off`||e.fontId!==``&&Number.isInteger(e.fontSize)&&e.fontSize>=16&&e.fontSize<=120}var tO={title:``,format:`16:9`,sources:{research:`off`,article:`generate`,audio:`generate`,images:`generate`,thumbnail:`off`,video:`generate`},llm:{provider:``,model:``},audio:{provider:``,model:``,voice:``},images:{provider:``,model:``},articlePrompt:``,imagePrompts:[],thumbnailPrompt:``,intro:``,outro:``,chunking:{mode:`whole`},subtitles:ZD,values:{},provided:{research:``,article:``,audio:void 0,images:[],thumbnail:void 0}},nO={off:`Off`,generate:`Generate`,provide:`Provide`,from_prompt:`From prompt`,prompt_by_llm:`Prompt by LLM`};function rO(e){return tb[e].map(e=>({value:e,label:nO[e]}))}function iO(e,t){return e.sources.article===`generate`||e.sources.thumbnail===`prompt_by_llm`||e.sources.audio===`generate`&&(aO(t,`intro`,e.intro)===`llm`||aO(t,`outro`,e.outro)===`llm`)}function aO(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.mode}function oO(e){return[e.audio,e.thumbnail,...e.images].flatMap(e=>e?.file===void 0?[]:[e.file])}function sO(e){let{form:t}=e;return{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,articlePrompt:t.articlePrompt,imagePrompts:t.imagePrompts,thumbnailPrompt:t.thumbnailPrompt,...cO(lO(e,`intro`),e=>({intro:e})),...cO(lO(e,`outro`),e=>({outro:e})),values:uO(t.values,e.slots),provided:{research:t.provided.research,article:t.provided.article,...cO(t.provided.audio?.file,e=>({audio:e.id})),...cO(t.provided.thumbnail?.file,e=>({thumbnail:e.id})),images:t.provided.images.flatMap(e=>e.file===void 0?[]:[e.file.id])},chunking:t.chunking,subtitles:QD(t.subtitles,t.sources),silenceGapSeconds:e.silenceGapSeconds}}function cO(e,t){return e===void 0?{}:t(e)}function lO(e,t){if(e.form.sources.audio!==`generate`)return;let n=t===`intro`?e.form.intro:e.form.outro,r=aO(e.entries,t,n);return n===``||r===void 0?void 0:{name:n,mode:r}}function uO(e,t){let n=Object.create(null);for(let r of t)n[r]=Object.hasOwn(e,r)?e[r]??``:``;return n}var dO=(0,m.createContext)(void 0);function fO({children:e}){let[t,n]=(0,m.useState)(()=>new Map),[r,i]=(0,m.useState)(tO),a=(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})},[]),o=(0,m.useMemo)(()=>({prompts:t,updatePrompt:a,play:r,updatePlay:i}),[t,a,r]);return(0,h.jsx)(dO.Provider,{value:o,children:e})}function pO(e){let t=(0,m.useContext)(dO),[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 mO(){let e=(0,m.useContext)(dO),[t,n]=(0,m.useState)(tO);return e?[e.play,e.updatePlay]:[t,n]}function hO(e,t){if(e===void 0)return;if(t.type===`project.state`)return{...e,project:{...e.project,status:t.state}};let n=e.stages.findIndex(e=>e.kind===t.stage),r=e.stages[n];return r===void 0?e:{...e,stages:e.stages.with(n,gO(r,t))}}function gO(e,t){return t.type===`stage.progress`?{...e,progressCurrent:t.current,progressTotal:t.total}:{...e,state:t.state,failureReason:t.failureReason??e.failureReason}}function _O(e,t){let n,r=!1,i=()=>{n=void 0,r&&(r=!1,e(),a())},a=()=>{n=setTimeout(i,t)};return{ask:()=>{if(n!==void 0){r=!0;return}e(),a()},stop:()=>{n!==void 0&&clearTimeout(n),n=void 0,r=!1}}}var vO=[{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-article`,title:`11. Choose what to write`,target:`play-article`,page:`play`},{id:`play-audio`,title:`12. Choose the narration`,target:`play-audio`,page:`play`},{id:`play-images`,title:`13. Choose the images`,target:`play-images`,page:`play`},{id:`play-video`,title:`14. Choose your final output`,target:`play-video`,page:`play`},{id:`play-subtitles`,title:`15. Add optional subtitles`,target:`play-subtitles`,page:`play`},{id:`play-options`,title:`16. Name and configure your project`,target:`play-options`,page:`play`},{id:`play-keywords`,title:`17. Fill in your keywords`,target:`play-keywords`,page:`play`},{id:`play-start`,title:`18. Review and press PLAY`,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`}];function yO(e,t){return e.active?t.type===`project-created`?{...e,projectId:t.id,step:vO.findIndex(e=>e.id===`project`)}:t.kind===`article`?{...e,articleId:t.id}:t.kind===`image`?{...e,imageId:t.id}:e:e}var bO={research:`Research`,article:`Article`,audio:`Audio`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`};function xO(e){return e.sources.video===`off`?e.sources.audio===`off`?`article`:`audio`:`video`}function SO(e,t){return e===`video`&&xO(t)===`audio`?`Audio export`:bO[e]}var CO={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(jO(e,t))}% rendered`},wO={audio_intro:`intro`,audio_body:`body`,audio_outro:`outro`};function TO(e,t,n){let r=t.filter(t=>t.stageKind===e.kind);switch(e.state){case`skipped`:return`Not part of this run`;case`pending`:return n.status===`paused`?`Waiting for Resume`:e.kind===`images`||e.kind===`thumbnail`&&e.source===`from_prompt`?`Ready to run`:`Waits for the stages above`;case`provided`:return OO(r)??`Provided`;case`failed`:return`Stopped after ${EO(e)}`;case`canceled`:return`Canceled by user`;case`running`:return e.kind===`video`&&xO(n.config)===`audio`?`Exporting combined audio`:e.progressTotal===null||e.progressTotal<=0?`Running`:CO[e.kind](e.progressCurrent??0,e.progressTotal);case`done`:return DO(e.kind,r,n)}}function EO(e){return e.attemptCount===1?`1 attempt`:`${String(e.attemptCount)} attempts`}function DO(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 FO([NO(t.flatMap(e=>{let t=wO[e.role];return t===void 0?[]:[t]})),AO(kO(t))]);case`images`:return MO(t.filter(e=>e.role===`image`).length,`image`);case`thumbnail`:return t.length===0?`Thumbnail ready`:`1 image`;case`video`:return FO([AO(kO(t)),xO(n.config)===`audio`?`WAV · stereo · 48 kHz`:n.format])}}function OO(e){let t=e.flatMap(e=>e.originalFilename===null?[]:[e.originalFilename]);return t.length===0?void 0:t.join(`, `)}function kO(e){let t=Math.max(0,...e.map(e=>e.durationMs??0));return t===0?void 0:t}function AO(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 jO(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function MO(e,t){return e===1?`1 ${t}`:`${String(e)} ${t}s`}function NO(e){if(e.length!==0)return e.length===1?PO(e[0]??``):PO(`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]??``}`)}function PO(e){return e.charAt(0).toUpperCase()+e.slice(1)}function FO(e){return e.filter(e=>e!==void 0&&e!==``).join(` · `)}var IO=12,LO=16;function RO(e,t,n){return Math.max(t,Math.min(e,Math.max(t,n)))}function zO(e,t,n){let r=Math.min(n.width,t.width-24),i=RO(e?.left??(t.width-r)/2,IO,t.width-r-IO),a=RO((e?.top??0)+((e?.height??t.height)-n.height)/2,IO,t.height-n.height-IO),o=t.height-n.height-IO;if(!e)return{left:i,top:a,width:r,docked:!1};let s=e.left+e.width,c=e.top+e.height;return s+LO+r<=t.width-IO?{left:s+LO,top:a,width:r,docked:!1}:e.left-LO-r>=IO?{left:e.left-LO-r,top:a,width:r,docked:!1}:c>=IO&&c+LO+n.height<=t.height-IO?{left:i,top:c+LO,width:r,docked:!1}:e.top-LO-n.height>=IO&&e.top<=t.height-IO?{left:i,top:e.top-LO-n.height,width:r,docked:!1}:{left:t.width-r-IO,top:Math.max(IO,o),width:r,docked:!0}}function BO(e,t,n=t.height){let r=RO(e.left-6,0,t.width),i=RO(e.top-6,0,Math.min(n,t.height)),a=RO(e.left+e.width+6,0,t.width),o=RO(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 VO=`[data-slot="select-content"], [data-slot="dropdown-menu-content"]`;function HO(e){try{return document.querySelector(e)}catch{return null}}function UO(){return[...document.querySelectorAll(`[data-slot="dialog-content"][data-state="open"]`)].at(-1)??null}function WO(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(VO)].filter(e=>n.has(e.id))}function GO(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 KO=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable="true"]`;function qO(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=HO(e);return[t,n.current,...WO(t)].filter(e=>e!==null)},i=e=>e instanceof Node&&t().some(t=>t.contains(e)),o=e=>{UO()||i(e.target)||(e.preventDefault(),e.stopImmediatePropagation())},s=e=>{UO()||i(e.target)||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-radix-focus-guard`)||r.current?.focus({preventScroll:!0})},c=n=>{if(UO())return;let r=WO(HO(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(KO)]).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 JO(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:UO()!==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=HO(t);r!==u&&(u&&f.unobserve(u),r&&f.observe(r),u=r);let i=r?GO(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=WO(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(GO).filter(e=>e!==null),width:window.innerWidth,height:window.innerHeight,cardHeight:n.current?.getBoundingClientRect().height||260,modalOpen:UO()!==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(),UO()||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 YO({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=JO(p,t,g,_,v,y);qO(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=zO(C,w,T),D=C?BO(C,w,E.docked?E.top-12:w.height):null,O=b.key===p?b.portals.map(e=>BO(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,$c.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-panel border border-line2 bg-panel p-4 text-body text-ink shadow-[0_8px_24px_var(--color-shadow)]`,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-run-text`,children:[`Getting started · `,i]}),(0,h.jsx)(J,{variant:`ghost`,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 font-bold outline-none`,children:n}),(0,h.jsxs)(`div`,{id:`${f}-instructions`,className:`min-h-0 overflow-y-auto text-ink2 [&_p+p]:mt-2 [&_code]:text-ink`,children:[r,!C&&(0,h.jsx)(`p`,{role:`status`,className:`mt-3 text-amber`,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)(J,{onClick:o,children:`Back`}),u&&(0,h.jsx)(J,{variant:`ghost`,onClick:u,className:`px-2`,children:d}),(0,h.jsx)(J,{variant:`primary`,onClick:a,disabled:l||!C,className:`ml-auto`,children:c})]})]})]})]}),document.body)}function XO({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 ZO({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-line2 bg-panel2 p-3 text-small leading-relaxed`,children:e}),(0,h.jsx)(J,{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]})}function QO({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)(XO,{href:`https://openrouter.ai/settings/keys`,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 and press`,` `,(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-ink3`,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`,` `,(0,h.jsx)(`strong`,{children:`ElevenLabs`}),`, `,(0,h.jsx)(`strong`,{children:`OpenAI`}),`, or `,(0,h.jsx)(`strong`,{children:`Cartesia`}),`; you do not need all three.`]}),(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 and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(XO,{href:`https://elevenlabs.io/app/developers/api-keys`,children:`ElevenLabs keys`}),` `,`· `,(0,h.jsx)(XO,{href:`https://platform.openai.com/api-keys`,children:`OpenAI keys`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://play.cartesia.ai/keys`,children:`Cartesia keys`})]}),(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, create a key in its dashboard, paste it into the matching row, and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(XO,{href:`https://fal.ai/dashboard/keys`,children:`fal.ai`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://replicate.com/account/api-tokens`,children:`Replicate`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://aistudio.google.com/apikey`,children:`Google AI Studio`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://platform.openai.com/api-keys`,children:`OpenAI`})]}),(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 $O=`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.`,ek=`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 tk({step:e,output:t=`video`}){switch(e){case`text-key`:case`audio-key`:case`image-key`:case`voice`:return(0,h.jsx)(QO,{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)(ZO,{text:$O}),(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)(ZO,{text:ek}),(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 chunking 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)(`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`}),`, select your image prompt, and set`,` `,(0,h.jsx)(`strong`,{children:`Number`}),` to 2 for a small first run.`]}),(0,h.jsx)(`p`,{children:`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:[`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:`Video title`}),`, such as “A quick trip to Albania.” Choose`,` `,(0,h.jsx)(`strong`,{children:`16:9`}),` for landscape or `,(0,h.jsx)(`strong`,{children:`9:16`}),` for portrait.`]}),(0,h.jsxs)(`p`,{children:[`Select the text `,(0,h.jsx)(`strong`,{children:`LLM`}),` and `,(0,h.jsx)(`strong`,{children:`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.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Intro`}),` and `,(0,h.jsx)(`strong`,{children:`Outro`}),` Off for this first run. They are available only 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.jsxs)(`p`,{children:[`A field under `,(0,h.jsx)(`strong`,{children:`Common`}),` feeds both the article and images. Changing it changes both prompts 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:`Check the hint above PLAY. 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:`PLAY`}),` 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 finish the tutorial without generating anything.`})]});case`project`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Overall progress stays above the workspace. Select a stage from `,(0,h.jsx)(`strong`,{children:`Stages`}),` `,`to see its results or live writing. Press `,(0,h.jsx)(`strong`,{children:`Pause`}),` to stop active requests safely and keep finished work.`]}),(0,h.jsxs)(`p`,{children:[`While paused or failed, open `,(0,h.jsx)(`strong`,{children:`Run settings`}),` to change providers, models or voice. Press `,(0,h.jsx)(`strong`,{children:`Save providers`}),`, then `,(0,h.jsx)(`strong`,{children:`Resume`}),` `,`separately. Changing TTS choices restarts unfinished narration to avoid mixing voices; completed outputs stay unchanged.`]}),(0,h.jsxs)(`p`,{children:[`Select a failed stage and open `,(0,h.jsx)(`strong`,{children:`Error details`}),` to read the provider’s message. `,(0,h.jsx)(`strong`,{children:`Retry stage`}),` keeps completed outputs. Editing or rerunning earlier work updates only the enabled dependent outputs.`]})]});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 .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 .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 `,(0,h.jsx)(`strong`,{children:`Stages`}),` 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.`]}),(0,h.jsxs)(`p`,{children:[`You have reached the end. Open `,(0,h.jsx)(`strong`,{children:`Tutorial`}),` in the navigation anytime to walk through these steps again.`]})]})}}function nk(e){return e.readiness.kind===`cli`?e.readiness.installed:e.readiness.hasKey}function rk({session:e,progress:t,update:n}){let{api:r}=B(),i=Hi(),a=ka(),o=R(Py(r)),s=R(Iy(r)),c=R(Ly(r)),l=R({...Ny(r,e.projectId??``),enabled:e.projectId!==void 0}),u=(0,m.useRef)(null),d=vO[e.step],f=o.data?.seen===!0;if((0,m.useEffect)(()=>{if(f&&d&&u.current!==e.step){if(u.current=e.step,d.page===`settings`&&a.pathname!==`/settings`&&i({to:`/settings`}),d.page===`article`||d.page===`image`){let t=d.page===`article`?e.articleId:e.imageId,n=a.pathname===`/prompts/new`&&a.searchStr.includes(`kind=${d.page}`);t&&a.pathname!==`/prompts/${t}`?i({to:`/prompts/$promptId`,params:{promptId:t}}):!t&&!n&&i({to:`/prompts/new`,search:{kind:d.page}})}d.page===`play`&&a.pathname!==`/play`&&i({to:`/play`}),d.page===`project`&&e.projectId&&a.pathname!==`/projects/${e.projectId}`&&i({to:`/projects/$projectId`,params:{projectId:e.projectId}})}},[f,d,e.step,e.articleId,e.imageId,e.projectId,a.pathname,a.searchStr,i]),(0,m.useEffect)(()=>{a.pathname===`/prompts`&&(d?.id===`image-prompt`&&e.imageId?n(e=>({...e,step:vO.findIndex(e=>e.id===`play-article`)})):(d?.id===`article-save`&&e.articleId||d?.id===`image-save`&&e.imageId)&&n(e=>({...e,step:e.step+1})))},[a.pathname,d?.id,e.articleId,e.imageId,n]),!f||!d)return null;let p=s.data?.providers??[],g=e=>p.some(t=>t.family===e&&nk(t)),_=(c.data?.voices??[]).some(e=>p.some(t=>t.id===e.provider&&nk(t))),v={"text-key":g(`llm`),"audio-key":g(`tts`),"image-key":g(`image`),voice:_,"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},y=()=>n(e=>({...e,active:!1})),b=()=>{e.step===vO.length-1||d.id===`play-start`?y():n(e=>({...e,step:e.step+1}))},x=l.data?xO(l.data.project.config):`video`,S=d.id===`download`&&x===`article`?`project-article`:d.id===`play-keywords`&&t.playHasKeywords===!1?`play-options`:d.target,C=d.id===`article-save`||d.id===`image-save`,w=(d.page===`article`||d.page===`image`)&&t.promptSaving===!0;return(0,h.jsxs)(YO,{stepId:d.id,target:`[data-tour="${S}"]`,title:d.title,progress:`${e.step+1} of ${vO.length} · First project`,onClose:y,...e.step===0||d.id===`project`||w?{}:{onBack:()=>n(e=>({...e,step:e.step-1}))},onNext:b,nextDisabled:w||v[d.id]===!1,nextLabel:C?`Use Save in the editor`:d.id===`play-start`?`Use PLAY on the page`:d.id===`download`?`Finish tutorial`:`Next`,...w?{}:{onSkip:b},skipLabel:d.id===`play-start`?`Finish without generating`:C?`Skip without saving`:`Skip this step`,children:[(0,h.jsx)(tk,{step:d.id,output:x}),s.error||c.error?(0,h.jsx)(`p`,{className:`text-red`,children:s.error?.message??c.error?.message}):null]})}var ik=(0,m.createContext)(void 0);function ak({children:e}){let[t,n]=(0,m.useState)({active:!1,step:0}),[r,i]=(0,m.useState)({}),a=(0,m.useCallback)(()=>{n({active:!0,step:0})},[]),o=(0,m.useCallback)(e=>{i(t=>Object.entries(e).every(([e,n])=>t[e]===n)?t:{...t,...e})},[]),s=(0,m.useCallback)(e=>{i(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!e.includes(t))))},[]),c=(0,m.useCallback)(e=>{n(t=>yO(t,e))},[]),l=vO[t.step]?.id,u=t.active&&(l===`project`||l===`download`)?l:void 0,d=(0,m.useMemo)(()=>({active:t.active,projectId:t.projectId,projectStep:u,start:a,report:o,clear:s,event:c}),[t.active,t.projectId,u,a,o,s,c]);return(0,h.jsxs)(ik.Provider,{value:d,children:[e,t.active?(0,h.jsx)(rk,{session:t,progress:r,update:n}):null]})}function ok(){return(0,m.useContext)(ik)}function sk(e){let t=(0,m.useContext)(ik),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 ck(){let e=(0,m.useContext)(ik);return(0,m.useCallback)(t=>{e?.event(t)},[e?.event])}function lk(e){let t=(0,m.useContext)(ik);return t?.projectId===e?t.projectStep:void 0}var uk=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),dk=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),fk=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),pk=e=>{let t=fk(e);return t.charAt(0).toUpperCase()+t.slice(1)},mk={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},hk=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},gk=(0,m.createContext)({}),_k=()=>(0,m.useContext)(gk),vk=(0,m.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=_k()??{},h=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,m.createElement)(`svg`,{ref:c,...mk,width:t??l??mk.width,height:t??l??mk.height,stroke:e??f,strokeWidth:h,className:uk(`lucide`,p,i),...!a&&!hk(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,m.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),yk=(e,t)=>{let n=(0,m.forwardRef)(({className:n,...r},i)=>(0,m.createElement)(vk,{ref:i,iconNode:t,className:uk(`lucide-${dk(pk(e))}`,`lucide-${e}`,n),...r}));return n.displayName=pk(e),n},bk=yk(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),xk=yk(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Sk=yk(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Ck=yk(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),wk=yk(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),Tk=yk(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ek=yk(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Dk=yk(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Ok=yk(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),kk=yk(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Ak=yk(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),jk=yk(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Mk=yk(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Nk(){let e=ok();return e?(0,h.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,onClick:e.start,disabled:e.active,"aria-label":`Start interactive tutorial`,title:`Start interactive tutorial`,children:[(0,h.jsx)(Tk,{className:`size-4`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`sr-only min-[1280px]:not-sr-only`,children:`Tutorial`})]}):null}function Pk(){let e=ok();return!e||e.active?null:(0,h.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-4 rounded-panel border border-line bg-panel px-4 py-[14px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`font-semibold`,children:`Make your first video`}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`An interactive walkthrough of API keys, reusable prompts, keywords, and Play. Each step highlights the real controls you will use.`})]}),(0,h.jsx)(J,{variant:`accent`,onClick:e.start,children:`Start tutorial`})]})}var Fk=[`app-update`],Ik=9e5,Lk=2e3;async function Rk(e,t=!1,n){let r=AbortSignal.timeout(2e4);return Za(await e.fetch(`${e.origin}/api/update${t?`?refresh=1`:``}`,{signal:n===void 0?r:AbortSignal.any([n,r]),cache:`no-store`}))}async function zk(e){return Za(await e.fetch(`${e.origin}/api/update`,{method:`POST`,signal:AbortSignal.timeout(2e4)}))}function Bk(e){let{api:t}=B(),n=_(),[r,i]=(0,m.useState)(null),a=(0,m.useRef)(!1),o=R({queryKey:Fk,queryFn:({signal:e})=>Rk(t,!1,e),staleTime:Ik,refetchOnWindowFocus:`always`,refetchInterval:e=>r!==null||e.state.data?.status===`checking`||e.state.data?.status===`installing`||e.state.data?.status===`restarting`?Lk:Ik,retry:!1}),s=tt({mutationFn:()=>Rk(t,!0),onMutate:()=>n.cancelQueries({queryKey:Fk}),onSuccess:e=>n.setQueryData(Fk,e),retry:!1}),c=tt({mutationFn:()=>zk(t),onMutate:()=>n.cancelQueries({queryKey:Fk}),onSuccess:e=>{i(e.currentVersion),n.setQueryData(Fk,e)},onError:()=>{n.invalidateQueries({queryKey:Fk})},retry:!1});(0,m.useEffect)(()=>{if(r===null||o.data===void 0)return;let t=o.data.status===`idle`||o.data.status===`error`;o.data.currentVersion!==r&&t&&!a.current?(a.current=!0,e()):o.data.status===`error`&&i(null)},[r,e,o.data]);let l=r!==null||o.data?.status===`installing`||o.data?.status===`restarting`,u=c.error?.message??s.error?.message??(l?void 0:o.error?.message??o.data?.error);return{info:o.data,updating:l,checking:o.isFetching||s.isPending||o.data?.status===`checking`,installing:c.isPending,reconnecting:l&&o.isError,error:u,inspect:()=>{o.refetch()},refresh:()=>{c.reset(),s.mutate()},install:()=>{s.reset(),c.mutate()}}}function Vk({reload:e}){let t=Bk(e),n=(0,m.useId)(),r=(0,m.useId)(),{info:i,updating:a,installing:o,reconnecting:s,checking:c,error:l}=t,u=a||o,d=u?`Slopify updates: Updating Slopify`:l?`Slopify updates: Update check failed`:i?.available?`Slopify updates: version ${i.latestVersion??`new`} available`:`Slopify updates`,f=i?.blockedReason??(i?.busy?`Pause running projects and wait for their active work to stop before updating.`:void 0);return(0,h.jsxs)(X_,{onOpenChange:e=>{e&&t.inspect()},children:[(0,h.jsx)(Z_,{asChild:!0,children:(0,h.jsxs)(`button`,{type:`button`,"aria-label":d,title:d,className:W(`fixed right-5 bottom-5 z-30 flex size-10 items-center justify-center rounded-full bg-transparent text-ink2 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,l&&`text-amber`),children:[(0,h.jsx)(Ak,{"aria-hidden":`true`,size:20,className:W(u&&`animate-spin motion-reduce:animate-none`)}),i?.available&&!u?(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1 right-1 size-1.5 rounded-full bg-lamp-run`}):null]})}),(0,h.jsx)(Q_,{children:(0,h.jsxs)($_,{align:`end`,side:`top`,sideOffset:10,collisionPadding:16,"aria-labelledby":n,className:`z-50 w-[min(340px,calc(100vw-2rem))] rounded-panel border border-line bg-panel p-4 shadow-[0_8px_24px_var(--color-shadow)]`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-4`,children:[(0,h.jsx)(`h2`,{id:n,className:`text-row font-semibold text-ink`,children:`Slopify updates`}),(0,h.jsx)(ev,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`Close updates`,className:`size-8 p-0`,children:(0,h.jsx)(Mk,{"aria-hidden":`true`,size:16})})})]}),i?(0,h.jsxs)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-x-5 gap-y-1 text-small`,children:[(0,h.jsx)(`dt`,{className:`text-ink3`,children:`Installed`}),(0,h.jsx)(`dd`,{className:`text-ink`,children:i.currentVersion}),(0,h.jsx)(`dt`,{className:`text-ink3`,children:`Latest release`}),(0,h.jsx)(`dd`,{className:`text-ink`,children:i.latestVersion??`Not available`})]}):null,(0,h.jsx)(`p`,{role:`status`,className:`mt-3 text-small text-ink2`,children:s?`Reconnecting to Slopify after the update… This tab will reload when it is ready.`:u?i?.status===`restarting`?`Restarting Slopify… This tab will reload when it is ready.`:`Installing Slopify… You can close this panel while it finishes.`:c?`Checking for updates…`:l?`The update could not finish. You can check again.`:i?.available?`A new version is ready to install.`:i?`No newer release is available.`:`Check for the latest Slopify release.`}),l?(0,h.jsx)(`p`,{role:`alert`,className:`mt-2 break-words text-small text-red`,children:l}):null,f&&!u?(0,h.jsx)(`p`,{id:r,className:`mt-2 text-small text-ink2`,children:f}):null,i?.available&&!u&&!f?(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink3`,children:`Save any edits first. Updating restarts Slopify and reloads this tab.`}):null,(0,h.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[i?.available||u?(0,h.jsx)(J,{variant:`primary`,disabled:!i?.canUpdate||i.busy||u||c,"aria-describedby":f&&!u?r:void 0,onClick:t.install,children:u?`Updating…`:`Update Slopify`}):null,(0,h.jsxs)(J,{variant:`ghost`,disabled:u||c,onClick:t.refresh,children:[(0,h.jsx)(Ak,{"aria-hidden":`true`,size:14}),`Check again`]})]}),(0,h.jsx)(`p`,{className:`mt-3 text-label text-ink3`,children:`Checks every 15 minutes. Installs only when you choose.`})]})})]})}var Hk=[{to:`/`,label:`Projects`,exact:!0},{to:`/play`,label:`Play`,exact:!0},{to:`/prompts`,label:`Prompts`,exact:!1},{to:`/entries`,label:`Intros & Outros`,exact:!1},{to:`/settings`,label:`Settings`,exact:!0},{to:`/usage`,label:`Usage`,exact:!0}],Uk=[{href:`https://github.com/GentBajko/slopify`,label:`GitHub`,glyph:`github`,tone:``},{href:`https://www.patreon.com/cw/GentBajko`,label:`Patreon`,glyph:`patreon`,tone:`text-lamp-run`},{href:`https://buymeacoffee.com/gentbajko`,label:`Buy Me a Coffee`,glyph:`coffee`,tone:`text-lamp-run`}];function Wk(){return(0,h.jsx)(fO,{children:(0,h.jsx)(ak,{children:(0,h.jsx)(Gk,{})})})}function Gk(){let{api:e,openEvents:t}=B(),n=_(),[r,i]=(0,m.useState)(0);return(0,m.useEffect)(()=>{let r=_O(()=>{n.invalidateQueries({queryKey:jy.projects})},200),a=Zy(t,Ao(e,`global`),{tally:i,stagingChanged:()=>{n.invalidateQueries({queryKey:jy.staging})},refetch:e=>{e===void 0?n.invalidateQueries():r.ask()}});return()=>{a(),r.stop()}},[e,t,n]),(0,h.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,h.jsxs)(`header`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-3 border-b border-line bg-panel px-4 min-[1280px]:flex min-[1280px]:h-14 min-[1280px]:gap-7 min-[1280px]:px-7`,children:[(0,h.jsxs)(ia,{to:`/`,className:`flex h-14 shrink-0 items-center gap-[10px] text-wordmark font-extrabold tracking-[-0.02em] text-ink`,children:[(0,h.jsx)(Ec,{className:`relative top-[3px] text-lamp-run`}),`Slopify`]}),(0,h.jsx)(`nav`,{"aria-label":`Main navigation`,className:`col-span-2 row-start-2 flex min-w-0 items-center gap-6 overflow-x-auto [scrollbar-width:thin] min-[1280px]:flex-1 min-[1280px]:gap-7`,children:Hk.map(e=>(0,h.jsx)(ia,{to:e.to,activeOptions:{exact:e.exact},className:`shrink-0 whitespace-nowrap border-b-2 border-transparent py-3 text-ink2 hover:text-ink focus-visible:outline-offset-[-3px] min-[1280px]:py-[18px]`,activeProps:{className:`!border-lamp-run !text-ink`},children:e.label},e.to))}),(0,h.jsxs)(`div`,{className:`col-start-2 row-start-1 ml-auto flex items-center gap-1 sm:gap-4 min-[1280px]:gap-7 [&_button]:min-h-8 [&_button]:min-w-8`,children:[(0,h.jsx)(Nk,{}),r===0?null:(0,h.jsxs)(ia,{to:`/`,"aria-label":`${String(r)} running`,title:`${String(r)} running`,className:`engraved flex min-h-8 items-center whitespace-nowrap text-ink3 hover:text-ink2`,children:[String(r),(0,h.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:`\xA0running`})]}),Uk.map(e=>(0,h.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,title:e.label,className:`flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,children:[(0,h.jsx)(Oc,{name:e.glyph,className:e.tone}),(0,h.jsx)(`span`,{className:`sr-only min-[1100px]:not-sr-only`,children:e.label})]},e.href))]})]}),(0,h.jsx)(`main`,{className:`min-w-0 flex-1 px-4 py-6 sm:px-7`,children:(0,h.jsx)(ya,{})}),(0,h.jsx)(`footer`,{className:`flex items-center gap-[18px] border-t border-line px-4 py-[14px] text-label sm:px-7 text-ink3`,children:(0,h.jsx)(`span`,{children:`Free. Your keys, your machine.`})}),(0,h.jsx)(Vk,{reload:()=>window.location.reload()}),(0,h.jsx)(Ky,{}),(0,h.jsx)(Uy,{}),(0,h.jsx)(qy,{reload:()=>{window.location.reload()}})]})}var Kk=[`text`,`llm`],qk=[`article`,`image`,`thumbnail`],Jk=[`intro`,`outro`],Yk=1e5,Xk=Jk.map(e=>({value:e,label:Qk(e)})),Zk=Kk.map(e=>({value:e,label:$k(e)}));function Qk(e){switch(e){case`intro`:return`Intro`;case`outro`:return`Outro`}}function $k(e){switch(e){case`text`:return`Text`;case`llm`:return`LLM`}}function eA(e){switch(e){case`text`:return`Text is narrated as written.`;case`llm`:return`LLM is an instruction whose answer is narrated.`}}function tA(e){switch(e){case`text`:return`No slots. This text is narrated as written.`;case`llm`:return`No slots. This instruction runs as written.`}}function nA(e){return Jk.find(t=>t===e)??`intro`}var rA=qk.map(e=>({value:e,label:iA(e)}));function iA(e){switch(e){case`article`:return`Article`;case`image`:return`Image`;case`thumbnail`:return`Thumbnail`}}function aA(e){return qk.find(t=>t===e)??`article`}function oA({open:e,title:t,consequence:n,verb:r,dismiss:i=`Cancel`,pending:a=!1,onConfirm:o,onCancel:s}){return(0,h.jsx)(Ty,{open:e,onOpenChange:e=>{e||s()},children:(0,h.jsxs)(Oy,{children:[(0,h.jsx)(ky,{children:t}),(0,h.jsx)(Ay,{children:n}),(0,h.jsxs)(`div`,{className:`flex justify-end gap-[10px]`,children:[(0,h.jsx)(J,{autoFocus:!0,onClick:s,children:i}),(0,h.jsx)(J,{variant:`danger`,disabled:a,onClick:o,children:r})]})]})})}function sA({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:W(`overflow-hidden rounded-panel border border-line bg-panel`,t),children:e})}function cA({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:W(`relative flex items-center gap-[14px] border-b border-line px-4 py-[14px] last:border-b-0`,t),children:e})}function lA({current:e,total:t}){let n=t<=0?0:Math.min(1,Math.max(0,e/t));return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-meter`,className:`absolute inset-x-0 bottom-0 h-[2px] bg-lamp-run transition-[width] duration-[250ms] ease-out motion-reduce:transition-none`,style:{width:`${String(Math.round(n*100))}%`}})}function uA({name:e,className:t}){return(0,h.jsx)(`span`,{"data-slot-chip":e,className:W(`engraved animate-tick-in rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] text-ink2 motion-reduce:animate-none`,t),children:e})}var dA=p_,fA=m_;function pA({className:e,sideOffset:t=4,align:n=`end`,...r}){return(0,h.jsx)(h_,{children:(0,h.jsx)(g_,{"data-slot":`dropdown-menu-content`,sideOffset:t,align:n,className:W(`z-50 min-w-[160px] overflow-hidden rounded-panel border border-line bg-panel p-1`,`shadow-[0_8px_24px_var(--color-shadow)]`,e),...r})})}function mA({className:e,...t}){return(0,h.jsx)(__,{"data-slot":`dropdown-menu-item`,className:W(`flex cursor-default items-center rounded-control px-[10px] py-[5px] text-small text-ink`,`outline-hidden select-none focus:bg-panel2 data-highlighted:bg-panel2`,e),...t})}function hA({className:e,...t}){return(0,h.jsx)(py,{"data-slot":`toggle-group`,className:W(`inline-flex w-fit items-stretch overflow-hidden rounded-control border border-line2`,e),...t})}function gA({className:e,...t}){return(0,h.jsx)(Sy,{"data-slot":`toggle-group-item`,className:W(`min-h-8 shrink-0 border-r border-line2 px-[10px] py-[5px] text-label text-ink2 last:border-r-0`,`transition-colors duration-150 ease-out motion-reduce:transition-none hover:bg-panel2 hover:text-ink`,`data-[state=on]:bg-panel2 data-[state=on]:text-ink data-[state=on]:shadow-[inset_0_-2px_0_var(--color-lamp-run)]`,`disabled:cursor-not-allowed disabled:opacity-40`,e),...t})}var _A=`grid grid-cols-[minmax(0,1fr)_auto_auto_32px] items-center gap-x-[14px] gap-y-[6px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[260px_70px_minmax(0,1fr)_auto_32px]`,vA=`col-span-4 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1 md:col-start-3 md:row-start-1`;function yA({category:e,onCategory:t}){let{api:n}=B(),r=_(),i=R(zy(n)),[a,o]=(0,m.useState)(void 0),s=tt({mutationFn:e=>ko(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:jy.entries})}}),c=i.data?.entries.filter(t=>t.category===e);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:`Intros & Outros`}),(0,h.jsxs)(`div`,{className:`mb-4 flex items-center gap-4`,children:[(0,h.jsx)(hA,{type:`single`,value:e,"aria-label":`Entry category`,onValueChange:e=>{let n=Xk.find(t=>t.value===e);n!==void 0&&t(n.value)},children:Xk.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(J,{asChild:!0,children:(0,h.jsxs)(ia,{to:`/entries/new`,search:{category:e},children:[(0,h.jsx)(kk,{"aria-hidden":`true`,className:`size-[14px]`}),`New entry`]})})]}),i.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:i.error.message})}),c===void 0?i.error===null?(0,h.jsx)(CA,{}):null:c.length===0?(0,h.jsx)(xA,{category:e}):(0,h.jsx)(sA,{children:c.map(e=>(0,h.jsxs)(`div`,{className:_A,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(bA,{mode:e.mode}),(0,h.jsx)(`span`,{className:vA,children:e.slots.map(e=>(0,h.jsx)(uA,{name:e},e))}),(0,h.jsx)(J,{className:`col-start-3 row-start-1 md:col-start-4`,asChild:!0,children:(0,h.jsx)(ia,{to:`/entries/$entryId`,params:{entryId:e.id},children:`Edit`})}),(0,h.jsx)(SA,{entry:e,onDelete:()=>{o(e)}})]},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{className:`mt-[10px] text-label text-red`,children:s.error.message}),(0,h.jsx)(oA,{open:a!==void 0,title:a===void 0?``:`Delete "${a.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>{o(void 0)}})]})}function bA({mode:e}){return(0,h.jsx)(`span`,{"data-entry-mode":e,className:`engraved col-start-2 row-start-1 justify-self-start rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] font-bold text-ink`,children:$k(e)})}function xA({category:e}){return(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`max-w-[75ch] px-4 py-7 text-ink2`,children:`No ${e}s yet. An ${e} is narrated ${e===`intro`?`before`:`after`} the body in the run's voice.`})})}function SA({entry:e,onDelete:t}){return(0,h.jsxs)(dA,{children:[(0,h.jsx)(fA,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-4 row-start-1 size-8 p-0 md:col-start-5`,children:(0,h.jsx)(Dk,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(pA,{children:[(0,h.jsx)(mA,{asChild:!0,children:(0,h.jsx)(ia,{to:`/entries/new`,search:{category:e.category,from:e.id},children:`Duplicate`})}),(0,h.jsx)(mA,{onSelect:t,children:`Delete`})]})]})}function CA(){return(0,h.jsx)(sA,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:_A,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-[18px] w-10 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:vA,children:(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`})}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-4`})]},e))})}function wA({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)(`h2`,{className:`engraved text-ink3`,children:`Detected slots`}),e.length>0?(0,h.jsx)(`div`,{className:`flex flex-wrap gap-[6px]`,children:e.map(e=>(0,h.jsx)(uA,{name:e,className:`px-2 py-[3px]`},e))}):t.trim()===``?(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`Slots appear here as you type {{name}}.`}):(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:i}),n.length===0?null:(0,h.jsxs)(`div`,{id:r,className:`flex flex-col gap-[6px] border-t border-line pt-3`,children:[(0,h.jsx)(`span`,{className:`engraved text-red`,children:n.length===1?`1 slot error`:`${String(n.length)} slot errors`}),n.map(e=>(0,h.jsx)(`span`,{className:`text-small text-red`,children:e.message},e.message))]})]})}var TA=2e3;function EA(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()},TA);return()=>{clearTimeout(t)}},[e])}function DA(){return(0,h.jsxs)(`span`,{className:`inline-flex animate-tick-in items-center gap-1 text-label text-done motion-reduce:animate-none`,children:[(0,h.jsx)(bk,{"aria-hidden":`true`,className:`size-[14px]`}),`Saved`]})}function OA({onDelete:e,blocked:t,blockedId:n,pending:r,saved:i,cancel:a,errors:o,onSave:s}){let c=t!==void 0||r||i;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px] border-t border-line pt-[14px]`,children:[e===void 0?null:(0,h.jsx)(J,{className:`bg-transparent`,onClick:e,children:`Delete`}),(0,h.jsx)(`span`,{className:`flex-1`}),i?(0,h.jsx)(DA,{}):null,t===void 0?null:(0,h.jsx)(`span`,{id:n,className:`text-small text-ink2`,children:t}),a,(0,h.jsx)(J,{variant:`primary`,"aria-disabled":c,"aria-describedby":t===void 0?void 0:n,onClick:()=>{c||s()},children:`Save`}),o.map(e=>(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:e},e))]})}var kA=`rounded-panel border border-line bg-panel p-[18px]`;function AA(){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:`${kA} flex flex-col gap-[14px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-64 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[520px] rounded-control bg-panel2`})]}),(0,h.jsx)(`div`,{className:`${kA} flex flex-col gap-3`,children:(0,h.jsx)(`span`,{className:`h-3 w-28 rounded-control bg-panel2`})})]})}function jA({children:e,back:t}){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:e})}),t]})}var MA=`mt-[10px] inline-block text-small text-run-text underline`;function NA({className:e,...t}){return(0,h.jsx)(y_,{"data-slot":`label`,className:W(`engraved block select-none text-ink3`,e),...t})}function PA({label:e,value:t,options:n,describedBy:r,onPick:i}){let a=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(NA,{id:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(hA,{type:`single`,value:t,"aria-labelledby":a,"aria-describedby":r,onValueChange:e=>{let t=n.find(t=>t.value===e);t!==void 0&&i(t.value)},children:n.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))})]})}function FA({className:e,...t}){return(0,h.jsx)(`input`,{"data-slot":`input`,className:W(`h-8 w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}function IA({className:e,...t}){return(0,h.jsx)(`textarea`,{"data-slot":`textarea`,className:W(`w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}var LA=`{{`,RA=`}}`;function zA(e){let t=[],n=[],r=e.indexOf(LA);for(;r!==-1;){let i=e.indexOf(`
98
+ 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 FT(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;FT(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 IT=new Set([`type`,`properties`,`required`,`additionalProperties`]),LT=[`oneOf`,`anyOf`];function RT(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function zT(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!IT.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]??RT(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}_b(n,r,e.length===1?e[0]:zT(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=RT(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 BT(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of IT)if(t in e)return;let n=t.filter(e=>LT.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=zT(t);else{let e=n[0],i=LT.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=>zT([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,kT(e,r))}function VT(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)):kT(i,s),kT(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())FT(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)??[])BT(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)}kT(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,_b(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:WT(t,`input`,e.processors),output:WT(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function HT(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 HT(r.element,n);if(r.type===`set`)return HT(r.valueType,n);if(r.type===`lazy`)return HT(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 HT(r.innerType,n);if(r.type===`intersection`)return HT(r.left,n)||HT(r.right,n);if(r.type===`record`||r.type===`map`)return HT(r.keyType,n)||HT(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:HT(r.in,n)||HT(r.out,n);if(r.type===`object`){for(let e in r.shape)if(HT(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(HT(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(HT(e,n))return!0;return!!(r.rest&&HT(r.rest,n))}return!1}var UT=(e,t={})=>n=>{let r=AT({...n,processors:t});return MT(e,r),PT(r,e),VT(r,e)},WT=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=AT({...i??{},target:a,io:t,processors:n});return MT(e,o),PT(o,e),VT(o,e)},GT={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},KT=(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=GT[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}))])}},qT=(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):jT(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},JT=(e,t,n,r)=>{n.not={}},YT=(e,t,n,r)=>{let i=e._zod.def,a=ub(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},XT=(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(jT(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(jT(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}},ZT=(e,t,n,r)=>{jT(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},QT=(e,t,n,r)=>{jT(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},$T=(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=MT(a.element,t,{...r,path:[...r.path,`items`]})};function eE(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?eE(t.out):t.type===`catch`?eE(t.innerType):e._zod.optin}var tE=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&jT(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)_b(i.properties,e,MT(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`?eE(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=MT(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},nE=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>MT(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},rE=(e,t,n,r)=>{let i=e._zod.def,a=MT(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=MT(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=e._zod.def,a=MT(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`}]},aE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},oE=Symbol();function sE(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(jT(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),oE):JSON.parse(o)}var cE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=sE(i.defaultValue,e,t,n,r);o!==oE&&(n.default=o)},lE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=sE(i.defaultValue,e,t,n,r);o!==oE&&(n._prefault=o)},uE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{jT(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},dE=(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;MT(o,t,r);let s=t.seen.get(e);s.ref=o},fE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},pE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},mE=new WeakSet([Object.prototype,Error.prototype]);function hE(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 gE=X(`ZodError`,(e,t)=>{Cx.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);mE.has(n)||(mE.add(n),hE(n,`format`,e=>t=>Dx(e,t)),hE(n,`flatten`,e=>t=>Ex(e,t)),hE(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,fb,2)}),hE(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,fb,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),_E=kx(gE),vE=Ax(gE),yE=jx(gE),bE=Nx(gE),xE=Fx(gE),SE=Ix(gE),CE=Lx(gE),wE=Rx(gE),TE=zx(gE),EE=Bx(gE),DE=Vx(gE),OE=Hx(gE);function kE(){mx.localeError||hx(Cw())}function AE(){mx.memoizer||hx({memoizer:bw()})}var jE=X(`ZodType`,(e,t)=>(kE(),VS.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(vb(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 Ob(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(KD(e,t))},superRefine(e,t){return this.check(qD(e,t))},overwrite(e){return this.check(yT(e))},optional(){return OD(this)},exactOptional(){return AD(this)},nullable(){return MD(this)},nullish(){return OD(MD(this))},nonoptional(e){return RD(this,e)},array(){return mD(this)},or(e){return vD([this,e])},and(e){return bD(this,e)},transform(e){return HD(this,ED(e))},default(e){return PD(this,e)},prefault(e){return ID(this,e)},catch(e){return BD(this,e)},pipe(e){return HD(this,e)},readonly(){return WD(this)},describe(e){let t=this.clone();return Dw.add(t,{description:e}),t},meta(...e){if(e.length===0)return Dw.get(this);let t=this.clone();return Dw.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 Qb(this,`~standard`,{...US(this),jsonSchema:{input:WT(this,`input`),output:WT(this,`output`)}})},set"~standard"(e){Zb(this,`~standard`,e)},parse:function e(t,n){return _E(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await vE(this,t,n,{callee:e})},safeParse(e,t){return yE(this,e,t)},async safeParseAsync(e,t){return bE(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Zb(this,`spa`,e)},encode:function e(t,n){return xE(this,t,n,{callee:e})},decode:function e(t,n){return SE(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await CE(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await wE(this,t,n,{callee:e})},safeEncode(e,t){return TE(this,e,t)},safeDecode(e,t){return EE(this,e,t)},async safeEncodeAsync(e,t){return DE(this,e,t)},async safeDecodeAsync(e,t){return OE(this,e,t)},toJSONSchema(e){return UT(this,{})(e)},get description(){return Dw.get(this)?.description},get _def(){return this._zod.def}}),ME=X(`_ZodString`,(e,t)=>{WS.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>KT(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(pT(...e))},includes(...e){return this.check(gT(...e))},startsWith(...e){return this.check(_T(...e))},endsWith(...e){return this.check(vT(...e))},min(...e){return this.check(dT(...e))},max(...e){return this.check(uT(...e))},length(...e){return this.check(fT(...e))},nonempty(...e){return this.check(dT(1,...e))},lowercase(e){return this.check(mT(e))},uppercase(e){return this.check(hT(e))},trim(){return this.check(xT())},normalize(...e){return this.check(bT(...e))},toLowerCase(){return this.check(ST())},toUpperCase(){return this.check(CT())},slugify(){return this.check(wT())}}),NE=X(`ZodString`,(e,t)=>{WS.init(e,t),ME.init(e,t)},{email(e){return this.check(kw(BE,e))},url(e){return this.check(Fw(UE,e))},jwt(e){return this.check(Xw(iD,e))},emoji(e){return this.check(Iw(WE,e))},guid(e){return this.check(Aw(VE,e))},uuid(e){return this.check(jw(HE,e))},uuidv4(e){return this.check(Mw(HE,e))},uuidv6(e){return this.check(Nw(HE,e))},uuidv7(e){return this.check(Pw(HE,e))},nanoid(e){return this.check(Lw(GE,e))},cuid(e){return this.check(Rw(KE,e))},cuid2(e){return this.check(zw(qE,e))},ulid(e){return this.check(Bw(JE,e))},base64(e){return this.check(qw(tD,e))},base64url(e){return this.check(Jw(nD,e))},xid(e){return this.check(Vw(YE,e))},ksuid(e){return this.check(Hw(XE,e))},ipv4(e){return this.check(Uw(ZE,e))},ipv6(e){return this.check(Ww(QE,e))},cidrv4(e){return this.check(Gw($E,e))},cidrv6(e){return this.check(Kw(eD,e))},e164(e){return this.check(Yw(rD,e))},datetime(e){return this.check(Zw(IE,e))},date(e){return this.check(Qw(LE,e))},time(e){return this.check($w(RE,e))},duration(e){return this.check(eT(zE,e))}});function PE(e){return Ow(NE,e)}var FE=X(`ZodStringFormat`,(e,t)=>{GS.init(e,t),ME.init(e,t)}),IE=X(`ZodISODateTime`,(e,t)=>{cC.init(e,t),FE.init(e,t)}),LE=X(`ZodISODate`,(e,t)=>{lC.init(e,t),FE.init(e,t)}),RE=X(`ZodISOTime`,(e,t)=>{uC.init(e,t),FE.init(e,t)}),zE=X(`ZodISODuration`,(e,t)=>{dC.init(e,t),FE.init(e,t)}),BE=X(`ZodEmail`,(e,t)=>{JS.init(e,t),FE.init(e,t)}),VE=X(`ZodGUID`,(e,t)=>{KS.init(e,t),FE.init(e,t)}),HE=X(`ZodUUID`,(e,t)=>{qS.init(e,t),FE.init(e,t)}),UE=X(`ZodURL`,(e,t)=>{eC.init(e,t),FE.init(e,t)}),WE=X(`ZodEmoji`,(e,t)=>{tC.init(e,t),FE.init(e,t)}),GE=X(`ZodNanoID`,(e,t)=>{nC.init(e,t),FE.init(e,t)}),KE=X(`ZodCUID`,(e,t)=>{rC.init(e,t),FE.init(e,t)}),qE=X(`ZodCUID2`,(e,t)=>{iC.init(e,t),FE.init(e,t)}),JE=X(`ZodULID`,(e,t)=>{aC.init(e,t),FE.init(e,t)}),YE=X(`ZodXID`,(e,t)=>{oC.init(e,t),FE.init(e,t)}),XE=X(`ZodKSUID`,(e,t)=>{sC.init(e,t),FE.init(e,t)}),ZE=X(`ZodIPv4`,(e,t)=>{fC.init(e,t),FE.init(e,t)}),QE=X(`ZodIPv6`,(e,t)=>{hC.init(e,t),FE.init(e,t)}),$E=X(`ZodCIDRv4`,(e,t)=>{gC.init(e,t),FE.init(e,t)}),eD=X(`ZodCIDRv6`,(e,t)=>{vC.init(e,t),FE.init(e,t)}),tD=X(`ZodBase64`,(e,t)=>{bC.init(e,t),FE.init(e,t)}),nD=X(`ZodBase64URL`,(e,t)=>{SC.init(e,t),FE.init(e,t)}),rD=X(`ZodE164`,(e,t)=>{CC.init(e,t),FE.init(e,t)}),iD=X(`ZodJWT`,(e,t)=>{TC.init(e,t),FE.init(e,t)}),aD=X(`ZodNumber`,(e,t)=>{EC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qT(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(sT(e,t))},gte(e,t){return this.check(cT(e,t))},min(e,t){return this.check(cT(e,t))},lt(e,t){return this.check(aT(e,t))},lte(e,t){return this.check(oT(e,t))},max(e,t){return this.check(oT(e,t))},int(e){return this.check(cD(e))},safe(e){return this.check(cD(e))},positive(e){return this.check(sT(0,e))},nonnegative(e){return this.check(cT(0,e))},negative(e){return this.check(aT(0,e))},nonpositive(e){return this.check(oT(0,e))},multipleOf(e,t){return this.check(lT(e,t))},step(e,t){return this.check(lT(e,t))},finite(){return this}});function oD(e){return tT(aD,e)}var sD=X(`ZodNumberFormat`,(e,t)=>{DC.init(e,t),aD.init(e,t)});function cD(e){return nT(sD,e)}var lD=X(`ZodUnknown`,(e,t)=>{OC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function uD(){return rT(lD)}var dD=X(`ZodNever`,(e,t)=>{kC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JT(e,t,n,r)});function fD(e){return iT(dD,e)}var pD=X(`ZodArray`,(e,t)=>{AE(),jC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$T(e,t,n,r),e.element=t.element},{min(e,t){return this.check(dT(e,t))},nonempty(e){return this.check(dT(1,e))},max(e,t){return this.check(uT(e,t))},length(e,t){return this.check(fT(e,t))},unwrap(){return this.element}});function mD(e,t){return TT(pD,e,t)}var hD=X(`ZodObject`,(e,t)=>{AE(),RC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tE(e,t,n,r),ax(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return SD(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:uD()})},loose(){return this.clone({...this._zod.def,catchall:uD()})},strict(){return this.clone({...this._zod.def,catchall:fD()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Pb(this,e)},safeExtend(e){return Fb(this,e)},merge(e){return Ib(this,e)},pick(e){return Mb(this,e)},omit(e){return Nb(this,e)},partial(...e){return Lb(DD,this,e[0])},exactPartial(...e){return Lb(kD,this,e[0],`exactPartial`)},required(...e){return Rb(LD,this,e[0])}});function gD(e,t){return new hD({type:`object`,shape:e??{},...Y(t)})}var _D=X(`ZodUnion`,(e,t)=>{BC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nE(e,t,n,r),e.options=t.options});function vD(e,t){return new _D({type:`union`,options:e,...Y(t)})}var yD=X(`ZodIntersection`,(e,t)=>{VC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rE(e,t,n,r)});function bD(e,t){return new yD({type:`intersection`,left:e,right:t})}var xD=X(`ZodEnum`,(e,t)=>{WC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>YT(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 xD({...t,checks:[],...Y(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 xD({...t,checks:[],...Y(r),entries:i})}});function SD(e,t){return new xD({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Y(t)})}var CD=X(`ZodLiteral`,(e,t)=>{GC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>XT(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 wD(e,t){return new CD({type:`literal`,values:Array.isArray(e)?e:[e],...Y(t)})}var TD=X(`ZodTransform`,(e,t)=>{AE(),KC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>QT(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new px(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Yb(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(Yb(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ED(e){return new TD({type:`transform`,transform:e})}var DD=X(`ZodOptional`,(e,t)=>{JC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function OD(e){return new DD({type:`optional`,innerType:e})}var kD=X(`ZodExactOptional`,(e,t)=>{YC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function AD(e){return new kD({type:`optional`,innerType:e})}var jD=X(`ZodNullable`,(e,t)=>{XC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function MD(e){return new jD({type:`nullable`,innerType:e})}var ND=X(`ZodDefault`,(e,t)=>{ZC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function PD(e,t){return new ND({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Tb(t)}})}var FD=X(`ZodPrefault`,(e,t)=>{$C.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ID(e,t){return new FD({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Tb(t)}})}var LD=X(`ZodNonOptional`,(e,t)=>{ew.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function RD(e,t){return new LD({type:`nonoptional`,innerType:e,...Y(t)})}var zD=X(`ZodCatch`,(e,t)=>{rw.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function BD(e,t){return new zD({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:sx(t)})}var VD=X(`ZodPipe`,(e,t)=>{iw.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dE(e,t,n,r),e.in=t.in,e.out=t.out});function HD(e,t){return new VD({type:`pipe`,in:e,out:t})}var UD=X(`ZodReadonly`,(e,t)=>{ow.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function WD(e){return new UD({type:`readonly`,innerType:e})}var GD=X(`ZodCustom`,(e,t)=>{cw.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ZT(e,t,n,r)});function KD(e,t={}){return ET(GD,e,t)}function qD(e,t){return DT(e,t)}var JD=[`off`,`files`,`burn-in`],YD=[`top`,`upper-middle`,`center`,`lower-middle`,`bottom`],XD=gD({mode:SD(JD),language:wD(`en`).default(`en`),fontId:PE().max(160).regex(/^[A-Za-z0-9_-]+$/).default(`default`),position:SD(YD).default(`bottom`),fontSize:oD().int().min(16).max(120).default(48)}),ZD={mode:`off`,language:`en`,fontId:`default`,fontSize:48,position:`bottom`};function QD(e,t){let n={...ZD,...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=XD.shape.fontId.safeParse(n.fontId),a=XD.shape.fontSize.safeParse(n.fontSize);return{...n,mode:r,fontId:i.success?i.data:ZD.fontId,fontSize:a.success?a.data:ZD.fontSize}}function $D(e,t){return e.mode===t.mode&&e.language===t.language&&e.fontId===t.fontId&&e.fontSize===t.fontSize&&(e.position??`bottom`)===(t.position??`bottom`)}function eO(e){return e.mode===`off`||e.fontId!==``&&Number.isInteger(e.fontSize)&&e.fontSize>=16&&e.fontSize<=120}var tO={title:``,format:`16:9`,sources:{research:`off`,article:`generate`,audio:`generate`,images:`generate`,thumbnail:`off`,video:`generate`},llm:{provider:``,model:``},audio:{provider:``,model:``,voice:``},images:{provider:``,model:``},articlePrompt:``,imagePrompts:[],thumbnailPrompt:``,intro:``,outro:``,chunking:{mode:`whole`},subtitles:ZD,values:{},provided:{research:``,article:``,audio:void 0,images:[],thumbnail:void 0}},nO={off:`Off`,generate:`Generate`,provide:`Provide`,from_prompt:`From prompt`,prompt_by_llm:`Prompt by LLM`};function rO(e){return tb[e].map(e=>({value:e,label:nO[e]}))}function iO(e,t){return e.sources.article===`generate`||e.sources.thumbnail===`prompt_by_llm`||e.sources.audio===`generate`&&(aO(t,`intro`,e.intro)===`llm`||aO(t,`outro`,e.outro)===`llm`)}function aO(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.mode}function oO(e){return[e.audio,e.thumbnail,...e.images].flatMap(e=>e?.file===void 0?[]:[e.file])}function sO(e){let{form:t}=e;return{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,articlePrompt:t.articlePrompt,imagePrompts:t.imagePrompts,thumbnailPrompt:t.thumbnailPrompt,...cO(lO(e,`intro`),e=>({intro:e})),...cO(lO(e,`outro`),e=>({outro:e})),values:uO(t.values,e.slots),provided:{research:t.provided.research,article:t.provided.article,...cO(t.provided.audio?.file,e=>({audio:e.id})),...cO(t.provided.thumbnail?.file,e=>({thumbnail:e.id})),images:t.provided.images.flatMap(e=>e.file===void 0?[]:[e.file.id])},chunking:t.chunking,subtitles:QD(t.subtitles,t.sources),silenceGapSeconds:e.silenceGapSeconds}}function cO(e,t){return e===void 0?{}:t(e)}function lO(e,t){if(e.form.sources.audio!==`generate`)return;let n=t===`intro`?e.form.intro:e.form.outro,r=aO(e.entries,t,n);return n===``||r===void 0?void 0:{name:n,mode:r}}function uO(e,t){let n=Object.create(null);for(let r of t)n[r]=Object.hasOwn(e,r)?e[r]??``:``;return n}var dO=(0,m.createContext)(void 0);function fO({children:e}){let[t,n]=(0,m.useState)(()=>new Map),[r,i]=(0,m.useState)(tO),a=(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})},[]),o=(0,m.useMemo)(()=>({prompts:t,updatePrompt:a,play:r,updatePlay:i}),[t,a,r]);return(0,h.jsx)(dO.Provider,{value:o,children:e})}function pO(e){let t=(0,m.useContext)(dO),[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 mO(){let e=(0,m.useContext)(dO),[t,n]=(0,m.useState)(tO);return e?[e.play,e.updatePlay]:[t,n]}function hO(e,t){if(e===void 0)return;if(t.type===`project.state`)return{...e,project:{...e.project,status:t.state}};let n=e.stages.findIndex(e=>e.kind===t.stage),r=e.stages[n];return r===void 0?e:{...e,stages:e.stages.with(n,gO(r,t))}}function gO(e,t){return t.type===`stage.progress`?{...e,progressCurrent:t.current,progressTotal:t.total}:{...e,state:t.state,failureReason:t.failureReason??e.failureReason}}function _O(e,t){let n,r=!1,i=()=>{n=void 0,r&&(r=!1,e(),a())},a=()=>{n=setTimeout(i,t)};return{ask:()=>{if(n!==void 0){r=!0;return}e(),a()},stop:()=>{n!==void 0&&clearTimeout(n),n=void 0,r=!1}}}var vO=[{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-article`,title:`11. Choose what to write`,target:`play-article`,page:`play`},{id:`play-audio`,title:`12. Choose the narration`,target:`play-audio`,page:`play`},{id:`play-images`,title:`13. Choose the images`,target:`play-images`,page:`play`},{id:`play-video`,title:`14. Choose your final output`,target:`play-video`,page:`play`},{id:`play-subtitles`,title:`15. Add optional subtitles`,target:`play-subtitles`,page:`play`},{id:`play-options`,title:`16. Name and configure your project`,target:`play-options`,page:`play`},{id:`play-keywords`,title:`17. Fill in your keywords`,target:`play-keywords`,page:`play`},{id:`play-start`,title:`18. Review and press PLAY`,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`}];function yO(e,t){return e.active?t.type===`project-created`?{...e,projectId:t.id,step:vO.findIndex(e=>e.id===`project`)}:t.kind===`article`?{...e,articleId:t.id}:t.kind===`image`?{...e,imageId:t.id}:e:e}var bO={research:`Research`,article:`Article`,audio:`Audio`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`};function xO(e){return e.sources.video===`off`?e.sources.audio===`off`?`article`:`audio`:`video`}function SO(e,t){return e===`video`&&xO(t)===`audio`?`Audio export`:bO[e]}var CO={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(jO(e,t))}% rendered`},wO={audio_intro:`intro`,audio_body:`body`,audio_outro:`outro`};function TO(e,t,n){let r=t.filter(t=>t.stageKind===e.kind);switch(e.state){case`skipped`:return`Not part of this run`;case`pending`:return n.status===`paused`?`Waiting for Resume`:e.kind===`images`||e.kind===`thumbnail`&&e.source===`from_prompt`?`Ready to run`:`Waits for the stages above`;case`provided`:return OO(r)??`Provided`;case`failed`:return`Stopped after ${EO(e)}`;case`canceled`:return`Canceled by user`;case`running`:return e.kind===`video`&&xO(n.config)===`audio`?`Exporting combined audio`:e.progressTotal===null||e.progressTotal<=0?`Running`:CO[e.kind](e.progressCurrent??0,e.progressTotal);case`done`:return DO(e.kind,r,n)}}function EO(e){return e.attemptCount===1?`1 attempt`:`${String(e.attemptCount)} attempts`}function DO(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 FO([NO(t.flatMap(e=>{let t=wO[e.role];return t===void 0?[]:[t]})),AO(kO(t))]);case`images`:return MO(t.filter(e=>e.role===`image`).length,`image`);case`thumbnail`:return t.length===0?`Thumbnail ready`:`1 image`;case`video`:return FO([AO(kO(t)),xO(n.config)===`audio`?`WAV · stereo · 48 kHz`:n.format])}}function OO(e){let t=e.flatMap(e=>e.originalFilename===null?[]:[e.originalFilename]);return t.length===0?void 0:t.join(`, `)}function kO(e){let t=Math.max(0,...e.map(e=>e.durationMs??0));return t===0?void 0:t}function AO(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 jO(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function MO(e,t){return e===1?`1 ${t}`:`${String(e)} ${t}s`}function NO(e){if(e.length!==0)return e.length===1?PO(e[0]??``):PO(`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]??``}`)}function PO(e){return e.charAt(0).toUpperCase()+e.slice(1)}function FO(e){return e.filter(e=>e!==void 0&&e!==``).join(` · `)}var IO=12,LO=16;function RO(e,t,n){return Math.max(t,Math.min(e,Math.max(t,n)))}function zO(e,t,n){let r=Math.min(n.width,t.width-24),i=RO(e?.left??(t.width-r)/2,IO,t.width-r-IO),a=RO((e?.top??0)+((e?.height??t.height)-n.height)/2,IO,t.height-n.height-IO),o=t.height-n.height-IO;if(!e)return{left:i,top:a,width:r,docked:!1};let s=e.left+e.width,c=e.top+e.height;return s+LO+r<=t.width-IO?{left:s+LO,top:a,width:r,docked:!1}:e.left-LO-r>=IO?{left:e.left-LO-r,top:a,width:r,docked:!1}:c>=IO&&c+LO+n.height<=t.height-IO?{left:i,top:c+LO,width:r,docked:!1}:e.top-LO-n.height>=IO&&e.top<=t.height-IO?{left:i,top:e.top-LO-n.height,width:r,docked:!1}:{left:t.width-r-IO,top:Math.max(IO,o),width:r,docked:!0}}function BO(e,t,n=t.height){let r=RO(e.left-6,0,t.width),i=RO(e.top-6,0,Math.min(n,t.height)),a=RO(e.left+e.width+6,0,t.width),o=RO(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 VO=`[data-slot="select-content"], [data-slot="dropdown-menu-content"]`;function HO(e){try{return document.querySelector(e)}catch{return null}}function UO(){return[...document.querySelectorAll(`[data-slot="dialog-content"][data-state="open"]`)].at(-1)??null}function WO(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(VO)].filter(e=>n.has(e.id))}function GO(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 KO=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable="true"]`;function qO(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=HO(e);return[t,n.current,...WO(t)].filter(e=>e!==null)},i=e=>e instanceof Node&&t().some(t=>t.contains(e)),o=e=>{UO()||i(e.target)||(e.preventDefault(),e.stopImmediatePropagation())},s=e=>{UO()||i(e.target)||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-radix-focus-guard`)||r.current?.focus({preventScroll:!0})},c=n=>{if(UO())return;let r=WO(HO(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(KO)]).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 JO(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:UO()!==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=HO(t);r!==u&&(u&&f.unobserve(u),r&&f.observe(r),u=r);let i=r?GO(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=WO(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(GO).filter(e=>e!==null),width:window.innerWidth,height:window.innerHeight,cardHeight:n.current?.getBoundingClientRect().height||260,modalOpen:UO()!==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(),UO()||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 YO({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=JO(p,t,g,_,v,y);qO(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=zO(C,w,T),D=C?BO(C,w,E.docked?E.top-12:w.height):null,O=b.key===p?b.portals.map(e=>BO(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,$c.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-panel border border-line2 bg-panel p-4 text-body text-ink shadow-[0_8px_24px_var(--color-shadow)]`,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-run-text`,children:[`Getting started · `,i]}),(0,h.jsx)(J,{variant:`ghost`,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 font-bold outline-none`,children:n}),(0,h.jsxs)(`div`,{id:`${f}-instructions`,className:`min-h-0 overflow-y-auto text-ink2 [&_p+p]:mt-2 [&_code]:text-ink`,children:[r,!C&&(0,h.jsx)(`p`,{role:`status`,className:`mt-3 text-amber`,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)(J,{onClick:o,children:`Back`}),u&&(0,h.jsx)(J,{variant:`ghost`,onClick:u,className:`px-2`,children:d}),(0,h.jsx)(J,{variant:`primary`,onClick:a,disabled:l||!C,className:`ml-auto`,children:c})]})]})]})]}),document.body)}function XO({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 ZO({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-line2 bg-panel2 p-3 text-small leading-relaxed`,children:e}),(0,h.jsx)(J,{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]})}function QO({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)(XO,{href:`https://openrouter.ai/settings/keys`,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 and press`,` `,(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-ink3`,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`,` `,(0,h.jsx)(`strong`,{children:`ElevenLabs`}),`, `,(0,h.jsx)(`strong`,{children:`OpenAI`}),`, or `,(0,h.jsx)(`strong`,{children:`Cartesia`}),`; you do not need all three.`]}),(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 and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(XO,{href:`https://elevenlabs.io/app/developers/api-keys`,children:`ElevenLabs keys`}),` `,`· `,(0,h.jsx)(XO,{href:`https://platform.openai.com/api-keys`,children:`OpenAI keys`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://play.cartesia.ai/keys`,children:`Cartesia keys`})]}),(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, create a key in its dashboard, paste it into the matching row, and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(XO,{href:`https://fal.ai/dashboard/keys`,children:`fal.ai`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://replicate.com/account/api-tokens`,children:`Replicate`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://aistudio.google.com/apikey`,children:`Google AI Studio`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://platform.openai.com/api-keys`,children:`OpenAI`})]}),(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 $O=`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.`,ek=`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 tk({step:e,output:t=`video`}){switch(e){case`text-key`:case`audio-key`:case`image-key`:case`voice`:return(0,h.jsx)(QO,{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)(ZO,{text:$O}),(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)(ZO,{text:ek}),(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 chunking 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)(`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`}),`, select your image prompt, and set`,` `,(0,h.jsx)(`strong`,{children:`Number`}),` to 2 for a small first run.`]}),(0,h.jsx)(`p`,{children:`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:[`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:`Video title`}),`, such as “A quick trip to Albania.” Choose`,` `,(0,h.jsx)(`strong`,{children:`16:9`}),` for landscape or `,(0,h.jsx)(`strong`,{children:`9:16`}),` for portrait.`]}),(0,h.jsxs)(`p`,{children:[`Select the text `,(0,h.jsx)(`strong`,{children:`LLM`}),` and `,(0,h.jsx)(`strong`,{children:`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.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Intro`}),` and `,(0,h.jsx)(`strong`,{children:`Outro`}),` Off for this first run. They are available only 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.jsxs)(`p`,{children:[`A field under `,(0,h.jsx)(`strong`,{children:`Common`}),` feeds both the article and images. Changing it changes both prompts 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:`Check the hint above PLAY. 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:`PLAY`}),` 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 finish the tutorial without generating anything.`})]});case`project`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Overall progress stays above the workspace. Select a stage from `,(0,h.jsx)(`strong`,{children:`Stages`}),` `,`to see its results or live writing. Press `,(0,h.jsx)(`strong`,{children:`Pause`}),` to stop active requests safely and keep finished work.`]}),(0,h.jsxs)(`p`,{children:[`While paused or failed, open `,(0,h.jsx)(`strong`,{children:`Run settings`}),` to change providers, models or voice. Press `,(0,h.jsx)(`strong`,{children:`Save providers`}),`, then `,(0,h.jsx)(`strong`,{children:`Resume`}),` `,`separately. Changing TTS choices restarts unfinished narration to avoid mixing voices; completed outputs stay unchanged.`]}),(0,h.jsxs)(`p`,{children:[`Select a failed stage and open `,(0,h.jsx)(`strong`,{children:`Error details`}),` to read the provider’s message. `,(0,h.jsx)(`strong`,{children:`Retry stage`}),` keeps completed outputs. Editing or rerunning earlier work updates only the enabled dependent outputs.`]})]});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 .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 .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 `,(0,h.jsx)(`strong`,{children:`Stages`}),` 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.`]}),(0,h.jsxs)(`p`,{children:[`You have reached the end. Open `,(0,h.jsx)(`strong`,{children:`Tutorial`}),` in the navigation anytime to walk through these steps again.`]})]})}}function nk(e){return e.readiness.kind===`cli`?e.readiness.installed:e.readiness.hasKey}function rk({session:e,progress:t,update:n}){let{api:r}=B(),i=Hi(),a=ka(),o=R(Py(r)),s=R(Iy(r)),c=R(Ly(r)),l=R({...Ny(r,e.projectId??``),enabled:e.projectId!==void 0}),u=(0,m.useRef)(null),d=vO[e.step],f=o.data?.seen===!0;if((0,m.useEffect)(()=>{if(f&&d&&u.current!==e.step){if(u.current=e.step,d.page===`settings`&&a.pathname!==`/settings`&&i({to:`/settings`}),d.page===`article`||d.page===`image`){let t=d.page===`article`?e.articleId:e.imageId,n=a.pathname===`/prompts/new`&&a.searchStr.includes(`kind=${d.page}`);t&&a.pathname!==`/prompts/${t}`?i({to:`/prompts/$promptId`,params:{promptId:t}}):!t&&!n&&i({to:`/prompts/new`,search:{kind:d.page}})}d.page===`play`&&a.pathname!==`/play`&&i({to:`/play`}),d.page===`project`&&e.projectId&&a.pathname!==`/projects/${e.projectId}`&&i({to:`/projects/$projectId`,params:{projectId:e.projectId}})}},[f,d,e.step,e.articleId,e.imageId,e.projectId,a.pathname,a.searchStr,i]),(0,m.useEffect)(()=>{a.pathname===`/prompts`&&(d?.id===`image-prompt`&&e.imageId?n(e=>({...e,step:vO.findIndex(e=>e.id===`play-article`)})):(d?.id===`article-save`&&e.articleId||d?.id===`image-save`&&e.imageId)&&n(e=>({...e,step:e.step+1})))},[a.pathname,d?.id,e.articleId,e.imageId,n]),!f||!d)return null;let p=s.data?.providers??[],g=e=>p.some(t=>t.family===e&&nk(t)),_=(c.data?.voices??[]).some(e=>p.some(t=>t.id===e.provider&&nk(t))),v={"text-key":g(`llm`),"audio-key":g(`tts`),"image-key":g(`image`),voice:_,"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},y=()=>n(e=>({...e,active:!1})),b=()=>{e.step===vO.length-1||d.id===`play-start`?y():n(e=>({...e,step:e.step+1}))},x=l.data?xO(l.data.project.config):`video`,S=d.id===`download`&&x===`article`?`project-article`:d.id===`play-keywords`&&t.playHasKeywords===!1?`play-options`:d.target,C=d.id===`article-save`||d.id===`image-save`,w=(d.page===`article`||d.page===`image`)&&t.promptSaving===!0;return(0,h.jsxs)(YO,{stepId:d.id,target:`[data-tour="${S}"]`,title:d.title,progress:`${e.step+1} of ${vO.length} · First project`,onClose:y,...e.step===0||d.id===`project`||w?{}:{onBack:()=>n(e=>({...e,step:e.step-1}))},onNext:b,nextDisabled:w||v[d.id]===!1,nextLabel:C?`Use Save in the editor`:d.id===`play-start`?`Use PLAY on the page`:d.id===`download`?`Finish tutorial`:`Next`,...w?{}:{onSkip:b},skipLabel:d.id===`play-start`?`Finish without generating`:C?`Skip without saving`:`Skip this step`,children:[(0,h.jsx)(tk,{step:d.id,output:x}),s.error||c.error?(0,h.jsx)(`p`,{className:`text-red`,children:s.error?.message??c.error?.message}):null]})}var ik=(0,m.createContext)(void 0);function ak({children:e}){let[t,n]=(0,m.useState)({active:!1,step:0}),[r,i]=(0,m.useState)({}),a=(0,m.useCallback)(()=>{n({active:!0,step:0})},[]),o=(0,m.useCallback)(e=>{i(t=>Object.entries(e).every(([e,n])=>t[e]===n)?t:{...t,...e})},[]),s=(0,m.useCallback)(e=>{i(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!e.includes(t))))},[]),c=(0,m.useCallback)(e=>{n(t=>yO(t,e))},[]),l=vO[t.step]?.id,u=t.active&&(l===`project`||l===`download`)?l:void 0,d=(0,m.useMemo)(()=>({active:t.active,projectId:t.projectId,projectStep:u,start:a,report:o,clear:s,event:c}),[t.active,t.projectId,u,a,o,s,c]);return(0,h.jsxs)(ik.Provider,{value:d,children:[e,t.active?(0,h.jsx)(rk,{session:t,progress:r,update:n}):null]})}function ok(){return(0,m.useContext)(ik)}function sk(e){let t=(0,m.useContext)(ik),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 ck(){let e=(0,m.useContext)(ik);return(0,m.useCallback)(t=>{e?.event(t)},[e?.event])}function lk(e){let t=(0,m.useContext)(ik);return t?.projectId===e?t.projectStep:void 0}var uk=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),dk=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),fk=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),pk=e=>{let t=fk(e);return t.charAt(0).toUpperCase()+t.slice(1)},mk={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},hk=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},gk=(0,m.createContext)({}),_k=()=>(0,m.useContext)(gk),vk=(0,m.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=_k()??{},h=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,m.createElement)(`svg`,{ref:c,...mk,width:t??l??mk.width,height:t??l??mk.height,stroke:e??f,strokeWidth:h,className:uk(`lucide`,p,i),...!a&&!hk(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,m.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),yk=(e,t)=>{let n=(0,m.forwardRef)(({className:n,...r},i)=>(0,m.createElement)(vk,{ref:i,iconNode:t,className:uk(`lucide-${dk(pk(e))}`,`lucide-${e}`,n),...r}));return n.displayName=pk(e),n},bk=yk(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),xk=yk(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Sk=yk(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Ck=yk(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),wk=yk(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),Tk=yk(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ek=yk(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Dk=yk(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Ok=yk(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),kk=yk(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Ak=yk(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),jk=yk(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Mk=yk(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Nk(){let e=ok();return e?(0,h.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,onClick:e.start,disabled:e.active,"aria-label":`Start interactive tutorial`,title:`Start interactive tutorial`,children:[(0,h.jsx)(Tk,{className:`size-4`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`sr-only min-[1280px]:not-sr-only`,children:`Tutorial`})]}):null}function Pk(){let e=ok();return!e||e.active?null:(0,h.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-4 rounded-panel border border-line bg-panel px-4 py-[14px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`font-semibold`,children:`Make your first video`}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`An interactive walkthrough of API keys, reusable prompts, keywords, and Play. Each step highlights the real controls you will use.`})]}),(0,h.jsx)(J,{variant:`accent`,onClick:e.start,children:`Start tutorial`})]})}var Fk=[`app-update`],Ik=9e5,Lk=2e3;async function Rk(e,t=!1,n){let r=AbortSignal.timeout(2e4);return Za(await e.fetch(`${e.origin}/api/update${t?`?refresh=1`:``}`,{signal:n===void 0?r:AbortSignal.any([n,r]),cache:`no-store`}))}async function zk(e){return Za(await e.fetch(`${e.origin}/api/update`,{method:`POST`,signal:AbortSignal.timeout(2e4)}))}function Bk(e){let{api:t}=B(),n=_(),[r,i]=(0,m.useState)(null),a=(0,m.useRef)(!1),o=R({queryKey:Fk,queryFn:({signal:e})=>Rk(t,!1,e),staleTime:Ik,refetchOnWindowFocus:`always`,refetchInterval:e=>r!==null||e.state.data?.status===`checking`||e.state.data?.status===`installing`||e.state.data?.status===`restarting`?Lk:Ik,retry:!1}),s=tt({mutationFn:()=>Rk(t,!0),onMutate:()=>n.cancelQueries({queryKey:Fk}),onSuccess:e=>n.setQueryData(Fk,e),retry:!1}),c=tt({mutationFn:()=>zk(t),onMutate:()=>n.cancelQueries({queryKey:Fk}),onSuccess:e=>{i(e.currentVersion),n.setQueryData(Fk,e)},onError:()=>{n.invalidateQueries({queryKey:Fk})},retry:!1});(0,m.useEffect)(()=>{if(r===null||o.data===void 0)return;let t=o.data.status===`idle`||o.data.status===`error`;o.data.currentVersion!==r&&t&&!a.current?(a.current=!0,i(null),e()):t&&i(null)},[r,e,o.data]);let l=r!==null||o.data?.status===`installing`||o.data?.status===`restarting`,u=c.error?.message??s.error?.message??(l?void 0:o.error?.message??o.data?.error);return{info:o.data,updating:l,checking:o.isFetching||s.isPending||o.data?.status===`checking`,installing:c.isPending,reconnecting:l&&o.isError,error:u,inspect:()=>{o.refetch()},refresh:()=>{c.reset(),s.mutate()},install:()=>{s.reset(),c.mutate()}}}function Vk({reload:e}){let t=Bk(e),n=(0,m.useId)(),r=(0,m.useId)(),{info:i,updating:a,installing:o,reconnecting:s,checking:c,error:l}=t,u=a||o,d=u?`Slopify updates: Updating Slopify`:l?`Slopify updates: Update check failed`:i?.available?`Slopify updates: version ${i.latestVersion??`new`} available`:`Slopify updates`,f=i?.blockedReason??(i?.busy?`Pause running projects and wait for their active work to stop before updating.`:void 0);return(0,h.jsxs)(X_,{onOpenChange:e=>{e&&t.inspect()},children:[(0,h.jsx)(Z_,{asChild:!0,children:(0,h.jsxs)(`button`,{type:`button`,"aria-label":d,title:d,className:W(`fixed right-5 bottom-5 z-30 flex size-10 items-center justify-center rounded-full bg-transparent text-ink2 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,l&&`text-amber`),children:[(0,h.jsx)(Ak,{"aria-hidden":`true`,size:20,className:W(u&&`animate-spin motion-reduce:animate-none`)}),i?.available&&!u?(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1 right-1 size-1.5 rounded-full bg-lamp-run`}):null]})}),(0,h.jsx)(Q_,{children:(0,h.jsxs)($_,{align:`end`,side:`top`,sideOffset:10,collisionPadding:16,"aria-labelledby":n,className:`z-50 w-[min(340px,calc(100vw-2rem))] rounded-panel border border-line bg-panel p-4 shadow-[0_8px_24px_var(--color-shadow)]`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-4`,children:[(0,h.jsx)(`h2`,{id:n,className:`text-row font-semibold text-ink`,children:`Slopify updates`}),(0,h.jsx)(ev,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`Close updates`,className:`size-8 p-0`,children:(0,h.jsx)(Mk,{"aria-hidden":`true`,size:16})})})]}),i?(0,h.jsxs)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-x-5 gap-y-1 text-small`,children:[(0,h.jsx)(`dt`,{className:`text-ink3`,children:`Installed`}),(0,h.jsx)(`dd`,{className:`text-ink`,children:i.currentVersion}),(0,h.jsx)(`dt`,{className:`text-ink3`,children:`Latest release`}),(0,h.jsx)(`dd`,{className:`text-ink`,children:i.latestVersion??`Not available`})]}):null,(0,h.jsx)(`p`,{role:`status`,className:`mt-3 text-small text-ink2`,children:s?`Reconnecting to Slopify after the update… This tab will reload when it is ready.`:u?i?.status===`restarting`?`Restarting Slopify… This tab will reload when it is ready.`:`Installing Slopify… You can close this panel while it finishes.`:c?`Checking for updates…`:l?`The update could not finish. You can check again.`:i?.available?`A new version is ready to install.`:i?`No newer release is available.`:`Check for the latest Slopify release.`}),l?(0,h.jsx)(`p`,{role:`alert`,className:`mt-2 break-words text-small text-red`,children:l}):null,f&&!u?(0,h.jsx)(`p`,{id:r,className:`mt-2 text-small text-ink2`,children:f}):null,i?.available&&!u&&!f?(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink3`,children:`Save any edits first. Updating restarts Slopify and reloads this tab.`}):null,(0,h.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[i?.available||u?(0,h.jsx)(J,{variant:`primary`,disabled:!i?.canUpdate||i.busy||u||c,"aria-describedby":f&&!u?r:void 0,onClick:t.install,children:u?`Updating…`:`Update Slopify`}):null,(0,h.jsxs)(J,{variant:`ghost`,disabled:u||c,onClick:t.refresh,children:[(0,h.jsx)(Ak,{"aria-hidden":`true`,size:14}),`Check again`]})]}),(0,h.jsx)(`p`,{className:`mt-3 text-label text-ink3`,children:`Checks every 15 minutes. Installs only when you choose.`})]})})]})}var Hk=[{to:`/`,label:`Projects`,exact:!0},{to:`/play`,label:`Play`,exact:!0},{to:`/prompts`,label:`Prompts`,exact:!1},{to:`/entries`,label:`Intros & Outros`,exact:!1},{to:`/settings`,label:`Settings`,exact:!0},{to:`/usage`,label:`Usage`,exact:!0}],Uk=[{href:`https://github.com/GentBajko/slopify`,label:`GitHub`,glyph:`github`,tone:``},{href:`https://www.patreon.com/cw/GentBajko`,label:`Patreon`,glyph:`patreon`,tone:`text-lamp-run`},{href:`https://buymeacoffee.com/gentbajko`,label:`Buy Me a Coffee`,glyph:`coffee`,tone:`text-lamp-run`}];function Wk(){return(0,h.jsx)(fO,{children:(0,h.jsx)(ak,{children:(0,h.jsx)(Gk,{})})})}function Gk(){let{api:e,openEvents:t}=B(),n=_(),[r,i]=(0,m.useState)(0);return(0,m.useEffect)(()=>{let r=_O(()=>{n.invalidateQueries({queryKey:jy.projects})},200),a=Zy(t,Ao(e,`global`),{tally:i,stagingChanged:()=>{n.invalidateQueries({queryKey:jy.staging})},refetch:e=>{e===void 0?n.invalidateQueries():r.ask()}});return()=>{a(),r.stop()}},[e,t,n]),(0,h.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,h.jsxs)(`header`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-3 border-b border-line bg-panel px-4 min-[1280px]:flex min-[1280px]:h-14 min-[1280px]:gap-7 min-[1280px]:px-7`,children:[(0,h.jsxs)(ia,{to:`/`,className:`flex h-14 shrink-0 items-center gap-[10px] text-wordmark font-extrabold tracking-[-0.02em] text-ink`,children:[(0,h.jsx)(Ec,{className:`relative top-[3px] text-lamp-run`}),`Slopify`]}),(0,h.jsx)(`nav`,{"aria-label":`Main navigation`,className:`col-span-2 row-start-2 flex min-w-0 items-center gap-6 overflow-x-auto [scrollbar-width:thin] min-[1280px]:flex-1 min-[1280px]:gap-7`,children:Hk.map(e=>(0,h.jsx)(ia,{to:e.to,activeOptions:{exact:e.exact},className:`shrink-0 whitespace-nowrap border-b-2 border-transparent py-3 text-ink2 hover:text-ink focus-visible:outline-offset-[-3px] min-[1280px]:py-[18px]`,activeProps:{className:`!border-lamp-run !text-ink`},children:e.label},e.to))}),(0,h.jsxs)(`div`,{className:`col-start-2 row-start-1 ml-auto flex items-center gap-1 sm:gap-4 min-[1280px]:gap-7 [&_button]:min-h-8 [&_button]:min-w-8`,children:[(0,h.jsx)(Nk,{}),r===0?null:(0,h.jsxs)(ia,{to:`/`,"aria-label":`${String(r)} running`,title:`${String(r)} running`,className:`engraved flex min-h-8 items-center whitespace-nowrap text-ink3 hover:text-ink2`,children:[String(r),(0,h.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:`\xA0running`})]}),Uk.map(e=>(0,h.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,title:e.label,className:`flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,children:[(0,h.jsx)(Oc,{name:e.glyph,className:e.tone}),(0,h.jsx)(`span`,{className:`sr-only min-[1100px]:not-sr-only`,children:e.label})]},e.href))]})]}),(0,h.jsx)(`main`,{className:`min-w-0 flex-1 px-4 py-6 sm:px-7`,children:(0,h.jsx)(ya,{})}),(0,h.jsx)(`footer`,{className:`flex items-center gap-[18px] border-t border-line px-4 py-[14px] text-label sm:px-7 text-ink3`,children:(0,h.jsx)(`span`,{children:`Free. Your keys, your machine.`})}),(0,h.jsx)(Vk,{reload:()=>window.location.reload()}),(0,h.jsx)(Ky,{}),(0,h.jsx)(Uy,{}),(0,h.jsx)(qy,{reload:()=>{window.location.reload()}})]})}var Kk=[`text`,`llm`],qk=[`article`,`image`,`thumbnail`],Jk=[`intro`,`outro`],Yk=1e5,Xk=Jk.map(e=>({value:e,label:Qk(e)})),Zk=Kk.map(e=>({value:e,label:$k(e)}));function Qk(e){switch(e){case`intro`:return`Intro`;case`outro`:return`Outro`}}function $k(e){switch(e){case`text`:return`Text`;case`llm`:return`LLM`}}function eA(e){switch(e){case`text`:return`Text is narrated as written.`;case`llm`:return`LLM is an instruction whose answer is narrated.`}}function tA(e){switch(e){case`text`:return`No slots. This text is narrated as written.`;case`llm`:return`No slots. This instruction runs as written.`}}function nA(e){return Jk.find(t=>t===e)??`intro`}var rA=qk.map(e=>({value:e,label:iA(e)}));function iA(e){switch(e){case`article`:return`Article`;case`image`:return`Image`;case`thumbnail`:return`Thumbnail`}}function aA(e){return qk.find(t=>t===e)??`article`}function oA({open:e,title:t,consequence:n,verb:r,dismiss:i=`Cancel`,pending:a=!1,onConfirm:o,onCancel:s}){return(0,h.jsx)(Ty,{open:e,onOpenChange:e=>{e||s()},children:(0,h.jsxs)(Oy,{children:[(0,h.jsx)(ky,{children:t}),(0,h.jsx)(Ay,{children:n}),(0,h.jsxs)(`div`,{className:`flex justify-end gap-[10px]`,children:[(0,h.jsx)(J,{autoFocus:!0,onClick:s,children:i}),(0,h.jsx)(J,{variant:`danger`,disabled:a,onClick:o,children:r})]})]})})}function sA({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:W(`overflow-hidden rounded-panel border border-line bg-panel`,t),children:e})}function cA({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:W(`relative flex items-center gap-[14px] border-b border-line px-4 py-[14px] last:border-b-0`,t),children:e})}function lA({current:e,total:t}){let n=t<=0?0:Math.min(1,Math.max(0,e/t));return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-meter`,className:`absolute inset-x-0 bottom-0 h-[2px] bg-lamp-run transition-[width] duration-[250ms] ease-out motion-reduce:transition-none`,style:{width:`${String(Math.round(n*100))}%`}})}function uA({name:e,className:t}){return(0,h.jsx)(`span`,{"data-slot-chip":e,className:W(`engraved animate-tick-in rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] text-ink2 motion-reduce:animate-none`,t),children:e})}var dA=p_,fA=m_;function pA({className:e,sideOffset:t=4,align:n=`end`,...r}){return(0,h.jsx)(h_,{children:(0,h.jsx)(g_,{"data-slot":`dropdown-menu-content`,sideOffset:t,align:n,className:W(`z-50 min-w-[160px] overflow-hidden rounded-panel border border-line bg-panel p-1`,`shadow-[0_8px_24px_var(--color-shadow)]`,e),...r})})}function mA({className:e,...t}){return(0,h.jsx)(__,{"data-slot":`dropdown-menu-item`,className:W(`flex cursor-default items-center rounded-control px-[10px] py-[5px] text-small text-ink`,`outline-hidden select-none focus:bg-panel2 data-highlighted:bg-panel2`,e),...t})}function hA({className:e,...t}){return(0,h.jsx)(py,{"data-slot":`toggle-group`,className:W(`inline-flex w-fit items-stretch overflow-hidden rounded-control border border-line2`,e),...t})}function gA({className:e,...t}){return(0,h.jsx)(Sy,{"data-slot":`toggle-group-item`,className:W(`min-h-8 shrink-0 border-r border-line2 px-[10px] py-[5px] text-label text-ink2 last:border-r-0`,`transition-colors duration-150 ease-out motion-reduce:transition-none hover:bg-panel2 hover:text-ink`,`data-[state=on]:bg-panel2 data-[state=on]:text-ink data-[state=on]:shadow-[inset_0_-2px_0_var(--color-lamp-run)]`,`disabled:cursor-not-allowed disabled:opacity-40`,e),...t})}var _A=`grid grid-cols-[minmax(0,1fr)_auto_auto_32px] items-center gap-x-[14px] gap-y-[6px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[260px_70px_minmax(0,1fr)_auto_32px]`,vA=`col-span-4 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1 md:col-start-3 md:row-start-1`;function yA({category:e,onCategory:t}){let{api:n}=B(),r=_(),i=R(zy(n)),[a,o]=(0,m.useState)(void 0),s=tt({mutationFn:e=>ko(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:jy.entries})}}),c=i.data?.entries.filter(t=>t.category===e);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:`Intros & Outros`}),(0,h.jsxs)(`div`,{className:`mb-4 flex items-center gap-4`,children:[(0,h.jsx)(hA,{type:`single`,value:e,"aria-label":`Entry category`,onValueChange:e=>{let n=Xk.find(t=>t.value===e);n!==void 0&&t(n.value)},children:Xk.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(J,{asChild:!0,children:(0,h.jsxs)(ia,{to:`/entries/new`,search:{category:e},children:[(0,h.jsx)(kk,{"aria-hidden":`true`,className:`size-[14px]`}),`New entry`]})})]}),i.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:i.error.message})}),c===void 0?i.error===null?(0,h.jsx)(CA,{}):null:c.length===0?(0,h.jsx)(xA,{category:e}):(0,h.jsx)(sA,{children:c.map(e=>(0,h.jsxs)(`div`,{className:_A,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(bA,{mode:e.mode}),(0,h.jsx)(`span`,{className:vA,children:e.slots.map(e=>(0,h.jsx)(uA,{name:e},e))}),(0,h.jsx)(J,{className:`col-start-3 row-start-1 md:col-start-4`,asChild:!0,children:(0,h.jsx)(ia,{to:`/entries/$entryId`,params:{entryId:e.id},children:`Edit`})}),(0,h.jsx)(SA,{entry:e,onDelete:()=>{o(e)}})]},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{className:`mt-[10px] text-label text-red`,children:s.error.message}),(0,h.jsx)(oA,{open:a!==void 0,title:a===void 0?``:`Delete "${a.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>{o(void 0)}})]})}function bA({mode:e}){return(0,h.jsx)(`span`,{"data-entry-mode":e,className:`engraved col-start-2 row-start-1 justify-self-start rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] font-bold text-ink`,children:$k(e)})}function xA({category:e}){return(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`max-w-[75ch] px-4 py-7 text-ink2`,children:`No ${e}s yet. An ${e} is narrated ${e===`intro`?`before`:`after`} the body in the run's voice.`})})}function SA({entry:e,onDelete:t}){return(0,h.jsxs)(dA,{children:[(0,h.jsx)(fA,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-4 row-start-1 size-8 p-0 md:col-start-5`,children:(0,h.jsx)(Dk,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(pA,{children:[(0,h.jsx)(mA,{asChild:!0,children:(0,h.jsx)(ia,{to:`/entries/new`,search:{category:e.category,from:e.id},children:`Duplicate`})}),(0,h.jsx)(mA,{onSelect:t,children:`Delete`})]})]})}function CA(){return(0,h.jsx)(sA,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:_A,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-[18px] w-10 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:vA,children:(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`})}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-4`})]},e))})}function wA({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)(`h2`,{className:`engraved text-ink3`,children:`Detected slots`}),e.length>0?(0,h.jsx)(`div`,{className:`flex flex-wrap gap-[6px]`,children:e.map(e=>(0,h.jsx)(uA,{name:e,className:`px-2 py-[3px]`},e))}):t.trim()===``?(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`Slots appear here as you type {{name}}.`}):(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:i}),n.length===0?null:(0,h.jsxs)(`div`,{id:r,className:`flex flex-col gap-[6px] border-t border-line pt-3`,children:[(0,h.jsx)(`span`,{className:`engraved text-red`,children:n.length===1?`1 slot error`:`${String(n.length)} slot errors`}),n.map(e=>(0,h.jsx)(`span`,{className:`text-small text-red`,children:e.message},e.message))]})]})}var TA=2e3;function EA(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()},TA);return()=>{clearTimeout(t)}},[e])}function DA(){return(0,h.jsxs)(`span`,{className:`inline-flex animate-tick-in items-center gap-1 text-label text-done motion-reduce:animate-none`,children:[(0,h.jsx)(bk,{"aria-hidden":`true`,className:`size-[14px]`}),`Saved`]})}function OA({onDelete:e,blocked:t,blockedId:n,pending:r,saved:i,cancel:a,errors:o,onSave:s}){let c=t!==void 0||r||i;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px] border-t border-line pt-[14px]`,children:[e===void 0?null:(0,h.jsx)(J,{className:`bg-transparent`,onClick:e,children:`Delete`}),(0,h.jsx)(`span`,{className:`flex-1`}),i?(0,h.jsx)(DA,{}):null,t===void 0?null:(0,h.jsx)(`span`,{id:n,className:`text-small text-ink2`,children:t}),a,(0,h.jsx)(J,{variant:`primary`,"aria-disabled":c,"aria-describedby":t===void 0?void 0:n,onClick:()=>{c||s()},children:`Save`}),o.map(e=>(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:e},e))]})}var kA=`rounded-panel border border-line bg-panel p-[18px]`;function AA(){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:`${kA} flex flex-col gap-[14px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-64 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[520px] rounded-control bg-panel2`})]}),(0,h.jsx)(`div`,{className:`${kA} flex flex-col gap-3`,children:(0,h.jsx)(`span`,{className:`h-3 w-28 rounded-control bg-panel2`})})]})}function jA({children:e,back:t}){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:e})}),t]})}var MA=`mt-[10px] inline-block text-small text-run-text underline`;function NA({className:e,...t}){return(0,h.jsx)(y_,{"data-slot":`label`,className:W(`engraved block select-none text-ink3`,e),...t})}function PA({label:e,value:t,options:n,describedBy:r,onPick:i}){let a=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(NA,{id:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(hA,{type:`single`,value:t,"aria-labelledby":a,"aria-describedby":r,onValueChange:e=>{let t=n.find(t=>t.value===e);t!==void 0&&i(t.value)},children:n.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))})]})}function FA({className:e,...t}){return(0,h.jsx)(`input`,{"data-slot":`input`,className:W(`h-8 w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}function IA({className:e,...t}){return(0,h.jsx)(`textarea`,{"data-slot":`textarea`,className:W(`w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}var LA=`{{`,RA=`}}`;function zA(e){let t=[],n=[],r=e.indexOf(LA);for(;r!==-1;){let i=e.indexOf(`
99
99
  `,r+2),a=i===-1?e.length:i,o=e.indexOf(RA,r+2);if(o===-1||o>a){n.push({kind:`unclosed`,at:r}),r=e.indexOf(LA,r+2);continue}let s=e.slice(r+2,o),c=s.trim();s.includes(`{`)||s.includes(`}`)?n.push({kind:`nested`,at:r}):c===``?n.push({kind:`empty`,at:r}):t.includes(c)||t.push(c),r=e.indexOf(LA,o+2)}return{names:t,errors:n}}function BA(e,t){let n=VA(e),r=VA(t),i=[];for(let e of[...n,...r]){if(i.some(t=>t.name===e))continue;let t=n.includes(e),a=r.includes(e);i.push({name:e,group:t&&a?`common`:t?`text`:`image`})}return i}function VA(e){let t=[];for(let n of e)for(let e of zA(n).names)t.includes(e)||t.push(e);return t}function HA(e){return WA(e.name,e.body)}function UA(e){return WA(e.name,e.body)}function WA(e,t){let n=[],r=e.trim();if(r===``?n.push({field:`name`,message:`A name is required.`}):r.length>200&&n.push({field:`name`,message:`A name is at most 200 characters.`}),t.trim()===``)return n.push({field:`body`,message:`A body is required.`}),n;if(t.length>1e5)return n.push({field:`body`,message:`A body is at most ${String(Yk)} characters.`}),n;for(let e of zA(t).errors)n.push({field:`body`,message:GA(e,t)});return n}function GA(e,t){let n=KA(t,e.at);switch(e.kind){case`unclosed`:return`The \`{{\` at ${n} is never closed.`;case`empty`:return`The slot at ${n} has no name.`;case`nested`:return`The slot at ${n} holds a brace; slots do not nest.`}}function KA(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`
100
100
  `),i=n.split(`
101
101
  `).length,a=t-r;return`line ${String(i)}, column ${String(a)}`}function qA(e,t){return[...`kind`in e?HA(e):UA(e),...t]}function JA(e){return e[0]?.message}function YA(e){return e.filter(e=>e.field===`body`)}function XA(e){return e.filter(e=>e.field===`name`)}function ZA(e){return zA(e).names}function QA(e){let t=[],n=0;for(let r of zA(e).errors){if(r.at<n)continue;r.at>n&&t.push({start:n,text:e.slice(n,r.at),marked:!1});let i=Math.min(r.at+2,e.length);t.push({start:r.at,text:e.slice(r.at,i),marked:!0}),n=i}return n<e.length&&t.push({start:n,text:e.slice(n),marked:!1}),t}var $A=`px-3 py-[10px] font-sans text-body leading-[1.5] break-words [scrollbar-gutter:stable]`;function ej({id:e,value:t,invalid:n,describedBy:r,onChange:i}){let a=(0,m.useRef)(null);return(0,h.jsxs)(`div`,{className:`relative max-w-[75ch]`,children:[(0,h.jsxs)(`div`,{ref:a,"aria-hidden":`true`,"data-slot":`lint-overlay`,className:W($A,`pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap`,`rounded-control border border-transparent bg-panel2 text-ink`),children:[QA(t).map(e=>(0,h.jsx)(`span`,{"data-lint-mark":e.marked?e.start:void 0,className:e.marked?`text-red underline decoration-red decoration-2 underline-offset-[3px]`:void 0,children:e.text},e.start)),`
@@ -127,4 +127,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
127
127
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
128
128
  `,...a.current()});return/^[\t ]/.test(l)&&(l=OB(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}PB.peek=FB;function PB(e){return e.value||``}function FB(){return`<`}IB.peek=LB;function IB(e,t,n,r){let i=TB(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function LB(){return`!`}RB.peek=zB;function RB(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function zB(){return`!`}BB.peek=VB;function BB(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function VB(){return"`"}function HB(e,t){let n=pP(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}UB.peek=WB;function UB(e,t,n,r){let i=TB(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(HB(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function WB(e,t,n){return HB(e,n)?`<`:`[`}GB.peek=KB;function GB(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function KB(){return`[`}function qB(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function JB(e){let t=qB(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function YB(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function XB(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function ZB(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?YB(n):qB(n),s=e.ordered?o===`.`?`)`:`.`:JB(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),XB(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function QB(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function $B(e,t,n,r){let i=QB(n),a=n.bulletCurrent||qB(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function eV(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var tV=cR([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function nV(e,t,n,r){return(e.children.some(function(e){return tV(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function rV(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}iV.peek=aV;function iV(e,t,n,r){let i=rV(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=kB(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=OB(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=kB(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+OB(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function aV(e,t,n){return n.options.strong||`*`}function oV(e,t,n,r){return n.safe(e.value,r)}function sV(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function cV(e,t,n){let r=(XB(n)+(n.options.ruleSpaces?` `:``)).repeat(sV(n));return n.options.ruleSpaces?r.slice(0,-1):r}var lV={blockquote:hB,break:yB,code:CB,definition:EB,emphasis:AB,hardBreak:yB,heading:NB,html:PB,image:IB,imageReference:RB,inlineCode:BB,link:UB,linkReference:GB,list:ZB,listItem:$B,paragraph:eV,root:nV,strong:iV,text:oV,thematicBreak:cV};function uV(){return{enter:{table:dV,tableData:hV,tableHeader:hV,tableRow:pV},exit:{codeText:gV,table:fV,tableData:mV,tableHeader:mV,tableRow:mV}}}function dV(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function fV(e){this.exit(e),this.data.inTable=void 0}function pV(e){this.enter({type:`tableRow`,children:[]},e)}function mV(e){this.exit(e)}function hV(e){this.enter({type:`tableCell`,children:[]},e)}function gV(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,_V));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function _V(e,t){return t===`|`?t:e}function vV(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
129
129
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
130
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return fB(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=lV.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function yV(){return{exit:{taskListCheckValueChecked:xV,taskListCheckValueUnchecked:xV,paragraph:SV}}}function bV(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:CV}}}function xV(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function SV(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function CV(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=lV.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function wV(){return[Az(),eB(),aB(),uV(),yV()]}function TV(e){return{extensions:[jz(),tB(e),oB(),vV(e),bV()]}}var EV={tokenize:BV,partial:!0},DV={tokenize:VV,partial:!0},OV={tokenize:HV,partial:!0},kV={tokenize:UV,partial:!0},AV={tokenize:WV,partial:!0},jV={name:`wwwAutolink`,tokenize:RV,previous:GV},MV={name:`protocolAutolink`,tokenize:zV,previous:KV},NV={name:`emailAutolink`,tokenize:LV,previous:qV},PV={};function FV(){return{text:PV}}for(var IV=48;IV<123;)PV[IV]=NV,IV++,IV===58?IV=65:IV===91&&(IV=97);PV[43]=NV,PV[45]=NV,PV[46]=NV,PV[95]=NV,PV[72]=[NV,MV],PV[104]=[NV,MV],PV[87]=[NV,jV],PV[119]=[NV,jV];function LV(e,t,n){let r=this,i,a;return o;function o(t){return!JV(t)||!qV.call(r,r.previous)||YV(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return JV(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(AV,u,l)(t):t===45||t===95||OP(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&DP(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function RV(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!GV.call(r,r.previous)||YV(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(EV,e.attempt(DV,e.attempt(OV,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function zV(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&KV.call(r,r.previous)&&!YV(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(DP(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||AP(t)||PP(t)||LP(t)||IP(t)?n(t):e.attempt(DV,e.attempt(OV,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function BV(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function VV(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(kV,c,s)(t):t===null||PP(t)||LP(t)||t!==45&&IP(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function HV(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(kV,t,a)(o):o===null||PP(o)||LP(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function UV(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||PP(o)||LP(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||PP(e)||LP(e)?t(e):r(e)}function a(e){return DP(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):DP(t)?(e.consume(t),o):n(t)}}function WV(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return OP(e)?n(e):t(e)}}function GV(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||PP(e)}function KV(e){return!DP(e)}function qV(e){return!(e===47||JV(e))}function JV(e){return e===43||e===45||e===46||e===95||OP(e)}function YV(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var XV={tokenize:iH,partial:!0};function ZV(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:tH,continuation:{tokenize:nH},exit:rH}},text:{91:{name:`gfmFootnoteCall`,tokenize:eH},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:QV,resolveTo:$V}}}}function QV(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=EP(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function $V(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function eH(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||PP(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(EP(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return PP(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function tH(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||PP(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=EP(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return PP(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),BP(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function nH(e,t,n){return e.check(tF,t,e.attempt(XV,t,n))}function rH(e){e.exit(`gfmFootnoteDefinition`)}function iH(e,t,n){let r=this;return BP(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function aH(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&yP(o,o.length,0,JP(s,e.slice(r+1,n),t)),yP(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),yP(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=qP(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=qP(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var oH=class{constructor(){this.map=[]}add(e,t,n){sH(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function sH(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function cH(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function lH(){return{flow:{null:{name:`table`,tokenize:uH,resolveAll:dH}}}}function uH(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):$(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):FP(t)?BP(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||PP(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,FP(t)?BP(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return FP(t)?BP(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||$(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return FP(t)?BP(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||$(n)?(e.exit(`tableRow`),t(n)):FP(n)?BP(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||PP(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function dH(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new oH;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(pH(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=fH(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=fH(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=fH(f,t,o,i,n,d)):(o[0]=o[1],d=fH(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&pH(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=cH(t.events,n))}return e}function fH(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},mH(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=mH(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=mH(t.events,n[2]),a=mH(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},mH(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function pH(e,t,n,r,i){let a=[],o=mH(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function mH(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var hH={name:`tasklistCheck`,tokenize:_H};function gH(){return{text:{91:hH}}}function _H(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return PP(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return $(r)?t(r):FP(r)?e.check({tokenize:vH},t,n)(r):n(r)}}function vH(e,t,n){return BP(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function yH(e){return SP([FV(),ZV(),aH(e),lH(),gH()])}var bH={};function xH(e){let t=this,n=e||bH,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(yH(n)),a.push(wV()),o.push(TV(n))}var SH=new Set([400,404,409]);async function CH(e,t){return PH(await e.client.projects[`:id`].cancel.$post({param:{id:t}}))}async function wH(e,t){return PH(await e.client.projects[`:id`].pause.$post({param:{id:t}}))}async function TH(e,t){return PH(await e.client.projects[`:id`].resume.$post({param:{id:t}}))}async function EH(e,t,n){return PH(await e.client.projects[`:id`].providers.$patch({param:{id:t},json:n}))}async function DH(e,t,n){return PH(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/subtitles`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function OH(e,t,n){return PH(await e.client.projects[`:id`].stages[`:kind`].retry.$post({param:{id:t,kind:n}}))}async function kH(e,t,n){return PH(await e.client.projects[`:id`].stages[`:kind`].rerun.$post({param:{id:t,kind:n}}))}async function AH(e,t,n){return PH(await e.client.projects[`:id`].article.$put({param:{id:t},json:{markdown:n}}))}async function jH(e,t,n){return PH(await e.client.projects[`:id`].images[`:outputId`].$delete({param:{id:t,outputId:n}}))}async function MH(e,t,n){return PH(await e.client.projects[`:id`].images[`:outputId`].regenerate.$post({param:{id:t,outputId:n}}))}async function NH(e,t,n){return Qa(await e.fetch(po(e,t,n)))}async function PH(e){if(e.ok)return{ok:!0,value:await e.json()};let t=await no(e);if(t!==void 0&&SH.has(e.status))return{ok:!1,message:to(e,t).message};throw to(e,t)}function FH({projectId:e,asset:t}){let{api:n}=B(),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)();async function s(){i(!0),o(void 0);try{let r=await n.client.projects[`:id`][`open-folder`].$post({param:{id:e},json:{asset:t}});if(!r.ok)throw to(r,await no(r))}catch(e){o(e instanceof Error?e.message:`Could not open the folder.`)}finally{i(!1)}}return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,disabled:r,onClick:()=>void s(),title:`Open the saved output folder on the machine running Slopify`,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink disabled:opacity-50`,children:[(0,h.jsx)(Ok,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),r?`Opening…`:`Open folder`]}),a!==void 0&&(0,h.jsx)(`span`,{role:`alert`,className:`basis-full text-small text-red`,children:a})]})}function IH({children:e,className:t}){return(0,h.jsx)(`div`,{className:W(`flex min-w-0 flex-col gap-4 p-5`,t),children:e})}function LH({children:e}){return(0,h.jsx)(`div`,{className:`flex flex-wrap items-center gap-4 text-small`,children:e})}function RH({children:e}){return(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:e})}var zH={h1:({children:e})=>(0,h.jsx)(VH,{size:`text-title`,children:e}),h2:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h3:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h4:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h5:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h6:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),p:({children:e})=>(0,h.jsx)(`p`,{className:`m-0`,children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),ul:({children:e})=>(0,h.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-5`,children:e}),ol:({children:e})=>(0,h.jsx)(`ol`,{className:`m-0 flex list-decimal flex-col gap-1 pl-5`,children:e}),li:({children:e})=>(0,h.jsx)(`li`,{className:`m-0`,children:e}),a:({children:e,href:t})=>(0,h.jsx)(`a`,{href:t,className:`rounded-control text-run-text underline underline-offset-[3px]`,target:`_blank`,rel:`noreferrer`,children:e}),code:({children:e})=>(0,h.jsx)(`code`,{className:`rounded-control bg-panel2 px-[4px] py-[1px] font-sans text-small`,children:e}),pre:({children:e})=>(0,h.jsx)(`pre`,{className:`m-0 overflow-x-auto rounded-control bg-panel2 p-[10px] font-sans text-small`,children:e}),blockquote:({children:e})=>(0,h.jsx)(`blockquote`,{className:`m-0 flex flex-col gap-2 border-l-2 border-line2 pl-3 text-ink2`,children:e}),hr:()=>(0,h.jsx)(`hr`,{className:`my-2 border-line`}),table:({children:e})=>(0,h.jsx)(`table`,{className:`w-full border-collapse text-left text-small`,children:e}),th:({children:e})=>(0,h.jsx)(`th`,{className:`engraved border-b border-line py-[6px] pr-4 text-left text-ink3`,children:e}),td:({children:e})=>(0,h.jsx)(`td`,{className:`border-b border-line py-[6px] pr-4 align-top`,children:e})},BH={p:({children:e})=>(0,h.jsx)(h.Fragment,{children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),a:({children:e})=>(0,h.jsx)(h.Fragment,{children:e})};function VH({size:e,children:t}){return(0,h.jsx)(`h3`,{className:W(`mt-2 font-bold tracking-[-0.01em]`,e),children:t})}function HH({markdown:e}){return(0,h.jsx)(`div`,{className:`flex max-w-[75ch] flex-col gap-2 text-pretty text-body text-ink`,children:(0,h.jsx)(_z,{remarkPlugins:[xH],components:zH,children:e})})}function UH({markdown:e}){return(0,h.jsx)(_z,{remarkPlugins:[xH],components:BH,children:e})}var WH=/^#{1,6}[ \t]+(.*?)[ \t]*#*[ \t]*(?:\r?\n|$)/;function GH(e){let t=e.replace(/^[\s]*\n/,``),n=WH.exec(t);return n===null?{title:void 0,body:e.trim()}:{title:n[1]??``,body:t.slice(n[0].length).trim()}}function KH({message:e,onDismiss:t}){return(0,h.jsxs)(`div`,{className:`flex items-center gap-3 rounded-control bg-red-tint px-[10px] py-[6px] text-small text-red`,children:[(0,h.jsx)(`span`,{role:`alert`,className:`min-w-0 break-words`,children:e}),(0,h.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto shrink-0 rounded-control px-2 text-ink2 hover:text-ink`,children:`Dismiss`})]})}function qH({projectId:e,asset:t,label:n=`Download`}){let{api:r}=B();return(0,h.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsxs)(`a`,{href:po(r,e,t),download:!0,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(Ek,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),n]}),(0,h.jsx)(FH,{projectId:e,asset:t})]})}function JH({output:e,label:t}){return(0,h.jsx)(qH,{projectId:e.projectId,asset:PM(e),...t===void 0?{}:{label:t}})}function YH(e){let{api:t}=B();return R({queryKey:jy.file(e?.projectId??``,e?.id??``),queryFn:()=>e===void 0?``:NH(t,e.projectId,PM(e)),enabled:e!==void 0,staleTime:1/0})}function XH({output:e,as:t=`prose`}){let n=YH(e);return n.error===null?n.data===void 0?(0,h.jsx)(`span`,{className:`h-4 w-[40ch] max-w-full rounded-control bg-panel2`}):t===`prose`?(0,h.jsx)(HH,{markdown:n.data}):(0,h.jsx)(`pre`,{className:`max-w-[75ch] overflow-x-auto whitespace-pre-wrap font-sans text-small text-ink2`,children:n.data}):(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})}function ZH({output:e}){let[t,n]=(0,m.useState)(!1);return e===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>{n(!t)},className:`rounded-control text-small text-ink2 underline underline-offset-[3px] hover:text-ink`,children:t?`Hide instructions`:`Show instructions`}),t?(0,h.jsx)(XH,{output:e,as:`plain`}):null]})}function QH({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=EM(n,e),o=DM(a,`article_md`),s=DM(a,`sources`),c=DM(a,`glossary`),l=YH(o),u=R({queryKey:jM(t.id),queryFn:()=>[],enabled:!1}).data?.some(e=>e.stage===`article`)===!0,d=R({queryKey:jy.article(t.id),queryFn:()=>``,enabled:!1}),[f,p]=(0,m.useState)(void 0),[g,_]=(0,m.useState)(!1),v=l.data??``,y=GH(e.state===`running`?d.data??``:v),b=y.title??t.title,x=kM({kind:`discard-article`});return(0,h.jsxs)(IH,{children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-[14px] text-small text-ink2`,children:[(0,h.jsx)(`span`,{className:`text-row font-semibold text-ink`,children:(0,h.jsx)(UH,{markdown:b})}),s===void 0?null:(0,h.jsx)(JH,{output:s,label:`Sources`}),c===void 0?null:(0,h.jsx)(JH,{output:c,label:`Glossary`})]}),(0,h.jsx)(LH,{children:f===void 0?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(J,{type:`button`,disabled:i||o===void 0||l.data===void 0,onClick:()=>{p(v)},children:`Edit`}),(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run`}),(0,h.jsx)(ZH,{output:DM(a,`instructions`)}),o===void 0?null:(0,h.jsx)(JH,{output:o})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(AM,{action:{kind:`save-article`,markdown:f},run:()=>{r.run({kind:`save-article`,markdown:f},()=>{p(void 0)})},disabled:i,pending:r.pending,children:`Save & update outputs`}),(0,h.jsx)(J,{type:`button`,onClick:()=>{_(!0)},children:`Discard`})]})}),l.error===null?null:(0,h.jsx)(`p`,{className:`text-body text-red`,children:l.error.message}),(0,h.jsx)(`section`,{"aria-label":`Article content`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:f===void 0?e.state===`running`&&u?(0,h.jsx)(NM,{projectId:t.id,stage:`article`}):(0,h.jsx)(HH,{markdown:y.body}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`label`,{htmlFor:`article-editor`,className:`engraved text-ink3`,children:`Article`}),(0,h.jsx)(`textarea`,{id:`article-editor`,value:f,onChange:e=>{p(e.target.value)},className:`h-[420px] w-full max-w-[75ch] resize-y rounded-control border border-line2 bg-panel2 p-[10px] font-sans text-body text-ink`})]})}),(0,h.jsx)(oA,{open:g,title:x.title,consequence:x.consequence,verb:x.verb,dismiss:x.dismiss,onConfirm:()=>{_(!1),p(void 0)},onCancel:()=>{_(!1)}})]})}function $H({projectId:e}){let{api:t}=B(),n=R({queryKey:[`audio-preview`,e],queryFn:async()=>Za(await t.client.projects[`:projectId`][`audio-preview`].$get({param:{projectId:e}})),refetchInterval:1e3,staleTime:0,gcTime:0,retry:!1}),r=n.data?.previews??[];return(0,h.jsxs)(`section`,{"aria-label":`Live narration`,className:`grid gap-3 rounded-control border border-line2 bg-panel2 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold text-ink`,children:`Listen while it generates`}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Play any part. Each preview starts from its beginning.`})]}),n.error===null?null:(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Live preview is temporarily unavailable. Finished audio will still appear here.`}),r.length===0&&n.error===null?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Waiting for the first audio bytes…`}):null,(0,h.jsx)(`div`,{className:`grid max-h-[420px] gap-3 overflow-y-auto`,children:r.map(n=>(0,h.jsx)(eU,{preview:n,url:`${t.origin}/api/projects/${encodeURIComponent(e)}/audio-preview/${n.id}`},n.id))})]})}function eU({preview:e,url:t}){let[n,r]=(0,m.useState)(!1),i=(e.state===`streaming`||e.state===`ready`)&&e.bytes>0,a=e.state===`ready`?`Ready`:e.state===`streaming`?`Generating`:`Preview stopped`;return(0,h.jsxs)(`div`,{className:`grid gap-2 text-small`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-ink`,children:e.label}),(0,h.jsx)(`span`,{className:`text-ink2`,children:a})]}),i&&!n?(0,h.jsx)(tU,{label:e.label,url:t,onError:()=>r(!0)}):(0,h.jsx)(`p`,{className:`text-ink2`,children:e.state===`streaming`&&!n?`Waiting for audio…`:`This preview has stopped. The finished narration will be available when generation completes.`})]})}function tU({label:e,url:t,onError:n}){let r=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=r.current;return()=>{e!==null&&(e.pause(),e.removeAttribute(`src`),e.load())}},[]),(0,h.jsx)(`audio`,{ref:r,controls:!0,preload:`none`,"aria-label":`Live ${e} narration`,src:t,onError:n,className:`h-9 w-full max-w-[620px]`})}var nU=[{role:`audio_intro`,name:`Intro`},{role:`audio_body`,name:`Body`},{role:`audio_outro`,name:`Outro`}];function rU({stage:e,project:t,outputs:n,actions:r,busy:i}){let{api:a}=B(),o=R(Ly(a)),s=EM(n,e),c=nU.flatMap(e=>{let t=DM(s,e.role);return t===void 0?[]:[{...e,output:t}]}),l=c.find(e=>e.output.meta.voice!==void 0)?.output.meta,u=c.length>0?l?.voice:t.config.audio?.voice,d=c.length>0?l?.provider:t.config.audio?.provider,f=o.data?.voices.find(e=>e.voiceId===u&&e.provider===d)?.name??u;return(0,h.jsxs)(IH,{children:[e.state===`running`?(0,h.jsx)($H,{projectId:t.id}):null,c.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No narration has landed yet.`}):c.map(e=>(0,h.jsx)(iU,{name:e.name,output:e.output},e.role)),(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run`}),f===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(RH,{children:`Voice`}),(0,h.jsx)(`span`,{className:`text-small text-ink`,children:f})]}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Chunking: ${aU(t.config.chunking)}`})]})]})}function iU({name:e,output:t}){let{api:n}=B(),r=AO(t.durationMs??void 0);return(0,h.jsxs)(`div`,{className:`grid grid-cols-[60px_minmax(0,1fr)_auto] items-center gap-3 text-small`,children:[(0,h.jsx)(RH,{children:e}),(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`${e} narration`,src:po(n,t.projectId,PM(t)),className:`h-8 w-full max-w-[520px]`}),(0,h.jsxs)(`span`,{className:`flex items-center gap-4`,children:[r===void 0?null:(0,h.jsx)(`span`,{className:`text-ink2 tabular-nums`,children:r}),(0,h.jsx)(JH,{output:t})]})]})}function aU(e){return e===void 0||e.mode===`whole`?`the whole text as one request`:e.mode===`paragraph`?`one request per paragraph`:e.mode===`characters`?`every ${String(e.characters??3e3)} characters`:`every ${String(e.words??500)} words`}function oU(e,t){let n=e.filter(e=>e.role===`image`),r=new Map;for(let e of n){let t=e.meta.promptName??`Images`;r.set(t,[...r.get(t)??[],e])}let i=t.filter(e=>r.has(e)),a=[...r.keys()].filter(e=>!i.includes(e)).sort();return[...i,...a].flatMap(e=>{let t=r.get(e);return t===void 0?[]:[{name:e,images:[...t].sort(sU)}]})}function sU(e,t){return(e.meta.index??0)-(t.meta.index??0)}function cU(e){return e===`9:16`?`aspect-[9/16]`:`aspect-video`}function lU({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=oU(EM(n,e),t.config.imagePrompts?.map(e=>e.name)??[]);return(0,h.jsxs)(IH,{children:[(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run stage`}),(0,h.jsx)(qH,{projectId:t.id,asset:`images.zip`,label:`Download all`})]}),a.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No images have landed yet.`}):null,a.map(e=>(0,h.jsxs)(`section`,{className:`flex flex-col gap-[10px]`,children:[(0,h.jsx)(RH,{children:`${e.name} × ${String(e.images.length)}`}),(0,h.jsx)(`div`,{className:`grid grid-cols-3 gap-2 min-[900px]:grid-cols-6`,children:e.images.map(e=>(0,h.jsx)(uU,{image:e,format:t.format,actions:r,busy:i},e.id))})]},e.name))]})}function uU({image:e,format:t,actions:n,busy:r}){let{api:i}=B(),a=e.meta.index===void 0?``:` ${String(e.meta.index)}`;return(0,h.jsxs)(`figure`,{className:`group relative m-0 overflow-hidden rounded-control border border-line bg-panel2`,children:[(0,h.jsx)(`img`,{src:po(i,e.projectId,PM(e)),alt:e.meta.prompt??`Slideshow image${a}`,className:W(`block w-full object-cover animate-tick-in motion-reduce:animate-none`,cU(t))}),(0,h.jsxs)(`figcaption`,{className:`absolute inset-x-0 bottom-0 flex flex-wrap items-center justify-between gap-1 bg-panel/90 p-1 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 motion-reduce:transition-none`,children:[(0,h.jsx)(JH,{output:e}),(0,h.jsx)(AM,{action:{kind:`regenerate-image`,outputId:e.id},run:()=>{n.run({kind:`regenerate-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Regenerate`}),(0,h.jsx)(AM,{action:{kind:`delete-image`,outputId:e.id},run:()=>{n.run({kind:`delete-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Delete`})]})]})}function dU({stage:e,outputs:t,actions:n,busy:r}){let i=EM(t,e),a=DM(i,`notes`);return e.state===`running`&&a===void 0?null:(0,h.jsxs)(IH,{children:[(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{n.run({kind:`rerun`,stage:e.kind})},disabled:r,pending:n.pending,children:`Re-run`}),(0,h.jsx)(ZH,{output:DM(i,`instructions`)}),a===void 0?null:(0,h.jsx)(JH,{output:a})]}),(0,h.jsx)(`section`,{"aria-label":`Research notes`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:a===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e.state===`running`?`Research notes will be saved when the writing above finishes.`:`No notes were written.`}):(0,h.jsx)(XH,{output:a})})]})}function fU({stage:e,project:t,outputs:n,actions:r,busy:i}){let{api:a}=B(),o=EM(n,e),s=DM(o,`thumbnail`),c=t.config.sources.thumbnail===`prompt_by_llm`;return(0,h.jsxs)(IH,{className:`grid grid-cols-1 items-start gap-4 min-[900px]:grid-cols-[200px_minmax(0,1fr)]`,children:[s===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No thumbnail has landed yet.`}):(0,h.jsx)(`img`,{src:po(a,s.projectId,PM(s)),alt:s.meta.prompt??`Thumbnail`,className:W(`block w-full rounded-control border border-line bg-panel2 object-cover`,cU(t.format))}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(RH,{children:c?`Prompt written by the LLM`:`Prompt`}),s?.meta.prompt===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`This run stored no prompt for the thumbnail.`}):(0,h.jsx)(`p`,{className:`max-w-[75ch] rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-pretty text-small text-ink`,children:s.meta.prompt}),(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Regenerate`}),(0,h.jsx)(ZH,{output:DM(o,`instructions`)}),s===void 0?null:(0,h.jsx)(JH,{output:s})]})]})]})}function pU({stage:e,project:t,outputs:n,actions:r,busy:i,subtitleControls:a}){let{api:o}=B(),s=t.config.sources.video===`off`&&t.config.sources.audio!==`off`,c=DM(EM(n,e),s?`audio_export`:`video`),l=EM(n,e),u=DM(l,`subtitles_srt`),d=DM(l,`subtitles_vtt`),f=c?.meta.subtitlesMode??t.config.subtitles?.mode,p=e.state===`running`,m=jO(e.progressCurrent??0,e.progressTotal??0);return t.config.sources.video===`off`&&!s?(0,h.jsx)(IH,{children:a}):(0,h.jsxs)(IH,{children:[p?(0,h.jsx)(`p`,{className:`text-small text-run-text`,children:s?`Exporting combined audio`:e.progressTotal===null?`Re-rendering`:`Re-rendering · ${String(m)}%`}):null,c===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:s?`No combined audio export has landed yet.`:`No render has landed yet.`}):s?(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`Combined narration`,src:po(o,c.projectId,PM(c)),className:`h-9 w-full max-w-[720px]`},c.id):(0,h.jsx)(`video`,{controls:!0,preload:`metadata`,src:po(o,c.projectId,PM(c)),"aria-label":`Generated video`,className:W(`mx-auto block max-h-[min(58vh,560px)] w-auto max-w-full rounded-control bg-screen`,t.format===`9:16`?`aspect-[9/16]`:`aspect-video`),children:f===`files`&&d?(0,h.jsx)(`track`,{kind:`captions`,srcLang:`en`,label:`English`,default:!0,src:po(o,t.id,`subtitles-vtt`)},d.id):null},c.id),(0,h.jsxs)(LH,{children:[c===void 0?null:(0,h.jsx)(JH,{output:c,label:s?`Download .wav`:`Download .mp4`}),e.state===`pending`||e.state===`skipped`?null:(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i||![`done`,`failed`,`canceled`].includes(e.state),pending:r.pending,children:s?`Re-export`:`Re-render`}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:[AO(c?.durationMs??void 0),s?`WAV · stereo · 48 kHz`:t.format].filter(e=>e!==void 0).join(` · `)})]}),u||d?(0,h.jsxs)(LH,{children:[u?(0,h.jsx)(JH,{output:u,label:`Download .srt`}):null,d?(0,h.jsx)(JH,{output:d,label:`Download .vtt`}):null]}):null,a?(0,h.jsxs)(`details`,{className:`mt-2 rounded-control border border-line px-4 py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small font-semibold`,children:`Subtitles & fonts`}),a]}):null]})}function mU(e){switch(e.stage.kind){case`research`:return(0,h.jsx)(dU,{...e});case`article`:return(0,h.jsx)(QH,{...e});case`audio`:return(0,h.jsx)(rU,{...e});case`images`:return(0,h.jsx)(lU,{...e});case`thumbnail`:return(0,h.jsx)(fU,{...e});case`video`:return(0,h.jsx)(pU,{...e})}}function hU({project:e,prompts:t,actions:n,inFlight:r,unsavedProviders:i,settingsOpen:a,onToggleSettings:o,primaryOutput:s}){let c=e.status===`running`;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-5 py-2`,children:[(0,h.jsxs)(`div`,{className:`w-full min-w-0 sm:min-w-[220px] sm:flex-1`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,h.jsx)(Zj,{state:e.status}),(0,h.jsx)(Yj,{state:e.status,announce:`Project`})]}),(0,h.jsx)(`h1`,{className:`break-words text-[28px] font-bold leading-tight`,children:e.title}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:gU(e,t)})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s?(0,h.jsx)(`span`,{className:`rounded-control border border-accent bg-accent px-4 py-2 [&_a]:font-semibold [&_a]:text-accent-ink`,children:(0,h.jsx)(JH,{output:s,label:s.role===`video`?`Download video`:s.role===`audio_export`?`Download audio`:`Download article`})}):null,(0,h.jsxs)(J,{"aria-expanded":a,onClick:o,children:[(0,h.jsx)(jk,{"aria-hidden":`true`,className:`mr-2 size-4`}),`Run settings`,i?` •`:``]}),c||e.status===`pending`?(0,h.jsx)(J,{disabled:n.pending,onClick:()=>n.run({kind:`pause`}),children:`Pause`}):null,e.status===`paused`||e.status===`failed`?(0,h.jsx)(J,{disabled:n.pending||r||i,onClick:()=>n.run({kind:`resume`}),children:`Resume`}):null,c?(0,h.jsx)(AM,{action:{kind:`cancel`},run:()=>{n.run({kind:`cancel`})},pending:n.pending,children:`Cancel run`}):null]}),i?(0,h.jsx)(`p`,{className:`w-full rounded-control border border-line2 bg-panel2 px-3 py-2 text-small text-ink2`,children:`You have unsaved changes. Save or discard them before resuming.`}):null]})}function gU(e,t){let n=e.config.articlePrompt,r=t===void 0||t.some(e=>e.name===n);return[n===void 0||n===``?void 0:r?n:`${n} (deleted)`,e.format,`started ${Sc(e.createdAt)}`].filter(e=>e!==void 0).join(` · `)}var _U=e=>e.state===`done`||e.state===`provided`;function vU(e){let t=e.filter(e=>e.state!==`skipped`),n=t.length,r=t.filter(_U).length,i=t.reduce((e,t)=>_U(t)?e+1:t.progressTotal===null||t.progressTotal<=0?e:e+Math.min(.99,Math.max(0,(t.progressCurrent??0)/t.progressTotal)),0);return{completed:r,total:n,percent:n===0?0:Math.min(r===n?100:99,Math.round(i/n*100))}}function yU(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`&&_U(e));if(n)return n.kind;let r=e.find(e=>e.state===`pending`);return r?r.kind:e.find(e=>e.kind===`article`&&_U(e))?.kind??e.find(e=>e.state!==`skipped`)?.kind??`article`}function bU({stages:e,project:t}){let n=vU(e);return(0,h.jsxs)(`div`,{className:`rounded-panel border border-line bg-panel px-5 py-4`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold`,children:`Overall progress`}),(0,h.jsxs)(`span`,{className:`text-small text-ink2`,children:[n.completed,` of `,n.total,` stages finished`]})]}),(0,h.jsxs)(`span`,{className:`text-small font-semibold tabular-nums`,children:[n.percent,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`Overall progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n.percent,"aria-valuetext":`${n.percent} percent; ${n.completed} of ${n.total} stages finished`,className:`h-2 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:W(`h-full origin-left bg-accent transition-transform duration-200 motion-reduce:transition-none`,t.status===`failed`&&`bg-red`),style:{transform:`scaleX(${n.percent/100})`}})}),(0,h.jsx)(`p`,{className:`mt-2 text-label text-ink3`,children:`Combines finished stages with progress reported by active stages.`})]})}function xU({stages:e,project:t,outputs:n,selected:r,onSelect:i}){return(0,h.jsxs)(`nav`,{"aria-label":`Project stages`,className:`h-fit rounded-panel border border-line bg-panel lg:sticky lg:top-6`,children:[(0,h.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Stages`})}),(0,h.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-1`,children:e.map(e=>{let a=e.kind===r,o=SO(e.kind,t.config),s=e.state===`done`||e.state===`provided`;return(0,h.jsxs)(`button`,{type:`button`,"aria-label":`${o}, ${e.state}`,"aria-current":a?`step`:void 0,onClick:()=>i(e.kind),className:W(`group relative flex min-w-0 items-start gap-2 border-b border-line px-3 py-4 sm:gap-3 sm:px-4 text-left transition-colors last:border-b-0 hover:bg-panel2`,a&&`bg-panel2 before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:bg-accent`,e.state===`skipped`&&`text-ink3`),children:[(0,h.jsx)(Tc,{kind:e.kind,className:W(`mt-0.5 shrink-0 text-ink2`,a&&`text-run-text`)}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block text-body font-semibold`,children:o}),(0,h.jsx)(`span`,{className:`mt-1 block truncate text-label text-ink2`,children:TO(e,n,t)}),(0,h.jsxs)(`span`,{className:`mt-2 flex items-center gap-2`,children:[(0,h.jsx)(Zj,{state:e.state}),(0,h.jsx)(Yj,{state:e.state,announce:o})]})]}),s?(0,h.jsx)(bk,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):e.state===`canceled`?(0,h.jsx)(wk,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 sm:block`}):a?(0,h.jsx)(Ck,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):null]},e.id)})})]})}function SU({project:e,providers:t,actions:n,inFlight:r,edits:i,setEdits:a}){let{api:o}=B(),s=R(Ly(o)),{config:c}=e,l=i.llm??c.llm??{provider:``,model:``},u=i.audio??c.audio??{provider:``,model:``,voice:``},d=i.images??c.images??{provider:``,model:``},f=c.sources.research===`generate`||c.sources.article===`generate`||c.sources.thumbnail===`prompt_by_llm`||c.sources.audio===`generate`&&(c.intro?.mode===`llm`||c.outro?.mode===`llm`),p=c.sources.audio===`generate`,m=c.sources.images===`generate`||c.sources.thumbnail===`from_prompt`||c.sources.thumbnail===`prompt_by_llm`;if(!f&&!p&&!m)return null;let g=(e.status===`paused`||e.status===`failed`)&&!r,_=CU(c,i),v=Object.keys(_).length>0,y=e=>e.provider!==``&&e.model.trim()!==``&&t.some(t=>t.id===e.provider&&(t.readiness.kind===`keyed`?t.readiness.hasKey:t.readiness.installed)),b=(!_.llm||y(_.llm))&&(!_.images||y(_.images))&&(!_.audio||y(_.audio)&&(s.data?.voices??[]).some(e=>e.provider===_.audio?.provider&&e.voiceId===_.audio.voice));return(0,h.jsx)(cA,{className:`block py-3`,"data-tour":`project-providers`,children:(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-row font-semibold`,children:`Run providers`}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:g?`Save your choices, then press Resume when ready. Finished outputs stay as they are. Changing the voice, TTS model or chunking restarts unfinished narration to keep one voice throughout.`:r&&e.status===`paused`?`Pausing: waiting for active requests to stop before providers can be changed.`:e.status===`done`||e.status===`canceled`?`These are the saved providers for this run. Start a new run to choose different providers.`:`Pause the run to change providers, models or voice. These controls are also available after a failure.`}),(0,h.jsxs)(`fieldset`,{disabled:!g||n.pending,className:`mt-3 flex min-w-0 flex-col gap-3 disabled:opacity-60`,children:[f?(0,h.jsx)(wU,{label:`Text`,choice:l,family:`llm`,providers:t,onChange:e=>a(t=>({...t,llm:e}))}):null,p?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(wU,{label:`TTS`,choice:u,family:`tts`,providers:t,onChange:e=>a(t=>({...t,audio:{...e,voice:e.provider===u.provider?u.voice:``}}))}),(0,h.jsx)(wj,{label:`Narration voice`,inline:!0,value:u.voice,placeholder:`Pick a voice`,problem:void 0,options:(s.data?.voices??[]).filter(e=>e.provider===u.provider).map(e=>({value:e.voiceId,label:e.name})),onPick:e=>a(t=>({...t,audio:{...u,voice:e}}))})]}):null,p?(0,h.jsx)(Bj,{value:i.chunking??c.chunking??{mode:`whole`},onPick:e=>a(t=>({...t,chunking:e}))}):null,m?(0,h.jsx)(wU,{label:`Image`,choice:d,family:`image`,providers:t,onChange:e=>a(t=>({...t,images:e}))}):null,(0,h.jsx)(`div`,{children:(0,h.jsx)(J,{disabled:!g||n.pending||!b||!v,onClick:()=>n.run({kind:`providers`,choices:_},()=>a({})),children:`Save providers`})})]}),v?(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Save or discard provider changes before resuming.`}),(0,h.jsx)(J,{disabled:n.pending,onClick:()=>a({}),children:`Discard provider changes`})]}):null,s.error?(0,h.jsx)(`p`,{className:`mt-2 text-small text-red`,children:s.error.message}):null]})})}function CU(e,t){return{...t.chunking&&!Rj(t.chunking,e.chunking)?{chunking:t.chunking}:{},...t.llm&&!TU(t.llm,e.llm)?{llm:t.llm}:{},...t.audio&&!TU(t.audio,e.audio)?{audio:t.audio}:{},...t.images&&!TU(t.images,e.images)?{images:t.images}:{}}}function wU({label:e,choice:t,family:n,providers:r,onChange:i}){return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(Dj,{label:`${e} provider`,inline:!0,family:n,providers:r,value:t.provider,problem:void 0,onPick:e=>i({provider:e,model:``})}),(0,h.jsx)(Oj,{label:`${e} model`,inline:!0,provider:t.provider,value:t.model,problem:void 0,onPick:e=>i({...t,model:e})}),n===`llm`?(0,h.jsx)(Aj,{choice:t,onChange:i}):null]})}function TU(e,t){return e.provider===t?.provider&&e.model===t.model&&e.thinking===t.thinking&&(`voice`in e?e.voice:void 0)===(t&&`voice`in t?t.voice:void 0)}function EU(e,t){switch(e){case`research`:case`article`:return t.llm?.provider;case`audio`:return t.audio?.provider;case`images`:case`thumbnail`:return t.images?.provider;case`video`:return}}function DU(e,t,n){let r=EU(e,t);if(r===void 0||r===``)return;let i=n.find(e=>e.id===r);if(i!==void 0)return i.readiness.kind===`keyed`?i.readiness.hasKey?void 0:{label:`Key missing`,provider:r}:i.readiness.installed?void 0:{label:`CLI missing`,provider:r}}var OU={research:`Research notes`,article:`Article workspace`,audio:`Narration`,images:`Image library`,thumbnail:`Thumbnail preview`,video:`Preview & export`};function kU({stage:e,project:t,outputs:n,providers:r,actions:i,children:a,active:o=!0}){let s=SO(e.kind,t.config),c=t.status===`paused`?{...i,pending:!0}:i,l=DU(e.kind,t.config,r),u=i.refusal?.stage===e.kind?i.refusal.message:void 0,d=e.state===`failed`||e.state===`canceled`,f=n.some(t=>t.stageKind===e.kind&&t.role!==`instructions`)||e.state===`running`||e.state===`done`||e.state===`provided`||e.kind===`video`&&e.state!==`skipped`,p=e.progressTotal===null||e.progressTotal<=0?void 0:Math.min(100,Math.max(0,Math.round((e.progressCurrent??0)/e.progressTotal*100)));return(0,h.jsxs)(`section`,{"data-tour":`project-${e.kind}`,hidden:!o,"aria-label":`${s} workspace`,className:o?`min-w-0 rounded-panel border border-line bg-panel`:`hidden`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-line px-5 py-4`,children:[(0,h.jsx)(Tc,{kind:e.kind,className:`text-ink2`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`text-row font-bold`,children:e.kind===`video`&&s===`Audio export`?`Listen & export`:OU[e.kind]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:TO(e,n,t)})]}),(0,h.jsx)(Yj,{state:e.state})]}),e.state===`running`?(0,h.jsxs)(`div`,{className:`border-b border-line px-5 py-3`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex justify-between text-small text-run-text`,children:[(0,h.jsxs)(`span`,{children:[s,` in progress`]}),p===void 0?(0,h.jsx)(`span`,{children:`Waiting for provider progress`}):(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[p,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`${s} progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":p,className:`h-1.5 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:`h-full origin-left bg-accent`,style:{transform:`scaleX(${(p??0)/100})`}})})]}):null,d?(0,h.jsxs)(`div`,{className:`m-5 rounded-control border border-red/30 bg-red-tint p-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`p`,{className:`min-w-0 flex-1 text-small text-red`,children:e.state===`failed`?`${s} needs attention.`:`${s} was canceled.`}),(0,h.jsx)(`span`,{className:`text-label text-ink2`,children:EO(e)}),(0,h.jsx)(`button`,{type:`button`,disabled:l!==void 0||c.pending,onClick:()=>c.run({kind:`retry`,stage:e.kind}),className:`rounded-control border border-red px-3 py-2 text-small text-ink hover:bg-panel2 disabled:opacity-50`,children:l?.label??`Retry stage`})]}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:t.status===`paused`?`Resume the project to continue with its saved settings.`:`Retry keeps completed outputs. To change the provider or model, open Run settings.`}),e.failureReason?(0,h.jsxs)(`details`,{className:`mt-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small text-red`,children:`Error details`}),(0,h.jsx)(`span`,{className:`mt-2 block max-h-48 overflow-auto whitespace-pre-wrap break-words text-label text-ink2`,children:e.failureReason})]}):null,l?(0,h.jsxs)(`p`,{className:`mt-3 text-small text-ink2`,children:[l.label,` for `,l.provider,`.`,` `,(0,h.jsx)(ia,{to:`/settings`,className:`underline underline-offset-4`,children:`Open Settings`})]}):null]}):null,u?(0,h.jsx)(`div`,{className:`px-5 pt-4`,children:(0,h.jsx)(KH,{message:u,onDismiss:i.dismissRefusal})}):null,e.state===`running`&&e.kind!==`article`&&e.kind!==`images`&&e.kind!==`video`?(0,h.jsx)(NM,{projectId:t.id,stage:e.kind}):null,f?a:d?null:(0,h.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,h.jsx)(Tc,{kind:e.kind,className:`size-8 text-ink3`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:e.state===`skipped`?`${s} was switched off for this run.`:t.status===`paused`?`Resume the project when you are ready to continue.`:`This stage will start when its inputs are ready.`}),(0,h.jsx)(`p`,{className:`max-w-md text-small text-ink3`,children:e.state===`skipped`?`The other stages are available from the list.`:`You can review completed outputs while the project runs.`})]})]})}function AU({project:e,actions:t,inFlight:n,value:r,uploading:i,onChange:a,onDiscard:o,onUploading:s}){let c=!$D(QD(e.config.subtitles,e.config.sources),r),l=e.status!==`running`&&!n,u=e.config.sources.audio!==`off`,d=e.config.sources.video!==`off`&&e.config.sources.images!==`off`;return(0,h.jsxs)(`div`,{"data-tour":`project-subtitles`,className:`mt-2 min-w-0 border-t border-line pt-4`,children:[(0,h.jsx)(hM,{value:r,format:e.format,audioEnabled:u,videoEnabled:d,disabled:!l||t.pending,onChange:a,onUploading:s}),(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink2`,children:l?e.status===`paused`?`Save subtitles, then Resume to update the export. Existing narration and images are reused.`:`Saving updates only the local export using saved narration and images. No paid generation requests are made.`:`Pause the run and wait for active requests to stop before changing subtitles.`}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(J,{disabled:!l||t.pending||i||!u||!c||!eO(r),onClick:()=>t.run({kind:`subtitles`,subtitles:QD(r,e.config.sources)},o),children:`Save subtitles`}),c?(0,h.jsx)(J,{variant:`ghost`,disabled:t.pending||i,onClick:o,children:`Discard subtitle changes`}):null,c&&e.status===`paused`?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Save or discard subtitle changes before resuming.`}):null]})]})}function jU(e){let{api:t}=B(),n=_(),[r,i]=(0,m.useState)(void 0),a=tt({mutationFn:e=>NU(t,e.projectId,e.action),onMutate:()=>{i(void 0)},onSuccess:async(e,t)=>{if(!e.ok){i({message:e.message,stage:MU(t.action)});return}let{project:r,stages:a,outputs:o}=e.value;n.setQueryData(jy.project(t.projectId),{project:r,stages:a,outputs:o}),n.invalidateQueries({queryKey:jy.projects}),await n.invalidateQueries({queryKey:jy.project(t.projectId)})},onError:(e,t)=>{i({message:e.message,stage:MU(t.action)})}});return{run:(t,n)=>{a.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok&&n?.()}})},pending:a.isPending,refusal:r,dismissRefusal:()=>{i(void 0)}}}function MU(e){switch(e.kind){case`cancel`:case`pause`:case`resume`:case`providers`:return;case`retry`:case`rerun`:return e.stage;case`subtitles`:return`video`;case`save-article`:return`article`;case`delete-image`:case`regenerate-image`:return`images`}}function NU(e,t,n){switch(n.kind){case`pause`:return wH(e,t);case`resume`:return TH(e,t);case`providers`:return EH(e,t,n.choices);case`subtitles`:return DH(e,t,n.subtitles);case`cancel`:return CH(e,t);case`retry`:return OH(e,t,n.stage);case`rerun`:return kH(e,t,n.stage);case`save-article`:return AH(e,t,n.markdown);case`delete-image`:return jH(e,t,n.outputId);case`regenerate-image`:return MH(e,t,n.outputId)}}var PU=200;function FU(e){let{api:t,openEvents:n}=B(),r=_();(0,m.useEffect)(()=>{let i=_O(()=>{r.invalidateQueries({queryKey:jy.project(e)}),r.invalidateQueries({queryKey:jy.projects})},PU),a=Xy(n,Ao(t,`projects/${e}`),{refetch:i.ask,previewWriting:t=>{r.setQueryData(jM(e),e=>MM(e??[],t))},appendArticle:t=>{r.setQueryData(jy.article(e),e=>`${e??``}${t}`)},patch:t=>{t.type===`stage.state`&&t.state===`running`&&(r.setQueryData(jM(e),e=>(e??[]).filter(e=>e.stage!==t.stage)),t.stage===`article`&&r.setQueryData(jy.article(e),``)),r.setQueryData(jy.project(e),e=>hO(e,t))}});return()=>{a(),i.stop()}},[t,n,r,e])}function IU({projectId:e}){return(0,h.jsx)(LU,{projectId:e},e)}function LU({projectId:e}){let{api:t}=B(),n=R(Ny(t,e)),r=R(Iy(t)),i=R(Ry(t)),a=jU(e),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)({}),[f,p]=(0,m.useState)(),[g,_]=(0,m.useState)(),v=lk(e),y=(0,m.useRef)(void 0);if((0,m.useEffect)(()=>{if(v===void 0){y.current=void 0;return}n.data!==void 0&&y.current!==v&&(y.current=v,v===`project`&&s(!0),v===`download`&&l({projectId:e,stage:xO(n.data.project.config)===`article`?`article`:`video`}))},[v,e,n.data]),FU(e),n.error!==null)return(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message});if(n.data===void 0)return(0,h.jsx)(RU,{});let{project:b,stages:x,outputs:S}=n.data,C=c?.projectId===e?c.stage:yU(x),w=t=>l({projectId:e,stage:t}),T=S.find(e=>e.role===`video`||e.role===`audio_export`)??(b.config.sources.video===`off`&&b.config.sources.audio===`off`?S.find(e=>e.role===`article_md`):void 0),E=x.some(e=>e.state===`running`),D=b.status===`running`||b.status===`paused`||E||a.pending,O=QD(b.config.subtitles,b.config.sources),k=f?.projectId===e?QD(f.value,b.config.sources):O,A=!$D(k,O),j=g?.projectId===e&&g.pending,M=()=>p(t=>t?.projectId===e?void 0:t);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,children:[(0,h.jsx)(ia,{to:`/`,className:`mb-[10px] block text-small text-ink2 hover:text-ink`,children:`< Projects`}),(0,h.jsxs)(`div`,{"data-tour":`project-controls`,children:[(0,h.jsx)(hU,{project:b,prompts:i.data?.prompts,actions:a,inFlight:E,settingsOpen:o,onToggleSettings:()=>s(!o),primaryOutput:T,unsavedProviders:Object.keys(CU(b.config,u)).length>0||A||j}),(0,h.jsx)(`div`,{hidden:!o,className:o?`mt-4 rounded-panel border border-line bg-panel`:`hidden`,children:(0,h.jsx)(SU,{project:b,providers:r.data?.providers??[],actions:a,inFlight:E,edits:u,setEdits:d})}),a.refusal===void 0||a.refusal.stage!==void 0?null:(0,h.jsx)(cA,{className:`py-[10px]`,children:(0,h.jsx)(KH,{message:a.refusal.message,onDismiss:a.dismissRefusal})})]}),(0,h.jsx)(TM,{}),(0,h.jsx)(bU,{stages:x,project:b}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(xU,{stages:x,project:b,outputs:S,selected:C,onSelect:w}),(0,h.jsx)(`div`,{className:`min-w-0`,children:x.map(t=>(0,h.jsx)(kU,{active:t.kind===C,stage:t,project:b,outputs:S,providers:r.data?.providers??[],actions:a,children:(0,h.jsx)(mU,{stage:t,project:b,outputs:S,actions:a,busy:D,...t.kind===`video`?{subtitleControls:(0,h.jsx)(AU,{project:b,actions:a,inFlight:E,value:k,uploading:j,onChange:t=>p({projectId:e,value:QD(t,b.config.sources)}),onDiscard:M,onUploading:t=>_(n=>n?.projectId===e&&n.pending===t?n:{projectId:e,pending:t})},e)}:{}})},t.id))})]})]})}function RU(){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,role:`status`,"aria-label":`Loading project`,children:[(0,h.jsx)(`div`,{className:`h-28 rounded-panel bg-panel`}),(0,h.jsx)(`div`,{className:`h-24 rounded-panel border border-line bg-panel`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(sA,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(cA,{children:[(0,h.jsx)(`span`,{className:`size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`h-4 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-16 rounded-control bg-panel2`})]},e))}),(0,h.jsx)(`div`,{className:`h-[560px] rounded-panel border border-line bg-panel`})]})]})}var zU=`relative grid grid-cols-[14px_minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[4px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[14px_minmax(0,1fr)_140px_100px_32px]`,BU=`col-start-2 row-start-2 text-small text-ink2 tabular-nums md:col-start-3 md:row-start-1`,VU=`col-start-3 row-start-1 justify-end md:col-start-4`,HU=`relative z-10 col-start-4 row-start-1 size-8 p-0 md:col-start-5`;function UU(){let{api:e}=B(),t=_(),n=R(My(e)),[r,i]=(0,m.useState)(void 0),a=tt({mutationFn:t=>oo(e,t),onSettled:async()=>{i(void 0),await t.invalidateQueries({queryKey:jy.projects})}});return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(`div`,{className:`mb-4 flex items-center`,children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Projects`}),(0,h.jsx)(J,{variant:`accent`,className:`ml-auto`,asChild:!0,children:(0,h.jsx)(ia,{to:`/play`,children:`New run`})})]}),(0,h.jsx)(TM,{}),n.data?.projects.length===0?(0,h.jsx)(Pk,{}):null,n.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:n.error.message})}),n.data===void 0?n.error===null?(0,h.jsx)(qU,{}):null:n.data.projects.length===0?(0,h.jsx)(sA,{children:(0,h.jsxs)(`p`,{className:`px-4 py-7 text-body text-ink2`,children:[`No projects yet. Set up a run on`,` `,(0,h.jsx)(ia,{to:`/play`,className:`rounded-control text-ink underline underline-offset-[3px]`,children:`Play`}),`.`]})}):(0,h.jsx)(sA,{children:n.data.projects.map(e=>(0,h.jsx)(WU,{project:e,onDelete:()=>{i(e)}},e.id))}),a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`mt-[10px] text-label text-red`,children:a.error.message}),(0,h.jsx)(oA,{open:r!==void 0,title:r===void 0?``:`Delete "${r.title}"?`,consequence:`Deletes the project and every file it produced.`,verb:`Delete`,pending:a.isPending,onConfirm:()=>{r!==void 0&&a.mutate(r.id)},onCancel:()=>{i(void 0)}})]})}function WU({project:e,onDelete:t}){return(0,h.jsxs)(`div`,{className:zU,children:[(0,h.jsx)(Zj,{state:e.status,className:`col-start-1 row-start-1`}),(0,h.jsxs)(`span`,{className:`col-start-2 row-start-1 flex min-w-0 flex-wrap items-baseline gap-x-3`,children:[(0,h.jsx)(ia,{to:`/projects/$projectId`,params:{projectId:e.id},className:`rounded-control font-semibold after:absolute after:inset-0 after:content-['']`,children:e.title}),(0,h.jsx)(`span`,{className:`truncate text-small text-ink2`,children:GU(e)})]}),(0,h.jsx)(`span`,{className:BU,children:Sc(e.createdAt)}),(0,h.jsx)(Yj,{state:e.status,announce:e.title,className:VU}),(0,h.jsx)(KU,{project:e,onDelete:t}),e.status===`running`?(0,h.jsx)(lA,{current:e.progress,total:1}):null]})}function GU(e){let t=e.config.articlePrompt;return[t===void 0||t===``?void 0:t,e.format].filter(e=>e!==void 0).join(` · `)}function KU({project:e,onDelete:t}){let n=e.status===`running`;return(0,h.jsxs)(dA,{children:[(0,h.jsx)(fA,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.title}`,className:HU,children:(0,h.jsx)(Dk,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(pA,{children:[(0,h.jsx)(`span`,{title:n?`Cancel the run first`:void 0,children:(0,h.jsx)(mA,{disabled:n,onSelect:t,children:`Delete`})}),n?(0,h.jsx)(`p`,{className:`engraved px-[10px] py-[5px] text-ink3`,children:`Cancel the run first`}):null]})]})}function qU(){return(0,h.jsx)(sA,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(`div`,{className:zU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-3 w-2/5 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-[10px] w-[90px] rounded-control bg-panel2 md:col-start-3`}),(0,h.jsx)(`span`,{className:`col-start-4 row-start-1 h-[10px] w-14 justify-self-end rounded-control bg-panel2 md:col-start-4`})]},e))})}function JU({promptId:e,kind:t,from:n,onLeave:r}){let{api:i}=B(),a=_(),o=ck(),s=R(Ry(i)),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),f=(0,m.useId)(),[p,g]=pO(JSON.stringify(e===void 0?[`new`,t,n??null]:[`prompt`,e])),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(void 0),S=b!==void 0,[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=p??b??O,A=tt({mutationFn:t=>To(i,t,e),onSuccess:async(e,t)=>{if(!e.ok){y(e.fields);return}x(e.value),g(e=>e===t?void 0:e),o({type:`prompt-saved`,id:e.value.id,kind:e.value.kind}),await a.invalidateQueries({queryKey:Ry(i).queryKey})}}),j=tt({mutationFn:e=>Eo(i,e),onSuccess:async()=>{w(!1),g(void 0),await a.invalidateQueries({queryKey:Ry(i).queryKey}),r(k.kind)}});EA(S,()=>{r(k.kind)});let M=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},N=qA(k,v),P=JA(N),F=ZA(k.body),I=k.body.trim()===``?[]:YA(N),ee=k.name.trim()===``?[]:XA(N);return sk({promptNamed:k.name.trim()!==``&&ee.length===0,promptBodyReady:k.body.trim()!==``&&I.length===0,promptHasKeywords:F.length>0&&I.length===0,promptSaveReady:P===void 0&&!A.isPending&&!S,promptSaving:A.isPending||S,promptIsArticle:k.kind===`article`,promptIsImage:k.kind===`image`}),s.error===null?E!==void 0&&T===void 0?(0,h.jsx)(AA,{}):E!==void 0&&D===void 0?(0,h.jsx)(YU,{kind:t,children:`That prompt is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(ia,{to:`/prompts`,search:{kind:k.kind},className:`mb-[10px] inline-flex items-center gap-1 text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(Sk,{"aria-hidden":`true`,className:`size-[14px]`}),`Prompts`]}),(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:e===void 0?`New prompt`:`Edit 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:`${kA} flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`flex items-end gap-[14px]`,children:[(0,h.jsxs)(`div`,{"data-tour":`prompt-name`,className:`flex-1`,children:[(0,h.jsx)(NA,{htmlFor:c,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(FA,{id:c,value:k.name,"aria-invalid":ee.length>0,"aria-describedby":ee.length===0?void 0:l,onChange:e=>{M({...k,name:e.target.value},`name`)}}),ee.length===0?null:(0,h.jsx)(`p`,{id:l,className:`mt-1 text-label text-red`,children:ee.map(e=>e.message).join(` `)})]}),(0,h.jsx)(PA,{label:`Kind`,value:k.kind,options:rA,onPick:e=>{M({...k,kind:e},`name`)}})]}),(0,h.jsxs)(`div`,{"data-tour":`prompt-body`,children:[(0,h.jsx)(NA,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(ej,{id:u,value:k.body,invalid:I.length>0,describedBy:I.length===0?void 0:d,onChange:e=>{M({...k,body:e},`body`)}})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-save`,children:(0,h.jsx)(OA,{onDelete:e===void 0?void 0:()=>{w(!0)},blocked:P,blockedId:f,pending:A.isPending,saved:S,cancel:(0,h.jsx)(J,{asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts`,search:{kind:k.kind},onClick:()=>{g(void 0)},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:`${kA} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(wA,{slots:F,body:k.body,lint:I,lintId:d})})]}),(0,h.jsx)(oA,{open:C,title:`Delete "${k.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:j.isPending,onConfirm:()=>{e!==void 0&&j.mutate(e)},onCancel:()=>{w(!1)}})]}):(0,h.jsx)(YU,{kind:k.kind,children:s.error.message})}function YU({kind:e,children:t}){return(0,h.jsx)(jA,{back:(0,h.jsx)(ia,{to:`/prompts`,search:{kind:e},className:MA,children:`Back to Prompts`}),children:t})}var XU=`grid grid-cols-[minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[6px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[260px_minmax(0,1fr)_auto_32px]`,ZU=`col-span-3 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1`,QU=`md:col-start-2 md:row-start-1`;function $U({kind:e,onKind:t}){let{api:n}=B(),r=_(),i=R(Ry(n)),[a,o]=(0,m.useState)(void 0),s=tt({mutationFn:e=>Eo(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:jy.prompts})}}),c=i.data?.prompts.filter(t=>t.kind===e);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:`Prompts`}),(0,h.jsxs)(`div`,{className:`mb-4 flex items-center gap-4`,children:[(0,h.jsx)(hA,{type:`single`,value:e,"aria-label":`Prompt kind`,onValueChange:e=>{let n=rA.find(t=>t.value===e);n!==void 0&&t(n.value)},children:rA.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(eW,{kind:e})]}),i.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:i.error.message})}),c===void 0?i.error===null?(0,h.jsx)(rW,{}):null:c.length===0?(0,h.jsx)(tW,{kind:e}):(0,h.jsx)(sA,{children:c.map(e=>(0,h.jsxs)(`div`,{className:XU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(`span`,{className:W(ZU,QU),children:e.slots.map(e=>(0,h.jsx)(uA,{name:e},e))}),(0,h.jsx)(J,{className:`col-start-2 row-start-1 md:col-start-3`,asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts/$promptId`,params:{promptId:e.id},children:`Edit`})}),(0,h.jsx)(nW,{prompt:e,onDelete:()=>{o(e)}})]},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{className:`mt-[10px] text-label text-red`,children:s.error.message}),(0,h.jsx)(oA,{open:a!==void 0,title:a===void 0?``:`Delete "${a.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>{o(void 0)}})]})}function eW({kind:e}){return(0,h.jsx)(J,{asChild:!0,children:(0,h.jsxs)(ia,{to:`/prompts/new`,search:{kind:e},children:[(0,h.jsx)(kk,{"aria-hidden":`true`,className:`size-[14px]`}),`New prompt`]})})}function tW({kind:e}){return(0,h.jsx)(sA,{children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-4 py-7 text-ink2`,children:[(0,h.jsx)(`span`,{className:`max-w-[75ch]`,children:`No ${e} prompts yet. A prompt is text with {{keywords}}; each keyword becomes a field on Play.`}),(0,h.jsx)(eW,{kind:e})]})})}function nW({prompt:e,onDelete:t}){return(0,h.jsxs)(dA,{children:[(0,h.jsx)(fA,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-3 row-start-1 size-8 p-0 md:col-start-4`,children:(0,h.jsx)(Dk,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(pA,{children:[(0,h.jsx)(mA,{asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts/new`,search:{kind:e.kind,from:e.id},children:`Duplicate`})}),(0,h.jsx)(mA,{onSelect:t,children:`Delete`})]})]})}function rW(){return(0,h.jsx)(sA,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:XU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsxs)(`span`,{className:W(ZU,QU),children:[(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[18px] w-[72px] rounded-control bg-panel2`})]}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-3`})]},e))})}function iW(){let{api:e}=B(),t=_(),n=R({queryKey:[`catalogue`],queryFn:async()=>Za(await e.fetch(`${e.origin}/api/providers/catalogue`)),refetchInterval:3e4}),r=tt({mutationFn:async()=>Za(await e.fetch(`${e.origin}/api/providers/catalogue/refresh`,{method:`POST`})),onSuccess:e=>{t.setQueryData([`catalogue`],e),t.invalidateQueries({queryKey:[`provider-models`]})}});return(0,h.jsxs)(`section`,{className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Models and request limits`}),(0,h.jsx)(`p`,{className:`my-2 text-body text-ink2`,children:`The catalogue lists supported text, image and speech models, their prices and request limits. Local YAML edits load automatically; model pickers refresh every 30 seconds.`}),n.data?.path?(0,h.jsx)(`p`,{className:`my-2 break-all font-mono text-small`,children:n.data.path}):null,(0,h.jsxs)(`p`,{className:`mb-3 text-small text-ink2`,children:[`Verified `,n.data?.updatedAt??`date unavailable`,`. Refresh replaces your local file with the published catalogue and saves the previous file alongside it.`]}),(0,h.jsx)(J,{disabled:r.isPending||!n.data?.path,onClick:()=>r.mutate(),children:r.isPending?`Refreshing…`:`Refresh published catalogue`}),n.data?.warning||n.error||r.error?(0,h.jsx)(`p`,{role:`alert`,className:`mt-2 text-body text-red`,children:r.error?.message??n.error?.message??n.data?.warning}):null,r.isSuccess?(0,h.jsx)(`p`,{role:`status`,className:`mt-2 text-small text-green`,children:`Catalogue updated.`}):null]})}function aW({provider:e,readiness:t}){let{api:n}=B(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(void 0),[d,f]=(0,m.useState)(!1),p=e.cliPath?.configured??null,g=e.id===`claude-code`?`claude`:e.id,v=e.cliPath?.command??g,y=l??p??``,b=tt({mutationFn:t=>ho(n,e.id,t),onMutate:()=>f(!1),onSuccess:async e=>{r.setQueryData(jy.providers,t=>t?{...t,providers:t.providers.map(t=>t.id===e.id?e:t)}:void 0),u(void 0),f(!0),await r.invalidateQueries({queryKey:jy.providers})}});return(0,m.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),TA);return()=>clearTimeout(e)},[d]),(0,h.jsxs)(`div`,{"data-ready":t.installed,className:`grid gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0 sm:grid-cols-[140px_1fr]`,children:[(0,h.jsx)(`span`,{id:i,className:W(`font-semibold`,t.installed?`text-ink`:`text-ink3`),children:e.displayName}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-ink2`,"aria-live":`polite`,children:[(0,h.jsx)(Zj,{state:t.installed?`done`:`pending`}),(0,h.jsx)(`span`,{children:oW(t,p)})]}),(0,h.jsxs)(`p`,{className:`mt-1 break-all text-label text-ink3`,children:[`Command: `,(0,h.jsx)(`code`,{children:v})]}),(0,h.jsxs)(`form`,{className:`mt-3`,onSubmit:e=>{e.preventDefault(),b.isPending||b.mutate(y)},children:[(0,h.jsx)(NA,{htmlFor:a,id:o,className:`mb-[5px]`,children:`Executable path`}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(FA,{id:a,autoComplete:`off`,spellCheck:!1,maxLength:4096,"aria-labelledby":`${i} ${o}`,"aria-invalid":b.error!==null,"aria-describedby":`${s}${b.error?` ${c}`:``}`,placeholder:g,value:y,disabled:b.isPending,onChange:e=>{u(e.target.value),f(!1),b.reset()}}),(0,h.jsx)(J,{type:`submit`,"aria-label":`Save ${e.displayName} path`,disabled:b.isPending,children:b.isPending?`Checking…`:`Save path`}),d?(0,h.jsx)(DA,{}):null]}),(0,h.jsxs)(`p`,{id:s,className:`mt-1 text-label text-ink3`,children:[`Leave blank to find `,(0,h.jsx)(`code`,{children:g}),` on PATH. Use an absolute path without quotes or arguments.`]}),b.error?(0,h.jsx)(`p`,{id:c,role:`alert`,className:`mt-1 text-label text-red`,children:b.error.message}):null]}),(0,h.jsxs)(`p`,{className:`mt-2 text-label text-ink3`,children:[`Sign in through `,e.displayName,` itself before generating; Slopify uses that login.`]})]})]})}function oW(e,t){return e.installed?e.version===void 0?`Installed`:`Installed, version ${e.version}`:t===null?`Not found on PATH`:`Not found at saved path`}var sW=[`llm`,`tts`,`image`],cW={llm:`API keys · LLM`,tts:`API keys · Text to speech`,image:`API keys · Image generation`},lW=`••••••••••••`,uW=`grid grid-cols-[140px_1fr_auto] items-end gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0`,dW=`engraved border-t border-line px-4 py-3 text-ink3 first:border-t-0`;function fW(){let{api:e}=B(),t=R(Iy(e));if(t.error!==null)return(0,h.jsx)(sA,{children:(0,h.jsx)(cA,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:t.error.message})})});if(t.data===void 0)return(0,h.jsx)(mW,{});let n=t.data.providers,r=n.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey);return(0,h.jsx)(sA,{children:sW.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,className:`border-t border-line first:border-t-0`,children:[(0,h.jsx)(`h2`,{className:dW,children:cW[e]}),n.filter(t=>t.family===e).map(e=>e.readiness.kind===`cli`?(0,h.jsx)(aW,{provider:e,readiness:e.readiness},e.id):(0,h.jsx)(pW,{provider:e,hasKey:e.readiness.hasKey},e.id)),e===`llm`&&r?(0,h.jsx)(`p`,{className:`border-t border-line px-4 pt-[10px] pb-[14px] text-small text-ink2`,children:`Paste a key to make its provider selectable on Play.`}):null]},e))})}function pW({provider:e,hasKey:t}){let{api:n}=B(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(void 0),[b,x]=(0,m.useState)(!1),S=async()=>{f(!0),y(void 0);try{await z(n,e.id,l),u(``),g(!0),await r.invalidateQueries({queryKey:jy.providers})}catch(e){y(e instanceof Error?e.message:String(e))}finally{f(!1)}},C=tt({mutationFn:()=>go(n,e.id),onSuccess:async()=>{x(!1),y(void 0),await r.invalidateQueries({queryKey:jy.providers})},onError:e=>{x(!1),y(e.message)}});(0,m.useEffect)(()=>{if(!p)return;let e=setTimeout(()=>{g(!1)},TA);return()=>{clearTimeout(e)}},[p]);let w=[t?s:void 0,v===void 0?void 0:c].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`div`,{"data-ready":t,className:uW,children:[(0,h.jsx)(`span`,{id:o,className:`pb-[7px] font-semibold`,children:e.displayName}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(NA,{htmlFor:i,id:a,className:`mb-[5px]`,children:`API key`}),(0,h.jsx)(FA,{id:i,type:`password`,autoComplete:`off`,spellCheck:!1,"aria-labelledby":`${o} ${a}`,"aria-invalid":v!==void 0,"aria-describedby":w===``?void 0:w,placeholder:t?lW:void 0,value:l,onChange:e=>{u(e.target.value)}}),e.id===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Paste the Base64 credentials from Inworld Settings → API Keys.`}):null,t?(0,h.jsx)(`span`,{id:s,className:`sr-only`,children:`A key is stored for this provider.`}):null,v===void 0?null:(0,h.jsx)(`p`,{id:c,className:`mt-1 text-label text-red`,children:v})]}),(0,h.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2`,children:[(0,h.jsx)(J,{"aria-label":`Save ${e.displayName} key`,disabled:l.trim()===``||d,onClick:()=>{S()},children:`Save`}),p?(0,h.jsx)(DA,{}):null,t?(0,h.jsx)(J,{className:`bg-transparent`,"aria-label":`Remove ${e.displayName} key`,onClick:()=>{x(!0)},children:`Remove`}):null]}),(0,h.jsx)(oA,{open:b,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this provider cannot retry until a key is saved.`,verb:`Remove`,pending:C.isPending,onConfirm:()=>{C.mutate()},onCancel:()=>{x(!1)}})]})}function mW(){return(0,h.jsx)(sA,{children:[0,1,2,3].map(e=>(0,h.jsxs)(cA,{children:[(0,h.jsx)(`span`,{className:`h-4 w-28 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 flex-1 rounded-control bg-panel2`})]},e))})}var hW=_v,gW=xv;function _W({className:e,children:t,...n}){return(0,h.jsxs)(yv,{"data-slot":`select-trigger`,className:W(`flex h-8 w-full items-center justify-between gap-2 rounded-control border border-line2`,`bg-panel2 px-[10px] text-left text-small text-ink data-[placeholder]:text-ink3`,e),...n,children:[t,(0,h.jsx)(Sv,{asChild:!0,children:(0,h.jsx)(xk,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-ink2`})})]})}function vW({className:e,children:t,position:n=`popper`,...r}){return(0,h.jsx)(Tv,{children:(0,h.jsx)(Dv,{"data-slot":`select-content`,position:n,sideOffset:4,className:W(`z-50 min-w-[var(--radix-select-trigger-width)] overflow-hidden rounded-panel`,`border border-line bg-panel p-1 shadow-[0_8px_24px_var(--color-shadow)]`,e),...r,children:(0,h.jsx)(zv,{children:t})})})}function yW({className:e,children:t,...n}){return(0,h.jsxs)(Gv,{"data-slot":`select-item`,className:W(`relative flex cursor-default items-center rounded-control py-[5px] pr-8 pl-[10px]`,`text-small text-ink outline-hidden select-none`,`focus:bg-panel2 data-highlighted:bg-panel2`,e),...n,children:[(0,h.jsx)(qv,{children:t}),(0,h.jsx)(Yv,{className:`absolute right-[10px] flex items-center`,children:(0,h.jsx)(bk,{"aria-hidden":`true`,className:`size-[14px] text-done`})})]})}var bW=`px-4 align-top`;function xW(){let{api:e}=B(),t=_(),n=R(Ly(e)),r=R(Iy(e)),[i,a]=(0,m.useState)(void 0),o=tt({mutationFn:t=>xo(e,t),onSettled:async()=>{a(void 0),await t.invalidateQueries({queryKey:jy.voices})}}),s=(r.data?.providers??[]).filter(e=>e.family===`tts`);if(n.error!==null)return(0,h.jsx)(sA,{children:(0,h.jsx)(cA,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});let c=n.data?.voices;return(0,h.jsxs)(sA,{"data-tour":`voices`,children:[(0,h.jsxs)(`table`,{className:`w-full table-fixed border-collapse text-small`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`th`,{className:W(bW,`engraved w-[26%] py-3 text-left text-ink3`),children:`Voices · Name`}),(0,h.jsx)(`th`,{className:W(bW,`engraved w-[26%] py-3 text-left text-ink3`),children:`Provider`}),(0,h.jsx)(`th`,{className:W(bW,`engraved py-3 text-left text-ink3`),children:`Voice ID`}),(0,h.jsx)(`th`,{className:W(bW,`w-[104px] py-3`),children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:c===void 0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:W(bW,`py-4`),children:(0,h.jsx)(`span`,{className:`block h-4 w-64 rounded-control bg-panel2`})})}):c.length===0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:W(bW,`py-4 text-ink2`),children:`Add a voice ID from your text-to-speech provider. Audio needs one to narrate.`})}):c.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`td`,{className:W(bW,`py-3 font-semibold`),children:e.name}),(0,h.jsx)(`td`,{className:W(bW,`py-3 text-ink2`),children:wW(s,e.provider)}),(0,h.jsx)(`td`,{className:W(bW,`py-3 text-ink2 tabular-nums`),children:e.voiceId}),(0,h.jsx)(`td`,{className:W(bW,`py-3 text-right`),children:(0,h.jsx)(J,{className:`bg-transparent`,"aria-label":`Remove ${e.name}`,onClick:()=>{a(e)},children:`Remove`})})]},e.id))}),(0,h.jsx)(`tfoot`,{children:(0,h.jsx)(SW,{tts:s})})]}),o.error===null?null:(0,h.jsx)(`p`,{className:`border-t border-line px-4 py-3 text-label text-red`,children:o.error.message}),(0,h.jsx)(oA,{open:i!==void 0,title:i===void 0?``:`Remove ${i.name}?`,consequence:`Projects that used this voice keep the audio they made with it.`,verb:`Remove`,pending:o.isPending,onConfirm:()=>{i!==void 0&&o.mutate(i.id)},onCancel:()=>{a(void 0)}})]})}function SW({tts:e}){let{api:t}=B(),n=_(),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(void 0),y=f??e[0]?.id,b=tt({mutationFn:e=>bo(t,e),onSuccess:async e=>{if(!e.ok){v(e.refusal);return}l(``),d(``),v(void 0),await n.invalidateQueries({queryKey:jy.voices})}}),x=(e,t)=>{t(),g?.field===e&&v(void 0)},S=e=>g?.field===e?g.message:void 0;return(0,h.jsxs)(`tr`,{children:[(0,h.jsxs)(`td`,{className:W(bW,`py-[14px]`),children:[(0,h.jsx)(NA,{htmlFor:r,className:`mb-[5px]`,children:`Voice name`}),(0,h.jsx)(FA,{id:r,value:c,"aria-invalid":S(`name`)!==void 0,onChange:e=>{let t=e.target.value;x(`name`,()=>{l(t)})}}),(0,h.jsx)(CW,{id:`${s}-name`,message:S(`name`)})]}),(0,h.jsxs)(`td`,{className:W(bW,`py-[14px]`),children:[(0,h.jsx)(NA,{id:a,className:`mb-[5px]`,children:`Provider`}),(0,h.jsxs)(hW,{value:y??``,onValueChange:t=>{let n=e.find(e=>e.id===t);n!==void 0&&x(`provider`,()=>{p(n.id)})},children:[(0,h.jsx)(_W,{id:i,"aria-labelledby":`${a} ${i}`,children:(0,h.jsx)(gW,{placeholder:`Pick a provider`})}),(0,h.jsx)(vW,{children:e.map(e=>(0,h.jsx)(yW,{value:e.id,children:e.displayName},e.id))})]}),(0,h.jsx)(CW,{id:`${s}-provider`,message:S(`provider`)})]}),(0,h.jsxs)(`td`,{className:W(bW,`py-[14px]`),children:[(0,h.jsx)(NA,{htmlFor:o,className:`mb-[5px]`,children:`Voice ID`}),(0,h.jsx)(FA,{id:o,className:`tabular-nums`,value:u,"aria-invalid":S(`voiceId`)!==void 0,"aria-describedby":S(`voiceId`)===void 0?void 0:`${s}-voiceId`,onChange:e=>{let t=e.target.value;x(`voiceId`,()=>{d(t)})}}),(0,h.jsx)(CW,{id:`${s}-voiceId`,message:S(`voiceId`)}),y===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Use an Inworld voice ID, such as Dennis, or one from your workspace.`}):null,b.error===null?null:(0,h.jsx)(`p`,{className:`mt-1 text-label text-red`,children:b.error.message})]}),(0,h.jsx)(`td`,{className:W(bW,`py-[14px] text-right`),children:(0,h.jsx)(J,{className:`mt-[22px]`,disabled:y===void 0||g!==void 0||b.isPending,onClick:()=>{y!==void 0&&b.mutate({provider:y,name:c,voiceId:u})},children:`Add voice`})})]})}function CW({id:e,message:t}){return t===void 0?null:(0,h.jsx)(`p`,{id:e,className:`mt-1 text-label text-red`,children:t})}function wW(e,t){return e.find(e=>e.id===t)?.displayName??t}var TW=30,EW=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function DW(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=TW?void 0:`The silence gap is a whole number of seconds between 0 and ${String(TW)}.`}function OW(){return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Settings`}),(0,h.jsx)(fW,{}),(0,h.jsx)(xW,{}),(0,h.jsx)(iW,{}),(0,h.jsx)(kW,{})]})}function kW(){let{api:e}=B(),t=_(),n=R(By(e)),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(!1),u=tt({mutationFn:t=>vo(e,t),onMutate:e=>{let n=t.getQueryData(jy.settings);return t.setQueryData(jy.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(jy.settings,r.previous)},onSuccess:e=>{t.setQueryData(jy.settings,e)}});if((0,m.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>{l(!1)},TA);return()=>{clearTimeout(e)}},[c]),n.error!==null)return(0,h.jsx)(sA,{children:(0,h.jsx)(cA,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});if(n.data===void 0)return(0,h.jsxs)(sA,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(cA,{children:[(0,h.jsx)(`span`,{className:`h-4 w-48 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 w-[72px] rounded-control bg-panel2`})]})]});let d=n.data,f=o??String(d.silenceGapSeconds),p=DW(f);return(0,h.jsxs)(sA,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] border-b border-line px-4 py-[14px]`,children:[(0,h.jsx)(`label`,{htmlFor:r,className:`font-semibold`,children:`Silence between segments`}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px]`,children:[(0,h.jsx)(FA,{id:r,type:`number`,inputMode:`numeric`,min:0,max:TW,step:1,className:`w-[72px] tabular-nums`,value:f,"aria-invalid":p!==void 0,"aria-describedby":p===void 0?void 0:i,onChange:e=>{s(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`seconds`}),(0,h.jsx)(J,{className:`ml-[6px]`,disabled:p!==void 0||u.isPending,onClick:()=>{l(!1),u.mutate({silenceGapSeconds:Number(f.trim()),appearance:d.appearance},{onSuccess:()=>{s(void 0),l(!0)}})},children:`Save`}),c?(0,h.jsx)(DA,{}):null,p===void 0?null:(0,h.jsx)(`p`,{id:i,className:`basis-full text-label text-red`,children:p}),u.error===null?null:(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:u.error.message})]})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] px-4 py-[14px]`,children:[(0,h.jsx)(`span`,{id:a,className:`font-semibold`,children:`Appearance`}),(0,h.jsx)(hA,{type:`single`,value:d.appearance,"aria-labelledby":a,className:`justify-self-start`,onValueChange:e=>{let t=EW.find(t=>t.value===e);t!==void 0&&u.mutate({silenceGapSeconds:d.silenceGapSeconds,appearance:t.value})},children:EW.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))})]})]})}function AW({counters:e}){return(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:e.map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col-reverse gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`dt`,{className:`engraved text-ink3`,children:e.label}),(0,h.jsx)(`dd`,{className:`m-0 text-counter font-bold tabular-nums tracking-[-0.01em]`,children:e.value})]},e.label))})}function jW({cells:e}){return(0,h.jsx)(`div`,{className:`grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:Array.from({length:e},(e,t)=>t).map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`})]},e))})}function MW(){let{api:e}=B(),t=R(Fy(e));return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`mb-1 text-title font-bold tracking-[-0.01em]`,children:`Usage`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`This machine only. The same counters, anonymised, feed slopify.stream.`})]}),t.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:t.error.message})}),t.data===void 0?t.error===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(jW,{cells:5}),(0,h.jsx)(VW,{})]}):null:(0,h.jsx)(NW,{usage:t.data})]})}function NW({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(AW,{counters:BW(e)}),t?(0,h.jsx)(`p`,{className:`-mt-3 text-body text-ink2`,children:`Numbers appear after your first run.`}):null,(0,h.jsxs)(`div`,{className:`overflow-hidden rounded-panel border border-line bg-panel`,children:[(0,h.jsxs)(`table`,{"aria-label":`Tokens by stage`,className:`w-full table-fixed border-collapse`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(PW,{className:`w-[24%]`,children:`Tokens by stage`}),(0,h.jsx)(PW,{className:`w-[38%]`,children:`Provider · model`}),(0,h.jsx)(PW,{className:`w-[19%] text-right`,children:`Tokens in`}),(0,h.jsx)(PW,{className:`w-[19%] text-right`,children:`Tokens out`})]})}),(0,h.jsx)(`tbody`,{children:e.byStage.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line last:border-b-0`,children:[(0,h.jsx)(FW,{className:`truncate font-semibold`,children:bO[e.stage]}),(0,h.jsx)(FW,{className:`truncate text-ink2`,children:IW(e)}),(0,h.jsx)(FW,{className:`text-right tabular-nums`,children:LW.format(e.tokensIn)}),(0,h.jsx)(FW,{className:`text-right tabular-nums`,children:LW.format(e.tokensOut)})]},`${e.stage}/${e.provider}/${e.model??``}`))})]}),e.byStage.length===0?(0,h.jsx)(`p`,{className:`px-4 py-5 text-small text-ink3`,children:`No stages have run yet.`}):null]}),(0,h.jsx)(`p`,{className:`engraved text-ink3`,children:`Machine ID ${e.machineId??`not made yet`} · Slopify ${e.appVersion}`})]})}function PW({children:e,className:t}){return(0,h.jsx)(`th`,{className:`engraved px-4 py-3 text-left text-ink3 ${t}`,children:e})}function FW({children:e,className:t}){return(0,h.jsx)(`td`,{className:`px-4 py-3 align-top text-small ${t}`,children:e})}function IW(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var LW=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),RW=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),zW=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function BW(e){let t=e.counters;return[{label:`Videos made`,value:LW.format(t.videosMade)},{label:`Hours of audio`,value:RW.format(t.audioSeconds/3600)},{label:`Images made`,value:LW.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?LW.format(t.tokensUsed):zW.format(t.tokensUsed)},{label:`Projects`,value:LW.format(t.projects)}]}function VW(){return(0,h.jsx)(sA,{children:[0,1,2,3].map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-[14px] border-b border-line px-4 py-3 last:border-b-0`,children:[(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-56 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-panel2`})]},e))})}var HW=ca({component:Wk}),UW=oa({getParentRoute:()=>HW,path:`/`,component:UU}),WW=oa({getParentRoute:()=>HW,path:`play`,component:xM}),GW=oa({getParentRoute:()=>HW,path:`projects/$projectId`,component:eG}),KW=oa({getParentRoute:()=>HW,path:`prompts`,validateSearch:e=>({kind:aA(e.kind)}),component:tG}),qW=oa({getParentRoute:()=>HW,path:`prompts/new`,validateSearch:e=>{let t=aA(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:nG}),JW=oa({getParentRoute:()=>HW,path:`prompts/$promptId`,component:rG}),YW=oa({getParentRoute:()=>HW,path:`entries`,validateSearch:e=>({category:nA(e.category)}),component:aG}),XW=oa({getParentRoute:()=>HW,path:`entries/new`,validateSearch:e=>{let t=nA(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:oG}),ZW=oa({getParentRoute:()=>HW,path:`entries/$entryId`,component:sG}),QW=oa({getParentRoute:()=>HW,path:`settings`,component:OW}),$W=oa({getParentRoute:()=>HW,path:`usage`,component:MW});function eG(){let{projectId:e}=GW.useParams();return(0,h.jsx)(IU,{projectId:e},e)}function tG(){let{kind:e}=KW.useSearch(),t=Hi();return(0,h.jsx)($U,{kind:e,onKind:e=>{t({to:`/prompts`,search:{kind:e},replace:!0})}})}function nG(){let{kind:e,from:t}=qW.useSearch(),n=iG();return(0,h.jsx)(JU,{promptId:void 0,kind:e,from:t,onLeave:n},`${e}:${t??`new`}`)}function rG(){let{promptId:e}=JW.useParams(),t=iG();return(0,h.jsx)(JU,{promptId:e,kind:`article`,from:void 0,onLeave:t},e)}function iG(){let e=Hi();return t=>{e({to:`/prompts`,search:{kind:t}})}}function aG(){let{category:e}=YW.useSearch(),t=Hi();return(0,h.jsx)(yA,{category:e,onCategory:e=>{t({to:`/entries`,search:{category:e},replace:!0})}})}function oG(){let{category:e,from:t}=XW.useSearch(),n=cG();return(0,h.jsx)(tj,{entryId:void 0,category:e,from:t,onLeave:n})}function sG(){let{entryId:e}=ZW.useParams(),t=cG();return(0,h.jsx)(tj,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function cG(){let e=Hi();return t=>{e({to:`/entries`,search:{category:t}})}}var lG=HW.addChildren({projectsRoute:UW,playRoute:WW,projectRoute:GW,promptsRoute:KW,newPromptRoute:qW,promptRoute:JW,entriesRoute:YW,newEntryRoute:XW,entryRoute:ZW,settingsRoute:QW,usageRoute:$W});function uG(){return Ta({routeTree:lG})}function dG(){let e,t,n=new Set;return{observe:r=>{if(e===void 0){e=r;return}if(r!==e&&r!==t){t=r;for(let e of n)e()}},staleAt:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function fG(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 pG(e){let t=dG(),n={api:ro(window.location.origin,fG(window.fetch.bind(window),t)),openEvents:e=>new EventSource(e),version:t};(0,Xa.createRoot)(e).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:new Ve,children:(0,h.jsx)(Mo,{deps:n,children:(0,h.jsx)(Oa,{router:uG()})})})}))}var mG=document.getElementById(`root`);if(mG===null)throw Error(`index.html carries no #root element for the app to mount on`);pG(mG);
130
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return fB(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=lV.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function yV(){return{exit:{taskListCheckValueChecked:xV,taskListCheckValueUnchecked:xV,paragraph:SV}}}function bV(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:CV}}}function xV(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function SV(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function CV(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=lV.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function wV(){return[Az(),eB(),aB(),uV(),yV()]}function TV(e){return{extensions:[jz(),tB(e),oB(),vV(e),bV()]}}var EV={tokenize:BV,partial:!0},DV={tokenize:VV,partial:!0},OV={tokenize:HV,partial:!0},kV={tokenize:UV,partial:!0},AV={tokenize:WV,partial:!0},jV={name:`wwwAutolink`,tokenize:RV,previous:GV},MV={name:`protocolAutolink`,tokenize:zV,previous:KV},NV={name:`emailAutolink`,tokenize:LV,previous:qV},PV={};function FV(){return{text:PV}}for(var IV=48;IV<123;)PV[IV]=NV,IV++,IV===58?IV=65:IV===91&&(IV=97);PV[43]=NV,PV[45]=NV,PV[46]=NV,PV[95]=NV,PV[72]=[NV,MV],PV[104]=[NV,MV],PV[87]=[NV,jV],PV[119]=[NV,jV];function LV(e,t,n){let r=this,i,a;return o;function o(t){return!JV(t)||!qV.call(r,r.previous)||YV(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return JV(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(AV,u,l)(t):t===45||t===95||OP(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&DP(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function RV(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!GV.call(r,r.previous)||YV(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(EV,e.attempt(DV,e.attempt(OV,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function zV(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&KV.call(r,r.previous)&&!YV(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(DP(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||AP(t)||PP(t)||LP(t)||IP(t)?n(t):e.attempt(DV,e.attempt(OV,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function BV(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function VV(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(kV,c,s)(t):t===null||PP(t)||LP(t)||t!==45&&IP(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function HV(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(kV,t,a)(o):o===null||PP(o)||LP(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function UV(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||PP(o)||LP(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||PP(e)||LP(e)?t(e):r(e)}function a(e){return DP(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):DP(t)?(e.consume(t),o):n(t)}}function WV(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return OP(e)?n(e):t(e)}}function GV(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||PP(e)}function KV(e){return!DP(e)}function qV(e){return!(e===47||JV(e))}function JV(e){return e===43||e===45||e===46||e===95||OP(e)}function YV(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var XV={tokenize:iH,partial:!0};function ZV(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:tH,continuation:{tokenize:nH},exit:rH}},text:{91:{name:`gfmFootnoteCall`,tokenize:eH},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:QV,resolveTo:$V}}}}function QV(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=EP(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function $V(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function eH(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||PP(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(EP(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return PP(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function tH(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||PP(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=EP(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return PP(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),BP(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function nH(e,t,n){return e.check(tF,t,e.attempt(XV,t,n))}function rH(e){e.exit(`gfmFootnoteDefinition`)}function iH(e,t,n){let r=this;return BP(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function aH(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&yP(o,o.length,0,JP(s,e.slice(r+1,n),t)),yP(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),yP(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=qP(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=qP(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var oH=class{constructor(){this.map=[]}add(e,t,n){sH(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function sH(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function cH(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function lH(){return{flow:{null:{name:`table`,tokenize:uH,resolveAll:dH}}}}function uH(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):$(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):FP(t)?BP(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||PP(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,FP(t)?BP(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return FP(t)?BP(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||$(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return FP(t)?BP(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||$(n)?(e.exit(`tableRow`),t(n)):FP(n)?BP(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||PP(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function dH(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new oH;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(pH(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=fH(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=fH(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=fH(f,t,o,i,n,d)):(o[0]=o[1],d=fH(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&pH(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=cH(t.events,n))}return e}function fH(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},mH(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=mH(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=mH(t.events,n[2]),a=mH(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},mH(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function pH(e,t,n,r,i){let a=[],o=mH(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function mH(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var hH={name:`tasklistCheck`,tokenize:_H};function gH(){return{text:{91:hH}}}function _H(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return PP(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return $(r)?t(r):FP(r)?e.check({tokenize:vH},t,n)(r):n(r)}}function vH(e,t,n){return BP(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function yH(e){return SP([FV(),ZV(),aH(e),lH(),gH()])}var bH={};function xH(e){let t=this,n=e||bH,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(yH(n)),a.push(wV()),o.push(TV(n))}var SH=new Set([400,404,409]);async function CH(e,t){return PH(await e.client.projects[`:id`].cancel.$post({param:{id:t}}))}async function wH(e,t){return PH(await e.client.projects[`:id`].pause.$post({param:{id:t}}))}async function TH(e,t){return PH(await e.client.projects[`:id`].resume.$post({param:{id:t}}))}async function EH(e,t,n){return PH(await e.client.projects[`:id`].providers.$patch({param:{id:t},json:n}))}async function DH(e,t,n){return PH(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/subtitles`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function OH(e,t,n){return PH(await e.client.projects[`:id`].stages[`:kind`].retry.$post({param:{id:t,kind:n}}))}async function kH(e,t,n){return PH(await e.client.projects[`:id`].stages[`:kind`].rerun.$post({param:{id:t,kind:n}}))}async function AH(e,t,n){return PH(await e.client.projects[`:id`].article.$put({param:{id:t},json:{markdown:n}}))}async function jH(e,t,n){return PH(await e.client.projects[`:id`].images[`:outputId`].$delete({param:{id:t,outputId:n}}))}async function MH(e,t,n){return PH(await e.client.projects[`:id`].images[`:outputId`].regenerate.$post({param:{id:t,outputId:n}}))}async function NH(e,t,n){return Qa(await e.fetch(po(e,t,n)))}async function PH(e){if(e.ok)return{ok:!0,value:await e.json()};let t=await no(e);if(t!==void 0&&SH.has(e.status))return{ok:!1,message:to(e,t).message};throw to(e,t)}function FH({projectId:e,asset:t}){let{api:n}=B(),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)();async function s(){i(!0),o(void 0);try{let r=await n.client.projects[`:id`][`open-folder`].$post({param:{id:e},json:{asset:t}});if(!r.ok)throw to(r,await no(r))}catch(e){o(e instanceof Error?e.message:`Could not open the folder.`)}finally{i(!1)}}return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,disabled:r,onClick:()=>void s(),title:`Open the saved output folder on the machine running Slopify`,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink disabled:opacity-50`,children:[(0,h.jsx)(Ok,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),r?`Opening…`:`Open folder`]}),a!==void 0&&(0,h.jsx)(`span`,{role:`alert`,className:`basis-full text-small text-red`,children:a})]})}function IH({children:e,className:t}){return(0,h.jsx)(`div`,{className:W(`flex min-w-0 flex-col gap-4 p-5`,t),children:e})}function LH({children:e}){return(0,h.jsx)(`div`,{className:`flex flex-wrap items-center gap-4 text-small`,children:e})}function RH({children:e}){return(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:e})}var zH={h1:({children:e})=>(0,h.jsx)(VH,{size:`text-title`,children:e}),h2:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h3:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h4:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h5:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h6:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),p:({children:e})=>(0,h.jsx)(`p`,{className:`m-0`,children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),ul:({children:e})=>(0,h.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-5`,children:e}),ol:({children:e})=>(0,h.jsx)(`ol`,{className:`m-0 flex list-decimal flex-col gap-1 pl-5`,children:e}),li:({children:e})=>(0,h.jsx)(`li`,{className:`m-0`,children:e}),a:({children:e,href:t})=>(0,h.jsx)(`a`,{href:t,className:`rounded-control text-run-text underline underline-offset-[3px]`,target:`_blank`,rel:`noreferrer`,children:e}),code:({children:e})=>(0,h.jsx)(`code`,{className:`rounded-control bg-panel2 px-[4px] py-[1px] font-sans text-small`,children:e}),pre:({children:e})=>(0,h.jsx)(`pre`,{className:`m-0 overflow-x-auto rounded-control bg-panel2 p-[10px] font-sans text-small`,children:e}),blockquote:({children:e})=>(0,h.jsx)(`blockquote`,{className:`m-0 flex flex-col gap-2 border-l-2 border-line2 pl-3 text-ink2`,children:e}),hr:()=>(0,h.jsx)(`hr`,{className:`my-2 border-line`}),table:({children:e})=>(0,h.jsx)(`table`,{className:`w-full border-collapse text-left text-small`,children:e}),th:({children:e})=>(0,h.jsx)(`th`,{className:`engraved border-b border-line py-[6px] pr-4 text-left text-ink3`,children:e}),td:({children:e})=>(0,h.jsx)(`td`,{className:`border-b border-line py-[6px] pr-4 align-top`,children:e})},BH={p:({children:e})=>(0,h.jsx)(h.Fragment,{children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),a:({children:e})=>(0,h.jsx)(h.Fragment,{children:e})};function VH({size:e,children:t}){return(0,h.jsx)(`h3`,{className:W(`mt-2 font-bold tracking-[-0.01em]`,e),children:t})}function HH({markdown:e}){return(0,h.jsx)(`div`,{className:`flex max-w-[75ch] flex-col gap-2 text-pretty text-body text-ink`,children:(0,h.jsx)(_z,{remarkPlugins:[xH],components:zH,children:e})})}function UH({markdown:e}){return(0,h.jsx)(_z,{remarkPlugins:[xH],components:BH,children:e})}var WH=/^#{1,6}[ \t]+(.*?)[ \t]*#*[ \t]*(?:\r?\n|$)/;function GH(e){let t=e.replace(/^[\s]*\n/,``),n=WH.exec(t);return n===null?{title:void 0,body:e.trim()}:{title:n[1]??``,body:t.slice(n[0].length).trim()}}function KH({message:e,onDismiss:t}){return(0,h.jsxs)(`div`,{className:`flex items-center gap-3 rounded-control bg-red-tint px-[10px] py-[6px] text-small text-red`,children:[(0,h.jsx)(`span`,{role:`alert`,className:`min-w-0 break-words`,children:e}),(0,h.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto shrink-0 rounded-control px-2 text-ink2 hover:text-ink`,children:`Dismiss`})]})}function qH({projectId:e,asset:t,label:n=`Download`}){let{api:r}=B();return(0,h.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsxs)(`a`,{href:po(r,e,t),download:!0,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(Ek,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),n]}),(0,h.jsx)(FH,{projectId:e,asset:t})]})}function JH({output:e,label:t}){return(0,h.jsx)(qH,{projectId:e.projectId,asset:PM(e),...t===void 0?{}:{label:t}})}function YH(e){let{api:t}=B();return R({queryKey:jy.file(e?.projectId??``,e?.id??``),queryFn:()=>e===void 0?``:NH(t,e.projectId,PM(e)),enabled:e!==void 0,staleTime:1/0})}function XH({output:e,as:t=`prose`}){let n=YH(e);return n.error===null?n.data===void 0?(0,h.jsx)(`span`,{className:`h-4 w-[40ch] max-w-full rounded-control bg-panel2`}):t===`prose`?(0,h.jsx)(HH,{markdown:n.data}):(0,h.jsx)(`pre`,{className:`max-w-[75ch] overflow-x-auto whitespace-pre-wrap font-sans text-small text-ink2`,children:n.data}):(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})}function ZH({output:e}){let[t,n]=(0,m.useState)(!1);return e===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>{n(!t)},className:`rounded-control text-small text-ink2 underline underline-offset-[3px] hover:text-ink`,children:t?`Hide instructions`:`Show instructions`}),t?(0,h.jsx)(XH,{output:e,as:`plain`}):null]})}function QH({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=EM(n,e),o=DM(a,`article_md`),s=DM(a,`sources`),c=DM(a,`glossary`),l=YH(o),u=R({queryKey:jM(t.id),queryFn:()=>[],enabled:!1}).data?.some(e=>e.stage===`article`)===!0,d=R({queryKey:jy.article(t.id),queryFn:()=>``,enabled:!1}),[f,p]=(0,m.useState)(void 0),[g,_]=(0,m.useState)(!1),v=l.data??``,y=GH(e.state===`running`?d.data??``:v),b=y.title??t.title,x=kM({kind:`discard-article`});return(0,h.jsxs)(IH,{children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-[14px] text-small text-ink2`,children:[(0,h.jsx)(`span`,{className:`text-row font-semibold text-ink`,children:(0,h.jsx)(UH,{markdown:b})}),s===void 0?null:(0,h.jsx)(JH,{output:s,label:`Sources`}),c===void 0?null:(0,h.jsx)(JH,{output:c,label:`Glossary`})]}),(0,h.jsx)(LH,{children:f===void 0?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(J,{type:`button`,disabled:i||o===void 0||l.data===void 0,onClick:()=>{p(v)},children:`Edit`}),(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run`}),(0,h.jsx)(ZH,{output:DM(a,`instructions`)}),o===void 0?null:(0,h.jsx)(JH,{output:o})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(AM,{action:{kind:`save-article`,markdown:f},run:()=>{r.run({kind:`save-article`,markdown:f},()=>{p(void 0)})},disabled:i,pending:r.pending,children:`Save & update outputs`}),(0,h.jsx)(J,{type:`button`,onClick:()=>{_(!0)},children:`Discard`})]})}),l.error===null?null:(0,h.jsx)(`p`,{className:`text-body text-red`,children:l.error.message}),(0,h.jsx)(`section`,{"aria-label":`Article content`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:f===void 0?e.state===`running`&&u?(0,h.jsx)(NM,{projectId:t.id,stage:`article`}):(0,h.jsx)(HH,{markdown:y.body}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`label`,{htmlFor:`article-editor`,className:`engraved text-ink3`,children:`Article`}),(0,h.jsx)(`textarea`,{id:`article-editor`,value:f,onChange:e=>{p(e.target.value)},className:`h-[420px] w-full max-w-[75ch] resize-y rounded-control border border-line2 bg-panel2 p-[10px] font-sans text-body text-ink`})]})}),(0,h.jsx)(oA,{open:g,title:x.title,consequence:x.consequence,verb:x.verb,dismiss:x.dismiss,onConfirm:()=>{_(!1),p(void 0)},onCancel:()=>{_(!1)}})]})}function $H({projectId:e}){let{api:t}=B(),n=R({queryKey:[`audio-preview`,e],queryFn:async()=>Za(await t.client.projects[`:projectId`][`audio-preview`].$get({param:{projectId:e}})),refetchInterval:1e3,staleTime:0,gcTime:0,retry:!1}),r=n.data?.previews??[];return(0,h.jsxs)(`section`,{"aria-label":`Live narration`,className:`grid gap-3 rounded-control border border-line2 bg-panel2 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold text-ink`,children:`Listen while it generates`}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Play any part. Each preview starts from its beginning.`})]}),n.error===null?null:(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Live preview is temporarily unavailable. Finished audio will still appear here.`}),r.length===0&&n.error===null?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Waiting for the first audio bytes…`}):null,(0,h.jsx)(`div`,{className:`grid max-h-[420px] gap-3 overflow-y-auto`,children:r.map(n=>(0,h.jsx)(eU,{preview:n,url:`${t.origin}/api/projects/${encodeURIComponent(e)}/audio-preview/${n.id}`},n.id))})]})}function eU({preview:e,url:t}){let[n,r]=(0,m.useState)(!1),i=(e.state===`streaming`||e.state===`ready`)&&e.bytes>0,a=e.state===`ready`?`Ready`:e.state===`streaming`?`Generating`:`Preview stopped`;return(0,h.jsxs)(`div`,{className:`grid gap-2 text-small`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-ink`,children:e.label}),(0,h.jsx)(`span`,{className:`text-ink2`,children:a})]}),i&&!n?(0,h.jsx)(tU,{label:e.label,url:t,onError:()=>r(!0)}):(0,h.jsx)(`p`,{className:`text-ink2`,children:e.state===`streaming`&&!n?`Waiting for audio…`:`This preview has stopped. The finished narration will be available when generation completes.`})]})}function tU({label:e,url:t,onError:n}){let r=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=r.current;return()=>{e!==null&&(e.pause(),e.removeAttribute(`src`),e.load())}},[]),(0,h.jsx)(`audio`,{ref:r,controls:!0,preload:`none`,"aria-label":`Live ${e} narration`,src:t,onError:n,className:`h-9 w-full max-w-[620px]`})}var nU=[{role:`audio_intro`,name:`Intro`},{role:`audio_body`,name:`Body`},{role:`audio_outro`,name:`Outro`}];function rU({stage:e,project:t,outputs:n,actions:r,busy:i}){let{api:a}=B(),o=R(Ly(a)),s=EM(n,e),c=nU.flatMap(e=>{let t=DM(s,e.role);return t===void 0?[]:[{...e,output:t}]}),l=c.find(e=>e.output.meta.voice!==void 0)?.output.meta,u=c.length>0?l?.voice:t.config.audio?.voice,d=c.length>0?l?.provider:t.config.audio?.provider,f=o.data?.voices.find(e=>e.voiceId===u&&e.provider===d)?.name??u;return(0,h.jsxs)(IH,{children:[e.state===`running`?(0,h.jsx)($H,{projectId:t.id}):null,c.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No narration has landed yet.`}):c.map(e=>(0,h.jsx)(iU,{name:e.name,output:e.output},e.role)),(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run`}),f===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(RH,{children:`Voice`}),(0,h.jsx)(`span`,{className:`text-small text-ink`,children:f})]}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Chunking: ${aU(t.config.chunking)}`})]})]})}function iU({name:e,output:t}){let{api:n}=B(),r=AO(t.durationMs??void 0);return(0,h.jsxs)(`div`,{className:`grid grid-cols-[60px_minmax(0,1fr)_auto] items-center gap-3 text-small`,children:[(0,h.jsx)(RH,{children:e}),(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`${e} narration`,src:po(n,t.projectId,PM(t)),className:`h-8 w-full max-w-[520px]`}),(0,h.jsxs)(`span`,{className:`flex items-center gap-4`,children:[r===void 0?null:(0,h.jsx)(`span`,{className:`text-ink2 tabular-nums`,children:r}),(0,h.jsx)(JH,{output:t})]})]})}function aU(e){return e===void 0||e.mode===`whole`?`the whole text as one request`:e.mode===`paragraph`?`one request per paragraph`:e.mode===`characters`?`every ${String(e.characters??3e3)} characters`:`every ${String(e.words??500)} words`}function oU(e,t){let n=e.filter(e=>e.role===`image`),r=new Map;for(let e of n){let t=e.meta.promptName??`Images`;r.set(t,[...r.get(t)??[],e])}let i=t.filter(e=>r.has(e)),a=[...r.keys()].filter(e=>!i.includes(e)).sort();return[...i,...a].flatMap(e=>{let t=r.get(e);return t===void 0?[]:[{name:e,images:[...t].sort(sU)}]})}function sU(e,t){return(e.meta.index??0)-(t.meta.index??0)}function cU(e){return e===`9:16`?`aspect-[9/16]`:`aspect-video`}function lU({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=oU(EM(n,e),t.config.imagePrompts?.map(e=>e.name)??[]);return(0,h.jsxs)(IH,{children:[(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run stage`}),(0,h.jsx)(qH,{projectId:t.id,asset:`images.zip`,label:`Download all`})]}),a.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No images have landed yet.`}):null,a.map(e=>(0,h.jsxs)(`section`,{className:`flex flex-col gap-[10px]`,children:[(0,h.jsx)(RH,{children:`${e.name} × ${String(e.images.length)}`}),(0,h.jsx)(`div`,{className:`grid grid-cols-3 gap-2 min-[900px]:grid-cols-6`,children:e.images.map(e=>(0,h.jsx)(uU,{image:e,format:t.format,actions:r,busy:i},e.id))})]},e.name))]})}function uU({image:e,format:t,actions:n,busy:r}){let{api:i}=B(),a=e.meta.index===void 0?``:` ${String(e.meta.index)}`;return(0,h.jsxs)(`figure`,{className:`group relative m-0 overflow-hidden rounded-control border border-line bg-panel2`,children:[(0,h.jsx)(`img`,{src:po(i,e.projectId,PM(e)),alt:e.meta.prompt??`Slideshow image${a}`,className:W(`block w-full object-cover animate-tick-in motion-reduce:animate-none`,cU(t))}),(0,h.jsxs)(`figcaption`,{className:`absolute inset-x-0 bottom-0 flex flex-wrap items-center justify-between gap-1 bg-panel/90 p-1 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 motion-reduce:transition-none`,children:[(0,h.jsx)(JH,{output:e}),(0,h.jsx)(AM,{action:{kind:`regenerate-image`,outputId:e.id},run:()=>{n.run({kind:`regenerate-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Regenerate`}),(0,h.jsx)(AM,{action:{kind:`delete-image`,outputId:e.id},run:()=>{n.run({kind:`delete-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Delete`})]})]})}function dU({stage:e,outputs:t,actions:n,busy:r}){let i=EM(t,e),a=DM(i,`notes`);return e.state===`running`&&a===void 0?null:(0,h.jsxs)(IH,{children:[(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{n.run({kind:`rerun`,stage:e.kind})},disabled:r,pending:n.pending,children:`Re-run`}),(0,h.jsx)(ZH,{output:DM(i,`instructions`)}),a===void 0?null:(0,h.jsx)(JH,{output:a})]}),(0,h.jsx)(`section`,{"aria-label":`Research notes`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:a===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e.state===`running`?`Research notes will be saved when the writing above finishes.`:`No notes were written.`}):(0,h.jsx)(XH,{output:a})})]})}function fU({stage:e,project:t,outputs:n,actions:r,busy:i}){let{api:a}=B(),o=EM(n,e),s=DM(o,`thumbnail`),c=t.config.sources.thumbnail===`prompt_by_llm`;return(0,h.jsxs)(IH,{className:`grid grid-cols-1 items-start gap-4 min-[900px]:grid-cols-[200px_minmax(0,1fr)]`,children:[s===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No thumbnail has landed yet.`}):(0,h.jsx)(`img`,{src:po(a,s.projectId,PM(s)),alt:s.meta.prompt??`Thumbnail`,className:W(`block w-full rounded-control border border-line bg-panel2 object-cover`,cU(t.format))}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(RH,{children:c?`Prompt written by the LLM`:`Prompt`}),s?.meta.prompt===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`This run stored no prompt for the thumbnail.`}):(0,h.jsx)(`p`,{className:`max-w-[75ch] rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-pretty text-small text-ink`,children:s.meta.prompt}),(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Regenerate`}),(0,h.jsx)(ZH,{output:DM(o,`instructions`)}),s===void 0?null:(0,h.jsx)(JH,{output:s})]})]})]})}function pU({stage:e,project:t,outputs:n,actions:r,busy:i,subtitleControls:a}){let{api:o}=B(),s=t.config.sources.video===`off`&&t.config.sources.audio!==`off`,c=DM(EM(n,e),s?`audio_export`:`video`),l=EM(n,e),u=DM(l,`subtitles_srt`),d=DM(l,`subtitles_vtt`),f=c?.meta.subtitlesMode??t.config.subtitles?.mode,p=e.state===`running`,m=jO(e.progressCurrent??0,e.progressTotal??0);return t.config.sources.video===`off`&&!s?(0,h.jsx)(IH,{children:a}):(0,h.jsxs)(IH,{children:[p?(0,h.jsx)(`p`,{className:`text-small text-run-text`,children:s?`Exporting combined audio`:e.progressTotal===null?`Re-rendering`:`Re-rendering · ${String(m)}%`}):null,c===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:s?`No combined audio export has landed yet.`:`No render has landed yet.`}):s?(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`Combined narration`,src:po(o,c.projectId,PM(c)),className:`h-9 w-full max-w-[720px]`},c.id):(0,h.jsx)(`video`,{controls:!0,preload:`metadata`,src:po(o,c.projectId,PM(c)),"aria-label":`Generated video`,className:W(`mx-auto block max-h-[min(58vh,560px)] w-auto max-w-full rounded-control bg-screen`,t.format===`9:16`?`aspect-[9/16]`:`aspect-video`),children:f===`files`&&d?(0,h.jsx)(`track`,{kind:`captions`,srcLang:`en`,label:`English`,default:!0,src:po(o,t.id,`subtitles-vtt`)},d.id):null},c.id),(0,h.jsxs)(LH,{children:[c===void 0?null:(0,h.jsx)(JH,{output:c,label:s?`Download .wav`:`Download .mp4`}),e.state===`pending`||e.state===`skipped`?null:(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i||![`done`,`failed`,`canceled`].includes(e.state),pending:r.pending,children:s?`Re-export`:`Re-render`}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:[AO(c?.durationMs??void 0),s?`WAV · stereo · 48 kHz`:t.format].filter(e=>e!==void 0).join(` · `)})]}),c?.meta.subtitleOmissions?.length?(0,h.jsxs)(`details`,{className:`rounded-control border border-line p-3 text-small`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer font-semibold`,children:[`Subtitles recovered after missing narration (`,c.meta.subtitleOmissions.length,`)`]}),(0,h.jsx)(`p`,{className:`mt-2 text-ink2`,children:`These transcript passages could not be matched to the audio and were left out of the captions. The audio is unchanged. Review these passages before sharing.`}),(0,h.jsx)(`ul`,{className:`mt-2 space-y-2`,children:c.meta.subtitleOmissions.map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsx)(`strong`,{children:new Date(e.start*1e3).toISOString().slice(11,19)}),` —`,` `,e.text]},`${e.start}-${e.text}`))})]}):null,u||d?(0,h.jsxs)(LH,{children:[u?(0,h.jsx)(JH,{output:u,label:`Download .srt`}):null,d?(0,h.jsx)(JH,{output:d,label:`Download .vtt`}):null]}):null,a?(0,h.jsxs)(`details`,{className:`mt-2 rounded-control border border-line px-4 py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small font-semibold`,children:`Subtitles & fonts`}),a]}):null]})}function mU(e){switch(e.stage.kind){case`research`:return(0,h.jsx)(dU,{...e});case`article`:return(0,h.jsx)(QH,{...e});case`audio`:return(0,h.jsx)(rU,{...e});case`images`:return(0,h.jsx)(lU,{...e});case`thumbnail`:return(0,h.jsx)(fU,{...e});case`video`:return(0,h.jsx)(pU,{...e})}}function hU({project:e,prompts:t,actions:n,inFlight:r,unsavedProviders:i,settingsOpen:a,onToggleSettings:o,primaryOutput:s}){let c=e.status===`running`;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-5 py-2`,children:[(0,h.jsxs)(`div`,{className:`w-full min-w-0 sm:min-w-[220px] sm:flex-1`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,h.jsx)(Zj,{state:e.status}),(0,h.jsx)(Yj,{state:e.status,announce:`Project`})]}),(0,h.jsx)(`h1`,{className:`break-words text-[28px] font-bold leading-tight`,children:e.title}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:gU(e,t)})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s?(0,h.jsx)(`span`,{className:`rounded-control border border-accent bg-accent px-4 py-2 [&_a]:font-semibold [&_a]:text-accent-ink`,children:(0,h.jsx)(JH,{output:s,label:s.role===`video`?`Download video`:s.role===`audio_export`?`Download audio`:`Download article`})}):null,(0,h.jsxs)(J,{"aria-expanded":a,onClick:o,children:[(0,h.jsx)(jk,{"aria-hidden":`true`,className:`mr-2 size-4`}),`Run settings`,i?` •`:``]}),c||e.status===`pending`?(0,h.jsx)(J,{disabled:n.pending,onClick:()=>n.run({kind:`pause`}),children:`Pause`}):null,e.status===`paused`||e.status===`failed`?(0,h.jsx)(J,{disabled:n.pending||r||i,onClick:()=>n.run({kind:`resume`}),children:`Resume`}):null,c?(0,h.jsx)(AM,{action:{kind:`cancel`},run:()=>{n.run({kind:`cancel`})},pending:n.pending,children:`Cancel run`}):null]}),i?(0,h.jsx)(`p`,{className:`w-full rounded-control border border-line2 bg-panel2 px-3 py-2 text-small text-ink2`,children:`You have unsaved changes. Save or discard them before resuming.`}):null]})}function gU(e,t){let n=e.config.articlePrompt,r=t===void 0||t.some(e=>e.name===n);return[n===void 0||n===``?void 0:r?n:`${n} (deleted)`,e.format,`started ${Sc(e.createdAt)}`].filter(e=>e!==void 0).join(` · `)}var _U=e=>e.state===`done`||e.state===`provided`;function vU(e){let t=e.filter(e=>e.state!==`skipped`),n=t.length,r=t.filter(_U).length,i=t.reduce((e,t)=>_U(t)?e+1:t.progressTotal===null||t.progressTotal<=0?e:e+Math.min(.99,Math.max(0,(t.progressCurrent??0)/t.progressTotal)),0);return{completed:r,total:n,percent:n===0?0:Math.min(r===n?100:99,Math.round(i/n*100))}}function yU(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`&&_U(e));if(n)return n.kind;let r=e.find(e=>e.state===`pending`);return r?r.kind:e.find(e=>e.kind===`article`&&_U(e))?.kind??e.find(e=>e.state!==`skipped`)?.kind??`article`}function bU({stages:e,project:t}){let n=vU(e);return(0,h.jsxs)(`div`,{className:`rounded-panel border border-line bg-panel px-5 py-4`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold`,children:`Overall progress`}),(0,h.jsxs)(`span`,{className:`text-small text-ink2`,children:[n.completed,` of `,n.total,` stages finished`]})]}),(0,h.jsxs)(`span`,{className:`text-small font-semibold tabular-nums`,children:[n.percent,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`Overall progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n.percent,"aria-valuetext":`${n.percent} percent; ${n.completed} of ${n.total} stages finished`,className:`h-2 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:W(`h-full origin-left bg-accent transition-transform duration-200 motion-reduce:transition-none`,t.status===`failed`&&`bg-red`),style:{transform:`scaleX(${n.percent/100})`}})}),(0,h.jsx)(`p`,{className:`mt-2 text-label text-ink3`,children:`Combines finished stages with progress reported by active stages.`})]})}function xU({stages:e,project:t,outputs:n,selected:r,onSelect:i}){return(0,h.jsxs)(`nav`,{"aria-label":`Project stages`,className:`h-fit rounded-panel border border-line bg-panel lg:sticky lg:top-6`,children:[(0,h.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Stages`})}),(0,h.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-1`,children:e.map(e=>{let a=e.kind===r,o=SO(e.kind,t.config),s=e.state===`done`||e.state===`provided`;return(0,h.jsxs)(`button`,{type:`button`,"aria-label":`${o}, ${e.state}`,"aria-current":a?`step`:void 0,onClick:()=>i(e.kind),className:W(`group relative flex min-w-0 items-start gap-2 border-b border-line px-3 py-4 sm:gap-3 sm:px-4 text-left transition-colors last:border-b-0 hover:bg-panel2`,a&&`bg-panel2 before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:bg-accent`,e.state===`skipped`&&`text-ink3`),children:[(0,h.jsx)(Tc,{kind:e.kind,className:W(`mt-0.5 shrink-0 text-ink2`,a&&`text-run-text`)}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block text-body font-semibold`,children:o}),(0,h.jsx)(`span`,{className:`mt-1 block truncate text-label text-ink2`,children:TO(e,n,t)}),(0,h.jsxs)(`span`,{className:`mt-2 flex items-center gap-2`,children:[(0,h.jsx)(Zj,{state:e.state}),(0,h.jsx)(Yj,{state:e.state,announce:o})]})]}),s?(0,h.jsx)(bk,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):e.state===`canceled`?(0,h.jsx)(wk,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 sm:block`}):a?(0,h.jsx)(Ck,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):null]},e.id)})})]})}function SU({project:e,providers:t,actions:n,inFlight:r,edits:i,setEdits:a}){let{api:o}=B(),s=R(Ly(o)),{config:c}=e,l=i.llm??c.llm??{provider:``,model:``},u=i.audio??c.audio??{provider:``,model:``,voice:``},d=i.images??c.images??{provider:``,model:``},f=c.sources.research===`generate`||c.sources.article===`generate`||c.sources.thumbnail===`prompt_by_llm`||c.sources.audio===`generate`&&(c.intro?.mode===`llm`||c.outro?.mode===`llm`),p=c.sources.audio===`generate`,m=c.sources.images===`generate`||c.sources.thumbnail===`from_prompt`||c.sources.thumbnail===`prompt_by_llm`;if(!f&&!p&&!m)return null;let g=(e.status===`paused`||e.status===`failed`)&&!r,_=CU(c,i),v=Object.keys(_).length>0,y=e=>e.provider!==``&&e.model.trim()!==``&&t.some(t=>t.id===e.provider&&(t.readiness.kind===`keyed`?t.readiness.hasKey:t.readiness.installed)),b=(!_.llm||y(_.llm))&&(!_.images||y(_.images))&&(!_.audio||y(_.audio)&&(s.data?.voices??[]).some(e=>e.provider===_.audio?.provider&&e.voiceId===_.audio.voice));return(0,h.jsx)(cA,{className:`block py-3`,"data-tour":`project-providers`,children:(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-row font-semibold`,children:`Run providers`}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:g?`Save your choices, then press Resume when ready. Finished outputs stay as they are. Changing the voice, TTS model or chunking restarts unfinished narration to keep one voice throughout.`:r&&e.status===`paused`?`Pausing: waiting for active requests to stop before providers can be changed.`:e.status===`done`||e.status===`canceled`?`These are the saved providers for this run. Start a new run to choose different providers.`:`Pause the run to change providers, models or voice. These controls are also available after a failure.`}),(0,h.jsxs)(`fieldset`,{disabled:!g||n.pending,className:`mt-3 flex min-w-0 flex-col gap-3 disabled:opacity-60`,children:[f?(0,h.jsx)(wU,{label:`Text`,choice:l,family:`llm`,providers:t,onChange:e=>a(t=>({...t,llm:e}))}):null,p?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(wU,{label:`TTS`,choice:u,family:`tts`,providers:t,onChange:e=>a(t=>({...t,audio:{...e,voice:e.provider===u.provider?u.voice:``}}))}),(0,h.jsx)(wj,{label:`Narration voice`,inline:!0,value:u.voice,placeholder:`Pick a voice`,problem:void 0,options:(s.data?.voices??[]).filter(e=>e.provider===u.provider).map(e=>({value:e.voiceId,label:e.name})),onPick:e=>a(t=>({...t,audio:{...u,voice:e}}))})]}):null,p?(0,h.jsx)(Bj,{value:i.chunking??c.chunking??{mode:`whole`},onPick:e=>a(t=>({...t,chunking:e}))}):null,m?(0,h.jsx)(wU,{label:`Image`,choice:d,family:`image`,providers:t,onChange:e=>a(t=>({...t,images:e}))}):null,(0,h.jsx)(`div`,{children:(0,h.jsx)(J,{disabled:!g||n.pending||!b||!v,onClick:()=>n.run({kind:`providers`,choices:_},()=>a({})),children:`Save providers`})})]}),v?(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Save or discard provider changes before resuming.`}),(0,h.jsx)(J,{disabled:n.pending,onClick:()=>a({}),children:`Discard provider changes`})]}):null,s.error?(0,h.jsx)(`p`,{className:`mt-2 text-small text-red`,children:s.error.message}):null]})})}function CU(e,t){return{...t.chunking&&!Rj(t.chunking,e.chunking)?{chunking:t.chunking}:{},...t.llm&&!TU(t.llm,e.llm)?{llm:t.llm}:{},...t.audio&&!TU(t.audio,e.audio)?{audio:t.audio}:{},...t.images&&!TU(t.images,e.images)?{images:t.images}:{}}}function wU({label:e,choice:t,family:n,providers:r,onChange:i}){return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(Dj,{label:`${e} provider`,inline:!0,family:n,providers:r,value:t.provider,problem:void 0,onPick:e=>i({provider:e,model:``})}),(0,h.jsx)(Oj,{label:`${e} model`,inline:!0,provider:t.provider,value:t.model,problem:void 0,onPick:e=>i({...t,model:e})}),n===`llm`?(0,h.jsx)(Aj,{choice:t,onChange:i}):null]})}function TU(e,t){return e.provider===t?.provider&&e.model===t.model&&e.thinking===t.thinking&&(`voice`in e?e.voice:void 0)===(t&&`voice`in t?t.voice:void 0)}function EU(e,t){switch(e){case`research`:case`article`:return t.llm?.provider;case`audio`:return t.audio?.provider;case`images`:case`thumbnail`:return t.images?.provider;case`video`:return}}function DU(e,t,n){let r=EU(e,t);if(r===void 0||r===``)return;let i=n.find(e=>e.id===r);if(i!==void 0)return i.readiness.kind===`keyed`?i.readiness.hasKey?void 0:{label:`Key missing`,provider:r}:i.readiness.installed?void 0:{label:`CLI missing`,provider:r}}var OU={research:`Research notes`,article:`Article workspace`,audio:`Narration`,images:`Image library`,thumbnail:`Thumbnail preview`,video:`Preview & export`};function kU({stage:e,project:t,outputs:n,providers:r,actions:i,children:a,active:o=!0}){let s=SO(e.kind,t.config),c=t.status===`paused`?{...i,pending:!0}:i,l=DU(e.kind,t.config,r),u=i.refusal?.stage===e.kind?i.refusal.message:void 0,d=e.state===`failed`||e.state===`canceled`,f=n.some(t=>t.stageKind===e.kind&&t.role!==`instructions`)||e.state===`running`||e.state===`done`||e.state===`provided`||e.kind===`video`&&e.state!==`skipped`,p=e.progressTotal===null||e.progressTotal<=0?void 0:Math.min(100,Math.max(0,Math.round((e.progressCurrent??0)/e.progressTotal*100)));return(0,h.jsxs)(`section`,{"data-tour":`project-${e.kind}`,hidden:!o,"aria-label":`${s} workspace`,className:o?`min-w-0 rounded-panel border border-line bg-panel`:`hidden`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-line px-5 py-4`,children:[(0,h.jsx)(Tc,{kind:e.kind,className:`text-ink2`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`text-row font-bold`,children:e.kind===`video`&&s===`Audio export`?`Listen & export`:OU[e.kind]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:TO(e,n,t)})]}),(0,h.jsx)(Yj,{state:e.state})]}),e.state===`running`?(0,h.jsxs)(`div`,{className:`border-b border-line px-5 py-3`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex justify-between text-small text-run-text`,children:[(0,h.jsxs)(`span`,{children:[s,` in progress`]}),p===void 0?(0,h.jsx)(`span`,{children:`Waiting for provider progress`}):(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[p,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`${s} progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":p,className:`h-1.5 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:`h-full origin-left bg-accent`,style:{transform:`scaleX(${(p??0)/100})`}})})]}):null,d?(0,h.jsxs)(`div`,{className:`m-5 rounded-control border border-red/30 bg-red-tint p-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`p`,{className:`min-w-0 flex-1 text-small text-red`,children:e.state===`failed`?`${s} needs attention.`:`${s} was canceled.`}),(0,h.jsx)(`span`,{className:`text-label text-ink2`,children:EO(e)}),(0,h.jsx)(`button`,{type:`button`,disabled:l!==void 0||c.pending,onClick:()=>c.run({kind:`retry`,stage:e.kind}),className:`rounded-control border border-red px-3 py-2 text-small text-ink hover:bg-panel2 disabled:opacity-50`,children:l?.label??`Retry stage`})]}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:t.status===`paused`?`Resume the project to continue with its saved settings.`:`Retry keeps completed outputs. To change the provider or model, open Run settings.`}),e.failureReason?(0,h.jsxs)(`details`,{className:`mt-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small text-red`,children:`Error details`}),(0,h.jsx)(`span`,{className:`mt-2 block max-h-48 overflow-auto whitespace-pre-wrap break-words text-label text-ink2`,children:e.failureReason})]}):null,l?(0,h.jsxs)(`p`,{className:`mt-3 text-small text-ink2`,children:[l.label,` for `,l.provider,`.`,` `,(0,h.jsx)(ia,{to:`/settings`,className:`underline underline-offset-4`,children:`Open Settings`})]}):null]}):null,u?(0,h.jsx)(`div`,{className:`px-5 pt-4`,children:(0,h.jsx)(KH,{message:u,onDismiss:i.dismissRefusal})}):null,e.state===`running`&&e.kind!==`article`&&e.kind!==`images`&&e.kind!==`video`?(0,h.jsx)(NM,{projectId:t.id,stage:e.kind}):null,f?a:d?null:(0,h.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,h.jsx)(Tc,{kind:e.kind,className:`size-8 text-ink3`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:e.state===`skipped`?`${s} was switched off for this run.`:t.status===`paused`?`Resume the project when you are ready to continue.`:`This stage will start when its inputs are ready.`}),(0,h.jsx)(`p`,{className:`max-w-md text-small text-ink3`,children:e.state===`skipped`?`The other stages are available from the list.`:`You can review completed outputs while the project runs.`})]})]})}function AU({project:e,actions:t,inFlight:n,value:r,uploading:i,onChange:a,onDiscard:o,onUploading:s}){let c=!$D(QD(e.config.subtitles,e.config.sources),r),l=e.status!==`running`&&!n,u=e.config.sources.audio!==`off`,d=e.config.sources.video!==`off`&&e.config.sources.images!==`off`;return(0,h.jsxs)(`div`,{"data-tour":`project-subtitles`,className:`mt-2 min-w-0 border-t border-line pt-4`,children:[(0,h.jsx)(hM,{value:r,format:e.format,audioEnabled:u,videoEnabled:d,disabled:!l||t.pending,onChange:a,onUploading:s}),(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink2`,children:l?e.status===`paused`?`Save subtitles, then Resume to update the export. Existing narration and images are reused.`:`Saving updates only the local export using saved narration and images. No paid generation requests are made.`:`Pause the run and wait for active requests to stop before changing subtitles.`}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(J,{disabled:!l||t.pending||i||!u||!c||!eO(r),onClick:()=>t.run({kind:`subtitles`,subtitles:QD(r,e.config.sources)},o),children:`Save subtitles`}),c?(0,h.jsx)(J,{variant:`ghost`,disabled:t.pending||i,onClick:o,children:`Discard subtitle changes`}):null,c&&e.status===`paused`?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Save or discard subtitle changes before resuming.`}):null]})]})}function jU(e){let{api:t}=B(),n=_(),[r,i]=(0,m.useState)(void 0),a=tt({mutationFn:e=>NU(t,e.projectId,e.action),onMutate:()=>{i(void 0)},onSuccess:async(e,t)=>{if(!e.ok){i({message:e.message,stage:MU(t.action)});return}let{project:r,stages:a,outputs:o}=e.value;n.setQueryData(jy.project(t.projectId),{project:r,stages:a,outputs:o}),n.invalidateQueries({queryKey:jy.projects}),await n.invalidateQueries({queryKey:jy.project(t.projectId)})},onError:(e,t)=>{i({message:e.message,stage:MU(t.action)})}});return{run:(t,n)=>{a.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok&&n?.()}})},pending:a.isPending,refusal:r,dismissRefusal:()=>{i(void 0)}}}function MU(e){switch(e.kind){case`cancel`:case`pause`:case`resume`:case`providers`:return;case`retry`:case`rerun`:return e.stage;case`subtitles`:return`video`;case`save-article`:return`article`;case`delete-image`:case`regenerate-image`:return`images`}}function NU(e,t,n){switch(n.kind){case`pause`:return wH(e,t);case`resume`:return TH(e,t);case`providers`:return EH(e,t,n.choices);case`subtitles`:return DH(e,t,n.subtitles);case`cancel`:return CH(e,t);case`retry`:return OH(e,t,n.stage);case`rerun`:return kH(e,t,n.stage);case`save-article`:return AH(e,t,n.markdown);case`delete-image`:return jH(e,t,n.outputId);case`regenerate-image`:return MH(e,t,n.outputId)}}var PU=200;function FU(e){let{api:t,openEvents:n}=B(),r=_();(0,m.useEffect)(()=>{let i=_O(()=>{r.invalidateQueries({queryKey:jy.project(e)}),r.invalidateQueries({queryKey:jy.projects})},PU),a=Xy(n,Ao(t,`projects/${e}`),{refetch:i.ask,previewWriting:t=>{r.setQueryData(jM(e),e=>MM(e??[],t))},appendArticle:t=>{r.setQueryData(jy.article(e),e=>`${e??``}${t}`)},patch:t=>{t.type===`stage.state`&&t.state===`running`&&(r.setQueryData(jM(e),e=>(e??[]).filter(e=>e.stage!==t.stage)),t.stage===`article`&&r.setQueryData(jy.article(e),``)),r.setQueryData(jy.project(e),e=>hO(e,t))}});return()=>{a(),i.stop()}},[t,n,r,e])}function IU({projectId:e}){return(0,h.jsx)(LU,{projectId:e},e)}function LU({projectId:e}){let{api:t}=B(),n=R(Ny(t,e)),r=R(Iy(t)),i=R(Ry(t)),a=jU(e),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)({}),[f,p]=(0,m.useState)(),[g,_]=(0,m.useState)(),v=lk(e),y=(0,m.useRef)(void 0);if((0,m.useEffect)(()=>{if(v===void 0){y.current=void 0;return}n.data!==void 0&&y.current!==v&&(y.current=v,v===`project`&&s(!0),v===`download`&&l({projectId:e,stage:xO(n.data.project.config)===`article`?`article`:`video`}))},[v,e,n.data]),FU(e),n.error!==null)return(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message});if(n.data===void 0)return(0,h.jsx)(RU,{});let{project:b,stages:x,outputs:S}=n.data,C=c?.projectId===e?c.stage:yU(x),w=t=>l({projectId:e,stage:t}),T=S.find(e=>e.role===`video`||e.role===`audio_export`)??(b.config.sources.video===`off`&&b.config.sources.audio===`off`?S.find(e=>e.role===`article_md`):void 0),E=x.some(e=>e.state===`running`),D=b.status===`running`||b.status===`paused`||E||a.pending,O=QD(b.config.subtitles,b.config.sources),k=f?.projectId===e?QD(f.value,b.config.sources):O,A=!$D(k,O),j=g?.projectId===e&&g.pending,M=()=>p(t=>t?.projectId===e?void 0:t);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,children:[(0,h.jsx)(ia,{to:`/`,className:`mb-[10px] block text-small text-ink2 hover:text-ink`,children:`< Projects`}),(0,h.jsxs)(`div`,{"data-tour":`project-controls`,children:[(0,h.jsx)(hU,{project:b,prompts:i.data?.prompts,actions:a,inFlight:E,settingsOpen:o,onToggleSettings:()=>s(!o),primaryOutput:T,unsavedProviders:Object.keys(CU(b.config,u)).length>0||A||j}),(0,h.jsx)(`div`,{hidden:!o,className:o?`mt-4 rounded-panel border border-line bg-panel`:`hidden`,children:(0,h.jsx)(SU,{project:b,providers:r.data?.providers??[],actions:a,inFlight:E,edits:u,setEdits:d})}),a.refusal===void 0||a.refusal.stage!==void 0?null:(0,h.jsx)(cA,{className:`py-[10px]`,children:(0,h.jsx)(KH,{message:a.refusal.message,onDismiss:a.dismissRefusal})})]}),(0,h.jsx)(TM,{}),(0,h.jsx)(bU,{stages:x,project:b}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(xU,{stages:x,project:b,outputs:S,selected:C,onSelect:w}),(0,h.jsx)(`div`,{className:`min-w-0`,children:x.map(t=>(0,h.jsx)(kU,{active:t.kind===C,stage:t,project:b,outputs:S,providers:r.data?.providers??[],actions:a,children:(0,h.jsx)(mU,{stage:t,project:b,outputs:S,actions:a,busy:D,...t.kind===`video`?{subtitleControls:(0,h.jsx)(AU,{project:b,actions:a,inFlight:E,value:k,uploading:j,onChange:t=>p({projectId:e,value:QD(t,b.config.sources)}),onDiscard:M,onUploading:t=>_(n=>n?.projectId===e&&n.pending===t?n:{projectId:e,pending:t})},e)}:{}})},t.id))})]})]})}function RU(){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,role:`status`,"aria-label":`Loading project`,children:[(0,h.jsx)(`div`,{className:`h-28 rounded-panel bg-panel`}),(0,h.jsx)(`div`,{className:`h-24 rounded-panel border border-line bg-panel`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(sA,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(cA,{children:[(0,h.jsx)(`span`,{className:`size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`h-4 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-16 rounded-control bg-panel2`})]},e))}),(0,h.jsx)(`div`,{className:`h-[560px] rounded-panel border border-line bg-panel`})]})]})}var zU=`relative grid grid-cols-[14px_minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[4px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[14px_minmax(0,1fr)_140px_100px_32px]`,BU=`col-start-2 row-start-2 text-small text-ink2 tabular-nums md:col-start-3 md:row-start-1`,VU=`col-start-3 row-start-1 justify-end md:col-start-4`,HU=`relative z-10 col-start-4 row-start-1 size-8 p-0 md:col-start-5`;function UU(){let{api:e}=B(),t=_(),n=R(My(e)),[r,i]=(0,m.useState)(void 0),a=tt({mutationFn:t=>oo(e,t),onSettled:async()=>{i(void 0),await t.invalidateQueries({queryKey:jy.projects})}});return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(`div`,{className:`mb-4 flex items-center`,children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Projects`}),(0,h.jsx)(J,{variant:`accent`,className:`ml-auto`,asChild:!0,children:(0,h.jsx)(ia,{to:`/play`,children:`New run`})})]}),(0,h.jsx)(TM,{}),n.data?.projects.length===0?(0,h.jsx)(Pk,{}):null,n.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:n.error.message})}),n.data===void 0?n.error===null?(0,h.jsx)(qU,{}):null:n.data.projects.length===0?(0,h.jsx)(sA,{children:(0,h.jsxs)(`p`,{className:`px-4 py-7 text-body text-ink2`,children:[`No projects yet. Set up a run on`,` `,(0,h.jsx)(ia,{to:`/play`,className:`rounded-control text-ink underline underline-offset-[3px]`,children:`Play`}),`.`]})}):(0,h.jsx)(sA,{children:n.data.projects.map(e=>(0,h.jsx)(WU,{project:e,onDelete:()=>{i(e)}},e.id))}),a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`mt-[10px] text-label text-red`,children:a.error.message}),(0,h.jsx)(oA,{open:r!==void 0,title:r===void 0?``:`Delete "${r.title}"?`,consequence:`Deletes the project and every file it produced.`,verb:`Delete`,pending:a.isPending,onConfirm:()=>{r!==void 0&&a.mutate(r.id)},onCancel:()=>{i(void 0)}})]})}function WU({project:e,onDelete:t}){return(0,h.jsxs)(`div`,{className:zU,children:[(0,h.jsx)(Zj,{state:e.status,className:`col-start-1 row-start-1`}),(0,h.jsxs)(`span`,{className:`col-start-2 row-start-1 flex min-w-0 flex-wrap items-baseline gap-x-3`,children:[(0,h.jsx)(ia,{to:`/projects/$projectId`,params:{projectId:e.id},className:`rounded-control font-semibold after:absolute after:inset-0 after:content-['']`,children:e.title}),(0,h.jsx)(`span`,{className:`truncate text-small text-ink2`,children:GU(e)})]}),(0,h.jsx)(`span`,{className:BU,children:Sc(e.createdAt)}),(0,h.jsx)(Yj,{state:e.status,announce:e.title,className:VU}),(0,h.jsx)(KU,{project:e,onDelete:t}),e.status===`running`?(0,h.jsx)(lA,{current:e.progress,total:1}):null]})}function GU(e){let t=e.config.articlePrompt;return[t===void 0||t===``?void 0:t,e.format].filter(e=>e!==void 0).join(` · `)}function KU({project:e,onDelete:t}){let n=e.status===`running`;return(0,h.jsxs)(dA,{children:[(0,h.jsx)(fA,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.title}`,className:HU,children:(0,h.jsx)(Dk,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(pA,{children:[(0,h.jsx)(`span`,{title:n?`Cancel the run first`:void 0,children:(0,h.jsx)(mA,{disabled:n,onSelect:t,children:`Delete`})}),n?(0,h.jsx)(`p`,{className:`engraved px-[10px] py-[5px] text-ink3`,children:`Cancel the run first`}):null]})]})}function qU(){return(0,h.jsx)(sA,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(`div`,{className:zU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-3 w-2/5 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-[10px] w-[90px] rounded-control bg-panel2 md:col-start-3`}),(0,h.jsx)(`span`,{className:`col-start-4 row-start-1 h-[10px] w-14 justify-self-end rounded-control bg-panel2 md:col-start-4`})]},e))})}function JU({promptId:e,kind:t,from:n,onLeave:r}){let{api:i}=B(),a=_(),o=ck(),s=R(Ry(i)),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),f=(0,m.useId)(),[p,g]=pO(JSON.stringify(e===void 0?[`new`,t,n??null]:[`prompt`,e])),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(void 0),S=b!==void 0,[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=p??b??O,A=tt({mutationFn:t=>To(i,t,e),onSuccess:async(e,t)=>{if(!e.ok){y(e.fields);return}x(e.value),g(e=>e===t?void 0:e),o({type:`prompt-saved`,id:e.value.id,kind:e.value.kind}),await a.invalidateQueries({queryKey:Ry(i).queryKey})}}),j=tt({mutationFn:e=>Eo(i,e),onSuccess:async()=>{w(!1),g(void 0),await a.invalidateQueries({queryKey:Ry(i).queryKey}),r(k.kind)}});EA(S,()=>{r(k.kind)});let M=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},N=qA(k,v),P=JA(N),F=ZA(k.body),I=k.body.trim()===``?[]:YA(N),ee=k.name.trim()===``?[]:XA(N);return sk({promptNamed:k.name.trim()!==``&&ee.length===0,promptBodyReady:k.body.trim()!==``&&I.length===0,promptHasKeywords:F.length>0&&I.length===0,promptSaveReady:P===void 0&&!A.isPending&&!S,promptSaving:A.isPending||S,promptIsArticle:k.kind===`article`,promptIsImage:k.kind===`image`}),s.error===null?E!==void 0&&T===void 0?(0,h.jsx)(AA,{}):E!==void 0&&D===void 0?(0,h.jsx)(YU,{kind:t,children:`That prompt is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(ia,{to:`/prompts`,search:{kind:k.kind},className:`mb-[10px] inline-flex items-center gap-1 text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(Sk,{"aria-hidden":`true`,className:`size-[14px]`}),`Prompts`]}),(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:e===void 0?`New prompt`:`Edit 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:`${kA} flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`flex items-end gap-[14px]`,children:[(0,h.jsxs)(`div`,{"data-tour":`prompt-name`,className:`flex-1`,children:[(0,h.jsx)(NA,{htmlFor:c,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(FA,{id:c,value:k.name,"aria-invalid":ee.length>0,"aria-describedby":ee.length===0?void 0:l,onChange:e=>{M({...k,name:e.target.value},`name`)}}),ee.length===0?null:(0,h.jsx)(`p`,{id:l,className:`mt-1 text-label text-red`,children:ee.map(e=>e.message).join(` `)})]}),(0,h.jsx)(PA,{label:`Kind`,value:k.kind,options:rA,onPick:e=>{M({...k,kind:e},`name`)}})]}),(0,h.jsxs)(`div`,{"data-tour":`prompt-body`,children:[(0,h.jsx)(NA,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(ej,{id:u,value:k.body,invalid:I.length>0,describedBy:I.length===0?void 0:d,onChange:e=>{M({...k,body:e},`body`)}})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-save`,children:(0,h.jsx)(OA,{onDelete:e===void 0?void 0:()=>{w(!0)},blocked:P,blockedId:f,pending:A.isPending,saved:S,cancel:(0,h.jsx)(J,{asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts`,search:{kind:k.kind},onClick:()=>{g(void 0)},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:`${kA} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(wA,{slots:F,body:k.body,lint:I,lintId:d})})]}),(0,h.jsx)(oA,{open:C,title:`Delete "${k.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:j.isPending,onConfirm:()=>{e!==void 0&&j.mutate(e)},onCancel:()=>{w(!1)}})]}):(0,h.jsx)(YU,{kind:k.kind,children:s.error.message})}function YU({kind:e,children:t}){return(0,h.jsx)(jA,{back:(0,h.jsx)(ia,{to:`/prompts`,search:{kind:e},className:MA,children:`Back to Prompts`}),children:t})}var XU=`grid grid-cols-[minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[6px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[260px_minmax(0,1fr)_auto_32px]`,ZU=`col-span-3 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1`,QU=`md:col-start-2 md:row-start-1`;function $U({kind:e,onKind:t}){let{api:n}=B(),r=_(),i=R(Ry(n)),[a,o]=(0,m.useState)(void 0),s=tt({mutationFn:e=>Eo(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:jy.prompts})}}),c=i.data?.prompts.filter(t=>t.kind===e);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:`Prompts`}),(0,h.jsxs)(`div`,{className:`mb-4 flex items-center gap-4`,children:[(0,h.jsx)(hA,{type:`single`,value:e,"aria-label":`Prompt kind`,onValueChange:e=>{let n=rA.find(t=>t.value===e);n!==void 0&&t(n.value)},children:rA.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(eW,{kind:e})]}),i.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:i.error.message})}),c===void 0?i.error===null?(0,h.jsx)(rW,{}):null:c.length===0?(0,h.jsx)(tW,{kind:e}):(0,h.jsx)(sA,{children:c.map(e=>(0,h.jsxs)(`div`,{className:XU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(`span`,{className:W(ZU,QU),children:e.slots.map(e=>(0,h.jsx)(uA,{name:e},e))}),(0,h.jsx)(J,{className:`col-start-2 row-start-1 md:col-start-3`,asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts/$promptId`,params:{promptId:e.id},children:`Edit`})}),(0,h.jsx)(nW,{prompt:e,onDelete:()=>{o(e)}})]},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{className:`mt-[10px] text-label text-red`,children:s.error.message}),(0,h.jsx)(oA,{open:a!==void 0,title:a===void 0?``:`Delete "${a.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>{o(void 0)}})]})}function eW({kind:e}){return(0,h.jsx)(J,{asChild:!0,children:(0,h.jsxs)(ia,{to:`/prompts/new`,search:{kind:e},children:[(0,h.jsx)(kk,{"aria-hidden":`true`,className:`size-[14px]`}),`New prompt`]})})}function tW({kind:e}){return(0,h.jsx)(sA,{children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-4 py-7 text-ink2`,children:[(0,h.jsx)(`span`,{className:`max-w-[75ch]`,children:`No ${e} prompts yet. A prompt is text with {{keywords}}; each keyword becomes a field on Play.`}),(0,h.jsx)(eW,{kind:e})]})})}function nW({prompt:e,onDelete:t}){return(0,h.jsxs)(dA,{children:[(0,h.jsx)(fA,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-3 row-start-1 size-8 p-0 md:col-start-4`,children:(0,h.jsx)(Dk,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(pA,{children:[(0,h.jsx)(mA,{asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts/new`,search:{kind:e.kind,from:e.id},children:`Duplicate`})}),(0,h.jsx)(mA,{onSelect:t,children:`Delete`})]})]})}function rW(){return(0,h.jsx)(sA,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:XU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsxs)(`span`,{className:W(ZU,QU),children:[(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[18px] w-[72px] rounded-control bg-panel2`})]}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-3`})]},e))})}function iW(){let{api:e}=B(),t=_(),n=R({queryKey:[`catalogue`],queryFn:async()=>Za(await e.fetch(`${e.origin}/api/providers/catalogue`)),refetchInterval:3e4}),r=tt({mutationFn:async()=>Za(await e.fetch(`${e.origin}/api/providers/catalogue/refresh`,{method:`POST`})),onSuccess:e=>{t.setQueryData([`catalogue`],e),t.invalidateQueries({queryKey:[`provider-models`]})}});return(0,h.jsxs)(`section`,{className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Models and request limits`}),(0,h.jsx)(`p`,{className:`my-2 text-body text-ink2`,children:`The catalogue lists supported text, image and speech models, their prices and request limits. Local YAML edits load automatically; model pickers refresh every 30 seconds.`}),n.data?.path?(0,h.jsx)(`p`,{className:`my-2 break-all font-mono text-small`,children:n.data.path}):null,(0,h.jsxs)(`p`,{className:`mb-3 text-small text-ink2`,children:[`Verified `,n.data?.updatedAt??`date unavailable`,`. Refresh replaces your local file with the published catalogue and saves the previous file alongside it.`]}),(0,h.jsx)(J,{disabled:r.isPending||!n.data?.path,onClick:()=>r.mutate(),children:r.isPending?`Refreshing…`:`Refresh published catalogue`}),n.data?.warning||n.error||r.error?(0,h.jsx)(`p`,{role:`alert`,className:`mt-2 text-body text-red`,children:r.error?.message??n.error?.message??n.data?.warning}):null,r.isSuccess?(0,h.jsx)(`p`,{role:`status`,className:`mt-2 text-small text-green`,children:`Catalogue updated.`}):null]})}function aW({provider:e,readiness:t}){let{api:n}=B(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(void 0),[d,f]=(0,m.useState)(!1),p=e.cliPath?.configured??null,g=e.id===`claude-code`?`claude`:e.id,v=e.cliPath?.command??g,y=l??p??``,b=tt({mutationFn:t=>ho(n,e.id,t),onMutate:()=>f(!1),onSuccess:async e=>{r.setQueryData(jy.providers,t=>t?{...t,providers:t.providers.map(t=>t.id===e.id?e:t)}:void 0),u(void 0),f(!0),await r.invalidateQueries({queryKey:jy.providers})}});return(0,m.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),TA);return()=>clearTimeout(e)},[d]),(0,h.jsxs)(`div`,{"data-ready":t.installed,className:`grid gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0 sm:grid-cols-[140px_1fr]`,children:[(0,h.jsx)(`span`,{id:i,className:W(`font-semibold`,t.installed?`text-ink`:`text-ink3`),children:e.displayName}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-ink2`,"aria-live":`polite`,children:[(0,h.jsx)(Zj,{state:t.installed?`done`:`pending`}),(0,h.jsx)(`span`,{children:oW(t,p)})]}),(0,h.jsxs)(`p`,{className:`mt-1 break-all text-label text-ink3`,children:[`Command: `,(0,h.jsx)(`code`,{children:v})]}),(0,h.jsxs)(`form`,{className:`mt-3`,onSubmit:e=>{e.preventDefault(),b.isPending||b.mutate(y)},children:[(0,h.jsx)(NA,{htmlFor:a,id:o,className:`mb-[5px]`,children:`Executable path`}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(FA,{id:a,autoComplete:`off`,spellCheck:!1,maxLength:4096,"aria-labelledby":`${i} ${o}`,"aria-invalid":b.error!==null,"aria-describedby":`${s}${b.error?` ${c}`:``}`,placeholder:g,value:y,disabled:b.isPending,onChange:e=>{u(e.target.value),f(!1),b.reset()}}),(0,h.jsx)(J,{type:`submit`,"aria-label":`Save ${e.displayName} path`,disabled:b.isPending,children:b.isPending?`Checking…`:`Save path`}),d?(0,h.jsx)(DA,{}):null]}),(0,h.jsxs)(`p`,{id:s,className:`mt-1 text-label text-ink3`,children:[`Leave blank to find `,(0,h.jsx)(`code`,{children:g}),` on PATH. Use an absolute path without quotes or arguments.`]}),b.error?(0,h.jsx)(`p`,{id:c,role:`alert`,className:`mt-1 text-label text-red`,children:b.error.message}):null]}),(0,h.jsxs)(`p`,{className:`mt-2 text-label text-ink3`,children:[`Sign in through `,e.displayName,` itself before generating; Slopify uses that login.`]})]})]})}function oW(e,t){return e.installed?e.version===void 0?`Installed`:`Installed, version ${e.version}`:t===null?`Not found on PATH`:`Not found at saved path`}var sW=[`llm`,`tts`,`image`],cW={llm:`API keys · LLM`,tts:`API keys · Text to speech`,image:`API keys · Image generation`},lW=`••••••••••••`,uW=`grid grid-cols-[140px_1fr_auto] items-end gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0`,dW=`engraved border-t border-line px-4 py-3 text-ink3 first:border-t-0`;function fW(){let{api:e}=B(),t=R(Iy(e));if(t.error!==null)return(0,h.jsx)(sA,{children:(0,h.jsx)(cA,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:t.error.message})})});if(t.data===void 0)return(0,h.jsx)(mW,{});let n=t.data.providers,r=n.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey);return(0,h.jsx)(sA,{children:sW.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,className:`border-t border-line first:border-t-0`,children:[(0,h.jsx)(`h2`,{className:dW,children:cW[e]}),n.filter(t=>t.family===e).map(e=>e.readiness.kind===`cli`?(0,h.jsx)(aW,{provider:e,readiness:e.readiness},e.id):(0,h.jsx)(pW,{provider:e,hasKey:e.readiness.hasKey},e.id)),e===`llm`&&r?(0,h.jsx)(`p`,{className:`border-t border-line px-4 pt-[10px] pb-[14px] text-small text-ink2`,children:`Paste a key to make its provider selectable on Play.`}):null]},e))})}function pW({provider:e,hasKey:t}){let{api:n}=B(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(void 0),[b,x]=(0,m.useState)(!1),S=async()=>{f(!0),y(void 0);try{await z(n,e.id,l),u(``),g(!0),await r.invalidateQueries({queryKey:jy.providers})}catch(e){y(e instanceof Error?e.message:String(e))}finally{f(!1)}},C=tt({mutationFn:()=>go(n,e.id),onSuccess:async()=>{x(!1),y(void 0),await r.invalidateQueries({queryKey:jy.providers})},onError:e=>{x(!1),y(e.message)}});(0,m.useEffect)(()=>{if(!p)return;let e=setTimeout(()=>{g(!1)},TA);return()=>{clearTimeout(e)}},[p]);let w=[t?s:void 0,v===void 0?void 0:c].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`div`,{"data-ready":t,className:uW,children:[(0,h.jsx)(`span`,{id:o,className:`pb-[7px] font-semibold`,children:e.displayName}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(NA,{htmlFor:i,id:a,className:`mb-[5px]`,children:`API key`}),(0,h.jsx)(FA,{id:i,type:`password`,autoComplete:`off`,spellCheck:!1,"aria-labelledby":`${o} ${a}`,"aria-invalid":v!==void 0,"aria-describedby":w===``?void 0:w,placeholder:t?lW:void 0,value:l,onChange:e=>{u(e.target.value)}}),e.id===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Paste the Base64 credentials from Inworld Settings → API Keys.`}):null,t?(0,h.jsx)(`span`,{id:s,className:`sr-only`,children:`A key is stored for this provider.`}):null,v===void 0?null:(0,h.jsx)(`p`,{id:c,className:`mt-1 text-label text-red`,children:v})]}),(0,h.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2`,children:[(0,h.jsx)(J,{"aria-label":`Save ${e.displayName} key`,disabled:l.trim()===``||d,onClick:()=>{S()},children:`Save`}),p?(0,h.jsx)(DA,{}):null,t?(0,h.jsx)(J,{className:`bg-transparent`,"aria-label":`Remove ${e.displayName} key`,onClick:()=>{x(!0)},children:`Remove`}):null]}),(0,h.jsx)(oA,{open:b,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this provider cannot retry until a key is saved.`,verb:`Remove`,pending:C.isPending,onConfirm:()=>{C.mutate()},onCancel:()=>{x(!1)}})]})}function mW(){return(0,h.jsx)(sA,{children:[0,1,2,3].map(e=>(0,h.jsxs)(cA,{children:[(0,h.jsx)(`span`,{className:`h-4 w-28 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 flex-1 rounded-control bg-panel2`})]},e))})}var hW=_v,gW=xv;function _W({className:e,children:t,...n}){return(0,h.jsxs)(yv,{"data-slot":`select-trigger`,className:W(`flex h-8 w-full items-center justify-between gap-2 rounded-control border border-line2`,`bg-panel2 px-[10px] text-left text-small text-ink data-[placeholder]:text-ink3`,e),...n,children:[t,(0,h.jsx)(Sv,{asChild:!0,children:(0,h.jsx)(xk,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-ink2`})})]})}function vW({className:e,children:t,position:n=`popper`,...r}){return(0,h.jsx)(Tv,{children:(0,h.jsx)(Dv,{"data-slot":`select-content`,position:n,sideOffset:4,className:W(`z-50 min-w-[var(--radix-select-trigger-width)] overflow-hidden rounded-panel`,`border border-line bg-panel p-1 shadow-[0_8px_24px_var(--color-shadow)]`,e),...r,children:(0,h.jsx)(zv,{children:t})})})}function yW({className:e,children:t,...n}){return(0,h.jsxs)(Gv,{"data-slot":`select-item`,className:W(`relative flex cursor-default items-center rounded-control py-[5px] pr-8 pl-[10px]`,`text-small text-ink outline-hidden select-none`,`focus:bg-panel2 data-highlighted:bg-panel2`,e),...n,children:[(0,h.jsx)(qv,{children:t}),(0,h.jsx)(Yv,{className:`absolute right-[10px] flex items-center`,children:(0,h.jsx)(bk,{"aria-hidden":`true`,className:`size-[14px] text-done`})})]})}var bW=`px-4 align-top`;function xW(){let{api:e}=B(),t=_(),n=R(Ly(e)),r=R(Iy(e)),[i,a]=(0,m.useState)(void 0),o=tt({mutationFn:t=>xo(e,t),onSettled:async()=>{a(void 0),await t.invalidateQueries({queryKey:jy.voices})}}),s=(r.data?.providers??[]).filter(e=>e.family===`tts`);if(n.error!==null)return(0,h.jsx)(sA,{children:(0,h.jsx)(cA,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});let c=n.data?.voices;return(0,h.jsxs)(sA,{"data-tour":`voices`,children:[(0,h.jsxs)(`table`,{className:`w-full table-fixed border-collapse text-small`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`th`,{className:W(bW,`engraved w-[26%] py-3 text-left text-ink3`),children:`Voices · Name`}),(0,h.jsx)(`th`,{className:W(bW,`engraved w-[26%] py-3 text-left text-ink3`),children:`Provider`}),(0,h.jsx)(`th`,{className:W(bW,`engraved py-3 text-left text-ink3`),children:`Voice ID`}),(0,h.jsx)(`th`,{className:W(bW,`w-[104px] py-3`),children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:c===void 0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:W(bW,`py-4`),children:(0,h.jsx)(`span`,{className:`block h-4 w-64 rounded-control bg-panel2`})})}):c.length===0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:W(bW,`py-4 text-ink2`),children:`Add a voice ID from your text-to-speech provider. Audio needs one to narrate.`})}):c.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`td`,{className:W(bW,`py-3 font-semibold`),children:e.name}),(0,h.jsx)(`td`,{className:W(bW,`py-3 text-ink2`),children:wW(s,e.provider)}),(0,h.jsx)(`td`,{className:W(bW,`py-3 text-ink2 tabular-nums`),children:e.voiceId}),(0,h.jsx)(`td`,{className:W(bW,`py-3 text-right`),children:(0,h.jsx)(J,{className:`bg-transparent`,"aria-label":`Remove ${e.name}`,onClick:()=>{a(e)},children:`Remove`})})]},e.id))}),(0,h.jsx)(`tfoot`,{children:(0,h.jsx)(SW,{tts:s})})]}),o.error===null?null:(0,h.jsx)(`p`,{className:`border-t border-line px-4 py-3 text-label text-red`,children:o.error.message}),(0,h.jsx)(oA,{open:i!==void 0,title:i===void 0?``:`Remove ${i.name}?`,consequence:`Projects that used this voice keep the audio they made with it.`,verb:`Remove`,pending:o.isPending,onConfirm:()=>{i!==void 0&&o.mutate(i.id)},onCancel:()=>{a(void 0)}})]})}function SW({tts:e}){let{api:t}=B(),n=_(),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(void 0),y=f??e[0]?.id,b=tt({mutationFn:e=>bo(t,e),onSuccess:async e=>{if(!e.ok){v(e.refusal);return}l(``),d(``),v(void 0),await n.invalidateQueries({queryKey:jy.voices})}}),x=(e,t)=>{t(),g?.field===e&&v(void 0)},S=e=>g?.field===e?g.message:void 0;return(0,h.jsxs)(`tr`,{children:[(0,h.jsxs)(`td`,{className:W(bW,`py-[14px]`),children:[(0,h.jsx)(NA,{htmlFor:r,className:`mb-[5px]`,children:`Voice name`}),(0,h.jsx)(FA,{id:r,value:c,"aria-invalid":S(`name`)!==void 0,onChange:e=>{let t=e.target.value;x(`name`,()=>{l(t)})}}),(0,h.jsx)(CW,{id:`${s}-name`,message:S(`name`)})]}),(0,h.jsxs)(`td`,{className:W(bW,`py-[14px]`),children:[(0,h.jsx)(NA,{id:a,className:`mb-[5px]`,children:`Provider`}),(0,h.jsxs)(hW,{value:y??``,onValueChange:t=>{let n=e.find(e=>e.id===t);n!==void 0&&x(`provider`,()=>{p(n.id)})},children:[(0,h.jsx)(_W,{id:i,"aria-labelledby":`${a} ${i}`,children:(0,h.jsx)(gW,{placeholder:`Pick a provider`})}),(0,h.jsx)(vW,{children:e.map(e=>(0,h.jsx)(yW,{value:e.id,children:e.displayName},e.id))})]}),(0,h.jsx)(CW,{id:`${s}-provider`,message:S(`provider`)})]}),(0,h.jsxs)(`td`,{className:W(bW,`py-[14px]`),children:[(0,h.jsx)(NA,{htmlFor:o,className:`mb-[5px]`,children:`Voice ID`}),(0,h.jsx)(FA,{id:o,className:`tabular-nums`,value:u,"aria-invalid":S(`voiceId`)!==void 0,"aria-describedby":S(`voiceId`)===void 0?void 0:`${s}-voiceId`,onChange:e=>{let t=e.target.value;x(`voiceId`,()=>{d(t)})}}),(0,h.jsx)(CW,{id:`${s}-voiceId`,message:S(`voiceId`)}),y===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Use an Inworld voice ID, such as Dennis, or one from your workspace.`}):null,b.error===null?null:(0,h.jsx)(`p`,{className:`mt-1 text-label text-red`,children:b.error.message})]}),(0,h.jsx)(`td`,{className:W(bW,`py-[14px] text-right`),children:(0,h.jsx)(J,{className:`mt-[22px]`,disabled:y===void 0||g!==void 0||b.isPending,onClick:()=>{y!==void 0&&b.mutate({provider:y,name:c,voiceId:u})},children:`Add voice`})})]})}function CW({id:e,message:t}){return t===void 0?null:(0,h.jsx)(`p`,{id:e,className:`mt-1 text-label text-red`,children:t})}function wW(e,t){return e.find(e=>e.id===t)?.displayName??t}var TW=30,EW=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function DW(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=TW?void 0:`The silence gap is a whole number of seconds between 0 and ${String(TW)}.`}function OW(){return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Settings`}),(0,h.jsx)(fW,{}),(0,h.jsx)(xW,{}),(0,h.jsx)(iW,{}),(0,h.jsx)(kW,{})]})}function kW(){let{api:e}=B(),t=_(),n=R(By(e)),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(!1),u=tt({mutationFn:t=>vo(e,t),onMutate:e=>{let n=t.getQueryData(jy.settings);return t.setQueryData(jy.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(jy.settings,r.previous)},onSuccess:e=>{t.setQueryData(jy.settings,e)}});if((0,m.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>{l(!1)},TA);return()=>{clearTimeout(e)}},[c]),n.error!==null)return(0,h.jsx)(sA,{children:(0,h.jsx)(cA,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});if(n.data===void 0)return(0,h.jsxs)(sA,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(cA,{children:[(0,h.jsx)(`span`,{className:`h-4 w-48 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 w-[72px] rounded-control bg-panel2`})]})]});let d=n.data,f=o??String(d.silenceGapSeconds),p=DW(f);return(0,h.jsxs)(sA,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] border-b border-line px-4 py-[14px]`,children:[(0,h.jsx)(`label`,{htmlFor:r,className:`font-semibold`,children:`Silence between segments`}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px]`,children:[(0,h.jsx)(FA,{id:r,type:`number`,inputMode:`numeric`,min:0,max:TW,step:1,className:`w-[72px] tabular-nums`,value:f,"aria-invalid":p!==void 0,"aria-describedby":p===void 0?void 0:i,onChange:e=>{s(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`seconds`}),(0,h.jsx)(J,{className:`ml-[6px]`,disabled:p!==void 0||u.isPending,onClick:()=>{l(!1),u.mutate({silenceGapSeconds:Number(f.trim()),appearance:d.appearance},{onSuccess:()=>{s(void 0),l(!0)}})},children:`Save`}),c?(0,h.jsx)(DA,{}):null,p===void 0?null:(0,h.jsx)(`p`,{id:i,className:`basis-full text-label text-red`,children:p}),u.error===null?null:(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:u.error.message})]})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] px-4 py-[14px]`,children:[(0,h.jsx)(`span`,{id:a,className:`font-semibold`,children:`Appearance`}),(0,h.jsx)(hA,{type:`single`,value:d.appearance,"aria-labelledby":a,className:`justify-self-start`,onValueChange:e=>{let t=EW.find(t=>t.value===e);t!==void 0&&u.mutate({silenceGapSeconds:d.silenceGapSeconds,appearance:t.value})},children:EW.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))})]})]})}function AW({counters:e}){return(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:e.map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col-reverse gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`dt`,{className:`engraved text-ink3`,children:e.label}),(0,h.jsx)(`dd`,{className:`m-0 text-counter font-bold tabular-nums tracking-[-0.01em]`,children:e.value})]},e.label))})}function jW({cells:e}){return(0,h.jsx)(`div`,{className:`grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:Array.from({length:e},(e,t)=>t).map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`})]},e))})}function MW(){let{api:e}=B(),t=R(Fy(e));return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`mb-1 text-title font-bold tracking-[-0.01em]`,children:`Usage`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`This machine only. The same counters, anonymised, feed slopify.stream.`})]}),t.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:t.error.message})}),t.data===void 0?t.error===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(jW,{cells:5}),(0,h.jsx)(VW,{})]}):null:(0,h.jsx)(NW,{usage:t.data})]})}function NW({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(AW,{counters:BW(e)}),t?(0,h.jsx)(`p`,{className:`-mt-3 text-body text-ink2`,children:`Numbers appear after your first run.`}):null,(0,h.jsxs)(`div`,{className:`overflow-hidden rounded-panel border border-line bg-panel`,children:[(0,h.jsxs)(`table`,{"aria-label":`Tokens by stage`,className:`w-full table-fixed border-collapse`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(PW,{className:`w-[24%]`,children:`Tokens by stage`}),(0,h.jsx)(PW,{className:`w-[38%]`,children:`Provider · model`}),(0,h.jsx)(PW,{className:`w-[19%] text-right`,children:`Tokens in`}),(0,h.jsx)(PW,{className:`w-[19%] text-right`,children:`Tokens out`})]})}),(0,h.jsx)(`tbody`,{children:e.byStage.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line last:border-b-0`,children:[(0,h.jsx)(FW,{className:`truncate font-semibold`,children:bO[e.stage]}),(0,h.jsx)(FW,{className:`truncate text-ink2`,children:IW(e)}),(0,h.jsx)(FW,{className:`text-right tabular-nums`,children:LW.format(e.tokensIn)}),(0,h.jsx)(FW,{className:`text-right tabular-nums`,children:LW.format(e.tokensOut)})]},`${e.stage}/${e.provider}/${e.model??``}`))})]}),e.byStage.length===0?(0,h.jsx)(`p`,{className:`px-4 py-5 text-small text-ink3`,children:`No stages have run yet.`}):null]}),(0,h.jsx)(`p`,{className:`engraved text-ink3`,children:`Machine ID ${e.machineId??`not made yet`} · Slopify ${e.appVersion}`})]})}function PW({children:e,className:t}){return(0,h.jsx)(`th`,{className:`engraved px-4 py-3 text-left text-ink3 ${t}`,children:e})}function FW({children:e,className:t}){return(0,h.jsx)(`td`,{className:`px-4 py-3 align-top text-small ${t}`,children:e})}function IW(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var LW=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),RW=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),zW=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function BW(e){let t=e.counters;return[{label:`Videos made`,value:LW.format(t.videosMade)},{label:`Hours of audio`,value:RW.format(t.audioSeconds/3600)},{label:`Images made`,value:LW.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?LW.format(t.tokensUsed):zW.format(t.tokensUsed)},{label:`Projects`,value:LW.format(t.projects)}]}function VW(){return(0,h.jsx)(sA,{children:[0,1,2,3].map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-[14px] border-b border-line px-4 py-3 last:border-b-0`,children:[(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-56 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-panel2`})]},e))})}var HW=ca({component:Wk}),UW=oa({getParentRoute:()=>HW,path:`/`,component:UU}),WW=oa({getParentRoute:()=>HW,path:`play`,component:xM}),GW=oa({getParentRoute:()=>HW,path:`projects/$projectId`,component:eG}),KW=oa({getParentRoute:()=>HW,path:`prompts`,validateSearch:e=>({kind:aA(e.kind)}),component:tG}),qW=oa({getParentRoute:()=>HW,path:`prompts/new`,validateSearch:e=>{let t=aA(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:nG}),JW=oa({getParentRoute:()=>HW,path:`prompts/$promptId`,component:rG}),YW=oa({getParentRoute:()=>HW,path:`entries`,validateSearch:e=>({category:nA(e.category)}),component:aG}),XW=oa({getParentRoute:()=>HW,path:`entries/new`,validateSearch:e=>{let t=nA(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:oG}),ZW=oa({getParentRoute:()=>HW,path:`entries/$entryId`,component:sG}),QW=oa({getParentRoute:()=>HW,path:`settings`,component:OW}),$W=oa({getParentRoute:()=>HW,path:`usage`,component:MW});function eG(){let{projectId:e}=GW.useParams();return(0,h.jsx)(IU,{projectId:e},e)}function tG(){let{kind:e}=KW.useSearch(),t=Hi();return(0,h.jsx)($U,{kind:e,onKind:e=>{t({to:`/prompts`,search:{kind:e},replace:!0})}})}function nG(){let{kind:e,from:t}=qW.useSearch(),n=iG();return(0,h.jsx)(JU,{promptId:void 0,kind:e,from:t,onLeave:n},`${e}:${t??`new`}`)}function rG(){let{promptId:e}=JW.useParams(),t=iG();return(0,h.jsx)(JU,{promptId:e,kind:`article`,from:void 0,onLeave:t},e)}function iG(){let e=Hi();return t=>{e({to:`/prompts`,search:{kind:t}})}}function aG(){let{category:e}=YW.useSearch(),t=Hi();return(0,h.jsx)(yA,{category:e,onCategory:e=>{t({to:`/entries`,search:{category:e},replace:!0})}})}function oG(){let{category:e,from:t}=XW.useSearch(),n=cG();return(0,h.jsx)(tj,{entryId:void 0,category:e,from:t,onLeave:n})}function sG(){let{entryId:e}=ZW.useParams(),t=cG();return(0,h.jsx)(tj,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function cG(){let e=Hi();return t=>{e({to:`/entries`,search:{category:t}})}}var lG=HW.addChildren({projectsRoute:UW,playRoute:WW,projectRoute:GW,promptsRoute:KW,newPromptRoute:qW,promptRoute:JW,entriesRoute:YW,newEntryRoute:XW,entryRoute:ZW,settingsRoute:QW,usageRoute:$W});function uG(){return Ta({routeTree:lG})}function dG(){let e,t,n=new Set;return{observe:r=>{if(e===void 0){e=r;return}if(r!==e&&r!==t){t=r;for(let e of n)e()}},staleAt:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function fG(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 pG(e){let t=dG(),n={api:ro(window.location.origin,fG(window.fetch.bind(window),t)),openEvents:e=>new EventSource(e),version:t};(0,Xa.createRoot)(e).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:new Ve,children:(0,h.jsx)(Mo,{deps:n,children:(0,h.jsx)(Oa,{router:uG()})})})}))}var mG=document.getElementById(`root`);if(mG===null)throw Error(`index.html carries no #root element for the app to mount on`);pG(mG);