@adhdev/daemon-standalone 0.6.45 → 0.6.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-standalone",
3
- "version": "0.6.45",
3
+ "version": "0.6.46",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -37,7 +37,7 @@ var Cs=Object.defineProperty;var Is=(t,s,a)=>s in t?Cs(t,s,{enumerable:!0,config
37
37
  }
38
38
  `})]})}function gs({activeConv:t,onModalButton:s}){const[a,r]=n.useState(null);if(n.useEffect(()=>{r(null)},[t.modalMessage,t.status]),t.status!=="waiting_approval"||!t.modalButtons)return null;const i=o=>{a||(r(o),s(o))},l=o=>o.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim();return e.jsxs("div",{className:"bg-gradient-to-br from-amber-600 to-amber-700 text-white py-2.5 px-4 shrink-0 z-[5]",children:[t.modalMessage&&e.jsx("div",{className:"text-[11px] opacity-85 mb-1.5 whitespace-nowrap overflow-hidden text-ellipsis max-w-full",children:t.modalMessage.replace(/[\n\r]+/g," ").slice(0,120)}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"font-black text-xs flex items-center gap-2",children:[e.jsx(xs,{size:14})," ",a?"PROCESSING...":"ACTION REQUIRED"]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:t.modalButtons.map((o,m)=>{const u=l(o).toLowerCase(),p=/^(run|approve|accept|yes|allow|always)/.test(u),c=/^(reject|deny|delete|remove|abort)/.test(u),d=a===o,v=a!==null;return e.jsx("button",{onClick:()=>i(o),disabled:v,className:`btn btn-sm border-none rounded-md text-xs px-3 py-1 ${p?"bg-white text-amber-700 font-extrabold":c?"bg-red-500/30 text-white font-semibold":"bg-white/15 text-white font-semibold"} ${v&&!d?"opacity-40":"opacity-100"} ${v?"cursor-not-allowed":"cursor-pointer"}`,children:d?"⏳ ...":l(o)},m)})})]})]})}const Le=new Map;function un({ideId:t,ideType:s,agentType:a,agentName:r,serverModel:i,serverMode:l,acpConfigOptions:o,acpModes:m}){var P;const{sendCommand:u}=Ge(),p=!!(o||m),c=`${t}:${a}`,d=Le.get(c),[v,j]=n.useState(!1),[x,M]=n.useState(!1),[T,f]=n.useState((d==null?void 0:d.models)||[]),[C,_]=n.useState((d==null?void 0:d.modes)||[]),U=g=>g?typeof g=="string"?g:typeof g=="object"?g.name||g.id||JSON.stringify(g):String(g):"",[R,I]=n.useState(U(i)),[A,S]=n.useState(U(l)),[y,B]=n.useState(!1),[W,z]=n.useState(!1),Z=n.useRef(0),b=g=>g.map(L=>typeof L=="string"?L:(L==null?void 0:L.name)||(L==null?void 0:L.id)||String(L));n.useEffect(()=>{if(o){const g=o.find(L=>L.category==="model");if(g){const L=b(g.options.map(K=>K.value));f(L),g.currentValue&&I(U(g.currentValue));const h=Le.get(c)||{models:[],modes:[]};Le.set(c,{...h,models:L})}}if(m&&m.length>0){const g=b(m.map(h=>h.id));_(g);const L=Le.get(c)||{models:[],modes:[]};Le.set(c,{...L,modes:g})}else if(o){const g=o.find(L=>L.category!=="model");if(g){const L=b(g.options.map(K=>K.value));_(L),g.currentValue&&S(U(g.currentValue));const h=Le.get(c)||{models:[],modes:[]};Le.set(c,{...h,modes:L})}}},[o,m,c]),n.useEffect(()=>{j(!1),M(!1),I(U(i)),S(U(l));const g=Le.get(c);g?(f(g.models),_(g.modes)):(f([]),_([]))},[t,a]),n.useEffect(()=>{i&&Date.now()>Z.current&&I(U(i))},[i]),n.useEffect(()=>{l&&Date.now()>Z.current&&S(U(l))},[l]);const G=n.useCallback(async(g,L={})=>{const h={...L},K=t.split(":");return K.length>=3&&(K[1]==="ide"||K[1]==="cli"||K[1]==="acp")&&(h._targetInstance=K.slice(2).join(":"),h._targetType=K[1]),await u(t,g,h)},[t]),ie=async()=>{var g,L;if(T.length>0){j(!v);return}if(p){j(!0);return}B(!0);try{const h=await G("list_extension_models",{agentType:a,ideType:s}),K=(h==null?void 0:h.models)||((g=h==null?void 0:h.result)==null?void 0:g.models)||[],Q=b(K);f(Q),h!=null&&h.current&&I(U(h.current)),(L=h==null?void 0:h.result)!=null&&L.current&&I(U(h.result.current));const xe=Le.get(c)||{models:[],modes:[]};Le.set(c,{...xe,models:Q}),j(!0)}catch{}finally{B(!1)}},V=async()=>{var g,L;if(C.length>0){M(!x);return}if(p){M(!0);return}z(!0);try{const h=await G("list_extension_modes",{agentType:a,ideType:s}),K=(h==null?void 0:h.modes)||((g=h==null?void 0:h.result)==null?void 0:g.modes)||[],Q=b(K);_(Q),h!=null&&h.current&&S(U(h.current)),(L=h==null?void 0:h.result)!=null&&L.current&&S(U(h.result.current));const xe=Le.get(c)||{models:[],modes:[]};Le.set(c,{...xe,modes:Q}),M(!0)}catch{}finally{z(!1)}},ee=async g=>{j(!1),I(g),Z.current=Date.now()+5e3;try{p?await G("change_model",{agentType:a,ideType:s,model:g}):await G("set_extension_model",{agentType:a,ideType:s,model:g})}catch{}},F=p&&!(m&&m.length>0)&&(o==null?void 0:o.some(g=>g.category!=="model")),oe=F?(P=o==null?void 0:o.find(g=>g.category!=="model"))==null?void 0:P.configId:void 0,te=async g=>{M(!1),S(g),Z.current=Date.now()+5e3;try{p&&F&&oe?await G("set_thought_level",{agentType:a,ideType:s,configId:oe,value:g}):p?await G("set_mode",{agentType:a,ideType:s,mode:g}):await G("set_extension_mode",{agentType:a,ideType:s,mode:g})}catch{}},ce={cline:"#22d3ee","roo-code":"#a78bfa",cursor:"#60a5fa",antigravity:"#f97316",windsurf:"#34d399"}[a]||"#94a3b8";return e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 flex-wrap text-[10px] border-t border-border-subtle bg-[var(--surface-primary)]",children:[e.jsx("span",{className:"text-[9px] font-bold tracking-wide uppercase opacity-70",style:{color:ce},children:r}),e.jsx("span",{className:"text-border-subtle text-[10px]",children:"│"}),e.jsxs("div",{className:"relative",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-xl text-[10px] font-medium cursor-pointer transition-all bg-[var(--surface-tertiary)] whitespace-nowrap max-w-40 overflow-hidden text-ellipsis",style:{borderColor:v?`${ce}55`:"transparent",border:"1px solid",color:R?"var(--text-primary)":"var(--text-muted)"},onClick:ie,children:[e.jsx("span",{className:"text-[9px] opacity-60",children:"🤖"}),y?"...":R||"Model",e.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),v&&T.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>j(!1)}),e.jsxs("div",{className:"absolute bottom-full left-0 z-[60] bg-[var(--surface-primary)] border border-border-subtle rounded-lg mb-1 max-h-[220px] overflow-y-auto min-w-40 shadow-[0_-4px_16px_rgba(0,0,0,0.3)]",children:[e.jsx("div",{className:"px-3 py-1.5 text-[9px] font-bold text-text-muted tracking-wider border-b border-border-subtle",children:"SELECT MODEL"}),T.map(g=>e.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:g===R?`${ce}18`:"transparent",color:g===R?ce:"var(--text-secondary)",fontWeight:g===R?600:400,borderLeft:g===R?`2px solid ${ce}`:"2px solid transparent"},onMouseEnter:L=>{L.currentTarget.style.background=`${ce}12`},onMouseLeave:L=>{L.currentTarget.style.background=g===R?`${ce}18`:"transparent"},onClick:()=>ee(g),children:g},g))]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-xl text-[10px] font-medium cursor-pointer transition-all bg-[var(--surface-tertiary)] whitespace-nowrap max-w-40 overflow-hidden text-ellipsis",style:{borderColor:x?`${ce}55`:"transparent",border:"1px solid",color:A?"var(--text-primary)":"var(--text-muted)"},onClick:V,children:[e.jsx("span",{className:"text-[9px] opacity-60",children:F?"🧠":"⚡"}),W?"...":A||(F?"Thinking":"Mode"),e.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),x&&C.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>M(!1)}),e.jsxs("div",{className:"absolute bottom-full left-0 z-[60] bg-[var(--surface-primary)] border border-border-subtle rounded-lg mb-1 max-h-[220px] overflow-y-auto min-w-40 shadow-[0_-4px_16px_rgba(0,0,0,0.3)]",children:[e.jsx("div",{className:"px-3 py-1.5 text-[9px] font-bold text-text-muted tracking-wider border-b border-border-subtle",children:F?"SELECT THINKING LEVEL":"SELECT MODE"}),C.map(g=>e.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:g===A?`${ce}18`:"transparent",color:g===A?ce:"var(--text-secondary)",fontWeight:g===A?600:400,borderLeft:g===A?`2px solid ${ce}`:"2px solid transparent"},onMouseEnter:L=>{L.currentTarget.style.background=`${ce}12`},onMouseLeave:L=>{L.currentTarget.style.background=g===A?`${ce}18`:"transparent"},onClick:()=>te(g),children:g},g))]})]})]})]})}const Ye=t=>(t.ideId||t.tabKey||t.id||"").includes(":cli:"),Oe=t=>(t.ideId||t.tabKey||t.id||"").includes(":acp:");function bs({activeConv:t,ides:s,agentInput:a,setAgentInput:r,handleSendChat:i,handleFocusAgent:l,isFocusingAgent:o,messageReceivedAt:m,actionLogs:u,userName:p}){const c=n.useRef(null),{sendCommand:d}=Ge(),v=n.useRef(new Map),j=n.useCallback(y=>(v.current.has(y)||v.current.set(y,{messages:[],offset:0,hasMore:!0,error:null}),v.current.get(y)),[]),x=n.useCallback((y,B)=>{const W=j(y);v.current.set(y,{...W,...B}),M(z=>z+1)},[j]),[,M]=n.useState(0),T=t.tabKey,f=j(T),C=f.messages,_=f.hasMore,U=f.error,[R,I]=n.useState(!1),A=n.useCallback(async()=>{var W,z;if(R)return;const y=t.tabKey,B=j(y);I(!0),x(y,{error:null});try{const Z=s.find(oe=>oe.id===t.ideId),b=(Z==null?void 0:Z.daemonId)||((W=t.ideId)==null?void 0:W.split(":")[0])||"";if(!b){x(y,{hasMore:!1});return}const G=t.ideType||t.agentType||"",ie=(t.ideId||"").split(":"),V=ie.length>=3?ie.slice(2).join(":"):void 0,ee=await d(b,"chat_history",{agentType:G,offset:B.offset,limit:30,instanceId:V}),F=(ee==null?void 0:ee.result)??ee;if(((z=F.messages)==null?void 0:z.length)>0){const oe=j(y);x(y,{messages:[...F.messages,...oe.messages],offset:oe.offset+F.messages.length,hasMore:!!F.hasMore})}else x(y,{hasMore:!!F.hasMore})}catch(Z){const b=(Z==null?void 0:Z.message)||"";b.includes("P2P not available")||b.includes("channel not open")||b.includes("P2P not connected")||b.includes("timeout")?x(y,{error:"Connection not ready — tap to retry"}):x(y,{hasMore:!1,error:"Failed to load history"})}finally{I(!1)}},[R,s,t,d,j,x]),S=(()=>{const y=t.messages.map((z,Z)=>{const b=`${t.ideId}-${z.id??`i-${Z}`}`;return{...z,receivedAt:z.receivedAt||m[b]||0}});if(C.length===0)return y;const B=new Set(y.map(z=>`${z.role}:${(z.content||"").slice(0,100)}`));return[...C.filter(z=>!B.has(`${z.role}:${(z.content||"").slice(0,100)}`)),...y]})();return e.jsxs(e.Fragment,{children:[e.jsx(cn,{messages:S,actionLogs:u.filter(y=>y.ideId===t.tabKey).sort((y,B)=>y.timestamp-B.timestamp),agentName:t.agentName||t.displayPrimary||"Agent",userName:p,isCliMode:Ye(t)||Oe(t),isWorking:t.status==="working",contextKey:t.tabKey,onLoadMore:A,isLoadingMore:R,hasMoreHistory:_,loadError:U??void 0,emptyState:t.messages.length===0?t.connectionState==="connecting"||t.connectionState==="new"?e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-4",children:[e.jsx("div",{className:"connecting-logo-float",children:e.jsx("div",{style:{width:64,height:64,borderRadius:"50%",background:"radial-gradient(circle, rgba(96,165,250,0.12), transparent 70%)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 0 40px rgba(96,165,250,0.08)"},children:e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",style:{width:40,height:40,borderRadius:"50%",opacity:.85}})})}),e.jsxs("div",{className:"flex flex-col items-center gap-1.5",children:[e.jsxs("div",{className:"text-[13px] text-blue-400 font-medium",children:["Connecting to your machine",e.jsx("span",{className:"connecting-dots"})]}),e.jsx("div",{className:"text-[11px] opacity-35",children:"Establishing P2P connection"})]})]}):t.status==="not_monitored"?e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[e.jsx("div",{className:"text-3xl opacity-60",children:e.jsx(ms,{size:28})}),e.jsx("div",{className:"text-[13px] opacity-50",children:"Agent not monitored"}),e.jsx("button",{onClick:l,disabled:o,className:"btn btn-primary",children:o?"⌛ Switching...":e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(At,{size:14})," Open ",t.displayPrimary," Panel"]})}),e.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Click to switch monitoring to this agent"})]}):t.status==="panel_hidden"?e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[e.jsx("div",{className:"text-3xl opacity-60",children:e.jsx(en,{size:28})}),e.jsx("div",{className:"text-[13px] opacity-50",children:"Panel is not visible in IDE"}),e.jsx("button",{onClick:l,disabled:o,className:"btn btn-primary",children:o?"⌛ Opening...":e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(At,{size:14})," Open ",t.displayPrimary," Panel"]})}),e.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Open the agent sidebar in your IDE to start viewing messages"})]}):t.status==="idle"&&!R?e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[e.jsx("div",{className:"text-2xl opacity-40 animate-pulse",children:"💬"}),e.jsx("div",{className:"text-[13px] opacity-40",children:"Loading chat..."})]}):void 0:void 0}),!Ye(t)&&(()=>{var B,W,z,Z;const y=s.find(b=>b.id===t.ideId);return e.jsx(un,{ideId:t.ideId,ideType:t.ideType,agentType:t.streamSource==="agent-stream"?t.agentType:((W=(B=y==null?void 0:y.agents)==null?void 0:B[0])==null?void 0:W.type)||t.ideType,agentName:t.streamSource==="agent-stream"?t.agentName:((Z=(z=y==null?void 0:y.agents)==null?void 0:z[0])==null?void 0:Z.name)||t.agentName,serverModel:(y==null?void 0:y.currentModel)||void 0,serverMode:(y==null?void 0:y.currentPlan)||void 0,acpConfigOptions:Oe(t)?y==null?void 0:y.acpConfigOptions:void 0,acpModes:Oe(t)?y==null?void 0:y.acpModes:void 0})})(),e.jsx("div",{className:"dashboard-input-area px-3 py-2.5 bg-[var(--surface-primary)] border-t border-border-subtle shrink-0",children:e.jsxs("div",{className:"flex gap-2.5 items-center",children:[e.jsx("div",{className:"flex-1 relative",children:e.jsx("input",{ref:c,type:"text",placeholder:`Send message to ${t.displayPrimary}...`,value:a,onChange:y=>r(y.target.value),onPaste:y=>{const B=y.clipboardData.getData("text");B&&r(W=>W+B),y.preventDefault()},onKeyDown:y=>{if(y.key==="Enter"){if(y.nativeEvent.isComposing){y.preventDefault();return}y.preventDefault(),i()}},onBlur:y=>{if(window.innerWidth<768){const B=y.relatedTarget;if((B==null?void 0:B.tagName)==="BUTTON")return;setTimeout(()=>{document.documentElement.scrollTop=0},300)}},className:"w-full h-10 rounded-[20px] px-4 bg-bg-secondary text-sm text-text-primary",style:{border:"1px solid var(--chat-input-border, var(--border-subtle))"}})}),e.jsx("button",{onClick:i,disabled:!a.trim(),className:`w-10 h-10 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${a.trim()?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:a.trim()?{background:"var(--chat-send-bg, var(--accent-primary))"}:void 0,children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:a.trim()?"text-white":"text-text-muted",children:e.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})]})}const kt=new Set,ys={emit(t,s){for(const a of kt)a(t,s)},on(t){return kt.add(t),()=>{kt.delete(t)}}};function xn({activeConv:t,ptyBuffers:s,terminalRef:a,agentInput:r,setAgentInput:i,handleSendChat:l,handleModalButton:o}){var j;const m=n.useRef(null),{sendCommand:u,sendData:p}=Ge(),c=(j=t.ideId)!=null&&j.includes(":cli:")?t.ideId.split(":cli:")[1]:"",d=t.tabKey,v=t.ideType||t.agentType||"";return n.useEffect(()=>{const x=s.current.get(d);if(x&&x.length>0){const M=setTimeout(()=>{var T;for(const f of x)(T=a.current)==null||T.write(f);requestAnimationFrame(()=>{var f;(f=a.current)==null||f.bumpResize()})},100);return()=>clearTimeout(M)}},[d]),n.useEffect(()=>{const x=ys.on((M,T)=>{var C;if(!T)return;(M===c||M===v)&&((C=a.current)==null||C.write(T))});return()=>{x()}},[c,v]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-[var(--surface-primary)] border-b border-border-subtle shrink-0",children:[e.jsx("div",{className:"flex gap-1",children:e.jsx("div",{className:"px-3 py-1 rounded-md text-[11px] font-semibold bg-accent text-white",children:"⬛ Terminal"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"text-[10px] text-text-muted",children:[t.agentName," — Terminal"]}),e.jsx("button",{onClick:()=>{if(!a.current||!t)return;const x=s.current.get(t.tabKey);if(x&&x.length>0)for(const M of x)a.current.write(M);requestAnimationFrame(()=>{requestAnimationFrame(()=>{var M;(M=a.current)==null||M.bumpResize()})})},title:"Refresh terminal (replay buffer + TUI redraw)",className:"px-2 py-0.5 rounded-[5px] text-[11px] bg-bg-secondary text-text-secondary border border-border-subtle cursor-pointer leading-none",children:"↺"}),e.jsx("button",{onClick:async()=>{var T;const x=(T=t.ideId)!=null&&T.includes(":cli:")?t.ideId.split(":cli:")[1]:t.ideType||t.agentType||"";if(!window.confirm(`Stop ${x}?
39
39
  This will terminate the CLI process.`))return;const M=t.ideId||t.daemonId||"";try{await u(M,"stop_cli",{cliType:x})}catch(f){console.error("Stop CLI failed:",f)}},title:"Stop CLI process",className:"px-2 py-0.5 rounded-[5px] text-[11px] bg-red-500/[0.08] text-red-400 border border-red-500/30 cursor-pointer leading-none font-semibold",children:"■ Stop"})]})]}),e.jsx(gs,{activeConv:t,onModalButton:o}),e.jsx("div",{className:"flex-1 min-h-0 p-2 bg-[#0f1117]",children:e.jsx(fs,{ref:a,onInput:x=>{var f;const M=t.ideId||t.daemonId||"",T=(f=t.ideId)!=null&&f.includes(":cli:")?t.ideId.split(":cli:")[1]:t.ideType||t.agentType||"";p!=null&&p(M,{type:"pty_input",cliType:T,data:x})||u(M,"pty_input",{cliType:T,data:x}).catch(console.error)},onResize:(x,M)=>{var C;const T=t.ideId||t.daemonId||"",f=(C=t.ideId)!=null&&C.includes(":cli:")?t.ideId.split(":cli:")[1]:t.ideType||t.agentType||"";p!=null&&p(T,{type:"pty_resize",cliType:f,cols:x,rows:M})||u(T,"pty_resize",{cliType:f,cols:x,rows:M,force:!0}).catch(()=>{})}},t.tabKey)}),e.jsx("div",{className:"px-3 py-2 bg-[var(--surface-primary)] border-t border-border-subtle shrink-0",children:e.jsxs("div",{className:"flex gap-2.5 items-center",children:[e.jsx("div",{className:"flex-1 relative",children:e.jsx("input",{ref:m,type:"text",placeholder:`Send message to ${t.displayPrimary}...`,value:r,onChange:x=>i(x.target.value),onPaste:x=>{const M=x.clipboardData.getData("text");M&&i(T=>T+M),x.preventDefault()},onKeyDown:x=>{if(x.key==="Enter"){if(x.nativeEvent.isComposing){x.preventDefault();return}x.preventDefault(),l()}},className:"w-full h-9 rounded-[18px] px-4 bg-bg-secondary text-[13px] text-text-primary",style:{border:"1px solid var(--chat-input-border, var(--border-subtle))"}})}),e.jsx("button",{onClick:l,disabled:!r.trim(),className:`w-9 h-9 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${r.trim()?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:r.trim()?{background:"var(--chat-send-bg, var(--accent-primary))"}:void 0,children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:r.trim()?"text-white":"text-text-muted",children:e.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})]})}function mn({wsStatus:t,showReconnected:s,loginUrl:a}){const r=t==="disconnected"||t==="reconnecting"||t==="offline"||t==="auth_failed",i=t==="auth_failed"?"red":t==="offline"?"orange":"violet",l={red:"linear-gradient(90deg, rgba(239,68,68,0.12), rgba(239,68,68,0.04))",orange:"linear-gradient(90deg, rgba(255,107,53,0.12), rgba(255,107,53,0.04))",violet:"linear-gradient(90deg, rgba(139,92,246,0.12), rgba(139,92,246,0.04))"},o={red:"1px solid rgba(239,68,68,0.2)",orange:"1px solid rgba(255,107,53,0.2)",violet:"1px solid rgba(139,92,246,0.2)"},m={red:"#ef4444",orange:"#ff6b35",violet:"#a78bfa"};return e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"py-2.5 px-5 text-[13px] font-semibold flex items-center gap-2.5 justify-center",style:{background:l[i],borderBottom:o[i],color:m[i]},children:[e.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-5 h-5",style:{opacity:t==="auth_failed"?.6:1,animation:t==="auth_failed"?void 0:"pulse 2s ease-in-out infinite",filter:t==="auth_failed"?"grayscale(1)":void 0}}),t==="offline"&&"Network offline — waiting for connection...",t==="disconnected"&&"Reconnecting to server...",t==="reconnecting"&&"Reconnecting to server...",t==="auth_failed"&&(a?e.jsxs(e.Fragment,{children:["Session expired."," ",e.jsx("a",{href:a,className:"text-inherit underline",children:"Log in again"})]}):"Connection failed — please restart the server.")]}),s&&t==="connected"&&e.jsxs("div",{className:"py-2 px-4 text-xs font-semibold flex items-center gap-2 justify-center bg-gradient-to-r from-green-500/[0.12] to-green-500/[0.04] text-green-400 border-b border-green-500/15 animate-[fadeIn_0.3s_ease]",children:[e.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-4 h-4"}),"Connected"]})]})}let pn=it;function vt(){return pn()}class hn{constructor(){$e(this,"listeners",new Map)}send(s){}isConnected(){return!1}on(s,a){return this.listeners.has(s)||this.listeners.set(s,new Set),this.listeners.get(s).add(a),()=>{var r;(r=this.listeners.get(s))==null||r.delete(a)}}emit(s,...a){var r;(r=this.listeners.get(s))==null||r.forEach(i=>i(...a))}}let fn=new hn;class gn{constructor(){$e(this,"ptyCallbacks",new Set)}sendPtyInput(s,a,r){return!1}sendPtyResize(s,a,r,i){return!1}async requestChatHistory(s,a,r,i,l){return{messages:[],hasMore:!1}}retryConnection(s){}getState(s){return"disconnected"}sendData(s,a){return!1}get(s){}onScreenshot(s,a){return()=>{}}onPtyOutput(s){return this.ptyCallbacks.add(s),()=>{this.ptyCallbacks.delete(s)}}emitPtyOutput(s,a){this.ptyCallbacks.forEach(r=>r(s,a))}}let Ae=new gn,bn=Ae;const St=t=>(t.ideId||t.tabKey||t.id||"").includes(":cli:"),Ct=t=>(t.ideId||t.tabKey||t.id||"").includes(":acp:");function yn({activeConv:t,agentCount:s,wsStatus:a,isConnected:r,onOpenHistory:i}){const l=dt(),o=vt(),m=o.p2pStates||{},u=o.ides||[],p=r?"#22c55e":a==="connected"?"#eab308":"#ef4444",c=r?"0 0 4px #22c55e80":a==="connected"?"0 0 4px #eab30880":"0 0 4px #ef444480",d=u.filter(f=>f.type==="adhdev-daemon"),v=Object.values(m),j=v.filter(f=>f==="connected").length,x=v.filter(f=>f==="connecting"||f==="new"||f==="checking").length,T=a!=="connected"||d.length===0?null:x>0&&j===0?"P2P connecting...":j>0&&s===0?"Waiting for IDE...":null;return e.jsxs("div",{className:"dashboard-header",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"leading-tight",children:[e.jsxs("h1",{className:"header-title m-0 flex items-center gap-1.5",children:[e.jsx(yt,{size:18}),e.jsx("span",{className:"header-title-desktop",children:"Dashboard"}),e.jsx("span",{className:"header-title-mobile",children:(t==null?void 0:t.displayPrimary)||"Dashboard"}),e.jsx("span",{className:"header-count-mobile text-[10px] font-semibold opacity-60 ml-2 tracking-wide",children:e.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full align-middle",style:{background:p,boxShadow:c}})})]}),e.jsxs("div",{className:"header-subtitle text-xs items-center gap-1",children:[s," agent",s!==1?"s":""," active",e.jsx("span",{title:r?"Connected":a==="connected"?"Partial":"Disconnected",className:"inline-block w-1.5 h-1.5 rounded-full shrink-0",style:{background:p,boxShadow:c}}),T&&e.jsxs("span",{className:"text-[10px] text-text-muted animate-pulse ml-1",children:["· ",T]})]})]})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[t&&!St(t)&&!Ct(t)&&e.jsxs("button",{onClick:()=>l(`/ide/${t.ideId}`),className:"btn btn-primary btn-sm",title:"IDE View",children:[e.jsx(ps,{size:14})," IDE"]}),t&&!St(t)&&!Ct(t)&&e.jsx("button",{onClick:i,className:"btn btn-secondary btn-sm",title:"Chat History",children:e.jsx(Js,{size:16})}),t&&!St(t)&&!Ct(t)&&e.jsx("button",{onClick:()=>l(`/ide/${t.ideId}?view=remote`),className:"btn btn-secondary btn-sm",title:"Remote Control",children:e.jsx(ut,{size:16})})]})]})}function De(t){return t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():"IDE"}function jn(t){if(t<60)return`${Math.round(t)}s`;const s=Math.floor(t/60);if(s<60)return`${s}m`;const a=Math.floor(s/60),r=s%60;if(a<24)return r>0?`${a}h ${r}m`:`${a}h`;const i=Math.floor(a/24),l=a%24;return`${i}d ${l}h`}function Yt(t){return t<1024*1024*1024?`${(t/(1024*1024)).toFixed(0)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function Gt(t){return(t.id||"").includes(":cli:")}function Xt(t){return(t.id||"").includes(":acp:")}function _t(t,s){return De(t)}function vn(t){if(!Array.isArray(t)||t.length<=1)return t;const s=new Map,a=["generating","streaming","active","connected","idle","panel_hidden"];for(const r of t){const i=(r.name||r.id||"").toLowerCase().replace(/\s+/g,"-"),l=s.get(i);if(!l){s.set(i,r);continue}const o=a.indexOf(l.status||"idle"),m=a.indexOf(r.status||"idle");m>=0&&(o<0||m<o)&&s.set(i,r)}return Array.from(s.values())}function wn({activeConv:t,ides:s,isCreatingChat:a,isRefreshingHistory:r,onClose:i,onNewChat:l,onSwitchSession:o,onRefreshHistory:m}){var d;const u=s.find(v=>v.id===t.ideId),p=(u==null?void 0:u.chats)||[],c=(d=u==null?void 0:u.activeChat)==null?void 0:d.id;return e.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center",children:[e.jsx("div",{onClick:i,className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),e.jsxs("div",{className:"card fade-in relative w-[90%] max-w-[500px] max-h-[80vh] flex flex-col p-0 overflow-hidden shadow-[0_20px_40px_rgba(0,0,0,0.4)] rounded-[20px]",children:[e.jsxs("div",{className:"px-6 py-5 border-b border-border-subtle flex justify-between items-center bg-[var(--surface-primary)]",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"m-0 text-lg font-extrabold",children:"Chat History"}),e.jsxs("div",{className:"text-xs text-text-muted mt-0.5",children:[t.displayPrimary," — ",De(t.ideType)]})]}),e.jsx("button",{onClick:i,className:"bg-transparent border-none text-xl text-text-muted cursor-pointer",children:"✕"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 bg-bg-primary",children:[e.jsx("button",{onClick:l,disabled:a,className:"w-full p-3.5 rounded-xl mb-3 bg-indigo-500/10 border border-dashed border-accent text-accent font-bold text-sm cursor-pointer",children:a?"⌛ Creating...":"+ Start New Chat Session"}),p.map(v=>e.jsxs("div",{onClick:()=>{o(t.ideId,v.id),i()},className:`p-4 rounded-xl mb-2 cursor-pointer border transition-all ${c===v.id?"bg-[var(--bg-glass-hover)] border-accent":"bg-[var(--surface-secondary)] border-border-subtle"}`,children:[e.jsx("div",{className:`font-bold text-sm mb-1 ${c===v.id?"text-[var(--accent-primary-light)]":"text-text-primary"}`,children:v.title||"Untitled Session"}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"text-[11px] text-text-muted font-mono",children:[v.id.substring(0,12),"..."]}),c===v.id&&e.jsx("span",{className:"text-[10px] bg-accent text-white px-2 py-0.5 rounded-[10px] font-extrabold",children:"ACTIVE"})]})]},v.id)),p.length===0&&e.jsxs("div",{className:"py-10 px-5 text-center text-text-muted",children:[e.jsx("div",{className:"text-3xl mb-3 opacity-60",children:e.jsx(an,{size:32})}),e.jsx("div",{className:"text-[13px]",children:"No recent chat sessions found."})]})]}),e.jsx("div",{className:"px-5 py-4 bg-[var(--surface-tertiary)] border-t border-border-subtle text-right",children:e.jsx("button",{onClick:m,disabled:r,className:"btn btn-secondary btn-sm rounded-[10px]",children:r?"⌛ Refreshing...":e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Qs,{size:13})," Refresh History"]})})})]})]})}const Vt={success:"rgba(16, 185, 129, 0.95)",warning:"rgba(245, 158, 11, 0.95)",info:"rgba(99, 102, 241, 0.95)"};function Nn({toasts:t,onDismiss:s,onClickToast:a}){return e.jsx("div",{className:"fixed right-4 z-[9999] flex flex-col gap-2 pointer-events-none",style:{top:"calc(env(safe-area-inset-top, 0px) + 16px)"},children:t.map(r=>e.jsxs("div",{className:"fade-in text-white px-5 py-3 rounded-xl text-[13px] font-semibold shadow-[0_8px_32px_rgba(0,0,0,0.3)] backdrop-blur-lg pointer-events-auto cursor-pointer animate-[toast-in_0.3s_ease-out] max-w-[360px]",style:{background:Vt[r.type]||Vt.info},onClick:()=>{var i;(i=r.actions)!=null&&i.length||(a&&a(r),s(r.id))},children:[e.jsx("div",{children:r.message}),r.actions&&r.actions.length>0&&e.jsx("div",{className:"flex gap-2 mt-2",children:r.actions.map((i,l)=>e.jsx("button",{className:`text-xs px-3 py-1 rounded-md font-bold transition-all cursor-pointer ${i.variant==="primary"?"bg-white text-amber-700 hover:bg-gray-100":i.variant==="danger"?"bg-red-500/30 text-white hover:bg-red-500/50":"bg-white/20 text-white hover:bg-white/30"}`,onClick:o=>{o.stopPropagation(),i.onClick(),s(r.id)},children:i.label},l))})]},r.id))})}const kn=t=>(t.id||"").includes(":cli:")||(t.id||"").includes(":acp:")||(t.id||"").includes(":ide:")?!0:t.daemonId!==t.id;function Sn(t){return t.workspace||""}function Cn(t,s,a,r){var l;const i={};if(a)for(const o of a){const m=o;if(m.type==="adhdev-daemon"||m.daemonMode){const u=m.machine||{},p=m.machineNickname,c=u.hostname||((l=m.system)==null?void 0:l.hostname)||"",d=p||(c&&c!=="Unknown"?c.replace(/\.local$/,""):null)||`Machine ${(m.id||"").substring(0,6)}`;i[m.id]=d}}return t.flatMap(o=>{var C,_,U,R,I;const m=[],u=o.daemonId&&i[o.daemonId]||void 0,p=o.daemonId||((C=o.id)==null?void 0:C.split(":")[0])||o.id,c=r?r[p]||"new":void 0,d=Sn(o),v=De(o.type),j=o.agentStreams,x=Array.isArray(j)?j.map(A=>({...A,activeModal:A.activeModal??void 0})):[],M=kn(o),T=o.activeChat||{title:""},f=T.title&&String(T.title).trim()?String(T.title).trim():"";if(M){const A=_t(o.type),S=(_=o.agents)==null?void 0:_[0],y=(U=o.activeChat)==null?void 0:U.activeModal,B=y&&Array.isArray(y.buttons)&&y.buttons.length>0,W=(R=o.activeChat)==null?void 0:R.status,z=W==="generating"||W==="loading"||W&&W.toLowerCase()==="thinking",b=B||W==="waiting_approval"?"waiting_approval":z?"working":(S==null?void 0:S.status)||"idle",G=o.activeChat||{title:"",messages:[]};let ie=G.title&&String(G.title).trim()?String(G.title).trim():"";const V=(I=o.activeChat)==null?void 0:I.id,ee=o.chats;if(V&&Array.isArray(ee)&&ee.length>0){const ce=ee.find(P=>P.id===V||P.id&&String(P.id)===String(V));ce!=null&&ce.title&&String(ce.title).trim()&&(ie=String(ce.title).trim())}const F=G.messages||[],oe=s[o.id]||[],te=new Map;F.filter(ce=>ce.role==="user").forEach(ce=>{te.set(ce.content,(te.get(ce.content)||0)+1)});const le=oe.filter(ce=>{const P=te.get(ce.content)||0;return P>0?(te.set(ce.content,P-1),!1):!0});m.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:A,agentType:Ye(o)||Oe(o)?o.type:(S==null?void 0:S.type)||"ide-native",status:b,title:ie,messages:[...F,...le],ideType:o.type,workspaceName:d,displayPrimary:ie||d||A,displaySecondary:v,cdpConnected:o.cdpConnected,modalButtons:B?y.buttons:void 0,modalMessage:B?y.message:void 0,streamSource:"native",tabKey:o.id,machineName:u,connectionState:c})}if(M&&(Ye(o)||Oe(o)))return m;for(const A of x){const S=A.activeModal&&Array.isArray(A.activeModal.buttons)&&A.activeModal.buttons.length>0,y=S?"waiting_approval":A.status==="streaming"?"working":A.status,B=`${o.id}:${A.agentType}`,W=A.messages||[],z=s[B]||[],Z=new Map;W.filter(G=>G.role==="user").forEach(G=>{Z.set(G.content,(Z.get(G.content)||0)+1)});const b=z.filter(G=>{const ie=Z.get(G.content)||0;return ie>0?(Z.set(G.content,ie-1),!1):!0});m.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:A.agentName,agentType:A.agentType,status:y,title:"",messages:[...W,...b],ideType:A.agentType,workspaceName:d,displayPrimary:f||d||A.agentName,displaySecondary:`${v}·${A.agentName}`,cdpConnected:o.cdpConnected,modalButtons:S?A.activeModal.buttons:void 0,modalMessage:S?A.activeModal.message:void 0,streamSource:"agent-stream",tabKey:B,machineName:u,connectionState:c})}return m.length===0&&m.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:_t(o.type),agentType:"ide-native",status:"idle",title:"",messages:[],ideType:o.type,workspaceName:d,displayPrimary:d||v,displaySecondary:v,cdpConnected:o.cdpConnected,streamSource:"native",tabKey:o.id,connectionState:c}),m})}function In(t,s){var m,u,p,c;const a=[],{daemonId:r,existingDaemon:i,timestamp:l}=s,o=l||t.timestamp||Date.now();a.push({...i||{},id:r,type:"adhdev-daemon",status:"online",daemonMode:!0,timestamp:o,...t.version&&{version:t.version},...t.machine&&{machine:t.machine,platform:t.machine.platform},...t.instanceId&&{instanceId:t.instanceId},...t.machineNickname!==void 0&&{machineNickname:t.machineNickname},...t.p2p&&{p2p:t.p2p},..."system"in t&&{system:t.system},..."hostname"in t&&{hostname:t.hostname},...t.workspaces&&{workspaces:t.workspaces},...t.defaultWorkspaceId!==void 0&&{defaultWorkspaceId:t.defaultWorkspaceId},...t.defaultWorkspacePath!==void 0&&{defaultWorkspacePath:t.defaultWorkspacePath},...t.workspaceActivity&&{workspaceActivity:t.workspaceActivity},...t.detectedIdes&&{detectedIdes:t.detectedIdes},..."availableProviders"in t&&{availableProviders:t.availableProviders},cdpConnected:t.managedIdes.some(d=>d.cdpConnected),managedIdeIds:t.managedIdes.map(d=>`${r}:ide:${d.instanceId}`),managedCliIds:t.managedClis.map(d=>d.id?`${r}:cli:${d.id}`:`${r}:cli:${d.cliType}`),managedAcpIds:t.managedAcps.map(d=>d.id?`${r}:acp:${d.id}`:`${r}:acp:${d.acpType}`)});for(const d of t.managedIdes)a.push({id:`${r}:ide:${d.instanceId}`,type:d.ideType,ideType:d.ideType,version:d.ideVersion,status:d.cdpConnected?"online":"detected",daemonId:r,instanceId:d.instanceId,workspace:d.workspace,terminals:d.terminals,agents:d.aiAgents,activeChat:d.activeChat,chats:d.chats,agentStreams:d.agentStreams,cdpConnected:d.cdpConnected,currentModel:d.currentModel,currentPlan:d.currentPlan,currentAutoApprove:d.currentAutoApprove,timestamp:o});for(const d of t.managedClis){const v=d.id?`${r}:cli:${d.id}`:`${r}:cli:${d.cliType}`;a.push({id:v,type:d.cliType,ideType:d.cliType,agentType:d.cliType,status:d.status||"running",daemonId:r,instanceId:d.id,cliName:d.cliName,mode:d.mode||"terminal",workspace:d.workspace,activeChat:d.activeChat,agentStreams:[{agentType:d.cliType,agentName:d.cliName,extensionId:"cli-agent",status:d.status==="generating"?"streaming":d.status==="waiting_approval"?"waiting_approval":"idle",messages:((m=d.activeChat)==null?void 0:m.messages)||[],inputContent:"",activeModal:(u=d.activeChat)==null?void 0:u.activeModal}],timestamp:o,_isCli:!0})}for(const d of t.managedAcps){const v=d.id?`${r}:acp:${d.id}`:`${r}:acp:${d.acpType}`;a.push({id:v,type:d.acpType,ideType:d.acpType,agentType:d.acpType,status:d.status||"running",daemonId:r,instanceId:d.id,cliName:d.acpName,mode:"chat",workspace:d.workspace,activeChat:d.activeChat,currentModel:d.currentModel,currentPlan:d.currentPlan,acpConfigOptions:d.acpConfigOptions,acpModes:d.acpModes,agentStreams:[{agentType:d.acpType,agentName:d.acpName,extensionId:"acp-agent",status:d.status==="generating"?"streaming":d.status==="waiting_approval"?"waiting_approval":"idle",messages:((p=d.activeChat)==null?void 0:p.messages)||[],inputContent:"",activeModal:(c=d.activeChat)==null?void 0:c.activeModal}],timestamp:o,_isAcp:!0})}return a}const js="adhdev_notification_prefs",qt={globalEnabled:!0,disconnectAlert:!0,browserNotifications:!0,completionAlert:!0,approvalAlert:!0};function Mn(){try{const t=localStorage.getItem(js);if(t){const s=JSON.parse(t);return{...qt,...s}}}catch{}return{...qt}}function Tn(t){try{localStorage.setItem(js,JSON.stringify(t))}catch{}}let He=Mn(),ht=[];function En(){ht.forEach(t=>t())}function $n(t){He={...He,...t},Tn(He),En()}function An(){const[,t]=n.useState(0);n.useEffect(()=>{const a=()=>t(r=>r+1);return ht.push(a),()=>{ht=ht.filter(r=>r!==a)}},[]);const s=n.useCallback(a=>{$n(a)},[]);return[{...He},s]}function rt(t){if(!He.globalEnabled)return!1;switch(t){case"disconnect":return He.disconnectAlert;case"completion":return He.completionAlert;case"approval":return He.approvalAlert;case"browser":return He.browserNotifications;default:return!0}}const _n={enabled:!0,onApproval:!0,onComplete:!0,onError:!0,throttleMs:5e3};async function Rn(){return"Notification"in window?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"}function vs(){return"Notification"in window&&Notification.permission==="granted"}let Ve=null;async function Pn(){if(Ve!==null)return Ve;try{if(!("serviceWorker"in navigator)||!("PushManager"in window))return Ve=!1,!1;const t=await navigator.serviceWorker.getRegistration();return t?(Ve=!!await t.pushManager.getSubscription(),Ve):(Ve=!1,!1)}catch{return Ve=!1,!1}}function Rt(t,s,a){if(vs())try{const r=new Notification(t,{body:s,icon:"/otter-logo.png",tag:a||`adhdev-${Date.now()}`,silent:!1});setTimeout(()=>r.close(),8e3),r.onclick=()=>{window.focus(),r.close()}}catch{}}function Ln(t,s={}){const a={..._n,...s},r=n.useRef(new Map),i=n.useRef(0),l=n.useRef(null);n.useEffect(()=>{Pn().then(m=>{l.current=m})},[]);const o=n.useCallback((m,u,p)=>{const c=Date.now();c-i.current<a.throttleMs||(i.current=c,Rt(m,u,p))},[a.throttleMs]);n.useEffect(()=>{var m;if(!(!a.enabled||!vs())&&rt("browser")&&l.current!==!0){if(document.hasFocus()){for(const u of t)r.current.set(u.id,u.status||"idle");return}for(const u of t){const p=r.current.get(u.id),c=u.status||"idle",d=u.name||u.id;if(a.onApproval&&rt("approval")&&c==="waiting_approval"&&p!=="waiting_approval"){const v=((m=u.activeModal)==null?void 0:m.message)||"Action requires your approval";o(`🔔 ${d} — Approval needed`,v.slice(0,120),`approval-${u.id}`)}a.onComplete&&rt("completion")&&p==="generating"&&c==="idle"&&o(`✅ ${d} — Task complete`,"Agent has finished working",`complete-${u.id}`),a.onError&&c==="error"&&p!=="error"&&o(`⚠️ ${d} — Error`,"Agent encountered an error",`error-${u.id}`),r.current.set(u.id,c)}}},[t,a.enabled,a.onApproval,a.onComplete,a.onError,o])}class Dn{constructor(){$e(this,"dedupMap",new Map);$e(this,"DEDUP_WINDOW_MS",5e3);$e(this,"DEDUP_MAX_SIZE",50);$e(this,"DEDUP_CLEANUP_AGE_MS",1e4);$e(this,"toastCallbacks",[]);$e(this,"systemMessageCallbacks",[]);$e(this,"clearSystemMessageCallbacks",[]);$e(this,"resolveActionFn",null);$e(this,"viewRequestRespondFn",null);$e(this,"ides",[])}onToast(s){return this.toastCallbacks.push(s),()=>{this.toastCallbacks=this.toastCallbacks.filter(a=>a!==s)}}onSystemMessage(s){return this.systemMessageCallbacks.push(s),()=>{this.systemMessageCallbacks=this.systemMessageCallbacks.filter(a=>a!==s)}}onClearSystemMessage(s){return this.clearSystemMessageCallbacks.push(s),()=>{this.clearSystemMessageCallbacks=this.clearSystemMessageCallbacks.filter(a=>a!==s)}}setResolveAction(s){this.resolveActionFn=s}setIdes(s){this.ides=s}setViewRequestRespond(s){this.viewRequestRespondFn=s}emitToast(s){for(const a of this.toastCallbacks)a(s)}emitSystemMessage(s,a){for(const r of this.systemMessageCallbacks)r(s,a)}emitClearSystemMessage(s,a){for(const r of this.clearSystemMessageCallbacks)r(s,a)}isDuplicate(s){const a=Date.now(),r=this.dedupMap.get(s)||0;if(a-r<this.DEDUP_WINDOW_MS)return!0;if(this.dedupMap.set(s,a),this.dedupMap.size>this.DEDUP_MAX_SIZE)for(const[i,l]of this.dedupMap)a-l>this.DEDUP_CLEANUP_AGE_MS&&this.dedupMap.delete(i);return!1}resolveRouteId(s,a){for(const r of this.ides)if(r.id.startsWith(s)&&(!a||a===r.type))return r.id;return s}handleRawEvent(s,a){var m,u,p;const r=`${s.ideType||s.providerType||""}:${s.event}:${s.chatTitle||""}`;if(this.isDuplicate(r))return;if(!s.ideId&&s.instanceId){for(const c of this.ides)if(c.id.endsWith(`:ide:${s.instanceId}`)||c.id.endsWith(`:cli:${s.instanceId}`)){s.ideId=c.id;break}}let i=De(s.ideType||"");if(s.ideType==="adhdev-daemon"){const c=this.ides.find(d=>d.type==="adhdev-daemon");c&&(i=c.machineNickname||((m=c.machine)==null?void 0:m.hostname)||i)}let l="",o="info";if(s.event==="agent:generating_completed"){const c=s.duration?` (${s.duration}s)`:"";l=`✅ ${i} agent task completed${c}`,o="success";try{new Audio("data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQQAAAB/f39/").play().catch(()=>{})}catch{}s.ideId&&this.emitSystemMessage(s.ideId,{role:"system",timestamp:Date.now(),content:`✅ Task completed${c}`,_localId:`sys_complete_${Date.now()}`})}else if(s.event==="agent:generating_started")s.ideId&&this.emitClearSystemMessage(s.ideId,"sys_complete_");else if(s.event==="agent:waiting_approval"){if(l=`⚡ ${i} approval needed`,o="warning",s.ideId){const c=s.modalMessage||"Approval requested",d=(u=s.modalButtons)!=null&&u.length?s.modalButtons.map(v=>`[${v}]`).join(" "):"[Approve] [Reject]";this.emitSystemMessage(s.ideId,{role:"system",timestamp:Date.now(),content:`⚡ Approval requested: ${c}
40
- ${d}`,_localId:`sys_approval_${Date.now()}`})}if(s.ideId&&((p=s.modalButtons)!=null&&p.length)&&this.resolveActionFn){const c=s.ideId,d=s.agentType||s.ideType||"",v=s.ideType||"",j=s.modalButtons,x=_=>_.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),M=this.resolveActionFn,T=j.map((_,U)=>{const R=x(_).toLowerCase(),I=/^(run|approve|accept|yes|allow|always)/.test(R),A=/^(reject|deny|delete|remove|abort|cancel|no)/.test(R);return{label:x(_),variant:I?"primary":A?"danger":"default",onClick:()=>{const S=this.resolveRouteId(c,d),y=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(R);M(S,"resolve_action",{action:y?"approve":"reject",button:_,buttonIndex:U,agentType:d,ideType:v})}}}),f=s.modalMessage?`⚡ ${i}: ${s.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:l,C=Date.now();this.emitToast({id:C,message:f,type:o,timestamp:C,ideId:c,actions:T,duration:15e3}),l=""}}else if(s.event==="monitor:long_generating"){const c=s.elapsedSec?` (${Math.round(s.elapsedSec/60)}m)`:"";l=`⚠️ ${i} agent is taking a long time${c}`,o="warning",rt("browser")&&!document.hasFocus()&&Rt(`⚠️ ${i} — Long Running`,`Agent has been generating for over ${c.replace(/[()]/g,"")}`,`long-${s.ideId||s.agentType}`)}else if(s.event==="team:view_request"){const c=s.requesterName||"A team member",d=s.requestId,v=s.orgId;if(l=`👁️ ${c} wants to view your session`,o="warning",d&&v&&this.viewRequestRespondFn){const j=this.viewRequestRespondFn,x=Date.now(),M=[{label:"Approve",variant:"primary",onClick:()=>{j(v,d,"approve").catch(T=>console.error("[EventManager] approve view request failed:",T))}},{label:"Decline",variant:"danger",onClick:()=>{j(v,d,"reject").catch(T=>console.error("[EventManager] reject view request failed:",T))}}];this.emitToast({id:x,message:l,type:o,timestamp:x,actions:M,duration:3e4}),l=""}rt("browser")&&!document.hasFocus()&&Rt("👁️ View Request",`${c} wants to view your session`,`view-request-${d}`)}else s.event==="team:view_request_approved"?(l="✅ View request approved",o="success"):s.event==="team:view_request_rejected"&&(l=`❌ ${s.targetName||"Team member"} declined your view request`,o="warning");if(l){const c=Date.now();this.emitToast({id:c,message:l,type:o,timestamp:c,ideId:s.ideId,duration:5e3})}}}const Qe=new Dn;function ct(...t){return Es($s(t))}function Bn({icon:t,title:s,subtitle:a,badge:r,actions:i,className:l}){return e.jsxs("div",{className:ct("dashboard-header",l),children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"header-title flex items-center gap-2",children:[e.jsx("span",{className:"flex items-center text-lg",children:t})," ",s,r&&e.jsxs("span",{className:"text-[10px] font-semibold px-1.5 py-px rounded-full bg-accent/10 text-accent-light",children:[r.count!==void 0?r.count:""," ",r.text]})]}),a&&e.jsx("div",{className:"header-subtitle mt-1 text-xs text-text-muted",children:a})]}),i&&e.jsx("div",{className:"flex gap-2",children:i})]})}function et({title:t,icon:s,description:a,accentColor:r,className:i,children:l}){return e.jsxs("div",{className:ct("bg-bg-card border border-border-subtle rounded-2xl p-5 backdrop-blur-xl transition-all","hover:border-border-default hover:shadow-glow",r&&"border-l-[3px]",i),style:r?{borderLeftColor:r}:void 0,children:[(t||a)&&e.jsxs("div",{className:"mb-4",children:[t&&e.jsxs("h3",{className:"text-base font-semibold text-text-primary",children:[s&&e.jsx("span",{className:"mr-1.5",children:s}),t]}),a&&e.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:a})]}),l]})}function Wn({icon:t,title:s,description:a,action:r,className:i}){return e.jsxs("div",{className:ct("py-16 px-5 text-center bg-bg-glass border-2 border-dashed border-border-subtle rounded-2xl",i),children:[e.jsx("div",{className:"text-5xl mb-4 opacity-50",children:t}),e.jsx("h3",{className:"text-lg font-bold text-text-secondary mb-2",children:s}),e.jsx("p",{className:"text-sm text-text-muted max-w-sm mx-auto mb-5 leading-relaxed",children:a}),r]})}const On={online:"bg-green-500/10 text-green-400 border-green-500/30",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/30",busy:"bg-orange-500/10 text-orange-400 border-orange-500/30",error:"bg-red-500/10 text-red-400 border-red-500/30",offline:"bg-gray-500/10 text-text-secondary border-gray-500/30"},Kn={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function Fn({status:t,label:s,className:a}){const r=s||t;return e.jsxs("span",{className:ct("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",On[t],a),children:[e.jsx("span",{className:ct("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",Kn[t])}),r]})}function Hn(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function Jt(){try{const t=localStorage.getItem("theme");if(t==="dark"||t==="light"||t==="system")return t}catch{}return"system"}function It(t){return t==="system"?Hn():t}function zn(){const[t,s]=n.useState(Jt),[a,r]=n.useState(()=>It(Jt()));n.useEffect(()=>{document.documentElement.setAttribute("data-theme",a)},[a]),n.useEffect(()=>{const o=window.matchMedia("(prefers-color-scheme: light)"),m=u=>{t==="system"&&r(u.matches?"light":"dark")};return o.addEventListener("change",m),()=>o.removeEventListener("change",m)},[t]);const i=n.useCallback(o=>{s(o),r(It(o));try{localStorage.setItem("theme",o)}catch{}},[]),l=n.useCallback(()=>{s(o=>{const m=o==="dark"?"light":o==="light"?"system":"dark";r(It(m));try{localStorage.setItem("theme",m)}catch{}return m})},[]);return{theme:a,preference:t,setPreference:i,cycleTheme:l,isDark:a==="dark"}}function tt({label:t,description:s,checked:a,disabled:r,onChange:i,extra:l}){return e.jsxs("label",{className:"flex justify-between items-center cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:t}),e.jsx("div",{className:"text-[11px] text-text-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[l,e.jsx("input",{type:"checkbox",checked:a,disabled:r,onChange:o=>i(o.target.checked),className:"w-5 h-5 accent-accent"})]})]})}function Un({onPrefChange:t}){const[s,a]=An(),r=(i,l)=>{a({[i]:l}),t==null||t(i,l)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(tt,{label:"🔔 Notifications",description:"Master toggle for all alerts",checked:s.globalEnabled,onChange:i=>r("globalEnabled",i)}),s.globalEnabled&&e.jsx("div",{className:"border-t border-border-subtle my-0.5"}),s.globalEnabled&&e.jsx(tt,{label:"🖥️ Browser Notifications",description:"Desktop alerts when tab is inactive",checked:s.browserNotifications,onChange:i=>r("browserNotifications",i)}),s.globalEnabled&&s.browserNotifications&&e.jsxs("div",{className:"ml-5 pl-3 border-l-2 border-border-subtle flex flex-col gap-2",children:[e.jsx(tt,{label:"✅ Completion Alerts",description:"Notify when agent finishes a task",checked:s.completionAlert,onChange:i=>r("completionAlert",i)}),e.jsx(tt,{label:"⚡ Approval Alerts",description:"Notify when agent needs approval",checked:s.approvalAlert,onChange:i=>r("approvalAlert",i)}),e.jsx(tt,{label:"📡 Connection Alerts",description:"Alert when a daemon disconnects",checked:s.disconnectAlert,onChange:i=>r("disconnectAlert",i)})]}),!s.globalEnabled&&e.jsx("p",{className:"text-[11px] text-text-muted italic",children:"All notifications are disabled. Enable the master toggle to configure individual alerts."})]})}function Yn({ides:t,emptyMessage:s,sendDaemonCommand:a,onDisconnect:r,onRevokeToken:i}){const l=t.filter(o=>o.type==="adhdev-daemon");return l.length===0?e.jsx(Wn,{icon:e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-12 h-12 object-contain mx-auto opacity-90"}),title:"No machines connected",description:s||"Run 'adhdev daemon' on your machine to connect."}):e.jsx("div",{className:"flex flex-col gap-2",children:l.map(o=>e.jsx(Vn,{ide:o,allIdes:t,sendDaemonCommand:a,onDisconnect:r,onRevokeToken:i},o.id))})}function Zt({title:t,message:s,confirmLabel:a,confirmColor:r,onConfirm:i,onCancel:l}){const o=r==="red"?"bg-red-500/20 text-red-400 border-red-500/30 hover:bg-red-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30 hover:bg-amber-500/30";return As.createPortal(e.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",style:{zIndex:9999},onClick:l,children:e.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl p-5 max-w-sm w-full mx-4 shadow-2xl",onClick:m=>m.stopPropagation(),children:[e.jsx("div",{className:"font-semibold text-sm mb-3",children:t}),e.jsx("div",{className:"text-xs text-text-muted leading-relaxed mb-5 whitespace-pre-line",children:s}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded-lg font-medium bg-bg-secondary text-text-secondary border border-border-subtle hover:bg-bg-glass transition-colors",children:"Cancel"}),e.jsx("button",{onClick:i,className:`text-xs px-3 py-1.5 rounded-lg font-medium border transition-colors ${o}`,children:a})]})]})}),document.body)}const Gn={vscode:{icon:"💠",name:"VS Code"},cursor:{icon:"⚡",name:"Cursor"},windsurf:{icon:"🏄",name:"Windsurf"},codex:{icon:"🤖",name:"Codex"},"claude-code":{icon:"🟠",name:"Claude Code"},aider:{icon:"🔧",name:"Aider"}};function Xn(t){const s=t.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase();return Gn[s]||{icon:"📝",name:t}}function Vn({ide:t,allIdes:s,sendDaemonCommand:a,onDisconnect:r,onRevokeToken:i}){var G,ie,V,ee;const[l,o]=n.useState("idle"),[m,u]=n.useState(""),[p,c]=n.useState(null),[d,v]=n.useState("idle"),[j,x]=n.useState(""),M=t,T=M.version||M.daemonVersion||null,f=((G=M.machine)==null?void 0:G.hostname)||((ie=M.system)==null?void 0:ie.hostname)||"",C=((V=M.machine)==null?void 0:V.platform)||((ee=M.system)==null?void 0:ee.platform)||"",_=M.machineNickname||(f==null?void 0:f.replace(/\.local$/,""))||"Machine",U=C==="win32"?"🪟":C==="darwin"?"🍎":"🐧",R=s.filter(F=>F.daemonId===t.id&&F.id.includes(":ide:")),I=s.filter(F=>F.daemonId===t.id&&F.id.includes(":cli:")),A=s.filter(F=>F.daemonId===t.id&&F.id.includes(":acp:")),S=M.p2p,y=async()=>{var F,oe,te;if(a){o("upgrading"),u("Installing latest version...");try{const le=await a(t.id,"daemon_upgrade",{});(F=le==null?void 0:le.result)!=null&&F.upgraded||(oe=le==null?void 0:le.result)!=null&&oe.success?(o("done"),u(`Upgraded to v${le.result.version||"latest"}. Daemon is restarting...`)):(o("error"),u(((te=le==null?void 0:le.result)==null?void 0:te.error)||"Upgrade failed"))}catch(le){o("error"),u((le==null?void 0:le.message)||"Connection lost during upgrade")}}},B=async()=>{if(c(null),!!r){v("loading");try{await r(t.id),v("done"),x("Machine disconnected.")}catch(F){v("error"),x((F==null?void 0:F.message)||"Failed to disconnect")}}},W=async()=>{if(c(null),!!i){v("loading");try{await i(t.id),v("done"),x('Token revoked. Machine must run "adhdev setup" to reconnect.')}catch(F){v("error"),x((F==null?void 0:F.message)||"Failed to revoke token")}}},z="0.6.45",Z=!T||T!==z,b=R.length+I.length+A.length;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-bg-glass rounded-lg px-4 py-3 border border-border-subtle",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xl",children:U}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:_}),e.jsxs("div",{className:"text-xs text-text-muted font-mono flex items-center gap-2",children:[e.jsxs("span",{children:[t.id.substring(0,12),"…"]}),T&&e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${Z?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",T,!Z&&" ✓"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a&&Z&&e.jsx("button",{onClick:y,disabled:l==="upgrading"||l==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${z}`,children:l==="upgrading"?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"animate-spin",children:"⟳"})," Upgrading..."]}):l==="done"?"✓ Updated":`↑ Update${` to v${z}`}`}),r&&e.jsx("button",{onClick:()=>c("disconnect"),disabled:d==="loading",className:"btn btn-sm btn-warning disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect this machine",children:"Disconnect"}),i&&e.jsx("button",{onClick:()=>c("revoke"),disabled:d==="loading",className:"btn btn-sm btn-danger disabled:opacity-50 disabled:cursor-not-allowed",title:"Remove machine (requires re-setup)",children:"Remove"}),e.jsx(Fn,{status:t.status==="online"?"online":"error"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2.5 pt-2.5 border-t border-border-subtle/50",children:[S&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${S.state==="connected"?"bg-green-400":S.state==="connecting"||S.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),e.jsxs("span",{className:"text-text-muted",children:["P2P ",S.state==="connected"?"connected":S.state==="connecting"||S.state==="new"?"connecting...":S.state||"off"]}),S.peers!==void 0&&S.peers>0&&e.jsxs("span",{className:"text-text-muted/60",children:["(",S.peers," peer",S.peers!==1?"s":"",")"]})]}),S&&b>0&&e.jsx("span",{className:"text-border-subtle",children:"·"}),b>0?e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[R.map(F=>{const oe=Xn(F.type),te=F.cdpConnected;return e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:oe.icon}),e.jsx("span",{children:oe.name}),te!==void 0&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${te?"bg-green-400":"bg-amber-400 animate-pulse"}`,title:te?"CDP connected":"CDP connecting..."})]},F.id)}),I.map(F=>e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:"⌨️"}),e.jsx("span",{children:F.cliName||"CLI"})]},F.id)),A.map(F=>e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:"🔗"}),e.jsx("span",{children:F.cliName||"ACP"})]},F.id))]}):e.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(m||j)&&e.jsx("div",{className:`text-xs mt-2 px-1 ${l==="error"||d==="error"?"text-red-400":l==="done"||d==="done"?"text-green-400":"text-text-muted"}`,children:j||m})]}),p==="disconnect"&&e.jsx(Zt,{title:"🔌 Disconnect Machine",message:`Disconnect "${_}" from ADHDev?
40
+ ${d}`,_localId:`sys_approval_${Date.now()}`})}if(s.ideId&&((p=s.modalButtons)!=null&&p.length)&&this.resolveActionFn){const c=s.ideId,d=s.agentType||s.ideType||"",v=s.ideType||"",j=s.modalButtons,x=_=>_.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),M=this.resolveActionFn,T=j.map((_,U)=>{const R=x(_).toLowerCase(),I=/^(run|approve|accept|yes|allow|always)/.test(R),A=/^(reject|deny|delete|remove|abort|cancel|no)/.test(R);return{label:x(_),variant:I?"primary":A?"danger":"default",onClick:()=>{const S=this.resolveRouteId(c,d),y=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(R);M(S,"resolve_action",{action:y?"approve":"reject",button:_,buttonIndex:U,agentType:d,ideType:v})}}}),f=s.modalMessage?`⚡ ${i}: ${s.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:l,C=Date.now();this.emitToast({id:C,message:f,type:o,timestamp:C,ideId:c,actions:T,duration:15e3}),l=""}}else if(s.event==="monitor:long_generating"){const c=s.elapsedSec?` (${Math.round(s.elapsedSec/60)}m)`:"";l=`⚠️ ${i} agent is taking a long time${c}`,o="warning",rt("browser")&&!document.hasFocus()&&Rt(`⚠️ ${i} — Long Running`,`Agent has been generating for over ${c.replace(/[()]/g,"")}`,`long-${s.ideId||s.agentType}`)}else if(s.event==="team:view_request"){const c=s.requesterName||"A team member",d=s.requestId,v=s.orgId;if(l=`👁️ ${c} wants to view your session`,o="warning",d&&v&&this.viewRequestRespondFn){const j=this.viewRequestRespondFn,x=Date.now(),M=[{label:"Approve",variant:"primary",onClick:()=>{j(v,d,"approve").catch(T=>console.error("[EventManager] approve view request failed:",T))}},{label:"Decline",variant:"danger",onClick:()=>{j(v,d,"reject").catch(T=>console.error("[EventManager] reject view request failed:",T))}}];this.emitToast({id:x,message:l,type:o,timestamp:x,actions:M,duration:3e4}),l=""}rt("browser")&&!document.hasFocus()&&Rt("👁️ View Request",`${c} wants to view your session`,`view-request-${d}`)}else s.event==="team:view_request_approved"?(l="✅ View request approved",o="success"):s.event==="team:view_request_rejected"&&(l=`❌ ${s.targetName||"Team member"} declined your view request`,o="warning");if(l){const c=Date.now();this.emitToast({id:c,message:l,type:o,timestamp:c,ideId:s.ideId,duration:5e3})}}}const Qe=new Dn;function ct(...t){return Es($s(t))}function Bn({icon:t,title:s,subtitle:a,badge:r,actions:i,className:l}){return e.jsxs("div",{className:ct("dashboard-header",l),children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"header-title flex items-center gap-2",children:[e.jsx("span",{className:"flex items-center text-lg",children:t})," ",s,r&&e.jsxs("span",{className:"text-[10px] font-semibold px-1.5 py-px rounded-full bg-accent/10 text-accent-light",children:[r.count!==void 0?r.count:""," ",r.text]})]}),a&&e.jsx("div",{className:"header-subtitle mt-1 text-xs text-text-muted",children:a})]}),i&&e.jsx("div",{className:"flex gap-2",children:i})]})}function et({title:t,icon:s,description:a,accentColor:r,className:i,children:l}){return e.jsxs("div",{className:ct("bg-bg-card border border-border-subtle rounded-2xl p-5 backdrop-blur-xl transition-all","hover:border-border-default hover:shadow-glow",r&&"border-l-[3px]",i),style:r?{borderLeftColor:r}:void 0,children:[(t||a)&&e.jsxs("div",{className:"mb-4",children:[t&&e.jsxs("h3",{className:"text-base font-semibold text-text-primary",children:[s&&e.jsx("span",{className:"mr-1.5",children:s}),t]}),a&&e.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:a})]}),l]})}function Wn({icon:t,title:s,description:a,action:r,className:i}){return e.jsxs("div",{className:ct("py-16 px-5 text-center bg-bg-glass border-2 border-dashed border-border-subtle rounded-2xl",i),children:[e.jsx("div",{className:"text-5xl mb-4 opacity-50",children:t}),e.jsx("h3",{className:"text-lg font-bold text-text-secondary mb-2",children:s}),e.jsx("p",{className:"text-sm text-text-muted max-w-sm mx-auto mb-5 leading-relaxed",children:a}),r]})}const On={online:"bg-green-500/10 text-green-400 border-green-500/30",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/30",busy:"bg-orange-500/10 text-orange-400 border-orange-500/30",error:"bg-red-500/10 text-red-400 border-red-500/30",offline:"bg-gray-500/10 text-text-secondary border-gray-500/30"},Kn={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function Fn({status:t,label:s,className:a}){const r=s||t;return e.jsxs("span",{className:ct("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",On[t],a),children:[e.jsx("span",{className:ct("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",Kn[t])}),r]})}function Hn(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function Jt(){try{const t=localStorage.getItem("theme");if(t==="dark"||t==="light"||t==="system")return t}catch{}return"system"}function It(t){return t==="system"?Hn():t}function zn(){const[t,s]=n.useState(Jt),[a,r]=n.useState(()=>It(Jt()));n.useEffect(()=>{document.documentElement.setAttribute("data-theme",a)},[a]),n.useEffect(()=>{const o=window.matchMedia("(prefers-color-scheme: light)"),m=u=>{t==="system"&&r(u.matches?"light":"dark")};return o.addEventListener("change",m),()=>o.removeEventListener("change",m)},[t]);const i=n.useCallback(o=>{s(o),r(It(o));try{localStorage.setItem("theme",o)}catch{}},[]),l=n.useCallback(()=>{s(o=>{const m=o==="dark"?"light":o==="light"?"system":"dark";r(It(m));try{localStorage.setItem("theme",m)}catch{}return m})},[]);return{theme:a,preference:t,setPreference:i,cycleTheme:l,isDark:a==="dark"}}function tt({label:t,description:s,checked:a,disabled:r,onChange:i,extra:l}){return e.jsxs("label",{className:"flex justify-between items-center cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:t}),e.jsx("div",{className:"text-[11px] text-text-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[l,e.jsx("input",{type:"checkbox",checked:a,disabled:r,onChange:o=>i(o.target.checked),className:"w-5 h-5 accent-accent"})]})]})}function Un({onPrefChange:t}){const[s,a]=An(),r=(i,l)=>{a({[i]:l}),t==null||t(i,l)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(tt,{label:"🔔 Notifications",description:"Master toggle for all alerts",checked:s.globalEnabled,onChange:i=>r("globalEnabled",i)}),s.globalEnabled&&e.jsx("div",{className:"border-t border-border-subtle my-0.5"}),s.globalEnabled&&e.jsx(tt,{label:"🖥️ Browser Notifications",description:"Desktop alerts when tab is inactive",checked:s.browserNotifications,onChange:i=>r("browserNotifications",i)}),s.globalEnabled&&s.browserNotifications&&e.jsxs("div",{className:"ml-5 pl-3 border-l-2 border-border-subtle flex flex-col gap-2",children:[e.jsx(tt,{label:"✅ Completion Alerts",description:"Notify when agent finishes a task",checked:s.completionAlert,onChange:i=>r("completionAlert",i)}),e.jsx(tt,{label:"⚡ Approval Alerts",description:"Notify when agent needs approval",checked:s.approvalAlert,onChange:i=>r("approvalAlert",i)}),e.jsx(tt,{label:"📡 Connection Alerts",description:"Alert when a daemon disconnects",checked:s.disconnectAlert,onChange:i=>r("disconnectAlert",i)})]}),!s.globalEnabled&&e.jsx("p",{className:"text-[11px] text-text-muted italic",children:"All notifications are disabled. Enable the master toggle to configure individual alerts."})]})}function Yn({ides:t,emptyMessage:s,sendDaemonCommand:a,onDisconnect:r,onRevokeToken:i}){const l=t.filter(o=>o.type==="adhdev-daemon");return l.length===0?e.jsx(Wn,{icon:e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-12 h-12 object-contain mx-auto opacity-90"}),title:"No machines connected",description:s||"Run 'adhdev daemon' on your machine to connect."}):e.jsx("div",{className:"flex flex-col gap-2",children:l.map(o=>e.jsx(Vn,{ide:o,allIdes:t,sendDaemonCommand:a,onDisconnect:r,onRevokeToken:i},o.id))})}function Zt({title:t,message:s,confirmLabel:a,confirmColor:r,onConfirm:i,onCancel:l}){const o=r==="red"?"bg-red-500/20 text-red-400 border-red-500/30 hover:bg-red-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30 hover:bg-amber-500/30";return As.createPortal(e.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",style:{zIndex:9999},onClick:l,children:e.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl p-5 max-w-sm w-full mx-4 shadow-2xl",onClick:m=>m.stopPropagation(),children:[e.jsx("div",{className:"font-semibold text-sm mb-3",children:t}),e.jsx("div",{className:"text-xs text-text-muted leading-relaxed mb-5 whitespace-pre-line",children:s}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded-lg font-medium bg-bg-secondary text-text-secondary border border-border-subtle hover:bg-bg-glass transition-colors",children:"Cancel"}),e.jsx("button",{onClick:i,className:`text-xs px-3 py-1.5 rounded-lg font-medium border transition-colors ${o}`,children:a})]})]})}),document.body)}const Gn={vscode:{icon:"💠",name:"VS Code"},cursor:{icon:"⚡",name:"Cursor"},windsurf:{icon:"🏄",name:"Windsurf"},codex:{icon:"🤖",name:"Codex"},"claude-code":{icon:"🟠",name:"Claude Code"},aider:{icon:"🔧",name:"Aider"}};function Xn(t){const s=t.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase();return Gn[s]||{icon:"📝",name:t}}function Vn({ide:t,allIdes:s,sendDaemonCommand:a,onDisconnect:r,onRevokeToken:i}){var G,ie,V,ee;const[l,o]=n.useState("idle"),[m,u]=n.useState(""),[p,c]=n.useState(null),[d,v]=n.useState("idle"),[j,x]=n.useState(""),M=t,T=M.version||M.daemonVersion||null,f=((G=M.machine)==null?void 0:G.hostname)||((ie=M.system)==null?void 0:ie.hostname)||"",C=((V=M.machine)==null?void 0:V.platform)||((ee=M.system)==null?void 0:ee.platform)||"",_=M.machineNickname||(f==null?void 0:f.replace(/\.local$/,""))||"Machine",U=C==="win32"?"🪟":C==="darwin"?"🍎":"🐧",R=s.filter(F=>F.daemonId===t.id&&F.id.includes(":ide:")),I=s.filter(F=>F.daemonId===t.id&&F.id.includes(":cli:")),A=s.filter(F=>F.daemonId===t.id&&F.id.includes(":acp:")),S=M.p2p,y=async()=>{var F,oe,te;if(a){o("upgrading"),u("Installing latest version...");try{const le=await a(t.id,"daemon_upgrade",{});(F=le==null?void 0:le.result)!=null&&F.upgraded||(oe=le==null?void 0:le.result)!=null&&oe.success?(o("done"),u(`Upgraded to v${le.result.version||"latest"}. Daemon is restarting...`)):(o("error"),u(((te=le==null?void 0:le.result)==null?void 0:te.error)||"Upgrade failed"))}catch(le){o("error"),u((le==null?void 0:le.message)||"Connection lost during upgrade")}}},B=async()=>{if(c(null),!!r){v("loading");try{await r(t.id),v("done"),x("Machine disconnected.")}catch(F){v("error"),x((F==null?void 0:F.message)||"Failed to disconnect")}}},W=async()=>{if(c(null),!!i){v("loading");try{await i(t.id),v("done"),x('Token revoked. Machine must run "adhdev setup" to reconnect.')}catch(F){v("error"),x((F==null?void 0:F.message)||"Failed to revoke token")}}},z="0.6.46",Z=!T||T!==z,b=R.length+I.length+A.length;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-bg-glass rounded-lg px-4 py-3 border border-border-subtle",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xl",children:U}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:_}),e.jsxs("div",{className:"text-xs text-text-muted font-mono flex items-center gap-2",children:[e.jsxs("span",{children:[t.id.substring(0,12),"…"]}),T&&e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${Z?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",T,!Z&&" ✓"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a&&Z&&e.jsx("button",{onClick:y,disabled:l==="upgrading"||l==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${z}`,children:l==="upgrading"?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"animate-spin",children:"⟳"})," Upgrading..."]}):l==="done"?"✓ Updated":`↑ Update${` to v${z}`}`}),r&&e.jsx("button",{onClick:()=>c("disconnect"),disabled:d==="loading",className:"btn btn-sm btn-warning disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect this machine",children:"Disconnect"}),i&&e.jsx("button",{onClick:()=>c("revoke"),disabled:d==="loading",className:"btn btn-sm btn-danger disabled:opacity-50 disabled:cursor-not-allowed",title:"Remove machine (requires re-setup)",children:"Remove"}),e.jsx(Fn,{status:t.status==="online"?"online":"error"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2.5 pt-2.5 border-t border-border-subtle/50",children:[S&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${S.state==="connected"?"bg-green-400":S.state==="connecting"||S.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),e.jsxs("span",{className:"text-text-muted",children:["P2P ",S.state==="connected"?"connected":S.state==="connecting"||S.state==="new"?"connecting...":S.state||"off"]}),S.peers!==void 0&&S.peers>0&&e.jsxs("span",{className:"text-text-muted/60",children:["(",S.peers," peer",S.peers!==1?"s":"",")"]})]}),S&&b>0&&e.jsx("span",{className:"text-border-subtle",children:"·"}),b>0?e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[R.map(F=>{const oe=Xn(F.type),te=F.cdpConnected;return e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:oe.icon}),e.jsx("span",{children:oe.name}),te!==void 0&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${te?"bg-green-400":"bg-amber-400 animate-pulse"}`,title:te?"CDP connected":"CDP connecting..."})]},F.id)}),I.map(F=>e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:"⌨️"}),e.jsx("span",{children:F.cliName||"CLI"})]},F.id)),A.map(F=>e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:"🔗"}),e.jsx("span",{children:F.cliName||"ACP"})]},F.id))]}):e.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(m||j)&&e.jsx("div",{className:`text-xs mt-2 px-1 ${l==="error"||d==="error"?"text-red-400":l==="done"||d==="done"?"text-green-400":"text-text-muted"}`,children:j||m})]}),p==="disconnect"&&e.jsx(Zt,{title:"🔌 Disconnect Machine",message:`Disconnect "${_}" from ADHDev?
41
41
 
42
42
  This will close the server connection. The daemon process will continue running on the machine and will automatically reconnect.
43
43
 
@@ -68,4 +68,4 @@ Use this if you want to permanently remove a machine.`,confirmLabel:"Remove Mach
68
68
  This will terminate the process.`))try{const h=await s(t,"stop_cli",{cliType:P,dir:g,_targetInstance:L});h!=null&&h.success?y("info",`${P} stopped`):y("error",`Stop failed: ${(h==null?void 0:h.error)||"Unknown error"}`)}catch(h){y("error",`Stop failed: ${h.message}`)}},[t,y,s]),b=n.useCallback(async P=>{try{await s(P.daemonId,"restart_ide",{ideType:P.type}),y("info",`${De(P.type)} restart initiated`)}catch(g){y("error",`Restart failed: ${g.message}`)}},[y,s]),G=n.useCallback(async P=>{if(window.confirm(`Stop ${De(P.type)}?
69
69
  This will disconnect CDP and optionally kill the process.`))try{const g=await s(P.daemonId,"stop_ide",{ideType:P.type,killProcess:!0});g!=null&&g.success?y("info",`${De(P.type)} stopped`):y("error",`Stop failed: ${(g==null?void 0:g.error)||"Unknown error"}`)}catch(g){y("error",`Stop failed: ${g.message}`)}},[y,s]),ie=n.useCallback(async()=>{if(t)try{const P=await s(t,"detect_ides",{});y("info",`Found ${((P==null?void 0:P.result)||[]).length} IDE(s)`)}catch(P){y("error",`Detection failed: ${P.message}`)}},[t,y,s]),V=n.useCallback(async()=>{if(t){u(!0);try{const P=await s(t,"get_recent_workspaces",{});P!=null&&P.success&&Array.isArray(P==null?void 0:P.result)&&T(P.result)}catch(P){y("error",`Failed: ${P.message}`)}finally{u(!1)}}},[t,y,s]),ee=n.useCallback(async P=>{if(!(!t||!P.trim())){c(!0);try{const g=await s(t,"workspace_add",{path:P.trim()});g!=null&&g.success?y("info",`Workspace added: ${P.trim()}`):y("error",(g==null?void 0:g.error)||"workspace_add failed")}catch(g){y("error",g.message)}finally{c(!1)}return!0}},[t,y,s]),F=n.useCallback(async P=>{if(!(!t||!window.confirm("Remove this workspace from the list?"))){c(!0);try{const g=await s(t,"workspace_remove",{id:P});g!=null&&g.success?y("info","Workspace removed"):y("error",(g==null?void 0:g.error)||"workspace_remove failed")}catch(g){y("error",g.message)}finally{c(!1)}}},[t,y,s]),oe=n.useCallback(async P=>{var g;if(t){c(!0);try{const L=await s(t,"workspace_set_default",P===null?{clear:!0}:{id:P});if(L!=null&&L.success){y("info",P?"Default workspace updated":"Default workspace cleared");const h=typeof L.defaultWorkspacePath=="string"?L.defaultWorkspacePath:"";h&&((g=A.current)==null||g.call(A,h))}else y("error",(L==null?void 0:L.error)||"workspace_set_default failed")}catch(L){y("error",L.message)}finally{c(!1)}}},[t,y,s]),te=n.useCallback(async P=>{var L;if(!t||!P.trim())return;const g=P.trim();c(!0);try{const h=await s(t,"workspace_set_default",{path:g});h!=null&&h.success?(y("info","Default workspace set from history"),(L=A.current)==null||L.call(A,g)):y("error",(h==null?void 0:h.error)||"Could not set default (path missing on disk?)")}catch(h){y("error",h.message)}finally{c(!1)}},[t,y,s]),le=n.useCallback(async()=>{var P;if(t){v(!0);try{const g=await s(t,"get_cli_history",{}),L=(g==null?void 0:g.history)??((P=g==null?void 0:g.result)==null?void 0:P.history);g!=null&&g.success&&Array.isArray(L)&&x(L)}catch{}v(!1)}},[t,s]),ce=n.useCallback(async()=>{if(t)try{await s(t,"set_machine_nickname",{nickname:R}),y("info",`Nickname set to "${R||"(cleared)"}"`),U(!1)}catch(P){y("error",`Failed: ${P.message}`)}},[t,R,y,s]);return{logs:r,launchingIde:l,loadingWorkspaces:m,workspaceBusy:p,loadingHistory:d,cliHistory:j,recentWorkspaces:M,launchPick:f,setLaunchPick:C,editingNickname:_,setEditingNickname:U,nicknameInput:R,setNicknameInput:I,addLog:y,handleLaunchIde:B,runLaunchCliCore:W,handleLaunchCli:z,handleStopCli:Z,handleRestartIde:b,handleStopIde:G,handleDetectIdes:ie,handleLoadRecentWorkspaces:V,handleWorkspaceAdd:ee,handleWorkspaceRemove:F,handleWorkspaceSetDefault:oe,handleWorkspaceResumePath:te,loadCliHistory:le,handleSaveNickname:ce,setOnDefaultWorkspaceChanged:S}}function br({machine:t,managedIdes:s,managedClis:a,managedAcps:r,actions:i}){const{workspaceBusy:l,handleWorkspaceAdd:o,handleWorkspaceRemove:m,handleWorkspaceSetDefault:u}=i,[p,c]=n.useState(""),d=t.availableMem??t.freeMem,v=t.totalMem>0?Math.min(100,Math.max(0,Math.round((t.totalMem-d)/t.totalMem*100))):0,j=t.loadavg[0]||0;return e.jsxs("div",{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5 mb-5",children:[e.jsx(xt,{icon:e.jsx(tn,{size:16}),label:"Uptime",value:jn(t.uptime)}),e.jsx(xt,{icon:e.jsx(ut,{size:16}),label:"IDEs",value:`${s.length}`}),e.jsx(xt,{icon:e.jsx(ps,{size:16}),label:"CLIs",value:`${a.length}`}),e.jsx(xt,{icon:e.jsx(hs,{size:16}),label:"ACPs",value:`${r.length}`})]}),e.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[e.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-3",children:"Resource Usage"}),e.jsxs("div",{className:"flex gap-6",children:[e.jsx(Ut,{value:Math.min(Math.round(j/t.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${j.toFixed(2)} avg / ${t.cpus} cores`}),e.jsx(Ut,{value:v,max:100,label:"Memory",color:"#3b82f6",detail:`${Yt(t.totalMem-d)} / ${Yt(t.totalMem)}${t.platform==="darwin"?" (approx.)":""}`})]})]}),e.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[e.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider flex items-center gap-1.5 mb-3",children:[e.jsx(At,{size:14})," Workspaces"]}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center mb-3",children:[e.jsx("span",{className:"text-[10px] text-text-muted",children:"Default:"}),e.jsxs("select",{className:"text-xs bg-bg-primary border border-border-subtle rounded-lg px-2 py-1 max-w-[min(100%,420px)]",disabled:l,value:t.defaultWorkspaceId||"",onChange:x=>void u(x.target.value===""?null:x.target.value),children:[e.jsx("option",{value:"",children:"(none)"}),(t.workspaces||[]).map(x=>e.jsx("option",{value:x.id,children:x.label||x.path},x.id))]}),t.defaultWorkspacePath&&e.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate max-w-[min(100%,360px)]",title:t.defaultWorkspacePath,children:t.defaultWorkspacePath})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-end",children:[e.jsx("input",{className:"flex-1 min-w-[200px] text-xs bg-bg-primary border border-border-subtle rounded-lg px-2.5 py-1.5",placeholder:"Add workspace path…",value:p,disabled:l,onChange:x=>c(x.target.value),onKeyDown:x=>x.key==="Enter"&&void(async()=>{await o(p)&&c("")})()}),e.jsx("button",{type:"button",className:"machine-btn text-xs px-3 py-1.5",disabled:l,onClick:async()=>{await o(p)&&c("")},children:"Add"})]}),(t.workspaces||[]).length>0&&e.jsx("ul",{className:"mt-3 space-y-1 max-h-32 overflow-y-auto",children:(t.workspaces||[]).map(x=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[x.id===t.defaultWorkspaceId&&e.jsx("span",{className:"text-[10px]",children:"⭐"}),e.jsx("span",{className:"font-mono truncate flex-1",title:x.path,children:x.path}),e.jsx("button",{type:"button",className:"text-[10px] text-red-400/90 hover:underline",disabled:l,onClick:()=>void m(x.id),children:"Remove"})]},x.id))})]})]})}const yr={ide:{label:"IDE",plural:"IDEs",accent:"border-blue-500/[0.12]"},cli:{label:"CLI",plural:"CLIs",accent:"border-violet-500/[0.12]"},acp:{label:"ACP Agent",plural:"ACP agents",accent:"border-emerald-500/[0.12]"}};function Et({category:t,machine:s,machineId:a,providers:r,managedEntries:i,getIcon:l,actions:o,sendDaemonCommand:m}){const u=dt(),{handleLaunchIde:p,handleLaunchCli:c,handleStopCli:d,handleRestartIde:v,handleStopIde:j,handleDetectIdes:x,cliHistory:M,loadingHistory:T,loadCliHistory:f,launchingIde:C}=o,_=yr[t],U=t==="ide",R=t==="acp",I=r.filter(h=>h.category===t),[A,S]=n.useState(""),[y,B]=n.useState(""),[W,z]=n.useState(""),[Z,b]=n.useState(s.defaultWorkspaceId||""),[G,ie]=n.useState("");n.useEffect(()=>{!A&&I.length>0&&S(I[0].type)},[A,I.length]),n.useEffect(()=>{s.defaultWorkspaceId&&!Z&&b(s.defaultWorkspaceId)},[s.defaultWorkspaceId]);const V=(()=>{if(Z==="__custom__")return G.trim();if(!Z)return"";const h=(s.workspaces||[]).find(K=>K.id===Z);return(h==null?void 0:h.path)||""})(),[ee,F]=n.useState({}),[oe,te]=n.useState(null);n.useEffect(()=>{if(!U||!a||!m)return;(async()=>{try{const K=await m(a,"get_ide_extensions",{}),Q=(K==null?void 0:K.result)||K;Q!=null&&Q.success&&(Q!=null&&Q.ides)&&F(Q.ides)}catch{}})()},[U,a,m]);const le=h=>U?De(h.type):t==="cli"?h.cliName:h.acpName,ce=U?s.detectedIdes||[]:[],P=()=>{U?p(A,V?{workspace:V}:void 0):c(A,V,y||void 0,R&&W||void 0)},g=h=>{U?j(h):d(h.type,h.workspace,h.id)},L=e.jsxs("div",{className:"flex gap-2 items-center flex-wrap mb-3",children:[e.jsx("select",{value:Z,onChange:h=>{b(h.target.value),h.target.value!=="__custom__"&&ie("")},className:"machine-input min-w-[200px] flex-1",children:(s.workspaces||[]).length>0?e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"",children:"(no workspace — launch in home)"}),(s.workspaces||[]).map(h=>e.jsxs("option",{value:h.id,children:[h.id===s.defaultWorkspaceId?"⭐ ":"",h.label||h.path.split("/").filter(Boolean).pop()||h.path," — ",h.path]},h.id)),e.jsx("option",{value:"__custom__",children:"✏️ Custom path…"})]}):e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"",children:"(no workspaces saved — add in Overview tab)"}),e.jsx("option",{value:"__custom__",children:"✏️ Custom path…"})]})}),Z==="__custom__"&&e.jsx("input",{type:"text",placeholder:"Enter absolute path…",value:G,onChange:h=>ie(h.target.value),className:"machine-input flex-1 min-w-[200px]",autoFocus:!0})]});return e.jsxs("div",{children:[e.jsxs("div",{className:`px-5 py-4 rounded-xl mb-5 bg-bg-secondary border ${_.accent}`,children:[e.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Launch ",_.label]}),L,U?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[ce.map(h=>{const K=h.running||i.some(Q=>(Q.type||"").toLowerCase()===(h.type||"").toLowerCase());return e.jsxs("button",{onClick:()=>p(h.type||h.id||"",V?{workspace:V}:void 0),disabled:!!C,className:`machine-btn-primary flex items-center gap-1.5 ${K?"!border-green-500/30":""}`,style:{opacity:C&&C!==h.type?.4:1},children:[e.jsx("span",{children:l(h.type)}),K&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_4px_rgba(34,197,94,0.4)]"}),C===h.type?"⏳ Launching...":`▶ ${h.name||De(h.type)}`,K&&e.jsx("span",{className:"text-[9px] text-green-400 font-normal",children:"+ window"})]},h.type)}),ce.length===0&&e.jsxs("div",{className:"text-xs text-text-muted italic",children:["No IDEs detected.",e.jsxs("button",{onClick:x,className:"machine-btn ml-2 flex items-center gap-1",children:[e.jsx(Zs,{size:12})," Scan"]})]})]})}):e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsx("select",{value:A,onChange:h=>S(h.target.value),className:"machine-input",children:I.length>0?I.map(h=>e.jsxs("option",{value:h.type,children:[h.icon," ",h.displayName]},h.type)):e.jsxs("option",{value:"",disabled:!0,children:["No ",t.toUpperCase()," providers available"]})}),R&&e.jsx("input",{type:"text",placeholder:"Model (default)",value:W,onChange:h=>z(h.target.value),className:"machine-input min-w-[120px]"}),e.jsx("input",{type:"text",placeholder:"Args (optional)",value:y,onChange:h=>B(h.target.value),className:"machine-input min-w-[120px]"}),e.jsx("button",{onClick:P,className:"machine-btn-primary",children:"▶ Launch"})]})]}),e.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",i.length,")"]}),i.length===0?e.jsxs("div",{className:"py-7.5 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:["No ",_.plural," running"]}):e.jsx("div",{className:"flex flex-col gap-2.5 mb-5",children:i.map(h=>{const K=U?h:null,Q=R?h:null;return e.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:l(h.type)}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold text-[13px] text-text-primary",children:[le(h),(K==null?void 0:K.version)&&e.jsxs("span",{className:"text-[10px] text-text-muted ml-1.5",children:["v",K.version]})]}),e.jsxs("div",{className:"text-[11px] text-text-muted flex gap-2",children:[e.jsx("span",{children:h.workspace||"—"}),(Q==null?void 0:Q.currentModel)&&e.jsxs("span",{className:"text-cyan-500",children:["🤖 ",Q.currentModel]}),(Q==null?void 0:Q.currentPlan)&&e.jsxs("span",{className:"text-amber-500",children:["📋 ",Q.currentPlan]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`px-2 py-0.5 rounded-md text-[10px] font-semibold ${h.status==="stopped"?"bg-red-500/[0.08] text-red-500":h.status==="generating"?"bg-orange-500/[0.08] text-orange-400":"bg-green-500/[0.08] text-green-500"}`,children:h.status}),U&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>u(`/ide/${h.id}`),className:"machine-btn flex items-center gap-1",children:[e.jsx(ut,{size:13})," Control"]}),e.jsx("button",{onClick:()=>v(h),className:"machine-btn text-amber-500 border-amber-500/30",children:"↻"})]}),R&&e.jsx("button",{onClick:()=>u(`/ide/${h.id}`),className:"machine-btn",title:"View chat",children:e.jsx(yt,{size:14})}),h.status==="stopped"?e.jsx("button",{onClick:()=>U?p(h.type,h.workspace?{workspace:h.workspace}:void 0):c(h.type,h.workspace),className:"machine-btn text-green-500 border-green-500/30",children:"▶"}):e.jsx("button",{onClick:()=>g(h),className:"machine-btn text-red-500 border-red-500/30",children:"■"})]})]}),K&&K.aiAgents.length>0&&e.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:K.aiAgents.map(xe=>e.jsxs("span",{className:`px-2 py-0.5 rounded-md text-[10px] ${xe.status==="generating"||xe.status==="streaming"?"bg-orange-500/[0.08] text-orange-400":"bg-indigo-500/[0.06] text-indigo-400"}`,children:[xe.name," · ",xe.status]},xe.id))}),K&&(ee[K.type]||[]).length>0&&m&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-border-subtle",children:[e.jsx("div",{className:"text-[10px] text-text-muted font-semibold uppercase tracking-wider mb-1.5",children:"Extensions"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(ee[K.type]||[]).map(xe=>e.jsxs("button",{disabled:oe===`${K.type}.${xe.type}`,onClick:async()=>{const ge=`${K.type}.${xe.type}`;te(ge);try{await m(a,"set_ide_extension",{ideType:K.type,extensionType:xe.type,enabled:!xe.enabled}),F(he=>({...he,[K.type]:(he[K.type]||[]).map(ke=>ke.type===xe.type?{...ke,enabled:!ke.enabled}:ke)}))}catch(he){console.error("Extension toggle failed:",he)}finally{te(null)}},className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors duration-150 cursor-pointer ${xe.enabled?"bg-violet-500/[0.08] border-violet-500/20 text-violet-400":"bg-bg-glass border-border-subtle text-text-muted"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${xe.enabled?"bg-violet-400 shadow-[0_0_4px_rgba(139,92,246,0.4)]":"bg-zinc-600"}`}),xe.name,e.jsx("span",{className:"text-[9px] font-normal",children:xe.enabled?"ON":"OFF"})]},xe.type))})]})]},h.id)})}),!U&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[e.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"History"}),e.jsx("button",{onClick:f,disabled:T,className:"machine-btn",children:T?"⏳":"↻ Load"})]}),(()=>{const h=new Set(I.map(Q=>Q.type)),K=M.filter(Q=>h.has(Q.cliType));return K.length>0?e.jsx("div",{className:"flex flex-col gap-1 max-h-[200px] overflow-y-auto",children:K.map((Q,xe)=>{var ge,he;return e.jsxs("div",{onClick:()=>{S(Q.cliType),b("__custom__"),ie(Q.dir),B((Q.cliArgs||[]).join(" "))},className:"flex justify-between items-center px-2.5 py-1.5 rounded-md cursor-pointer bg-bg-glass border border-border-subtle text-xs transition-colors duration-150 hover:bg-bg-glass-hover",children:[e.jsxs("div",{className:"flex gap-1.5 items-center text-text-secondary",children:[e.jsx("span",{children:l(Q.cliType)}),e.jsx("span",{children:((ge=Q.dir)==null?void 0:ge.split("/").filter(Boolean).pop())||"root"}),((he=Q.cliArgs)==null?void 0:he.length)>0&&e.jsx("span",{className:"text-text-muted text-[10px]",children:Q.cliArgs.join(" ")})]}),e.jsx("span",{className:"text-text-muted text-[10px]",children:Q.timestamp?new Date(Q.timestamp).toLocaleDateString():""})]},xe)})}):e.jsxs("div",{className:"text-[11px] text-text-muted italic mb-2",children:["No ",_.label," launch history yet."]})})()]})]})}const ss=["openPanel","sendMessage","readChat","newSession","listSessions","switchSession","resolveAction","listModels","setModel","listModes","setMode","focusEditor"],jr=[{value:"codex-cli",label:"Codex CLI",desc:"OpenAI o3/gpt-5.4",color:"#22c55e"},{value:"claude-cli",label:"Claude Code",desc:"Anthropic Claude",color:"#a855f7"},{value:"gemini-cli",label:"Gemini CLI",desc:"Google Gemini",color:"#3b82f6"}];function vr({machineId:t,provider:s,sendDaemonCommand:a,onClose:r}){const[i,l]=n.useState("config"),[o,m]=n.useState("codex-cli"),[u,p]=n.useState([]),[c,d]=n.useState(""),[v,j]=n.useState([]),[x,M]=n.useState(""),T=n.useRef(null),f=n.useRef(null),C=S=>{p(y=>y.includes(S)?y.filter(B=>B!==S):[...y,S])},_=()=>p([...ss]),U=()=>p([]);n.useEffect(()=>{var S;(S=T.current)==null||S.scrollIntoView({behavior:"smooth"})},[v]),n.useEffect(()=>()=>{f.current&&clearInterval(f.current)},[]);const R=n.useCallback(()=>{f.current&&clearInterval(f.current),f.current=setInterval(async()=>{try{const S=await a(t,"provider_auto_fix_status",{providerType:s.type});(S==null?void 0:S.running)===!1&&i==="running"&&(l("done"),j(y=>[...y,`
70
70
  ✅ Auto-fix completed!`]),f.current&&clearInterval(f.current))}catch{}},3e3)},[t,s.type,a,i]),I=async()=>{if(u.length!==0){l("running"),j(["🚀 Starting auto-fix...",`Agent: ${o}`,`Scripts: ${u.join(", ")}`,c?`💬 Comment: ${c}`:"",""]),M("");try{const S=await a(t,"provider_auto_fix",{providerType:s.type,functions:u,agent:o,...c?{comment:c}:{}});S!=null&&S.success&&(S!=null&&S.started||S!=null&&S.running)?(j(y=>[...y,"✅ Agent started. Monitoring progress..."]),R()):(l("error"),M((S==null?void 0:S.error)||"Failed to start auto-fix"))}catch(S){l("error"),M((S==null?void 0:S.message)||"Connection failed")}}},A=async()=>{try{await a(t,"provider_auto_fix_cancel",{providerType:s.type}),j(S=>[...S,`
71
- ⚠️ Auto-fix cancelled.`]),l("done"),f.current&&clearInterval(f.current)}catch{}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,children:e.jsxs("div",{className:"w-full max-w-[560px] max-h-[85vh] overflow-hidden rounded-2xl bg-bg-primary border border-border-subtle shadow-2xl flex flex-col",onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:s.icon||"🔧"}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-[15px] font-semibold text-text-primary",children:["Auto-Fix: ",s.displayName]}),e.jsx("p",{className:"text-[11px] text-text-muted mt-0.5",children:"AI agent will implement provider scripts"})]})]}),e.jsx("button",{onClick:r,className:"text-text-muted hover:text-text-primary text-lg leading-none",children:"×"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[i==="config"&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"AI Agent"}),e.jsx("div",{className:"flex gap-2",children:jr.map(S=>e.jsxs("button",{onClick:()=>m(S.value),className:"flex-1 px-3 py-2 rounded-lg border text-left transition-all",style:{borderColor:o===S.value?S.color+"66":"var(--border-subtle)",background:o===S.value?S.color+"0d":"transparent"},children:[e.jsx("div",{className:"text-[12px] font-semibold",style:{color:o===S.value?S.color:"var(--text-primary)"},children:S.label}),e.jsx("div",{className:"text-[10px] text-text-muted",children:S.desc})]},S.value))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"Scripts to Fix"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:_,className:"text-[10px] text-violet-400 hover:text-violet-300",children:"All"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"|"}),e.jsx("button",{onClick:U,className:"text-[10px] text-text-muted hover:text-text-secondary",children:"None"})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:ss.map(S=>e.jsxs("button",{onClick:()=>C(S),className:"px-2.5 py-1.5 rounded-md border text-[11px] font-medium text-left transition-all",style:{borderColor:u.includes(S)?"rgba(139,92,246,0.4)":"var(--border-subtle)",background:u.includes(S)?"rgba(139,92,246,0.08)":"transparent",color:u.includes(S)?"#a78bfa":"var(--text-secondary)"},children:[u.includes(S)?"☑ ":"☐ ",S]},S))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:["Additional Instructions ",e.jsx("span",{className:"text-text-muted font-normal",children:"(optional)"})]}),e.jsx("textarea",{value:c,onChange:S=>d(S.target.value),placeholder:"e.g. Shadow DOM 안의 버튼도 탐색해줘, readChat에서 코드블럭 포맷 유지해...",rows:2,className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] resize-none placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"})]})]}),(i==="running"||i==="done"||i==="error")&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Agent Output"}),e.jsxs("div",{className:"rounded-lg border border-border-subtle bg-[#0d0d0d] p-3 font-mono text-[11px] leading-relaxed text-text-secondary overflow-y-auto",style:{maxHeight:320,minHeight:200},children:[v.map((S,y)=>e.jsx("div",{className:S.startsWith("✅")?"text-green-400":S.startsWith("❌")||S.startsWith("⚠")?"text-amber-400":"",children:S},y)),i==="running"&&e.jsx("div",{className:"text-violet-400 animate-pulse mt-1",children:"● Running..."}),e.jsx("div",{ref:T})]}),x&&e.jsx("div",{className:"mt-2 px-3 py-2 rounded-lg bg-red-500/[0.06] border border-red-500/20 text-red-400 text-[11px]",children:x})]})]}),e.jsxs("div",{className:"px-5 py-3.5 border-t border-border-subtle flex justify-between items-center",children:[e.jsxs("div",{className:"text-[10px] text-text-muted",children:[i==="config"&&u.length>0&&`${u.length} script(s) selected`,i==="running"&&"Agent is working...",i==="done"&&"Run `adhdev provider verify` to validate"]}),e.jsxs("div",{className:"flex gap-2",children:[i==="config"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:r,className:"machine-btn",children:"Cancel"}),e.jsx("button",{onClick:I,disabled:u.length===0,className:"machine-btn",style:{background:u.length>0?"rgba(139,92,246,0.15)":void 0,borderColor:u.length>0?"rgba(139,92,246,0.4)":void 0,color:u.length>0?"#a78bfa":void 0,opacity:u.length===0?.4:1},children:"🚀 Start Fix"})]}),i==="running"&&e.jsx("button",{onClick:A,className:"machine-btn text-red-400 border-red-500/30",children:"⬛ Cancel"}),(i==="done"||i==="error")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{l("config"),j([]),M("")},className:"machine-btn",children:"← Back"}),e.jsx("button",{onClick:r,className:"machine-btn",children:"Close"})]})]})]})]})})}function wr({machineId:t,providers:s,sendDaemonCommand:a,onClose:r,onCreated:i}){var R;const l=s.filter(I=>I.category==="ide"),[o,m]=n.useState(((R=l[0])==null?void 0:R.type)||""),[u,p]=n.useState(""),[c,d]=n.useState(""),[v,j]=n.useState(!1),[x,M]=n.useState(""),[T,f]=n.useState(!1),C=I=>{const A=I.toLowerCase().replace(/[^a-z0-9-]/g,"");p(A),(!c||c===_(u))&&d(_(A))},_=I=>I.split("-").map(A=>A.charAt(0).toUpperCase()+A.slice(1)).join(" "),U=async()=>{if(!(!u||!c||!o)){j(!0),M("");try{const I=await a(t,"provider_clone",{type:u,name:c,category:"ide",location:"user",cloneFrom:o});I!=null&&I.success||I!=null&&I.created?(f(!0),i==null||i(u)):M((I==null?void 0:I.error)||"Failed to create provider")}catch(I){M((I==null?void 0:I.message)||"Connection failed")}j(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,children:e.jsxs("div",{className:"w-full max-w-[480px] rounded-2xl bg-bg-primary border border-border-subtle shadow-2xl flex flex-col",onClick:I=>I.stopPropagation(),children:[e.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle",children:[e.jsx("h2",{className:"text-[15px] font-semibold text-text-primary",children:"✨ Create User Provider"}),e.jsx("p",{className:"text-[11px] text-text-muted mt-0.5",children:"Clone an upstream IDE provider to customize"})]}),e.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:T?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"text-3xl mb-2",children:"🎉"}),e.jsx("h3",{className:"text-[14px] font-semibold text-text-primary",children:"Provider Created!"}),e.jsxs("p",{className:"text-[11px] text-text-muted mt-1",children:[e.jsx("code",{className:"text-violet-400",children:u})," has been created at ",e.jsxs("code",{className:"text-green-400",children:["~/.adhdev/providers/",u,"/"]})]}),e.jsxs("p",{className:"text-[11px] text-text-muted mt-2",children:["Run ",e.jsxs("code",{className:"text-violet-400",children:["adhdev provider fix ",u]})," or use Auto-Fix to implement scripts."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Base Provider"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:l.map(I=>e.jsxs("button",{onClick:()=>m(I.type),className:"px-2.5 py-2 rounded-lg border text-center transition-all",style:{borderColor:o===I.type?"rgba(139,92,246,0.4)":"var(--border-subtle)",background:o===I.type?"rgba(139,92,246,0.08)":"transparent"},children:[e.jsx("div",{className:"text-lg",children:I.icon}),e.jsx("div",{className:"text-[10px] font-medium mt-0.5",style:{color:o===I.type?"#a78bfa":"var(--text-secondary)"},children:I.displayName})]},I.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Provider Type (ID)"}),e.jsx("input",{value:u,onChange:I=>C(I.target.value),placeholder:"my-cursor, custom-windsurf...",className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"}),e.jsxs("p",{className:"text-[10px] text-text-muted mt-1",children:["Lowercase, alphanumeric + hyphens only. Will be created at ",e.jsxs("code",{className:"text-violet-400",children:["~/.adhdev/providers/",u||"...","/"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Display Name"}),e.jsx("input",{value:c,onChange:I=>d(I.target.value),placeholder:"My Custom IDE",className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"})]}),x&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-red-500/[0.06] border border-red-500/20 text-red-400 text-[11px]",children:x})]})}),e.jsx("div",{className:"px-5 py-3.5 border-t border-border-subtle flex justify-end gap-2",children:T?e.jsx("button",{onClick:r,className:"machine-btn",children:"Close"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:r,className:"machine-btn",children:"Cancel"}),e.jsx("button",{onClick:U,disabled:!u||!c||v,className:"machine-btn",style:{background:u&&c?"rgba(34,197,94,0.12)":void 0,borderColor:u&&c?"rgba(34,197,94,0.3)":void 0,color:u&&c?"#86efac":void 0,opacity:!u||!c||v?.4:1},children:v?"⏳ Creating...":"✨ Create Provider"})]})})]})})}function Nr({machineId:t,providers:s,sendDaemonCommand:a}){const[r,i]=n.useState([]),[l,o]=n.useState(!1),[m,u]=n.useState(null),[p,c]=n.useState("all"),[d,v]=n.useState(null),[j,x]=n.useState(!1),M=n.useCallback(async()=>{var f;if(t){o(!0);try{const C=await a(t,"get_provider_settings",{}),_=(C==null?void 0:C.result)||C;if(C!=null&&C.success&&(_!=null&&_.settings)){const U=[];for(const[R,I]of Object.entries(_.settings)){const A=s.find(S=>S.type===R);U.push({type:R,displayName:(A==null?void 0:A.displayName)||R,icon:(A==null?void 0:A.icon)||"",category:(A==null?void 0:A.category)||"unknown",schema:I,values:((f=_.values)==null?void 0:f[R])||{}})}U.sort((R,I)=>R.category.localeCompare(I.category)||R.displayName.localeCompare(I.displayName)),i(U)}}catch{}o(!1)}},[t,s,a]);n.useEffect(()=>{r.length===0&&M()},[]);const T=async(f,C,_)=>{u(`${f}.${C}`),i(U=>U.map(R=>R.type===f?{...R,values:{...R.values,[C]:_}}:R));try{const U=await a(t,"set_provider_setting",{providerType:f,key:C,value:_});U!=null&&U.success||M()}catch{M()}u(null)};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("div",{className:"flex gap-1 items-center",children:[e.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Filter"}),["all","acp","cli","ide","extension"].map(f=>e.jsx("button",{onClick:()=>c(f),className:`machine-btn text-[10px] px-2 py-0.5 ${p===f?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:f.toUpperCase()},f))]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:()=>x(!0),className:"machine-btn text-[10px] bg-green-500/[0.06] border-green-500/20 text-green-400 hover:bg-green-500/[0.12]",children:"✨ Create Provider"}),e.jsx("button",{onClick:M,disabled:l,className:"machine-btn",children:l?"⏳ Loading...":"↻ Refresh"})]})]}),p!=="all"&&r.filter(f=>f.category===p).length>1&&(()=>{const f=r.filter(R=>R.category===p),C=new Map;for(const R of f)for(const I of R.schema){if(I.type!=="boolean")continue;const A=C.get(I.key),S=!!(R.values[I.key]??I.default);A?(A.onCount+=S?1:0,A.total+=1):C.set(I.key,{label:I.label||I.key,onCount:S?1:0,total:1})}const _=[...C.entries()].filter(([,R])=>R.total===f.length);if(_.length===0)return null;const U=async(R,I)=>{for(const A of f)await T(A.type,R,I)};return e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-violet-500/[0.04] border border-violet-500/10 mb-4",children:[e.jsxs("div",{className:"text-[10px] text-violet-400 font-semibold uppercase tracking-wider mb-2",children:["Bulk — Apply to all ",p.toUpperCase()," providers (",f.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(([R,I])=>{const A=I.onCount===I.total,S=I.onCount===0;return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx("span",{className:"text-text-secondary font-medium",children:I.label}),e.jsxs("span",{className:"text-[9px] text-text-muted",children:["(",I.onCount,"/",I.total,")"]}),e.jsx("button",{onClick:()=>void U(R,!0),disabled:A,className:`machine-btn text-[9px] px-1.5 py-px ${A?"opacity-40":"text-green-400 border-green-500/30"}`,children:"All ON"}),e.jsx("button",{onClick:()=>void U(R,!1),disabled:S,className:`machine-btn text-[9px] px-1.5 py-px ${S?"opacity-40":"text-red-400 border-red-500/30"}`,children:"All OFF"})]},R)})})]})})(),l&&r.length===0?e.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading provider settings..."}):e.jsx("div",{className:"flex flex-col gap-2",children:r.filter(f=>p==="all"||f.category===p).map(f=>e.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[e.jsx("span",{className:"text-lg",children:f.icon}),e.jsx("span",{className:"font-semibold text-[13px] text-text-primary",children:f.displayName}),e.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:f.category==="acp"?"rgba(139,92,246,0.08)":f.category==="cli"?"rgba(59,130,246,0.08)":f.category==="ide"?"rgba(34,197,94,0.08)":"rgba(245,158,11,0.08)",color:f.category==="acp"?"#a78bfa":f.category==="cli"?"#60a5fa":f.category==="ide"?"#86efac":"#fbbf24"},children:f.category}),f.category==="ide"&&e.jsx("button",{onClick:()=>v(s.find(C=>C.type===f.type)||{type:f.type,displayName:f.displayName,icon:f.icon,category:f.category}),className:"ml-auto machine-btn text-[9px] px-2 py-0.5 bg-violet-500/[0.06] border-violet-500/20 text-violet-400 hover:bg-violet-500/[0.12]",children:"🔧 Auto-Fix"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:f.schema.map(C=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-xs font-medium text-text-primary",children:[C.label||C.key,m===`${f.type}.${C.key}`&&e.jsx("span",{className:"ml-1.5 text-[9px] text-violet-500",children:"saving..."})]}),C.description&&e.jsx("div",{className:"text-[10px] text-text-muted mt-px",children:C.description})]}),e.jsx("div",{className:"shrink-0",children:C.type==="boolean"?e.jsx("button",{onClick:()=>T(f.type,C.key,!(f.values[C.key]??C.default)),className:"w-10 h-[22px] rounded-[11px] border-none relative cursor-pointer transition-colors duration-200",style:{background:f.values[C.key]??C.default?"#8b5cf6":"var(--border-subtle)"},children:e.jsx("div",{className:"w-4 h-4 rounded-full bg-white absolute top-[3px] transition-[left] duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.3)]",style:{left:f.values[C.key]??C.default?21:3}})}):C.type==="number"?e.jsx("input",{type:"number",value:f.values[C.key]??C.default??0,min:C.min,max:C.max,onChange:_=>{const U=parseInt(_.target.value)||0;C.min!==void 0&&U<C.min||C.max!==void 0&&U>C.max||T(f.type,C.key,U)},className:"machine-input w-20 text-center text-[11px]"}):C.type==="select"&&C.options?e.jsx("select",{value:f.values[C.key]??C.default??"",onChange:_=>T(f.type,C.key,_.target.value),className:"machine-input text-[11px]",children:C.options.map(_=>e.jsx("option",{value:_,children:_},_))}):e.jsx("input",{type:"text",value:f.values[C.key]??C.default??"",onBlur:_=>T(f.type,C.key,_.target.value),className:"machine-input w-[120px] text-[11px]"})})]},C.key))})]},f.type))}),d&&e.jsx(vr,{machineId:t,provider:d,sendDaemonCommand:a,onClose:()=>v(null)}),j&&e.jsx(wr,{machineId:t,providers:s,sendDaemonCommand:a,onClose:()=>x(!1),onCreated:()=>{x(!1),M()}})]})}function kr({machineId:t,sendDaemonCommand:s}){const[a,r]=n.useState([]),[i,l]=n.useState(0),[o,m]=n.useState(!0),[u,p]=n.useState("debug"),c=n.useRef(null),d=n.useRef(!1);return n.useEffect(()=>{if(!t||!o)return;const v=async()=>{try{const x=await s(t,"get_logs",{count:200,minLevel:u,since:i}),M=(x==null?void 0:x.result)||x;if(x!=null&&x.success&&Array.isArray(M==null?void 0:M.logs)&&M.logs.length>0){r(f=>[...f,...M.logs.map(_=>({timestamp:_.ts,level:_.level,message:`[${_.category}] ${_.message}`}))].slice(-300));const T=Math.max(...M.logs.map(f=>f.ts));l(T)}}catch{}};v();const j=setInterval(v,3e3);return()=>clearInterval(j)},[t,o,i,u,s]),n.useEffect(()=>{if(o&&a.length>0){const v=d.current?"smooth":"instant";setTimeout(()=>{var j;(j=c.current)==null||j.scrollIntoView({behavior:v}),d.current=!0},50)}},[a.length,o]),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsxs("div",{className:"flex gap-1 items-center",children:[e.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Level"}),["debug","info","warn","error"].map(v=>e.jsx("button",{onClick:()=>{p(v),r([]),l(0)},className:`machine-btn text-[10px] px-2 py-0.5 ${u===v?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:v.toUpperCase()},v))]}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsxs("span",{className:"text-[10px] text-text-muted",children:[a.length," entries"]}),e.jsx("button",{onClick:()=>m(!o),className:`machine-btn ${o?"text-green-500 border-green-500/30":""}`,children:o?"⏸ Pause":"▶ Resume"}),e.jsx("button",{onClick:()=>{r([]),l(0)},className:"machine-btn",children:"Clear"})]})]}),e.jsxs("div",{className:"bg-bg-secondary border border-border-subtle rounded-xl p-3 min-h-[200px] max-h-[500px] overflow-y-auto font-mono text-[11px] leading-relaxed",children:[a.length===0&&e.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading daemon logs..."}),a.map((v,j)=>e.jsxs("div",{className:"flex gap-2 py-px",style:{color:v.level==="error"?"#ef4444":v.level==="warn"?"#f59e0b":v.level==="debug"?"#64748b":"#94a3b8"},children:[e.jsx("span",{className:"text-text-muted min-w-[75px] shrink-0",children:new Date(v.timestamp).toLocaleTimeString()}),e.jsx("span",{className:"font-semibold min-w-[32px] shrink-0 text-[9px]",style:{color:v.level==="error"?"#ef4444":v.level==="warn"?"#f59e0b":v.level==="debug"?"#475569":"#8b5cf6"},children:v.level==="error"?"ERR":v.level==="warn"?"WRN":v.level==="debug"?"DBG":"INF"}),e.jsx("span",{children:v.message})]},j)),e.jsx("div",{ref:c})]})]})}function Sr({machine:t,launchPick:s,actions:a}){const{runLaunchCliCore:r,setLaunchPick:i}=a;return e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/55 backdrop-blur-[2px]",role:"dialog","aria-modal":"true","aria-labelledby":"launch-pick-title",children:e.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border-subtle bg-bg-secondary shadow-xl p-5",children:[e.jsx("h2",{id:"launch-pick-title",className:"text-sm font-semibold text-text-primary m-0 mb-1",children:"Where should this run?"}),e.jsx("p",{className:"text-[11px] text-text-muted m-0 mb-4",children:"Nothing is assumed. Pick a saved workspace, your default workspace, or home — or cancel and type a path."}),e.jsx("div",{className:"flex flex-col gap-2 mb-4 max-h-48 overflow-y-auto",children:(t.workspaces||[]).length===0?e.jsx("span",{className:"text-[11px] text-text-muted",children:"No saved workspaces yet. Add one in Overview or type a path above."}):(t.workspaces||[]).map(l=>e.jsxs("button",{type:"button",className:"text-left text-xs px-3 py-2 rounded-lg border border-border-subtle bg-bg-primary hover:bg-violet-500/10 transition-colors",onClick:()=>{i(null),r({cliType:s.cliType,workspaceId:l.id,argsStr:s.argsStr,model:s.model})},children:[e.jsx("span",{className:"font-medium text-text-primary block truncate",children:l.label||l.path}),e.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate block",children:l.path})]},l.id))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",disabled:!t.defaultWorkspacePath,onClick:()=>{i(null),r({cliType:s.cliType,useDefaultWorkspace:!0,argsStr:s.argsStr,model:s.model})},children:"Default workspace"}),e.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",onClick:()=>{i(null),r({cliType:s.cliType,useHome:!0,argsStr:s.argsStr,model:s.model})},children:"Home directory"}),e.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[80px]",onClick:()=>i(null),children:"Cancel"})]})]})})}function Cr(){var U,R,I,A,S,y,B,W,z,Z;const{id:t}=is(),s=dt(),{sendCommand:a}=Ge(),r=vt(),i=r.ides||[],l=r.initialLoaded??!0,[o,m]=n.useState("overview"),u=n.useRef(null),p=gr({machineId:t,sendDaemonCommand:a,logsEndRef:u}),c=i.find(b=>b.id===t&&b.daemonMode),d=((c==null?void 0:c.availableProviders)||[]).map(b=>({type:b.type,displayName:b.displayName,icon:b.icon,category:b.category})),v={};for(const b of d)v[b.type]=b.icon;const j=b=>v[b]||"",x=c?{id:c.id,hostname:((U=c.machine)==null?void 0:U.hostname)||c.id,platform:((R=c.machine)==null?void 0:R.platform)||"unknown",arch:((I=c.machine)==null?void 0:I.arch)||"",cpus:((A=c.machine)==null?void 0:A.cpus)||0,totalMem:((S=c.machine)==null?void 0:S.totalMem)||0,freeMem:((y=c.machine)==null?void 0:y.freeMem)||0,availableMem:(B=c.machine)==null?void 0:B.availableMem,loadavg:((W=c.machine)==null?void 0:W.loadavg)||[],uptime:((z=c.machine)==null?void 0:z.uptime)||0,release:((Z=c.machine)==null?void 0:Z.release)||"",cdpConnected:!!(c.ides||[]).some(b=>b.cdpConnected),machineNickname:c.machineNickname||null,p2p:c.p2p||{available:!1,state:"unavailable",peers:0,screenshotActive:!1},detectedIdes:c.detectedIdes||[],managedIdeIds:c.managedIdeIds||[],managedCliIds:c.managedCliIds||[],workspaces:c.workspaces||[],defaultWorkspaceId:c.defaultWorkspaceId??c.activeWorkspaceId??null,defaultWorkspacePath:c.defaultWorkspacePath??c.activeWorkspacePath??null,workspaceActivity:c.workspaceActivity||[]}:null,M=i.filter(b=>b.daemonId===t&&!b.daemonMode).filter(b=>!Gt(b)&&!Xt(b)).map(b=>({id:b.id,type:b.type,version:b.version||"",instanceId:b.instanceId||"",status:b.status,workspace:b.workspace||null,terminals:b.terminals||0,aiAgents:vn(b.aiAgents||b.agents||[]),activeChat:b.activeChat||null,chats:b.chats||[],agentStreams:b.agentStreams||[],cdpConnected:b.cdpConnected||!1,daemonId:t})),T=i.filter(b=>b.daemonId===t&&Gt(b)).map(b=>({id:b.id,type:b.type,cliName:b.cliName||b.type,status:b.status,workspace:b.workspace||"",activeChat:b.activeChat||null,daemonId:t})),f=i.filter(b=>b.daemonId===t&&Xt(b)).map(b=>({id:b.id,type:b.type,acpName:b.cliName||b.type,status:b.status,workspace:b.workspace||"",activeChat:b.activeChat||null,currentModel:b.currentModel,currentPlan:b.currentPlan,daemonId:t}));if(!x)return l?e.jsxs("div",{className:"p-10 text-center text-text-muted",children:[e.jsx("h2",{className:"text-text-primary",children:"Machine not found"}),e.jsx("p",{className:"mt-3",children:"The machine may be offline or not yet connected."}),e.jsx("button",{onClick:()=>s("/machines"),className:"machine-btn-back",children:"← Back to Burrows"})]}):e.jsx("div",{className:"p-10 text-center text-text-muted",children:e.jsx("p",{children:"⏳ Loading machine..."})});const C=x.machineNickname||x.hostname,_=[{id:"overview",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(sn,{size:14})," Overview"]})},{id:"ides",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ut,{size:14})," IDEs"]}),count:M.length},{id:"clis",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ms,{size:14})," CLIs"]}),count:T.length},{id:"acps",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(hs,{size:14})," ACP Agents"]}),count:f.length},{id:"providers",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(us,{size:14})," Providers"]})},{id:"logs",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Vs,{size:14})," Logs"]})}];return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"dashboard-header !flex-col !items-stretch",children:[e.jsx("div",{className:"flex items-center justify-between w-full",children:e.jsxs("div",{className:"flex items-center gap-2 md:gap-3.5 w-full min-w-0",children:[e.jsx("button",{onClick:()=>s("/machines"),className:"machine-btn-back flex shrink-0",children:"←"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[p.editingNickname?e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("input",{autoFocus:!0,value:p.nicknameInput,onChange:b=>p.setNicknameInput(b.target.value),onKeyDown:b=>{b.key==="Enter"&&p.handleSaveNickname(),b.key==="Escape"&&p.setEditingNickname(!1)},placeholder:"Machine nickname...",className:"px-2.5 py-1 rounded-md border border-violet-500/30 bg-bg-secondary text-text-primary text-sm font-semibold w-[140px] md:w-[200px]"}),e.jsx("button",{onClick:p.handleSaveNickname,className:"machine-btn text-green-500 border-green-500/30 shrink-0",children:"✓"}),e.jsx("button",{onClick:()=>p.setEditingNickname(!1),className:"machine-btn shrink-0",children:"✕"})]}):e.jsx("h1",{className:"header-title cursor-pointer truncate",onClick:()=>{p.setEditingNickname(!0),p.setNicknameInput(x.machineNickname||"")},title:"Click to set nickname",children:C}),e.jsx("span",{className:"status-dot-md online shrink-0"})]}),e.jsxs("div",{className:"header-subtitle mt-1 flex-wrap gap-1 md:gap-2 items-center display-none-mobile",children:[e.jsxs("span",{children:[x.platform," · ",x.arch," · ",x.cpus," cores"]}),(c==null?void 0:c.version)&&e.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-bg-glass border border-border-subtle text-text-muted shrink-0",children:["v",c.version]}),(c==null?void 0:c.versionMismatch)&&e.jsxs("button",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-amber-500/[0.08] border border-amber-500/20 text-amber-400 cursor-pointer hover:bg-amber-500/[0.15] transition-colors shrink-0",onClick:async()=>{try{await a(t,"daemon_upgrade",{})}catch{}},children:["🔄 Update to v",c.serverVersion]}),x.p2p.available&&e.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:x.p2p.state==="connected"?"rgba(34,197,94,0.08)":"rgba(234,179,8,0.08)",color:x.p2p.state==="connected"?"#22c55e":"#eab308"},children:["P2P ",x.p2p.state==="connected"?`● ${x.p2p.peers}`:"○"]}),x.cdpConnected&&e.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-green-500/[0.08] text-green-500 shrink-0",children:"CDP ●"}),x.machineNickname&&e.jsxs("span",{className:"text-text-muted opacity-80 shrink-0",children:["(",x.hostname,")"]})]})]})]})}),e.jsx("div",{className:"machine-tabs w-full overflow-x-auto overflow-y-hidden pb-1 -mb-1 mt-2",children:_.map(b=>e.jsxs("button",{onClick:()=>m(b.id),className:`machine-tab shrink-0${o===b.id?" active":""}`,children:[b.label,b.count!==void 0&&e.jsx("span",{className:"tab-count",children:b.count})]},b.id))})]}),e.jsxs("div",{className:"page-content",children:[o==="overview"&&e.jsx(br,{machine:x,managedIdes:M,managedClis:T,managedAcps:f,actions:p}),o==="ides"&&e.jsx(Et,{category:"ide",machine:x,machineId:t,providers:d,managedEntries:M,getIcon:j,actions:p,sendDaemonCommand:a}),o==="clis"&&e.jsx(Et,{category:"cli",machine:x,machineId:t,providers:d,managedEntries:T,getIcon:j,actions:p}),o==="acps"&&e.jsx(Et,{category:"acp",machine:x,machineId:t,providers:d,managedEntries:f,getIcon:j,actions:p}),o==="providers"&&e.jsx(Nr,{machineId:t,providers:d,sendDaemonCommand:a}),o==="logs"&&e.jsx(kr,{machineId:t,sendDaemonCommand:a})]}),p.launchPick&&x&&e.jsx(Sr,{machine:x,launchPick:p.launchPick,actions:p})]})}function Ir(){if(typeof window>"u")return"ws://localhost:3847/ws";const s=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,r=new URLSearchParams(window.location.search).get("token");return r?`${s}?token=${encodeURIComponent(r)}`:s}const ns=Ir(),rs=3e3,Mr=3e4;let Fe=null,Tr=0;const jt=new Map,Bt=new Set;let qe=null,Er=null,ot=null;async function bt(t,s,a){const r=Fe;if(r&&r.readyState===WebSocket.OPEN){const l=`req_${++Tr}_${Date.now()}`;return new Promise((o,m)=>{const u=setTimeout(()=>{jt.delete(l),m(new Error(`WS command timeout: ${s}`))},3e4);jt.set(l,{resolve:p=>{clearTimeout(u),o(p)},reject:p=>{clearTimeout(u),m(p)}}),r.send(JSON.stringify({type:"command",requestId:l,data:{type:s,payload:a||{},target:t}}))})}const i=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:s,payload:a||{},target:t})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()}class $r{constructor(s){$e(this,"daemonId");$e(this,"screenshotIdeType",null);this.daemonId=s}get hasCommandChannel(){return(Fe==null?void 0:Fe.readyState)===WebSocket.OPEN}get connectionState(){return(Fe==null?void 0:Fe.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(s,a){return bt(this.daemonId,s,a)}async sendInput(s,a){const r=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId;return bt(r,"cdp_remote_action",{action:s,params:a})}startScreenshots(s){this.screenshotIdeType=s||null,qe&&(clearInterval(qe),qe=null);const a=async()=>{if(this.hasCommandChannel)try{const r=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId,i=await bt(r,"screenshot",{width:1280});if(i!=null&&i.success&&(i!=null&&i.base64)){const l=await fetch(`data:image/jpeg;base64,${i.base64}`).then(o=>o.blob());Bt.forEach(o=>o(this.daemonId,l))}}catch{}};a(),qe=setInterval(a,2e3)}stopScreenshots(s){qe&&(clearInterval(qe),qe=null)}}let Je=null;function Ar(t){(!Je||Je.daemonId!==t)&&(Je=new $r(t));const s=Ae._originalGet||Ae.get.bind(Ae);Ae._originalGet=s,Ae.get=a=>a===t||a.startsWith("standalone")?Je:s(a),Ae.getState=a=>(a===t||a.startsWith("standalone"))&&(Je==null?void 0:Je.connectionState)||"disconnected",Ae.onScreenshot=(a,r)=>(Bt.add(r),()=>{Bt.delete(r)})}function _r({children:t}){const s=n.useRef(Ht()),a=Ht();s.current=a;const{setUserName:r}=it(),i=n.useRef(r);i.current=r;const[,l]=n.useState("disconnected"),o=n.useCallback((d,v)=>{l(d),ot==null||ot(d,v)},[]),m=n.useRef(null),u=n.useRef(),p=n.useRef(rs),c=n.useRef(!0);return n.useEffect(()=>{c.current=!0;function d(){var x,M;if(!c.current||((x=m.current)==null?void 0:x.readyState)===WebSocket.OPEN||((M=m.current)==null?void 0:M.readyState)===WebSocket.CONNECTING)return;o("connecting"),console.log(`[Standalone WS] Connecting to ${ns}...`);let j;try{j=new WebSocket(ns)}catch(T){console.error("[Standalone WS] Failed to create WebSocket:",T),v();return}m.current=j,j.onopen=()=>{if(!c.current){j.close();return}o("connected"),p.current=rs,console.log("[Standalone WS] Connected")},Fe=j,j.onmessage=T=>{var f;try{const C=JSON.parse(T.data);if((C.type==="command_result"||C.type==="error")&&C.requestId){const _=jt.get(C.requestId);_&&(jt.delete(C.requestId),C.type==="error"?_.reject(new Error(((f=C.data)==null?void 0:f.message)||"Command failed")):_.resolve(C.data));return}if(C.type==="status"||C.type==="initial_state"){const _=C.data;if(!_)return;const{injectEntries:U,markLoaded:R}=s.current,I=_.id||"standalone";Er=I,Ar(I),o("connected",I);const A=In(_,{daemonId:I});A.length>0&&U(A),R(),_.userName&&i.current&&i.current(_.userName)}}catch(C){console.error("[Standalone WS] Parse error:",C)}},j.onclose=()=>{c.current&&(o("disconnected"),m.current=null,v())},j.onerror=T=>{console.warn("[Standalone WS] Error, will reconnect:",T)}}function v(){if(!c.current)return;clearTimeout(u.current);const j=p.current;console.log(`[Standalone WS] Reconnecting in ${j}ms...`),u.current=setTimeout(()=>{p.current=Math.min(p.current*1.5,Mr),d()},j)}return d(),()=>{c.current=!1,clearTimeout(u.current),m.current&&(m.current.onclose=null,m.current.close(),m.current=null,Fe=null)}},[]),e.jsx(e.Fragment,{children:t})}function Rr({children:t}){const[s,a]=n.useState("disconnected"),[r,i]=n.useState(null);n.useEffect(()=>(ot=(o,m)=>{a(o),m&&i(m)},()=>{ot=null}),[]);const l=n.useMemo(()=>{const o=s==="connected",m={};return r&&(m[r]=o?"connected":"connecting"),m.standalone=o?"connected":"connecting",{wsStatus:s,isConnected:o,connectionStates:m}},[s,r]);return e.jsx(Fs,{connectionOverrides:l,children:e.jsx(_r,{children:t})})}const Pr=[{id:"dashboard",path:"/dashboard",icon:e.jsx(Gs,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:e.jsx(Xs,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:e.jsx(us,{}),label:"Settings"}];function Lr({children:t}){const s=dt(),a=Rs(),[r,i]=n.useState(!1),[l,o]=n.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),m=c=>{s(c),i(!1)},u=()=>{o(c=>{const d=!c;try{localStorage.setItem("sidebar-collapsed",d?"1":"0")}catch{}return d})},p=c=>`nav-item${a.pathname.startsWith(c)?" active":""} cursor-pointer ${l?"justify-center py-2.5 px-0":""}`;return e.jsxs("div",{className:`app-layout${r?" mobile-menu-open":""}${l?" sidebar-collapsed":""}`,children:[e.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>i(!0),children:[e.jsx("span",{className:"mobile-menu-icon"}),e.jsx("span",{className:"mobile-menu-icon"}),e.jsx("span",{className:"mobile-menu-icon"})]}),r&&e.jsx("div",{className:"sidebar-overlay",role:"button",tabIndex:0,"aria-label":"Close menu",onClick:()=>i(!1),onKeyDown:c=>c.key==="Escape"&&i(!1)}),e.jsxs("aside",{className:`sidebar ${r?"sidebar-open":""}`,children:[e.jsxs("div",{className:"sidebar-header",children:[e.jsxs("div",{className:`sidebar-logo ${l?"justify-center gap-0":""}`,children:[e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-7 h-7"}),!l&&e.jsx("span",{children:"ADHDev"})]}),e.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>i(!1),children:"✕"})]}),e.jsx("nav",{className:"sidebar-nav",children:Pr.map(c=>e.jsxs("div",{className:p(c.path),id:`nav-${c.id}`,onClick:()=>m(c.path),title:l?c.label:void 0,children:[e.jsx("span",{className:"nav-icon",children:c.icon}),!l&&c.label]},c.id))}),e.jsxs("div",{className:"border-t border-border-subtle pt-4 mt-2",children:[e.jsxs("div",{className:`nav-item cursor-pointer${a.pathname==="/about"?" active":""} ${l?"justify-center py-2.5 px-0":""}`,id:"nav-about",onClick:()=>s("/about"),title:l?"About":void 0,children:[e.jsx("span",{className:"nav-icon",children:e.jsx(qs,{})}),!l&&"About"]}),!l&&e.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.6.45"]}),e.jsxs("div",{className:`nav-item cursor-pointer ${l?"justify-center py-2.5 px-0":"mt-1"}`,onClick:u,title:l?"Expand sidebar":"Collapse sidebar",children:[e.jsx("span",{className:"nav-icon text-base",children:l?"›":"‹"}),!l&&e.jsx("span",{className:"text-xs",children:"Collapse"})]})]})]}),e.jsx("main",{className:"main-content relative",children:e.jsx("div",{className:"main-content-inner",children:t})})]})}const Dr=[{icon:"🏠",title:"Local-first",desc:"Everything runs on your machine. No data leaves your network. Full privacy by design."},{icon:"💬",title:"Agent chat relay",desc:"Read and respond to AI conversations in real-time across all connected IDEs."},{icon:"📸",title:"Live screenshots",desc:"View your IDE screens directly in the browser via local WebSocket streaming."},{icon:"🎛️",title:"Remote control",desc:"Click, type, and interact with your IDE from the dashboard — no window switching."},{icon:"🔌",title:"Multi-IDE support",desc:"Monitor and control multiple IDEs simultaneously — VS Code, Cursor, Windsurf, and more."},{icon:"⚡",title:"Extension agents",desc:"Manage extension-based agents like Cline and Roo Code alongside native IDE agents."}],Br=[{icon:"🌍",title:"Access from anywhere",desc:"Control your agents from any device, any network. No VPN or port forwarding needed."},{icon:"🔗",title:"WebRTC P2P streaming",desc:"End-to-end encrypted peer-to-peer connection for zero-latency remote screenshots and control."},{icon:"📱",title:"Mobile notifications",desc:"Get push notifications when agents need approval. Quick approve/reject from your phone."},{icon:"📡",title:"REST API access",desc:"Integrate with Slack, CI/CD pipelines, or custom tools. Scoped API keys with granular permissions."},{icon:"👥",title:"Team dashboard",desc:"Share a unified view across your team. See who's running what, where, in real time."},{icon:"🔐",title:"Enterprise security",desc:"SSO, RBAC, audit logs, and SLA guarantees for production teams."}],Wr=[{feature:"Agent chat relay",selfhost:!0,cloud:!0},{feature:"Live IDE screenshots",selfhost:!0,cloud:!0},{feature:"Remote IDE control",selfhost:!0,cloud:!0},{feature:"Multi-IDE monitoring",selfhost:!0,cloud:!0},{feature:"Extension agent support",selfhost:!0,cloud:!0},{feature:"CLI agent support",selfhost:!0,cloud:!0},{feature:"Access from any network",selfhost:!1,cloud:!0},{feature:"WebRTC P2P streaming",selfhost:!1,cloud:!0},{feature:"Mobile push notifications",selfhost:!1,cloud:!0},{feature:"REST API & webhooks",selfhost:!1,cloud:!0},{feature:"Team collaboration",selfhost:!1,cloud:!0},{feature:"Multi-machine (Burrows)",selfhost:!1,cloud:!0},{feature:"SSO / RBAC / Audit logs",selfhost:!1,cloud:!0}],$t={ides:["VS Code","Cursor","Antigravity","Windsurf","Trae","PearAI","Kiro","VSCodium","VS Code Insiders"],agents:["GitHub Copilot","Cline","Roo Code"],cli:["Gemini CLI","Claude Code","Codex CLI"]};function Or(){return e.jsxs("div",{className:"py-8 px-6 max-w-[860px] mx-auto text-text-primary",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-14 h-14 mb-3 mx-auto"}),e.jsx("h1",{className:"text-[26px] font-extrabold mb-1.5 text-text-primary",children:"ADHDev"}),e.jsx("p",{className:"text-[13px] text-text-muted",children:"Agent Dashboard Hub for Dev — Self-hosted Edition"}),e.jsxs("div",{className:"inline-block mt-3 px-3 py-1 text-[11px] font-semibold tracking-wide rounded-full bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:["SELFHOST v","0.6.45"]})]}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"✅"})," What's included"]}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-3",children:Dr.map(t=>e.jsxs("div",{className:"bg-bg-glass border border-border-subtle rounded-xl px-4 py-4 transition-colors hover:border-border-default",children:[e.jsx("div",{className:"text-xl mb-1.5",children:t.icon}),e.jsx("div",{className:"font-semibold text-[13px] mb-1",children:t.title}),e.jsx("div",{className:"text-[12px] text-text-muted leading-relaxed",children:t.desc})]},t.title))})]}),e.jsxs("section",{className:"mb-10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4",children:"Compatible with"}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-5",children:[{label:"IDEs",items:$t.ides},{label:"Extension agents",items:$t.agents},{label:"CLI agents",items:$t.cli}].map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-bold tracking-wider text-text-muted mb-2 uppercase",children:t.label}),e.jsx("div",{className:"flex flex-col gap-1",children:t.items.map(s=>e.jsx("div",{className:"text-[12px] px-2.5 py-1.5 bg-bg-glass rounded-md border border-border-subtle",children:s},s))})]},t.label))})]}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"⚖️"})," Self-hosted vs Cloud"]}),e.jsx("div",{className:"rounded-xl border border-border-subtle overflow-hidden",children:e.jsxs("table",{className:"w-full text-[13px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-bg-secondary",children:[e.jsx("th",{className:"text-left px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider",children:"Feature"}),e.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider w-[100px]",children:"Selfhost"}),e.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-[11px] uppercase tracking-wider w-[100px] text-violet-500",children:"Cloud"})]})}),e.jsx("tbody",{children:Wr.map((t,s)=>e.jsxs("tr",{className:s%2===0?"bg-bg-glass":"",children:[e.jsx("td",{className:"px-4 py-2 text-text-secondary",children:t.feature}),e.jsx("td",{className:"text-center px-4 py-2",children:t.selfhost?e.jsx("span",{className:"text-emerald-500",children:"✓"}):e.jsx("span",{className:"text-text-muted opacity-40",children:"—"})}),e.jsx("td",{className:"text-center px-4 py-2",children:e.jsx("span",{className:"text-emerald-500",children:"✓"})})]},t.feature))})]})})]}),e.jsx("section",{className:"mb-10",children:e.jsx("div",{className:"rounded-2xl border border-violet-500/20 bg-violet-500/[0.04] px-6 py-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"text-3xl shrink-0",children:"🚀"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-bold text-[15px] mb-1.5",children:"Unlock more with ADHDev Cloud"}),e.jsx("p",{className:"text-[13px] text-text-muted leading-relaxed mb-4",children:"Access your agents from anywhere — your phone, another laptop, or a coffee shop. Cloud adds WebRTC P2P streaming, mobile push notifications, REST API, team collaboration, and multi-machine support. Your local setup stays exactly the same."}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-2.5 mb-5",children:Br.map(t=>e.jsxs("div",{className:"flex gap-2.5 items-start",children:[e.jsx("span",{className:"text-base shrink-0 mt-0.5",children:t.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-[12px]",children:t.title}),e.jsx("div",{className:"text-[11px] text-text-muted leading-snug",children:t.desc})]})]},t.title))}),e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[e.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Try ADHDev Cloud →"}),e.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"GitHub"}),e.jsx("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Discord"})]})]})]})})}),e.jsxs("div",{className:"text-center text-xs text-text-muted pt-4 border-t border-border-subtle",children:[e.jsx("p",{children:"© 2026 RacoLab · ADHDev, Your AI sidekick otter 🦦"}),e.jsx("p",{className:"mt-1 opacity-60",children:"Self-hosted edition — all data stays on your machine"})]})]})}function Kr(){const{ides:t}=it(),s=t.find(d=>d.type==="adhdev-daemon"),a=(s==null?void 0:s.detectedIdes)||[],{sendCommand:r}=Ge(),{userName:i}=it(),[l,o]=n.useState(i||"");n.useEffect(()=>{i!==void 0&&o(i)},[i]);const m=d=>{const v=d.target.value.trim();s!=null&&s.id&&v!==i&&r(s.id,"set_user_name",{userName:v}).catch(console.error)},[u,p]=n.useState(()=>{try{return localStorage.getItem("adhdev_sound")!=="0"}catch{return!0}}),c=d=>{p(d);try{localStorage.setItem("adhdev_sound",d?"1":"0")}catch{}};return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(Bn,{icon:"⚙️",title:"Settings",subtitle:"Local daemon configuration & preferences"}),e.jsxs("div",{className:"page-content",children:[e.jsx(et,{title:"Daemon",className:"mb-4",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-x-4 gap-y-2.5 text-sm",children:[e.jsx("span",{className:"text-text-muted",children:"Version"}),e.jsxs("span",{className:"font-mono text-xs",children:["v","0.6.45"]}),e.jsx("span",{className:"text-text-muted",children:"Status"}),e.jsx("span",{className:s?"text-green-400":"text-yellow-400",children:s?"● Running":"○ Not connected"}),e.jsx("span",{className:"text-text-muted",children:"WebSocket"}),e.jsx("span",{className:"font-mono text-xs",children:"ws://localhost:19222"}),e.jsx("span",{className:"text-text-muted",children:"HTTP"}),e.jsx("span",{className:"font-mono text-xs",children:"http://localhost:19280"})]})}),e.jsx(et,{title:"Detected IDEs",className:"mb-4",children:a.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:"No IDEs detected. Start an IDE to see it here."}):e.jsx("div",{className:"flex flex-col gap-1.5",children:a.map(d=>e.jsxs("div",{className:"flex justify-between items-center bg-bg-glass rounded-lg px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${d.running?"bg-green-400":"bg-text-muted/30"}`}),e.jsx("span",{className:"text-sm font-medium",children:d.name})]}),e.jsx("span",{className:"text-[11px] text-text-muted font-mono",children:d.type})]},d.type))})}),e.jsx(et,{title:"Machine",className:"mb-4",children:e.jsx(Yn,{ides:t,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),e.jsx(et,{title:"Theme",className:"mb-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Site theme"}),e.jsx(Jn,{})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[e.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Chat theme"}),e.jsx(nr,{})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[e.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Accent color"}),e.jsx(lr,{})]})]})}),e.jsx(et,{title:"Notifications",className:"mb-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Un,{}),e.jsx(tt,{label:"🔊 Sound Effects",description:"Play a sound when agent completes or needs approval",checked:u,onChange:c})]})}),e.jsx(et,{title:"Preferences",className:"mb-4",children:e.jsx("div",{className:"flex flex-col gap-3",children:e.jsxs("div",{className:"flex items-center justify-between px-3.5 py-4 bg-bg-glass rounded-xl border border-border-subtle hover:border-border-default transition-colors",children:[e.jsxs("div",{className:"flex flex-col gap-1 pr-4 max-w-[500px]",children:[e.jsx("span",{className:"text-sm font-semibold flex items-center gap-2",children:"👤 Display Name"}),e.jsx("span",{className:"text-[12px] text-text-muted leading-relaxed",children:"Your name shown in chat threads and on the team dashboard."})]}),e.jsx("input",{type:"text",className:"bg-bg-primary border border-border-strong rounded-lg px-3 py-1.5 text-sm w-48 text-right focus:border-accent focus:outline-none transition-colors",placeholder:"Anonymous",value:l,onChange:d=>o(d.target.value),onBlur:m,onKeyDown:d=>{d.key==="Enter"&&d.currentTarget.blur()}})]})})})]})]})}tr();function as(){const{ides:t}=it(),s=t.find(a=>{var r;return a.daemonMode||((r=a.id)==null?void 0:r.startsWith("standalone"))});return s?e.jsx(pt,{to:`/machines/${s.id}`,replace:!0}):t.length>0?e.jsx(pt,{to:`/machines/${t[0].id}`,replace:!0}):e.jsx(pt,{to:"/dashboard",replace:!0})}function Fr(){return e.jsx(Ps,{children:e.jsx(Rr,{children:e.jsx(Ys,{value:{sendCommand:bt,sendData:()=>!1},children:e.jsx(Lr,{children:e.jsxs(Ls,{children:[e.jsx(Ue,{path:"/dashboard",element:e.jsx(pr,{})}),e.jsx(Ue,{path:"/ide/:id",element:e.jsx(fr,{})}),e.jsx(Ue,{path:"/machine",element:e.jsx(as,{})}),e.jsx(Ue,{path:"/machines/:id",element:e.jsx(Cr,{})}),e.jsx(Ue,{path:"/machines",element:e.jsx(as,{})}),e.jsx(Ue,{path:"/about",element:e.jsx(Or,{})}),e.jsx(Ue,{path:"/settings",element:e.jsx(Kr,{})}),e.jsx(Ue,{path:"*",element:e.jsx(pt,{to:"/dashboard",replace:!0})})]})})})})})}Ds(document.getElementById("root")).render(e.jsx(n.StrictMode,{children:e.jsx(Fr,{})}));
71
+ ⚠️ Auto-fix cancelled.`]),l("done"),f.current&&clearInterval(f.current)}catch{}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,children:e.jsxs("div",{className:"w-full max-w-[560px] max-h-[85vh] overflow-hidden rounded-2xl bg-bg-primary border border-border-subtle shadow-2xl flex flex-col",onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:s.icon||"🔧"}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-[15px] font-semibold text-text-primary",children:["Auto-Fix: ",s.displayName]}),e.jsx("p",{className:"text-[11px] text-text-muted mt-0.5",children:"AI agent will implement provider scripts"})]})]}),e.jsx("button",{onClick:r,className:"text-text-muted hover:text-text-primary text-lg leading-none",children:"×"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[i==="config"&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"AI Agent"}),e.jsx("div",{className:"flex gap-2",children:jr.map(S=>e.jsxs("button",{onClick:()=>m(S.value),className:"flex-1 px-3 py-2 rounded-lg border text-left transition-all",style:{borderColor:o===S.value?S.color+"66":"var(--border-subtle)",background:o===S.value?S.color+"0d":"transparent"},children:[e.jsx("div",{className:"text-[12px] font-semibold",style:{color:o===S.value?S.color:"var(--text-primary)"},children:S.label}),e.jsx("div",{className:"text-[10px] text-text-muted",children:S.desc})]},S.value))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"Scripts to Fix"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:_,className:"text-[10px] text-violet-400 hover:text-violet-300",children:"All"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"|"}),e.jsx("button",{onClick:U,className:"text-[10px] text-text-muted hover:text-text-secondary",children:"None"})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:ss.map(S=>e.jsxs("button",{onClick:()=>C(S),className:"px-2.5 py-1.5 rounded-md border text-[11px] font-medium text-left transition-all",style:{borderColor:u.includes(S)?"rgba(139,92,246,0.4)":"var(--border-subtle)",background:u.includes(S)?"rgba(139,92,246,0.08)":"transparent",color:u.includes(S)?"#a78bfa":"var(--text-secondary)"},children:[u.includes(S)?"☑ ":"☐ ",S]},S))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:["Additional Instructions ",e.jsx("span",{className:"text-text-muted font-normal",children:"(optional)"})]}),e.jsx("textarea",{value:c,onChange:S=>d(S.target.value),placeholder:"e.g. Shadow DOM 안의 버튼도 탐색해줘, readChat에서 코드블럭 포맷 유지해...",rows:2,className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] resize-none placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"})]})]}),(i==="running"||i==="done"||i==="error")&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Agent Output"}),e.jsxs("div",{className:"rounded-lg border border-border-subtle bg-[#0d0d0d] p-3 font-mono text-[11px] leading-relaxed text-text-secondary overflow-y-auto",style:{maxHeight:320,minHeight:200},children:[v.map((S,y)=>e.jsx("div",{className:S.startsWith("✅")?"text-green-400":S.startsWith("❌")||S.startsWith("⚠")?"text-amber-400":"",children:S},y)),i==="running"&&e.jsx("div",{className:"text-violet-400 animate-pulse mt-1",children:"● Running..."}),e.jsx("div",{ref:T})]}),x&&e.jsx("div",{className:"mt-2 px-3 py-2 rounded-lg bg-red-500/[0.06] border border-red-500/20 text-red-400 text-[11px]",children:x})]})]}),e.jsxs("div",{className:"px-5 py-3.5 border-t border-border-subtle flex justify-between items-center",children:[e.jsxs("div",{className:"text-[10px] text-text-muted",children:[i==="config"&&u.length>0&&`${u.length} script(s) selected`,i==="running"&&"Agent is working...",i==="done"&&"Run `adhdev provider verify` to validate"]}),e.jsxs("div",{className:"flex gap-2",children:[i==="config"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:r,className:"machine-btn",children:"Cancel"}),e.jsx("button",{onClick:I,disabled:u.length===0,className:"machine-btn",style:{background:u.length>0?"rgba(139,92,246,0.15)":void 0,borderColor:u.length>0?"rgba(139,92,246,0.4)":void 0,color:u.length>0?"#a78bfa":void 0,opacity:u.length===0?.4:1},children:"🚀 Start Fix"})]}),i==="running"&&e.jsx("button",{onClick:A,className:"machine-btn text-red-400 border-red-500/30",children:"⬛ Cancel"}),(i==="done"||i==="error")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{l("config"),j([]),M("")},className:"machine-btn",children:"← Back"}),e.jsx("button",{onClick:r,className:"machine-btn",children:"Close"})]})]})]})]})})}function wr({machineId:t,providers:s,sendDaemonCommand:a,onClose:r,onCreated:i}){var R;const l=s.filter(I=>I.category==="ide"),[o,m]=n.useState(((R=l[0])==null?void 0:R.type)||""),[u,p]=n.useState(""),[c,d]=n.useState(""),[v,j]=n.useState(!1),[x,M]=n.useState(""),[T,f]=n.useState(!1),C=I=>{const A=I.toLowerCase().replace(/[^a-z0-9-]/g,"");p(A),(!c||c===_(u))&&d(_(A))},_=I=>I.split("-").map(A=>A.charAt(0).toUpperCase()+A.slice(1)).join(" "),U=async()=>{if(!(!u||!c||!o)){j(!0),M("");try{const I=await a(t,"provider_clone",{type:u,name:c,category:"ide",location:"user",cloneFrom:o});I!=null&&I.success||I!=null&&I.created?(f(!0),i==null||i(u)):M((I==null?void 0:I.error)||"Failed to create provider")}catch(I){M((I==null?void 0:I.message)||"Connection failed")}j(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,children:e.jsxs("div",{className:"w-full max-w-[480px] rounded-2xl bg-bg-primary border border-border-subtle shadow-2xl flex flex-col",onClick:I=>I.stopPropagation(),children:[e.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle",children:[e.jsx("h2",{className:"text-[15px] font-semibold text-text-primary",children:"✨ Create User Provider"}),e.jsx("p",{className:"text-[11px] text-text-muted mt-0.5",children:"Clone an upstream IDE provider to customize"})]}),e.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:T?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"text-3xl mb-2",children:"🎉"}),e.jsx("h3",{className:"text-[14px] font-semibold text-text-primary",children:"Provider Created!"}),e.jsxs("p",{className:"text-[11px] text-text-muted mt-1",children:[e.jsx("code",{className:"text-violet-400",children:u})," has been created at ",e.jsxs("code",{className:"text-green-400",children:["~/.adhdev/providers/",u,"/"]})]}),e.jsxs("p",{className:"text-[11px] text-text-muted mt-2",children:["Run ",e.jsxs("code",{className:"text-violet-400",children:["adhdev provider fix ",u]})," or use Auto-Fix to implement scripts."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Base Provider"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:l.map(I=>e.jsxs("button",{onClick:()=>m(I.type),className:"px-2.5 py-2 rounded-lg border text-center transition-all",style:{borderColor:o===I.type?"rgba(139,92,246,0.4)":"var(--border-subtle)",background:o===I.type?"rgba(139,92,246,0.08)":"transparent"},children:[e.jsx("div",{className:"text-lg",children:I.icon}),e.jsx("div",{className:"text-[10px] font-medium mt-0.5",style:{color:o===I.type?"#a78bfa":"var(--text-secondary)"},children:I.displayName})]},I.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Provider Type (ID)"}),e.jsx("input",{value:u,onChange:I=>C(I.target.value),placeholder:"my-cursor, custom-windsurf...",className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"}),e.jsxs("p",{className:"text-[10px] text-text-muted mt-1",children:["Lowercase, alphanumeric + hyphens only. Will be created at ",e.jsxs("code",{className:"text-violet-400",children:["~/.adhdev/providers/",u||"...","/"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Display Name"}),e.jsx("input",{value:c,onChange:I=>d(I.target.value),placeholder:"My Custom IDE",className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"})]}),x&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-red-500/[0.06] border border-red-500/20 text-red-400 text-[11px]",children:x})]})}),e.jsx("div",{className:"px-5 py-3.5 border-t border-border-subtle flex justify-end gap-2",children:T?e.jsx("button",{onClick:r,className:"machine-btn",children:"Close"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:r,className:"machine-btn",children:"Cancel"}),e.jsx("button",{onClick:U,disabled:!u||!c||v,className:"machine-btn",style:{background:u&&c?"rgba(34,197,94,0.12)":void 0,borderColor:u&&c?"rgba(34,197,94,0.3)":void 0,color:u&&c?"#86efac":void 0,opacity:!u||!c||v?.4:1},children:v?"⏳ Creating...":"✨ Create Provider"})]})})]})})}function Nr({machineId:t,providers:s,sendDaemonCommand:a}){const[r,i]=n.useState([]),[l,o]=n.useState(!1),[m,u]=n.useState(null),[p,c]=n.useState("all"),[d,v]=n.useState(null),[j,x]=n.useState(!1),M=n.useCallback(async()=>{var f;if(t){o(!0);try{const C=await a(t,"get_provider_settings",{}),_=(C==null?void 0:C.result)||C;if(C!=null&&C.success&&(_!=null&&_.settings)){const U=[];for(const[R,I]of Object.entries(_.settings)){const A=s.find(S=>S.type===R);U.push({type:R,displayName:(A==null?void 0:A.displayName)||R,icon:(A==null?void 0:A.icon)||"",category:(A==null?void 0:A.category)||"unknown",schema:I,values:((f=_.values)==null?void 0:f[R])||{}})}U.sort((R,I)=>R.category.localeCompare(I.category)||R.displayName.localeCompare(I.displayName)),i(U)}}catch{}o(!1)}},[t,s,a]);n.useEffect(()=>{r.length===0&&M()},[]);const T=async(f,C,_)=>{u(`${f}.${C}`),i(U=>U.map(R=>R.type===f?{...R,values:{...R.values,[C]:_}}:R));try{const U=await a(t,"set_provider_setting",{providerType:f,key:C,value:_});U!=null&&U.success||M()}catch{M()}u(null)};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("div",{className:"flex gap-1 items-center",children:[e.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Filter"}),["all","acp","cli","ide","extension"].map(f=>e.jsx("button",{onClick:()=>c(f),className:`machine-btn text-[10px] px-2 py-0.5 ${p===f?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:f.toUpperCase()},f))]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:()=>x(!0),className:"machine-btn text-[10px] bg-green-500/[0.06] border-green-500/20 text-green-400 hover:bg-green-500/[0.12]",children:"✨ Create Provider"}),e.jsx("button",{onClick:M,disabled:l,className:"machine-btn",children:l?"⏳ Loading...":"↻ Refresh"})]})]}),p!=="all"&&r.filter(f=>f.category===p).length>1&&(()=>{const f=r.filter(R=>R.category===p),C=new Map;for(const R of f)for(const I of R.schema){if(I.type!=="boolean")continue;const A=C.get(I.key),S=!!(R.values[I.key]??I.default);A?(A.onCount+=S?1:0,A.total+=1):C.set(I.key,{label:I.label||I.key,onCount:S?1:0,total:1})}const _=[...C.entries()].filter(([,R])=>R.total===f.length);if(_.length===0)return null;const U=async(R,I)=>{for(const A of f)await T(A.type,R,I)};return e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-violet-500/[0.04] border border-violet-500/10 mb-4",children:[e.jsxs("div",{className:"text-[10px] text-violet-400 font-semibold uppercase tracking-wider mb-2",children:["Bulk — Apply to all ",p.toUpperCase()," providers (",f.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(([R,I])=>{const A=I.onCount===I.total,S=I.onCount===0;return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx("span",{className:"text-text-secondary font-medium",children:I.label}),e.jsxs("span",{className:"text-[9px] text-text-muted",children:["(",I.onCount,"/",I.total,")"]}),e.jsx("button",{onClick:()=>void U(R,!0),disabled:A,className:`machine-btn text-[9px] px-1.5 py-px ${A?"opacity-40":"text-green-400 border-green-500/30"}`,children:"All ON"}),e.jsx("button",{onClick:()=>void U(R,!1),disabled:S,className:`machine-btn text-[9px] px-1.5 py-px ${S?"opacity-40":"text-red-400 border-red-500/30"}`,children:"All OFF"})]},R)})})]})})(),l&&r.length===0?e.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading provider settings..."}):e.jsx("div",{className:"flex flex-col gap-2",children:r.filter(f=>p==="all"||f.category===p).map(f=>e.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[e.jsx("span",{className:"text-lg",children:f.icon}),e.jsx("span",{className:"font-semibold text-[13px] text-text-primary",children:f.displayName}),e.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:f.category==="acp"?"rgba(139,92,246,0.08)":f.category==="cli"?"rgba(59,130,246,0.08)":f.category==="ide"?"rgba(34,197,94,0.08)":"rgba(245,158,11,0.08)",color:f.category==="acp"?"#a78bfa":f.category==="cli"?"#60a5fa":f.category==="ide"?"#86efac":"#fbbf24"},children:f.category}),f.category==="ide"&&e.jsx("button",{onClick:()=>v(s.find(C=>C.type===f.type)||{type:f.type,displayName:f.displayName,icon:f.icon,category:f.category}),className:"ml-auto machine-btn text-[9px] px-2 py-0.5 bg-violet-500/[0.06] border-violet-500/20 text-violet-400 hover:bg-violet-500/[0.12]",children:"🔧 Auto-Fix"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:f.schema.map(C=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-xs font-medium text-text-primary",children:[C.label||C.key,m===`${f.type}.${C.key}`&&e.jsx("span",{className:"ml-1.5 text-[9px] text-violet-500",children:"saving..."})]}),C.description&&e.jsx("div",{className:"text-[10px] text-text-muted mt-px",children:C.description})]}),e.jsx("div",{className:"shrink-0",children:C.type==="boolean"?e.jsx("button",{onClick:()=>T(f.type,C.key,!(f.values[C.key]??C.default)),className:"w-10 h-[22px] rounded-[11px] border-none relative cursor-pointer transition-colors duration-200",style:{background:f.values[C.key]??C.default?"#8b5cf6":"var(--border-subtle)"},children:e.jsx("div",{className:"w-4 h-4 rounded-full bg-white absolute top-[3px] transition-[left] duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.3)]",style:{left:f.values[C.key]??C.default?21:3}})}):C.type==="number"?e.jsx("input",{type:"number",value:f.values[C.key]??C.default??0,min:C.min,max:C.max,onChange:_=>{const U=parseInt(_.target.value)||0;C.min!==void 0&&U<C.min||C.max!==void 0&&U>C.max||T(f.type,C.key,U)},className:"machine-input w-20 text-center text-[11px]"}):C.type==="select"&&C.options?e.jsx("select",{value:f.values[C.key]??C.default??"",onChange:_=>T(f.type,C.key,_.target.value),className:"machine-input text-[11px]",children:C.options.map(_=>e.jsx("option",{value:_,children:_},_))}):e.jsx("input",{type:"text",value:f.values[C.key]??C.default??"",onBlur:_=>T(f.type,C.key,_.target.value),className:"machine-input w-[120px] text-[11px]"})})]},C.key))})]},f.type))}),d&&e.jsx(vr,{machineId:t,provider:d,sendDaemonCommand:a,onClose:()=>v(null)}),j&&e.jsx(wr,{machineId:t,providers:s,sendDaemonCommand:a,onClose:()=>x(!1),onCreated:()=>{x(!1),M()}})]})}function kr({machineId:t,sendDaemonCommand:s}){const[a,r]=n.useState([]),[i,l]=n.useState(0),[o,m]=n.useState(!0),[u,p]=n.useState("debug"),c=n.useRef(null),d=n.useRef(!1);return n.useEffect(()=>{if(!t||!o)return;const v=async()=>{try{const x=await s(t,"get_logs",{count:200,minLevel:u,since:i}),M=(x==null?void 0:x.result)||x;if(x!=null&&x.success&&Array.isArray(M==null?void 0:M.logs)&&M.logs.length>0){r(f=>[...f,...M.logs.map(_=>({timestamp:_.ts,level:_.level,message:`[${_.category}] ${_.message}`}))].slice(-300));const T=Math.max(...M.logs.map(f=>f.ts));l(T)}}catch{}};v();const j=setInterval(v,3e3);return()=>clearInterval(j)},[t,o,i,u,s]),n.useEffect(()=>{if(o&&a.length>0){const v=d.current?"smooth":"instant";setTimeout(()=>{var j;(j=c.current)==null||j.scrollIntoView({behavior:v}),d.current=!0},50)}},[a.length,o]),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsxs("div",{className:"flex gap-1 items-center",children:[e.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Level"}),["debug","info","warn","error"].map(v=>e.jsx("button",{onClick:()=>{p(v),r([]),l(0)},className:`machine-btn text-[10px] px-2 py-0.5 ${u===v?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:v.toUpperCase()},v))]}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsxs("span",{className:"text-[10px] text-text-muted",children:[a.length," entries"]}),e.jsx("button",{onClick:()=>m(!o),className:`machine-btn ${o?"text-green-500 border-green-500/30":""}`,children:o?"⏸ Pause":"▶ Resume"}),e.jsx("button",{onClick:()=>{r([]),l(0)},className:"machine-btn",children:"Clear"})]})]}),e.jsxs("div",{className:"bg-bg-secondary border border-border-subtle rounded-xl p-3 min-h-[200px] max-h-[500px] overflow-y-auto font-mono text-[11px] leading-relaxed",children:[a.length===0&&e.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading daemon logs..."}),a.map((v,j)=>e.jsxs("div",{className:"flex gap-2 py-px",style:{color:v.level==="error"?"#ef4444":v.level==="warn"?"#f59e0b":v.level==="debug"?"#64748b":"#94a3b8"},children:[e.jsx("span",{className:"text-text-muted min-w-[75px] shrink-0",children:new Date(v.timestamp).toLocaleTimeString()}),e.jsx("span",{className:"font-semibold min-w-[32px] shrink-0 text-[9px]",style:{color:v.level==="error"?"#ef4444":v.level==="warn"?"#f59e0b":v.level==="debug"?"#475569":"#8b5cf6"},children:v.level==="error"?"ERR":v.level==="warn"?"WRN":v.level==="debug"?"DBG":"INF"}),e.jsx("span",{children:v.message})]},j)),e.jsx("div",{ref:c})]})]})}function Sr({machine:t,launchPick:s,actions:a}){const{runLaunchCliCore:r,setLaunchPick:i}=a;return e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/55 backdrop-blur-[2px]",role:"dialog","aria-modal":"true","aria-labelledby":"launch-pick-title",children:e.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border-subtle bg-bg-secondary shadow-xl p-5",children:[e.jsx("h2",{id:"launch-pick-title",className:"text-sm font-semibold text-text-primary m-0 mb-1",children:"Where should this run?"}),e.jsx("p",{className:"text-[11px] text-text-muted m-0 mb-4",children:"Nothing is assumed. Pick a saved workspace, your default workspace, or home — or cancel and type a path."}),e.jsx("div",{className:"flex flex-col gap-2 mb-4 max-h-48 overflow-y-auto",children:(t.workspaces||[]).length===0?e.jsx("span",{className:"text-[11px] text-text-muted",children:"No saved workspaces yet. Add one in Overview or type a path above."}):(t.workspaces||[]).map(l=>e.jsxs("button",{type:"button",className:"text-left text-xs px-3 py-2 rounded-lg border border-border-subtle bg-bg-primary hover:bg-violet-500/10 transition-colors",onClick:()=>{i(null),r({cliType:s.cliType,workspaceId:l.id,argsStr:s.argsStr,model:s.model})},children:[e.jsx("span",{className:"font-medium text-text-primary block truncate",children:l.label||l.path}),e.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate block",children:l.path})]},l.id))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",disabled:!t.defaultWorkspacePath,onClick:()=>{i(null),r({cliType:s.cliType,useDefaultWorkspace:!0,argsStr:s.argsStr,model:s.model})},children:"Default workspace"}),e.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",onClick:()=>{i(null),r({cliType:s.cliType,useHome:!0,argsStr:s.argsStr,model:s.model})},children:"Home directory"}),e.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[80px]",onClick:()=>i(null),children:"Cancel"})]})]})})}function Cr(){var U,R,I,A,S,y,B,W,z,Z;const{id:t}=is(),s=dt(),{sendCommand:a}=Ge(),r=vt(),i=r.ides||[],l=r.initialLoaded??!0,[o,m]=n.useState("overview"),u=n.useRef(null),p=gr({machineId:t,sendDaemonCommand:a,logsEndRef:u}),c=i.find(b=>b.id===t&&b.daemonMode),d=((c==null?void 0:c.availableProviders)||[]).map(b=>({type:b.type,displayName:b.displayName,icon:b.icon,category:b.category})),v={};for(const b of d)v[b.type]=b.icon;const j=b=>v[b]||"",x=c?{id:c.id,hostname:((U=c.machine)==null?void 0:U.hostname)||c.id,platform:((R=c.machine)==null?void 0:R.platform)||"unknown",arch:((I=c.machine)==null?void 0:I.arch)||"",cpus:((A=c.machine)==null?void 0:A.cpus)||0,totalMem:((S=c.machine)==null?void 0:S.totalMem)||0,freeMem:((y=c.machine)==null?void 0:y.freeMem)||0,availableMem:(B=c.machine)==null?void 0:B.availableMem,loadavg:((W=c.machine)==null?void 0:W.loadavg)||[],uptime:((z=c.machine)==null?void 0:z.uptime)||0,release:((Z=c.machine)==null?void 0:Z.release)||"",cdpConnected:!!(c.ides||[]).some(b=>b.cdpConnected),machineNickname:c.machineNickname||null,p2p:c.p2p||{available:!1,state:"unavailable",peers:0,screenshotActive:!1},detectedIdes:c.detectedIdes||[],managedIdeIds:c.managedIdeIds||[],managedCliIds:c.managedCliIds||[],workspaces:c.workspaces||[],defaultWorkspaceId:c.defaultWorkspaceId??c.activeWorkspaceId??null,defaultWorkspacePath:c.defaultWorkspacePath??c.activeWorkspacePath??null,workspaceActivity:c.workspaceActivity||[]}:null,M=i.filter(b=>b.daemonId===t&&!b.daemonMode).filter(b=>!Gt(b)&&!Xt(b)).map(b=>({id:b.id,type:b.type,version:b.version||"",instanceId:b.instanceId||"",status:b.status,workspace:b.workspace||null,terminals:b.terminals||0,aiAgents:vn(b.aiAgents||b.agents||[]),activeChat:b.activeChat||null,chats:b.chats||[],agentStreams:b.agentStreams||[],cdpConnected:b.cdpConnected||!1,daemonId:t})),T=i.filter(b=>b.daemonId===t&&Gt(b)).map(b=>({id:b.id,type:b.type,cliName:b.cliName||b.type,status:b.status,workspace:b.workspace||"",activeChat:b.activeChat||null,daemonId:t})),f=i.filter(b=>b.daemonId===t&&Xt(b)).map(b=>({id:b.id,type:b.type,acpName:b.cliName||b.type,status:b.status,workspace:b.workspace||"",activeChat:b.activeChat||null,currentModel:b.currentModel,currentPlan:b.currentPlan,daemonId:t}));if(!x)return l?e.jsxs("div",{className:"p-10 text-center text-text-muted",children:[e.jsx("h2",{className:"text-text-primary",children:"Machine not found"}),e.jsx("p",{className:"mt-3",children:"The machine may be offline or not yet connected."}),e.jsx("button",{onClick:()=>s("/machines"),className:"machine-btn-back",children:"← Back to Burrows"})]}):e.jsx("div",{className:"p-10 text-center text-text-muted",children:e.jsx("p",{children:"⏳ Loading machine..."})});const C=x.machineNickname||x.hostname,_=[{id:"overview",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(sn,{size:14})," Overview"]})},{id:"ides",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ut,{size:14})," IDEs"]}),count:M.length},{id:"clis",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ms,{size:14})," CLIs"]}),count:T.length},{id:"acps",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(hs,{size:14})," ACP Agents"]}),count:f.length},{id:"providers",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(us,{size:14})," Providers"]})},{id:"logs",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Vs,{size:14})," Logs"]})}];return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"dashboard-header !flex-col !items-stretch",children:[e.jsx("div",{className:"flex items-center justify-between w-full",children:e.jsxs("div",{className:"flex items-center gap-2 md:gap-3.5 w-full min-w-0",children:[e.jsx("button",{onClick:()=>s("/machines"),className:"machine-btn-back flex shrink-0",children:"←"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[p.editingNickname?e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("input",{autoFocus:!0,value:p.nicknameInput,onChange:b=>p.setNicknameInput(b.target.value),onKeyDown:b=>{b.key==="Enter"&&p.handleSaveNickname(),b.key==="Escape"&&p.setEditingNickname(!1)},placeholder:"Machine nickname...",className:"px-2.5 py-1 rounded-md border border-violet-500/30 bg-bg-secondary text-text-primary text-sm font-semibold w-[140px] md:w-[200px]"}),e.jsx("button",{onClick:p.handleSaveNickname,className:"machine-btn text-green-500 border-green-500/30 shrink-0",children:"✓"}),e.jsx("button",{onClick:()=>p.setEditingNickname(!1),className:"machine-btn shrink-0",children:"✕"})]}):e.jsx("h1",{className:"header-title cursor-pointer truncate",onClick:()=>{p.setEditingNickname(!0),p.setNicknameInput(x.machineNickname||"")},title:"Click to set nickname",children:C}),e.jsx("span",{className:"status-dot-md online shrink-0"})]}),e.jsxs("div",{className:"header-subtitle mt-1 flex-wrap gap-1 md:gap-2 items-center display-none-mobile",children:[e.jsxs("span",{children:[x.platform," · ",x.arch," · ",x.cpus," cores"]}),(c==null?void 0:c.version)&&e.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-bg-glass border border-border-subtle text-text-muted shrink-0",children:["v",c.version]}),(c==null?void 0:c.versionMismatch)&&e.jsxs("button",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-amber-500/[0.08] border border-amber-500/20 text-amber-400 cursor-pointer hover:bg-amber-500/[0.15] transition-colors shrink-0",onClick:async()=>{try{await a(t,"daemon_upgrade",{})}catch{}},children:["🔄 Update to v",c.serverVersion]}),x.p2p.available&&e.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:x.p2p.state==="connected"?"rgba(34,197,94,0.08)":"rgba(234,179,8,0.08)",color:x.p2p.state==="connected"?"#22c55e":"#eab308"},children:["P2P ",x.p2p.state==="connected"?`● ${x.p2p.peers}`:"○"]}),x.cdpConnected&&e.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-green-500/[0.08] text-green-500 shrink-0",children:"CDP ●"}),x.machineNickname&&e.jsxs("span",{className:"text-text-muted opacity-80 shrink-0",children:["(",x.hostname,")"]})]})]})]})}),e.jsx("div",{className:"machine-tabs w-full overflow-x-auto overflow-y-hidden pb-1 -mb-1 mt-2",children:_.map(b=>e.jsxs("button",{onClick:()=>m(b.id),className:`machine-tab shrink-0${o===b.id?" active":""}`,children:[b.label,b.count!==void 0&&e.jsx("span",{className:"tab-count",children:b.count})]},b.id))})]}),e.jsxs("div",{className:"page-content",children:[o==="overview"&&e.jsx(br,{machine:x,managedIdes:M,managedClis:T,managedAcps:f,actions:p}),o==="ides"&&e.jsx(Et,{category:"ide",machine:x,machineId:t,providers:d,managedEntries:M,getIcon:j,actions:p,sendDaemonCommand:a}),o==="clis"&&e.jsx(Et,{category:"cli",machine:x,machineId:t,providers:d,managedEntries:T,getIcon:j,actions:p}),o==="acps"&&e.jsx(Et,{category:"acp",machine:x,machineId:t,providers:d,managedEntries:f,getIcon:j,actions:p}),o==="providers"&&e.jsx(Nr,{machineId:t,providers:d,sendDaemonCommand:a}),o==="logs"&&e.jsx(kr,{machineId:t,sendDaemonCommand:a})]}),p.launchPick&&x&&e.jsx(Sr,{machine:x,launchPick:p.launchPick,actions:p})]})}function Ir(){if(typeof window>"u")return"ws://localhost:3847/ws";const s=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,r=new URLSearchParams(window.location.search).get("token");return r?`${s}?token=${encodeURIComponent(r)}`:s}const ns=Ir(),rs=3e3,Mr=3e4;let Fe=null,Tr=0;const jt=new Map,Bt=new Set;let qe=null,Er=null,ot=null;async function bt(t,s,a){const r=Fe;if(r&&r.readyState===WebSocket.OPEN){const l=`req_${++Tr}_${Date.now()}`;return new Promise((o,m)=>{const u=setTimeout(()=>{jt.delete(l),m(new Error(`WS command timeout: ${s}`))},3e4);jt.set(l,{resolve:p=>{clearTimeout(u),o(p)},reject:p=>{clearTimeout(u),m(p)}}),r.send(JSON.stringify({type:"command",requestId:l,data:{type:s,payload:a||{},target:t}}))})}const i=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:s,payload:a||{},target:t})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()}class $r{constructor(s){$e(this,"daemonId");$e(this,"screenshotIdeType",null);this.daemonId=s}get hasCommandChannel(){return(Fe==null?void 0:Fe.readyState)===WebSocket.OPEN}get connectionState(){return(Fe==null?void 0:Fe.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(s,a){return bt(this.daemonId,s,a)}async sendInput(s,a){const r=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId;return bt(r,"cdp_remote_action",{action:s,params:a})}startScreenshots(s){this.screenshotIdeType=s||null,qe&&(clearInterval(qe),qe=null);const a=async()=>{if(this.hasCommandChannel)try{const r=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId,i=await bt(r,"screenshot",{width:1280});if(i!=null&&i.success&&(i!=null&&i.base64)){const l=await fetch(`data:image/jpeg;base64,${i.base64}`).then(o=>o.blob());Bt.forEach(o=>o(this.daemonId,l))}}catch{}};a(),qe=setInterval(a,2e3)}stopScreenshots(s){qe&&(clearInterval(qe),qe=null)}}let Je=null;function Ar(t){(!Je||Je.daemonId!==t)&&(Je=new $r(t));const s=Ae._originalGet||Ae.get.bind(Ae);Ae._originalGet=s,Ae.get=a=>a===t||a.startsWith("standalone")?Je:s(a),Ae.getState=a=>(a===t||a.startsWith("standalone"))&&(Je==null?void 0:Je.connectionState)||"disconnected",Ae.onScreenshot=(a,r)=>(Bt.add(r),()=>{Bt.delete(r)})}function _r({children:t}){const s=n.useRef(Ht()),a=Ht();s.current=a;const{setUserName:r}=it(),i=n.useRef(r);i.current=r;const[,l]=n.useState("disconnected"),o=n.useCallback((d,v)=>{l(d),ot==null||ot(d,v)},[]),m=n.useRef(null),u=n.useRef(),p=n.useRef(rs),c=n.useRef(!0);return n.useEffect(()=>{c.current=!0;function d(){var x,M;if(!c.current||((x=m.current)==null?void 0:x.readyState)===WebSocket.OPEN||((M=m.current)==null?void 0:M.readyState)===WebSocket.CONNECTING)return;o("connecting"),console.log(`[Standalone WS] Connecting to ${ns}...`);let j;try{j=new WebSocket(ns)}catch(T){console.error("[Standalone WS] Failed to create WebSocket:",T),v();return}m.current=j,j.onopen=()=>{if(!c.current){j.close();return}o("connected"),p.current=rs,console.log("[Standalone WS] Connected")},Fe=j,j.onmessage=T=>{var f;try{const C=JSON.parse(T.data);if((C.type==="command_result"||C.type==="error")&&C.requestId){const _=jt.get(C.requestId);_&&(jt.delete(C.requestId),C.type==="error"?_.reject(new Error(((f=C.data)==null?void 0:f.message)||"Command failed")):_.resolve(C.data));return}if(C.type==="status"||C.type==="initial_state"){const _=C.data;if(!_)return;const{injectEntries:U,markLoaded:R}=s.current,I=_.id||"standalone";Er=I,Ar(I),o("connected",I);const A=In(_,{daemonId:I});A.length>0&&U(A),R(),_.userName&&i.current&&i.current(_.userName)}}catch(C){console.error("[Standalone WS] Parse error:",C)}},j.onclose=()=>{c.current&&(o("disconnected"),m.current=null,v())},j.onerror=T=>{console.warn("[Standalone WS] Error, will reconnect:",T)}}function v(){if(!c.current)return;clearTimeout(u.current);const j=p.current;console.log(`[Standalone WS] Reconnecting in ${j}ms...`),u.current=setTimeout(()=>{p.current=Math.min(p.current*1.5,Mr),d()},j)}return d(),()=>{c.current=!1,clearTimeout(u.current),m.current&&(m.current.onclose=null,m.current.close(),m.current=null,Fe=null)}},[]),e.jsx(e.Fragment,{children:t})}function Rr({children:t}){const[s,a]=n.useState("disconnected"),[r,i]=n.useState(null);n.useEffect(()=>(ot=(o,m)=>{a(o),m&&i(m)},()=>{ot=null}),[]);const l=n.useMemo(()=>{const o=s==="connected",m={};return r&&(m[r]=o?"connected":"connecting"),m.standalone=o?"connected":"connecting",{wsStatus:s,isConnected:o,connectionStates:m}},[s,r]);return e.jsx(Fs,{connectionOverrides:l,children:e.jsx(_r,{children:t})})}const Pr=[{id:"dashboard",path:"/dashboard",icon:e.jsx(Gs,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:e.jsx(Xs,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:e.jsx(us,{}),label:"Settings"}];function Lr({children:t}){const s=dt(),a=Rs(),[r,i]=n.useState(!1),[l,o]=n.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),m=c=>{s(c),i(!1)},u=()=>{o(c=>{const d=!c;try{localStorage.setItem("sidebar-collapsed",d?"1":"0")}catch{}return d})},p=c=>`nav-item${a.pathname.startsWith(c)?" active":""} cursor-pointer ${l?"justify-center py-2.5 px-0":""}`;return e.jsxs("div",{className:`app-layout${r?" mobile-menu-open":""}${l?" sidebar-collapsed":""}`,children:[e.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>i(!0),children:[e.jsx("span",{className:"mobile-menu-icon"}),e.jsx("span",{className:"mobile-menu-icon"}),e.jsx("span",{className:"mobile-menu-icon"})]}),r&&e.jsx("div",{className:"sidebar-overlay",role:"button",tabIndex:0,"aria-label":"Close menu",onClick:()=>i(!1),onKeyDown:c=>c.key==="Escape"&&i(!1)}),e.jsxs("aside",{className:`sidebar ${r?"sidebar-open":""}`,children:[e.jsxs("div",{className:"sidebar-header",children:[e.jsxs("div",{className:`sidebar-logo ${l?"justify-center gap-0":""}`,children:[e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-7 h-7"}),!l&&e.jsx("span",{children:"ADHDev"})]}),e.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>i(!1),children:"✕"})]}),e.jsx("nav",{className:"sidebar-nav",children:Pr.map(c=>e.jsxs("div",{className:p(c.path),id:`nav-${c.id}`,onClick:()=>m(c.path),title:l?c.label:void 0,children:[e.jsx("span",{className:"nav-icon",children:c.icon}),!l&&c.label]},c.id))}),e.jsxs("div",{className:"border-t border-border-subtle pt-4 mt-2",children:[e.jsxs("div",{className:`nav-item cursor-pointer${a.pathname==="/about"?" active":""} ${l?"justify-center py-2.5 px-0":""}`,id:"nav-about",onClick:()=>s("/about"),title:l?"About":void 0,children:[e.jsx("span",{className:"nav-icon",children:e.jsx(qs,{})}),!l&&"About"]}),!l&&e.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.6.46"]}),e.jsxs("div",{className:`nav-item cursor-pointer ${l?"justify-center py-2.5 px-0":"mt-1"}`,onClick:u,title:l?"Expand sidebar":"Collapse sidebar",children:[e.jsx("span",{className:"nav-icon text-base",children:l?"›":"‹"}),!l&&e.jsx("span",{className:"text-xs",children:"Collapse"})]})]})]}),e.jsx("main",{className:"main-content relative",children:e.jsx("div",{className:"main-content-inner",children:t})})]})}const Dr=[{icon:"🏠",title:"Local-first",desc:"Everything runs on your machine. No data leaves your network. Full privacy by design."},{icon:"💬",title:"Agent chat relay",desc:"Read and respond to AI conversations in real-time across all connected IDEs."},{icon:"📸",title:"Live screenshots",desc:"View your IDE screens directly in the browser via local WebSocket streaming."},{icon:"🎛️",title:"Remote control",desc:"Click, type, and interact with your IDE from the dashboard — no window switching."},{icon:"🔌",title:"Multi-IDE support",desc:"Monitor and control multiple IDEs simultaneously — VS Code, Cursor, Windsurf, and more."},{icon:"⚡",title:"Extension agents",desc:"Manage extension-based agents like Cline and Roo Code alongside native IDE agents."}],Br=[{icon:"🌍",title:"Access from anywhere",desc:"Control your agents from any device, any network. No VPN or port forwarding needed."},{icon:"🔗",title:"WebRTC P2P streaming",desc:"End-to-end encrypted peer-to-peer connection for zero-latency remote screenshots and control."},{icon:"📱",title:"Mobile notifications",desc:"Get push notifications when agents need approval. Quick approve/reject from your phone."},{icon:"📡",title:"REST API access",desc:"Integrate with Slack, CI/CD pipelines, or custom tools. Scoped API keys with granular permissions."},{icon:"👥",title:"Team dashboard",desc:"Share a unified view across your team. See who's running what, where, in real time."},{icon:"🔐",title:"Enterprise security",desc:"SSO, RBAC, audit logs, and SLA guarantees for production teams."}],Wr=[{feature:"Agent chat relay",selfhost:!0,cloud:!0},{feature:"Live IDE screenshots",selfhost:!0,cloud:!0},{feature:"Remote IDE control",selfhost:!0,cloud:!0},{feature:"Multi-IDE monitoring",selfhost:!0,cloud:!0},{feature:"Extension agent support",selfhost:!0,cloud:!0},{feature:"CLI agent support",selfhost:!0,cloud:!0},{feature:"Access from any network",selfhost:!1,cloud:!0},{feature:"WebRTC P2P streaming",selfhost:!1,cloud:!0},{feature:"Mobile push notifications",selfhost:!1,cloud:!0},{feature:"REST API & webhooks",selfhost:!1,cloud:!0},{feature:"Team collaboration",selfhost:!1,cloud:!0},{feature:"Multi-machine (Burrows)",selfhost:!1,cloud:!0},{feature:"SSO / RBAC / Audit logs",selfhost:!1,cloud:!0}],$t={ides:["VS Code","Cursor","Antigravity","Windsurf","Trae","PearAI","Kiro","VSCodium","VS Code Insiders"],agents:["GitHub Copilot","Cline","Roo Code"],cli:["Gemini CLI","Claude Code","Codex CLI"]};function Or(){return e.jsxs("div",{className:"py-8 px-6 max-w-[860px] mx-auto text-text-primary",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-14 h-14 mb-3 mx-auto"}),e.jsx("h1",{className:"text-[26px] font-extrabold mb-1.5 text-text-primary",children:"ADHDev"}),e.jsx("p",{className:"text-[13px] text-text-muted",children:"Agent Dashboard Hub for Dev — Self-hosted Edition"}),e.jsxs("div",{className:"inline-block mt-3 px-3 py-1 text-[11px] font-semibold tracking-wide rounded-full bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:["SELFHOST v","0.6.46"]})]}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"✅"})," What's included"]}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-3",children:Dr.map(t=>e.jsxs("div",{className:"bg-bg-glass border border-border-subtle rounded-xl px-4 py-4 transition-colors hover:border-border-default",children:[e.jsx("div",{className:"text-xl mb-1.5",children:t.icon}),e.jsx("div",{className:"font-semibold text-[13px] mb-1",children:t.title}),e.jsx("div",{className:"text-[12px] text-text-muted leading-relaxed",children:t.desc})]},t.title))})]}),e.jsxs("section",{className:"mb-10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4",children:"Compatible with"}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-5",children:[{label:"IDEs",items:$t.ides},{label:"Extension agents",items:$t.agents},{label:"CLI agents",items:$t.cli}].map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-bold tracking-wider text-text-muted mb-2 uppercase",children:t.label}),e.jsx("div",{className:"flex flex-col gap-1",children:t.items.map(s=>e.jsx("div",{className:"text-[12px] px-2.5 py-1.5 bg-bg-glass rounded-md border border-border-subtle",children:s},s))})]},t.label))})]}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"⚖️"})," Self-hosted vs Cloud"]}),e.jsx("div",{className:"rounded-xl border border-border-subtle overflow-hidden",children:e.jsxs("table",{className:"w-full text-[13px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-bg-secondary",children:[e.jsx("th",{className:"text-left px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider",children:"Feature"}),e.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider w-[100px]",children:"Selfhost"}),e.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-[11px] uppercase tracking-wider w-[100px] text-violet-500",children:"Cloud"})]})}),e.jsx("tbody",{children:Wr.map((t,s)=>e.jsxs("tr",{className:s%2===0?"bg-bg-glass":"",children:[e.jsx("td",{className:"px-4 py-2 text-text-secondary",children:t.feature}),e.jsx("td",{className:"text-center px-4 py-2",children:t.selfhost?e.jsx("span",{className:"text-emerald-500",children:"✓"}):e.jsx("span",{className:"text-text-muted opacity-40",children:"—"})}),e.jsx("td",{className:"text-center px-4 py-2",children:e.jsx("span",{className:"text-emerald-500",children:"✓"})})]},t.feature))})]})})]}),e.jsx("section",{className:"mb-10",children:e.jsx("div",{className:"rounded-2xl border border-violet-500/20 bg-violet-500/[0.04] px-6 py-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"text-3xl shrink-0",children:"🚀"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-bold text-[15px] mb-1.5",children:"Unlock more with ADHDev Cloud"}),e.jsx("p",{className:"text-[13px] text-text-muted leading-relaxed mb-4",children:"Access your agents from anywhere — your phone, another laptop, or a coffee shop. Cloud adds WebRTC P2P streaming, mobile push notifications, REST API, team collaboration, and multi-machine support. Your local setup stays exactly the same."}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-2.5 mb-5",children:Br.map(t=>e.jsxs("div",{className:"flex gap-2.5 items-start",children:[e.jsx("span",{className:"text-base shrink-0 mt-0.5",children:t.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-[12px]",children:t.title}),e.jsx("div",{className:"text-[11px] text-text-muted leading-snug",children:t.desc})]})]},t.title))}),e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[e.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Try ADHDev Cloud →"}),e.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"GitHub"}),e.jsx("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Discord"})]})]})]})})}),e.jsxs("div",{className:"text-center text-xs text-text-muted pt-4 border-t border-border-subtle",children:[e.jsx("p",{children:"© 2026 RacoLab · ADHDev, Your AI sidekick otter 🦦"}),e.jsx("p",{className:"mt-1 opacity-60",children:"Self-hosted edition — all data stays on your machine"})]})]})}function Kr(){const{ides:t}=it(),s=t.find(d=>d.type==="adhdev-daemon"),a=(s==null?void 0:s.detectedIdes)||[],{sendCommand:r}=Ge(),{userName:i}=it(),[l,o]=n.useState(i||"");n.useEffect(()=>{i!==void 0&&o(i)},[i]);const m=d=>{const v=d.target.value.trim();s!=null&&s.id&&v!==i&&r(s.id,"set_user_name",{userName:v}).catch(console.error)},[u,p]=n.useState(()=>{try{return localStorage.getItem("adhdev_sound")!=="0"}catch{return!0}}),c=d=>{p(d);try{localStorage.setItem("adhdev_sound",d?"1":"0")}catch{}};return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(Bn,{icon:"⚙️",title:"Settings",subtitle:"Local daemon configuration & preferences"}),e.jsxs("div",{className:"page-content",children:[e.jsx(et,{title:"Daemon",className:"mb-4",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-x-4 gap-y-2.5 text-sm",children:[e.jsx("span",{className:"text-text-muted",children:"Version"}),e.jsxs("span",{className:"font-mono text-xs",children:["v","0.6.46"]}),e.jsx("span",{className:"text-text-muted",children:"Status"}),e.jsx("span",{className:s?"text-green-400":"text-yellow-400",children:s?"● Running":"○ Not connected"}),e.jsx("span",{className:"text-text-muted",children:"WebSocket"}),e.jsx("span",{className:"font-mono text-xs",children:"ws://localhost:19222"}),e.jsx("span",{className:"text-text-muted",children:"HTTP"}),e.jsx("span",{className:"font-mono text-xs",children:"http://localhost:19280"})]})}),e.jsx(et,{title:"Detected IDEs",className:"mb-4",children:a.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:"No IDEs detected. Start an IDE to see it here."}):e.jsx("div",{className:"flex flex-col gap-1.5",children:a.map(d=>e.jsxs("div",{className:"flex justify-between items-center bg-bg-glass rounded-lg px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${d.running?"bg-green-400":"bg-text-muted/30"}`}),e.jsx("span",{className:"text-sm font-medium",children:d.name})]}),e.jsx("span",{className:"text-[11px] text-text-muted font-mono",children:d.type})]},d.type))})}),e.jsx(et,{title:"Machine",className:"mb-4",children:e.jsx(Yn,{ides:t,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),e.jsx(et,{title:"Theme",className:"mb-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Site theme"}),e.jsx(Jn,{})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[e.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Chat theme"}),e.jsx(nr,{})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[e.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Accent color"}),e.jsx(lr,{})]})]})}),e.jsx(et,{title:"Notifications",className:"mb-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Un,{}),e.jsx(tt,{label:"🔊 Sound Effects",description:"Play a sound when agent completes or needs approval",checked:u,onChange:c})]})}),e.jsx(et,{title:"Preferences",className:"mb-4",children:e.jsx("div",{className:"flex flex-col gap-3",children:e.jsxs("div",{className:"flex items-center justify-between px-3.5 py-4 bg-bg-glass rounded-xl border border-border-subtle hover:border-border-default transition-colors",children:[e.jsxs("div",{className:"flex flex-col gap-1 pr-4 max-w-[500px]",children:[e.jsx("span",{className:"text-sm font-semibold flex items-center gap-2",children:"👤 Display Name"}),e.jsx("span",{className:"text-[12px] text-text-muted leading-relaxed",children:"Your name shown in chat threads and on the team dashboard."})]}),e.jsx("input",{type:"text",className:"bg-bg-primary border border-border-strong rounded-lg px-3 py-1.5 text-sm w-48 text-right focus:border-accent focus:outline-none transition-colors",placeholder:"Anonymous",value:l,onChange:d=>o(d.target.value),onBlur:m,onKeyDown:d=>{d.key==="Enter"&&d.currentTarget.blur()}})]})})})]})]})}tr();function as(){const{ides:t}=it(),s=t.find(a=>{var r;return a.daemonMode||((r=a.id)==null?void 0:r.startsWith("standalone"))});return s?e.jsx(pt,{to:`/machines/${s.id}`,replace:!0}):t.length>0?e.jsx(pt,{to:`/machines/${t[0].id}`,replace:!0}):e.jsx(pt,{to:"/dashboard",replace:!0})}function Fr(){return e.jsx(Ps,{children:e.jsx(Rr,{children:e.jsx(Ys,{value:{sendCommand:bt,sendData:()=>!1},children:e.jsx(Lr,{children:e.jsxs(Ls,{children:[e.jsx(Ue,{path:"/dashboard",element:e.jsx(pr,{})}),e.jsx(Ue,{path:"/ide/:id",element:e.jsx(fr,{})}),e.jsx(Ue,{path:"/machine",element:e.jsx(as,{})}),e.jsx(Ue,{path:"/machines/:id",element:e.jsx(Cr,{})}),e.jsx(Ue,{path:"/machines",element:e.jsx(as,{})}),e.jsx(Ue,{path:"/about",element:e.jsx(Or,{})}),e.jsx(Ue,{path:"/settings",element:e.jsx(Kr,{})}),e.jsx(Ue,{path:"*",element:e.jsx(pt,{to:"/dashboard",replace:!0})})]})})})})})}Ds(document.getElementById("root")).render(e.jsx(n.StrictMode,{children:e.jsx(Fr,{})}));
package/public/index.html CHANGED
@@ -7,7 +7,7 @@
7
7
  <meta name="description" content="ADHDev self-hosted dashboard for controlling AI agents" />
8
8
  <link rel="icon" href="/otter-logo.png" />
9
9
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
10
- <script type="module" crossorigin src="/assets/index-BB6cuGO5.js"></script>
10
+ <script type="module" crossorigin src="/assets/index-DUodBzek.js"></script>
11
11
  <link rel="modulepreload" crossorigin href="/assets/vendor-Df99lqBA.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/terminal-Dm9LBRva.js">
13
13
  <link rel="stylesheet" crossorigin href="/assets/terminal-6GBZ9nXN.css">