meshy-node 0.8.5 → 0.8.6

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-SPgMQP8H.js","assets/DashboardShared-CNEt96B1.js","assets/play-DKbfL1lN.js","assets/DashboardPage-i714dDoR.css","assets/SharedConversationPage-Cd0hBNE_.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-CMsJFjmz.js","assets/DashboardShared-Bf1AO_zZ.js","assets/play-ByJhX-44.js","assets/DashboardPage-i714dDoR.css","assets/SharedConversationPage-DCIspBsA.js"])))=>i.map(i=>d[i]);
2
2
  function S2(n,l){for(var o=0;o<l.length;o++){const i=l[o];if(typeof i!="string"&&!Array.isArray(i)){for(const c in i)if(c!=="default"&&!(c in n)){const d=Object.getOwnPropertyDescriptor(i,c);d&&Object.defineProperty(n,c,d.get?d:{enumerable:!0,get:()=>i[c]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))i(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const m of d.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function o(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function i(c){if(c.ep)return;c.ep=!0;const d=o(c);fetch(c.href,d)}})();function s0(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Nd={exports:{}},zo={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -313,4 +313,4 @@ You can add a description to the \`${Dr}\` by passing a \`${Mx}\` component as a
313
313
 
314
314
  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 \`${Dr}\`. 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.
315
315
 
316
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return v.useEffect(()=>{var i;document.getElementById((i=n.current)==null?void 0:i.getAttribute("aria-describedby"))||console.warn(l)},[l,n]),null},d_=Nx,f_=Tx,m_=Cx,Lx=Ax,Ux=Rx,Bx=Dx,Hx=zx,Vx=jx,$x=Ox;const gf=d_,vf=f_,h_=m_,Yx=v.forwardRef(({className:n,...l},o)=>f.jsx(Lx,{className:re("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),...l,ref:o}));Yx.displayName=Lx.displayName;const Gs=v.forwardRef(({className:n,...l},o)=>f.jsxs(h_,{children:[f.jsx(Yx,{}),f.jsx(Ux,{ref:o,className:re("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl border bg-background p-6 shadow-[0_34px_110px_-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),...l})]}));Gs.displayName=Ux.displayName;const Ps=({className:n,...l})=>f.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",n),...l});Ps.displayName="AlertDialogHeader";const Xs=({className:n,...l})=>f.jsx("div",{className:re("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...l});Xs.displayName="AlertDialogFooter";const Ks=v.forwardRef(({className:n,...l},o)=>f.jsx(Vx,{ref:o,className:re("text-lg font-semibold",n),...l}));Ks.displayName=Vx.displayName;const Qs=v.forwardRef(({className:n,...l},o)=>f.jsx($x,{ref:o,className:re("text-sm text-muted-foreground",n),...l}));Qs.displayName=$x.displayName;const Zs=v.forwardRef(({className:n,...l},o)=>f.jsx(Bx,{ref:o,className:re(jf(),n),...l}));Zs.displayName=Bx.displayName;const Is=v.forwardRef(({className:n,...l},o)=>f.jsx(Hx,{ref:o,className:re(jf({variant:"outline"}),"mt-2 sm:mt-0",n),...l}));Is.displayName=Hx.displayName;const p_={online:"bg-green-500",busy:"bg-yellow-500",offline:"bg-red-500"};function g_({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-green-500 opacity-30"}),f.jsx("span",{className:re("relative inline-flex h-2.5 w-2.5 rounded-full",p_[n])})]})}function v_({role:n,size:l="default"}){return f.jsx(St,{variant:n==="leader"?"default":"secondary",className:re(l==="compact"?"px-1.5 py-0 text-[9px] leading-4":"text-[11px]"),children:n})}const qx={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-red-200",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 Wj({status:n,size:l="default"}){const o=qx[n],i=l==="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(St,{variant:o.variant,className:re("rounded-sm font-medium shadow-none",i,o.className),children:[f.jsx("span",{className:re("rounded-full",o.dotClass)}),n]})}function eM({status:n,isNative:l=!1,size:o="default",className:i}){const c=qx[n],d=[n,l?"native":null].filter(Boolean).join(", "),m=o==="compact"?"h-1.5 w-1.5":"h-2 w-2";return f.jsxs("span",{className:re("inline-flex shrink-0 items-center gap-1",i),title:d,"aria-label":d,children:[f.jsx("span",{className:re("rounded-full",m,c.dotClass),title:n}),l&&f.jsx("span",{className:re("rounded-full bg-sky-500",m),title:"native"})]})}const y_={critical:{variant:"destructive",label:"Critical"},high:{variant:"outline",label:"High"},normal:{variant:"secondary",label:"Normal"},low:{variant:"secondary",label:"Low"}};function tM({priority:n}){const l=y_[n];return f.jsx(St,{variant:l.variant,className:"rounded-sm px-1.5 py-0 text-[10px] leading-4 shadow-none",children:l.label})}function b_(n){return[{key:"workspace",label:"Workspace",value:n==null?void 0:n.workspace},{key:"node",label:"Node app",value:n==null?void 0:n.node},{key:"core",label:"Core",value:n==null?void 0:n.core},{key:"dashboard",label:"Dashboard",value:n==null?void 0:n.dashboard},{key:"api",label:"API",value:n==null?void 0:n.api}].filter(o=>o.value)}function Ar({label:n,value:l,mono:o=!1}){return f.jsxs("div",{className:"min-w-0 rounded-lg 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:l})]})}function x_({formatDateTime:n,viewInfo:l}){var i,c,d,m,h,y,p,x;const o=b_(l.packages);return f.jsxs(qs,{value:"about","data-about-layout":"compact",className:"mt-0 space-y-2",children:[f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(qE,{className:"h-3.5 w-3.5 text-primary"}),"Repository & runtime"]}),f.jsx(Pn,{className:"text-[10px]",children:"Build source and runtime identity for this node."})]}),f.jsxs(Xn,{className:"space-y-2 px-3 pb-2.5",children:[(i=l.repository)!=null&&i.url?f.jsxs("a",{href:l.repository.url,target:"_blank",rel:"noreferrer",className:"group flex min-w-0 items-center justify-between gap-2 rounded-lg 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:l.repository.url}),f.jsx(sN,{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-lg 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(Ar,{label:"Branch",value:((c=l.repository)==null?void 0:c.branch)??"Unavailable",mono:!!((d=l.repository)!=null&&d.branch)}),f.jsx(Ar,{label:"Commit",value:((m=l.repository)==null?void 0:m.commit)??"Unavailable",mono:!!((h=l.repository)!=null&&h.commit)}),f.jsx(Ar,{label:"Runtime",value:`${l.packageName??"meshy"} ${l.version}`,mono:!0}),f.jsx(Ar,{label:"Node.js",value:((y=l.runtime)==null?void 0:y.nodeVersion)??"Unavailable",mono:!!((p=l.runtime)!=null&&p.nodeVersion)}),f.jsx(Ar,{label:"PID",value:l.runtime?String(l.runtime.pid):"Unavailable",mono:!!l.runtime}),f.jsx(Ar,{label:"Started",value:n((x=l.runtime)==null?void 0:x.startedAt)})]})]})]}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(hN,{className:"h-3.5 w-3.5 text-primary"}),"Package versions"]}),f.jsx(Pn,{className:"text-[10px]",children:"Version snapshot for the packages most relevant to this dashboard session."})]}),f.jsx(Xn,{"data-package-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:o.map(g=>{var w,N;return f.jsxs("div",{className:"grid gap-1.5 rounded-lg 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:g.label}),f.jsx("div",{className:"min-w-0 truncate text-[10px] text-muted-foreground",children:(w=g.value)==null?void 0:w.name}),f.jsx(St,{variant:"outline",className:"w-fit rounded-sm border-border/70 bg-background/60 font-mono text-[10px]",children:(N=g.value)==null?void 0:N.version})]},g.key)})})]})]})}var fc="Checkbox",[S_]=al(fc),[w_,tm]=S_(fc);function E_(n){const{__scopeCheckbox:l,checked:o,children:i,defaultChecked:c,disabled:d,form:m,name:h,onCheckedChange:y,required:p,value:x="on",internal_do_not_use_render:g}=n,[w,N]=kr({prop:o,defaultProp:c??!1,onChange:y,caller:fc}),[T,E]=v.useState(null),[C,A]=v.useState(null),j=v.useRef(!1),O=T?!!m||!!T.closest("form"):!0,z={checked:w,disabled:d,setChecked:N,control:T,setControl:E,name:h,form:m,value:x,hasConsumerStoppedPropagationRef:j,required:p,defaultChecked:Ja(c)?!1:c,isFormControl:O,bubbleInput:C,setBubbleInput:A};return f.jsx(w_,{scope:l,...z,children:N_(g)?g(z):i})}var Gx="CheckboxTrigger",Px=v.forwardRef(({__scopeCheckbox:n,onKeyDown:l,onClick:o,...i},c)=>{const{control:d,value:m,disabled:h,checked:y,required:p,setControl:x,setChecked:g,hasConsumerStoppedPropagationRef:w,isFormControl:N,bubbleInput:T}=tm(Gx,n),E=tt(c,x),C=v.useRef(y);return v.useEffect(()=>{const A=d==null?void 0:d.form;if(A){const j=()=>g(C.current);return A.addEventListener("reset",j),()=>A.removeEventListener("reset",j)}},[d,g]),f.jsx(Ue.button,{type:"button",role:"checkbox","aria-checked":Ja(y)?"mixed":y,"aria-required":p,"data-state":Ix(y),"data-disabled":h?"":void 0,disabled:h,value:m,...i,ref:E,onKeyDown:De(l,A=>{A.key==="Enter"&&A.preventDefault()}),onClick:De(o,A=>{g(j=>Ja(j)?!0:!j),T&&N&&(w.current=A.isPropagationStopped(),w.current||A.stopPropagation())})})});Px.displayName=Gx;var nm=v.forwardRef((n,l)=>{const{__scopeCheckbox:o,name:i,checked:c,defaultChecked:d,required:m,disabled:h,value:y,onCheckedChange:p,form:x,...g}=n;return f.jsx(E_,{__scopeCheckbox:o,checked:c,defaultChecked:d,disabled:h,required:m,onCheckedChange:p,name:i,form:x,value:y,internal_do_not_use_render:({isFormControl:w})=>f.jsxs(f.Fragment,{children:[f.jsx(Px,{...g,ref:l,__scopeCheckbox:o}),w&&f.jsx(Zx,{__scopeCheckbox:o})]})})});nm.displayName=fc;var Xx="CheckboxIndicator",Kx=v.forwardRef((n,l)=>{const{__scopeCheckbox:o,forceMount:i,...c}=n,d=tm(Xx,o);return f.jsx(Vr,{present:i||Ja(d.checked)||d.checked===!0,children:f.jsx(Ue.span,{"data-state":Ix(d.checked),"data-disabled":d.disabled?"":void 0,...c,ref:l,style:{pointerEvents:"none",...n.style}})})});Kx.displayName=Xx;var Qx="CheckboxBubbleInput",Zx=v.forwardRef(({__scopeCheckbox:n,...l},o)=>{const{control:i,hasConsumerStoppedPropagationRef:c,checked:d,defaultChecked:m,required:h,disabled:y,name:p,value:x,form:g,bubbleInput:w,setBubbleInput:N}=tm(Qx,n),T=tt(o,N),E=gb(d),C=rb(i);v.useEffect(()=>{const j=w;if(!j)return;const O=window.HTMLInputElement.prototype,B=Object.getOwnPropertyDescriptor(O,"checked").set,G=!c.current;if(E!==d&&B){const $=new Event("click",{bubbles:G});j.indeterminate=Ja(d),B.call(j,Ja(d)?!1:d),j.dispatchEvent($)}},[w,E,d,c]);const A=v.useRef(Ja(d)?!1:d);return f.jsx(Ue.input,{type:"checkbox","aria-hidden":!0,defaultChecked:m??A.current,required:h,disabled:y,name:p,value:x,form:g,...l,tabIndex:-1,ref:T,style:{...l.style,...C,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Zx.displayName=Qx;function N_(n){return typeof n=="function"}function Ja(n){return n==="indeterminate"}function Ix(n){return Ja(n)?"indeterminate":n?"checked":"unchecked"}const Fx=v.forwardRef(({className:n,...l},o)=>f.jsx(nm,{ref:o,className:re("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),...l,children:f.jsx(Kx,{className:re("flex items-center justify-center text-current"),children:f.jsx(ks,{className:"h-3.5 w-3.5"})})}));Fx.displayName=nm.displayName;const am=v.forwardRef(({className:n,type:l,...o},i)=>f.jsx("input",{type:l,className:re("flex h-10 w-full rounded-sm border border-input/85 bg-background/72 px-3 py-2 text-sm shadow-sm ring-offset-background transition-all duration-200 file:border-0 file:bg-transparent file:text-sm 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:i,...o}));am.displayName="Input";const e0=["queued","running"];function T_(n){return n.map(l=>`${l.id}:${l.name}`).join("\0")}function C_(n){return n==="claude"||n==="codex"||n==="copilot"}function Jx(n){var o;if(n.kind!=="agent.upgrade")return null;const l=(o=n.payload)==null?void 0:o.agent;return C_(l)?`${n.nodeId}:${l}`:null}function A_(n){return n.status==="succeeded"||n.status==="failed"}async function Wx(n,l={}){const o=l.getOperation??pE,i=l.pollIntervalMs??2e3,c=l.timeoutMs??24e4,d=Date.now()+c;let m=n;for(;!A_(m)&&Date.now()<d;)await __(i),m=await o(n.id);return m}async function R_(n,l=gE){const o=new Set(n),i=await Promise.all(e0.map(d=>l({kind:"agent.upgrade",status:d}))),c=new Map;for(const d of i.flat()){if(!e0.includes(d.status)||o.size>0&&!o.has(d.nodeId))continue;const m=Jx(d);if(!m)continue;const h=c.get(m);(!h||d.updatedAt>h.updatedAt)&&c.set(m,d)}return c}function __(n){return new Promise(l=>setTimeout(l,n))}const j_=1500,M_=1e3,O_=9e4;async function e1(n={}){const l=n.fetchHealth??D_,o=n.initialDelayMs??j_,i=n.pollIntervalMs??M_,c=n.previousPid,d=n.reload??(()=>window.location.reload()),m=n.sleep??z_,h=n.timeoutMs??O_,y=Date.now()+h;let p=!1;for(o>0&&await m(o);Date.now()<=y;){const x=k_(await l());if(!x.ok){p=!0,await m(i);continue}if(c===void 0||x.pid!==void 0&&x.pid!==c||p)return d(),!0;await m(i)}return!1}async function D_(){try{const n=await fetch("/api/system/health",{cache:"no-store"}),l=await n.json().catch(()=>null),o=l&&typeof l=="object"&&typeof l.pid=="number"?l.pid:void 0;return{ok:n.ok,pid:o}}catch{return!1}}function k_(n){return typeof n=="boolean"?{ok:n}:n}function z_(n){return new Promise(l=>window.setTimeout(l,n))}function L_(n,l=!0){return l?(n==null?void 0:n.restartMode)==="development"?"Restart dev runtime":n!=null&&n.updateAvailable?"Restart to update":"Restart runtime":n!=null&&n.updateAvailable?"Restart follower to update":"Restart follower"}function U_({checkedLabel:n,disableAuthDefault:l,endpoint:o,isLiveLocalNode:i,nodeId:c,nodeName:d,onRefresh:m,pid:h,transportType:y,update:p,workDir:x}){const g=L_(p,i),[w,N]=v.useState(null),[T,E]=v.useState(()=>t0({disableAuthDefault:l,endpoint:o,nodeName:d,transportType:y,workDir:x})),[C,A]=v.useState(!1),[j,O]=v.useState(!1),[z,B]=v.useState(!1);v.useEffect(()=>{E(t0({disableAuthDefault:l,endpoint:o,nodeName:d,transportType:y,workDir:x}))},[l,o,d,y,x]);async function G(){if(!c||C||j)return;const le=p.updateAvailable?"update":"restart",fe=V_(T);if(T.port.trim()&&(fe==null?void 0:fe.port)===void 0){Ge.error("Runtime restart port must be a positive integer");return}const me=fe?{reason:le,startArgs:fe}:{reason:le};A(!0);try{if(i){const M=await O0(me);N({...M,pid:M.pid??h,status:"accepted"}),Ge.info(`Restarting ${d} from a detached helper. PID ${M.pid??h??"unknown"} will not stay attached to the original terminal window; follow ${M.logPath} for launch output.`),e1({previousPid:M.pid??h}).then(Y=>{Y||(A(!1),Ge.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout. Refresh the page after the node finishes starting."))}).catch(Y=>{A(!1),Ge.error(Y instanceof Error?Y.message:"Runtime restart recovery failed")});return}const ie=await yE(c,me);N({operationId:ie.id,pid:h,status:ie.status}),Ge.info(`Restart requested on ${d}. Operation ${Xd(ie.id)} will hand off to a detached process, so the new runtime will not stay attached to the original terminal window.`);const ue=await Wx(ie,{timeoutMs:6e4}),oe=H_(ue);N({command:oe==null?void 0:oe.command,logPath:oe==null?void 0:oe.logPath,mode:oe==null?void 0:oe.mode,operationId:ue.id,pid:(oe==null?void 0:oe.pid)??h,status:ue.status}),ue.status==="succeeded"?(await(m==null?void 0:m()),Ge.success(`Restart handoff accepted on ${d}. Follow ${(oe==null?void 0:oe.logPath)??"the node restart log"} for launch output.`)):ue.status==="failed"?Ge.error(ue.error??`Restart failed on ${d}`):Ge.info(`Restart operation ${Xd(ue.id)} is still ${ue.status}. More details will update after the node reports back.`),A(!1)}catch(ie){A(!1),Ge.error(ie instanceof Error?ie.message:"Runtime restart failed")}}async function $(){if(!(!i||C||j)){O(!0);try{const le=await mE();Ge.info(`Stopping Meshy process ${le.pid}`)}catch(le){O(!1),Ge.error(le instanceof Error?le.message:"Runtime stop failed")}}}const V=C?"restarting":j?"stopping":(w==null?void 0:w.status)??"idle",ne=p.restartMode==="development";return f.jsxs("div",{className:"rounded-xl border border-border/70 bg-background/70 overflow-hidden",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(Ds,{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:ne?"Development launcher":`Latest ${p.latestVersion??"—"}`})]})]}),f.jsx("div",{className:"flex items-center gap-1.5",children:f.jsx(St,{variant:p.updateAvailable?"default":"outline",className:"rounded-full border-border/70 bg-background/60 font-mono text-[10px] px-2 py-0.5",children:ne?"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:V})]})]}),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:[i&&f.jsxs(gf,{children:[f.jsx(vf,{asChild:!0,children:f.jsxs(yn,{type:"button",size:"sm",variant:"ghost",disabled:C||j,className:"h-7 rounded-lg px-2 text-[11px] text-muted-foreground hover:text-destructive hover:bg-destructive/10",children:[f.jsx(xN,{className:re("mr-1 h-3.5 w-3.5",j&&"animate-pulse")}),j?"Stopping":"Stop"]})}),f.jsxs(Gs,{className:"max-w-[22rem] rounded-xl gap-2 p-4",children:[f.jsxs(Ps,{className:"space-y-1",children:[f.jsx(Ks,{className:"text-sm",children:"Stop runtime?"}),f.jsx(Qs,{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(Xs,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Is,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),f.jsx(Zs,{className:"h-7 rounded-lg px-2 text-[11px] bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>void $(),children:"Stop runtime"})]})]})]}),f.jsxs(gf,{children:[f.jsx(vf,{asChild:!0,children:f.jsxs(yn,{type:"button",size:"sm",variant:p.updateAvailable?"default":"outline",disabled:!c||C||j,className:"h-7 rounded-lg px-2 text-[11px]",children:[f.jsx(tf,{className:re("mr-1 h-3.5 w-3.5",C&&"animate-spin")}),C?"Restarting…":g]})}),f.jsxs(Gs,{className:"max-w-[28rem] gap-3 rounded-xl p-4",children:[f.jsxs(Ps,{className:"space-y-1",children:[f.jsxs(Ks,{className:"text-sm",children:[g,"?"]}),f.jsxs(Qs,{className:"text-[11px] leading-4",children:["Starts a detached restart helper, shuts down ",i?"the current node":d,", and brings it back with the configured launcher. The new process will not stay attached to the original terminal window."]})]}),f.jsx(B_,{value:T,onChange:E}),f.jsxs(Xs,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Is,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),f.jsx(Zs,{className:"h-7 rounded-lg px-2 text-[11px]",onClick:()=>void G(),children:g})]})]})]})]})]}),f.jsxs("div",{className:"border-t border-border/50",children:[f.jsxs("button",{type:"button",onClick:()=>B(le=>!le),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($0,{className:"h-3 w-3"}),"Restart details"]}),f.jsx(Ko,{className:re("h-3 w-3 transition-transform duration-150",z&&"rotate-180")})]}),z&&f.jsxs("div",{className:"border-t border-border/50 bg-muted/20 px-3 py-2 space-y-1",children:[f.jsx(_l,{label:"Current PID",value:h===void 0?"—":String(h),mono:h!==void 0}),f.jsx(_l,{label:"Restart PID",value:(w==null?void 0:w.pid)===void 0?"Pending":String(w.pid),mono:(w==null?void 0:w.pid)!==void 0}),f.jsx(_l,{label:"Operation",value:w!=null&&w.operationId?Xd(w.operationId):"Local direct request",mono:!!(w!=null&&w.operationId)}),f.jsx(_l,{label:"Status",value:(w==null?void 0:w.status)??(C?"requested":"idle")}),f.jsx(_l,{label:"Launcher",value:(w==null?void 0:w.command)??"Available after restart",mono:!!(w!=null&&w.command)}),f.jsx(_l,{label:"Log",value:(w==null?void 0:w.logPath)??"Available after restart",mono:!!(w!=null&&w.logPath)}),f.jsx(_l,{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 B_({onChange:n,value:l}){const o=(i,c)=>{n({...l,[i]: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(Ho,{label:"HTTP port",value:l.port,onChange:i=>o("port",i),inputMode:"numeric"}),f.jsx(Ho,{label:"Node name",value:l.name,onChange:i=>o("name",i)}),f.jsx(Ho,{label:"Join endpoint",value:l.join,onChange:i=>o("join",i),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(Wb,{value:l.transport,onValueChange:i=>o("transport",t1(i)),children:[f.jsx(Jf,{className:"h-7 rounded-md border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(ex,{placeholder:"Transport"})}),f.jsxs(Wf,{children:[f.jsx(jr,{className:"py-1 text-[11px]",value:"inherit",children:"current / default"}),f.jsx(jr,{className:"py-1 text-[11px]",value:"direct",children:"direct"}),f.jsx(jr,{className:"py-1 text-[11px]",value:"devtunnel",children:"devtunnel"}),f.jsx(jr,{className:"py-1 text-[11px]",value:"tailscale",children:"tailscale"})]})]})]}),f.jsx(Ho,{label:"Working directory",value:l.workDir,onChange:i=>o("workDir",i)}),f.jsx(Ho,{label:"Config path",value:l.config,onChange:i=>o("config",i),className:"sm:col-span-2"}),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(Fx,{className:"h-3.5 w-3.5",checked:l.disableAuth,onCheckedChange:i=>n({...l,disableAuth:i===!0,disableAuthKnown:!0})}),"Disable auth"]})]})]})}function Ho({className:n,inputMode:l,label:o,onChange:i,value:c}){return f.jsxs("label",{className:re("space-y-1",n),children:[f.jsx("span",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:o}),f.jsx(am,{className:"h-7 rounded-md px-2 text-[10px]",inputMode:l,value:c,onChange:d=>i(d.target.value)})]})}function _l({label:n,value:l,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:re("break-all text-right text-foreground",o&&"font-mono"),children:l})]})}function H_(n){const l=n.result;if(!l||typeof l!="object")return null;const o=l;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 t0(n){return{port:$_(n.endpoint),name:n.nodeName,join:"",transport:t1(n.transportType),workDir:n.workDir??"",config:"",disableAuth:n.disableAuthDefault===!0,disableAuthKnown:n.disableAuthDefault!==void 0}}function V_(n){const l={},o=Number(n.port.trim());return n.port.trim()&&Number.isInteger(o)&&o>0&&(l.port=o),n.name.trim()&&(l.name=n.name.trim()),n.join.trim()&&(l.join=n.join.trim()),n.transport!=="inherit"&&(l.transport=n.transport),n.workDir.trim()&&(l.workDir=n.workDir.trim()),n.config.trim()&&(l.config=n.config.trim()),n.disableAuthKnown&&(l.disableAuth=n.disableAuth),Object.keys(l).length>0?l:void 0}function t1(n){return n==="direct"||n==="devtunnel"||n==="tailscale"?n:"inherit"}function $_(n){if(!n)return"";try{return new URL(n).port||""}catch{return""}}function Xd(n){return n.length<=8?n:n.slice(0,8)}function Vo({formatDateTime:n,name:l,status:o,statusVariant:i}){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:l}),f.jsx("div",{className:"text-[10px] text-muted-foreground",children:n(o==null?void 0:o.checkedAt)})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof(o==null?void 0:o.authenticated)=="boolean"&&f.jsx(St,{variant:o.authenticated?"default":"outline",className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o.authenticated?"auth ok":"auth required"}),f.jsx(St,{variant:i(o==null?void 0:o.status),className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:(o==null?void 0:o.status)??"unknown"})]})]})}function Zt(n){if(n==null||n==="")return"Unavailable";const l=new Date(n);return Number.isNaN(l.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(l)}function Y_(n){const l=Math.max(0,Math.floor(n)),o=Math.floor(l/86400),i=Math.floor(l%86400/3600),c=Math.floor(l%3600/60);return o>0?`${o}d ${i}h`:i>0?`${i}h ${c}m`:`${c}m`}function n0(n){if(n==null||Number.isNaN(n))return"Unavailable";const l=["B","KB","MB","GB","TB"];let o=n,i=0;for(;o>=1024&&i<l.length-1;)o/=1024,i+=1;return`${o.toFixed(o>=10||i===0?0:1)} ${l[i]}`}function _r(n){return n==="ok"?"default":n==="missing"||n==="install-failed"||n==="login-failed"?"destructive":n==="not-authenticated"||n==="unsupported-platform"?"outline":"secondary"}function q_(n){return n.available?f.jsxs(St,{className:"gap-1 rounded-full px-2 py-0.5 text-[10px]",children:[f.jsx(Yo,{className:"h-3 w-3"}),"Available"]}):f.jsxs(St,{variant:"destructive",className:"gap-1 rounded-full px-2 py-0.5 text-[10px]",children:[f.jsx(nN,{className:"h-3 w-3"}),"Unavailable"]})}function G_(n){return n.update?n.update.updateAvailable?f.jsxs(St,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:["Update ",n.update.latestVersion]}):f.jsx(St,{variant:"secondary",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:"Up to date"}):null}function P_(n){return n.available?null:n.metadataStatus??null}function X_(n){var o;const l=`npm install -g ${(o=n.update)==null?void 0:o.packageName}@latest`;return n.id==="claude"?`${l} --include=optional --ignore-scripts=false`:l}function K_(n){if(n.error)return n.error;const l=n.result;return(l==null?void 0:l.detail)??null}function et({label:n,value:l,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:re("break-all text-right text-[11px] text-foreground",o&&"font-mono text-[11px]"),children:l})]})}function $o({label:n,value:l,mono:o=!1,className:i}){return f.jsxs("div",{className:re("min-w-0 space-y-0.5",i),children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:n}),f.jsx("div",{className:re("truncate text-[11px] text-foreground",o&&"font-mono",n==="Path"&&"break-all whitespace-normal"),children:l})]})}function Q_({agent:n,nodeName:l,activeOperation:o,onUpgrade:i}){var y,p;const c=((y=n.update)==null?void 0:y.updateAvailable)===!0,d=G_(n),m=!!o,h=P_(n);return f.jsxs("div",{className:"rounded-lg 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(L0,{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:[q_(n),h&&f.jsx(St,{variant:_r(h),className:"rounded-full px-2 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($o,{label:"Version",value:n.version??"Unavailable",mono:!!n.version}),n.update&&f.jsx($o,{label:"Latest",value:n.update.latestVersion??"Unavailable",mono:!!n.update.latestVersion}),f.jsx($o,{label:"Checked",value:Zt(n.checkedAt)}),n.update&&f.jsx($o,{label:"Update check",value:Zt(n.update.checkedAt)}),f.jsx($o,{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(St,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:["Upgrade ",o.status]}):c?f.jsxs(gf,{children:[f.jsx(vf,{asChild:!0,children:f.jsx("button",{type:"button",disabled:m,className:"rounded-full transition duration-150 hover:-translate-y-0.5 hover:scale-[1.03] hover:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 focus-visible:ring-offset-2 active:translate-y-0 active:scale-95 disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:translate-y-0 disabled:hover:scale-100 disabled:hover:shadow-none",children:d})}),f.jsxs(Gs,{children:[f.jsxs(Ps,{children:[f.jsxs(Ks,{children:["Upgrade ",n.label,"?"]}),f.jsxs(Qs,{children:["This runs ",X_(n)," on ",l,". Remote nodes execute the command on the remote machine."]})]}),f.jsxs(Xs,{children:[f.jsx(Is,{children:"Cancel"}),f.jsx(Zs,{onClick:()=>i(n),children:"Upgrade"})]})]})]}):d})]}),((p=n.update)==null?void 0:p.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 Z_(n,l){var o;return(o=n==null?void 0:n.nodes)!=null&&o.length?n.nodes:l?[l]:[]}function I_(n,l){var i;if(l&&n.id===l.nodeId)return l;const o=n.settingsSnapshot;return{...n,nodeId:n.id,version:(o==null?void 0:o.version)??"Unavailable",packageName:o==null?void 0:o.packageName,uptime:(o==null?void 0:o.uptime)??0,localDashboardOrigin:((i=o==null?void 0:o.runtime)==null?void 0:i.localDashboardOrigin)??void 0,auth:o==null?void 0:o.auth,os:o==null?void 0:o.os,runtime:o==null?void 0:o.runtime,runtimeUpdate:o==null?void 0:o.runtimeUpdate,agents:o==null?void 0:o.agents,startupRequirements:o==null?void 0:o.startupRequirements,components:o==null?void 0:o.components,repository:o==null?void 0:o.repository,packages:o==null?void 0:o.packages}}function F_(n,l){return n.id===l?`${n.name} (this node)`:`${n.name} (${n.role})`}function J_(n){return n==="claude"?"Claude Code":n==="copilot"?"Copilot CLI":"Codex"}function W_(n){var o;const l=(o=n.payload)==null?void 0:o.agent;return l==="claude"||l==="codex"||l==="copilot"?l:null}function e3({cluster:n,systemInfo:l,sseConnected:o,initialSelectedNodeId:i,onRefresh:c}){var ne,le,fe,me,ie,ue,oe,M,Y,I,de,F,R,P,K,W,te,se,ee,ce;const d=v.useMemo(()=>Z_(n,l),[n,l]),[m,h]=v.useState(()=>{var J;return i??(l==null?void 0:l.nodeId)??((J=n==null?void 0:n.self)==null?void 0:J.id)??""}),[y,p]=v.useState(()=>new Map),x=v.useRef(new Set),g=v.useRef(new Set),w=(n==null?void 0:n.self)??l??d[0]??null,N=d.find(J=>J.id===m)??w,T=N?I_(N,l):null,E=!!(l&&N&&N.id===l.nodeId),C=E||!!(N!=null&&N.settingsSnapshot),A=T==null?void 0:T.runtimeUpdate,j=((ne=T==null?void 0:T.startupRequirements)==null?void 0:ne.components)??(T==null?void 0:T.components)??{},O=v.useMemo(()=>d.map(J=>J.id),[d]),z=O.join("\0"),B=T_(d),G=v.useMemo(()=>new Map(d.map(J=>[J.id,J.name])),[B]);v.useEffect(()=>{i&&O.includes(i)&&h(i)},[i,z]);const $=v.useCallback(async(J,ve)=>{const be=Jx(J);if(!be||x.current.has(J.id))return;const Se=W_(J),He=(ve==null?void 0:ve.agentLabel)??(Se?J_(Se):"Agent"),je=(ve==null?void 0:ve.nodeName)??G.get(J.nodeId)??J.nodeId;x.current.add(J.id),p(Ve=>new Map(Ve).set(be,J));try{const Ve=await Wx(J);if(Ve.status==="succeeded")await(c==null?void 0:c()),g.current.has(Ve.id)||(Ge.success(`${He} upgrade finished on ${je}`),g.current.add(Ve.id));else if(Ve.status==="failed")g.current.has(Ve.id)||(Ge.error(K_(Ve)??`${He} upgrade failed`),g.current.add(Ve.id));else{p(dt=>new Map(dt).set(be,Ve)),Ge.info(`${He} upgrade is still ${Ve.status} on ${je}`);return}p(dt=>{const Pe=new Map(dt),Lt=Pe.get(be);return(!Lt||Lt.id===Ve.id)&&Pe.delete(be),Pe})}catch(Ve){p(dt=>{const Pe=new Map(dt),Lt=Pe.get(be);return(!Lt||Lt.id===J.id)&&Pe.delete(be),Pe}),Ge.error(Ve instanceof Error?Ve.message:`${He} upgrade failed`)}finally{x.current.delete(J.id)}},[c,G]);v.useEffect(()=>{if(O.length===0)return;let J=!1;async function ve(){let be;try{be=await R_(O)}catch{return}if(!J){p(Se=>{const He=new Map(Se);for(const[je,Ve]of be)He.set(je,Ve);return He});for(const Se of be.values())$(Se)}}return ve(),()=>{J=!0}},[$,z]);async function V(J){if(N)try{const ve=await vE(N.id,J.id);Ge.info(`${J.label} upgrade started on ${N.name}`),await $(ve,{agentLabel:J.label,nodeName:N.name})}catch(ve){Ge.error(ve instanceof Error?ve.message:`${J.label} upgrade failed`)}}return!N||!T?f.jsx("div",{className:"rounded-2xl border border-dashed border-border/70 bg-muted/20 px-4 py-8 text-center text-[12px] text-muted-foreground",children:"Loading session metadata..."}):f.jsxs("div",{className:"space-y-3",children:[f.jsxs("section",{className:"relative mt-2 rounded-2xl border border-border/70 bg-[radial-gradient(circle_at_top_left,rgba(59,130,246,0.18),transparent_42%),radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.12),transparent_32%),rgba(255,255,255,0.72)] p-3 shadow-[0_24px_90px_-54px_rgba(15,23,42,0.55)] dark:bg-[radial-gradient(circle_at_top_left,rgba(59,130,246,0.18),transparent_42%),radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.12),transparent_32%),rgba(10,15,23,0.78)]",children:[!E&&f.jsxs(St,{variant:"outline",className:"absolute right-3 top-2.5 rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em] whitespace-nowrap",children:["Updated ",Zt((le=N.settingsSnapshot)==null?void 0:le.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-full border border-border/70 bg-background/75 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur",children:[f.jsx(g_,{status:N.status}),f.jsx("span",{className:"font-medium text-foreground",children:N.name})]}),f.jsx(v_,{role:N.role}),f.jsx(St,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:N.transportType??T.transportType??"direct"}),f.jsx(St,{variant:E?"default":"outline",className:"rounded-full px-2 py-0.5 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."})]}),d.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(Wb,{value:N.id,onValueChange:h,children:[f.jsx(Jf,{className:"h-7 rounded-lg border-border/70 bg-background/70 text-[11px]",children:f.jsx(ex,{placeholder:"Choose a node"})}),f.jsx(Wf,{className:"settings-node-select-content rounded-lg text-[10px] leading-4",children:d.map(J=>f.jsx(jr,{value:J.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:F_(J,l==null?void 0:l.nodeId)},J.id))})]})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(St,{variant:o?"default":"outline",className:"gap-1 rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:[f.jsx(wN,{className:"h-3 w-3"}),o?"Live link":"Reconnecting"]}),f.jsxs(St,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Uptime ",Y_(T.uptime)]})]})]})]}),!C&&f.jsx("div",{className:"rounded-xl 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(t_,{defaultValue:"session",className:"space-y-2",children:[f.jsxs(wx,{className:"h-auto flex-wrap rounded-xl border border-border/60 bg-muted/40 p-0.5",children:[f.jsx(js,{value:"session",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Session"}),f.jsx(js,{value:"access",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Access"}),f.jsx(js,{value:"about",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"About"})]}),f.jsxs(qs,{value:"session",className:"mt-0 grid gap-2 xl:grid-cols-[1.15fr_0.85fr]",children:[f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(H0,{className:"h-3.5 w-3.5 text-primary"}),"Selected node"]}),f.jsx(Pn,{className:"text-[10px]",children:"Cluster role, identity, and node-scoped runtime state."})]}),f.jsxs(Xn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Node ID",value:T.nodeId,mono:!0}),f.jsx(et,{label:"Status",value:N.status}),f.jsx(et,{label:"Role",value:N.role}),f.jsx(et,{label:"Endpoint",value:N.endpoint,mono:!0}),f.jsx(et,{label:"Joined",value:Zt(N.joinedAt)}),f.jsx(et,{label:"Heartbeat",value:Zt(N.lastHeartbeat)}),f.jsx(et,{label:"Capabilities",value:N.capabilities.length>0?N.capabilities.join(", "):"None"})]})]}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(oN,{className:"h-3.5 w-3.5 text-primary"}),"OS info"]}),f.jsx(Pn,{className:"text-[10px]",children:"Host and resource details reported by the current process."})]}),f.jsxs(Xn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Host",value:((fe=T.os)==null?void 0:fe.hostname)??"Unavailable"}),f.jsx(et,{label:"Platform",value:T.os?`${T.os.platform} ${T.os.release}`:"Unavailable"}),f.jsx(et,{label:"Arch",value:((me=T.os)==null?void 0:me.arch)??"Unavailable"}),f.jsx(et,{label:"CPU",value:((ie=T.os)==null?void 0:ie.cpuModel)??"Unavailable"}),f.jsx(et,{label:"Cores",value:String(((ue=T.os)==null?void 0:ue.cpuCount)??"Unavailable")}),f.jsx(et,{label:"Memory",value:T.os?`${n0(T.os.freeMemoryBytes)} free / ${n0(T.os.totalMemoryBytes)} total`:"Unavailable"})]})]}),A&&f.jsx("div",{className:"xl:col-span-2",children:f.jsx(U_,{checkedLabel:Zt(A.checkedAt),disableAuthDefault:((oe=T.auth)==null?void 0:oe.enabled)===void 0?void 0:T.auth.enabled===!1,endpoint:N.endpoint,isLiveLocalNode:E,nodeId:N.id,nodeName:N.name,onRefresh:c,pid:(M=T.runtime)==null?void 0:M.pid,transportType:N.transportType,update:A,workDir:((Y=T.runtime)==null?void 0:Y.workDir)??N.workDir})}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)] xl:col-span-2",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(L0,{className:"h-3.5 w-3.5 text-primary"}),"Available agents"]}),f.jsx(Pn,{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(Xn,{"data-agent-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:(T.agents??[]).map(J=>f.jsx(Q_,{agent:J,nodeName:N.name,activeOperation:y.get(`${N.id}:${J.id}`),onUpgrade:V},J.id))})]})]}),f.jsxs(qs,{value:"access",className:"mt-0 grid gap-2 xl:grid-cols-2",children:[f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(XE,{className:"h-3.5 w-3.5 text-primary"}),"Access surface"]}),f.jsx(Pn,{className:"text-[10px]",children:"How this node is exposed to the dashboard and other peers."})]}),f.jsxs(Xn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Transport",value:N.transportType??T.transportType??"direct"}),f.jsx(et,{label:"Node URL",value:N.endpoint,mono:!0}),f.jsx(et,{label:"Node tunnel",value:N.devtunnelEndpoint??"Disabled",mono:!!N.devtunnelEndpoint}),f.jsx(et,{label:"Dashboard URL",value:N.dashboardOrigin??T.localDashboardOrigin??"Unavailable",mono:!!(N.dashboardOrigin||T.localDashboardOrigin)}),f.jsx(et,{label:"Local dashboard",value:T.localDashboardOrigin??"Unavailable",mono:!!T.localDashboardOrigin})]})]}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(MN,{className:"h-3.5 w-3.5 text-primary"}),"Auth"]}),f.jsx(Pn,{className:"text-[10px]",children:"Current bearer-auth and trusted access posture."})]}),f.jsxs(Xn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Enabled",value:(I=T.auth)!=null&&I.enabled?"Yes":"No"}),f.jsx(et,{label:"Same tenant",value:(de=T.auth)!=null&&de.allowSameTenant?"Allowed":"Off"}),f.jsx(et,{label:"Allowed users",value:(F=T.auth)!=null&&F.allowedUsers.length?T.auth.allowedUsers.join(", "):"None"})]})]}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(uN,{className:"h-3.5 w-3.5 text-primary"}),"Paths"]}),f.jsx(Pn,{className:"text-[10px]",children:"Workspace and runtime paths currently used by this node."})]}),f.jsxs(Xn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Work dir",value:((R=T.runtime)==null?void 0:R.workDir)??T.workDir??"Unavailable",mono:!!(((P=T.runtime)==null?void 0:P.workDir)??T.workDir)}),f.jsx(et,{label:"Storage",value:((K=T.runtime)==null?void 0:K.storagePath)??"Unavailable",mono:!!((W=T.runtime)!=null&&W.storagePath)}),f.jsx(et,{label:"Process cwd",value:((te=T.runtime)==null?void 0:te.cwd)??"Unavailable",mono:!!((se=T.runtime)!=null&&se.cwd)}),f.jsx(et,{label:"Started",value:Zt((ee=T.runtime)==null?void 0:ee.startedAt)}),f.jsx(et,{label:"PID",value:T.runtime?String(T.runtime.pid):"Unavailable",mono:!!T.runtime})]})]}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(Ds,{className:"h-3.5 w-3.5 text-primary"}),"Startup checks"]}),f.jsx(Pn,{className:"text-[10px]",children:"Dependency preflight snapshot persisted during node startup."})]}),f.jsxs(Xn,{className:"space-y-3 px-3 pb-2.5",children:[f.jsxs("div",{className:"rounded-xl 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:Zt((ce=T.startupRequirements)==null?void 0:ce.lastCheckedAt)})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vo,{formatDateTime:Zt,name:"Azure CLI",status:j.az,statusVariant:_r}),f.jsx(Vo,{formatDateTime:Zt,name:"DevTunnel",status:j.devtunnel,statusVariant:_r}),f.jsx(Vo,{formatDateTime:Zt,name:"Claude Code",status:j.claude,statusVariant:_r}),f.jsx(Vo,{formatDateTime:Zt,name:"Codex",status:j.codex,statusVariant:_r}),f.jsx(Vo,{formatDateTime:Zt,name:"Copilot CLI",status:j.copilot,statusVariant:_r})]})]})]})]}),f.jsx(x_,{formatDateTime:Zt,viewInfo:T})]})]})}function t3({initialSelectedNodeId:n,open:l,onOpenChange:o,showTrigger:i=!0}={}){const{cluster:c,systemInfo:d,sseConnected:m,refresh:h}=k0();return f.jsx(G5,{open:l,onOpenChange:o,showTrigger:i,children:f.jsx(e3,{cluster:c,systemInfo:d,sseConnected:m,initialSelectedNodeId:n,onRefresh:h})})}const nM="codex",aM="bypass",n3=[{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"}],lM=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],rM=new Set(n3.filter(n=>n.supportsFollowUp).map(n=>n.value)),oM=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"shared",label:"Shared"},{value:"archived",label:"Archived"}],iM=[{value:"all",label:"All task types"},{value:"native",label:"Native sessions"},{value:"meshy",label:"Meshy chats"}],a3=new Set(["pending","assigned"]),l3=new Set(["running"]),r3=new Set(["completed","failed","cancelled"]),sM=10;function cM(n,l){switch(l){case"running":return l3.has(n.status);case"waiting":return a3.has(n.status);case"closed":return r3.has(n.status);case"shared":return!!n.activeShare;case"archived":return n.status==="archived";case"active":default:return n.status!=="archived"}}function uM(n,l){if(l==="all")return!0;const o=n.conversationKind==="nativeSession";return l==="native"?o:!o}function dM(n,l){const o=l.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(i=>i.toLowerCase().includes(o)):!0}function o3(n,l,o){if(!n)return"unassigned";const i=l==null?void 0:l.find(c=>c.id===n);return(i==null?void 0:i.name)??o??n.slice(0,8)}function fM(n,l,o){return o3(n,l,o).toLowerCase()}function mM(n,l,o){return!n.assignedTo||(o==null?void 0:o.id)===n.assignedTo?!0:(l==null?void 0:l.some(i=>i.id===n.assignedTo))??!1}function hM(n,l){return[...n].sort((o,i)=>o.id===l?-1:i.id===l?1:o.name.localeCompare(i.name))}function pM(n){if(!n||typeof n!="object")return null;const l=n,o=l.createMode,i=o==="chat"||o==="native"?o:void 0,c=l.createDefaults,d=c&&typeof c=="object"&&!Array.isArray(c)?c:null,m=d?{assignTo:typeof d.assignTo=="string"||d.assignTo===null?d.assignTo:void 0,project:typeof d.project=="string"||d.project===null?d.project:void 0}:void 0;return{draftNewTask:l.draftNewTask===!0,returnRoute:typeof l.returnRoute=="string"?l.returnRoute:void 0,returnTaskId:typeof l.returnTaskId=="string"||l.returnTaskId===null?l.returnTaskId:void 0,createMode:i,createDefaults:m}}function gM(n){return n==="default workspace"?n:n.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??n}function vM(n){const l=Date.now()-n;return l<6e4?"just now":l<36e5?`${Math.floor(l/6e4)}m`:l<864e5?`${Math.floor(l/36e5)}h`:`${Math.floor(l/864e5)}d`}function yM(n){return new Date(n).toLocaleString()}function bM(n){const l=Math.floor(n/1e3),o=Math.floor(l/3600),i=Math.floor(l%3600/60),c=l%60;return`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}:${String(c).padStart(2,"0")}`}async function i3(n,l="Copied to clipboard"){var o,i,c;try{if((i=(o=globalThis.navigator)==null?void 0:o.clipboard)!=null&&i.writeText)return await globalThis.navigator.clipboard.writeText(n),Ge.success(l),!0;const d=globalThis.document,m=(c=d==null?void 0:d.execCommand)==null?void 0:c.bind(d);if(!(d!=null&&d.body)||typeof d.createElement!="function"||typeof m!="function")throw new Error("Clipboard access is unavailable");const h=d.createElement("textarea"),y=d.activeElement,p=y&&typeof y.focus=="function"?y:null;h.value=n,h.setAttribute("readonly","true"),h.style.position="fixed",h.style.opacity="0",h.style.pointerEvents="none",d.body.appendChild(h),h.select(),h.setSelectionRange(0,h.value.length);const x=m("copy");if(d.body.removeChild(h),p==null||p.focus(),!x)throw new Error("Clipboard access is unavailable");return Ge.success(l),!0}catch(d){return Ge.error(d instanceof Error?d.message:"Failed to copy"),!1}}const s3="default workspace";function Ms(n){const l=n.replace(/\\/g,"/");return l==="/"||/^[A-Za-z]:\/$/.test(l)?l:l.replace(/\/+$/g,"")||l}function c3(n){const l=n.replace(/\\/g,"/");return l.startsWith("/")||l.startsWith("//")||/^[A-Za-z]:\//.test(l)}function u3(n,l){const o=Ms(n),i=l.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!i||i==="."?o:o==="/"||/^[A-Za-z]:\/$/.test(o)?`${o}${i}`:`${o}/${i}`}function d3(n,l){var d,m,h;const o=(d=n.effectiveProjectPath)==null?void 0:d.trim();if(o)return Ms(o);const i=(m=n.project)==null?void 0:m.trim();if(!i)return s3;if(c3(i)||!n.assignedTo)return Ms(i);const c=(h=l==null?void 0:l.get(n.assignedTo))==null?void 0:h.trim();return c?u3(c,i):Ms(i)}function xM(n,l,o,i){const c=new Map;for(const m of n){const h=m.assignedTo??null,y=h??"__unassigned__",p=h?l.get(h)??m.assignedNodeName??h.slice(0,8):"Unassigned",x=d3(m,i);c.has(y)||c.set(y,{nodeId:h,nodeName:p,dirMap:new Map});const g=c.get(y);g.dirMap.has(x)||g.dirMap.set(x,[]),g.dirMap.get(x).push(m)}const d=Array.from(c.values()).map(({nodeId:m,nodeName:h,dirMap:y})=>{const p=Array.from(y.entries()).map(([x,g])=>({path:x,tasks:g})).sort((x,g)=>g.tasks.length-x.tasks.length||x.path.localeCompare(g.path));return{nodeId:m,nodeName:h,dirs:p}});return d.sort((m,h)=>{if(o){if(m.nodeId===o)return-1;if(h.nodeId===o)return 1}return m.nodeId===null?1:h.nodeId===null?-1:m.nodeName.localeCompare(h.nodeName)}),d}const f3={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"},m3={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 h3(n){return n.split(".")[0]??"unknown"}function p3(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function Rr(n,l){return(l==null?void 0:l.get(n))??n}function n1(n,l){const o=n.data,i=o.operation;switch(n.type){case"node.joined":return`${o.name} joined the cluster`;case"node.left":return`${Rr(o.nodeId,l)} left (${o.reason})`;case"node.status":return`${Rr(o.nodeId,l)} is now ${o.status}`;case"node.operation.created":return`${i==null?void 0:i.kind} ${i==null?void 0:i.status} on ${Rr(i==null?void 0:i.nodeId,l)}`;case"node.operation.updated":return`${i==null?void 0:i.kind} ${i==null?void 0:i.status} on ${Rr(i==null?void 0:i.nodeId,l)}`;case"transport.changed":return`${Rr(o.nodeId,l)} transport switched to ${o.transportType}`;case"task.created":return`"${o.title}" created`;case"task.assigned":return`task assigned to ${Rr(o.nodeId,l)}`;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 g3(n){return JSON.stringify(n,null,2)}function v3({events:n,maxHeight:l="400px",nodeNameById:o,onDismiss:i,density:c="default"}){if(n.length===0)return null;const d=c==="compact";return f.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:l},children:f.jsx("div",{className:"space-y-1.5",children:n.map(m=>{const h=h3(m.type);return f.jsx("div",{className:re("transition-colors hover:bg-muted/30",d?"rounded-sm px-1 py-0.5":"rounded-lg 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:re("font-mono text-muted-foreground",d?"text-[8px]":"text-[9px]"),children:p3(m.timestamp)}),d?f.jsx("span",{className:re("max-w-[8.5rem] truncate text-[7px] font-medium uppercase tracking-[0.08em] text-muted-foreground/70",m3[h]),children:m.type}):f.jsx(St,{variant:"outline",className:re("w-fit text-[9px] font-medium uppercase tracking-[0.14em] px-1.5 py-0",f3[h]),children:m.type})]}),f.jsxs("div",{className:re("flex shrink-0 items-center",d?"gap-px":"gap-0.5"),children:[f.jsx(yn,{type:"button",variant:"ghost",size:"icon",className:re("rounded-sm text-muted-foreground hover:text-foreground",d?"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:()=>void i3(g3(m),"Event copied"),"aria-label":`Copy ${m.type} event`,title:"Copy event",children:f.jsx(lN,{className:d?"h-2.5 w-2.5":"h-3 w-3"})}),i&&f.jsx(yn,{type:"button",variant:"ghost",size:"icon",className:re("rounded-sm text-muted-foreground hover:text-foreground",d?"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:()=>i(m.id),"aria-label":`Dismiss ${m.type} event`,title:"Dismiss event",children:f.jsx(Y0,{className:d?"h-2.5 w-2.5":"h-3 w-3"})})]})]}),f.jsx("div",{className:"text-[9px] leading-snug text-foreground/85",children:n1(m,o)})]})},m.id)})})})}const y3=["node.","election.","transport."],b3="cluster.state";function x3(n){return n.type==="node.status"?!1:y3.some(l=>n.type.startsWith(l))}function S3(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function w3(n,l){return n?{time:S3(n.timestamp),text:n1(n,l)}:null}function E3(n){return n.transportType==="devtunnel"||!!n.devtunnelEndpoint}function N3(n){if(n.length===0)return"No node tunnel";const l=n.filter(c=>c.status==="offline").length;if(l>0)return`${l} offline`;const o=n.filter(c=>{var d;return((d=c.devtunnelHealth)==null?void 0:d.status)==="failed"}).length;if(o>0)return`${o} failed`;const i=n.filter(c=>{var d;return c.status!=="offline"&&((d=c.devtunnelHealth)==null?void 0:d.status)!=="healthy"}).length;return i>0?`${i} checking`:"Healthy"}function T3(n,l){var c;const o=(l==null?void 0:l.get(n.id))??n.name??n.id;if(n.status==="offline")return{label:o,status:"offline"};const i=((c=n.devtunnelHealth)==null?void 0:c.status)??"checking";return{label:o,status:i}}function C3(n){if(n.length===0)return"No nodes";const l=n.filter(i=>i.status==="offline").length;if(l>0)return`${l} offline`;const o=n.filter(i=>i.status==="busy").length;return o>0?`${o} busy`:"Healthy"}function A3(n,l){return{label:(l==null?void 0:l.get(n.id))??n.name??n.id,status:n.status}}function R3({connected:n,events:l,nodes:o=[],currentNode:i=null,nodeNameById:c,desktopUpdate:d=null,defaultOpen:m=!1,defaultActionMenuOpen:h=!1,onDesktopUpdate:y,onDesktopRestart:p,onReload:x,onRestart:g}){const[w,N]=v.useState(m),[T,E]=v.useState(h),[C,A]=v.useState(!0),[j,O]=v.useState(new Set),[z,B]=v.useState(!1),[G,$]=v.useState(!1),V=v.useRef(null),ne=v.useRef(null),le=v.useMemo(()=>l.filter(Ne=>x3(Ne)&&!j.has(Ne.id)),[l,j]),fe=v.useMemo(()=>l.find(Ne=>Ne.type===b3)??le[0],[l,le]),me=v.useMemo(()=>w3(fe,c),[fe,c]),ie=v.useMemo(()=>{const Ne=new Map(o.map(Xe=>[Xe.id,Xe]));return i&&Ne.set(i.id,i),Array.from(Ne.values())},[i,o]),ue=v.useMemo(()=>ie.filter(E3),[ie]),oe=ue.some(Ne=>{var Xe;return Ne.status==="offline"||((Xe=Ne.devtunnelHealth)==null?void 0:Xe.status)==="failed"}),M=ie.some(Ne=>Ne.status==="offline"),Y=ie.some(Ne=>Ne.status==="busy"),I=ie.length>0,de=(i==null?void 0:i.name)??"offline",F=(i==null?void 0:i.role)==="leader"?"Leader":(i==null?void 0:i.role)==="follower"?"Follower":"Node",R=d!==null,P=!!(R&&(d!=null&&d.updateAvailable)&&d.latestVersion),K=(d==null?void 0:d.latestVersion)??null,W=!!(R&&!P&&!K&&(d!=null&&d.detail)),te=z?"Relaunching runtime...":"Relaunch to apply update",se=G?"Downloading and installing desktop update...":P&&K?`Available version ${K}`:W?(d==null?void 0:d.detail)??"Desktop update unavailable":"Desktop is current",ee=!!x,ce=!!(R&&p),J=ee||ce,ve=R||!!g,be=R||!!g||ee,Se=ve?R?"Update":"Relaunch":"Reload",He=ve?R?se:te:"Reload dashboard page",je=ve?R?G:z:!1,Ve=ve?R?je||!P||!y:je:!1,dt=R?P&&K?`Install desktop update ${K}`:W?"Desktop update unavailable":"Desktop is current":ve?z?"Relaunching runtime":"Relaunch runtime":"Reload dashboard page";function Pe(){ne.current&&(clearTimeout(ne.current),ne.current=null)}function Lt(){Pe(),N(!0)}function ht(){Pe(),ne.current=setTimeout(()=>{N(!1),ne.current=null},180)}function ol(){Pe()}function il(){Pe(),E(!1),N(!1)}async function Tt(){if(!(!g||z)){B(!0);try{await g()}finally{B(!1)}}}async function jn(){if(!(!P||!y||G)){$(!0);try{await y()}finally{$(!1)}}}async function Ct(){if(!(!p||z)){E(!1),B(!0);try{await p()}finally{B(!1)}}}async function Ll(){if(!ve){await Mn();return}if(R){await jn();return}await Tt()}async function Mn(){x&&(E(!1),await x())}return v.useEffect(()=>()=>{Pe()},[]),v.useEffect(()=>{O(Ne=>{if(Ne.size===0)return Ne;const Xe=new Set(l.map(st=>st.id)),We=new Set(Array.from(Ne).filter(st=>Xe.has(st)));return We.size===Ne.size?Ne:We})},[l]),v.useEffect(()=>{w||E(!1)},[w]),v.useEffect(()=>{if(!w)return;const Ne=We=>{var st;(st=V.current)!=null&&st.contains(We.target)||(Pe(),E(!1),N(!1))},Xe=We=>{We.key==="Escape"&&(Pe(),E(!1),N(!1))};return document.addEventListener("pointerdown",Ne),document.addEventListener("keydown",Xe),()=>{document.removeEventListener("pointerdown",Ne),document.removeEventListener("keydown",Xe)}},[w]),f.jsxs("div",{ref:V,className:"relative",children:[f.jsxs("button",{type:"button","aria-label":n?"Cluster link connected":"Cluster link reconnecting","aria-expanded":w,"aria-haspopup":"dialog",onClick:()=>N(Ne=>!Ne),onMouseEnter:Lt,onMouseLeave:ht,className:re("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",w&&(n?"bg-muted/60 text-foreground":"bg-destructive/12")),title:n?"Cluster link connected":"Cluster link reconnecting",children:[f.jsxs("span",{className:re("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:re("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:de}),f.jsx("span",{className:re("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:F})]})]}),w&&f.jsxs("div",{role:"dialog","aria-label":"Live link connection events",onMouseEnter:ol,onMouseLeave:il,className:"absolute right-0 top-[calc(100%+0.4rem)] z-50 w-[18rem] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-lg border border-border/70 bg-background/96 shadow-[0_28px_90px_-42px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl 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(Ds,{className:"h-3 w-3 text-emerald-500"}):f.jsx(UN,{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:re("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"}),me?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mt-0.5 truncate text-[9px] leading-snug text-foreground/80",children:me.text}),f.jsx("div",{className:"font-mono text-[8px] text-muted-foreground/60",children:me.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:[M?f.jsx(hs,{className:"h-3 w-3 shrink-0 text-destructive"}):Y?f.jsx(Ds,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Yo,{className:re("h-3 w-3 shrink-0",I?"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:re("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",M?"border-destructive/30 bg-destructive/10 text-destructive":Y?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":I?"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:C3(ie)})]}),ie.length>0&&f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:ie.map(Ne=>{const{label:Xe,status:We}=A3(Ne,c),st=We==="offline",On=We==="busy";return f.jsxs("div",{"aria-label":`${Xe} ${We}`,className:re("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",st?"bg-destructive/6":On?"bg-amber-500/6":"bg-emerald-500/5"),title:`${Xe} ${We}`,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),st?f.jsx(hs,{className:"h-3 w-3 shrink-0 text-destructive"}):On?f.jsx(vv,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Yo,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},Ne.id)})})]}),ue.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:[oe?f.jsx(hs,{className:"h-3 w-3 shrink-0 text-destructive"}):f.jsx(Yo,{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:re("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",oe?"border-destructive/30 bg-destructive/10 text-destructive":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:N3(ue)})]}),f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:ue.map(Ne=>{var kn;const{label:Xe,status:We}=T3(Ne,c),st=We==="failed"||We==="offline",On=We!=="healthy"&&We!=="failed"&&We!=="offline",Dn=(kn=Ne.devtunnelHealth)!=null&&kn.reason?`${Xe} ${We}: ${Ne.devtunnelHealth.reason}`:`${Xe} ${We}`;return f.jsxs("div",{"aria-label":`${Xe} ${We}`,className:re("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",st?"bg-destructive/6":On?"bg-muted/30":"bg-emerald-500/5"),title:Dn,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),st?f.jsx(hs,{className:"h-3 w-3 shrink-0 text-destructive"}):On?f.jsx(vv,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(Yo,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},Ne.id)})})]}),f.jsxs("div",{children:[f.jsxs("button",{type:"button",onClick:()=>A(Ne=>!Ne),className:"flex w-full items-center justify-between px-2.5 py-1.5 text-left hover:bg-muted/30",children:[f.jsxs("span",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:["Notifications ",le.length>0&&`(${le.length})`]}),C?f.jsx(Ko,{className:"h-3 w-3 text-muted-foreground"}):f.jsx(ef,{className:"h-3 w-3 text-muted-foreground"})]}),C&&f.jsx("div",{className:"px-2 pb-2",children:f.jsx(v3,{events:le,maxHeight:"12rem",density:"compact",emptyTitle:"No connection events yet",emptyDescription:"Node, election, and system events will appear here.",nodeNameById:c,onDismiss:Ne=>O(Xe=>new Set(Xe).add(Ne))})})]}),R&&(d==null?void 0:d.detail)&&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:d.detail,children:d.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:be&&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(yn,{type:"button",variant:"ghost",size:"sm",className:re("h-5 rounded-none border-0 px-1.5 text-[9px] font-medium hover:text-foreground [&_svg]:size-2.5",P?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>void Ll(),disabled:Ve,"aria-label":dt,"aria-describedby":"live-link-restart-hint",title:He,children:[f.jsx(yv,{className:re("h-2.5 w-2.5",je&&"animate-pulse")}),f.jsx("span",{children:Se})]}),J&&f.jsx(yn,{type:"button",variant:"ghost",size:"sm",className:re("h-5 rounded-none border-l border-border/50 px-1 text-[9px] hover:text-foreground [&_svg]:size-2.5",P?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>E(Ne=>!Ne),"aria-label":"Open live link actions","aria-expanded":T,title:"Live link actions",children:f.jsx(Ko,{className:"h-2.5 w-2.5"})})]}),J&&T&&f.jsxs("div",{className:"absolute bottom-[calc(100%+0.25rem)] left-0 z-20 min-w-28 overflow-hidden rounded-md border border-border/70 bg-background text-[9px] shadow-lg",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:()=>void Ll(),disabled:Ve,"aria-label":dt,children:[f.jsx(yv,{className:re("h-2.5 w-2.5",je&&"animate-pulse")}),f.jsx("span",{children:Se})]}),ce&&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:()=>void Ct(),disabled:z,"aria-label":"Restart Meshy Desktop",children:[f.jsx(tf,{className:re("h-2.5 w-2.5",z&&"animate-spin")}),f.jsx("span",{children:"Restart"})]}),ee&&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:()=>void Mn(),"aria-label":"Reload dashboard page",children:[f.jsx(tf,{className:"h-2.5 w-2.5"}),f.jsx("span",{children:"Reload"})]})]}),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:He})]})}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(yn,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>O(new Set(l.map(Ne=>Ne.id))),disabled:le.length===0,title:"Dismiss all notifications",children:"Dismiss all"}),f.jsx(yn,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>N(!1),children:"Close"})]})]})]})]})}const a0="dark",Lr="fluent",_3="clean",Kd="meshy-layout-default-migrated-to-compact",yf="true",j3="compact",M3=new Set(["airy","clean","fluent"]);function O3(n){return n!==null&&M3.has(n)}function lm(n){return n===j3?"fluent":O3(n)?n:null}function D3(n,l){const o=lm(n);return o===_3&&l!==yf?Lr:o??Lr}const Fs="symphony",a1="default",k3=new Set(["light","dark","system"]),z3=new Set(["porcelain","warm","finsight","edge","symphony","launcher"]),l1=v.createContext(null);function L3(n){const l=new URLSearchParams(n).get("theme");return r1(l)?l:null}function U3(n){const l=new URLSearchParams(n).get("palette");return rm(l)}function B3(n){const l=new URLSearchParams(n).get("layout");return lm(l)}function H3(){if(typeof document>"u")return null;const n=document.documentElement;return{theme:n.classList.contains("dark")?"dark":"light",palette:rm(n.getAttribute("data-palette"))??Fs,layout:lm(n.getAttribute("data-layout"))??Lr}}function SM(n,l=H3()){if(!l)return n;try{const o=/^[a-z][a-z\d+\-.]*:/i.test(n),i=typeof window<"u"?window.location.href:"http://localhost",c=new URL(n,i);return c.searchParams.set("theme",l.theme),c.searchParams.set("palette",l.palette),c.searchParams.set("layout",l.layout),o?c.toString():`${c.pathname}${c.search}${c.hash}`}catch{return n}}function V3({children:n}){const[l,o]=v.useState(()=>typeof window<"u"?L3(window.location.search)??q3(localStorage.getItem("meshy-theme"))??a0:a0),[i,c]=v.useState(()=>typeof window<"u"?U3(window.location.search)??G3(localStorage.getItem("meshy-palette"))??Fs:Fs),[d,m]=v.useState(()=>{if(typeof window<"u"){const h=B3(window.location.search);if(h)return localStorage.setItem(Kd,yf),h;const y=D3(localStorage.getItem("meshy-layout"),localStorage.getItem(Kd));return localStorage.setItem(Kd,yf),y}return Lr});return v.useEffect(()=>{const h=document.documentElement,y=p=>{if(p==="system"){const x=window.matchMedia("(prefers-color-scheme: dark)").matches;h.classList.toggle("dark",x)}else h.classList.toggle("dark",p==="dark")};if(y(l),localStorage.setItem("meshy-theme",l),l==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)"),x=()=>y("system");return p.addEventListener("change",x),()=>p.removeEventListener("change",x)}},[l]),v.useEffect(()=>{document.documentElement.setAttribute("data-palette",i),localStorage.setItem("meshy-palette",i)},[i]),v.useEffect(()=>{const h=document.documentElement;d===Lr?h.removeAttribute("data-layout"):h.setAttribute("data-layout",d),localStorage.setItem("meshy-layout",d)},[d]),f.jsx(l1.Provider,{value:{theme:l,setTheme:o,palette:i,setPalette:c,layout:d,setLayout:m},children:n})}function $3(){const n=v.useContext(l1);if(!n)throw new Error("useTheme must be used within ThemeProvider");return n}function r1(n){return n!==null&&k3.has(n)}function Y3(n){return n!==null&&z3.has(n)}function q3(n){return r1(n)?n:null}function rm(n){return n===a1?"porcelain":Y3(n)?n:null}function G3(n){return n===a1?null:rm(n)}const P3=[{value:"light",label:"Light",icon:V0},{value:"dark",label:"Dark",icon:B0},{value:"system",label:"System",icon:U0}],o1=[{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"}],i1=[{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 X3(){const{theme:n,setTheme:l,palette:o,setPalette:i,layout:c,setLayout:d}=$3(),[m,h]=v.useState(!1),y=v.useRef(null),p=v.useRef(null),x=n==="dark"?B0:n==="light"?V0:U0,g=()=>{y.current&&(clearTimeout(y.current),y.current=null)},w=()=>{g(),y.current=setTimeout(()=>h(!1),180)};return v.useEffect(()=>{if(!m)return;const N=T=>{p.current&&!p.current.contains(T.target)&&h(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[m]),v.useEffect(()=>()=>g(),[]),f.jsxs("div",{ref:p,className:"relative",onMouseEnter:()=>{g(),h(!0)},onMouseLeave:w,children:[f.jsx(yn,{variant:"ghost",size:"icon",onClick:()=>h(N=>!N),className:re("h-8 w-8 rounded-sm",o!==Fs||c!==Lr?"text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),title:"Appearance","aria-haspopup":"menu","aria-expanded":m,children:f.jsx(x,{className:"h-4 w-4"})}),m&&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:[K3(c)," / ",Q3(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:P3.map(({value:N,label:T,icon:E})=>{const C=n===N;return f.jsxs("button",{type:"button",onClick:()=>l(N),role:"menuitemradio","aria-checked":C,className:re("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",C?"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(E,{className:"h-3 w-3"}),T]},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:i1.map(({value:N,label:T,hint:E})=>{const C=c===N;return f.jsxs("button",{type:"button",onClick:()=>d(N),role:"menuitemradio","aria-checked":C,className:re("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",C?"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:re("text-[10px] font-medium leading-tight",C?"text-primary":"text-foreground"),children:T}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:E})]}),C&&f.jsx(ks,{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(DN,{className:"h-2.5 w-2.5"}),"Palette"]}),f.jsx("div",{className:"space-y-1",children:o1.map(({value:N,label:T,hint:E})=>{const C=o===N;return f.jsxs("button",{type:"button",onClick:()=>i(N),role:"menuitemradio","aria-checked":C,className:re("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",C?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsx(Z3,{value:N}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:re("text-[10px] font-medium leading-tight",C?"text-primary":"text-foreground"),children:T}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:E})]}),C&&f.jsx(ks,{className:"h-3 w-3 text-primary"})]},N)})})]})]})]})]})}function K3(n){var l;return((l=i1.find(o=>o.value===n))==null?void 0:l.label)??n}function Q3(n){var l;return((l=o1.find(o=>o.value===n))==null?void 0:l.label)??n}function Z3({value:n}){const l={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,i,c]=l[n];return f.jsxs("div",{className:re("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:i}}),f.jsx("div",{className:"h-full w-1/3",style:{background:c}})]})}const Go={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}},s1="meshy-dashboard-panel-state-v2",c1="meshy-dashboard-terminal-open-v1";function wM({operationsOpen:n}){return{layout:{desktopTasksOpen:!0,operationsOpen:n},sizes:{tasks:Go.tasks.defaultSize,operations:Go.operations.defaultSize,terminal:Go.terminal.defaultSize}}}function Qd(n){return typeof n=="object"&&n!==null}function l0(n,l){return typeof n=="boolean"?n:l}function Zd(n,l,o){return typeof l=="number"&&Number.isFinite(l)?Po(n,l):o}function Po(n,l){const o=Go[n];return Math.min(o.max,Math.max(o.min,l))}function EM(n,l){if(!n)return l;try{const o=n.getItem(s1);if(!o)return l;const i=JSON.parse(o);if(!Qd(i))return l;const c=Qd(i.layout)?i.layout:{},d=Qd(i.sizes)?i.sizes:{};return{layout:{desktopTasksOpen:l0(c.desktopTasksOpen,l.layout.desktopTasksOpen),operationsOpen:l0(c.operationsOpen,l.layout.operationsOpen)},sizes:{tasks:Zd("tasks",d.tasks,l.sizes.tasks),operations:Zd("operations",d.operations,l.sizes.operations),terminal:Zd("terminal",d.terminal,l.sizes.terminal)}}}catch{return l}}function NM(n,l){if(n)try{n.setItem(s1,JSON.stringify(l))}catch{}}function I3(n,l){if(!n)return l;try{const o=n.getItem(c1);return o==="true"?!0:o==="false"?!1:l}catch{return l}}function F3(n,l){if(n)try{n.setItem(c1,String(l))}catch{}}function r0(){var n;try{return((n=globalThis.window)==null?void 0:n.localStorage)??globalThis.localStorage??null}catch{return null}}function TM(n){return`${Number(n.toFixed(2))}rem`}function CM(n,l,o,i,c,d,m){const h=Number.isFinite(m)&&m>0?m:16;return n==="tasks"?Po(n,l+(c-o)/h):n==="operations"?Po(n,l+(o-c)/h):Po(n,l+(i-d)/h)}function AM(n,l,o){const i=o===0?0:o>0?-1:1;return Po(n,l+i*Go[n].wheelStep)}const J3=7200*1e3;function W3(){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 Ns(){var n,l;return typeof window>"u"?null:((l=(n=window.__TAURI__)==null?void 0:n.core)==null?void 0:l.invoke)??null}function o0(n){return{currentVersion:null,latestVersion:null,updateAvailable:!1,checkedAt:new Date().toISOString(),releaseUrl:null,assetName:null,installable:!1,detail:n}}function Id(n,l){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 l}function ej(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 tj(){const{cluster:n,events:l,sseConnected:o,systemInfo:i}=k0(),c=Fn(),[d,m]=v.useState(()=>I3(r0(),!1)),[h,y]=v.useState(""),[p,x]=v.useState(null),[g,w]=v.useState(null),N=!!Ns(),T=N?"max-w-none":"max-w-[1760px]",E=c.pathname==="/"||/^\/tasks\/[^/]+$/.test(c.pathname),C=v.useMemo(()=>{const B=new Map;for(const G of(n==null?void 0:n.nodes)??[])B.set(G.id,G.name);return n!=null&&n.self&&B.set(n.self.id,n.self.name),B},[n==null?void 0:n.nodes,n==null?void 0:n.self]),A=v.useCallback(B=>{m(G=>typeof B=="function"?B(G):B)},[]);v.useEffect(()=>{F3(r0(),d)},[d]),v.useEffect(()=>{const B=Ns();if(!B){w(null);return}let G=!1,$=!1;const V=le=>{$||($=!0,le&&w(o0("Checking desktop update...")),B("check_desktop_update").then(fe=>{G||w(fe)}).catch(fe=>{if(!G){const me=Id(fe,"Desktop update check failed");w(ie=>ie!=null&&ie.updateAvailable?ie:o0(me))}}).finally(()=>{$=!1}))};V(!0);const ne=window.setInterval(()=>V(!1),J3);return()=>{G=!0,window.clearInterval(ne)}},[i==null?void 0:i.version]);async function j(){try{const B=await O0({reason:"restart"});Ge.info(`Restarting runtime. Follow ${B.logPath} for launch output.`),await e1({previousPid:B.pid})||Ge.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout.")}catch(B){Ge.error(B instanceof Error?B.message:"Runtime restart failed")}}async function O(){const B=Ns();if(!B){Ge.error("Desktop updater is not available in this window");return}try{Ge.info("Downloading desktop update...");const G=await B("install_desktop_update");Ge.info(ej(G))}catch(G){Ge.error(Id(G,"Desktop update failed"))}}async function z(){const B=Ns();if(!B){Ge.error("Desktop restart is not available in this window");return}try{Ge.info("Restarting Meshy Desktop..."),await B("restart_desktop_app")}catch(G){Ge.error(Id(G,"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:"relative z-50 shrink-0 px-2 py-2",children:f.jsxs("div",{className:re("dashboard-panel dashboard-panel-muted animate-panel-settle mx-auto flex items-center gap-0 rounded-lg px-3 py-2",T),children:[f.jsx("div",{className:"flex shrink-0 items-center gap-3 pr-3",children:f.jsxs(Wd,{to:"/","aria-label":"Meshy home",className:"flex items-center gap-2",children:[f.jsx(W3,{}),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"}),E&&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:()=>y(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(H0,{className:"h-3 w-3 shrink-0 text-primary/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.nodeName})]}),f.jsx(ef,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsxs("button",{type:"button",onClick:()=>y(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(fN,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.projectLabel})]}),f.jsx(ef,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsx(Wd,{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(CN,{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(am,{"aria-label":"Search tasks",value:h,onChange:B=>y(B.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:[E&&f.jsx(yn,{variant:"ghost",size:"icon",onClick:()=>A(B=>!B),"aria-label":d?"Close terminal":"Open terminal",title:d?"Close terminal":"Open terminal",className:re("h-8 w-8 rounded-sm text-muted-foreground hover:bg-muted/50 hover:text-foreground",d&&"bg-primary/8 text-primary"),children:f.jsx($0,{className:"h-4 w-4"})}),f.jsx(t3,{}),f.jsx(X3,{}),f.jsx("div",{className:"mx-0 h-4 w-px shrink-0 bg-border/50"}),f.jsx(R3,{connected:o,events:l,nodes:(n==null?void 0:n.nodes)??[],currentNode:(n==null?void 0:n.self)??null,nodeNameById:C,desktopUpdate:g,onDesktopUpdate:g!=null&&g.updateAvailable?O:void 0,onDesktopRestart:N?z:void 0,onReload:N?()=>window.location.reload():void 0,onRestart:j})]})]})}),f.jsx("main",{className:re("min-h-0 flex-1 px-2 pb-2",E?"overflow-hidden":"overflow-y-auto"),children:f.jsx("div",{className:re("mx-auto h-full min-h-0",T),children:f.jsx(_w,{context:{terminalOpen:d,setTerminalOpen:A,headerSearchQuery:h,setHeaderSearchQuery:y,setHeaderTaskContext:x}})})})]})]})}const i0=v.lazy(async()=>({default:(await u0(()=>import("./DashboardPage-SPgMQP8H.js").then(l=>l.D),__vite__mapDeps([0,1,2,3]))).DashboardPage})),nj=v.lazy(async()=>({default:(await u0(()=>import("./SharedConversationPage-Cd0hBNE_.js"),__vite__mapDeps([4,1]))).SharedConversationPage}));function aj(){return f.jsx(tE,{children:f.jsx(v.Suspense,{fallback:f.jsx(lj,{}),children:f.jsxs(Mw,{children:[f.jsx(jl,{path:"/shared/tasks/:shareId",element:f.jsx(nj,{})}),f.jsxs(jl,{element:f.jsx(kE,{children:f.jsx(tj,{})}),children:[f.jsx(jl,{path:"/",element:f.jsx(i0,{})}),f.jsx(jl,{path:"/nodes",element:f.jsx(hv,{to:"/",replace:!0})}),f.jsx(jl,{path:"/tasks",element:f.jsx(hv,{to:"/",replace:!0})}),f.jsx(jl,{path:"/tasks/:id",element:f.jsx(i0,{})})]})]})})})}function lj(){return f.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading workspace..."})}function rj(n){const l=n??(typeof window>"u"?void 0:window);l!=null&&l.__TAURI__&&l.addEventListener("contextmenu",o=>{o.preventDefault()})}function oj(n){return f.jsx(eC,{className:"toaster group",style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border))"},...n})}rj();j2.createRoot(document.getElementById("root")).render(f.jsx(v.StrictMode,{children:f.jsxs(V3,{children:[f.jsx(aj,{}),f.jsx(oj,{})]})}));export{Qs as $,Yy as A,yn as B,ks as C,aM as D,Gy as E,uN as F,SM as G,lN as H,am as I,i3 as J,o3 as K,L0 as L,t_ as M,eM as N,wx as O,tM as P,js as Q,St as R,H0 as S,lM as T,yM as U,qs as V,gf as W,Y0 as X,Gs as Y,Ps as Z,Ks as _,rC as a,mM as a$,Xs as a0,Is as a1,Zs as a2,u0 as a3,dj as a4,qy as a5,q5 as a6,Nj as a7,$0 as a8,Yo as a9,r0 as aA,NM as aB,AM as aC,TM as aD,CM as aE,Cj as aF,AE as aG,SE as aH,Fj as aI,Ij as aJ,jE as aK,kj as aL,pj as aM,mj as aN,Py as aO,hj as aP,gj as aQ,gE as aR,t3 as aS,zj as aT,Lj as aU,sj as aV,Fn as aW,S0 as aX,ij as aY,k0 as aZ,pM as a_,nN as aa,Ej as ab,Tj as ac,wj as ad,_N as ae,gN as af,hM as ag,wN as ah,v3 as ai,g_ as aj,sN as ak,v_ as al,bM as am,a3 as an,sM as ao,xM as ap,oM as aq,iM as ar,gM as as,Fx as at,vM as au,vf as av,Uj as aw,Bj as ax,EM as ay,wM as az,re as b,cM as b0,uM as b1,fM as b2,dM as b3,Aj as b4,rM as b5,l3 as b6,Oj as b7,Dj as b8,Mj as b9,jj as ba,uj as bb,fj as bc,cj as bd,vj as be,Wj as bf,qj as bg,Yj as bh,$j as bi,Hj as bj,Vj as bk,Gj as bl,n3 as bm,s0 as bn,FE as bo,Kj as bp,Xj as bq,Pj as br,tf as bs,Qj as bt,Jj as bu,Zj as bv,Be as c,ry as d,Sj as e,pE as f,bj as g,yj as h,fN as i,f as j,ef as k,jr as l,xj as m,_j as n,Wb as o,Jf as p,ex as q,v as r,Wf as s,Ge as t,CN as u,Ko as v,DN as w,nM as x,Rj as y,V5 as z};
316
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return v.useEffect(()=>{var i;document.getElementById((i=n.current)==null?void 0:i.getAttribute("aria-describedby"))||console.warn(l)},[l,n]),null},d_=Nx,f_=Tx,m_=Cx,Lx=Ax,Ux=Rx,Bx=Dx,Hx=zx,Vx=jx,$x=Ox;const gf=d_,vf=f_,h_=m_,Yx=v.forwardRef(({className:n,...l},o)=>f.jsx(Lx,{className:re("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),...l,ref:o}));Yx.displayName=Lx.displayName;const Gs=v.forwardRef(({className:n,...l},o)=>f.jsxs(h_,{children:[f.jsx(Yx,{}),f.jsx(Ux,{ref:o,className:re("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl border bg-background p-6 shadow-[0_34px_110px_-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),...l})]}));Gs.displayName=Ux.displayName;const Ps=({className:n,...l})=>f.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",n),...l});Ps.displayName="AlertDialogHeader";const Xs=({className:n,...l})=>f.jsx("div",{className:re("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...l});Xs.displayName="AlertDialogFooter";const Ks=v.forwardRef(({className:n,...l},o)=>f.jsx(Vx,{ref:o,className:re("text-lg font-semibold",n),...l}));Ks.displayName=Vx.displayName;const Qs=v.forwardRef(({className:n,...l},o)=>f.jsx($x,{ref:o,className:re("text-sm text-muted-foreground",n),...l}));Qs.displayName=$x.displayName;const Zs=v.forwardRef(({className:n,...l},o)=>f.jsx(Bx,{ref:o,className:re(jf(),n),...l}));Zs.displayName=Bx.displayName;const Is=v.forwardRef(({className:n,...l},o)=>f.jsx(Hx,{ref:o,className:re(jf({variant:"outline"}),"mt-2 sm:mt-0",n),...l}));Is.displayName=Hx.displayName;const p_={online:"bg-green-500",busy:"bg-yellow-500",offline:"bg-red-500"};function g_({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-green-500 opacity-30"}),f.jsx("span",{className:re("relative inline-flex h-2.5 w-2.5 rounded-full",p_[n])})]})}function v_({role:n,size:l="default"}){return f.jsx(St,{variant:n==="leader"?"default":"secondary",className:re(l==="compact"?"px-1.5 py-0 text-[9px] leading-4":"text-[11px]"),children:n})}const qx={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-red-200",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 Wj({status:n,size:l="default"}){const o=qx[n],i=l==="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(St,{variant:o.variant,className:re("rounded-sm font-medium shadow-none",i,o.className),children:[f.jsx("span",{className:re("rounded-full",o.dotClass)}),n]})}function eM({status:n,isNative:l=!1,size:o="default",className:i}){const c=qx[n],d=[n,l?"native":null].filter(Boolean).join(", "),m=o==="compact"?"h-1.5 w-1.5":"h-2 w-2";return f.jsxs("span",{className:re("inline-flex shrink-0 items-center gap-1",i),title:d,"aria-label":d,children:[f.jsx("span",{className:re("rounded-full",m,c.dotClass),title:n}),l&&f.jsx("span",{className:re("rounded-full bg-sky-500",m),title:"native"})]})}const y_={critical:{variant:"destructive",label:"Critical"},high:{variant:"outline",label:"High"},normal:{variant:"secondary",label:"Normal"},low:{variant:"secondary",label:"Low"}};function tM({priority:n}){const l=y_[n];return f.jsx(St,{variant:l.variant,className:"rounded-sm px-1.5 py-0 text-[10px] leading-4 shadow-none",children:l.label})}function b_(n){return[{key:"workspace",label:"Workspace",value:n==null?void 0:n.workspace},{key:"node",label:"Node app",value:n==null?void 0:n.node},{key:"core",label:"Core",value:n==null?void 0:n.core},{key:"dashboard",label:"Dashboard",value:n==null?void 0:n.dashboard},{key:"api",label:"API",value:n==null?void 0:n.api}].filter(o=>o.value)}function Ar({label:n,value:l,mono:o=!1}){return f.jsxs("div",{className:"min-w-0 rounded-lg 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:l})]})}function x_({formatDateTime:n,viewInfo:l}){var i,c,d,m,h,y,p,x;const o=b_(l.packages);return f.jsxs(qs,{value:"about","data-about-layout":"compact",className:"mt-0 space-y-2",children:[f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(qE,{className:"h-3.5 w-3.5 text-primary"}),"Repository & runtime"]}),f.jsx(Pn,{className:"text-[10px]",children:"Build source and runtime identity for this node."})]}),f.jsxs(Xn,{className:"space-y-2 px-3 pb-2.5",children:[(i=l.repository)!=null&&i.url?f.jsxs("a",{href:l.repository.url,target:"_blank",rel:"noreferrer",className:"group flex min-w-0 items-center justify-between gap-2 rounded-lg 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:l.repository.url}),f.jsx(sN,{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-lg 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(Ar,{label:"Branch",value:((c=l.repository)==null?void 0:c.branch)??"Unavailable",mono:!!((d=l.repository)!=null&&d.branch)}),f.jsx(Ar,{label:"Commit",value:((m=l.repository)==null?void 0:m.commit)??"Unavailable",mono:!!((h=l.repository)!=null&&h.commit)}),f.jsx(Ar,{label:"Runtime",value:`${l.packageName??"meshy"} ${l.version}`,mono:!0}),f.jsx(Ar,{label:"Node.js",value:((y=l.runtime)==null?void 0:y.nodeVersion)??"Unavailable",mono:!!((p=l.runtime)!=null&&p.nodeVersion)}),f.jsx(Ar,{label:"PID",value:l.runtime?String(l.runtime.pid):"Unavailable",mono:!!l.runtime}),f.jsx(Ar,{label:"Started",value:n((x=l.runtime)==null?void 0:x.startedAt)})]})]})]}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(hN,{className:"h-3.5 w-3.5 text-primary"}),"Package versions"]}),f.jsx(Pn,{className:"text-[10px]",children:"Version snapshot for the packages most relevant to this dashboard session."})]}),f.jsx(Xn,{"data-package-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:o.map(g=>{var w,N;return f.jsxs("div",{className:"grid gap-1.5 rounded-lg 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:g.label}),f.jsx("div",{className:"min-w-0 truncate text-[10px] text-muted-foreground",children:(w=g.value)==null?void 0:w.name}),f.jsx(St,{variant:"outline",className:"w-fit rounded-sm border-border/70 bg-background/60 font-mono text-[10px]",children:(N=g.value)==null?void 0:N.version})]},g.key)})})]})]})}var fc="Checkbox",[S_]=al(fc),[w_,tm]=S_(fc);function E_(n){const{__scopeCheckbox:l,checked:o,children:i,defaultChecked:c,disabled:d,form:m,name:h,onCheckedChange:y,required:p,value:x="on",internal_do_not_use_render:g}=n,[w,N]=kr({prop:o,defaultProp:c??!1,onChange:y,caller:fc}),[T,E]=v.useState(null),[C,A]=v.useState(null),j=v.useRef(!1),O=T?!!m||!!T.closest("form"):!0,z={checked:w,disabled:d,setChecked:N,control:T,setControl:E,name:h,form:m,value:x,hasConsumerStoppedPropagationRef:j,required:p,defaultChecked:Ja(c)?!1:c,isFormControl:O,bubbleInput:C,setBubbleInput:A};return f.jsx(w_,{scope:l,...z,children:N_(g)?g(z):i})}var Gx="CheckboxTrigger",Px=v.forwardRef(({__scopeCheckbox:n,onKeyDown:l,onClick:o,...i},c)=>{const{control:d,value:m,disabled:h,checked:y,required:p,setControl:x,setChecked:g,hasConsumerStoppedPropagationRef:w,isFormControl:N,bubbleInput:T}=tm(Gx,n),E=tt(c,x),C=v.useRef(y);return v.useEffect(()=>{const A=d==null?void 0:d.form;if(A){const j=()=>g(C.current);return A.addEventListener("reset",j),()=>A.removeEventListener("reset",j)}},[d,g]),f.jsx(Ue.button,{type:"button",role:"checkbox","aria-checked":Ja(y)?"mixed":y,"aria-required":p,"data-state":Ix(y),"data-disabled":h?"":void 0,disabled:h,value:m,...i,ref:E,onKeyDown:De(l,A=>{A.key==="Enter"&&A.preventDefault()}),onClick:De(o,A=>{g(j=>Ja(j)?!0:!j),T&&N&&(w.current=A.isPropagationStopped(),w.current||A.stopPropagation())})})});Px.displayName=Gx;var nm=v.forwardRef((n,l)=>{const{__scopeCheckbox:o,name:i,checked:c,defaultChecked:d,required:m,disabled:h,value:y,onCheckedChange:p,form:x,...g}=n;return f.jsx(E_,{__scopeCheckbox:o,checked:c,defaultChecked:d,disabled:h,required:m,onCheckedChange:p,name:i,form:x,value:y,internal_do_not_use_render:({isFormControl:w})=>f.jsxs(f.Fragment,{children:[f.jsx(Px,{...g,ref:l,__scopeCheckbox:o}),w&&f.jsx(Zx,{__scopeCheckbox:o})]})})});nm.displayName=fc;var Xx="CheckboxIndicator",Kx=v.forwardRef((n,l)=>{const{__scopeCheckbox:o,forceMount:i,...c}=n,d=tm(Xx,o);return f.jsx(Vr,{present:i||Ja(d.checked)||d.checked===!0,children:f.jsx(Ue.span,{"data-state":Ix(d.checked),"data-disabled":d.disabled?"":void 0,...c,ref:l,style:{pointerEvents:"none",...n.style}})})});Kx.displayName=Xx;var Qx="CheckboxBubbleInput",Zx=v.forwardRef(({__scopeCheckbox:n,...l},o)=>{const{control:i,hasConsumerStoppedPropagationRef:c,checked:d,defaultChecked:m,required:h,disabled:y,name:p,value:x,form:g,bubbleInput:w,setBubbleInput:N}=tm(Qx,n),T=tt(o,N),E=gb(d),C=rb(i);v.useEffect(()=>{const j=w;if(!j)return;const O=window.HTMLInputElement.prototype,B=Object.getOwnPropertyDescriptor(O,"checked").set,G=!c.current;if(E!==d&&B){const $=new Event("click",{bubbles:G});j.indeterminate=Ja(d),B.call(j,Ja(d)?!1:d),j.dispatchEvent($)}},[w,E,d,c]);const A=v.useRef(Ja(d)?!1:d);return f.jsx(Ue.input,{type:"checkbox","aria-hidden":!0,defaultChecked:m??A.current,required:h,disabled:y,name:p,value:x,form:g,...l,tabIndex:-1,ref:T,style:{...l.style,...C,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Zx.displayName=Qx;function N_(n){return typeof n=="function"}function Ja(n){return n==="indeterminate"}function Ix(n){return Ja(n)?"indeterminate":n?"checked":"unchecked"}const Fx=v.forwardRef(({className:n,...l},o)=>f.jsx(nm,{ref:o,className:re("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),...l,children:f.jsx(Kx,{className:re("flex items-center justify-center text-current"),children:f.jsx(ks,{className:"h-3.5 w-3.5"})})}));Fx.displayName=nm.displayName;const am=v.forwardRef(({className:n,type:l,...o},i)=>f.jsx("input",{type:l,className:re("flex h-10 w-full rounded-sm border border-input/85 bg-background/72 px-3 py-2 text-sm shadow-sm ring-offset-background transition-all duration-200 file:border-0 file:bg-transparent file:text-sm 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:i,...o}));am.displayName="Input";const e0=["queued","running"];function T_(n){return n.map(l=>`${l.id}:${l.name}`).join("\0")}function C_(n){return n==="claude"||n==="codex"||n==="copilot"}function Jx(n){var o;if(n.kind!=="agent.upgrade")return null;const l=(o=n.payload)==null?void 0:o.agent;return C_(l)?`${n.nodeId}:${l}`:null}function A_(n){return n.status==="succeeded"||n.status==="failed"}async function Wx(n,l={}){const o=l.getOperation??pE,i=l.pollIntervalMs??2e3,c=l.timeoutMs??24e4,d=Date.now()+c;let m=n;for(;!A_(m)&&Date.now()<d;)await __(i),m=await o(n.id);return m}async function R_(n,l=gE){const o=new Set(n),i=await Promise.all(e0.map(d=>l({kind:"agent.upgrade",status:d}))),c=new Map;for(const d of i.flat()){if(!e0.includes(d.status)||o.size>0&&!o.has(d.nodeId))continue;const m=Jx(d);if(!m)continue;const h=c.get(m);(!h||d.updatedAt>h.updatedAt)&&c.set(m,d)}return c}function __(n){return new Promise(l=>setTimeout(l,n))}const j_=1500,M_=1e3,O_=9e4;async function e1(n={}){const l=n.fetchHealth??D_,o=n.initialDelayMs??j_,i=n.pollIntervalMs??M_,c=n.previousPid,d=n.reload??(()=>window.location.reload()),m=n.sleep??z_,h=n.timeoutMs??O_,y=Date.now()+h;let p=!1;for(o>0&&await m(o);Date.now()<=y;){const x=k_(await l());if(!x.ok){p=!0,await m(i);continue}if(c===void 0||x.pid!==void 0&&x.pid!==c||p)return d(),!0;await m(i)}return!1}async function D_(){try{const n=await fetch("/api/system/health",{cache:"no-store"}),l=await n.json().catch(()=>null),o=l&&typeof l=="object"&&typeof l.pid=="number"?l.pid:void 0;return{ok:n.ok,pid:o}}catch{return!1}}function k_(n){return typeof n=="boolean"?{ok:n}:n}function z_(n){return new Promise(l=>window.setTimeout(l,n))}function L_(n,l=!0){return l?(n==null?void 0:n.restartMode)==="development"?"Restart dev runtime":n!=null&&n.updateAvailable?"Restart to update":"Restart runtime":n!=null&&n.updateAvailable?"Restart follower to update":"Restart follower"}function U_({checkedLabel:n,disableAuthDefault:l,endpoint:o,isLiveLocalNode:i,nodeId:c,nodeName:d,onRefresh:m,pid:h,transportType:y,update:p,workDir:x}){const g=L_(p,i),[w,N]=v.useState(null),[T,E]=v.useState(()=>t0({disableAuthDefault:l,endpoint:o,nodeName:d,transportType:y,workDir:x})),[C,A]=v.useState(!1),[j,O]=v.useState(!1),[z,B]=v.useState(!1);v.useEffect(()=>{E(t0({disableAuthDefault:l,endpoint:o,nodeName:d,transportType:y,workDir:x}))},[l,o,d,y,x]);async function G(){if(!c||C||j)return;const le=p.updateAvailable?"update":"restart",fe=V_(T);if(T.port.trim()&&(fe==null?void 0:fe.port)===void 0){Ge.error("Runtime restart port must be a positive integer");return}const me=fe?{reason:le,startArgs:fe}:{reason:le};A(!0);try{if(i){const M=await O0(me);N({...M,pid:M.pid??h,status:"accepted"}),Ge.info(`Restarting ${d} from a detached helper. PID ${M.pid??h??"unknown"} will not stay attached to the original terminal window; follow ${M.logPath} for launch output.`),e1({previousPid:M.pid??h}).then(Y=>{Y||(A(!1),Ge.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout. Refresh the page after the node finishes starting."))}).catch(Y=>{A(!1),Ge.error(Y instanceof Error?Y.message:"Runtime restart recovery failed")});return}const ie=await yE(c,me);N({operationId:ie.id,pid:h,status:ie.status}),Ge.info(`Restart requested on ${d}. Operation ${Xd(ie.id)} will hand off to a detached process, so the new runtime will not stay attached to the original terminal window.`);const ue=await Wx(ie,{timeoutMs:6e4}),oe=H_(ue);N({command:oe==null?void 0:oe.command,logPath:oe==null?void 0:oe.logPath,mode:oe==null?void 0:oe.mode,operationId:ue.id,pid:(oe==null?void 0:oe.pid)??h,status:ue.status}),ue.status==="succeeded"?(await(m==null?void 0:m()),Ge.success(`Restart handoff accepted on ${d}. Follow ${(oe==null?void 0:oe.logPath)??"the node restart log"} for launch output.`)):ue.status==="failed"?Ge.error(ue.error??`Restart failed on ${d}`):Ge.info(`Restart operation ${Xd(ue.id)} is still ${ue.status}. More details will update after the node reports back.`),A(!1)}catch(ie){A(!1),Ge.error(ie instanceof Error?ie.message:"Runtime restart failed")}}async function $(){if(!(!i||C||j)){O(!0);try{const le=await mE();Ge.info(`Stopping Meshy process ${le.pid}`)}catch(le){O(!1),Ge.error(le instanceof Error?le.message:"Runtime stop failed")}}}const V=C?"restarting":j?"stopping":(w==null?void 0:w.status)??"idle",ne=p.restartMode==="development";return f.jsxs("div",{className:"rounded-xl border border-border/70 bg-background/70 overflow-hidden",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(Ds,{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:ne?"Development launcher":`Latest ${p.latestVersion??"—"}`})]})]}),f.jsx("div",{className:"flex items-center gap-1.5",children:f.jsx(St,{variant:p.updateAvailable?"default":"outline",className:"rounded-full border-border/70 bg-background/60 font-mono text-[10px] px-2 py-0.5",children:ne?"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:V})]})]}),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:[i&&f.jsxs(gf,{children:[f.jsx(vf,{asChild:!0,children:f.jsxs(yn,{type:"button",size:"sm",variant:"ghost",disabled:C||j,className:"h-7 rounded-lg px-2 text-[11px] text-muted-foreground hover:text-destructive hover:bg-destructive/10",children:[f.jsx(xN,{className:re("mr-1 h-3.5 w-3.5",j&&"animate-pulse")}),j?"Stopping":"Stop"]})}),f.jsxs(Gs,{className:"max-w-[22rem] rounded-xl gap-2 p-4",children:[f.jsxs(Ps,{className:"space-y-1",children:[f.jsx(Ks,{className:"text-sm",children:"Stop runtime?"}),f.jsx(Qs,{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(Xs,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Is,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),f.jsx(Zs,{className:"h-7 rounded-lg px-2 text-[11px] bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>void $(),children:"Stop runtime"})]})]})]}),f.jsxs(gf,{children:[f.jsx(vf,{asChild:!0,children:f.jsxs(yn,{type:"button",size:"sm",variant:p.updateAvailable?"default":"outline",disabled:!c||C||j,className:"h-7 rounded-lg px-2 text-[11px]",children:[f.jsx(tf,{className:re("mr-1 h-3.5 w-3.5",C&&"animate-spin")}),C?"Restarting…":g]})}),f.jsxs(Gs,{className:"max-w-[28rem] gap-3 rounded-xl p-4",children:[f.jsxs(Ps,{className:"space-y-1",children:[f.jsxs(Ks,{className:"text-sm",children:[g,"?"]}),f.jsxs(Qs,{className:"text-[11px] leading-4",children:["Starts a detached restart helper, shuts down ",i?"the current node":d,", and brings it back with the configured launcher. The new process will not stay attached to the original terminal window."]})]}),f.jsx(B_,{value:T,onChange:E}),f.jsxs(Xs,{className:"gap-1 pt-0 sm:space-x-1",children:[f.jsx(Is,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),f.jsx(Zs,{className:"h-7 rounded-lg px-2 text-[11px]",onClick:()=>void G(),children:g})]})]})]})]})]}),f.jsxs("div",{className:"border-t border-border/50",children:[f.jsxs("button",{type:"button",onClick:()=>B(le=>!le),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($0,{className:"h-3 w-3"}),"Restart details"]}),f.jsx(Ko,{className:re("h-3 w-3 transition-transform duration-150",z&&"rotate-180")})]}),z&&f.jsxs("div",{className:"border-t border-border/50 bg-muted/20 px-3 py-2 space-y-1",children:[f.jsx(_l,{label:"Current PID",value:h===void 0?"—":String(h),mono:h!==void 0}),f.jsx(_l,{label:"Restart PID",value:(w==null?void 0:w.pid)===void 0?"Pending":String(w.pid),mono:(w==null?void 0:w.pid)!==void 0}),f.jsx(_l,{label:"Operation",value:w!=null&&w.operationId?Xd(w.operationId):"Local direct request",mono:!!(w!=null&&w.operationId)}),f.jsx(_l,{label:"Status",value:(w==null?void 0:w.status)??(C?"requested":"idle")}),f.jsx(_l,{label:"Launcher",value:(w==null?void 0:w.command)??"Available after restart",mono:!!(w!=null&&w.command)}),f.jsx(_l,{label:"Log",value:(w==null?void 0:w.logPath)??"Available after restart",mono:!!(w!=null&&w.logPath)}),f.jsx(_l,{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 B_({onChange:n,value:l}){const o=(i,c)=>{n({...l,[i]: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(Ho,{label:"HTTP port",value:l.port,onChange:i=>o("port",i),inputMode:"numeric"}),f.jsx(Ho,{label:"Node name",value:l.name,onChange:i=>o("name",i)}),f.jsx(Ho,{label:"Join endpoint",value:l.join,onChange:i=>o("join",i),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(Wb,{value:l.transport,onValueChange:i=>o("transport",t1(i)),children:[f.jsx(Jf,{className:"h-7 rounded-md border-border/70 bg-background/70 px-2 text-[10px]",children:f.jsx(ex,{placeholder:"Transport"})}),f.jsxs(Wf,{children:[f.jsx(jr,{className:"py-1 text-[11px]",value:"inherit",children:"current / default"}),f.jsx(jr,{className:"py-1 text-[11px]",value:"direct",children:"direct"}),f.jsx(jr,{className:"py-1 text-[11px]",value:"devtunnel",children:"devtunnel"}),f.jsx(jr,{className:"py-1 text-[11px]",value:"tailscale",children:"tailscale"})]})]})]}),f.jsx(Ho,{label:"Working directory",value:l.workDir,onChange:i=>o("workDir",i)}),f.jsx(Ho,{label:"Config path",value:l.config,onChange:i=>o("config",i),className:"sm:col-span-2"}),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(Fx,{className:"h-3.5 w-3.5",checked:l.disableAuth,onCheckedChange:i=>n({...l,disableAuth:i===!0,disableAuthKnown:!0})}),"Disable auth"]})]})]})}function Ho({className:n,inputMode:l,label:o,onChange:i,value:c}){return f.jsxs("label",{className:re("space-y-1",n),children:[f.jsx("span",{className:"text-[9px] uppercase tracking-[0.14em] text-muted-foreground",children:o}),f.jsx(am,{className:"h-7 rounded-md px-2 text-[10px]",inputMode:l,value:c,onChange:d=>i(d.target.value)})]})}function _l({label:n,value:l,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:re("break-all text-right text-foreground",o&&"font-mono"),children:l})]})}function H_(n){const l=n.result;if(!l||typeof l!="object")return null;const o=l;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 t0(n){return{port:$_(n.endpoint),name:n.nodeName,join:"",transport:t1(n.transportType),workDir:n.workDir??"",config:"",disableAuth:n.disableAuthDefault===!0,disableAuthKnown:n.disableAuthDefault!==void 0}}function V_(n){const l={},o=Number(n.port.trim());return n.port.trim()&&Number.isInteger(o)&&o>0&&(l.port=o),n.name.trim()&&(l.name=n.name.trim()),n.join.trim()&&(l.join=n.join.trim()),n.transport!=="inherit"&&(l.transport=n.transport),n.workDir.trim()&&(l.workDir=n.workDir.trim()),n.config.trim()&&(l.config=n.config.trim()),n.disableAuthKnown&&(l.disableAuth=n.disableAuth),Object.keys(l).length>0?l:void 0}function t1(n){return n==="direct"||n==="devtunnel"||n==="tailscale"?n:"inherit"}function $_(n){if(!n)return"";try{return new URL(n).port||""}catch{return""}}function Xd(n){return n.length<=8?n:n.slice(0,8)}function Vo({formatDateTime:n,name:l,status:o,statusVariant:i}){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:l}),f.jsx("div",{className:"text-[10px] text-muted-foreground",children:n(o==null?void 0:o.checkedAt)})]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof(o==null?void 0:o.authenticated)=="boolean"&&f.jsx(St,{variant:o.authenticated?"default":"outline",className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:o.authenticated?"auth ok":"auth required"}),f.jsx(St,{variant:i(o==null?void 0:o.status),className:"rounded-full text-[10px] uppercase tracking-[0.14em]",children:(o==null?void 0:o.status)??"unknown"})]})]})}function Zt(n){if(n==null||n==="")return"Unavailable";const l=new Date(n);return Number.isNaN(l.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(l)}function Y_(n){const l=Math.max(0,Math.floor(n)),o=Math.floor(l/86400),i=Math.floor(l%86400/3600),c=Math.floor(l%3600/60);return o>0?`${o}d ${i}h`:i>0?`${i}h ${c}m`:`${c}m`}function n0(n){if(n==null||Number.isNaN(n))return"Unavailable";const l=["B","KB","MB","GB","TB"];let o=n,i=0;for(;o>=1024&&i<l.length-1;)o/=1024,i+=1;return`${o.toFixed(o>=10||i===0?0:1)} ${l[i]}`}function _r(n){return n==="ok"?"default":n==="missing"||n==="install-failed"||n==="login-failed"?"destructive":n==="not-authenticated"||n==="unsupported-platform"?"outline":"secondary"}function q_(n){return n.available?f.jsxs(St,{className:"gap-1 rounded-full px-2 py-0.5 text-[10px]",children:[f.jsx(Yo,{className:"h-3 w-3"}),"Available"]}):f.jsxs(St,{variant:"destructive",className:"gap-1 rounded-full px-2 py-0.5 text-[10px]",children:[f.jsx(nN,{className:"h-3 w-3"}),"Unavailable"]})}function G_(n){return n.update?n.update.updateAvailable?f.jsxs(St,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:["Update ",n.update.latestVersion]}):f.jsx(St,{variant:"secondary",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:"Up to date"}):null}function P_(n){return n.available?null:n.metadataStatus??null}function X_(n){var o;const l=`npm install -g ${(o=n.update)==null?void 0:o.packageName}@latest`;return n.id==="claude"?`${l} --include=optional --ignore-scripts=false`:l}function K_(n){if(n.error)return n.error;const l=n.result;return(l==null?void 0:l.detail)??null}function et({label:n,value:l,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:re("break-all text-right text-[11px] text-foreground",o&&"font-mono text-[11px]"),children:l})]})}function $o({label:n,value:l,mono:o=!1,className:i}){return f.jsxs("div",{className:re("min-w-0 space-y-0.5",i),children:[f.jsx("div",{className:"text-[9px] uppercase tracking-[0.16em] text-muted-foreground",children:n}),f.jsx("div",{className:re("truncate text-[11px] text-foreground",o&&"font-mono",n==="Path"&&"break-all whitespace-normal"),children:l})]})}function Q_({agent:n,nodeName:l,activeOperation:o,onUpgrade:i}){var y,p;const c=((y=n.update)==null?void 0:y.updateAvailable)===!0,d=G_(n),m=!!o,h=P_(n);return f.jsxs("div",{className:"rounded-lg 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(L0,{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:[q_(n),h&&f.jsx(St,{variant:_r(h),className:"rounded-full px-2 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($o,{label:"Version",value:n.version??"Unavailable",mono:!!n.version}),n.update&&f.jsx($o,{label:"Latest",value:n.update.latestVersion??"Unavailable",mono:!!n.update.latestVersion}),f.jsx($o,{label:"Checked",value:Zt(n.checkedAt)}),n.update&&f.jsx($o,{label:"Update check",value:Zt(n.update.checkedAt)}),f.jsx($o,{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(St,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.14em]",children:["Upgrade ",o.status]}):c?f.jsxs(gf,{children:[f.jsx(vf,{asChild:!0,children:f.jsx("button",{type:"button",disabled:m,className:"rounded-full transition duration-150 hover:-translate-y-0.5 hover:scale-[1.03] hover:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 focus-visible:ring-offset-2 active:translate-y-0 active:scale-95 disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:translate-y-0 disabled:hover:scale-100 disabled:hover:shadow-none",children:d})}),f.jsxs(Gs,{children:[f.jsxs(Ps,{children:[f.jsxs(Ks,{children:["Upgrade ",n.label,"?"]}),f.jsxs(Qs,{children:["This runs ",X_(n)," on ",l,". Remote nodes execute the command on the remote machine."]})]}),f.jsxs(Xs,{children:[f.jsx(Is,{children:"Cancel"}),f.jsx(Zs,{onClick:()=>i(n),children:"Upgrade"})]})]})]}):d})]}),((p=n.update)==null?void 0:p.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 Z_(n,l){var o;return(o=n==null?void 0:n.nodes)!=null&&o.length?n.nodes:l?[l]:[]}function I_(n,l){var i;if(l&&n.id===l.nodeId)return l;const o=n.settingsSnapshot;return{...n,nodeId:n.id,version:(o==null?void 0:o.version)??"Unavailable",packageName:o==null?void 0:o.packageName,uptime:(o==null?void 0:o.uptime)??0,localDashboardOrigin:((i=o==null?void 0:o.runtime)==null?void 0:i.localDashboardOrigin)??void 0,auth:o==null?void 0:o.auth,os:o==null?void 0:o.os,runtime:o==null?void 0:o.runtime,runtimeUpdate:o==null?void 0:o.runtimeUpdate,agents:o==null?void 0:o.agents,startupRequirements:o==null?void 0:o.startupRequirements,components:o==null?void 0:o.components,repository:o==null?void 0:o.repository,packages:o==null?void 0:o.packages}}function F_(n,l){return n.id===l?`${n.name} (this node)`:`${n.name} (${n.role})`}function J_(n){return n==="claude"?"Claude Code":n==="copilot"?"Copilot CLI":"Codex"}function W_(n){var o;const l=(o=n.payload)==null?void 0:o.agent;return l==="claude"||l==="codex"||l==="copilot"?l:null}function e3({cluster:n,systemInfo:l,sseConnected:o,initialSelectedNodeId:i,onRefresh:c}){var ne,le,fe,me,ie,ue,oe,M,Y,I,de,F,R,P,K,W,te,se,ee,ce;const d=v.useMemo(()=>Z_(n,l),[n,l]),[m,h]=v.useState(()=>{var J;return i??(l==null?void 0:l.nodeId)??((J=n==null?void 0:n.self)==null?void 0:J.id)??""}),[y,p]=v.useState(()=>new Map),x=v.useRef(new Set),g=v.useRef(new Set),w=(n==null?void 0:n.self)??l??d[0]??null,N=d.find(J=>J.id===m)??w,T=N?I_(N,l):null,E=!!(l&&N&&N.id===l.nodeId),C=E||!!(N!=null&&N.settingsSnapshot),A=T==null?void 0:T.runtimeUpdate,j=((ne=T==null?void 0:T.startupRequirements)==null?void 0:ne.components)??(T==null?void 0:T.components)??{},O=v.useMemo(()=>d.map(J=>J.id),[d]),z=O.join("\0"),B=T_(d),G=v.useMemo(()=>new Map(d.map(J=>[J.id,J.name])),[B]);v.useEffect(()=>{i&&O.includes(i)&&h(i)},[i,z]);const $=v.useCallback(async(J,ve)=>{const be=Jx(J);if(!be||x.current.has(J.id))return;const Se=W_(J),He=(ve==null?void 0:ve.agentLabel)??(Se?J_(Se):"Agent"),je=(ve==null?void 0:ve.nodeName)??G.get(J.nodeId)??J.nodeId;x.current.add(J.id),p(Ve=>new Map(Ve).set(be,J));try{const Ve=await Wx(J);if(Ve.status==="succeeded")await(c==null?void 0:c()),g.current.has(Ve.id)||(Ge.success(`${He} upgrade finished on ${je}`),g.current.add(Ve.id));else if(Ve.status==="failed")g.current.has(Ve.id)||(Ge.error(K_(Ve)??`${He} upgrade failed`),g.current.add(Ve.id));else{p(dt=>new Map(dt).set(be,Ve)),Ge.info(`${He} upgrade is still ${Ve.status} on ${je}`);return}p(dt=>{const Pe=new Map(dt),Lt=Pe.get(be);return(!Lt||Lt.id===Ve.id)&&Pe.delete(be),Pe})}catch(Ve){p(dt=>{const Pe=new Map(dt),Lt=Pe.get(be);return(!Lt||Lt.id===J.id)&&Pe.delete(be),Pe}),Ge.error(Ve instanceof Error?Ve.message:`${He} upgrade failed`)}finally{x.current.delete(J.id)}},[c,G]);v.useEffect(()=>{if(O.length===0)return;let J=!1;async function ve(){let be;try{be=await R_(O)}catch{return}if(!J){p(Se=>{const He=new Map(Se);for(const[je,Ve]of be)He.set(je,Ve);return He});for(const Se of be.values())$(Se)}}return ve(),()=>{J=!0}},[$,z]);async function V(J){if(N)try{const ve=await vE(N.id,J.id);Ge.info(`${J.label} upgrade started on ${N.name}`),await $(ve,{agentLabel:J.label,nodeName:N.name})}catch(ve){Ge.error(ve instanceof Error?ve.message:`${J.label} upgrade failed`)}}return!N||!T?f.jsx("div",{className:"rounded-2xl border border-dashed border-border/70 bg-muted/20 px-4 py-8 text-center text-[12px] text-muted-foreground",children:"Loading session metadata..."}):f.jsxs("div",{className:"space-y-3",children:[f.jsxs("section",{className:"relative mt-2 rounded-2xl border border-border/70 bg-[radial-gradient(circle_at_top_left,rgba(59,130,246,0.18),transparent_42%),radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.12),transparent_32%),rgba(255,255,255,0.72)] p-3 shadow-[0_24px_90px_-54px_rgba(15,23,42,0.55)] dark:bg-[radial-gradient(circle_at_top_left,rgba(59,130,246,0.18),transparent_42%),radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.12),transparent_32%),rgba(10,15,23,0.78)]",children:[!E&&f.jsxs(St,{variant:"outline",className:"absolute right-3 top-2.5 rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em] whitespace-nowrap",children:["Updated ",Zt((le=N.settingsSnapshot)==null?void 0:le.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-full border border-border/70 bg-background/75 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur",children:[f.jsx(g_,{status:N.status}),f.jsx("span",{className:"font-medium text-foreground",children:N.name})]}),f.jsx(v_,{role:N.role}),f.jsx(St,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:N.transportType??T.transportType??"direct"}),f.jsx(St,{variant:E?"default":"outline",className:"rounded-full px-2 py-0.5 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."})]}),d.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(Wb,{value:N.id,onValueChange:h,children:[f.jsx(Jf,{className:"h-7 rounded-lg border-border/70 bg-background/70 text-[11px]",children:f.jsx(ex,{placeholder:"Choose a node"})}),f.jsx(Wf,{className:"settings-node-select-content rounded-lg text-[10px] leading-4",children:d.map(J=>f.jsx(jr,{value:J.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:F_(J,l==null?void 0:l.nodeId)},J.id))})]})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(St,{variant:o?"default":"outline",className:"gap-1 rounded-full px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:[f.jsx(wN,{className:"h-3 w-3"}),o?"Live link":"Reconnecting"]}),f.jsxs(St,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Uptime ",Y_(T.uptime)]})]})]})]}),!C&&f.jsx("div",{className:"rounded-xl 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(t_,{defaultValue:"session",className:"space-y-2",children:[f.jsxs(wx,{className:"h-auto flex-wrap rounded-xl border border-border/60 bg-muted/40 p-0.5",children:[f.jsx(js,{value:"session",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Session"}),f.jsx(js,{value:"access",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"Access"}),f.jsx(js,{value:"about",className:"rounded-md px-2.5 py-0.5 text-[11px]",children:"About"})]}),f.jsxs(qs,{value:"session",className:"mt-0 grid gap-2 xl:grid-cols-[1.15fr_0.85fr]",children:[f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(H0,{className:"h-3.5 w-3.5 text-primary"}),"Selected node"]}),f.jsx(Pn,{className:"text-[10px]",children:"Cluster role, identity, and node-scoped runtime state."})]}),f.jsxs(Xn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Node ID",value:T.nodeId,mono:!0}),f.jsx(et,{label:"Status",value:N.status}),f.jsx(et,{label:"Role",value:N.role}),f.jsx(et,{label:"Endpoint",value:N.endpoint,mono:!0}),f.jsx(et,{label:"Joined",value:Zt(N.joinedAt)}),f.jsx(et,{label:"Heartbeat",value:Zt(N.lastHeartbeat)}),f.jsx(et,{label:"Capabilities",value:N.capabilities.length>0?N.capabilities.join(", "):"None"})]})]}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(oN,{className:"h-3.5 w-3.5 text-primary"}),"OS info"]}),f.jsx(Pn,{className:"text-[10px]",children:"Host and resource details reported by the current process."})]}),f.jsxs(Xn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Host",value:((fe=T.os)==null?void 0:fe.hostname)??"Unavailable"}),f.jsx(et,{label:"Platform",value:T.os?`${T.os.platform} ${T.os.release}`:"Unavailable"}),f.jsx(et,{label:"Arch",value:((me=T.os)==null?void 0:me.arch)??"Unavailable"}),f.jsx(et,{label:"CPU",value:((ie=T.os)==null?void 0:ie.cpuModel)??"Unavailable"}),f.jsx(et,{label:"Cores",value:String(((ue=T.os)==null?void 0:ue.cpuCount)??"Unavailable")}),f.jsx(et,{label:"Memory",value:T.os?`${n0(T.os.freeMemoryBytes)} free / ${n0(T.os.totalMemoryBytes)} total`:"Unavailable"})]})]}),A&&f.jsx("div",{className:"xl:col-span-2",children:f.jsx(U_,{checkedLabel:Zt(A.checkedAt),disableAuthDefault:((oe=T.auth)==null?void 0:oe.enabled)===void 0?void 0:T.auth.enabled===!1,endpoint:N.endpoint,isLiveLocalNode:E,nodeId:N.id,nodeName:N.name,onRefresh:c,pid:(M=T.runtime)==null?void 0:M.pid,transportType:N.transportType,update:A,workDir:((Y=T.runtime)==null?void 0:Y.workDir)??N.workDir})}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)] xl:col-span-2",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(L0,{className:"h-3.5 w-3.5 text-primary"}),"Available agents"]}),f.jsx(Pn,{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(Xn,{"data-agent-layout":"list",className:"space-y-1.5 px-3 pb-2.5",children:(T.agents??[]).map(J=>f.jsx(Q_,{agent:J,nodeName:N.name,activeOperation:y.get(`${N.id}:${J.id}`),onUpgrade:V},J.id))})]})]}),f.jsxs(qs,{value:"access",className:"mt-0 grid gap-2 xl:grid-cols-2",children:[f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(XE,{className:"h-3.5 w-3.5 text-primary"}),"Access surface"]}),f.jsx(Pn,{className:"text-[10px]",children:"How this node is exposed to the dashboard and other peers."})]}),f.jsxs(Xn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Transport",value:N.transportType??T.transportType??"direct"}),f.jsx(et,{label:"Node URL",value:N.endpoint,mono:!0}),f.jsx(et,{label:"Node tunnel",value:N.devtunnelEndpoint??"Disabled",mono:!!N.devtunnelEndpoint}),f.jsx(et,{label:"Dashboard URL",value:N.dashboardOrigin??T.localDashboardOrigin??"Unavailable",mono:!!(N.dashboardOrigin||T.localDashboardOrigin)}),f.jsx(et,{label:"Local dashboard",value:T.localDashboardOrigin??"Unavailable",mono:!!T.localDashboardOrigin})]})]}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(MN,{className:"h-3.5 w-3.5 text-primary"}),"Auth"]}),f.jsx(Pn,{className:"text-[10px]",children:"Current bearer-auth and trusted access posture."})]}),f.jsxs(Xn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Enabled",value:(I=T.auth)!=null&&I.enabled?"Yes":"No"}),f.jsx(et,{label:"Same tenant",value:(de=T.auth)!=null&&de.allowSameTenant?"Allowed":"Off"}),f.jsx(et,{label:"Allowed users",value:(F=T.auth)!=null&&F.allowedUsers.length?T.auth.allowedUsers.join(", "):"None"})]})]}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(uN,{className:"h-3.5 w-3.5 text-primary"}),"Paths"]}),f.jsx(Pn,{className:"text-[10px]",children:"Workspace and runtime paths currently used by this node."})]}),f.jsxs(Xn,{className:"space-y-0 px-3 pb-2.5",children:[f.jsx(et,{label:"Work dir",value:((R=T.runtime)==null?void 0:R.workDir)??T.workDir??"Unavailable",mono:!!(((P=T.runtime)==null?void 0:P.workDir)??T.workDir)}),f.jsx(et,{label:"Storage",value:((K=T.runtime)==null?void 0:K.storagePath)??"Unavailable",mono:!!((W=T.runtime)!=null&&W.storagePath)}),f.jsx(et,{label:"Process cwd",value:((te=T.runtime)==null?void 0:te.cwd)??"Unavailable",mono:!!((se=T.runtime)!=null&&se.cwd)}),f.jsx(et,{label:"Started",value:Zt((ee=T.runtime)==null?void 0:ee.startedAt)}),f.jsx(et,{label:"PID",value:T.runtime?String(T.runtime.pid):"Unavailable",mono:!!T.runtime})]})]}),f.jsxs(Yn,{className:"rounded-xl border-border/70 bg-background/75 shadow-[0_24px_80px_-58px_rgba(15,23,42,0.45)]",children:[f.jsxs(qn,{className:"pb-1.5 pt-2.5 px-3",children:[f.jsxs(Gn,{className:"flex items-center gap-1.5 text-[12px]",children:[f.jsx(Ds,{className:"h-3.5 w-3.5 text-primary"}),"Startup checks"]}),f.jsx(Pn,{className:"text-[10px]",children:"Dependency preflight snapshot persisted during node startup."})]}),f.jsxs(Xn,{className:"space-y-3 px-3 pb-2.5",children:[f.jsxs("div",{className:"rounded-xl 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:Zt((ce=T.startupRequirements)==null?void 0:ce.lastCheckedAt)})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Vo,{formatDateTime:Zt,name:"Azure CLI",status:j.az,statusVariant:_r}),f.jsx(Vo,{formatDateTime:Zt,name:"DevTunnel",status:j.devtunnel,statusVariant:_r}),f.jsx(Vo,{formatDateTime:Zt,name:"Claude Code",status:j.claude,statusVariant:_r}),f.jsx(Vo,{formatDateTime:Zt,name:"Codex",status:j.codex,statusVariant:_r}),f.jsx(Vo,{formatDateTime:Zt,name:"Copilot CLI",status:j.copilot,statusVariant:_r})]})]})]})]}),f.jsx(x_,{formatDateTime:Zt,viewInfo:T})]})]})}function t3({initialSelectedNodeId:n,open:l,onOpenChange:o,showTrigger:i=!0}={}){const{cluster:c,systemInfo:d,sseConnected:m,refresh:h}=k0();return f.jsx(G5,{open:l,onOpenChange:o,showTrigger:i,children:f.jsx(e3,{cluster:c,systemInfo:d,sseConnected:m,initialSelectedNodeId:n,onRefresh:h})})}const nM="codex",aM="bypass",n3=[{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"}],lM=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],rM=new Set(n3.filter(n=>n.supportsFollowUp).map(n=>n.value)),oM=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"shared",label:"Shared"},{value:"archived",label:"Archived"}],iM=[{value:"all",label:"All task types"},{value:"native",label:"Native sessions"},{value:"meshy",label:"Meshy chats"}],a3=new Set(["pending","assigned"]),l3=new Set(["running"]),r3=new Set(["completed","failed","cancelled"]),sM=10;function cM(n,l){switch(l){case"running":return l3.has(n.status);case"waiting":return a3.has(n.status);case"closed":return r3.has(n.status);case"shared":return!!n.activeShare;case"archived":return n.status==="archived";case"active":default:return n.status!=="archived"}}function uM(n,l){if(l==="all")return!0;const o=n.conversationKind==="nativeSession";return l==="native"?o:!o}function dM(n,l){const o=l.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(i=>i.toLowerCase().includes(o)):!0}function o3(n,l,o){if(!n)return"unassigned";const i=l==null?void 0:l.find(c=>c.id===n);return(i==null?void 0:i.name)??o??n.slice(0,8)}function fM(n,l,o){return o3(n,l,o).toLowerCase()}function mM(n,l,o){return!n.assignedTo||(o==null?void 0:o.id)===n.assignedTo?!0:(l==null?void 0:l.some(i=>i.id===n.assignedTo))??!1}function hM(n,l){return[...n].sort((o,i)=>o.id===l?-1:i.id===l?1:o.name.localeCompare(i.name))}function pM(n){if(!n||typeof n!="object")return null;const l=n,o=l.createMode,i=o==="chat"||o==="native"?o:void 0,c=l.createDefaults,d=c&&typeof c=="object"&&!Array.isArray(c)?c:null,m=d?{assignTo:typeof d.assignTo=="string"||d.assignTo===null?d.assignTo:void 0,project:typeof d.project=="string"||d.project===null?d.project:void 0}:void 0;return{draftNewTask:l.draftNewTask===!0,returnRoute:typeof l.returnRoute=="string"?l.returnRoute:void 0,returnTaskId:typeof l.returnTaskId=="string"||l.returnTaskId===null?l.returnTaskId:void 0,createMode:i,createDefaults:m}}function gM(n){return n==="default workspace"?n:n.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??n}function vM(n){const l=Date.now()-n;return l<6e4?"just now":l<36e5?`${Math.floor(l/6e4)}m`:l<864e5?`${Math.floor(l/36e5)}h`:`${Math.floor(l/864e5)}d`}function yM(n){return new Date(n).toLocaleString()}function bM(n){const l=Math.floor(n/1e3),o=Math.floor(l/3600),i=Math.floor(l%3600/60),c=l%60;return`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}:${String(c).padStart(2,"0")}`}async function i3(n,l="Copied to clipboard"){var o,i,c;try{if((i=(o=globalThis.navigator)==null?void 0:o.clipboard)!=null&&i.writeText)return await globalThis.navigator.clipboard.writeText(n),Ge.success(l),!0;const d=globalThis.document,m=(c=d==null?void 0:d.execCommand)==null?void 0:c.bind(d);if(!(d!=null&&d.body)||typeof d.createElement!="function"||typeof m!="function")throw new Error("Clipboard access is unavailable");const h=d.createElement("textarea"),y=d.activeElement,p=y&&typeof y.focus=="function"?y:null;h.value=n,h.setAttribute("readonly","true"),h.style.position="fixed",h.style.opacity="0",h.style.pointerEvents="none",d.body.appendChild(h),h.select(),h.setSelectionRange(0,h.value.length);const x=m("copy");if(d.body.removeChild(h),p==null||p.focus(),!x)throw new Error("Clipboard access is unavailable");return Ge.success(l),!0}catch(d){return Ge.error(d instanceof Error?d.message:"Failed to copy"),!1}}const s3="default workspace";function Ms(n){const l=n.replace(/\\/g,"/");return l==="/"||/^[A-Za-z]:\/$/.test(l)?l:l.replace(/\/+$/g,"")||l}function c3(n){const l=n.replace(/\\/g,"/");return l.startsWith("/")||l.startsWith("//")||/^[A-Za-z]:\//.test(l)}function u3(n,l){const o=Ms(n),i=l.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!i||i==="."?o:o==="/"||/^[A-Za-z]:\/$/.test(o)?`${o}${i}`:`${o}/${i}`}function d3(n,l){var d,m,h;const o=(d=n.effectiveProjectPath)==null?void 0:d.trim();if(o)return Ms(o);const i=(m=n.project)==null?void 0:m.trim();if(!i)return s3;if(c3(i)||!n.assignedTo)return Ms(i);const c=(h=l==null?void 0:l.get(n.assignedTo))==null?void 0:h.trim();return c?u3(c,i):Ms(i)}function xM(n,l,o,i){const c=new Map;for(const m of n){const h=m.assignedTo??null,y=h??"__unassigned__",p=h?l.get(h)??m.assignedNodeName??h.slice(0,8):"Unassigned",x=d3(m,i);c.has(y)||c.set(y,{nodeId:h,nodeName:p,dirMap:new Map});const g=c.get(y);g.dirMap.has(x)||g.dirMap.set(x,[]),g.dirMap.get(x).push(m)}const d=Array.from(c.values()).map(({nodeId:m,nodeName:h,dirMap:y})=>{const p=Array.from(y.entries()).map(([x,g])=>({path:x,tasks:g})).sort((x,g)=>g.tasks.length-x.tasks.length||x.path.localeCompare(g.path));return{nodeId:m,nodeName:h,dirs:p}});return d.sort((m,h)=>{if(o){if(m.nodeId===o)return-1;if(h.nodeId===o)return 1}return m.nodeId===null?1:h.nodeId===null?-1:m.nodeName.localeCompare(h.nodeName)}),d}const f3={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"},m3={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 h3(n){return n.split(".")[0]??"unknown"}function p3(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function Rr(n,l){return(l==null?void 0:l.get(n))??n}function n1(n,l){const o=n.data,i=o.operation;switch(n.type){case"node.joined":return`${o.name} joined the cluster`;case"node.left":return`${Rr(o.nodeId,l)} left (${o.reason})`;case"node.status":return`${Rr(o.nodeId,l)} is now ${o.status}`;case"node.operation.created":return`${i==null?void 0:i.kind} ${i==null?void 0:i.status} on ${Rr(i==null?void 0:i.nodeId,l)}`;case"node.operation.updated":return`${i==null?void 0:i.kind} ${i==null?void 0:i.status} on ${Rr(i==null?void 0:i.nodeId,l)}`;case"transport.changed":return`${Rr(o.nodeId,l)} transport switched to ${o.transportType}`;case"task.created":return`"${o.title}" created`;case"task.assigned":return`task assigned to ${Rr(o.nodeId,l)}`;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 g3(n){return JSON.stringify(n,null,2)}function v3({events:n,maxHeight:l="400px",nodeNameById:o,onDismiss:i,density:c="default"}){if(n.length===0)return null;const d=c==="compact";return f.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:l},children:f.jsx("div",{className:"space-y-1.5",children:n.map(m=>{const h=h3(m.type);return f.jsx("div",{className:re("transition-colors hover:bg-muted/30",d?"rounded-sm px-1 py-0.5":"rounded-lg 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:re("font-mono text-muted-foreground",d?"text-[8px]":"text-[9px]"),children:p3(m.timestamp)}),d?f.jsx("span",{className:re("max-w-[8.5rem] truncate text-[7px] font-medium uppercase tracking-[0.08em] text-muted-foreground/70",m3[h]),children:m.type}):f.jsx(St,{variant:"outline",className:re("w-fit text-[9px] font-medium uppercase tracking-[0.14em] px-1.5 py-0",f3[h]),children:m.type})]}),f.jsxs("div",{className:re("flex shrink-0 items-center",d?"gap-px":"gap-0.5"),children:[f.jsx(yn,{type:"button",variant:"ghost",size:"icon",className:re("rounded-sm text-muted-foreground hover:text-foreground",d?"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:()=>void i3(g3(m),"Event copied"),"aria-label":`Copy ${m.type} event`,title:"Copy event",children:f.jsx(lN,{className:d?"h-2.5 w-2.5":"h-3 w-3"})}),i&&f.jsx(yn,{type:"button",variant:"ghost",size:"icon",className:re("rounded-sm text-muted-foreground hover:text-foreground",d?"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:()=>i(m.id),"aria-label":`Dismiss ${m.type} event`,title:"Dismiss event",children:f.jsx(Y0,{className:d?"h-2.5 w-2.5":"h-3 w-3"})})]})]}),f.jsx("div",{className:"text-[9px] leading-snug text-foreground/85",children:n1(m,o)})]})},m.id)})})})}const y3=["node.","election.","transport."],b3="cluster.state";function x3(n){return n.type==="node.status"?!1:y3.some(l=>n.type.startsWith(l))}function S3(n){return new Date(n).toLocaleTimeString("en-US",{hour12:!1})}function w3(n,l){return n?{time:S3(n.timestamp),text:n1(n,l)}:null}function E3(n){return n.transportType==="devtunnel"||!!n.devtunnelEndpoint}function N3(n){if(n.length===0)return"No node tunnel";const l=n.filter(c=>c.status==="offline").length;if(l>0)return`${l} offline`;const o=n.filter(c=>{var d;return((d=c.devtunnelHealth)==null?void 0:d.status)==="failed"}).length;if(o>0)return`${o} failed`;const i=n.filter(c=>{var d;return c.status!=="offline"&&((d=c.devtunnelHealth)==null?void 0:d.status)!=="healthy"}).length;return i>0?`${i} checking`:"Healthy"}function T3(n,l){var c;const o=(l==null?void 0:l.get(n.id))??n.name??n.id;if(n.status==="offline")return{label:o,status:"offline"};const i=((c=n.devtunnelHealth)==null?void 0:c.status)??"checking";return{label:o,status:i}}function C3(n){if(n.length===0)return"No nodes";const l=n.filter(i=>i.status==="offline").length;if(l>0)return`${l} offline`;const o=n.filter(i=>i.status==="busy").length;return o>0?`${o} busy`:"Healthy"}function A3(n,l){return{label:(l==null?void 0:l.get(n.id))??n.name??n.id,status:n.status}}function R3({connected:n,events:l,nodes:o=[],currentNode:i=null,nodeNameById:c,desktopUpdate:d=null,defaultOpen:m=!1,defaultActionMenuOpen:h=!1,onDesktopUpdate:y,onDesktopRestart:p,onReload:x,onRestart:g}){const[w,N]=v.useState(m),[T,E]=v.useState(h),[C,A]=v.useState(!0),[j,O]=v.useState(new Set),[z,B]=v.useState(!1),[G,$]=v.useState(!1),V=v.useRef(null),ne=v.useRef(null),le=v.useMemo(()=>l.filter(Ne=>x3(Ne)&&!j.has(Ne.id)),[l,j]),fe=v.useMemo(()=>l.find(Ne=>Ne.type===b3)??le[0],[l,le]),me=v.useMemo(()=>w3(fe,c),[fe,c]),ie=v.useMemo(()=>{const Ne=new Map(o.map(Xe=>[Xe.id,Xe]));return i&&Ne.set(i.id,i),Array.from(Ne.values())},[i,o]),ue=v.useMemo(()=>ie.filter(E3),[ie]),oe=ue.some(Ne=>{var Xe;return Ne.status==="offline"||((Xe=Ne.devtunnelHealth)==null?void 0:Xe.status)==="failed"}),M=ie.some(Ne=>Ne.status==="offline"),Y=ie.some(Ne=>Ne.status==="busy"),I=ie.length>0,de=(i==null?void 0:i.name)??"offline",F=(i==null?void 0:i.role)==="leader"?"Leader":(i==null?void 0:i.role)==="follower"?"Follower":"Node",R=d!==null,P=!!(R&&(d!=null&&d.updateAvailable)&&d.latestVersion),K=(d==null?void 0:d.latestVersion)??null,W=!!(R&&!P&&!K&&(d!=null&&d.detail)),te=z?"Relaunching runtime...":"Relaunch to apply update",se=G?"Downloading and installing desktop update...":P&&K?`Available version ${K}`:W?(d==null?void 0:d.detail)??"Desktop update unavailable":"Desktop is current",ee=!!x,ce=!!(R&&p),J=ee||ce,ve=R||!!g,be=R||!!g||ee,Se=ve?R?"Update":"Relaunch":"Reload",He=ve?R?se:te:"Reload dashboard page",je=ve?R?G:z:!1,Ve=ve?R?je||!P||!y:je:!1,dt=R?P&&K?`Install desktop update ${K}`:W?"Desktop update unavailable":"Desktop is current":ve?z?"Relaunching runtime":"Relaunch runtime":"Reload dashboard page";function Pe(){ne.current&&(clearTimeout(ne.current),ne.current=null)}function Lt(){Pe(),N(!0)}function ht(){Pe(),ne.current=setTimeout(()=>{N(!1),ne.current=null},180)}function ol(){Pe()}function il(){Pe(),E(!1),N(!1)}async function Tt(){if(!(!g||z)){B(!0);try{await g()}finally{B(!1)}}}async function jn(){if(!(!P||!y||G)){$(!0);try{await y()}finally{$(!1)}}}async function Ct(){if(!(!p||z)){E(!1),B(!0);try{await p()}finally{B(!1)}}}async function Ll(){if(!ve){await Mn();return}if(R){await jn();return}await Tt()}async function Mn(){x&&(E(!1),await x())}return v.useEffect(()=>()=>{Pe()},[]),v.useEffect(()=>{O(Ne=>{if(Ne.size===0)return Ne;const Xe=new Set(l.map(st=>st.id)),We=new Set(Array.from(Ne).filter(st=>Xe.has(st)));return We.size===Ne.size?Ne:We})},[l]),v.useEffect(()=>{w||E(!1)},[w]),v.useEffect(()=>{if(!w)return;const Ne=We=>{var st;(st=V.current)!=null&&st.contains(We.target)||(Pe(),E(!1),N(!1))},Xe=We=>{We.key==="Escape"&&(Pe(),E(!1),N(!1))};return document.addEventListener("pointerdown",Ne),document.addEventListener("keydown",Xe),()=>{document.removeEventListener("pointerdown",Ne),document.removeEventListener("keydown",Xe)}},[w]),f.jsxs("div",{ref:V,className:"relative",children:[f.jsxs("button",{type:"button","aria-label":n?"Cluster link connected":"Cluster link reconnecting","aria-expanded":w,"aria-haspopup":"dialog",onClick:()=>N(Ne=>!Ne),onMouseEnter:Lt,onMouseLeave:ht,className:re("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",w&&(n?"bg-muted/60 text-foreground":"bg-destructive/12")),title:n?"Cluster link connected":"Cluster link reconnecting",children:[f.jsxs("span",{className:re("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:re("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:de}),f.jsx("span",{className:re("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:F})]})]}),w&&f.jsxs("div",{role:"dialog","aria-label":"Live link connection events",onMouseEnter:ol,onMouseLeave:il,className:"absolute right-0 top-[calc(100%+0.4rem)] z-50 w-[18rem] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-lg border border-border/70 bg-background/96 shadow-[0_28px_90px_-42px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl 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(Ds,{className:"h-3 w-3 text-emerald-500"}):f.jsx(UN,{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:re("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"}),me?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mt-0.5 truncate text-[9px] leading-snug text-foreground/80",children:me.text}),f.jsx("div",{className:"font-mono text-[8px] text-muted-foreground/60",children:me.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:[M?f.jsx(hs,{className:"h-3 w-3 shrink-0 text-destructive"}):Y?f.jsx(Ds,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Yo,{className:re("h-3 w-3 shrink-0",I?"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:re("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",M?"border-destructive/30 bg-destructive/10 text-destructive":Y?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":I?"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:C3(ie)})]}),ie.length>0&&f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:ie.map(Ne=>{const{label:Xe,status:We}=A3(Ne,c),st=We==="offline",On=We==="busy";return f.jsxs("div",{"aria-label":`${Xe} ${We}`,className:re("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",st?"bg-destructive/6":On?"bg-amber-500/6":"bg-emerald-500/5"),title:`${Xe} ${We}`,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),st?f.jsx(hs,{className:"h-3 w-3 shrink-0 text-destructive"}):On?f.jsx(vv,{className:"h-3 w-3 shrink-0 text-amber-500"}):f.jsx(Yo,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},Ne.id)})})]}),ue.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:[oe?f.jsx(hs,{className:"h-3 w-3 shrink-0 text-destructive"}):f.jsx(Yo,{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:re("shrink-0 rounded-sm border px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.1em]",oe?"border-destructive/30 bg-destructive/10 text-destructive":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:N3(ue)})]}),f.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:ue.map(Ne=>{var kn;const{label:Xe,status:We}=T3(Ne,c),st=We==="failed"||We==="offline",On=We!=="healthy"&&We!=="failed"&&We!=="offline",Dn=(kn=Ne.devtunnelHealth)!=null&&kn.reason?`${Xe} ${We}: ${Ne.devtunnelHealth.reason}`:`${Xe} ${We}`;return f.jsxs("div",{"aria-label":`${Xe} ${We}`,className:re("flex items-center justify-between gap-2 rounded-sm px-2 py-0.5",st?"bg-destructive/6":On?"bg-muted/30":"bg-emerald-500/5"),title:Dn,children:[f.jsx("span",{className:"truncate text-[9px] text-foreground/70",children:Xe}),st?f.jsx(hs,{className:"h-3 w-3 shrink-0 text-destructive"}):On?f.jsx(vv,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):f.jsx(Yo,{className:"h-3 w-3 shrink-0 text-emerald-500"})]},Ne.id)})})]}),f.jsxs("div",{children:[f.jsxs("button",{type:"button",onClick:()=>A(Ne=>!Ne),className:"flex w-full items-center justify-between px-2.5 py-1.5 text-left hover:bg-muted/30",children:[f.jsxs("span",{className:"text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:["Notifications ",le.length>0&&`(${le.length})`]}),C?f.jsx(Ko,{className:"h-3 w-3 text-muted-foreground"}):f.jsx(ef,{className:"h-3 w-3 text-muted-foreground"})]}),C&&f.jsx("div",{className:"px-2 pb-2",children:f.jsx(v3,{events:le,maxHeight:"12rem",density:"compact",emptyTitle:"No connection events yet",emptyDescription:"Node, election, and system events will appear here.",nodeNameById:c,onDismiss:Ne=>O(Xe=>new Set(Xe).add(Ne))})})]}),R&&(d==null?void 0:d.detail)&&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:d.detail,children:d.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:be&&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(yn,{type:"button",variant:"ghost",size:"sm",className:re("h-5 rounded-none border-0 px-1.5 text-[9px] font-medium hover:text-foreground [&_svg]:size-2.5",P?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>void Ll(),disabled:Ve,"aria-label":dt,"aria-describedby":"live-link-restart-hint",title:He,children:[f.jsx(yv,{className:re("h-2.5 w-2.5",je&&"animate-pulse")}),f.jsx("span",{children:Se})]}),J&&f.jsx(yn,{type:"button",variant:"ghost",size:"sm",className:re("h-5 rounded-none border-l border-border/50 px-1 text-[9px] hover:text-foreground [&_svg]:size-2.5",P?"bg-primary/12 text-primary hover:bg-primary/18":"bg-background/45 text-muted-foreground hover:bg-emerald-500/10"),onClick:()=>E(Ne=>!Ne),"aria-label":"Open live link actions","aria-expanded":T,title:"Live link actions",children:f.jsx(Ko,{className:"h-2.5 w-2.5"})})]}),J&&T&&f.jsxs("div",{className:"absolute bottom-[calc(100%+0.25rem)] left-0 z-20 min-w-28 overflow-hidden rounded-md border border-border/70 bg-background text-[9px] shadow-lg",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:()=>void Ll(),disabled:Ve,"aria-label":dt,children:[f.jsx(yv,{className:re("h-2.5 w-2.5",je&&"animate-pulse")}),f.jsx("span",{children:Se})]}),ce&&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:()=>void Ct(),disabled:z,"aria-label":"Restart Meshy Desktop",children:[f.jsx(tf,{className:re("h-2.5 w-2.5",z&&"animate-spin")}),f.jsx("span",{children:"Restart"})]}),ee&&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:()=>void Mn(),"aria-label":"Reload dashboard page",children:[f.jsx(tf,{className:"h-2.5 w-2.5"}),f.jsx("span",{children:"Reload"})]})]}),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:He})]})}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(yn,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>O(new Set(l.map(Ne=>Ne.id))),disabled:le.length===0,title:"Dismiss all notifications",children:"Dismiss all"}),f.jsx(yn,{type:"button",variant:"ghost",size:"sm",className:"h-5 rounded-sm px-1.5 text-[9px]",onClick:()=>N(!1),children:"Close"})]})]})]})]})}const a0="dark",Lr="fluent",_3="clean",Kd="meshy-layout-default-migrated-to-compact",yf="true",j3="compact",M3=new Set(["airy","clean","fluent"]);function O3(n){return n!==null&&M3.has(n)}function lm(n){return n===j3?"fluent":O3(n)?n:null}function D3(n,l){const o=lm(n);return o===_3&&l!==yf?Lr:o??Lr}const Fs="symphony",a1="default",k3=new Set(["light","dark","system"]),z3=new Set(["porcelain","warm","finsight","edge","symphony","launcher"]),l1=v.createContext(null);function L3(n){const l=new URLSearchParams(n).get("theme");return r1(l)?l:null}function U3(n){const l=new URLSearchParams(n).get("palette");return rm(l)}function B3(n){const l=new URLSearchParams(n).get("layout");return lm(l)}function H3(){if(typeof document>"u")return null;const n=document.documentElement;return{theme:n.classList.contains("dark")?"dark":"light",palette:rm(n.getAttribute("data-palette"))??Fs,layout:lm(n.getAttribute("data-layout"))??Lr}}function SM(n,l=H3()){if(!l)return n;try{const o=/^[a-z][a-z\d+\-.]*:/i.test(n),i=typeof window<"u"?window.location.href:"http://localhost",c=new URL(n,i);return c.searchParams.set("theme",l.theme),c.searchParams.set("palette",l.palette),c.searchParams.set("layout",l.layout),o?c.toString():`${c.pathname}${c.search}${c.hash}`}catch{return n}}function V3({children:n}){const[l,o]=v.useState(()=>typeof window<"u"?L3(window.location.search)??q3(localStorage.getItem("meshy-theme"))??a0:a0),[i,c]=v.useState(()=>typeof window<"u"?U3(window.location.search)??G3(localStorage.getItem("meshy-palette"))??Fs:Fs),[d,m]=v.useState(()=>{if(typeof window<"u"){const h=B3(window.location.search);if(h)return localStorage.setItem(Kd,yf),h;const y=D3(localStorage.getItem("meshy-layout"),localStorage.getItem(Kd));return localStorage.setItem(Kd,yf),y}return Lr});return v.useEffect(()=>{const h=document.documentElement,y=p=>{if(p==="system"){const x=window.matchMedia("(prefers-color-scheme: dark)").matches;h.classList.toggle("dark",x)}else h.classList.toggle("dark",p==="dark")};if(y(l),localStorage.setItem("meshy-theme",l),l==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)"),x=()=>y("system");return p.addEventListener("change",x),()=>p.removeEventListener("change",x)}},[l]),v.useEffect(()=>{document.documentElement.setAttribute("data-palette",i),localStorage.setItem("meshy-palette",i)},[i]),v.useEffect(()=>{const h=document.documentElement;d===Lr?h.removeAttribute("data-layout"):h.setAttribute("data-layout",d),localStorage.setItem("meshy-layout",d)},[d]),f.jsx(l1.Provider,{value:{theme:l,setTheme:o,palette:i,setPalette:c,layout:d,setLayout:m},children:n})}function $3(){const n=v.useContext(l1);if(!n)throw new Error("useTheme must be used within ThemeProvider");return n}function r1(n){return n!==null&&k3.has(n)}function Y3(n){return n!==null&&z3.has(n)}function q3(n){return r1(n)?n:null}function rm(n){return n===a1?"porcelain":Y3(n)?n:null}function G3(n){return n===a1?null:rm(n)}const P3=[{value:"light",label:"Light",icon:V0},{value:"dark",label:"Dark",icon:B0},{value:"system",label:"System",icon:U0}],o1=[{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"}],i1=[{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 X3(){const{theme:n,setTheme:l,palette:o,setPalette:i,layout:c,setLayout:d}=$3(),[m,h]=v.useState(!1),y=v.useRef(null),p=v.useRef(null),x=n==="dark"?B0:n==="light"?V0:U0,g=()=>{y.current&&(clearTimeout(y.current),y.current=null)},w=()=>{g(),y.current=setTimeout(()=>h(!1),180)};return v.useEffect(()=>{if(!m)return;const N=T=>{p.current&&!p.current.contains(T.target)&&h(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[m]),v.useEffect(()=>()=>g(),[]),f.jsxs("div",{ref:p,className:"relative",onMouseEnter:()=>{g(),h(!0)},onMouseLeave:w,children:[f.jsx(yn,{variant:"ghost",size:"icon",onClick:()=>h(N=>!N),className:re("h-8 w-8 rounded-sm",o!==Fs||c!==Lr?"text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),title:"Appearance","aria-haspopup":"menu","aria-expanded":m,children:f.jsx(x,{className:"h-4 w-4"})}),m&&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:[K3(c)," / ",Q3(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:P3.map(({value:N,label:T,icon:E})=>{const C=n===N;return f.jsxs("button",{type:"button",onClick:()=>l(N),role:"menuitemradio","aria-checked":C,className:re("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",C?"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(E,{className:"h-3 w-3"}),T]},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:i1.map(({value:N,label:T,hint:E})=>{const C=c===N;return f.jsxs("button",{type:"button",onClick:()=>d(N),role:"menuitemradio","aria-checked":C,className:re("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",C?"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:re("text-[10px] font-medium leading-tight",C?"text-primary":"text-foreground"),children:T}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:E})]}),C&&f.jsx(ks,{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(DN,{className:"h-2.5 w-2.5"}),"Palette"]}),f.jsx("div",{className:"space-y-1",children:o1.map(({value:N,label:T,hint:E})=>{const C=o===N;return f.jsxs("button",{type:"button",onClick:()=>i(N),role:"menuitemradio","aria-checked":C,className:re("flex min-h-[2.25rem] w-full items-center gap-1.5 rounded-sm border px-1.5 py-1 text-left transition-colors",C?"border-primary/55 bg-primary/10":"border-border/45 bg-background/45 hover:border-border hover:bg-muted/55"),children:[f.jsx(Z3,{value:N}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:re("text-[10px] font-medium leading-tight",C?"text-primary":"text-foreground"),children:T}),f.jsx("div",{className:"mt-0.5 text-[8px] leading-tight text-muted-foreground",children:E})]}),C&&f.jsx(ks,{className:"h-3 w-3 text-primary"})]},N)})})]})]})]})]})}function K3(n){var l;return((l=i1.find(o=>o.value===n))==null?void 0:l.label)??n}function Q3(n){var l;return((l=o1.find(o=>o.value===n))==null?void 0:l.label)??n}function Z3({value:n}){const l={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,i,c]=l[n];return f.jsxs("div",{className:re("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:i}}),f.jsx("div",{className:"h-full w-1/3",style:{background:c}})]})}const Go={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}},s1="meshy-dashboard-panel-state-v2",c1="meshy-dashboard-terminal-open-v1";function wM({operationsOpen:n}){return{layout:{desktopTasksOpen:!0,operationsOpen:n},sizes:{tasks:Go.tasks.defaultSize,operations:Go.operations.defaultSize,terminal:Go.terminal.defaultSize}}}function Qd(n){return typeof n=="object"&&n!==null}function l0(n,l){return typeof n=="boolean"?n:l}function Zd(n,l,o){return typeof l=="number"&&Number.isFinite(l)?Po(n,l):o}function Po(n,l){const o=Go[n];return Math.min(o.max,Math.max(o.min,l))}function EM(n,l){if(!n)return l;try{const o=n.getItem(s1);if(!o)return l;const i=JSON.parse(o);if(!Qd(i))return l;const c=Qd(i.layout)?i.layout:{},d=Qd(i.sizes)?i.sizes:{};return{layout:{desktopTasksOpen:l0(c.desktopTasksOpen,l.layout.desktopTasksOpen),operationsOpen:l0(c.operationsOpen,l.layout.operationsOpen)},sizes:{tasks:Zd("tasks",d.tasks,l.sizes.tasks),operations:Zd("operations",d.operations,l.sizes.operations),terminal:Zd("terminal",d.terminal,l.sizes.terminal)}}}catch{return l}}function NM(n,l){if(n)try{n.setItem(s1,JSON.stringify(l))}catch{}}function I3(n,l){if(!n)return l;try{const o=n.getItem(c1);return o==="true"?!0:o==="false"?!1:l}catch{return l}}function F3(n,l){if(n)try{n.setItem(c1,String(l))}catch{}}function r0(){var n;try{return((n=globalThis.window)==null?void 0:n.localStorage)??globalThis.localStorage??null}catch{return null}}function TM(n){return`${Number(n.toFixed(2))}rem`}function CM(n,l,o,i,c,d,m){const h=Number.isFinite(m)&&m>0?m:16;return n==="tasks"?Po(n,l+(c-o)/h):n==="operations"?Po(n,l+(o-c)/h):Po(n,l+(i-d)/h)}function AM(n,l,o){const i=o===0?0:o>0?-1:1;return Po(n,l+i*Go[n].wheelStep)}const J3=7200*1e3;function W3(){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 Ns(){var n,l;return typeof window>"u"?null:((l=(n=window.__TAURI__)==null?void 0:n.core)==null?void 0:l.invoke)??null}function o0(n){return{currentVersion:null,latestVersion:null,updateAvailable:!1,checkedAt:new Date().toISOString(),releaseUrl:null,assetName:null,installable:!1,detail:n}}function Id(n,l){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 l}function ej(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 tj(){const{cluster:n,events:l,sseConnected:o,systemInfo:i}=k0(),c=Fn(),[d,m]=v.useState(()=>I3(r0(),!1)),[h,y]=v.useState(""),[p,x]=v.useState(null),[g,w]=v.useState(null),N=!!Ns(),T=N?"max-w-none":"max-w-[1760px]",E=c.pathname==="/"||/^\/tasks\/[^/]+$/.test(c.pathname),C=v.useMemo(()=>{const B=new Map;for(const G of(n==null?void 0:n.nodes)??[])B.set(G.id,G.name);return n!=null&&n.self&&B.set(n.self.id,n.self.name),B},[n==null?void 0:n.nodes,n==null?void 0:n.self]),A=v.useCallback(B=>{m(G=>typeof B=="function"?B(G):B)},[]);v.useEffect(()=>{F3(r0(),d)},[d]),v.useEffect(()=>{const B=Ns();if(!B){w(null);return}let G=!1,$=!1;const V=le=>{$||($=!0,le&&w(o0("Checking desktop update...")),B("check_desktop_update").then(fe=>{G||w(fe)}).catch(fe=>{if(!G){const me=Id(fe,"Desktop update check failed");w(ie=>ie!=null&&ie.updateAvailable?ie:o0(me))}}).finally(()=>{$=!1}))};V(!0);const ne=window.setInterval(()=>V(!1),J3);return()=>{G=!0,window.clearInterval(ne)}},[i==null?void 0:i.version]);async function j(){try{const B=await O0({reason:"restart"});Ge.info(`Restarting runtime. Follow ${B.logPath} for launch output.`),await e1({previousPid:B.pid})||Ge.error("Runtime restart was accepted, but the dashboard did not reconnect before the timeout.")}catch(B){Ge.error(B instanceof Error?B.message:"Runtime restart failed")}}async function O(){const B=Ns();if(!B){Ge.error("Desktop updater is not available in this window");return}try{Ge.info("Downloading desktop update...");const G=await B("install_desktop_update");Ge.info(ej(G))}catch(G){Ge.error(Id(G,"Desktop update failed"))}}async function z(){const B=Ns();if(!B){Ge.error("Desktop restart is not available in this window");return}try{Ge.info("Restarting Meshy Desktop..."),await B("restart_desktop_app")}catch(G){Ge.error(Id(G,"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:"relative z-50 shrink-0 px-2 py-2",children:f.jsxs("div",{className:re("dashboard-panel dashboard-panel-muted animate-panel-settle mx-auto flex items-center gap-0 rounded-lg px-3 py-2",T),children:[f.jsx("div",{className:"flex shrink-0 items-center gap-3 pr-3",children:f.jsxs(Wd,{to:"/","aria-label":"Meshy home",className:"flex items-center gap-2",children:[f.jsx(W3,{}),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"}),E&&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:()=>y(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(H0,{className:"h-3 w-3 shrink-0 text-primary/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.nodeName})]}),f.jsx(ef,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsxs("button",{type:"button",onClick:()=>y(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(fN,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),f.jsx("span",{className:"max-w-[9rem] truncate",children:p.projectLabel})]}),f.jsx(ef,{className:"h-3 w-3 shrink-0 text-border/80"}),f.jsx(Wd,{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(CN,{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(am,{"aria-label":"Search tasks",value:h,onChange:B=>y(B.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:[E&&f.jsx(yn,{variant:"ghost",size:"icon",onClick:()=>A(B=>!B),"aria-label":d?"Close terminal":"Open terminal",title:d?"Close terminal":"Open terminal",className:re("h-8 w-8 rounded-sm text-muted-foreground hover:bg-muted/50 hover:text-foreground",d&&"bg-primary/8 text-primary"),children:f.jsx($0,{className:"h-4 w-4"})}),f.jsx(t3,{}),f.jsx(X3,{}),f.jsx("div",{className:"mx-0 h-4 w-px shrink-0 bg-border/50"}),f.jsx(R3,{connected:o,events:l,nodes:(n==null?void 0:n.nodes)??[],currentNode:(n==null?void 0:n.self)??null,nodeNameById:C,desktopUpdate:g,onDesktopUpdate:g!=null&&g.updateAvailable?O:void 0,onDesktopRestart:N?z:void 0,onReload:N?()=>window.location.reload():void 0,onRestart:j})]})]})}),f.jsx("main",{className:re("min-h-0 flex-1 px-2 pb-2",E?"overflow-hidden":"overflow-y-auto"),children:f.jsx("div",{className:re("mx-auto h-full min-h-0",T),children:f.jsx(_w,{context:{terminalOpen:d,setTerminalOpen:A,headerSearchQuery:h,setHeaderSearchQuery:y,setHeaderTaskContext:x}})})})]})]})}const i0=v.lazy(async()=>({default:(await u0(()=>import("./DashboardPage-CMsJFjmz.js").then(l=>l.D),__vite__mapDeps([0,1,2,3]))).DashboardPage})),nj=v.lazy(async()=>({default:(await u0(()=>import("./SharedConversationPage-DCIspBsA.js"),__vite__mapDeps([4,1]))).SharedConversationPage}));function aj(){return f.jsx(tE,{children:f.jsx(v.Suspense,{fallback:f.jsx(lj,{}),children:f.jsxs(Mw,{children:[f.jsx(jl,{path:"/shared/tasks/:shareId",element:f.jsx(nj,{})}),f.jsxs(jl,{element:f.jsx(kE,{children:f.jsx(tj,{})}),children:[f.jsx(jl,{path:"/",element:f.jsx(i0,{})}),f.jsx(jl,{path:"/nodes",element:f.jsx(hv,{to:"/",replace:!0})}),f.jsx(jl,{path:"/tasks",element:f.jsx(hv,{to:"/",replace:!0})}),f.jsx(jl,{path:"/tasks/:id",element:f.jsx(i0,{})})]})]})})})}function lj(){return f.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading workspace..."})}function rj(n){const l=n??(typeof window>"u"?void 0:window);l!=null&&l.__TAURI__&&l.addEventListener("contextmenu",o=>{o.preventDefault()})}function oj(n){return f.jsx(eC,{className:"toaster group",style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border))"},...n})}rj();j2.createRoot(document.getElementById("root")).render(f.jsx(v.StrictMode,{children:f.jsxs(V3,{children:[f.jsx(aj,{}),f.jsx(oj,{})]})}));export{Qs as $,Yy as A,yn as B,ks as C,aM as D,Gy as E,uN as F,SM as G,lN as H,am as I,i3 as J,o3 as K,L0 as L,t_ as M,eM as N,wx as O,tM as P,js as Q,St as R,H0 as S,lM as T,yM as U,qs as V,gf as W,Y0 as X,Gs as Y,Ps as Z,Ks as _,rC as a,mM as a$,Xs as a0,Is as a1,Zs as a2,u0 as a3,dj as a4,qy as a5,q5 as a6,Nj as a7,$0 as a8,Yo as a9,r0 as aA,NM as aB,AM as aC,TM as aD,CM as aE,Cj as aF,AE as aG,SE as aH,Fj as aI,Ij as aJ,jE as aK,kj as aL,pj as aM,mj as aN,Py as aO,hj as aP,gj as aQ,gE as aR,t3 as aS,zj as aT,Lj as aU,sj as aV,Fn as aW,S0 as aX,ij as aY,k0 as aZ,pM as a_,nN as aa,Ej as ab,Tj as ac,wj as ad,_N as ae,gN as af,hM as ag,wN as ah,v3 as ai,g_ as aj,sN as ak,v_ as al,bM as am,a3 as an,sM as ao,xM as ap,oM as aq,iM as ar,gM as as,Fx as at,vM as au,vf as av,Uj as aw,Bj as ax,EM as ay,wM as az,re as b,cM as b0,uM as b1,fM as b2,dM as b3,Aj as b4,rM as b5,l3 as b6,Oj as b7,Dj as b8,Mj as b9,jj as ba,uj as bb,fj as bc,cj as bd,vj as be,Wj as bf,qj as bg,Yj as bh,$j as bi,Hj as bj,Vj as bk,Gj as bl,n3 as bm,s0 as bn,FE as bo,Kj as bp,Xj as bq,Pj as br,tf as bs,Qj as bt,Jj as bu,Zj as bv,Be as c,ry as d,Sj as e,pE as f,bj as g,yj as h,fN as i,f as j,ef as k,jr as l,xj as m,_j as n,Wb as o,Jf as p,ex as q,v as r,Wf as s,Ge as t,CN as u,Ko as v,DN as w,nM as x,Rj as y,V5 as z};
@@ -1,4 +1,4 @@
1
- import{c as a}from"./index-C-8r6nJt.js";/**
1
+ import{c as a}from"./index-CwYkt_RH.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -5,8 +5,8 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Meshy Dashboard</title>
7
7
  <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>&#x1F578;</text></svg>" />
8
- <script type="module" crossorigin src="/assets/index-C-8r6nJt.js"></script>
9
- <link rel="stylesheet" crossorigin href="/assets/index-BUyIef5c.css">
8
+ <script type="module" crossorigin src="/assets/index-CwYkt_RH.js"></script>
9
+ <link rel="stylesheet" crossorigin href="/assets/index-BHdoRCbz.css">
10
10
  </head>
11
11
  <body>
12
12
  <div id="root"></div>
package/main.cjs CHANGED
@@ -60501,7 +60501,7 @@ function listResolvedDirectory(absPath, relativeBase, options = {}) {
60501
60501
  const result = [];
60502
60502
  const childPathStyle = options.childPathStyle ?? "relative";
60503
60503
  for (const entry of entries) {
60504
- if (entry.name.startsWith(".")) continue;
60504
+ if (entry.name.startsWith(".") && !(options.includeDotDirectories && entry.isDirectory())) continue;
60505
60505
  const entryRelPath = childPathStyle === "absolute" ? path15.join(absPath, entry.name) : path15.join(relativeBase || ".", entry.name).split(path15.sep).join("/");
60506
60506
  if (entry.isDirectory()) {
60507
60507
  result.push({
@@ -60590,7 +60590,7 @@ function getOutputSummary(root) {
60590
60590
  let fileCount;
60591
60591
  try {
60592
60592
  const entries = fs14.readdirSync(root, { withFileTypes: true });
60593
- fileCount = entries.filter((e) => !e.name.startsWith(".")).length;
60593
+ fileCount = entries.filter((e) => e.isDirectory() || !e.name.startsWith(".")).length;
60594
60594
  } catch {
60595
60595
  fileCount = void 0;
60596
60596
  }
@@ -63231,7 +63231,7 @@ function getLocalTaskOutputTree(taskEngine, taskId, currentPath) {
63231
63231
  return {
63232
63232
  rootPath,
63233
63233
  currentPath,
63234
- entries: listDirectory(rootPath, currentPath)
63234
+ entries: listDirectory(rootPath, currentPath, { includeDotDirectories: true })
63235
63235
  };
63236
63236
  } catch (err) {
63237
63237
  if (err instanceof Error && err.message === "Path traversal detected") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meshy-node",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "private": false,
5
5
  "description": "Standalone Meshy node package with bundled runtime and dashboard assets.",
6
6
  "type": "commonjs",