meshy-node 0.10.4 → 0.10.5
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/README.md +1 -1
- package/dashboard/assets/{DashboardPage-0WRjBujS.js → DashboardPage-CuNReQ9k.js} +3 -3
- package/dashboard/assets/{DashboardShared-BGkSTKYP.js → DashboardShared-vm6Ua9h6.js} +22 -22
- package/dashboard/assets/{DiffTab-CGRnl8EV.js → DiffTab-Bz1OAlIg.js} +1 -1
- package/dashboard/assets/{FilesTab-DdNDe4Vy.js → FilesTab-BlJn83X5.js} +1 -1
- package/dashboard/assets/{MarkdownPreviewFrame-DwALMk1j.js → MarkdownPreviewFrame-CrujIEck.js} +1 -1
- package/dashboard/assets/{PreviewTab-CLE4ZFIp.js → PreviewTab-C7vB52yS.js} +1 -1
- package/dashboard/assets/{SharedConversationPage-DScv1dQe.js → SharedConversationPage-D86sReze.js} +2 -2
- package/dashboard/assets/{file-Bp3lcXJZ.js → file-CBXlsD1A.js} +1 -1
- package/dashboard/assets/{index-DtTy7Ax9.js → index-B21dpk5D.js} +2 -2
- package/dashboard/assets/{index-DVIvShRC.css → index-Bd5ODKX4.css} +1 -1
- package/dashboard/index.html +2 -2
- package/package.json +1 -1
- package/runtime-metadata.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-CuNReQ9k.js","assets/DashboardShared-vm6Ua9h6.js","assets/MarkdownPreviewFrame-CrujIEck.js","assets/PreviewTab-C7vB52yS.js","assets/DashboardPage-BaHExl1O.css","assets/SharedConversationPage-D86sReze.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
function Kw(n,r){for(var o=0;o<r.length;o++){const s=r[o];if(typeof s!="string"&&!Array.isArray(s)){for(const c in s)if(c!=="default"&&!(c in n)){const u=Object.getOwnPropertyDescriptor(s,c);u&&Object.defineProperty(n,c,u.get?u:{enumerable:!0,get:()=>s[c]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))s(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const m of u.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&s(m)}).observe(document,{childList:!0,subtree:!0});function o(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(c){if(c.ep)return;c.ep=!0;const u=o(c);fetch(c.href,u)}})();function w0(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var kd={exports:{}},zl={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -343,4 +343,4 @@ You can add a description to the \`${jo}\` by passing a \`${t1}\` component as a
|
|
|
343
343
|
|
|
344
344
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${jo}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
345
345
|
|
|
346
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return g.useEffect(()=>{document.getElementById(n.current?.getAttribute("aria-describedby"))||console.warn(r)},[r,n]),null},cj=Qx,uj=Kx,dj=Zx,l1=Fx,s1=Wx,i1=a1,c1=o1,u1=e1,d1=n1;const Nf=cj,Tf=uj,fj=dj,f1=g.forwardRef(({className:n,...r},o)=>f.jsx(l1,{className:ae("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...r,ref:o}));f1.displayName=l1.displayName;const Xi=g.forwardRef(({className:n,...r},o)=>f.jsxs(fj,{children:[f.jsx(f1,{}),f.jsx(s1,{ref:o,className:ae("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-3 rounded-sm border bg-background p-4 shadow-[0_24px_84px_-54px_rgba(0,0,0,0.55)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",n),...r})]}));Xi.displayName=s1.displayName;const Qi=({className:n,...r})=>f.jsx("div",{className:ae("flex flex-col space-y-1.5 text-center sm:text-left",n),...r});Qi.displayName="AlertDialogHeader";const Ki=({className:n,...r})=>f.jsx("div",{className:ae("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...r});Ki.displayName="AlertDialogFooter";const Zi=g.forwardRef(({className:n,...r},o)=>f.jsx(u1,{ref:o,className:ae("text-sm font-semibold",n),...r}));Zi.displayName=u1.displayName;const Fi=g.forwardRef(({className:n,...r},o)=>f.jsx(d1,{ref:o,className:ae("text-[11px] text-muted-foreground",n),...r}));Fi.displayName=d1.displayName;const Wi=g.forwardRef(({className:n,...r},o)=>f.jsx(i1,{ref:o,className:ae(If(),n),...r}));Wi.displayName=i1.displayName;const Ji=g.forwardRef(({className:n,...r},o)=>f.jsx(c1,{ref:o,className:ae(If({variant:"outline"}),"mt-2 sm:mt-0",n),...r}));Ji.displayName=c1.displayName;const mj={online:"bg-emerald-500",busy:"bg-amber-500",offline:"bg-destructive"};function hj({status:n}){return f.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5",children:[n==="online"&&f.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-500 opacity-30"}),f.jsx("span",{className:ae("relative inline-flex h-2.5 w-2.5 rounded-full",mj[n])})]})}function pj({role:n,size:r="default"}){return f.jsx(_t,{variant:n==="leader"?"default":"secondary",className:ae(r==="compact"?"px-1.5 py-0 text-[9px] leading-4":"text-[11px]"),children:n})}const m1={pending:{variant:"secondary",dotClass:"bg-muted-foreground",className:"border-transparent bg-muted/55 text-muted-foreground"},assigned:{variant:"outline",dotClass:"bg-teal-500",className:"border-teal-500/20 bg-teal-500/8 text-teal-700 dark:text-teal-300"},running:{variant:"outline",dotClass:"bg-amber-500",className:"border-amber-500/22 bg-amber-500/9 text-amber-700 dark:text-amber-300"},completed:{variant:"outline",dotClass:"bg-emerald-500",className:"border-emerald-500/18 bg-emerald-500/8 text-emerald-700 dark:text-emerald-300"},failed:{variant:"destructive",dotClass:"bg-destructive-foreground",className:"border-destructive/20 bg-destructive/90 text-destructive-foreground"},cancelled:{variant:"secondary",dotClass:"bg-muted-foreground",className:"border-transparent bg-muted/55 text-muted-foreground"},archived:{variant:"secondary",dotClass:"bg-slate-400",className:"border-transparent bg-muted/50 text-muted-foreground"}};function DO({status:n,size:r="default"}){const o=m1[n],s=r==="compact"?"gap-0.5 px-1 py-0 text-[8px] leading-3 [&>span]:h-[3px] [&>span]:w-[3px]":"gap-1 px-1.5 py-0 text-[10px] leading-4 [&>span]:h-[5px] [&>span]:w-[5px]";return f.jsxs(_t,{variant:o.variant,className:ae("rounded-sm font-medium shadow-none",s,o.className),children:[f.jsx("span",{className:ae("rounded-full",o.dotClass)}),n]})}function zO({status:n,isNative:r=!1,size:o="default",className:s}){const c=m1[n],u=[n,r?"native":null].filter(Boolean).join(", "),m=o==="compact"?"h-1.5 w-1.5":"h-2 w-2";return f.jsxs("span",{className:ae("inline-flex shrink-0 items-center gap-1",s),title:u,"aria-label":u,children:[f.jsx("span",{className:ae("rounded-full",m,c.dotClass),title:n}),r&&f.jsx("span",{className:ae("rounded-full bg-sky-500",m),title:"native"})]})}const gj={critical:{variant:"destructive",label:"Critical"},high:{variant:"outline",label:"High"},normal:{variant:"secondary",label:"Normal"},low:{variant:"secondary",label:"Low"}};function LO({priority:n}){const r=gj[n];return f.jsx(_t,{variant:r.variant,className:"rounded-sm px-1.5 py-0 text-[10px] leading-4 shadow-none",children:r.label})}function vj(n){return[{key:"workspace",label:"Workspace",value:n?.workspace},{key:"node",label:"Node app",value:n?.node},{key:"core",label:"Core",value:n?.core},{key:"dashboard",label:"Dashboard",value:n?.dashboard},{key:"api",label:"API",value:n?.api}].filter(o=>o.value)}function Eo({label:n,value:r,mono:o=!1}){return f.jsxs("div",{className:"min-w-0 rounded-sm border border-border/60 bg-background/65 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:n}),f.jsx("div",{className:o?"mt-0.5 break-all font-mono text-[11px] text-foreground":"mt-0.5 break-all text-[11px] text-foreground",children:r})]})}function yj({formatDateTime:n,viewInfo:r}){const o=vj(r.packages);return f.jsxs(Gl,{value:"about","data-about-layout":"compact",className:"mt-0 space-y-2",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(DN,{className:"h-3.5 w-3.5 text-primary"}),"Repository & runtime"]}),f.jsx(Nn,{className:"text-[10px]",children:"Build source and runtime identity for this node."})]}),f.jsxs(Tn,{className:"space-y-2 px-3 pb-2.5",children:[r.repository?.url?f.jsxs("a",{href:r.repository.url,target:"_blank",rel:"noreferrer",className:"group flex min-w-0 items-center justify-between gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-1.5 text-[11px] text-foreground transition-colors hover:border-primary/40 hover:bg-primary/5",children:[f.jsx("span",{className:"truncate font-mono text-[10px]",children:r.repository.url}),f.jsx(oy,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform group-hover:-translate-y-0.5 group-hover:translate-x-0.5"})]}):f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-2.5 py-1.5 text-[11px] text-muted-foreground",children:"Repository URL is unavailable in this runtime."}),f.jsxs("div",{className:"grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3",children:[f.jsx(Eo,{label:"Branch",value:r.repository?.branch??"Unavailable",mono:!!r.repository?.branch}),f.jsx(Eo,{label:"Commit",value:r.repository?.commit??"Unavailable",mono:!!r.repository?.commit}),f.jsx(Eo,{label:"Runtime",value:`${r.packageName??"meshy"} ${r.version}`,mono:!0}),f.jsx(Eo,{label:"Node.js",value:r.runtime?.nodeVersion??"Unavailable",mono:!!r.runtime?.nodeVersion}),f.jsx(Eo,{label:"PID",value:r.runtime?String(r.runtime.pid):"Unavailable",mono:!!r.runtime}),f.jsx(Eo,{label:"Started",value:n(r.runtime?.startedAt)})]})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(tT,{className:"h-3.5 w-3.5 text-primary"}),"Package versions"]}),f.jsx(Nn,{className:"text-[10px]",children:"Version snapshot for the packages most relevant to this dashboard session."})]}),f.jsx(Tn,{"data-package-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:o.map(s=>f.jsxs("div",{className:"grid gap-1.5 rounded-sm border border-border/60 bg-background/65 px-2.5 py-1.5 sm:grid-cols-[9rem_minmax(0,1fr)_auto] sm:items-center",children:[f.jsx("div",{className:"text-[11px] font-medium text-foreground",children:s.label}),f.jsx("div",{className:"min-w-0 truncate text-[10px] text-muted-foreground",children:s.value?.name}),f.jsx(_t,{variant:"outline",className:"w-fit rounded-sm border-border/70 bg-background/60 font-mono text-[10px]",children:s.value?.version})]},s.key))})]})]})}const UO="codex",BO="bypass",bj=[{value:"codex",label:"Codex",supportsFollowUp:!0},{value:"claudecode",label:"Claude Code",supportsFollowUp:!0},{value:"copilot",label:"Copilot",supportsFollowUp:!0},{value:"mars",label:"mars",disabled:!0,description:"coming soon"},{value:"eureka",label:"eureka",disabled:!0,description:"coming soon"}],HO=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],PO=new Set(bj.filter(n=>n.supportsFollowUp).map(n=>n.value)),$O=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"shared",label:"Shared"},{value:"archived",label:"Archived"}],qO=[{value:"all",label:"All task types"},{value:"native",label:"Native sessions"},{value:"meshy",label:"Meshy chats"}],xj=new Set(["pending","assigned"]),Sj=new Set(["running"]),wj=new Set(["completed","failed","cancelled"]),VO=10;function YO(n,r){switch(r){case"running":return Sj.has(n.status);case"waiting":return xj.has(n.status);case"closed":return wj.has(n.status);case"shared":return!!n.activeShare;case"archived":return n.status==="archived";default:return n.status!=="archived"}}function IO(n,r){if(r==="all")return!0;const o=n.conversationKind==="nativeSession";return r==="native"?o:!o}function GO(n,r){const o=r.trim().toLowerCase();return o?[n.title,n.description,n.id,n.agent,n.assignedTo??"",n.assignedNodeName??"",n.project??"",n.effectiveProjectPath??"",n.conversationKind==="nativeSession"?"native session":"meshy chat",n.activeShare?"shared conversation":""].some(s=>s.toLowerCase().includes(o)):!0}function Ej(n,r,o){return n?r?.find(c=>c.id===n)?.name??o??n.slice(0,8):"unassigned"}function XO(n,r,o){return Ej(n,r,o).toLowerCase()}function QO(n){return n.type!=="node.status"&&n.type!=="cluster.state"}function KO(n,r,o){return!n.assignedTo||o?.id===n.assignedTo?!0:r?.some(s=>s.id===n.assignedTo)??!1}function ZO(n,r){return[...n].sort((o,s)=>o.id===r?-1:s.id===r?1:o.name.localeCompare(s.name))}function FO(n){if(!n||typeof n!="object")return null;const r=n,o=r.createMode,s=o==="chat"||o==="native"?o:void 0,c=r.createDefaults,u=c&&typeof c=="object"&&!Array.isArray(c)?c:null,m=u?{assignTo:typeof u.assignTo=="string"||u.assignTo===null?u.assignTo:void 0,project:typeof u.project=="string"||u.project===null?u.project:void 0}:void 0;return{draftNewTask:r.draftNewTask===!0,returnRoute:typeof r.returnRoute=="string"?r.returnRoute:void 0,returnTaskId:typeof r.returnTaskId=="string"||r.returnTaskId===null?r.returnTaskId:void 0,createMode:s,createDefaults:m}}function WO(n){return n==="default workspace"?n:n.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??n}function JO(n){const r=Date.now()-n;return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m`:r<864e5?`${Math.floor(r/36e5)}h`:`${Math.floor(r/864e5)}d`}function eM(n){return new Date(n).toLocaleString()}function tM(n){const r=Math.floor(n/1e3),o=Math.floor(r/3600),s=Math.floor(r%3600/60),c=r%60;return`${String(o).padStart(2,"0")}:${String(s).padStart(2,"0")}:${String(c).padStart(2,"0")}`}async function h1(n,r="Copied to clipboard"){try{if(globalThis.navigator?.clipboard?.writeText)return await globalThis.navigator.clipboard.writeText(n),_e.success(r),!0;const o=globalThis.document,s=o?.execCommand?.bind(o);if(!o?.body||typeof o.createElement!="function"||typeof s!="function")throw new Error("Clipboard access is unavailable");const c=o.createElement("textarea"),u=o.activeElement,m=u&&typeof u.focus=="function"?u:null;c.value=n,c.setAttribute("readonly","true"),c.style.position="fixed",c.style.opacity="0",c.style.pointerEvents="none",o.body.appendChild(c),c.select(),c.setSelectionRange(0,c.value.length);const h=s("copy");if(o.body.removeChild(c),m?.focus(),!h)throw new Error("Clipboard access is unavailable");return _e.success(r),!0}catch(o){return _e.error(o instanceof Error?o.message:"Failed to copy"),!1}}const Nj="default workspace";function _i(n){const r=n.replace(/\\/g,"/");return r==="/"||/^[A-Za-z]:\/$/.test(r)?r:r.replace(/\/+$/g,"")||r}function Tj(n){const r=n.replace(/\\/g,"/");return r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r)}function Cj(n,r){const o=_i(n),s=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!s||s==="."?o:o==="/"||/^[A-Za-z]:\/$/.test(o)?`${o}${s}`:`${o}/${s}`}function Rj(n,r){const o=n.effectiveProjectPath?.trim();if(o)return _i(o);const s=n.project?.trim();if(!s)return Nj;if(Tj(s)||!n.assignedTo)return _i(s);const c=r?.get(n.assignedTo)?.trim();return c?Cj(c,s):_i(s)}function nM({nodeStatusById:n,nodeNameById:r,nodeFilter:o,searchQuery:s,nodeWorkDirById:c}){const u=o.trim().toLowerCase(),m=s.trim().toLowerCase(),h=[];for(const[v,p]of n){if(p==="offline"||u==="unassigned")continue;const b=r.get(v)??v.slice(0,8);if(!(u&&u!=="all"&&b.toLowerCase()!==u)){if(m){const y=c?.get(v)??"";if(![v,b,y].some(C=>C.toLowerCase().includes(m)))continue}h.push(v)}}return h}function aM(n,r,o,s,c){const u=new Map;for(const h of n){const v=h.assignedTo??null,p=v??"__unassigned__",b=v?r.get(v)??h.assignedNodeName??v.slice(0,8):"Unassigned",y=Rj(h,s);u.has(p)||u.set(p,{nodeId:v,nodeName:b,dirMap:new Map});const w=u.get(p);w.dirMap.has(y)||w.dirMap.set(y,[]),w.dirMap.get(y).push(h)}for(const h of c??[])u.has(h)||u.set(h,{nodeId:h,nodeName:r.get(h)??h.slice(0,8),dirMap:new Map});const m=Array.from(u.values()).map(({nodeId:h,nodeName:v,dirMap:p})=>{const b=Array.from(p.entries()).map(([y,w])=>({path:y,tasks:w})).sort((y,w)=>w.tasks.length-y.tasks.length||y.path.localeCompare(w.path));return{nodeId:h,nodeName:v,dirs:b}});return m.sort((h,v)=>{if(o){if(h.nodeId===o)return-1;if(v.nodeId===o)return 1}return h.nodeId===null?1:v.nodeId===null?-1:h.nodeName.localeCompare(v.nodeName)}),m}const Aj=["queued","running"],kj=["copilot.tunnel","copilot.tunnel.disable"],jj=1e4;function i0(n){return n?.status==="succeeded"||n?.status==="failed"}function _j(n){return n.reduce((r,o)=>!r||o.updatedAt>r.updatedAt?o:r,null)}async function Oj(n,r=Z0){const o=await Promise.all(kj.flatMap(s=>Aj.map(c=>r({kind:s,status:c,nodeId:n}))));return _j(o.flat())}function c0(n){return n?.split(/\r?\n/).map(r=>r.trim()).filter(Boolean).at(-1)??null}function Mj(n,r){return[n,...r].join(" ")}function Dj(n,r,o){return r&&!n?"Checking port 8314":n?n.status==="queued"?"Queued":n.status==="running"?n.kind==="copilot.tunnel.disable"?"Stopping Meshy-managed tunnel":n.kind==="copilot.tunnel"?n.result?.status==="auth-required"?"Waiting for GitHub device authorization":"Starting Copilot tunnel":"Checking port 8314":n.status==="succeeded"?n.result?.available?n.result.status==="already-running"?"Port 8314 is already reachable":"Proxy is listening on 8314":n.result?.status==="stopped"?"Meshy-managed tunnel stopped":"Port 8314 is not listening":o??"Tunnel operation failed":"Port 8314 status has not been checked"}function zj(n,r){return r||n?.status==="queued"||n?.status==="running"?f.jsx(ly,{className:"h-3.5 w-3.5 animate-spin text-primary"}):n?.result?.available?f.jsx(Ro,{className:"h-3.5 w-3.5 text-emerald-500"}):n?.status==="failed"?f.jsx(sf,{className:"h-3.5 w-3.5 text-destructive"}):f.jsx(sf,{className:"h-3.5 w-3.5 text-muted-foreground"})}function Lj({checked:n,disabled:r,onCheckedChange:o}){return f.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":"Toggle GitHub Copilot Tunnel",title:n?"Disable GitHub Copilot Tunnel":"Enable GitHub Copilot Tunnel","data-copilot-tunnel-switch":"true",disabled:r,onClick:()=>o(!n),className:ae("relative h-5 w-9 shrink-0 rounded-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",n?"bg-primary/85":"bg-muted"),children:f.jsx("span",{className:ae("absolute left-0.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 rounded-sm bg-background shadow-sm transition-transform",n?"translate-x-4":"translate-x-0")})})}function Uj({nodeId:n,nodeName:r}){const[o,s]=g.useState(null),[c,u]=g.useState(!1),[m,h]=g.useState(!1),v=o?.status==="queued"||o?.status==="running",p=o?.result,b=p?.auth??null,y=o?.error??p?.detail??c0(p?.stderr)??c0(p?.stdout),w=p?Mj(p.command,p.args):"npx -y ghc-tunnel@latest -d",C=!!p?.available||v&&o?.kind==="copilot.tunnel",N=c||m||v,E=g.useMemo(()=>Dj(o,c,y),[c,y,o]);g.useEffect(()=>{let A=!1;async function k(){u(!0);try{const O=await Oj(n);if(A)return;if(O){s(O);return}const B=await Sv(n);A||s(B)}catch(O){A||_e.error(O instanceof Error?O.message:"Failed to check Copilot tunnel")}finally{A||u(!1)}}return s(null),k(),()=>{A=!0}},[n]),g.useEffect(()=>{if(!o||i0(o))return;let A=!1;const k=o.id;async function O(){try{const L=await K0(k);if(A)return;if(L.kind==="copilot.tunnel.status"&&!i0(L)&&Date.now()-L.createdAt>jj){const Z=await Sv(n);A||s(Z);return}s(L),L.status==="succeeded"&&L.kind==="copilot.tunnel"&&_e.success(`Copilot tunnel is available on ${r}`),L.status==="succeeded"&&L.kind==="copilot.tunnel.disable"&&_e.success(`Copilot tunnel stopped on ${r}`),L.status==="failed"&&L.kind!=="copilot.tunnel.status"&&_e.error(L.error??"Copilot tunnel failed")}catch(L){A||_e.error(L instanceof Error?L.message:"Failed to refresh Copilot tunnel")}}O();const B=window.setInterval(O,2e3);return()=>{A=!0,window.clearInterval(B)}},[n,r,o?.id,o?.status]);const T=g.useCallback(async A=>{h(!0);try{const k=A?await VE(n):await YE(n);s(k),_e.info(A?`Copilot tunnel enable requested on ${r}`:`Copilot tunnel stop requested on ${r}`)}catch(k){_e.error(k instanceof Error?k.message:"Failed to update Copilot tunnel")}finally{h(!1)}},[n,r]);return f.jsxs(Sn,{"data-copilot-tunnel-section":"true",className:"rounded-sm border-border/70 bg-background/75 shadow-none xl:col-span-2",children:[f.jsx(wn,{className:"pb-1.5 pt-2.5 px-3",children:f.jsxs("div",{className:"flex items-start justify-between gap-3",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(ay,{className:"h-3.5 w-3.5 text-primary"}),"GitHub Copilot Tunnel"]}),f.jsx(Nn,{className:"text-[10px]",children:"Node-local Copilot proxy model provider."})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[f.jsx("span",{"aria-label":E,title:E,className:"inline-flex h-5 w-5 items-center justify-center",children:zj(o,c)}),f.jsx(Lj,{checked:C,disabled:N,onCheckedChange:A=>{T(A)}})]})]})}),f.jsxs(Tn,{className:"space-y-2 px-3 pb-2.5",children:[f.jsxs("div",{className:"space-y-1.5 rounded-sm bg-background/55 px-2.5 py-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[f.jsx("span",{className:ae("h-1.5 w-1.5 rounded-sm",p?.available?"bg-emerald-500":v||c?"animate-pulse bg-amber-500":o?.status==="failed"?"bg-destructive":"bg-muted-foreground/50")}),E]}),f.jsx("div",{className:"truncate font-mono text-[10px] text-muted-foreground",children:w}),(v||c||m)&&f.jsx("div",{className:"h-0.5 overflow-hidden rounded-sm bg-muted",children:f.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})})]}),b&&v&&f.jsxs("div",{className:"grid gap-2 rounded-sm border border-primary/35 bg-primary/8 px-2.5 py-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",children:[f.jsxs("div",{className:"min-w-0 space-y-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[f.jsx(aT,{className:"h-3.5 w-3.5 animate-pulse text-primary"}),"GitHub device login"]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:[f.jsx("span",{className:"font-mono text-[11px] text-foreground",children:b.code}),b.expiresInSeconds?f.jsxs("span",{children:[Math.ceil(b.expiresInSeconds/60),"m expiry"]}):null]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ct,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 rounded-sm",title:"Copy device code","aria-label":"Copy device code",onClick:()=>{h1(b.code,"Device code copied")},children:f.jsx(ry,{className:"h-3.5 w-3.5"})}),f.jsx(Ct,{asChild:!0,variant:"outline",size:"icon",className:"h-7 w-7 rounded-sm",title:"Open GitHub device login","aria-label":"Open GitHub device login",children:f.jsx("a",{href:b.url,target:"_blank",rel:"noreferrer",children:f.jsx(oy,{className:"h-3.5 w-3.5"})})})]})]}),y&&o?.status!=="succeeded"&&f.jsx("div",{className:"rounded-sm border border-border/60 bg-muted/35 px-2 py-1 text-[10px] text-muted-foreground",children:y})]})]})}const bc=g.forwardRef(({className:n,type:r,...o},s)=>f.jsx("input",{type:r,className:ae("flex h-8 w-full rounded-sm border border-input/85 bg-background/72 px-2.5 py-1.5 text-[11px] shadow-sm ring-offset-background transition-all duration-200 file:border-0 file:bg-transparent file:text-[11px] file:font-medium file:text-foreground placeholder:text-muted-foreground/75 focus-visible:border-primary/45 focus-visible:bg-background/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/45 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",n),ref:s,...o}));bc.displayName="Input";function Bj(){return be("/system/quick-chats")}function Hj(n){return be("/system/quick-chats",{method:"PUT",body:JSON.stringify({quickChats:n})})}const Cf="quick-chats:updated";function Pj(){typeof window>"u"||window.dispatchEvent(new CustomEvent(Cf))}function $j(){const[n,r]=g.useState([]),[o,s]=g.useState(!0),[c,u]=g.useState(!1),[m,h]=g.useState(null),v=g.useCallback(async()=>{s(!0);try{const b=await Bj();r(b.quickChats),h(null)}catch(b){h(b instanceof Error?b.message:"Failed to load quick chats")}finally{s(!1)}},[]),p=g.useCallback(async b=>{u(!0);try{const y=await Hj(b);return r(y.quickChats),h(null),Pj(),y.quickChats}catch(y){const w=y instanceof Error?y.message:"Failed to save quick chats";throw h(w),y}finally{u(!1)}},[]);return g.useEffect(()=>{v()},[v]),g.useEffect(()=>{if(typeof window>"u")return;const b=()=>{v()};return window.addEventListener(Cf,b),()=>window.removeEventListener(Cf,b)},[v]),{error:m,loading:o,quickChats:n,refresh:v,save:p,saving:c}}function p1(n){return n.trim().replace(/^\/+/,"").toLowerCase()}function g1(n,r){const o=n.trim();if(!o.startsWith("/"))return[];const s=p1(o);return r.filter(c=>c.alias.startsWith(s))}function ec(n,r){return r<=0?-1:(n%r+r)%r}function rM(n,r,o=0){const s=g1(n,r),c=ec(o,s.length);return c>=0?s[c]??null:null}function oM(n,r,o){const s=ec(n,r);return s<0?0:ec(s+o,r)}function lM({query:n,quickChats:r,selectedIndex:o=0,onSelect:s,onActiveIndexChange:c}){const u=g1(n,r);if(u.length===0)return null;const m=ec(o,u.length);return f.jsxs("div",{"data-quick-chat-menu":"true",className:"mx-2 mb-0.5 rounded-sm bg-background/70 p-0.5 shadow-none sm:mx-5",children:[f.jsxs("div",{className:"flex items-center gap-1 px-1 py-0.5 text-[8px] uppercase tracking-[0.14em] text-muted-foreground/75",children:[f.jsx(sy,{className:"h-2.5 w-2.5 text-primary/55"}),"Quick chats"]}),f.jsx("div",{className:"max-h-24 overflow-y-auto",role:"listbox","aria-label":"Quick chats",children:u.map((h,v)=>f.jsxs("button",{type:"button",role:"option","aria-selected":v===m,"data-selected":v===m?"true":void 0,onMouseEnter:()=>c?.(v),onClick:()=>s(h),className:ae("flex w-full min-w-0 items-start gap-1.5 rounded-sm px-1 py-1 text-left text-[9px] transition-colors hover:bg-muted/50 hover:text-foreground"),children:[f.jsxs("span",{"data-quick-chat-alias":"true",className:ae("shrink-0 font-mono text-[9px] leading-3 text-primary/70",v===m&&"text-primary"),children:["/",h.alias]}),f.jsx("span",{"data-quick-chat-prompt":"true",className:ae("line-clamp-1 min-w-0 text-[9px] leading-3 text-muted-foreground",v===m&&"text-primary/90"),children:h.prompt})]},h.alias))})]})}const qj="h-14 w-full resize-none rounded-sm border border-border/70 bg-background/80 px-2 py-1.5 text-[11px] leading-4 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";let Vj=0;function Oi(n,r=0){return{id:n?`${n.alias}:${r}`:`new:${Vj++}`,alias:n?.alias??"",prompt:n?.prompt??""}}function Rf(n){return{quickChats:n.map(r=>({alias:p1(r.alias),prompt:r.prompt.trim()})).filter(r=>r.alias.length>0&&r.prompt.length>0)}}function Yj(n,r){const o=Rf(n).quickChats,s=r.map((u,m)=>Oi(u,m)),c=Rf(s).quickChats;return JSON.stringify(o)!==JSON.stringify(c)}function Ij(){const{error:n,loading:r,quickChats:o,save:s,saving:c}=$j(),[u,m]=g.useState(()=>o.map((y,w)=>Oi(y,w))),h=u.length>0,v=g.useMemo(()=>Rf(u),[u]),p=g.useMemo(()=>Yj(u,o),[u,o]);g.useEffect(()=>{m(o.map((y,w)=>Oi(y,w)))},[o]);async function b(){try{await s(v.quickChats),_e.success("Quick chats saved")}catch(y){_e.error(y instanceof Error?y.message:"Failed to save quick chats")}}return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"rounded-sm border border-border/70 bg-background/75 px-3 py-2.5",children:f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[f.jsx(sy,{className:"h-3.5 w-3.5 text-primary"}),"Quick chats"]}),f.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:"Reusable slash aliases for chat composers on this leader."})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsxs(Ct,{type:"button",variant:"outline",onClick:()=>m(y=>[...y,Oi(void 0,y.length)]),className:"h-7 rounded-sm px-2 text-[10px]",children:[f.jsx(dT,{className:"h-3.5 w-3.5"}),"Add"]}),f.jsxs(Ct,{type:"button",onClick:b,disabled:c||!p,className:"h-7 rounded-sm px-2 text-[10px]",children:[c?f.jsx(ly,{className:"h-3.5 w-3.5 animate-spin"}):f.jsx(bT,{className:"h-3.5 w-3.5"}),"Save"]})]})]})}),r&&!h?f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-4 text-[11px] text-muted-foreground",children:"Loading quick chats..."}):h?f.jsx("div",{className:"space-y-1.5",children:u.map((y,w)=>f.jsxs("div",{className:"grid gap-1.5 rounded-sm border border-border/60 bg-background/70 px-2 py-2 md:grid-cols-[12rem_minmax(0,1fr)_auto]",children:[f.jsx(bc,{"aria-label":`Quick chat ${w+1} alias`,value:y.alias,onChange:C=>m(N=>N.map(E=>E.id===y.id?{...E,alias:C.target.value}:E)),placeholder:"alias",className:"h-7 rounded-sm border-border/70 bg-background/80 px-2 font-mono text-[11px]"}),f.jsx("textarea",{"aria-label":`Quick chat ${w+1} prompt`,value:y.prompt,onChange:C=>m(N=>N.map(E=>E.id===y.id?{...E,prompt:C.target.value}:E)),placeholder:"Prompt text",className:qj}),f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",onClick:()=>m(C=>C.filter(N=>N.id!==y.id)),"aria-label":`Remove quick chat ${w+1}`,className:"h-7 w-7 rounded-sm text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:f.jsx(OT,{className:"h-3.5 w-3.5"})})]},y.id))}):f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-4 text-[11px] text-muted-foreground",children:"No quick chats configured."}),n&&f.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:n})]})}var xc="Checkbox",[Gj]=Fa(xc),[Xj,hm]=Gj(xc);function Qj(n){const{__scopeCheckbox:r,checked:o,children:s,defaultChecked:c,disabled:u,form:m,name:h,onCheckedChange:v,required:p,value:b="on",internal_do_not_use_render:y}=n,[w,C]=_o({prop:o,defaultProp:c??!1,onChange:v,caller:xc}),[N,E]=g.useState(null),[T,A]=g.useState(null),k=g.useRef(!1),O=N?!!m||!!N.closest("form"):!0,B={checked:w,disabled:u,setChecked:C,control:N,setControl:E,name:h,form:m,value:b,hasConsumerStoppedPropagationRef:k,required:p,defaultChecked:Ga(c)?!1:c,isFormControl:O,bubbleInput:T,setBubbleInput:A};return f.jsx(Xj,{scope:r,...B,children:Kj(y)?y(B):s})}var v1="CheckboxTrigger",y1=g.forwardRef(({__scopeCheckbox:n,onKeyDown:r,onClick:o,...s},c)=>{const{control:u,value:m,disabled:h,checked:v,required:p,setControl:b,setChecked:y,hasConsumerStoppedPropagationRef:w,isFormControl:C,bubbleInput:N}=hm(v1,n),E=We(c,b),T=g.useRef(v);return g.useEffect(()=>{const A=u?.form;if(A){const k=()=>y(T.current);return A.addEventListener("reset",k),()=>A.removeEventListener("reset",k)}},[u,y]),f.jsx(Le.button,{type:"button",role:"checkbox","aria-checked":Ga(v)?"mixed":v,"aria-required":p,"data-state":E1(v),"data-disabled":h?"":void 0,disabled:h,value:m,...s,ref:E,onKeyDown:ze(r,A=>{A.key==="Enter"&&A.preventDefault()}),onClick:ze(o,A=>{y(k=>Ga(k)?!0:!k),N&&C&&(w.current=A.isPropagationStopped(),w.current||A.stopPropagation())})})});y1.displayName=v1;var pm=g.forwardRef((n,r)=>{const{__scopeCheckbox:o,name:s,checked:c,defaultChecked:u,required:m,disabled:h,value:v,onCheckedChange:p,form:b,...y}=n;return f.jsx(Qj,{__scopeCheckbox:o,checked:c,defaultChecked:u,disabled:h,required:m,onCheckedChange:p,name:s,form:b,value:v,internal_do_not_use_render:({isFormControl:w})=>f.jsxs(f.Fragment,{children:[f.jsx(y1,{...y,ref:r,__scopeCheckbox:o}),w&&f.jsx(w1,{__scopeCheckbox:o})]})})});pm.displayName=xc;var b1="CheckboxIndicator",x1=g.forwardRef((n,r)=>{const{__scopeCheckbox:o,forceMount:s,...c}=n,u=hm(b1,o);return f.jsx(Uo,{present:s||Ga(u.checked)||u.checked===!0,children:f.jsx(Le.span,{"data-state":E1(u.checked),"data-disabled":u.disabled?"":void 0,...c,ref:r,style:{pointerEvents:"none",...n.style}})})});x1.displayName=b1;var S1="CheckboxBubbleInput",w1=g.forwardRef(({__scopeCheckbox:n,...r},o)=>{const{control:s,hasConsumerStoppedPropagationRef:c,checked:u,defaultChecked:m,required:h,disabled:v,name:p,value:b,form:y,bubbleInput:w,setBubbleInput:C}=hm(S1,n),N=We(o,C),E=$b(u),T=jb(s);g.useEffect(()=>{const k=w;if(!k)return;const O=window.HTMLInputElement.prototype,L=Object.getOwnPropertyDescriptor(O,"checked").set,Z=!c.current;if(E!==u&&L){const V=new Event("click",{bubbles:Z});k.indeterminate=Ga(u),L.call(k,Ga(u)?!1:u),k.dispatchEvent(V)}},[w,E,u,c]);const A=g.useRef(Ga(u)?!1:u);return f.jsx(Le.input,{type:"checkbox","aria-hidden":!0,defaultChecked:m??A.current,required:h,disabled:v,name:p,value:b,form:y,...r,tabIndex:-1,ref:N,style:{...r.style,...T,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});w1.displayName=S1;function Kj(n){return typeof n=="function"}function Ga(n){return n==="indeterminate"}function E1(n){return Ga(n)?"indeterminate":n?"checked":"unchecked"}const N1=g.forwardRef(({className:n,...r},o)=>f.jsx(pm,{ref:o,className:ae("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",n),...r,children:f.jsx(x1,{className:ae("flex items-center justify-center text-current"),children:f.jsx(Li,{className:"h-3.5 w-3.5"})})}));N1.displayName=pm.displayName;const u0=["queued","running"];function Zj(n){return n.map(r=>`${r.id}:${r.name}`).join("\0")}function Fj(n){return n==="claude"||n==="codex"||n==="copilot"}function T1(n){if(n.kind!=="agent.upgrade")return null;const r=n.payload?.agent;return Fj(r)?`${n.nodeId}:${r}`:null}function Wj(n){return n.status==="succeeded"||n.status==="failed"}async function C1(n,r={}){const o=r.getOperation??K0,s=r.pollIntervalMs??2e3,c=r.timeoutMs??24e4,u=Date.now()+c;let m=n;for(;!Wj(m)&&Date.now()<u;)await e_(s),m=await o(n.id);return m}async function Jj(n,r=Z0){const o=new Set(n),s=await Promise.all(u0.map(u=>r({kind:"agent.upgrade",status:u}))),c=new Map;for(const u of s.flat()){if(!u0.includes(u.status)||o.size>0&&!o.has(u.nodeId))continue;const m=T1(u);if(!m)continue;const h=c.get(m);(!h||u.updatedAt>h.updatedAt)&&c.set(m,u)}return c}function e_(n){return new Promise(r=>setTimeout(r,n))}const t_=1500,n_=1e3,a_=9e4;async function R1(n={}){const r=n.fetchHealth??r_,o=n.initialDelayMs??t_,s=n.pollIntervalMs??n_,c=n.previousPid,u=n.reload??(()=>window.location.reload()),m=n.sleep??l_,h=n.timeoutMs??a_,v=Date.now()+h;let p=!1;for(o>0&&await m(o);Date.now()<=v;){const b=o_(await r());if(!b.ok){p=!0,await m(s);continue}if(c===void 0||b.pid!==void 0&&b.pid!==c||p)return u(),!0;await m(s)}return!1}async function r_(){try{const n=await fetch("/api/system/health",{cache:"no-store"}),r=await n.json().catch(()=>null),o=r&&typeof r=="object"&&typeof r.pid=="number"?r.pid:void 0;return{ok:n.ok,pid:o}}catch{return!1}}function o_(n){return typeof n=="boolean"?{ok:n}:n}function l_(n){return new Promise(r=>window.setTimeout(r,n))}function s_(n,r=!0){return r?n?.restartMode==="development"?"Restart dev runtime":n?.updateAvailable?"Restart to update":"Restart runtime":n?.updateAvailable?"Restart follower to update":"Restart follower"}function i_({checkedLabel:n,disableAuthDefault:r,endpoint:o,isLiveLocalNode:s,nodeId:c,nodeName:u,onRefresh:m,pid:h,transportType:v,update:p,workDir:b}){const y=s_(p,s),[w,C]=g.useState(null),[N,E]=g.useState(()=>d0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:v,workDir:b})),[T,A]=g.useState(!1),[k,O]=g.useState(!1),[B,L]=g.useState(!1);g.useEffect(()=>{E(d0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:v,workDir:b}))},[r,o,u,v,b]);async function Z(){if(!c||T||k)return;const ce=p.updateAvailable?"update":"restart",ue=d_(N);if(N.port.trim()&&ue?.port===void 0){_e.error("Runtime restart port must be a positive integer");return}const W=ue?{reason:ce,startArgs:ue}:{reason:ce};A(!0);try{if(s){const _=await F0(W);C({..._,pid:_.pid??h,status:"accepted"}),_e.info(`Restarting ${u} from a detached helper. PID ${_.pid??h??"unknown"} will not stay attached to the original terminal window; follow ${_.logPath} for launch output.`),R1({previousPid:_.pid??h}).then(P=>{P||(A(!1),_e.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout. Refresh the page after the node finishes starting."))}).catch(P=>{A(!1),_e.error(P instanceof Error?P.message:"Runtime restart recovery failed")});return}const ee=await KE(c,W);C({operationId:ee.id,pid:h,status:ee.status}),_e.info(`Restart requested on ${u}. Operation ${Fd(ee.id)} will hand off to a detached process, so the new runtime will not stay attached to the original terminal window.`);const le=await C1(ee,{timeoutMs:6e4}),J=u_(le);C({command:J?.command,logPath:J?.logPath,mode:J?.mode,operationId:le.id,pid:J?.pid??h,status:le.status}),le.status==="succeeded"?(await m?.(),_e.success(`Restart handoff accepted on ${u}. Follow ${J?.logPath??"the node restart log"} for launch output.`)):le.status==="failed"?_e.error(le.error??`Restart failed on ${u}`):_e.info(`Restart operation ${Fd(le.id)} is still ${le.status}. More details will update after the node reports back.`),A(!1)}catch(ee){A(!1),_e.error(ee instanceof Error?ee.message:"Runtime restart failed")}}async function V(){if(!(!s||T||k)){O(!0);try{const ce=await GE();_e.info(`Stopping Meshy process ${ce.pid}`)}catch(ce){O(!1),_e.error(ce instanceof Error?ce.message:"Runtime stop failed")}}}const $=T?"restarting":k?"stopping":w?.status??"idle",G=p.restartMode==="development";return f.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/70 bg-background/70",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border/50",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(zi,{className:"h-3.5 w-3.5 text-primary shrink-0"}),f.jsxs("div",{children:[f.jsx("div",{className:"text-[11px] font-semibold text-foreground leading-tight",children:"Runtime"}),f.jsx("div",{className:"text-[10px] text-muted-foreground leading-tight",children:G?"Development launcher":`Latest ${p.latestVersion??"—"}`})]})]}),f.jsx("div",{className:"flex items-center gap-1.5",children:f.jsx(_t,{variant:p.updateAvailable?"default":"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 font-mono text-[10px]",children:G?"dev":p.updateAvailable?`→ ${p.latestVersion}`:"current"})})]}),f.jsxs("div",{className:"grid grid-cols-2 divide-x divide-border/50 border-b border-border/50",children:[f.jsxs("div",{className:"px-3 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"PID"}),f.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-foreground",children:h??"—"})]}),f.jsxs("div",{className:"px-3 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"Status"}),f.jsx("div",{className:"mt-0.5 text-[11px] text-foreground capitalize",children:$})]})]}),f.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2",children:[f.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Checked ",n]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[s&&f.jsxs(Nf,{children:[f.jsx(Tf,{asChild:!0,children:f.jsxs(Ct,{type:"button",size:"sm",variant:"ghost",disabled:T||k,className:"h-7 rounded-sm px-2 text-[11px] text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:[f.jsx(mT,{className:ae("mr-1 h-3.5 w-3.5",k&&"animate-pulse")}),k?"Stopping":"Stop"]})}),f.jsxs(Xi,{className:"max-w-[22rem] gap-2 rounded-sm p-4",children:[f.jsxs(Qi,{className:"space-y-1",children:[f.jsx(Zi,{className:"text-sm",children:"Stop runtime?"}),f.jsx(Fi,{className:"text-[11px] leading-4",children:"Gracefully stops the current Meshy process without launching a replacement. The dashboard will disconnect until the node is started again."})]}),f.jsxs(Ki,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Ji,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Wi,{className:"h-7 rounded-sm bg-destructive px-2 text-[11px] text-destructive-foreground hover:bg-destructive/90",onClick:()=>{V()},children:"Stop runtime"})]})]})]}),f.jsxs(Nf,{children:[f.jsx(Tf,{asChild:!0,children:f.jsxs(Ct,{type:"button",size:"sm",variant:p.updateAvailable?"default":"outline",disabled:!c||T||k,className:"h-7 rounded-sm px-2 text-[11px]",children:[f.jsx(Ri,{className:ae("mr-1 h-3.5 w-3.5",T&&"animate-spin")}),T?"Restarting…":y]})}),f.jsxs(Xi,{className:"max-w-[28rem] gap-3 rounded-sm p-4",children:[f.jsxs(Qi,{className:"space-y-1",children:[f.jsxs(Zi,{className:"text-sm",children:[y,"?"]}),f.jsxs(Fi,{className:"text-[11px] leading-4",children:["Starts a detached restart helper, shuts down ",s?"the current node":u,", and brings it back with the configured launcher. The new process will not stay attached to the original terminal window."]})]}),f.jsx(c_,{value:N,onChange:E}),f.jsxs(Ki,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Ji,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Wi,{className:"h-7 rounded-sm px-2 text-[11px]",onClick:()=>{Z()},children:y})]})]})]})]})]}),f.jsxs("div",{className:"border-t border-border/50",children:[f.jsxs("button",{type:"button",onClick:()=>L(ce=>!ce),className:"flex w-full items-center justify-between px-3 py-1.5 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(fy,{className:"h-3 w-3"}),"Restart details"]}),f.jsx(Zl,{className:ae("h-3 w-3 transition-transform duration-150",B&&"rotate-180")})]}),B&&f.jsxs("div",{className:"border-t border-border/50 bg-muted/20 px-3 py-2 space-y-1",children:[f.jsx(Er,{label:"Current PID",value:h===void 0?"—":String(h),mono:h!==void 0}),f.jsx(Er,{label:"Restart PID",value:w?.pid===void 0?"Pending":String(w.pid),mono:w?.pid!==void 0}),f.jsx(Er,{label:"Operation",value:w?.operationId?Fd(w.operationId):"Local direct request",mono:!!w?.operationId}),f.jsx(Er,{label:"Status",value:w?.status??(T?"requested":"idle")}),f.jsx(Er,{label:"Launcher",value:w?.command??"Available after restart",mono:!!w?.command}),f.jsx(Er,{label:"Log",value:w?.logPath??"Available after restart",mono:!!w?.logPath}),f.jsx(Er,{label:"Terminal",value:"New process is detached from original terminal"})]})]}),p.detail&&f.jsx("div",{className:"border-t border-border/50 px-3 py-1.5 text-[10px] text-muted-foreground bg-muted/20",children:p.detail})]})}function c_({onChange:n,value:r}){const o=(s,c)=>{n({...r,[s]:c})};return f.jsxs("div",{className:"rounded-lg border border-border/70 bg-muted/30 p-3 space-y-3",children:[f.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Startup arguments"}),f.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[f.jsx(Pl,{label:"HTTP port",value:r.port,onChange:s=>o("port",s),inputMode:"numeric"}),f.jsx(Pl,{label:"Node name",value:r.name,onChange:s=>o("name",s)}),f.jsx(Pl,{label:"Join endpoint",value:r.join,onChange:s=>o("join",s),className:"sm:col-span-2"}),f.jsxs("div",{className:"space-y-1",children:[f.jsx("label",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:"Transport"}),f.jsxs(Sf,{value:r.transport,onValueChange:s=>o("transport",A1(s)),children:[f.jsx(Ii,{className:"h-7 rounded-md border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(wf,{placeholder:"Transport"})}),f.jsxs(Gi,{children:[f.jsx(ua,{className:"py-1 text-[11px]",value:"inherit",children:"current / default"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"direct",children:"direct"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"devtunnel",children:"devtunnel"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"tailscale",children:"tailscale"})]})]})]}),f.jsx(Pl,{label:"Working directory",value:r.workDir,onChange:s=>o("workDir",s)}),f.jsx(Pl,{label:"Config path",value:r.config,onChange:s=>o("config",s),className:"sm:col-span-2"}),f.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[f.jsx("label",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:"GHC tunnel"}),f.jsxs(Sf,{value:r.ghcTunnel,onValueChange:s=>o("ghcTunnel",f_(s)),children:[f.jsx(Ii,{className:"h-7 rounded-sm border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(wf,{placeholder:"GHC tunnel"})}),f.jsxs(Gi,{children:[f.jsx(ua,{className:"py-1 text-[11px]",value:"inherit",children:"current / remembered"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"enable",children:"enable"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"disable",children:"disable"})]})]})]}),f.jsxs("label",{className:"flex items-center gap-2 rounded-md border border-border/60 bg-background/60 px-2 py-1.5 text-[10px] text-foreground sm:col-span-2 cursor-pointer hover:bg-muted/40 transition-colors",children:[f.jsx(N1,{className:"h-3.5 w-3.5",checked:r.disableAuth,onCheckedChange:s=>n({...r,disableAuth:s===!0,disableAuthKnown:!0})}),"Disable auth"]})]})]})}function Pl({className:n,inputMode:r,label:o,onChange:s,value:c}){return f.jsxs("label",{className:ae("space-y-1",n),children:[f.jsx("span",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:o}),f.jsx(bc,{className:"h-7 rounded-md px-2 text-[10px]",inputMode:r,value:c,onChange:u=>s(u.target.value)})]})}function Er({label:n,value:r,mono:o=!1}){return f.jsxs("div",{className:"flex items-start justify-between gap-3 text-[10px]",children:[f.jsx("span",{className:"shrink-0 uppercase tracking-[0.14em] text-muted-foreground",children:n}),f.jsx("span",{className:ae("break-all text-right text-foreground",o&&"font-mono"),children:r})]})}function u_(n){const r=n.result;if(!r||typeof r!="object")return null;const o=r;return o.ok!==!0||typeof o.command!="string"||typeof o.logPath!="string"?null:{ok:!0,mode:o.mode==="package"?"package":"development",command:o.command,logPath:o.logPath,pid:typeof o.pid=="number"?o.pid:void 0}}function d0(n){return{port:m_(n.endpoint),name:n.nodeName,join:"",transport:A1(n.transportType),workDir:n.workDir??"",config:"",disableAuth:n.disableAuthDefault===!0,disableAuthKnown:n.disableAuthDefault!==void 0,ghcTunnel:"inherit"}}function d_(n){const r={},o=Number(n.port.trim());return n.port.trim()&&Number.isInteger(o)&&o>0&&(r.port=o),n.name.trim()&&(r.name=n.name.trim()),n.join.trim()&&(r.join=n.join.trim()),n.transport!=="inherit"&&(r.transport=n.transport),n.workDir.trim()&&(r.workDir=n.workDir.trim()),n.config.trim()&&(r.config=n.config.trim()),n.disableAuthKnown&&(r.disableAuth=n.disableAuth),n.ghcTunnel==="enable"&&(r.ghcTunnel=!0),n.ghcTunnel==="disable"&&(r.ghcTunnel=!1),Object.keys(r).length>0?r:void 0}function A1(n){return n==="direct"||n==="devtunnel"||n==="tailscale"?n:"inherit"}function f_(n){return n==="enable"||n==="disable"?n:"inherit"}function m_(n){if(!n)return"";try{return new URL(n).port||""}catch{return""}}function Fd(n){return n.length<=8?n:n.slice(0,8)}function $l({formatDateTime:n,name:r,status:o,statusVariant:s}){return f.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-border/60 bg-background/70 px-2.5 py-1.5",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[11px] font-medium text-foreground",children:r}),f.jsx("div",{className:"text-[10px] text-muted-foreground",children:n(o?.checkedAt)})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof o?.authenticated=="boolean"&&f.jsx(_t,{variant:o.authenticated?"default":"outline",className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o.authenticated?"auth ok":"auth required"}),f.jsx(_t,{variant:s(o?.status),className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o?.status??"unknown"})]})]})}function qt(n){if(n==null||n==="")return"Unavailable";const r=new Date(n);return Number.isNaN(r.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(r)}function h_(n){const r=Math.max(0,Math.floor(n)),o=Math.floor(r/86400),s=Math.floor(r%86400/3600),c=Math.floor(r%3600/60);return o>0?`${o}d ${s}h`:s>0?`${s}h ${c}m`:`${c}m`}function f0(n){if(n==null||Number.isNaN(n))return"Unavailable";const r=["B","KB","MB","GB","TB"];let o=n,s=0;for(;o>=1024&&s<r.length-1;)o/=1024,s+=1;return`${o.toFixed(o>=10||s===0?0:1)} ${r[s]}`}function Co(n){return n==="ok"?"default":n==="missing"||n==="install-failed"||n==="login-failed"?"destructive":n==="not-authenticated"||n==="unsupported-platform"?"outline":"secondary"}function p_(n){return n.available?f.jsx("span",{"data-agent-availability":"available","aria-label":"Available",title:"Available",className:"inline-flex h-5 w-5 items-center justify-center text-emerald-500",children:f.jsx(Ro,{className:"h-3.5 w-3.5"})}):f.jsx("span",{"data-agent-availability":"unavailable","aria-label":"Unavailable",title:"Unavailable",className:"inline-flex h-5 w-5 items-center justify-center text-destructive",children:f.jsx(sf,{className:"h-3.5 w-3.5"})})}function g_(n){return n.update?n.update.updateAvailable?f.jsxs(_t,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Update ",n.update.latestVersion]}):f.jsx(_t,{variant:"secondary",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:"Up to date"}):null}function v_(n){return n.available?null:n.metadataStatus??null}function y_(n){const r=`npm install -g ${n.update?.packageName}@latest`;return n.id==="claude"?`${r} --include=optional --ignore-scripts=false`:r}function b_(n){return n.error?n.error:n.result?.detail??null}function Fe({label:n,value:r,mono:o=!1}){return f.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border/50 py-1 last:border-b-0 last:pb-0 first:pt-0",children:[f.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:n}),f.jsx("span",{className:ae("break-all text-right text-[11px] text-foreground",o&&"font-mono text-[11px]"),children:r})]})}function ql({label:n,value:r,mono:o=!1,className:s}){return f.jsxs("div",{className:ae("min-w-0 space-y-0.5",s),children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:n}),f.jsx("div",{className:ae("truncate text-[11px] text-foreground",o&&"font-mono",n==="Path"&&"break-all whitespace-normal"),children:r})]})}function x_({agent:n,nodeName:r,activeOperation:o,onUpgrade:s}){const c=n.update?.updateAvailable===!0,u=g_(n),m=!!o,h=v_(n);return f.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/65 px-3 py-2.5 transition-colors hover:bg-background/85",children:[f.jsxs("div",{className:"grid gap-3 lg:grid-cols-[12rem_minmax(0,1fr)_auto] lg:items-start",children:[f.jsxs("div",{className:"min-w-0 space-y-1.5",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[f.jsx(ny,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),f.jsx("span",{className:"truncate",children:n.label})]}),f.jsxs("div",{className:"truncate text-[10px] text-muted-foreground",children:["Command: ",f.jsx("span",{className:"font-mono text-[10px]",children:n.command})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[p_(n),h&&f.jsx(_t,{variant:Co(h),className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:h})]})]}),f.jsxs("div",{className:"grid min-w-0 gap-x-4 gap-y-1.5 sm:grid-cols-2",children:[f.jsx(ql,{label:"Version",value:n.version??"Unavailable",mono:!!n.version}),n.update&&f.jsx(ql,{label:"Latest",value:n.update.latestVersion??"Unavailable",mono:!!n.update.latestVersion}),f.jsx(ql,{label:"Checked",value:qt(n.checkedAt)}),n.update&&f.jsx(ql,{label:"Update check",value:qt(n.update.checkedAt)}),f.jsx(ql,{label:"Path",value:n.path??"Not on PATH",mono:!!n.path,className:"sm:col-span-2"})]}),f.jsx("div",{className:"flex items-start justify-start lg:justify-end",children:o?f.jsxs(_t,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Upgrade ",o.status]}):c?f.jsxs(Nf,{children:[f.jsx(Tf,{asChild:!0,children:f.jsx("button",{type:"button",disabled:m,className:"rounded-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60",children:u})}),f.jsxs(Xi,{children:[f.jsxs(Qi,{children:[f.jsxs(Zi,{children:["Upgrade ",n.label,"?"]}),f.jsxs(Fi,{children:["This runs ",y_(n)," on ",r,". Remote nodes execute the command on the remote machine."]})]}),f.jsxs(Ki,{children:[f.jsx(Ji,{children:"Cancel"}),f.jsx(Wi,{onClick:()=>s(n),children:"Upgrade"})]})]})]}):u})]}),n.update?.detail&&f.jsx("div",{className:"mt-2 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:n.update.detail}),n.detail&&f.jsx("div",{className:"mt-2 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:n.detail})]})}function S_(n,r){return n?.nodes?.length?n.nodes:r?[r]:[]}function w_(n,r){if(r&&n.id===r.nodeId)return r;const o=n.settingsSnapshot;return{...n,nodeId:n.id,version:o?.version??"Unavailable",packageName:o?.packageName,uptime:o?.uptime??0,localDashboardOrigin:o?.runtime?.localDashboardOrigin??void 0,auth:o?.auth,os:o?.os,runtime:o?.runtime,runtimeUpdate:o?.runtimeUpdate,agents:o?.agents,startupRequirements:o?.startupRequirements,components:o?.components,repository:o?.repository,packages:o?.packages}}function E_(n,r){return n.id===r?`${n.name} (this node)`:`${n.name} (${n.role})`}function N_(n){return n==="claude"?"Claude Code":n==="copilot"?"Copilot CLI":"Codex"}function T_(n){const r=n.payload?.agent;return r==="claude"||r==="codex"||r==="copilot"?r:null}function C_({cluster:n,systemInfo:r,sseConnected:o,initialSelectedNodeId:s,onRefresh:c}){const u=g.useMemo(()=>S_(n,r),[n,r]),[m,h]=g.useState(()=>s??r?.nodeId??n?.self?.id??""),[v,p]=g.useState(()=>new Map),b=g.useRef(new Set),y=g.useRef(new Set),w=n?.self??r??u[0]??null,C=u.find(G=>G.id===m)??w,N=C?w_(C,r):null,E=!!(r&&C&&C.id===r.nodeId),T=E||!!C?.settingsSnapshot,A=N?.runtimeUpdate,k=N?.startupRequirements?.components??N?.components??{},O=g.useMemo(()=>u.map(G=>G.id),[u]),B=O.join("\0"),L=Zj(u),Z=g.useMemo(()=>new Map(u.map(G=>[G.id,G.name])),[L]);g.useEffect(()=>{s&&O.includes(s)&&h(s)},[s,B]);const V=g.useCallback(async(G,ce)=>{const ue=T1(G);if(!ue||b.current.has(G.id))return;const W=T_(G),ee=ce?.agentLabel??(W?N_(W):"Agent"),le=ce?.nodeName??Z.get(G.nodeId)??G.nodeId;b.current.add(G.id),p(J=>new Map(J).set(ue,G));try{const J=await C1(G);if(J.status==="succeeded")await c?.(),y.current.has(J.id)||(_e.success(`${ee} upgrade finished on ${le}`),y.current.add(J.id));else if(J.status==="failed")y.current.has(J.id)||(_e.error(b_(J)??`${ee} upgrade failed`),y.current.add(J.id));else{p(_=>new Map(_).set(ue,J)),_e.info(`${ee} upgrade is still ${J.status} on ${le}`);return}p(_=>{const P=new Map(_),X=P.get(ue);return(!X||X.id===J.id)&&P.delete(ue),P})}catch(J){p(_=>{const P=new Map(_),X=P.get(ue);return(!X||X.id===G.id)&&P.delete(ue),P}),_e.error(J instanceof Error?J.message:`${ee} upgrade failed`)}finally{b.current.delete(G.id)}},[c,Z]);g.useEffect(()=>{if(O.length===0)return;let G=!1;async function ce(){let ue;try{ue=await Jj(O)}catch{return}if(!G){p(W=>{const ee=new Map(W);for(const[le,J]of ue)ee.set(le,J);return ee});for(const W of ue.values())V(W)}}return ce(),()=>{G=!0}},[V,B]);async function $(G){if(C)try{const ce=await QE(C.id,G.id);_e.info(`${G.label} upgrade started on ${C.name}`),await V(ce,{agentLabel:G.label,nodeName:C.name})}catch(ce){_e.error(ce instanceof Error?ce.message:`${G.label} upgrade failed`)}}return!C||!N?f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-5 text-center text-[11px] text-muted-foreground",children:"Loading session metadata..."}):f.jsxs("div",{className:"space-y-3",children:[f.jsxs("section",{className:"relative mt-1 rounded-sm border border-border/70 bg-background/75 p-3 shadow-none",children:[!E&&f.jsxs(_t,{variant:"outline",className:"absolute right-3 top-2.5 rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em] whitespace-nowrap",children:["Updated ",qt(C.settingsSnapshot?.collectedAt)]}),f.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-end md:justify-between",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.jsxs("span",{className:"flex items-center gap-1.5 rounded-sm border border-border/70 bg-background/75 px-1.5 py-0 text-[10px] text-muted-foreground",children:[f.jsx(hj,{status:C.status}),f.jsx("span",{className:"font-medium text-foreground",children:C.name})]}),f.jsx(pj,{role:C.role}),f.jsx(_t,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:C.transportType??N.transportType??"direct"}),f.jsx(_t,{variant:E?"default":"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:E?"Live local session":"Leader-synced snapshot"})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.34em] text-muted-foreground",children:"Session"}),f.jsx("h3",{className:"mt-0.5 text-sm font-semibold tracking-tight text-foreground",children:"Node runtime"}),f.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Runtime environment, connectivity, and build metadata."})]}),u.length>1&&f.jsxs("div",{className:"w-48 space-y-1.5",children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Inspect node"}),f.jsxs(Sf,{value:C.id,onValueChange:h,children:[f.jsx(Ii,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px]",children:f.jsx(wf,{placeholder:"Choose a node"})}),f.jsx(Gi,{className:"settings-node-select-content rounded-sm text-[10px] leading-4",children:u.map(G=>f.jsx(ua,{value:G.id,className:"settings-node-select-item py-1 pl-6 pr-2 text-[10px] leading-4 [&>span]:left-1.5 [&_svg]:h-3 [&_svg]:w-3",children:E_(G,r?.nodeId)},G.id))})]})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(_t,{variant:o?"default":"outline",className:"gap-1 rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:[f.jsx(pT,{className:"h-3 w-3"}),o?"Live link":"Reconnecting"]}),f.jsxs(_t,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:["Uptime ",h_(N.uptime)]})]})]})]}),!T&&f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-[11px] text-muted-foreground",children:"This node has not synced its settings snapshot to the leader yet. Wait for the next keepalive and reopen the dialog if needed."}),f.jsxs(Jk,{defaultValue:"session",className:"space-y-2",children:[f.jsxs(Gx,{className:"h-auto flex-wrap rounded-sm border border-border/60 bg-muted/40 p-0.5",children:[f.jsx(Il,{value:"session",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Session"}),f.jsx(Il,{value:"access",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Access"}),f.jsx(Il,{value:"quick-chats",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Quick chats"}),f.jsx(Il,{value:"about",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"About"})]}),f.jsxs(Gl,{value:"session",className:"mt-0 grid gap-2 xl:grid-cols-[1.15fr_0.85fr]",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(uy,{className:"h-3.5 w-3.5 text-primary"}),"Selected node"]}),f.jsx(Nn,{className:"text-[10px]",children:"Cluster role, identity, and node-scoped runtime state."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Node ID",value:N.nodeId,mono:!0}),f.jsx(Fe,{label:"Status",value:C.status}),f.jsx(Fe,{label:"Role",value:C.role}),f.jsx(Fe,{label:"Endpoint",value:C.endpoint,mono:!0}),f.jsx(Fe,{label:"Joined",value:qt(C.joinedAt)}),f.jsx(Fe,{label:"Heartbeat",value:qt(C.lastHeartbeat)}),f.jsx(Fe,{label:"Capabilities",value:C.capabilities.length>0?C.capabilities.join(", "):"None"})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(QN,{className:"h-3.5 w-3.5 text-primary"}),"OS info"]}),f.jsx(Nn,{className:"text-[10px]",children:"Host and resource details reported by the current process."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Host",value:N.os?.hostname??"Unavailable"}),f.jsx(Fe,{label:"Platform",value:N.os?`${N.os.platform} ${N.os.release}`:"Unavailable"}),f.jsx(Fe,{label:"Arch",value:N.os?.arch??"Unavailable"}),f.jsx(Fe,{label:"CPU",value:N.os?.cpuModel??"Unavailable"}),f.jsx(Fe,{label:"Cores",value:String(N.os?.cpuCount??"Unavailable")}),f.jsx(Fe,{label:"Memory",value:N.os?`${f0(N.os.freeMemoryBytes)} free / ${f0(N.os.totalMemoryBytes)} total`:"Unavailable"})]})]}),A&&f.jsx("div",{className:"xl:col-span-2",children:f.jsx(i_,{checkedLabel:qt(A.checkedAt),disableAuthDefault:N.auth?.enabled===void 0?void 0:N.auth.enabled===!1,endpoint:C.endpoint,isLiveLocalNode:E,nodeId:C.id,nodeName:C.name,onRefresh:c,pid:N.runtime?.pid,transportType:C.transportType,update:A,workDir:N.runtime?.workDir??C.workDir})}),f.jsx(Uj,{nodeId:C.id,nodeName:C.name}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none xl:col-span-2",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(ny,{className:"h-3.5 w-3.5 text-primary"}),"Available agents"]}),f.jsx(Nn,{className:"text-[10px]",children:E?"Live command availability for runtime agents on this node.":"Most recent agent availability snapshot synced from this node."})]}),f.jsx(Tn,{"data-agent-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:(N.agents??[]).map(G=>f.jsx(x_,{agent:G,nodeName:C.name,activeOperation:v.get(`${C.id}:${G.id}`),onUpgrade:$},G.id))})]})]}),f.jsxs(Gl,{value:"access",className:"mt-0 grid gap-2 xl:grid-cols-2",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(ay,{className:"h-3.5 w-3.5 text-primary"}),"Access surface"]}),f.jsx(Nn,{className:"text-[10px]",children:"How this node is exposed to the dashboard and other peers."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Transport",value:C.transportType??N.transportType??"direct"}),f.jsx(Fe,{label:"Node URL",value:C.endpoint,mono:!0}),f.jsx(Fe,{label:"Node tunnel",value:C.devtunnelEndpoint??"Disabled",mono:!!C.devtunnelEndpoint}),f.jsx(Fe,{label:"Dashboard URL",value:C.dashboardOrigin??N.localDashboardOrigin??"Unavailable",mono:!!(C.dashboardOrigin||N.localDashboardOrigin)}),f.jsx(Fe,{label:"Local dashboard",value:N.localDashboardOrigin??"Unavailable",mono:!!N.localDashboardOrigin})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(CT,{className:"h-3.5 w-3.5 text-primary"}),"Auth"]}),f.jsx(Nn,{className:"text-[10px]",children:"Current bearer-auth and trusted access posture."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Enabled",value:N.auth?.enabled?"Yes":"No"}),f.jsx(Fe,{label:"Same tenant",value:N.auth?.allowSameTenant?"Allowed":"Off"}),f.jsx(Fe,{label:"Allowed users",value:N.auth?.allowedUsers.length?N.auth.allowedUsers.join(", "):"None"})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(FN,{className:"h-3.5 w-3.5 text-primary"}),"Paths"]}),f.jsx(Nn,{className:"text-[10px]",children:"Workspace and runtime paths currently used by this node."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Work dir",value:N.runtime?.workDir??N.workDir??"Unavailable",mono:!!(N.runtime?.workDir??N.workDir)}),f.jsx(Fe,{label:"Storage",value:N.runtime?.storagePath??"Unavailable",mono:!!N.runtime?.storagePath}),f.jsx(Fe,{label:"Process cwd",value:N.runtime?.cwd??"Unavailable",mono:!!N.runtime?.cwd}),f.jsx(Fe,{label:"Started",value:qt(N.runtime?.startedAt)}),f.jsx(Fe,{label:"PID",value:N.runtime?String(N.runtime.pid):"Unavailable",mono:!!N.runtime})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(zi,{className:"h-3.5 w-3.5 text-primary"}),"Startup checks"]}),f.jsx(Nn,{className:"text-[10px]",children:"Dependency preflight snapshot persisted during node startup."})]}),f.jsxs(Tn,{className:"space-y-3 px-3 pb-2.5",children:[f.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/70 px-3 py-2",children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Last checked"}),f.jsx("div",{className:"mt-0.5 text-[11px] text-foreground",children:qt(N.startupRequirements?.lastCheckedAt)})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx($l,{formatDateTime:qt,name:"Azure CLI",status:k.az,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"DevTunnel",status:k.devtunnel,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Claude Code",status:k.claude,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Codex",status:k.codex,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Copilot CLI",status:k.copilot,statusVariant:Co})]})]})]})]}),f.jsx(Gl,{value:"quick-chats",className:"mt-0",children:f.jsx(Ij,{})}),f.jsx(yj,{formatDateTime:qt,viewInfo:N})]})]})}function R_({initialSelectedNodeId:n,open:r,onOpenChange:o,showTrigger:s=!0}={}){const{cluster:c,systemInfo:u,sseConnected:m,refresh:h}=ey();return f.jsx(q5,{open:r,onOpenChange:o,showTrigger:s,children:f.jsx(C_,{cluster:c,systemInfo:u,sseConnected:m,initialSelectedNodeId:n,onRefresh:h})})}const tc="meshy:show-live-events";function k1(){const n=globalThis.window;if(!n)return;const r=typeof n.CustomEvent=="function"?new n.CustomEvent(tc):new n.Event(tc);n.dispatchEvent(r)}function sM(n){const r=globalThis.window;return r?(r.addEventListener(tc,n),()=>r.removeEventListener(tc,n)):()=>{}}const A_={node:"border-teal-500/30 bg-teal-500/10 text-teal-700 dark:text-teal-300",task:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",election:"border-indigo-500/30 bg-indigo-500/10 text-indigo-700 dark:text-indigo-300",cluster:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",transport:"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300"},k_={node:"text-teal-700/70 dark:text-teal-300/70",task:"text-amber-700/70 dark:text-amber-300/70",election:"text-indigo-700/70 dark:text-indigo-300/70",cluster:"text-emerald-700/70 dark:text-emerald-300/70",transport:"text-sky-700/70 dark:text-sky-300/70"};function j_(n){return n.split(".")[0]??"unknown"}function __(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function No(n,r,o){return typeof o=="string"&&o.length>0?o:r?.get(n)??n}function j1(n,r){const o=n.data,s=o.operation;switch(n.type){case"node.joined":return`${o.name} joined the cluster`;case"node.left":return`${No(o.nodeId,r,o.name)} left (${o.reason})`;case"node.status":return`${No(o.nodeId,r)} is now ${o.status}`;case"node.operation.created":return`${s?.kind} ${s?.status} on ${No(s?.nodeId,r)}`;case"node.operation.updated":return`${s?.kind} ${s?.status} on ${No(s?.nodeId,r)}`;case"transport.changed":return`${No(o.nodeId,r)} transport switched to ${o.transportType}`;case"task.created":return`"${o.title}" created`;case"task.assigned":return`task assigned to ${No(o.nodeId,r)}`;case"task.status":return`task ${o.taskId.slice(0,8)} -> ${o.status}`;case"election.started":return`candidate ${o.candidateId.slice(0,8)} term ${o.term}`;case"election.complete":return`leader elected, term ${o.term}`;case"cluster.state":return`${o.nodeCount} nodes, term ${o.term}`;default:return JSON.stringify(o)}}function O_(n){return JSON.stringify(n,null,2)}function M_({events:n,maxHeight:r="400px",nodeNameById:o,onDismiss:s,onSelect:c,density:u="default"}){if(n.length===0)return null;const m=u==="compact";return f.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:r},children:f.jsx("div",{className:"space-y-1.5",children:n.map(h=>{const v=j_(h.type);return f.jsx("div",{onClick:c?()=>c(h.id):void 0,onKeyDown:c?p=>{p.target===p.currentTarget&&(p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),c(h.id)))}:void 0,"data-click-open-live-events":c?"true":void 0,role:c?"button":void 0,tabIndex:c?0:void 0,title:c?"Open in Live events":void 0,className:ae("transition-colors hover:bg-muted/30",c&&"cursor-pointer",m?"rounded-sm px-1 py-0.5":"rounded-sm px-1.5 py-1"),children:f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.jsx("div",{className:ae("font-mono text-muted-foreground",m?"text-[8px]":"text-[9px]"),children:__(h.timestamp)}),m?f.jsx("span",{className:ae("max-w-[8.5rem] truncate text-[7px] font-medium uppercase tracking-[0.08em] text-muted-foreground/70",k_[v]),children:h.type}):f.jsx(_t,{variant:"outline",className:ae("w-fit text-[9px] font-medium uppercase tracking-[0.14em] px-1.5 py-0",A_[v]),children:h.type})]}),f.jsxs("div",{className:ae("flex shrink-0 items-center",m?"gap-px":"gap-0.5"),children:[f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",className:ae("rounded-sm text-muted-foreground hover:text-foreground",m?"h-3.5 w-3.5 p-0 opacity-65 hover:bg-muted/40 hover:opacity-100 [&_svg]:size-2.5":"h-5 w-5"),onClick:p=>{p.stopPropagation(),h1(O_(h),"Event copied")},"aria-label":`Copy ${h.type} event`,title:"Copy event",children:f.jsx(ry,{className:m?"h-2.5 w-2.5":"h-3 w-3"})}),s&&f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",className:ae("rounded-sm text-muted-foreground hover:text-foreground",m?"h-3.5 w-3.5 p-0 opacity-65 hover:bg-muted/40 hover:opacity-100 [&_svg]:size-2.5":"h-5 w-5"),onClick:p=>{p.stopPropagation(),s(h.id)},"aria-label":`Dismiss ${h.type} event`,title:"Dismiss event",children:f.jsx(my,{className:m?"h-2.5 w-2.5":"h-3 w-3"})})]})]}),f.jsx("div",{className:"text-[9px] leading-snug text-foreground/85",children:j1(h,o)})]})},h.id)})})})}function _1(n){return n!==null}function O1(n){return n==="click"?n:"hover"}function Af(n){return n==="hover"?null:n}function M1(n){return n==="click"?null:"click"}const D_=["node.","election.","transport."],z_="cluster.state";function L_(n){return n.type==="node.status"?!1:D_.some(r=>n.type.startsWith(r))}function U_(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function B_(n,r){return n?{time:U_(n.timestamp),text:j1(n,r)}:null}function H_(n){return n.transportType==="devtunnel"||!!n.devtunnelEndpoint}function P_(n){if(n.length===0)return"No node tunnel";const r=n.filter(c=>c.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(c=>c.devtunnelHealth?.status==="failed").length;if(o>0)return`${o} failed`;const s=n.filter(c=>c.status!=="offline"&&c.devtunnelHealth?.status!=="healthy").length;return s>0?`${s} checking`:"Healthy"}function $_(n,r){const o=r?.get(n.id)??n.name??n.id;if(n.status==="offline")return{label:o,status:"offline"};const s=n.devtunnelHealth?.status??"checking";return{label:o,status:s}}function q_(n){if(n.length===0)return"No nodes";const r=n.filter(s=>s.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(s=>s.status==="busy").length;return o>0?`${o} busy`:"Healthy"}function V_(n,r){return{label:r?.get(n.id)??n.name??n.id,status:n.status}}function Y_({connected:n,events:r,nodes:o=[],currentNode:s=null,nodeNameById:c,desktopUpdate:u=null,desktopUpdateCheckPending:m=!1,desktopUpdateProgress:h=null,defaultOpen:v=!1,defaultActionMenuOpen:p=!1,onDesktopUpdateCheck:b,onDesktopUpdate:y,onDesktopRestart:w,onReload:C,onRestart:N}){const[E,T]=g.useState(v?"click":null),[A,k]=g.useState(p),[O,B]=g.useState(!0),[L,Z]=g.useState(new Set),[V,$]=g.useState(!1),[G,ce]=g.useState(!1),ue=_1(E),W=g.useRef(null),ee=g.useRef(null),le=g.useMemo(()=>r.filter(ye=>L_(ye)&&!L.has(ye.id)),[r,L]),J=g.useMemo(()=>r.find(ye=>ye.type===z_)??le[0],[r,le]),_=g.useMemo(()=>B_(J,c),[J,c]),P=g.useMemo(()=>{const ye=new Map(o.map(Xe=>[Xe.id,Xe]));return s&&ye.set(s.id,s),Array.from(ye.values())},[s,o]),X=g.useMemo(()=>P.filter(H_),[P]),fe=X.some(ye=>ye.status==="offline"||ye.devtunnelHealth?.status==="failed"),R=P.some(ye=>ye.status==="offline"),Y=P.some(ye=>ye.status==="busy"),se=P.length>0,Q=s?.name??"offline",oe=s?.role==="leader"?"Leader":s?.role==="follower"?"Follower":"Node",te=u!==null,ne=!!(te&&u?.updateAvailable&&u.latestVersion),ie=u?.latestVersion??null,de=!!(te&&!ne&&ie),xe=!!(te&&u?.detail==="Checking desktop update..."),Ce=!!(te&&!ne&&!ie&&u?.detail&&!xe),Ne=h?.percent??null,Re=Ne===null?null:`${Ne}%`,et=V?"Relaunching runtime...":"Relaunch to apply update",rt=Re?`Downloading ${Re}`:G?"Downloading and installing desktop update...":ne&&ie?`Available version ${ie}`:Ce?u?.detail??"Desktop update unavailable":"Desktop is current",hn=!!C,pn=!!(te&&w),er=!!(te&&b)||hn||pn,pt=te||!!N,_r=te||!!N||hn,Yn=pt?te?ne?"Update":de?"Latest":"Check":"Relaunch":"Reload",it=te&&!ne,gn=it?"Check":Yn,Or=pt?te?rt:et:"Reload dashboard page",ga=pt?te?G||h!==null:V:!1,Yt=pt?te?ga||!ne||!y:ga:!1,Rt=m||G||!b,Lt=te?ne&&ie?`Install desktop update ${ie}`:Ce?"Desktop update unavailable":"Desktop is current":pt?V?"Relaunching runtime":"Relaunch runtime":"Reload dashboard page";function Je(){ee.current&&(clearTimeout(ee.current),ee.current=null)}function On(){Je(),T(ye=>O1(ye))}function Mr(){Je(),ee.current=setTimeout(()=>{T(ye=>Af(ye)),ee.current=null},180)}function Mn(){Je()}function va(){Je(),T(ye=>Af(ye))}async function ya(){if(!(!N||V)){$(!0);try{await N()}finally{$(!1)}}}async function nn(){if(!(!ne||!y||G)){ce(!0);try{await y()}finally{ce(!1)}}}async function In(){!b||m||G||await b()}async function Gn(){if(!(!w||V)){k(!1),$(!0);try{await w()}finally{$(!1)}}}async function ba(){if(!pt){await Ut();return}if(te){await nn();return}await ya()}async function Ut(){C&&(k(!1),await C())}function tr(){Z(ye=>{const Xe=new Set(ye);return le.forEach(me=>Xe.add(me.id)),Xe})}function nr(){k1(),T(null)}return g.useEffect(()=>()=>{Je()},[]),g.useEffect(()=>{Z(ye=>{if(ye.size===0)return ye;const Xe=new Set(r.map(He=>He.id)),me=new Set(Array.from(ye).filter(He=>Xe.has(He)));return me.size===ye.size?ye:me})},[r]),g.useEffect(()=>{ue||k(!1)},[ue]),g.useEffect(()=>{if(!ue)return;const ye=me=>{W.current?.contains(me.target)||(Je(),k(!1),T(null))},Xe=me=>{me.key==="Escape"&&(Je(),k(!1),T(null))};return document.addEventListener("pointerdown",ye),document.addEventListener("keydown",Xe),()=>{document.removeEventListener("pointerdown",ye),document.removeEventListener("keydown",Xe)}},[ue]),f.jsxs("div",{ref:W,className:"relative",children:[f.jsxs("button",{type:"button","aria-label":n?"Cluster link connected":"Cluster link reconnecting","aria-expanded":ue,"aria-haspopup":"dialog",onClick:()=>T(ye=>M1(ye)),onMouseEnter:On,onMouseLeave:Mr,className:ae("flex h-8 max-w-[18rem] items-center gap-1.5 rounded-sm px-2 text-[10px] transition-all sm:gap-2 sm:px-2.5 sm:text-[11px]",n?"bg-muted/40 text-muted-foreground hover:bg-muted/60 hover:text-foreground":"bg-destructive/8 text-destructive hover:bg-destructive/12",ue&&(n?"bg-muted/60 text-foreground":"bg-destructive/12")),title:n?"Cluster link connected":"Cluster link reconnecting",children:[f.jsxs("span",{className:ae("relative flex h-2 w-2 shrink-0"),children:[n&&f.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-60"}),f.jsx("span",{className:ae("relative inline-flex h-2 w-2 rounded-full",n?"bg-emerald-500":"bg-destructive")})]}),f.jsxs("span",{className:"hidden min-w-0 items-center gap-2 sm:flex",children:[f.jsx("span",{className:"truncate font-medium text-foreground",children:Q}),f.jsx("span",{className:ae("shrink-0 rounded border px-1 py-px text-[8px] font-semibold uppercase tracking-[0.1em]",n?"border-emerald-500/25 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:oe})]})]}),ue&&f.jsxs("div",{role:"dialog","aria-label":"Live link connection events",onMouseEnter:Mn,onMouseLeave:va,className:"absolute right-0 top-[calc(100%+0.35rem)] z-50 w-[17rem] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-sm border border-border/60 bg-popover/98 shadow-[0_16px_44px_-34px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-sm max-sm:fixed max-sm:right-3 max-sm:top-[3.75rem] max-sm:w-[calc(100vw-1.5rem)]",children:[f.jsx("div",{className:"border-b border-border/60 bg-muted/25 px-2.5 py-1.5",children:f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[n?f.jsx(zi,{className:"h-3 w-3 text-emerald-500"}):f.jsx(DT,{className:"h-3 w-3 text-destructive"}),f.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:"Live link"}),f.jsx("span",{className:"text-[9px] text-muted-foreground",children:n?"· SSE connected":"· reconnecting"})]}),f.jsx("div",{className:ae("rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.12em]",n?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:n?"Connected":"Retrying"})]})}),f.jsxs("div",{className:"grid grid-cols-2 border-b border-border/60",children:[f.jsxs("div",{className:"border-r border-border/60 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Events"}),f.jsx("div",{className:"mt-0.5 text-base font-semibold tracking-tight text-foreground",children:le.length})]}),f.jsxs("div",{className:"min-w-0 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Latest"}),_?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mt-0.5 truncate text-[9px] leading-snug text-foreground/80",children:_.text}),f.jsx("div",{className:"font-mono text-[8px] text-muted-foreground/60",children:_.time})]}):f.jsx("div",{className:"mt-0.5 text-[8px] text-muted-foreground/50",children:"—"})]})]}),f.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[R?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):Y?f.jsx(zi,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Ro,{className:ae("h-3 w-3 shrink-0",se?"text-emerald-500":"text-muted-foreground")}),f.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Node health"})]}),f.jsx("span",{className:ae("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",R?"border-destructive/30 bg-destructive/10 text-destructive":Y?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":se?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-border/70 bg-background/60 text-muted-foreground"),children:q_(P)})]}),P.length>0&&f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:P.map(ye=>{const{label:Xe,status:me}=V_(ye,c),He=me==="offline",Qe=me==="busy";return f.jsxs("div",{"aria-label":`${Xe} ${me}`,className:ae("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",He?"bg-destructive/6":Qe?"bg-amber-500/6":"bg-emerald-500/5"),title:`${Xe} ${me}`,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),He?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):Qe?f.jsx(Tv,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},ye.id)})})]}),X.length>0&&f.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[fe?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"}),f.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"DevTunnel"})]}),f.jsx("span",{className:ae("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",fe?"border-destructive/30 bg-destructive/10 text-destructive":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:P_(X)})]}),f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:X.map(ye=>{const{label:Xe,status:me}=$_(ye,c),He=me==="failed"||me==="offline",Qe=me!=="healthy"&&me!=="failed"&&me!=="offline",gt=ye.devtunnelHealth?.reason?`${Xe} ${me}: ${ye.devtunnelHealth.reason}`:`${Xe} ${me}`;return f.jsxs("div",{"aria-label":`${Xe} ${me}`,className:ae("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",He?"bg-destructive/6":Qe?"bg-muted/30":"bg-emerald-500/5"),title:gt,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),He?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):Qe?f.jsx(Tv,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},ye.id)})})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1",children:[f.jsxs("button",{type:"button",onClick:()=>B(ye=>!ye),className:"flex min-w-0 flex-1 items-center justify-between rounded-sm px-0.5 py-0.5 text-left hover:bg-muted/25",children:[f.jsxs("span",{className:"truncate text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:["Notifications ",le.length>0&&`(${le.length})`]}),O?f.jsx(Zl,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(lf,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}),!O&&le.length>0&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px] font-medium text-muted-foreground hover:text-foreground",onClick:tr,title:"Clear all notifications",children:"Clear all"})]}),O&&f.jsx("div",{className:"px-2 pb-1.5",children:f.jsx(M_,{events:le,maxHeight:"10rem",density:"compact",emptyTitle:"No connection events yet",emptyDescription:"Node, election, and system events will appear here.",nodeNameById:c,onSelect:nr,onDismiss:ye=>Z(Xe=>new Set(Xe).add(ye))})})]}),te&&u?.detail&&!xe&&f.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/60 px-2.5 py-1 text-[8px] text-muted-foreground",children:[f.jsx("span",{className:"shrink-0 font-medium uppercase tracking-[0.12em]",children:"Desktop update"}),f.jsx("span",{className:"truncate",title:u.detail,children:u.detail})]}),f.jsxs("div",{className:"flex items-center justify-between gap-1 border-t border-border/60 px-2.5 py-1",children:[f.jsx("div",{children:_r&&f.jsxs("div",{className:"group/restart relative flex items-center",children:[f.jsxs("div",{className:"flex items-center overflow-hidden rounded-sm border border-border/50",children:[f.jsxs(Ct,{type:"button",variant:"ghost",size:"sm",className:ae("relative h-5 overflow-hidden rounded-none border-0 px-1.5 text-[9px] font-medium hover:text-foreground [&_svg]:size-2.5",ne?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>{ba()},disabled:Yt,"aria-label":Lt,"aria-describedby":"live-link-restart-hint",title:Or,children:[Ne!==null&&f.jsx("span",{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Ne,className:"pointer-events-none absolute inset-y-0 left-0 bg-primary/24",style:{width:`${Ne}%`}}),Ne===null&&f.jsx(Cv,{className:ae("relative z-10 h-2.5 w-2.5",ga&&"animate-pulse")}),f.jsx("span",{className:"relative z-10",children:Re??Yn})]}),er&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:ae("h-5 rounded-none border-l border-border/50 px-1 text-[9px] hover:text-foreground [&_svg]:size-2.5",ne?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>k(ye=>!ye),"aria-label":"Open live link actions","aria-expanded":A,title:"Live link actions",children:f.jsx(Zl,{className:"h-2.5 w-2.5"})})]}),er&&A&&f.jsxs("div",{className:"absolute bottom-[calc(100%+0.25rem)] left-0 z-20 min-w-28 overflow-hidden rounded-sm border border-border/70 bg-background text-[9px] shadow-sm",children:[f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground disabled:opacity-45 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",onClick:()=>{it?In():ba()},disabled:it?Rt:Yt,"aria-label":it?"Check for desktop updates":Lt,children:[it?f.jsx(Ri,{className:ae("h-2.5 w-2.5",m&&"animate-spin")}):f.jsx(Cv,{className:ae("h-2.5 w-2.5",ga&&"animate-pulse")}),f.jsx("span",{children:gn})]}),hn&&f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 border-t border-border/50 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground disabled:opacity-45 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",onClick:()=>{Ut()},"aria-label":"Reload dashboard page",children:[f.jsx(Ri,{className:"h-2.5 w-2.5"}),f.jsx("span",{children:"Reload"})]}),pn&&f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 border-t border-border/50 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground",onClick:()=>{Gn()},disabled:V,"aria-label":"Restart Meshy Desktop",children:[f.jsx(Ri,{className:ae("h-2.5 w-2.5",V&&"animate-spin")}),f.jsx("span",{children:"Restart"})]})]}),f.jsx("span",{id:"live-link-restart-hint",role:"tooltip",className:"pointer-events-none absolute left-6 top-1/2 z-10 -translate-y-1/2 whitespace-nowrap rounded-sm border border-border/70 bg-background px-1.5 py-0.5 text-[8px] text-muted-foreground opacity-0 shadow-sm transition-opacity group-hover/restart:opacity-100 group-focus-within/restart:opacity-100",children:Or})]})}),f.jsxs("div",{className:"flex items-center gap-1",children:[O&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:tr,disabled:le.length===0,title:"Clear all notifications",children:"Clear all"}),f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>T(null),children:"Close"})]})]})]})]})}const m0="dark",kr="fluent",I_="clean",Wd="meshy-layout-default-migrated-to-compact",kf="true",G_="compact",X_=new Set(["airy","clean","fluent"]);function Q_(n){return n!==null&&X_.has(n)}function Sc(n){return n===G_?"fluent":Q_(n)?n:null}function K_(n,r){const o=Sc(n);return o===I_&&r!==kf?kr:o??kr}const nc="symphony",D1="default",Z_=new Set(["light","dark","system"]),F_=new Set(["porcelain","warm","finsight","edge","symphony","launcher"]),z1=g.createContext(null);function W_(n){const r=new URLSearchParams(n).get("theme");return L1(r)?r:null}function J_(n){const r=new URLSearchParams(n).get("palette");return gm(r)}function e3(n){const r=new URLSearchParams(n).get("layout");return Sc(r)}function t3(){if(typeof document>"u")return null;const n=document.documentElement;return{theme:n.classList.contains("dark")?"dark":"light",palette:gm(n.getAttribute("data-palette"))??nc,layout:Sc(n.getAttribute("data-layout"))??kr}}function iM(n,r=t3()){if(!r)return n;try{const o=/^[a-z][a-z\d+\-.]*:/i.test(n),s=typeof window<"u"?window.location.href:"http://localhost",c=new URL(n,s);return c.searchParams.set("theme",r.theme),c.searchParams.set("palette",r.palette),c.searchParams.set("layout",r.layout),o?c.toString():`${c.pathname}${c.search}${c.hash}`}catch{return n}}const Jd=.9;function h0(n){const r=n.trim().match(/^(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)%\s+(-?\d+(?:\.\d+)?)%$/);if(!r)return null;const o=(Number(r[1])%360+360)%360/60,s=ac(Number(r[2])/100,0,1),c=ac(Number(r[3])/100,0,1),u=(1-Math.abs(2*c-1))*s,m=u*(1-Math.abs(o%2-1)),h=c-u/2,[v,p,b]=o<1?[u,m,0]:o<2?[m,u,0]:o<3?[0,u,m]:o<4?[0,m,u]:o<5?[m,0,u]:[u,0,m];return[Math.round((v+h)*255),Math.round((p+h)*255),Math.round((b+h)*255),255]}function n3(n){const r=n.trim();if(!r||r==="transparent")return null;const o=r.match(/^rgba?\(\s*([+-]?\d+(?:\.\d+)?)\s*,\s*([+-]?\d+(?:\.\d+)?)\s*,\s*([+-]?\d+(?:\.\d+)?)(?:\s*,\s*([+-]?\d+(?:\.\d+)?))?\s*\)$/i);if(o)return[To(Number(o[1])),To(Number(o[2])),To(Number(o[3])),v0(o[4])];const s=r.match(/^rgba?\(\s*([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)(?:\s*\/\s*([+-]?\d+(?:\.\d+)?%?))?\s*\)$/i);return s?[To(Number(s[1])),To(Number(s[2])),To(Number(s[3])),v0(s[4])]:null}function a3(n,r,o){const s=h0(n);if(!s)return null;if(o==="clean"||o==="fluent")return s;const c=h0(r);return c?[ef(s[0],c[0],Jd),ef(s[1],c[1],Jd),ef(s[2],c[2],Jd),255]:null}function r3(){const n=document.querySelector(".dashboard-shell-header-panel");if(!n)return null;const r=n3(getComputedStyle(n).backgroundColor);return!r||r[3]===0?null:r}function p0(){if(typeof window>"u"||typeof document>"u")return;const n=window.__TAURI__?.core?.invoke??null;if(!n)return;const r=document.documentElement,o=r.classList.contains("dark")?"dark":"light",s=getComputedStyle(r),c=Sc(r.getAttribute("data-layout"))??kr,u=r3()??a3(s.getPropertyValue("--card"),s.getPropertyValue("--background"),c);n("sync_desktop_theme",{theme:o,backgroundColor:u}).catch(()=>{})}function g0(){if(typeof window>"u")return()=>{};if(p0(),typeof window.requestAnimationFrame!="function")return()=>{};const n=window.requestAnimationFrame(()=>p0());return()=>window.cancelAnimationFrame(n)}function ef(n,r,o){return Math.round(n*o+r*(1-o))}function ac(n,r,o){return Math.min(Math.max(n,r),o)}function To(n){return Math.round(ac(n,0,255))}function v0(n){if(n==null||n==="")return 255;const r=n.endsWith("%")?Number(n.slice(0,-1))/100:Number(n);return Math.round(ac(r,0,1)*255)}function o3({children:n}){const[r,o]=g.useState(()=>typeof window<"u"?W_(window.location.search)??i3(localStorage.getItem("meshy-theme"))??m0:m0),[s,c]=g.useState(()=>typeof window<"u"?J_(window.location.search)??c3(localStorage.getItem("meshy-palette"))??nc:nc),[u,m]=g.useState(()=>{if(typeof window<"u"){const h=e3(window.location.search);if(h)return localStorage.setItem(Wd,kf),h;const v=K_(localStorage.getItem("meshy-layout"),localStorage.getItem(Wd));return localStorage.setItem(Wd,kf),v}return kr});return g.useEffect(()=>{const h=document.documentElement,v=p=>{if(p==="system"){const b=window.matchMedia("(prefers-color-scheme: dark)").matches;h.classList.toggle("dark",b)}else h.classList.toggle("dark",p==="dark")};if(v(r),localStorage.setItem("meshy-theme",r),r==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)"),b=()=>{v("system"),g0()};return p.addEventListener("change",b),()=>p.removeEventListener("change",b)}},[r]),g.useEffect(()=>{document.documentElement.setAttribute("data-palette",s),localStorage.setItem("meshy-palette",s)},[s]),g.useEffect(()=>{const h=document.documentElement;u===kr?h.removeAttribute("data-layout"):h.setAttribute("data-layout",u),localStorage.setItem("meshy-layout",u)},[u]),g.useEffect(()=>g0(),[r,s,u]),f.jsx(z1.Provider,{value:{theme:r,setTheme:o,palette:s,setPalette:c,layout:u,setLayout:m},children:n})}function l3(){const n=g.useContext(z1);if(!n)throw new Error("useTheme must be used within ThemeProvider");return n}function L1(n){return n!==null&&Z_.has(n)}function s3(n){return n!==null&&F_.has(n)}function i3(n){return L1(n)?n:null}function gm(n){return n===D1?"porcelain":s3(n)?n:null}function c3(n){return n===D1?null:gm(n)}const u3=[{value:"light",label:"Light",icon:dy},{value:"dark",label:"Dark",icon:cy},{value:"system",label:"System",icon:iy}],U1=[{value:"finsight",label:"FinSight",hint:"Cool sage green"},{value:"porcelain",label:"Porcelain",hint:"Blue workspace"},{value:"warm",label:"Warm",hint:"Cream + amber"},{value:"edge",label:"Edge",hint:"Rounded violet panels"},{value:"symphony",label:"Symphony",hint:"Near-black rose accent"},{value:"launcher",label:"Launcher",hint:"Desktop startup blue"}],B1=[{value:"airy",label:"Airy",hint:"Gradients, blur, spacious"},{value:"clean",label:"Clean",hint:"Flat, borders, high density"},{value:"fluent",label:"Fluent",hint:"Compact neutral"}];function d3(){const{theme:n,setTheme:r,palette:o,setPalette:s,layout:c,setLayout:u}=l3(),[m,h]=g.useState(null),v=g.useRef(null),p=g.useRef(null),b=_1(m),y=n==="dark"?cy:n==="light"?dy:iy,w=()=>{v.current&&(clearTimeout(v.current),v.current=null)},C=()=>{w(),v.current=setTimeout(()=>h(N=>Af(N)),180)};return g.useEffect(()=>{if(!b)return;const N=E=>{p.current&&!p.current.contains(E.target)&&h(null)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[b]),g.useEffect(()=>()=>w(),[]),f.jsxs("div",{ref:p,className:"relative",onMouseEnter:()=>{w(),h(N=>O1(N))},onMouseLeave:C,children:[f.jsx(Ct,{variant:"ghost",size:"icon",onClick:()=>h(N=>M1(N)),className:ae("h-8 w-8 rounded-sm",o!==nc||c!==kr?"text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),title:"Appearance","aria-haspopup":"menu","aria-expanded":b,children:f.jsx(y,{className:"h-4 w-4"})}),b&&f.jsxs("div",{role:"menu",className:"fixed left-2 right-2 top-[4.25rem] z-50 w-auto max-w-none rounded-md border border-border/70 bg-popover/95 p-2 text-popover-foreground shadow-[0_24px_70px_-32px_rgba(0,0,0,0.45)] backdrop-blur-xl sm:absolute sm:left-auto sm:right-0 sm:top-[calc(100%+6px)] sm:w-[23rem] sm:max-w-[23rem]",children:[f.jsxs("div",{className:"mb-2 flex items-end justify-between gap-2",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Appearance"}),f.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:[f3(c)," / ",m3(o)]})]}),f.jsx("div",{className:"rounded-sm border border-border/60 bg-background/70 px-1.5 py-0.5 text-[8px] font-medium capitalize text-muted-foreground",children:n})]}),f.jsx("div",{className:"px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Theme"}),f.jsx("div",{className:"mb-2 grid grid-cols-3 gap-1 rounded-sm bg-muted/35 p-0.5",children:u3.map(({value:N,label:E,icon:T})=>{const A=n===N;return f.jsxs("button",{type:"button",onClick:()=>r(N),role:"menuitemradio","aria-checked":A,className:ae("flex min-h-[2.1rem] flex-col items-center justify-center gap-0.5 rounded-sm border px-1.5 py-1 text-[9px] font-medium transition-colors",A?"border-primary/55 bg-background text-primary shadow-sm":"border-transparent text-muted-foreground hover:border-border/70 hover:bg-background/80 hover:text-foreground"),children:[f.jsx(T,{className:"h-3 w-3"}),E]},N)})}),f.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[f.jsxs("div",{children:[f.jsx("div",{className:"px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Layout"}),f.jsx("div",{className:"space-y-1",children:B1.map(({value:N,label:E,hint:T})=>{const A=c===N;return f.jsxs("button",{type:"button",onClick:()=>u(N),role:"menuitemradio","aria-checked":A,className:ae("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",A?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:ae("text-[10px] font-medium leading-tight",A?"text-primary":"text-foreground"),children:E}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:T})]}),A&&f.jsx(Li,{className:"h-3 w-3 text-primary"})]},N)})})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-1.5 px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:[f.jsx(AT,{className:"h-2.5 w-2.5"}),"Palette"]}),f.jsx("div",{className:"space-y-1",children:U1.map(({value:N,label:E,hint:T})=>{const A=o===N;return f.jsxs("button",{type:"button",onClick:()=>s(N),role:"menuitemradio","aria-checked":A,className:ae("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",A?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsx(h3,{value:N}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:ae("text-[10px] font-medium leading-tight",A?"text-primary":"text-foreground"),children:E}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:T})]}),A&&f.jsx(Li,{className:"h-3 w-3 text-primary"})]},N)})})]})]})]})]})}function f3(n){return B1.find(r=>r.value===n)?.label??n}function m3(n){return U1.find(r=>r.value===n)?.label??n}function h3({value:n}){const r={porcelain:["hsl(212 76% 44%)","hsl(210 22% 98%)","hsl(174 42% 61%)"],warm:["hsl(35 88% 56%)","hsl(42 22% 97%)","hsl(160 60% 45%)"],finsight:["hsl(152 38% 32%)","hsl(150 14% 97%)","hsl(142 55% 58%)"],edge:["hsl(265 75% 55%)","hsl(260 12% 98%)","hsl(285 70% 65%)"],symphony:["hsl(348 100% 71%)","hsl(0 0% 6%)","hsl(240 2% 9%)"],launcher:["hsl(213 77% 49%)","hsl(60 10% 96%)","hsl(0 0% 100%)"]},[o,s,c]=r[n];return f.jsxs("div",{className:ae("flex h-5 w-5 shrink-0 overflow-hidden border border-border/60 shadow-sm","rounded-sm"),children:[f.jsx("div",{className:"h-full w-1/3",style:{background:o}}),f.jsx("div",{className:"h-full w-1/3",style:{background:s}}),f.jsx("div",{className:"h-full w-1/3",style:{background:c}})]})}const Xl={tasks:{defaultSize:20,min:16,max:36,wheelStep:1},operations:{defaultSize:20,min:18,max:38,wheelStep:1},terminal:{defaultSize:18,min:10,max:30,wheelStep:1}},H1="meshy-dashboard-panel-state-v2",P1="meshy-dashboard-terminal-open-v1";function cM({operationsOpen:n}){return{layout:{desktopTasksOpen:!0,operationsOpen:n},sizes:{tasks:Xl.tasks.defaultSize,operations:Xl.operations.defaultSize,terminal:Xl.terminal.defaultSize}}}function tf(n){return typeof n=="object"&&n!==null}function y0(n,r){return typeof n=="boolean"?n:r}function nf(n,r,o){return typeof r=="number"&&Number.isFinite(r)?Ql(n,r):o}function Ql(n,r){const o=Xl[n];return Math.min(o.max,Math.max(o.min,r))}function uM(n,r){if(!n)return r;try{const o=n.getItem(H1);if(!o)return r;const s=JSON.parse(o);if(!tf(s))return r;const c=tf(s.layout)?s.layout:{},u=tf(s.sizes)?s.sizes:{};return{layout:{desktopTasksOpen:y0(c.desktopTasksOpen,r.layout.desktopTasksOpen),operationsOpen:y0(c.operationsOpen,r.layout.operationsOpen)},sizes:{tasks:nf("tasks",u.tasks,r.sizes.tasks),operations:nf("operations",u.operations,r.sizes.operations),terminal:nf("terminal",u.terminal,r.sizes.terminal)}}}catch{return r}}function dM(n,r){if(n)try{n.setItem(H1,JSON.stringify(r))}catch{}}function p3(n,r){if(!n)return r;try{const o=n.getItem(P1);return o==="true"?!0:o==="false"?!1:r}catch{return r}}function g3(n,r){if(n)try{n.setItem(P1,String(r))}catch{}}function b0(){try{return globalThis.window?.localStorage??globalThis.localStorage??null}catch{return null}}function fM(n){return`${Number(n.toFixed(2))}rem`}function mM(n,r,o,s,c,u,m){const h=Number.isFinite(m)&&m>0?m:16;return n==="tasks"?Ql(n,r+(c-o)/h):n==="operations"?Ql(n,r+(o-c)/h):Ql(n,r+(s-u)/h)}function hM(n,r,o){const s=o===0?0:o>0?-1:1;return Ql(n,r+s*Xl[n].wheelStep)}const v3=7200*1e3,y3=15*1e3,b3="meshy://desktop-update-progress",x3="Desktop update check timed out";function S3(){return f.jsxs("svg",{"data-meshy-app-icon":"header",viewBox:"0 0 1024 1024",className:"h-8 w-8","aria-hidden":"true",children:[f.jsxs("defs",{children:[f.jsxs("linearGradient",{id:"meshy-header-icon-bg",x1:"160",y1:"128",x2:"864",y2:"896",gradientUnits:"userSpaceOnUse",children:[f.jsx("stop",{offset:"0",stopColor:"#182033"}),f.jsx("stop",{offset:"1",stopColor:"#0a0f1f"})]}),f.jsxs("linearGradient",{id:"meshy-header-icon-edge",x1:"260",y1:"244",x2:"768",y2:"780",gradientUnits:"userSpaceOnUse",children:[f.jsx("stop",{offset:"0",stopColor:"#66e3ff"}),f.jsx("stop",{offset:"0.52",stopColor:"#8fd56b"}),f.jsx("stop",{offset:"1",stopColor:"#ffcb5b"})]})]}),f.jsx("rect",{width:"1024",height:"1024",rx:"224",fill:"url(#meshy-header-icon-bg)"}),f.jsx("path",{d:"M308 652V372l204 174 204-174v280",fill:"none",stroke:"url(#meshy-header-icon-edge)",strokeWidth:"86",strokeLinecap:"round",strokeLinejoin:"round"}),f.jsx("circle",{cx:"308",cy:"372",r:"58",fill:"#66e3ff"}),f.jsx("circle",{cx:"512",cy:"546",r:"58",fill:"#8fd56b"}),f.jsx("circle",{cx:"716",cy:"372",r:"58",fill:"#ffcb5b"}),f.jsx("circle",{cx:"308",cy:"652",r:"58",fill:"#66e3ff"}),f.jsx("circle",{cx:"716",cy:"652",r:"58",fill:"#ffcb5b"})]})}function Vl(){return typeof window>"u"?null:window.__TAURI__?.core?.invoke??null}function w3(){return typeof window>"u"?null:window.__TAURI__?.event?.listen??null}function E3(n){if(!n||typeof n!="object")return null;const r=n;return r.phase!=="downloading"&&r.phase!=="installing"&&r.phase!=="complete"?null:{phase:r.phase,receivedBytes:typeof r.receivedBytes=="number"?r.receivedBytes:0,totalBytes:typeof r.totalBytes=="number"?r.totalBytes:null,percent:typeof r.percent=="number"?Math.max(0,Math.min(100,Math.round(r.percent))):null}}function x0(n){return{currentVersion:null,latestVersion:null,updateAvailable:!1,checkedAt:new Date().toISOString(),releaseUrl:null,assetName:null,installable:!1,detail:n}}async function N3(n,r,o){let s;const c=new Promise((u,m)=>{s=setTimeout(()=>{m(new Error(x3))},r)});try{return await Promise.race([n,c])}finally{s!==void 0&&clearTimeout(s)}}async function T3({activeCheck:n,startCheck:r,timeoutMs:o,shouldApply:s,applyUpdate:c,applyFailure:u,failureFallback:m="Desktop update check failed"}){let h=n.current;if(!h){let v;try{v=r()}catch(p){v=Promise.reject(p)}h=N3(v,o),n.current=h}try{const v=await h;return s()&&c(v),v}catch(v){return s()&&u(jf(v,m)),null}finally{n.current===h&&(n.current=null)}}function jf(n,r){if(n instanceof Error&&n.message.trim())return n.message;if(typeof n=="string"&&n.trim())return n;if(n&&typeof n=="object"&&"message"in n){const o=n.message;if(typeof o=="string"&&o.trim())return o}return r}function C3(n){return n.openedRelease?"Opened the latest Meshy release page.":n.installMethod==="tauri-updater"?"Installing desktop update. Meshy will relaunch to finish updating.":(n.assetName??"desktop update").toLowerCase().endsWith(".dmg")?"Downloaded desktop update. Open the DMG and drag Meshy to Applications to finish updating.":"Downloaded desktop update. Follow the installer to finish updating."}function R3(){const{cluster:n,events:r,sseConnected:o,systemInfo:s}=ey(),c=jn(),[u,m]=g.useState(()=>p3(b0(),!1)),[h,v]=g.useState(""),[p,b]=g.useState(null),[y,w]=g.useState(null),[C,N]=g.useState(!1),[E,T]=g.useState(null),A=g.useRef(null),k=!!Vl(),O=k?"max-w-none":"max-w-[1760px]",B=c.pathname==="/"||/^\/tasks\/[^/]+$/.test(c.pathname),L=g.useMemo(()=>{const W=new Map;for(const ee of n?.nodes??[])W.set(ee.id,ee.name);return n?.self&&W.set(n.self.id,n.self.name),W},[n?.nodes,n?.self]),Z=g.useCallback(W=>{m(ee=>typeof W=="function"?W(ee):W)},[]);g.useEffect(()=>{g3(b0(),u)},[u]);const V=g.useCallback(async(W=!0,ee=()=>!0)=>{const le=Vl();return le?(W&&ee()&&w(x0("Checking desktop update...")),T3({activeCheck:A,startCheck:()=>le("check_desktop_update"),timeoutMs:y3,shouldApply:ee,applyUpdate:J=>w(J),applyFailure:J=>w(_=>_?.updateAvailable?_:x0(J))})):(ee()&&w(null),null)},[]);async function $(){N(!0);try{await V(!1)}finally{N(!1)}}g.useEffect(()=>{if(!Vl()){w(null);return}let W=!1;const ee=()=>!W;V(!0,ee);const le=window.setInterval(()=>{V(!1,ee)},v3);return()=>{W=!0,window.clearInterval(le)}},[V,s?.version]),g.useEffect(()=>{const W=w3();if(!W)return;let ee=!1,le;return W(b3,J=>{const _=E3(J.payload);_&&T(_)}).then(J=>{if(ee){J();return}le=J}).catch(()=>{}),()=>{ee=!0,le?.()}},[]);async function G(){try{const W=await F0({reason:"restart"});_e.info(`Restarting runtime. Follow ${W.logPath} for launch output.`),await R1({previousPid:W.pid})||_e.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout.")}catch(W){_e.error(W instanceof Error?W.message:"Runtime restart failed")}}async function ce(){const W=Vl();if(!W){_e.error("Desktop updater is not available in this window");return}try{_e.info("Downloading desktop update..."),T({phase:"downloading",receivedBytes:0,totalBytes:null,percent:0});const ee=await W("install_desktop_update");T({phase:"complete",receivedBytes:1,totalBytes:1,percent:100}),_e.info(C3(ee))}catch(ee){_e.error(jf(ee,"Desktop update failed"))}finally{T(null)}}async function ue(){const W=Vl();if(!W){_e.error("Desktop restart is not available in this window");return}try{_e.info("Restarting Meshy Desktop..."),await W("restart_desktop_app")}catch(ee){_e.error(jf(ee,"Desktop restart failed"))}}return f.jsxs("div",{className:"relative h-full overflow-hidden bg-background text-foreground",children:[f.jsx("div",{className:"mesh-grid pointer-events-none absolute inset-0"}),f.jsxs("div",{className:"relative z-10 flex h-full min-h-0 flex-col",children:[f.jsx("header",{className:"dashboard-shell-header relative z-50 shrink-0 px-2 py-2",children:f.jsxs("div",{className:ae("dashboard-shell-header-panel dashboard-panel dashboard-panel-muted animate-panel-settle mx-auto flex items-center gap-0 rounded-lg px-3 py-2",O),children:[f.jsx("div",{className:"flex shrink-0 items-center gap-3 pr-3",children:f.jsxs(of,{to:"/","aria-label":"Meshy home",className:"flex items-center gap-2",children:[f.jsx(S3,{}),f.jsxs("div",{className:"hidden min-w-0 items-baseline gap-1.5 sm:flex",children:[f.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:"MESHY"}),f.jsx("span",{className:"truncate text-[13px] font-semibold tracking-tight text-foreground",children:"Workspace"})]})]})}),f.jsx("div",{className:"mx-0 hidden h-4 w-px shrink-0 bg-border/50 md:block"}),B&&f.jsxs("div",{className:"hidden min-w-0 flex-1 items-center px-3 md:flex",children:[p&&f.jsxs("nav",{"aria-label":"Current task location",className:"flex min-w-0 max-w-[38rem] items-center gap-1 rounded-sm bg-background/55 px-2 py-1 text-[10px] text-muted-foreground",children:[f.jsxs("button",{type:"button",onClick:()=>v(p.nodeName),className:"flex min-w-0 items-center gap-1 rounded-sm px-1 py-0.5 hover:bg-muted/60 hover:text-foreground",title:`Filter by ${p.nodeName}`,children:[f.jsx(uy,{className:"h-3 w-3 shrink-0 text-primary/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.nodeName})]}),f.jsx(lf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsxs("button",{type:"button",onClick:()=>v(p.projectLabel),className:"flex min-w-0 items-center gap-1 rounded-sm px-1 py-0.5 hover:bg-muted/60 hover:text-foreground",title:p.projectPath,children:[f.jsx(JN,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.projectLabel})]}),f.jsx(lf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsx(of,{to:`/tasks/${p.taskId}`,className:"min-w-0 truncate px-1 font-medium text-foreground/85 hover:text-foreground",title:p.taskTitle,children:p.taskTitle})]}),f.jsxs("div",{className:"relative ml-auto w-[18rem] max-w-[28rem]",children:[f.jsx(ST,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/60"}),f.jsx(bc,{"aria-label":"Search tasks",value:h,onChange:W=>v(W.target.value),placeholder:"Search tasks, nodes, workspaces",className:"h-8 rounded-sm border-0 bg-background/62 pl-8 pr-2 text-[11px] shadow-none focus-visible:ring-0 focus-visible:ring-offset-0"})]})]}),f.jsx("div",{className:"mx-0 hidden h-4 w-px shrink-0 bg-border/50 md:block"}),f.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5 pl-3 sm:gap-2 md:ml-0",children:[B&&f.jsx(Ct,{variant:"ghost",size:"icon",onClick:()=>Z(W=>!W),"aria-label":u?"Close terminal":"Open terminal",title:u?"Close terminal":"Open terminal",className:ae("h-8 w-8 rounded-sm text-muted-foreground hover:bg-muted/50 hover:text-foreground",u&&"bg-primary/8 text-primary"),children:f.jsx(fy,{className:"h-4 w-4"})}),f.jsx(R_,{}),f.jsx(d3,{}),f.jsx("div",{className:"mx-0 h-4 w-px shrink-0 bg-border/50"}),f.jsx(Y_,{connected:o,events:r,nodes:n?.nodes??[],currentNode:n?.self??null,nodeNameById:L,desktopUpdate:y,desktopUpdateCheckPending:C,desktopUpdateProgress:E,onDesktopUpdateCheck:k?$:void 0,onDesktopUpdate:y?.updateAvailable?ce:void 0,onDesktopRestart:k?ue:void 0,onReload:k?()=>window.location.reload():void 0,onRestart:G})]})]})}),f.jsx("main",{className:ae("dashboard-shell-main min-h-0 flex-1 px-2 pb-2",B?"overflow-hidden":"overflow-y-auto"),children:f.jsx("div",{className:ae("dashboard-shell-content mx-auto h-full min-h-0",O),children:f.jsx(oE,{context:{terminalOpen:u,setTerminalOpen:Z,headerSearchQuery:h,setHeaderSearchQuery:v,setHeaderTaskContext:b}})})})]})]})}const S0=g.lazy(async()=>({default:(await N0(()=>import("./DashboardPage-0WRjBujS.js").then(r=>r.D),__vite__mapDeps([0,1,2,3,4]))).DashboardPage})),A3=g.lazy(async()=>({default:(await N0(()=>import("./SharedConversationPage-DScv1dQe.js"),__vite__mapDeps([5,1]))).SharedConversationPage}));function k3(){return f.jsx(_E,{children:f.jsx(g.Suspense,{fallback:f.jsx(j3,{}),children:f.jsxs(sE,{children:[f.jsx(Nr,{path:"/shared/tasks/:shareId",element:f.jsx(A3,{})}),f.jsxs(Nr,{element:f.jsx(TN,{children:f.jsx(R3,{})}),children:[f.jsx(Nr,{path:"/",element:f.jsx(S0,{})}),f.jsx(Nr,{path:"/nodes",element:f.jsx(bv,{to:"/",replace:!0})}),f.jsx(Nr,{path:"/tasks",element:f.jsx(bv,{to:"/",replace:!0})}),f.jsx(Nr,{path:"/tasks/:id",element:f.jsx(S0,{})})]})]})})})}function j3(){return f.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading workspace..."})}function _3(n){const r=n??(typeof window>"u"?void 0:window);r?.__TAURI__&&r.addEventListener("contextmenu",o=>{o.preventDefault()})}function O3(n){const{className:r,style:o,toastOptions:s,...c}=n;function u(m){const h=m.target;if(!(h instanceof Element)||h.closest("button, a, input, textarea, select, [data-close-button], [data-button]"))return;const v=h.closest("[data-sonner-toast]");v&&v.dataset.type!=="loading"&&k1()}return f.jsx("div",{onClick:u,children:f.jsx(FC,{className:["toaster group",r].filter(Boolean).join(" "),closeButton:!0,gap:6,offset:{right:"0.6rem",bottom:"0.6rem"},mobileOffset:{right:"0.5rem",bottom:"0.5rem",left:"0.5rem"},position:"bottom-right",visibleToasts:3,style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border) / 0.7)","--width":"17rem",...o},toastOptions:{duration:3e3,closeButton:!0,...s,classNames:{toast:"meshy-toast",title:"meshy-toast__title",description:"meshy-toast__description",content:"meshy-toast__content",icon:"meshy-toast__icon",closeButton:"meshy-toast__close",actionButton:"meshy-toast__action",cancelButton:"meshy-toast__cancel",success:"meshy-toast--success",error:"meshy-toast--error",info:"meshy-toast--info",warning:"meshy-toast--warning",...s?.classNames}},...c})})}_3();r2.createRoot(document.getElementById("root")).render(f.jsx(g.StrictMode,{children:f.jsxs(o3,{children:[f.jsx(k3,{}),f.jsx(O3,{})]})}));export{LO as $,UO as A,Ct as B,Li as C,BO as D,oO as E,FN as F,B5 as G,mb as H,bc as I,pb as J,iM as K,ly as L,ry as M,h1 as N,Gx as O,dT as P,lM as Q,sy as R,uy as S,HO as T,Il as U,$N as V,Ej as W,my as X,ny as Y,Jk as Z,zO as _,rM as a,jO as a$,_t as a0,eM as a1,Gl as a2,Nf as a3,Xi as a4,Qi as a5,Zi as a6,Fi as a7,Ki as a8,Ji as a9,tM as aA,xj as aB,CO as aC,cR as aD,Ri as aE,VO as aF,nM as aG,aM as aH,$O as aI,qO as aJ,WO as aK,N1 as aL,JO as aM,Tf as aN,OT as aO,hO as aP,pO as aQ,uM as aR,cM as aS,b0 as aT,dM as aU,hM as aV,fM as aW,mM as aX,aO as aY,yN as aZ,FE as a_,Wi as aa,N0 as ab,U3 as ac,hb as ad,$5 as ae,Z3 as af,fy as ag,Ro as ah,sf as ai,K3 as aj,F3 as ak,Q3 as al,AO as am,H5 as an,gb as ao,DT as ap,NT as aq,DN as ar,sT as as,ts as at,ZO as au,pT as av,M_ as aw,hj as ax,oy as ay,pj as az,nR as b,kO as b0,_O as b1,SN as b2,dO as b3,$3 as b4,H3 as b5,Z0 as b6,P3 as b7,q3 as b8,R_ as b9,iO as bA,sO as bB,L3 as bC,B3 as bD,z3 as bE,V3 as bF,DO as bG,xO as bH,bO as bI,yO as bJ,gO as bK,vO as bL,SO as bM,bj as bN,Uk as bO,MO as bP,Lk as bQ,w0 as bR,NO as bS,EO as bT,wO as bU,TO as bV,OO as bW,RO as bX,fO as ba,mO as bb,tO as bc,W3 as bd,J3 as be,eO as bf,nO as bg,D3 as bh,jn as bi,P0 as bj,M3 as bk,ey as bl,FO as bm,$j as bn,sM as bo,KO as bp,YO as bq,IO as br,XO as bs,GO as bt,QO as bu,rO as bv,PO as bw,Sj as bx,cO as by,uO as bz,Ae as c,ae as d,jy as e,g1 as f,I3 as g,X3 as h,K0 as i,f as j,Y3 as k,JN as l,oM as m,lf as n,ua as o,G3 as p,lO as q,g as r,Sf as s,_e as t,Ii as u,wf as v,Gi as w,ST as x,Zl as y,AT as z};
|
|
346
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return g.useEffect(()=>{document.getElementById(n.current?.getAttribute("aria-describedby"))||console.warn(r)},[r,n]),null},cj=Qx,uj=Kx,dj=Zx,l1=Fx,s1=Wx,i1=a1,c1=o1,u1=e1,d1=n1;const Nf=cj,Tf=uj,fj=dj,f1=g.forwardRef(({className:n,...r},o)=>f.jsx(l1,{className:ae("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...r,ref:o}));f1.displayName=l1.displayName;const Xi=g.forwardRef(({className:n,...r},o)=>f.jsxs(fj,{children:[f.jsx(f1,{}),f.jsx(s1,{ref:o,className:ae("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-3 rounded-sm border bg-background p-4 shadow-[0_24px_84px_-54px_rgba(0,0,0,0.55)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",n),...r})]}));Xi.displayName=s1.displayName;const Qi=({className:n,...r})=>f.jsx("div",{className:ae("flex flex-col space-y-1.5 text-center sm:text-left",n),...r});Qi.displayName="AlertDialogHeader";const Ki=({className:n,...r})=>f.jsx("div",{className:ae("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...r});Ki.displayName="AlertDialogFooter";const Zi=g.forwardRef(({className:n,...r},o)=>f.jsx(u1,{ref:o,className:ae("text-sm font-semibold",n),...r}));Zi.displayName=u1.displayName;const Fi=g.forwardRef(({className:n,...r},o)=>f.jsx(d1,{ref:o,className:ae("text-[11px] text-muted-foreground",n),...r}));Fi.displayName=d1.displayName;const Wi=g.forwardRef(({className:n,...r},o)=>f.jsx(i1,{ref:o,className:ae(If(),n),...r}));Wi.displayName=i1.displayName;const Ji=g.forwardRef(({className:n,...r},o)=>f.jsx(c1,{ref:o,className:ae(If({variant:"outline"}),"mt-2 sm:mt-0",n),...r}));Ji.displayName=c1.displayName;const mj={online:"bg-emerald-500",busy:"bg-amber-500",offline:"bg-destructive"};function hj({status:n}){return f.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5",children:[n==="online"&&f.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-500 opacity-30"}),f.jsx("span",{className:ae("relative inline-flex h-2.5 w-2.5 rounded-full",mj[n])})]})}function pj({role:n,size:r="default"}){return f.jsx(_t,{variant:n==="leader"?"default":"secondary",className:ae(r==="compact"?"px-1.5 py-0 text-[9px] leading-4":"text-[11px]"),children:n})}const m1={pending:{variant:"secondary",dotClass:"bg-muted-foreground",className:"border-transparent bg-muted/55 text-muted-foreground"},assigned:{variant:"outline",dotClass:"bg-teal-500",className:"border-teal-500/20 bg-teal-500/8 text-teal-700 dark:text-teal-300"},running:{variant:"outline",dotClass:"bg-amber-500",className:"border-amber-500/22 bg-amber-500/9 text-amber-700 dark:text-amber-300"},completed:{variant:"outline",dotClass:"bg-emerald-500",className:"border-emerald-500/18 bg-emerald-500/8 text-emerald-700 dark:text-emerald-300"},failed:{variant:"destructive",dotClass:"bg-destructive-foreground",className:"border-destructive/20 bg-destructive/90 text-destructive-foreground"},cancelled:{variant:"secondary",dotClass:"bg-muted-foreground",className:"border-transparent bg-muted/55 text-muted-foreground"},archived:{variant:"secondary",dotClass:"bg-slate-400",className:"border-transparent bg-muted/50 text-muted-foreground"}};function DO({status:n,size:r="default"}){const o=m1[n],s=r==="compact"?"gap-0.5 px-1 py-0 text-[8px] leading-3 [&>span]:h-[3px] [&>span]:w-[3px]":"gap-1 px-1.5 py-0 text-[10px] leading-4 [&>span]:h-[5px] [&>span]:w-[5px]";return f.jsxs(_t,{variant:o.variant,className:ae("rounded-sm font-medium shadow-none",s,o.className),children:[f.jsx("span",{className:ae("rounded-full",o.dotClass)}),n]})}function zO({status:n,isNative:r=!1,size:o="default",className:s}){const c=m1[n],u=[n,r?"native":null].filter(Boolean).join(", "),m=o==="compact"?"h-1.5 w-1.5":"h-2 w-2";return f.jsxs("span",{className:ae("inline-flex shrink-0 items-center gap-1",s),title:u,"aria-label":u,children:[f.jsx("span",{className:ae("rounded-full",m,c.dotClass),title:n}),r&&f.jsx("span",{className:ae("rounded-full bg-sky-500",m),title:"native"})]})}const gj={critical:{variant:"destructive",label:"Critical"},high:{variant:"outline",label:"High"},normal:{variant:"secondary",label:"Normal"},low:{variant:"secondary",label:"Low"}};function LO({priority:n}){const r=gj[n];return f.jsx(_t,{variant:r.variant,className:"rounded-sm px-1.5 py-0 text-[10px] leading-4 shadow-none",children:r.label})}function vj(n){return[{key:"workspace",label:"Workspace",value:n?.workspace},{key:"node",label:"Node app",value:n?.node},{key:"core",label:"Core",value:n?.core},{key:"dashboard",label:"Dashboard",value:n?.dashboard},{key:"api",label:"API",value:n?.api}].filter(o=>o.value)}function Eo({label:n,value:r,mono:o=!1}){return f.jsxs("div",{className:"min-w-0 rounded-sm border border-border/60 bg-background/65 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:n}),f.jsx("div",{className:o?"mt-0.5 break-all font-mono text-[11px] text-foreground":"mt-0.5 break-all text-[11px] text-foreground",children:r})]})}function yj({formatDateTime:n,viewInfo:r}){const o=vj(r.packages);return f.jsxs(Gl,{value:"about","data-about-layout":"compact",className:"mt-0 space-y-2",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(DN,{className:"h-3.5 w-3.5 text-primary"}),"Repository & runtime"]}),f.jsx(Nn,{className:"text-[10px]",children:"Build source and runtime identity for this node."})]}),f.jsxs(Tn,{className:"space-y-2 px-3 pb-2.5",children:[r.repository?.url?f.jsxs("a",{href:r.repository.url,target:"_blank",rel:"noreferrer",className:"group flex min-w-0 items-center justify-between gap-2 rounded-sm border border-border/70 bg-background/70 px-2.5 py-1.5 text-[11px] text-foreground transition-colors hover:border-primary/40 hover:bg-primary/5",children:[f.jsx("span",{className:"truncate font-mono text-[10px]",children:r.repository.url}),f.jsx(oy,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform group-hover:-translate-y-0.5 group-hover:translate-x-0.5"})]}):f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-2.5 py-1.5 text-[11px] text-muted-foreground",children:"Repository URL is unavailable in this runtime."}),f.jsxs("div",{className:"grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3",children:[f.jsx(Eo,{label:"Branch",value:r.repository?.branch??"Unavailable",mono:!!r.repository?.branch}),f.jsx(Eo,{label:"Commit",value:r.repository?.commit??"Unavailable",mono:!!r.repository?.commit}),f.jsx(Eo,{label:"Runtime",value:`${r.packageName??"meshy"} ${r.version}`,mono:!0}),f.jsx(Eo,{label:"Node.js",value:r.runtime?.nodeVersion??"Unavailable",mono:!!r.runtime?.nodeVersion}),f.jsx(Eo,{label:"PID",value:r.runtime?String(r.runtime.pid):"Unavailable",mono:!!r.runtime}),f.jsx(Eo,{label:"Started",value:n(r.runtime?.startedAt)})]})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(tT,{className:"h-3.5 w-3.5 text-primary"}),"Package versions"]}),f.jsx(Nn,{className:"text-[10px]",children:"Version snapshot for the packages most relevant to this dashboard session."})]}),f.jsx(Tn,{"data-package-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:o.map(s=>f.jsxs("div",{className:"grid gap-1.5 rounded-sm border border-border/60 bg-background/65 px-2.5 py-1.5 sm:grid-cols-[9rem_minmax(0,1fr)_auto] sm:items-center",children:[f.jsx("div",{className:"text-[11px] font-medium text-foreground",children:s.label}),f.jsx("div",{className:"min-w-0 truncate text-[10px] text-muted-foreground",children:s.value?.name}),f.jsx(_t,{variant:"outline",className:"w-fit rounded-sm border-border/70 bg-background/60 font-mono text-[10px]",children:s.value?.version})]},s.key))})]})]})}const UO="codex",BO="bypass",bj=[{value:"codex",label:"Codex",supportsFollowUp:!0},{value:"claudecode",label:"Claude Code",supportsFollowUp:!0},{value:"copilot",label:"Copilot",supportsFollowUp:!0},{value:"mars",label:"mars",disabled:!0,description:"coming soon"},{value:"eureka",label:"eureka",disabled:!0,description:"coming soon"}],HO=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],PO=new Set(bj.filter(n=>n.supportsFollowUp).map(n=>n.value)),$O=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"shared",label:"Shared"},{value:"archived",label:"Archived"}],qO=[{value:"all",label:"All task types"},{value:"native",label:"Native sessions"},{value:"meshy",label:"Meshy chats"}],xj=new Set(["pending","assigned"]),Sj=new Set(["running"]),wj=new Set(["completed","failed","cancelled"]),VO=10;function YO(n,r){switch(r){case"running":return Sj.has(n.status);case"waiting":return xj.has(n.status);case"closed":return wj.has(n.status);case"shared":return!!n.activeShare;case"archived":return n.status==="archived";default:return n.status!=="archived"}}function IO(n,r){if(r==="all")return!0;const o=n.conversationKind==="nativeSession";return r==="native"?o:!o}function GO(n,r){const o=r.trim().toLowerCase();return o?[n.title,n.description,n.id,n.agent,n.assignedTo??"",n.assignedNodeName??"",n.project??"",n.effectiveProjectPath??"",n.conversationKind==="nativeSession"?"native session":"meshy chat",n.activeShare?"shared conversation":""].some(s=>s.toLowerCase().includes(o)):!0}function Ej(n,r,o){return n?r?.find(c=>c.id===n)?.name??o??n.slice(0,8):"unassigned"}function XO(n,r,o){return Ej(n,r,o).toLowerCase()}function QO(n){return n.type!=="node.status"&&n.type!=="cluster.state"}function KO(n,r,o){return!n.assignedTo||o?.id===n.assignedTo?!0:r?.some(s=>s.id===n.assignedTo)??!1}function ZO(n,r){return[...n].sort((o,s)=>o.id===r?-1:s.id===r?1:o.name.localeCompare(s.name))}function FO(n){if(!n||typeof n!="object")return null;const r=n,o=r.createMode,s=o==="chat"||o==="native"?o:void 0,c=r.createDefaults,u=c&&typeof c=="object"&&!Array.isArray(c)?c:null,m=u?{assignTo:typeof u.assignTo=="string"||u.assignTo===null?u.assignTo:void 0,project:typeof u.project=="string"||u.project===null?u.project:void 0}:void 0;return{draftNewTask:r.draftNewTask===!0,returnRoute:typeof r.returnRoute=="string"?r.returnRoute:void 0,returnTaskId:typeof r.returnTaskId=="string"||r.returnTaskId===null?r.returnTaskId:void 0,createMode:s,createDefaults:m}}function WO(n){return n==="default workspace"?n:n.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??n}function JO(n){const r=Date.now()-n;return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m`:r<864e5?`${Math.floor(r/36e5)}h`:`${Math.floor(r/864e5)}d`}function eM(n){return new Date(n).toLocaleString()}function tM(n){const r=Math.floor(n/1e3),o=Math.floor(r/3600),s=Math.floor(r%3600/60),c=r%60;return`${String(o).padStart(2,"0")}:${String(s).padStart(2,"0")}:${String(c).padStart(2,"0")}`}async function h1(n,r="Copied to clipboard"){try{if(globalThis.navigator?.clipboard?.writeText)return await globalThis.navigator.clipboard.writeText(n),_e.success(r),!0;const o=globalThis.document,s=o?.execCommand?.bind(o);if(!o?.body||typeof o.createElement!="function"||typeof s!="function")throw new Error("Clipboard access is unavailable");const c=o.createElement("textarea"),u=o.activeElement,m=u&&typeof u.focus=="function"?u:null;c.value=n,c.setAttribute("readonly","true"),c.style.position="fixed",c.style.opacity="0",c.style.pointerEvents="none",o.body.appendChild(c),c.select(),c.setSelectionRange(0,c.value.length);const h=s("copy");if(o.body.removeChild(c),m?.focus(),!h)throw new Error("Clipboard access is unavailable");return _e.success(r),!0}catch(o){return _e.error(o instanceof Error?o.message:"Failed to copy"),!1}}const Nj="default workspace";function _i(n){const r=n.replace(/\\/g,"/");return r==="/"||/^[A-Za-z]:\/$/.test(r)?r:r.replace(/\/+$/g,"")||r}function Tj(n){const r=n.replace(/\\/g,"/");return r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r)}function Cj(n,r){const o=_i(n),s=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!s||s==="."?o:o==="/"||/^[A-Za-z]:\/$/.test(o)?`${o}${s}`:`${o}/${s}`}function Rj(n,r){const o=n.effectiveProjectPath?.trim();if(o)return _i(o);const s=n.project?.trim();if(!s)return Nj;if(Tj(s)||!n.assignedTo)return _i(s);const c=r?.get(n.assignedTo)?.trim();return c?Cj(c,s):_i(s)}function nM({nodeStatusById:n,nodeNameById:r,nodeFilter:o,searchQuery:s,nodeWorkDirById:c}){const u=o.trim().toLowerCase(),m=s.trim().toLowerCase(),h=[];for(const[v,p]of n){if(p==="offline"||u==="unassigned")continue;const b=r.get(v)??v.slice(0,8);if(!(u&&u!=="all"&&b.toLowerCase()!==u)){if(m){const y=c?.get(v)??"";if(![v,b,y].some(C=>C.toLowerCase().includes(m)))continue}h.push(v)}}return h}function aM(n,r,o,s,c){const u=new Map;for(const h of n){const v=h.assignedTo??null,p=v??"__unassigned__",b=v?r.get(v)??h.assignedNodeName??v.slice(0,8):"Unassigned",y=Rj(h,s);u.has(p)||u.set(p,{nodeId:v,nodeName:b,dirMap:new Map});const w=u.get(p);w.dirMap.has(y)||w.dirMap.set(y,[]),w.dirMap.get(y).push(h)}for(const h of c??[])u.has(h)||u.set(h,{nodeId:h,nodeName:r.get(h)??h.slice(0,8),dirMap:new Map});const m=Array.from(u.values()).map(({nodeId:h,nodeName:v,dirMap:p})=>{const b=Array.from(p.entries()).map(([y,w])=>({path:y,tasks:w})).sort((y,w)=>w.tasks.length-y.tasks.length||y.path.localeCompare(w.path));return{nodeId:h,nodeName:v,dirs:b}});return m.sort((h,v)=>{if(o){if(h.nodeId===o)return-1;if(v.nodeId===o)return 1}return h.nodeId===null?1:v.nodeId===null?-1:h.nodeName.localeCompare(v.nodeName)}),m}const Aj=["queued","running"],kj=["copilot.tunnel","copilot.tunnel.disable"],jj=1e4;function i0(n){return n?.status==="succeeded"||n?.status==="failed"}function _j(n){return n.reduce((r,o)=>!r||o.updatedAt>r.updatedAt?o:r,null)}async function Oj(n,r=Z0){const o=await Promise.all(kj.flatMap(s=>Aj.map(c=>r({kind:s,status:c,nodeId:n}))));return _j(o.flat())}function c0(n){return n?.split(/\r?\n/).map(r=>r.trim()).filter(Boolean).at(-1)??null}function Mj(n,r){return[n,...r].join(" ")}function Dj(n,r,o){return r&&!n?"Checking port 8314":n?n.status==="queued"?"Queued":n.status==="running"?n.kind==="copilot.tunnel.disable"?"Stopping Meshy-managed tunnel":n.kind==="copilot.tunnel"?n.result?.status==="auth-required"?"Waiting for GitHub device authorization":"Starting Copilot tunnel":"Checking port 8314":n.status==="succeeded"?n.result?.available?n.result.status==="already-running"?"Port 8314 is already reachable":"Proxy is listening on 8314":n.result?.status==="stopped"?"Meshy-managed tunnel stopped":"Port 8314 is not listening":o??"Tunnel operation failed":"Port 8314 status has not been checked"}function zj(n,r){return r||n?.status==="queued"||n?.status==="running"?f.jsx(ly,{className:"h-3.5 w-3.5 animate-spin text-primary"}):n?.result?.available?f.jsx(Ro,{className:"h-3.5 w-3.5 text-emerald-500"}):n?.status==="failed"?f.jsx(sf,{className:"h-3.5 w-3.5 text-destructive"}):f.jsx(sf,{className:"h-3.5 w-3.5 text-muted-foreground"})}function Lj({checked:n,disabled:r,onCheckedChange:o}){return f.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":"Toggle GitHub Copilot Tunnel",title:n?"Disable GitHub Copilot Tunnel":"Enable GitHub Copilot Tunnel","data-copilot-tunnel-switch":"true",disabled:r,onClick:()=>o(!n),className:ae("relative h-5 w-9 shrink-0 rounded-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",n?"bg-primary/85":"bg-muted"),children:f.jsx("span",{className:ae("absolute left-0.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 rounded-sm bg-background shadow-sm transition-transform",n?"translate-x-4":"translate-x-0")})})}function Uj({nodeId:n,nodeName:r}){const[o,s]=g.useState(null),[c,u]=g.useState(!1),[m,h]=g.useState(!1),v=o?.status==="queued"||o?.status==="running",p=o?.result,b=p?.auth??null,y=o?.error??p?.detail??c0(p?.stderr)??c0(p?.stdout),w=p?Mj(p.command,p.args):"npx -y ghc-tunnel@latest -d",C=!!p?.available||v&&o?.kind==="copilot.tunnel",N=c||m||v,E=g.useMemo(()=>Dj(o,c,y),[c,y,o]);g.useEffect(()=>{let A=!1;async function k(){u(!0);try{const O=await Oj(n);if(A)return;if(O){s(O);return}const B=await Sv(n);A||s(B)}catch(O){A||_e.error(O instanceof Error?O.message:"Failed to check Copilot tunnel")}finally{A||u(!1)}}return s(null),k(),()=>{A=!0}},[n]),g.useEffect(()=>{if(!o||i0(o))return;let A=!1;const k=o.id;async function O(){try{const L=await K0(k);if(A)return;if(L.kind==="copilot.tunnel.status"&&!i0(L)&&Date.now()-L.createdAt>jj){const Z=await Sv(n);A||s(Z);return}s(L),L.status==="succeeded"&&L.kind==="copilot.tunnel"&&_e.success(`Copilot tunnel is available on ${r}`),L.status==="succeeded"&&L.kind==="copilot.tunnel.disable"&&_e.success(`Copilot tunnel stopped on ${r}`),L.status==="failed"&&L.kind!=="copilot.tunnel.status"&&_e.error(L.error??"Copilot tunnel failed")}catch(L){A||_e.error(L instanceof Error?L.message:"Failed to refresh Copilot tunnel")}}O();const B=window.setInterval(O,2e3);return()=>{A=!0,window.clearInterval(B)}},[n,r,o?.id,o?.status]);const T=g.useCallback(async A=>{h(!0);try{const k=A?await VE(n):await YE(n);s(k),_e.info(A?`Copilot tunnel enable requested on ${r}`:`Copilot tunnel stop requested on ${r}`)}catch(k){_e.error(k instanceof Error?k.message:"Failed to update Copilot tunnel")}finally{h(!1)}},[n,r]);return f.jsxs(Sn,{"data-copilot-tunnel-section":"true",className:"rounded-sm border-border/70 bg-background/75 shadow-none xl:col-span-2",children:[f.jsx(wn,{className:"pb-1.5 pt-2.5 px-3",children:f.jsxs("div",{className:"flex items-start justify-between gap-3",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(ay,{className:"h-3.5 w-3.5 text-primary"}),"GitHub Copilot Tunnel"]}),f.jsx(Nn,{className:"text-[10px]",children:"Node-local Copilot proxy model provider."})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[f.jsx("span",{"aria-label":E,title:E,className:"inline-flex h-5 w-5 items-center justify-center",children:zj(o,c)}),f.jsx(Lj,{checked:C,disabled:N,onCheckedChange:A=>{T(A)}})]})]})}),f.jsxs(Tn,{className:"space-y-2 px-3 pb-2.5",children:[f.jsxs("div",{className:"space-y-1.5 rounded-sm bg-background/55 px-2.5 py-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[f.jsx("span",{className:ae("h-1.5 w-1.5 rounded-sm",p?.available?"bg-emerald-500":v||c?"animate-pulse bg-amber-500":o?.status==="failed"?"bg-destructive":"bg-muted-foreground/50")}),E]}),f.jsx("div",{className:"truncate font-mono text-[10px] text-muted-foreground",children:w}),(v||c||m)&&f.jsx("div",{className:"h-0.5 overflow-hidden rounded-sm bg-muted",children:f.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})})]}),b&&v&&f.jsxs("div",{className:"grid gap-2 rounded-sm border border-primary/35 bg-primary/8 px-2.5 py-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",children:[f.jsxs("div",{className:"min-w-0 space-y-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[f.jsx(aT,{className:"h-3.5 w-3.5 animate-pulse text-primary"}),"GitHub device login"]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:[f.jsx("span",{className:"font-mono text-[11px] text-foreground",children:b.code}),b.expiresInSeconds?f.jsxs("span",{children:[Math.ceil(b.expiresInSeconds/60),"m expiry"]}):null]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ct,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7 rounded-sm",title:"Copy device code","aria-label":"Copy device code",onClick:()=>{h1(b.code,"Device code copied")},children:f.jsx(ry,{className:"h-3.5 w-3.5"})}),f.jsx(Ct,{asChild:!0,variant:"outline",size:"icon",className:"h-7 w-7 rounded-sm",title:"Open GitHub device login","aria-label":"Open GitHub device login",children:f.jsx("a",{href:b.url,target:"_blank",rel:"noreferrer",children:f.jsx(oy,{className:"h-3.5 w-3.5"})})})]})]}),y&&o?.status!=="succeeded"&&f.jsx("div",{className:"rounded-sm border border-border/60 bg-muted/35 px-2 py-1 text-[10px] text-muted-foreground",children:y})]})]})}const bc=g.forwardRef(({className:n,type:r,...o},s)=>f.jsx("input",{type:r,className:ae("flex h-8 w-full rounded-sm border border-input/85 bg-background/72 px-2.5 py-1.5 text-[11px] shadow-sm ring-offset-background transition-all duration-200 file:border-0 file:bg-transparent file:text-[11px] file:font-medium file:text-foreground placeholder:text-muted-foreground/75 focus-visible:border-primary/45 focus-visible:bg-background/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/45 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",n),ref:s,...o}));bc.displayName="Input";function Bj(){return be("/system/quick-chats")}function Hj(n){return be("/system/quick-chats",{method:"PUT",body:JSON.stringify({quickChats:n})})}const Cf="quick-chats:updated";function Pj(){typeof window>"u"||window.dispatchEvent(new CustomEvent(Cf))}function $j(){const[n,r]=g.useState([]),[o,s]=g.useState(!0),[c,u]=g.useState(!1),[m,h]=g.useState(null),v=g.useCallback(async()=>{s(!0);try{const b=await Bj();r(b.quickChats),h(null)}catch(b){h(b instanceof Error?b.message:"Failed to load quick chats")}finally{s(!1)}},[]),p=g.useCallback(async b=>{u(!0);try{const y=await Hj(b);return r(y.quickChats),h(null),Pj(),y.quickChats}catch(y){const w=y instanceof Error?y.message:"Failed to save quick chats";throw h(w),y}finally{u(!1)}},[]);return g.useEffect(()=>{v()},[v]),g.useEffect(()=>{if(typeof window>"u")return;const b=()=>{v()};return window.addEventListener(Cf,b),()=>window.removeEventListener(Cf,b)},[v]),{error:m,loading:o,quickChats:n,refresh:v,save:p,saving:c}}function p1(n){return n.trim().replace(/^\/+/,"").toLowerCase()}function g1(n,r){const o=n.trim();if(!o.startsWith("/"))return[];const s=p1(o);return r.filter(c=>c.alias.startsWith(s))}function ec(n,r){return r<=0?-1:(n%r+r)%r}function rM(n,r,o=0){const s=g1(n,r),c=ec(o,s.length);return c>=0?s[c]??null:null}function oM(n,r,o){const s=ec(n,r);return s<0?0:ec(s+o,r)}function lM({query:n,quickChats:r,selectedIndex:o=0,onSelect:s,onActiveIndexChange:c}){const u=g1(n,r);if(u.length===0)return null;const m=ec(o,u.length);return f.jsxs("div",{"data-quick-chat-menu":"true",className:"mx-2 mb-0.5 rounded-sm bg-background/70 p-0.5 shadow-none sm:mx-5",children:[f.jsxs("div",{className:"flex items-center gap-1 px-1 py-0.5 text-[8px] uppercase tracking-[0.14em] text-muted-foreground/75",children:[f.jsx(sy,{className:"h-2.5 w-2.5 text-primary/55"}),"Quick chats"]}),f.jsx("div",{className:"max-h-24 overflow-y-auto",role:"listbox","aria-label":"Quick chats",children:u.map((h,v)=>f.jsxs("button",{type:"button",role:"option","aria-selected":v===m,"data-selected":v===m?"true":void 0,onMouseEnter:()=>c?.(v),onClick:()=>s(h),className:ae("flex w-full min-w-0 items-start gap-1.5 rounded-sm px-1 py-1 text-left text-[9px] transition-colors hover:bg-muted/50 hover:text-foreground"),children:[f.jsxs("span",{"data-quick-chat-alias":"true",className:ae("shrink-0 font-mono text-[9px] leading-3 text-primary/70",v===m&&"text-primary"),children:["/",h.alias]}),f.jsx("span",{"data-quick-chat-prompt":"true",className:ae("line-clamp-1 min-w-0 text-[9px] leading-3 text-muted-foreground",v===m&&"text-primary/90"),children:h.prompt})]},h.alias))})]})}const qj="h-14 w-full resize-none rounded-sm border border-border/70 bg-background/80 px-2 py-1.5 text-[11px] leading-4 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";let Vj=0;function Oi(n,r=0){return{id:n?`${n.alias}:${r}`:`new:${Vj++}`,alias:n?.alias??"",prompt:n?.prompt??""}}function Rf(n){return{quickChats:n.map(r=>({alias:p1(r.alias),prompt:r.prompt.trim()})).filter(r=>r.alias.length>0&&r.prompt.length>0)}}function Yj(n,r){const o=Rf(n).quickChats,s=r.map((u,m)=>Oi(u,m)),c=Rf(s).quickChats;return JSON.stringify(o)!==JSON.stringify(c)}function Ij(){const{error:n,loading:r,quickChats:o,save:s,saving:c}=$j(),[u,m]=g.useState(()=>o.map((y,w)=>Oi(y,w))),h=u.length>0,v=g.useMemo(()=>Rf(u),[u]),p=g.useMemo(()=>Yj(u,o),[u,o]);g.useEffect(()=>{m(o.map((y,w)=>Oi(y,w)))},[o]);async function b(){try{await s(v.quickChats),_e.success("Quick chats saved")}catch(y){_e.error(y instanceof Error?y.message:"Failed to save quick chats")}}return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"rounded-sm border border-border/70 bg-background/75 px-3 py-2.5",children:f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[f.jsx(sy,{className:"h-3.5 w-3.5 text-primary"}),"Quick chats"]}),f.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:"Reusable slash aliases for chat composers on this leader."})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsxs(Ct,{type:"button",variant:"outline",onClick:()=>m(y=>[...y,Oi(void 0,y.length)]),className:"h-7 rounded-sm px-2 text-[10px]",children:[f.jsx(dT,{className:"h-3.5 w-3.5"}),"Add"]}),f.jsxs(Ct,{type:"button",onClick:b,disabled:c||!p,className:"h-7 rounded-sm px-2 text-[10px]",children:[c?f.jsx(ly,{className:"h-3.5 w-3.5 animate-spin"}):f.jsx(bT,{className:"h-3.5 w-3.5"}),"Save"]})]})]})}),r&&!h?f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-4 text-[11px] text-muted-foreground",children:"Loading quick chats..."}):h?f.jsx("div",{className:"space-y-1.5",children:u.map((y,w)=>f.jsxs("div",{className:"grid gap-1.5 rounded-sm border border-border/60 bg-background/70 px-2 py-2 md:grid-cols-[12rem_minmax(0,1fr)_auto]",children:[f.jsx(bc,{"aria-label":`Quick chat ${w+1} alias`,value:y.alias,onChange:C=>m(N=>N.map(E=>E.id===y.id?{...E,alias:C.target.value}:E)),placeholder:"alias",className:"h-7 rounded-sm border-border/70 bg-background/80 px-2 font-mono text-[11px]"}),f.jsx("textarea",{"aria-label":`Quick chat ${w+1} prompt`,value:y.prompt,onChange:C=>m(N=>N.map(E=>E.id===y.id?{...E,prompt:C.target.value}:E)),placeholder:"Prompt text",className:qj}),f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",onClick:()=>m(C=>C.filter(N=>N.id!==y.id)),"aria-label":`Remove quick chat ${w+1}`,className:"h-7 w-7 rounded-sm text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:f.jsx(OT,{className:"h-3.5 w-3.5"})})]},y.id))}):f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-4 text-[11px] text-muted-foreground",children:"No quick chats configured."}),n&&f.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:n})]})}var xc="Checkbox",[Gj]=Fa(xc),[Xj,hm]=Gj(xc);function Qj(n){const{__scopeCheckbox:r,checked:o,children:s,defaultChecked:c,disabled:u,form:m,name:h,onCheckedChange:v,required:p,value:b="on",internal_do_not_use_render:y}=n,[w,C]=_o({prop:o,defaultProp:c??!1,onChange:v,caller:xc}),[N,E]=g.useState(null),[T,A]=g.useState(null),k=g.useRef(!1),O=N?!!m||!!N.closest("form"):!0,B={checked:w,disabled:u,setChecked:C,control:N,setControl:E,name:h,form:m,value:b,hasConsumerStoppedPropagationRef:k,required:p,defaultChecked:Ga(c)?!1:c,isFormControl:O,bubbleInput:T,setBubbleInput:A};return f.jsx(Xj,{scope:r,...B,children:Kj(y)?y(B):s})}var v1="CheckboxTrigger",y1=g.forwardRef(({__scopeCheckbox:n,onKeyDown:r,onClick:o,...s},c)=>{const{control:u,value:m,disabled:h,checked:v,required:p,setControl:b,setChecked:y,hasConsumerStoppedPropagationRef:w,isFormControl:C,bubbleInput:N}=hm(v1,n),E=We(c,b),T=g.useRef(v);return g.useEffect(()=>{const A=u?.form;if(A){const k=()=>y(T.current);return A.addEventListener("reset",k),()=>A.removeEventListener("reset",k)}},[u,y]),f.jsx(Le.button,{type:"button",role:"checkbox","aria-checked":Ga(v)?"mixed":v,"aria-required":p,"data-state":E1(v),"data-disabled":h?"":void 0,disabled:h,value:m,...s,ref:E,onKeyDown:ze(r,A=>{A.key==="Enter"&&A.preventDefault()}),onClick:ze(o,A=>{y(k=>Ga(k)?!0:!k),N&&C&&(w.current=A.isPropagationStopped(),w.current||A.stopPropagation())})})});y1.displayName=v1;var pm=g.forwardRef((n,r)=>{const{__scopeCheckbox:o,name:s,checked:c,defaultChecked:u,required:m,disabled:h,value:v,onCheckedChange:p,form:b,...y}=n;return f.jsx(Qj,{__scopeCheckbox:o,checked:c,defaultChecked:u,disabled:h,required:m,onCheckedChange:p,name:s,form:b,value:v,internal_do_not_use_render:({isFormControl:w})=>f.jsxs(f.Fragment,{children:[f.jsx(y1,{...y,ref:r,__scopeCheckbox:o}),w&&f.jsx(w1,{__scopeCheckbox:o})]})})});pm.displayName=xc;var b1="CheckboxIndicator",x1=g.forwardRef((n,r)=>{const{__scopeCheckbox:o,forceMount:s,...c}=n,u=hm(b1,o);return f.jsx(Uo,{present:s||Ga(u.checked)||u.checked===!0,children:f.jsx(Le.span,{"data-state":E1(u.checked),"data-disabled":u.disabled?"":void 0,...c,ref:r,style:{pointerEvents:"none",...n.style}})})});x1.displayName=b1;var S1="CheckboxBubbleInput",w1=g.forwardRef(({__scopeCheckbox:n,...r},o)=>{const{control:s,hasConsumerStoppedPropagationRef:c,checked:u,defaultChecked:m,required:h,disabled:v,name:p,value:b,form:y,bubbleInput:w,setBubbleInput:C}=hm(S1,n),N=We(o,C),E=$b(u),T=jb(s);g.useEffect(()=>{const k=w;if(!k)return;const O=window.HTMLInputElement.prototype,L=Object.getOwnPropertyDescriptor(O,"checked").set,Z=!c.current;if(E!==u&&L){const V=new Event("click",{bubbles:Z});k.indeterminate=Ga(u),L.call(k,Ga(u)?!1:u),k.dispatchEvent(V)}},[w,E,u,c]);const A=g.useRef(Ga(u)?!1:u);return f.jsx(Le.input,{type:"checkbox","aria-hidden":!0,defaultChecked:m??A.current,required:h,disabled:v,name:p,value:b,form:y,...r,tabIndex:-1,ref:N,style:{...r.style,...T,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});w1.displayName=S1;function Kj(n){return typeof n=="function"}function Ga(n){return n==="indeterminate"}function E1(n){return Ga(n)?"indeterminate":n?"checked":"unchecked"}const N1=g.forwardRef(({className:n,...r},o)=>f.jsx(pm,{ref:o,className:ae("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",n),...r,children:f.jsx(x1,{className:ae("flex items-center justify-center text-current"),children:f.jsx(Li,{className:"h-3.5 w-3.5"})})}));N1.displayName=pm.displayName;const u0=["queued","running"];function Zj(n){return n.map(r=>`${r.id}:${r.name}`).join("\0")}function Fj(n){return n==="claude"||n==="codex"||n==="copilot"}function T1(n){if(n.kind!=="agent.upgrade")return null;const r=n.payload?.agent;return Fj(r)?`${n.nodeId}:${r}`:null}function Wj(n){return n.status==="succeeded"||n.status==="failed"}async function C1(n,r={}){const o=r.getOperation??K0,s=r.pollIntervalMs??2e3,c=r.timeoutMs??24e4,u=Date.now()+c;let m=n;for(;!Wj(m)&&Date.now()<u;)await e_(s),m=await o(n.id);return m}async function Jj(n,r=Z0){const o=new Set(n),s=await Promise.all(u0.map(u=>r({kind:"agent.upgrade",status:u}))),c=new Map;for(const u of s.flat()){if(!u0.includes(u.status)||o.size>0&&!o.has(u.nodeId))continue;const m=T1(u);if(!m)continue;const h=c.get(m);(!h||u.updatedAt>h.updatedAt)&&c.set(m,u)}return c}function e_(n){return new Promise(r=>setTimeout(r,n))}const t_=1500,n_=1e3,a_=9e4;async function R1(n={}){const r=n.fetchHealth??r_,o=n.initialDelayMs??t_,s=n.pollIntervalMs??n_,c=n.previousPid,u=n.reload??(()=>window.location.reload()),m=n.sleep??l_,h=n.timeoutMs??a_,v=Date.now()+h;let p=!1;for(o>0&&await m(o);Date.now()<=v;){const b=o_(await r());if(!b.ok){p=!0,await m(s);continue}if(c===void 0||b.pid!==void 0&&b.pid!==c||p)return u(),!0;await m(s)}return!1}async function r_(){try{const n=await fetch("/api/system/health",{cache:"no-store"}),r=await n.json().catch(()=>null),o=r&&typeof r=="object"&&typeof r.pid=="number"?r.pid:void 0;return{ok:n.ok,pid:o}}catch{return!1}}function o_(n){return typeof n=="boolean"?{ok:n}:n}function l_(n){return new Promise(r=>window.setTimeout(r,n))}function s_(n,r=!0){return r?n?.restartMode==="development"?"Restart dev runtime":n?.updateAvailable?"Restart to update":"Restart runtime":n?.updateAvailable?"Restart follower to update":"Restart follower"}function i_({checkedLabel:n,disableAuthDefault:r,endpoint:o,isLiveLocalNode:s,nodeId:c,nodeName:u,onRefresh:m,pid:h,transportType:v,update:p,workDir:b}){const y=s_(p,s),[w,C]=g.useState(null),[N,E]=g.useState(()=>d0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:v,workDir:b})),[T,A]=g.useState(!1),[k,O]=g.useState(!1),[B,L]=g.useState(!1);g.useEffect(()=>{E(d0({disableAuthDefault:r,endpoint:o,nodeName:u,transportType:v,workDir:b}))},[r,o,u,v,b]);async function Z(){if(!c||T||k)return;const ce=p.updateAvailable?"update":"restart",ue=d_(N);if(N.port.trim()&&ue?.port===void 0){_e.error("Runtime restart port must be a positive integer");return}const W=ue?{reason:ce,startArgs:ue}:{reason:ce};A(!0);try{if(s){const _=await F0(W);C({..._,pid:_.pid??h,status:"accepted"}),_e.info(`Restarting ${u} from a detached helper. PID ${_.pid??h??"unknown"} will not stay attached to the original terminal window; follow ${_.logPath} for launch output.`),R1({previousPid:_.pid??h}).then(P=>{P||(A(!1),_e.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout. Refresh the page after the node finishes starting."))}).catch(P=>{A(!1),_e.error(P instanceof Error?P.message:"Runtime restart recovery failed")});return}const ee=await KE(c,W);C({operationId:ee.id,pid:h,status:ee.status}),_e.info(`Restart requested on ${u}. Operation ${Fd(ee.id)} will hand off to a detached process, so the new runtime will not stay attached to the original terminal window.`);const le=await C1(ee,{timeoutMs:6e4}),J=u_(le);C({command:J?.command,logPath:J?.logPath,mode:J?.mode,operationId:le.id,pid:J?.pid??h,status:le.status}),le.status==="succeeded"?(await m?.(),_e.success(`Restart handoff accepted on ${u}. Follow ${J?.logPath??"the node restart log"} for launch output.`)):le.status==="failed"?_e.error(le.error??`Restart failed on ${u}`):_e.info(`Restart operation ${Fd(le.id)} is still ${le.status}. More details will update after the node reports back.`),A(!1)}catch(ee){A(!1),_e.error(ee instanceof Error?ee.message:"Runtime restart failed")}}async function V(){if(!(!s||T||k)){O(!0);try{const ce=await GE();_e.info(`Stopping Meshy process ${ce.pid}`)}catch(ce){O(!1),_e.error(ce instanceof Error?ce.message:"Runtime stop failed")}}}const $=T?"restarting":k?"stopping":w?.status??"idle",G=p.restartMode==="development";return f.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/70 bg-background/70",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border/50",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(zi,{className:"h-3.5 w-3.5 text-primary shrink-0"}),f.jsxs("div",{children:[f.jsx("div",{className:"text-[11px] font-semibold text-foreground leading-tight",children:"Runtime"}),f.jsx("div",{className:"text-[10px] text-muted-foreground leading-tight",children:G?"Development launcher":`Latest ${p.latestVersion??"—"}`})]})]}),f.jsx("div",{className:"flex items-center gap-1.5",children:f.jsx(_t,{variant:p.updateAvailable?"default":"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 font-mono text-[10px]",children:G?"dev":p.updateAvailable?`→ ${p.latestVersion}`:"current"})})]}),f.jsxs("div",{className:"grid grid-cols-2 divide-x divide-border/50 border-b border-border/50",children:[f.jsxs("div",{className:"px-3 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"PID"}),f.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-foreground",children:h??"—"})]}),f.jsxs("div",{className:"px-3 py-1.5",children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:"Status"}),f.jsx("div",{className:"mt-0.5 text-[11px] text-foreground capitalize",children:$})]})]}),f.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2",children:[f.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Checked ",n]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[s&&f.jsxs(Nf,{children:[f.jsx(Tf,{asChild:!0,children:f.jsxs(Ct,{type:"button",size:"sm",variant:"ghost",disabled:T||k,className:"h-7 rounded-sm px-2 text-[11px] text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:[f.jsx(mT,{className:ae("mr-1 h-3.5 w-3.5",k&&"animate-pulse")}),k?"Stopping":"Stop"]})}),f.jsxs(Xi,{className:"max-w-[22rem] gap-2 rounded-sm p-4",children:[f.jsxs(Qi,{className:"space-y-1",children:[f.jsx(Zi,{className:"text-sm",children:"Stop runtime?"}),f.jsx(Fi,{className:"text-[11px] leading-4",children:"Gracefully stops the current Meshy process without launching a replacement. The dashboard will disconnect until the node is started again."})]}),f.jsxs(Ki,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Ji,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Wi,{className:"h-7 rounded-sm bg-destructive px-2 text-[11px] text-destructive-foreground hover:bg-destructive/90",onClick:()=>{V()},children:"Stop runtime"})]})]})]}),f.jsxs(Nf,{children:[f.jsx(Tf,{asChild:!0,children:f.jsxs(Ct,{type:"button",size:"sm",variant:p.updateAvailable?"default":"outline",disabled:!c||T||k,className:"h-7 rounded-sm px-2 text-[11px]",children:[f.jsx(Ri,{className:ae("mr-1 h-3.5 w-3.5",T&&"animate-spin")}),T?"Restarting…":y]})}),f.jsxs(Xi,{className:"max-w-[28rem] gap-3 rounded-sm p-4",children:[f.jsxs(Qi,{className:"space-y-1",children:[f.jsxs(Zi,{className:"text-sm",children:[y,"?"]}),f.jsxs(Fi,{className:"text-[11px] leading-4",children:["Starts a detached restart helper, shuts down ",s?"the current node":u,", and brings it back with the configured launcher. The new process will not stay attached to the original terminal window."]})]}),f.jsx(c_,{value:N,onChange:E}),f.jsxs(Ki,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Ji,{className:"h-7 rounded-sm px-2 text-[11px]",children:"Cancel"}),f.jsx(Wi,{className:"h-7 rounded-sm px-2 text-[11px]",onClick:()=>{Z()},children:y})]})]})]})]})]}),f.jsxs("div",{className:"border-t border-border/50",children:[f.jsxs("button",{type:"button",onClick:()=>L(ce=>!ce),className:"flex w-full items-center justify-between px-3 py-1.5 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(fy,{className:"h-3 w-3"}),"Restart details"]}),f.jsx(Zl,{className:ae("h-3 w-3 transition-transform duration-150",B&&"rotate-180")})]}),B&&f.jsxs("div",{className:"border-t border-border/50 bg-muted/20 px-3 py-2 space-y-1",children:[f.jsx(Er,{label:"Current PID",value:h===void 0?"—":String(h),mono:h!==void 0}),f.jsx(Er,{label:"Restart PID",value:w?.pid===void 0?"Pending":String(w.pid),mono:w?.pid!==void 0}),f.jsx(Er,{label:"Operation",value:w?.operationId?Fd(w.operationId):"Local direct request",mono:!!w?.operationId}),f.jsx(Er,{label:"Status",value:w?.status??(T?"requested":"idle")}),f.jsx(Er,{label:"Launcher",value:w?.command??"Available after restart",mono:!!w?.command}),f.jsx(Er,{label:"Log",value:w?.logPath??"Available after restart",mono:!!w?.logPath}),f.jsx(Er,{label:"Terminal",value:"New process is detached from original terminal"})]})]}),p.detail&&f.jsx("div",{className:"border-t border-border/50 px-3 py-1.5 text-[10px] text-muted-foreground bg-muted/20",children:p.detail})]})}function c_({onChange:n,value:r}){const o=(s,c)=>{n({...r,[s]:c})};return f.jsxs("div",{className:"rounded-lg border border-border/70 bg-muted/30 p-3 space-y-3",children:[f.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Startup arguments"}),f.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[f.jsx(Pl,{label:"HTTP port",value:r.port,onChange:s=>o("port",s),inputMode:"numeric"}),f.jsx(Pl,{label:"Node name",value:r.name,onChange:s=>o("name",s)}),f.jsx(Pl,{label:"Join endpoint",value:r.join,onChange:s=>o("join",s),className:"sm:col-span-2"}),f.jsxs("div",{className:"space-y-1",children:[f.jsx("label",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:"Transport"}),f.jsxs(Sf,{value:r.transport,onValueChange:s=>o("transport",A1(s)),children:[f.jsx(Ii,{className:"h-7 rounded-md border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(wf,{placeholder:"Transport"})}),f.jsxs(Gi,{children:[f.jsx(ua,{className:"py-1 text-[11px]",value:"inherit",children:"current / default"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"direct",children:"direct"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"devtunnel",children:"devtunnel"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"tailscale",children:"tailscale"})]})]})]}),f.jsx(Pl,{label:"Working directory",value:r.workDir,onChange:s=>o("workDir",s)}),f.jsx(Pl,{label:"Config path",value:r.config,onChange:s=>o("config",s),className:"sm:col-span-2"}),f.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[f.jsx("label",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:"GHC tunnel"}),f.jsxs(Sf,{value:r.ghcTunnel,onValueChange:s=>o("ghcTunnel",f_(s)),children:[f.jsx(Ii,{className:"h-7 rounded-sm border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(wf,{placeholder:"GHC tunnel"})}),f.jsxs(Gi,{children:[f.jsx(ua,{className:"py-1 text-[11px]",value:"inherit",children:"current / remembered"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"enable",children:"enable"}),f.jsx(ua,{className:"py-1 text-[11px]",value:"disable",children:"disable"})]})]})]}),f.jsxs("label",{className:"flex items-center gap-2 rounded-md border border-border/60 bg-background/60 px-2 py-1.5 text-[10px] text-foreground sm:col-span-2 cursor-pointer hover:bg-muted/40 transition-colors",children:[f.jsx(N1,{className:"h-3.5 w-3.5",checked:r.disableAuth,onCheckedChange:s=>n({...r,disableAuth:s===!0,disableAuthKnown:!0})}),"Disable auth"]})]})]})}function Pl({className:n,inputMode:r,label:o,onChange:s,value:c}){return f.jsxs("label",{className:ae("space-y-1",n),children:[f.jsx("span",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:o}),f.jsx(bc,{className:"h-7 rounded-md px-2 text-[10px]",inputMode:r,value:c,onChange:u=>s(u.target.value)})]})}function Er({label:n,value:r,mono:o=!1}){return f.jsxs("div",{className:"flex items-start justify-between gap-3 text-[10px]",children:[f.jsx("span",{className:"shrink-0 uppercase tracking-[0.14em] text-muted-foreground",children:n}),f.jsx("span",{className:ae("break-all text-right text-foreground",o&&"font-mono"),children:r})]})}function u_(n){const r=n.result;if(!r||typeof r!="object")return null;const o=r;return o.ok!==!0||typeof o.command!="string"||typeof o.logPath!="string"?null:{ok:!0,mode:o.mode==="package"?"package":"development",command:o.command,logPath:o.logPath,pid:typeof o.pid=="number"?o.pid:void 0}}function d0(n){return{port:m_(n.endpoint),name:n.nodeName,join:"",transport:A1(n.transportType),workDir:n.workDir??"",config:"",disableAuth:n.disableAuthDefault===!0,disableAuthKnown:n.disableAuthDefault!==void 0,ghcTunnel:"inherit"}}function d_(n){const r={},o=Number(n.port.trim());return n.port.trim()&&Number.isInteger(o)&&o>0&&(r.port=o),n.name.trim()&&(r.name=n.name.trim()),n.join.trim()&&(r.join=n.join.trim()),n.transport!=="inherit"&&(r.transport=n.transport),n.workDir.trim()&&(r.workDir=n.workDir.trim()),n.config.trim()&&(r.config=n.config.trim()),n.disableAuthKnown&&(r.disableAuth=n.disableAuth),n.ghcTunnel==="enable"&&(r.ghcTunnel=!0),n.ghcTunnel==="disable"&&(r.ghcTunnel=!1),Object.keys(r).length>0?r:void 0}function A1(n){return n==="direct"||n==="devtunnel"||n==="tailscale"?n:"inherit"}function f_(n){return n==="enable"||n==="disable"?n:"inherit"}function m_(n){if(!n)return"";try{return new URL(n).port||""}catch{return""}}function Fd(n){return n.length<=8?n:n.slice(0,8)}function $l({formatDateTime:n,name:r,status:o,statusVariant:s}){return f.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-border/60 bg-background/70 px-2.5 py-1.5",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[11px] font-medium text-foreground",children:r}),f.jsx("div",{className:"text-[10px] text-muted-foreground",children:n(o?.checkedAt)})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof o?.authenticated=="boolean"&&f.jsx(_t,{variant:o.authenticated?"default":"outline",className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o.authenticated?"auth ok":"auth required"}),f.jsx(_t,{variant:s(o?.status),className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o?.status??"unknown"})]})]})}function qt(n){if(n==null||n==="")return"Unavailable";const r=new Date(n);return Number.isNaN(r.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(r)}function h_(n){const r=Math.max(0,Math.floor(n)),o=Math.floor(r/86400),s=Math.floor(r%86400/3600),c=Math.floor(r%3600/60);return o>0?`${o}d ${s}h`:s>0?`${s}h ${c}m`:`${c}m`}function f0(n){if(n==null||Number.isNaN(n))return"Unavailable";const r=["B","KB","MB","GB","TB"];let o=n,s=0;for(;o>=1024&&s<r.length-1;)o/=1024,s+=1;return`${o.toFixed(o>=10||s===0?0:1)} ${r[s]}`}function Co(n){return n==="ok"?"default":n==="missing"||n==="install-failed"||n==="login-failed"?"destructive":n==="not-authenticated"||n==="unsupported-platform"?"outline":"secondary"}function p_(n){return n.available?f.jsx("span",{"data-agent-availability":"available","aria-label":"Available",title:"Available",className:"inline-flex h-5 w-5 items-center justify-center text-emerald-500",children:f.jsx(Ro,{className:"h-3.5 w-3.5"})}):f.jsx("span",{"data-agent-availability":"unavailable","aria-label":"Unavailable",title:"Unavailable",className:"inline-flex h-5 w-5 items-center justify-center text-destructive",children:f.jsx(sf,{className:"h-3.5 w-3.5"})})}function g_(n){return n.update?n.update.updateAvailable?f.jsxs(_t,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Update ",n.update.latestVersion]}):f.jsx(_t,{variant:"secondary",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:"Up to date"}):null}function v_(n){return n.available?null:n.metadataStatus??null}function y_(n){const r=`npm install -g ${n.update?.packageName}@latest`;return n.id==="claude"?`${r} --include=optional --ignore-scripts=false`:r}function b_(n){return n.error?n.error:n.result?.detail??null}function Fe({label:n,value:r,mono:o=!1}){return f.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border/50 py-1 last:border-b-0 last:pb-0 first:pt-0",children:[f.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:n}),f.jsx("span",{className:ae("break-all text-right text-[11px] text-foreground",o&&"font-mono text-[11px]"),children:r})]})}function ql({label:n,value:r,mono:o=!1,className:s}){return f.jsxs("div",{className:ae("min-w-0 space-y-0.5",s),children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:n}),f.jsx("div",{className:ae("truncate text-[11px] text-foreground",o&&"font-mono",n==="Path"&&"break-all whitespace-normal"),children:r})]})}function x_({agent:n,nodeName:r,activeOperation:o,onUpgrade:s}){const c=n.update?.updateAvailable===!0,u=g_(n),m=!!o,h=v_(n);return f.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/65 px-3 py-2.5 transition-colors hover:bg-background/85",children:[f.jsxs("div",{className:"grid gap-3 lg:grid-cols-[12rem_minmax(0,1fr)_auto] lg:items-start",children:[f.jsxs("div",{className:"min-w-0 space-y-1.5",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[f.jsx(ny,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),f.jsx("span",{className:"truncate",children:n.label})]}),f.jsxs("div",{className:"truncate text-[10px] text-muted-foreground",children:["Command: ",f.jsx("span",{className:"font-mono text-[10px]",children:n.command})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[p_(n),h&&f.jsx(_t,{variant:Co(h),className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:h})]})]}),f.jsxs("div",{className:"grid min-w-0 gap-x-4 gap-y-1.5 sm:grid-cols-2",children:[f.jsx(ql,{label:"Version",value:n.version??"Unavailable",mono:!!n.version}),n.update&&f.jsx(ql,{label:"Latest",value:n.update.latestVersion??"Unavailable",mono:!!n.update.latestVersion}),f.jsx(ql,{label:"Checked",value:qt(n.checkedAt)}),n.update&&f.jsx(ql,{label:"Update check",value:qt(n.update.checkedAt)}),f.jsx(ql,{label:"Path",value:n.path??"Not on PATH",mono:!!n.path,className:"sm:col-span-2"})]}),f.jsx("div",{className:"flex items-start justify-start lg:justify-end",children:o?f.jsxs(_t,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.14em]",children:["Upgrade ",o.status]}):c?f.jsxs(Nf,{children:[f.jsx(Tf,{asChild:!0,children:f.jsx("button",{type:"button",disabled:m,className:"rounded-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60",children:u})}),f.jsxs(Xi,{children:[f.jsxs(Qi,{children:[f.jsxs(Zi,{children:["Upgrade ",n.label,"?"]}),f.jsxs(Fi,{children:["This runs ",y_(n)," on ",r,". Remote nodes execute the command on the remote machine."]})]}),f.jsxs(Ki,{children:[f.jsx(Ji,{children:"Cancel"}),f.jsx(Wi,{onClick:()=>s(n),children:"Upgrade"})]})]})]}):u})]}),n.update?.detail&&f.jsx("div",{className:"mt-2 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:n.update.detail}),n.detail&&f.jsx("div",{className:"mt-2 rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[10px] text-muted-foreground",children:n.detail})]})}function S_(n,r){return n?.nodes?.length?n.nodes:r?[r]:[]}function w_(n,r){if(r&&n.id===r.nodeId)return r;const o=n.settingsSnapshot;return{...n,nodeId:n.id,version:o?.version??"Unavailable",packageName:o?.packageName,uptime:o?.uptime??0,localDashboardOrigin:o?.runtime?.localDashboardOrigin??void 0,auth:o?.auth,os:o?.os,runtime:o?.runtime,runtimeUpdate:o?.runtimeUpdate,agents:o?.agents,startupRequirements:o?.startupRequirements,components:o?.components,repository:o?.repository,packages:o?.packages}}function E_(n,r){return n.id===r?`${n.name} (this node)`:`${n.name} (${n.role})`}function N_(n){return n==="claude"?"Claude Code":n==="copilot"?"Copilot CLI":"Codex"}function T_(n){const r=n.payload?.agent;return r==="claude"||r==="codex"||r==="copilot"?r:null}function C_({cluster:n,systemInfo:r,sseConnected:o,initialSelectedNodeId:s,onRefresh:c}){const u=g.useMemo(()=>S_(n,r),[n,r]),[m,h]=g.useState(()=>s??r?.nodeId??n?.self?.id??""),[v,p]=g.useState(()=>new Map),b=g.useRef(new Set),y=g.useRef(new Set),w=n?.self??r??u[0]??null,C=u.find(G=>G.id===m)??w,N=C?w_(C,r):null,E=!!(r&&C&&C.id===r.nodeId),T=E||!!C?.settingsSnapshot,A=N?.runtimeUpdate,k=N?.startupRequirements?.components??N?.components??{},O=g.useMemo(()=>u.map(G=>G.id),[u]),B=O.join("\0"),L=Zj(u),Z=g.useMemo(()=>new Map(u.map(G=>[G.id,G.name])),[L]);g.useEffect(()=>{s&&O.includes(s)&&h(s)},[s,B]);const V=g.useCallback(async(G,ce)=>{const ue=T1(G);if(!ue||b.current.has(G.id))return;const W=T_(G),ee=ce?.agentLabel??(W?N_(W):"Agent"),le=ce?.nodeName??Z.get(G.nodeId)??G.nodeId;b.current.add(G.id),p(J=>new Map(J).set(ue,G));try{const J=await C1(G);if(J.status==="succeeded")await c?.(),y.current.has(J.id)||(_e.success(`${ee} upgrade finished on ${le}`),y.current.add(J.id));else if(J.status==="failed")y.current.has(J.id)||(_e.error(b_(J)??`${ee} upgrade failed`),y.current.add(J.id));else{p(_=>new Map(_).set(ue,J)),_e.info(`${ee} upgrade is still ${J.status} on ${le}`);return}p(_=>{const P=new Map(_),X=P.get(ue);return(!X||X.id===J.id)&&P.delete(ue),P})}catch(J){p(_=>{const P=new Map(_),X=P.get(ue);return(!X||X.id===G.id)&&P.delete(ue),P}),_e.error(J instanceof Error?J.message:`${ee} upgrade failed`)}finally{b.current.delete(G.id)}},[c,Z]);g.useEffect(()=>{if(O.length===0)return;let G=!1;async function ce(){let ue;try{ue=await Jj(O)}catch{return}if(!G){p(W=>{const ee=new Map(W);for(const[le,J]of ue)ee.set(le,J);return ee});for(const W of ue.values())V(W)}}return ce(),()=>{G=!0}},[V,B]);async function $(G){if(C)try{const ce=await QE(C.id,G.id);_e.info(`${G.label} upgrade started on ${C.name}`),await V(ce,{agentLabel:G.label,nodeName:C.name})}catch(ce){_e.error(ce instanceof Error?ce.message:`${G.label} upgrade failed`)}}return!C||!N?f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-5 text-center text-[11px] text-muted-foreground",children:"Loading session metadata..."}):f.jsxs("div",{className:"space-y-3",children:[f.jsxs("section",{className:"relative mt-1 rounded-sm border border-border/70 bg-background/75 p-3 shadow-none",children:[!E&&f.jsxs(_t,{variant:"outline",className:"absolute right-3 top-2.5 rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em] whitespace-nowrap",children:["Updated ",qt(C.settingsSnapshot?.collectedAt)]}),f.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-end md:justify-between",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.jsxs("span",{className:"flex items-center gap-1.5 rounded-sm border border-border/70 bg-background/75 px-1.5 py-0 text-[10px] text-muted-foreground",children:[f.jsx(hj,{status:C.status}),f.jsx("span",{className:"font-medium text-foreground",children:C.name})]}),f.jsx(pj,{role:C.role}),f.jsx(_t,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:C.transportType??N.transportType??"direct"}),f.jsx(_t,{variant:E?"default":"outline",className:"rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:E?"Live local session":"Leader-synced snapshot"})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.34em] text-muted-foreground",children:"Session"}),f.jsx("h3",{className:"mt-0.5 text-sm font-semibold tracking-tight text-foreground",children:"Node runtime"}),f.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Runtime environment, connectivity, and build metadata."})]}),u.length>1&&f.jsxs("div",{className:"w-48 space-y-1.5",children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Inspect node"}),f.jsxs(Sf,{value:C.id,onValueChange:h,children:[f.jsx(Ii,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px]",children:f.jsx(wf,{placeholder:"Choose a node"})}),f.jsx(Gi,{className:"settings-node-select-content rounded-sm text-[10px] leading-4",children:u.map(G=>f.jsx(ua,{value:G.id,className:"settings-node-select-item py-1 pl-6 pr-2 text-[10px] leading-4 [&>span]:left-1.5 [&_svg]:h-3 [&_svg]:w-3",children:E_(G,r?.nodeId)},G.id))})]})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(_t,{variant:o?"default":"outline",className:"gap-1 rounded-sm px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:[f.jsx(pT,{className:"h-3 w-3"}),o?"Live link":"Reconnecting"]}),f.jsxs(_t,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[10px] uppercase tracking-[0.16em]",children:["Uptime ",h_(N.uptime)]})]})]})]}),!T&&f.jsx("div",{className:"rounded-sm border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-[11px] text-muted-foreground",children:"This node has not synced its settings snapshot to the leader yet. Wait for the next keepalive and reopen the dialog if needed."}),f.jsxs(Jk,{defaultValue:"session",className:"space-y-2",children:[f.jsxs(Gx,{className:"h-auto flex-wrap rounded-sm border border-border/60 bg-muted/40 p-0.5",children:[f.jsx(Il,{value:"session",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Session"}),f.jsx(Il,{value:"access",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Access"}),f.jsx(Il,{value:"quick-chats",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Quick chats"}),f.jsx(Il,{value:"about",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"About"})]}),f.jsxs(Gl,{value:"session",className:"mt-0 grid gap-2 xl:grid-cols-[1.15fr_0.85fr]",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(uy,{className:"h-3.5 w-3.5 text-primary"}),"Selected node"]}),f.jsx(Nn,{className:"text-[10px]",children:"Cluster role, identity, and node-scoped runtime state."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Node ID",value:N.nodeId,mono:!0}),f.jsx(Fe,{label:"Status",value:C.status}),f.jsx(Fe,{label:"Role",value:C.role}),f.jsx(Fe,{label:"Endpoint",value:C.endpoint,mono:!0}),f.jsx(Fe,{label:"Joined",value:qt(C.joinedAt)}),f.jsx(Fe,{label:"Heartbeat",value:qt(C.lastHeartbeat)}),f.jsx(Fe,{label:"Capabilities",value:C.capabilities.length>0?C.capabilities.join(", "):"None"})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(QN,{className:"h-3.5 w-3.5 text-primary"}),"OS info"]}),f.jsx(Nn,{className:"text-[10px]",children:"Host and resource details reported by the current process."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Host",value:N.os?.hostname??"Unavailable"}),f.jsx(Fe,{label:"Platform",value:N.os?`${N.os.platform} ${N.os.release}`:"Unavailable"}),f.jsx(Fe,{label:"Arch",value:N.os?.arch??"Unavailable"}),f.jsx(Fe,{label:"CPU",value:N.os?.cpuModel??"Unavailable"}),f.jsx(Fe,{label:"Cores",value:String(N.os?.cpuCount??"Unavailable")}),f.jsx(Fe,{label:"Memory",value:N.os?`${f0(N.os.freeMemoryBytes)} free / ${f0(N.os.totalMemoryBytes)} total`:"Unavailable"})]})]}),A&&f.jsx("div",{className:"xl:col-span-2",children:f.jsx(i_,{checkedLabel:qt(A.checkedAt),disableAuthDefault:N.auth?.enabled===void 0?void 0:N.auth.enabled===!1,endpoint:C.endpoint,isLiveLocalNode:E,nodeId:C.id,nodeName:C.name,onRefresh:c,pid:N.runtime?.pid,transportType:C.transportType,update:A,workDir:N.runtime?.workDir??C.workDir})}),f.jsx(Uj,{nodeId:C.id,nodeName:C.name}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none xl:col-span-2",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(ny,{className:"h-3.5 w-3.5 text-primary"}),"Available agents"]}),f.jsx(Nn,{className:"text-[10px]",children:E?"Live command availability for runtime agents on this node.":"Most recent agent availability snapshot synced from this node."})]}),f.jsx(Tn,{"data-agent-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:(N.agents??[]).map(G=>f.jsx(x_,{agent:G,nodeName:C.name,activeOperation:v.get(`${C.id}:${G.id}`),onUpgrade:$},G.id))})]})]}),f.jsxs(Gl,{value:"access",className:"mt-0 grid gap-2 xl:grid-cols-2",children:[f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(ay,{className:"h-3.5 w-3.5 text-primary"}),"Access surface"]}),f.jsx(Nn,{className:"text-[10px]",children:"How this node is exposed to the dashboard and other peers."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Transport",value:C.transportType??N.transportType??"direct"}),f.jsx(Fe,{label:"Node URL",value:C.endpoint,mono:!0}),f.jsx(Fe,{label:"Node tunnel",value:C.devtunnelEndpoint??"Disabled",mono:!!C.devtunnelEndpoint}),f.jsx(Fe,{label:"Dashboard URL",value:C.dashboardOrigin??N.localDashboardOrigin??"Unavailable",mono:!!(C.dashboardOrigin||N.localDashboardOrigin)}),f.jsx(Fe,{label:"Local dashboard",value:N.localDashboardOrigin??"Unavailable",mono:!!N.localDashboardOrigin})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(CT,{className:"h-3.5 w-3.5 text-primary"}),"Auth"]}),f.jsx(Nn,{className:"text-[10px]",children:"Current bearer-auth and trusted access posture."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Enabled",value:N.auth?.enabled?"Yes":"No"}),f.jsx(Fe,{label:"Same tenant",value:N.auth?.allowSameTenant?"Allowed":"Off"}),f.jsx(Fe,{label:"Allowed users",value:N.auth?.allowedUsers.length?N.auth.allowedUsers.join(", "):"None"})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(FN,{className:"h-3.5 w-3.5 text-primary"}),"Paths"]}),f.jsx(Nn,{className:"text-[10px]",children:"Workspace and runtime paths currently used by this node."})]}),f.jsxs(Tn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(Fe,{label:"Work dir",value:N.runtime?.workDir??N.workDir??"Unavailable",mono:!!(N.runtime?.workDir??N.workDir)}),f.jsx(Fe,{label:"Storage",value:N.runtime?.storagePath??"Unavailable",mono:!!N.runtime?.storagePath}),f.jsx(Fe,{label:"Process cwd",value:N.runtime?.cwd??"Unavailable",mono:!!N.runtime?.cwd}),f.jsx(Fe,{label:"Started",value:qt(N.runtime?.startedAt)}),f.jsx(Fe,{label:"PID",value:N.runtime?String(N.runtime.pid):"Unavailable",mono:!!N.runtime})]})]}),f.jsxs(Sn,{className:"rounded-sm border-border/70 bg-background/75 shadow-none",children:[f.jsxs(wn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(En,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(zi,{className:"h-3.5 w-3.5 text-primary"}),"Startup checks"]}),f.jsx(Nn,{className:"text-[10px]",children:"Dependency preflight snapshot persisted during node startup."})]}),f.jsxs(Tn,{className:"space-y-3 px-3 pb-2.5",children:[f.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/70 px-3 py-2",children:[f.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:"Last checked"}),f.jsx("div",{className:"mt-0.5 text-[11px] text-foreground",children:qt(N.startupRequirements?.lastCheckedAt)})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx($l,{formatDateTime:qt,name:"Azure CLI",status:k.az,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"DevTunnel",status:k.devtunnel,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Claude Code",status:k.claude,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Codex",status:k.codex,statusVariant:Co}),f.jsx($l,{formatDateTime:qt,name:"Copilot CLI",status:k.copilot,statusVariant:Co})]})]})]})]}),f.jsx(Gl,{value:"quick-chats",className:"mt-0",children:f.jsx(Ij,{})}),f.jsx(yj,{formatDateTime:qt,viewInfo:N})]})]})}function R_({initialSelectedNodeId:n,open:r,onOpenChange:o,showTrigger:s=!0}={}){const{cluster:c,systemInfo:u,sseConnected:m,refresh:h}=ey();return f.jsx(q5,{open:r,onOpenChange:o,showTrigger:s,children:f.jsx(C_,{cluster:c,systemInfo:u,sseConnected:m,initialSelectedNodeId:n,onRefresh:h})})}const tc="meshy:show-live-events";function k1(){const n=globalThis.window;if(!n)return;const r=typeof n.CustomEvent=="function"?new n.CustomEvent(tc):new n.Event(tc);n.dispatchEvent(r)}function sM(n){const r=globalThis.window;return r?(r.addEventListener(tc,n),()=>r.removeEventListener(tc,n)):()=>{}}const A_={node:"border-teal-500/30 bg-teal-500/10 text-teal-700 dark:text-teal-300",task:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",election:"border-indigo-500/30 bg-indigo-500/10 text-indigo-700 dark:text-indigo-300",cluster:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",transport:"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300"},k_={node:"text-teal-700/70 dark:text-teal-300/70",task:"text-amber-700/70 dark:text-amber-300/70",election:"text-indigo-700/70 dark:text-indigo-300/70",cluster:"text-emerald-700/70 dark:text-emerald-300/70",transport:"text-sky-700/70 dark:text-sky-300/70"};function j_(n){return n.split(".")[0]??"unknown"}function __(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function No(n,r,o){return typeof o=="string"&&o.length>0?o:r?.get(n)??n}function j1(n,r){const o=n.data,s=o.operation;switch(n.type){case"node.joined":return`${o.name} joined the cluster`;case"node.left":return`${No(o.nodeId,r,o.name)} left (${o.reason})`;case"node.status":return`${No(o.nodeId,r)} is now ${o.status}`;case"node.operation.created":return`${s?.kind} ${s?.status} on ${No(s?.nodeId,r)}`;case"node.operation.updated":return`${s?.kind} ${s?.status} on ${No(s?.nodeId,r)}`;case"transport.changed":return`${No(o.nodeId,r)} transport switched to ${o.transportType}`;case"task.created":return`"${o.title}" created`;case"task.assigned":return`task assigned to ${No(o.nodeId,r)}`;case"task.status":return`task ${o.taskId.slice(0,8)} -> ${o.status}`;case"election.started":return`candidate ${o.candidateId.slice(0,8)} term ${o.term}`;case"election.complete":return`leader elected, term ${o.term}`;case"cluster.state":return`${o.nodeCount} nodes, term ${o.term}`;default:return JSON.stringify(o)}}function O_(n){return JSON.stringify(n,null,2)}function M_({events:n,maxHeight:r="400px",nodeNameById:o,onDismiss:s,onSelect:c,density:u="default"}){if(n.length===0)return null;const m=u==="compact";return f.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:r},children:f.jsx("div",{className:"space-y-1.5",children:n.map(h=>{const v=j_(h.type);return f.jsx("div",{onClick:c?()=>c(h.id):void 0,onKeyDown:c?p=>{p.target===p.currentTarget&&(p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),c(h.id)))}:void 0,"data-click-open-live-events":c?"true":void 0,role:c?"button":void 0,tabIndex:c?0:void 0,title:c?"Open in Live events":void 0,className:ae("transition-colors hover:bg-muted/30",c&&"cursor-pointer",m?"rounded-sm px-1 py-0.5":"rounded-sm px-1.5 py-1"),children:f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.jsx("div",{className:ae("font-mono text-muted-foreground",m?"text-[8px]":"text-[9px]"),children:__(h.timestamp)}),m?f.jsx("span",{className:ae("max-w-[8.5rem] truncate text-[7px] font-medium uppercase tracking-[0.08em] text-muted-foreground/70",k_[v]),children:h.type}):f.jsx(_t,{variant:"outline",className:ae("w-fit text-[9px] font-medium uppercase tracking-[0.14em] px-1.5 py-0",A_[v]),children:h.type})]}),f.jsxs("div",{className:ae("flex shrink-0 items-center",m?"gap-px":"gap-0.5"),children:[f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",className:ae("rounded-sm text-muted-foreground hover:text-foreground",m?"h-3.5 w-3.5 p-0 opacity-65 hover:bg-muted/40 hover:opacity-100 [&_svg]:size-2.5":"h-5 w-5"),onClick:p=>{p.stopPropagation(),h1(O_(h),"Event copied")},"aria-label":`Copy ${h.type} event`,title:"Copy event",children:f.jsx(ry,{className:m?"h-2.5 w-2.5":"h-3 w-3"})}),s&&f.jsx(Ct,{type:"button",variant:"ghost",size:"icon",className:ae("rounded-sm text-muted-foreground hover:text-foreground",m?"h-3.5 w-3.5 p-0 opacity-65 hover:bg-muted/40 hover:opacity-100 [&_svg]:size-2.5":"h-5 w-5"),onClick:p=>{p.stopPropagation(),s(h.id)},"aria-label":`Dismiss ${h.type} event`,title:"Dismiss event",children:f.jsx(my,{className:m?"h-2.5 w-2.5":"h-3 w-3"})})]})]}),f.jsx("div",{className:"text-[9px] leading-snug text-foreground/85",children:j1(h,o)})]})},h.id)})})})}function _1(n){return n!==null}function O1(n){return n==="click"?n:"hover"}function Af(n){return n==="hover"?null:n}function M1(n){return n==="click"?null:"click"}const D_=["node.","election.","transport."],z_="cluster.state";function L_(n){return n.type==="node.status"?!1:D_.some(r=>n.type.startsWith(r))}function U_(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function B_(n,r){return n?{time:U_(n.timestamp),text:j1(n,r)}:null}function H_(n){return n.transportType==="devtunnel"||!!n.devtunnelEndpoint}function P_(n){if(n.length===0)return"No node tunnel";const r=n.filter(c=>c.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(c=>c.devtunnelHealth?.status==="failed").length;if(o>0)return`${o} failed`;const s=n.filter(c=>c.status!=="offline"&&c.devtunnelHealth?.status!=="healthy").length;return s>0?`${s} checking`:"Healthy"}function $_(n,r){const o=r?.get(n.id)??n.name??n.id;if(n.status==="offline")return{label:o,status:"offline"};const s=n.devtunnelHealth?.status??"checking";return{label:o,status:s}}function q_(n){if(n.length===0)return"No nodes";const r=n.filter(s=>s.status==="offline").length;if(r>0)return`${r} offline`;const o=n.filter(s=>s.status==="busy").length;return o>0?`${o} busy`:"Healthy"}function V_(n,r){return{label:r?.get(n.id)??n.name??n.id,status:n.status}}function Y_({connected:n,events:r,nodes:o=[],currentNode:s=null,nodeNameById:c,desktopUpdate:u=null,desktopUpdateCheckPending:m=!1,desktopUpdateProgress:h=null,defaultOpen:v=!1,defaultActionMenuOpen:p=!1,onDesktopUpdateCheck:b,onDesktopUpdate:y,onDesktopRestart:w,onReload:C,onRestart:N}){const[E,T]=g.useState(v?"click":null),[A,k]=g.useState(p),[O,B]=g.useState(!0),[L,Z]=g.useState(new Set),[V,$]=g.useState(!1),[G,ce]=g.useState(!1),ue=_1(E),W=g.useRef(null),ee=g.useRef(null),le=g.useMemo(()=>r.filter(ye=>L_(ye)&&!L.has(ye.id)),[r,L]),J=g.useMemo(()=>r.find(ye=>ye.type===z_)??le[0],[r,le]),_=g.useMemo(()=>B_(J,c),[J,c]),P=g.useMemo(()=>{const ye=new Map(o.map(Xe=>[Xe.id,Xe]));return s&&ye.set(s.id,s),Array.from(ye.values())},[s,o]),X=g.useMemo(()=>P.filter(H_),[P]),fe=X.some(ye=>ye.status==="offline"||ye.devtunnelHealth?.status==="failed"),R=P.some(ye=>ye.status==="offline"),Y=P.some(ye=>ye.status==="busy"),se=P.length>0,Q=s?.name??"offline",oe=s?.role==="leader"?"Leader":s?.role==="follower"?"Follower":"Node",te=u!==null,ne=!!(te&&u?.updateAvailable&&u.latestVersion),ie=u?.latestVersion??null,de=!!(te&&!ne&&ie),xe=!!(te&&u?.detail==="Checking desktop update..."),Ce=!!(te&&!ne&&!ie&&u?.detail&&!xe),Ne=h?.percent??null,Re=Ne===null?null:`${Ne}%`,et=V?"Relaunching runtime...":"Relaunch to apply update",rt=Re?`Downloading ${Re}`:G?"Downloading and installing desktop update...":ne&&ie?`Available version ${ie}`:Ce?u?.detail??"Desktop update unavailable":"Desktop is current",hn=!!C,pn=!!(te&&w),er=!!(te&&b)||hn||pn,pt=te||!!N,_r=te||!!N||hn,Yn=pt?te?ne?"Update":de?"Latest":"Check":"Relaunch":"Reload",it=te&&!ne,gn=it?"Check":Yn,Or=pt?te?rt:et:"Reload dashboard page",ga=pt?te?G||h!==null:V:!1,Yt=pt?te?ga||!ne||!y:ga:!1,Rt=m||G||!b,Lt=te?ne&&ie?`Install desktop update ${ie}`:Ce?"Desktop update unavailable":"Desktop is current":pt?V?"Relaunching runtime":"Relaunch runtime":"Reload dashboard page";function Je(){ee.current&&(clearTimeout(ee.current),ee.current=null)}function On(){Je(),T(ye=>O1(ye))}function Mr(){Je(),ee.current=setTimeout(()=>{T(ye=>Af(ye)),ee.current=null},180)}function Mn(){Je()}function va(){Je(),T(ye=>Af(ye))}async function ya(){if(!(!N||V)){$(!0);try{await N()}finally{$(!1)}}}async function nn(){if(!(!ne||!y||G)){ce(!0);try{await y()}finally{ce(!1)}}}async function In(){!b||m||G||await b()}async function Gn(){if(!(!w||V)){k(!1),$(!0);try{await w()}finally{$(!1)}}}async function ba(){if(!pt){await Ut();return}if(te){await nn();return}await ya()}async function Ut(){C&&(k(!1),await C())}function tr(){Z(ye=>{const Xe=new Set(ye);return le.forEach(me=>Xe.add(me.id)),Xe})}function nr(){k1(),T(null)}return g.useEffect(()=>()=>{Je()},[]),g.useEffect(()=>{Z(ye=>{if(ye.size===0)return ye;const Xe=new Set(r.map(He=>He.id)),me=new Set(Array.from(ye).filter(He=>Xe.has(He)));return me.size===ye.size?ye:me})},[r]),g.useEffect(()=>{ue||k(!1)},[ue]),g.useEffect(()=>{if(!ue)return;const ye=me=>{W.current?.contains(me.target)||(Je(),k(!1),T(null))},Xe=me=>{me.key==="Escape"&&(Je(),k(!1),T(null))};return document.addEventListener("pointerdown",ye),document.addEventListener("keydown",Xe),()=>{document.removeEventListener("pointerdown",ye),document.removeEventListener("keydown",Xe)}},[ue]),f.jsxs("div",{ref:W,className:"relative",children:[f.jsxs("button",{type:"button","aria-label":n?"Cluster link connected":"Cluster link reconnecting","aria-expanded":ue,"aria-haspopup":"dialog",onClick:()=>T(ye=>M1(ye)),onMouseEnter:On,onMouseLeave:Mr,className:ae("flex h-8 max-w-[18rem] items-center gap-1.5 rounded-sm px-2 text-[10px] transition-all sm:gap-2 sm:px-2.5 sm:text-[11px]",n?"bg-muted/40 text-muted-foreground hover:bg-muted/60 hover:text-foreground":"bg-destructive/8 text-destructive hover:bg-destructive/12",ue&&(n?"bg-muted/60 text-foreground":"bg-destructive/12")),title:n?"Cluster link connected":"Cluster link reconnecting",children:[f.jsxs("span",{className:ae("relative flex h-2 w-2 shrink-0"),children:[n&&f.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-60"}),f.jsx("span",{className:ae("relative inline-flex h-2 w-2 rounded-full",n?"bg-emerald-500":"bg-destructive")})]}),f.jsxs("span",{className:"hidden min-w-0 items-center gap-2 sm:flex",children:[f.jsx("span",{className:"truncate font-medium text-foreground",children:Q}),f.jsx("span",{className:ae("shrink-0 rounded border px-1 py-px text-[8px] font-semibold uppercase tracking-[0.1em]",n?"border-emerald-500/25 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:oe})]})]}),ue&&f.jsxs("div",{role:"dialog","aria-label":"Live link connection events",onMouseEnter:Mn,onMouseLeave:va,className:"absolute right-0 top-[calc(100%+0.35rem)] z-50 w-[17rem] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-sm border border-border/60 bg-popover/98 shadow-[0_16px_44px_-34px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-sm max-sm:fixed max-sm:right-3 max-sm:top-[3.75rem] max-sm:w-[calc(100vw-1.5rem)]",children:[f.jsx("div",{className:"border-b border-border/60 bg-muted/25 px-2.5 py-1.5",children:f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[n?f.jsx(zi,{className:"h-3 w-3 text-emerald-500"}):f.jsx(DT,{className:"h-3 w-3 text-destructive"}),f.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:"Live link"}),f.jsx("span",{className:"text-[9px] text-muted-foreground",children:n?"· SSE connected":"· reconnecting"})]}),f.jsx("div",{className:ae("rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.12em]",n?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-destructive/30 bg-destructive/10 text-destructive"),children:n?"Connected":"Retrying"})]})}),f.jsxs("div",{className:"grid grid-cols-2 border-b border-border/60",children:[f.jsxs("div",{className:"border-r border-border/60 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Events"}),f.jsx("div",{className:"mt-0.5 text-base font-semibold tracking-tight text-foreground",children:le.length})]}),f.jsxs("div",{className:"min-w-0 px-2.5 py-1.5",children:[f.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Latest"}),_?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mt-0.5 truncate text-[9px] leading-snug text-foreground/80",children:_.text}),f.jsx("div",{className:"font-mono text-[8px] text-muted-foreground/60",children:_.time})]}):f.jsx("div",{className:"mt-0.5 text-[8px] text-muted-foreground/50",children:"—"})]})]}),f.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[R?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):Y?f.jsx(zi,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Ro,{className:ae("h-3 w-3 shrink-0",se?"text-emerald-500":"text-muted-foreground")}),f.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Node health"})]}),f.jsx("span",{className:ae("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",R?"border-destructive/30 bg-destructive/10 text-destructive":Y?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":se?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-border/70 bg-background/60 text-muted-foreground"),children:q_(P)})]}),P.length>0&&f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:P.map(ye=>{const{label:Xe,status:me}=V_(ye,c),He=me==="offline",Qe=me==="busy";return f.jsxs("div",{"aria-label":`${Xe} ${me}`,className:ae("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",He?"bg-destructive/6":Qe?"bg-amber-500/6":"bg-emerald-500/5"),title:`${Xe} ${me}`,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),He?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):Qe?f.jsx(Tv,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},ye.id)})})]}),X.length>0&&f.jsxs("div",{className:"border-b border-border/60 px-2.5 py-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[fe?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"}),f.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"DevTunnel"})]}),f.jsx("span",{className:ae("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",fe?"border-destructive/30 bg-destructive/10 text-destructive":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:P_(X)})]}),f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:X.map(ye=>{const{label:Xe,status:me}=$_(ye,c),He=me==="failed"||me==="offline",Qe=me!=="healthy"&&me!=="failed"&&me!=="offline",gt=ye.devtunnelHealth?.reason?`${Xe} ${me}: ${ye.devtunnelHealth.reason}`:`${Xe} ${me}`;return f.jsxs("div",{"aria-label":`${Xe} ${me}`,className:ae("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",He?"bg-destructive/6":Qe?"bg-muted/30":"bg-emerald-500/5"),title:gt,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),He?f.jsx(pi,{className:"h-3 w-3 shrink-0 text-destructive"}):Qe?f.jsx(Tv,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(Ro,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},ye.id)})})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1",children:[f.jsxs("button",{type:"button",onClick:()=>B(ye=>!ye),className:"flex min-w-0 flex-1 items-center justify-between rounded-sm px-0.5 py-0.5 text-left hover:bg-muted/25",children:[f.jsxs("span",{className:"truncate text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:["Notifications ",le.length>0&&`(${le.length})`]}),O?f.jsx(Zl,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(lf,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}),!O&&le.length>0&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px] font-medium text-muted-foreground hover:text-foreground",onClick:tr,title:"Clear all notifications",children:"Clear all"})]}),O&&f.jsx("div",{className:"px-2 pb-1.5",children:f.jsx(M_,{events:le,maxHeight:"10rem",density:"compact",emptyTitle:"No connection events yet",emptyDescription:"Node, election, and system events will appear here.",nodeNameById:c,onSelect:nr,onDismiss:ye=>Z(Xe=>new Set(Xe).add(ye))})})]}),te&&u?.detail&&!xe&&f.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/60 px-2.5 py-1 text-[8px] text-muted-foreground",children:[f.jsx("span",{className:"shrink-0 font-medium uppercase tracking-[0.12em]",children:"Desktop update"}),f.jsx("span",{className:"truncate",title:u.detail,children:u.detail})]}),f.jsxs("div",{className:"flex items-center justify-between gap-1 border-t border-border/60 px-2.5 py-1",children:[f.jsx("div",{children:_r&&f.jsxs("div",{className:"group/restart relative flex items-center",children:[f.jsxs("div",{className:"flex items-center overflow-hidden rounded-sm border border-border/50",children:[f.jsxs(Ct,{type:"button",variant:"ghost",size:"sm",className:ae("relative h-5 overflow-hidden rounded-none border-0 px-1.5 text-[9px] font-medium hover:text-foreground [&_svg]:size-2.5",ne?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>{ba()},disabled:Yt,"aria-label":Lt,"aria-describedby":"live-link-restart-hint",title:Or,children:[Ne!==null&&f.jsx("span",{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Ne,className:"pointer-events-none absolute inset-y-0 left-0 bg-primary/24",style:{width:`${Ne}%`}}),Ne===null&&f.jsx(Cv,{className:ae("relative z-10 h-2.5 w-2.5",ga&&"animate-pulse")}),f.jsx("span",{className:"relative z-10",children:Re??Yn})]}),er&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:ae("h-5 rounded-none border-l border-border/50 px-1 text-[9px] hover:text-foreground [&_svg]:size-2.5",ne?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>k(ye=>!ye),"aria-label":"Open live link actions","aria-expanded":A,title:"Live link actions",children:f.jsx(Zl,{className:"h-2.5 w-2.5"})})]}),er&&A&&f.jsxs("div",{className:"absolute bottom-[calc(100%+0.25rem)] left-0 z-20 min-w-28 overflow-hidden rounded-sm border border-border/70 bg-background text-[9px] shadow-sm",children:[f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground disabled:opacity-45 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",onClick:()=>{it?In():ba()},disabled:it?Rt:Yt,"aria-label":it?"Check for desktop updates":Lt,children:[it?f.jsx(Ri,{className:ae("h-2.5 w-2.5",m&&"animate-spin")}):f.jsx(Cv,{className:ae("h-2.5 w-2.5",ga&&"animate-pulse")}),f.jsx("span",{children:gn})]}),hn&&f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 border-t border-border/50 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground disabled:opacity-45 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",onClick:()=>{Ut()},"aria-label":"Reload dashboard page",children:[f.jsx(Ri,{className:"h-2.5 w-2.5"}),f.jsx("span",{children:"Reload"})]}),pn&&f.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 border-t border-border/50 px-2 py-1 text-left text-muted-foreground hover:bg-muted/55 hover:text-foreground",onClick:()=>{Gn()},disabled:V,"aria-label":"Restart Meshy Desktop",children:[f.jsx(Ri,{className:ae("h-2.5 w-2.5",V&&"animate-spin")}),f.jsx("span",{children:"Restart"})]})]}),f.jsx("span",{id:"live-link-restart-hint",role:"tooltip",className:"pointer-events-none absolute left-6 top-1/2 z-10 -translate-y-1/2 whitespace-nowrap rounded-sm border border-border/70 bg-background px-1.5 py-0.5 text-[8px] text-muted-foreground opacity-0 shadow-sm transition-opacity group-hover/restart:opacity-100 group-focus-within/restart:opacity-100",children:Or})]})}),f.jsxs("div",{className:"flex items-center gap-1",children:[O&&f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:tr,disabled:le.length===0,title:"Clear all notifications",children:"Clear all"}),f.jsx(Ct,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>T(null),children:"Close"})]})]})]})]})}const m0="dark",kr="fluent",I_="clean",Wd="meshy-layout-default-migrated-to-compact",kf="true",G_="compact",X_=new Set(["airy","clean","fluent"]);function Q_(n){return n!==null&&X_.has(n)}function Sc(n){return n===G_?"fluent":Q_(n)?n:null}function K_(n,r){const o=Sc(n);return o===I_&&r!==kf?kr:o??kr}const nc="symphony",D1="default",Z_=new Set(["light","dark","system"]),F_=new Set(["porcelain","warm","finsight","edge","symphony","launcher"]),z1=g.createContext(null);function W_(n){const r=new URLSearchParams(n).get("theme");return L1(r)?r:null}function J_(n){const r=new URLSearchParams(n).get("palette");return gm(r)}function e3(n){const r=new URLSearchParams(n).get("layout");return Sc(r)}function t3(){if(typeof document>"u")return null;const n=document.documentElement;return{theme:n.classList.contains("dark")?"dark":"light",palette:gm(n.getAttribute("data-palette"))??nc,layout:Sc(n.getAttribute("data-layout"))??kr}}function iM(n,r=t3()){if(!r)return n;try{const o=/^[a-z][a-z\d+\-.]*:/i.test(n),s=typeof window<"u"?window.location.href:"http://localhost",c=new URL(n,s);return c.searchParams.set("theme",r.theme),c.searchParams.set("palette",r.palette),c.searchParams.set("layout",r.layout),o?c.toString():`${c.pathname}${c.search}${c.hash}`}catch{return n}}const Jd=.9;function h0(n){const r=n.trim().match(/^(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)%\s+(-?\d+(?:\.\d+)?)%$/);if(!r)return null;const o=(Number(r[1])%360+360)%360/60,s=ac(Number(r[2])/100,0,1),c=ac(Number(r[3])/100,0,1),u=(1-Math.abs(2*c-1))*s,m=u*(1-Math.abs(o%2-1)),h=c-u/2,[v,p,b]=o<1?[u,m,0]:o<2?[m,u,0]:o<3?[0,u,m]:o<4?[0,m,u]:o<5?[m,0,u]:[u,0,m];return[Math.round((v+h)*255),Math.round((p+h)*255),Math.round((b+h)*255),255]}function n3(n){const r=n.trim();if(!r||r==="transparent")return null;const o=r.match(/^rgba?\(\s*([+-]?\d+(?:\.\d+)?)\s*,\s*([+-]?\d+(?:\.\d+)?)\s*,\s*([+-]?\d+(?:\.\d+)?)(?:\s*,\s*([+-]?\d+(?:\.\d+)?))?\s*\)$/i);if(o)return[To(Number(o[1])),To(Number(o[2])),To(Number(o[3])),v0(o[4])];const s=r.match(/^rgba?\(\s*([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)(?:\s*\/\s*([+-]?\d+(?:\.\d+)?%?))?\s*\)$/i);return s?[To(Number(s[1])),To(Number(s[2])),To(Number(s[3])),v0(s[4])]:null}function a3(n,r,o){const s=h0(n);if(!s)return null;if(o==="clean"||o==="fluent")return s;const c=h0(r);return c?[ef(s[0],c[0],Jd),ef(s[1],c[1],Jd),ef(s[2],c[2],Jd),255]:null}function r3(){const n=document.querySelector(".dashboard-shell-header-panel");if(!n)return null;const r=n3(getComputedStyle(n).backgroundColor);return!r||r[3]===0?null:r}function p0(){if(typeof window>"u"||typeof document>"u")return;const n=window.__TAURI__?.core?.invoke??null;if(!n)return;const r=document.documentElement,o=r.classList.contains("dark")?"dark":"light",s=getComputedStyle(r),c=Sc(r.getAttribute("data-layout"))??kr,u=r3()??a3(s.getPropertyValue("--card"),s.getPropertyValue("--background"),c);n("sync_desktop_theme",{theme:o,backgroundColor:u}).catch(()=>{})}function g0(){if(typeof window>"u")return()=>{};if(p0(),typeof window.requestAnimationFrame!="function")return()=>{};const n=window.requestAnimationFrame(()=>p0());return()=>window.cancelAnimationFrame(n)}function ef(n,r,o){return Math.round(n*o+r*(1-o))}function ac(n,r,o){return Math.min(Math.max(n,r),o)}function To(n){return Math.round(ac(n,0,255))}function v0(n){if(n==null||n==="")return 255;const r=n.endsWith("%")?Number(n.slice(0,-1))/100:Number(n);return Math.round(ac(r,0,1)*255)}function o3({children:n}){const[r,o]=g.useState(()=>typeof window<"u"?W_(window.location.search)??i3(localStorage.getItem("meshy-theme"))??m0:m0),[s,c]=g.useState(()=>typeof window<"u"?J_(window.location.search)??c3(localStorage.getItem("meshy-palette"))??nc:nc),[u,m]=g.useState(()=>{if(typeof window<"u"){const h=e3(window.location.search);if(h)return localStorage.setItem(Wd,kf),h;const v=K_(localStorage.getItem("meshy-layout"),localStorage.getItem(Wd));return localStorage.setItem(Wd,kf),v}return kr});return g.useEffect(()=>{const h=document.documentElement,v=p=>{if(p==="system"){const b=window.matchMedia("(prefers-color-scheme: dark)").matches;h.classList.toggle("dark",b)}else h.classList.toggle("dark",p==="dark")};if(v(r),localStorage.setItem("meshy-theme",r),r==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)"),b=()=>{v("system"),g0()};return p.addEventListener("change",b),()=>p.removeEventListener("change",b)}},[r]),g.useEffect(()=>{document.documentElement.setAttribute("data-palette",s),localStorage.setItem("meshy-palette",s)},[s]),g.useEffect(()=>{const h=document.documentElement;u===kr?h.removeAttribute("data-layout"):h.setAttribute("data-layout",u),localStorage.setItem("meshy-layout",u)},[u]),g.useEffect(()=>g0(),[r,s,u]),f.jsx(z1.Provider,{value:{theme:r,setTheme:o,palette:s,setPalette:c,layout:u,setLayout:m},children:n})}function l3(){const n=g.useContext(z1);if(!n)throw new Error("useTheme must be used within ThemeProvider");return n}function L1(n){return n!==null&&Z_.has(n)}function s3(n){return n!==null&&F_.has(n)}function i3(n){return L1(n)?n:null}function gm(n){return n===D1?"porcelain":s3(n)?n:null}function c3(n){return n===D1?null:gm(n)}const u3=[{value:"light",label:"Light",icon:dy},{value:"dark",label:"Dark",icon:cy},{value:"system",label:"System",icon:iy}],U1=[{value:"finsight",label:"FinSight",hint:"Cool sage green"},{value:"porcelain",label:"Porcelain",hint:"Blue workspace"},{value:"warm",label:"Warm",hint:"Cream + amber"},{value:"edge",label:"Edge",hint:"Rounded violet panels"},{value:"symphony",label:"Symphony",hint:"Near-black rose accent"},{value:"launcher",label:"Launcher",hint:"Desktop startup blue"}],B1=[{value:"airy",label:"Airy",hint:"Gradients, blur, spacious"},{value:"clean",label:"Clean",hint:"Flat, borders, high density"},{value:"fluent",label:"Fluent",hint:"Compact neutral"}];function d3(){const{theme:n,setTheme:r,palette:o,setPalette:s,layout:c,setLayout:u}=l3(),[m,h]=g.useState(null),v=g.useRef(null),p=g.useRef(null),b=_1(m),y=n==="dark"?cy:n==="light"?dy:iy,w=()=>{v.current&&(clearTimeout(v.current),v.current=null)},C=()=>{w(),v.current=setTimeout(()=>h(N=>Af(N)),180)};return g.useEffect(()=>{if(!b)return;const N=E=>{p.current&&!p.current.contains(E.target)&&h(null)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[b]),g.useEffect(()=>()=>w(),[]),f.jsxs("div",{ref:p,className:"relative",onMouseEnter:()=>{w(),h(N=>O1(N))},onMouseLeave:C,children:[f.jsx(Ct,{variant:"ghost",size:"icon",onClick:()=>h(N=>M1(N)),className:ae("h-8 w-8 rounded-sm",o!==nc||c!==kr?"text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),title:"Appearance","aria-haspopup":"menu","aria-expanded":b,children:f.jsx(y,{className:"h-4 w-4"})}),b&&f.jsxs("div",{role:"menu",className:"fixed left-2 right-2 top-[4.25rem] z-50 w-auto max-w-none rounded-md border border-border/70 bg-popover/95 p-2 text-popover-foreground shadow-[0_24px_70px_-32px_rgba(0,0,0,0.45)] backdrop-blur-xl sm:absolute sm:left-auto sm:right-0 sm:top-[calc(100%+6px)] sm:w-[23rem] sm:max-w-[23rem]",children:[f.jsxs("div",{className:"mb-2 flex items-end justify-between gap-2",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Appearance"}),f.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:[f3(c)," / ",m3(o)]})]}),f.jsx("div",{className:"rounded-sm border border-border/60 bg-background/70 px-1.5 py-0.5 text-[8px] font-medium capitalize text-muted-foreground",children:n})]}),f.jsx("div",{className:"px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Theme"}),f.jsx("div",{className:"mb-2 grid grid-cols-3 gap-1 rounded-sm bg-muted/35 p-0.5",children:u3.map(({value:N,label:E,icon:T})=>{const A=n===N;return f.jsxs("button",{type:"button",onClick:()=>r(N),role:"menuitemradio","aria-checked":A,className:ae("flex min-h-[2.1rem] flex-col items-center justify-center gap-0.5 rounded-sm border px-1.5 py-1 text-[9px] font-medium transition-colors",A?"border-primary/55 bg-background text-primary shadow-sm":"border-transparent text-muted-foreground hover:border-border/70 hover:bg-background/80 hover:text-foreground"),children:[f.jsx(T,{className:"h-3 w-3"}),E]},N)})}),f.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[f.jsxs("div",{children:[f.jsx("div",{className:"px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Layout"}),f.jsx("div",{className:"space-y-1",children:B1.map(({value:N,label:E,hint:T})=>{const A=c===N;return f.jsxs("button",{type:"button",onClick:()=>u(N),role:"menuitemradio","aria-checked":A,className:ae("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",A?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:ae("text-[10px] font-medium leading-tight",A?"text-primary":"text-foreground"),children:E}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:T})]}),A&&f.jsx(Li,{className:"h-3 w-3 text-primary"})]},N)})})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-1.5 px-0.5 pb-1 text-[8px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:[f.jsx(AT,{className:"h-2.5 w-2.5"}),"Palette"]}),f.jsx("div",{className:"space-y-1",children:U1.map(({value:N,label:E,hint:T})=>{const A=o===N;return f.jsxs("button",{type:"button",onClick:()=>s(N),role:"menuitemradio","aria-checked":A,className:ae("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",A?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsx(h3,{value:N}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:ae("text-[10px] font-medium leading-tight",A?"text-primary":"text-foreground"),children:E}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:T})]}),A&&f.jsx(Li,{className:"h-3 w-3 text-primary"})]},N)})})]})]})]})]})}function f3(n){return B1.find(r=>r.value===n)?.label??n}function m3(n){return U1.find(r=>r.value===n)?.label??n}function h3({value:n}){const r={porcelain:["hsl(212 76% 44%)","hsl(210 22% 98%)","hsl(174 42% 61%)"],warm:["hsl(35 88% 56%)","hsl(42 22% 97%)","hsl(160 60% 45%)"],finsight:["hsl(152 38% 32%)","hsl(150 14% 97%)","hsl(142 55% 58%)"],edge:["hsl(265 75% 55%)","hsl(260 12% 98%)","hsl(285 70% 65%)"],symphony:["hsl(348 100% 71%)","hsl(0 0% 6%)","hsl(240 2% 9%)"],launcher:["hsl(213 77% 49%)","hsl(60 10% 96%)","hsl(0 0% 100%)"]},[o,s,c]=r[n];return f.jsxs("div",{className:ae("flex h-5 w-5 shrink-0 overflow-hidden border border-border/60 shadow-sm","rounded-sm"),children:[f.jsx("div",{className:"h-full w-1/3",style:{background:o}}),f.jsx("div",{className:"h-full w-1/3",style:{background:s}}),f.jsx("div",{className:"h-full w-1/3",style:{background:c}})]})}const Xl={tasks:{defaultSize:20,min:16,max:36,wheelStep:1},operations:{defaultSize:20,min:18,max:38,wheelStep:1},terminal:{defaultSize:18,min:10,max:30,wheelStep:1}},H1="meshy-dashboard-panel-state-v2",P1="meshy-dashboard-terminal-open-v1";function cM({operationsOpen:n}){return{layout:{desktopTasksOpen:!0,operationsOpen:n},sizes:{tasks:Xl.tasks.defaultSize,operations:Xl.operations.defaultSize,terminal:Xl.terminal.defaultSize}}}function tf(n){return typeof n=="object"&&n!==null}function y0(n,r){return typeof n=="boolean"?n:r}function nf(n,r,o){return typeof r=="number"&&Number.isFinite(r)?Ql(n,r):o}function Ql(n,r){const o=Xl[n];return Math.min(o.max,Math.max(o.min,r))}function uM(n,r){if(!n)return r;try{const o=n.getItem(H1);if(!o)return r;const s=JSON.parse(o);if(!tf(s))return r;const c=tf(s.layout)?s.layout:{},u=tf(s.sizes)?s.sizes:{};return{layout:{desktopTasksOpen:y0(c.desktopTasksOpen,r.layout.desktopTasksOpen),operationsOpen:y0(c.operationsOpen,r.layout.operationsOpen)},sizes:{tasks:nf("tasks",u.tasks,r.sizes.tasks),operations:nf("operations",u.operations,r.sizes.operations),terminal:nf("terminal",u.terminal,r.sizes.terminal)}}}catch{return r}}function dM(n,r){if(n)try{n.setItem(H1,JSON.stringify(r))}catch{}}function p3(n,r){if(!n)return r;try{const o=n.getItem(P1);return o==="true"?!0:o==="false"?!1:r}catch{return r}}function g3(n,r){if(n)try{n.setItem(P1,String(r))}catch{}}function b0(){try{return globalThis.window?.localStorage??globalThis.localStorage??null}catch{return null}}function fM(n){return`${Number(n.toFixed(2))}rem`}function mM(n,r,o,s,c,u,m){const h=Number.isFinite(m)&&m>0?m:16;return n==="tasks"?Ql(n,r+(c-o)/h):n==="operations"?Ql(n,r+(o-c)/h):Ql(n,r+(s-u)/h)}function hM(n,r,o){const s=o===0?0:o>0?-1:1;return Ql(n,r+s*Xl[n].wheelStep)}const v3=7200*1e3,y3=15*1e3,b3="meshy://desktop-update-progress",x3="Desktop update check timed out";function S3(){return f.jsxs("svg",{"data-meshy-app-icon":"header",viewBox:"0 0 1024 1024",className:"h-8 w-8","aria-hidden":"true",children:[f.jsxs("defs",{children:[f.jsxs("linearGradient",{id:"meshy-header-icon-bg",x1:"160",y1:"128",x2:"864",y2:"896",gradientUnits:"userSpaceOnUse",children:[f.jsx("stop",{offset:"0",stopColor:"#182033"}),f.jsx("stop",{offset:"1",stopColor:"#0a0f1f"})]}),f.jsxs("linearGradient",{id:"meshy-header-icon-edge",x1:"260",y1:"244",x2:"768",y2:"780",gradientUnits:"userSpaceOnUse",children:[f.jsx("stop",{offset:"0",stopColor:"#66e3ff"}),f.jsx("stop",{offset:"0.52",stopColor:"#8fd56b"}),f.jsx("stop",{offset:"1",stopColor:"#ffcb5b"})]})]}),f.jsx("rect",{width:"1024",height:"1024",rx:"224",fill:"url(#meshy-header-icon-bg)"}),f.jsx("path",{d:"M308 652V372l204 174 204-174v280",fill:"none",stroke:"url(#meshy-header-icon-edge)",strokeWidth:"86",strokeLinecap:"round",strokeLinejoin:"round"}),f.jsx("circle",{cx:"308",cy:"372",r:"58",fill:"#66e3ff"}),f.jsx("circle",{cx:"512",cy:"546",r:"58",fill:"#8fd56b"}),f.jsx("circle",{cx:"716",cy:"372",r:"58",fill:"#ffcb5b"}),f.jsx("circle",{cx:"308",cy:"652",r:"58",fill:"#66e3ff"}),f.jsx("circle",{cx:"716",cy:"652",r:"58",fill:"#ffcb5b"})]})}function Vl(){return typeof window>"u"?null:window.__TAURI__?.core?.invoke??null}function w3(){return typeof window>"u"?null:window.__TAURI__?.event?.listen??null}function E3(n){if(!n||typeof n!="object")return null;const r=n;return r.phase!=="downloading"&&r.phase!=="installing"&&r.phase!=="complete"?null:{phase:r.phase,receivedBytes:typeof r.receivedBytes=="number"?r.receivedBytes:0,totalBytes:typeof r.totalBytes=="number"?r.totalBytes:null,percent:typeof r.percent=="number"?Math.max(0,Math.min(100,Math.round(r.percent))):null}}function x0(n){return{currentVersion:null,latestVersion:null,updateAvailable:!1,checkedAt:new Date().toISOString(),releaseUrl:null,assetName:null,installable:!1,detail:n}}async function N3(n,r,o){let s;const c=new Promise((u,m)=>{s=setTimeout(()=>{m(new Error(x3))},r)});try{return await Promise.race([n,c])}finally{s!==void 0&&clearTimeout(s)}}async function T3({activeCheck:n,startCheck:r,timeoutMs:o,shouldApply:s,applyUpdate:c,applyFailure:u,failureFallback:m="Desktop update check failed"}){let h=n.current;if(!h){let v;try{v=r()}catch(p){v=Promise.reject(p)}h=N3(v,o),n.current=h}try{const v=await h;return s()&&c(v),v}catch(v){return s()&&u(jf(v,m)),null}finally{n.current===h&&(n.current=null)}}function jf(n,r){if(n instanceof Error&&n.message.trim())return n.message;if(typeof n=="string"&&n.trim())return n;if(n&&typeof n=="object"&&"message"in n){const o=n.message;if(typeof o=="string"&&o.trim())return o}return r}function C3(n){return n.openedRelease?"Opened the latest Meshy release page.":n.installMethod==="tauri-updater"?"Installing desktop update. Meshy will relaunch to finish updating.":(n.assetName??"desktop update").toLowerCase().endsWith(".dmg")?"Downloaded desktop update. Open the DMG and drag Meshy to Applications to finish updating.":"Downloaded desktop update. Follow the installer to finish updating."}function R3(){const{cluster:n,events:r,sseConnected:o,systemInfo:s}=ey(),c=jn(),[u,m]=g.useState(()=>p3(b0(),!1)),[h,v]=g.useState(""),[p,b]=g.useState(null),[y,w]=g.useState(null),[C,N]=g.useState(!1),[E,T]=g.useState(null),A=g.useRef(null),k=!!Vl(),O=k?"max-w-none":"max-w-[1760px]",B=c.pathname==="/"||/^\/tasks\/[^/]+$/.test(c.pathname),L=g.useMemo(()=>{const W=new Map;for(const ee of n?.nodes??[])W.set(ee.id,ee.name);return n?.self&&W.set(n.self.id,n.self.name),W},[n?.nodes,n?.self]),Z=g.useCallback(W=>{m(ee=>typeof W=="function"?W(ee):W)},[]);g.useEffect(()=>{g3(b0(),u)},[u]);const V=g.useCallback(async(W=!0,ee=()=>!0)=>{const le=Vl();return le?(W&&ee()&&w(x0("Checking desktop update...")),T3({activeCheck:A,startCheck:()=>le("check_desktop_update"),timeoutMs:y3,shouldApply:ee,applyUpdate:J=>w(J),applyFailure:J=>w(_=>_?.updateAvailable?_:x0(J))})):(ee()&&w(null),null)},[]);async function $(){N(!0);try{await V(!1)}finally{N(!1)}}g.useEffect(()=>{if(!Vl()){w(null);return}let W=!1;const ee=()=>!W;V(!0,ee);const le=window.setInterval(()=>{V(!1,ee)},v3);return()=>{W=!0,window.clearInterval(le)}},[V,s?.version]),g.useEffect(()=>{const W=w3();if(!W)return;let ee=!1,le;return W(b3,J=>{const _=E3(J.payload);_&&T(_)}).then(J=>{if(ee){J();return}le=J}).catch(()=>{}),()=>{ee=!0,le?.()}},[]);async function G(){try{const W=await F0({reason:"restart"});_e.info(`Restarting runtime. Follow ${W.logPath} for launch output.`),await R1({previousPid:W.pid})||_e.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout.")}catch(W){_e.error(W instanceof Error?W.message:"Runtime restart failed")}}async function ce(){const W=Vl();if(!W){_e.error("Desktop updater is not available in this window");return}try{_e.info("Downloading desktop update..."),T({phase:"downloading",receivedBytes:0,totalBytes:null,percent:0});const ee=await W("install_desktop_update");T({phase:"complete",receivedBytes:1,totalBytes:1,percent:100}),_e.info(C3(ee))}catch(ee){_e.error(jf(ee,"Desktop update failed"))}finally{T(null)}}async function ue(){const W=Vl();if(!W){_e.error("Desktop restart is not available in this window");return}try{_e.info("Restarting Meshy Desktop..."),await W("restart_desktop_app")}catch(ee){_e.error(jf(ee,"Desktop restart failed"))}}return f.jsxs("div",{className:"relative h-full overflow-hidden bg-background text-foreground",children:[f.jsx("div",{className:"mesh-grid pointer-events-none absolute inset-0"}),f.jsxs("div",{className:"relative z-10 flex h-full min-h-0 flex-col",children:[f.jsx("header",{className:"dashboard-shell-header relative z-50 shrink-0 px-2 py-2",children:f.jsxs("div",{className:ae("dashboard-shell-header-panel dashboard-panel dashboard-panel-muted animate-panel-settle mx-auto flex items-center gap-0 rounded-lg px-3 py-2",O),children:[f.jsx("div",{className:"flex shrink-0 items-center gap-3 pr-3",children:f.jsxs(of,{to:"/","aria-label":"Meshy home",className:"flex items-center gap-2",children:[f.jsx(S3,{}),f.jsxs("div",{className:"hidden min-w-0 items-baseline gap-1.5 sm:flex",children:[f.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:"MESHY"}),f.jsx("span",{className:"truncate text-[13px] font-semibold tracking-tight text-foreground",children:"Workspace"})]})]})}),f.jsx("div",{className:"mx-0 hidden h-4 w-px shrink-0 bg-border/50 md:block"}),B&&f.jsxs("div",{className:"hidden min-w-0 flex-1 items-center px-3 md:flex",children:[p&&f.jsxs("nav",{"aria-label":"Current task location",className:"flex min-w-0 max-w-[38rem] items-center gap-1 rounded-sm bg-background/55 px-2 py-1 text-[10px] text-muted-foreground",children:[f.jsxs("button",{type:"button",onClick:()=>v(p.nodeName),className:"flex min-w-0 items-center gap-1 rounded-sm px-1 py-0.5 hover:bg-muted/60 hover:text-foreground",title:`Filter by ${p.nodeName}`,children:[f.jsx(uy,{className:"h-3 w-3 shrink-0 text-primary/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.nodeName})]}),f.jsx(lf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsxs("button",{type:"button",onClick:()=>v(p.projectLabel),className:"flex min-w-0 items-center gap-1 rounded-sm px-1 py-0.5 hover:bg-muted/60 hover:text-foreground",title:p.projectPath,children:[f.jsx(JN,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.projectLabel})]}),f.jsx(lf,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsx(of,{to:`/tasks/${p.taskId}`,className:"min-w-0 truncate px-1 font-medium text-foreground/85 hover:text-foreground",title:p.taskTitle,children:p.taskTitle})]}),f.jsxs("div",{className:"relative ml-auto w-[18rem] max-w-[28rem]",children:[f.jsx(ST,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/60"}),f.jsx(bc,{"aria-label":"Search tasks",value:h,onChange:W=>v(W.target.value),placeholder:"Search tasks, nodes, workspaces",className:"h-8 rounded-sm border-0 bg-background/62 pl-8 pr-2 text-[11px] shadow-none focus-visible:ring-0 focus-visible:ring-offset-0"})]})]}),f.jsx("div",{className:"mx-0 hidden h-4 w-px shrink-0 bg-border/50 md:block"}),f.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5 pl-3 sm:gap-2 md:ml-0",children:[B&&f.jsx(Ct,{variant:"ghost",size:"icon",onClick:()=>Z(W=>!W),"aria-label":u?"Close terminal":"Open terminal",title:u?"Close terminal":"Open terminal",className:ae("h-8 w-8 rounded-sm text-muted-foreground hover:bg-muted/50 hover:text-foreground",u&&"bg-primary/8 text-primary"),children:f.jsx(fy,{className:"h-4 w-4"})}),f.jsx(R_,{}),f.jsx(d3,{}),f.jsx("div",{className:"mx-0 h-4 w-px shrink-0 bg-border/50"}),f.jsx(Y_,{connected:o,events:r,nodes:n?.nodes??[],currentNode:n?.self??null,nodeNameById:L,desktopUpdate:y,desktopUpdateCheckPending:C,desktopUpdateProgress:E,onDesktopUpdateCheck:k?$:void 0,onDesktopUpdate:y?.updateAvailable?ce:void 0,onDesktopRestart:k?ue:void 0,onReload:k?()=>window.location.reload():void 0,onRestart:G})]})]})}),f.jsx("main",{className:ae("dashboard-shell-main min-h-0 flex-1 px-2 pb-2",B?"overflow-hidden":"overflow-y-auto"),children:f.jsx("div",{className:ae("dashboard-shell-content mx-auto h-full min-h-0",O),children:f.jsx(oE,{context:{terminalOpen:u,setTerminalOpen:Z,headerSearchQuery:h,setHeaderSearchQuery:v,setHeaderTaskContext:b}})})})]})]})}const S0=g.lazy(async()=>({default:(await N0(()=>import("./DashboardPage-CuNReQ9k.js").then(r=>r.D),__vite__mapDeps([0,1,2,3,4]))).DashboardPage})),A3=g.lazy(async()=>({default:(await N0(()=>import("./SharedConversationPage-D86sReze.js"),__vite__mapDeps([5,1]))).SharedConversationPage}));function k3(){return f.jsx(_E,{children:f.jsx(g.Suspense,{fallback:f.jsx(j3,{}),children:f.jsxs(sE,{children:[f.jsx(Nr,{path:"/shared/tasks/:shareId",element:f.jsx(A3,{})}),f.jsxs(Nr,{element:f.jsx(TN,{children:f.jsx(R3,{})}),children:[f.jsx(Nr,{path:"/",element:f.jsx(S0,{})}),f.jsx(Nr,{path:"/nodes",element:f.jsx(bv,{to:"/",replace:!0})}),f.jsx(Nr,{path:"/tasks",element:f.jsx(bv,{to:"/",replace:!0})}),f.jsx(Nr,{path:"/tasks/:id",element:f.jsx(S0,{})})]})]})})})}function j3(){return f.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading workspace..."})}function _3(n){const r=n??(typeof window>"u"?void 0:window);r?.__TAURI__&&r.addEventListener("contextmenu",o=>{o.preventDefault()})}function O3(n){const{className:r,style:o,toastOptions:s,...c}=n;function u(m){const h=m.target;if(!(h instanceof Element)||h.closest("button, a, input, textarea, select, [data-close-button], [data-button]"))return;const v=h.closest("[data-sonner-toast]");v&&v.dataset.type!=="loading"&&k1()}return f.jsx("div",{onClick:u,children:f.jsx(FC,{className:["toaster group",r].filter(Boolean).join(" "),closeButton:!0,gap:6,offset:{right:"0.6rem",bottom:"0.6rem"},mobileOffset:{right:"0.5rem",bottom:"0.5rem",left:"0.5rem"},position:"bottom-right",visibleToasts:3,style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border) / 0.7)","--width":"17rem",...o},toastOptions:{duration:3e3,closeButton:!0,...s,classNames:{toast:"meshy-toast",title:"meshy-toast__title",description:"meshy-toast__description",content:"meshy-toast__content",icon:"meshy-toast__icon",closeButton:"meshy-toast__close",actionButton:"meshy-toast__action",cancelButton:"meshy-toast__cancel",success:"meshy-toast--success",error:"meshy-toast--error",info:"meshy-toast--info",warning:"meshy-toast--warning",...s?.classNames}},...c})})}_3();r2.createRoot(document.getElementById("root")).render(f.jsx(g.StrictMode,{children:f.jsxs(o3,{children:[f.jsx(k3,{}),f.jsx(O3,{})]})}));export{LO as $,UO as A,Ct as B,Li as C,BO as D,oO as E,FN as F,B5 as G,mb as H,bc as I,pb as J,iM as K,ly as L,ry as M,h1 as N,Gx as O,dT as P,lM as Q,sy as R,uy as S,HO as T,Il as U,$N as V,Ej as W,my as X,ny as Y,Jk as Z,zO as _,rM as a,jO as a$,_t as a0,eM as a1,Gl as a2,Nf as a3,Xi as a4,Qi as a5,Zi as a6,Fi as a7,Ki as a8,Ji as a9,tM as aA,xj as aB,CO as aC,cR as aD,Ri as aE,VO as aF,nM as aG,aM as aH,$O as aI,qO as aJ,WO as aK,N1 as aL,JO as aM,Tf as aN,OT as aO,hO as aP,pO as aQ,uM as aR,cM as aS,b0 as aT,dM as aU,hM as aV,fM as aW,mM as aX,aO as aY,yN as aZ,FE as a_,Wi as aa,N0 as ab,U3 as ac,hb as ad,$5 as ae,Z3 as af,fy as ag,Ro as ah,sf as ai,K3 as aj,F3 as ak,Q3 as al,AO as am,H5 as an,gb as ao,DT as ap,NT as aq,DN as ar,sT as as,ts as at,ZO as au,pT as av,M_ as aw,hj as ax,oy as ay,pj as az,nR as b,kO as b0,_O as b1,SN as b2,dO as b3,$3 as b4,H3 as b5,Z0 as b6,P3 as b7,q3 as b8,R_ as b9,iO as bA,sO as bB,L3 as bC,B3 as bD,z3 as bE,V3 as bF,DO as bG,xO as bH,bO as bI,yO as bJ,gO as bK,vO as bL,SO as bM,bj as bN,Uk as bO,MO as bP,Lk as bQ,w0 as bR,NO as bS,EO as bT,wO as bU,TO as bV,OO as bW,RO as bX,fO as ba,mO as bb,tO as bc,W3 as bd,J3 as be,eO as bf,nO as bg,D3 as bh,jn as bi,P0 as bj,M3 as bk,ey as bl,FO as bm,$j as bn,sM as bo,KO as bp,YO as bq,IO as br,XO as bs,GO as bt,QO as bu,rO as bv,PO as bw,Sj as bx,cO as by,uO as bz,Ae as c,ae as d,jy as e,g1 as f,I3 as g,X3 as h,K0 as i,f as j,Y3 as k,JN as l,oM as m,lf as n,ua as o,G3 as p,lO as q,g as r,Sf as s,_e as t,Ii as u,wf as v,Gi as w,ST as x,Zl as y,AT as z};
|