(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[44262],{46710:(e,s,t)=>{Promise.resolve().then(t.bind(t,74993))},74993:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>x});var n=t(95155),l=t(2125),a=t(65738),c=t(73321),r=t(12115),i=t(3765),o=t(45160),d=t(89239),m=t(81477),u=t(42763);function x(){(0,i.si)("Skills");let e="u">typeof localStorage&&localStorage.getItem("cockpit-agents-cwd")||void 0,{skills:s,loading:t,deleteSkill:a}=function(e){let[s,t]=(0,r.useState)([]),[n,l]=(0,r.useState)(!0),a=(0,r.useCallback)(()=>{l(!0);let s=new URLSearchParams;e&&s.set("cwd",e),fetch(`/api/skills?${s}`).then(e=>e.json()).then(e=>t(e.skills)).catch(()=>t([])).finally(()=>l(!1))},[e]);(0,r.useEffect)(()=>{a()},[a]);let c=(0,r.useCallback)(async(s,t)=>{let n=new URLSearchParams({scope:t});"project"===t&&e&&n.set("cwd",e);try{if((await fetch(`/api/skills/${encodeURIComponent(s)}?${n}`,{method:"DELETE"})).ok)return a(),!0;return!1}catch{return!1}},[e,a]);return{skills:s,loading:n,refresh:a,deleteSkill:c}}(e),o=(0,c.useRouter)(),[x,p]=(0,r.useState)(null),[j,f]=(0,r.useState)(!1),k=s.filter(e=>"user"===e.scope),N=s.filter(e=>"project"===e.scope);function b(s){f(!1);let t=new URLSearchParams({scope:s});"project"===s&&e&&t.set("cwd",e),o.push(`/skills/new?${t}`)}function g(s,t){let n=new URLSearchParams({scope:t});"project"===t&&e&&n.set("cwd",e),o.push(`/skills/${encodeURIComponent(s)}?${n}`)}async function v(){x&&(await a(x.name,x.scope),p(null))}return(0,n.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("div",{}),(0,n.jsxs)(d.$,{size:"sm",onClick:()=>f(!0),children:[(0,n.jsx)(l.A,{className:"h-4 w-4 mr-1"}),"New Skill"]})]}),t&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading skills..."}),!t&&0===s.length&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"No custom skills found. Create one to get started."}),k.length>0&&(0,n.jsxs)(m.Zp,{children:[(0,n.jsx)(m.aR,{children:(0,n.jsx)(m.ZB,{className:"text-base",children:"Global"})}),(0,n.jsx)(m.Wu,{className:"space-y-1",children:k.map(e=>(0,n.jsx)(h,{name:e.name,scope:"user",description:e.description,onClick:()=>g(e.name,"user"),onDelete:()=>p({name:e.name,scope:"user"})},e.name))})]}),N.length>0&&(0,n.jsxs)(m.Zp,{children:[(0,n.jsx)(m.aR,{children:(0,n.jsx)(m.ZB,{className:"text-base",children:"Project"})}),(0,n.jsx)(m.Wu,{className:"space-y-1",children:N.map(e=>(0,n.jsx)(h,{name:e.name,scope:"project",description:e.description,onClick:()=>g(e.name,"project"),onDelete:()=>p({name:e.name,scope:"project"})},e.name))})]}),(0,n.jsx)(u.lG,{open:j,onOpenChange:f,children:(0,n.jsxs)(u.Cf,{children:[(0,n.jsx)(u.c7,{children:(0,n.jsx)(u.L3,{children:"New Skill"})}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Where should this skill be saved?"}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)(d.$,{variant:"outline",className:"flex-1",onClick:()=>b("user"),children:"Global"}),(0,n.jsx)(d.$,{variant:"outline",className:"flex-1",onClick:()=>b("project"),disabled:!e,children:"Project"})]})]})}),(0,n.jsx)(u.lG,{open:!!x,onOpenChange:()=>p(null),children:(0,n.jsxs)(u.Cf,{children:[(0,n.jsx)(u.c7,{children:(0,n.jsx)(u.L3,{children:"Delete Skill"})}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground mb-4",children:["Delete ",(0,n.jsx)("span",{className:"font-mono font-bold",children:x?.name}),"? This cannot be undone."]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(d.$,{variant:"outline",onClick:()=>p(null),children:"Cancel"}),(0,n.jsx)(d.$,{variant:"destructive",onClick:v,children:"Delete"})]})]})})]})}function h({name:e,scope:s,description:t,onClick:l,onDelete:c}){return(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded px-2 py-2 hover:bg-muted transition-colors",children:[(0,n.jsxs)("button",{type:"button",className:"flex-1 text-left min-w-0",onClick:l,children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-mono font-bold text-sm",children:e}),(0,n.jsx)(o.E,{variant:"secondary",className:"text-[10px]",children:"user"===s?"Global":"Project"})]}),t&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:t})]}),(0,n.jsx)("button",{type:"button",className:"shrink-0 p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors",onClick:e=>{e.stopPropagation(),c()},children:(0,n.jsx)(a.A,{className:"h-4 w-4"})})]})}}},e=>{e.O(0,[989,11242,3765,28441,93794,77358],()=>e(e.s=46710)),_N_E=e.O()}]);