morpheus-cli 0.9.13 → 0.9.20

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 (86) hide show
  1. package/README.md +48 -17
  2. package/dist/channels/discord.js +93 -6
  3. package/dist/channels/telegram.js +109 -9
  4. package/dist/cli/commands/start.js +15 -0
  5. package/dist/config/manager.js +20 -1
  6. package/dist/config/paths.js +4 -0
  7. package/dist/config/schemas.js +15 -0
  8. package/dist/http/api.js +2 -1
  9. package/dist/http/routers/danger.js +4 -5
  10. package/dist/http/routers/link.js +2 -2
  11. package/dist/runtime/__tests__/telephonist-tts.test.js +84 -0
  12. package/dist/runtime/adapters/AuditRepositoryAdapter.js +6 -0
  13. package/dist/runtime/adapters/ChannelNotifierAdapter.js +9 -0
  14. package/dist/runtime/adapters/LangChainProviderAdapter.js +9 -0
  15. package/dist/runtime/adapters/SQLiteChatHistoryAdapter.js +15 -0
  16. package/dist/runtime/adapters/SQLiteTaskEnqueuerAdapter.js +6 -0
  17. package/dist/runtime/adapters/index.js +5 -0
  18. package/dist/runtime/audit/repository.js +6 -2
  19. package/dist/runtime/chronos/repository.js +2 -2
  20. package/dist/runtime/container.js +50 -0
  21. package/dist/runtime/hot-reload.js +6 -9
  22. package/dist/runtime/memory/backfill-embeddings.js +2 -3
  23. package/dist/runtime/memory/sati/repository.js +3 -3
  24. package/dist/runtime/memory/sqlite.js +3 -3
  25. package/dist/runtime/memory/trinity-db.js +2 -2
  26. package/dist/runtime/ports/IAuditEmitter.js +1 -0
  27. package/dist/runtime/ports/IChatHistory.js +1 -0
  28. package/dist/runtime/ports/ILLMProviderFactory.js +1 -0
  29. package/dist/runtime/ports/INotifier.js +1 -0
  30. package/dist/runtime/ports/ITaskEnqueuer.js +1 -0
  31. package/dist/runtime/ports/index.js +1 -0
  32. package/dist/runtime/providers/factory.js +8 -52
  33. package/dist/runtime/providers/strategies.js +66 -0
  34. package/dist/runtime/setup/repository.js +2 -2
  35. package/dist/runtime/subagents/apoc.js +2 -2
  36. package/dist/runtime/subagents/link/link.js +2 -2
  37. package/dist/runtime/subagents/link/repository.js +2 -2
  38. package/dist/runtime/subagents/link/worker.js +3 -3
  39. package/dist/runtime/subagents/neo.js +2 -2
  40. package/dist/runtime/subagents/trinity/trinity.js +2 -2
  41. package/dist/runtime/tasks/repository.js +2 -2
  42. package/dist/runtime/telephonist.js +160 -0
  43. package/dist/runtime/tools/delegation-utils.js +5 -7
  44. package/dist/runtime/tools/morpheus-tools.js +6 -7
  45. package/dist/runtime/tools/smith-tool.js +5 -7
  46. package/dist/runtime/webhooks/repository.js +2 -2
  47. package/dist/types/config.js +6 -0
  48. package/dist/ui/assets/AuditDashboard-Cu33zb_7.js +1 -0
  49. package/dist/ui/assets/{Chat-UVoDlqqM.js → Chat-mt1j5V55.js} +1 -1
  50. package/dist/ui/assets/{Chronos-Dfs_pOsc.js → Chronos-Bq_h41cw.js} +1 -1
  51. package/dist/ui/assets/{ConfirmationModal-BBIjVef7.js → ConfirmationModal-CxLP8iC6.js} +1 -1
  52. package/dist/ui/assets/{Dashboard-BdSQDB14.js → Dashboard-D0LAlHtG.js} +1 -1
  53. package/dist/ui/assets/{DeleteConfirmationModal-Du85q5u2.js → DeleteConfirmationModal-kZ_c3sFk.js} +1 -1
  54. package/dist/ui/assets/{Documents-DguILrI8.js → Documents-nlQNoUcq.js} +1 -1
  55. package/dist/ui/assets/{Logs-BDup2FET.js → Logs-C1tlg574.js} +1 -1
  56. package/dist/ui/assets/{MCPManager-WBdh1rum.js → MCPManager-Do7isizG.js} +1 -1
  57. package/dist/ui/assets/ModelPricing-BeJ7oXBA.js +1 -0
  58. package/dist/ui/assets/{Notifications-BslO2Ect.js → Notifications-Cg5CMlY0.js} +1 -1
  59. package/dist/ui/assets/{SatiMemories-DzaLaZ6M.js → SatiMemories-D9l6s8Pc.js} +1 -1
  60. package/dist/ui/assets/SessionAudit-Da1ySlYg.js +9 -0
  61. package/dist/ui/assets/Settings-DpXwpEhO.js +49 -0
  62. package/dist/ui/assets/{Skills-BnDg1HCb.js → Skills-DaqCY8QH.js} +1 -1
  63. package/dist/ui/assets/Smiths-DA-x4KFT.js +1 -0
  64. package/dist/ui/assets/Switch-CJTE4ZQm.js +1 -0
  65. package/dist/ui/assets/{Tasks-BuoNCvI-.js → Tasks-DU49M9U-.js} +1 -1
  66. package/dist/ui/assets/{TrinityDatabases-DYHJunk7.js → TrinityDatabases-CoKzKTL-.js} +1 -1
  67. package/dist/ui/assets/{UsageStats-BpGXaHgW.js → UsageStats-cds352Pj.js} +1 -1
  68. package/dist/ui/assets/{WebhookManager-D2muhYy9.js → WebhookManager-DdAdHQUk.js} +1 -1
  69. package/dist/ui/assets/{agents-CgqJea9n.js → agents-B1z_dlQC.js} +1 -1
  70. package/dist/ui/assets/{audit-Dc3YW0-4.js → audit-BAhaGrKY.js} +1 -1
  71. package/dist/ui/assets/{chronos-CZvGhZQB.js → chronos-DGD_Md9M.js} +1 -1
  72. package/dist/ui/assets/config-BwTXe5M2.js +1 -0
  73. package/dist/ui/assets/{index-Bta9YXEm.js → index-BcX5O7kY.js} +2 -2
  74. package/dist/ui/assets/{mcp-vIffcwd6.js → mcp-BlkruPaA.js} +1 -1
  75. package/dist/ui/assets/{skills-wANsorUj.js → skills-CtCb-52u.js} +1 -1
  76. package/dist/ui/assets/{stats-xnlA4NwX.js → stats-BiPI2kaw.js} +1 -1
  77. package/dist/ui/assets/useCurrency-BCdG-pHx.js +1 -0
  78. package/dist/ui/index.html +1 -1
  79. package/dist/ui/sw.js +1 -1
  80. package/package.json +1 -1
  81. package/dist/ui/assets/AuditDashboard-BVyKnpVm.js +0 -1
  82. package/dist/ui/assets/ModelPricing-BQPw0r6z.js +0 -1
  83. package/dist/ui/assets/SessionAudit-CBDThjBi.js +0 -9
  84. package/dist/ui/assets/Settings-JPTCA7C7.js +0 -49
  85. package/dist/ui/assets/Smiths-DR6g_o3D.js +0 -1
  86. package/dist/ui/assets/config-pKL8Y4V9.js +0 -1
