@gbasin/agentboard-linux-arm64 0.24.0 → 0.24.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
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 95398032 bytes
|
|
4
|
+
sha256: aba2e33f9510412d191eba8a44feb08b234258f8667cde8b9040b60a68e56472
|
|
@@ -303,4 +303,4 @@ ${s.join(`
|
|
|
303
303
|
active:scale-95 transition-all duration-75
|
|
304
304
|
select-none touch-manipulation
|
|
305
305
|
${r?nq[t.status]:tq[t.status]}
|
|
306
|
-
`,onClick:()=>{rq(),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)(RK,{...ut}),(0,S.jsx)(lK,{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)($K,{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)(eq,{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 aq({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 oq(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 sq(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?oq(o):null}function cq(e){return e?e===`claude-rp`?`claude`:e:null}function lq(e){let t=e.trim();if(!t)return``;let n=oq(t);return sq(n)??n}function uq(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 dq(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`:uq(e.split(`/`).pop()||e);return t?{agentType:t,end:n.index+n[0].length}:void 0}}function fq(e){let t=lq(e);if(t)return dq(t.toLowerCase().trim().replace(/^["']|["']$/g,``))?.agentType}var pq={claude:`--dangerously-skip-permissions`,codex:`--yolo`,grok:`--always-approve`,devin:`--permission-mode dangerous`,pi:null,omp:`--auto-approve`},mq={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 hq(e){let t=cq(e);return t?pq[t]:null}function gq(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _q(e){return RegExp(`(^|\\s)${gq(e)}(?=\\s|$)`,`g`)}function vq(e,t){return(t?[cq(t)].filter(e=>e!==null):Object.keys(mq)).some(t=>mq[t].some(t=>_q(t).test(e)))}function yq(e,t){let n=dq(e);return n?`${e.slice(0,n.end)} ${t}${e.slice(n.end)}`:null}function bq(e,t){let n=hq(t);if(!n)return e;let r=e.trim();if(!r||vq(r,t))return r;let i=yq(r,n);if(i)return i;let a=lq(r);if(a&&a!==r){let e=yq(a,n);if(e)return`bash -lc '${e.replace(/'/g,`'\\''`)}'`}return`${r} ${n}`}function xq(e,t){let n=cq(t);if(!n||vq(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 Sq(e,t){let n=cq(t);if(!n)return e;let r=e;for(let e of mq[n])r=r.replace(_q(e),` `);return r.replace(/\s+/g,` `).trim()}function Cq({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=fq(e);return t&&!xq(e,t)?bq(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=fq(y),z=hq(R)!==null,B=R?vq(y,R):!1,te=R&&!B?xq(y,R):null,V=!z||te!==null,H=R?R===`pi`?`Pi has no permission prompts — nothing to enable`:te??`Append ${hq(R)}`:`Enter a supported agent command (claude, codex, grok, devin)`,ne=e=>{O(e),R&&b(e?bq(y,R):Sq(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`,"data-suspends-terminal":``,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)(aq,{initialPath:ae,onSelect:e=>{m(e),w(!1)},onCancel:()=>w(!1)})]})}var wq=[{id:`new-sessions`,label:`New sessions`},{id:`session-list`,label:`Session list`},{id:`appearance`,label:`Appearance`},{id:`terminal`,label:`Terminal`},{id:`notifications`,label:`Notifications`}];function Tq(e){return wq.some(t=>t.id===e)}function Eq(e){return wq.find(t=>t.id===e)?.label??e}var Dq=`agentboard-settings-page`,Oq=`new-sessions`;function kq(){let e=Je.getItem(Dq);return Tq(e)?e:Oq}function Aq(e){Je.setItem(Dq,e)}var jq=`h-[32px] max-md:h-[44px]`,Mq=`${jq} inline-flex shrink-0 items-center justify-center border text-[12px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,Nq=`${Mq} border-border bg-surface px-3 text-secondary hover:bg-hover hover:text-primary`,Pq=`${Mq} w-[32px] max-md:w-[44px] border-border bg-surface text-secondary hover:bg-hover hover:text-primary`,Fq=`input ${jq} px-2 py-0 text-[13px] max-md:text-[16px] focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-50 aria-[invalid=true]:border-danger`;function Iq(e,t){let[n,r]=(0,C.useState)(null),[i,a]=(0,C.useState)(null),o=(0,C.useRef)({draft:n,stored:e,commit:t});o.current={draft:n,stored:e,commit:t},(0,C.useEffect)(()=>()=>{let{draft:e,stored:t,commit:n}=o.current;e!==null&&e!==t&&n(e)},[]);let s=()=>{if(n===null)return;if(n===e){r(null),a(null);return}let i=t(n);if(i){a(i);return}r(null),a(null)};return{value:n??e,error:i,dirty:n!==null,onChange:e=>{r(e.target.value),a(null)},onBlur:s,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&n!==null&&(e.preventDefault(),r(null),a(null))}}}var Lq=(0,C.forwardRef)(function({value:e,onCommit:t,describedBy:n,id:r,className:i,wrapperClassName:a,...o},s){let c=Iq(e,t),l=r?`${r}-error`:void 0,u=[n,c.error?l:void 0].filter(Boolean).join(` `);return(0,S.jsxs)(`div`,{className:l_(`min-w-0`,a),children:[(0,S.jsx)(`input`,{...o,ref:s,id:r,value:c.value,onChange:c.onChange,onBlur:c.onBlur,onKeyDown:c.onKeyDown,"aria-invalid":c.error?!0:void 0,"aria-describedby":u||void 0,className:l_(Fq,i)}),c.error&&(0,S.jsx)(`p`,{id:l,className:l_(`text-[12px] leading-snug text-danger`,`mt-1`),role:`alert`,children:c.error})]})});function Rq(e,t,n){let r=e.trim();return/^-?\d+$/.test(r)?Math.min(n,Math.max(t,Number.parseInt(r,10))):null}function zq({value:e,min:t,max:n,onChange:r,noun:i,labelledBy:a,describedBy:o}){return(0,S.jsxs)(`div`,{role:`group`,"aria-labelledby":a,"aria-describedby":o,className:`flex items-center`,children:[(0,S.jsx)(`button`,{type:`button`,className:Pq,"aria-label":`Decrease ${i}`,disabled:e<=t,onClick:()=>r(Math.max(t,e-1)),children:(0,S.jsx)(ye,{width:G.default,height:G.default})}),(0,S.jsx)(`output`,{"aria-live":`polite`,className:l_(jq,`flex w-10 items-center justify-center border-y border-border bg-base text-[13px] tabular-nums text-primary`),children:e}),(0,S.jsx)(`button`,{type:`button`,className:Pq,"aria-label":`Increase ${i}`,disabled:e>=n,onClick:()=>r(Math.min(n,e+1)),children:(0,S.jsx)(ke,{width:G.default,height:G.default})})]})}function Bq({id:e,value:t,min:n,max:r,step:i,onChange:a,format:o,labelledBy:s,describedBy:c}){return(0,S.jsxs)(`div`,{className:l_(jq,`flex items-center gap-3`),children:[(0,S.jsx)(`input`,{id:e,type:`range`,min:n,max:r,step:i,value:t,"aria-labelledby":s,"aria-describedby":c,"aria-valuetext":o(t),onChange:e=>{let t=Number.parseFloat(e.target.value);Number.isFinite(t)&&a(Math.min(r,Math.max(n,t)))},className:`h-1 w-28 max-md:w-36 cursor-pointer appearance-none bg-border accent-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),(0,S.jsx)(`span`,{className:`w-10 text-right text-[13px] tabular-nums text-secondary`,children:o(t)})]})}function Vq({options:e,value:t,onChange:n,labelledBy:r,describedBy:i,fill:a=!1}){let o=(0,C.useRef)([]),s=Math.max(0,e.findIndex(e=>e.value===t)),c=t=>{let r=e[t];r&&(n(r.value),o.current[t]?.focus())},l=(t,n)=>{let r=e.length-1,i=null;t.key===`ArrowRight`||t.key===`ArrowDown`?i=n===r?0:n+1:t.key===`ArrowLeft`||t.key===`ArrowUp`?i=n===0?r:n-1:t.key===`Home`?i=0:t.key===`End`&&(i=r),i!==null&&(t.preventDefault(),c(i))};return(0,S.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":r,"aria-describedby":i,className:l_(`flex border border-border bg-base p-[2px]`,a?`w-full`:`w-max max-w-full`),children:e.map((e,t)=>{let n=t===s;return(0,S.jsx)(`button`,{ref:e=>{o.current[t]=e},type:`button`,role:`radio`,"aria-checked":n,tabIndex:n?0:-1,onClick:()=>c(t),onKeyDown:e=>l(e,t),className:l_(`h-[26px] max-md:h-[38px] min-w-0 whitespace-nowrap px-3 text-[12px] transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,a&&`flex-1`,n?`bg-hover text-primary shadow-[inset_0_0_0_1px_var(--border)]`:`text-muted hover:text-primary`),children:e.label},e.value)})})}function Hq({ids:e}){return(0,S.jsx)(Vq,{options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`System`}],value:VG(e=>e.theme),onChange:VG(e=>e.setTheme),labelledBy:e.label,describedBy:e.description})}function Uq({ids:e}){let t=W(e=>e.fontOption),n=W(e=>e.setFontOption);return(0,S.jsx)(`select`,{id:e.control,value:t,"aria-describedby":e.description,onChange:e=>n(e.target.value),className:`${Fq} w-44 max-md:w-full`,children:$e.map(e=>(0,S.jsx)(`option`,{value:e.id,children:e.label},e.id))})}function Wq({ids:e}){let t=W(e=>e.customFontFamily);return(0,S.jsx)(Lq,{id:e.control,value:t,placeholder:`"Fira Code", monospace`,describedBy:e.description,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,maxLength:256,wrapperClassName:`w-60 max-md:w-full`,onCommit:e=>(W.getState().setCustomFontFamily(e.trim()),null)})}function Gq({ids:e}){return(0,S.jsx)(zq,{value:W(e=>e.fontSize),min:6,max:24,onChange:W(e=>e.setFontSize),noun:`font size`,labelledBy:e.label,describedBy:e.description})}function Kq({ids:e}){let t=W(e=>e.lineHeight),n=W(e=>e.setLineHeight);return(0,S.jsx)(Bq,{id:e.control,value:t,min:1,max:2,step:.1,onChange:e=>n(Math.round(e*10)/10),format:e=>e.toFixed(1),labelledBy:e.label,describedBy:e.description})}function qq({ids:e}){let t=W(e=>e.letterSpacing),n=W(e=>e.setLetterSpacing);return(0,S.jsx)(Bq,{id:e.control,value:t,min:-3,max:3,step:1,onChange:e=>n(Math.round(e)),format:e=>`${e}px`,labelledBy:e.label,describedBy:e.description})}var Jq=[{id:`theme`,page:`appearance`,label:`Theme`,description:`Light, dark, or follow the system setting.`,keywords:[`dark mode`,`light mode`,`color`,`colour`,`system`],Control:Hq},{id:`font-family`,page:`appearance`,label:`Font family`,description:`Terminal typeface. Default JetBrains Mono.`,keywords:[`font`,`typeface`,`monospace`],tags:[`device`],Control:Uq},{id:`custom-font-family`,page:`appearance`,label:`Custom font family`,description:`A CSS font-family list. Empty falls back to JetBrains Mono.`,keywords:[`font`,`typeface`,`css`],tags:[`device`],layout:`wide`,visibleWhen:e=>e.fontOption===`custom`,Control:Wq},{id:`font-size`,page:`appearance`,label:`Font size`,description:`Terminal text size in pixels (6–24). Default 13.`,keywords:[`font`,`text`,`zoom`,`size`],tags:[`device`],Control:Gq},{id:`line-height`,page:`appearance`,label:`Line height`,description:`Vertical spacing, 1.0 compact to 2.0 spacious. Default 1.0.`,keywords:[`spacing`,`leading`,`line`],tags:[`device`],Control:Kq},{id:`letter-spacing`,page:`appearance`,label:`Letter spacing`,description:`Extra space between characters in pixels (−3 to 3). Default 0.`,keywords:[`spacing`,`tracking`,`kerning`],tags:[`device`],Control:qq}],Yq=1024,Xq=[{value:``,label:`Terminal`},{value:`claude`,label:`Claude`},{value:`codex`,label:`Codex`},{value:`pi`,label:`Pi`},{value:`devin`,label:`Devin`},{value:`grok`,label:`Grok`},{value:`omp`,label:`OMP`}];function Zq(e,t){let n=t.trim();return e===`label`?n?n.length>64?`Name is at most 64 characters`:null:`Name is required`:n?n.length>1024?`Command is at most ${Yq} characters`:null:`Command is required`}function Qq(e){return Zq(`label`,e.label)===null&&Zq(`command`,e.command)===null}function $q(e,t,n){return e.map(e=>e.id===t?rt({...e,...n}):e)}var eJ=`grid items-start gap-2 grid-cols-[56px_92px_minmax(0,0.8fr)_minmax(0,1.3fr)_auto] max-md:grid-cols-[minmax(0,1fr)_minmax(0,auto)_auto] max-md:gap-y-2`,tJ=4e3;function nJ({preset:e,index:t,isDefault:n,pending:r=!1,autoFocusName:i=!1,onSetDefault:a,onCommitField:o,onIconChange:s,onDelete:c}){let[l,u]=(0,C.useState)(!1),d=(0,C.useRef)(null),f=`settings-preset-${e.id}`,p=e.label.trim()||`preset ${t+1}`;return(0,C.useEffect)(()=>{i&&d.current?.focus()},[i]),(0,C.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>u(!1),tJ);return()=>clearTimeout(e)},[l]),(0,S.jsxs)(`div`,{role:`listitem`,"data-preset-id":e.id,className:l_(eJ,`py-2`),children:[(0,S.jsxs)(`label`,{className:l_(jq,`flex cursor-pointer items-center gap-2 md:justify-center`),children:[(0,S.jsx)(`input`,{type:`radio`,name:`settings-default-preset`,checked:n,disabled:r,onChange:a,"aria-label":`Default preset: ${p}`,className:`size-4 cursor-pointer accent-accent disabled:cursor-not-allowed`}),(0,S.jsx)(`span`,{"aria-hidden":`true`,className:`text-[12px] text-secondary md:hidden`,children:`Default`})]}),e.isBuiltIn?(0,S.jsxs)(`div`,{className:l_(jq,`flex items-center gap-2 text-muted`),children:[(0,S.jsx)(Bh,{agentType:e.agentType,command:e.command,className:`size-4`}),(0,S.jsx)(`span`,{className:`text-[11px]`,children:`Built-in`})]}):(0,S.jsx)(`select`,{id:`${f}-icon`,value:e.agentType??``,"aria-label":`Icon for ${p}`,onChange:e=>s(e.target.value||void 0),className:l_(Fq,`w-full px-1`),children:Xq.map(e=>(0,S.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,S.jsx)(Lq,{ref:d,id:`${f}-label`,value:e.label,placeholder:`Name`,"aria-label":`Name of preset ${t+1}`,maxLength:64,onCommit:e=>o(`label`,e),wrapperClassName:`max-md:order-4 max-md:col-span-3`}),(0,S.jsx)(Lq,{id:`${f}-command`,value:e.command,placeholder:`command --flags`,"aria-label":`Command for ${p}`,maxLength:Yq,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,onCommit:e=>o(`command`,e),wrapperClassName:`max-md:order-5 max-md:col-span-3`}),e.isBuiltIn?(0,S.jsx)(`span`,{"aria-hidden":`true`,className:`w-[32px] max-md:order-3 max-md:w-[44px]`}):(0,S.jsx)(`button`,{type:`button`,onClick:()=>{if(r||l){c();return}u(!0)},onPointerDown:r?e=>e.preventDefault():void 0,onBlur:()=>u(!1),"aria-label":l?`Confirm delete ${p}`:r?`Discard new preset`:`Delete ${p}`,title:l?`Click again to delete`:void 0,className:l_(Mq,`max-md:order-3`,l?`border-danger bg-danger/10 px-2 text-danger hover:bg-danger/20`:`w-[32px] border-border bg-surface text-secondary hover:bg-hover hover:text-danger max-md:w-[44px]`),children:l?`Delete?`:(0,S.jsx)(R,{width:G.default,height:G.default})})]})}function rJ({ids:e}){let t=W(e=>e.commandPresets),n=W(e=>e.defaultPresetId),[r,i]=(0,C.useState)(null),a=(0,C.useRef)(null),o=(0,C.useRef)(null),s=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!s.current)return;s.current=!1;let e=o.current;if(e&&!e.disabled){e.focus();return}let t=a.current?.id;t&&typeof document<`u`&&document.getElementById(`settings-preset-${t}-label`)?.focus()});let c=e=>{a.current=e,i(e)},l=!r&&t.length<50,u=r?[...t,r]:t,d=(e,t,n)=>{let r=Zq(t,n);if(r)return r;let{commandPresets:i,setCommandPresets:a}=W.getState();return a($q(i,e,{[t]:n})),null},f=(e,t)=>{let n=a.current;if(!n)return null;let r={...n,[e]:t},{commandPresets:i,setCommandPresets:o}=W.getState();return Qq(r)&&i.length<50?(o([...i,rt(r)]),c(null)):c(r),null},p=(e,t)=>{if(r?.id===e){c({...r,agentType:t});return}let{commandPresets:n,setCommandPresets:i}=W.getState();i($q(n,e,{agentType:t}))},m=()=>{l&&c({id:at(new Set(t.map(e=>e.id))),label:``,command:``,isBuiltIn:!1})},h=e=>{s.current=!0,a.current?.id===e?c(null):W.getState().removePreset(e)};return(0,S.jsxs)(`div`,{className:`w-full min-w-0`,children:[(0,S.jsxs)(`div`,{"aria-hidden":`true`,className:l_(eJ,`border-b border-border pb-1 text-[11px] uppercase tracking-wide text-muted max-md:hidden`),children:[(0,S.jsx)(`span`,{className:`text-center`,children:`Default`}),(0,S.jsx)(`span`,{children:`Icon`}),(0,S.jsx)(`span`,{children:`Name`}),(0,S.jsx)(`span`,{children:`Command`}),(0,S.jsx)(`span`,{className:`w-[32px]`})]}),(0,S.jsx)(`div`,{role:`list`,"aria-labelledby":e.label,"aria-describedby":e.description,className:`divide-y divide-border-subtle`,children:u.map((e,t)=>{let i=e.id===r?.id;return(0,S.jsx)(nJ,{preset:e,index:t,isDefault:e.id===n,pending:i,autoFocusName:i,onSetDefault:()=>W.getState().setDefaultPresetId(e.id),onCommitField:(t,n)=>i?f(t,n):d(e.id,t,n),onIconChange:t=>p(e.id,t),onDelete:()=>h(e.id)},e.id)})}),r&&(0,S.jsx)(`p`,{className:l_(`text-[12px] leading-snug text-muted`,`pb-2`),role:`status`,children:`Enter a name and a command to add the preset.`}),(0,S.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,S.jsxs)(`button`,{ref:o,type:`button`,className:Nq,onClick:m,disabled:!l,children:[(0,S.jsx)(ke,{width:G.default,height:G.default,className:`mr-1.5`}),`Add preset`]}),t.length>=50&&(0,S.jsxs)(`span`,{className:`text-[12px] leading-snug text-muted`,children:[`Maximum of `,50,` presets.`]})]})]})}function iJ({ids:e}){let t=W(e=>e.defaultProjectDir);return(0,S.jsx)(Lq,{id:e.control,value:t,placeholder:Xe,describedBy:e.description,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,maxLength:4096,wrapperClassName:`w-72 max-md:w-full`,onCommit:e=>(W.getState().setDefaultProjectDir(e.trim()||`~/Documents/GitHub`),null)})}var aJ=[{id:`default-project-dir`,page:`new-sessions`,label:`Default project directory`,description:`Folder the new session dialog starts in. Default ${Xe}.`,keywords:[`path`,`folder`,`cwd`,`directory`],layout:`wide`,Control:iJ},{id:`command-presets`,page:`new-sessions`,label:`Command presets`,description:`Commands offered when creating a session. The default preset is pre-selected.`,keywords:[`preset`,`command`,`agent`,`claude`,`codex`,`default`,`icon`],layout:`block`,Control:rJ}],oJ=null,sJ=!1,cJ={},lJ=500;function uJ(){if(typeof window>`u`)return null;if(oJ?.state===`closed`&&(oJ=null),!oJ){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;oJ=new e}return oJ}function dJ(){oJ&&=(oJ.close().catch(()=>{}),null),uJ()}function fJ(){return sJ}function pJ(){oJ&&(dJ(),sJ=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&pJ()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&pJ()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&pJ(),e=t},5e3)}async function mJ(){let e=uJ();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),sJ=!1}async function hJ(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function gJ(e){let t=uJ();if(!t||(await hJ(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 _J(){let e=Date.now();if(!(e-(cJ.permission||0)<lJ)){cJ.permission=e;try{await gJ({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function vJ(){let e=Date.now();if(!(e-(cJ.idle||0)<lJ)){cJ.idle=e;try{await gJ({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function yJ({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 bJ={};function xJ(e,t){let n=C.useRef(bJ);return n.current===bJ&&(n.current=e(t)),n}var SJ=C[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],CJ=SJ&&SJ!==C.useLayoutEffect?SJ:e=>e();function wJ(e){let t=xJ(TJ).current;return t.next=e,CJ(t.effect),t.trampoline}function TJ(){let e={next:void 0,callback:EJ,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function EJ(){}function DJ(e,t,n,r){let i=xJ(kJ).current;return AJ(i,e,t,n,r)&&MJ(i,[e,t,n,r]),i.callback}function OJ(e){let t=xJ(kJ).current;return jJ(t,e)&&MJ(t,e),t.callback}function kJ(){return{callback:null,cleanup:null,refs:[]}}function AJ(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function jJ(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function MJ(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 NJ=typeof document<`u`?C.useLayoutEffect:()=>{},PJ={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},FJ={...PJ,position:`fixed`,top:0,left:0},IJ={...PJ,position:`absolute`};function LJ(){}Object.freeze([]);var RJ=Object.freeze({});function zJ(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 BJ=18;function VJ(e){return BJ>=e}function HJ(e){if(!C.isValidElement(e))return null;let t=e,n=t.props;return(VJ(19)?n?.ref:t.ref)??null}function UJ(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function WJ(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 GJ(e,t){return typeof e==`function`?e(t):e}function KJ(e,t){return typeof e==`function`?e(t):e}var qJ={};function JJ(e,t,n,r,i){let a={...eY(e,qJ)};return t&&(a=XJ(a,t)),n&&(a=XJ(a,n)),r&&(a=XJ(a,r)),i&&(a=XJ(a,i)),a}function YJ(e){if(e.length===0)return qJ;if(e.length===1)return eY(e[0],qJ);let t={...eY(e[0],qJ)};for(let n=1;n<e.length;n+=1)t=XJ(t,e[n]);return t}function XJ(e,t){return $J(t)?t(e):ZJ(e,t)}function ZJ(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=UJ(e.style,r);break;case`className`:e[n]=rY(e.className,r);break;default:QJ(n,r)?e[n]=tY(e[n],r):e[n]=r}}return e}function QJ(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 $J(e){return typeof e==`function`}function eY(e,t){return $J(e)?e(t):e??qJ}function tY(e,t){return t?e?n=>{if(iY(n)){let r=n;nY(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function nY(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function rY(e,t){return t?e?t+` `+e:t:e}function iY(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function aY(e,t,n={}){let r=t.render,i=oY(t,n);return n.enabled===!1?null:cY(e,r,i,n.state??RJ)}function oY(e,t={}){let{className:n,style:r,render:i}=e,{state:a=RJ,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?GJ(n,a):void 0,d=l?KJ(r,a):void 0,f=l?WJ(a,c):RJ,p=l?UJ(f,Array.isArray(s)?YJ(s):s)??RJ:RJ;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=OJ([p.ref,HJ(i),...o]):p.ref=DJ(p.ref,HJ(i),o):DJ(null,null)),l?(u!==void 0&&(p.className=rY(p.className,u)),d!==void 0&&(p.style=UJ(p.style,d)),p):RJ}var sY=Symbol.for(`react.lazy`);function cY(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=JJ(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===sY&&(i=C.Children.toArray(t)[0]),C.cloneElement(i,e)}if(e&&typeof e==`string`)return lY(e,n);throw Error(zJ(8))}function lY(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 uY={...C},dY=0;function fY(e,t=`mui`){let[n,r]=C.useState(e),i=e||n;return C.useEffect(()=>{n??(dY+=1,r(`${t}-${dY}`))},[n,t]),i}var pY=uY.useId;function mY(e,t){if(pY!==void 0){let n=pY();return e??(t?`${t}-${n}`:n)}return fY(e,t)}function hY(e){return mY(e,`base-ui`)}function gY(){return typeof window<`u`}function _Y(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vY(e){return gY()?e instanceof Element||e instanceof _Y(e).Element:!1}function yY(e){return gY()?e instanceof HTMLElement||e instanceof _Y(e).HTMLElement:!1}function bY(e){return!gY()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof _Y(e).ShadowRoot}var xY=C.createContext(void 0);function SY(e=!1){let t=C.useContext(xY);if(t===void 0&&!e)throw Error(zJ(16));return t}function CY(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 wY(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=C.useRef(null),o=SY(!0)!==void 0,s=wJ(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=CY({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=C.useCallback(()=>{let e=a.current;TY(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return NJ(l,[l]),{getButtonProps:C.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return JJ({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(nY(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||(nY(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:wJ(e=>{a.current=e,l()})}}function TY(e){return yY(e)&&e.tagName===`BUTTON`}var EY=C.createContext(void 0);function DY(){let e=C.useContext(EY);if(e===void 0)throw Error(zJ(63));return e}var OY=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}({}),kY={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},AY={valid(e){return e===null?null:e?{[OY.valid]:``}:{[OY.invalid]:``}}},jY=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}({}),MY={...AY,checked(e){return e?{[jY.checked]:``}:{[jY.unchecked]:``}}};function NY(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var PY=C.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:LJ,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function FY(){return C.useContext(PY)}var IY=C.createContext({invalid:void 0,name:void 0,validityData:{state:kY,errors:[],error:``,value:``,initialValue:null},setValidityData:LJ,disabled:void 0,touched:!1,setTouched:LJ,dirty:!1,setDirty:LJ,filled:!1,setFilled:LJ,focused:!1,setFocused:LJ,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=RJ)=>e,getInputValidationProps:(e=RJ)=>e,inputRef:{current:null},commit:async()=>{}}});function LY(e=!0){let t=C.useContext(IY);if(t.setValidityData===LJ&&!e)throw Error(zJ(28));return t}function RY(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=FY(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=LY(),f=wJ(e.getValue);NJ(()=>{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]),NJ(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:NY(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]),NJ(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var zY=C.createContext({controlId:void 0,registerControlId:LJ,labelId:void 0,setLabelId:LJ,messageIds:[],setMessageIds:LJ,getDescriptionProps:e=>e});function BY(){return C.useContext(zY)}function VY(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=BY(),o=hY(t),s=n?i:void 0,c=xJ(()=>Symbol(`labelable-control`)),l=C.useRef(!1),u=C.useRef(t!=null),d=wJ(()=>{!l.current||a===LJ||(l.current=!1,a(c.current,void 0))});return NJ(()=>{if(a===LJ)return;let e;if(n){let n=r?.current;e=vY(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 HY=`none`;function UY(e,t,n,r){let i=!1,a=!1,o=r??RJ;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 WY(e,t){let n=C.useRef(e),r=wJ(t);NJ(()=>{n.current!==e&&r(n.current)},[e,r]),NJ(()=>{n.current=e},[e])}var GY=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:_}=FY(),{state:v,setTouched:y,setDirty:b,validityData:x,setFilled:w,setFocused:T,shouldValidateOnChange:E,validationMode:D,disabled:O,name:k,validation:A}=LY(),{labelId:j}=BY(),M=O||f,N=k??s,P=wJ(l),F=C.useRef(null),I=DJ(F,o,A.inputRef),L=C.useRef(null),ee=hY(),R=VY({id:a,implicit:!1,controlRef:L}),z=c?void 0:R,[B,te]=yJ({controlled:n,default:!!i,name:`Switch`,state:`checked`});RY({id:ee,commit:A.commit,value:B,controlRef:L,name:N,getValue:()=>B}),NJ(()=>{F.current&&w(F.current.checked)},[F,w]),WY(B,()=>{_(N),b(B!==x.initialValue),w(B),E()?A.commit(B):A.commit(B,!0)});let{getButtonProps:V,buttonRef:H}=wY({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(()=>JJ({checked:B,disabled:M,id:z,name:N,required:d,style:N?IJ:FJ,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:I,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=UY(HY,e.nativeEvent);P?.(t,n),!n.isCanceled&&te(t)},onFocus(){L.current?.focus()}},A.getInputValidationProps,h===void 0?RJ:{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=aY(`span`,e,{state:ie,ref:[t,L,H],props:[ne,A.getValidationProps,g,V],stateAttributesMapping:MY});return(0,S.jsxs)(EY.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})]})}),KY=C.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=LY(),o=DY();return aY(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:MY,props:i})});function qY({checked:e,onCheckedChange:t,disabled:n,className:r,ariaLabel:i,id:a,ariaLabelledBy:o,ariaDescribedBy:s}){return(0,S.jsx)(GY,{checked:e,onCheckedChange:t,disabled:n,"aria-label":i,id:a,"aria-labelledby":o,"aria-describedby":s,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)(KY,{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`)})})}function JY(e,t,n,r){return function({ids:i}){let a=W(t=>t[e]),o=W(e=>e[t]);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`button`,{type:`button`,className:Nq,"aria-label":`Test ${r}`,onClick:()=>void n(),children:`Test`}),(0,S.jsx)(qY,{className:St,id:i.control,checked:a,onCheckedChange:e=>{o(e),e&&mJ()},ariaLabelledBy:i.label,ariaDescribedBy:i.description})]})}}var YY=[{id:`sound-permission`,page:`notifications`,label:`Permission sound`,description:`Play a ping when any session needs permission.`,keywords:[`sound`,`audio`,`alert`,`ping`,`approval`],Control:JY(`soundOnPermission`,`setSoundOnPermission`,_J,`permission sound`)},{id:`sound-idle`,page:`notifications`,label:`Idle sound`,description:`Play a chime when a session finishes working.`,keywords:[`sound`,`audio`,`alert`,`chime`,`done`,`finished`],Control:JY(`soundOnIdle`,`setSoundOnIdle`,vJ,`idle sound`)}];function XY(e,t,n){let r=`/api/settings/${e}`,[i,a]=(0,C.useState)(n),[o,s]=(0,C.useState)(!0),[c,l]=(0,C.useState)(!1),u=(0,C.useRef)(n),d=(0,C.useRef)(Promise.resolve()),f=(0,C.useRef)(0),p=(0,C.useRef)(!0),m=(0,C.useRef)(!1);return(0,C.useEffect)(()=>{p.current=!0;let e=!0;return fetch(r).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(n=>{if(!e)return;let r=n[t];f.current===0&&!m.current&&(u.current=r),m.current||a(r)}).catch(()=>{}).finally(()=>{e&&(l(!0),f.current===0&&s(!1))}),()=>{e=!1,p.current=!1}},[r,t]),{value:i,loading:o,loaded:c,set:(0,C.useCallback)(e=>{m.current=!0,f.current+=1,a(e),s(!0),d.current=d.current.then(()=>fetch(r,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({[t]:e})}).then(t=>{if(!t.ok)throw Error(`HTTP ${t.status}`);u.current=e}).catch(()=>{p.current&&f.current===1&&a(u.current)}).finally(()=>{--f.current,p.current&&f.current===0&&s(!1)}))},[r,t])}}function ZY(e,t){return function({ids:n}){let r=W(t=>t[e]),i=W(e=>e[t]);return(0,S.jsx)(qY,{className:St,id:n.control,checked:r,onCheckedChange:i,ariaLabelledBy:n.label,ariaDescribedBy:n.description})}}function QY({ids:e}){return(0,S.jsx)(Vq,{options:[{value:`created`,label:`Created`},{value:`status`,label:`Status`},{value:`manual`,label:`Manual`}],value:W(e=>e.sessionSortMode),onChange:W(e=>e.setSessionSortMode),labelledBy:e.label,describedBy:e.description})}function $Y(){let e=W(e=>e.sessionSortMode);return e===`status`?(0,S.jsx)(S.Fragment,{children:`Sessions re-sort by status: waiting, working, unknown.`}):e===`manual`?(0,S.jsx)(S.Fragment,{children:`Drag sessions in the sidebar to reorder them.`}):(0,S.jsx)(S.Fragment,{children:`Sessions stay in the order they were created.`})}function eX({ids:e}){return(0,S.jsx)(Vq,{options:[{value:`desc`,label:`Newest first`},{value:`asc`,label:`Oldest first`}],value:W(e=>e.sessionSortDirection),onChange:W(e=>e.setSessionSortDirection),labelledBy:e.label,describedBy:e.description})}function tX({ids:e}){return(0,S.jsx)(Vq,{options:[{value:`top`,label:`Top`},{value:`bottom`,label:`Bottom`}],value:W(e=>e.sidebarAnchor),onChange:W(e=>e.setSidebarAnchor),labelledBy:e.label,describedBy:e.description})}function nX(){return W(e=>e.sidebarAnchor)===`bottom`?(0,S.jsx)(S.Fragment,{children:`The sidebar is mirrored: the first session sits at the bottom, next to the prompt.`}):(0,S.jsx)(S.Fragment,{children:`The first session sits at the top of the sidebar.`})}function rX({ids:e}){let{value:t,loaded:n,set:r}=XY(`history-max-age-hours`,`hours`,24);return(0,S.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,S.jsx)(Lq,{id:e.control,type:`text`,inputMode:`numeric`,value:String(t),disabled:!n,describedBy:e.description,wrapperClassName:`w-20`,className:`text-center tabular-nums`,onCommit:e=>{let n=Rq(e,1,168);return n===null?`Enter 1–168`:(n!==t&&r(n),null)}}),(0,S.jsx)(`span`,{className:`flex h-[32px] items-center text-[12px] text-muted max-md:h-[44px]`,children:`hours`})]})}function iX({ids:e}){let{value:t,loaded:n,set:r}=XY(`prefer-window-name`,`enabled`,!1);return(0,S.jsx)(qY,{className:St,id:e.control,checked:t,onCheckedChange:r,disabled:!n,ariaLabelledBy:e.label,ariaDescribedBy:e.description})}var aX=[{id:`sort-order`,page:`session-list`,label:`Sort order`,description:`Created keeps creation order, Status re-sorts by status, Manual lets you drag.`,keywords:[`sort`,`order`,`created`,`status`,`manual`,`drag`],layout:`wide`,Description:$Y,Control:QY},{id:`sort-direction`,page:`session-list`,label:`Sort direction`,description:`Newest or oldest sessions first.`,keywords:[`sort`,`newest`,`oldest`,`ascending`,`descending`],layout:`wide`,visibleWhen:e=>e.sessionSortMode===`created`,Control:eX},{id:`sidebar-anchor`,page:`session-list`,label:`Sidebar anchor`,description:`Top lists the first session at the top; Bottom mirrors the sidebar.`,keywords:[`sidebar`,`mirror`,`top`,`bottom`],tags:[`desktop`],Description:nX,Control:tX},{id:`show-project-name`,page:`session-list`,label:`Project name`,description:`Show the project folder name under each session.`,keywords:[`folder`,`details`],Control:ZY(`showProjectName`,`setShowProjectName`)},{id:`show-last-user-message`,page:`session-list`,label:`Last user message`,description:`Show the most recent prompt next to the project name.`,keywords:[`prompt`,`input`,`details`],Control:ZY(`showLastUserMessage`,`setShowLastUserMessage`)},{id:`show-session-id-prefix`,page:`session-list`,label:`Session ID prefix`,description:`Show the first 5 characters of the agent session ID.`,keywords:[`id`,`uuid`,`details`],Control:ZY(`showSessionIdPrefix`,`setShowSessionIdPrefix`)},{id:`history-lookback`,page:`session-list`,label:`History lookback`,description:`Show history sessions from the last N hours (1–168). Default 24.`,keywords:[`history`,`hours`,`age`,`inactive`,`past`],Control:rX},{id:`prefer-window-name`,page:`session-list`,label:`Prefer window names`,description:`Label discovered sessions with their tmux window name instead of the session name.`,keywords:[`tmux`,`window`,`name`,`title`],Control:iX}],oX=`1-9 [ ] N X ,`;function sX({ids:e}){let t=W(e=>e.useWebGL),n=W(e=>e.setUseWebGL);return(0,S.jsx)(qY,{className:St,id:e.control,checked:t,onCheckedChange:n,ariaLabelledBy:e.label,ariaDescribedBy:e.description})}function cX(e,t){return function({ids:n}){let{value:r,loaded:i,set:a}=XY(e,`enabled`,t);return(0,S.jsx)(qY,{className:St,id:n.control,checked:r,onCheckedChange:a,disabled:!i,ariaLabelledBy:n.label,ariaDescribedBy:n.description})}}var lX=[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`];function uX({ids:e}){let t=W(e=>e.shortcutModifier),n=W(e=>e.setShortcutModifier);return(0,S.jsx)(Vq,{options:lX.map(e=>({value:e,label:e===`auto`?`Auto`:pt(e)})),value:t,onChange:n,labelledBy:e.label,describedBy:e.description})}function dX(){return(0,S.jsxs)(S.Fragment,{children:[`Shortcuts: `,pt(dt(W(e=>e.shortcutModifier))),` + `,oX,` (sessions, navigate, new, kill, settings).`]})}var fX=[{id:`webgl`,page:`terminal`,label:`WebGL acceleration`,description:`GPU rendering for better performance. Turn off if text looks fuzzy or flickers (common in Safari).`,keywords:[`gpu`,`renderer`,`canvas`,`blurry`,`performance`],tags:[`device`],Control:sX},{id:`mouse-mode`,page:`terminal`,label:`Mouse mode`,description:`tmux mouse mode for trackpad and scroll wheel support.`,keywords:[`tmux`,`scroll`,`trackpad`,`mouse`],Control:cX(`tmux-mouse-mode`,!0)},{id:`terminal-colors`,page:`terminal`,label:`Terminal colors`,description:`Preserve ANSI colors in terminal output. Hibernate then Wake running agents after changing this.`,keywords:[`ansi`,`color`,`colour`],Control:cX(`terminal-colors`,!0)},{id:`shortcut-modifier`,page:`terminal`,label:`Keyboard shortcut modifier`,description:`Modifier keys for the app shortcuts. Auto picks ⌃⌥ on macOS, ⌃⇧ elsewhere.`,keywords:[`keyboard`,`shortcut`,`hotkey`,`ctrl`,`cmd`,`option`,`shift`],tags:[`desktop`,`device`],layout:`wide`,Description:dX,Control:uX}],pX=[...aJ,...aX,...Jq,...fX,...YY];function mX(e,t=pX){return t.filter(t=>t.page===e)}function hX(e){return[e.label,e.description,...e.keywords??[]].join(` `).toLowerCase()}function gX(e,t=pX){let n=e.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[]:t.filter(e=>{let t=hX(e);return n.every(e=>t.includes(e))})}function _X(e){return wq.map(t=>({page:t.id,label:t.label,rows:e.filter(e=>e.page===t.id)})).filter(e=>e.rows.length>0)}var vX={desktop:`Desktop`,device:`This device`},yX={desktop:`Only affects the desktop layout`,device:`Stored in this browser only; not synced to other devices`};function bX({tag:e}){return(0,S.jsx)(`span`,{title:yX[e],className:`shrink-0 border border-border px-1 py-px text-[10px] uppercase leading-none tracking-wide text-muted`,children:vX[e]})}function xX(e){let t=`settings-${e}`;return{control:`${t}-control`,label:`${t}-label`,description:`${t}-desc`}}function SX({row:e}){let t=xX(e.id),n=e.layout??`inline`,{Control:r,Description:i}=e;return(0,S.jsxs)(`div`,{"data-setting-row":e.id,className:l_(`flex gap-x-6 gap-y-3 py-4`,n===`block`&&`flex-col`,n===`wide`&&`items-center max-md:flex-col max-md:items-stretch`,n===`inline`&&`items-center`),children:[(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,S.jsx)(`label`,{id:t.label,htmlFor:t.control,className:`text-[14px] leading-snug text-primary`,children:e.label}),e.tags?.map(e=>(0,S.jsx)(bX,{tag:e},e))]}),(0,S.jsx)(`div`,{id:t.description,className:`mt-1 text-[12px] leading-snug text-muted text-pretty`,children:i?(0,S.jsx)(i,{}):e.description})]}),(0,S.jsx)(`div`,{className:l_(`flex min-w-0 items-center gap-2`,n===`inline`?`shrink-0`:`max-w-full`),children:(0,S.jsx)(r,{ids:t})})]})}function CX(e,t){return e.visibleWhen?e.visibleWhen(t):!0}function wX({rows:e}){let t=W(t=>e.map(e=>CX(e,t)?`1`:`0`).join(``));return(0,S.jsx)(`div`,{className:`divide-y divide-border`,children:e.filter((e,n)=>t[n]===`1`).map(e=>(0,S.jsx)(SX,{row:e},e.id))})}function TX({page:e,showTitle:t}){let n=(0,C.useMemo)(()=>mX(e),[e]);return(0,S.jsxs)(`section`,{"aria-labelledby":t?`settings-page-${e}-title`:void 0,children:[t&&(0,S.jsx)(`h3`,{id:`settings-page-${e}-title`,className:`pb-1 text-[18px] font-semibold leading-tight text-primary`,children:Eq(e)}),(0,S.jsx)(wX,{rows:n})]})}function EX({query:e}){let t=(0,C.useMemo)(()=>gX(e),[e]),n=W(e=>t.some(t=>CX(t,e))),r=(0,C.useMemo)(()=>_X(t),[t]);return n?(0,S.jsx)(`div`,{className:`flex flex-col gap-6`,children:r.map(e=>(0,S.jsx)(DX,{label:e.label,rows:e.rows},e.page))}):(0,S.jsxs)(`div`,{role:`status`,className:`flex flex-col items-center gap-1 py-16 text-center`,children:[(0,S.jsxs)(`p`,{className:`text-[14px] text-primary`,children:[`No settings match “`,e.trim(),`”`]}),(0,S.jsx)(`p`,{className:`text-[12px] text-muted`,children:`Try a different word, like “font” or “sound”.`})]})}function DX({label:e,rows:t}){return W(e=>t.some(t=>CX(t,e)))?(0,S.jsxs)(`section`,{"aria-label":e,children:[(0,S.jsx)(`h3`,{className:`border-b border-border pb-1 text-[11px] font-medium uppercase tracking-wider text-muted`,children:e}),(0,S.jsx)(wX,{rows:t})]}):null}function OX(e){return`settings-tab-${e}`}function kX(e,t,n){return e===`ArrowDown`?(t+1)%n:e===`ArrowUp`?(t-1+n)%n:e===`Home`?0:e===`End`?n-1:null}function AX({variant:e,current:t,onSelect:n,panelId:r}){let i=(0,C.useRef)([]),a=Math.max(0,wq.findIndex(e=>e.id===t)),o=(t,r)=>{let a=kX(t.key,r,wq.length);a!==null&&(t.preventDefault(),i.current[a]?.focus(),e===`tabs`&&n(wq[a].id))};return e===`list`?(0,S.jsx)(`nav`,{"aria-label":`Settings pages`,children:(0,S.jsx)(`ul`,{className:`divide-y divide-border border-y border-border`,children:wq.map((e,t)=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(`button`,{ref:e=>{i.current[t]=e},type:`button`,"data-page-id":e.id,onClick:()=>n(e.id),onKeyDown:e=>o(e,t),className:`flex min-h-[52px] w-full items-center justify-between gap-3 px-4 text-left text-[15px] text-primary active:bg-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,children:[e.label,(0,S.jsx)(j,{width:G.primary,height:G.primary,className:`text-muted`,"aria-hidden":`true`})]})},e.id))})}):(0,S.jsx)(`div`,{role:`tablist`,"aria-orientation":`vertical`,"aria-label":`Settings pages`,className:`flex flex-col gap-px`,children:wq.map((e,s)=>{let c=e.id===t;return(0,S.jsx)(`button`,{ref:e=>{i.current[s]=e},id:OX(e.id),type:`button`,role:`tab`,"aria-selected":c,"aria-controls":r,tabIndex:s===a?0:-1,onClick:()=>n(e.id),onKeyDown:e=>o(e,s),className:l_(`flex h-[32px] w-full items-center border-l-2 px-3 text-left text-[13px] transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,c?`border-primary bg-hover font-medium text-primary`:`border-transparent text-secondary hover:text-primary`),children:e.label},e.id)})})}var jX=(0,C.forwardRef)(function({value:e,onChange:t,className:n},r){return(0,S.jsxs)(`div`,{className:n,children:[(0,S.jsx)(`label`,{htmlFor:`settings-search`,className:`sr-only`,children:`Search settings`}),(0,S.jsx)(`input`,{ref:r,id:`settings-search`,type:`search`,value:e,placeholder:`Search settings`,autoComplete:`off`,spellCheck:!1,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),t(``))},className:`input h-[32px] px-2 py-0 text-[13px] max-md:h-[44px] max-md:text-[16px] focus-visible:ring-2 focus-visible:ring-accent/40`})]})}),MX=[`a[href]`,`button:not([disabled])`,`input:not([disabled]):not([type="hidden"])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function NX(e){return Array.from(e.querySelectorAll(MX)).filter(e=>e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex!==-1)}function PX(e,t,n){if(e.length===0)return null;let r=e[0],i=e[e.length-1],a=t===null?-1:e.indexOf(t);return a===-1?n?i:r:n&&a===0?i:!n&&a===e.length-1?r:null}var FX=`.xterm-helper-textarea`,IX=300,LX=`[data-suspends-terminal]`,RX=null;function zX(e){return!e||typeof document>`u`||e===document.body?null:typeof e.focus==`function`?e:null}function BX(e,t){if(e.isConnected)return e;if(!t)return null;let n=t.replace(/["\\]/g,`\\$&`);return document.querySelector(`button[aria-label="${n}"]`)}function VX(){(0,C.useEffect)(()=>{if(typeof document>`u`||typeof document.querySelector!=`function`)return;RX&&=(clearTimeout(RX),null);let e=zX(document.activeElement),t=document.querySelector(FX);t&&(t.blur(),t.setAttribute(`disabled`,`true`));let n=e?.getAttribute?.(`aria-label`)??null;return()=>{RX=setTimeout(()=>{if(RX=null,document.querySelector(LX))return;let r=document.querySelector(FX);if(r){r.removeAttribute(`disabled`),r.focus();return}(e&&e!==t?BX(e,n):null)?.focus()},IX)}},[])}function HX(e,t){let n=(0,C.useRef)(t);n.current=t,(0,C.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let t=t=>{if(t.key===`Escape`){if(t.defaultPrevented)return;t.preventDefault(),t.stopPropagation(),n.current();return}if(t.key!==`Tab`)return;let r=e.current;if(!r)return;let i=document.activeElement,a=PX(NX(r),i,t.shiftKey);a&&(t.preventDefault(),a.focus())},r=t=>{let n=e.current,r=t.target;n&&r&&!n.contains(r)&&n.focus()};return document.addEventListener(`keydown`,t),document.addEventListener(`focusin`,r),()=>{document.removeEventListener(`keydown`,t),document.removeEventListener(`focusin`,r)}},[e])}function UX({isOpen:e,onClose:t}){return e?(0,S.jsx)(KX,{onClose:t}):null}var WX=`settings-panel`,GX=`flex shrink-0 items-center justify-center text-secondary transition-colors hover:bg-hover hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`;function KX({onClose:e}){let t=PG(),[n,r]=(0,C.useState)(()=>t?null:kq()),[i,a]=(0,C.useState)(``),o=(0,C.useRef)(null),s=(0,C.useRef)(null),c=(0,C.useRef)(null),l=(0,C.useRef)(!1),u=(0,C.useRef)(null);VX(),HX(o,e),(0,C.useEffect)(()=>{t?o.current?.focus():s.current?.focus()},[]),(0,C.useEffect)(()=>{if(t){if(n)c.current?.focus();else if(u.current){let e=o.current?.querySelector(`[data-page-id="${u.current}"]`);u.current=null,e?.focus()}}},[t,n]);let d=e=>{r(e),Aq(e),a(``)},f=i.trim().length>0,p=(0,S.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Close settings`,className:l_(GX,`size-[32px] max-md:size-[44px]`),children:(0,S.jsx)(Fe,{width:G.primary,height:G.primary})});if(t)return(0,S.jsxs)(`div`,{ref:o,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`settings-title`,"data-suspends-terminal":``,tabIndex:-1,className:`fixed inset-0 z-50 flex flex-col bg-elevated outline-none`,style:{paddingTop:`env(safe-area-inset-top)`,paddingLeft:`env(safe-area-inset-left)`,paddingRight:`env(safe-area-inset-right)`},children:[(0,S.jsxs)(`header`,{className:`flex h-[52px] shrink-0 items-center gap-1 border-b border-border px-1`,children:[n?(0,S.jsx)(`button`,{ref:c,type:`button`,onClick:()=>{u.current=n,r(null)},"aria-label":`Back to settings`,className:l_(GX,`size-[44px]`),children:(0,S.jsx)(j,{width:G.primary,height:G.primary,className:`rotate-180`})}):(0,S.jsx)(`span`,{"aria-hidden":`true`,className:`size-[44px] shrink-0`}),(0,S.jsx)(`h2`,{id:`settings-title`,className:`min-w-0 flex-1 truncate text-center text-[16px] font-semibold text-primary`,children:n?Eq(n):`Settings`}),p]}),(0,S.jsx)(`div`,{id:WX,className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-4`,style:{paddingBottom:`calc(24px + env(safe-area-inset-bottom))`},children:n?(0,S.jsx)(TX,{page:n,showTitle:!1}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(jX,{ref:s,value:i,onChange:a,className:`py-3`}),f?(0,S.jsx)(EX,{query:i}):(0,S.jsx)(`div`,{className:`-mx-4`,children:(0,S.jsx)(AX,{variant:`list`,current:null,onSelect:d})})]})})]});let m=n??kq();return(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4`,onMouseDown:e=>{l.current=e.target===e.currentTarget},onClick:t=>{l.current&&t.target===t.currentTarget&&e(),l.current=!1},children:(0,S.jsxs)(`div`,{ref:o,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`settings-title`,"data-suspends-terminal":``,tabIndex:-1,className:`flex h-[600px] max-h-full w-[760px] max-w-full flex-col border border-border bg-elevated shadow-2xl outline-none`,children:[(0,S.jsxs)(`header`,{className:`flex h-[48px] shrink-0 items-center justify-between border-b border-border pl-5 pr-2`,children:[(0,S.jsx)(`h2`,{id:`settings-title`,className:`text-[13px] font-semibold uppercase tracking-wider text-primary`,children:`Settings`}),p]}),(0,S.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex w-[192px] shrink-0 flex-col gap-3 border-r border-border p-3`,children:[(0,S.jsx)(jX,{ref:s,value:i,onChange:a}),(0,S.jsx)(AX,{variant:`tabs`,current:f?null:m,onSelect:d,panelId:WX})]}),(0,S.jsx)(`div`,{id:WX,role:f?`region`:`tabpanel`,"aria-label":f?`Search results`:void 0,"aria-labelledby":f?void 0:OX(m),className:`min-w-0 flex-1 overflow-y-auto overflow-x-hidden px-6 py-5`,children:f?(0,S.jsx)(EX,{query:i}):(0,S.jsx)(TX,{page:m,showTitle:!0})})]})]})})}var qX=[];function JX(e){C.useEffect(e,qX)}var YX=C.createContext(void 0);function XX(){let e=C.useContext(YX);if(!e)throw Error(zJ(73));return e}var ZX=Symbol(`NOT_FOUND`);function QX(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function $X(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function eZ(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 tZ=e=>Array.isArray(e)?e:[e];function nZ(e){let t=Array.isArray(e[0])?e[0]:e;return eZ(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function rZ(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function iZ(e){let t;return{get(n){return t&&e(t.key,n)?t.value:ZX},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function aZ(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 ZX}function i(t,i){r(t)===ZX&&(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 oZ=(e,t)=>e===t;function sZ(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 cZ(e,t){let{equalityCheck:n=oZ,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=sZ(n),o=0,s=r<=1?iZ(a):aZ(r,a);function c(){let t=s.get(arguments);if(t===ZX){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 lZ=class{constructor(e){this.value=e}deref(){return this.value}},uZ=typeof WeakRef<`u`?WeakRef:lZ,dZ=0,fZ=1;function pZ(){return{s:dZ,v:void 0,o:null,p:null}}function mZ(e,t={}){let n=pZ(),{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=pZ(),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=pZ(),e.set(n,t)):t=r}}let s=t,c;if(t.s===fZ)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 uZ(c):c}return s.s=fZ,s.v=c,c}return o.clearCache=()=>{n=pZ(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function hZ(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()),QX(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=mZ,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=tZ(c),p=tZ(u),m=nZ(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=rZ(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 gZ=hZ(mZ),_Z=Object.assign((e,t=gZ)=>{$X(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:()=>_Z}),vZ=hZ({memoize:cZ,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),yZ=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(zJ(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},bZ=(...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(zJ(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(zJ(2))}u=vZ(...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`)}}},xZ=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})),SZ=s(((e,t)=>{t.exports=xZ()})),CZ=s((e=>{var t=p(),n=SZ();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}})),wZ=s(((e,t)=>{t.exports=CZ()})),TZ=[],EZ=void 0;function DZ(){return EZ}function OZ(e){TZ.push(e)}var kZ=SZ(),AZ=wZ(),jZ=VJ(19)?PZ:FZ;function MZ(e,t,n,r,i){return jZ(e,t,n,r,i)}function NZ(e,t,n,r,i){let a=C.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,kZ.useSyncExternalStore)(e.subscribe,a,a)}OZ({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,kZ.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function PZ(e,t,n,r,i){let a=DZ();if(!a)return NZ(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 FZ(e,t,n,r,i){return(0,AZ.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var IZ=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 MZ(this,e,t,n,r)}},LZ=class extends IZ{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){C.useDebugValue(e),NJ(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;NJ(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;NJ(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){C.useDebugValue(e);let n=t!==void 0;NJ(()=>{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),MZ(this,this.selectors[e],t,n,r)}useContextCallback(e,t){C.useDebugValue(e);let n=wJ(t??LJ);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)}})}},RZ=null;globalThis.requestAnimationFrame;var zZ=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)}},BZ=class e{static create(){return new e}static request(e){return zZ.request(e)}static cancel(e){return zZ.cancel(e)}currentId=RZ;request(e){this.cancel(),this.currentId=zZ.request(()=>{this.currentId=RZ,e()})}cancel=()=>{this.currentId!==RZ&&(zZ.cancel(this.currentId),this.currentId=RZ)};disposeEffect=()=>this.cancel};function VZ(){let e=xJ(BZ.create).current;return JX(e.disposeEffect),e}var HZ=0,UZ=class e{static create(){return new e}currentId=HZ;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=HZ,t()},e)}isStarted(){return this.currentId!==HZ}clear=()=>{this.currentId!==HZ&&(clearTimeout(this.currentId),this.currentId=HZ)};disposeEffect=()=>this.clear};function WZ(){let e=xJ(UZ.create).current;return JX(e.disposeEffect),e}var GZ=0;function KZ(e){return GZ+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${GZ}`}function qZ(e){return e?.ownerDocument||document}function JZ(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 YZ=typeof navigator<`u`,XZ=tQ(),ZZ=rQ(),QZ=nQ();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),XZ.platform===`MacIntel`&&XZ.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(XZ.platform),YZ&&/firefox/i.test(QZ);var $Z=YZ&&/apple/i.test(navigator.vendor);YZ&&/Edg/i.test(QZ),YZ&&/android/i.test(ZZ)||/android/i.test(QZ),YZ&&ZZ.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var eQ=QZ.includes(`jsdom/`);function tQ(){if(!YZ)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 nQ(){if(!YZ)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function rQ(){if(!YZ)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function iQ(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function aQ(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&bY(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function oQ(e){return`composedPath`in e?e.composedPath()[0]:e.target}function sQ(e){if(!e||eQ)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var cQ=bZ(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}),lQ={toasts:yZ(e=>e.toasts),isEmpty:yZ(e=>e.toasts.length===0),toast:yZ(cQ,(e,t)=>e.get(t)?.value),toastIndex:yZ(cQ,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:yZ(cQ,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:yZ(cQ,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:yZ(e=>e.hovering),focused:yZ(e=>e.focused),expanded:yZ(e=>e.hovering||e.focused),expandedOrOutOfFocus:yZ(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:yZ(e=>e.prevFocusElement)},uQ=class extends LZ{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},lQ)}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=lQ.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||KZ(`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)),lQ.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=lQ.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)),lQ.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{lQ.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=JZ(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=JZ(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=JZ(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??=UZ.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=oQ(e);aQ(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!lQ.expandedOrOutOfFocus(this.state),a=i?UZ.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=iQ(qZ(this.state.viewport));if(!this.state.viewport||!aQ(this.state.viewport,t)||!sQ(t))return;let n=lQ.toasts(this.state),r=lQ.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()}},dQ=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=xJ(()=>new uQ({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return JX(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)(YX.Provider,{value:a,children:t})},fQ=C.forwardRef(function(e,t){let[n,r]=C.useState();NJ(()=>{$Z&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,S.jsx)(`span`,{...e,ref:t,style:FJ,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),pQ=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),mQ=C.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=XX(),s=WZ(),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(iQ(qZ(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=_Y(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=_Y(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=oQ(n),i=iQ(qZ(e));(!aQ(e,r)||!sQ(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=qZ(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||sQ(qZ(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function w(e){!f||aQ(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=aY(`div`,e,{ref:[t,o.setViewport],state:E,props:[T,{style:{[pQ.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,S.jsxs)(C.Fragment,{children:[!u&&m&&(0,S.jsx)(fQ,{onFocus:_}),i,!u&&m&&(0,S.jsx)(fQ,{onFocus:_})]})}]}),O=C.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,S.jsxs)(C.Fragment,{children:[!u&&m&&(0,S.jsx)(fQ,{onFocus:_}),D,!f&&O.length>0&&(0,S.jsx)(`div`,{style:FJ,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 hQ(e){return VJ(19)?e:e?`true`:void 0}var gQ=C.createContext(void 0);function _Q(){let e=C.useContext(gQ);if(!e)throw Error(zJ(66));return e}var vQ=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),yQ={[vQ.startingStyle]:``},bQ={[vQ.endingStyle]:``},xQ={transitionStatus(e){return e===`starting`?yQ:e===`ending`?bQ:null}};function SQ(e){return e==null?e:`current`in e?e.current:e}function CQ(e,t=!1,n=!0){let r=VZ();return wJ((i,a=null)=>{r.cancel();function o(){Vd.flushSync(i)}let s=SQ(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=vQ.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 wQ(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=wJ(i),o=CQ(r,n,!1);C.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var TQ=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}({}),EQ={...xQ,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},DQ=40,OQ=10,kQ=.5,AQ=1;function jQ(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 MQ(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 NQ=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=XX(),[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`);wQ({open:n.transitionStatus!==`ending`,ref:j,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let H=wJ((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()});NJ(H,[H]);function ne(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**kQ:-(Math.abs(e)**kQ):(!c.includes(`right`)&&e>0&&(n=e**kQ),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**kQ))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**kQ:-(Math.abs(t)**kQ):(!c.includes(`down`)&&t>0&&(r=t**kQ),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**kQ))),{x:n,y:r}}function re(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=oQ(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=MQ(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)>=AQ&&(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=jQ(u,a,o),f(u));else{let e=P.current,t=jQ(e,l,s);t>DQ?(I.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&F.current-t>=OQ&&(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>DQ&&(t=!0,a=`right`);break;case`left`:r<-DQ&&(t=!0,a=`left`);break;case`down`:i>DQ&&(t=!0,a=`down`);break;case`up`:i<-DQ&&(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||!aQ(j.current,iQ(qZ(j.current))))return;u.closeToast(n.id)}}C.useEffect(()=>{if(!l)return;let e=j.current;if(!e)return;function t(t){aQ(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{[TQ.swipeMovementX]:`0px`,[TQ.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,[TQ.swipeMovementX]:`${e}px`,[TQ.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:hQ(n.limited),style:{...oe(),[TQ.index]:n.transitionStatus===`ending`?R:z,[TQ.offsetY]:`${B}px`,[TQ.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=aY(`div`,e,{ref:[t,le.rootRef],state:ue,stateAttributesMapping:EQ,props:[ce,o]});return(0,S.jsx)(gQ.Provider,{value:le,children:de})}),PQ=C.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=_Q(),l=a??s.description,u=!!l,d=mY(i);NJ(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=aY(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),FQ=C.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=_Q(),l=a??s.title,u=!!l,d=mY(i);NJ(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=aY(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),IQ=C.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=XX(),{toast:c}=_Q(),l=s.useState(`expanded`),[u,d]=C.useState(!1),{getButtonProps:f,buttonRef:p}=wY({disabled:i,native:a}),m={type:c.type};return aY(`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 LQ(){let e=C.useContext(YX);if(!e)throw Error(zJ(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 RQ(){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||KZ(`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 zQ=5e3,BQ=RQ();function VQ({toast:e}){return(0,S.jsxs)(NQ,{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)(FQ,{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)(PQ,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,S.jsx)(IQ,{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 HQ(){let{toasts:e}=LQ();return(0,S.jsx)(S.Fragment,{children:e.map(e=>(0,S.jsx)(VQ,{toast:e},e.id))})}function UQ(){return(0,S.jsxs)(dQ,{timeout:zQ,toastManager:BQ,children:[(0,S.jsx)(HQ,{}),(0,S.jsx)(mQ,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var WQ=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],GQ=3e3,KQ=8e3,qQ=15e3,JQ=5e3,YQ=2e4,XQ=1e4,ZQ=1500,QQ=5e3,$Q=750,e$=4,t$=5e3,n$=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?WQ[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?KQ:GQ;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:WQ[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(QQ)));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>qQ&&(KO(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},JQ))}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))},ZQ)}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()},$Q)):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()},XQ)))};e!==void 0&&e<YQ?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,YQ)},e):this.heartbeatTimer=window.setInterval(t,YQ)}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>=e$){KO(`ws_stall_detected`,this.wsSnap(),`info`),this.purgeLeakedSockets();let e=Math.min(t$*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 r$(){let e=Sh(e=>e.setConnectionState);return(0,C.useEffect)(()=>{n$.connect(),n$.startLifecycleListeners();let t=n$.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),n$.stopLifecycleListeners()}},[e]),{sendMessage:(0,C.useMemo)(()=>e=>{n$.send(e)},[]),subscribe:(0,C.useMemo)(()=>n$.subscribe.bind(n$),[]),getConnectionEpoch:(0,C.useMemo)(()=>()=>n$.getConnectionEpoch(),[])}}var i$=100;function a$({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>i$?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function o$(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 s$(){(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=()=>{a$({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(),o$(document)}},[])}var c$=[`theme`,`commandPresets`,`defaultPresetId`,`defaultProjectDir`,`lastProjectPath`,`recentPaths`,`sessionSortMode`,`sessionSortDirection`,`manualSessionOrder`,`sidebarAnchor`,`projectFilters`,`hostFilters`,`showProjectName`,`showLastUserMessage`,`showSessionIdPrefix`,`soundOnPermission`,`soundOnIdle`],l$=[`claude`,`claude-rp`,`codex`,`pi`,`devin`,`grok`,`omp`];function u$(e){return typeof e==`boolean`}function d$(e,t){return Array.isArray(e)&&e.length<=t&&e.every(e=>typeof e==`string`)}function f$(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||l$.includes(t.agentType))}var p$={theme:e=>e===`dark`||e===`light`||e===`system`,commandPresets:e=>Array.isArray(e)&&e.length<=50&&e.every(f$),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=>d$(e,50),sessionSortMode:e=>e===`status`||e===`created`||e===`manual`,sessionSortDirection:e=>e===`asc`||e===`desc`,manualSessionOrder:e=>d$(e,1e3),sidebarAnchor:e=>e===`top`||e===`bottom`,projectFilters:e=>d$(e,500),hostFilters:e=>d$(e,500),showProjectName:u$,showLastUserMessage:u$,showSessionIdPrefix:u$,soundOnPermission:u$,soundOnIdle:u$};function m$(e){return c$.includes(e)}function h$(e,t){return p$[e](t)}var g$=`agentboard-theme`,_$=`agentboard-settings`,v$=200,y$=new Map,b$=new Set,x$=null,S$=!1;function C$(e){return e===`theme`?VG.getState().theme:W.getState()[e]}function w$(e){let t=e===`theme`?g$:_$;return Je.getItem(t)!==null}function T$(){if(x$=null,b$.size===0)return;let e={};for(let t of b$){let n=C$(t);e[t]=n,y$.set(t,JSON.stringify(n))}b$.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 E$(e){b$.add(e),!x$&&(x$=setTimeout(T$,v$))}function D$(e){let t=new Map;for(let e of c$)t.set(e,w$(e));let n={},r;for(let[t,i]of Object.entries(e))!m$(t)||!h$(t,i)||(y$.set(t,JSON.stringify(i)),t===`theme`?r=i:n[t]=i);r!==void 0&&VG.setState({theme:r}),Object.keys(n).length>0&&W.setState(n);for(let n of c$){if(n in e||!t.get(n))continue;let r=C$(n);h$(n,r)&&y$.get(n)!==JSON.stringify(r)&&E$(n)}}function O$(){if(S$)return()=>{};S$=!0;let e=W.subscribe((e,t)=>{let n=e,r=t;for(let e of c$)e!==`theme`&&n[e]!==r[e]&&y$.get(e)!==JSON.stringify(n[e])&&E$(e)}),t=VG.subscribe((e,t)=>{e.theme!==t.theme&&y$.get(`theme`)!==JSON.stringify(e.theme)&&E$(`theme`)});return()=>{e(),t(),S$=!1,x$&&=(clearTimeout(x$),null),b$.clear(),y$.clear()}}function k$(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 A$(){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=HG(),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}=r$();(0,C.useEffect)(()=>O$(),[]),s$(),(0,C.useEffect)(()=>{if(typeof document>`u`||!fe&&!pe)return;let e=!1,t=()=>{e&&!fJ()||(e=!0,mJ())};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&&_J(),e.status===`working`&&i.status===`waiting`&&r&&vJ())}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`&&D$(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&&_J(),t===`working`&&n===`waiting`&&r&&vJ()}}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)(()=>k$(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=ce===`bottom`&&!window.matchMedia(`(max-width: 767px)`).matches,t=(i===`BracketLeft`?-1:1)*(e?-1:1),n=ke;if(n.length===0){let e=Ce;if(e.length===0)return;let n=e.findIndex(e=>e.sessionId===b);if(n===-1){k(e[0].sessionId);return}k(e[(n+t+e.length)%e.length].sessionId);return}let a=n.findIndex(e=>e.id===y);if(a===-1){O(n[0].id);return}O(n[(a+t+n.length)%n.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&&!c&&V&&t(!0);return}if(a&&i===`Comma`){r.preventDefault(),l(t=>t?!1:!e);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&!c&&Ie(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,c,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)(()=>UG(),[]),(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)(iq,{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)(Cq,{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)(UX,{isOpen:c,onClose:()=>l(!1)}),(0,S.jsx)(UQ,{})]})}var j$=`modulepreload`,M$=function(e){return`/`+e},N$={},P$=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=M$(t,n),t in N$)return;N$[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`:j$,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)})},F$=`true`,I$=`false`,L$=F$===`true`,R$=I$===`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,L$||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await P$(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()},!R$)if(L$)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 B$=document.getElementById(`root`);if(!B$)throw Error(`Root element not found`);(0,x.createRoot)(B$).render((0,S.jsx)(C.StrictMode,{children:(0,S.jsx)(A$,{})}));
|
|
306
|
+
`,onClick:()=>{rq(),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)(RK,{...ut}),(0,S.jsx)(lK,{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)($K,{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)(eq,{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 aq({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 oq(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 sq(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?oq(o):null}function cq(e){return e?e===`claude-rp`?`claude`:e:null}function lq(e){let t=e.trim();if(!t)return``;let n=oq(t);return sq(n)??n}function uq(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 dq(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`:uq(e.split(`/`).pop()||e);return t?{agentType:t,end:n.index+n[0].length}:void 0}}function fq(e){let t=lq(e);if(t)return dq(t.toLowerCase().trim().replace(/^["']|["']$/g,``))?.agentType}var pq={claude:`--dangerously-skip-permissions`,codex:`--yolo`,grok:`--always-approve`,devin:`--permission-mode dangerous`,pi:null,omp:`--auto-approve`},mq={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 hq(e){let t=cq(e);return t?pq[t]:null}function gq(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _q(e){return RegExp(`(^|\\s)${gq(e)}(?=\\s|$)`,`g`)}function vq(e,t){return(t?[cq(t)].filter(e=>e!==null):Object.keys(mq)).some(t=>mq[t].some(t=>_q(t).test(e)))}function yq(e,t){let n=dq(e);return n?`${e.slice(0,n.end)} ${t}${e.slice(n.end)}`:null}function bq(e,t){let n=hq(t);if(!n)return e;let r=e.trim();if(!r||vq(r,t))return r;let i=yq(r,n);if(i)return i;let a=lq(r);if(a&&a!==r){let e=yq(a,n);if(e)return`bash -lc '${e.replace(/'/g,`'\\''`)}'`}return`${r} ${n}`}function xq(e,t){let n=cq(t);if(!n||vq(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 Sq(e,t){let n=cq(t);if(!n)return e;let r=e;for(let e of mq[n])r=r.replace(_q(e),` `);return r.replace(/\s+/g,` `).trim()}function Cq({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=fq(e);return t&&!xq(e,t)?bq(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(t)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=fq(y),z=hq(R)!==null,B=R?vq(y,R):!1,te=R&&!B?xq(y,R):null,V=!z||te!==null,H=R?R===`pi`?`Pi has no permission prompts — nothing to enable`:te??`Append ${hq(R)}`:`Enter a supported agent command (claude, codex, grok, devin)`,ne=e=>{O(e),R&&b(e?bq(y,R):Sq(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`,"data-suspends-terminal":``,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)(aq,{initialPath:ae,onSelect:e=>{m(e),w(!1)},onCancel:()=>w(!1)})]})}var wq=[{id:`new-sessions`,label:`New sessions`},{id:`session-list`,label:`Session list`},{id:`appearance`,label:`Appearance`},{id:`terminal`,label:`Terminal`},{id:`notifications`,label:`Notifications`}];function Tq(e){return wq.some(t=>t.id===e)}function Eq(e){return wq.find(t=>t.id===e)?.label??e}var Dq=`agentboard-settings-page`,Oq=`new-sessions`;function kq(){let e=Je.getItem(Dq);return Tq(e)?e:Oq}function Aq(e){Je.setItem(Dq,e)}var jq=`h-[32px] max-md:h-[44px]`,Mq=`${jq} inline-flex shrink-0 items-center justify-center border text-[12px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,Nq=`${Mq} border-border bg-surface px-3 text-secondary hover:bg-hover hover:text-primary`,Pq=`${Mq} w-[32px] max-md:w-[44px] border-border bg-surface text-secondary hover:bg-hover hover:text-primary`,Fq=`input ${jq} px-2 py-0 text-[13px] max-md:text-[16px] focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-50 aria-[invalid=true]:border-danger`;function Iq(e,t){let[n,r]=(0,C.useState)(null),[i,a]=(0,C.useState)(null),o=(0,C.useRef)({draft:n,stored:e,commit:t});o.current={draft:n,stored:e,commit:t},(0,C.useEffect)(()=>()=>{let{draft:e,stored:t,commit:n}=o.current;e!==null&&e!==t&&n(e)},[]);let s=()=>{if(n===null)return;if(n===e){r(null),a(null);return}let i=t(n);if(i){a(i);return}r(null),a(null)};return{value:n??e,error:i,dirty:n!==null,onChange:e=>{r(e.target.value),a(null)},onBlur:s,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&n!==null&&(e.preventDefault(),r(null),a(null))}}}var Lq=(0,C.forwardRef)(function({value:e,onCommit:t,describedBy:n,id:r,className:i,wrapperClassName:a,...o},s){let c=Iq(e,t),l=r?`${r}-error`:void 0,u=[n,c.error?l:void 0].filter(Boolean).join(` `);return(0,S.jsxs)(`div`,{className:l_(`min-w-0`,a),children:[(0,S.jsx)(`input`,{...o,ref:s,id:r,value:c.value,onChange:c.onChange,onBlur:c.onBlur,onKeyDown:c.onKeyDown,"aria-invalid":c.error?!0:void 0,"aria-describedby":u||void 0,className:l_(Fq,i)}),c.error&&(0,S.jsx)(`p`,{id:l,className:l_(`text-[12px] leading-snug text-danger`,`mt-1`),role:`alert`,children:c.error})]})});function Rq(e,t,n){let r=e.trim();return/^-?\d+$/.test(r)?Math.min(n,Math.max(t,Number.parseInt(r,10))):null}function zq({value:e,min:t,max:n,onChange:r,noun:i,labelledBy:a,describedBy:o}){return(0,S.jsxs)(`div`,{role:`group`,"aria-labelledby":a,"aria-describedby":o,className:`flex items-center`,children:[(0,S.jsx)(`button`,{type:`button`,className:Pq,"aria-label":`Decrease ${i}`,disabled:e<=t,onClick:()=>r(Math.max(t,e-1)),children:(0,S.jsx)(ye,{width:G.default,height:G.default})}),(0,S.jsx)(`output`,{"aria-live":`polite`,className:l_(jq,`flex w-10 items-center justify-center border-y border-border bg-base text-[13px] tabular-nums text-primary`),children:e}),(0,S.jsx)(`button`,{type:`button`,className:Pq,"aria-label":`Increase ${i}`,disabled:e>=n,onClick:()=>r(Math.min(n,e+1)),children:(0,S.jsx)(ke,{width:G.default,height:G.default})})]})}function Bq({id:e,value:t,min:n,max:r,step:i,onChange:a,format:o,labelledBy:s,describedBy:c}){return(0,S.jsxs)(`div`,{className:l_(jq,`flex items-center gap-3`),children:[(0,S.jsx)(`input`,{id:e,type:`range`,min:n,max:r,step:i,value:t,"aria-labelledby":s,"aria-describedby":c,"aria-valuetext":o(t),onChange:e=>{let t=Number.parseFloat(e.target.value);Number.isFinite(t)&&a(Math.min(r,Math.max(n,t)))},className:`h-1 w-28 max-md:w-36 cursor-pointer appearance-none bg-border accent-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),(0,S.jsx)(`span`,{className:`w-10 text-right text-[13px] tabular-nums text-secondary`,children:o(t)})]})}function Vq({options:e,value:t,onChange:n,labelledBy:r,describedBy:i,fill:a=!1}){let o=(0,C.useRef)([]),s=Math.max(0,e.findIndex(e=>e.value===t)),c=t=>{let r=e[t];r&&(n(r.value),o.current[t]?.focus())},l=(t,n)=>{let r=e.length-1,i=null;t.key===`ArrowRight`||t.key===`ArrowDown`?i=n===r?0:n+1:t.key===`ArrowLeft`||t.key===`ArrowUp`?i=n===0?r:n-1:t.key===`Home`?i=0:t.key===`End`&&(i=r),i!==null&&(t.preventDefault(),c(i))};return(0,S.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":r,"aria-describedby":i,className:l_(`flex border border-border bg-base p-[2px]`,a?`w-full`:`w-max max-w-full`),children:e.map((e,t)=>{let n=t===s;return(0,S.jsx)(`button`,{ref:e=>{o.current[t]=e},type:`button`,role:`radio`,"aria-checked":n,tabIndex:n?0:-1,onClick:()=>c(t),onKeyDown:e=>l(e,t),className:l_(`h-[26px] max-md:h-[38px] min-w-0 whitespace-nowrap px-3 text-[12px] transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,a&&`flex-1`,n?`bg-hover text-primary shadow-[inset_0_0_0_1px_var(--border)]`:`text-muted hover:text-primary`),children:e.label},e.value)})})}function Hq({ids:e}){return(0,S.jsx)(Vq,{options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`System`}],value:VG(e=>e.theme),onChange:VG(e=>e.setTheme),labelledBy:e.label,describedBy:e.description})}function Uq({ids:e}){let t=W(e=>e.fontOption),n=W(e=>e.setFontOption);return(0,S.jsx)(`select`,{id:e.control,value:t,"aria-describedby":e.description,onChange:e=>n(e.target.value),className:`${Fq} w-44 max-md:w-full`,children:$e.map(e=>(0,S.jsx)(`option`,{value:e.id,children:e.label},e.id))})}function Wq({ids:e}){let t=W(e=>e.customFontFamily);return(0,S.jsx)(Lq,{id:e.control,value:t,placeholder:`"Fira Code", monospace`,describedBy:e.description,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,maxLength:256,wrapperClassName:`w-60 max-md:w-full`,onCommit:e=>(W.getState().setCustomFontFamily(e.trim()),null)})}function Gq({ids:e}){return(0,S.jsx)(zq,{value:W(e=>e.fontSize),min:6,max:24,onChange:W(e=>e.setFontSize),noun:`font size`,labelledBy:e.label,describedBy:e.description})}function Kq({ids:e}){let t=W(e=>e.lineHeight),n=W(e=>e.setLineHeight);return(0,S.jsx)(Bq,{id:e.control,value:t,min:1,max:2,step:.1,onChange:e=>n(Math.round(e*10)/10),format:e=>e.toFixed(1),labelledBy:e.label,describedBy:e.description})}function qq({ids:e}){let t=W(e=>e.letterSpacing),n=W(e=>e.setLetterSpacing);return(0,S.jsx)(Bq,{id:e.control,value:t,min:-3,max:3,step:1,onChange:e=>n(Math.round(e)),format:e=>`${e}px`,labelledBy:e.label,describedBy:e.description})}var Jq=[{id:`theme`,page:`appearance`,label:`Theme`,description:`Light, dark, or follow the system setting.`,keywords:[`dark mode`,`light mode`,`color`,`colour`,`system`],Control:Hq},{id:`font-family`,page:`appearance`,label:`Font family`,description:`Terminal typeface. Default JetBrains Mono.`,keywords:[`font`,`typeface`,`monospace`],tags:[`device`],Control:Uq},{id:`custom-font-family`,page:`appearance`,label:`Custom font family`,description:`A CSS font-family list. Empty falls back to JetBrains Mono.`,keywords:[`font`,`typeface`,`css`],tags:[`device`],layout:`wide`,visibleWhen:e=>e.fontOption===`custom`,Control:Wq},{id:`font-size`,page:`appearance`,label:`Font size`,description:`Terminal text size in pixels (6–24). Default 13.`,keywords:[`font`,`text`,`zoom`,`size`],tags:[`device`],Control:Gq},{id:`line-height`,page:`appearance`,label:`Line height`,description:`Vertical spacing, 1.0 compact to 2.0 spacious. Default 1.0.`,keywords:[`spacing`,`leading`,`line`],tags:[`device`],Control:Kq},{id:`letter-spacing`,page:`appearance`,label:`Letter spacing`,description:`Extra space between characters in pixels (−3 to 3). Default 0.`,keywords:[`spacing`,`tracking`,`kerning`],tags:[`device`],Control:qq}],Yq=1024,Xq=[{value:``,label:`Terminal`},{value:`claude`,label:`Claude`},{value:`codex`,label:`Codex`},{value:`pi`,label:`Pi`},{value:`devin`,label:`Devin`},{value:`grok`,label:`Grok`},{value:`omp`,label:`OMP`}];function Zq(e,t){let n=t.trim();return e===`label`?n?n.length>64?`Name is at most 64 characters`:null:`Name is required`:n?n.length>1024?`Command is at most ${Yq} characters`:null:`Command is required`}function Qq(e){return Zq(`label`,e.label)===null&&Zq(`command`,e.command)===null}function $q(e,t,n){return e.map(e=>e.id===t?rt({...e,...n}):e)}var eJ=`grid items-start gap-2 grid-cols-[56px_92px_minmax(0,0.8fr)_minmax(0,1.3fr)_auto] max-md:grid-cols-[minmax(0,1fr)_minmax(0,auto)_auto] max-md:gap-y-2`,tJ=4e3;function nJ({preset:e,index:t,isDefault:n,pending:r=!1,autoFocusName:i=!1,onSetDefault:a,onCommitField:o,onIconChange:s,onDelete:c}){let[l,u]=(0,C.useState)(!1),d=(0,C.useRef)(null),f=`settings-preset-${e.id}`,p=e.label.trim()||`preset ${t+1}`;return(0,C.useEffect)(()=>{i&&d.current?.focus()},[i]),(0,C.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>u(!1),tJ);return()=>clearTimeout(e)},[l]),(0,S.jsxs)(`div`,{role:`listitem`,"data-preset-id":e.id,className:l_(eJ,`py-2`),children:[(0,S.jsxs)(`label`,{className:l_(jq,`flex cursor-pointer items-center gap-2 md:justify-center`),children:[(0,S.jsx)(`input`,{type:`radio`,name:`settings-default-preset`,checked:n,disabled:r,onChange:a,"aria-label":`Default preset: ${p}`,className:`size-4 cursor-pointer accent-accent disabled:cursor-not-allowed`}),(0,S.jsx)(`span`,{"aria-hidden":`true`,className:`text-[12px] text-secondary md:hidden`,children:`Default`})]}),e.isBuiltIn?(0,S.jsxs)(`div`,{className:l_(jq,`flex items-center gap-2 text-muted`),children:[(0,S.jsx)(Bh,{agentType:e.agentType,command:e.command,className:`size-4`}),(0,S.jsx)(`span`,{className:`text-[11px]`,children:`Built-in`})]}):(0,S.jsx)(`select`,{id:`${f}-icon`,value:e.agentType??``,"aria-label":`Icon for ${p}`,onChange:e=>s(e.target.value||void 0),className:l_(Fq,`w-full px-1`),children:Xq.map(e=>(0,S.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,S.jsx)(Lq,{ref:d,id:`${f}-label`,value:e.label,placeholder:`Name`,"aria-label":`Name of preset ${t+1}`,maxLength:64,onCommit:e=>o(`label`,e),wrapperClassName:`max-md:order-4 max-md:col-span-3`}),(0,S.jsx)(Lq,{id:`${f}-command`,value:e.command,placeholder:`command --flags`,"aria-label":`Command for ${p}`,maxLength:Yq,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,onCommit:e=>o(`command`,e),wrapperClassName:`max-md:order-5 max-md:col-span-3`}),e.isBuiltIn?(0,S.jsx)(`span`,{"aria-hidden":`true`,className:`w-[32px] max-md:order-3 max-md:w-[44px]`}):(0,S.jsx)(`button`,{type:`button`,onClick:()=>{if(r||l){c();return}u(!0)},onPointerDown:r?e=>e.preventDefault():void 0,onBlur:()=>u(!1),"aria-label":l?`Confirm delete ${p}`:r?`Discard new preset`:`Delete ${p}`,title:l?`Click again to delete`:void 0,className:l_(Mq,`max-md:order-3`,l?`border-danger bg-danger/10 px-2 text-danger hover:bg-danger/20`:`w-[32px] border-border bg-surface text-secondary hover:bg-hover hover:text-danger max-md:w-[44px]`),children:l?`Delete?`:(0,S.jsx)(R,{width:G.default,height:G.default})})]})}function rJ({ids:e}){let t=W(e=>e.commandPresets),n=W(e=>e.defaultPresetId),[r,i]=(0,C.useState)(null),a=(0,C.useRef)(null),o=(0,C.useRef)(null),s=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!s.current)return;s.current=!1;let e=o.current;if(e&&!e.disabled){e.focus();return}let t=a.current?.id;t&&typeof document<`u`&&document.getElementById(`settings-preset-${t}-label`)?.focus()});let c=e=>{a.current=e,i(e)},l=!r&&t.length<50,u=r?[...t,r]:t,d=(e,t,n)=>{let r=Zq(t,n);if(r)return r;let{commandPresets:i,setCommandPresets:a}=W.getState();return a($q(i,e,{[t]:n})),null},f=(e,t)=>{let n=a.current;if(!n)return null;let r={...n,[e]:t},{commandPresets:i,setCommandPresets:o}=W.getState();return Qq(r)&&i.length<50?(o([...i,rt(r)]),c(null)):c(r),null},p=(e,t)=>{if(r?.id===e){c({...r,agentType:t});return}let{commandPresets:n,setCommandPresets:i}=W.getState();i($q(n,e,{agentType:t}))},m=()=>{l&&c({id:at(new Set(t.map(e=>e.id))),label:``,command:``,isBuiltIn:!1})},h=e=>{s.current=!0,a.current?.id===e?c(null):W.getState().removePreset(e)};return(0,S.jsxs)(`div`,{className:`w-full min-w-0`,children:[(0,S.jsxs)(`div`,{"aria-hidden":`true`,className:l_(eJ,`border-b border-border pb-1 text-[11px] uppercase tracking-wide text-muted max-md:hidden`),children:[(0,S.jsx)(`span`,{className:`text-center`,children:`Default`}),(0,S.jsx)(`span`,{children:`Icon`}),(0,S.jsx)(`span`,{children:`Name`}),(0,S.jsx)(`span`,{children:`Command`}),(0,S.jsx)(`span`,{className:`w-[32px]`})]}),(0,S.jsx)(`div`,{role:`list`,"aria-labelledby":e.label,"aria-describedby":e.description,className:`divide-y divide-border-subtle`,children:u.map((e,t)=>{let i=e.id===r?.id;return(0,S.jsx)(nJ,{preset:e,index:t,isDefault:e.id===n,pending:i,autoFocusName:i,onSetDefault:()=>W.getState().setDefaultPresetId(e.id),onCommitField:(t,n)=>i?f(t,n):d(e.id,t,n),onIconChange:t=>p(e.id,t),onDelete:()=>h(e.id)},e.id)})}),r&&(0,S.jsx)(`p`,{className:l_(`text-[12px] leading-snug text-muted`,`pb-2`),role:`status`,children:`Enter a name and a command to add the preset.`}),(0,S.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,S.jsxs)(`button`,{ref:o,type:`button`,className:Nq,onClick:m,disabled:!l,children:[(0,S.jsx)(ke,{width:G.default,height:G.default,className:`mr-1.5`}),`Add preset`]}),t.length>=50&&(0,S.jsxs)(`span`,{className:`text-[12px] leading-snug text-muted`,children:[`Maximum of `,50,` presets.`]})]})]})}function iJ({ids:e}){let t=W(e=>e.defaultProjectDir);return(0,S.jsx)(Lq,{id:e.control,value:t,placeholder:Xe,describedBy:e.description,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,maxLength:4096,wrapperClassName:`w-72 max-md:w-full`,onCommit:e=>(W.getState().setDefaultProjectDir(e.trim()||`~/Documents/GitHub`),null)})}var aJ=[{id:`default-project-dir`,page:`new-sessions`,label:`Default project directory`,description:`Folder the new session dialog starts in. Default ${Xe}.`,keywords:[`path`,`folder`,`cwd`,`directory`],layout:`wide`,Control:iJ},{id:`command-presets`,page:`new-sessions`,label:`Command presets`,description:`Commands offered when creating a session. The default preset is pre-selected.`,keywords:[`preset`,`command`,`agent`,`claude`,`codex`,`default`,`icon`],layout:`block`,Control:rJ}],oJ=null,sJ=!1,cJ={},lJ=500;function uJ(){if(typeof window>`u`)return null;if(oJ?.state===`closed`&&(oJ=null),!oJ){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;oJ=new e}return oJ}function dJ(){oJ&&=(oJ.close().catch(()=>{}),null),uJ()}function fJ(){return sJ}function pJ(){oJ&&(dJ(),sJ=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&pJ()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&pJ()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&pJ(),e=t},5e3)}async function mJ(){let e=uJ();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),sJ=!1}async function hJ(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function gJ(e){let t=uJ();if(!t||(await hJ(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 _J(){let e=Date.now();if(!(e-(cJ.permission||0)<lJ)){cJ.permission=e;try{await gJ({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function vJ(){let e=Date.now();if(!(e-(cJ.idle||0)<lJ)){cJ.idle=e;try{await gJ({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function yJ({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 bJ={};function xJ(e,t){let n=C.useRef(bJ);return n.current===bJ&&(n.current=e(t)),n}var SJ=C[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],CJ=SJ&&SJ!==C.useLayoutEffect?SJ:e=>e();function wJ(e){let t=xJ(TJ).current;return t.next=e,CJ(t.effect),t.trampoline}function TJ(){let e={next:void 0,callback:EJ,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function EJ(){}function DJ(e,t,n,r){let i=xJ(kJ).current;return AJ(i,e,t,n,r)&&MJ(i,[e,t,n,r]),i.callback}function OJ(e){let t=xJ(kJ).current;return jJ(t,e)&&MJ(t,e),t.callback}function kJ(){return{callback:null,cleanup:null,refs:[]}}function AJ(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function jJ(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function MJ(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 NJ=typeof document<`u`?C.useLayoutEffect:()=>{},PJ={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},FJ={...PJ,position:`fixed`,top:0,left:0},IJ={...PJ,position:`absolute`};function LJ(){}Object.freeze([]);var RJ=Object.freeze({});function zJ(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 BJ=18;function VJ(e){return BJ>=e}function HJ(e){if(!C.isValidElement(e))return null;let t=e,n=t.props;return(VJ(19)?n?.ref:t.ref)??null}function UJ(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function WJ(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 GJ(e,t){return typeof e==`function`?e(t):e}function KJ(e,t){return typeof e==`function`?e(t):e}var qJ={};function JJ(e,t,n,r,i){let a={...eY(e,qJ)};return t&&(a=XJ(a,t)),n&&(a=XJ(a,n)),r&&(a=XJ(a,r)),i&&(a=XJ(a,i)),a}function YJ(e){if(e.length===0)return qJ;if(e.length===1)return eY(e[0],qJ);let t={...eY(e[0],qJ)};for(let n=1;n<e.length;n+=1)t=XJ(t,e[n]);return t}function XJ(e,t){return $J(t)?t(e):ZJ(e,t)}function ZJ(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=UJ(e.style,r);break;case`className`:e[n]=rY(e.className,r);break;default:QJ(n,r)?e[n]=tY(e[n],r):e[n]=r}}return e}function QJ(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 $J(e){return typeof e==`function`}function eY(e,t){return $J(e)?e(t):e??qJ}function tY(e,t){return t?e?n=>{if(iY(n)){let r=n;nY(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function nY(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function rY(e,t){return t?e?t+` `+e:t:e}function iY(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function aY(e,t,n={}){let r=t.render,i=oY(t,n);return n.enabled===!1?null:cY(e,r,i,n.state??RJ)}function oY(e,t={}){let{className:n,style:r,render:i}=e,{state:a=RJ,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?GJ(n,a):void 0,d=l?KJ(r,a):void 0,f=l?WJ(a,c):RJ,p=l?UJ(f,Array.isArray(s)?YJ(s):s)??RJ:RJ;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=OJ([p.ref,HJ(i),...o]):p.ref=DJ(p.ref,HJ(i),o):DJ(null,null)),l?(u!==void 0&&(p.className=rY(p.className,u)),d!==void 0&&(p.style=UJ(p.style,d)),p):RJ}var sY=Symbol.for(`react.lazy`);function cY(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=JJ(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===sY&&(i=C.Children.toArray(t)[0]),C.cloneElement(i,e)}if(e&&typeof e==`string`)return lY(e,n);throw Error(zJ(8))}function lY(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 uY={...C},dY=0;function fY(e,t=`mui`){let[n,r]=C.useState(e),i=e||n;return C.useEffect(()=>{n??(dY+=1,r(`${t}-${dY}`))},[n,t]),i}var pY=uY.useId;function mY(e,t){if(pY!==void 0){let n=pY();return e??(t?`${t}-${n}`:n)}return fY(e,t)}function hY(e){return mY(e,`base-ui`)}function gY(){return typeof window<`u`}function _Y(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vY(e){return gY()?e instanceof Element||e instanceof _Y(e).Element:!1}function yY(e){return gY()?e instanceof HTMLElement||e instanceof _Y(e).HTMLElement:!1}function bY(e){return!gY()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof _Y(e).ShadowRoot}var xY=C.createContext(void 0);function SY(e=!1){let t=C.useContext(xY);if(t===void 0&&!e)throw Error(zJ(16));return t}function CY(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 wY(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=C.useRef(null),o=SY(!0)!==void 0,s=wJ(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=CY({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=C.useCallback(()=>{let e=a.current;TY(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return NJ(l,[l]),{getButtonProps:C.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return JJ({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(nY(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||(nY(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:wJ(e=>{a.current=e,l()})}}function TY(e){return yY(e)&&e.tagName===`BUTTON`}var EY=C.createContext(void 0);function DY(){let e=C.useContext(EY);if(e===void 0)throw Error(zJ(63));return e}var OY=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}({}),kY={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},AY={valid(e){return e===null?null:e?{[OY.valid]:``}:{[OY.invalid]:``}}},jY=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}({}),MY={...AY,checked(e){return e?{[jY.checked]:``}:{[jY.unchecked]:``}}};function NY(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var PY=C.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:LJ,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function FY(){return C.useContext(PY)}var IY=C.createContext({invalid:void 0,name:void 0,validityData:{state:kY,errors:[],error:``,value:``,initialValue:null},setValidityData:LJ,disabled:void 0,touched:!1,setTouched:LJ,dirty:!1,setDirty:LJ,filled:!1,setFilled:LJ,focused:!1,setFocused:LJ,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=RJ)=>e,getInputValidationProps:(e=RJ)=>e,inputRef:{current:null},commit:async()=>{}}});function LY(e=!0){let t=C.useContext(IY);if(t.setValidityData===LJ&&!e)throw Error(zJ(28));return t}function RY(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=FY(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=LY(),f=wJ(e.getValue);NJ(()=>{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]),NJ(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:NY(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]),NJ(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var zY=C.createContext({controlId:void 0,registerControlId:LJ,labelId:void 0,setLabelId:LJ,messageIds:[],setMessageIds:LJ,getDescriptionProps:e=>e});function BY(){return C.useContext(zY)}function VY(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=BY(),o=hY(t),s=n?i:void 0,c=xJ(()=>Symbol(`labelable-control`)),l=C.useRef(!1),u=C.useRef(t!=null),d=wJ(()=>{!l.current||a===LJ||(l.current=!1,a(c.current,void 0))});return NJ(()=>{if(a===LJ)return;let e;if(n){let n=r?.current;e=vY(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 HY=`none`;function UY(e,t,n,r){let i=!1,a=!1,o=r??RJ;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 WY(e,t){let n=C.useRef(e),r=wJ(t);NJ(()=>{n.current!==e&&r(n.current)},[e,r]),NJ(()=>{n.current=e},[e])}var GY=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:_}=FY(),{state:v,setTouched:y,setDirty:b,validityData:x,setFilled:w,setFocused:T,shouldValidateOnChange:E,validationMode:D,disabled:O,name:k,validation:A}=LY(),{labelId:j}=BY(),M=O||f,N=k??s,P=wJ(l),F=C.useRef(null),I=DJ(F,o,A.inputRef),L=C.useRef(null),ee=hY(),R=VY({id:a,implicit:!1,controlRef:L}),z=c?void 0:R,[B,te]=yJ({controlled:n,default:!!i,name:`Switch`,state:`checked`});RY({id:ee,commit:A.commit,value:B,controlRef:L,name:N,getValue:()=>B}),NJ(()=>{F.current&&w(F.current.checked)},[F,w]),WY(B,()=>{_(N),b(B!==x.initialValue),w(B),E()?A.commit(B):A.commit(B,!0)});let{getButtonProps:V,buttonRef:H}=wY({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(()=>JJ({checked:B,disabled:M,id:z,name:N,required:d,style:N?IJ:FJ,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:I,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=UY(HY,e.nativeEvent);P?.(t,n),!n.isCanceled&&te(t)},onFocus(){L.current?.focus()}},A.getInputValidationProps,h===void 0?RJ:{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=aY(`span`,e,{state:ie,ref:[t,L,H],props:[ne,A.getValidationProps,g,V],stateAttributesMapping:MY});return(0,S.jsxs)(EY.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})]})}),KY=C.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=LY(),o=DY();return aY(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:MY,props:i})});function qY({checked:e,onCheckedChange:t,disabled:n,className:r,ariaLabel:i,id:a,ariaLabelledBy:o,ariaDescribedBy:s}){return(0,S.jsx)(GY,{checked:e,onCheckedChange:t,disabled:n,"aria-label":i,id:a,"aria-labelledby":o,"aria-describedby":s,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)(KY,{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`)})})}function JY(e,t,n,r){return function({ids:i}){let a=W(t=>t[e]),o=W(e=>e[t]);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`button`,{type:`button`,className:Nq,"aria-label":`Test ${r}`,onClick:()=>void n(),children:`Test`}),(0,S.jsx)(qY,{className:St,id:i.control,checked:a,onCheckedChange:e=>{o(e),e&&mJ()},ariaLabelledBy:i.label,ariaDescribedBy:i.description})]})}}var YY=[{id:`sound-permission`,page:`notifications`,label:`Permission sound`,description:`Play a ping when any session needs permission.`,keywords:[`sound`,`audio`,`alert`,`ping`,`approval`],Control:JY(`soundOnPermission`,`setSoundOnPermission`,_J,`permission sound`)},{id:`sound-idle`,page:`notifications`,label:`Idle sound`,description:`Play a chime when a session finishes working.`,keywords:[`sound`,`audio`,`alert`,`chime`,`done`,`finished`],Control:JY(`soundOnIdle`,`setSoundOnIdle`,vJ,`idle sound`)}];function XY(e,t,n){let r=`/api/settings/${e}`,[i,a]=(0,C.useState)(n),[o,s]=(0,C.useState)(!0),[c,l]=(0,C.useState)(!1),u=(0,C.useRef)(n),d=(0,C.useRef)(Promise.resolve()),f=(0,C.useRef)(0),p=(0,C.useRef)(!0),m=(0,C.useRef)(!1);return(0,C.useEffect)(()=>{p.current=!0;let e=!0;return fetch(r).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(n=>{if(!e)return;let r=n[t];f.current===0&&!m.current&&(u.current=r),m.current||a(r)}).catch(()=>{}).finally(()=>{e&&(l(!0),f.current===0&&s(!1))}),()=>{e=!1,p.current=!1}},[r,t]),{value:i,loading:o,loaded:c,set:(0,C.useCallback)(e=>{m.current=!0,f.current+=1,a(e),s(!0),d.current=d.current.then(()=>fetch(r,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({[t]:e})}).then(t=>{if(!t.ok)throw Error(`HTTP ${t.status}`);u.current=e}).catch(()=>{p.current&&f.current===1&&a(u.current)}).finally(()=>{--f.current,p.current&&f.current===0&&s(!1)}))},[r,t])}}function ZY(e,t){return function({ids:n}){let r=W(t=>t[e]),i=W(e=>e[t]);return(0,S.jsx)(qY,{className:St,id:n.control,checked:r,onCheckedChange:i,ariaLabelledBy:n.label,ariaDescribedBy:n.description})}}function QY({ids:e}){return(0,S.jsx)(Vq,{options:[{value:`created`,label:`Created`},{value:`status`,label:`Status`},{value:`manual`,label:`Manual`}],value:W(e=>e.sessionSortMode),onChange:W(e=>e.setSessionSortMode),labelledBy:e.label,describedBy:e.description})}function $Y(){let e=W(e=>e.sessionSortMode);return e===`status`?(0,S.jsx)(S.Fragment,{children:`Sessions re-sort by status: waiting, working, unknown.`}):e===`manual`?(0,S.jsx)(S.Fragment,{children:`Drag sessions in the sidebar to reorder them.`}):(0,S.jsx)(S.Fragment,{children:`Sessions stay in the order they were created.`})}function eX({ids:e}){return(0,S.jsx)(Vq,{options:[{value:`desc`,label:`Newest first`},{value:`asc`,label:`Oldest first`}],value:W(e=>e.sessionSortDirection),onChange:W(e=>e.setSessionSortDirection),labelledBy:e.label,describedBy:e.description})}function tX({ids:e}){return(0,S.jsx)(Vq,{options:[{value:`top`,label:`Top`},{value:`bottom`,label:`Bottom`}],value:W(e=>e.sidebarAnchor),onChange:W(e=>e.setSidebarAnchor),labelledBy:e.label,describedBy:e.description})}function nX(){return W(e=>e.sidebarAnchor)===`bottom`?(0,S.jsx)(S.Fragment,{children:`The sidebar is mirrored: the first session sits at the bottom, next to the prompt.`}):(0,S.jsx)(S.Fragment,{children:`The first session sits at the top of the sidebar.`})}function rX({ids:e}){let{value:t,loaded:n,set:r}=XY(`history-max-age-hours`,`hours`,24);return(0,S.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,S.jsx)(Lq,{id:e.control,type:`text`,inputMode:`numeric`,value:String(t),disabled:!n,describedBy:e.description,wrapperClassName:`w-20`,className:`text-center tabular-nums`,onCommit:e=>{let n=Rq(e,1,168);return n===null?`Enter 1–168`:(n!==t&&r(n),null)}}),(0,S.jsx)(`span`,{className:`flex h-[32px] items-center text-[12px] text-muted max-md:h-[44px]`,children:`hours`})]})}function iX({ids:e}){let{value:t,loaded:n,set:r}=XY(`prefer-window-name`,`enabled`,!1);return(0,S.jsx)(qY,{className:St,id:e.control,checked:t,onCheckedChange:r,disabled:!n,ariaLabelledBy:e.label,ariaDescribedBy:e.description})}var aX=[{id:`sort-order`,page:`session-list`,label:`Sort order`,description:`Created keeps creation order, Status re-sorts by status, Manual lets you drag.`,keywords:[`sort`,`order`,`created`,`status`,`manual`,`drag`],layout:`wide`,Description:$Y,Control:QY},{id:`sort-direction`,page:`session-list`,label:`Sort direction`,description:`Newest or oldest sessions first.`,keywords:[`sort`,`newest`,`oldest`,`ascending`,`descending`],layout:`wide`,visibleWhen:e=>e.sessionSortMode===`created`,Control:eX},{id:`sidebar-anchor`,page:`session-list`,label:`Sidebar anchor`,description:`Top lists the first session at the top; Bottom mirrors the sidebar.`,keywords:[`sidebar`,`mirror`,`top`,`bottom`],tags:[`desktop`],Description:nX,Control:tX},{id:`show-project-name`,page:`session-list`,label:`Project name`,description:`Show the project folder name under each session.`,keywords:[`folder`,`details`],Control:ZY(`showProjectName`,`setShowProjectName`)},{id:`show-last-user-message`,page:`session-list`,label:`Last user message`,description:`Show the most recent prompt next to the project name.`,keywords:[`prompt`,`input`,`details`],Control:ZY(`showLastUserMessage`,`setShowLastUserMessage`)},{id:`show-session-id-prefix`,page:`session-list`,label:`Session ID prefix`,description:`Show the first 5 characters of the agent session ID.`,keywords:[`id`,`uuid`,`details`],Control:ZY(`showSessionIdPrefix`,`setShowSessionIdPrefix`)},{id:`history-lookback`,page:`session-list`,label:`History lookback`,description:`Show history sessions from the last N hours (1–168). Default 24.`,keywords:[`history`,`hours`,`age`,`inactive`,`past`],Control:rX},{id:`prefer-window-name`,page:`session-list`,label:`Prefer window names`,description:`Label discovered sessions with their tmux window name instead of the session name.`,keywords:[`tmux`,`window`,`name`,`title`],Control:iX}],oX=`1-9 [ ] N X ,`;function sX({ids:e}){let t=W(e=>e.useWebGL),n=W(e=>e.setUseWebGL);return(0,S.jsx)(qY,{className:St,id:e.control,checked:t,onCheckedChange:n,ariaLabelledBy:e.label,ariaDescribedBy:e.description})}function cX(e,t){return function({ids:n}){let{value:r,loaded:i,set:a}=XY(e,`enabled`,t);return(0,S.jsx)(qY,{className:St,id:n.control,checked:r,onCheckedChange:a,disabled:!i,ariaLabelledBy:n.label,ariaDescribedBy:n.description})}}var lX=[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`];function uX({ids:e}){let t=W(e=>e.shortcutModifier),n=W(e=>e.setShortcutModifier);return(0,S.jsx)(Vq,{options:lX.map(e=>({value:e,label:e===`auto`?`Auto`:pt(e)})),value:t,onChange:n,labelledBy:e.label,describedBy:e.description})}function dX(){return(0,S.jsxs)(S.Fragment,{children:[`Shortcuts: `,pt(dt(W(e=>e.shortcutModifier))),` + `,oX,` (sessions, navigate, new, kill, settings).`]})}var fX=[{id:`webgl`,page:`terminal`,label:`WebGL acceleration`,description:`GPU rendering for better performance. Turn off if text looks fuzzy or flickers (common in Safari).`,keywords:[`gpu`,`renderer`,`canvas`,`blurry`,`performance`],tags:[`device`],Control:sX},{id:`mouse-mode`,page:`terminal`,label:`Mouse mode`,description:`tmux mouse mode for trackpad and scroll wheel support.`,keywords:[`tmux`,`scroll`,`trackpad`,`mouse`],Control:cX(`tmux-mouse-mode`,!0)},{id:`terminal-colors`,page:`terminal`,label:`Terminal colors`,description:`Preserve ANSI colors in terminal output. Hibernate then Wake running agents after changing this.`,keywords:[`ansi`,`color`,`colour`],Control:cX(`terminal-colors`,!0)},{id:`shortcut-modifier`,page:`terminal`,label:`Keyboard shortcut modifier`,description:`Modifier keys for the app shortcuts. Auto picks ⌃⌥ on macOS, ⌃⇧ elsewhere.`,keywords:[`keyboard`,`shortcut`,`hotkey`,`ctrl`,`cmd`,`option`,`shift`],tags:[`desktop`,`device`],layout:`wide`,Description:dX,Control:uX}],pX=[...aJ,...aX,...Jq,...fX,...YY];function mX(e,t=pX){return t.filter(t=>t.page===e)}function hX(e){return[e.label,e.description,...e.keywords??[]].join(` `).toLowerCase()}function gX(e,t=pX){let n=e.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[]:t.filter(e=>{let t=hX(e);return n.every(e=>t.includes(e))})}function _X(e){return wq.map(t=>({page:t.id,label:t.label,rows:e.filter(e=>e.page===t.id)})).filter(e=>e.rows.length>0)}var vX={desktop:`Desktop`,device:`This device`},yX={desktop:`Only affects the desktop layout`,device:`Stored in this browser only; not synced to other devices`};function bX({tag:e}){return(0,S.jsx)(`span`,{title:yX[e],className:`shrink-0 border border-border px-1 py-px text-[10px] uppercase leading-none tracking-wide text-muted`,children:vX[e]})}function xX(e){let t=`settings-${e}`;return{control:`${t}-control`,label:`${t}-label`,description:`${t}-desc`}}function SX({row:e}){let t=xX(e.id),n=e.layout??`inline`,{Control:r,Description:i}=e;return(0,S.jsxs)(`div`,{"data-setting-row":e.id,className:l_(`flex gap-x-6 gap-y-3 py-4`,n===`block`&&`flex-col`,n===`wide`&&`items-center max-md:flex-col max-md:items-stretch`,n===`inline`&&`items-center`),children:[(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,S.jsx)(`label`,{id:t.label,htmlFor:t.control,className:`text-[14px] leading-snug text-primary`,children:e.label}),e.tags?.map(e=>(0,S.jsx)(bX,{tag:e},e))]}),(0,S.jsx)(`div`,{id:t.description,className:`mt-1 text-[12px] leading-snug text-muted text-pretty`,children:i?(0,S.jsx)(i,{}):e.description})]}),(0,S.jsx)(`div`,{className:l_(`flex min-w-0 items-center gap-2`,n===`inline`?`shrink-0`:`max-w-full`),children:(0,S.jsx)(r,{ids:t})})]})}function CX(e,t){return e.visibleWhen?e.visibleWhen(t):!0}function wX({rows:e}){let t=W(t=>e.map(e=>CX(e,t)?`1`:`0`).join(``));return(0,S.jsx)(`div`,{className:`divide-y divide-border`,children:e.filter((e,n)=>t[n]===`1`).map(e=>(0,S.jsx)(SX,{row:e},e.id))})}function TX({page:e,showTitle:t}){let n=(0,C.useMemo)(()=>mX(e),[e]);return(0,S.jsxs)(`section`,{"aria-labelledby":t?`settings-page-${e}-title`:void 0,children:[t&&(0,S.jsx)(`h3`,{id:`settings-page-${e}-title`,className:`pb-1 text-[18px] font-semibold leading-tight text-primary`,children:Eq(e)}),(0,S.jsx)(wX,{rows:n})]})}function EX({query:e}){let t=(0,C.useMemo)(()=>gX(e),[e]),n=W(e=>t.some(t=>CX(t,e))),r=(0,C.useMemo)(()=>_X(t),[t]);return n?(0,S.jsx)(`div`,{className:`flex flex-col gap-6`,children:r.map(e=>(0,S.jsx)(DX,{label:e.label,rows:e.rows},e.page))}):(0,S.jsxs)(`div`,{role:`status`,className:`flex flex-col items-center gap-1 py-16 text-center`,children:[(0,S.jsxs)(`p`,{className:`text-[14px] text-primary`,children:[`No settings match “`,e.trim(),`”`]}),(0,S.jsx)(`p`,{className:`text-[12px] text-muted`,children:`Try a different word, like “font” or “sound”.`})]})}function DX({label:e,rows:t}){return W(e=>t.some(t=>CX(t,e)))?(0,S.jsxs)(`section`,{"aria-label":e,children:[(0,S.jsx)(`h3`,{className:`border-b border-border pb-1 text-[11px] font-medium uppercase tracking-wider text-muted`,children:e}),(0,S.jsx)(wX,{rows:t})]}):null}function OX(e){return`settings-tab-${e}`}function kX(e,t,n){return e===`ArrowDown`?(t+1)%n:e===`ArrowUp`?(t-1+n)%n:e===`Home`?0:e===`End`?n-1:null}function AX({variant:e,current:t,onSelect:n,panelId:r}){let i=(0,C.useRef)([]),a=Math.max(0,wq.findIndex(e=>e.id===t)),o=(t,r)=>{let a=kX(t.key,r,wq.length);a!==null&&(t.preventDefault(),i.current[a]?.focus(),e===`tabs`&&n(wq[a].id))};return e===`list`?(0,S.jsx)(`nav`,{"aria-label":`Settings pages`,children:(0,S.jsx)(`ul`,{className:`divide-y divide-border border-y border-border`,children:wq.map((e,t)=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(`button`,{ref:e=>{i.current[t]=e},type:`button`,"data-page-id":e.id,onClick:()=>n(e.id),onKeyDown:e=>o(e,t),className:`flex min-h-[52px] w-full items-center justify-between gap-3 px-4 text-left text-[15px] text-primary active:bg-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,children:[e.label,(0,S.jsx)(j,{width:G.primary,height:G.primary,className:`text-muted`,"aria-hidden":`true`})]})},e.id))})}):(0,S.jsx)(`div`,{role:`tablist`,"aria-orientation":`vertical`,"aria-label":`Settings pages`,className:`flex flex-col gap-px`,children:wq.map((e,s)=>{let c=e.id===t;return(0,S.jsx)(`button`,{ref:e=>{i.current[s]=e},id:OX(e.id),type:`button`,role:`tab`,"aria-selected":c,"aria-controls":r,tabIndex:s===a?0:-1,onClick:()=>n(e.id),onKeyDown:e=>o(e,s),className:l_(`flex h-[32px] w-full items-center border-l-2 px-3 text-left text-[13px] transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,c?`border-primary bg-hover font-medium text-primary`:`border-transparent text-secondary hover:text-primary`),children:e.label},e.id)})})}var jX=(0,C.forwardRef)(function({value:e,onChange:t,className:n},r){return(0,S.jsxs)(`div`,{className:n,children:[(0,S.jsx)(`label`,{htmlFor:`settings-search`,className:`sr-only`,children:`Search settings`}),(0,S.jsx)(`input`,{ref:r,id:`settings-search`,type:`search`,value:e,placeholder:`Search settings`,autoComplete:`off`,spellCheck:!1,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),t(``))},className:`input h-[32px] px-2 py-0 text-[13px] max-md:h-[44px] max-md:text-[16px] focus-visible:ring-2 focus-visible:ring-accent/40`})]})}),MX=[`a[href]`,`button:not([disabled])`,`input:not([disabled]):not([type="hidden"])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function NX(e){return Array.from(e.querySelectorAll(MX)).filter(e=>e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex!==-1)}function PX(e,t,n){if(e.length===0)return null;let r=e[0],i=e[e.length-1],a=t===null?-1:e.indexOf(t);return a===-1?n?i:r:n&&a===0?i:!n&&a===e.length-1?r:null}var FX=`.xterm-helper-textarea`,IX=300,LX=`[data-suspends-terminal]`,RX=null;function zX(e){return!e||typeof document>`u`||e===document.body?null:typeof e.focus==`function`?e:null}function BX(e,t){if(e.isConnected)return e;if(!t)return null;let n=t.replace(/["\\]/g,`\\$&`);return document.querySelector(`button[aria-label="${n}"]`)}function VX(){(0,C.useEffect)(()=>{if(typeof document>`u`||typeof document.querySelector!=`function`)return;RX&&=(clearTimeout(RX),null);let e=zX(document.activeElement),t=document.querySelector(FX);t&&(t.blur(),t.setAttribute(`disabled`,`true`));let n=e?.getAttribute?.(`aria-label`)??null;return()=>{RX=setTimeout(()=>{if(RX=null,document.querySelector(LX))return;let r=document.querySelector(FX);if(r){r.removeAttribute(`disabled`),r.focus();return}(e&&e!==t?BX(e,n):null)?.focus()},IX)}},[])}function HX(e,t){let n=(0,C.useRef)(t);n.current=t,(0,C.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let t=t=>{if(t.key===`Escape`){if(t.defaultPrevented)return;t.preventDefault(),t.stopPropagation(),n.current();return}if(t.key!==`Tab`)return;let r=e.current;if(!r)return;let i=document.activeElement,a=PX(NX(r),i,t.shiftKey);a&&(t.preventDefault(),a.focus())},r=t=>{let n=e.current,r=t.target;n&&r&&!n.contains(r)&&n.focus()};return document.addEventListener(`keydown`,t),document.addEventListener(`focusin`,r),()=>{document.removeEventListener(`keydown`,t),document.removeEventListener(`focusin`,r)}},[e])}function UX({isOpen:e,onClose:t}){return e?(0,S.jsx)(KX,{onClose:t}):null}var WX=`settings-panel`,GX=`flex shrink-0 items-center justify-center text-secondary transition-colors hover:bg-hover hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`;function KX({onClose:e}){let t=PG(),[n,r]=(0,C.useState)(()=>t?null:kq()),[i,a]=(0,C.useState)(``),o=(0,C.useRef)(null),s=(0,C.useRef)(null),c=(0,C.useRef)(null),l=(0,C.useRef)(!1),u=(0,C.useRef)(null);VX(),HX(o,e),(0,C.useEffect)(()=>{t?o.current?.focus():s.current?.focus()},[]),(0,C.useEffect)(()=>{if(t){if(n)c.current?.focus();else if(u.current){let e=o.current?.querySelector(`[data-page-id="${u.current}"]`);u.current=null,e?.focus()}}},[t,n]);let d=e=>{r(e),Aq(e),a(``)},f=i.trim().length>0,p=(0,S.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Close settings`,className:l_(GX,`size-[32px] max-md:size-[44px]`),children:(0,S.jsx)(Fe,{width:G.primary,height:G.primary})});if(t)return(0,S.jsxs)(`div`,{ref:o,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`settings-title`,"data-suspends-terminal":``,tabIndex:-1,className:`fixed inset-0 z-50 flex flex-col bg-elevated outline-none`,style:{paddingTop:`env(safe-area-inset-top)`,paddingLeft:`env(safe-area-inset-left)`,paddingRight:`env(safe-area-inset-right)`},children:[(0,S.jsxs)(`header`,{className:`flex h-[52px] shrink-0 items-center gap-1 border-b border-border px-1`,children:[n?(0,S.jsx)(`button`,{ref:c,type:`button`,onClick:()=>{u.current=n,r(null)},"aria-label":`Back to settings`,className:l_(GX,`size-[44px]`),children:(0,S.jsx)(j,{width:G.primary,height:G.primary,className:`rotate-180`})}):(0,S.jsx)(`span`,{"aria-hidden":`true`,className:`size-[44px] shrink-0`}),(0,S.jsx)(`h2`,{id:`settings-title`,className:`min-w-0 flex-1 truncate text-center text-[16px] font-semibold text-primary`,children:n?Eq(n):`Settings`}),p]}),(0,S.jsx)(`div`,{id:WX,className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-4`,style:{paddingBottom:`calc(24px + env(safe-area-inset-bottom))`},children:n?(0,S.jsx)(TX,{page:n,showTitle:!1}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(jX,{ref:s,value:i,onChange:a,className:`py-3`}),f?(0,S.jsx)(EX,{query:i}):(0,S.jsx)(`div`,{className:`-mx-4`,children:(0,S.jsx)(AX,{variant:`list`,current:null,onSelect:d})})]})})]});let m=n??kq();return(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4`,onMouseDown:e=>{l.current=e.target===e.currentTarget},onClick:t=>{l.current&&t.target===t.currentTarget&&e(),l.current=!1},children:(0,S.jsxs)(`div`,{ref:o,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`settings-title`,"data-suspends-terminal":``,tabIndex:-1,className:`flex h-[600px] max-h-full w-[760px] max-w-full flex-col border border-border bg-elevated shadow-2xl outline-none`,children:[(0,S.jsxs)(`header`,{className:`flex h-[48px] shrink-0 items-center justify-between border-b border-border pl-5 pr-2`,children:[(0,S.jsx)(`h2`,{id:`settings-title`,className:`text-[13px] font-semibold uppercase tracking-wider text-primary`,children:`Settings`}),p]}),(0,S.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex w-[192px] shrink-0 flex-col gap-3 border-r border-border p-3`,children:[(0,S.jsx)(jX,{ref:s,value:i,onChange:a}),(0,S.jsx)(AX,{variant:`tabs`,current:f?null:m,onSelect:d,panelId:WX})]}),(0,S.jsx)(`div`,{id:WX,role:f?`region`:`tabpanel`,"aria-label":f?`Search results`:void 0,"aria-labelledby":f?void 0:OX(m),className:`min-w-0 flex-1 overflow-y-auto overflow-x-hidden px-6 py-5`,children:f?(0,S.jsx)(EX,{query:i}):(0,S.jsx)(TX,{page:m,showTitle:!0})})]})]})})}var qX=[];function JX(e){C.useEffect(e,qX)}var YX=C.createContext(void 0);function XX(){let e=C.useContext(YX);if(!e)throw Error(zJ(73));return e}var ZX=Symbol(`NOT_FOUND`);function QX(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function $X(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function eZ(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 tZ=e=>Array.isArray(e)?e:[e];function nZ(e){let t=Array.isArray(e[0])?e[0]:e;return eZ(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function rZ(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function iZ(e){let t;return{get(n){return t&&e(t.key,n)?t.value:ZX},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function aZ(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 ZX}function i(t,i){r(t)===ZX&&(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 oZ=(e,t)=>e===t;function sZ(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 cZ(e,t){let{equalityCheck:n=oZ,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=sZ(n),o=0,s=r<=1?iZ(a):aZ(r,a);function c(){let t=s.get(arguments);if(t===ZX){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 lZ=class{constructor(e){this.value=e}deref(){return this.value}},uZ=typeof WeakRef<`u`?WeakRef:lZ,dZ=0,fZ=1;function pZ(){return{s:dZ,v:void 0,o:null,p:null}}function mZ(e,t={}){let n=pZ(),{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=pZ(),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=pZ(),e.set(n,t)):t=r}}let s=t,c;if(t.s===fZ)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 uZ(c):c}return s.s=fZ,s.v=c,c}return o.clearCache=()=>{n=pZ(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function hZ(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()),QX(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=mZ,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=tZ(c),p=tZ(u),m=nZ(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=rZ(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 gZ=hZ(mZ),_Z=Object.assign((e,t=gZ)=>{$X(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:()=>_Z}),vZ=hZ({memoize:cZ,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),yZ=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(zJ(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},bZ=(...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(zJ(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(zJ(2))}u=vZ(...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`)}}},xZ=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})),SZ=s(((e,t)=>{t.exports=xZ()})),CZ=s((e=>{var t=p(),n=SZ();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}})),wZ=s(((e,t)=>{t.exports=CZ()})),TZ=[],EZ=void 0;function DZ(){return EZ}function OZ(e){TZ.push(e)}var kZ=SZ(),AZ=wZ(),jZ=VJ(19)?PZ:FZ;function MZ(e,t,n,r,i){return jZ(e,t,n,r,i)}function NZ(e,t,n,r,i){let a=C.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,kZ.useSyncExternalStore)(e.subscribe,a,a)}OZ({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,kZ.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function PZ(e,t,n,r,i){let a=DZ();if(!a)return NZ(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 FZ(e,t,n,r,i){return(0,AZ.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var IZ=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 MZ(this,e,t,n,r)}},LZ=class extends IZ{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){C.useDebugValue(e),NJ(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;NJ(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;NJ(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){C.useDebugValue(e);let n=t!==void 0;NJ(()=>{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),MZ(this,this.selectors[e],t,n,r)}useContextCallback(e,t){C.useDebugValue(e);let n=wJ(t??LJ);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)}})}},RZ=null;globalThis.requestAnimationFrame;var zZ=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)}},BZ=class e{static create(){return new e}static request(e){return zZ.request(e)}static cancel(e){return zZ.cancel(e)}currentId=RZ;request(e){this.cancel(),this.currentId=zZ.request(()=>{this.currentId=RZ,e()})}cancel=()=>{this.currentId!==RZ&&(zZ.cancel(this.currentId),this.currentId=RZ)};disposeEffect=()=>this.cancel};function VZ(){let e=xJ(BZ.create).current;return JX(e.disposeEffect),e}var HZ=0,UZ=class e{static create(){return new e}currentId=HZ;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=HZ,t()},e)}isStarted(){return this.currentId!==HZ}clear=()=>{this.currentId!==HZ&&(clearTimeout(this.currentId),this.currentId=HZ)};disposeEffect=()=>this.clear};function WZ(){let e=xJ(UZ.create).current;return JX(e.disposeEffect),e}var GZ=0;function KZ(e){return GZ+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${GZ}`}function qZ(e){return e?.ownerDocument||document}function JZ(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 YZ=typeof navigator<`u`,XZ=tQ(),ZZ=rQ(),QZ=nQ();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),XZ.platform===`MacIntel`&&XZ.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(XZ.platform),YZ&&/firefox/i.test(QZ);var $Z=YZ&&/apple/i.test(navigator.vendor);YZ&&/Edg/i.test(QZ),YZ&&/android/i.test(ZZ)||/android/i.test(QZ),YZ&&ZZ.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var eQ=QZ.includes(`jsdom/`);function tQ(){if(!YZ)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 nQ(){if(!YZ)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function rQ(){if(!YZ)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function iQ(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function aQ(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&bY(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function oQ(e){return`composedPath`in e?e.composedPath()[0]:e.target}function sQ(e){if(!e||eQ)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var cQ=bZ(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}),lQ={toasts:yZ(e=>e.toasts),isEmpty:yZ(e=>e.toasts.length===0),toast:yZ(cQ,(e,t)=>e.get(t)?.value),toastIndex:yZ(cQ,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:yZ(cQ,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:yZ(cQ,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:yZ(e=>e.hovering),focused:yZ(e=>e.focused),expanded:yZ(e=>e.hovering||e.focused),expandedOrOutOfFocus:yZ(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:yZ(e=>e.prevFocusElement)},uQ=class extends LZ{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},lQ)}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=lQ.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||KZ(`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)),lQ.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=lQ.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)),lQ.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{lQ.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=JZ(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=JZ(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=JZ(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??=UZ.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=oQ(e);aQ(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!lQ.expandedOrOutOfFocus(this.state),a=i?UZ.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=iQ(qZ(this.state.viewport));if(!this.state.viewport||!aQ(this.state.viewport,t)||!sQ(t))return;let n=lQ.toasts(this.state),r=lQ.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()}},dQ=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=xJ(()=>new uQ({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return JX(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)(YX.Provider,{value:a,children:t})},fQ=C.forwardRef(function(e,t){let[n,r]=C.useState();NJ(()=>{$Z&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,S.jsx)(`span`,{...e,ref:t,style:FJ,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),pQ=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),mQ=C.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=XX(),s=WZ(),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(iQ(qZ(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=_Y(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=_Y(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=oQ(n),i=iQ(qZ(e));(!aQ(e,r)||!sQ(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=qZ(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||sQ(qZ(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function w(e){!f||aQ(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=aY(`div`,e,{ref:[t,o.setViewport],state:E,props:[T,{style:{[pQ.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,S.jsxs)(C.Fragment,{children:[!u&&m&&(0,S.jsx)(fQ,{onFocus:_}),i,!u&&m&&(0,S.jsx)(fQ,{onFocus:_})]})}]}),O=C.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,S.jsxs)(C.Fragment,{children:[!u&&m&&(0,S.jsx)(fQ,{onFocus:_}),D,!f&&O.length>0&&(0,S.jsx)(`div`,{style:FJ,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 hQ(e){return VJ(19)?e:e?`true`:void 0}var gQ=C.createContext(void 0);function _Q(){let e=C.useContext(gQ);if(!e)throw Error(zJ(66));return e}var vQ=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),yQ={[vQ.startingStyle]:``},bQ={[vQ.endingStyle]:``},xQ={transitionStatus(e){return e===`starting`?yQ:e===`ending`?bQ:null}};function SQ(e){return e==null?e:`current`in e?e.current:e}function CQ(e,t=!1,n=!0){let r=VZ();return wJ((i,a=null)=>{r.cancel();function o(){Vd.flushSync(i)}let s=SQ(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=vQ.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 wQ(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=wJ(i),o=CQ(r,n,!1);C.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var TQ=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}({}),EQ={...xQ,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},DQ=40,OQ=10,kQ=.5,AQ=1;function jQ(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 MQ(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 NQ=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=XX(),[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`);wQ({open:n.transitionStatus!==`ending`,ref:j,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let H=wJ((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()});NJ(H,[H]);function ne(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**kQ:-(Math.abs(e)**kQ):(!c.includes(`right`)&&e>0&&(n=e**kQ),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**kQ))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**kQ:-(Math.abs(t)**kQ):(!c.includes(`down`)&&t>0&&(r=t**kQ),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**kQ))),{x:n,y:r}}function re(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=oQ(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=MQ(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)>=AQ&&(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=jQ(u,a,o),f(u));else{let e=P.current,t=jQ(e,l,s);t>DQ?(I.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&F.current-t>=OQ&&(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>DQ&&(t=!0,a=`right`);break;case`left`:r<-DQ&&(t=!0,a=`left`);break;case`down`:i>DQ&&(t=!0,a=`down`);break;case`up`:i<-DQ&&(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||!aQ(j.current,iQ(qZ(j.current))))return;u.closeToast(n.id)}}C.useEffect(()=>{if(!l)return;let e=j.current;if(!e)return;function t(t){aQ(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{[TQ.swipeMovementX]:`0px`,[TQ.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,[TQ.swipeMovementX]:`${e}px`,[TQ.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:hQ(n.limited),style:{...oe(),[TQ.index]:n.transitionStatus===`ending`?R:z,[TQ.offsetY]:`${B}px`,[TQ.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=aY(`div`,e,{ref:[t,le.rootRef],state:ue,stateAttributesMapping:EQ,props:[ce,o]});return(0,S.jsx)(gQ.Provider,{value:le,children:de})}),PQ=C.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=_Q(),l=a??s.description,u=!!l,d=mY(i);NJ(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=aY(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),FQ=C.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=_Q(),l=a??s.title,u=!!l,d=mY(i);NJ(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=aY(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),IQ=C.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=XX(),{toast:c}=_Q(),l=s.useState(`expanded`),[u,d]=C.useState(!1),{getButtonProps:f,buttonRef:p}=wY({disabled:i,native:a}),m={type:c.type};return aY(`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 LQ(){let e=C.useContext(YX);if(!e)throw Error(zJ(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 RQ(){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||KZ(`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 zQ=5e3,BQ=RQ();function VQ({toast:e}){return(0,S.jsxs)(NQ,{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)(FQ,{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)(PQ,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,S.jsx)(IQ,{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 HQ(){let{toasts:e}=LQ();return(0,S.jsx)(S.Fragment,{children:e.map(e=>(0,S.jsx)(VQ,{toast:e},e.id))})}function UQ(){return(0,S.jsxs)(dQ,{timeout:zQ,toastManager:BQ,children:[(0,S.jsx)(HQ,{}),(0,S.jsx)(mQ,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var WQ=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],GQ=3e3,KQ=8e3,qQ=15e3,JQ=5e3,YQ=2e4,XQ=1e4,ZQ=1500,QQ=5e3,$Q=750,e$=4,t$=5e3,n$=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?WQ[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?KQ:GQ;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:WQ[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(QQ)));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>qQ&&(KO(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},JQ))}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))},ZQ)}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()},$Q)):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()},XQ)))};e!==void 0&&e<YQ?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,YQ)},e):this.heartbeatTimer=window.setInterval(t,YQ)}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>=e$){KO(`ws_stall_detected`,this.wsSnap(),`info`),this.purgeLeakedSockets();let e=Math.min(t$*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 r$(){let e=Sh(e=>e.setConnectionState);return(0,C.useEffect)(()=>{n$.connect(),n$.startLifecycleListeners();let t=n$.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),n$.stopLifecycleListeners()}},[e]),{sendMessage:(0,C.useMemo)(()=>e=>{n$.send(e)},[]),subscribe:(0,C.useMemo)(()=>n$.subscribe.bind(n$),[]),getConnectionEpoch:(0,C.useMemo)(()=>()=>n$.getConnectionEpoch(),[])}}var i$=100;function a$({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>i$?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function o$(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 s$(){(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=()=>{a$({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(),o$(document)}},[])}var c$=[`theme`,`commandPresets`,`defaultPresetId`,`defaultProjectDir`,`lastProjectPath`,`recentPaths`,`sessionSortMode`,`sessionSortDirection`,`manualSessionOrder`,`sidebarAnchor`,`projectFilters`,`hostFilters`,`showProjectName`,`showLastUserMessage`,`showSessionIdPrefix`,`soundOnPermission`,`soundOnIdle`],l$=[`claude`,`claude-rp`,`codex`,`pi`,`devin`,`grok`,`omp`];function u$(e){return typeof e==`boolean`}function d$(e,t){return Array.isArray(e)&&e.length<=t&&e.every(e=>typeof e==`string`)}function f$(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||l$.includes(t.agentType))}var p$={theme:e=>e===`dark`||e===`light`||e===`system`,commandPresets:e=>Array.isArray(e)&&e.length<=50&&e.every(f$),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=>d$(e,50),sessionSortMode:e=>e===`status`||e===`created`||e===`manual`,sessionSortDirection:e=>e===`asc`||e===`desc`,manualSessionOrder:e=>d$(e,1e3),sidebarAnchor:e=>e===`top`||e===`bottom`,projectFilters:e=>d$(e,500),hostFilters:e=>d$(e,500),showProjectName:u$,showLastUserMessage:u$,showSessionIdPrefix:u$,soundOnPermission:u$,soundOnIdle:u$};function m$(e){return c$.includes(e)}function h$(e,t){return p$[e](t)}var g$=`agentboard-theme`,_$=`agentboard-settings`,v$=200,y$=new Map,b$=new Map,x$=new Set;function S$(e){return b$.has(e)||x$.has(e)}var C$=null,w$=!1;function T$(e){return e===`theme`?VG.getState().theme:W.getState()[e]}function E$(e){let t=e===`theme`?g$:_$;return Je.getItem(t)!==null}function D$(){if(C$=null,b$.size===0)return;let e={},t=new Map,n=new Map;for(let[r,i]of b$)e[r]=JSON.parse(i),t.set(r,i),n.set(r,y$.get(r)),y$.set(r,i),x$.add(r);b$.clear();let r=()=>{for(let[e,r]of t){if(y$.get(e)!==r)continue;let t=n.get(e);t===void 0?y$.delete(e):y$.set(e,t)}},i=e=>{for(let n of t.keys()){if(x$.delete(n),!e||b$.has(n))continue;let t=y$.get(n);t!==void 0&&t!==JSON.stringify(T$(n))&&O$(n,JSON.parse(t))}},a=!1;try{fetch(`/api/settings/synced`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({settings:e})}).then(e=>{a=e.ok,e.ok||(KO(`synced_settings_push_rejected`,{status:e.status},`warn`),r())}).catch(e=>{KO(`synced_settings_push_failed`,{message:e instanceof Error?e.message:String(e)},`warn`),r()}).finally(()=>i(a))}catch(e){r(),i(!1),KO(`synced_settings_push_failed`,{message:e instanceof Error?e.message:String(e)},`warn`)}}function O$(e,t){e===`theme`?VG.setState({theme:t}):W.setState({[e]:t})}function k$(e,t){if(y$.get(e)===JSON.stringify(t)){b$.delete(e);return}A$(e,t)}function A$(e,t){b$.set(e,JSON.stringify(t)),!C$&&(C$=setTimeout(D$,v$))}function j$(e){let t=new Map;for(let e of c$)t.set(e,E$(e));let n={},r;for(let[t,i]of Object.entries(e))!m$(t)||!h$(t,i)||(y$.set(t,JSON.stringify(i)),!S$(t)&&(t===`theme`?r=i:n[t]=i));r!==void 0&&VG.setState({theme:r}),Object.keys(n).length>0&&W.setState(n);for(let n of c$){if(n in e||!t.get(n))continue;let r=T$(n);h$(n,r)&&y$.get(n)!==JSON.stringify(r)&&A$(n,r)}}function M$(){if(w$)return()=>{};w$=!0;let e=W.subscribe((e,t)=>{let n=e,r=t;for(let e of c$)e!==`theme`&&n[e]!==r[e]&&k$(e,n[e])}),t=VG.subscribe((e,t)=>{e.theme!==t.theme&&k$(`theme`,e.theme)});return()=>{e(),t(),w$=!1,C$&&=(clearTimeout(C$),null),b$.clear(),x$.clear(),y$.clear()}}function N$(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 P$(){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=HG(),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}=r$();(0,C.useEffect)(()=>M$(),[]),s$(),(0,C.useEffect)(()=>{if(typeof document>`u`||!fe&&!pe)return;let e=!1,t=()=>{e&&!fJ()||(e=!0,mJ())};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&&_J(),e.status===`working`&&i.status===`waiting`&&r&&vJ())}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`&&j$(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&&_J(),t===`working`&&n===`waiting`&&r&&vJ()}}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)(()=>N$(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=ce===`bottom`&&!window.matchMedia(`(max-width: 767px)`).matches,t=(i===`BracketLeft`?-1:1)*(e?-1:1),n=ke;if(n.length===0){let e=Ce;if(e.length===0)return;let n=e.findIndex(e=>e.sessionId===b);if(n===-1){k(e[0].sessionId);return}k(e[(n+t+e.length)%e.length].sessionId);return}let a=n.findIndex(e=>e.id===y);if(a===-1){O(n[0].id);return}O(n[(a+t+n.length)%n.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&&!c&&V&&t(!0);return}if(a&&i===`Comma`){r.preventDefault(),l(t=>t?!1:!e);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&!c&&Ie(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,c,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)(()=>UG(),[]),(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)(iq,{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)(Cq,{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)(UX,{isOpen:c,onClose:()=>l(!1)}),(0,S.jsx)(UQ,{})]})}var F$=`modulepreload`,I$=function(e){return`/`+e},L$={},R$=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=I$(t,n),t in L$)return;L$[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`:F$,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)})},z$=`true`,B$=`false`,V$=z$===`true`,H$=B$===`true`;function U$(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,V$||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await R$(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()},!H$)if(V$)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`),U$({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var W$=document.getElementById(`root`);if(!W$)throw Error(`Root element not found`);(0,x.createRoot)(W$).render((0,S.jsx)(C.StrictMode,{children:(0,S.jsx)(P$,{})}));
|
package/dist/client/index.html
CHANGED
|
@@ -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-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-DnLPRHVE.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-Df-L8u4N.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 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:"
|
|
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:"957fcd18d30e89e31873594be1925f54"},{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-DnLPRHVE.js",revision:null},{url:"assets/index-Df-L8u4N.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(?:\/|$)/]}))});
|