morpheus-cli 0.9.41 → 0.9.50

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.
Files changed (54) hide show
  1. package/dist/channels/discord.js +1 -1
  2. package/dist/channels/telegram.js +1 -1
  3. package/dist/config/manager.js +3 -3
  4. package/dist/config/schemas.js +2 -2
  5. package/dist/runtime/__tests__/manual_start_verify.js +1 -1
  6. package/dist/runtime/__tests__/telephonist-tts.test.js +2 -2
  7. package/dist/runtime/hot-reload.js +5 -0
  8. package/dist/runtime/memory/sqlite.js +20 -5
  9. package/dist/runtime/migration.js +45 -0
  10. package/dist/runtime/oracle.js +3 -0
  11. package/dist/runtime/subagents/apoc.js +2 -2
  12. package/dist/runtime/subagents/link/link.js +2 -2
  13. package/dist/runtime/subagents/neo.js +5 -3
  14. package/dist/runtime/subagents/registry.js +8 -8
  15. package/dist/runtime/subagents/trinity/trinity.js +2 -2
  16. package/dist/runtime/subagents/utils.js +2 -0
  17. package/dist/runtime/telephonist.js +6 -6
  18. package/dist/runtime/tools/factory.js +50 -34
  19. package/dist/types/config.js +2 -2
  20. package/dist/ui/assets/{AuditDashboard-EvtKjy5H.js → AuditDashboard-CPzQrzFj.js} +1 -1
  21. package/dist/ui/assets/{Chat-yptierPt.js → Chat-Dp4qy6Gs.js} +4 -4
  22. package/dist/ui/assets/{Chronos-BA77MYbp.js → Chronos-CyhR9ccX.js} +1 -1
  23. package/dist/ui/assets/{ConfirmationModal-NOZr-ipQ.js → ConfirmationModal-CNhiVVl3.js} +1 -1
  24. package/dist/ui/assets/{Dashboard-ly1MJiB4.js → Dashboard-DkNBsaWw.js} +1 -1
  25. package/dist/ui/assets/{DeleteConfirmationModal-2HMraacH.js → DeleteConfirmationModal-Dy9tnt_b.js} +1 -1
  26. package/dist/ui/assets/{Documents-C31fAm0Z.js → Documents-DRrqTxAm.js} +1 -1
  27. package/dist/ui/assets/{Logs-BiajoLAB.js → Logs-BQ4f2Gfo.js} +1 -1
  28. package/dist/ui/assets/{MCPManager-DS9jfiZT.js → MCPManager-BWar71tN.js} +1 -1
  29. package/dist/ui/assets/{ModelPresets-CxhKcalw.js → ModelPresets-CPKQqVTG.js} +1 -1
  30. package/dist/ui/assets/{ModelPricing-CN8flHnP.js → ModelPricing-DWP3iAO7.js} +1 -1
  31. package/dist/ui/assets/{Notifications-BfP1_CM3.js → Notifications-BYx4ua0g.js} +1 -1
  32. package/dist/ui/assets/{SatiMemories-Bk4_ubo7.js → SatiMemories-BpHdwM0A.js} +1 -1
  33. package/dist/ui/assets/{SessionAudit-D3E6QSQw.js → SessionAudit-CCbPOKy9.js} +1 -1
  34. package/dist/ui/assets/{Settings-3VBK8muv.js → Settings-B5InwiHP.js} +3 -3
  35. package/dist/ui/assets/{Skills-Dp0_GwiW.js → Skills-DtGzD8Qw.js} +1 -1
  36. package/dist/ui/assets/{Smiths-COTgI2R4.js → Smiths-CNtqkAFS.js} +1 -1
  37. package/dist/ui/assets/{Tasks-COe4lIJ7.js → Tasks-BTVcCY9w.js} +1 -1
  38. package/dist/ui/assets/{TrinityDatabases-BEU4mmyW.js → TrinityDatabases-1JLYBExa.js} +1 -1
  39. package/dist/ui/assets/{UsageStats-BTmDeG2V.js → UsageStats-DLm3pFj2.js} +1 -1
  40. package/dist/ui/assets/{WebhookManager-FQVyKyW-.js → WebhookManager-Cp0c6m9t.js} +1 -1
  41. package/dist/ui/assets/{agents-B6e9N0QI.js → agents-D54KZHoX.js} +1 -1
  42. package/dist/ui/assets/{audit-giQG2WRk.js → audit-C3PRWFnZ.js} +1 -1
  43. package/dist/ui/assets/{chronos-sweaRcNj.js → chronos-BDSY9T_M.js} +1 -1
  44. package/dist/ui/assets/{config-CbUdj76n.js → config-DZGSjv5e.js} +1 -1
  45. package/dist/ui/assets/{index-CRPT77Yo.css → index-Bn2nGQ5z.css} +1 -1
  46. package/dist/ui/assets/{index-yu2c4ry1.js → index-C_cF6S2J.js} +2 -2
  47. package/dist/ui/assets/{mcp-v64BBpUk.js → mcp-Bho7XEgS.js} +1 -1
  48. package/dist/ui/assets/{modelPresets-BaNh-gxn.js → modelPresets-DP4danw2.js} +1 -1
  49. package/dist/ui/assets/{skills-ClRXBlVt.js → skills-CaMm4Xe8.js} +1 -1
  50. package/dist/ui/assets/{stats-nI-89hEX.js → stats-BDnmqrhn.js} +1 -1
  51. package/dist/ui/assets/{useCurrency-D5An8I2f.js → useCurrency-Bkd-Hd8n.js} +1 -1
  52. package/dist/ui/index.html +2 -2
  53. package/dist/ui/sw.js +1 -1
  54. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{j as o}from"./vendor-motion-C3CZ8ZlO.js";import{r as P}from"./vendor-react-DikRIOlj.js";import{t as Ar,u as se,Z as $r,m as me}from"./vendor-utils-BIYveU_1.js";import{u as Tr,c as Zr}from"./chronos-sweaRcNj.js";import{T as w,S as V}from"./SelectInput-BPDcd3y7.js";import{N as O,S as Q}from"./Switch-C7TxLq0E.js";import{c as ee}from"./config-CbUdj76n.js";import{m as ft}from"./modelPresets-BaNh-gxn.js";import{h as tt}from"./index-yu2c4ry1.js";import{C as Er}from"./ConfirmationModal-NOZr-ipQ.js";import{d as Ir,X as Pr,Y as Rr}from"./vendor-icons-LSkmAkBj.js";function W({title:e,description:t,children:r}){return o.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg p-6 bg-azure-surface/50 dark:bg-matrix-base/50",children:[o.jsxs("div",{className:"mb-4",children:[o.jsx("h3",{className:"text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:e}),t&&o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mt-1",children:t})]}),o.jsx("div",{className:"space-y-4",children:r})]})}function Xe({label:e,error:t,helperText:r,className:n,...a}){return o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-secondary",children:e}),o.jsx("textarea",{className:Ar("bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-secondary placeholder-azure-text-secondary/50 dark:placeholder-matrix-secondary/50 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors resize-y min-h-[80px]",t&&"border-red-500 focus:border-red-500 focus:ring-red-500",n),rows:10,...a}),r&&!t&&o.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:r}),t&&o.jsx("p",{className:"text-xs text-red-500",children:t})]})}function p(e,t,r){function n(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);const m=i.prototype,h=Object.keys(m);for(let f=0;f<h.length;f++){const g=h[f];g in c||(c[g]=m[g].bind(c))}}const a=r?.Parent??Object;class l extends a{}Object.defineProperty(l,"name",{value:e});function i(c){var u;const m=r?.Parent?new l:this;n(m,c),(u=m._zod).deferred??(u.deferred=[]);for(const h of m._zod.deferred)h();return m}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Se extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mt extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ut={};function pe(e){return Ut}function Lt(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,a])=>t.indexOf(+n)===-1).map(([n,a])=>a)}function rt(e,t){return typeof t=="bigint"?t.toString():t}function Ve(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ot(e){return e==null}function it(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Dr(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let a=(n.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(n)){const u=n.match(/\d?e-(\d?)/);u?.[1]&&(a=Number.parseInt(u[1]))}const l=r>a?r:a,i=Number.parseInt(e.toFixed(l).replace(".","")),c=Number.parseInt(t.toFixed(l).replace(".",""));return i%c/10**l}const gt=Symbol("evaluating");function N(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==gt)return n===void 0&&(n=gt,n=r()),n},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function xe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function fe(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function bt(e){return JSON.stringify(e)}function Mr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ft="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ur=Ve(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ne(e){if(Ie(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Ie(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Jt(e){return Ne(e)?{...e}:Array.isArray(e)?[...e]:e}const Lr=new Set(["string","number","symbol"]);function Ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ge(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function b(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Fr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Jr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Br(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const l=fe(e._zod.def,{get shape(){const i={};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(i[c]=r.shape[c])}return xe(this,"shape",i),i},checks:[]});return ge(e,l)}function Kr(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const l=fe(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete i[c]}return xe(this,"shape",i),i},checks:[]});return ge(e,l)}function Vr(e,t){if(!Ne(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const l=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(l,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=fe(e._zod.def,{get shape(){const l={...e._zod.def.shape,...t};return xe(this,"shape",l),l}});return ge(e,a)}function Wr(e,t){if(!Ne(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=fe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return xe(this,"shape",n),n}});return ge(e,r)}function Gr(e,t){const r=fe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return xe(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return ge(e,r)}function qr(e,t,r){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=fe(t._zod.def,{get shape(){const c=t._zod.def.shape,u={...c};if(r)for(const m in r){if(!(m in c))throw new Error(`Unrecognized key: "${m}"`);r[m]&&(u[m]=e?new e({type:"optional",innerType:c[m]}):c[m])}else for(const m in c)u[m]=e?new e({type:"optional",innerType:c[m]}):c[m];return xe(this,"shape",u),u},checks:[]});return ge(t,i)}function Hr(e,t,r){const n=fe(t._zod.def,{get shape(){const a=t._zod.def.shape,l={...a};if(r)for(const i in r){if(!(i in l))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(l[i]=new e({type:"nonoptional",innerType:a[i]}))}else for(const i in a)l[i]=new e({type:"nonoptional",innerType:a[i]});return xe(this,"shape",l),l}});return ge(t,n)}function ze(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function je(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Me(e){return typeof e=="string"?e:e?.message}function he(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const a=Me(e.inst?._zod.def?.error?.(e))??Me(t?.error?.(e))??Me(r.customError?.(e))??Me(r.localeError?.(e))??"Invalid input";n.message=a}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function st(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Pe(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Bt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,rt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Kt=p("$ZodError",Bt),Vt=p("$ZodError",Bt,{Parent:Error});function Yr(e,t=r=>r.message){const r={},n=[];for(const a of e.issues)a.path.length>0?(r[a.path[0]]=r[a.path[0]]||[],r[a.path[0]].push(t(a))):n.push(t(a));return{formErrors:n,fieldErrors:r}}function Xr(e,t=r=>r.message){const r={_errors:[]},n=a=>{for(const l of a.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(i=>n({issues:i}));else if(l.code==="invalid_key")n({issues:l.issues});else if(l.code==="invalid_element")n({issues:l.issues});else if(l.path.length===0)r._errors.push(t(l));else{let i=r,c=0;for(;c<l.path.length;){const u=l.path[c];c===l.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(l))):i[u]=i[u]||{_errors:[]},i=i[u],c++}}};return n(e),r}const lt=e=>(t,r,n,a)=>{const l=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:r,issues:[]},l);if(i instanceof Promise)throw new Se;if(i.issues.length){const c=new(a?.Err??e)(i.issues.map(u=>he(u,l,pe())));throw Ft(c,a?.callee),c}return i.value},ct=e=>async(t,r,n,a)=>{const l=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},l);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(a?.Err??e)(i.issues.map(u=>he(u,l,pe())));throw Ft(c,a?.callee),c}return i.value},We=e=>(t,r,n)=>{const a=n?{...n,async:!1}:{async:!1},l=t._zod.run({value:r,issues:[]},a);if(l instanceof Promise)throw new Se;return l.issues.length?{success:!1,error:new(e??Kt)(l.issues.map(i=>he(i,a,pe())))}:{success:!0,data:l.value}},Qr=We(Vt),Ge=e=>async(t,r,n)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let l=t._zod.run({value:r,issues:[]},a);return l instanceof Promise&&(l=await l),l.issues.length?{success:!1,error:new e(l.issues.map(i=>he(i,a,pe())))}:{success:!0,data:l.value}},en=Ge(Vt),tn=e=>(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return lt(e)(t,r,a)},rn=e=>(t,r,n)=>lt(e)(t,r,n),nn=e=>async(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return ct(e)(t,r,a)},an=e=>async(t,r,n)=>ct(e)(t,r,n),on=e=>(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return We(e)(t,r,a)},sn=e=>(t,r,n)=>We(e)(t,r,n),ln=e=>async(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ge(e)(t,r,a)},cn=e=>async(t,r,n)=>Ge(e)(t,r,n),un=/^[cC][^\s-]{8,}$/,dn=/^[0-9a-z]+$/,mn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,pn=/^[0-9a-vA-V]{20}$/,hn=/^[A-Za-z0-9]{27}$/,fn=/^[a-zA-Z0-9_-]{21}$/,gn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,bn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,xt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,xn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,vn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function yn(){return new RegExp(vn,"u")}const _n=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,kn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,wn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,zn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Wt=/^[A-Za-z0-9_-]*$/,Sn=/^\+[1-9]\d{6,14}$/,Gt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Nn=new RegExp(`^${Gt}$`);function qt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Cn(e){return new RegExp(`^${qt(e)}$`)}function On(e){const t=qt({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Gt}T(?:${n})$`)}const An=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},$n=/^-?\d+$/,Ht=/^-?\d+(?:\.\d+)?$/,Tn=/^(?:true|false)$/i,Zn=/^[^A-Z]*$/,En=/^[^a-z]*$/,Y=p("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Yt={number:"number",bigint:"bigint",object:"date"},Xt=p("$ZodCheckLessThan",(e,t)=>{Y.init(e,t);const r=Yt[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,l=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<l&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Qt=p("$ZodCheckGreaterThan",(e,t)=>{Y.init(e,t);const r=Yt[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,l=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>l&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),In=p("$ZodCheckMultipleOf",(e,t)=>{Y.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Dr(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Pn=p("$ZodCheckNumberFormat",(e,t)=>{Y.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[a,l]=Jr[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=a,c.maximum=l,r&&(c.pattern=$n)}),e._zod.check=i=>{const c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<a&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!t.abort}),c>l&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:l,inclusive:!0,inst:e,continue:!t.abort})}}),Rn=p("$ZodCheckMaxLength",(e,t)=>{var r;Y.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!ot(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const a=n.value;if(a.length<=t.maximum)return;const i=st(a);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Dn=p("$ZodCheckMinLength",(e,t)=>{var r;Y.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!ot(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const a=n.value;if(a.length>=t.minimum)return;const i=st(a);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Mn=p("$ZodCheckLengthEquals",(e,t)=>{var r;Y.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!ot(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=n=>{const a=n.value,l=a.length;if(l===t.length)return;const i=st(a),c=l>t.length;n.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),qe=p("$ZodCheckStringFormat",(e,t)=>{var r,n;Y.init(e,t),e._zod.onattach.push(a=>{const l=a._zod.bag;l.format=t.format,t.pattern&&(l.patterns??(l.patterns=new Set),l.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Un=p("$ZodCheckRegex",(e,t)=>{qe.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ln=p("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Zn),qe.init(e,t)}),Fn=p("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=En),qe.init(e,t)}),Jn=p("$ZodCheckIncludes",(e,t)=>{Y.init(e,t);const r=Ce(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(a=>{const l=a._zod.bag;l.patterns??(l.patterns=new Set),l.patterns.add(n)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),Bn=p("$ZodCheckStartsWith",(e,t)=>{Y.init(e,t);const r=new RegExp(`^${Ce(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Kn=p("$ZodCheckEndsWith",(e,t)=>{Y.init(e,t);const r=new RegExp(`.*${Ce(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Vn=p("$ZodCheckOverwrite",(e,t)=>{Y.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Wn{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
1
+ import{j as o}from"./vendor-motion-C3CZ8ZlO.js";import{r as P}from"./vendor-react-DikRIOlj.js";import{t as Ar,u as se,Z as $r,m as me}from"./vendor-utils-BIYveU_1.js";import{u as Tr,c as Zr}from"./chronos-BDSY9T_M.js";import{T as w,S as V}from"./SelectInput-BPDcd3y7.js";import{N as O,S as Q}from"./Switch-C7TxLq0E.js";import{c as ee}from"./config-DZGSjv5e.js";import{m as ft}from"./modelPresets-DP4danw2.js";import{h as tt}from"./index-C_cF6S2J.js";import{C as Er}from"./ConfirmationModal-CNhiVVl3.js";import{d as Ir,X as Pr,Y as Rr}from"./vendor-icons-LSkmAkBj.js";function W({title:e,description:t,children:r}){return o.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg p-6 bg-azure-surface/50 dark:bg-matrix-base/50",children:[o.jsxs("div",{className:"mb-4",children:[o.jsx("h3",{className:"text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:e}),t&&o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mt-1",children:t})]}),o.jsx("div",{className:"space-y-4",children:r})]})}function Xe({label:e,error:t,helperText:r,className:n,...a}){return o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-secondary",children:e}),o.jsx("textarea",{className:Ar("bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-secondary placeholder-azure-text-secondary/50 dark:placeholder-matrix-secondary/50 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors resize-y min-h-[80px]",t&&"border-red-500 focus:border-red-500 focus:ring-red-500",n),rows:10,...a}),r&&!t&&o.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:r}),t&&o.jsx("p",{className:"text-xs text-red-500",children:t})]})}function p(e,t,r){function n(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);const m=i.prototype,h=Object.keys(m);for(let f=0;f<h.length;f++){const g=h[f];g in c||(c[g]=m[g].bind(c))}}const a=r?.Parent??Object;class l extends a{}Object.defineProperty(l,"name",{value:e});function i(c){var u;const m=r?.Parent?new l:this;n(m,c),(u=m._zod).deferred??(u.deferred=[]);for(const h of m._zod.deferred)h();return m}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Se extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mt extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ut={};function pe(e){return Ut}function Lt(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,a])=>t.indexOf(+n)===-1).map(([n,a])=>a)}function rt(e,t){return typeof t=="bigint"?t.toString():t}function Ve(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ot(e){return e==null}function it(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Dr(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let a=(n.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(n)){const u=n.match(/\d?e-(\d?)/);u?.[1]&&(a=Number.parseInt(u[1]))}const l=r>a?r:a,i=Number.parseInt(e.toFixed(l).replace(".","")),c=Number.parseInt(t.toFixed(l).replace(".",""));return i%c/10**l}const gt=Symbol("evaluating");function N(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==gt)return n===void 0&&(n=gt,n=r()),n},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function xe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function fe(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function bt(e){return JSON.stringify(e)}function Mr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ft="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ur=Ve(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ne(e){if(Ie(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Ie(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Jt(e){return Ne(e)?{...e}:Array.isArray(e)?[...e]:e}const Lr=new Set(["string","number","symbol"]);function Ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ge(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function b(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Fr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Jr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Br(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const l=fe(e._zod.def,{get shape(){const i={};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(i[c]=r.shape[c])}return xe(this,"shape",i),i},checks:[]});return ge(e,l)}function Kr(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const l=fe(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete i[c]}return xe(this,"shape",i),i},checks:[]});return ge(e,l)}function Vr(e,t){if(!Ne(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const l=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(l,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=fe(e._zod.def,{get shape(){const l={...e._zod.def.shape,...t};return xe(this,"shape",l),l}});return ge(e,a)}function Wr(e,t){if(!Ne(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=fe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return xe(this,"shape",n),n}});return ge(e,r)}function Gr(e,t){const r=fe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return xe(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return ge(e,r)}function qr(e,t,r){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=fe(t._zod.def,{get shape(){const c=t._zod.def.shape,u={...c};if(r)for(const m in r){if(!(m in c))throw new Error(`Unrecognized key: "${m}"`);r[m]&&(u[m]=e?new e({type:"optional",innerType:c[m]}):c[m])}else for(const m in c)u[m]=e?new e({type:"optional",innerType:c[m]}):c[m];return xe(this,"shape",u),u},checks:[]});return ge(t,i)}function Hr(e,t,r){const n=fe(t._zod.def,{get shape(){const a=t._zod.def.shape,l={...a};if(r)for(const i in r){if(!(i in l))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(l[i]=new e({type:"nonoptional",innerType:a[i]}))}else for(const i in a)l[i]=new e({type:"nonoptional",innerType:a[i]});return xe(this,"shape",l),l}});return ge(t,n)}function ze(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function je(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Me(e){return typeof e=="string"?e:e?.message}function he(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const a=Me(e.inst?._zod.def?.error?.(e))??Me(t?.error?.(e))??Me(r.customError?.(e))??Me(r.localeError?.(e))??"Invalid input";n.message=a}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function st(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Pe(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Bt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,rt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Kt=p("$ZodError",Bt),Vt=p("$ZodError",Bt,{Parent:Error});function Yr(e,t=r=>r.message){const r={},n=[];for(const a of e.issues)a.path.length>0?(r[a.path[0]]=r[a.path[0]]||[],r[a.path[0]].push(t(a))):n.push(t(a));return{formErrors:n,fieldErrors:r}}function Xr(e,t=r=>r.message){const r={_errors:[]},n=a=>{for(const l of a.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(i=>n({issues:i}));else if(l.code==="invalid_key")n({issues:l.issues});else if(l.code==="invalid_element")n({issues:l.issues});else if(l.path.length===0)r._errors.push(t(l));else{let i=r,c=0;for(;c<l.path.length;){const u=l.path[c];c===l.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(l))):i[u]=i[u]||{_errors:[]},i=i[u],c++}}};return n(e),r}const lt=e=>(t,r,n,a)=>{const l=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:r,issues:[]},l);if(i instanceof Promise)throw new Se;if(i.issues.length){const c=new(a?.Err??e)(i.issues.map(u=>he(u,l,pe())));throw Ft(c,a?.callee),c}return i.value},ct=e=>async(t,r,n,a)=>{const l=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},l);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(a?.Err??e)(i.issues.map(u=>he(u,l,pe())));throw Ft(c,a?.callee),c}return i.value},We=e=>(t,r,n)=>{const a=n?{...n,async:!1}:{async:!1},l=t._zod.run({value:r,issues:[]},a);if(l instanceof Promise)throw new Se;return l.issues.length?{success:!1,error:new(e??Kt)(l.issues.map(i=>he(i,a,pe())))}:{success:!0,data:l.value}},Qr=We(Vt),Ge=e=>async(t,r,n)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let l=t._zod.run({value:r,issues:[]},a);return l instanceof Promise&&(l=await l),l.issues.length?{success:!1,error:new e(l.issues.map(i=>he(i,a,pe())))}:{success:!0,data:l.value}},en=Ge(Vt),tn=e=>(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return lt(e)(t,r,a)},rn=e=>(t,r,n)=>lt(e)(t,r,n),nn=e=>async(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return ct(e)(t,r,a)},an=e=>async(t,r,n)=>ct(e)(t,r,n),on=e=>(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return We(e)(t,r,a)},sn=e=>(t,r,n)=>We(e)(t,r,n),ln=e=>async(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ge(e)(t,r,a)},cn=e=>async(t,r,n)=>Ge(e)(t,r,n),un=/^[cC][^\s-]{8,}$/,dn=/^[0-9a-z]+$/,mn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,pn=/^[0-9a-vA-V]{20}$/,hn=/^[A-Za-z0-9]{27}$/,fn=/^[a-zA-Z0-9_-]{21}$/,gn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,bn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,xt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,xn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,vn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function yn(){return new RegExp(vn,"u")}const _n=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,kn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,wn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,zn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Wt=/^[A-Za-z0-9_-]*$/,Sn=/^\+[1-9]\d{6,14}$/,Gt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Nn=new RegExp(`^${Gt}$`);function qt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Cn(e){return new RegExp(`^${qt(e)}$`)}function On(e){const t=qt({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Gt}T(?:${n})$`)}const An=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},$n=/^-?\d+$/,Ht=/^-?\d+(?:\.\d+)?$/,Tn=/^(?:true|false)$/i,Zn=/^[^A-Z]*$/,En=/^[^a-z]*$/,Y=p("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Yt={number:"number",bigint:"bigint",object:"date"},Xt=p("$ZodCheckLessThan",(e,t)=>{Y.init(e,t);const r=Yt[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,l=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<l&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Qt=p("$ZodCheckGreaterThan",(e,t)=>{Y.init(e,t);const r=Yt[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,l=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>l&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),In=p("$ZodCheckMultipleOf",(e,t)=>{Y.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Dr(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Pn=p("$ZodCheckNumberFormat",(e,t)=>{Y.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[a,l]=Jr[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=a,c.maximum=l,r&&(c.pattern=$n)}),e._zod.check=i=>{const c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<a&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!t.abort}),c>l&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:l,inclusive:!0,inst:e,continue:!t.abort})}}),Rn=p("$ZodCheckMaxLength",(e,t)=>{var r;Y.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!ot(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const a=n.value;if(a.length<=t.maximum)return;const i=st(a);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Dn=p("$ZodCheckMinLength",(e,t)=>{var r;Y.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!ot(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const a=n.value;if(a.length>=t.minimum)return;const i=st(a);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Mn=p("$ZodCheckLengthEquals",(e,t)=>{var r;Y.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!ot(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=n=>{const a=n.value,l=a.length;if(l===t.length)return;const i=st(a),c=l>t.length;n.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),qe=p("$ZodCheckStringFormat",(e,t)=>{var r,n;Y.init(e,t),e._zod.onattach.push(a=>{const l=a._zod.bag;l.format=t.format,t.pattern&&(l.patterns??(l.patterns=new Set),l.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Un=p("$ZodCheckRegex",(e,t)=>{qe.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ln=p("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Zn),qe.init(e,t)}),Fn=p("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=En),qe.init(e,t)}),Jn=p("$ZodCheckIncludes",(e,t)=>{Y.init(e,t);const r=Ce(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(a=>{const l=a._zod.bag;l.patterns??(l.patterns=new Set),l.patterns.add(n)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),Bn=p("$ZodCheckStartsWith",(e,t)=>{Y.init(e,t);const r=new RegExp(`^${Ce(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Kn=p("$ZodCheckEndsWith",(e,t)=>{Y.init(e,t);const r=new RegExp(`.*${Ce(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Vn=p("$ZodCheckOverwrite",(e,t)=>{Y.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Wn{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
2
2
  `).filter(i=>i),a=Math.min(...n.map(i=>i.length-i.trimStart().length)),l=n.map(i=>i.slice(a)).map(i=>" ".repeat(this.indent*2)+i);for(const i of l)this.content.push(i)}compile(){const t=Function,r=this?.args,a=[...(this?.content??[""]).map(l=>` ${l}`)];return new t(...r,a.join(`
3
3
  `))}}const Gn={major:4,minor:3,patch:6},M=p("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Gn;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const a of n)for(const l of a._zod.onattach)l(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const a=(i,c,u)=>{let m=ze(i),h;for(const f of c){if(f._zod.def.when){if(!f._zod.def.when(i))continue}else if(m)continue;const g=i.issues.length,x=f._zod.check(i);if(x instanceof Promise&&u?.async===!1)throw new Se;if(h||x instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await x,i.issues.length!==g&&(m||(m=ze(i,g)))});else{if(i.issues.length===g)continue;m||(m=ze(i,g))}}return h?h.then(()=>i):i},l=(i,c,u)=>{if(ze(i))return i.aborted=!0,i;const m=a(c,n,u);if(m instanceof Promise){if(u.async===!1)throw new Se;return m.then(h=>e._zod.parse(h,u))}return e._zod.parse(m,u)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){const m=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return m instanceof Promise?m.then(h=>l(h,i,c)):l(m,i,c)}const u=e._zod.parse(i,c);if(u instanceof Promise){if(c.async===!1)throw new Se;return u.then(m=>a(m,n,c))}return a(u,n,c)}}N(e,"~standard",()=>({validate:a=>{try{const l=Qr(e,a);return l.success?{value:l.data}:{issues:l.error?.issues}}catch{return en(e,a).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),ut=p("$ZodString",(e,t)=>{M.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??An(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),D=p("$ZodStringFormat",(e,t)=>{qe.init(e,t),ut.init(e,t)}),qn=p("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=bn),D.init(e,t)}),Hn=p("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=xt(n))}else t.pattern??(t.pattern=xt());D.init(e,t)}),Yn=p("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=xn),D.init(e,t)}),Xn=p("$ZodURL",(e,t)=>{D.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),a=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(a.protocol.endsWith(":")?a.protocol.slice(0,-1):a.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=a.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Qn=p("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=yn()),D.init(e,t)}),ea=p("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=fn),D.init(e,t)}),ta=p("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=un),D.init(e,t)}),ra=p("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=dn),D.init(e,t)}),na=p("$ZodULID",(e,t)=>{t.pattern??(t.pattern=mn),D.init(e,t)}),aa=p("$ZodXID",(e,t)=>{t.pattern??(t.pattern=pn),D.init(e,t)}),oa=p("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=hn),D.init(e,t)}),ia=p("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=On(t)),D.init(e,t)}),sa=p("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Nn),D.init(e,t)}),la=p("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Cn(t)),D.init(e,t)}),ca=p("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=gn),D.init(e,t)}),ua=p("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=_n),D.init(e,t),e._zod.bag.format="ipv4"}),da=p("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=kn),D.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),ma=p("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=wn),D.init(e,t)}),pa=p("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=zn),D.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[a,l]=n;if(!l)throw new Error;const i=Number(l);if(`${i}`!==l)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${a}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function er(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ha=p("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=jn),D.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{er(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function fa(e){if(!Wt.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return er(r)}const ga=p("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Wt),D.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{fa(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ba=p("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Sn),D.init(e,t)});function xa(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const a=JSON.parse(atob(n));return!("typ"in a&&a?.typ!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const va=p("$ZodJWT",(e,t)=>{D.init(e,t),e._zod.check=r=>{xa(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),tr=p("$ZodNumber",(e,t)=>{M.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ht,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const a=r.value;if(typeof a=="number"&&!Number.isNaN(a)&&Number.isFinite(a))return r;const l=typeof a=="number"?Number.isNaN(a)?"NaN":Number.isFinite(a)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:a,inst:e,...l?{received:l}:{}}),r}}),ya=p("$ZodNumberFormat",(e,t)=>{Pn.init(e,t),tr.init(e,t)}),_a=p("$ZodBoolean",(e,t)=>{M.init(e,t),e._zod.pattern=Tn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const a=r.value;return typeof a=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),r}}),ka=p("$ZodUnknown",(e,t)=>{M.init(e,t),e._zod.parse=r=>r}),wa=p("$ZodNever",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function vt(e,t,r){e.issues.length&&t.issues.push(...je(r,e.issues)),t.value[r]=e.value}const za=p("$ZodArray",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{const a=r.value;if(!Array.isArray(a))return r.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),r;r.value=Array(a.length);const l=[];for(let i=0;i<a.length;i++){const c=a[i],u=t.element._zod.run({value:c,issues:[]},n);u instanceof Promise?l.push(u.then(m=>vt(m,r,i))):vt(u,r,i)}return l.length?Promise.all(l).then(()=>r):r}});function Je(e,t,r,n,a){if(e.issues.length){if(a&&!(r in n))return;t.issues.push(...je(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function rr(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=Fr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function nr(e,t,r,n,a,l){const i=[],c=a.keySet,u=a.catchall._zod,m=u.def.type,h=u.optout==="optional";for(const f in t){if(c.has(f))continue;if(m==="never"){i.push(f);continue}const g=u.run({value:t[f],issues:[]},n);g instanceof Promise?e.push(g.then(x=>Je(x,r,f,t,h))):Je(g,r,f,t,h)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:l}),e.length?Promise.all(e).then(()=>r):r}const ja=p("$ZodObject",(e,t)=>{if(M.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const u={...c};return Object.defineProperty(t,"shape",{value:u}),u}})}const n=Ve(()=>rr(t));N(e._zod,"propValues",()=>{const c=t.shape,u={};for(const m in c){const h=c[m]._zod;if(h.values){u[m]??(u[m]=new Set);for(const f of h.values)u[m].add(f)}}return u});const a=Ie,l=t.catchall;let i;e._zod.parse=(c,u)=>{i??(i=n.value);const m=c.value;if(!a(m))return c.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),c;c.value={};const h=[],f=i.shape;for(const g of i.keys){const x=f[g],F=x._zod.optout==="optional",d=x._zod.run({value:m[g],issues:[]},u);d instanceof Promise?h.push(d.then(oe=>Je(oe,c,g,m,F))):Je(d,c,g,m,F)}return l?nr(h,m,c,u,n.value,e):h.length?Promise.all(h).then(()=>c):c}}),Sa=p("$ZodObjectJIT",(e,t)=>{ja.init(e,t);const r=e._zod.parse,n=Ve(()=>rr(t)),a=g=>{const x=new Wn(["shape","payload","ctx"]),F=n.value,d=z=>{const J=bt(z);return`shape[${J}]._zod.run({ value: input[${J}], issues: [] }, ctx)`};x.write("const input = payload.value;");const oe=Object.create(null);let $=0;for(const z of F.keys)oe[z]=`key_${$++}`;x.write("const newResult = {};");for(const z of F.keys){const J=oe[z],j=bt(z),T=g[z]?._zod?.optout==="optional";x.write(`const ${J} = ${d(z)};`),T?x.write(`
4
4
  if (${J}.issues.length) {
@@ -36,11 +36,11 @@ import{j as o}from"./vendor-motion-C3CZ8ZlO.js";import{r as P}from"./vendor-reac
36
36
 
37
37
  `)}x.write("payload.value = newResult;"),x.write("return payload;");const ve=x.compile();return(z,J)=>ve(g,z,J)};let l;const i=Ie,c=!Ut.jitless,m=c&&Ur.value,h=t.catchall;let f;e._zod.parse=(g,x)=>{f??(f=n.value);const F=g.value;return i(F)?c&&m&&x?.async===!1&&x.jitless!==!0?(l||(l=a(t.shape)),g=l(g,x),h?nr([],F,g,x,f,e):g):r(g,x):(g.issues.push({expected:"object",code:"invalid_type",input:F,inst:e}),g)}});function yt(e,t,r,n){for(const l of e)if(l.issues.length===0)return t.value=l.value,t;const a=e.filter(l=>!ze(l));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(l=>l.issues.map(i=>he(i,n,pe())))}),t)}const ar=p("$ZodUnion",(e,t)=>{M.init(e,t),N(e._zod,"optin",()=>t.options.some(a=>a._zod.optin==="optional")?"optional":void 0),N(e._zod,"optout",()=>t.options.some(a=>a._zod.optout==="optional")?"optional":void 0),N(e._zod,"values",()=>{if(t.options.every(a=>a._zod.values))return new Set(t.options.flatMap(a=>Array.from(a._zod.values)))}),N(e._zod,"pattern",()=>{if(t.options.every(a=>a._zod.pattern)){const a=t.options.map(l=>l._zod.pattern);return new RegExp(`^(${a.map(l=>it(l.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(a,l)=>{if(r)return n(a,l);let i=!1;const c=[];for(const u of t.options){const m=u._zod.run({value:a.value,issues:[]},l);if(m instanceof Promise)c.push(m),i=!0;else{if(m.issues.length===0)return m;c.push(m)}}return i?Promise.all(c).then(u=>yt(u,a,e,l)):yt(c,a,e,l)}}),Na=p("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ar.init(e,t);const r=e._zod.parse;N(e._zod,"propValues",()=>{const a={};for(const l of t.options){const i=l._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(l)}"`);for(const[c,u]of Object.entries(i)){a[c]||(a[c]=new Set);for(const m of u)a[c].add(m)}}return a});const n=Ve(()=>{const a=t.options,l=new Map;for(const i of a){const c=i._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const u of c){if(l.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);l.set(u,i)}}return l});e._zod.parse=(a,l)=>{const i=a.value;if(!Ie(i))return a.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),a;const c=n.value.get(i?.[t.discriminator]);return c?c._zod.run(a,l):t.unionFallback?r(a,l):(a.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),a)}}),Ca=p("$ZodIntersection",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{const a=r.value,l=t.left._zod.run({value:a,issues:[]},n),i=t.right._zod.run({value:a,issues:[]},n);return l instanceof Promise||i instanceof Promise?Promise.all([l,i]).then(([u,m])=>_t(r,u,m)):_t(r,l,i)}});function nt(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(Ne(e)&&Ne(t)){const r=Object.keys(t),n=Object.keys(e).filter(l=>r.indexOf(l)!==-1),a={...e,...t};for(const l of n){const i=nt(e[l],t[l]);if(!i.valid)return{valid:!1,mergeErrorPath:[l,...i.mergeErrorPath]};a[l]=i.data}return{valid:!0,data:a}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const a=e[n],l=t[n],i=nt(a,l);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function _t(e,t,r){const n=new Map;let a;for(const c of t.issues)if(c.code==="unrecognized_keys"){a??(a=c);for(const u of c.keys)n.has(u)||n.set(u,{}),n.get(u).l=!0}else e.issues.push(c);for(const c of r.issues)if(c.code==="unrecognized_keys")for(const u of c.keys)n.has(u)||n.set(u,{}),n.get(u).r=!0;else e.issues.push(c);const l=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(l.length&&a&&e.issues.push({...a,keys:l}),ze(e))return e;const i=nt(t.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const Oa=p("$ZodRecord",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{const a=r.value;if(!Ne(a))return r.issues.push({expected:"record",code:"invalid_type",input:a,inst:e}),r;const l=[],i=t.keyType._zod.values;if(i){r.value={};const c=new Set;for(const m of i)if(typeof m=="string"||typeof m=="number"||typeof m=="symbol"){c.add(typeof m=="number"?m.toString():m);const h=t.valueType._zod.run({value:a[m],issues:[]},n);h instanceof Promise?l.push(h.then(f=>{f.issues.length&&r.issues.push(...je(m,f.issues)),r.value[m]=f.value})):(h.issues.length&&r.issues.push(...je(m,h.issues)),r.value[m]=h.value)}let u;for(const m in a)c.has(m)||(u=u??[],u.push(m));u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:a,inst:e,keys:u})}else{r.value={};for(const c of Reflect.ownKeys(a)){if(c==="__proto__")continue;let u=t.keyType._zod.run({value:c,issues:[]},n);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&Ht.test(c)&&u.issues.length){const f=t.keyType._zod.run({value:Number(c),issues:[]},n);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(u=f)}if(u.issues.length){t.mode==="loose"?r.value[c]=a[c]:r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(f=>he(f,n,pe())),input:c,path:[c],inst:e});continue}const h=t.valueType._zod.run({value:a[c],issues:[]},n);h instanceof Promise?l.push(h.then(f=>{f.issues.length&&r.issues.push(...je(c,f.issues)),r.value[u.value]=f.value})):(h.issues.length&&r.issues.push(...je(c,h.issues)),r.value[u.value]=h.value)}}return l.length?Promise.all(l).then(()=>r):r}}),Aa=p("$ZodEnum",(e,t)=>{M.init(e,t);const r=Lt(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(a=>Lr.has(typeof a)).map(a=>typeof a=="string"?Ce(a):a.toString()).join("|")})$`),e._zod.parse=(a,l)=>{const i=a.value;return n.has(i)||a.issues.push({code:"invalid_value",values:r,input:i,inst:e}),a}}),$a=p("$ZodLiteral",(e,t)=>{if(M.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?Ce(n):n?Ce(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,a)=>{const l=n.value;return r.has(l)||n.issues.push({code:"invalid_value",values:t.values,input:l,inst:e}),n}}),Ta=p("$ZodTransform",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Mt(e.constructor.name);const a=t.transform(r.value,r);if(n.async)return(a instanceof Promise?a:Promise.resolve(a)).then(i=>(r.value=i,r));if(a instanceof Promise)throw new Se;return r.value=a,r}});function kt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const or=p("$ZodOptional",(e,t)=>{M.init(e,t),e._zod.optin="optional",e._zod.optout="optional",N(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),N(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${it(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(l=>kt(l,r.value)):kt(a,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Za=p("$ZodExactOptional",(e,t)=>{or.init(e,t),N(e._zod,"values",()=>t.innerType._zod.values),N(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Ea=p("$ZodNullable",(e,t)=>{M.init(e,t),N(e._zod,"optin",()=>t.innerType._zod.optin),N(e._zod,"optout",()=>t.innerType._zod.optout),N(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${it(r.source)}|null)$`):void 0}),N(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Ia=p("$ZodDefault",(e,t)=>{M.init(e,t),e._zod.optin="optional",N(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(l=>wt(l,t)):wt(a,t)}});function wt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Pa=p("$ZodPrefault",(e,t)=>{M.init(e,t),e._zod.optin="optional",N(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Ra=p("$ZodNonOptional",(e,t)=>{M.init(e,t),N(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(l=>zt(l,e)):zt(a,e)}});function zt(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 Da=p("$ZodCatch",(e,t)=>{M.init(e,t),N(e._zod,"optin",()=>t.innerType._zod.optin),N(e._zod,"optout",()=>t.innerType._zod.optout),N(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(l=>(r.value=l.value,l.issues.length&&(r.value=t.catchValue({...r,error:{issues:l.issues.map(i=>he(i,n,pe()))},input:r.value}),r.issues=[]),r)):(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(l=>he(l,n,pe()))},input:r.value}),r.issues=[]),r)}}),Ma=p("$ZodPipe",(e,t)=>{M.init(e,t),N(e._zod,"values",()=>t.in._zod.values),N(e._zod,"optin",()=>t.in._zod.optin),N(e._zod,"optout",()=>t.out._zod.optout),N(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const l=t.out._zod.run(r,n);return l instanceof Promise?l.then(i=>Ue(i,t.in,n)):Ue(l,t.in,n)}const a=t.in._zod.run(r,n);return a instanceof Promise?a.then(l=>Ue(l,t.out,n)):Ue(a,t.out,n)}});function Ue(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const Ua=p("$ZodReadonly",(e,t)=>{M.init(e,t),N(e._zod,"propValues",()=>t.innerType._zod.propValues),N(e._zod,"values",()=>t.innerType._zod.values),N(e._zod,"optin",()=>t.innerType?._zod?.optin),N(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(jt):jt(a)}});function jt(e){return e.value=Object.freeze(e.value),e}const La=p("$ZodCustom",(e,t)=>{Y.init(e,t),M.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,a=t.fn(n);if(a instanceof Promise)return a.then(l=>St(l,r,n,e));St(a,r,n,e)}});function St(e,t,r,n){if(!e){const a={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(a.params=n._zod.def.params),t.issues.push(Pe(a))}}var Nt;class Fa{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const a={...n,...this._map.get(t)};return Object.keys(a).length?a:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Ja(){return new Fa}(Nt=globalThis).__zod_globalRegistry??(Nt.__zod_globalRegistry=Ja());const Ee=globalThis.__zod_globalRegistry;function Ba(e,t){return new e({type:"string",...b(t)})}function Ka(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...b(t)})}function Ct(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...b(t)})}function Va(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...b(t)})}function Wa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(t)})}function Ga(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(t)})}function qa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(t)})}function Ha(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(t)})}function Ya(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...b(t)})}function Xa(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(t)})}function Qa(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...b(t)})}function eo(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(t)})}function to(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...b(t)})}function ro(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...b(t)})}function no(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(t)})}function ao(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(t)})}function oo(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(t)})}function io(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(t)})}function so(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(t)})}function lo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...b(t)})}function co(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...b(t)})}function uo(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...b(t)})}function mo(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...b(t)})}function po(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(t)})}function ho(e,t){return new e({type:"string",format:"date",check:"string_format",...b(t)})}function fo(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...b(t)})}function go(e,t){return new e({type:"string",format:"duration",check:"string_format",...b(t)})}function bo(e,t){return new e({type:"number",checks:[],...b(t)})}function xo(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...b(t)})}function vo(e,t){return new e({type:"boolean",...b(t)})}function yo(e){return new e({type:"unknown"})}function _o(e,t){return new e({type:"never",...b(t)})}function Ot(e,t){return new Xt({check:"less_than",...b(t),value:e,inclusive:!1})}function Qe(e,t){return new Xt({check:"less_than",...b(t),value:e,inclusive:!0})}function At(e,t){return new Qt({check:"greater_than",...b(t),value:e,inclusive:!1})}function et(e,t){return new Qt({check:"greater_than",...b(t),value:e,inclusive:!0})}function $t(e,t){return new In({check:"multiple_of",...b(t),value:e})}function ir(e,t){return new Rn({check:"max_length",...b(t),maximum:e})}function Be(e,t){return new Dn({check:"min_length",...b(t),minimum:e})}function sr(e,t){return new Mn({check:"length_equals",...b(t),length:e})}function ko(e,t){return new Un({check:"string_format",format:"regex",...b(t),pattern:e})}function wo(e){return new Ln({check:"string_format",format:"lowercase",...b(e)})}function zo(e){return new Fn({check:"string_format",format:"uppercase",...b(e)})}function jo(e,t){return new Jn({check:"string_format",format:"includes",...b(t),includes:e})}function So(e,t){return new Bn({check:"string_format",format:"starts_with",...b(t),prefix:e})}function No(e,t){return new Kn({check:"string_format",format:"ends_with",...b(t),suffix:e})}function Oe(e){return new Vn({check:"overwrite",tx:e})}function Co(e){return Oe(t=>t.normalize(e))}function Oo(){return Oe(e=>e.trim())}function Ao(){return Oe(e=>e.toLowerCase())}function $o(){return Oe(e=>e.toUpperCase())}function To(){return Oe(e=>Mr(e))}function Zo(e,t,r){return new e({type:"array",element:t,...b(r)})}function Eo(e,t,r){return new e({type:"custom",check:"custom",fn:t,...b(r)})}function Io(e){const t=Po(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Pe(n,r.value,t._zod.def));else{const a=n;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=t),a.continue??(a.continue=!t._zod.def.abort),r.issues.push(Pe(a))}},e(r.value,r)));return t}function Po(e,t){const r=new Y({check:"custom",...b(t)});return r._zod.check=e,r}function lr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Ee,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function K(e,t,r={path:[],schemaPath:[]}){var n;const a=e._zod.def,l=t.seen.get(e);if(l)return l.count++,r.schemaPath.includes(e)&&(l.cycle=r.path),l.schema;const i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i);const c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{const h={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,h);else{const g=i.schema,x=t.processors[a.type];if(!x)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);x(e,t,g,h)}const f=e._zod.parent;f&&(i.ref||(i.ref=f),K(f,t,h),t.seen.get(f).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Object.assign(i.schema,u),t.io==="input"&&q(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function cr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const i of e.seen.entries()){const c=e.metadataRegistry.get(i[0])?.id;if(c){const u=n.get(c);if(u&&u!==i[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,i[0])}}const a=i=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const f=e.external.registry.get(i[0])?.id,g=e.external.uri??(F=>F);if(f)return{ref:g(f)};const x=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=x,{defId:x,ref:`${g("__shared")}#/${c}/${x}`}}if(i[1]===r)return{ref:"#"};const m=`#/${c}/`,h=i[1].schema.id??`__schema${e.counter++}`;return{defId:h,ref:m+h}},l=i=>{if(i[1].schema.$ref)return;const c=i[1],{ref:u,defId:m}=a(i);c.def={...c.schema},m&&(c.defId=m);const h=c.schema;for(const f in h)delete h[f];h.$ref=u};if(e.cycles==="throw")for(const i of e.seen.entries()){const c=i[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
38
38
 
39
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const c=i[1];if(t===i[0]){l(i);continue}if(e.external){const m=e.external.registry.get(i[0])?.id;if(t!==i[0]&&m){l(i);continue}}if(e.metadataRegistry.get(i[0])?.id){l(i);continue}if(c.cycle){l(i);continue}if(c.count>1&&e.reused==="ref"){l(i);continue}}}function ur(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=i=>{const c=e.seen.get(i);if(c.ref===null)return;const u=c.def??c.schema,m={...u},h=c.ref;if(c.ref=null,h){n(h);const g=e.seen.get(h),x=g.schema;if(x.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(x)):Object.assign(u,x),Object.assign(u,m),i._zod.parent===h)for(const d in u)d==="$ref"||d==="allOf"||d in m||delete u[d];if(x.$ref&&g.def)for(const d in u)d==="$ref"||d==="allOf"||d in g.def&&JSON.stringify(u[d])===JSON.stringify(g.def[d])&&delete u[d]}const f=i._zod.parent;if(f&&f!==h){n(f);const g=e.seen.get(f);if(g?.schema.$ref&&(u.$ref=g.schema.$ref,g.def))for(const x in u)x==="$ref"||x==="allOf"||x in g.def&&JSON.stringify(u[x])===JSON.stringify(g.def[x])&&delete u[x]}e.override({zodSchema:i,jsonSchema:u,path:c.path??[]})};for(const i of[...e.seen.entries()].reverse())n(i[0]);const a={};if(e.target==="draft-2020-12"?a.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?a.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?a.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(i)}Object.assign(a,r.def??r.schema);const l=e.external?.defs??{};for(const i of e.seen.entries()){const c=i[1];c.def&&c.defId&&(l[c.defId]=c.def)}e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?a.$defs=l:a.definitions=l);try{const i=JSON.parse(JSON.stringify(a));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ke(t,"input",e.processors),output:Ke(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function q(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return q(n.element,r);if(n.type==="set")return q(n.valueType,r);if(n.type==="lazy")return q(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return q(n.innerType,r);if(n.type==="intersection")return q(n.left,r)||q(n.right,r);if(n.type==="record"||n.type==="map")return q(n.keyType,r)||q(n.valueType,r);if(n.type==="pipe")return q(n.in,r)||q(n.out,r);if(n.type==="object"){for(const a in n.shape)if(q(n.shape[a],r))return!0;return!1}if(n.type==="union"){for(const a of n.options)if(q(a,r))return!0;return!1}if(n.type==="tuple"){for(const a of n.items)if(q(a,r))return!0;return!!(n.rest&&q(n.rest,r))}return!1}const Ro=(e,t={})=>r=>{const n=lr({...r,processors:t});return K(e,n),cr(n,e),ur(n,e)},Ke=(e,t,r={})=>n=>{const{libraryOptions:a,target:l}=n??{},i=lr({...a??{},target:l,io:t,processors:r});return K(e,i),cr(i,e),ur(i,e)},Do={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Mo=(e,t,r,n)=>{const a=r;a.type="string";const{minimum:l,maximum:i,format:c,patterns:u,contentEncoding:m}=e._zod.bag;if(typeof l=="number"&&(a.minLength=l),typeof i=="number"&&(a.maxLength=i),c&&(a.format=Do[c]??c,a.format===""&&delete a.format,c==="time"&&delete a.format),m&&(a.contentEncoding=m),u&&u.size>0){const h=[...u];h.length===1?a.pattern=h[0].source:h.length>1&&(a.allOf=[...h.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Uo=(e,t,r,n)=>{const a=r,{minimum:l,maximum:i,format:c,multipleOf:u,exclusiveMaximum:m,exclusiveMinimum:h}=e._zod.bag;typeof c=="string"&&c.includes("int")?a.type="integer":a.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(a.minimum=h,a.exclusiveMinimum=!0):a.exclusiveMinimum=h),typeof l=="number"&&(a.minimum=l,typeof h=="number"&&t.target!=="draft-04"&&(h>=l?delete a.minimum:delete a.exclusiveMinimum)),typeof m=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(a.maximum=m,a.exclusiveMaximum=!0):a.exclusiveMaximum=m),typeof i=="number"&&(a.maximum=i,typeof m=="number"&&t.target!=="draft-04"&&(m<=i?delete a.maximum:delete a.exclusiveMaximum)),typeof u=="number"&&(a.multipleOf=u)},Lo=(e,t,r,n)=>{r.type="boolean"},Fo=(e,t,r,n)=>{r.not={}},Jo=(e,t,r,n)=>{},Bo=(e,t,r,n)=>{const a=e._zod.def,l=Lt(a.entries);l.every(i=>typeof i=="number")&&(r.type="number"),l.every(i=>typeof i=="string")&&(r.type="string"),r.enum=l},Ko=(e,t,r,n)=>{const a=e._zod.def,l=[];for(const i of a.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");l.push(Number(i))}else l.push(i);if(l.length!==0)if(l.length===1){const i=l[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else l.every(i=>typeof i=="number")&&(r.type="number"),l.every(i=>typeof i=="string")&&(r.type="string"),l.every(i=>typeof i=="boolean")&&(r.type="boolean"),l.every(i=>i===null)&&(r.type="null"),r.enum=l},Vo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Wo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Go=(e,t,r,n)=>{const a=r,l=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;typeof i=="number"&&(a.minItems=i),typeof c=="number"&&(a.maxItems=c),a.type="array",a.items=K(l.element,t,{...n,path:[...n.path,"items"]})},qo=(e,t,r,n)=>{const a=r,l=e._zod.def;a.type="object",a.properties={};const i=l.shape;for(const m in i)a.properties[m]=K(i[m],t,{...n,path:[...n.path,"properties",m]});const c=new Set(Object.keys(i)),u=new Set([...c].filter(m=>{const h=l.shape[m]._zod;return t.io==="input"?h.optin===void 0:h.optout===void 0}));u.size>0&&(a.required=Array.from(u)),l.catchall?._zod.def.type==="never"?a.additionalProperties=!1:l.catchall?l.catchall&&(a.additionalProperties=K(l.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},Ho=(e,t,r,n)=>{const a=e._zod.def,l=a.inclusive===!1,i=a.options.map((c,u)=>K(c,t,{...n,path:[...n.path,l?"oneOf":"anyOf",u]}));l?r.oneOf=i:r.anyOf=i},Yo=(e,t,r,n)=>{const a=e._zod.def,l=K(a.left,t,{...n,path:[...n.path,"allOf",0]}),i=K(a.right,t,{...n,path:[...n.path,"allOf",1]}),c=m=>"allOf"in m&&Object.keys(m).length===1,u=[...c(l)?l.allOf:[l],...c(i)?i.allOf:[i]];r.allOf=u},Xo=(e,t,r,n)=>{const a=r,l=e._zod.def;a.type="object";const i=l.keyType,u=i._zod.bag?.patterns;if(l.mode==="loose"&&u&&u.size>0){const h=K(l.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});a.patternProperties={};for(const f of u)a.patternProperties[f.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(a.propertyNames=K(l.keyType,t,{...n,path:[...n.path,"propertyNames"]})),a.additionalProperties=K(l.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const m=i._zod.values;if(m){const h=[...m].filter(f=>typeof f=="string"||typeof f=="number");h.length>0&&(a.required=h)}},Qo=(e,t,r,n)=>{const a=e._zod.def,l=K(a.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=a.innerType,r.nullable=!0):r.anyOf=[l,{type:"null"}]},ei=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType},ti=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType,r.default=JSON.parse(JSON.stringify(a.defaultValue))},ri=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},ni=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType;let i;try{i=a.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},ai=(e,t,r,n)=>{const a=e._zod.def,l=t.io==="input"?a.in._zod.def.type==="transform"?a.out:a.in:a.out;K(l,t,n);const i=t.seen.get(e);i.ref=l},oi=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType,r.readOnly=!0},dr=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType},ii=p("ZodISODateTime",(e,t)=>{ia.init(e,t),L.init(e,t)});function si(e){return po(ii,e)}const li=p("ZodISODate",(e,t)=>{sa.init(e,t),L.init(e,t)});function ci(e){return ho(li,e)}const ui=p("ZodISOTime",(e,t)=>{la.init(e,t),L.init(e,t)});function di(e){return fo(ui,e)}const mi=p("ZodISODuration",(e,t)=>{ca.init(e,t),L.init(e,t)});function pi(e){return go(mi,e)}const hi=(e,t)=>{Kt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Xr(e,r)},flatten:{value:r=>Yr(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,rt,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,rt,2)}},isEmpty:{get(){return e.issues.length===0}}})},te=p("ZodError",hi,{Parent:Error}),fi=lt(te),gi=ct(te),bi=We(te),xi=Ge(te),vi=tn(te),yi=rn(te),_i=nn(te),ki=an(te),wi=on(te),zi=sn(te),ji=ln(te),Si=cn(te),U=p("ZodType",(e,t)=>(M.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ke(e,"input"),output:Ke(e,"output")}}),e.toJSONSchema=Ro(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(fe(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>ge(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>fi(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>bi(e,r,n),e.parseAsync=async(r,n)=>gi(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>xi(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>vi(e,r,n),e.decode=(r,n)=>yi(e,r,n),e.encodeAsync=async(r,n)=>_i(e,r,n),e.decodeAsync=async(r,n)=>ki(e,r,n),e.safeEncode=(r,n)=>wi(e,r,n),e.safeDecode=(r,n)=>zi(e,r,n),e.safeEncodeAsync=async(r,n)=>ji(e,r,n),e.safeDecodeAsync=async(r,n)=>Si(e,r,n),e.refine=(r,n)=>e.check(ys(r,n)),e.superRefine=r=>e.check(_s(r)),e.overwrite=r=>e.check(Oe(r)),e.optional=()=>Pt(e),e.exactOptional=()=>ss(e),e.nullable=()=>Rt(e),e.nullish=()=>Pt(Rt(e)),e.nonoptional=r=>ps(e,r),e.array=()=>ae(e),e.or=r=>fr([e,r]),e.and=r=>ts(e,r),e.transform=r=>Dt(e,os(r)),e.default=r=>us(e,r),e.prefault=r=>ms(e,r),e.catch=r=>fs(e,r),e.pipe=r=>Dt(e,r),e.readonly=()=>xs(e),e.describe=r=>{const n=e.clone();return Ee.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Ee.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Ee.get(e);const n=e.clone();return Ee.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),mr=p("_ZodString",(e,t)=>{ut.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,l)=>Mo(e,n,a);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(ko(...n)),e.includes=(...n)=>e.check(jo(...n)),e.startsWith=(...n)=>e.check(So(...n)),e.endsWith=(...n)=>e.check(No(...n)),e.min=(...n)=>e.check(Be(...n)),e.max=(...n)=>e.check(ir(...n)),e.length=(...n)=>e.check(sr(...n)),e.nonempty=(...n)=>e.check(Be(1,...n)),e.lowercase=n=>e.check(wo(n)),e.uppercase=n=>e.check(zo(n)),e.trim=()=>e.check(Oo()),e.normalize=(...n)=>e.check(Co(...n)),e.toLowerCase=()=>e.check(Ao()),e.toUpperCase=()=>e.check($o()),e.slugify=()=>e.check(To())}),Ni=p("ZodString",(e,t)=>{ut.init(e,t),mr.init(e,t),e.email=r=>e.check(Ka(Ci,r)),e.url=r=>e.check(Ha(Oi,r)),e.jwt=r=>e.check(mo(Bi,r)),e.emoji=r=>e.check(Ya(Ai,r)),e.guid=r=>e.check(Ct(Tt,r)),e.uuid=r=>e.check(Va(Le,r)),e.uuidv4=r=>e.check(Wa(Le,r)),e.uuidv6=r=>e.check(Ga(Le,r)),e.uuidv7=r=>e.check(qa(Le,r)),e.nanoid=r=>e.check(Xa($i,r)),e.guid=r=>e.check(Ct(Tt,r)),e.cuid=r=>e.check(Qa(Ti,r)),e.cuid2=r=>e.check(eo(Zi,r)),e.ulid=r=>e.check(to(Ei,r)),e.base64=r=>e.check(lo(Li,r)),e.base64url=r=>e.check(co(Fi,r)),e.xid=r=>e.check(ro(Ii,r)),e.ksuid=r=>e.check(no(Pi,r)),e.ipv4=r=>e.check(ao(Ri,r)),e.ipv6=r=>e.check(oo(Di,r)),e.cidrv4=r=>e.check(io(Mi,r)),e.cidrv6=r=>e.check(so(Ui,r)),e.e164=r=>e.check(uo(Ji,r)),e.datetime=r=>e.check(si(r)),e.date=r=>e.check(ci(r)),e.time=r=>e.check(di(r)),e.duration=r=>e.check(pi(r))});function v(e){return Ba(Ni,e)}const L=p("ZodStringFormat",(e,t)=>{D.init(e,t),mr.init(e,t)}),Ci=p("ZodEmail",(e,t)=>{Yn.init(e,t),L.init(e,t)}),Tt=p("ZodGUID",(e,t)=>{qn.init(e,t),L.init(e,t)}),Le=p("ZodUUID",(e,t)=>{Hn.init(e,t),L.init(e,t)}),Oi=p("ZodURL",(e,t)=>{Xn.init(e,t),L.init(e,t)}),Ai=p("ZodEmoji",(e,t)=>{Qn.init(e,t),L.init(e,t)}),$i=p("ZodNanoID",(e,t)=>{ea.init(e,t),L.init(e,t)}),Ti=p("ZodCUID",(e,t)=>{ta.init(e,t),L.init(e,t)}),Zi=p("ZodCUID2",(e,t)=>{ra.init(e,t),L.init(e,t)}),Ei=p("ZodULID",(e,t)=>{na.init(e,t),L.init(e,t)}),Ii=p("ZodXID",(e,t)=>{aa.init(e,t),L.init(e,t)}),Pi=p("ZodKSUID",(e,t)=>{oa.init(e,t),L.init(e,t)}),Ri=p("ZodIPv4",(e,t)=>{ua.init(e,t),L.init(e,t)}),Di=p("ZodIPv6",(e,t)=>{da.init(e,t),L.init(e,t)}),Mi=p("ZodCIDRv4",(e,t)=>{ma.init(e,t),L.init(e,t)}),Ui=p("ZodCIDRv6",(e,t)=>{pa.init(e,t),L.init(e,t)}),Li=p("ZodBase64",(e,t)=>{ha.init(e,t),L.init(e,t)}),Fi=p("ZodBase64URL",(e,t)=>{ga.init(e,t),L.init(e,t)}),Ji=p("ZodE164",(e,t)=>{ba.init(e,t),L.init(e,t)}),Bi=p("ZodJWT",(e,t)=>{va.init(e,t),L.init(e,t)}),pr=p("ZodNumber",(e,t)=>{tr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,l)=>Uo(e,n,a),e.gt=(n,a)=>e.check(At(n,a)),e.gte=(n,a)=>e.check(et(n,a)),e.min=(n,a)=>e.check(et(n,a)),e.lt=(n,a)=>e.check(Ot(n,a)),e.lte=(n,a)=>e.check(Qe(n,a)),e.max=(n,a)=>e.check(Qe(n,a)),e.int=n=>e.check(Zt(n)),e.safe=n=>e.check(Zt(n)),e.positive=n=>e.check(At(0,n)),e.nonnegative=n=>e.check(et(0,n)),e.negative=n=>e.check(Ot(0,n)),e.nonpositive=n=>e.check(Qe(0,n)),e.multipleOf=(n,a)=>e.check($t(n,a)),e.step=(n,a)=>e.check($t(n,a)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function I(e){return bo(pr,e)}const Ki=p("ZodNumberFormat",(e,t)=>{ya.init(e,t),pr.init(e,t)});function Zt(e){return xo(Ki,e)}const Vi=p("ZodBoolean",(e,t)=>{_a.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Lo(e,r,n)});function G(e){return vo(Vi,e)}const Wi=p("ZodUnknown",(e,t)=>{ka.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Jo()});function Et(){return yo(Wi)}const Gi=p("ZodNever",(e,t)=>{wa.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Fo(e,r,n)});function qi(e){return _o(Gi,e)}const Hi=p("ZodArray",(e,t)=>{za.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Go(e,r,n,a),e.element=t.element,e.min=(r,n)=>e.check(Be(r,n)),e.nonempty=r=>e.check(Be(1,r)),e.max=(r,n)=>e.check(ir(r,n)),e.length=(r,n)=>e.check(sr(r,n)),e.unwrap=()=>e.element});function ae(e,t){return Zo(Hi,e,t)}const Yi=p("ZodObject",(e,t)=>{Sa.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>qo(e,r,n,a),N(e,"shape",()=>t.shape),e.keyof=()=>ne(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Et()}),e.loose=()=>e.clone({...e._zod.def,catchall:Et()}),e.strict=()=>e.clone({...e._zod.def,catchall:qi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Vr(e,r),e.safeExtend=r=>Wr(e,r),e.merge=r=>Gr(e,r),e.pick=r=>Br(e,r),e.omit=r=>Kr(e,r),e.partial=(...r)=>qr(gr,e,r[0]),e.required=(...r)=>Hr(br,e,r[0])});function R(e,t){const r={type:"object",shape:e??{},...b(t)};return new Yi(r)}const hr=p("ZodUnion",(e,t)=>{ar.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Ho(e,r,n,a),e.options=t.options});function fr(e,t){return new hr({type:"union",options:e,...b(t)})}const Xi=p("ZodDiscriminatedUnion",(e,t)=>{hr.init(e,t),Na.init(e,t)});function Qi(e,t,r){return new Xi({type:"union",options:t,discriminator:e,...b(r)})}const es=p("ZodIntersection",(e,t)=>{Ca.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Yo(e,r,n,a)});function ts(e,t){return new es({type:"intersection",left:e,right:t})}const rs=p("ZodRecord",(e,t)=>{Oa.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Xo(e,r,n,a),e.keyType=t.keyType,e.valueType=t.valueType});function Fe(e,t,r){return new rs({type:"record",keyType:e,valueType:t,...b(r)})}const at=p("ZodEnum",(e,t)=>{Aa.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,l)=>Bo(e,n,a),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,a)=>{const l={};for(const i of n)if(r.has(i))l[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new at({...t,checks:[],...b(a),entries:l})},e.exclude=(n,a)=>{const l={...t.entries};for(const i of n)if(r.has(i))delete l[i];else throw new Error(`Key ${i} not found in enum`);return new at({...t,checks:[],...b(a),entries:l})}});function ne(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new at({type:"enum",entries:r,...b(t)})}const ns=p("ZodLiteral",(e,t)=>{$a.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Ko(e,r,n),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 It(e,t){return new ns({type:"literal",values:Array.isArray(e)?e:[e],...b(t)})}const as=p("ZodTransform",(e,t)=>{Ta.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Wo(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Mt(e.constructor.name);r.addIssue=l=>{if(typeof l=="string")r.issues.push(Pe(l,r.value,t));else{const i=l;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(Pe(i))}};const a=t.transform(r.value,r);return a instanceof Promise?a.then(l=>(r.value=l,r)):(r.value=a,r)}});function os(e){return new as({type:"transform",transform:e})}const gr=p("ZodOptional",(e,t)=>{or.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>dr(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Pt(e){return new gr({type:"optional",innerType:e})}const is=p("ZodExactOptional",(e,t)=>{Za.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>dr(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function ss(e){return new is({type:"optional",innerType:e})}const ls=p("ZodNullable",(e,t)=>{Ea.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Qo(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Rt(e){return new ls({type:"nullable",innerType:e})}const cs=p("ZodDefault",(e,t)=>{Ia.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ti(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function us(e,t){return new cs({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Jt(t)}})}const ds=p("ZodPrefault",(e,t)=>{Pa.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ri(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function ms(e,t){return new ds({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Jt(t)}})}const br=p("ZodNonOptional",(e,t)=>{Ra.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ei(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function ps(e,t){return new br({type:"nonoptional",innerType:e,...b(t)})}const hs=p("ZodCatch",(e,t)=>{Da.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ni(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fs(e,t){return new hs({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const gs=p("ZodPipe",(e,t)=>{Ma.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ai(e,r,n,a),e.in=t.in,e.out=t.out});function Dt(e,t){return new gs({type:"pipe",in:e,out:t})}const bs=p("ZodReadonly",(e,t)=>{Ua.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>oi(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function xs(e){return new bs({type:"readonly",innerType:e})}const vs=p("ZodCustom",(e,t)=>{La.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Vo(e,r)});function ys(e,t={}){return Eo(vs,e,t)}function _s(e){return Io(e)}const A={agent:{name:"morpheus",personality:"helpful_dev"},logging:{enabled:!0,level:"info",retention:"14d"},audio:{provider:"google",model:"gemini-2.5-flash-lite",enabled:!0,maxDurationSeconds:300,supportedMimeTypes:["audio/ogg","audio/mp3","audio/mpeg","audio/wav"],tts:{enabled:!1,provider:"google",model:"gemini-2.5-flash-preview-tts",voice:"Kore"}},memory:{limit:100},runtime:{async_tasks:{enabled:!0}},llm:{provider:"openai",model:"gpt-4",temperature:.7,context_window:100},channels:{telegram:{enabled:!1,allowedUsers:[]},discord:{enabled:!1,allowedUsers:[]}},ui:{enabled:!0,port:3333}},ks=R({enabled:G().default(!1),provider:ne(["openai","google"]).default("google"),model:v().min(1).default("gemini-2.5-flash-preview-tts"),voice:v().min(1).default("Kore"),apiKey:v().optional(),style_prompt:v().optional()}),ws=R({provider:ne(["google","openai","openrouter","ollama"]).default(A.audio.provider),model:v().min(1).default(A.audio.model),enabled:G().default(A.audio.enabled),apiKey:v().optional(),base_url:v().optional(),maxDurationSeconds:I().default(A.audio.maxDurationSeconds),supportedMimeTypes:ae(v()).default(A.audio.supportedMimeTypes),tts:ks.optional()}),Ae=R({provider:ne(["openai","anthropic","openrouter","ollama","gemini"]).default(A.llm.provider),model:v().min(1).default(A.llm.model),temperature:I().min(0).max(1).default(A.llm.temperature),max_tokens:I().int().positive().optional(),api_key:v().optional(),base_url:v().optional(),context_window:I().int().positive().optional()}),zs=Ae.extend({memory_limit:I().int().positive().optional(),enabled_archived_sessions:G().default(!0),similarity_threshold:I().min(0).max(1).default(.9),evaluation_interval:I().int().min(1).default(1)}),js=Ae.extend({working_dir:v().optional(),timeout_ms:I().int().positive().optional(),execution_mode:ne(["sync","async"]).default("async")}),Ss=Ae.extend({execution_mode:ne(["sync","async"]).default("async")}),Ns=Ae.extend({execution_mode:ne(["sync","async"]).default("async")}),Cs=Ae.extend({personality:v().optional(),chunk_size:I().int().positive().default(500),score_threshold:I().min(0).max(1).default(.5),max_results:I().int().positive().default(10),execution_mode:ne(["sync","async"]).default("async"),scan_interval_ms:I().int().min(5e3).default(3e4),max_file_size_mb:I().int().positive().default(50),vector_weight:I().min(0).max(1).default(.8),bm25_weight:I().min(0).max(1).default(.2)}),Os=R({telegram_notify_all:G().optional()}).optional(),As=R({timezone:v().default("UTC"),check_interval_ms:I().min(6e4).default(6e4),max_active_jobs:I().min(1).max(1e3).default(100)}),$s=R({sandbox_dir:v().optional(),readonly_mode:G().default(!1),allowed_shell_commands:ae(v()).default([]),allowed_paths:ae(v()).default([]),enable_filesystem:G().default(!0),enable_shell:G().default(!0),enable_git:G().default(!0),enable_network:G().default(!0),timeout_ms:I().int().positive().default(3e4)}),Ts=R({name:v().min(1).max(64).regex(/^[a-z0-9][a-z0-9_-]*$/,"Smith name must be lowercase alphanumeric with hyphens/underscores"),host:v().min(1),port:I().int().min(1).max(65535).default(7900),auth_token:v().min(1),tls:G().default(!1)}),Zs=R({enabled:G().default(!0),fields:ae(v()).default(["name","timezone","preferred_language"])}),Es=R({enabled:G().default(!1),execution_mode:ne(["sync","async"]).default("async"),heartbeat_interval_ms:I().int().min(5e3).default(3e4),connection_timeout_ms:I().int().min(1e3).default(1e4),task_timeout_ms:I().int().min(1e3).default(6e4),entries:ae(Ts).default([])}),Is=R({code:v().min(1).default("USD"),symbol:v().min(1).default("$"),rate:I().positive().default(1)}),Ps=R({service_account_json:v().optional(),service_account_json_content:v().optional(),enabled:G().default(!0)}),Rs=R({agent:R({name:v().default(A.agent.name),personality:v().default(A.agent.personality)}).default(A.agent),llm:Ae.default(A.llm),sati:zs.optional(),neo:Ss.optional(),apoc:js.optional(),trinity:Ns.optional(),link:Cs.optional(),webhooks:Os,audio:ws.default(A.audio),memory:R({limit:I().int().positive().optional()}).default(A.memory),runtime:R({async_tasks:R({enabled:G().default(A.runtime?.async_tasks.enabled)}).default(A.runtime?.async_tasks??{enabled:!0})}).optional(),chronos:As.optional(),devkit:$s.optional(),smiths:Es.optional(),gws:Ps.optional(),setup:Zs.optional(),currency:Is.optional(),verbose_mode:G().default(!0),channels:R({telegram:R({enabled:G().default(!1),token:v().optional(),allowedUsers:ae(v()).default([])}).default(A.channels.telegram),discord:R({enabled:G().default(!1),token:v().optional(),allowedUsers:ae(v()).default([])}).default(A.channels.discord)}).default(A.channels),ui:R({enabled:G().default(A.ui.enabled),port:I().default(A.ui.port)}).default(A.ui),logging:R({enabled:G().default(A.logging.enabled),level:ne(["debug","info","warn","error"]).default(A.logging.level),retention:v().default(A.logging.retention)}).default(A.logging)}),Ds=R({grant_type:ne(["client_credentials","authorization_code"]).default("authorization_code"),client_id:v().optional(),client_secret:v().optional(),scope:v().optional()}),Ms=Qi("transport",[R({transport:It("stdio"),command:v().min(1,"Command is required for stdio transport"),args:ae(v()).optional().default([]),env:Fe(v(),v()).optional().default({}),_comment:v().optional()}),R({transport:It("http"),url:v().url("Valid URL is required for http transport"),headers:Fe(v(),v()).optional().default({}),oauth2:Ds.optional(),args:ae(v()).optional().default([]),env:Fe(v(),v()).optional().default({}),_comment:v().optional()})]);Fe(v(),fr([Ms,v()]));const Us={resetData:async e=>tt.delete("/danger/reset",{categories:e})},Ls=[{id:"general",label:"General"},{id:"agents",label:"Agents"},{id:"devkit",label:"DevKit"},{id:"gws",label:"GWS"},{id:"audio",label:"Audio"},{id:"channels",label:"Channels"},{id:"ui",label:"Interface"},{id:"chronos",label:"Chronos"},{id:"danger",label:"Danger Zone"}],Fs=[{id:"oracle",label:"Oracle"},{id:"sati",label:"Sati"},{id:"neo",label:"Neo"},{id:"apoc",label:"Apoc"},{id:"trinity",label:"Trinity"},{id:"link",label:"Link"}],Ze=[{label:"OpenAI",value:"openai"},{label:"Anthropic",value:"anthropic"},{label:"OpenRouter",value:"openrouter"},{label:"Ollama",value:"ollama"},{label:"Google Gemini",value:"gemini"}];function tl(){const{data:e,error:t}=se("/api/config",ee.fetchConfig),{data:r}=se("/api/config/sati",ee.getSatiConfig),{data:n}=se("/api/config/apoc",ee.getApocConfig),{data:a}=se("/api/config/neo",ee.getNeoConfig),{data:l}=se("/api/config/trinity",ee.getTrinityConfig),{data:i}=se("/api/link/config",()=>tt.get("/link/config")),{data:c}=se("/api/config/encryption-status",()=>ee.getEncryptionStatus()),{data:u}=se("/api/config/env-overrides",()=>ee.getEnvOverrides()),{data:m=[]}=se("/api/model-presets",ft.list),{data:h}=Tr(),[f,g]=P.useState(null),[x,F]=P.useState({}),[d,oe]=P.useState(null),[$,ve]=P.useState(null),[z,J]=P.useState(null),[j,ye]=P.useState(null),[T,$e]=P.useState(null),[Z,Re]=P.useState(null),[re,xr]=P.useState("general"),[be,vr]=P.useState("oracle"),[dt,mt]=P.useState(!1),[H,De]=P.useState({}),[He,Te]=P.useState(null);P.useEffect(()=>{e&&!d&&oe(e)},[e]),P.useEffect(()=>{r&&!$&&ve(r)},[r]),P.useEffect(()=>{n&&!j?ye(n):!n&&!j&&d&&ye({...d.apoc??d.llm,temperature:d.apoc?.temperature??.2,timeout_ms:d.apoc?.timeout_ms??3e4})},[n,d]),P.useEffect(()=>{a&&!z?J(a):!a&&!z&&d&&J({...d.neo??d.llm,temperature:d.neo?.temperature??.2})},[a,d]),P.useEffect(()=>{l&&!T?$e(l):!l&&!T&&d&&$e({...d.trinity??d.llm,temperature:d.trinity?.temperature??.2})},[l,d]),P.useEffect(()=>{h&&!f&&g(h)},[h]),P.useEffect(()=>{i&&!Z&&Re(i)},[i]);const pt=JSON.stringify(e)!==JSON.stringify(d)||JSON.stringify(r)!==JSON.stringify($)||JSON.stringify(a)!==JSON.stringify(z)||JSON.stringify(n)!==JSON.stringify(j)||JSON.stringify(l)!==JSON.stringify(T)||JSON.stringify(h)!==JSON.stringify(f)||JSON.stringify(i)!==JSON.stringify(Z),yr={general:JSON.stringify(e?.agent)!==JSON.stringify(d?.agent)||e?.verbose_mode!==d?.verbose_mode,agents:JSON.stringify(e?.llm)!==JSON.stringify(d?.llm)||JSON.stringify(r)!==JSON.stringify($)||JSON.stringify(a)!==JSON.stringify(z)||JSON.stringify(n)!==JSON.stringify(j)||JSON.stringify(l)!==JSON.stringify(T)||JSON.stringify(i)!==JSON.stringify(Z),devkit:JSON.stringify(e?.devkit)!==JSON.stringify(d?.devkit),gws:JSON.stringify(e?.gws)!==JSON.stringify(d?.gws),audio:JSON.stringify(e?.audio)!==JSON.stringify(d?.audio),channels:JSON.stringify(e?.channels?.telegram)!==JSON.stringify(d?.channels?.telegram)||JSON.stringify(e?.channels?.discord)!==JSON.stringify(d?.channels?.discord)||JSON.stringify(e?.webhooks)!==JSON.stringify(d?.webhooks),ui:JSON.stringify(e?.ui)!==JSON.stringify(d?.ui),logging:JSON.stringify(e?.logging)!==JSON.stringify(d?.logging),chronos:JSON.stringify(h)!==JSON.stringify(f)},_e=(s,k)=>{if(!c?.apiKeysEncrypted)return null;const{morpheusSecretSet:E,apiKeysEncrypted:C}=c,B=C[s];return!k?o.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-azure-surface border border-azure-border text-azure-text-secondary dark:bg-matrix-primary/10 dark:border-matrix-primary dark:text-matrix-tertiary",children:"No API key"}):u&&u[_r(s)]?null:E?B?o.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-emerald-100 border border-emerald-300 text-emerald-800 dark:bg-emerald-900/30 dark:border-emerald-700 dark:text-emerald-400",title:"API key encrypted with AES-256-GCM",children:"🔒 Encrypted"}):o.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-amber-100 border border-amber-300 text-amber-800 dark:bg-amber-900/30 dark:border-amber-700 dark:text-amber-400",title:"Re-save this configuration to encrypt the API key",children:"⚠️ Re-save to encrypt"}):o.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-amber-100 border border-amber-300 text-amber-800 dark:bg-amber-900/30 dark:border-amber-700 dark:text-amber-400",title:"Set MORPHEUS_SECRET to enable encryption",children:"⚠️ Plaintext"})},_r=s=>({oracle:"llm.api_key",sati:"sati.api_key",neo:"neo.api_key",apoc:"apoc.api_key",trinity:"trinity.api_key",audio:"audio.apiKey"})[s],S=s=>!u||!u[s]?null:o.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-blue-100 border border-blue-300 text-blue-800 dark:bg-blue-900/30 dark:border-blue-700 dark:text-blue-400",title:"This field is set by an environment variable and cannot be edited",children:"🔒 Env Var"}),_=s=>!!(u&&u[s]),y=(s,k)=>{if(!d)return;const E=JSON.parse(JSON.stringify(d));let C=E;for(let B=0;B<s.length-1;B++)(C[s[B]]===void 0||C[s[B]]===null)&&(C[s[B]]={}),C=C[s[B]];C[s[s.length-1]]=k,oe(E);try{Rs.parse(E),De({})}catch(B){if(B instanceof $r){const de={};B.errors.forEach(ht=>{const Or=ht.path.join(".");de[Or]=ht.message}),De(de)}}},Ye=[{code:"USD",symbol:"$",label:"USD — US Dollar ($)"},{code:"BRL",symbol:"R$",label:"BRL — Brazilian Real (R$)"},{code:"CAD",symbol:"CA$",label:"CAD — Canadian Dollar (CA$)"},{code:"EUR",symbol:"€",label:"EUR — Euro (€)"},{code:"JPY",symbol:"¥",label:"JPY — Japanese Yen (¥)"},{code:"GBP",symbol:"£",label:"GBP — British Pound (£)"},{code:"AUD",symbol:"A$",label:"AUD — Australian Dollar (A$)"},{code:"CHF",symbol:"CHF",label:"CHF — Swiss Franc (CHF)"},{code:"ARS",symbol:"$",label:"ARS — Argentine Peso ($)"},{code:"OTHER",symbol:"",label:"Other…"}],kr=s=>{if(!d)return;const k=Ye.find(B=>B.code===s),E=k&&s!=="OTHER"?{code:k.code,symbol:k.symbol,rate:s==="USD"?1:d.currency?.rate??1}:{code:"",symbol:"",rate:d.currency?.rate??1},C={...d,currency:E};oe(C)},le=(s,k)=>{$&&ve({...$,[s]:k})},ce=(s,k)=>{j&&ye({...j,[s]:k})},ie=(s,k)=>{z&&J({...z,[s]:k})},ue=(s,k)=>{T&&$e({...T,[s]:k})},wr=()=>{!d||!T||$e({...T,provider:d.llm.provider,model:d.llm.model,api_key:d.llm.api_key})},zr=()=>{!d||!$||ve({...$,provider:d.llm.provider,model:d.llm.model,api_key:d.llm.api_key})},jr=()=>{!d||!j||ye({...j,provider:d.llm.provider,model:d.llm.model,api_key:d.llm.api_key})},Sr=()=>{!d||!z||J({...z,provider:d.llm.provider,model:d.llm.model,api_key:d.llm.api_key})},X=(s,k)=>{Z&&Re({...Z,[s]:k})},Nr=()=>{!d||!Z||Re({...Z,provider:d.llm.provider,model:d.llm.model,api_key:d.llm.api_key})},ke=async(s,k)=>{if(!s)return;const E=m.find(de=>de.id===s);if(!E)return;let C;E.has_api_key&&(C=(await ft.decryptApiKey(s)).api_key??void 0);const B={provider:E.provider,model:E.model,api_key:C,base_url:E.base_url??void 0,...E.temperature!=null?{temperature:E.temperature}:{},...E.max_tokens!=null?{max_tokens:E.max_tokens}:{}};switch(k){case"oracle":if(!d)return;oe({...d,llm:{...d.llm,...B}});break;case"sati":if(!$)return;ve({...$,...B});break;case"neo":if(!z)return;J({...z,...B});break;case"apoc":if(!j)return;ye({...j,...B});break;case"trinity":if(!T)return;$e({...T,...B});break;case"link":if(!Z)return;Re({...Z,...B});break}F(de=>({...de,[k]:""}))},Cr=async()=>{if(d){mt(!0),Te(null);try{const s=await ee.updateConfig(d);$&&await ee.updateSatiConfig($),z&&await ee.updateNeoConfig(z),j&&await ee.updateApocConfig(j),T&&await ee.updateTrinityConfig(T),f&&await Zr.updateConfig(f),Z&&await tt.post("/link/config",Z),me("/api/config"),me("/api/config/sati"),me("/api/config/neo"),me("/api/config/apoc"),me("/api/config/trinity"),me("/api/config/chronos"),me("/api/link/config"),De({});const k=s._restartRequired||[],E=k.length>0?`Settings saved and applied. Some changes require restart: ${k.join(", ")}`:"Settings saved and applied successfully.";Te({type:"success",message:E}),setTimeout(()=>Te(null),5e3)}catch(s){if(Te({type:"error",message:s.message}),s.details&&Array.isArray(s.details)){const k={};s.details.forEach(E=>{const C=E.path.join(".");k[C]=E.message}),De(k)}}finally{mt(!1)}}};return t?o.jsx("div",{className:"p-8 text-red-500",children:"Failed to load configuration"}):d?o.jsxs("div",{className:"max-w-4xl mx-auto p-0 md:p-6 space-y-6",children:[o.jsxs("div",{className:"flex justify-between items-center flex-wrap gap-3",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:o.jsx(Ir,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Zaion Settings"}),o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Configure agents, models, channels, and runtime behavior."})]})]}),o.jsx("button",{onClick:Cr,disabled:!pt||Object.keys(H).length>0||dt,className:`px-4 py-2 rounded font-medium transition-colors ${pt&&Object.keys(H).length===0?"bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90":"bg-azure-border text-azure-text-secondary cursor-not-allowed dark:bg-matrix-primary/50 dark:text-matrix-highlight/50"}`,children:dt?"Saving...":"Save Changes"})]}),He&&o.jsxs("div",{className:`flex items-start justify-between gap-3 p-4 rounded border ${He.type==="success"?"border-azure-primary text-azure-primary bg-azure-primary/10 dark:border-matrix-highlight dark:text-matrix-highlight dark:bg-matrix-highlight/10":"border-red-500 text-red-500 bg-red-900/10"}`,children:[o.jsx("span",{className:"text-sm",children:He.message}),o.jsx("button",{type:"button",onClick:()=>Te(null),className:"shrink-0 opacity-60 hover:opacity-100 transition-opacity","aria-label":"Dismiss",children:o.jsx(Pr,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"overflow-x-auto py-1 hide-scrollbar",children:o.jsx("div",{className:"flex space-x-1 border-b border-azure-border dark:border-matrix-primary pb-px min-w-max",children:Ls.map(s=>o.jsxs("button",{onClick:()=>xr(s.id),className:`px-4 py-2 text-sm font-medium rounded-t-md transition-colors flex-shrink-0 flex items-center gap-1.5 ${re===s.id?"bg-azure-surface/50 text-azure-primary border-t border-x border-azure-border dark:bg-matrix-primary/20 dark:text-matrix-highlight dark:border-t dark:border-x dark:border-matrix-primary":"text-azure-text-secondary hover:text-azure-primary dark:text-matrix-secondary dark:hover:text-matrix-highlight"}`,children:[s.label,yr[s.id]&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"})]},s.id))})}),o.jsxs("div",{className:"space-y-6",children:[re==="general"&&o.jsxs(W,{title:"Agent Identity",children:[o.jsx(w,{label:"Agent Name",value:d.agent.name,onChange:s=>y(["agent","name"],s.target.value),error:H["agent.name"]}),o.jsx(Xe,{label:"Personality",value:d.agent.personality,onChange:s=>y(["agent","personality"],s.target.value),error:H["agent.personality"],placeholder:"Describe the agent's personality or description..."}),o.jsx(V,{label:"Verbose Mode",value:d.verbose_mode!==!1?"true":"false",onChange:s=>y(["verbose_mode"],s.target.value==="true"),options:[{value:"true",label:"Enabled (notify tool execution on channels)"},{value:"false",label:"Disabled"}],helperText:"When enabled, channels like Telegram/Discord show which tools are being executed in real-time."})]}),re==="agents"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"flex space-x-1 border-b border-azure-border dark:border-matrix-primary pb-px",children:Fs.map(s=>o.jsx("button",{onClick:()=>vr(s.id),className:`px-4 py-2 text-sm font-medium rounded-t-md transition-colors ${be===s.id?"bg-azure-primary/10 text-azure-primary border-b-2 border-azure-primary dark:bg-matrix-highlight/10 dark:text-matrix-highlight dark:border-matrix-highlight":"text-azure-text-secondary hover:text-azure-primary dark:text-matrix-secondary dark:hover:text-matrix-highlight"}`,children:s.label},s.id))}),be==="oracle"&&o.jsxs(W,{title:"Oracle Agent",children:[m.length>0&&o.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[o.jsxs("select",{value:x.oracle??"",onChange:s=>ke(s.target.value,"oracle"),className:"flex-1 px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight",children:[o.jsx("option",{value:"",disabled:!0,children:"Apply a preset..."}),m.map(s=>o.jsxs("option",{value:s.id,children:[s.name," (",s.provider," / ",s.model,")"]},s.id))]}),o.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary shrink-0",children:"Auto-fills fields below."})]}),o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Main orchestration agent — handles user requests and delegates to subagents"}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("llm.provider")]}),o.jsx(V,{label:"",value:d.llm.provider,onChange:s=>y(["llm","provider"],s.target.value),options:Ze,error:H["llm.provider"],disabled:_("llm.provider")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("llm.model")]}),o.jsx(w,{label:"",value:d.llm.model,onChange:s=>y(["llm","model"],s.target.value),disabled:_("llm.model")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),S("llm.temperature")]}),o.jsx(O,{label:"",value:d.llm.temperature,onChange:s=>y(["llm","temperature"],parseFloat(s.target.value)),step:.1,min:0,max:1,error:H["llm.temperature"],disabled:_("llm.temperature")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),S("llm.max_tokens")]}),o.jsx(O,{label:"",value:d.llm.max_tokens??"",onChange:s=>y(["llm","max_tokens"],s.target.value?parseInt(s.target.value):void 0),min:1,error:H["llm.max_tokens"],helperText:"Maximum tokens per response. Leave empty for model default.",disabled:_("llm.max_tokens")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Context Window (Messages)"}),S("llm.context_window")]}),o.jsx(O,{label:"",value:d.llm.context_window??100,onChange:s=>y(["llm","context_window"],parseInt(s.target.value)),min:1,step:1,error:H["llm.context_window"],helperText:"Number of past interactions to load into LLM context (e.g., 100).",disabled:_("llm.context_window")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),o.jsxs("div",{className:"flex items-center gap-2",children:[S("llm.api_key"),_e("oracle",d.llm.api_key)]})]}),o.jsx(w,{label:"",type:"password",value:d.llm.api_key||"",onChange:s=>y(["llm","api_key"],s.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("llm.api_key")}),d.llm.provider==="openrouter"&&o.jsx(w,{label:"Base URL",value:d.llm.base_url||"https://openrouter.ai/api/v1",onChange:s=>y(["llm","base_url"],s.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]}),be==="sati"&&o.jsxs(W,{title:"Sati Agent",children:[m.length>0&&o.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[o.jsxs("select",{value:x.sati??"",onChange:s=>ke(s.target.value,"sati"),className:"flex-1 px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight",children:[o.jsx("option",{value:"",disabled:!0,children:"Apply a preset..."}),m.map(s=>o.jsxs("option",{value:s.id,children:[s.name," (",s.provider," / ",s.model,")"]},s.id))]}),o.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary shrink-0",children:"Auto-fills fields below."})]}),o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Background memory consolidation agent — evaluates conversations and persists important context"}),o.jsxs("div",{className:"mb-4",children:[o.jsx("button",{type:"button",onClick:zr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),o.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),$&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("sati.provider")]}),o.jsx(V,{label:"",value:$.provider,onChange:s=>le("provider",s.target.value),options:Ze,disabled:_("sati.provider")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("sati.model")]}),o.jsx(w,{label:"",value:$.model,onChange:s=>le("model",s.target.value),disabled:_("sati.model")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),o.jsxs("div",{className:"flex items-center gap-2",children:[S("sati.api_key"),_e("sati",$.api_key)]})]}),o.jsx(w,{label:"",type:"password",value:$.api_key||"",onChange:s=>le("api_key",s.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("sati.api_key")}),$.provider==="openrouter"&&o.jsx(w,{label:"Base URL",value:$.base_url||"https://openrouter.ai/api/v1",onChange:s=>le("base_url",s.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"}),o.jsx(O,{label:"Memory Limit",value:$.memory_limit??10,onChange:s=>le("memory_limit",parseInt(s.target.value)),min:1,step:1,helperText:"Number of memory items to retrieve from long-term storage."}),o.jsx(O,{label:"Evaluation Interval",value:$.evaluation_interval??1,onChange:s=>le("evaluation_interval",parseInt(s.target.value)),min:1,step:1,helperText:"Oracle turns between memory evaluations. Default: 1 (every turn). *If Evaluation interval is more than context window, this value will be ignored."}),o.jsx(Q,{label:"Enable Archived Sessions in Memory Retrieval",checked:$.enabled_archived_sessions??!0,onChange:s=>le("enabled_archived_sessions",s)}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-1",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Similarity Threshold"}),o.jsx("span",{className:"text-sm font-mono text-azure-text-primary dark:text-matrix-highlight",children:($.similarity_threshold??.9).toFixed(2)})]}),o.jsx("input",{type:"range",min:0,max:1,step:.01,value:$.similarity_threshold??.9,onChange:s=>le("similarity_threshold",parseFloat(s.target.value)),className:`w-full h-1.5 rounded-full appearance-none cursor-pointer
39
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const c=i[1];if(t===i[0]){l(i);continue}if(e.external){const m=e.external.registry.get(i[0])?.id;if(t!==i[0]&&m){l(i);continue}}if(e.metadataRegistry.get(i[0])?.id){l(i);continue}if(c.cycle){l(i);continue}if(c.count>1&&e.reused==="ref"){l(i);continue}}}function ur(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=i=>{const c=e.seen.get(i);if(c.ref===null)return;const u=c.def??c.schema,m={...u},h=c.ref;if(c.ref=null,h){n(h);const g=e.seen.get(h),x=g.schema;if(x.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(x)):Object.assign(u,x),Object.assign(u,m),i._zod.parent===h)for(const d in u)d==="$ref"||d==="allOf"||d in m||delete u[d];if(x.$ref&&g.def)for(const d in u)d==="$ref"||d==="allOf"||d in g.def&&JSON.stringify(u[d])===JSON.stringify(g.def[d])&&delete u[d]}const f=i._zod.parent;if(f&&f!==h){n(f);const g=e.seen.get(f);if(g?.schema.$ref&&(u.$ref=g.schema.$ref,g.def))for(const x in u)x==="$ref"||x==="allOf"||x in g.def&&JSON.stringify(u[x])===JSON.stringify(g.def[x])&&delete u[x]}e.override({zodSchema:i,jsonSchema:u,path:c.path??[]})};for(const i of[...e.seen.entries()].reverse())n(i[0]);const a={};if(e.target==="draft-2020-12"?a.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?a.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?a.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(i)}Object.assign(a,r.def??r.schema);const l=e.external?.defs??{};for(const i of e.seen.entries()){const c=i[1];c.def&&c.defId&&(l[c.defId]=c.def)}e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?a.$defs=l:a.definitions=l);try{const i=JSON.parse(JSON.stringify(a));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ke(t,"input",e.processors),output:Ke(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function q(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return q(n.element,r);if(n.type==="set")return q(n.valueType,r);if(n.type==="lazy")return q(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return q(n.innerType,r);if(n.type==="intersection")return q(n.left,r)||q(n.right,r);if(n.type==="record"||n.type==="map")return q(n.keyType,r)||q(n.valueType,r);if(n.type==="pipe")return q(n.in,r)||q(n.out,r);if(n.type==="object"){for(const a in n.shape)if(q(n.shape[a],r))return!0;return!1}if(n.type==="union"){for(const a of n.options)if(q(a,r))return!0;return!1}if(n.type==="tuple"){for(const a of n.items)if(q(a,r))return!0;return!!(n.rest&&q(n.rest,r))}return!1}const Ro=(e,t={})=>r=>{const n=lr({...r,processors:t});return K(e,n),cr(n,e),ur(n,e)},Ke=(e,t,r={})=>n=>{const{libraryOptions:a,target:l}=n??{},i=lr({...a??{},target:l,io:t,processors:r});return K(e,i),cr(i,e),ur(i,e)},Do={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Mo=(e,t,r,n)=>{const a=r;a.type="string";const{minimum:l,maximum:i,format:c,patterns:u,contentEncoding:m}=e._zod.bag;if(typeof l=="number"&&(a.minLength=l),typeof i=="number"&&(a.maxLength=i),c&&(a.format=Do[c]??c,a.format===""&&delete a.format,c==="time"&&delete a.format),m&&(a.contentEncoding=m),u&&u.size>0){const h=[...u];h.length===1?a.pattern=h[0].source:h.length>1&&(a.allOf=[...h.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Uo=(e,t,r,n)=>{const a=r,{minimum:l,maximum:i,format:c,multipleOf:u,exclusiveMaximum:m,exclusiveMinimum:h}=e._zod.bag;typeof c=="string"&&c.includes("int")?a.type="integer":a.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(a.minimum=h,a.exclusiveMinimum=!0):a.exclusiveMinimum=h),typeof l=="number"&&(a.minimum=l,typeof h=="number"&&t.target!=="draft-04"&&(h>=l?delete a.minimum:delete a.exclusiveMinimum)),typeof m=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(a.maximum=m,a.exclusiveMaximum=!0):a.exclusiveMaximum=m),typeof i=="number"&&(a.maximum=i,typeof m=="number"&&t.target!=="draft-04"&&(m<=i?delete a.maximum:delete a.exclusiveMaximum)),typeof u=="number"&&(a.multipleOf=u)},Lo=(e,t,r,n)=>{r.type="boolean"},Fo=(e,t,r,n)=>{r.not={}},Jo=(e,t,r,n)=>{},Bo=(e,t,r,n)=>{const a=e._zod.def,l=Lt(a.entries);l.every(i=>typeof i=="number")&&(r.type="number"),l.every(i=>typeof i=="string")&&(r.type="string"),r.enum=l},Ko=(e,t,r,n)=>{const a=e._zod.def,l=[];for(const i of a.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");l.push(Number(i))}else l.push(i);if(l.length!==0)if(l.length===1){const i=l[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else l.every(i=>typeof i=="number")&&(r.type="number"),l.every(i=>typeof i=="string")&&(r.type="string"),l.every(i=>typeof i=="boolean")&&(r.type="boolean"),l.every(i=>i===null)&&(r.type="null"),r.enum=l},Vo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Wo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Go=(e,t,r,n)=>{const a=r,l=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;typeof i=="number"&&(a.minItems=i),typeof c=="number"&&(a.maxItems=c),a.type="array",a.items=K(l.element,t,{...n,path:[...n.path,"items"]})},qo=(e,t,r,n)=>{const a=r,l=e._zod.def;a.type="object",a.properties={};const i=l.shape;for(const m in i)a.properties[m]=K(i[m],t,{...n,path:[...n.path,"properties",m]});const c=new Set(Object.keys(i)),u=new Set([...c].filter(m=>{const h=l.shape[m]._zod;return t.io==="input"?h.optin===void 0:h.optout===void 0}));u.size>0&&(a.required=Array.from(u)),l.catchall?._zod.def.type==="never"?a.additionalProperties=!1:l.catchall?l.catchall&&(a.additionalProperties=K(l.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},Ho=(e,t,r,n)=>{const a=e._zod.def,l=a.inclusive===!1,i=a.options.map((c,u)=>K(c,t,{...n,path:[...n.path,l?"oneOf":"anyOf",u]}));l?r.oneOf=i:r.anyOf=i},Yo=(e,t,r,n)=>{const a=e._zod.def,l=K(a.left,t,{...n,path:[...n.path,"allOf",0]}),i=K(a.right,t,{...n,path:[...n.path,"allOf",1]}),c=m=>"allOf"in m&&Object.keys(m).length===1,u=[...c(l)?l.allOf:[l],...c(i)?i.allOf:[i]];r.allOf=u},Xo=(e,t,r,n)=>{const a=r,l=e._zod.def;a.type="object";const i=l.keyType,u=i._zod.bag?.patterns;if(l.mode==="loose"&&u&&u.size>0){const h=K(l.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});a.patternProperties={};for(const f of u)a.patternProperties[f.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(a.propertyNames=K(l.keyType,t,{...n,path:[...n.path,"propertyNames"]})),a.additionalProperties=K(l.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const m=i._zod.values;if(m){const h=[...m].filter(f=>typeof f=="string"||typeof f=="number");h.length>0&&(a.required=h)}},Qo=(e,t,r,n)=>{const a=e._zod.def,l=K(a.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=a.innerType,r.nullable=!0):r.anyOf=[l,{type:"null"}]},ei=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType},ti=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType,r.default=JSON.parse(JSON.stringify(a.defaultValue))},ri=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},ni=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType;let i;try{i=a.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},ai=(e,t,r,n)=>{const a=e._zod.def,l=t.io==="input"?a.in._zod.def.type==="transform"?a.out:a.in:a.out;K(l,t,n);const i=t.seen.get(e);i.ref=l},oi=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType,r.readOnly=!0},dr=(e,t,r,n)=>{const a=e._zod.def;K(a.innerType,t,n);const l=t.seen.get(e);l.ref=a.innerType},ii=p("ZodISODateTime",(e,t)=>{ia.init(e,t),L.init(e,t)});function si(e){return po(ii,e)}const li=p("ZodISODate",(e,t)=>{sa.init(e,t),L.init(e,t)});function ci(e){return ho(li,e)}const ui=p("ZodISOTime",(e,t)=>{la.init(e,t),L.init(e,t)});function di(e){return fo(ui,e)}const mi=p("ZodISODuration",(e,t)=>{ca.init(e,t),L.init(e,t)});function pi(e){return go(mi,e)}const hi=(e,t)=>{Kt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Xr(e,r)},flatten:{value:r=>Yr(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,rt,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,rt,2)}},isEmpty:{get(){return e.issues.length===0}}})},te=p("ZodError",hi,{Parent:Error}),fi=lt(te),gi=ct(te),bi=We(te),xi=Ge(te),vi=tn(te),yi=rn(te),_i=nn(te),ki=an(te),wi=on(te),zi=sn(te),ji=ln(te),Si=cn(te),U=p("ZodType",(e,t)=>(M.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ke(e,"input"),output:Ke(e,"output")}}),e.toJSONSchema=Ro(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(fe(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>ge(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>fi(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>bi(e,r,n),e.parseAsync=async(r,n)=>gi(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>xi(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>vi(e,r,n),e.decode=(r,n)=>yi(e,r,n),e.encodeAsync=async(r,n)=>_i(e,r,n),e.decodeAsync=async(r,n)=>ki(e,r,n),e.safeEncode=(r,n)=>wi(e,r,n),e.safeDecode=(r,n)=>zi(e,r,n),e.safeEncodeAsync=async(r,n)=>ji(e,r,n),e.safeDecodeAsync=async(r,n)=>Si(e,r,n),e.refine=(r,n)=>e.check(ys(r,n)),e.superRefine=r=>e.check(_s(r)),e.overwrite=r=>e.check(Oe(r)),e.optional=()=>Pt(e),e.exactOptional=()=>ss(e),e.nullable=()=>Rt(e),e.nullish=()=>Pt(Rt(e)),e.nonoptional=r=>ps(e,r),e.array=()=>ae(e),e.or=r=>fr([e,r]),e.and=r=>ts(e,r),e.transform=r=>Dt(e,os(r)),e.default=r=>us(e,r),e.prefault=r=>ms(e,r),e.catch=r=>fs(e,r),e.pipe=r=>Dt(e,r),e.readonly=()=>xs(e),e.describe=r=>{const n=e.clone();return Ee.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Ee.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Ee.get(e);const n=e.clone();return Ee.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),mr=p("_ZodString",(e,t)=>{ut.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,l)=>Mo(e,n,a);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(ko(...n)),e.includes=(...n)=>e.check(jo(...n)),e.startsWith=(...n)=>e.check(So(...n)),e.endsWith=(...n)=>e.check(No(...n)),e.min=(...n)=>e.check(Be(...n)),e.max=(...n)=>e.check(ir(...n)),e.length=(...n)=>e.check(sr(...n)),e.nonempty=(...n)=>e.check(Be(1,...n)),e.lowercase=n=>e.check(wo(n)),e.uppercase=n=>e.check(zo(n)),e.trim=()=>e.check(Oo()),e.normalize=(...n)=>e.check(Co(...n)),e.toLowerCase=()=>e.check(Ao()),e.toUpperCase=()=>e.check($o()),e.slugify=()=>e.check(To())}),Ni=p("ZodString",(e,t)=>{ut.init(e,t),mr.init(e,t),e.email=r=>e.check(Ka(Ci,r)),e.url=r=>e.check(Ha(Oi,r)),e.jwt=r=>e.check(mo(Bi,r)),e.emoji=r=>e.check(Ya(Ai,r)),e.guid=r=>e.check(Ct(Tt,r)),e.uuid=r=>e.check(Va(Le,r)),e.uuidv4=r=>e.check(Wa(Le,r)),e.uuidv6=r=>e.check(Ga(Le,r)),e.uuidv7=r=>e.check(qa(Le,r)),e.nanoid=r=>e.check(Xa($i,r)),e.guid=r=>e.check(Ct(Tt,r)),e.cuid=r=>e.check(Qa(Ti,r)),e.cuid2=r=>e.check(eo(Zi,r)),e.ulid=r=>e.check(to(Ei,r)),e.base64=r=>e.check(lo(Li,r)),e.base64url=r=>e.check(co(Fi,r)),e.xid=r=>e.check(ro(Ii,r)),e.ksuid=r=>e.check(no(Pi,r)),e.ipv4=r=>e.check(ao(Ri,r)),e.ipv6=r=>e.check(oo(Di,r)),e.cidrv4=r=>e.check(io(Mi,r)),e.cidrv6=r=>e.check(so(Ui,r)),e.e164=r=>e.check(uo(Ji,r)),e.datetime=r=>e.check(si(r)),e.date=r=>e.check(ci(r)),e.time=r=>e.check(di(r)),e.duration=r=>e.check(pi(r))});function v(e){return Ba(Ni,e)}const L=p("ZodStringFormat",(e,t)=>{D.init(e,t),mr.init(e,t)}),Ci=p("ZodEmail",(e,t)=>{Yn.init(e,t),L.init(e,t)}),Tt=p("ZodGUID",(e,t)=>{qn.init(e,t),L.init(e,t)}),Le=p("ZodUUID",(e,t)=>{Hn.init(e,t),L.init(e,t)}),Oi=p("ZodURL",(e,t)=>{Xn.init(e,t),L.init(e,t)}),Ai=p("ZodEmoji",(e,t)=>{Qn.init(e,t),L.init(e,t)}),$i=p("ZodNanoID",(e,t)=>{ea.init(e,t),L.init(e,t)}),Ti=p("ZodCUID",(e,t)=>{ta.init(e,t),L.init(e,t)}),Zi=p("ZodCUID2",(e,t)=>{ra.init(e,t),L.init(e,t)}),Ei=p("ZodULID",(e,t)=>{na.init(e,t),L.init(e,t)}),Ii=p("ZodXID",(e,t)=>{aa.init(e,t),L.init(e,t)}),Pi=p("ZodKSUID",(e,t)=>{oa.init(e,t),L.init(e,t)}),Ri=p("ZodIPv4",(e,t)=>{ua.init(e,t),L.init(e,t)}),Di=p("ZodIPv6",(e,t)=>{da.init(e,t),L.init(e,t)}),Mi=p("ZodCIDRv4",(e,t)=>{ma.init(e,t),L.init(e,t)}),Ui=p("ZodCIDRv6",(e,t)=>{pa.init(e,t),L.init(e,t)}),Li=p("ZodBase64",(e,t)=>{ha.init(e,t),L.init(e,t)}),Fi=p("ZodBase64URL",(e,t)=>{ga.init(e,t),L.init(e,t)}),Ji=p("ZodE164",(e,t)=>{ba.init(e,t),L.init(e,t)}),Bi=p("ZodJWT",(e,t)=>{va.init(e,t),L.init(e,t)}),pr=p("ZodNumber",(e,t)=>{tr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,l)=>Uo(e,n,a),e.gt=(n,a)=>e.check(At(n,a)),e.gte=(n,a)=>e.check(et(n,a)),e.min=(n,a)=>e.check(et(n,a)),e.lt=(n,a)=>e.check(Ot(n,a)),e.lte=(n,a)=>e.check(Qe(n,a)),e.max=(n,a)=>e.check(Qe(n,a)),e.int=n=>e.check(Zt(n)),e.safe=n=>e.check(Zt(n)),e.positive=n=>e.check(At(0,n)),e.nonnegative=n=>e.check(et(0,n)),e.negative=n=>e.check(Ot(0,n)),e.nonpositive=n=>e.check(Qe(0,n)),e.multipleOf=(n,a)=>e.check($t(n,a)),e.step=(n,a)=>e.check($t(n,a)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function I(e){return bo(pr,e)}const Ki=p("ZodNumberFormat",(e,t)=>{ya.init(e,t),pr.init(e,t)});function Zt(e){return xo(Ki,e)}const Vi=p("ZodBoolean",(e,t)=>{_a.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Lo(e,r,n)});function G(e){return vo(Vi,e)}const Wi=p("ZodUnknown",(e,t)=>{ka.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Jo()});function Et(){return yo(Wi)}const Gi=p("ZodNever",(e,t)=>{wa.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Fo(e,r,n)});function qi(e){return _o(Gi,e)}const Hi=p("ZodArray",(e,t)=>{za.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Go(e,r,n,a),e.element=t.element,e.min=(r,n)=>e.check(Be(r,n)),e.nonempty=r=>e.check(Be(1,r)),e.max=(r,n)=>e.check(ir(r,n)),e.length=(r,n)=>e.check(sr(r,n)),e.unwrap=()=>e.element});function ae(e,t){return Zo(Hi,e,t)}const Yi=p("ZodObject",(e,t)=>{Sa.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>qo(e,r,n,a),N(e,"shape",()=>t.shape),e.keyof=()=>ne(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Et()}),e.loose=()=>e.clone({...e._zod.def,catchall:Et()}),e.strict=()=>e.clone({...e._zod.def,catchall:qi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Vr(e,r),e.safeExtend=r=>Wr(e,r),e.merge=r=>Gr(e,r),e.pick=r=>Br(e,r),e.omit=r=>Kr(e,r),e.partial=(...r)=>qr(gr,e,r[0]),e.required=(...r)=>Hr(br,e,r[0])});function R(e,t){const r={type:"object",shape:e??{},...b(t)};return new Yi(r)}const hr=p("ZodUnion",(e,t)=>{ar.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Ho(e,r,n,a),e.options=t.options});function fr(e,t){return new hr({type:"union",options:e,...b(t)})}const Xi=p("ZodDiscriminatedUnion",(e,t)=>{hr.init(e,t),Na.init(e,t)});function Qi(e,t,r){return new Xi({type:"union",options:t,discriminator:e,...b(r)})}const es=p("ZodIntersection",(e,t)=>{Ca.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Yo(e,r,n,a)});function ts(e,t){return new es({type:"intersection",left:e,right:t})}const rs=p("ZodRecord",(e,t)=>{Oa.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Xo(e,r,n,a),e.keyType=t.keyType,e.valueType=t.valueType});function Fe(e,t,r){return new rs({type:"record",keyType:e,valueType:t,...b(r)})}const at=p("ZodEnum",(e,t)=>{Aa.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,l)=>Bo(e,n,a),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,a)=>{const l={};for(const i of n)if(r.has(i))l[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new at({...t,checks:[],...b(a),entries:l})},e.exclude=(n,a)=>{const l={...t.entries};for(const i of n)if(r.has(i))delete l[i];else throw new Error(`Key ${i} not found in enum`);return new at({...t,checks:[],...b(a),entries:l})}});function ne(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new at({type:"enum",entries:r,...b(t)})}const ns=p("ZodLiteral",(e,t)=>{$a.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Ko(e,r,n),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 It(e,t){return new ns({type:"literal",values:Array.isArray(e)?e:[e],...b(t)})}const as=p("ZodTransform",(e,t)=>{Ta.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Wo(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Mt(e.constructor.name);r.addIssue=l=>{if(typeof l=="string")r.issues.push(Pe(l,r.value,t));else{const i=l;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(Pe(i))}};const a=t.transform(r.value,r);return a instanceof Promise?a.then(l=>(r.value=l,r)):(r.value=a,r)}});function os(e){return new as({type:"transform",transform:e})}const gr=p("ZodOptional",(e,t)=>{or.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>dr(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Pt(e){return new gr({type:"optional",innerType:e})}const is=p("ZodExactOptional",(e,t)=>{Za.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>dr(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function ss(e){return new is({type:"optional",innerType:e})}const ls=p("ZodNullable",(e,t)=>{Ea.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Qo(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Rt(e){return new ls({type:"nullable",innerType:e})}const cs=p("ZodDefault",(e,t)=>{Ia.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ti(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function us(e,t){return new cs({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Jt(t)}})}const ds=p("ZodPrefault",(e,t)=>{Pa.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ri(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function ms(e,t){return new ds({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Jt(t)}})}const br=p("ZodNonOptional",(e,t)=>{Ra.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ei(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function ps(e,t){return new br({type:"nonoptional",innerType:e,...b(t)})}const hs=p("ZodCatch",(e,t)=>{Da.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ni(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fs(e,t){return new hs({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const gs=p("ZodPipe",(e,t)=>{Ma.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ai(e,r,n,a),e.in=t.in,e.out=t.out});function Dt(e,t){return new gs({type:"pipe",in:e,out:t})}const bs=p("ZodReadonly",(e,t)=>{Ua.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>oi(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function xs(e){return new bs({type:"readonly",innerType:e})}const vs=p("ZodCustom",(e,t)=>{La.init(e,t),U.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Vo(e,r)});function ys(e,t={}){return Eo(vs,e,t)}function _s(e){return Io(e)}const A={agent:{name:"morpheus",personality:"helpful_dev"},logging:{enabled:!0,level:"info",retention:"14d"},audio:{provider:"gemini",model:"gemini-2.5-flash-lite",enabled:!0,maxDurationSeconds:300,supportedMimeTypes:["audio/ogg","audio/mp3","audio/mpeg","audio/wav"],tts:{enabled:!1,provider:"gemini",model:"gemini-2.5-flash-preview-tts",voice:"Kore"}},memory:{limit:100},runtime:{async_tasks:{enabled:!0}},llm:{provider:"openai",model:"gpt-4",temperature:.7,context_window:100},channels:{telegram:{enabled:!1,allowedUsers:[]},discord:{enabled:!1,allowedUsers:[]}},ui:{enabled:!0,port:3333}},ks=R({enabled:G().default(!1),provider:ne(["openai","gemini"]).default("gemini"),model:v().min(1).default("gemini-2.5-flash-preview-tts"),voice:v().min(1).default("Kore"),apiKey:v().optional(),style_prompt:v().optional()}),ws=R({provider:ne(["gemini","openai","openrouter","ollama"]).default(A.audio.provider),model:v().min(1).default(A.audio.model),enabled:G().default(A.audio.enabled),apiKey:v().optional(),base_url:v().optional(),maxDurationSeconds:I().default(A.audio.maxDurationSeconds),supportedMimeTypes:ae(v()).default(A.audio.supportedMimeTypes),tts:ks.optional()}),Ae=R({provider:ne(["openai","anthropic","openrouter","ollama","gemini"]).default(A.llm.provider),model:v().min(1).default(A.llm.model),temperature:I().min(0).max(1).default(A.llm.temperature),max_tokens:I().int().positive().optional(),api_key:v().optional(),base_url:v().optional(),context_window:I().int().positive().optional()}),zs=Ae.extend({memory_limit:I().int().positive().optional(),enabled_archived_sessions:G().default(!0),similarity_threshold:I().min(0).max(1).default(.9),evaluation_interval:I().int().min(1).default(1)}),js=Ae.extend({working_dir:v().optional(),timeout_ms:I().int().positive().optional(),execution_mode:ne(["sync","async"]).default("async")}),Ss=Ae.extend({execution_mode:ne(["sync","async"]).default("async")}),Ns=Ae.extend({execution_mode:ne(["sync","async"]).default("async")}),Cs=Ae.extend({personality:v().optional(),chunk_size:I().int().positive().default(500),score_threshold:I().min(0).max(1).default(.5),max_results:I().int().positive().default(10),execution_mode:ne(["sync","async"]).default("async"),scan_interval_ms:I().int().min(5e3).default(3e4),max_file_size_mb:I().int().positive().default(50),vector_weight:I().min(0).max(1).default(.8),bm25_weight:I().min(0).max(1).default(.2)}),Os=R({telegram_notify_all:G().optional()}).optional(),As=R({timezone:v().default("UTC"),check_interval_ms:I().min(6e4).default(6e4),max_active_jobs:I().min(1).max(1e3).default(100)}),$s=R({sandbox_dir:v().optional(),readonly_mode:G().default(!1),allowed_shell_commands:ae(v()).default([]),allowed_paths:ae(v()).default([]),enable_filesystem:G().default(!0),enable_shell:G().default(!0),enable_git:G().default(!0),enable_network:G().default(!0),timeout_ms:I().int().positive().default(3e4)}),Ts=R({name:v().min(1).max(64).regex(/^[a-z0-9][a-z0-9_-]*$/,"Smith name must be lowercase alphanumeric with hyphens/underscores"),host:v().min(1),port:I().int().min(1).max(65535).default(7900),auth_token:v().min(1),tls:G().default(!1)}),Zs=R({enabled:G().default(!0),fields:ae(v()).default(["name","timezone","preferred_language"])}),Es=R({enabled:G().default(!1),execution_mode:ne(["sync","async"]).default("async"),heartbeat_interval_ms:I().int().min(5e3).default(3e4),connection_timeout_ms:I().int().min(1e3).default(1e4),task_timeout_ms:I().int().min(1e3).default(6e4),entries:ae(Ts).default([])}),Is=R({code:v().min(1).default("USD"),symbol:v().min(1).default("$"),rate:I().positive().default(1)}),Ps=R({service_account_json:v().optional(),service_account_json_content:v().optional(),enabled:G().default(!0)}),Rs=R({agent:R({name:v().default(A.agent.name),personality:v().default(A.agent.personality)}).default(A.agent),llm:Ae.default(A.llm),sati:zs.optional(),neo:Ss.optional(),apoc:js.optional(),trinity:Ns.optional(),link:Cs.optional(),webhooks:Os,audio:ws.default(A.audio),memory:R({limit:I().int().positive().optional()}).default(A.memory),runtime:R({async_tasks:R({enabled:G().default(A.runtime?.async_tasks.enabled)}).default(A.runtime?.async_tasks??{enabled:!0})}).optional(),chronos:As.optional(),devkit:$s.optional(),smiths:Es.optional(),gws:Ps.optional(),setup:Zs.optional(),currency:Is.optional(),verbose_mode:G().default(!0),channels:R({telegram:R({enabled:G().default(!1),token:v().optional(),allowedUsers:ae(v()).default([])}).default(A.channels.telegram),discord:R({enabled:G().default(!1),token:v().optional(),allowedUsers:ae(v()).default([])}).default(A.channels.discord)}).default(A.channels),ui:R({enabled:G().default(A.ui.enabled),port:I().default(A.ui.port)}).default(A.ui),logging:R({enabled:G().default(A.logging.enabled),level:ne(["debug","info","warn","error"]).default(A.logging.level),retention:v().default(A.logging.retention)}).default(A.logging)}),Ds=R({grant_type:ne(["client_credentials","authorization_code"]).default("authorization_code"),client_id:v().optional(),client_secret:v().optional(),scope:v().optional()}),Ms=Qi("transport",[R({transport:It("stdio"),command:v().min(1,"Command is required for stdio transport"),args:ae(v()).optional().default([]),env:Fe(v(),v()).optional().default({}),_comment:v().optional()}),R({transport:It("http"),url:v().url("Valid URL is required for http transport"),headers:Fe(v(),v()).optional().default({}),oauth2:Ds.optional(),args:ae(v()).optional().default([]),env:Fe(v(),v()).optional().default({}),_comment:v().optional()})]);Fe(v(),fr([Ms,v()]));const Us={resetData:async e=>tt.delete("/danger/reset",{categories:e})},Ls=[{id:"general",label:"General"},{id:"agents",label:"Agents"},{id:"devkit",label:"DevKit"},{id:"gws",label:"GWS"},{id:"audio",label:"Audio"},{id:"channels",label:"Channels"},{id:"ui",label:"Interface"},{id:"chronos",label:"Chronos"},{id:"danger",label:"Danger Zone"}],Fs=[{id:"oracle",label:"Oracle"},{id:"sati",label:"Sati"},{id:"neo",label:"Neo"},{id:"apoc",label:"Apoc"},{id:"trinity",label:"Trinity"},{id:"link",label:"Link"}],Ze=[{label:"OpenAI",value:"openai"},{label:"Anthropic",value:"anthropic"},{label:"OpenRouter",value:"openrouter"},{label:"Ollama",value:"ollama"},{label:"Google Gemini",value:"gemini"}];function tl(){const{data:e,error:t}=se("/api/config",ee.fetchConfig),{data:r}=se("/api/config/sati",ee.getSatiConfig),{data:n}=se("/api/config/apoc",ee.getApocConfig),{data:a}=se("/api/config/neo",ee.getNeoConfig),{data:l}=se("/api/config/trinity",ee.getTrinityConfig),{data:i}=se("/api/link/config",()=>tt.get("/link/config")),{data:c}=se("/api/config/encryption-status",()=>ee.getEncryptionStatus()),{data:u}=se("/api/config/env-overrides",()=>ee.getEnvOverrides()),{data:m=[]}=se("/api/model-presets",ft.list),{data:h}=Tr(),[f,g]=P.useState(null),[x,F]=P.useState({}),[d,oe]=P.useState(null),[$,ve]=P.useState(null),[z,J]=P.useState(null),[j,ye]=P.useState(null),[T,$e]=P.useState(null),[Z,Re]=P.useState(null),[re,xr]=P.useState("general"),[be,vr]=P.useState("oracle"),[dt,mt]=P.useState(!1),[H,De]=P.useState({}),[He,Te]=P.useState(null);P.useEffect(()=>{e&&!d&&oe(e)},[e]),P.useEffect(()=>{r&&!$&&ve(r)},[r]),P.useEffect(()=>{n&&!j?ye(n):!n&&!j&&d&&ye({...d.apoc??d.llm,temperature:d.apoc?.temperature??.2,timeout_ms:d.apoc?.timeout_ms??3e4})},[n,d]),P.useEffect(()=>{a&&!z?J(a):!a&&!z&&d&&J({...d.neo??d.llm,temperature:d.neo?.temperature??.2})},[a,d]),P.useEffect(()=>{l&&!T?$e(l):!l&&!T&&d&&$e({...d.trinity??d.llm,temperature:d.trinity?.temperature??.2})},[l,d]),P.useEffect(()=>{h&&!f&&g(h)},[h]),P.useEffect(()=>{i&&!Z&&Re(i)},[i]);const pt=JSON.stringify(e)!==JSON.stringify(d)||JSON.stringify(r)!==JSON.stringify($)||JSON.stringify(a)!==JSON.stringify(z)||JSON.stringify(n)!==JSON.stringify(j)||JSON.stringify(l)!==JSON.stringify(T)||JSON.stringify(h)!==JSON.stringify(f)||JSON.stringify(i)!==JSON.stringify(Z),yr={general:JSON.stringify(e?.agent)!==JSON.stringify(d?.agent)||e?.verbose_mode!==d?.verbose_mode,agents:JSON.stringify(e?.llm)!==JSON.stringify(d?.llm)||JSON.stringify(r)!==JSON.stringify($)||JSON.stringify(a)!==JSON.stringify(z)||JSON.stringify(n)!==JSON.stringify(j)||JSON.stringify(l)!==JSON.stringify(T)||JSON.stringify(i)!==JSON.stringify(Z),devkit:JSON.stringify(e?.devkit)!==JSON.stringify(d?.devkit),gws:JSON.stringify(e?.gws)!==JSON.stringify(d?.gws),audio:JSON.stringify(e?.audio)!==JSON.stringify(d?.audio),channels:JSON.stringify(e?.channels?.telegram)!==JSON.stringify(d?.channels?.telegram)||JSON.stringify(e?.channels?.discord)!==JSON.stringify(d?.channels?.discord)||JSON.stringify(e?.webhooks)!==JSON.stringify(d?.webhooks),ui:JSON.stringify(e?.ui)!==JSON.stringify(d?.ui),logging:JSON.stringify(e?.logging)!==JSON.stringify(d?.logging),chronos:JSON.stringify(h)!==JSON.stringify(f)},_e=(s,k)=>{if(!c?.apiKeysEncrypted)return null;const{morpheusSecretSet:E,apiKeysEncrypted:C}=c,B=C[s];return!k?o.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-azure-surface border border-azure-border text-azure-text-secondary dark:bg-matrix-primary/10 dark:border-matrix-primary dark:text-matrix-tertiary",children:"No API key"}):u&&u[_r(s)]?null:E?B?o.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-emerald-100 border border-emerald-300 text-emerald-800 dark:bg-emerald-900/30 dark:border-emerald-700 dark:text-emerald-400",title:"API key encrypted with AES-256-GCM",children:"🔒 Encrypted"}):o.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-amber-100 border border-amber-300 text-amber-800 dark:bg-amber-900/30 dark:border-amber-700 dark:text-amber-400",title:"Re-save this configuration to encrypt the API key",children:"⚠️ Re-save to encrypt"}):o.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-amber-100 border border-amber-300 text-amber-800 dark:bg-amber-900/30 dark:border-amber-700 dark:text-amber-400",title:"Set MORPHEUS_SECRET to enable encryption",children:"⚠️ Plaintext"})},_r=s=>({oracle:"llm.api_key",sati:"sati.api_key",neo:"neo.api_key",apoc:"apoc.api_key",trinity:"trinity.api_key",audio:"audio.apiKey"})[s],S=s=>!u||!u[s]?null:o.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-blue-100 border border-blue-300 text-blue-800 dark:bg-blue-900/30 dark:border-blue-700 dark:text-blue-400",title:"This field is set by an environment variable and cannot be edited",children:"🔒 Env Var"}),_=s=>!!(u&&u[s]),y=(s,k)=>{if(!d)return;const E=JSON.parse(JSON.stringify(d));let C=E;for(let B=0;B<s.length-1;B++)(C[s[B]]===void 0||C[s[B]]===null)&&(C[s[B]]={}),C=C[s[B]];C[s[s.length-1]]=k,oe(E);try{Rs.parse(E),De({})}catch(B){if(B instanceof $r){const de={};B.errors.forEach(ht=>{const Or=ht.path.join(".");de[Or]=ht.message}),De(de)}}},Ye=[{code:"USD",symbol:"$",label:"USD — US Dollar ($)"},{code:"BRL",symbol:"R$",label:"BRL — Brazilian Real (R$)"},{code:"CAD",symbol:"CA$",label:"CAD — Canadian Dollar (CA$)"},{code:"EUR",symbol:"€",label:"EUR — Euro (€)"},{code:"JPY",symbol:"¥",label:"JPY — Japanese Yen (¥)"},{code:"GBP",symbol:"£",label:"GBP — British Pound (£)"},{code:"AUD",symbol:"A$",label:"AUD — Australian Dollar (A$)"},{code:"CHF",symbol:"CHF",label:"CHF — Swiss Franc (CHF)"},{code:"ARS",symbol:"$",label:"ARS — Argentine Peso ($)"},{code:"OTHER",symbol:"",label:"Other…"}],kr=s=>{if(!d)return;const k=Ye.find(B=>B.code===s),E=k&&s!=="OTHER"?{code:k.code,symbol:k.symbol,rate:s==="USD"?1:d.currency?.rate??1}:{code:"",symbol:"",rate:d.currency?.rate??1},C={...d,currency:E};oe(C)},le=(s,k)=>{$&&ve({...$,[s]:k})},ce=(s,k)=>{j&&ye({...j,[s]:k})},ie=(s,k)=>{z&&J({...z,[s]:k})},ue=(s,k)=>{T&&$e({...T,[s]:k})},wr=()=>{!d||!T||$e({...T,provider:d.llm.provider,model:d.llm.model,api_key:d.llm.api_key})},zr=()=>{!d||!$||ve({...$,provider:d.llm.provider,model:d.llm.model,api_key:d.llm.api_key})},jr=()=>{!d||!j||ye({...j,provider:d.llm.provider,model:d.llm.model,api_key:d.llm.api_key})},Sr=()=>{!d||!z||J({...z,provider:d.llm.provider,model:d.llm.model,api_key:d.llm.api_key})},X=(s,k)=>{Z&&Re({...Z,[s]:k})},Nr=()=>{!d||!Z||Re({...Z,provider:d.llm.provider,model:d.llm.model,api_key:d.llm.api_key})},ke=async(s,k)=>{if(!s)return;const E=m.find(de=>de.id===s);if(!E)return;let C;E.has_api_key&&(C=(await ft.decryptApiKey(s)).api_key??void 0);const B={provider:E.provider,model:E.model,api_key:C,base_url:E.base_url??void 0,...E.temperature!=null?{temperature:E.temperature}:{},...E.max_tokens!=null?{max_tokens:E.max_tokens}:{}};switch(k){case"oracle":if(!d)return;oe({...d,llm:{...d.llm,...B}});break;case"sati":if(!$)return;ve({...$,...B});break;case"neo":if(!z)return;J({...z,...B});break;case"apoc":if(!j)return;ye({...j,...B});break;case"trinity":if(!T)return;$e({...T,...B});break;case"link":if(!Z)return;Re({...Z,...B});break}F(de=>({...de,[k]:""}))},Cr=async()=>{if(d){mt(!0),Te(null);try{const s=await ee.updateConfig(d);$&&await ee.updateSatiConfig($),z&&await ee.updateNeoConfig(z),j&&await ee.updateApocConfig(j),T&&await ee.updateTrinityConfig(T),f&&await Zr.updateConfig(f),Z&&await tt.post("/link/config",Z),me("/api/config"),me("/api/config/sati"),me("/api/config/neo"),me("/api/config/apoc"),me("/api/config/trinity"),me("/api/config/chronos"),me("/api/link/config"),De({});const k=s._restartRequired||[],E=k.length>0?`Settings saved and applied. Some changes require restart: ${k.join(", ")}`:"Settings saved and applied successfully.";Te({type:"success",message:E}),setTimeout(()=>Te(null),5e3)}catch(s){if(Te({type:"error",message:s.message}),s.details&&Array.isArray(s.details)){const k={};s.details.forEach(E=>{const C=E.path.join(".");k[C]=E.message}),De(k)}}finally{mt(!1)}}};return t?o.jsx("div",{className:"p-8 text-red-500",children:"Failed to load configuration"}):d?o.jsxs("div",{className:"max-w-4xl mx-auto p-0 md:p-6 space-y-6",children:[o.jsxs("div",{className:"flex justify-between items-center flex-wrap gap-3",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:o.jsx(Ir,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Zaion Settings"}),o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Configure agents, models, channels, and runtime behavior."})]})]}),o.jsx("button",{onClick:Cr,disabled:!pt||Object.keys(H).length>0||dt,className:`px-4 py-2 rounded font-medium transition-colors ${pt&&Object.keys(H).length===0?"bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90":"bg-azure-border text-azure-text-secondary cursor-not-allowed dark:bg-matrix-primary/50 dark:text-matrix-highlight/50"}`,children:dt?"Saving...":"Save Changes"})]}),He&&o.jsxs("div",{className:`flex items-start justify-between gap-3 p-4 rounded border ${He.type==="success"?"border-azure-primary text-azure-primary bg-azure-primary/10 dark:border-matrix-highlight dark:text-matrix-highlight dark:bg-matrix-highlight/10":"border-red-500 text-red-500 bg-red-900/10"}`,children:[o.jsx("span",{className:"text-sm",children:He.message}),o.jsx("button",{type:"button",onClick:()=>Te(null),className:"shrink-0 opacity-60 hover:opacity-100 transition-opacity","aria-label":"Dismiss",children:o.jsx(Pr,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"overflow-x-auto py-1 hide-scrollbar",children:o.jsx("div",{className:"flex space-x-1 border-b border-azure-border dark:border-matrix-primary pb-px min-w-max",children:Ls.map(s=>o.jsxs("button",{onClick:()=>xr(s.id),className:`px-4 py-2 text-sm font-medium rounded-t-md transition-colors flex-shrink-0 flex items-center gap-1.5 ${re===s.id?"bg-azure-surface/50 text-azure-primary border-t border-x border-azure-border dark:bg-matrix-primary/20 dark:text-matrix-highlight dark:border-t dark:border-x dark:border-matrix-primary":"text-azure-text-secondary hover:text-azure-primary dark:text-matrix-secondary dark:hover:text-matrix-highlight"}`,children:[s.label,yr[s.id]&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"})]},s.id))})}),o.jsxs("div",{className:"space-y-6",children:[re==="general"&&o.jsxs(W,{title:"Agent Identity",children:[o.jsx(w,{label:"Agent Name",value:d.agent.name,onChange:s=>y(["agent","name"],s.target.value),error:H["agent.name"]}),o.jsx(Xe,{label:"Personality",value:d.agent.personality,onChange:s=>y(["agent","personality"],s.target.value),error:H["agent.personality"],placeholder:"Describe the agent's personality or description..."}),o.jsx(V,{label:"Verbose Mode",value:d.verbose_mode!==!1?"true":"false",onChange:s=>y(["verbose_mode"],s.target.value==="true"),options:[{value:"true",label:"Enabled (notify tool execution on channels)"},{value:"false",label:"Disabled"}],helperText:"When enabled, channels like Telegram/Discord show which tools are being executed in real-time."})]}),re==="agents"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"flex space-x-1 border-b border-azure-border dark:border-matrix-primary pb-px",children:Fs.map(s=>o.jsx("button",{onClick:()=>vr(s.id),className:`px-4 py-2 text-sm font-medium rounded-t-md transition-colors ${be===s.id?"bg-azure-primary/10 text-azure-primary border-b-2 border-azure-primary dark:bg-matrix-highlight/10 dark:text-matrix-highlight dark:border-matrix-highlight":"text-azure-text-secondary hover:text-azure-primary dark:text-matrix-secondary dark:hover:text-matrix-highlight"}`,children:s.label},s.id))}),be==="oracle"&&o.jsxs(W,{title:"Oracle Agent",children:[m.length>0&&o.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[o.jsxs("select",{value:x.oracle??"",onChange:s=>ke(s.target.value,"oracle"),className:"flex-1 px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight",children:[o.jsx("option",{value:"",disabled:!0,children:"Apply a preset..."}),m.map(s=>o.jsxs("option",{value:s.id,children:[s.name," (",s.provider," / ",s.model,")"]},s.id))]}),o.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary shrink-0",children:"Auto-fills fields below."})]}),o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Main orchestration agent — handles user requests and delegates to subagents"}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("llm.provider")]}),o.jsx(V,{label:"",value:d.llm.provider,onChange:s=>y(["llm","provider"],s.target.value),options:Ze,error:H["llm.provider"],disabled:_("llm.provider")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("llm.model")]}),o.jsx(w,{label:"",value:d.llm.model,onChange:s=>y(["llm","model"],s.target.value),disabled:_("llm.model")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),S("llm.temperature")]}),o.jsx(O,{label:"",value:d.llm.temperature,onChange:s=>y(["llm","temperature"],parseFloat(s.target.value)),step:.1,min:0,max:1,error:H["llm.temperature"],disabled:_("llm.temperature")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),S("llm.max_tokens")]}),o.jsx(O,{label:"",value:d.llm.max_tokens??"",onChange:s=>y(["llm","max_tokens"],s.target.value?parseInt(s.target.value):void 0),min:1,error:H["llm.max_tokens"],helperText:"Maximum tokens per response. Leave empty for model default.",disabled:_("llm.max_tokens")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Context Window (Messages)"}),S("llm.context_window")]}),o.jsx(O,{label:"",value:d.llm.context_window??100,onChange:s=>y(["llm","context_window"],parseInt(s.target.value)),min:1,step:1,error:H["llm.context_window"],helperText:"Number of past interactions to load into LLM context (e.g., 100).",disabled:_("llm.context_window")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),o.jsxs("div",{className:"flex items-center gap-2",children:[S("llm.api_key"),_e("oracle",d.llm.api_key)]})]}),o.jsx(w,{label:"",type:"password",value:d.llm.api_key||"",onChange:s=>y(["llm","api_key"],s.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("llm.api_key")}),d.llm.provider==="openrouter"&&o.jsx(w,{label:"Base URL",value:d.llm.base_url||"https://openrouter.ai/api/v1",onChange:s=>y(["llm","base_url"],s.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]}),be==="sati"&&o.jsxs(W,{title:"Sati Agent",children:[m.length>0&&o.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[o.jsxs("select",{value:x.sati??"",onChange:s=>ke(s.target.value,"sati"),className:"flex-1 px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight",children:[o.jsx("option",{value:"",disabled:!0,children:"Apply a preset..."}),m.map(s=>o.jsxs("option",{value:s.id,children:[s.name," (",s.provider," / ",s.model,")"]},s.id))]}),o.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary shrink-0",children:"Auto-fills fields below."})]}),o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Background memory consolidation agent — evaluates conversations and persists important context"}),o.jsxs("div",{className:"mb-4",children:[o.jsx("button",{type:"button",onClick:zr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),o.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),$&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("sati.provider")]}),o.jsx(V,{label:"",value:$.provider,onChange:s=>le("provider",s.target.value),options:Ze,disabled:_("sati.provider")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("sati.model")]}),o.jsx(w,{label:"",value:$.model,onChange:s=>le("model",s.target.value),disabled:_("sati.model")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),o.jsxs("div",{className:"flex items-center gap-2",children:[S("sati.api_key"),_e("sati",$.api_key)]})]}),o.jsx(w,{label:"",type:"password",value:$.api_key||"",onChange:s=>le("api_key",s.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("sati.api_key")}),$.provider==="openrouter"&&o.jsx(w,{label:"Base URL",value:$.base_url||"https://openrouter.ai/api/v1",onChange:s=>le("base_url",s.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"}),o.jsx(O,{label:"Memory Limit",value:$.memory_limit??10,onChange:s=>le("memory_limit",parseInt(s.target.value)),min:1,step:1,helperText:"Number of memory items to retrieve from long-term storage."}),o.jsx(O,{label:"Evaluation Interval",value:$.evaluation_interval??1,onChange:s=>le("evaluation_interval",parseInt(s.target.value)),min:1,step:1,helperText:"Oracle turns between memory evaluations. Default: 1 (every turn). *If Evaluation interval is more than context window, this value will be ignored."}),o.jsx(Q,{label:"Enable Archived Sessions in Memory Retrieval",checked:$.enabled_archived_sessions??!0,onChange:s=>le("enabled_archived_sessions",s)}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-1",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Similarity Threshold"}),o.jsx("span",{className:"text-sm font-mono text-azure-text-primary dark:text-matrix-highlight",children:($.similarity_threshold??.9).toFixed(2)})]}),o.jsx("input",{type:"range",min:0,max:1,step:.01,value:$.similarity_threshold??.9,onChange:s=>le("similarity_threshold",parseFloat(s.target.value)),className:`w-full h-1.5 rounded-full appearance-none cursor-pointer
40
40
  bg-gray-200 dark:bg-matrix-primary/30
41
41
  accent-azure-primary dark:accent-matrix-highlight`}),o.jsx("p",{className:"mt-1.5 text-xs text-gray-400 dark:text-matrix-secondary",children:"Minimum cosine similarity to consider a memory relevant (0–1). Lower values retrieve more memories, but may increase token consumption."})]})]})]}),be==="neo"&&o.jsxs(W,{title:"Neo Agent",children:[m.length>0&&o.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[o.jsxs("select",{value:x.neo??"",onChange:s=>ke(s.target.value,"neo"),className:"flex-1 px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight",children:[o.jsx("option",{value:"",disabled:!0,children:"Apply a preset..."}),m.map(s=>o.jsxs("option",{value:s.id,children:[s.name," (",s.provider," / ",s.model,")"]},s.id))]}),o.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary shrink-0",children:"Auto-fills fields below."})]}),o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"MCP + internal tools subagent — executes analytical and operational tasks delegated by Oracle"}),o.jsxs("div",{className:"mb-4",children:[o.jsx("button",{type:"button",onClick:Sr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),o.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),z&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("neo.provider")]}),o.jsx(V,{label:"",value:z.provider,onChange:s=>ie("provider",s.target.value),options:Ze,disabled:_("neo.provider")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("neo.model")]}),o.jsx(w,{label:"",value:z.model,onChange:s=>ie("model",s.target.value),disabled:_("neo.model")}),o.jsx(w,{label:"Personality",value:z.personality||"analytical_engineer",onChange:s=>ie("personality",s.target.value),placeholder:"analytical_engineer",helperText:"e.g., analytical_engineer, meticulous_auditor, systems_thinker"}),o.jsx(V,{label:"Execution Mode",value:z.execution_mode||"async",onChange:s=>ie("execution_mode",s.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),S("neo.temperature")]}),o.jsx(O,{label:"",value:z.temperature,onChange:s=>ie("temperature",parseFloat(s.target.value)),step:.1,min:0,max:1,disabled:_("neo.temperature")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),S("neo.max_tokens")]}),o.jsx(O,{label:"",value:z.max_tokens??"",onChange:s=>ie("max_tokens",s.target.value?parseInt(s.target.value):void 0),min:1,helperText:"Maximum tokens per response. Leave empty for model default.",disabled:_("neo.max_tokens")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Context Window (Messages)"}),S("neo.context_window")]}),o.jsx(O,{label:"",value:z.context_window??100,onChange:s=>ie("context_window",parseInt(s.target.value)),min:1,step:1,disabled:_("neo.context_window")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),o.jsxs("div",{className:"flex items-center gap-2",children:[S("neo.api_key"),_e("neo",z.api_key)]})]}),o.jsx(w,{label:"",type:"password",value:z.api_key||"",onChange:s=>ie("api_key",s.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("neo.api_key")}),z.provider==="openrouter"&&o.jsx(w,{label:"Base URL",value:z.base_url||"https://openrouter.ai/api/v1",onChange:s=>ie("base_url",s.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]})]}),be==="trinity"&&o.jsxs(W,{title:"Trinity Agent",children:[m.length>0&&o.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[o.jsxs("select",{value:x.trinity??"",onChange:s=>ke(s.target.value,"trinity"),className:"flex-1 px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight",children:[o.jsx("option",{value:"",disabled:!0,children:"Apply a preset..."}),m.map(s=>o.jsxs("option",{value:s.id,children:[s.name," (",s.provider," / ",s.model,")"]},s.id))]}),o.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary shrink-0",children:"Auto-fills fields below."})]}),o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Database subagent — interprets natural language queries and executes them against registered databases (PostgreSQL, MySQL, SQLite, MongoDB)"}),o.jsxs("div",{className:"mb-4",children:[o.jsx("button",{type:"button",onClick:wr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),o.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),T&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("trinity.provider")]}),o.jsx(V,{label:"",value:T.provider,onChange:s=>ue("provider",s.target.value),options:Ze,disabled:_("trinity.provider")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("trinity.model")]}),o.jsx(w,{label:"",value:T.model,onChange:s=>ue("model",s.target.value),disabled:_("trinity.model")}),o.jsx(w,{label:"Personality",value:T.personality||"data_specialist",onChange:s=>ue("personality",s.target.value),placeholder:"data_specialist",helperText:"e.g., data_specialist, query_optimizer, db_architect"}),o.jsx(V,{label:"Execution Mode",value:T.execution_mode||"async",onChange:s=>ue("execution_mode",s.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),S("trinity.temperature")]}),o.jsx(O,{label:"",value:T.temperature,onChange:s=>ue("temperature",parseFloat(s.target.value)),step:.1,min:0,max:1,disabled:_("trinity.temperature")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),S("trinity.max_tokens")]}),o.jsx(O,{label:"",value:T.max_tokens??"",onChange:s=>ue("max_tokens",s.target.value?parseInt(s.target.value):void 0),min:1,helperText:"Maximum tokens per response. Leave empty for model default.",disabled:_("trinity.max_tokens")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),o.jsxs("div",{className:"flex items-center gap-2",children:[S("trinity.api_key"),_e("trinity",T.api_key)]})]}),o.jsx(w,{label:"",type:"password",value:T.api_key||"",onChange:s=>ue("api_key",s.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("trinity.api_key")}),T.provider==="openrouter"&&o.jsx(w,{label:"Base URL",value:T.base_url||"https://openrouter.ai/api/v1",onChange:s=>ue("base_url",s.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]})]}),be==="link"&&o.jsxs(W,{title:"Link Agent",children:[m.length>0&&o.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[o.jsxs("select",{value:x.link??"",onChange:s=>ke(s.target.value,"link"),className:"flex-1 px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight",children:[o.jsx("option",{value:"",disabled:!0,children:"Apply a preset..."}),m.map(s=>o.jsxs("option",{value:s.id,children:[s.name," (",s.provider," / ",s.model,")"]},s.id))]}),o.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary shrink-0",children:"Auto-fills fields below."})]}),o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Documentation specialist — indexes documents from ~/.morpheus/docs, uses an LLM to reason over search results and synthesize intelligent answers"}),Z&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"mb-4",children:o.jsx("button",{type:"button",onClick:Nr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"})}),o.jsx(V,{label:"Provider",value:Z.provider||"openai",onChange:s=>X("provider",s.target.value),options:[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"openrouter",label:"OpenRouter"},{value:"ollama",label:"Ollama"},{value:"gemini",label:"Gemini"}]}),o.jsx(w,{label:"Model Name",value:Z.model||"",onChange:s=>X("model",s.target.value),placeholder:"e.g., gpt-4"}),o.jsx(w,{label:"Personality",value:Z.personality||"",onChange:s=>X("personality",s.target.value),placeholder:"documentation_specialist"}),o.jsx(V,{label:"Execution Mode",value:Z.execution_mode||"async",onChange:s=>X("execution_mode",s.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),o.jsx(O,{label:"Temperature",value:Z.temperature??.2,onChange:s=>X("temperature",parseFloat(s.target.value)),step:.1,min:0,max:1}),o.jsx(w,{label:"API Key (optional — falls back to Oracle)",value:Z.api_key||"",onChange:s=>X("api_key",s.target.value||void 0),type:"password",placeholder:"Leave empty to use Oracle's API key"}),o.jsx("h4",{className:"text-sm font-medium text-azure-text dark:text-matrix-highlight mt-6 mb-3",children:"RAG Settings"}),o.jsx(O,{label:"Chunk Size",value:Z.chunk_size,onChange:s=>X("chunk_size",parseInt(s.target.value)||500),min:100,max:2e3,helperText:"Character count per document chunk (default: 500)"}),o.jsx(O,{label:"Score Threshold",value:Z.score_threshold,onChange:s=>X("score_threshold",parseFloat(s.target.value)||.5),step:.1,min:0,max:1,helperText:"Minimum similarity score to include in results (0-1, default: 0.5)"}),o.jsx(O,{label:"Max Results",value:Z.max_results,onChange:s=>X("max_results",parseInt(s.target.value)||10),min:1,max:50,helperText:"Maximum number of chunks to return per search (default: 10)"}),o.jsx(O,{label:"Scan Interval (ms)",value:Z.scan_interval_ms,onChange:s=>X("scan_interval_ms",parseInt(s.target.value)||3e4),min:5e3,max:3e5,helperText:"How often to scan docs folder for changes (default: 30000ms = 30s)"}),o.jsx(O,{label:"Max File Size (MB)",value:Z.max_file_size_mb,onChange:s=>X("max_file_size_mb",parseInt(s.target.value)||50),min:1,max:100,helperText:"Maximum file size to process (default: 50MB)"}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsx(O,{label:"Vector Weight",value:Z.vector_weight,onChange:s=>X("vector_weight",parseFloat(s.target.value)||.8),step:.1,min:0,max:1,helperText:"Weight for vector similarity (default: 0.8)"}),o.jsx(O,{label:"BM25 Weight",value:Z.bm25_weight,onChange:s=>X("bm25_weight",parseFloat(s.target.value)||.2),step:.1,min:0,max:1,helperText:"Weight for keyword matching (default: 0.2)"})]}),o.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-2",children:"Note: Vector weight + BM25 weight should equal 1.0 for balanced results"})]})]}),be==="apoc"&&o.jsxs(W,{title:"Apoc Agent",children:[m.length>0&&o.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[o.jsxs("select",{value:x.apoc??"",onChange:s=>ke(s.target.value,"apoc"),className:"flex-1 px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight",children:[o.jsx("option",{value:"",disabled:!0,children:"Apply a preset..."}),m.map(s=>o.jsxs("option",{value:s.id,children:[s.name," (",s.provider," / ",s.model,")"]},s.id))]}),o.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary shrink-0",children:"Auto-fills fields below."})]}),o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"DevTools subagent — executes file, shell, git, network, and system operations on behalf of Oracle"}),o.jsxs("div",{className:"mb-4",children:[o.jsx("button",{type:"button",onClick:jr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),o.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),j&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("apoc.provider")]}),o.jsx(V,{label:"",value:j.provider,onChange:s=>ce("provider",s.target.value),options:Ze,disabled:_("apoc.provider")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("apoc.model")]}),o.jsx(w,{label:"",value:j.model,onChange:s=>ce("model",s.target.value),disabled:_("apoc.model")}),o.jsx(w,{label:"Personality",value:j.personality||"pragmatic_dev",onChange:s=>ce("personality",s.target.value),placeholder:"pragmatic_dev",helperText:"e.g., pragmatic_dev, cautious_admin, automation_specialist"}),o.jsx(V,{label:"Execution Mode",value:j.execution_mode||"async",onChange:s=>ce("execution_mode",s.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),S("apoc.temperature")]}),o.jsx(O,{label:"",value:j.temperature,onChange:s=>ce("temperature",parseFloat(s.target.value)),step:.1,min:0,max:1,disabled:_("apoc.temperature")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),o.jsxs("div",{className:"flex items-center gap-2",children:[S("apoc.api_key"),_e("apoc",j.api_key)]})]}),o.jsx(w,{label:"",type:"password",value:j.api_key||"",onChange:s=>ce("api_key",s.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("apoc.api_key")}),j.provider==="openrouter"&&o.jsx(w,{label:"Base URL",value:j.base_url||"https://openrouter.ai/api/v1",onChange:s=>ce("base_url",s.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"}),o.jsx(O,{label:"Timeout (ms)",value:j.timeout_ms??3e4,onChange:s=>ce("timeout_ms",parseInt(s.target.value)),min:1e3,step:1e3,helperText:"Maximum execution time for shell and system operations in milliseconds."})]})]})]}),re==="devkit"&&o.jsxs(o.Fragment,{children:[o.jsxs(W,{title:"DevKit Security",children:[o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Shared security configuration for DevKit tools used by Apoc. Controls path sandboxing, shell command restrictions, and tool category access."}),o.jsx(w,{label:"Sandbox Directory",value:d.devkit?.sandbox_dir||"",onChange:s=>y(["devkit","sandbox_dir"],s.target.value),placeholder:typeof window<"u"?"(defaults to process.cwd())":"",helperText:"Root directory for all DevKit operations. All file, shell, and git paths are confined here.",disabled:_("devkit.sandbox_dir")}),o.jsx(Xe,{label:"Allowed Paths",value:d.devkit?.allowed_paths?.join(`
42
42
  `)||"",onChange:s=>y(["devkit","allowed_paths"],s.target.value.split(`
43
- `).map(k=>k.trim()).filter(Boolean)),placeholder:"~/.morpheus/docs",helperText:"Additional paths outside sandbox_dir that DevKit can access (one per line).",rows:4}),o.jsx(V,{label:"Read-Only Mode",value:d.devkit?.readonly_mode?"true":"false",onChange:s=>y(["devkit","readonly_mode"],s.target.value==="true"),options:[{value:"false",label:"Disabled (read + write)"},{value:"true",label:"Enabled (read-only, blocks writes/deletes)"}],helperText:"When enabled, blocks all write, delete, and create operations on the filesystem.",disabled:_("devkit.readonly_mode")}),o.jsx(O,{label:"Timeout (ms)",value:d.devkit?.timeout_ms??3e4,onChange:s=>y(["devkit","timeout_ms"],parseInt(s.target.value)),min:1e3,step:1e3,helperText:"Default timeout for shell and system operations in milliseconds.",disabled:_("devkit.timeout_ms")})]}),o.jsxs(W,{title:"Tool Categories",children:[o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Enable or disable entire categories of DevKit tools."}),o.jsx(Q,{label:"Filesystem (read, write, list, copy, move, delete files)",checked:d.devkit?.enable_filesystem!==!1,onChange:s=>y(["devkit","enable_filesystem"],s)}),o.jsx(Q,{label:"Shell (run_command, run_script, which)",checked:d.devkit?.enable_shell!==!1,onChange:s=>y(["devkit","enable_shell"],s)}),o.jsx(Q,{label:"Git (status, diff, commit, push, pull, clone, branch)",checked:d.devkit?.enable_git!==!1,onChange:s=>y(["devkit","enable_git"],s)}),o.jsx(Q,{label:"Network (http_request, ping, dns_lookup, download_file)",checked:d.devkit?.enable_network!==!1,onChange:s=>y(["devkit","enable_network"],s)})]}),o.jsxs(W,{title:"Shell Command Allowlist",children:[o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Restrict which shell commands Apoc can execute. Leave empty to allow all commands (default)."}),o.jsx(w,{label:"Allowed Commands",value:(d.devkit?.allowed_shell_commands||[]).join(", "),onChange:s=>y(["devkit","allowed_shell_commands"],s.target.value.split(",").map(k=>k.trim()).filter(Boolean)),placeholder:"e.g. node, npm, git, python, cargo",helperText:"Comma-separated list of allowed binary names. Empty = all commands allowed.",disabled:_("devkit.allowed_shell_commands")})]})]}),re==="gws"&&o.jsxs(W,{title:"Google Workspace",children:[o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Configure Google Workspace integration for Sheet, Calendar, and Drive tools."}),o.jsx(Q,{label:"Enable GWS Skill Initialization",checked:d.gws?.enabled!==!1,onChange:s=>y(["gws","enabled"],s),helperText:"When enabled, GWS skills are automatically synchronized during startup."}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Service Account JSON"}),S("gws.service_account_json")]}),o.jsx(Xe,{label:"",value:d.gws?.service_account_json_content||"",onChange:s=>y(["gws","service_account_json_content"],s.target.value),placeholder:'{ "type": "service_account", ... }',helperText:"Paste your Google Service Account JSON key content here. It will be saved securely to ~/.morpheus/gws/credentials.json",disabled:_("gws.service_account_json"),rows:8}),d.gws?.service_account_json&&!d.gws?.service_account_json_content&&o.jsxs("p",{className:"text-xs text-emerald-600 dark:text-emerald-400 mt-1",children:["✅ Credentials file present at: ",d.gws.service_account_json]})]}),re==="audio"&&o.jsxs(o.Fragment,{children:[o.jsxs(W,{title:"Audio Transcription",children:[o.jsx(Q,{label:"Enable Audio",checked:d.audio.enabled,onChange:s=>y(["audio","enabled"],s)}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("audio.provider")]}),o.jsx(V,{label:"",value:d.audio.provider||"google",onChange:s=>y(["audio","provider"],s.target.value),options:[{label:"Google Gemini",value:"google"},{label:"OpenAI (Whisper)",value:"openai"},{label:"OpenRouter (multimodal)",value:"openrouter"},{label:"Ollama (Whisper local)",value:"ollama"}],error:H["audio.provider"],disabled:_("audio.provider")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model"}),S("audio.model")]}),o.jsx(w,{label:"",value:d.audio.model,onChange:s=>y(["audio","model"],s.target.value),placeholder:"e.g. whisper-1, gemini-2.5-flash-lite...",helperText:"Model to use for audio transcription.",error:H["audio.model"],disabled:_("audio.model")}),d.audio.provider==="ollama"&&o.jsx(w,{label:"Base URL",value:d.audio.base_url||"",onChange:s=>y(["audio","base_url"],s.target.value),placeholder:"http://localhost:11434",helperText:"Ollama base URL. Requires a Whisper model loaded (ollama pull whisper)."}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),o.jsxs("div",{className:"flex items-center gap-2",children:[S("audio.apiKey"),_e("audio",d.audio.apiKey)]})]}),o.jsx(w,{label:"",type:"password",value:d.audio.apiKey||"",onChange:s=>y(["audio","apiKey"],s.target.value),placeholder:"If different from LLM key...",helperText:"Leave empty to use LLM API key if using the same provider.",disabled:_("audio.apiKey")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Duration (Seconds)"}),S("audio.maxDurationSeconds")]}),o.jsx(O,{label:"",value:d.audio.maxDurationSeconds,onChange:s=>y(["audio","maxDurationSeconds"],parseInt(s.target.value)),min:1,disabled:_("audio.maxDurationSeconds")}),o.jsx(w,{label:"Supported Mime Types",value:d.audio.supportedMimeTypes.join(", "),onChange:s=>y(["audio","supportedMimeTypes"],s.target.value.split(",").map(k=>k.trim()).filter(Boolean)),helperText:"Comma separated list (e.g. audio/ogg, audio/mp3)"})]}),o.jsxs(W,{title:"Audio Response (TTS)",children:[o.jsx(Q,{label:"Enable Voice Responses",checked:d.audio.tts?.enabled??!1,onChange:s=>y(["audio","tts","enabled"],s)}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"TTS Provider"}),S("audio.tts.provider")]}),o.jsx(V,{label:"",value:d.audio.tts?.provider||"openai",onChange:s=>y(["audio","tts","provider"],s.target.value),options:[{label:"Google Gemini",value:"google"}],error:H["audio.tts.provider"],disabled:_("audio.tts.provider")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"TTS Model"}),S("audio.tts.model")]}),o.jsx(w,{label:"",value:d.audio.tts?.model||"gemini-2.5-flash-preview-tts",onChange:s=>y(["audio","tts","model"],s.target.value),placeholder:"e.g. gemini-2.5-flash-preview-tts, tts-1...",helperText:"Google: gemini-2.5-flash-preview-tts. OpenAI: tts-1, tts-1-hd.",error:H["audio.tts.model"],disabled:_("audio.tts.model")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Voice"}),S("audio.tts.voice")]}),d.audio.tts?.provider==="openai"?o.jsx(V,{label:"",value:d.audio.tts?.voice||"alloy",onChange:s=>y(["audio","tts","voice"],s.target.value),options:[{label:"Alloy",value:"alloy"},{label:"Echo",value:"echo"},{label:"Fable",value:"fable"},{label:"Onyx",value:"onyx"},{label:"Nova",value:"nova"},{label:"Shimmer",value:"shimmer"},{label:"Ash",value:"ash"},{label:"Ballad",value:"ballad"},{label:"Coral",value:"coral"},{label:"Sage",value:"sage"}],error:H["audio.tts.voice"],disabled:_("audio.tts.voice")}):o.jsxs(o.Fragment,{children:[o.jsx(V,{label:"",value:d.audio.tts?.voice||"Kore",onChange:s=>y(["audio","tts","voice"],s.target.value),options:[{label:"Achernar (F)",value:"Achernar"},{label:"Achird (M)",value:"Achird"},{label:"Algenib (M)",value:"Algenib"},{label:"Algieba (M)",value:"Algieba"},{label:"Alnilam (M)",value:"Alnilam"},{label:"Aoede (F)",value:"Aoede"},{label:"Autonoe (F)",value:"Autonoe"},{label:"Callirrhoe (F)",value:"Callirrhoe"},{label:"Charon (M)",value:"Charon"},{label:"Despina (F)",value:"Despina"},{label:"Enceladus (M)",value:"Enceladus"},{label:"Erinome (F)",value:"Erinome"},{label:"Fenrir (M)",value:"Fenrir"},{label:"Gacrux (F)",value:"Gacrux"},{label:"Iapetus (M)",value:"Iapetus"},{label:"Kore (F)",value:"Kore"},{label:"Laomedeia (F)",value:"Laomedeia"},{label:"Leda (F)",value:"Leda"},{label:"Orus (M)",value:"Orus"},{label:"Pulcherrima (F)",value:"Pulcherrima"},{label:"Puck (M)",value:"Puck"},{label:"Rasalgethi (M)",value:"Rasalgethi"},{label:"Sadachbia (M)",value:"Sadachbia"},{label:"Sadaltager (M)",value:"Sadaltager"},{label:"Schedar (M)",value:"Schedar"},{label:"Sulafat (F)",value:"Sulafat"},{label:"Umbriel (M)",value:"Umbriel"},{label:"Vindemiatrix (F)",value:"Vindemiatrix"},{label:"Zephyr (F)",value:"Zephyr"},{label:"Zubenelgenubi (M)",value:"Zubenelgenubi"}],error:H["audio.tts.voice"],disabled:_("audio.tts.voice")}),o.jsxs("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-1",children:["Listen examples in"," ",o.jsx("a",{href:"https://docs.cloud.google.com/text-to-speech/docs/gemini-tts#voice_options",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-azure-text-primary dark:hover:text-matrix-secondary",children:"Google TTS Voice Options"})]})]}),o.jsx(w,{label:"Style Prompt",value:d.audio.tts?.style_prompt||"",onChange:s=>y(["audio","tts","style_prompt"],s.target.value),placeholder:"e.g. fale de forma calma e pausada",helperText:"Instrução de tom/estilo aplicada antes de cada resposta. Ex: fale animado, fale devagar, fale com entusiasmo.",disabled:_("audio.tts.style_prompt")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"TTS API Key"}),o.jsx("div",{className:"flex items-center gap-2",children:S("audio.tts.apiKey")})]}),o.jsx(w,{label:"",type:"password",value:d.audio.tts?.apiKey||"",onChange:s=>y(["audio","tts","apiKey"],s.target.value),placeholder:"If different from STT or LLM key...",helperText:"Leave empty to use the STT API key or LLM API key.",disabled:_("audio.tts.apiKey")})]})]}),re==="channels"&&o.jsxs(o.Fragment,{children:[o.jsxs(W,{title:"Telegram",children:[o.jsx(Q,{label:"Enable Telegram",checked:d.channels.telegram.enabled,onChange:s=>y(["channels","telegram","enabled"],s)}),d.channels.telegram.enabled&&o.jsxs("div",{className:"space-y-4 mt-4 pl-4 border-l border-matrix-primary",children:[o.jsx(w,{label:"Bot Token",type:"password",value:d.channels.telegram.token||"",onChange:s=>y(["channels","telegram","token"],s.target.value)}),o.jsx(w,{label:"Allowed Users (comma separated)",value:d.channels.telegram.allowedUsers.join(", "),onChange:s=>y(["channels","telegram","allowedUsers"],s.target.value.split(",").map(k=>k.trim()).filter(Boolean)),helperText:"User IDs allowed to interact with the bot"})]})]}),o.jsxs(W,{title:"Discord",children:[o.jsx(Q,{label:"Enable Discord",checked:d.channels.discord.enabled,onChange:s=>y(["channels","discord","enabled"],s)}),d.channels.discord.enabled&&o.jsxs("div",{className:"space-y-4 mt-4 pl-4 border-l border-matrix-primary",children:[o.jsx(w,{label:"Bot Token",type:"password",value:d.channels.discord.token||"",onChange:s=>y(["channels","discord","token"],s.target.value)}),o.jsx(w,{label:"Allowed Users (comma separated)",value:(d.channels.discord.allowedUsers??[]).join(", "),onChange:s=>y(["channels","discord","allowedUsers"],s.target.value.split(",").map(k=>k.trim()).filter(Boolean)),helperText:"Discord user IDs allowed to interact with the bot"})]})]})]}),re==="ui"&&o.jsxs(o.Fragment,{children:[o.jsxs(W,{title:"Dashboard",children:[o.jsx(Q,{label:"Enable Web UI",checked:d.ui.enabled,onChange:s=>y(["ui","enabled"],s)}),o.jsx(O,{label:"Port",value:d.ui.port,onChange:s=>y(["ui","port"],parseInt(s.target.value)),disabled:!0,helperText:"Port changes require daemon restart."})]}),o.jsx(W,{title:"Display Currency",children:(()=>{const s=d.currency?.code??"USD",E=Ye.some(C=>C.code===s&&C.code!=="OTHER")?s:"OTHER";return o.jsxs(o.Fragment,{children:[o.jsx(V,{label:"Currency",value:E,onChange:C=>kr(C.target.value),options:Ye.map(C=>({value:C.code,label:C.label})),helperText:"Costs are always stored in USD. The selected currency is used for display only."}),E==="OTHER"&&o.jsxs(o.Fragment,{children:[o.jsx(w,{label:"Currency Code",value:s,onChange:C=>y(["currency","code"],C.target.value.toUpperCase()),helperText:"ISO 4217 code (e.g. MXN, CNY, INR)."}),o.jsx(w,{label:"Currency Symbol",value:d.currency?.symbol??"",onChange:C=>y(["currency","symbol"],C.target.value),helperText:"Symbol shown in cost displays (e.g. MX$, ¥, ₹)."})]}),o.jsx(O,{label:"Conversion Rate (from USD)",value:d.currency?.rate??1,onChange:C=>y(["currency","rate"],parseFloat(C.target.value)||1),min:1e-4,step:.01,helperText:"Multiply USD values by this rate. Example: 5.25 for BRL. Use 1.0 for USD (no conversion)."})]})})()})]}),re==="logging"&&o.jsxs(W,{title:"Logging",children:[o.jsx(Q,{label:"Enable Logging",checked:d.logging.enabled,onChange:s=>y(["logging","enabled"],s)}),o.jsx(V,{label:"Log Level",value:d.logging.level,onChange:s=>y(["logging","level"],s.target.value),options:[{label:"Debug",value:"debug"},{label:"Info",value:"info"},{label:"Warning",value:"warn"},{label:"Error",value:"error"}]})]}),re==="chronos"&&f&&o.jsxs(W,{title:"Chronos — Temporal Intent Engine",children:[o.jsx(V,{label:"Timezone",value:f.timezone,onChange:s=>g({...f,timezone:s.target.value}),options:[{label:"UTC",value:"UTC"},{label:"America/New_York",value:"America/New_York"},{label:"America/Chicago",value:"America/Chicago"},{label:"America/Denver",value:"America/Denver"},{label:"America/Los_Angeles",value:"America/Los_Angeles"},{label:"America/Sao_Paulo",value:"America/Sao_Paulo"},{label:"America/Buenos_Aires",value:"America/Buenos_Aires"},{label:"America/Bogota",value:"America/Bogota"},{label:"America/Lima",value:"America/Lima"},{label:"America/Santiago",value:"America/Santiago"},{label:"America/Mexico_City",value:"America/Mexico_City"},{label:"America/Toronto",value:"America/Toronto"},{label:"America/Vancouver",value:"America/Vancouver"},{label:"Europe/London",value:"Europe/London"},{label:"Europe/Paris",value:"Europe/Paris"},{label:"Europe/Berlin",value:"Europe/Berlin"},{label:"Europe/Madrid",value:"Europe/Madrid"},{label:"Europe/Rome",value:"Europe/Rome"},{label:"Europe/Amsterdam",value:"Europe/Amsterdam"},{label:"Europe/Brussels",value:"Europe/Brussels"},{label:"Europe/Zurich",value:"Europe/Zurich"},{label:"Europe/Lisbon",value:"Europe/Lisbon"},{label:"Europe/Warsaw",value:"Europe/Warsaw"},{label:"Europe/Stockholm",value:"Europe/Stockholm"},{label:"Europe/Helsinki",value:"Europe/Helsinki"},{label:"Europe/Moscow",value:"Europe/Moscow"},{label:"Asia/Dubai",value:"Asia/Dubai"},{label:"Asia/Kolkata",value:"Asia/Kolkata"},{label:"Asia/Bangkok",value:"Asia/Bangkok"},{label:"Asia/Singapore",value:"Asia/Singapore"},{label:"Asia/Hong_Kong",value:"Asia/Hong_Kong"},{label:"Asia/Shanghai",value:"Asia/Shanghai"},{label:"Asia/Tokyo",value:"Asia/Tokyo"},{label:"Asia/Seoul",value:"Asia/Seoul"},{label:"Australia/Sydney",value:"Australia/Sydney"},{label:"Australia/Melbourne",value:"Australia/Melbourne"},{label:"Pacific/Auckland",value:"Pacific/Auckland"},{label:"Africa/Cairo",value:"Africa/Cairo"},{label:"Africa/Johannesburg",value:"Africa/Johannesburg"}]}),o.jsx(O,{label:"Check Interval (seconds)",value:Math.round(f.check_interval_ms/1e3),onChange:s=>g({...f,check_interval_ms:Number(s.target.value)*1e3}),min:60}),o.jsx(O,{label:"Max Active Jobs",value:f.max_active_jobs,onChange:s=>g({...f,max_active_jobs:Number(s.target.value)}),min:1,max:1e3})]}),re==="danger"&&o.jsx(Js,{})]})]}):o.jsx("div",{className:"p-8 text-azure-primary dark:text-matrix-highlight",children:"Loading settings..."})}const we=[{id:"sessions",label:"Sessions & Messages",description:"All chat sessions and their messages"},{id:"memories",label:"Long-term Memories",description:"Sati knowledge base, embeddings, and archived session chunks"},{id:"tasks",label:"Tasks",description:"Background task queue and execution results"},{id:"audit",label:"Audit Logs",description:"All agent and tool audit events"},{id:"chronos",label:"Chronos Jobs",description:"Scheduled jobs and their execution history"},{id:"webhooks",label:"Webhooks",description:"Webhook definitions and notification history"}];function Js(){const[e,t]=P.useState(new Set),[r,n]=P.useState(!1),[a,l]=P.useState(!1),[i,c]=P.useState(null),u=g=>{t(x=>{const F=new Set(x);return F.has(g)?F.delete(g):F.add(g),F})},m=()=>{e.size===we.length?t(new Set):t(new Set(we.map(g=>g.id)))},h=async()=>{if(e.size!==0){l(!0),c(null);try{const g=await Us.resetData([...e]);c({success:!0,message:g.message}),t(new Set),me(()=>!0,void 0,{revalidate:!0})}catch(g){c({success:!1,message:g instanceof Error?g.message:"Failed to reset data"})}finally{l(!1)}}},f=we.filter(g=>e.has(g.id)).map(g=>g.label);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rounded-lg border-2 border-red-300 dark:border-red-900 bg-red-50 dark:bg-red-950/20 p-6 space-y-5",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Rr,{className:"w-6 h-6 text-red-500 dark:text-red-400 shrink-0"}),o.jsx("h3",{className:"text-lg font-semibold text-red-700 dark:text-red-400",children:"Danger Zone"})]}),o.jsxs("p",{className:"text-sm text-red-600 dark:text-red-300/80",children:["Select the data you want to permanently delete. These actions are ",o.jsx("strong",{children:"irreversible"}),"."]}),o.jsxs("div",{className:"rounded-md border border-red-200 dark:border-red-900/60 bg-white dark:bg-black p-4 space-y-3",children:[o.jsxs("label",{className:"flex items-center gap-3 pb-2 border-b border-red-100 dark:border-red-900/40 cursor-pointer select-none",children:[o.jsx("input",{type:"checkbox",checked:e.size===we.length,onChange:m,className:`w-4 h-4 rounded border-red-300 text-red-600 focus:ring-red-500
43
+ `).map(k=>k.trim()).filter(Boolean)),placeholder:"~/.morpheus/docs",helperText:"Additional paths outside sandbox_dir that DevKit can access (one per line).",rows:4}),o.jsx(V,{label:"Read-Only Mode",value:d.devkit?.readonly_mode?"true":"false",onChange:s=>y(["devkit","readonly_mode"],s.target.value==="true"),options:[{value:"false",label:"Disabled (read + write)"},{value:"true",label:"Enabled (read-only, blocks writes/deletes)"}],helperText:"When enabled, blocks all write, delete, and create operations on the filesystem.",disabled:_("devkit.readonly_mode")}),o.jsx(O,{label:"Timeout (ms)",value:d.devkit?.timeout_ms??3e4,onChange:s=>y(["devkit","timeout_ms"],parseInt(s.target.value)),min:1e3,step:1e3,helperText:"Default timeout for shell and system operations in milliseconds.",disabled:_("devkit.timeout_ms")})]}),o.jsxs(W,{title:"Tool Categories",children:[o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Enable or disable entire categories of DevKit tools."}),o.jsx(Q,{label:"Filesystem (read, write, list, copy, move, delete files)",checked:d.devkit?.enable_filesystem!==!1,onChange:s=>y(["devkit","enable_filesystem"],s)}),o.jsx(Q,{label:"Shell (run_command, run_script, which)",checked:d.devkit?.enable_shell!==!1,onChange:s=>y(["devkit","enable_shell"],s)}),o.jsx(Q,{label:"Git (status, diff, commit, push, pull, clone, branch)",checked:d.devkit?.enable_git!==!1,onChange:s=>y(["devkit","enable_git"],s)}),o.jsx(Q,{label:"Network (http_request, ping, dns_lookup, download_file)",checked:d.devkit?.enable_network!==!1,onChange:s=>y(["devkit","enable_network"],s)})]}),o.jsxs(W,{title:"Shell Command Allowlist",children:[o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Restrict which shell commands Apoc can execute. Leave empty to allow all commands (default)."}),o.jsx(w,{label:"Allowed Commands",value:(d.devkit?.allowed_shell_commands||[]).join(", "),onChange:s=>y(["devkit","allowed_shell_commands"],s.target.value.split(",").map(k=>k.trim()).filter(Boolean)),placeholder:"e.g. node, npm, git, python, cargo",helperText:"Comma-separated list of allowed binary names. Empty = all commands allowed.",disabled:_("devkit.allowed_shell_commands")})]})]}),re==="gws"&&o.jsxs(W,{title:"Google Workspace",children:[o.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Configure Google Workspace integration for Sheet, Calendar, and Drive tools."}),o.jsx(Q,{label:"Enable GWS Skill Initialization",checked:d.gws?.enabled!==!1,onChange:s=>y(["gws","enabled"],s),helperText:"When enabled, GWS skills are automatically synchronized during startup."}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Service Account JSON"}),S("gws.service_account_json")]}),o.jsx(Xe,{label:"",value:d.gws?.service_account_json_content||"",onChange:s=>y(["gws","service_account_json_content"],s.target.value),placeholder:'{ "type": "service_account", ... }',helperText:"Paste your Google Service Account JSON key content here. It will be saved securely to ~/.morpheus/gws/credentials.json",disabled:_("gws.service_account_json"),rows:8}),d.gws?.service_account_json&&!d.gws?.service_account_json_content&&o.jsxs("p",{className:"text-xs text-emerald-600 dark:text-emerald-400 mt-1",children:["✅ Credentials file present at: ",d.gws.service_account_json]})]}),re==="audio"&&o.jsxs(o.Fragment,{children:[o.jsxs(W,{title:"Audio Transcription",children:[o.jsx(Q,{label:"Enable Audio",checked:d.audio.enabled,onChange:s=>y(["audio","enabled"],s)}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("audio.provider")]}),o.jsx(V,{label:"",value:d.audio.provider||"gemini",onChange:s=>y(["audio","provider"],s.target.value),options:[{label:"Google Gemini",value:"gemini"},{label:"OpenAI (Whisper)",value:"openai"},{label:"OpenRouter (multimodal)",value:"openrouter"},{label:"Ollama (Whisper local)",value:"ollama"}],error:H["audio.provider"],disabled:_("audio.provider")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model"}),S("audio.model")]}),o.jsx(w,{label:"",value:d.audio.model,onChange:s=>y(["audio","model"],s.target.value),placeholder:"e.g. whisper-1, gemini-2.5-flash-lite...",helperText:"Model to use for audio transcription.",error:H["audio.model"],disabled:_("audio.model")}),d.audio.provider==="ollama"&&o.jsx(w,{label:"Base URL",value:d.audio.base_url||"",onChange:s=>y(["audio","base_url"],s.target.value),placeholder:"http://localhost:11434",helperText:"Ollama base URL. Requires a Whisper model loaded (ollama pull whisper)."}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),o.jsxs("div",{className:"flex items-center gap-2",children:[S("audio.apiKey"),_e("audio",d.audio.apiKey)]})]}),o.jsx(w,{label:"",type:"password",value:d.audio.apiKey||"",onChange:s=>y(["audio","apiKey"],s.target.value),placeholder:"If different from LLM key...",helperText:"Leave empty to use LLM API key if using the same provider.",disabled:_("audio.apiKey")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Duration (Seconds)"}),S("audio.maxDurationSeconds")]}),o.jsx(O,{label:"",value:d.audio.maxDurationSeconds,onChange:s=>y(["audio","maxDurationSeconds"],parseInt(s.target.value)),min:1,disabled:_("audio.maxDurationSeconds")}),o.jsx(w,{label:"Supported Mime Types",value:d.audio.supportedMimeTypes.join(", "),onChange:s=>y(["audio","supportedMimeTypes"],s.target.value.split(",").map(k=>k.trim()).filter(Boolean)),helperText:"Comma separated list (e.g. audio/ogg, audio/mp3)"})]}),o.jsxs(W,{title:"Audio Response (TTS)",children:[o.jsx(Q,{label:"Enable Voice Responses",checked:d.audio.tts?.enabled??!1,onChange:s=>y(["audio","tts","enabled"],s)}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"TTS Provider"}),S("audio.tts.provider")]}),o.jsx(V,{label:"",value:d.audio.tts?.provider||"openai",onChange:s=>y(["audio","tts","provider"],s.target.value),options:[{label:"Google Gemini",value:"gemini"}],error:H["audio.tts.provider"],disabled:_("audio.tts.provider")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"TTS Model"}),S("audio.tts.model")]}),o.jsx(w,{label:"",value:d.audio.tts?.model||"gemini-2.5-flash-preview-tts",onChange:s=>y(["audio","tts","model"],s.target.value),placeholder:"e.g. gemini-2.5-flash-preview-tts, tts-1...",helperText:"Google: gemini-2.5-flash-preview-tts. OpenAI: tts-1, tts-1-hd.",error:H["audio.tts.model"],disabled:_("audio.tts.model")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Voice"}),S("audio.tts.voice")]}),d.audio.tts?.provider==="openai"?o.jsx(V,{label:"",value:d.audio.tts?.voice||"alloy",onChange:s=>y(["audio","tts","voice"],s.target.value),options:[{label:"Alloy",value:"alloy"},{label:"Echo",value:"echo"},{label:"Fable",value:"fable"},{label:"Onyx",value:"onyx"},{label:"Nova",value:"nova"},{label:"Shimmer",value:"shimmer"},{label:"Ash",value:"ash"},{label:"Ballad",value:"ballad"},{label:"Coral",value:"coral"},{label:"Sage",value:"sage"}],error:H["audio.tts.voice"],disabled:_("audio.tts.voice")}):o.jsxs(o.Fragment,{children:[o.jsx(V,{label:"",value:d.audio.tts?.voice||"Kore",onChange:s=>y(["audio","tts","voice"],s.target.value),options:[{label:"Achernar (F)",value:"Achernar"},{label:"Achird (M)",value:"Achird"},{label:"Algenib (M)",value:"Algenib"},{label:"Algieba (M)",value:"Algieba"},{label:"Alnilam (M)",value:"Alnilam"},{label:"Aoede (F)",value:"Aoede"},{label:"Autonoe (F)",value:"Autonoe"},{label:"Callirrhoe (F)",value:"Callirrhoe"},{label:"Charon (M)",value:"Charon"},{label:"Despina (F)",value:"Despina"},{label:"Enceladus (M)",value:"Enceladus"},{label:"Erinome (F)",value:"Erinome"},{label:"Fenrir (M)",value:"Fenrir"},{label:"Gacrux (F)",value:"Gacrux"},{label:"Iapetus (M)",value:"Iapetus"},{label:"Kore (F)",value:"Kore"},{label:"Laomedeia (F)",value:"Laomedeia"},{label:"Leda (F)",value:"Leda"},{label:"Orus (M)",value:"Orus"},{label:"Pulcherrima (F)",value:"Pulcherrima"},{label:"Puck (M)",value:"Puck"},{label:"Rasalgethi (M)",value:"Rasalgethi"},{label:"Sadachbia (M)",value:"Sadachbia"},{label:"Sadaltager (M)",value:"Sadaltager"},{label:"Schedar (M)",value:"Schedar"},{label:"Sulafat (F)",value:"Sulafat"},{label:"Umbriel (M)",value:"Umbriel"},{label:"Vindemiatrix (F)",value:"Vindemiatrix"},{label:"Zephyr (F)",value:"Zephyr"},{label:"Zubenelgenubi (M)",value:"Zubenelgenubi"}],error:H["audio.tts.voice"],disabled:_("audio.tts.voice")}),o.jsxs("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-1",children:["Listen examples in"," ",o.jsx("a",{href:"https://docs.cloud.google.com/text-to-speech/docs/gemini-tts#voice_options",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-azure-text-primary dark:hover:text-matrix-secondary",children:"Google TTS Voice Options"})]})]}),o.jsx(w,{label:"Style Prompt",value:d.audio.tts?.style_prompt||"",onChange:s=>y(["audio","tts","style_prompt"],s.target.value),placeholder:"e.g. fale de forma calma e pausada",helperText:"Instrução de tom/estilo aplicada antes de cada resposta. Ex: fale animado, fale devagar, fale com entusiasmo.",disabled:_("audio.tts.style_prompt")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"TTS API Key"}),o.jsx("div",{className:"flex items-center gap-2",children:S("audio.tts.apiKey")})]}),o.jsx(w,{label:"",type:"password",value:d.audio.tts?.apiKey||"",onChange:s=>y(["audio","tts","apiKey"],s.target.value),placeholder:"If different from STT or LLM key...",helperText:"Leave empty to use the STT API key or LLM API key.",disabled:_("audio.tts.apiKey")})]})]}),re==="channels"&&o.jsxs(o.Fragment,{children:[o.jsxs(W,{title:"Telegram",children:[o.jsx(Q,{label:"Enable Telegram",checked:d.channels.telegram.enabled,onChange:s=>y(["channels","telegram","enabled"],s)}),d.channels.telegram.enabled&&o.jsxs("div",{className:"space-y-4 mt-4 pl-4 border-l border-matrix-primary",children:[o.jsx(w,{label:"Bot Token",type:"password",value:d.channels.telegram.token||"",onChange:s=>y(["channels","telegram","token"],s.target.value)}),o.jsx(w,{label:"Allowed Users (comma separated)",value:d.channels.telegram.allowedUsers.join(", "),onChange:s=>y(["channels","telegram","allowedUsers"],s.target.value.split(",").map(k=>k.trim()).filter(Boolean)),helperText:"User IDs allowed to interact with the bot"})]})]}),o.jsxs(W,{title:"Discord",children:[o.jsx(Q,{label:"Enable Discord",checked:d.channels.discord.enabled,onChange:s=>y(["channels","discord","enabled"],s)}),d.channels.discord.enabled&&o.jsxs("div",{className:"space-y-4 mt-4 pl-4 border-l border-matrix-primary",children:[o.jsx(w,{label:"Bot Token",type:"password",value:d.channels.discord.token||"",onChange:s=>y(["channels","discord","token"],s.target.value)}),o.jsx(w,{label:"Allowed Users (comma separated)",value:(d.channels.discord.allowedUsers??[]).join(", "),onChange:s=>y(["channels","discord","allowedUsers"],s.target.value.split(",").map(k=>k.trim()).filter(Boolean)),helperText:"Discord user IDs allowed to interact with the bot"})]})]})]}),re==="ui"&&o.jsxs(o.Fragment,{children:[o.jsxs(W,{title:"Dashboard",children:[o.jsx(Q,{label:"Enable Web UI",checked:d.ui.enabled,onChange:s=>y(["ui","enabled"],s)}),o.jsx(O,{label:"Port",value:d.ui.port,onChange:s=>y(["ui","port"],parseInt(s.target.value)),disabled:!0,helperText:"Port changes require daemon restart."})]}),o.jsx(W,{title:"Display Currency",children:(()=>{const s=d.currency?.code??"USD",E=Ye.some(C=>C.code===s&&C.code!=="OTHER")?s:"OTHER";return o.jsxs(o.Fragment,{children:[o.jsx(V,{label:"Currency",value:E,onChange:C=>kr(C.target.value),options:Ye.map(C=>({value:C.code,label:C.label})),helperText:"Costs are always stored in USD. The selected currency is used for display only."}),E==="OTHER"&&o.jsxs(o.Fragment,{children:[o.jsx(w,{label:"Currency Code",value:s,onChange:C=>y(["currency","code"],C.target.value.toUpperCase()),helperText:"ISO 4217 code (e.g. MXN, CNY, INR)."}),o.jsx(w,{label:"Currency Symbol",value:d.currency?.symbol??"",onChange:C=>y(["currency","symbol"],C.target.value),helperText:"Symbol shown in cost displays (e.g. MX$, ¥, ₹)."})]}),o.jsx(O,{label:"Conversion Rate (from USD)",value:d.currency?.rate??1,onChange:C=>y(["currency","rate"],parseFloat(C.target.value)||1),min:1e-4,step:.01,helperText:"Multiply USD values by this rate. Example: 5.25 for BRL. Use 1.0 for USD (no conversion)."})]})})()})]}),re==="logging"&&o.jsxs(W,{title:"Logging",children:[o.jsx(Q,{label:"Enable Logging",checked:d.logging.enabled,onChange:s=>y(["logging","enabled"],s)}),o.jsx(V,{label:"Log Level",value:d.logging.level,onChange:s=>y(["logging","level"],s.target.value),options:[{label:"Debug",value:"debug"},{label:"Info",value:"info"},{label:"Warning",value:"warn"},{label:"Error",value:"error"}]})]}),re==="chronos"&&f&&o.jsxs(W,{title:"Chronos — Temporal Intent Engine",children:[o.jsx(V,{label:"Timezone",value:f.timezone,onChange:s=>g({...f,timezone:s.target.value}),options:[{label:"UTC",value:"UTC"},{label:"America/New_York",value:"America/New_York"},{label:"America/Chicago",value:"America/Chicago"},{label:"America/Denver",value:"America/Denver"},{label:"America/Los_Angeles",value:"America/Los_Angeles"},{label:"America/Sao_Paulo",value:"America/Sao_Paulo"},{label:"America/Buenos_Aires",value:"America/Buenos_Aires"},{label:"America/Bogota",value:"America/Bogota"},{label:"America/Lima",value:"America/Lima"},{label:"America/Santiago",value:"America/Santiago"},{label:"America/Mexico_City",value:"America/Mexico_City"},{label:"America/Toronto",value:"America/Toronto"},{label:"America/Vancouver",value:"America/Vancouver"},{label:"Europe/London",value:"Europe/London"},{label:"Europe/Paris",value:"Europe/Paris"},{label:"Europe/Berlin",value:"Europe/Berlin"},{label:"Europe/Madrid",value:"Europe/Madrid"},{label:"Europe/Rome",value:"Europe/Rome"},{label:"Europe/Amsterdam",value:"Europe/Amsterdam"},{label:"Europe/Brussels",value:"Europe/Brussels"},{label:"Europe/Zurich",value:"Europe/Zurich"},{label:"Europe/Lisbon",value:"Europe/Lisbon"},{label:"Europe/Warsaw",value:"Europe/Warsaw"},{label:"Europe/Stockholm",value:"Europe/Stockholm"},{label:"Europe/Helsinki",value:"Europe/Helsinki"},{label:"Europe/Moscow",value:"Europe/Moscow"},{label:"Asia/Dubai",value:"Asia/Dubai"},{label:"Asia/Kolkata",value:"Asia/Kolkata"},{label:"Asia/Bangkok",value:"Asia/Bangkok"},{label:"Asia/Singapore",value:"Asia/Singapore"},{label:"Asia/Hong_Kong",value:"Asia/Hong_Kong"},{label:"Asia/Shanghai",value:"Asia/Shanghai"},{label:"Asia/Tokyo",value:"Asia/Tokyo"},{label:"Asia/Seoul",value:"Asia/Seoul"},{label:"Australia/Sydney",value:"Australia/Sydney"},{label:"Australia/Melbourne",value:"Australia/Melbourne"},{label:"Pacific/Auckland",value:"Pacific/Auckland"},{label:"Africa/Cairo",value:"Africa/Cairo"},{label:"Africa/Johannesburg",value:"Africa/Johannesburg"}]}),o.jsx(O,{label:"Check Interval (seconds)",value:Math.round(f.check_interval_ms/1e3),onChange:s=>g({...f,check_interval_ms:Number(s.target.value)*1e3}),min:60}),o.jsx(O,{label:"Max Active Jobs",value:f.max_active_jobs,onChange:s=>g({...f,max_active_jobs:Number(s.target.value)}),min:1,max:1e3})]}),re==="danger"&&o.jsx(Js,{})]})]}):o.jsx("div",{className:"p-8 text-azure-primary dark:text-matrix-highlight",children:"Loading settings..."})}const we=[{id:"sessions",label:"Sessions & Messages",description:"All chat sessions and their messages"},{id:"memories",label:"Long-term Memories",description:"Sati knowledge base, embeddings, and archived session chunks"},{id:"tasks",label:"Tasks",description:"Background task queue and execution results"},{id:"audit",label:"Audit Logs",description:"All agent and tool audit events"},{id:"chronos",label:"Chronos Jobs",description:"Scheduled jobs and their execution history"},{id:"webhooks",label:"Webhooks",description:"Webhook definitions and notification history"}];function Js(){const[e,t]=P.useState(new Set),[r,n]=P.useState(!1),[a,l]=P.useState(!1),[i,c]=P.useState(null),u=g=>{t(x=>{const F=new Set(x);return F.has(g)?F.delete(g):F.add(g),F})},m=()=>{e.size===we.length?t(new Set):t(new Set(we.map(g=>g.id)))},h=async()=>{if(e.size!==0){l(!0),c(null);try{const g=await Us.resetData([...e]);c({success:!0,message:g.message}),t(new Set),me(()=>!0,void 0,{revalidate:!0})}catch(g){c({success:!1,message:g instanceof Error?g.message:"Failed to reset data"})}finally{l(!1)}}},f=we.filter(g=>e.has(g.id)).map(g=>g.label);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rounded-lg border-2 border-red-300 dark:border-red-900 bg-red-50 dark:bg-red-950/20 p-6 space-y-5",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Rr,{className:"w-6 h-6 text-red-500 dark:text-red-400 shrink-0"}),o.jsx("h3",{className:"text-lg font-semibold text-red-700 dark:text-red-400",children:"Danger Zone"})]}),o.jsxs("p",{className:"text-sm text-red-600 dark:text-red-300/80",children:["Select the data you want to permanently delete. These actions are ",o.jsx("strong",{children:"irreversible"}),"."]}),o.jsxs("div",{className:"rounded-md border border-red-200 dark:border-red-900/60 bg-white dark:bg-black p-4 space-y-3",children:[o.jsxs("label",{className:"flex items-center gap-3 pb-2 border-b border-red-100 dark:border-red-900/40 cursor-pointer select-none",children:[o.jsx("input",{type:"checkbox",checked:e.size===we.length,onChange:m,className:`w-4 h-4 rounded border-red-300 text-red-600 focus:ring-red-500
44
44
  dark:border-red-800 dark:bg-black dark:checked:bg-red-600`}),o.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-400",children:"Select all"})]}),we.map(g=>o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[o.jsx("input",{type:"checkbox",checked:e.has(g.id),onChange:()=>u(g.id),className:`w-4 h-4 mt-0.5 rounded border-red-300 text-red-600 focus:ring-red-500
45
45
  dark:border-red-800 dark:bg-black dark:checked:bg-red-600`}),o.jsxs("div",{children:[o.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:g.label}),o.jsx("p",{className:"text-xs text-red-500 dark:text-red-300/60",children:g.description})]})]},g.id))]}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx("p",{className:"text-xs text-red-500 dark:text-red-300/50",children:e.size===0?"No categories selected":`${e.size} of ${we.length} selected`}),o.jsx("button",{onClick:()=>n(!0),disabled:a||e.size===0,className:`shrink-0 px-4 py-2 text-sm font-medium rounded-md
46
46
  bg-red-600 text-white hover:bg-red-700