ccdash
Version:
Claude Code Dashboard - A comprehensive monitoring dashboard for Claude Code
1 lines • 46.4 kB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1397:(e,s,t)=>{"use strict";t.d(s,{k:()=>i});var a=t(5155),l=t(2115),r=t(5312),n=t(3999);let i=l.forwardRef((e,s)=>{let{className:t,value:l,...i}=e;return(0,a.jsx)(r.bL,{ref:s,className:(0,n.cn)("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...i,children:(0,a.jsx)(r.C1,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:"translateX(-".concat(100-(l||0),"%)")}})})});i.displayName=r.bL.displayName},4964:(e,s,t)=>{"use strict";t.d(s,{Xi:()=>d,av:()=>o,j7:()=>c,tU:()=>i});var a=t(5155),l=t(2115),r=t(704),n=t(3999);let i=r.bL,c=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)(r.B8,{ref:s,className:(0,n.cn)("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...l})});c.displayName=r.B8.displayName;let d=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)(r.l9,{ref:s,className:(0,n.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...l})});d.displayName=r.l9.displayName;let o=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)(r.UC,{ref:s,className:(0,n.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...l})});o.displayName=r.UC.displayName},6453:(e,s,t)=>{"use strict";t.d(s,{JJ:()=>n,Os:()=>r,TI:()=>i,Wv:()=>c,YK:()=>d});var a=t(2115),l=t(1886);function r(e){let[s,t]=(0,a.useState)([]),[r,n]=(0,a.useState)(!0),[i,c]=(0,a.useState)(null),[d,o]=(0,a.useState)(0),m=(0,a.useCallback)(async()=>{try{n(!0),c(null);let s=await l.F.jobs.getAll(e);t(s.jobs),o(s.count)}catch(e){c(e instanceof Error?e.message:"Failed to fetch jobs"),t([]),o(0)}finally{n(!1)}},[e]);return(0,a.useEffect)(()=>{m()},[m]),{jobs:s,loading:r,error:i,count:d,refetch:m}}function n(e){let[s,t]=(0,a.useState)(null),[r,n]=(0,a.useState)(!0),[i,c]=(0,a.useState)(null),[d,o]=(0,a.useState)(!1),m=(0,a.useCallback)(async()=>{if(!e){t(null),n(!1);return}try{n(!0),c(null);let s=await l.F.jobs.getById(e);t(s.job),o(s.is_running)}catch(e){c(e instanceof Error?e.message:"Failed to fetch job"),t(null),o(!1)}finally{n(!1)}},[e]);return(0,a.useEffect)(()=>{m()},[m]),{job:s,loading:r,error:i,isRunning:d,refetch:m}}function i(){let[e,s]=(0,a.useState)(!1),[t,r]=(0,a.useState)(null);return{createJob:(0,a.useCallback)(async e=>{try{return s(!0),r(null),(await l.F.jobs.create(e)).job}catch(s){let e=s instanceof Error?s.message:"Failed to create job";throw r(e),Error(e)}finally{s(!1)}},[]),loading:e,error:t}}function c(){let[e,s]=(0,a.useState)(!1),[t,r]=(0,a.useState)(null);return{cancelJob:(0,a.useCallback)(async e=>{try{s(!0),r(null),await l.F.jobs.cancel(e)}catch(s){let e=s instanceof Error?s.message:"Failed to cancel job";throw r(e),Error(e)}finally{s(!1)}},[]),deleteJob:(0,a.useCallback)(async e=>{try{s(!0),r(null),await l.F.jobs.delete(e)}catch(s){let e=s instanceof Error?s.message:"Failed to delete job";throw r(e),Error(e)}finally{s(!1)}},[]),loading:e,error:t}}function d(){let[e,s]=(0,a.useState)([]),[t,r]=(0,a.useState)(!0),[n,i]=(0,a.useState)(null),c=(0,a.useCallback)(async()=>{try{r(!0),i(null);let e=await l.F.projects.getAll();s(e.projects)}catch(e){i(e instanceof Error?e.message:"Failed to fetch projects"),s([])}finally{r(!1)}},[]);return(0,a.useEffect)(()=>{c()},[c]),{projects:e,loading:t,error:n,refetch:c}}},6495:(e,s,t)=>{Promise.resolve().then(t.bind(t,9348)),Promise.resolve().then(t.bind(t,9966))},9348:(e,s,t)=>{"use strict";t.d(s,{AppWrapper:()=>g});var a=t(5155),l=t(2115),r=t(1886);function n(){let[e,s]=(0,l.useState)(null),[t,a]=(0,l.useState)(!0),[n,i]=(0,l.useState)(null),c=(0,l.useCallback)(async()=>{try{i(null);let e=await r.F.initialization.getStatus();s(e),"initializing"===e.status&&setTimeout(()=>c(),2e3)}catch(e){i(e instanceof Error?e.message:"Unknown error")}finally{a(!1)}},[]);return(0,l.useEffect)(()=>{c()},[c]),{status:e,isLoading:t,error:n,retry:(0,l.useCallback)(()=>{a(!0),i(null),c()},[c]),isInitializing:(null==e?void 0:e.status)==="initializing",isCompleted:(null==e?void 0:e.status)==="completed",isFailed:(null==e?void 0:e.status)==="failed"}}var i=t(8482),c=t(1397),d=t(7168),o=t(1154),m=t(5339),x=t(4213),u=t(7434),h=t(646),j=t(9026);function f(e){let{onComplete:s}=e,{status:t,isLoading:l,error:r,retry:f,isInitializing:g,isCompleted:p,isFailed:b}=n();if(p&&s&&setTimeout(()=>s(),1500),l&&!t)return(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-blue-50 to-indigo-100",children:(0,a.jsx)(i.Zp,{className:"w-full max-w-md",children:(0,a.jsxs)(i.aR,{className:"text-center",children:[(0,a.jsx)("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-blue-100",children:(0,a.jsx)(o.A,{className:"h-6 w-6 animate-spin text-blue-600"})}),(0,a.jsx)(i.ZB,{children:"Connecting..."}),(0,a.jsx)(i.BT,{children:"Checking system status"})]})})});if(r&&!t)return(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-red-50 to-pink-100",children:(0,a.jsxs)(i.Zp,{className:"w-full max-w-md",children:[(0,a.jsxs)(i.aR,{className:"text-center",children:[(0,a.jsx)("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-red-100",children:(0,a.jsx)(m.A,{className:"h-6 w-6 text-red-600"})}),(0,a.jsx)(i.ZB,{children:"Connection Error"}),(0,a.jsx)(i.BT,{children:"Failed to connect to the server"})]}),(0,a.jsxs)(i.Wu,{className:"space-y-4",children:[(0,a.jsxs)(j.Fc,{children:[(0,a.jsx)(m.A,{className:"h-4 w-4"}),(0,a.jsx)(j.TN,{children:r})]}),(0,a.jsx)(d.$,{className:"w-full",onClick:f,children:"Retry Connection"})]})]})});if(g){let e=null==t?void 0:t.progress,s=e&&e.total_files>0?e.processed_files/e.total_files*100:0;return(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-blue-50 to-indigo-100",children:(0,a.jsxs)(i.Zp,{className:"w-full max-w-lg",children:[(0,a.jsxs)(i.aR,{className:"text-center",children:[(0,a.jsx)("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-100",children:(0,a.jsx)(x.A,{className:"h-8 w-8 text-blue-600"})}),(0,a.jsx)(i.ZB,{className:"text-2xl",children:"Initializing Database"}),(0,a.jsx)(i.BT,{children:null==t?void 0:t.message})]}),(0,a.jsxs)(i.Wu,{className:"space-y-6",children:[e&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,a.jsx)("span",{children:"Processing log files..."}),(0,a.jsxs)("span",{children:[e.processed_files," / ",e.total_files]})]}),(0,a.jsx)(c.k,{value:s,className:"h-2"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(u.A,{className:"h-4 w-4 text-blue-500"}),(0,a.jsxs)("span",{children:["Files: ",e.processed_files]})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(x.A,{className:"h-4 w-4 text-green-500"}),(0,a.jsxs)("span",{children:["Lines: ",e.new_lines]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-center space-x-2 text-sm text-muted-foreground",children:[(0,a.jsx)(o.A,{className:"h-4 w-4 animate-spin"}),(0,a.jsx)("span",{children:"This may take a few moments for large log files..."})]})]})]})})}return b?(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-red-50 to-pink-100",children:(0,a.jsxs)(i.Zp,{className:"w-full max-w-md",children:[(0,a.jsxs)(i.aR,{className:"text-center",children:[(0,a.jsx)("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-red-100",children:(0,a.jsx)(m.A,{className:"h-6 w-6 text-red-600"})}),(0,a.jsx)(i.ZB,{children:"Initialization Failed"}),(0,a.jsx)(i.BT,{children:null==t?void 0:t.message})]}),(0,a.jsxs)(i.Wu,{className:"space-y-4",children:[(null==t?void 0:t.error)&&(0,a.jsxs)(j.Fc,{children:[(0,a.jsx)(m.A,{className:"h-4 w-4"}),(0,a.jsx)(j.TN,{children:t.error})]}),(0,a.jsx)(d.$,{className:"w-full",onClick:f,children:"Retry Initialization"})]})]})}):p?(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-green-50 to-emerald-100",children:(0,a.jsxs)(i.Zp,{className:"w-full max-w-md",children:[(0,a.jsxs)(i.aR,{className:"text-center",children:[(0,a.jsx)("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-green-100",children:(0,a.jsx)(h.A,{className:"h-6 w-6 text-green-600"})}),(0,a.jsx)(i.ZB,{children:"Initialization Complete"}),(0,a.jsx)(i.BT,{children:null==t?void 0:t.message})]}),(0,a.jsxs)(i.Wu,{className:"space-y-4",children:[(null==t?void 0:t.progress)&&(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,a.jsxs)("div",{className:"text-center p-3 bg-white rounded-lg",children:[(0,a.jsx)("div",{className:"font-semibold text-lg",children:t.progress.processed_files}),(0,a.jsx)("div",{className:"text-muted-foreground",children:"Files Processed"})]}),(0,a.jsxs)("div",{className:"text-center p-3 bg-white rounded-lg",children:[(0,a.jsx)("div",{className:"font-semibold text-lg",children:t.progress.new_lines}),(0,a.jsx)("div",{className:"text-muted-foreground",children:"Log Entries"})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-center space-x-2 text-sm text-muted-foreground",children:[(0,a.jsx)(h.A,{className:"h-4 w-4 text-green-500"}),(0,a.jsx)("span",{children:"Ready to use! Redirecting..."})]})]})]})}):null}function g(e){let{children:s}=e,[t,r]=(0,l.useState)(!1),{isInitializing:i,isFailed:c,isCompleted:d,isLoading:o}=n();return!t&&(o||i||c||!d)?(0,a.jsx)(f,{onComplete:()=>r(!0)}):(0,a.jsx)(a.Fragment,{children:s})}},9966:(e,s,t)=>{"use strict";t.d(s,{default:()=>ev});var a=t(5155),l=t(2115),r=t(5695),n=t(4964),i=t(8482),c=t(1397),d=t(8145),o=t(3109),m=t(1539),x=t(1243),u=t(4186),h=t(2261);function j(e){let{currentTokens:s,currentMessages:t,currentCost:l,p90Prediction:r,resetTime:n,isLoading:j=!1,settings:f}=e,{t:g,formatFullDate:p}=(0,h.s)(),b="fixed_limits"===f.usageMode,N=b?f.fixedLimits.tokenLimit:(null==r?void 0:r.token_limit)||0,v=b?f.fixedLimits.messageLimit:(null==r?void 0:r.message_limit)||0,y=b?f.fixedLimits.costLimit:(null==r?void 0:r.cost_limit)||0;if(j||!b&&!r)return(0,a.jsxs)(i.Zp,{className:"bg-gradient-to-br from-blue-50 to-indigo-50 border-blue-200",children:[(0,a.jsx)(i.aR,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:(0,a.jsxs)(i.ZB,{className:"text-sm font-medium flex items-center gap-2",children:[(0,a.jsx)(o.A,{className:"w-4 h-4 text-blue-600"}),b?g("settings.fixedLimits"):g("p90Prediction.title")]})}),(0,a.jsx)(i.Wu,{children:(0,a.jsxs)("div",{className:"animate-pulse space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"h-4 bg-blue-200 rounded w-3/4"}),(0,a.jsx)("div",{className:"h-2 bg-blue-200 rounded"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"h-4 bg-blue-200 rounded w-2/3"}),(0,a.jsx)("div",{className:"h-2 bg-blue-200 rounded"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"h-4 bg-blue-200 rounded w-1/2"}),(0,a.jsx)("div",{className:"h-2 bg-blue-200 rounded"})]})]})})]});let w=N>0?s/N*100:0,_=v>0?t/v*100:0,k=y>0?l/y*100:0,T=w>80,A=_>80,C=k>80,S=T||A||C,F=e=>{let s=Math.max(0,e.getTime()-Date.now()),t=Math.floor(s/36e5),a=Math.floor(s%36e5/6e4);return 0===t&&0===a?g("p90Prediction.resetSoon"):0===t?"".concat(a,"m"):"".concat(t,"h ").concat(a,"m")},P=e=>e>90?"bg-red-500":e>80?"bg-orange-500":e>60?"bg-yellow-500":"bg-green-500";return(0,a.jsxs)(i.Zp,{className:"transition-colors ".concat(S?"bg-gradient-to-br from-orange-50 to-red-50 border-orange-200":"bg-gradient-to-br from-blue-50 to-indigo-50 border-blue-200"),children:[(0,a.jsxs)(i.aR,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,a.jsxs)(i.ZB,{className:"text-sm font-medium flex items-center gap-2",children:[(0,a.jsx)(o.A,{className:"w-4 h-4 ".concat(S?"text-orange-600":"text-blue-600")}),b?g("settings.fixedLimits"):g("p90Prediction.title")]}),(0,a.jsx)("div",{className:"flex items-center gap-2",children:!b&&r&&(0,a.jsxs)(d.E,{variant:"outline",className:"bg-white text-xs",children:[(100*r.confidence).toFixed(0),"% ",g("p90Prediction.confidence")]})})]}),(0,a.jsx)(i.Wu,{children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,a.jsxs)("span",{className:"font-medium flex items-center gap-1",children:[(0,a.jsx)(m.A,{className:"w-3 h-3"}),g("tokenUsage.tokens")]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[(s/1e3).toFixed(1),"K / ",(N/1e3).toFixed(1),"K"]}),T&&(0,a.jsx)(x.A,{className:"w-3 h-3 text-orange-600"})]})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(c.k,{value:Math.min(w,100),className:"h-2"}),(0,a.jsx)("div",{className:"absolute top-0 h-2 rounded-full ".concat(P(w)," transition-all duration-300"),style:{width:"".concat(Math.min(w,100),"%")}})]}),(0,a.jsxs)("div",{className:"text-xs text-muted-foreground",children:[w.toFixed(1),"% ",b?"of fixed limit":g("p90Prediction.ofPredictedLimit")]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,a.jsx)("span",{className:"font-medium",children:g("session.messages")}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[t," / ",v]}),A&&(0,a.jsx)(x.A,{className:"w-3 h-3 text-orange-600"})]})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(c.k,{value:Math.min(_,100),className:"h-2"}),(0,a.jsx)("div",{className:"absolute top-0 h-2 rounded-full ".concat(P(_)," transition-all duration-300"),style:{width:"".concat(Math.min(_,100),"%")}})]}),(0,a.jsxs)("div",{className:"text-xs text-muted-foreground",children:[_.toFixed(1),"% ",b?"of fixed limit":g("p90Prediction.ofPredictedLimit")]})]}),y>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,a.jsx)("span",{className:"font-medium",children:g("session.cost")}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:["$",l.toFixed(1)," / $",y.toFixed(1)]}),C&&(0,a.jsx)(x.A,{className:"w-3 h-3 text-orange-600"})]})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(c.k,{value:Math.min(k,100),className:"h-2"}),(0,a.jsx)("div",{className:"absolute top-0 h-2 rounded-full ".concat(P(k)," transition-all duration-300"),style:{width:"".concat(Math.min(k,100),"%")}})]}),(0,a.jsxs)("div",{className:"text-xs text-muted-foreground",children:[k.toFixed(1),"% ",b?"of fixed limit":g("p90Prediction.ofPredictedLimit")]})]}),!b&&r&&(0,a.jsxs)("div",{className:"border-t pt-3 mt-3 mb-3 space-y-2",children:[(0,a.jsxs)("div",{className:"grid gap-4 text-sm ".concat(r.time_to_limit_minutes>0?"grid-cols-3":"grid-cols-2"),children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-muted-foreground",children:g("p90Prediction.burnRate")}),(0,a.jsxs)("div",{className:"font-semibold",children:[(r.burn_rate_per_hour/1e3).toFixed(1),"K ",g("p90Prediction.tokensPerHour")]})]}),r.time_to_limit_minutes>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1",children:[(0,a.jsx)(u.A,{className:"w-3 h-3"}),g("p90Prediction.timeToLimit")]}),(0,a.jsx)("div",{className:"font-semibold ".concat(r.time_to_limit_minutes<60?"text-red-600":r.time_to_limit_minutes<180?"text-orange-600":""),children:(e=>{if(e<=0)return g("p90Prediction.alreadyReached");if(e<60)return"".concat(e,"m");let s=Math.floor(e/60);return"".concat(s,"h ").concat(e%60,"m")})(r.time_to_limit_minutes)})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1",children:[(0,a.jsx)(u.A,{className:"w-3 h-3"}),g("p90Prediction.resetIn")]}),(0,a.jsxs)("div",{className:"font-semibold text-blue-600",title:p(n),children:[F(n)," (",g("p90Prediction.at")," ",n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",timeZoneName:"short"}),")"]})]})]}),(0,a.jsxs)("div",{className:"text-xs text-muted-foreground border-t pt-2 col-span-full",children:[g("p90Prediction.lastPredicted"),": ",p(new Date(r.predicted_at))]})]}),b&&(0,a.jsx)("div",{className:"border-t pt-3 mt-3",children:(0,a.jsx)("div",{className:"grid gap-4 text-sm grid-cols-1",children:(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1",children:[(0,a.jsx)(u.A,{className:"w-3 h-3"}),g("p90Prediction.resetIn")]}),(0,a.jsx)("div",{className:"font-semibold text-blue-600",title:p(n),children:F(n)}),(0,a.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[g("p90Prediction.at")," ",n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",timeZoneName:"short"})]})]})})})]})})]})}var f=t(3999);let g=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)("div",{className:"relative w-full overflow-auto",children:(0,a.jsx)("table",{ref:s,className:(0,f.cn)("w-full caption-bottom text-sm",t),...l})})});g.displayName="Table";let p=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)("thead",{ref:s,className:(0,f.cn)("[&_tr]:border-b",t),...l})});p.displayName="TableHeader";let b=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)("tbody",{ref:s,className:(0,f.cn)("[&_tr:last-child]:border-0",t),...l})});b.displayName="TableBody",l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)("tfoot",{ref:s,className:(0,f.cn)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...l})}).displayName="TableFooter";let N=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)("tr",{ref:s,className:(0,f.cn)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...l})});N.displayName="TableRow";let v=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)("th",{ref:s,className:(0,f.cn)("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...l})});v.displayName="TableHead";let y=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)("td",{ref:s,className:(0,f.cn)("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...l})});y.displayName="TableCell",l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)("caption",{ref:s,className:(0,f.cn)("mt-4 text-sm text-muted-foreground",t),...l})}).displayName="TableCaption";var w=t(523);let _=w.bL,k=w.R6,T=w.Ke;var A=t(8979),C=t(5690),S=t(2178),F=t(1497),P=t(6474),R=t(3052);function M(e){let{projects:s}=e,[t,n]=(0,l.useState)(new Set),c=(0,r.useRouter)(),{t:o,formatDate:m}=(0,h.s)(),x=e=>{let s=new Set(t);s.has(e)?s.delete(e):s.add(e),n(s)},u=e=>{switch(e){case"completed":return(0,a.jsx)(A.A,{className:"w-4 h-4 text-green-600"});case"running":return(0,a.jsx)(C.A,{className:"w-4 h-4 text-blue-600"});case"paused":return(0,a.jsx)(S.A,{className:"w-4 h-4 text-yellow-600"});case"failed":return(0,a.jsx)(A.A,{className:"w-4 h-4 text-red-600"});default:return(0,a.jsx)(A.A,{className:"w-4 h-4 text-gray-600"})}},j=e=>{switch(e){case"completed":return o("session.completed");case"running":return o("session.active");case"paused":return o("session.paused");case"failed":return o("session.failed");default:return o("session.unknown")}},f=e=>{switch(e){case"completed":return"bg-green-100 text-green-800";case"running":return"bg-blue-100 text-blue-800";case"paused":return"bg-yellow-100 text-yellow-800";case"failed":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}},w=(e,s)=>{let t=Math.floor(((s||new Date).getTime()-e.getTime())/6e4),a=Math.floor(t/60);return a>0?"".concat(a).concat(o("tokenUsage.hours")).concat(t%60).concat(o("tokenUsage.minutes")):"".concat(t).concat(o("tokenUsage.minutes"))};return 0===s.length?(0,a.jsxs)("div",{className:"text-center py-8",children:[(0,a.jsx)("div",{className:"w-12 h-12 mx-auto text-muted-foreground mb-4",children:(0,a.jsx)(F.A,{className:"w-full h-full"})}),(0,a.jsx)("p",{className:"text-lg font-medium text-muted-foreground",children:o("empty.noSessions")}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:o("empty.noSessionsDesc")})]}):(0,a.jsx)("div",{className:"space-y-4",children:s.map(e=>(0,a.jsx)(i.Zp,{children:(0,a.jsxs)(_,{open:t.has(e.id),onOpenChange:()=>x(e.id),children:[(0,a.jsx)(k,{asChild:!0,children:(0,a.jsx)(i.aR,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[t.has(e.id)?(0,a.jsx)(P.A,{className:"w-4 h-4"}):(0,a.jsx)(R.A,{className:"w-4 h-4"}),(0,a.jsxs)("div",{children:[(0,a.jsx)(i.ZB,{className:"text-base",children:e.originalPath.split("/").pop()}),(0,a.jsx)(i.BT,{className:"text-sm break-all",children:e.originalPath})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(d.E,{variant:"outline",children:[e.sessions.length," ",o("common.sessions")]}),(0,a.jsxs)(d.E,{variant:"secondary",children:[e.sessions.reduce((e,s)=>e+s.tokenUsage,0).toLocaleString()," tokens"]})]})]})})}),(0,a.jsx)(T,{children:(0,a.jsx)(i.Wu,{className:"pt-0",children:(0,a.jsxs)(g,{children:[(0,a.jsx)(p,{children:(0,a.jsxs)(N,{children:[(0,a.jsx)(v,{children:o("session.status")}),(0,a.jsx)(v,{children:o("session.sessionId")}),(0,a.jsx)(v,{children:o("session.startTime")}),(0,a.jsx)(v,{children:o("session.duration")}),(0,a.jsx)(v,{children:o("session.tokenUsage")}),(0,a.jsx)(v,{children:o("session.messageCount")})]})}),(0,a.jsx)(b,{children:e.sessions.map(e=>(0,a.jsxs)(N,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>c.push("/sessions/".concat(e.sessionId)),children:[(0,a.jsx)(y,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[u(e.status),(0,a.jsx)(d.E,{variant:"secondary",className:"text-xs ".concat(f(e.status)),children:j(e.status)})]})}),(0,a.jsx)(y,{className:"font-mono text-sm truncate",children:e.sessionId}),(0,a.jsx)(y,{children:m(e.startTime)}),(0,a.jsx)(y,{children:w(e.startTime,e.endTime)}),(0,a.jsx)(y,{className:"font-semibold",children:e.tokenUsage.toLocaleString()}),(0,a.jsx)(y,{children:e.messageCount})]},e.id))})]})})})]})},e.id))})}var D=t(6618),E=t(6874),L=t.n(E);function B(e){let{projects:s}=e,{t,formatDate:l}=(0,h.s)();return 0===s.length?(0,a.jsxs)("div",{className:"text-center py-8",children:[(0,a.jsx)(D.A,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),(0,a.jsx)("p",{className:"text-lg font-medium text-muted-foreground",children:t("empty.noProjects")}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:t("empty.noProjectsDesc")})]}):(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:s.map(e=>{let s=e.sessions.reduce((e,s)=>e+s.tokenUsage,0),r=e.sessions.filter(e=>"running"===e.status).length,n=e.sessions.filter(e=>"completed"===e.status).length;return(0,a.jsxs)(i.Zp,{className:"hover:shadow-md transition-shadow",children:[(0,a.jsxs)(i.aR,{className:"pb-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(D.A,{className:"w-4 h-4 text-muted-foreground"}),(0,a.jsx)(i.ZB,{className:"text-sm font-medium truncate",children:e.originalPath.split("/").pop()})]}),(0,a.jsx)(i.BT,{className:"text-xs",children:e.originalPath})]}),(0,a.jsxs)(i.Wu,{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:t("project.totalTokenUsage")}),(0,a.jsx)("span",{className:"font-semibold",children:s.toLocaleString()})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:t("project.sessionCount")}),(0,a.jsxs)("div",{className:"flex gap-1",children:[r>0&&(0,a.jsxs)(d.E,{variant:"secondary",className:"text-xs",children:[t("project.running")," ",r]}),(0,a.jsxs)(d.E,{variant:"outline",className:"text-xs",children:[t("project.completed")," ",n]})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:t("project.recentSessions")}),e.sessions.slice(0,2).map(e=>(0,a.jsx)(L(),{href:"/sessions/".concat(e.sessionId),className:"block",children:(0,a.jsxs)("div",{className:"flex items-center justify-between p-2 bg-muted/50 rounded-sm hover:bg-muted transition-colors cursor-pointer group",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:[e.tokenUsage.toLocaleString()," ",t("project.tokensLabel")]}),(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:[e.messageCount," msgs"]})]}),(0,a.jsx)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:e.endTime?l(new Date(e.endTime)):t("session.active")})]})},e.id)),e.sessions.length>2&&(0,a.jsxs)("div",{className:"text-xs text-muted-foreground text-center py-1",children:[t("project.others")," ",e.sessions.length-2," ",t("project.sessionsText")]})]})]})]},e.id)})})}var Z=t(7168),U=t(2714),I=t(5784);let H=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)("textarea",{className:(0,f.cn)("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...l})});H.displayName="Textarea";var z=t(5196);let J=l.forwardRef((e,s)=>{let{className:t,checked:l=!1,onCheckedChange:r,disabled:n,id:i,...c}=e;return(0,a.jsxs)("div",{className:"relative inline-flex items-center",children:[(0,a.jsx)("input",{ref:s,type:"checkbox",id:i,checked:l,onChange:e=>null==r?void 0:r(e.target.checked),disabled:n,className:"sr-only",...c}),(0,a.jsx)("div",{className:(0,f.cn)("h-4 w-4 shrink-0 rounded-sm border border-gray-300 bg-white flex items-center justify-center transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50",l&&"bg-blue-600 border-blue-600 text-white",t),onClick:()=>!n&&(null==r?void 0:r(!l)),children:l&&(0,a.jsx)(z.A,{className:"h-3 w-3"})})]})});J.displayName="Checkbox";var W=t(9026),G=t(1284),Y=t(5339),O=t(1154),K=t(3921);let $=K.Kq,q=K.bL,V=K.l9,X=l.forwardRef((e,s)=>{let{className:t,sideOffset:l=4,...r}=e;return(0,a.jsx)(K.UC,{ref:s,sideOffset:l,className:(0,f.cn)("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})});X.displayName=K.UC.displayName;var Q=t(6453),ee=t(9583);let es=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsxs)(ee.bL,{ref:s,className:(0,f.cn)("relative flex w-full touch-none select-none items-center",t),...l,children:[(0,a.jsx)(ee.CC,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:(0,a.jsx)(ee.Q6,{className:"absolute h-full bg-primary"})}),(0,a.jsx)(ee.zi,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]})});es.displayName=ee.bL.displayName;var et=t(9852),ea=t(514),el=t(8885),er=t(3039);function en(e){let{onJobCreated:s}=e,{createJob:t,loading:r,error:n}=(0,Q.TI)(),{projects:c,loading:d,error:o}=(0,Q.YK)(),{t:m,language:x}=(0,h.s)(),j="ja"===x?el.ja:er.c,[f,g]=(0,l.useState)(""),[p,b]=(0,l.useState)(""),[N,v]=(0,l.useState)(!1),[y,w]=(0,l.useState)("immediate"),[_,k]=(0,l.useState)(1),[T,A]=(0,l.useState)(""),[S,F]=(0,l.useState)(""),[P,R]=(0,l.useState)(null),[M,D]=(0,l.useState)(null),E=()=>{if("scheduled"!==y)return!0;if(!T||!S)return D(m("job.form.dateTimeRequired")),!1;let e=new Date("".concat(T,"T").concat(S,":00"));if(e<=new Date)return D(m("job.validation.futureTime")),!1;let s=new Date;return s.setFullYear(s.getFullYear()+1),!(e>s)||(D(m("job.validation.withinYear")),!1)},L=async e=>{if(e.preventDefault(),f&&p.trim()){if(D(null),E())try{R(null);let e={project_id:f,command:p.trim(),yolo_mode:N,schedule_type:y};"delayed"===y?e.schedule_params={delay_hours:_}:"scheduled"===y&&T&&S&&(e.schedule_params={scheduled_time:new Date("".concat(T,"T").concat(S,":00")).toISOString()});let a=await t(e);R("".concat(m("job.created"),": ").concat(a.id)),b(""),v(!1),w("immediate"),k(1),A(""),F(""),D(null),s&&s()}catch(e){}}},B=null==c?void 0:c.find(e=>e.id===f);return(0,a.jsxs)(i.Zp,{children:[(0,a.jsxs)(i.aR,{children:[(0,a.jsxs)(i.ZB,{className:"flex items-center gap-2",children:[(0,a.jsx)(C.A,{className:"h-5 w-5"}),m("job.execution")]}),(0,a.jsx)(i.BT,{children:m("job.description")})]}),(0,a.jsx)(i.Wu,{children:(0,a.jsxs)("form",{onSubmit:L,className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(U.J,{htmlFor:"project",children:m("session.project")}),(0,a.jsxs)(I.l6,{value:f,onValueChange:g,children:[(0,a.jsx)(I.bq,{children:(0,a.jsx)(I.yv,{placeholder:m("job.form.selectProject")})}),(0,a.jsx)(I.gC,{children:d?(0,a.jsx)(I.eb,{value:"loading",disabled:!0,children:m("job.form.loadingProjects")}):o?(0,a.jsxs)(I.eb,{value:"error",disabled:!0,children:[m("job.form.errorProjects"),": ",o]}):c&&0!==c.length?c.map(e=>(0,a.jsx)(I.eb,{value:e.id,children:e.name},e.id)):(0,a.jsx)(I.eb,{value:"no-projects",disabled:!0,children:m("job.form.noProjects")})})]}),B&&(0,a.jsxs)("div",{className:"text-sm text-muted-foreground",children:[m("job.form.executionDirectory"),": ",B.path]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(U.J,{htmlFor:"command",children:m("job.command")}),(0,a.jsx)(H,{id:"command",placeholder:m("job.form.commandPlaceholder"),value:p,onChange:e=>b(e.target.value),rows:6,className:"resize-none"}),(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:m("job.form.commandHelp")})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(J,{id:"yolo-mode",checked:N,onCheckedChange:e=>v(e)}),(0,a.jsx)(U.J,{htmlFor:"yolo-mode",className:"text-sm font-medium",children:m("job.form.yoloMode")}),(0,a.jsx)($,{children:(0,a.jsxs)(q,{children:[(0,a.jsx)(V,{asChild:!0,children:(0,a.jsx)(G.A,{className:"h-4 w-4 text-amber-500 cursor-help hover:text-amber-600"})}),(0,a.jsx)(X,{className:"max-w-md p-4",children:(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("p",{className:"font-semibold text-amber-600",children:["⚠️ ",m("job.security.warningTitle")]}),(0,a.jsx)("p",{className:"text-sm",children:m("job.security.yoloWarning")}),(0,a.jsxs)("p",{className:"text-sm",children:[(0,a.jsx)("strong",{children:m("job.security.safeExecutionTitle")}),(0,a.jsx)("br",{}),m("job.security.safeExecutionText")]}),(0,a.jsx)("p",{className:"text-xs text-blue-600 underline",children:(0,a.jsx)("a",{href:"https://docs.anthropic.com/ja/docs/claude-code/settings#設定ファイル",target:"_blank",rel:"noopener noreferrer",children:m("job.security.settingsGuide")})})]})})]})}),(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:m("job.form.yoloModeDescription")})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(U.J,{htmlFor:"schedule-type",children:m("job.form.executionTiming")}),(0,a.jsxs)(I.l6,{value:y,onValueChange:e=>{if(w(e),D(null),"scheduled"===e){let e=new Date;A((0,ea.GP)(e,"yyyy-MM-dd")),F((0,ea.GP)(e,"HH:mm"))}},children:[(0,a.jsx)(I.bq,{children:(0,a.jsx)(I.yv,{})}),(0,a.jsxs)(I.gC,{children:[(0,a.jsx)(I.eb,{value:"immediate",children:m("job.schedule.immediate")}),(0,a.jsx)(I.eb,{value:"after_reset",children:m("job.schedule.afterReset")}),(0,a.jsx)(I.eb,{value:"delayed",children:m("job.schedule.delayed")}),(0,a.jsx)(I.eb,{value:"scheduled",children:m("job.schedule.scheduled")})]})]})]}),"delayed"===y&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)(U.J,{children:[m("job.timeUntil"),": ",_,m("job.hoursAfter")]}),(0,a.jsx)(es,{value:[_],onValueChange:e=>{let[s]=e;return k(s)},min:1,max:72,step:1,className:"w-full"}),(0,a.jsxs)("div",{className:"text-sm text-muted-foreground",children:[m("job.form.executionScheduled"),": ",(0,ea.GP)(new Date(Date.now()+36e5*_),"ja"===x?"yyyy年MM月dd日 HH:mm":"MMM dd, yyyy HH:mm",{locale:j})]})]}),"scheduled"===y&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(U.J,{htmlFor:"scheduled-date",children:m("job.form.executionDate")}),(0,a.jsx)(et.p,{id:"scheduled-date",type:"date",value:T,onChange:e=>{A(e.target.value),D(null)},min:(0,ea.GP)(new Date,"yyyy-MM-dd"),max:(0,ea.GP)(new Date(new Date().setFullYear(new Date().getFullYear()+1)),"yyyy-MM-dd")})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(U.J,{htmlFor:"scheduled-time",children:m("job.form.executionTime")}),(0,a.jsx)(et.p,{id:"scheduled-time",type:"time",value:S,onChange:e=>{F(e.target.value),D(null)}})]})]}),T&&S&&(0,a.jsxs)("div",{className:"text-sm text-muted-foreground",children:[m("job.form.executionScheduled"),": ",(0,ea.GP)(new Date("".concat(T,"T").concat(S,":00")),"ja"===x?"yyyy年MM月dd日 HH:mm":"MMM dd, yyyy HH:mm",{locale:j})]})]}),"immediate"!==y&&(0,a.jsxs)(W.Fc,{children:[(0,a.jsx)(u.A,{className:"h-4 w-4"}),(0,a.jsxs)(W.TN,{children:["after_reset"===y&&m("job.resetDescription"),"delayed"===y&&"".concat(_).concat(m("job.delayDescription")),"scheduled"===y&&T&&S&&"".concat((0,ea.GP)(new Date("".concat(T,"T").concat(S,":00")),"ja"===x?"yyyy年MM月dd日 HH:mm":"MMM dd, yyyy HH:mm",{locale:j})).concat(m("job.scheduleDescription"))]})]}),M&&(0,a.jsxs)(W.Fc,{variant:"destructive",children:[(0,a.jsx)(Y.A,{className:"h-4 w-4"}),(0,a.jsx)(W.TN,{children:M})]}),n&&(0,a.jsxs)(W.Fc,{variant:"destructive",children:[(0,a.jsx)(Y.A,{className:"h-4 w-4"}),(0,a.jsx)(W.TN,{children:n})]}),P&&(0,a.jsx)(W.Fc,{children:(0,a.jsx)(W.TN,{className:"text-green-600",children:P})}),(0,a.jsx)(Z.$,{type:"submit",disabled:!f||!p.trim()||r||"scheduled"===y&&(!T||!S),className:"w-full",children:r?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(O.A,{className:"mr-2 h-4 w-4 animate-spin"}),m("job.executing")]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(C.A,{className:"mr-2 h-4 w-4"}),m("job.create")]})})]})})]})}var ei=t(646),ec=t(4861),ed=t(2431),eo=t(9676),em=t(3904),ex=t(1482),eu=t(9074),eh=t(2525);function ej(e){let{refreshTrigger:s}=e,t=(0,r.useRouter)(),{t:n}=(0,h.s)(),[c,o]=(0,l.useState)({limit:20}),{projects:m}=(0,Q.YK)(),{jobs:x,loading:j,error:f,refetch:w}=(0,Q.Os)(c),{cancelJob:_,deleteJob:k,loading:T}=(0,Q.Wv)();(0,l.useEffect)(()=>{s&&s>0&&w()},[s,w]);let F=e=>{let s={pending:{color:"bg-yellow-100 text-yellow-800",icon:S.A,label:"待機中"},running:{color:"bg-blue-100 text-blue-800",icon:C.A,label:"実行中"},completed:{color:"bg-green-100 text-green-800",icon:ei.A,label:"完了"},failed:{color:"bg-red-100 text-red-800",icon:ec.A,label:"失敗"},cancelled:{color:"bg-gray-100 text-gray-800",icon:ed.A,label:"キャンセル"}}[e],t=s.icon;return(0,a.jsxs)(d.E,{className:s.color,children:[(0,a.jsx)(t,{className:"mr-1 h-3 w-3"}),s.label]})},P=e=>new Date(e).toLocaleString("ja-JP",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),R=e=>e.schedule_type?{type:({immediate:n("job.schedule.immediate"),after_reset:n("job.schedule.afterReset"),delayed:n("job.schedule.delayed"),scheduled:n("job.schedule.scheduled")})[e.schedule_type]||e.schedule_type,scheduledAt:e.scheduled_at}:null,M=(e,s)=>{if(!e)return"-";let t=new Date(e),a=Math.floor(((s?new Date(s):new Date).getTime()-t.getTime())/1e3);if(a<60)return"".concat(a,"秒");let l=Math.floor(a/60);if(l<60)return"".concat(l,"分");let r=Math.floor(l/60);return"".concat(r,"時間").concat(l%60,"分")},D=e=>{let s=new Date(e),t=new Date,a=s.getTime()-t.getTime();if(a<=0)return"実行待機中";let l=Math.floor(a/6e4),r=Math.floor(l/60),i=Math.floor(r/24);return i>0?"".concat(i).concat(n("job.daysAfter")):r>0?"".concat(r).concat(n("tokenUsage.hours")).concat(l%60).concat(n("job.minutesAfter")):l>0?"".concat(l).concat(n("job.minutesAfter")):"間もなく実行"},E=async e=>{try{await _(e),w()}catch(e){}},L=async e=>{if(confirm(n("job.confirmDelete")))try{await k(e),w()}catch(e){}},B=(e,s)=>{o(t=>({...t,[e]:"all"===s?void 0:s}))};return(0,a.jsxs)(i.Zp,{children:[(0,a.jsx)(i.aR,{children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)(i.ZB,{className:"flex items-center gap-2",children:[(0,a.jsx)(eo.A,{className:"h-5 w-5"}),n("job.history")]}),(0,a.jsx)(i.BT,{children:"実行されたタスクの履歴と状態を確認できます。"})]}),(0,a.jsxs)(Z.$,{variant:"outline",size:"sm",onClick:w,disabled:j,children:[(0,a.jsx)(em.A,{className:"mr-2 h-4 w-4 ".concat(j?"animate-spin":"")}),"更新"]})]})}),(0,a.jsxs)(i.Wu,{children:[(0,a.jsxs)("div",{className:"flex gap-4 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(ex.A,{className:"h-4 w-4"}),(0,a.jsxs)(I.l6,{value:c.status||"all",onValueChange:e=>B("status",e),children:[(0,a.jsx)(I.bq,{className:"w-32",children:(0,a.jsx)(I.yv,{})}),(0,a.jsxs)(I.gC,{children:[(0,a.jsx)(I.eb,{value:"all",children:"全ステータス"}),(0,a.jsx)(I.eb,{value:"pending",children:"待機中"}),(0,a.jsx)(I.eb,{value:"running",children:"実行中"}),(0,a.jsx)(I.eb,{value:"completed",children:"完了"}),(0,a.jsx)(I.eb,{value:"failed",children:"失敗"}),(0,a.jsx)(I.eb,{value:"cancelled",children:"キャンセル"})]})]})]}),(0,a.jsxs)(I.l6,{value:c.project_id||"all",onValueChange:e=>B("project_id",e),children:[(0,a.jsx)(I.bq,{className:"w-48",children:(0,a.jsx)(I.yv,{placeholder:"プロジェクト"})}),(0,a.jsxs)(I.gC,{children:[(0,a.jsx)(I.eb,{value:"all",children:"全プロジェクト"}),m.map(e=>(0,a.jsx)(I.eb,{value:e.id,children:e.name},e.id))]})]})]}),f&&(0,a.jsx)(W.Fc,{variant:"destructive",className:"mb-4",children:(0,a.jsx)(W.TN,{children:f})}),(0,a.jsx)("div",{className:"rounded-md border",children:(0,a.jsxs)(g,{children:[(0,a.jsx)(p,{children:(0,a.jsxs)(N,{children:[(0,a.jsx)(v,{children:n("session.status")}),(0,a.jsx)(v,{children:n("session.project")}),(0,a.jsx)(v,{children:n("job.command")}),(0,a.jsx)(v,{children:n("job.scheduleHeader")}),(0,a.jsx)(v,{children:n("job.duration")}),(0,a.jsx)(v,{children:n("job.createdAt")}),(0,a.jsx)(v,{className:"text-right",children:n("job.actions")})]})}),(0,a.jsx)(b,{children:j?(0,a.jsx)(N,{children:(0,a.jsx)(y,{colSpan:7,className:"text-center py-8",children:"読み込み中..."})}):x&&0!==x.length?x.map(e=>{var s,l;return(0,a.jsxs)(N,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>t.push("/jobs/".concat(e.id)),children:[(0,a.jsx)(y,{children:F(e.status)}),(0,a.jsxs)(y,{children:[(0,a.jsx)("div",{className:"font-medium",children:null===(s=e.project)||void 0===s?void 0:s.name}),(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:null===(l=e.project)||void 0===l?void 0:l.path})]}),(0,a.jsxs)(y,{children:[(0,a.jsx)("div",{className:"max-w-xs truncate font-mono text-sm",children:e.command}),e.yolo_mode&&(0,a.jsx)(d.E,{variant:"outline",className:"mt-1 text-xs",children:"YOLO"})]}),(0,a.jsx)(y,{children:(()=>{let s=R(e);return s?(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:["immediate"===e.schedule_type&&(0,a.jsx)(C.A,{className:"h-3 w-3"}),"after_reset"===e.schedule_type&&(0,a.jsx)(em.A,{className:"h-3 w-3"}),"scheduled"===e.schedule_type&&(0,a.jsx)(eu.A,{className:"h-3 w-3"}),"delayed"===e.schedule_type&&(0,a.jsx)(u.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{className:"text-sm",children:s.type})]}),s.scheduledAt&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"text-xs ".concat("pending"===e.status&&("scheduled"===e.schedule_type||"delayed"===e.schedule_type)?"text-blue-600 font-medium":"text-muted-foreground"),children:"pending"===e.status&&("scheduled"===e.schedule_type||"delayed"===e.schedule_type)?"実行予定: ".concat(P(s.scheduledAt)):P(s.scheduledAt)}),"pending"===e.status&&("scheduled"===e.schedule_type||"delayed"===e.schedule_type)&&(0,a.jsx)("div",{className:"text-xs text-orange-600",children:D(s.scheduledAt)})]})]}):"-"})()}),(0,a.jsx)(y,{children:M(e.started_at,e.completed_at)}),(0,a.jsx)(y,{children:P(e.created_at)}),(0,a.jsx)(y,{className:"text-right",children:(0,a.jsxs)("div",{className:"flex items-center justify-end gap-1",children:["running"===e.status&&(0,a.jsx)(Z.$,{variant:"ghost",size:"sm",disabled:T,onClick:s=>{s.stopPropagation(),E(e.id)},children:(0,a.jsx)(A.A,{className:"h-4 w-4"})}),("completed"===e.status||"failed"===e.status||"cancelled"===e.status)&&(0,a.jsx)(Z.$,{variant:"ghost",size:"sm",disabled:T,onClick:s=>{s.stopPropagation(),L(e.id)},children:(0,a.jsx)(eh.A,{className:"h-4 w-4"})})]})})]},e.id)}):(0,a.jsx)(N,{children:(0,a.jsx)(y,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:n("job.notFound")})})})]})}),x&&x.length>0&&(0,a.jsxs)("div",{className:"mt-4 text-sm text-muted-foreground",children:[x.length," ",n("job.totalJobs")]})]})]})}var ef=t(1380),eg=t(811),ep=t(2815);function eb(){let e=(0,r.useRouter)(),s=(0,r.useSearchParams)(),{data:t,loading:i,error:c,refetch:d}=(0,eg.AR)(),{data:o,loading:m,error:x,refetch:u}=(0,eg.te)(),{data:f,loading:g,refetch:p}=(0,eg.BI)(),{sync:b}=(0,eg.G_)(),[N,v]=(0,l.useState)(!1),[y,w]=(0,l.useState)(()=>(0,ep.mt)()),[_,k]=(0,l.useState)(0),T=(null==s?void 0:s.get("tab"))||"overview",{t:A}=(0,h.s)(),C=(0,l.useCallback)(async()=>{v(!0);try{await b(),await Promise.all([d(),u(),p()])}catch(e){}finally{v(!1)}},[b,d,u,p]);(0,l.useEffect)(()=>{let e=setInterval(()=>{N||C()},1e3*y.autoRefreshInterval);return()=>clearInterval(e)},[N,y.autoRefreshInterval,C]);let S=o?function(e){let s=new Map;e.forEach(e=>{var t;let a=e.project_path,l=e.project_name;s.has(a)||s.set(a,{id:a,name:l,originalPath:a,sessions:[]}),s.get(a).sessions.push({id:"".concat(e.id,"-").concat(e.start_time),sessionId:e.id,startTime:new Date(e.start_time),endTime:e.end_time?new Date(e.end_time):null,tokenUsage:e.total_tokens,status:e.is_active?"running":"completed",messageCount:e.message_count,codeGenerated:(null===(t=e.generated_code)||void 0===t?void 0:t.length)>0})});let t=Array.from(s.values());return t.forEach(e=>{e.sessions.sort((e,s)=>{let t=e.endTime||e.startTime;return(s.endTime||s.startTime).getTime()-t.getTime()})}),t.sort((e,s)=>{let t=e.sessions.length>0?e.sessions[0].endTime||e.sessions[0].startTime:new Date(0);return(s.sessions.length>0?s.sessions[0].endTime||s.sessions[0].startTime:new Date(0)).getTime()-t.getTime()}),t}(o):[],F=new Date(t?t.window_end:Date.now()+18e6);return(0,a.jsxs)("div",{className:"min-h-screen bg-background",children:[(0,a.jsx)(ef.Y,{onSettingsChange:e=>{w(e)}}),(0,a.jsxs)("div",{className:"container mx-auto max-w-7xl p-6 space-y-6",children:[i?(0,a.jsx)("div",{className:"animate-pulse bg-gray-200 rounded-lg h-32"}):c?(0,a.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,a.jsxs)("p",{className:"text-red-600",children:[A("errors.tokenUsageFetch"),": ",c]})}):t?(0,a.jsx)(j,{currentTokens:t.total_tokens,currentMessages:t.total_messages,currentCost:t.total_cost,p90Prediction:f,resetTime:F,isLoading:g,settings:y}):null,(0,a.jsxs)(n.tU,{value:T,onValueChange:t=>{let a=new URLSearchParams((null==s?void 0:s.toString())||"");a.set("tab",t),e.push("/?".concat(a.toString()))},className:"space-y-4",children:[(0,a.jsxs)(n.j7,{children:[(0,a.jsx)(n.Xi,{value:"overview",children:A("common.overview")}),(0,a.jsx)(n.Xi,{value:"sessions",children:A("common.sessions")}),(0,a.jsx)(n.Xi,{value:"tasks",children:A("job.execution")})]}),(0,a.jsx)(n.av,{value:"overview",className:"space-y-4",children:m?(0,a.jsx)("div",{className:"animate-pulse bg-gray-200 rounded-lg h-64"}):x?(0,a.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,a.jsxs)("p",{className:"text-red-600",children:[A("errors.sessionsFetch"),": ",x]})}):(0,a.jsx)(B,{projects:S})}),(0,a.jsx)(n.av,{value:"sessions",className:"space-y-4",children:m?(0,a.jsx)("div",{className:"animate-pulse bg-gray-200 rounded-lg h-64"}):x?(0,a.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,a.jsxs)("p",{className:"text-red-600",children:[A("errors.sessionsFetch"),": ",x]})}):(0,a.jsx)(M,{projects:S})}),(0,a.jsxs)(n.av,{value:"tasks",className:"space-y-6",children:[(0,a.jsx)(en,{onJobCreated:()=>{k(e=>e+1)}}),(0,a.jsx)(ej,{refreshTrigger:_})]})]})]})]})}function eN(){return(0,a.jsx)("div",{className:"container mx-auto max-w-7xl p-6 space-y-6",children:(0,a.jsxs)("div",{className:"animate-pulse",children:[(0,a.jsx)("div",{className:"bg-gray-200 rounded-lg h-32 mb-6"}),(0,a.jsx)("div",{className:"bg-gray-200 rounded-lg h-64"})]})})}function ev(){return(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(eN,{}),children:(0,a.jsx)(eb,{})})}}},e=>{var s=s=>e(e.s=s);e.O(0,[205,433,646,972,999,441,684,358],()=>s(6495)),_N_E=e.O()}]);