adam-agent-server 1.18.0 → 1.19.0

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 (131) hide show
  1. package/dist/{App-SIQUVFJY.js → App-522DTURQ.js} +10 -10
  2. package/dist/approval-handler-S3NV7OPO.js +1 -0
  3. package/dist/{artifacts-MAYKOTA2.js → artifacts-NFMM3ORE.js} +1 -1
  4. package/dist/audit-diagnostics-IHU3CJYZ.js +1 -0
  5. package/dist/audit-manager-MUMEEP3C.js +1 -0
  6. package/dist/bree-engine-EEKUQA3U.js +1 -0
  7. package/dist/channels-IDBWHLLE.js +1 -0
  8. package/dist/{channels-2TWTBE6Y.js → channels-ZHCTFSDA.js} +1 -1
  9. package/dist/chat-tool-calls-4BQWZCJH.js +1 -0
  10. package/dist/{chunk-Z2APBKIT.js → chunk-2JM3URDG.js} +1 -1
  11. package/dist/{chunk-OBD4245G.js → chunk-4G4CKAXY.js} +1 -1
  12. package/dist/{chunk-2CE2WUUZ.js → chunk-4ZESWP3J.js} +1 -1
  13. package/dist/{chunk-QYI44EP6.js → chunk-4ZG4UMAK.js} +1 -1
  14. package/dist/{chunk-BE653A45.js → chunk-6GYNUTPP.js} +1 -1
  15. package/dist/{chunk-JROGEBP5.js → chunk-76MMY2XC.js} +1 -1
  16. package/dist/{chunk-BMCNQGUH.js → chunk-7QT2ZX3K.js} +1 -1
  17. package/dist/{chunk-SGLZAIVL.js → chunk-A3YUIWLK.js} +1 -1
  18. package/dist/{chunk-HL373H4P.js → chunk-AMJJ2WGU.js} +1 -1
  19. package/dist/{chunk-NUOTFUNF.js → chunk-CN5NEJXG.js} +1 -1
  20. package/dist/{chunk-O6L4UVLV.js → chunk-DFTRUOT6.js} +1 -1
  21. package/dist/{chunk-JYZTIE2J.js → chunk-DRS5NOAA.js} +1 -1
  22. package/dist/{chunk-6WQFYV3N.js → chunk-EBZCHLYS.js} +1 -1
  23. package/dist/{chunk-SKHMWKJT.js → chunk-EPLSB63A.js} +1 -1
  24. package/dist/{chunk-V2MMQ3SH.js → chunk-FN64ZULV.js} +1 -1
  25. package/dist/chunk-FQHGIY3E.js +1 -0
  26. package/dist/{chunk-NSUXJ2VA.js → chunk-GQS3ED3B.js} +1 -1
  27. package/dist/{chunk-LKGYQJMS.js → chunk-HEHST2E2.js} +1 -1
  28. package/dist/chunk-IAGTZGGV.js +32 -0
  29. package/dist/chunk-ITVCPC7G.js +1 -0
  30. package/dist/{chunk-NXGR3PRY.js → chunk-J2VSAXVU.js} +1 -1
  31. package/dist/{chunk-5G64P4KE.js → chunk-JRRNGKDK.js} +1 -1
  32. package/dist/{chunk-KS24764D.js → chunk-JVYSSJKT.js} +2 -2
  33. package/dist/chunk-JXZCQ5XW.js +1 -0
  34. package/dist/{chunk-LCD5DVS6.js → chunk-KM4EFB4N.js} +1 -1
  35. package/dist/chunk-KQMKRRYW.js +143 -0
  36. package/dist/{chunk-4JHACUZY.js → chunk-L4APYD5A.js} +1 -1
  37. package/dist/{chunk-WY5BOCQP.js → chunk-LMQPGVM7.js} +16 -16
  38. package/dist/chunk-MMVDXKYS.js +14 -0
  39. package/dist/chunk-NKS7LEA7.js +182 -0
  40. package/dist/{chunk-VWX2B6OM.js → chunk-ORFLN4BF.js} +1 -1
  41. package/dist/{chunk-2JIQT2CI.js → chunk-PO66F7UQ.js} +1 -1
  42. package/dist/{chunk-XAPJJAJQ.js → chunk-QJXV4SQE.js} +1 -1
  43. package/dist/{chunk-UCUELFCS.js → chunk-R7Q6FSV4.js} +1 -1
  44. package/dist/{chunk-47HJPIUA.js → chunk-T7EKW3B7.js} +1 -1
  45. package/dist/{chunk-JZBXLN7M.js → chunk-VOH52UDS.js} +1 -1
  46. package/dist/{chunk-HRPMRWHD.js → chunk-VZL2DGC4.js} +1 -1
  47. package/dist/{chunk-IEBAOZED.js → chunk-WDMSZS4W.js} +1 -1
  48. package/dist/{chunk-2A2TXYT3.js → chunk-WG3C43QS.js} +3 -3
  49. package/dist/{chunk-TA5PFK5C.js → chunk-YEGUFMLJ.js} +1 -1
  50. package/dist/{chunk-ZQN6JZIJ.js → chunk-ZGA52HRD.js} +1 -1
  51. package/dist/cli.js +2 -2
  52. package/dist/{config-U624HJKI.js → config-GOJLI3X2.js} +1 -1
  53. package/dist/config-Z6KFEFJO.js +1 -0
  54. package/dist/db-ROXIYW5B.js +1 -0
  55. package/dist/{delivery-log-QMQQHES4.js → delivery-log-TGJZ5HU7.js} +1 -1
  56. package/dist/engine-GN7PJPGQ.js +1 -0
  57. package/dist/{evolution-audit-XF4KZZMP.js → evolution-audit-TFJF666X.js} +1 -1
  58. package/dist/execution-tools-BQD2O25X.js +1 -0
  59. package/dist/{external-api-435WH6V3.js → external-api-DSLQDRZ2.js} +1 -1
  60. package/dist/index.js +41 -39
  61. package/dist/{learner-4CJ7BSCN.js → learner-ACBX3GI7.js} +1 -1
  62. package/dist/{memories-NJFKSOL5.js → memories-RAIR5O2F.js} +1 -1
  63. package/dist/{memory-extractor-UQI75BBK.js → memory-extractor-A6CAOFOX.js} +1 -1
  64. package/dist/{memory-gc-NTZVUGJX.js → memory-gc-W63MGSDH.js} +1 -1
  65. package/dist/memory-service-H4OFUNCF.js +1 -0
  66. package/dist/outbound-gateway-LKRQYPA2.js +1 -0
  67. package/dist/presets-FO6RSGDN.js +1 -0
  68. package/dist/{reflection-job-F4BZA2E3.js → reflection-job-XC2F7GTT.js} +1 -1
  69. package/dist/role-presets-SDA664QG.js +1 -0
  70. package/dist/role-workspace-NGJEJG3H.js +1 -0
  71. package/dist/{roles-WDMUBWQP.js → roles-LZCJ7QFS.js} +1 -1
  72. package/dist/{session-manager-XFUKWEC7.js → session-manager-PU4GH3E4.js} +1 -1
  73. package/dist/skill-registry-XKLE2LXU.js +1 -0
  74. package/dist/{task-templates-BIVCRNXA.js → task-templates-52LAC6OA.js} +1 -1
  75. package/dist/template-dispatch-PJFSWEO2.js +1 -0
  76. package/package.json +1 -1
  77. package/web/dist/assets/{ChannelDetail-D0FBZoAX.js → ChannelDetail-CSq9o5fq.js} +1 -1
  78. package/web/dist/assets/{Channels-Cztxvsa2.js → Channels-CAxTh1Bp.js} +1 -1
  79. package/web/dist/assets/Chat-PUz41HFr.js +2 -0
  80. package/web/dist/assets/{Cost-K8-4xqBe.js → Cost-BHcsPz5T.js} +1 -1
  81. package/web/dist/assets/{Dashboard-BXqFb_Vr.js → Dashboard-BT39_iWc.js} +1 -1
  82. package/web/dist/assets/{EnvVarEditor-FiiJazzp.js → EnvVarEditor-D_1d7bTJ.js} +1 -1
  83. package/web/dist/assets/{EventDefDetail-C3S1G0K8.js → EventDefDetail-jKN3gO_7.js} +1 -1
  84. package/web/dist/assets/{Events-BKxqZ9j6.js → Events-CpeHg3fh.js} +1 -1
  85. package/web/dist/assets/{Evolution-DFcSm6Rw.js → Evolution-DsWyv2_a.js} +1 -1
  86. package/web/dist/assets/{ExtensionDetail-C8aPpyLv.js → ExtensionDetail-CJHNaNii.js} +1 -1
  87. package/web/dist/assets/{Extensions-MLZk05j0.js → Extensions-Pg2vx_ZK.js} +1 -1
  88. package/web/dist/assets/{FeatureRequests-D_4XaQ7F.js → FeatureRequests-3Yl8wTNT.js} +1 -1
  89. package/web/dist/assets/{GoalDetail-DVU7c0aR.js → GoalDetail-L3T1zqqs.js} +1 -1
  90. package/web/dist/assets/{Goals-D3h4WMjU.js → Goals-B-__r-Yq.js} +1 -1
  91. package/web/dist/assets/{Logs-D5MQv6Yw.js → Logs-CMkjUkmu.js} +1 -1
  92. package/web/dist/assets/{Memories-Dls71I2i.js → Memories-Q1eKfPQ2.js} +1 -1
  93. package/web/dist/assets/{Mistakes-BZcTg0vP.js → Mistakes-BROkixt_.js} +1 -1
  94. package/web/dist/assets/{Plugins-CwCHGzI6.js → Plugins-v17MyPVe.js} +1 -1
  95. package/web/dist/assets/{RoleDetail-B2M6ALSl.js → RoleDetail-DCGFBLP1.js} +2 -2
  96. package/web/dist/assets/{Roles-FEHqm_Jf.js → Roles-C7SNebvY.js} +1 -1
  97. package/web/dist/assets/{Settings-rdVQMfqX.js → Settings-QuKwKbKg.js} +1 -1
  98. package/web/dist/assets/{Strategies-CwJ9JQ-X.js → Strategies-CXQYvCkc.js} +1 -1
  99. package/web/dist/assets/{Switch-1JjR4Imr.js → Switch--h1rqagh.js} +1 -1
  100. package/web/dist/assets/{TaskDetail-h12WxjfG.js → TaskDetail-B0G5ZjDD.js} +1 -1
  101. package/web/dist/assets/{Work-CfzFRSZX.js → Work-DbFst_9-.js} +1 -1
  102. package/web/dist/assets/index-D35OGE0z.css +2 -0
  103. package/web/dist/assets/{index-CXEJd-0s.js → index-Dd3NDYZR.js} +2 -2
  104. package/web/dist/assets/{usePluginsWithUsage-4iLJAPjH.js → usePluginsWithUsage-DpTxJuFQ.js} +1 -1
  105. package/web/dist/index.html +2 -2
  106. package/dist/approval-handler-BWA7UIKN.js +0 -1
  107. package/dist/audit-diagnostics-K3LUWXTI.js +0 -1
  108. package/dist/audit-manager-6WL2V6JG.js +0 -1
  109. package/dist/bree-engine-KYD4GKQK.js +0 -1
  110. package/dist/channels-PWDSTYNR.js +0 -1
  111. package/dist/chat-tool-calls-WJDFQ54U.js +0 -1
  112. package/dist/chunk-3UFEOB6P.js +0 -143
  113. package/dist/chunk-MTRLUW7Z.js +0 -1
  114. package/dist/chunk-QTGAK62Z.js +0 -14
  115. package/dist/chunk-TWOJVEO7.js +0 -32
  116. package/dist/chunk-VO24C673.js +0 -1
  117. package/dist/chunk-VPMHZJS2.js +0 -1
  118. package/dist/chunk-ZJ3TS4FL.js +0 -182
  119. package/dist/config-X7A6NA73.js +0 -1
  120. package/dist/db-XODNIJSJ.js +0 -1
  121. package/dist/engine-OQXDHA2R.js +0 -1
  122. package/dist/execution-tools-BR4T4MMW.js +0 -1
  123. package/dist/memory-service-3RLVOF2C.js +0 -1
  124. package/dist/outbound-gateway-NJNSN2ZX.js +0 -1
  125. package/dist/presets-SUJRFRJC.js +0 -1
  126. package/dist/role-presets-VEYTGYA4.js +0 -1
  127. package/dist/role-workspace-AIVHPX5P.js +0 -1
  128. package/dist/skill-registry-LARMNUT5.js +0 -1
  129. package/dist/template-dispatch-6FPJQN6A.js +0 -1
  130. package/web/dist/assets/Chat-Ce72TtUi.js +0 -2
  131. package/web/dist/assets/index-CarTGiGO.css +0 -2
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{ft as t,l as n,pt as r,xt as i,z as a}from"./vendor-icons-Bc_e_XXa.js";import{d as o,f as s,t as c}from"./vendor-react-bQ_cvNuA.js";import{t as l}from"./Button-CRNb8sD3.js";import{o as u,u as d}from"./api-BP4ZP9kk.js";import{p as f}from"./index-CXEJd-0s.js";import{t as p}from"./Card-Cwvv0An8.js";import{t as m}from"./PageHeader-acLQTYct.js";import{t as h}from"./ui-D1crlGpt.js";var g=e(i(),1),_=c();function v({meta:e}){let[n,i]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`button`,{className:`flex items-center gap-1 text-xs text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>i(e=>!e),children:[n?(0,_.jsx)(r,{size:12}):(0,_.jsx)(t,{size:12}),`_meta`]}),n&&(0,_.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-lg bg-black/20 p-3 text-xs text-[var(--app-text-muted)]`,children:JSON.stringify(e,null,2)})]})}function y({fieldKey:e,field:t,value:n}){let r=n==null?t.default===void 0?``:String(t.default):String(n);return(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`label`,{className:`text-xs font-medium text-[var(--app-text)]`,children:[t.title,t.required&&(0,_.jsx)(`span`,{className:`ml-1 text-red-400`,children:`*`}),t.sensitive&&(0,_.jsx)(`span`,{className:`ml-1 text-[var(--app-text-subtle)]`,children:`(sensitive)`})]}),t.description&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t.description}),(0,_.jsx)(`input`,{type:t.sensitive?`password`:`text`,readOnly:!0,defaultValue:r,placeholder:`${e}`,className:`w-full rounded-lg border border-[var(--app-border)] bg-black/20 px-3 py-1.5 text-xs text-[var(--app-text)] outline-none`})]})}function b(){let{name:e}=s(),t=o(),[r,i]=(0,g.useState)(null),[c,b]=(0,g.useState)(null),[x,S]=(0,g.useState)(!0),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1),D=(0,g.useCallback)(async()=>{if(e){S(!0);try{let t=await d(e);i(t);try{b(JSON.parse(t.manifestJson))}catch{}}catch{f.error(`Extension not found`),t(`/extensions`)}finally{S(!1)}}},[e,t]);(0,g.useEffect)(()=>{D()},[D]);async function O(){if(r){w(!0);try{await u(r.name),f.success(`Uninstalled ${r.name}`),t(`/extensions`)}catch{f.error(`Failed to uninstall extension`),w(!1)}}}if(x)return(0,_.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,_.jsx)(a,{size:24,className:`animate-spin text-[var(--app-text-subtle)]`})});if(!r||!c)return null;let k=(()=>{try{return r.defaultConfigJson?JSON.parse(r.defaultConfigJson):{}}catch{return{}}})();return(0,_.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,_.jsx)(m,{title:c.display_name??r.name,description:`v${r.version} · Source: ${r.installSource}`,actions:(0,_.jsxs)(l,{variant:`destructive`,onClick:()=>E(!0),disabled:C,children:[(0,_.jsx)(n,{size:h.md}),`卸载`]})}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto space-y-4 p-4`,children:[(0,_.jsxs)(p,{className:`p-4 space-y-2`,children:[(0,_.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:c.description}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-[var(--app-text-subtle)]`,children:[(0,_.jsxs)(`span`,{children:[`Author: `,c.author.name]}),c.author.email&&(0,_.jsx)(`span`,{children:c.author.email}),c.homepage&&(0,_.jsx)(`a`,{href:c.homepage,target:`_blank`,rel:`noreferrer`,className:`text-[var(--app-accent)] hover:underline`,children:`Homepage`})]})]}),c.tools&&c.tools.length>0&&(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsxs)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:[`Tools (`,c.tools.length,`)`]}),(0,_.jsx)(`div`,{className:`space-y-2`,children:c.tools.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,_.jsx)(`p`,{className:`font-mono text-xs font-medium text-[var(--app-text)]`,children:e.name}),e.description&&(0,_.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--app-text-muted)]`,children:e.description})]},e.name))})]}),c.user_config&&Object.keys(c.user_config).length>0&&(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:`Configuration`}),(0,_.jsx)(`div`,{className:`space-y-3`,children:Object.entries(c.user_config).map(([e,t])=>(0,_.jsx)(y,{fieldKey:e,field:t,value:k[e]},e))})]}),c._meta&&Object.keys(c._meta).length>0&&(0,_.jsx)(p,{className:`p-4`,children:(0,_.jsx)(v,{meta:c._meta})}),(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:`Server`}),(0,_.jsxs)(`div`,{className:`space-y-1 text-xs text-[var(--app-text)]`,children:[(0,_.jsxs)(`p`,{children:[`Type: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.type})]}),(0,_.jsxs)(`p`,{children:[`Command: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.mcp_config.command})]}),c.server.mcp_config.args&&c.server.mcp_config.args.length>0&&(0,_.jsxs)(`p`,{children:[`Args: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.mcp_config.args.join(` `)})]})]})]})]}),T&&(0,_.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,children:(0,_.jsxs)(`div`,{className:`w-full max-w-sm rounded-2xl border border-[var(--app-border)] bg-[var(--app-bg)] p-6 shadow-2xl`,children:[(0,_.jsx)(`h2`,{className:`mb-2 text-base font-semibold text-[var(--app-text)]`,children:`Uninstall extension?`}),(0,_.jsxs)(`p`,{className:`mb-4 text-sm text-[var(--app-text-subtle)]`,children:[`This will remove `,(0,_.jsx)(`strong`,{children:r.name}),` from the DB and delete its files from disk. This cannot be undone.`]}),(0,_.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,_.jsx)(l,{variant:`ghost`,onClick:()=>E(!1),disabled:C,children:`Cancel`}),(0,_.jsxs)(l,{variant:`destructive`,onClick:()=>void O(),disabled:C,children:[C?(0,_.jsx)(a,{size:h.md,className:`animate-spin`}):(0,_.jsx)(n,{size:h.md}),`Uninstall`]})]})]})})]})}export{b as ExtensionDetail};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{ft as t,l as n,pt as r,xt as i,z as a}from"./vendor-icons-Bc_e_XXa.js";import{d as o,f as s,t as c}from"./vendor-react-bQ_cvNuA.js";import{t as l}from"./Button-CRNb8sD3.js";import{o as u,u as d}from"./api-BP4ZP9kk.js";import{p as f}from"./index-Dd3NDYZR.js";import{t as p}from"./Card-Cwvv0An8.js";import{t as m}from"./PageHeader-acLQTYct.js";import{t as h}from"./ui-D1crlGpt.js";var g=e(i(),1),_=c();function v({meta:e}){let[n,i]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`button`,{className:`flex items-center gap-1 text-xs text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>i(e=>!e),children:[n?(0,_.jsx)(r,{size:12}):(0,_.jsx)(t,{size:12}),`_meta`]}),n&&(0,_.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-lg bg-black/20 p-3 text-xs text-[var(--app-text-muted)]`,children:JSON.stringify(e,null,2)})]})}function y({fieldKey:e,field:t,value:n}){let r=n==null?t.default===void 0?``:String(t.default):String(n);return(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`label`,{className:`text-xs font-medium text-[var(--app-text)]`,children:[t.title,t.required&&(0,_.jsx)(`span`,{className:`ml-1 text-red-400`,children:`*`}),t.sensitive&&(0,_.jsx)(`span`,{className:`ml-1 text-[var(--app-text-subtle)]`,children:`(sensitive)`})]}),t.description&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t.description}),(0,_.jsx)(`input`,{type:t.sensitive?`password`:`text`,readOnly:!0,defaultValue:r,placeholder:`${e}`,className:`w-full rounded-lg border border-[var(--app-border)] bg-black/20 px-3 py-1.5 text-xs text-[var(--app-text)] outline-none`})]})}function b(){let{name:e}=s(),t=o(),[r,i]=(0,g.useState)(null),[c,b]=(0,g.useState)(null),[x,S]=(0,g.useState)(!0),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1),D=(0,g.useCallback)(async()=>{if(e){S(!0);try{let t=await d(e);i(t);try{b(JSON.parse(t.manifestJson))}catch{}}catch{f.error(`Extension not found`),t(`/extensions`)}finally{S(!1)}}},[e,t]);(0,g.useEffect)(()=>{D()},[D]);async function O(){if(r){w(!0);try{await u(r.name),f.success(`Uninstalled ${r.name}`),t(`/extensions`)}catch{f.error(`Failed to uninstall extension`),w(!1)}}}if(x)return(0,_.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,_.jsx)(a,{size:24,className:`animate-spin text-[var(--app-text-subtle)]`})});if(!r||!c)return null;let k=(()=>{try{return r.defaultConfigJson?JSON.parse(r.defaultConfigJson):{}}catch{return{}}})();return(0,_.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,_.jsx)(m,{title:c.display_name??r.name,description:`v${r.version} · Source: ${r.installSource}`,actions:(0,_.jsxs)(l,{variant:`destructive`,onClick:()=>E(!0),disabled:C,children:[(0,_.jsx)(n,{size:h.md}),`卸载`]})}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto space-y-4 p-4`,children:[(0,_.jsxs)(p,{className:`p-4 space-y-2`,children:[(0,_.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:c.description}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-[var(--app-text-subtle)]`,children:[(0,_.jsxs)(`span`,{children:[`Author: `,c.author.name]}),c.author.email&&(0,_.jsx)(`span`,{children:c.author.email}),c.homepage&&(0,_.jsx)(`a`,{href:c.homepage,target:`_blank`,rel:`noreferrer`,className:`text-[var(--app-accent)] hover:underline`,children:`Homepage`})]})]}),c.tools&&c.tools.length>0&&(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsxs)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:[`Tools (`,c.tools.length,`)`]}),(0,_.jsx)(`div`,{className:`space-y-2`,children:c.tools.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,_.jsx)(`p`,{className:`font-mono text-xs font-medium text-[var(--app-text)]`,children:e.name}),e.description&&(0,_.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--app-text-muted)]`,children:e.description})]},e.name))})]}),c.user_config&&Object.keys(c.user_config).length>0&&(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:`Configuration`}),(0,_.jsx)(`div`,{className:`space-y-3`,children:Object.entries(c.user_config).map(([e,t])=>(0,_.jsx)(y,{fieldKey:e,field:t,value:k[e]},e))})]}),c._meta&&Object.keys(c._meta).length>0&&(0,_.jsx)(p,{className:`p-4`,children:(0,_.jsx)(v,{meta:c._meta})}),(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:`Server`}),(0,_.jsxs)(`div`,{className:`space-y-1 text-xs text-[var(--app-text)]`,children:[(0,_.jsxs)(`p`,{children:[`Type: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.type})]}),(0,_.jsxs)(`p`,{children:[`Command: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.mcp_config.command})]}),c.server.mcp_config.args&&c.server.mcp_config.args.length>0&&(0,_.jsxs)(`p`,{children:[`Args: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.mcp_config.args.join(` `)})]})]})]})]}),T&&(0,_.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,children:(0,_.jsxs)(`div`,{className:`w-full max-w-sm rounded-2xl border border-[var(--app-border)] bg-[var(--app-bg)] p-6 shadow-2xl`,children:[(0,_.jsx)(`h2`,{className:`mb-2 text-base font-semibold text-[var(--app-text)]`,children:`Uninstall extension?`}),(0,_.jsxs)(`p`,{className:`mb-4 text-sm text-[var(--app-text-subtle)]`,children:[`This will remove `,(0,_.jsx)(`strong`,{children:r.name}),` from the DB and delete its files from disk. This cannot be undone.`]}),(0,_.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,_.jsx)(l,{variant:`ghost`,onClick:()=>E(!1),disabled:C,children:`Cancel`}),(0,_.jsxs)(l,{variant:`destructive`,onClick:()=>void O(),disabled:C,children:[C?(0,_.jsx)(a,{size:h.md,className:`animate-spin`}):(0,_.jsx)(n,{size:h.md}),`Uninstall`]})]})]})})]})}export{b as ExtensionDetail};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{N as t,c as n,ft as r,n as i,pt as a,s as o,xt as s,z as c}from"./vendor-icons-Bc_e_XXa.js";import{d as l,t as u}from"./vendor-react-bQ_cvNuA.js";import{t as d}from"./Button-CRNb8sD3.js";import{f,i as p,p as m,w as h}from"./api-BP4ZP9kk.js";import{p as g}from"./index-CXEJd-0s.js";import{t as _}from"./Card-Cwvv0An8.js";import{t as v}from"./PageHeader-acLQTYct.js";import{t as y}from"./EmptyState-BvQA1o5K.js";import{t as b}from"./ui-D1crlGpt.js";var x=e(s(),1),S=u();function C({snapshot:e,onClear:t}){let[i,o]=(0,x.useState)(!1),[s,l]=(0,x.useState)(null);if(e.count===0)return null;async function u(e){l(e.roleId);try{await p(e.roleId),t(e.roleId),g.success(`Cleared legacy mcp_servers for ${e.roleName}`)}catch{g.error(`Failed to clear legacy mcp_servers`)}finally{l(null)}}return(0,S.jsxs)(`div`,{className:`mb-4 rounded-xl border border-yellow-500/30 bg-yellow-500/5 p-4`,children:[(0,S.jsxs)(`button`,{className:`flex w-full items-center gap-2 text-left`,onClick:()=>o(e=>!e),children:[(0,S.jsx)(n,{size:b.sm,className:`shrink-0 text-yellow-400`}),(0,S.jsxs)(`span`,{className:`flex-1 text-sm font-medium text-yellow-300`,children:[e.count,` role`,e.count===1?``:`s`,` with legacy`,` `,(0,S.jsx)(`code`,{className:`font-mono`,children:`mcp_servers`}),` field`]}),i?(0,S.jsx)(a,{size:b.sm,className:`text-yellow-400`}):(0,S.jsx)(r,{size:b.sm,className:`text-yellow-400`})]}),i&&(0,S.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,S.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`These roles have an inline `,(0,S.jsx)(`code`,{className:`font-mono`,children:`mcp_servers`}),` config that predates the Extensions system. Click "Clear" to zero it out — the column is preserved, only its value is reset to `,(0,S.jsx)(`code`,{className:`font-mono`,children:`{}`}),`.`]}),e.rows.map(e=>(0,S.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-[var(--app-border)] bg-black/20 px-3 py-2`,children:[(0,S.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:e.roleName}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void u(e),disabled:s===e.roleId,children:s===e.roleId?(0,S.jsx)(c,{size:b.sm,className:`animate-spin`}):`Clear`})]},e.roleId))]})]})}function w({onClose:e,onSuccess:t}){let n=(0,x.useRef)(null),[r,a]=(0,x.useState)(!1),[s,l]=(0,x.useState)(!1);async function u(n){if(!n.name.endsWith(`.mcpb`)){g.error(`Only .mcpb files are supported`);return}a(!0);try{let r=await h(n);t(r),g.success(`Installed extension: ${r.name} v${r.version}`),e()}catch(e){let t=e instanceof Error?e.message:`Upload failed`;g.error(t)}finally{a(!1)}}function f(e){let t=e.target.files?.[0];t&&u(t)}function p(e){e.preventDefault(),l(!1);let t=e.dataTransfer.files[0];t&&u(t)}return(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-[var(--app-border)] bg-[var(--app-bg)] p-6 shadow-2xl`,children:[(0,S.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,S.jsx)(`h2`,{className:`text-base font-semibold text-[var(--app-text)]`,children:`Import Extension`}),(0,S.jsx)(`button`,{onClick:e,className:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,children:(0,S.jsx)(i,{size:b.lg})})]}),(0,S.jsx)(`div`,{className:`flex min-h-[140px] cursor-pointer flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed p-6 transition-colors ${s?`border-[var(--app-accent)] bg-[var(--app-accent)]/10`:`border-[var(--app-border)] hover:border-[var(--app-text-subtle)]`}`,onClick:()=>n.current?.click(),onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:p,children:r?(0,S.jsx)(c,{size:32,className:`animate-spin text-[var(--app-accent)]`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{size:32,className:`text-[var(--app-text-subtle)]`}),(0,S.jsxs)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:[`Drop a `,(0,S.jsx)(`code`,{className:`font-mono`,children:`.mcpb`}),` file here, or click to browse`]})]})}),(0,S.jsx)(`input`,{ref:n,type:`file`,accept:`.mcpb`,className:`hidden`,onChange:f}),(0,S.jsx)(`div`,{className:`mt-4 flex justify-end gap-2`,children:(0,S.jsx)(d,{variant:`ghost`,onClick:e,disabled:r,children:`Cancel`})})]})})}function T({health:e}){return e?e.lastStatus===`success`?(0,S.jsx)(`span`,{title:`Last ok ${e.lastRunAt?new Date(e.lastRunAt).toLocaleString():``}`,className:`text-green-500 text-sm`,children:`✅`}):(0,S.jsx)(`span`,{title:e.lastError??`Failed`,className:`text-red-500 text-sm`,children:`❌`}):(0,S.jsx)(`span`,{title:`Never run`,className:`text-gray-500 text-sm`,children:`⏳`})}function E({extension:e}){let n=l(),r={};try{r=JSON.parse(e.manifestJson)}catch{}return(0,S.jsx)(_,{className:`cursor-pointer p-4 transition-colors hover:border-[var(--app-accent)]/50`,onClick:()=>n(`/extensions/${e.name}`),children:(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsx)(`p`,{className:`truncate font-medium text-[var(--app-text)]`,children:e.name}),(0,S.jsxs)(`p`,{className:`mt-0.5 text-xs text-[var(--app-text-subtle)]`,children:[`v`,e.version]}),r.description&&(0,S.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-[var(--app-text-muted)]`,children:r.description})]}),(0,S.jsxs)(`div`,{className:`flex flex-col items-end gap-1 shrink-0`,children:[(0,S.jsx)(T,{health:e.health}),(0,S.jsx)(t,{size:b.md,className:`mt-0.5 text-[var(--app-text-subtle)]`})]})]})})}function D(){let[e,n]=(0,x.useState)([]),[r,i]=(0,x.useState)({count:0,rows:[]}),[a,s]=(0,x.useState)(!0),[l,u]=(0,x.useState)(!1),p=(0,x.useCallback)(async()=>{s(!0);try{let[e,t]=await Promise.all([f(),m()]);n(e),i(t)}catch{g.error(`Failed to load extensions`)}finally{s(!1)}},[]);(0,x.useEffect)(()=>{p()},[p]);function h(e){i(t=>({count:t.count-1,rows:t.rows.filter(t=>t.roleId!==e)}))}function _(e){n(t=>{let n=t.findIndex(t=>t.name===e.name);if(n>=0){let r=[...t];return r[n]=e,r}return[e,...t]})}return(0,S.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,S.jsx)(v,{title:`Extensions`,description:a?`Loading…`:`${e.length} installed`,actions:(0,S.jsxs)(d,{onClick:()=>u(!0),children:[(0,S.jsx)(o,{size:b.md}),`Import`]})}),(0,S.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,S.jsx)(C,{snapshot:r,onClear:h}),a?(0,S.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,S.jsx)(c,{size:24,className:`animate-spin text-[var(--app-text-subtle)]`})}):e.length===0?(0,S.jsx)(y,{icon:(0,S.jsx)(t,{size:32,className:`text-[var(--app-text-subtle)]`}),title:`还没装任何 extension`,description:`Click Import to upload a .mcpb package.`,action:(0,S.jsxs)(d,{onClick:()=>u(!0),children:[(0,S.jsx)(o,{size:b.md}),`Import`]})}):(0,S.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,S.jsx)(E,{extension:e},e.id))})]}),l&&(0,S.jsx)(w,{onClose:()=>u(!1),onSuccess:_})]})}export{D as Extensions};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{N as t,c as n,ft as r,n as i,pt as a,s as o,xt as s,z as c}from"./vendor-icons-Bc_e_XXa.js";import{d as l,t as u}from"./vendor-react-bQ_cvNuA.js";import{t as d}from"./Button-CRNb8sD3.js";import{f,i as p,p as m,w as h}from"./api-BP4ZP9kk.js";import{p as g}from"./index-Dd3NDYZR.js";import{t as _}from"./Card-Cwvv0An8.js";import{t as v}from"./PageHeader-acLQTYct.js";import{t as y}from"./EmptyState-BvQA1o5K.js";import{t as b}from"./ui-D1crlGpt.js";var x=e(s(),1),S=u();function C({snapshot:e,onClear:t}){let[i,o]=(0,x.useState)(!1),[s,l]=(0,x.useState)(null);if(e.count===0)return null;async function u(e){l(e.roleId);try{await p(e.roleId),t(e.roleId),g.success(`Cleared legacy mcp_servers for ${e.roleName}`)}catch{g.error(`Failed to clear legacy mcp_servers`)}finally{l(null)}}return(0,S.jsxs)(`div`,{className:`mb-4 rounded-xl border border-yellow-500/30 bg-yellow-500/5 p-4`,children:[(0,S.jsxs)(`button`,{className:`flex w-full items-center gap-2 text-left`,onClick:()=>o(e=>!e),children:[(0,S.jsx)(n,{size:b.sm,className:`shrink-0 text-yellow-400`}),(0,S.jsxs)(`span`,{className:`flex-1 text-sm font-medium text-yellow-300`,children:[e.count,` role`,e.count===1?``:`s`,` with legacy`,` `,(0,S.jsx)(`code`,{className:`font-mono`,children:`mcp_servers`}),` field`]}),i?(0,S.jsx)(a,{size:b.sm,className:`text-yellow-400`}):(0,S.jsx)(r,{size:b.sm,className:`text-yellow-400`})]}),i&&(0,S.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,S.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`These roles have an inline `,(0,S.jsx)(`code`,{className:`font-mono`,children:`mcp_servers`}),` config that predates the Extensions system. Click "Clear" to zero it out — the column is preserved, only its value is reset to `,(0,S.jsx)(`code`,{className:`font-mono`,children:`{}`}),`.`]}),e.rows.map(e=>(0,S.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-[var(--app-border)] bg-black/20 px-3 py-2`,children:[(0,S.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:e.roleName}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void u(e),disabled:s===e.roleId,children:s===e.roleId?(0,S.jsx)(c,{size:b.sm,className:`animate-spin`}):`Clear`})]},e.roleId))]})]})}function w({onClose:e,onSuccess:t}){let n=(0,x.useRef)(null),[r,a]=(0,x.useState)(!1),[s,l]=(0,x.useState)(!1);async function u(n){if(!n.name.endsWith(`.mcpb`)){g.error(`Only .mcpb files are supported`);return}a(!0);try{let r=await h(n);t(r),g.success(`Installed extension: ${r.name} v${r.version}`),e()}catch(e){let t=e instanceof Error?e.message:`Upload failed`;g.error(t)}finally{a(!1)}}function f(e){let t=e.target.files?.[0];t&&u(t)}function p(e){e.preventDefault(),l(!1);let t=e.dataTransfer.files[0];t&&u(t)}return(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-[var(--app-border)] bg-[var(--app-bg)] p-6 shadow-2xl`,children:[(0,S.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,S.jsx)(`h2`,{className:`text-base font-semibold text-[var(--app-text)]`,children:`Import Extension`}),(0,S.jsx)(`button`,{onClick:e,className:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,children:(0,S.jsx)(i,{size:b.lg})})]}),(0,S.jsx)(`div`,{className:`flex min-h-[140px] cursor-pointer flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed p-6 transition-colors ${s?`border-[var(--app-accent)] bg-[var(--app-accent)]/10`:`border-[var(--app-border)] hover:border-[var(--app-text-subtle)]`}`,onClick:()=>n.current?.click(),onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:p,children:r?(0,S.jsx)(c,{size:32,className:`animate-spin text-[var(--app-accent)]`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{size:32,className:`text-[var(--app-text-subtle)]`}),(0,S.jsxs)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:[`Drop a `,(0,S.jsx)(`code`,{className:`font-mono`,children:`.mcpb`}),` file here, or click to browse`]})]})}),(0,S.jsx)(`input`,{ref:n,type:`file`,accept:`.mcpb`,className:`hidden`,onChange:f}),(0,S.jsx)(`div`,{className:`mt-4 flex justify-end gap-2`,children:(0,S.jsx)(d,{variant:`ghost`,onClick:e,disabled:r,children:`Cancel`})})]})})}function T({health:e}){return e?e.lastStatus===`success`?(0,S.jsx)(`span`,{title:`Last ok ${e.lastRunAt?new Date(e.lastRunAt).toLocaleString():``}`,className:`text-green-500 text-sm`,children:`✅`}):(0,S.jsx)(`span`,{title:e.lastError??`Failed`,className:`text-red-500 text-sm`,children:`❌`}):(0,S.jsx)(`span`,{title:`Never run`,className:`text-gray-500 text-sm`,children:`⏳`})}function E({extension:e}){let n=l(),r={};try{r=JSON.parse(e.manifestJson)}catch{}return(0,S.jsx)(_,{className:`cursor-pointer p-4 transition-colors hover:border-[var(--app-accent)]/50`,onClick:()=>n(`/extensions/${e.name}`),children:(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsx)(`p`,{className:`truncate font-medium text-[var(--app-text)]`,children:e.name}),(0,S.jsxs)(`p`,{className:`mt-0.5 text-xs text-[var(--app-text-subtle)]`,children:[`v`,e.version]}),r.description&&(0,S.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-[var(--app-text-muted)]`,children:r.description})]}),(0,S.jsxs)(`div`,{className:`flex flex-col items-end gap-1 shrink-0`,children:[(0,S.jsx)(T,{health:e.health}),(0,S.jsx)(t,{size:b.md,className:`mt-0.5 text-[var(--app-text-subtle)]`})]})]})})}function D(){let[e,n]=(0,x.useState)([]),[r,i]=(0,x.useState)({count:0,rows:[]}),[a,s]=(0,x.useState)(!0),[l,u]=(0,x.useState)(!1),p=(0,x.useCallback)(async()=>{s(!0);try{let[e,t]=await Promise.all([f(),m()]);n(e),i(t)}catch{g.error(`Failed to load extensions`)}finally{s(!1)}},[]);(0,x.useEffect)(()=>{p()},[p]);function h(e){i(t=>({count:t.count-1,rows:t.rows.filter(t=>t.roleId!==e)}))}function _(e){n(t=>{let n=t.findIndex(t=>t.name===e.name);if(n>=0){let r=[...t];return r[n]=e,r}return[e,...t]})}return(0,S.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,S.jsx)(v,{title:`Extensions`,description:a?`Loading…`:`${e.length} installed`,actions:(0,S.jsxs)(d,{onClick:()=>u(!0),children:[(0,S.jsx)(o,{size:b.md}),`Import`]})}),(0,S.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,S.jsx)(C,{snapshot:r,onClear:h}),a?(0,S.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,S.jsx)(c,{size:24,className:`animate-spin text-[var(--app-text-subtle)]`})}):e.length===0?(0,S.jsx)(y,{icon:(0,S.jsx)(t,{size:32,className:`text-[var(--app-text-subtle)]`}),title:`还没装任何 extension`,description:`Click Import to upload a .mcpb package.`,action:(0,S.jsxs)(d,{onClick:()=>u(!0),children:[(0,S.jsx)(o,{size:b.md}),`Import`]})}):(0,S.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,S.jsx)(E,{extension:e},e.id))})]}),l&&(0,S.jsx)(w,{onClose:()=>u(!1),onSuccess:_})]})}export{D as Extensions};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{t as r}from"./Button-CRNb8sD3.js";import{t as i}from"./api-BP4ZP9kk.js";import{t as a}from"./index-CXEJd-0s.js";import{t as o}from"./Card-Cwvv0An8.js";import{t as s}from"./SectionHeader-NZWZgoOs.js";import{t as c}from"./EmptyState-BvQA1o5K.js";var l=e(t(),1),u=n(),d={new:`muted`,reviewed:`success`,dismissed:`secondary`,converted:`warning`};function f(e){let t=Date.now()-e;if(Math.floor(t/6e4)<1)return`just now`;let n=Math.floor(t/36e5);return n<24?`${n}h ago`:`${Math.floor(t/864e5)}d ago`}function p(){let[e,t]=(0,l.useState)([]),[n,p]=(0,l.useState)(!0),[m,h]=(0,l.useState)(`all`),[g,_]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),b=(0,l.useCallback)(async()=>{p(!0);try{let e=new URLSearchParams({limit:`200`});m!==`all`&&e.set(`status`,m),t((await i(`/feature-requests?${e}`)).featureRequests)}catch{t([])}finally{p(!1)}},[m]);(0,l.useEffect)(()=>{b()},[b]);let x=async(e,t)=>{y(e);try{await i(`/feature-requests/${e}`,{method:`PATCH`,body:JSON.stringify({status:t})}),await b()}finally{y(null)}};return(0,u.jsxs)(`div`,{className:`space-y-5`,children:[(0,u.jsx)(s,{title:`Feature Requests`,description:`Unmet user needs identified by the Feature Miner role.`,compact:!0,action:(0,u.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>void b(),children:`Refresh`})}),(0,u.jsx)(`div`,{className:`flex gap-2`,children:[`all`,`new`,`reviewed`,`dismissed`,`converted`].map(e=>(0,u.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`rounded px-3 py-1.5 text-xs font-medium transition-colors ${m===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:e===`all`?`All`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),n?(0,u.jsx)(o,{children:(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:`Loading...`})}):e.length===0?(0,u.jsx)(o,{children:(0,u.jsx)(c,{title:`No feature requests`,description:`Run the Feature Mining template to extract unmet needs from chat sessions.`})}):(0,u.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,u.jsxs)(o,{padding:!1,children:[(0,u.jsx)(`div`,{className:`p-4 cursor-pointer hover:bg-black/[0.02]`,onClick:()=>_(g===e.id?null:e.id),role:`button`,tabIndex:0,onKeyDown:t=>{t.key===`Enter`&&_(g===e.id?null:e.id)},children:(0,u.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,u.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(a,{variant:d[e.status],children:e.status}),(0,u.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:f(e.extractedAt)}),e.tags&&e.tags.length>0&&(0,u.jsx)(`div`,{className:`flex gap-1`,children:e.tags.slice(0,3).map(e=>(0,u.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-muted)]`,children:e},e))})]}),e.summary?(0,u.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.summary}):null,(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)] line-clamp-2`,children:e.content})]})})}),g===e.id&&(0,u.jsxs)(`div`,{className:`border-t border-[var(--app-border)] p-4 space-y-3`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Content`}),(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.content})]}),e.evidenceQuote&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Evidence Quote`}),(0,u.jsx)(`blockquote`,{className:`border-l-2 border-[var(--app-border)] pl-3 text-sm text-[var(--app-text-muted)] italic`,children:e.evidenceQuote})]}),e.tags&&e.tags.length>0&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Tags`}),(0,u.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.tags.map(e=>(0,u.jsx)(`span`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-0.5 text-xs text-[var(--app-text)]`,children:e},e))})]}),(0,u.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,u.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Extracted: `,new Date(e.extractedAt).toLocaleString()]}),e.sourceSessionId&&(0,u.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Session: `,e.sourceSessionId.slice(0,8)]})]}),(0,u.jsx)(`div`,{className:`flex gap-2 pt-1`,children:[`new`,`reviewed`,`dismissed`,`converted`].map(t=>(0,u.jsx)(r,{variant:e.status===t?`default`:`ghost`,size:`sm`,disabled:v===e.id||e.status===t,onClick:n=>{n.stopPropagation(),x(e.id,t)},children:t.charAt(0).toUpperCase()+t.slice(1)},t))})]})]},e.id))})]})}export{p as FeatureRequests};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{t as r}from"./Button-CRNb8sD3.js";import{t as i}from"./api-BP4ZP9kk.js";import{t as a}from"./index-Dd3NDYZR.js";import{t as o}from"./Card-Cwvv0An8.js";import{t as s}from"./SectionHeader-NZWZgoOs.js";import{t as c}from"./EmptyState-BvQA1o5K.js";var l=e(t(),1),u=n(),d={new:`muted`,reviewed:`success`,dismissed:`secondary`,converted:`warning`};function f(e){let t=Date.now()-e;if(Math.floor(t/6e4)<1)return`just now`;let n=Math.floor(t/36e5);return n<24?`${n}h ago`:`${Math.floor(t/864e5)}d ago`}function p(){let[e,t]=(0,l.useState)([]),[n,p]=(0,l.useState)(!0),[m,h]=(0,l.useState)(`all`),[g,_]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),b=(0,l.useCallback)(async()=>{p(!0);try{let e=new URLSearchParams({limit:`200`});m!==`all`&&e.set(`status`,m),t((await i(`/feature-requests?${e}`)).featureRequests)}catch{t([])}finally{p(!1)}},[m]);(0,l.useEffect)(()=>{b()},[b]);let x=async(e,t)=>{y(e);try{await i(`/feature-requests/${e}`,{method:`PATCH`,body:JSON.stringify({status:t})}),await b()}finally{y(null)}};return(0,u.jsxs)(`div`,{className:`space-y-5`,children:[(0,u.jsx)(s,{title:`Feature Requests`,description:`Unmet user needs identified by the Feature Miner role.`,compact:!0,action:(0,u.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>void b(),children:`Refresh`})}),(0,u.jsx)(`div`,{className:`flex gap-2`,children:[`all`,`new`,`reviewed`,`dismissed`,`converted`].map(e=>(0,u.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`rounded px-3 py-1.5 text-xs font-medium transition-colors ${m===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:e===`all`?`All`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),n?(0,u.jsx)(o,{children:(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:`Loading...`})}):e.length===0?(0,u.jsx)(o,{children:(0,u.jsx)(c,{title:`No feature requests`,description:`Run the Feature Mining template to extract unmet needs from chat sessions.`})}):(0,u.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,u.jsxs)(o,{padding:!1,children:[(0,u.jsx)(`div`,{className:`p-4 cursor-pointer hover:bg-black/[0.02]`,onClick:()=>_(g===e.id?null:e.id),role:`button`,tabIndex:0,onKeyDown:t=>{t.key===`Enter`&&_(g===e.id?null:e.id)},children:(0,u.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,u.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(a,{variant:d[e.status],children:e.status}),(0,u.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:f(e.extractedAt)}),e.tags&&e.tags.length>0&&(0,u.jsx)(`div`,{className:`flex gap-1`,children:e.tags.slice(0,3).map(e=>(0,u.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-muted)]`,children:e},e))})]}),e.summary?(0,u.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.summary}):null,(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)] line-clamp-2`,children:e.content})]})})}),g===e.id&&(0,u.jsxs)(`div`,{className:`border-t border-[var(--app-border)] p-4 space-y-3`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Content`}),(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.content})]}),e.evidenceQuote&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Evidence Quote`}),(0,u.jsx)(`blockquote`,{className:`border-l-2 border-[var(--app-border)] pl-3 text-sm text-[var(--app-text-muted)] italic`,children:e.evidenceQuote})]}),e.tags&&e.tags.length>0&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Tags`}),(0,u.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.tags.map(e=>(0,u.jsx)(`span`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-0.5 text-xs text-[var(--app-text)]`,children:e},e))})]}),(0,u.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,u.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Extracted: `,new Date(e.extractedAt).toLocaleString()]}),e.sourceSessionId&&(0,u.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Session: `,e.sourceSessionId.slice(0,8)]})]}),(0,u.jsx)(`div`,{className:`flex gap-2 pt-1`,children:[`new`,`reviewed`,`dismissed`,`converted`].map(t=>(0,u.jsx)(r,{variant:e.status===t?`default`:`ghost`,size:`sm`,disabled:v===e.id||e.status===t,onClick:n=>{n.stopPropagation(),x(e.id,t)},children:t.charAt(0).toUpperCase()+t.slice(1)},t))})]})]},e.id))})]})}export{p as FeatureRequests};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{U as t,at as n,m as r,rt as i,vt as a,xt as o}from"./vendor-icons-Bc_e_XXa.js";import{f as s,r as c,t as l}from"./vendor-react-bQ_cvNuA.js";import{t as u}from"./api-BP4ZP9kk.js";import{t as d}from"./index-CXEJd-0s.js";import{a as f,i as p,t as m}from"./Card-Cwvv0An8.js";import{t as h}from"./PageHeader-acLQTYct.js";import{t as g}from"./SectionHeader-NZWZgoOs.js";import{n as _}from"./format-ZWN4JNj-.js";var v=e(o(),1),y=l();function b(){let{id:e}=s(),[o,l]=(0,v.useState)(null),[b,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&(async()=>{try{let t=await u(`/goals/${e}`);l(t.goal),w(null);try{S((await u(`/strategies?role=${t.goal.roleId}`)).strategies??[])}catch{}}catch(e){w(e instanceof Error?e.message:`Failed to load goal`)}})()},[e]),C)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:C})]});if(!o)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let T=o.targetValue>0?Math.min(100,o.currentValue/o.targetValue*100):0,E=o.deadline>0&&o.deadline<Date.now()&&o.status!==`completed`;return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(h,{eyebrow:`Goal`,title:o.name,compact:!0,description:o.description||`Progress, delivery targets, and strategy support before raw metrics.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:(e=>e===`completed`?`success`:e===`executing`||e===`evaluating`?`warning`:e===`failed`?`destructive`:`secondary`)(o.status),children:o.status})},{label:`Role`,value:o.roleId},{label:`Metric`,value:o.metricType},{label:`Progress`,value:`${T.toFixed(1)}%`}]}),(0,y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Goal ID`}),(0,y.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:o.id})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Current delta`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:Math.max(o.targetValue-o.currentValue,0)})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Strategies in play`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:b.length})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Deadline state`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium ${E?`text-[var(--app-danger-soft-text)]`:`text-[var(--app-text)]`}`,children:E?`Overdue`:`On track`})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:r,label:`Progress`,value:`${o.currentValue} / ${o.targetValue}`}),(0,y.jsx)(x,{icon:n,label:E?`Overdue`:`Deadline`,value:_(o.deadline),mono:!0}),(0,y.jsx)(x,{icon:i,label:`Budget`,value:`$${o.budgetUsd.toFixed(2)}`}),(0,y.jsx)(x,{icon:t,label:`Created`,value:_(o.createdAt),mono:!0})]}),(0,y.jsx)(g,{title:`Progress`,compact:!0,description:`Completion first, then delivery targets and strategy support.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Progress`})}),(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`flex-1 h-3 rounded-full bg-[var(--app-panel-muted)] overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${E?`bg-[var(--app-danger)]`:`bg-[var(--app-accent)]`}`,style:{width:`${T}%`}})}),(0,y.jsxs)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:[T.toFixed(1),`%`]})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,y.jsxs)(`span`,{children:[o.currentValue,` current`]}),(0,y.jsxs)(`span`,{children:[o.targetValue,` target`]})]})]}),(o.deliverTo??[]).length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Delivery Targets`})}),(0,y.jsx)(`div`,{className:`space-y-1.5`,children:(o.deliverTo??[]).map((e,t)=>(0,y.jsx)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:e.type===`channel`?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Channel`}),(0,y.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Session`}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Chat session`})]})},t))})]}),b.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(g,{title:`Strategy Support`,compact:!0,description:`Strategy candidates already associated with the goal's role.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(t,{size:14}),` Strategies (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsx)(`div`,{className:`flex items-center justify-between text-sm border-b border-[var(--app-border)] pb-2`,children:(0,y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:e.taskType})]})},e.id))})]})]})]})}function x({icon:e,label:t,value:n,mono:r}){return(0,y.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,y.jsx)(e,{size:12}),(0,y.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{b as GoalDetail};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{U as t,at as n,m as r,rt as i,vt as a,xt as o}from"./vendor-icons-Bc_e_XXa.js";import{f as s,r as c,t as l}from"./vendor-react-bQ_cvNuA.js";import{t as u}from"./api-BP4ZP9kk.js";import{t as d}from"./index-Dd3NDYZR.js";import{a as f,i as p,t as m}from"./Card-Cwvv0An8.js";import{t as h}from"./PageHeader-acLQTYct.js";import{t as g}from"./SectionHeader-NZWZgoOs.js";import{n as _}from"./format-ZWN4JNj-.js";var v=e(o(),1),y=l();function b(){let{id:e}=s(),[o,l]=(0,v.useState)(null),[b,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&(async()=>{try{let t=await u(`/goals/${e}`);l(t.goal),w(null);try{S((await u(`/strategies?role=${t.goal.roleId}`)).strategies??[])}catch{}}catch(e){w(e instanceof Error?e.message:`Failed to load goal`)}})()},[e]),C)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:C})]});if(!o)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let T=o.targetValue>0?Math.min(100,o.currentValue/o.targetValue*100):0,E=o.deadline>0&&o.deadline<Date.now()&&o.status!==`completed`;return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(h,{eyebrow:`Goal`,title:o.name,compact:!0,description:o.description||`Progress, delivery targets, and strategy support before raw metrics.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:(e=>e===`completed`?`success`:e===`executing`||e===`evaluating`?`warning`:e===`failed`?`destructive`:`secondary`)(o.status),children:o.status})},{label:`Role`,value:o.roleId},{label:`Metric`,value:o.metricType},{label:`Progress`,value:`${T.toFixed(1)}%`}]}),(0,y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Goal ID`}),(0,y.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:o.id})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Current delta`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:Math.max(o.targetValue-o.currentValue,0)})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Strategies in play`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:b.length})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Deadline state`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium ${E?`text-[var(--app-danger-soft-text)]`:`text-[var(--app-text)]`}`,children:E?`Overdue`:`On track`})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:r,label:`Progress`,value:`${o.currentValue} / ${o.targetValue}`}),(0,y.jsx)(x,{icon:n,label:E?`Overdue`:`Deadline`,value:_(o.deadline),mono:!0}),(0,y.jsx)(x,{icon:i,label:`Budget`,value:`$${o.budgetUsd.toFixed(2)}`}),(0,y.jsx)(x,{icon:t,label:`Created`,value:_(o.createdAt),mono:!0})]}),(0,y.jsx)(g,{title:`Progress`,compact:!0,description:`Completion first, then delivery targets and strategy support.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Progress`})}),(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`flex-1 h-3 rounded-full bg-[var(--app-panel-muted)] overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${E?`bg-[var(--app-danger)]`:`bg-[var(--app-accent)]`}`,style:{width:`${T}%`}})}),(0,y.jsxs)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:[T.toFixed(1),`%`]})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,y.jsxs)(`span`,{children:[o.currentValue,` current`]}),(0,y.jsxs)(`span`,{children:[o.targetValue,` target`]})]})]}),(o.deliverTo??[]).length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Delivery Targets`})}),(0,y.jsx)(`div`,{className:`space-y-1.5`,children:(o.deliverTo??[]).map((e,t)=>(0,y.jsx)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:e.type===`channel`?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Channel`}),(0,y.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Session`}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Chat session`})]})},t))})]}),b.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(g,{title:`Strategy Support`,compact:!0,description:`Strategy candidates already associated with the goal's role.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(t,{size:14}),` Strategies (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsx)(`div`,{className:`flex items-center justify-between text-sm border-b border-[var(--app-border)] pb-2`,children:(0,y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:e.taskType})]})},e.id))})]})]})]})}function x({icon:e,label:t,value:n,mono:r}){return(0,y.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,y.jsx)(e,{size:12}),(0,y.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{b as GoalDetail};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,D as n,M as r,j as i,l as a,m as o,n as s,w as c,xt as l}from"./vendor-icons-Bc_e_XXa.js";import{t as u}from"./vendor-react-bQ_cvNuA.js";import"./es2015-BkFSNOYE.js";import{t as d}from"./Button-CRNb8sD3.js";import{t as f}from"./api-BP4ZP9kk.js";import{a as p,c as m,d as h,f as g,i as _,l as v,n as ee,o as y,p as b,r as x,s as S,t as C,u as te}from"./index-CXEJd-0s.js";import{a as ne,i as re,t as w}from"./Card-Cwvv0An8.js";import{t as T}from"./PageHeader-acLQTYct.js";import{n as E,t as D}from"./format-ZWN4JNj-.js";import{t as O}from"./EmptyState-BvQA1o5K.js";var k=e(l(),1),A=u();function j({value:e,onChange:t,label:n=`Delivery Targets`}){let[r,i]=(0,k.useState)([]),[a,o]=(0,k.useState)(!1);(0,k.useEffect)(()=>{let e=!1;return Promise.all([f(`/channels`).catch(()=>({channels:[]})),f(`/chat/sessions`).catch(()=>({sessions:[]}))]).then(([t,n])=>{if(e)return;let r=new Map(t.channels.map(e=>[e.id,e])),a=[];for(let e of n.sessions)if(e.source.type===`channel`&&e.source.channelId&&e.source.chatId){let t=r.get(e.source.channelId);a.push({id:e.id,channelId:e.source.channelId,channelName:t?.name??e.source.channelId.slice(0,8),platform:t?.platform??`unknown`,chatId:e.source.chatId})}for(let e of t.channels)e.enabled&&e.platform===`email`&&typeof e.config.address==`string`&&a.push({id:`email:${e.id}`,channelId:e.id,channelName:e.name,platform:e.platform,chatId:e.config.address});let o=new Set;i(a.filter(e=>{let t=`${e.channelId}:${e.chatId}`;return o.has(t)?!1:(o.add(t),!0)}))}),()=>{e=!0}},[]);let s=(t,n)=>e.some(e=>e.type===`channel`&&e.channelId===t&&e.chatId===n),c=(n,r)=>{s(n,r)?t(e.filter(e=>!(e.type===`channel`&&e.channelId===n&&e.chatId===r))):t([...e,{type:`channel`,channelId:n,chatId:r}])},l=e.filter(e=>e.type===`channel`).length;return(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:n}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!a),className:`mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-left text-sm text-[var(--app-text)] hover:border-[var(--app-border-strong)] focus:border-[var(--app-accent)] focus:outline-none`,children:l===0?`Default (current session)`:`${l} channel${l>1?`s`:``} selected`}),a&&(0,A.jsxs)(`div`,{className:`absolute z-10 mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] py-1 shadow-lg`,children:[r.length===0?(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-[var(--app-text-subtle)]`,children:`No channel delivery targets available.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`px-3 py-1 text-xs text-[var(--app-text-subtle)]`,children:`Channel conversations`}),r.map(e=>(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1.5 text-xs text-[var(--app-text)] hover:bg-[var(--app-panel-muted)]`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s(e.channelId,e.chatId),onChange:()=>c(e.channelId,e.chatId),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-muted)]`}),(0,A.jsx)(`span`,{className:`truncate font-medium`,children:e.channelName}),(0,A.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`(`,e.platform,`)`]})]},`${e.channelId}:${e.chatId}`))]}),l>0&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{t([]),o(!1)},className:`mt-1 w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-danger)] hover:bg-[var(--app-panel-muted)]`,children:`Clear all`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-text-subtle)] hover:bg-[var(--app-panel-muted)]`,children:`Done`})]})]})}var M={active:`paused`,paused:`active`,completed:`active`,failed:`active`},N={active:(0,A.jsx)(r,{size:12}),paused:(0,A.jsx)(t,{size:12}),completed:(0,A.jsx)(c,{size:12}),failed:(0,A.jsx)(c,{size:12})};function P(){let e=g(e=>e.goals),r=g(e=>e.fetchGoals),l=g(e=>e.updateGoal),u=g(e=>e.deleteGoal),[P,F]=(0,k.useState)(!1),[I,L]=(0,k.useState)(``),[R,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(null),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(``),[K,q]=(0,k.useState)(``),[J,Y]=(0,k.useState)([]),[X,Z]=(0,k.useState)([]),[Q,ie]=(0,k.useState)([]),[$,ae]=(0,k.useState)([]),oe=e.filter(e=>e.status===`active`).length,se=e.filter(e=>e.status===`paused`).length,ce=e.filter(e=>e.status===`completed`).length;(0,k.useEffect)(()=>{r();let e=setInterval(()=>void r(),1e4);return()=>clearInterval(e)},[r]);let le=async()=>{if(I.trim()){z(!0),V(null);try{await f(`/goals`,{method:`POST`,body:JSON.stringify({input:I.trim(),deliverTo:Q.length>0?Q:void 0,reportTo:$.length>0?$:void 0})}),L(``),F(!1),r()}catch(e){V(e instanceof Error?e.message:`Failed to create goal`)}finally{z(!1)}}};return(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsx)(T,{eyebrow:`Operations`,title:`Goals`,compact:!0,description:`Long-running outcomes, budgets, and delivery targets.`,metrics:[{label:`Active`,value:oe},{label:`Paused`,value:se},{label:`Completed`,value:ce}],actions:(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void r(),children:(0,A.jsx)(c,{size:14})}),(0,A.jsxs)(d,{size:`sm`,onClick:()=>F(!P),children:[(0,A.jsx)(n,{size:14}),`New Goal`]})]})}),P&&(0,A.jsxs)(w,{className:`space-y-3`,children:[(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Describe your goal in natural language...`,rows:3,value:I,onChange:e=>L(e.target.value)}),(0,A.jsx)(j,{value:Q,onChange:ie,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:$,onChange:ae,label:`Report To (status)`}),B&&(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:B}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(d,{onClick:()=>void le(),disabled:R||!I.trim(),children:R?`Creating...`:`Create`}),(0,A.jsx)(d,{variant:`ghost`,onClick:()=>F(!1),children:`Cancel`})]})]}),e.length===0?(0,A.jsx)(O,{icon:(0,A.jsx)(o,{size:32}),title:`No goals`,description:`Create a goal to start goal-driven task orchestration`}):(0,A.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>{let n=e.targetValue>0?Math.min(100,Math.round(e.currentValue/e.targetValue*100)):0,r=new Date(e.deadline).getTime()<Date.now()&&e.status!==`completed`,o=H===e.id;return(0,A.jsxs)(w,{children:[(0,A.jsxs)(re,{children:[o?(0,A.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:W,onChange:e=>G(e.target.value),autoFocus:!0}):(0,A.jsx)(ne,{className:`max-w-full text-[var(--app-text)] text-sm font-medium truncate sm:max-w-[180px]`,children:e.name}),(0,A.jsx)(C,{variant:ee(e.status),children:e.status})]}),o?(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none mb-3`,placeholder:`Description...`,rows:2,value:K,onChange:e=>q(e.target.value)}):e.description?(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-text-muted)] mb-3 line-clamp-2`,children:e.description}):null,o&&(0,A.jsxs)(`div`,{className:`mb-3 space-y-2`,children:[(0,A.jsx)(j,{value:J,onChange:Y,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:X,onChange:Z,label:`Report To (status)`})]}),(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,A.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Progress`}),(0,A.jsxs)(`span`,{className:`font-mono text-xs text-[var(--app-text)]`,children:[n,`%`]})]}),(0,A.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--app-panel-elevated)]`,children:(0,A.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${n>=100?`bg-[var(--app-success)]`:`bg-[var(--app-accent)]`}`,style:{width:`${n}%`}})}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,A.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:[e.currentValue,` / `,e.targetValue]}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:e.metricType})]})]}),(0,A.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Role`}),(0,A.jsx)(C,{variant:`muted`,className:`text-[10px]`,children:e.roleId})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Budget`}),(0,A.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:D(e.budgetUsd)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)] ${r?`text-[var(--app-danger)]`:``}`,children:`Deadline`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text)] ${r?`text-[var(--app-danger)]`:``}`,children:E(e.deadline)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Created`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text-muted)]`,children:E(e.createdAt)})]})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1 mt-3 pt-3 border-t border-[var(--app-border)]`,children:o?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{size:`sm`,variant:`ghost`,onClick:async()=>{try{await l(e.id,{name:W,description:K,deliverTo:J,reportTo:X}),U(null),b.success(`Goal updated`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update`)}},children:`Save`}),(0,A.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>U(null),children:(0,A.jsx)(s,{size:14})})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{size:`sm`,variant:`ghost`,title:`Edit`,onClick:()=>{U(e.id),G(e.name),q(e.description??``),Y(e.deliverTo??[]),Z(e.reportTo??[])},children:(0,A.jsx)(i,{size:14})}),(0,A.jsxs)(d,{size:`sm`,variant:`ghost`,title:`Change to ${M[e.status]}`,onClick:async()=>{try{await l(e.id,{status:M[e.status]}),b.success(`Status changed to ${M[e.status]}`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update status`)}},children:[N[e.status]??(0,A.jsx)(t,{size:12}),(0,A.jsx)(`span`,{className:`text-xs`,children:M[e.status]})]}),(0,A.jsx)(`div`,{className:`ml-auto`,children:(0,A.jsxs)(x,{children:[(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(d,{size:`sm`,variant:`ghost`,title:`Delete`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,A.jsx)(a,{size:14})})}),(0,A.jsxs)(y,{children:[(0,A.jsxs)(v,{children:[(0,A.jsx)(te,{children:`Delete goal`}),(0,A.jsxs)(S,{children:[`This will permanently delete "`,e.name,`". This action cannot be undone.`]})]}),(0,A.jsxs)(m,{children:[(0,A.jsx)(p,{children:`Cancel`}),(0,A.jsx)(_,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger-strong)]`,onClick:async()=>{try{await u(e.id),b.success(`Goal deleted`)}catch(e){b.error(e instanceof Error?e.message:`Failed to delete`)}},children:`Delete`})]})]})]})})]})})]},e.id)})})]})}export{P as Goals,j as t};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,D as n,M as r,j as i,l as a,m as o,n as s,w as c,xt as l}from"./vendor-icons-Bc_e_XXa.js";import{t as u}from"./vendor-react-bQ_cvNuA.js";import"./es2015-BkFSNOYE.js";import{t as d}from"./Button-CRNb8sD3.js";import{t as f}from"./api-BP4ZP9kk.js";import{a as p,c as m,d as h,f as g,i as _,l as v,n as ee,o as y,p as b,r as x,s as S,t as C,u as te}from"./index-Dd3NDYZR.js";import{a as ne,i as re,t as w}from"./Card-Cwvv0An8.js";import{t as T}from"./PageHeader-acLQTYct.js";import{n as E,t as D}from"./format-ZWN4JNj-.js";import{t as O}from"./EmptyState-BvQA1o5K.js";var k=e(l(),1),A=u();function j({value:e,onChange:t,label:n=`Delivery Targets`}){let[r,i]=(0,k.useState)([]),[a,o]=(0,k.useState)(!1);(0,k.useEffect)(()=>{let e=!1;return Promise.all([f(`/channels`).catch(()=>({channels:[]})),f(`/chat/sessions`).catch(()=>({sessions:[]}))]).then(([t,n])=>{if(e)return;let r=new Map(t.channels.map(e=>[e.id,e])),a=[];for(let e of n.sessions)if(e.source.type===`channel`&&e.source.channelId&&e.source.chatId){let t=r.get(e.source.channelId);a.push({id:e.id,channelId:e.source.channelId,channelName:t?.name??e.source.channelId.slice(0,8),platform:t?.platform??`unknown`,chatId:e.source.chatId})}for(let e of t.channels)e.enabled&&e.platform===`email`&&typeof e.config.address==`string`&&a.push({id:`email:${e.id}`,channelId:e.id,channelName:e.name,platform:e.platform,chatId:e.config.address});let o=new Set;i(a.filter(e=>{let t=`${e.channelId}:${e.chatId}`;return o.has(t)?!1:(o.add(t),!0)}))}),()=>{e=!0}},[]);let s=(t,n)=>e.some(e=>e.type===`channel`&&e.channelId===t&&e.chatId===n),c=(n,r)=>{s(n,r)?t(e.filter(e=>!(e.type===`channel`&&e.channelId===n&&e.chatId===r))):t([...e,{type:`channel`,channelId:n,chatId:r}])},l=e.filter(e=>e.type===`channel`).length;return(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:n}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!a),className:`mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-left text-sm text-[var(--app-text)] hover:border-[var(--app-border-strong)] focus:border-[var(--app-accent)] focus:outline-none`,children:l===0?`Default (current session)`:`${l} channel${l>1?`s`:``} selected`}),a&&(0,A.jsxs)(`div`,{className:`absolute z-10 mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] py-1 shadow-lg`,children:[r.length===0?(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-[var(--app-text-subtle)]`,children:`No channel delivery targets available.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`px-3 py-1 text-xs text-[var(--app-text-subtle)]`,children:`Channel conversations`}),r.map(e=>(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1.5 text-xs text-[var(--app-text)] hover:bg-[var(--app-panel-muted)]`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s(e.channelId,e.chatId),onChange:()=>c(e.channelId,e.chatId),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-muted)]`}),(0,A.jsx)(`span`,{className:`truncate font-medium`,children:e.channelName}),(0,A.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`(`,e.platform,`)`]})]},`${e.channelId}:${e.chatId}`))]}),l>0&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{t([]),o(!1)},className:`mt-1 w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-danger)] hover:bg-[var(--app-panel-muted)]`,children:`Clear all`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-text-subtle)] hover:bg-[var(--app-panel-muted)]`,children:`Done`})]})]})}var M={active:`paused`,paused:`active`,completed:`active`,failed:`active`},N={active:(0,A.jsx)(r,{size:12}),paused:(0,A.jsx)(t,{size:12}),completed:(0,A.jsx)(c,{size:12}),failed:(0,A.jsx)(c,{size:12})};function P(){let e=g(e=>e.goals),r=g(e=>e.fetchGoals),l=g(e=>e.updateGoal),u=g(e=>e.deleteGoal),[P,F]=(0,k.useState)(!1),[I,L]=(0,k.useState)(``),[R,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(null),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(``),[K,q]=(0,k.useState)(``),[J,Y]=(0,k.useState)([]),[X,Z]=(0,k.useState)([]),[Q,ie]=(0,k.useState)([]),[$,ae]=(0,k.useState)([]),oe=e.filter(e=>e.status===`active`).length,se=e.filter(e=>e.status===`paused`).length,ce=e.filter(e=>e.status===`completed`).length;(0,k.useEffect)(()=>{r();let e=setInterval(()=>void r(),1e4);return()=>clearInterval(e)},[r]);let le=async()=>{if(I.trim()){z(!0),V(null);try{await f(`/goals`,{method:`POST`,body:JSON.stringify({input:I.trim(),deliverTo:Q.length>0?Q:void 0,reportTo:$.length>0?$:void 0})}),L(``),F(!1),r()}catch(e){V(e instanceof Error?e.message:`Failed to create goal`)}finally{z(!1)}}};return(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsx)(T,{eyebrow:`Operations`,title:`Goals`,compact:!0,description:`Long-running outcomes, budgets, and delivery targets.`,metrics:[{label:`Active`,value:oe},{label:`Paused`,value:se},{label:`Completed`,value:ce}],actions:(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void r(),children:(0,A.jsx)(c,{size:14})}),(0,A.jsxs)(d,{size:`sm`,onClick:()=>F(!P),children:[(0,A.jsx)(n,{size:14}),`New Goal`]})]})}),P&&(0,A.jsxs)(w,{className:`space-y-3`,children:[(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Describe your goal in natural language...`,rows:3,value:I,onChange:e=>L(e.target.value)}),(0,A.jsx)(j,{value:Q,onChange:ie,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:$,onChange:ae,label:`Report To (status)`}),B&&(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:B}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(d,{onClick:()=>void le(),disabled:R||!I.trim(),children:R?`Creating...`:`Create`}),(0,A.jsx)(d,{variant:`ghost`,onClick:()=>F(!1),children:`Cancel`})]})]}),e.length===0?(0,A.jsx)(O,{icon:(0,A.jsx)(o,{size:32}),title:`No goals`,description:`Create a goal to start goal-driven task orchestration`}):(0,A.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>{let n=e.targetValue>0?Math.min(100,Math.round(e.currentValue/e.targetValue*100)):0,r=new Date(e.deadline).getTime()<Date.now()&&e.status!==`completed`,o=H===e.id;return(0,A.jsxs)(w,{children:[(0,A.jsxs)(re,{children:[o?(0,A.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:W,onChange:e=>G(e.target.value),autoFocus:!0}):(0,A.jsx)(ne,{className:`max-w-full text-[var(--app-text)] text-sm font-medium truncate sm:max-w-[180px]`,children:e.name}),(0,A.jsx)(C,{variant:ee(e.status),children:e.status})]}),o?(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none mb-3`,placeholder:`Description...`,rows:2,value:K,onChange:e=>q(e.target.value)}):e.description?(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-text-muted)] mb-3 line-clamp-2`,children:e.description}):null,o&&(0,A.jsxs)(`div`,{className:`mb-3 space-y-2`,children:[(0,A.jsx)(j,{value:J,onChange:Y,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:X,onChange:Z,label:`Report To (status)`})]}),(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,A.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Progress`}),(0,A.jsxs)(`span`,{className:`font-mono text-xs text-[var(--app-text)]`,children:[n,`%`]})]}),(0,A.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--app-panel-elevated)]`,children:(0,A.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${n>=100?`bg-[var(--app-success)]`:`bg-[var(--app-accent)]`}`,style:{width:`${n}%`}})}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,A.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:[e.currentValue,` / `,e.targetValue]}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:e.metricType})]})]}),(0,A.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Role`}),(0,A.jsx)(C,{variant:`muted`,className:`text-[10px]`,children:e.roleId})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Budget`}),(0,A.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:D(e.budgetUsd)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)] ${r?`text-[var(--app-danger)]`:``}`,children:`Deadline`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text)] ${r?`text-[var(--app-danger)]`:``}`,children:E(e.deadline)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Created`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text-muted)]`,children:E(e.createdAt)})]})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1 mt-3 pt-3 border-t border-[var(--app-border)]`,children:o?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{size:`sm`,variant:`ghost`,onClick:async()=>{try{await l(e.id,{name:W,description:K,deliverTo:J,reportTo:X}),U(null),b.success(`Goal updated`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update`)}},children:`Save`}),(0,A.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>U(null),children:(0,A.jsx)(s,{size:14})})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{size:`sm`,variant:`ghost`,title:`Edit`,onClick:()=>{U(e.id),G(e.name),q(e.description??``),Y(e.deliverTo??[]),Z(e.reportTo??[])},children:(0,A.jsx)(i,{size:14})}),(0,A.jsxs)(d,{size:`sm`,variant:`ghost`,title:`Change to ${M[e.status]}`,onClick:async()=>{try{await l(e.id,{status:M[e.status]}),b.success(`Status changed to ${M[e.status]}`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update status`)}},children:[N[e.status]??(0,A.jsx)(t,{size:12}),(0,A.jsx)(`span`,{className:`text-xs`,children:M[e.status]})]}),(0,A.jsx)(`div`,{className:`ml-auto`,children:(0,A.jsxs)(x,{children:[(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(d,{size:`sm`,variant:`ghost`,title:`Delete`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,A.jsx)(a,{size:14})})}),(0,A.jsxs)(y,{children:[(0,A.jsxs)(v,{children:[(0,A.jsx)(te,{children:`Delete goal`}),(0,A.jsxs)(S,{children:[`This will permanently delete "`,e.name,`". This action cannot be undone.`]})]}),(0,A.jsxs)(m,{children:[(0,A.jsx)(p,{children:`Cancel`}),(0,A.jsx)(_,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger-strong)]`,onClick:async()=>{try{await u(e.id),b.success(`Goal deleted`)}catch(e){b.error(e instanceof Error?e.message:`Failed to delete`)}},children:`Delete`})]})]})]})})]})})]},e.id)})})]})}export{P as Goals,j as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,M as n,et as r,p as i,xt as a}from"./vendor-icons-Bc_e_XXa.js";import{t as o}from"./vendor-react-bQ_cvNuA.js";import{t as s}from"./Button-CRNb8sD3.js";import{f as c}from"./index-CXEJd-0s.js";import{t as l}from"./Card-Cwvv0An8.js";import{t as u}from"./PageHeader-acLQTYct.js";import{t as d}from"./EmptyState-BvQA1o5K.js";import{t as f}from"./ui-D1crlGpt.js";var p=e(a(),1),m=o(),h={debug:`text-[var(--app-text-subtle)]`,info:`text-[var(--app-accent)]`,warn:`text-[var(--app-warning)]`,error:`text-[var(--app-danger)]`},g={adam:`text-[var(--app-log-adam)]`,manager:`text-[var(--app-log-manager)]`,worker:`text-[var(--app-success)]`,scheduler:`text-[var(--app-log-scheduler)]`,api:`text-[var(--app-accent)]`,ws:`text-[var(--app-log-ws)]`,store:`text-[var(--app-log-store)]`,embedding:`text-[var(--app-log-embedding)]`},_=[`adam`,`manager`,`worker`,`scheduler`,`api`,`ws`,`store`,`embedding`],v=[`debug`,`info`,`warn`,`error`];function y(){let e=c(e=>e.logs),a=(0,p.useRef)(null),[o,y]=(0,p.useState)(!0),[x,S]=(0,p.useState)(null),[C,w]=(0,p.useState)(null),T=(0,p.useMemo)(()=>e.filter(e=>!(x&&e.level!==x||C&&e.component!==C)),[e,x,C]);return(0,p.useEffect)(()=>{o&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},[T,o]),(0,m.jsxs)(`div`,{className:`flex h-full flex-col gap-5`,children:[(0,m.jsx)(u,{title:`Logs`,compact:!0,description:`Backend events with inline filters and a stable reading surface.`,metrics:[{label:`Visible`,value:T.length},{label:`Total`,value:e.length},{label:`Mode`,value:o?`Live`:`Paused`}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>y(!o),title:o?`Pause auto-scroll`:`Resume auto-scroll`,children:o?(0,m.jsx)(n,{size:f.sm}):(0,m.jsx)(t,{size:f.sm})}),(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>{c.setState({logs:[]})},title:`Clear logs`,children:(0,m.jsx)(r,{size:f.sm})})]})}),(0,m.jsx)(l,{className:`surface-panel-muted py-3`,children:(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Level:`}),(0,m.jsxs)(`div`,{className:`flex gap-1`,children:[(0,m.jsx)(b,{active:x===null,onClick:()=>S(null),children:`All`}),v.map(e=>(0,m.jsx)(b,{active:x===e,onClick:()=>S(x===e?null:e),children:e},e))]})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Component:`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,m.jsx)(b,{active:C===null,onClick:()=>w(null),children:`All`}),_.map(e=>(0,m.jsx)(b,{active:C===e,onClick:()=>w(C===e?null:e),children:e},e))]})]})]})}),(0,m.jsx)(l,{padding:!1,className:`flex-1 min-h-0`,children:T.length===0?(0,m.jsx)(`div`,{className:`p-4`,children:(0,m.jsx)(d,{icon:(0,m.jsx)(i,{size:32}),title:`No log entries`,description:`Log events will appear here in real-time via WebSocket.`,compact:!0,className:`min-h-[10rem]`})}):(0,m.jsx)(`div`,{ref:a,className:`h-full max-h-[calc(100vh-280px)] overflow-y-auto p-3 font-mono text-xs leading-5`,children:T.map((e,t)=>{let n=new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,fractionalSecondDigits:3}),r=h[e.level]??`text-[var(--app-text-muted)]`,i=g[e.component]??`text-[var(--app-text-muted)]`;return(0,m.jsxs)(`div`,{className:`flex gap-2 hover:bg-[var(--app-panel-elevated)]/30 px-1 rounded`,children:[(0,m.jsx)(`span`,{className:`text-[var(--app-text-subtle)] shrink-0`,children:n}),(0,m.jsx)(`span`,{className:`w-12 shrink-0 uppercase ${r}`,children:e.level.padEnd(5)}),(0,m.jsxs)(`span`,{className:`w-20 shrink-0 ${i}`,children:[`[`,e.component,`]`]}),(0,m.jsx)(`span`,{className:`text-[var(--app-text)] break-all`,children:e.msg})]},t)})})}),(0,m.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,m.jsxs)(`span`,{children:[T.length,` entries `,T.length!==e.length&&`(${e.length} total)`]}),(0,m.jsx)(`span`,{children:o?`Following live feed`:`Scroll paused`})]})]})}function b({active:e,onClick:t,children:n}){return(0,m.jsx)(`button`,{onClick:t,className:`rounded px-2 py-0.5 text-xs transition-colors ${e?`bg-[var(--app-panel-muted)] text-[var(--app-text)]`:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n})}export{y as Logs};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,M as n,et as r,p as i,xt as a}from"./vendor-icons-Bc_e_XXa.js";import{t as o}from"./vendor-react-bQ_cvNuA.js";import{t as s}from"./Button-CRNb8sD3.js";import{f as c}from"./index-Dd3NDYZR.js";import{t as l}from"./Card-Cwvv0An8.js";import{t as u}from"./PageHeader-acLQTYct.js";import{t as d}from"./EmptyState-BvQA1o5K.js";import{t as f}from"./ui-D1crlGpt.js";var p=e(a(),1),m=o(),h={debug:`text-[var(--app-text-subtle)]`,info:`text-[var(--app-accent)]`,warn:`text-[var(--app-warning)]`,error:`text-[var(--app-danger)]`},g={adam:`text-[var(--app-log-adam)]`,manager:`text-[var(--app-log-manager)]`,worker:`text-[var(--app-success)]`,scheduler:`text-[var(--app-log-scheduler)]`,api:`text-[var(--app-accent)]`,ws:`text-[var(--app-log-ws)]`,store:`text-[var(--app-log-store)]`,embedding:`text-[var(--app-log-embedding)]`},_=[`adam`,`manager`,`worker`,`scheduler`,`api`,`ws`,`store`,`embedding`],v=[`debug`,`info`,`warn`,`error`];function y(){let e=c(e=>e.logs),a=(0,p.useRef)(null),[o,y]=(0,p.useState)(!0),[x,S]=(0,p.useState)(null),[C,w]=(0,p.useState)(null),T=(0,p.useMemo)(()=>e.filter(e=>!(x&&e.level!==x||C&&e.component!==C)),[e,x,C]);return(0,p.useEffect)(()=>{o&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},[T,o]),(0,m.jsxs)(`div`,{className:`flex h-full flex-col gap-5`,children:[(0,m.jsx)(u,{title:`Logs`,compact:!0,description:`Backend events with inline filters and a stable reading surface.`,metrics:[{label:`Visible`,value:T.length},{label:`Total`,value:e.length},{label:`Mode`,value:o?`Live`:`Paused`}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>y(!o),title:o?`Pause auto-scroll`:`Resume auto-scroll`,children:o?(0,m.jsx)(n,{size:f.sm}):(0,m.jsx)(t,{size:f.sm})}),(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>{c.setState({logs:[]})},title:`Clear logs`,children:(0,m.jsx)(r,{size:f.sm})})]})}),(0,m.jsx)(l,{className:`surface-panel-muted py-3`,children:(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Level:`}),(0,m.jsxs)(`div`,{className:`flex gap-1`,children:[(0,m.jsx)(b,{active:x===null,onClick:()=>S(null),children:`All`}),v.map(e=>(0,m.jsx)(b,{active:x===e,onClick:()=>S(x===e?null:e),children:e},e))]})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Component:`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,m.jsx)(b,{active:C===null,onClick:()=>w(null),children:`All`}),_.map(e=>(0,m.jsx)(b,{active:C===e,onClick:()=>w(C===e?null:e),children:e},e))]})]})]})}),(0,m.jsx)(l,{padding:!1,className:`flex-1 min-h-0`,children:T.length===0?(0,m.jsx)(`div`,{className:`p-4`,children:(0,m.jsx)(d,{icon:(0,m.jsx)(i,{size:32}),title:`No log entries`,description:`Log events will appear here in real-time via WebSocket.`,compact:!0,className:`min-h-[10rem]`})}):(0,m.jsx)(`div`,{ref:a,className:`h-full max-h-[calc(100vh-280px)] overflow-y-auto p-3 font-mono text-xs leading-5`,children:T.map((e,t)=>{let n=new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,fractionalSecondDigits:3}),r=h[e.level]??`text-[var(--app-text-muted)]`,i=g[e.component]??`text-[var(--app-text-muted)]`;return(0,m.jsxs)(`div`,{className:`flex gap-2 hover:bg-[var(--app-panel-elevated)]/30 px-1 rounded`,children:[(0,m.jsx)(`span`,{className:`text-[var(--app-text-subtle)] shrink-0`,children:n}),(0,m.jsx)(`span`,{className:`w-12 shrink-0 uppercase ${r}`,children:e.level.padEnd(5)}),(0,m.jsxs)(`span`,{className:`w-20 shrink-0 ${i}`,children:[`[`,e.component,`]`]}),(0,m.jsx)(`span`,{className:`text-[var(--app-text)] break-all`,children:e.msg})]},t)})})}),(0,m.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,m.jsxs)(`span`,{children:[T.length,` entries `,T.length!==e.length&&`(${e.length} total)`]}),(0,m.jsx)(`span`,{children:o?`Following live feed`:`Scroll paused`})]})]})}function b({active:e,onClick:t,children:n}){return(0,m.jsx)(`button`,{onClick:t,className:`rounded px-2 py-0.5 text-xs transition-colors ${e?`bg-[var(--app-panel-muted)] text-[var(--app-text)]`:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n})}export{y as Logs};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{gt as t,w as n,x as r,xt as i}from"./vendor-icons-Bc_e_XXa.js";import{t as a}from"./vendor-react-bQ_cvNuA.js";import{t as o}from"./Button-CRNb8sD3.js";import{t as s}from"./api-BP4ZP9kk.js";import{f as c,t as l}from"./index-CXEJd-0s.js";import{t as u}from"./Card-Cwvv0An8.js";import{t as d}from"./PageHeader-acLQTYct.js";import{t as f}from"./SectionHeader-NZWZgoOs.js";import{a as p}from"./format-ZWN4JNj-.js";import{t as m}from"./EmptyState-BvQA1o5K.js";var h=e(i(),1),g=a();function _(){let e=c(e=>e.roles),i=c(e=>e.fetchRoles),[a,_]=(0,h.useState)(``),[v,y]=(0,h.useState)([]),[b,x]=(0,h.useState)(!1),[S,C]=(0,h.useState)(``),[w,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(`all`),[O,k]=(0,h.useState)(new Set);(0,h.useEffect)(()=>{i()},[i]),(0,h.useEffect)(()=>{!a&&e.length>0&&_(e[0].id)},[e,a]);let A=(0,h.useCallback)(async()=>{if(a){x(!0);try{y((await s(`/memories/${a}?limit=100`)).memories)}catch{y([])}finally{x(!1)}}},[a]);(0,h.useEffect)(()=>{a&&A()},[a,A]);let j=async()=>{if(!(!S.trim()||!a)){T(!0);try{y((await s(`/memories/query`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentId:a,prompt:S.trim(),topK:20})})).memories)}catch{y([])}finally{T(!1)}}},M=()=>{C(``),A()},N=v.filter(e=>E===`high`?e.importance>3:E===`medium`?e.importance===3:E===`low`?e.importance<3:!0),P=e=>e>=4?`text-[var(--app-danger)]`:e===3?`text-[var(--app-warning)]`:`text-[var(--app-text-subtle)]`;return(0,g.jsxs)(`div`,{className:`space-y-5`,children:[(0,g.jsx)(d,{eyebrow:`Knowledge`,title:`Memories`,compact:!0,description:`What each role is retaining and how retrieval changes the visible recall set.`,metrics:[{label:`Role`,value:e.find(e=>e.id===a)?.name??`None`},{label:`Visible`,value:N.length},{label:`High Importance`,value:v.filter(e=>e.importance>3).length}],actions:(0,g.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>void A(),children:(0,g.jsx)(n,{size:14})})}),(0,g.jsx)(f,{title:`Recall Controls`,compact:!0,description:`Switch role context, run a retrieval query, or narrow by importance.`}),(0,g.jsx)(u,{className:`surface-panel-muted`,children:(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(`select`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:a,onChange:e=>_(e.target.value),children:e.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(`input`,{className:`w-64 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder-slate-600 focus:border-[var(--app-accent)] focus:outline-none`,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>e.key===`Enter`&&void j(),placeholder:`Search memories...`}),(0,g.jsx)(o,{size:`sm`,variant:`ghost`,onClick:()=>void j(),disabled:w,children:(0,g.jsx)(r,{size:14})}),S&&(0,g.jsx)(o,{size:`sm`,variant:`ghost`,onClick:M,children:`Clear`})]}),(0,g.jsx)(`div`,{className:`flex gap-1`,children:[`all`,`high`,`medium`,`low`].map(e=>(0,g.jsx)(`button`,{className:`rounded px-2 py-1 text-xs transition-colors ${E===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:bg-[var(--app-panel-muted)]`}`,onClick:()=>D(e),children:e},e))})]})}),(0,g.jsx)(u,{children:b||w?(0,g.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,g.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):N.length===0?(0,g.jsx)(m,{icon:(0,g.jsx)(t,{size:32}),title:`No memories`,description:S?`No results for this query`:`This agent has no memories yet`,className:`py-8`}):(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[N.length,` memories`]}),N.map(e=>(0,g.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,g.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,g.jsx)(l,{variant:e.type===`reflection`?`info`:e.type===`thought`?`warning`:`muted`,children:e.type}),(0,g.jsx)(l,{variant:`muted`,children:e.sourceType}),(0,g.jsx)(`span`,{className:`text-xs font-medium ${P(e.importance)}`,children:`*`.repeat(e.importance)}),e.score!=null&&(0,g.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`score: `,e.score.toFixed(3)]})]}),(0,g.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-[var(--app-text)]`,children:e.content}),(0,g.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:e.keywords.map(e=>(0,g.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-subtle)]`,children:e},e))}),e.type===`reflection`&&e.evidence&&e.evidence.length>0&&(0,g.jsxs)(`div`,{className:`mt-2`,children:[(0,g.jsxs)(`button`,{className:`text-[10px] text-[var(--app-accent)] hover:text-[var(--app-accent)]`,onClick:()=>k(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),children:[O.has(e.id)?`Hide`:`Show`,` evidence (`,e.evidence.length,` memories)`]}),O.has(e.id)&&(0,g.jsx)(`div`,{className:`mt-1.5 space-y-1 border-l-2 border-[var(--app-border)] pl-2`,children:e.evidence.map(e=>{let t=v.find(t=>t.id===e);return(0,g.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t?t.content.slice(0,120)+(t.content.length>120?`...`:``):(0,g.jsxs)(`span`,{className:`italic`,children:[`Memory `,e.slice(0,8),` (not in current view)`]})},e)})})]}),(0,g.jsxs)(`p`,{className:`mt-1.5 text-[10px] text-[var(--app-text-subtle)]`,children:[p(e.createdAt),` | accessed `,e.retrievedCount,`x | last: `,p(e.lastAccessed)]})]},e.id))]})})]})}export{_ as Memories};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{gt as t,w as n,x as r,xt as i}from"./vendor-icons-Bc_e_XXa.js";import{t as a}from"./vendor-react-bQ_cvNuA.js";import{t as o}from"./Button-CRNb8sD3.js";import{t as s}from"./api-BP4ZP9kk.js";import{f as c,t as l}from"./index-Dd3NDYZR.js";import{t as u}from"./Card-Cwvv0An8.js";import{t as d}from"./PageHeader-acLQTYct.js";import{t as f}from"./SectionHeader-NZWZgoOs.js";import{a as p}from"./format-ZWN4JNj-.js";import{t as m}from"./EmptyState-BvQA1o5K.js";var h=e(i(),1),g=a();function _(){let e=c(e=>e.roles),i=c(e=>e.fetchRoles),[a,_]=(0,h.useState)(``),[v,y]=(0,h.useState)([]),[b,x]=(0,h.useState)(!1),[S,C]=(0,h.useState)(``),[w,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(`all`),[O,k]=(0,h.useState)(new Set);(0,h.useEffect)(()=>{i()},[i]),(0,h.useEffect)(()=>{!a&&e.length>0&&_(e[0].id)},[e,a]);let A=(0,h.useCallback)(async()=>{if(a){x(!0);try{y((await s(`/memories/${a}?limit=100`)).memories)}catch{y([])}finally{x(!1)}}},[a]);(0,h.useEffect)(()=>{a&&A()},[a,A]);let j=async()=>{if(!(!S.trim()||!a)){T(!0);try{y((await s(`/memories/query`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentId:a,prompt:S.trim(),topK:20})})).memories)}catch{y([])}finally{T(!1)}}},M=()=>{C(``),A()},N=v.filter(e=>E===`high`?e.importance>3:E===`medium`?e.importance===3:E===`low`?e.importance<3:!0),P=e=>e>=4?`text-[var(--app-danger)]`:e===3?`text-[var(--app-warning)]`:`text-[var(--app-text-subtle)]`;return(0,g.jsxs)(`div`,{className:`space-y-5`,children:[(0,g.jsx)(d,{eyebrow:`Knowledge`,title:`Memories`,compact:!0,description:`What each role is retaining and how retrieval changes the visible recall set.`,metrics:[{label:`Role`,value:e.find(e=>e.id===a)?.name??`None`},{label:`Visible`,value:N.length},{label:`High Importance`,value:v.filter(e=>e.importance>3).length}],actions:(0,g.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>void A(),children:(0,g.jsx)(n,{size:14})})}),(0,g.jsx)(f,{title:`Recall Controls`,compact:!0,description:`Switch role context, run a retrieval query, or narrow by importance.`}),(0,g.jsx)(u,{className:`surface-panel-muted`,children:(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(`select`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:a,onChange:e=>_(e.target.value),children:e.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(`input`,{className:`w-64 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder-slate-600 focus:border-[var(--app-accent)] focus:outline-none`,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>e.key===`Enter`&&void j(),placeholder:`Search memories...`}),(0,g.jsx)(o,{size:`sm`,variant:`ghost`,onClick:()=>void j(),disabled:w,children:(0,g.jsx)(r,{size:14})}),S&&(0,g.jsx)(o,{size:`sm`,variant:`ghost`,onClick:M,children:`Clear`})]}),(0,g.jsx)(`div`,{className:`flex gap-1`,children:[`all`,`high`,`medium`,`low`].map(e=>(0,g.jsx)(`button`,{className:`rounded px-2 py-1 text-xs transition-colors ${E===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:bg-[var(--app-panel-muted)]`}`,onClick:()=>D(e),children:e},e))})]})}),(0,g.jsx)(u,{children:b||w?(0,g.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,g.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):N.length===0?(0,g.jsx)(m,{icon:(0,g.jsx)(t,{size:32}),title:`No memories`,description:S?`No results for this query`:`This agent has no memories yet`,className:`py-8`}):(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[N.length,` memories`]}),N.map(e=>(0,g.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,g.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,g.jsx)(l,{variant:e.type===`reflection`?`info`:e.type===`thought`?`warning`:`muted`,children:e.type}),(0,g.jsx)(l,{variant:`muted`,children:e.sourceType}),(0,g.jsx)(`span`,{className:`text-xs font-medium ${P(e.importance)}`,children:`*`.repeat(e.importance)}),e.score!=null&&(0,g.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`score: `,e.score.toFixed(3)]})]}),(0,g.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-[var(--app-text)]`,children:e.content}),(0,g.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:e.keywords.map(e=>(0,g.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-subtle)]`,children:e},e))}),e.type===`reflection`&&e.evidence&&e.evidence.length>0&&(0,g.jsxs)(`div`,{className:`mt-2`,children:[(0,g.jsxs)(`button`,{className:`text-[10px] text-[var(--app-accent)] hover:text-[var(--app-accent)]`,onClick:()=>k(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),children:[O.has(e.id)?`Hide`:`Show`,` evidence (`,e.evidence.length,` memories)`]}),O.has(e.id)&&(0,g.jsx)(`div`,{className:`mt-1.5 space-y-1 border-l-2 border-[var(--app-border)] pl-2`,children:e.evidence.map(e=>{let t=v.find(t=>t.id===e);return(0,g.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t?t.content.slice(0,120)+(t.content.length>120?`...`:``):(0,g.jsxs)(`span`,{className:`italic`,children:[`Memory `,e.slice(0,8),` (not in current view)`]})},e)})})]}),(0,g.jsxs)(`p`,{className:`mt-1.5 text-[10px] text-[var(--app-text-subtle)]`,children:[p(e.createdAt),` | accessed `,e.retrievedCount,`x | last: `,p(e.lastAccessed)]})]},e.id))]})})]})}export{_ as Memories};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{t as r}from"./Button-CRNb8sD3.js";import{S as i,m as a}from"./api-BP4ZP9kk.js";import{t as o}from"./index-CXEJd-0s.js";import{t as s}from"./Card-Cwvv0An8.js";import{t as c}from"./SectionHeader-NZWZgoOs.js";import{t as l}from"./EmptyState-BvQA1o5K.js";var u=e(t(),1),d=n(),f={new:`muted`,acknowledged:`success`,dismissed:`secondary`};function p(e){let t=Date.now()-e;if(Math.floor(t/6e4)<1)return`just now`;let n=Math.floor(t/36e5);return n<24?`${n}h ago`:`${Math.floor(t/864e5)}d ago`}function m(e){return new Date(e).toLocaleString()}function h(){let[e,t]=(0,u.useState)([]),[n,h]=(0,u.useState)(!0),[g,_]=(0,u.useState)(`all`),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(null),S=(0,u.useCallback)(async()=>{h(!0);try{t(await a(g===`all`?void 0:g))}catch{t([])}finally{h(!1)}},[g]);(0,u.useEffect)(()=>{S()},[S]);let C=async(e,t)=>{x(e);try{await i(e,t),await S()}finally{x(null)}};return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsx)(c,{title:`Mistake Patterns`,description:`Cross-role failure patterns extracted from audit data.`,compact:!0,action:(0,d.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>void S(),children:`Refresh`})}),(0,d.jsx)(`div`,{className:`flex gap-2`,children:[`all`,`new`,`acknowledged`,`dismissed`].map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>_(e),className:`rounded px-3 py-1.5 text-xs font-medium transition-colors ${g===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:e===`all`?`All`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),n?(0,d.jsx)(s,{children:(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:`Loading...`})}):e.length===0?(0,d.jsx)(s,{children:(0,d.jsx)(l,{title:`No mistake patterns`,description:`Run the Mistake Digest template to aggregate failure signals from audit data.`})}):(0,d.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,d.jsxs)(s,{padding:!1,children:[(0,d.jsx)(`div`,{className:`p-4 cursor-pointer hover:bg-black/[0.02]`,onClick:()=>y(v===e.id?null:e.id),role:`button`,tabIndex:0,onKeyDown:t=>{t.key===`Enter`&&y(v===e.id?null:e.id)},children:(0,d.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,d.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,d.jsx)(o,{variant:f[e.status],children:e.status}),(0,d.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:p(e.lastSeen)}),(0,d.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-muted)] font-mono`,children:e.dimensionType})]}),(0,d.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.dimensionValue}),(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-muted)]`,children:[e.count,` occurrence`,e.count===1?``:`s`,` across `,e.roleIds.length,` role`,e.roleIds.length===1?``:`s`]})]})})}),v===e.id&&(0,d.jsxs)(`div`,{className:`border-t border-[var(--app-border)] p-4 space-y-3`,children:[(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Dimension`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)] font-mono`,children:e.dimensionType})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Dimension Value`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)] font-mono break-all`,children:e.dimensionValue})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Affected Roles`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.roleIds.length>0?e.roleIds.join(`, `):`—`})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Evidence Items`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.sampleEvidenceIds.length>0?(0,d.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[e.sampleEvidenceIds.slice(0,5).map(e=>(0,d.jsxs)(`span`,{className:`text-xs`,children:[(0,d.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1 py-0.5 text-[10px] font-mono`,children:e.source}),` `,e.id]},e.id)),e.sampleEvidenceIds.length>5&&(0,d.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`+`,e.sampleEvidenceIds.length-5,` more`]})]}):`—`})]})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-4 pt-1`,children:[(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`First seen: `,m(e.firstSeen)]}),(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Last seen: `,m(e.lastSeen)]})]}),(0,d.jsx)(`div`,{className:`flex gap-2 pt-1`,children:[`new`,`acknowledged`,`dismissed`].map(t=>(0,d.jsx)(r,{variant:e.status===t?`default`:`ghost`,size:`sm`,disabled:b===e.id||e.status===t,onClick:n=>{n.stopPropagation(),C(e.id,t)},children:t.charAt(0).toUpperCase()+t.slice(1)},t))})]})]},e.id))})]})}export{h as Mistakes};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{t as r}from"./Button-CRNb8sD3.js";import{S as i,m as a}from"./api-BP4ZP9kk.js";import{t as o}from"./index-Dd3NDYZR.js";import{t as s}from"./Card-Cwvv0An8.js";import{t as c}from"./SectionHeader-NZWZgoOs.js";import{t as l}from"./EmptyState-BvQA1o5K.js";var u=e(t(),1),d=n(),f={new:`muted`,acknowledged:`success`,dismissed:`secondary`};function p(e){let t=Date.now()-e;if(Math.floor(t/6e4)<1)return`just now`;let n=Math.floor(t/36e5);return n<24?`${n}h ago`:`${Math.floor(t/864e5)}d ago`}function m(e){return new Date(e).toLocaleString()}function h(){let[e,t]=(0,u.useState)([]),[n,h]=(0,u.useState)(!0),[g,_]=(0,u.useState)(`all`),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(null),S=(0,u.useCallback)(async()=>{h(!0);try{t(await a(g===`all`?void 0:g))}catch{t([])}finally{h(!1)}},[g]);(0,u.useEffect)(()=>{S()},[S]);let C=async(e,t)=>{x(e);try{await i(e,t),await S()}finally{x(null)}};return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsx)(c,{title:`Mistake Patterns`,description:`Cross-role failure patterns extracted from audit data.`,compact:!0,action:(0,d.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>void S(),children:`Refresh`})}),(0,d.jsx)(`div`,{className:`flex gap-2`,children:[`all`,`new`,`acknowledged`,`dismissed`].map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>_(e),className:`rounded px-3 py-1.5 text-xs font-medium transition-colors ${g===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:e===`all`?`All`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),n?(0,d.jsx)(s,{children:(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:`Loading...`})}):e.length===0?(0,d.jsx)(s,{children:(0,d.jsx)(l,{title:`No mistake patterns`,description:`Run the Mistake Digest template to aggregate failure signals from audit data.`})}):(0,d.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,d.jsxs)(s,{padding:!1,children:[(0,d.jsx)(`div`,{className:`p-4 cursor-pointer hover:bg-black/[0.02]`,onClick:()=>y(v===e.id?null:e.id),role:`button`,tabIndex:0,onKeyDown:t=>{t.key===`Enter`&&y(v===e.id?null:e.id)},children:(0,d.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,d.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,d.jsx)(o,{variant:f[e.status],children:e.status}),(0,d.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:p(e.lastSeen)}),(0,d.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-muted)] font-mono`,children:e.dimensionType})]}),(0,d.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.dimensionValue}),(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-muted)]`,children:[e.count,` occurrence`,e.count===1?``:`s`,` across `,e.roleIds.length,` role`,e.roleIds.length===1?``:`s`]})]})})}),v===e.id&&(0,d.jsxs)(`div`,{className:`border-t border-[var(--app-border)] p-4 space-y-3`,children:[(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Dimension`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)] font-mono`,children:e.dimensionType})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Dimension Value`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)] font-mono break-all`,children:e.dimensionValue})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Affected Roles`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.roleIds.length>0?e.roleIds.join(`, `):`—`})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Evidence Items`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.sampleEvidenceIds.length>0?(0,d.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[e.sampleEvidenceIds.slice(0,5).map(e=>(0,d.jsxs)(`span`,{className:`text-xs`,children:[(0,d.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1 py-0.5 text-[10px] font-mono`,children:e.source}),` `,e.id]},e.id)),e.sampleEvidenceIds.length>5&&(0,d.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`+`,e.sampleEvidenceIds.length-5,` more`]})]}):`—`})]})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-4 pt-1`,children:[(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`First seen: `,m(e.firstSeen)]}),(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Last seen: `,m(e.lastSeen)]})]}),(0,d.jsx)(`div`,{className:`flex gap-2 pt-1`,children:[`new`,`acknowledged`,`dismissed`].map(t=>(0,d.jsx)(r,{variant:e.status===t?`default`:`ghost`,size:`sm`,disabled:b===e.id||e.status===t,onClick:n=>{n.stopPropagation(),C(e.id,t)},children:t.charAt(0).toUpperCase()+t.slice(1)},t))})]})]},e.id))})]})}export{h as Mistakes};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,E as n,K as r,ft as i,ht as a,mt as o,n as s,nt as c,pt as l,st as u,tt as d,w as f,x as ee,xt as p,z as m}from"./vendor-icons-Bc_e_XXa.js";import{t as te}from"./vendor-react-bQ_cvNuA.js";import{n as h}from"./dist-CgGno8kE.js";import{_ as g,a as ne,c as _,d as v,f as y,i as re,m as b,n as ie,o as x,p as S,r as C,s as w,t as ae,u as oe,v as T}from"./es2015-BkFSNOYE.js";import{i as E,r as D,t as O}from"./Button-CRNb8sD3.js";import{t as k}from"./api-BP4ZP9kk.js";import{S as A,_ as se,b as ce,g as j,h as M,m as le,p as N,t as P,v as ue,x as F,y as de}from"./index-CXEJd-0s.js";import{t as I}from"./Card-Cwvv0An8.js";import{t as fe}from"./PageHeader-acLQTYct.js";import{t as pe}from"./SectionHeader-NZWZgoOs.js";import{a as me}from"./format-ZWN4JNj-.js";import{t as he}from"./EmptyState-BvQA1o5K.js";import{t as L}from"./ui-D1crlGpt.js";import{a as ge,i as R,n as _e,o as z,r as B,t as ve}from"./Table-CvSmzzkm.js";import{n as ye,r as be,t as xe}from"./usePluginsWithUsage-4iLJAPjH.js";import{a as Se,c as Ce,i as we,l as Te,n as Ee,o as De,r as Oe,s as ke,t as Ae}from"./Tabs-DWk9HyNd.js";var V=e(p(),1),H=te();function je(){let[e,t]=(0,V.useState)(!1),[n,r]=(0,V.useState)([]),o=(0,V.useCallback)(async()=>{try{r((await k(`/plugins/stats?limit=20`)).stats)}catch{r([])}},[]);return(0,H.jsxs)(I,{children:[(0,H.jsxs)(`button`,{className:`flex w-full items-center gap-2 text-sm font-semibold text-[var(--app-text)]`,onClick:()=>{!e&&n.length===0&&o(),t(e=>!e)},children:[(0,H.jsx)(a,{size:L.sm,className:`text-[var(--app-text-muted)]`}),`Usage Stats`,e?(0,H.jsx)(l,{size:L.xs,className:`ml-auto`}):(0,H.jsx)(i,{size:L.xs,className:`ml-auto`})]}),e?(0,H.jsx)(`div`,{className:`mt-3`,children:n.length===0?(0,H.jsx)(`p`,{className:`py-2 text-center text-xs text-[var(--app-text-subtle)]`,children:`No usage data yet`}):(0,H.jsxs)(ve,{children:[(0,H.jsx)(ge,{children:(0,H.jsxs)(z,{children:[(0,H.jsx)(R,{children:`Plugin`}),(0,H.jsx)(R,{children:`Usage Count`}),(0,H.jsx)(R,{children:`Last Used`})]})}),(0,H.jsx)(_e,{children:n.map(e=>(0,H.jsxs)(z,{children:[(0,H.jsx)(B,{className:`text-xs font-medium text-[var(--app-text)]`,children:e.pluginName}),(0,H.jsx)(B,{className:`font-mono text-xs text-[var(--app-text-muted)]`,children:e.usageCount}),(0,H.jsx)(B,{className:`text-xs text-[var(--app-text-muted)]`,children:e.lastUsed?me(e.lastUsed):`—`})]},e.pluginPath))})]})}):null]})}var Me=[`Enter`,` `],Ne=[`ArrowDown`,`PageUp`,`Home`],Pe=[`ArrowUp`,`PageDown`,`End`],Fe=[...Ne,...Pe],Ie={ltr:[...Me,`ArrowRight`],rtl:[...Me,`ArrowLeft`]},Le={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},U=`Menu`,[W,Re,ze]=Te(U),[G,Be]=g(U,[ze,A,ke]),K=A(),Ve=ke(),[He,q]=G(U),[Ue,J]=G(U),We=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=K(t),[c,l]=V.useState(null),u=V.useRef(!1),d=v(a),f=Ce(i);return V.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,H.jsx)(F,{...s,children:(0,H.jsx)(He,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,H.jsx)(Ue,{scope:t,onClose:V.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};We.displayName=U;var Ge=`MenuAnchor`,Ke=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=K(n);return(0,H.jsx)(ue,{...i,...r,ref:t})});Ke.displayName=Ge;var qe=`MenuPortal`,[Je,Ye]=G(qe,{forceMount:void 0}),Xe=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=q(qe,t);return(0,H.jsx)(Je,{scope:t,forceMount:n,children:(0,H.jsx)(x,{present:n||a.open,children:(0,H.jsx)(w,{asChild:!0,container:i,children:r})})})};Xe.displayName=qe;var Y=`MenuContent`,[Ze,Qe]=G(Y),$e=V.forwardRef((e,t)=>{let n=Ye(Y,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeMenu),o=J(Y,e.__scopeMenu);return(0,H.jsx)(W.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(x,{present:r||a.open,children:(0,H.jsx)(W.Slot,{scope:e.__scopeMenu,children:o.modal?(0,H.jsx)(et,{...i,ref:t}):(0,H.jsx)(tt,{...i,ref:t})})})})}),et=V.forwardRef((e,t)=>{let n=q(Y,e.__scopeMenu),r=V.useRef(null),i=E(t,r);return V.useEffect(()=>{let e=r.current;if(e)return ae(e)},[]),(0,H.jsx)(rt,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:T(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),tt=V.forwardRef((e,t)=>{let n=q(Y,e.__scopeMenu);return(0,H.jsx)(rt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),nt=b(`MenuContent.ScrollLock`),rt=V.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:ee,disableOutsideScroll:p,...m}=e,te=q(Y,n),h=J(Y,n),g=K(n),ne=Ve(n),_=Re(n),[v,y]=V.useState(null),b=V.useRef(null),x=E(t,b,te.onContentChange),S=V.useRef(0),w=V.useRef(``),ae=V.useRef(0),D=V.useRef(null),O=V.useRef(`right`),k=V.useRef(0),A=p?ie:V.Fragment,se=p?{as:nt,allowPinchZoom:!0}:void 0,j=e=>{let t=w.current+e,n=_().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Bt(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){w.current=t,window.clearTimeout(S.current),t!==``&&(S.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};V.useEffect(()=>()=>window.clearTimeout(S.current),[]),C();let M=V.useCallback(e=>O.current===D.current?.side&&Ht(e,D.current?.area),[]);return(0,H.jsx)(Ze,{scope:n,searchRef:w,onItemEnter:V.useCallback(e=>{M(e)&&e.preventDefault()},[M]),onItemLeave:V.useCallback(e=>{M(e)||(b.current?.focus(),y(null))},[M]),onTriggerLeave:V.useCallback(e=>{M(e)&&e.preventDefault()},[M]),pointerGraceTimerRef:ae,onPointerGraceIntentChange:V.useCallback(e=>{D.current=e},[]),children:(0,H.jsx)(A,{...se,children:(0,H.jsx)(re,{asChild:!0,trapped:i,onMountAutoFocus:T(a,e=>{e.preventDefault(),b.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,H.jsx)(oe,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:ee,children:(0,H.jsx)(De,{asChild:!0,...ne,dir:h.dir,orientation:`vertical`,loop:r,currentTabStopId:v,onCurrentTabStopIdChange:y,onEntryFocus:T(c,e=>{h.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,H.jsx)(ce,{role:`menu`,"aria-orientation":`vertical`,"data-state":Ft(te.open),"data-radix-menu-content":``,dir:h.dir,...g,...m,ref:x,style:{outline:`none`,...m.style},onKeyDown:T(m.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&j(e.key));let i=b.current;if(e.target!==i||!Fe.includes(e.key))return;e.preventDefault();let a=_().filter(e=>!e.disabled).map(e=>e.ref.current);Pe.includes(e.key)&&a.reverse(),Rt(a)}),onBlur:T(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(S.current),w.current=``)}),onPointerMove:T(e.onPointerMove,Z(e=>{let t=e.target,n=k.current!==e.clientX;e.currentTarget.contains(t)&&n&&(O.current=e.clientX>k.current?`right`:`left`,k.current=e.clientX)}))})})})})})})});$e.displayName=Y;var it=`MenuGroup`,at=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{role:`group`,...r,ref:t})});at.displayName=it;var ot=`MenuLabel`,st=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{...r,ref:t})});st.displayName=ot;var ct=`MenuItem`,lt=`menu.itemSelect`,ut=V.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=V.useRef(null),o=J(ct,e.__scopeMenu),s=Qe(ct,e.__scopeMenu),c=E(t,a),l=V.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(lt,{bubbles:!0,cancelable:!0});e.addEventListener(lt,e=>r?.(e),{once:!0}),S(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,H.jsx)(dt,{...i,ref:c,disabled:n,onClick:T(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:T(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:T(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||Me.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ut.displayName=ct;var dt=V.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Qe(ct,n),s=Ve(n),c=V.useRef(null),l=E(t,c),[u,d]=V.useState(!1),[f,ee]=V.useState(``);return V.useEffect(()=>{let e=c.current;e&&ee((e.textContent??``).trim())},[a.children]),(0,H.jsx)(W.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,H.jsx)(Se,{asChild:!0,...s,focusable:!r,children:(0,H.jsx)(y.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:T(e.onPointerMove,Z(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:T(e.onPointerLeave,Z(e=>o.onItemLeave(e))),onFocus:T(e.onFocus,()=>d(!0)),onBlur:T(e.onBlur,()=>d(!1))})})})}),ft=`MenuCheckboxItem`,pt=V.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,H.jsx)(xt,{scope:e.__scopeMenu,checked:n,children:(0,H.jsx)(ut,{role:`menuitemcheckbox`,"aria-checked":It(n)?`mixed`:n,...i,ref:t,"data-state":Lt(n),onSelect:T(i.onSelect,()=>r?.(It(n)?!0:!n),{checkForDefaultPrevented:!1})})})});pt.displayName=ft;var mt=`MenuRadioGroup`,[ht,gt]=G(mt,{value:void 0,onValueChange:()=>{}}),_t=V.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=v(r);return(0,H.jsx)(ht,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,H.jsx)(at,{...i,ref:t})})});_t.displayName=mt;var vt=`MenuRadioItem`,yt=V.forwardRef((e,t)=>{let{value:n,...r}=e,i=gt(vt,e.__scopeMenu),a=n===i.value;return(0,H.jsx)(xt,{scope:e.__scopeMenu,checked:a,children:(0,H.jsx)(ut,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Lt(a),onSelect:T(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});yt.displayName=vt;var bt=`MenuItemIndicator`,[xt,St]=G(bt,{checked:!1}),Ct=V.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=St(bt,n);return(0,H.jsx)(x,{present:r||It(a.checked)||a.checked===!0,children:(0,H.jsx)(y.span,{...i,ref:t,"data-state":Lt(a.checked)})})});Ct.displayName=bt;var wt=`MenuSeparator`,Tt=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Tt.displayName=wt;var Et=`MenuArrow`,Dt=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=K(n);return(0,H.jsx)(de,{...i,...r,ref:t})});Dt.displayName=Et;var Ot=`MenuSub`,[kt,At]=G(Ot),jt=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=q(Ot,t),o=K(t),[s,c]=V.useState(null),[l,u]=V.useState(null),d=v(i);return V.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,H.jsx)(F,{...o,children:(0,H.jsx)(He,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,H.jsx)(kt,{scope:t,contentId:_(),triggerId:_(),trigger:s,onTriggerChange:c,children:n})})})};jt.displayName=Ot;var X=`MenuSubTrigger`,Mt=V.forwardRef((e,t)=>{let n=q(X,e.__scopeMenu),r=J(X,e.__scopeMenu),i=At(X,e.__scopeMenu),a=Qe(X,e.__scopeMenu),o=V.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=V.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return V.useEffect(()=>u,[u]),V.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,H.jsx)(Ke,{asChild:!0,...l,children:(0,H.jsx)(dt,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Ft(n.open),...e,ref:D(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:T(e.onPointerMove,Z(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:T(e.onPointerLeave,Z(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:T(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Ie[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Mt.displayName=X;var Nt=`MenuSubContent`,Pt=V.forwardRef((e,t)=>{let n=Ye(Y,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeMenu),o=J(Y,e.__scopeMenu),s=At(Nt,e.__scopeMenu),c=V.useRef(null),l=E(t,c);return(0,H.jsx)(W.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(x,{present:r||a.open,children:(0,H.jsx)(W.Slot,{scope:e.__scopeMenu,children:(0,H.jsx)(rt,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:T(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:T(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:T(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Le[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Pt.displayName=Nt;function Ft(e){return e?`open`:`closed`}function It(e){return e===`indeterminate`}function Lt(e){return It(e)?`indeterminate`:e?`checked`:`unchecked`}function Rt(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function zt(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Bt(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=zt(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Vt(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Ht(e,t){return t?Vt({x:e.clientX,y:e.clientY},t):!1}function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Ut=We,Wt=Ke,Gt=Xe,Kt=$e,qt=at,Jt=st,Yt=ut,Xt=pt,Zt=_t,Qt=yt,$t=Ct,en=Tt,tn=Dt,nn=Mt,rn=Pt,an=`DropdownMenu`,[on,sn]=g(an,[Be]),Q=Be(),[cn,ln]=on(an),un=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Q(t),l=V.useRef(null),[u,d]=ne({prop:i,defaultProp:a??!1,onChange:o,caller:an});return(0,H.jsx)(cn,{scope:t,triggerId:_(),triggerRef:l,contentId:_(),open:u,onOpenChange:d,onOpenToggle:V.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,H.jsx)(Ut,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};un.displayName=an;var dn=`DropdownMenuTrigger`,fn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ln(dn,n),o=Q(n);return(0,H.jsx)(Wt,{asChild:!0,...o,children:(0,H.jsx)(y.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:D(t,a.triggerRef),onPointerDown:T(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:T(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});fn.displayName=dn;var pn=`DropdownMenuPortal`,mn=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Q(t);return(0,H.jsx)(Gt,{...r,...n})};mn.displayName=pn;var hn=`DropdownMenuContent`,gn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ln(hn,n),a=Q(n),o=V.useRef(!1);return(0,H.jsx)(Kt,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:T(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:T(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});gn.displayName=hn;var _n=`DropdownMenuGroup`,vn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(qt,{...i,...r,ref:t})});vn.displayName=_n;var yn=`DropdownMenuLabel`,bn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Jt,{...i,...r,ref:t})});bn.displayName=yn;var xn=`DropdownMenuItem`,Sn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Yt,{...i,...r,ref:t})});Sn.displayName=xn;var Cn=`DropdownMenuCheckboxItem`,wn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Xt,{...i,...r,ref:t})});wn.displayName=Cn;var Tn=`DropdownMenuRadioGroup`,En=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Zt,{...i,...r,ref:t})});En.displayName=Tn;var Dn=`DropdownMenuRadioItem`,On=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Qt,{...i,...r,ref:t})});On.displayName=Dn;var kn=`DropdownMenuItemIndicator`,An=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)($t,{...i,...r,ref:t})});An.displayName=kn;var jn=`DropdownMenuSeparator`,Mn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(en,{...i,...r,ref:t})});Mn.displayName=jn;var Nn=`DropdownMenuArrow`,Pn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(tn,{...i,...r,ref:t})});Pn.displayName=Nn;var Fn=`DropdownMenuSubTrigger`,In=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(nn,{...i,...r,ref:t})});In.displayName=Fn;var Ln=`DropdownMenuSubContent`,Rn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(rn,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Rn.displayName=Ln;var zn=un,Bn=fn,Vn=mn,Hn=gn,Un=bn,Wn=Sn,Gn=wn,Kn=On,qn=An,Jn=Mn,Yn=In,Xn=Rn,Zn=zn,Qn=Bn,$n=V.forwardRef(({className:e,inset:t,children:n,...r},a)=>(0,H.jsxs)(Yn,{ref:a,className:h(`flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-[var(--app-panel-elevated)] data-[state=open]:bg-[var(--app-panel-elevated)] [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...r,children:[n,(0,H.jsx)(i,{className:`ml-auto`})]}));$n.displayName=Yn.displayName;var er=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Xn,{ref:n,className:h(`z-50 min-w-[8rem] overflow-hidden rounded-md border border-[var(--app-border)] bg-[var(--app-panel)] p-1 text-[var(--app-text)] shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));er.displayName=Xn.displayName;var tr=V.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,H.jsx)(Vn,{children:(0,H.jsx)(Hn,{ref:r,sideOffset:t,className:h(`z-50 min-w-[8rem] overflow-hidden rounded-md border border-[var(--app-border)] bg-[var(--app-panel)] p-1 text-[var(--app-text)] shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));tr.displayName=Hn.displayName;var $=V.forwardRef(({className:e,inset:t,...n},r)=>(0,H.jsx)(Wn,{ref:r,className:h(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...n}));$.displayName=Wn.displayName;var nr=V.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,H.jsxs)(Gn,{ref:i,className:h(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,H.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,H.jsx)(qn,{children:(0,H.jsx)(o,{className:`h-4 w-4`})})}),t]}));nr.displayName=Gn.displayName;var rr=V.forwardRef(({className:e,children:t,...n},r)=>(0,H.jsxs)(Kn,{ref:r,className:h(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,H.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,H.jsx)(qn,{children:(0,H.jsx)(u,{className:`h-2 w-2 fill-current`})})}),t]}));rr.displayName=Kn.displayName;var ir=V.forwardRef(({className:e,inset:t,...n},r)=>(0,H.jsx)(Un,{ref:r,className:h(`px-2 py-1.5 text-sm font-semibold text-[var(--app-text)]`,t&&`pl-8`,e),...n}));ir.displayName=Un.displayName;var ar=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Jn,{ref:n,className:h(`-mx-1 my-1 h-px bg-[var(--app-panel-elevated)]`,e),...t}));ar.displayName=Jn.displayName;var or=({className:e,...t})=>(0,H.jsx)(`span`,{className:h(`ml-auto text-xs tracking-widest text-[var(--app-text-subtle)]`,e),...t});or.displayName=`DropdownMenuShortcut`;function sr({plugin:e}){let t=e.manifest;if(!t)return null;let n=[];return t.skills.length>0&&n.push({label:`Skill(${t.skills.length})`,variant:`info`}),t.agents.length>0&&n.push({label:`Agent(${t.agents.length})`,variant:`success`}),t.mcpServers.length>0&&n.push({label:`MCP(${t.mcpServers.length})`,variant:`warning`}),t.hooks.length>0&&n.push({label:`Hook(${t.hooks.length})`,variant:`default`}),t.lspServers.length>0&&n.push({label:`LSP(${t.lspServers.length})`,variant:`default`}),n.length===0?null:(0,H.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:n.map(e=>(0,H.jsx)(P,{variant:e.variant,children:e.label},e.label))})}function cr({plugin:e,roles:t,onInstallToRole:n,onToggleGlobal:r,onUninstallUser:i,projectOperatingKey:a,userOperatingId:o}){let s=o===e.id;return(0,H.jsxs)(Zn,{modal:!1,children:[(0,H.jsx)(Qn,{asChild:!0,children:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-7 w-7 px-0`,"aria-label":`Manage ${e.name}`,children:s?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):(0,H.jsx)(d,{size:L.sm})})}),(0,H.jsxs)(tr,{align:`end`,className:`min-w-[200px]`,children:[t.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ir,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Add to Role`}),t.map(t=>{let r=e.usedByRoles.some(e=>e.roleId===t.id),i=a===`${e.id}:${t.workspacePath}`;return(0,H.jsxs)($,{disabled:i||r,onSelect:()=>{n(e.id,t.workspacePath)},children:[(0,H.jsx)(`span`,{className:`flex-1`,children:t.name}),i?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):r?(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`installed`}):null]},t.id)}),(0,H.jsx)(ar,{})]}):null,(0,H.jsx)($,{disabled:s,onSelect:()=>{r(e.id,!e.globalEnabled)},children:e.globalEnabled?`Disable`:`Enable`}),(0,H.jsx)($,{disabled:s,className:`text-[var(--app-danger)] focus:text-[var(--app-danger)]`,onSelect:()=>{i(e.id)},children:`Uninstall`})]})]})}function lr({plugin:e,roles:t,expandedContent:n,onInstallToRole:r,onToggleGlobal:a,onUninstallUser:o,projectOperatingKey:s,userOperatingId:c}){let[u,d]=(0,V.useState)(!1),f=e.usedByRoles.map(e=>`${e.roleName} (v${e.version})`).join(`, `)||`No Roles`;return(0,H.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`button`,{className:`mt-0.5 text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>d(e=>!e),"aria-label":u?`Collapse ${e.name}`:`Expand ${e.name}`,children:u?(0,H.jsx)(l,{size:L.xs}):(0,H.jsx)(i,{size:L.xs})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`v`,e.version]}),e.marketplace?(0,H.jsx)(P,{variant:`muted`,className:`text-[10px]`,children:e.marketplace}):null,(0,H.jsx)(j,{delayDuration:150,children:(0,H.jsxs)(le,{children:[(0,H.jsx)(se,{asChild:!0,children:(0,H.jsxs)(`button`,{className:`text-xs text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,title:f,children:[e.usedByRoles.length,` `,e.usedByRoles.length===1?`Role`:`Roles`]})}),(0,H.jsx)(M,{children:f})]})})]}),(0,H.jsx)(sr,{plugin:e})]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,H.jsx)(P,{variant:e.globalEnabled?`success`:`destructive`,children:e.globalEnabled?`User On`:`User Off`}),(0,H.jsx)(cr,{plugin:e,roles:t,onInstallToRole:r,onToggleGlobal:a,onUninstallUser:o,projectOperatingKey:s,userOperatingId:c})]})]}),u?(0,H.jsx)(`div`,{className:`mt-4 rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:n}):null]})}function ur({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:e}),(0,H.jsx)(`p`,{className:`mt-1 text-sm font-medium text-[var(--app-text)]`,children:t})]})}function dr({plugin:e}){return e.manifest?(0,H.jsxs)(`div`,{className:`space-y-4 text-xs`,children:[e.manifest.description?(0,H.jsx)(`p`,{className:`text-[var(--app-text-muted)]`,children:e.manifest.description}):null,(0,H.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-4`,children:[(0,H.jsx)(ur,{label:`Version`,value:e.version?`v${e.version}`:`—`}),(0,H.jsx)(ur,{label:`Scope`,value:e.scope}),(0,H.jsx)(ur,{label:`Capability Count`,value:e.manifest.skills.length+e.manifest.agents.length+e.manifest.mcpServers.length+e.manifest.hooks.length+e.manifest.lspServers.length}),(0,H.jsx)(ur,{label:`Activation`,value:e.globalEnabled?`User On`:`User Off`})]}),(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Install Path`}),(0,H.jsx)(`p`,{className:`mt-1 truncate font-mono text-[11px] text-[var(--app-text-muted)]`,title:e.installPath,children:e.installPath})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[e.manifest.skills.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Skills`}),e.manifest.skills.map(e=>(0,H.jsxs)(`div`,{className:`inline-flex items-baseline gap-1 text-[var(--app-text-muted)]`,children:[(0,H.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),e.description?(0,H.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`; `,e.description]}):null]},e.name))]}):null,e.manifest.agents.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Agents`}),e.manifest.agents.map(e=>(0,H.jsxs)(`div`,{className:`inline-flex items-baseline gap-1 text-[var(--app-text-muted)]`,children:[(0,H.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),e.description?(0,H.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`; `,e.description]}):null]},e.name))]}):null,e.manifest.mcpServers.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`MCP Servers`}),e.manifest.mcpServers.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null,e.manifest.hooks.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Hooks`}),e.manifest.hooks.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null,e.manifest.lspServers.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`LSP Servers`}),e.manifest.lspServers.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null]})]}):(0,H.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading manifest...`})}function fr(){let{userScope:e,projectScope:i,loading:a,error:o,refresh:u,rawPlugins:d,roles:p}=xe(),[te,h]=(0,V.useState)(`installed`),[g,ne]=(0,V.useState)([]),[_,v]=(0,V.useState)([]),[y,re]=(0,V.useState)(new Set),[b,ie]=(0,V.useState)(!1),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(``),[ae,oe]=(0,V.useState)(!1),[T,E]=(0,V.useState)(``),[D,A]=(0,V.useState)(null),[se,ce]=(0,V.useState)(null),{operatingKey:j,installToRole:M,uninstallFromRole:le,updateRoleVersion:ue}=ye(u),F=(0,V.useCallback)(async()=>{ie(!0),S(null);try{let[e,t]=await Promise.all([k(`/plugins/marketplace`).catch(()=>({available:[],installed:[]})),k(`/plugins/marketplaces`)]);v(e.available),re(new Set(e.installed.map(e=>e.id))),ne(t.sources)}catch(e){S(e instanceof Error?e.message:`Failed to load marketplace`)}finally{ie(!1)}},[]);(0,V.useEffect)(()=>{F()},[F]);let de=(0,V.useCallback)(async(e,t)=>{A(e);try{await k(`/plugins/${encodeURIComponent(e)}/${t?`enable`:`disable`}`,{method:`POST`}),N.success(`${e} ${t?`enabled`:`disabled`} globally`)}catch(e){N.error(e instanceof Error?e.message:`Failed to ${t?`enable`:`disable`} plugin`)}finally{await u(),A(null)}},[u]),me=(0,V.useCallback)(async e=>{A(e);try{await k(`/plugins/uninstall/${encodeURIComponent(e)}`,{method:`POST`}),N.success(`Plugin uninstalled`)}catch(e){N.error(e instanceof Error?e.message:`Uninstall failed`)}finally{await Promise.all([u(),F()]),A(null)}},[F,u]),Se=(0,V.useCallback)(async()=>{let e=T.trim();if(e)try{await k(`/plugins/marketplaces`,{method:`POST`,body:JSON.stringify({url:e})}),N.success(`Marketplace added`),E(``),oe(!1),await F()}catch(e){N.error(e instanceof Error?e.message:`Failed to add marketplace`)}},[F,T]),Ce=(0,V.useCallback)(async(e,t=`user`,n)=>{ce(e);try{await k(`/plugins/install/${encodeURIComponent(e)}`,{method:`POST`,body:JSON.stringify({scope:t,cwd:n})});let r=t===`project`&&n?`${e.split(`@`)[0]} for ${n.split(`/`).pop()}`:e.split(`@`)[0];N.success(`Installed ${r}`)}catch(e){N.error(e instanceof Error?e.message:`Install failed`)}finally{await Promise.all([u(),F()]),ce(null)}},[F,u]),Te=C?_.filter(e=>e.name.toLowerCase().includes(C.toLowerCase())||e.description.toLowerCase().includes(C.toLowerCase())):_,De=d.filter(e=>e.scope===`project`).length;return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsx)(fe,{eyebrow:`Capabilities`,title:`Plugins`,compact:!0,description:`Installed capabilities, scope, and activation.`,metrics:[{label:`Total`,value:d.length},{label:`Project Scope`,value:De},{label:`Catalog`,value:_.length}],actions:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>void Promise.all([u(),F()]),children:(0,H.jsx)(f,{size:L.sm})})}),(0,H.jsx)(pe,{title:`Plugin Library`,compact:!0,description:`Installed plugins and marketplace discovery live in separate tabs.`}),(0,H.jsxs)(Ae,{value:te,onValueChange:e=>h(e),children:[(0,H.jsxs)(Oe,{children:[(0,H.jsxs)(we,{value:`installed`,children:[`Installed (`,e.length,`)`]}),(0,H.jsxs)(we,{value:`marketplace`,children:[`Marketplace (`,_.length,`)`]})]}),(0,H.jsx)(Ee,{value:`installed`,className:`space-y-5`,children:a?(0,H.jsx)(I,{children:(0,H.jsx)(`div`,{className:`py-8 text-center text-sm text-[var(--app-text-subtle)]`,children:`Loading...`})}):o?(0,H.jsx)(I,{children:(0,H.jsx)(`div`,{className:`py-8 text-center text-sm text-[var(--app-danger)]`,children:o})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(pe,{title:`User scope`,compact:!0,description:`Global defaults. Available to all Roles unless overridden.`}),e.length===0?(0,H.jsx)(I,{children:(0,H.jsx)(he,{icon:(0,H.jsx)(n,{size:L.hero}),title:`No user-scope plugins`,description:`Install a plugin once here to make it available as the default for every Role.`,className:`py-8`})}):(0,H.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,H.jsx)(lr,{plugin:e,roles:p,expandedContent:(0,H.jsx)(dr,{plugin:e}),onInstallToRole:M,onToggleGlobal:de,onUninstallUser:me,projectOperatingKey:j,userOperatingId:D},e.id))})]}),(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(pe,{title:`Project scope`,compact:!0,description:`Role-specific overrides. Only plugins that differ from user scope are shown here.`}),(0,H.jsx)(be,{groups:i,layout:`full`,onUninstall:le,onUpdate:ue,operatingKey:j})]}),(0,H.jsx)(je,{})]})}),(0,H.jsxs)(Ee,{value:`marketplace`,className:`space-y-4`,children:[(0,H.jsxs)(I,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(r,{size:L.sm,className:`flex-shrink-0 text-[var(--app-text-muted)]`}),g.map(e=>(0,H.jsx)(P,{variant:`muted`,className:`text-xs`,children:e.name},e.name)),(0,H.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[b?(0,H.jsx)(m,{size:L.xs,className:`animate-spin text-[var(--app-text-subtle)]`}):null,(0,H.jsxs)(O,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>oe(e=>!e),children:[ae?(0,H.jsx)(s,{size:L.xs}):(0,H.jsx)(t,{size:L.xs}),`Source`]})]})]}),ae?(0,H.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,H.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:T,onChange:e=>E(e.target.value),placeholder:`https://github.com/org/marketplace-repo`,onKeyDown:e=>{e.key===`Enter`&&Se()}}),(0,H.jsx)(O,{size:`sm`,onClick:()=>void Se(),disabled:!T.trim(),children:`Add`})]}):null]}),(0,H.jsx)(I,{children:(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(ee,{size:L.sm,className:`absolute left-2.5 top-2 text-[var(--app-text-subtle)]`}),(0,H.jsx)(`input`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] py-1.5 pl-8 pr-3 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,value:C,onChange:e=>w(e.target.value),placeholder:`Search available plugins...`})]})}),b?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-text-subtle)]`,children:`Loading marketplace...`})}):x?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-danger)]`,children:x})}):Te.length===0?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-text-subtle)]`,children:C?`No plugins match your search`:`No marketplace plugins available`})}):(0,H.jsx)(I,{padding:!1,children:(0,H.jsxs)(ve,{children:[(0,H.jsx)(ge,{children:(0,H.jsxs)(z,{children:[(0,H.jsx)(R,{children:`Name`}),(0,H.jsx)(R,{children:`Description`}),(0,H.jsx)(R,{children:`Source`}),(0,H.jsx)(R,{children:`Action`})]})}),(0,H.jsx)(_e,{children:Te.map(e=>{let t=y.has(e.pluginId),n=se===e.pluginId;return(0,H.jsxs)(z,{children:[(0,H.jsx)(B,{className:`text-xs font-medium text-[var(--app-text)]`,children:e.name}),(0,H.jsx)(B,{className:`max-w-[300px] truncate text-xs text-[var(--app-text-muted)]`,title:e.description,children:e.description}),(0,H.jsx)(B,{children:(0,H.jsx)(P,{variant:`muted`,className:`text-[10px]`,children:e.marketplaceName})}),(0,H.jsx)(B,{children:t?(0,H.jsx)(P,{variant:`success`,className:`text-[10px]`,children:`Installed`}):(0,H.jsxs)(Zn,{modal:!1,children:[(0,H.jsx)(Qn,{asChild:!0,children:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,disabled:n,children:n?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(c,{size:L.xs}),`Install`,(0,H.jsx)(l,{size:L.xs})]})})}),(0,H.jsxs)(tr,{align:`end`,className:`min-w-[200px]`,children:[(0,H.jsx)($,{disabled:n,onSelect:()=>{Ce(e.pluginId)},children:`Install globally (User scope)`}),p.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ar,{}),p.map(t=>(0,H.jsxs)($,{disabled:n,onSelect:()=>{Ce(e.pluginId,`project`,t.workspacePath)},children:[`Install to `,t.name]},t.id))]}):null]})]})})]},e.pluginId)})})]})})]})]})]})}export{fr as Plugins};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,E as n,K as r,ft as i,ht as a,mt as o,n as s,nt as c,pt as l,st as u,tt as d,w as f,x as ee,xt as p,z as m}from"./vendor-icons-Bc_e_XXa.js";import{t as te}from"./vendor-react-bQ_cvNuA.js";import{n as h}from"./dist-CgGno8kE.js";import{_ as g,a as ne,c as _,d as v,f as y,i as re,m as b,n as ie,o as x,p as S,r as C,s as w,t as ae,u as oe,v as T}from"./es2015-BkFSNOYE.js";import{i as E,r as D,t as O}from"./Button-CRNb8sD3.js";import{t as k}from"./api-BP4ZP9kk.js";import{S as A,_ as se,b as ce,g as j,h as M,m as le,p as N,t as P,v as ue,x as F,y as de}from"./index-Dd3NDYZR.js";import{t as I}from"./Card-Cwvv0An8.js";import{t as fe}from"./PageHeader-acLQTYct.js";import{t as pe}from"./SectionHeader-NZWZgoOs.js";import{a as me}from"./format-ZWN4JNj-.js";import{t as he}from"./EmptyState-BvQA1o5K.js";import{t as L}from"./ui-D1crlGpt.js";import{a as ge,i as R,n as _e,o as z,r as B,t as ve}from"./Table-CvSmzzkm.js";import{n as ye,r as be,t as xe}from"./usePluginsWithUsage-DpTxJuFQ.js";import{a as Se,c as Ce,i as we,l as Te,n as Ee,o as De,r as Oe,s as ke,t as Ae}from"./Tabs-DWk9HyNd.js";var V=e(p(),1),H=te();function je(){let[e,t]=(0,V.useState)(!1),[n,r]=(0,V.useState)([]),o=(0,V.useCallback)(async()=>{try{r((await k(`/plugins/stats?limit=20`)).stats)}catch{r([])}},[]);return(0,H.jsxs)(I,{children:[(0,H.jsxs)(`button`,{className:`flex w-full items-center gap-2 text-sm font-semibold text-[var(--app-text)]`,onClick:()=>{!e&&n.length===0&&o(),t(e=>!e)},children:[(0,H.jsx)(a,{size:L.sm,className:`text-[var(--app-text-muted)]`}),`Usage Stats`,e?(0,H.jsx)(l,{size:L.xs,className:`ml-auto`}):(0,H.jsx)(i,{size:L.xs,className:`ml-auto`})]}),e?(0,H.jsx)(`div`,{className:`mt-3`,children:n.length===0?(0,H.jsx)(`p`,{className:`py-2 text-center text-xs text-[var(--app-text-subtle)]`,children:`No usage data yet`}):(0,H.jsxs)(ve,{children:[(0,H.jsx)(ge,{children:(0,H.jsxs)(z,{children:[(0,H.jsx)(R,{children:`Plugin`}),(0,H.jsx)(R,{children:`Usage Count`}),(0,H.jsx)(R,{children:`Last Used`})]})}),(0,H.jsx)(_e,{children:n.map(e=>(0,H.jsxs)(z,{children:[(0,H.jsx)(B,{className:`text-xs font-medium text-[var(--app-text)]`,children:e.pluginName}),(0,H.jsx)(B,{className:`font-mono text-xs text-[var(--app-text-muted)]`,children:e.usageCount}),(0,H.jsx)(B,{className:`text-xs text-[var(--app-text-muted)]`,children:e.lastUsed?me(e.lastUsed):`—`})]},e.pluginPath))})]})}):null]})}var Me=[`Enter`,` `],Ne=[`ArrowDown`,`PageUp`,`Home`],Pe=[`ArrowUp`,`PageDown`,`End`],Fe=[...Ne,...Pe],Ie={ltr:[...Me,`ArrowRight`],rtl:[...Me,`ArrowLeft`]},Le={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},U=`Menu`,[W,Re,ze]=Te(U),[G,Be]=g(U,[ze,A,ke]),K=A(),Ve=ke(),[He,q]=G(U),[Ue,J]=G(U),We=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=K(t),[c,l]=V.useState(null),u=V.useRef(!1),d=v(a),f=Ce(i);return V.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,H.jsx)(F,{...s,children:(0,H.jsx)(He,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,H.jsx)(Ue,{scope:t,onClose:V.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};We.displayName=U;var Ge=`MenuAnchor`,Ke=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=K(n);return(0,H.jsx)(ue,{...i,...r,ref:t})});Ke.displayName=Ge;var qe=`MenuPortal`,[Je,Ye]=G(qe,{forceMount:void 0}),Xe=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=q(qe,t);return(0,H.jsx)(Je,{scope:t,forceMount:n,children:(0,H.jsx)(x,{present:n||a.open,children:(0,H.jsx)(w,{asChild:!0,container:i,children:r})})})};Xe.displayName=qe;var Y=`MenuContent`,[Ze,Qe]=G(Y),$e=V.forwardRef((e,t)=>{let n=Ye(Y,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeMenu),o=J(Y,e.__scopeMenu);return(0,H.jsx)(W.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(x,{present:r||a.open,children:(0,H.jsx)(W.Slot,{scope:e.__scopeMenu,children:o.modal?(0,H.jsx)(et,{...i,ref:t}):(0,H.jsx)(tt,{...i,ref:t})})})})}),et=V.forwardRef((e,t)=>{let n=q(Y,e.__scopeMenu),r=V.useRef(null),i=E(t,r);return V.useEffect(()=>{let e=r.current;if(e)return ae(e)},[]),(0,H.jsx)(rt,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:T(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),tt=V.forwardRef((e,t)=>{let n=q(Y,e.__scopeMenu);return(0,H.jsx)(rt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),nt=b(`MenuContent.ScrollLock`),rt=V.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:ee,disableOutsideScroll:p,...m}=e,te=q(Y,n),h=J(Y,n),g=K(n),ne=Ve(n),_=Re(n),[v,y]=V.useState(null),b=V.useRef(null),x=E(t,b,te.onContentChange),S=V.useRef(0),w=V.useRef(``),ae=V.useRef(0),D=V.useRef(null),O=V.useRef(`right`),k=V.useRef(0),A=p?ie:V.Fragment,se=p?{as:nt,allowPinchZoom:!0}:void 0,j=e=>{let t=w.current+e,n=_().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Bt(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){w.current=t,window.clearTimeout(S.current),t!==``&&(S.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};V.useEffect(()=>()=>window.clearTimeout(S.current),[]),C();let M=V.useCallback(e=>O.current===D.current?.side&&Ht(e,D.current?.area),[]);return(0,H.jsx)(Ze,{scope:n,searchRef:w,onItemEnter:V.useCallback(e=>{M(e)&&e.preventDefault()},[M]),onItemLeave:V.useCallback(e=>{M(e)||(b.current?.focus(),y(null))},[M]),onTriggerLeave:V.useCallback(e=>{M(e)&&e.preventDefault()},[M]),pointerGraceTimerRef:ae,onPointerGraceIntentChange:V.useCallback(e=>{D.current=e},[]),children:(0,H.jsx)(A,{...se,children:(0,H.jsx)(re,{asChild:!0,trapped:i,onMountAutoFocus:T(a,e=>{e.preventDefault(),b.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,H.jsx)(oe,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:ee,children:(0,H.jsx)(De,{asChild:!0,...ne,dir:h.dir,orientation:`vertical`,loop:r,currentTabStopId:v,onCurrentTabStopIdChange:y,onEntryFocus:T(c,e=>{h.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,H.jsx)(ce,{role:`menu`,"aria-orientation":`vertical`,"data-state":Ft(te.open),"data-radix-menu-content":``,dir:h.dir,...g,...m,ref:x,style:{outline:`none`,...m.style},onKeyDown:T(m.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&j(e.key));let i=b.current;if(e.target!==i||!Fe.includes(e.key))return;e.preventDefault();let a=_().filter(e=>!e.disabled).map(e=>e.ref.current);Pe.includes(e.key)&&a.reverse(),Rt(a)}),onBlur:T(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(S.current),w.current=``)}),onPointerMove:T(e.onPointerMove,Z(e=>{let t=e.target,n=k.current!==e.clientX;e.currentTarget.contains(t)&&n&&(O.current=e.clientX>k.current?`right`:`left`,k.current=e.clientX)}))})})})})})})});$e.displayName=Y;var it=`MenuGroup`,at=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{role:`group`,...r,ref:t})});at.displayName=it;var ot=`MenuLabel`,st=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{...r,ref:t})});st.displayName=ot;var ct=`MenuItem`,lt=`menu.itemSelect`,ut=V.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=V.useRef(null),o=J(ct,e.__scopeMenu),s=Qe(ct,e.__scopeMenu),c=E(t,a),l=V.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(lt,{bubbles:!0,cancelable:!0});e.addEventListener(lt,e=>r?.(e),{once:!0}),S(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,H.jsx)(dt,{...i,ref:c,disabled:n,onClick:T(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:T(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:T(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||Me.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ut.displayName=ct;var dt=V.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Qe(ct,n),s=Ve(n),c=V.useRef(null),l=E(t,c),[u,d]=V.useState(!1),[f,ee]=V.useState(``);return V.useEffect(()=>{let e=c.current;e&&ee((e.textContent??``).trim())},[a.children]),(0,H.jsx)(W.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,H.jsx)(Se,{asChild:!0,...s,focusable:!r,children:(0,H.jsx)(y.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:T(e.onPointerMove,Z(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:T(e.onPointerLeave,Z(e=>o.onItemLeave(e))),onFocus:T(e.onFocus,()=>d(!0)),onBlur:T(e.onBlur,()=>d(!1))})})})}),ft=`MenuCheckboxItem`,pt=V.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,H.jsx)(xt,{scope:e.__scopeMenu,checked:n,children:(0,H.jsx)(ut,{role:`menuitemcheckbox`,"aria-checked":It(n)?`mixed`:n,...i,ref:t,"data-state":Lt(n),onSelect:T(i.onSelect,()=>r?.(It(n)?!0:!n),{checkForDefaultPrevented:!1})})})});pt.displayName=ft;var mt=`MenuRadioGroup`,[ht,gt]=G(mt,{value:void 0,onValueChange:()=>{}}),_t=V.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=v(r);return(0,H.jsx)(ht,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,H.jsx)(at,{...i,ref:t})})});_t.displayName=mt;var vt=`MenuRadioItem`,yt=V.forwardRef((e,t)=>{let{value:n,...r}=e,i=gt(vt,e.__scopeMenu),a=n===i.value;return(0,H.jsx)(xt,{scope:e.__scopeMenu,checked:a,children:(0,H.jsx)(ut,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Lt(a),onSelect:T(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});yt.displayName=vt;var bt=`MenuItemIndicator`,[xt,St]=G(bt,{checked:!1}),Ct=V.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=St(bt,n);return(0,H.jsx)(x,{present:r||It(a.checked)||a.checked===!0,children:(0,H.jsx)(y.span,{...i,ref:t,"data-state":Lt(a.checked)})})});Ct.displayName=bt;var wt=`MenuSeparator`,Tt=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Tt.displayName=wt;var Et=`MenuArrow`,Dt=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=K(n);return(0,H.jsx)(de,{...i,...r,ref:t})});Dt.displayName=Et;var Ot=`MenuSub`,[kt,At]=G(Ot),jt=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=q(Ot,t),o=K(t),[s,c]=V.useState(null),[l,u]=V.useState(null),d=v(i);return V.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,H.jsx)(F,{...o,children:(0,H.jsx)(He,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,H.jsx)(kt,{scope:t,contentId:_(),triggerId:_(),trigger:s,onTriggerChange:c,children:n})})})};jt.displayName=Ot;var X=`MenuSubTrigger`,Mt=V.forwardRef((e,t)=>{let n=q(X,e.__scopeMenu),r=J(X,e.__scopeMenu),i=At(X,e.__scopeMenu),a=Qe(X,e.__scopeMenu),o=V.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=V.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return V.useEffect(()=>u,[u]),V.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,H.jsx)(Ke,{asChild:!0,...l,children:(0,H.jsx)(dt,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Ft(n.open),...e,ref:D(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:T(e.onPointerMove,Z(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:T(e.onPointerLeave,Z(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:T(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Ie[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Mt.displayName=X;var Nt=`MenuSubContent`,Pt=V.forwardRef((e,t)=>{let n=Ye(Y,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeMenu),o=J(Y,e.__scopeMenu),s=At(Nt,e.__scopeMenu),c=V.useRef(null),l=E(t,c);return(0,H.jsx)(W.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(x,{present:r||a.open,children:(0,H.jsx)(W.Slot,{scope:e.__scopeMenu,children:(0,H.jsx)(rt,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:T(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:T(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:T(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Le[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Pt.displayName=Nt;function Ft(e){return e?`open`:`closed`}function It(e){return e===`indeterminate`}function Lt(e){return It(e)?`indeterminate`:e?`checked`:`unchecked`}function Rt(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function zt(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Bt(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=zt(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Vt(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Ht(e,t){return t?Vt({x:e.clientX,y:e.clientY},t):!1}function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Ut=We,Wt=Ke,Gt=Xe,Kt=$e,qt=at,Jt=st,Yt=ut,Xt=pt,Zt=_t,Qt=yt,$t=Ct,en=Tt,tn=Dt,nn=Mt,rn=Pt,an=`DropdownMenu`,[on,sn]=g(an,[Be]),Q=Be(),[cn,ln]=on(an),un=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Q(t),l=V.useRef(null),[u,d]=ne({prop:i,defaultProp:a??!1,onChange:o,caller:an});return(0,H.jsx)(cn,{scope:t,triggerId:_(),triggerRef:l,contentId:_(),open:u,onOpenChange:d,onOpenToggle:V.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,H.jsx)(Ut,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};un.displayName=an;var dn=`DropdownMenuTrigger`,fn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ln(dn,n),o=Q(n);return(0,H.jsx)(Wt,{asChild:!0,...o,children:(0,H.jsx)(y.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:D(t,a.triggerRef),onPointerDown:T(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:T(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});fn.displayName=dn;var pn=`DropdownMenuPortal`,mn=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Q(t);return(0,H.jsx)(Gt,{...r,...n})};mn.displayName=pn;var hn=`DropdownMenuContent`,gn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ln(hn,n),a=Q(n),o=V.useRef(!1);return(0,H.jsx)(Kt,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:T(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:T(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});gn.displayName=hn;var _n=`DropdownMenuGroup`,vn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(qt,{...i,...r,ref:t})});vn.displayName=_n;var yn=`DropdownMenuLabel`,bn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Jt,{...i,...r,ref:t})});bn.displayName=yn;var xn=`DropdownMenuItem`,Sn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Yt,{...i,...r,ref:t})});Sn.displayName=xn;var Cn=`DropdownMenuCheckboxItem`,wn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Xt,{...i,...r,ref:t})});wn.displayName=Cn;var Tn=`DropdownMenuRadioGroup`,En=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Zt,{...i,...r,ref:t})});En.displayName=Tn;var Dn=`DropdownMenuRadioItem`,On=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Qt,{...i,...r,ref:t})});On.displayName=Dn;var kn=`DropdownMenuItemIndicator`,An=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)($t,{...i,...r,ref:t})});An.displayName=kn;var jn=`DropdownMenuSeparator`,Mn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(en,{...i,...r,ref:t})});Mn.displayName=jn;var Nn=`DropdownMenuArrow`,Pn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(tn,{...i,...r,ref:t})});Pn.displayName=Nn;var Fn=`DropdownMenuSubTrigger`,In=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(nn,{...i,...r,ref:t})});In.displayName=Fn;var Ln=`DropdownMenuSubContent`,Rn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(rn,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Rn.displayName=Ln;var zn=un,Bn=fn,Vn=mn,Hn=gn,Un=bn,Wn=Sn,Gn=wn,Kn=On,qn=An,Jn=Mn,Yn=In,Xn=Rn,Zn=zn,Qn=Bn,$n=V.forwardRef(({className:e,inset:t,children:n,...r},a)=>(0,H.jsxs)(Yn,{ref:a,className:h(`flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-[var(--app-panel-elevated)] data-[state=open]:bg-[var(--app-panel-elevated)] [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...r,children:[n,(0,H.jsx)(i,{className:`ml-auto`})]}));$n.displayName=Yn.displayName;var er=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Xn,{ref:n,className:h(`z-50 min-w-[8rem] overflow-hidden rounded-md border border-[var(--app-border)] bg-[var(--app-panel)] p-1 text-[var(--app-text)] shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));er.displayName=Xn.displayName;var tr=V.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,H.jsx)(Vn,{children:(0,H.jsx)(Hn,{ref:r,sideOffset:t,className:h(`z-50 min-w-[8rem] overflow-hidden rounded-md border border-[var(--app-border)] bg-[var(--app-panel)] p-1 text-[var(--app-text)] shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));tr.displayName=Hn.displayName;var $=V.forwardRef(({className:e,inset:t,...n},r)=>(0,H.jsx)(Wn,{ref:r,className:h(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...n}));$.displayName=Wn.displayName;var nr=V.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,H.jsxs)(Gn,{ref:i,className:h(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,H.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,H.jsx)(qn,{children:(0,H.jsx)(o,{className:`h-4 w-4`})})}),t]}));nr.displayName=Gn.displayName;var rr=V.forwardRef(({className:e,children:t,...n},r)=>(0,H.jsxs)(Kn,{ref:r,className:h(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,H.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,H.jsx)(qn,{children:(0,H.jsx)(u,{className:`h-2 w-2 fill-current`})})}),t]}));rr.displayName=Kn.displayName;var ir=V.forwardRef(({className:e,inset:t,...n},r)=>(0,H.jsx)(Un,{ref:r,className:h(`px-2 py-1.5 text-sm font-semibold text-[var(--app-text)]`,t&&`pl-8`,e),...n}));ir.displayName=Un.displayName;var ar=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Jn,{ref:n,className:h(`-mx-1 my-1 h-px bg-[var(--app-panel-elevated)]`,e),...t}));ar.displayName=Jn.displayName;var or=({className:e,...t})=>(0,H.jsx)(`span`,{className:h(`ml-auto text-xs tracking-widest text-[var(--app-text-subtle)]`,e),...t});or.displayName=`DropdownMenuShortcut`;function sr({plugin:e}){let t=e.manifest;if(!t)return null;let n=[];return t.skills.length>0&&n.push({label:`Skill(${t.skills.length})`,variant:`info`}),t.agents.length>0&&n.push({label:`Agent(${t.agents.length})`,variant:`success`}),t.mcpServers.length>0&&n.push({label:`MCP(${t.mcpServers.length})`,variant:`warning`}),t.hooks.length>0&&n.push({label:`Hook(${t.hooks.length})`,variant:`default`}),t.lspServers.length>0&&n.push({label:`LSP(${t.lspServers.length})`,variant:`default`}),n.length===0?null:(0,H.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:n.map(e=>(0,H.jsx)(P,{variant:e.variant,children:e.label},e.label))})}function cr({plugin:e,roles:t,onInstallToRole:n,onToggleGlobal:r,onUninstallUser:i,projectOperatingKey:a,userOperatingId:o}){let s=o===e.id;return(0,H.jsxs)(Zn,{modal:!1,children:[(0,H.jsx)(Qn,{asChild:!0,children:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-7 w-7 px-0`,"aria-label":`Manage ${e.name}`,children:s?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):(0,H.jsx)(d,{size:L.sm})})}),(0,H.jsxs)(tr,{align:`end`,className:`min-w-[200px]`,children:[t.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ir,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Add to Role`}),t.map(t=>{let r=e.usedByRoles.some(e=>e.roleId===t.id),i=a===`${e.id}:${t.workspacePath}`;return(0,H.jsxs)($,{disabled:i||r,onSelect:()=>{n(e.id,t.workspacePath)},children:[(0,H.jsx)(`span`,{className:`flex-1`,children:t.name}),i?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):r?(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`installed`}):null]},t.id)}),(0,H.jsx)(ar,{})]}):null,(0,H.jsx)($,{disabled:s,onSelect:()=>{r(e.id,!e.globalEnabled)},children:e.globalEnabled?`Disable`:`Enable`}),(0,H.jsx)($,{disabled:s,className:`text-[var(--app-danger)] focus:text-[var(--app-danger)]`,onSelect:()=>{i(e.id)},children:`Uninstall`})]})]})}function lr({plugin:e,roles:t,expandedContent:n,onInstallToRole:r,onToggleGlobal:a,onUninstallUser:o,projectOperatingKey:s,userOperatingId:c}){let[u,d]=(0,V.useState)(!1),f=e.usedByRoles.map(e=>`${e.roleName} (v${e.version})`).join(`, `)||`No Roles`;return(0,H.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`button`,{className:`mt-0.5 text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>d(e=>!e),"aria-label":u?`Collapse ${e.name}`:`Expand ${e.name}`,children:u?(0,H.jsx)(l,{size:L.xs}):(0,H.jsx)(i,{size:L.xs})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`v`,e.version]}),e.marketplace?(0,H.jsx)(P,{variant:`muted`,className:`text-[10px]`,children:e.marketplace}):null,(0,H.jsx)(j,{delayDuration:150,children:(0,H.jsxs)(le,{children:[(0,H.jsx)(se,{asChild:!0,children:(0,H.jsxs)(`button`,{className:`text-xs text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,title:f,children:[e.usedByRoles.length,` `,e.usedByRoles.length===1?`Role`:`Roles`]})}),(0,H.jsx)(M,{children:f})]})})]}),(0,H.jsx)(sr,{plugin:e})]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,H.jsx)(P,{variant:e.globalEnabled?`success`:`destructive`,children:e.globalEnabled?`User On`:`User Off`}),(0,H.jsx)(cr,{plugin:e,roles:t,onInstallToRole:r,onToggleGlobal:a,onUninstallUser:o,projectOperatingKey:s,userOperatingId:c})]})]}),u?(0,H.jsx)(`div`,{className:`mt-4 rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:n}):null]})}function ur({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:e}),(0,H.jsx)(`p`,{className:`mt-1 text-sm font-medium text-[var(--app-text)]`,children:t})]})}function dr({plugin:e}){return e.manifest?(0,H.jsxs)(`div`,{className:`space-y-4 text-xs`,children:[e.manifest.description?(0,H.jsx)(`p`,{className:`text-[var(--app-text-muted)]`,children:e.manifest.description}):null,(0,H.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-4`,children:[(0,H.jsx)(ur,{label:`Version`,value:e.version?`v${e.version}`:`—`}),(0,H.jsx)(ur,{label:`Scope`,value:e.scope}),(0,H.jsx)(ur,{label:`Capability Count`,value:e.manifest.skills.length+e.manifest.agents.length+e.manifest.mcpServers.length+e.manifest.hooks.length+e.manifest.lspServers.length}),(0,H.jsx)(ur,{label:`Activation`,value:e.globalEnabled?`User On`:`User Off`})]}),(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Install Path`}),(0,H.jsx)(`p`,{className:`mt-1 truncate font-mono text-[11px] text-[var(--app-text-muted)]`,title:e.installPath,children:e.installPath})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[e.manifest.skills.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Skills`}),e.manifest.skills.map(e=>(0,H.jsxs)(`div`,{className:`inline-flex items-baseline gap-1 text-[var(--app-text-muted)]`,children:[(0,H.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),e.description?(0,H.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`; `,e.description]}):null]},e.name))]}):null,e.manifest.agents.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Agents`}),e.manifest.agents.map(e=>(0,H.jsxs)(`div`,{className:`inline-flex items-baseline gap-1 text-[var(--app-text-muted)]`,children:[(0,H.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),e.description?(0,H.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`; `,e.description]}):null]},e.name))]}):null,e.manifest.mcpServers.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`MCP Servers`}),e.manifest.mcpServers.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null,e.manifest.hooks.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Hooks`}),e.manifest.hooks.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null,e.manifest.lspServers.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`LSP Servers`}),e.manifest.lspServers.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null]})]}):(0,H.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading manifest...`})}function fr(){let{userScope:e,projectScope:i,loading:a,error:o,refresh:u,rawPlugins:d,roles:p}=xe(),[te,h]=(0,V.useState)(`installed`),[g,ne]=(0,V.useState)([]),[_,v]=(0,V.useState)([]),[y,re]=(0,V.useState)(new Set),[b,ie]=(0,V.useState)(!1),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(``),[ae,oe]=(0,V.useState)(!1),[T,E]=(0,V.useState)(``),[D,A]=(0,V.useState)(null),[se,ce]=(0,V.useState)(null),{operatingKey:j,installToRole:M,uninstallFromRole:le,updateRoleVersion:ue}=ye(u),F=(0,V.useCallback)(async()=>{ie(!0),S(null);try{let[e,t]=await Promise.all([k(`/plugins/marketplace`).catch(()=>({available:[],installed:[]})),k(`/plugins/marketplaces`)]);v(e.available),re(new Set(e.installed.map(e=>e.id))),ne(t.sources)}catch(e){S(e instanceof Error?e.message:`Failed to load marketplace`)}finally{ie(!1)}},[]);(0,V.useEffect)(()=>{F()},[F]);let de=(0,V.useCallback)(async(e,t)=>{A(e);try{await k(`/plugins/${encodeURIComponent(e)}/${t?`enable`:`disable`}`,{method:`POST`}),N.success(`${e} ${t?`enabled`:`disabled`} globally`)}catch(e){N.error(e instanceof Error?e.message:`Failed to ${t?`enable`:`disable`} plugin`)}finally{await u(),A(null)}},[u]),me=(0,V.useCallback)(async e=>{A(e);try{await k(`/plugins/uninstall/${encodeURIComponent(e)}`,{method:`POST`}),N.success(`Plugin uninstalled`)}catch(e){N.error(e instanceof Error?e.message:`Uninstall failed`)}finally{await Promise.all([u(),F()]),A(null)}},[F,u]),Se=(0,V.useCallback)(async()=>{let e=T.trim();if(e)try{await k(`/plugins/marketplaces`,{method:`POST`,body:JSON.stringify({url:e})}),N.success(`Marketplace added`),E(``),oe(!1),await F()}catch(e){N.error(e instanceof Error?e.message:`Failed to add marketplace`)}},[F,T]),Ce=(0,V.useCallback)(async(e,t=`user`,n)=>{ce(e);try{await k(`/plugins/install/${encodeURIComponent(e)}`,{method:`POST`,body:JSON.stringify({scope:t,cwd:n})});let r=t===`project`&&n?`${e.split(`@`)[0]} for ${n.split(`/`).pop()}`:e.split(`@`)[0];N.success(`Installed ${r}`)}catch(e){N.error(e instanceof Error?e.message:`Install failed`)}finally{await Promise.all([u(),F()]),ce(null)}},[F,u]),Te=C?_.filter(e=>e.name.toLowerCase().includes(C.toLowerCase())||e.description.toLowerCase().includes(C.toLowerCase())):_,De=d.filter(e=>e.scope===`project`).length;return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsx)(fe,{eyebrow:`Capabilities`,title:`Plugins`,compact:!0,description:`Installed capabilities, scope, and activation.`,metrics:[{label:`Total`,value:d.length},{label:`Project Scope`,value:De},{label:`Catalog`,value:_.length}],actions:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>void Promise.all([u(),F()]),children:(0,H.jsx)(f,{size:L.sm})})}),(0,H.jsx)(pe,{title:`Plugin Library`,compact:!0,description:`Installed plugins and marketplace discovery live in separate tabs.`}),(0,H.jsxs)(Ae,{value:te,onValueChange:e=>h(e),children:[(0,H.jsxs)(Oe,{children:[(0,H.jsxs)(we,{value:`installed`,children:[`Installed (`,e.length,`)`]}),(0,H.jsxs)(we,{value:`marketplace`,children:[`Marketplace (`,_.length,`)`]})]}),(0,H.jsx)(Ee,{value:`installed`,className:`space-y-5`,children:a?(0,H.jsx)(I,{children:(0,H.jsx)(`div`,{className:`py-8 text-center text-sm text-[var(--app-text-subtle)]`,children:`Loading...`})}):o?(0,H.jsx)(I,{children:(0,H.jsx)(`div`,{className:`py-8 text-center text-sm text-[var(--app-danger)]`,children:o})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(pe,{title:`User scope`,compact:!0,description:`Global defaults. Available to all Roles unless overridden.`}),e.length===0?(0,H.jsx)(I,{children:(0,H.jsx)(he,{icon:(0,H.jsx)(n,{size:L.hero}),title:`No user-scope plugins`,description:`Install a plugin once here to make it available as the default for every Role.`,className:`py-8`})}):(0,H.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,H.jsx)(lr,{plugin:e,roles:p,expandedContent:(0,H.jsx)(dr,{plugin:e}),onInstallToRole:M,onToggleGlobal:de,onUninstallUser:me,projectOperatingKey:j,userOperatingId:D},e.id))})]}),(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(pe,{title:`Project scope`,compact:!0,description:`Role-specific overrides. Only plugins that differ from user scope are shown here.`}),(0,H.jsx)(be,{groups:i,layout:`full`,onUninstall:le,onUpdate:ue,operatingKey:j})]}),(0,H.jsx)(je,{})]})}),(0,H.jsxs)(Ee,{value:`marketplace`,className:`space-y-4`,children:[(0,H.jsxs)(I,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(r,{size:L.sm,className:`flex-shrink-0 text-[var(--app-text-muted)]`}),g.map(e=>(0,H.jsx)(P,{variant:`muted`,className:`text-xs`,children:e.name},e.name)),(0,H.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[b?(0,H.jsx)(m,{size:L.xs,className:`animate-spin text-[var(--app-text-subtle)]`}):null,(0,H.jsxs)(O,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>oe(e=>!e),children:[ae?(0,H.jsx)(s,{size:L.xs}):(0,H.jsx)(t,{size:L.xs}),`Source`]})]})]}),ae?(0,H.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,H.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:T,onChange:e=>E(e.target.value),placeholder:`https://github.com/org/marketplace-repo`,onKeyDown:e=>{e.key===`Enter`&&Se()}}),(0,H.jsx)(O,{size:`sm`,onClick:()=>void Se(),disabled:!T.trim(),children:`Add`})]}):null]}),(0,H.jsx)(I,{children:(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(ee,{size:L.sm,className:`absolute left-2.5 top-2 text-[var(--app-text-subtle)]`}),(0,H.jsx)(`input`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] py-1.5 pl-8 pr-3 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,value:C,onChange:e=>w(e.target.value),placeholder:`Search available plugins...`})]})}),b?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-text-subtle)]`,children:`Loading marketplace...`})}):x?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-danger)]`,children:x})}):Te.length===0?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-text-subtle)]`,children:C?`No plugins match your search`:`No marketplace plugins available`})}):(0,H.jsx)(I,{padding:!1,children:(0,H.jsxs)(ve,{children:[(0,H.jsx)(ge,{children:(0,H.jsxs)(z,{children:[(0,H.jsx)(R,{children:`Name`}),(0,H.jsx)(R,{children:`Description`}),(0,H.jsx)(R,{children:`Source`}),(0,H.jsx)(R,{children:`Action`})]})}),(0,H.jsx)(_e,{children:Te.map(e=>{let t=y.has(e.pluginId),n=se===e.pluginId;return(0,H.jsxs)(z,{children:[(0,H.jsx)(B,{className:`text-xs font-medium text-[var(--app-text)]`,children:e.name}),(0,H.jsx)(B,{className:`max-w-[300px] truncate text-xs text-[var(--app-text-muted)]`,title:e.description,children:e.description}),(0,H.jsx)(B,{children:(0,H.jsx)(P,{variant:`muted`,className:`text-[10px]`,children:e.marketplaceName})}),(0,H.jsx)(B,{children:t?(0,H.jsx)(P,{variant:`success`,className:`text-[10px]`,children:`Installed`}):(0,H.jsxs)(Zn,{modal:!1,children:[(0,H.jsx)(Qn,{asChild:!0,children:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,disabled:n,children:n?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(c,{size:L.xs}),`Install`,(0,H.jsx)(l,{size:L.xs})]})})}),(0,H.jsxs)(tr,{align:`end`,className:`min-w-[200px]`,children:[(0,H.jsx)($,{disabled:n,onSelect:()=>{Ce(e.pluginId)},children:`Install globally (User scope)`}),p.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ar,{}),p.map(t=>(0,H.jsxs)($,{disabled:n,onSelect:()=>{Ce(e.pluginId,`project`,t.workspacePath)},children:[`Install to `,t.name]},t.id))]}):null]})]})})]},e.pluginId)})})]})})]})]})]})}export{fr as Plugins};