vibora 3.1.2 → 3.1.4

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.
@@ -108,7 +108,7 @@ ${n.map(([a,s])=>{const o=s.theme?.[r]||s.color;return o?` --color-${a}: ${o};`
108
108
  `)}
109
109
  }
110
110
  `).join(`
111
- `)}}):null},lX=Fo;function uX({active:e,payload:t,className:n,indicator:r="dot",hideLabel:i=!1,hideIndicator:a=!1,label:s,labelFormatter:o,labelClassName:l,formatter:u,color:f,nameKey:d,labelKey:p}){const{config:m}=LHe(),S=k.useMemo(()=>{if(i||!t?.length)return null;const[g]=t,_=`${p||g?.dataKey||g?.name||"value"}`,b=cX(m,g,_),x=!p&&typeof s=="string"?m[s]?.label||s:b?.label;return o?y.jsx("div",{className:We("font-medium",l),children:o(x,t)}):x?y.jsx("div",{className:We("font-medium",l),children:x}):null},[s,o,t,i,l,m,p]);if(!e||!t?.length)return null;const E=t.length===1&&r!=="dot";return y.jsxs("div",{className:We("border-border/50 bg-background gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs/relaxed shadow-xl grid min-w-[8rem] items-start",n),children:[E?null:S,y.jsx("div",{className:"grid gap-1.5",children:t.filter(g=>g.type!=="none").map((g,_)=>{const b=`${d||g.name||g.dataKey||"value"}`,x=cX(m,g,b),T=f||g.payload.fill||g.color;return y.jsx("div",{className:We("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",r==="dot"&&"items-center"),children:u&&g?.value!==void 0&&g.name?u(g.value,g.name,g,_,g.payload):y.jsxs(y.Fragment,{children:[x?.icon?y.jsx(x.icon,{}):!a&&y.jsx("div",{className:We("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",{"h-2.5 w-2.5":r==="dot","w-1":r==="line","w-0 border-[1.5px] border-dashed bg-transparent":r==="dashed","my-0.5":E&&r==="dashed"}),style:{"--color-bg":T,"--color-border":T}}),y.jsxs("div",{className:We("flex flex-1 justify-between leading-none",E?"items-end":"items-center"),children:[y.jsxs("div",{className:"grid gap-1.5",children:[E?S:null,y.jsx("span",{className:"text-muted-foreground",children:x?.label||g.name})]}),g.value&&y.jsx("span",{className:"text-foreground font-mono font-medium tabular-nums",children:g.value.toLocaleString()})]})]})},g.dataKey)})})]})}function cX(e,t,n){if(typeof t!="object"||t===null)return;const r="payload"in t&&typeof t.payload=="object"&&t.payload!==null?t.payload:void 0;let i=n;return n in t&&typeof t[n]=="string"?i=t[n]:r&&n in r&&typeof r[n]=="string"&&(i=r[n]),i in e?e[i]:e[n]}const yu="";function MHe(e="vibora"){return or({queryKey:["monitoring","claude-instances",e],queryFn:()=>Zt(`${yu}/api/monitoring/claude-instances?filter=${e}`),refetchInterval:5e3})}function jHe(e="1h"){return or({queryKey:["monitoring","system-metrics",e],queryFn:()=>Zt(`${yu}/api/monitoring/system-metrics?window=${e}`),refetchInterval:5e3})}function FHe(){const e=zr();return pr({mutationFn:({terminalId:t,pid:n})=>{if(t)return Zt(`${yu}/api/monitoring/claude-instances/${t}/kill`,{method:"POST"});if(n)return Zt(`${yu}/api/monitoring/claude-instances/${n}/kill-pid`,{method:"POST"});throw new Error("Either terminalId or pid must be provided")},onSuccess:()=>{e.invalidateQueries({queryKey:["monitoring","claude-instances"]})}})}function fb(e){if(e===0)return"0 B";const t=1024,n=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,r)).toFixed(1))} ${n[r]}`}function BHe(e){return{"1m":"1 min","10m":"10 min","1h":"1 hour","3h":"3 hours","6h":"6 hours","12h":"12 hours","24h":"24 hours"}[e]}function UHe(e="memory",t=10){return or({queryKey:["monitoring","top-processes",e,t],queryFn:()=>Zt(`${yu}/api/monitoring/top-processes?sort=${e}&limit=${t}`),refetchInterval:5e3})}function $He(){return or({queryKey:["monitoring","docker-stats"],queryFn:()=>Zt(`${yu}/api/monitoring/docker-stats`),refetchInterval:5e3})}function HHe(){return or({queryKey:["monitoring","vibora-instances"],queryFn:()=>Zt(`${yu}/api/monitoring/vibora-instances`),refetchInterval:5e3})}function zHe(){const e=zr();return pr({mutationFn:({backendPid:t})=>Zt(`${yu}/api/monitoring/vibora-instances/${t}/kill`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["monitoring","vibora-instances"]})}})}function VHe(){return or({queryKey:["monitoring","claude-usage"],queryFn:()=>Zt(`${yu}/api/monitoring/claude-usage`),refetchInterval:5e3})}const WHe=Bs("/monitoring/")({component:rze}),GHe=["1m","10m","1h","3h","6h","12h","24h"],dX={cpu:{label:"CPU",color:"var(--chart-system)"},memoryUsed:{label:"Used",color:"var(--chart-system)"},memoryCache:{label:"Cache / Buffers",color:"var(--muted-foreground)"},disk:{label:"Disk",color:"var(--muted-foreground)"}};function qHe(){const{t:e}=an("monitoring"),[t,n]=k.useState("vibora"),[r,i]=k.useState(null),{data:a,isLoading:s,error:o}=MHe(t),l=FHe(),u=a?.reduce((d,p)=>d+p.ramMB,0)||0,f=d=>{i(d.pid);const p=d.isViboraManaged&&d.terminalId?{terminalId:d.terminalId}:{pid:d.pid};l.mutate(p,{onSettled:()=>i(null)})};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Gl,{id:"show-all",checked:t==="all",onCheckedChange:d=>n(d?"all":"vibora")}),y.jsx(tte,{htmlFor:"show-all",className:"text-sm text-muted-foreground",children:e("claude.showAllInstances")})]}),a&&y.jsxs("span",{className:"text-sm text-muted-foreground",children:[e("claude.instanceCount",{count:a.length}),u>0&&` · ${e("claude.totalRam",{ram:u.toFixed(0)})}`]})]}),s&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),o&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("claude.error",{message:o.message})}),a&&a.length===0&&y.jsxs("div",{className:"py-12 text-center text-muted-foreground",children:[e("claude.empty"),t==="vibora"&&e("claude.emptyVibora")]}),a&&a.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"hidden lg:grid grid-cols-[60px_150px_1fr_1fr_80px_80px] gap-4 px-3 py-2 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("claude.headers.pid")}),y.jsx("span",{children:e("claude.headers.terminal")}),y.jsx("span",{children:e("claude.headers.task")}),y.jsx("span",{children:e("claude.headers.workingDirectory")}),y.jsx("span",{className:"text-right",children:e("claude.headers.ram")}),y.jsx("span",{className:"text-right",children:e("claude.headers.actions")})]}),a.map(d=>y.jsxs(Aa,{className:"px-3 py-2",children:[y.jsxs("div",{className:"flex flex-col gap-1 lg:hidden",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("span",{className:"text-sm font-medium truncate",children:d.taskId?y.jsx(Li,{to:"/tasks/$taskId",params:{taskId:d.taskId},className:"hover:text-foreground hover:underline",children:d.taskTitle}):y.jsx("span",{className:"text-muted-foreground",children:d.isViboraManaged?d.terminalName:e("claude.source.external")})}),y.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y.jsxs("span",{className:"tabular-nums text-sm text-muted-foreground",children:[d.ramMB.toFixed(0)," MB"]}),y.jsx(Ye,{variant:"ghost",size:"xs",onClick:()=>f(d),disabled:r===d.pid,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${r===d.pid?"opacity-50":""}`,children:y.jsx(ve,{icon:r===d.pid?xn:aa,className:`size-3.5 ${r===d.pid?"animate-spin":""}`})})]})]}),y.jsx("span",{className:"text-xs text-muted-foreground truncate",title:d.cwd,children:d.cwd})]}),y.jsxs("div",{className:"hidden lg:grid grid-cols-[60px_150px_1fr_1fr_80px_80px] items-center gap-4",children:[y.jsx("span",{className:"font-mono text-xs",children:d.pid}),y.jsx("span",{className:"truncate text-sm",children:d.isViboraManaged?y.jsx("span",{children:d.terminalName||`Terminal ${d.terminalId?.slice(0,8)}`}):y.jsx("span",{className:"text-muted-foreground",children:e("claude.source.external")})}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",children:d.taskId?y.jsx(Li,{to:"/tasks/$taskId",params:{taskId:d.taskId},className:"hover:text-foreground hover:underline",children:d.taskTitle}):e("claude.noTask")}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",title:d.cwd,children:d.cwd}),y.jsxs("span",{className:"text-right tabular-nums text-sm",children:[d.ramMB.toFixed(0)," MB"]}),y.jsx("div",{className:"flex justify-end",children:y.jsxs(Ye,{variant:"ghost",size:"xs",onClick:()=>f(d),disabled:r===d.pid,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${r===d.pid?"opacity-50":""}`,children:[y.jsx(ve,{icon:r===d.pid?xn:aa,className:`size-3.5 ${r===d.pid?"animate-spin":""}`}),r===d.pid?e("claude.killing"):e("claude.kill")]})})]})]},d.pid))]})]})}function KHe(){const{t:e}=an("monitoring"),[t,n]=k.useState("1h"),{data:r,isLoading:i,error:a}=jHe(t),s=r?.dataPoints.map(o=>({time:new Date(o.timestamp*1e3).toLocaleTimeString(),timestamp:o.timestamp,cpu:Math.round(o.cpuPercent*10)/10,memoryUsed:Math.round(o.memoryUsedPercent*10)/10,memoryCache:Math.round(o.memoryCachePercent*10)/10}))||[];return y.jsxs("div",{className:"space-y-6",children:[y.jsx("div",{className:"flex gap-1",children:GHe.map(o=>y.jsx(Ye,{variant:t===o?"secondary":"ghost",size:"xs",onClick:()=>n(o),children:BHe(o)},o))}),i&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),a&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("system.error",{message:a.message})}),r&&y.jsxs("div",{className:"space-y-6",children:[y.jsxs(Aa,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.cpuUsage")}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[r.current.cpu.toFixed(1),"%"]})]}),y.jsx(oX,{config:dX,className:"h-[150px] w-full",children:y.jsxs(sX,{data:s,margin:{left:0,right:0},children:[y.jsx(EL,{strokeDasharray:"3 3",vertical:!1}),y.jsx(ay,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:40}),y.jsx(sy,{domain:[0,100],tickLine:!1,axisLine:!1,tickMargin:8,tickFormatter:o=>`${o}%`}),y.jsx(lX,{content:y.jsx(uX,{hideLabel:!0,formatter:o=>[`${o}% `,"CPU"]})}),y.jsx(Qo,{type:"monotone",dataKey:"cpu",stroke:"var(--color-cpu)",fill:"var(--color-cpu)",fillOpacity:.4,strokeWidth:2})]})})]}),y.jsxs(Aa,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.memoryUsage")}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[fb(r.current.memory.used)," ",e("system.memoryLabels.used").toLowerCase()," + ",fb(r.current.memory.cache)," ",e("system.memoryLabels.cache").toLowerCase()," / ",fb(r.current.memory.total)]})]}),y.jsx(oX,{config:dX,className:"h-[150px] w-full",children:y.jsxs(sX,{data:s,margin:{left:0,right:0},children:[y.jsx(EL,{strokeDasharray:"3 3",vertical:!1}),y.jsx(ay,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:40}),y.jsx(sy,{domain:[0,100],tickLine:!1,axisLine:!1,tickMargin:8,tickFormatter:o=>`${o}%`}),y.jsx(lX,{content:y.jsx(uX,{hideLabel:!0,formatter:(o,l)=>{const u=e(l==="memoryUsed"?"system.memoryLabels.used":"system.memoryLabels.cache");return[`${o}% `,u]}})}),y.jsx(Qo,{type:"monotone",dataKey:"memoryUsed",stroke:"var(--color-memoryUsed)",fill:"var(--color-memoryUsed)",fillOpacity:.5,strokeWidth:2,stackId:"memory"}),y.jsx(Qo,{type:"monotone",dataKey:"memoryCache",stroke:"var(--color-memoryCache)",fill:"var(--color-memoryCache)",fillOpacity:.4,strokeWidth:1,stackId:"memory"})]})})]}),y.jsxs(Aa,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.diskUsage",{path:r.current.disk.path})}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[r.current.disk.usedPercent.toFixed(1),"% (",fb(r.current.disk.used)," /"," ",fb(r.current.disk.total),")"]})]}),y.jsx("div",{className:"h-4 w-full overflow-hidden rounded-full bg-muted",children:y.jsx("div",{className:"h-full bg-chart-system transition-all",style:{width:`${Math.min(r.current.disk.usedPercent,100)}%`}})})]})]})]})}function YHe(){const{t:e}=an("monitoring"),[t,n]=k.useState("memory"),{data:r,isLoading:i,error:a}=UHe(t),{data:s,isLoading:o}=$He();return y.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start",children:[y.jsxs(Aa,{className:"p-4 lg:flex-1 lg:min-w-0 h-[400px] flex flex-col",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between shrink-0",children:[y.jsx("h3",{className:"font-medium",children:e("processes.topProcesses")}),y.jsxs(Qi,{value:t,onValueChange:l=>n(l),children:[y.jsx(ea,{className:"w-32",children:y.jsx(Ji,{})}),y.jsxs(ta,{children:[y.jsx(Nn,{value:"memory",children:e("processes.sortBy.memory")}),y.jsx(Nn,{value:"cpu",children:e("processes.sortBy.cpu")})]})]})]}),i&&y.jsx("div",{className:"flex items-center justify-center flex-1",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),a&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("processes.error",{message:a.message})}),r&&r.length>0&&y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"grid grid-cols-[60px_120px_1fr_70px_80px] gap-2 px-2 py-1 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("processes.headers.pid")}),y.jsx("span",{children:e("processes.headers.name")}),y.jsx("span",{children:e("processes.headers.command")}),y.jsx("span",{className:"text-right",children:e("processes.headers.memory")}),y.jsx("span",{className:"text-right",children:"%"})]}),r.map(l=>y.jsxs("div",{className:"grid grid-cols-[60px_120px_1fr_70px_80px] gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted/50",children:[y.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:l.pid}),y.jsx("span",{className:"truncate font-medium",title:l.name,children:l.name}),y.jsx("span",{className:"truncate text-muted-foreground text-xs",title:l.command,children:l.command}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.memoryMB.toFixed(0)," MB"]}),y.jsxs("span",{className:"text-right tabular-nums text-muted-foreground",children:[l.memoryPercent.toFixed(1),"%"]})]},l.pid))]})}),r&&r.length===0&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.empty")})]}),y.jsxs(Aa,{className:"p-4 lg:flex-1 lg:min-w-0 h-[400px] flex flex-col",children:[y.jsx("div",{className:"mb-4 flex items-center justify-between shrink-0",children:y.jsxs("h3",{className:"font-medium",children:[e("processes.containers"),s?.runtime&&y.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:["(",s.runtime,")"]})]})}),o&&y.jsx("div",{className:"flex items-center justify-center flex-1",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),s&&!s.available&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.containersUnavailable")}),s&&s.available&&s.containers.length===0&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.containersEmpty")}),s&&s.available&&s.containers.length>0&&y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"grid grid-cols-[1fr_70px_100px_80px] gap-2 px-2 py-1 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("processes.headers.name")}),y.jsx("span",{className:"text-right",children:"CPU"}),y.jsx("span",{className:"text-right",children:e("processes.headers.memory")}),y.jsx("span",{className:"text-right",children:"%"})]}),s.containers.map(l=>y.jsxs("div",{className:"grid grid-cols-[1fr_70px_100px_80px] gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted/50",children:[y.jsx("span",{className:"truncate font-medium",title:l.name,children:l.name}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.cpuPercent.toFixed(1),"%"]}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.memoryMB.toFixed(0)," / ",l.memoryLimit.toFixed(0)," MB"]}),y.jsxs("span",{className:"text-right tabular-nums text-muted-foreground",children:[l.memoryPercent.toFixed(1),"%"]})]},l.id))]})})]})]})}function XHe(){const{t:e}=an("monitoring"),[t,n]=k.useState(null),{data:r,isLoading:i,error:a}=HHe(),s=zHe(),o=l=>{l.backend&&(n(l.backend.pid),s.mutate({backendPid:l.backend.pid},{onSettled:()=>n(null)}))};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"text-sm text-muted-foreground",children:e("vibora.description")}),r&&r.length>0&&y.jsx("span",{className:"text-sm text-muted-foreground",children:e("vibora.instanceCount",{count:r.length})})]}),i&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),a&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("vibora.error",{message:a.message})}),r&&r.length===0&&y.jsx("div",{className:"py-12 text-center text-muted-foreground",children:e("vibora.empty")}),r&&r.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"hidden lg:grid grid-cols-[80px_100px_1fr_100px_80px] gap-4 px-3 py-2 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("vibora.headers.port")}),y.jsx("span",{children:e("vibora.headers.mode")}),y.jsx("span",{children:e("vibora.headers.directory")}),y.jsx("span",{className:"text-right",children:e("vibora.headers.ram")}),y.jsx("span",{className:"text-right",children:e("vibora.headers.actions")})]}),r.map(l=>{const u=t===l.backend?.pid;return y.jsxs(Aa,{className:"px-3 py-2",children:[y.jsxs("div",{className:"flex flex-col gap-1 lg:hidden",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsxs("span",{className:"text-sm font-medium",children:[y.jsxs("span",{className:"font-mono",children:[":",l.port]}),y.jsxs("span",{className:`ml-2 text-xs ${l.mode==="development"?"text-muted-foreground":""}`,children:[l.mode==="development"?e("vibora.mode.dev"):e("vibora.mode.prod"),l.frontend&&` + ${e("vibora.vite")}`]})]}),y.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y.jsxs("span",{className:"tabular-nums text-sm text-muted-foreground",children:[l.totalMemoryMB.toFixed(0)," MB"]}),y.jsx(Ye,{variant:"ghost",size:"xs",onClick:()=>o(l),disabled:u||!l.backend,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${u?"opacity-50":""}`,children:y.jsx(ve,{icon:u?xn:aa,className:`size-3.5 ${u?"animate-spin":""}`})})]})]}),y.jsx("span",{className:"text-xs text-muted-foreground truncate",title:l.viboraDir,children:l.viboraDir})]}),y.jsxs("div",{className:"hidden lg:grid grid-cols-[80px_100px_1fr_100px_80px] items-center gap-4",children:[y.jsx("span",{className:"font-mono text-sm",children:l.port}),y.jsxs("span",{className:`text-xs ${l.mode==="development"?"text-muted-foreground":""}`,children:[l.mode==="development"?e("vibora.mode.dev"):e("vibora.mode.prod"),l.frontend&&` + ${e("vibora.vite")}`]}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",title:l.viboraDir,children:l.viboraDir}),y.jsxs("span",{className:"text-right tabular-nums text-sm",children:[l.totalMemoryMB.toFixed(0)," MB"]}),y.jsx("div",{className:"flex justify-end",children:y.jsxs(Ye,{variant:"ghost",size:"xs",onClick:()=>o(l),disabled:u||!l.backend,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${u?"opacity-50":""}`,children:[y.jsx(ve,{icon:u?xn:aa,className:`size-3.5 ${u?"animate-spin":""}`}),e(u?"vibora.killing":"vibora.kill")]})})]})]},l.backend?.pid||l.port)})]})]})}function ZHe(e){return e>=90?"text-destructive":e>=70?"text-muted-foreground":"text-chart-system"}function QHe(e){if(e<60)return`${e}m`;const t=Math.floor(e/60),n=e%60;return n>0?`${t}h ${n}m`:`${t}h`}function xI(e){const t=new Date(e),n=new Date,r=t.getTime()-n.getTime(),i=Math.floor(r/(1e3*60*60*24));return i===0?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):i===1?`Tomorrow ${t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`:i<7?t.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function x_({percent:e,label:t,subtitle:n,color:r}){const i=[{value:Math.min(e,100),fill:r}],a=Math.round(96*fc),s=Math.round(48*fc),o=Math.round(32*fc),l=Math.round(44*fc),u=Math.round(10*fc),f=Math.round(5*fc);return y.jsx(Aa,{className:"p-4",children:y.jsxs("div",{className:"flex items-center gap-4",children:[y.jsxs("div",{className:"relative size-24 shrink-0",children:[y.jsxs(NHe,{width:a,height:a,cx:s,cy:s,innerRadius:o,outerRadius:l,barSize:u,data:i,startAngle:90,endAngle:-270,children:[y.jsx(e0,{type:"number",domain:[0,100],angleAxisId:0,tick:!1}),y.jsx(t0,{background:{fill:"var(--border)"},dataKey:"value",cornerRadius:f,angleAxisId:0})]}),y.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:y.jsxs("span",{className:`text-lg font-semibold tabular-nums ${ZHe(e)}`,children:[e.toFixed(0),"%"]})})]}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsx("h3",{className:"text-sm font-medium truncate",children:t}),y.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:n})]})]})})}function JHe(){const{t:e}=an("monitoring"),{data:t,isLoading:n,error:r}=VHe(),i=a=>a>=90?"var(--destructive)":a>=70?"var(--muted-foreground)":"var(--chart-system)";return y.jsxs("div",{className:"space-y-4",children:[n&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),r&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("usage.error",{message:r.message})}),t&&!t.available&&y.jsx("div",{className:"rounded-lg border border-muted-foreground/50 bg-muted p-4 text-sm text-muted-foreground",children:t.error||e("usage.unavailable")}),t&&t.available&&y.jsxs("div",{className:"space-y-3",children:[y.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.fiveHour&&y.jsx(x_,{percent:t.fiveHour.percentUsed,label:e("usage.fiveHourBlock"),subtitle:e("usage.resetsIn",{time:QHe(t.fiveHour.timeRemainingMinutes)}),color:i(t.fiveHour.percentUsed)}),t.sevenDay&&y.jsx(x_,{percent:t.sevenDay.percentUsed,label:e("usage.sevenDayRolling"),subtitle:`${e("usage.resetsAt",{time:xI(t.sevenDay.resetAt)})} · ${e("usage.weekProgress",{percent:t.sevenDay.weekProgressPercent})}`,color:i(t.sevenDay.percentUsed)})]}),(t.sevenDayOpus||t.sevenDaySonnet)&&y.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.sevenDayOpus&&y.jsx(x_,{percent:t.sevenDayOpus.percentUsed,label:e("usage.opusWeekly"),subtitle:e("usage.resetsAt",{time:xI(t.sevenDayOpus.resetAt)}),color:i(t.sevenDayOpus.percentUsed)}),t.sevenDaySonnet&&y.jsx(x_,{percent:t.sevenDaySonnet.percentUsed,label:e("usage.sonnetWeekly"),subtitle:e("usage.resetsAt",{time:xI(t.sevenDaySonnet.resetAt)}),color:i(t.sevenDaySonnet.percentUsed)})]})]})]})}const wI={IN_PROGRESS:"bg-muted-foreground/20 text-muted-foreground",IN_REVIEW:"bg-primary/20 text-primary",DONE:"bg-accent/20 text-accent",CANCELED:"bg-destructive/20 text-destructive",ORPHANED:"bg-destructive/20 text-destructive"},eze=["IN_PROGRESS","IN_REVIEW","DONE","CANCELED","ORPHANED"];function tze(){const{t:e}=an("common");return t=>{const n=new Date(t),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),s=Math.floor(a/60),o=Math.floor(s/60),l=Math.floor(o/24);return l>0?l===1?e("time.dayAgo"):e("time.daysAgo",{count:l}):o>0?o===1?e("time.hourAgo"):e("time.hoursAgo",{count:o}):s>0?s===1?e("time.minuteAgo"):e("time.minutesAgo",{count:s}):e("time.justNow")}}function nze(){const{t:e}=an("common"),{t}=an("worktrees"),n=tze(),{worktrees:r,summary:i,isLoading:a,isLoadingDetails:s,error:o,refetch:l}=tne(),u=nne(),[f,d]=k.useState(new Set),[p,m]=k.useState(!1),[S,E]=k.useState(!1),[g,_]=k.useState(!1),[b,x]=k.useState(null),[T,w]=k.useState(null),[C,R]=k.useState(!1),O=$=>{d(q=>{const K=new Set(q);return K.has($)?K.delete($):K.add($),K})},I=()=>{d(new Set)},D=k.useMemo(()=>f.size===0?r:r.filter($=>!!($.isOrphaned&&f.has("ORPHANED")||$.taskStatus&&f.has($.taskStatus))),[r,f]),P=k.useMemo(()=>r.filter($=>$.taskStatus==="DONE"||$.taskStatus==="CANCELED"),[r]),H=async()=>{if(P.length!==0){E(!0);try{for(const $ of P)await u.mutateAsync({worktreePath:$.path,repoPath:$.repoPath,deleteLinkedTask:g});m(!1),l()}catch{}finally{E(!1)}}},M=async($,q)=>{x($.path);try{await u.mutateAsync({worktreePath:$.path,repoPath:$.repoPath,deleteLinkedTask:q}),w(null),l()}catch{}finally{x(null)}},W=$=>{$||(w(null),R(!1))},V=$=>{m($),$||_(!1)};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[y.jsx("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:(i||r.length>0)&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:t("summary.total",{count:i?.total??r.length})}),(i?.orphaned??r.filter($=>$.isOrphaned).length)>0&&y.jsx("span",{className:"text-destructive",children:t("summary.orphaned",{count:i?.orphaned??r.filter($=>$.isOrphaned).length})}),s?y.jsx("span",{className:"animate-pulse",children:e("status.calculating")}):i?y.jsx("span",{children:i.totalSizeFormatted}):null]})}),y.jsxs("div",{className:"flex items-center gap-2",children:[P.length>0&&y.jsxs(Bc,{open:p,onOpenChange:V,children:[y.jsxs(Uc,{render:y.jsx(Ye,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground hover:text-destructive",disabled:s}),children:[y.jsx(ve,{icon:Nee,size:12,strokeWidth:2}),t("cleanup.button",{count:P.length})]}),y.jsxs($c,{children:[y.jsxs(Hc,{children:[y.jsx(Vc,{children:t("cleanup.title")}),y.jsxs(Wc,{children:[t("cleanup.description",{count:P.length}),g&&` ${t("cleanup.linkedTasksWillBeDeleted")}`]}),y.jsxs("div",{className:"space-y-3",children:[y.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[y.jsx(rl,{checked:g,onCheckedChange:$=>_($===!0),disabled:S}),t("cleanup.alsoDeleteLinkedTasks")]}),y.jsx("p",{className:"font-medium text-destructive text-xs",children:t("cleanup.cannotUndo")})]})]}),y.jsxs(zc,{children:[y.jsx(Gc,{disabled:S,children:e("buttons.cancel")}),y.jsxs(Ye,{variant:"destructive",onClick:H,disabled:S,className:"gap-2",children:[S&&y.jsx(ve,{icon:xn,size:14,strokeWidth:2,className:"animate-spin"}),S?e("status.deleting"):t("delete.button",{count:P.length})]})]})]})]}),f.size>0&&y.jsxs(Ye,{variant:"ghost",size:"sm",onClick:I,className:"gap-1.5 text-xs",children:[y.jsx(ve,{icon:aa,size:12,strokeWidth:2}),e("buttons.clearFilters")]})]})]}),y.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:eze.map($=>{const q=f.has($);return y.jsx("button",{onClick:()=>O($),className:We("rounded-full px-2.5 py-1 text-xs font-medium transition-colors",q?wI[$]:"bg-muted text-muted-foreground hover:bg-muted/80"),children:e(`statuses.${$}`)},$)})}),a&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),o&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:t("error.failedToLoad",{message:o.message})}),!a&&!o&&D.length===0&&y.jsx("div",{className:"py-12 text-center text-muted-foreground",children:f.size>0?t("empty.noMatch"):t("empty.noWorktrees")}),!a&&D.length>0&&y.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:D.map($=>{const q=$.sizeFormatted==="..."||$.branch==="...",K=!$.isOrphaned&&$.taskId,U=b===$.path;return y.jsx(Aa,{className:"transition-colors hover:border-border/80",children:y.jsxs(Tf,{className:"flex items-start justify-between gap-4 py-4",children:[y.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"truncate font-medium",children:$.name}),$.isOrphaned?y.jsx(lo,{className:We("shrink-0",wI.ORPHANED),children:e("statuses.ORPHANED")}):$.taskStatus?y.jsx(lo,{className:We("shrink-0",wI[$.taskStatus]),children:e(`statuses.${$.taskStatus}`)}):null]}),y.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(ve,{icon:Pi,size:12,strokeWidth:2,className:"shrink-0"}),y.jsx("span",{className:"truncate font-mono",children:$.path})]}),y.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(ve,{icon:wE,size:12,strokeWidth:2,className:"shrink-0"}),$.branch==="..."?y.jsx("span",{className:"inline-block animate-pulse rounded bg-muted h-3 w-16"}):y.jsx("span",{className:"font-mono",children:$.branch})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(ve,{icon:Lee,size:12,strokeWidth:2,className:"shrink-0"}),$.sizeFormatted==="..."?y.jsx("span",{className:"inline-block animate-pulse rounded bg-muted h-3 w-12"}):y.jsx("span",{children:$.sizeFormatted})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(ve,{icon:Iee,size:12,strokeWidth:2,className:"shrink-0"}),y.jsx("span",{children:n($.lastModified)})]})]}),$.taskId&&$.taskTitle&&y.jsx("div",{className:"flex items-center gap-1.5 pt-1",children:y.jsxs(Li,{to:"/tasks/$taskId",params:{taskId:$.taskId},className:"inline-flex items-center gap-1 text-foreground hover:underline",children:[y.jsx("span",{className:"truncate",children:$.taskTitle}),y.jsx(ve,{icon:Oy,size:12,strokeWidth:2,className:"shrink-0"})]})})]})]}),y.jsxs(Bc,{open:T?.path===$.path,onOpenChange:W,children:[y.jsx(Uc,{render:y.jsx(Ye,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:q||U,onClick:()=>w($)}),children:y.jsx(ve,{icon:U?xn:km,size:14,strokeWidth:2,className:U?"animate-spin":""})}),y.jsxs($c,{children:[y.jsxs(Hc,{children:[y.jsx(Vc,{children:t("delete.title")}),y.jsxs(Wc,{children:[t("delete.description")," ",y.jsx("span",{className:"font-mono",children:$.name}),".",C&&K&&y.jsxs(y.Fragment,{children:[" ",t("delete.linkedTaskWillBeDeleted",{title:$.taskTitle})]})," ",t("delete.cannotUndo")]}),K&&y.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[y.jsx(rl,{checked:C,onCheckedChange:F=>R(F===!0),disabled:U}),t("delete.alsoDeleteLinkedTask",{title:$.taskTitle})]})]}),y.jsxs(zc,{children:[y.jsx(Gc,{disabled:U,children:e("buttons.cancel")}),y.jsxs(Ye,{variant:"destructive",onClick:()=>M($,C),disabled:U,className:"gap-2",children:[U&&y.jsx(ve,{icon:xn,size:14,strokeWidth:2,className:"animate-spin"}),e(U?"status.deleting":"buttons.delete")]})]})]})]})]})},$.path)})})]})}function rze(){const{t:e}=an("monitoring"),{data:t}=Kte(),[n,r]=k.useState("system"),a=[{value:"system",label:e("tabs.system")},{value:"processes",label:e("tabs.processes")},{value:"claude",label:e("tabs.claude")},{value:"vibora",label:e("tabs.vibora"),devOnly:!0},{value:"worktrees",label:e("tabs.worktrees")},{value:"usage",label:e("tabs.usage")}].filter(s=>!s.devOnly||t?.enabled);return y.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[y.jsxs("div",{className:"flex shrink-0 items-center border-b border-border bg-background px-4 py-2",children:[y.jsx("div",{className:"sm:hidden",children:y.jsxs(Qi,{value:n,onValueChange:s=>r(s),children:[y.jsx(ea,{size:"sm",className:"w-auto gap-2",children:y.jsx(Ji,{})}),y.jsx(ta,{children:a.map(s=>y.jsx(Nn,{value:s.value,children:s.label},s.value))})]})}),y.jsx("div",{className:"hidden sm:block",children:y.jsx(Dc,{value:n,onValueChange:s=>r(s),children:y.jsx(Lc,{variant:"line",children:a.map(s=>y.jsx(Ii,{value:s.value,className:"px-3 py-1.5",children:s.label},s.value))})})})]}),y.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[n==="system"&&y.jsx(KHe,{}),n==="processes"&&y.jsx(YHe,{}),n==="claude"&&y.jsx(qHe,{}),n==="vibora"&&t?.enabled&&y.jsx(XHe,{}),n==="worktrees"&&y.jsx(nze,{}),n==="usage"&&y.jsx(JHe,{})]})]})}const ize=()=>"http://localhost:3000",hb={activeTab:"diff",browserUrl:ize(),diffOptions:{wrap:!0,ignoreWhitespace:!0,includeUntracked:!1,collapsedFiles:[]},filesViewState:{selectedFile:null,expandedDirs:[]}};function $3(e){const t=zr(),n=k.useRef(void 0),r=k.useRef({}),{data:i}=Wte(e),a=k.useMemo(()=>{const p=i?.viewState;return p?{activeTab:p.activeTab??hb.activeTab,browserUrl:p.browserUrl??hb.browserUrl,diffOptions:{...hb.diffOptions,...p.diffOptions},filesViewState:{...hb.filesViewState,...p.filesViewState}}:hb},[i?.viewState]),s=pr({mutationFn:async p=>{const m=await fetch(`/api/tasks/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({viewState:p})});if(!m.ok)throw new Error("Failed to update view state");return m.json()},onSuccess:p=>{t.setQueryData(["tasks",e],p),t.setQueryData(["tasks"],m=>m&&m.map(S=>S.id===e?p:S))}}),o=k.useCallback(p=>{const m=r.current;r.current={...m,...p,diffOptions:p.diffOptions||m.diffOptions?{...m.diffOptions,...p.diffOptions}:void 0,filesViewState:p.filesViewState||m.filesViewState?{...m.filesViewState,...p.filesViewState}:void 0};const S=r.current,E={activeTab:S.activeTab??a.activeTab,browserUrl:S.browserUrl??a.browserUrl,diffOptions:{...a.diffOptions,...S.diffOptions},filesViewState:{...a.filesViewState,...S.filesViewState}};t.setQueryData(["tasks",e],g=>g&&{...g,viewState:E}),t.setQueryData(["tasks"],g=>g&&g.map(_=>_.id===e?{..._,viewState:E}:_)),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{s.mutate(E),r.current={}},500)},[t,e,a,s]),l=k.useCallback(p=>{o({activeTab:p})},[o]),u=k.useCallback(p=>{o({browserUrl:p})},[o]),f=k.useCallback(p=>{o({diffOptions:p})},[o]),d=k.useCallback(p=>{o({filesViewState:p})},[o]);return{viewState:a,setActiveTab:l,setBrowserUrl:u,setDiffOptions:f,setFilesViewState:d}}function aze(e){return or({queryKey:["linear-ticket",e],queryFn:async()=>{if(!e)return null;const t=await fetch(`/api/linear/ticket/${e}`);return t.ok?t.json():null},enabled:!!e,staleTime:300*1e3})}function fX({taskName:e,cwd:t,className:n,aiMode:r,description:i,startupScript:a,serverPort:s=7777}){const o=k.useRef(null),l=k.useRef(null),u=k.useRef(null),f=k.useRef(!1),d=k.useRef(!1),[p,m]=k.useState(null),[S,E]=k.useState(!1),[g,_]=k.useState(!1),[b,x]=k.useState(!1),{resolvedTheme:T}=Pf(),w=T==="dark",C=w?Ere:_re;k.useEffect(()=>{Gt.taskTerminal.debug("cwd changed, resetting refs",{cwd:t}),f.current=!1,d.current=!1,m(null),E(!1)},[t]);const{setTerminalFocused:R}=YP(),{terminals:O,terminalsLoaded:I,connected:D,createTerminal:P,attachXterm:H,resizeTerminal:M,setupImagePaste:W,writeToTerminal:V,consumePendingStartup:$}=PM(),q=k.useRef(H),K=k.useRef(W),U=k.useRef(V),F=k.useRef($);k.useEffect(()=>{q.current=H},[H]),k.useEffect(()=>{K.current=W},[W]),k.useEffect(()=>{U.current=V},[V]),k.useEffect(()=>{F.current=$},[$]);const B=p?O.find(ee=>ee.id===p):null,Y=B?.status;k.useEffect(()=>{if(!o.current||l.current)return;const ee=new bre.Terminal({cursorBlink:!0,fontSize:Math.round(13*fc),fontFamily:"JetBrains Mono Variable, Menlo, Monaco, monospace",lineHeight:1.2,theme:C}),te=new vre.FitAddon,Z=new yre.WebLinksAddon;ee.loadAddon(te),ee.loadAddon(Z),ee.open(o.current),l.current=ee,u.current=te,x(!0),requestAnimationFrame(()=>{te.fit()});const G=setTimeout(()=>{te.fit(),ee.refresh(0,ee.rows-1)},100),Q=()=>R(!0),ae=()=>R(!1);return ee.textarea&&(ee.textarea.addEventListener("focus",Q),ee.textarea.addEventListener("blur",ae)),()=>{clearTimeout(G),ee.textarea&&(ee.textarea.removeEventListener("focus",Q),ee.textarea.removeEventListener("blur",ae)),R(!1),ee.dispose(),l.current=null,u.current=null,x(!1)}},[R]);const z=k.useCallback(()=>{if(!u.current||!l.current)return;u.current.fit();const{cols:ee,rows:te}=l.current;p&&M(p,ee,te)},[p,M]);k.useEffect(()=>{if(!o.current)return;const ee=()=>{requestAnimationFrame(z)};window.addEventListener("resize",ee);const te=()=>{document.visibilityState==="visible"&&requestAnimationFrame(()=>{z(),l.current&&l.current.refresh(0,l.current.rows-1)})};document.addEventListener("visibilitychange",te);const Z=new ResizeObserver(ee);Z.observe(o.current);const G=new IntersectionObserver(Q=>{Q[0]?.isIntersecting&&requestAnimationFrame(()=>{z(),l.current&&l.current.refresh(0,l.current.rows-1)})},{threshold:.1});return G.observe(o.current),()=>{window.removeEventListener("resize",ee),document.removeEventListener("visibilitychange",te),Z.disconnect(),G.disconnect()}},[z]),k.useEffect(()=>{if(!D||!t||!b||!I)return;const ee=O.find(te=>te.cwd===t);if(ee){m(ee.id);return}if(!f.current&&l.current){f.current=!0,E(!0);const{cols:te,rows:Z}=l.current;P({name:e,cols:te,rows:Z,cwd:t,startup:{startupScript:a,aiMode:r,description:i,taskName:e,serverPort:s}})}},[D,t,b,I,O,e,P]),k.useEffect(()=>{if(!t)return;const ee=O.find(Z=>Z.cwd===t);if(!ee)return;const te=p&&O.some(Z=>Z.id===p);(!p||!te)&&(Gt.taskTerminal.debug("setting terminalId",{newId:ee.id,prevId:p,reason:p?"tempId replaced":"initial",cwd:t,terminalCount:O.length}),m(ee.id),E(!1),p&&!te&&(d.current=!1))},[O,t,p]),k.useEffect(()=>{if(Gt.taskTerminal.debug("attach effect",{terminalId:p,hasTermRef:!!l.current,hasContainerRef:!!o.current,attachedRef:d.current}),!p||!l.current||!o.current||d.current)return;Gt.taskTerminal.debug("attach effect passed guards, calling attachXterm",{terminalId:p});const ee=G=>{requestAnimationFrame(z);const Q=F.current(G);if(Gt.taskTerminal.debug("onAttached checking pending startup",{terminalId:G,hasPendingStartup:!!Q}),Q){Gt.taskTerminal.info("onAttached: running startup commands",{terminalId:G}),_(!0);const{startupScript:ae,aiMode:se,description:ne,taskName:ye,serverPort:Ee}=Q;ae&&setTimeout(()=>{const we=`source /dev/stdin <<'VIBORA_STARTUP'
111
+ `)}}):null},lX=Fo;function uX({active:e,payload:t,className:n,indicator:r="dot",hideLabel:i=!1,hideIndicator:a=!1,label:s,labelFormatter:o,labelClassName:l,formatter:u,color:f,nameKey:d,labelKey:p}){const{config:m}=LHe(),S=k.useMemo(()=>{if(i||!t?.length)return null;const[g]=t,_=`${p||g?.dataKey||g?.name||"value"}`,b=cX(m,g,_),x=!p&&typeof s=="string"?m[s]?.label||s:b?.label;return o?y.jsx("div",{className:We("font-medium",l),children:o(x,t)}):x?y.jsx("div",{className:We("font-medium",l),children:x}):null},[s,o,t,i,l,m,p]);if(!e||!t?.length)return null;const E=t.length===1&&r!=="dot";return y.jsxs("div",{className:We("border-border/50 bg-background gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs/relaxed shadow-xl grid min-w-[8rem] items-start",n),children:[E?null:S,y.jsx("div",{className:"grid gap-1.5",children:t.filter(g=>g.type!=="none").map((g,_)=>{const b=`${d||g.name||g.dataKey||"value"}`,x=cX(m,g,b),T=f||g.payload.fill||g.color;return y.jsx("div",{className:We("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",r==="dot"&&"items-center"),children:u&&g?.value!==void 0&&g.name?u(g.value,g.name,g,_,g.payload):y.jsxs(y.Fragment,{children:[x?.icon?y.jsx(x.icon,{}):!a&&y.jsx("div",{className:We("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",{"h-2.5 w-2.5":r==="dot","w-1":r==="line","w-0 border-[1.5px] border-dashed bg-transparent":r==="dashed","my-0.5":E&&r==="dashed"}),style:{"--color-bg":T,"--color-border":T}}),y.jsxs("div",{className:We("flex flex-1 justify-between leading-none",E?"items-end":"items-center"),children:[y.jsxs("div",{className:"grid gap-1.5",children:[E?S:null,y.jsx("span",{className:"text-muted-foreground",children:x?.label||g.name})]}),g.value&&y.jsx("span",{className:"text-foreground font-mono font-medium tabular-nums",children:g.value.toLocaleString()})]})]})},g.dataKey)})})]})}function cX(e,t,n){if(typeof t!="object"||t===null)return;const r="payload"in t&&typeof t.payload=="object"&&t.payload!==null?t.payload:void 0;let i=n;return n in t&&typeof t[n]=="string"?i=t[n]:r&&n in r&&typeof r[n]=="string"&&(i=r[n]),i in e?e[i]:e[n]}const yu="";function MHe(e="vibora"){return or({queryKey:["monitoring","claude-instances",e],queryFn:()=>Zt(`${yu}/api/monitoring/claude-instances?filter=${e}`),refetchInterval:5e3})}function jHe(e="1h"){return or({queryKey:["monitoring","system-metrics",e],queryFn:()=>Zt(`${yu}/api/monitoring/system-metrics?window=${e}`),refetchInterval:5e3})}function FHe(){const e=zr();return pr({mutationFn:({terminalId:t,pid:n})=>{if(t)return Zt(`${yu}/api/monitoring/claude-instances/${t}/kill`,{method:"POST"});if(n)return Zt(`${yu}/api/monitoring/claude-instances/${n}/kill-pid`,{method:"POST"});throw new Error("Either terminalId or pid must be provided")},onSuccess:()=>{e.invalidateQueries({queryKey:["monitoring","claude-instances"]})}})}function fb(e){if(e===0)return"0 B";const t=1024,n=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,r)).toFixed(1))} ${n[r]}`}function BHe(e){return{"1m":"1 min","10m":"10 min","1h":"1 hour","3h":"3 hours","6h":"6 hours","12h":"12 hours","24h":"24 hours"}[e]}function UHe(e="memory",t=10){return or({queryKey:["monitoring","top-processes",e,t],queryFn:()=>Zt(`${yu}/api/monitoring/top-processes?sort=${e}&limit=${t}`),refetchInterval:5e3})}function $He(){return or({queryKey:["monitoring","docker-stats"],queryFn:()=>Zt(`${yu}/api/monitoring/docker-stats`),refetchInterval:5e3})}function HHe(){return or({queryKey:["monitoring","vibora-instances"],queryFn:()=>Zt(`${yu}/api/monitoring/vibora-instances`),refetchInterval:5e3})}function zHe(){const e=zr();return pr({mutationFn:({backendPid:t})=>Zt(`${yu}/api/monitoring/vibora-instances/${t}/kill`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["monitoring","vibora-instances"]})}})}function VHe(){return or({queryKey:["monitoring","claude-usage"],queryFn:()=>Zt(`${yu}/api/monitoring/claude-usage`),refetchInterval:5e3})}const WHe=Bs("/monitoring/")({component:rze}),GHe=["1m","10m","1h","3h","6h","12h","24h"],dX={cpu:{label:"CPU",color:"var(--chart-system)"},memoryUsed:{label:"Used",color:"var(--chart-system)"},memoryCache:{label:"Cache / Buffers",color:"var(--muted-foreground)"},disk:{label:"Disk",color:"var(--muted-foreground)"}};function qHe(){const{t:e}=an("monitoring"),[t,n]=k.useState("vibora"),[r,i]=k.useState(null),{data:a,isLoading:s,error:o}=MHe(t),l=FHe(),u=a?.reduce((d,p)=>d+p.ramMB,0)||0;k.useEffect(()=>{r!==null&&a&&!a.some(d=>d.pid===r)&&i(null)},[r,a]);const f=d=>{i(d.pid);const p=d.isViboraManaged&&d.terminalId?{terminalId:d.terminalId}:{pid:d.pid};l.mutate(p,{onError:()=>i(null)})};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Gl,{id:"show-all",checked:t==="all",onCheckedChange:d=>n(d?"all":"vibora")}),y.jsx(tte,{htmlFor:"show-all",className:"text-sm text-muted-foreground",children:e("claude.showAllInstances")})]}),a&&y.jsxs("span",{className:"text-sm text-muted-foreground",children:[e("claude.instanceCount",{count:a.length}),u>0&&` · ${e("claude.totalRam",{ram:u.toFixed(0)})}`]})]}),s&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),o&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("claude.error",{message:o.message})}),a&&a.length===0&&y.jsxs("div",{className:"py-12 text-center text-muted-foreground",children:[e("claude.empty"),t==="vibora"&&e("claude.emptyVibora")]}),a&&a.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"hidden lg:grid grid-cols-[60px_150px_1fr_1fr_80px_80px] gap-4 px-3 py-2 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("claude.headers.pid")}),y.jsx("span",{children:e("claude.headers.terminal")}),y.jsx("span",{children:e("claude.headers.task")}),y.jsx("span",{children:e("claude.headers.workingDirectory")}),y.jsx("span",{className:"text-right",children:e("claude.headers.ram")}),y.jsx("span",{className:"text-right",children:e("claude.headers.actions")})]}),a.map(d=>y.jsxs(Aa,{className:"px-3 py-2",children:[y.jsxs("div",{className:"flex flex-col gap-1 lg:hidden",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("span",{className:"text-sm font-medium truncate",children:d.taskId?y.jsx(Li,{to:"/tasks/$taskId",params:{taskId:d.taskId},className:"hover:text-foreground hover:underline",children:d.taskTitle}):y.jsx("span",{className:"text-muted-foreground",children:d.isViboraManaged?d.terminalName:e("claude.source.external")})}),y.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y.jsxs("span",{className:"tabular-nums text-sm text-muted-foreground",children:[d.ramMB.toFixed(0)," MB"]}),y.jsx(Ye,{variant:"ghost",size:"xs",onClick:()=>f(d),disabled:r!==null,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${r!==null?"opacity-50":""}`,children:y.jsx(ve,{icon:r===d.pid?xn:aa,className:`size-3.5 ${r===d.pid?"animate-spin":""}`})})]})]}),y.jsx("span",{className:"text-xs text-muted-foreground truncate",title:d.cwd,children:d.cwd})]}),y.jsxs("div",{className:"hidden lg:grid grid-cols-[60px_150px_1fr_1fr_80px_80px] items-center gap-4",children:[y.jsx("span",{className:"font-mono text-xs",children:d.pid}),y.jsx("span",{className:"truncate text-sm",children:d.isViboraManaged?y.jsx("span",{children:d.terminalName||`Terminal ${d.terminalId?.slice(0,8)}`}):y.jsx("span",{className:"text-muted-foreground",children:e("claude.source.external")})}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",children:d.taskId?y.jsx(Li,{to:"/tasks/$taskId",params:{taskId:d.taskId},className:"hover:text-foreground hover:underline",children:d.taskTitle}):e("claude.noTask")}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",title:d.cwd,children:d.cwd}),y.jsxs("span",{className:"text-right tabular-nums text-sm",children:[d.ramMB.toFixed(0)," MB"]}),y.jsx("div",{className:"flex justify-end",children:y.jsxs(Ye,{variant:"ghost",size:"xs",onClick:()=>f(d),disabled:r!==null,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${r!==null?"opacity-50":""}`,children:[y.jsx(ve,{icon:r===d.pid?xn:aa,className:`size-3.5 ${r===d.pid?"animate-spin":""}`}),r===d.pid?e("claude.killing"):e("claude.kill")]})})]})]},d.pid))]})]})}function KHe(){const{t:e}=an("monitoring"),[t,n]=k.useState("1h"),{data:r,isLoading:i,error:a}=jHe(t),s=r?.dataPoints.map(o=>({time:new Date(o.timestamp*1e3).toLocaleTimeString(),timestamp:o.timestamp,cpu:Math.round(o.cpuPercent*10)/10,memoryUsed:Math.round(o.memoryUsedPercent*10)/10,memoryCache:Math.round(o.memoryCachePercent*10)/10}))||[];return y.jsxs("div",{className:"space-y-6",children:[y.jsx("div",{className:"flex gap-1",children:GHe.map(o=>y.jsx(Ye,{variant:t===o?"secondary":"ghost",size:"xs",onClick:()=>n(o),children:BHe(o)},o))}),i&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),a&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("system.error",{message:a.message})}),r&&y.jsxs("div",{className:"space-y-6",children:[y.jsxs(Aa,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.cpuUsage")}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[r.current.cpu.toFixed(1),"%"]})]}),y.jsx(oX,{config:dX,className:"h-[150px] w-full",children:y.jsxs(sX,{data:s,margin:{left:0,right:0},children:[y.jsx(EL,{strokeDasharray:"3 3",vertical:!1}),y.jsx(ay,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:40}),y.jsx(sy,{domain:[0,100],tickLine:!1,axisLine:!1,tickMargin:8,tickFormatter:o=>`${o}%`}),y.jsx(lX,{content:y.jsx(uX,{hideLabel:!0,formatter:o=>[`${o}% `,"CPU"]})}),y.jsx(Qo,{type:"monotone",dataKey:"cpu",stroke:"var(--color-cpu)",fill:"var(--color-cpu)",fillOpacity:.4,strokeWidth:2})]})})]}),y.jsxs(Aa,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.memoryUsage")}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[fb(r.current.memory.used)," ",e("system.memoryLabels.used").toLowerCase()," + ",fb(r.current.memory.cache)," ",e("system.memoryLabels.cache").toLowerCase()," / ",fb(r.current.memory.total)]})]}),y.jsx(oX,{config:dX,className:"h-[150px] w-full",children:y.jsxs(sX,{data:s,margin:{left:0,right:0},children:[y.jsx(EL,{strokeDasharray:"3 3",vertical:!1}),y.jsx(ay,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:40}),y.jsx(sy,{domain:[0,100],tickLine:!1,axisLine:!1,tickMargin:8,tickFormatter:o=>`${o}%`}),y.jsx(lX,{content:y.jsx(uX,{hideLabel:!0,formatter:(o,l)=>{const u=e(l==="memoryUsed"?"system.memoryLabels.used":"system.memoryLabels.cache");return[`${o}% `,u]}})}),y.jsx(Qo,{type:"monotone",dataKey:"memoryUsed",stroke:"var(--color-memoryUsed)",fill:"var(--color-memoryUsed)",fillOpacity:.5,strokeWidth:2,stackId:"memory"}),y.jsx(Qo,{type:"monotone",dataKey:"memoryCache",stroke:"var(--color-memoryCache)",fill:"var(--color-memoryCache)",fillOpacity:.4,strokeWidth:1,stackId:"memory"})]})})]}),y.jsxs(Aa,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.diskUsage",{path:r.current.disk.path})}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[r.current.disk.usedPercent.toFixed(1),"% (",fb(r.current.disk.used)," /"," ",fb(r.current.disk.total),")"]})]}),y.jsx("div",{className:"h-4 w-full overflow-hidden rounded-full bg-muted",children:y.jsx("div",{className:"h-full bg-chart-system transition-all",style:{width:`${Math.min(r.current.disk.usedPercent,100)}%`}})})]})]})]})}function YHe(){const{t:e}=an("monitoring"),[t,n]=k.useState("memory"),{data:r,isLoading:i,error:a}=UHe(t),{data:s,isLoading:o}=$He();return y.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start",children:[y.jsxs(Aa,{className:"p-4 lg:flex-1 lg:min-w-0 h-[400px] flex flex-col",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between shrink-0",children:[y.jsx("h3",{className:"font-medium",children:e("processes.topProcesses")}),y.jsxs(Qi,{value:t,onValueChange:l=>n(l),children:[y.jsx(ea,{className:"w-32",children:y.jsx(Ji,{})}),y.jsxs(ta,{children:[y.jsx(Nn,{value:"memory",children:e("processes.sortBy.memory")}),y.jsx(Nn,{value:"cpu",children:e("processes.sortBy.cpu")})]})]})]}),i&&y.jsx("div",{className:"flex items-center justify-center flex-1",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),a&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("processes.error",{message:a.message})}),r&&r.length>0&&y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"grid grid-cols-[60px_120px_1fr_70px_80px] gap-2 px-2 py-1 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("processes.headers.pid")}),y.jsx("span",{children:e("processes.headers.name")}),y.jsx("span",{children:e("processes.headers.command")}),y.jsx("span",{className:"text-right",children:e("processes.headers.memory")}),y.jsx("span",{className:"text-right",children:"%"})]}),r.map(l=>y.jsxs("div",{className:"grid grid-cols-[60px_120px_1fr_70px_80px] gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted/50",children:[y.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:l.pid}),y.jsx("span",{className:"truncate font-medium",title:l.name,children:l.name}),y.jsx("span",{className:"truncate text-muted-foreground text-xs",title:l.command,children:l.command}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.memoryMB.toFixed(0)," MB"]}),y.jsxs("span",{className:"text-right tabular-nums text-muted-foreground",children:[l.memoryPercent.toFixed(1),"%"]})]},l.pid))]})}),r&&r.length===0&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.empty")})]}),y.jsxs(Aa,{className:"p-4 lg:flex-1 lg:min-w-0 h-[400px] flex flex-col",children:[y.jsx("div",{className:"mb-4 flex items-center justify-between shrink-0",children:y.jsxs("h3",{className:"font-medium",children:[e("processes.containers"),s?.runtime&&y.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:["(",s.runtime,")"]})]})}),o&&y.jsx("div",{className:"flex items-center justify-center flex-1",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),s&&!s.available&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.containersUnavailable")}),s&&s.available&&s.containers.length===0&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.containersEmpty")}),s&&s.available&&s.containers.length>0&&y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"grid grid-cols-[1fr_70px_100px_80px] gap-2 px-2 py-1 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("processes.headers.name")}),y.jsx("span",{className:"text-right",children:"CPU"}),y.jsx("span",{className:"text-right",children:e("processes.headers.memory")}),y.jsx("span",{className:"text-right",children:"%"})]}),s.containers.map(l=>y.jsxs("div",{className:"grid grid-cols-[1fr_70px_100px_80px] gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted/50",children:[y.jsx("span",{className:"truncate font-medium",title:l.name,children:l.name}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.cpuPercent.toFixed(1),"%"]}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.memoryMB.toFixed(0)," / ",l.memoryLimit.toFixed(0)," MB"]}),y.jsxs("span",{className:"text-right tabular-nums text-muted-foreground",children:[l.memoryPercent.toFixed(1),"%"]})]},l.id))]})})]})]})}function XHe(){const{t:e}=an("monitoring"),[t,n]=k.useState(null),{data:r,isLoading:i,error:a}=HHe(),s=zHe();k.useEffect(()=>{t!==null&&r&&!r.some(l=>l.backend?.pid===t)&&n(null)},[t,r]);const o=l=>{l.backend&&(n(l.backend.pid),s.mutate({backendPid:l.backend.pid},{onError:()=>n(null)}))};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"text-sm text-muted-foreground",children:e("vibora.description")}),r&&r.length>0&&y.jsx("span",{className:"text-sm text-muted-foreground",children:e("vibora.instanceCount",{count:r.length})})]}),i&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),a&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("vibora.error",{message:a.message})}),r&&r.length===0&&y.jsx("div",{className:"py-12 text-center text-muted-foreground",children:e("vibora.empty")}),r&&r.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"hidden lg:grid grid-cols-[80px_100px_1fr_100px_80px] gap-4 px-3 py-2 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("vibora.headers.port")}),y.jsx("span",{children:e("vibora.headers.mode")}),y.jsx("span",{children:e("vibora.headers.directory")}),y.jsx("span",{className:"text-right",children:e("vibora.headers.ram")}),y.jsx("span",{className:"text-right",children:e("vibora.headers.actions")})]}),r.map(l=>{const u=t===l.backend?.pid,f=t!==null;return y.jsxs(Aa,{className:"px-3 py-2",children:[y.jsxs("div",{className:"flex flex-col gap-1 lg:hidden",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsxs("span",{className:"text-sm font-medium",children:[y.jsxs("span",{className:"font-mono",children:[":",l.port]}),y.jsxs("span",{className:`ml-2 text-xs ${l.mode==="development"?"text-muted-foreground":""}`,children:[l.mode==="development"?e("vibora.mode.dev"):e("vibora.mode.prod"),l.frontend&&` + ${e("vibora.vite")}`]})]}),y.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y.jsxs("span",{className:"tabular-nums text-sm text-muted-foreground",children:[l.totalMemoryMB.toFixed(0)," MB"]}),y.jsx(Ye,{variant:"ghost",size:"xs",onClick:()=>o(l),disabled:f||!l.backend,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${f?"opacity-50":""}`,children:y.jsx(ve,{icon:u?xn:aa,className:`size-3.5 ${u?"animate-spin":""}`})})]})]}),y.jsx("span",{className:"text-xs text-muted-foreground truncate",title:l.viboraDir,children:l.viboraDir})]}),y.jsxs("div",{className:"hidden lg:grid grid-cols-[80px_100px_1fr_100px_80px] items-center gap-4",children:[y.jsx("span",{className:"font-mono text-sm",children:l.port}),y.jsxs("span",{className:`text-xs ${l.mode==="development"?"text-muted-foreground":""}`,children:[l.mode==="development"?e("vibora.mode.dev"):e("vibora.mode.prod"),l.frontend&&` + ${e("vibora.vite")}`]}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",title:l.viboraDir,children:l.viboraDir}),y.jsxs("span",{className:"text-right tabular-nums text-sm",children:[l.totalMemoryMB.toFixed(0)," MB"]}),y.jsx("div",{className:"flex justify-end",children:y.jsxs(Ye,{variant:"ghost",size:"xs",onClick:()=>o(l),disabled:f||!l.backend,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${f?"opacity-50":""}`,children:[y.jsx(ve,{icon:u?xn:aa,className:`size-3.5 ${u?"animate-spin":""}`}),e(u?"vibora.killing":"vibora.kill")]})})]})]},l.backend?.pid||l.port)})]})]})}function ZHe(e){return e>=90?"text-destructive":e>=70?"text-muted-foreground":"text-chart-system"}function QHe(e){if(e<60)return`${e}m`;const t=Math.floor(e/60),n=e%60;return n>0?`${t}h ${n}m`:`${t}h`}function xI(e){const t=new Date(e),n=new Date,r=t.getTime()-n.getTime(),i=Math.floor(r/(1e3*60*60*24));return i===0?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):i===1?`Tomorrow ${t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`:i<7?t.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function x_({percent:e,label:t,subtitle:n,color:r}){const i=[{value:Math.min(e,100),fill:r}],a=Math.round(96*fc),s=Math.round(48*fc),o=Math.round(32*fc),l=Math.round(44*fc),u=Math.round(10*fc),f=Math.round(5*fc);return y.jsx(Aa,{className:"p-4",children:y.jsxs("div",{className:"flex items-center gap-4",children:[y.jsxs("div",{className:"relative size-24 shrink-0",children:[y.jsxs(NHe,{width:a,height:a,cx:s,cy:s,innerRadius:o,outerRadius:l,barSize:u,data:i,startAngle:90,endAngle:-270,children:[y.jsx(e0,{type:"number",domain:[0,100],angleAxisId:0,tick:!1}),y.jsx(t0,{background:{fill:"var(--border)"},dataKey:"value",cornerRadius:f,angleAxisId:0})]}),y.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:y.jsxs("span",{className:`text-lg font-semibold tabular-nums ${ZHe(e)}`,children:[e.toFixed(0),"%"]})})]}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsx("h3",{className:"text-sm font-medium truncate",children:t}),y.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:n})]})]})})}function JHe(){const{t:e}=an("monitoring"),{data:t,isLoading:n,error:r}=VHe(),i=a=>a>=90?"var(--destructive)":a>=70?"var(--muted-foreground)":"var(--chart-system)";return y.jsxs("div",{className:"space-y-4",children:[n&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),r&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("usage.error",{message:r.message})}),t&&!t.available&&y.jsx("div",{className:"rounded-lg border border-muted-foreground/50 bg-muted p-4 text-sm text-muted-foreground",children:t.error||e("usage.unavailable")}),t&&t.available&&y.jsxs("div",{className:"space-y-3",children:[y.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.fiveHour&&y.jsx(x_,{percent:t.fiveHour.percentUsed,label:e("usage.fiveHourBlock"),subtitle:e("usage.resetsIn",{time:QHe(t.fiveHour.timeRemainingMinutes)}),color:i(t.fiveHour.percentUsed)}),t.sevenDay&&y.jsx(x_,{percent:t.sevenDay.percentUsed,label:e("usage.sevenDayRolling"),subtitle:`${e("usage.resetsAt",{time:xI(t.sevenDay.resetAt)})} · ${e("usage.weekProgress",{percent:t.sevenDay.weekProgressPercent})}`,color:i(t.sevenDay.percentUsed)})]}),(t.sevenDayOpus||t.sevenDaySonnet)&&y.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.sevenDayOpus&&y.jsx(x_,{percent:t.sevenDayOpus.percentUsed,label:e("usage.opusWeekly"),subtitle:e("usage.resetsAt",{time:xI(t.sevenDayOpus.resetAt)}),color:i(t.sevenDayOpus.percentUsed)}),t.sevenDaySonnet&&y.jsx(x_,{percent:t.sevenDaySonnet.percentUsed,label:e("usage.sonnetWeekly"),subtitle:e("usage.resetsAt",{time:xI(t.sevenDaySonnet.resetAt)}),color:i(t.sevenDaySonnet.percentUsed)})]})]})]})}const wI={IN_PROGRESS:"bg-muted-foreground/20 text-muted-foreground",IN_REVIEW:"bg-primary/20 text-primary",DONE:"bg-accent/20 text-accent",CANCELED:"bg-destructive/20 text-destructive",ORPHANED:"bg-destructive/20 text-destructive"},eze=["IN_PROGRESS","IN_REVIEW","DONE","CANCELED","ORPHANED"];function tze(){const{t:e}=an("common");return t=>{const n=new Date(t),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),s=Math.floor(a/60),o=Math.floor(s/60),l=Math.floor(o/24);return l>0?l===1?e("time.dayAgo"):e("time.daysAgo",{count:l}):o>0?o===1?e("time.hourAgo"):e("time.hoursAgo",{count:o}):s>0?s===1?e("time.minuteAgo"):e("time.minutesAgo",{count:s}):e("time.justNow")}}function nze(){const{t:e}=an("common"),{t}=an("worktrees"),n=tze(),{worktrees:r,summary:i,isLoading:a,isLoadingDetails:s,error:o,refetch:l}=tne(),u=nne(),[f,d]=k.useState(new Set),[p,m]=k.useState(!1),[S,E]=k.useState(!1),[g,_]=k.useState(!1),[b,x]=k.useState(null),[T,w]=k.useState(null),[C,R]=k.useState(!1),O=$=>{d(q=>{const K=new Set(q);return K.has($)?K.delete($):K.add($),K})},I=()=>{d(new Set)},D=k.useMemo(()=>f.size===0?r:r.filter($=>!!($.isOrphaned&&f.has("ORPHANED")||$.taskStatus&&f.has($.taskStatus))),[r,f]),P=k.useMemo(()=>r.filter($=>$.taskStatus==="DONE"||$.taskStatus==="CANCELED"),[r]),H=async()=>{if(P.length!==0){E(!0);try{for(const $ of P)await u.mutateAsync({worktreePath:$.path,repoPath:$.repoPath,deleteLinkedTask:g});m(!1),l()}catch{}finally{E(!1)}}},M=async($,q)=>{x($.path);try{await u.mutateAsync({worktreePath:$.path,repoPath:$.repoPath,deleteLinkedTask:q}),w(null),l()}catch{}finally{x(null)}},W=$=>{$||(w(null),R(!1))},V=$=>{m($),$||_(!1)};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[y.jsx("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:(i||r.length>0)&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:t("summary.total",{count:i?.total??r.length})}),(i?.orphaned??r.filter($=>$.isOrphaned).length)>0&&y.jsx("span",{className:"text-destructive",children:t("summary.orphaned",{count:i?.orphaned??r.filter($=>$.isOrphaned).length})}),s?y.jsx("span",{className:"animate-pulse",children:e("status.calculating")}):i?y.jsx("span",{children:i.totalSizeFormatted}):null]})}),y.jsxs("div",{className:"flex items-center gap-2",children:[P.length>0&&y.jsxs(Bc,{open:p,onOpenChange:V,children:[y.jsxs(Uc,{render:y.jsx(Ye,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground hover:text-destructive",disabled:s}),children:[y.jsx(ve,{icon:Nee,size:12,strokeWidth:2}),t("cleanup.button",{count:P.length})]}),y.jsxs($c,{children:[y.jsxs(Hc,{children:[y.jsx(Vc,{children:t("cleanup.title")}),y.jsxs(Wc,{children:[t("cleanup.description",{count:P.length}),g&&` ${t("cleanup.linkedTasksWillBeDeleted")}`]}),y.jsxs("div",{className:"space-y-3",children:[y.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[y.jsx(rl,{checked:g,onCheckedChange:$=>_($===!0),disabled:S}),t("cleanup.alsoDeleteLinkedTasks")]}),y.jsx("p",{className:"font-medium text-destructive text-xs",children:t("cleanup.cannotUndo")})]})]}),y.jsxs(zc,{children:[y.jsx(Gc,{disabled:S,children:e("buttons.cancel")}),y.jsxs(Ye,{variant:"destructive",onClick:H,disabled:S,className:"gap-2",children:[S&&y.jsx(ve,{icon:xn,size:14,strokeWidth:2,className:"animate-spin"}),S?e("status.deleting"):t("delete.button",{count:P.length})]})]})]})]}),f.size>0&&y.jsxs(Ye,{variant:"ghost",size:"sm",onClick:I,className:"gap-1.5 text-xs",children:[y.jsx(ve,{icon:aa,size:12,strokeWidth:2}),e("buttons.clearFilters")]})]})]}),y.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:eze.map($=>{const q=f.has($);return y.jsx("button",{onClick:()=>O($),className:We("rounded-full px-2.5 py-1 text-xs font-medium transition-colors",q?wI[$]:"bg-muted text-muted-foreground hover:bg-muted/80"),children:e(`statuses.${$}`)},$)})}),a&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ve,{icon:xn,className:"size-6 animate-spin text-muted-foreground"})}),o&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:t("error.failedToLoad",{message:o.message})}),!a&&!o&&D.length===0&&y.jsx("div",{className:"py-12 text-center text-muted-foreground",children:f.size>0?t("empty.noMatch"):t("empty.noWorktrees")}),!a&&D.length>0&&y.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:D.map($=>{const q=$.sizeFormatted==="..."||$.branch==="...",K=!$.isOrphaned&&$.taskId,U=b===$.path;return y.jsx(Aa,{className:"transition-colors hover:border-border/80",children:y.jsxs(Tf,{className:"flex items-start justify-between gap-4 py-4",children:[y.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"truncate font-medium",children:$.name}),$.isOrphaned?y.jsx(lo,{className:We("shrink-0",wI.ORPHANED),children:e("statuses.ORPHANED")}):$.taskStatus?y.jsx(lo,{className:We("shrink-0",wI[$.taskStatus]),children:e(`statuses.${$.taskStatus}`)}):null]}),y.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(ve,{icon:Pi,size:12,strokeWidth:2,className:"shrink-0"}),y.jsx("span",{className:"truncate font-mono",children:$.path})]}),y.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(ve,{icon:wE,size:12,strokeWidth:2,className:"shrink-0"}),$.branch==="..."?y.jsx("span",{className:"inline-block animate-pulse rounded bg-muted h-3 w-16"}):y.jsx("span",{className:"font-mono",children:$.branch})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(ve,{icon:Lee,size:12,strokeWidth:2,className:"shrink-0"}),$.sizeFormatted==="..."?y.jsx("span",{className:"inline-block animate-pulse rounded bg-muted h-3 w-12"}):y.jsx("span",{children:$.sizeFormatted})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(ve,{icon:Iee,size:12,strokeWidth:2,className:"shrink-0"}),y.jsx("span",{children:n($.lastModified)})]})]}),$.taskId&&$.taskTitle&&y.jsx("div",{className:"flex items-center gap-1.5 pt-1",children:y.jsxs(Li,{to:"/tasks/$taskId",params:{taskId:$.taskId},className:"inline-flex items-center gap-1 text-foreground hover:underline",children:[y.jsx("span",{className:"truncate",children:$.taskTitle}),y.jsx(ve,{icon:Oy,size:12,strokeWidth:2,className:"shrink-0"})]})})]})]}),y.jsxs(Bc,{open:T?.path===$.path,onOpenChange:W,children:[y.jsx(Uc,{render:y.jsx(Ye,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:q||U,onClick:()=>w($)}),children:y.jsx(ve,{icon:U?xn:km,size:14,strokeWidth:2,className:U?"animate-spin":""})}),y.jsxs($c,{children:[y.jsxs(Hc,{children:[y.jsx(Vc,{children:t("delete.title")}),y.jsxs(Wc,{children:[t("delete.description")," ",y.jsx("span",{className:"font-mono",children:$.name}),".",C&&K&&y.jsxs(y.Fragment,{children:[" ",t("delete.linkedTaskWillBeDeleted",{title:$.taskTitle})]})," ",t("delete.cannotUndo")]}),K&&y.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[y.jsx(rl,{checked:C,onCheckedChange:F=>R(F===!0),disabled:U}),t("delete.alsoDeleteLinkedTask",{title:$.taskTitle})]})]}),y.jsxs(zc,{children:[y.jsx(Gc,{disabled:U,children:e("buttons.cancel")}),y.jsxs(Ye,{variant:"destructive",onClick:()=>M($,C),disabled:U,className:"gap-2",children:[U&&y.jsx(ve,{icon:xn,size:14,strokeWidth:2,className:"animate-spin"}),e(U?"status.deleting":"buttons.delete")]})]})]})]})]})},$.path)})})]})}function rze(){const{t:e}=an("monitoring"),{data:t}=Kte(),[n,r]=k.useState("system"),a=[{value:"system",label:e("tabs.system")},{value:"processes",label:e("tabs.processes")},{value:"claude",label:e("tabs.claude")},{value:"vibora",label:e("tabs.vibora"),devOnly:!0},{value:"worktrees",label:e("tabs.worktrees")},{value:"usage",label:e("tabs.usage")}].filter(s=>!s.devOnly||t?.enabled);return y.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[y.jsxs("div",{className:"flex shrink-0 items-center border-b border-border bg-background px-4 py-2",children:[y.jsx("div",{className:"sm:hidden",children:y.jsxs(Qi,{value:n,onValueChange:s=>r(s),children:[y.jsx(ea,{size:"sm",className:"w-auto gap-2",children:y.jsx(Ji,{})}),y.jsx(ta,{children:a.map(s=>y.jsx(Nn,{value:s.value,children:s.label},s.value))})]})}),y.jsx("div",{className:"hidden sm:block",children:y.jsx(Dc,{value:n,onValueChange:s=>r(s),children:y.jsx(Lc,{variant:"line",children:a.map(s=>y.jsx(Ii,{value:s.value,className:"px-3 py-1.5",children:s.label},s.value))})})})]}),y.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[n==="system"&&y.jsx(KHe,{}),n==="processes"&&y.jsx(YHe,{}),n==="claude"&&y.jsx(qHe,{}),n==="vibora"&&t?.enabled&&y.jsx(XHe,{}),n==="worktrees"&&y.jsx(nze,{}),n==="usage"&&y.jsx(JHe,{})]})]})}const ize=()=>"http://localhost:3000",hb={activeTab:"diff",browserUrl:ize(),diffOptions:{wrap:!0,ignoreWhitespace:!0,includeUntracked:!1,collapsedFiles:[]},filesViewState:{selectedFile:null,expandedDirs:[]}};function $3(e){const t=zr(),n=k.useRef(void 0),r=k.useRef({}),{data:i}=Wte(e),a=k.useMemo(()=>{const p=i?.viewState;return p?{activeTab:p.activeTab??hb.activeTab,browserUrl:p.browserUrl??hb.browserUrl,diffOptions:{...hb.diffOptions,...p.diffOptions},filesViewState:{...hb.filesViewState,...p.filesViewState}}:hb},[i?.viewState]),s=pr({mutationFn:async p=>{const m=await fetch(`/api/tasks/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({viewState:p})});if(!m.ok)throw new Error("Failed to update view state");return m.json()},onSuccess:p=>{t.setQueryData(["tasks",e],p),t.setQueryData(["tasks"],m=>m&&m.map(S=>S.id===e?p:S))}}),o=k.useCallback(p=>{const m=r.current;r.current={...m,...p,diffOptions:p.diffOptions||m.diffOptions?{...m.diffOptions,...p.diffOptions}:void 0,filesViewState:p.filesViewState||m.filesViewState?{...m.filesViewState,...p.filesViewState}:void 0};const S=r.current,E={activeTab:S.activeTab??a.activeTab,browserUrl:S.browserUrl??a.browserUrl,diffOptions:{...a.diffOptions,...S.diffOptions},filesViewState:{...a.filesViewState,...S.filesViewState}};t.setQueryData(["tasks",e],g=>g&&{...g,viewState:E}),t.setQueryData(["tasks"],g=>g&&g.map(_=>_.id===e?{..._,viewState:E}:_)),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{s.mutate(E),r.current={}},500)},[t,e,a,s]),l=k.useCallback(p=>{o({activeTab:p})},[o]),u=k.useCallback(p=>{o({browserUrl:p})},[o]),f=k.useCallback(p=>{o({diffOptions:p})},[o]),d=k.useCallback(p=>{o({filesViewState:p})},[o]);return{viewState:a,setActiveTab:l,setBrowserUrl:u,setDiffOptions:f,setFilesViewState:d}}function aze(e){return or({queryKey:["linear-ticket",e],queryFn:async()=>{if(!e)return null;const t=await fetch(`/api/linear/ticket/${e}`);return t.ok?t.json():null},enabled:!!e,staleTime:300*1e3})}function fX({taskName:e,cwd:t,className:n,aiMode:r,description:i,startupScript:a,serverPort:s=7777}){const o=k.useRef(null),l=k.useRef(null),u=k.useRef(null),f=k.useRef(!1),d=k.useRef(!1),[p,m]=k.useState(null),[S,E]=k.useState(!1),[g,_]=k.useState(!1),[b,x]=k.useState(!1),{resolvedTheme:T}=Pf(),w=T==="dark",C=w?Ere:_re;k.useEffect(()=>{Gt.taskTerminal.debug("cwd changed, resetting refs",{cwd:t}),f.current=!1,d.current=!1,m(null),E(!1)},[t]);const{setTerminalFocused:R}=YP(),{terminals:O,terminalsLoaded:I,connected:D,createTerminal:P,attachXterm:H,resizeTerminal:M,setupImagePaste:W,writeToTerminal:V,consumePendingStartup:$}=PM(),q=k.useRef(H),K=k.useRef(W),U=k.useRef(V),F=k.useRef($);k.useEffect(()=>{q.current=H},[H]),k.useEffect(()=>{K.current=W},[W]),k.useEffect(()=>{U.current=V},[V]),k.useEffect(()=>{F.current=$},[$]);const B=p?O.find(ee=>ee.id===p):null,Y=B?.status;k.useEffect(()=>{if(!o.current||l.current)return;const ee=new bre.Terminal({cursorBlink:!0,fontSize:Math.round(13*fc),fontFamily:"JetBrains Mono Variable, Menlo, Monaco, monospace",lineHeight:1.2,theme:C}),te=new vre.FitAddon,Z=new yre.WebLinksAddon;ee.loadAddon(te),ee.loadAddon(Z),ee.open(o.current),l.current=ee,u.current=te,x(!0),requestAnimationFrame(()=>{te.fit()});const G=setTimeout(()=>{te.fit(),ee.refresh(0,ee.rows-1)},100),Q=()=>R(!0),ae=()=>R(!1);return ee.textarea&&(ee.textarea.addEventListener("focus",Q),ee.textarea.addEventListener("blur",ae)),()=>{clearTimeout(G),ee.textarea&&(ee.textarea.removeEventListener("focus",Q),ee.textarea.removeEventListener("blur",ae)),R(!1),ee.dispose(),l.current=null,u.current=null,x(!1)}},[R]);const z=k.useCallback(()=>{if(!u.current||!l.current)return;u.current.fit();const{cols:ee,rows:te}=l.current;p&&M(p,ee,te)},[p,M]);k.useEffect(()=>{if(!o.current)return;const ee=()=>{requestAnimationFrame(z)};window.addEventListener("resize",ee);const te=()=>{document.visibilityState==="visible"&&requestAnimationFrame(()=>{z(),l.current&&l.current.refresh(0,l.current.rows-1)})};document.addEventListener("visibilitychange",te);const Z=new ResizeObserver(ee);Z.observe(o.current);const G=new IntersectionObserver(Q=>{Q[0]?.isIntersecting&&requestAnimationFrame(()=>{z(),l.current&&l.current.refresh(0,l.current.rows-1)})},{threshold:.1});return G.observe(o.current),()=>{window.removeEventListener("resize",ee),document.removeEventListener("visibilitychange",te),Z.disconnect(),G.disconnect()}},[z]),k.useEffect(()=>{if(!D||!t||!b||!I)return;const ee=O.find(te=>te.cwd===t);if(ee){m(ee.id);return}if(!f.current&&l.current){f.current=!0,E(!0);const{cols:te,rows:Z}=l.current;P({name:e,cols:te,rows:Z,cwd:t,startup:{startupScript:a,aiMode:r,description:i,taskName:e,serverPort:s}})}},[D,t,b,I,O,e,P]),k.useEffect(()=>{if(!t)return;const ee=O.find(Z=>Z.cwd===t);if(!ee)return;const te=p&&O.some(Z=>Z.id===p);(!p||!te)&&(Gt.taskTerminal.debug("setting terminalId",{newId:ee.id,prevId:p,reason:p?"tempId replaced":"initial",cwd:t,terminalCount:O.length}),m(ee.id),E(!1),p&&!te&&(d.current=!1))},[O,t,p]),k.useEffect(()=>{if(Gt.taskTerminal.debug("attach effect",{terminalId:p,hasTermRef:!!l.current,hasContainerRef:!!o.current,attachedRef:d.current}),!p||!l.current||!o.current||d.current)return;Gt.taskTerminal.debug("attach effect passed guards, calling attachXterm",{terminalId:p});const ee=G=>{requestAnimationFrame(z);const Q=F.current(G);if(Gt.taskTerminal.debug("onAttached checking pending startup",{terminalId:G,hasPendingStartup:!!Q}),Q){Gt.taskTerminal.info("onAttached: running startup commands",{terminalId:G}),_(!0);const{startupScript:ae,aiMode:se,description:ne,taskName:ye,serverPort:Ee}=Q;ae&&setTimeout(()=>{const we=`source /dev/stdin <<'VIBORA_STARTUP'
112
112
  ${ae}
113
113
  VIBORA_STARTUP`;U.current(G,we+"\r")},100);const he=Ee??7777,_e=he!==7777?` --port=${he}`:"",be=`You are working in a Vibora task worktree. Commit after completing each logical unit of work (feature, fix, refactor) to preserve progress. When you finish working and need user input, run: vibora current-task review${_e}. When linking a PR: vibora current-task pr <url>${_e}. For notifications: vibora notify "Title" "Message"${_e}.`,Se=(ne?`${ye}: ${ne}`:ye).replace(/"/g,'\\"'),$e=be.replace(/"/g,'\\"'),Te=se==="plan"?`claude "${Se}" --append-system-prompt "${$e}" --session-id "${G}" --allow-dangerously-skip-permissions --permission-mode plan`:`claude "${Se}" --append-system-prompt "${$e}" --session-id "${G}" --dangerously-skip-permissions`;setTimeout(()=>{Gt.taskTerminal.debug("writing claude command to terminal",{terminalId:G,taskCommand:Te.substring(0,50)+"..."}),U.current(G,Te+"\r"),_(!1)},ae?5e3:100)}},te=q.current(p,l.current,{onAttached:ee}),Z=K.current(o.current,p);return d.current=!0,Gt.taskTerminal.debug("attachedRef set to true",{terminalId:p}),()=>{Gt.taskTerminal.debug("cleanup running, setting attachedRef to false",{terminalId:p}),te(),Z(),d.current=!1}},[p,z]),k.useEffect(()=>{l.current&&(l.current.options.theme=C)},[C]);const J=k.useCallback(ee=>{p&&U.current(p,ee)},[p]);return t?y.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[!D&&y.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:"Connecting to terminal server..."}),Y==="error"&&y.jsx("div",{className:"shrink-0 px-2 py-1 bg-destructive/20 text-destructive text-xs",children:"Terminal failed to start. The worktree directory may not exist."}),Y==="exited"&&y.jsxs("div",{className:"shrink-0 px-2 py-1 bg-muted text-muted-foreground text-xs",children:["Terminal exited (code: ",B?.exitCode,")"]}),y.jsxs("div",{className:"relative min-h-0 flex-1",children:[y.jsx("div",{ref:o,className:We("h-full w-full overflow-hidden p-2 bg-terminal-background",n)}),S&&!p&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-terminal-background",children:y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx(ve,{icon:xn,size:24,strokeWidth:2,className:We("animate-spin",w?"text-white/50":"text-black/50")}),y.jsx("span",{className:We("font-mono text-sm",w?"text-white/50":"text-black/50"),children:"Initializing terminal..."})]})}),g&&y.jsx("div",{className:"pointer-events-auto absolute inset-0 z-10 flex items-center justify-center bg-terminal-background/90",children:y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx(ve,{icon:xn,size:24,strokeWidth:2,className:We("animate-spin",w?"text-white/60":"text-black/60")}),y.jsx("span",{className:We("font-mono text-sm",w?"text-white/60":"text-black/60"),children:"Starting Claude Code..."})]})}),y.jsx("button",{onClick:()=>l.current?.scrollToBottom(),className:We("absolute top-2 right-5 p-1 transition-colors",w?"text-white/50 hover:text-white/80":"text-black/50 hover:text-black/80"),children:y.jsx(ve,{icon:VP,size:20,strokeWidth:2})})]}),y.jsx(RM,{onSend:J})]}):y.jsx("div",{className:We("flex h-full items-center justify-center text-muted-foreground text-sm bg-terminal-background",n),children:"No worktree path configured for this task"})}function sze(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e?.(i),n===!1||!i.defaultPrevented)return t?.(i)}}function oze(e,t=[]){let n=[];function r(a,s){const o=k.createContext(s),l=n.length;n=[...n,s];const u=d=>{const{scope:p,children:m,...S}=d,E=p?.[e]?.[l]||o,g=k.useMemo(()=>S,Object.values(S));return y.jsx(E.Provider,{value:g,children:m})};u.displayName=a+"Provider";function f(d,p){const m=p?.[e]?.[l]||o,S=k.useContext(m);if(S)return S;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${a}\``)}return[u,f]}const i=()=>{const a=n.map(s=>k.createContext(s));return function(o){const l=o?.[e]||a;return k.useMemo(()=>({[`__scope${e}`]:{...o,[e]:l}}),[o,l])}};return i.scopeName=e,[r,lze(i,...t)]}function lze(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(a){const s=r.reduce((o,{useScope:l,scopeName:u})=>{const d=l(a)[`__scope${u}`];return{...o,...d}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}var uy=globalThis?.document?k.useLayoutEffect:()=>{},uze=ex[" useInsertionEffect ".trim().toString()]||uy;function cze({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,a,s]=dze({defaultProp:t,onChange:n}),o=e!==void 0,l=o?e:i;{const f=k.useRef(e!==void 0);k.useEffect(()=>{const d=f.current;d!==o&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=o},[o,r])}const u=k.useCallback(f=>{if(o){const d=fze(f)?f(e):f;d!==e&&s.current?.(d)}else a(f)},[o,e,a,s]);return[l,u]}function dze({defaultProp:e,onChange:t}){const[n,r]=k.useState(e),i=k.useRef(n),a=k.useRef(t);return uze(()=>{a.current=t},[t]),k.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function fze(e){return typeof e=="function"}function hX(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ile(...e){return t=>{let n=!1;const r=e.map(i=>{const a=hX(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():hX(e[i],null)}}}}function ale(...e){return k.useCallback(ile(...e),e)}function hze(e){const t=pze(e),n=k.forwardRef((r,i)=>{const{children:a,...s}=r,o=k.Children.toArray(a),l=o.find(gze);if(l){const u=l.props.children,f=o.map(d=>d===l?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:d);return y.jsx(t,{...s,ref:i,children:k.isValidElement(u)?k.cloneElement(u,void 0,f):null})}return y.jsx(t,{...s,ref:i,children:a})});return n.displayName=`${e}.Slot`,n}function pze(e){const t=k.forwardRef((n,r)=>{const{children:i,...a}=n;if(k.isValidElement(i)){const s=vze(i),o=bze(a,i.props);return i.type!==k.Fragment&&(o.ref=r?ile(r,s):s),k.cloneElement(i,o)}return k.Children.count(i)>1?k.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var mze=Symbol("radix.slottable");function gze(e){return k.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===mze}function bze(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...o)=>{const l=a(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}function vze(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var yze=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],H3=yze.reduce((e,t)=>{const n=hze(`Primitive.${t}`),r=k.forwardRef((i,a)=>{const{asChild:s,...o}=i,l=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(l,{...o,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function _ze(e,t){return k.useReducer((n,r)=>t[n][r]??n,e)}var sle=e=>{const{present:t,children:n}=e,r=Eze(t),i=typeof n=="function"?n({present:r.isPresent}):k.Children.only(n),a=ale(r.ref,Sze(i));return typeof n=="function"||r.isPresent?k.cloneElement(i,{ref:a}):null};sle.displayName="Presence";function Eze(e){const[t,n]=k.useState(),r=k.useRef(null),i=k.useRef(e),a=k.useRef("none"),s=e?"mounted":"unmounted",[o,l]=_ze(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const u=w_(r.current);a.current=o==="mounted"?u:"none"},[o]),uy(()=>{const u=r.current,f=i.current;if(f!==e){const p=a.current,m=w_(u);e?l("MOUNT"):m==="none"||u?.display==="none"?l("UNMOUNT"):l(f&&p!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),uy(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,d=m=>{const E=w_(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&E&&(l("ANIMATION_END"),!i.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},p=m=>{m.target===t&&(a.current=w_(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(o),ref:k.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function w_(e){return e?.animationName||"none"}function Sze(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var xze=ex[" useId ".trim().toString()]||(()=>{}),wze=0;function Tze(e){const[t,n]=k.useState(xze());return uy(()=>{n(r=>r??String(wze++))},[e]),e||(t?`radix-${t}`:"")}var jw="Collapsible",[Cze]=oze(jw),[Aze,z3]=Cze(jw),ole=k.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:s,...o}=e,[l,u]=cze({prop:r,defaultProp:i??!1,onChange:s,caller:jw});return y.jsx(Aze,{scope:n,disabled:a,contentId:Tze(),open:l,onOpenToggle:k.useCallback(()=>u(f=>!f),[u]),children:y.jsx(H3.div,{"data-state":W3(l),"data-disabled":a?"":void 0,...o,ref:t})})});ole.displayName=jw;var lle="CollapsibleTrigger",ule=k.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=z3(lle,n);return y.jsx(H3.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":W3(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...r,ref:t,onClick:sze(e.onClick,i.onOpenToggle)})});ule.displayName=lle;var V3="CollapsibleContent",cle=k.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=z3(V3,e.__scopeCollapsible);return y.jsx(sle,{present:n||i.open,children:({present:a})=>y.jsx(kze,{...r,ref:t,present:a})})});cle.displayName=V3;var kze=k.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...a}=e,s=z3(V3,n),[o,l]=k.useState(r),u=k.useRef(null),f=ale(t,u),d=k.useRef(0),p=d.current,m=k.useRef(0),S=m.current,E=s.open||o,g=k.useRef(E),_=k.useRef(void 0);return k.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),uy(()=>{const b=u.current;if(b){_.current=_.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const x=b.getBoundingClientRect();d.current=x.height,m.current=x.width,g.current||(b.style.transitionDuration=_.current.transitionDuration,b.style.animationName=_.current.animationName),l(r)}},[s.open,r]),y.jsx(H3.div,{"data-state":W3(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!E,...a,ref:f,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":S?`${S}px`:void 0,...e.style},children:E&&i})});function W3(e){return e?"open":"closed"}var Oze=ole;const Rze=Oze,Ize=ule,Nze=cle;function Dze(e){const{viewState:t,setDiffOptions:n}=$3(e),{collapsedFiles:r}=t.diffOptions,i=k.useCallback(l=>{const u=r.includes(l);n({collapsedFiles:u?r.filter(f=>f!==l):[...r,l]})},[r,n]),a=k.useCallback(l=>{n({collapsedFiles:l})},[n]),s=k.useCallback(()=>{n({collapsedFiles:[]})},[n]),o=k.useCallback(l=>r.includes(l),[r]);return{options:t.diffOptions,setOption:(l,u)=>{n({[l]:u})},setOptions:n,toggleFileCollapse:i,collapseAll:a,expandAll:s,isFileCollapsed:o}}function Lze(e){const t=[];let n=null,r=0,i=0;for(const a of e.split(`
114
114
  `))if(a.startsWith("diff --git"))n={path:a.match(/diff --git a\/(.+?) b\//)?.[1]??"unknown",lines:[],additions:0,deletions:0},t.push(n),n.lines.push({type:"header",content:a});else if(a.startsWith("index ")||a.startsWith("---")||a.startsWith("+++"))n?.lines.push({type:"header",content:a});else if(a.startsWith("@@")){const s=a.match(/@@ -(\d+),?\d* \+(\d+),?\d* @@/);s&&(r=parseInt(s[1],10),i=parseInt(s[2],10)),n?.lines.push({type:"hunk",content:a})}else a.startsWith("+")?n&&(n.additions++,n.lines.push({type:"added",content:a.slice(1),newLineNumber:i++})):a.startsWith("-")?n&&(n.deletions++,n.lines.push({type:"removed",content:a.slice(1),oldLineNumber:r++})):a.startsWith(" ")&&n?.lines.push({type:"context",content:a.slice(1),oldLineNumber:r++,newLineNumber:i++});return t}function Pze({file:e,wrap:t,isCollapsed:n,onToggle:r}){return y.jsxs(Rze,{open:!n,onOpenChange:()=>r(),children:[y.jsx(Ize,{asChild:!0,children:y.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 bg-card border-b border-border cursor-pointer hover:bg-muted select-none",children:[y.jsx(ve,{icon:n?Oy:ky,size:12,strokeWidth:2,className:"text-muted-foreground shrink-0"}),y.jsx("span",{className:"font-mono text-xs text-foreground truncate flex-1",children:e.path}),y.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[e.additions>0&&y.jsxs("span",{className:"text-accent",children:["+",e.additions]}),e.additions>0&&e.deletions>0&&" ",e.deletions>0&&y.jsxs("span",{className:"text-destructive",children:["-",e.deletions]})]})]})}),y.jsx(Nze,{children:y.jsx("div",{className:"font-mono text-xs",children:e.lines.slice(1).map((i,a)=>y.jsxs("div",{className:We("flex px-2 py-0.5",i.type==="added"&&"bg-accent/10",i.type==="removed"&&"bg-destructive/10",i.type==="header"&&"bg-muted/50 text-muted-foreground",i.type==="hunk"&&"bg-accent/10 text-accent"),children:[(i.type==="added"||i.type==="removed"||i.type==="context")&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"w-10 shrink-0 select-none pr-2 text-right text-muted-foreground",children:i.oldLineNumber??""}),y.jsx("span",{className:"w-10 shrink-0 select-none pr-2 text-right text-muted-foreground",children:i.newLineNumber??""})]}),y.jsxs("span",{className:We("w-4 shrink-0 select-none text-center",i.type==="added"&&"text-accent",i.type==="removed"&&"text-destructive"),children:[i.type==="added"&&"+",i.type==="removed"&&"-"]}),y.jsx("span",{className:We("flex-1",t?"whitespace-pre-wrap break-all":"whitespace-pre",i.type==="added"&&"text-accent",i.type==="removed"&&"text-destructive"),children:i.content})]},a))})})]})}function pX({taskId:e,worktreePath:t}){const{options:n,setOption:r,toggleFileCollapse:i,collapseAll:a,expandAll:s,isFileCollapsed:o}=Dze(e),{wrap:l,ignoreWhitespace:u,includeUntracked:f,collapsedFiles:d}=n,{data:p,isLoading:m,error:S}=YSe(t,{ignoreWhitespace:u,includeUntracked:f}),E=k.useMemo(()=>p?.diff?Lze(p.diff):[],[p?.diff]),g=k.useMemo(()=>E.map(w=>w.path),[E]),_=E.length>0&&d.length===E.length,b=k.useMemo(()=>E.reduce((w,C)=>w+C.additions,0),[E]),x=k.useMemo(()=>E.reduce((w,C)=>w+C.deletions,0),[E]);if(k.useEffect(()=>{const w=C=>{if(C.shiftKey&&C.key==="C"&&!C.ctrlKey&&!C.metaKey&&!C.altKey){const R=C.target;if(R.tagName==="INPUT"||R.tagName==="TEXTAREA"||R.isContentEditable)return;C.preventDefault(),_?s():a(g)}};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[_,g,a,s]),!t)return y.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"No worktree selected"});if(m)return y.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Loading diff..."});if(S)return y.jsx("div",{className:"flex h-full items-center justify-center text-destructive text-sm",children:S.message});const T=p?.files?.some(w=>w.status==="untracked")??!1;return E.length===0?y.jsxs("div",{className:"flex h-full flex-col items-center justify-center text-muted-foreground text-sm gap-2",children:[y.jsx("p",{children:"No changes detected"}),p?.files&&p.files.length>0&&y.jsxs("div",{className:"text-xs",children:[y.jsx("p",{className:"text-center mb-2",children:"Modified files:"}),y.jsxs("div",{className:"flex flex-col gap-1",children:[p.files.map(w=>y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("span",{className:We("w-4 text-center",w.status==="added"&&"text-accent",w.status==="deleted"&&"text-destructive",w.status==="modified"&&"text-muted-foreground",w.status==="untracked"&&"text-muted-foreground"),children:[w.status==="added"&&"A",w.status==="deleted"&&"D",w.status==="modified"&&"M",w.status==="untracked"&&"?"]}),y.jsx("span",{children:w.path})]},w.path)),T&&y.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-muted-foreground hover:text-foreground mt-1",children:[y.jsx("input",{type:"checkbox",checked:f,onChange:w=>r("includeUntracked",w.target.checked),className:"w-4 h-3"}),y.jsx("span",{children:"Show untracked files"})]})]})]})]}):y.jsxs("div",{className:"flex flex-col h-full bg-background",children:[y.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-card border-b border-border text-xs",children:[p?.branch&&y.jsxs("span",{className:"text-muted-foreground",children:[p.branch,p.isBranchDiff&&y.jsx("span",{className:"opacity-70",children:" (vs master)"})]}),(b>0||x>0)&&y.jsxs("span",{className:"text-muted-foreground",children:[y.jsxs("span",{className:"text-accent",children:["+",b]})," ",y.jsxs("span",{className:"text-destructive",children:["-",x]})]}),y.jsx("div",{className:"flex-1"}),y.jsxs("button",{onClick:()=>_?s():a(g),className:"flex items-center gap-1 px-1.5 py-0.5 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:_?"Expand all (Shift+C)":"Collapse all (Shift+C)",children:[y.jsx(ve,{icon:_?Bee:Pee,size:12,strokeWidth:2}),y.jsx("span",{className:"hidden sm:inline",children:_?"Expand":"Collapse"})]}),y.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[y.jsx("input",{type:"checkbox",checked:l,onChange:w=>r("wrap",w.target.checked),className:"w-3 h-3"}),"Wrap"]}),y.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[y.jsx("input",{type:"checkbox",checked:u,onChange:w=>r("ignoreWhitespace",w.target.checked),className:"w-3 h-3"}),"Ignore whitespace"]}),y.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[y.jsx("input",{type:"checkbox",checked:f,onChange:w=>r("includeUntracked",w.target.checked),className:"w-3 h-3"}),"Untracked"]})]}),y.jsx(Om,{className:"flex-1 min-h-0",children:E.map(w=>y.jsx(Pze,{file:w,wrap:l,isCollapsed:o(w.path),onToggle:()=>i(w.path)},w.path))})]})}function Mze(e){const{viewState:t,setBrowserUrl:n}=$3(e);return{url:t.browserUrl,setUrl:n}}function mX({taskId:e}){const{url:t,setUrl:n}=Mze(e),[r,i]=k.useState(t),[a,s]=k.useState(0);k.useEffect(()=>{i(t)},[t]);const o=k.useCallback(()=>{s(u=>u+1)},[]),l=k.useCallback(u=>{u.preventDefault();let f=r.trim();!f.startsWith("http://")&&!f.startsWith("https://")&&(f=`http://${f}`),n(f),s(d=>d+1)},[r,n]);return y.jsxs("div",{className:"flex h-full flex-col bg-background",children:[y.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border bg-card px-2 py-1.5",children:[y.jsx(Ye,{variant:"ghost",size:"icon-xs",disabled:!0,children:y.jsx(ve,{icon:Oee,size:14,strokeWidth:2})}),y.jsx(Ye,{variant:"ghost",size:"icon-xs",disabled:!0,children:y.jsx(ve,{icon:Oy,size:14,strokeWidth:2})}),y.jsx(Ye,{variant:"ghost",size:"icon-xs",onClick:o,children:y.jsx(ve,{icon:u1e,size:14,strokeWidth:2})}),y.jsx("form",{onSubmit:l,className:"flex-1",children:y.jsx(sn,{value:r,onChange:u=>i(u.target.value),className:"h-7 bg-background text-xs",placeholder:"Enter URL..."})})]}),y.jsx("div",{className:"flex-1 overflow-hidden bg-card",children:y.jsx("iframe",{src:t,className:"h-full w-full border-0",title:"Browser Preview",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},a)})]})}function jze(e){const t=[];function n(r){for(const i of r)i.type==="file"?t.push({name:i.name,path:i.path}):i.children&&n(i.children)}return n(e),t}function dle(e){const t=e.split(".").pop()?.toLowerCase()||"";return["png","jpg","jpeg","gif","svg","webp","ico"].includes(t)?n1e:["ts","tsx","js","jsx","json","css","html","md","yaml","yml","toml","sh","py","rs","go","sql"].includes(t)?X0e:Z0e}function fle({entry:e,depth:t,selectedFile:n,expandedDirs:r,onSelectFile:i,onToggleDir:a}){const s=r.includes(e.path),o=n===e.path,l=e.type==="directory",u=k.useCallback(()=>{l?a(e.path):i(e.path)},[l,e.path,i,a]);return y.jsxs("div",{children:[y.jsxs("div",{className:We("flex items-center gap-1.5 px-2 py-0.5 cursor-pointer text-sm hover:bg-muted/50",o&&"bg-primary/10 text-primary"),style:{paddingLeft:`${t*12+8}px`},onClick:u,children:[y.jsx(ve,{icon:l?s?MN:Pi:dle(e.name),size:14,strokeWidth:2,className:We("shrink-0",l?"text-accent":"text-muted-foreground")}),y.jsx("span",{className:"break-all",children:e.name})]}),l&&s&&e.children&&y.jsx("div",{children:e.children.map(f=>y.jsx(fle,{entry:f,depth:t+1,selectedFile:n,expandedDirs:r,onSelectFile:i,onToggleDir:a},f.path))})]})}function Fze({entries:e,selectedFile:t,expandedDirs:n,onSelectFile:r,onToggleDir:i,onCollapseAll:a}){const[s,o]=k.useState(""),l=k.useMemo(()=>jze(e),[e]),u=k.useMemo(()=>{if(!s.trim())return null;const d=s.trim();return l.map(p=>({...p,score:Math.max(Kl(p.name,d),Kl(p.path,d))})).filter(p=>p.score>0).sort((p,m)=>m.score-p.score)},[l,s]),f=k.useCallback(()=>{o("")},[]);return e.length===0?y.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"No files"}):y.jsxs("div",{className:"flex flex-col h-full bg-background",children:[y.jsxs("div",{className:"flex shrink-0 items-center justify-between px-2 py-1 border-b border-border bg-card",children:[y.jsx("span",{className:"text-xs text-muted-foreground",children:"Files"}),y.jsx("button",{onClick:a,className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:"Collapse all folders",children:y.jsx(ve,{icon:Pee,size:14,strokeWidth:2})})]}),y.jsx("div",{className:"shrink-0 px-2 py-1.5 border-b border-border bg-card",children:y.jsxs("div",{className:"relative",children:[y.jsx("input",{type:"text",value:s,onChange:d=>o(d.target.value),placeholder:"Search files...",className:"w-full text-sm bg-muted/50 border border-border rounded px-2 py-1 pr-7 placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"}),s&&y.jsx("button",{onClick:f,className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-muted-foreground hover:text-foreground rounded hover:bg-muted",children:y.jsx(ve,{icon:aa,size:12,strokeWidth:2})})]})}),y.jsx("div",{className:"py-1 flex-1 overflow-auto",children:u?u.length>0?u.map(d=>y.jsxs("div",{className:We("flex items-center gap-1.5 px-2 py-0.5 cursor-pointer text-sm hover:bg-muted/50",t===d.path&&"bg-primary/10 text-primary"),onClick:()=>r(d.path),children:[y.jsx(ve,{icon:dle(d.name),size:14,strokeWidth:2,className:"shrink-0 text-muted-foreground"}),y.jsx("span",{className:"truncate",title:d.path,children:d.name}),y.jsx("span",{className:"text-xs text-muted-foreground truncate ml-auto",children:d.path.split("/").slice(0,-1).join("/")})]},d.path)):y.jsx("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No matching files"}):e.map(d=>y.jsx(fle,{entry:d,depth:0,selectedFile:t,expandedDirs:n,onSelectFile:r,onToggleDir:i},d.path))})]})}function gX(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Bze(e){if(Array.isArray(e))return e}function Uze(e,t,n){return(t=qze(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $ze(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,s,o=[],l=!0,u=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(l=(r=a.call(n)).done)&&(o.push(r.value),o.length!==t);l=!0);}catch(f){u=!0,i=f}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return o}}function Hze(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
package/dist/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/jpeg" href="/logo-dark.jpg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Vibora</title>
8
- <script type="module" crossorigin src="/assets/index-Buydhv-g.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-4r4Wiaog.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-BU3_BthC.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibora",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "description": "The Vibe Engineer's Cockpit",
5
5
  "license": "PolyForm-Shield-1.0.0",
6
6
  "repository": {
package/server/index.js CHANGED
@@ -146913,49 +146913,6 @@ function generateFilename(extension) {
146913
146913
  const time2 = now.toTimeString().slice(0, 8).replace(/:/g, "");
146914
146914
  return `clipboard-${date}-${time2}.${extension}`;
146915
146915
  }
146916
- app6.post("/", async (c) => {
146917
- const body = await c.req.parseBody();
146918
- const file = body["file"];
146919
- if (!file || !(file instanceof File)) {
146920
- return c.json({ error: "No file provided" }, 400);
146921
- }
146922
- if (!file.type.startsWith("image/")) {
146923
- return c.json({ error: "File must be an image" }, 400);
146924
- }
146925
- const mimeToExt = {
146926
- "image/png": "png",
146927
- "image/jpeg": "jpg",
146928
- "image/gif": "gif",
146929
- "image/webp": "webp",
146930
- "image/svg+xml": "svg"
146931
- };
146932
- const extension = mimeToExt[file.type] || "png";
146933
- const saveDir = join10(getViboraDir(), "uploads");
146934
- if (!existsSync8(saveDir)) {
146935
- await mkdir(saveDir, { recursive: true });
146936
- }
146937
- const filename = generateFilename(extension);
146938
- const filePath = join10(saveDir, filename);
146939
- const arrayBuffer = await file.arrayBuffer();
146940
- await writeFile(filePath, Buffer.from(arrayBuffer));
146941
- return c.json({ path: filePath });
146942
- });
146943
- app6.get("/:filename", async (c) => {
146944
- const filename = c.req.param("filename");
146945
- if (!/^clipboard-\d{4}-\d{2}-\d{2}-\d{6}\.\w+$/.test(filename)) {
146946
- return c.notFound();
146947
- }
146948
- const filePath = join10(getViboraDir(), "uploads", filename);
146949
- if (!existsSync8(filePath)) {
146950
- return c.notFound();
146951
- }
146952
- const ext2 = filename.split(".").pop()?.toLowerCase() || "";
146953
- const contentType = mimeTypes[ext2] || "application/octet-stream";
146954
- const content = await readFile(filePath);
146955
- return new Response(content, {
146956
- headers: { "Content-Type": contentType }
146957
- });
146958
- });
146959
146916
  app6.post("/sound", async (c) => {
146960
146917
  const body = await c.req.parseBody();
146961
146918
  const file = body["file"];
@@ -147025,6 +146982,49 @@ app6.get("/sound", async (c) => {
147025
146982
  headers: { "Content-Type": contentType }
147026
146983
  });
147027
146984
  });
146985
+ app6.post("/", async (c) => {
146986
+ const body = await c.req.parseBody();
146987
+ const file = body["file"];
146988
+ if (!file || !(file instanceof File)) {
146989
+ return c.json({ error: "No file provided" }, 400);
146990
+ }
146991
+ if (!file.type.startsWith("image/")) {
146992
+ return c.json({ error: "File must be an image" }, 400);
146993
+ }
146994
+ const mimeToExt = {
146995
+ "image/png": "png",
146996
+ "image/jpeg": "jpg",
146997
+ "image/gif": "gif",
146998
+ "image/webp": "webp",
146999
+ "image/svg+xml": "svg"
147000
+ };
147001
+ const extension = mimeToExt[file.type] || "png";
147002
+ const saveDir = join10(getViboraDir(), "uploads");
147003
+ if (!existsSync8(saveDir)) {
147004
+ await mkdir(saveDir, { recursive: true });
147005
+ }
147006
+ const filename = generateFilename(extension);
147007
+ const filePath = join10(saveDir, filename);
147008
+ const arrayBuffer = await file.arrayBuffer();
147009
+ await writeFile(filePath, Buffer.from(arrayBuffer));
147010
+ return c.json({ path: filePath });
147011
+ });
147012
+ app6.get("/:filename", async (c) => {
147013
+ const filename = c.req.param("filename");
147014
+ if (!/^clipboard-\d{4}-\d{2}-\d{2}-\d{6}\.\w+$/.test(filename)) {
147015
+ return c.notFound();
147016
+ }
147017
+ const filePath = join10(getViboraDir(), "uploads", filename);
147018
+ if (!existsSync8(filePath)) {
147019
+ return c.notFound();
147020
+ }
147021
+ const ext2 = filename.split(".").pop()?.toLowerCase() || "";
147022
+ const contentType = mimeTypes[ext2] || "application/octet-stream";
147023
+ const content = await readFile(filePath);
147024
+ return new Response(content, {
147025
+ headers: { "Content-Type": contentType }
147026
+ });
147027
+ });
147028
147028
  var uploads_default = app6;
147029
147029
 
147030
147030
  // node_modules/hono/dist/utils/stream.js