"use strict";exports.id=398,exports.ids=[398],exports.modules={11865:(e,t,r)=>{r.d(t,{Ix:()=>g,pm:()=>h});var a=r(10326),s=r(17577),n=r(28567),l=r(69669),o=r(50949),i=r(18019),c=r(94019),d=r(22202);let u=3e3;function x({type:e,iconColor:t}){let r=`h-5 w-5 ${t}`;switch(e){case"success":return a.jsx(n.Z,{className:r,"data-testid":"toast-icon-success"});case"error":return a.jsx(l.Z,{className:r,"data-testid":"toast-icon-error"});case"warning":return a.jsx(o.Z,{className:r,"data-testid":"toast-icon-warning"});default:return a.jsx(i.Z,{className:r,"data-testid":"toast-icon-info"})}}function m({id:e,message:t,type:r,onClose:n,duration:l=u}){let o=(0,s.useRef)(null),i=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"};case"warning":return{bgColor:"bg-amber-50",borderColor:"border-amber-200",textColor:"text-amber-800",iconColor:"text-amber-500"};default:return{bgColor:"bg-cyan-50",borderColor:"border-cyan-200",textColor:"text-cyan-800",iconColor:"text-cyan-500"}}}(r),d=(0,s.useCallback)(()=>{o.current&&clearTimeout(o.current),n(e)},[e,n]);return(0,a.jsxs)("div",{"data-testid":`toast-${e}`,role:"alert",className:`
        ${i.bgColor}
        ${i.borderColor}
        ${i.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(x,{type:r,iconColor:i.iconColor}),a.jsx("p",{className:"flex-1 text-sm font-medium",children:t}),a.jsx("button",{"data-testid":"toast-close-button",onClick:d,"aria-label":"Close notification",className:`
          ${i.textColor}
          hover:opacity-70
          focus:outline-none focus:ring-2 focus:ring-offset-2
          transition-opacity
        `,children:a.jsx(c.Z,{className:"h-4 w-4"})})]})}function g({toasts:e,onClose:t}){return a.jsx("div",{"data-testid":"toast-container","aria-live":"polite",className:"fixed bottom-4 right-4 flex flex-col gap-2",style:{zIndex:d.k.TOAST},children:e.map(e=>a.jsx(m,{id:e.id,message:e.message,type:e.type,onClose:t,duration:e.duration},e.id))})}function h(){let[e,t]=(0,s.useState)([]),r=(0,s.useRef)(0);return{toasts:e,showToast:(0,s.useCallback)((e,a="info",s=u)=>{let n=`toast-${++r.current}-${Date.now()}`,l={id:n,message:e,type:a,duration:s};return t(e=>[...e,l]),n},[]),removeToast:(0,s.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),clearToasts:(0,s.useCallback)(()=>{t([])},[])}}},17706:(e,t,r)=>{r.d(t,{Vw:()=>V});var a=r(10326),s=r(17577);r(90434);var n=r(87403),l=r(2982),o=r(35047),i=r(6162),c=r(3885),d=r(61421),u=r(2491);function x({status:e,label:t}){let r=d.F4[e],s=`${t}: ${r.label}`;return"spinner"===r.type?a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ${r.className}`,title:s,"aria-label":s}):a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${r.className}`,title:s,"aria-label":s})}let m=(0,s.memo)(function({branch:e,isSelected:t,onClick:r}){return(0,a.jsxs)("button",{"data-testid":"branch-list-item",onClick:r,"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-cyan-500
        ${t?"bg-gray-700 border-l-2 border-cyan-500":"border-l-2 border-transparent"}
      `,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 w-full",children:[e.cliStatus&&Object.keys(e.cliStatus).length>0&&a.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 w-11","aria-label":"CLI tool status",children:Object.entries(e.cliStatus).map(([e,t])=>a.jsx(x,{status:t??"idle",label:(0,u.Ds)(e)},e))}),(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-cyan-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})})]})}),g=[{key:"updatedAt",label:"Updated"},{key:"repositoryName",label:"Repository"},{key:"branchName",label:"Branch"},{key:"status",label:"Status"}],h=(0,s.memo)(function(){let{sortKey:e,sortDirection:t,setSortKey:r,setSortDirection:l}=(0,n.Sz)(),[o,i]=(0,s.useState)(!1),c=(0,s.useRef)(null);(0,s.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,s.useEffect)(()=>{function e(e){"Escape"===e.key&&i(!1)}if(o)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[o]);let d=(0,s.useCallback)(()=>{i(e=>!e)},[]),u=(0,s.useCallback)(a=>{a===e?l("asc"===t?"desc":"asc"):(r(a),l("updatedAt"===a?"desc":"asc")),i(!1)},[e,t,r,l]),x=(0,s.useCallback)(()=>{l("asc"===t?"desc":"asc")},[t,l]),m=g.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 ${m}`,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(p,{className:"w-3 h-3"}),a.jsx("span",{className:"hidden sm:inline",children:m})]}),a.jsx("button",{type:"button",onClick:x,"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(f,{className:"w-3 h-3"}):a.jsx(b,{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:g.map(r=>(0,a.jsxs)("button",{type:"button",role:"option","aria-selected":e===r.key,onClick:()=>u(r.key),className:`
                w-full px-3 py-2 text-left text-sm
                flex items-center justify-between
                hover:bg-gray-700 transition-colors
                ${e===r.key?"text-blue-400":"text-gray-300"}
              `,children:[a.jsx("span",{children:r.label}),e===r.key&&a.jsx("span",{className:"text-xs",children:"asc"===t?"ASC":"DESC"})]},r.key))})]})});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:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})})}function f({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 b({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 y=r(34643);let v=["en","ja"],w={en:"English",ja:"日本語"};function k(){let{currentLocale:e,switchLocale:t}={currentLocale:(0,y.bU)(),switchLocale:e=>{v.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:v.map(e=>a.jsx("option",{value:e,children:w[e]},e))})}var j=r(14831),N=r(60850),C=r(72607);function S(){let{theme:e,setTheme:t}=(0,j.F)(),[r,n]=(0,s.useState)(!1);if(!r)return a.jsx("div",{"data-testid":"theme-toggle-placeholder",className:"w-8 h-8","aria-hidden":"true"});let l="dark"===e;return a.jsx("button",{"data-testid":"theme-toggle",onClick:()=>t(l?"light":"dark"),className:"p-1.5 rounded-md text-gray-400 hover:text-white hover:bg-gray-700 transition-colors focus:outline-none focus:ring-2 focus:ring-cyan-500","aria-label":l?"Switch to light mode":"Switch to dark mode",title:l?"Switch to light mode":"Switch to dark mode",children:l?a.jsx(N.Z,{className:"w-5 h-5","data-testid":"theme-icon-sun"}):a.jsx(C.Z,{className:"w-5 h-5","data-testid":"theme-icon-moon"})})}var L=r(94001);function M(){let e=(0,i.T)("auth"),t=(0,L.m)(),[r,n]=(0,s.useState)(!1);if(!t)return null;async function l(){n(!0);try{await fetch("/api/auth/logout",{method:"POST"}),window.location.href="/login"}catch{window.location.href="/login"}}return a.jsx("button",{type:"button",onClick:l,disabled:r,"data-testid":"logout-button",className:" w-full px-3 py-2 text-sm text-left rounded-md text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 transition-colors ",children:r?"...":e("logout.button")})}var z=r(11865),E=r(73002),$=r(18421);let T={waiting:0,ready:1,running:2,generating:3,idle:4};function B(e,t,r){let a=[...e];return a.sort((e,a)=>{let s=0;switch(t){case"updatedAt":{let t=e=>e?e instanceof Date?e.getTime():new Date(e).getTime():0,r=t(e.lastActivity);s=t(a.lastActivity)-r;break}case"repositoryName":{let t=e.repositoryName.toLowerCase(),r=a.repositoryName.toLowerCase();s=t.localeCompare(r);break}case"branchName":{let t=e.name.toLowerCase(),r=a.name.toLowerCase();s=t.localeCompare(r);break}case"status":s=T[e.status]-T[a.status]}return("updatedAt"===t?"desc"===r:"asc"===r)?s:-s}),a}let A=(0,s.memo)(function(){let e=(0,o.useRouter)(),{worktrees:t,selectedWorktreeId:r,selectWorktree:l,refreshWorktrees:i}=(0,c.Mu)(),{closeMobileDrawer:d,sortKey:u,sortDirection:x,viewMode:g,setViewMode:p}=(0,n.Sz)(),[f,b]=(0,s.useState)(""),[y,v]=(0,s.useState)(()=>({})),w=(0,s.useMemo)(()=>{let e=t.map($.I_);if(!f.trim())return e;let r=f.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(r)||e.repositoryName.toLowerCase().includes(r))},[t,f]),j=(0,s.useMemo)(()=>"flat"===g?B(w,u,x):[],[g,w,u,x]),N=(0,s.useMemo)(()=>"grouped"===g?function(e,t,r){let a=new Map;for(let t of e){let e=t.repositoryName;a.has(e)||a.set(e,[]),a.get(e).push(t)}return[...a.keys()].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).map(e=>({repositoryName:e,branches:B(a.get(e),t,r)}))}(w,u,x):null,[g,w,u,x]);(0,s.useEffect)(()=>{},[y]);let C=(0,s.useCallback)(e=>{v(t=>({...t,[e]:!t[e]}))},[]),L=(0,s.useCallback)(t=>{l(t);let r=`/worktrees/${t}`;e.push(r),d();let a=setTimeout(()=>{window.location.pathname!==r&&(window.location.href=r)},300),s=()=>clearTimeout(a);return window.addEventListener("popstate",s,{once:!0}),()=>{clearTimeout(a),window.removeEventListener("popstate",s)}},[l,e,d]),z="flat"===g?0===j.length:(N?.length??0)===0;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"}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[a.jsx(W,{viewMode:g,onToggle:p}),a.jsx(h,{}),a.jsx(F,{refreshWorktrees:i})]})]})}),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:f,onChange:e=>b(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-cyan-500 focus:border-transparent "})}),a.jsx("div",{"data-testid":"branch-list",className:"flex-1 overflow-y-auto",children:z?a.jsx("div",{className:"px-4 py-8 text-center text-gray-400",children:f?"No branches found":"No branches available"}):"grouped"===g&&N?N.map(e=>{let t=!y[e.repositoryName]||!!f.trim();return(0,a.jsxs)("div",{children:[a.jsx(I,{repositoryName:e.repositoryName,branchCount:e.branches.length,isExpanded:t,onClick:()=>C(e.repositoryName)}),t&&e.branches.map(e=>a.jsx(m,{branch:e,isSelected:e.id===r,onClick:()=>L(e.id)},e.id))]},e.repositoryName)}):j.map(e=>a.jsx(m,{branch:e,isSelected:e.id===r,onClick:()=>L(e.id)},e.id))}),(0,a.jsxs)("div",{className:"flex-shrink-0 px-4 py-3 border-t border-gray-700 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1",children:a.jsx(k,{})}),a.jsx(S,{})]}),a.jsx(M,{})]})]})});function I({repositoryName:e,branchCount:t,isExpanded:r,onClick:s}){return(0,a.jsxs)("button",{"data-testid":"group-header",type:"button",onClick:s,"aria-expanded":r,className:" w-full flex items-center gap-2 px-4 py-2 text-xs font-semibold text-gray-300 uppercase tracking-wider bg-gray-800/50 hover:bg-gray-800 border-b border-gray-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-cyan-500 transition-colors ",children:[a.jsx(R,{isExpanded:r}),a.jsx(D,{color:function(e){let t=function(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)|0;return Math.abs(t)}(e)%360;return`hsl(${t}, 65%, 60%)`}(e)}),a.jsx("span",{className:"flex-1 text-left truncate",children:e}),a.jsx("span",{className:"text-gray-500 font-normal",children:t})]})}function W({viewMode:e,onToggle:t}){return a.jsx("button",{"data-testid":"view-mode-toggle",type:"button",onClick:()=>{t("grouped"===e?"flat":"grouped")},"aria-label":"grouped"===e?"Switch to flat view":"Switch to grouped view",title:"grouped"===e?"Flat view":"Grouped view",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:"grouped"===e?a.jsx(H,{className:"w-3 h-3"}):a.jsx(D,{className:"w-3 h-3"})})}function R({isExpanded:e}){return a.jsx("svg",{className:`w-3 h-3 flex-shrink-0 transition-transform ${e?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})}function D({className:e="w-3.5 h-3.5",color:t}){return a.jsx("svg",{className:`${e} flex-shrink-0`,viewBox:"0 0 24 24",fill:t??"none",stroke:t?"none":"currentColor",strokeWidth:t?0:2,"aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})})}function H({className:e="w-3 h-3"}){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:"M4 6h16M4 12h16M4 18h16"})})}function O({className:e=""}){return a.jsx("svg",{className:`w-3 h-3 ${e}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h5M20 20v-5h-5M20.49 9A9 9 0 005.64 5.64L4 4m16 16l-1.64-1.64A9 9 0 014.51 15"})})}let F=(0,s.memo)(function({refreshWorktrees:e}){let[t,r]=(0,s.useState)(!1),n=(0,s.useRef)(!1),{showToast:l,toasts:o,removeToast:c}=(0,z.pm)(),d=(0,i.T)("common"),u=(0,s.useCallback)(async()=>{if(!n.current){n.current=!0,r(!0);try{let t=await E.J1.sync();await e(),l(d("syncSuccess",{count:t.worktreeCount}),"success",3e3)}catch(e){e instanceof E.MS&&401===e.status?l(d("syncAuthError"),"error",5e3):l(d("syncError"),"error",5e3)}finally{n.current=!1,r(!1)}}},[e,l,d]);return(0,a.jsxs)(a.Fragment,{children:[a.jsx("button",{type:"button",onClick:u,disabled:t,"aria-label":d("syncButtonLabel"),className:"p-1 rounded text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:a.jsx(O,{className:t?"animate-spin":""})}),a.jsx(z.Ix,{toasts:o,onClose:c})]})});var Z=r(22202);let U="transform transition-transform duration-300 ease-out",V=(0,s.memo)(function({children:e}){let{isOpen:t,isMobileDrawerOpen:r,closeMobileDrawer:s}=(0,n.Sz)();return(0,l.d)()?(0,a.jsxs)("div",{"data-testid":"app-shell",className:"h-screen flex flex-col",children:[r&&a.jsx("div",{"data-testid":"drawer-overlay",className:"fixed inset-0 bg-black/50 z-40",onClick:s,"aria-hidden":"true"}),a.jsx("aside",{"data-testid":"sidebar-container",className:`
            fixed left-0 top-0 h-full w-72 z-50
            ${U}
            ${r?"translate-x-0":"-translate-x-full"}
          `,role:"complementary",children:a.jsx(A,{})}),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
          border-r border-gray-200 dark:border-gray-600
          ${U}
          ${t?"translate-x-0":"-translate-x-full"}
        `,style:{zIndex:Z.k.SIDEBAR},role:"complementary","aria-hidden":!t,children:a.jsx(A,{})}),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,r)=>{r.d(t,{u:()=>o});var a=r(10326),s=r(17577),n=r(60962),l=r(22202);function o({isOpen:e,onClose:t,title:r,children:o,size:i="lg",showCloseButton:c=!0,disableClose:d=!1}){let u=(0,s.useRef)(null);return e?(0,n.createPortal)((0,a.jsxs)("div",{className:"fixed inset-0 overflow-y-auto",style:{zIndex:l.k.MODAL},children:[a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:d?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:u,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]"}[i]} max-h-[calc(100vh-1rem)] sm:max-h-[calc(100vh-2rem)] flex flex-col bg-white dark:bg-gray-900 rounded-lg shadow-xl transform transition-all`,children:[(r||c)&&(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 dark:border-gray-700 flex-shrink-0",children:[a.jsx("h3",{className:"text-base sm:text-lg font-semibold text-gray-900 dark:text-gray-100 truncate pr-2",children:r}),c&&a.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300 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:o})]})})]}),document.body):null}},77758:(e,t,r)=>{r.d(t,{Ct:()=>c,zx:()=>s,Zb:()=>n,aY:()=>i,Ol:()=>l,ll:()=>o,u_:()=>d.u});var a=r(10326);function s({variant:e="primary",size:t="md",fullWidth:r=!1,loading:s=!1,disabled:n,className:l="",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],r?"w-full":"",n||s?"opacity-50 cursor-not-allowed":"",l].filter(Boolean).join(" ");return(0,a.jsxs)("button",{className:c,disabled:n||s,...i,children:[s&&(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 n({hover:e=!1,padding:t="md",className:r="",children:s,...n}){let l=["card",e?"card-hover":"",{none:"",sm:"p-3",md:"p-4",lg:"p-6"}[t],r].filter(Boolean).join(" ");return a.jsx("div",{className:l,...n,children:s})}function l({className:e="",children:t,...r}){return a.jsx("div",{className:`mb-3 ${e}`,...r,children:t})}function o({className:e="",children:t,...r}){return a.jsx("h3",{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 ${e}`,...r,children:t})}function i({className:e="",children:t,...r}){return a.jsx("div",{className:e,...r,children:t})}function c({variant:e="gray",dot:t=!1,className:r="",children:s,...n}){let l=["badge",{success:"badge-success",warning:"badge-warning",error:"badge-error",info:"badge-info",gray:"badge-gray"}[e],r].filter(Boolean).join(" ");return(0,a.jsxs)("span",{className:l,...n,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"}),s]})}r(17577);var d=r(28676)},11867:(e,t,r)=>{r.d(t,{n:()=>d});var a=r(10326),s=r(17577),n=r(77758),l=r(11865),o=r(73002),i=r(91515),c=r(51223);function d({worktreeId:e}){let[t,r]=(0,s.useState)([]),[d,u]=(0,s.useState)(null),[x,m]=(0,s.useState)(null),[g,h]=(0,s.useState)(!0),[p,f]=(0,s.useState)(null),[b,y]=(0,s.useState)(""),[v,w]=(0,s.useState)(0),[k,j]=(0,s.useState)("all"),[N,C]=(0,s.useState)(!1),{toasts:S,showToast:L,removeToast:M}=(0,l.pm)(),z=(0,s.useMemo)(()=>"all"===k?t:t.filter(e=>e.toLowerCase().includes(k)),[t,k]),E=async t=>{try{h(!0),f(null);let r=await o.Iv.getLogFile(e,t);m(r.content),u(t),y(""),w(0)}catch(e){f((0,o.zG)(e))}finally{h(!1)}},$=(0,s.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,s.useMemo)(()=>{let e;if(!b||!x)return[];let t=RegExp((0,c.hr)(b),"gi"),r=[];for(;null!==(e=t.exec(x));)r.push({index:e.index,length:e[0].length});return r},[b,x]),B=()=>{T.length>0&&w(e=>(e+1)%T.length)},A=()=>{T.length>0&&w(e=>(e-1+T.length)%T.length)},I=(0,s.useMemo)(()=>{if(!x||!b||0===T.length)return x;let e="",t=0;return T.forEach((r,a)=>{e+=(0,c.Xv)(x.substring(t,r.index));let s=x.substring(r.index,r.index+r.length),n=a===v;e+=`<mark class="${n?"bg-yellow-400 text-black":"bg-yellow-200 text-black"}" data-match-index="${a}">${(0,c.Xv)(s)}</mark>`,t=r.index+r.length}),e+=(0,c.Xv)(x.substring(t))},[x,b,T,v]);return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)(n.Zb,{padding:"md",children:[a.jsx(n.Ol,{children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx(n.ll,{children:"Log Files"}),a.jsx(n.Ct,{variant:"gray",children:z.length})]}),(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,a.jsxs)(n.zx,{variant:"all"===k?"primary":"ghost",size:"sm",onClick:()=>j("all"),children:["All (",t.length,")"]}),(0,a.jsxs)(n.zx,{variant:"claude"===k?"primary":"ghost",size:"sm",onClick:()=>j("claude"),children:["Claude (",t.filter(e=>e.toLowerCase().includes("claude")).length,")"]}),(0,a.jsxs)(n.zx,{variant:"codex"===k?"primary":"ghost",size:"sm",onClick:()=>j("codex"),children:["Codex (",t.filter(e=>e.toLowerCase().includes("codex")).length,")"]}),(0,a.jsxs)(n.zx,{variant:"gemini"===k?"primary":"ghost",size:"sm",onClick:()=>j("gemini"),children:["Gemini (",t.filter(e=>e.toLowerCase().includes("gemini")).length,")"]})]})]})}),(0,a.jsxs)(n.aY,{children:[g&&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"})}),p&&a.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded text-sm text-red-800",children:p}),!g&&0===z.length&&!p&&a.jsx("p",{className:"text-sm text-gray-600 text-center py-4",children:"all"===k?"No log files found":`No ${k} log files found`}),z.length>0&&a.jsx("div",{className:"space-y-2",children:z.map(e=>a.jsx("button",{onClick:()=>E(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)(n.Zb,{padding:"md",children:[a.jsx(n.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(n.ll,{className:"font-mono text-base",children:d}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx(n.zx,{variant:"ghost",size:"sm",onClick:$,disabled:!d||N,title:"Copy sanitized log to clipboard",children:N?"Exporting...":"Export"}),a.jsx(n.zx,{variant:"ghost",size:"sm",onClick:()=>{u(null),m(null),y(""),w(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:b,onChange:e=>y(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?A():B())},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(n.zx,{variant:"ghost",size:"sm",onClick:A,disabled:0===T.length,title:"Previous match (Shift+Enter)",children:"↑"}),a.jsx(n.zx,{variant:"ghost",size:"sm",onClick:B,disabled:0===T.length,title:"Next match (Enter)",children:"↓"})]})]})]})}),(0,a.jsxs)(n.aY,{children:[g&&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"})}),!g&&x&&a.jsx("div",{className:"bg-gray-900 text-gray-100 rounded p-4 overflow-x-auto max-h-[500px] scrollbar-thin",children:b&&T.length>0?a.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap",dangerouslySetInnerHTML:{__html:I||""}}):a.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap",children:x})}),!g&&b&&0===T.length&&x&&(0,a.jsxs)("div",{className:"text-center py-4 text-sm text-gray-500",children:['No matches found for "',b,'"']})]})]}),a.jsx(l.Ix,{toasts:S,onClose:M})]})}},10557:(e,t,r)=>{r.d(t,{R:()=>h});var a=r(10326),s=r(17577),n=r(73002);function l(e,t){if(!t.trim())return e;let r=t.toLowerCase();return e.map(e=>({...e,commands:e.commands.filter(e=>{let t=e.name.toLowerCase().includes(r),a=e.description.toLowerCase().includes(r);return t||a})})).filter(e=>e.commands.length>0)}function o(e){return"codex-prompt"===e.invocation?`/prompts:${e.name}`:`/${e.name}`}function i({groups:e,onSelect:t,highlightedIndex:r=-1,className:s=""}){let n=0;return 0===e.length?a.jsx("div",{className:`text-sm text-gray-500 p-4 text-center ${s}`,children:"No commands available"}):a.jsx("div",{className:`overflow-y-auto ${s}`,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 dark:text-gray-400 uppercase tracking-wider bg-gray-50 dark:bg-gray-800",children:e.label}),a.jsx("div",{children:e.commands.map(e=>{let s=n;n++;let l=s===r;return(0,a.jsxs)("button",{type:"button","data-command-item":!0,"data-highlighted":l,onClick:()=>t(e),className:`w-full px-3 py-2 text-left flex items-start gap-2 hover:bg-cyan-50 dark:hover:bg-cyan-900/30 transition-colors ${l?"bg-cyan-100 dark:bg-cyan-900/40":""}`,children:[a.jsx("span",{className:"text-cyan-600 dark:text-cyan-400 font-mono text-sm flex-shrink-0",children:o(e)}),e.cliTools?.length===1&&"codex"===e.cliTools[0]&&a.jsx("span",{className:"mt-0.5 rounded border border-cyan-200 bg-cyan-50 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-cyan-700 dark:border-cyan-800 dark:bg-cyan-950/40 dark:text-cyan-300",children:"Codex"}),a.jsx("span",{className:"text-gray-600 dark:text-gray-300 text-sm truncate",children:e.description})]},e.name)})})]},e.category))})}let c=(0,s.memo)(function({isOpen:e,groups:t,onSelect:r,onClose:n,isMobile:o=!1,position:c,onFreeInput:d}){let[u,x]=(0,s.useState)(""),[m,g]=(0,s.useState)(0),h=(0,s.useRef)(null),p=(0,s.useMemo)(()=>l(t,u),[t,u]),f=(0,s.useMemo)(()=>p.flatMap(e=>e.commands),[p]);(0,s.useEffect)(()=>{e&&(x(""),g(0),setTimeout(()=>{h.current?.focus()},50))},[e]);let b=(0,s.useCallback)(e=>{r(e),n()},[r,n]),y=(0,s.useCallback)(t=>{if(e)switch(t.key){case"Escape":t.preventDefault(),n();break;case"ArrowDown":t.preventDefault(),g(e=>Math.min(e+1,f.length-1));break;case"ArrowUp":t.preventDefault(),g(e=>Math.max(e-1,0));break;case"Enter":t.preventDefault(),f[m]&&b(f[m])}},[e,f,m,n,b]);return((0,s.useEffect)(()=>{if(e)return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},[e,y]),e)?o?(0,a.jsxs)(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 bg-black/50 z-40",onClick:n,"aria-hidden":"true"}),(0,a.jsxs)("div",{"data-testid":"slash-command-bottom-sheet",className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-gray-900 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 dark:border-gray-700",children:[a.jsx("h2",{className:"text-lg font-semibold dark:text-gray-100",children:"Commands"}),a.jsx("button",{type:"button",onClick:n,"aria-label":"Close",className:"p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-800",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 dark:border-gray-700",children:a.jsx("input",{ref:h,type:"text",value:u,onChange:e=>x(e.target.value),placeholder:"Search commands...",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100 rounded-lg focus:outline-none focus:ring-2 focus:ring-cyan-500"})}),d&&(0,a.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>d(u),className:"w-full px-4 py-3 text-left border-b border-gray-100 dark:border-gray-700 flex items-center gap-2 hover:bg-cyan-50 dark:hover:bg-cyan-900/30 transition-colors",children:[a.jsx("span",{className:"text-cyan-600 dark:text-cyan-400",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 dark:text-gray-400",children:"Enter custom command..."})]}),a.jsx(i,{groups:p,onSelect:b,highlightedIndex:m,className:"flex-1 overflow-y-auto pb-20"})]})]}):(0,a.jsxs)("div",{role:"listbox",className:"absolute bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 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 dark:border-gray-700",children:a.jsx("input",{ref:h,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 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100 rounded focus:outline-none focus:ring-1 focus:ring-cyan-500"})}),d&&(0,a.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>d(u),className:"w-full px-3 py-2 text-left border-b border-gray-100 dark:border-gray-700 flex items-center gap-2 hover:bg-cyan-50 dark:hover:bg-cyan-900/30 transition-colors text-sm",children:[a.jsx("span",{className:"text-cyan-600 dark:text-cyan-400",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 dark:text-gray-400",children:"Enter custom command..."})]}),a.jsx(i,{groups:p,onSelect:b,highlightedIndex:m,className:"flex-1 overflow-y-auto"}),(0,a.jsxs)("div",{className:"px-3 py-1.5 border-t border-gray-100 dark:border-gray-700 text-xs text-gray-400 dark:text-gray-500 flex gap-3",children:[(0,a.jsxs)("span",{children:[a.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 dark:bg-gray-700 rounded",children:"Enter"})," select"]}),(0,a.jsxs)("span",{children:[a.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 dark:bg-gray-700 rounded",children:"Esc"})," close"]})]})]}):null}),d=(0,s.memo)(function({worktreeId:e,cliToolId:t,disabled:r=!1,onInterrupt:n}){let[l,o]=(0,s.useState)(!1),i=(0,s.useRef)(0),c=(0,s.useCallback)(async()=>{let r=Date.now();if(!(r-i.current<1e3)){i.current=r,o(!0);try{let r=await fetch(`/api/worktrees/${e}/interrupt`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:t})});if(r.ok)n?.();else{let e=await r.json().catch(()=>({}));console.error("[InterruptButton] Failed to send interrupt:",e.error||r.statusText)}}catch(e){console.error("[InterruptButton] Error sending interrupt:",e)}finally{o(!1)}}},[e,t,n]);return a.jsx("button",{type:"button",onClick:c,disabled:r||l,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:l?(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(u,{})})});function u(){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 x=r(2982),m=r(33772);let g="commandmate:draft-message:",h=(0,s.memo)(function({worktreeId:e,onMessageSent:t,cliToolId:r,isSessionRunning:i=!1,pendingInsertText:u,onInsertConsumed:h}){let[p,f]=(0,s.useState)(""),[b,y]=(0,s.useState)(!1),[v,w]=(0,s.useState)(null),[k,j]=(0,s.useState)(!1),[N,C]=(0,s.useState)(!1),[S,L]=(0,s.useState)(!1),M=(0,s.useRef)(null),z=(0,s.useRef)(null),E=(0,s.useRef)(!1),$=(0,s.useRef)(null),T=(0,s.useRef)(null),B=(0,x.d)(),{groups:A}=function(e,t){let[r,a]=(0,s.useState)([]),[o,i]=(0,s.useState)(!0),[c,d]=(0,s.useState)(null),[u,x]=(0,s.useState)(""),[m,g]=(0,s.useState)(t||"claude"),h=(0,s.useCallback)(async()=>{try{i(!0),d(null);let r=e?`/api/worktrees/${e}/slash-commands`:"/api/slash-commands";t&&(r+=`?cliTool=${t}`);let s=await fetch(r);if(!s.ok)throw Error(`HTTP error ${s.status}`);let n=await s.json();a(n.groups),g(n.cliTool||t||"claude")}catch(e){d((0,n.zG)(e)),a([])}finally{i(!1)}},[e,t]),p=(0,s.useMemo)(()=>r.flatMap(e=>e.commands),[r]),f=(0,s.useMemo)(()=>l(r,u),[r,u]);return{groups:r,filteredGroups:f,allCommands:p,loading:o,error:c,filter:u,setFilter:x,refresh:(0,s.useCallback)(()=>{h()},[h]),cliTool:m}}(e,r),{attachedImage:I,fileInputRef:W,isUploading:R,error:D,acceptAttribute:H,openFileDialog:O,handleFileSelect:F,removeAttachment:Z,resetAfterSend:U}=function(e,t){let[r,a]=(0,s.useState)(null),[n,l]=(0,s.useState)(!1),[o,i]=(0,s.useState)(null),c=(0,s.useRef)(null),d=(0,s.useCallback)(()=>{c.current?.click()},[]),u=(0,s.useCallback)(async r=>{let s=r.target.files?.[0];if(!s)return;i(null);let n=function(e){let t=e.name.lastIndexOf(".");if(-1===t)return"Unsupported file format";let r=(0,m.Ab)(e.name.substring(t));if(!m.UE.includes(r))return`Unsupported file format: ${r}`;if(e.size>m.zq){let e=m.zq/1024/1024;return`File size exceeds ${e}MB limit`}return null}(s);if(n){i(n),c.current&&(c.current.value="");return}l(!0);try{let r=await t(e,s);a({file:s,path:r.path})}catch(e){i(e instanceof Error?e.message:"Upload failed")}finally{l(!1),c.current&&(c.current.value="")}},[e,t]),x=(0,s.useCallback)(()=>{a(null),i(null)},[]),g=(0,s.useCallback)(()=>{a(null)},[]);return{attachedImage:r,fileInputRef:c,isUploading:n,error:o,acceptAttribute:m.Ze,openFileDialog:d,handleFileSelect:u,removeAttachment:x,resetAfterSend:g}}(e,(0,s.useCallback)((e,t)=>n.Iv.uploadImageFile(e,t),[]));(0,s.useEffect)(()=>{try{let t=window.localStorage.getItem(g+e);t?f(t):f("")}catch{}return()=>{T.current&&clearTimeout(T.current)}},[e]),(0,s.useEffect)(()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{try{p?window.localStorage.setItem(g+e,p):window.localStorage.removeItem(g+e)}catch{}},500)},[p,e]),(0,s.useEffect)(()=>{let e=M.current;e&&(p?(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,160)}px`):e.style.height="24px")},[p]),(0,s.useEffect)(()=>{u&&(f(e=>""===e.trim()?u:e+"\n\n"+u),h?.())},[u,h]);let V=(0,s.useCallback)(async()=>{if(!k&&(p.trim()||I)&&!b)try{y(!0),w(null);let a=r||"claude",s={cliToolId:a};I&&(s.imagePath=I.path),await n.Iv.sendMessage(e,p.trim(),s),f(""),L(!1),U();try{window.localStorage.removeItem(g+e)}catch{}t?.(a)}catch(e){w((0,n.zG)(e))}finally{y(!1)}},[k,p,I,b,e,r,t,U]),G=(0,s.useCallback)(async e=>{e.preventDefault(),await V()},[V]),P=(0,s.useCallback)(()=>{j(!0),E.current=!1,z.current&&clearTimeout(z.current)},[]),_=(0,s.useCallback)(()=>{j(!1),E.current=!0,z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{E.current=!1},300)},[]),q=(0,s.useCallback)(e=>{f(`${o(e)} `),C(!1),M.current?.focus()},[]),X=(0,s.useCallback)(()=>{C(!1),L(!1),M.current?.focus()},[]),K=(0,s.useCallback)(e=>{C(!1),L(!0),f(e?`/${e}`:"/"),setTimeout(()=>{M.current?.focus()},50)},[]),Y=(0,s.useCallback)(e=>{let t=e.target.value;if(f(t),""===t){L(!1),C(!1);return}S||("/"===t||t.startsWith("/")&&!t.includes(" ")?C(!0):C(!1))},[S]),J=(0,s.useCallback)(e=>{let{keyCode:t}=e.nativeEvent;if(229!==t){if("Escape"===e.key&&N){e.preventDefault(),X();return}if(E.current&&"Enter"===e.key){E.current=!1;return}if("Enter"===e.key&&!k&&(!N||S)){if(B)return;e.shiftKey||(e.preventDefault(),V())}}},[N,S,k,B,V,X]);return(0,a.jsxs)("div",{ref:$,className:"space-y-2 relative",children:[(v||D)&&a.jsx("div",{className:"p-2 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 rounded text-sm text-red-800 dark:text-red-300",children:v||D}),I&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-cyan-50 dark:bg-cyan-900/20 border border-cyan-200 dark:border-cyan-800 rounded-lg text-sm","data-testid":"image-attachment-preview",children:[a.jsx("svg",{className:"h-4 w-4 flex-shrink-0 text-cyan-600 dark:text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),a.jsx("span",{className:"truncate text-cyan-800 dark:text-cyan-300",children:I.file.name}),a.jsx("button",{type:"button",onClick:Z,className:"flex-shrink-0 p-0.5 text-cyan-600 hover:text-red-500 dark:text-cyan-400 dark:hover:text-red-400 rounded transition-colors","aria-label":"Remove attachment","data-testid":"remove-attachment-button",children:a.jsx("svg",{className:"h-4 w-4",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("input",{ref:W,type:"file",accept:H,onChange:F,className:"hidden","data-testid":"image-file-input"}),(0,a.jsxs)("form",{onSubmit:G,className:`bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg px-4 py-2 focus-within:border-cyan-500 focus-within:ring-1 focus-within:ring-cyan-500 ${B?"flex flex-col gap-1":"flex items-center gap-2"}`,children:[B&&(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",onClick:()=>{S&&L(!1),C(!0)},className:"flex-shrink-0 p-2 text-gray-500 hover:text-cyan-600 hover:bg-cyan-50 dark:text-gray-400 dark:hover:text-cyan-400 dark:hover:bg-cyan-900/30 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("button",{type:"button",onClick:O,disabled:R||b,className:"flex-shrink-0 p-2 text-gray-500 hover:text-cyan-600 hover:bg-cyan-50 dark:text-gray-400 dark:hover:text-cyan-400 dark:hover:bg-cyan-900/30 rounded-full transition-colors disabled:text-gray-300 dark:disabled:text-gray-600 disabled:hover:bg-transparent","aria-label":"Attach image","data-testid":"attach-image-button",children:R?(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:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),a.jsx(d,{worktreeId:e,cliToolId:r||"claude",disabled:!i})]}),!B&&a.jsx("button",{type:"button",onClick:O,disabled:R||b,className:"flex-shrink-0 p-2 text-gray-500 hover:text-cyan-600 hover:bg-cyan-50 dark:text-gray-400 dark:hover:text-cyan-400 dark:hover:bg-cyan-900/30 rounded-full transition-colors disabled:text-gray-300 dark:disabled:text-gray-600 disabled:hover:bg-transparent","aria-label":"Attach image","data-testid":"attach-image-button",children:R?(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:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[a.jsx("textarea",{ref:M,value:p,onChange:Y,onKeyDown:J,onCompositionStart:P,onCompositionEnd:_,placeholder:B?"Type your message...":"Type your message... (/ for commands, Shift+Enter for line break)",disabled:b,rows:1,className:"flex-1 outline-none bg-transparent resize-none overflow-y-auto scrollbar-thin",style:{minHeight:"36px",maxHeight:"160px",paddingTop:"8px",paddingBottom:"8px",lineHeight:"20px"}}),!B&&a.jsx(d,{worktreeId:e,cliToolId:r||"claude",disabled:!i}),a.jsx("button",{type:"submit",disabled:!p.trim()&&!I||b,className:"flex-shrink-0 p-2 text-cyan-600 hover:bg-cyan-50 dark:text-cyan-400 dark:hover:bg-cyan-900/30 rounded-full transition-colors disabled:text-gray-300 dark:disabled:text-gray-600 disabled:hover:bg-transparent","aria-label":"Send message",children:b?(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(c,{isOpen:N,groups:A,onSelect:q,onClose:X,isMobile:B,onFreeInput:K})]})})},33772:(e,t,r)=>{r.d(t,{Ab:()=>n,UE:()=>l,Ze:()=>o,zq:()=>a});let a=5242880,s=[{extension:".png",mimeType:"image/png",magicBytes:[137,80,78,71]},{extension:".jpg",mimeType:"image/jpeg",magicBytes:[255,216,255]},{extension:".jpeg",mimeType:"image/jpeg",magicBytes:[255,216,255]},{extension:".gif",mimeType:"image/gif",magicBytes:[71,73,70,56]},{extension:".webp",mimeType:"image/webp",magicBytes:[82,73,70,70]},{extension:".svg",mimeType:"image/svg+xml"}];function n(e){return e?e.startsWith(".")?e.toLowerCase():"."+e.toLowerCase():""}let l=[".png",".jpg",".jpeg",".gif",".webp",".svg"].filter(e=>".svg"!==e),o=l.map(e=>(function(e){let t=n(e),r=s.find(e=>e.extension===t);return r?.mimeType||"application/octet-stream"})(e)).filter(e=>"application/octet-stream"!==e).join(",")},61421:(e,t,r)=>{r.d(t,{F4:()=>s,Ie:()=>l,xh:()=>n});let a={idle:"bg-gray-500",ready:"bg-green-500",spinner:"border-blue-500",waiting:"bg-yellow-500",error:"bg-red-500"},s={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"}},n={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"}},l={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,r)=>{r.d(t,{k:()=>a});let a={DROPDOWN:10,SIDEBAR:30,MODAL:50,MAXIMIZED_EDITOR:55,TOAST:60,CONTEXT_MENU:70}},2982:(e,t,r)=>{r.d(t,{G:()=>s,d:()=>n});var a=r(17577);let s=768;function n(e={}){let{breakpoint:t=s}=e,[r,n]=(0,a.useState)(!1);return r}},2491:(e,t,r)=>{r.d(t,{Ds:()=>l,Ho:()=>i,Ns:()=>c,_7:()=>n,tK:()=>a,ts:()=>o});let a=["claude","codex","gemini","vibe-local","opencode"],s={claude:"Claude",codex:"Codex",gemini:"Gemini","vibe-local":"Vibe Local",opencode:"OpenCode"};function n(e){return a.includes(e)}function l(e){return s[e]??e}function o(e,t="Assistant"){return e&&n(e)?l(e):t}let i=128,c=2097152},91515:(e,t,r)=>{r.d(t,{v:()=>s});let a=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07|\[[0-9;]*m/g;async function s(e){if(!e||0===e.trim().length)return;let t=e.replace(a,"");if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(t);return}catch{}let r=document.createElement("textarea");r.value=t,r.style.position="fixed",r.style.left="-9999px",r.style.top="-9999px",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();try{document.execCommand("copy")}finally{document.body.removeChild(r)}}},41593:(e,t,r)=>{r.d(t,{G:()=>l});var a=r(27808),s=r(18811);let n={en:s._,ja:a.ja};function l(e){return n[e]??s._}},77465:(e,t,r)=>{r.d(t,{Fq:()=>a}),r(2491);let a=["claude","codex","gemini"]},51223:(e,t,r)=>{function a(e,t){let r=null;return(...a)=>{r&&clearTimeout(r),r=setTimeout(()=>{e(...a),r=null},t)}}function s(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function n(e){let t=new Set;for(let r of e){t.add(r);let e=r.split("/"),a="";for(let r=0;r<e.length-1;r++)a=a?`${a}/${e[r]}`:e[r],t.add(a)}return t}function l(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;")}r.d(t,{Ds:()=>a,Ps:()=>n,Xv:()=>o,aS:()=>l,hr:()=>s})},18421:(e,t,r)=>{r.d(t,{He:()=>s,I_:()=>n});var a=r(77465);function s(e){return e?e.isWaitingForResponse?"waiting":e.isProcessing?"running":e.isRunning?"ready":"idle":"idle"}function n(e){let t=!!e.lastAssistantMessageAt&&(!e.lastViewedAt||new Date(e.lastAssistantMessageAt)>new Date(e.lastViewedAt)),r=e.selectedAgents??a.Fq,n={};for(let t of r)n[t]=s(e.sessionStatusByCli?.[t]);return{id:e.id,name:e.name,repositoryName:e.repositoryName,status:"idle",hasUnread:t,lastActivity:e.updatedAt,description:e.description,cliStatus:n}}},63601:(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var a=r(66621);let s=e=>[{type:"image/png",sizes:"180x180",url:(0,a.fillMetadataSegment)(".",e.params,"apple-icon.png")+"?31a89e65aa4ac65b"}]},71150:(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var a=r(66621);let s=e=>[{type:"image/png",sizes:"32x32",url:(0,a.fillMetadataSegment)(".",e.params,"icon.png")+"?32d9127ba30ee286"}]}};