@lovelybunch/api 1.0.75-alpha.9 → 1.0.75

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 (163) hide show
  1. package/dist/lib/jobs/job-runner.js +10 -2
  2. package/dist/lib/jobs/job-scheduler.js +21 -0
  3. package/dist/lib/mail/mail-runner.d.ts +51 -0
  4. package/dist/lib/mail/mail-runner.js +342 -0
  5. package/dist/lib/slack/slack-service.d.ts +2 -0
  6. package/dist/lib/slack/slack-service.js +3 -0
  7. package/dist/lib/storage/file-storage.d.ts +16 -16
  8. package/dist/lib/storage/file-storage.js +59 -64
  9. package/dist/lib/terminal/terminal-manager.d.ts +3 -3
  10. package/dist/lib/terminal/terminal-manager.js +10 -10
  11. package/dist/routes/api/v1/ai/route.js +39 -19
  12. package/dist/routes/api/v1/git/index.js +23 -0
  13. package/dist/routes/api/v1/mail/index.d.ts +3 -0
  14. package/dist/routes/api/v1/mail/index.js +23 -0
  15. package/dist/routes/api/v1/mail/route.d.ts +294 -0
  16. package/dist/routes/api/v1/mail/route.js +344 -0
  17. package/dist/routes/api/v1/mcp/index.js +32 -32
  18. package/dist/routes/api/v1/slack/index.d.ts +3 -0
  19. package/dist/routes/api/v1/slack/index.js +15 -0
  20. package/dist/routes/api/v1/slack/route.d.ts +124 -0
  21. package/dist/routes/api/v1/slack/route.js +192 -0
  22. package/dist/routes/api/v1/tasks/[id]/route.d.ts +117 -0
  23. package/dist/routes/api/v1/tasks/[id]/route.js +166 -0
  24. package/dist/routes/api/v1/tasks/index.d.ts +3 -0
  25. package/dist/routes/api/v1/tasks/index.js +10 -0
  26. package/dist/routes/api/v1/tasks/route.d.ts +96 -0
  27. package/dist/routes/api/v1/tasks/route.js +136 -0
  28. package/dist/routes/api/v1/terminal/[taskId]/create/index.d.ts +3 -0
  29. package/dist/routes/api/v1/terminal/[taskId]/create/index.js +5 -0
  30. package/dist/routes/api/v1/terminal/[taskId]/create/route.d.ts +10 -0
  31. package/dist/routes/api/v1/terminal/[taskId]/create/route.js +27 -0
  32. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.d.ts +3 -0
  33. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.js +5 -0
  34. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.d.ts +10 -0
  35. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.js +21 -0
  36. package/dist/routes/api/v1/terminal/[taskId]/resize/index.d.ts +3 -0
  37. package/dist/routes/api/v1/terminal/[taskId]/resize/index.js +5 -0
  38. package/dist/routes/api/v1/terminal/[taskId]/resize/route.d.ts +10 -0
  39. package/dist/routes/api/v1/terminal/[taskId]/resize/route.js +21 -0
  40. package/dist/routes/api/v1/terminal/sessions/route.js +4 -4
  41. package/dist/server-with-static.js +12 -8
  42. package/dist/server.js +12 -8
  43. package/package.json +4 -4
  44. package/static/assets/{ActivityPage-OxRci_V2.js → ActivityPage-k4I7Q53O.js} +1 -1
  45. package/static/assets/ApiKeysSettingsPage-B1YvVdmg.js +2 -0
  46. package/static/assets/{ArchitectureEditPage-D7xcH6dY.js → ArchitectureEditPage-CpowsIx2.js} +4 -4
  47. package/static/assets/{ArchitecturePage-pvnlX-NW.js → ArchitecturePage-DYxC_aMR.js} +1 -1
  48. package/static/assets/{AuthSettingsPage-Bu0CZ1rY.js → AuthSettingsPage-DtSo78Y_.js} +2 -2
  49. package/static/assets/{CallbackPage-D0lkjxCT.js → CallbackPage-bROCGapx.js} +1 -1
  50. package/static/assets/CodePage-CPCj64rX.js +2 -0
  51. package/static/assets/{CollapsibleSection-Bt_ZLnJc.js → CollapsibleSection-M5cXbl92.js} +1 -1
  52. package/static/assets/DashboardPage-B9BZZfw6.js +51 -0
  53. package/static/assets/{GitPage-TrTxZ27J.js → GitPage-BiDtdSK1.js} +2 -2
  54. package/static/assets/GitSettingsPage-THm6wDjs.js +6 -0
  55. package/static/assets/IdentityPage-BC16skg6.js +6 -0
  56. package/static/assets/{ImplementationStepsEditor-Ctx0CvbU.js → ImplementationStepsEditor-HliLQav5.js} +2 -2
  57. package/static/assets/{IntegrationsSettingsPage-C2wJVdM7.js → IntegrationsSettingsPage-CC_VKIQa.js} +1 -1
  58. package/static/assets/JobDetailPage-z1QQYvmU.js +1 -0
  59. package/static/assets/{KnowledgeDetailPage-BdTUfWqj.js → KnowledgeDetailPage-DzHXBS7Q.js} +1 -1
  60. package/static/assets/{KnowledgeEditPage-D8XK4IUf.js → KnowledgeEditPage-BwGnUH_m.js} +1 -1
  61. package/static/assets/KnowledgePage-CGIVMS02.js +3 -0
  62. package/static/assets/{LoginPage-Dqxd7cTa.js → LoginPage-VQ3lcfLV.js} +1 -1
  63. package/static/assets/MailInboxPage-DiZKqwdU.js +1 -0
  64. package/static/assets/MailProcessingModal-DIeSQBoR.js +6 -0
  65. package/static/assets/MailReadPage-C8AACmZQ.js +1 -0
  66. package/static/assets/MailSentPage-C_5yFly_.js +1 -0
  67. package/static/assets/{McpSettingsPage-10n35zXi.js → McpSettingsPage-i9YHcu1s.js} +1 -1
  68. package/static/assets/{NewKnowledgePage-BlJzzuh7.js → NewKnowledgePage-BnVY7WUD.js} +1 -1
  69. package/static/assets/{NewSkillPage-ByqN--mH.js → NewSkillPage-DwniHD6D.js} +1 -1
  70. package/static/assets/NewTaskPage-F5UX2WMc.js +90 -0
  71. package/static/assets/NotFoundPage-BbSZX_4L.js +6 -0
  72. package/static/assets/NotificationsSettingsPage-C8kjcift.js +1 -0
  73. package/static/assets/{ProjectEditPage-DKJTY2uc.js → ProjectEditPage-DUUlIEqI.js} +1 -1
  74. package/static/assets/{ProjectPage-2VblKCWz.js → ProjectPage-Unz9PQpA.js} +1 -1
  75. package/static/assets/{PromptsSettingsPage-B4mOhXuo.js → PromptsSettingsPage-DVpIuRKI.js} +1 -1
  76. package/static/assets/ResourceDetailPage-DqHZ2KYD.js +1 -0
  77. package/static/assets/{ResourcesPage-2BbjIWfF.js → ResourcesPage-BP5tuAi-.js} +1 -1
  78. package/static/assets/RoleEditPage-BgKu8S0-.js +13 -0
  79. package/static/assets/{RolePage-qXWXZ2FZ.js → RolePage-Fed52Ov5.js} +1 -1
  80. package/static/assets/{RulesSettingsPage-BtM7p8F6.js → RulesSettingsPage-BQ2O0u66.js} +3 -3
  81. package/static/assets/SchedulePage-jkxjuzBx.js +4 -0
  82. package/static/assets/SkillDetailPage-k3Q2-NFd.js +1 -0
  83. package/static/assets/{SkillEditPage-Czlo8WWT.js → SkillEditPage-urF4snjo.js} +1 -1
  84. package/static/assets/SkillsPage-DlWDhEjR.js +8 -0
  85. package/static/assets/{SkillsSettingsPage-DKtpy7qk.js → SkillsSettingsPage-BViFgckG.js} +1 -1
  86. package/static/assets/{SourceInput-BITn1Y15.js → SourceInput-CAFKTHw-.js} +1 -1
  87. package/static/assets/{TagInput-BK91_M1N.js → TagInput-C6lI-ePr.js} +1 -1
  88. package/static/assets/TaskDetailPage-DpbRHnW_.js +16 -0
  89. package/static/assets/TaskEditPage-DssRbW0h.js +1 -0
  90. package/static/assets/TasksPage-CD_eo0Bj.js +17 -0
  91. package/static/assets/TerminalPage-BG_wlccr.js +1 -0
  92. package/static/assets/TerminalSessionPage-CsK-LznK.js +8 -0
  93. package/static/assets/{UserPreferencesPage-DrgYEcxO.js → UserPreferencesPage-CWUq3efu.js} +1 -1
  94. package/static/assets/UserSettingsPage-CduI_MGS.js +1 -0
  95. package/static/assets/{UtilitiesPage-Djr4qT5L.js → UtilitiesPage-BAxokhLh.js} +1 -1
  96. package/static/assets/{alert-CsMvyYoX.js → alert-BXsc6_qu.js} +1 -1
  97. package/static/assets/{arrow-down-BZnfbld8.js → arrow-down-DmW_3gE8.js} +1 -1
  98. package/static/assets/{arrow-left-WGBYWq3h.js → arrow-left-1S-835kP.js} +1 -1
  99. package/static/assets/{arrow-up-BByVUPE7.js → arrow-up-BYism_o1.js} +1 -1
  100. package/static/assets/arrow-up-down-Dw3J0a4i.js +6 -0
  101. package/static/assets/{badge-AwLOflf5.js → badge-BUEY53dV.js} +1 -1
  102. package/static/assets/{browser-modal-BzGNFfTG.js → browser-modal-DCNdI4NT.js} +2 -2
  103. package/static/assets/{card-SN5gKnu7.js → card-BcPlIAH5.js} +1 -1
  104. package/static/assets/{chevron-left-C7uNq9l_.js → chevron-left-FMmNe7yP.js} +1 -1
  105. package/static/assets/{chevron-up-CHdIiLxL.js → chevron-up-CqM3won3.js} +1 -1
  106. package/static/assets/{chevrons-up-TXwQuoUN.js → chevrons-up-DTvCkIHc.js} +1 -1
  107. package/static/assets/{circle-alert-37E5gU9K.js → circle-alert-dseM-Ib7.js} +1 -1
  108. package/static/assets/{circle-check-big-nY4PntB5.js → circle-check-big-jKg34xC-.js} +1 -1
  109. package/static/assets/{circle-check-D02pWDME.js → circle-check-eyo6pBP1.js} +1 -1
  110. package/static/assets/{circle-play-7EXFLo4F.js → circle-play-BrY_lNiH.js} +1 -1
  111. package/static/assets/{circle-x-By4JoTHB.js → circle-x-uqmzEce1.js} +1 -1
  112. package/static/assets/{clipboard-BdymjxLO.js → clipboard-tzPFoieb.js} +1 -1
  113. package/static/assets/{clock-HDu44KTo.js → clock-Bjc06QBM.js} +1 -1
  114. package/static/assets/code-DrYqPukx.js +6 -0
  115. package/static/assets/{download-Cv2G2Eg9.js → download-Bg__QCLT.js} +1 -1
  116. package/static/assets/{external-link-DwMXcCCj.js → external-link-CNDy2UUo.js} +1 -1
  117. package/static/assets/{eye-DYnjJzdb.js → eye-DLFBnC8t.js} +1 -1
  118. package/static/assets/{folder-git-2-COeWFPHS.js → folder-git-2-DUqd0WRi.js} +1 -1
  119. package/static/assets/index-CHdBxVyk.css +2 -0
  120. package/static/assets/{index-9Tv-j_Ga.js → index-DFcWlnzl.js} +118 -103
  121. package/static/assets/{info-BmtuPMhv.js → info-D6jxZC5X.js} +1 -1
  122. package/static/assets/kiro-CX1mOsRO.js +17 -0
  123. package/static/assets/{label-TGqbNfMO.js → label-DBuh-ke5.js} +1 -1
  124. package/static/assets/{markdown-editor-ls1JPK_e.js → markdown-editor-B4YNQFT2.js} +1 -1
  125. package/static/assets/message-square-B5RWz_ff.js +6 -0
  126. package/static/assets/paperclip-4A_3MaPx.js +6 -0
  127. package/static/assets/{pause-CAWbvTiL.js → pause-BzhKXHtR.js} +1 -1
  128. package/static/assets/{play-DF_Qeu0H.js → play-CHIf-Rcz.js} +1 -1
  129. package/static/assets/{radio-group-DYTbywtK.js → radio-group-C1ct-VsJ.js} +1 -1
  130. package/static/assets/{refresh-cw-BFZxHqbC.js → refresh-cw-B3OwrDUf.js} +1 -1
  131. package/static/assets/{search-Dr90tbch.js → search-Cq1ksEdp.js} +1 -1
  132. package/static/assets/{select-Cs5qtMYV.js → select-44mcS2_G.js} +1 -1
  133. package/static/assets/{status-utils-BDOyevaX.js → status-utils-CDkPeVfP.js} +1 -1
  134. package/static/assets/{switch-4TDb6YiQ.js → switch-CIwjYvCt.js} +1 -1
  135. package/static/assets/{tabs-BrbEvF4V.js → tabs-DTV6Su-h.js} +1 -1
  136. package/static/assets/{tag-DrQkepeD.js → tag-p6yeowCW.js} +1 -1
  137. package/static/assets/{terminal-preview-uuKF9_x4.js → terminal-preview-DN38x9Jm.js} +1 -1
  138. package/static/assets/use-terminal-BXJqOeJe.js +1 -0
  139. package/static/assets/{video-DYA2WfbA.js → video-BH5ChaoS.js} +1 -1
  140. package/static/index.html +2 -2
  141. package/static/assets/ApiKeysSettingsPage-C0evI19e.js +0 -2
  142. package/static/assets/CodePage-BJ4PC5nb.js +0 -2
  143. package/static/assets/DashboardPage-BiffPdmj.js +0 -41
  144. package/static/assets/GitSettingsPage-D7q5xQd_.js +0 -6
  145. package/static/assets/IdentityPage-CY0Ak2j0.js +0 -11
  146. package/static/assets/JobDetailPage-Phx_IlKX.js +0 -1
  147. package/static/assets/KnowledgePage-Ci9G7Br-.js +0 -8
  148. package/static/assets/NewProposalPage-BP7Ttoxk.js +0 -90
  149. package/static/assets/ProposalDetailPage-m3ysyzpj.js +0 -1
  150. package/static/assets/ProposalEditPage-3XVg_paW.js +0 -1
  151. package/static/assets/ProposalsPage-B3u0aFFz.js +0 -17
  152. package/static/assets/ResourceDetailPage-somBLUpC.js +0 -1
  153. package/static/assets/RoleEditPage-CLzX7Xhi.js +0 -13
  154. package/static/assets/SchedulePage-4tFcIBSs.js +0 -4
  155. package/static/assets/SkillDetailPage-CroSdaju.js +0 -1
  156. package/static/assets/SkillsPage-CgULbcI-.js +0 -8
  157. package/static/assets/TerminalPage-8fwvnOo2.js +0 -1
  158. package/static/assets/TerminalSessionPage-BhO5U48p.js +0 -13
  159. package/static/assets/UserSettingsPage-Dj6lKLi8.js +0 -1
  160. package/static/assets/droid-CPteN3f9.js +0 -17
  161. package/static/assets/index-GFQ5RqVh.css +0 -2
  162. package/static/assets/use-terminal-BG5UXuVE.js +0 -1
  163. package/static/assets/zap-h9QOsasv.js +0 -6
