@curie-agent/daemon 0.4.3 → 0.4.4

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.
@@ -231,4 +231,4 @@ ${V.join(`
231
231
 
232
232
  `)}p.write("payload.value = newResult;"),p.write("return payload;");const y=p.compile();return(N,k)=>y(h,N,k)};let i;const o=Ol,a=!Gg.jitless,u=a&&T6.value,d=t.catchall;let f;e._zod.parse=(h,p)=>{f??(f=r.value);const x=h.value;return o(x)?a&&u&&(p==null?void 0:p.async)===!1&&p.jitless!==!0?(i||(i=s(t.shape)),h=i(h,p),d?dk([],x,h,p,f,e):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),h)}});function Hv(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const s=e.filter(i=>!vo(i));return s.length===1?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(o=>ds(o,r,us())))}),t)}const fk=Q("$ZodUnion",(e,t)=>{nt.init(e,t),$e(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),$e(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),$e(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),$e(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${r.map(s=>Pg(s.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,s)=>{if(n)return n(r,s);let i=!1;const o=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},s);if(c instanceof Promise)o.push(c),i=!0;else{if(c.issues.length===0)return c;o.push(c)}}return i?Promise.all(o).then(a=>Hv(a,r,e,s)):Hv(o,r,e,s)}}),g8=Q("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,fk.init(e,t);const n=e._zod.parse;$e(e._zod,"propValues",()=>{const s={};for(const i of t.options){const o=i._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[a,c]of Object.entries(o)){s[a]||(s[a]=new Set);for(const u of c)s[a].add(u)}}return s});const r=pf(()=>{var o;const s=t.options,i=new Map;for(const a of s){const c=(o=a._zod.propValues)==null?void 0:o[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const u of c){if(i.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);i.set(u,a)}}return i});e._zod.parse=(s,i)=>{const o=s.value;if(!Ol(o))return s.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),s;const a=r.value.get(o==null?void 0:o[t.discriminator]);return a?a._zod.run(s,i):t.unionFallback||i.direction==="backward"?n(s,i):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),s)}}),x8=Q("$ZodIntersection",(e,t)=>{nt.init(e,t),e._zod.parse=(n,r)=>{const s=n.value,i=t.left._zod.run({value:s,issues:[]},r),o=t.right._zod.run({value:s,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,u])=>Bv(n,c,u)):Bv(n,i,o)}});function rm(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ea(e)&&ea(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),s={...e,...t};for(const i of r){const o=rm(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r],o=rm(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Bv(e,t,n){const r=new Map;let s;for(const a of t.issues)if(a.code==="unrecognized_keys"){s??(s=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&s&&e.issues.push({...s,keys:i}),vo(e))return e;const o=rm(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const y8=Q("$ZodRecord",(e,t)=>{nt.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!ea(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const i=[],o=t.keyType._zod.values;if(o){n.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(p=>ds(p,r,us())),input:u,path:[u],inst:e});continue}const f=d.value,h=t.valueType._zod.run({value:s[u],issues:[]},r);h instanceof Promise?i.push(h.then(p=>{p.issues.length&&n.issues.push(...bo(u,p.issues)),n.value[f]=p.value})):(h.issues.length&&n.issues.push(...bo(u,h.issues)),n.value[f]=h.value)}let c;for(const u in s)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&sk.test(a)&&c.issues.length){const f=t.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(c=f)}if(c.issues.length){t.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>ds(f,r,us())),input:a,path:[a],inst:e});continue}const d=t.valueType._zod.run({value:s[a],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...bo(a,f.issues)),n.value[c.value]=f.value})):(d.issues.length&&n.issues.push(...bo(a,d.issues)),n.value[c.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),v8=Q("$ZodEnum",(e,t)=>{nt.init(e,t);const n=F_(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(s=>A6.has(typeof s)).map(s=>typeof s=="string"?ta(s):s.toString()).join("|")})$`),e._zod.parse=(s,i)=>{const o=s.value;return r.has(o)||s.issues.push({code:"invalid_value",values:n,input:o,inst:e}),s}}),b8=Q("$ZodLiteral",(e,t)=>{if(nt.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?ta(r):r?ta(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),w8=Q("$ZodTransform",(e,t)=>{nt.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new P_(e.constructor.name);const s=t.transform(n.value,n);if(r.async)return(s instanceof Promise?s:Promise.resolve(s)).then(o=>(n.value=o,n.fallback=!0,n));if(s instanceof Promise)throw new Do;return n.value=s,n.fallback=!0,n}});function Uv(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const hk=Q("$ZodOptional",(e,t)=>{nt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",$e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),$e(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Pg(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const s=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Uv(o,s)):Uv(i,s)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),S8=Q("$ZodExactOptional",(e,t)=>{hk.init(e,t),$e(e._zod,"values",()=>t.innerType._zod.values),$e(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),_8=Q("$ZodNullable",(e,t)=>{nt.init(e,t),$e(e._zod,"optin",()=>t.innerType._zod.optin),$e(e._zod,"optout",()=>t.innerType._zod.optout),$e(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Pg(n.source)}|null)$`):void 0}),$e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),k8=Q("$ZodDefault",(e,t)=>{nt.init(e,t),e._zod.optin="optional",$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>Iv(i,t)):Iv(s,t)}});function Iv(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const N8=Q("$ZodPrefault",(e,t)=>{nt.init(e,t),e._zod.optin="optional",$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),j8=Q("$ZodNonOptional",(e,t)=>{nt.init(e,t),$e(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>Zv(i,e)):Zv(s,e)}});function Zv(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const E8=Q("$ZodCatch",(e,t)=>{nt.init(e,t),e._zod.optin="optional",$e(e._zod,"optout",()=>t.innerType._zod.optout),$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>ds(o,r,us()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>ds(i,r,us()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),T8=Q("$ZodPipe",(e,t)=>{nt.init(e,t),$e(e._zod,"values",()=>t.in._zod.values),$e(e._zod,"optin",()=>t.in._zod.optin),$e(e._zod,"optout",()=>t.out._zod.optout),$e(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(o=>su(o,t.in,r)):su(i,t.in,r)}const s=t.in._zod.run(n,r);return s instanceof Promise?s.then(i=>su(i,t.out,r)):su(s,t.out,r)}});function su(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const A8=Q("$ZodReadonly",(e,t)=>{nt.init(e,t),$e(e._zod,"propValues",()=>t.innerType._zod.propValues),$e(e._zod,"values",()=>t.innerType._zod.values),$e(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),$e(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(Yv):Yv(s)}});function Yv(e){return e.value=Object.freeze(e.value),e}const C8=Q("$ZodCustom",(e,t)=>{fn.init(e,t),nt.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,s=t.fn(r);if(s instanceof Promise)return s.then(i=>qv(i,n,r,e));qv(s,n,r,e)}});function qv(e,t,n,r){if(!e){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),t.issues.push($l(s))}}var Vv;class M8{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const s={...r,...this._map.get(t)};return Object.keys(s).length?s:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function z8(){return new M8}(Vv=globalThis).__zod_globalRegistry??(Vv.__zod_globalRegistry=z8());const qa=globalThis.__zod_globalRegistry;function D8(e,t){return new e({type:"string",...de(t)})}function R8(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...de(t)})}function Gv(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...de(t)})}function O8(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...de(t)})}function $8(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...de(t)})}function L8(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...de(t)})}function H8(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...de(t)})}function B8(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...de(t)})}function U8(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...de(t)})}function I8(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...de(t)})}function Z8(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...de(t)})}function Y8(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...de(t)})}function q8(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...de(t)})}function V8(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...de(t)})}function G8(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...de(t)})}function X8(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...de(t)})}function P8(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...de(t)})}function F8(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...de(t)})}function Q8(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...de(t)})}function K8(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...de(t)})}function W8(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...de(t)})}function J8(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...de(t)})}function eL(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...de(t)})}function tL(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...de(t)})}function nL(e,t){return new e({type:"string",format:"date",check:"string_format",...de(t)})}function rL(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...de(t)})}function sL(e,t){return new e({type:"string",format:"duration",check:"string_format",...de(t)})}function iL(e,t){return new e({type:"number",checks:[],...de(t)})}function oL(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...de(t)})}function aL(e,t){return new e({type:"boolean",...de(t)})}function lL(e){return new e({type:"unknown"})}function cL(e,t){return new e({type:"never",...de(t)})}function Xv(e,t){return new ok({check:"less_than",...de(t),value:e,inclusive:!1})}function Oh(e,t){return new ok({check:"less_than",...de(t),value:e,inclusive:!0})}function Pv(e,t){return new ak({check:"greater_than",...de(t),value:e,inclusive:!1})}function $h(e,t){return new ak({check:"greater_than",...de(t),value:e,inclusive:!0})}function Fv(e,t){return new k$({check:"multiple_of",...de(t),value:e})}function pk(e,t){return new j$({check:"max_length",...de(t),maximum:e})}function jd(e,t){return new E$({check:"min_length",...de(t),minimum:e})}function mk(e,t){return new T$({check:"length_equals",...de(t),length:e})}function uL(e,t){return new A$({check:"string_format",format:"regex",...de(t),pattern:e})}function dL(e){return new C$({check:"string_format",format:"lowercase",...de(e)})}function fL(e){return new M$({check:"string_format",format:"uppercase",...de(e)})}function hL(e,t){return new z$({check:"string_format",format:"includes",...de(t),includes:e})}function pL(e,t){return new D$({check:"string_format",format:"starts_with",...de(t),prefix:e})}function mL(e,t){return new R$({check:"string_format",format:"ends_with",...de(t),suffix:e})}function ma(e){return new O$({check:"overwrite",tx:e})}function gL(e){return ma(t=>t.normalize(e))}function xL(){return ma(e=>e.trim())}function yL(){return ma(e=>e.toLowerCase())}function vL(){return ma(e=>e.toUpperCase())}function bL(){return ma(e=>E6(e))}function wL(e,t,n){return new e({type:"array",element:t,...de(n)})}function SL(e,t,n){return new e({type:"custom",check:"custom",fn:t,...de(n)})}function _L(e,t){const n=kL(r=>(r.addIssue=s=>{if(typeof s=="string")r.issues.push($l(s,r.value,n._zod.def));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push($l(i))}},e(r.value,r)),t);return n}function kL(e,t){const n=new fn({check:"custom",...de(t)});return n._zod.check=e,n}function gk(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??qa,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function mt(e,t,n={path:[],schemaPath:[]}){var d,f;var r;const s=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const a=(f=(d=e._zod).toJSONSchema)==null?void 0:f.call(d);if(a)o.schema=a;else{const h={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,h);else{const x=o.schema,b=t.processors[s.type];if(!b)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);b(e,t,x,h)}const p=e._zod.parent;p&&(o.ref||(o.ref=p),mt(p,t,h),t.seen.get(p).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&Xt(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 xk(e,t){var o,a,c,u;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of e.seen.entries()){const f=(o=e.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const h=r.get(f);if(h&&h!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const s=d=>{var b;const f=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const S=(b=e.external.registry.get(d[0]))==null?void 0:b.id,m=e.external.uri??(g=>g);if(S)return{ref:m(S)};const y=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=y,{defId:y,ref:`${m("__shared")}#/${f}/${y}`}}if(d[1]===n)return{ref:"#"};const p=`#/${f}/`,x=d[1].schema.id??`__schema${e.counter++}`;return{defId:x,ref:p+x}},i=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:h,defId:p}=s(d);f.def={...f.schema},p&&(f.defId=p);const x=f.schema;for(const b in x)delete x[b];x.$ref=h};if(e.cycles==="throw")for(const d of e.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
233
233
 
234
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of e.seen.entries()){const f=d[1];if(t===d[0]){i(d);continue}if(e.external){const p=(c=e.external.registry.get(d[0]))==null?void 0:c.id;if(t!==d[0]&&p){i(d);continue}}if((u=e.metadataRegistry.get(d[0]))==null?void 0:u.id){i(d);continue}if(f.cycle){i(d);continue}if(f.count>1&&e.reused==="ref"){i(d);continue}}}function yk(e,t){var a,c,u,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=f=>{const h=e.seen.get(f);if(h.ref===null)return;const p=h.def??h.schema,x={...p},b=h.ref;if(h.ref=null,b){r(b);const m=e.seen.get(b),y=m.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(y)):Object.assign(p,y),Object.assign(p,x),f._zod.parent===b)for(const v in p)v==="$ref"||v==="allOf"||v in x||delete p[v];if(y.$ref&&m.def)for(const v in p)v==="$ref"||v==="allOf"||v in m.def&&JSON.stringify(p[v])===JSON.stringify(m.def[v])&&delete p[v]}const S=f._zod.parent;if(S&&S!==b){r(S);const m=e.seen.get(S);if(m!=null&&m.schema.$ref&&(p.$ref=m.schema.$ref,m.def))for(const y in p)y==="$ref"||y==="allOf"||y in m.def&&JSON.stringify(p[y])===JSON.stringify(m.def[y])&&delete p[y]}e.override({zodSchema:f,jsonSchema:p,path:h.path??[]})};for(const f of[...e.seen.entries()].reverse())r(f[0]);const s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,(a=e.external)!=null&&a.uri){const f=(c=e.external.registry.get(t))==null?void 0:c.id;if(!f)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(f)}Object.assign(s,n.def??n.schema);const i=(u=e.metadataRegistry.get(t))==null?void 0:u.id;i!==void 0&&s.id===i&&delete s.id;const o=((d=e.external)==null?void 0:d.defs)??{};for(const f of e.seen.entries()){const h=f[1];h.def&&h.defId&&(h.def.id===h.defId&&delete h.def.id,o[h.defId]=h.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?s.$defs=o:s.definitions=o);try{const f=JSON.parse(JSON.stringify(s));return Object.defineProperty(f,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ed(t,"input",e.processors),output:Ed(t,"output",e.processors)}},enumerable:!1,writable:!1}),f}catch{throw new Error("Error converting schema to JSON.")}}function Xt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Xt(r.element,n);if(r.type==="set")return Xt(r.valueType,n);if(r.type==="lazy")return Xt(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")return Xt(r.innerType,n);if(r.type==="intersection")return Xt(r.left,n)||Xt(r.right,n);if(r.type==="record"||r.type==="map")return Xt(r.keyType,n)||Xt(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Xt(r.in,n)||Xt(r.out,n);if(r.type==="object"){for(const s in r.shape)if(Xt(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(Xt(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(Xt(s,n))return!0;return!!(r.rest&&Xt(r.rest,n))}return!1}const NL=(e,t={})=>n=>{const r=gk({...n,processors:t});return mt(e,r),xk(r,e),yk(r,e)},Ed=(e,t,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},o=gk({...s??{},target:i,io:t,processors:n});return mt(e,o),xk(o,e),yk(o,e)},jL={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},EL=(e,t,n,r)=>{const s=n;s.type="string";const{minimum:i,maximum:o,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(s.minLength=i),typeof o=="number"&&(s.maxLength=o),a&&(s.format=jL[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),u&&(s.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},TL=(e,t,n,r)=>{const s=n,{minimum:i,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number";const f=typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY),h=typeof u=="number"&&u<=(o??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";f?p?(s.minimum=d,s.exclusiveMinimum=!0):s.exclusiveMinimum=d:typeof i=="number"&&(s.minimum=i),h?p?(s.maximum=u,s.exclusiveMaximum=!0):s.exclusiveMaximum=u:typeof o=="number"&&(s.maximum=o),typeof c=="number"&&(s.multipleOf=c)},AL=(e,t,n,r)=>{n.type="boolean"},CL=(e,t,n,r)=>{n.not={}},ML=(e,t,n,r)=>{},zL=(e,t,n,r)=>{const s=e._zod.def,i=F_(s.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},DL=(e,t,n,r)=>{const s=e._zod.def,i=[];for(const o of s.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},RL=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},OL=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},$L=(e,t,n,r)=>{const s=n,i=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;typeof o=="number"&&(s.minItems=o),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=mt(i.element,t,{...r,path:[...r.path,"items"]})},LL=(e,t,n,r)=>{var u;const s=n,i=e._zod.def;s.type="object",s.properties={};const o=i.shape;for(const d in o)s.properties[d]=mt(o[d],t,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(d=>{const f=i.shape[d]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(s.required=Array.from(c)),((u=i.catchall)==null?void 0:u._zod.def.type)==="never"?s.additionalProperties=!1:i.catchall?i.catchall&&(s.additionalProperties=mt(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},HL=(e,t,n,r)=>{const s=e._zod.def,i=s.inclusive===!1,o=s.options.map((a,c)=>mt(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=o:n.anyOf=o},BL=(e,t,n,r)=>{const s=e._zod.def,i=mt(s.left,t,{...r,path:[...r.path,"allOf",0]}),o=mt(s.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(o)?o.allOf:[o]];n.allOf=c},UL=(e,t,n,r)=>{const s=n,i=e._zod.def;s.type="object";const o=i.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(i.mode==="loose"&&c&&c.size>0){const d=mt(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});s.patternProperties={};for(const f of c)s.patternProperties[f.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(s.propertyNames=mt(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),s.additionalProperties=mt(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(s.required=d)}},IL=(e,t,n,r)=>{const s=e._zod.def,i=mt(s.innerType,t,r),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=s.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},ZL=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType},YL=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))},qL=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},VL=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType;let o;try{o=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},GL=(e,t,n,r)=>{const s=e._zod.def,i=s.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?s.out:s.in:s.out;mt(o,t,r);const a=t.seen.get(e);a.ref=o},XL=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType,n.readOnly=!0},vk=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType},PL=Q("ZodISODateTime",(e,t)=>{F$.init(e,t),st.init(e,t)});function FL(e){return tL(PL,e)}const QL=Q("ZodISODate",(e,t)=>{Q$.init(e,t),st.init(e,t)});function KL(e){return nL(QL,e)}const WL=Q("ZodISOTime",(e,t)=>{K$.init(e,t),st.init(e,t)});function JL(e){return rL(WL,e)}const e9=Q("ZodISODuration",(e,t)=>{W$.init(e,t),st.init(e,t)});function t9(e){return sL(e9,e)}const n9=(e,t)=>{J_.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>I6(e,n)},flatten:{value:n=>U6(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,nm,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,nm,2)}},isEmpty:{get(){return e.issues.length===0}}})},Gn=Q("ZodError",n9,{Parent:Error}),r9=Qg(Gn),s9=Kg(Gn),i9=mf(Gn),o9=gf(Gn),a9=q6(Gn),l9=V6(Gn),c9=G6(Gn),u9=X6(Gn),d9=P6(Gn),f9=F6(Gn),h9=Q6(Gn),p9=K6(Gn),Qv=new WeakMap;function ac(e,t,n){const r=Object.getPrototypeOf(e);let s=Qv.get(r);if(s||(s=new Set,Qv.set(r,s)),!s.has(t)){s.add(t);for(const i in n){const o=n[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){const a=o.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}const rt=Q("ZodType",(e,t)=>(nt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ed(e,"input"),output:Ed(e,"output")}}),e.toJSONSchema=NL(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>r9(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>i9(e,n,r),e.parseAsync=async(n,r)=>s9(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>o9(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>a9(e,n,r),e.decode=(n,r)=>l9(e,n,r),e.encodeAsync=async(n,r)=>c9(e,n,r),e.decodeAsync=async(n,r)=>u9(e,n,r),e.safeEncode=(n,r)=>d9(e,n,r),e.safeDecode=(n,r)=>f9(e,n,r),e.safeEncodeAsync=async(n,r)=>h9(e,n,r),e.safeDecodeAsync=async(n,r)=>p9(e,n,r),ac(e,"ZodType",{check(...n){const r=this.def;return this.clone(Js(r,{checks:[...r.checks??[],...n.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return ei(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(a7(n,r))},superRefine(n,r){return this.check(l7(n,r))},overwrite(n){return this.check(ma(n))},optional(){return eb(this)},exactOptional(){return P9(this)},nullable(){return tb(this)},nullish(){return eb(tb(this))},nonoptional(n){return e7(this,n)},array(){return Dr(this)},or(n){return lc([this,n])},and(n){return Y9(this,n)},transform(n){return nb(this,G9(n))},default(n){return K9(this,n)},prefault(n){return J9(this,n)},catch(n){return n7(this,n)},pipe(n){return nb(this,n)},readonly(){return i7(this)},describe(n){const r=this.clone();return qa.add(r,{description:n}),r},meta(...n){if(n.length===0)return qa.get(this);const r=this.clone();return qa.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=qa.get(e))==null?void 0:n.description},configurable:!0}),e)),bk=Q("_ZodString",(e,t)=>{Wg.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,s,i)=>EL(e,r,s);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ac(e,"_ZodString",{regex(...r){return this.check(uL(...r))},includes(...r){return this.check(hL(...r))},startsWith(...r){return this.check(pL(...r))},endsWith(...r){return this.check(mL(...r))},min(...r){return this.check(jd(...r))},max(...r){return this.check(pk(...r))},length(...r){return this.check(mk(...r))},nonempty(...r){return this.check(jd(1,...r))},lowercase(r){return this.check(dL(r))},uppercase(r){return this.check(fL(r))},trim(){return this.check(xL())},normalize(...r){return this.check(gL(...r))},toLowerCase(){return this.check(yL())},toUpperCase(){return this.check(vL())},slugify(){return this.check(bL())}})}),m9=Q("ZodString",(e,t)=>{Wg.init(e,t),bk.init(e,t),e.email=n=>e.check(R8(g9,n)),e.url=n=>e.check(B8(x9,n)),e.jwt=n=>e.check(eL(z9,n)),e.emoji=n=>e.check(U8(y9,n)),e.guid=n=>e.check(Gv(Kv,n)),e.uuid=n=>e.check(O8(iu,n)),e.uuidv4=n=>e.check($8(iu,n)),e.uuidv6=n=>e.check(L8(iu,n)),e.uuidv7=n=>e.check(H8(iu,n)),e.nanoid=n=>e.check(I8(v9,n)),e.guid=n=>e.check(Gv(Kv,n)),e.cuid=n=>e.check(Z8(b9,n)),e.cuid2=n=>e.check(Y8(w9,n)),e.ulid=n=>e.check(q8(S9,n)),e.base64=n=>e.check(K8(A9,n)),e.base64url=n=>e.check(W8(C9,n)),e.xid=n=>e.check(V8(_9,n)),e.ksuid=n=>e.check(G8(k9,n)),e.ipv4=n=>e.check(X8(N9,n)),e.ipv6=n=>e.check(P8(j9,n)),e.cidrv4=n=>e.check(F8(E9,n)),e.cidrv6=n=>e.check(Q8(T9,n)),e.e164=n=>e.check(J8(M9,n)),e.datetime=n=>e.check(FL(n)),e.date=n=>e.check(KL(n)),e.time=n=>e.check(JL(n)),e.duration=n=>e.check(t9(n))});function P(e){return D8(m9,e)}const st=Q("ZodStringFormat",(e,t)=>{et.init(e,t),bk.init(e,t)}),g9=Q("ZodEmail",(e,t)=>{U$.init(e,t),st.init(e,t)}),Kv=Q("ZodGUID",(e,t)=>{H$.init(e,t),st.init(e,t)}),iu=Q("ZodUUID",(e,t)=>{B$.init(e,t),st.init(e,t)}),x9=Q("ZodURL",(e,t)=>{I$.init(e,t),st.init(e,t)}),y9=Q("ZodEmoji",(e,t)=>{Z$.init(e,t),st.init(e,t)}),v9=Q("ZodNanoID",(e,t)=>{Y$.init(e,t),st.init(e,t)}),b9=Q("ZodCUID",(e,t)=>{q$.init(e,t),st.init(e,t)}),w9=Q("ZodCUID2",(e,t)=>{V$.init(e,t),st.init(e,t)}),S9=Q("ZodULID",(e,t)=>{G$.init(e,t),st.init(e,t)}),_9=Q("ZodXID",(e,t)=>{X$.init(e,t),st.init(e,t)}),k9=Q("ZodKSUID",(e,t)=>{P$.init(e,t),st.init(e,t)}),N9=Q("ZodIPv4",(e,t)=>{J$.init(e,t),st.init(e,t)}),j9=Q("ZodIPv6",(e,t)=>{e8.init(e,t),st.init(e,t)}),E9=Q("ZodCIDRv4",(e,t)=>{t8.init(e,t),st.init(e,t)}),T9=Q("ZodCIDRv6",(e,t)=>{n8.init(e,t),st.init(e,t)}),A9=Q("ZodBase64",(e,t)=>{r8.init(e,t),st.init(e,t)}),C9=Q("ZodBase64URL",(e,t)=>{i8.init(e,t),st.init(e,t)}),M9=Q("ZodE164",(e,t)=>{o8.init(e,t),st.init(e,t)}),z9=Q("ZodJWT",(e,t)=>{l8.init(e,t),st.init(e,t)}),wk=Q("ZodNumber",(e,t)=>{ck.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,s,i)=>TL(e,r,s),ac(e,"ZodNumber",{gt(r,s){return this.check(Pv(r,s))},gte(r,s){return this.check($h(r,s))},min(r,s){return this.check($h(r,s))},lt(r,s){return this.check(Xv(r,s))},lte(r,s){return this.check(Oh(r,s))},max(r,s){return this.check(Oh(r,s))},int(r){return this.check(Wv(r))},safe(r){return this.check(Wv(r))},positive(r){return this.check(Pv(0,r))},nonnegative(r){return this.check($h(0,r))},negative(r){return this.check(Xv(0,r))},nonpositive(r){return this.check(Oh(0,r))},multipleOf(r,s){return this.check(Fv(r,s))},step(r,s){return this.check(Fv(r,s))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function xe(e){return iL(wk,e)}const D9=Q("ZodNumberFormat",(e,t)=>{c8.init(e,t),wk.init(e,t)});function Wv(e){return oL(D9,e)}const R9=Q("ZodBoolean",(e,t)=>{u8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>AL(e,n,r)});function Jg(e){return aL(R9,e)}const O9=Q("ZodUnknown",(e,t)=>{d8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>ML()});function zn(){return lL(O9)}const $9=Q("ZodNever",(e,t)=>{f8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>CL(e,n,r)});function L9(e){return cL($9,e)}const H9=Q("ZodArray",(e,t)=>{h8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>$L(e,n,r,s),e.element=t.element,ac(e,"ZodArray",{min(n,r){return this.check(jd(n,r))},nonempty(n){return this.check(jd(1,n))},max(n,r){return this.check(pk(n,r))},length(n,r){return this.check(mk(n,r))},unwrap(){return this.element}})});function Dr(e,t){return wL(H9,e,t)}const B9=Q("ZodObject",(e,t)=>{m8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>LL(e,n,r,s),$e(e,"shape",()=>t.shape),ac(e,"ZodObject",{keyof(){return De(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:zn()})},loose(){return this.clone({...this._zod.def,catchall:zn()})},strict(){return this.clone({...this._zod.def,catchall:L9()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return R6(this,n)},safeExtend(n){return O6(this,n)},merge(n){return $6(this,n)},pick(n){return z6(this,n)},omit(n){return D6(this,n)},partial(...n){return L6(_k,this,n[0])},required(...n){return H6(kk,this,n[0])}})});function se(e,t){const n={type:"object",shape:e??{},...de(t)};return new B9(n)}const Sk=Q("ZodUnion",(e,t)=>{fk.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>HL(e,n,r,s),e.options=t.options});function lc(e,t){return new Sk({type:"union",options:e,...de(t)})}const U9=Q("ZodDiscriminatedUnion",(e,t)=>{Sk.init(e,t),g8.init(e,t)});function I9(e,t,n){return new U9({type:"union",options:t,discriminator:e,...de(n)})}const Z9=Q("ZodIntersection",(e,t)=>{x8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>BL(e,n,r,s)});function Y9(e,t){return new Z9({type:"intersection",left:e,right:t})}const Jv=Q("ZodRecord",(e,t)=>{y8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>UL(e,n,r,s),e.keyType=t.keyType,e.valueType=t.valueType});function ga(e,t,n){return!t||!t._zod?new Jv({type:"record",keyType:P(),valueType:e,...de(t)}):new Jv({type:"record",keyType:e,valueType:t,...de(n)})}const sm=Q("ZodEnum",(e,t)=>{v8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,s,i)=>zL(e,r,s),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,s)=>{const i={};for(const o of r)if(n.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new sm({...t,checks:[],...de(s),entries:i})},e.exclude=(r,s)=>{const i={...t.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new sm({...t,checks:[],...de(s),entries:i})}});function De(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new sm({type:"enum",entries:n,...de(t)})}const q9=Q("ZodLiteral",(e,t)=>{b8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>DL(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Be(e,t){return new q9({type:"literal",values:Array.isArray(e)?e:[e],...de(t)})}const V9=Q("ZodTransform",(e,t)=>{w8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>OL(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new P_(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push($l(i,n.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push($l(o))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=s,n.fallback=!0,n)}});function G9(e){return new V9({type:"transform",transform:e})}const _k=Q("ZodOptional",(e,t)=>{hk.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>vk(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function eb(e){return new _k({type:"optional",innerType:e})}const X9=Q("ZodExactOptional",(e,t)=>{S8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>vk(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function P9(e){return new X9({type:"optional",innerType:e})}const F9=Q("ZodNullable",(e,t)=>{_8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>IL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function tb(e){return new F9({type:"nullable",innerType:e})}const Q9=Q("ZodDefault",(e,t)=>{k8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>YL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function K9(e,t){return new Q9({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():K_(t)}})}const W9=Q("ZodPrefault",(e,t)=>{N8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>qL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function J9(e,t){return new W9({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():K_(t)}})}const kk=Q("ZodNonOptional",(e,t)=>{j8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>ZL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function e7(e,t){return new kk({type:"nonoptional",innerType:e,...de(t)})}const t7=Q("ZodCatch",(e,t)=>{E8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>VL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function n7(e,t){return new t7({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const r7=Q("ZodPipe",(e,t)=>{T8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>GL(e,n,r,s),e.in=t.in,e.out=t.out});function nb(e,t){return new r7({type:"pipe",in:e,out:t})}const s7=Q("ZodReadonly",(e,t)=>{A8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>XL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function i7(e){return new s7({type:"readonly",innerType:e})}const o7=Q("ZodCustom",(e,t)=>{C8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>RL(e,n)});function a7(e,t={}){return SL(o7,e,t)}function l7(e,t){return _L(e,t)}const c7=se({type:Be("user-prompt"),id:P(),text:P(),cwd:P(),timestamp:xe()}),u7=se({type:Be("assistant-delta"),id:P(),text:P(),timestamp:xe()}),d7=se({type:Be("assistant-stop"),id:P(),timestamp:xe()}),f7=se({type:Be("tool-call"),id:P(),toolCallId:P(),name:P(),input:ga(P(),zn()),timestamp:xe()}),h7=se({type:Be("tool-result"),id:P(),toolCallId:P(),output:zn(),error:P().optional(),timestamp:xe()}),p7=se({type:Be("approval-request"),id:P(),toolCallId:P(),name:P(),input:ga(P(),zn()),decision:De(["allow","deny","ask"]).optional(),timestamp:xe()}),m7=se({type:Be("approval-decision"),id:P(),toolCallId:P(),decision:De(["allow","deny"]),by:P().optional(),timestamp:xe()}),g7=se({type:Be("usage"),id:P(),inputTokens:xe(),outputTokens:xe(),cacheReadTokens:xe().optional(),cacheWriteTokens:xe().optional(),timestamp:xe()}),x7=se({type:Be("error"),id:P(),message:P(),code:P().optional(),timestamp:xe()}),y7=se({type:Be("session-start"),id:P(),model:P(),provider:P(),cwd:P(),timestamp:xe()}),v7=se({type:Be("session-stop"),id:P(),reason:P(),timestamp:xe()}),b7=se({type:Be("hook"),id:P(),phase:P(),name:P(),result:P().optional(),error:P().optional(),timestamp:xe()}),w7=se({type:Be("status"),id:P(),message:P(),spinner:Jg().optional(),timestamp:xe()}),S7=se({type:Be("session-resumed"),id:P(),turnsRecovered:xe(),timestamp:xe()}),_7=se({type:Be("context-warning"),id:P(),message:P(),timestamp:xe()}),k7=se({type:Be("compaction"),id:P(),summary:P(),summarizedMessageCount:xe(),tokensBefore:xe(),tokensAfter:xe(),timestamp:xe()}),N7=se({type:Be("context-report"),id:P(),model:P(),windowTokens:xe(),usedTokens:xe(),reservedOutput:xe(),breakdown:Dr(se({label:P(),tokens:xe()})),timestamp:xe()}),j7=se({type:Be("cron-task-fired"),id:P(),taskId:P(),taskType:De(["notify","auto"]),message:P(),timestamp:xe()}),E7=se({type:Be("heartbeat-brief"),id:P(),scheduleType:De(["intraday","daily","weekly","monthly","dreaming"]),formattedText:P(),toolCalls:xe(),errors:Dr(P()),timestamp:xe()}),T7=se({type:Be("channel-updated"),id:P(),channelId:P(),channelType:De(["cli","telegram"]),displayName:P(),sessionId:P(),timestamp:xe()}),A7=se({type:Be("mcp-status"),id:P(),serverId:P(),connected:Jg(),tools:Dr(P()),timestamp:xe()}),C7=se({type:Be("daemon-ready"),id:P(),version:P(),timestamp:xe()}),M7=se({type:Be("wiki-op"),id:P(),op:De(["ingest","query","lint","edit"]),pages:Dr(P()),timestamp:xe()});I9("type",[c7,u7,d7,f7,h7,p7,m7,g7,x7,y7,v7,b7,w7,S7,_7,k7,N7,j7,E7,T7,A7,C7,M7]);const z7=se({jsonrpc:Be("2.0"),id:lc([xe(),P()]),method:P(),params:ga(P(),zn()).optional()}),D7=se({jsonrpc:Be("2.0"),method:P(),params:ga(P(),zn()).optional()}),R7=se({jsonrpc:Be("2.0"),id:lc([xe(),P()]),result:zn()}),O7=se({jsonrpc:Be("2.0"),id:lc([xe(),P()]),error:se({code:xe(),message:P(),data:zn().optional()})});lc([z7,D7,R7,O7]);se({});se({id:P()});se({id:P(),text:P()});se({id:P()});se({id:P().optional()});se({});se({paneIds:Dr(P()),text:P()});se({query:P()});se({slug:P()});se({source:P()});se({});se({});se({sessionId:P().optional()});se({toolCallId:P(),decision:De(["allow","deny"])});se({});se({});se({key:P()});se({key:P(),value:zn()});se({});se({});se({type:De(["reminder","heartbeat","task"]).optional(),status:De(["pending","fired","executing","completed","failed","cancelled"]).optional()});se({type:De(["reminder","task"]),message:P(),scheduledAt:xe(),schedule:se({type:De(["intraday","daily","weekly","monthly","dreaming"]),value:P()}).optional()});se({id:P()});se({});se({scheduleType:De(["intraday","daily","weekly","monthly","dreaming"]).optional()});se({});se({});se({channelId:P()});se({});se({});se({provider:P(),apiKey:P(),model:P(),soulName:P(),soulVibe:P(),userName:P(),userTimezone:P(),userLanguages:P()});se({sessionId:P(),prompt:P(),provider:De(["anthropic","openai","google","ollama","openrouter"]).optional(),mode:De(["plan","edit","auto","yolo"]).optional(),effort:De(["low","medium","high","max","auto"]).optional(),model:P().optional(),tools:Dr(P()).optional()});se({sessionId:P().optional(),status:De(["running","completed","error","cancelled"]).optional()});se({agentId:P()});se({agentId:P()});se({agentId:P(),message:P()});se({instruction:P(),scheduled_at:P(),provider:P().optional(),model:P().optional(),effort:De(["low","medium","high","max","auto"]).optional()});se({status:De(["backlog","todo","in_progress","done","canceled","pending","executing","completed","failed"]).optional(),mode:De(["human","agent","notify"]).optional(),scope:De(["personal","project"]).optional(),priority:De(["low","medium","high","critical"]).optional()});se({title:P(),description:P().default(""),mode:De(["human","agent","notify"]).default("human"),scope:De(["personal","project"]).default("personal"),priority:De(["low","medium","high","critical"]).default("medium"),tags:Dr(P()).default([]),status:De(["backlog","todo","in_progress","done","canceled","pending","executing","completed","failed"]).optional(),scheduled_at:xe().optional()});se({id:P(),status:De(["backlog","todo","in_progress","done","canceled","pending","executing","completed","failed"]).optional(),priority:De(["low","medium","high","critical"]).optional(),title:P().optional(),description:P().optional(),tags:Dr(P()).optional(),mode:De(["human","agent","notify"]).optional(),scope:De(["personal","project"]).optional(),scheduled_at:xe().optional()});se({id:P()});const $7=[{name:"status",description:"Show version, model, and account info",usage:"/status",category:"General",handler:"daemon"},{name:"help",description:"Show all available commands",usage:"/help",category:"General",handler:"daemon"},{name:"system",description:"Show OS, platform, Node version, and PathGuard status",usage:"/system",category:"General",handler:"daemon"},{name:"init",description:"Run the setup wizard",usage:"/init",category:"General",handler:"client"},{name:"exit",description:"Exit curie-agent",usage:"/exit",category:"General",handler:"client",aliases:["quit"]},{name:"provider",description:"Switch AI provider",usage:"/provider <anthropic|openai|google|local|ollama|openrouter>",category:"Model & Provider",handler:"daemon"},{name:"model",description:"Switch AI model, set pricing or context window",usage:"/model <model|pricing in;out|window tokens>",category:"Model & Provider",handler:"daemon"},{name:"effort",description:"Set reasoning effort level",usage:"/effort <low|medium|high|max|auto>",category:"Model & Provider",handler:"daemon"},{name:"mode",description:"Set approval mode",usage:"/mode <plan|edit|auto|yolo>",category:"Model & Provider",handler:"daemon"},{name:"theme",description:"Change color theme",usage:"/theme <name>",category:"Display",handler:"client"},{name:"debug",description:"Toggle debug logging",usage:"/debug [on|off]",category:"Display",handler:"client"},{name:"statusline",description:"Toggle status line display",usage:"/statusline [on|off]",category:"Display",handler:"client"},{name:"memory",description:"View memory file sizes or capture a memory",usage:"/memory [status|add <text>]",category:"Knowledge",handler:"daemon"},{name:"todo",description:"Manage tasks in tasks.json",usage:"/todo <list|add|complete|remove>",category:"Knowledge",handler:"daemon"},{name:"stats",description:"Daily usage, sessions, streaks",usage:"/stats",category:"Knowledge",handler:"client"},{name:"context",description:"Context window usage breakdown, compaction, auto-compaction settings",usage:"/context [messages|compact|auto [on|off|threshold N|warn N|forced N|pricing on/off]]",category:"Knowledge",handler:"daemon"},{name:"wiki",description:"Open the wiki tab or run a wiki operation",usage:"/wiki [list|search <query>|lint|status]",category:"Knowledge",handler:"client"},{name:"remind",description:"Create a reminder",usage:"/remind <message at time>",category:"Automation",handler:"daemon"},{name:"cron",description:"Manage reminders",usage:"/cron <list|delete <id>|clear>",category:"Automation",handler:"daemon"},{name:"task",description:"Schedule an agent task",usage:"/task <create|list|delete>",category:"Automation",handler:"daemon"},{name:"heartbeat",description:"Manage heartbeat cycle",usage:"/heartbeat <status|enable|disable|intraday|daily|weekly|monthly|dreaming|now>",category:"Automation",handler:"daemon"},{name:"agent",description:"Launch external AI agent",usage:"/agent <prompt>",category:"Tools",handler:"daemon"},{name:"tools",description:"View/set tool call limits per turn",usage:"/tools [tools_per_call [websearch_per_call]]",category:"Tools",handler:"daemon"},{name:"websearch",description:"View/set web search+fetch limit per turn",usage:"/websearch [count]",category:"Tools",handler:"daemon"},{name:"mcp",description:"Manage MCP server connections",usage:"/mcp <list|reload>",category:"Tools",handler:"daemon"},{name:"skill",description:"List or show available skills",usage:"/skill [name]",category:"Tools",handler:"daemon"},{name:"channels",description:"Manage Telegram channel config",usage:"/channels <list|switch <id>|set-bot-token <t>|set-user-id <id>|set-chat-id <id>|disconnect>",category:"Communication",handler:"client"},{name:"cd",description:"Change working directory with safety checks",usage:"/cd <path>",category:"Safety",handler:"daemon"},{name:"snapshots",description:"List recent git snapshots for recovery",usage:"/snapshots",category:"Safety",handler:"daemon"},{name:"revert",description:"Revert to a git snapshot (index, default: most recent)",usage:"/revert [index]",category:"Safety",handler:"daemon"}],L7=se({type:Be("object"),properties:ga(P(),zn()),required:Dr(P()).optional(),additionalProperties:Jg().optional()});se({name:P(),description:P(),inputSchema:L7});se({id:P(),name:P(),input:ga(P(),zn())});se({id:P(),output:zn(),error:P().optional()});const H7=new Set(["wiki"]),rb=$7.filter(e=>e.handler==="daemon"||H7.has(e.name)).map(e=>[e.usage||`/${e.name}`,e.description]);function B7({open:e,onClose:t,onPick:n}){const[r,s]=w.useState(""),[i,o]=w.useState(0),a=w.useRef(null),c=r?rb.filter(([f,h])=>f.includes(r.toLowerCase())||h.toLowerCase().includes(r.toLowerCase())):rb,u=w.useCallback(f=>{t(),n(f)},[t,n]);w.useEffect(()=>{e&&(s(""),o(0),setTimeout(()=>{var f;return(f=a.current)==null?void 0:f.focus()},50))},[e]);const d=w.useCallback(f=>{if(f.key==="Escape"){t();return}f.key==="ArrowDown"&&(o(h=>Math.min(h+1,c.length-1)),f.preventDefault()),f.key==="ArrowUp"&&(o(h=>Math.max(h-1,0)),f.preventDefault()),f.key==="Enter"&&c[i]&&u(c[i][0])},[c,i,t,u]);return e?l.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[120px]",style:{background:"rgba(10, 8, 5, 0.85)",backdropFilter:"blur(8px)"},onClick:t,children:l.jsxs("div",{className:"w-[560px] rounded-xl overflow-hidden animate-scaleIn",style:{background:"linear-gradient(135deg, var(--s2) 0%, var(--s1) 100%)",border:"1px solid var(--b2)",boxShadow:"0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.03)"},onClick:f=>f.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",style:{borderBottom:"1px solid var(--b1)"},children:[l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"var(--gold)",strokeWidth:"1.5",className:"shrink-0",style:{opacity:.7},children:[l.jsx("circle",{cx:"11",cy:"11",r:"8"}),l.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),l.jsx("input",{ref:a,className:"flex-1 bg-transparent border-0 outline-none font-sans text-sm",style:{color:"var(--cream)"},placeholder:"Search commands...",value:r,onChange:f=>{s(f.target.value),o(0)},onKeyDown:d})]}),l.jsx("div",{className:"gold-divider"}),l.jsxs("div",{className:"max-h-[340px] overflow-y-auto py-1 scrollbar-thin",children:[c.map(([f,h],p)=>l.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 mx-1",style:{background:p===i?"var(--s3)":"transparent",borderLeft:p===i?"2px solid var(--gold)":"2px solid transparent"},onClick:()=>u(f),children:[l.jsx("span",{className:"font-mono text-[12.5px] min-w-[190px]",style:{color:p===i?"var(--gold)":"var(--text)"},children:f}),l.jsx("span",{className:"text-xs text-muted truncate",children:h})]},f)),c.length===0&&l.jsx("div",{className:"px-3 py-6 text-center text-muted text-sm",children:"No commands found"})]})]})}):null}const Wi={anthropic:{label:"Anthropic",defaultModel:"claude-sonnet-4-6",requiresKey:!0},openai:{label:"OpenAI",defaultModel:"gpt-4o",requiresKey:!0},local:{label:"Local (OpenAI-compatible)",defaultModel:"custom",requiresKey:!1},openrouter:{label:"OpenRouter",defaultModel:"anthropic/claude-sonnet-4-6",requiresKey:!0},ollama:{label:"Ollama (Local)",defaultModel:"custom",requiresKey:!1}};function U7({rpc:e,onComplete:t,className:n}){const[r,s]=w.useState("provider"),[i,o]=w.useState(null),[a,c]=w.useState(""),[u,d]=w.useState(""),[f,h]=w.useState(""),[p,x]=w.useState(""),[b,S]=w.useState(""),[m,y]=w.useState(""),[g,v]=w.useState(""),[N,k]=w.useState(!1),[T,z]=w.useState(null),A=w.useCallback(()=>{switch(z(null),r){case"provider":{if(!i)return;const _=Wi[i];d(_.defaultModel),s(_.requiresKey?"api_key":"model");break}case"api_key":s("model");break;case"model":s("soul_name");break;case"soul_name":if(!f.trim())return;s("soul_vibe");break;case"soul_vibe":s("user_name");break;case"user_name":if(!b.trim())return;s("user_tz");break;case"user_tz":s("user_lang");break;case"user_lang":s("agents");break;case"agents":s("memory");break;case"memory":s("tools");break;case"tools":s("confirm");break}},[r,i,f,b]),L=w.useCallback(async()=>{if(!(!e||!i)){k(!0),z(null);try{await e.identitySetup({provider:i,apiKey:a,model:u,soulName:f.trim()||"Curie",soulVibe:p.trim()||"AI coding assistant — sharp, resourceful, gets things done",userName:b.trim()||"User",userTimezone:m.trim()||"UTC",userLanguages:g.trim()||"TypeScript, Python"}),t()}catch(_){z(_ instanceof Error?_.message:"Setup failed")}finally{k(!1)}}},[e,i,a,u,f,p,b,m,g,t]),R=()=>{switch(r){case"provider":return"Choose your provider";case"api_key":return"API key";case"model":return"Select a model";case"soul_name":return"Name your assistant";case"soul_vibe":return"Define the vibe";case"user_name":return"Your name";case"user_tz":return"Timezone";case"user_lang":return"Programming languages";case"agents":return"Workspace configuration";case"memory":return"Memory";case"tools":return"Tools";case"confirm":return"Review & create"}},H=()=>(["provider","api_key","model","soul_name","soul_vibe","user_name","user_tz","user_lang","agents","memory","tools","confirm"].indexOf(r)+1)/12,Y=()=>{switch(r){case"provider":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted mb-4",children:"Which LLM provider do you want to use for your AI assistant?"}),l.jsx("div",{className:"grid grid-cols-1 gap-2",children:Object.entries(Wi).map(([_,C])=>l.jsxs("button",{type:"button",onClick:()=>o(_),className:`flex items-center gap-3 px-4 py-3 rounded-xl border text-left transition-all duration-100 ${i===_?"border-blue-500 bg-blue-500/10 text-text":"border-b2 bg-s2 text-text hover:border-b3 hover:bg-s2/80"}`,children:[l.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center shrink-0 ${i===_?"border-blue-500":"border-b3"}`,children:i===_&&l.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500"})}),l.jsxs("div",{children:[l.jsx("div",{className:"text-xs font-medium text-text",children:C.label}),l.jsxs("div",{className:"text-[10.5px] text-muted",children:["Model: ",C.defaultModel]})]})]},_))})]});case"api_key":{const _=Wi[i];return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("p",{className:"text-xs text-muted",children:["Enter your ",_.label," API key:"]}),l.jsx("input",{type:"password",value:a,onChange:C=>c(C.target.value),placeholder:"sk-...",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text font-mono placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0}),l.jsx("p",{className:"text-[10px] text-muted",children:"Saved to ~/.curie-settings.json"})]})}case"model":{const _=Wi[i];return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("p",{className:"text-xs text-muted",children:["Suggested model: ",l.jsx("code",{className:"text-text font-mono",children:_.defaultModel})]}),l.jsx("input",{type:"text",value:u,onChange:C=>d(C.target.value),placeholder:"Enter model name or accept the default",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text font-mono placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]})}case"soul_name":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"What should your AI assistant's name be?"}),l.jsx("input",{type:"text",value:f,onChange:_=>h(_.target.value),placeholder:"Curie",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]});case"soul_vibe":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"Describe your assistant's vibe/personality (1 sentence)."}),l.jsx("input",{type:"text",value:p,onChange:_=>x(_.target.value),placeholder:"AI coding assistant — sharp, resourceful, gets things done",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]});case"user_name":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"What is your name?"}),l.jsx("input",{type:"text",value:b,onChange:_=>S(_.target.value),placeholder:"Paweł",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]});case"user_tz":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"Your timezone?"}),l.jsx("input",{type:"text",value:m,onChange:_=>y(_.target.value),placeholder:"Europe/Warsaw",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text font-mono placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]});case"user_lang":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"Your primary programming languages?"}),l.jsx("input",{type:"text",value:g,onChange:_=>v(_.target.value),placeholder:"TypeScript, Python",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]});case"agents":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"Next: I'll create your workspace configuration files."}),l.jsxs("div",{className:"p-3 bg-s2 border border-b1 rounded-xl text-[10.5px] text-text leading-relaxed",children:[l.jsx("p",{className:"font-medium mb-1",children:"AGENTS.md will include:"}),l.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-muted",children:[l.jsx("li",{children:"Session startup instructions"}),l.jsx("li",{children:"Memory system (daily notes + long-term)"}),l.jsx("li",{children:"Coding agent capabilities"}),l.jsx("li",{children:"Red lines and safety boundaries"}),l.jsx("li",{children:"Heartbeat configuration"})]})]})]});case"memory":return l.jsx("div",{className:"space-y-3",children:l.jsx("div",{className:"p-3 bg-s2 border border-b1 rounded-xl text-xs text-text leading-relaxed",children:l.jsx("p",{children:"Auto-creating MEMORY.md with initialization entry..."})})});case"tools":return l.jsx("div",{className:"space-y-3",children:l.jsx("div",{className:"p-3 bg-s2 border border-b1 rounded-xl text-xs text-text leading-relaxed",children:l.jsx("p",{children:"Auto-creating TOOLS.md and HEARTBEAT.md..."})})});case"confirm":return l.jsxs("div",{className:"space-y-4",children:[l.jsx("p",{className:"text-xs text-muted",children:"Review your configuration before creating files:"}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_s,{label:"Provider",value:Wi[i].label}),l.jsx(_s,{label:"Model",value:u}),l.jsx(_s,{label:"API Key",value:a?"[set]":"(not set)"}),l.jsx(_s,{label:"Assistant Name",value:f.trim()||"Curie"}),l.jsx(_s,{label:"Vibe",value:p.trim()||"AI coding assistant"}),l.jsx(_s,{label:"Your Name",value:b.trim()||"User"}),l.jsx(_s,{label:"Timezone",value:m.trim()||"UTC"}),l.jsx(_s,{label:"Languages",value:g.trim()||"TypeScript, Python"})]}),l.jsxs("div",{className:"p-3 bg-s2 border border-b1 rounded-xl text-[10.5px] text-muted leading-relaxed",children:["Identity files to be created:",l.jsxs("ul",{className:"list-disc list-inside mt-1",children:[l.jsx("li",{children:"~/.curie-agent/SOUL.md"}),l.jsx("li",{children:"~/.curie-agent/USER.md"}),l.jsx("li",{children:"~/.curie-agent/AGENTS.md"}),l.jsx("li",{children:"~/.curie-agent/MEMORY.md"}),l.jsx("li",{children:"~/.curie-agent/TOOLS.md"}),l.jsx("li",{children:"~/.curie-agent/HEARTBEAT.md"})]})]})]})}};return l.jsx("div",{className:`flex-1 overflow-y-auto p-7 scrollbar-thin flex flex-col ${n||""}`,children:l.jsxs("div",{className:"max-w-lg mx-auto w-full",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h2",{className:"text-base font-semibold text-fg tracking-tight mb-1",children:"Setup Wizard"}),l.jsx("p",{className:"text-[11px] text-muted",children:"Configure your AI assistant — takes about 2 minutes"})]}),l.jsx("div",{className:"mb-5",children:l.jsx("div",{className:"h-1 bg-b2 rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-blue-500 rounded-full transition-all duration-300",style:{width:`${H()*100}%`}})})}),l.jsx("h3",{className:"text-sm font-medium text-text mb-4",children:R()}),l.jsx("div",{className:"mb-6",children:Y()}),T&&l.jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded-xl text-red-400 text-xs flex items-start gap-2.5 mb-4",children:[l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"shrink-0 mt-0.5",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),l.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),l.jsx("span",{children:T})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r!=="provider"&&r!=="confirm"?l.jsxs("button",{type:"button",onClick:()=>{switch(z(null),r){case"api_key":s("provider");break;case"model":s(Wi[i].requiresKey?"api_key":"provider");break;case"soul_name":s("provider");break;case"soul_vibe":s("soul_name");break;case"user_name":s("soul_vibe");break;case"user_tz":s("user_name");break;case"user_lang":s("user_tz");break;case"agents":s("user_lang");break;case"memory":s("agents");break;case"tools":s("memory");break}},className:"flex items-center gap-1 bg-transparent border border-b2 rounded px-3 py-2 text-muted text-xs hover:border-b3 hover:text-fg transition-colors duration-100",children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:l.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back"]}):l.jsx("div",{}),r==="confirm"?l.jsx("button",{type:"button",onClick:L,disabled:N,className:"flex items-center gap-2 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-500 hover:to-indigo-500 text-white font-semibold text-xs px-5 py-2 rounded-xl shadow-lg shadow-blue-500/10 disabled:opacity-50 disabled:pointer-events-none active:scale-[0.98] transition-all duration-150",children:N?l.jsxs(l.Fragment,{children:[l.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 text-white",fill:"none",viewBox:"0 0 24 24",children:[l.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Creating..."]}):"Create Setup"}):l.jsxs("button",{type:"button",onClick:A,disabled:r==="provider"&&!i||r==="soul_name"&&!f.trim()||r==="user_name"&&!b.trim(),className:"flex items-center gap-2 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-500 hover:to-indigo-500 text-white font-semibold text-xs px-5 py-2 rounded-xl shadow-lg shadow-blue-500/10 disabled:opacity-50 disabled:pointer-events-none active:scale-[0.98] transition-all duration-150",children:["Next",l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[l.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),l.jsx("polyline",{points:"12 5 19 12 12 19"})]})]})]})]})})}function _s({label:e,value:t}){return l.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-b1/50",children:[l.jsx("span",{className:"text-[10.5px] text-muted",children:e}),l.jsx("span",{className:"text-[10.5px] text-text font-mono",children:t})]})}function I7({onReload:e}){const[t,n]=w.useState(!1);w.useEffect(()=>{const s=()=>n(!0),i=()=>{n(!1),e==null||e()};return window.addEventListener("pwa-update-available",s),window.addEventListener("pwa-controller-updated",i),()=>{window.removeEventListener("pwa-update-available",s),window.removeEventListener("pwa-controller-updated",i)}},[e]);const r=()=>{n(!1),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(s=>{s.waiting&&s.waiting.postMessage("SKIP_WAITING")}),window._pendingUpdateWorker&&window._pendingUpdateWorker.postMessage("SKIP_WAITING")};return t?l.jsxs("div",{className:"bg-blue-500/10 border-b border-blue-500/20 text-blue-400 px-4 py-2 text-center text-xs font-semibold flex items-center justify-center gap-2 select-none shrink-0 z-50 animate-fadeIn",children:[l.jsxs("svg",{className:"animate-bounce shrink-0",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),l.jsx("polyline",{points:"17 8 12 3 7 8"}),l.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),"Update available",l.jsx("button",{onClick:r,className:"bg-blue-500/20 border border-blue-500/40 text-blue-400 px-2 py-0.5 rounded-[4px] text-[11px] font-bold cursor-pointer hover:bg-blue-500/30 transition-all duration-100",children:"Update"})]}):null}const Z7="0.2.4";function Y7({intervalMs:e=3*60*1e3,onNewVersion:t}){const[n,r]=w.useState(!1);return w.useEffect(()=>{async function s(){var o;try{const c=await(await fetch("/health?token="+encodeURIComponent(((o=document.cookie.match(/curie_token=([^;]*)/))==null?void 0:o[1])??""),{cache:"no-store"})).json();c.version&&c.version!==Z7&&!n&&(r(!0),t==null||t(c.version),window.dispatchEvent(new CustomEvent("pwa-version-update")))}catch{}}s();const i=setInterval(s,e);return()=>clearInterval(i)},[e,n,t]),null}function q7(){const{rpc:e,ws:t}=fr(),[n,r]=w.useState([]),s=w.useCallback(()=>{e&&e.sessionList().then(i=>{Array.isArray(i)&&r(i)}).catch(()=>{})},[e]);return w.useEffect(()=>{s()},[s]),w.useEffect(()=>{if(!t)return;const i=["user-prompt","assistant-stop","error","session-start","session-resumed"],o=[];for(const a of i)o.push(t.on(a,s));return()=>{for(const a of o)a()}},[t,s]),{sessions:n,refetch:s}}function V7(e){const{rpc:t,ws:n}=fr(),[r,s]=w.useState(null),[i,o]=w.useState([]),[a,c]=w.useState(!1),[u,d]=w.useState(null);w.useEffect(()=>{if(!t||!e){s(null),o([]),c(!1);return}c(!0),t.sessionGet(e).then(h=>{h!=null&&h.info&&s(h.info),h!=null&&h.events&&o(h.events)}).catch(()=>{}).finally(()=>c(!1))},[t,e]),w.useEffect(()=>{if(!n||!e)return;const h=b=>{if(b.type!=="heartbeat-brief"&&b.type!=="cron-task-fired"){const S=b.sessionId||b.id;if(S&&S!==e)return}o(S=>S.slice(-10).some(y=>y.timestamp===b.timestamp&&y.type===b.type&&JSON.stringify(y)===JSON.stringify(b))?S:[...S,b])},p=[],x=["user-prompt","assistant-delta","assistant-stop","tool-call","tool-result","error","status","usage","thinking-delta","heartbeat-brief","approval-request","approval-decision","context-warning","cron-task-fired","compaction"];for(const b of x)p.push(n.on(b,h));return p.push(n.on("context-report",b=>{const S=b.sessionId;S&&S!==e||d({model:String(b.model??""),windowTokens:Number(b.windowTokens??0),usedTokens:Number(b.usedTokens??0),reservedOutput:Number(b.reservedOutput??0),breakdown:b.breakdown??[]})})),()=>{for(const b of p)b()}},[n,e]);const f=w.useCallback(h=>{o(p=>[...p,h])},[]);return{info:r,events:i,loading:a,addLiveEvent:f,contextReport:u}}function G7({onAuthorize:e}){const[t,n]=w.useState(""),[r,s]=w.useState(!1),[i,o]=w.useState(null),a=async c=>{if(c.preventDefault(),!!t.trim()){s(!0),o(null);try{(await fetch("/health",{headers:{Authorization:`Bearer ${t.trim()}`}})).ok?e(t.trim()):o("Invalid Access Token. Please verify and try again.")}catch{o("Cannot connect to Curie Daemon. Make sure the daemon is running.")}finally{s(!1)}}};return l.jsxs("div",{className:"flex min-h-screen w-screen items-center justify-center p-4 font-sans select-none relative overflow-hidden",style:{background:"#0e0b08",color:"var(--cream, #f5e6d0)"},children:[l.jsx("div",{className:"absolute top-[-20%] left-[-20%] w-[60%] h-[60%] rounded-full opacity-30 blur-[120px] pointer-events-none",style:{background:"#2d1f0e"}}),l.jsx("div",{className:"absolute bottom-[-20%] right-[-20%] w-[60%] h-[60%] rounded-full opacity-25 blur-[120px] pointer-events-none",style:{background:"#1e1408"}}),l.jsx("div",{className:"absolute top-[40%] left-[50%] w-[40%] h-[40%] rounded-full opacity-15 blur-[100px] pointer-events-none",style:{background:"#d4a54a",transform:"translate(-50%, -50%)"}}),l.jsxs("div",{className:"w-full max-w-[440px] rounded-2xl shadow-2xl p-7 flex flex-col items-center animate-scaleIn relative z-10",style:{background:"linear-gradient(135deg, rgba(34, 28, 22, 0.95), rgba(20, 16, 12, 0.98))",backdropFilter:"blur(24px)",border:"1px solid rgba(86, 72, 58, 0.5)",boxShadow:"0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(245,230,208,0.04)"},children:[l.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px] rounded-t-2xl",style:{background:"linear-gradient(90deg, transparent, #d4a54a, transparent)"}}),l.jsxs("div",{className:"flex flex-col items-center gap-3 mb-6 mt-2",children:[l.jsxs("div",{className:"relative group",children:[l.jsx("div",{className:"absolute inset-0 rounded-xl blur-md group-hover:blur-lg transition-all duration-300 animate-gold-pulse",style:{background:"rgba(212, 165, 74, 0.2)"}}),l.jsx("img",{src:"/icons/logo-512.png",alt:"Curie Logo",className:"w-14 h-14 object-contain rounded-xl relative z-10 transform group-hover:scale-105 transition-transform duration-300",style:{border:"1px solid rgba(86, 72, 58, 0.6)",boxShadow:"0 4px 16px rgba(0,0,0,0.4)"}})]}),l.jsxs("div",{className:"text-center mt-1",children:[l.jsx("span",{className:"text-xl font-display font-bold gold-shimmer block",children:"curie-agent"}),l.jsx("span",{className:"text-[10px] font-mono block mt-0.5",style:{color:"#d4a54a",opacity:.6},children:"v0.2.4"})]})]}),l.jsxs("div",{className:"text-center mb-6",children:[l.jsx("h2",{className:"text-sm font-semibold mb-2",style:{color:"#f5e6d0"},children:"Authorize this device"}),l.jsx("p",{className:"text-[12.5px] leading-relaxed px-2",style:{color:"#8b7355"},children:"Curie requires a secure daemon connection. Enter your access token below to authorize this device and start planning."})]}),l.jsxs("form",{onSubmit:a,className:"w-full space-y-4",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-wider block ml-1",style:{color:"#d4a54a",opacity:.7},children:"Daemon Access Token"}),l.jsxs("div",{className:"relative group",children:[l.jsx("div",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none transition-colors duration-200",style:{color:"#8b7355"},children:l.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:l.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})})}),l.jsx("input",{type:"password",required:!0,placeholder:"Paste your daemon.token...",value:t,onChange:c=>n(c.target.value),disabled:r,className:"w-full pl-10 pr-4 py-2.5 rounded-xl text-[13px] font-mono focus:outline-none transition-all duration-200",style:{background:"rgba(14, 11, 8, 0.8)",border:"1px solid rgba(86, 72, 58, 0.4)",color:"#f5e6d0"}})]})]}),i&&l.jsxs("div",{className:"p-3 rounded-xl text-xs flex items-start gap-2.5 animate-fadeIn",style:{background:"color-mix(in srgb, var(--red) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--red) 20%, transparent)",color:"var(--red)"},children:[l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"shrink-0 mt-0.5",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),l.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),l.jsx("span",{children:i})]}),l.jsx("button",{type:"submit",disabled:r||!t.trim(),className:"btn-gold w-full py-2.5 px-4 rounded-xl font-semibold text-xs active:scale-[0.98] transition-all duration-150 disabled:opacity-50 disabled:pointer-events-none cursor-pointer flex items-center justify-center gap-2",children:r?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"w-3.5 h-3.5 rounded-full animate-spin",style:{background:"conic-gradient(from 0deg, transparent, #1a1410)",mask:"radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 0)",WebkitMask:"radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 0)"}}),"Verifying Credentials..."]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{children:"Authorize & Connect"}),l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[l.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),l.jsx("polyline",{points:"12 5 19 12 12 19"})]})]})})]}),l.jsxs("div",{className:"w-full mt-6 pt-5 space-y-2 leading-relaxed",style:{borderTop:"1px solid rgba(86, 72, 58, 0.3)",fontSize:"11.5px",color:"#8b7355"},children:[l.jsx("div",{className:"font-semibold",style:{color:"#bfae94"},children:"Where is my token?"}),l.jsx("p",{children:"When starting the daemon, look for the console output in your terminal. It displays the dashboard link containing the secure token."}),l.jsxs("p",{children:["You can also find the raw token inside the file ",l.jsx("code",{className:"font-mono px-1 py-0.5 rounded text-[10.5px]",style:{background:"rgba(14, 11, 8, 0.6)",border:"1px solid rgba(86, 72, 58, 0.3)",color:"#d4c4a8"},children:"~/.curie-agent/daemon.token"})," on your host machine."]})]})]})]})}const X7=["plan","edit","auto","yolo"],P7=[{view:"assistant",label:"Assistant",icon:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"},{view:"channels",label:"Channels",icon:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07A19.5 19.5 0 0 1 4.86 13a19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 3.77 2h3a2 2 0 0 1 2 1.72c.127.96.361 1.903.7 2.81a2 2 0 0 1-.45 2.11L7.91 9.91a16 16 0 0 0 6.16 6.16l1.27-1.27a2 2 0 0 1 2.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0 1 22 16.92z"},{view:"stats",label:"Stats",icon:"M18 20V10M12 20V4M6 20v-6"},{view:"projects",label:"Projects",icon:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"},{view:"agents",label:"Agents",icon:"M12 8c0 2.21-1.79 4-4 4s-4-1.79-4-4 1.79-4 4-4 4 1.79 4 4zm-6 12v-2a6 6 0 0 1 12 0v2"},{view:"kanban",label:"Tasks",icon:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"},{view:"wiki",label:"Wiki",icon:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"},{view:"settings",label:"Settings",icon:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}];function F7(){const{rpc:e,connected:t,token:n,setToken:r}=fr(),{get:s,set:i,providers:o}=og(),[a,c]=w.useState("assistant"),u=s("mode")||"auto",[d,f]=w.useState(!1),[h,p]=w.useState(""),[x,b]=w.useState(null),[S,m]=w.useState(!1),[y,g]=w.useState(null),[v,N]=w.useState(navigator.onLine),[k,T]=w.useState(!1),[z,A]=w.useState(!1),[L,R]=w.useState(!1),[H,Y]=w.useState(!1),_=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;w.useEffect(()=>{const G=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone===!0;T(!!G)},[]),w.useEffect(()=>{const G=ie=>{ie.preventDefault(),g(ie)},te=()=>N(!0),le=()=>N(!1);return window.addEventListener("beforeinstallprompt",G),window.addEventListener("online",te),window.addEventListener("offline",le),()=>{window.removeEventListener("beforeinstallprompt",G),window.removeEventListener("online",te),window.removeEventListener("offline",le)}},[]);const C=async()=>{if(y){y.prompt();const{outcome:G}=await y.userChoice;console.log(`PWA install prompt choice: ${G}`),g(null)}else A(!0)},{sessions:j,refetch:D}=q7(),{events:O,addLiveEvent:$,contextReport:U}=V7(x),X=s("theme")||"curie";w.useEffect(()=>{document.documentElement.setAttribute("data-theme",X)},[X]),w.useEffect(()=>{const G=()=>m(window.innerWidth<768);return G(),window.addEventListener("resize",G),()=>window.removeEventListener("resize",G)},[]),w.useEffect(()=>{!t||!e||e.configGet("current_provider").then(G=>{G||R(!0)}).catch(()=>{})},[t,e]);const Z=w.useCallback(()=>{b(null)},[]),B=w.useCallback(G=>{b(G)},[]),E=w.useCallback(G=>{b(G),c("assistant")},[]),q=w.useCallback(G=>{b(G),D()},[D]);w.useEffect(()=>{const G=te=>{(te.metaKey||te.ctrlKey)&&te.key==="k"&&(te.preventDefault(),f(!0))};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[]);const V=w.useCallback(G=>{p(G),f(!1)},[]),J=w.useCallback(()=>{p("")},[]),F=(G,te=18)=>l.jsx("svg",{width:te,height:te,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:l.jsx("path",{d:G.icon})});return n?l.jsxs("div",{className:"flex h-dvh w-screen flex-col overflow-hidden bg-bg coffee-pattern",children:[!v&&l.jsxs("div",{className:"px-4 py-2 text-center text-xs font-semibold flex items-center justify-center gap-2 select-none shrink-0 z-50 animate-fadeIn",style:{background:"color-mix(in srgb, var(--yellow) 10%, transparent)",borderBottom:"1px solid color-mix(in srgb, var(--yellow) 20%, transparent)",color:"var(--yellow)"},children:[l.jsxs("svg",{className:"animate-pulse shrink-0",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),l.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),l.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),"Offline Mode — Curie is running on cached local client"]}),l.jsx(I7,{}),l.jsx(Y7,{}),l.jsxs("main",{className:"flex flex-1 flex-col overflow-hidden bg-bg",children:[l.jsxs("div",{className:"topbar-wood flex h-12 items-center gap-3 px-4 shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs("button",{className:"relative flex items-center justify-center w-8 h-8 rounded-lg transition-all duration-150",style:{color:H?"var(--fg)":"var(--muted)",background:H?"var(--s3)":"transparent",border:H?"1px solid var(--b1)":"1px solid transparent"},onClick:()=>Y(!0),title:"Sessions",children:[l.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:l.jsx("path",{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"})}),j.length>0&&l.jsx("span",{className:"absolute -top-0.5 -right-0.5 text-[9px] font-bold rounded-full w-4 h-4 flex items-center justify-center",style:{background:"var(--gold)",color:"#1a1410"},children:j.length>99?"99+":j.length})]}),l.jsx("div",{className:"w-px h-5 bg-b1 mx-0.5"}),P7.map(G=>l.jsx("button",{className:"flex items-center justify-center w-8 h-8 rounded-lg transition-all duration-150 cursor-pointer",style:{color:a===G.view?"var(--gold)":"var(--muted)",background:a===G.view?"var(--s3)":"transparent",border:a===G.view?"1px solid var(--b1)":"1px solid transparent"},onClick:()=>c(G.view),title:G.label,children:F(G,18)},G.view))]}),l.jsx("div",{className:"flex-1"}),window.innerWidth>=640&&l.jsx("div",{className:"flex rounded-lg overflow-hidden",style:{border:"1px solid var(--b2)",background:"var(--bg)"},children:X7.map(G=>l.jsx("button",{className:"px-2.5 py-1 text-xs cursor-pointer transition-all duration-150 font-mono select-none",style:{color:u===G?"var(--gold)":"var(--muted)",background:u===G?"var(--s3)":"transparent",borderRight:"1px solid var(--b1)"},onClick:()=>i("mode",G),children:G},G))}),(y||S&&!k)&&l.jsxs("button",{onClick:C,className:"flex items-center justify-center rounded-lg transition-all duration-150 px-2.5 py-1 gap-1.5 text-xs font-semibold cursor-pointer shrink-0",style:{background:"var(--bg)",border:"1px solid color-mix(in srgb, var(--green) 30%, transparent)",color:"var(--green)"},children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),l.jsx("polyline",{points:"7 10 12 15 17 10"}),l.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),!S&&l.jsx(l.Fragment,{children:"Install"})]}),l.jsxs("button",{className:"flex items-center justify-center rounded-lg transition-all duration-150 px-2.5 py-1 gap-1.5 text-xs font-semibold cursor-pointer shrink-0",style:{background:"transparent",border:"1px solid var(--b2)",color:"var(--muted)"},onClick:()=>f(!0),title:"Open Commands",children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[l.jsx("circle",{cx:"11",cy:"11",r:"8"}),l.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),!S&&l.jsx(l.Fragment,{children:"Ctrl+k"})]})]}),l.jsxs("div",{className:"relative flex-1 min-h-0",children:[L&&e?l.jsx(U7,{rpc:e,onComplete:()=>R(!1),className:"absolute inset-0"}):a==="assistant"&&l.jsx(EA,{contextReport:U,cmdResult:h,onClearCmdResult:J,rpc:e,className:"absolute inset-0",activeSessionId:x,onCreateSession:q,events:O,addLiveEvent:$,onSwitchView:G=>c(G)}),a==="channels"&&l.jsx(TA,{rpc:e,className:"absolute inset-0"}),a==="stats"&&l.jsx(AA,{rpc:e,className:"absolute inset-0"}),a==="projects"&&l.jsx(CA,{rpc:e,className:"absolute inset-0"}),a==="agents"&&l.jsx(UA,{rpc:e,onOpenSession:E,className:"absolute inset-0"}),a==="kanban"&&l.jsx(UC,{rpc:e,className:"absolute inset-0"}),a==="wiki"&&l.jsx(p6,{rpc:e,className:"absolute inset-0"}),a==="settings"&&l.jsx(_6,{rpc:e,className:"absolute inset-0"})]})]}),l.jsx(B7,{open:d,onClose:()=>f(!1),onPick:V}),H&&l.jsx("div",{className:"fixed inset-0 z-[998] flex items-end animate-fadeIn",style:{background:"rgba(10, 8, 5, 0.6)",backdropFilter:"blur(4px)"},onClick:()=>Y(!1),children:l.jsxs("div",{className:"w-full max-h-[70vh] rounded-t-2xl overflow-hidden animate-slideUp select-none flex flex-col wood-grain",style:{background:"var(--s1)",borderTop:"1px solid var(--b1)"},onClick:G=>G.stopPropagation(),children:[l.jsx("div",{className:"flex justify-center pt-3 pb-1 shrink-0",children:l.jsx("div",{className:"w-8 h-1 rounded-full",style:{background:"var(--gold)",opacity:.3}})}),l.jsxs("div",{className:"flex items-center justify-between px-4 pb-3 shrink-0",style:{borderBottom:"1px solid var(--b1)"},children:[l.jsx("span",{className:"text-[13px] font-display font-semibold",style:{color:"var(--cream)"},children:"Sessions"}),l.jsx("button",{onClick:()=>Y(!1),className:"text-muted hover:text-fg transition-colors duration-100 p-1",children:l.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),l.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--b1)"},children:l.jsxs("button",{onClick:()=>{Z(),Y(!1)},className:"w-full flex items-center gap-2.5 py-2 px-3 rounded-xl transition-all duration-150 active:scale-[0.98] cursor-pointer",style:{background:"color-mix(in srgb, var(--gold) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--gold) 20%, transparent)",color:"var(--gold)"},children:[l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),l.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),l.jsx("span",{className:"text-[12.5px] font-semibold",children:"New Chat"})]})}),l.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4 scrollbar-thin",children:[j.sort((G,te)=>te.updatedAt-G.updatedAt).map(G=>l.jsx("button",{className:"w-full text-left py-3 px-3 rounded-xl mb-1 transition-all duration-150 active:scale-[0.98] min-h-[52px] cursor-pointer",style:{background:G.id===x?"linear-gradient(135deg, var(--s3) 0%, var(--s2) 100%)":"transparent",border:G.id===x?"1px solid var(--b2)":"1px solid transparent"},onClick:()=>{B(G.id),Y(!1)},children:l.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[l.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:G.id===x?"var(--gold)":"transparent",boxShadow:G.id===x?"0 0 4px var(--gold)":"none"}}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-[12.5px] font-medium text-fg truncate",children:G.name||G.provider}),l.jsxs("div",{className:"text-[11px] text-muted",children:[G.provider," · ",(()=>{const te=Date.now()-G.updatedAt;return te<6e4?"just now":te<36e5?`${Math.floor(te/6e4)}m ago`:te<864e5?`${Math.floor(te/36e5)}h ago`:`${Math.floor(te/864e5)}d ago`})()]})]}),G.type&&G.type!=="webui"&&l.jsx("span",{className:"text-[9px] font-mono text-muted bg-s2 px-1.5 py-0.5 rounded shrink-0",children:G.type})]})},G.id)),j.length===0&&l.jsx("div",{className:"text-center py-8 text-xs text-muted",children:"No sessions yet"})]}),x&&l.jsx("div",{className:"border-t border-b1 px-4 py-3 shrink-0",children:(()=>{var W;const G=O.filter(ge=>ge.type==="usage"),te=G.reduce((ge,Ue)=>ge+(Ue.inputTokens||0)+(Ue.outputTokens||0),0),le=G[G.length-1],ie=le&&le.inputTokens||0,ce=s("current_provider")||"anthropic",oe=(W=o.find(ge=>ge.name===ce))==null?void 0:W.model_cost,he=s("model")||"sonnet",re=G.reduce((ge,Ue)=>ge+T2(he,Ue.inputTokens||0,Ue.outputTokens||0,oe),0);return l.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-[9px] text-muted2 uppercase tracking-wider font-mono",children:"Tokens"}),l.jsx("div",{className:"text-[12px] text-fg font-mono font-semibold",children:Sn(te)})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-[9px] text-muted2 uppercase tracking-wider font-mono",children:"Context"}),l.jsx("div",{className:"text-[12px] text-fg font-mono font-semibold",children:Sn(ie)})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-[9px] text-muted2 uppercase tracking-wider font-mono",children:"Cost"}),l.jsxs("div",{className:"text-[12px] text-green font-mono font-semibold",children:["$",re.toFixed(4)]})]})]})})()})]})}),z&&l.jsx("div",{className:"fixed inset-0 z-[999] flex items-center justify-center p-4 animate-fadeIn",style:{background:"rgba(10, 8, 5, 0.7)",backdropFilter:"blur(8px)"},children:l.jsxs("div",{className:"w-full max-w-[340px] p-5 rounded-2xl shadow-2xl animate-scaleIn select-none",style:{background:"linear-gradient(135deg, var(--s2), var(--s1))",border:"1px solid var(--b2)",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[l.jsxs("div",{className:"flex items-center justify-between pb-3 mb-4",style:{borderBottom:"1px solid var(--b1)"},children:[l.jsx("span",{className:"font-bold text-[13.5px] font-display",style:{color:"var(--cream)"},children:"Install Curie Agent"}),l.jsx("button",{onClick:()=>A(!1),className:"text-muted hover:text-fg transition-colors duration-100 cursor-pointer",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),l.jsx("div",{className:"space-y-3.5 text-xs text-text leading-relaxed",children:_?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-[12px] text-muted mb-1 px-0.5",children:"Follow these simple steps to add Curie to your home screen:"}),l.jsxs("div",{className:"flex gap-3 items-start p-3 rounded-xl",style:{background:"color-mix(in srgb, var(--s1) 50%, transparent)",border:"1px solid var(--b1)"},children:[l.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-lg shrink-0",style:{background:"color-mix(in srgb, var(--gold) 10%, transparent)",color:"var(--gold)"},children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:l.jsx("path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8M16 6l-4-4-4 4M12 2v13"})})}),l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-fg block mb-0.5",children:"1. Tap the Share Button"}),l.jsx("span",{className:"text-[11px] text-muted",children:"Tap the Share icon in Safari's bottom toolbar."})]})]}),l.jsxs("div",{className:"flex gap-3 items-start p-3 rounded-xl",style:{background:"color-mix(in srgb, var(--s1) 50%, transparent)",border:"1px solid var(--b1)"},children:[l.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-lg shrink-0 font-bold font-mono text-[16px] select-none",style:{background:"color-mix(in srgb, var(--gold) 10%, transparent)",color:"var(--gold)"},children:"+"}),l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-fg block mb-0.5",children:"2. Add to Home Screen"}),l.jsxs("span",{className:"text-[11px] text-muted",children:["Scroll down and select ",l.jsx("strong",{children:"Add to Home Screen"}),"."]})]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-[12px] text-muted mb-1 px-0.5",children:"Follow these simple steps to add Curie to your home screen:"}),l.jsxs("div",{className:"flex gap-3 items-start bg-s1/50 border border-b1 p-3 rounded-xl",children:[l.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-lg bg-blue-500/10 text-blue-400 shrink-0",children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("circle",{cx:"12",cy:"12",r:"1"}),l.jsx("circle",{cx:"12",cy:"5",r:"1"}),l.jsx("circle",{cx:"12",cy:"19",r:"1"})]})}),l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-fg block mb-0.5",children:"1. Open Browser Menu"}),l.jsx("span",{className:"text-[11px] text-muted",children:"Tap the menu icon (three dots) in the top-right corner."})]})]}),l.jsxs("div",{className:"flex gap-3 items-start bg-s1/50 border border-b1 p-3 rounded-xl",children:[l.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-lg bg-blue-500/10 text-blue-400 shrink-0",children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),l.jsx("polyline",{points:"7 10 12 15 17 10"}),l.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-fg block mb-0.5",children:"2. Select Add / Install"}),l.jsxs("span",{className:"text-[11px] text-muted",children:["Tap ",l.jsx("strong",{children:"Add to Home screen"})," or ",l.jsx("strong",{children:"Install app"}),"."]})]})]})]})}),l.jsx("button",{onClick:()=>A(!1),className:"btn-gold w-full mt-5 py-2.5 px-4 rounded-xl font-semibold text-xs active:scale-[0.98] transition-all duration-150 cursor-pointer flex items-center justify-center",children:"Got it"})]})})]}):l.jsx(G7,{onAuthorize:r})}function Q7(){return l.jsx(AE,{children:l.jsx(F7,{})})}const K7=NE.createRoot(document.getElementById("root"));K7.render(l.jsx(Xe.StrictMode,{children:l.jsx(Q7,{})}));"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js").then(e=>{console.log("ServiceWorker registration successful with scope: ",e.scope),e.addEventListener("updatefound",()=>{const t=e.installing;t&&(window._pendingUpdateWorker=t,t.addEventListener("statechange",()=>{t.state==="installed"&&(window._hasPendingUpdate=!0,window.dispatchEvent(new CustomEvent("pwa-update-available")))}))}),navigator.serviceWorker.addEventListener("controllerchange",()=>{window.dispatchEvent(new CustomEvent("pwa-controller-updated"))})}).catch(e=>console.error("ServiceWorker registration failed: ",e))});
234
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of e.seen.entries()){const f=d[1];if(t===d[0]){i(d);continue}if(e.external){const p=(c=e.external.registry.get(d[0]))==null?void 0:c.id;if(t!==d[0]&&p){i(d);continue}}if((u=e.metadataRegistry.get(d[0]))==null?void 0:u.id){i(d);continue}if(f.cycle){i(d);continue}if(f.count>1&&e.reused==="ref"){i(d);continue}}}function yk(e,t){var a,c,u,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=f=>{const h=e.seen.get(f);if(h.ref===null)return;const p=h.def??h.schema,x={...p},b=h.ref;if(h.ref=null,b){r(b);const m=e.seen.get(b),y=m.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(y)):Object.assign(p,y),Object.assign(p,x),f._zod.parent===b)for(const v in p)v==="$ref"||v==="allOf"||v in x||delete p[v];if(y.$ref&&m.def)for(const v in p)v==="$ref"||v==="allOf"||v in m.def&&JSON.stringify(p[v])===JSON.stringify(m.def[v])&&delete p[v]}const S=f._zod.parent;if(S&&S!==b){r(S);const m=e.seen.get(S);if(m!=null&&m.schema.$ref&&(p.$ref=m.schema.$ref,m.def))for(const y in p)y==="$ref"||y==="allOf"||y in m.def&&JSON.stringify(p[y])===JSON.stringify(m.def[y])&&delete p[y]}e.override({zodSchema:f,jsonSchema:p,path:h.path??[]})};for(const f of[...e.seen.entries()].reverse())r(f[0]);const s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,(a=e.external)!=null&&a.uri){const f=(c=e.external.registry.get(t))==null?void 0:c.id;if(!f)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(f)}Object.assign(s,n.def??n.schema);const i=(u=e.metadataRegistry.get(t))==null?void 0:u.id;i!==void 0&&s.id===i&&delete s.id;const o=((d=e.external)==null?void 0:d.defs)??{};for(const f of e.seen.entries()){const h=f[1];h.def&&h.defId&&(h.def.id===h.defId&&delete h.def.id,o[h.defId]=h.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?s.$defs=o:s.definitions=o);try{const f=JSON.parse(JSON.stringify(s));return Object.defineProperty(f,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ed(t,"input",e.processors),output:Ed(t,"output",e.processors)}},enumerable:!1,writable:!1}),f}catch{throw new Error("Error converting schema to JSON.")}}function Xt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Xt(r.element,n);if(r.type==="set")return Xt(r.valueType,n);if(r.type==="lazy")return Xt(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")return Xt(r.innerType,n);if(r.type==="intersection")return Xt(r.left,n)||Xt(r.right,n);if(r.type==="record"||r.type==="map")return Xt(r.keyType,n)||Xt(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Xt(r.in,n)||Xt(r.out,n);if(r.type==="object"){for(const s in r.shape)if(Xt(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(Xt(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(Xt(s,n))return!0;return!!(r.rest&&Xt(r.rest,n))}return!1}const NL=(e,t={})=>n=>{const r=gk({...n,processors:t});return mt(e,r),xk(r,e),yk(r,e)},Ed=(e,t,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},o=gk({...s??{},target:i,io:t,processors:n});return mt(e,o),xk(o,e),yk(o,e)},jL={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},EL=(e,t,n,r)=>{const s=n;s.type="string";const{minimum:i,maximum:o,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(s.minLength=i),typeof o=="number"&&(s.maxLength=o),a&&(s.format=jL[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),u&&(s.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},TL=(e,t,n,r)=>{const s=n,{minimum:i,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number";const f=typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY),h=typeof u=="number"&&u<=(o??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";f?p?(s.minimum=d,s.exclusiveMinimum=!0):s.exclusiveMinimum=d:typeof i=="number"&&(s.minimum=i),h?p?(s.maximum=u,s.exclusiveMaximum=!0):s.exclusiveMaximum=u:typeof o=="number"&&(s.maximum=o),typeof c=="number"&&(s.multipleOf=c)},AL=(e,t,n,r)=>{n.type="boolean"},CL=(e,t,n,r)=>{n.not={}},ML=(e,t,n,r)=>{},zL=(e,t,n,r)=>{const s=e._zod.def,i=F_(s.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},DL=(e,t,n,r)=>{const s=e._zod.def,i=[];for(const o of s.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},RL=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},OL=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},$L=(e,t,n,r)=>{const s=n,i=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;typeof o=="number"&&(s.minItems=o),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=mt(i.element,t,{...r,path:[...r.path,"items"]})},LL=(e,t,n,r)=>{var u;const s=n,i=e._zod.def;s.type="object",s.properties={};const o=i.shape;for(const d in o)s.properties[d]=mt(o[d],t,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(d=>{const f=i.shape[d]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(s.required=Array.from(c)),((u=i.catchall)==null?void 0:u._zod.def.type)==="never"?s.additionalProperties=!1:i.catchall?i.catchall&&(s.additionalProperties=mt(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},HL=(e,t,n,r)=>{const s=e._zod.def,i=s.inclusive===!1,o=s.options.map((a,c)=>mt(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=o:n.anyOf=o},BL=(e,t,n,r)=>{const s=e._zod.def,i=mt(s.left,t,{...r,path:[...r.path,"allOf",0]}),o=mt(s.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(o)?o.allOf:[o]];n.allOf=c},UL=(e,t,n,r)=>{const s=n,i=e._zod.def;s.type="object";const o=i.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(i.mode==="loose"&&c&&c.size>0){const d=mt(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});s.patternProperties={};for(const f of c)s.patternProperties[f.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(s.propertyNames=mt(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),s.additionalProperties=mt(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(s.required=d)}},IL=(e,t,n,r)=>{const s=e._zod.def,i=mt(s.innerType,t,r),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=s.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},ZL=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType},YL=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))},qL=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},VL=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType;let o;try{o=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},GL=(e,t,n,r)=>{const s=e._zod.def,i=s.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?s.out:s.in:s.out;mt(o,t,r);const a=t.seen.get(e);a.ref=o},XL=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType,n.readOnly=!0},vk=(e,t,n,r)=>{const s=e._zod.def;mt(s.innerType,t,r);const i=t.seen.get(e);i.ref=s.innerType},PL=Q("ZodISODateTime",(e,t)=>{F$.init(e,t),st.init(e,t)});function FL(e){return tL(PL,e)}const QL=Q("ZodISODate",(e,t)=>{Q$.init(e,t),st.init(e,t)});function KL(e){return nL(QL,e)}const WL=Q("ZodISOTime",(e,t)=>{K$.init(e,t),st.init(e,t)});function JL(e){return rL(WL,e)}const e9=Q("ZodISODuration",(e,t)=>{W$.init(e,t),st.init(e,t)});function t9(e){return sL(e9,e)}const n9=(e,t)=>{J_.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>I6(e,n)},flatten:{value:n=>U6(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,nm,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,nm,2)}},isEmpty:{get(){return e.issues.length===0}}})},Gn=Q("ZodError",n9,{Parent:Error}),r9=Qg(Gn),s9=Kg(Gn),i9=mf(Gn),o9=gf(Gn),a9=q6(Gn),l9=V6(Gn),c9=G6(Gn),u9=X6(Gn),d9=P6(Gn),f9=F6(Gn),h9=Q6(Gn),p9=K6(Gn),Qv=new WeakMap;function ac(e,t,n){const r=Object.getPrototypeOf(e);let s=Qv.get(r);if(s||(s=new Set,Qv.set(r,s)),!s.has(t)){s.add(t);for(const i in n){const o=n[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){const a=o.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}const rt=Q("ZodType",(e,t)=>(nt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ed(e,"input"),output:Ed(e,"output")}}),e.toJSONSchema=NL(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>r9(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>i9(e,n,r),e.parseAsync=async(n,r)=>s9(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>o9(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>a9(e,n,r),e.decode=(n,r)=>l9(e,n,r),e.encodeAsync=async(n,r)=>c9(e,n,r),e.decodeAsync=async(n,r)=>u9(e,n,r),e.safeEncode=(n,r)=>d9(e,n,r),e.safeDecode=(n,r)=>f9(e,n,r),e.safeEncodeAsync=async(n,r)=>h9(e,n,r),e.safeDecodeAsync=async(n,r)=>p9(e,n,r),ac(e,"ZodType",{check(...n){const r=this.def;return this.clone(Js(r,{checks:[...r.checks??[],...n.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return ei(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(a7(n,r))},superRefine(n,r){return this.check(l7(n,r))},overwrite(n){return this.check(ma(n))},optional(){return eb(this)},exactOptional(){return P9(this)},nullable(){return tb(this)},nullish(){return eb(tb(this))},nonoptional(n){return e7(this,n)},array(){return Dr(this)},or(n){return lc([this,n])},and(n){return Y9(this,n)},transform(n){return nb(this,G9(n))},default(n){return K9(this,n)},prefault(n){return J9(this,n)},catch(n){return n7(this,n)},pipe(n){return nb(this,n)},readonly(){return i7(this)},describe(n){const r=this.clone();return qa.add(r,{description:n}),r},meta(...n){if(n.length===0)return qa.get(this);const r=this.clone();return qa.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=qa.get(e))==null?void 0:n.description},configurable:!0}),e)),bk=Q("_ZodString",(e,t)=>{Wg.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,s,i)=>EL(e,r,s);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ac(e,"_ZodString",{regex(...r){return this.check(uL(...r))},includes(...r){return this.check(hL(...r))},startsWith(...r){return this.check(pL(...r))},endsWith(...r){return this.check(mL(...r))},min(...r){return this.check(jd(...r))},max(...r){return this.check(pk(...r))},length(...r){return this.check(mk(...r))},nonempty(...r){return this.check(jd(1,...r))},lowercase(r){return this.check(dL(r))},uppercase(r){return this.check(fL(r))},trim(){return this.check(xL())},normalize(...r){return this.check(gL(...r))},toLowerCase(){return this.check(yL())},toUpperCase(){return this.check(vL())},slugify(){return this.check(bL())}})}),m9=Q("ZodString",(e,t)=>{Wg.init(e,t),bk.init(e,t),e.email=n=>e.check(R8(g9,n)),e.url=n=>e.check(B8(x9,n)),e.jwt=n=>e.check(eL(z9,n)),e.emoji=n=>e.check(U8(y9,n)),e.guid=n=>e.check(Gv(Kv,n)),e.uuid=n=>e.check(O8(iu,n)),e.uuidv4=n=>e.check($8(iu,n)),e.uuidv6=n=>e.check(L8(iu,n)),e.uuidv7=n=>e.check(H8(iu,n)),e.nanoid=n=>e.check(I8(v9,n)),e.guid=n=>e.check(Gv(Kv,n)),e.cuid=n=>e.check(Z8(b9,n)),e.cuid2=n=>e.check(Y8(w9,n)),e.ulid=n=>e.check(q8(S9,n)),e.base64=n=>e.check(K8(A9,n)),e.base64url=n=>e.check(W8(C9,n)),e.xid=n=>e.check(V8(_9,n)),e.ksuid=n=>e.check(G8(k9,n)),e.ipv4=n=>e.check(X8(N9,n)),e.ipv6=n=>e.check(P8(j9,n)),e.cidrv4=n=>e.check(F8(E9,n)),e.cidrv6=n=>e.check(Q8(T9,n)),e.e164=n=>e.check(J8(M9,n)),e.datetime=n=>e.check(FL(n)),e.date=n=>e.check(KL(n)),e.time=n=>e.check(JL(n)),e.duration=n=>e.check(t9(n))});function P(e){return D8(m9,e)}const st=Q("ZodStringFormat",(e,t)=>{et.init(e,t),bk.init(e,t)}),g9=Q("ZodEmail",(e,t)=>{U$.init(e,t),st.init(e,t)}),Kv=Q("ZodGUID",(e,t)=>{H$.init(e,t),st.init(e,t)}),iu=Q("ZodUUID",(e,t)=>{B$.init(e,t),st.init(e,t)}),x9=Q("ZodURL",(e,t)=>{I$.init(e,t),st.init(e,t)}),y9=Q("ZodEmoji",(e,t)=>{Z$.init(e,t),st.init(e,t)}),v9=Q("ZodNanoID",(e,t)=>{Y$.init(e,t),st.init(e,t)}),b9=Q("ZodCUID",(e,t)=>{q$.init(e,t),st.init(e,t)}),w9=Q("ZodCUID2",(e,t)=>{V$.init(e,t),st.init(e,t)}),S9=Q("ZodULID",(e,t)=>{G$.init(e,t),st.init(e,t)}),_9=Q("ZodXID",(e,t)=>{X$.init(e,t),st.init(e,t)}),k9=Q("ZodKSUID",(e,t)=>{P$.init(e,t),st.init(e,t)}),N9=Q("ZodIPv4",(e,t)=>{J$.init(e,t),st.init(e,t)}),j9=Q("ZodIPv6",(e,t)=>{e8.init(e,t),st.init(e,t)}),E9=Q("ZodCIDRv4",(e,t)=>{t8.init(e,t),st.init(e,t)}),T9=Q("ZodCIDRv6",(e,t)=>{n8.init(e,t),st.init(e,t)}),A9=Q("ZodBase64",(e,t)=>{r8.init(e,t),st.init(e,t)}),C9=Q("ZodBase64URL",(e,t)=>{i8.init(e,t),st.init(e,t)}),M9=Q("ZodE164",(e,t)=>{o8.init(e,t),st.init(e,t)}),z9=Q("ZodJWT",(e,t)=>{l8.init(e,t),st.init(e,t)}),wk=Q("ZodNumber",(e,t)=>{ck.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,s,i)=>TL(e,r,s),ac(e,"ZodNumber",{gt(r,s){return this.check(Pv(r,s))},gte(r,s){return this.check($h(r,s))},min(r,s){return this.check($h(r,s))},lt(r,s){return this.check(Xv(r,s))},lte(r,s){return this.check(Oh(r,s))},max(r,s){return this.check(Oh(r,s))},int(r){return this.check(Wv(r))},safe(r){return this.check(Wv(r))},positive(r){return this.check(Pv(0,r))},nonnegative(r){return this.check($h(0,r))},negative(r){return this.check(Xv(0,r))},nonpositive(r){return this.check(Oh(0,r))},multipleOf(r,s){return this.check(Fv(r,s))},step(r,s){return this.check(Fv(r,s))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function xe(e){return iL(wk,e)}const D9=Q("ZodNumberFormat",(e,t)=>{c8.init(e,t),wk.init(e,t)});function Wv(e){return oL(D9,e)}const R9=Q("ZodBoolean",(e,t)=>{u8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>AL(e,n,r)});function Jg(e){return aL(R9,e)}const O9=Q("ZodUnknown",(e,t)=>{d8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>ML()});function zn(){return lL(O9)}const $9=Q("ZodNever",(e,t)=>{f8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>CL(e,n,r)});function L9(e){return cL($9,e)}const H9=Q("ZodArray",(e,t)=>{h8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>$L(e,n,r,s),e.element=t.element,ac(e,"ZodArray",{min(n,r){return this.check(jd(n,r))},nonempty(n){return this.check(jd(1,n))},max(n,r){return this.check(pk(n,r))},length(n,r){return this.check(mk(n,r))},unwrap(){return this.element}})});function Dr(e,t){return wL(H9,e,t)}const B9=Q("ZodObject",(e,t)=>{m8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>LL(e,n,r,s),$e(e,"shape",()=>t.shape),ac(e,"ZodObject",{keyof(){return De(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:zn()})},loose(){return this.clone({...this._zod.def,catchall:zn()})},strict(){return this.clone({...this._zod.def,catchall:L9()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return R6(this,n)},safeExtend(n){return O6(this,n)},merge(n){return $6(this,n)},pick(n){return z6(this,n)},omit(n){return D6(this,n)},partial(...n){return L6(_k,this,n[0])},required(...n){return H6(kk,this,n[0])}})});function se(e,t){const n={type:"object",shape:e??{},...de(t)};return new B9(n)}const Sk=Q("ZodUnion",(e,t)=>{fk.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>HL(e,n,r,s),e.options=t.options});function lc(e,t){return new Sk({type:"union",options:e,...de(t)})}const U9=Q("ZodDiscriminatedUnion",(e,t)=>{Sk.init(e,t),g8.init(e,t)});function I9(e,t,n){return new U9({type:"union",options:t,discriminator:e,...de(n)})}const Z9=Q("ZodIntersection",(e,t)=>{x8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>BL(e,n,r,s)});function Y9(e,t){return new Z9({type:"intersection",left:e,right:t})}const Jv=Q("ZodRecord",(e,t)=>{y8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>UL(e,n,r,s),e.keyType=t.keyType,e.valueType=t.valueType});function ga(e,t,n){return!t||!t._zod?new Jv({type:"record",keyType:P(),valueType:e,...de(t)}):new Jv({type:"record",keyType:e,valueType:t,...de(n)})}const sm=Q("ZodEnum",(e,t)=>{v8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,s,i)=>zL(e,r,s),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,s)=>{const i={};for(const o of r)if(n.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new sm({...t,checks:[],...de(s),entries:i})},e.exclude=(r,s)=>{const i={...t.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new sm({...t,checks:[],...de(s),entries:i})}});function De(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new sm({type:"enum",entries:n,...de(t)})}const q9=Q("ZodLiteral",(e,t)=>{b8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>DL(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Be(e,t){return new q9({type:"literal",values:Array.isArray(e)?e:[e],...de(t)})}const V9=Q("ZodTransform",(e,t)=>{w8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>OL(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new P_(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push($l(i,n.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push($l(o))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=s,n.fallback=!0,n)}});function G9(e){return new V9({type:"transform",transform:e})}const _k=Q("ZodOptional",(e,t)=>{hk.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>vk(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function eb(e){return new _k({type:"optional",innerType:e})}const X9=Q("ZodExactOptional",(e,t)=>{S8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>vk(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function P9(e){return new X9({type:"optional",innerType:e})}const F9=Q("ZodNullable",(e,t)=>{_8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>IL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function tb(e){return new F9({type:"nullable",innerType:e})}const Q9=Q("ZodDefault",(e,t)=>{k8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>YL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function K9(e,t){return new Q9({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():K_(t)}})}const W9=Q("ZodPrefault",(e,t)=>{N8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>qL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function J9(e,t){return new W9({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():K_(t)}})}const kk=Q("ZodNonOptional",(e,t)=>{j8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>ZL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function e7(e,t){return new kk({type:"nonoptional",innerType:e,...de(t)})}const t7=Q("ZodCatch",(e,t)=>{E8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>VL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function n7(e,t){return new t7({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const r7=Q("ZodPipe",(e,t)=>{T8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>GL(e,n,r,s),e.in=t.in,e.out=t.out});function nb(e,t){return new r7({type:"pipe",in:e,out:t})}const s7=Q("ZodReadonly",(e,t)=>{A8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>XL(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function i7(e){return new s7({type:"readonly",innerType:e})}const o7=Q("ZodCustom",(e,t)=>{C8.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(n,r,s)=>RL(e,n)});function a7(e,t={}){return SL(o7,e,t)}function l7(e,t){return _L(e,t)}const c7=se({type:Be("user-prompt"),id:P(),text:P(),cwd:P(),timestamp:xe()}),u7=se({type:Be("assistant-delta"),id:P(),text:P(),timestamp:xe()}),d7=se({type:Be("assistant-stop"),id:P(),timestamp:xe()}),f7=se({type:Be("tool-call"),id:P(),toolCallId:P(),name:P(),input:ga(P(),zn()),timestamp:xe()}),h7=se({type:Be("tool-result"),id:P(),toolCallId:P(),output:zn(),error:P().optional(),timestamp:xe()}),p7=se({type:Be("approval-request"),id:P(),toolCallId:P(),name:P(),input:ga(P(),zn()),decision:De(["allow","deny","ask"]).optional(),timestamp:xe()}),m7=se({type:Be("approval-decision"),id:P(),toolCallId:P(),decision:De(["allow","deny"]),by:P().optional(),timestamp:xe()}),g7=se({type:Be("usage"),id:P(),inputTokens:xe(),outputTokens:xe(),cacheReadTokens:xe().optional(),cacheWriteTokens:xe().optional(),timestamp:xe()}),x7=se({type:Be("error"),id:P(),message:P(),code:P().optional(),timestamp:xe()}),y7=se({type:Be("session-start"),id:P(),model:P(),provider:P(),cwd:P(),timestamp:xe()}),v7=se({type:Be("session-stop"),id:P(),reason:P(),timestamp:xe()}),b7=se({type:Be("hook"),id:P(),phase:P(),name:P(),result:P().optional(),error:P().optional(),timestamp:xe()}),w7=se({type:Be("status"),id:P(),message:P(),spinner:Jg().optional(),timestamp:xe()}),S7=se({type:Be("session-resumed"),id:P(),turnsRecovered:xe(),timestamp:xe()}),_7=se({type:Be("context-warning"),id:P(),message:P(),timestamp:xe()}),k7=se({type:Be("compaction"),id:P(),summary:P(),summarizedMessageCount:xe(),tokensBefore:xe(),tokensAfter:xe(),timestamp:xe()}),N7=se({type:Be("context-report"),id:P(),model:P(),windowTokens:xe(),usedTokens:xe(),reservedOutput:xe(),breakdown:Dr(se({label:P(),tokens:xe()})),timestamp:xe()}),j7=se({type:Be("cron-task-fired"),id:P(),taskId:P(),taskType:De(["notify","agent","auto"]),message:P(),timestamp:xe()}),E7=se({type:Be("heartbeat-brief"),id:P(),scheduleType:De(["intraday","daily","weekly","monthly","dreaming"]),formattedText:P(),toolCalls:xe(),errors:Dr(P()),timestamp:xe()}),T7=se({type:Be("channel-updated"),id:P(),channelId:P(),channelType:De(["cli","telegram"]),displayName:P(),sessionId:P(),timestamp:xe()}),A7=se({type:Be("mcp-status"),id:P(),serverId:P(),connected:Jg(),tools:Dr(P()),timestamp:xe()}),C7=se({type:Be("daemon-ready"),id:P(),version:P(),timestamp:xe()}),M7=se({type:Be("wiki-op"),id:P(),op:De(["ingest","query","lint","edit"]),pages:Dr(P()),timestamp:xe()});I9("type",[c7,u7,d7,f7,h7,p7,m7,g7,x7,y7,v7,b7,w7,S7,_7,k7,N7,j7,E7,T7,A7,C7,M7]);const z7=se({jsonrpc:Be("2.0"),id:lc([xe(),P()]),method:P(),params:ga(P(),zn()).optional()}),D7=se({jsonrpc:Be("2.0"),method:P(),params:ga(P(),zn()).optional()}),R7=se({jsonrpc:Be("2.0"),id:lc([xe(),P()]),result:zn()}),O7=se({jsonrpc:Be("2.0"),id:lc([xe(),P()]),error:se({code:xe(),message:P(),data:zn().optional()})});lc([z7,D7,R7,O7]);se({});se({id:P()});se({id:P(),text:P()});se({id:P()});se({id:P().optional()});se({});se({paneIds:Dr(P()),text:P()});se({query:P()});se({slug:P()});se({source:P()});se({});se({});se({sessionId:P().optional()});se({toolCallId:P(),decision:De(["allow","deny"])});se({});se({});se({key:P()});se({key:P(),value:zn()});se({});se({});se({type:De(["reminder","heartbeat","task"]).optional(),status:De(["pending","fired","executing","completed","failed","cancelled"]).optional()});se({type:De(["reminder","task"]),message:P(),scheduledAt:xe(),schedule:se({type:De(["intraday","daily","weekly","monthly","dreaming"]),value:P()}).optional()});se({id:P()});se({});se({scheduleType:De(["intraday","daily","weekly","monthly","dreaming"]).optional()});se({});se({});se({channelId:P()});se({});se({});se({provider:P(),apiKey:P(),model:P(),soulName:P(),soulVibe:P(),userName:P(),userTimezone:P(),userLanguages:P()});se({sessionId:P(),prompt:P(),provider:De(["anthropic","openai","google","ollama","openrouter"]).optional(),mode:De(["plan","edit","auto","yolo"]).optional(),effort:De(["low","medium","high","max","auto"]).optional(),model:P().optional(),tools:Dr(P()).optional()});se({sessionId:P().optional(),status:De(["running","completed","error","cancelled"]).optional()});se({agentId:P()});se({agentId:P()});se({agentId:P(),message:P()});se({instruction:P(),scheduled_at:P(),provider:P().optional(),model:P().optional(),effort:De(["low","medium","high","max","auto"]).optional()});se({status:De(["backlog","todo","in_progress","done","canceled","pending","executing","completed","failed"]).optional(),mode:De(["human","agent","notify"]).optional(),scope:De(["personal","project"]).optional(),priority:De(["low","medium","high","critical"]).optional()});se({title:P(),description:P().default(""),mode:De(["human","agent","notify"]).default("human"),scope:De(["personal","project"]).default("personal"),priority:De(["low","medium","high","critical"]).default("medium"),tags:Dr(P()).default([]),status:De(["backlog","todo","in_progress","done","canceled","pending","executing","completed","failed"]).optional(),scheduled_at:xe().optional()});se({id:P(),status:De(["backlog","todo","in_progress","done","canceled","pending","executing","completed","failed"]).optional(),priority:De(["low","medium","high","critical"]).optional(),title:P().optional(),description:P().optional(),tags:Dr(P()).optional(),mode:De(["human","agent","notify"]).optional(),scope:De(["personal","project"]).optional(),scheduled_at:xe().optional()});se({id:P()});const $7=[{name:"status",description:"Show version, model, and account info",usage:"/status",category:"General",handler:"daemon"},{name:"help",description:"Show all available commands",usage:"/help",category:"General",handler:"daemon"},{name:"system",description:"Show OS, platform, Node version, and PathGuard status",usage:"/system",category:"General",handler:"daemon"},{name:"init",description:"Run the setup wizard",usage:"/init",category:"General",handler:"client"},{name:"exit",description:"Exit curie-agent",usage:"/exit",category:"General",handler:"client",aliases:["quit"]},{name:"provider",description:"Switch AI provider",usage:"/provider <anthropic|openai|google|local|ollama|openrouter>",category:"Model & Provider",handler:"daemon"},{name:"model",description:"Switch AI model, set pricing or context window",usage:"/model <model|pricing in;out|window tokens>",category:"Model & Provider",handler:"daemon"},{name:"effort",description:"Set reasoning effort level",usage:"/effort <low|medium|high|max|auto>",category:"Model & Provider",handler:"daemon"},{name:"mode",description:"Set approval mode",usage:"/mode <plan|edit|auto|yolo>",category:"Model & Provider",handler:"daemon"},{name:"theme",description:"Change color theme",usage:"/theme <name>",category:"Display",handler:"client"},{name:"debug",description:"Toggle debug logging",usage:"/debug [on|off]",category:"Display",handler:"client"},{name:"statusline",description:"Toggle status line display",usage:"/statusline [on|off]",category:"Display",handler:"client"},{name:"memory",description:"View memory file sizes or capture a memory",usage:"/memory [status|add <text>]",category:"Knowledge",handler:"daemon"},{name:"todo",description:"Manage tasks in tasks.json",usage:"/todo <list|add|complete|remove>",category:"Knowledge",handler:"daemon"},{name:"stats",description:"Daily usage, sessions, streaks",usage:"/stats",category:"Knowledge",handler:"client"},{name:"context",description:"Context window usage breakdown, compaction, auto-compaction settings",usage:"/context [messages|compact|auto [on|off|threshold N|warn N|forced N|pricing on/off]]",category:"Knowledge",handler:"daemon"},{name:"wiki",description:"Open the wiki tab or run a wiki operation",usage:"/wiki [list|search <query>|lint|status]",category:"Knowledge",handler:"client"},{name:"remind",description:"Create a reminder",usage:"/remind <message at time>",category:"Automation",handler:"daemon"},{name:"cron",description:"Manage reminders",usage:"/cron <list|delete <id>|clear>",category:"Automation",handler:"daemon"},{name:"task",description:"Schedule an agent task",usage:"/task <create|list|delete>",category:"Automation",handler:"daemon"},{name:"heartbeat",description:"Manage heartbeat cycle",usage:"/heartbeat <status|enable|disable|intraday|daily|weekly|monthly|dreaming|now>",category:"Automation",handler:"daemon"},{name:"agent",description:"Launch external AI agent",usage:"/agent <prompt>",category:"Tools",handler:"daemon"},{name:"tools",description:"View/set tool call limits per turn",usage:"/tools [tools_per_call [websearch_per_call]]",category:"Tools",handler:"daemon"},{name:"websearch",description:"View/set web search+fetch limit per turn",usage:"/websearch [count]",category:"Tools",handler:"daemon"},{name:"mcp",description:"Manage MCP server connections",usage:"/mcp <list|reload>",category:"Tools",handler:"daemon"},{name:"skill",description:"List or show available skills",usage:"/skill [name]",category:"Tools",handler:"daemon"},{name:"channels",description:"Manage Telegram channel config",usage:"/channels <list|switch <id>|set-bot-token <t>|set-user-id <id>|set-chat-id <id>|disconnect>",category:"Communication",handler:"client"},{name:"cd",description:"Change working directory with safety checks",usage:"/cd <path>",category:"Safety",handler:"daemon"},{name:"snapshots",description:"List recent git snapshots for recovery",usage:"/snapshots",category:"Safety",handler:"daemon"},{name:"revert",description:"Revert to a git snapshot (index, default: most recent)",usage:"/revert [index]",category:"Safety",handler:"daemon"}],L7=se({type:Be("object"),properties:ga(P(),zn()),required:Dr(P()).optional(),additionalProperties:Jg().optional()});se({name:P(),description:P(),inputSchema:L7});se({id:P(),name:P(),input:ga(P(),zn())});se({id:P(),output:zn(),error:P().optional()});const H7=new Set(["wiki"]),rb=$7.filter(e=>e.handler==="daemon"||H7.has(e.name)).map(e=>[e.usage||`/${e.name}`,e.description]);function B7({open:e,onClose:t,onPick:n}){const[r,s]=w.useState(""),[i,o]=w.useState(0),a=w.useRef(null),c=r?rb.filter(([f,h])=>f.includes(r.toLowerCase())||h.toLowerCase().includes(r.toLowerCase())):rb,u=w.useCallback(f=>{t(),n(f)},[t,n]);w.useEffect(()=>{e&&(s(""),o(0),setTimeout(()=>{var f;return(f=a.current)==null?void 0:f.focus()},50))},[e]);const d=w.useCallback(f=>{if(f.key==="Escape"){t();return}f.key==="ArrowDown"&&(o(h=>Math.min(h+1,c.length-1)),f.preventDefault()),f.key==="ArrowUp"&&(o(h=>Math.max(h-1,0)),f.preventDefault()),f.key==="Enter"&&c[i]&&u(c[i][0])},[c,i,t,u]);return e?l.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[120px]",style:{background:"rgba(10, 8, 5, 0.85)",backdropFilter:"blur(8px)"},onClick:t,children:l.jsxs("div",{className:"w-[560px] rounded-xl overflow-hidden animate-scaleIn",style:{background:"linear-gradient(135deg, var(--s2) 0%, var(--s1) 100%)",border:"1px solid var(--b2)",boxShadow:"0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.03)"},onClick:f=>f.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",style:{borderBottom:"1px solid var(--b1)"},children:[l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"var(--gold)",strokeWidth:"1.5",className:"shrink-0",style:{opacity:.7},children:[l.jsx("circle",{cx:"11",cy:"11",r:"8"}),l.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),l.jsx("input",{ref:a,className:"flex-1 bg-transparent border-0 outline-none font-sans text-sm",style:{color:"var(--cream)"},placeholder:"Search commands...",value:r,onChange:f=>{s(f.target.value),o(0)},onKeyDown:d})]}),l.jsx("div",{className:"gold-divider"}),l.jsxs("div",{className:"max-h-[340px] overflow-y-auto py-1 scrollbar-thin",children:[c.map(([f,h],p)=>l.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 mx-1",style:{background:p===i?"var(--s3)":"transparent",borderLeft:p===i?"2px solid var(--gold)":"2px solid transparent"},onClick:()=>u(f),children:[l.jsx("span",{className:"font-mono text-[12.5px] min-w-[190px]",style:{color:p===i?"var(--gold)":"var(--text)"},children:f}),l.jsx("span",{className:"text-xs text-muted truncate",children:h})]},f)),c.length===0&&l.jsx("div",{className:"px-3 py-6 text-center text-muted text-sm",children:"No commands found"})]})]})}):null}const Wi={anthropic:{label:"Anthropic",defaultModel:"claude-sonnet-4-6",requiresKey:!0},openai:{label:"OpenAI",defaultModel:"gpt-4o",requiresKey:!0},local:{label:"Local (OpenAI-compatible)",defaultModel:"custom",requiresKey:!1},openrouter:{label:"OpenRouter",defaultModel:"anthropic/claude-sonnet-4-6",requiresKey:!0},ollama:{label:"Ollama (Local)",defaultModel:"custom",requiresKey:!1}};function U7({rpc:e,onComplete:t,className:n}){const[r,s]=w.useState("provider"),[i,o]=w.useState(null),[a,c]=w.useState(""),[u,d]=w.useState(""),[f,h]=w.useState(""),[p,x]=w.useState(""),[b,S]=w.useState(""),[m,y]=w.useState(""),[g,v]=w.useState(""),[N,k]=w.useState(!1),[T,z]=w.useState(null),A=w.useCallback(()=>{switch(z(null),r){case"provider":{if(!i)return;const _=Wi[i];d(_.defaultModel),s(_.requiresKey?"api_key":"model");break}case"api_key":s("model");break;case"model":s("soul_name");break;case"soul_name":if(!f.trim())return;s("soul_vibe");break;case"soul_vibe":s("user_name");break;case"user_name":if(!b.trim())return;s("user_tz");break;case"user_tz":s("user_lang");break;case"user_lang":s("agents");break;case"agents":s("memory");break;case"memory":s("tools");break;case"tools":s("confirm");break}},[r,i,f,b]),L=w.useCallback(async()=>{if(!(!e||!i)){k(!0),z(null);try{await e.identitySetup({provider:i,apiKey:a,model:u,soulName:f.trim()||"Curie",soulVibe:p.trim()||"AI coding assistant — sharp, resourceful, gets things done",userName:b.trim()||"User",userTimezone:m.trim()||"UTC",userLanguages:g.trim()||"TypeScript, Python"}),t()}catch(_){z(_ instanceof Error?_.message:"Setup failed")}finally{k(!1)}}},[e,i,a,u,f,p,b,m,g,t]),R=()=>{switch(r){case"provider":return"Choose your provider";case"api_key":return"API key";case"model":return"Select a model";case"soul_name":return"Name your assistant";case"soul_vibe":return"Define the vibe";case"user_name":return"Your name";case"user_tz":return"Timezone";case"user_lang":return"Programming languages";case"agents":return"Workspace configuration";case"memory":return"Memory";case"tools":return"Tools";case"confirm":return"Review & create"}},H=()=>(["provider","api_key","model","soul_name","soul_vibe","user_name","user_tz","user_lang","agents","memory","tools","confirm"].indexOf(r)+1)/12,Y=()=>{switch(r){case"provider":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted mb-4",children:"Which LLM provider do you want to use for your AI assistant?"}),l.jsx("div",{className:"grid grid-cols-1 gap-2",children:Object.entries(Wi).map(([_,C])=>l.jsxs("button",{type:"button",onClick:()=>o(_),className:`flex items-center gap-3 px-4 py-3 rounded-xl border text-left transition-all duration-100 ${i===_?"border-blue-500 bg-blue-500/10 text-text":"border-b2 bg-s2 text-text hover:border-b3 hover:bg-s2/80"}`,children:[l.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center shrink-0 ${i===_?"border-blue-500":"border-b3"}`,children:i===_&&l.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500"})}),l.jsxs("div",{children:[l.jsx("div",{className:"text-xs font-medium text-text",children:C.label}),l.jsxs("div",{className:"text-[10.5px] text-muted",children:["Model: ",C.defaultModel]})]})]},_))})]});case"api_key":{const _=Wi[i];return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("p",{className:"text-xs text-muted",children:["Enter your ",_.label," API key:"]}),l.jsx("input",{type:"password",value:a,onChange:C=>c(C.target.value),placeholder:"sk-...",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text font-mono placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0}),l.jsx("p",{className:"text-[10px] text-muted",children:"Saved to ~/.curie-settings.json"})]})}case"model":{const _=Wi[i];return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("p",{className:"text-xs text-muted",children:["Suggested model: ",l.jsx("code",{className:"text-text font-mono",children:_.defaultModel})]}),l.jsx("input",{type:"text",value:u,onChange:C=>d(C.target.value),placeholder:"Enter model name or accept the default",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text font-mono placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]})}case"soul_name":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"What should your AI assistant's name be?"}),l.jsx("input",{type:"text",value:f,onChange:_=>h(_.target.value),placeholder:"Curie",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]});case"soul_vibe":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"Describe your assistant's vibe/personality (1 sentence)."}),l.jsx("input",{type:"text",value:p,onChange:_=>x(_.target.value),placeholder:"AI coding assistant — sharp, resourceful, gets things done",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]});case"user_name":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"What is your name?"}),l.jsx("input",{type:"text",value:b,onChange:_=>S(_.target.value),placeholder:"Paweł",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]});case"user_tz":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"Your timezone?"}),l.jsx("input",{type:"text",value:m,onChange:_=>y(_.target.value),placeholder:"Europe/Warsaw",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text font-mono placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]});case"user_lang":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"Your primary programming languages?"}),l.jsx("input",{type:"text",value:g,onChange:_=>v(_.target.value),placeholder:"TypeScript, Python",className:"w-full px-3 py-2.5 bg-[#0d1117] border border-b2 rounded-xl text-xs text-text placeholder-slate-600 focus:outline-none focus:border-blue-500/70 transition-colors",autoFocus:!0})]});case"agents":return l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted",children:"Next: I'll create your workspace configuration files."}),l.jsxs("div",{className:"p-3 bg-s2 border border-b1 rounded-xl text-[10.5px] text-text leading-relaxed",children:[l.jsx("p",{className:"font-medium mb-1",children:"AGENTS.md will include:"}),l.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-muted",children:[l.jsx("li",{children:"Session startup instructions"}),l.jsx("li",{children:"Memory system (daily notes + long-term)"}),l.jsx("li",{children:"Coding agent capabilities"}),l.jsx("li",{children:"Red lines and safety boundaries"}),l.jsx("li",{children:"Heartbeat configuration"})]})]})]});case"memory":return l.jsx("div",{className:"space-y-3",children:l.jsx("div",{className:"p-3 bg-s2 border border-b1 rounded-xl text-xs text-text leading-relaxed",children:l.jsx("p",{children:"Auto-creating MEMORY.md with initialization entry..."})})});case"tools":return l.jsx("div",{className:"space-y-3",children:l.jsx("div",{className:"p-3 bg-s2 border border-b1 rounded-xl text-xs text-text leading-relaxed",children:l.jsx("p",{children:"Auto-creating TOOLS.md and HEARTBEAT.md..."})})});case"confirm":return l.jsxs("div",{className:"space-y-4",children:[l.jsx("p",{className:"text-xs text-muted",children:"Review your configuration before creating files:"}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_s,{label:"Provider",value:Wi[i].label}),l.jsx(_s,{label:"Model",value:u}),l.jsx(_s,{label:"API Key",value:a?"[set]":"(not set)"}),l.jsx(_s,{label:"Assistant Name",value:f.trim()||"Curie"}),l.jsx(_s,{label:"Vibe",value:p.trim()||"AI coding assistant"}),l.jsx(_s,{label:"Your Name",value:b.trim()||"User"}),l.jsx(_s,{label:"Timezone",value:m.trim()||"UTC"}),l.jsx(_s,{label:"Languages",value:g.trim()||"TypeScript, Python"})]}),l.jsxs("div",{className:"p-3 bg-s2 border border-b1 rounded-xl text-[10.5px] text-muted leading-relaxed",children:["Identity files to be created:",l.jsxs("ul",{className:"list-disc list-inside mt-1",children:[l.jsx("li",{children:"~/.curie-agent/SOUL.md"}),l.jsx("li",{children:"~/.curie-agent/USER.md"}),l.jsx("li",{children:"~/.curie-agent/AGENTS.md"}),l.jsx("li",{children:"~/.curie-agent/MEMORY.md"}),l.jsx("li",{children:"~/.curie-agent/TOOLS.md"}),l.jsx("li",{children:"~/.curie-agent/HEARTBEAT.md"})]})]})]})}};return l.jsx("div",{className:`flex-1 overflow-y-auto p-7 scrollbar-thin flex flex-col ${n||""}`,children:l.jsxs("div",{className:"max-w-lg mx-auto w-full",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h2",{className:"text-base font-semibold text-fg tracking-tight mb-1",children:"Setup Wizard"}),l.jsx("p",{className:"text-[11px] text-muted",children:"Configure your AI assistant — takes about 2 minutes"})]}),l.jsx("div",{className:"mb-5",children:l.jsx("div",{className:"h-1 bg-b2 rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-blue-500 rounded-full transition-all duration-300",style:{width:`${H()*100}%`}})})}),l.jsx("h3",{className:"text-sm font-medium text-text mb-4",children:R()}),l.jsx("div",{className:"mb-6",children:Y()}),T&&l.jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded-xl text-red-400 text-xs flex items-start gap-2.5 mb-4",children:[l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"shrink-0 mt-0.5",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),l.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),l.jsx("span",{children:T})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r!=="provider"&&r!=="confirm"?l.jsxs("button",{type:"button",onClick:()=>{switch(z(null),r){case"api_key":s("provider");break;case"model":s(Wi[i].requiresKey?"api_key":"provider");break;case"soul_name":s("provider");break;case"soul_vibe":s("soul_name");break;case"user_name":s("soul_vibe");break;case"user_tz":s("user_name");break;case"user_lang":s("user_tz");break;case"agents":s("user_lang");break;case"memory":s("agents");break;case"tools":s("memory");break}},className:"flex items-center gap-1 bg-transparent border border-b2 rounded px-3 py-2 text-muted text-xs hover:border-b3 hover:text-fg transition-colors duration-100",children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:l.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back"]}):l.jsx("div",{}),r==="confirm"?l.jsx("button",{type:"button",onClick:L,disabled:N,className:"flex items-center gap-2 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-500 hover:to-indigo-500 text-white font-semibold text-xs px-5 py-2 rounded-xl shadow-lg shadow-blue-500/10 disabled:opacity-50 disabled:pointer-events-none active:scale-[0.98] transition-all duration-150",children:N?l.jsxs(l.Fragment,{children:[l.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 text-white",fill:"none",viewBox:"0 0 24 24",children:[l.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Creating..."]}):"Create Setup"}):l.jsxs("button",{type:"button",onClick:A,disabled:r==="provider"&&!i||r==="soul_name"&&!f.trim()||r==="user_name"&&!b.trim(),className:"flex items-center gap-2 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-500 hover:to-indigo-500 text-white font-semibold text-xs px-5 py-2 rounded-xl shadow-lg shadow-blue-500/10 disabled:opacity-50 disabled:pointer-events-none active:scale-[0.98] transition-all duration-150",children:["Next",l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[l.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),l.jsx("polyline",{points:"12 5 19 12 12 19"})]})]})]})]})})}function _s({label:e,value:t}){return l.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-b1/50",children:[l.jsx("span",{className:"text-[10.5px] text-muted",children:e}),l.jsx("span",{className:"text-[10.5px] text-text font-mono",children:t})]})}function I7({onReload:e}){const[t,n]=w.useState(!1);w.useEffect(()=>{const s=()=>n(!0),i=()=>{n(!1),e==null||e()};return window.addEventListener("pwa-update-available",s),window.addEventListener("pwa-controller-updated",i),()=>{window.removeEventListener("pwa-update-available",s),window.removeEventListener("pwa-controller-updated",i)}},[e]);const r=()=>{n(!1),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(s=>{s.waiting&&s.waiting.postMessage("SKIP_WAITING")}),window._pendingUpdateWorker&&window._pendingUpdateWorker.postMessage("SKIP_WAITING")};return t?l.jsxs("div",{className:"bg-blue-500/10 border-b border-blue-500/20 text-blue-400 px-4 py-2 text-center text-xs font-semibold flex items-center justify-center gap-2 select-none shrink-0 z-50 animate-fadeIn",children:[l.jsxs("svg",{className:"animate-bounce shrink-0",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),l.jsx("polyline",{points:"17 8 12 3 7 8"}),l.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),"Update available",l.jsx("button",{onClick:r,className:"bg-blue-500/20 border border-blue-500/40 text-blue-400 px-2 py-0.5 rounded-[4px] text-[11px] font-bold cursor-pointer hover:bg-blue-500/30 transition-all duration-100",children:"Update"})]}):null}const Z7="0.2.4";function Y7({intervalMs:e=3*60*1e3,onNewVersion:t}){const[n,r]=w.useState(!1);return w.useEffect(()=>{async function s(){var o;try{const c=await(await fetch("/health?token="+encodeURIComponent(((o=document.cookie.match(/curie_token=([^;]*)/))==null?void 0:o[1])??""),{cache:"no-store"})).json();c.version&&c.version!==Z7&&!n&&(r(!0),t==null||t(c.version),window.dispatchEvent(new CustomEvent("pwa-version-update")))}catch{}}s();const i=setInterval(s,e);return()=>clearInterval(i)},[e,n,t]),null}function q7(){const{rpc:e,ws:t}=fr(),[n,r]=w.useState([]),s=w.useCallback(()=>{e&&e.sessionList().then(i=>{Array.isArray(i)&&r(i)}).catch(()=>{})},[e]);return w.useEffect(()=>{s()},[s]),w.useEffect(()=>{if(!t)return;const i=["user-prompt","assistant-stop","error","session-start","session-resumed"],o=[];for(const a of i)o.push(t.on(a,s));return()=>{for(const a of o)a()}},[t,s]),{sessions:n,refetch:s}}function V7(e){const{rpc:t,ws:n}=fr(),[r,s]=w.useState(null),[i,o]=w.useState([]),[a,c]=w.useState(!1),[u,d]=w.useState(null);w.useEffect(()=>{if(!t||!e){s(null),o([]),c(!1);return}c(!0),t.sessionGet(e).then(h=>{h!=null&&h.info&&s(h.info),h!=null&&h.events&&o(h.events)}).catch(()=>{}).finally(()=>c(!1))},[t,e]),w.useEffect(()=>{if(!n||!e)return;const h=b=>{if(b.type!=="heartbeat-brief"&&b.type!=="cron-task-fired"){const S=b.sessionId||b.id;if(S&&S!==e)return}o(S=>S.slice(-10).some(y=>y.timestamp===b.timestamp&&y.type===b.type&&JSON.stringify(y)===JSON.stringify(b))?S:[...S,b])},p=[],x=["user-prompt","assistant-delta","assistant-stop","tool-call","tool-result","error","status","usage","thinking-delta","heartbeat-brief","approval-request","approval-decision","context-warning","cron-task-fired","compaction"];for(const b of x)p.push(n.on(b,h));return p.push(n.on("context-report",b=>{const S=b.sessionId;S&&S!==e||d({model:String(b.model??""),windowTokens:Number(b.windowTokens??0),usedTokens:Number(b.usedTokens??0),reservedOutput:Number(b.reservedOutput??0),breakdown:b.breakdown??[]})})),()=>{for(const b of p)b()}},[n,e]);const f=w.useCallback(h=>{o(p=>[...p,h])},[]);return{info:r,events:i,loading:a,addLiveEvent:f,contextReport:u}}function G7({onAuthorize:e}){const[t,n]=w.useState(""),[r,s]=w.useState(!1),[i,o]=w.useState(null),a=async c=>{if(c.preventDefault(),!!t.trim()){s(!0),o(null);try{(await fetch("/health",{headers:{Authorization:`Bearer ${t.trim()}`}})).ok?e(t.trim()):o("Invalid Access Token. Please verify and try again.")}catch{o("Cannot connect to Curie Daemon. Make sure the daemon is running.")}finally{s(!1)}}};return l.jsxs("div",{className:"flex min-h-screen w-screen items-center justify-center p-4 font-sans select-none relative overflow-hidden",style:{background:"#0e0b08",color:"var(--cream, #f5e6d0)"},children:[l.jsx("div",{className:"absolute top-[-20%] left-[-20%] w-[60%] h-[60%] rounded-full opacity-30 blur-[120px] pointer-events-none",style:{background:"#2d1f0e"}}),l.jsx("div",{className:"absolute bottom-[-20%] right-[-20%] w-[60%] h-[60%] rounded-full opacity-25 blur-[120px] pointer-events-none",style:{background:"#1e1408"}}),l.jsx("div",{className:"absolute top-[40%] left-[50%] w-[40%] h-[40%] rounded-full opacity-15 blur-[100px] pointer-events-none",style:{background:"#d4a54a",transform:"translate(-50%, -50%)"}}),l.jsxs("div",{className:"w-full max-w-[440px] rounded-2xl shadow-2xl p-7 flex flex-col items-center animate-scaleIn relative z-10",style:{background:"linear-gradient(135deg, rgba(34, 28, 22, 0.95), rgba(20, 16, 12, 0.98))",backdropFilter:"blur(24px)",border:"1px solid rgba(86, 72, 58, 0.5)",boxShadow:"0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(245,230,208,0.04)"},children:[l.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px] rounded-t-2xl",style:{background:"linear-gradient(90deg, transparent, #d4a54a, transparent)"}}),l.jsxs("div",{className:"flex flex-col items-center gap-3 mb-6 mt-2",children:[l.jsxs("div",{className:"relative group",children:[l.jsx("div",{className:"absolute inset-0 rounded-xl blur-md group-hover:blur-lg transition-all duration-300 animate-gold-pulse",style:{background:"rgba(212, 165, 74, 0.2)"}}),l.jsx("img",{src:"/icons/logo-512.png",alt:"Curie Logo",className:"w-14 h-14 object-contain rounded-xl relative z-10 transform group-hover:scale-105 transition-transform duration-300",style:{border:"1px solid rgba(86, 72, 58, 0.6)",boxShadow:"0 4px 16px rgba(0,0,0,0.4)"}})]}),l.jsxs("div",{className:"text-center mt-1",children:[l.jsx("span",{className:"text-xl font-display font-bold gold-shimmer block",children:"curie-agent"}),l.jsx("span",{className:"text-[10px] font-mono block mt-0.5",style:{color:"#d4a54a",opacity:.6},children:"v0.2.4"})]})]}),l.jsxs("div",{className:"text-center mb-6",children:[l.jsx("h2",{className:"text-sm font-semibold mb-2",style:{color:"#f5e6d0"},children:"Authorize this device"}),l.jsx("p",{className:"text-[12.5px] leading-relaxed px-2",style:{color:"#8b7355"},children:"Curie requires a secure daemon connection. Enter your access token below to authorize this device and start planning."})]}),l.jsxs("form",{onSubmit:a,className:"w-full space-y-4",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-wider block ml-1",style:{color:"#d4a54a",opacity:.7},children:"Daemon Access Token"}),l.jsxs("div",{className:"relative group",children:[l.jsx("div",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none transition-colors duration-200",style:{color:"#8b7355"},children:l.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:l.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})})}),l.jsx("input",{type:"password",required:!0,placeholder:"Paste your daemon.token...",value:t,onChange:c=>n(c.target.value),disabled:r,className:"w-full pl-10 pr-4 py-2.5 rounded-xl text-[13px] font-mono focus:outline-none transition-all duration-200",style:{background:"rgba(14, 11, 8, 0.8)",border:"1px solid rgba(86, 72, 58, 0.4)",color:"#f5e6d0"}})]})]}),i&&l.jsxs("div",{className:"p-3 rounded-xl text-xs flex items-start gap-2.5 animate-fadeIn",style:{background:"color-mix(in srgb, var(--red) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--red) 20%, transparent)",color:"var(--red)"},children:[l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"shrink-0 mt-0.5",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),l.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),l.jsx("span",{children:i})]}),l.jsx("button",{type:"submit",disabled:r||!t.trim(),className:"btn-gold w-full py-2.5 px-4 rounded-xl font-semibold text-xs active:scale-[0.98] transition-all duration-150 disabled:opacity-50 disabled:pointer-events-none cursor-pointer flex items-center justify-center gap-2",children:r?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"w-3.5 h-3.5 rounded-full animate-spin",style:{background:"conic-gradient(from 0deg, transparent, #1a1410)",mask:"radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 0)",WebkitMask:"radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 0)"}}),"Verifying Credentials..."]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{children:"Authorize & Connect"}),l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[l.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),l.jsx("polyline",{points:"12 5 19 12 12 19"})]})]})})]}),l.jsxs("div",{className:"w-full mt-6 pt-5 space-y-2 leading-relaxed",style:{borderTop:"1px solid rgba(86, 72, 58, 0.3)",fontSize:"11.5px",color:"#8b7355"},children:[l.jsx("div",{className:"font-semibold",style:{color:"#bfae94"},children:"Where is my token?"}),l.jsx("p",{children:"When starting the daemon, look for the console output in your terminal. It displays the dashboard link containing the secure token."}),l.jsxs("p",{children:["You can also find the raw token inside the file ",l.jsx("code",{className:"font-mono px-1 py-0.5 rounded text-[10.5px]",style:{background:"rgba(14, 11, 8, 0.6)",border:"1px solid rgba(86, 72, 58, 0.3)",color:"#d4c4a8"},children:"~/.curie-agent/daemon.token"})," on your host machine."]})]})]})]})}const X7=["plan","edit","auto","yolo"],P7=[{view:"assistant",label:"Assistant",icon:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"},{view:"channels",label:"Channels",icon:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07A19.5 19.5 0 0 1 4.86 13a19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 3.77 2h3a2 2 0 0 1 2 1.72c.127.96.361 1.903.7 2.81a2 2 0 0 1-.45 2.11L7.91 9.91a16 16 0 0 0 6.16 6.16l1.27-1.27a2 2 0 0 1 2.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0 1 22 16.92z"},{view:"stats",label:"Stats",icon:"M18 20V10M12 20V4M6 20v-6"},{view:"projects",label:"Projects",icon:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"},{view:"agents",label:"Agents",icon:"M12 8c0 2.21-1.79 4-4 4s-4-1.79-4-4 1.79-4 4-4 4 1.79 4 4zm-6 12v-2a6 6 0 0 1 12 0v2"},{view:"kanban",label:"Tasks",icon:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"},{view:"wiki",label:"Wiki",icon:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"},{view:"settings",label:"Settings",icon:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}];function F7(){const{rpc:e,connected:t,token:n,setToken:r}=fr(),{get:s,set:i,providers:o}=og(),[a,c]=w.useState("assistant"),u=s("mode")||"auto",[d,f]=w.useState(!1),[h,p]=w.useState(""),[x,b]=w.useState(null),[S,m]=w.useState(!1),[y,g]=w.useState(null),[v,N]=w.useState(navigator.onLine),[k,T]=w.useState(!1),[z,A]=w.useState(!1),[L,R]=w.useState(!1),[H,Y]=w.useState(!1),_=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;w.useEffect(()=>{const G=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone===!0;T(!!G)},[]),w.useEffect(()=>{const G=ie=>{ie.preventDefault(),g(ie)},te=()=>N(!0),le=()=>N(!1);return window.addEventListener("beforeinstallprompt",G),window.addEventListener("online",te),window.addEventListener("offline",le),()=>{window.removeEventListener("beforeinstallprompt",G),window.removeEventListener("online",te),window.removeEventListener("offline",le)}},[]);const C=async()=>{if(y){y.prompt();const{outcome:G}=await y.userChoice;console.log(`PWA install prompt choice: ${G}`),g(null)}else A(!0)},{sessions:j,refetch:D}=q7(),{events:O,addLiveEvent:$,contextReport:U}=V7(x),X=s("theme")||"curie";w.useEffect(()=>{document.documentElement.setAttribute("data-theme",X)},[X]),w.useEffect(()=>{const G=()=>m(window.innerWidth<768);return G(),window.addEventListener("resize",G),()=>window.removeEventListener("resize",G)},[]),w.useEffect(()=>{!t||!e||e.configGet("current_provider").then(G=>{G||R(!0)}).catch(()=>{})},[t,e]);const Z=w.useCallback(()=>{b(null)},[]),B=w.useCallback(G=>{b(G)},[]),E=w.useCallback(G=>{b(G),c("assistant")},[]),q=w.useCallback(G=>{b(G),D()},[D]);w.useEffect(()=>{const G=te=>{(te.metaKey||te.ctrlKey)&&te.key==="k"&&(te.preventDefault(),f(!0))};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[]);const V=w.useCallback(G=>{p(G),f(!1)},[]),J=w.useCallback(()=>{p("")},[]),F=(G,te=18)=>l.jsx("svg",{width:te,height:te,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:l.jsx("path",{d:G.icon})});return n?l.jsxs("div",{className:"flex h-dvh w-screen flex-col overflow-hidden bg-bg coffee-pattern",children:[!v&&l.jsxs("div",{className:"px-4 py-2 text-center text-xs font-semibold flex items-center justify-center gap-2 select-none shrink-0 z-50 animate-fadeIn",style:{background:"color-mix(in srgb, var(--yellow) 10%, transparent)",borderBottom:"1px solid color-mix(in srgb, var(--yellow) 20%, transparent)",color:"var(--yellow)"},children:[l.jsxs("svg",{className:"animate-pulse shrink-0",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),l.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),l.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),"Offline Mode — Curie is running on cached local client"]}),l.jsx(I7,{}),l.jsx(Y7,{}),l.jsxs("main",{className:"flex flex-1 flex-col overflow-hidden bg-bg",children:[l.jsxs("div",{className:"topbar-wood flex h-12 items-center gap-3 px-4 shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs("button",{className:"relative flex items-center justify-center w-8 h-8 rounded-lg transition-all duration-150",style:{color:H?"var(--fg)":"var(--muted)",background:H?"var(--s3)":"transparent",border:H?"1px solid var(--b1)":"1px solid transparent"},onClick:()=>Y(!0),title:"Sessions",children:[l.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:l.jsx("path",{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"})}),j.length>0&&l.jsx("span",{className:"absolute -top-0.5 -right-0.5 text-[9px] font-bold rounded-full w-4 h-4 flex items-center justify-center",style:{background:"var(--gold)",color:"#1a1410"},children:j.length>99?"99+":j.length})]}),l.jsx("div",{className:"w-px h-5 bg-b1 mx-0.5"}),P7.map(G=>l.jsx("button",{className:"flex items-center justify-center w-8 h-8 rounded-lg transition-all duration-150 cursor-pointer",style:{color:a===G.view?"var(--gold)":"var(--muted)",background:a===G.view?"var(--s3)":"transparent",border:a===G.view?"1px solid var(--b1)":"1px solid transparent"},onClick:()=>c(G.view),title:G.label,children:F(G,18)},G.view))]}),l.jsx("div",{className:"flex-1"}),window.innerWidth>=640&&l.jsx("div",{className:"flex rounded-lg overflow-hidden",style:{border:"1px solid var(--b2)",background:"var(--bg)"},children:X7.map(G=>l.jsx("button",{className:"px-2.5 py-1 text-xs cursor-pointer transition-all duration-150 font-mono select-none",style:{color:u===G?"var(--gold)":"var(--muted)",background:u===G?"var(--s3)":"transparent",borderRight:"1px solid var(--b1)"},onClick:()=>i("mode",G),children:G},G))}),(y||S&&!k)&&l.jsxs("button",{onClick:C,className:"flex items-center justify-center rounded-lg transition-all duration-150 px-2.5 py-1 gap-1.5 text-xs font-semibold cursor-pointer shrink-0",style:{background:"var(--bg)",border:"1px solid color-mix(in srgb, var(--green) 30%, transparent)",color:"var(--green)"},children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),l.jsx("polyline",{points:"7 10 12 15 17 10"}),l.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),!S&&l.jsx(l.Fragment,{children:"Install"})]}),l.jsxs("button",{className:"flex items-center justify-center rounded-lg transition-all duration-150 px-2.5 py-1 gap-1.5 text-xs font-semibold cursor-pointer shrink-0",style:{background:"transparent",border:"1px solid var(--b2)",color:"var(--muted)"},onClick:()=>f(!0),title:"Open Commands",children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[l.jsx("circle",{cx:"11",cy:"11",r:"8"}),l.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),!S&&l.jsx(l.Fragment,{children:"Ctrl+k"})]})]}),l.jsxs("div",{className:"relative flex-1 min-h-0",children:[L&&e?l.jsx(U7,{rpc:e,onComplete:()=>R(!1),className:"absolute inset-0"}):a==="assistant"&&l.jsx(EA,{contextReport:U,cmdResult:h,onClearCmdResult:J,rpc:e,className:"absolute inset-0",activeSessionId:x,onCreateSession:q,events:O,addLiveEvent:$,onSwitchView:G=>c(G)}),a==="channels"&&l.jsx(TA,{rpc:e,className:"absolute inset-0"}),a==="stats"&&l.jsx(AA,{rpc:e,className:"absolute inset-0"}),a==="projects"&&l.jsx(CA,{rpc:e,className:"absolute inset-0"}),a==="agents"&&l.jsx(UA,{rpc:e,onOpenSession:E,className:"absolute inset-0"}),a==="kanban"&&l.jsx(UC,{rpc:e,className:"absolute inset-0"}),a==="wiki"&&l.jsx(p6,{rpc:e,className:"absolute inset-0"}),a==="settings"&&l.jsx(_6,{rpc:e,className:"absolute inset-0"})]})]}),l.jsx(B7,{open:d,onClose:()=>f(!1),onPick:V}),H&&l.jsx("div",{className:"fixed inset-0 z-[998] flex items-end animate-fadeIn",style:{background:"rgba(10, 8, 5, 0.6)",backdropFilter:"blur(4px)"},onClick:()=>Y(!1),children:l.jsxs("div",{className:"w-full max-h-[70vh] rounded-t-2xl overflow-hidden animate-slideUp select-none flex flex-col wood-grain",style:{background:"var(--s1)",borderTop:"1px solid var(--b1)"},onClick:G=>G.stopPropagation(),children:[l.jsx("div",{className:"flex justify-center pt-3 pb-1 shrink-0",children:l.jsx("div",{className:"w-8 h-1 rounded-full",style:{background:"var(--gold)",opacity:.3}})}),l.jsxs("div",{className:"flex items-center justify-between px-4 pb-3 shrink-0",style:{borderBottom:"1px solid var(--b1)"},children:[l.jsx("span",{className:"text-[13px] font-display font-semibold",style:{color:"var(--cream)"},children:"Sessions"}),l.jsx("button",{onClick:()=>Y(!1),className:"text-muted hover:text-fg transition-colors duration-100 p-1",children:l.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),l.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--b1)"},children:l.jsxs("button",{onClick:()=>{Z(),Y(!1)},className:"w-full flex items-center gap-2.5 py-2 px-3 rounded-xl transition-all duration-150 active:scale-[0.98] cursor-pointer",style:{background:"color-mix(in srgb, var(--gold) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--gold) 20%, transparent)",color:"var(--gold)"},children:[l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),l.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),l.jsx("span",{className:"text-[12.5px] font-semibold",children:"New Chat"})]})}),l.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4 scrollbar-thin",children:[j.sort((G,te)=>te.updatedAt-G.updatedAt).map(G=>l.jsx("button",{className:"w-full text-left py-3 px-3 rounded-xl mb-1 transition-all duration-150 active:scale-[0.98] min-h-[52px] cursor-pointer",style:{background:G.id===x?"linear-gradient(135deg, var(--s3) 0%, var(--s2) 100%)":"transparent",border:G.id===x?"1px solid var(--b2)":"1px solid transparent"},onClick:()=>{B(G.id),Y(!1)},children:l.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[l.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:G.id===x?"var(--gold)":"transparent",boxShadow:G.id===x?"0 0 4px var(--gold)":"none"}}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-[12.5px] font-medium text-fg truncate",children:G.name||G.provider}),l.jsxs("div",{className:"text-[11px] text-muted",children:[G.provider," · ",(()=>{const te=Date.now()-G.updatedAt;return te<6e4?"just now":te<36e5?`${Math.floor(te/6e4)}m ago`:te<864e5?`${Math.floor(te/36e5)}h ago`:`${Math.floor(te/864e5)}d ago`})()]})]}),G.type&&G.type!=="webui"&&l.jsx("span",{className:"text-[9px] font-mono text-muted bg-s2 px-1.5 py-0.5 rounded shrink-0",children:G.type})]})},G.id)),j.length===0&&l.jsx("div",{className:"text-center py-8 text-xs text-muted",children:"No sessions yet"})]}),x&&l.jsx("div",{className:"border-t border-b1 px-4 py-3 shrink-0",children:(()=>{var W;const G=O.filter(ge=>ge.type==="usage"),te=G.reduce((ge,Ue)=>ge+(Ue.inputTokens||0)+(Ue.outputTokens||0),0),le=G[G.length-1],ie=le&&le.inputTokens||0,ce=s("current_provider")||"anthropic",oe=(W=o.find(ge=>ge.name===ce))==null?void 0:W.model_cost,he=s("model")||"sonnet",re=G.reduce((ge,Ue)=>ge+T2(he,Ue.inputTokens||0,Ue.outputTokens||0,oe),0);return l.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-[9px] text-muted2 uppercase tracking-wider font-mono",children:"Tokens"}),l.jsx("div",{className:"text-[12px] text-fg font-mono font-semibold",children:Sn(te)})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-[9px] text-muted2 uppercase tracking-wider font-mono",children:"Context"}),l.jsx("div",{className:"text-[12px] text-fg font-mono font-semibold",children:Sn(ie)})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-[9px] text-muted2 uppercase tracking-wider font-mono",children:"Cost"}),l.jsxs("div",{className:"text-[12px] text-green font-mono font-semibold",children:["$",re.toFixed(4)]})]})]})})()})]})}),z&&l.jsx("div",{className:"fixed inset-0 z-[999] flex items-center justify-center p-4 animate-fadeIn",style:{background:"rgba(10, 8, 5, 0.7)",backdropFilter:"blur(8px)"},children:l.jsxs("div",{className:"w-full max-w-[340px] p-5 rounded-2xl shadow-2xl animate-scaleIn select-none",style:{background:"linear-gradient(135deg, var(--s2), var(--s1))",border:"1px solid var(--b2)",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[l.jsxs("div",{className:"flex items-center justify-between pb-3 mb-4",style:{borderBottom:"1px solid var(--b1)"},children:[l.jsx("span",{className:"font-bold text-[13.5px] font-display",style:{color:"var(--cream)"},children:"Install Curie Agent"}),l.jsx("button",{onClick:()=>A(!1),className:"text-muted hover:text-fg transition-colors duration-100 cursor-pointer",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),l.jsx("div",{className:"space-y-3.5 text-xs text-text leading-relaxed",children:_?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-[12px] text-muted mb-1 px-0.5",children:"Follow these simple steps to add Curie to your home screen:"}),l.jsxs("div",{className:"flex gap-3 items-start p-3 rounded-xl",style:{background:"color-mix(in srgb, var(--s1) 50%, transparent)",border:"1px solid var(--b1)"},children:[l.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-lg shrink-0",style:{background:"color-mix(in srgb, var(--gold) 10%, transparent)",color:"var(--gold)"},children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:l.jsx("path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8M16 6l-4-4-4 4M12 2v13"})})}),l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-fg block mb-0.5",children:"1. Tap the Share Button"}),l.jsx("span",{className:"text-[11px] text-muted",children:"Tap the Share icon in Safari's bottom toolbar."})]})]}),l.jsxs("div",{className:"flex gap-3 items-start p-3 rounded-xl",style:{background:"color-mix(in srgb, var(--s1) 50%, transparent)",border:"1px solid var(--b1)"},children:[l.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-lg shrink-0 font-bold font-mono text-[16px] select-none",style:{background:"color-mix(in srgb, var(--gold) 10%, transparent)",color:"var(--gold)"},children:"+"}),l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-fg block mb-0.5",children:"2. Add to Home Screen"}),l.jsxs("span",{className:"text-[11px] text-muted",children:["Scroll down and select ",l.jsx("strong",{children:"Add to Home Screen"}),"."]})]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-[12px] text-muted mb-1 px-0.5",children:"Follow these simple steps to add Curie to your home screen:"}),l.jsxs("div",{className:"flex gap-3 items-start bg-s1/50 border border-b1 p-3 rounded-xl",children:[l.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-lg bg-blue-500/10 text-blue-400 shrink-0",children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("circle",{cx:"12",cy:"12",r:"1"}),l.jsx("circle",{cx:"12",cy:"5",r:"1"}),l.jsx("circle",{cx:"12",cy:"19",r:"1"})]})}),l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-fg block mb-0.5",children:"1. Open Browser Menu"}),l.jsx("span",{className:"text-[11px] text-muted",children:"Tap the menu icon (three dots) in the top-right corner."})]})]}),l.jsxs("div",{className:"flex gap-3 items-start bg-s1/50 border border-b1 p-3 rounded-xl",children:[l.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-lg bg-blue-500/10 text-blue-400 shrink-0",children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),l.jsx("polyline",{points:"7 10 12 15 17 10"}),l.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-fg block mb-0.5",children:"2. Select Add / Install"}),l.jsxs("span",{className:"text-[11px] text-muted",children:["Tap ",l.jsx("strong",{children:"Add to Home screen"})," or ",l.jsx("strong",{children:"Install app"}),"."]})]})]})]})}),l.jsx("button",{onClick:()=>A(!1),className:"btn-gold w-full mt-5 py-2.5 px-4 rounded-xl font-semibold text-xs active:scale-[0.98] transition-all duration-150 cursor-pointer flex items-center justify-center",children:"Got it"})]})})]}):l.jsx(G7,{onAuthorize:r})}function Q7(){return l.jsx(AE,{children:l.jsx(F7,{})})}const K7=NE.createRoot(document.getElementById("root"));K7.render(l.jsx(Xe.StrictMode,{children:l.jsx(Q7,{})}));"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js").then(e=>{console.log("ServiceWorker registration successful with scope: ",e.scope),e.addEventListener("updatefound",()=>{const t=e.installing;t&&(window._pendingUpdateWorker=t,t.addEventListener("statechange",()=>{t.state==="installed"&&(window._hasPendingUpdate=!0,window.dispatchEvent(new CustomEvent("pwa-update-available")))}))}),navigator.serviceWorker.addEventListener("controllerchange",()=>{window.dispatchEvent(new CustomEvent("pwa-controller-updated"))})}).catch(e=>console.error("ServiceWorker registration failed: ",e))});
@@ -13,7 +13,7 @@
13
13
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
14
14
  <link rel="icon" type="image/png" href="/icons/logo-512.png">
15
15
  <link rel="apple-touch-icon" href="/icons/icon-192.png">
16
- <script type="module" crossorigin src="/assets/index-CyCuINoz.js"></script>
16
+ <script type="module" crossorigin src="/assets/index-BNHnn_LR.js"></script>
17
17
  <link rel="stylesheet" crossorigin href="/assets/index-ulOOFddN.css">
18
18
  </head>
19
19
  <body class="bg-bg">