@@ -0,0 +1,49 @@
1
+ import{j as i}from"./vendor-motion-C3CZ8ZlO.js";import{r as I}from"./vendor-react-DikRIOlj.js";import{t as jr,u as ce,Z as Sr,m as ue}from"./vendor-utils-D4NnWbOU.js";import{u as Nr,c as Cr}from"./chronos-DGD_Md9M.js";import{T as k,S as F}from"./SelectInput-KVLsnfra.js";import{N as O,S as te}from"./Switch-CJTE4ZQm.js";import{c as Q}from"./config-BwTXe5M2.js";import{h as He}from"./index-BcX5O7kY.js";import{C as Or}from"./ConfirmationModal-CxLP8iC6.js";import{d as $r,X as Ar,O as Tr}from"./vendor-icons-NHF9HNeN.js";function J({title:e,description:t,children:r}){return i.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:[i.jsxs("div",{className:"mb-4",children:[i.jsx("h3",{className:"text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:e}),t&&i.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mt-1",children:t})]}),i.jsx("div",{className:"space-y-4",children:r})]})}function ut({label:e,error:t,helperText:r,className:n,...a}){return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-secondary",children:e}),i.jsx("textarea",{className:jr("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&&i.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:r}),t&&i.jsx("p",{className:"text-xs text-red-500",children:t})]})}function m(e,t,r){function n(c,d){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:d,constr:o,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,d);const p=o.prototype,f=Object.keys(p);for(let h=0;h<f.length;h++){const u=f[h];u in c||(c[u]=p[u].bind(c))}}const a=r?.Parent??Object;class s extends a{}Object.defineProperty(s,"name",{value:e});function o(c){var d;const p=r?.Parent?new s:this;n(p,c),(d=p._zod).deferred??(d.deferred=[]);for(const f of p._zod.deferred)f();return p}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}class ke extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Et extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const It={};function de(e){return It}function Pt(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 Ye(e,t){return typeof t=="bigint"?t.toString():t}function Le(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function et(e){return e==null}function tt(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Zr(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 d=n.match(/\d?e-(\d?)/);d?.[1]&&(a=Number.parseInt(d[1]))}const s=r>a?r:a,o=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return o%c/10**s}const dt=Symbol("evaluating");function S(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==dt)return n===void 0&&(n=dt,n=r()),n},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function ge(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function pe(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function mt(e){return JSON.stringify(e)}function Er(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Rt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ir=Le(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function we(e){if(Ae(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Ae(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Dt(e){return we(e)?{...e}:Array.isArray(e)?[...e]:e}const Pr=new Set(["string","number","symbol"]);function ze(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fe(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function g(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 Rr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Dr={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 Mr(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 s=pe(e._zod.def,{get shape(){const o={};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(o[c]=r.shape[c])}return ge(this,"shape",o),o},checks:[]});return fe(e,s)}function Ur(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 s=pe(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete o[c]}return ge(this,"shape",o),o},checks:[]});return fe(e,s)}function Lr(e,t){if(!we(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const s=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=pe(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return ge(this,"shape",s),s}});return fe(e,a)}function Fr(e,t){if(!we(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=pe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return ge(this,"shape",n),n}});return fe(e,r)}function Jr(e,t){const r=pe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return ge(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return fe(e,r)}function Br(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 o=pe(t._zod.def,{get shape(){const c=t._zod.def.shape,d={...c};if(r)for(const p in r){if(!(p in c))throw new Error(`Unrecognized key: "${p}"`);r[p]&&(d[p]=e?new e({type:"optional",innerType:c[p]}):c[p])}else for(const p in c)d[p]=e?new e({type:"optional",innerType:c[p]}):c[p];return ge(this,"shape",d),d},checks:[]});return fe(t,o)}function Kr(e,t,r){const n=pe(t._zod.def,{get shape(){const a=t._zod.def.shape,s={...a};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)s[o]=new e({type:"nonoptional",innerType:a[o]});return ge(this,"shape",s),s}});return fe(t,n)}function ye(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 _e(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ee(e){return typeof e=="string"?e:e?.message}function me(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const a=Ee(e.inst?._zod.def?.error?.(e))??Ee(t?.error?.(e))??Ee(r.customError?.(e))??Ee(r.localeError?.(e))??"Invalid input";n.message=a}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function rt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Te(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Mt=(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,Ye,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ut=m("$ZodError",Mt),Lt=m("$ZodError",Mt,{Parent:Error});function Vr(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 Wr(e,t=r=>r.message){const r={_errors:[]},n=a=>{for(const s of a.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>n({issues:o}));else if(s.code==="invalid_key")n({issues:s.issues});else if(s.code==="invalid_element")n({issues:s.issues});else if(s.path.length===0)r._errors.push(t(s));else{let o=r,c=0;for(;c<s.path.length;){const d=s.path[c];c===s.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(t(s))):o[d]=o[d]||{_errors:[]},o=o[d],c++}}};return n(e),r}const nt=e=>(t,r,n,a)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new ke;if(o.issues.length){const c=new(a?.Err??e)(o.issues.map(d=>me(d,s,de())));throw Rt(c,a?.callee),c}return o.value},at=e=>async(t,r,n,a)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const c=new(a?.Err??e)(o.issues.map(d=>me(d,s,de())));throw Rt(c,a?.callee),c}return o.value},Fe=e=>(t,r,n)=>{const a=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},a);if(s instanceof Promise)throw new ke;return s.issues.length?{success:!1,error:new(e??Ut)(s.issues.map(o=>me(o,a,de())))}:{success:!0,data:s.value}},Gr=Fe(Lt),Je=e=>async(t,r,n)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:r,issues:[]},a);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(o=>me(o,a,de())))}:{success:!0,data:s.value}},qr=Je(Lt),Hr=e=>(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return nt(e)(t,r,a)},Yr=e=>(t,r,n)=>nt(e)(t,r,n),Xr=e=>async(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return at(e)(t,r,a)},Qr=e=>async(t,r,n)=>at(e)(t,r,n),en=e=>(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Fe(e)(t,r,a)},tn=e=>(t,r,n)=>Fe(e)(t,r,n),rn=e=>async(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Je(e)(t,r,a)},nn=e=>async(t,r,n)=>Je(e)(t,r,n),an=/^[cC][^\s-]{8,}$/,on=/^[0-9a-z]+$/,sn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ln=/^[0-9a-vA-V]{20}$/,cn=/^[A-Za-z0-9]{27}$/,un=/^[a-zA-Z0-9_-]{21}$/,dn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,mn=/^([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})$/,pt=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)$/,pn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,fn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function hn(){return new RegExp(fn,"u")}const gn=/^(?:(?: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])$/,bn=/^(([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}|:))$/,vn=/^((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])$/,xn=/^(([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])$/,yn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ft=/^[A-Za-z0-9_-]*$/,_n=/^\+[1-9]\d{6,14}$/,Jt="(?:(?:\\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])))",kn=new RegExp(`^${Jt}$`);function Bt(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 wn(e){return new RegExp(`^${Bt(e)}$`)}function zn(e){const t=Bt({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(`^${Jt}T(?:${n})$`)}const jn=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Sn=/^-?\d+$/,Kt=/^-?\d+(?:\.\d+)?$/,Nn=/^(?:true|false)$/i,Cn=/^[^A-Z]*$/,On=/^[^a-z]*$/,H=m("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Vt={number:"number",bigint:"bigint",object:"date"},Wt=m("$ZodCheckLessThan",(e,t)=>{H.init(e,t);const r=Vt[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,s=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(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})}}),Gt=m("$ZodCheckGreaterThan",(e,t)=>{H.init(e,t);const r=Vt[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,s=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(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})}}),$n=m("$ZodCheckMultipleOf",(e,t)=>{H.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):Zr(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})}}),An=m("$ZodCheckNumberFormat",(e,t)=>{H.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[a,s]=Dr[t.format];e._zod.onattach.push(o=>{const c=o._zod.bag;c.format=t.format,c.minimum=a,c.maximum=s,r&&(c.pattern=Sn)}),e._zod.check=o=>{const c=o.value;if(r){if(!Number.isInteger(c)){o.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?o.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}):o.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&&o.issues.push({origin:"number",input:c,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!t.abort}),c>s&&o.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Tn=m("$ZodCheckMaxLength",(e,t)=>{var r;H.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!et(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 o=rt(a);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Zn=m("$ZodCheckMinLength",(e,t)=>{var r;H.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!et(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 o=rt(a);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),En=m("$ZodCheckLengthEquals",(e,t)=>{var r;H.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!et(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,s=a.length;if(s===t.length)return;const o=rt(a),c=s>t.length;n.issues.push({origin:o,...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})}}),Be=m("$ZodCheckStringFormat",(e,t)=>{var r,n;H.init(e,t),e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.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=()=>{})}),In=m("$ZodCheckRegex",(e,t)=>{Be.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})}}),Pn=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Cn),Be.init(e,t)}),Rn=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=On),Be.init(e,t)}),Dn=m("$ZodCheckIncludes",(e,t)=>{H.init(e,t);const r=ze(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(a=>{const s=a._zod.bag;s.patterns??(s.patterns=new Set),s.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})}}),Mn=m("$ZodCheckStartsWith",(e,t)=>{H.init(e,t);const r=new RegExp(`^${ze(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})}}),Un=m("$ZodCheckEndsWith",(e,t)=>{H.init(e,t);const r=new RegExp(`.*${ze(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})}}),Ln=m("$ZodCheckOverwrite",(e,t)=>{H.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Fn{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
+ `).filter(o=>o),a=Math.min(...n.map(o=>o.length-o.trimStart().length)),s=n.map(o=>o.slice(a)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const t=Function,r=this?.args,a=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...r,a.join(`
3
+ `))}}const Jn={major:4,minor:3,patch:6},P=m("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Jn;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const a of n)for(const s of a._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const a=(o,c,d)=>{let p=ye(o),f;for(const h of c){if(h._zod.def.when){if(!h._zod.def.when(o))continue}else if(p)continue;const u=o.issues.length,b=h._zod.check(o);if(b instanceof Promise&&d?.async===!1)throw new ke;if(f||b instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await b,o.issues.length!==u&&(p||(p=ye(o,u)))});else{if(o.issues.length===u)continue;p||(p=ye(o,u))}}return f?f.then(()=>o):o},s=(o,c,d)=>{if(ye(o))return o.aborted=!0,o;const p=a(c,n,d);if(p instanceof Promise){if(d.async===!1)throw new ke;return p.then(f=>e._zod.parse(f,d))}return e._zod.parse(p,d)};e._zod.run=(o,c)=>{if(c.skipChecks)return e._zod.parse(o,c);if(c.direction==="backward"){const p=e._zod.parse({value:o.value,issues:[]},{...c,skipChecks:!0});return p instanceof Promise?p.then(f=>s(f,o,c)):s(p,o,c)}const d=e._zod.parse(o,c);if(d instanceof Promise){if(c.async===!1)throw new ke;return d.then(p=>a(p,n,c))}return a(d,n,c)}}S(e,"~standard",()=>({validate:a=>{try{const s=Gr(e,a);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return qr(e,a).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}))}),ot=m("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??jn(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}}),Z=m("$ZodStringFormat",(e,t)=>{Be.init(e,t),ot.init(e,t)}),Bn=m("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=mn),Z.init(e,t)}),Kn=m("$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=pt(n))}else t.pattern??(t.pattern=pt());Z.init(e,t)}),Vn=m("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=pn),Z.init(e,t)}),Wn=m("$ZodURL",(e,t)=>{Z.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})}}}),Gn=m("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=hn()),Z.init(e,t)}),qn=m("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=un),Z.init(e,t)}),Hn=m("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=an),Z.init(e,t)}),Yn=m("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=on),Z.init(e,t)}),Xn=m("$ZodULID",(e,t)=>{t.pattern??(t.pattern=sn),Z.init(e,t)}),Qn=m("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ln),Z.init(e,t)}),ea=m("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=cn),Z.init(e,t)}),ta=m("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=zn(t)),Z.init(e,t)}),ra=m("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=kn),Z.init(e,t)}),na=m("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=wn(t)),Z.init(e,t)}),aa=m("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=dn),Z.init(e,t)}),oa=m("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=gn),Z.init(e,t),e._zod.bag.format="ipv4"}),ia=m("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=bn),Z.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})}}}),sa=m("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=vn),Z.init(e,t)}),la=m("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=xn),Z.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[a,s]=n;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>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 qt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ca=m("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=yn),Z.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{qt(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function ua(e){if(!Ft.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return qt(r)}const da=m("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ft),Z.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{ua(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ma=m("$ZodE164",(e,t)=>{t.pattern??(t.pattern=_n),Z.init(e,t)});function pa(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 fa=m("$ZodJWT",(e,t)=>{Z.init(e,t),e._zod.check=r=>{pa(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Ht=m("$ZodNumber",(e,t)=>{P.init(e,t),e._zod.pattern=e._zod.bag.pattern??Kt,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 s=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,...s?{received:s}:{}}),r}}),ha=m("$ZodNumberFormat",(e,t)=>{An.init(e,t),Ht.init(e,t)}),ga=m("$ZodBoolean",(e,t)=>{P.init(e,t),e._zod.pattern=Nn,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}}),ba=m("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=r=>r}),va=m("$ZodNever",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function ft(e,t,r){e.issues.length&&t.issues.push(..._e(r,e.issues)),t.value[r]=e.value}const xa=m("$ZodArray",(e,t)=>{P.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 s=[];for(let o=0;o<a.length;o++){const c=a[o],d=t.element._zod.run({value:c,issues:[]},n);d instanceof Promise?s.push(d.then(p=>ft(p,r,o))):ft(d,r,o)}return s.length?Promise.all(s).then(()=>r):r}});function De(e,t,r,n,a){if(e.issues.length){if(a&&!(r in n))return;t.issues.push(..._e(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Yt(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=Rr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Xt(e,t,r,n,a,s){const o=[],c=a.keySet,d=a.catchall._zod,p=d.def.type,f=d.optout==="optional";for(const h in t){if(c.has(h))continue;if(p==="never"){o.push(h);continue}const u=d.run({value:t[h],issues:[]},n);u instanceof Promise?e.push(u.then(b=>De(b,r,h,t,f))):De(u,r,h,t,f)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}const ya=m("$ZodObject",(e,t)=>{if(P.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...c};return Object.defineProperty(t,"shape",{value:d}),d}})}const n=Le(()=>Yt(t));S(e._zod,"propValues",()=>{const c=t.shape,d={};for(const p in c){const f=c[p]._zod;if(f.values){d[p]??(d[p]=new Set);for(const h of f.values)d[p].add(h)}}return d});const a=Ae,s=t.catchall;let o;e._zod.parse=(c,d)=>{o??(o=n.value);const p=c.value;if(!a(p))return c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c;c.value={};const f=[],h=o.shape;for(const u of o.keys){const b=h[u],y=b._zod.optout==="optional",U=b._zod.run({value:p[u],issues:[]},d);U instanceof Promise?f.push(U.then(N=>De(N,c,u,p,y))):De(U,c,u,p,y)}return s?Xt(f,p,c,d,n.value,e):f.length?Promise.all(f).then(()=>c):c}}),_a=m("$ZodObjectJIT",(e,t)=>{ya.init(e,t);const r=e._zod.parse,n=Le(()=>Yt(t)),a=u=>{const b=new Fn(["shape","payload","ctx"]),y=n.value,U=V=>{const w=mt(V);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};b.write("const input = payload.value;");const N=Object.create(null);let be=0;for(const V of y.keys)N[V]=`key_${be++}`;b.write("const newResult = {};");for(const V of y.keys){const w=N[V],K=mt(V),Ne=u[V]?._zod?.optout==="optional";b.write(`const ${w} = ${U(V)};`),Ne?b.write(`
4
+ if (${w}.issues.length) {
5
+ if (${K} in input) {
6
+ payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
7
+ ...iss,
8
+ path: iss.path ? [${K}, ...iss.path] : [${K}]
9
+ })));
10
+ }
11
+ }
12
+
13
+ if (${w}.value === undefined) {
14
+ if (${K} in input) {
15
+ newResult[${K}] = undefined;
16
+ }
17
+ } else {
18
+ newResult[${K}] = ${w}.value;
19
+ }
20
+
21
+ `):b.write(`
22
+ if (${w}.issues.length) {
23
+ payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
24
+ ...iss,
25
+ path: iss.path ? [${K}, ...iss.path] : [${K}]
26
+ })));
27
+ }
28
+
29
+ if (${w}.value === undefined) {
30
+ if (${K} in input) {
31
+ newResult[${K}] = undefined;
32
+ }
33
+ } else {
34
+ newResult[${K}] = ${w}.value;
35
+ }
36
+
37
+ `)}b.write("payload.value = newResult;"),b.write("return payload;");const E=b.compile();return(V,w)=>E(u,V,w)};let s;const o=Ae,c=!It.jitless,p=c&&Ir.value,f=t.catchall;let h;e._zod.parse=(u,b)=>{h??(h=n.value);const y=u.value;return o(y)?c&&p&&b?.async===!1&&b.jitless!==!0?(s||(s=a(t.shape)),u=s(u,b),f?Xt([],y,u,b,h,e):u):r(u,b):(u.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),u)}});function ht(e,t,r,n){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const a=e.filter(s=>!ye(s));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(s=>s.issues.map(o=>me(o,n,de())))}),t)}const Qt=m("$ZodUnion",(e,t)=>{P.init(e,t),S(e._zod,"optin",()=>t.options.some(a=>a._zod.optin==="optional")?"optional":void 0),S(e._zod,"optout",()=>t.options.some(a=>a._zod.optout==="optional")?"optional":void 0),S(e._zod,"values",()=>{if(t.options.every(a=>a._zod.values))return new Set(t.options.flatMap(a=>Array.from(a._zod.values)))}),S(e._zod,"pattern",()=>{if(t.options.every(a=>a._zod.pattern)){const a=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${a.map(s=>tt(s.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(a,s)=>{if(r)return n(a,s);let o=!1;const c=[];for(const d of t.options){const p=d._zod.run({value:a.value,issues:[]},s);if(p instanceof Promise)c.push(p),o=!0;else{if(p.issues.length===0)return p;c.push(p)}}return o?Promise.all(c).then(d=>ht(d,a,e,s)):ht(c,a,e,s)}}),ka=m("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Qt.init(e,t);const r=e._zod.parse;S(e._zod,"propValues",()=>{const a={};for(const s of t.options){const o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[c,d]of Object.entries(o)){a[c]||(a[c]=new Set);for(const p of d)a[c].add(p)}}return a});const n=Le(()=>{const a=t.options,s=new Map;for(const o of a){const c=o._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const d of c){if(s.has(d))throw new Error(`Duplicate discriminator value "${String(d)}"`);s.set(d,o)}}return s});e._zod.parse=(a,s)=>{const o=a.value;if(!Ae(o))return a.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),a;const c=n.value.get(o?.[t.discriminator]);return c?c._zod.run(a,s):t.unionFallback?r(a,s):(a.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),a)}}),wa=m("$ZodIntersection",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{const a=r.value,s=t.left._zod.run({value:a,issues:[]},n),o=t.right._zod.run({value:a,issues:[]},n);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([d,p])=>gt(r,d,p)):gt(r,s,o)}});function Xe(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(we(e)&&we(t)){const r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),a={...e,...t};for(const s of n){const o=Xe(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};a[s]=o.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],s=t[n],o=Xe(a,s);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function gt(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 d of c.keys)n.has(d)||n.set(d,{}),n.get(d).l=!0}else e.issues.push(c);for(const c of r.issues)if(c.code==="unrecognized_keys")for(const d of c.keys)n.has(d)||n.set(d,{}),n.get(d).r=!0;else e.issues.push(c);const s=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(s.length&&a&&e.issues.push({...a,keys:s}),ye(e))return e;const o=Xe(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const za=m("$ZodRecord",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{const a=r.value;if(!we(a))return r.issues.push({expected:"record",code:"invalid_type",input:a,inst:e}),r;const s=[],o=t.keyType._zod.values;if(o){r.value={};const c=new Set;for(const p of o)if(typeof p=="string"||typeof p=="number"||typeof p=="symbol"){c.add(typeof p=="number"?p.toString():p);const f=t.valueType._zod.run({value:a[p],issues:[]},n);f instanceof Promise?s.push(f.then(h=>{h.issues.length&&r.issues.push(..._e(p,h.issues)),r.value[p]=h.value})):(f.issues.length&&r.issues.push(..._e(p,f.issues)),r.value[p]=f.value)}let d;for(const p in a)c.has(p)||(d=d??[],d.push(p));d&&d.length>0&&r.issues.push({code:"unrecognized_keys",input:a,inst:e,keys:d})}else{r.value={};for(const c of Reflect.ownKeys(a)){if(c==="__proto__")continue;let d=t.keyType._zod.run({value:c,issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&Kt.test(c)&&d.issues.length){const h=t.keyType._zod.run({value:Number(c),issues:[]},n);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(d=h)}if(d.issues.length){t.mode==="loose"?r.value[c]=a[c]:r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>me(h,n,de())),input:c,path:[c],inst:e});continue}const f=t.valueType._zod.run({value:a[c],issues:[]},n);f instanceof Promise?s.push(f.then(h=>{h.issues.length&&r.issues.push(..._e(c,h.issues)),r.value[d.value]=h.value})):(f.issues.length&&r.issues.push(..._e(c,f.issues)),r.value[d.value]=f.value)}}return s.length?Promise.all(s).then(()=>r):r}}),ja=m("$ZodEnum",(e,t)=>{P.init(e,t);const r=Pt(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(a=>Pr.has(typeof a)).map(a=>typeof a=="string"?ze(a):a.toString()).join("|")})$`),e._zod.parse=(a,s)=>{const o=a.value;return n.has(o)||a.issues.push({code:"invalid_value",values:r,input:o,inst:e}),a}}),Sa=m("$ZodLiteral",(e,t)=>{if(P.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"?ze(n):n?ze(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,a)=>{const s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}}),Na=m("$ZodTransform",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Et(e.constructor.name);const a=t.transform(r.value,r);if(n.async)return(a instanceof Promise?a:Promise.resolve(a)).then(o=>(r.value=o,r));if(a instanceof Promise)throw new ke;return r.value=a,r}});function bt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const er=m("$ZodOptional",(e,t)=>{P.init(e,t),e._zod.optin="optional",e._zod.optout="optional",S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${tt(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(s=>bt(s,r.value)):bt(a,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Ca=m("$ZodExactOptional",(e,t)=>{er.init(e,t),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Oa=m("$ZodNullable",(e,t)=>{P.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${tt(r.source)}|null)$`):void 0}),S(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)}),$a=m("$ZodDefault",(e,t)=>{P.init(e,t),e._zod.optin="optional",S(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(s=>vt(s,t)):vt(a,t)}});function vt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Aa=m("$ZodPrefault",(e,t)=>{P.init(e,t),e._zod.optin="optional",S(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))}),Ta=m("$ZodNonOptional",(e,t)=>{P.init(e,t),S(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(s=>xt(s,e)):xt(a,e)}});function xt(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 Za=m("$ZodCatch",(e,t)=>{P.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(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(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>me(o,n,de()))},input:r.value}),r.issues=[]),r)):(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(s=>me(s,n,de()))},input:r.value}),r.issues=[]),r)}}),Ea=m("$ZodPipe",(e,t)=>{P.init(e,t),S(e._zod,"values",()=>t.in._zod.values),S(e._zod,"optin",()=>t.in._zod.optin),S(e._zod,"optout",()=>t.out._zod.optout),S(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const s=t.out._zod.run(r,n);return s instanceof Promise?s.then(o=>Ie(o,t.in,n)):Ie(s,t.in,n)}const a=t.in._zod.run(r,n);return a instanceof Promise?a.then(s=>Ie(s,t.out,n)):Ie(a,t.out,n)}});function Ie(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const Ia=m("$ZodReadonly",(e,t)=>{P.init(e,t),S(e._zod,"propValues",()=>t.innerType._zod.propValues),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"optin",()=>t.innerType?._zod?.optin),S(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(yt):yt(a)}});function yt(e){return e.value=Object.freeze(e.value),e}const Pa=m("$ZodCustom",(e,t)=>{H.init(e,t),P.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(s=>_t(s,r,n,e));_t(a,r,n,e)}});function _t(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(Te(a))}}var kt;class Ra{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 Da(){return new Ra}(kt=globalThis).__zod_globalRegistry??(kt.__zod_globalRegistry=Da());const $e=globalThis.__zod_globalRegistry;function Ma(e,t){return new e({type:"string",...g(t)})}function Ua(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function wt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function La(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function Fa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function Ja(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function Ba(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function Ka(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function Va(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function Wa(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function Ga(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function qa(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function Ha(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function Ya(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function Xa(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function Qa(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function eo(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function to(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function ro(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function no(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function ao(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function oo(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function io(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function so(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function lo(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function co(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function uo(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function mo(e,t){return new e({type:"number",checks:[],...g(t)})}function po(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function fo(e,t){return new e({type:"boolean",...g(t)})}function ho(e){return new e({type:"unknown"})}function go(e,t){return new e({type:"never",...g(t)})}function zt(e,t){return new Wt({check:"less_than",...g(t),value:e,inclusive:!1})}function Ge(e,t){return new Wt({check:"less_than",...g(t),value:e,inclusive:!0})}function jt(e,t){return new Gt({check:"greater_than",...g(t),value:e,inclusive:!1})}function qe(e,t){return new Gt({check:"greater_than",...g(t),value:e,inclusive:!0})}function St(e,t){return new $n({check:"multiple_of",...g(t),value:e})}function tr(e,t){return new Tn({check:"max_length",...g(t),maximum:e})}function Me(e,t){return new Zn({check:"min_length",...g(t),minimum:e})}function rr(e,t){return new En({check:"length_equals",...g(t),length:e})}function bo(e,t){return new In({check:"string_format",format:"regex",...g(t),pattern:e})}function vo(e){return new Pn({check:"string_format",format:"lowercase",...g(e)})}function xo(e){return new Rn({check:"string_format",format:"uppercase",...g(e)})}function yo(e,t){return new Dn({check:"string_format",format:"includes",...g(t),includes:e})}function _o(e,t){return new Mn({check:"string_format",format:"starts_with",...g(t),prefix:e})}function ko(e,t){return new Un({check:"string_format",format:"ends_with",...g(t),suffix:e})}function je(e){return new Ln({check:"overwrite",tx:e})}function wo(e){return je(t=>t.normalize(e))}function zo(){return je(e=>e.trim())}function jo(){return je(e=>e.toLowerCase())}function So(){return je(e=>e.toUpperCase())}function No(){return je(e=>Er(e))}function Co(e,t,r){return new e({type:"array",element:t,...g(r)})}function Oo(e,t,r){return new e({type:"custom",check:"custom",fn:t,...g(r)})}function $o(e){const t=Ao(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Te(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(Te(a))}},e(r.value,r)));return t}function Ao(e,t){const r=new H({check:"custom",...g(t)});return r._zod.check=e,r}function nr(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??$e,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 L(e,t,r={path:[],schemaPath:[]}){var n;const a=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);const c=e._zod.toJSONSchema?.();if(c)o.schema=c;else{const f={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,f);else{const u=o.schema,b=t.processors[a.type];if(!b)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);b(e,t,u,f)}const h=e._zod.parent;h&&(o.ref||(o.ref=h),L(h,t,f),t.seen.get(h).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&Object.assign(o.schema,d),t.io==="input"&&G(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ar(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 o of e.seen.entries()){const c=e.metadataRegistry.get(o[0])?.id;if(c){const d=n.get(c);if(d&&d!==o[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,o[0])}}const a=o=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const h=e.external.registry.get(o[0])?.id,u=e.external.uri??(y=>y);if(h)return{ref:u(h)};const b=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=b,{defId:b,ref:`${u("__shared")}#/${c}/${b}`}}if(o[1]===r)return{ref:"#"};const p=`#/${c}/`,f=o[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:p+f}},s=o=>{if(o[1].schema.$ref)return;const c=o[1],{ref:d,defId:p}=a(o);c.def={...c.schema},p&&(c.defId=p);const f=c.schema;for(const h in f)delete f[h];f.$ref=d};if(e.cycles==="throw")for(const o of e.seen.entries()){const c=o[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
38
+
39
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const o of e.seen.entries()){const c=o[1];if(t===o[0]){s(o);continue}if(e.external){const p=e.external.registry.get(o[0])?.id;if(t!==o[0]&&p){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(c.cycle){s(o);continue}if(c.count>1&&e.reused==="ref"){s(o);continue}}}function or(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=o=>{const c=e.seen.get(o);if(c.ref===null)return;const d=c.def??c.schema,p={...d},f=c.ref;if(c.ref=null,f){n(f);const u=e.seen.get(f),b=u.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(b)):Object.assign(d,b),Object.assign(d,p),o._zod.parent===f)for(const U in d)U==="$ref"||U==="allOf"||U in p||delete d[U];if(b.$ref&&u.def)for(const U in d)U==="$ref"||U==="allOf"||U in u.def&&JSON.stringify(d[U])===JSON.stringify(u.def[U])&&delete d[U]}const h=o._zod.parent;if(h&&h!==f){n(h);const u=e.seen.get(h);if(u?.schema.$ref&&(d.$ref=u.schema.$ref,u.def))for(const b in d)b==="$ref"||b==="allOf"||b in u.def&&JSON.stringify(d[b])===JSON.stringify(u.def[b])&&delete d[b]}e.override({zodSchema:o,jsonSchema:d,path:c.path??[]})};for(const o of[...e.seen.entries()].reverse())n(o[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 o=e.external.registry.get(t)?.id;if(!o)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(o)}Object.assign(a,r.def??r.schema);const s=e.external?.defs??{};for(const o of e.seen.entries()){const c=o[1];c.def&&c.defId&&(s[c.defId]=c.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?a.$defs=s:a.definitions=s);try{const o=JSON.parse(JSON.stringify(a));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ue(t,"input",e.processors),output:Ue(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch{throw new Error("Error converting schema to JSON.")}}function G(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 G(n.element,r);if(n.type==="set")return G(n.valueType,r);if(n.type==="lazy")return G(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 G(n.innerType,r);if(n.type==="intersection")return G(n.left,r)||G(n.right,r);if(n.type==="record"||n.type==="map")return G(n.keyType,r)||G(n.valueType,r);if(n.type==="pipe")return G(n.in,r)||G(n.out,r);if(n.type==="object"){for(const a in n.shape)if(G(n.shape[a],r))return!0;return!1}if(n.type==="union"){for(const a of n.options)if(G(a,r))return!0;return!1}if(n.type==="tuple"){for(const a of n.items)if(G(a,r))return!0;return!!(n.rest&&G(n.rest,r))}return!1}const To=(e,t={})=>r=>{const n=nr({...r,processors:t});return L(e,n),ar(n,e),or(n,e)},Ue=(e,t,r={})=>n=>{const{libraryOptions:a,target:s}=n??{},o=nr({...a??{},target:s,io:t,processors:r});return L(e,o),ar(o,e),or(o,e)},Zo={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Eo=(e,t,r,n)=>{const a=r;a.type="string";const{minimum:s,maximum:o,format:c,patterns:d,contentEncoding:p}=e._zod.bag;if(typeof s=="number"&&(a.minLength=s),typeof o=="number"&&(a.maxLength=o),c&&(a.format=Zo[c]??c,a.format===""&&delete a.format,c==="time"&&delete a.format),p&&(a.contentEncoding=p),d&&d.size>0){const f=[...d];f.length===1?a.pattern=f[0].source:f.length>1&&(a.allOf=[...f.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Io=(e,t,r,n)=>{const a=r,{minimum:s,maximum:o,format:c,multipleOf:d,exclusiveMaximum:p,exclusiveMinimum:f}=e._zod.bag;typeof c=="string"&&c.includes("int")?a.type="integer":a.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(a.minimum=f,a.exclusiveMinimum=!0):a.exclusiveMinimum=f),typeof s=="number"&&(a.minimum=s,typeof f=="number"&&t.target!=="draft-04"&&(f>=s?delete a.minimum:delete a.exclusiveMinimum)),typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(a.maximum=p,a.exclusiveMaximum=!0):a.exclusiveMaximum=p),typeof o=="number"&&(a.maximum=o,typeof p=="number"&&t.target!=="draft-04"&&(p<=o?delete a.maximum:delete a.exclusiveMaximum)),typeof d=="number"&&(a.multipleOf=d)},Po=(e,t,r,n)=>{r.type="boolean"},Ro=(e,t,r,n)=>{r.not={}},Do=(e,t,r,n)=>{},Mo=(e,t,r,n)=>{const a=e._zod.def,s=Pt(a.entries);s.every(o=>typeof o=="number")&&(r.type="number"),s.every(o=>typeof o=="string")&&(r.type="string"),r.enum=s},Uo=(e,t,r,n)=>{const a=e._zod.def,s=[];for(const o of a.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else s.every(o=>typeof o=="number")&&(r.type="number"),s.every(o=>typeof o=="string")&&(r.type="string"),s.every(o=>typeof o=="boolean")&&(r.type="boolean"),s.every(o=>o===null)&&(r.type="null"),r.enum=s},Lo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Fo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Jo=(e,t,r,n)=>{const a=r,s=e._zod.def,{minimum:o,maximum:c}=e._zod.bag;typeof o=="number"&&(a.minItems=o),typeof c=="number"&&(a.maxItems=c),a.type="array",a.items=L(s.element,t,{...n,path:[...n.path,"items"]})},Bo=(e,t,r,n)=>{const a=r,s=e._zod.def;a.type="object",a.properties={};const o=s.shape;for(const p in o)a.properties[p]=L(o[p],t,{...n,path:[...n.path,"properties",p]});const c=new Set(Object.keys(o)),d=new Set([...c].filter(p=>{const f=s.shape[p]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));d.size>0&&(a.required=Array.from(d)),s.catchall?._zod.def.type==="never"?a.additionalProperties=!1:s.catchall?s.catchall&&(a.additionalProperties=L(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},Ko=(e,t,r,n)=>{const a=e._zod.def,s=a.inclusive===!1,o=a.options.map((c,d)=>L(c,t,{...n,path:[...n.path,s?"oneOf":"anyOf",d]}));s?r.oneOf=o:r.anyOf=o},Vo=(e,t,r,n)=>{const a=e._zod.def,s=L(a.left,t,{...n,path:[...n.path,"allOf",0]}),o=L(a.right,t,{...n,path:[...n.path,"allOf",1]}),c=p=>"allOf"in p&&Object.keys(p).length===1,d=[...c(s)?s.allOf:[s],...c(o)?o.allOf:[o]];r.allOf=d},Wo=(e,t,r,n)=>{const a=r,s=e._zod.def;a.type="object";const o=s.keyType,d=o._zod.bag?.patterns;if(s.mode==="loose"&&d&&d.size>0){const f=L(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});a.patternProperties={};for(const h of d)a.patternProperties[h.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(a.propertyNames=L(s.keyType,t,{...n,path:[...n.path,"propertyNames"]})),a.additionalProperties=L(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const p=o._zod.values;if(p){const f=[...p].filter(h=>typeof h=="string"||typeof h=="number");f.length>0&&(a.required=f)}},Go=(e,t,r,n)=>{const a=e._zod.def,s=L(a.innerType,t,n),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=a.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},qo=(e,t,r,n)=>{const a=e._zod.def;L(a.innerType,t,n);const s=t.seen.get(e);s.ref=a.innerType},Ho=(e,t,r,n)=>{const a=e._zod.def;L(a.innerType,t,n);const s=t.seen.get(e);s.ref=a.innerType,r.default=JSON.parse(JSON.stringify(a.defaultValue))},Yo=(e,t,r,n)=>{const a=e._zod.def;L(a.innerType,t,n);const s=t.seen.get(e);s.ref=a.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},Xo=(e,t,r,n)=>{const a=e._zod.def;L(a.innerType,t,n);const s=t.seen.get(e);s.ref=a.innerType;let o;try{o=a.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},Qo=(e,t,r,n)=>{const a=e._zod.def,s=t.io==="input"?a.in._zod.def.type==="transform"?a.out:a.in:a.out;L(s,t,n);const o=t.seen.get(e);o.ref=s},ei=(e,t,r,n)=>{const a=e._zod.def;L(a.innerType,t,n);const s=t.seen.get(e);s.ref=a.innerType,r.readOnly=!0},ir=(e,t,r,n)=>{const a=e._zod.def;L(a.innerType,t,n);const s=t.seen.get(e);s.ref=a.innerType},ti=m("ZodISODateTime",(e,t)=>{ta.init(e,t),D.init(e,t)});function ri(e){return so(ti,e)}const ni=m("ZodISODate",(e,t)=>{ra.init(e,t),D.init(e,t)});function ai(e){return lo(ni,e)}const oi=m("ZodISOTime",(e,t)=>{na.init(e,t),D.init(e,t)});function ii(e){return co(oi,e)}const si=m("ZodISODuration",(e,t)=>{aa.init(e,t),D.init(e,t)});function li(e){return uo(si,e)}const ci=(e,t)=>{Ut.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Wr(e,r)},flatten:{value:r=>Vr(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Ye,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Ye,2)}},isEmpty:{get(){return e.issues.length===0}}})},ee=m("ZodError",ci,{Parent:Error}),ui=nt(ee),di=at(ee),mi=Fe(ee),pi=Je(ee),fi=Hr(ee),hi=Yr(ee),gi=Xr(ee),bi=Qr(ee),vi=en(ee),xi=tn(ee),yi=rn(ee),_i=nn(ee),R=m("ZodType",(e,t)=>(P.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ue(e,"input"),output:Ue(e,"output")}}),e.toJSONSchema=To(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(pe(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)=>fe(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>ui(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>mi(e,r,n),e.parseAsync=async(r,n)=>di(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>pi(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>fi(e,r,n),e.decode=(r,n)=>hi(e,r,n),e.encodeAsync=async(r,n)=>gi(e,r,n),e.decodeAsync=async(r,n)=>bi(e,r,n),e.safeEncode=(r,n)=>vi(e,r,n),e.safeDecode=(r,n)=>xi(e,r,n),e.safeEncodeAsync=async(r,n)=>yi(e,r,n),e.safeDecodeAsync=async(r,n)=>_i(e,r,n),e.refine=(r,n)=>e.check(hs(r,n)),e.superRefine=r=>e.check(gs(r)),e.overwrite=r=>e.check(je(r)),e.optional=()=>At(e),e.exactOptional=()=>rs(e),e.nullable=()=>Tt(e),e.nullish=()=>At(Tt(e)),e.nonoptional=r=>ls(e,r),e.array=()=>ne(e),e.or=r=>ur([e,r]),e.and=r=>Hi(e,r),e.transform=r=>Zt(e,es(r)),e.default=r=>os(e,r),e.prefault=r=>ss(e,r),e.catch=r=>us(e,r),e.pipe=r=>Zt(e,r),e.readonly=()=>ps(e),e.describe=r=>{const n=e.clone();return $e.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return $e.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return $e.get(e);const n=e.clone();return $e.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),sr=m("_ZodString",(e,t)=>{ot.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,a,s)=>Eo(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(bo(...n)),e.includes=(...n)=>e.check(yo(...n)),e.startsWith=(...n)=>e.check(_o(...n)),e.endsWith=(...n)=>e.check(ko(...n)),e.min=(...n)=>e.check(Me(...n)),e.max=(...n)=>e.check(tr(...n)),e.length=(...n)=>e.check(rr(...n)),e.nonempty=(...n)=>e.check(Me(1,...n)),e.lowercase=n=>e.check(vo(n)),e.uppercase=n=>e.check(xo(n)),e.trim=()=>e.check(zo()),e.normalize=(...n)=>e.check(wo(...n)),e.toLowerCase=()=>e.check(jo()),e.toUpperCase=()=>e.check(So()),e.slugify=()=>e.check(No())}),ki=m("ZodString",(e,t)=>{ot.init(e,t),sr.init(e,t),e.email=r=>e.check(Ua(wi,r)),e.url=r=>e.check(Ka(zi,r)),e.jwt=r=>e.check(io(Mi,r)),e.emoji=r=>e.check(Va(ji,r)),e.guid=r=>e.check(wt(Nt,r)),e.uuid=r=>e.check(La(Pe,r)),e.uuidv4=r=>e.check(Fa(Pe,r)),e.uuidv6=r=>e.check(Ja(Pe,r)),e.uuidv7=r=>e.check(Ba(Pe,r)),e.nanoid=r=>e.check(Wa(Si,r)),e.guid=r=>e.check(wt(Nt,r)),e.cuid=r=>e.check(Ga(Ni,r)),e.cuid2=r=>e.check(qa(Ci,r)),e.ulid=r=>e.check(Ha(Oi,r)),e.base64=r=>e.check(no(Pi,r)),e.base64url=r=>e.check(ao(Ri,r)),e.xid=r=>e.check(Ya($i,r)),e.ksuid=r=>e.check(Xa(Ai,r)),e.ipv4=r=>e.check(Qa(Ti,r)),e.ipv6=r=>e.check(eo(Zi,r)),e.cidrv4=r=>e.check(to(Ei,r)),e.cidrv6=r=>e.check(ro(Ii,r)),e.e164=r=>e.check(oo(Di,r)),e.datetime=r=>e.check(ri(r)),e.date=r=>e.check(ai(r)),e.time=r=>e.check(ii(r)),e.duration=r=>e.check(li(r))});function x(e){return Ma(ki,e)}const D=m("ZodStringFormat",(e,t)=>{Z.init(e,t),sr.init(e,t)}),wi=m("ZodEmail",(e,t)=>{Vn.init(e,t),D.init(e,t)}),Nt=m("ZodGUID",(e,t)=>{Bn.init(e,t),D.init(e,t)}),Pe=m("ZodUUID",(e,t)=>{Kn.init(e,t),D.init(e,t)}),zi=m("ZodURL",(e,t)=>{Wn.init(e,t),D.init(e,t)}),ji=m("ZodEmoji",(e,t)=>{Gn.init(e,t),D.init(e,t)}),Si=m("ZodNanoID",(e,t)=>{qn.init(e,t),D.init(e,t)}),Ni=m("ZodCUID",(e,t)=>{Hn.init(e,t),D.init(e,t)}),Ci=m("ZodCUID2",(e,t)=>{Yn.init(e,t),D.init(e,t)}),Oi=m("ZodULID",(e,t)=>{Xn.init(e,t),D.init(e,t)}),$i=m("ZodXID",(e,t)=>{Qn.init(e,t),D.init(e,t)}),Ai=m("ZodKSUID",(e,t)=>{ea.init(e,t),D.init(e,t)}),Ti=m("ZodIPv4",(e,t)=>{oa.init(e,t),D.init(e,t)}),Zi=m("ZodIPv6",(e,t)=>{ia.init(e,t),D.init(e,t)}),Ei=m("ZodCIDRv4",(e,t)=>{sa.init(e,t),D.init(e,t)}),Ii=m("ZodCIDRv6",(e,t)=>{la.init(e,t),D.init(e,t)}),Pi=m("ZodBase64",(e,t)=>{ca.init(e,t),D.init(e,t)}),Ri=m("ZodBase64URL",(e,t)=>{da.init(e,t),D.init(e,t)}),Di=m("ZodE164",(e,t)=>{ma.init(e,t),D.init(e,t)}),Mi=m("ZodJWT",(e,t)=>{fa.init(e,t),D.init(e,t)}),lr=m("ZodNumber",(e,t)=>{Ht.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,a,s)=>Io(e,n,a),e.gt=(n,a)=>e.check(jt(n,a)),e.gte=(n,a)=>e.check(qe(n,a)),e.min=(n,a)=>e.check(qe(n,a)),e.lt=(n,a)=>e.check(zt(n,a)),e.lte=(n,a)=>e.check(Ge(n,a)),e.max=(n,a)=>e.check(Ge(n,a)),e.int=n=>e.check(Ct(n)),e.safe=n=>e.check(Ct(n)),e.positive=n=>e.check(jt(0,n)),e.nonnegative=n=>e.check(qe(0,n)),e.negative=n=>e.check(zt(0,n)),e.nonpositive=n=>e.check(Ge(0,n)),e.multipleOf=(n,a)=>e.check(St(n,a)),e.step=(n,a)=>e.check(St(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 A(e){return mo(lr,e)}const Ui=m("ZodNumberFormat",(e,t)=>{ha.init(e,t),lr.init(e,t)});function Ct(e){return po(Ui,e)}const Li=m("ZodBoolean",(e,t)=>{ga.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Po(e,r,n)});function B(e){return fo(Li,e)}const Fi=m("ZodUnknown",(e,t)=>{ba.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Do()});function Ot(){return ho(Fi)}const Ji=m("ZodNever",(e,t)=>{va.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Ro(e,r,n)});function Bi(e){return go(Ji,e)}const Ki=m("ZodArray",(e,t)=>{xa.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Jo(e,r,n,a),e.element=t.element,e.min=(r,n)=>e.check(Me(r,n)),e.nonempty=r=>e.check(Me(1,r)),e.max=(r,n)=>e.check(tr(r,n)),e.length=(r,n)=>e.check(rr(r,n)),e.unwrap=()=>e.element});function ne(e,t){return Co(Ki,e,t)}const Vi=m("ZodObject",(e,t)=>{_a.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Bo(e,r,n,a),S(e,"shape",()=>t.shape),e.keyof=()=>ae(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ot()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ot()}),e.strict=()=>e.clone({...e._zod.def,catchall:Bi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Lr(e,r),e.safeExtend=r=>Fr(e,r),e.merge=r=>Jr(e,r),e.pick=r=>Mr(e,r),e.omit=r=>Ur(e,r),e.partial=(...r)=>Br(dr,e,r[0]),e.required=(...r)=>Kr(mr,e,r[0])});function M(e,t){const r={type:"object",shape:e??{},...g(t)};return new Vi(r)}const cr=m("ZodUnion",(e,t)=>{Qt.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Ko(e,r,n,a),e.options=t.options});function ur(e,t){return new cr({type:"union",options:e,...g(t)})}const Wi=m("ZodDiscriminatedUnion",(e,t)=>{cr.init(e,t),ka.init(e,t)});function Gi(e,t,r){return new Wi({type:"union",options:t,discriminator:e,...g(r)})}const qi=m("ZodIntersection",(e,t)=>{wa.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Vo(e,r,n,a)});function Hi(e,t){return new qi({type:"intersection",left:e,right:t})}const Yi=m("ZodRecord",(e,t)=>{za.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Wo(e,r,n,a),e.keyType=t.keyType,e.valueType=t.valueType});function Re(e,t,r){return new Yi({type:"record",keyType:e,valueType:t,...g(r)})}const Qe=m("ZodEnum",(e,t)=>{ja.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,a,s)=>Mo(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 s={};for(const o of n)if(r.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Qe({...t,checks:[],...g(a),entries:s})},e.exclude=(n,a)=>{const s={...t.entries};for(const o of n)if(r.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new Qe({...t,checks:[],...g(a),entries:s})}});function ae(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Qe({type:"enum",entries:r,...g(t)})}const Xi=m("ZodLiteral",(e,t)=>{Sa.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Uo(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 $t(e,t){return new Xi({type:"literal",values:Array.isArray(e)?e:[e],...g(t)})}const Qi=m("ZodTransform",(e,t)=>{Na.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Fo(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Et(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(Te(s,r.value,t));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(Te(o))}};const a=t.transform(r.value,r);return a instanceof Promise?a.then(s=>(r.value=s,r)):(r.value=a,r)}});function es(e){return new Qi({type:"transform",transform:e})}const dr=m("ZodOptional",(e,t)=>{er.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ir(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function At(e){return new dr({type:"optional",innerType:e})}const ts=m("ZodExactOptional",(e,t)=>{Ca.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ir(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function rs(e){return new ts({type:"optional",innerType:e})}const ns=m("ZodNullable",(e,t)=>{Oa.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Go(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Tt(e){return new ns({type:"nullable",innerType:e})}const as=m("ZodDefault",(e,t)=>{$a.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Ho(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function os(e,t){return new as({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Dt(t)}})}const is=m("ZodPrefault",(e,t)=>{Aa.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Yo(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function ss(e,t){return new is({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Dt(t)}})}const mr=m("ZodNonOptional",(e,t)=>{Ta.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>qo(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function ls(e,t){return new mr({type:"nonoptional",innerType:e,...g(t)})}const cs=m("ZodCatch",(e,t)=>{Za.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Xo(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function us(e,t){return new cs({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ds=m("ZodPipe",(e,t)=>{Ea.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Qo(e,r,n,a),e.in=t.in,e.out=t.out});function Zt(e,t){return new ds({type:"pipe",in:e,out:t})}const ms=m("ZodReadonly",(e,t)=>{Ia.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ei(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function ps(e){return new ms({type:"readonly",innerType:e})}const fs=m("ZodCustom",(e,t)=>{Pa.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Lo(e,r)});function hs(e,t={}){return Oo(fs,e,t)}function gs(e){return $o(e)}const $={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}},bs=M({enabled:B().default(!1),provider:ae(["openai","google"]).default("google"),model:x().min(1).default("gemini-2.5-flash-preview-tts"),voice:x().min(1).default("Kore"),apiKey:x().optional(),style_prompt:x().optional()}),vs=M({provider:ae(["google","openai","openrouter","ollama"]).default($.audio.provider),model:x().min(1).default($.audio.model),enabled:B().default($.audio.enabled),apiKey:x().optional(),base_url:x().optional(),maxDurationSeconds:A().default($.audio.maxDurationSeconds),supportedMimeTypes:ne(x()).default($.audio.supportedMimeTypes),tts:bs.optional()}),Se=M({provider:ae(["openai","anthropic","openrouter","ollama","gemini"]).default($.llm.provider),model:x().min(1).default($.llm.model),temperature:A().min(0).max(1).default($.llm.temperature),max_tokens:A().int().positive().optional(),api_key:x().optional(),base_url:x().optional(),context_window:A().int().positive().optional()}),xs=Se.extend({memory_limit:A().int().positive().optional(),enabled_archived_sessions:B().default(!0),similarity_threshold:A().min(0).max(1).default(.9),evaluation_interval:A().int().min(1).default(1)}),ys=Se.extend({working_dir:x().optional(),timeout_ms:A().int().positive().optional(),execution_mode:ae(["sync","async"]).default("async")}),_s=Se.extend({execution_mode:ae(["sync","async"]).default("async")}),ks=Se.extend({execution_mode:ae(["sync","async"]).default("async")}),ws=Se.extend({personality:x().optional(),chunk_size:A().int().positive().default(500),score_threshold:A().min(0).max(1).default(.5),max_results:A().int().positive().default(10),execution_mode:ae(["sync","async"]).default("async"),scan_interval_ms:A().int().min(5e3).default(3e4),max_file_size_mb:A().int().positive().default(50),vector_weight:A().min(0).max(1).default(.8),bm25_weight:A().min(0).max(1).default(.2)}),zs=M({telegram_notify_all:B().optional()}).optional(),js=M({timezone:x().default("UTC"),check_interval_ms:A().min(6e4).default(6e4),max_active_jobs:A().min(1).max(1e3).default(100)}),Ss=M({sandbox_dir:x().optional(),readonly_mode:B().default(!1),allowed_shell_commands:ne(x()).default([]),allowed_paths:ne(x()).default([]),enable_filesystem:B().default(!0),enable_shell:B().default(!0),enable_git:B().default(!0),enable_network:B().default(!0),timeout_ms:A().int().positive().default(3e4)}),Ns=M({name:x().min(1).max(64).regex(/^[a-z0-9][a-z0-9_-]*$/,"Smith name must be lowercase alphanumeric with hyphens/underscores"),host:x().min(1),port:A().int().min(1).max(65535).default(7900),auth_token:x().min(1),tls:B().default(!1)}),Cs=M({enabled:B().default(!0),fields:ne(x()).default(["name","timezone","preferred_language"])}),Os=M({enabled:B().default(!1),execution_mode:ae(["sync","async"]).default("async"),heartbeat_interval_ms:A().int().min(5e3).default(3e4),connection_timeout_ms:A().int().min(1e3).default(1e4),task_timeout_ms:A().int().min(1e3).default(6e4),entries:ne(Ns).default([])}),$s=M({code:x().min(1).default("USD"),symbol:x().min(1).default("$"),rate:A().positive().default(1)}),As=M({agent:M({name:x().default($.agent.name),personality:x().default($.agent.personality)}).default($.agent),llm:Se.default($.llm),sati:xs.optional(),neo:_s.optional(),apoc:ys.optional(),trinity:ks.optional(),link:ws.optional(),webhooks:zs,audio:vs.default($.audio),memory:M({limit:A().int().positive().optional()}).default($.memory),runtime:M({async_tasks:M({enabled:B().default($.runtime?.async_tasks.enabled)}).default($.runtime?.async_tasks??{enabled:!0})}).optional(),chronos:js.optional(),devkit:Ss.optional(),smiths:Os.optional(),setup:Cs.optional(),currency:$s.optional(),verbose_mode:B().default(!0),channels:M({telegram:M({enabled:B().default(!1),token:x().optional(),allowedUsers:ne(x()).default([])}).default($.channels.telegram),discord:M({enabled:B().default(!1),token:x().optional(),allowedUsers:ne(x()).default([])}).default($.channels.discord)}).default($.channels),ui:M({enabled:B().default($.ui.enabled),port:A().default($.ui.port)}).default($.ui),logging:M({enabled:B().default($.logging.enabled),level:ae(["debug","info","warn","error"]).default($.logging.level),retention:x().default($.logging.retention)}).default($.logging)}),Ts=Gi("transport",[M({transport:$t("stdio"),command:x().min(1,"Command is required for stdio transport"),args:ne(x()).optional().default([]),env:Re(x(),x()).optional().default({}),_comment:x().optional()}),M({transport:$t("http"),url:x().url("Valid URL is required for http transport"),headers:Re(x(),x()).optional().default({}),args:ne(x()).optional().default([]),env:Re(x(),x()).optional().default({}),_comment:x().optional()})]);Re(x(),ur([Ts,x()]));const Zs={resetData:async e=>He.delete("/danger/reset",{categories:e})},Es=[{id:"general",label:"General"},{id:"agents",label:"Agents"},{id:"devkit",label:"DevKit"},{id:"audio",label:"Audio"},{id:"channels",label:"Channels"},{id:"ui",label:"Interface"},{id:"chronos",label:"Chronos"},{id:"danger",label:"Danger Zone"}],Is=[{id:"oracle",label:"Oracle"},{id:"sati",label:"Sati"},{id:"neo",label:"Neo"},{id:"apoc",label:"Apoc"},{id:"trinity",label:"Trinity"},{id:"link",label:"Link"}],Oe=[{label:"OpenAI",value:"openai"},{label:"Anthropic",value:"anthropic"},{label:"OpenRouter",value:"openrouter"},{label:"Ollama",value:"ollama"},{label:"Google Gemini",value:"gemini"}];function Ws(){const{data:e,error:t}=ce("/api/config",Q.fetchConfig),{data:r}=ce("/api/config/sati",Q.getSatiConfig),{data:n}=ce("/api/config/apoc",Q.getApocConfig),{data:a}=ce("/api/config/neo",Q.getNeoConfig),{data:s}=ce("/api/config/trinity",Q.getTrinityConfig),{data:o}=ce("/api/link/config",()=>He.get("/link/config")),{data:c}=ce("/api/config/encryption-status",()=>Q.getEncryptionStatus()),{data:d}=ce("/api/config/env-overrides",()=>Q.getEnvOverrides()),{data:p}=Nr(),[f,h]=I.useState(null),[u,b]=I.useState(null),[y,U]=I.useState(null),[N,be]=I.useState(null),[E,V]=I.useState(null),[w,K]=I.useState(null),[T,Ne]=I.useState(null),[re,pr]=I.useState("general"),[he,fr]=I.useState("oracle"),[it,st]=I.useState(!1),[q,Ze]=I.useState({}),[Ke,Ce]=I.useState(null);I.useEffect(()=>{e&&!u&&b(e)},[e]),I.useEffect(()=>{r&&!y&&U(r)},[r]),I.useEffect(()=>{n&&!E?V(n):!n&&!E&&u&&V({...u.apoc??u.llm,temperature:u.apoc?.temperature??.2,timeout_ms:u.apoc?.timeout_ms??3e4})},[n,u]),I.useEffect(()=>{a&&!N?be(a):!a&&!N&&u&&be({...u.neo??u.llm,temperature:u.neo?.temperature??.2})},[a,u]),I.useEffect(()=>{s&&!w?K(s):!s&&!w&&u&&K({...u.trinity??u.llm,temperature:u.trinity?.temperature??.2})},[s,u]),I.useEffect(()=>{p&&!f&&h(p)},[p]),I.useEffect(()=>{o&&!T&&Ne(o)},[o]);const lt=JSON.stringify(e)!==JSON.stringify(u)||JSON.stringify(r)!==JSON.stringify(y)||JSON.stringify(a)!==JSON.stringify(N)||JSON.stringify(n)!==JSON.stringify(E)||JSON.stringify(s)!==JSON.stringify(w)||JSON.stringify(p)!==JSON.stringify(f)||JSON.stringify(o)!==JSON.stringify(T),hr={general:JSON.stringify(e?.agent)!==JSON.stringify(u?.agent)||e?.verbose_mode!==u?.verbose_mode,agents:JSON.stringify(e?.llm)!==JSON.stringify(u?.llm)||JSON.stringify(r)!==JSON.stringify(y)||JSON.stringify(a)!==JSON.stringify(N)||JSON.stringify(n)!==JSON.stringify(E)||JSON.stringify(s)!==JSON.stringify(w)||JSON.stringify(o)!==JSON.stringify(T),devkit:JSON.stringify(e?.devkit)!==JSON.stringify(u?.devkit),audio:JSON.stringify(e?.audio)!==JSON.stringify(u?.audio),channels:JSON.stringify(e?.channels?.telegram)!==JSON.stringify(u?.channels?.telegram)||JSON.stringify(e?.channels?.discord)!==JSON.stringify(u?.channels?.discord)||JSON.stringify(e?.webhooks)!==JSON.stringify(u?.webhooks),ui:JSON.stringify(e?.ui)!==JSON.stringify(u?.ui),logging:JSON.stringify(e?.logging)!==JSON.stringify(u?.logging),chronos:JSON.stringify(p)!==JSON.stringify(f)},ve=(l,z)=>{if(!c?.apiKeysEncrypted)return null;const{morpheusSecretSet:W,apiKeysEncrypted:C}=c,X=C[l];return!z?i.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"}):d&&d[gr(l)]?null:W?X?i.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"}):i.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"}):i.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"})},gr=l=>({oracle:"llm.api_key",sati:"sati.api_key",neo:"neo.api_key",apoc:"apoc.api_key",trinity:"trinity.api_key",audio:"audio.apiKey"})[l],j=l=>!d||!d[l]?null:i.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"}),_=l=>!!(d&&d[l]),v=(l,z)=>{if(!u)return;const W=JSON.parse(JSON.stringify(u));let C=W;for(let X=0;X<l.length-1;X++)(C[l[X]]===void 0||C[l[X]]===null)&&(C[l[X]]={}),C=C[l[X]];C[l[l.length-1]]=z,b(W);try{As.parse(W),Ze({})}catch(X){if(X instanceof Sr){const We={};X.errors.forEach(ct=>{const zr=ct.path.join(".");We[zr]=ct.message}),Ze(We)}}},Ve=[{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…"}],br=l=>{if(!u)return;const z=Ve.find(X=>X.code===l),W=z&&l!=="OTHER"?{code:z.code,symbol:z.symbol,rate:l==="USD"?1:u.currency?.rate??1}:{code:"",symbol:"",rate:u.currency?.rate??1},C={...u,currency:W};b(C)},ie=(l,z)=>{y&&U({...y,[l]:z})},se=(l,z)=>{E&&V({...E,[l]:z})},oe=(l,z)=>{N&&be({...N,[l]:z})},le=(l,z)=>{w&&K({...w,[l]:z})},vr=()=>{!u||!w||K({...w,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},xr=()=>{!u||!y||U({...y,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},yr=()=>{!u||!E||V({...E,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},_r=()=>{!u||!N||be({...N,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},Y=(l,z)=>{T&&Ne({...T,[l]:z})},kr=()=>{!u||!T||Ne({...T,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},wr=async()=>{if(u){st(!0),Ce(null);try{const l=await Q.updateConfig(u);y&&await Q.updateSatiConfig(y),N&&await Q.updateNeoConfig(N),E&&await Q.updateApocConfig(E),w&&await Q.updateTrinityConfig(w),f&&await Cr.updateConfig(f),T&&await He.post("/link/config",T),ue("/api/config"),ue("/api/config/sati"),ue("/api/config/neo"),ue("/api/config/apoc"),ue("/api/config/trinity"),ue("/api/config/chronos"),ue("/api/link/config"),Ze({});const z=l._restartRequired||[],W=z.length>0?`Settings saved and applied. Some changes require restart: ${z.join(", ")}`:"Settings saved and applied successfully.";Ce({type:"success",message:W}),setTimeout(()=>Ce(null),5e3)}catch(l){if(Ce({type:"error",message:l.message}),l.details&&Array.isArray(l.details)){const z={};l.details.forEach(W=>{const C=W.path.join(".");z[C]=W.message}),Ze(z)}}finally{st(!1)}}};return t?i.jsx("div",{className:"p-8 text-red-500",children:"Failed to load configuration"}):u?i.jsxs("div",{className:"max-w-4xl mx-auto p-0 md:p-6 space-y-6",children:[i.jsxs("div",{className:"flex justify-between items-center flex-wrap gap-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.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:i.jsx($r,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),i.jsxs("div",{children:[i.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Zaion Settings"}),i.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Configure agents, models, channels, and runtime behavior."})]})]}),i.jsx("button",{onClick:wr,disabled:!lt||Object.keys(q).length>0||it,className:`px-4 py-2 rounded font-medium transition-colors ${lt&&Object.keys(q).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:it?"Saving...":"Save Changes"})]}),Ke&&i.jsxs("div",{className:`flex items-start justify-between gap-3 p-4 rounded border ${Ke.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:[i.jsx("span",{className:"text-sm",children:Ke.message}),i.jsx("button",{type:"button",onClick:()=>Ce(null),className:"shrink-0 opacity-60 hover:opacity-100 transition-opacity","aria-label":"Dismiss",children:i.jsx(Ar,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"overflow-x-auto py-1 hide-scrollbar",children:i.jsx("div",{className:"flex space-x-1 border-b border-azure-border dark:border-matrix-primary pb-px min-w-max",children:Es.map(l=>i.jsxs("button",{onClick:()=>pr(l.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===l.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:[l.label,hr[l.id]&&i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"})]},l.id))})}),i.jsxs("div",{className:"space-y-6",children:[re==="general"&&i.jsxs(J,{title:"Agent Identity",children:[i.jsx(k,{label:"Agent Name",value:u.agent.name,onChange:l=>v(["agent","name"],l.target.value),error:q["agent.name"]}),i.jsx(ut,{label:"Personality",value:u.agent.personality,onChange:l=>v(["agent","personality"],l.target.value),error:q["agent.personality"],placeholder:"Describe the agent's personality or description..."}),i.jsx(F,{label:"Verbose Mode",value:u.verbose_mode!==!1?"true":"false",onChange:l=>v(["verbose_mode"],l.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"&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex space-x-1 border-b border-azure-border dark:border-matrix-primary pb-px",children:Is.map(l=>i.jsx("button",{onClick:()=>fr(l.id),className:`px-4 py-2 text-sm font-medium rounded-t-md transition-colors ${he===l.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:l.label},l.id))}),he==="oracle"&&i.jsxs(J,{title:"Oracle Agent",children:[i.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"}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("llm.provider")]}),i.jsx(F,{label:"",value:u.llm.provider,onChange:l=>v(["llm","provider"],l.target.value),options:Oe,error:q["llm.provider"],disabled:_("llm.provider")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),j("llm.model")]}),i.jsx(k,{label:"",value:u.llm.model,onChange:l=>v(["llm","model"],l.target.value),disabled:_("llm.model")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),j("llm.temperature")]}),i.jsx(O,{label:"",value:u.llm.temperature,onChange:l=>v(["llm","temperature"],parseFloat(l.target.value)),step:.1,min:0,max:1,error:q["llm.temperature"],disabled:_("llm.temperature")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),j("llm.max_tokens")]}),i.jsx(O,{label:"",value:u.llm.max_tokens??"",onChange:l=>v(["llm","max_tokens"],l.target.value?parseInt(l.target.value):void 0),min:1,error:q["llm.max_tokens"],helperText:"Maximum tokens per response. Leave empty for model default.",disabled:_("llm.max_tokens")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Context Window (Messages)"}),j("llm.context_window")]}),i.jsx(O,{label:"",value:u.llm.context_window??100,onChange:l=>v(["llm","context_window"],parseInt(l.target.value)),min:1,step:1,error:q["llm.context_window"],helperText:"Number of past interactions to load into LLM context (e.g., 100).",disabled:_("llm.context_window")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),i.jsxs("div",{className:"flex items-center gap-2",children:[j("llm.api_key"),ve("oracle",u.llm.api_key)]})]}),i.jsx(k,{label:"",type:"password",value:u.llm.api_key||"",onChange:l=>v(["llm","api_key"],l.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("llm.api_key")}),u.llm.provider==="openrouter"&&i.jsx(k,{label:"Base URL",value:u.llm.base_url||"https://openrouter.ai/api/v1",onChange:l=>v(["llm","base_url"],l.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]}),he==="sati"&&i.jsxs(J,{title:"Sati Agent",children:[i.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"}),i.jsxs("div",{className:"mb-4",children:[i.jsx("button",{type:"button",onClick:xr,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"}),i.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"})]}),y&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("sati.provider")]}),i.jsx(F,{label:"",value:y.provider,onChange:l=>ie("provider",l.target.value),options:Oe,disabled:_("sati.provider")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),j("sati.model")]}),i.jsx(k,{label:"",value:y.model,onChange:l=>ie("model",l.target.value),disabled:_("sati.model")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),i.jsxs("div",{className:"flex items-center gap-2",children:[j("sati.api_key"),ve("sati",y.api_key)]})]}),i.jsx(k,{label:"",type:"password",value:y.api_key||"",onChange:l=>ie("api_key",l.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("sati.api_key")}),y.provider==="openrouter"&&i.jsx(k,{label:"Base URL",value:y.base_url||"https://openrouter.ai/api/v1",onChange:l=>ie("base_url",l.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"}),i.jsx(O,{label:"Memory Limit",value:y.memory_limit??10,onChange:l=>ie("memory_limit",parseInt(l.target.value)),min:1,step:1,helperText:"Number of memory items to retrieve from long-term storage."}),i.jsx(O,{label:"Evaluation Interval",value:y.evaluation_interval??1,onChange:l=>ie("evaluation_interval",parseInt(l.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."}),i.jsx(te,{label:"Enable Archived Sessions in Memory Retrieval",checked:y.enabled_archived_sessions??!0,onChange:l=>ie("enabled_archived_sessions",l)}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-1",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Similarity Threshold"}),i.jsx("span",{className:"text-sm font-mono text-azure-text-primary dark:text-matrix-highlight",children:(y.similarity_threshold??.9).toFixed(2)})]}),i.jsx("input",{type:"range",min:0,max:1,step:.01,value:y.similarity_threshold??.9,onChange:l=>ie("similarity_threshold",parseFloat(l.target.value)),className:`w-full h-1.5 rounded-full appearance-none cursor-pointer
40
+ bg-gray-200 dark:bg-matrix-primary/30
41
+ accent-azure-primary dark:accent-matrix-highlight`}),i.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."})]})]})]}),he==="neo"&&i.jsxs(J,{title:"Neo Agent",children:[i.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"}),i.jsxs("div",{className:"mb-4",children:[i.jsx("button",{type:"button",onClick:_r,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"}),i.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"})]}),N&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("neo.provider")]}),i.jsx(F,{label:"",value:N.provider,onChange:l=>oe("provider",l.target.value),options:Oe,disabled:_("neo.provider")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),j("neo.model")]}),i.jsx(k,{label:"",value:N.model,onChange:l=>oe("model",l.target.value),disabled:_("neo.model")}),i.jsx(k,{label:"Personality",value:N.personality||"analytical_engineer",onChange:l=>oe("personality",l.target.value),placeholder:"analytical_engineer",helperText:"e.g., analytical_engineer, meticulous_auditor, systems_thinker"}),i.jsx(F,{label:"Execution Mode",value:N.execution_mode||"async",onChange:l=>oe("execution_mode",l.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),j("neo.temperature")]}),i.jsx(O,{label:"",value:N.temperature,onChange:l=>oe("temperature",parseFloat(l.target.value)),step:.1,min:0,max:1,disabled:_("neo.temperature")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),j("neo.max_tokens")]}),i.jsx(O,{label:"",value:N.max_tokens??"",onChange:l=>oe("max_tokens",l.target.value?parseInt(l.target.value):void 0),min:1,helperText:"Maximum tokens per response. Leave empty for model default.",disabled:_("neo.max_tokens")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Context Window (Messages)"}),j("neo.context_window")]}),i.jsx(O,{label:"",value:N.context_window??100,onChange:l=>oe("context_window",parseInt(l.target.value)),min:1,step:1,disabled:_("neo.context_window")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),i.jsxs("div",{className:"flex items-center gap-2",children:[j("neo.api_key"),ve("neo",N.api_key)]})]}),i.jsx(k,{label:"",type:"password",value:N.api_key||"",onChange:l=>oe("api_key",l.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("neo.api_key")}),N.provider==="openrouter"&&i.jsx(k,{label:"Base URL",value:N.base_url||"https://openrouter.ai/api/v1",onChange:l=>oe("base_url",l.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]})]}),he==="trinity"&&i.jsxs(J,{title:"Trinity Agent",children:[i.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)"}),i.jsxs("div",{className:"mb-4",children:[i.jsx("button",{type:"button",onClick:vr,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"}),i.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"})]}),w&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("trinity.provider")]}),i.jsx(F,{label:"",value:w.provider,onChange:l=>le("provider",l.target.value),options:Oe,disabled:_("trinity.provider")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),j("trinity.model")]}),i.jsx(k,{label:"",value:w.model,onChange:l=>le("model",l.target.value),disabled:_("trinity.model")}),i.jsx(k,{label:"Personality",value:w.personality||"data_specialist",onChange:l=>le("personality",l.target.value),placeholder:"data_specialist",helperText:"e.g., data_specialist, query_optimizer, db_architect"}),i.jsx(F,{label:"Execution Mode",value:w.execution_mode||"async",onChange:l=>le("execution_mode",l.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),j("trinity.temperature")]}),i.jsx(O,{label:"",value:w.temperature,onChange:l=>le("temperature",parseFloat(l.target.value)),step:.1,min:0,max:1,disabled:_("trinity.temperature")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),j("trinity.max_tokens")]}),i.jsx(O,{label:"",value:w.max_tokens??"",onChange:l=>le("max_tokens",l.target.value?parseInt(l.target.value):void 0),min:1,helperText:"Maximum tokens per response. Leave empty for model default.",disabled:_("trinity.max_tokens")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),i.jsxs("div",{className:"flex items-center gap-2",children:[j("trinity.api_key"),ve("trinity",w.api_key)]})]}),i.jsx(k,{label:"",type:"password",value:w.api_key||"",onChange:l=>le("api_key",l.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("trinity.api_key")}),w.provider==="openrouter"&&i.jsx(k,{label:"Base URL",value:w.base_url||"https://openrouter.ai/api/v1",onChange:l=>le("base_url",l.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]})]}),he==="link"&&i.jsxs(J,{title:"Link Agent",children:[i.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"}),T&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mb-4",children:i.jsx("button",{type:"button",onClick:kr,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"})}),i.jsx(F,{label:"Provider",value:T.provider||"openai",onChange:l=>Y("provider",l.target.value),options:[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"openrouter",label:"OpenRouter"},{value:"ollama",label:"Ollama"},{value:"gemini",label:"Gemini"}]}),i.jsx(k,{label:"Model Name",value:T.model||"",onChange:l=>Y("model",l.target.value),placeholder:"e.g., gpt-4"}),i.jsx(k,{label:"Personality",value:T.personality||"",onChange:l=>Y("personality",l.target.value),placeholder:"documentation_specialist"}),i.jsx(F,{label:"Execution Mode",value:T.execution_mode||"async",onChange:l=>Y("execution_mode",l.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),i.jsx(O,{label:"Temperature",value:T.temperature??.2,onChange:l=>Y("temperature",parseFloat(l.target.value)),step:.1,min:0,max:1}),i.jsx(k,{label:"API Key (optional — falls back to Oracle)",value:T.api_key||"",onChange:l=>Y("api_key",l.target.value||void 0),type:"password",placeholder:"Leave empty to use Oracle's API key"}),i.jsx("h4",{className:"text-sm font-medium text-azure-text dark:text-matrix-highlight mt-6 mb-3",children:"RAG Settings"}),i.jsx(O,{label:"Chunk Size",value:T.chunk_size,onChange:l=>Y("chunk_size",parseInt(l.target.value)||500),min:100,max:2e3,helperText:"Character count per document chunk (default: 500)"}),i.jsx(O,{label:"Score Threshold",value:T.score_threshold,onChange:l=>Y("score_threshold",parseFloat(l.target.value)||.5),step:.1,min:0,max:1,helperText:"Minimum similarity score to include in results (0-1, default: 0.5)"}),i.jsx(O,{label:"Max Results",value:T.max_results,onChange:l=>Y("max_results",parseInt(l.target.value)||10),min:1,max:50,helperText:"Maximum number of chunks to return per search (default: 10)"}),i.jsx(O,{label:"Scan Interval (ms)",value:T.scan_interval_ms,onChange:l=>Y("scan_interval_ms",parseInt(l.target.value)||3e4),min:5e3,max:3e5,helperText:"How often to scan docs folder for changes (default: 30000ms = 30s)"}),i.jsx(O,{label:"Max File Size (MB)",value:T.max_file_size_mb,onChange:l=>Y("max_file_size_mb",parseInt(l.target.value)||50),min:1,max:100,helperText:"Maximum file size to process (default: 50MB)"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(O,{label:"Vector Weight",value:T.vector_weight,onChange:l=>Y("vector_weight",parseFloat(l.target.value)||.8),step:.1,min:0,max:1,helperText:"Weight for vector similarity (default: 0.8)"}),i.jsx(O,{label:"BM25 Weight",value:T.bm25_weight,onChange:l=>Y("bm25_weight",parseFloat(l.target.value)||.2),step:.1,min:0,max:1,helperText:"Weight for keyword matching (default: 0.2)"})]}),i.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"})]})]}),he==="apoc"&&i.jsxs(J,{title:"Apoc Agent",children:[i.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"}),i.jsxs("div",{className:"mb-4",children:[i.jsx("button",{type:"button",onClick:yr,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"}),i.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"})]}),E&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("apoc.provider")]}),i.jsx(F,{label:"",value:E.provider,onChange:l=>se("provider",l.target.value),options:Oe,disabled:_("apoc.provider")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),j("apoc.model")]}),i.jsx(k,{label:"",value:E.model,onChange:l=>se("model",l.target.value),disabled:_("apoc.model")}),i.jsx(k,{label:"Personality",value:E.personality||"pragmatic_dev",onChange:l=>se("personality",l.target.value),placeholder:"pragmatic_dev",helperText:"e.g., pragmatic_dev, cautious_admin, automation_specialist"}),i.jsx(F,{label:"Execution Mode",value:E.execution_mode||"async",onChange:l=>se("execution_mode",l.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),j("apoc.temperature")]}),i.jsx(O,{label:"",value:E.temperature,onChange:l=>se("temperature",parseFloat(l.target.value)),step:.1,min:0,max:1,disabled:_("apoc.temperature")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),i.jsxs("div",{className:"flex items-center gap-2",children:[j("apoc.api_key"),ve("apoc",E.api_key)]})]}),i.jsx(k,{label:"",type:"password",value:E.api_key||"",onChange:l=>se("api_key",l.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:_("apoc.api_key")}),E.provider==="openrouter"&&i.jsx(k,{label:"Base URL",value:E.base_url||"https://openrouter.ai/api/v1",onChange:l=>se("base_url",l.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"}),i.jsx(O,{label:"Timeout (ms)",value:E.timeout_ms??3e4,onChange:l=>se("timeout_ms",parseInt(l.target.value)),min:1e3,step:1e3,helperText:"Maximum execution time for shell and system operations in milliseconds."})]})]})]}),re==="devkit"&&i.jsxs(i.Fragment,{children:[i.jsxs(J,{title:"DevKit Security",children:[i.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."}),i.jsx(k,{label:"Sandbox Directory",value:u.devkit?.sandbox_dir||"",onChange:l=>v(["devkit","sandbox_dir"],l.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")}),i.jsx(ut,{label:"Allowed Paths",value:u.devkit?.allowed_paths?.join(`
42
+ `)||"",onChange:l=>v(["devkit","allowed_paths"],l.target.value.split(`
43
+ `).map(z=>z.trim()).filter(Boolean)),placeholder:"~/.morpheus/docs",helperText:"Additional paths outside sandbox_dir that DevKit can access (one per line).",rows:4}),i.jsx(F,{label:"Read-Only Mode",value:u.devkit?.readonly_mode?"true":"false",onChange:l=>v(["devkit","readonly_mode"],l.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")}),i.jsx(O,{label:"Timeout (ms)",value:u.devkit?.timeout_ms??3e4,onChange:l=>v(["devkit","timeout_ms"],parseInt(l.target.value)),min:1e3,step:1e3,helperText:"Default timeout for shell and system operations in milliseconds.",disabled:_("devkit.timeout_ms")})]}),i.jsxs(J,{title:"Tool Categories",children:[i.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Enable or disable entire categories of DevKit tools."}),i.jsx(te,{label:"Filesystem (read, write, list, copy, move, delete files)",checked:u.devkit?.enable_filesystem!==!1,onChange:l=>v(["devkit","enable_filesystem"],l)}),i.jsx(te,{label:"Shell (run_command, run_script, which)",checked:u.devkit?.enable_shell!==!1,onChange:l=>v(["devkit","enable_shell"],l)}),i.jsx(te,{label:"Git (status, diff, commit, push, pull, clone, branch)",checked:u.devkit?.enable_git!==!1,onChange:l=>v(["devkit","enable_git"],l)}),i.jsx(te,{label:"Network (http_request, ping, dns_lookup, download_file)",checked:u.devkit?.enable_network!==!1,onChange:l=>v(["devkit","enable_network"],l)})]}),i.jsxs(J,{title:"Shell Command Allowlist",children:[i.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)."}),i.jsx(k,{label:"Allowed Commands",value:(u.devkit?.allowed_shell_commands||[]).join(", "),onChange:l=>v(["devkit","allowed_shell_commands"],l.target.value.split(",").map(z=>z.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==="audio"&&i.jsxs(i.Fragment,{children:[i.jsxs(J,{title:"Audio Transcription",children:[i.jsx(te,{label:"Enable Audio",checked:u.audio.enabled,onChange:l=>v(["audio","enabled"],l)}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("audio.provider")]}),i.jsx(F,{label:"",value:u.audio.provider||"google",onChange:l=>v(["audio","provider"],l.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:q["audio.provider"],disabled:_("audio.provider")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model"}),j("audio.model")]}),i.jsx(k,{label:"",value:u.audio.model,onChange:l=>v(["audio","model"],l.target.value),placeholder:"e.g. whisper-1, gemini-2.5-flash-lite...",helperText:"Model to use for audio transcription.",error:q["audio.model"],disabled:_("audio.model")}),u.audio.provider==="ollama"&&i.jsx(k,{label:"Base URL",value:u.audio.base_url||"",onChange:l=>v(["audio","base_url"],l.target.value),placeholder:"http://localhost:11434",helperText:"Ollama base URL. Requires a Whisper model loaded (ollama pull whisper)."}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),i.jsxs("div",{className:"flex items-center gap-2",children:[j("audio.apiKey"),ve("audio",u.audio.apiKey)]})]}),i.jsx(k,{label:"",type:"password",value:u.audio.apiKey||"",onChange:l=>v(["audio","apiKey"],l.target.value),placeholder:"If different from LLM key...",helperText:"Leave empty to use LLM API key if using the same provider.",disabled:_("audio.apiKey")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Duration (Seconds)"}),j("audio.maxDurationSeconds")]}),i.jsx(O,{label:"",value:u.audio.maxDurationSeconds,onChange:l=>v(["audio","maxDurationSeconds"],parseInt(l.target.value)),min:1,disabled:_("audio.maxDurationSeconds")}),i.jsx(k,{label:"Supported Mime Types",value:u.audio.supportedMimeTypes.join(", "),onChange:l=>v(["audio","supportedMimeTypes"],l.target.value.split(",").map(z=>z.trim()).filter(Boolean)),helperText:"Comma separated list (e.g. audio/ogg, audio/mp3)"})]}),i.jsxs(J,{title:"Audio Response (TTS)",children:[i.jsx(te,{label:"Enable Voice Responses",checked:u.audio.tts?.enabled??!1,onChange:l=>v(["audio","tts","enabled"],l)}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"TTS Provider"}),j("audio.tts.provider")]}),i.jsx(F,{label:"",value:u.audio.tts?.provider||"openai",onChange:l=>v(["audio","tts","provider"],l.target.value),options:[{label:"Google Gemini",value:"google"}],error:q["audio.tts.provider"],disabled:_("audio.tts.provider")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"TTS Model"}),j("audio.tts.model")]}),i.jsx(k,{label:"",value:u.audio.tts?.model||"gemini-2.5-flash-preview-tts",onChange:l=>v(["audio","tts","model"],l.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:q["audio.tts.model"],disabled:_("audio.tts.model")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Voice"}),j("audio.tts.voice")]}),u.audio.tts?.provider==="openai"?i.jsx(F,{label:"",value:u.audio.tts?.voice||"alloy",onChange:l=>v(["audio","tts","voice"],l.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:q["audio.tts.voice"],disabled:_("audio.tts.voice")}):i.jsxs(i.Fragment,{children:[i.jsx(F,{label:"",value:u.audio.tts?.voice||"Kore",onChange:l=>v(["audio","tts","voice"],l.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:q["audio.tts.voice"],disabled:_("audio.tts.voice")}),i.jsxs("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-1",children:["Listen examples in"," ",i.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"})]})]}),i.jsx(k,{label:"Style Prompt",value:u.audio.tts?.style_prompt||"",onChange:l=>v(["audio","tts","style_prompt"],l.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")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"TTS API Key"}),i.jsx("div",{className:"flex items-center gap-2",children:j("audio.tts.apiKey")})]}),i.jsx(k,{label:"",type:"password",value:u.audio.tts?.apiKey||"",onChange:l=>v(["audio","tts","apiKey"],l.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"&&i.jsxs(i.Fragment,{children:[i.jsxs(J,{title:"Telegram",children:[i.jsx(te,{label:"Enable Telegram",checked:u.channels.telegram.enabled,onChange:l=>v(["channels","telegram","enabled"],l)}),u.channels.telegram.enabled&&i.jsxs("div",{className:"space-y-4 mt-4 pl-4 border-l border-matrix-primary",children:[i.jsx(k,{label:"Bot Token",type:"password",value:u.channels.telegram.token||"",onChange:l=>v(["channels","telegram","token"],l.target.value)}),i.jsx(k,{label:"Allowed Users (comma separated)",value:u.channels.telegram.allowedUsers.join(", "),onChange:l=>v(["channels","telegram","allowedUsers"],l.target.value.split(",").map(z=>z.trim()).filter(Boolean)),helperText:"User IDs allowed to interact with the bot"})]})]}),i.jsxs(J,{title:"Discord",children:[i.jsx(te,{label:"Enable Discord",checked:u.channels.discord.enabled,onChange:l=>v(["channels","discord","enabled"],l)}),u.channels.discord.enabled&&i.jsxs("div",{className:"space-y-4 mt-4 pl-4 border-l border-matrix-primary",children:[i.jsx(k,{label:"Bot Token",type:"password",value:u.channels.discord.token||"",onChange:l=>v(["channels","discord","token"],l.target.value)}),i.jsx(k,{label:"Allowed Users (comma separated)",value:(u.channels.discord.allowedUsers??[]).join(", "),onChange:l=>v(["channels","discord","allowedUsers"],l.target.value.split(",").map(z=>z.trim()).filter(Boolean)),helperText:"Discord user IDs allowed to interact with the bot"})]})]})]}),re==="ui"&&i.jsxs(i.Fragment,{children:[i.jsxs(J,{title:"Dashboard",children:[i.jsx(te,{label:"Enable Web UI",checked:u.ui.enabled,onChange:l=>v(["ui","enabled"],l)}),i.jsx(O,{label:"Port",value:u.ui.port,onChange:l=>v(["ui","port"],parseInt(l.target.value)),disabled:!0,helperText:"Port changes require daemon restart."})]}),i.jsx(J,{title:"Display Currency",children:(()=>{const l=u.currency?.code??"USD",W=Ve.some(C=>C.code===l&&C.code!=="OTHER")?l:"OTHER";return i.jsxs(i.Fragment,{children:[i.jsx(F,{label:"Currency",value:W,onChange:C=>br(C.target.value),options:Ve.map(C=>({value:C.code,label:C.label})),helperText:"Costs are always stored in USD. The selected currency is used for display only."}),W==="OTHER"&&i.jsxs(i.Fragment,{children:[i.jsx(k,{label:"Currency Code",value:l,onChange:C=>v(["currency","code"],C.target.value.toUpperCase()),helperText:"ISO 4217 code (e.g. MXN, CNY, INR)."}),i.jsx(k,{label:"Currency Symbol",value:u.currency?.symbol??"",onChange:C=>v(["currency","symbol"],C.target.value),helperText:"Symbol shown in cost displays (e.g. MX$, ¥, ₹)."})]}),i.jsx(O,{label:"Conversion Rate (from USD)",value:u.currency?.rate??1,onChange:C=>v(["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"&&i.jsxs(J,{title:"Logging",children:[i.jsx(te,{label:"Enable Logging",checked:u.logging.enabled,onChange:l=>v(["logging","enabled"],l)}),i.jsx(F,{label:"Log Level",value:u.logging.level,onChange:l=>v(["logging","level"],l.target.value),options:[{label:"Debug",value:"debug"},{label:"Info",value:"info"},{label:"Warning",value:"warn"},{label:"Error",value:"error"}]})]}),re==="chronos"&&f&&i.jsxs(J,{title:"Chronos — Temporal Intent Engine",children:[i.jsx(F,{label:"Timezone",value:f.timezone,onChange:l=>h({...f,timezone:l.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"}]}),i.jsx(O,{label:"Check Interval (seconds)",value:Math.round(f.check_interval_ms/1e3),onChange:l=>h({...f,check_interval_ms:Number(l.target.value)*1e3}),min:60}),i.jsx(O,{label:"Max Active Jobs",value:f.max_active_jobs,onChange:l=>h({...f,max_active_jobs:Number(l.target.value)}),min:1,max:1e3})]}),re==="danger"&&i.jsx(Ps,{})]})]}):i.jsx("div",{className:"p-8 text-azure-primary dark:text-matrix-highlight",children:"Loading settings..."})}const xe=[{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 Ps(){const[e,t]=I.useState(new Set),[r,n]=I.useState(!1),[a,s]=I.useState(!1),[o,c]=I.useState(null),d=u=>{t(b=>{const y=new Set(b);return y.has(u)?y.delete(u):y.add(u),y})},p=()=>{e.size===xe.length?t(new Set):t(new Set(xe.map(u=>u.id)))},f=async()=>{if(e.size!==0){s(!0),c(null);try{const u=await Zs.resetData([...e]);c({success:!0,message:u.message}),t(new Set),ue(()=>!0,void 0,{revalidate:!0})}catch(u){c({success:!1,message:u instanceof Error?u.message:"Failed to reset data"})}finally{s(!1)}}},h=xe.filter(u=>e.has(u.id)).map(u=>u.label);return i.jsxs(i.Fragment,{children:[i.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:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Tr,{className:"w-6 h-6 text-red-500 dark:text-red-400 shrink-0"}),i.jsx("h3",{className:"text-lg font-semibold text-red-700 dark:text-red-400",children:"Danger Zone"})]}),i.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 ",i.jsx("strong",{children:"irreversible"}),"."]}),i.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:[i.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:[i.jsx("input",{type:"checkbox",checked:e.size===xe.length,onChange:p,className:`w-4 h-4 rounded border-red-300 text-red-600 focus:ring-red-500
44
+ dark:border-red-800 dark:bg-black dark:checked:bg-red-600`}),i.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-400",children:"Select all"})]}),xe.map(u=>i.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[i.jsx("input",{type:"checkbox",checked:e.has(u.id),onChange:()=>d(u.id),className:`w-4 h-4 mt-0.5 rounded border-red-300 text-red-600 focus:ring-red-500
45
+ dark:border-red-800 dark:bg-black dark:checked:bg-red-600`}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:u.label}),i.jsx("p",{className:"text-xs text-red-500 dark:text-red-300/60",children:u.description})]})]},u.id))]}),i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsx("p",{className:"text-xs text-red-500 dark:text-red-300/50",children:e.size===0?"No categories selected":`${e.size} of ${xe.length} selected`}),i.jsx("button",{onClick:()=>n(!0),disabled:a||e.size===0,className:`shrink-0 px-4 py-2 text-sm font-medium rounded-md
46
+ bg-red-600 text-white hover:bg-red-700
47
+ dark:bg-red-900/50 dark:text-red-200 dark:hover:bg-red-800/60
48
+ disabled:opacity-50 disabled:cursor-not-allowed
49
+ transition-colors`,children:a?"Resetting...":"Reset selected data"})]}),o&&i.jsx("div",{className:`rounded-md p-3 text-sm ${o.success?"bg-green-50 text-green-700 dark:bg-green-950/30 dark:text-green-400 border border-green-200 dark:border-green-900":"bg-red-100 text-red-700 dark:bg-red-950/40 dark:text-red-300 border border-red-300 dark:border-red-800"}`,children:o.message})]}),i.jsx(Or,{isOpen:r,onClose:()=>n(!1),onConfirm:f,title:"Reset selected data?",description:`This will permanently delete: ${h.join(", ")}. This action cannot be undone.`,confirmJson:"Yes, delete permanently",variant:"destructive"})]})}export{Ws as default};
@@ -1,4 +1,4 @@
1
- import{j as e,m as n}from"./vendor-motion-C3CZ8ZlO.js";import{r as s}from"./vendor-react-DikRIOlj.js";import{u as Z}from"./vendor-utils-D4NnWbOU.js";import{s as l}from"./skills-wANsorUj.js";import{D as K,e as O,j as V}from"./index-Bta9YXEm.js";import{W as y,ak as u,Q as b,a2 as W,G as F,V as L,U as I,_ as q,a3 as A,a4 as B,X as G,al as H}from"./vendor-icons-NHF9HNeN.js";const U={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},g={hidden:{opacity:0,y:8},show:{opacity:1,y:0}};function M({skill:r,onToggle:i,onView:d}){return e.jsxs(n.div,{variants:g,className:`rounded-lg border flex flex-col transition-all ${r.enabled?"border-azure-primary/50 dark:border-matrix-primary bg-white dark:bg-zinc-900 shadow-sm":"border-azure-border dark:border-matrix-primary/30 bg-azure-surface/50 dark:bg-zinc-900 shadow-sm"}`,children:[e.jsxs("div",{className:"p-4 flex items-start gap-3 flex-1",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${r.enabled?"bg-azure-primary/10 dark:bg-matrix-highlight/10":"bg-azure-surface dark:bg-zinc-900"}`,children:e.jsx(y,{className:`w-4 h-4 ${r.enabled?"text-azure-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:`font-semibold truncate ${r.enabled?"text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary"}`,children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]}),!r.enabled&&e.jsx("span",{className:"text-[10px] font-medium text-zinc-400 dark:text-zinc-500 bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded px-1.5 py-0.5 shrink-0",children:"disabled"})]}),e.jsx("p",{className:`text-sm mt-1.5 line-clamp-2 leading-relaxed ${r.enabled?"text-azure-text-secondary dark:text-matrix-secondary":"text-azure-text-secondary/70 dark:text-matrix-tertiary"}`,children:r.description}),r.tags&&r.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]})]}),e.jsxs("div",{className:"px-4 py-3 border-t border-azure-border dark:border-matrix-primary/30 flex items-center justify-between gap-2",children:[r.author?e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary min-w-0",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:r.author})]}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:d,className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary/50 text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"View details",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:i,className:`p-1.5 rounded border transition-colors ${r.enabled?"border-emerald-300 dark:border-emerald-700/60 text-emerald-500 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-900/20":"border-azure-border dark:border-matrix-primary/40 text-zinc-400 dark:text-zinc-600 hover:text-azure-text dark:hover:text-matrix-secondary hover:border-azure-border dark:hover:border-matrix-primary"}`,title:r.enabled?"Disable skill":"Enable skill",children:r.enabled?e.jsx(A,{className:"w-4 h-4"}):e.jsx(B,{className:"w-4 h-4"})})]})]})]})}function Q({skill:r,open:i,onOpenChange:d}){return!i||!r?null:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>d(!1)}),e.jsxs("div",{className:"relative bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-azure-border dark:border-matrix-primary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 flex items-center justify-center shrink-0",children:e.jsx(y,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight truncate",children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]})]}),r.author&&e.jsxs("div",{className:"flex items-center gap-1 mt-0.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),r.author]})]})]}),e.jsx("button",{onClick:()=>d(!1),className:"p-1.5 rounded text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight hover:bg-azure-surface dark:hover:bg-zinc-900 transition-colors shrink-0",children:e.jsx(G,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[r.description&&e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary leading-relaxed",children:r.description}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsxs("div",{className:"flex items-start gap-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(H,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{className:"break-all font-mono text-azure-text dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-2 py-0.5",children:r.path})]})}),r.tags&&r.tags.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]}),r.examples&&r.examples.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Examples"}),e.jsx("ul",{className:"space-y-1.5",children:r.examples.map((t,x)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-azure-text-secondary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/30 rounded px-3 py-2",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary font-mono text-xs mt-0.5 shrink-0",children:[x+1,"."]}),t]},x))})]}),r.content&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"SKILL.md"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-72 whitespace-pre-wrap leading-relaxed font-mono",children:r.content})]})]})]})]})}function ae(){const[r,i]=s.useState(null),[d,t]=s.useState(!1),[x,N]=s.useState(!1),[o,v]=s.useState(!1),[c,k]=s.useState(null),[w,f]=s.useState(null),j=s.useRef(null),{data:S,mutate:z,isLoading:D}=Z("/skills",()=>l.fetchSkills(),{refreshInterval:1e4}),m=S?.skills??[],E=S?.enabled??0,R=async()=>{await l.reloadSkills(),z()},T=async a=>{a.enabled?await l.disableSkill(a.name):await l.enableSkill(a.name),z()},$=async a=>{t(!0);try{const p=await l.fetchSkill(a.name);i(p)}finally{t(!1)}},P=async a=>{const p=a.target.files?.[0];if(p){k(null),f(null),v(!0);try{const h=await l.uploadSkill(p);f(`Skill "${h.skill.name}" uploaded successfully!`),z(),j.current&&(j.current.value="")}catch(h){k({error:h.message||"Upload failed",details:h.details})}finally{v(!1)}}},C=()=>{k(null),f(null),N(!0)};return e.jsxs(n.div,{variants:U,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.div,{variants:g,className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.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:e.jsx(y,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Skills"}),e.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:[m.length," skill",m.length!==1?"s":"",", ",E," enabled"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:C,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-azure-primary dark:border-matrix-primary text-azure-primary dark:text-matrix-primary font-medium hover:bg-azure-primary/10 dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload"]}),e.jsxs("button",{onClick:R,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(b,{className:"w-4 h-4"}),"Reload"]})]})]}),D?e.jsxs(n.div,{variants:g,className:"text-center py-12",children:[e.jsx(b,{className:"w-8 h-8 animate-spin mx-auto text-azure-text-secondary dark:text-matrix-dim"}),e.jsx("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-dim",children:"Loading skills..."})]}):m.length===0?e.jsxs(n.div,{variants:g,className:"rounded-lg border border-dashed border-azure-border dark:border-matrix-primary p-8 text-center",children:[e.jsx(y,{className:"w-12 h-12 mx-auto text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("h3",{className:"mt-4 text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:"No skills found"}),e.jsxs("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-secondary max-w-md mx-auto",children:["Upload a skill ZIP or add skills manually to"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"~/.morpheus/skills/"}),". Each skill folder must contain a"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file with frontmatter."]}),e.jsxs("button",{onClick:C,className:"mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload Skill"]})]}):e.jsx(n.div,{variants:U,initial:"hidden",animate:"show",className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:m.map(a=>e.jsx(M,{skill:a,onToggle:()=>T(a),onView:()=>$(a)},a.name))}),e.jsx(Q,{skill:r,open:!!r,onOpenChange:a=>!a&&i(null)}),e.jsxs(K,{open:x,onOpenChange:N,children:[e.jsx(O,{children:e.jsx(V,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5"}),"Upload Skill"]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm",children:["Upload a ZIP file containing your skill folder. The ZIP must have exactly one folder at root level with a valid ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file."]}),e.jsxs("div",{className:"border-2 border-dashed border-azure-border dark:border-matrix-primary rounded-lg p-6",children:[e.jsx("input",{ref:j,type:"file",accept:".zip,application/zip,application/x-zip-compressed",onChange:P,disabled:o,className:"hidden",id:"skill-upload-input"}),e.jsxs("label",{htmlFor:"skill-upload-input",className:`flex flex-col items-center gap-2 cursor-pointer ${o?"opacity-50 cursor-not-allowed":""}`,children:[o?e.jsx(b,{className:"w-8 h-8 animate-spin text-azure-primary dark:text-matrix-primary"}):e.jsx(u,{className:"w-8 h-8 text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:o?"Uploading...":"Click to select ZIP file"})]})]}),c&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800",children:[e.jsx(W,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:c.error}),c.details&&e.jsx("p",{className:"text-xs text-red-600 dark:text-red-300 mt-1",children:c.details})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800",children:[e.jsx(F,{className:"w-5 h-5 text-green-600 dark:text-green-400"}),e.jsx("p",{className:"text-sm text-green-800 dark:text-green-200",children:w})]}),e.jsxs("div",{className:"rounded-lg bg-azure-hover dark:bg-zinc-900 p-3",children:[e.jsx("h4",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight mb-2",children:"ZIP Structure Example"}),e.jsx("pre",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:`my-skill.zip
1
+ import{j as e,m as n}from"./vendor-motion-C3CZ8ZlO.js";import{r as s}from"./vendor-react-DikRIOlj.js";import{u as Z}from"./vendor-utils-D4NnWbOU.js";import{s as l}from"./skills-CtCb-52u.js";import{D as K,e as O,j as V}from"./index-BcX5O7kY.js";import{W as y,ak as u,Q as b,a2 as W,G as F,V as L,U as I,_ as q,a3 as A,a4 as B,X as G,al as H}from"./vendor-icons-NHF9HNeN.js";const U={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},g={hidden:{opacity:0,y:8},show:{opacity:1,y:0}};function M({skill:r,onToggle:i,onView:d}){return e.jsxs(n.div,{variants:g,className:`rounded-lg border flex flex-col transition-all ${r.enabled?"border-azure-primary/50 dark:border-matrix-primary bg-white dark:bg-zinc-900 shadow-sm":"border-azure-border dark:border-matrix-primary/30 bg-azure-surface/50 dark:bg-zinc-900 shadow-sm"}`,children:[e.jsxs("div",{className:"p-4 flex items-start gap-3 flex-1",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${r.enabled?"bg-azure-primary/10 dark:bg-matrix-highlight/10":"bg-azure-surface dark:bg-zinc-900"}`,children:e.jsx(y,{className:`w-4 h-4 ${r.enabled?"text-azure-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:`font-semibold truncate ${r.enabled?"text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary"}`,children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]}),!r.enabled&&e.jsx("span",{className:"text-[10px] font-medium text-zinc-400 dark:text-zinc-500 bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded px-1.5 py-0.5 shrink-0",children:"disabled"})]}),e.jsx("p",{className:`text-sm mt-1.5 line-clamp-2 leading-relaxed ${r.enabled?"text-azure-text-secondary dark:text-matrix-secondary":"text-azure-text-secondary/70 dark:text-matrix-tertiary"}`,children:r.description}),r.tags&&r.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]})]}),e.jsxs("div",{className:"px-4 py-3 border-t border-azure-border dark:border-matrix-primary/30 flex items-center justify-between gap-2",children:[r.author?e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary min-w-0",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:r.author})]}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:d,className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary/50 text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"View details",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:i,className:`p-1.5 rounded border transition-colors ${r.enabled?"border-emerald-300 dark:border-emerald-700/60 text-emerald-500 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-900/20":"border-azure-border dark:border-matrix-primary/40 text-zinc-400 dark:text-zinc-600 hover:text-azure-text dark:hover:text-matrix-secondary hover:border-azure-border dark:hover:border-matrix-primary"}`,title:r.enabled?"Disable skill":"Enable skill",children:r.enabled?e.jsx(A,{className:"w-4 h-4"}):e.jsx(B,{className:"w-4 h-4"})})]})]})]})}function Q({skill:r,open:i,onOpenChange:d}){return!i||!r?null:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>d(!1)}),e.jsxs("div",{className:"relative bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-azure-border dark:border-matrix-primary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 flex items-center justify-center shrink-0",children:e.jsx(y,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight truncate",children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]})]}),r.author&&e.jsxs("div",{className:"flex items-center gap-1 mt-0.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),r.author]})]})]}),e.jsx("button",{onClick:()=>d(!1),className:"p-1.5 rounded text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight hover:bg-azure-surface dark:hover:bg-zinc-900 transition-colors shrink-0",children:e.jsx(G,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[r.description&&e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary leading-relaxed",children:r.description}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsxs("div",{className:"flex items-start gap-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(H,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{className:"break-all font-mono text-azure-text dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-2 py-0.5",children:r.path})]})}),r.tags&&r.tags.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]}),r.examples&&r.examples.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Examples"}),e.jsx("ul",{className:"space-y-1.5",children:r.examples.map((t,x)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-azure-text-secondary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/30 rounded px-3 py-2",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary font-mono text-xs mt-0.5 shrink-0",children:[x+1,"."]}),t]},x))})]}),r.content&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"SKILL.md"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-72 whitespace-pre-wrap leading-relaxed font-mono",children:r.content})]})]})]})]})}function ae(){const[r,i]=s.useState(null),[d,t]=s.useState(!1),[x,N]=s.useState(!1),[o,v]=s.useState(!1),[c,k]=s.useState(null),[w,f]=s.useState(null),j=s.useRef(null),{data:S,mutate:z,isLoading:D}=Z("/skills",()=>l.fetchSkills(),{refreshInterval:1e4}),m=S?.skills??[],E=S?.enabled??0,R=async()=>{await l.reloadSkills(),z()},T=async a=>{a.enabled?await l.disableSkill(a.name):await l.enableSkill(a.name),z()},$=async a=>{t(!0);try{const p=await l.fetchSkill(a.name);i(p)}finally{t(!1)}},P=async a=>{const p=a.target.files?.[0];if(p){k(null),f(null),v(!0);try{const h=await l.uploadSkill(p);f(`Skill "${h.skill.name}" uploaded successfully!`),z(),j.current&&(j.current.value="")}catch(h){k({error:h.message||"Upload failed",details:h.details})}finally{v(!1)}}},C=()=>{k(null),f(null),N(!0)};return e.jsxs(n.div,{variants:U,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.div,{variants:g,className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.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:e.jsx(y,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Skills"}),e.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:[m.length," skill",m.length!==1?"s":"",", ",E," enabled"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:C,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-azure-primary dark:border-matrix-primary text-azure-primary dark:text-matrix-primary font-medium hover:bg-azure-primary/10 dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload"]}),e.jsxs("button",{onClick:R,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(b,{className:"w-4 h-4"}),"Reload"]})]})]}),D?e.jsxs(n.div,{variants:g,className:"text-center py-12",children:[e.jsx(b,{className:"w-8 h-8 animate-spin mx-auto text-azure-text-secondary dark:text-matrix-dim"}),e.jsx("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-dim",children:"Loading skills..."})]}):m.length===0?e.jsxs(n.div,{variants:g,className:"rounded-lg border border-dashed border-azure-border dark:border-matrix-primary p-8 text-center",children:[e.jsx(y,{className:"w-12 h-12 mx-auto text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("h3",{className:"mt-4 text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:"No skills found"}),e.jsxs("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-secondary max-w-md mx-auto",children:["Upload a skill ZIP or add skills manually to"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"~/.morpheus/skills/"}),". Each skill folder must contain a"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file with frontmatter."]}),e.jsxs("button",{onClick:C,className:"mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload Skill"]})]}):e.jsx(n.div,{variants:U,initial:"hidden",animate:"show",className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:m.map(a=>e.jsx(M,{skill:a,onToggle:()=>T(a),onView:()=>$(a)},a.name))}),e.jsx(Q,{skill:r,open:!!r,onOpenChange:a=>!a&&i(null)}),e.jsxs(K,{open:x,onOpenChange:N,children:[e.jsx(O,{children:e.jsx(V,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5"}),"Upload Skill"]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm",children:["Upload a ZIP file containing your skill folder. The ZIP must have exactly one folder at root level with a valid ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file."]}),e.jsxs("div",{className:"border-2 border-dashed border-azure-border dark:border-matrix-primary rounded-lg p-6",children:[e.jsx("input",{ref:j,type:"file",accept:".zip,application/zip,application/x-zip-compressed",onChange:P,disabled:o,className:"hidden",id:"skill-upload-input"}),e.jsxs("label",{htmlFor:"skill-upload-input",className:`flex flex-col items-center gap-2 cursor-pointer ${o?"opacity-50 cursor-not-allowed":""}`,children:[o?e.jsx(b,{className:"w-8 h-8 animate-spin text-azure-primary dark:text-matrix-primary"}):e.jsx(u,{className:"w-8 h-8 text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:o?"Uploading...":"Click to select ZIP file"})]})]}),c&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800",children:[e.jsx(W,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:c.error}),c.details&&e.jsx("p",{className:"text-xs text-red-600 dark:text-red-300 mt-1",children:c.details})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800",children:[e.jsx(F,{className:"w-5 h-5 text-green-600 dark:text-green-400"}),e.jsx("p",{className:"text-sm text-green-800 dark:text-green-200",children:w})]}),e.jsxs("div",{className:"rounded-lg bg-azure-hover dark:bg-zinc-900 p-3",children:[e.jsx("h4",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight mb-2",children:"ZIP Structure Example"}),e.jsx("pre",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:`my-skill.zip
2
2
  └── my-skill/
3
3
  ├── SKILL.md (required)
4
4
  ├── scripts/ (optional)
@@ -0,0 +1 @@
1
+ import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as c}from"./vendor-react-DikRIOlj.js";import{u as O}from"./vendor-utils-D4NnWbOU.js";import{c as b}from"./config-BwTXe5M2.js";import{S as Y,T as C}from"./SelectInput-KVLsnfra.js";import{S as V,N as w}from"./Switch-CJTE4ZQm.js";import{C as Z}from"./ConfirmationModal-CxLP8iC6.js";import{h as ee,a2 as $,H as _,Q as te,am as H,a6 as I,ac as re,an as q,ad as ae,ao as se,ap as ie,aq as ne,w as le,z as de,l as oe,ar as ce,g as me,ae as xe,I as he,X as ue}from"./vendor-icons-NHF9HNeN.js";import"./index-BcX5O7kY.js";const ge={name:"",host:"",port:7900,auth_token:"",tls:!1};function be(t){const n=Math.floor(t/86400),i=Math.floor(t%86400/3600),o=Math.floor(t%3600/60);return n>0?`${n}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function pe(t,n){const i=t>=1024?`${(t/1024).toFixed(1)}GB`:`${Math.round(t)}MB`,o=n>=1024?`${(n/1024).toFixed(1)}GB`:`${Math.round(n)}MB`;return`${i} / ${o}`}function fe({state:t}){return t==="online"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"online"]}):t==="connecting"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),"connecting"]}):t==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-red-500 bg-red-500/10 border border-red-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"error"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-zinc-500 bg-zinc-500/10 border border-zinc-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-500"}),"offline"]})}function je({cap:t}){const i={filesystem:"text-blue-400 bg-blue-400/10 border-blue-400/30",shell:"text-yellow-400 bg-yellow-400/10 border-yellow-400/30",git:"text-orange-400 bg-orange-400/10 border-orange-400/30",browser:"text-purple-400 bg-purple-400/10 border-purple-400/30",network:"text-cyan-400 bg-cyan-400/10 border-cyan-400/30",packages:"text-green-400 bg-green-400/10 border-green-400/30",processes:"text-pink-400 bg-pink-400/10 border-pink-400/30",system:"text-indigo-400 bg-indigo-400/10 border-indigo-400/30"}[t]??"text-zinc-400 bg-zinc-400/10 border-zinc-400/30";return e.jsx("span",{className:`text-[10px] font-medium border rounded px-1.5 py-0.5 ${i}`,children:t})}function ye({status:t,entry:n,onPing:i,onEdit:o,onDelete:a}){const[l,h]=c.useState(!1),s=t.state==="online";return e.jsxs("div",{className:`rounded-lg border bg-white dark:bg-zinc-900 shadow-sm transition-all ${s?"border-emerald-500/40 dark:border-emerald-500/30":t.state==="error"?"border-red-500/40 dark:border-red-500/30":t.state==="connecting"?"border-amber-500/40 dark:border-amber-500/30":"border-azure-border dark:border-matrix-primary"}`,children:[e.jsxs("div",{className:"p-4 bg-white dark:bg-zinc-900 shadow-sm rounded-tl-lg rounded-tr-lg",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${s?"bg-emerald-500/10":"bg-zinc-100 dark:bg-zinc-900"}`,children:e.jsx(ie,{className:`w-4 h-4 ${s?"text-emerald-500":"text-zinc-400 dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-highlight truncate",children:t.name}),e.jsx(fe,{state:t.state}),n?.tls&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded px-1.5 py-0.5",children:[e.jsx(ne,{className:"w-2.5 h-2.5"}),"TLS"]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:[t.host,":",t.port]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>i(t.name),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Ping",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>o(n??{name:t.name,host:t.host,port:t.port,auth_token:"",tls:!1}),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Edit",children:e.jsx(le,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>a(t.name),className:"p-1.5 rounded border border-red-200 dark:border-red-800/50 text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-500 transition-colors",title:"Remove",children:e.jsx(de,{className:"w-3.5 h-3.5"})})]})]}),t.error&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded p-2",children:[e.jsx($,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{children:t.error})]}),s&&t.stats&&e.jsx("div",{className:"mt-3 space-y-2",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"OS"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:t.stats.os})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Hostname"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate max-w-[120px]",children:t.stats.hostname})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(oe,{className:"w-3 h-3"})," CPU"]}),e.jsxs("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:[t.stats.cpu_percent.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(ce,{className:"w-3 h-3"})," RAM"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:pe(t.stats.memory_used_mb,t.stats.memory_total_mb)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(me,{className:"w-3 h-3"})," Uptime"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:be(t.stats.uptime_seconds)})]}),t.config?.sandbox_dir&&e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:"Sandbox"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate text-right ml-2",children:t.config.sandbox_dir})]}),t.config&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Read-only"}),e.jsx("span",{className:`font-medium ${t.config.readonly_mode?"text-amber-500":"text-emerald-500"}`,children:t.config.readonly_mode?"yes":"no"})]})]})}),!s&&t.lastSeen&&e.jsxs("div",{className:"mt-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]}),t.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>h(!l),className:"w-full flex items-center justify-between px-4 py-2 border-t border-azure-border dark:border-matrix-primary/30 text-xs text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-secondary hover:bg-azure-surface/50 dark:hover:bg-zinc-900/50 transition-colors",children:[e.jsxs("span",{children:["Capabilities (",t.capabilities.length,")"]}),l?e.jsx(xe,{className:"w-3.5 h-3.5"}):e.jsx(he,{className:"w-3.5 h-3.5"})]}),l&&e.jsxs("div",{className:"px-4 pb-4 pt-3 border-t border-azure-border dark:border-matrix-primary/30 bg-azure-surface/30 dark:bg-zinc-900/30",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.capabilities.map(x=>e.jsx(je,{cap:x},x))}),t.lastSeen&&e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-3",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]})]})]})}function U({title:t,initial:n,isEdit:i,onSave:o,onClose:a,saving:l,error:h}){const[s,x]=c.useState(n),[j,p]=c.useState(null),f=()=>{if(!s.name.trim()){p("Name is required.");return}if(!s.host.trim()){p("Host is required.");return}if(!i&&!s.auth_token.trim()){p("Auth token is required.");return}p(null),o(s)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsxs("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(_,{className:"w-4 h-4"}),t]}),e.jsx("button",{onClick:a,className:"text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:e.jsx(ue,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[(j||h)&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-500 bg-red-500/10 border border-red-500/20 rounded p-3",children:[e.jsx($,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsx("span",{children:j||h})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(C,{label:"Name",value:s.name,onChange:m=>x({...s,name:m.target.value}),disabled:i,helperText:i?"Name cannot be changed after creation.":"Unique identifier (lowercase, hyphens ok)."})}),e.jsx(C,{label:"Host",value:s.host,onChange:m=>x({...s,host:m.target.value}),placeholder:"localhost"}),e.jsx(w,{label:"Port",value:s.port,onChange:m=>x({...s,port:Number(m.target.value)}),min:1,max:65535}),e.jsx("div",{className:"col-span-2",children:e.jsx(C,{label:"Auth Token",value:s.auth_token,onChange:m=>x({...s,auth_token:m.target.value}),placeholder:i?"Leave blank to keep existing token":"Shared secret",helperText:i?"Leave blank to keep the current token.":void 0})})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("input",{type:"checkbox",id:"smith-tls",checked:s.tls??!1,onChange:m=>x({...s,tls:m.target.checked}),className:"w-4 h-4 accent-azure-primary dark:accent-matrix-highlight"}),e.jsxs("label",{htmlFor:"smith-tls",className:"text-sm text-azure-text-secondary dark:text-matrix-secondary cursor-pointer",children:["Use TLS (",e.jsx("code",{className:"text-xs font-mono",children:"wss://"}),")"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 rounded text-sm text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:"Cancel"}),e.jsx("button",{onClick:f,disabled:l,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:l?"Saving…":i?"Update Smith":"Add Smith"})]})]})})}function Te(){const{data:t,mutate:n}=O("/api/smiths",b.getSmithsList,{refreshInterval:1e4}),{data:i,mutate:o}=O("/api/smiths/config",b.getSmithsConfig),[a,l]=c.useState(null),[h,s]=c.useState(!1),[x,j]=c.useState(!1),[p,f]=c.useState(!1),[m,z]=c.useState(null),[T,v]=c.useState(!1),[M,u]=c.useState(null),[N,A]=c.useState(null),[B,L]=c.useState(!1),[y,S]=c.useState(null);i&&!a&&l(i);const g=(r,d)=>{A({type:r,message:d}),setTimeout(()=>A(null),4e3)},G=async r=>{try{const d=await b.pingSmith(r);g("success",`Ping ${r}: ${d.latency_ms}ms`)}catch(d){g("error",`Ping failed: ${d.message}`)}},W=r=>{S(r)},K=async()=>{if(y)try{await b.removeSmith(y),n(),o(),l(null),g("success",`Smith "${y}" removed.`)}catch(r){g("error",`Failed to remove: ${r.message}`)}finally{S(null)}},J=async r=>{if(a){if(a.entries.some(d=>d.name===r.name)){u(`Smith "${r.name}" already exists.`);return}v(!0),u(null);try{const d={...a,entries:[...a.entries,r]};await b.updateSmithsConfig(d),f(!1),l(null),n(),o(),g("success",`Smith "${r.name}" added.`)}catch(d){u(d.message)}finally{v(!1)}}},Q=async r=>{if(a){v(!0),u(null);try{const d={...a,entries:a.entries.map(F=>F.name===r.name?r:F)};await b.updateSmithsConfig(d),z(null),l(null),n(),o(),g("success",`Smith "${r.name}" updated.`)}catch(d){u(d.message)}finally{v(!1)}}},X=async()=>{if(a){j(!0);try{await b.updateSmithsConfig(a),n(),o(),g("success","Settings saved."),s(!1)}catch(r){g("error",r.message)}finally{j(!1)}}},k=t?.smiths??[],P=k.filter(r=>r.state==="online").length,E=k.filter(r=>r.state==="offline"||r.state==="error").length,R=k.filter(r=>r.state==="connecting").length,D={};return(a??i)?.entries?.forEach(r=>{D[r.name]=r}),e.jsxs("div",{className:"space-y-6",children:[N&&e.jsxs("div",{className:`fixed top-4 right-4 z-50 flex items-center gap-2 px-4 py-3 rounded-lg shadow-xl text-sm border ${N.type==="success"?"bg-emerald-50 dark:bg-emerald-900/30 border-emerald-300 dark:border-emerald-500/50 text-emerald-700 dark:text-emerald-400":"bg-red-50 dark:bg-red-900/30 border-red-300 dark:border-red-500/50 text-red-700 dark:text-red-400"}`,children:[N.type==="success"?e.jsx(ee,{className:"w-4 h-4"}):e.jsx($,{className:"w-4 h-4"}),N.message]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.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:e.jsx(_,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Smiths"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Remote DevKit agents via WebSocket"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:async()=>{L(!0),await Promise.all([n(),o(),new Promise(r=>setTimeout(r,500))]),L(!1)},className:"p-2 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",title:"Refresh",children:e.jsx(te,{className:`w-4 h-4 transition-transform ${B?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{s(!h),!a&&i&&l(i)},className:`flex items-center gap-1.5 px-3 py-2 rounded border text-sm transition-colors ${h?"bg-azure-primary/10 border-azure-primary dark:bg-matrix-highlight/10 dark:border-matrix-highlight text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight"}`,children:[e.jsx(H,{className:"w-4 h-4"}),"Settings"]}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-1.5 px-3 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 text-sm font-medium transition-colors",children:[e.jsx(I,{className:"w-4 h-4"}),"Add Smith"]})]})]}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Total"}),e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-secondary",children:t.total})]}),P>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(re,{className:"w-3.5 h-3.5 text-emerald-500"}),e.jsxs("span",{className:"font-semibold text-emerald-500",children:[P," online"]})]}),R>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(q,{className:"w-3.5 h-3.5 text-amber-500"}),e.jsxs("span",{className:"font-semibold text-amber-500",children:[R," connecting"]})]}),E>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(ae,{className:"w-3.5 h-3.5 text-zinc-400 dark:text-matrix-tertiary"}),e.jsxs("span",{className:"font-semibold text-zinc-500 dark:text-matrix-tertiary",children:[E," offline"]})]}),!t.enabled&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2.5 py-0.5",children:[e.jsx(se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Smiths subsystem disabled"})]})]}),h&&a&&e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-5 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-sm font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4"}),"Global Settings"]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx("div",{className:"sm:col-span-2",children:e.jsx(V,{label:"Enable Smiths",checked:a.enabled,onChange:r=>l({...a,enabled:r}),helperText:"Master switch — disabling stops all Smith connections."})}),e.jsx(Y,{label:"Execution Mode",value:a.execution_mode,onChange:r=>l({...a,execution_mode:r.target.value}),options:[{label:"Sync — inline result",value:"sync"},{label:"Async — background task",value:"async"}]}),e.jsx(w,{label:"Heartbeat Interval (s)",value:Math.round(a.heartbeat_interval_ms/1e3),onChange:r=>l({...a,heartbeat_interval_ms:Number(r.target.value)*1e3}),min:5}),e.jsx(w,{label:"Connection Timeout (s)",value:Math.round(a.connection_timeout_ms/1e3),onChange:r=>l({...a,connection_timeout_ms:Number(r.target.value)*1e3}),min:1}),e.jsx(w,{label:"Task Timeout (s)",value:Math.round(a.task_timeout_ms/1e3),onChange:r=>l({...a,task_timeout_ms:Number(r.target.value)*1e3}),min:5})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx("button",{onClick:X,disabled:x,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:x?"Saving…":"Save Settings"})})]}),k.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary flex items-center justify-center mb-4",children:e.jsx(_,{className:"w-7 h-7 text-azure-text-secondary dark:text-matrix-tertiary"})}),e.jsx("h3",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight mb-1",children:"No Smiths configured"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mb-4",children:"Add a remote agent to delegate DevKit tasks to isolated environments."}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-2 px-4 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black text-sm font-medium transition-colors",children:[e.jsx(I,{className:"w-4 h-4"}),"Add First Smith"]})]}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:k.map(r=>e.jsx(ye,{status:r,entry:D[r.name],onPing:G,onEdit:d=>{z({...d,auth_token:""}),u(null)},onDelete:W},r.name))}),p&&e.jsx(U,{title:"Add Smith",initial:ge,onSave:J,onClose:()=>f(!1),saving:T,error:M}),m&&e.jsx(U,{title:"Edit Smith",initial:m,isEdit:!0,onSave:Q,onClose:()=>z(null),saving:T,error:M}),e.jsx(Z,{isOpen:!!y,onClose:()=>S(null),onConfirm:K,title:"Remove Smith",description:`Are you sure you want to remove "${y}" from the registry? This action cannot be undone.`,confirmJson:"Remove",variant:"destructive"})]})}export{Te as SmithsPage};
@@ -0,0 +1 @@
1
+ import{j as r}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{t as i}from"./vendor-utils-D4NnWbOU.js";function l({label:n,error:t,helperText:a,className:s,...e}){return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-secondary",children:n}),r.jsx("input",{type:"number",className:i("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",t&&"border-red-500 focus:border-red-500 focus:ring-red-500",s),...e}),a&&!t&&r.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:a}),t&&r.jsx("p",{className:"text-xs text-red-500",children:t})]})}function d({label:n,checked:t,onChange:a,helperText:s,disabled:e}){return r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:i("text-sm font-medium text-azure-text-primary/80 dark:text-matrix-highlight/80",e&&"opacity-50"),children:n}),s&&r.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:s})]}),r.jsx("button",{type:"button",role:"switch","aria-checked":t,onClick:()=>!e&&a(!t),className:i("relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:ring-offset-2 focus:ring-offset-azure-bg dark:focus:ring-offset-black",t?"bg-azure-primary dark:bg-matrix-highlight":"bg-slate-300 dark:bg-matrix-primary",e&&"opacity-50 cursor-not-allowed"),children:r.jsx("span",{className:i("inline-block h-4 w-4 transform rounded-full bg-white dark:bg-black transition-transform",t?"translate-x-6":"translate-x-1")})})]})}export{l as N,d as S};