@@ -1,11 +0,0 @@
1
- import{c as oe,a as ve,r as u,j as e,x as se,B as x,a3 as fe,$ as Ne,b0 as Te,i as Ce,I as c,q as O,ae,P as E,a2 as ne,O as be,A as ie}from"./index-9Tv-j_Ga.js";import{C as y,b as g,c as j,d as v,a as f,e as Se}from"./card-SN5gKnu7.js";import{L as o}from"./label-TGqbNfMO.js";import{B as re}from"./badge-AwLOflf5.js";import{S as we,a as Ae,b as ke,c as Ie,d as Oe}from"./select-Cs5qtMYV.js";import{A as Fe,a as Pe}from"./alert-CsMvyYoX.js";import{T as Ee,a as Me,b,c as S}from"./tabs-BrbEvF4V.js";import{Z as Le}from"./zap-h9QOsasv.js";import{E as De}from"./eye-DYnjJzdb.js";import{C as _e,a as Ue}from"./clipboard-BdymjxLO.js";import"./chevron-up-CHdIiLxL.js";/**
2
- * @license lucide-react v0.542.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Re=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],$e=oe("mail",Re);/**
7
- * @license lucide-react v0.542.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Je=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],qe=oe("refresh-ccw",Je),Be=["a2a_v0.2","a2a_v0.1","jsonrpc2","jsonrpc","openrpc","rest"],Ke=["GET","POST","PUT","PATCH","DELETE"],He=()=>({id:"",skill:"",description:"",endpoint:"",method:"POST",enabled:!0,inputMimeType:"application/json",outputMimeType:"application/json",inputSchema:"",outputSchema:""}),w={id:"",name:"",description:"",version:"1.0.0",url:"",documentation:"",protocols:["a2a_v0.2"],authentication:{scheme:"api_key",in:"header",name:"X-API-Key",example:"",description:""},capabilities:[],supportedInputTypes:["application/json"],supportedOutputTypes:["application/json"],security:{transport:"https",encryption:"TLS 1.3",notes:""},contact:{name:"",email:""},lastUpdated:void 0},N=a=>({...a,protocols:[...a.protocols],authentication:{...a.authentication},capabilities:a.capabilities.map(n=>({...n})),supportedInputTypes:[...a.supportedInputTypes],supportedOutputTypes:[...a.supportedOutputTypes],security:{...a.security},contact:{...a.contact}}),F=()=>N(w);function Ve(a){if(!a)return F();const n=Array.isArray(a.protocols)?a.protocols.filter(r=>typeof r=="string"):[],d=Array.isArray(a.supportedContentTypes?.input)?a.supportedContentTypes.input.filter(r=>typeof r=="string"):[],A=Array.isArray(a.supportedContentTypes?.output)?a.supportedContentTypes.output.filter(r=>typeof r=="string"):[],T=Array.isArray(a.capabilities)?a.capabilities.map(r=>({id:typeof r.id=="string"?r.id:"",skill:typeof r.skill=="string"?r.skill:"",description:typeof r.description=="string"?r.description:"",endpoint:typeof r.endpoint=="string"?r.endpoint:"",method:typeof r.method=="string"?r.method:"POST",enabled:r?.enabled!==!1,inputMimeType:typeof r.input?.mimeType=="string"?r.input.mimeType:"application/json",outputMimeType:typeof r.output?.mimeType=="string"?r.output.mimeType:"application/json",inputSchema:r.input?.schema?JSON.stringify(r.input.schema,null,2):"",outputSchema:r.output?.schema?JSON.stringify(r.output.schema,null,2):""})):[],M={scheme:typeof a.authentication?.scheme=="string"?a.authentication.scheme:"api_key",in:typeof a.authentication?.in=="string"?a.authentication.in:"header",name:typeof a.authentication?.name=="string"?a.authentication.name:"X-API-Key",example:typeof a.authentication?.example=="string"?a.authentication.example:"",description:typeof a.authentication?.description=="string"?a.authentication.description:""};return{id:typeof a.id=="string"?a.id:"",name:typeof a.name=="string"?a.name:"",description:typeof a.description=="string"?a.description:"",version:typeof a.version=="string"?a.version:"1.0.0",url:typeof a.url=="string"?a.url:"",documentation:typeof a.documentation=="string"?a.documentation:"",protocols:n.length>0?n:w.protocols,authentication:M,capabilities:T,supportedInputTypes:d.length>0?d:w.supportedInputTypes,supportedOutputTypes:A.length>0?A:w.supportedOutputTypes,security:{transport:typeof a.security?.transport=="string"?a.security.transport:w.security.transport,encryption:typeof a.security?.encryption=="string"?a.security.encryption:w.security.encryption,notes:typeof a.security?.notes=="string"?a.security.notes:""},contact:{name:typeof a.contact?.name=="string"?a.contact.name:"",email:typeof a.contact?.email=="string"?a.contact.email:""},lastUpdated:typeof a.lastUpdated=="string"?a.lastUpdated:void 0}}function nt(){const{toast:a}=ve(),[n,d]=u.useState(()=>F()),[A,T]=u.useState(()=>F()),[M,r]=u.useState(!0),[L,B]=u.useState(!1),[K,k]=u.useState(null),[H,D]=u.useState(""),[V,_]=u.useState(""),[X,U]=u.useState(""),[P,R]=u.useState(void 0),[le,z]=u.useState(!1),ce=u.useMemo(()=>{const t=new Set([...Be,...n.protocols]);return Array.from(t).sort()},[n.protocols]);u.useEffect(()=>{let t=!0;return(async()=>{r(!0),k(null);try{const s=await fetch(`${ie}/api/v1/identity/agent-card`);if(!s.ok)throw new Error(`Failed to load agent card (${s.status})`);const l=await s.json();if(l.success&&l.data){const p=Ve(l.data.card||void 0);if(p.id||(p.id="urn:agent:coconut"),p.url||(p.url=`${window.location.origin}/api/v1`),p.lastUpdated=l.data.updatedAt??p.lastUpdated,t){const m=N(p);d(m),T(N(m)),R(l.data.updatedAt??m.lastUpdated)}}else{if(l.error)throw new Error(l.error);if(t){const p=F();d(p),T(N(p))}}}catch(s){if(console.error("Failed to fetch agent card",s),t){k(s instanceof Error?s.message:"Failed to load agent identity");const l=F();d(l),T(N(l))}}finally{t&&r(!1)}})(),()=>{t=!1}},[]);const de=(t,i)=>{d(s=>{const l=i?[...new Set([...s.protocols,t])]:s.protocols.filter(p=>p!==t);return{...s,protocols:l}})},Y=()=>{const t=H.trim();t&&(d(i=>({...i,protocols:[...new Set([...i.protocols,t])]})),D(""))},Z=()=>{const t=V.trim();t&&(d(i=>({...i,supportedInputTypes:[...new Set([...i.supportedInputTypes,t])]})),_(""))},G=()=>{const t=X.trim();t&&(d(i=>({...i,supportedOutputTypes:[...new Set([...i.supportedOutputTypes,t])]})),U(""))},pe=t=>{d(i=>({...i,supportedInputTypes:i.supportedInputTypes.filter(s=>s!==t)}))},ue=t=>{d(i=>({...i,supportedOutputTypes:i.supportedOutputTypes.filter(s=>s!==t)}))},C=(t,i)=>{d(s=>({...s,[t]:i}))},I=(t,i)=>{d(s=>({...s,authentication:{...s.authentication,[t]:i}}))},$=(t,i)=>{d(s=>({...s,security:{...s.security,[t]:i}}))},Q=(t,i)=>{d(s=>({...s,contact:{...s.contact,[t]:i}}))},he=()=>{d(t=>({...t,capabilities:[...t.capabilities,He()]}))},h=(t,i)=>{d(s=>{const l=[...s.capabilities];return l[t]={...l[t],...i},{...s,capabilities:l}})},me=t=>{d(i=>({...i,capabilities:i.capabilities.filter((s,l)=>l!==t)}))},J=()=>{const t=[["id","Agent ID"],["name","Name"],["description","Description"],["version","Version"],["url","Service URL"]];for(const[s,l]of t){const p=n[s];if(typeof p!="string"||!p.trim())throw new Error(`${l} is required`)}const i=n.capabilities.map((s,l)=>({cap:s,index:l})).filter(({cap:s})=>s.enabled&&s.id.trim()&&s.endpoint.trim()).map(({cap:s,index:l})=>{const p=s.id.trim()||`Capability ${l+1}`,m={id:s.id.trim(),skill:s.skill.trim(),description:s.description.trim(),endpoint:s.endpoint.trim(),method:s.method||"POST"},ee=(q,je)=>{if(!(!q||!q.trim()))try{return JSON.parse(q)}catch(te){throw new Error(`${p} ${je} schema must be valid JSON. ${te?.message??te}`)}};return(s.inputMimeType?.trim()||s.inputSchema?.trim())&&(m.input={mimeType:s.inputMimeType?.trim()||"application/json",schema:ee(s.inputSchema,"input")}),(s.outputMimeType?.trim()||s.outputSchema?.trim())&&(m.output={mimeType:s.outputMimeType?.trim()||"application/json",schema:ee(s.outputSchema,"output")}),m});return{id:n.id.trim(),name:n.name.trim(),description:n.description.trim(),version:n.version.trim(),url:n.url.trim(),documentation:n.documentation.trim()||void 0,protocols:n.protocols,authentication:{scheme:n.authentication.scheme.trim()||"api_key",in:n.authentication.in.trim()||"header",name:n.authentication.name.trim()||"X-API-Key",example:n.authentication.example.trim()||void 0,description:n.authentication.description.trim()||void 0},capabilities:i,supportedContentTypes:{input:n.supportedInputTypes,output:n.supportedOutputTypes},security:{transport:n.security.transport.trim()||"https",encryption:n.security.encryption.trim()||"TLS 1.3",notes:n.security.notes.trim()||void 0},contact:{name:n.contact.name.trim()||void 0,email:n.contact.email.trim()||void 0},lastUpdated:new Date().toISOString()}},xe=async()=>{B(!0),k(null);try{const t=J(),i=await fetch(`${ie}/api/v1/identity/agent-card`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({card:t})}),s=await i.json();if(!i.ok||!s?.success)throw new Error(s?.error||"Failed to save agent card");a({title:"Agent card saved",description:"The identity card has been updated successfully."});const l=s?.data?.updatedAt??new Date().toISOString();d(p=>{const m={...p,lastUpdated:l};return T(N(m)),m}),R(l)}catch(t){console.error("Failed to save agent card",t),k(t instanceof Error?t.message:"Failed to save agent card"),a({title:"Save failed",description:t instanceof Error?t.message:"Failed to save agent card, see console for details.",variant:"destructive"})}finally{B(!1)}},ye=()=>{d(N(A)),k(null),D(""),_(""),U(""),R(A.lastUpdated??P)},ge=async()=>{try{const t=JSON.stringify(J(),null,2);await navigator.clipboard.writeText(t),z(!0),setTimeout(()=>z(!1),1500),a({title:"Copied!",description:"Agent card JSON copied to clipboard."})}catch(t){console.error("Failed to copy agent card preview:",t),a({title:"Copy failed",description:"Unable to copy agent card JSON to clipboard.",variant:"destructive"})}},W=u.useMemo(()=>{if(!P)return null;try{return new Date(P).toLocaleString()}catch{return null}},[P]);return M?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(se,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading identity card..."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col justify-between gap-4 md:flex-row md:items-end",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Agent Identity"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage the"," ",e.jsx("a",{href:"/.well-known/agent-card.json",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-4 hover:text-primary",children:"/.well-known/agent-card.json"})," ","descriptor for A2A discovery."]}),W&&e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Last updated ",W]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(x,{variant:"outline",onClick:ye,disabled:L,children:[e.jsx(qe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Reset"})]}),e.jsx(x,{onClick:xe,disabled:L,children:L?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"h-4 w-4 animate-spin sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Saving..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Save Changes"})]})})]})]}),K&&e.jsxs(Fe,{variant:"destructive",children:[e.jsx("div",{className:"font-semibold",children:"Something went wrong"}),e.jsx(Pe,{children:K})]}),e.jsxs(Ee,{defaultValue:"overview",className:"space-y-6",children:[e.jsxs(Me,{className:"grid w-full grid-cols-6 h-auto p-1",children:[e.jsxs(b,{value:"overview",className:"gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Identity"})]}),e.jsxs(b,{value:"protocols",className:"gap-2",children:[e.jsx(Te,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Protocols"})]}),e.jsxs(b,{value:"auth",className:"gap-2",children:[e.jsx(Ce,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Security"})]}),e.jsxs(b,{value:"capabilities",className:"gap-2",children:[e.jsx(Le,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Capabilities"})]}),e.jsxs(b,{value:"contact",className:"gap-2",children:[e.jsx($e,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(b,{value:"preview",className:"gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Preview"})]})]}),e.jsx(S,{value:"overview",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Identity Overview"}),e.jsx(v,{children:"Define core attributes used for discovery."})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-id",children:"Agent Identifier"}),e.jsx(c,{id:"agent-id",value:n.id,placeholder:"urn:agent:coconut-dev",onChange:t=>C("id",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-name",children:"Name"}),e.jsx(c,{id:"agent-name",value:n.name,placeholder:"Coconut Development Agent",onChange:t=>C("name",t.target.value)})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-version",children:"Version"}),e.jsx(c,{id:"agent-version",value:n.version,placeholder:"1.0.0",onChange:t=>C("version",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-url",children:"Primary Endpoint"}),e.jsx(c,{id:"agent-url",value:n.url,placeholder:"https://coconut.dev/api/v1",onChange:t=>C("url",t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-description",children:"Description"}),e.jsx(O,{id:"agent-description",value:n.description,placeholder:"Agent responsible for managing proposals, plans, and operations...",onChange:t=>C("description",t.target.value),rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-docs",children:"Documentation URL"}),e.jsx(c,{id:"agent-docs",value:n.documentation,placeholder:"https://docs.coconut.dev/a2a",onChange:t=>C("documentation",t.target.value)})]})]})]})}),e.jsx(S,{value:"protocols",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Protocols & Content Types"}),e.jsx(v,{children:"Select supported discovery protocols and payload formats."})]}),e.jsxs(f,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Protocols"}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:ce.map(t=>e.jsxs("label",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[e.jsx(ae,{checked:n.protocols.includes(t),onCheckedChange:i=>de(t,!!i)}),e.jsx("span",{className:"text-sm font-medium",children:t})]},t))}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:H,placeholder:"Add custom protocol (press Add)",onChange:t=>D(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),Y())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:Y,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]})]}),e.jsx(ne,{}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Supported Input Types"}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:V,placeholder:"application/json",onChange:t=>_(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),Z())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:Z,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.supportedInputTypes.map(t=>e.jsxs(re,{variant:"secondary",className:"flex items-center gap-1",children:[t,e.jsx("button",{type:"button",onClick:()=>pe(t),className:"ml-1 rounded-full border border-transparent bg-transparent text-muted-foreground transition hover:text-foreground",children:"×"})]},t))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Supported Output Types"}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:X,placeholder:"application/json",onChange:t=>U(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),G())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:G,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.supportedOutputTypes.map(t=>e.jsxs(re,{variant:"secondary",className:"flex items-center gap-1",children:[t,e.jsx("button",{type:"button",onClick:()=>ue(t),className:"ml-1 rounded-full border border-transparent bg-transparent text-muted-foreground transition hover:text-foreground",children:"×"})]},t))})]})]})]})]})}),e.jsx(S,{value:"auth",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Authentication & Security"}),e.jsx(v,{children:"Document how peer agents should authenticate and connect."})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-scheme",children:"Authentication Scheme"}),e.jsx(c,{id:"auth-scheme",value:n.authentication.scheme,placeholder:"api_key",onChange:t=>I("scheme",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-in",children:"Credential Location"}),e.jsx(c,{id:"auth-in",value:n.authentication.in,placeholder:"header",onChange:t=>I("in",t.target.value)})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-name",children:"Header or Field Name"}),e.jsx(c,{id:"auth-name",value:n.authentication.name,placeholder:"X-API-Key",onChange:t=>I("name",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-example",children:"Example Secret"}),e.jsx(c,{id:"auth-example",value:n.authentication.example,placeholder:"nut_***************",onChange:t=>I("example",t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-description",children:"Authentication Notes"}),e.jsx(O,{id:"auth-description",value:n.authentication.description,placeholder:"Provide API key via X-API-Key header to authenticate requests between agents.",onChange:t=>I("description",t.target.value),rows:3})]}),e.jsx(ne,{}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-transport",children:"Transport"}),e.jsx(c,{id:"security-transport",value:n.security.transport,placeholder:"https",onChange:t=>$("transport",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-encryption",children:"Encryption"}),e.jsx(c,{id:"security-encryption",value:n.security.encryption,placeholder:"TLS 1.3",onChange:t=>$("encryption",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-notes",children:"Security Notes"}),e.jsx(c,{id:"security-notes",value:n.security.notes,placeholder:"Requests must be encrypted over TLS.",onChange:t=>$("notes",t.target.value)})]})]})]})]})}),e.jsx(S,{value:"capabilities",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Capabilities"}),e.jsx(v,{children:"Describe the skills other agents can invoke."})]}),e.jsxs(f,{className:"space-y-4",children:[n.capabilities.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 p-6 text-center text-sm text-muted-foreground",children:"No capabilities defined yet. Add one to expose functionality for peer agents."}),n.capabilities.map((t,i)=>e.jsxs(y,{className:"border border-border/60",children:[e.jsxs(g,{className:"flex flex-col gap-2 space-y-0 md:flex-row md:items-center",children:[e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsxs(j,{className:"text-lg font-semibold",children:["Capability #",i+1]}),e.jsx(v,{children:"Toggle availability and describe request contracts."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ae,{checked:t.enabled,onCheckedChange:s=>h(i,{enabled:!!s})}),"Expose capability"]}),e.jsxs(x,{size:"icon",variant:"ghost",onClick:()=>me(i),title:"Remove capability",children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Remove capability"})]})]})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Capability ID"}),e.jsx(c,{value:t.id,placeholder:"create-proposal",onChange:s=>h(i,{id:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Skill"}),e.jsx(c,{value:t.skill,placeholder:"proposal_management.create",onChange:s=>h(i,{skill:s.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Description"}),e.jsx(O,{value:t.description,placeholder:"Creates a new task containing intent, plan, and artifacts.",rows:3,onChange:s=>h(i,{description:s.target.value})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Endpoint"}),e.jsx(c,{value:t.endpoint,placeholder:"https://coconut.dev/api/v1/proposals",onChange:s=>h(i,{endpoint:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"HTTP Method"}),e.jsxs(we,{value:t.method,onValueChange:s=>h(i,{method:s}),children:[e.jsx(Ae,{children:e.jsx(ke,{placeholder:"Select method"})}),e.jsx(Ie,{children:Ke.map(s=>e.jsx(Oe,{value:s,children:s},s))})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Input MIME Type"}),e.jsx(c,{value:t.inputMimeType??"",placeholder:"application/json",onChange:s=>h(i,{inputMimeType:s.target.value})}),e.jsx(o,{children:"Input Schema (JSON)"}),e.jsx(O,{value:t.inputSchema??"",placeholder:'{ "type": "object", "properties": { "title": { "type": "string" } } }',rows:5,onChange:s=>h(i,{inputSchema:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Output MIME Type"}),e.jsx(c,{value:t.outputMimeType??"",placeholder:"application/json",onChange:s=>h(i,{outputMimeType:s.target.value})}),e.jsx(o,{children:"Output Schema (JSON)"}),e.jsx(O,{value:t.outputSchema??"",placeholder:'{ "type": "object", "properties": { "status": { "type": "string" } } }',rows:5,onChange:s=>h(i,{outputSchema:s.target.value})})]})]})]})]},`${t.id||"capability"}-${i}`))]}),e.jsx(Se,{children:e.jsxs(x,{type:"button",variant:"outline",onClick:he,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add Capability"]})})]})}),e.jsx(S,{value:"contact",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Contact"}),e.jsx(v,{children:"Provide a human escalation path for peer agents."})]}),e.jsxs(f,{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"contact-name",children:"Contact Name"}),e.jsx(c,{id:"contact-name",value:n.contact.name,placeholder:"Coconut DevOps Team",onChange:t=>Q("name",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"contact-email",children:"Contact Email"}),e.jsx(c,{id:"contact-email",value:n.contact.email,placeholder:"support@coconut.dev",onChange:t=>Q("email",t.target.value)})]})]})]})}),e.jsx(S,{value:"preview",children:e.jsxs(y,{children:[e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(j,{children:"Preview"}),e.jsx(v,{children:"Review the JSON payload served at /.well-known/agent-card.json."})]}),e.jsx(x,{variant:"outline",size:"sm",onClick:ge,children:le?e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy"})]})})]})}),e.jsx(f,{children:e.jsx("pre",{className:"max-h-96 overflow-auto rounded-md bg-muted p-4 text-sm",children:JSON.stringify((()=>{try{return J()}catch{return{id:n.id,name:n.name,description:n.description,version:n.version,url:n.url,protocols:n.protocols}}})(),null,2)})})]})})]})]})}export{nt as default};
@@ -1 +0,0 @@
1
- import{E as se,u as te,a as ae,ag as re,r as d,j as e,B as c,L as N,x as C,J as ne,N as ie,O as de,Q as le,R as ce,U as oe,V as me,W as xe,Y as ue,Z as he,k as H,ac as pe,p as je,F as ge,H as fe,a2 as O,n as Ne,A as v}from"./index-9Tv-j_Ga.js";import{c as ve}from"./clipboard-B9ndUJKl.js";import{C as o,b as g,a as m,c as b,d as G}from"./card-SN5gKnu7.js";import{B as w}from"./badge-AwLOflf5.js";import{A as D}from"./arrow-left-WGBYWq3h.js";import{P as S}from"./play-DF_Qeu0H.js";import{C as be,a as we}from"./clipboard-BdymjxLO.js";import{R as ye}from"./refresh-cw-BFZxHqbC.js";import{C as Ce}from"./chevron-up-CHdIiLxL.js";import{P as Se}from"./pause-CAWbvTiL.js";import{C as V}from"./clock-HDu44KTo.js";const Ae=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"}],f=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},L=a=>{if(!a)return"—";const i=new Date(a).getTime()-Date.now(),l=Math.round(i/(1e3*60));if(Number.isNaN(l))return f(a);if(Math.abs(l)<1)return"now";if(l>0){if(l<60)return`in ${l}m`;const h=Math.round(l/60);return h<24?`in ${h}h`:`in ${Math.round(h/24)}d`}const t=Math.abs(l);if(t<60)return`${t}m ago`;const u=Math.round(t/60);return u<24?`${u}h ago`:`${Math.round(u/24)}d ago`},ke=a=>{if(a.type==="interval"){const x=a.daysOfWeek.map(i=>i.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${x||"All days"})`}return a.description||`Cron: ${a.expression}`},Re=a=>{const x=Ae.find(i=>i.id===a);return x?x.label:a},T=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}};function _e(){const{id:a}=se(),x=te(),{toast:i}=ae(),{refresh:l}=re(),[t,u]=d.useState(null),[$,h]=d.useState(!0),[y,E]=d.useState(null),[P,F]=d.useState(!1),[A,J]=d.useState(!1),[p,U]=d.useState(!1),[W,B]=d.useState(!1),[q,Q]=d.useState(new Set),[M,k]=d.useState({}),[Y,_]=d.useState(new Set),R=async()=>{if(a)try{h(!0);const r=await(await fetch(`${v}/api/v1/jobs/${a}`)).json();r.success?u(r.data):E(r.error?.message||"Failed to fetch job")}catch(s){E(s instanceof Error?s.message:"Unknown error")}finally{h(!1)}};d.useEffect(()=>{R()},[a]);const Z=async()=>{if(a){F(!0);try{const r=await(await fetch(`${v}/api/v1/jobs/${a}`,{method:"DELETE"})).json();r.success?(i({title:"Job deleted",description:t?.name||"Scheduled job has been deleted"}),x("/schedule")):i({title:"Failed to delete job",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(s){i({title:"Failed to delete job",description:s instanceof Error?s.message:"Unknown error",variant:"destructive"})}finally{F(!1)}}},K=async()=>{if(!t||!a)return;J(!0);const s=t.status==="active"?"paused":"active";try{const n=await(await fetch(`${v}/api/v1/jobs/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:s})})).json();n.success?(u(n.data),await l(),i({title:s==="active"?"Job resumed":"Job paused",description:t.name})):i({title:"Failed to update job",description:n.error?.message||"Unknown error",variant:"destructive"})}catch(r){i({title:"Failed to update job",description:r instanceof Error?r.message:"Unknown error",variant:"destructive"})}finally{J(!1)}},z=async()=>{if(!(!t||!a)){U(!0);try{const s=await fetch(`${v}/api/v1/jobs/${a}/run`,{method:"POST"}),r=await s.json();r.success||s.ok?(i({title:"Run started",description:`${t.name} is executing.`}),await R(),await l()):i({title:"Failed to start run",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(s){i({title:"Failed to start run",description:s instanceof Error?s.message:"Unknown error",variant:"destructive"})}finally{U(!1)}}},X=async s=>{Q(r=>{const n=new Set(r);return n.has(s)?n.delete(s):(n.add(s),!M[s]&&a&&ee(s)),n})},ee=async s=>{if(a){_(r=>new Set(r).add(s));try{const r=await fetch(`${v}/api/v1/jobs/${a}/runs/${s}/log`);if(r.ok){const n=await r.text();k(j=>({...j,[s]:n}))}else{const n=await r.json().catch(()=>({}));k(j=>({...j,[s]:n.error?.message||"Log not available"}))}}catch(r){k(n=>({...n,[s]:r instanceof Error?r.message:"Failed to load log"}))}finally{_(r=>{const n=new Set(r);return n.delete(s),n})}}};if($)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(N,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]})}),e.jsx(m,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-5/6 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-4/6 animate-pulse"})]})})]})]});if(y||!t)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:y||"Job not found"})}),e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(N,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})]}),e.jsx(o,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:y||"Job not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The job with ID "',a,'" could not be found.']}),e.jsx(c,{asChild:!0,className:"mt-4",children:e.jsx(N,{to:"/schedule",children:"Back to Schedule"})})]})})})]});const I=t.agentIds||(t.agentId?[t.agentId]:[]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:t.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(N,{to:"/schedule",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})}),e.jsxs(c,{variant:"default",size:"sm",onClick:z,disabled:p||!!t._error,children:[p?e.jsx(C,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Running...":"Run Now"})]}),e.jsxs(ne,{children:[e.jsx(ie,{asChild:!0,children:e.jsxs(c,{variant:"destructive",size:"sm",disabled:P,children:[e.jsx(de,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:P?"Deleting...":"Delete"})]})}),e.jsxs(le,{children:[e.jsxs(ce,{children:[e.jsx(oe,{children:"Are you absolutely sure?"}),e.jsxs(me,{children:["This action cannot be undone. This will permanently delete the scheduled job",e.jsxs("span",{className:"font-semibold",children:[' "',t.name,'"']}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(xe,{children:[e.jsx(ue,{children:"Cancel"}),e.jsx(he,{onClick:Z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Job"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const s=`.nut/jobs/job-${t.id}.md`;try{await ve(s),B(!0),i({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>B(!1),2e3)}catch(r){console.error("Failed to copy path:",r),i({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono",children:[e.jsx("span",{children:`.nut/jobs/job-${t.id}.md`}),W?e.jsx(be,{className:"h-3.5 w-3.5"}):e.jsx(we,{className:"h-3.5 w-3.5"})]})]}),t._error&&e.jsx(o,{className:"border-destructive/50 bg-destructive/5",children:e.jsxs(m,{className:"pt-6",children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:t._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/job-",t.id,".md"]})]})]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(o,{children:[e.jsxs(g,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Job Configuration"}),e.jsx(w,{variant:T(t.status),className:"capitalize",children:t.status})]}),t.description&&e.jsx(G,{children:t.description})]}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Instructions"}),e.jsx("div",{className:"rounded-md bg-muted/50 p-3 font-mono text-sm whitespace-pre-wrap",children:t.prompt})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"AI Model"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:Re(t.model)})]})]}),I.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Custom Agents"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:I.map(s=>e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 text-xs",children:[e.jsx(H,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:s.replace(".md","")})]},s))})]}),t.mcpServers&&t.mcpServers.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"MCP Servers"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.mcpServers.map(s=>e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800 text-xs",children:[e.jsx(pe,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:s})]},s))})]})]})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{children:"Run History"}),e.jsxs(G,{children:[t.runs.length," recorded run",t.runs.length!==1?"s":""]})]}),e.jsxs(c,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})}),e.jsx(m,{children:t.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-6 text-center text-sm text-muted-foreground",children:'No runs yet. Click "Run Now" to execute this job.'}):e.jsx("div",{className:"space-y-3",children:t.runs.map(s=>{const r=q.has(s.id),n=Y.has(s.id),j=M[s.id];return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden",children:[e.jsxs("div",{className:"p-3 cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>X(s.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(w,{variant:T(s.status),className:"capitalize text-xs",children:s.status}),e.jsx("span",{className:"text-sm text-muted-foreground",children:f(s.startedAt)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",L(s.startedAt),")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.trigger==="manual"&&e.jsx(w,{variant:"outline",className:"text-xs",children:"manual"}),r?e.jsx(Ce,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(je,{className:"h-4 w-4 text-muted-foreground"})]})]}),s.error&&e.jsx("p",{className:"text-sm text-destructive font-medium mb-2",children:s.error}),s.summary&&!r&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.summary})]}),r&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t bg-muted/20",children:[e.jsxs("div",{className:"pt-3 grid gap-2 text-xs",children:[s.finishedAt&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Finished:"}),e.jsx("span",{children:f(s.finishedAt)})]}),s.cliCommand&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Command:"}),e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs break-all",children:s.cliCommand})]}),s.outputPath&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Log path:"}),e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs",children:s.outputPath})]})]}),s.summary&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Summary"}),e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-xs leading-relaxed whitespace-pre-wrap",children:s.summary})]}),e.jsxs("div",{children:[e.jsxs("h5",{className:"text-xs font-medium text-muted-foreground mb-1 flex items-center gap-1.5",children:[e.jsx(ge,{className:"h-3 w-3"}),"Full Log"]}),n?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground p-2",children:[e.jsx(C,{className:"h-3 w-3 animate-spin"}),"Loading log..."]}):j?e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-xs leading-relaxed max-h-96 overflow-auto whitespace-pre-wrap",children:j}):e.jsx("div",{className:"text-xs text-muted-foreground p-2",children:"Log not available"})]})]})]},s.id)})})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Actions"})}),e.jsxs(m,{className:"space-y-2",children:[e.jsxs(c,{variant:"default",className:"w-full justify-start",onClick:z,disabled:p||!!t._error,children:[p?e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(S,{className:"h-4 w-4 mr-2"}),p?"Running...":"Run Now"]}),e.jsxs(c,{variant:"outline",className:"w-full justify-start",onClick:K,disabled:A||!!t._error,children:[A?e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}):t.status==="active"?e.jsx(Se,{className:"h-4 w-4 mr-2"}):e.jsx(S,{className:"h-4 w-4 mr-2"}),A?"Updating...":t.status==="active"?"Pause Job":"Resume Job"]}),e.jsx(c,{variant:"outline",className:"w-full justify-start",asChild:!0,disabled:!!t._error,children:e.jsxs(N,{to:"/schedule",state:{editJobId:t.id},children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Edit Job"]})})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Schedule"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(V,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:ke(t.schedule)})]}),t.schedule.type==="interval"&&t.schedule.anchorHour!==void 0&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Start hour:"})," ",e.jsxs("span",{children:[t.schedule.anchorHour,":00"]})]}),e.jsx(O,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Next run:"}),e.jsx("span",{className:"font-medium",children:L(t.metadata.nextRunAt)})]}),t.metadata.nextRunAt&&e.jsx("div",{className:"text-xs text-muted-foreground",children:f(t.metadata.nextRunAt)})]})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Information"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ne,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:f(t.metadata.createdAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(V,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Updated:"}),e.jsx("span",{children:f(t.metadata.updatedAt)})]}),t.metadata.lastRunAt&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(S,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Last run:"}),e.jsx("span",{children:L(t.metadata.lastRunAt)})]}),e.jsx(O,{}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Status:"}),e.jsx("div",{className:"mt-1",children:e.jsx(w,{variant:T(t.status),className:"capitalize",children:t.status})})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:t.tags.map(s=>e.jsx(w,{variant:"outline",className:"text-xs",children:s},s))})]})]})]})]})]})]})}export{_e as default};
@@ -1,8 +0,0 @@
1
- import{c as q,j as e,S as G,_ as Q,u as W,r as p,a as X,A as $,x as Z,B as x,L as P,P as z,F as C,M,ah as I,ai as K}from"./index-9Tv-j_Ga.js";import{C as L,a as B}from"./card-SN5gKnu7.js";import{B as j}from"./badge-AwLOflf5.js";import{c as ee}from"./clipboard-B9ndUJKl.js";import{R as te,L as O}from"./browser-modal-BzGNFfTG.js";import{R as se,f as ae}from"./registry-ANRa5WBi.js";import{A as ne}from"./arrow-up-BByVUPE7.js";import{A as re}from"./arrow-down-BZnfbld8.js";import"./search-Dr90tbch.js";/**
2
- * @license lucide-react v0.542.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ie=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],oe=q("arrow-up-down",ie),le=["createdAt","updatedAt","version","tags"];function _(a){if(a){if(Array.isArray(a)){const l=a.map(i=>{if(typeof i=="string")return i.trim();if(typeof i=="number")return`${i}`}).filter(i=>typeof i=="string"&&i.length>0);return l.length>0?l:void 0}if(typeof a=="string"){const l=a.split(",").map(i=>i.trim()).filter(i=>i.length>0);return l.length>0?l:void 0}}}function ce(a,l){const i=[];if(a.content&&typeof a.content=="object")for(const r of Object.values(a.content))typeof r=="string"&&r.trim().length>0&&i.push(r.trim());const s=[];return s.push(`# ${l}`),a.description?.trim()&&s.push(a.description.trim()),[...s,...i].join(`
7
-
8
- `).trim()}function U(a,l){const i=a.name||l.name,s={registryId:a.id,registryEndpoint:a.endpoint,registrySource:se,author:a.author,category:"general"};for(const r of le){const o=l[r];if(o!==void 0)if(r==="tags"){const m=_(o);m&&(s[r]=m)}else s[r]=o}!s.version&&a.version&&(s.version=a.version),!s.tags&&a.tags&&(s.tags=_(a.tags));const d=s.tags;if(d){const r=["knowledge","architecture","rules"],o=d.find(m=>r.includes(m.toLowerCase()));o&&(s.type=o.toLowerCase())}for(const[r,o]of Object.entries(s))o==null&&delete s[r];return{title:i,content:ce(l,i),metadata:Object.keys(s).length>0?s:void 0}}function H({open:a,onOpenChange:l,onImport:i}){return e.jsx(te,{open:a,onOpenChange:l,categoryId:"knowledge",title:"Coconut Registry – Knowledge",confirmLabel:"Import Knowledge",getDetail:s=>ae(s.endpoint),renderPreview:(s,d)=>{if(!d)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select a knowledge item to preview"});const r=U(s,d),o=r.metadata??{},m=typeof o.version=="string"?o.version:void 0,f=Array.isArray(s.tags)?s.tags:[],y=typeof o.category=="string"?o.category:"general",w=typeof o.type=="string"?o.type:void 0;return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(G,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]}),m&&e.jsxs(j,{variant:"outline",children:["v",m]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:s.id})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(j,{variant:"secondary",className:"capitalize",children:y}),w&&e.jsx(j,{variant:"outline",className:"capitalize",children:w})]}),f.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(g=>e.jsx(j,{variant:"secondary",children:g},g))})]}),e.jsx(Q,{className:"[&_.prose]:max-w-none",children:r.content})]})})})},onConfirm:async(s,d)=>{const r=U(s,d);await i({summary:s,detail:d,payload:r})}})}const J=a=>{if(!a)return"Unknown";const l=new Date(a);if(Number.isNaN(l.getTime()))return a;const s=new Date().getTime()-l.getTime(),d=Math.floor(s/6e4),r=Math.floor(s/36e5),o=Math.floor(s/864e5);return d<1?"Just now":d<60?`${d} minute${d===1?"":"s"} ago`:r<24?`${r} hour${r===1?"":"s"} ago`:o<7?`${o} day${o===1?"":"s"} ago`:new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(l)};function we(){const a=W(),[l,i]=p.useState([]),[s,d]=p.useState(!0),[r,o]=p.useState({}),[m,f]=p.useState(!1),[y,w]=p.useState(!1),[g,V]=p.useState("updated"),[A,S]=p.useState("desc"),{toast:u}=X(),v=p.useCallback(async()=>{d(!0);try{const t=await fetch(`${$}/api/v1/knowledge`);if(!t.ok)throw new Error("Failed to load knowledge");const n=await t.json();i(n.documents||[])}catch(t){console.error("Failed to load knowledge:",t),i([])}finally{d(!1)}},[]);p.useEffect(()=>{v()},[v]);const N=t=>{g===t?S(n=>n==="asc"?"desc":"asc"):(V(t),S(t==="updated"?"desc":"asc"))},Y=[...l].sort((t,n)=>{let c=0;switch(g){case"file":c=(t.title||t.filename).localeCompare(n.title||n.filename);break;case"category":c=(t.metadata.category||"general").localeCompare(n.metadata.category||"general");break;case"updated":{const h=new Date(t.metadata.updated||0).getTime(),E=new Date(n.metadata.updated||0).getTime();c=h-E;break}}return A==="asc"?c:-c}),b=({column:t})=>g!==t?e.jsx(oe,{className:"h-3 w-3 ml-1 opacity-50"}):A==="asc"?e.jsx(ne,{className:"h-3 w-3 ml-1"}):e.jsx(re,{className:"h-3 w-3 ml-1"}),k=async t=>{const n=`.nut/knowledge/${t}`;try{await ee(n),o(c=>({...c,[t]:!0})),setTimeout(()=>{o(c=>({...c,[t]:!1}))},2e3),u({title:"Path copied!",description:`Copied ${n} to clipboard`})}catch(c){console.error("Failed to copy path:",c),u({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},D=t=>{const n=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${t.filename.replace(".md","")}`,filename:t.filename,name:t.filename,path:`.nut/knowledge/${t.filename}`}});window.dispatchEvent(n)},T=p.useCallback(async({payload:t})=>{let n=!1;w(!0);try{const c=await fetch(`${$}/api/v1/knowledge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t.title,content:t.content,metadata:t.metadata})});let h=null;try{h=await c.json()}catch(F){console.error("Failed to parse registry import response:",F)}if(!(c.ok&&h?.success)){const R=(typeof h?.error=="string"?h.error:h?.error?.message)||c.statusText||"Failed to import knowledge from registry";throw u({title:"Failed to import knowledge",description:R,variant:"destructive"}),n=!0,new Error(R)}u({title:"Knowledge imported",description:`${t.title} is now available in Coconut`}),await v()}catch(c){if(!n){const h=c instanceof Error&&c.message?c.message:"Failed to import knowledge from registry";u({title:"Failed to import knowledge",description:h,variant:"destructive"})}throw c}finally{w(!1)}},[v,u]);return s?e.jsx("div",{className:"space-y-6",children:e.jsx(L,{children:e.jsx(B,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Z,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge base..."})]})})})}):l.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Knowledge Base"}),e.jsx("p",{className:"text-muted-foreground",children:"Accumulated project knowledge, patterns, and best practices"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>f(!0),disabled:y,children:[e.jsx(O,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(x,{size:"sm",asChild:!0,children:e.jsxs(P,{to:"/knowledge/new",children:[e.jsx(z,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(L,{children:e.jsx(B,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Knowledge Documents Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Knowledge documents will appear here as they are created."})]})})})]}),e.jsx(H,{open:m,onOpenChange:f,onImport:T})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Knowledge Base"}),e.jsxs("p",{className:"text-muted-foreground",children:["Accumulated project knowledge, patterns, and best practices (",l.length," documents)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>f(!0),disabled:y,children:[e.jsx(O,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(x,{size:"sm",asChild:!0,children:e.jsxs(P,{to:"/knowledge/new",children:[e.jsx(z,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsxs("div",{className:"rounded-lg border overflow-hidden",children:[e.jsxs("div",{className:"hidden bg-muted/50 px-4 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground md:grid md:grid-cols-[minmax(0,2.5fr),minmax(0,1fr),minmax(0,1fr),auto] md:items-center md:gap-4",children:[e.jsxs("button",{type:"button",onClick:()=>N("file"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["File",e.jsx(b,{column:"file"})]}),e.jsxs("button",{type:"button",onClick:()=>N("category"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["Category",e.jsx(b,{column:"category"})]}),e.jsxs("button",{type:"button",onClick:()=>N("updated"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["Updated",e.jsx(b,{column:"updated"})]}),e.jsx("span",{className:"justify-self-end",children:"Actions"})]}),e.jsx("div",{className:"divide-y",children:Y.map(t=>e.jsxs("div",{onClick:()=>a(`/knowledge/${t.filename.replace(".md","")}`),className:"px-3 py-3 transition-colors hover:bg-muted/60 cursor-pointer md:px-4 md:py-4 md:grid md:grid-cols-[minmax(0,2.5fr),minmax(0,1fr),minmax(0,1fr),auto] md:items-center md:gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 md:hidden",children:[e.jsx("div",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:e.jsx(C,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium text-foreground text-sm",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(j,{variant:"secondary",className:"capitalize text-[10px] px-1.5 py-0",children:t.metadata.category||"general"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:J(t.metadata.updated)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),D(t)},className:"h-7 w-7",title:"Discuss in chat",children:e.jsx(M,{className:"h-3 w-3"})}),e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),k(t.filename)},className:"h-7 w-7",title:"Copy file path to clipboard",children:r[t.filename]?e.jsx(I,{className:"h-3 w-3 text-green-600"}):e.jsx(K,{className:"h-3 w-3"})})]})]})})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:e.jsx(C,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("div",{className:"block truncate font-medium text-foreground",children:t.title}),e.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),k(t.filename)},className:`inline-flex max-w-full items-center overflow-hidden rounded bg-muted px-2 py-1 font-mono text-xs text-muted-foreground transition-colors hover:bg-muted/80${r[t.filename]?" ring-1 ring-primary/50 text-foreground":""}`,title:"Copy file path to clipboard",children:e.jsxs("span",{className:"truncate",children:[".nut/knowledge/",t.filename]})})]})]}),e.jsx("div",{className:"hidden md:block",children:e.jsx(j,{variant:"secondary",className:"capitalize",children:t.metadata.category||"general"})}),e.jsx("div",{className:"hidden text-sm text-muted-foreground md:block",children:J(t.metadata.updated)}),e.jsxs("div",{className:"hidden md:flex items-center gap-1 justify-end",children:[e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),D(t)},className:"h-8 w-8",title:"Discuss in chat",children:e.jsx(M,{className:"h-3.5 w-3.5"})}),e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),k(t.filename)},className:"h-8 w-8",title:"Copy file path to clipboard",children:r[t.filename]?e.jsx(I,{className:"h-3 w-3 text-green-600"}):e.jsx(K,{className:"h-3 w-3"})})]})]},t.filename))})]})]}),e.jsx(H,{open:m,onOpenChange:f,onImport:T})]})}export{we as default};
@@ -1,90 +0,0 @@
1
- import{u as Z,v as X,a as ee,w as te,r as n,A as k,j as e,B as j,L as E,I as y,a3 as se,J as ae,Q as ie,R as ne,U as re,V as oe,W as le,Y as ce,Z as de}from"./index-9Tv-j_Ga.js";import{C as he,b as ue,c as me,a as pe}from"./card-SN5gKnu7.js";import{L as h}from"./label-TGqbNfMO.js";import{M as ge}from"./markdown-editor-ls1JPK_e.js";import{S as F,a as L,b as P,c as I,d as r}from"./select-Cs5qtMYV.js";import{C as xe}from"./CollapsibleSection-Bt_ZLnJc.js";import{I as fe,L as je}from"./ImplementationStepsEditor-Ctx0CvbU.js";import{T as ye}from"./TagInput-BK91_M1N.js";import{A as ve}from"./arrow-left-WGBYWq3h.js";import"./chevron-up-CHdIiLxL.js";import"./badge-AwLOflf5.js";const R={feature:{name:"New Feature",content:`## Problem Statement
2
- Describe the problem this new feature addresses.
3
-
4
- ## Proposed Solution
5
- Describe the solution you're proposing.
6
-
7
- ### Key Features
8
- - Feature 1
9
- - Feature 2
10
- - Feature 3
11
-
12
- ## Implementation Details
13
- Describe the technical implementation approach.
14
-
15
- ## Testing Strategy
16
- - [ ] Unit tests
17
- - [ ] Integration tests
18
- - [ ] Manual testing
19
-
20
- ## Rollout Plan
21
- 1. Development and testing
22
- 2. Staging deployment
23
- 3. Production rollout
24
-
25
- ## Success Metrics
26
- Define how you'll measure the success of this change.`},"quick-change":{name:"Quick Change",content:`## Overview
27
- Describe the quick change you're proposing.`},"bug-fix":{name:"Bug Fix",content:`## Bug Description
28
- Describe the bug that needs to be fixed.
29
-
30
- ## Steps to Reproduce
31
- 1. Step 1
32
- 2. Step 2
33
- 3. Step 3
34
-
35
- ## Expected Behavior
36
- Describe what should happen.
37
-
38
- ## Actual Behavior
39
- Describe what currently happens.
40
-
41
- ## Root Cause Analysis
42
- Explain the underlying cause of the bug.
43
-
44
- ## Proposed Fix
45
- Describe the solution to fix the bug.
46
-
47
- ## Testing Plan
48
- - [ ] Verify fix resolves the original issue
49
- - [ ] Test edge cases
50
- - [ ] Regression testing
51
-
52
- ## Risk Assessment
53
- - Impact: Low/Medium/High
54
- - Complexity: Low/Medium/High
55
- - Risk of introducing new bugs: Low/Medium/High`},refactor:{name:"Refactor",content:`## Current State
56
- Describe what needs to be refactored and why.
57
-
58
- ## Refactoring Goals
59
- - Improve code readability
60
- - Reduce complexity
61
- - Enhance maintainability
62
-
63
- ## Proposed Changes
64
- Describe the refactoring approach.
65
-
66
- ## Risk Assessment
67
- - Breaking changes: None/Low/Medium/High
68
- - Testing strategy for regression prevention`},documentation:{name:"Documentation",content:`## Documentation Gap
69
- What documentation is missing or outdated?
70
-
71
- ## Proposed Updates
72
- - [ ] API documentation
73
- - [ ] User guides
74
- - [ ] Code comments
75
- - [ ] README updates
76
-
77
- ## Target Audience
78
- Who will benefit from these documentation changes?`},"security-fix":{name:"Security Fix",content:`## Security Issue
79
- Brief description (avoid sensitive details).
80
-
81
- ## Impact Assessment
82
- - Severity: Low/Medium/High/Critical
83
- - Affected components
84
- - User impact
85
-
86
- ## Proposed Fix
87
- High-level approach to resolution.
88
-
89
- ## Verification Plan
90
- How to confirm the fix works without exposing the vulnerability.`}},M="feature";function Pe(){const B=Z(),U=X(),{toast:v}=ee(),{user:u,authEnabled:w}=te(),[c,S]=n.useState(!1),[H,q]=n.useState(M),[O,p]=n.useState(!1),[C,g]=n.useState(null),b=U.state,N=b?.description||R[M].content,V=b?.title||"",[a,l]=n.useState({title:V,description:N,priority:"medium",author:{id:"current-user",name:"",email:""}}),[m,$]=n.useState([]),[D,z]=n.useState([]),[K,W]=n.useState(N),x=n.useCallback(t=>{if((t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),!c&&a.title)){const s=document.querySelector("form");s&&s.requestSubmit()}},[c,a.title]),_=a.description!==K,Q=t=>{_?(g(t),p(!0)):T(t)},T=t=>{const s=R[t];q(t),l(i=>({...i,description:s.content})),W(s.content)},Y=()=>{C&&(T(C),g(null)),p(!1)},G=()=>{g(null),p(!1)};n.useEffect(()=>(document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}),[x]);const A=n.useCallback(async()=>{try{const s=await(await fetch(`${k}/api/v1/user/settings`)).json();if(s.success&&s.data){const{profile:i}=s.data;l(d=>({...d,author:{...d.author,name:i?.firstName&&i?.lastName?`${i.firstName} ${i.lastName}`.trim():i?.firstName||i?.lastName||d.author.name,email:i?.email||d.author.email}}))}}catch(t){console.error("Failed to load user settings:",t)}},[]);n.useEffect(()=>{w?u&&l(t=>({...t,author:{...t.author,id:u.id||t.author.id,name:u.name||t.author.name,email:u.email||t.author.email}})):A()},[w,u,A]);const J=async t=>{t.preventDefault(),S(!0);try{const s=m.map(o=>({id:o.id,description:o.description.trim(),status:o.status})).filter(o=>o.description.length>0),i=D.map(o=>o.trim()).filter(o=>o.length>0),d={title:a.title,author:{...a.author,type:"human"},planSteps:s,metadata:{priority:a.priority,tags:i},content:a.description},f=await(await fetch(`${k}/api/v1/proposals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)})).json();if(f.success)v({title:"Success",description:"Proposal created successfully."}),B(`/proposals/${f.data.id}`);else throw new Error(f.error?.message||"Failed to create proposal")}catch(s){const i=s instanceof Error?s.message:"Unknown error occurred";v({title:"Error",description:`Error creating proposal: ${i}`,variant:"destructive"})}finally{S(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"New Task"}),e.jsx("p",{className:"text-muted-foreground",children:"Create a new task"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(j,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(E,{to:"/proposals",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(ve,{className:"h-4 w-4"})})})})]}),e.jsx("form",{onSubmit:J,children:e.jsxs(he,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(me,{children:"Task Details"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{htmlFor:"template-select",className:"text-sm text-muted-foreground",children:"Template:"}),e.jsxs(F,{value:H,onValueChange:Q,children:[e.jsx(L,{className:"w-36",children:e.jsx(P,{})}),e.jsxs(I,{children:[e.jsx(r,{value:"feature",children:"New Feature"}),e.jsx(r,{value:"quick-change",children:"Quick Change"}),e.jsx(r,{value:"bug-fix",children:"Bug Fix"}),e.jsx(r,{value:"refactor",children:"Refactor"}),e.jsx(r,{value:"documentation",children:"Documentation"}),e.jsx(r,{value:"security-fix",children:"Security Fix"})]})]})]})]})}),e.jsxs(pe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"title",children:"Title *"}),e.jsx(y,{id:"title",placeholder:"Brief overview of the proposal",value:a.title,onChange:t=>l(s=>({...s,title:t.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"description",children:"Description"}),e.jsx(ge,{value:a.description,onChange:t=>l(s=>({...s,description:t||""})),placeholder:"Write your proposal description in markdown...",height:300})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"author-name",children:"Author Name"}),e.jsx(y,{id:"author-name",value:a.author.name,onChange:t=>l(s=>({...s,author:{...s.author,name:t.target.value}})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"author-email",children:"Author Email"}),e.jsx(y,{id:"author-email",type:"email",value:a.author.email,onChange:t=>l(s=>({...s,author:{...s.author,email:t.target.value}}))})]})]}),e.jsx(xe,{icon:e.jsx(je,{className:"h-4 w-4"}),title:"Optional Implementation Detail",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"priority",children:"Priority"}),e.jsxs(F,{value:a.priority,onValueChange:t=>l(s=>({...s,priority:t})),children:[e.jsx(L,{children:e.jsx(P,{placeholder:"Select priority"})}),e.jsxs(I,{children:[e.jsx(r,{value:"low",children:"Low"}),e.jsx(r,{value:"medium",children:"Medium"}),e.jsx(r,{value:"high",children:"High"}),e.jsx(r,{value:"critical",children:"Critical"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Implementation Steps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Break the change into actionable steps."})]}),m.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.length," step",m.length===1?"":"s"]})]}),e.jsx(fe,{steps:m,onChange:$,disabled:c})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Tags"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Use tags to categorize this proposal by area, team, or priority."}),e.jsx(ye,{tags:D,onChange:z,disabled:c,placeholder:"Add a tag (e.g. frontend, infra)"})]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{type:"button",variant:"outline",asChild:!0,children:e.jsx(E,{to:"/proposals",children:"Cancel"})}),e.jsx(j,{type:"submit",disabled:c||!a.title,className:"relative",children:c?e.jsx(e.Fragment,{children:"Creating..."}):e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Create Task",e.jsx("span",{className:"ml-2 text-xs opacity-60 font-mono",children:"⌘↵"})]})})]})]})]})}),e.jsx(ae,{open:O,onOpenChange:p,children:e.jsxs(ie,{children:[e.jsxs(ne,{children:[e.jsx(re,{children:"Switch Template?"}),e.jsx(oe,{children:"You have unsaved changes to your proposal description. Switching templates will replace your current content with the new template. This action cannot be undone."})]}),e.jsxs(le,{children:[e.jsx(ce,{onClick:G,children:"Cancel"}),e.jsx(de,{onClick:Y,children:"Switch Template"})]})]})})]})}export{Pe as NewProposalPage};
@@ -1 +0,0 @@
1
- import{E as ae,u as re,r as l,a as ne,j as e,B as n,L as c,H as le,J as ie,N as oe,O as ce,Q as de,R as me,U as he,V as xe,W as pe,Y as ue,Z as je,_ as O,$ as I,l as fe,D as F,a0 as R,b as B,d as H,f as V,g as z,a1 as J,q as ge,n as ve,a2 as Ne,A as f}from"./index-9Tv-j_Ga.js";import{c as Ce}from"./clipboard-B9ndUJKl.js";import{C as d,b as h,a as m,c as p,d as _}from"./card-SN5gKnu7.js";import{B as x}from"./badge-AwLOflf5.js";import{L as q}from"./label-TGqbNfMO.js";import{S as ye,a as we,b as be,c as Se,d as De}from"./select-Cs5qtMYV.js";import{g as M,C as Ae,a as ke}from"./status-utils-BDOyevaX.js";import{A as w}from"./arrow-left-WGBYWq3h.js";import{C as Te,a as Ee}from"./clipboard-BdymjxLO.js";import{I as $e}from"./info-BmtuPMhv.js";import{D as Pe}from"./download-Cv2G2Eg9.js";import{C as Ue}from"./clock-HDu44KTo.js";import"./chevron-up-CHdIiLxL.js";function Q(r){switch(r){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}function Qe(){const{id:r}=ae(),W=re(),[s,g]=l.useState(null),[Y,b]=l.useState(!0),[v,S]=l.useState(null),[D,A]=l.useState(!1),[k,T]=l.useState(!1),[E,$]=l.useState(!1),[u,N]=l.useState(""),[Z,C]=l.useState(!1),[G,y]=l.useState(!1),[j,P]=l.useState("draft"),[K,U]=l.useState(!1),{toast:L}=ne();l.useEffect(()=>{async function t(){if(r)try{b(!0);const o=await(await fetch(`${f}/api/v1/proposals/${r}`)).json();o.success?g(o.data):S(o.error?.message||"Failed to fetch proposal")}catch(a){S(a instanceof Error?a.message:"Unknown error")}finally{b(!1)}}t()},[r]);const X=async()=>{if(r){A(!0);try{const a=await(await fetch(`${f}/api/v1/proposals/${r}`,{method:"DELETE"})).json();a.success?W("/proposals"):alert(a.error?.message||"Failed to delete proposal")}catch(t){alert(`Error deleting proposal: ${t instanceof Error?t.message:"Unknown error"}`)}finally{A(!1)}}},ee=async()=>{if(!(!s||!r||j===s.status)){T(!0);try{const a=await(await fetch(`${f}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:j})})).json();a.success?(g(a.data),C(!1)):alert(a.error?.message||"Failed to update status")}catch(t){alert(`Error updating status: ${t instanceof Error?t.message:"Unknown error"}`)}finally{T(!1)}}},se=async()=>{if(!(!s||!r||!u.trim())){$(!0);try{const t={id:`comment-${Date.now()}`,content:u,author:"current-user",createdAt:new Date().toISOString()},a=[...s.comments||[],t],i=await(await fetch(`${f}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comments:a})})).json();i.success?(g(i.data),N(""),y(!1)):alert(i.error?.message||"Failed to add comment")}catch(t){alert(`Error adding comment: ${t instanceof Error?t.message:"Unknown error"}`)}finally{$(!1)}}},te=()=>{if(!s)return;const t={...s,exportedAt:new Date().toISOString()},a=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),o=URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.download=`proposal-${s.id}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)};return Y?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(c,{to:"/proposals",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(w,{className:"h-4 w-4"})})})})]}),e.jsxs(d,{children:[e.jsx(h,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]})}),e.jsx(m,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-5/6 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-4/6 animate-pulse"})]})})]})]}):v||!s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:v||"Proposal not found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(c,{to:"/proposals",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(w,{className:"h-4 w-4"})})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:v||"Proposal not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The proposal with ID "',r,'" could not be found.']}),e.jsx(n,{asChild:!0,className:"mt-4",children:e.jsx(c,{to:"/proposals",children:"Back to Proposals"})})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.title||s.intent}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(c,{to:"/proposals",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(w,{className:"h-4 w-4"})})}),e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(c,{to:`/proposals/${r}/edit`,children:[e.jsx(le,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(ie,{children:[e.jsx(oe,{asChild:!0,children:e.jsxs(n,{variant:"destructive",size:"sm",disabled:D,children:[e.jsx(ce,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:D?"Deleting...":"Delete"})]})}),e.jsxs(de,{children:[e.jsxs(me,{children:[e.jsx(he,{children:"Are you absolutely sure?"}),e.jsxs(xe,{children:["This action cannot be undone. This will permanently delete the change proposal",e.jsxs("span",{className:"font-semibold",children:[' "',s.title||s.intent,'"']})," and remove it from the system."]})]}),e.jsxs(pe,{children:[e.jsx(ue,{children:"Cancel"}),e.jsx(je,{onClick:X,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Proposal"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const t=`.nut/proposals/${s.id}.md`;try{await Ce(t),U(!0),L({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>U(!1),2e3)}catch(a){console.error("Failed to copy path:",a),L({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono",children:[e.jsx("span",{children:`.nut/proposals/${s.id}.md`}),K?e.jsx(Te,{className:"h-3.5 w-3.5"}):e.jsx(Ee,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(d,{children:[e.jsx(h,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{children:"Task Details"}),e.jsxs("div",{className:"flex gap-2",children:[s.metadata.priority&&e.jsx(x,{variant:Q(s.metadata.priority),children:s.metadata.priority}),e.jsx(x,{variant:M(s.status),children:s.status})]})]})}),e.jsx(m,{className:"space-y-4",children:s.content?e.jsx(O,{children:s.content}):e.jsx("p",{className:"text-muted-foreground",children:"No detailed content available for this proposal."})})]}),s.planSteps&&s.planSteps.length>0&&e.jsxs(d,{children:[e.jsxs(h,{children:[e.jsx(p,{children:"Implementation Steps"}),e.jsxs(_,{children:[s.planSteps.length," step",s.planSteps.length!==1?"s":""," planned"]})]}),e.jsx(m,{children:e.jsx("div",{className:"space-y-3",children:s.planSteps.map((t,a)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-muted text-xs font-medium",children:a+1}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:t.description}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:e.jsx(x,{variant:"outline",className:"text-xs",children:t.status})})]})]},t.id))})})]}),s.comments&&s.comments.length>0&&e.jsxs(d,{children:[e.jsxs(h,{children:[e.jsx(p,{children:"Comments"}),e.jsxs(_,{children:[s.comments.length," comment",s.comments.length!==1?"s":""]})]}),e.jsx(m,{children:e.jsx("div",{className:"space-y-4",children:s.comments.map((t,a)=>e.jsxs("div",{className:"border-l-2 border-muted pl-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(I,{className:"h-3 w-3"}),e.jsx("span",{children:t.author}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(t.createdAt).toLocaleString()})]}),e.jsx(O,{className:"prose-sm prose-p:mb-2 prose-ul:my-2 prose-ol:my-2",children:t.content})]},t.id||a))})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(d,{children:[e.jsx(h,{children:e.jsx(p,{children:"Task Actions"})}),e.jsxs(m,{className:"space-y-2",children:[e.jsx(n,{variant:"default",className:"w-full justify-start bg-blue-600 hover:bg-blue-700",asChild:!0,children:e.jsxs(c,{to:`/terminal/${r}?reviewOnly=true`,children:[e.jsx($e,{className:"h-4 w-4 mr-2"}),"Review Task"]})}),e.jsx(n,{variant:"default",className:"w-full justify-start",asChild:!0,children:e.jsxs(c,{to:`/terminal/${r}?startOnly=true`,children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Prepare Agent"]})}),e.jsxs(F,{open:Z,onOpenChange:C,children:[e.jsx(R,{asChild:!0,children:e.jsx(n,{variant:"outline",className:"w-full justify-start",onClick:()=>P(s?.status||"draft"),children:"Change Status"})}),e.jsxs(B,{children:[e.jsxs(H,{children:[e.jsx(V,{children:"Change Task Status"}),e.jsx(z,{children:"Update the status of this task."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(q,{htmlFor:"status",children:"Status"}),e.jsxs(ye,{value:j,onValueChange:t=>P(t),children:[e.jsx(we,{children:e.jsx(be,{placeholder:"Select status"})}),e.jsx(Se,{children:Ae.map(t=>e.jsx(De,{value:t,children:ke(t)},t))})]})]})}),e.jsxs(J,{children:[e.jsx(n,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(n,{onClick:ee,disabled:k||j===s?.status,children:k?"Updating...":"Update Status"})]})]})]}),e.jsxs(F,{open:G,onOpenChange:y,children:[e.jsx(R,{asChild:!0,children:e.jsx(n,{variant:"outline",className:"w-full justify-start",children:"Add Comment"})}),e.jsxs(B,{children:[e.jsxs(H,{children:[e.jsx(V,{children:"Add Comment"}),e.jsx(z,{children:"Add a comment to this change proposal."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(q,{htmlFor:"comment",children:"Comment"}),e.jsx(ge,{id:"comment",placeholder:"Enter your comment...",value:u,onChange:t=>N(t.target.value),rows:4})]})}),e.jsxs(J,{children:[e.jsx(n,{variant:"outline",onClick:()=>{y(!1),N("")},children:"Cancel"}),e.jsx(n,{onClick:se,disabled:E||!u.trim(),children:E?"Adding...":"Add Comment"})]})]})]}),e.jsxs(n,{variant:"outline",className:"w-full justify-start",onClick:te,children:[e.jsx(Pe,{className:"h-4 w-4 mr-2"}),"Export"]})]})]}),e.jsxs(d,{children:[e.jsx(h,{children:e.jsx(p,{children:"Information"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(I,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Author:"}),e.jsx("span",{children:s.author.name})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ve,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:new Date(s.metadata.createdAt).toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ue,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Updated:"}),e.jsx("span",{children:new Date(s.metadata.updatedAt).toLocaleString()})]}),e.jsx(Ne,{}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Status:"}),e.jsx("div",{className:"mt-1",children:e.jsx(x,{variant:M(s.status),children:s.status})})]}),s.metadata.priority&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Priority:"}),e.jsx("div",{className:"mt-1",children:e.jsx(x,{variant:Q(s.metadata.priority),children:s.metadata.priority})})]}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:s.metadata.tags.map(t=>e.jsx(x,{variant:"outline",className:"text-xs",children:t},t))})]})]})]})]})]})]})}export{Qe as default};
@@ -1 +0,0 @@
1
- import{E as R,u as U,a as H,r as o,A as P,j as e,B as m,L as x,I as O,X as V,a3 as _}from"./index-9Tv-j_Ga.js";import{L as j}from"./label-TGqbNfMO.js";import{S as k,a as L,b as D,c as F,d as r}from"./select-Cs5qtMYV.js";import{C as f,b as I,a as v,c as q,d as J}from"./card-SN5gKnu7.js";import{M as K}from"./markdown-editor-ls1JPK_e.js";import{C as W}from"./CollapsibleSection-Bt_ZLnJc.js";import{I as X,L as G}from"./ImplementationStepsEditor-Ctx0CvbU.js";import{T as Q}from"./TagInput-BK91_M1N.js";import{A as N}from"./arrow-left-WGBYWq3h.js";import"./chevron-up-CHdIiLxL.js";import"./badge-AwLOflf5.js";function ce(){const{id:i}=R(),$=U(),{toast:y}=H(),[z,S]=o.useState(!0),[h,C]=o.useState(!1),[w,b]=o.useState(null),[l,d]=o.useState({title:"",description:"",priority:"medium",status:"draft",author:{id:"current-user",name:"Current User",email:"user@example.com"}}),[p,E]=o.useState([]),[T,A]=o.useState([]);o.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${P}/api/v1/proposals/${i}`),s=await t.json();if(s.success||s.data||t.ok){const a=s.data||s;d({title:a.title||a.intent||"",description:a.content||"",priority:a.metadata?.priority||"medium",status:a.status||"draft",author:{id:a.author?.id||"current-user",name:a.author?.name||"Current User",email:a.author?.email||"user@example.com"}});const g=Array.isArray(a.planSteps)?a.planSteps:[];E(g.map((c,u)=>({id:c.id||`step-${u+1}`,description:c.description||"",status:c.status||"pending"}))),A(a.metadata?.tags||[])}else b(s.error?.message||"Failed to fetch proposal")}catch(t){b(t instanceof Error?t.message:"An error occurred")}finally{S(!1)}},M=async t=>{t.preventDefault(),C(!0);try{const s=p.map(n=>({id:n.id,description:n.description.trim(),status:n.status})).filter(n=>n.description.length>0),a=T.map(n=>n.trim()).filter(n=>n.length>0),g={title:l.title,status:l.status,planSteps:s,metadata:{priority:l.priority,tags:a},content:l.description},c=await fetch(`${P}/api/v1/proposals/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),u=await c.json();if(u.success||c.ok)y({title:"Success",description:"Proposal updated successfully."}),$(`/proposals/${i}`);else throw new Error(u.error?.message||"Failed to update proposal")}catch(s){y({title:"Error",description:`Failed to update proposal: ${s instanceof Error?s.message:"An error occurred"}`,variant:"destructive"})}finally{C(!1)}};return z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Proposal"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading proposal data..."})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(x,{to:`/proposals/${i}`,className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsxs(f,{children:[e.jsx(I,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-6 bg-muted rounded w-1/2 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-3/4 animate-pulse"})]})}),e.jsx(v,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-10 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-64 bg-muted rounded animate-pulse"})]})})]})]}):w?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(x,{to:"/proposals",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx(f,{children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:w})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Proposal"}),e.jsxs("p",{className:"text-muted-foreground",children:["Editing ",i]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(x,{to:`/proposals/${i}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx("form",{onSubmit:M,children:e.jsxs(f,{children:[e.jsxs(I,{children:[e.jsx(q,{children:"Task Details"}),e.jsx(J,{children:"Update the information for your change proposal"})]}),e.jsxs(v,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"title",children:"Title *"}),e.jsx(O,{id:"title",placeholder:"Brief description of what you want to change",value:l.title,onChange:t=>d(s=>({...s,title:t.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"description",children:"Description"}),e.jsx(K,{value:l.description,onChange:t=>d(s=>({...s,description:t||""})),placeholder:"Write your proposal description in markdown...",height:400})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"status",children:"Status"}),e.jsxs(k,{value:l.status,onValueChange:t=>d(s=>({...s,status:t})),children:[e.jsx(L,{children:e.jsx(D,{placeholder:"Select status"})}),e.jsxs(F,{children:[e.jsx(r,{value:"draft",children:"Draft"}),e.jsx(r,{value:"proposed",children:"Proposed"}),e.jsx(r,{value:"in-review",children:"In Review"}),e.jsx(r,{value:"approved",children:"Approved"}),e.jsx(r,{value:"code-complete",children:"Code Complete"}),e.jsx(r,{value:"rejected",children:"Rejected"}),e.jsx(r,{value:"merged",children:"Merged"})]})]})]}),e.jsx(W,{defaultOpen:!0,icon:e.jsx(G,{className:"h-4 w-4"}),title:"Optional Implementation Detail",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"priority",children:"Priority"}),e.jsxs(k,{value:l.priority,onValueChange:t=>d(s=>({...s,priority:t})),children:[e.jsx(L,{children:e.jsx(D,{placeholder:"Select priority"})}),e.jsxs(F,{children:[e.jsx(r,{value:"low",children:"Low"}),e.jsx(r,{value:"medium",children:"Medium"}),e.jsx(r,{value:"high",children:"High"}),e.jsx(r,{value:"critical",children:"Critical"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Implementation Steps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Keep the implementation plan accurate as work progresses."})]}),p.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.length," step",p.length===1?"":"s"]})]}),e.jsx(X,{steps:p,onChange:E,disabled:h})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Tags"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tags power filtering and discovery across the proposal list."}),e.jsx(Q,{tags:T,onChange:A,disabled:h,placeholder:"Add a tag (e.g. backend, rollout)"})]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(m,{type:"button",variant:"outline",asChild:!0,children:e.jsxs(x,{to:`/proposals/${i}`,children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Cancel"]})}),e.jsx(m,{type:"submit",disabled:h||!l.title,children:h?e.jsx(e.Fragment,{children:"Saving..."}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Save Changes"]})})]})]})]})})]})}export{ce as ProposalEditPage};
@@ -1,17 +0,0 @@
1
- import{c as xe,z as Ie,u as Le,v as Te,r as j,j as s,B as z,L as Y,P as Z,I as Re,X,K as Oe,s as $e,p as Pe,G as Ke,A as Ve}from"./index-9Tv-j_Ga.js";import{C as J,b as ze,a as q,c as We}from"./card-SN5gKnu7.js";import{B as ee}from"./badge-AwLOflf5.js";import{S as ie,a as ae,b as ce,c as ue,d as B}from"./select-Cs5qtMYV.js";import{A as Ue,a as Ae,C as Ge,g as He}from"./status-utils-BDOyevaX.js";import{S as Qe}from"./search-Dr90tbch.js";import{C as Ye}from"./chevron-up-CHdIiLxL.js";/**
2
- * @license lucide-react v0.542.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Xe=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],Je=xe("arrow-down-wide-narrow",Xe);/**
7
- * @license lucide-react v0.542.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Ze=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],qe=xe("arrow-up-narrow-wide",Ze);/**
12
- * @license lucide-react v0.542.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const et=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],je=xe("funnel",et);function R(t){return Array.isArray?Array.isArray(t):ve(t)==="[object Array]"}function tt(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function st(t){return t==null?"":tt(t)}function T(t){return typeof t=="string"}function be(t){return typeof t=="number"}function rt(t){return t===!0||t===!1||nt(t)&&ve(t)=="[object Boolean]"}function Fe(t){return typeof t=="object"}function nt(t){return Fe(t)&&t!==null}function D(t){return t!=null}function le(t){return!t.trim().length}function ve(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const it="Incorrect 'index' type",at=t=>`Invalid value for key ${t}`,ct=t=>`Pattern length exceeds max of ${t}.`,ut=t=>`Missing ${t} property in key`,lt=t=>`Property 'weight' in key '${t}' must be a positive integer`,ye=Object.prototype.hasOwnProperty;class ot{constructor(e){this._keys=[],this._keyMap={};let r=0;e.forEach(n=>{let i=Me(n);this._keys.push(i),this._keyMap[i.id]=i,r+=i.weight}),this._keys.forEach(n=>{n.weight/=r})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Me(t){let e=null,r=null,n=null,i=1,a=null;if(T(t)||R(t))n=t,e=Ce(t),r=oe(t);else{if(!ye.call(t,"name"))throw new Error(ut("name"));const c=t.name;if(n=c,ye.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(lt(c));e=Ce(c),r=oe(c),a=t.getFn}return{path:e,id:r,weight:i,src:n,getFn:a}}function Ce(t){return R(t)?t:t.split(".")}function oe(t){return R(t)?t.join("."):t}function ht(t,e){let r=[],n=!1;const i=(a,c,l)=>{if(D(a))if(!c[l])r.push(a);else{let o=c[l];const h=a[o];if(!D(h))return;if(l===c.length-1&&(T(h)||be(h)||rt(h)))r.push(st(h));else if(R(h)){n=!0;for(let d=0,m=h.length;d<m;d+=1)i(h[d],c,l+1)}else c.length&&i(h,c,l+1)}};return i(t,T(e)?e.split("."):e,0),n?r:r[0]}const dt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},ft={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},mt={location:0,threshold:.6,distance:100},gt={useExtendedSearch:!1,getFn:ht,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var f={...ft,...dt,...mt,...gt};const xt=/[^ ]+/g;function pt(t=1,e=3){const r=new Map,n=Math.pow(10,e);return{get(i){const a=i.match(xt).length;if(r.has(a))return r.get(a);const c=1/Math.pow(a,.5*t),l=parseFloat(Math.round(c*n)/n);return r.set(a,l),l},clear(){r.clear()}}}class pe{constructor({getFn:e=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){this.norm=pt(r,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((r,n)=>{this._keysMap[r.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,T(this.docs[0])?this.docs.forEach((e,r)=>{this._addString(e,r)}):this.docs.forEach((e,r)=>{this._addObject(e,r)}),this.norm.clear())}add(e){const r=this.size();T(e)?this._addString(e,r):this._addObject(e,r)}removeAt(e){this.records.splice(e,1);for(let r=e,n=this.size();r<n;r+=1)this.records[r].i-=1}getValueForItemAtKeyId(e,r){return e[this._keysMap[r]]}size(){return this.records.length}_addString(e,r){if(!D(e)||le(e))return;let n={v:e,i:r,n:this.norm.get(e)};this.records.push(n)}_addObject(e,r){let n={i:r,$:{}};this.keys.forEach((i,a)=>{let c=i.getFn?i.getFn(e):this.getFn(e,i.path);if(D(c)){if(R(c)){let l=[];const o=[{nestedArrIndex:-1,value:c}];for(;o.length;){const{nestedArrIndex:h,value:d}=o.pop();if(D(d))if(T(d)&&!le(d)){let m={v:d,i:h,n:this.norm.get(d)};l.push(m)}else R(d)&&d.forEach((m,x)=>{o.push({nestedArrIndex:x,value:m})})}n.$[a]=l}else if(T(c)&&!le(c)){let l={v:c,n:this.norm.get(c)};n.$[a]=l}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Se(t,e,{getFn:r=f.getFn,fieldNormWeight:n=f.fieldNormWeight}={}){const i=new pe({getFn:r,fieldNormWeight:n});return i.setKeys(t.map(Me)),i.setSources(e),i.create(),i}function At(t,{getFn:e=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){const{keys:n,records:i}=t,a=new pe({getFn:e,fieldNormWeight:r});return a.setKeys(n),a.setIndexRecords(i),a}function te(t,{errors:e=0,currentLocation:r=0,expectedLocation:n=0,distance:i=f.distance,ignoreLocation:a=f.ignoreLocation}={}){const c=e/t.length;if(a)return c;const l=Math.abs(n-r);return i?c+l/i:l?1:c}function jt(t=[],e=f.minMatchCharLength){let r=[],n=-1,i=-1,a=0;for(let c=t.length;a<c;a+=1){let l=t[a];l&&n===-1?n=a:!l&&n!==-1&&(i=a-1,i-n+1>=e&&r.push([n,i]),n=-1)}return t[a-1]&&a-n>=e&&r.push([n,a-1]),r}const W=32;function yt(t,e,r,{location:n=f.location,distance:i=f.distance,threshold:a=f.threshold,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,includeMatches:o=f.includeMatches,ignoreLocation:h=f.ignoreLocation}={}){if(e.length>W)throw new Error(ct(W));const d=e.length,m=t.length,x=Math.max(0,Math.min(n,m));let g=a,A=x;const C=l>1||o,v=C?Array(m):[];let E;for(;(E=t.indexOf(e,A))>-1;){let F=te(e,{currentLocation:E,expectedLocation:x,distance:i,ignoreLocation:h});if(g=Math.min(F,g),A=E+d,C){let k=0;for(;k<d;)v[E+k]=1,k+=1}}A=-1;let _=[],b=1,L=d+m;const G=1<<d-1;for(let F=0;F<d;F+=1){let k=0,y=L;for(;k<y;)te(e,{errors:F,currentLocation:x+y,expectedLocation:x,distance:i,ignoreLocation:h})<=g?k=y:L=y,y=Math.floor((L-k)/2+k);L=y;let V=Math.max(1,x-y+1),O=c?m:Math.min(x+y,m)+d,I=Array(O+2);I[O+1]=(1<<F)-1;for(let M=O;M>=V;M-=1){let $=M-1,Q=r[t.charAt($)];if(C&&(v[$]=+!!Q),I[M]=(I[M+1]<<1|1)&Q,F&&(I[M]|=(_[M+1]|_[M])<<1|1|_[M+1]),I[M]&G&&(b=te(e,{errors:F,currentLocation:$,expectedLocation:x,distance:i,ignoreLocation:h}),b<=g)){if(g=b,A=$,A<=x)break;V=Math.max(1,2*x-A)}}if(te(e,{errors:F+1,currentLocation:x,expectedLocation:x,distance:i,ignoreLocation:h})>g)break;_=I}const H={isMatch:A>=0,score:Math.max(.001,b)};if(C){const F=jt(v,l);F.length?o&&(H.indices=F):H.isMatch=!1}return H}function Ct(t){let e={};for(let r=0,n=t.length;r<n;r+=1){const i=t.charAt(r);e[i]=(e[i]||0)|1<<n-r-1}return e}const se=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class Be{constructor(e,{location:r=f.location,threshold:n=f.threshold,distance:i=f.distance,includeMatches:a=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,isCaseSensitive:o=f.isCaseSensitive,ignoreDiacritics:h=f.ignoreDiacritics,ignoreLocation:d=f.ignoreLocation}={}){if(this.options={location:r,threshold:n,distance:i,includeMatches:a,findAllMatches:c,minMatchCharLength:l,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d},e=o?e:e.toLowerCase(),e=h?se(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const m=(g,A)=>{this.chunks.push({pattern:g,alphabet:Ct(g),startIndex:A})},x=this.pattern.length;if(x>W){let g=0;const A=x%W,C=x-A;for(;g<C;)m(this.pattern.substr(g,W),g),g+=W;if(A){const v=x-W;m(this.pattern.substr(v),v)}}else m(this.pattern,0)}searchIn(e){const{isCaseSensitive:r,ignoreDiacritics:n,includeMatches:i}=this.options;if(e=r?e:e.toLowerCase(),e=n?se(e):e,this.pattern===e){let C={isMatch:!0,score:0};return i&&(C.indices=[[0,e.length-1]]),C}const{location:a,distance:c,threshold:l,findAllMatches:o,minMatchCharLength:h,ignoreLocation:d}=this.options;let m=[],x=0,g=!1;this.chunks.forEach(({pattern:C,alphabet:v,startIndex:E})=>{const{isMatch:_,score:b,indices:L}=yt(e,C,v,{location:a+E,distance:c,threshold:l,findAllMatches:o,minMatchCharLength:h,includeMatches:i,ignoreLocation:d});_&&(g=!0),x+=b,_&&L&&(m=[...m,...L])});let A={isMatch:g,score:g?x/this.chunks.length:1};return g&&i&&(A.indices=m),A}}class K{constructor(e){this.pattern=e}static isMultiMatch(e){return we(e,this.multiRegex)}static isSingleMatch(e){return we(e,this.singleRegex)}search(){}}function we(t,e){const r=t.match(e);return r?r[1]:null}class wt extends K{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const r=e===this.pattern;return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class Nt extends K{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Et extends K{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const r=e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class bt extends K{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const r=!e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class Ft extends K{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const r=e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class vt extends K{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const r=!e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class De extends K{constructor(e,{location:r=f.location,threshold:n=f.threshold,distance:i=f.distance,includeMatches:a=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,isCaseSensitive:o=f.isCaseSensitive,ignoreDiacritics:h=f.ignoreDiacritics,ignoreLocation:d=f.ignoreLocation}={}){super(e),this._bitapSearch=new Be(e,{location:r,threshold:n,distance:i,includeMatches:a,findAllMatches:c,minMatchCharLength:l,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ke extends K{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let r=0,n;const i=[],a=this.pattern.length;for(;(n=e.indexOf(this.pattern,r))>-1;)r=n+a,i.push([n,r-1]);const c=!!i.length;return{isMatch:c,score:c?0:1,indices:i}}}const he=[wt,ke,Et,bt,vt,Ft,Nt,De],Ne=he.length,Mt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,St="|";function Bt(t,e={}){return t.split(St).map(r=>{let n=r.trim().split(Mt).filter(a=>a&&!!a.trim()),i=[];for(let a=0,c=n.length;a<c;a+=1){const l=n[a];let o=!1,h=-1;for(;!o&&++h<Ne;){const d=he[h];let m=d.isMultiMatch(l);m&&(i.push(new d(m,e)),o=!0)}if(!o)for(h=-1;++h<Ne;){const d=he[h];let m=d.isSingleMatch(l);if(m){i.push(new d(m,e));break}}}return i})}const Dt=new Set([De.type,ke.type]);class kt{constructor(e,{isCaseSensitive:r=f.isCaseSensitive,ignoreDiacritics:n=f.ignoreDiacritics,includeMatches:i=f.includeMatches,minMatchCharLength:a=f.minMatchCharLength,ignoreLocation:c=f.ignoreLocation,findAllMatches:l=f.findAllMatches,location:o=f.location,threshold:h=f.threshold,distance:d=f.distance}={}){this.query=null,this.options={isCaseSensitive:r,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:a,findAllMatches:l,ignoreLocation:c,location:o,threshold:h,distance:d},e=r?e:e.toLowerCase(),e=n?se(e):e,this.pattern=e,this.query=Bt(this.pattern,this.options)}static condition(e,r){return r.useExtendedSearch}searchIn(e){const r=this.query;if(!r)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:a}=this.options;e=i?e:e.toLowerCase(),e=a?se(e):e;let c=0,l=[],o=0;for(let h=0,d=r.length;h<d;h+=1){const m=r[h];l.length=0,c=0;for(let x=0,g=m.length;x<g;x+=1){const A=m[x],{isMatch:C,indices:v,score:E}=A.search(e);if(C){if(c+=1,o+=E,n){const _=A.constructor.type;Dt.has(_)?l=[...l,...v]:l.push(v)}}else{o=0,c=0,l.length=0;break}}if(c){let x={isMatch:!0,score:o/c};return n&&(x.indices=l),x}}return{isMatch:!1,score:1}}}const de=[];function _t(...t){de.push(...t)}function fe(t,e){for(let r=0,n=de.length;r<n;r+=1){let i=de[r];if(i.condition(t,e))return new i(t,e)}return new Be(t,e)}const re={AND:"$and",OR:"$or"},me={PATH:"$path",PATTERN:"$val"},ge=t=>!!(t[re.AND]||t[re.OR]),It=t=>!!t[me.PATH],Lt=t=>!R(t)&&Fe(t)&&!ge(t),Ee=t=>({[re.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function _e(t,e,{auto:r=!0}={}){const n=i=>{let a=Object.keys(i);const c=It(i);if(!c&&a.length>1&&!ge(i))return n(Ee(i));if(Lt(i)){const o=c?i[me.PATH]:a[0],h=c?i[me.PATTERN]:i[o];if(!T(h))throw new Error(at(o));const d={keyId:oe(o),pattern:h};return r&&(d.searcher=fe(h,e)),d}let l={children:[],operator:a[0]};return a.forEach(o=>{const h=i[o];R(h)&&h.forEach(d=>{l.children.push(n(d))})}),l};return ge(t)||(t=Ee(t)),n(t)}function Tt(t,{ignoreFieldNorm:e=f.ignoreFieldNorm}){t.forEach(r=>{let n=1;r.matches.forEach(({key:i,norm:a,score:c})=>{const l=i?i.weight:null;n*=Math.pow(c===0&&l?Number.EPSILON:c,(l||1)*(e?1:a))}),r.score=n})}function Rt(t,e){const r=t.matches;e.matches=[],D(r)&&r.forEach(n=>{if(!D(n.indices)||!n.indices.length)return;const{indices:i,value:a}=n;let c={indices:i,value:a};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function Ot(t,e){e.score=t.score}function $t(t,e,{includeMatches:r=f.includeMatches,includeScore:n=f.includeScore}={}){const i=[];return r&&i.push(Rt),n&&i.push(Ot),t.map(a=>{const{idx:c}=a,l={item:e[c],refIndex:c};return i.length&&i.forEach(o=>{o(a,l)}),l})}class U{constructor(e,r={},n){this.options={...f,...r},this.options.useExtendedSearch,this._keyStore=new ot(this.options.keys),this.setCollection(e,n)}setCollection(e,r){if(this._docs=e,r&&!(r instanceof pe))throw new Error(it);this._myIndex=r||Se(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){D(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const r=[];for(let n=0,i=this._docs.length;n<i;n+=1){const a=this._docs[n];e(a,n)&&(this.removeAt(n),n-=1,i-=1,r.push(a))}return r}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:r=-1}={}){const{includeMatches:n,includeScore:i,shouldSort:a,sortFn:c,ignoreFieldNorm:l}=this.options;let o=T(e)?T(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return Tt(o,{ignoreFieldNorm:l}),a&&o.sort(c),be(r)&&r>-1&&(o=o.slice(0,r)),$t(o,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(e){const r=fe(e,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:a,i:c,n:l})=>{if(!D(a))return;const{isMatch:o,score:h,indices:d}=r.searchIn(a);o&&i.push({item:a,idx:c,matches:[{score:h,value:a,norm:l,indices:d}]})}),i}_searchLogical(e){const r=_e(e,this.options),n=(l,o,h)=>{if(!l.children){const{keyId:m,searcher:x}=l,g=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(o,m),searcher:x});return g&&g.length?[{idx:h,item:o,matches:g}]:[]}const d=[];for(let m=0,x=l.children.length;m<x;m+=1){const g=l.children[m],A=n(g,o,h);if(A.length)d.push(...A);else if(l.operator===re.AND)return[]}return d},i=this._myIndex.records,a={},c=[];return i.forEach(({$:l,i:o})=>{if(D(l)){let h=n(r,l,o);h.length&&(a[o]||(a[o]={idx:o,item:l,matches:[]},c.push(a[o])),h.forEach(({matches:d})=>{a[o].matches.push(...d)}))}}),c}_searchObjectList(e){const r=fe(e,this.options),{keys:n,records:i}=this._myIndex,a=[];return i.forEach(({$:c,i:l})=>{if(!D(c))return;let o=[];n.forEach((h,d)=>{o.push(...this._findMatches({key:h,value:c[d],searcher:r}))}),o.length&&a.push({idx:l,item:c,matches:o})}),a}_findMatches({key:e,value:r,searcher:n}){if(!D(r))return[];let i=[];if(R(r))r.forEach(({v:a,i:c,n:l})=>{if(!D(a))return;const{isMatch:o,score:h,indices:d}=n.searchIn(a);o&&i.push({score:h,key:e,value:a,idx:c,norm:l,indices:d})});else{const{v:a,n:c}=r,{isMatch:l,score:o,indices:h}=n.searchIn(a);l&&i.push({score:o,key:e,value:a,norm:c,indices:h})}return i}}U.version="7.1.0";U.createIndex=Se;U.parseIndex=At;U.config=f;U.parseQuery=_e;_t(kt);function Pt(t){switch(t){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}function Qt(){const[t]=Ie(),e=Le(),r=Te(),[n,i]=j.useState([]),[a,c]=j.useState([]),[l,o]=j.useState(!0),[h,d]=j.useState(null),[m,x]=j.useState(t.get("status")||"_default"),[g,A]=j.useState(t.get("priority")||"all"),[C,v]=j.useState(t.get("search")||""),[E,_]=j.useState(t.get("sortBy")||"created"),[b,L]=j.useState(t.get("order")||"desc"),[G,H]=j.useState(!1),F=j.useRef(null),k=[m!=="_default",g!=="all",E!=="created",b!=="desc"].filter(Boolean).length,y=j.useCallback(u=>{const p=new URLSearchParams(t);Object.entries(u).forEach(([S,P])=>{P&&P!=="all"&&P!=="_default"&&P!==""?p.set(S,P):p.delete(S)});const w=p.toString(),N=w?`?${w}`:"";e(`${r.pathname}${N}`)},[t,e,r.pathname]),V=j.useCallback(u=>{x(u),y({status:u==="_default"?null:u})},[y]),O=j.useCallback(u=>{A(u),y({priority:u==="all"?null:u})},[y]),I=j.useCallback(u=>{v(u),y({search:u||null})},[y]),ne=j.useCallback(u=>{_(u),y({sortBy:u==="created"?null:u})},[y]),M=j.useCallback(()=>{const u=b==="asc"?"desc":"asc";L(u),y({order:u==="desc"?null:u})},[b,y]),$=j.useCallback(u=>{if(u.key==="s"||u.key==="S"){const p=document.activeElement;p?.tagName==="INPUT"||p?.tagName==="TEXTAREA"||p?.getAttribute("contenteditable")==="true"||(u.preventDefault(),F.current?.focus())}},[]);j.useEffect(()=>(document.addEventListener("keydown",$),()=>{document.removeEventListener("keydown",$)}),[$]);const Q=j.useMemo(()=>{const u={keys:[{name:"title",weight:.4},{name:"intent",weight:.3},{name:"id",weight:.2},{name:"author.name",weight:.05},{name:"metadata.tags",weight:.05}],threshold:.3,includeScore:!0};return new U(n,u)},[n]);return j.useEffect(()=>{async function u(){try{o(!0);const w=await(await fetch(`${Ve}/api/v1/proposals`)).json();w.success?(i(w.data),c(w.data)):d(w.error?.message||"Failed to fetch proposals")}catch(p){d(p instanceof Error?p.message:"Unknown error")}finally{o(!1)}}u()},[]),j.useEffect(()=>{let u=n;if(m==="_default"?u=u.filter(p=>Ue.includes(p.status)):m!=="all"&&(u=u.filter(p=>p.status===m)),g!=="all"&&(u=u.filter(p=>p.metadata.priority===g)),C.trim()){const p=Q.search(C),w=new Set(p.map(N=>N.item.id));u=u.filter(N=>w.has(N.id))}u=u.sort((p,w)=>{let N,S;switch(E){case"created":{N=new Date(p.metadata.createdAt).getTime(),S=new Date(w.metadata.createdAt).getTime();break}case"updated":{N=new Date(p.metadata.updatedAt).getTime(),S=new Date(w.metadata.updatedAt).getTime();break}case"status":{N=p.status,S=w.status;break}case"priority":{const P={critical:4,high:3,medium:2,low:1};N=P[p.metadata.priority]||0,S=P[w.metadata.priority]||0;break}case"intent":{N=(p.title||p.intent||"").toLowerCase(),S=(w.title||w.intent||"").toLowerCase();break}default:N=new Date(p.metadata.createdAt).getTime(),S=new Date(w.metadata.createdAt).getTime()}return b==="asc"?N<S?-1:N>S?1:0:N>S?-1:N<S?1:0}),c(u)},[n,m,g,C,E,b,Q]),l?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),s.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your agents"})]}),s.jsx(z,{asChild:!0,children:s.jsxs(Y,{to:"/proposals/new",children:[s.jsx(Z,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),s.jsx("div",{className:"space-y-4",children:[...Array(3)].map((u,p)=>s.jsx(J,{children:s.jsx(ze,{children:s.jsxs("div",{className:"flex justify-between items-start",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-6 bg-muted rounded w-3/4 animate-pulse"}),s.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]}),s.jsx("div",{className:"h-6 bg-muted rounded w-20 animate-pulse"})]})})},p))})]}):h?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),s.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your agents"})]}),s.jsx(z,{asChild:!0,children:s.jsxs(Y,{to:"/proposals/new",children:[s.jsx(Z,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),s.jsx(J,{children:s.jsx(q,{className:"pt-6",children:s.jsx("div",{className:"text-center",children:s.jsxs("p",{className:"text-destructive",children:["Error: ",h]})})})})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),s.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your agents"})]}),s.jsx(z,{asChild:!0,children:s.jsxs(Y,{to:"/proposals/new",children:[s.jsx(Z,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Qe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),s.jsx(Re,{ref:F,placeholder:"Search tasks...",value:C,onChange:u=>I(u.target.value),className:"pl-9 pr-20 h-11 bg-muted/40 border-muted-foreground/20 focus:bg-background transition-colors"}),s.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-2",children:C?s.jsx("button",{onClick:()=>I(""),className:"h-5 w-5 rounded-full bg-muted-foreground/20 hover:bg-muted-foreground/30 flex items-center justify-center transition-colors",children:s.jsx(X,{className:"h-3 w-3"})}):s.jsx(Oe,{children:s.jsx($e,{children:"S"})})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>H(!G),className:"flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg border border-muted-foreground/20 hover:bg-muted/50 transition-colors",children:[s.jsx(je,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:"Filters & Sort"}),s.jsx("span",{className:"sm:hidden",children:"Filters"}),k>0&&s.jsx("span",{className:"flex items-center justify-center h-5 w-5 text-xs font-bold rounded-full bg-primary text-primary-foreground",children:k}),G?s.jsx(Ye,{className:"h-4 w-4 ml-1"}):s.jsx(Pe,{className:"h-4 w-4 ml-1"})]}),s.jsxs("div",{className:"flex-1 flex items-center gap-2 overflow-x-auto scrollbar-hide",children:[m!=="_default"&&s.jsxs("button",{onClick:()=>V("_default"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors whitespace-nowrap",children:[m==="all"?"All statuses":Ae(m),s.jsx(X,{className:"h-3 w-3"})]}),g!=="all"&&s.jsxs("button",{onClick:()=>O("all"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors whitespace-nowrap",children:[g," priority",s.jsx(X,{className:"h-3 w-3"})]}),(E!=="created"||b!=="desc")&&s.jsxs("button",{onClick:()=>{ne("created"),L("desc"),y({sortBy:null,order:null})},className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-purple-500/15 text-purple-600 dark:text-purple-400 hover:bg-purple-500/25 transition-colors whitespace-nowrap",children:[E," ",b==="asc"?"↑":"↓",s.jsx(X,{className:"h-3 w-3"})]})]}),s.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[a.length," result",a.length!==1?"s":""]})]}),G&&s.jsxs("div",{className:"p-4 rounded-lg border border-muted-foreground/20 bg-muted/30 space-y-4 animate-in slide-in-from-top-2 duration-200",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Status"}),s.jsxs(ie,{value:m,onValueChange:V,children:[s.jsx(ae,{className:"w-full bg-background",children:s.jsx(ce,{placeholder:"Filter by status"})}),s.jsxs(ue,{children:[s.jsx(B,{value:"_default",children:"Active (Default)"}),s.jsx(B,{value:"all",children:"All statuses"}),Ge.map(u=>s.jsx(B,{value:u,children:Ae(u)},u))]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Priority"}),s.jsxs(ie,{value:g,onValueChange:O,children:[s.jsx(ae,{className:"w-full bg-background",children:s.jsx(ce,{placeholder:"Filter by priority"})}),s.jsxs(ue,{children:[s.jsx(B,{value:"all",children:"All priorities"}),s.jsx(B,{value:"low",children:"Low"}),s.jsx(B,{value:"medium",children:"Medium"}),s.jsx(B,{value:"high",children:"High"}),s.jsx(B,{value:"critical",children:"Critical"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Sort By"}),s.jsxs(ie,{value:E,onValueChange:u=>ne(u),children:[s.jsx(ae,{className:"w-full bg-background",children:s.jsx(ce,{})}),s.jsxs(ue,{children:[s.jsx(B,{value:"created",children:"Created Date"}),s.jsx(B,{value:"updated",children:"Updated Date"}),s.jsx(B,{value:"status",children:"Status"}),s.jsx(B,{value:"priority",children:"Priority"}),s.jsx(B,{value:"intent",children:"Title"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Order"}),s.jsx(z,{variant:"outline",onClick:M,className:"w-full justify-between bg-background",children:b==="asc"?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"Ascending"}),s.jsx(qe,{className:"h-4 w-4"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"Descending"}),s.jsx(Je,{className:"h-4 w-4"})]})})]})]}),k>0&&s.jsx("div",{className:"pt-2 border-t border-muted-foreground/10",children:s.jsxs(z,{variant:"ghost",size:"sm",onClick:()=>{V("_default"),O("all"),I("")},className:"text-muted-foreground hover:text-foreground",children:[s.jsx(X,{className:"h-3 w-3 mr-1"}),"Reset all filters"]})})]})]}),a.length===0&&n.length>0?s.jsx(J,{children:s.jsx(q,{className:"pt-6",children:s.jsxs("div",{className:"text-center py-6",children:[s.jsx(je,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),s.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No proposals match your filters"}),s.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try adjusting your status or priority filters."}),s.jsx(z,{variant:"outline",className:"mt-4",onClick:()=>{V("_default"),O("all"),I("")},children:"Clear Filters"})]})})}):n.length===0?s.jsx(J,{children:s.jsx(q,{className:"pt-6",children:s.jsxs("div",{className:"text-center py-6",children:[s.jsx(Ke,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),s.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No proposals yet"}),s.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first change proposal to get started."}),s.jsx(z,{asChild:!0,className:"mt-4",children:s.jsxs(Y,{to:"/proposals/new",children:[s.jsx(Z,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})}):s.jsx("div",{className:"space-y-4",children:a.map(u=>s.jsx(Y,{to:`/proposals/${u.id}`,className:"block",children:s.jsx(J,{className:"hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:s.jsx(q,{className:"py-4",children:s.jsx("div",{className:"flex justify-between items-start gap-4",children:s.jsxs("div",{className:"flex-1 space-y-2",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsx(We,{className:"text-base leading-tight",children:u.title||u.intent}),s.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[u.metadata.priority&&s.jsx(ee,{variant:Pt(u.metadata.priority),className:"text-xs",children:u.metadata.priority}),s.jsx(ee,{variant:He(u.status),className:"text-xs",children:u.status})]})]}),u.content&&s.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[u.content.split(`
17
- `).slice(0,2).join(" ").substring(0,150),u.content.length>150?"...":""]}),s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{className:"text-xs text-muted-foreground",children:[u.id," • by ",u.author.name," • ",new Date(u.metadata.createdAt).toLocaleDateString()]}),s.jsxs("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[u.planSteps.length>0&&s.jsxs("span",{children:[u.planSteps.length," step",u.planSteps.length!==1?"s":""]}),u.evidence.length>0&&s.jsxs("span",{children:[u.evidence.length," evidence"]}),u.metadata.tags&&u.metadata.tags.length>0&&s.jsxs("span",{children:[u.metadata.tags.length," tag",u.metadata.tags.length!==1?"s":""]})]})]}),u.metadata.tags&&u.metadata.tags.length>0&&s.jsxs("div",{className:"flex gap-1 mt-2",children:[u.metadata.tags.slice(0,3).map(p=>s.jsx(ee,{variant:"outline",className:"text-xs",children:p},p)),u.metadata.tags.length>3&&s.jsxs(ee,{variant:"outline",className:"text-xs",children:["+",u.metadata.tags.length-3]})]})]})})})})},u.id))})]})}export{Qt as default};
@@ -1 +0,0 @@
1
- import{E as X,u as q,a as Q,r as a,A as f,j as e,B as i,ah as Z,ai as z,n as ee,F as P,X as se,at as te,au as ae,av as ie,aw as re}from"./index-9Tv-j_Ga.js";import{B as ne}from"./badge-AwLOflf5.js";import{c as A}from"./clipboard-B9ndUJKl.js";import{A as M}from"./arrow-left-WGBYWq3h.js";import{L as le,H as oe,I as ce,V as de,M as W,F as me,a as $}from"./video-DYA2WfbA.js";import{D as B}from"./download-Cv2G2Eg9.js";import{T as ue}from"./tag-DrQkepeD.js";function ve(){const{id:u}=X(),k=q(),{toast:o}=Q(),[s,p]=a.useState(null),[R,b]=a.useState(!0),[C,x]=a.useState(null),[r,j]=a.useState(null),[h,L]=a.useState(!1),[g,c]=a.useState(!1),[I,F]=a.useState(!1);a.useEffect(()=>{u&&(b(!0),x(null),fetch(`${f}/api/v1/resources/${u}`).then(t=>{if(!t.ok)throw new Error(`Resource not found (${t.status})`);if(t.headers.get("content-type")?.includes("application/json"))return t.json();throw new Error("NEED_METADATA")}).then(t=>{if(t.success&&t.data)p(t.data);else if(t.id)p(t);else throw new Error("Invalid response")}).catch(async t=>{if(t.message==="NEED_METADATA")try{const d=await(await fetch(`${f}/api/v1/resources`)).json();if(d.success&&d.data){const m=d.data.find(Y=>Y.id===u);if(m){p(m);return}}x("Resource not found")}catch{x("Failed to load resource")}else x(t.message||"Failed to load resource")}).finally(()=>b(!1)))},[u]);const n=s?`${f}/api/v1/resources/${s.id}`:"",E=s?.type.startsWith("image/")??!1,T=s?s.type==="image/svg+xml"||s.name.toLowerCase().endsWith(".svg"):!1,U=s?s.type==="application/pdf"||s.name.toLowerCase().endsWith(".pdf"):!1,G=s?.type.startsWith("video/")??!1,V=s?.type.startsWith("audio/")??!1,w=s?s.type.startsWith("text/")||s.type==="application/json"||s.type.includes("javascript")||s.type.includes("typescript")||s.type.includes("xml")||s.name.toLowerCase().match(/\.(txt|md|json|js|ts|jsx|tsx|css|html|xml|yaml|yml|log|sh|bash|zsh|fish)$/)!==null:!1,v=s?s.name.toLowerCase().endsWith(".md")||s.name.toLowerCase().endsWith(".markdown"):!1,N=s?s.type==="application/json"||s.name.toLowerCase().endsWith(".json"):!1,y=s?s.type==="text/html"||s.name.toLowerCase().endsWith(".html"):!1;a.useEffect(()=>{s&&(w||v||N||y)?(L(!0),fetch(n).then(t=>{if(t.ok)return t.text();throw new Error("Failed to load file")}).then(t=>j(t)).catch(t=>{console.error("Failed to load text content:",t),j(null)}).finally(()=>L(!1))):j(null)},[s?.id,w,v,N,y,n]),a.useEffect(()=>{const t=l=>{l.key==="Escape"&&g&&c(!1)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[g]);const _=t=>{if(t===0)return"0 B";const l=1024,d=["B","KB","MB","GB"],m=Math.floor(Math.log(t)/Math.log(l));return parseFloat((t/Math.pow(l,m)).toFixed(2))+" "+d[m]},H=t=>new Date(t).toLocaleString(),S=t=>t.startsWith("image/")?e.jsx(ce,{className:"h-6 w-6"}):t.startsWith("video/")?e.jsx(de,{className:"h-6 w-6"}):t.startsWith("audio/")?e.jsx(W,{className:"h-6 w-6"}):t.includes("text")||t.includes("document")||t.includes("code")?e.jsx(P,{className:"h-6 w-6"}):t.includes("json")||t.includes("javascript")||t.includes("typescript")?e.jsx(me,{className:"h-6 w-6"}):e.jsx(te,{className:"h-6 w-6"}),D=()=>{s&&window.open(`${f}/api/v1/resources/${s.id}?download=true`)},J=async()=>{if(s)try{const t=`.nut/resources/files/${s.path}`;await A(t),o({title:"Path copied!",description:`Copied ${t} to clipboard`})}catch{o({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},O=async()=>{if(s)try{const t=`${window.location.origin}/resources/${s.id}`;await A(t),F(!0),o({title:"Link copied!",description:"Share link copied to clipboard"}),setTimeout(()=>F(!1),2e3)}catch{o({title:"Failed to copy",description:"Unable to copy link to clipboard",variant:"destructive"})}},K=()=>{if(!s)return null;if(T)return e.jsxs(e.Fragment,{children:[e.jsx("img",{src:n,alt:s.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(i,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>c(!0),children:e.jsx($,{className:"h-4 w-4"})})]});if(U)return e.jsx("iframe",{src:n,className:"w-full h-full min-h-[600px] rounded-lg border",title:s.name});if(G)return e.jsx("video",{src:n,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg",children:"Your browser does not support the video tag."});if(V)return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(W,{className:"h-24 w-24 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-6 bg-muted/30 flex justify-center",children:e.jsx("audio",{src:n,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]});if(v&&r!==null)return h?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6 prose prose-sm dark:prose-invert max-w-none",children:e.jsx(ae,{remarkPlugins:[re],rehypePlugins:[ie],children:r})});if(y&&r!==null)return h?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("iframe",{srcDoc:r,className:"w-full h-full min-h-[600px] rounded-lg border",title:s.name,sandbox:"allow-same-origin"});if(N&&r!==null){if(h)return e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})});let t=r;try{const l=JSON.parse(r);t=JSON.stringify(l,null,2)}catch{}return e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto",children:e.jsx("code",{children:t})})})}return w&&r!==null?h?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto whitespace-pre-wrap",children:e.jsx("code",{children:r})})}):E?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:n,alt:s.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(i,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>c(!0),children:e.jsx($,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[S(s.type),e.jsx("p",{className:"text-sm",children:"Preview not available for this file type"}),e.jsxs(i,{variant:"outline",onClick:D,children:[e.jsx(B,{className:"mr-2 h-4 w-4"}),"Download to view"]})]})};return R?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading resource..."})}):C||!s?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:C||"Resource not found"}),e.jsxs(i,{variant:"outline",onClick:()=>k("/resources"),children:[e.jsx(M,{className:"mr-2 h-4 w-4"}),"Back to Resources"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"px-6 py-4 flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>k("/resources"),title:"Back to Resources",children:e.jsx(M,{className:"h-4 w-4"})}),S(s.type),e.jsxs("div",{className:"min-w-0 flex items-baseline gap-3",children:[e.jsx("h1",{className:"text-xl font-semibold truncate",children:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground flex-shrink-0",children:s.type})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:O,title:"Copy share link",children:I?e.jsx(Z,{className:"h-4 w-4"}):e.jsx(le,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:J,title:"Copy path to clipboard",children:e.jsx(z,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:D,title:"Download",children:e.jsx(B,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 relative flex items-center justify-center bg-muted/30 p-6 overflow-hidden border rounded-lg",children:K()}),e.jsx("div",{className:"p-6 flex-shrink-0 bg-background",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-x-6 gap-y-2 md:grid-cols-2 text-sm",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsx("span",{children:_(s.size)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Uploaded:"}),e.jsx("span",{children:H(s.uploadedAt)})]})]}),e.jsx("div",{className:"space-y-2",children:s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map(t=>e.jsx(ne,{variant:"secondary",className:"text-xs",children:t},t))})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.metadata.description?e.jsxs(e.Fragment,{children:[e.jsx(P,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Description:"}),e.jsx("span",{className:"truncate flex-1",title:s.metadata.description,children:s.metadata.description})]}):e.jsx("div",{className:"flex-1"}),s.metadata.generationPrompt&&e.jsxs(i,{size:"sm",className:"h-6 text-xs px-2 flex-shrink-0",onClick:()=>{navigator.clipboard.writeText(s.metadata.generationPrompt||""),o({title:"Prompt copied!",description:"Generation prompt copied to clipboard"})},children:[e.jsx(z,{className:"h-2.5 w-2.5 mr-1"}),"Copy Prompt"]})]})]})})]}),g&&(E||T)&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black/95 flex items-center justify-center",onClick:()=>c(!1),children:[e.jsx(i,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 h-10 w-10 text-white hover:bg-white/20",onClick:()=>c(!1),children:e.jsx(se,{className:"h-6 w-6"})}),e.jsx("img",{src:n,alt:s.name,className:"max-w-[95vw] max-h-[95vh] object-contain",onClick:t=>t.stopPropagation()})]})]})}export{ve as default};
@@ -1,13 +0,0 @@
1
- import{u as j,a as v,r as n,A as d,j as e,B as h,L as g,a3 as y}from"./index-9Tv-j_Ga.js";import{C as m,a as x,b as N,c as C}from"./card-SN5gKnu7.js";import{M as w}from"./markdown-editor-ls1JPK_e.js";import{A as S}from"./arrow-left-WGBYWq3h.js";import{C as b}from"./circle-check-big-nY4PntB5.js";function B(){const u=j(),{toast:t}=v(),[i,a]=n.useState(""),[f,r]=n.useState(!0),[o,l]=n.useState(!1);n.useEffect(()=>{fetch(`${d}/api/v1/context/role`).then(s=>s.json()).then(s=>{s.success&&a(s.document.content.trim()),r(!1)}).catch(s=>{console.error("Failed to load context:",s),t({title:"Error",description:"Failed to load role definition",variant:"destructive"}),r(!1)})},[t]);const p=async()=>{l(!0);try{const c=await(await fetch(`${d}/api/v1/context/role`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,metadata:{}})})).json();if(c.success)t({title:"Success",description:"Role definition saved successfully",action:e.jsx(b,{className:"h-4 w-4"})}),u("/context/role");else throw new Error(c.error||"Failed to save context")}catch(s){console.error("Save error:",s),t({title:"Error",description:"Failed to save role definition",variant:"destructive"})}finally{l(!1)}};return f?e.jsx("div",{className:"space-y-6",children:e.jsx(m,{children:e.jsx(x,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Role Definition"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Define your role, responsibilities, and guidelines"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(g,{to:"/context/role",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"w-4 h-4"})})}),e.jsxs(h,{onClick:p,disabled:o,size:"sm",children:[e.jsx(y,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:o?"Saving...":"Save"})]})]})]}),e.jsxs(m,{children:[e.jsx(N,{children:e.jsx(C,{children:"Role Documentation"})}),e.jsx(x,{children:e.jsx(w,{value:i,onChange:s=>a(s||""),placeholder:`Write your role definition in markdown...
2
-
3
- ## Your Role
4
-
5
- Describe your role and primary responsibilities.
6
-
7
- ## Guidelines
8
-
9
- Key guidelines and principles to follow.
10
-
11
- ## Constraints
12
-
13
- Any constraints or boundaries to be aware of.`,height:800})})]})]})}export{B as default};