@lovelybunch/api 1.0.75-alpha.8 → 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.
- package/dist/lib/jobs/job-runner.js +10 -2
- package/dist/lib/jobs/job-scheduler.js +21 -0
- package/dist/lib/mail/mail-runner.d.ts +51 -0
- package/dist/lib/mail/mail-runner.js +342 -0
- package/dist/lib/slack/slack-service.d.ts +2 -0
- package/dist/lib/slack/slack-service.js +3 -0
- package/dist/lib/storage/file-storage.d.ts +16 -16
- package/dist/lib/storage/file-storage.js +59 -64
- package/dist/lib/terminal/terminal-manager.d.ts +3 -5
- package/dist/lib/terminal/terminal-manager.js +10 -61
- package/dist/routes/api/v1/ai/route.js +361 -20
- package/dist/routes/api/v1/chats/[id]/index.js +2 -1
- package/dist/routes/api/v1/chats/[id]/route.d.ts +7 -0
- package/dist/routes/api/v1/chats/[id]/route.js +30 -1
- package/dist/routes/api/v1/context/index.js +0 -2
- package/dist/routes/api/v1/git/index.js +23 -0
- package/dist/routes/api/v1/knowledge/[filename]/index.d.ts +1 -0
- package/dist/routes/api/v1/knowledge/[filename]/index.js +1 -0
- package/dist/routes/api/v1/knowledge/[filename]/route.d.ts +3 -0
- package/dist/routes/api/v1/knowledge/[filename]/route.js +254 -0
- package/dist/routes/api/v1/knowledge/index.d.ts +1 -0
- package/dist/routes/api/v1/knowledge/index.js +1 -0
- package/dist/routes/api/v1/knowledge/route.d.ts +3 -0
- package/dist/routes/api/v1/knowledge/route.js +176 -0
- package/dist/routes/api/v1/mail/index.d.ts +3 -0
- package/dist/routes/api/v1/mail/index.js +23 -0
- package/dist/routes/api/v1/mail/route.d.ts +294 -0
- package/dist/routes/api/v1/mail/route.js +344 -0
- package/dist/routes/api/v1/mcp/index.js +109 -34
- package/dist/routes/api/v1/slack/index.d.ts +3 -0
- package/dist/routes/api/v1/slack/index.js +15 -0
- package/dist/routes/api/v1/slack/route.d.ts +124 -0
- package/dist/routes/api/v1/slack/route.js +192 -0
- package/dist/routes/api/v1/tasks/[id]/route.d.ts +117 -0
- package/dist/routes/api/v1/tasks/[id]/route.js +166 -0
- package/dist/routes/api/v1/tasks/index.d.ts +3 -0
- package/dist/routes/api/v1/tasks/index.js +10 -0
- package/dist/routes/api/v1/tasks/route.d.ts +96 -0
- package/dist/routes/api/v1/tasks/route.js +136 -0
- package/dist/routes/api/v1/terminal/[proposalId]/create/route.js +2 -2
- package/dist/routes/api/v1/terminal/[taskId]/create/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[taskId]/create/index.js +5 -0
- package/dist/routes/api/v1/terminal/[taskId]/create/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[taskId]/create/route.js +27 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/index.js +5 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/route.js +21 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/index.js +5 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/route.js +21 -0
- package/dist/routes/api/v1/terminal/sessions/route.js +4 -4
- package/dist/server-with-static.js +14 -8
- package/dist/server.js +14 -8
- package/package.json +4 -4
- package/static/assets/{ActivityPage-DSSML9J-.js → ActivityPage-k4I7Q53O.js} +1 -1
- package/static/assets/ApiKeysSettingsPage-B1YvVdmg.js +2 -0
- package/static/assets/{ArchitectureEditPage-CIjqkpMz.js → ArchitectureEditPage-CpowsIx2.js} +1 -1
- package/static/assets/{ArchitecturePage-Db__w054.js → ArchitecturePage-DYxC_aMR.js} +1 -1
- package/static/assets/{AuthSettingsPage-Bpooi8Z0.js → AuthSettingsPage-DtSo78Y_.js} +2 -2
- package/static/assets/{CallbackPage-BGLKeyjv.js → CallbackPage-bROCGapx.js} +1 -1
- package/static/assets/CodePage-CPCj64rX.js +2 -0
- package/static/assets/{CollapsibleSection-B6RO5o5R.js → CollapsibleSection-M5cXbl92.js} +1 -1
- package/static/assets/DashboardPage-B9BZZfw6.js +51 -0
- package/static/assets/{GitPage-DxjLaRWe.js → GitPage-BiDtdSK1.js} +2 -2
- package/static/assets/GitSettingsPage-THm6wDjs.js +6 -0
- package/static/assets/IdentityPage-BC16skg6.js +6 -0
- package/static/assets/{ImplementationStepsEditor-DWjDyZzP.js → ImplementationStepsEditor-HliLQav5.js} +2 -2
- package/static/assets/IntegrationsSettingsPage-CC_VKIQa.js +1 -0
- package/static/assets/JobDetailPage-z1QQYvmU.js +1 -0
- package/static/assets/KnowledgeDetailPage-DzHXBS7Q.js +1 -0
- package/static/assets/KnowledgeEditPage-BwGnUH_m.js +1 -0
- package/static/assets/KnowledgePage-CGIVMS02.js +3 -0
- package/static/assets/{LoginPage-DptfKsWo.js → LoginPage-VQ3lcfLV.js} +1 -1
- package/static/assets/MailInboxPage-DiZKqwdU.js +1 -0
- package/static/assets/MailProcessingModal-DIeSQBoR.js +6 -0
- package/static/assets/MailReadPage-C8AACmZQ.js +1 -0
- package/static/assets/MailSentPage-C_5yFly_.js +1 -0
- package/static/assets/McpSettingsPage-i9YHcu1s.js +1 -0
- package/static/assets/NewKnowledgePage-BnVY7WUD.js +9 -0
- package/static/assets/{NewSkillPage-Cwy2MSr9.js → NewSkillPage-DwniHD6D.js} +1 -1
- package/static/assets/NewTaskPage-F5UX2WMc.js +90 -0
- package/static/assets/NotFoundPage-BbSZX_4L.js +6 -0
- package/static/assets/NotificationsSettingsPage-C8kjcift.js +1 -0
- package/static/assets/ProjectEditPage-DUUlIEqI.js +11 -0
- package/static/assets/{ProjectPage-DgUr4bVU.js → ProjectPage-Unz9PQpA.js} +1 -1
- package/static/assets/PromptsSettingsPage-DVpIuRKI.js +1 -0
- package/static/assets/ResourceDetailPage-DqHZ2KYD.js +1 -0
- package/static/assets/ResourcesPage-BP5tuAi-.js +41 -0
- package/static/assets/RoleEditPage-BgKu8S0-.js +13 -0
- package/static/assets/{RolePage-Sc-GFiL2.js → RolePage-Fed52Ov5.js} +1 -1
- package/static/assets/{RulesSettingsPage-DdMCzh9j.js → RulesSettingsPage-BQ2O0u66.js} +2 -2
- package/static/assets/SchedulePage-jkxjuzBx.js +4 -0
- package/static/assets/SkillDetailPage-k3Q2-NFd.js +1 -0
- package/static/assets/{SkillEditPage-BDd2CtAS.js → SkillEditPage-urF4snjo.js} +1 -1
- package/static/assets/SkillsPage-DlWDhEjR.js +8 -0
- package/static/assets/{SkillsSettingsPage-1N0JQOYc.js → SkillsSettingsPage-BViFgckG.js} +1 -1
- package/static/assets/SourceInput-CAFKTHw-.js +1 -0
- package/static/assets/{TagInput-D_SdcypZ.js → TagInput-C6lI-ePr.js} +1 -1
- package/static/assets/TaskDetailPage-DpbRHnW_.js +16 -0
- package/static/assets/TaskEditPage-DssRbW0h.js +1 -0
- package/static/assets/TasksPage-CD_eo0Bj.js +17 -0
- package/static/assets/TerminalPage-BG_wlccr.js +1 -0
- package/static/assets/TerminalSessionPage-CsK-LznK.js +8 -0
- package/static/assets/UserPreferencesPage-CWUq3efu.js +1 -0
- package/static/assets/UserSettingsPage-CduI_MGS.js +1 -0
- package/static/assets/UtilitiesPage-BAxokhLh.js +1 -0
- package/static/assets/{alert-BD5jo3SI.js → alert-BXsc6_qu.js} +1 -1
- package/static/assets/{arrow-down-BxcoVp6S.js → arrow-down-DmW_3gE8.js} +1 -1
- package/static/assets/{arrow-left-CdM_IPng.js → arrow-left-1S-835kP.js} +1 -1
- package/static/assets/{arrow-up-BOJ6ob9X.js → arrow-up-BYism_o1.js} +1 -1
- package/static/assets/arrow-up-down-Dw3J0a4i.js +6 -0
- package/static/assets/{badge-DEiQk9C9.js → badge-BUEY53dV.js} +1 -1
- package/static/assets/{browser-modal-Dp1eMxt6.js → browser-modal-DCNdI4NT.js} +2 -2
- package/static/assets/{card-BCFxXzRk.js → card-BcPlIAH5.js} +1 -1
- package/static/assets/{chevron-left-C25izNzZ.js → chevron-left-FMmNe7yP.js} +1 -1
- package/static/assets/{plus-iamYJu5V.js → chevron-up-CqM3won3.js} +2 -2
- package/static/assets/{chevrons-up-DqbWMOjv.js → chevrons-up-DTvCkIHc.js} +1 -1
- package/static/assets/{circle-alert-CMRMPnbY.js → circle-alert-dseM-Ib7.js} +1 -1
- package/static/assets/{circle-check-big-NI18oHuP.js → circle-check-big-jKg34xC-.js} +1 -1
- package/static/assets/{circle-check-D5wZZPvj.js → circle-check-eyo6pBP1.js} +1 -1
- package/static/assets/{circle-play-BhVU869u.js → circle-play-BrY_lNiH.js} +1 -1
- package/static/assets/{circle-x-BXDB-G_q.js → circle-x-uqmzEce1.js} +1 -1
- package/static/assets/{clipboard-DC2xmNVx.js → clipboard-tzPFoieb.js} +1 -1
- package/static/assets/{clock-CeCp7Pz1.js → clock-Bjc06QBM.js} +1 -1
- package/static/assets/code-DrYqPukx.js +6 -0
- package/static/assets/{download-ZF_XbTIA.js → download-Bg__QCLT.js} +1 -1
- package/static/assets/{external-link-CYBz87-P.js → external-link-CNDy2UUo.js} +1 -1
- package/static/assets/{eye-BT8MAvKY.js → eye-DLFBnC8t.js} +1 -1
- package/static/assets/{folder-git-2-BE9AIPnj.js → folder-git-2-DUqd0WRi.js} +1 -1
- package/static/assets/index-CHdBxVyk.css +2 -0
- package/static/assets/index-DFcWlnzl.js +487 -0
- package/static/assets/{info-DunFSp-x.js → info-D6jxZC5X.js} +1 -1
- package/static/assets/kiro-CX1mOsRO.js +17 -0
- package/static/assets/{label-vYhfrPMD.js → label-DBuh-ke5.js} +1 -1
- package/static/assets/{markdown-editor-BzZ8tCto.js → markdown-editor-B4YNQFT2.js} +1 -1
- package/static/assets/message-square-B5RWz_ff.js +6 -0
- package/static/assets/paperclip-4A_3MaPx.js +6 -0
- package/static/assets/{pause-BHonpdnw.js → pause-BzhKXHtR.js} +1 -1
- package/static/assets/{play-CCo7tau2.js → play-CHIf-Rcz.js} +1 -1
- package/static/assets/{radio-group-Db-pBuyW.js → radio-group-C1ct-VsJ.js} +1 -1
- package/static/assets/{refresh-cw-Bg7vQzOw.js → refresh-cw-B3OwrDUf.js} +1 -1
- package/static/assets/{search-CH2zaibZ.js → search-Cq1ksEdp.js} +1 -1
- package/static/assets/select-44mcS2_G.js +1 -0
- package/static/assets/{status-utils-BDOyevaX.js → status-utils-CDkPeVfP.js} +1 -1
- package/static/assets/{switch-CH-VOgPo.js → switch-CIwjYvCt.js} +1 -1
- package/static/assets/{tabs-XeRAjZYR.js → tabs-DTV6Su-h.js} +1 -1
- package/static/assets/{tag-CRP5nL5-.js → tag-p6yeowCW.js} +1 -1
- package/static/assets/{terminal-preview-DMJMuORo.js → terminal-preview-DN38x9Jm.js} +1 -1
- package/static/assets/use-terminal-BXJqOeJe.js +1 -0
- package/static/assets/video-BH5ChaoS.js +36 -0
- package/static/index.html +2 -2
- package/static/assets/ApiKeysSettingsPage-Chw9PNL5.js +0 -2
- package/static/assets/CodePage-CrokcH-S.js +0 -2
- package/static/assets/DashboardPage-BaSQQ8Nv.js +0 -41
- package/static/assets/GitSettingsPage-tKBXYAFm.js +0 -6
- package/static/assets/IdentityPage-D2yBjeYn.js +0 -11
- package/static/assets/IntegrationsSettingsPage-Bx8-0Ig4.js +0 -1
- package/static/assets/JobDetailPage-BQmTHled.js +0 -1
- package/static/assets/KnowledgeDetailPage-QMU2bC3L.js +0 -1
- package/static/assets/KnowledgeEditPage-DbMJVcLc.js +0 -1
- package/static/assets/KnowledgePage-aU1GxZSZ.js +0 -8
- package/static/assets/McpSettingsPage-C3WxFwRB.js +0 -1
- package/static/assets/NewKnowledgePage-Cbiswrw_.js +0 -9
- package/static/assets/NewProposalPage-B_sDMBTK.js +0 -90
- package/static/assets/ProjectEditPage-BznWiBBc.js +0 -11
- package/static/assets/PromptsSettingsPage-CY0-870a.js +0 -1
- package/static/assets/ProposalDetailPage-K4iMXHEg.js +0 -1
- package/static/assets/ProposalEditPage-jZOtCMqP.js +0 -1
- package/static/assets/ProposalsPage-C7n4-G05.js +0 -17
- package/static/assets/ResourcesPage-vB5-XkUv.js +0 -71
- package/static/assets/RoleEditPage-Cu7ZB3yj.js +0 -13
- package/static/assets/SchedulePage-Bkkf2wA0.js +0 -4
- package/static/assets/SkillDetailPage-5sDxf3Of.js +0 -1
- package/static/assets/SkillsPage-D2G7EfK8.js +0 -8
- package/static/assets/SourceInput-DlC0zwva.js +0 -1
- package/static/assets/TerminalPage--KZ7azvP.js +0 -1
- package/static/assets/TerminalSessionPage-ClvxK9ia.js +0 -13
- package/static/assets/UserPreferencesPage-CheOH7jZ.js +0 -1
- package/static/assets/UserSettingsPage-C8STDvfQ.js +0 -1
- package/static/assets/UtilitiesPage-9rTxR2md.js +0 -1
- package/static/assets/calendar-Cx5r9R7A.js +0 -6
- package/static/assets/droid-DqWsM2dp.js +0 -17
- package/static/assets/index-DVTgTsDa.css +0 -2
- package/static/assets/index-hqVgTgRB.js +0 -462
- package/static/assets/use-terminal-DuGZuvd2.js +0 -1
- package/static/assets/zap-BlzMp7dY.js +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{x as Q,u as V,a as W,r as i,j as e,B as u,L as v,k as X,I as B,o as Y,ab as Z,A as y}from"./index-DFcWlnzl.js";import{C as N,a as C,b as O,c as ee}from"./card-BcPlIAH5.js";import{L as l}from"./label-DBuh-ke5.js";import{B as se}from"./badge-BUEY53dV.js";import{c as te}from"./clipboard-B9ndUJKl.js";import{A as D}from"./arrow-left-1S-835kP.js";import{C as re,a as ae}from"./clipboard-tzPFoieb.js";function me(){const{id:n}=Q(),q=V(),{toast:S}=W(),[U,k]=i.useState(!0),[o,w]=i.useState(!1),[d,c]=i.useState(null),[f,E]=i.useState(""),[x,P]=i.useState(""),[m,M]=i.useState("blue"),[h,F]=i.useState([]),[p,L]=i.useState(""),[$,g]=i.useState([]),[z,A]=i.useState(!0),[R,I]=i.useState(!1),_=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],H={blue:{bg:"#3b82f6",border:"#1e40af",text:"#ffffff"},green:{bg:"#22c55e",border:"#15803d",text:"#ffffff"},red:{bg:"#ef4444",border:"#b91c1c",text:"#ffffff"},emerald:{bg:"#10b981",border:"#047857",text:"#ffffff"},purple:{bg:"#a855f7",border:"#7e22ce",text:"#ffffff"},orange:{bg:"#f97316",border:"#c2410c",text:"#ffffff"},yellow:{bg:"#eab308",border:"#a16207",text:"#ffffff"},teal:{bg:"#14b8a6",border:"#0f766e",text:"#ffffff"},indigo:{bg:"#6366f1",border:"#4338ca",text:"#ffffff"},pink:{bg:"#ec4899",border:"#be185d",text:"#ffffff"},cyan:{bg:"#06b6d4",border:"#0e7490",text:"#ffffff"},slate:{bg:"#64748b",border:"#475569",text:"#ffffff"},gray:{bg:"#6b7280",border:"#4b5563",text:"#ffffff"}};i.useEffect(()=>{async function s(){try{k(!0);const r=await(await fetch(`${y}/api/v1/skills/${n}`)).json();if(!r.success)throw new Error(r.error||"Failed to load skill");const t=r.document;E(t.name||""),P(t.description||""),M(t.metadata?.color||"blue"),L(t.content||""),F(Array.isArray(t.metadata?.mcpServers)?t.metadata.mcpServers:[])}catch(a){const r=a instanceof Error?a.message:"Failed to load skill";c(r)}finally{k(!1)}}n&&s()},[n]),i.useEffect(()=>{let s=!0;return(async()=>{A(!0);try{const r=await fetch(`${y}/api/v1/mcp`);if(!r.ok)throw new Error("Failed to fetch MCP servers");const t=await r.json();if(!t?.success||!Array.isArray(t.servers)){s&&g([]);return}const b=t.mcpServers&&typeof t.mcpServers=="object"?t.mcpServers:{},K=t.servers.map(T=>{const j=b[T]??{};return{name:T,enabled:j?.enabled!==!1,description:typeof j?.description=="string"?j.description:void 0}});s&&g(K)}catch(r){console.error("Failed to load MCP servers",r),s&&g([])}finally{s&&A(!1)}})(),()=>{s=!1}},[]);const J=async()=>{const s=".nut/config.json";try{await te(s),I(!0),S({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>I(!1),2e3)}catch(a){console.error("Failed to copy config path:",a),S({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},G=async s=>{if(s.preventDefault(),!f.trim()||!x.trim()||!p.trim()){c("Name, description, and skill instructions are required");return}try{w(!0),c(null);const a={name:f.trim(),description:x.trim(),content:p.trim(),metadata:{color:m,mcpServers:h.length?h:void 0}},t=await(await fetch(`${y}/api/v1/skills/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();if(!t.success)throw new Error(t.error||"Failed to update skill");const b=t.document?.id||n;q(`/skills/${b}`)}catch(a){const r=a instanceof Error?a.message:"Failed to update skill";c(r)}finally{w(!1)}};return U?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:"Loading skill..."})})}):d&&!f?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Skill"}),e.jsx("p",{className:"text-muted-foreground",children:"Unable to load skill"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})})]}),e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:e.jsx("div",{className:"text-destructive",children:d})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Skill"}),e.jsxs("p",{className:"text-muted-foreground",children:["Skill ID: ",n]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,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(N,{children:[e.jsx(O,{children:e.jsxs(ee,{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-5 w-5"}),"Skill Configuration"]})}),e.jsx(C,{children:e.jsxs("form",{onSubmit:G,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",children:"Name *"}),e.jsx(B,{id:"name",value:f,onChange:s=>E(s.target.value),disabled:o})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Description *"}),e.jsx(B,{id:"description",value:x,onChange:s=>P(s.target.value),disabled:o})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(s=>{const a=H[s];return e.jsx("button",{type:"button",onClick:()=>M(s),disabled:o,className:`w-10 h-10 rounded-md border-2 transition-all ${m===s?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:a.bg,borderColor:m===s?a.border:"hsl(var(--border))",...m===s&&{"--tw-ring-color":a.border}},title:s,children:e.jsx("span",{className:"sr-only",children:s})},s)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"content",children:"Skill Instructions *"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["System prompt or instructions for this skill's behavior."," ","Insert ",e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:".nut/config.json"})," ",e.jsx("button",{type:"button",onClick:J,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:R?e.jsx(re,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(ae,{className:"h-3.5 w-3.5 ml-0.5"})})," ","if you want the skill to be able to access its name, role, or email address."]}),e.jsx(Y,{id:"content",value:p,onChange:s=>L(s.target.value),rows:8,disabled:o,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"MCP Servers (Optional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which MCP servers this skill requires. Leave empty to inherit all available servers."}),e.jsx("div",{className:"space-y-2",children:z?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers..."}):$.length===0?e.jsx("div",{className:"text-sm text-muted-foreground border border-dashed rounded-md p-3",children:"No MCP servers configured yet. Configure servers in Settings → MCP."}):$.map(s=>e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-transparent bg-muted/30 px-3 py-2 hover:border-muted transition-colors",children:[e.jsx(Z,{checked:h.includes(s.name),onCheckedChange:a=>{F(r=>a===!0?r.includes(s.name)?r:[...r,s.name]:r.filter(t=>t!==s.name))},disabled:o||!s.enabled}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s.name,!s.enabled&&e.jsx(se,{variant:"secondary",className:"ml-2 text-xs",children:"Disabled"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.enabled?s.description||"Enabled MCP server":"Enable this server in Settings to use it"})]})]},s.name))})]}),d&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:d}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(u,{type:"button",variant:"outline",asChild:!0,disabled:o,children:e.jsx(v,{to:`/skills/${n}`,children:"Cancel"})}),e.jsx(u,{type:"submit",disabled:o,children:o?"Saving...":"Save Changes"})]})]})})]})]})}export{me as default};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{c as M,j as e,S as z,_,r as f,a as $,A as R,t as O,B as j,L as y,P as E,k as F,ae as B,af as U}from"./index-DFcWlnzl.js";import{C as N,a as w,b as D,c as K}from"./card-BcPlIAH5.js";import{c as V}from"./clipboard-B9ndUJKl.js";import{R as H,L}from"./browser-modal-DCNdI4NT.js";import{R as P,f as Y}from"./registry-ANRa5WBi.js";import{B as v}from"./badge-BUEY53dV.js";import"./search-Cq1ksEdp.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 q=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],G=M("package",q),J=["color","tools","createdAt","updatedAt","version","focusAreas","contextPreferences","tags"];function k(s){if(s){if(Array.isArray(s)){const i=s.map(a=>{if(typeof a=="string")return a.trim();if(typeof a=="number")return`${a}`}).filter(a=>typeof a=="string"&&a.length>0);return i.length>0?i:void 0}if(typeof s=="string"){const i=s.split(",").map(a=>a.trim()).filter(a=>a.length>0);return i.length>0?i:void 0}}}function W(s,i){const a=[];if(s.content&&typeof s.content=="object")for(const c of Object.values(s.content))typeof c=="string"&&c.trim().length>0&&a.push(c.trim());const n=[];return n.push(`# ${i}`),s.description?.trim()&&n.push(s.description.trim()),[...n,...a].join(`
|
|
7
|
+
|
|
8
|
+
`).trim()}function T(s,i){const a=s.name||i.name,n=i.description||s.description||"",r={registryId:s.id,registryEndpoint:s.endpoint,registrySource:P,author:s.author};for(const o of J){const d=i[o];if(d!==void 0)if(o==="tools"){const h=k(d);h&&(r.mcpServers=h)}else if(o==="focusAreas"||o==="contextPreferences"||o==="tags"){const h=k(d);h&&(r[o]=h)}else r[o]=d}!r.version&&s.version&&(r.version=s.version),r.color||(r.color="blue"),!r.tags&&s.tags&&(r.tags=k(s.tags));for(const[o,d]of Object.entries(r))d==null&&delete r[o];let c;return i.archive&&(c=i.archive.startsWith("http")?i.archive:`${P}${i.archive}`),{name:a,description:n,content:W(i,a),metadata:Object.keys(r).length>0?r:void 0,archiveUrl:c}}function I({open:s,onOpenChange:i,onImport:a}){return e.jsx(H,{open:s,onOpenChange:i,categoryId:"skills",title:"Coconut Registry - Skills",confirmLabel:"Import Skill",getDetail:n=>Y(n.endpoint),renderPreview:(n,r)=>{if(!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select a skill to preview"});const c=T(n,r),o=c.metadata??{},d=typeof o.version=="string"?o.version:void 0,h=Array.isArray(n.tags)?n.tags:[],g=Array.isArray(o.mcpServers)?o.mcpServers.filter(l=>typeof l=="string"):[],x=Array.isArray(o.focusAreas)?o.focusAreas.filter(l=>typeof l=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(z,{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:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.description})]}),d&&e.jsxs(v,{variant:"outline",children:["v",d]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:n.id})]}),r.archive&&e.jsxs(v,{variant:"outline",className:"gap-1 text-[10px]",children:[e.jsx(G,{className:"h-3 w-3"}),"Includes companion files"]})]}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(l=>e.jsx(v,{variant:"secondary",children:l},l))}),g.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:"MCP Servers:"}),g.map(l=>e.jsx(v,{variant:"outline",children:l},l))]}),x.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Focus Areas"}),e.jsx("ul",{className:"list-disc pl-5 text-sm text-muted-foreground",children:x.map(l=>e.jsx("li",{children:l},l))})]})]}),c.content?e.jsx(_,{className:"[&_.prose]:max-w-none",children:c.content}):r.archive?e.jsx("div",{className:"rounded-md bg-muted/50 p-4 text-sm text-muted-foreground",children:e.jsx("p",{children:"Full skill content and companion files will be downloaded during import."})}):null]})})})},onConfirm:async(n,r)=>{const c=T(n,r);await a({summary:n,detail:r,payload:c})}})}function Q(s){return s.replace(/[-_]/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function ne(){const[s,i]=f.useState([]),[a,n]=f.useState(!0),[r,c]=f.useState({}),[o,d]=f.useState(!1),[h,g]=f.useState(!1),{toast:x}=$(),l=f.useCallback(async()=>{n(!0);try{const t=await fetch(`${R}/api/v1/skills`);if(!t.ok)throw new Error("Failed to load skills");const p=await t.json();i(Array.isArray(p.documents)?p.documents:[])}catch(t){console.error("Failed to load skills:",t),i([])}finally{n(!1)}},[]);f.useEffect(()=>{l()},[l]);const b=async t=>{const p=`.nut/skills/${t}/SKILL.md`;try{await V(p),c(m=>({...m,[t]:!0})),setTimeout(()=>{c(m=>({...m,[t]:!1}))},2e3),x({title:"Path copied!",description:`Copied ${p} to clipboard`})}catch(m){console.error("Failed to copy path:",m),x({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},S=f.useCallback(async({payload:t})=>{let p=!1;g(!0);try{const m=await fetch(`${R}/api/v1/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.name,description:t.description,content:t.content,metadata:t.metadata,...t.archiveUrl?{archiveUrl:t.archiveUrl}:{}})});let u=null;try{u=await m.json()}catch(C){console.error("Failed to parse registry import response:",C)}if(!(m.ok&&u?.success)){const A=(typeof u?.error=="string"?u.error:u?.error?.message)||m.statusText||"Failed to import skill from registry";throw x({title:"Failed to import skill",description:A,variant:"destructive"}),p=!0,new Error(A)}x({title:"Skill imported",description:`${t.name} is now available in Coconut`}),await l()}catch(m){if(!p){const u=m instanceof Error&&m.message?m.message:"Failed to import skill from registry";x({title:"Failed to import skill",description:u,variant:"destructive"})}throw m}finally{g(!1)}},[l,x]);return a?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(O,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading skills..."})]})})})}):s.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:h,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(j,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(F,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Skills Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Specialized skills help you automate your development and business workflows."})]})})})]}),e.jsx(I,{open:o,onOpenChange:d,onImport:S})]}):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("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:h,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(j,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx("div",{className:"grid gap-4",children:s.map(t=>e.jsx(y,{to:`/skills/${t.id}`,className:"block",children:e.jsxs(N,{className:"group hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:[e.jsx(D,{children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"text-lg",children:Q(t.name)}),e.jsx(j,{variant:"ghost",size:"sm",onClick:p=>{p.preventDefault(),b(t.id)},className:"h-6 w-6 p-0 hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy file path to clipboard",children:r[t.id]?e.jsx(B,{className:"w-3 h-3 text-green-600"}):e.jsx(U,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono bg-muted/50 px-2 py-1 rounded inline-block cursor-pointer hover:bg-muted/70 transition-colors",onClick:p=>{p.preventDefault(),b(t.id)},title:"Click to copy file path to clipboard",children:[".nut/skills/",t.id,"/SKILL.md"]}),t.allowedTools&&e.jsx("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{className:"w-3 h-3"}),t.allowedTools]})})]})})}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:t.description})})})})]})},t.id))})]}),e.jsx(I,{open:o,onOpenChange:d,onImport:S})]})}export{ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,
|
|
1
|
+
import{j as s,a$ as e,B as a,L as t}from"./index-DFcWlnzl.js";import{C as i,b as l,c as r,d as n,a as d}from"./card-BcPlIAH5.js";import{E as o}from"./external-link-CNDy2UUo.js";function h(){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-medium",children:"Skills Management"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure and manage AI skills that automate various development tasks."})]}),s.jsx(e,{}),s.jsxs(i,{children:[s.jsxs(l,{children:[s.jsx(r,{children:"Skills"}),s.jsx(n,{children:"Skills are managed from the Skills page. Visit the skills page to create, edit, and manage your AI skills."})]}),s.jsx(d,{children:s.jsx(a,{asChild:!0,children:s.jsxs(t,{to:"/skills",children:[s.jsx(o,{className:"h-4 w-4 mr-2"}),"Go to Skills"]})})})]})]})}export{h as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as h,j as t,I as x,B as d,P as j,X as N}from"./index-DFcWlnzl.js";import{E as v}from"./external-link-CNDy2UUo.js";function g(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function S(n){return n?n.map(g):[]}function k({sources:n,onChange:i,disabled:a}){const[l,m]=h.useState(""),[o,c]=h.useState(""),u=()=>{const e=l.trim();if(!e)return;const s=o.trim()||void 0,r={title:e,url:s};i([...n,r]),m(""),c("")},f=e=>{i(n.filter((s,r)=>r!==e))},p=e=>{e.key==="Enter"&&(e.preventDefault(),u())};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(x,{placeholder:"Source title (e.g., Design System Audit)",value:l,onChange:e=>m(e.target.value),onKeyDown:p,disabled:a,className:"flex-1"}),t.jsx(x,{placeholder:"URL (optional)",value:o,onChange:e=>c(e.target.value),onKeyDown:p,disabled:a,className:"flex-1",type:"url"}),t.jsxs(d,{type:"button",variant:"outline",onClick:u,disabled:a||!l.trim(),className:"shrink-0",children:[t.jsx(j,{className:"h-4 w-4 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Add"})]})]}),n.length>0&&t.jsx("ul",{className:"space-y-2",children:n.map((e,s)=>t.jsxs("li",{className:"flex items-start gap-2 rounded-md border bg-muted/50 p-2 text-sm",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium truncate",children:e.title}),e.url&&t.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-primary flex items-center gap-1 truncate",children:[t.jsx(v,{className:"h-3 w-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e.url})]})]}),t.jsx(d,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(s),disabled:a,className:"h-6 w-6 p-0 shrink-0","aria-label":`Remove source ${e.title}`,children:t.jsx(N,{className:"h-3 w-3"})})]},s))})]})}export{k as S,S as n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as t,I as d,B as m,X as x}from"./index-
|
|
1
|
+
import{r as p,j as t,I as d,B as m,X as x}from"./index-DFcWlnzl.js";import{B as f}from"./badge-BUEY53dV.js";function j({tags:a,onChange:r,disabled:n,placeholder:o}){const[l,s]=p.useState(""),c=()=>{const e=l.trim();if(e){if(a.includes(e)){s("");return}r([...a,e]),s("")}},i=e=>{r(a.filter(u=>u!==e))};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(d,{placeholder:o||"Add a tag",value:l,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),c())},disabled:n}),t.jsx(m,{type:"button",variant:"outline",onClick:c,disabled:n,children:"Add"})]}),a.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(e=>t.jsxs(f,{variant:"secondary",className:"flex items-center gap-1",children:[e,t.jsx("button",{type:"button",onClick:()=>i(e),className:"ml-1 hover:text-destructive",disabled:n,"aria-label":`Remove tag ${e}`,children:t.jsx(x,{className:"h-3 w-3"})})]},e))})]})}export{j as T};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{c as T,x as xe,u as ue,r as i,a as pe,j as e,B as n,L as c,y as je,z as fe,E as ge,H as Ne,J as ye,N as ve,O as be,Q as we,R as Ce,U as ke,D as H,V,b as B,d as q,f as J,g as K,W as G,Y as Se,_ as Q,$ as De,m as Te,o as Ae,A as u}from"./index-DFcWlnzl.js";import{c as $e}from"./clipboard-B9ndUJKl.js";import{C as m,b as k,a as h,c as W,d as Pe}from"./card-BcPlIAH5.js";import{B as g}from"./badge-BUEY53dV.js";import{L as Y}from"./label-DBuh-ke5.js";import{S as X,a as Z,b as ee,c as se,d as te}from"./select-44mcS2_G.js";import{T as Ue,a as ae,g as Ee}from"./status-utils-CDkPeVfP.js";import{A as S}from"./arrow-left-1S-835kP.js";import{C as Ie,a as Oe}from"./clipboard-tzPFoieb.js";import{A as Fe}from"./arrow-up-down-Dw3J0a4i.js";import{I as ze}from"./info-D6jxZC5X.js";import{P as Le}from"./play-CHIf-Rcz.js";import{C as Me}from"./clock-Bjc06QBM.js";import{M as _e}from"./message-square-B5RWz_ff.js";import"./chevron-up-CqM3won3.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=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],re=T("circle-dot",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 He=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],Ve=T("flag",He);/**
|
|
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 Be=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],qe=T("gauge",Be);function Je(a){return a>=80?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300":a>=60?"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300":a>=40?"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-300":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300"}function Ke(a){switch(a){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}const Ge=["low","medium","high","critical"];function ne(a){return a?a.charAt(0).toUpperCase()+a.slice(1):"None"}function D(a){const N=Date.now(),s=new Date(a).getTime(),d=N-s,y=Math.floor(d/1e3),o=Math.floor(y/60),l=Math.floor(o/60),x=Math.floor(l/24);return x>0?`${x}d ago`:l>0?`${l}h ago`:o>0?`${o}m ago`:"just now"}function os(){const{id:a}=xe(),N=ue(),[s,d]=i.useState(null),[y,o]=i.useState(!0),[l,x]=i.useState(null),[A,$]=i.useState(!1),[P,U]=i.useState(!1),[E,I]=i.useState(!1),[O,F]=i.useState(!1),[p,z]=i.useState(""),[ie,v]=i.useState(!1),[le,b]=i.useState(!1),[j,L]=i.useState("draft"),[w,M]=i.useState("medium"),[ce,_]=i.useState(!1),{toast:R}=pe();i.useEffect(()=>{async function t(){if(a)try{o(!0);const f=await(await fetch(`${u}/api/v1/tasks/${a}`)).json();f.success?d(f.data):x(f.error?.message||"Failed to fetch task")}catch(r){x(r instanceof Error?r.message:"Unknown error")}finally{o(!1)}}t()},[a]);const de=async()=>{if(a){$(!0);try{const r=await(await fetch(`${u}/api/v1/tasks/${a}`,{method:"DELETE"})).json();r.success?N("/tasks"):alert(r.error?.message||"Failed to delete task")}catch(t){alert(`Error deleting task: ${t instanceof Error?t.message:"Unknown error"}`)}finally{$(!1)}}},oe=async()=>{if(!(!s||!a||j===s.status)){U(!0);try{const r=await(await fetch(`${u}/api/v1/tasks/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:j})})).json();r.success?(d(r.data),v(!1)):alert(r.error?.message||"Failed to update status")}catch(t){alert(`Error updating status: ${t instanceof Error?t.message:"Unknown error"}`)}finally{U(!1)}}},me=async()=>{if(!(!s||!a)){I(!0);try{const r=await(await fetch(`${u}/api/v1/tasks/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:{...s.metadata,priority:w}})})).json();r.success?(d(r.data),b(!1)):alert(r.error?.message||"Failed to update priority")}catch(t){alert(`Error updating priority: ${t instanceof Error?t.message:"Unknown error"}`)}finally{I(!1)}}},he=async()=>{if(!(!s||!a||!p.trim())){F(!0);try{const t={id:`comment-${Date.now()}`,content:p,author:"current-user",createdAt:new Date().toISOString()},r=[...s.comments||[],t],C=await(await fetch(`${u}/api/v1/tasks/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comments:r})})).json();C.success?(d(C.data),z("")):alert(C.error?.message||"Failed to add comment")}catch(t){alert(`Error adding comment: ${t instanceof Error?t.message:"Unknown error"}`)}finally{F(!1)}}};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:"/tasks",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})})})]}),e.jsxs(m,{children:[e.jsx(k,{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(h,{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"})]})})]})]}):l||!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:l||"Task 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:"/tasks",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})})})]}),e.jsx(m,{children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:l||"Task not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The task with ID "',a,'" could not be found.']}),e.jsx(n,{asChild:!0,className:"mt-4",children:e.jsx(c,{to:"/tasks",children:"Back to Tasks"})})]})})})]}):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:"/tasks",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})}),e.jsxs(je,{children:[e.jsx(fe,{asChild:!0,children:e.jsxs(n,{variant:"destructive",size:"sm",disabled:A,children:[e.jsx(ge,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:A?"Deleting...":"Delete"})]})}),e.jsxs(Ne,{children:[e.jsxs(ye,{children:[e.jsx(ve,{children:"Are you absolutely sure?"}),e.jsxs(be,{children:["This action cannot be undone. This will permanently delete the task",e.jsxs("span",{className:"font-semibold",children:[' "',s.title||s.intent,'"']})," and remove it from the system."]})]}),e.jsxs(we,{children:[e.jsx(Ce,{children:"Cancel"}),e.jsx(ke,{onClick:de,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Task"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const t=`.nut/tasks/${s.id}.md`;try{await $e(t),_(!0),R({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>_(!1),2e3)}catch(r){console.error("Failed to copy path:",r),R({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/tasks/${s.id}.md`}),ce?e.jsx(Ie,{className:"h-3.5 w-3.5"}):e.jsx(Oe,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(H,{open:ie,onOpenChange:v,children:[e.jsx(V,{asChild:!0,children:e.jsxs(n,{variant:"outline",size:"sm",onClick:()=>L(s?.status||"draft"),children:[e.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Update Status"]})}),e.jsxs(B,{children:[e.jsxs(q,{children:[e.jsx(J,{children:"Change Task Status"}),e.jsx(K,{children:"Update the status of this task."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(Y,{htmlFor:"status",children:"Status"}),e.jsxs(X,{value:j,onValueChange:t=>L(t),children:[e.jsx(Z,{children:e.jsx(ee,{placeholder:"Select status"})}),e.jsx(se,{children:Ue.map(t=>e.jsx(te,{value:t,children:ae(t)},t))})]})]})}),e.jsxs(G,{children:[e.jsx(n,{variant:"outline",onClick:()=>v(!1),children:"Cancel"}),e.jsx(n,{onClick:oe,disabled:P||j===s?.status,children:P?"Updating...":"Update Status"})]})]})]}),e.jsxs(H,{open:le,onOpenChange:b,children:[e.jsx(V,{asChild:!0,children:e.jsxs(n,{variant:"outline",size:"sm",onClick:()=>M(s?.metadata.priority||"medium"),children:[e.jsx(re,{className:"h-4 w-4 mr-2"}),"Update Priority"]})}),e.jsxs(B,{children:[e.jsxs(q,{children:[e.jsx(J,{children:"Change Task Priority"}),e.jsx(K,{children:"Update the priority of this task."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(Y,{htmlFor:"priority",children:"Priority"}),e.jsxs(X,{value:w,onValueChange:M,children:[e.jsx(Z,{children:e.jsx(ee,{placeholder:"Select priority"})}),e.jsx(se,{children:Ge.map(t=>e.jsx(te,{value:t,children:ne(t)},t))})]})]})}),e.jsxs(G,{children:[e.jsx(n,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(n,{onClick:me,disabled:E||w===s?.metadata.priority,children:E?"Updating...":"Update Priority"})]})]})]}),e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(c,{to:`/tasks/${a}/edit`,children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Edit"]})}),e.jsx("div",{className:"border-l h-6 mx-1"}),e.jsx(n,{variant:"default",size:"sm",className:"bg-blue-600 hover:bg-blue-700",asChild:!0,children:e.jsxs(c,{to:`/terminal/${a}?reviewOnly=true`,children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Review Task"]})}),e.jsx(n,{variant:"default",size:"sm",className:"bg-green-600 hover:bg-green-700",asChild:!0,children:e.jsxs(c,{to:`/terminal/${a}?startOnly=true`,children:[e.jsx(Le,{className:"h-4 w-4 mr-2"}),"Start Task"]})})]}),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.jsx(m,{children:e.jsx(h,{className:"pt-6 space-y-4",children:s.content?e.jsx(Q,{children:s.content}):e.jsx("p",{className:"text-muted-foreground",children:"No detailed content available for this task."})})}),s.planSteps&&s.planSteps.length>0&&e.jsxs(m,{children:[e.jsxs(k,{children:[e.jsx(W,{children:"Implementation Steps"}),e.jsxs(Pe,{children:[s.planSteps.length," step",s.planSteps.length!==1?"s":""," planned"]})]}),e.jsx(h,{children:e.jsx("div",{className:"space-y-3",children:s.planSteps.map((t,r)=>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:r+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(g,{variant:"outline",className:"text-xs",children:t.status})})]})]},t.id))})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(m,{children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{children:[s.metadata.readiness!=null&&e.jsxs("div",{className:"flex items-center justify-between py-2 first:pt-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(qe,{className:"h-4 w-4"}),e.jsx("span",{children:"Readiness"})]}),e.jsxs("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold ${Je(s.metadata.readiness)}`,children:[s.metadata.readiness,"%"]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 first:pt-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(re,{className:"h-4 w-4"}),e.jsx("span",{children:"Status"})]}),e.jsx(g,{variant:Ee(s.status),children:ae(s.status)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ve,{className:"h-4 w-4"}),e.jsx("span",{children:"Priority"})]}),e.jsx(g,{variant:Ke(s.metadata.priority),children:ne(s.metadata.priority)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(De,{className:"h-4 w-4"}),e.jsx("span",{children:"Author"})]}),e.jsx("span",{className:"text-sm font-medium",children:s.author.name})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Te,{className:"h-4 w-4"}),e.jsx("span",{children:"Created"})]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:D(s.metadata.createdAt)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 last:pb-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Me,{className:"h-4 w-4"}),e.jsx("span",{children:"Updated"})]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:D(s.metadata.updatedAt)})]})]})})}),e.jsxs(m,{children:[e.jsx(k,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-5 w-5"}),e.jsx(W,{children:"Comments"}),s.comments&&s.comments.length>0&&e.jsx(g,{variant:"secondary",className:"rounded-full px-2 py-0.5 text-xs",children:s.comments.length})]})}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ae,{placeholder:"Add a comment...",value:p,onChange:t=>z(t.target.value),rows:3}),e.jsx(n,{className:"w-full",onClick:he,disabled:O||!p.trim(),children:O?"Adding...":"Add Comment"})]}),s.comments&&s.comments.length>0&&e.jsx("div",{className:"space-y-3",children:[...s.comments].reverse().map((t,r)=>e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsxs("div",{className:"mb-1",children:[e.jsx("span",{className:"text-sm font-semibold",children:t.author}),e.jsx("p",{className:"text-xs text-muted-foreground",children:D(t.createdAt)})]}),e.jsx(Q,{className:"prose-sm prose-p:mb-0 prose-ul:my-1 prose-ol:my-1 text-sm",children:t.content})]},t.id||r))})]})]})]})]})]})}export{os as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{x as R,u as U,a as H,r as c,A,j as e,B as h,L as p,I as O,X as V,a0 as _}from"./index-DFcWlnzl.js";import{L as j}from"./label-DBuh-ke5.js";import{S as D,a as L,b as F,c as I,d as r}from"./select-44mcS2_G.js";import{C as f,b as $,a as v,c as q,d as J}from"./card-BcPlIAH5.js";import{M as K}from"./markdown-editor-B4YNQFT2.js";import{C as W}from"./CollapsibleSection-M5cXbl92.js";import{I as X,L as G}from"./ImplementationStepsEditor-HliLQav5.js";import{T as Q}from"./TagInput-C6lI-ePr.js";import{A as N}from"./arrow-left-1S-835kP.js";import"./chevron-up-CqM3won3.js";import"./badge-BUEY53dV.js";function de(){const{id:i}=R(),P=U(),{toast:y}=H(),[z,S]=c.useState(!0),[u,k]=c.useState(!1),[C,w]=c.useState(null),[n,o]=c.useState({title:"",description:"",priority:"medium",status:"draft",author:{id:"current-user",name:"Current User",email:"user@example.com"}}),[m,b]=c.useState([]),[T,E]=c.useState([]);c.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${A}/api/v1/tasks/${i}`),s=await t.json();if(s.success||s.data||t.ok){const a=s.data||s;o({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:[];b(g.map((d,x)=>({id:d.id||`step-${x+1}`,description:d.description||"",status:d.status||"pending"}))),E(a.metadata?.tags||[])}else w(s.error?.message||"Failed to fetch task")}catch(t){w(t instanceof Error?t.message:"An error occurred")}finally{S(!1)}},M=async t=>{t.preventDefault(),k(!0);try{const s=m.map(l=>({id:l.id,description:l.description.trim(),status:l.status})).filter(l=>l.description.length>0),a=T.map(l=>l.trim()).filter(l=>l.length>0),g={title:n.title,status:n.status,planSteps:s,metadata:{priority:n.priority,tags:a},content:n.description},d=await fetch(`${A}/api/v1/tasks/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),x=await d.json();if(x.success||d.ok)y({title:"Success",description:"Task updated successfully."}),P(`/tasks/${i}`);else throw new Error(x.error?.message||"Failed to update task")}catch(s){y({title:"Error",description:`Failed to update task: ${s instanceof Error?s.message:"An error occurred"}`,variant:"destructive"})}finally{k(!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 Task"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading task data..."})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:`/tasks/${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($,{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"})]})})]})]}):C?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(h,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:"/tasks",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:C})]})})})]}):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 Task"}),e.jsxs("p",{className:"text-muted-foreground",children:["Editing ",i]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(p,{to:`/tasks/${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($,{children:[e.jsx(q,{children:"Task Details"}),e.jsx(J,{children:"Update the information for your task"})]}),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:n.title,onChange:t=>o(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:n.description,onChange:t=>o(s=>({...s,description:t||""})),placeholder:"Write your task description in markdown...",height:400})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"status",children:"Status"}),e.jsxs(D,{value:n.status,onValueChange:t=>o(s=>({...s,status:t})),children:[e.jsx(L,{children:e.jsx(F,{placeholder:"Select status"})}),e.jsxs(I,{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(D,{value:n.priority,onValueChange:t=>o(s=>({...s,priority:t})),children:[e.jsx(L,{children:e.jsx(F,{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:"Keep the implementation plan accurate as work progresses."})]}),m.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.length," step",m.length===1?"":"s"]})]}),e.jsx(X,{steps:m,onChange:b,disabled:u})]}),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 task list."}),e.jsx(Q,{tags:T,onChange:E,disabled:u,placeholder:"Add a tag (e.g. backend, rollout)"})]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(h,{type:"button",variant:"outline",asChild:!0,children:e.jsxs(p,{to:`/tasks/${i}`,children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Cancel"]})}),e.jsx(h,{type:"submit",disabled:u||!n.title,children:u?e.jsx(e.Fragment,{children:"Saving..."}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Save Changes"]})})]})]})]})})]})}export{de as TaskEditPage};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{c as Ce,w as Ke,u as ze,q as Ve,r as A,j as t,B as P,L as te,P as ue,I as We,X,K as Ue,p as Ge,n as He,G as Qe,C as Ye,A as Xe}from"./index-DFcWlnzl.js";import{C as J,a as Z,c as Je}from"./card-BcPlIAH5.js";import{B as se}from"./badge-BUEY53dV.js";import{S as oe,a as he,b as de,c as me,d as B}from"./select-44mcS2_G.js";import{A as Ze,a as Ee,T as qe,g as et}from"./status-utils-CDkPeVfP.js";import{S as tt}from"./search-Cq1ksEdp.js";import{C as st}from"./chevron-up-CqM3won3.js";import{C as rt}from"./chevron-left-FMmNe7yP.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 nt=[["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"}]],at=Ce("arrow-down-wide-narrow",nt);/**
|
|
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 it=[["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"}]],ct=Ce("arrow-up-narrow-wide",it);/**
|
|
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 lt=[["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"}]],be=Ce("funnel",lt);function K(s){return Array.isArray?Array.isArray(s):_e(s)==="[object Array]"}function ut(s){if(typeof s=="string")return s;let e=s+"";return e=="0"&&1/s==-1/0?"-0":e}function ot(s){return s==null?"":ut(s)}function O(s){return typeof s=="string"}function De(s){return typeof s=="number"}function ht(s){return s===!0||s===!1||dt(s)&&_e(s)=="[object Boolean]"}function ke(s){return typeof s=="object"}function dt(s){return ke(s)&&s!==null}function D(s){return s!=null}function fe(s){return!s.trim().length}function _e(s){return s==null?s===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(s)}const mt="Incorrect 'index' type",ft=s=>`Invalid value for key ${s}`,gt=s=>`Pattern length exceeds max of ${s}.`,xt=s=>`Missing ${s} property in key`,pt=s=>`Property 'weight' in key '${s}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class At{constructor(e){this._keys=[],this._keyMap={};let r=0;e.forEach(n=>{let a=Ie(n);this._keys.push(a),this._keyMap[a.id]=a,r+=a.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 Ie(s){let e=null,r=null,n=null,a=1,c=null;if(O(s)||K(s))n=s,e=Fe(s),r=ge(s);else{if(!ve.call(s,"name"))throw new Error(xt("name"));const l=s.name;if(n=l,ve.call(s,"weight")&&(a=s.weight,a<=0))throw new Error(pt(l));e=Fe(l),r=ge(l),c=s.getFn}return{path:e,id:r,weight:a,src:n,getFn:c}}function Fe(s){return K(s)?s:s.split(".")}function ge(s){return K(s)?s.join("."):s}function jt(s,e){let r=[],n=!1;const a=(c,l,u)=>{if(D(c))if(!l[u])r.push(c);else{let o=l[u];const h=c[o];if(!D(h))return;if(u===l.length-1&&(O(h)||De(h)||ht(h)))r.push(ot(h));else if(K(h)){n=!0;for(let d=0,f=h.length;d<f;d+=1)a(h[d],l,u+1)}else l.length&&a(h,l,u+1)}};return a(s,O(e)?e.split("."):e,0),n?r:r[0]}const yt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Ct={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(s,e)=>s.score===e.score?s.idx<e.idx?-1:1:s.score<e.score?-1:1},wt={location:0,threshold:.6,distance:100},Nt={useExtendedSearch:!1,getFn:jt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var m={...Ct,...yt,...wt,...Nt};const Et=/[^ ]+/g;function bt(s=1,e=3){const r=new Map,n=Math.pow(10,e);return{get(a){const c=a.match(Et).length;if(r.has(c))return r.get(c);const l=1/Math.pow(c,.5*s),u=parseFloat(Math.round(l*n)/n);return r.set(c,u),u},clear(){r.clear()}}}class we{constructor({getFn:e=m.getFn,fieldNormWeight:r=m.fieldNormWeight}={}){this.norm=bt(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,O(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();O(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)||fe(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((a,c)=>{let l=a.getFn?a.getFn(e):this.getFn(e,a.path);if(D(l)){if(K(l)){let u=[];const o=[{nestedArrIndex:-1,value:l}];for(;o.length;){const{nestedArrIndex:h,value:d}=o.pop();if(D(d))if(O(d)&&!fe(d)){let f={v:d,i:h,n:this.norm.get(d)};u.push(f)}else K(d)&&d.forEach((f,p)=>{o.push({nestedArrIndex:p,value:f})})}n.$[c]=u}else if(O(l)&&!fe(l)){let u={v:l,n:this.norm.get(l)};n.$[c]=u}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Le(s,e,{getFn:r=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const a=new we({getFn:r,fieldNormWeight:n});return a.setKeys(s.map(Ie)),a.setSources(e),a.create(),a}function vt(s,{getFn:e=m.getFn,fieldNormWeight:r=m.fieldNormWeight}={}){const{keys:n,records:a}=s,c=new we({getFn:e,fieldNormWeight:r});return c.setKeys(n),c.setIndexRecords(a),c}function re(s,{errors:e=0,currentLocation:r=0,expectedLocation:n=0,distance:a=m.distance,ignoreLocation:c=m.ignoreLocation}={}){const l=e/s.length;if(c)return l;const u=Math.abs(n-r);return a?l+u/a:u?1:l}function Ft(s=[],e=m.minMatchCharLength){let r=[],n=-1,a=-1,c=0;for(let l=s.length;c<l;c+=1){let u=s[c];u&&n===-1?n=c:!u&&n!==-1&&(a=c-1,a-n+1>=e&&r.push([n,a]),n=-1)}return s[c-1]&&c-n>=e&&r.push([n,c-1]),r}const U=32;function Mt(s,e,r,{location:n=m.location,distance:a=m.distance,threshold:c=m.threshold,findAllMatches:l=m.findAllMatches,minMatchCharLength:u=m.minMatchCharLength,includeMatches:o=m.includeMatches,ignoreLocation:h=m.ignoreLocation}={}){if(e.length>U)throw new Error(gt(U));const d=e.length,f=s.length,p=Math.max(0,Math.min(n,f));let x=c,j=p;const C=u>1||o,M=C?Array(f):[];let v;for(;(v=s.indexOf(e,j))>-1;){let E=re(e,{currentLocation:v,expectedLocation:p,distance:a,ignoreLocation:h});if(x=Math.min(E,x),j=v+d,C){let R=0;for(;R<d;)M[v+R]=1,R+=1}}j=-1;let k=[],F=1,L=d+f;const ie=1<<d-1;for(let E=0;E<d;E+=1){let R=0,_=L;for(;R<_;)re(e,{errors:E,currentLocation:p+_,expectedLocation:p,distance:a,ignoreLocation:h})<=x?R=_:L=_,_=Math.floor((L-R)/2+R);L=_;let G=Math.max(1,p-_+1),N=l?f:Math.min(p+_,f)+d,I=Array(N+2);I[N+1]=(1<<E)-1;for(let b=N;b>=G;b-=1){let W=b-1,ee=r[s.charAt(W)];if(C&&(M[W]=+!!ee),I[b]=(I[b+1]<<1|1)&ee,E&&(I[b]|=(k[b+1]|k[b])<<1|1|k[b+1]),I[b]&ie&&(F=re(e,{errors:E,currentLocation:W,expectedLocation:p,distance:a,ignoreLocation:h}),F<=x)){if(x=F,j=W,j<=p)break;G=Math.max(1,2*p-j)}}if(re(e,{errors:E+1,currentLocation:p,expectedLocation:p,distance:a,ignoreLocation:h})>x)break;k=I}const T={isMatch:j>=0,score:Math.max(.001,F)};if(C){const E=Ft(M,u);E.length?o&&(T.indices=E):T.isMatch=!1}return T}function St(s){let e={};for(let r=0,n=s.length;r<n;r+=1){const a=s.charAt(r);e[a]=(e[a]||0)|1<<n-r-1}return e}const ne=String.prototype.normalize?(s=>s.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,"")):(s=>s);class Te{constructor(e,{location:r=m.location,threshold:n=m.threshold,distance:a=m.distance,includeMatches:c=m.includeMatches,findAllMatches:l=m.findAllMatches,minMatchCharLength:u=m.minMatchCharLength,isCaseSensitive:o=m.isCaseSensitive,ignoreDiacritics:h=m.ignoreDiacritics,ignoreLocation:d=m.ignoreLocation}={}){if(this.options={location:r,threshold:n,distance:a,includeMatches:c,findAllMatches:l,minMatchCharLength:u,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d},e=o?e:e.toLowerCase(),e=h?ne(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const f=(x,j)=>{this.chunks.push({pattern:x,alphabet:St(x),startIndex:j})},p=this.pattern.length;if(p>U){let x=0;const j=p%U,C=p-j;for(;x<C;)f(this.pattern.substr(x,U),x),x+=U;if(j){const M=p-U;f(this.pattern.substr(M),M)}}else f(this.pattern,0)}searchIn(e){const{isCaseSensitive:r,ignoreDiacritics:n,includeMatches:a}=this.options;if(e=r?e:e.toLowerCase(),e=n?ne(e):e,this.pattern===e){let C={isMatch:!0,score:0};return a&&(C.indices=[[0,e.length-1]]),C}const{location:c,distance:l,threshold:u,findAllMatches:o,minMatchCharLength:h,ignoreLocation:d}=this.options;let f=[],p=0,x=!1;this.chunks.forEach(({pattern:C,alphabet:M,startIndex:v})=>{const{isMatch:k,score:F,indices:L}=Mt(e,C,M,{location:c+v,distance:l,threshold:u,findAllMatches:o,minMatchCharLength:h,includeMatches:a,ignoreLocation:d});k&&(x=!0),p+=F,k&&L&&(f=[...f,...L])});let j={isMatch:x,score:x?p/this.chunks.length:1};return x&&a&&(j.indices=f),j}}class V{constructor(e){this.pattern=e}static isMultiMatch(e){return Me(e,this.multiRegex)}static isSingleMatch(e){return Me(e,this.singleRegex)}search(){}}function Me(s,e){const r=s.match(e);return r?r[1]:null}class Bt extends V{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 Dt extends V{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 kt extends V{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 _t extends V{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 It extends V{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 Lt extends V{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 Re extends V{constructor(e,{location:r=m.location,threshold:n=m.threshold,distance:a=m.distance,includeMatches:c=m.includeMatches,findAllMatches:l=m.findAllMatches,minMatchCharLength:u=m.minMatchCharLength,isCaseSensitive:o=m.isCaseSensitive,ignoreDiacritics:h=m.ignoreDiacritics,ignoreLocation:d=m.ignoreLocation}={}){super(e),this._bitapSearch=new Te(e,{location:r,threshold:n,distance:a,includeMatches:c,findAllMatches:l,minMatchCharLength:u,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 $e extends V{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let r=0,n;const a=[],c=this.pattern.length;for(;(n=e.indexOf(this.pattern,r))>-1;)r=n+c,a.push([n,r-1]);const l=!!a.length;return{isMatch:l,score:l?0:1,indices:a}}}const xe=[Bt,$e,kt,_t,Lt,It,Dt,Re],Se=xe.length,Tt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Rt="|";function $t(s,e={}){return s.split(Rt).map(r=>{let n=r.trim().split(Tt).filter(c=>c&&!!c.trim()),a=[];for(let c=0,l=n.length;c<l;c+=1){const u=n[c];let o=!1,h=-1;for(;!o&&++h<Se;){const d=xe[h];let f=d.isMultiMatch(u);f&&(a.push(new d(f,e)),o=!0)}if(!o)for(h=-1;++h<Se;){const d=xe[h];let f=d.isSingleMatch(u);if(f){a.push(new d(f,e));break}}}return a})}const Ot=new Set([Re.type,$e.type]);class Pt{constructor(e,{isCaseSensitive:r=m.isCaseSensitive,ignoreDiacritics:n=m.ignoreDiacritics,includeMatches:a=m.includeMatches,minMatchCharLength:c=m.minMatchCharLength,ignoreLocation:l=m.ignoreLocation,findAllMatches:u=m.findAllMatches,location:o=m.location,threshold:h=m.threshold,distance:d=m.distance}={}){this.query=null,this.options={isCaseSensitive:r,ignoreDiacritics:n,includeMatches:a,minMatchCharLength:c,findAllMatches:u,ignoreLocation:l,location:o,threshold:h,distance:d},e=r?e:e.toLowerCase(),e=n?ne(e):e,this.pattern=e,this.query=$t(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:a,ignoreDiacritics:c}=this.options;e=a?e:e.toLowerCase(),e=c?ne(e):e;let l=0,u=[],o=0;for(let h=0,d=r.length;h<d;h+=1){const f=r[h];u.length=0,l=0;for(let p=0,x=f.length;p<x;p+=1){const j=f[p],{isMatch:C,indices:M,score:v}=j.search(e);if(C){if(l+=1,o+=v,n){const k=j.constructor.type;Ot.has(k)?u=[...u,...M]:u.push(M)}}else{o=0,l=0,u.length=0;break}}if(l){let p={isMatch:!0,score:o/l};return n&&(p.indices=u),p}}return{isMatch:!1,score:1}}}const pe=[];function Kt(...s){pe.push(...s)}function Ae(s,e){for(let r=0,n=pe.length;r<n;r+=1){let a=pe[r];if(a.condition(s,e))return new a(s,e)}return new Te(s,e)}const ae={AND:"$and",OR:"$or"},je={PATH:"$path",PATTERN:"$val"},ye=s=>!!(s[ae.AND]||s[ae.OR]),zt=s=>!!s[je.PATH],Vt=s=>!K(s)&&ke(s)&&!ye(s),Be=s=>({[ae.AND]:Object.keys(s).map(e=>({[e]:s[e]}))});function Oe(s,e,{auto:r=!0}={}){const n=a=>{let c=Object.keys(a);const l=zt(a);if(!l&&c.length>1&&!ye(a))return n(Be(a));if(Vt(a)){const o=l?a[je.PATH]:c[0],h=l?a[je.PATTERN]:a[o];if(!O(h))throw new Error(ft(o));const d={keyId:ge(o),pattern:h};return r&&(d.searcher=Ae(h,e)),d}let u={children:[],operator:c[0]};return c.forEach(o=>{const h=a[o];K(h)&&h.forEach(d=>{u.children.push(n(d))})}),u};return ye(s)||(s=Be(s)),n(s)}function Wt(s,{ignoreFieldNorm:e=m.ignoreFieldNorm}){s.forEach(r=>{let n=1;r.matches.forEach(({key:a,norm:c,score:l})=>{const u=a?a.weight:null;n*=Math.pow(l===0&&u?Number.EPSILON:l,(u||1)*(e?1:c))}),r.score=n})}function Ut(s,e){const r=s.matches;e.matches=[],D(r)&&r.forEach(n=>{if(!D(n.indices)||!n.indices.length)return;const{indices:a,value:c}=n;let l={indices:a,value:c};n.key&&(l.key=n.key.src),n.idx>-1&&(l.refIndex=n.idx),e.matches.push(l)})}function Gt(s,e){e.score=s.score}function Ht(s,e,{includeMatches:r=m.includeMatches,includeScore:n=m.includeScore}={}){const a=[];return r&&a.push(Ut),n&&a.push(Gt),s.map(c=>{const{idx:l}=c,u={item:e[l],refIndex:l};return a.length&&a.forEach(o=>{o(c,u)}),u})}class H{constructor(e,r={},n){this.options={...m,...r},this.options.useExtendedSearch,this._keyStore=new At(this.options.keys),this.setCollection(e,n)}setCollection(e,r){if(this._docs=e,r&&!(r instanceof we))throw new Error(mt);this._myIndex=r||Le(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,a=this._docs.length;n<a;n+=1){const c=this._docs[n];e(c,n)&&(this.removeAt(n),n-=1,a-=1,r.push(c))}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:a,shouldSort:c,sortFn:l,ignoreFieldNorm:u}=this.options;let o=O(e)?O(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return Wt(o,{ignoreFieldNorm:u}),c&&o.sort(l),De(r)&&r>-1&&(o=o.slice(0,r)),Ht(o,this._docs,{includeMatches:n,includeScore:a})}_searchStringList(e){const r=Ae(e,this.options),{records:n}=this._myIndex,a=[];return n.forEach(({v:c,i:l,n:u})=>{if(!D(c))return;const{isMatch:o,score:h,indices:d}=r.searchIn(c);o&&a.push({item:c,idx:l,matches:[{score:h,value:c,norm:u,indices:d}]})}),a}_searchLogical(e){const r=Oe(e,this.options),n=(u,o,h)=>{if(!u.children){const{keyId:f,searcher:p}=u,x=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(o,f),searcher:p});return x&&x.length?[{idx:h,item:o,matches:x}]:[]}const d=[];for(let f=0,p=u.children.length;f<p;f+=1){const x=u.children[f],j=n(x,o,h);if(j.length)d.push(...j);else if(u.operator===ae.AND)return[]}return d},a=this._myIndex.records,c={},l=[];return a.forEach(({$:u,i:o})=>{if(D(u)){let h=n(r,u,o);h.length&&(c[o]||(c[o]={idx:o,item:u,matches:[]},l.push(c[o])),h.forEach(({matches:d})=>{c[o].matches.push(...d)}))}}),l}_searchObjectList(e){const r=Ae(e,this.options),{keys:n,records:a}=this._myIndex,c=[];return a.forEach(({$:l,i:u})=>{if(!D(l))return;let o=[];n.forEach((h,d)=>{o.push(...this._findMatches({key:h,value:l[d],searcher:r}))}),o.length&&c.push({idx:u,item:l,matches:o})}),c}_findMatches({key:e,value:r,searcher:n}){if(!D(r))return[];let a=[];if(K(r))r.forEach(({v:c,i:l,n:u})=>{if(!D(c))return;const{isMatch:o,score:h,indices:d}=n.searchIn(c);o&&a.push({score:h,key:e,value:c,idx:l,norm:u,indices:d})});else{const{v:c,n:l}=r,{isMatch:u,score:o,indices:h}=n.searchIn(c);u&&a.push({score:o,key:e,value:c,norm:l,indices:h})}return a}}H.version="7.1.0";H.createIndex=Le;H.parseIndex=vt;H.config=m;H.parseQuery=Oe;Kt(Pt);function Qt(s){switch(s){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}const q=20;function rs(){const[s]=Ke(),e=ze(),r=Ve(),[n,a]=A.useState([]),[c,l]=A.useState([]),[u,o]=A.useState(!0),[h,d]=A.useState(null),[f,p]=A.useState(s.get("status")||"_default"),[x,j]=A.useState(s.get("priority")||"all"),[C,M]=A.useState(s.get("search")||""),[v,k]=A.useState(s.get("sortBy")||"created"),[F,L]=A.useState(s.get("order")||"desc"),[ie,T]=A.useState(()=>{const i=parseInt(s.get("page")||"1",10);return Number.isNaN(i)||i<1?1:i}),[E,R]=A.useState(!1),_=A.useRef(null),G=[f!=="_default",x!=="all",v!=="created",F!=="desc"].filter(Boolean).length,N=A.useCallback(i=>{const g=new URLSearchParams(s);Object.entries(i).forEach(([S,z])=>{z&&z!=="all"&&z!=="_default"&&z!==""?g.set(S,z):g.delete(S)});const y=g.toString(),w=y?`?${y}`:"";e(`${r.pathname}${w}`)},[s,e,r.pathname]),I=A.useCallback(i=>{p(i),T(1),N({status:i==="_default"?null:i,page:null})},[N]),Q=A.useCallback(i=>{j(i),T(1),N({priority:i==="all"?null:i,page:null})},[N]),b=A.useCallback(i=>{M(i),T(1),N({search:i||null,page:null})},[N]),W=A.useCallback(i=>{k(i),T(1),N({sortBy:i==="created"?null:i,page:null})},[N]),ee=A.useCallback(()=>{const i=F==="asc"?"desc":"asc";L(i),T(1),N({order:i==="desc"?null:i,page:null})},[F,N]),ce=A.useCallback(i=>{T(i),N({page:i===1?null:String(i)}),window.scrollTo({top:0,behavior:"smooth"})},[N]),le=A.useCallback(i=>{if(i.key==="s"||i.key==="S"){const g=document.activeElement;g?.tagName==="INPUT"||g?.tagName==="TEXTAREA"||g?.getAttribute("contenteditable")==="true"||(i.preventDefault(),_.current?.focus())}},[]);A.useEffect(()=>(document.addEventListener("keydown",le),()=>{document.removeEventListener("keydown",le)}),[le]);const Ne=A.useMemo(()=>{const i={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 H(n,i)},[n]);A.useEffect(()=>{async function i(){try{o(!0);const y=await(await fetch(`${Xe}/api/v1/tasks`)).json();y.success?(a(y.data),l(y.data)):d(y.error?.message||"Failed to fetch tasks")}catch(g){d(g instanceof Error?g.message:"Unknown error")}finally{o(!1)}}i()},[]),A.useEffect(()=>{let i=n;if(f==="_default"?i=i.filter(g=>Ze.includes(g.status)):f!=="all"&&(i=i.filter(g=>g.status===f)),x!=="all"&&(i=i.filter(g=>g.metadata.priority===x)),C.trim()){const g=Ne.search(C),y=new Set(g.map(w=>w.item.id));i=i.filter(w=>y.has(w.id))}i=i.sort((g,y)=>{let w,S;switch(v){case"created":{w=new Date(g.metadata.createdAt).getTime(),S=new Date(y.metadata.createdAt).getTime();break}case"updated":{w=new Date(g.metadata.updatedAt).getTime(),S=new Date(y.metadata.updatedAt).getTime();break}case"status":{w=g.status,S=y.status;break}case"priority":{const z={critical:4,high:3,medium:2,low:1};w=z[g.metadata.priority]||0,S=z[y.metadata.priority]||0;break}case"intent":{w=(g.title||g.intent||"").toLowerCase(),S=(y.title||y.intent||"").toLowerCase();break}default:w=new Date(g.metadata.createdAt).getTime(),S=new Date(y.metadata.createdAt).getTime()}return F==="asc"?w<S?-1:w>S?1:0:w>S?-1:w<S?1:0}),l(i)},[n,f,x,C,v,F,Ne]);const Y=Math.max(1,Math.ceil(c.length/q)),$=Math.min(ie,Y),Pe=c.slice(($-1)*q,$*q);return h?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your agents"})]}),t.jsx(P,{asChild:!0,children:t.jsxs(te,{to:"/tasks/new",children:[t.jsx(ue,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsx("div",{className:"text-center",children:t.jsxs("p",{className:"text-destructive",children:["Error: ",h]})})})})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your agents"})]}),t.jsx(P,{asChild:!0,children:t.jsxs(te,{to:"/tasks/new",children:[t.jsx(ue,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx(tt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),t.jsx(We,{ref:_,placeholder:"Search tasks...",value:C,onChange:i=>b(i.target.value),className:"pl-9 pr-20 h-11 bg-muted/40 border-muted-foreground/20 focus:bg-background transition-colors"}),t.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-2",children:C?t.jsx("button",{onClick:()=>b(""),className:"h-5 w-5 rounded-full bg-muted-foreground/20 hover:bg-muted-foreground/30 flex items-center justify-center transition-colors",children:t.jsx(X,{className:"h-3 w-3"})}):t.jsx(Ue,{children:t.jsx(Ge,{children:"S"})})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:()=>R(!E),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:[t.jsx(be,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Filters & Sort"}),t.jsx("span",{className:"sm:hidden",children:"Filters"}),G>0&&t.jsx("span",{className:"flex items-center justify-center h-5 w-5 text-xs font-bold rounded-full bg-primary text-primary-foreground",children:G}),E?t.jsx(st,{className:"h-4 w-4 ml-1"}):t.jsx(He,{className:"h-4 w-4 ml-1"})]}),t.jsxs("div",{className:"flex-1 flex items-center gap-2 overflow-x-auto scrollbar-hide",children:[f!=="_default"&&t.jsxs("button",{onClick:()=>I("_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:[f==="all"?"All statuses":Ee(f),t.jsx(X,{className:"h-3 w-3"})]}),x!=="all"&&t.jsxs("button",{onClick:()=>Q("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:[x," priority",t.jsx(X,{className:"h-3 w-3"})]}),(v!=="created"||F!=="desc")&&t.jsxs("button",{onClick:()=>{W("created"),L("desc"),N({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:[v," ",F==="asc"?"↑":"↓",t.jsx(X,{className:"h-3 w-3"})]})]}),!u&&t.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[c.length," result",c.length!==1?"s":""]})]}),E&&t.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:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Status"}),t.jsxs(oe,{value:f,onValueChange:I,children:[t.jsx(he,{className:"w-full bg-background",children:t.jsx(de,{placeholder:"Filter by status"})}),t.jsxs(me,{children:[t.jsx(B,{value:"_default",children:"Active (Default)"}),t.jsx(B,{value:"all",children:"All statuses"}),qe.map(i=>t.jsx(B,{value:i,children:Ee(i)},i))]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Priority"}),t.jsxs(oe,{value:x,onValueChange:Q,children:[t.jsx(he,{className:"w-full bg-background",children:t.jsx(de,{placeholder:"Filter by priority"})}),t.jsxs(me,{children:[t.jsx(B,{value:"all",children:"All priorities"}),t.jsx(B,{value:"low",children:"Low"}),t.jsx(B,{value:"medium",children:"Medium"}),t.jsx(B,{value:"high",children:"High"}),t.jsx(B,{value:"critical",children:"Critical"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Sort By"}),t.jsxs(oe,{value:v,onValueChange:i=>W(i),children:[t.jsx(he,{className:"w-full bg-background",children:t.jsx(de,{})}),t.jsxs(me,{children:[t.jsx(B,{value:"created",children:"Created Date"}),t.jsx(B,{value:"updated",children:"Updated Date"}),t.jsx(B,{value:"status",children:"Status"}),t.jsx(B,{value:"priority",children:"Priority"}),t.jsx(B,{value:"intent",children:"Title"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Order"}),t.jsx(P,{variant:"outline",onClick:ee,className:"w-full justify-between bg-background",children:F==="asc"?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Ascending"}),t.jsx(ct,{className:"h-4 w-4"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Descending"}),t.jsx(at,{className:"h-4 w-4"})]})})]})]}),G>0&&t.jsx("div",{className:"pt-2 border-t border-muted-foreground/10",children:t.jsxs(P,{variant:"ghost",size:"sm",onClick:()=>{I("_default"),Q("all"),b("")},className:"text-muted-foreground hover:text-foreground",children:[t.jsx(X,{className:"h-3 w-3 mr-1"}),"Reset all filters"]})})]})]}),u?t.jsx("div",{className:"space-y-3",children:Array.from({length:6}).map((i,g)=>t.jsx(J,{className:"overflow-hidden",children:t.jsx(Z,{className:"py-4",children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsx("div",{className:"h-5 bg-muted rounded w-2/3 animate-pulse"}),t.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[t.jsx("div",{className:"h-5 w-14 bg-muted rounded-full animate-pulse"}),t.jsx("div",{className:"h-5 w-14 bg-muted rounded-full animate-pulse"})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("div",{className:"h-3.5 bg-muted rounded w-full animate-pulse"}),t.jsx("div",{className:"h-3.5 bg-muted rounded w-4/5 animate-pulse"})]}),t.jsxs("div",{className:"flex justify-between items-center pt-1",children:[t.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"}),t.jsx("div",{className:"h-3 bg-muted rounded w-1/6 animate-pulse"})]})]})})},g))}):c.length===0&&n.length>0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(be,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No tasks match your filters"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try adjusting your status or priority filters."}),t.jsx(P,{variant:"outline",className:"mt-4",onClick:()=>{I("_default"),Q("all"),b("")},children:"Clear Filters"})]})})}):n.length===0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Qe,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No tasks yet"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first task to get started."}),t.jsx(P,{asChild:!0,className:"mt-4",children:t.jsxs(te,{to:"/tasks/new",children:[t.jsx(ue,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"space-y-3",children:Pe.map(i=>t.jsx(te,{to:`/tasks/${i.id}`,className:"block",children:t.jsx(J,{className:"hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:t.jsx(Z,{className:"py-4",children:t.jsx("div",{className:"flex justify-between items-start gap-4",children:t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsx(Je,{className:"text-base leading-tight",children:i.title||i.intent}),t.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[i.metadata.priority&&t.jsx(se,{variant:Qt(i.metadata.priority),className:"text-xs",children:i.metadata.priority}),t.jsx(se,{variant:et(i.status),className:"text-xs",children:i.status})]})]}),i.content&&t.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[i.content.split(`
|
|
17
|
+
`).slice(0,2).join(" ").substring(0,150),i.content.length>150?"...":""]}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"text-xs text-muted-foreground",children:[i.id," • by ",i.author.name," • ",new Date(i.metadata.createdAt).toLocaleDateString()]}),t.jsxs("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[i.planSteps.length>0&&t.jsxs("span",{children:[i.planSteps.length," step",i.planSteps.length!==1?"s":""]}),i.metadata.tags&&i.metadata.tags.length>0&&t.jsxs("span",{children:[i.metadata.tags.length," tag",i.metadata.tags.length!==1?"s":""]})]})]}),i.metadata.tags&&i.metadata.tags.length>0&&t.jsxs("div",{className:"flex gap-1 mt-2",children:[i.metadata.tags.slice(0,3).map(g=>t.jsx(se,{variant:"outline",className:"text-xs",children:g},g)),i.metadata.tags.length>3&&t.jsxs(se,{variant:"outline",className:"text-xs",children:["+",i.metadata.tags.length-3]})]})]})})})})},i.id))}),Y>1&&t.jsxs("div",{className:"flex items-center justify-between pt-2",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",($-1)*q+1,"–",Math.min($*q,c.length)," of ",c.length]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(P,{variant:"outline",size:"sm",disabled:$<=1,onClick:()=>ce($-1),children:t.jsx(rt,{className:"h-4 w-4"})}),Array.from({length:Y},(i,g)=>g+1).filter(i=>i===1||i===Y||Math.abs(i-$)<=1).reduce((i,g,y,w)=>(y>0&&g-w[y-1]>1&&i.push("ellipsis"),i.push(g),i),[]).map((i,g)=>i==="ellipsis"?t.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:"…"},`e${g}`):t.jsx(P,{variant:i===$?"default":"outline",size:"sm",className:"min-w-[2rem]",onClick:()=>ce(i),children:i},i)),t.jsx(P,{variant:"outline",size:"sm",disabled:$>=Y,onClick:()=>ce($+1),children:t.jsx(Ye,{className:"h-4 w-4"})})]})]})]})]})}export{rs as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as U,a as J,r as i,j as e,B as r,T as C,n as K,X as L,t as H,a1 as G}from"./index-DFcWlnzl.js";import{C as p,a as W}from"./card-BcPlIAH5.js";import{u as X}from"./use-terminal-BXJqOeJe.js";import{T as _}from"./terminal-preview-DN38x9Jm.js";/* empty css */import{R as q}from"./refresh-cw-B3OwrDUf.js";import{C as Q,a as V}from"./chevrons-up-DTvCkIHc.js";import{C as Y}from"./chevron-up-CqM3won3.js";import{P as M}from"./play-CHIf-Rcz.js";import{C as Z}from"./circle-play-BrY_lNiH.js";import"./xterm-DTxiCjtJ.js";function he(){const m=U(),{sessions:f,loading:d,error:S,refreshSessions:h,createSession:j,destroySession:B}=X(),{toast:l}=J(),[x,u]=i.useState(""),[g,T]=i.useState(!1),[v,I]=i.useState(!1),[N,$]=i.useState([]),[,w]=i.useState(null),O=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const b=Math.floor(n/60);if(b<60)return`${b}m ago`;const k=Math.floor(b/60);return k<24?`${k}h ago`:`${Math.floor(k/24)}d ago`};i.useEffect(()=>{h()},[h]),i.useEffect(()=>{y(s=>{const t={...s};return f.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[f]),i.useEffect(()=>{try{const s=localStorage.getItem("terminal.commandHistory");s&&$(JSON.parse(s))}catch{}},[]);const D=s=>{s&&($(t=>{const a=[s,...t.filter(n=>n!==s)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a}),w(null))},c=f.filter(s=>!s.taskId?.startsWith("cp-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[o,y]=i.useState(()=>{const s={};return f.forEach(t=>{s[t.id]=!0}),s}),R=async()=>{const s=`session-${Date.now()}`;await j(s)&&(l({title:"New terminal started",description:`${s}`}),m(`/terminal/${s}`))},E=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;T(!0);try{await j(t,s)?(D(s),l({title:"Session started",description:`${t}`}),m(`/terminal/${t}`)):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{T(!1)}},A=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;I(!0);try{await j(t,s)?(D(s),setTimeout(()=>h(),150),u(""),l({title:"Started in background",description:`${t}`,action:e.jsx(G,{altText:"Open session",onClick:()=>m(`/terminal/${t}`),children:"Open"})})):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{I(!1)}},P=async s=>{await B(s)?(l({title:"Session closed",description:s}),setTimeout(()=>h(),100)):l({title:"Failed to close session",description:s,variant:"destructive"})},F=()=>{const s=c.every(a=>o[a.id]),t={};c.forEach(a=>{t[a.id]=!s}),y(t)},z=c.length>0&&c.every(s=>o[s.id]);return 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:"Terminal"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage terminal sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",onClick:()=>h(),disabled:d,children:[e.jsx(q,{className:`h-4 w-4 sm:mr-2 ${d?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),c.length>0&&e.jsx(r,{variant:"outline",onClick:F,children:z?e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{onClick:R,disabled:d,children:[e.jsx(C,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})]}),S&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:S})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),d?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(p,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):c.length===0?e.jsx(p,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(C,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching a new terminal session with the"," ",e.jsx("button",{onClick:R,className:"text-primary hover:underline font-medium",children:"New Terminal"})," ","button above."]})]})]})}):e.jsx("div",{className:"space-y-2",children:c.slice(0,10).map(s=>e.jsxs(p,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(C,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.taskId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",O(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{y(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":o[s.id]?"Hide preview":"Show preview",title:o[s.id]?"Hide preview":"Show preview",children:o[s.id]?e.jsx(Y,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})}),e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(`/terminal/${s.taskId}`),children:[e.jsx(M,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Open"})]}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>P(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(L,{className:"h-4 w-4"})})]})]}),o[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>m(`/terminal/${s.taskId}`),title:"Click to open full terminal session",children:e.jsx(_,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Run Custom Command"}),e.jsx(p,{children:e.jsxs(W,{className:"py-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:x,onChange:s=>u(s.target.value),onKeyDown:s=>{s.key==="Enter"?(s.preventDefault(),s.shiftKey?A():E()):s.key==="ArrowUp"?(s.preventDefault(),w(t=>{const a=t===null?0:Math.min((t??0)+1,N.length-1),n=N[a];return n&&u(n),a})):s.key==="ArrowDown"&&(s.preventDefault(),w(t=>{if(t===null)return null;const a=t-1;if(a<0)return u(""),null;const n=N[a];return n&&u(n),a}))},placeholder:"npm run dev",className:"flex-1 h-9 rounded-md border px-3 text-sm bg-white dark:bg-gray-900 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400"}),e.jsxs(r,{onClick:A,variant:"secondary",disabled:d||!x.trim()||v||g,children:[v?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-1"}):e.jsx(Z,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),e.jsxs(r,{onClick:E,disabled:d||!x.trim()||g||v,children:[g?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(M,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Run"})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Enter to Run • Shift+Enter to Run in background"})]})})]})]})}export{he as default};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{c as Ye,j as e,B as v,a2 as Me,a3 as We,a4 as Le,a5 as Re,a6 as Be,a7 as Xe,p as de,r as a,a8 as Qe,x as et,q as tt,u as rt,w as st,a as at,T as ve,X as je,P as ye,k as we,l as nt,a9 as ze,Z as it,G as ct,D as ot,b as lt,d as dt,f as mt,n as De,aa as Fe,ab as ut,A as me}from"./index-DFcWlnzl.js";import{C as ht,a as xt}from"./card-BcPlIAH5.js";import{B as Je}from"./badge-BUEY53dV.js";import{S as ke,a as Ne,b as Se,c as Ce,d as _}from"./select-44mcS2_G.js";import{R as ft,a as Ae}from"./radio-group-C1ct-VsJ.js";import{C as gt}from"./CollapsibleSection-M5cXbl92.js";import{L as fe}from"./label-DBuh-ke5.js";import{u as pt}from"./use-terminal-BXJqOeJe.js";import{x as bt,a as vt}from"./xterm-DTxiCjtJ.js";import{A as jt}from"./arrow-down-DmW_3gE8.js";/* empty css */import{b as Ue,a as yt,c as wt,d as kt,e as Nt}from"./kiro-CX1mOsRO.js";import{C as Te}from"./code-DrYqPukx.js";import{R as St}from"./refresh-cw-B3OwrDUf.js";import{P as Ee}from"./play-CHIf-Rcz.js";import{E as Ct}from"./eye-DLFBnC8t.js";import{M as At}from"./message-square-B5RWz_ff.js";import"./chevron-up-CqM3won3.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 Tt=[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],Et=Ye("book-marked",Tt);var Pe={exports:{}},Ge;function Pt(){return Ge||(Ge=1,(function(r,T){(function(E,C){r.exports=C()})(self,(()=>(()=>{var E={6:(d,o)=>{function g(m){try{const n=new URL(m),l=n.password&&n.username?`${n.protocol}//${n.username}:${n.password}@${n.host}`:n.username?`${n.protocol}//${n.username}@${n.host}`:`${n.protocol}//${n.host}`;return m.toLocaleLowerCase().startsWith(l.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(o,"__esModule",{value:!0}),o.LinkComputer=o.WebLinkProvider=void 0,o.WebLinkProvider=class{constructor(m,n,l,h={}){this._terminal=m,this._regex=n,this._handler=l,this._options=h}provideLinks(m,n){const l=z.computeLink(m,this._regex,this._terminal,this._handler);n(this._addCallbacks(l))}_addCallbacks(m){return m.map((n=>(n.leave=this._options.leave,n.hover=(l,h)=>{if(this._options.hover){const{range:x}=n;this._options.hover(l,h,x)}},n)))}};class z{static computeLink(n,l,h,x){const D=new RegExp(l.source,(l.flags||"")+"g"),[k,f]=z._getWindowedLineStrings(n-1,h),j=k.join("");let u;const P=[];for(;u=D.exec(j);){const p=u[0];if(!g(p))continue;const[B,y]=z._mapStrIdx(h,f,0,u.index),[Z,V]=z._mapStrIdx(h,B,y,p.length);if(B===-1||y===-1||Z===-1||V===-1)continue;const ee={start:{x:y+1,y:B+1},end:{x:V,y:Z+1}};P.push({range:ee,text:p,activate:x})}return P}static _getWindowedLineStrings(n,l){let h,x=n,D=n,k=0,f="";const j=[];if(h=l.buffer.active.getLine(n)){const u=h.translateToString(!0);if(h.isWrapped&&u[0]!==" "){for(k=0;(h=l.buffer.active.getLine(--x))&&k<2048&&(f=h.translateToString(!0),k+=f.length,j.push(f),h.isWrapped&&f.indexOf(" ")===-1););j.reverse()}for(j.push(u),k=0;(h=l.buffer.active.getLine(++D))&&h.isWrapped&&k<2048&&(f=h.translateToString(!0),k+=f.length,j.push(f),f.indexOf(" ")===-1););}return[j,x]}static _mapStrIdx(n,l,h,x){const D=n.buffer.active,k=D.getNullCell();let f=h;for(;x;){const j=D.getLine(l);if(!j)return[-1,-1];for(let u=f;u<j.length;++u){j.getCell(u,k);const P=k.getChars();if(k.getWidth()&&(x-=P.length||1,u===j.length-1&&P==="")){const p=D.getLine(l+1);p&&p.isWrapped&&(p.getCell(0,k),k.getWidth()===2&&(x+=1))}if(x<0)return[l,u]}l++,f=0}return[l,f]}}o.LinkComputer=z}},C={};function A(d){var o=C[d];if(o!==void 0)return o.exports;var g=C[d]={exports:{}};return E[d](g,g.exports,A),g.exports}var M={};return(()=>{var d=M;Object.defineProperty(d,"__esModule",{value:!0}),d.WebLinksAddon=void 0;const o=A(6),g=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function z(m,n){const l=window.open();if(l){try{l.opener=null}catch{}l.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}d.WebLinksAddon=class{constructor(m=z,n={}){this._handler=m,this._options=n}activate(m){this._terminal=m;const n=this._options,l=n.urlRegex||g;this._linkProvider=this._terminal.registerLinkProvider(new o.WebLinkProvider(this._terminal,l,this._handler,n))}dispose(){this._linkProvider?.dispose()}}})(),M})()))})(Pe)),Pe.exports}var Mt=Pt();const Wt=[{label:"Save to knowledge base",command:"Save this to the knowledge base (.nut/knowledge/) using the following schema as reference .nut/.schema/knowledge.schema.md",description:"Save content to knowledge base with schema reference"},{label:"Update project document",command:"Update the project document (.nut/context/project.md) using the following schema as reference .nut/.schema/project.schema.md",description:"Update project.md using schema reference"},{label:"Update architecture document",command:"Update the architecture document (.nut/context/architecture.md) using the following schema as reference .nut/.schema/architecture.schema.md",description:"Update architecture.md using schema reference"}];function Lt({onJumpToBottom:r,onSnippet:T,onSendKey:E}){return e.jsxs("div",{className:"w-full border-t border-gray-700/50 bg-[#252525] px-4 py-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsxs(v,{variant:"outline",size:"sm",onClick:r,className:"h-8 text-xs bg-[#2d2d2d] border-gray-600 hover:bg-[#3d3d3d] text-gray-200 hover:text-white transition-colors",title:"Jump to bottom and set focus",children:[e.jsx(jt,{className:"h-3.5 w-3.5 sm:mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Jump to Bottom"})]}),T&&e.jsxs(Me,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:"h-8 text-xs bg-[#2d2d2d] border-gray-600 hover:bg-[#3d3d3d] text-gray-200 hover:text-white transition-colors",children:[e.jsx(Et,{className:"h-3.5 w-3.5 sm:mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Snippets"})]})}),e.jsxs(Le,{align:"start",className:"w-72",children:[e.jsx(Re,{children:"Command Snippets"}),e.jsx(Be,{}),Wt.map((C,A)=>e.jsxs(Xe,{onClick:()=>T(C.command),className:"cursor-pointer flex flex-col items-start py-2",children:[e.jsx("span",{className:"font-medium",children:C.label}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono mt-0.5",children:C.command})]},A))]})]})]}),E&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>E(""),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-red-900/40 hover:border-red-700 text-gray-200 hover:text-red-300 transition-colors",title:"Send Ctrl+C (interrupt)",children:[e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"⌃"}),e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"C"})]}),e.jsxs("button",{onClick:()=>E(""),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-[#3d3d3d] hover:border-gray-500 text-gray-200 hover:text-white transition-colors",title:"Send Ctrl+Z (suspend)",children:[e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"⌃"}),e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"Z"})]}),e.jsx("button",{onClick:()=>E("\x1B"),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-[#3d3d3d] hover:border-gray-500 text-gray-200 hover:text-white transition-colors",title:"Send Escape key",children:e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"Esc"})})]})]})}function Rt({sessionId:r,onResize:T,onDestroy:E,pendingCommand:C,onCommandExecuted:A,showToolbar:M=!0,onSnippet:d}){const o=a.useRef(null),g=a.useRef(null),z=a.useRef(null),m=a.useRef(null),[n,l]=a.useState(!1),[h,x]=a.useState(null),[D,k]=a.useState(!0),f=a.useRef(0),j=5,u=a.useRef(null),P=a.useRef(null),p=a.useRef(C??null),B=a.useRef(!1),y=a.useRef(null),Z=a.useRef(A),V=a.useRef(E),ee=a.useRef(T);a.useEffect(()=>{Z.current=A},[A]),a.useEffect(()=>{V.current=E},[E]),a.useEffect(()=>{ee.current=T},[T]);const te=a.useCallback(N=>{!p.current||B.current||(y.current!==null&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>{if(!p.current||B.current){y.current=null;return}m.current?.readyState===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"input",data:p.current+"\r"})),B.current=!0,Z.current?.()),y.current=null},N))},[]);a.useEffect(()=>{if(p.current=C??null,B.current=!1,!p.current){y.current!==null&&(window.clearTimeout(y.current),y.current=null);return}const N=m.current?.readyState===WebSocket.OPEN;return te(N?200:800),()=>{y.current!==null&&(window.clearTimeout(y.current),y.current=null)}},[C,r,te]),a.useEffect(()=>{l(!1),k(!0),x(null)},[r]),a.useEffect(()=>{if(!o.current||!r)return;const N=S=>{const b=S.getBoundingClientRect();return b.width>0&&b.height>0},W=new bt.Terminal({cursorBlink:!0,fontSize:14,fontFamily:"'IBM Plex Mono', 'Source Code Pro', 'Fira Code', ui-monospace, Menlo, Monaco, monospace",lineHeight:1.35,letterSpacing:.5,convertEol:!0,theme:{background:"#1a1b26",foreground:"#c0caf5",cursor:"#c0caf5",cursorAccent:"#1a1b26",selectionBackground:"#33467c",selectionForeground:"#c0caf5",black:"#15161e",red:"#f7768e",green:"#9ece6a",yellow:"#e0af68",blue:"#7aa2f7",magenta:"#bb9af7",cyan:"#7dcfff",white:"#a9b1d6",brightBlack:"#414868",brightRed:"#f7768e",brightGreen:"#9ece6a",brightYellow:"#e0af68",brightBlue:"#7aa2f7",brightMagenta:"#bb9af7",brightCyan:"#7dcfff",brightWhite:"#c0caf5"}}),O=new vt.FitAddon,Y=new Mt.WebLinksAddon;W.loadAddon(O),W.loadAddon(Y),W.open(o.current),g.current=W,z.current=O;let L=null,X=null;const R=()=>{if(!W||!W.element||!W.element.parentElement)return;const S=W.cols??0,b=W.rows??0;if(S>0&&b>0){m.current?.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:S,rows:b}));const $=ee.current;$&&$(S,b)}},H=()=>{const S=o.current;if(S&&N(S)&&!(!W||!W.element||!W.element.parentElement))try{const b=S.getBoundingClientRect();if(b.width<10||b.height<10)return;O.fit(),R()}catch(b){console.warn("xterm fit() failed, will retry if needed:",b)}},J=()=>{L&&cancelAnimationFrame(L),L=requestAnimationFrame(()=>{H()})},ce=()=>{if(!r)return;u.current&&(window.clearTimeout(u.current),u.current=null);const S=`${Qe}/ws/terminal/${r}`,b=new WebSocket(S);return m.current=b,b.onopen=()=>{l(!0),x(null),f.current=0,console.log("Terminal WebSocket connected"),P.current&&window.clearInterval(P.current),P.current=window.setInterval(()=>{b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"keepalive"}))},120*1e3),J(),setTimeout(()=>{k(!1),J(),setTimeout(()=>J(),50),setTimeout(()=>J(),150)},400),te(1200)},b.onmessage=$=>{try{const w=JSON.parse($.data);switch(w.type){case"snapshot":if(typeof w.data=="string"&&w.data.length&&g.current){const U=g.current;U.write(w.data,()=>{U.scrollToBottom()})}break;case"data":if(g.current){const U=g.current,ae=U.buffer.active.viewportY+U.rows>=U.buffer.active.baseY+U.buffer.active.cursorY;U.write(w.data,()=>{ae&&U.scrollToBottom()})}break;case"exit":g.current&&g.current.write(`\r
|
|
7
|
+
\x1B[31mProcess exited with code ${w.exitCode}\x1B[0m\r
|
|
8
|
+
`),V.current?.();break}}catch(w){console.error("Error parsing WebSocket message:",w)}},b.onclose=$=>{if(l(!1),console.log("Terminal WebSocket disconnected",$.code,$.reason),P.current&&(window.clearInterval(P.current),P.current=null),$.code!==1e3&&f.current<j&&r){f.current++;const w=Math.min(1e3*Math.pow(2,f.current-1),1e4);console.log(`Attempting to reconnect (${f.current}/${j}) in ${w}ms`),u.current=window.setTimeout(()=>{ce()},w)}else f.current>=j&&x("Connection lost. Please refresh the page to reconnect.")},b.onerror=$=>{console.error("Terminal WebSocket error:",$),f.current===0&&x("WebSocket connection failed")},b};ce(),W.onData(S=>{m.current?.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:S}))});const I=()=>{J()},oe=new ResizeObserver(I);o.current&&oe.observe(o.current),window.addEventListener("resize",I),window.addEventListener("orientationchange",I);const se=()=>{document.visibilityState==="visible"&&(X&&clearTimeout(X),X=window.setTimeout(()=>{J()},50))};document.addEventListener("visibilitychange",se);let he=0;const Oe=20,xe=()=>{const S=o.current;if(S){if(N(S)){H();return}he+=1,he<Oe?L=requestAnimationFrame(xe):X=window.setTimeout(()=>{H()},100)}};return L=requestAnimationFrame(xe),()=>{oe.disconnect(),window.removeEventListener("resize",I),window.removeEventListener("orientationchange",I),document.removeEventListener("visibilitychange",se),L&&cancelAnimationFrame(L),X&&clearTimeout(X),u.current&&(window.clearTimeout(u.current),u.current=null),P.current&&(window.clearInterval(P.current),P.current=null),m.current?.readyState===WebSocket.OPEN&&m.current.close(),y.current!==null&&(window.clearTimeout(y.current),y.current=null),W.dispose()}},[r,te]);const re=a.useCallback(()=>{g.current&&(g.current.scrollToBottom(),g.current.focus())},[]),F=a.useCallback(N=>{m.current?.readyState===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"input",data:N})),g.current&&g.current.focus())},[]),ue=a.useCallback(N=>{m.current?.readyState===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"input",data:N})),g.current&&g.current.focus())},[]);return h?e.jsx("div",{className:"flex items-center justify-center h-full bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-red-600 font-medium",children:"Terminal Connection Error"}),e.jsx("div",{className:"text-red-500 text-sm mt-1",children:h})]})}):e.jsxs("div",{className:"relative h-full flex flex-col bg-[#1a1b26] overflow-hidden",children:[!n&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#1a1b26] bg-opacity-95 z-10 backdrop-blur-sm",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto"}),e.jsx("div",{className:"text-gray-300 mt-2",children:"Connecting to terminal..."})]})}),n&&D&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#1a1b26] bg-opacity-50 z-10 transition-opacity duration-300 backdrop-blur-sm",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-pulse rounded-full h-6 w-6 bg-blue-500 mx-auto"}),e.jsx("div",{className:"text-gray-300 text-sm mt-2",children:"Loading terminal..."})]})}),e.jsx("div",{ref:o,className:"flex-1 w-full overflow-hidden",style:{minHeight:"400px"}}),M&&e.jsx(Lt,{onJumpToBottom:re,onSnippet:d||F,onSendKey:ue})]})}const Bt=r=>r?Array.isArray(r)?r.filter(T=>typeof T=="string").map(T=>T.trim()).filter(Boolean):typeof r=="string"?r.split(",").map(T=>T.trim()).filter(Boolean):[]:[];function tr(){const{taskId:r}=et(),T=tt(),E=rt(),[C]=st(),{toast:A}=at(),M=r?.startsWith("session-"),d=a.useMemo(()=>!!r&&r.startsWith("cp-"),[r]),o=a.useMemo(()=>!!r&&r.startsWith("sk-"),[r]),g=C.get("reviewOnly")==="true",z=C.get("startOnly")==="true",m=d&&!z,n=!g,l=a.useMemo(()=>o&&r?r.replace("sk-",""):null,[o,r]),{sessions:h,loading:x,error:D,createSession:k,destroySession:f,refreshSessions:j}=pt(),[u,P]=a.useState([]),[p,B]=a.useState(null),[y,Z]=a.useState(null),[V,ee]=a.useState("claude"),[te,re]=a.useState(!1),[F,ue]=a.useState("claude"),[N,W]=a.useState([]),[O,Y]=a.useState([]),[L,X]=a.useState([]),[R,H]=a.useState([]),[J,ce]=a.useState(!0),[I,oe]=a.useState(""),[se,he]=a.useState(!1),[Oe,xe]=a.useState({}),[S,b]=a.useState(null),$=a.useRef([]),[w,U]=a.useState("current"),[ae,qe]=a.useState("main"),Q=a.useMemo(()=>r?`terminal.cp.config.${r}`:null,[r]);a.useEffect(()=>{if(!(!d&&!o||!Q))try{const t=localStorage.getItem(Q);if(t){const s=JSON.parse(t);s.cliAgent&&ue(s.cliAgent),Array.isArray(s.selectedMcpServers)&&Y(s.selectedMcpServers),Array.isArray(s.selectedSkillIds)&&H(s.selectedSkillIds),typeof s.automationEnabled=="boolean"&&ce(s.automationEnabled),typeof s.customInstruction=="string"&&oe(s.customInstruction),typeof s.createWorktree=="boolean"&&he(s.createWorktree),s.branchMode&&U(s.branchMode)}}catch{console.error("Failed to load config",Q)}},[d,o,Q]);const ge=a.useCallback(()=>{if(!Q)return;const t={cliAgent:F,selectedMcpServers:O,selectedSkillIds:R,automationEnabled:J,customInstruction:I,createWorktree:se,branchMode:w};try{localStorage.setItem(Q,JSON.stringify(t))}catch{console.error("Failed to persist config",Q)}},[Q,F,O,R,J,I,se,w]);a.useEffect(()=>{ge()},[I,ge]);const ne=t=>`feat/cp-${t.startsWith("cp-")?t.slice(5):t}`,Ve=async t=>{try{const s=ne(t),c=await(await fetch(`${me}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,from:ae})})).json();if(!c.success){const G=c.error?.message||"Unknown error";return A({title:"Branch creation failed",description:G,variant:"destructive"}),!1}return A({title:"Branch created",description:`Created branch: ${s}`}),!0}catch{return A({title:"Branch creation failed",description:"Network error or invalid response",variant:"destructive"}),!1}},Ie=async t=>{try{const s=ne(t),c=await(await fetch(`${me}/api/v1/git/worktrees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:s,from:ae})})).json();if(!c.success){const G=c.error?.message||"Unknown error";return A({title:"Worktree creation failed",description:G,variant:"destructive"}),!1}return A({title:"Worktree created",description:`Created branch: ${s}`}),!0}catch{return A({title:"Worktree creation failed",description:"Network error or invalid response",variant:"destructive"}),!1}};a.useEffect(()=>{(d||o)&&r&&(async()=>{try{const s=await fetch(`${me}/api/v1/git/status`);if(s.ok){const c=await s.json();c?.success&&c.data?.branch&&qe(c.data.branch)}const i=await fetch(`${me}/api/v1/mcp`);if(i.ok){const c=await i.json();c?.success&&Array.isArray(c.servers)&&(W(c.servers),Y(G=>G.filter(q=>c.servers.includes(q))),c.mcpServers&&typeof c.mcpServers=="object"&&xe(c.mcpServers))}}catch(s){console.error("Failed to load MCP servers",s)}try{const s=await fetch(`${me}/api/v1/skills`);if(s.ok){const i=await s.json(),G=(Array.isArray(i?.documents)?i.documents:[]).map(q=>({id:q.id,name:q?.metadata?.name||q.id,mcpServers:Bt(q?.metadata?.metadata?.mcpServers)}));X(G),H(q=>{const le=q.filter(K=>G.some(be=>be.id===K));if(o&&l&&le.length===0){const K=G.find(be=>be.id===l);if(K)return[K.id]}return le})}}catch(s){console.error("Failed to load skills",s)}})()},[d,o,r,l]),a.useEffect(()=>{const t=$.current,s=R.filter(i=>!t.includes(i));s.length>0&&Y(i=>{const c=new Set(i),G=N.length>0?new Set(N):void 0;return s.forEach(q=>{const le=L.find(K=>K.id===q);le&&le.mcpServers.forEach(K=>{(!G||G.has(K))&&c.add(K)})}),Array.from(c)}),$.current=R},[R,L,N]),a.useEffect(()=>{r&&j(r)},[r,j]),a.useEffect(()=>{if(!r)return;const s=h.filter(i=>i.taskId===r).map(i=>i.id);P(s),!p&&s.length>0&&B(s[0]),p&&!s.includes(p)&&B(s.length>0?s[0]:null)},[h,r,p]);const ie=async t=>{if(!r)return;const s=t||void 0,i=await k(r,s);i&&(B(i),!s&&t&&Z(t),setTimeout(()=>j(r),100))},$e=(t,s)=>{const c={taskId:r,contextType:s??(d?"change-task":o?"skill":"general"),selectedMcpServers:O,selectedSkillIds:R,automationEnabled:J,customInstruction:I};switch(t){case"claude":return Ue(c);case"gemini":return Nt(c);case"codex":return kt(c);case"droid":return wt(c);case"kiro":return yt(c);default:return Ue(c)}},pe=async()=>{d&&r&&(w==="new-branch"?await Ve(r)||console.warn("Branch creation failed, continuing with terminal creation"):w==="new-worktree"&&(await Ie(r)||console.warn("Worktree creation failed, continuing with terminal creation"))),d&&se&&w==="current"&&r&&(await Ie(r)||console.warn("Worktree creation failed, continuing with terminal creation"));const s=$e(d||o?F:V);await ie(s)},He=async()=>{const s=$e(F,"prepare-task");await ie(s)},_e=async t=>{if(await f(t)&&p===t){const i=u.filter(c=>c!==t);i.length>0?B(i[0]):r?.startsWith("session-")?E("/agents"):B(null)}},Ke=t=>{_e(t)},Ze=async()=>{for(const t of u)await f(t);E("/agents")};return r?e.jsxs("div",{className:"flex flex-col h-full",children:[M&&u.length===0&&r&&e.jsx(Ot,{taskId:r,onStart:ie,locationSearch:T.search}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-lg",children:d||o?e.jsx(Te,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(ve,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:M?"Terminal":"Agent Session"}),!M&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 font-mono",children:r}),M&&e.jsxs("span",{className:"text-sm text-gray-500 font-mono",children:["(",r,")"]})]})]})}),e.jsx("div",{className:"flex items-center gap-2 sm:gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>r&&j(r),disabled:x,className:"bg-white dark:bg-gray-800",children:[e.jsx(St,{className:`h-4 w-4 sm:mr-2 ${x?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),e.jsx(v,{size:"sm",variant:"destructive",onClick:Ze,title:"Close session","aria-label":"Close session",className:"h-9 w-9 p-0",children:e.jsx(je,{className:"h-4 w-4"})}),!M&&!d&&!o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ke,{value:V,onValueChange:ee,children:[e.jsx(Ne,{className:"w-24",children:e.jsx(Se,{})}),e.jsxs(Ce,{children:[e.jsx(_,{value:"claude",children:"Claude Code"}),e.jsx(_,{value:"gemini",children:"Google Gemini"}),e.jsx(_,{value:"codex",children:"OpenAI Codex"}),e.jsx(_,{value:"kiro",children:"Kiro"})]})]}),e.jsxs(v,{onClick:pe,disabled:x,size:"sm",variant:"default",className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Ee,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Start Agent"})]})]}),!d&&!o&&(!M||u.length===0)&&e.jsxs(v,{onClick:()=>ie(),disabled:x,size:"sm",children:[e.jsx(ye,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})})]}),D&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-1.5 bg-red-100 dark:bg-red-900/40 rounded-lg flex-shrink-0",children:e.jsx(je,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),e.jsx("div",{className:"text-red-800 dark:text-red-200 text-sm font-medium",children:D})]})}),u.length>0&&e.jsx("div",{className:"flex items-center gap-1 border-b dark:border-gray-700",children:u.map(t=>{const s=h.find(c=>c.id===t),i=p===t;return e.jsxs("div",{className:`flex items-center gap-2 px-4 py-3 border-b-1 cursor-pointer rounded-t-lg transition-all duration-200 ${i?"border-gray-400 bg-white dark:bg-gray-800 dark:border-gray-500 shadow-sm":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800 hover:border-gray-300"}`,onClick:()=>B(t),children:[e.jsx("div",{className:`p-1.5 rounded-md ${i?"bg-gray-200 dark:bg-gray-700":"bg-gray-100 dark:bg-gray-700"}`,children:e.jsx(ve,{className:`h-3.5 w-3.5 ${i?"text-gray-700 dark:text-gray-300":"text-gray-600 dark:text-gray-400"}`})}),e.jsxs("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["Terminal ",t.split("-").slice(-1)[0].substring(0,6)]}),e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${s?.connected?"bg-green-500":"bg-gray-400"}`}),e.jsx(v,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-red-100 dark:hover:bg-red-900/30 rounded-md opacity-60 hover:opacity-100 transition-opacity",onClick:c=>{c.stopPropagation(),_e(t)},children:e.jsx(je,{className:"h-3 w-3"})})]},t)})}),e.jsx("div",{className:"flex-1 min-h-0",children:u.length===0?e.jsx(ht,{className:"h-full",children:e.jsx(xt,{className:"flex items-center justify-center h-full p-8",children:e.jsxs("div",{className:"text-center w-full max-w-[33vw] min-w-[400px]",children:[e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-full w-fit mx-auto mb-2",children:d||o?e.jsx(we,{className:"h-8 w-8 text-gray-600 dark:text-gray-400"}):e.jsx(ve,{className:"h-8 w-8 text-gray-600 dark:text-gray-400"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100 mb-3",children:"Prepare Agent"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6 leading-relaxed",children:M?"Create a new terminal session":e.jsxs(e.Fragment,{children:["Configure the agent to start working on ",r,"."]})}),e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[!M&&!d&&!o&&e.jsxs("div",{className:"flex flex-col items-center gap-4 p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:[e.jsxs("div",{className:"w-full space-y-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Choose your AI agent"}),e.jsxs(ke,{value:V,onValueChange:ee,children:[e.jsx(Ne,{className:"w-full h-11 bg-white dark:bg-gray-800",children:e.jsx(Se,{})}),e.jsxs(Ce,{children:[e.jsx(_,{value:"claude",children:"Claude Code (default)"}),e.jsx(_,{value:"gemini",children:"Google Gemini"}),e.jsx(_,{value:"codex",children:"OpenAI Codex"}),e.jsx(_,{value:"kiro",children:"Kiro"})]})]})]}),e.jsxs(v,{onClick:pe,disabled:x,className:"bg-green-600 hover:bg-green-700 w-full h-11 text-base font-medium",size:"lg",children:[e.jsx(Ee,{className:"h-5 w-5 mr-2"}),"Start Agent"]}),e.jsxs("div",{className:"flex items-center gap-3 w-full",children:[e.jsx("div",{className:"flex-1 h-px bg-gray-300 dark:bg-gray-600"}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 font-medium",children:"or"}),e.jsx("div",{className:"flex-1 h-px bg-gray-300 dark:bg-gray-600"})]}),e.jsxs(v,{onClick:()=>ie(),disabled:x,variant:"outline",className:"w-full h-11 bg-white dark:bg-gray-800",size:"lg",children:[e.jsx(ye,{className:"h-5 w-5 mr-2"}),"New Terminal"]})]}),!M&&(d||o)&&e.jsxs("div",{className:"flex flex-col items-center gap-4 p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:[m&&e.jsxs(v,{onClick:He,disabled:x,className:"w-full bg-blue-600 hover:bg-blue-700 h-11 text-base font-medium",size:"lg",children:[e.jsx(Ct,{className:"h-5 w-5 mr-2"}),"Review & Prepare"]}),e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsxs(v,{variant:"outline",onClick:()=>re(!0),className:"flex-1 h-11 bg-white dark:bg-gray-800",size:"lg",children:[e.jsx(nt,{className:"h-5 w-5 mr-2"}),"Configure"]}),n&&e.jsxs(v,{onClick:pe,disabled:x,className:"flex-1 bg-green-600 hover:bg-green-700 h-11 text-base font-medium",size:"lg",children:[e.jsx(Ee,{className:"h-5 w-5 mr-2"}),"Start Agent"]})]}),e.jsxs("div",{className:"w-full space-y-3",children:[e.jsx("div",{className:"text-xs uppercase font-semibold text-gray-500 dark:text-gray-400",children:"Agent Configuration"}),e.jsxs("div",{className:"text-left text-sm text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Agent:"}),e.jsx("span",{className:"font-mono text-sm",children:F==="claude"?"Claude Code":F.charAt(0).toUpperCase()+F.slice(1)})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Te,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400 mt-0.5"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Skills:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:R.length?R.map(t=>{const s=L.find(i=>i.id===t);return e.jsx(Je,{variant:"secondary",className:"font-mono text-xs",children:s?.name||t},t)}):e.jsx("span",{className:"font-mono text-sm text-gray-500",children:"None"})})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ze,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400 mt-0.5"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"MCP Servers:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:O.length?O.map(t=>e.jsx(Je,{variant:"secondary",className:"font-mono text-xs",children:t},t)):e.jsx("span",{className:"font-mono text-sm text-gray-500",children:"None"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(it,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Full Environment Access:"}),e.jsx("span",{className:"font-mono text-sm",children:J?"Enabled":"Disabled"})]}),d&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ct,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Branch:"}),e.jsx("span",{className:"font-mono text-sm",children:w==="current"?`Current (${ae})`:w==="new-branch"?`New branch (${ne(r||"")})`:`New worktree (${ne(r||"")})`})]})]}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2 text-gray-700 dark:text-gray-300",children:[e.jsx(At,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),"Additional Instructions"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[I.length,"/500"]})]}),e.jsx("textarea",{className:"w-full min-h-[80px] rounded-md border p-3 text-sm bg-gray-50 dark:bg-gray-900/50 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 resize-none",placeholder:"Add specific instructions to guide the agent...",value:I,onChange:t=>oe(t.target.value),rows:3}),I.length>500&&e.jsx("div",{className:"text-xs text-red-600 mt-1",children:"Custom instruction is too long (max 500 characters)"})]})]})]}),M&&u.length===0&&e.jsx("div",{className:"p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:e.jsxs(v,{onClick:()=>ie(),disabled:x,className:"w-full h-11 text-base font-medium",size:"lg",children:[e.jsx(ye,{className:"h-5 w-5 mr-2"}),"New Terminal"]})})]})]})})}):p?e.jsx("div",{className:"h-full overflow-hidden rounded-b-lg",children:e.jsx(Rt,{sessionId:p,onDestroy:()=>Ke(p),pendingCommand:y,onCommandExecuted:()=>Z(null),showToolbar:!0})}):null}),e.jsx(ot,{open:te,onOpenChange:re,children:e.jsxs(lt,{className:"max-w-3xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(dt,{children:[e.jsx(mt,{children:"Configure Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Customize the agent's capabilities and configure it's environment."})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(we,{className:"h-4 w-4"}),"Agent"]}),e.jsxs(ke,{value:F,onValueChange:t=>ue(t),children:[e.jsx(Ne,{className:"w-full",children:e.jsx(Se,{placeholder:"Select agent"})}),e.jsxs(Ce,{children:[e.jsx(_,{value:"claude",children:"Claude Code"}),e.jsx(_,{value:"gemini",children:"Google Gemini"}),e.jsx(_,{value:"codex",children:"OpenAI Codex"}),e.jsx(_,{value:"droid",children:"Factory Droid"}),e.jsx(_,{value:"kiro",children:"Kiro"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Te,{className:"h-4 w-4"}),"Skills"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[R.length," of ",L.length," selected"]})]}),e.jsxs(Me,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:"w-full justify-between",children:[R.length===0?"Select skills...":R.length===L.length?"All skills selected":`${R.length} skill${R.length!==1?"s":""} selected`,e.jsx(De,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Le,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Skills"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),H(L.map(s=>s.id))},children:"All"}),e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),H([])},children:"None"})]})]}),e.jsx(Be,{}),L.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No skills found"}):L.map(t=>e.jsx(Fe,{checked:R.includes(t.id),onCheckedChange:s=>{H(i=>s?i.includes(t.id)?i:[...i,t.id]:i.filter(c=>c!==t.id))},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:t.name}),t.mcpServers.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",t.mcpServers.join(", ")]}),t.mcpServers.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},t.id))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ze,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[O.length," of ",N.length," selected"]})]}),e.jsxs(Me,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:"w-full justify-between",children:[O.length===0?"Select MCP servers...":O.length===N.length?"All servers selected":`${O.length} server${O.length!==1?"s":""} selected`,e.jsx(De,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Le,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),Y(N)},children:"All"}),e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),Y([])},children:"None"})]})]}),e.jsx(Be,{}),N.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No MCP servers found"}):N.map(t=>e.jsx(Fe,{checked:O.includes(t),onCheckedChange:s=>{Y(i=>s?i.includes(t)?i:[...i,t]:i.filter(c=>c!==t))},children:t},t))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-md bg-amber-50/50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800",children:[e.jsx(ut,{id:"automation",checked:J,onCheckedChange:t=>ce(t===!0),className:"data-[state=checked]:bg-red-600 data-[state=checked]:border-red-600 data-[state=checked]:text-white border-red-400",disabled:F==="droid"}),e.jsx("label",{htmlFor:"automation",className:"text-sm font-medium text-red-600 dark:text-red-400 cursor-pointer",children:"Full environment access (recommended in secure environments only)"})]}),F==="droid"&&e.jsxs("p",{className:"text-xs text-muted-foreground px-1",children:[e.jsx("span",{className:"font-medium",children:"Droid:"})," Automation level is set in the REPL. Press ",e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono",children:"shift+tab"})," to cycle through Off → Low → Medium → High."]})]}),d&&e.jsx(gt,{title:"Advanced Settings",description:"Configure branch and worktree options",defaultOpen:!1,children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(fe,{className:"text-sm font-medium mb-3 block",children:"Branch Management"}),e.jsxs(ft,{value:w,onValueChange:t=>U(t),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ae,{value:"current",id:"branch-current"}),e.jsxs(fe,{htmlFor:"branch-current",className:"cursor-pointer font-normal",children:["Stay on current branch (",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:ae}),")"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ae,{value:"new-branch",id:"branch-new"}),e.jsxs(fe,{htmlFor:"branch-new",className:"cursor-pointer font-normal",children:["Create new branch: ",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:ne(r||"")})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ae,{value:"new-worktree",id:"branch-worktree"}),e.jsxs(fe,{htmlFor:"branch-worktree",className:"cursor-pointer font-normal",children:["Create new worktree: ",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:ne(r||"")})]})]})]})]})})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(v,{variant:"outline",onClick:()=>re(!1),children:"Close"}),e.jsx(v,{onClick:()=>{if(I.length>500){b("Please shorten the custom instruction to 500 characters.");return}b(null),ge(),re(!1)},children:"Save"})]}),S&&e.jsx("div",{className:"text-xs text-red-600 text-right",children:S})]})]})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-red-600 font-medium",children:"Invalid Task ID"}),e.jsx(v,{onClick:()=>E("/tasks"),className:"mt-4",children:"Back to Tasks"})]})})}function Ot({taskId:r,onStart:T,locationSearch:E}){return a.useEffect(()=>{if(!r)return;const C=new URLSearchParams(E);if(!C.has("autostart"))return;const A=`terminal.autostart.${r}`;if(sessionStorage.getItem(A)==="done")return;sessionStorage.setItem(A,"done");const d=C.get("run")||void 0;T(d||void 0)},[r]),null}export{tr as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,a as k,aY as N,A as g,j as e,a$ as P,I as b,B as C}from"./index-DFcWlnzl.js";import{C as F,b as w,c as T,d as L,a as D}from"./card-BcPlIAH5.js";import{L as o}from"./label-DBuh-ke5.js";import{S as h,a as u,b as m,c as f,d as a}from"./select-44mcS2_G.js";import"./chevron-up-CqM3won3.js";const r={theme:"coconut",defaultEditor:"cursor",terminalShell:"bash",autoSaveInterval:60,notifications:{email:!1,desktop:!1,slack:!1}};function V(s){return{theme:s?.theme??r.theme,defaultEditor:s?.defaultEditor??r.defaultEditor,terminalShell:s?.terminalShell??r.terminalShell,autoSaveInterval:s?.autoSaveInterval??r.autoSaveInterval,notifications:{email:s?.notifications?.email??r.notifications.email,desktop:s?.notifications?.desktop??r.notifications.desktop,slack:s?.notifications?.slack??r.notifications.slack}}}function $(){const[s,v]=i.useState(r),[y,E]=i.useState(!0),[c,x]=i.useState(!1),{toast:d}=k(),{theme:j,setTheme:p}=N();i.useEffect(()=>{S()},[]),i.useEffect(()=>{s.theme!==j&&p(s.theme)},[s.theme,j,p]);const S=async()=>{try{const l=await(await fetch(`${g}/api/v1/user/settings`)).json();l.success&&v(V(l.data.preferences))}catch(t){console.error("Failed to load preferences:",t),d({title:"Error",description:"Failed to load user preferences",variant:"destructive"})}finally{E(!1)}},I=async()=>{x(!0);try{const l=await(await fetch(`${g}/api/v1/user/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({preferences:s})})).json();if(l.success)d({title:"Preferences saved",description:"Your personal preferences have been updated."});else throw new Error(l.error)}catch(t){console.error("Failed to save preferences:",t),d({title:"Error",description:"Failed to save preferences",variant:"destructive"})}finally{x(!1)}},n=t=>{v(l=>({...l,...t,notifications:{...l.notifications,...t.notifications}}))};return y?e.jsx("div",{children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"User Preferences"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure defaults for editors, shells, themes, and notifications."})]}),e.jsx(P,{}),e.jsxs(F,{children:[e.jsxs(w,{children:[e.jsx(T,{children:"Workspace Defaults"}),e.jsx(L,{children:"Set the defaults Coconut uses when creating sessions and surfaces."})]}),e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"theme",children:"Theme"}),e.jsxs(h,{value:s.theme,onValueChange:t=>n({theme:t}),children:[e.jsx(u,{id:"theme",children:e.jsx(m,{placeholder:"Select theme"})}),e.jsxs(f,{children:[e.jsx(a,{value:"coconut",children:"Coconut"}),e.jsx(a,{value:"system",children:"System"}),e.jsx(a,{value:"light",children:"Light"}),e.jsx(a,{value:"dark",children:"Dark"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"System follows your OS preference. Coconut is the default branded theme."})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"defaultEditor",children:"Default Editor"}),e.jsxs(h,{value:s.defaultEditor,onValueChange:t=>n({defaultEditor:t}),children:[e.jsx(u,{id:"defaultEditor",children:e.jsx(m,{placeholder:"Select editor"})}),e.jsxs(f,{children:[e.jsx(a,{value:"cursor",children:"Cursor"}),e.jsx(a,{value:"vscode",children:"VS Code"}),e.jsx(a,{value:"vim",children:"Vim"}),e.jsx(a,{value:"emacs",children:"Emacs"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"terminalShell",children:"Preferred Shell"}),e.jsxs(h,{value:s.terminalShell,onValueChange:t=>n({terminalShell:t}),children:[e.jsx(u,{id:"terminalShell",children:e.jsx(m,{placeholder:"Select shell"})}),e.jsxs(f,{children:[e.jsx(a,{value:"bash",children:"Bash"}),e.jsx(a,{value:"zsh",children:"Zsh"}),e.jsx(a,{value:"fish",children:"Fish"}),e.jsx(a,{value:"sh",children:"sh"}),e.jsx(a,{value:"system",children:"System Default"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"autoSaveInterval",children:"Auto-save Interval (seconds)"}),e.jsx(b,{id:"autoSaveInterval",type:"number",min:10,max:600,value:s.autoSaveInterval,onChange:t=>n({autoSaveInterval:Number.parseInt(t.target.value,10)||r.autoSaveInterval})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Controls how often Coconut persists draft work to disk."})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(C,{variant:"outline",onClick:S,disabled:c,children:"Reset"}),e.jsx(C,{onClick:I,disabled:c,children:c?"Saving...":"Save Preferences"})]})]})}export{$ as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,a as S,A as j,j as e,a$ as b,B as m,I as u,L as w}from"./index-DFcWlnzl.js";import{C as E,b as I,c as F,d as L,a as k}from"./card-BcPlIAH5.js";import{L as h}from"./label-DBuh-ke5.js";import{C as D,a as P}from"./clipboard-tzPFoieb.js";function B(){const[r,l]=i.useState({}),[o,c]=i.useState(null),[f,p]=i.useState(!1),[v,C]=i.useState(!0),[d,x]=i.useState(!1),{toast:n}=S();i.useEffect(()=>{g()},[]);const g=async()=>{try{try{const t=await fetch(`${j}/api/v1/config`),s=await t.json();if(t.ok&&s?.success){const a=s.data?.coconut||{};c(a.id??null),(a.firstName||a.lastName||a.email)&&l({firstName:a.firstName,lastName:a.lastName,email:a.email})}else c(null)}catch(t){console.error("Failed to load coconut config:",t),c(null)}}catch(t){console.error("Failed to load settings:",t),n({title:"Error",description:"Failed to load user settings",variant:"destructive"})}finally{C(!1)}},N=async()=>{x(!0);try{const s=await(await fetch(`${j}/api/v1/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({coconut:{...r,id:o||void 0}})})).json();if(s.success)window.dispatchEvent(new CustomEvent("config-updated")),n({title:"Success",description:"Settings saved successfully"});else throw new Error(s.error||"Failed to save settings")}catch(t){console.error("Failed to save settings:",t),n({title:"Error",description:"Failed to save settings",variant:"destructive"})}finally{x(!1)}},y=async()=>{if(o)try{await navigator.clipboard.writeText(o),p(!0),n({title:"Copied",description:"Coconut ID copied to clipboard."}),setTimeout(()=>p(!1),1500)}catch(t){console.error("Failed to copy coconut ID:",t),n({title:"Copy failed",description:"Unable to copy the Coconut ID to the clipboard.",variant:"destructive"})}};return v?e.jsx("div",{children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Coconut Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage the Coconut's profile information."})]}),e.jsx(b,{}),e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/40 p-4",children:o?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"Coconut ID"}),e.jsx("p",{className:"mt-1 font-mono text-sm",children:o})]}),e.jsxs(m,{variant:"outline",size:"sm",onClick:y,children:[f?e.jsx(D,{className:"h-4 w-4"}):e.jsx(P,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2",children:f?"Copied":"Copy"})]})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"Coconut ID not configured"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add an `id` under the `coconut` section in `.nut/config.json` to register this Coconut instance."})]})}),e.jsxs(E,{children:[e.jsxs(I,{children:[e.jsx(F,{children:"Coconut Profile"}),e.jsx(L,{children:"Update the Coconut's identifying details."})]}),e.jsxs(k,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"firstName",children:"First Name"}),e.jsx(u,{id:"firstName",value:r.firstName||"",onChange:t=>l(s=>({...s,firstName:t.target.value})),placeholder:"Enter first name"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"lastName",children:"Last Name"}),e.jsx(u,{id:"lastName",value:r.lastName||"",onChange:t=>l(s=>({...s,lastName:t.target.value})),placeholder:"Enter last name"})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"email",children:"Email"}),e.jsx(u,{id:"email",type:"email",value:r.email||"",onChange:t=>l(s=>({...s,email:t.target.value})),placeholder:"Enter email address"})]})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can also manage the Coconut's identity to other agents on the"," ",e.jsx(w,{to:"/identity",className:"underline underline-offset-4 hover:text-primary",children:"Identity page"}),"."]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(m,{variant:"outline",onClick:g,disabled:d,children:"Cancel"}),e.jsx(m,{onClick:N,disabled:d,children:d?"Saving...":"Save Changes"})]})]})}export{B as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as v,a as w,r as n,j as e,B as g,ac as b,L as C,A as S,a1 as I}from"./index-DFcWlnzl.js";import{C as R,a as B}from"./card-BcPlIAH5.js";import{u as Q}from"./use-terminal-BXJqOeJe.js";import{C as $}from"./circle-play-BrY_lNiH.js";import{P as O}from"./play-CHIf-Rcz.js";function L(){const o=v(),{loading:l,createSession:d,refreshSessions:j}=Q(),{toast:i}=w(),[m,u]=n.useState(!1),[x,h]=n.useState(!1),[,f]=n.useState([]),[c,y]=n.useState({});n.useEffect(()=>{try{const t=localStorage.getItem("terminal.commandHistory");t&&f(JSON.parse(t))}catch{}},[]),n.useEffect(()=>{(async()=>{try{const s=await fetch(`${S}/api/v1/context/architecture`);if(!s.ok)return;const a=await s.json();a?.success&&a?.document?.metadata?.commands&&y(a.document.metadata.commands)}catch{}})()},[]);const p=t=>{t&&f(s=>{const a=[t,...s.filter(r=>r!==t)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a})},N=async t=>{const s=(t||"").trim();if(!s)return;const a=`session-${Date.now()}`;u(!0);try{await d(a,s)?(p(s),i({title:"Session started",description:`${a}`}),o(`/terminal/${a}`)):i({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{u(!1)}},k=async t=>{const s=(t||"").trim();if(!s)return;const a=`session-${Date.now()}`;h(!0);try{await d(a,s)?(p(s),setTimeout(()=>j(),150),i({title:"Started in background",description:`${a}`,action:e.jsx(I,{altText:"Open session",onClick:()=>o(`/terminal/${a}`),children:"Open"})})):i({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{h(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Utilities"}),e.jsx("p",{className:"text-muted-foreground",children:"Quick commands and shortcuts"})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Quick Commands"}),e.jsx(R,{children:e.jsx(B,{className:"pt-6",children:c&&Object.keys(c).length>0?e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"rounded-md border divide-y",children:Object.entries(c).map(([t,s])=>e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 p-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-2",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:t}),e.jsx("span",{className:"text-muted-foreground hidden sm:inline",children:":"}),e.jsx("span",{className:"truncate max-w-full",children:e.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs",children:s})})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 flex-shrink-0",children:[e.jsxs(g,{onClick:()=>k(s),variant:"secondary",size:"sm",disabled:l||x||m,title:"Run in background",children:[e.jsx($,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),e.jsxs(g,{onClick:()=>N(s),size:"sm",disabled:l||m||x,title:"Run",children:[e.jsx(O,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Run"})]})]})]},t))})}):e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3 py-8",children:[e.jsx(b,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No quick commands configured"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md leading-relaxed",children:"Quick commands let you run common tasks with one click, like starting your development server or running build scripts."}),e.jsxs("p",{className:"text-sm text-muted-foreground max-w-md mt-2",children:["Set them up in the"," ",e.jsx(C,{to:"/context/architecture/edit",className:"text-primary hover:underline font-medium",children:"Quick Commands section"}),"."]})]})]})})})]})]})}export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as a,e as o}from"./index-
|
|
1
|
+
import{r,j as a,e as o}from"./index-DFcWlnzl.js";const v=r.forwardRef(({className:e,variant:t="default",...s},d)=>{const l="relative w-full rounded-lg border px-4 py-3 text-sm [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",i=t==="destructive"?"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive":"bg-background text-foreground";return a.jsx("div",{ref:d,role:"alert",className:o(l,i,e),...s})});v.displayName="Alert";const c=r.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:o("text-sm [&_p]:leading-relaxed",e),...t}));c.displayName="AlertDescription";export{v as A,c as a};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as o}from"./index-DFcWlnzl.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 e=[["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"}]],a=o("arrow-up-down",e);export{a as A};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o,e as n,
|
|
1
|
+
import{j as o,e as n,b2 as a}from"./index-DFcWlnzl.js";const s=a("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function i({className:r,variant:e,...t}){return o.jsx("div",{className:n(s({variant:e}),r),...t})}export{i as B};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as $,r,j as e,D as z,b as G,d as J,f as K,I as Q,t as M,S as V,e as X,W as Y,B}from"./index-DFcWlnzl.js";import{B as v}from"./badge-BUEY53dV.js";import{a as Z}from"./registry-ANRa5WBi.js";import{S as O}from"./search-Cq1ksEdp.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ee=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],ne
|
|
6
|
+
*/const ee=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],ne=$("library",ee),te="Browse Registry",se="Import";function oe({open:f,categoryId:n,onOpenChange:x,title:F=te,confirmLabel:A=se,filterTags:o,onConfirm:I,getDetail:R,renderPreview:_}){const[c,y]=r.useState([]),[P,N]=r.useState(!1),[w,S]=r.useState(null),[l,b]=r.useState(null),[h,L]=r.useState({}),[T,g]=r.useState(!1),[E,j]=r.useState(null),[d,C]=r.useState(""),[p,k]=r.useState(!1);r.useEffect(()=>{if(!f)return;N(!0),S(null),b(null),j(null),g(!1),L({}),C("");const t=Array.isArray(n)?n:[n];Promise.all(t.map(s=>Z(s))).then(s=>{const a=s.flatMap(u=>u.elements??[]);y(a)}).catch(s=>{console.error("Failed to load registry category",s),y([]),S("Failed to load registry entries")}).finally(()=>N(!1))},[f,n]);const D=r.useMemo(()=>{let t=c;if(o&&o.length>0&&(t=t.filter(a=>{const u=a.tags??[];return o.some(H=>u.some(W=>W.toLowerCase()===H.toLowerCase()))})),!d.trim())return t;const s=d.trim().toLowerCase();return t.filter(a=>[a.name,a.description,a.preview,...a.tags??[]].filter(Boolean).join(" ").toLowerCase().includes(s))},[c,d,o]),i=r.useMemo(()=>l?c.find(t=>t.id===l)??null:null,[c,l]),m=r.useMemo(()=>l?h[l]?.detail??null:null,[l,h]),U=async t=>{if(b(t.id),j(null),!h?.[t.id]?.detail){g(!0);try{const s=await R(t);L(a=>({...a??{},[t.id]:{detail:s,fetchedAt:Date.now()}}))}catch(s){console.error("Failed to load registry element detail",s),j("Unable to load detail for this entry")}finally{g(!1)}}},q=async()=>{if(!(!i||!m)){k(!0);try{await I(i,m),x(!1)}catch(t){console.error("Failed to import registry element",t)}finally{k(!1)}}};return e.jsx(z,{open:f,onOpenChange:x,children:e.jsxs(G,{className:"max-w-5xl h-[80vh] flex flex-col",children:[e.jsx(J,{children:e.jsx(K,{children:F})}),e.jsx("div",{className:"flex flex-col gap-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(O,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Q,{value:d,onChange:t=>C(t.target.value),placeholder:"Search registry entries",className:"pl-9"})]})}),e.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[e.jsx("div",{className:"w-1/3 border-r pr-3",children:P?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(M,{className:"h-4 w-4 animate-spin mr-2"}),"Loading entries…"]}):w?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:w}):D.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"No entries found"}):e.jsx(V,{className:"h-full",children:e.jsx("div",{className:"space-y-1 pb-4",children:D.map(t=>e.jsxs("button",{onClick:()=>U(t),className:X("w-full rounded-md border border-transparent p-3 text-left transition-colors hover:border-border hover:bg-muted/40",l===t.id&&"border-primary bg-muted"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:t.name}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:t.description||t.preview})]}),t.version&&e.jsxs(v,{variant:"outline",className:"text-[10px] font-medium uppercase",children:["v",t.version]})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[t.tags.slice(0,4).map(s=>e.jsx(v,{variant:"secondary",className:"text-[10px] font-normal",children:s},s)),t.tags.length>4&&e.jsxs(v,{variant:"outline",className:"text-[10px] font-normal",children:["+",t.tags.length-4]})]})]},t.id))})})}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:T?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(M,{className:"h-5 w-5 animate-spin mr-2"}),"Loading detail…"]}):E?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:E}):i?e.jsx("div",{className:"h-full overflow-hidden",children:_(i,m)}):e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select an entry to preview"})})]}),e.jsxs(Y,{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:i?`Selected: ${i.name}`:"No entry selected"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{variant:"outline",onClick:()=>x(!1),disabled:p,children:"Cancel"}),e.jsx(B,{onClick:q,disabled:!i||!m||p,children:p?"Importing…":A})]})]})]})})}export{ne as L,oe as R};
|