@gbasin/agentboard-linux-arm64 0.23.0 → 0.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/agentboard CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/agentboard
3
3
  size: 95332496 bytes
4
- sha256: 977e54492dbddacedce8042289412c7fe0eb13f936ee480ef93809a085599861
4
+ sha256: 9b53548d7e4416e2838cf68680f9d629605ef3355e35642d84185bc1004f5fa2
@@ -303,4 +303,4 @@ ${s.join(`
303
303
  active:scale-95 transition-all duration-75
304
304
  select-none touch-manipulation
305
305
  ${r?ZK[t.status]:XK[t.status]}
306
- `,onClick:()=>{QK(),d(t.id)},title:ht?t.name:void 0,children:i},t.id)})})]}),(0,S.jsxs)(`div`,{className:`relative flex-1`,children:[(0,S.jsx)(`div`,{ref:Me,className:`absolute inset-0`,style:{backgroundColor:E.background}}),Be&&e&&(0,S.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`absolute top-2 left-2 z-50 flex items-center gap-1.5 rounded-lg bg-black/60 px-2.5 py-1.5 text-xs text-white/90 shadow-lg backdrop-blur-md`,children:[(0,S.jsx)(Ie,{width:G.pill,height:G.pill,className:`animate-spin`}),`Loading`]}),He&&e&&(0,S.jsxs)(`div`,{className:`absolute ${L&&!R?`bottom-20`:`bottom-8`} left-1/2 z-30 flex max-w-[calc(100%-2rem)] -translate-x-1/2 items-center gap-2 rounded-lg border border-border bg-elevated/95 px-2 py-2 shadow-lg backdrop-blur-sm md:hidden`,children:[(0,S.jsx)(`span`,{className:`max-w-[12rem] truncate text-xs text-secondary md:max-w-[18rem]`,children:`Selection ready`}),(0,S.jsxs)(`button`,{type:`button`,onClick:Ue,className:`relative flex h-8 shrink-0 items-center justify-center gap-1.5 rounded bg-accent px-2.5 text-xs font-medium text-white hover:bg-accent/90 active:scale-95 transition-all [@media(pointer:coarse)]:before:absolute [@media(pointer:coarse)]:before:inset-[calc(50%-22px)] [@media(pointer:coarse)]:before:content-['']`,title:`Copy selection`,"aria-label":`Copy selection`,children:[(0,S.jsx)(F,{width:G.default,height:G.default}),`Copy`]}),(0,S.jsx)(`button`,{type:`button`,onClick:We,className:`relative flex h-8 w-8 shrink-0 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all [@media(pointer:coarse)]:before:absolute [@media(pointer:coarse)]:before:inset-[calc(50%-22px)] [@media(pointer:coarse)]:before:content-['']`,title:`Dismiss`,"aria-label":`Dismiss`,children:(0,S.jsx)(Fe,{width:G.default,height:G.default})})]}),!e&&(0,S.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted`,children:r?null:`Select a session to view terminal`}),e&&Ce&&(0,S.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-center text-sm text-muted`,children:`Remote session (read-only). Use SSH to attach on the host.`}),r&&(0,S.jsx)(`div`,{className:`absolute inset-0 z-10 overflow-y-auto bg-base`,children:(0,S.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col gap-4 p-4 md:p-6`,children:[(0,S.jsx)(`div`,{className:`border-b border-border pb-4`,children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,S.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,S.jsx)(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-primary`,children:Te}),(0,S.jsx)(`span`,{className:`rounded-full bg-blue-500/15 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-blue-400`,children:`Hibernating`}),Ee&&(0,S.jsx)(`span`,{className:`text-muted`,children:Ee}),(0,S.jsxs)(`span`,{className:`text-muted`,children:[`Last active `,De]})]}),r.lastResumeError&&(0,S.jsxs)(`div`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/15 px-2 py-1 text-xs text-amber-400`,title:`Last wake failed: ${r.lastResumeError}`,children:[(0,S.jsx)(T,{width:G.pill,height:G.pill}),`Last wake failed`]}),r.lastUserMessage&&(0,S.jsx)(`p`,{className:`max-h-28 max-w-3xl overflow-y-auto whitespace-pre-wrap break-words pr-2 text-sm leading-6 text-secondary`,children:r.lastUserMessage})]}),(0,S.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>_(r.sessionId),className:`btn btn-primary hidden md:inline-flex`,children:`Wake`}),y&&(0,S.jsx)(`button`,{type:`button`,onClick:()=>y(r.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,S.jsx)(DO,{session:r})]})}),Le&&e&&!R?(0,S.jsxs)(`button`,{type:`button`,onClick:Ge,className:`absolute bottom-14 left-1/2 z-20 flex h-10 items-center justify-center rounded-full border border-amber-400/35 bg-amber-500/20 text-amber-100 shadow-lg backdrop-blur-sm transition-all hover:bg-amber-500/30 active:scale-95 md:hidden ${St}`,style:{transform:`translateX(-50%)`},title:`Exit tmux copy mode and return to live output`,"aria-label":`Exit copy mode`,children:[(0,S.jsx)(`span`,{className:`px-3 text-[11px] font-semibold uppercase tracking-wide`,children:`Copy mode`}),(0,S.jsx)(`span`,{className:`self-stretch border-l border-amber-400/25`,"aria-hidden":`true`}),(0,S.jsx)(`span`,{className:`px-3 text-sm font-medium`,children:`Exit`})]}):L&&e&&!R?(0,S.jsxs)(`button`,{type:`button`,onClick:Ge,className:`absolute bottom-8 left-1/2 z-20 flex h-10 px-4 items-center justify-center gap-1.5 rounded-full bg-blue-600/90 text-white shadow-lg hover:bg-blue-600 active:scale-95 transition-all md:hidden ${St}`,style:{transform:`translateX(-50%)`},title:`Scroll to bottom`,"aria-label":`Scroll to bottom`,children:[(0,S.jsx)(D,{width:G.primary,height:G.primary}),(0,S.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]}):null]}),(0,S.jsx)(NK,{...ut}),(0,S.jsx)(iK,{session:e,hibernatingSession:r,hibernatingDisplayName:Te,showHostBadge:Ae,sessionCount:t.length,connectionStatus:o,isSwitching:Be,canControl:we,canHibernate:Oe,modDisplay:N,onKill:()=>H(!0),onHibernate:Ye,onWake:()=>r&&_(r.sessionId),onRename:t=>{let n=e?.id??r?.sessionId;n&&h(n,t)},onDuplicate:e&&g?()=>g(e.id):void 0,onMoveToHistory:r&&y?()=>y(r.sessionId):void 0,isTmuxCopyMode:Le,showJumpToBottom:L&&!R,onJumpToBottom:Ge,selectionReady:!!He,onCopySelection:Ue,onDismissSelection:We}),e&&(0,S.jsx)(JK,{onSendKey:at,onPasteText:ot,onPasteImage:st,disabled:o!==`connected`||Ce||!Ve,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,agentType:e.agentType,fileUploadsAllowed:!ve,onSelectSession:d,hideSessionSwitcher:!0,onRefocus:lt,isKeyboardVisible:mt,onEnterTextMode:ft}),(I||P)&&(0,S.jsx)(YK,{isOpen:ie,onClose:()=>U(!1),sessions:n??t,hibernatingSessions:i,historySessions:a,selectedSessionId:e?.id??null,selectedHibernatingSessionId:r?.sessionId??null,onSelect:d,onSelectHibernating:f,onRename:h,onResume:_,onHibernate:v,onMoveToHistory:y,onNewSession:p,loading:x,error:w}),te&&e&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,S.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,S.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,S.jsxs)(`p`,{className:`text-sm text-secondary mb-4 text-pretty`,children:[`Kill "`,e.agentSessionName||e.name,`"? The process will be terminated. Conversation history is preserved in logs.`]}),(0,S.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,S.jsx)(`button`,{onClick:()=>H(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,S.jsx)(`button`,{ref:me,onClick:Je,className:`btn btn-danger py-1.5 px-3 text-sm`,children:`Kill Session`})]})]})})]})}function eq({onSelect:e,onCancel:t,initialPath:n}){let[r,i]=(0,C.useState)(n||`~`),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(null),[l,u]=(0,C.useState)(!0),[d,f]=(0,C.useState)(-1),p=(0,C.useRef)(null),m=W(e=>e.recentPaths),h=(0,C.useCallback)(async e=>{p.current?.abort();let t=new AbortController;p.current=t;let{signal:n}=t;u(!0),c(null),o(null),f(-1),i(e);try{let r=await fetch(`/api/directories?path=${encodeURIComponent(e)}`,{signal:n});if(!r.ok){let e=await r.json();throw Error(e.message||`Failed to load directory`)}let a=await r.json();if(p.current!==t)return;o(a),i(a.path)}catch(e){if(p.current!==t)return;let n=e;n?.name!==`AbortError`&&c(n?.message||`Failed to load directory`)}finally{p.current===t&&u(!1)}},[]);(0,C.useEffect)(()=>(h(n||`~`),()=>{p.current?.abort()}),[h,n]);let g=a?.directories??[],_=a?.path||r,v=a?.parent;return(0,C.useEffect)(()=>{let n=n=>{if(n.key===`Escape`){n.preventDefault(),t();return}if(!l){if(n.key===`ArrowDown`){n.preventDefault(),f(e=>g.length===0?-1:e<0?0:Math.min(e+1,g.length-1));return}if(n.key===`ArrowUp`){n.preventDefault(),f(e=>g.length===0?-1:e<0?g.length-1:Math.max(e-1,0));return}if(n.key===`Enter`){n.preventDefault();let t=g[d];t?h(t.path):_&&e(_);return}n.key===`Backspace`&&v&&(n.preventDefault(),h(v))}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[g,_,h,d,l,t,e,v]),(0,S.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Directory browser`,className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},"data-testid":`directory-browser`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,S.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,S.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,S.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,S.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,S.jsx)(`p`,{className:`text-danger`,children:s}),(0,S.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,S.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,S.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,S.jsxs)(`button`,{type:`button`,onClick:()=>h(e.path),onMouseEnter:()=>f(t),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-xs ${t===d?`bg-hover text-primary`:`text-secondary`}`,"data-testid":`directory-entry`,"data-entry-name":e.name,"data-entry-path":e.path,children:[(0,S.jsx)(ae,{width:G.default,height:G.default,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,S.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,S.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,S.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,S.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,S.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,S.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,S.jsx)(`button`,{type:`button`,className:`block w-full truncate text-left text-xs text-secondary hover:text-primary`,onClick:()=>h(e),title:e,"data-testid":`directory-recent`,"data-recent-path":e,children:e},e))})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function tq(e){let t=e.trim();if(t.length>=2){let e=t[0],n=t[t.length-1];if(e===`'`&&n===`'`)return t.slice(1,-1).replace(/'\\''/g,`'`);if(e===`"`&&n===`"`)return t.slice(1,-1).replace(/\\"/g,`"`).replace(/\\\\/g,`\\`)}return t}function nq(e){let t=e.trim(),n=t.search(/\s/);if(n===-1||t.slice(0,n).split(`/`).pop()!==`bash`)return null;let r=n;for(;r<t.length&&/\s/.test(t[r]);)r++;let i=!1,a=!1;for(;r<t.length;){let e=r;for(;r<t.length&&!/\s/.test(t[r]);)r++;let n=t.slice(e,r);for(;r<t.length&&/\s/.test(t[r]);)r++;if(!n.startsWith(`-`)||n===`-`)return null;if(n===`--`)break;if(n.startsWith(`--`)||!/^-[a-zA-Z]+$/.test(n))continue;let o=n.slice(1);if(o.includes(`l`)&&(i=!0),o.includes(`c`)){a=!0;break}}if(!i||!a)return null;let o=t.slice(r).trim();return o?tq(o):null}function rq(e){return e?e===`claude-rp`?`claude`:e:null}function iq(e){let t=e.trim();if(!t)return``;let n=tq(t);return nq(n)??n}function aq(e){if(e===`claude`)return`claude`;if(e===`codex`)return`codex`;if(e===`pi`)return`pi`;if(e===`devin`||e===`devin-cli`)return`devin`;if(e===`grok`||e.startsWith(`grok-`))return`grok`;if(e===`omp`)return`omp`}function oq(e){let t=/\S+/g,n;for(;n=t.exec(e);){let e=n[0].toLowerCase().replace(/^["']+|["']+$/g,``);if([`npx`,`bunx`,`pnpm`,`yarn`,`env`].includes(e)||e.includes(`=`)||e.startsWith(`-`))continue;let t=e.includes(`@oh-my-pi/`)?`omp`:aq(e.split(`/`).pop()||e);return t?{agentType:t,end:n.index+n[0].length}:void 0}}function sq(e){let t=iq(e);if(t)return oq(t.toLowerCase().trim().replace(/^["']|["']$/g,``))?.agentType}var cq={claude:`--dangerously-skip-permissions`,codex:`--yolo`,grok:`--always-approve`,devin:`--permission-mode dangerous`,pi:null,omp:`--auto-approve`},lq={claude:[`--dangerously-skip-permissions`,`--permission-mode bypassPermissions`,`--permission-mode=bypassPermissions`],codex:[`--yolo`,`--dangerously-bypass-approvals-and-sandbox`],grok:[`--always-approve`,`--yolo`,`--dangerously-skip-permissions`,`--permission-mode bypassPermissions`,`--permission-mode=bypassPermissions`],devin:[`--permission-mode dangerous`,`--permission-mode=dangerous`],pi:[],omp:[`--auto-approve`,`--approval-mode yolo`,`--approval-mode=yolo`]};function uq(e){let t=rq(e);return t?cq[t]:null}function dq(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function fq(e){return RegExp(`(^|\\s)${dq(e)}(?=\\s|$)`,`g`)}function pq(e,t){return(t?[rq(t)].filter(e=>e!==null):Object.keys(lq)).some(t=>lq[t].some(t=>fq(t).test(e)))}function mq(e,t){let n=oq(e);return n?`${e.slice(0,n.end)} ${t}${e.slice(n.end)}`:null}function hq(e,t){let n=uq(t);if(!n)return e;let r=e.trim();if(!r||pq(r,t))return r;let i=mq(r,n);if(i)return i;let a=iq(r);if(a&&a!==r){let e=mq(a,n);if(e)return`bash -lc '${e.replace(/'/g,`'\\''`)}'`}return`${r} ${n}`}function gq(e,t){let n=rq(t);if(!n||pq(e,t))return null;if(n===`codex`){let t=/(^|\s)(--full-auto|--ask-for-approval|-a)(?=\s|=|$)/.exec(e);if(t)return`conflicts with ${t[2]}`}if(n===`omp`){let t=/(^|\s)--approval-mode(?:\s+|=)(always-ask|write)/.exec(e);if(t)return`conflicts with --approval-mode ${t[2]}`}let r=/(^|\s)--permission-mode(?:\s+|=)(\S+)/.exec(e);return r&&n!==`codex`?`conflicts with --permission-mode ${r[2]}`:null}function _q(e,t){let n=rq(t);if(!n)return e;let r=e;for(let e of lq[n])r=r.replace(fq(e),` `);return r.replace(/\s+/g,` `).trim()}function vq({isOpen:e,onClose:t,onCreate:n,defaultProjectDir:r,commandPresets:i,defaultPresetId:a,lastProjectPath:o,activeProjectPath:s,remoteHosts:c=[],remoteAllowControl:l=!1,initialHost:u,initialPath:d,initialCommand:f}){let[p,m]=(0,C.useState)(``),[h,g]=(0,C.useState)(``),[_,v]=(0,C.useState)(null),[y,b]=(0,C.useState)(``),[x,w]=(0,C.useState)(!1),[T,E]=(0,C.useState)(``),D=W(e=>e.yoloMode),O=W(e=>e.setYoloMode),k=(0,C.useRef)(null),A=(0,C.useRef)(null),j=(0,C.useRef)(null),M=(0,C.useRef)(!1),N=l&&c.length>0,P=e=>{if(!D)return e;let t=sq(e);return t&&!gq(e,t)?hq(e,t):e},F=e=>{let t=i.find(t=>t.id===e);t&&(v(e),b(P(it(t))))},I=()=>{v(null),b(``)};if((0,C.useEffect)(()=>{let t=M.current;if(M.current=e,!e){m(``),g(``),v(null),b(``),w(!1),E(u??``),t&&setTimeout(()=>{if(typeof document>`u`||typeof document.querySelector!=`function`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300);return}if(typeof document<`u`&&typeof document.querySelector==`function`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}m(d?.trim()||s?.trim()||o||r||``),g(``),E(u??``);let n=f?.trim();if(n){let e=i.find(e=>it(e)===n);e?(v(e.id),b(it(e))):(v(null),b(n))}else{let e=i.find(e=>e.id===a);e?(v(a),b(P(it(e)))):i.length>0?(v(i[0].id),b(P(it(i[0])))):(v(null),b(``))}setTimeout(()=>{if(j.current?.focus(),A.current){let e=A.current;e.scrollLeft=e.scrollWidth}},50)},[s,i,a,r,e,o,u,d,f]),(0,C.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=()=>k.current?Array.from(k.current.querySelectorAll(`input:not([disabled]), select:not([disabled]), button:not([disabled]):not([tabindex="-1"]), [tabindex="0"]`)):[],r=e=>{if(!x){if(e.key===`Escape`){typeof e.stopPropagation==`function`&&e.stopPropagation(),t();return}if(e.key===`Enter`){let t=document.activeElement;if(!t||t.tagName===`INPUT`||t.closest(`[data-testid="host-select"]`)||!t.closest(`[data-testid="command-select"]`))return;e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation(),k.current?.requestSubmit();return}if(/^[0-9]$/.test(e.key)&&!e.metaKey&&!e.ctrlKey&&!e.altKey){let t=document.activeElement;if(t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable))return;let n;if(e.key===`0`)n=i.length;else if(n=Number(e.key)-1,n>=i.length)return;e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation(),n===i.length?I():F(i[n].id),(k.current?.querySelectorAll?.(`[data-testid="command-select"] [role="radio"]`))?.[n]?.focus();return}if(e.key===`Tab`){e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation();let t=n();if(t.length===0)return;let r=document.activeElement,i=t.indexOf(r),a;a=i===-1?e.shiftKey?t.length-1:0:e.shiftKey?i<=0?t.length-1:i-1:i>=t.length-1?0:i+1,t[a]?.focus()}}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,t,x,i,D]),!e)return null;let L=_===null,ee=T!==``,R=sq(y),z=uq(R)!==null,B=R?pq(y,R):!1,te=R&&!B?gq(y,R):null,V=!z||te!==null,H=R?R===`pi`?`Pi has no permission prompts — nothing to enable`:te??`Append ${uq(R)}`:`Enter a supported agent command (claude, codex, grok, devin)`,ne=e=>{O(e),R&&b(e?hq(y,R):_q(y,R))},re=e=>{e.preventDefault();let r=p.trim();if(!r)return;let i=y.trim();n(r,h.trim()||void 0,i||void 0,ee?T:void 0),t()},ie=[...i.map(e=>({id:e.id,label:e.label,isCustom:!1,agentType:e.agentType,command:e.command})),{id:`custom`,label:`Custom`,isCustom:!0,agentType:void 0,command:void 0}],U=[{id:``,label:`Local`,ok:!0,error:void 0},...c.map(e=>({id:e.host,label:e.host,ok:e.ok,error:e.error}))],ae=p.trim()||`~`;return(0,S.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-session-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:[(0,S.jsxs)(`form`,{ref:k,onSubmit:re,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,S.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,S.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[N&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,S.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Host`,"data-testid":`host-select`,children:U.map((e,t)=>{let n=T===e.id,r=!e.ok&&!n;return(0,S.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":e.label,title:e.ok?void 0:e.error||`Unreachable`,tabIndex:n?0:-1,onClick:()=>E(e.id),onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%U.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+U.length)%U.length;else return;let r=U[n];E(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``} ${r?`opacity-60`:``}`,children:e.label},e.id||`local`)})})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,S.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Command preset`,"data-testid":`command-select`,children:ie.map((e,t)=>{let n=e.isCustom?L:_===e.id,r=e.isCustom?`0`:t<9?String(t+1):null;return(0,S.jsxs)(`button`,{ref:n?j:void 0,type:`button`,role:`radio`,"aria-checked":n,"aria-keyshortcuts":r??void 0,tabIndex:n?0:-1,onClick:()=>{e.isCustom?I():F(e.id)},onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%ie.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+ie.length)%ie.length;else return;let r=ie[n];r.isCustom?I():F(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``}`,children:[r&&(0,S.jsx)(`kbd`,{"aria-hidden":`true`,className:`shortcut-badge`,children:r}),(0,S.jsx)(Bh,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,S.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`}),(0,S.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-xs ${V?`text-muted opacity-60`:`text-secondary`}`,title:H,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:B,disabled:V,onChange:e=>ne(e.target.checked)}),`yolo mode — skip permission prompts`]})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(`input`,{ref:A,value:p,onChange:e=>m(e.target.value),placeholder:ee?`/home/user/project`:s||o||r||`/Users/you/code/my-project`,className:`input flex-1 text-sm`}),!ee&&(0,S.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>w(!0),children:`Browse`})]})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,S.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,S.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,S.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),x&&!ee&&(0,S.jsx)(eq,{initialPath:ae,onSelect:e=>{m(e),w(!1)},onCancel:()=>w(!1)})]})}function yq({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=C.useRef(e!==void 0),[a,o]=C.useState(t);return[i?e:a,C.useCallback(e=>{i||o(e)},[])]}var bq={};function xq(e,t){let n=C.useRef(bq);return n.current===bq&&(n.current=e(t)),n}var Sq=C[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],Cq=Sq&&Sq!==C.useLayoutEffect?Sq:e=>e();function wq(e){let t=xq(Tq).current;return t.next=e,Cq(t.effect),t.trampoline}function Tq(){let e={next:void 0,callback:Eq,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Eq(){}function Dq(e,t,n,r){let i=xq(kq).current;return Aq(i,e,t,n,r)&&Mq(i,[e,t,n,r]),i.callback}function Oq(e){let t=xq(kq).current;return jq(t,e)&&Mq(t,e),t.callback}function kq(){return{callback:null,cleanup:null,refs:[]}}function Aq(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function jq(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Mq(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n;break;default:}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null;break;default:}}}}}}var Nq=typeof document<`u`?C.useLayoutEffect:()=>{},Pq={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},Fq={...Pq,position:`fixed`,top:0,left:0},Iq={...Pq,position:`absolute`};function Lq(){}Object.freeze([]);var Rq=Object.freeze({});function zq(e,...t){let n=new URL(`https://base-ui.com/production-error`);return n.searchParams.set(`code`,e.toString()),t.forEach(e=>n.searchParams.append(`args[]`,e)),`Base UI error #${e}; visit ${n} for the full message.`}var Bq=18;function Vq(e){return Bq>=e}function Hq(e){if(!C.isValidElement(e))return null;let t=e,n=t.props;return(Vq(19)?n?.ref:t.ref)??null}function Uq(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function Wq(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Gq(e,t){return typeof e==`function`?e(t):e}function Kq(e,t){return typeof e==`function`?e(t):e}var qq={};function Jq(e,t,n,r,i){let a={...eJ(e,qq)};return t&&(a=Xq(a,t)),n&&(a=Xq(a,n)),r&&(a=Xq(a,r)),i&&(a=Xq(a,i)),a}function Yq(e){if(e.length===0)return qq;if(e.length===1)return eJ(e[0],qq);let t={...eJ(e[0],qq)};for(let n=1;n<e.length;n+=1)t=Xq(t,e[n]);return t}function Xq(e,t){return $q(t)?t(e):Zq(e,t)}function Zq(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Uq(e.style,r);break;case`className`:e[n]=rJ(e.className,r);break;default:Qq(n,r)?e[n]=tJ(e[n],r):e[n]=r}}return e}function Qq(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function $q(e){return typeof e==`function`}function eJ(e,t){return $q(e)?e(t):e??qq}function tJ(e,t){return t?e?n=>{if(iJ(n)){let r=n;nJ(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function nJ(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function rJ(e,t){return t?e?t+` `+e:t:e}function iJ(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function aJ(e,t,n={}){let r=t.render,i=oJ(t,n);return n.enabled===!1?null:cJ(e,r,i,n.state??Rq)}function oJ(e,t={}){let{className:n,style:r,render:i}=e,{state:a=Rq,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Gq(n,a):void 0,d=l?Kq(r,a):void 0,f=l?Wq(a,c):Rq,p=l?Uq(f,Array.isArray(s)?Yq(s):s)??Rq:Rq;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=Oq([p.ref,Hq(i),...o]):p.ref=Dq(p.ref,Hq(i),o):Dq(null,null)),l?(u!==void 0&&(p.className=rJ(p.className,u)),d!==void 0&&(p.style=Uq(p.style,d)),p):Rq}var sJ=Symbol.for(`react.lazy`);function cJ(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Jq(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===sJ&&(i=C.Children.toArray(t)[0]),C.cloneElement(i,e)}if(e&&typeof e==`string`)return lJ(e,n);throw Error(zq(8))}function lJ(e,t){return e===`button`?(0,C.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,C.createElement)(`img`,{alt:``,...t,key:t.key}):C.createElement(e,t)}var uJ={...C},dJ=0;function fJ(e,t=`mui`){let[n,r]=C.useState(e),i=e||n;return C.useEffect(()=>{n??(dJ+=1,r(`${t}-${dJ}`))},[n,t]),i}var pJ=uJ.useId;function mJ(e,t){if(pJ!==void 0){let n=pJ();return e??(t?`${t}-${n}`:n)}return fJ(e,t)}function hJ(e){return mJ(e,`base-ui`)}function gJ(){return typeof window<`u`}function _J(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vJ(e){return gJ()?e instanceof Element||e instanceof _J(e).Element:!1}function yJ(e){return gJ()?e instanceof HTMLElement||e instanceof _J(e).HTMLElement:!1}function bJ(e){return!gJ()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof _J(e).ShadowRoot}var xJ=C.createContext(void 0);function SJ(e=!1){let t=C.useContext(xJ);if(t===void 0&&!e)throw Error(zq(16));return t}function CJ(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:C.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function wJ(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=C.useRef(null),o=SJ(!0)!==void 0,s=wq(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=CJ({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=C.useCallback(()=>{let e=a.current;TJ(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return Nq(l,[l]),{getButtonProps:C.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return Jq({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(nJ(e),o?.(e)),e.baseUIHandlerPrevented)return;let r=e.target===e.currentTarget&&!i&&!s()&&!t,a=e.key===`Enter`,c=e.key===` `;r&&((c||a)&&e.preventDefault(),a&&n?.(e))},onKeyUp(e){t||(nJ(e),a?.(e)),!e.baseUIHandlerPrevented&&e.target===e.currentTarget&&!i&&!t&&e.key===` `&&n?.(e)},onPointerDown(e){if(t){e.preventDefault();return}l?.(e)}},i?void 0:{role:`button`},c,u)},[t,c,i,s]),buttonRef:wq(e=>{a.current=e,l()})}}function TJ(e){return yJ(e)&&e.tagName===`BUTTON`}var EJ=C.createContext(void 0);function DJ(){let e=C.useContext(EJ);if(e===void 0)throw Error(zq(63));return e}var OJ=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),kJ={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},AJ={valid(e){return e===null?null:e?{[OJ.valid]:``}:{[OJ.invalid]:``}}},jJ=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),MJ={...AJ,checked(e){return e?{[jJ.checked]:``}:{[jJ.unchecked]:``}}};function NJ(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var PJ=C.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Lq,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function FJ(){return C.useContext(PJ)}var IJ=C.createContext({invalid:void 0,name:void 0,validityData:{state:kJ,errors:[],error:``,value:``,initialValue:null},setValidityData:Lq,disabled:void 0,touched:!1,setTouched:Lq,dirty:!1,setDirty:Lq,filled:!1,setFilled:Lq,focused:!1,setFocused:Lq,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=Rq)=>e,getInputValidationProps:(e=Rq)=>e,inputRef:{current:null},commit:async()=>{}}});function LJ(e=!0){let t=C.useContext(IJ);if(t.setValidityData===Lq&&!e)throw Error(zq(28));return t}function RJ(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=FJ(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=LJ(),f=wq(e.getValue);Nq(()=>{if(!t)return;let e=n;e===void 0&&(e=f()),u.initialValue===null&&e!==null&&d(t=>({...t,initialValue:e}))},[t,d,n,u.initialValue,f]),Nq(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:NJ(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?Vd.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),Nq(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var zJ=C.createContext({controlId:void 0,registerControlId:Lq,labelId:void 0,setLabelId:Lq,messageIds:[],setMessageIds:Lq,getDescriptionProps:e=>e});function BJ(){return C.useContext(zJ)}function VJ(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=BJ(),o=hJ(t),s=n?i:void 0,c=xq(()=>Symbol(`labelable-control`)),l=C.useRef(!1),u=C.useRef(t!=null),d=wq(()=>{!l.current||a===Lq||(l.current=!1,a(c.current,void 0))});return Nq(()=>{if(a===Lq)return;let e;if(n){let n=r?.current;e=vJ(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),C.useEffect(()=>d,[d]),i??o}var HJ=`none`;function UJ(e,t,n,r){let i=!1,a=!1,o=r??Rq;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function WJ(e,t){let n=C.useRef(e),r=wq(t);Nq(()=>{n.current!==e&&r(n.current)},[e,r]),Nq(()=>{n.current=e},[e])}var GJ=C.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,id:a,inputRef:o,name:s,nativeButton:c=!1,onCheckedChange:l,readOnly:u=!1,required:d=!1,disabled:f=!1,render:p,uncheckedValue:m,value:h,...g}=e,{clearErrors:_}=FJ(),{state:v,setTouched:y,setDirty:b,validityData:x,setFilled:w,setFocused:T,shouldValidateOnChange:E,validationMode:D,disabled:O,name:k,validation:A}=LJ(),{labelId:j}=BJ(),M=O||f,N=k??s,P=wq(l),F=C.useRef(null),I=Dq(F,o,A.inputRef),L=C.useRef(null),ee=hJ(),R=VJ({id:a,implicit:!1,controlRef:L}),z=c?void 0:R,[B,te]=yq({controlled:n,default:!!i,name:`Switch`,state:`checked`});RJ({id:ee,commit:A.commit,value:B,controlRef:L,name:N,getValue:()=>B}),Nq(()=>{F.current&&w(F.current.checked)},[F,w]),WJ(B,()=>{_(N),b(B!==x.initialValue),w(B),E()?A.commit(B):A.commit(B,!0)});let{getButtonProps:V,buttonRef:H}=wJ({disabled:M,native:c}),ne={id:c?R:ee,role:`switch`,"aria-checked":B,"aria-readonly":u||void 0,"aria-required":d||void 0,"aria-labelledby":j,onFocus(){M||T(!0)},onBlur(){let e=F.current;!e||M||(y(!0),T(!1),D===`onBlur`&&A.commit(e.checked))},onClick(e){u||M||(e.preventDefault(),F.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},re=C.useMemo(()=>Jq({checked:B,disabled:M,id:z,name:N,required:d,style:N?Iq:Fq,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:I,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=UJ(HJ,e.nativeEvent);P?.(t,n),!n.isCanceled&&te(t)},onFocus(){L.current?.focus()}},A.getInputValidationProps,h===void 0?Rq:{value:h}),[B,M,I,z,N,P,d,te,A,h]),ie=C.useMemo(()=>({...v,checked:B,disabled:M,readOnly:u,required:d}),[v,B,M,u,d]),U=aJ(`span`,e,{state:ie,ref:[t,L,H],props:[ne,A.getValidationProps,g,V],stateAttributesMapping:MJ});return(0,S.jsxs)(EJ.Provider,{value:ie,children:[U,!B&&N&&m!==void 0&&(0,S.jsx)(`input`,{type:`hidden`,name:N,value:m}),(0,S.jsx)(`input`,{...re})]})}),KJ=C.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=LJ(),o=DJ();return aJ(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:MJ,props:i})});function qJ({checked:e,onCheckedChange:t,disabled:n,className:r,ariaLabel:i}){return(0,S.jsx)(GJ,{checked:e,onCheckedChange:t,disabled:n,"aria-label":i,className:l_(`group relative inline-flex h-6 w-10 shrink-0 cursor-pointer items-center rounded-full transition-colors`,`bg-border data-[checked]:bg-accent`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-bg-base`,`disabled:cursor-not-allowed disabled:opacity-50`,r),children:(0,S.jsx)(KJ,{className:l_(`pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform`,`translate-x-1 group-data-[checked]:translate-x-5`)})})}var JJ=null,YJ=!1,XJ={},ZJ=500;function QJ(){if(typeof window>`u`)return null;if(JJ?.state===`closed`&&(JJ=null),!JJ){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;JJ=new e}return JJ}function $J(){JJ&&=(JJ.close().catch(()=>{}),null),QJ()}function eY(){return YJ}function tY(){JJ&&($J(),YJ=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&tY()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&tY()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&tY(),e=t},5e3)}async function nY(){let e=QJ();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),YJ=!1}async function rY(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function iY(e){let t=QJ();if(!t||(await rY(t),t.state!==`running`))return;let{frequencies:n,durationMs:r,attackMs:i,peakGain:a,type:o=`sine`}=e,s=t.currentTime,c=r/1e3,l=i/1e3,u=t.createGain();u.connect(t.destination);let d=s+c*.7;u.gain.setValueAtTime(0,s),u.gain.linearRampToValueAtTime(a,s+l),u.gain.setValueAtTime(a,d),u.gain.linearRampToValueAtTime(0,s+c);let f=n.map(e=>{let n=t.createOscillator();return n.type=o,n.frequency.setValueAtTime(e,s),n.connect(u),n});for(let e of f)e.start(s),e.stop(s+c);let p=f[f.length-1];p.onended=()=>{for(let e of f)e.disconnect();u.disconnect()}}async function aY(){let e=Date.now();if(!(e-(XJ.permission||0)<ZJ)){XJ.permission=e;try{await iY({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function oY(){let e=Date.now();if(!(e-(XJ.idle||0)<ZJ)){XJ.idle=e;try{await iY({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function sY({isOpen:e,onClose:t}){let n=W(e=>e.defaultProjectDir),r=W(e=>e.setDefaultProjectDir),i=W(e=>e.commandPresets),a=W(e=>e.setCommandPresets),o=W(e=>e.defaultPresetId),s=W(e=>e.setDefaultPresetId),c=W(e=>e.sessionSortMode),l=W(e=>e.setSessionSortMode),u=W(e=>e.sessionSortDirection),d=W(e=>e.setSessionSortDirection),f=W(e=>e.sidebarAnchor),p=W(e=>e.setSidebarAnchor),m=W(e=>e.useWebGL),h=W(e=>e.setUseWebGL),g=W(e=>e.fontSize),_=W(e=>e.setFontSize),v=W(e=>e.lineHeight),y=W(e=>e.setLineHeight),b=W(e=>e.letterSpacing),x=W(e=>e.setLetterSpacing),w=W(e=>e.fontOption),T=W(e=>e.setFontOption),E=W(e=>e.customFontFamily),D=W(e=>e.setCustomFontFamily),O=W(e=>e.shortcutModifier),k=W(e=>e.setShortcutModifier),A=W(e=>e.showProjectName),j=W(e=>e.setShowProjectName),M=W(e=>e.showLastUserMessage),N=W(e=>e.setShowLastUserMessage),P=W(e=>e.showSessionIdPrefix),F=W(e=>e.setShowSessionIdPrefix),I=RG(e=>e.theme),L=RG(e=>e.setTheme),ee=W(e=>e.soundOnPermission),R=W(e=>e.setSoundOnPermission),z=W(e=>e.soundOnIdle),B=W(e=>e.setSoundOnIdle),[te,V]=(0,C.useState)(n),[H,ne]=(0,C.useState)(i),[re,ie]=(0,C.useState)(o),[U,ae]=(0,C.useState)(c),[oe,se]=(0,C.useState)(u),[ce,le]=(0,C.useState)(f),[ue,de]=(0,C.useState)(m),[fe,pe]=(0,C.useState)(g),[me,he]=(0,C.useState)(v),[ge,_e]=(0,C.useState)(b),[ve,be]=(0,C.useState)(w),[xe,Se]=(0,C.useState)(E),[Ce,we]=(0,C.useState)(O),[Te,Ee]=(0,C.useState)(A),[De,Oe]=(0,C.useState)(M),[Ae,je]=(0,C.useState)(P),[Me,Ne]=(0,C.useState)(I),[Pe,Fe]=(0,C.useState)(ee),[Ie,Le]=(0,C.useState)(z),[Re,ze]=(0,C.useState)(!0),[Be,Ve]=(0,C.useState)(!1),[He,Ue]=(0,C.useState)(!0),[We,Ge]=(0,C.useState)(!0),[Ke,qe]=(0,C.useState)(!1),[Je,Ye]=(0,C.useState)(!1),[Ze,Qe]=(0,C.useState)(24),[et,tt]=(0,C.useState)(!1),[nt,rt]=(0,C.useState)(!1),[it,at]=(0,C.useState)(``),[ot,st]=(0,C.useState)(``),[ct,lt]=(0,C.useState)(``),ut=(0,C.useRef)(null),ft=(0,C.useRef)(0),mt=(0,C.useRef)(!1);if((0,C.useEffect)(()=>{let t=++ft.current,r=mt.current;if(mt.current=e,ut.current&&=(clearTimeout(ut.current),null),e){if(V(n),ne(i),ie(o),ae(c),se(u),le(f),de(m),pe(g),he(v),_e(b),be(w),Se(E),we(O),Ee(A),Oe(M),je(P),Ne(I),Fe(ee),Le(z),rt(!1),at(``),st(``),lt(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>ze(e.enabled)).catch(()=>{}),Ge(!0),fetch(`/api/settings/terminal-colors`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{ft.current===t&&Ue(e.enabled)}).catch(()=>{}).finally(()=>{ft.current===t&&Ge(!1)}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>Qe(e.hours)).catch(()=>{}),fetch(`/api/settings/prefer-window-name`).then(e=>e.json()).then(e=>qe(e.enabled)).catch(()=>{}),typeof document<`u`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}}else r&&typeof document<`u`&&(ut.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{ut.current&&=(clearTimeout(ut.current),null)}},[i,o,n,c,u,f,m,g,v,b,w,E,O,A,M,P,I,ee,z,e]),(0,C.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=e=>{e.key===`Escape`&&(typeof e.stopPropagation==`function`&&e.stopPropagation(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let ht=e=>{e.preventDefault();let n=te.trim(),i=ue!==m;r(n||`~/Documents/GitHub`),a(H),s(re),l(U),d(oe),p(ce),h(ue),_(fe),y(me),x(ge),T(ve),D(xe),k(Ce),j(Te),N(De),F(Ae),L(Me),R(Pe),B(Ie),t({webglChanged:i})},gt=(e,t)=>{ne(n=>n.map(n=>n.id===e?{...n,...t}:n))},_t=e=>{let t=H.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=H.filter(t=>t.id!==e);ne(n),e===re&&ie(n[0]?.id||`claude`)},yt=()=>{if(!it.trim()||!ot.trim()||H.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:it.trim(),command:ot.trim(),isBuiltIn:!1,agentType:ct||void 0};ne([...H,e]),rt(!1),at(``),st(``),lt(``)},bt=H.length<50,xt=e=>{Ve(!0),ze(e),fetch(`/api/settings/tmux-mouse-mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>ze(!e)).finally(()=>Ve(!1))},St=e=>{Ye(!0),qe(e),fetch(`/api/settings/prefer-window-name`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>qe(!e)).finally(()=>Ye(!1))},Ct=e=>{Ge(!0),Ue(e),fetch(`/api/settings/terminal-colors`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Ue(!e)).finally(()=>Ge(!1))},wt=e=>{let t=Ze;tt(!0),Qe(e),fetch(`/api/settings/history-max-age-hours`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hours:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Qe(t)).finally(()=>tt(!1))};return(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,S.jsxs)(`form`,{onSubmit:ht,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,S.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,S.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,S.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,S.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,S.jsx)(`input`,{value:te,onChange:e=>V(e.target.value),placeholder:Xe,className:`input`,autoFocus:!0})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,S.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,S.jsx)(`select`,{value:re,onChange:e=>ie(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:H.map(e=>(0,S.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,S.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,S.jsx)(`div`,{className:`space-y-3`,children:H.map(e=>(0,S.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,S.jsx)(`input`,{value:e.label,onChange:t=>gt(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,S.jsx)(`button`,{type:`button`,onClick:()=>_t(e.id),className:`btn text-xs px-2 py-1 text-danger hover:bg-danger/10`,children:`Delete`})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,S.jsx)(`input`,{value:e.command,onChange:t=>gt(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,S.jsxs)(`select`,{value:e.agentType||``,onChange:t=>gt(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,S.jsx)(`option`,{value:``,children:`Terminal`}),(0,S.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,S.jsx)(`option`,{value:`codex`,children:`Codex`}),(0,S.jsx)(`option`,{value:`pi`,children:`Pi`}),(0,S.jsx)(`option`,{value:`devin`,children:`Devin`}),(0,S.jsx)(`option`,{value:`grok`,children:`Grok`}),(0,S.jsx)(`option`,{value:`omp`,children:`OMP`})]})]})]},e.id))}),nt?(0,S.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,S.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,S.jsx)(`input`,{value:it,onChange:e=>at(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,S.jsx)(`input`,{value:ot,onChange:e=>st(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsxs)(`select`,{value:ct,onChange:e=>lt(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,S.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,S.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,S.jsx)(`option`,{value:`codex`,children:`Codex Icon`}),(0,S.jsx)(`option`,{value:`pi`,children:`Pi Icon`}),(0,S.jsx)(`option`,{value:`devin`,children:`Devin Icon`}),(0,S.jsx)(`option`,{value:`grok`,children:`Grok Icon`}),(0,S.jsx)(`option`,{value:`omp`,children:`OMP Icon`})]}),(0,S.jsx)(`div`,{className:`flex-1`}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>rt(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,S.jsx)(`button`,{type:`button`,onClick:yt,disabled:!it.trim()||!ot.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,S.jsx)(`button`,{type:`button`,onClick:()=>rt(!0),disabled:!bt,className:`btn text-xs mt-3 w-full`,children:bt?`+ Add Preset`:`Max 50 presets`})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,S.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${U===`created`?`btn-primary`:``}`,onClick:()=>ae(`created`),children:`Created`}),(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${U===`status`?`btn-primary`:``}`,onClick:()=>ae(`status`),children:`Status`}),(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${U===`manual`?`btn-primary`:``}`,onClick:()=>ae(`manual`),children:`Manual`})]}),(0,S.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:U===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:U===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),U===`created`&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`desc`?`btn-primary`:``}`,onClick:()=>se(`desc`),children:`Newest First`}),(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`asc`?`btn-primary`:``}`,onClick:()=>se(`asc`),children:`Oldest First`})]})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sidebar Anchor`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ce===`top`?`btn-primary`:``}`,onClick:()=>le(`top`),children:`Top`}),(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ce===`bottom`?`btn-primary`:``}`,onClick:()=>le(`bottom`),children:`Bottom`})]}),(0,S.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:ce===`bottom`?`Desktop sidebar is mirrored: the first session sits at the bottom, next to the prompt`:`First session at the top of the sidebar`})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,S.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,S.jsx)(qJ,{checked:Te,onCheckedChange:Ee})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,S.jsx)(qJ,{checked:De,onCheckedChange:Oe})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,S.jsx)(qJ,{checked:Ae,onCheckedChange:je})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,S.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`input`,{type:`number`,min:1,max:168,value:Ze,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&&wt(t)},disabled:et,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,S.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,S.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex-1`,children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>void aY(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,S.jsx)(qJ,{checked:Pe,onCheckedChange:e=>{Fe(e),e&&nY()}})]})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex-1`,children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>void oY(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,S.jsx)(qJ,{checked:Ie,onCheckedChange:e=>{Le(e),e&&nY()}})]})]})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,S.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,S.jsx)(qJ,{checked:ue,onCheckedChange:de})]}),ue!==m&&(0,S.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,S.jsx)(qJ,{checked:Re,onCheckedChange:xt,disabled:Be})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Terminal Colors`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Preserve ANSI colors for terminal output. Hibernate then Wake running agents after changing this setting.`})]}),(0,S.jsx)(qJ,{checked:He,onCheckedChange:Ct,disabled:We,ariaLabel:`Enable terminal colors`})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Prefer Window Names`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Label discovered sessions with their tmux window name instead of the session name. Applies immediately.`})]}),(0,S.jsx)(qJ,{checked:Ke,onCheckedChange:St,disabled:Je})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>pe(Math.max(6,fe-1)),className:vt,"aria-label":`Decrease font size`,children:(0,S.jsx)(ye,{width:G.default,height:G.default})}),(0,S.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:fe}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>pe(Math.min(24,fe+1)),className:vt,"aria-label":`Increase font size`,children:(0,S.jsx)(ke,{width:G.default,height:G.default})})]})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:me,onChange:e=>he(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,S.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:me.toFixed(1)})]})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:ge,onChange:e=>_e(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,S.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[ge,`px`]})]})]}),(0,S.jsxs)(`div`,{className:`mt-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,S.jsx)(`select`,{value:ve,onChange:e=>be(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:$e.map(e=>(0,S.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),ve===`custom`&&(0,S.jsx)(`input`,{value:xe,onChange:e=>Se(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,S.jsx)(qJ,{checked:Me===`dark`,onCheckedChange:e=>Ne(e?`dark`:`light`)})]})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,S.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,S.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,S.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${Ce===e?`btn-primary`:``}`,onClick:()=>we(e),children:e===`auto`?`Auto`:pt(e)},e))}),(0,S.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:Ce===`auto`?`Shortcuts: ${pt(dt(`auto`))}+[1-9/N/X/[/]]`:`Shortcuts: ${pt(Ce)}+[1-9/N/X/[/]]`})]})]})}),(0,S.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,S.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var cY=[];function lY(e){C.useEffect(e,cY)}var uY=C.createContext(void 0);function dY(){let e=C.useContext(uY);if(!e)throw Error(zq(73));return e}var fY=Symbol(`NOT_FOUND`);function pY(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function mY(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function hY(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var gY=e=>Array.isArray(e)?e:[e];function _Y(e){let t=Array.isArray(e[0])?e[0]:e;return hY(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function vY(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function yY(e){let t;return{get(n){return t&&e(t.key,n)?t.value:fY},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function bY(e,t){let n=[];function r(e){let r=n.findIndex(n=>t(e,n.key));if(r>-1){let e=n[r];return r>0&&(n.splice(r,1),n.unshift(e)),e.value}return fY}function i(t,i){r(t)===fY&&(n.unshift({key:t,value:i}),n.length>e&&n.pop())}function a(){return n}function o(){n=[]}return{get:r,put:i,getEntries:a,clear:o}}var xY=(e,t)=>e===t;function SY(e){return function(t,n){if(t===null||n===null||t.length!==n.length)return!1;let{length:r}=t;for(let i=0;i<r;i++)if(!e(t[i],n[i]))return!1;return!0}}function CY(e,t){let{equalityCheck:n=xY,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=SY(n),o=0,s=r<=1?yY(a):bY(r,a);function c(){let t=s.get(arguments);if(t===fY){if(t=e.apply(null,arguments),o++,i){let e=s.getEntries().find(e=>i(e.value,t));e&&(t=e.value,o!==0&&o--)}s.put(arguments,t)}return t}return c.clearCache=()=>{s.clear(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}var wY=class{constructor(e){this.value=e}deref(){return this.value}},TY=typeof WeakRef<`u`?WeakRef:wY,EY=0,DY=1;function OY(){return{s:EY,v:void 0,o:null,p:null}}function kY(e,t={}){let n=OY(),{resultEqualityCheck:r}=t,i,a=0;function o(){let t=n,{length:o}=arguments;for(let e=0,n=o;e<n;e++){let n=arguments[e];if(typeof n==`function`||typeof n==`object`&&n){let e=t.o;e===null&&(t.o=e=new WeakMap);let r=e.get(n);r===void 0?(t=OY(),e.set(n,t)):t=r}else{let e=t.p;e===null&&(t.p=e=new Map);let r=e.get(n);r===void 0?(t=OY(),e.set(n,t)):t=r}}let s=t,c;if(t.s===DY)c=t.v;else if(c=e.apply(null,arguments),a++,r){let e=i?.deref?.()??i;e!=null&&r(e,c)&&(c=e,a!==0&&a--),i=typeof c==`object`&&c||typeof c==`function`?new TY(c):c}return s.s=DY,s.v=c,c}return o.clearCache=()=>{n=OY(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function AY(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),pY(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=kY,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=gY(c),p=gY(u),m=_Y(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=vY(m,arguments);return i=h.apply(null,e),i},...p);return Object.assign(g,{resultFunc:o,memoizedResultFunc:h,dependencies:m,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var jY=AY(kY),MY=Object.assign((e,t=jY)=>{mY(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);let n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>MY}),NY=AY({memoize:CY,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),PY=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(zq(1));let s;if(e&&t&&n&&r&&i&&a)s=(o,s,c,l)=>a(e(o,s,c,l),t(o,s,c,l),n(o,s,c,l),r(o,s,c,l),i(o,s,c,l),s,c,l);else if(e&&t&&n&&r&&i)s=(a,o,s,c)=>i(e(a,o,s,c),t(a,o,s,c),n(a,o,s,c),r(a,o,s,c),o,s,c);else if(e&&t&&n&&r)s=(i,a,o,s)=>r(e(i,a,o,s),t(i,a,o,s),n(i,a,o,s),a,o,s);else if(e&&t&&n)s=(r,i,a,o)=>n(e(r,i,a,o),t(r,i,a,o),i,a,o);else if(e&&t)s=(n,r,i,a)=>t(e(n,r,i,a),r,i,a);else if(e)s=e;else throw Error(`Missing arguments`);return s},FY=(...e)=>{let t=new WeakMap,n=1,r=e[e.length-1],i=e.length-1||1,a=r.length-i;if(a>3)throw Error(zq(2));return(i,o,s,c)=>{let l=i.__cacheKey__;l||(l={id:n},i.__cacheKey__=l,n+=1);let u=t.get(l);if(!u){let n=e,i=[void 0,void 0,void 0];switch(a){case 0:break;case 1:n=[...e.slice(0,-1),()=>i[0],r];break;case 2:n=[...e.slice(0,-1),()=>i[0],()=>i[1],r];break;case 3:n=[...e.slice(0,-1),()=>i[0],()=>i[1],()=>i[2],r];break;default:throw Error(zq(2))}u=NY(...n),u.selectorArgs=i,t.set(l,u)}switch(u.selectorArgs[0]=o,u.selectorArgs[1]=s,u.selectorArgs[2]=c,a){case 0:return u(i);case 1:return u(i,o);case 2:return u(i,o,s);case 3:return u(i,o,s,c);default:throw Error(`unreachable`)}}},IY=s((e=>{var t=p();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),LY=s(((e,t)=>{t.exports=IY()})),RY=s((e=>{var t=p(),n=LY();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),zY=s(((e,t)=>{t.exports=RY()})),BY=[],VY=void 0;function HY(){return VY}function UY(e){BY.push(e)}var WY=LY(),GY=zY(),KY=Vq(19)?YY:XY;function qY(e,t,n,r,i){return KY(e,t,n,r,i)}function JY(e,t,n,r,i){let a=C.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,WY.useSyncExternalStore)(e.subscribe,a,a)}UY({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);(r.didChange||!Object.is(r.value,i))&&(t=!0,r.value=i,r.didChange=!1)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,WY.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function YY(e,t,n,r,i){let a=HY();if(!a)return JY(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.didChange=!0)):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i),didChange:!1},a.syncHooks.push(s)),s.value}function XY(e,t,n,r,i){return(0,GY.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var ZY=class{constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return qY(this,e,t,n,r)}},QY=class extends ZY{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){C.useDebugValue(e),Nq(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;Nq(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;Nq(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){C.useDebugValue(e);let n=t!==void 0;Nq(()=>{n&&!Object.is(this.state[e],t)&&super.setState({...this.state,[e]:t})},[e,t,n])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return C.useDebugValue(e),qY(this,this.selectors[e],t,n,r)}useContextCallback(e,t){C.useDebugValue(e);let n=wq(t??Lq);this.context[e]=n}useStateSetter(e){let t=C.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},$Y=null;globalThis.requestAnimationFrame;var eX=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,--this.callbacksCount)}},tX=class e{static create(){return new e}static request(e){return eX.request(e)}static cancel(e){return eX.cancel(e)}currentId=$Y;request(e){this.cancel(),this.currentId=eX.request(()=>{this.currentId=$Y,e()})}cancel=()=>{this.currentId!==$Y&&(eX.cancel(this.currentId),this.currentId=$Y)};disposeEffect=()=>this.cancel};function nX(){let e=xq(tX.create).current;return lY(e.disposeEffect),e}var rX=0,iX=class e{static create(){return new e}currentId=rX;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=rX,t()},e)}isStarted(){return this.currentId!==rX}clear=()=>{this.currentId!==rX&&(clearTimeout(this.currentId),this.currentId=rX)};disposeEffect=()=>this.clear};function aX(){let e=xq(iX.create).current;return lY(e.disposeEffect),e}var oX=0;function sX(e){return oX+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${oX}`}function cX(e){return e?.ownerDocument||document}function lX(e,t){if(typeof e==`string`)return{description:e};if(typeof e==`function`){let n=e(t);return typeof n==`string`?{description:n}:n}return e}var uX=typeof navigator<`u`,dX=gX(),fX=vX(),pX=_X();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),dX.platform===`MacIntel`&&dX.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(dX.platform),uX&&/firefox/i.test(pX);var mX=uX&&/apple/i.test(navigator.vendor);uX&&/Edg/i.test(pX),uX&&/android/i.test(fX)||/android/i.test(pX),uX&&fX.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var hX=pX.includes(`jsdom/`);function gX(){if(!uX)return{platform:``,maxTouchPoints:-1};let e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??-1}}function _X(){if(!uX)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function vX(){if(!uX)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function yX(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function bX(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&bJ(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function xX(e){return`composedPath`in e?e.composedPath()[0]:e.target}function SX(e){if(!e||hX)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var CX=FY(e=>e.toasts,e=>{let t=new Map,n=0,r=0;return e.forEach((e,i)=>{let a=e.transitionStatus===`ending`;t.set(e.id,{value:e,domIndex:i,visibleIndex:a?-1:n,offsetY:r}),r+=e.height||0,a||(n+=1)}),t}),wX={toasts:PY(e=>e.toasts),isEmpty:PY(e=>e.toasts.length===0),toast:PY(CX,(e,t)=>e.get(t)?.value),toastIndex:PY(CX,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:PY(CX,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:PY(CX,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:PY(e=>e.hovering),focused:PY(e=>e.focused),expanded:PY(e=>e.hovering||e.focused),expandedOrOutOfFocus:PY(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:PY(e=>e.prevFocusElement)},TX=class extends QY{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},wX)}setFocused(e){this.set(`focused`,e)}setHovering(e){this.set(`hovering`,e)}setIsWindowFocused(e){this.set(`isWindowFocused`,e)}setPrevFocusElement(e){this.set(`prevFocusElement`,e)}setViewport=e=>{this.set(`viewport`,e)};disposeEffect=()=>()=>{this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear()};removeToast(e){let t=wX.toastIndex(this.state,e);if(t===-1)return;this.state.toasts[t]?.onRemove?.();let n=[...this.state.toasts];n.splice(t,1),this.setToasts(n)}addToast=e=>{let{toasts:t,timeout:n,limit:r}=this.state,i=e.id||sX(`toast`),a={...e,id:i,transitionStatus:`starting`},o=[a,...t],s=o.filter(e=>e.transitionStatus!==`ending`);if(s.length>r){let e=s.length-r,t=s.slice(-e),n=new Set(t.map(e=>e.id));this.setToasts(o.map(e=>{let t=n.has(e.id);return e.limited===t?e:{...e,limited:t}}))}else this.setToasts(o.map(e=>e.limited?{...e,limited:!1}:e));let c=a.timeout??n;return a.type!==`loading`&&c>0&&this.scheduleTimer(i,c,()=>this.closeToast(i)),wX.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=wX.toast(this.state,e)??null;if(!i||i.transitionStatus===`ending`)return;let a={...i,...t};this.setToasts(r.map(n=>n.id===e?{...n,...t}:n));let o=a.timeout??n,s=i?.timeout??n,c=Object.hasOwn(t,`timeout`),l=a.transitionStatus!==`ending`&&a.type!==`loading`&&o>0,u=this.timers.has(e),d=s!==o,f=i?.type===`loading`;if(!l&&u){this.timers.get(e)?.timeout?.clear(),this.timers.delete(e);return}if(l&&(!u||d||c||f)){let t=this.timers.get(e);t&&(t.timeout?.clear(),this.timers.delete(e)),this.scheduleTimer(e,o,()=>this.closeToast(e)),wX.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{wX.toast(this.state,e)?.onClose?.();let{limit:t,toasts:n}=this.state,r=0,i=n.map(n=>{if(n.id===e)return{...n,transitionStatus:`ending`,height:0};if(n.transitionStatus===`ending`)return n;let i=r>=t;return r+=1,n.limited===i?n:{...n,limited:i}}),a=this.timers.get(e);a&&a.timeout&&(a.timeout.clear(),this.timers.delete(e)),this.handleFocusManagement(e),this.setToasts(i)};promiseToast=(e,t)=>{let n=lX(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=lX(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=lX(t.error,e);return this.updateToast(r,{...n,type:`error`,timeout:n.timeout}),Promise.reject(e)});return{}.hasOwnProperty.call(t,`setPromise`)&&t.setPromise(i),i};pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(e=>{if(e.timeout){e.timeout.clear();let t=Date.now()-e.start,n=e.delay-t;e.remaining=n>0?n:0}}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((e,t)=>{e.remaining=e.remaining>0?e.remaining:e.delay,e.timeout??=iX.create(),e.timeout.start(e.remaining,()=>{this.timers.delete(t),e.callback()}),e.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}handleDocumentPointerDown=e=>{if(e.pointerType!==`touch`)return;let t=xX(e);bX(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!wX.expandedOrOutOfFocus(this.state),a=i?iX.create():void 0;a?.start(t,()=>{this.timers.delete(e),n()}),this.timers.set(e,{timeout:a,start:i?r:0,delay:t,remaining:t,callback:n})}setToasts(e){let t={toasts:e};e.length===0&&(t.hovering=!1,t.focused=!1),this.update(t)}handleFocusManagement(e){let t=yX(cX(this.state.viewport));if(!this.state.viewport||!bX(this.state.viewport,t)||!SX(t))return;let n=wX.toasts(this.state),r=wX.toastIndex(this.state,e),i=null,a=r+1;for(;a<n.length;){if(n[a].transitionStatus!==`ending`){i=n[a];break}a+=1}if(!i)for(a=r-1;a>=0;){if(n[a].transitionStatus!==`ending`){i=n[a];break}--a}i?i.ref?.current?.focus():this.restoreFocusToPrevElement()}},EX=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=xq(()=>new TX({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return lY(a.disposeEffect),C.useEffect(function(){if(i)return i[` subscribe`](({action:e,options:t})=>{let n=t.id;e===`promise`&&t.promise?a.promiseToast(t.promise,t):e===`update`&&n?a.updateToast(n,t):e===`close`&&n?a.closeToast(n):a.addToast(t)})},[a,n,i]),a.useSyncedValues({timeout:n,limit:r}),(0,S.jsx)(uY.Provider,{value:a,children:t})},DX=C.forwardRef(function(e,t){let[n,r]=C.useState();Nq(()=>{mX&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,S.jsx)(`span`,{...e,ref:t,style:Fq,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),OX=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),kX=C.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=dY(),s=aX(),c=C.useRef(!1),l=C.useRef(!1),u=o.useState(`isEmpty`),d=o.useState(`toasts`),f=o.useState(`focused`),p=o.useState(`expanded`),m=o.useState(`prevFocusElement`),h=d[0]?.height??0,g=C.useMemo(()=>d.some(e=>e.transitionStatus===`ending`),[d]);C.useEffect(()=>{let e=o.state.viewport;if(!e)return;function t(t){u||t.key===`F6`&&t.target!==e&&(t.preventDefault(),o.setPrevFocusElement(yX(cX(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=_J(e);return n.addEventListener(`keydown`,t),()=>{n.removeEventListener(`keydown`,t)}},[o,u]),C.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=_J(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=xX(n),i=yX(cX(e));(!bX(e,r)||!SX(i))&&o.resumeTimers(),s.start(0,()=>o.setIsWindowFocused(!0))}return t.addEventListener(`blur`,n,!0),t.addEventListener(`focus`,r,!0),()=>{t.removeEventListener(`blur`,n,!0),t.removeEventListener(`focus`,r,!0)}},[o,s,u]),C.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=cX(e);return t.addEventListener(`pointerdown`,o.handleDocumentPointerDown,!0),()=>{t.removeEventListener(`pointerdown`,o.handleDocumentPointerDown,!0)}},[u,o]);function _(e){let t=o.state.viewport;t&&(c.current=!0,e.relatedTarget===t?d[0]?.ref?.current?.focus():o.restoreFocusToPrevElement())}function v(e){e.key===`Tab`&&e.shiftKey&&e.target===o.state.viewport&&(e.preventDefault(),o.restoreFocusToPrevElement(),o.resumeTimers())}C.useEffect(()=>{!o.state.isWindowFocused||g||!l.current||(o.resumeTimers(),o.setHovering(!1),l.current=!1)},[g,o]);function y(){o.pauseTimers(),o.setHovering(!0),l.current=!1}function b(){g?l.current=!0:(o.resumeTimers(),o.setHovering(!1))}function x(){if(c.current){c.current=!1;return}f||SX(cX(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function w(e){!f||bX(o.state.viewport,e.relatedTarget)||(o.setFocused(!1),o.resumeTimers())}let T={tabIndex:-1,role:`region`,"aria-live":`polite`,"aria-atomic":!1,"aria-relevant":`additions text`,"aria-label":`Notifications`,onMouseEnter:y,onMouseMove:y,onMouseLeave:b,onFocus:x,onBlur:w,onKeyDown:v,onClick:x},E={expanded:p},D=aJ(`div`,e,{ref:[t,o.setViewport],state:E,props:[T,{style:{[OX.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,S.jsxs)(C.Fragment,{children:[!u&&m&&(0,S.jsx)(DX,{onFocus:_}),i,!u&&m&&(0,S.jsx)(DX,{onFocus:_})]})}]}),O=C.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,S.jsxs)(C.Fragment,{children:[!u&&m&&(0,S.jsx)(DX,{onFocus:_}),D,!f&&O.length>0&&(0,S.jsx)(`div`,{style:Fq,children:O.map(e=>(0,S.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,S.jsx)(`div`,{children:e.title}),(0,S.jsx)(`div`,{children:e.description})]},e.id))})]})});function AX(e){return Vq(19)?e:e?`true`:void 0}var jX=C.createContext(void 0);function MX(){let e=C.useContext(jX);if(!e)throw Error(zq(66));return e}var NX=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),PX={[NX.startingStyle]:``},FX={[NX.endingStyle]:``},IX={transitionStatus(e){return e===`starting`?PX:e===`ending`?FX:null}};function LX(e){return e==null?e:`current`in e?e.current:e}function RX(e,t=!1,n=!0){let r=nX();return wq((i,a=null)=>{r.cancel();function o(){Vd.flushSync(i)}let s=LX(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=NX.startingStyle;if(!c.hasAttribute(e)){r.request(i);return}let t=new MutationObserver(()=>{c.hasAttribute(e)||(t.disconnect(),i())});t.observe(c,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}function i(){Promise.all(c.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||o()}).catch(()=>{let e=c.getAnimations();if(n){if(a?.aborted)return;o()}else e.length>0&&e.some(e=>e.pending||e.playState!==`finished`)&&i()})}if(t){e();return}r.request(i)}})}function zX(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=wq(i),o=RX(r,n,!1);C.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var BX=function(e){return e.index=`--toast-index`,e.offsetY=`--toast-offset-y`,e.height=`--toast-height`,e.swipeMovementX=`--toast-swipe-movement-x`,e.swipeMovementY=`--toast-swipe-movement-y`,e}({}),VX={...IX,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},HX=40,UX=10,WX=.5,GX=1;function KX(e,t,n){switch(e){case`up`:return-n;case`down`:return n;case`left`:return-t;case`right`:return t;default:return 0}}function qX(e){let t=window.getComputedStyle(e).transform,n=0,r=0,i=1;if(t&&t!==`none`){let e=t.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){let t=e[1].split(`, `).map(parseFloat);t.length===6?(n=t[4],r=t[5],i=Math.sqrt(t[0]*t[0]+t[1]*t[1])):t.length===16&&(n=t[12],r=t[13],i=t[0])}}return{x:n,y:r,scale:i}}var JX=C.forwardRef(function(e,t){let{toast:n,render:r,className:i,swipeDirection:a=[`down`,`right`],...o}=e,s=n.positionerProps?.anchor!==void 0,c=[];s||(c=Array.isArray(a)?a:[a]);let l=c.length>0,u=dY(),[d,f]=C.useState(void 0),[p,m]=C.useState(!1),[h,g]=C.useState(!1),[_,v]=C.useState(!1),[y,b]=C.useState({x:0,y:0}),[x,w]=C.useState({x:0,y:0,scale:1}),[T,E]=C.useState(),[D,O]=C.useState(),[k,A]=C.useState(null),j=C.useRef(null),M=C.useRef({x:0,y:0}),N=C.useRef({x:0,y:0,scale:1}),P=C.useRef(void 0),F=C.useRef(0),I=C.useRef(!1),L=C.useRef({x:0,y:0}),ee=C.useRef(!1),R=u.useState(`toastIndex`,n.id),z=u.useState(`toastVisibleIndex`,n.id),B=u.useState(`toastOffsetY`,n.id),te=u.useState(`focused`),V=u.useState(`expanded`);zX({open:n.transitionStatus!==`ending`,ref:j,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let H=wq((e=!1)=>{let t=j.current;if(!t)return;let r=t.style.height;t.style.height=`auto`;let i=t.offsetHeight;t.style.height=r;function a(){u.updateToastInternal(n.id,{ref:j,height:i,...n.transitionStatus===`starting`?{transitionStatus:void 0}:{}})}e?Vd.flushSync(a):a()});Nq(H,[H]);function ne(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**WX:-(Math.abs(e)**WX):(!c.includes(`right`)&&e>0&&(n=e**WX),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**WX))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**WX:-(Math.abs(t)**WX):(!c.includes(`down`)&&t>0&&(r=t**WX),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**WX))),{x:n,y:r}}function re(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=xX(e.nativeEvent);if(!(t&&t.closest(`button,a,input,textarea,[role="button"],[data-swipe-ignore]`))){if(I.current=!1,P.current=void 0,F.current=0,M.current={x:e.clientX,y:e.clientY},L.current=M.current,j.current){let e=qX(j.current);N.current=e,w(e),b({x:e.x,y:e.y})}u.setHovering(!0),m(!0),g(!1),A(null),ee.current=!0,j.current?.setPointerCapture(e.pointerId)}}function ie(e){if(!p)return;e.preventDefault(),ee.current&&=(M.current={x:e.clientX,y:e.clientY},!1);let{clientY:t,clientX:n,movementX:r,movementY:i}=e;(i<0&&t>L.current.y||i>0&&t<L.current.y)&&(L.current={x:L.current.x,y:t}),(r<0&&n>L.current.x||r>0&&n<L.current.x)&&(L.current={x:n,y:L.current.y});let a=n-M.current.x,o=t-M.current.y,s=t-L.current.y,l=n-L.current.x;if(!h&&Math.sqrt(a*a+o*o)>=GX&&(g(!0),k===null)){let e=c.includes(`left`)||c.includes(`right`),t=c.includes(`up`)||c.includes(`down`);e&&t&&A(Math.abs(a)>Math.abs(o)?`horizontal`:`vertical`)}let u;if(!P.current)k===`vertical`?o>0?u=`down`:o<0&&(u=`up`):k===`horizontal`?a>0?u=`right`:a<0&&(u=`left`):u=Math.abs(a)>=Math.abs(o)?a>0?`right`:`left`:o>0?`down`:`up`,u&&c.includes(u)&&(P.current=u,F.current=KX(u,a,o),f(u));else{let e=P.current,t=KX(e,l,s);t>HX?(I.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&F.current-t>=UX&&(I.current=!0)}let d=ne(a,o),m=N.current.x,_=N.current.y;k===`horizontal`?(c.includes(`left`)||c.includes(`right`))&&(m+=d.x):(k===`vertical`||(c.includes(`left`)||c.includes(`right`))&&(m+=d.x),(c.includes(`up`)||c.includes(`down`))&&(_+=d.y)),b({x:m,y:_})}function U(e){if(!p)return;if(m(!1),g(!1),A(null),j.current?.releasePointerCapture(e.pointerId),I.current){b({x:x.x,y:x.y}),f(void 0);return}let t=!1,r=y.x-x.x,i=y.y-x.y,a;for(let e of c){switch(e){case`right`:r>HX&&(t=!0,a=`right`);break;case`left`:r<-HX&&(t=!0,a=`left`);break;case`down`:i>HX&&(t=!0,a=`down`);break;case`up`:i<-HX&&(t=!0,a=`up`);break;default:break}if(t)break}t?(f(a),v(!0),u.closeToast(n.id)):(b({x:x.x,y:x.y}),f(void 0))}function ae(e){if(e.key===`Escape`){if(!j.current||!bX(j.current,yX(cX(j.current))))return;u.closeToast(n.id)}}C.useEffect(()=>{if(!l)return;let e=j.current;if(!e)return;function t(t){bX(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function oe(){if(!p&&y.x===x.x&&y.y===x.y&&!_)return{[BX.swipeMovementX]:`0px`,[BX.swipeMovementY]:`0px`};let e=y.x-x.x,t=y.y-x.y;return{transition:p?`none`:void 0,transform:p?`translateX(${y.x}px) translateY(${y.y}px) scale(${x.scale})`:void 0,[BX.swipeMovementX]:`${e}px`,[BX.swipeMovementY]:`${t}px`}}let se=n.priority===`high`,ce={role:se?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":T,"aria-describedby":D,"aria-hidden":se&&!te?!0:void 0,onPointerDown:l?re:void 0,onPointerMove:l?ie:void 0,onPointerUp:l?U:void 0,onKeyDown:ae,inert:AX(n.limited),style:{...oe(),[BX.index]:n.transitionStatus===`ending`?R:z,[BX.offsetY]:`${B}px`,[BX.height]:n.height?`${n.height}px`:void 0}},le=C.useMemo(()=>({rootRef:j,toast:n,titleId:T,setTitleId:E,descriptionId:D,setDescriptionId:O,swiping:p,swipeDirection:d,recalculateHeight:H,index:R,visibleIndex:z,expanded:V}),[n,T,D,p,d,H,R,z,V]),ue={transitionStatus:n.transitionStatus,expanded:V,limited:n.limited||!1,type:n.type,swiping:le.swiping,swipeDirection:le.swipeDirection},de=aJ(`div`,e,{ref:[t,le.rootRef],state:ue,stateAttributesMapping:VX,props:[ce,o]});return(0,S.jsx)(jX.Provider,{value:le,children:de})}),YX=C.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=MX(),l=a??s.description,u=!!l,d=mJ(i);Nq(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=aJ(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),XX=C.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=MX(),l=a??s.title,u=!!l,d=mJ(i);Nq(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=aJ(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),ZX=C.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=dY(),{toast:c}=MX(),l=s.useState(`expanded`),[u,d]=C.useState(!1),{getButtonProps:f,buttonRef:p}=wJ({disabled:i,native:a}),m={type:c.type};return aJ(`button`,e,{ref:[t,p],state:m,props:[{"aria-hidden":!l&&!u,onClick(){s.closeToast(c.id)},onFocus(){d(!0)},onBlur(){d(!1)}},o,f]})});function QX(){let e=C.useContext(uY);if(!e)throw Error(zq(73));let t=e.useState(`toasts`);return C.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function $X(){let e=new Set;function t(t){e.forEach(e=>e(t))}return{" subscribe":function(t){return e.add(t),()=>{e.delete(t)}},add(e){let n=e.id||sX(`toast`);return t({action:`add`,options:{...e,id:n,transitionStatus:`starting`}}),n},close(e){t({action:`close`,options:{id:e}})},update(e,n){t({action:`update`,options:{...n,id:e}})},promise(e,n){let r=e;return t({action:`promise`,options:{...n,promise:e,setPromise(e){r=e}}}),r}}}var eZ=5e3,tZ=$X();function nZ({toast:e}){return(0,S.jsxs)(JX,{toast:e,className:l_(`relative flex w-80 items-start gap-3 border bg-elevated p-4 shadow-lg`,`data-[swipe=move]:translate-x-[var(--toast-swipe-move-x)]`,`data-[ending-style]:translate-x-[var(--toast-swipe-end-x)]`,`data-[ending-style]:opacity-0`,`data-[starting-style]:translate-y-2 data-[starting-style]:opacity-0`,`transition-all duration-200`,e.type===`error`&&`border-danger/50`,e.type===`success`&&`border-approval/50`,(!e.type||e.type===`info`)&&`border-border`),children:[(0,S.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,S.jsx)(XX,{className:l_(`text-sm font-medium`,e.type===`error`&&`text-danger`,e.type===`success`&&`text-approval`,(!e.type||e.type===`info`)&&`text-primary`),children:e.title}),e.description&&(0,S.jsx)(YX,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,S.jsx)(ZX,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,S.jsx)(Fe,{width:G.default,height:G.default})})]})}function rZ(){let{toasts:e}=QX();return(0,S.jsx)(S.Fragment,{children:e.map(e=>(0,S.jsx)(nZ,{toast:e},e.id))})}function iZ(){return(0,S.jsxs)(EX,{timeout:eZ,toastManager:tZ,children:[(0,S.jsx)(rZ,{}),(0,S.jsx)(kX,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var aZ=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],oZ=3e3,sZ=8e3,cZ=15e3,lZ=5e3,uZ=2e4,dZ=1e4,fZ=1500,pZ=5e3,mZ=750,hZ=4,gZ=5e3,_Z=new class{constructor(){this.ws=null,this.listeners=new Set,this.statusListeners=new Set,this.status=`connecting`,this.error=null,this.reconnectAttempts=0,this.reconnectTimer=null,this.connectTimer=null,this.manualClose=!1,this.lastTick=Date.now(),this.wakeCheckInterval=null,this.lifecycleStarted=!1,this.heartbeatTimer=null,this.pongTimer=null,this.lastForceReconnectTs=0,this.lastConnectTs=0,this.pingSeq=0,this.connectionEpoch=0,this.consecutiveFailures=0,this.stallCount=0,this.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{if(KO(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,KO(`ws_resume`,{gapMs:t,...this.wsSnap()},`info`),this.ws?.readyState===WebSocket.OPEN?this.verifyConnection():this.forceReconnect(`visibilitychange`,!0)}else this.stopHeartbeat(),this.cancelVerify(),this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null)},this.onPageShow=e=>{KO(`ws_pageshow`,{persisted:e.persisted,...this.wsSnap()},`info`),e.persisted&&(this.lastTick=Date.now(),this.forceReconnect(`pageshow`,!0))}}wsSnap(){return{status:this.status,ws:this.ws?aZ[this.ws.readyState]:null,attempt:this.reconnectAttempts,failures:this.consecutiveFailures,stalls:this.stallCount,leaked:this.leakedSockets.size,online:typeof navigator<`u`?navigator.onLine:void 0,verifying:this.verifyTimer!==null,buffered:this.ws?this.ws.bufferedAmount:void 0}}connect(){if(this.ws){let e=this.ws.readyState===WebSocket.OPEN;if(e&&this.status===`connected`){KO(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){KO(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}KO(`ws_connect_destroy_zombie`,{reason:e?`open_desynced`:`not_open`,...this.wsSnap()}),this.destroySocket()}this.manualClose=!1,this.clearConnectTimer(),this.setStatus(`connecting`);let e=`${window.location.protocol===`https:`?`wss`:`ws`}://${window.location.host}/ws`;KO(`ws_connect`,{url:e,resume:this.isResumeAttempt,...this.wsSnap()},`info`);let t=new WebSocket(e);this.ws=t,this.lastConnectTs=Date.now(),this.leakedSockets.add(t);let n=this.isResumeAttempt?sZ:oZ;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(KO(`ws_connect_timeout`,{wsState:aZ[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){KO(`ws_onopen_stale`,this.wsSnap(),`info`);return}KO(`ws_onopen`,this.wsSnap(),`info`),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=0,this.stallCount=0,this.connectionEpoch+=1,this.leakedSockets.delete(t),this.setStatus(`connected`),this.startHeartbeat()},t.onmessage=e=>{try{let t=e.data,n=performance.now(),r=JSON.parse(t),i=performance.now()-n,a=r;if(a._parseMs=Math.round(i),a._rawLength=t.length,r.type===`pong`){r.seq===this.pingSeq&&(this.clearPongTimer(),this.verifyTimer!==null&&(this.cancelVerify(),KO(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(pZ)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(KO(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){KO(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}KO(`ws_onclose`,{code:e.code,reason:e.reason,clean:e.wasClean,...this.wsSnap()},`info`),this.clearConnectTimer(),this.cancelVerify(),this.consecutiveFailures+=1,this.ws=null,this.manualClose?this.setStatus(`disconnected`):this.scheduleReconnect()}}disconnect(){this.manualClose=!0,this.clearConnectTimer(),this.cancelVerify(),this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null),this.destroySocket(),this.setStatus(`disconnected`)}startLifecycleListeners(){this.lifecycleStarted||typeof document>`u`||typeof window>`u`||(this.lifecycleStarted=!0,document.addEventListener(`visibilitychange`,this.onVisibilityChange),window.addEventListener(`pageshow`,this.onPageShow),this.lastTick=Date.now(),this.wakeCheckInterval=window.setInterval(()=>{let e=Date.now(),t=e-this.lastTick;this.isHidden()||(t>cZ&&(KO(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},lZ))}stopLifecycleListeners(){this.lifecycleStarted&&(this.lifecycleStarted=!1,document.removeEventListener(`visibilitychange`,this.onVisibilityChange),window.removeEventListener(`pageshow`,this.onPageShow),this.wakeCheckInterval!==null&&(window.clearInterval(this.wakeCheckInterval),this.wakeCheckInterval=null))}send(e){if(this.ws?.readyState!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(e)),!0}catch(t){return KO(`ws_send_error`,{messageType:e.type,error:t instanceof Error?t.message:String(t),...this.wsSnap()},`info`),this.destroySocket(),this.scheduleReconnect(),!1}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}subscribeStatus(e){return this.statusListeners.add(e),e(this.status,this.error,this.connectionEpoch),()=>this.statusListeners.delete(e)}getStatus(){return this.status}getConnectionEpoch(){return this.connectionEpoch}verifyConnection(){this.cancelVerify(),this.stopHeartbeat(),this.pingSeq+=1;let e=this.pingSeq,t=this.ws;if(KO(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){KO(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(KO(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},fZ)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){KO(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){KO(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){KO(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,KO(`ws_force_reconnect`,{trigger:e,force:t,...this.wsSnap()},`info`),this.reconnectAttempts=0,this.consecutiveFailures=0,this.stallCount=0,this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null),this.destroySocket(),t?(this.purgeLeakedSockets(),this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},mZ)):this.connect()}startHeartbeat(e){this.stopHeartbeat();let t=()=>{this.ws?.readyState===WebSocket.OPEN&&(this.pingSeq+=1,this.send({type:`ping`,seq:this.pingSeq})&&(this.clearPongTimer(),this.pongTimer=window.setTimeout(()=>{this.pongTimer=null,KO(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},dZ)))};e!==void 0&&e<uZ?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,uZ)},e):this.heartbeatTimer=window.setInterval(t,uZ)}stopHeartbeat(){this.heartbeatTimer!==null&&(window.clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null),this.clearPongTimer()}clearPongTimer(){this.pongTimer!==null&&(window.clearTimeout(this.pongTimer),this.pongTimer=null)}setStatus(e,t=null){this.status=e,this.error=t,this.statusListeners.forEach(n=>n(e,t,this.connectionEpoch))}scheduleReconnect(){if(this.stopHeartbeat(),this.isHidden()){KO(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=hZ){KO(`ws_stall_detected`,this.wsSnap(),`info`),this.purgeLeakedSockets();let e=Math.min(gZ*2**this.stallCount,3e4);this.stallCount+=1,this.consecutiveFailures=0,this.reconnectAttempts=0,this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},e);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);KO(`ws_schedule_reconnect`,{delay:e,...this.wsSnap()}),this.setStatus(`reconnecting`),this.reconnectTimer&&window.clearTimeout(this.reconnectTimer),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}isHidden(){return typeof document<`u`&&document.visibilityState===`hidden`}clearConnectTimer(){this.connectTimer&&=(window.clearTimeout(this.connectTimer),null)}destroySocket(){if(this.clearConnectTimer(),this.stopHeartbeat(),this.cancelVerify(),!this.ws)return;let e=this.ws;this.ws=null,this.leakedSockets.add(e),e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}purgeLeakedSockets(){if(this.leakedSockets.size!==0){KO(`ws_purge_leaked`,{count:this.leakedSockets.size},`info`);for(let e of this.leakedSockets)try{e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,e.close()}catch{}this.leakedSockets.clear()}}};function vZ(){let e=Sh(e=>e.setConnectionState);return(0,C.useEffect)(()=>{_Z.connect(),_Z.startLifecycleListeners();let t=_Z.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),_Z.stopLifecycleListeners()}},[e]),{sendMessage:(0,C.useMemo)(()=>e=>{_Z.send(e)},[]),subscribe:(0,C.useMemo)(()=>_Z.subscribe.bind(_Z),[]),getConnectionEpoch:(0,C.useMemo)(()=>()=>_Z.getConnectionEpoch(),[])}}var yZ=100;function bZ({viewport:e,win:t,doc:n}){if(!e)return!1;let r=Math.max(0,e.offsetTop||0),i=Math.max(0,e.offsetLeft||0),a=t.innerHeight-(e.height+r),o=Math.max(0,a),s=Math.max(0,e.height||0),c=Math.max(0,e.width||0);return n.documentElement.style.setProperty(`--keyboard-inset`,`${o}px`),n.documentElement.style.setProperty(`--viewport-offset-top`,`${r}px`),n.documentElement.style.setProperty(`--viewport-offset-left`,`${i}px`),n.documentElement.style.setProperty(`--visual-viewport-height`,`${s}px`),n.documentElement.style.setProperty(`--visual-viewport-width`,`${c}px`),o>yZ?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function xZ(e){e.documentElement.style.removeProperty(`--keyboard-inset`),e.documentElement.style.removeProperty(`--viewport-offset-top`),e.documentElement.style.removeProperty(`--viewport-offset-left`),e.documentElement.style.removeProperty(`--visual-viewport-height`),e.documentElement.style.removeProperty(`--visual-viewport-width`),e.documentElement.classList.remove(`keyboard-visible`)}function SZ(){(0,C.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=null,n=null,r=()=>{let e=document.activeElement;if(!e)return!1;let t=e.tagName?.toLowerCase();return t===`input`||t===`textarea`?!0:!!e.isContentEditable},i=()=>{bZ({viewport:e,win:window,doc:document})},a=()=>{if(typeof window.requestAnimationFrame!=`function`){i();return}t!==null&&window.cancelAnimationFrame(t);let e=performance.now(),n=()=>{i(),t=performance.now()-e<1500?window.requestAnimationFrame(n):null};t=window.requestAnimationFrame(n)},o=()=>{if(!r()){c();return}i()},s=()=>{n!==null||typeof window.setInterval!=`function`||(n=window.setInterval(o,250),o())},c=()=>{n===null||typeof window.clearInterval!=`function`||(window.clearInterval(n),n=null)},l=()=>{r()?(a(),s(),i()):c()},u=()=>{l()},d=()=>{l()},f=()=>{a()};return i(),l(),e.addEventListener(`resize`,i),e.addEventListener(`scroll`,i),typeof window.addEventListener==`function`&&(window.addEventListener(`resize`,i),window.addEventListener(`orientationchange`,f)),typeof document.addEventListener==`function`&&(document.addEventListener(`focusin`,u),document.addEventListener(`focusout`,d),document.addEventListener(`focus`,u,!0),document.addEventListener(`blur`,d,!0)),()=>{e.removeEventListener(`resize`,i),e.removeEventListener(`scroll`,i),typeof window.removeEventListener==`function`&&(window.removeEventListener(`resize`,i),window.removeEventListener(`orientationchange`,f)),typeof document.removeEventListener==`function`&&(document.removeEventListener(`focusin`,u),document.removeEventListener(`focusout`,d),document.removeEventListener(`focus`,u,!0),document.removeEventListener(`blur`,d,!0)),t!==null&&typeof window.cancelAnimationFrame==`function`&&window.cancelAnimationFrame(t),c(),xZ(document)}},[])}var CZ=[`theme`,`commandPresets`,`defaultPresetId`,`defaultProjectDir`,`lastProjectPath`,`recentPaths`,`sessionSortMode`,`sessionSortDirection`,`manualSessionOrder`,`sidebarAnchor`,`projectFilters`,`hostFilters`],wZ=[`claude`,`claude-rp`,`codex`,`pi`,`devin`,`grok`,`omp`];function TZ(e,t){return Array.isArray(e)&&e.length<=t&&e.every(e=>typeof e==`string`)}function EZ(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.id==`string`&&t.id.length>=1&&t.id.length<=128&&typeof t.label==`string`&&t.label.trim().length>=1&&t.label.length<=64&&typeof t.command==`string`&&t.command.trim().length>=1&&t.command.length<=1024&&typeof t.isBuiltIn==`boolean`&&(t.agentType===void 0||wZ.includes(t.agentType))}var DZ={theme:e=>e===`dark`||e===`light`,commandPresets:e=>Array.isArray(e)&&e.length<=50&&e.every(EZ),defaultPresetId:e=>typeof e==`string`&&e.length<=128,defaultProjectDir:e=>typeof e==`string`&&e.length<=4096,lastProjectPath:e=>e===null||typeof e==`string`&&e.length<=4096,recentPaths:e=>TZ(e,50),sessionSortMode:e=>e===`status`||e===`created`||e===`manual`,sessionSortDirection:e=>e===`asc`||e===`desc`,manualSessionOrder:e=>TZ(e,1e3),sidebarAnchor:e=>e===`top`||e===`bottom`,projectFilters:e=>TZ(e,500),hostFilters:e=>TZ(e,500)};function OZ(e){return CZ.includes(e)}function kZ(e,t){return DZ[e](t)}var AZ=`agentboard-theme`,jZ=`agentboard-settings`,MZ=200,NZ=new Map,PZ=new Set,FZ=null,IZ=!1;function LZ(e){return e===`theme`?RG.getState().theme:W.getState()[e]}function RZ(e){let t=e===`theme`?AZ:jZ;return Je.getItem(t)!==null}function zZ(){if(FZ=null,PZ.size===0)return;let e={};for(let t of PZ){let n=LZ(t);e[t]=n,NZ.set(t,JSON.stringify(n))}PZ.clear();try{fetch(`/api/settings/synced`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({settings:e})}).then(e=>{e.ok||KO(`synced_settings_push_rejected`,{status:e.status},`warn`)}).catch(e=>{KO(`synced_settings_push_failed`,{message:e instanceof Error?e.message:String(e)},`warn`)})}catch(e){KO(`synced_settings_push_failed`,{message:e instanceof Error?e.message:String(e)},`warn`)}}function BZ(e){PZ.add(e),!FZ&&(FZ=setTimeout(zZ,MZ))}function VZ(e){let t=new Map;for(let e of CZ)t.set(e,RZ(e));let n={},r;for(let[t,i]of Object.entries(e))!OZ(t)||!kZ(t,i)||(NZ.set(t,JSON.stringify(i)),t===`theme`?r=i:n[t]=i);r!==void 0&&RG.setState({theme:r}),Object.keys(n).length>0&&W.setState(n);for(let n of CZ){if(n in e||!t.get(n))continue;let r=LZ(n);kZ(n,r)&&NZ.get(n)!==JSON.stringify(r)&&BZ(n)}}function HZ(){if(IZ)return()=>{};IZ=!0;let e=W.subscribe((e,t)=>{let n=e,r=t;for(let e of CZ)e!==`theme`&&n[e]!==r[e]&&NZ.get(e)!==JSON.stringify(n[e])&&BZ(e)}),t=RG.subscribe((e,t)=>{e.theme!==t.theme&&NZ.get(`theme`)!==JSON.stringify(e.theme)&&BZ(`theme`)});return()=>{e(),t(),IZ=!1,FZ&&=(clearTimeout(FZ),null),PZ.clear(),NZ.clear()}}function UZ(e,t,n){let r=e;return t.length>0&&(r=r.filter(e=>t.includes(e.projectPath))),n.length>0&&(r=r.filter(e=>n.includes(e.host??``))),r}function WZ(){let[e,t]=(0,C.useState)(!1),[n,r]=(0,C.useState)(void 0),[i,a]=(0,C.useState)(void 0),[o,s]=(0,C.useState)(void 0),[c,l]=(0,C.useState)(!1),[u,d]=(0,C.useState)(null),[f,p]=(0,C.useState)(null),[m,h]=(0,C.useState)(null),g=Sh(e=>e.sessions),_=Sh(e=>e.agentSessions),v=Sh(e=>e.agentSessionsEpoch),y=Sh(e=>e.selectedSessionId),b=Sh(e=>e.selectedHibernatingSessionId),x=Sh(e=>e.setSessions),w=Sh(e=>e.setAgentSessions),T=Sh(e=>e.setActiveAgentSessions),E=Sh(e=>e.setHostStatuses),D=Sh(e=>e.updateSession),O=Sh(e=>e.setSelectedSessionId),k=Sh(e=>e.setSelectedHibernatingSessionId),A=Sh(e=>e.hasLoaded),j=Sh(e=>e.connectionStatus),M=Sh(e=>e.connectionError),N=Sh(e=>e.clearExitingSession),P=Sh(e=>e.markSessionExiting),F=Sh(e=>e.setRemoteAllowControl),I=Sh(e=>e.setRemoteAllowAttach),L=Sh(e=>e.setHostLabel),ee=Sh(e=>e.setPreferWindowName),R=Sh(e=>e.hostStatuses),z=Sh(e=>e.remoteAllowControl),B=Sh(e=>e.hostLabel),te=RG(e=>e.theme),V=st(),H=W(e=>e.defaultProjectDir),ne=W(e=>e.commandPresets),re=W(e=>e.defaultPresetId),ie=W(e=>e.lastProjectPath),U=W(e=>e.setLastProjectPath),ae=W(e=>e.addRecentPath),oe=W(e=>e.shortcutModifier),se=W(e=>e.sidebarWidth),ce=W(e=>e.sidebarAnchor),le=W(e=>e.setSidebarWidth),ue=W(e=>e.projectFilters),de=W(e=>e.hostFilters),fe=W(e=>e.soundOnPermission),pe=W(e=>e.soundOnIdle),me=Sh(e=>e.connectionEpoch),{sendMessage:he,subscribe:ge,getConnectionEpoch:_e}=vZ();(0,C.useEffect)(()=>HZ(),[]),SZ(),(0,C.useEffect)(()=>{if(typeof document>`u`||!fe&&!pe)return;let e=!1,t=()=>{e&&!eY()||(e=!0,nY())};return document.addEventListener(`click`,t,{passive:!0}),document.addEventListener(`keydown`,t,{passive:!0}),document.addEventListener(`touchstart`,t,{passive:!0}),()=>{document.removeEventListener(`click`,t),document.removeEventListener(`keydown`,t),document.removeEventListener(`touchstart`,t)}},[fe,pe]);let ve=(0,C.useRef)(!1),ye=(0,C.useCallback)(e=>{e.preventDefault(),ve.current=!0,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[]);(0,C.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=e=>{if(!ve.current)return;let t=e.clientX;le(Math.max(180,Math.min(400,t)))},t=()=>{ve.current&&(ve.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[le]),(0,C.useEffect)(()=>{let e=ge(e=>{if(e.type!==`terminal-output`){if(e.type===`sessions`){let t=Sh.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=W.getState();if(n||r)for(let i of e.sessions){let e=t.find(e=>e.id===i.id);e&&e.status!==i.status&&(e.status!==`permission`&&i.status===`permission`&&n&&aY(),e.status===`working`&&i.status===`waiting`&&r&&oY())}if(Fe.current.size>0){let e=_e();for(let[t,n]of Fe.current)n.epoch!==e&&Fe.current.delete(t)}let i=Fe.current.size>0?e.sessions.filter(e=>!Fe.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=Sh.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(je.current=s),x(i);let c=Me.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=Sh.getState(),{projectFilters:d,hostFilters:f}=W.getState();if(c&&l===null&&u===null){let e=i.find(e=>!(e.agentSessionId?.trim()!==c||d.length>0&&!d.includes(e.projectPath)||f.length>0&&!f.includes(e.host??``)));e&&(Me.current=null,O(e.id))}}if(e.type===`host-status`&&E(e.hosts),e.type===`server-config`&&(F(e.remoteAllowControl),I(e.remoteAllowAttach),L(e.hostLabel),ee(e.preferWindowName),e.clientLogLevel&&GO(e.clientLogLevel)),e.type===`synced-settings`&&VZ(e.settings),e.type===`session-update`){let t=Sh.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(D(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=W.getState();t!==`permission`&&n===`permission`&&e&&aY(),t===`working`&&n===`waiting`&&r&&oY()}}if(e.type===`session-created`){let t=Sh.getState().sessions;t.some(t=>t.id===e.session.id)||x([e.session,...t]),O(e.session.id),ae(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=W.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){aG(e.sessionId);let t=Sh.getState().sessions,n=t.filter(t=>t.id!==e.sessionId);n.length!==t.length&&x(n)}if(e.type===`agent-sessions`){let t=Array.isArray(e.active)?e.active:[],n=Array.isArray(e.hibernating)?e.hibernating:[],r=Array.isArray(e.history)?e.history:[],{selectedHibernatingSessionId:i}=Sh.getState(),a=je.current;i&&!n.some(e=>e.sessionId===i)&&(Me.current=i),w(t,n,r),h(e=>e&&n.some(t=>t.sessionId===e.sessionId)?null:e),a&&n.some(e=>e.sessionId===a)?(je.current=null,k(a)):a&&(je.current=null)}if(e.type===`agent-sessions-active`&&T(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=Sh.getState().sessions,n=t.filter(t=>t.agentSessionId?.trim()!==e.session.sessionId);n.length!==t.length&&x(n)}if(e.type===`session-activated`){let t=Sh.getState().sessions.find(t=>t.tmuxWindow===e.window);t&&D({...t,agentSessionId:e.session.sessionId,agentSessionName:e.session.displayName,logFilePath:e.session.logFilePath,isHibernating:e.session.isHibernating,lastUserMessage:e.session.lastUserMessage??t.lastUserMessage})}if(e.type===`session-wake-result`)if(e.ok&&e.session){h(t=>t?.sessionId===e.sessionId?null:t);let t=Sh.getState().sessions;t.some(t=>t.id===e.session.id)||x([e.session,...t]),O(e.session.id)}else e.ok||(d(`${e.error?.code}: ${e.error?.message}`),window.setTimeout(()=>d(null),6e3));if(e.type===`session-hibernate-result`&&(e.ok?(e.session&&h(e.session),k(e.sessionId)):(d(e.error??`Failed to hibernate session`),window.setTimeout(()=>d(null),6e3))),e.type===`terminal-error`&&(!e.sessionId||e.sessionId===y)&&(d(`${e.code}: ${e.message}`),window.setTimeout(()=>d(null),6e3)),e.type===`terminal-ready`&&e.sessionId===y&&d(null),e.type===`error`&&(d(e.message),window.setTimeout(()=>d(null),6e3)),e.type===`kill-failed`){let t=Fe.current.get(e.sessionId);if(t){let n=Sh.getState().sessions;n.some(t=>t.id===e.sessionId)||x([t.session,...n]),t.wasSelected&&O(e.sessionId),Fe.current.delete(e.sessionId)}N(e.sessionId),d(e.message),window.setTimeout(()=>d(null),6e3)}e.type===`session-move-to-history-result`&&!e.ok&&e.error&&(d(e.error),window.setTimeout(()=>d(null),6e3))}});return()=>{e()}},[y,b,ae,N,he,O,k,h,x,w,T,E,F,I,L,ee,ge,D]);let be=(0,C.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),xe=_.hibernating??[],Se=_.history??[],Ce=(0,C.useMemo)(()=>UZ(xe,ue,de),[xe,ue,de]),we=(0,C.useMemo)(()=>Ce.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[Ce,m,b]);(0,C.useEffect)(()=>{be?.projectPath&&!be.remote&&U(be.projectPath)},[be?.projectPath,be?.remote,U]);let Te=W(e=>e.sessionSortMode),Ee=W(e=>e.sessionSortDirection),De=W(e=>e.manualSessionOrder),Oe=(0,C.useMemo)(()=>oh(g,{mode:Te,direction:Ee,manualOrder:De}),[g,Te,Ee,De]),ke=(0,C.useMemo)(()=>{let e=Oe;return ue.length>0&&(e=e.filter(e=>ue.includes(e.projectPath))),de.length>0&&(e=e.filter(e=>de.includes(e.host??``))),e},[Oe,ue,de]),Ae=(0,C.useRef)(b),je=(0,C.useRef)(null),Me=(0,C.useRef)(null),Ne=(0,C.useRef)(me),Pe=(0,C.useCallback)(()=>ke.length>0?(O(ke[0].id),!0):Ce.length>0?(k(Ce[0].sessionId),!0):!1,[ke,Ce,O,k]);(0,C.useEffect)(()=>{let e=Ae.current;e&&b===null&&!xe.some(t=>t.sessionId===e)?Me.current=e:b!==null&&(Me.current=null),Ae.current=b},[xe,b]),(0,C.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,C.useEffect)(()=>{Ne.current!==me&&(Ne.current=me,je.current=null,Me.current=null,h(null))},[me]),(0,C.useEffect)(()=>{A&&(b||y&&(ke.some(e=>e.id===y)||Pe()||O(null)))},[A,y,b,Pe,O]),(0,C.useEffect)(()=>{if(!b||m?.sessionId===b||v!==me||Ce.some(e=>e.sessionId===b))return;let e=ke.find(e=>e.agentSessionId?.trim()===b);if(e){O(e.id);return}Pe()||k(null)},[Ce,ke,v,m,b,Pe,O,k,me]),(0,C.useEffect)(()=>{let e=Me.current;if(!e)return;if(b!==null){Me.current=null;return}let t=ke.find(t=>t.agentSessionId?.trim()===e);if(t){Me.current=null,O(t.id);return}if(y!==null){Me.current=null;return}Pe()&&(Me.current=null)},[ke,y,b,Pe,O]),(0,C.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&A&&y===null&&b===null&&(ke.length>0||Ce.length>0)&&Pe()},[Ce.length,ke.length,A,Pe,y,b]);let Fe=(0,C.useRef)(new Map),Ie=(0,C.useCallback)((e,t=`unknown`)=>{aG(e);let{sessions:n,selectedSessionId:r}=Sh.getState(),i=n.find(t=>t.id===e);i&&Fe.current.set(e,{session:i,wasSelected:r===e,epoch:_e()}),(0,Vd.flushSync)(()=>{P(e),x(n.filter(t=>t.id!==e))}),he({type:`session-kill`,sessionId:e,source:t})},[P,x,he]);(0,C.useEffect)(()=>{let n=dt(oe),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=mt(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=i===`BracketLeft`?-1:1,t=ke;if(t.length===0){let t=Ce;if(t.length===0)return;let n=t.findIndex(e=>e.sessionId===b);if(n===-1){k(t[0].sessionId);return}k(t[(n+e+t.length)%t.length].sessionId);return}let n=t.findIndex(e=>e.id===y);if(n===-1){O(t[0].id);return}O(t[(n+e+t.length)%t.length].id);return}if(a&&/^Digit[1-9]$/.test(i)){let e=Number(i.slice(5))-1;if(ke.length>0){let t=ke[e];if(!t)return;r.preventDefault(),O(t.id);return}let t=Ce[e];if(!t)return;r.preventDefault(),k(t.sessionId);return}if(a&&i===`KeyN`){r.preventDefault(),!e&&V&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Ie(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,O,k,ke,Ce,Ie,oe,V]);let Le=()=>V?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,Re=()=>l(!0),ze=(e,t,n,r)=>{he({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||U(e)},Be=e=>{he({type:`session-wake`,sessionId:e})},Ve=(0,C.useCallback)(e=>{he({type:`session-hibernate`,sessionId:e})},[he]),He=(e,t)=>{he({type:`session-rename`,sessionId:e,newName:t})},Ue=(0,C.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&he({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,he]),We=(0,C.useCallback)(e=>{he({type:`session-move-to-history`,sessionId:e})},[he]);(0,C.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,te)},[te]),(0,C.useEffect)(()=>{fetch(`/api/server-info`).then(e=>e.json()).then(e=>p(e)).catch(()=>{})},[]);let Ge=(0,C.useMemo)(()=>B?R.filter(e=>e.host!==B):R,[R,B]);return(0,S.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,S.jsx)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:se},children:(0,S.jsx)(BO,{sessions:g,hibernatingSessions:xe,historySessions:Se,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:O,onSelectHibernating:k,onRename:He,onResume:Be,onHibernate:Ve,onKill:Ie,onDuplicate:Ue,onMoveToHistory:We,onNewSession:Le,loading:!A,error:M||u,anchor:ce,filterBarControls:(0,S.jsx)(Et,{connectionStatus:j,onNewSession:Le,onOpenSettings:Re,tailscaleIp:f?.tailscaleIp??null,placement:ce===`bottom`?`up`:`down`})})}),(0,S.jsx)(`div`,{className:`hidden md:block w-1 shrink-0 cursor-col-resize bg-transparent transition-colors hover:bg-white/10 active:bg-white/20`,onMouseDown:ye}),(0,S.jsx)($K,{session:be,sessions:ke,drawerSessions:g,hibernatingSession:we,hibernatingSessions:xe,connectionStatus:j,connectionEpoch:me,sendMessage:he,subscribe:ge,onClose:()=>O(null),onSelectSession:O,onSelectHibernatingSession:k,onNewSession:Le,onKillSession:Ie,onRenameSession:He,onDuplicateSession:Ue,onOpenSettings:Re,onResumeSession:Be,onHibernateSession:Ve,onMoveToHistory:We,historySessions:Se,loading:!A,error:M||u}),(0,S.jsx)(vq,{isOpen:e,onClose:()=>t(!1),onCreate:ze,defaultProjectDir:H,commandPresets:ne,defaultPresetId:re,lastProjectPath:ie,activeProjectPath:be&&!be.remote?be.projectPath:void 0,remoteHosts:Ge,remoteAllowControl:z,initialHost:n,initialPath:i,initialCommand:o}),(0,S.jsx)(sY,{isOpen:c,onClose:()=>l(!1)}),(0,S.jsx)(iZ,{})]})}var GZ=`modulepreload`,KZ=function(e){return`/`+e},qZ={},JZ=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=KZ(t,n),t in qZ)return;qZ[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:GZ,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},YZ=`true`,XZ=`false`,ZZ=YZ===`true`,QZ=XZ===`true`;function $Z(e={}){let{immediate:t=!1,onNeedRefresh:n,onOfflineReady:r,onRegistered:i,onRegisteredSW:a,onRegisterError:o}=e,s,c,l,u=async(e=!0)=>{await c,ZZ||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await JZ(async()=>{let{Workbox:e}=await import(`./workbox-window.prod.es5-Bq4GJJid.js`);return{Workbox:e}},[]).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{o?.(e)}),!s)return;if(l=()=>{s?.messageSkipWaiting()},!QZ)if(ZZ)s.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&window.location.reload()}),s.addEventListener(`installed`,e=>{e.isUpdate||r?.()});else{let e=!1,t=()=>{e=!0,s?.addEventListener(`controlling`,e=>{e.isUpdate&&window.location.reload()}),n?.()};s.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&r?.():n.isExternal?t():!e&&r?.():n.isUpdate||r?.()}),s.addEventListener(`waiting`,t)}s.register({immediate:t}).then(e=>{a?a(`/sw.js`,e):i?.(e)}).catch(e=>{o?.(e)})}}return c=d(),u}ct()&&document.documentElement.classList.add(`ios`),lt()&&document.documentElement.classList.add(`ios-pwa`),$Z({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var eQ=document.getElementById(`root`);if(!eQ)throw Error(`Root element not found`);(0,x.createRoot)(eQ).render((0,S.jsx)(C.StrictMode,{children:(0,S.jsx)(WZ,{})}));
306
+ `,onClick:()=>{QK(),d(t.id)},title:ht?t.name:void 0,children:i},t.id)})})]}),(0,S.jsxs)(`div`,{className:`relative flex-1`,children:[(0,S.jsx)(`div`,{ref:Me,className:`absolute inset-0`,style:{backgroundColor:E.background}}),Be&&e&&(0,S.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`absolute top-2 left-2 z-50 flex items-center gap-1.5 rounded-lg bg-black/60 px-2.5 py-1.5 text-xs text-white/90 shadow-lg backdrop-blur-md`,children:[(0,S.jsx)(Ie,{width:G.pill,height:G.pill,className:`animate-spin`}),`Loading`]}),He&&e&&(0,S.jsxs)(`div`,{className:`absolute ${L&&!R?`bottom-20`:`bottom-8`} left-1/2 z-30 flex max-w-[calc(100%-2rem)] -translate-x-1/2 items-center gap-2 rounded-lg border border-border bg-elevated/95 px-2 py-2 shadow-lg backdrop-blur-sm md:hidden`,children:[(0,S.jsx)(`span`,{className:`max-w-[12rem] truncate text-xs text-secondary md:max-w-[18rem]`,children:`Selection ready`}),(0,S.jsxs)(`button`,{type:`button`,onClick:Ue,className:`relative flex h-8 shrink-0 items-center justify-center gap-1.5 rounded bg-accent px-2.5 text-xs font-medium text-white hover:bg-accent/90 active:scale-95 transition-all [@media(pointer:coarse)]:before:absolute [@media(pointer:coarse)]:before:inset-[calc(50%-22px)] [@media(pointer:coarse)]:before:content-['']`,title:`Copy selection`,"aria-label":`Copy selection`,children:[(0,S.jsx)(F,{width:G.default,height:G.default}),`Copy`]}),(0,S.jsx)(`button`,{type:`button`,onClick:We,className:`relative flex h-8 w-8 shrink-0 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all [@media(pointer:coarse)]:before:absolute [@media(pointer:coarse)]:before:inset-[calc(50%-22px)] [@media(pointer:coarse)]:before:content-['']`,title:`Dismiss`,"aria-label":`Dismiss`,children:(0,S.jsx)(Fe,{width:G.default,height:G.default})})]}),!e&&(0,S.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted`,children:r?null:`Select a session to view terminal`}),e&&Ce&&(0,S.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-center text-sm text-muted`,children:`Remote session (read-only). Use SSH to attach on the host.`}),r&&(0,S.jsx)(`div`,{className:`absolute inset-0 z-10 overflow-y-auto bg-base`,children:(0,S.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col gap-4 p-4 md:p-6`,children:[(0,S.jsx)(`div`,{className:`border-b border-border pb-4`,children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,S.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,S.jsx)(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-primary`,children:Te}),(0,S.jsx)(`span`,{className:`rounded-full bg-blue-500/15 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-blue-400`,children:`Hibernating`}),Ee&&(0,S.jsx)(`span`,{className:`text-muted`,children:Ee}),(0,S.jsxs)(`span`,{className:`text-muted`,children:[`Last active `,De]})]}),r.lastResumeError&&(0,S.jsxs)(`div`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/15 px-2 py-1 text-xs text-amber-400`,title:`Last wake failed: ${r.lastResumeError}`,children:[(0,S.jsx)(T,{width:G.pill,height:G.pill}),`Last wake failed`]}),r.lastUserMessage&&(0,S.jsx)(`p`,{className:`max-h-28 max-w-3xl overflow-y-auto whitespace-pre-wrap break-words pr-2 text-sm leading-6 text-secondary`,children:r.lastUserMessage})]}),(0,S.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>_(r.sessionId),className:`btn btn-primary hidden md:inline-flex`,children:`Wake`}),y&&(0,S.jsx)(`button`,{type:`button`,onClick:()=>y(r.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,S.jsx)(DO,{session:r})]})}),Le&&e&&!R?(0,S.jsxs)(`button`,{type:`button`,onClick:Ge,className:`absolute bottom-14 left-1/2 z-20 flex h-10 items-center justify-center rounded-full border border-amber-400/35 bg-amber-500/20 text-amber-100 shadow-lg backdrop-blur-sm transition-all hover:bg-amber-500/30 active:scale-95 md:hidden ${St}`,style:{transform:`translateX(-50%)`},title:`Exit tmux copy mode and return to live output`,"aria-label":`Exit copy mode`,children:[(0,S.jsx)(`span`,{className:`px-3 text-[11px] font-semibold uppercase tracking-wide`,children:`Copy mode`}),(0,S.jsx)(`span`,{className:`self-stretch border-l border-amber-400/25`,"aria-hidden":`true`}),(0,S.jsx)(`span`,{className:`px-3 text-sm font-medium`,children:`Exit`})]}):L&&e&&!R?(0,S.jsxs)(`button`,{type:`button`,onClick:Ge,className:`absolute bottom-8 left-1/2 z-20 flex h-10 px-4 items-center justify-center gap-1.5 rounded-full bg-blue-600/90 text-white shadow-lg hover:bg-blue-600 active:scale-95 transition-all md:hidden ${St}`,style:{transform:`translateX(-50%)`},title:`Scroll to bottom`,"aria-label":`Scroll to bottom`,children:[(0,S.jsx)(D,{width:G.primary,height:G.primary}),(0,S.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]}):null]}),(0,S.jsx)(NK,{...ut}),(0,S.jsx)(iK,{session:e,hibernatingSession:r,hibernatingDisplayName:Te,showHostBadge:Ae,sessionCount:t.length,connectionStatus:o,isSwitching:Be,canControl:we,canHibernate:Oe,modDisplay:N,onKill:()=>H(!0),onHibernate:Ye,onWake:()=>r&&_(r.sessionId),onRename:t=>{let n=e?.id??r?.sessionId;n&&h(n,t)},onDuplicate:e&&g?()=>g(e.id):void 0,onMoveToHistory:r&&y?()=>y(r.sessionId):void 0,isTmuxCopyMode:Le,showJumpToBottom:L&&!R,onJumpToBottom:Ge,selectionReady:!!He,onCopySelection:Ue,onDismissSelection:We}),e&&(0,S.jsx)(JK,{onSendKey:at,onPasteText:ot,onPasteImage:st,disabled:o!==`connected`||Ce||!Ve,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,agentType:e.agentType,fileUploadsAllowed:!ve,onSelectSession:d,hideSessionSwitcher:!0,onRefocus:lt,isKeyboardVisible:mt,onEnterTextMode:ft}),(I||P)&&(0,S.jsx)(YK,{isOpen:ie,onClose:()=>U(!1),sessions:n??t,hibernatingSessions:i,historySessions:a,selectedSessionId:e?.id??null,selectedHibernatingSessionId:r?.sessionId??null,onSelect:d,onSelectHibernating:f,onRename:h,onResume:_,onHibernate:v,onMoveToHistory:y,onNewSession:p,loading:x,error:w}),te&&e&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,S.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,S.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,S.jsxs)(`p`,{className:`text-sm text-secondary mb-4 text-pretty`,children:[`Kill "`,e.agentSessionName||e.name,`"? The process will be terminated. Conversation history is preserved in logs.`]}),(0,S.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,S.jsx)(`button`,{onClick:()=>H(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,S.jsx)(`button`,{ref:me,onClick:Je,className:`btn btn-danger py-1.5 px-3 text-sm`,children:`Kill Session`})]})]})})]})}function eq({onSelect:e,onCancel:t,initialPath:n}){let[r,i]=(0,C.useState)(n||`~`),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(null),[l,u]=(0,C.useState)(!0),[d,f]=(0,C.useState)(-1),p=(0,C.useRef)(null),m=W(e=>e.recentPaths),h=(0,C.useCallback)(async e=>{p.current?.abort();let t=new AbortController;p.current=t;let{signal:n}=t;u(!0),c(null),o(null),f(-1),i(e);try{let r=await fetch(`/api/directories?path=${encodeURIComponent(e)}`,{signal:n});if(!r.ok){let e=await r.json();throw Error(e.message||`Failed to load directory`)}let a=await r.json();if(p.current!==t)return;o(a),i(a.path)}catch(e){if(p.current!==t)return;let n=e;n?.name!==`AbortError`&&c(n?.message||`Failed to load directory`)}finally{p.current===t&&u(!1)}},[]);(0,C.useEffect)(()=>(h(n||`~`),()=>{p.current?.abort()}),[h,n]);let g=a?.directories??[],_=a?.path||r,v=a?.parent;return(0,C.useEffect)(()=>{let n=n=>{if(n.key===`Escape`){n.preventDefault(),t();return}if(!l){if(n.key===`ArrowDown`){n.preventDefault(),f(e=>g.length===0?-1:e<0?0:Math.min(e+1,g.length-1));return}if(n.key===`ArrowUp`){n.preventDefault(),f(e=>g.length===0?-1:e<0?g.length-1:Math.max(e-1,0));return}if(n.key===`Enter`){n.preventDefault();let t=g[d];t?h(t.path):_&&e(_);return}n.key===`Backspace`&&v&&(n.preventDefault(),h(v))}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[g,_,h,d,l,t,e,v]),(0,S.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Directory browser`,className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},"data-testid":`directory-browser`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,S.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,S.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,S.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,S.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,S.jsx)(`p`,{className:`text-danger`,children:s}),(0,S.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,S.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,S.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,S.jsxs)(`button`,{type:`button`,onClick:()=>h(e.path),onMouseEnter:()=>f(t),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-xs ${t===d?`bg-hover text-primary`:`text-secondary`}`,"data-testid":`directory-entry`,"data-entry-name":e.name,"data-entry-path":e.path,children:[(0,S.jsx)(ae,{width:G.default,height:G.default,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,S.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,S.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,S.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,S.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,S.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,S.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,S.jsx)(`button`,{type:`button`,className:`block w-full truncate text-left text-xs text-secondary hover:text-primary`,onClick:()=>h(e),title:e,"data-testid":`directory-recent`,"data-recent-path":e,children:e},e))})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function tq(e){let t=e.trim();if(t.length>=2){let e=t[0],n=t[t.length-1];if(e===`'`&&n===`'`)return t.slice(1,-1).replace(/'\\''/g,`'`);if(e===`"`&&n===`"`)return t.slice(1,-1).replace(/\\"/g,`"`).replace(/\\\\/g,`\\`)}return t}function nq(e){let t=e.trim(),n=t.search(/\s/);if(n===-1||t.slice(0,n).split(`/`).pop()!==`bash`)return null;let r=n;for(;r<t.length&&/\s/.test(t[r]);)r++;let i=!1,a=!1;for(;r<t.length;){let e=r;for(;r<t.length&&!/\s/.test(t[r]);)r++;let n=t.slice(e,r);for(;r<t.length&&/\s/.test(t[r]);)r++;if(!n.startsWith(`-`)||n===`-`)return null;if(n===`--`)break;if(n.startsWith(`--`)||!/^-[a-zA-Z]+$/.test(n))continue;let o=n.slice(1);if(o.includes(`l`)&&(i=!0),o.includes(`c`)){a=!0;break}}if(!i||!a)return null;let o=t.slice(r).trim();return o?tq(o):null}function rq(e){return e?e===`claude-rp`?`claude`:e:null}function iq(e){let t=e.trim();if(!t)return``;let n=tq(t);return nq(n)??n}function aq(e){if(e===`claude`)return`claude`;if(e===`codex`)return`codex`;if(e===`pi`)return`pi`;if(e===`devin`||e===`devin-cli`)return`devin`;if(e===`grok`||e.startsWith(`grok-`))return`grok`;if(e===`omp`)return`omp`}function oq(e){let t=/\S+/g,n;for(;n=t.exec(e);){let e=n[0].toLowerCase().replace(/^["']+|["']+$/g,``);if([`npx`,`bunx`,`pnpm`,`yarn`,`env`].includes(e)||e.includes(`=`)||e.startsWith(`-`))continue;let t=e.includes(`@oh-my-pi/`)?`omp`:aq(e.split(`/`).pop()||e);return t?{agentType:t,end:n.index+n[0].length}:void 0}}function sq(e){let t=iq(e);if(t)return oq(t.toLowerCase().trim().replace(/^["']|["']$/g,``))?.agentType}var cq={claude:`--dangerously-skip-permissions`,codex:`--yolo`,grok:`--always-approve`,devin:`--permission-mode dangerous`,pi:null,omp:`--auto-approve`},lq={claude:[`--dangerously-skip-permissions`,`--permission-mode bypassPermissions`,`--permission-mode=bypassPermissions`],codex:[`--yolo`,`--dangerously-bypass-approvals-and-sandbox`],grok:[`--always-approve`,`--yolo`,`--dangerously-skip-permissions`,`--permission-mode bypassPermissions`,`--permission-mode=bypassPermissions`],devin:[`--permission-mode dangerous`,`--permission-mode=dangerous`],pi:[],omp:[`--auto-approve`,`--approval-mode yolo`,`--approval-mode=yolo`]};function uq(e){let t=rq(e);return t?cq[t]:null}function dq(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function fq(e){return RegExp(`(^|\\s)${dq(e)}(?=\\s|$)`,`g`)}function pq(e,t){return(t?[rq(t)].filter(e=>e!==null):Object.keys(lq)).some(t=>lq[t].some(t=>fq(t).test(e)))}function mq(e,t){let n=oq(e);return n?`${e.slice(0,n.end)} ${t}${e.slice(n.end)}`:null}function hq(e,t){let n=uq(t);if(!n)return e;let r=e.trim();if(!r||pq(r,t))return r;let i=mq(r,n);if(i)return i;let a=iq(r);if(a&&a!==r){let e=mq(a,n);if(e)return`bash -lc '${e.replace(/'/g,`'\\''`)}'`}return`${r} ${n}`}function gq(e,t){let n=rq(t);if(!n||pq(e,t))return null;if(n===`codex`){let t=/(^|\s)(--full-auto|--ask-for-approval|-a)(?=\s|=|$)/.exec(e);if(t)return`conflicts with ${t[2]}`}if(n===`omp`){let t=/(^|\s)--approval-mode(?:\s+|=)(always-ask|write)/.exec(e);if(t)return`conflicts with --approval-mode ${t[2]}`}let r=/(^|\s)--permission-mode(?:\s+|=)(\S+)/.exec(e);return r&&n!==`codex`?`conflicts with --permission-mode ${r[2]}`:null}function _q(e,t){let n=rq(t);if(!n)return e;let r=e;for(let e of lq[n])r=r.replace(fq(e),` `);return r.replace(/\s+/g,` `).trim()}function vq({isOpen:e,onClose:t,onCreate:n,defaultProjectDir:r,commandPresets:i,defaultPresetId:a,lastProjectPath:o,activeProjectPath:s,remoteHosts:c=[],remoteAllowControl:l=!1,initialHost:u,initialPath:d,initialCommand:f}){let[p,m]=(0,C.useState)(``),[h,g]=(0,C.useState)(``),[_,v]=(0,C.useState)(null),[y,b]=(0,C.useState)(``),[x,w]=(0,C.useState)(!1),[T,E]=(0,C.useState)(``),D=W(e=>e.yoloMode),O=W(e=>e.setYoloMode),k=(0,C.useRef)(null),A=(0,C.useRef)(null),j=(0,C.useRef)(null),M=(0,C.useRef)(!1),N=l&&c.length>0,P=e=>{if(!D)return e;let t=sq(e);return t&&!gq(e,t)?hq(e,t):e},F=e=>{let t=i.find(t=>t.id===e);t&&(v(e),b(P(it(t))))},I=()=>{v(null),b(``)};if((0,C.useEffect)(()=>{let t=M.current;if(M.current=e,!e){m(``),g(``),v(null),b(``),w(!1),E(u??``),t&&setTimeout(()=>{if(typeof document>`u`||typeof document.querySelector!=`function`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300);return}if(typeof document<`u`&&typeof document.querySelector==`function`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}m(d?.trim()||s?.trim()||o||r||``),g(``),E(u??``);let n=f?.trim();if(n){let e=i.find(e=>it(e)===n);e?(v(e.id),b(it(e))):(v(null),b(n))}else{let e=i.find(e=>e.id===a);e?(v(a),b(P(it(e)))):i.length>0?(v(i[0].id),b(P(it(i[0])))):(v(null),b(``))}setTimeout(()=>{if(j.current?.focus(),A.current){let e=A.current;e.scrollLeft=e.scrollWidth}},50)},[s,i,a,r,e,o,u,d,f]),(0,C.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=()=>k.current?Array.from(k.current.querySelectorAll(`input:not([disabled]), select:not([disabled]), button:not([disabled]):not([tabindex="-1"]), [tabindex="0"]`)):[],r=e=>{if(!x){if(e.key===`Escape`){typeof e.stopPropagation==`function`&&e.stopPropagation(),t();return}if(e.key===`Enter`){let t=document.activeElement;if(!t||t.tagName===`INPUT`||t.closest(`[data-testid="host-select"]`)||!t.closest(`[data-testid="command-select"]`))return;e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation(),k.current?.requestSubmit();return}if(/^[0-9]$/.test(e.key)&&!e.metaKey&&!e.ctrlKey&&!e.altKey){let t=document.activeElement;if(t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable))return;let n;if(e.key===`0`)n=i.length;else if(n=Number(e.key)-1,n>=i.length)return;e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation(),n===i.length?I():F(i[n].id),(k.current?.querySelectorAll?.(`[data-testid="command-select"] [role="radio"]`))?.[n]?.focus();return}if(e.key===`Tab`){e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation();let t=n();if(t.length===0)return;let r=document.activeElement,i=t.indexOf(r),a;a=i===-1?e.shiftKey?t.length-1:0:e.shiftKey?i<=0?t.length-1:i-1:i>=t.length-1?0:i+1,t[a]?.focus()}}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,t,x,i,D]),!e)return null;let L=_===null,ee=T!==``,R=sq(y),z=uq(R)!==null,B=R?pq(y,R):!1,te=R&&!B?gq(y,R):null,V=!z||te!==null,H=R?R===`pi`?`Pi has no permission prompts — nothing to enable`:te??`Append ${uq(R)}`:`Enter a supported agent command (claude, codex, grok, devin)`,ne=e=>{O(e),R&&b(e?hq(y,R):_q(y,R))},re=e=>{e.preventDefault();let r=p.trim();if(!r)return;let i=y.trim();n(r,h.trim()||void 0,i||void 0,ee?T:void 0),t()},ie=[...i.map(e=>({id:e.id,label:e.label,isCustom:!1,agentType:e.agentType,command:e.command})),{id:`custom`,label:`Custom`,isCustom:!0,agentType:void 0,command:void 0}],U=[{id:``,label:`Local`,ok:!0,error:void 0},...c.map(e=>({id:e.host,label:e.host,ok:e.ok,error:e.error}))],ae=p.trim()||`~`;return(0,S.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-session-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:[(0,S.jsxs)(`form`,{ref:k,onSubmit:re,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,S.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,S.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[N&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,S.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Host`,"data-testid":`host-select`,children:U.map((e,t)=>{let n=T===e.id,r=!e.ok&&!n;return(0,S.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":e.label,title:e.ok?void 0:e.error||`Unreachable`,tabIndex:n?0:-1,onClick:()=>E(e.id),onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%U.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+U.length)%U.length;else return;let r=U[n];E(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``} ${r?`opacity-60`:``}`,children:e.label},e.id||`local`)})})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,S.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Command preset`,"data-testid":`command-select`,children:ie.map((e,t)=>{let n=e.isCustom?L:_===e.id,r=e.isCustom?`0`:t<9?String(t+1):null;return(0,S.jsxs)(`button`,{ref:n?j:void 0,type:`button`,role:`radio`,"aria-checked":n,"aria-keyshortcuts":r??void 0,tabIndex:n?0:-1,onClick:()=>{e.isCustom?I():F(e.id)},onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%ie.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+ie.length)%ie.length;else return;let r=ie[n];r.isCustom?I():F(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``}`,children:[r&&(0,S.jsx)(`kbd`,{"aria-hidden":`true`,className:`shortcut-badge`,children:r}),(0,S.jsx)(Bh,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,S.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`}),(0,S.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-xs ${V?`text-muted opacity-60`:`text-secondary`}`,title:H,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:B,disabled:V,onChange:e=>ne(e.target.checked)}),`yolo mode — skip permission prompts`]})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(`input`,{ref:A,value:p,onChange:e=>m(e.target.value),placeholder:ee?`/home/user/project`:s||o||r||`/Users/you/code/my-project`,className:`input flex-1 text-sm`}),!ee&&(0,S.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>w(!0),children:`Browse`})]})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,S.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,S.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,S.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),x&&!ee&&(0,S.jsx)(eq,{initialPath:ae,onSelect:e=>{m(e),w(!1)},onCancel:()=>w(!1)})]})}function yq({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=C.useRef(e!==void 0),[a,o]=C.useState(t);return[i?e:a,C.useCallback(e=>{i||o(e)},[])]}var bq={};function xq(e,t){let n=C.useRef(bq);return n.current===bq&&(n.current=e(t)),n}var Sq=C[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],Cq=Sq&&Sq!==C.useLayoutEffect?Sq:e=>e();function wq(e){let t=xq(Tq).current;return t.next=e,Cq(t.effect),t.trampoline}function Tq(){let e={next:void 0,callback:Eq,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Eq(){}function Dq(e,t,n,r){let i=xq(kq).current;return Aq(i,e,t,n,r)&&Mq(i,[e,t,n,r]),i.callback}function Oq(e){let t=xq(kq).current;return jq(t,e)&&Mq(t,e),t.callback}function kq(){return{callback:null,cleanup:null,refs:[]}}function Aq(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function jq(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Mq(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n;break;default:}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null;break;default:}}}}}}var Nq=typeof document<`u`?C.useLayoutEffect:()=>{},Pq={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},Fq={...Pq,position:`fixed`,top:0,left:0},Iq={...Pq,position:`absolute`};function Lq(){}Object.freeze([]);var Rq=Object.freeze({});function zq(e,...t){let n=new URL(`https://base-ui.com/production-error`);return n.searchParams.set(`code`,e.toString()),t.forEach(e=>n.searchParams.append(`args[]`,e)),`Base UI error #${e}; visit ${n} for the full message.`}var Bq=18;function Vq(e){return Bq>=e}function Hq(e){if(!C.isValidElement(e))return null;let t=e,n=t.props;return(Vq(19)?n?.ref:t.ref)??null}function Uq(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function Wq(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Gq(e,t){return typeof e==`function`?e(t):e}function Kq(e,t){return typeof e==`function`?e(t):e}var qq={};function Jq(e,t,n,r,i){let a={...eJ(e,qq)};return t&&(a=Xq(a,t)),n&&(a=Xq(a,n)),r&&(a=Xq(a,r)),i&&(a=Xq(a,i)),a}function Yq(e){if(e.length===0)return qq;if(e.length===1)return eJ(e[0],qq);let t={...eJ(e[0],qq)};for(let n=1;n<e.length;n+=1)t=Xq(t,e[n]);return t}function Xq(e,t){return $q(t)?t(e):Zq(e,t)}function Zq(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Uq(e.style,r);break;case`className`:e[n]=rJ(e.className,r);break;default:Qq(n,r)?e[n]=tJ(e[n],r):e[n]=r}}return e}function Qq(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function $q(e){return typeof e==`function`}function eJ(e,t){return $q(e)?e(t):e??qq}function tJ(e,t){return t?e?n=>{if(iJ(n)){let r=n;nJ(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function nJ(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function rJ(e,t){return t?e?t+` `+e:t:e}function iJ(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function aJ(e,t,n={}){let r=t.render,i=oJ(t,n);return n.enabled===!1?null:cJ(e,r,i,n.state??Rq)}function oJ(e,t={}){let{className:n,style:r,render:i}=e,{state:a=Rq,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Gq(n,a):void 0,d=l?Kq(r,a):void 0,f=l?Wq(a,c):Rq,p=l?Uq(f,Array.isArray(s)?Yq(s):s)??Rq:Rq;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=Oq([p.ref,Hq(i),...o]):p.ref=Dq(p.ref,Hq(i),o):Dq(null,null)),l?(u!==void 0&&(p.className=rJ(p.className,u)),d!==void 0&&(p.style=Uq(p.style,d)),p):Rq}var sJ=Symbol.for(`react.lazy`);function cJ(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Jq(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===sJ&&(i=C.Children.toArray(t)[0]),C.cloneElement(i,e)}if(e&&typeof e==`string`)return lJ(e,n);throw Error(zq(8))}function lJ(e,t){return e===`button`?(0,C.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,C.createElement)(`img`,{alt:``,...t,key:t.key}):C.createElement(e,t)}var uJ={...C},dJ=0;function fJ(e,t=`mui`){let[n,r]=C.useState(e),i=e||n;return C.useEffect(()=>{n??(dJ+=1,r(`${t}-${dJ}`))},[n,t]),i}var pJ=uJ.useId;function mJ(e,t){if(pJ!==void 0){let n=pJ();return e??(t?`${t}-${n}`:n)}return fJ(e,t)}function hJ(e){return mJ(e,`base-ui`)}function gJ(){return typeof window<`u`}function _J(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vJ(e){return gJ()?e instanceof Element||e instanceof _J(e).Element:!1}function yJ(e){return gJ()?e instanceof HTMLElement||e instanceof _J(e).HTMLElement:!1}function bJ(e){return!gJ()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof _J(e).ShadowRoot}var xJ=C.createContext(void 0);function SJ(e=!1){let t=C.useContext(xJ);if(t===void 0&&!e)throw Error(zq(16));return t}function CJ(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:C.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function wJ(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=C.useRef(null),o=SJ(!0)!==void 0,s=wq(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=CJ({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=C.useCallback(()=>{let e=a.current;TJ(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return Nq(l,[l]),{getButtonProps:C.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return Jq({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(nJ(e),o?.(e)),e.baseUIHandlerPrevented)return;let r=e.target===e.currentTarget&&!i&&!s()&&!t,a=e.key===`Enter`,c=e.key===` `;r&&((c||a)&&e.preventDefault(),a&&n?.(e))},onKeyUp(e){t||(nJ(e),a?.(e)),!e.baseUIHandlerPrevented&&e.target===e.currentTarget&&!i&&!t&&e.key===` `&&n?.(e)},onPointerDown(e){if(t){e.preventDefault();return}l?.(e)}},i?void 0:{role:`button`},c,u)},[t,c,i,s]),buttonRef:wq(e=>{a.current=e,l()})}}function TJ(e){return yJ(e)&&e.tagName===`BUTTON`}var EJ=C.createContext(void 0);function DJ(){let e=C.useContext(EJ);if(e===void 0)throw Error(zq(63));return e}var OJ=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),kJ={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},AJ={valid(e){return e===null?null:e?{[OJ.valid]:``}:{[OJ.invalid]:``}}},jJ=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),MJ={...AJ,checked(e){return e?{[jJ.checked]:``}:{[jJ.unchecked]:``}}};function NJ(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var PJ=C.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Lq,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function FJ(){return C.useContext(PJ)}var IJ=C.createContext({invalid:void 0,name:void 0,validityData:{state:kJ,errors:[],error:``,value:``,initialValue:null},setValidityData:Lq,disabled:void 0,touched:!1,setTouched:Lq,dirty:!1,setDirty:Lq,filled:!1,setFilled:Lq,focused:!1,setFocused:Lq,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=Rq)=>e,getInputValidationProps:(e=Rq)=>e,inputRef:{current:null},commit:async()=>{}}});function LJ(e=!0){let t=C.useContext(IJ);if(t.setValidityData===Lq&&!e)throw Error(zq(28));return t}function RJ(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=FJ(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=LJ(),f=wq(e.getValue);Nq(()=>{if(!t)return;let e=n;e===void 0&&(e=f()),u.initialValue===null&&e!==null&&d(t=>({...t,initialValue:e}))},[t,d,n,u.initialValue,f]),Nq(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:NJ(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?Vd.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),Nq(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var zJ=C.createContext({controlId:void 0,registerControlId:Lq,labelId:void 0,setLabelId:Lq,messageIds:[],setMessageIds:Lq,getDescriptionProps:e=>e});function BJ(){return C.useContext(zJ)}function VJ(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=BJ(),o=hJ(t),s=n?i:void 0,c=xq(()=>Symbol(`labelable-control`)),l=C.useRef(!1),u=C.useRef(t!=null),d=wq(()=>{!l.current||a===Lq||(l.current=!1,a(c.current,void 0))});return Nq(()=>{if(a===Lq)return;let e;if(n){let n=r?.current;e=vJ(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),C.useEffect(()=>d,[d]),i??o}var HJ=`none`;function UJ(e,t,n,r){let i=!1,a=!1,o=r??Rq;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function WJ(e,t){let n=C.useRef(e),r=wq(t);Nq(()=>{n.current!==e&&r(n.current)},[e,r]),Nq(()=>{n.current=e},[e])}var GJ=C.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,id:a,inputRef:o,name:s,nativeButton:c=!1,onCheckedChange:l,readOnly:u=!1,required:d=!1,disabled:f=!1,render:p,uncheckedValue:m,value:h,...g}=e,{clearErrors:_}=FJ(),{state:v,setTouched:y,setDirty:b,validityData:x,setFilled:w,setFocused:T,shouldValidateOnChange:E,validationMode:D,disabled:O,name:k,validation:A}=LJ(),{labelId:j}=BJ(),M=O||f,N=k??s,P=wq(l),F=C.useRef(null),I=Dq(F,o,A.inputRef),L=C.useRef(null),ee=hJ(),R=VJ({id:a,implicit:!1,controlRef:L}),z=c?void 0:R,[B,te]=yq({controlled:n,default:!!i,name:`Switch`,state:`checked`});RJ({id:ee,commit:A.commit,value:B,controlRef:L,name:N,getValue:()=>B}),Nq(()=>{F.current&&w(F.current.checked)},[F,w]),WJ(B,()=>{_(N),b(B!==x.initialValue),w(B),E()?A.commit(B):A.commit(B,!0)});let{getButtonProps:V,buttonRef:H}=wJ({disabled:M,native:c}),ne={id:c?R:ee,role:`switch`,"aria-checked":B,"aria-readonly":u||void 0,"aria-required":d||void 0,"aria-labelledby":j,onFocus(){M||T(!0)},onBlur(){let e=F.current;!e||M||(y(!0),T(!1),D===`onBlur`&&A.commit(e.checked))},onClick(e){u||M||(e.preventDefault(),F.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},re=C.useMemo(()=>Jq({checked:B,disabled:M,id:z,name:N,required:d,style:N?Iq:Fq,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:I,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=UJ(HJ,e.nativeEvent);P?.(t,n),!n.isCanceled&&te(t)},onFocus(){L.current?.focus()}},A.getInputValidationProps,h===void 0?Rq:{value:h}),[B,M,I,z,N,P,d,te,A,h]),ie=C.useMemo(()=>({...v,checked:B,disabled:M,readOnly:u,required:d}),[v,B,M,u,d]),U=aJ(`span`,e,{state:ie,ref:[t,L,H],props:[ne,A.getValidationProps,g,V],stateAttributesMapping:MJ});return(0,S.jsxs)(EJ.Provider,{value:ie,children:[U,!B&&N&&m!==void 0&&(0,S.jsx)(`input`,{type:`hidden`,name:N,value:m}),(0,S.jsx)(`input`,{...re})]})}),KJ=C.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=LJ(),o=DJ();return aJ(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:MJ,props:i})});function qJ({checked:e,onCheckedChange:t,disabled:n,className:r,ariaLabel:i}){return(0,S.jsx)(GJ,{checked:e,onCheckedChange:t,disabled:n,"aria-label":i,className:l_(`group relative inline-flex h-6 w-10 shrink-0 cursor-pointer items-center rounded-full transition-colors`,`bg-border data-[checked]:bg-accent`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-bg-base`,`disabled:cursor-not-allowed disabled:opacity-50`,r),children:(0,S.jsx)(KJ,{className:l_(`pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform`,`translate-x-1 group-data-[checked]:translate-x-5`)})})}var JJ=null,YJ=!1,XJ={},ZJ=500;function QJ(){if(typeof window>`u`)return null;if(JJ?.state===`closed`&&(JJ=null),!JJ){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;JJ=new e}return JJ}function $J(){JJ&&=(JJ.close().catch(()=>{}),null),QJ()}function eY(){return YJ}function tY(){JJ&&($J(),YJ=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&tY()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&tY()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&tY(),e=t},5e3)}async function nY(){let e=QJ();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),YJ=!1}async function rY(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function iY(e){let t=QJ();if(!t||(await rY(t),t.state!==`running`))return;let{frequencies:n,durationMs:r,attackMs:i,peakGain:a,type:o=`sine`}=e,s=t.currentTime,c=r/1e3,l=i/1e3,u=t.createGain();u.connect(t.destination);let d=s+c*.7;u.gain.setValueAtTime(0,s),u.gain.linearRampToValueAtTime(a,s+l),u.gain.setValueAtTime(a,d),u.gain.linearRampToValueAtTime(0,s+c);let f=n.map(e=>{let n=t.createOscillator();return n.type=o,n.frequency.setValueAtTime(e,s),n.connect(u),n});for(let e of f)e.start(s),e.stop(s+c);let p=f[f.length-1];p.onended=()=>{for(let e of f)e.disconnect();u.disconnect()}}async function aY(){let e=Date.now();if(!(e-(XJ.permission||0)<ZJ)){XJ.permission=e;try{await iY({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function oY(){let e=Date.now();if(!(e-(XJ.idle||0)<ZJ)){XJ.idle=e;try{await iY({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function sY({isOpen:e,onClose:t}){let n=W(e=>e.defaultProjectDir),r=W(e=>e.setDefaultProjectDir),i=W(e=>e.commandPresets),a=W(e=>e.setCommandPresets),o=W(e=>e.defaultPresetId),s=W(e=>e.setDefaultPresetId),c=W(e=>e.sessionSortMode),l=W(e=>e.setSessionSortMode),u=W(e=>e.sessionSortDirection),d=W(e=>e.setSessionSortDirection),f=W(e=>e.sidebarAnchor),p=W(e=>e.setSidebarAnchor),m=W(e=>e.useWebGL),h=W(e=>e.setUseWebGL),g=W(e=>e.fontSize),_=W(e=>e.setFontSize),v=W(e=>e.lineHeight),y=W(e=>e.setLineHeight),b=W(e=>e.letterSpacing),x=W(e=>e.setLetterSpacing),w=W(e=>e.fontOption),T=W(e=>e.setFontOption),E=W(e=>e.customFontFamily),D=W(e=>e.setCustomFontFamily),O=W(e=>e.shortcutModifier),k=W(e=>e.setShortcutModifier),A=W(e=>e.showProjectName),j=W(e=>e.setShowProjectName),M=W(e=>e.showLastUserMessage),N=W(e=>e.setShowLastUserMessage),P=W(e=>e.showSessionIdPrefix),F=W(e=>e.setShowSessionIdPrefix),I=RG(e=>e.theme),L=RG(e=>e.setTheme),ee=W(e=>e.soundOnPermission),R=W(e=>e.setSoundOnPermission),z=W(e=>e.soundOnIdle),B=W(e=>e.setSoundOnIdle),[te,V]=(0,C.useState)(n),[H,ne]=(0,C.useState)(i),[re,ie]=(0,C.useState)(o),[U,ae]=(0,C.useState)(c),[oe,se]=(0,C.useState)(u),[ce,le]=(0,C.useState)(f),[ue,de]=(0,C.useState)(m),[fe,pe]=(0,C.useState)(g),[me,he]=(0,C.useState)(v),[ge,_e]=(0,C.useState)(b),[ve,be]=(0,C.useState)(w),[xe,Se]=(0,C.useState)(E),[Ce,we]=(0,C.useState)(O),[Te,Ee]=(0,C.useState)(A),[De,Oe]=(0,C.useState)(M),[Ae,je]=(0,C.useState)(P),[Me,Ne]=(0,C.useState)(I),[Pe,Fe]=(0,C.useState)(ee),[Ie,Le]=(0,C.useState)(z),[Re,ze]=(0,C.useState)(!0),[Be,Ve]=(0,C.useState)(!1),[He,Ue]=(0,C.useState)(!0),[We,Ge]=(0,C.useState)(!0),[Ke,qe]=(0,C.useState)(!1),[Je,Ye]=(0,C.useState)(!1),[Ze,Qe]=(0,C.useState)(24),[et,tt]=(0,C.useState)(!1),[nt,rt]=(0,C.useState)(!1),[it,at]=(0,C.useState)(``),[ot,st]=(0,C.useState)(``),[ct,lt]=(0,C.useState)(``),ut=(0,C.useRef)(null),ft=(0,C.useRef)(0),mt=(0,C.useRef)(!1);if((0,C.useEffect)(()=>{let t=++ft.current,r=mt.current;if(mt.current=e,ut.current&&=(clearTimeout(ut.current),null),e){if(V(n),ne(i),ie(o),ae(c),se(u),le(f),de(m),pe(g),he(v),_e(b),be(w),Se(E),we(O),Ee(A),Oe(M),je(P),Ne(I),Fe(ee),Le(z),rt(!1),at(``),st(``),lt(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>ze(e.enabled)).catch(()=>{}),Ge(!0),fetch(`/api/settings/terminal-colors`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{ft.current===t&&Ue(e.enabled)}).catch(()=>{}).finally(()=>{ft.current===t&&Ge(!1)}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>Qe(e.hours)).catch(()=>{}),fetch(`/api/settings/prefer-window-name`).then(e=>e.json()).then(e=>qe(e.enabled)).catch(()=>{}),typeof document<`u`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}}else r&&typeof document<`u`&&(ut.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{ut.current&&=(clearTimeout(ut.current),null)}},[i,o,n,c,u,f,m,g,v,b,w,E,O,A,M,P,I,ee,z,e]),(0,C.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=e=>{e.key===`Escape`&&(typeof e.stopPropagation==`function`&&e.stopPropagation(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let ht=e=>{e.preventDefault();let n=te.trim(),i=ue!==m;r(n||`~/Documents/GitHub`),a(H),s(re),l(U),d(oe),p(ce),h(ue),_(fe),y(me),x(ge),T(ve),D(xe),k(Ce),j(Te),N(De),F(Ae),L(Me),R(Pe),B(Ie),t({webglChanged:i})},gt=(e,t)=>{ne(n=>n.map(n=>n.id===e?{...n,...t}:n))},_t=e=>{let t=H.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=H.filter(t=>t.id!==e);ne(n),e===re&&ie(n[0]?.id||`claude`)},yt=()=>{if(!it.trim()||!ot.trim()||H.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:it.trim(),command:ot.trim(),isBuiltIn:!1,agentType:ct||void 0};ne([...H,e]),rt(!1),at(``),st(``),lt(``)},bt=H.length<50,xt=e=>{Ve(!0),ze(e),fetch(`/api/settings/tmux-mouse-mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>ze(!e)).finally(()=>Ve(!1))},St=e=>{Ye(!0),qe(e),fetch(`/api/settings/prefer-window-name`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>qe(!e)).finally(()=>Ye(!1))},Ct=e=>{Ge(!0),Ue(e),fetch(`/api/settings/terminal-colors`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Ue(!e)).finally(()=>Ge(!1))},wt=e=>{let t=Ze;tt(!0),Qe(e),fetch(`/api/settings/history-max-age-hours`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hours:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Qe(t)).finally(()=>tt(!1))};return(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,S.jsxs)(`form`,{onSubmit:ht,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,S.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,S.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,S.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,S.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,S.jsx)(`input`,{value:te,onChange:e=>V(e.target.value),placeholder:Xe,className:`input`,autoFocus:!0})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,S.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,S.jsx)(`select`,{value:re,onChange:e=>ie(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:H.map(e=>(0,S.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,S.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,S.jsx)(`div`,{className:`space-y-3`,children:H.map(e=>(0,S.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,S.jsx)(`input`,{value:e.label,onChange:t=>gt(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,S.jsx)(`button`,{type:`button`,onClick:()=>_t(e.id),className:`btn text-xs px-2 py-1 text-danger hover:bg-danger/10`,children:`Delete`})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,S.jsx)(`input`,{value:e.command,onChange:t=>gt(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,S.jsxs)(`select`,{value:e.agentType||``,onChange:t=>gt(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,S.jsx)(`option`,{value:``,children:`Terminal`}),(0,S.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,S.jsx)(`option`,{value:`codex`,children:`Codex`}),(0,S.jsx)(`option`,{value:`pi`,children:`Pi`}),(0,S.jsx)(`option`,{value:`devin`,children:`Devin`}),(0,S.jsx)(`option`,{value:`grok`,children:`Grok`}),(0,S.jsx)(`option`,{value:`omp`,children:`OMP`})]})]})]},e.id))}),nt?(0,S.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,S.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,S.jsx)(`input`,{value:it,onChange:e=>at(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,S.jsx)(`input`,{value:ot,onChange:e=>st(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsxs)(`select`,{value:ct,onChange:e=>lt(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,S.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,S.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,S.jsx)(`option`,{value:`codex`,children:`Codex Icon`}),(0,S.jsx)(`option`,{value:`pi`,children:`Pi Icon`}),(0,S.jsx)(`option`,{value:`devin`,children:`Devin Icon`}),(0,S.jsx)(`option`,{value:`grok`,children:`Grok Icon`}),(0,S.jsx)(`option`,{value:`omp`,children:`OMP Icon`})]}),(0,S.jsx)(`div`,{className:`flex-1`}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>rt(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,S.jsx)(`button`,{type:`button`,onClick:yt,disabled:!it.trim()||!ot.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,S.jsx)(`button`,{type:`button`,onClick:()=>rt(!0),disabled:!bt,className:`btn text-xs mt-3 w-full`,children:bt?`+ Add Preset`:`Max 50 presets`})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,S.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${U===`created`?`btn-primary`:``}`,onClick:()=>ae(`created`),children:`Created`}),(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${U===`status`?`btn-primary`:``}`,onClick:()=>ae(`status`),children:`Status`}),(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${U===`manual`?`btn-primary`:``}`,onClick:()=>ae(`manual`),children:`Manual`})]}),(0,S.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:U===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:U===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),U===`created`&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`desc`?`btn-primary`:``}`,onClick:()=>se(`desc`),children:`Newest First`}),(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`asc`?`btn-primary`:``}`,onClick:()=>se(`asc`),children:`Oldest First`})]})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sidebar Anchor`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ce===`top`?`btn-primary`:``}`,onClick:()=>le(`top`),children:`Top`}),(0,S.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ce===`bottom`?`btn-primary`:``}`,onClick:()=>le(`bottom`),children:`Bottom`})]}),(0,S.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:ce===`bottom`?`Desktop sidebar is mirrored: the first session sits at the bottom, next to the prompt`:`First session at the top of the sidebar`})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,S.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,S.jsx)(qJ,{checked:Te,onCheckedChange:Ee})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,S.jsx)(qJ,{checked:De,onCheckedChange:Oe})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,S.jsx)(qJ,{checked:Ae,onCheckedChange:je})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,S.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`input`,{type:`number`,min:1,max:168,value:Ze,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&&wt(t)},disabled:et,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,S.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,S.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex-1`,children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>void aY(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,S.jsx)(qJ,{checked:Pe,onCheckedChange:e=>{Fe(e),e&&nY()}})]})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex-1`,children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>void oY(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,S.jsx)(qJ,{checked:Ie,onCheckedChange:e=>{Le(e),e&&nY()}})]})]})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,S.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,S.jsx)(qJ,{checked:ue,onCheckedChange:de})]}),ue!==m&&(0,S.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,S.jsx)(qJ,{checked:Re,onCheckedChange:xt,disabled:Be})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Terminal Colors`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Preserve ANSI colors for terminal output. Hibernate then Wake running agents after changing this setting.`})]}),(0,S.jsx)(qJ,{checked:He,onCheckedChange:Ct,disabled:We,ariaLabel:`Enable terminal colors`})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Prefer Window Names`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Label discovered sessions with their tmux window name instead of the session name. Applies immediately.`})]}),(0,S.jsx)(qJ,{checked:Ke,onCheckedChange:St,disabled:Je})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>pe(Math.max(6,fe-1)),className:vt,"aria-label":`Decrease font size`,children:(0,S.jsx)(ye,{width:G.default,height:G.default})}),(0,S.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:fe}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>pe(Math.min(24,fe+1)),className:vt,"aria-label":`Increase font size`,children:(0,S.jsx)(ke,{width:G.default,height:G.default})})]})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:me,onChange:e=>he(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,S.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:me.toFixed(1)})]})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:ge,onChange:e=>_e(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,S.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[ge,`px`]})]})]}),(0,S.jsxs)(`div`,{className:`mt-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,S.jsx)(`select`,{value:ve,onChange:e=>be(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:$e.map(e=>(0,S.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),ve===`custom`&&(0,S.jsx)(`input`,{value:xe,onChange:e=>Se(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,S.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,S.jsx)(qJ,{checked:Me===`dark`,onCheckedChange:e=>Ne(e?`dark`:`light`)})]})]}),(0,S.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,S.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,S.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,S.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${Ce===e?`btn-primary`:``}`,onClick:()=>we(e),children:e===`auto`?`Auto`:pt(e)},e))}),(0,S.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:Ce===`auto`?`Shortcuts: ${pt(dt(`auto`))}+[1-9/N/X/[/]]`:`Shortcuts: ${pt(Ce)}+[1-9/N/X/[/]]`})]})]})}),(0,S.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,S.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var cY=[];function lY(e){C.useEffect(e,cY)}var uY=C.createContext(void 0);function dY(){let e=C.useContext(uY);if(!e)throw Error(zq(73));return e}var fY=Symbol(`NOT_FOUND`);function pY(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function mY(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function hY(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var gY=e=>Array.isArray(e)?e:[e];function _Y(e){let t=Array.isArray(e[0])?e[0]:e;return hY(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function vY(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function yY(e){let t;return{get(n){return t&&e(t.key,n)?t.value:fY},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function bY(e,t){let n=[];function r(e){let r=n.findIndex(n=>t(e,n.key));if(r>-1){let e=n[r];return r>0&&(n.splice(r,1),n.unshift(e)),e.value}return fY}function i(t,i){r(t)===fY&&(n.unshift({key:t,value:i}),n.length>e&&n.pop())}function a(){return n}function o(){n=[]}return{get:r,put:i,getEntries:a,clear:o}}var xY=(e,t)=>e===t;function SY(e){return function(t,n){if(t===null||n===null||t.length!==n.length)return!1;let{length:r}=t;for(let i=0;i<r;i++)if(!e(t[i],n[i]))return!1;return!0}}function CY(e,t){let{equalityCheck:n=xY,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=SY(n),o=0,s=r<=1?yY(a):bY(r,a);function c(){let t=s.get(arguments);if(t===fY){if(t=e.apply(null,arguments),o++,i){let e=s.getEntries().find(e=>i(e.value,t));e&&(t=e.value,o!==0&&o--)}s.put(arguments,t)}return t}return c.clearCache=()=>{s.clear(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}var wY=class{constructor(e){this.value=e}deref(){return this.value}},TY=typeof WeakRef<`u`?WeakRef:wY,EY=0,DY=1;function OY(){return{s:EY,v:void 0,o:null,p:null}}function kY(e,t={}){let n=OY(),{resultEqualityCheck:r}=t,i,a=0;function o(){let t=n,{length:o}=arguments;for(let e=0,n=o;e<n;e++){let n=arguments[e];if(typeof n==`function`||typeof n==`object`&&n){let e=t.o;e===null&&(t.o=e=new WeakMap);let r=e.get(n);r===void 0?(t=OY(),e.set(n,t)):t=r}else{let e=t.p;e===null&&(t.p=e=new Map);let r=e.get(n);r===void 0?(t=OY(),e.set(n,t)):t=r}}let s=t,c;if(t.s===DY)c=t.v;else if(c=e.apply(null,arguments),a++,r){let e=i?.deref?.()??i;e!=null&&r(e,c)&&(c=e,a!==0&&a--),i=typeof c==`object`&&c||typeof c==`function`?new TY(c):c}return s.s=DY,s.v=c,c}return o.clearCache=()=>{n=OY(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function AY(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),pY(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=kY,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=gY(c),p=gY(u),m=_Y(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=vY(m,arguments);return i=h.apply(null,e),i},...p);return Object.assign(g,{resultFunc:o,memoizedResultFunc:h,dependencies:m,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var jY=AY(kY),MY=Object.assign((e,t=jY)=>{mY(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);let n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>MY}),NY=AY({memoize:CY,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),PY=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(zq(1));let s;if(e&&t&&n&&r&&i&&a)s=(o,s,c,l)=>a(e(o,s,c,l),t(o,s,c,l),n(o,s,c,l),r(o,s,c,l),i(o,s,c,l),s,c,l);else if(e&&t&&n&&r&&i)s=(a,o,s,c)=>i(e(a,o,s,c),t(a,o,s,c),n(a,o,s,c),r(a,o,s,c),o,s,c);else if(e&&t&&n&&r)s=(i,a,o,s)=>r(e(i,a,o,s),t(i,a,o,s),n(i,a,o,s),a,o,s);else if(e&&t&&n)s=(r,i,a,o)=>n(e(r,i,a,o),t(r,i,a,o),i,a,o);else if(e&&t)s=(n,r,i,a)=>t(e(n,r,i,a),r,i,a);else if(e)s=e;else throw Error(`Missing arguments`);return s},FY=(...e)=>{let t=new WeakMap,n=1,r=e[e.length-1],i=e.length-1||1,a=r.length-i;if(a>3)throw Error(zq(2));return(i,o,s,c)=>{let l=i.__cacheKey__;l||(l={id:n},i.__cacheKey__=l,n+=1);let u=t.get(l);if(!u){let n=e,i=[void 0,void 0,void 0];switch(a){case 0:break;case 1:n=[...e.slice(0,-1),()=>i[0],r];break;case 2:n=[...e.slice(0,-1),()=>i[0],()=>i[1],r];break;case 3:n=[...e.slice(0,-1),()=>i[0],()=>i[1],()=>i[2],r];break;default:throw Error(zq(2))}u=NY(...n),u.selectorArgs=i,t.set(l,u)}switch(u.selectorArgs[0]=o,u.selectorArgs[1]=s,u.selectorArgs[2]=c,a){case 0:return u(i);case 1:return u(i,o);case 2:return u(i,o,s);case 3:return u(i,o,s,c);default:throw Error(`unreachable`)}}},IY=s((e=>{var t=p();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),LY=s(((e,t)=>{t.exports=IY()})),RY=s((e=>{var t=p(),n=LY();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),zY=s(((e,t)=>{t.exports=RY()})),BY=[],VY=void 0;function HY(){return VY}function UY(e){BY.push(e)}var WY=LY(),GY=zY(),KY=Vq(19)?YY:XY;function qY(e,t,n,r,i){return KY(e,t,n,r,i)}function JY(e,t,n,r,i){let a=C.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,WY.useSyncExternalStore)(e.subscribe,a,a)}UY({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);(r.didChange||!Object.is(r.value,i))&&(t=!0,r.value=i,r.didChange=!1)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,WY.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function YY(e,t,n,r,i){let a=HY();if(!a)return JY(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.didChange=!0)):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i),didChange:!1},a.syncHooks.push(s)),s.value}function XY(e,t,n,r,i){return(0,GY.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var ZY=class{constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return qY(this,e,t,n,r)}},QY=class extends ZY{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){C.useDebugValue(e),Nq(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;Nq(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;Nq(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){C.useDebugValue(e);let n=t!==void 0;Nq(()=>{n&&!Object.is(this.state[e],t)&&super.setState({...this.state,[e]:t})},[e,t,n])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return C.useDebugValue(e),qY(this,this.selectors[e],t,n,r)}useContextCallback(e,t){C.useDebugValue(e);let n=wq(t??Lq);this.context[e]=n}useStateSetter(e){let t=C.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},$Y=null;globalThis.requestAnimationFrame;var eX=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,--this.callbacksCount)}},tX=class e{static create(){return new e}static request(e){return eX.request(e)}static cancel(e){return eX.cancel(e)}currentId=$Y;request(e){this.cancel(),this.currentId=eX.request(()=>{this.currentId=$Y,e()})}cancel=()=>{this.currentId!==$Y&&(eX.cancel(this.currentId),this.currentId=$Y)};disposeEffect=()=>this.cancel};function nX(){let e=xq(tX.create).current;return lY(e.disposeEffect),e}var rX=0,iX=class e{static create(){return new e}currentId=rX;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=rX,t()},e)}isStarted(){return this.currentId!==rX}clear=()=>{this.currentId!==rX&&(clearTimeout(this.currentId),this.currentId=rX)};disposeEffect=()=>this.clear};function aX(){let e=xq(iX.create).current;return lY(e.disposeEffect),e}var oX=0;function sX(e){return oX+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${oX}`}function cX(e){return e?.ownerDocument||document}function lX(e,t){if(typeof e==`string`)return{description:e};if(typeof e==`function`){let n=e(t);return typeof n==`string`?{description:n}:n}return e}var uX=typeof navigator<`u`,dX=gX(),fX=vX(),pX=_X();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),dX.platform===`MacIntel`&&dX.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(dX.platform),uX&&/firefox/i.test(pX);var mX=uX&&/apple/i.test(navigator.vendor);uX&&/Edg/i.test(pX),uX&&/android/i.test(fX)||/android/i.test(pX),uX&&fX.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var hX=pX.includes(`jsdom/`);function gX(){if(!uX)return{platform:``,maxTouchPoints:-1};let e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??-1}}function _X(){if(!uX)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function vX(){if(!uX)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function yX(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function bX(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&bJ(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function xX(e){return`composedPath`in e?e.composedPath()[0]:e.target}function SX(e){if(!e||hX)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var CX=FY(e=>e.toasts,e=>{let t=new Map,n=0,r=0;return e.forEach((e,i)=>{let a=e.transitionStatus===`ending`;t.set(e.id,{value:e,domIndex:i,visibleIndex:a?-1:n,offsetY:r}),r+=e.height||0,a||(n+=1)}),t}),wX={toasts:PY(e=>e.toasts),isEmpty:PY(e=>e.toasts.length===0),toast:PY(CX,(e,t)=>e.get(t)?.value),toastIndex:PY(CX,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:PY(CX,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:PY(CX,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:PY(e=>e.hovering),focused:PY(e=>e.focused),expanded:PY(e=>e.hovering||e.focused),expandedOrOutOfFocus:PY(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:PY(e=>e.prevFocusElement)},TX=class extends QY{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},wX)}setFocused(e){this.set(`focused`,e)}setHovering(e){this.set(`hovering`,e)}setIsWindowFocused(e){this.set(`isWindowFocused`,e)}setPrevFocusElement(e){this.set(`prevFocusElement`,e)}setViewport=e=>{this.set(`viewport`,e)};disposeEffect=()=>()=>{this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear()};removeToast(e){let t=wX.toastIndex(this.state,e);if(t===-1)return;this.state.toasts[t]?.onRemove?.();let n=[...this.state.toasts];n.splice(t,1),this.setToasts(n)}addToast=e=>{let{toasts:t,timeout:n,limit:r}=this.state,i=e.id||sX(`toast`),a={...e,id:i,transitionStatus:`starting`},o=[a,...t],s=o.filter(e=>e.transitionStatus!==`ending`);if(s.length>r){let e=s.length-r,t=s.slice(-e),n=new Set(t.map(e=>e.id));this.setToasts(o.map(e=>{let t=n.has(e.id);return e.limited===t?e:{...e,limited:t}}))}else this.setToasts(o.map(e=>e.limited?{...e,limited:!1}:e));let c=a.timeout??n;return a.type!==`loading`&&c>0&&this.scheduleTimer(i,c,()=>this.closeToast(i)),wX.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=wX.toast(this.state,e)??null;if(!i||i.transitionStatus===`ending`)return;let a={...i,...t};this.setToasts(r.map(n=>n.id===e?{...n,...t}:n));let o=a.timeout??n,s=i?.timeout??n,c=Object.hasOwn(t,`timeout`),l=a.transitionStatus!==`ending`&&a.type!==`loading`&&o>0,u=this.timers.has(e),d=s!==o,f=i?.type===`loading`;if(!l&&u){this.timers.get(e)?.timeout?.clear(),this.timers.delete(e);return}if(l&&(!u||d||c||f)){let t=this.timers.get(e);t&&(t.timeout?.clear(),this.timers.delete(e)),this.scheduleTimer(e,o,()=>this.closeToast(e)),wX.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{wX.toast(this.state,e)?.onClose?.();let{limit:t,toasts:n}=this.state,r=0,i=n.map(n=>{if(n.id===e)return{...n,transitionStatus:`ending`,height:0};if(n.transitionStatus===`ending`)return n;let i=r>=t;return r+=1,n.limited===i?n:{...n,limited:i}}),a=this.timers.get(e);a&&a.timeout&&(a.timeout.clear(),this.timers.delete(e)),this.handleFocusManagement(e),this.setToasts(i)};promiseToast=(e,t)=>{let n=lX(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=lX(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=lX(t.error,e);return this.updateToast(r,{...n,type:`error`,timeout:n.timeout}),Promise.reject(e)});return{}.hasOwnProperty.call(t,`setPromise`)&&t.setPromise(i),i};pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(e=>{if(e.timeout){e.timeout.clear();let t=Date.now()-e.start,n=e.delay-t;e.remaining=n>0?n:0}}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((e,t)=>{e.remaining=e.remaining>0?e.remaining:e.delay,e.timeout??=iX.create(),e.timeout.start(e.remaining,()=>{this.timers.delete(t),e.callback()}),e.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}handleDocumentPointerDown=e=>{if(e.pointerType!==`touch`)return;let t=xX(e);bX(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!wX.expandedOrOutOfFocus(this.state),a=i?iX.create():void 0;a?.start(t,()=>{this.timers.delete(e),n()}),this.timers.set(e,{timeout:a,start:i?r:0,delay:t,remaining:t,callback:n})}setToasts(e){let t={toasts:e};e.length===0&&(t.hovering=!1,t.focused=!1),this.update(t)}handleFocusManagement(e){let t=yX(cX(this.state.viewport));if(!this.state.viewport||!bX(this.state.viewport,t)||!SX(t))return;let n=wX.toasts(this.state),r=wX.toastIndex(this.state,e),i=null,a=r+1;for(;a<n.length;){if(n[a].transitionStatus!==`ending`){i=n[a];break}a+=1}if(!i)for(a=r-1;a>=0;){if(n[a].transitionStatus!==`ending`){i=n[a];break}--a}i?i.ref?.current?.focus():this.restoreFocusToPrevElement()}},EX=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=xq(()=>new TX({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return lY(a.disposeEffect),C.useEffect(function(){if(i)return i[` subscribe`](({action:e,options:t})=>{let n=t.id;e===`promise`&&t.promise?a.promiseToast(t.promise,t):e===`update`&&n?a.updateToast(n,t):e===`close`&&n?a.closeToast(n):a.addToast(t)})},[a,n,i]),a.useSyncedValues({timeout:n,limit:r}),(0,S.jsx)(uY.Provider,{value:a,children:t})},DX=C.forwardRef(function(e,t){let[n,r]=C.useState();Nq(()=>{mX&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,S.jsx)(`span`,{...e,ref:t,style:Fq,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),OX=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),kX=C.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=dY(),s=aX(),c=C.useRef(!1),l=C.useRef(!1),u=o.useState(`isEmpty`),d=o.useState(`toasts`),f=o.useState(`focused`),p=o.useState(`expanded`),m=o.useState(`prevFocusElement`),h=d[0]?.height??0,g=C.useMemo(()=>d.some(e=>e.transitionStatus===`ending`),[d]);C.useEffect(()=>{let e=o.state.viewport;if(!e)return;function t(t){u||t.key===`F6`&&t.target!==e&&(t.preventDefault(),o.setPrevFocusElement(yX(cX(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=_J(e);return n.addEventListener(`keydown`,t),()=>{n.removeEventListener(`keydown`,t)}},[o,u]),C.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=_J(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=xX(n),i=yX(cX(e));(!bX(e,r)||!SX(i))&&o.resumeTimers(),s.start(0,()=>o.setIsWindowFocused(!0))}return t.addEventListener(`blur`,n,!0),t.addEventListener(`focus`,r,!0),()=>{t.removeEventListener(`blur`,n,!0),t.removeEventListener(`focus`,r,!0)}},[o,s,u]),C.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=cX(e);return t.addEventListener(`pointerdown`,o.handleDocumentPointerDown,!0),()=>{t.removeEventListener(`pointerdown`,o.handleDocumentPointerDown,!0)}},[u,o]);function _(e){let t=o.state.viewport;t&&(c.current=!0,e.relatedTarget===t?d[0]?.ref?.current?.focus():o.restoreFocusToPrevElement())}function v(e){e.key===`Tab`&&e.shiftKey&&e.target===o.state.viewport&&(e.preventDefault(),o.restoreFocusToPrevElement(),o.resumeTimers())}C.useEffect(()=>{!o.state.isWindowFocused||g||!l.current||(o.resumeTimers(),o.setHovering(!1),l.current=!1)},[g,o]);function y(){o.pauseTimers(),o.setHovering(!0),l.current=!1}function b(){g?l.current=!0:(o.resumeTimers(),o.setHovering(!1))}function x(){if(c.current){c.current=!1;return}f||SX(cX(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function w(e){!f||bX(o.state.viewport,e.relatedTarget)||(o.setFocused(!1),o.resumeTimers())}let T={tabIndex:-1,role:`region`,"aria-live":`polite`,"aria-atomic":!1,"aria-relevant":`additions text`,"aria-label":`Notifications`,onMouseEnter:y,onMouseMove:y,onMouseLeave:b,onFocus:x,onBlur:w,onKeyDown:v,onClick:x},E={expanded:p},D=aJ(`div`,e,{ref:[t,o.setViewport],state:E,props:[T,{style:{[OX.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,S.jsxs)(C.Fragment,{children:[!u&&m&&(0,S.jsx)(DX,{onFocus:_}),i,!u&&m&&(0,S.jsx)(DX,{onFocus:_})]})}]}),O=C.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,S.jsxs)(C.Fragment,{children:[!u&&m&&(0,S.jsx)(DX,{onFocus:_}),D,!f&&O.length>0&&(0,S.jsx)(`div`,{style:Fq,children:O.map(e=>(0,S.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,S.jsx)(`div`,{children:e.title}),(0,S.jsx)(`div`,{children:e.description})]},e.id))})]})});function AX(e){return Vq(19)?e:e?`true`:void 0}var jX=C.createContext(void 0);function MX(){let e=C.useContext(jX);if(!e)throw Error(zq(66));return e}var NX=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),PX={[NX.startingStyle]:``},FX={[NX.endingStyle]:``},IX={transitionStatus(e){return e===`starting`?PX:e===`ending`?FX:null}};function LX(e){return e==null?e:`current`in e?e.current:e}function RX(e,t=!1,n=!0){let r=nX();return wq((i,a=null)=>{r.cancel();function o(){Vd.flushSync(i)}let s=LX(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=NX.startingStyle;if(!c.hasAttribute(e)){r.request(i);return}let t=new MutationObserver(()=>{c.hasAttribute(e)||(t.disconnect(),i())});t.observe(c,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}function i(){Promise.all(c.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||o()}).catch(()=>{let e=c.getAnimations();if(n){if(a?.aborted)return;o()}else e.length>0&&e.some(e=>e.pending||e.playState!==`finished`)&&i()})}if(t){e();return}r.request(i)}})}function zX(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=wq(i),o=RX(r,n,!1);C.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var BX=function(e){return e.index=`--toast-index`,e.offsetY=`--toast-offset-y`,e.height=`--toast-height`,e.swipeMovementX=`--toast-swipe-movement-x`,e.swipeMovementY=`--toast-swipe-movement-y`,e}({}),VX={...IX,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},HX=40,UX=10,WX=.5,GX=1;function KX(e,t,n){switch(e){case`up`:return-n;case`down`:return n;case`left`:return-t;case`right`:return t;default:return 0}}function qX(e){let t=window.getComputedStyle(e).transform,n=0,r=0,i=1;if(t&&t!==`none`){let e=t.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){let t=e[1].split(`, `).map(parseFloat);t.length===6?(n=t[4],r=t[5],i=Math.sqrt(t[0]*t[0]+t[1]*t[1])):t.length===16&&(n=t[12],r=t[13],i=t[0])}}return{x:n,y:r,scale:i}}var JX=C.forwardRef(function(e,t){let{toast:n,render:r,className:i,swipeDirection:a=[`down`,`right`],...o}=e,s=n.positionerProps?.anchor!==void 0,c=[];s||(c=Array.isArray(a)?a:[a]);let l=c.length>0,u=dY(),[d,f]=C.useState(void 0),[p,m]=C.useState(!1),[h,g]=C.useState(!1),[_,v]=C.useState(!1),[y,b]=C.useState({x:0,y:0}),[x,w]=C.useState({x:0,y:0,scale:1}),[T,E]=C.useState(),[D,O]=C.useState(),[k,A]=C.useState(null),j=C.useRef(null),M=C.useRef({x:0,y:0}),N=C.useRef({x:0,y:0,scale:1}),P=C.useRef(void 0),F=C.useRef(0),I=C.useRef(!1),L=C.useRef({x:0,y:0}),ee=C.useRef(!1),R=u.useState(`toastIndex`,n.id),z=u.useState(`toastVisibleIndex`,n.id),B=u.useState(`toastOffsetY`,n.id),te=u.useState(`focused`),V=u.useState(`expanded`);zX({open:n.transitionStatus!==`ending`,ref:j,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let H=wq((e=!1)=>{let t=j.current;if(!t)return;let r=t.style.height;t.style.height=`auto`;let i=t.offsetHeight;t.style.height=r;function a(){u.updateToastInternal(n.id,{ref:j,height:i,...n.transitionStatus===`starting`?{transitionStatus:void 0}:{}})}e?Vd.flushSync(a):a()});Nq(H,[H]);function ne(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**WX:-(Math.abs(e)**WX):(!c.includes(`right`)&&e>0&&(n=e**WX),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**WX))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**WX:-(Math.abs(t)**WX):(!c.includes(`down`)&&t>0&&(r=t**WX),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**WX))),{x:n,y:r}}function re(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=xX(e.nativeEvent);if(!(t&&t.closest(`button,a,input,textarea,[role="button"],[data-swipe-ignore]`))){if(I.current=!1,P.current=void 0,F.current=0,M.current={x:e.clientX,y:e.clientY},L.current=M.current,j.current){let e=qX(j.current);N.current=e,w(e),b({x:e.x,y:e.y})}u.setHovering(!0),m(!0),g(!1),A(null),ee.current=!0,j.current?.setPointerCapture(e.pointerId)}}function ie(e){if(!p)return;e.preventDefault(),ee.current&&=(M.current={x:e.clientX,y:e.clientY},!1);let{clientY:t,clientX:n,movementX:r,movementY:i}=e;(i<0&&t>L.current.y||i>0&&t<L.current.y)&&(L.current={x:L.current.x,y:t}),(r<0&&n>L.current.x||r>0&&n<L.current.x)&&(L.current={x:n,y:L.current.y});let a=n-M.current.x,o=t-M.current.y,s=t-L.current.y,l=n-L.current.x;if(!h&&Math.sqrt(a*a+o*o)>=GX&&(g(!0),k===null)){let e=c.includes(`left`)||c.includes(`right`),t=c.includes(`up`)||c.includes(`down`);e&&t&&A(Math.abs(a)>Math.abs(o)?`horizontal`:`vertical`)}let u;if(!P.current)k===`vertical`?o>0?u=`down`:o<0&&(u=`up`):k===`horizontal`?a>0?u=`right`:a<0&&(u=`left`):u=Math.abs(a)>=Math.abs(o)?a>0?`right`:`left`:o>0?`down`:`up`,u&&c.includes(u)&&(P.current=u,F.current=KX(u,a,o),f(u));else{let e=P.current,t=KX(e,l,s);t>HX?(I.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&F.current-t>=UX&&(I.current=!0)}let d=ne(a,o),m=N.current.x,_=N.current.y;k===`horizontal`?(c.includes(`left`)||c.includes(`right`))&&(m+=d.x):(k===`vertical`||(c.includes(`left`)||c.includes(`right`))&&(m+=d.x),(c.includes(`up`)||c.includes(`down`))&&(_+=d.y)),b({x:m,y:_})}function U(e){if(!p)return;if(m(!1),g(!1),A(null),j.current?.releasePointerCapture(e.pointerId),I.current){b({x:x.x,y:x.y}),f(void 0);return}let t=!1,r=y.x-x.x,i=y.y-x.y,a;for(let e of c){switch(e){case`right`:r>HX&&(t=!0,a=`right`);break;case`left`:r<-HX&&(t=!0,a=`left`);break;case`down`:i>HX&&(t=!0,a=`down`);break;case`up`:i<-HX&&(t=!0,a=`up`);break;default:break}if(t)break}t?(f(a),v(!0),u.closeToast(n.id)):(b({x:x.x,y:x.y}),f(void 0))}function ae(e){if(e.key===`Escape`){if(!j.current||!bX(j.current,yX(cX(j.current))))return;u.closeToast(n.id)}}C.useEffect(()=>{if(!l)return;let e=j.current;if(!e)return;function t(t){bX(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function oe(){if(!p&&y.x===x.x&&y.y===x.y&&!_)return{[BX.swipeMovementX]:`0px`,[BX.swipeMovementY]:`0px`};let e=y.x-x.x,t=y.y-x.y;return{transition:p?`none`:void 0,transform:p?`translateX(${y.x}px) translateY(${y.y}px) scale(${x.scale})`:void 0,[BX.swipeMovementX]:`${e}px`,[BX.swipeMovementY]:`${t}px`}}let se=n.priority===`high`,ce={role:se?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":T,"aria-describedby":D,"aria-hidden":se&&!te?!0:void 0,onPointerDown:l?re:void 0,onPointerMove:l?ie:void 0,onPointerUp:l?U:void 0,onKeyDown:ae,inert:AX(n.limited),style:{...oe(),[BX.index]:n.transitionStatus===`ending`?R:z,[BX.offsetY]:`${B}px`,[BX.height]:n.height?`${n.height}px`:void 0}},le=C.useMemo(()=>({rootRef:j,toast:n,titleId:T,setTitleId:E,descriptionId:D,setDescriptionId:O,swiping:p,swipeDirection:d,recalculateHeight:H,index:R,visibleIndex:z,expanded:V}),[n,T,D,p,d,H,R,z,V]),ue={transitionStatus:n.transitionStatus,expanded:V,limited:n.limited||!1,type:n.type,swiping:le.swiping,swipeDirection:le.swipeDirection},de=aJ(`div`,e,{ref:[t,le.rootRef],state:ue,stateAttributesMapping:VX,props:[ce,o]});return(0,S.jsx)(jX.Provider,{value:le,children:de})}),YX=C.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=MX(),l=a??s.description,u=!!l,d=mJ(i);Nq(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=aJ(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),XX=C.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=MX(),l=a??s.title,u=!!l,d=mJ(i);Nq(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=aJ(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),ZX=C.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=dY(),{toast:c}=MX(),l=s.useState(`expanded`),[u,d]=C.useState(!1),{getButtonProps:f,buttonRef:p}=wJ({disabled:i,native:a}),m={type:c.type};return aJ(`button`,e,{ref:[t,p],state:m,props:[{"aria-hidden":!l&&!u,onClick(){s.closeToast(c.id)},onFocus(){d(!0)},onBlur(){d(!1)}},o,f]})});function QX(){let e=C.useContext(uY);if(!e)throw Error(zq(73));let t=e.useState(`toasts`);return C.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function $X(){let e=new Set;function t(t){e.forEach(e=>e(t))}return{" subscribe":function(t){return e.add(t),()=>{e.delete(t)}},add(e){let n=e.id||sX(`toast`);return t({action:`add`,options:{...e,id:n,transitionStatus:`starting`}}),n},close(e){t({action:`close`,options:{id:e}})},update(e,n){t({action:`update`,options:{...n,id:e}})},promise(e,n){let r=e;return t({action:`promise`,options:{...n,promise:e,setPromise(e){r=e}}}),r}}}var eZ=5e3,tZ=$X();function nZ({toast:e}){return(0,S.jsxs)(JX,{toast:e,className:l_(`relative flex w-80 items-start gap-3 border bg-elevated p-4 shadow-lg`,`data-[swipe=move]:translate-x-[var(--toast-swipe-move-x)]`,`data-[ending-style]:translate-x-[var(--toast-swipe-end-x)]`,`data-[ending-style]:opacity-0`,`data-[starting-style]:translate-y-2 data-[starting-style]:opacity-0`,`transition-all duration-200`,e.type===`error`&&`border-danger/50`,e.type===`success`&&`border-approval/50`,(!e.type||e.type===`info`)&&`border-border`),children:[(0,S.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,S.jsx)(XX,{className:l_(`text-sm font-medium`,e.type===`error`&&`text-danger`,e.type===`success`&&`text-approval`,(!e.type||e.type===`info`)&&`text-primary`),children:e.title}),e.description&&(0,S.jsx)(YX,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,S.jsx)(ZX,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,S.jsx)(Fe,{width:G.default,height:G.default})})]})}function rZ(){let{toasts:e}=QX();return(0,S.jsx)(S.Fragment,{children:e.map(e=>(0,S.jsx)(nZ,{toast:e},e.id))})}function iZ(){return(0,S.jsxs)(EX,{timeout:eZ,toastManager:tZ,children:[(0,S.jsx)(rZ,{}),(0,S.jsx)(kX,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var aZ=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],oZ=3e3,sZ=8e3,cZ=15e3,lZ=5e3,uZ=2e4,dZ=1e4,fZ=1500,pZ=5e3,mZ=750,hZ=4,gZ=5e3,_Z=new class{constructor(){this.ws=null,this.listeners=new Set,this.statusListeners=new Set,this.status=`connecting`,this.error=null,this.reconnectAttempts=0,this.reconnectTimer=null,this.connectTimer=null,this.manualClose=!1,this.lastTick=Date.now(),this.wakeCheckInterval=null,this.lifecycleStarted=!1,this.heartbeatTimer=null,this.pongTimer=null,this.lastForceReconnectTs=0,this.lastConnectTs=0,this.pingSeq=0,this.connectionEpoch=0,this.consecutiveFailures=0,this.stallCount=0,this.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{if(KO(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,KO(`ws_resume`,{gapMs:t,...this.wsSnap()},`info`),this.ws?.readyState===WebSocket.OPEN?this.verifyConnection():this.forceReconnect(`visibilitychange`,!0)}else this.stopHeartbeat(),this.cancelVerify(),this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null)},this.onPageShow=e=>{KO(`ws_pageshow`,{persisted:e.persisted,...this.wsSnap()},`info`),e.persisted&&(this.lastTick=Date.now(),this.forceReconnect(`pageshow`,!0))}}wsSnap(){return{status:this.status,ws:this.ws?aZ[this.ws.readyState]:null,attempt:this.reconnectAttempts,failures:this.consecutiveFailures,stalls:this.stallCount,leaked:this.leakedSockets.size,online:typeof navigator<`u`?navigator.onLine:void 0,verifying:this.verifyTimer!==null,buffered:this.ws?this.ws.bufferedAmount:void 0}}connect(){if(this.ws){let e=this.ws.readyState===WebSocket.OPEN;if(e&&this.status===`connected`){KO(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){KO(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}KO(`ws_connect_destroy_zombie`,{reason:e?`open_desynced`:`not_open`,...this.wsSnap()}),this.destroySocket()}this.manualClose=!1,this.clearConnectTimer(),this.setStatus(`connecting`);let e=`${window.location.protocol===`https:`?`wss`:`ws`}://${window.location.host}/ws`;KO(`ws_connect`,{url:e,resume:this.isResumeAttempt,...this.wsSnap()},`info`);let t=new WebSocket(e);this.ws=t,this.lastConnectTs=Date.now(),this.leakedSockets.add(t);let n=this.isResumeAttempt?sZ:oZ;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(KO(`ws_connect_timeout`,{wsState:aZ[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){KO(`ws_onopen_stale`,this.wsSnap(),`info`);return}KO(`ws_onopen`,this.wsSnap(),`info`),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=0,this.stallCount=0,this.connectionEpoch+=1,this.leakedSockets.delete(t),this.setStatus(`connected`),this.startHeartbeat()},t.onmessage=e=>{try{let t=e.data,n=performance.now(),r=JSON.parse(t),i=performance.now()-n,a=r;if(a._parseMs=Math.round(i),a._rawLength=t.length,r.type===`pong`){r.seq===this.pingSeq&&(this.clearPongTimer(),this.verifyTimer!==null&&(this.cancelVerify(),KO(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(pZ)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(KO(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){KO(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}KO(`ws_onclose`,{code:e.code,reason:e.reason,clean:e.wasClean,...this.wsSnap()},`info`),this.clearConnectTimer(),this.cancelVerify(),this.consecutiveFailures+=1,this.ws=null,this.manualClose?this.setStatus(`disconnected`):this.scheduleReconnect()}}disconnect(){this.manualClose=!0,this.clearConnectTimer(),this.cancelVerify(),this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null),this.destroySocket(),this.setStatus(`disconnected`)}startLifecycleListeners(){this.lifecycleStarted||typeof document>`u`||typeof window>`u`||(this.lifecycleStarted=!0,document.addEventListener(`visibilitychange`,this.onVisibilityChange),window.addEventListener(`pageshow`,this.onPageShow),this.lastTick=Date.now(),this.wakeCheckInterval=window.setInterval(()=>{let e=Date.now(),t=e-this.lastTick;this.isHidden()||(t>cZ&&(KO(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},lZ))}stopLifecycleListeners(){this.lifecycleStarted&&(this.lifecycleStarted=!1,document.removeEventListener(`visibilitychange`,this.onVisibilityChange),window.removeEventListener(`pageshow`,this.onPageShow),this.wakeCheckInterval!==null&&(window.clearInterval(this.wakeCheckInterval),this.wakeCheckInterval=null))}send(e){if(this.ws?.readyState!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(e)),!0}catch(t){return KO(`ws_send_error`,{messageType:e.type,error:t instanceof Error?t.message:String(t),...this.wsSnap()},`info`),this.destroySocket(),this.scheduleReconnect(),!1}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}subscribeStatus(e){return this.statusListeners.add(e),e(this.status,this.error,this.connectionEpoch),()=>this.statusListeners.delete(e)}getStatus(){return this.status}getConnectionEpoch(){return this.connectionEpoch}verifyConnection(){this.cancelVerify(),this.stopHeartbeat(),this.pingSeq+=1;let e=this.pingSeq,t=this.ws;if(KO(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){KO(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(KO(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},fZ)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){KO(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){KO(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){KO(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,KO(`ws_force_reconnect`,{trigger:e,force:t,...this.wsSnap()},`info`),this.reconnectAttempts=0,this.consecutiveFailures=0,this.stallCount=0,this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null),this.destroySocket(),t?(this.purgeLeakedSockets(),this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},mZ)):this.connect()}startHeartbeat(e){this.stopHeartbeat();let t=()=>{this.ws?.readyState===WebSocket.OPEN&&(this.pingSeq+=1,this.send({type:`ping`,seq:this.pingSeq})&&(this.clearPongTimer(),this.pongTimer=window.setTimeout(()=>{this.pongTimer=null,KO(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},dZ)))};e!==void 0&&e<uZ?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,uZ)},e):this.heartbeatTimer=window.setInterval(t,uZ)}stopHeartbeat(){this.heartbeatTimer!==null&&(window.clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null),this.clearPongTimer()}clearPongTimer(){this.pongTimer!==null&&(window.clearTimeout(this.pongTimer),this.pongTimer=null)}setStatus(e,t=null){this.status=e,this.error=t,this.statusListeners.forEach(n=>n(e,t,this.connectionEpoch))}scheduleReconnect(){if(this.stopHeartbeat(),this.isHidden()){KO(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=hZ){KO(`ws_stall_detected`,this.wsSnap(),`info`),this.purgeLeakedSockets();let e=Math.min(gZ*2**this.stallCount,3e4);this.stallCount+=1,this.consecutiveFailures=0,this.reconnectAttempts=0,this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},e);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);KO(`ws_schedule_reconnect`,{delay:e,...this.wsSnap()}),this.setStatus(`reconnecting`),this.reconnectTimer&&window.clearTimeout(this.reconnectTimer),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}isHidden(){return typeof document<`u`&&document.visibilityState===`hidden`}clearConnectTimer(){this.connectTimer&&=(window.clearTimeout(this.connectTimer),null)}destroySocket(){if(this.clearConnectTimer(),this.stopHeartbeat(),this.cancelVerify(),!this.ws)return;let e=this.ws;this.ws=null,this.leakedSockets.add(e),e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}purgeLeakedSockets(){if(this.leakedSockets.size!==0){KO(`ws_purge_leaked`,{count:this.leakedSockets.size},`info`);for(let e of this.leakedSockets)try{e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,e.close()}catch{}this.leakedSockets.clear()}}};function vZ(){let e=Sh(e=>e.setConnectionState);return(0,C.useEffect)(()=>{_Z.connect(),_Z.startLifecycleListeners();let t=_Z.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),_Z.stopLifecycleListeners()}},[e]),{sendMessage:(0,C.useMemo)(()=>e=>{_Z.send(e)},[]),subscribe:(0,C.useMemo)(()=>_Z.subscribe.bind(_Z),[]),getConnectionEpoch:(0,C.useMemo)(()=>()=>_Z.getConnectionEpoch(),[])}}var yZ=100;function bZ({viewport:e,win:t,doc:n}){if(!e)return!1;let r=Math.max(0,e.offsetTop||0),i=Math.max(0,e.offsetLeft||0),a=t.innerHeight-(e.height+r),o=Math.max(0,a),s=Math.max(0,e.height||0),c=Math.max(0,e.width||0);return n.documentElement.style.setProperty(`--keyboard-inset`,`${o}px`),n.documentElement.style.setProperty(`--viewport-offset-top`,`${r}px`),n.documentElement.style.setProperty(`--viewport-offset-left`,`${i}px`),n.documentElement.style.setProperty(`--visual-viewport-height`,`${s}px`),n.documentElement.style.setProperty(`--visual-viewport-width`,`${c}px`),o>yZ?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function xZ(e){e.documentElement.style.removeProperty(`--keyboard-inset`),e.documentElement.style.removeProperty(`--viewport-offset-top`),e.documentElement.style.removeProperty(`--viewport-offset-left`),e.documentElement.style.removeProperty(`--visual-viewport-height`),e.documentElement.style.removeProperty(`--visual-viewport-width`),e.documentElement.classList.remove(`keyboard-visible`)}function SZ(){(0,C.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=null,n=null,r=()=>{let e=document.activeElement;if(!e)return!1;let t=e.tagName?.toLowerCase();return t===`input`||t===`textarea`?!0:!!e.isContentEditable},i=()=>{bZ({viewport:e,win:window,doc:document})},a=()=>{if(typeof window.requestAnimationFrame!=`function`){i();return}t!==null&&window.cancelAnimationFrame(t);let e=performance.now(),n=()=>{i(),t=performance.now()-e<1500?window.requestAnimationFrame(n):null};t=window.requestAnimationFrame(n)},o=()=>{if(!r()){c();return}i()},s=()=>{n!==null||typeof window.setInterval!=`function`||(n=window.setInterval(o,250),o())},c=()=>{n===null||typeof window.clearInterval!=`function`||(window.clearInterval(n),n=null)},l=()=>{r()?(a(),s(),i()):c()},u=()=>{l()},d=()=>{l()},f=()=>{a()};return i(),l(),e.addEventListener(`resize`,i),e.addEventListener(`scroll`,i),typeof window.addEventListener==`function`&&(window.addEventListener(`resize`,i),window.addEventListener(`orientationchange`,f)),typeof document.addEventListener==`function`&&(document.addEventListener(`focusin`,u),document.addEventListener(`focusout`,d),document.addEventListener(`focus`,u,!0),document.addEventListener(`blur`,d,!0)),()=>{e.removeEventListener(`resize`,i),e.removeEventListener(`scroll`,i),typeof window.removeEventListener==`function`&&(window.removeEventListener(`resize`,i),window.removeEventListener(`orientationchange`,f)),typeof document.removeEventListener==`function`&&(document.removeEventListener(`focusin`,u),document.removeEventListener(`focusout`,d),document.removeEventListener(`focus`,u,!0),document.removeEventListener(`blur`,d,!0)),t!==null&&typeof window.cancelAnimationFrame==`function`&&window.cancelAnimationFrame(t),c(),xZ(document)}},[])}var CZ=[`theme`,`commandPresets`,`defaultPresetId`,`defaultProjectDir`,`lastProjectPath`,`recentPaths`,`sessionSortMode`,`sessionSortDirection`,`manualSessionOrder`,`sidebarAnchor`,`projectFilters`,`hostFilters`],wZ=[`claude`,`claude-rp`,`codex`,`pi`,`devin`,`grok`,`omp`];function TZ(e,t){return Array.isArray(e)&&e.length<=t&&e.every(e=>typeof e==`string`)}function EZ(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.id==`string`&&t.id.length>=1&&t.id.length<=128&&typeof t.label==`string`&&t.label.trim().length>=1&&t.label.length<=64&&typeof t.command==`string`&&t.command.trim().length>=1&&t.command.length<=1024&&typeof t.isBuiltIn==`boolean`&&(t.agentType===void 0||wZ.includes(t.agentType))}var DZ={theme:e=>e===`dark`||e===`light`,commandPresets:e=>Array.isArray(e)&&e.length<=50&&e.every(EZ),defaultPresetId:e=>typeof e==`string`&&e.length<=128,defaultProjectDir:e=>typeof e==`string`&&e.length<=4096,lastProjectPath:e=>e===null||typeof e==`string`&&e.length<=4096,recentPaths:e=>TZ(e,50),sessionSortMode:e=>e===`status`||e===`created`||e===`manual`,sessionSortDirection:e=>e===`asc`||e===`desc`,manualSessionOrder:e=>TZ(e,1e3),sidebarAnchor:e=>e===`top`||e===`bottom`,projectFilters:e=>TZ(e,500),hostFilters:e=>TZ(e,500)};function OZ(e){return CZ.includes(e)}function kZ(e,t){return DZ[e](t)}var AZ=`agentboard-theme`,jZ=`agentboard-settings`,MZ=200,NZ=new Map,PZ=new Set,FZ=null,IZ=!1;function LZ(e){return e===`theme`?RG.getState().theme:W.getState()[e]}function RZ(e){let t=e===`theme`?AZ:jZ;return Je.getItem(t)!==null}function zZ(){if(FZ=null,PZ.size===0)return;let e={};for(let t of PZ){let n=LZ(t);e[t]=n,NZ.set(t,JSON.stringify(n))}PZ.clear();try{fetch(`/api/settings/synced`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({settings:e})}).then(e=>{e.ok||KO(`synced_settings_push_rejected`,{status:e.status},`warn`)}).catch(e=>{KO(`synced_settings_push_failed`,{message:e instanceof Error?e.message:String(e)},`warn`)})}catch(e){KO(`synced_settings_push_failed`,{message:e instanceof Error?e.message:String(e)},`warn`)}}function BZ(e){PZ.add(e),!FZ&&(FZ=setTimeout(zZ,MZ))}function VZ(e){let t=new Map;for(let e of CZ)t.set(e,RZ(e));let n={},r;for(let[t,i]of Object.entries(e))!OZ(t)||!kZ(t,i)||(NZ.set(t,JSON.stringify(i)),t===`theme`?r=i:n[t]=i);r!==void 0&&RG.setState({theme:r}),Object.keys(n).length>0&&W.setState(n);for(let n of CZ){if(n in e||!t.get(n))continue;let r=LZ(n);kZ(n,r)&&NZ.get(n)!==JSON.stringify(r)&&BZ(n)}}function HZ(){if(IZ)return()=>{};IZ=!0;let e=W.subscribe((e,t)=>{let n=e,r=t;for(let e of CZ)e!==`theme`&&n[e]!==r[e]&&NZ.get(e)!==JSON.stringify(n[e])&&BZ(e)}),t=RG.subscribe((e,t)=>{e.theme!==t.theme&&NZ.get(`theme`)!==JSON.stringify(e.theme)&&BZ(`theme`)});return()=>{e(),t(),IZ=!1,FZ&&=(clearTimeout(FZ),null),PZ.clear(),NZ.clear()}}function UZ(e,t,n){let r=e;return t.length>0&&(r=r.filter(e=>t.includes(e.projectPath))),n.length>0&&(r=r.filter(e=>n.includes(e.host??``))),r}function WZ(){let[e,t]=(0,C.useState)(!1),[n,r]=(0,C.useState)(void 0),[i,a]=(0,C.useState)(void 0),[o,s]=(0,C.useState)(void 0),[c,l]=(0,C.useState)(!1),[u,d]=(0,C.useState)(null),[f,p]=(0,C.useState)(null),[m,h]=(0,C.useState)(null),g=Sh(e=>e.sessions),_=Sh(e=>e.agentSessions),v=Sh(e=>e.agentSessionsEpoch),y=Sh(e=>e.selectedSessionId),b=Sh(e=>e.selectedHibernatingSessionId),x=Sh(e=>e.setSessions),w=Sh(e=>e.setAgentSessions),T=Sh(e=>e.setActiveAgentSessions),E=Sh(e=>e.setHostStatuses),D=Sh(e=>e.updateSession),O=Sh(e=>e.setSelectedSessionId),k=Sh(e=>e.setSelectedHibernatingSessionId),A=Sh(e=>e.hasLoaded),j=Sh(e=>e.connectionStatus),M=Sh(e=>e.connectionError),N=Sh(e=>e.clearExitingSession),P=Sh(e=>e.markSessionExiting),F=Sh(e=>e.setRemoteAllowControl),I=Sh(e=>e.setRemoteAllowAttach),L=Sh(e=>e.setHostLabel),ee=Sh(e=>e.setPreferWindowName),R=Sh(e=>e.hostStatuses),z=Sh(e=>e.remoteAllowControl),B=Sh(e=>e.hostLabel),te=RG(e=>e.theme),V=st(),H=W(e=>e.defaultProjectDir),ne=W(e=>e.commandPresets),re=W(e=>e.defaultPresetId),ie=W(e=>e.lastProjectPath),U=W(e=>e.setLastProjectPath),ae=W(e=>e.addRecentPath),oe=W(e=>e.shortcutModifier),se=W(e=>e.sidebarWidth),ce=W(e=>e.sidebarAnchor),le=W(e=>e.setSidebarWidth),ue=W(e=>e.projectFilters),de=W(e=>e.hostFilters),fe=W(e=>e.soundOnPermission),pe=W(e=>e.soundOnIdle),me=Sh(e=>e.connectionEpoch),{sendMessage:he,subscribe:ge,getConnectionEpoch:_e}=vZ();(0,C.useEffect)(()=>HZ(),[]),SZ(),(0,C.useEffect)(()=>{if(typeof document>`u`||!fe&&!pe)return;let e=!1,t=()=>{e&&!eY()||(e=!0,nY())};return document.addEventListener(`click`,t,{passive:!0}),document.addEventListener(`keydown`,t,{passive:!0}),document.addEventListener(`touchstart`,t,{passive:!0}),()=>{document.removeEventListener(`click`,t),document.removeEventListener(`keydown`,t),document.removeEventListener(`touchstart`,t)}},[fe,pe]);let ve=(0,C.useRef)(!1),ye=(0,C.useCallback)(e=>{e.preventDefault(),ve.current=!0,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[]);(0,C.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=e=>{if(!ve.current)return;let t=e.clientX;le(Math.max(180,Math.min(400,t)))},t=()=>{ve.current&&(ve.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[le]),(0,C.useEffect)(()=>{let e=ge(e=>{if(e.type!==`terminal-output`){if(e.type===`sessions`){let t=Sh.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=W.getState();if(n||r)for(let i of e.sessions){let e=t.find(e=>e.id===i.id);e&&e.status!==i.status&&(e.status!==`permission`&&i.status===`permission`&&n&&aY(),e.status===`working`&&i.status===`waiting`&&r&&oY())}if(Fe.current.size>0){let e=_e();for(let[t,n]of Fe.current)n.epoch!==e&&Fe.current.delete(t)}let i=Fe.current.size>0?e.sessions.filter(e=>!Fe.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=Sh.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(je.current=s),x(i);let c=Me.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=Sh.getState(),{projectFilters:d,hostFilters:f}=W.getState();if(c&&l===null&&u===null){let e=i.find(e=>!(e.agentSessionId?.trim()!==c||d.length>0&&!d.includes(e.projectPath)||f.length>0&&!f.includes(e.host??``)));e&&(Me.current=null,O(e.id))}}if(e.type===`host-status`&&E(e.hosts),e.type===`server-config`&&(F(e.remoteAllowControl),I(e.remoteAllowAttach),L(e.hostLabel),ee(e.preferWindowName),e.clientLogLevel&&GO(e.clientLogLevel)),e.type===`synced-settings`&&VZ(e.settings),e.type===`session-update`){let t=Sh.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(D(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=W.getState();t!==`permission`&&n===`permission`&&e&&aY(),t===`working`&&n===`waiting`&&r&&oY()}}if(e.type===`session-created`){let t=Sh.getState().sessions;t.some(t=>t.id===e.session.id)||x([e.session,...t]),O(e.session.id),ae(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=W.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){aG(e.sessionId);let t=Sh.getState().sessions,n=t.filter(t=>t.id!==e.sessionId);n.length!==t.length&&x(n)}if(e.type===`agent-sessions`){let t=Array.isArray(e.active)?e.active:[],n=Array.isArray(e.hibernating)?e.hibernating:[],r=Array.isArray(e.history)?e.history:[],{selectedHibernatingSessionId:i}=Sh.getState(),a=je.current;i&&!n.some(e=>e.sessionId===i)&&(Me.current=i),w(t,n,r),h(e=>e&&n.some(t=>t.sessionId===e.sessionId)?null:e),a&&n.some(e=>e.sessionId===a)?(je.current=null,k(a)):a&&(je.current=null)}if(e.type===`agent-sessions-active`&&T(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=Sh.getState().sessions,n=t.filter(t=>t.agentSessionId?.trim()!==e.session.sessionId);n.length!==t.length&&x(n)}if(e.type===`session-activated`){let t=Sh.getState().sessions.find(t=>t.tmuxWindow===e.window);t&&D({...t,agentSessionId:e.session.sessionId,agentSessionName:e.session.displayName,logFilePath:e.session.logFilePath,isHibernating:e.session.isHibernating,lastUserMessage:e.session.lastUserMessage??t.lastUserMessage})}if(e.type===`session-wake-result`)if(e.ok&&e.session){h(t=>t?.sessionId===e.sessionId?null:t);let t=Sh.getState().sessions;t.some(t=>t.id===e.session.id)||x([e.session,...t]),O(e.session.id)}else e.ok||(d(`${e.error?.code}: ${e.error?.message}`),window.setTimeout(()=>d(null),6e3));if(e.type===`session-hibernate-result`&&(e.ok?(e.session&&h(e.session),k(e.sessionId)):(d(e.error??`Failed to hibernate session`),window.setTimeout(()=>d(null),6e3))),e.type===`terminal-error`&&(!e.sessionId||e.sessionId===y)&&(d(`${e.code}: ${e.message}`),window.setTimeout(()=>d(null),6e3)),e.type===`terminal-ready`&&e.sessionId===y&&d(null),e.type===`error`&&(d(e.message),window.setTimeout(()=>d(null),6e3)),e.type===`kill-failed`){let t=Fe.current.get(e.sessionId);if(t){let n=Sh.getState().sessions;n.some(t=>t.id===e.sessionId)||x([t.session,...n]),t.wasSelected&&O(e.sessionId),Fe.current.delete(e.sessionId)}N(e.sessionId),d(e.message),window.setTimeout(()=>d(null),6e3)}e.type===`session-move-to-history-result`&&!e.ok&&e.error&&(d(e.error),window.setTimeout(()=>d(null),6e3))}});return()=>{e()}},[y,b,ae,N,he,O,k,h,x,w,T,E,F,I,L,ee,ge,D]);let be=(0,C.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),xe=_.hibernating??[],Se=_.history??[],Ce=(0,C.useMemo)(()=>UZ(xe,ue,de),[xe,ue,de]),we=(0,C.useMemo)(()=>Ce.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[Ce,m,b]);(0,C.useEffect)(()=>{be?.projectPath&&!be.remote&&U(be.projectPath)},[be?.projectPath,be?.remote,U]);let Te=W(e=>e.sessionSortMode),Ee=W(e=>e.sessionSortDirection),De=W(e=>e.manualSessionOrder),Oe=(0,C.useMemo)(()=>oh(g,{mode:Te,direction:Ee,manualOrder:De}),[g,Te,Ee,De]),ke=(0,C.useMemo)(()=>{let e=Oe;return ue.length>0&&(e=e.filter(e=>ue.includes(e.projectPath))),de.length>0&&(e=e.filter(e=>de.includes(e.host??``))),e},[Oe,ue,de]),Ae=(0,C.useRef)(b),je=(0,C.useRef)(null),Me=(0,C.useRef)(null),Ne=(0,C.useRef)(me),Pe=(0,C.useCallback)(()=>ke.length>0?(O(ke[0].id),!0):Ce.length>0?(k(Ce[0].sessionId),!0):!1,[ke,Ce,O,k]);(0,C.useEffect)(()=>{let e=Ae.current;e&&b===null&&!xe.some(t=>t.sessionId===e)?Me.current=e:b!==null&&(Me.current=null),Ae.current=b},[xe,b]),(0,C.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,C.useEffect)(()=>{Ne.current!==me&&(Ne.current=me,je.current=null,Me.current=null,h(null))},[me]),(0,C.useEffect)(()=>{A&&(b||y&&(ke.some(e=>e.id===y)||Pe()||O(null)))},[A,y,b,Pe,O]),(0,C.useEffect)(()=>{if(!b||m?.sessionId===b||v!==me||Ce.some(e=>e.sessionId===b))return;let e=ke.find(e=>e.agentSessionId?.trim()===b);if(e){O(e.id);return}Pe()||k(null)},[Ce,ke,v,m,b,Pe,O,k,me]),(0,C.useEffect)(()=>{let e=Me.current;if(!e)return;if(b!==null){Me.current=null;return}let t=ke.find(t=>t.agentSessionId?.trim()===e);if(t){Me.current=null,O(t.id);return}if(y!==null){Me.current=null;return}Pe()&&(Me.current=null)},[ke,y,b,Pe,O]),(0,C.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&A&&y===null&&b===null&&(ke.length>0||Ce.length>0)&&Pe()},[Ce.length,ke.length,A,Pe,y,b]);let Fe=(0,C.useRef)(new Map),Ie=(0,C.useCallback)((e,t=`unknown`)=>{aG(e);let{sessions:n,selectedSessionId:r}=Sh.getState(),i=n.find(t=>t.id===e);i&&Fe.current.set(e,{session:i,wasSelected:r===e,epoch:_e()}),(0,Vd.flushSync)(()=>{P(e),x(n.filter(t=>t.id!==e))}),he({type:`session-kill`,sessionId:e,source:t})},[P,x,he]);(0,C.useEffect)(()=>{let n=dt(oe),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=mt(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=(i===`BracketLeft`?-1:1)*(ce===`bottom`?-1:1),t=ke;if(t.length===0){let t=Ce;if(t.length===0)return;let n=t.findIndex(e=>e.sessionId===b);if(n===-1){k(t[0].sessionId);return}k(t[(n+e+t.length)%t.length].sessionId);return}let n=t.findIndex(e=>e.id===y);if(n===-1){O(t[0].id);return}O(t[(n+e+t.length)%t.length].id);return}if(a&&/^Digit[1-9]$/.test(i)){let e=Number(i.slice(5))-1;if(ke.length>0){let t=ke[e];if(!t)return;r.preventDefault(),O(t.id);return}let t=Ce[e];if(!t)return;r.preventDefault(),k(t.sessionId);return}if(a&&i===`KeyN`){r.preventDefault(),!e&&V&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Ie(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,O,k,ke,Ce,Ie,ce,oe,V]);let Le=()=>V?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,Re=()=>l(!0),ze=(e,t,n,r)=>{he({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||U(e)},Be=e=>{he({type:`session-wake`,sessionId:e})},Ve=(0,C.useCallback)(e=>{he({type:`session-hibernate`,sessionId:e})},[he]),He=(e,t)=>{he({type:`session-rename`,sessionId:e,newName:t})},Ue=(0,C.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&he({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,he]),We=(0,C.useCallback)(e=>{he({type:`session-move-to-history`,sessionId:e})},[he]);(0,C.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,te)},[te]),(0,C.useEffect)(()=>{fetch(`/api/server-info`).then(e=>e.json()).then(e=>p(e)).catch(()=>{})},[]);let Ge=(0,C.useMemo)(()=>B?R.filter(e=>e.host!==B):R,[R,B]);return(0,S.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,S.jsx)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:se},children:(0,S.jsx)(BO,{sessions:g,hibernatingSessions:xe,historySessions:Se,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:O,onSelectHibernating:k,onRename:He,onResume:Be,onHibernate:Ve,onKill:Ie,onDuplicate:Ue,onMoveToHistory:We,onNewSession:Le,loading:!A,error:M||u,anchor:ce,filterBarControls:(0,S.jsx)(Et,{connectionStatus:j,onNewSession:Le,onOpenSettings:Re,tailscaleIp:f?.tailscaleIp??null,placement:ce===`bottom`?`up`:`down`})})}),(0,S.jsx)(`div`,{className:`hidden md:block w-1 shrink-0 cursor-col-resize bg-transparent transition-colors hover:bg-white/10 active:bg-white/20`,onMouseDown:ye}),(0,S.jsx)($K,{session:be,sessions:ke,drawerSessions:g,hibernatingSession:we,hibernatingSessions:xe,connectionStatus:j,connectionEpoch:me,sendMessage:he,subscribe:ge,onClose:()=>O(null),onSelectSession:O,onSelectHibernatingSession:k,onNewSession:Le,onKillSession:Ie,onRenameSession:He,onDuplicateSession:Ue,onOpenSettings:Re,onResumeSession:Be,onHibernateSession:Ve,onMoveToHistory:We,historySessions:Se,loading:!A,error:M||u}),(0,S.jsx)(vq,{isOpen:e,onClose:()=>t(!1),onCreate:ze,defaultProjectDir:H,commandPresets:ne,defaultPresetId:re,lastProjectPath:ie,activeProjectPath:be&&!be.remote?be.projectPath:void 0,remoteHosts:Ge,remoteAllowControl:z,initialHost:n,initialPath:i,initialCommand:o}),(0,S.jsx)(sY,{isOpen:c,onClose:()=>l(!1)}),(0,S.jsx)(iZ,{})]})}var GZ=`modulepreload`,KZ=function(e){return`/`+e},qZ={},JZ=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=KZ(t,n),t in qZ)return;qZ[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:GZ,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},YZ=`true`,XZ=`false`,ZZ=YZ===`true`,QZ=XZ===`true`;function $Z(e={}){let{immediate:t=!1,onNeedRefresh:n,onOfflineReady:r,onRegistered:i,onRegisteredSW:a,onRegisterError:o}=e,s,c,l,u=async(e=!0)=>{await c,ZZ||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await JZ(async()=>{let{Workbox:e}=await import(`./workbox-window.prod.es5-Bq4GJJid.js`);return{Workbox:e}},[]).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{o?.(e)}),!s)return;if(l=()=>{s?.messageSkipWaiting()},!QZ)if(ZZ)s.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&window.location.reload()}),s.addEventListener(`installed`,e=>{e.isUpdate||r?.()});else{let e=!1,t=()=>{e=!0,s?.addEventListener(`controlling`,e=>{e.isUpdate&&window.location.reload()}),n?.()};s.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&r?.():n.isExternal?t():!e&&r?.():n.isUpdate||r?.()}),s.addEventListener(`waiting`,t)}s.register({immediate:t}).then(e=>{a?a(`/sw.js`,e):i?.(e)}).catch(e=>{o?.(e)})}}return c=d(),u}ct()&&document.documentElement.classList.add(`ios`),lt()&&document.documentElement.classList.add(`ios-pwa`),$Z({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var eQ=document.getElementById(`root`);if(!eQ)throw Error(`Root element not found`);(0,x.createRoot)(eQ).render((0,S.jsx)(C.StrictMode,{children:(0,S.jsx)(WZ,{})}));
@@ -8,7 +8,7 @@
8
8
  <title>Agentboard</title>
9
9
  <link rel="apple-touch-icon" href="/icons/pwa-192x192.png" />
10
10
  <meta name="theme-color" content="#0f172a" />
11
- <script type="module" crossorigin src="/assets/index-D2AOHw62.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-B8IKAXvp.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="/assets/index-BYcxg5qQ.css">
13
13
  <link rel="manifest" href="/manifest.webmanifest"></head>
14
14
  <body>
package/dist/client/sw.js CHANGED
@@ -1 +1 @@
1
- if(!self.define){let e,n={};const i=(i,o)=>(i=new URL(i+".js",o).href,n[i]||new Promise(n=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=n,document.head.appendChild(e)}else e=i,importScripts(i),n()}).then(()=>{let e=n[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(o,s)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(n[r])return;let f={};const d=e=>i(e,r),t={module:{uri:r},exports:f,require:d};n[r]=Promise.all(o.map(e=>t[e]||d(e))).then(e=>(s(...e),f))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"index.html",revision:"2bd641f6bc5ada6722f640dd13bef32b"},{url:"favicon.svg",revision:"12048a608dedfc53518ddc59c07e41b6"},{url:"icons/pwa-512x512.png",revision:"eb82042b3e4ed505f3efe1b79622d998"},{url:"icons/pwa-192x192.png",revision:"affb57c15619ee7223d1adea372ad514"},{url:"fonts/jetbrains-mono-vietnamese-wght-normal.woff2",revision:"ddf99e6e35c6ee9f00a41d2567b0e77f"},{url:"fonts/jetbrains-mono-latin-wght-normal.woff2",revision:"b058178d7f309414f8f856b99fd80d9b"},{url:"fonts/jetbrains-mono-latin-ext-wght-normal.woff2",revision:"e36841ed93d5bfe6b1d487d18ad7e90b"},{url:"fonts/jetbrains-mono-greek-wght-normal.woff2",revision:"51671ed9eb64e29390d4791ab0023c8e"},{url:"fonts/jetbrains-mono-cyrillic-wght-normal.woff2",revision:"615bf869ebeb5998734d81fc8958116c"},{url:"fonts/jetbrains-mono-cyrillic-ext-wght-normal.woff2",revision:"742dd0628e0118d32dccf0437900670b"},{url:"assets/workbox-window.prod.es5-Bq4GJJid.js",revision:null},{url:"assets/index-D2AOHw62.js",revision:null},{url:"assets/index-BYcxg5qQ.css",revision:null},{url:"icons/pwa-192x192.png",revision:"affb57c15619ee7223d1adea372ad514"},{url:"icons/pwa-512x512.png",revision:"eb82042b3e4ed505f3efe1b79622d998"},{url:"manifest.webmanifest",revision:"b6d4b3666a548fa0f0c6919d31ec2eee"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"),{denylist:[/^\/api(?:\/|$)/,/^\/ws(?:\/|$)/]}))});
1
+ if(!self.define){let e,n={};const i=(i,o)=>(i=new URL(i+".js",o).href,n[i]||new Promise(n=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=n,document.head.appendChild(e)}else e=i,importScripts(i),n()}).then(()=>{let e=n[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(o,s)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(n[r])return;let f={};const t=e=>i(e,r),d={module:{uri:r},exports:f,require:t};n[r]=Promise.all(o.map(e=>d[e]||t(e))).then(e=>(s(...e),f))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"index.html",revision:"ede22f637692bfe4bb3ba11d1f27be8c"},{url:"favicon.svg",revision:"12048a608dedfc53518ddc59c07e41b6"},{url:"icons/pwa-512x512.png",revision:"eb82042b3e4ed505f3efe1b79622d998"},{url:"icons/pwa-192x192.png",revision:"affb57c15619ee7223d1adea372ad514"},{url:"fonts/jetbrains-mono-vietnamese-wght-normal.woff2",revision:"ddf99e6e35c6ee9f00a41d2567b0e77f"},{url:"fonts/jetbrains-mono-latin-wght-normal.woff2",revision:"b058178d7f309414f8f856b99fd80d9b"},{url:"fonts/jetbrains-mono-latin-ext-wght-normal.woff2",revision:"e36841ed93d5bfe6b1d487d18ad7e90b"},{url:"fonts/jetbrains-mono-greek-wght-normal.woff2",revision:"51671ed9eb64e29390d4791ab0023c8e"},{url:"fonts/jetbrains-mono-cyrillic-wght-normal.woff2",revision:"615bf869ebeb5998734d81fc8958116c"},{url:"fonts/jetbrains-mono-cyrillic-ext-wght-normal.woff2",revision:"742dd0628e0118d32dccf0437900670b"},{url:"assets/workbox-window.prod.es5-Bq4GJJid.js",revision:null},{url:"assets/index-BYcxg5qQ.css",revision:null},{url:"assets/index-B8IKAXvp.js",revision:null},{url:"icons/pwa-192x192.png",revision:"affb57c15619ee7223d1adea372ad514"},{url:"icons/pwa-512x512.png",revision:"eb82042b3e4ed505f3efe1b79622d998"},{url:"manifest.webmanifest",revision:"b6d4b3666a548fa0f0c6919d31ec2eee"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"),{denylist:[/^\/api(?:\/|$)/,/^\/ws(?:\/|$)/]}))});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gbasin/agentboard-linux-arm64",
3
- "version": "0.23.0",
3
+ "version": "0.23.2",
4
4
  "description": "agentboard binary for linux-arm64",
5
5
  "repository": {
6
6
  "type": "git",