@adhdev/daemon-standalone 0.7.33 → 0.7.35
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 +1 -1
- package/public/assets/{index-t8wLPphm.js → index-C7E9_cbK.js} +3 -3
- package/public/index.html +1 -1
- package/vendor/session-host-daemon/index.js +25 -4
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +25 -4
- package/vendor/session-host-daemon/index.mjs.map +1 -1
|
@@ -39,7 +39,7 @@ var wn=Object.defineProperty;var kn=(t,s,n)=>s in t?wn(t,s,{enumerable:!0,config
|
|
|
39
39
|
}
|
|
40
40
|
`})]})}function Ks({activeConv:t,onModalButton:s}){const[n,r]=o.useState(null);if(o.useEffect(()=>{r(null)},[t.modalMessage,t.status]),t.status!=="waiting_approval"||!t.modalButtons)return null;const a=i=>{n||(r(i),s(i))},c=i=>i.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim();return e.jsxs("div",{className:"text-white py-2.5 px-4 shrink-0 z-[5]",style:{background:"linear-gradient(135deg, var(--status-warning), color-mix(in srgb, var(--status-warning) 85%, #000))"},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(Ut,{size:14})," ",n?"PROCESSING...":"ACTION REQUIRED"]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:t.modalButtons.map((i,h)=>{const l=c(i).toLowerCase(),x=/^(run|approve|accept|yes|allow|always)/.test(l),d=/^(reject|deny|delete|remove|abort)/.test(l),f=n===i,b=n!==null;return e.jsx("button",{onClick:()=>a(i),disabled:b,className:`btn btn-sm border-none rounded-md text-xs px-3 py-1 ${x?"bg-white font-extrabold":d?"bg-red-500/30 text-white font-semibold":"bg-white/15 text-white font-semibold"} ${b&&!f?"opacity-40":"opacity-100"} ${b?"cursor-not-allowed":"cursor-pointer"}`,style:x?{color:"var(--status-warning)"}:void 0,children:f?"⏳ ...":c(i)},h)})})]})]})}const Ne=new Map;function gr({ideId:t,sessionId:s,ideType:n,providerType:r,displayLabel:a,serverModel:c,serverMode:i,acpConfigOptions:h,acpModes:l}){var ce;const{sendCommand:x}=$e(),d=!!(h||l),f=`${t}:${s||r}`,b=Ne.get(f),[u,m]=o.useState(!1),[v,N]=o.useState(!1),[g,p]=o.useState((b==null?void 0:b.models)||[]),[w,T]=o.useState((b==null?void 0:b.modes)||[]),y=B=>B?typeof B=="string"?B:typeof B=="object"?B.name||B.id||JSON.stringify(B):String(B):"",[S,k]=o.useState(y(c)),[j,_]=o.useState(y(i)),[R,D]=o.useState(!1),[M,E]=o.useState(!1),$=o.useRef(0),O=B=>B.map(P=>typeof P=="string"?P:(P==null?void 0:P.name)||(P==null?void 0:P.id)||String(P));o.useEffect(()=>{if(h){const B=h.find(P=>P.category==="model");if(B){const P=O(B.options.map(L=>L.value));p(P),B.currentValue&&k(y(B.currentValue));const A=Ne.get(f)||{models:[],modes:[]};Ne.set(f,{...A,models:P})}}if(l&&l.length>0){const B=O(l.map(A=>A.id));T(B);const P=Ne.get(f)||{models:[],modes:[]};Ne.set(f,{...P,modes:B})}else if(h){const B=h.find(P=>P.category!=="model");if(B){const P=O(B.options.map(L=>L.value));T(P),B.currentValue&&_(y(B.currentValue));const A=Ne.get(f)||{models:[],modes:[]};Ne.set(f,{...A,modes:P})}}},[h,l,f]),o.useEffect(()=>{m(!1),N(!1),k(y(c)),_(y(i));const B=Ne.get(f);B?(p(B.models),T(B.modes)):(p([]),T([]))},[t,r,s]),o.useEffect(()=>{c&&Date.now()>$.current&&k(y(c))},[c]),o.useEffect(()=>{i&&Date.now()>$.current&&_(y(i))},[i]);const C=o.useCallback(async(B,P={})=>{const A={...P,...s&&{targetSessionId:s}};return await x(t,B,A)},[t,s,x]),V=async()=>{var B,P;if(g.length>0){m(!u);return}if(d){m(!0);return}D(!0);try{const A=await C("list_extension_models",{agentType:r,ideType:n}),L=(A==null?void 0:A.models)||((B=A==null?void 0:A.result)==null?void 0:B.models)||[],W=O(L);p(W),A!=null&&A.current&&k(y(A.current)),(P=A==null?void 0:A.result)!=null&&P.current&&k(y(A.result.current));const U=Ne.get(f)||{models:[],modes:[]};Ne.set(f,{...U,models:W}),m(!0)}catch{}finally{D(!1)}},Z=async()=>{var B,P;if(w.length>0){N(!v);return}if(d){N(!0);return}E(!0);try{const A=await C("list_extension_modes",{agentType:r,ideType:n}),L=(A==null?void 0:A.modes)||((B=A==null?void 0:A.result)==null?void 0:B.modes)||[],W=O(L);T(W),A!=null&&A.current&&_(y(A.current)),(P=A==null?void 0:A.result)!=null&&P.current&&_(y(A.result.current));const U=Ne.get(f)||{models:[],modes:[]};Ne.set(f,{...U,modes:W}),N(!0)}catch{}finally{E(!1)}},J=async B=>{m(!1),k(B),$.current=Date.now()+5e3;try{d?await C("change_model",{agentType:r,ideType:n,model:B}):await C("set_extension_model",{agentType:r,ideType:n,model:B})}catch{}},G=d&&!(l&&l.length>0)&&(h==null?void 0:h.some(B=>B.category!=="model")),Q=G?(ce=h==null?void 0:h.find(B=>B.category!=="model"))==null?void 0:ce.configId:void 0,Y=async B=>{N(!1),_(B),$.current=Date.now()+5e3;try{d&&G&&Q?await C("set_thought_level",{agentType:r,ideType:n,configId:Q,value:B}):d?await C("set_mode",{agentType:r,ideType:n,mode:B}):await C("set_extension_mode",{agentType:r,ideType:n,mode:B})}catch{}},ee={cline:"#22d3ee","roo-code":"#a78bfa",cursor:"#60a5fa",antigravity:"#f97316",windsurf:"#34d399"}[r]||"#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 opacity-70",style:{color:ee},children:a}),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:u?`${ee}55`:"transparent",border:"1px solid",color:S?"var(--text-primary)":"var(--text-muted)"},onClick:V,children:[e.jsx("span",{className:"text-[9px] opacity-60",children:"🤖"}),R?"...":S||"Model",e.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),u&&g.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:"SELECT MODEL"}),g.map(B=>e.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:B===S?`${ee}18`:"transparent",color:B===S?ee:"var(--text-secondary)",fontWeight:B===S?600:400,borderLeft:B===S?`2px solid ${ee}`:"2px solid transparent"},onMouseEnter:P=>{P.currentTarget.style.background=`${ee}12`},onMouseLeave:P=>{P.currentTarget.style.background=B===S?`${ee}18`:"transparent"},onClick:()=>J(B),children:B},B))]})]})]}),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?`${ee}55`:"transparent",border:"1px solid",color:j?"var(--text-primary)":"var(--text-muted)"},onClick:Z,children:[e.jsx("span",{className:"text-[9px] opacity-60",children:G?"🧠":"⚡"}),M?"...":j||(G?"Thinking":"Mode"),e.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),v&&w.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>N(!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:G?"SELECT THINKING LEVEL":"SELECT MODE"}),w.map(B=>e.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:B===j?`${ee}18`:"transparent",color:B===j?ee:"var(--text-secondary)",fontWeight:B===j?600:400,borderLeft:B===j?`2px solid ${ee}`:"2px solid transparent"},onMouseEnter:P=>{P.currentTarget.style.background=`${ee}12`},onMouseLeave:P=>{P.currentTarget.style.background=B===j?`${ee}18`:"transparent"},onClick:()=>Y(B),children:B},B))]})]})]})]})}const br=o.memo(function({contextKey:s,panelLabel:n,isSending:r,onSend:a}){const c=o.useRef(null),[i,h]=o.useState("");o.useEffect(()=>{h("")},[s]);const l=()=>{const x=i.trim();!x||r||(h(""),a(x))};return 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 ${n}...`,value:i,onChange:x=>h(x.target.value),onPaste:x=>{const d=x.clipboardData.getData("text");d&&h(f=>f+d),x.preventDefault()},onKeyDown:x=>{if(x.key==="Enter"){if(x.nativeEvent.isComposing){x.preventDefault();return}x.preventDefault(),l()}},onBlur:x=>{if(window.innerWidth<768){const d=x.relatedTarget;if((d==null?void 0:d.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:l,disabled:!i.trim()||r,className:`w-10 h-10 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${i.trim()&&!r?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:i.trim()&&!r?{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:i.trim()?"text-white":"text-text-muted",children:e.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})}),je=t=>t.transport==="pty",fe=t=>t.transport==="acp";var yr=new Set(["generating","streaming","loading","loading_reference","thinking","active"]);function jr(t){var s;return(((s=t==null?void 0:t.buttons)==null?void 0:s.length)??0)>0}function ve(t,s){if(jr(s==null?void 0:s.activeModal))return"waiting_approval";const n=String(t||"idle").trim().toLowerCase();return n==="waiting_approval"?"waiting_approval":yr.has(n)?"generating":n==="error"?"error":n==="stopped"?"stopped":n==="starting"?"starting":n==="panel_hidden"?"panel_hidden":n==="not_monitored"?"not_monitored":n==="disconnected"?"disconnected":"idle"}function zs(t){return ve(t)==="generating"}function me(t){return t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():"IDE"}function vr(t){if(t<60)return`${Math.round(t)}s`;const s=Math.floor(t/60);if(s<60)return`${s}m`;const n=Math.floor(s/60),r=s%60;if(n<24)return r>0?`${n}h ${r}m`:`${n}h`;const a=Math.floor(n/24),c=n%24;return`${a}d ${c}h`}function rs(t){return t<1024*1024*1024?`${(t/(1024*1024)).toFixed(0)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function Wt(t,s){const n=typeof s=="string"?s.trim():"";if(n)return n;const r=typeof t=="string"?t.trim():"";if(!r)return"";const a=r.replace(/[\\/]+$/,""),c=a.split(/[\\/]/).filter(Boolean);return c[c.length-1]||a}function wr(t){if(t.length>16&&/^[a-f0-9]+$/i.test(t))return`Machine-${t.substring(0,8)}`;if(t.includes("_")){const s=t.split("_"),n=s[s.length-1];return n.length>12?`Machine-${n.substring(0,8)}`:n}return t}function kr(t){return wr(t.trim().replace(/\.local$/i,""))}function Nr(t){const s=t.machineNickname??t.nickname;return typeof s!="string"?null:s.trim()||null}function Fs(t,s={}){var a,c;const n=[t.hostname,(a=t.machine)==null?void 0:a.hostname,(c=t.system)==null?void 0:c.hostname].find(i=>typeof i=="string"&&i.trim().length>0);if(n&&n!=="Unknown")return kr(n);const r=s.fallbackId||t.id;return r?`Machine-${r.substring(0,8)}`:s.fallbackLabel||"Machine"}function Xe(t,s={}){return Nr(t)||Fs(t,s)}function as(t){return t.transport==="pty"}function os(t){return t.transport==="acp"}function is(t,s){return me(t)}function Sr(t,s,n){const r=(t||"").trim().toLowerCase();if(!r)return!0;const a=(s||"").trim().toLowerCase(),c=(n||"").trim().toLowerCase(),i=me(n||"").trim().toLowerCase();return r===a||r===c||r===i}function Cr(t){return ve(t==null?void 0:t.status,{activeModal:t==null?void 0:t.activeModal})}function Ir(t){if(!Array.isArray(t)||t.length<=1)return t;const s=new Map,n=["generating","waiting_approval","connected","idle","panel_hidden"];for(const r of t){const a=(r.name||r.id||"").toLowerCase().replace(/\s+/g,"-"),c=s.get(a),i=ve(r.status);if(!c){s.set(a,{...r,status:i});continue}const h=n.indexOf(c.status||"idle"),l=n.indexOf(i||"idle");l>=0&&(h<0||l<h)&&s.set(a,{...r,status:i})}return Array.from(s.values())}const Mr=60,Tr=60;function Hs({activeConv:t,ideEntry:s,handleSendChat:n,isSendingChat:r=!1,handleFocusAgent:a,isFocusingAgent:c,actionLogs:i,userName:h}){const l=o.useRef(new Map),{sendCommand:x}=$e();lt("ChatPane",{tabKey:t.tabKey,messageCount:t.messages.length,actionLogCount:i.length,isSendingChat:r});const d=o.useRef(new Map),f=o.useCallback(M=>(d.current.has(M)||d.current.set(M,{messages:[],offset:0,hasMore:!0,error:null,visibleLiveCount:Mr}),d.current.get(M)),[]),b=o.useCallback((M,E)=>{const $=f(M);d.current.set(M,{...$,...E}),u(O=>O+1)},[f]),[,u]=o.useState(0),m=t.tabKey,v=f(m),N=v.messages,g=v.hasMore,p=v.error,w=Math.max(0,t.messages.length-v.visibleLiveCount),[T,y]=o.useState(!1),S=o.useCallback(async()=>{var $,O;if(T)return;const M=t.tabKey,E=f(M);if(t.messages.length>E.visibleLiveCount){b(M,{visibleLiveCount:Math.min(t.messages.length,E.visibleLiveCount+Tr),error:null});return}y(!0),b(M,{error:null});try{const C=(s==null?void 0:s.daemonId)||(($=t.ideId)==null?void 0:$.split(":")[0])||"";if(!C){b(M,{hasMore:!1});return}const V=t.ideType||t.agentType||"",Z=await x(C,"chat_history",{agentType:V,offset:E.offset,limit:30,targetSessionId:t.sessionId}),J=(Z==null?void 0:Z.result)??Z;if(((O=J.messages)==null?void 0:O.length)>0){const G=f(M);b(M,{messages:[...J.messages,...G.messages],offset:G.offset+J.messages.length,hasMore:!!J.hasMore})}else b(M,{hasMore:!!J.hasMore})}catch(C){const V=(C==null?void 0:C.message)||"";V.includes("P2P not available")||V.includes("channel not open")||V.includes("P2P not connected")||V.includes("timeout")?b(M,{error:"Connection not ready — tap to retry"}):b(M,{hasMore:!1,error:"Failed to load history"})}finally{y(!1)}},[T,s,t,x,f,b]),{allMessages:k,receivedAtMap:j}=o.useMemo(()=>{const M=w>0?t.messages.slice(-v.visibleLiveCount):t.messages;if(N.length===0){const V={};return M.forEach((Z,J)=>{const G=`${t.tabKey}:${Ve(Z,J)}`;let Q=Z.receivedAt||l.current.get(G)||0;Q||(Q=Date.now(),l.current.set(G,Q)),V[Ve(Z,J)]=Q}),{allMessages:M,receivedAtMap:V}}const E=new Set(M.map(V=>`${V.role}:${(V.content||"").slice(0,100)}`)),O=[...N.filter(V=>!E.has(`${V.role}:${(V.content||"").slice(0,100)}`)),...M],C={};return O.forEach((V,Z)=>{const J=`${t.tabKey}:${Ve(V,Z)}`;let G=V.receivedAt||l.current.get(J)||0;G||(G=Date.now(),l.current.set(J,G)),C[Ve(V,Z)]=G}),{allMessages:O,receivedAtMap:C}},[t.messages,t.tabKey,w,N,v.visibleLiveCount]),_=o.useMemo(()=>i.filter(M=>M.ideId===t.tabKey).sort((M,E)=>M.timestamp-E.timestamp),[i,t.tabKey]),R=t.displayPrimary||t.agentName||"Agent",D=o.useMemo(()=>{if(t.messages.length===0){if(t.connectionState==="connecting"||t.connectionState==="new")return 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"})]})]});if(t.status==="not_monitored")return 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(Ge,{size:28})}),e.jsx("div",{className:"text-[13px] opacity-50",children:"Agent not monitored"}),e.jsx("button",{onClick:a,disabled:c,className:"btn btn-primary",children:c?"⌛ Switching...":e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Dt,{size:14})," Open ",R," Panel"]})}),e.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Click to switch monitoring to this agent"})]});if(t.status==="panel_hidden")return 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($s,{size:28})}),e.jsx("div",{className:"text-[13px] opacity-50",children:"Agent panel is not visible yet"}),e.jsx("button",{onClick:a,disabled:c,className:"btn btn-primary",children:c?"⌛ Opening...":e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Dt,{size:14})," Open ",R," Panel"]})}),e.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Open the agent panel or chat view in the app you are using to start viewing messages"})]});if(t.status==="idle"&&!T)return 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..."})]})}},[t.messages.length,t.connectionState,t.status,a,c,T,R]);return e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[e.jsx(lr,{messages:k,actionLogs:_,agentName:t.agentName||t.displayPrimary||"Agent",userName:h,isCliMode:je(t)||fe(t),isWorking:t.status==="generating",contextKey:t.tabKey,receivedAtMap:j,onLoadMore:S,isLoadingMore:T,hasMoreHistory:g,hiddenLiveCount:w,loadError:p??void 0,emptyState:D}),!je(t)&&(()=>{const M=t.streamSource!=="agent-stream",E=M?t.ideType:t.agentType,$=M?s!=null&&s.type?me(s.type):me(t.ideType||""):t.agentName||me(t.agentType||"");return e.jsx(gr,{ideId:t.ideId,sessionId:t.sessionId,ideType:t.ideType,providerType:E,displayLabel:$,serverModel:(s==null?void 0:s.currentModel)||void 0,serverMode:(s==null?void 0:s.currentPlan)||void 0,acpConfigOptions:fe(t)?s==null?void 0:s.acpConfigOptions:void 0,acpModes:fe(t)?s==null?void 0:s.acpModes:void 0})})(),e.jsx(br,{contextKey:t.tabKey,panelLabel:R,isSending:r,onSend:n})]})}let Us=it;function Tt(){return Us()}class Er{constructor(){xe(this,"listeners",new Map)}send(s){}isConnected(){return!1}on(s,n){return this.listeners.has(s)||this.listeners.set(s,new Set),this.listeners.get(s).add(n),()=>{var r;(r=this.listeners.get(s))==null||r.delete(n)}}emit(s,...n){var r;(r=this.listeners.get(s))==null||r.forEach(a=>a(...n))}}let Vs=new Er;class Ar{constructor(){xe(this,"ptyCallbacks",new Set)}sendPtyInput(s,n,r){return!1}sendPtyResize(s,n,r,a){return!1}retryConnection(s){}getState(s){return"disconnected"}sendData(s,n){return!1}get(s){}onScreenshot(s,n){return()=>{}}onPtyOutput(s){return this.ptyCallbacks.add(s),()=>{this.ptyCallbacks.delete(s)}}emitPtyOutput(s,n,r){this.ptyCallbacks.forEach(a=>a(s,n,r))}onRuntimeEvent(s,n){return()=>{}}requestRuntimeSnapshot(s,n){return Promise.resolve()}}let he=new Ar;function Rr(t){t.dashboardWS&&(Vs=t.dashboardWS),t.connectionManager&&(he=t.connectionManager),t.useDaemonsHook&&(Us=t.useDaemonsHook)}function Lr({activeConv:t,clearToken:s=0,terminalRef:n,handleSendChat:r,isSendingChat:a=!1}){var T;const c=o.useRef(null),{sendCommand:i,sendData:h}=$e(),[l,x]=o.useState(""),[d,f]=o.useState(!1),b=o.useRef(0),u=o.useRef(!1),m=t.tabKey,v=t.sessionId||"",N=t.daemonId||((T=t.ideId)==null?void 0:T.split(":")[0])||t.ideId||"",g=()=>{var y;b.current=0,u.current=!1,f(!1),(y=n.current)==null||y.clear()},p=()=>{var y;b.current=0,u.current=!1,f(!0),(y=n.current)==null||y.clear()},w=(y,S=0)=>{var k,j;u.current||b.current>=S&&b.current!==0||(b.current=S,f(!0),(k=n.current)==null||k.clear(),y&&((j=n.current)==null||j.write(y)))};return o.useEffect(()=>{g()},[v]),o.useEffect(()=>{var S,k;if(!v)return;const y=((S=he.onRuntimeEvent)==null?void 0:S.call(he,v,j=>{var _;if(!(!j||j.sessionId!==v)){if(j.type==="runtime_snapshot"){w(j.text||"",j.seq||0);return}if(j.type==="session_output"){u.current=!0,typeof j.seq=="number"&&(b.current=Math.max(b.current,j.seq)),f(!0),typeof j.data=="string"&&((_=n.current)==null||_.write(j.data));return}j.type==="session_cleared"&&p()}}))||(()=>{});return(k=he.requestRuntimeSnapshot)==null||k.call(he,N,v).catch(()=>{}),()=>{y()}},[N,v,n]),o.useEffect(()=>{var S,k,j;if(!v)return;N&&((S=he.getState)==null?void 0:S.call(he,N))==="connected"&&(f(!0),(k=he.requestRuntimeSnapshot)==null||k.call(he,N,v).catch(()=>{}));const y=(j=he.onStateChange)==null?void 0:j.call(he,(_,R)=>{var D;_!==N||R!=="connected"||(f(!0),(D=he.requestRuntimeSnapshot)==null||D.call(he,N,v).catch(()=>{}))});return()=>{y==null||y()}},[N,v,n]),o.useEffect(()=>{s&&g()},[s,m,n]),o.useEffect(()=>{x("")},[t.tabKey]),o.useEffect(()=>{const y=S=>{var j;const k=S.detail;k!=null&&k.sessionId&&k.sessionId!==v||d&&((j=n.current)==null||j.fit())};return window.addEventListener("adhdev:fit-cli-terminal",y),()=>{window.removeEventListener("adhdev:fit-cli-terminal",y)}},[d,v,n]),o.useEffect(()=>{if(!d)return;const y=requestAnimationFrame(()=>{var S;(S=n.current)==null||S.fit()});return()=>cancelAnimationFrame(y)},[d,v,n]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 min-h-0 p-2 bg-[#0f1117]",children:[e.jsx(Os,{ref:n,readOnly:!d,onInput:y=>{d&&(h!=null&&h(N,{type:"pty_input",targetSessionId:v,data:y})||i(N,"pty_input",{targetSessionId:v,data:y}).catch(console.error))},onResize:(y,S)=>{d&&(h!=null&&h(N,{type:"pty_resize",targetSessionId:v,cols:y,rows:S})||i(N,"pty_resize",{targetSessionId:v,cols:y,rows:S,force:!0}).catch(()=>{}))}},t.tabKey),!d&&e.jsx("div",{className:"absolute inset-x-2 top-2 rounded-md border border-red-500/30 bg-red-500/10 px-3 py-2 text-[11px] text-red-300 pointer-events-none",children:"Runtime terminal unavailable"})]}),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:c,type:"text",placeholder:`Send message to ${t.displayPrimary}...`,value:l,onChange:y=>x(y.target.value),onPaste:y=>{const S=y.clipboardData.getData("text");S&&x(k=>k+S),y.preventDefault()},onKeyDown:y=>{if(y.key!=="Enter")return;if(y.nativeEvent.isComposing){y.preventDefault();return}y.preventDefault();const S=l.trim();!d||!S||a||(x(""),r(S))},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:()=>{const y=l.trim();!d||!y||a||(x(""),r(y))},disabled:!d||!l.trim()||a,className:`w-9 h-9 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${l.trim()&&!a?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:l.trim()&&!a?{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:l.trim()?"text-white":"text-text-muted",children:e.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})]})}function _r({wsStatus:t,showReconnected:s,loginUrl:n}){const r=t==="disconnected"||t==="reconnecting"||t==="offline"||t==="auth_failed",a=t==="auth_failed"?"red":t==="offline"?"orange":"violet",c={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))"},i={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)"},h={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:c[a],borderBottom:i[a],color:h[a]},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"&&(n?e.jsxs(e.Fragment,{children:["Session expired."," ",e.jsx("a",{href:n,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"]})]})}function $r({activeConv:t,agentCount:s,wsStatus:n,isConnected:r,onOpenHistory:a,onStopCli:c,onFitCli:i}){const h=ct(),l=Tt(),x=l.p2pStates||{},d=l.ides||[],f=!!t&&je(t)&&!fe(t),b=r?"#22c55e":n==="connected"?"#eab308":"#ef4444",u=r?"0 0 4px #22c55e80":n==="connected"?"0 0 4px #eab30880":"0 0 4px #ef444480",m=d.filter(T=>T.type==="adhdev-daemon"),v=Object.values(x),N=v.filter(T=>T==="connected").length,g=v.filter(T=>T==="connecting"||T==="new"||T==="checking").length,w=n!=="connected"||m.length===0?null:g>0&&N===0?"P2P connecting...":N>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(Ye,{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:b,boxShadow:u}})})]}),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":n==="connected"?"Partial":"Disconnected",className:"inline-block w-1.5 h-1.5 rounded-full shrink-0",style:{background:b,boxShadow:u}}),w&&e.jsxs("span",{className:"text-[10px] text-text-muted animate-pulse ml-1",children:["· ",w]})]})]})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[f&&c&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:i,className:"btn btn-secondary btn-sm",title:"Fit terminal to current view",children:"Fit"}),e.jsx("button",{onClick:c,className:"btn btn-secondary btn-sm text-red-400 border-red-500/25 hover:bg-red-500/10",title:"Stop CLI process",children:"Stop"})]}),t&&!f&&!fe(t)&&e.jsxs("button",{onClick:()=>h(`/ide/${t.ideId}`),className:"btn btn-primary btn-sm",title:"IDE View",children:[e.jsx(Vt,{size:14})," IDE"]}),t&&!f&&!fe(t)&&e.jsx("button",{onClick:a,className:"btn btn-secondary btn-sm",title:"Chat History",children:e.jsx(Ls,{size:16})}),t&&!f&&!fe(t)&&e.jsx("button",{onClick:()=>h(`/ide/${t.ideId}?view=remote`),className:"btn btn-secondary btn-sm",title:"Remote Control",children:e.jsx(_e,{size:16})})]})]})}function qs({activeConv:t,ides:s,isCreatingChat:n,isRefreshingHistory:r,onClose:a,onNewChat:c,onSwitchSession:i,onRefreshHistory:h}){var f;const l=s.find(b=>b.id===t.ideId),x=(l==null?void 0:l.chats)||[],d=(f=l==null?void 0:l.activeChat)==null?void 0:f.id;return e.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center",children:[e.jsx("div",{onClick:a,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," — ",me(t.ideType)]})]}),e.jsx("button",{onClick:a,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:c,disabled:n,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:n?"⌛ Creating...":"+ Start New Chat Session"}),x.map(b=>e.jsxs("div",{onClick:()=>{i(t.ideId,b.id),a()},className:`p-4 rounded-xl mb-2 cursor-pointer border transition-all ${d===b.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 ${d===b.id?"text-[var(--accent-primary-light)]":"text-text-primary"}`,children:b.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:[b.id.substring(0,12),"..."]}),d===b.id&&e.jsx("span",{className:"text-[10px] bg-accent text-white px-2 py-0.5 rounded-[10px] font-extrabold",children:"ACTIVE"})]})]},b.id)),x.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(Qn,{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:h,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(_s,{size:13})," Refresh History"]})})})]})]})}const cs={success:"rgba(16, 185, 129, 0.95)",warning:"color-mix(in srgb, var(--status-warning) 95%, transparent)",info:"rgba(99, 102, 241, 0.95)"};function Ys({toasts:t,onDismiss:s,onClickToast:n}){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] relative group",style:{background:cs[r.type]||cs.info},onClick:()=>{var a;(a=r.actions)!=null&&a.length||(n&&n(r),s(r.id))},children:[e.jsx("button",{className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full flex items-center justify-center text-white/50 hover:text-white hover:bg-white/20 transition-all text-[11px] leading-none opacity-0 group-hover:opacity-100 cursor-pointer",onClick:a=>{a.stopPropagation(),s(r.id)},"aria-label":"Dismiss",children:"×"}),e.jsx("div",{className:"pr-4",children:r.message}),r.actions&&r.actions.length>0&&e.jsx("div",{className:"flex gap-2 mt-2",children:r.actions.map((a,c)=>e.jsx("button",{className:`text-xs px-3 py-1 rounded-md font-bold transition-all cursor-pointer ${a.variant==="primary"?"bg-white text-text-primary hover:bg-gray-100":a.variant==="danger"?"bg-red-500/30 text-white hover:bg-red-500/50":"bg-white/20 text-white hover:bg-white/30"}`,onClick:i=>{i.stopPropagation(),a.onClick(),s(r.id)},children:a.label},c))})]},r.id))})}const Pr=t=>t.transport==="pty"||t.transport==="acp"||t.transport==="cdp-page"?!0:t.daemonId!==t.id;function Dr(t){const s=t.workspace||"";if(!s)return"";const n=s.split(/[/\\]/).filter(Boolean);return n.length>0?n[n.length-1]:s}function Br(t){return t.sessionId||t.instanceId||t.agentType}function xt(t){return typeof t=="string"?t.replace(/\s+/g," ").trim():Array.isArray(t)?t.map(s=>typeof s=="string"?s:s&&typeof s=="object"&&"text"in s?String(s.text||""):"").join(`
|
|
41
41
|
`).replace(/\s+/g," ").trim():t&&typeof t=="object"&&"text"in t?String(t.text||"").replace(/\s+/g," ").trim():String(t||"").replace(/\s+/g," ").trim()}function ls(t,s){const n=new Set,r=[];for(const a of s)if(a)for(const c of t[a]||[]){const i=c._localId||`${c.role}:${c.timestamp}:${c.content}`;n.has(i)||(n.add(i),r.push(c))}return r.sort((a,c)=>a.timestamp-c.timestamp)}function Gs(t=[]){const s={};for(const n of t){const r=n;(r.type==="adhdev-daemon"||r.daemonMode)&&(s[r.id]=Xe(r,{fallbackId:r.id}))}return s}function Xs(t,s,n={}){var b,u,m,v,N,g;const r=[],a=n.machineName,c=n.connectionState,i=Dr(t),h=me(t.type),l=Array.isArray(t.childSessions)?t.childSessions.map(p=>{var w,T;return{sessionId:p.id,instanceId:p.id,agentType:p.providerType,agentName:p.providerName,status:p.status,title:p.title,messages:((w=p.activeChat)==null?void 0:w.messages)||[],activeModal:((T=p.activeChat)==null?void 0:T.activeModal)||void 0}}):[],x=Pr(t),d=t.activeChat||{title:""},f=d.title&&String(d.title).trim()?String(d.title).trim():"";if(x){const p=t.sessionId||t.instanceId,w=is(t.type),T=(b=t.activeChat)==null?void 0:b.activeModal,y=T&&Array.isArray(T.buttons)&&T.buttons.length>0,S=ve((u=t.activeChat)==null?void 0:u.status,{activeModal:(m=t.activeChat)==null?void 0:m.activeModal})||ve((N=(v=t.agents)==null?void 0:v[0])==null?void 0:N.status)||"idle",k=t.activeChat||{title:"",messages:[]};let j=k.title&&String(k.title).trim()?String(k.title).trim():"";const _=(g=t.activeChat)==null?void 0:g.id,R=t.chats;if(_&&Array.isArray(R)&&R.length>0){const O=R.find(C=>C.id===_||C.id&&String(C.id)===String(_));O!=null&&O.title&&String(O.title).trim()&&(j=String(O.title).trim())}const D=k.messages||[],M=ls(s,[t.id,p]),E=new Map;D.filter(O=>O.role==="user").forEach(O=>{const C=xt(O.content);C&&E.set(C,(E.get(C)||0)+1)});const $=M.filter(O=>{const C=xt(O.content),V=E.get(C)||0;return V>0?(E.set(C,V-1),!1):!0});r.push({ideId:t.id,sessionId:p,transport:t.transport,daemonId:t.daemonId||void 0,mode:je(t)?t.mode||"terminal":"chat",agentName:w,agentType:(je(t)||fe(t))&&(t.cliType||t.acpType)||t.type,status:S,title:j,messages:[...D,...$],resume:t.resume,ideType:t.cliType||t.acpType||t.type,workspaceName:i,displayPrimary:j||i||(je(t)||fe(t)?"Terminal":w),displaySecondary:h,cdpConnected:t.cdpConnected,modalButtons:y?T.buttons:void 0,modalMessage:y?T.message:void 0,streamSource:"native",tabKey:t.id,machineName:a,connectionState:c})}if(x&&(je(t)||fe(t)))return r;for(const p of l){const w=p.activeModal&&Array.isArray(p.activeModal.buttons)&&p.activeModal.buttons.length>0,T=Cr(p),y=Br(p),S=`${t.id}:${y}`,k=p.title&&String(p.title).trim()||"",j=Sr(k,p.agentName,p.agentType)?"":k,_=p.messages||[],R=ls(s,[S,p.sessionId,p.instanceId]),D=new Map;_.filter(E=>E.role==="user").forEach(E=>{const $=xt(E.content);$&&D.set($,(D.get($)||0)+1)});const M=R.filter(E=>{const $=xt(E.content),O=D.get($)||0;return O>0?(D.set($,O-1),!1):!0});r.push({ideId:t.id,sessionId:p.sessionId||p.instanceId,transport:p.transport||"cdp-webview",daemonId:t.daemonId||void 0,mode:"chat",agentName:p.agentName,agentType:p.agentType,status:T,title:j,messages:[..._,...M],ideType:p.agentType,workspaceName:i,displayPrimary:j||f||i||h,displaySecondary:`${h}·${p.agentName}`,cdpConnected:t.cdpConnected,modalButtons:w?p.activeModal.buttons:void 0,modalMessage:w?p.activeModal.message:void 0,streamSource:"agent-stream",tabKey:S,machineName:a,connectionState:c})}return r.length===0&&r.push({ideId:t.id,sessionId:t.sessionId||t.instanceId,transport:t.transport,daemonId:t.daemonId||void 0,mode:"chat",agentName:is(t.type),agentType:"ide-native",status:"idle",title:"",messages:[],ideType:t.type,workspaceName:i,displayPrimary:i||h,displaySecondary:h,cdpConnected:t.cdpConnected,streamSource:"native",tabKey:t.id,connectionState:c}),r}function Wr(t){const s=[],n=new Map;for(const r of t)if(r.parentId){const a=n.get(r.parentId)||[];a.push(r),n.set(r.parentId,a)}else s.push(r);return{topLevel:s,childrenByParent:n}}function Or(t,s){const n=[],{daemonId:r,existingDaemon:a,timestamp:c}=s,i=c||t.timestamp||Date.now(),h=t.sessions||[],{topLevel:l,childrenByParent:x}=Wr(h),d=l.filter(u=>u.kind==="workspace"&&u.transport==="cdp-page"),f=l.filter(u=>u.kind==="agent"&&u.transport==="pty"),b=l.filter(u=>u.kind==="agent"&&u.transport==="acp");n.push({...a||{},id:r,type:"adhdev-daemon",status:"online",daemonMode:!0,timestamp:i,...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},...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:d.some(u=>!!u.cdpConnected)});for(const u of d){const m=x.get(u.id)||[];n.push({id:`${r}:ide:${u.id}`,sessionId:u.id,parentSessionId:u.parentId,sessionKind:u.kind,transport:u.transport,sessionCapabilities:u.capabilities,type:u.providerType,ideType:u.providerType,status:u.cdpConnected?"online":"detected",daemonId:r,instanceId:u.id,workspace:u.workspace,terminals:0,childSessions:m,agents:m.map(v=>({id:v.id,name:v.providerName,type:v.providerType,status:v.status})),activeChat:u.activeChat,chats:[],cdpConnected:u.cdpConnected,currentModel:u.currentModel,currentPlan:u.currentPlan,currentAutoApprove:u.currentAutoApprove,timestamp:i})}for(const u of f){const m=u.runtime;n.push({id:`${r}:cli:${u.id}`,sessionId:u.id,parentSessionId:u.parentId,sessionKind:u.kind,transport:u.transport,sessionCapabilities:u.capabilities,type:u.providerType,ideType:u.providerType,agentType:u.providerType,status:u.status||"running",daemonId:r,instanceId:u.id,cliName:u.providerName,mode:"terminal",workspace:u.workspace||"",activeChat:u.activeChat,resume:u.resume,runtimeKey:u.runtimeKey??(m==null?void 0:m.runtimeKey),runtimeDisplayName:u.runtimeDisplayName??(m==null?void 0:m.displayName),runtimeWorkspaceLabel:u.runtimeWorkspaceLabel??(m==null?void 0:m.workspaceLabel),runtimeWriteOwner:u.runtimeWriteOwner??(m==null?void 0:m.writeOwner)??null,runtimeAttachedClients:u.runtimeAttachedClients??(m==null?void 0:m.attachedClients)??[],timestamp:i,_isCli:!0})}for(const u of b){const m=u.runtime;n.push({id:`${r}:acp:${u.id}`,sessionId:u.id,parentSessionId:u.parentId,sessionKind:u.kind,transport:u.transport,sessionCapabilities:u.capabilities,type:u.providerType,ideType:u.providerType,agentType:u.providerType,status:u.status||"running",daemonId:r,instanceId:u.id,cliName:u.providerName,mode:"chat",workspace:u.workspace||"",activeChat:u.activeChat,runtimeKey:u.runtimeKey??(m==null?void 0:m.runtimeKey),runtimeDisplayName:u.runtimeDisplayName??(m==null?void 0:m.displayName),runtimeWorkspaceLabel:u.runtimeWorkspaceLabel??(m==null?void 0:m.workspaceLabel),runtimeWriteOwner:u.runtimeWriteOwner??(m==null?void 0:m.writeOwner)??null,runtimeAttachedClients:u.runtimeAttachedClients??(m==null?void 0:m.attachedClients)??[],currentModel:u.currentModel,currentPlan:u.currentPlan,acpConfigOptions:u.acpConfigOptions,acpModes:u.acpModes,timestamp:i,_isAcp:!0})}return n}function Js(t){const s=t.split(":");return s.length>=3&&(s[1]==="ide"||s[1]==="cli"||s[1]==="acp")?{daemonId:s[0],targetSessionId:s.slice(2).join(":")||void 0}:{daemonId:t}}function Kr(t,s){const n=Js(t);return{daemonId:n.daemonId,payload:{...s,...n.targetSessionId&&!s.targetSessionId?{targetSessionId:n.targetSessionId}:{}}}}const Zs=[{id:"vscode",name:"VS Code",icon:"💙"},{id:"cursor",name:"Cursor",icon:"⚡"},{id:"windsurf",name:"Windsurf",icon:"🏄"},{id:"antigravity",name:"Antigravity",icon:"🌀"},{id:"trae",name:"Trae",icon:"🔮"},{id:"kiro",name:"Kiro",icon:"🎯"},{id:"pearai",name:"PearAI",icon:"🍐"},{id:"vscodium",name:"VSCodium",icon:"💚"}],Qs=[{id:"claude-cli",name:"Claude Code",icon:"🟠"},{id:"gemini-cli",name:"Gemini CLI",icon:"✨"},{id:"codex-cli",name:"Codex CLI",icon:"📦"},{id:"aider-cli",name:"Aider",icon:"🛠️"},{id:"cursor-cli",name:"Cursor CLI",icon:"⚡"},{id:"github-copilot-cli",name:"GitHub Copilot CLI",icon:"🤖"},{id:"goose-cli",name:"Goose CLI",icon:"🪿"},{id:"opencode-cli",name:"OpenCode CLI",icon:"🧩"}],en=[{id:"copilot",name:"GitHub Copilot",icon:"🤖"},{id:"cline",name:"Cline",icon:"🧠"},{id:"roo-code",name:"Roo Code",icon:"🦘"},{id:"continue",name:"Continue",icon:"▶️"}],tn="adhdev_notification_prefs",ds={globalEnabled:!0,disconnectAlert:!0,browserNotifications:!0,completionAlert:!0,approvalAlert:!0,chatTaskCompletionBubble:!1};function zr(){try{const t=localStorage.getItem(tn);if(t){const s=JSON.parse(t);return{...ds,...s}}}catch{}return{...ds}}function Fr(t){try{localStorage.setItem(tn,JSON.stringify(t))}catch{}}let Me=zr(),yt=[];function Hr(){yt.forEach(t=>t())}function Ur(){return{...Me}}function Vr(t){Me={...Me,...t},Fr(Me),Hr()}function qr(){const[,t]=o.useState(0);o.useEffect(()=>{const n=()=>t(r=>r+1);return yt.push(n),()=>{yt=yt.filter(r=>r!==n)}},[]);const s=o.useCallback(n=>{Vr(n)},[]);return[{...Me},s]}function rt(t){if(!Me.globalEnabled)return!1;switch(t){case"disconnect":return Me.disconnectAlert;case"completion":return Me.completionAlert;case"approval":return Me.approvalAlert;case"browser":return Me.browserNotifications;default:return!0}}const Yr={enabled:!0,onApproval:!0,onComplete:!0,onError:!0,throttleMs:5e3};async function Gr(){return"Notification"in window?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"}function sn(){return"Notification"in window&&Notification.permission==="granted"}let Be=null;async function Xr(){if(Be!==null)return Be;try{if(!("serviceWorker"in navigator)||!("PushManager"in window))return Be=!1,!1;const t=await navigator.serviceWorker.getRegistration();return t?(Be=!!await t.pushManager.getSubscription(),Be):(Be=!1,!1)}catch{return Be=!1,!1}}function Ot(t,s,n){if(sn())try{const r=new Notification(t,{body:s,icon:"/otter-logo.png",tag:n||`adhdev-${Date.now()}`,silent:!1});setTimeout(()=>r.close(),8e3),r.onclick=()=>{window.focus(),r.close()}}catch{}}function Jr(t,s={}){const n={...Yr,...s},r=o.useRef(new Map),a=o.useRef(0),c=o.useRef(null);o.useEffect(()=>{Xr().then(h=>{c.current=h})},[]);const i=o.useCallback((h,l,x)=>{const d=Date.now();d-a.current<n.throttleMs||(a.current=d,Ot(h,l,x))},[n.throttleMs]);o.useEffect(()=>{var h;if(!(!n.enabled||!sn())&&rt("browser")&&c.current!==!0){if(document.hasFocus()){for(const l of t)r.current.set(l.id,ve(l.status,{activeModal:l.activeModal}));return}for(const l of t){const x=r.current.get(l.id),d=ve(l.status,{activeModal:l.activeModal}),f=l.name||l.id;if(n.onApproval&&rt("approval")&&d==="waiting_approval"&&x!=="waiting_approval"){const b=((h=l.activeModal)==null?void 0:h.message)||"Action requires your approval";i(`🔔 ${f} — Approval needed`,b.slice(0,120),`approval-${l.id}`)}n.onComplete&&rt("completion")&&zs(x)&&d==="idle"&&i(`✅ ${f} — Task complete`,"Agent has finished generating",`complete-${l.id}`),n.onError&&d==="error"&&x!=="error"&&i(`⚠️ ${f} — Error`,"Agent encountered an error",`error-${l.id}`),r.current.set(l.id,d)}}},[t,n.enabled,n.onApproval,n.onComplete,n.onError,i])}class Zr{constructor(){xe(this,"dedupMap",new Map);xe(this,"DEDUP_WINDOW_MS",5e3);xe(this,"DEDUP_MAX_SIZE",50);xe(this,"DEDUP_CLEANUP_AGE_MS",1e4);xe(this,"toastCallbacks",[]);xe(this,"systemMessageCallbacks",[]);xe(this,"clearSystemMessageCallbacks",[]);xe(this,"resolveActionFn",null);xe(this,"viewRequestRespondFn",null);xe(this,"ides",[])}onToast(s){return this.toastCallbacks.push(s),()=>{this.toastCallbacks=this.toastCallbacks.filter(n=>n!==s)}}onSystemMessage(s){return this.systemMessageCallbacks.push(s),()=>{this.systemMessageCallbacks=this.systemMessageCallbacks.filter(n=>n!==s)}}onClearSystemMessage(s){return this.clearSystemMessageCallbacks.push(s),()=>{this.clearSystemMessageCallbacks=this.clearSystemMessageCallbacks.filter(n=>n!==s)}}setResolveAction(s){this.resolveActionFn=s}setIdes(s){this.ides=s}setViewRequestRespond(s){this.viewRequestRespondFn=s}emitToast(s){for(const n of this.toastCallbacks)n(s)}showToast(s,n="info",r){const a=(r==null?void 0:r.id)||Date.now();this.emitToast({id:a,message:s,type:n,timestamp:a,duration:5e3,...r})}emitSystemMessage(s,n){for(const r of this.systemMessageCallbacks)r(s,n)}emitClearSystemMessage(s,n){for(const r of this.clearSystemMessageCallbacks)r(s,n)}isDuplicate(s){const n=Date.now(),r=this.dedupMap.get(s)||0;if(n-r<this.DEDUP_WINDOW_MS)return!0;if(this.dedupMap.set(s,n),this.dedupMap.size>this.DEDUP_MAX_SIZE)for(const[a,c]of this.dedupMap)n-c>this.DEDUP_CLEANUP_AGE_MS&&this.dedupMap.delete(a);return!1}resolveOwningDaemon(s){if(s.ideType==="adhdev-daemon"&&s.ideId){const a=this.ides.find(c=>c.id===s.ideId&&c.type==="adhdev-daemon");if(a)return a}let n;if(s.targetSessionId&&(n=this.findOwningSession(s.targetSessionId)||void 0),s.ideId&&(n=n||this.ides.find(a=>a.id===s.ideId)),!n&&s.instanceId&&(n=this.ides.find(a=>a.id.endsWith(`:ide:${s.instanceId}`)||a.id.endsWith(`:cli:${s.instanceId}`))),n){const a=n.daemonId;if(a){const c=this.ides.find(i=>i.id===a&&i.type==="adhdev-daemon");if(c)return c}}const r=this.ides.filter(a=>a.type==="adhdev-daemon");return r.length===1?r[0]:null}resolveRouteId(s,n){for(const r of this.ides)if(r.id.startsWith(s)&&(!n||n===r.type))return r.id;return s}findOwningSession(s){for(const n of this.ides)if(n.id===s||n.sessionId===s||(Array.isArray(n.childSessions)?n.childSessions:[]).some(a=>(a==null?void 0:a.id)===s))return n;return null}resolveActionRouteTarget(s){if(s.ideId){const n=s.agentType||s.ideType||"";return this.resolveRouteId(s.ideId,n)}if(s.targetSessionId){const n=this.findOwningSession(s.targetSessionId);return(n==null?void 0:n.id)||(n==null?void 0:n.daemonId)||null}return null}resolveConversationKey(s){return s.targetSessionId?s.targetSessionId:s.ideId?s.ideId:null}handleRawEvent(s,n){var d,f;if(!s.ideId&&s.instanceId){for(const b of this.ides)if(b.id.endsWith(`:ide:${s.instanceId}`)||b.id.endsWith(`:cli:${s.instanceId}`)){s.ideId=b.id;break}}const r=this.resolveConversationKey(s),c=`${r||s.instanceId||s.ideType||s.providerType||""}:${s.event}:${s.chatTitle||""}`;if(this.isDuplicate(c))return;let i=me(s.ideType||"");const h=this.resolveOwningDaemon(s);if(h){const b=Xe(h,{fallbackId:h.id});b&&(i=s.ideType==="adhdev-daemon"?b:`${b}/${i}`)}let l="",x="info";if(s.event==="agent:generating_completed"){const b=s.duration?` (${s.duration}s)`:"";l=`✅ ${i} agent task completed${b}`,x="success";try{new Audio("data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQQAAAB/f39/").play().catch(()=>{})}catch{}r&&Ur().chatTaskCompletionBubble&&this.emitSystemMessage(r,{role:"system",timestamp:Date.now(),content:`✅ Task completed${b}`,_localId:`sys_complete_${Date.now()}`})}else if(s.event==="agent:generating_started")r&&this.emitClearSystemMessage(r,"sys_complete_");else if(s.event==="agent:waiting_approval"){if(l=`⚡ ${i} approval needed`,x="warning",r){const b=s.modalMessage||"Approval requested",u=(d=s.modalButtons)!=null&&d.length?s.modalButtons.map(m=>`[${m}]`).join(" "):"[Approve] [Reject]";this.emitSystemMessage(r,{role:"system",timestamp:Date.now(),content:`⚡ Approval requested: ${b}
|
|
42
|
-
${u}`,_localId:`sys_approval_${Date.now()}`})}if((f=s.modalButtons)!=null&&f.length&&this.resolveActionFn){const b=this.resolveActionRouteTarget(s);if(!b)return;const u=s.agentType||s.ideType||"",m=s.ideType||"",v=s.modalButtons,N=y=>y.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),g=this.resolveActionFn,p=v.map((y,S)=>{const k=N(y).toLowerCase(),j=/^(run|approve|accept|yes|allow|always)/.test(k),_=/^(reject|deny|delete|remove|abort|cancel|no)/.test(k);return{label:N(y),variant:j?"primary":_?"danger":"default",onClick:()=>{const R=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(k);g(b,"resolve_action",{action:R?"approve":"reject",button:y,buttonIndex:S,agentType:u,ideType:m,...s.targetSessionId&&{targetSessionId:s.targetSessionId}})}}}),w=s.modalMessage?`⚡ ${i}: ${s.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:l,T=Date.now();this.emitToast({id:T,message:w,type:x,timestamp:T,targetKey:r||b,actions:p,duration:15e3}),l=""}}else if(s.event==="monitor:long_generating"){const b=s.elapsedSec?` (${Math.round(s.elapsedSec/60)}m)`:"";l=`⚠️ ${i} agent is taking a long time${b}`,x="warning",rt("browser")&&!document.hasFocus()&&Ot(`⚠️ ${i} — Long Running`,`Agent has been generating for over ${b.replace(/[()]/g,"")}`,`long-${s.ideId||s.agentType}`)}else if(s.event==="team:view_request"){const b=s.requesterName||"A team member",u=s.requestId,m=s.orgId;if(l=`👁️ ${b} wants to view your session`,x="warning",u&&m&&this.viewRequestRespondFn){const v=this.viewRequestRespondFn,N=Date.now(),g=[{label:"Approve",variant:"primary",onClick:()=>{v(m,u,"approve").catch(p=>console.error("[EventManager] approve view request failed:",p))}},{label:"Decline",variant:"danger",onClick:()=>{v(m,u,"reject").catch(p=>console.error("[EventManager] reject view request failed:",p))}}];this.emitToast({id:N,message:l,type:x,timestamp:N,actions:g,duration:3e4}),l=""}rt("browser")&&!document.hasFocus()&&Ot("👁️ View Request",`${b} wants to view your session`,`view-request-${u}`)}else s.event==="team:view_request_approved"?(l="✅ View request approved",x="success"):s.event==="team:view_request_rejected"&&(l=`❌ ${s.targetName||"Team member"} declined your view request`,x="warning");if(l){const b=Date.now();this.emitToast({id:b,message:l,type:x,timestamp:b,targetKey:r||s.ideId,duration:5e3})}}}const Pe=new Zr;function Fe(...t){return Cn(In(t))}function Qr({icon:t,title:s,subtitle:n,badge:r,actions:a,className:c}){return e.jsxs("div",{className:Fe("dashboard-header",c),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]})]}),n&&e.jsx("div",{className:"header-subtitle mt-1 text-xs text-text-muted",children:n})]}),a&&e.jsx("div",{className:"flex gap-2",children:a})]})}function St({icon:t,title:s,subtitle:n,badge:r,actions:a,widthClassName:c="max-w-6xl",contentClassName:i,children:h}){return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(Qr,{icon:t,title:s,subtitle:n,badge:r,actions:a}),e.jsx("div",{className:"page-content",children:e.jsx("div",{className:Fe("mx-auto flex w-full flex-col gap-4",c,i),children:h})})]})}function be({title:t,icon:s,description:n,accentColor:r,className:a,children:c}){return e.jsxs("div",{className:Fe("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]",a),style:r?{borderLeftColor:r}:void 0,children:[(t||n)&&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]}),n&&e.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:n})]}),c]})}function qt({icon:t,title:s,description:n,action:r,className:a}){return e.jsxs("div",{className:Fe("py-16 px-5 text-center bg-bg-glass border-2 border-dashed border-border-subtle rounded-2xl",a),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:n}),r]})}const ea={error:"bg-red-500/10 border-red-500/30 text-red-400",warning:"bg-yellow-500/10 border-yellow-500/30 text-yellow-400",success:"bg-green-500/10 border-green-500/30 text-green-400",info:"bg-indigo-500/10 border-indigo-500/30 text-indigo-400"},ta={error:"⚠️",warning:"🧪",success:"✅",info:"💡"};function sa({variant:t,children:s,onDismiss:n,className:r}){return e.jsxs("div",{className:Fe("flex items-center justify-between gap-3 px-4 py-3 rounded-xl border text-[13px]",ea[t],r),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:ta[t]}),e.jsx("span",{children:s})]}),n&&e.jsx("button",{onClick:n,className:"cursor-pointer border-none bg-transparent text-current text-base opacity-70 hover:opacity-100 transition-opacity",children:"✕"})]})}const na={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"},ra={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function aa({status:t,label:s,className:n}){const r=s||t;return e.jsxs("span",{className:Fe("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",na[t],n),children:[e.jsx("span",{className:Fe("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",ra[t])}),r]})}function oa(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function Kt(){try{const t=localStorage.getItem("theme");if(t==="dark"||t==="light"||t==="system")return t}catch{}return"dark"}function jt(t){return t==="system"?oa():t}function ia(){typeof document>"u"||document.documentElement.setAttribute("data-theme",jt(Kt()))}function ca(){const[t,s]=o.useState(Kt),[n,r]=o.useState(()=>jt(Kt()));o.useEffect(()=>{document.documentElement.setAttribute("data-theme",n)},[n]),o.useEffect(()=>{const i=window.matchMedia("(prefers-color-scheme: light)"),h=l=>{t==="system"&&r(l.matches?"light":"dark")};return i.addEventListener("change",h),()=>i.removeEventListener("change",h)},[t]);const a=o.useCallback(i=>{s(i),r(jt(i));try{localStorage.setItem("theme",i)}catch{}},[]),c=o.useCallback(()=>{s(i=>{const h=i==="dark"?"light":i==="light"?"system":"dark";r(jt(h));try{localStorage.setItem("theme",h)}catch{}return h})},[]);return{theme:n,preference:t,setPreference:a,cycleTheme:c,isDark:n==="dark"}}function Oe({label:t,description:s,checked:n,disabled:r,onChange:a,extra:c}){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:[c,e.jsx("input",{type:"checkbox",checked:n,disabled:r,onChange:i=>a(i.target.checked),className:"w-5 h-5 accent-accent"})]})]})}function la({onPrefChange:t}){const[s,n]=qr(),r=(a,c)=>{n({[a]:c}),t==null||t(a,c)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ws,{size:15})," Notifications"]}),description:"Master toggle for all alerts",checked:s.globalEnabled,onChange:a=>r("globalEnabled",a)}),s.globalEnabled&&e.jsx("div",{className:"border-t border-border-subtle my-0.5"}),s.globalEnabled&&e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(_e,{size:15})," Browser Notifications"]}),description:"Desktop alerts when tab is inactive",checked:s.browserNotifications,onChange:a=>r("browserNotifications",a)}),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(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(er,{size:15})," Completion Alerts"]}),description:"Notify when agent finishes a task",checked:s.completionAlert,onChange:a=>r("completionAlert",a)}),e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(tr,{size:15})," Approval Alerts"]}),description:"Notify when agent needs approval",checked:s.approvalAlert,onChange:a=>r("approvalAlert",a)}),e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ge,{size:15})," Connection Alerts"]}),description:"Alert when a daemon disconnects",checked:s.disconnectAlert,onChange:a=>r("disconnectAlert",a)})]}),s.globalEnabled&&e.jsx("div",{className:"border-t border-border-subtle my-2"}),s.globalEnabled&&e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ye,{size:15})," Task Completion Bubble"]}),description:"Show a system message bubble in chat when an agent finishes a task",checked:s.chatTaskCompletionBubble,onChange:a=>r("chatTaskCompletionBubble",a)}),!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 da({ides:t,emptyMessage:s,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a}){const c=t.filter(i=>i.type==="adhdev-daemon");return c.length===0?e.jsx(qt,{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-standalone' to connect a local daemon instance."}):e.jsx("div",{className:"flex flex-col gap-2",children:c.map(i=>e.jsx(ha,{ide:i,allIdes:t,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a},i.id))})}function us({title:t,message:s,confirmLabel:n,confirmColor:r,onConfirm:a,onCancel:c}){const i=r==="red"?"bg-red-500/20 text-red-400 border-red-500/30 hover:bg-red-500/30":"";return Mn.createPortal(e.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",style:{zIndex:9999},onClick:c,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:h=>h.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:c,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:a,className:`text-xs px-3 py-1.5 rounded-lg font-medium border transition-colors ${i}`,style:r==="amber"?{background:"color-mix(in srgb, var(--status-warning) 20%, transparent)",color:"var(--status-warning)",borderColor:"color-mix(in srgb, var(--status-warning) 30%, transparent)"}:void 0,children:n})]})]})}),document.body)}function ua(t){const s=t.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase(),r=[...Zs,...Qs,...en].find(a=>a.id===s||s.includes(a.id)||a.id.includes(s));return r?{icon:r.icon,name:r.name}:{icon:"📝",name:t}}function ha({ide:t,allIdes:s,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a}){var $,O;const[c,i]=o.useState("idle"),[h,l]=o.useState(""),[x,d]=o.useState(null),[f,b]=o.useState("idle"),[u,m]=o.useState(""),v=t,N=v.version||v.daemonVersion||null,g=(($=v.machine)==null?void 0:$.platform)||((O=v.system)==null?void 0:O.platform)||"",p=Xe(v,{fallbackId:t.id}),w=g==="win32"?"🪟":g==="darwin"?"🍎":"🐧",T=s.filter(C=>C.daemonId===t.id&&C.transport==="cdp-page"),y=s.filter(C=>C.daemonId===t.id&&C.transport==="pty"),S=s.filter(C=>C.daemonId===t.id&&C.transport==="acp"),k=v.p2p,j=async()=>{var C,V,Z;if(n){i("upgrading"),l("Installing latest version...");try{const J=await n(t.id,"daemon_upgrade",{});(C=J==null?void 0:J.result)!=null&&C.upgraded||(V=J==null?void 0:J.result)!=null&&V.success?(i("done"),l(`Upgraded to v${J.result.version||"latest"}. Daemon is restarting...`)):(i("error"),l(((Z=J==null?void 0:J.result)==null?void 0:Z.error)||"Upgrade failed"))}catch(J){i("error"),l((J==null?void 0:J.message)||"Connection lost during upgrade")}}},_=async()=>{if(d(null),!!r){b("loading");try{await r(t.id),b("done"),m("Machine disconnected.")}catch(C){b("error"),m((C==null?void 0:C.message)||"Failed to disconnect")}}},R=async()=>{if(d(null),!!a){b("loading");try{await a(t.id),b("done"),m('Token revoked. Machine must restart "adhdev-standalone" to reconnect.')}catch(C){b("error"),m((C==null?void 0:C.message)||"Failed to revoke token")}}},D="0.7.33",M=!N||N!==D,E=T.length+y.length+S.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:w}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:p}),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),"…"]}),N&&e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${M?"":"bg-bg-secondary"}`,style:M?{background:"color-mix(in srgb, var(--status-warning) 15%, transparent)",color:"var(--status-warning)"}:void 0,children:["v",N,!M&&" ✓"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&M&&e.jsx("button",{onClick:j,disabled:c==="upgrading"||c==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${D}`,children:c==="upgrading"?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"animate-spin",children:"⟳"})," Upgrading..."]}):c==="done"?"✓ Updated":`↑ Update${` to v${D}`}`}),r&&e.jsx("button",{onClick:()=>d("disconnect"),disabled:f==="loading",className:"btn btn-sm btn-warning disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect this machine",children:"Disconnect"}),a&&e.jsx("button",{onClick:()=>d("revoke"),disabled:f==="loading",className:"btn btn-sm btn-danger disabled:opacity-50 disabled:cursor-not-allowed",title:"Remove machine (requires re-setup)",children:"Remove"}),e.jsx(aa,{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:[k&&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 ${k.state==="connected"?"bg-green-400":"bg-text-muted/30"} ${k.state==="connecting"||k.state==="new"?"animate-pulse":""}`,style:k.state==="connecting"||k.state==="new"?{background:"var(--status-warning)"}:void 0}),e.jsxs("span",{className:"text-text-muted",children:["P2P ",k.state==="connected"?"connected":k.state==="connecting"||k.state==="new"?"connecting...":k.state||"off"]}),k.peers!==void 0&&k.peers>0&&e.jsxs("span",{className:"text-text-muted/60",children:["(",k.peers," peer",k.peers!==1?"s":"",")"]})]}),k&&E>0&&e.jsx("span",{className:"text-border-subtle",children:"·"}),E>0?e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[T.map(C=>{const V=ua(C.type),Z=C.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:V.icon}),e.jsx("span",{children:V.name}),Z!==void 0&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Z?"bg-green-400":"animate-pulse"}`,style:Z?void 0:{background:"var(--status-warning)"},title:Z?"CDP connected":"CDP connecting..."})]},C.id)}),y.map(C=>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:C.cliName||"CLI"})]},C.id)),S.map(C=>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:C.cliName||"ACP"})]},C.id))]}):e.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(h||u)&&e.jsx("div",{className:`text-xs mt-2 px-1 ${c==="error"||f==="error"?"text-red-400":c==="done"||f==="done"?"text-green-400":"text-text-muted"}`,children:u||h})]}),x==="disconnect"&&e.jsx(us,{title:"🔌 Disconnect Machine",message:`Disconnect "${p}" from ADHDev?
|
|
42
|
+
${u}`,_localId:`sys_approval_${Date.now()}`})}if((f=s.modalButtons)!=null&&f.length&&this.resolveActionFn){const b=this.resolveActionRouteTarget(s);if(!b)return;const u=s.agentType||s.ideType||"",m=s.ideType||"",v=s.modalButtons,N=y=>y.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),g=this.resolveActionFn,p=v.map((y,S)=>{const k=N(y).toLowerCase(),j=/^(run|approve|accept|yes|allow|always)/.test(k),_=/^(reject|deny|delete|remove|abort|cancel|no)/.test(k);return{label:N(y),variant:j?"primary":_?"danger":"default",onClick:()=>{const R=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(k);g(b,"resolve_action",{action:R?"approve":"reject",button:y,buttonIndex:S,agentType:u,ideType:m,...s.targetSessionId&&{targetSessionId:s.targetSessionId}})}}}),w=s.modalMessage?`⚡ ${i}: ${s.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:l,T=Date.now();this.emitToast({id:T,message:w,type:x,timestamp:T,targetKey:r||b,actions:p,duration:15e3}),l=""}}else if(s.event==="monitor:long_generating"){const b=s.elapsedSec?` (${Math.round(s.elapsedSec/60)}m)`:"";l=`⚠️ ${i} agent is taking a long time${b}`,x="warning",rt("browser")&&!document.hasFocus()&&Ot(`⚠️ ${i} — Long Running`,`Agent has been generating for over ${b.replace(/[()]/g,"")}`,`long-${s.ideId||s.agentType}`)}else if(s.event==="team:view_request"){const b=s.requesterName||"A team member",u=s.requestId,m=s.orgId;if(l=`👁️ ${b} wants to view your session`,x="warning",u&&m&&this.viewRequestRespondFn){const v=this.viewRequestRespondFn,N=Date.now(),g=[{label:"Approve",variant:"primary",onClick:()=>{v(m,u,"approve").catch(p=>console.error("[EventManager] approve view request failed:",p))}},{label:"Decline",variant:"danger",onClick:()=>{v(m,u,"reject").catch(p=>console.error("[EventManager] reject view request failed:",p))}}];this.emitToast({id:N,message:l,type:x,timestamp:N,actions:g,duration:3e4}),l=""}rt("browser")&&!document.hasFocus()&&Ot("👁️ View Request",`${b} wants to view your session`,`view-request-${u}`)}else s.event==="team:view_request_approved"?(l="✅ View request approved",x="success"):s.event==="team:view_request_rejected"&&(l=`❌ ${s.targetName||"Team member"} declined your view request`,x="warning");if(l){const b=Date.now();this.emitToast({id:b,message:l,type:x,timestamp:b,targetKey:r||s.ideId,duration:5e3})}}}const Pe=new Zr;function Fe(...t){return Cn(In(t))}function Qr({icon:t,title:s,subtitle:n,badge:r,actions:a,className:c}){return e.jsxs("div",{className:Fe("dashboard-header",c),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]})]}),n&&e.jsx("div",{className:"header-subtitle mt-1 text-xs text-text-muted",children:n})]}),a&&e.jsx("div",{className:"flex gap-2",children:a})]})}function St({icon:t,title:s,subtitle:n,badge:r,actions:a,widthClassName:c="max-w-6xl",contentClassName:i,children:h}){return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(Qr,{icon:t,title:s,subtitle:n,badge:r,actions:a}),e.jsx("div",{className:"page-content",children:e.jsx("div",{className:Fe("mx-auto flex w-full flex-col gap-4",c,i),children:h})})]})}function be({title:t,icon:s,description:n,accentColor:r,className:a,children:c}){return e.jsxs("div",{className:Fe("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]",a),style:r?{borderLeftColor:r}:void 0,children:[(t||n)&&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]}),n&&e.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:n})]}),c]})}function qt({icon:t,title:s,description:n,action:r,className:a}){return e.jsxs("div",{className:Fe("py-16 px-5 text-center bg-bg-glass border-2 border-dashed border-border-subtle rounded-2xl",a),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:n}),r]})}const ea={error:"bg-red-500/10 border-red-500/30 text-red-400",warning:"bg-yellow-500/10 border-yellow-500/30 text-yellow-400",success:"bg-green-500/10 border-green-500/30 text-green-400",info:"bg-indigo-500/10 border-indigo-500/30 text-indigo-400"},ta={error:"⚠️",warning:"🧪",success:"✅",info:"💡"};function sa({variant:t,children:s,onDismiss:n,className:r}){return e.jsxs("div",{className:Fe("flex items-center justify-between gap-3 px-4 py-3 rounded-xl border text-[13px]",ea[t],r),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:ta[t]}),e.jsx("span",{children:s})]}),n&&e.jsx("button",{onClick:n,className:"cursor-pointer border-none bg-transparent text-current text-base opacity-70 hover:opacity-100 transition-opacity",children:"✕"})]})}const na={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"},ra={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function aa({status:t,label:s,className:n}){const r=s||t;return e.jsxs("span",{className:Fe("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",na[t],n),children:[e.jsx("span",{className:Fe("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",ra[t])}),r]})}function oa(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function Kt(){try{const t=localStorage.getItem("theme");if(t==="dark"||t==="light"||t==="system")return t}catch{}return"dark"}function jt(t){return t==="system"?oa():t}function ia(){typeof document>"u"||document.documentElement.setAttribute("data-theme",jt(Kt()))}function ca(){const[t,s]=o.useState(Kt),[n,r]=o.useState(()=>jt(Kt()));o.useEffect(()=>{document.documentElement.setAttribute("data-theme",n)},[n]),o.useEffect(()=>{const i=window.matchMedia("(prefers-color-scheme: light)"),h=l=>{t==="system"&&r(l.matches?"light":"dark")};return i.addEventListener("change",h),()=>i.removeEventListener("change",h)},[t]);const a=o.useCallback(i=>{s(i),r(jt(i));try{localStorage.setItem("theme",i)}catch{}},[]),c=o.useCallback(()=>{s(i=>{const h=i==="dark"?"light":i==="light"?"system":"dark";r(jt(h));try{localStorage.setItem("theme",h)}catch{}return h})},[]);return{theme:n,preference:t,setPreference:a,cycleTheme:c,isDark:n==="dark"}}function Oe({label:t,description:s,checked:n,disabled:r,onChange:a,extra:c}){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:[c,e.jsx("input",{type:"checkbox",checked:n,disabled:r,onChange:i=>a(i.target.checked),className:"w-5 h-5 accent-accent"})]})]})}function la({onPrefChange:t}){const[s,n]=qr(),r=(a,c)=>{n({[a]:c}),t==null||t(a,c)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ws,{size:15})," Notifications"]}),description:"Master toggle for all alerts",checked:s.globalEnabled,onChange:a=>r("globalEnabled",a)}),s.globalEnabled&&e.jsx("div",{className:"border-t border-border-subtle my-0.5"}),s.globalEnabled&&e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(_e,{size:15})," Browser Notifications"]}),description:"Desktop alerts when tab is inactive",checked:s.browserNotifications,onChange:a=>r("browserNotifications",a)}),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(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(er,{size:15})," Completion Alerts"]}),description:"Notify when agent finishes a task",checked:s.completionAlert,onChange:a=>r("completionAlert",a)}),e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(tr,{size:15})," Approval Alerts"]}),description:"Notify when agent needs approval",checked:s.approvalAlert,onChange:a=>r("approvalAlert",a)}),e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ge,{size:15})," Connection Alerts"]}),description:"Alert when a daemon disconnects",checked:s.disconnectAlert,onChange:a=>r("disconnectAlert",a)})]}),s.globalEnabled&&e.jsx("div",{className:"border-t border-border-subtle my-2"}),s.globalEnabled&&e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ye,{size:15})," Task Completion Bubble"]}),description:"Show a system message bubble in chat when an agent finishes a task",checked:s.chatTaskCompletionBubble,onChange:a=>r("chatTaskCompletionBubble",a)}),!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 da({ides:t,emptyMessage:s,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a}){const c=t.filter(i=>i.type==="adhdev-daemon");return c.length===0?e.jsx(qt,{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-standalone' to connect a local daemon instance."}):e.jsx("div",{className:"flex flex-col gap-2",children:c.map(i=>e.jsx(ha,{ide:i,allIdes:t,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a},i.id))})}function us({title:t,message:s,confirmLabel:n,confirmColor:r,onConfirm:a,onCancel:c}){const i=r==="red"?"bg-red-500/20 text-red-400 border-red-500/30 hover:bg-red-500/30":"";return Mn.createPortal(e.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",style:{zIndex:9999},onClick:c,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:h=>h.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:c,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:a,className:`text-xs px-3 py-1.5 rounded-lg font-medium border transition-colors ${i}`,style:r==="amber"?{background:"color-mix(in srgb, var(--status-warning) 20%, transparent)",color:"var(--status-warning)",borderColor:"color-mix(in srgb, var(--status-warning) 30%, transparent)"}:void 0,children:n})]})]})}),document.body)}function ua(t){const s=t.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase(),r=[...Zs,...Qs,...en].find(a=>a.id===s||s.includes(a.id)||a.id.includes(s));return r?{icon:r.icon,name:r.name}:{icon:"📝",name:t}}function ha({ide:t,allIdes:s,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a}){var $,O;const[c,i]=o.useState("idle"),[h,l]=o.useState(""),[x,d]=o.useState(null),[f,b]=o.useState("idle"),[u,m]=o.useState(""),v=t,N=v.version||v.daemonVersion||null,g=(($=v.machine)==null?void 0:$.platform)||((O=v.system)==null?void 0:O.platform)||"",p=Xe(v,{fallbackId:t.id}),w=g==="win32"?"🪟":g==="darwin"?"🍎":"🐧",T=s.filter(C=>C.daemonId===t.id&&C.transport==="cdp-page"),y=s.filter(C=>C.daemonId===t.id&&C.transport==="pty"),S=s.filter(C=>C.daemonId===t.id&&C.transport==="acp"),k=v.p2p,j=async()=>{var C,V,Z;if(n){i("upgrading"),l("Installing latest version...");try{const J=await n(t.id,"daemon_upgrade",{});(C=J==null?void 0:J.result)!=null&&C.upgraded||(V=J==null?void 0:J.result)!=null&&V.success?(i("done"),l(`Upgraded to v${J.result.version||"latest"}. Daemon is restarting...`)):(i("error"),l(((Z=J==null?void 0:J.result)==null?void 0:Z.error)||"Upgrade failed"))}catch(J){i("error"),l((J==null?void 0:J.message)||"Connection lost during upgrade")}}},_=async()=>{if(d(null),!!r){b("loading");try{await r(t.id),b("done"),m("Machine disconnected.")}catch(C){b("error"),m((C==null?void 0:C.message)||"Failed to disconnect")}}},R=async()=>{if(d(null),!!a){b("loading");try{await a(t.id),b("done"),m('Token revoked. Machine must restart "adhdev-standalone" to reconnect.')}catch(C){b("error"),m((C==null?void 0:C.message)||"Failed to revoke token")}}},D="0.7.35",M=!N||N!==D,E=T.length+y.length+S.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:w}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:p}),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),"…"]}),N&&e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${M?"":"bg-bg-secondary"}`,style:M?{background:"color-mix(in srgb, var(--status-warning) 15%, transparent)",color:"var(--status-warning)"}:void 0,children:["v",N,!M&&" ✓"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&M&&e.jsx("button",{onClick:j,disabled:c==="upgrading"||c==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${D}`,children:c==="upgrading"?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"animate-spin",children:"⟳"})," Upgrading..."]}):c==="done"?"✓ Updated":`↑ Update${` to v${D}`}`}),r&&e.jsx("button",{onClick:()=>d("disconnect"),disabled:f==="loading",className:"btn btn-sm btn-warning disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect this machine",children:"Disconnect"}),a&&e.jsx("button",{onClick:()=>d("revoke"),disabled:f==="loading",className:"btn btn-sm btn-danger disabled:opacity-50 disabled:cursor-not-allowed",title:"Remove machine (requires re-setup)",children:"Remove"}),e.jsx(aa,{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:[k&&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 ${k.state==="connected"?"bg-green-400":"bg-text-muted/30"} ${k.state==="connecting"||k.state==="new"?"animate-pulse":""}`,style:k.state==="connecting"||k.state==="new"?{background:"var(--status-warning)"}:void 0}),e.jsxs("span",{className:"text-text-muted",children:["P2P ",k.state==="connected"?"connected":k.state==="connecting"||k.state==="new"?"connecting...":k.state||"off"]}),k.peers!==void 0&&k.peers>0&&e.jsxs("span",{className:"text-text-muted/60",children:["(",k.peers," peer",k.peers!==1?"s":"",")"]})]}),k&&E>0&&e.jsx("span",{className:"text-border-subtle",children:"·"}),E>0?e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[T.map(C=>{const V=ua(C.type),Z=C.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:V.icon}),e.jsx("span",{children:V.name}),Z!==void 0&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Z?"bg-green-400":"animate-pulse"}`,style:Z?void 0:{background:"var(--status-warning)"},title:Z?"CDP connected":"CDP connecting..."})]},C.id)}),y.map(C=>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:C.cliName||"CLI"})]},C.id)),S.map(C=>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:C.cliName||"ACP"})]},C.id))]}):e.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(h||u)&&e.jsx("div",{className:`text-xs mt-2 px-1 ${c==="error"||f==="error"?"text-red-400":c==="done"||f==="done"?"text-green-400":"text-text-muted"}`,children:u||h})]}),x==="disconnect"&&e.jsx(us,{title:"🔌 Disconnect Machine",message:`Disconnect "${p}" from ADHDev?
|
|
43
43
|
|
|
44
44
|
This will close the server connection. The daemon process will continue running on the machine and will automatically reconnect.
|
|
45
45
|
|
|
@@ -50,7 +50,7 @@ This will:
|
|
|
50
50
|
• Delete the machine registration
|
|
51
51
|
• Require restarting "adhdev-standalone" on that machine
|
|
52
52
|
|
|
53
|
-
Use this if you want to permanently remove a machine.`,confirmLabel:"Remove Machine",confirmColor:"red",onConfirm:R,onCancel:()=>d(null)})]})}const xa=[{id:"dark",label:"Dark",icon:"🌙"},{id:"light",label:"Light",icon:"☀️"},{id:"system",label:"System",icon:"💻"}];function pa(){const{preference:t,setPreference:s}=ca();return e.jsx("div",{className:"flex gap-2",children:xa.map(n=>e.jsxs("button",{onClick:()=>s(n.id),className:`px-3 py-1.5 rounded-lg border text-sm font-medium transition-colors flex items-center gap-1.5 ${t===n.id?"bg-accent border-accent text-white":"bg-bg-glass border-border-subtle hover:bg-bg-secondary text-text-muted hover:text-text-primary"}`,children:[e.jsx("span",{children:n.icon}),n.label]},n.id))})}const zt={bgPrimary:"#0a0e1a",bgSecondary:"#0f1320",surfacePrimary:"#111726",textPrimary:"#f0f0f5",textSecondary:"#9ca3af",textMuted:"#6b7280",borderSubtle:"#1d2536",borderDefault:"#313c52",accentColor:"#d97706",userBubble:"#f59e0b",userText:"#1a1a1a",assistantBubble:"#111726",assistantText:"#f0f0f5",containerBg:"#0f1320",sendButton:"#d97706",inputBorder:"#313c52",bubbleRadius:16},Ft={bgPrimary:"#fff8ee",bgSecondary:"#fff1de",surfacePrimary:"#ffffff",textPrimary:"#24160f",textSecondary:"#6f6255",textMuted:"#938374",borderSubtle:"#e7d3ba",borderDefault:"#d7b892",accentColor:"#d97706",userBubble:"#f59e0b",userText:"#1a1a1a",assistantBubble:"#fffaf4",assistantText:"#24160f",containerBg:"#fff8ee",sendButton:"#d97706",inputBorder:"#d7b892",bubbleRadius:16},ma=[{id:"midnight",name:"Midnight",description:"Classic violet theme",preview:{dark:{userBubble:"#8b5cf6",assistantBubble:"#18181d",assistantBorder:"1px solid rgba(255,255,255,0.08)",containerBg:"#0f0f13",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"#7c3aed",assistantBubble:"#ffffff",assistantBorder:"1px solid rgba(0,0,0,0.08)",containerBg:"#f0f1f5",textColor:"#52525b"}}},{id:"ember",name:"Ember",description:"Default landing-inspired amber theme",preview:{dark:{userBubble:"#f59e0b",assistantBubble:"#111726",assistantBorder:"1px solid rgba(255,255,255,0.08)",containerBg:"#0a0e1a",textColor:"#9ca3af"},light:{userBubble:"#f59e0b",assistantBubble:"#fffaf4",assistantBorder:"1px solid rgba(146,64,14,0.10)",containerBg:"#fff8ee",textColor:"#6f6255"}}},{id:"aurora",name:"Aurora",description:"Pink accent theme",preview:{dark:{userBubble:"#ec4899",assistantBubble:"#1e1b2e",assistantBorder:"1px solid rgba(236,72,153,0.12)",containerBg:"#0f0d17",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"#ec4899",assistantBubble:"#fef2f8",assistantBorder:"1px solid rgba(236,72,153,0.15)",containerBg:"#f0f1f5",textColor:"#1a1a2e"}}},{id:"honey",name:"Honey",description:"Warm yellow accents",preview:{dark:{userBubble:"#fbbf24",assistantBubble:"#1c1c1e",assistantBorder:"1px solid rgba(255,255,255,0.06)",containerBg:"#111113",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"#fbbf24",assistantBubble:"#fffbeb",assistantBorder:"1px solid rgba(251,191,36,0.15)",containerBg:"#f0f1f5",textColor:"#1a1a2e"}}}],nn="adhdev-chat-theme",rn="adhdev-chat-theme-custom";function vt(){return typeof window>"u"?"ember":localStorage.getItem(nn)||"ember"}function Ie(t){try{const s=localStorage.getItem(rn);if(s){const n=JSON.parse(s);return{...t==="dark"?zt:Ft,...n[t]}}}catch{}return t==="dark"?zt:Ft}function pt(t,s){localStorage.setItem(rn,JSON.stringify({dark:t,light:s}))}function Se(t,s){const n=parseInt(t.slice(1,3),16),r=parseInt(t.slice(3,5),16),a=parseInt(t.slice(5,7),16);return`rgba(${n}, ${r}, ${a}, ${s})`}function Ct(t,s){const n=Math.min(255,parseInt(t.slice(1,3),16)+s),r=Math.min(255,parseInt(t.slice(3,5),16)+s),a=Math.min(255,parseInt(t.slice(5,7),16)+s);return`#${n.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}const fa={midnight:{dark:"#8b5cf6",light:"#7c3aed"},ember:{dark:"#d97706",light:"#d97706"},aurora:{dark:"#ec4899",light:"#ec4899"},honey:{dark:"#fbbf24",light:"#fbbf24"}};function at(t,s){var a;const n=(a=fa[t])==null?void 0:a[s];if(!n)return;const r=document.documentElement;r.style.setProperty("--accent-primary",n),r.style.setProperty("--accent-primary-light",Ct(n,24)),r.style.setProperty("--accent-gradient",`linear-gradient(135deg, ${n}, ${Ct(n,18)})`),r.style.setProperty("--border-accent",Se(n,.35)),r.style.setProperty("--nav-active-bg",Se(n,.1)),r.style.setProperty("--nav-active-shadow",`inset 3px 0 0 ${n}, 0 0 12px ${Se(n,.06)}`)}function Ke(t){const s=document.documentElement;s.style.setProperty("--bg-primary",t.bgPrimary),s.style.setProperty("--bg-secondary",t.bgSecondary),s.style.setProperty("--bg-card",Se(t.surfacePrimary,.92)),s.style.setProperty("--surface-primary",t.surfacePrimary),s.style.setProperty("--surface-secondary",t.bgSecondary),s.style.setProperty("--bg-glass",Se(t.borderSubtle,.15)),s.style.setProperty("--bg-glass-hover",Se(t.borderSubtle,.25)),s.style.setProperty("--text-primary",t.textPrimary),s.style.setProperty("--text-secondary",t.textSecondary),s.style.setProperty("--text-muted",t.textMuted),s.style.setProperty("--border-subtle",Se(t.borderSubtle,.5)),s.style.setProperty("--border-default",Se(t.borderDefault,.5)),s.style.setProperty("--accent-primary",t.accentColor),s.style.setProperty("--accent-primary-light",Ct(t.accentColor,30)),s.style.setProperty("--accent-gradient",`linear-gradient(135deg, ${t.accentColor}, ${Ct(t.accentColor,40)})`),s.style.setProperty("--border-accent",Se(t.accentColor,.35)),s.style.setProperty("--nav-active-bg",Se(t.accentColor,.1)),s.style.setProperty("--nav-active-shadow",`inset 3px 0 0 ${t.accentColor}, 0 0 12px ${Se(t.accentColor,.06)}`),s.style.setProperty("--chat-user-bg",t.userBubble),s.style.setProperty("--chat-user-color",t.userText),s.style.setProperty("--chat-user-radius",`${t.bubbleRadius}px ${t.bubbleRadius}px 4px ${t.bubbleRadius}px`),s.style.setProperty("--chat-assistant-bg",t.assistantBubble),s.style.setProperty("--chat-assistant-color",t.assistantText),s.style.setProperty("--chat-assistant-radius",`${t.bubbleRadius}px ${t.bubbleRadius}px ${t.bubbleRadius}px 4px`),s.style.setProperty("--chat-assistant-border",`1px solid ${Se(t.accentColor,.12)}`),s.style.setProperty("--chat-container-bg",t.containerBg),s.style.setProperty("--chat-thought-accent",t.accentColor),s.style.setProperty("--chat-tool-accent",t.accentColor),s.style.setProperty("--chat-action-color",t.accentColor),s.style.setProperty("--chat-send-bg",t.sendButton),s.style.setProperty("--chat-input-border",t.inputBorder)}function Yt(){const t=document.documentElement;["--bg-primary","--bg-secondary","--bg-card","--surface-primary","--surface-secondary","--bg-glass","--bg-glass-hover","--text-primary","--text-secondary","--text-muted","--border-subtle","--border-default","--accent-primary","--accent-primary-light","--accent-gradient","--border-accent","--nav-active-bg","--nav-active-shadow","--chat-user-bg","--chat-user-color","--chat-user-radius","--chat-assistant-bg","--chat-assistant-color","--chat-assistant-radius","--chat-assistant-border","--chat-container-bg","--chat-thought-accent","--chat-tool-accent","--chat-action-color","--chat-send-bg","--chat-input-border"].forEach(n=>t.style.removeProperty(n))}function ga(t){if(localStorage.setItem(nn,t),document.documentElement.setAttribute("data-chat-theme",t),t==="custom"){const s=ze()?"dark":"light";Ke(Ie(s))}else Yt(),at(t,ze()?"dark":"light")}function ba(){const t=vt();if(document.documentElement.setAttribute("data-chat-theme",t),t==="custom"){const s=ze()?"dark":"light";Ke(Ie(s))}else Yt(),at(t,ze()?"dark":"light")}function ze(){const t=document.documentElement.getAttribute("data-theme");return t?t==="dark":window.matchMedia("(prefers-color-scheme: dark)").matches}function ge({label:t,value:s,onChange:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:110},children:t}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("input",{type:"color",value:s,onChange:r=>n(r.target.value),style:{width:28,height:28,border:"none",borderRadius:6,cursor:"pointer",background:"transparent",padding:0}}),e.jsx("input",{type:"text",value:s,onChange:r=>{/^#[0-9a-fA-F]{0,6}$/.test(r.target.value)&&n(r.target.value)},style:{width:72,fontSize:"0.7rem",fontFamily:"monospace",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"3px 6px",color:"var(--text-primary)"}})]})]})}function et({title:t,children:s}){return e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("div",{style:{fontSize:"0.65rem",fontWeight:700,textTransform:"uppercase",color:"var(--text-muted)",letterSpacing:"0.08em",marginBottom:8,borderBottom:"1px solid var(--border-subtle)",paddingBottom:4},children:t}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s})]})}function ya({dark:t,onColorsChange:s}){const n=t?"dark":"light",[r,a]=o.useState(()=>Ie(n));o.useEffect(()=>{a(Ie(n))},[n]);const c=o.useCallback((i,h)=>{a(l=>{const x={...l,[i]:h},f=Ie(n==="dark"?"light":"dark");return n==="dark"?pt(x,f):pt(f,x),Ke(x),s(x),x})},[n,s]);return e.jsxs("div",{style:{marginTop:12,padding:"16px 18px",background:"var(--bg-glass)",border:"1px solid var(--border-subtle)",borderRadius:12},children:[e.jsxs("div",{style:{fontSize:"0.75rem",fontWeight:700,color:"var(--text-primary)",marginBottom:14,display:"flex",alignItems:"center",gap:8},children:["🎨 Custom Theme Editor",e.jsxs("span",{style:{fontSize:"0.65rem",fontWeight:500,color:"var(--text-muted)",background:"var(--bg-glass)",padding:"2px 8px",borderRadius:4},children:[t?"🌙 Dark":"☀️ Light"," mode"]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsxs(et,{title:"App Background",children:[e.jsx(ge,{label:"Background",value:r.bgPrimary,onChange:i=>c("bgPrimary",i)}),e.jsx(ge,{label:"Surface",value:r.bgSecondary,onChange:i=>c("bgSecondary",i)}),e.jsx(ge,{label:"Card",value:r.surfacePrimary,onChange:i=>c("surfacePrimary",i)})]}),e.jsxs(et,{title:"App Text",children:[e.jsx(ge,{label:"Primary",value:r.textPrimary,onChange:i=>c("textPrimary",i)}),e.jsx(ge,{label:"Secondary",value:r.textSecondary,onChange:i=>c("textSecondary",i)}),e.jsx(ge,{label:"Muted",value:r.textMuted,onChange:i=>c("textMuted",i)})]}),e.jsxs(et,{title:"Borders & Accent",children:[e.jsx(ge,{label:"Border subtle",value:r.borderSubtle,onChange:i=>c("borderSubtle",i)}),e.jsx(ge,{label:"Border default",value:r.borderDefault,onChange:i=>c("borderDefault",i)}),e.jsx(ge,{label:"Accent",value:r.accentColor,onChange:i=>c("accentColor",i)})]})]}),e.jsxs("div",{children:[e.jsxs(et,{title:"Chat Bubbles",children:[e.jsx(ge,{label:"User bubble",value:r.userBubble,onChange:i=>c("userBubble",i)}),e.jsx(ge,{label:"User text",value:r.userText,onChange:i=>c("userText",i)}),e.jsx(ge,{label:"Agent bubble",value:r.assistantBubble,onChange:i=>c("assistantBubble",i)}),e.jsx(ge,{label:"Agent text",value:r.assistantText,onChange:i=>c("assistantText",i)})]}),e.jsxs(et,{title:"Chat Layout",children:[e.jsx(ge,{label:"Chat BG",value:r.containerBg,onChange:i=>c("containerBg",i)}),e.jsx(ge,{label:"Send button",value:r.sendButton,onChange:i=>c("sendButton",i)}),e.jsx(ge,{label:"Input border",value:r.inputBorder,onChange:i=>c("inputBorder",i)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:110},children:"Bubble radius"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1},children:[e.jsx("input",{type:"range",min:4,max:24,value:r.bubbleRadius,onChange:i=>c("bubbleRadius",Number(i.target.value)),style:{flex:1,accentColor:"var(--accent-primary)"}}),e.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)",width:28,textAlign:"right"},children:[r.bubbleRadius,"px"]})]})]})]})]})]}),e.jsx("button",{onClick:()=>{const i=t?zt:Ft,l=Ie(t?"light":"dark");t?pt(i,l):pt(l,i),a(i),Ke(i),s(i)},style:{marginTop:10,fontSize:"0.7rem",color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"4px 10px",cursor:"pointer"},children:"Reset to defaults"})]})}function ja(){const[t,s]=o.useState(vt),[n,r]=o.useState(!0),[a,c]=o.useState(()=>Ie("dark"));o.useEffect(()=>{r(ze());const l=new MutationObserver(()=>{const f=ze();r(f);const b=vt();b==="custom"?Ke(Ie(f?"dark":"light")):at(b,f?"dark":"light")});l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});const x=window.matchMedia("(prefers-color-scheme: dark)"),d=()=>{const f=ze();r(f);const b=vt();b==="custom"?Ke(Ie(f?"dark":"light")):at(b,f?"dark":"light")};return x.addEventListener("change",d),()=>{l.disconnect(),x.removeEventListener("change",d)}},[]),o.useEffect(()=>{document.documentElement.setAttribute("data-chat-theme",t),t==="custom"?Ke(Ie(n?"dark":"light")):(Yt(),at(t,n?"dark":"light"))},[t,n]),o.useEffect(()=>{c(Ie(n?"dark":"light"))},[n]);const i=l=>{s(l),ga(l)},h=[...ma,{id:"custom",name:"Custom",description:"Full app + chat customization",preview:{dark:{userBubble:a.userBubble,assistantBubble:a.assistantBubble,assistantBorder:`1px solid ${a.accentColor}22`,containerBg:a.containerBg,textColor:a.assistantText},light:{userBubble:a.userBubble,assistantBubble:a.assistantBubble,assistantBorder:`1px solid ${a.accentColor}22`,containerBg:a.containerBg,textColor:a.assistantText}}}];return e.jsxs("div",{children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-3",children:h.map(l=>{const x=t===l.id,d=n?l.preview.dark:l.preview.light,f=l.id==="honey"||l.id==="ember"?"#1a1a1a":l.id==="custom"?a.userText:"#fff";return e.jsxs("button",{onClick:()=>i(l.id),className:"text-left rounded-xl p-3 transition-all",style:{background:x?"var(--bg-glass-hover)":"var(--bg-glass)",border:x?"2px solid var(--accent-primary)":"2px solid var(--border-subtle)",opacity:x?1:.75},children:[e.jsxs("div",{className:"rounded-lg p-3 mb-2.5 flex flex-col gap-1.5",style:{background:d.containerBg},children:[e.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"Hello! How can I help?"}),e.jsx("div",{className:"self-end rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.userBubble,color:f},children:"Fix the bug please"}),e.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"On it! ✨"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[x&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-accent shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-bold text-text-primary",children:l.id==="custom"?"🎨 Custom":l.name}),e.jsx("div",{className:"text-[10px] text-text-muted",children:l.description})]})]})]},l.id)})}),t==="custom"&&e.jsx(ya,{dark:n,onColorsChange:l=>c(l)})]})}const an="adhdev_hiddenTabs";function va(){try{const t=localStorage.getItem(an);if(t)return new Set(JSON.parse(t))}catch{}return new Set}function tt(t){try{localStorage.setItem(an,JSON.stringify([...t]))}catch{}}function on(){const[t,s]=o.useState(va),n=o.useCallback(l=>{s(x=>{const d=new Set(x);return d.has(l)?d.delete(l):d.add(l),tt(d),d})},[]),r=o.useCallback(l=>{s(x=>{if(x.has(l))return x;const d=new Set(x);return d.add(l),tt(d),d})},[]),a=o.useCallback(l=>{s(x=>{if(!x.has(l))return x;const d=new Set(x);return d.delete(l),tt(d),d})},[]),c=o.useCallback((l,x)=>{s(d=>{const f=new Set(d);for(const b of x)f.add(b);return tt(f),f})},[]),i=o.useCallback((l,x)=>{s(d=>{const f=new Set(d);for(const b of x)f.delete(b);return tt(f),f})},[]),h=o.useCallback(l=>t.has(l),[t]);return{hiddenTabs:t,toggleTab:n,hideTab:r,showTab:a,hideAllForDaemon:c,showAllForDaemon:i,isHidden:h}}function cn({visibleConversations:t,clearedTabs:s,setClearedTabs:n,setActionLogs:r}){o.useEffect(()=>{Gr()},[]);const a=o.useMemo(()=>t.map(c=>({id:c.tabKey,name:c.title||c.agentName||c.ideId,status:c.status,activeModal:c.modalMessage?{message:c.modalMessage,buttons:c.modalButtons}:null})),[t]);return Jr(a),o.useEffect(()=>{if(Object.keys(s).length===0)return;const i=setTimeout(()=>{n(h=>{const l=Date.now(),x={};for(const[d,f]of Object.entries(h))l-f<5e3&&(x[d]=f);return Object.keys(x).length===Object.keys(h).length?h:x})},5500);return()=>clearTimeout(i)},[s,n]),o.useEffect(()=>{const c=setInterval(()=>{const i=Date.now()-3e5;r(h=>{const l=h.filter(x=>x.timestamp>i).slice(-100);return l.length===h.length?h:l})},6e4);return()=>clearInterval(c)},[r]),null}function wa(t){const s=t.filter(r=>r.type!=="adhdev-daemon"),n=new Map;for(const r of s){const a=n.get(r.id);if(!a){n.set(r.id,r);continue}const c=(a.workspace?1:0)+(a.activeChat?1:0);((r.workspace?1:0)+(r.activeChat?1:0)>c||(r.timestamp||0)>(a.timestamp||0))&&n.set(r.id,r)}return Array.from(n.values())}function mt(t,s){if(t.length!==s.length)return!1;for(let n=0;n<t.length;n+=1)if(t[n]!==s[n])return!1;return!0}function ka(t,s){const n=Date.now();return t.map(r=>{const a=s[r.tabKey];return a&&n-a<5e3?{...r,messages:[],title:""}:r})}function Na(t,s){const n=[],r=t.sessionId||t.instanceId;n.push({key:t.id,ref:s[t.id]}),r&&n.push({key:r,ref:s[r]});for(const a of t.childSessions||[]){const c=a.id||a.providerType,i=`${t.id}:${c}`;n.push({key:i,ref:s[i]}),n.push({key:a.id,ref:s[a.id]})}return n}function Sa(t,s){if(t.length!==s.length)return!1;for(let n=0;n<t.length;n+=1)if(t[n].key!==s[n].key||t[n].ref!==s[n].ref)return!1;return!0}function Ca({ides:t,connectionStates:s,localUserMessages:n,clearedTabs:r,hiddenTabs:a}){const c=o.useRef([]),i=o.useRef([]),h=o.useRef([]),l=o.useRef([]),x=o.useMemo(()=>{const p=wa(t);return mt(c.current,p)?c.current:(c.current=p,p)},[t]),d=o.useMemo(()=>Gs(t),[t]),f=o.useRef(new Map),b=o.useMemo(()=>{var T;const p=new Map,w=[];for(const y of x){const S=y.daemonId||((T=y.id)==null?void 0:T.split(":")[0])||y.id,k=s[S]||"new",j=y.daemonId&&d[y.daemonId]||void 0,_=Na(y,n),R=f.current.get(y.id);if(R&&R.ide===y&&R.connectionState===k&&R.machineName===j&&Sa(R.localRefs,_)){p.set(y.id,R),w.push(...R.conversations);continue}const D=Xs(y,n,{machineName:j,connectionState:k}),M={ide:y,connectionState:k,machineName:j,localRefs:_,conversations:D};p.set(y.id,M),w.push(...D)}return f.current=p,w},[x,n,s,d]),u=o.useMemo(()=>{const p=ka(b,r);return mt(i.current,p)?i.current:(i.current=p,p)},[b,r]),m=o.useMemo(()=>{const p=new Map;for(const w of u)w.sessionId&&p.set(w.sessionId,w),p.set(w.ideId,w),p.set(w.tabKey,w),p.set(w.ideType,w),p.set(w.agentType,w);return p},[u]),v=o.useCallback(p=>{if(p)return m.get(p)},[m]),N=o.useMemo(()=>{const p=u.filter(w=>!a.has(w.tabKey));return mt(h.current,p)?h.current:(h.current=p,p)},[u,a]),g=o.useMemo(()=>{const p=N.map(w=>w.tabKey);return mt(l.current,p)?l.current:(l.current=p,p)},[N]);return{chatIdes:x,conversations:u,visibleConversations:N,visibleTabKeys:g,resolveConversationByTarget:v}}function ln({ides:t,sendDaemonCommand:s,setToasts:n,setLocalUserMessages:r,resolveConversationByTarget:a}){o.useEffect(()=>{Pe.setIdes(t)},[t]),o.useEffect(()=>{Pe.setResolveAction((c,i,h)=>{s(c,i,h).catch(()=>{})})},[s]),o.useEffect(()=>{const c=Pe.onToast(l=>{n(d=>d.some(b=>b.message===l.message&&l.timestamp-b.timestamp<3e3)?d:[...d.slice(-4),{id:l.id,message:l.message,type:l.type,timestamp:l.timestamp,targetKey:l.targetKey,actions:l.actions}]);const x=l.duration||5e3;setTimeout(()=>n(d=>d.filter(f=>f.id!==l.id)),x)}),i=Pe.onSystemMessage((l,x)=>{r(d=>({...d,[l]:[...d[l]||[],x]}))}),h=Pe.onClearSystemMessage((l,x)=>{r(d=>{var f;return(f=d[l])!=null&&f.length?{...d,[l]:d[l].filter(b=>{var u;return!(b.role==="system"&&((u=b._localId)!=null&&u.startsWith(x)))})}:d})});return()=>{c(),i(),h()}},[n,r]),o.useEffect(()=>{const c=Vs.on("status_event",i=>Pe.handleRawEvent(i,"ws"));return()=>{c()}},[]),o.useEffect(()=>{var i;const c=h=>{const l=h.data;if((l==null?void 0:l.type)!=="notification_action"||l.action!=="approve"||!(l.ideId||l.targetSessionId||l.targetKey))return;const x=l.targetSessionId||l.targetKey||l.ideId,d=a(x),f=(d==null?void 0:d.ideId)||l.ideId;f&&s(f,"resolve_action",{action:"approve",button:"Approve",...(d==null?void 0:d.sessionId)&&{targetSessionId:d.sessionId},...l.targetSessionId&&{targetSessionId:l.targetSessionId}}).catch(b=>console.error("[SW Action] approve failed:",b))};return(i=navigator.serviceWorker)==null||i.addEventListener("message",c),()=>{var h;return(h=navigator.serviceWorker)==null?void 0:h.removeEventListener("message",c)}},[a,s])}const Ia="adhdev_dashboardLayout_v1",Ma="adhdev_dashboardDockview_v1",st={splitGroups:"adhdev_splitGroups",focusedGroup:"adhdev_focusedGroup",groupActiveTabs:"adhdev_groupActiveTabs",groupTabOrders:"adhdev_groupTabOrders",splitSizes:"adhdev_splitSizes"},nt={groupAssignments:[],focusedGroup:0,groupActiveTabIds:{},groupTabOrders:{},groupSizes:[]};function qe(t,s){try{const n=localStorage.getItem(t);return n?JSON.parse(n):s}catch{return s}}function Ta(t){try{return localStorage.getItem(t)}catch{return null}}function dn(t){return t<768?"mobile":t<1280?"desktop-narrow":"desktop-wide"}function un(t){return`${Ia}:${t}`}function hn(){const t=Ta(st.focusedGroup),s=qe(st.splitGroups,[]),n=qe(st.groupActiveTabs,{}),r=qe(st.groupTabOrders,{}),a=qe(st.splitSizes,[]);return t!==null||s.length>0||Object.keys(n).length>0||Object.keys(r).length>0||a.length>0?{groupAssignments:s,focusedGroup:t&&parseInt(t,10)||0,groupActiveTabIds:n,groupTabOrders:r,groupSizes:a}:null}function Ea(){return hn()}function Aa(t){const s=un(t),n=qe(s,null);return n||hn()}function Ra(t,s){try{const n=s.groupAssignments.length===0&&s.focusedGroup===0&&Object.keys(s.groupActiveTabIds).length===0&&Object.keys(s.groupTabOrders).length===0&&s.groupSizes.length===0,r=un(t);if(n){localStorage.removeItem(r);return}localStorage.setItem(r,JSON.stringify(s))}catch{}}function xn(t){return`${Ma}:${t}`}function La(t){const s=xn(t);return qe(s,null)}function _a(t,s){try{const n=xn(t);if(!s){localStorage.removeItem(n);return}localStorage.setItem(n,JSON.stringify(s))}catch{}}function $a(){return{groupAssignments:[...nt.groupAssignments],focusedGroup:nt.focusedGroup,groupActiveTabIds:{...nt.groupActiveTabIds},groupTabOrders:{...nt.groupTabOrders},groupSizes:[...nt.groupSizes]}}function Pa(){const[t]=o.useState(()=>dn(typeof window<"u"?window.innerWidth:1280)),[s,n]=o.useState(()=>new Map),[r,a]=o.useState(0),[c,i]=o.useState({}),[h,l]=o.useState({}),[x,d]=o.useState([]),[f,b]=o.useState(()=>typeof window<"u"&&window.innerWidth<768),[u,m]=o.useState(!1),v=o.useCallback(()=>{if(u)return;const N=Aa(t)??$a();n(new Map(N.groupAssignments)),a(N.focusedGroup),i(N.groupActiveTabIds),l(N.groupTabOrders),d(N.groupSizes),m(!0)},[u,t]);return o.useEffect(()=>{u&&Ra(t,{groupAssignments:[...s.entries()],focusedGroup:r,groupActiveTabIds:c,groupTabOrders:h,groupSizes:x})},[u,t,s,r,c,h,x]),o.useEffect(()=>{const N=window.matchMedia("(max-width: 767px)"),g=p=>b(p.matches);return N.addEventListener("change",g),()=>N.removeEventListener("change",g)},[]),{groupAssignments:s,setGroupAssignments:n,focusedGroup:r,setFocusedGroup:a,groupActiveTabIds:c,setGroupActiveTabIds:i,groupTabOrders:h,setGroupTabOrders:l,groupSizes:x,setGroupSizes:d,isMobile:f,hasHydratedStoredLayout:u,hydrateStoredLayout:v}}function Da({urlActiveTab:t,conversations:s,resolveConversationByTarget:n,normalizedGroupAssignments:r,hasHydratedStoredLayout:a,hydrateStoredLayout:c,setGroupActiveTabIds:i,setFocusedGroup:h,setSearchParams:l,historyModalOpen:x,activeConv:d,isRefreshingHistory:f,ides:b,handleRefreshHistory:u}){const m=o.useRef(!1),v=o.useRef(!1),N=o.useRef(null),g=o.useRef(!1);o.useEffect(()=>{if(!t||m.current||s.length===0)return;if(!a){c();return}const p=n(t);if(!p)return;const w=r.get(p.tabKey)??0;i(T=>({...T,[w]:p.tabKey})),h(w),m.current=!0,v.current=!0,N.current!=null&&(window.clearTimeout(N.current),N.current=null),l(T=>{const y=new URLSearchParams(T);return y.delete("activeTab"),y},{replace:!0})},[t,s,n,r,a,c,i,h,l]),o.useEffect(()=>{if(!(v.current||a)&&s.length!==0){if(!t){c(),v.current=!0;return}if(m.current){v.current=!0;return}if(N.current==null)return N.current=window.setTimeout(()=>{N.current=null,!(v.current||a)&&(c(),v.current=!0)},1500),()=>{N.current!=null&&(window.clearTimeout(N.current),N.current=null)}}},[t,s.length,a,c]),o.useEffect(()=>{if(!x){g.current=!1;return}if(!d||g.current||f)return;const p=b.find(w=>w.id===d.ideId);p&&(!p.chats||p.chats.length===0)&&(g.current=!0,u())},[x,d,f,b,u]),o.useEffect(()=>{if(!d)return;let p=null,w=0,T=-1,y=0;const S=()=>{p=null;const k=Array.from(document.querySelectorAll("[data-chat-scroll]")).filter(_=>_.offsetParent!==null);if(k.length===0){w<18&&(w+=1,p=requestAnimationFrame(S));return}let j=0;for(const _ of k)_.scrollTop=_.scrollHeight,j+=_.scrollHeight;j===T?y+=1:(y=0,T=j),w+=1,!(y>=2||w>=18)&&(p=requestAnimationFrame(S))};return p=requestAnimationFrame(S),()=>{p!=null&&cancelAnimationFrame(p)}},[d==null?void 0:d.tabKey])}function Le(t){if(!t)return{};const s=t.sessionId?{targetSessionId:t.sessionId}:{};return je(t)||fe(t)?{...s,agentType:t.agentType||t.ideType}:t.streamSource==="agent-stream"?{...s,agentType:t.agentType}:s}function It(t){return t&&(t.ideId||t.daemonId)||""}function ft(t,s){t(n=>[...n,{id:Date.now(),message:s,type:"warning",timestamp:Date.now()}])}function Ba({sendDaemonCommand:t,activeConv:s,updateIdeChats:n,setToasts:r,setLocalUserMessages:a,setClearedTabs:c}){const[i,h]=o.useState(!1),[l,x]=o.useState(!1),d=o.useCallback(async m=>{try{await t("standalone","launch_ide",{ideType:m,enableCdp:!0})}catch(v){console.error("Launch failed",v)}},[t]),f=o.useCallback(async(m,v)=>{try{const N=m||(s==null?void 0:s.daemonId)||"",g=await t(N,"switch_chat",{id:v,sessionId:v,...Le(s)}),p=g==null?void 0:g.result;if((g==null?void 0:g.success)===!0||p==="switched"||p==="switched-by-title")return;p===!1||p==="not_found"?ft(r,"⚠️ Session tab not found — try refreshing history"):typeof p=="string"&&p.startsWith("error:")?ft(r,`⚠️ Switch error: ${p}`):ft(r,"⚠️ Session switch failed")}catch(N){console.error("Switch failed",N),ft(r,`❌ Switch failed: ${N.message||"connection error"}`)}},[s,t,r]),b=o.useCallback(async()=>{if(!(!s||i)){h(!0);try{const m=It(s);await t(m,"new_chat",{...Le(s)}),c(v=>({...v,[s.tabKey]:Date.now()})),a(v=>({...v,[s.tabKey]:[]}))}catch(m){console.error("New chat failed",m)}finally{h(!1)}}},[s,i,t,c,a]),u=o.useCallback(async()=>{var m;if(!(!s||l)){x(!0);try{const v=It(s),N=await t(v,"list_chats",{forceExpand:!0,...Le(s)}),g=(N==null?void 0:N.chats)||((m=N==null?void 0:N.result)==null?void 0:m.chats);N!=null&&N.success&&Array.isArray(g)&&n(s.ideId,g)}catch(v){console.error("Refresh history failed",v)}finally{x(!1)}}},[s,l,t,n]);return{isCreatingChat:i,isRefreshingHistory:l,handleLaunchIde:d,handleSwitchSession:f,handleNewChat:b,handleRefreshHistory:u}}function Wa(t,s){if(t.size!==s.size)return!1;for(const[n,r]of t)if(s.get(n)!==r)return!1;return!0}function Oa(t,s){return t.length!==s.length?!1:t.every((n,r)=>n===s[r])}function hs(t,s){const n=Object.keys(t),r=Object.keys(s);return n.length!==r.length?!1:n.every(a=>s[Number(a)]===t[Number(a)])}function gt(t,s){const n=new Set(s),r=s.length>0?[0]:[];for(const[i,h]of t)!n.has(i)||h<=0||r.includes(h)||r.push(h);r.sort((i,h)=>i-h);const a={};r.forEach((i,h)=>{a[i]=h}),r.length===0&&(a[0]=0);const c=new Map;for(const[i,h]of t){if(!n.has(i)||h<=0)continue;const l=a[h];typeof l=="number"&&l>0&&c.set(i,l)}return{assignments:c,groupCount:Math.max(1,r.length),mapping:a,usedGroups:r}}function xs(t,s){const n={};for(const[r,a]of Object.entries(t)){const c=s[Number(r)];typeof c=="number"&&(n[c]=a)}return n}function Ka(t,s,n){if(s.length===0)return 0;if(typeof n[t]=="number")return n[t];const r=[...s].reverse().find(a=>a<t)??s[0];return n[r]??0}function za(t,s,n){if(s.length<=1)return[];const r=s.map(i=>t[i]).filter(i=>Number.isFinite(i)),a=r.length===s.length?r:Array(n).fill(100/n),c=a.reduce((i,h)=>i+h,0);return c>0?a.map(i=>i/c*100):Array(n).fill(100/n)}function ps(t,s){const n={};for(const[r,a]of Object.entries(t)){const c=Number(r);n[c>=s?c+1:c]=a}return n}function ms(t){return Array(t).fill(100/t)}function Fa({groupAssignments:t,setGroupAssignments:s,setFocusedGroup:n,setGroupActiveTabIds:r,setGroupTabOrders:a,groupSizes:c,setGroupSizes:i,isMobile:h,visibleConversations:l,visibleTabKeys:x}){const d=o.useRef(null),f=o.useMemo(()=>gt(t,x),[t,x]),b=f.assignments,u=o.useMemo(()=>h?1:f.groupCount,[f.groupCount,h]),m=u>1,v=o.useCallback((y,S)=>{s(k=>{const j=new Map(gt(k,x).assignments);return S===0?j.delete(y):j.set(y,S),j}),r(k=>({...k,[S]:y})),n(S)},[s,x,r,n]),N=o.useCallback(y=>{s(S=>{const k=gt(S,x).assignments,j=new Map;for(const[_,R]of k)R!==y&&(R>y?j.set(_,R-1):j.set(_,R));return j}),i(S=>{if(S.length<=1)return[];const k=[...S];k.splice(y,1);const j=k.reduce((_,R)=>_+R,0);return j>0?k.map(_=>_/j*100):[]}),n(0)},[s,x,i,n]),g=o.useCallback((y,S)=>{S.preventDefault();const k=d.current;if(!k)return;const j=S.clientX,_=k.offsetWidth,R=c.length===u?[...c]:ms(u),D=E=>{const O=(E.clientX-j)/_*100,C=[...R];C[y]=Math.max(15,R[y]+O),C[y+1]=Math.max(15,R[y+1]-O),i(C)},M=()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",M),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",D),document.addEventListener("mouseup",M)},[c,u,i]),p=o.useCallback((y,S,k)=>{if(u>=4)return;const j=k==="left"?S:S+1;s(_=>{const R=gt(_,x).assignments,D=new Map;for(const M of l){const E=R.get(M.tabKey)??0,$=E>=j?E+1:E;$>0&&D.set(M.tabKey,$)}return j>0&&D.set(y,j),D}),i(_=>{const R=_.length===u?[..._]:ms(u),D=R[S]??100/u,M=Math.max(15,D/2),E=Math.max(15,D/2),$=[...R];$[S]=M,$.splice(j,0,E);const O=$.reduce((C,V)=>C+V,0);return $.map(C=>C/O*100)}),r(_=>{const R=ps(_,j);return R[j]=y,R}),a(_=>{const R=ps(_,j);return R[j]=[y],R}),n(j)},[u,s,x,l,i,r,a,n]);o.useEffect(()=>{Wa(t,b)||s(b)},[t,b,s]),o.useEffect(()=>{const{mapping:y,usedGroups:S}=f;r(k=>{const j=xs(k,y);return hs(k,j)?k:j}),a(k=>{const j=xs(k,y);return hs(k,j)?k:j}),n(k=>{const j=h?0:Ka(k,S,y);return k===j?k:j}),i(k=>{const j=h?[]:za(k,S,f.groupCount);return Oa(k,j)?k:j})},[f,h,r,a,n,i]);const w=o.useMemo(()=>{const y=Array.from({length:u},()=>[]);for(const S of l){const k=b.get(S.tabKey)??0,j=Math.min(k,u-1);y[j].push(S)}return y},[l,b,u]),T=o.useCallback(()=>{s(new Map),n(0)},[s,n]);return{containerRef:d,normalizedGroupAssignments:b,numGroups:u,isSplitMode:m,groupedConvs:w,moveTabToGroup:v,closeGroup:N,handleResizeStart:g,splitTabRelative:p,clearAllSplits:T}}function Ha({ides:t,sendDaemonCommand:s}){const n="0.7.33",r=o.useMemo(()=>t.filter(x=>{if(x.type!=="adhdev-daemon")return!1;const d=x.version||x.daemonVersion||null;return!d||!n?!1:d!==n}),[n,t]),[a,c]=o.useState(!1),[i,h]=o.useState({}),l=o.useCallback(async x=>{var d,f;h(b=>({...b,[x]:"upgrading"}));try{const b=await s(x,"daemon_upgrade",{});(d=b==null?void 0:b.result)!=null&&d.upgraded||(f=b==null?void 0:b.result)!=null&&f.success?h(u=>({...u,[x]:"done"})):h(u=>({...u,[x]:"error"}))}catch{h(b=>({...b,[x]:"error"}))}},[s]);return{versionMismatchDaemons:r,appVersion:n,versionBannerDismissed:a,setVersionBannerDismissed:c,upgradingDaemons:i,handleBannerUpgrade:l}}const pn=o.memo(function({activeConv:s,clearToken:n,isCli:r,ideEntry:a,screenshotUrl:c,clearScreenshot:i,terminalRef:h,handleModalButton:l,handleRelaunch:x,handleSendChat:d,isSendingChat:f,handleFocusAgent:b,isFocusingAgent:u,actionLogs:m,userName:v}){const N=o.useCallback(()=>{i()},[i]);return e.jsxs(e.Fragment,{children:[e.jsx(Ks,{activeConv:s,onModalButton:l}),e.jsx("div",{className:"desktop-only px-3 pt-1 pb-2",children:!r&&s.transport!=="acp"&&c?e.jsx(fr,{screenshotUrl:c,mode:"preview",onDismiss:N}):!r&&s.transport!=="acp"&&s.cdpConnected===!1?e.jsxs("div",{className:"flex items-center gap-2.5 px-3.5 py-2 bg-yellow-500/[0.08] border border-yellow-500/20 rounded-lg text-xs text-text-secondary",children:[e.jsx("span",{className:"text-sm",children:e.jsx(Ut,{size:14})}),e.jsx("span",{className:"flex-1",children:"CDP not connected — chat history & screenshots unavailable."}),e.jsx("button",{className:"btn btn-sm bg-yellow-500/15 text-yellow-500 border border-yellow-500/30 text-[10px] whitespace-nowrap shrink-0",onClick:x,children:"Relaunch with CDP"})]}):null}),r?e.jsx(Lr,{activeConv:s,clearToken:n,terminalRef:h,handleSendChat:d,isSendingChat:f}):e.jsx(Hs,{activeConv:s,ideEntry:a,handleSendChat:d,isSendingChat:f,handleFocusAgent:b,isFocusingAgent:u,actionLogs:m,userName:v})]})},(t,s)=>t.activeConv===s.activeConv&&t.isCli===s.isCli&&t.ideEntry===s.ideEntry&&t.screenshotUrl===s.screenshotUrl&&t.terminalRef===s.terminalRef&&t.handleModalButton===s.handleModalButton&&t.handleRelaunch===s.handleRelaunch&&t.handleSendChat===s.handleSendChat&&t.isSendingChat===s.isSendingChat&&t.handleFocusAgent===s.handleFocusAgent&&t.isFocusingAgent===s.isFocusingAgent&&t.actionLogs===s.actionLogs&&t.userName===s.userName),Lt={unix:{cmd:"curl -fsSL https://adhf.dev/install | sh",shell:"Terminal",prompt:"$ "},powershell:{cmd:"irm https://adhf.dev/install.ps1 | iex",shell:"PowerShell",prompt:"PS> "},cmd:{cmd:"curl -fsSL https://adhf.dev/install.cmd -o %TEMP%\\adhdev.cmd && %TEMP%\\adhdev.cmd",shell:"CMD",prompt:"> "}};function Ua(){return typeof navigator>"u"?"unix":navigator.userAgent.toLowerCase().includes("win")?"windows":"unix"}function Va(){const[t,s]=o.useState("unix"),[n,r]=o.useState("powershell"),[a,c]=o.useState(!1),i=t==="unix"?"unix":n;o.useEffect(()=>{s(Ua())},[]);const h=o.useCallback(()=>{navigator.clipboard.writeText(Lt[i].cmd).catch(()=>{}),c(!0),setTimeout(()=>c(!1),2e3)},[i]);return e.jsxs("div",{className:"text-left bg-bg-secondary border border-border-subtle rounded-xl p-4 font-mono text-[13px] shadow-lg w-full mx-auto leading-relaxed relative select-all",children:[e.jsxs("div",{className:"flex gap-1 mb-3 font-sans",children:[e.jsx("button",{className:`text-[10px] px-2.5 py-1 rounded-md font-bold transition-all cursor-pointer ${t==="unix"?"bg-accent/15 text-accent border border-accent/25":"bg-transparent text-text-muted border border-transparent hover:text-text-secondary"}`,onClick:()=>s("unix"),children:"🍎🐧 macOS / Linux"}),e.jsx("button",{className:`text-[10px] px-2.5 py-1 rounded-md font-bold transition-all cursor-pointer ${t==="windows"?"bg-accent/15 text-accent border border-accent/25":"bg-transparent text-text-muted border border-transparent hover:text-text-secondary"}`,onClick:()=>s("windows"),children:"🪟 Windows"})]}),t==="windows"&&e.jsxs("div",{className:"flex gap-1 mb-3 font-sans",children:[e.jsx("button",{className:`text-[9px] px-2 py-0.5 rounded font-semibold cursor-pointer transition-all ${n==="powershell"?"bg-accent/10 text-accent":"text-text-muted hover:text-text-secondary"}`,onClick:()=>r("powershell"),children:"⚡ PowerShell"}),e.jsx("button",{className:`text-[9px] px-2 py-0.5 rounded font-semibold cursor-pointer transition-all ${n==="cmd"?"bg-accent/10 text-accent":"text-text-muted hover:text-text-secondary"}`,onClick:()=>r("cmd"),children:">_ CMD"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-accent cursor-pointer group",onClick:h,title:"Click to copy",children:[e.jsx("span",{className:"text-text-muted select-none",children:Lt[i].prompt}),e.jsx("span",{className:"flex-1 break-all",children:Lt[i].cmd}),e.jsx("span",{className:"text-[9px] font-sans text-text-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0 select-none",children:a?"✓":"📋"})]}),e.jsxs("div",{className:"text-text-muted text-[10px] font-sans mt-2",children:["Or via npm: ",e.jsx("span",{className:"text-text-secondary font-mono",children:"npm i -g @adhdev/daemon-standalone && adhdev-standalone"})]})]})}function Gt({conversationsCount:t,isSplitMode:s,isStandalone:n,detectedIdes:r,handleLaunchIde:a}){return t===0&&!s&&r&&a?e.jsxs("div",{className:"empty-dashboard flex-1 flex flex-col items-center justify-center -mt-8",children:[e.jsx("div",{className:"glow-orb mb-6 opacity-90 animate-bounce",style:{animationDuration:"3s"},children:e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-16 h-16 object-contain"})}),e.jsxs("div",{className:"text-center max-w-lg",children:[e.jsx("h2",{className:"font-bold text-2xl mb-2.5 tracking-tight text-text-primary",children:"Waiting for your IDE"}),e.jsx("p",{className:"text-[14px] text-text-secondary mb-8 leading-relaxed max-w-md mx-auto",children:n?"Launch any supported IDE or CLI agent to start monitoring automatically.":"Install the ADHDev daemon and link your dashboard to start."}),!n&&e.jsx(Va,{}),n&&r.length>0&&e.jsxs("div",{className:"flex flex-col gap-3 items-center",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Fast Launch"}),e.jsx("div",{className:"flex flex-wrap gap-2.5 justify-center mt-1",children:r.map(c=>e.jsxs("button",{className:"btn btn-sm bg-accent/10 border border-accent/25 text-accent text-xs font-medium px-4 py-2.5 rounded-lg cursor-pointer flex items-center gap-2 transition-all hover:bg-accent/20 hover:scale-105 active:scale-95",onClick:()=>a(c.type),children:[e.jsx(Ds,{size:14,className:"opacity-70"})," Launch ",c.name]},c.type))})]}),!n&&e.jsx("div",{className:"mt-8",children:e.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-accent hover:opacity-80 transition-colors flex items-center justify-center gap-1.5",children:"📚 Read the documentation →"})})]})]}):e.jsx("div",{className:"text-sm text-text-muted opacity-50",children:s?"Move a tab here to view":"No active agent"})}function Xt({sendDaemonCommand:t,activeConv:s,setLocalUserMessages:n,setActionLogs:r,isStandalone:a}){const[c,i]=o.useState(!1),[h,l]=o.useState(!1),x=o.useRef(!1),d=o.useCallback(async m=>{if(!s)return;const v=m.trim();if(!v||x.current)return;const N=s.tabKey;x.current=!0,l(!0);const g=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,p={role:"user",content:v,timestamp:Date.now(),_localId:g};n(w=>({...w,[N]:[...w[N]||[],p]}));try{const w=It(s);if(!w)return;await t(w,"send_chat",{message:v,text:v,...Le(s)}),setTimeout(()=>{const T=Date.now()-6e4;n(y=>{const S=y[N];if(!S)return y;const k=S.filter(j=>j.timestamp>T);return k.length===S.length?y:{...y,[N]:k}})},6e4)}catch(w){console.error("Send failed",w),n(T=>({...T,[N]:(T[N]||[]).filter(y=>y._localId!==g)}))}finally{x.current=!1,l(!1)}},[s,t,n]),f=o.useCallback(async()=>{if(s)try{if(a){await t(s.ideId,"launch_ide",{ideType:s.ideType,enableCdp:!0});return}await t(s.ideId,"vscode_command_exec",{commandId:"adhdev.relaunchWithCdp",args:[{force:!0}]})}catch(m){console.error("Relaunch failed",m)}},[s,a,t]),b=o.useCallback(async m=>{if(s){r(v=>[...v,{ideId:s.tabKey,text:`🖱️ **${m}** clicked`,timestamp:Date.now()}]);try{const N=(s.modalButtons||[]).indexOf(m),g=m.replace(/[⌥⏎⇧⌫⌘⌃]/g,"").trim().toLowerCase(),p=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(g),w=It(s);if(!w)return;(await t(w,"resolve_action",{button:m,action:p?"approve":"reject",...N>=0&&{buttonIndex:N},...Le(s)})).success||r(y=>[...y,{ideId:s.tabKey,text:`⚠️ **${m}** failed — button not found`,timestamp:Date.now()}])}catch(v){console.error("[ModalButton] Error:",v),r(N=>[...N,{ideId:s.tabKey,text:`❌ **${m}** error`,timestamp:Date.now()}])}}},[s,t,r]),u=o.useCallback(async()=>{if(!(!s||c)){i(!0);try{await t(s.ideId,"focus_session",{agentType:s.agentType,...s.sessionId&&{targetSessionId:s.sessionId}})}catch(m){console.error("Focus agent failed",m)}finally{i(!1)}}},[s,c,t]);return{isSendingChat:h,isFocusingAgent:c,handleSendChat:d,handleRelaunch:f,handleModalButton:b,handleFocusAgent:u}}const mn=o.createContext(null);function Jt(){const t=o.useContext(mn);if(!t)throw new Error("DashboardDockviewContext missing");return t}function wt(t){return t.displayPrimary||t.title||t.agentName||t.tabKey}function qa(t){const[,s]=o.useState(0);o.useEffect(()=>{const n=()=>s(a=>a+1),r=[t.onDidActiveGroupChange(n),t.onDidTitleChange(n),t.onDidGroupChange(n)];return()=>{for(const a of r)a.dispose()}},[t])}function Ya(t,s){if(!s)return[t];const n=new Map(s.groupAssignments),r=new Map(t.map(i=>[i.tabKey,i])),a=new Map;for(const i of t){const h=n.get(i.tabKey)??0,l=a.get(h)??[];l.push(i),a.set(h,l)}return[...a.keys()].sort((i,h)=>i-h).map(i=>{const h=a.get(i)??[],x=(s.groupTabOrders[i]??[]).map(f=>r.get(f)).filter(f=>!!f),d=new Set(x.map(f=>f.tabKey));for(const f of h)d.has(f.tabKey)||x.push(f);return x}).filter(i=>i.length>0)}function Ga(t,s,n){var l;const r=Ea(),a=Ya(s,r);let c;for(const x of a){let d;for(const f of x){const b=t.addPanel({id:f.tabKey,component:"conversation",title:wt(f),params:{tabKey:f.tabKey},...d?{position:{referencePanel:d,direction:"within"},inactive:!0}:c?{position:{referencePanel:c,direction:"right"},inactive:!0}:{}});d||(d=b.id)}c=d??c}const i=n??(r?r.groupActiveTabIds[r.focusedGroup]:null)??((l=s[0])==null?void 0:l.tabKey)??null;if(!i)return;const h=t.getPanel(i);h&&h.group.model.openPanel(h)}function fs(t,s){const n=new Set(s.map(r=>r.tabKey));for(const r of[...t.panels])n.has(r.id)||t.removePanel(r);for(const r of s){const a=t.getPanel(r.tabKey);if(a){a.update({params:{tabKey:r.tabKey}}),a.title!==wt(r)&&a.api.setTitle(wt(r));continue}t.addPanel({id:r.tabKey,component:"conversation",title:wt(r),params:{tabKey:r.tabKey},...t.activePanel?{position:{referencePanel:t.activePanel.id,direction:"within"},inactive:!0}:t.panels[0]?{position:{referencePanel:t.panels[0].id,direction:"within"},inactive:!0}:{}})}}function Xa({params:t}){const s=Jt(),n=o.useRef(null),r=s.conversationsByTabKey.get(t.tabKey),a=Xt({sendDaemonCommand:s.sendDaemonCommand,activeConv:r,setLocalUserMessages:s.setLocalUserMessages,setActionLogs:s.setActionLogs,isStandalone:s.isStandalone}),c=o.useMemo(()=>r?s.ides.find(d=>d.id===r.ideId):void 0,[s.ides,r]),i=r?s.screenshotMap[r.ideId]:void 0,h=o.useCallback(()=>{if(!r||!(r.ideId in s.screenshotMap))return;const d={...s.screenshotMap};delete d[r.ideId],s.setScreenshotMap(d)},[r,s]),l=o.useMemo(()=>r?s.actionLogs.filter(d=>d.ideId===r.tabKey):[],[s.actionLogs,r]);if(!r)return e.jsx("div",{className:"h-full min-h-0 min-w-0 flex flex-col",children:e.jsx(Gt,{conversationsCount:0,isSplitMode:!1,isStandalone:s.isStandalone,detectedIdes:s.detectedIdes,handleLaunchIde:s.handleLaunchIde})});const x=je(r)&&!fe(r);return e.jsx("div",{className:"h-full min-h-0 min-w-0 flex flex-col overflow-hidden",children:e.jsx(pn,{activeConv:r,clearToken:s.clearedTabs[r.tabKey]||0,isCli:x,ideEntry:c,screenshotUrl:i,clearScreenshot:h,terminalRef:n,handleModalButton:a.handleModalButton,handleRelaunch:a.handleRelaunch,handleSendChat:a.handleSendChat,isSendingChat:a.isSendingChat,handleFocusAgent:a.handleFocusAgent,isFocusingAgent:a.isFocusingAgent,actionLogs:l,userName:s.userName})})}function Ja(){const t=Jt();return e.jsx("div",{className:"h-full min-h-0 min-w-0 flex flex-col items-center justify-center",children:e.jsx(Gt,{conversationsCount:0,isSplitMode:!1,isStandalone:t.isStandalone,detectedIdes:t.detectedIdes,handleLaunchIde:t.handleLaunchIde})})}function Za(t){var x;qa(t.api);const n=Jt().conversationsByTabKey.get(t.params.tabKey);if(!n)return e.jsx("div",{className:"adhdev-dockview-tab adhdev-dockview-tab-empty",children:e.jsx("div",{className:"adhdev-dockview-tab-copy",children:e.jsx("div",{className:"adhdev-dockview-tab-primary",children:t.api.title||t.params.tabKey})})});const r=((x=t.api.group.activePanel)==null?void 0:x.id)===t.api.id,a=t.api.isGroupActive,c=n.connectionState==="failed"||n.connectionState==="closed",i=n.connectionState==="connecting"||n.connectionState==="new",h=n.status==="generating",l=n.status==="waiting_approval";return e.jsxs("div",{className:`adhdev-dockview-tab${r?" is-active":""}${a?" is-group-active":""}${c?" is-reconnecting":""}`,title:n.displayPrimary,children:[e.jsx("div",{className:"adhdev-dockview-tab-status","aria-hidden":"true",children:h?e.jsx("div",{className:"tab-spinner"}):l?e.jsx("span",{className:"adhdev-dockview-tab-status-text is-waiting",children:"▲"}):c?e.jsx("span",{className:"adhdev-dockview-tab-status-text is-reconnecting",children:"○"}):i?e.jsx("div",{className:"tab-connecting-spinner"}):n.connectionState==="connected"?e.jsx("span",{className:"adhdev-dockview-tab-status-text is-connected",children:"●"}):e.jsx("span",{className:"adhdev-dockview-tab-status-text is-idle",children:"○"})}),e.jsxs("div",{className:"adhdev-dockview-tab-copy",children:[e.jsx("div",{className:"adhdev-dockview-tab-primary",children:n.displayPrimary}),e.jsx("div",{className:"adhdev-dockview-tab-meta",children:c?e.jsx("span",{className:"adhdev-dockview-tab-reconnecting",children:"Reconnecting…"}):i?e.jsx("span",{className:"adhdev-dockview-tab-connecting",children:"Connecting…"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:n.displaySecondary}),n.machineName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"adhdev-dockview-tab-dot",children:"·"}),e.jsxs("span",{className:"adhdev-dockview-tab-machine",children:["🖥 ",n.machineName]})]})]})})]})]})}function Qa({visibleConversations:t,clearedTabs:s,ides:n,actionLogs:r,screenshotMap:a,setScreenshotMap:c,sendDaemonCommand:i,setLocalUserMessages:h,setActionLogs:l,isStandalone:x,userName:d,detectedIdes:f,handleLaunchIde:b,toggleHiddenTab:u,onActiveTabChange:m,requestedActiveTabKey:v,onRequestedActiveTabConsumed:N}){const{sendCommand:g}=$e(),p=o.useRef(null),w=o.useRef(!1),T=o.useMemo(()=>dn(typeof window<"u"?window.innerWidth:1280),[]),y=o.useMemo(()=>new Map(t.map(R=>[R.tabKey,R])),[t]),S=o.useMemo(()=>({actionLogs:r,clearedTabs:s,conversationsByTabKey:y,detectedIdes:f,handleLaunchIde:b,ides:n,isStandalone:x,screenshotMap:a,sendDaemonCommand:i,setActionLogs:l,setLocalUserMessages:h,setScreenshotMap:c,toggleHiddenTab:u,userName:d}),[r,s,y,f,b,n,x,a,i,l,h,c,u,d]),k=o.useCallback(R=>{if(!R)return!1;const D=p.current;if(!D)return!1;const M=D.getPanel(R);return M?(M.group.model.openPanel(M),N==null||N(),!0):!1},[N]),j=o.useCallback(R=>{var M;p.current=R.api;const D=La(T);D!=null&&D.layout&&R.api.fromJSON(D.layout,{reuseExistingPanels:!1}),fs(R.api,t),R.api.totalPanels===0&&t.length>0?Ga(R.api,t,v):k(v)||k(D==null?void 0:D.activeTabId),w.current=!0,R.api.onDidActivePanelChange(E=>{if(m((E==null?void 0:E.id)??null),!E)return;const $=y.get(E.id);($==null?void 0:$.streamSource)==="agent-stream"&&$.agentType&&g($.ideId,"focus_session",{agentType:$.agentType,...$.sessionId&&{targetSessionId:$.sessionId}}).catch(()=>{})}),R.api.onDidLayoutChange(()=>{var E;_a(T,{activeTabId:((E=R.api.activePanel)==null?void 0:E.id)??null,layout:R.api.toJSON()})}),m(((M=R.api.activePanel)==null?void 0:M.id)??null)},[k,y,T,m,v,g,t]);o.useEffect(()=>{const R=p.current;!R||!w.current||(fs(R,t),!R.activePanel&&R.panels[0]&&R.panels[0].group.model.openPanel(R.panels[0]))},[t]),o.useEffect(()=>{w.current&&k(v)},[k,v]);const _=typeof document<"u"&&document.documentElement.dataset.theme==="light"?Tn:En;return e.jsx(mn.Provider,{value:S,children:e.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:e.jsx(An,{className:"h-full min-h-0 min-w-0 adhdev-dockview",components:{conversation:Xa},defaultTabComponent:Za,watermarkComponent:Ja,onReady:j,singleTabMode:"default",tabAnimation:"smooth",theme:_})})})}function _t(t,s){return!!(t<4&&s&&window.innerWidth>=768)}function eo({conversations:t,numGroups:s,onMoveTab:n,onReceiveTab:r,onOwnTabDrop:a,onClearPreviewOrder:c}){const i=o.useRef(0),[h,l]=o.useState(!1),[x,d]=o.useState(null),f=o.useCallback(()=>{i.current=0,l(!1),d(null)},[]);o.useEffect(()=>(window.addEventListener("dragend",f),window.addEventListener("drop",f),()=>{window.removeEventListener("dragend",f),window.removeEventListener("drop",f)}),[f]);const b=o.useCallback(N=>{N.dataTransfer.types.includes("text/tab-key")&&(i.current+=1,l(!0))},[]),u=o.useCallback(N=>{if(!N.dataTransfer.types.includes("text/tab-key"))return;if(N.preventDefault(),!_t(s,n)){d("merge");return}const g=N.currentTarget.getBoundingClientRect(),p=N.clientX-g.left,w=g.width/3;p<w?d("split-left"):p>w*2?d("split-right"):d("merge")},[s,n]),m=o.useCallback(()=>{i.current-=1,!(i.current>0)&&(i.current=0,l(!1),d(null))},[]),v=o.useCallback(N=>{i.current=0,l(!1);const g=N.dataTransfer.getData("text/tab-key"),p=g?t.some(T=>T.tabKey===g):!1,w=x;if(d(null),c(),!!g){if(N.preventDefault(),w==="split-left"&&_t(s,n)){n==null||n(g,"split-left");return}if(w==="split-right"&&_t(s,n)){n==null||n(g,"split-right");return}if(p){a(g);return}r==null||r(g)}},[t,x,s,n,r,a,c]);return{dragOver:h,dropAction:x,resetDragState:f,handleDragEnter:b,handleDragOver:u,handleDragLeave:m,handleDrop:v}}function to(t,s){const n=new Set(s.map(c=>c.tabKey)),r=t.filter(c=>n.has(c)),a=s.filter(c=>!t.includes(c.tabKey)).map(c=>c.tabKey);return[...r,...a]}function so({conversations:t,initialActiveTabId:s,initialTabOrder:n,onActiveTabChange:r,onTabOrderChange:a}){const[c,i]=o.useState(s??null),[h,l]=o.useState(n??[]),[x,d]=o.useState(null),f=o.useRef(null),b=o.useRef(null),u=o.useRef(r),m=o.useRef(a);o.useEffect(()=>{u.current=r},[r]),o.useEffect(()=>{m.current=a},[a]),o.useEffect(()=>{s&&s!==c&&i(s)},[s,c]),o.useEffect(()=>{l(k=>{const j=to(k,t);return j.length===k.length&&j.every((_,R)=>_===k[R])?k:j})},[t]);const v=o.useMemo(()=>{const k=x??h;if(k.length===0)return t;const j=new Map(k.map((_,R)=>[_,R]));return[...t].sort((_,R)=>{const D=j.get(_.tabKey)??999,M=j.get(R.tabKey)??999;return D-M})},[t,x,h]);o.useEffect(()=>{var j,_;if(v.length===0){c!==null&&(i(null),(j=u.current)==null||j.call(u,null));return}if(c&&v.some(R=>R.tabKey===c))return;const k=v[0].tabKey;k!==c&&(i(k),(_=u.current)==null||_.call(u,k))},[v,c]);const N=o.useMemo(()=>v.find(k=>k.tabKey===c),[v,c]),g=o.useCallback(k=>{var j;i(k),(j=u.current)==null||j.call(u,k)},[]),p=o.useCallback((k,j,_)=>{l(R=>{var $;const D=R.filter(O=>O!==k),M=D.indexOf(j);if(M<0)return R;const E=_==="left"?M:M+1;return D.splice(E,0,k),($=m.current)==null||$.call(m,D),D}),d(null)},[]),w=o.useCallback((k,j,_)=>{const D=(h.length>0?h:t.map($=>$.tabKey)).filter($=>$!==k),M=D.indexOf(j);if(M<0)return;const E=_==="left"?M:M+1;D.splice(E,0,k),f.current=D,d(D)},[h,t]),T=o.useCallback(()=>{var j;const k=f.current;k&&(l(k),(j=m.current)==null||j.call(m,k))},[]),y=o.useCallback(()=>{f.current=null,d(null)},[]),S=o.useCallback(k=>{l(j=>{var R;const _=j.filter(D=>D!==k);return _.push(k),(R=m.current)==null||R.call(m,_),_})},[]);return{activeTabId:c,activeConv:N,sortedConversations:v,previewOrderRef:f,draggingTabRef:b,selectTab:g,handleTabReorder:p,updatePreviewOrder:w,commitPreviewOrder:T,clearPreviewOrder:y,moveTabToEnd:S,setDraggingTabKey:k=>{b.current=k}}}function no({dropAction:t,canSplit:s}){return e.jsxs("div",{className:"absolute inset-0 z-10 pointer-events-none hidden md:flex",children:[e.jsx("div",{className:"flex-1 border-r border-white/10 transition-all duration-150 flex items-center justify-center",style:{background:t==="split-left"?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.04)",boxShadow:t==="split-left"?"inset 0 0 0 2px var(--accent-primary)":"inset 0 0 0 1px rgba(255,255,255,0.05)",opacity:s?1:.45},children:e.jsx("div",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold text-white bg-black/45 backdrop-blur-sm",children:"Split Left"})}),e.jsx("div",{className:"flex-1 border-r border-white/10 transition-all duration-150 flex items-center justify-center",style:{background:t==="merge"?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.04)",boxShadow:t==="merge"?"inset 0 0 0 2px var(--accent-primary)":"inset 0 0 0 1px rgba(255,255,255,0.05)"},children:e.jsx("div",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold text-white bg-black/45 backdrop-blur-sm",children:"Move Here"})}),e.jsx("div",{className:"flex-1 transition-all duration-150 flex items-center justify-center",style:{background:t==="split-right"?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.04)",boxShadow:t==="split-right"?"inset 0 0 0 2px var(--accent-primary)":"inset 0 0 0 1px rgba(255,255,255,0.05)",opacity:s?1:.45},children:e.jsx("div",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold text-white bg-black/45 backdrop-blur-sm",children:"Split Right"})})]})}const fn="adhdev-tab-shortcuts";function ro(){try{return JSON.parse(localStorage.getItem(fn)||"{}")}catch{return{}}}function ao({sortedTabKeys:t,onFocus:s,onSelectTab:n}){const r=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent),[a,c]=o.useState(()=>ro()),[i,h]=o.useState(null),l=o.useCallback(d=>{const f=[];return d.metaKey&&f.push(r?"⌘":"Meta"),d.ctrlKey&&f.push("Ctrl"),d.altKey&&f.push(r?"⌥":"Alt"),d.shiftKey&&f.push(r?"⇧":"Shift"),["Control","Alt","Shift","Meta"].includes(d.key)?null:(f.push(d.key.length===1?d.key.toUpperCase():d.key),f.join("+"))},[r]),x=o.useCallback(d=>{c(d);try{localStorage.setItem(fn,JSON.stringify(d))}catch{}},[]);return o.useEffect(()=>{if(!i)return;const d=f=>{if(f.preventDefault(),f.stopPropagation(),f.key==="Escape"){h(null);return}const b=l(f);if(!b)return;const u={...a};for(const[m,v]of Object.entries(u))v===b&&delete u[m];u[i]=b,x(u),h(null)};return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[i,a,x,l]),o.useEffect(()=>{const d=f=>{if(!(!f.ctrlKey&&!f.metaKey&&!f.altKey)){for(const[b,u]of Object.entries(a))if(t.includes(b)&&l(f)===u){f.preventDefault(),s(),n(b);return}}};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a,t,s,n,l]),{isMac:r,tabShortcuts:a,shortcutListening:i,setShortcutListening:h,saveShortcuts:x}}const oo=o.memo(function({conv:s,isActive:n,isDraggedTab:r,shortcut:a,conversationKeys:c,draggingTabRef:i,onFocus:h,onSelectTab:l,onConversationActivated:x,onPreviewReorder:d,onReorderTab:f,onCommitPreviewOrder:b,onClearPreviewOrder:u,onDragStateReset:m,onDragTabKeyChange:v,onReceiveTab:N,onOpenContextMenu:g,longPressTimer:p}){const w=s.status==="generating"?"agent-tab-generating":s.status==="waiting_approval"?"agent-tab-waiting":"",T=s.connectionState==="failed"||s.connectionState==="closed",y=o.useCallback(E=>{i.current=s.tabKey,v(s.tabKey),E.dataTransfer.setData("text/tab-key",s.tabKey),E.dataTransfer.effectAllowed="move"},[s.tabKey,i,v]),S=o.useCallback(()=>{i.current=null,v(null),b(),u(),m()},[i,v,b,u,m]),k=o.useCallback(E=>{const $=i.current;if(!(!$||$===s.tabKey)&&E.dataTransfer.types.includes("text/tab-key")){E.preventDefault(),E.stopPropagation();const O=E.currentTarget.getBoundingClientRect(),C=E.clientX<O.left+O.width/2?"left":"right";d($,s.tabKey,C)}},[s.tabKey,i,d]),j=o.useCallback(E=>{E.preventDefault(),E.stopPropagation();const $=E.dataTransfer.getData("text/tab-key");if($&&$!==s.tabKey){const O=E.currentTarget.getBoundingClientRect(),C=E.clientX<O.left+O.width/2?"left":"right";c.includes($)?f($,s.tabKey,C):N&&N($)}u()},[s.tabKey,c,f,N,u]),_=o.useCallback(E=>{E.stopPropagation(),h(),l(s.tabKey),x(s)},[s,x,h,l]),R=o.useCallback(E=>{E.preventDefault(),g(E.clientX,E.clientY,s.tabKey)},[s.tabKey,g]),D=o.useCallback(E=>{const $=E.touches[0];p.current=setTimeout(()=>{g($.clientX,$.clientY,s.tabKey)},600)},[s.tabKey,p,g]),M=o.useCallback(()=>{p.current&&clearTimeout(p.current)},[p]);return e.jsxs("div",{"data-tabkey":s.tabKey,className:`${w} shrink-0 px-2.5 py-1.5 rounded-t-lg cursor-pointer flex items-center gap-2 relative`,draggable:!0,onDragStart:y,onDragEnd:S,onDragOver:k,onDrop:j,onClick:_,onContextMenu:R,onTouchStart:D,onTouchEnd:M,onTouchMove:M,style:{background:n?"var(--bg-primary)":"var(--bg-glass)",borderTop:n?"1px solid var(--border-subtle)":"1px solid transparent",borderLeft:n?"1px solid var(--border-subtle)":"1px solid transparent",borderRight:n?"1px solid var(--border-subtle)":"1px solid transparent",opacity:r?.4:T?n?.6:.3:n?1:.65,transition:"transform 0.2s ease, opacity 0.15s ease"},children:[s.status==="generating"?e.jsx("div",{className:"tab-spinner"}):s.status==="waiting_approval"?e.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400",children:"▲"}):T?e.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400 animate-pulse",children:"○"}):s.connectionState==="connecting"||s.connectionState==="new"?e.jsx("div",{className:"tab-connecting-spinner"}):s.connectionState==="connected"?e.jsx("span",{className:"text-[8px] px-[5px] py-px text-green-400",children:"●"}):e.jsx("span",{className:"text-[8px] px-[5px] py-px text-text-muted animate-pulse",children:"○"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-bold whitespace-nowrap overflow-hidden text-ellipsis",style:{maxWidth:"10ch"},title:s.displayPrimary,children:s.displayPrimary}),e.jsx("div",{className:"text-[8px] opacity-50 flex gap-1 items-center",children:T?e.jsx("span",{className:"text-yellow-400 opacity-100",children:"Reconnecting…"}):s.connectionState==="connecting"||s.connectionState==="new"?e.jsxs("span",{className:"text-blue-400 opacity-100",children:["Connecting",e.jsx("span",{className:"connecting-dots"})]}):e.jsxs(e.Fragment,{children:[s.displaySecondary,s.machineName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-40",children:"·"}),e.jsxs("span",{className:"opacity-70",children:["🖥 ",s.machineName]})]})]})})]}),a&&e.jsx("span",{className:"text-[9px] opacity-50 font-mono ml-0.5 shrink-0 bg-bg-secondary px-1 rounded",title:`Ctrl+${a}`,children:a})]})},(t,s)=>t.conv===s.conv&&t.isActive===s.isActive&&t.isDraggedTab===s.isDraggedTab&&t.shortcut===s.shortcut&&t.conversationKeys===s.conversationKeys);function io({conversations:t,activeTabId:s,groupIndex:n,numGroups:r,draggingTabRef:a,onFocus:c,onSelectTab:i,onConversationActivated:h,onPreviewReorder:l,onReorderTab:x,onCommitPreviewOrder:d,onClearPreviewOrder:f,onDragStateReset:b,onDragTabKeyChange:u,onMoveTab:m,onReceiveTab:v,onHideTab:N}){const[g,p]=o.useState(null),w=o.useRef(null),T=o.useRef(null),y=o.useMemo(()=>t.map(M=>M.tabKey),[t]);lt("PaneGroupTabBar",{groupIndex:n,activeTabId:s,tabCount:t.length,ctxMenuTab:(g==null?void 0:g.tabKey)||null});const{isMac:S,tabShortcuts:k,shortcutListening:j,setShortcutListening:_,saveShortcuts:R}=ao({sortedTabKeys:t.map(M=>M.tabKey),onFocus:c,onSelectTab:i});o.useEffect(()=>{if(!g)return;const M=E=>{const $=document.querySelector("[data-pane-context-menu]");$&&$.contains(E.target)||p(null)};return window.addEventListener("mousedown",M,!0),()=>window.removeEventListener("mousedown",M,!0)},[g]),o.useEffect(()=>{const M=T.current;if(!M)return;const E=$=>{Math.abs($.deltaY)>Math.abs($.deltaX)&&($.preventDefault(),M.scrollLeft+=$.deltaY)};return M.addEventListener("wheel",E,{passive:!1}),()=>M.removeEventListener("wheel",E)},[]);const D=o.useCallback((M,E,$)=>{p({x:M,y:E,tabKey:$})},[]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center bg-bg-secondary border-b border-border-subtle shrink-0 gap-0",children:e.jsxs("div",{ref:T,className:"flex-1 flex overflow-x-auto overflow-y-visible pt-1.5 pb-0 gap-1 select-none",style:{paddingLeft:8,paddingRight:4,scrollbarWidth:"none"},children:[t.map(M=>e.jsx(oo,{conv:M,isActive:s===M.tabKey,isDraggedTab:a.current===M.tabKey,shortcut:k[M.tabKey],conversationKeys:y,draggingTabRef:a,onFocus:c,onSelectTab:i,onConversationActivated:h,onPreviewReorder:l,onReorderTab:x,onCommitPreviewOrder:d,onClearPreviewOrder:f,onDragStateReset:b,onDragTabKeyChange:u,onReceiveTab:v,onOpenContextMenu:D,longPressTimer:w},M.tabKey)),t.length===0&&e.jsx("div",{className:"p-2 text-xs opacity-40",children:"No tabs in this group"})]})}),g&&e.jsxs("div",{"data-pane-context-menu":!0,className:"fixed z-50 bg-bg-primary border border-border-subtle rounded-lg shadow-lg py-1 min-w-[160px]",style:{left:g.x,top:g.y},children:[m&&n>0&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{m(g.tabKey,"left"),p(null)},children:"← Move to Left Group"}),m&&n<r-1&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{m(g.tabKey,"right"),p(null)},children:"Move to Right Group →"}),m&&r<4&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{m(g.tabKey,"split-left"),p(null)},children:"⇤ Split Left"}),m&&r<4&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{m(g.tabKey,"split-right"),p(null)},children:"Split Right ⇥"}),e.jsx("div",{className:"border-t border-border-subtle my-1 "}),e.jsxs("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:M=>{M.stopPropagation(),_(g.tabKey),p(null)},children:["⌨ ",k[g.tabKey]?`Change shortcut (${k[g.tabKey]})`:"Set shortcut"]}),k[g.tabKey]&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted ",onClick:()=>{const M={...k};delete M[g.tabKey],R(M),p(null)},children:"✕ Remove shortcut"}),N&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-border-subtle my-1"}),e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted",onClick:()=>{N(g.tabKey),p(null)},children:"🚫 Hide from Dashboard"})]}),!m&&!N&&e.jsx("div",{className:"px-3 py-1.5 text-[11px] text-text-muted opacity-50 italic",children:"No actions available"})]}),j&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(2px)"},onClick:()=>_(null),children:e.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl px-8 py-6 text-center shadow-xl",onClick:M=>M.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-bold text-text-primary mb-2",children:"⌨ Set shortcut"}),e.jsxs("div",{className:"text-xs text-text-secondary mb-4",children:["Press a key combo (e.g. ",S?"⌘+1":"Ctrl+1",", ",S?"⌥+A":"Alt+A",")"]}),e.jsx("div",{className:"text-lg font-mono text-accent animate-pulse",children:"Listening..."}),e.jsx("div",{className:"text-[10px] text-text-muted mt-3",children:"Press Esc to cancel"})]})})]})}function co({conversations:t,ides:s,clearedTabs:n,actionLogs:r,screenshotMap:a,setScreenshotMap:c,sendDaemonCommand:i,setLocalUserMessages:h,setActionLogs:l,isStandalone:x,userName:d,groupIndex:f,onFocus:b,isSplitMode:u,numGroups:m,onMoveTab:v,onReceiveTab:N,style:g,detectedIdes:p,handleLaunchIde:w,onActiveTabChange:T,initialActiveTabId:y,initialTabOrder:S,onTabOrderChange:k,onHideTab:j}){const{sendCommand:_}=$e(),R=o.useRef(null),{activeTabId:D,activeConv:M,sortedConversations:E,draggingTabRef:$,selectTab:O,handleTabReorder:C,updatePreviewOrder:V,commitPreviewOrder:Z,clearPreviewOrder:J,moveTabToEnd:G,setDraggingTabKey:Q}=so({conversations:t,initialActiveTabId:y,initialTabOrder:S,onActiveTabChange:T,onTabOrderChange:k}),Y=Xt({sendDaemonCommand:i,activeConv:M,setLocalUserMessages:h,setActionLogs:l,isStandalone:x}),{dragOver:se,dropAction:ee,resetDragState:ce,handleDragEnter:B,handleDragOver:P,handleDragLeave:A,handleDrop:L}=eo({conversations:t,numGroups:m,onMoveTab:v,onReceiveTab:N,onOwnTabDrop:G,onClearPreviewOrder:J}),W=M&&je(M)&&!fe(M),U=o.useMemo(()=>M?s.find(re=>re.id===M.ideId):void 0,[s,M]),H=M?a[M.ideId]:void 0,ae=o.useCallback(()=>{if(!M||!(M.ideId in a))return;const re={...a};delete re[M.ideId],c(re)},[M,a,c]),de=o.useMemo(()=>M?r.filter(re=>re.ideId===M.tabKey):[],[r,M]);lt("PaneGroup",{groupIndex:f,conversationCount:t.length,activeTabId:D,dragOver:se});const oe=o.useCallback(re=>{re.streamSource==="agent-stream"&&re.agentType&&_(re.ideId,"focus_session",{agentType:re.agentType,...re.sessionId&&{targetSessionId:re.sessionId}}).catch(()=>{})},[_]);return e.jsxs("div",{className:"flex flex-col min-h-0 min-w-0 flex-1 overflow-hidden",onClick:b,style:{...g,outline:se?"2px dashed var(--accent-primary)":"none",outlineOffset:"-2px",transition:"outline 0.15s ease"},children:[e.jsx(io,{conversations:E,activeTabId:D,groupIndex:f,numGroups:m,draggingTabRef:$,onFocus:b,onSelectTab:O,onConversationActivated:oe,onPreviewReorder:V,onReorderTab:C,onCommitPreviewOrder:Z,onClearPreviewOrder:J,onDragStateReset:ce,onDragTabKeyChange:Q,onMoveTab:v,onReceiveTab:N,onHideTab:j}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden relative",onDragEnter:B,onDragOver:P,onDragLeave:A,onDrop:L,children:[se&&e.jsx(no,{dropAction:ee,canSplit:!!(m<4&&v)}),M?e.jsx(pn,{activeConv:M,clearToken:n[M.tabKey]||0,isCli:!!W,ideEntry:U,screenshotUrl:H,clearScreenshot:ae,terminalRef:R,handleModalButton:Y.handleModalButton,handleRelaunch:Y.handleRelaunch,handleSendChat:Y.handleSendChat,isSendingChat:Y.isSendingChat,handleFocusAgent:Y.handleFocusAgent,isFocusingAgent:Y.isFocusingAgent,actionLogs:de,userName:d}):e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:e.jsx(Gt,{conversationsCount:t.length,isSplitMode:u,isStandalone:x,detectedIdes:p,handleLaunchIde:w})})]})]})}function lo({containerRef:t,isSplitMode:s,numGroups:n,groupSizes:r,groupedConvs:a,clearedTabs:c,ides:i,actionLogs:h,screenshotMap:l,setScreenshotMap:x,sendDaemonCommand:d,setLocalUserMessages:f,setActionLogs:b,isStandalone:u,userName:m,setFocusedGroup:v,moveTabToGroup:N,splitTabRelative:g,closeGroup:p,handleResizeStart:w,detectedIdes:T,handleLaunchIde:y,groupActiveTabIds:S,setGroupActiveTabIds:k,groupTabOrders:j,setGroupTabOrders:_,toggleHiddenTab:R}){return e.jsx("div",{ref:t,className:`flex-1 min-h-0 flex ${s?"flex-row":"flex-col"} overflow-hidden`,children:a.map((D,M)=>{const E=s&&r.length===n?`${r[M]}%`:void 0;return e.jsxs(Rn.Fragment,{children:[s&&M>0&&e.jsx("div",{className:"shrink-0 w-1 cursor-col-resize hover:bg-accent/30 transition-colors relative group",style:{background:"var(--border-subtle)"},onMouseDown:$=>w(M-1,$),onDoubleClick:()=>p(M),title:"Drag to resize · Double-click to merge",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 group-hover:bg-accent/10"})}),e.jsx(co,{style:s?{flexBasis:E??`${100/n}%`,flexGrow:E?0:1,flexShrink:E?0:1}:void 0,conversations:D,clearedTabs:c,ides:i,actionLogs:h,screenshotMap:l,setScreenshotMap:x,sendDaemonCommand:d,setLocalUserMessages:f,setActionLogs:b,isStandalone:u,userName:m,groupIndex:M,onFocus:()=>v(M),isSplitMode:s,numGroups:n,onMoveTab:($,O)=>{O==="left"&&M>0?N($,M-1):O==="right"&&M<n-1?N($,M+1):O==="split-left"&&n<4?g($,M,"left"):O==="split-right"&&n<4&&g($,M,"right")},onReceiveTab:$=>N($,M),detectedIdes:M===0?T:void 0,handleLaunchIde:M===0?y:void 0,onActiveTabChange:$=>k(O=>(O[M]??null)===($??null)?O:{...O,[M]:$}),initialActiveTabId:S[M],initialTabOrder:j[M],onTabOrderChange:$=>_(O=>{const C=O[M]||[];return C.length===$.length&&C.every((V,Z)=>V===$[Z])?O:{...O,[M]:$}}),onHideTab:R})]},M)})})}function uo({daemons:t,targetVersion:s,upgradingDaemons:n,onUpgrade:r,onDismiss:a}){return t.length===0?null:e.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2 border-b text-xs text-text-secondary shrink-0 flex-wrap",style:{background:"color-mix(in srgb, var(--status-warning) 8%, transparent)",borderColor:"color-mix(in srgb, var(--status-warning) 20%, transparent)"},children:[e.jsx("span",{className:"text-sm shrink-0 mt-0.5",style:{color:"var(--status-warning)"},children:e.jsx(_s,{size:14})}),e.jsxs("span",{className:"flex-1 flex items-center gap-2 flex-wrap min-w-0",children:[e.jsxs("span",{children:["Update available",s?e.jsxs(e.Fragment,{children:[": ",e.jsxs("strong",{children:["v",s]})]}):null]}),t.map(c=>{const i=Xe(c,{fallbackId:c.id}),h=n[c.id],l=c.version||c.daemonVersion||"unknown";return e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md",style:{background:"color-mix(in srgb, var(--status-warning) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--status-warning) 15%, transparent)"},children:[e.jsx("span",{className:"font-medium text-text-primary",children:i}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",l]}),h==="upgrading"?e.jsx("span",{className:"text-[10px] animate-pulse",style:{color:"var(--status-warning)"},children:"upgrading…"}):h==="done"?e.jsx("span",{className:"text-[10px] text-green-400",children:"✓ restarting"}):h==="error"?e.jsx("button",{className:"text-[10px] text-red-400 hover:text-red-300 underline cursor-pointer",onClick:()=>r(c.id),children:"retry"}):e.jsx("button",{className:"text-[10px] font-semibold cursor-pointer px-1.5 py-px rounded transition-colors",style:{color:"var(--status-warning)",background:"color-mix(in srgb, var(--status-warning) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--status-warning) 20%, transparent)"},onClick:()=>r(c.id),children:"Upgrade"})]},c.id)})]}),e.jsx("button",{className:"text-text-muted hover:text-text-primary transition-colors text-sm px-1 shrink-0",onClick:a,title:"Dismiss",children:"✕"})]})}function ho({activeConv:t,onCancel:s,onStopNow:n,onSaveAndStop:r}){const a=t.agentName||t.ideType||"CLI";return e.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center",children:[e.jsx("div",{onClick:s,className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),e.jsxs("div",{role:"dialog","aria-modal":"true",className:"card fade-in relative w-[92%] max-w-[420px] flex flex-col overflow-hidden rounded-[18px] shadow-[0_20px_40px_rgba(0,0,0,0.4)]",children:[e.jsxs("div",{className:"px-6 py-5 border-b border-border-subtle bg-[var(--surface-primary)]",children:[e.jsxs("h3",{className:"m-0 text-lg font-extrabold",children:["Stop ",a,"?"]}),e.jsx("div",{className:"mt-1 text-sm text-text-muted",children:"The CLI runtime will stop. Choose whether to stop immediately or ask the provider to save and exit first."})]}),e.jsxs("div",{className:"px-6 py-5 bg-bg-primary flex flex-col gap-3",children:[e.jsx("button",{onClick:r,className:"btn btn-primary w-full justify-center",children:"Save and stop"}),e.jsx("button",{onClick:n,className:"btn btn-secondary w-full justify-center text-red-400 border-red-500/25 hover:bg-red-500/10",children:"Stop now"}),e.jsx("button",{onClick:s,className:"btn btn-secondary w-full justify-center",children:"Cancel"})]})]})]})}const $t=[{icon:"🦦",title:"Welcome to ADHDev",desc:"Monitor and control your AI coding agents from anywhere — web, mobile, or CLI.",visual:"🎉"},{icon:"💬",title:"Real-time chat",desc:"See what your AI agent is doing in real-time. Send messages, approve or reject actions — all from your browser or phone.",visual:"📱"},{icon:"🖥️",title:"Remote desktop",desc:"View and control your IDE screen via P2P connection. Click, type, scroll — just like being there.",visual:"🖱️"},{icon:"🚀",title:"Get started",desc:"Install the daemon and link it to your dashboard. It connects automatically.",code:"npm install -g @adhdev/daemon-standalone && adhdev-standalone"}];function xo({onClose:t}){const[s,n]=o.useState(0),r=$t[s],a=s===$t.length-1;return e.jsxs("div",{className:"onboarding-overlay",style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.65)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.3s ease-out"},onClick:c=>{c.target===c.currentTarget&&t()},children:[e.jsxs("div",{style:{background:"var(--bg-secondary, #1a1a2e)",border:"1px solid var(--border-subtle, #333)",borderRadius:"1.25rem",width:"min(440px, 92vw)",padding:"2.5rem 2rem 2rem",position:"relative",animation:"slideUp 0.3s ease-out"},children:[e.jsx("button",{onClick:t,style:{position:"absolute",top:12,right:16,background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"1.2rem",cursor:"pointer"},children:"✕"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:6,marginBottom:"1.5rem"},children:$t.map((c,i)=>e.jsx("div",{style:{width:i===s?24:8,height:8,borderRadius:4,background:i===s?"var(--accent, #7c3aed)":"var(--border-subtle, #444)",transition:"all 0.3s ease"}},i))}),e.jsx("div",{style:{textAlign:"center",fontSize:"3rem",marginBottom:"1rem"},children:r.visual||r.icon}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsxs("h2",{style:{fontSize:"1.35rem",fontWeight:700,color:"var(--text-primary)",marginBottom:"0.75rem",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[e.jsx("span",{children:r.icon})," ",r.title]}),e.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"1.25rem"},children:r.desc}),r.code&&e.jsxs("div",{style:{background:"var(--bg-primary, #111)",border:"1px solid var(--border-subtle, #333)",borderRadius:"0.5rem",padding:"0.75rem 1rem",fontFamily:"monospace",fontSize:"0.8rem",color:"var(--accent, #a78bfa)",textAlign:"left",overflowX:"auto",marginBottom:"0.5rem"},children:[e.jsx("span",{style:{color:"var(--text-muted)",marginRight:8},children:"$"}),r.code]}),a&&e.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.75rem",color:"var(--accent, #a78bfa)",textDecoration:"none"},children:"📚 Learn more in the docs →"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"1.5rem"},children:[e.jsx("button",{onClick:t,style:{background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"0.85rem",cursor:"pointer"},children:"Skip"}),e.jsx("button",{onClick:()=>a?t():n(c=>c+1),className:"transition-opacity hover:opacity-90",style:{background:"linear-gradient(135deg, #7c3aed, #6366f1)",color:"#fff",border:"none",borderRadius:"0.5rem",padding:"0.55rem 1.5rem",fontSize:"0.9rem",fontWeight:600,cursor:"pointer"},children:a?"Get Started →":"Next →"})]})]}),e.jsx("style",{children:`
|
|
53
|
+
Use this if you want to permanently remove a machine.`,confirmLabel:"Remove Machine",confirmColor:"red",onConfirm:R,onCancel:()=>d(null)})]})}const xa=[{id:"dark",label:"Dark",icon:"🌙"},{id:"light",label:"Light",icon:"☀️"},{id:"system",label:"System",icon:"💻"}];function pa(){const{preference:t,setPreference:s}=ca();return e.jsx("div",{className:"flex gap-2",children:xa.map(n=>e.jsxs("button",{onClick:()=>s(n.id),className:`px-3 py-1.5 rounded-lg border text-sm font-medium transition-colors flex items-center gap-1.5 ${t===n.id?"bg-accent border-accent text-white":"bg-bg-glass border-border-subtle hover:bg-bg-secondary text-text-muted hover:text-text-primary"}`,children:[e.jsx("span",{children:n.icon}),n.label]},n.id))})}const zt={bgPrimary:"#0a0e1a",bgSecondary:"#0f1320",surfacePrimary:"#111726",textPrimary:"#f0f0f5",textSecondary:"#9ca3af",textMuted:"#6b7280",borderSubtle:"#1d2536",borderDefault:"#313c52",accentColor:"#d97706",userBubble:"#f59e0b",userText:"#1a1a1a",assistantBubble:"#111726",assistantText:"#f0f0f5",containerBg:"#0f1320",sendButton:"#d97706",inputBorder:"#313c52",bubbleRadius:16},Ft={bgPrimary:"#fff8ee",bgSecondary:"#fff1de",surfacePrimary:"#ffffff",textPrimary:"#24160f",textSecondary:"#6f6255",textMuted:"#938374",borderSubtle:"#e7d3ba",borderDefault:"#d7b892",accentColor:"#d97706",userBubble:"#f59e0b",userText:"#1a1a1a",assistantBubble:"#fffaf4",assistantText:"#24160f",containerBg:"#fff8ee",sendButton:"#d97706",inputBorder:"#d7b892",bubbleRadius:16},ma=[{id:"midnight",name:"Midnight",description:"Classic violet theme",preview:{dark:{userBubble:"#8b5cf6",assistantBubble:"#18181d",assistantBorder:"1px solid rgba(255,255,255,0.08)",containerBg:"#0f0f13",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"#7c3aed",assistantBubble:"#ffffff",assistantBorder:"1px solid rgba(0,0,0,0.08)",containerBg:"#f0f1f5",textColor:"#52525b"}}},{id:"ember",name:"Ember",description:"Default landing-inspired amber theme",preview:{dark:{userBubble:"#f59e0b",assistantBubble:"#111726",assistantBorder:"1px solid rgba(255,255,255,0.08)",containerBg:"#0a0e1a",textColor:"#9ca3af"},light:{userBubble:"#f59e0b",assistantBubble:"#fffaf4",assistantBorder:"1px solid rgba(146,64,14,0.10)",containerBg:"#fff8ee",textColor:"#6f6255"}}},{id:"aurora",name:"Aurora",description:"Pink accent theme",preview:{dark:{userBubble:"#ec4899",assistantBubble:"#1e1b2e",assistantBorder:"1px solid rgba(236,72,153,0.12)",containerBg:"#0f0d17",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"#ec4899",assistantBubble:"#fef2f8",assistantBorder:"1px solid rgba(236,72,153,0.15)",containerBg:"#f0f1f5",textColor:"#1a1a2e"}}},{id:"honey",name:"Honey",description:"Warm yellow accents",preview:{dark:{userBubble:"#fbbf24",assistantBubble:"#1c1c1e",assistantBorder:"1px solid rgba(255,255,255,0.06)",containerBg:"#111113",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"#fbbf24",assistantBubble:"#fffbeb",assistantBorder:"1px solid rgba(251,191,36,0.15)",containerBg:"#f0f1f5",textColor:"#1a1a2e"}}}],nn="adhdev-chat-theme",rn="adhdev-chat-theme-custom";function vt(){return typeof window>"u"?"ember":localStorage.getItem(nn)||"ember"}function Ie(t){try{const s=localStorage.getItem(rn);if(s){const n=JSON.parse(s);return{...t==="dark"?zt:Ft,...n[t]}}}catch{}return t==="dark"?zt:Ft}function pt(t,s){localStorage.setItem(rn,JSON.stringify({dark:t,light:s}))}function Se(t,s){const n=parseInt(t.slice(1,3),16),r=parseInt(t.slice(3,5),16),a=parseInt(t.slice(5,7),16);return`rgba(${n}, ${r}, ${a}, ${s})`}function Ct(t,s){const n=Math.min(255,parseInt(t.slice(1,3),16)+s),r=Math.min(255,parseInt(t.slice(3,5),16)+s),a=Math.min(255,parseInt(t.slice(5,7),16)+s);return`#${n.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}const fa={midnight:{dark:"#8b5cf6",light:"#7c3aed"},ember:{dark:"#d97706",light:"#d97706"},aurora:{dark:"#ec4899",light:"#ec4899"},honey:{dark:"#fbbf24",light:"#fbbf24"}};function at(t,s){var a;const n=(a=fa[t])==null?void 0:a[s];if(!n)return;const r=document.documentElement;r.style.setProperty("--accent-primary",n),r.style.setProperty("--accent-primary-light",Ct(n,24)),r.style.setProperty("--accent-gradient",`linear-gradient(135deg, ${n}, ${Ct(n,18)})`),r.style.setProperty("--border-accent",Se(n,.35)),r.style.setProperty("--nav-active-bg",Se(n,.1)),r.style.setProperty("--nav-active-shadow",`inset 3px 0 0 ${n}, 0 0 12px ${Se(n,.06)}`)}function Ke(t){const s=document.documentElement;s.style.setProperty("--bg-primary",t.bgPrimary),s.style.setProperty("--bg-secondary",t.bgSecondary),s.style.setProperty("--bg-card",Se(t.surfacePrimary,.92)),s.style.setProperty("--surface-primary",t.surfacePrimary),s.style.setProperty("--surface-secondary",t.bgSecondary),s.style.setProperty("--bg-glass",Se(t.borderSubtle,.15)),s.style.setProperty("--bg-glass-hover",Se(t.borderSubtle,.25)),s.style.setProperty("--text-primary",t.textPrimary),s.style.setProperty("--text-secondary",t.textSecondary),s.style.setProperty("--text-muted",t.textMuted),s.style.setProperty("--border-subtle",Se(t.borderSubtle,.5)),s.style.setProperty("--border-default",Se(t.borderDefault,.5)),s.style.setProperty("--accent-primary",t.accentColor),s.style.setProperty("--accent-primary-light",Ct(t.accentColor,30)),s.style.setProperty("--accent-gradient",`linear-gradient(135deg, ${t.accentColor}, ${Ct(t.accentColor,40)})`),s.style.setProperty("--border-accent",Se(t.accentColor,.35)),s.style.setProperty("--nav-active-bg",Se(t.accentColor,.1)),s.style.setProperty("--nav-active-shadow",`inset 3px 0 0 ${t.accentColor}, 0 0 12px ${Se(t.accentColor,.06)}`),s.style.setProperty("--chat-user-bg",t.userBubble),s.style.setProperty("--chat-user-color",t.userText),s.style.setProperty("--chat-user-radius",`${t.bubbleRadius}px ${t.bubbleRadius}px 4px ${t.bubbleRadius}px`),s.style.setProperty("--chat-assistant-bg",t.assistantBubble),s.style.setProperty("--chat-assistant-color",t.assistantText),s.style.setProperty("--chat-assistant-radius",`${t.bubbleRadius}px ${t.bubbleRadius}px ${t.bubbleRadius}px 4px`),s.style.setProperty("--chat-assistant-border",`1px solid ${Se(t.accentColor,.12)}`),s.style.setProperty("--chat-container-bg",t.containerBg),s.style.setProperty("--chat-thought-accent",t.accentColor),s.style.setProperty("--chat-tool-accent",t.accentColor),s.style.setProperty("--chat-action-color",t.accentColor),s.style.setProperty("--chat-send-bg",t.sendButton),s.style.setProperty("--chat-input-border",t.inputBorder)}function Yt(){const t=document.documentElement;["--bg-primary","--bg-secondary","--bg-card","--surface-primary","--surface-secondary","--bg-glass","--bg-glass-hover","--text-primary","--text-secondary","--text-muted","--border-subtle","--border-default","--accent-primary","--accent-primary-light","--accent-gradient","--border-accent","--nav-active-bg","--nav-active-shadow","--chat-user-bg","--chat-user-color","--chat-user-radius","--chat-assistant-bg","--chat-assistant-color","--chat-assistant-radius","--chat-assistant-border","--chat-container-bg","--chat-thought-accent","--chat-tool-accent","--chat-action-color","--chat-send-bg","--chat-input-border"].forEach(n=>t.style.removeProperty(n))}function ga(t){if(localStorage.setItem(nn,t),document.documentElement.setAttribute("data-chat-theme",t),t==="custom"){const s=ze()?"dark":"light";Ke(Ie(s))}else Yt(),at(t,ze()?"dark":"light")}function ba(){const t=vt();if(document.documentElement.setAttribute("data-chat-theme",t),t==="custom"){const s=ze()?"dark":"light";Ke(Ie(s))}else Yt(),at(t,ze()?"dark":"light")}function ze(){const t=document.documentElement.getAttribute("data-theme");return t?t==="dark":window.matchMedia("(prefers-color-scheme: dark)").matches}function ge({label:t,value:s,onChange:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:110},children:t}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("input",{type:"color",value:s,onChange:r=>n(r.target.value),style:{width:28,height:28,border:"none",borderRadius:6,cursor:"pointer",background:"transparent",padding:0}}),e.jsx("input",{type:"text",value:s,onChange:r=>{/^#[0-9a-fA-F]{0,6}$/.test(r.target.value)&&n(r.target.value)},style:{width:72,fontSize:"0.7rem",fontFamily:"monospace",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"3px 6px",color:"var(--text-primary)"}})]})]})}function et({title:t,children:s}){return e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("div",{style:{fontSize:"0.65rem",fontWeight:700,textTransform:"uppercase",color:"var(--text-muted)",letterSpacing:"0.08em",marginBottom:8,borderBottom:"1px solid var(--border-subtle)",paddingBottom:4},children:t}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s})]})}function ya({dark:t,onColorsChange:s}){const n=t?"dark":"light",[r,a]=o.useState(()=>Ie(n));o.useEffect(()=>{a(Ie(n))},[n]);const c=o.useCallback((i,h)=>{a(l=>{const x={...l,[i]:h},f=Ie(n==="dark"?"light":"dark");return n==="dark"?pt(x,f):pt(f,x),Ke(x),s(x),x})},[n,s]);return e.jsxs("div",{style:{marginTop:12,padding:"16px 18px",background:"var(--bg-glass)",border:"1px solid var(--border-subtle)",borderRadius:12},children:[e.jsxs("div",{style:{fontSize:"0.75rem",fontWeight:700,color:"var(--text-primary)",marginBottom:14,display:"flex",alignItems:"center",gap:8},children:["🎨 Custom Theme Editor",e.jsxs("span",{style:{fontSize:"0.65rem",fontWeight:500,color:"var(--text-muted)",background:"var(--bg-glass)",padding:"2px 8px",borderRadius:4},children:[t?"🌙 Dark":"☀️ Light"," mode"]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsxs(et,{title:"App Background",children:[e.jsx(ge,{label:"Background",value:r.bgPrimary,onChange:i=>c("bgPrimary",i)}),e.jsx(ge,{label:"Surface",value:r.bgSecondary,onChange:i=>c("bgSecondary",i)}),e.jsx(ge,{label:"Card",value:r.surfacePrimary,onChange:i=>c("surfacePrimary",i)})]}),e.jsxs(et,{title:"App Text",children:[e.jsx(ge,{label:"Primary",value:r.textPrimary,onChange:i=>c("textPrimary",i)}),e.jsx(ge,{label:"Secondary",value:r.textSecondary,onChange:i=>c("textSecondary",i)}),e.jsx(ge,{label:"Muted",value:r.textMuted,onChange:i=>c("textMuted",i)})]}),e.jsxs(et,{title:"Borders & Accent",children:[e.jsx(ge,{label:"Border subtle",value:r.borderSubtle,onChange:i=>c("borderSubtle",i)}),e.jsx(ge,{label:"Border default",value:r.borderDefault,onChange:i=>c("borderDefault",i)}),e.jsx(ge,{label:"Accent",value:r.accentColor,onChange:i=>c("accentColor",i)})]})]}),e.jsxs("div",{children:[e.jsxs(et,{title:"Chat Bubbles",children:[e.jsx(ge,{label:"User bubble",value:r.userBubble,onChange:i=>c("userBubble",i)}),e.jsx(ge,{label:"User text",value:r.userText,onChange:i=>c("userText",i)}),e.jsx(ge,{label:"Agent bubble",value:r.assistantBubble,onChange:i=>c("assistantBubble",i)}),e.jsx(ge,{label:"Agent text",value:r.assistantText,onChange:i=>c("assistantText",i)})]}),e.jsxs(et,{title:"Chat Layout",children:[e.jsx(ge,{label:"Chat BG",value:r.containerBg,onChange:i=>c("containerBg",i)}),e.jsx(ge,{label:"Send button",value:r.sendButton,onChange:i=>c("sendButton",i)}),e.jsx(ge,{label:"Input border",value:r.inputBorder,onChange:i=>c("inputBorder",i)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:110},children:"Bubble radius"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1},children:[e.jsx("input",{type:"range",min:4,max:24,value:r.bubbleRadius,onChange:i=>c("bubbleRadius",Number(i.target.value)),style:{flex:1,accentColor:"var(--accent-primary)"}}),e.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)",width:28,textAlign:"right"},children:[r.bubbleRadius,"px"]})]})]})]})]})]}),e.jsx("button",{onClick:()=>{const i=t?zt:Ft,l=Ie(t?"light":"dark");t?pt(i,l):pt(l,i),a(i),Ke(i),s(i)},style:{marginTop:10,fontSize:"0.7rem",color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"4px 10px",cursor:"pointer"},children:"Reset to defaults"})]})}function ja(){const[t,s]=o.useState(vt),[n,r]=o.useState(!0),[a,c]=o.useState(()=>Ie("dark"));o.useEffect(()=>{r(ze());const l=new MutationObserver(()=>{const f=ze();r(f);const b=vt();b==="custom"?Ke(Ie(f?"dark":"light")):at(b,f?"dark":"light")});l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});const x=window.matchMedia("(prefers-color-scheme: dark)"),d=()=>{const f=ze();r(f);const b=vt();b==="custom"?Ke(Ie(f?"dark":"light")):at(b,f?"dark":"light")};return x.addEventListener("change",d),()=>{l.disconnect(),x.removeEventListener("change",d)}},[]),o.useEffect(()=>{document.documentElement.setAttribute("data-chat-theme",t),t==="custom"?Ke(Ie(n?"dark":"light")):(Yt(),at(t,n?"dark":"light"))},[t,n]),o.useEffect(()=>{c(Ie(n?"dark":"light"))},[n]);const i=l=>{s(l),ga(l)},h=[...ma,{id:"custom",name:"Custom",description:"Full app + chat customization",preview:{dark:{userBubble:a.userBubble,assistantBubble:a.assistantBubble,assistantBorder:`1px solid ${a.accentColor}22`,containerBg:a.containerBg,textColor:a.assistantText},light:{userBubble:a.userBubble,assistantBubble:a.assistantBubble,assistantBorder:`1px solid ${a.accentColor}22`,containerBg:a.containerBg,textColor:a.assistantText}}}];return e.jsxs("div",{children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-3",children:h.map(l=>{const x=t===l.id,d=n?l.preview.dark:l.preview.light,f=l.id==="honey"||l.id==="ember"?"#1a1a1a":l.id==="custom"?a.userText:"#fff";return e.jsxs("button",{onClick:()=>i(l.id),className:"text-left rounded-xl p-3 transition-all",style:{background:x?"var(--bg-glass-hover)":"var(--bg-glass)",border:x?"2px solid var(--accent-primary)":"2px solid var(--border-subtle)",opacity:x?1:.75},children:[e.jsxs("div",{className:"rounded-lg p-3 mb-2.5 flex flex-col gap-1.5",style:{background:d.containerBg},children:[e.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"Hello! How can I help?"}),e.jsx("div",{className:"self-end rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.userBubble,color:f},children:"Fix the bug please"}),e.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"On it! ✨"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[x&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-accent shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-bold text-text-primary",children:l.id==="custom"?"🎨 Custom":l.name}),e.jsx("div",{className:"text-[10px] text-text-muted",children:l.description})]})]})]},l.id)})}),t==="custom"&&e.jsx(ya,{dark:n,onColorsChange:l=>c(l)})]})}const an="adhdev_hiddenTabs";function va(){try{const t=localStorage.getItem(an);if(t)return new Set(JSON.parse(t))}catch{}return new Set}function tt(t){try{localStorage.setItem(an,JSON.stringify([...t]))}catch{}}function on(){const[t,s]=o.useState(va),n=o.useCallback(l=>{s(x=>{const d=new Set(x);return d.has(l)?d.delete(l):d.add(l),tt(d),d})},[]),r=o.useCallback(l=>{s(x=>{if(x.has(l))return x;const d=new Set(x);return d.add(l),tt(d),d})},[]),a=o.useCallback(l=>{s(x=>{if(!x.has(l))return x;const d=new Set(x);return d.delete(l),tt(d),d})},[]),c=o.useCallback((l,x)=>{s(d=>{const f=new Set(d);for(const b of x)f.add(b);return tt(f),f})},[]),i=o.useCallback((l,x)=>{s(d=>{const f=new Set(d);for(const b of x)f.delete(b);return tt(f),f})},[]),h=o.useCallback(l=>t.has(l),[t]);return{hiddenTabs:t,toggleTab:n,hideTab:r,showTab:a,hideAllForDaemon:c,showAllForDaemon:i,isHidden:h}}function cn({visibleConversations:t,clearedTabs:s,setClearedTabs:n,setActionLogs:r}){o.useEffect(()=>{Gr()},[]);const a=o.useMemo(()=>t.map(c=>({id:c.tabKey,name:c.title||c.agentName||c.ideId,status:c.status,activeModal:c.modalMessage?{message:c.modalMessage,buttons:c.modalButtons}:null})),[t]);return Jr(a),o.useEffect(()=>{if(Object.keys(s).length===0)return;const i=setTimeout(()=>{n(h=>{const l=Date.now(),x={};for(const[d,f]of Object.entries(h))l-f<5e3&&(x[d]=f);return Object.keys(x).length===Object.keys(h).length?h:x})},5500);return()=>clearTimeout(i)},[s,n]),o.useEffect(()=>{const c=setInterval(()=>{const i=Date.now()-3e5;r(h=>{const l=h.filter(x=>x.timestamp>i).slice(-100);return l.length===h.length?h:l})},6e4);return()=>clearInterval(c)},[r]),null}function wa(t){const s=t.filter(r=>r.type!=="adhdev-daemon"),n=new Map;for(const r of s){const a=n.get(r.id);if(!a){n.set(r.id,r);continue}const c=(a.workspace?1:0)+(a.activeChat?1:0);((r.workspace?1:0)+(r.activeChat?1:0)>c||(r.timestamp||0)>(a.timestamp||0))&&n.set(r.id,r)}return Array.from(n.values())}function mt(t,s){if(t.length!==s.length)return!1;for(let n=0;n<t.length;n+=1)if(t[n]!==s[n])return!1;return!0}function ka(t,s){const n=Date.now();return t.map(r=>{const a=s[r.tabKey];return a&&n-a<5e3?{...r,messages:[],title:""}:r})}function Na(t,s){const n=[],r=t.sessionId||t.instanceId;n.push({key:t.id,ref:s[t.id]}),r&&n.push({key:r,ref:s[r]});for(const a of t.childSessions||[]){const c=a.id||a.providerType,i=`${t.id}:${c}`;n.push({key:i,ref:s[i]}),n.push({key:a.id,ref:s[a.id]})}return n}function Sa(t,s){if(t.length!==s.length)return!1;for(let n=0;n<t.length;n+=1)if(t[n].key!==s[n].key||t[n].ref!==s[n].ref)return!1;return!0}function Ca({ides:t,connectionStates:s,localUserMessages:n,clearedTabs:r,hiddenTabs:a}){const c=o.useRef([]),i=o.useRef([]),h=o.useRef([]),l=o.useRef([]),x=o.useMemo(()=>{const p=wa(t);return mt(c.current,p)?c.current:(c.current=p,p)},[t]),d=o.useMemo(()=>Gs(t),[t]),f=o.useRef(new Map),b=o.useMemo(()=>{var T;const p=new Map,w=[];for(const y of x){const S=y.daemonId||((T=y.id)==null?void 0:T.split(":")[0])||y.id,k=s[S]||"new",j=y.daemonId&&d[y.daemonId]||void 0,_=Na(y,n),R=f.current.get(y.id);if(R&&R.ide===y&&R.connectionState===k&&R.machineName===j&&Sa(R.localRefs,_)){p.set(y.id,R),w.push(...R.conversations);continue}const D=Xs(y,n,{machineName:j,connectionState:k}),M={ide:y,connectionState:k,machineName:j,localRefs:_,conversations:D};p.set(y.id,M),w.push(...D)}return f.current=p,w},[x,n,s,d]),u=o.useMemo(()=>{const p=ka(b,r);return mt(i.current,p)?i.current:(i.current=p,p)},[b,r]),m=o.useMemo(()=>{const p=new Map;for(const w of u)w.sessionId&&p.set(w.sessionId,w),p.set(w.ideId,w),p.set(w.tabKey,w),p.set(w.ideType,w),p.set(w.agentType,w);return p},[u]),v=o.useCallback(p=>{if(p)return m.get(p)},[m]),N=o.useMemo(()=>{const p=u.filter(w=>!a.has(w.tabKey));return mt(h.current,p)?h.current:(h.current=p,p)},[u,a]),g=o.useMemo(()=>{const p=N.map(w=>w.tabKey);return mt(l.current,p)?l.current:(l.current=p,p)},[N]);return{chatIdes:x,conversations:u,visibleConversations:N,visibleTabKeys:g,resolveConversationByTarget:v}}function ln({ides:t,sendDaemonCommand:s,setToasts:n,setLocalUserMessages:r,resolveConversationByTarget:a}){o.useEffect(()=>{Pe.setIdes(t)},[t]),o.useEffect(()=>{Pe.setResolveAction((c,i,h)=>{s(c,i,h).catch(()=>{})})},[s]),o.useEffect(()=>{const c=Pe.onToast(l=>{n(d=>d.some(b=>b.message===l.message&&l.timestamp-b.timestamp<3e3)?d:[...d.slice(-4),{id:l.id,message:l.message,type:l.type,timestamp:l.timestamp,targetKey:l.targetKey,actions:l.actions}]);const x=l.duration||5e3;setTimeout(()=>n(d=>d.filter(f=>f.id!==l.id)),x)}),i=Pe.onSystemMessage((l,x)=>{r(d=>({...d,[l]:[...d[l]||[],x]}))}),h=Pe.onClearSystemMessage((l,x)=>{r(d=>{var f;return(f=d[l])!=null&&f.length?{...d,[l]:d[l].filter(b=>{var u;return!(b.role==="system"&&((u=b._localId)!=null&&u.startsWith(x)))})}:d})});return()=>{c(),i(),h()}},[n,r]),o.useEffect(()=>{const c=Vs.on("status_event",i=>Pe.handleRawEvent(i,"ws"));return()=>{c()}},[]),o.useEffect(()=>{var i;const c=h=>{const l=h.data;if((l==null?void 0:l.type)!=="notification_action"||l.action!=="approve"||!(l.ideId||l.targetSessionId||l.targetKey))return;const x=l.targetSessionId||l.targetKey||l.ideId,d=a(x),f=(d==null?void 0:d.ideId)||l.ideId;f&&s(f,"resolve_action",{action:"approve",button:"Approve",...(d==null?void 0:d.sessionId)&&{targetSessionId:d.sessionId},...l.targetSessionId&&{targetSessionId:l.targetSessionId}}).catch(b=>console.error("[SW Action] approve failed:",b))};return(i=navigator.serviceWorker)==null||i.addEventListener("message",c),()=>{var h;return(h=navigator.serviceWorker)==null?void 0:h.removeEventListener("message",c)}},[a,s])}const Ia="adhdev_dashboardLayout_v1",Ma="adhdev_dashboardDockview_v1",st={splitGroups:"adhdev_splitGroups",focusedGroup:"adhdev_focusedGroup",groupActiveTabs:"adhdev_groupActiveTabs",groupTabOrders:"adhdev_groupTabOrders",splitSizes:"adhdev_splitSizes"},nt={groupAssignments:[],focusedGroup:0,groupActiveTabIds:{},groupTabOrders:{},groupSizes:[]};function qe(t,s){try{const n=localStorage.getItem(t);return n?JSON.parse(n):s}catch{return s}}function Ta(t){try{return localStorage.getItem(t)}catch{return null}}function dn(t){return t<768?"mobile":t<1280?"desktop-narrow":"desktop-wide"}function un(t){return`${Ia}:${t}`}function hn(){const t=Ta(st.focusedGroup),s=qe(st.splitGroups,[]),n=qe(st.groupActiveTabs,{}),r=qe(st.groupTabOrders,{}),a=qe(st.splitSizes,[]);return t!==null||s.length>0||Object.keys(n).length>0||Object.keys(r).length>0||a.length>0?{groupAssignments:s,focusedGroup:t&&parseInt(t,10)||0,groupActiveTabIds:n,groupTabOrders:r,groupSizes:a}:null}function Ea(){return hn()}function Aa(t){const s=un(t),n=qe(s,null);return n||hn()}function Ra(t,s){try{const n=s.groupAssignments.length===0&&s.focusedGroup===0&&Object.keys(s.groupActiveTabIds).length===0&&Object.keys(s.groupTabOrders).length===0&&s.groupSizes.length===0,r=un(t);if(n){localStorage.removeItem(r);return}localStorage.setItem(r,JSON.stringify(s))}catch{}}function xn(t){return`${Ma}:${t}`}function La(t){const s=xn(t);return qe(s,null)}function _a(t,s){try{const n=xn(t);if(!s){localStorage.removeItem(n);return}localStorage.setItem(n,JSON.stringify(s))}catch{}}function $a(){return{groupAssignments:[...nt.groupAssignments],focusedGroup:nt.focusedGroup,groupActiveTabIds:{...nt.groupActiveTabIds},groupTabOrders:{...nt.groupTabOrders},groupSizes:[...nt.groupSizes]}}function Pa(){const[t]=o.useState(()=>dn(typeof window<"u"?window.innerWidth:1280)),[s,n]=o.useState(()=>new Map),[r,a]=o.useState(0),[c,i]=o.useState({}),[h,l]=o.useState({}),[x,d]=o.useState([]),[f,b]=o.useState(()=>typeof window<"u"&&window.innerWidth<768),[u,m]=o.useState(!1),v=o.useCallback(()=>{if(u)return;const N=Aa(t)??$a();n(new Map(N.groupAssignments)),a(N.focusedGroup),i(N.groupActiveTabIds),l(N.groupTabOrders),d(N.groupSizes),m(!0)},[u,t]);return o.useEffect(()=>{u&&Ra(t,{groupAssignments:[...s.entries()],focusedGroup:r,groupActiveTabIds:c,groupTabOrders:h,groupSizes:x})},[u,t,s,r,c,h,x]),o.useEffect(()=>{const N=window.matchMedia("(max-width: 767px)"),g=p=>b(p.matches);return N.addEventListener("change",g),()=>N.removeEventListener("change",g)},[]),{groupAssignments:s,setGroupAssignments:n,focusedGroup:r,setFocusedGroup:a,groupActiveTabIds:c,setGroupActiveTabIds:i,groupTabOrders:h,setGroupTabOrders:l,groupSizes:x,setGroupSizes:d,isMobile:f,hasHydratedStoredLayout:u,hydrateStoredLayout:v}}function Da({urlActiveTab:t,conversations:s,resolveConversationByTarget:n,normalizedGroupAssignments:r,hasHydratedStoredLayout:a,hydrateStoredLayout:c,setGroupActiveTabIds:i,setFocusedGroup:h,setSearchParams:l,historyModalOpen:x,activeConv:d,isRefreshingHistory:f,ides:b,handleRefreshHistory:u}){const m=o.useRef(!1),v=o.useRef(!1),N=o.useRef(null),g=o.useRef(!1);o.useEffect(()=>{if(!t||m.current||s.length===0)return;if(!a){c();return}const p=n(t);if(!p)return;const w=r.get(p.tabKey)??0;i(T=>({...T,[w]:p.tabKey})),h(w),m.current=!0,v.current=!0,N.current!=null&&(window.clearTimeout(N.current),N.current=null),l(T=>{const y=new URLSearchParams(T);return y.delete("activeTab"),y},{replace:!0})},[t,s,n,r,a,c,i,h,l]),o.useEffect(()=>{if(!(v.current||a)&&s.length!==0){if(!t){c(),v.current=!0;return}if(m.current){v.current=!0;return}if(N.current==null)return N.current=window.setTimeout(()=>{N.current=null,!(v.current||a)&&(c(),v.current=!0)},1500),()=>{N.current!=null&&(window.clearTimeout(N.current),N.current=null)}}},[t,s.length,a,c]),o.useEffect(()=>{if(!x){g.current=!1;return}if(!d||g.current||f)return;const p=b.find(w=>w.id===d.ideId);p&&(!p.chats||p.chats.length===0)&&(g.current=!0,u())},[x,d,f,b,u]),o.useEffect(()=>{if(!d)return;let p=null,w=0,T=-1,y=0;const S=()=>{p=null;const k=Array.from(document.querySelectorAll("[data-chat-scroll]")).filter(_=>_.offsetParent!==null);if(k.length===0){w<18&&(w+=1,p=requestAnimationFrame(S));return}let j=0;for(const _ of k)_.scrollTop=_.scrollHeight,j+=_.scrollHeight;j===T?y+=1:(y=0,T=j),w+=1,!(y>=2||w>=18)&&(p=requestAnimationFrame(S))};return p=requestAnimationFrame(S),()=>{p!=null&&cancelAnimationFrame(p)}},[d==null?void 0:d.tabKey])}function Le(t){if(!t)return{};const s=t.sessionId?{targetSessionId:t.sessionId}:{};return je(t)||fe(t)?{...s,agentType:t.agentType||t.ideType}:t.streamSource==="agent-stream"?{...s,agentType:t.agentType}:s}function It(t){return t&&(t.ideId||t.daemonId)||""}function ft(t,s){t(n=>[...n,{id:Date.now(),message:s,type:"warning",timestamp:Date.now()}])}function Ba({sendDaemonCommand:t,activeConv:s,updateIdeChats:n,setToasts:r,setLocalUserMessages:a,setClearedTabs:c}){const[i,h]=o.useState(!1),[l,x]=o.useState(!1),d=o.useCallback(async m=>{try{await t("standalone","launch_ide",{ideType:m,enableCdp:!0})}catch(v){console.error("Launch failed",v)}},[t]),f=o.useCallback(async(m,v)=>{try{const N=m||(s==null?void 0:s.daemonId)||"",g=await t(N,"switch_chat",{id:v,sessionId:v,...Le(s)}),p=g==null?void 0:g.result;if((g==null?void 0:g.success)===!0||p==="switched"||p==="switched-by-title")return;p===!1||p==="not_found"?ft(r,"⚠️ Session tab not found — try refreshing history"):typeof p=="string"&&p.startsWith("error:")?ft(r,`⚠️ Switch error: ${p}`):ft(r,"⚠️ Session switch failed")}catch(N){console.error("Switch failed",N),ft(r,`❌ Switch failed: ${N.message||"connection error"}`)}},[s,t,r]),b=o.useCallback(async()=>{if(!(!s||i)){h(!0);try{const m=It(s);await t(m,"new_chat",{...Le(s)}),c(v=>({...v,[s.tabKey]:Date.now()})),a(v=>({...v,[s.tabKey]:[]}))}catch(m){console.error("New chat failed",m)}finally{h(!1)}}},[s,i,t,c,a]),u=o.useCallback(async()=>{var m;if(!(!s||l)){x(!0);try{const v=It(s),N=await t(v,"list_chats",{forceExpand:!0,...Le(s)}),g=(N==null?void 0:N.chats)||((m=N==null?void 0:N.result)==null?void 0:m.chats);N!=null&&N.success&&Array.isArray(g)&&n(s.ideId,g)}catch(v){console.error("Refresh history failed",v)}finally{x(!1)}}},[s,l,t,n]);return{isCreatingChat:i,isRefreshingHistory:l,handleLaunchIde:d,handleSwitchSession:f,handleNewChat:b,handleRefreshHistory:u}}function Wa(t,s){if(t.size!==s.size)return!1;for(const[n,r]of t)if(s.get(n)!==r)return!1;return!0}function Oa(t,s){return t.length!==s.length?!1:t.every((n,r)=>n===s[r])}function hs(t,s){const n=Object.keys(t),r=Object.keys(s);return n.length!==r.length?!1:n.every(a=>s[Number(a)]===t[Number(a)])}function gt(t,s){const n=new Set(s),r=s.length>0?[0]:[];for(const[i,h]of t)!n.has(i)||h<=0||r.includes(h)||r.push(h);r.sort((i,h)=>i-h);const a={};r.forEach((i,h)=>{a[i]=h}),r.length===0&&(a[0]=0);const c=new Map;for(const[i,h]of t){if(!n.has(i)||h<=0)continue;const l=a[h];typeof l=="number"&&l>0&&c.set(i,l)}return{assignments:c,groupCount:Math.max(1,r.length),mapping:a,usedGroups:r}}function xs(t,s){const n={};for(const[r,a]of Object.entries(t)){const c=s[Number(r)];typeof c=="number"&&(n[c]=a)}return n}function Ka(t,s,n){if(s.length===0)return 0;if(typeof n[t]=="number")return n[t];const r=[...s].reverse().find(a=>a<t)??s[0];return n[r]??0}function za(t,s,n){if(s.length<=1)return[];const r=s.map(i=>t[i]).filter(i=>Number.isFinite(i)),a=r.length===s.length?r:Array(n).fill(100/n),c=a.reduce((i,h)=>i+h,0);return c>0?a.map(i=>i/c*100):Array(n).fill(100/n)}function ps(t,s){const n={};for(const[r,a]of Object.entries(t)){const c=Number(r);n[c>=s?c+1:c]=a}return n}function ms(t){return Array(t).fill(100/t)}function Fa({groupAssignments:t,setGroupAssignments:s,setFocusedGroup:n,setGroupActiveTabIds:r,setGroupTabOrders:a,groupSizes:c,setGroupSizes:i,isMobile:h,visibleConversations:l,visibleTabKeys:x}){const d=o.useRef(null),f=o.useMemo(()=>gt(t,x),[t,x]),b=f.assignments,u=o.useMemo(()=>h?1:f.groupCount,[f.groupCount,h]),m=u>1,v=o.useCallback((y,S)=>{s(k=>{const j=new Map(gt(k,x).assignments);return S===0?j.delete(y):j.set(y,S),j}),r(k=>({...k,[S]:y})),n(S)},[s,x,r,n]),N=o.useCallback(y=>{s(S=>{const k=gt(S,x).assignments,j=new Map;for(const[_,R]of k)R!==y&&(R>y?j.set(_,R-1):j.set(_,R));return j}),i(S=>{if(S.length<=1)return[];const k=[...S];k.splice(y,1);const j=k.reduce((_,R)=>_+R,0);return j>0?k.map(_=>_/j*100):[]}),n(0)},[s,x,i,n]),g=o.useCallback((y,S)=>{S.preventDefault();const k=d.current;if(!k)return;const j=S.clientX,_=k.offsetWidth,R=c.length===u?[...c]:ms(u),D=E=>{const O=(E.clientX-j)/_*100,C=[...R];C[y]=Math.max(15,R[y]+O),C[y+1]=Math.max(15,R[y+1]-O),i(C)},M=()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",M),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",D),document.addEventListener("mouseup",M)},[c,u,i]),p=o.useCallback((y,S,k)=>{if(u>=4)return;const j=k==="left"?S:S+1;s(_=>{const R=gt(_,x).assignments,D=new Map;for(const M of l){const E=R.get(M.tabKey)??0,$=E>=j?E+1:E;$>0&&D.set(M.tabKey,$)}return j>0&&D.set(y,j),D}),i(_=>{const R=_.length===u?[..._]:ms(u),D=R[S]??100/u,M=Math.max(15,D/2),E=Math.max(15,D/2),$=[...R];$[S]=M,$.splice(j,0,E);const O=$.reduce((C,V)=>C+V,0);return $.map(C=>C/O*100)}),r(_=>{const R=ps(_,j);return R[j]=y,R}),a(_=>{const R=ps(_,j);return R[j]=[y],R}),n(j)},[u,s,x,l,i,r,a,n]);o.useEffect(()=>{Wa(t,b)||s(b)},[t,b,s]),o.useEffect(()=>{const{mapping:y,usedGroups:S}=f;r(k=>{const j=xs(k,y);return hs(k,j)?k:j}),a(k=>{const j=xs(k,y);return hs(k,j)?k:j}),n(k=>{const j=h?0:Ka(k,S,y);return k===j?k:j}),i(k=>{const j=h?[]:za(k,S,f.groupCount);return Oa(k,j)?k:j})},[f,h,r,a,n,i]);const w=o.useMemo(()=>{const y=Array.from({length:u},()=>[]);for(const S of l){const k=b.get(S.tabKey)??0,j=Math.min(k,u-1);y[j].push(S)}return y},[l,b,u]),T=o.useCallback(()=>{s(new Map),n(0)},[s,n]);return{containerRef:d,normalizedGroupAssignments:b,numGroups:u,isSplitMode:m,groupedConvs:w,moveTabToGroup:v,closeGroup:N,handleResizeStart:g,splitTabRelative:p,clearAllSplits:T}}function Ha({ides:t,sendDaemonCommand:s}){const n="0.7.35",r=o.useMemo(()=>t.filter(x=>{if(x.type!=="adhdev-daemon")return!1;const d=x.version||x.daemonVersion||null;return!d||!n?!1:d!==n}),[n,t]),[a,c]=o.useState(!1),[i,h]=o.useState({}),l=o.useCallback(async x=>{var d,f;h(b=>({...b,[x]:"upgrading"}));try{const b=await s(x,"daemon_upgrade",{});(d=b==null?void 0:b.result)!=null&&d.upgraded||(f=b==null?void 0:b.result)!=null&&f.success?h(u=>({...u,[x]:"done"})):h(u=>({...u,[x]:"error"}))}catch{h(b=>({...b,[x]:"error"}))}},[s]);return{versionMismatchDaemons:r,appVersion:n,versionBannerDismissed:a,setVersionBannerDismissed:c,upgradingDaemons:i,handleBannerUpgrade:l}}const pn=o.memo(function({activeConv:s,clearToken:n,isCli:r,ideEntry:a,screenshotUrl:c,clearScreenshot:i,terminalRef:h,handleModalButton:l,handleRelaunch:x,handleSendChat:d,isSendingChat:f,handleFocusAgent:b,isFocusingAgent:u,actionLogs:m,userName:v}){const N=o.useCallback(()=>{i()},[i]);return e.jsxs(e.Fragment,{children:[e.jsx(Ks,{activeConv:s,onModalButton:l}),e.jsx("div",{className:"desktop-only px-3 pt-1 pb-2",children:!r&&s.transport!=="acp"&&c?e.jsx(fr,{screenshotUrl:c,mode:"preview",onDismiss:N}):!r&&s.transport!=="acp"&&s.cdpConnected===!1?e.jsxs("div",{className:"flex items-center gap-2.5 px-3.5 py-2 bg-yellow-500/[0.08] border border-yellow-500/20 rounded-lg text-xs text-text-secondary",children:[e.jsx("span",{className:"text-sm",children:e.jsx(Ut,{size:14})}),e.jsx("span",{className:"flex-1",children:"CDP not connected — chat history & screenshots unavailable."}),e.jsx("button",{className:"btn btn-sm bg-yellow-500/15 text-yellow-500 border border-yellow-500/30 text-[10px] whitespace-nowrap shrink-0",onClick:x,children:"Relaunch with CDP"})]}):null}),r?e.jsx(Lr,{activeConv:s,clearToken:n,terminalRef:h,handleSendChat:d,isSendingChat:f}):e.jsx(Hs,{activeConv:s,ideEntry:a,handleSendChat:d,isSendingChat:f,handleFocusAgent:b,isFocusingAgent:u,actionLogs:m,userName:v})]})},(t,s)=>t.activeConv===s.activeConv&&t.isCli===s.isCli&&t.ideEntry===s.ideEntry&&t.screenshotUrl===s.screenshotUrl&&t.terminalRef===s.terminalRef&&t.handleModalButton===s.handleModalButton&&t.handleRelaunch===s.handleRelaunch&&t.handleSendChat===s.handleSendChat&&t.isSendingChat===s.isSendingChat&&t.handleFocusAgent===s.handleFocusAgent&&t.isFocusingAgent===s.isFocusingAgent&&t.actionLogs===s.actionLogs&&t.userName===s.userName),Lt={unix:{cmd:"curl -fsSL https://adhf.dev/install | sh",shell:"Terminal",prompt:"$ "},powershell:{cmd:"irm https://adhf.dev/install.ps1 | iex",shell:"PowerShell",prompt:"PS> "},cmd:{cmd:"curl -fsSL https://adhf.dev/install.cmd -o %TEMP%\\adhdev.cmd && %TEMP%\\adhdev.cmd",shell:"CMD",prompt:"> "}};function Ua(){return typeof navigator>"u"?"unix":navigator.userAgent.toLowerCase().includes("win")?"windows":"unix"}function Va(){const[t,s]=o.useState("unix"),[n,r]=o.useState("powershell"),[a,c]=o.useState(!1),i=t==="unix"?"unix":n;o.useEffect(()=>{s(Ua())},[]);const h=o.useCallback(()=>{navigator.clipboard.writeText(Lt[i].cmd).catch(()=>{}),c(!0),setTimeout(()=>c(!1),2e3)},[i]);return e.jsxs("div",{className:"text-left bg-bg-secondary border border-border-subtle rounded-xl p-4 font-mono text-[13px] shadow-lg w-full mx-auto leading-relaxed relative select-all",children:[e.jsxs("div",{className:"flex gap-1 mb-3 font-sans",children:[e.jsx("button",{className:`text-[10px] px-2.5 py-1 rounded-md font-bold transition-all cursor-pointer ${t==="unix"?"bg-accent/15 text-accent border border-accent/25":"bg-transparent text-text-muted border border-transparent hover:text-text-secondary"}`,onClick:()=>s("unix"),children:"🍎🐧 macOS / Linux"}),e.jsx("button",{className:`text-[10px] px-2.5 py-1 rounded-md font-bold transition-all cursor-pointer ${t==="windows"?"bg-accent/15 text-accent border border-accent/25":"bg-transparent text-text-muted border border-transparent hover:text-text-secondary"}`,onClick:()=>s("windows"),children:"🪟 Windows"})]}),t==="windows"&&e.jsxs("div",{className:"flex gap-1 mb-3 font-sans",children:[e.jsx("button",{className:`text-[9px] px-2 py-0.5 rounded font-semibold cursor-pointer transition-all ${n==="powershell"?"bg-accent/10 text-accent":"text-text-muted hover:text-text-secondary"}`,onClick:()=>r("powershell"),children:"⚡ PowerShell"}),e.jsx("button",{className:`text-[9px] px-2 py-0.5 rounded font-semibold cursor-pointer transition-all ${n==="cmd"?"bg-accent/10 text-accent":"text-text-muted hover:text-text-secondary"}`,onClick:()=>r("cmd"),children:">_ CMD"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-accent cursor-pointer group",onClick:h,title:"Click to copy",children:[e.jsx("span",{className:"text-text-muted select-none",children:Lt[i].prompt}),e.jsx("span",{className:"flex-1 break-all",children:Lt[i].cmd}),e.jsx("span",{className:"text-[9px] font-sans text-text-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0 select-none",children:a?"✓":"📋"})]}),e.jsxs("div",{className:"text-text-muted text-[10px] font-sans mt-2",children:["Or via npm: ",e.jsx("span",{className:"text-text-secondary font-mono",children:"npm i -g @adhdev/daemon-standalone && adhdev-standalone"})]})]})}function Gt({conversationsCount:t,isSplitMode:s,isStandalone:n,detectedIdes:r,handleLaunchIde:a}){return t===0&&!s&&r&&a?e.jsxs("div",{className:"empty-dashboard flex-1 flex flex-col items-center justify-center -mt-8",children:[e.jsx("div",{className:"glow-orb mb-6 opacity-90 animate-bounce",style:{animationDuration:"3s"},children:e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-16 h-16 object-contain"})}),e.jsxs("div",{className:"text-center max-w-lg",children:[e.jsx("h2",{className:"font-bold text-2xl mb-2.5 tracking-tight text-text-primary",children:"Waiting for your IDE"}),e.jsx("p",{className:"text-[14px] text-text-secondary mb-8 leading-relaxed max-w-md mx-auto",children:n?"Launch any supported IDE or CLI agent to start monitoring automatically.":"Install the ADHDev daemon and link your dashboard to start."}),!n&&e.jsx(Va,{}),n&&r.length>0&&e.jsxs("div",{className:"flex flex-col gap-3 items-center",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Fast Launch"}),e.jsx("div",{className:"flex flex-wrap gap-2.5 justify-center mt-1",children:r.map(c=>e.jsxs("button",{className:"btn btn-sm bg-accent/10 border border-accent/25 text-accent text-xs font-medium px-4 py-2.5 rounded-lg cursor-pointer flex items-center gap-2 transition-all hover:bg-accent/20 hover:scale-105 active:scale-95",onClick:()=>a(c.type),children:[e.jsx(Ds,{size:14,className:"opacity-70"})," Launch ",c.name]},c.type))})]}),!n&&e.jsx("div",{className:"mt-8",children:e.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-accent hover:opacity-80 transition-colors flex items-center justify-center gap-1.5",children:"📚 Read the documentation →"})})]})]}):e.jsx("div",{className:"text-sm text-text-muted opacity-50",children:s?"Move a tab here to view":"No active agent"})}function Xt({sendDaemonCommand:t,activeConv:s,setLocalUserMessages:n,setActionLogs:r,isStandalone:a}){const[c,i]=o.useState(!1),[h,l]=o.useState(!1),x=o.useRef(!1),d=o.useCallback(async m=>{if(!s)return;const v=m.trim();if(!v||x.current)return;const N=s.tabKey;x.current=!0,l(!0);const g=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,p={role:"user",content:v,timestamp:Date.now(),_localId:g};n(w=>({...w,[N]:[...w[N]||[],p]}));try{const w=It(s);if(!w)return;await t(w,"send_chat",{message:v,text:v,...Le(s)}),setTimeout(()=>{const T=Date.now()-6e4;n(y=>{const S=y[N];if(!S)return y;const k=S.filter(j=>j.timestamp>T);return k.length===S.length?y:{...y,[N]:k}})},6e4)}catch(w){console.error("Send failed",w),n(T=>({...T,[N]:(T[N]||[]).filter(y=>y._localId!==g)}))}finally{x.current=!1,l(!1)}},[s,t,n]),f=o.useCallback(async()=>{if(s)try{if(a){await t(s.ideId,"launch_ide",{ideType:s.ideType,enableCdp:!0});return}await t(s.ideId,"vscode_command_exec",{commandId:"adhdev.relaunchWithCdp",args:[{force:!0}]})}catch(m){console.error("Relaunch failed",m)}},[s,a,t]),b=o.useCallback(async m=>{if(s){r(v=>[...v,{ideId:s.tabKey,text:`🖱️ **${m}** clicked`,timestamp:Date.now()}]);try{const N=(s.modalButtons||[]).indexOf(m),g=m.replace(/[⌥⏎⇧⌫⌘⌃]/g,"").trim().toLowerCase(),p=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(g),w=It(s);if(!w)return;(await t(w,"resolve_action",{button:m,action:p?"approve":"reject",...N>=0&&{buttonIndex:N},...Le(s)})).success||r(y=>[...y,{ideId:s.tabKey,text:`⚠️ **${m}** failed — button not found`,timestamp:Date.now()}])}catch(v){console.error("[ModalButton] Error:",v),r(N=>[...N,{ideId:s.tabKey,text:`❌ **${m}** error`,timestamp:Date.now()}])}}},[s,t,r]),u=o.useCallback(async()=>{if(!(!s||c)){i(!0);try{await t(s.ideId,"focus_session",{agentType:s.agentType,...s.sessionId&&{targetSessionId:s.sessionId}})}catch(m){console.error("Focus agent failed",m)}finally{i(!1)}}},[s,c,t]);return{isSendingChat:h,isFocusingAgent:c,handleSendChat:d,handleRelaunch:f,handleModalButton:b,handleFocusAgent:u}}const mn=o.createContext(null);function Jt(){const t=o.useContext(mn);if(!t)throw new Error("DashboardDockviewContext missing");return t}function wt(t){return t.displayPrimary||t.title||t.agentName||t.tabKey}function qa(t){const[,s]=o.useState(0);o.useEffect(()=>{const n=()=>s(a=>a+1),r=[t.onDidActiveGroupChange(n),t.onDidTitleChange(n),t.onDidGroupChange(n)];return()=>{for(const a of r)a.dispose()}},[t])}function Ya(t,s){if(!s)return[t];const n=new Map(s.groupAssignments),r=new Map(t.map(i=>[i.tabKey,i])),a=new Map;for(const i of t){const h=n.get(i.tabKey)??0,l=a.get(h)??[];l.push(i),a.set(h,l)}return[...a.keys()].sort((i,h)=>i-h).map(i=>{const h=a.get(i)??[],x=(s.groupTabOrders[i]??[]).map(f=>r.get(f)).filter(f=>!!f),d=new Set(x.map(f=>f.tabKey));for(const f of h)d.has(f.tabKey)||x.push(f);return x}).filter(i=>i.length>0)}function Ga(t,s,n){var l;const r=Ea(),a=Ya(s,r);let c;for(const x of a){let d;for(const f of x){const b=t.addPanel({id:f.tabKey,component:"conversation",title:wt(f),params:{tabKey:f.tabKey},...d?{position:{referencePanel:d,direction:"within"},inactive:!0}:c?{position:{referencePanel:c,direction:"right"},inactive:!0}:{}});d||(d=b.id)}c=d??c}const i=n??(r?r.groupActiveTabIds[r.focusedGroup]:null)??((l=s[0])==null?void 0:l.tabKey)??null;if(!i)return;const h=t.getPanel(i);h&&h.group.model.openPanel(h)}function fs(t,s){const n=new Set(s.map(r=>r.tabKey));for(const r of[...t.panels])n.has(r.id)||t.removePanel(r);for(const r of s){const a=t.getPanel(r.tabKey);if(a){a.update({params:{tabKey:r.tabKey}}),a.title!==wt(r)&&a.api.setTitle(wt(r));continue}t.addPanel({id:r.tabKey,component:"conversation",title:wt(r),params:{tabKey:r.tabKey},...t.activePanel?{position:{referencePanel:t.activePanel.id,direction:"within"},inactive:!0}:t.panels[0]?{position:{referencePanel:t.panels[0].id,direction:"within"},inactive:!0}:{}})}}function Xa({params:t}){const s=Jt(),n=o.useRef(null),r=s.conversationsByTabKey.get(t.tabKey),a=Xt({sendDaemonCommand:s.sendDaemonCommand,activeConv:r,setLocalUserMessages:s.setLocalUserMessages,setActionLogs:s.setActionLogs,isStandalone:s.isStandalone}),c=o.useMemo(()=>r?s.ides.find(d=>d.id===r.ideId):void 0,[s.ides,r]),i=r?s.screenshotMap[r.ideId]:void 0,h=o.useCallback(()=>{if(!r||!(r.ideId in s.screenshotMap))return;const d={...s.screenshotMap};delete d[r.ideId],s.setScreenshotMap(d)},[r,s]),l=o.useMemo(()=>r?s.actionLogs.filter(d=>d.ideId===r.tabKey):[],[s.actionLogs,r]);if(!r)return e.jsx("div",{className:"h-full min-h-0 min-w-0 flex flex-col",children:e.jsx(Gt,{conversationsCount:0,isSplitMode:!1,isStandalone:s.isStandalone,detectedIdes:s.detectedIdes,handleLaunchIde:s.handleLaunchIde})});const x=je(r)&&!fe(r);return e.jsx("div",{className:"h-full min-h-0 min-w-0 flex flex-col overflow-hidden",children:e.jsx(pn,{activeConv:r,clearToken:s.clearedTabs[r.tabKey]||0,isCli:x,ideEntry:c,screenshotUrl:i,clearScreenshot:h,terminalRef:n,handleModalButton:a.handleModalButton,handleRelaunch:a.handleRelaunch,handleSendChat:a.handleSendChat,isSendingChat:a.isSendingChat,handleFocusAgent:a.handleFocusAgent,isFocusingAgent:a.isFocusingAgent,actionLogs:l,userName:s.userName})})}function Ja(){const t=Jt();return e.jsx("div",{className:"h-full min-h-0 min-w-0 flex flex-col items-center justify-center",children:e.jsx(Gt,{conversationsCount:0,isSplitMode:!1,isStandalone:t.isStandalone,detectedIdes:t.detectedIdes,handleLaunchIde:t.handleLaunchIde})})}function Za(t){var x;qa(t.api);const n=Jt().conversationsByTabKey.get(t.params.tabKey);if(!n)return e.jsx("div",{className:"adhdev-dockview-tab adhdev-dockview-tab-empty",children:e.jsx("div",{className:"adhdev-dockview-tab-copy",children:e.jsx("div",{className:"adhdev-dockview-tab-primary",children:t.api.title||t.params.tabKey})})});const r=((x=t.api.group.activePanel)==null?void 0:x.id)===t.api.id,a=t.api.isGroupActive,c=n.connectionState==="failed"||n.connectionState==="closed",i=n.connectionState==="connecting"||n.connectionState==="new",h=n.status==="generating",l=n.status==="waiting_approval";return e.jsxs("div",{className:`adhdev-dockview-tab${r?" is-active":""}${a?" is-group-active":""}${c?" is-reconnecting":""}`,title:n.displayPrimary,children:[e.jsx("div",{className:"adhdev-dockview-tab-status","aria-hidden":"true",children:h?e.jsx("div",{className:"tab-spinner"}):l?e.jsx("span",{className:"adhdev-dockview-tab-status-text is-waiting",children:"▲"}):c?e.jsx("span",{className:"adhdev-dockview-tab-status-text is-reconnecting",children:"○"}):i?e.jsx("div",{className:"tab-connecting-spinner"}):n.connectionState==="connected"?e.jsx("span",{className:"adhdev-dockview-tab-status-text is-connected",children:"●"}):e.jsx("span",{className:"adhdev-dockview-tab-status-text is-idle",children:"○"})}),e.jsxs("div",{className:"adhdev-dockview-tab-copy",children:[e.jsx("div",{className:"adhdev-dockview-tab-primary",children:n.displayPrimary}),e.jsx("div",{className:"adhdev-dockview-tab-meta",children:c?e.jsx("span",{className:"adhdev-dockview-tab-reconnecting",children:"Reconnecting…"}):i?e.jsx("span",{className:"adhdev-dockview-tab-connecting",children:"Connecting…"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:n.displaySecondary}),n.machineName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"adhdev-dockview-tab-dot",children:"·"}),e.jsxs("span",{className:"adhdev-dockview-tab-machine",children:["🖥 ",n.machineName]})]})]})})]})]})}function Qa({visibleConversations:t,clearedTabs:s,ides:n,actionLogs:r,screenshotMap:a,setScreenshotMap:c,sendDaemonCommand:i,setLocalUserMessages:h,setActionLogs:l,isStandalone:x,userName:d,detectedIdes:f,handleLaunchIde:b,toggleHiddenTab:u,onActiveTabChange:m,requestedActiveTabKey:v,onRequestedActiveTabConsumed:N}){const{sendCommand:g}=$e(),p=o.useRef(null),w=o.useRef(!1),T=o.useMemo(()=>dn(typeof window<"u"?window.innerWidth:1280),[]),y=o.useMemo(()=>new Map(t.map(R=>[R.tabKey,R])),[t]),S=o.useMemo(()=>({actionLogs:r,clearedTabs:s,conversationsByTabKey:y,detectedIdes:f,handleLaunchIde:b,ides:n,isStandalone:x,screenshotMap:a,sendDaemonCommand:i,setActionLogs:l,setLocalUserMessages:h,setScreenshotMap:c,toggleHiddenTab:u,userName:d}),[r,s,y,f,b,n,x,a,i,l,h,c,u,d]),k=o.useCallback(R=>{if(!R)return!1;const D=p.current;if(!D)return!1;const M=D.getPanel(R);return M?(M.group.model.openPanel(M),N==null||N(),!0):!1},[N]),j=o.useCallback(R=>{var M;p.current=R.api;const D=La(T);D!=null&&D.layout&&R.api.fromJSON(D.layout,{reuseExistingPanels:!1}),fs(R.api,t),R.api.totalPanels===0&&t.length>0?Ga(R.api,t,v):k(v)||k(D==null?void 0:D.activeTabId),w.current=!0,R.api.onDidActivePanelChange(E=>{if(m((E==null?void 0:E.id)??null),!E)return;const $=y.get(E.id);($==null?void 0:$.streamSource)==="agent-stream"&&$.agentType&&g($.ideId,"focus_session",{agentType:$.agentType,...$.sessionId&&{targetSessionId:$.sessionId}}).catch(()=>{})}),R.api.onDidLayoutChange(()=>{var E;_a(T,{activeTabId:((E=R.api.activePanel)==null?void 0:E.id)??null,layout:R.api.toJSON()})}),m(((M=R.api.activePanel)==null?void 0:M.id)??null)},[k,y,T,m,v,g,t]);o.useEffect(()=>{const R=p.current;!R||!w.current||(fs(R,t),!R.activePanel&&R.panels[0]&&R.panels[0].group.model.openPanel(R.panels[0]))},[t]),o.useEffect(()=>{w.current&&k(v)},[k,v]);const _=typeof document<"u"&&document.documentElement.dataset.theme==="light"?Tn:En;return e.jsx(mn.Provider,{value:S,children:e.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:e.jsx(An,{className:"h-full min-h-0 min-w-0 adhdev-dockview",components:{conversation:Xa},defaultTabComponent:Za,watermarkComponent:Ja,onReady:j,singleTabMode:"default",tabAnimation:"smooth",theme:_})})})}function _t(t,s){return!!(t<4&&s&&window.innerWidth>=768)}function eo({conversations:t,numGroups:s,onMoveTab:n,onReceiveTab:r,onOwnTabDrop:a,onClearPreviewOrder:c}){const i=o.useRef(0),[h,l]=o.useState(!1),[x,d]=o.useState(null),f=o.useCallback(()=>{i.current=0,l(!1),d(null)},[]);o.useEffect(()=>(window.addEventListener("dragend",f),window.addEventListener("drop",f),()=>{window.removeEventListener("dragend",f),window.removeEventListener("drop",f)}),[f]);const b=o.useCallback(N=>{N.dataTransfer.types.includes("text/tab-key")&&(i.current+=1,l(!0))},[]),u=o.useCallback(N=>{if(!N.dataTransfer.types.includes("text/tab-key"))return;if(N.preventDefault(),!_t(s,n)){d("merge");return}const g=N.currentTarget.getBoundingClientRect(),p=N.clientX-g.left,w=g.width/3;p<w?d("split-left"):p>w*2?d("split-right"):d("merge")},[s,n]),m=o.useCallback(()=>{i.current-=1,!(i.current>0)&&(i.current=0,l(!1),d(null))},[]),v=o.useCallback(N=>{i.current=0,l(!1);const g=N.dataTransfer.getData("text/tab-key"),p=g?t.some(T=>T.tabKey===g):!1,w=x;if(d(null),c(),!!g){if(N.preventDefault(),w==="split-left"&&_t(s,n)){n==null||n(g,"split-left");return}if(w==="split-right"&&_t(s,n)){n==null||n(g,"split-right");return}if(p){a(g);return}r==null||r(g)}},[t,x,s,n,r,a,c]);return{dragOver:h,dropAction:x,resetDragState:f,handleDragEnter:b,handleDragOver:u,handleDragLeave:m,handleDrop:v}}function to(t,s){const n=new Set(s.map(c=>c.tabKey)),r=t.filter(c=>n.has(c)),a=s.filter(c=>!t.includes(c.tabKey)).map(c=>c.tabKey);return[...r,...a]}function so({conversations:t,initialActiveTabId:s,initialTabOrder:n,onActiveTabChange:r,onTabOrderChange:a}){const[c,i]=o.useState(s??null),[h,l]=o.useState(n??[]),[x,d]=o.useState(null),f=o.useRef(null),b=o.useRef(null),u=o.useRef(r),m=o.useRef(a);o.useEffect(()=>{u.current=r},[r]),o.useEffect(()=>{m.current=a},[a]),o.useEffect(()=>{s&&s!==c&&i(s)},[s,c]),o.useEffect(()=>{l(k=>{const j=to(k,t);return j.length===k.length&&j.every((_,R)=>_===k[R])?k:j})},[t]);const v=o.useMemo(()=>{const k=x??h;if(k.length===0)return t;const j=new Map(k.map((_,R)=>[_,R]));return[...t].sort((_,R)=>{const D=j.get(_.tabKey)??999,M=j.get(R.tabKey)??999;return D-M})},[t,x,h]);o.useEffect(()=>{var j,_;if(v.length===0){c!==null&&(i(null),(j=u.current)==null||j.call(u,null));return}if(c&&v.some(R=>R.tabKey===c))return;const k=v[0].tabKey;k!==c&&(i(k),(_=u.current)==null||_.call(u,k))},[v,c]);const N=o.useMemo(()=>v.find(k=>k.tabKey===c),[v,c]),g=o.useCallback(k=>{var j;i(k),(j=u.current)==null||j.call(u,k)},[]),p=o.useCallback((k,j,_)=>{l(R=>{var $;const D=R.filter(O=>O!==k),M=D.indexOf(j);if(M<0)return R;const E=_==="left"?M:M+1;return D.splice(E,0,k),($=m.current)==null||$.call(m,D),D}),d(null)},[]),w=o.useCallback((k,j,_)=>{const D=(h.length>0?h:t.map($=>$.tabKey)).filter($=>$!==k),M=D.indexOf(j);if(M<0)return;const E=_==="left"?M:M+1;D.splice(E,0,k),f.current=D,d(D)},[h,t]),T=o.useCallback(()=>{var j;const k=f.current;k&&(l(k),(j=m.current)==null||j.call(m,k))},[]),y=o.useCallback(()=>{f.current=null,d(null)},[]),S=o.useCallback(k=>{l(j=>{var R;const _=j.filter(D=>D!==k);return _.push(k),(R=m.current)==null||R.call(m,_),_})},[]);return{activeTabId:c,activeConv:N,sortedConversations:v,previewOrderRef:f,draggingTabRef:b,selectTab:g,handleTabReorder:p,updatePreviewOrder:w,commitPreviewOrder:T,clearPreviewOrder:y,moveTabToEnd:S,setDraggingTabKey:k=>{b.current=k}}}function no({dropAction:t,canSplit:s}){return e.jsxs("div",{className:"absolute inset-0 z-10 pointer-events-none hidden md:flex",children:[e.jsx("div",{className:"flex-1 border-r border-white/10 transition-all duration-150 flex items-center justify-center",style:{background:t==="split-left"?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.04)",boxShadow:t==="split-left"?"inset 0 0 0 2px var(--accent-primary)":"inset 0 0 0 1px rgba(255,255,255,0.05)",opacity:s?1:.45},children:e.jsx("div",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold text-white bg-black/45 backdrop-blur-sm",children:"Split Left"})}),e.jsx("div",{className:"flex-1 border-r border-white/10 transition-all duration-150 flex items-center justify-center",style:{background:t==="merge"?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.04)",boxShadow:t==="merge"?"inset 0 0 0 2px var(--accent-primary)":"inset 0 0 0 1px rgba(255,255,255,0.05)"},children:e.jsx("div",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold text-white bg-black/45 backdrop-blur-sm",children:"Move Here"})}),e.jsx("div",{className:"flex-1 transition-all duration-150 flex items-center justify-center",style:{background:t==="split-right"?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.04)",boxShadow:t==="split-right"?"inset 0 0 0 2px var(--accent-primary)":"inset 0 0 0 1px rgba(255,255,255,0.05)",opacity:s?1:.45},children:e.jsx("div",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold text-white bg-black/45 backdrop-blur-sm",children:"Split Right"})})]})}const fn="adhdev-tab-shortcuts";function ro(){try{return JSON.parse(localStorage.getItem(fn)||"{}")}catch{return{}}}function ao({sortedTabKeys:t,onFocus:s,onSelectTab:n}){const r=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent),[a,c]=o.useState(()=>ro()),[i,h]=o.useState(null),l=o.useCallback(d=>{const f=[];return d.metaKey&&f.push(r?"⌘":"Meta"),d.ctrlKey&&f.push("Ctrl"),d.altKey&&f.push(r?"⌥":"Alt"),d.shiftKey&&f.push(r?"⇧":"Shift"),["Control","Alt","Shift","Meta"].includes(d.key)?null:(f.push(d.key.length===1?d.key.toUpperCase():d.key),f.join("+"))},[r]),x=o.useCallback(d=>{c(d);try{localStorage.setItem(fn,JSON.stringify(d))}catch{}},[]);return o.useEffect(()=>{if(!i)return;const d=f=>{if(f.preventDefault(),f.stopPropagation(),f.key==="Escape"){h(null);return}const b=l(f);if(!b)return;const u={...a};for(const[m,v]of Object.entries(u))v===b&&delete u[m];u[i]=b,x(u),h(null)};return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[i,a,x,l]),o.useEffect(()=>{const d=f=>{if(!(!f.ctrlKey&&!f.metaKey&&!f.altKey)){for(const[b,u]of Object.entries(a))if(t.includes(b)&&l(f)===u){f.preventDefault(),s(),n(b);return}}};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a,t,s,n,l]),{isMac:r,tabShortcuts:a,shortcutListening:i,setShortcutListening:h,saveShortcuts:x}}const oo=o.memo(function({conv:s,isActive:n,isDraggedTab:r,shortcut:a,conversationKeys:c,draggingTabRef:i,onFocus:h,onSelectTab:l,onConversationActivated:x,onPreviewReorder:d,onReorderTab:f,onCommitPreviewOrder:b,onClearPreviewOrder:u,onDragStateReset:m,onDragTabKeyChange:v,onReceiveTab:N,onOpenContextMenu:g,longPressTimer:p}){const w=s.status==="generating"?"agent-tab-generating":s.status==="waiting_approval"?"agent-tab-waiting":"",T=s.connectionState==="failed"||s.connectionState==="closed",y=o.useCallback(E=>{i.current=s.tabKey,v(s.tabKey),E.dataTransfer.setData("text/tab-key",s.tabKey),E.dataTransfer.effectAllowed="move"},[s.tabKey,i,v]),S=o.useCallback(()=>{i.current=null,v(null),b(),u(),m()},[i,v,b,u,m]),k=o.useCallback(E=>{const $=i.current;if(!(!$||$===s.tabKey)&&E.dataTransfer.types.includes("text/tab-key")){E.preventDefault(),E.stopPropagation();const O=E.currentTarget.getBoundingClientRect(),C=E.clientX<O.left+O.width/2?"left":"right";d($,s.tabKey,C)}},[s.tabKey,i,d]),j=o.useCallback(E=>{E.preventDefault(),E.stopPropagation();const $=E.dataTransfer.getData("text/tab-key");if($&&$!==s.tabKey){const O=E.currentTarget.getBoundingClientRect(),C=E.clientX<O.left+O.width/2?"left":"right";c.includes($)?f($,s.tabKey,C):N&&N($)}u()},[s.tabKey,c,f,N,u]),_=o.useCallback(E=>{E.stopPropagation(),h(),l(s.tabKey),x(s)},[s,x,h,l]),R=o.useCallback(E=>{E.preventDefault(),g(E.clientX,E.clientY,s.tabKey)},[s.tabKey,g]),D=o.useCallback(E=>{const $=E.touches[0];p.current=setTimeout(()=>{g($.clientX,$.clientY,s.tabKey)},600)},[s.tabKey,p,g]),M=o.useCallback(()=>{p.current&&clearTimeout(p.current)},[p]);return e.jsxs("div",{"data-tabkey":s.tabKey,className:`${w} shrink-0 px-2.5 py-1.5 rounded-t-lg cursor-pointer flex items-center gap-2 relative`,draggable:!0,onDragStart:y,onDragEnd:S,onDragOver:k,onDrop:j,onClick:_,onContextMenu:R,onTouchStart:D,onTouchEnd:M,onTouchMove:M,style:{background:n?"var(--bg-primary)":"var(--bg-glass)",borderTop:n?"1px solid var(--border-subtle)":"1px solid transparent",borderLeft:n?"1px solid var(--border-subtle)":"1px solid transparent",borderRight:n?"1px solid var(--border-subtle)":"1px solid transparent",opacity:r?.4:T?n?.6:.3:n?1:.65,transition:"transform 0.2s ease, opacity 0.15s ease"},children:[s.status==="generating"?e.jsx("div",{className:"tab-spinner"}):s.status==="waiting_approval"?e.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400",children:"▲"}):T?e.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400 animate-pulse",children:"○"}):s.connectionState==="connecting"||s.connectionState==="new"?e.jsx("div",{className:"tab-connecting-spinner"}):s.connectionState==="connected"?e.jsx("span",{className:"text-[8px] px-[5px] py-px text-green-400",children:"●"}):e.jsx("span",{className:"text-[8px] px-[5px] py-px text-text-muted animate-pulse",children:"○"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-bold whitespace-nowrap overflow-hidden text-ellipsis",style:{maxWidth:"10ch"},title:s.displayPrimary,children:s.displayPrimary}),e.jsx("div",{className:"text-[8px] opacity-50 flex gap-1 items-center",children:T?e.jsx("span",{className:"text-yellow-400 opacity-100",children:"Reconnecting…"}):s.connectionState==="connecting"||s.connectionState==="new"?e.jsxs("span",{className:"text-blue-400 opacity-100",children:["Connecting",e.jsx("span",{className:"connecting-dots"})]}):e.jsxs(e.Fragment,{children:[s.displaySecondary,s.machineName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-40",children:"·"}),e.jsxs("span",{className:"opacity-70",children:["🖥 ",s.machineName]})]})]})})]}),a&&e.jsx("span",{className:"text-[9px] opacity-50 font-mono ml-0.5 shrink-0 bg-bg-secondary px-1 rounded",title:`Ctrl+${a}`,children:a})]})},(t,s)=>t.conv===s.conv&&t.isActive===s.isActive&&t.isDraggedTab===s.isDraggedTab&&t.shortcut===s.shortcut&&t.conversationKeys===s.conversationKeys);function io({conversations:t,activeTabId:s,groupIndex:n,numGroups:r,draggingTabRef:a,onFocus:c,onSelectTab:i,onConversationActivated:h,onPreviewReorder:l,onReorderTab:x,onCommitPreviewOrder:d,onClearPreviewOrder:f,onDragStateReset:b,onDragTabKeyChange:u,onMoveTab:m,onReceiveTab:v,onHideTab:N}){const[g,p]=o.useState(null),w=o.useRef(null),T=o.useRef(null),y=o.useMemo(()=>t.map(M=>M.tabKey),[t]);lt("PaneGroupTabBar",{groupIndex:n,activeTabId:s,tabCount:t.length,ctxMenuTab:(g==null?void 0:g.tabKey)||null});const{isMac:S,tabShortcuts:k,shortcutListening:j,setShortcutListening:_,saveShortcuts:R}=ao({sortedTabKeys:t.map(M=>M.tabKey),onFocus:c,onSelectTab:i});o.useEffect(()=>{if(!g)return;const M=E=>{const $=document.querySelector("[data-pane-context-menu]");$&&$.contains(E.target)||p(null)};return window.addEventListener("mousedown",M,!0),()=>window.removeEventListener("mousedown",M,!0)},[g]),o.useEffect(()=>{const M=T.current;if(!M)return;const E=$=>{Math.abs($.deltaY)>Math.abs($.deltaX)&&($.preventDefault(),M.scrollLeft+=$.deltaY)};return M.addEventListener("wheel",E,{passive:!1}),()=>M.removeEventListener("wheel",E)},[]);const D=o.useCallback((M,E,$)=>{p({x:M,y:E,tabKey:$})},[]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center bg-bg-secondary border-b border-border-subtle shrink-0 gap-0",children:e.jsxs("div",{ref:T,className:"flex-1 flex overflow-x-auto overflow-y-visible pt-1.5 pb-0 gap-1 select-none",style:{paddingLeft:8,paddingRight:4,scrollbarWidth:"none"},children:[t.map(M=>e.jsx(oo,{conv:M,isActive:s===M.tabKey,isDraggedTab:a.current===M.tabKey,shortcut:k[M.tabKey],conversationKeys:y,draggingTabRef:a,onFocus:c,onSelectTab:i,onConversationActivated:h,onPreviewReorder:l,onReorderTab:x,onCommitPreviewOrder:d,onClearPreviewOrder:f,onDragStateReset:b,onDragTabKeyChange:u,onReceiveTab:v,onOpenContextMenu:D,longPressTimer:w},M.tabKey)),t.length===0&&e.jsx("div",{className:"p-2 text-xs opacity-40",children:"No tabs in this group"})]})}),g&&e.jsxs("div",{"data-pane-context-menu":!0,className:"fixed z-50 bg-bg-primary border border-border-subtle rounded-lg shadow-lg py-1 min-w-[160px]",style:{left:g.x,top:g.y},children:[m&&n>0&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{m(g.tabKey,"left"),p(null)},children:"← Move to Left Group"}),m&&n<r-1&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{m(g.tabKey,"right"),p(null)},children:"Move to Right Group →"}),m&&r<4&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{m(g.tabKey,"split-left"),p(null)},children:"⇤ Split Left"}),m&&r<4&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{m(g.tabKey,"split-right"),p(null)},children:"Split Right ⇥"}),e.jsx("div",{className:"border-t border-border-subtle my-1 "}),e.jsxs("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:M=>{M.stopPropagation(),_(g.tabKey),p(null)},children:["⌨ ",k[g.tabKey]?`Change shortcut (${k[g.tabKey]})`:"Set shortcut"]}),k[g.tabKey]&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted ",onClick:()=>{const M={...k};delete M[g.tabKey],R(M),p(null)},children:"✕ Remove shortcut"}),N&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-border-subtle my-1"}),e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted",onClick:()=>{N(g.tabKey),p(null)},children:"🚫 Hide from Dashboard"})]}),!m&&!N&&e.jsx("div",{className:"px-3 py-1.5 text-[11px] text-text-muted opacity-50 italic",children:"No actions available"})]}),j&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(2px)"},onClick:()=>_(null),children:e.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl px-8 py-6 text-center shadow-xl",onClick:M=>M.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-bold text-text-primary mb-2",children:"⌨ Set shortcut"}),e.jsxs("div",{className:"text-xs text-text-secondary mb-4",children:["Press a key combo (e.g. ",S?"⌘+1":"Ctrl+1",", ",S?"⌥+A":"Alt+A",")"]}),e.jsx("div",{className:"text-lg font-mono text-accent animate-pulse",children:"Listening..."}),e.jsx("div",{className:"text-[10px] text-text-muted mt-3",children:"Press Esc to cancel"})]})})]})}function co({conversations:t,ides:s,clearedTabs:n,actionLogs:r,screenshotMap:a,setScreenshotMap:c,sendDaemonCommand:i,setLocalUserMessages:h,setActionLogs:l,isStandalone:x,userName:d,groupIndex:f,onFocus:b,isSplitMode:u,numGroups:m,onMoveTab:v,onReceiveTab:N,style:g,detectedIdes:p,handleLaunchIde:w,onActiveTabChange:T,initialActiveTabId:y,initialTabOrder:S,onTabOrderChange:k,onHideTab:j}){const{sendCommand:_}=$e(),R=o.useRef(null),{activeTabId:D,activeConv:M,sortedConversations:E,draggingTabRef:$,selectTab:O,handleTabReorder:C,updatePreviewOrder:V,commitPreviewOrder:Z,clearPreviewOrder:J,moveTabToEnd:G,setDraggingTabKey:Q}=so({conversations:t,initialActiveTabId:y,initialTabOrder:S,onActiveTabChange:T,onTabOrderChange:k}),Y=Xt({sendDaemonCommand:i,activeConv:M,setLocalUserMessages:h,setActionLogs:l,isStandalone:x}),{dragOver:se,dropAction:ee,resetDragState:ce,handleDragEnter:B,handleDragOver:P,handleDragLeave:A,handleDrop:L}=eo({conversations:t,numGroups:m,onMoveTab:v,onReceiveTab:N,onOwnTabDrop:G,onClearPreviewOrder:J}),W=M&&je(M)&&!fe(M),U=o.useMemo(()=>M?s.find(re=>re.id===M.ideId):void 0,[s,M]),H=M?a[M.ideId]:void 0,ae=o.useCallback(()=>{if(!M||!(M.ideId in a))return;const re={...a};delete re[M.ideId],c(re)},[M,a,c]),de=o.useMemo(()=>M?r.filter(re=>re.ideId===M.tabKey):[],[r,M]);lt("PaneGroup",{groupIndex:f,conversationCount:t.length,activeTabId:D,dragOver:se});const oe=o.useCallback(re=>{re.streamSource==="agent-stream"&&re.agentType&&_(re.ideId,"focus_session",{agentType:re.agentType,...re.sessionId&&{targetSessionId:re.sessionId}}).catch(()=>{})},[_]);return e.jsxs("div",{className:"flex flex-col min-h-0 min-w-0 flex-1 overflow-hidden",onClick:b,style:{...g,outline:se?"2px dashed var(--accent-primary)":"none",outlineOffset:"-2px",transition:"outline 0.15s ease"},children:[e.jsx(io,{conversations:E,activeTabId:D,groupIndex:f,numGroups:m,draggingTabRef:$,onFocus:b,onSelectTab:O,onConversationActivated:oe,onPreviewReorder:V,onReorderTab:C,onCommitPreviewOrder:Z,onClearPreviewOrder:J,onDragStateReset:ce,onDragTabKeyChange:Q,onMoveTab:v,onReceiveTab:N,onHideTab:j}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden relative",onDragEnter:B,onDragOver:P,onDragLeave:A,onDrop:L,children:[se&&e.jsx(no,{dropAction:ee,canSplit:!!(m<4&&v)}),M?e.jsx(pn,{activeConv:M,clearToken:n[M.tabKey]||0,isCli:!!W,ideEntry:U,screenshotUrl:H,clearScreenshot:ae,terminalRef:R,handleModalButton:Y.handleModalButton,handleRelaunch:Y.handleRelaunch,handleSendChat:Y.handleSendChat,isSendingChat:Y.isSendingChat,handleFocusAgent:Y.handleFocusAgent,isFocusingAgent:Y.isFocusingAgent,actionLogs:de,userName:d}):e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:e.jsx(Gt,{conversationsCount:t.length,isSplitMode:u,isStandalone:x,detectedIdes:p,handleLaunchIde:w})})]})]})}function lo({containerRef:t,isSplitMode:s,numGroups:n,groupSizes:r,groupedConvs:a,clearedTabs:c,ides:i,actionLogs:h,screenshotMap:l,setScreenshotMap:x,sendDaemonCommand:d,setLocalUserMessages:f,setActionLogs:b,isStandalone:u,userName:m,setFocusedGroup:v,moveTabToGroup:N,splitTabRelative:g,closeGroup:p,handleResizeStart:w,detectedIdes:T,handleLaunchIde:y,groupActiveTabIds:S,setGroupActiveTabIds:k,groupTabOrders:j,setGroupTabOrders:_,toggleHiddenTab:R}){return e.jsx("div",{ref:t,className:`flex-1 min-h-0 flex ${s?"flex-row":"flex-col"} overflow-hidden`,children:a.map((D,M)=>{const E=s&&r.length===n?`${r[M]}%`:void 0;return e.jsxs(Rn.Fragment,{children:[s&&M>0&&e.jsx("div",{className:"shrink-0 w-1 cursor-col-resize hover:bg-accent/30 transition-colors relative group",style:{background:"var(--border-subtle)"},onMouseDown:$=>w(M-1,$),onDoubleClick:()=>p(M),title:"Drag to resize · Double-click to merge",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 group-hover:bg-accent/10"})}),e.jsx(co,{style:s?{flexBasis:E??`${100/n}%`,flexGrow:E?0:1,flexShrink:E?0:1}:void 0,conversations:D,clearedTabs:c,ides:i,actionLogs:h,screenshotMap:l,setScreenshotMap:x,sendDaemonCommand:d,setLocalUserMessages:f,setActionLogs:b,isStandalone:u,userName:m,groupIndex:M,onFocus:()=>v(M),isSplitMode:s,numGroups:n,onMoveTab:($,O)=>{O==="left"&&M>0?N($,M-1):O==="right"&&M<n-1?N($,M+1):O==="split-left"&&n<4?g($,M,"left"):O==="split-right"&&n<4&&g($,M,"right")},onReceiveTab:$=>N($,M),detectedIdes:M===0?T:void 0,handleLaunchIde:M===0?y:void 0,onActiveTabChange:$=>k(O=>(O[M]??null)===($??null)?O:{...O,[M]:$}),initialActiveTabId:S[M],initialTabOrder:j[M],onTabOrderChange:$=>_(O=>{const C=O[M]||[];return C.length===$.length&&C.every((V,Z)=>V===$[Z])?O:{...O,[M]:$}}),onHideTab:R})]},M)})})}function uo({daemons:t,targetVersion:s,upgradingDaemons:n,onUpgrade:r,onDismiss:a}){return t.length===0?null:e.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2 border-b text-xs text-text-secondary shrink-0 flex-wrap",style:{background:"color-mix(in srgb, var(--status-warning) 8%, transparent)",borderColor:"color-mix(in srgb, var(--status-warning) 20%, transparent)"},children:[e.jsx("span",{className:"text-sm shrink-0 mt-0.5",style:{color:"var(--status-warning)"},children:e.jsx(_s,{size:14})}),e.jsxs("span",{className:"flex-1 flex items-center gap-2 flex-wrap min-w-0",children:[e.jsxs("span",{children:["Update available",s?e.jsxs(e.Fragment,{children:[": ",e.jsxs("strong",{children:["v",s]})]}):null]}),t.map(c=>{const i=Xe(c,{fallbackId:c.id}),h=n[c.id],l=c.version||c.daemonVersion||"unknown";return e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md",style:{background:"color-mix(in srgb, var(--status-warning) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--status-warning) 15%, transparent)"},children:[e.jsx("span",{className:"font-medium text-text-primary",children:i}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",l]}),h==="upgrading"?e.jsx("span",{className:"text-[10px] animate-pulse",style:{color:"var(--status-warning)"},children:"upgrading…"}):h==="done"?e.jsx("span",{className:"text-[10px] text-green-400",children:"✓ restarting"}):h==="error"?e.jsx("button",{className:"text-[10px] text-red-400 hover:text-red-300 underline cursor-pointer",onClick:()=>r(c.id),children:"retry"}):e.jsx("button",{className:"text-[10px] font-semibold cursor-pointer px-1.5 py-px rounded transition-colors",style:{color:"var(--status-warning)",background:"color-mix(in srgb, var(--status-warning) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--status-warning) 20%, transparent)"},onClick:()=>r(c.id),children:"Upgrade"})]},c.id)})]}),e.jsx("button",{className:"text-text-muted hover:text-text-primary transition-colors text-sm px-1 shrink-0",onClick:a,title:"Dismiss",children:"✕"})]})}function ho({activeConv:t,onCancel:s,onStopNow:n,onSaveAndStop:r}){const a=t.agentName||t.ideType||"CLI";return e.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center",children:[e.jsx("div",{onClick:s,className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),e.jsxs("div",{role:"dialog","aria-modal":"true",className:"card fade-in relative w-[92%] max-w-[420px] flex flex-col overflow-hidden rounded-[18px] shadow-[0_20px_40px_rgba(0,0,0,0.4)]",children:[e.jsxs("div",{className:"px-6 py-5 border-b border-border-subtle bg-[var(--surface-primary)]",children:[e.jsxs("h3",{className:"m-0 text-lg font-extrabold",children:["Stop ",a,"?"]}),e.jsx("div",{className:"mt-1 text-sm text-text-muted",children:"The CLI runtime will stop. Choose whether to stop immediately or ask the provider to save and exit first."})]}),e.jsxs("div",{className:"px-6 py-5 bg-bg-primary flex flex-col gap-3",children:[e.jsx("button",{onClick:r,className:"btn btn-primary w-full justify-center",children:"Save and stop"}),e.jsx("button",{onClick:n,className:"btn btn-secondary w-full justify-center text-red-400 border-red-500/25 hover:bg-red-500/10",children:"Stop now"}),e.jsx("button",{onClick:s,className:"btn btn-secondary w-full justify-center",children:"Cancel"})]})]})]})}const $t=[{icon:"🦦",title:"Welcome to ADHDev",desc:"Monitor and control your AI coding agents from anywhere — web, mobile, or CLI.",visual:"🎉"},{icon:"💬",title:"Real-time chat",desc:"See what your AI agent is doing in real-time. Send messages, approve or reject actions — all from your browser or phone.",visual:"📱"},{icon:"🖥️",title:"Remote desktop",desc:"View and control your IDE screen via P2P connection. Click, type, scroll — just like being there.",visual:"🖱️"},{icon:"🚀",title:"Get started",desc:"Install the daemon and link it to your dashboard. It connects automatically.",code:"npm install -g @adhdev/daemon-standalone && adhdev-standalone"}];function xo({onClose:t}){const[s,n]=o.useState(0),r=$t[s],a=s===$t.length-1;return e.jsxs("div",{className:"onboarding-overlay",style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.65)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.3s ease-out"},onClick:c=>{c.target===c.currentTarget&&t()},children:[e.jsxs("div",{style:{background:"var(--bg-secondary, #1a1a2e)",border:"1px solid var(--border-subtle, #333)",borderRadius:"1.25rem",width:"min(440px, 92vw)",padding:"2.5rem 2rem 2rem",position:"relative",animation:"slideUp 0.3s ease-out"},children:[e.jsx("button",{onClick:t,style:{position:"absolute",top:12,right:16,background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"1.2rem",cursor:"pointer"},children:"✕"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:6,marginBottom:"1.5rem"},children:$t.map((c,i)=>e.jsx("div",{style:{width:i===s?24:8,height:8,borderRadius:4,background:i===s?"var(--accent, #7c3aed)":"var(--border-subtle, #444)",transition:"all 0.3s ease"}},i))}),e.jsx("div",{style:{textAlign:"center",fontSize:"3rem",marginBottom:"1rem"},children:r.visual||r.icon}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsxs("h2",{style:{fontSize:"1.35rem",fontWeight:700,color:"var(--text-primary)",marginBottom:"0.75rem",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[e.jsx("span",{children:r.icon})," ",r.title]}),e.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"1.25rem"},children:r.desc}),r.code&&e.jsxs("div",{style:{background:"var(--bg-primary, #111)",border:"1px solid var(--border-subtle, #333)",borderRadius:"0.5rem",padding:"0.75rem 1rem",fontFamily:"monospace",fontSize:"0.8rem",color:"var(--accent, #a78bfa)",textAlign:"left",overflowX:"auto",marginBottom:"0.5rem"},children:[e.jsx("span",{style:{color:"var(--text-muted)",marginRight:8},children:"$"}),r.code]}),a&&e.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.75rem",color:"var(--accent, #a78bfa)",textDecoration:"none"},children:"📚 Learn more in the docs →"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"1.5rem"},children:[e.jsx("button",{onClick:t,style:{background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"0.85rem",cursor:"pointer"},children:"Skip"}),e.jsx("button",{onClick:()=>a?t():n(c=>c+1),className:"transition-opacity hover:opacity-90",style:{background:"linear-gradient(135deg, #7c3aed, #6366f1)",color:"#fff",border:"none",borderRadius:"0.5rem",padding:"0.55rem 1.5rem",fontSize:"0.9rem",fontWeight:600,cursor:"pointer"},children:a?"Get Started →":"Next →"})]})]}),e.jsx("style",{children:`
|
|
54
54
|
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
|
|
55
55
|
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) } to { opacity: 1; transform: translateY(0) } }
|
|
56
56
|
`})]})}function po(){const{sendCommand:t}=$e(),[s,n]=ks(),r=s.get("activeTab"),a=Tt(),{updateIdeChats:c,screenshotMap:i,setScreenshotMap:h}=a,l=a.ides||[],[x,d]=o.useState(()=>{try{return!localStorage.getItem("adhdev_onboarding_v1")}catch{return!1}}),f=a.toasts||[],b=a.setToasts||(()=>{}),u=a.wsStatus||"connected",m=a.isConnected??!0,v=a.connectionStates||{},N=a.showReconnected||!1,{groupAssignments:g,setGroupAssignments:p,focusedGroup:w,setFocusedGroup:T,groupActiveTabIds:y,setGroupActiveTabIds:S,groupTabOrders:k,setGroupTabOrders:j,groupSizes:_,setGroupSizes:R,isMobile:D,hasHydratedStoredLayout:M,hydrateStoredLayout:E}=Pa(),[$,O]=o.useState(!1),[C,V]=o.useState(!1),[Z,J]=o.useState([]),[G,Q]=o.useState({}),[Y,se]=o.useState({}),[ee,ce]=o.useState(null);lt("Dashboard",{ideCount:l.length,toastCount:f.length,focusedGroup:w,groupCount:Object.keys(g).length,localMessageTabs:Object.keys(G).length,actionLogCount:Z.length});const B=l.find(pe=>pe.type==="adhdev-daemon"),P=(B==null?void 0:B.detectedIdes)||[],A=!!B,{hiddenTabs:L,toggleTab:W}=on(),{chatIdes:U,conversations:H,visibleConversations:ae,visibleTabKeys:de,resolveConversationByTarget:oe}=Ca({ides:l,connectionStates:v,localUserMessages:G,clearedTabs:Y,hiddenTabs:L}),{containerRef:re,normalizedGroupAssignments:K,numGroups:X,isSplitMode:F,groupedConvs:I,moveTabToGroup:q,closeGroup:z,handleResizeStart:ne,splitTabRelative:ue}=Fa({groupAssignments:g,setGroupAssignments:p,setFocusedGroup:T,setGroupActiveTabIds:S,setGroupTabOrders:j,groupSizes:_,setGroupSizes:R,isMobile:D,visibleConversations:ae,visibleTabKeys:de}),te=o.useMemo(()=>{var ye,Ue;if(!D){if(ee){const De=H.find(At=>At.tabKey===ee);if(De)return De}return ae[0]}const pe=y[w];if(pe){const De=H.find(At=>At.tabKey===pe);if(De)return De}return((ye=I[w])==null?void 0:ye[0])||((Ue=I[0])==null?void 0:Ue[0])},[ee,D,y,w,H,I,ae]),ie=o.useMemo(()=>{var pe;return D||!r?null:((pe=oe(r))==null?void 0:pe.tabKey)??null},[D,oe,r]);cn({visibleConversations:ae,clearedTabs:Y,setClearedTabs:se,setActionLogs:J}),ln({ides:l,sendDaemonCommand:t,setToasts:b,setLocalUserMessages:Q,resolveConversationByTarget:oe});const{isCreatingChat:Te,isRefreshingHistory:we,handleLaunchIde:ke,handleSwitchSession:Je,handleNewChat:Ze,handleRefreshHistory:dt}=Ba({sendDaemonCommand:t,activeConv:te,updateIdeChats:c,setToasts:b,setLocalUserMessages:Q,setClearedTabs:se});Da({urlActiveTab:D?r:null,conversations:H,resolveConversationByTarget:oe,normalizedGroupAssignments:K,hasHydratedStoredLayout:D?M:!0,hydrateStoredLayout:D?E:()=>{},setGroupActiveTabIds:S,setFocusedGroup:T,setSearchParams:n,historyModalOpen:$,activeConv:te,isRefreshingHistory:we,ides:l,handleRefreshHistory:dt});const He=o.useCallback(async pe=>{if(!te||!je(te)||fe(te))return;const ye=te.ideType||te.agentType||"",Ue=te.ideId||te.daemonId||"";try{await t(Ue,"stop_cli",{cliType:ye,targetSessionId:te.sessionId,mode:pe})}catch(De){console.error("Stop CLI failed:",De)}},[te,t]),ut=o.useCallback(async()=>{var ye;if(!te||!je(te)||fe(te))return;if((ye=te.resume)!=null&&ye.supported){V(!0);return}const pe=te.ideType||te.agentType||"CLI";window.confirm(`Stop ${pe}?
|
|
@@ -65,4 +65,4 @@ This will disconnect CDP and optionally kill the process.`))try{const L=await n(
|
|
|
65
65
|
from { opacity: 0; transform: translateX(40px); }
|
|
66
66
|
to { opacity: 1; transform: translateX(0); }
|
|
67
67
|
}
|
|
68
|
-
`})]})}function $o(){const[t,s]=o.useState({ide:[],cli:[],ext:[],acp:[]}),[n,r]=o.useState(!0);o.useEffect(()=>{fetch("https://raw.githubusercontent.com/vilmire/adhdev-providers/main/registry.json").then(i=>i.json()).then(i=>{const h=[],l=[],x=[],d=[];Object.values(i.providers||{}).forEach(b=>{const u={name:b.name||"Unknown",status:b.status||"Stable",details:b.details||"Community Provider"};b.category==="ide"?h.push(u):b.category==="cli"?l.push(u):b.category==="extension"?x.push(u):b.category==="acp"&&d.push(u)});const f=(b,u)=>{const m={Stable:1,Beta:2,WIP:3},v=m[b.status]||99,N=m[u.status]||99;return v!==N?v-N:b.name.localeCompare(u.name)};s({ide:h.sort(f),cli:l.sort(f),ext:x.sort(f),acp:d.sort(f)})}).catch(i=>console.error("Failed to load capabilities:",i)).finally(()=>r(!1))},[]);const a=i=>i==="Stable"?e.jsxs("div",{className:"flex items-center gap-1.5 text-success",children:[e.jsx(Rs,{className:"w-4 h-4"})," ",e.jsx("span",{children:"Stable"})]}):i==="Beta"?e.jsxs("div",{className:"flex items-center gap-1.5 text-warning",children:[e.jsx(Ut,{className:"w-4 h-4"})," ",e.jsx("span",{children:"Beta"})]}):e.jsxs("div",{className:"flex items-center gap-1.5 text-text-muted",children:[e.jsx(Ps,{className:"w-4 h-4"})," ",e.jsx("span",{children:i})]}),c=i=>e.jsx("div",{className:"bg-bg-card border border-border-subtle rounded-xl overflow-hidden",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-bg-secondary border-b border-border-subtle text-xs uppercase text-text-muted font-medium tracking-wider",children:[e.jsx("th",{className:"py-3 px-4 w-1/3",children:"Target"}),e.jsx("th",{className:"py-3 px-4 w-1/4",children:"Status"}),e.jsx("th",{className:"py-3 px-4",children:"Details"})]})}),e.jsx("tbody",{className:"divide-y divide-border-subtle text-sm",children:i.map((h,l)=>e.jsxs("tr",{className:"hover:bg-bg-subtle/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4 font-medium text-text-main",children:h.name}),e.jsx("td",{className:"py-3 px-4",children:a(h.status)}),e.jsx("td",{className:"py-3 px-4 text-text-muted",children:h.details})]},l))})]})});return n?e.jsx(St,{title:"Capabilities",subtitle:"Provider registry coverage for IDEs, CLI agents, extensions, and ACPs",icon:e.jsx(Nt,{}),widthClassName:"max-w-5xl",children:e.jsx(qt,{icon:e.jsx("div",{className:"w-8 h-8 border-4 border-accent border-t-transparent rounded-full animate-spin mx-auto"}),title:"Loading provider registry",description:"Fetching the latest support matrix from the shared provider registry."})}):e.jsxs(St,{title:"Capabilities",subtitle:"Provider registry coverage for IDEs, CLI agents, extensions, and ACPs",icon:e.jsx(Nt,{}),widthClassName:"max-w-5xl",contentClassName:"animate-fade-in",children:[e.jsx(be,{title:"Registry overview",description:"Support status is loaded from the shared provider registry used across OSS and cloud surfaces.",children:e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"IDEs"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.ide.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"CLI"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.cli.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"Extensions"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.ext.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"ACP"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.acp.length})]})]})}),e.jsx(be,{title:"IDE support",icon:e.jsx(_e,{className:"w-4 h-4"}),description:"Desktop editors and IDE surfaces with registry-backed providers.",children:c(t.ide)}),e.jsx(be,{title:"Standalone CLI agents",icon:e.jsx(Vt,{className:"w-4 h-4"}),description:"CLI-first agents that can participate in the standalone dashboard.",children:c(t.cli)}),e.jsx(be,{title:"AI extensions",icon:e.jsx(Ge,{className:"w-4 h-4"}),description:"IDE extensions and companion integrations available in the registry.",children:c(t.ext)}),e.jsx(be,{title:`ACP agents (${t.acp.length} loaded)`,icon:e.jsx(Ge,{className:"w-4 h-4"}),description:"ACP-backed providers discovered through the same shared registry.",children:c(t.acp)})]})}class Po{constructor(){xe(this,"adapters",new Map);xe(this,"states",new Map);xe(this,"ptyCallbacks",new Set);xe(this,"runtimeListeners",new Map);xe(this,"screenshotCallbacks",new Map);xe(this,"statusCallbacks",new Set)}resolveDaemonId(s){if(this.adapters.has(s))return s;if(s.startsWith("standalone")){for(const n of this.adapters.keys())if(n.startsWith("standalone"))return n}return null}register(s,n){this.adapters.set(s,n),this.states.set(s,n.connectionState)}unregister(s){this.adapters.delete(s),this.states.delete(s)}setState(s,n){this.states.set(s,n)}retryConnection(s){}get(s){const n=this.resolveDaemonId(s);return n?this.adapters.get(n):void 0}getState(s){const n=this.resolveDaemonId(s);return n&&this.states.get(n)||"disconnected"}sendData(s,n){return!1}sendPtyInput(s,n,r){return!1}sendPtyResize(s,n,r,a){return!1}onScreenshot(s,n){return this.screenshotCallbacks.set(s,n),()=>{this.screenshotCallbacks.delete(s)}}emitScreenshot(s,n){this.screenshotCallbacks.forEach(r=>r(s,n))}onStatus(s){return this.statusCallbacks.add(s),()=>{this.statusCallbacks.delete(s)}}emitStatus(s,n){this.statusCallbacks.forEach(r=>r(s,n))}onPtyOutput(s){return this.ptyCallbacks.add(s),()=>{this.ptyCallbacks.delete(s)}}emitPtyOutput(s,n,r){r!=null&&r.scrollback?this.emitRuntimeEvent(s,{type:"runtime_snapshot",sessionId:s,seq:0,text:typeof n=="string"?n:"",truncated:!1}):typeof n=="string"&&n&&this.emitRuntimeEvent(s,{type:"session_output",sessionId:s,data:n}),this.ptyCallbacks.forEach(a=>a(s,n,r))}emitRuntimeSnapshot(s,n,r=0,a=!1){this.emitRuntimeEvent(s,{type:"runtime_snapshot",sessionId:s,seq:r,text:n,truncated:a})}onRuntimeEvent(s,n){const r=this.runtimeListeners.get(s)||new Set;return r.add(n),this.runtimeListeners.set(s,r),()=>{const a=this.runtimeListeners.get(s);a&&(a.delete(n),a.size===0&&this.runtimeListeners.delete(s))}}async requestRuntimeSnapshot(s,n){if(!n)return;const r=await fetch(`/api/v1/runtime/${encodeURIComponent(n)}/snapshot`);if(!r.ok)return;const a=await r.json();this.emitRuntimeEvent(n,{type:"runtime_snapshot",sessionId:n,seq:typeof a.seq=="number"?a.seq:0,text:typeof a.text=="string"?a.text:"",truncated:!!a.truncated})}emitRuntimeEvent(s,n){var r;(r=this.runtimeListeners.get(s))==null||r.forEach(a=>a(n))}}const Ae=new Po;function Do(){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 bs=Do(),ys=3e3,Bo=3e4;let Re=null,Wo=0;const Mt=new Map;let We=null,ot=null;function Oo(t){return t==="connected"?"connected":t}async function kt(t,s,n){const r=Kr(t,n||{}),a=Re;if(a&&a.readyState===WebSocket.OPEN){const i=`req_${++Wo}_${Date.now()}`;return new Promise((h,l)=>{const x=setTimeout(()=>{Mt.delete(i),l(new Error(`WS command timeout: ${s}`))},3e4);Mt.set(i,{resolve:d=>{clearTimeout(x),h(d)},reject:d=>{clearTimeout(x),l(d)}}),a.send(JSON.stringify({type:"command",requestId:i,data:{type:s,payload:r.payload}}))})}const c=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:s,payload:r.payload})});if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}class Ko{constructor(s){xe(this,"daemonId");xe(this,"screenshotIdeType",null);this.daemonId=s}get hasCommandChannel(){return(Re==null?void 0:Re.readyState)===WebSocket.OPEN}get connectionState(){return(Re==null?void 0:Re.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(s,n){return kt(this.daemonId,s,n)}async sendInput(s,n){return kt(this.daemonId,"cdp_remote_action",{action:s,params:n,...this.screenshotIdeType&&{targetSessionId:this.screenshotIdeType}})}startScreenshots(s){this.screenshotIdeType=s||null,We&&(clearInterval(We),We=null);const n=async()=>{if(this.hasCommandChannel)try{const r=await kt(this.daemonId,"screenshot",{width:1280,...this.screenshotIdeType&&{targetSessionId:this.screenshotIdeType}});if(r!=null&&r.success&&(r!=null&&r.base64)){const a=await fetch(`data:image/jpeg;base64,${r.base64}`).then(c=>c.blob());Ae.emitScreenshot(this.daemonId,a)}}catch{}};n(),We=setInterval(n,2e3)}stopScreenshots(s){We&&(clearInterval(We),We=null)}}let Ce=null;function zo(t){return(!Ce||Ce.daemonId!==t)&&(Ce=new Ko(t)),Ce}function Fo({children:t}){const s=o.useRef(Qt()),n=Qt();s.current=n;const{setUserName:r}=it(),a=o.useRef(r);a.current=r;const[,c]=o.useState("disconnected"),i=o.useCallback((b,u)=>{c(b),ot==null||ot(b,u)},[]),h=o.useRef(null),l=o.useRef(),x=o.useRef(ys),d=o.useRef(!0),f=o.useRef(!1);return o.useEffect(()=>{d.current=!0,f.current=!1;function b(){var v,N;if(!d.current||((v=h.current)==null?void 0:v.readyState)===WebSocket.OPEN||((N=h.current)==null?void 0:N.readyState)===WebSocket.CONNECTING)return;i("connecting"),console.log(`[Standalone WS] Connecting to ${bs}...`);let m;try{m=new WebSocket(bs)}catch(g){console.error("[Standalone WS] Failed to create WebSocket:",g),u();return}h.current=m,m.onopen=()=>{if(!d.current){m.close();return}i("connected"),x.current=ys,console.log("[Standalone WS] Connected")},Re=m,m.onmessage=g=>{var p;try{const w=JSON.parse(g.data);if((w.type==="command_result"||w.type==="error")&&w.requestId){const T=Mt.get(w.requestId);T&&(Mt.delete(w.requestId),w.type==="error"?T.reject(new Error(((p=w.data)==null?void 0:p.message)||"Command failed")):T.resolve(w.data));return}if(w.type==="pty_output"){Ae.emitPtyOutput(w.cliId,w.data);return}if(w.type==="runtime_snapshot"){Ae.emitRuntimeSnapshot(w.sessionId,typeof w.text=="string"?w.text:"",typeof w.seq=="number"?w.seq:0,!!w.truncated);return}if(w.type==="status"||w.type==="initial_state"){const T=w.data;if(!T)return;const{injectEntries:y,markLoaded:S}=s.current,k=T.id||"standalone",j=zo(k);Ae.register(k,j),Ae.setState(k,"connected"),i("connected",k),Ae.emitStatus(k,T);const _=Or(T,{daemonId:k});_.length>0&&y(_),S(),T.userName&&a.current&&a.current(T.userName)}}catch(w){console.error("[Standalone WS] Parse error:",w)}},m.onclose=()=>{d.current&&(Ce==null||Ce.stopScreenshots(),Ce&&Ae.setState(Ce.daemonId,"disconnected"),i("disconnected"),h.current=null,u())},m.onerror=g=>{f.current||!d.current||console.warn("[Standalone WS] Error, will reconnect:",g)}}function u(){if(!d.current)return;clearTimeout(l.current);const m=x.current;console.log(`[Standalone WS] Reconnecting in ${m}ms...`),l.current=setTimeout(()=>{x.current=Math.min(x.current*1.5,Bo),b()},m)}return b(),()=>{d.current=!1,f.current=!0,clearTimeout(l.current),h.current&&(h.current.onerror=null,h.current.onclose=null,h.current.close(),h.current=null,Re=null),Ce&&(Ce.stopScreenshots(),Ae.unregister(Ce.daemonId))}},[]),e.jsx(e.Fragment,{children:t})}function Ho({children:t}){const[s,n]=o.useState("disconnected"),[r,a]=o.useState(null);o.useEffect(()=>(ot=(i,h)=>{n(i),h&&a(h)},()=>{ot=null}),[]);const c=o.useMemo(()=>{const i=s==="connected",h=Oo(s),l={};return r&&(l[r]=h),l.standalone=h,{wsStatus:s,isConnected:i,connectionStates:l}},[s,r]);return e.jsx(On,{connectionOverrides:c,children:e.jsx(Fo,{children:t})})}const Uo=[{id:"dashboard",path:"/dashboard",icon:e.jsx(Ts,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:e.jsx(Es,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:e.jsx(Ht,{}),label:"Settings"}];function Vo({children:t}){const s=ct(),n=Ln(),[r,a]=o.useState(!1),[c,i]=o.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),h=d=>{s(d),a(!1)},l=()=>{i(d=>{const f=!d;try{localStorage.setItem("sidebar-collapsed",f?"1":"0")}catch{}return f})},x=d=>`nav-item${n.pathname.startsWith(d)?" active":""} cursor-pointer ${c?"justify-center py-2.5 px-0":""}`;return e.jsxs("div",{className:`app-layout${r?" mobile-menu-open":""}${c?" sidebar-collapsed":""}`,children:[e.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>a(!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:()=>a(!1),onKeyDown:d=>d.key==="Escape"&&a(!1)}),e.jsxs("aside",{className:`sidebar ${r?"sidebar-open":""}`,children:[e.jsxs("div",{className:"sidebar-header",children:[e.jsxs("div",{className:`sidebar-logo ${c?"justify-center gap-0":""}`,children:[e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-7 h-7"}),!c&&e.jsx("span",{children:"ADHDev"})]}),e.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>a(!1),children:"✕"})]}),e.jsx("nav",{className:"sidebar-nav",children:Uo.map(d=>e.jsxs("div",{className:x(d.path),id:`nav-${d.id}`,onClick:()=>h(d.path),title:c?d.label:void 0,children:[e.jsx("span",{className:"nav-icon",children:d.icon}),!c&&d.label]},d.id))}),e.jsxs("div",{className:"border-t border-border-subtle pt-4 mt-2",children:[e.jsxs("div",{className:`nav-item cursor-pointer ${c?"justify-center py-2.5 px-0":""}`,id:"nav-docs",onClick:()=>window.open("https://docs.adhf.dev","_blank"),title:c?"Docs":void 0,children:[e.jsx("span",{className:"nav-icon",children:e.jsx(Nt,{})}),!c&&e.jsxs(e.Fragment,{children:["Docs",e.jsx("span",{className:"ml-auto text-[9px] text-text-muted",children:"↗"})]})]}),e.jsxs("div",{className:`nav-item cursor-pointer${n.pathname==="/about"?" active":""} ${c?"justify-center py-2.5 px-0":""}`,id:"nav-about",onClick:()=>s("/about"),title:c?"About":void 0,children:[e.jsx("span",{className:"nav-icon",children:e.jsx(As,{})}),!c&&"About"]}),!c&&e.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.7.33"]}),e.jsxs("div",{className:`nav-item cursor-pointer ${c?"justify-center py-2.5 px-0":"mt-1"}`,onClick:l,title:c?"Expand sidebar":"Collapse sidebar",children:[e.jsx("span",{className:"nav-icon text-base",children:c?"›":"‹"}),!c&&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 qo=[{icon:e.jsx(Es,{size:16}),title:"Local-first runtime",desc:"Everything stays on your machine and the browser only connects over localhost."},{icon:e.jsx(Ye,{size:16}),title:"Agent chat relay",desc:"Read and respond to AI conversations in real time across connected IDEs."},{icon:e.jsx($s,{size:16}),title:"Live screenshots",desc:"View your IDE directly in the browser through the local screenshot stream."},{icon:e.jsx(_e,{size:16}),title:"Remote control",desc:"Click, type, and steer your IDE sessions without switching windows."},{icon:e.jsx(Ge,{size:16}),title:"Multi-IDE support",desc:"Monitor VS Code, Cursor, Windsurf, and extension-based agents in one place."},{icon:e.jsx(Nt,{size:16}),title:"CLI and ACP coverage",desc:"Track standalone CLI agents and ACP-backed workflows alongside IDE sessions."}],Yo=[{icon:e.jsx(Ds,{size:16}),title:"Access from anywhere",desc:"Reach your burrows from another laptop or phone without opening local ports."},{icon:e.jsx(Ts,{size:16}),title:"Low-latency P2P stream",desc:"Cloud adds the WebRTC path for faster screenshots and remote control."},{icon:e.jsx(Ws,{size:16}),title:"Mobile notifications",desc:"Get approval prompts and activity updates when you are away from your desk."},{icon:e.jsx(Yn,{size:16}),title:"REST API access",desc:"Integrate with Slack, CI, or internal tools using API keys and service routes."},{icon:e.jsx(Vn,{size:16}),title:"Team workspace",desc:"Share burrows, activity views, and policies across a team workspace."},{icon:e.jsx(Rs,{size:16}),title:"Enterprise controls",desc:"SSO, RBAC, audit logs, and managed policy features for production teams."}],Go=[{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 and CLI agents",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 and 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}];function Xo(){return e.jsxs(St,{icon:e.jsx(As,{className:"text-text-primary"}),title:"About",subtitle:"Self-hosted ADHDev overview, supported surfaces, and what changes in Cloud",widthClassName:"max-w-5xl",actions:e.jsxs("div",{className:"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.7.33"]}),children:[e.jsx(be,{children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("div",{className:"text-[11px] font-semibold tracking-[0.18em] uppercase text-emerald-400 mb-2",children:"Self-hosted edition"}),e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-text-primary mb-2",children:"Keep the same dashboard experience, with the runtime fully on-device."}),e.jsx("p",{className:"text-sm text-text-muted leading-relaxed",children:"Standalone keeps the browser, daemon, screenshots, and control path on your own machine. It is the same core product shape as cloud, just without the remote networking and team layers."})]}),e.jsxs("div",{className:"grid gap-2 min-w-[220px]",children:[e.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex justify-center no-underline",children:"Docs ↗"}),e.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex justify-center no-underline",children:"GitHub ↗"}),e.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex justify-center no-underline",children:"Try Cloud ↗"})]})]})}),e.jsx(be,{title:"Included in standalone",description:"The local-first feature set available without the cloud control plane.",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:qo.map(t=>e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-4 transition-colors hover:border-border-default",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-text-primary mb-2",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-accent/10 text-accent-light",children:t.icon}),t.title]}),e.jsx("p",{className:"text-[13px] leading-relaxed text-text-muted",children:t.desc})]},t.title))})}),e.jsx(be,{title:"Compatible with",description:"Supported editors and agent surfaces exposed in the standalone dashboard.",children:e.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:[{label:"IDEs",items:Zs.map(t=>`${t.icon} ${t.name}`)},{label:"Extensions",items:en.map(t=>`${t.icon} ${t.name}`)},{label:"CLI agents",items:Qs.map(t=>`${t.icon} ${t.name}`)}].map(t=>e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-4",children:[e.jsx("div",{className:"text-[10px] font-bold tracking-wider text-text-muted mb-3 uppercase",children:t.label}),e.jsx("div",{className:"flex flex-col gap-1.5",children:t.items.map(s=>e.jsx("div",{className:"rounded-md border border-border-subtle bg-bg-card px-2.5 py-1.5 text-[12px] text-text-secondary",children:s},s))})]},t.label))})}),e.jsx(be,{title:"Cloud-only extras",description:"Capabilities that need the hosted control plane or team infrastructure.",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Yo.map(t=>e.jsxs("div",{className:"rounded-xl border border-violet-500/20 bg-violet-500/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-text-primary mb-2",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-violet-500/10 text-violet-400",children:t.icon}),t.title]}),e.jsx("p",{className:"text-[13px] leading-relaxed text-text-muted",children:t.desc})]},t.title))})}),e.jsx(be,{title:"Self-hosted vs Cloud",description:"The product split at a glance.",children:e.jsx("div",{className:"overflow-x-auto rounded-xl border border-border-subtle",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-3 font-semibold text-text-muted text-[11px] uppercase tracking-wider",children:"Feature"}),e.jsx("th",{className:"text-center px-4 py-3 font-semibold text-text-muted text-[11px] uppercase tracking-wider w-[110px]",children:"Selfhost"}),e.jsx("th",{className:"text-center px-4 py-3 font-semibold text-violet-400 text-[11px] uppercase tracking-wider w-[110px]",children:"Cloud"})]})}),e.jsx("tbody",{children:Go.map((t,s)=>e.jsxs("tr",{className:s%2===0?"bg-bg-glass":"bg-transparent",children:[e.jsx("td",{className:"px-4 py-2.5 text-text-secondary",children:t.feature}),e.jsx("td",{className:"px-4 py-2.5 text-center",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:"px-4 py-2.5 text-center",children:e.jsx("span",{className:"text-emerald-500",children:"✓"})})]},t.feature))})]})})}),e.jsx(qt,{icon:e.jsx("img",{src:"/otter-logo.png",alt:"",className:"mx-auto h-12 w-12 opacity-80"}),title:"Cloud is optional, not required",description:"You can stay fully local in standalone, and move to cloud later without changing how you use the dashboard.",action:e.jsxs("div",{className:"flex flex-wrap justify-center gap-3",children:[e.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm no-underline",children:"Compare Cloud ↗"}),e.jsxs("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm no-underline",children:[e.jsx(nr,{size:14,className:"mr-1"}),"Discord ↗"]})]})})]})}function Jo(){const{ides:t}=it(),s=t.find(f=>f.type==="adhdev-daemon"),n=(s==null?void 0:s.detectedIdes)||[],{sendCommand:r}=$e(),{userName:a}=it(),[c,i]=o.useState(a||"");o.useEffect(()=>{a!==void 0&&i(a)},[a]);const h=f=>{const b=f.target.value.trim();s!=null&&s.id&&b!==a&&r(s.id,"set_user_name",{userName:b}).catch(console.error)},[l,x]=o.useState(()=>{try{return localStorage.getItem("adhdev_sound")!=="0"}catch{return!0}}),d=f=>{x(f);try{localStorage.setItem("adhdev_sound",f?"1":"0")}catch{}};return e.jsxs(St,{icon:e.jsx(Ht,{className:"text-text-primary"}),title:"Settings",subtitle:"Local daemon configuration, appearance, and on-device preferences",widthClassName:"max-w-5xl",children:[e.jsx(sa,{variant:"info",children:"Standalone settings stay on this machine. The browser only talks to your local daemon over localhost."}),e.jsx(be,{title:"Daemon",description:"Connection health and local endpoints for the self-hosted runtime.",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.7.33"]}),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(be,{title:"Detected IDEs",description:"Editors discovered by the local daemon on this machine.",children:n.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:n.map(f=>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 ${f.running?"bg-green-400":"bg-text-muted/30"}`}),e.jsx("span",{className:"text-sm font-medium",children:f.name})]}),e.jsx("span",{className:"text-[11px] text-text-muted font-mono",children:f.type})]},f.type))})}),e.jsx(be,{title:"Machine",description:"The local burrow exposed by your standalone daemon.",children:e.jsx(da,{ides:t,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),e.jsx(be,{title:"Appearance",description:"Match the rest of the dashboard with a single place for mode and theme.",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:"Mode"}),e.jsx(pa,{})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[e.jsx("div",{className:"text-xs text-text-muted mb-1 font-medium",children:"Theme"}),e.jsx("p",{className:"text-[11px] text-text-muted mb-3",children:"Choose a preset or create a custom surface, accent, and chat palette for the standalone UI."}),e.jsx(ja,{})]})]})}),e.jsx(be,{title:"Notifications",description:"Browser prompts and local sound cues for agent activity.",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(la,{}),e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(sr,{size:15})," Sound Effects"]}),description:"Play a sound when agent completes or needs approval",checked:l,onChange:d})]})}),e.jsx(be,{title:"Profile",description:"How your name appears in local chat threads and dashboard views.",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.jsxs("span",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(qn,{size:16,className:"text-text-secondary"})," 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:c,onChange:f=>i(f.target.value),onBlur:h,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()}})]})})})]})}ia();ba();const Zo=Is({baseUrl:""});function js(){const{ides:t}=it(),s=t.find(n=>{var r;return n.daemonMode||((r=n.id)==null?void 0:r.startsWith("standalone"))});return s?e.jsx(bt,{to:`/machines/${s.id}`,replace:!0}):t.length>0?e.jsx(bt,{to:`/machines/${t[0].id}`,replace:!0}):e.jsx(bt,{to:"/dashboard",replace:!0})}function Qo(){return e.jsx(_n,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:e.jsx(Fn,{client:Zo,children:e.jsx(Ho,{children:e.jsx(Un,{value:{sendCommand:kt,sendData:()=>!1},children:e.jsx(Vo,{children:e.jsxs($n,{children:[e.jsx(Ee,{path:"/dashboard",element:e.jsx(po,{})}),e.jsx(Ee,{path:"/ide/:id",element:e.jsx(wo,{})}),e.jsx(Ee,{path:"/machine",element:e.jsx(js,{})}),e.jsx(Ee,{path:"/machines/:id",element:e.jsx(_o,{})}),e.jsx(Ee,{path:"/machines",element:e.jsx(js,{})}),e.jsx(Ee,{path:"/capabilities",element:e.jsx($o,{})}),e.jsx(Ee,{path:"/about",element:e.jsx(Xo,{})}),e.jsx(Ee,{path:"/settings",element:e.jsx(Jo,{})}),e.jsx(Ee,{path:"*",element:e.jsx(bt,{to:"/dashboard",replace:!0})})]})})})})})})}Rr({connectionManager:Ae});Pn(document.getElementById("root")).render(e.jsx(o.StrictMode,{children:e.jsx(Qo,{})}));
|
|
68
|
+
`})]})}function $o(){const[t,s]=o.useState({ide:[],cli:[],ext:[],acp:[]}),[n,r]=o.useState(!0);o.useEffect(()=>{fetch("https://raw.githubusercontent.com/vilmire/adhdev-providers/main/registry.json").then(i=>i.json()).then(i=>{const h=[],l=[],x=[],d=[];Object.values(i.providers||{}).forEach(b=>{const u={name:b.name||"Unknown",status:b.status||"Stable",details:b.details||"Community Provider"};b.category==="ide"?h.push(u):b.category==="cli"?l.push(u):b.category==="extension"?x.push(u):b.category==="acp"&&d.push(u)});const f=(b,u)=>{const m={Stable:1,Beta:2,WIP:3},v=m[b.status]||99,N=m[u.status]||99;return v!==N?v-N:b.name.localeCompare(u.name)};s({ide:h.sort(f),cli:l.sort(f),ext:x.sort(f),acp:d.sort(f)})}).catch(i=>console.error("Failed to load capabilities:",i)).finally(()=>r(!1))},[]);const a=i=>i==="Stable"?e.jsxs("div",{className:"flex items-center gap-1.5 text-success",children:[e.jsx(Rs,{className:"w-4 h-4"})," ",e.jsx("span",{children:"Stable"})]}):i==="Beta"?e.jsxs("div",{className:"flex items-center gap-1.5 text-warning",children:[e.jsx(Ut,{className:"w-4 h-4"})," ",e.jsx("span",{children:"Beta"})]}):e.jsxs("div",{className:"flex items-center gap-1.5 text-text-muted",children:[e.jsx(Ps,{className:"w-4 h-4"})," ",e.jsx("span",{children:i})]}),c=i=>e.jsx("div",{className:"bg-bg-card border border-border-subtle rounded-xl overflow-hidden",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-bg-secondary border-b border-border-subtle text-xs uppercase text-text-muted font-medium tracking-wider",children:[e.jsx("th",{className:"py-3 px-4 w-1/3",children:"Target"}),e.jsx("th",{className:"py-3 px-4 w-1/4",children:"Status"}),e.jsx("th",{className:"py-3 px-4",children:"Details"})]})}),e.jsx("tbody",{className:"divide-y divide-border-subtle text-sm",children:i.map((h,l)=>e.jsxs("tr",{className:"hover:bg-bg-subtle/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4 font-medium text-text-main",children:h.name}),e.jsx("td",{className:"py-3 px-4",children:a(h.status)}),e.jsx("td",{className:"py-3 px-4 text-text-muted",children:h.details})]},l))})]})});return n?e.jsx(St,{title:"Capabilities",subtitle:"Provider registry coverage for IDEs, CLI agents, extensions, and ACPs",icon:e.jsx(Nt,{}),widthClassName:"max-w-5xl",children:e.jsx(qt,{icon:e.jsx("div",{className:"w-8 h-8 border-4 border-accent border-t-transparent rounded-full animate-spin mx-auto"}),title:"Loading provider registry",description:"Fetching the latest support matrix from the shared provider registry."})}):e.jsxs(St,{title:"Capabilities",subtitle:"Provider registry coverage for IDEs, CLI agents, extensions, and ACPs",icon:e.jsx(Nt,{}),widthClassName:"max-w-5xl",contentClassName:"animate-fade-in",children:[e.jsx(be,{title:"Registry overview",description:"Support status is loaded from the shared provider registry used across OSS and cloud surfaces.",children:e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"IDEs"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.ide.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"CLI"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.cli.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"Extensions"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.ext.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"ACP"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.acp.length})]})]})}),e.jsx(be,{title:"IDE support",icon:e.jsx(_e,{className:"w-4 h-4"}),description:"Desktop editors and IDE surfaces with registry-backed providers.",children:c(t.ide)}),e.jsx(be,{title:"Standalone CLI agents",icon:e.jsx(Vt,{className:"w-4 h-4"}),description:"CLI-first agents that can participate in the standalone dashboard.",children:c(t.cli)}),e.jsx(be,{title:"AI extensions",icon:e.jsx(Ge,{className:"w-4 h-4"}),description:"IDE extensions and companion integrations available in the registry.",children:c(t.ext)}),e.jsx(be,{title:`ACP agents (${t.acp.length} loaded)`,icon:e.jsx(Ge,{className:"w-4 h-4"}),description:"ACP-backed providers discovered through the same shared registry.",children:c(t.acp)})]})}class Po{constructor(){xe(this,"adapters",new Map);xe(this,"states",new Map);xe(this,"ptyCallbacks",new Set);xe(this,"runtimeListeners",new Map);xe(this,"screenshotCallbacks",new Map);xe(this,"statusCallbacks",new Set)}resolveDaemonId(s){if(this.adapters.has(s))return s;if(s.startsWith("standalone")){for(const n of this.adapters.keys())if(n.startsWith("standalone"))return n}return null}register(s,n){this.adapters.set(s,n),this.states.set(s,n.connectionState)}unregister(s){this.adapters.delete(s),this.states.delete(s)}setState(s,n){this.states.set(s,n)}retryConnection(s){}get(s){const n=this.resolveDaemonId(s);return n?this.adapters.get(n):void 0}getState(s){const n=this.resolveDaemonId(s);return n&&this.states.get(n)||"disconnected"}sendData(s,n){return!1}sendPtyInput(s,n,r){return!1}sendPtyResize(s,n,r,a){return!1}onScreenshot(s,n){return this.screenshotCallbacks.set(s,n),()=>{this.screenshotCallbacks.delete(s)}}emitScreenshot(s,n){this.screenshotCallbacks.forEach(r=>r(s,n))}onStatus(s){return this.statusCallbacks.add(s),()=>{this.statusCallbacks.delete(s)}}emitStatus(s,n){this.statusCallbacks.forEach(r=>r(s,n))}onPtyOutput(s){return this.ptyCallbacks.add(s),()=>{this.ptyCallbacks.delete(s)}}emitPtyOutput(s,n,r){r!=null&&r.scrollback?this.emitRuntimeEvent(s,{type:"runtime_snapshot",sessionId:s,seq:0,text:typeof n=="string"?n:"",truncated:!1}):typeof n=="string"&&n&&this.emitRuntimeEvent(s,{type:"session_output",sessionId:s,data:n}),this.ptyCallbacks.forEach(a=>a(s,n,r))}emitRuntimeSnapshot(s,n,r=0,a=!1){this.emitRuntimeEvent(s,{type:"runtime_snapshot",sessionId:s,seq:r,text:n,truncated:a})}onRuntimeEvent(s,n){const r=this.runtimeListeners.get(s)||new Set;return r.add(n),this.runtimeListeners.set(s,r),()=>{const a=this.runtimeListeners.get(s);a&&(a.delete(n),a.size===0&&this.runtimeListeners.delete(s))}}async requestRuntimeSnapshot(s,n){if(!n)return;const r=await fetch(`/api/v1/runtime/${encodeURIComponent(n)}/snapshot`);if(!r.ok)return;const a=await r.json();this.emitRuntimeEvent(n,{type:"runtime_snapshot",sessionId:n,seq:typeof a.seq=="number"?a.seq:0,text:typeof a.text=="string"?a.text:"",truncated:!!a.truncated})}emitRuntimeEvent(s,n){var r;(r=this.runtimeListeners.get(s))==null||r.forEach(a=>a(n))}}const Ae=new Po;function Do(){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 bs=Do(),ys=3e3,Bo=3e4;let Re=null,Wo=0;const Mt=new Map;let We=null,ot=null;function Oo(t){return t==="connected"?"connected":t}async function kt(t,s,n){const r=Kr(t,n||{}),a=Re;if(a&&a.readyState===WebSocket.OPEN){const i=`req_${++Wo}_${Date.now()}`;return new Promise((h,l)=>{const x=setTimeout(()=>{Mt.delete(i),l(new Error(`WS command timeout: ${s}`))},3e4);Mt.set(i,{resolve:d=>{clearTimeout(x),h(d)},reject:d=>{clearTimeout(x),l(d)}}),a.send(JSON.stringify({type:"command",requestId:i,data:{type:s,payload:r.payload}}))})}const c=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:s,payload:r.payload})});if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}class Ko{constructor(s){xe(this,"daemonId");xe(this,"screenshotIdeType",null);this.daemonId=s}get hasCommandChannel(){return(Re==null?void 0:Re.readyState)===WebSocket.OPEN}get connectionState(){return(Re==null?void 0:Re.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(s,n){return kt(this.daemonId,s,n)}async sendInput(s,n){return kt(this.daemonId,"cdp_remote_action",{action:s,params:n,...this.screenshotIdeType&&{targetSessionId:this.screenshotIdeType}})}startScreenshots(s){this.screenshotIdeType=s||null,We&&(clearInterval(We),We=null);const n=async()=>{if(this.hasCommandChannel)try{const r=await kt(this.daemonId,"screenshot",{width:1280,...this.screenshotIdeType&&{targetSessionId:this.screenshotIdeType}});if(r!=null&&r.success&&(r!=null&&r.base64)){const a=await fetch(`data:image/jpeg;base64,${r.base64}`).then(c=>c.blob());Ae.emitScreenshot(this.daemonId,a)}}catch{}};n(),We=setInterval(n,2e3)}stopScreenshots(s){We&&(clearInterval(We),We=null)}}let Ce=null;function zo(t){return(!Ce||Ce.daemonId!==t)&&(Ce=new Ko(t)),Ce}function Fo({children:t}){const s=o.useRef(Qt()),n=Qt();s.current=n;const{setUserName:r}=it(),a=o.useRef(r);a.current=r;const[,c]=o.useState("disconnected"),i=o.useCallback((b,u)=>{c(b),ot==null||ot(b,u)},[]),h=o.useRef(null),l=o.useRef(),x=o.useRef(ys),d=o.useRef(!0),f=o.useRef(!1);return o.useEffect(()=>{d.current=!0,f.current=!1;function b(){var v,N;if(!d.current||((v=h.current)==null?void 0:v.readyState)===WebSocket.OPEN||((N=h.current)==null?void 0:N.readyState)===WebSocket.CONNECTING)return;i("connecting"),console.log(`[Standalone WS] Connecting to ${bs}...`);let m;try{m=new WebSocket(bs)}catch(g){console.error("[Standalone WS] Failed to create WebSocket:",g),u();return}h.current=m,m.onopen=()=>{if(!d.current){m.close();return}i("connected"),x.current=ys,console.log("[Standalone WS] Connected")},Re=m,m.onmessage=g=>{var p;try{const w=JSON.parse(g.data);if((w.type==="command_result"||w.type==="error")&&w.requestId){const T=Mt.get(w.requestId);T&&(Mt.delete(w.requestId),w.type==="error"?T.reject(new Error(((p=w.data)==null?void 0:p.message)||"Command failed")):T.resolve(w.data));return}if(w.type==="pty_output"){Ae.emitPtyOutput(w.cliId,w.data);return}if(w.type==="runtime_snapshot"){Ae.emitRuntimeSnapshot(w.sessionId,typeof w.text=="string"?w.text:"",typeof w.seq=="number"?w.seq:0,!!w.truncated);return}if(w.type==="status"||w.type==="initial_state"){const T=w.data;if(!T)return;const{injectEntries:y,markLoaded:S}=s.current,k=T.id||"standalone",j=zo(k);Ae.register(k,j),Ae.setState(k,"connected"),i("connected",k),Ae.emitStatus(k,T);const _=Or(T,{daemonId:k});_.length>0&&y(_),S(),T.userName&&a.current&&a.current(T.userName)}}catch(w){console.error("[Standalone WS] Parse error:",w)}},m.onclose=()=>{d.current&&(Ce==null||Ce.stopScreenshots(),Ce&&Ae.setState(Ce.daemonId,"disconnected"),i("disconnected"),h.current=null,u())},m.onerror=g=>{f.current||!d.current||console.warn("[Standalone WS] Error, will reconnect:",g)}}function u(){if(!d.current)return;clearTimeout(l.current);const m=x.current;console.log(`[Standalone WS] Reconnecting in ${m}ms...`),l.current=setTimeout(()=>{x.current=Math.min(x.current*1.5,Bo),b()},m)}return b(),()=>{d.current=!1,f.current=!0,clearTimeout(l.current),h.current&&(h.current.onerror=null,h.current.onclose=null,h.current.close(),h.current=null,Re=null),Ce&&(Ce.stopScreenshots(),Ae.unregister(Ce.daemonId))}},[]),e.jsx(e.Fragment,{children:t})}function Ho({children:t}){const[s,n]=o.useState("disconnected"),[r,a]=o.useState(null);o.useEffect(()=>(ot=(i,h)=>{n(i),h&&a(h)},()=>{ot=null}),[]);const c=o.useMemo(()=>{const i=s==="connected",h=Oo(s),l={};return r&&(l[r]=h),l.standalone=h,{wsStatus:s,isConnected:i,connectionStates:l}},[s,r]);return e.jsx(On,{connectionOverrides:c,children:e.jsx(Fo,{children:t})})}const Uo=[{id:"dashboard",path:"/dashboard",icon:e.jsx(Ts,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:e.jsx(Es,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:e.jsx(Ht,{}),label:"Settings"}];function Vo({children:t}){const s=ct(),n=Ln(),[r,a]=o.useState(!1),[c,i]=o.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),h=d=>{s(d),a(!1)},l=()=>{i(d=>{const f=!d;try{localStorage.setItem("sidebar-collapsed",f?"1":"0")}catch{}return f})},x=d=>`nav-item${n.pathname.startsWith(d)?" active":""} cursor-pointer ${c?"justify-center py-2.5 px-0":""}`;return e.jsxs("div",{className:`app-layout${r?" mobile-menu-open":""}${c?" sidebar-collapsed":""}`,children:[e.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>a(!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:()=>a(!1),onKeyDown:d=>d.key==="Escape"&&a(!1)}),e.jsxs("aside",{className:`sidebar ${r?"sidebar-open":""}`,children:[e.jsxs("div",{className:"sidebar-header",children:[e.jsxs("div",{className:`sidebar-logo ${c?"justify-center gap-0":""}`,children:[e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-7 h-7"}),!c&&e.jsx("span",{children:"ADHDev"})]}),e.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>a(!1),children:"✕"})]}),e.jsx("nav",{className:"sidebar-nav",children:Uo.map(d=>e.jsxs("div",{className:x(d.path),id:`nav-${d.id}`,onClick:()=>h(d.path),title:c?d.label:void 0,children:[e.jsx("span",{className:"nav-icon",children:d.icon}),!c&&d.label]},d.id))}),e.jsxs("div",{className:"border-t border-border-subtle pt-4 mt-2",children:[e.jsxs("div",{className:`nav-item cursor-pointer ${c?"justify-center py-2.5 px-0":""}`,id:"nav-docs",onClick:()=>window.open("https://docs.adhf.dev","_blank"),title:c?"Docs":void 0,children:[e.jsx("span",{className:"nav-icon",children:e.jsx(Nt,{})}),!c&&e.jsxs(e.Fragment,{children:["Docs",e.jsx("span",{className:"ml-auto text-[9px] text-text-muted",children:"↗"})]})]}),e.jsxs("div",{className:`nav-item cursor-pointer${n.pathname==="/about"?" active":""} ${c?"justify-center py-2.5 px-0":""}`,id:"nav-about",onClick:()=>s("/about"),title:c?"About":void 0,children:[e.jsx("span",{className:"nav-icon",children:e.jsx(As,{})}),!c&&"About"]}),!c&&e.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.7.35"]}),e.jsxs("div",{className:`nav-item cursor-pointer ${c?"justify-center py-2.5 px-0":"mt-1"}`,onClick:l,title:c?"Expand sidebar":"Collapse sidebar",children:[e.jsx("span",{className:"nav-icon text-base",children:c?"›":"‹"}),!c&&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 qo=[{icon:e.jsx(Es,{size:16}),title:"Local-first runtime",desc:"Everything stays on your machine and the browser only connects over localhost."},{icon:e.jsx(Ye,{size:16}),title:"Agent chat relay",desc:"Read and respond to AI conversations in real time across connected IDEs."},{icon:e.jsx($s,{size:16}),title:"Live screenshots",desc:"View your IDE directly in the browser through the local screenshot stream."},{icon:e.jsx(_e,{size:16}),title:"Remote control",desc:"Click, type, and steer your IDE sessions without switching windows."},{icon:e.jsx(Ge,{size:16}),title:"Multi-IDE support",desc:"Monitor VS Code, Cursor, Windsurf, and extension-based agents in one place."},{icon:e.jsx(Nt,{size:16}),title:"CLI and ACP coverage",desc:"Track standalone CLI agents and ACP-backed workflows alongside IDE sessions."}],Yo=[{icon:e.jsx(Ds,{size:16}),title:"Access from anywhere",desc:"Reach your burrows from another laptop or phone without opening local ports."},{icon:e.jsx(Ts,{size:16}),title:"Low-latency P2P stream",desc:"Cloud adds the WebRTC path for faster screenshots and remote control."},{icon:e.jsx(Ws,{size:16}),title:"Mobile notifications",desc:"Get approval prompts and activity updates when you are away from your desk."},{icon:e.jsx(Yn,{size:16}),title:"REST API access",desc:"Integrate with Slack, CI, or internal tools using API keys and service routes."},{icon:e.jsx(Vn,{size:16}),title:"Team workspace",desc:"Share burrows, activity views, and policies across a team workspace."},{icon:e.jsx(Rs,{size:16}),title:"Enterprise controls",desc:"SSO, RBAC, audit logs, and managed policy features for production teams."}],Go=[{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 and CLI agents",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 and 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}];function Xo(){return e.jsxs(St,{icon:e.jsx(As,{className:"text-text-primary"}),title:"About",subtitle:"Self-hosted ADHDev overview, supported surfaces, and what changes in Cloud",widthClassName:"max-w-5xl",actions:e.jsxs("div",{className:"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.7.35"]}),children:[e.jsx(be,{children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("div",{className:"text-[11px] font-semibold tracking-[0.18em] uppercase text-emerald-400 mb-2",children:"Self-hosted edition"}),e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-text-primary mb-2",children:"Keep the same dashboard experience, with the runtime fully on-device."}),e.jsx("p",{className:"text-sm text-text-muted leading-relaxed",children:"Standalone keeps the browser, daemon, screenshots, and control path on your own machine. It is the same core product shape as cloud, just without the remote networking and team layers."})]}),e.jsxs("div",{className:"grid gap-2 min-w-[220px]",children:[e.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex justify-center no-underline",children:"Docs ↗"}),e.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex justify-center no-underline",children:"GitHub ↗"}),e.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex justify-center no-underline",children:"Try Cloud ↗"})]})]})}),e.jsx(be,{title:"Included in standalone",description:"The local-first feature set available without the cloud control plane.",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:qo.map(t=>e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-4 transition-colors hover:border-border-default",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-text-primary mb-2",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-accent/10 text-accent-light",children:t.icon}),t.title]}),e.jsx("p",{className:"text-[13px] leading-relaxed text-text-muted",children:t.desc})]},t.title))})}),e.jsx(be,{title:"Compatible with",description:"Supported editors and agent surfaces exposed in the standalone dashboard.",children:e.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:[{label:"IDEs",items:Zs.map(t=>`${t.icon} ${t.name}`)},{label:"Extensions",items:en.map(t=>`${t.icon} ${t.name}`)},{label:"CLI agents",items:Qs.map(t=>`${t.icon} ${t.name}`)}].map(t=>e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-4",children:[e.jsx("div",{className:"text-[10px] font-bold tracking-wider text-text-muted mb-3 uppercase",children:t.label}),e.jsx("div",{className:"flex flex-col gap-1.5",children:t.items.map(s=>e.jsx("div",{className:"rounded-md border border-border-subtle bg-bg-card px-2.5 py-1.5 text-[12px] text-text-secondary",children:s},s))})]},t.label))})}),e.jsx(be,{title:"Cloud-only extras",description:"Capabilities that need the hosted control plane or team infrastructure.",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Yo.map(t=>e.jsxs("div",{className:"rounded-xl border border-violet-500/20 bg-violet-500/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-text-primary mb-2",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-violet-500/10 text-violet-400",children:t.icon}),t.title]}),e.jsx("p",{className:"text-[13px] leading-relaxed text-text-muted",children:t.desc})]},t.title))})}),e.jsx(be,{title:"Self-hosted vs Cloud",description:"The product split at a glance.",children:e.jsx("div",{className:"overflow-x-auto rounded-xl border border-border-subtle",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-3 font-semibold text-text-muted text-[11px] uppercase tracking-wider",children:"Feature"}),e.jsx("th",{className:"text-center px-4 py-3 font-semibold text-text-muted text-[11px] uppercase tracking-wider w-[110px]",children:"Selfhost"}),e.jsx("th",{className:"text-center px-4 py-3 font-semibold text-violet-400 text-[11px] uppercase tracking-wider w-[110px]",children:"Cloud"})]})}),e.jsx("tbody",{children:Go.map((t,s)=>e.jsxs("tr",{className:s%2===0?"bg-bg-glass":"bg-transparent",children:[e.jsx("td",{className:"px-4 py-2.5 text-text-secondary",children:t.feature}),e.jsx("td",{className:"px-4 py-2.5 text-center",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:"px-4 py-2.5 text-center",children:e.jsx("span",{className:"text-emerald-500",children:"✓"})})]},t.feature))})]})})}),e.jsx(qt,{icon:e.jsx("img",{src:"/otter-logo.png",alt:"",className:"mx-auto h-12 w-12 opacity-80"}),title:"Cloud is optional, not required",description:"You can stay fully local in standalone, and move to cloud later without changing how you use the dashboard.",action:e.jsxs("div",{className:"flex flex-wrap justify-center gap-3",children:[e.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm no-underline",children:"Compare Cloud ↗"}),e.jsxs("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm no-underline",children:[e.jsx(nr,{size:14,className:"mr-1"}),"Discord ↗"]})]})})]})}function Jo(){const{ides:t}=it(),s=t.find(f=>f.type==="adhdev-daemon"),n=(s==null?void 0:s.detectedIdes)||[],{sendCommand:r}=$e(),{userName:a}=it(),[c,i]=o.useState(a||"");o.useEffect(()=>{a!==void 0&&i(a)},[a]);const h=f=>{const b=f.target.value.trim();s!=null&&s.id&&b!==a&&r(s.id,"set_user_name",{userName:b}).catch(console.error)},[l,x]=o.useState(()=>{try{return localStorage.getItem("adhdev_sound")!=="0"}catch{return!0}}),d=f=>{x(f);try{localStorage.setItem("adhdev_sound",f?"1":"0")}catch{}};return e.jsxs(St,{icon:e.jsx(Ht,{className:"text-text-primary"}),title:"Settings",subtitle:"Local daemon configuration, appearance, and on-device preferences",widthClassName:"max-w-5xl",children:[e.jsx(sa,{variant:"info",children:"Standalone settings stay on this machine. The browser only talks to your local daemon over localhost."}),e.jsx(be,{title:"Daemon",description:"Connection health and local endpoints for the self-hosted runtime.",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.7.35"]}),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(be,{title:"Detected IDEs",description:"Editors discovered by the local daemon on this machine.",children:n.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:n.map(f=>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 ${f.running?"bg-green-400":"bg-text-muted/30"}`}),e.jsx("span",{className:"text-sm font-medium",children:f.name})]}),e.jsx("span",{className:"text-[11px] text-text-muted font-mono",children:f.type})]},f.type))})}),e.jsx(be,{title:"Machine",description:"The local burrow exposed by your standalone daemon.",children:e.jsx(da,{ides:t,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),e.jsx(be,{title:"Appearance",description:"Match the rest of the dashboard with a single place for mode and theme.",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:"Mode"}),e.jsx(pa,{})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[e.jsx("div",{className:"text-xs text-text-muted mb-1 font-medium",children:"Theme"}),e.jsx("p",{className:"text-[11px] text-text-muted mb-3",children:"Choose a preset or create a custom surface, accent, and chat palette for the standalone UI."}),e.jsx(ja,{})]})]})}),e.jsx(be,{title:"Notifications",description:"Browser prompts and local sound cues for agent activity.",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(la,{}),e.jsx(Oe,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(sr,{size:15})," Sound Effects"]}),description:"Play a sound when agent completes or needs approval",checked:l,onChange:d})]})}),e.jsx(be,{title:"Profile",description:"How your name appears in local chat threads and dashboard views.",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.jsxs("span",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(qn,{size:16,className:"text-text-secondary"})," 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:c,onChange:f=>i(f.target.value),onBlur:h,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()}})]})})})]})}ia();ba();const Zo=Is({baseUrl:""});function js(){const{ides:t}=it(),s=t.find(n=>{var r;return n.daemonMode||((r=n.id)==null?void 0:r.startsWith("standalone"))});return s?e.jsx(bt,{to:`/machines/${s.id}`,replace:!0}):t.length>0?e.jsx(bt,{to:`/machines/${t[0].id}`,replace:!0}):e.jsx(bt,{to:"/dashboard",replace:!0})}function Qo(){return e.jsx(_n,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:e.jsx(Fn,{client:Zo,children:e.jsx(Ho,{children:e.jsx(Un,{value:{sendCommand:kt,sendData:()=>!1},children:e.jsx(Vo,{children:e.jsxs($n,{children:[e.jsx(Ee,{path:"/dashboard",element:e.jsx(po,{})}),e.jsx(Ee,{path:"/ide/:id",element:e.jsx(wo,{})}),e.jsx(Ee,{path:"/machine",element:e.jsx(js,{})}),e.jsx(Ee,{path:"/machines/:id",element:e.jsx(_o,{})}),e.jsx(Ee,{path:"/machines",element:e.jsx(js,{})}),e.jsx(Ee,{path:"/capabilities",element:e.jsx($o,{})}),e.jsx(Ee,{path:"/about",element:e.jsx(Xo,{})}),e.jsx(Ee,{path:"/settings",element:e.jsx(Jo,{})}),e.jsx(Ee,{path:"*",element:e.jsx(bt,{to:"/dashboard",replace:!0})})]})})})})})})}Rr({connectionManager:Ae});Pn(document.getElementById("root")).render(e.jsx(o.StrictMode,{children:e.jsx(Qo,{})}));
|