"use strict";exports.id=4704,exports.ids=[4704],exports.modules={11865:(e,t,s)=>{s.d(t,{Ix:()=>x,pm:()=>m});var a=s(10326),r=s(17577),l=s(30361),n=s(69669),o=s(18019),i=s(94019);let c=3e3;function d({type:e,iconColor:t}){let s=`h-5 w-5 ${t}`;switch(e){case"success":return a.jsx(l.Z,{className:s,"data-testid":"toast-icon-success"});case"error":return a.jsx(n.Z,{className:s,"data-testid":"toast-icon-error"});default:return a.jsx(o.Z,{className:s,"data-testid":"toast-icon-info"})}}function u({id:e,message:t,type:s,onClose:l,duration:n=c}){let o=(0,r.useRef)(null),u=function(e){switch(e){case"success":return{bgColor:"bg-green-50",borderColor:"border-green-200",textColor:"text-green-800",iconColor:"text-green-500"};case"error":return{bgColor:"bg-red-50",borderColor:"border-red-200",textColor:"text-red-800",iconColor:"text-red-500"};default:return{bgColor:"bg-blue-50",borderColor:"border-blue-200",textColor:"text-blue-800",iconColor:"text-blue-500"}}}(s),x=(0,r.useCallback)(()=>{o.current&&clearTimeout(o.current),l(e)},[e,l]);return(0,a.jsxs)("div",{"data-testid":`toast-${e}`,role:"alert",className:`
        ${u.bgColor}
        ${u.borderColor}
        ${u.textColor}
        border rounded-lg shadow-lg p-4 min-w-[300px] max-w-[400px]
        flex items-start gap-3
        animate-slide-in
      `,children:[a.jsx(d,{type:s,iconColor:u.iconColor}),a.jsx("p",{className:"flex-1 text-sm font-medium",children:t}),a.jsx("button",{"data-testid":"toast-close-button",onClick:x,"aria-label":"Close notification",className:`
          ${u.textColor}
          hover:opacity-70
          focus:outline-none focus:ring-2 focus:ring-offset-2
          transition-opacity
        `,children:a.jsx(i.Z,{className:"h-4 w-4"})})]})}function x({toasts:e,onClose:t}){return a.jsx("div",{"data-testid":"toast-container","aria-live":"polite",className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(e=>a.jsx(u,{id:e.id,message:e.message,type:e.type,onClose:t,duration:e.duration},e.id))})}function m(){let[e,t]=(0,r.useState)([]),s=(0,r.useRef)(0);return{toasts:e,showToast:(0,r.useCallback)((e,a="info",r=c)=>{let l=`toast-${++s.current}-${Date.now()}`,n={id:l,message:e,type:a,duration:r};return t(e=>[...e,n]),l},[]),removeToast:(0,r.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),clearToasts:(0,r.useCallback)(()=>{t([])},[])}}},2583:(e,t,s)=>{s.d(t,{Vw:()=>S});var a=s(10326),r=s(17577);s(90434);var l=s(87403),n=s(2982),o=s(35047),i=s(3885),c=s(61421);function d({status:e,label:t}){let s=c.F4[e],r=`${t}: ${s.label}`;return"spinner"===s.type?a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ${s.className}`,title:r,"aria-label":r}):a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${s.className}`,title:r,"aria-label":r})}let u=(0,r.memo)(function({branch:e,isSelected:t,onClick:s}){return(0,a.jsxs)("button",{"data-testid":"branch-list-item",onClick:s,"aria-current":t?"true":void 0,className:`
        w-full px-4 py-3 flex flex-col gap-1
        hover:bg-gray-800 transition-colors
        focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500
        ${t?"bg-gray-700 border-l-2 border-blue-500":"border-l-2 border-transparent"}
      `,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 w-full",children:[e.cliStatus&&(0,a.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0","aria-label":"CLI tool status",children:[a.jsx(d,{status:e.cliStatus.claude,label:"Claude"}),a.jsx(d,{status:e.cliStatus.codex,label:"Codex"})]}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 text-left",children:[a.jsx("p",{className:"text-sm font-medium text-white truncate",children:e.name}),a.jsx("p",{className:"text-xs text-gray-400 truncate",children:e.repositoryName})]}),e.hasUnread&&a.jsx("span",{"data-testid":"unread-indicator",className:"w-2 h-2 rounded-full bg-blue-500 flex-shrink-0","aria-label":"Has unread messages"})]}),e.description&&a.jsx("div",{"data-testid":"branch-description",className:"pl-6 pr-2 mt-1 text-left",children:a.jsx("p",{className:"text-xs text-gray-400 line-clamp-2",children:e.description})})]})}),x=[{key:"updatedAt",label:"Updated"},{key:"repositoryName",label:"Repository"},{key:"branchName",label:"Branch"},{key:"status",label:"Status"}],m=(0,r.memo)(function(){let{sortKey:e,sortDirection:t,setSortKey:s,setSortDirection:n}=(0,l.Sz)(),[o,i]=(0,r.useState)(!1),c=(0,r.useRef)(null);(0,r.useEffect)(()=>{function e(e){c.current&&!c.current.contains(e.target)&&i(!1)}if(o)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o]),(0,r.useEffect)(()=>{function e(e){"Escape"===e.key&&i(!1)}if(o)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[o]);let d=(0,r.useCallback)(()=>{i(e=>!e)},[]),u=(0,r.useCallback)(a=>{a===e?n("asc"===t?"desc":"asc"):(s(a),n("updatedAt"===a?"desc":"asc")),i(!1)},[e,t,s,n]),m=(0,r.useCallback)(()=>{n("asc"===t?"desc":"asc")},[t,n]),b=x.find(t=>t.key===e)?.label||"Sort";return(0,a.jsxs)("div",{ref:c,className:"relative","data-testid":"sort-selector",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsxs)("button",{type:"button",onClick:d,"aria-expanded":o,"aria-haspopup":"listbox","aria-label":`Sort by ${b}`,className:" flex items-center gap-1 px-2 py-1 rounded text-xs text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors ",children:[a.jsx(h,{className:"w-3 h-3"}),a.jsx("span",{className:"hidden sm:inline",children:b})]}),a.jsx("button",{type:"button",onClick:m,"aria-label":"asc"===t?"Sort ascending":"Sort descending",className:" p-1 rounded text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors ",children:"asc"===t?a.jsx(p,{className:"w-3 h-3"}):a.jsx(g,{className:"w-3 h-3"})})]}),o&&a.jsx("div",{role:"listbox","aria-label":"Sort options",className:" absolute right-0 top-full mt-1 z-50 min-w-[140px] py-1 rounded-md shadow-lg bg-gray-800 border border-gray-600 ",children:x.map(s=>(0,a.jsxs)("button",{type:"button",role:"option","aria-selected":e===s.key,onClick:()=>u(s.key),className:`
                w-full px-3 py-2 text-left text-sm
                flex items-center justify-between
                hover:bg-gray-700 transition-colors
                ${e===s.key?"text-blue-400":"text-gray-300"}
              `,children:[a.jsx("span",{children:s.label}),e===s.key&&a.jsx("span",{className:"text-xs",children:"asc"===t?"ASC":"DESC"})]},s.key))})]})});function h({className:e}){return a.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})})}function p({className:e}){return a.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"})})}function g({className:e}){return a.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}var b=s(34643);let f=["en","ja"],y={en:"English",ja:"日本語"};function v(){let{currentLocale:e,switchLocale:t}={currentLocale:(0,b.bU)(),switchLocale:e=>{f.includes(e)&&(function(e){let t="https:"===window.location.protocol;document.cookie=`locale=${e};path=/;max-age=31536000;SameSite=Lax${t?";Secure":""}`}(e),localStorage.setItem("locale",e),window.location.reload())}};return a.jsx("select",{value:e,onChange:e=>t(e.target.value),"aria-label":"Language",className:" w-full px-3 py-2 rounded-md bg-gray-800 text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm ",children:f.map(e=>a.jsx("option",{value:e,children:y[e]},e))})}var j=s(18421);let w={waiting:0,ready:1,running:2,generating:3,idle:4},N=(0,r.memo)(function(){let e=(0,o.useRouter)(),{worktrees:t,selectedWorktreeId:s,selectWorktree:n}=(0,i.Mu)(),{closeMobileDrawer:c,sortKey:d,sortDirection:x}=(0,l.Sz)(),[h,p]=(0,r.useState)(""),g=(0,r.useMemo)(()=>{let e=t.map(j.I_),s=e;if(h.trim()){let t=h.toLowerCase();s=e.filter(e=>e.name.toLowerCase().includes(t)||e.repositoryName.toLowerCase().includes(t))}return function(e,t,s){let a=[...e];return a.sort((e,a)=>{let r=0;switch(t){case"updatedAt":{let t=e=>e?e instanceof Date?e.getTime():new Date(e).getTime():0,s=t(e.lastActivity);r=t(a.lastActivity)-s;break}case"repositoryName":{let t=e.repositoryName.toLowerCase(),s=a.repositoryName.toLowerCase();r=t.localeCompare(s);break}case"branchName":{let t=e.name.toLowerCase(),s=a.name.toLowerCase();r=t.localeCompare(s);break}case"status":r=w[e.status]-w[a.status]}return("updatedAt"===t?"desc"===s:"asc"===s)?r:-r}),a}(s,d,x)},[t,h,d,x]),b=t=>{n(t),e.push(`/worktrees/${t}`),c()};return(0,a.jsxs)("nav",{"data-testid":"sidebar","aria-label":"Branch navigation",className:"h-full flex flex-col bg-gray-900 text-white",role:"navigation",children:[a.jsx("div",{"data-testid":"sidebar-header",className:"flex-shrink-0 px-4 py-4 border-b border-gray-700",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Branches"}),a.jsx(m,{})]})}),a.jsx("div",{className:"flex-shrink-0 px-4 py-3 border-b border-gray-700",children:a.jsx("input",{type:"text",placeholder:"Search branches...",value:h,onChange:e=>p(e.target.value),className:" w-full px-3 py-2 rounded-md bg-gray-800 text-white placeholder-gray-400 border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent "})}),a.jsx("div",{"data-testid":"branch-list",className:"flex-1 overflow-y-auto",children:0===g.length?a.jsx("div",{className:"px-4 py-8 text-center text-gray-400",children:h?"No branches found":"No branches available"}):g.map(e=>a.jsx(u,{branch:e,isSelected:e.id===s,onClick:()=>b(e.id)},e.id))}),a.jsx("div",{className:"flex-shrink-0 px-4 py-3 border-t border-gray-700",children:a.jsx(v,{})})]})});var k=s(22202);let C="transform transition-transform duration-300 ease-out",S=(0,r.memo)(function({children:e}){let{isOpen:t,isMobileDrawerOpen:s,closeMobileDrawer:r}=(0,l.Sz)();return(0,n.d)()?(0,a.jsxs)("div",{"data-testid":"app-shell",className:"h-screen flex flex-col",children:[s&&a.jsx("div",{"data-testid":"drawer-overlay",className:"fixed inset-0 bg-black/50 z-40",onClick:r,"aria-hidden":"true"}),a.jsx("aside",{"data-testid":"sidebar-container",className:`
            fixed left-0 top-0 h-full w-72 z-50
            ${C}
            ${s?"translate-x-0":"-translate-x-full"}
          `,role:"complementary",children:a.jsx(N,{})}),a.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",role:"main",children:e})]}):(0,a.jsxs)("div",{"data-testid":"app-shell",className:"h-screen flex",children:[a.jsx("aside",{"data-testid":"sidebar-container",className:`
          fixed left-0 top-0 h-full w-72
          ${C}
          ${t?"translate-x-0":"-translate-x-full"}
        `,style:{zIndex:k.k.SIDEBAR},role:"complementary","aria-hidden":!t,children:a.jsx(N,{})}),a.jsx("main",{className:`
          flex-1 min-w-0 h-full overflow-hidden
          transition-[padding] duration-300 ease-out
          ${t?"md:pl-72":"md:pl-0"}
        `,role:"main",children:e})]})})},28676:(e,t,s)=>{s.d(t,{u:()=>n});var a=s(10326),r=s(17577),l=s(60962);function n({isOpen:e,onClose:t,title:s,children:n,size:o="lg",showCloseButton:i=!0,disableClose:c=!1}){let d=(0,r.useRef)(null);return e?(0,l.createPortal)((0,a.jsxs)("div",{className:"fixed inset-0 z-[9999] overflow-y-auto",children:[a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:c?void 0:t}),a.jsx("div",{className:"relative flex min-h-full items-center justify-center p-2 sm:p-4",children:(0,a.jsxs)("div",{ref:d,className:`relative w-full ${{sm:"max-w-[calc(100vw-2rem)] sm:max-w-md",md:"max-w-[calc(100vw-2rem)] sm:max-w-2xl",lg:"max-w-[calc(100vw-2rem)] sm:max-w-4xl",xl:"max-w-[calc(100vw-2rem)] sm:max-w-6xl",full:"max-w-[calc(100vw-2rem)] sm:max-w-[95vw]"}[o]} max-h-[calc(100vh-1rem)] sm:max-h-[calc(100vh-2rem)] flex flex-col bg-white rounded-lg shadow-xl transform transition-all`,children:[(s||i)&&(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 sm:px-6 py-3 sm:py-4 border-b border-gray-200 flex-shrink-0",children:[a.jsx("h3",{className:"text-base sm:text-lg font-semibold text-gray-900 truncate pr-2",children:s}),i&&a.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 transition-colors flex-shrink-0",children:a.jsx("svg",{className:"w-5 h-5 sm:w-6 sm:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsx("div",{className:"px-4 sm:px-6 py-3 sm:py-4 overflow-y-auto flex-1 min-h-0",children:n})]})})]}),document.body):null}},77758:(e,t,s)=>{s.d(t,{Ct:()=>c,zx:()=>r,Zb:()=>l,aY:()=>i,Ol:()=>n,ll:()=>o,u_:()=>d.u});var a=s(10326);function r({variant:e="primary",size:t="md",fullWidth:s=!1,loading:r=!1,disabled:l,className:n="",children:o,...i}){let c=["btn",{primary:"btn-primary",secondary:"btn-secondary",danger:"btn-danger",ghost:"bg-transparent text-gray-700 hover:bg-gray-100 focus:ring-gray-500"}[e],{sm:"btn-sm",md:"",lg:"btn-lg"}[t],s?"w-full":"",l||r?"opacity-50 cursor-not-allowed":"",n].filter(Boolean).join(" ");return(0,a.jsxs)("button",{className:c,disabled:l||r,...i,children:[r&&(0,a.jsxs)("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),o]})}function l({hover:e=!1,padding:t="md",className:s="",children:r,...l}){let n=["card",e?"card-hover":"",{none:"",sm:"p-3",md:"p-4",lg:"p-6"}[t],s].filter(Boolean).join(" ");return a.jsx("div",{className:n,...l,children:r})}function n({className:e="",children:t,...s}){return a.jsx("div",{className:`mb-3 ${e}`,...s,children:t})}function o({className:e="",children:t,...s}){return a.jsx("h3",{className:`text-lg font-semibold text-gray-900 ${e}`,...s,children:t})}function i({className:e="",children:t,...s}){return a.jsx("div",{className:e,...s,children:t})}function c({variant:e="gray",dot:t=!1,className:s="",children:r,...l}){let n=["badge",{success:"badge-success",warning:"badge-warning",error:"badge-error",info:"badge-info",gray:"badge-gray"}[e],s].filter(Boolean).join(" ");return(0,a.jsxs)("span",{className:n,...l,children:[t&&a.jsx("span",{className:`mr-1.5 inline-block h-2 w-2 rounded-full ${{success:"bg-green-600",warning:"bg-yellow-600",error:"bg-red-600",info:"bg-blue-600",gray:"bg-gray-600"}[e]}`,"aria-hidden":"true"}),r]})}s(17577);var d=s(28676)},11867:(e,t,s)=>{s.d(t,{n:()=>d});var a=s(10326),r=s(17577),l=s(77758),n=s(11865),o=s(73002),i=s(91515),c=s(51223);function d({worktreeId:e}){let[t,s]=(0,r.useState)([]),[d,u]=(0,r.useState)(null),[x,m]=(0,r.useState)(null),[h,p]=(0,r.useState)(!0),[g,b]=(0,r.useState)(null),[f,y]=(0,r.useState)(""),[v,j]=(0,r.useState)(0),[w,N]=(0,r.useState)("all"),[k,C]=(0,r.useState)(!1),{toasts:S,showToast:L,removeToast:z}=(0,n.pm)(),$=(0,r.useMemo)(()=>"all"===w?t:t.filter(e=>e.toLowerCase().includes(w)),[t,w]),M=async t=>{try{p(!0),b(null);let s=await o.Iv.getLogFile(e,t);m(s.content),u(t),y(""),j(0)}catch(e){b((0,o.zG)(e))}finally{p(!1)}},E=(0,r.useCallback)(async()=>{if(d)try{C(!0);let t=await o.Iv.getLogFile(e,d,{sanitize:!0});await (0,i.v)(t.content),L("Log copied to clipboard (sanitized)","success")}catch(e){L(`Failed to export log: ${(0,o.zG)(e)}`,"error")}finally{C(!1)}},[e,d,L]),T=(0,r.useMemo)(()=>{let e;if(!f||!x)return[];let t=RegExp((0,c.hr)(f),"gi"),s=[];for(;null!==(e=t.exec(x));)s.push({index:e.index,length:e[0].length});return s},[f,x]),A=()=>{T.length>0&&j(e=>(e+1)%T.length)},I=()=>{T.length>0&&j(e=>(e-1+T.length)%T.length)},B=(0,r.useMemo)(()=>{if(!x||!f||0===T.length)return x;let e="",t=0;return T.forEach((s,a)=>{e+=(0,c.Xv)(x.substring(t,s.index));let r=x.substring(s.index,s.index+s.length),l=a===v;e+=`<mark class="${l?"bg-yellow-400 text-black":"bg-yellow-200 text-black"}" data-match-index="${a}">${(0,c.Xv)(r)}</mark>`,t=s.index+s.length}),e+=(0,c.Xv)(x.substring(t))},[x,f,T,v]);return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)(l.Zb,{padding:"md",children:[a.jsx(l.Ol,{children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx(l.ll,{children:"Log Files"}),a.jsx(l.Ct,{variant:"gray",children:$.length})]}),(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,a.jsxs)(l.zx,{variant:"all"===w?"primary":"ghost",size:"sm",onClick:()=>N("all"),children:["All (",t.length,")"]}),(0,a.jsxs)(l.zx,{variant:"claude"===w?"primary":"ghost",size:"sm",onClick:()=>N("claude"),children:["Claude (",t.filter(e=>e.toLowerCase().includes("claude")).length,")"]}),(0,a.jsxs)(l.zx,{variant:"codex"===w?"primary":"ghost",size:"sm",onClick:()=>N("codex"),children:["Codex (",t.filter(e=>e.toLowerCase().includes("codex")).length,")"]}),(0,a.jsxs)(l.zx,{variant:"gemini"===w?"primary":"ghost",size:"sm",onClick:()=>N("gemini"),children:["Gemini (",t.filter(e=>e.toLowerCase().includes("gemini")).length,")"]})]})]})}),(0,a.jsxs)(l.aY,{children:[h&&0===t.length&&a.jsx("div",{className:"text-center py-4",children:a.jsx("div",{className:"inline-block animate-spin rounded-full h-6 w-6 border-4 border-gray-300 border-t-blue-600"})}),g&&a.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded text-sm text-red-800",children:g}),!h&&0===$.length&&!g&&a.jsx("p",{className:"text-sm text-gray-600 text-center py-4",children:"all"===w?"No log files found":`No ${w} log files found`}),$.length>0&&a.jsx("div",{className:"space-y-2",children:$.map(e=>a.jsx("button",{onClick:()=>M(e),className:`w-full text-left px-3 py-2 rounded text-sm font-mono transition-colors ${d===e?"bg-blue-50 text-blue-700 border border-blue-200":"hover:bg-gray-50 border border-transparent"}`,children:e},e))})]})]}),d&&(0,a.jsxs)(l.Zb,{padding:"md",children:[a.jsx(l.Ol,{children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx(l.ll,{className:"font-mono text-base",children:d}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx(l.zx,{variant:"ghost",size:"sm",onClick:E,disabled:!d||k,title:"Copy sanitized log to clipboard",children:k?"Exporting...":"Export"}),a.jsx(l.zx,{variant:"ghost",size:"sm",onClick:()=>{u(null),m(null),y(""),j(0)},children:"Close"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[a.jsx("input",{type:"text",value:f,onChange:e=>y(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?I():A())},placeholder:"Search in log file...",className:"input w-full pr-20"}),T.length>0&&(0,a.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:[v+1," / ",T.length]})]}),T.length>0&&(0,a.jsxs)("div",{className:"flex gap-1",children:[a.jsx(l.zx,{variant:"ghost",size:"sm",onClick:I,disabled:0===T.length,title:"Previous match (Shift+Enter)",children:"↑"}),a.jsx(l.zx,{variant:"ghost",size:"sm",onClick:A,disabled:0===T.length,title:"Next match (Enter)",children:"↓"})]})]})]})}),(0,a.jsxs)(l.aY,{children:[h&&a.jsx("div",{className:"text-center py-8",children:a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"})}),!h&&x&&a.jsx("div",{className:"bg-gray-900 text-gray-100 rounded p-4 overflow-x-auto max-h-[500px] scrollbar-thin",children:f&&T.length>0?a.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap",dangerouslySetInnerHTML:{__html:B||""}}):a.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap",children:x})}),!h&&f&&0===T.length&&x&&(0,a.jsxs)("div",{className:"text-center py-4 text-sm text-gray-500",children:['No matches found for "',f,'"']})]})]}),a.jsx(n.Ix,{toasts:S,onClose:z})]})}},15470:(e,t,s)=>{s.d(t,{R:()=>x});var a=s(10326),r=s(17577),l=s(73002);function n(e,t){if(!t.trim())return e;let s=t.toLowerCase();return e.map(e=>({...e,commands:e.commands.filter(e=>{let t=e.name.toLowerCase().includes(s),a=e.description.toLowerCase().includes(s);return t||a})})).filter(e=>e.commands.length>0)}function o({groups:e,onSelect:t,highlightedIndex:s=-1,className:r=""}){let l=0;return 0===e.length?a.jsx("div",{className:`text-sm text-gray-500 p-4 text-center ${r}`,children:"No commands available"}):a.jsx("div",{className:`overflow-y-auto ${r}`,children:e.map(e=>(0,a.jsxs)("div",{className:"mb-2",children:[a.jsx("div",{className:"px-3 py-1.5 text-xs font-semibold text-gray-500 uppercase tracking-wider bg-gray-50",children:e.label}),a.jsx("div",{children:e.commands.map(e=>{let r=l;l++;let n=r===s;return(0,a.jsxs)("button",{type:"button","data-command-item":!0,"data-highlighted":n,onClick:()=>t(e),className:`w-full px-3 py-2 text-left flex items-start gap-2 hover:bg-blue-50 transition-colors ${n?"bg-blue-100":""}`,children:[(0,a.jsxs)("span",{className:"text-blue-600 font-mono text-sm flex-shrink-0",children:["/",e.name]}),a.jsx("span",{className:"text-gray-600 text-sm truncate",children:e.description})]},e.name)})})]},e.category))})}function i({isOpen:e,groups:t,onSelect:s,onClose:l,isMobile:i=!1,position:c,onFreeInput:d}){let[u,x]=(0,r.useState)(""),[m,h]=(0,r.useState)(0),p=(0,r.useRef)(null),g=(0,r.useMemo)(()=>n(t,u),[t,u]),b=(0,r.useMemo)(()=>g.flatMap(e=>e.commands),[g]),f=(0,r.useCallback)(e=>{s(e),l()},[s,l]);return((0,r.useCallback)(t=>{if(e)switch(t.key){case"Escape":t.preventDefault(),l();break;case"ArrowDown":t.preventDefault(),h(e=>Math.min(e+1,b.length-1));break;case"ArrowUp":t.preventDefault(),h(e=>Math.max(e-1,0));break;case"Enter":t.preventDefault(),b[m]&&f(b[m])}},[e,b,m,l,f]),e)?i?(0,a.jsxs)(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 bg-black/50 z-40",onClick:l,"aria-hidden":"true"}),(0,a.jsxs)("div",{"data-testid":"slash-command-bottom-sheet",className:"fixed bottom-0 left-0 right-0 bg-white rounded-t-xl z-50 max-h-[70vh] flex flex-col shadow-xl",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Commands"}),a.jsx("button",{type:"button",onClick:l,"aria-label":"Close",className:"p-2 rounded-full hover:bg-gray-100",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsx("div",{className:"px-4 py-2 border-b border-gray-100",children:a.jsx("input",{ref:p,type:"text",value:u,onChange:e=>x(e.target.value),placeholder:"Search commands...",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})}),d&&(0,a.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:d,className:"w-full px-4 py-3 text-left border-b border-gray-100 flex items-center gap-2 hover:bg-blue-50 transition-colors",children:[a.jsx("span",{className:"text-blue-600",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),a.jsx("span",{className:"text-gray-600",children:"Enter custom command..."})]}),a.jsx(o,{groups:g,onSelect:f,highlightedIndex:m,className:"flex-1 overflow-y-auto pb-20"})]})]}):(0,a.jsxs)("div",{role:"listbox",className:"absolute bg-white border border-gray-200 rounded-lg shadow-lg z-50 w-80 max-h-96 flex flex-col",style:c?{top:c.top,left:c.left}:{bottom:"100%",left:0,marginBottom:"4px"},children:[a.jsx("div",{className:"px-3 py-2 border-b border-gray-100",children:a.jsx("input",{ref:p,type:"text",value:u,onChange:e=>x(e.target.value),placeholder:"Search commands...",className:"w-full px-3 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})}),d&&(0,a.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:d,className:"w-full px-3 py-2 text-left border-b border-gray-100 flex items-center gap-2 hover:bg-blue-50 transition-colors text-sm",children:[a.jsx("span",{className:"text-blue-600",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),a.jsx("span",{className:"text-gray-600",children:"Enter custom command..."})]}),a.jsx(o,{groups:g,onSelect:f,highlightedIndex:m,className:"flex-1 overflow-y-auto"}),(0,a.jsxs)("div",{className:"px-3 py-1.5 border-t border-gray-100 text-xs text-gray-400 flex gap-3",children:[(0,a.jsxs)("span",{children:[a.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 rounded",children:"Enter"})," select"]}),(0,a.jsxs)("span",{children:[a.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 rounded",children:"Esc"})," close"]})]})]}):null}function c({worktreeId:e,cliToolId:t,disabled:s=!1,onInterrupt:l}){let[n,o]=(0,r.useState)(!1),i=(0,r.useRef)(0),c=(0,r.useCallback)(async()=>{let s=Date.now();if(!(s-i.current<1e3)){i.current=s,o(!0);try{let s=await fetch(`/api/worktrees/${e}/interrupt`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:t})});if(s.ok)l?.();else{let e=await s.json().catch(()=>({}));console.error("[InterruptButton] Failed to send interrupt:",e.error||s.statusText)}}catch(e){console.error("[InterruptButton] Error sending interrupt:",e)}finally{o(!1)}}},[e,t,l]);return a.jsx("button",{type:"button",onClick:c,disabled:s||n,className:"flex-shrink-0 p-2 text-orange-600 hover:bg-orange-50 rounded-full transition-colors disabled:text-gray-300 disabled:hover:bg-transparent","aria-label":"Stop processing","data-testid":"interrupt-button",children:n?(0,a.jsxs)("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):a.jsx(d,{})})}function d(){return a.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 24 24",children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}var u=s(2982);function x({worktreeId:e,onMessageSent:t,cliToolId:s,isSessionRunning:o=!1}){let[d,x]=(0,r.useState)(""),[m,h]=(0,r.useState)(!1),[p,g]=(0,r.useState)(null),[b,f]=(0,r.useState)(!1),[y,v]=(0,r.useState)(!1),j=(0,r.useRef)(null),w=(0,r.useRef)(null),N=(0,r.useRef)(!1),k=(0,r.useRef)(null),C=(0,u.d)(),{groups:S}=function(e,t){let[s,a]=(0,r.useState)([]),[o,i]=(0,r.useState)(!0),[c,d]=(0,r.useState)(null),[u,x]=(0,r.useState)(""),[m,h]=(0,r.useState)(t||"claude"),p=(0,r.useCallback)(async()=>{try{i(!0),d(null);let s=e?`/api/worktrees/${e}/slash-commands`:"/api/slash-commands";t&&(s+=`?cliTool=${t}`);let r=await fetch(s);if(!r.ok)throw Error(`HTTP error ${r.status}`);let l=await r.json();a(l.groups),h(l.cliTool||t||"claude")}catch(e){d((0,l.zG)(e)),a([])}finally{i(!1)}},[e,t]),g=(0,r.useMemo)(()=>s.flatMap(e=>e.commands),[s]),b=(0,r.useMemo)(()=>n(s,u),[s,u]);return{groups:s,filteredGroups:b,allCommands:g,loading:o,error:c,filter:u,setFilter:x,refresh:(0,r.useCallback)(()=>{p()},[p]),cliTool:m}}(e,s),L=async()=>{if(!b&&d.trim()&&!m)try{h(!0),g(null);let a=s||"claude";await l.Iv.sendMessage(e,d.trim(),a),x(""),t?.(a)}catch(e){g((0,l.zG)(e))}finally{h(!1)}},z=async e=>{e.preventDefault(),await L()},$=()=>{v(!1),j.current?.focus()};return(0,a.jsxs)("div",{ref:k,className:"space-y-2 relative",children:[p&&a.jsx("div",{className:"p-2 bg-red-50 border border-red-200 rounded text-sm text-red-800",children:p}),(0,a.jsxs)("form",{onSubmit:z,className:"flex items-end gap-2 bg-white border border-gray-300 rounded-lg px-4 py-2 focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500",children:[C&&a.jsx("button",{type:"button",onClick:()=>v(!0),className:"flex-shrink-0 p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded-full transition-colors","aria-label":"Show slash commands","data-testid":"mobile-command-button",children:a.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"})})}),a.jsx("textarea",{ref:j,value:d,onChange:e=>{let t=e.target.value;x(t),"/"===t||t.startsWith("/")&&!t.includes(" ")?v(!0):v(!1)},onKeyDown:e=>{let{keyCode:t}=e.nativeEvent;if(229!==t){if("Escape"===e.key&&y){e.preventDefault(),$();return}if(N.current&&"Enter"===e.key){N.current=!1;return}if("Enter"===e.key&&!b&&!y){if(C)return;e.shiftKey||(e.preventDefault(),L())}}},onCompositionStart:()=>{f(!0),N.current=!1,w.current&&clearTimeout(w.current)},onCompositionEnd:()=>{f(!1),N.current=!0,w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{N.current=!1},300)},placeholder:C?"Type your message...":"Type your message... (/ for commands, Shift+Enter for line break)",disabled:m,rows:1,className:"flex-1 outline-none bg-transparent resize-none py-1 overflow-y-auto scrollbar-thin",style:{minHeight:"24px",maxHeight:"160px"}}),a.jsx(c,{worktreeId:e,cliToolId:s||"claude",disabled:!o}),a.jsx("button",{type:"submit",disabled:!d.trim()||m,className:"flex-shrink-0 p-2 text-blue-600 hover:bg-blue-50 rounded-full transition-colors disabled:text-gray-300 disabled:hover:bg-transparent","aria-label":"Send message",children:m?(0,a.jsxs)("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):a.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),a.jsx(i,{isOpen:y,groups:S,onSelect:e=>{x(`/${e.name} `),v(!1),j.current?.focus()},onClose:$,isMobile:C,onFreeInput:()=>{v(!1),x("/"),setTimeout(()=>{j.current?.focus()},50)}})]})}},61421:(e,t,s)=>{s.d(t,{F4:()=>r,Ie:()=>n,xh:()=>l});let a={idle:"bg-gray-500",ready:"bg-green-500",spinner:"border-blue-500",waiting:"bg-yellow-500",error:"bg-red-500"},r={idle:{className:a.idle,label:"Idle",type:"dot"},ready:{className:a.ready,label:"Ready",type:"dot"},running:{className:a.spinner,label:"Running",type:"spinner"},waiting:{className:a.waiting,label:"Waiting for response",type:"dot"},generating:{className:a.spinner,label:"Generating",type:"spinner"}},l={idle:{className:a.idle,label:"Idle",type:"dot"},ready:{className:a.ready,label:"Ready",type:"dot"},running:{className:a.spinner,label:"Running",type:"spinner"},waiting:{className:a.waiting,label:"Waiting for response",type:"dot"},error:{className:a.error,label:"Error",type:"dot"}},n={idle:{className:a.idle,label:"Idle - No active session",type:"dot"},ready:{className:a.ready,label:"Ready - Waiting for input",type:"dot"},running:{className:a.spinner,label:"Running - Processing",type:"spinner"},waiting:{className:a.waiting,label:"Waiting - User input required",type:"dot"},error:{className:a.error,label:"Error",type:"dot"}}},22202:(e,t,s)=>{s.d(t,{k:()=>a});let a={DROPDOWN:10,SIDEBAR:30,MODAL:50,MAXIMIZED_EDITOR:55,TOAST:60,CONTEXT_MENU:70}},2982:(e,t,s)=>{s.d(t,{d:()=>r});var a=s(17577);function r(e={}){let{breakpoint:t=768}=e,[s,r]=(0,a.useState)(!1);return s}},91515:(e,t,s)=>{s.d(t,{v:()=>r});let a=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07|\[[0-9;]*m/g;async function r(e){if(!e||0===e.trim().length)return;let t=e.replace(a,"");await navigator.clipboard.writeText(t)}},51223:(e,t,s)=>{function a(e,t){let s=null;return(...a)=>{s&&clearTimeout(s),s=setTimeout(()=>{e(...a),s=null},t)}}function r(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function l(e){let t=new Set;for(let s of e){t.add(s);let e=s.split("/"),a="";for(let s=0;s<e.length-1;s++)a=a?`${a}/${e[s]}`:e[s],t.add(a)}return t}function n(e,t=30){return e.length<=t?e:`${e.substring(0,t-3)}...`}function o(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}s.d(t,{Ds:()=>a,Ps:()=>l,Xv:()=>o,aS:()=>n,hr:()=>r})},18421:(e,t,s)=>{function a(e){return e?e.isWaitingForResponse?"waiting":e.isProcessing?"running":e.isRunning?"ready":"idle":"idle"}function r(e){let t=!!e.lastAssistantMessageAt&&(!e.lastViewedAt||new Date(e.lastAssistantMessageAt)>new Date(e.lastViewedAt));return{id:e.id,name:e.name,repositoryName:e.repositoryName,status:"idle",hasUnread:t,lastActivity:e.updatedAt,description:e.description,cliStatus:{claude:a(e.sessionStatusByCli?.claude),codex:a(e.sessionStatusByCli?.codex)}}}s.d(t,{He:()=>a,I_:()=>r})},63601:(e,t,s)=>{s.r(t),s.d(t,{default:()=>r});var a=s(66621);let r=e=>[{type:"image/png",sizes:"180x180",url:(0,a.fillMetadataSegment)(".",e.params,"apple-icon.png")+"?31a89e65aa4ac65b"}]},71150:(e,t,s)=>{s.r(t),s.d(t,{default:()=>r});var a=s(66621);let r=e=>[{type:"image/png",sizes:"32x32",url:(0,a.fillMetadataSegment)(".",e.params,"icon.png")+"?32d9127ba30ee286"}]}};