(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[40992],{64025:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>d});var o=s(95155),n=s(73321),a=s(3765),r=s(45160),l=s(81477),c=s(12115);let i={global:"Global",project:"Project","project-local":"Local"},h=new Set(["UserPromptSubmit","PreToolUse","PermissionRequest","Stop","SubagentStop"]);function d(){(0,a.si)("Hooks");let e="u">typeof localStorage&&localStorage.getItem("cockpit-agents-cwd")||void 0,{hooks:t,loading:s}=function(e){let[t,s]=(0,c.useState)([]),[o,n]=(0,c.useState)([]),[a,r]=(0,c.useState)(!0),l=(0,c.useCallback)(()=>{r(!0);let t=new URLSearchParams;e&&t.set("cwd",e),fetch(`/api/hooks?${t}`).then(e=>e.json()).then(e=>{s(e.hooks),n(e.events)}).catch(()=>s([])).finally(()=>r(!1))},[e]);(0,c.useEffect)(()=>{l()},[l]);let i=(0,c.useCallback)(async(t,s,o)=>{let n=new URLSearchParams;e&&n.set("cwd",e);try{if((await fetch(`/api/hooks?${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:t,event:s,hooks:o})})).ok)return l(),!0;return!1}catch{return!1}},[e,l]);return{hooks:t,events:o,loading:a,refresh:l,saveHooks:i}}(e),d=(0,n.useRouter)(),m={};for(let e of t){let t=e.scope;m[t]||(m[t]=[]),m[t].push(e)}return(0,o.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-4",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsx)("div",{}),(0,o.jsx)("button",{className:"inline-flex items-center rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90",onClick:function(){let t=new URLSearchParams;e&&t.set("cwd",e),d.push(`/hooks/new?${t}`)},children:"New Hook"})]}),s&&(0,o.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading hooks..."}),!s&&0===t.length&&(0,o.jsx)("p",{className:"text-sm text-muted-foreground",children:"No hooks configured. Hooks let you run commands, HTTP requests, or prompts at key points in the agent lifecycle."}),Object.entries(m).map(([t,s])=>(0,o.jsxs)(l.Zp,{children:[(0,o.jsx)(l.aR,{children:(0,o.jsx)(l.ZB,{className:"text-base",children:i[t]||t})}),(0,o.jsx)(l.Wu,{className:"space-y-1",children:s.map(t=>(0,o.jsx)("button",{type:"button",className:"flex w-full items-center gap-3 rounded px-2 py-2 hover:bg-muted transition-colors text-left",onClick:()=>{var s;let o;return s=t.event,o=new URLSearchParams({scope:t.scope,filePath:t.filePath}),void(e&&o.set("cwd",e),d.push(`/hooks/${encodeURIComponent(s)}?${o}`))},children:(0,o.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsx)("span",{className:"font-mono font-bold text-sm",children:t.event}),h.has(t.event)&&(0,o.jsx)(r.E,{variant:"outline",className:"text-[10px]",children:"can block"})]}),(0,o.jsxs)("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.hooks.length," hook",1!==t.hooks.length?"s":""," — ",t.hooks.map(e=>e.type).join(", ")]})]})},`${t.event}-${t.scope}`))})]},t))]})}},70532:(e,t,s)=>{Promise.resolve().then(s.bind(s,64025))}},e=>{e.O(0,[989,11242,3765,28441,93794,77358],()=>e(e.s=70532)),_N_E=e.O()}]);