@gbasin/agentboard-linux-arm64 0.5.2 → 0.5.3
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.
|
@@ -209,7 +209,7 @@ ${s.join(`
|
|
|
209
209
|
word-break: break-all;
|
|
210
210
|
`,h=document.createElement(`div`),m.appendChild(h),g=document.createElement(`div`),g.style.color=`var(--text-muted)`,g.style.marginTop=`2px`,g.style.fontSize=`11px`,m.appendChild(g),O.current=m);let x=(e,t)=>{if(!r.element||!m||!h||!g)return;let n=_H(t);if(!n)return;let i=r.element.getBoundingClientRect(),a=n.length>60?n.slice(0,57)+`...`:n;h.textContent=a,g.textContent=`${vH()?`⌘`:`Ctrl`}+click to open`,m.style.left=`${e.clientX-i.left+10}px`,m.style.top=`${e.clientY-i.top+10}px`,m.style.display=`block`},M=()=>{m&&(m.style.display=`none`)},P=null,L=!1,ee=null,z={activate:(e,t)=>{if(!L&&(e.metaKey||e.ctrlKey)){let e=_H(t);if(!e)return;window.open(e,`_blank`,`noopener`)}},hover:(e,t)=>{P=_H(t)||null,x(e,t)},leave:()=>{P=null,M()}},te=e=>{P&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.stopPropagation(),L=!0,window.open(P,`_blank`,`noopener`),ee&&clearTimeout(ee),ee=setTimeout(()=>{L=!1},100))};t.addEventListener(`mousedown`,te,!0),r.options.linkHandler=z;let V=new yz((e,t)=>z.activate(e,t),{urlRegex:pH,hover:(e,t)=>z.hover(e,t),leave:()=>z.leave()});r.loadAddon(V),D.current=V;let ne=null,U=null,ie=vH()?`metaKey`:`ctrlKey`,ae=(e,t)=>{t&&oe.current===e&&se.current===e&&(I.current&&(fe.current({type:`tmux-cancel-copy-mode`,sessionId:e}),Oe(!1)),fe.current({type:`terminal-input`,sessionId:e,data:t}))};r.attachCustomKeyEventHandler(e=>{if(e.type===`keydown`&&/^Digit[1-9]$/.test(e.code)&&Xe(e,qe(H.getState().shortcutModifier)))return!1;if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`c`&&r.hasSelection()){let e=r.getSelection();return e?.trim()&&navigator.clipboard&&navigator.clipboard.writeText(e),!1}if(vH()&&!b&&e.ctrlKey&&!e.metaKey&&e.key.toLowerCase()===`v`&&e.type===`keydown`){let e=se.current;if(e){if(!y())return v.current?.(`Use browser paste or choose a file from this device.`),!1;I.current&&(fe.current({type:`tmux-cancel-copy-mode`,sessionId:e}),Oe(!1)),(async()=>{ae(e,await TH(pe.current,{}))})()}return!e}if(e[ie]&&e.key.toLowerCase()===`v`&&e.type===`keydown`){U!==null&&(clearTimeout(U),U=null),ne=null;let e=new Promise(e=>{U=setTimeout(()=>{U=null,ne=null,e(null)},100),ne=t=>{U!==null&&(clearTimeout(U),U=null),e(t)}});return(async()=>{try{let t=se.current;if(!t)return;let n=await e;if(!n&&_.current)return;let r=n?.text??null;if(r===null)try{r=await navigator.clipboard.readText()}catch{r=``}if(n?.files.length&&_.current){if(oe.current===t&&se.current===t){let e=n.files.map(e=>e.name).join(`
|
|
211
211
|
`);_.current({files:n.files,text:r.trim()===e?``:r})}return}if(n?.hasImage&&vH()&&!b){if(!y()){if(n.imageBlob){let e=n.imageBlob;_.current?.({text:``,files:[new File([e],`clipboard.${e.type.split(`/`)[1]||`png`}`,{type:e.type})]})}else v.current?.(`The browser did not provide image data. Choose the file to upload it.`);return}ae(t,await TH(pe.current,{blob:n.imageBlob}));return}if(n?.hasFiles&&!y()){v.current?.(`The browser did not provide file data. Drop the file onto the terminal or choose it to upload.`);return}if((!r||n?.hasFiles)&&vH()&&!b&&y())try{let e=await fetch(`/api/clipboard-file-path`);if(e.ok){let{path:n,isImage:r}=await e.json();if(n){if(r){ae(t,await TH(pe.current,{path:n}));return}ae(t,eH(n));return}}}catch{}if(r&&!DH(r)){oe.current===t&&se.current===t&&(I.current&&(fe.current({type:`tmux-cancel-copy-mode`,sessionId:t}),Oe(!1)),fe.current({type:`terminal-paste`,sessionId:t,data:r}));return}vH()&&!b&&y()&&ae(t,await TH(pe.current,{}))}finally{ne=null}})(),!!_.current&&ie===`metaKey`}if(e.ctrlKey&&e.key===`Backspace`&&e.type===`keydown`){let e=se.current;return e&&fe.current({type:`terminal-input`,sessionId:e,data:``}),!1}return!0});let ce=e=>{if(!ne){let t=iH(e.clipboardData),n=e.clipboardData?.getData(`text/plain`)??``;if(!t.length&&!n||!_.current)return;if(e.preventDefault(),e.stopPropagation(),se.current&&se.current===oe.current){let e=t.map(e=>e.name).join(`
|
|
212
|
-
`);_.current({text:t.length&&n.trim()===e?``:n,files:t})}return}e.preventDefault(),e.stopPropagation();let t=e.clipboardData?.getData(`text/plain`)??``,n=kH(e.clipboardData),r=n!==null||OH(e.clipboardData),i=ne;ne=null,i({text:t,hasImage:r,hasFiles:(e.clipboardData?.files?.length??0)>0||Array.from(e.clipboardData?.items??[]).some(e=>e.kind===`file`)||Array.from(e.clipboardData?.types??[]).includes(`Files`),imageBlob:n,files:iH(e.clipboardData)})};return t.addEventListener(`paste`,ce,{capture:!0}),r.onData(e=>{let t=se.current;if(t){let n=/^\x1b\[(<[\d;]+[Mm]|[\d;]+M|M[\x20-\xff]{3})$/.test(e);if(I.current&&n)return;I.current&&(fe.current({type:`tmux-cancel-copy-mode`,sessionId:t}),Oe(!1)),fe.current({type:`terminal-input`,sessionId:t,data:e})}}),r.attachCustomWheelEventHandler(e=>{let t=se.current;if(!t||e.target?.closest(`input, textarea, [contenteditable="true"], .xterm-hover`)||r.hasSelection()||e.shiftKey)return!0;F.current+=e.deltaY;let n=r.cols,i=r.rows,a=Math.floor(n/2),o=Math.floor(i/2),s=!1,c=!1;for(;Math.abs(F.current)>=30;){c=!0;let e=F.current>0;F.current+=e?-30:30;let n=e?65:64;e||(s=!0),fe.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${n};${a};${o}M`})}return s&&!R.current&&Oe(!0),c&&!R.current&&ke(),!1}),C.current=r,T.current=i,()=>{if(n=!0,ee&&clearTimeout(ee),P=null,t.removeEventListener(`mousedown`,te,!0),t.removeEventListener(`paste`,ce,!0),U!==null&&(clearTimeout(U),U=null),ne=null,O.current&&=(O.current.remove(),null),D.current){try{D.current.dispose()}catch{}D.current=null}if(E.current){try{E.current.dispose()}catch{}E.current=null}try{r.dispose()}catch{}t&&(t.innerHTML=``),C.current=null,T.current=null,k.current=null,A.current=null,j.current=null,N.current&&window.clearTimeout(N.current),B.current!==null&&window.clearTimeout(B.current)}},[Ae]),(0,x.useEffect)(()=>{C.current&&(C.current.options.theme=c)},[c]),(0,x.useEffect)(()=>{let e=C.current,t=T.current;if(e&&t){e.options.fontFamily=f,e.options.fontSize=l,e.options.lineHeight=Math.round(l*u)/l,e.options.letterSpacing=d,t.fit();let n=oe.current;n&&fe.current({type:`terminal-resize`,sessionId:n,cols:e.cols,rows:e.rows})}},[l,u,d,f]),(0,x.useEffect)(()=>{let e=C.current;if(!e)return;let t=he.current;if(he.current=p,t!==p){if(p){if(!E.current)try{let t=new pz;t.onContextLoss(()=>{try{t.dispose()}catch{}E.current=null}),e.loadAddon(t),E.current=t}catch{}}else if(E.current){try{E.current.dispose()}catch{}E.current=null}}},[p]),(0,x.useLayoutEffect)(()=>{(se.current!==e||!r||i!==`connected`||le.current>=0&&le.current!==a)&&(se.current=null,e&&r&&i===`connected`&&xe(!0))},[e,r,i,a]),(0,x.useEffect)(()=>{let n=C.current;if(!n)return;let o=oe.current,s=ce.current;if(!r){se.current=null,P.current!==null&&(window.clearTimeout(P.current),P.current=null),o&&(fe.current({type:`terminal-detach`,sessionId:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)),n.reset(),ye.current=!1,xe(!1);return}if(i!==`connected`){se.current=null,P.current!==null&&(window.clearTimeout(P.current),P.current=null),o&&(J(`terminal_detach_on_disconnect`,{connectionStatus:i,prevAttached:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)),fH(),ye.current=!1,xe(!1);return}if(o&&o!==e){se.current=null;try{let e=A.current?.serialize();if(e&&(lH.set(o,e),lH.size>uH)){let e=lH.keys().next().value;e&&lH.delete(e)}}catch{}fe.current({type:`terminal-detach`,sessionId:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)}let c=le.current,l=a!==c;if(e&&(e!==o||t!==s||l)){J(`terminal_attach`,{sessionId:e,tmuxTarget:t,prevAttached:o,prevTarget:s,connectionStatus:i,connectionEpoch:a,attachedEpoch:c});let r=performance.now();ge.current=[],_e.current!==null&&(window.clearTimeout(_e.current),_e.current=null),ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null),ye.current=!0,xe(!0),o!==null&&(se.current=null);let l=lH.get(e);l&&(n.reset(),n.write(l));let u=T.current;u&&u.fit();let d=performance.now();oe.current=e,ce.current=t??null,le.current=a,ue.current=e,de.current=r,P.current!==null&&(window.clearTimeout(P.current),P.current=null);let f={type:`terminal-attach`,sessionId:e,tmuxTarget:t??void 0,cols:n.cols,rows:n.rows},p=o!==null&&o!==e;if(p){let t=e;queueMicrotask(()=>{oe.current===t&&(fe.current(f),fe.current({type:`tmux-check-copy-mode`,sessionId:e}))})}else P.current=window.setTimeout(()=>{P.current=null,fe.current(f),fe.current({type:`tmux-check-copy-mode`,sessionId:e})},50);J(`switch_attach_sent`,{sessionId:e,fitMs:Math.round(d-r),totalMs:Math.round(performance.now()-r),from:o??null,immediate:p})}return e&&e===o&&t===s&&!l&&J(`terminal_attach_skip`,{sessionId:e,prevAttached:o,connectionStatus:i,connectionEpoch:a,attachedEpoch:c}),!e&&o&&(P.current!==null&&(window.clearTimeout(P.current),P.current=null),oe.current=null,ce.current=null,le.current=-1,ue.current=null,se.current=null),()=>{P.current!==null&&(J(`attach_debounce_cancelled`,{sessionId:e,attachedSession:oe.current},`info`),window.clearTimeout(P.current),P.current=null)}},[e,t,r,i,a,De,Oe]),(0,x.useEffect)(()=>{if(ae.current!==null&&(globalThis.clearInterval(ae.current),ae.current=null),!(!e||!r||i!==`connected`))return ae.current=globalThis.setInterval(()=>{oe.current===e&&fe.current({type:`tmux-check-copy-mode`,sessionId:e})},750),()=>{ae.current!==null&&(globalThis.clearInterval(ae.current),ae.current=null)}},[e,r,i]),(0,x.useEffect)(()=>{let e=()=>{_e.current!==null&&(window.clearTimeout(_e.current),_e.current=null),ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null);let e=C.current,t=ge.current;if(!e||t.length===0)return;ge.current=[];let n=t.join(``);ye.current&&=(e.reset(),!1);let r=performance.now(),i=n.length;e.write(n,()=>{let e=Math.round(performance.now()-r);e>50&&J(`switch_write_slow`,{sessionId:oe.current,writeMs:e,bytes:i}),b&&e>50&&J(`ios_write_slow`,{sessionId:oe.current,writeMs:e,bytes:i}),De()})},t=()=>{_e.current!==null&&window.clearTimeout(_e.current),_e.current=window.setTimeout(e,2),ve.current===null&&(ve.current=window.setTimeout(e,16))},n=s(n=>{let r=oe.current;if(n.type===`terminal-output`&&(!r||n.sessionId!==r)&&J(`terminal_output_dropped`,{messageSessionId:n.sessionId,attachedSession:r,bytes:n.data.length,hasSwitchStart:de.current!==null},`info`),n.type===`terminal-output`&&r&&n.sessionId===r){let e=de.current;e&&(J(`switch_first_output`,{sessionId:n.sessionId,serverRoundtripMs:Math.round(performance.now()-e),bytes:n.data.length,parseMs:n._parseMs??-1,rawLength:n._rawLength??-1}),de.current=null),ge.current.push(b?PH(n.data):n.data),t()}if(n.type===`terminal-ready`&&r&&n.sessionId===r){se.current=n.sessionId,ye.current&&ge.current.length>0?e():ye.current&&=(C.current?.reset(),!1),xe(!1);let t=de.current;t&&(J(`switch_ready`,{sessionId:n.sessionId,totalMs:Math.round(performance.now()-t)}),de.current=null),ue.current===n.sessionId&&(C.current?.focus(),ue.current=null),b&&(e(),Ee(50,`terminal-ready`))}if(n.type===`terminal-error`&&r&&(!n.sessionId||n.sessionId===r)&&(se.current=null,ye.current=!1,xe(!1)),n.type===`clipboard-offer`&&r&&n.sessionId===r){let e=n.text;if(!e?.trim())return;if(!b&&navigator.clipboard?.writeText){let t=performance.now();navigator.clipboard.writeText(e).then(()=>{J(`clipboard_write_success`,{source:n.source,chars:e.length,durationMs:Math.round(performance.now()-t)})}).catch(t=>{J(`clipboard_write_failed`,{source:n.source,chars:e.length,error:t instanceof Error?t.message:String(t)},`warn`),re(e,n.source)})}else re(e,n.source)}if(n.type===`tmux-copy-mode-status`&&r&&n.sessionId===r){let e=n.appMouse===!0&&!n.inCopyMode,t=R.current;R.current=e,z.current=n.altScreen===!0,!t&&e&&C.current?.write(xH),Oe(n.inCopyMode)}});return()=>{n(),e(),Te()}},[s,De,Oe,re]),(0,x.useEffect)(()=>{let e=S.current,t=C.current,n=T.current;if(!e||!t||!n)return;let r=()=>{M.current&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{Ae()},150)},i=new ResizeObserver(r);return i.observe(e),r(),()=>{i.disconnect(),M.current&&window.clearTimeout(M.current)}},[]),(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=()=>{document.visibilityState!==`hidden`&&J(`terminal_visibility_resume`,{isiOS:b,hasWebGL:!!E.current,useWebGL:he.current,hasTerminal:!!C.current,bufferLines:C.current?.buffer.active.length??0,sessionId:oe.current},`info`)};if(document.addEventListener(`visibilitychange`,e),!b)return()=>{document.removeEventListener(`visibilitychange`,e)};let t=e=>{let t=C.current;if(t&&E.current&&he.current){try{E.current.dispose()}catch{}E.current=null;try{let n=new pz;n.onContextLoss(()=>{J(`webgl_context_loss`,{sessionId:oe.current},`info`);try{n.dispose()}catch{}E.current=null}),t.loadAddon(n),E.current=n,J(`ios_webgl_recreated`,{trigger:e},`info`)}catch{J(`ios_webgl_recreate_failed`,{trigger:e},`info`)}}},n=()=>{document.visibilityState!==`hidden`&&(t(`visibilitychange`),Ee(200,`visibilitychange`))},r=e=>{e.persisted&&(t(`pageshow`),Ee(200,`pageshow`))},i=()=>{t(`focus`),Ee(200,`focus`)};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`pageshow`,r),window.addEventListener(`focus`,i),()=>{document.removeEventListener(`visibilitychange`,e),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`pageshow`,r),window.removeEventListener(`focus`,i),Te()}},[]),{containerRef:S,terminalRef:C,searchAddonRef:k,serializeAddonRef:A,progressAddonRef:j,inTmuxCopyModeRef:I,isTmuxCopyMode:L,appMouseRef:R,setTmuxCopyMode:Oe,isSwitching:be,isInputReady:!!e&&r&&i===`connected`&&se.current===e,pendingClipboardOffer:V,copyPendingClipboardOffer:U,dismissPendingClipboardOffer:ie}}function IH(e=`(max-width: 767px)`){let[t,n]=(0,x.useState)(()=>typeof window>`u`||!window.matchMedia?!1:window.matchMedia(e).matches);return(0,x.useEffect)(()=>{if(typeof window>`u`||!window.matchMedia)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),typeof t.addEventListener==`function`?(t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)):(t.addListener(r),()=>t.removeListener(r))},[e]),t}function LH(e,t,n){(0,x.useEffect)(()=>{if(!t)return;let r=t=>{e.current&&!e.current.contains(t.target)&&n()};return document.addEventListener(`mousedown`,r),document.addEventListener(`touchstart`,r),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`touchstart`,r)}},[e,t,n])}function RH(e,t){(0,x.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t])}function zH({enabled:e,isOpen:t,onOpen:n,edgeThresholdPx:r=30,swipeDistancePx:i=50,swipeRatio:a=1.5}){let o=(0,x.useRef)(!1);return(0,x.useEffect)(()=>{if(!e)return;let s=0,c=0,l=!1,u=e=>{if(t)return;let n=e.touches[0];n.clientX<=r?(s=n.clientX,c=n.clientY,l=!0,o.current=!0):l=!1},d=e=>{if(o.current=!1,!l||t)return;let r=e.changedTouches[0],u=r.clientX-s,d=Math.abs(r.clientY-c);u>=i&&u>d*a&&n(),l=!1};return document.addEventListener(`touchstart`,u,{passive:!0}),document.addEventListener(`touchend`,d,{passive:!0}),()=>{o.current=!1,document.removeEventListener(`touchstart`,u),document.removeEventListener(`touchend`,d)}},[e,t,n,r,i,a]),o}var BH=T()(k(e=>({theme:`dark`,setTheme:t=>e({theme:t}),toggleTheme:()=>e(e=>({theme:e.theme===`dark`?`light`:`dark`}))}),{name:`agentboard-theme`,storage:D(()=>M)})),VH={dark:{background:`#2d2d2d`,foreground:`#d4d4d4`,cursor:`#3b82f6`,cursorAccent:`#2d2d2d`,selectionBackground:`rgba(59, 130, 246, 0.35)`,selectionForeground:`#ffffff`,black:`#808080`,red:`#f87171`,green:`#4ade80`,yellow:`#fbbf24`,blue:`#60a5fa`,magenta:`#c084fc`,cyan:`#22d3ee`,white:`#d4d4d4`,brightBlack:`#a0a0a0`,brightRed:`#fca5a5`,brightGreen:`#86efac`,brightYellow:`#fde047`,brightBlue:`#93c5fd`,brightMagenta:`#d8b4fe`,brightCyan:`#67e8f9`,brightWhite:`#ffffff`},light:{background:`#fafafa`,foreground:`#171717`,cursor:`#2563eb`,cursorAccent:`#fafafa`,selectionBackground:`rgba(37, 99, 235, 0.2)`,selectionForeground:`#000000`,black:`#171717`,red:`#dc2626`,green:`#16a34a`,yellow:`#ca8a04`,blue:`#2563eb`,magenta:`#9333ea`,cyan:`#0891b2`,white:`#f5f5f5`,brightBlack:`#737373`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#eab308`,brightBlue:`#3b82f6`,brightMagenta:`#a855f7`,brightCyan:`#06b6d4`,brightWhite:`#ffffff`}},HH=new WeakSet;function UH(e,t){let n=Object.getOwnPropertyDescriptor(e,t);return!n?.get||!n.set?null:{get:n.get,set:n.set,enumerable:n.enumerable??!0,configurable:n.configurable??!0}}var WH=!1,GH=null,KH=null;function qH(){WH||(WH=!0,!(typeof Node>`u`||typeof HTMLElement>`u`)&&(GH=UH(Node.prototype,`textContent`),KH=UH(HTMLElement.prototype,`innerText`)))}function JH(e){if(HH.has(e))return;HH.add(e);let t=GH?.get;if(t)for(let[n,r]of[[`textContent`,GH],[`innerText`,KH]])r&&Object.defineProperty(e,n,{configurable:r.configurable,enumerable:r.enumerable,get(){return r.get.call(this)},set(e){t.call(this)!==e&&r.set.call(this,e)}})}function YH(e){qH();let t=()=>{for(let t of Array.from(e.children))t instanceof HTMLElement&&JH(t)};t();let n=new MutationObserver(t);return n.observe(e,{childList:!0}),()=>n.disconnect()}var XH={up:`\x1B[A`,down:`\x1B[B`,left:`\x1B[D`,right:`\x1B[C`},ZH=44,QH=6,$H=8,eU=10,tU=8,nU=700;3*ZH+2*QH+2*$H,2*ZH+QH+2*$H;var rU={up:`↑`,down:`↓`,left:`←`,right:`→`},iU={up:`1 / 2 / 2 / 3`,left:`2 / 1 / 3 / 2`,down:`2 / 2 / 3 / 3`,right:`2 / 3 / 3 / 4`};function aU(e=10){typeof navigator<`u`&&`vibrate`in navigator&&navigator.vibrate(e)}function oU(e,t){let n=e.left-t.left+e.width/2,r=tU+160/2,i=t.width-tU-160/2;return r>i?t.width/2:Math.max(r,Math.min(i,n))}function sU({onSendKey:e,disabled:t=!1,onRefocus:n,isKeyboardVisible:r,sessionKey:i=null}){let[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(0),[l,u]=(0,x.useState)(null),d=(0,x.useId)(),f=(0,x.useRef)(null),p=(0,x.useRef)(!1),m=(0,x.useRef)(null),h=(0,x.useRef)(null),g=(0,x.useRef)(null),_=(0,x.useRef)(null),v=(0,x.useRef)(0),y=(0,x.useRef)(e),b=(0,x.useRef)(t);y.current=e,b.current=t;let S=(0,x.useCallback)(()=>{m.current&&=(clearTimeout(m.current),null),h.current&&=(clearInterval(h.current),null),g.current=null,_.current=null},[]),C=(0,x.useCallback)(()=>{S(),u(null)},[S]),w=(0,x.useCallback)(()=>{C(),o(!1),p.current&&n?.()},[C,n]),T=(0,x.useCallback)(()=>{let e=f.current,t=e?.getBoundingClientRect?.(),n=e?.closest?.(`.terminal-controls`)?.getBoundingClientRect?.();if(!t||!n){c(160/2+tU);return}c(oU(t,n))},[]),E=(0,x.useCallback)(()=>{p.current=r?.()??!1,T(),o(!0)},[r,T]),D=(0,x.useCallback)(()=>{t||(aU(),a?w():E())},[t,a,w,E]),O=(0,x.useCallback)(e=>{e.preventDefault(),v.current=Date.now(),D()},[D]),k=(0,x.useCallback)(()=>Date.now()-v.current<nU,[]),A=(0,x.useCallback)(e=>{k()||D()},[k,D]),j=(0,x.useCallback)(e=>{b.current||y.current(XH[e])},[]),M=(0,x.useCallback)(e=>{S(),g.current=e,u(e),aU(8),j(e),m.current=setTimeout(()=>{h.current=setInterval(()=>{g.current===e&&(aU(5),j(e))},100)},400)},[S,j]),N=(0,x.useCallback)(e=>n=>{t||(n.preventDefault(),_.current===null&&(n.currentTarget.setPointerCapture?.(n.pointerId),v.current=Date.now(),M(e),_.current=n.pointerId))},[t,M]),P=(0,x.useCallback)(e=>{e.preventDefault(),!(_.current!==null&&e.pointerId!==_.current)&&C()},[C]),F=(0,x.useCallback)(e=>n=>{t||k()||(aU(8),j(e))},[t,k,j]),I=(0,x.useCallback)(e=>{e.preventDefault(),w()},[w]);(0,x.useEffect)(()=>{t&&a&&w()},[t,a,w]);let L=(0,x.useRef)(i);return(0,x.useEffect)(()=>{L.current!==i&&(L.current=i,C())},[i,C]),(0,x.useEffect)(()=>{if(!a)return;let e=f.current?.parentElement;if(e?.addEventListener)return e.addEventListener(`scroll`,T,{passive:!0}),()=>e.removeEventListener(`scroll`,T)},[a,T]),(0,x.useEffect)(()=>S,[S]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{ref:f,type:`button`,"aria-label":`Arrow keys`,"aria-haspopup":`true`,"aria-expanded":a,"aria-controls":a?d:void 0,className:`
|
|
212
|
+
`);_.current({text:t.length&&n.trim()===e?``:n,files:t})}return}e.preventDefault(),e.stopPropagation();let t=e.clipboardData?.getData(`text/plain`)??``,n=kH(e.clipboardData),r=n!==null||OH(e.clipboardData),i=ne;ne=null,i({text:t,hasImage:r,hasFiles:(e.clipboardData?.files?.length??0)>0||Array.from(e.clipboardData?.items??[]).some(e=>e.kind===`file`)||Array.from(e.clipboardData?.types??[]).includes(`Files`),imageBlob:n,files:iH(e.clipboardData)})};return t.addEventListener(`paste`,ce,{capture:!0}),r.onData(e=>{let t=se.current;if(t){let n=/^\x1b\[(<[\d;]+[Mm]|[\d;]+M|M[\x20-\xff]{3})$/.test(e);if(I.current&&n)return;I.current&&(fe.current({type:`tmux-cancel-copy-mode`,sessionId:t}),Oe(!1)),fe.current({type:`terminal-input`,sessionId:t,data:e})}}),r.attachCustomWheelEventHandler(e=>{let t=se.current;if(!t||e.target?.closest(`input, textarea, [contenteditable="true"], .xterm-hover`)||r.hasSelection()||e.shiftKey)return!0;F.current+=e.deltaY;let n=r.cols,i=r.rows,a=Math.floor(n/2),o=Math.floor(i/2),s=!1,c=!1;for(;Math.abs(F.current)>=30;){c=!0;let e=F.current>0;F.current+=e?-30:30;let n=e?65:64;e||(s=!0),fe.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${n};${a};${o}M`})}return s&&!R.current&&Oe(!0),c&&!R.current&&ke(),!1}),C.current=r,T.current=i,()=>{if(n=!0,ee&&clearTimeout(ee),P=null,t.removeEventListener(`mousedown`,te,!0),t.removeEventListener(`paste`,ce,!0),U!==null&&(clearTimeout(U),U=null),ne=null,O.current&&=(O.current.remove(),null),D.current){try{D.current.dispose()}catch{}D.current=null}if(E.current){try{E.current.dispose()}catch{}E.current=null}try{r.dispose()}catch{}t&&(t.innerHTML=``),C.current=null,T.current=null,k.current=null,A.current=null,j.current=null,N.current&&window.clearTimeout(N.current),B.current!==null&&window.clearTimeout(B.current)}},[Ae]),(0,x.useEffect)(()=>{C.current&&(C.current.options.theme=c)},[c]),(0,x.useEffect)(()=>{let e=C.current,t=T.current;if(e&&t){e.options.fontFamily=f,e.options.fontSize=l,e.options.lineHeight=Math.round(l*u)/l,e.options.letterSpacing=d,t.fit();let n=oe.current;n&&fe.current({type:`terminal-resize`,sessionId:n,cols:e.cols,rows:e.rows})}},[l,u,d,f]),(0,x.useEffect)(()=>{let e=C.current;if(!e)return;let t=he.current;if(he.current=p,t!==p){if(p){if(!E.current)try{let t=new pz;t.onContextLoss(()=>{try{t.dispose()}catch{}E.current=null}),e.loadAddon(t),E.current=t}catch{}}else if(E.current){try{E.current.dispose()}catch{}E.current=null}}},[p]),(0,x.useLayoutEffect)(()=>{(se.current!==e||!r||i!==`connected`||le.current>=0&&le.current!==a)&&(se.current=null,e&&r&&i===`connected`&&xe(!0))},[e,r,i,a]),(0,x.useEffect)(()=>{let n=C.current;if(!n)return;let o=oe.current,s=ce.current;if(!r){se.current=null,P.current!==null&&(window.clearTimeout(P.current),P.current=null),o&&(fe.current({type:`terminal-detach`,sessionId:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)),n.reset(),ye.current=!1,xe(!1);return}if(i!==`connected`){se.current=null,P.current!==null&&(window.clearTimeout(P.current),P.current=null),o&&(J(`terminal_detach_on_disconnect`,{connectionStatus:i,prevAttached:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)),fH(),ye.current=!1,xe(!1);return}if(o&&o!==e){se.current=null;try{let e=A.current?.serialize();if(e&&(lH.set(o,e),lH.size>uH)){let e=lH.keys().next().value;e&&lH.delete(e)}}catch{}fe.current({type:`terminal-detach`,sessionId:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)}let c=le.current,l=a!==c;if(e&&(e!==o||t!==s||l)){J(`terminal_attach`,{sessionId:e,tmuxTarget:t,prevAttached:o,prevTarget:s,connectionStatus:i,connectionEpoch:a,attachedEpoch:c});let r=performance.now();ge.current=[],_e.current!==null&&(window.clearTimeout(_e.current),_e.current=null),ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null),ye.current=!0,xe(!0),o!==null&&(se.current=null);let l=lH.get(e);l&&(n.reset(),n.write(l));let u=T.current;u&&u.fit();let d=performance.now();oe.current=e,ce.current=t??null,le.current=a,ue.current=e,de.current=r,P.current!==null&&(window.clearTimeout(P.current),P.current=null);let f={type:`terminal-attach`,sessionId:e,tmuxTarget:t??void 0,cols:n.cols,rows:n.rows},p=o!==null&&o!==e;if(p){let t=e;queueMicrotask(()=>{oe.current===t&&(fe.current(f),fe.current({type:`tmux-check-copy-mode`,sessionId:e}))})}else P.current=window.setTimeout(()=>{P.current=null,fe.current(f),fe.current({type:`tmux-check-copy-mode`,sessionId:e})},50);J(`switch_attach_sent`,{sessionId:e,fitMs:Math.round(d-r),totalMs:Math.round(performance.now()-r),from:o??null,immediate:p})}return e&&e===o&&t===s&&!l&&J(`terminal_attach_skip`,{sessionId:e,prevAttached:o,connectionStatus:i,connectionEpoch:a,attachedEpoch:c}),!e&&o&&(P.current!==null&&(window.clearTimeout(P.current),P.current=null),oe.current=null,ce.current=null,le.current=-1,ue.current=null,se.current=null),()=>{P.current!==null&&(J(`attach_debounce_cancelled`,{sessionId:e,attachedSession:oe.current},`info`),window.clearTimeout(P.current),P.current=null)}},[e,t,r,i,a,De,Oe]),(0,x.useEffect)(()=>{if(ae.current!==null&&(globalThis.clearInterval(ae.current),ae.current=null),!(!e||!r||i!==`connected`))return ae.current=globalThis.setInterval(()=>{oe.current===e&&fe.current({type:`tmux-check-copy-mode`,sessionId:e})},750),()=>{ae.current!==null&&(globalThis.clearInterval(ae.current),ae.current=null)}},[e,r,i]),(0,x.useEffect)(()=>{let e=()=>{_e.current!==null&&(window.clearTimeout(_e.current),_e.current=null),ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null);let e=C.current,t=ge.current;if(!e||t.length===0)return;ge.current=[];let n=t.join(``);ye.current&&=(e.reset(),!1);let r=performance.now(),i=n.length;e.write(n,()=>{let e=Math.round(performance.now()-r);e>50&&J(`switch_write_slow`,{sessionId:oe.current,writeMs:e,bytes:i}),b&&e>50&&J(`ios_write_slow`,{sessionId:oe.current,writeMs:e,bytes:i}),De()})},t=()=>{_e.current!==null&&window.clearTimeout(_e.current),_e.current=window.setTimeout(e,2),ve.current===null&&(ve.current=window.setTimeout(e,16))},n=s(n=>{let r=oe.current;if(n.type===`terminal-output`&&(!r||n.sessionId!==r)&&J(`terminal_output_dropped`,{messageSessionId:n.sessionId,attachedSession:r,bytes:n.data.length,hasSwitchStart:de.current!==null},`info`),n.type===`terminal-output`&&r&&n.sessionId===r){let e=de.current;e&&(J(`switch_first_output`,{sessionId:n.sessionId,serverRoundtripMs:Math.round(performance.now()-e),bytes:n.data.length,parseMs:n._parseMs??-1,rawLength:n._rawLength??-1}),de.current=null),ge.current.push(b?PH(n.data):n.data),t()}if(n.type===`terminal-ready`&&r&&n.sessionId===r){se.current=n.sessionId,ye.current&&ge.current.length>0?e():ye.current&&=(C.current?.reset(),!1),xe(!1);let t=de.current;t&&(J(`switch_ready`,{sessionId:n.sessionId,totalMs:Math.round(performance.now()-t)}),de.current=null),ue.current===n.sessionId&&(C.current?.focus(),ue.current=null),b&&(e(),Ee(50,`terminal-ready`))}if(n.type===`terminal-error`&&r&&(!n.sessionId||n.sessionId===r)&&(se.current=null,ye.current=!1,xe(!1)),n.type===`clipboard-offer`&&r&&n.sessionId===r){let e=n.text;if(!e?.trim())return;if(!b&&navigator.clipboard?.writeText){let t=performance.now();navigator.clipboard.writeText(e).then(()=>{J(`clipboard_write_success`,{source:n.source,chars:e.length,durationMs:Math.round(performance.now()-t)})}).catch(t=>{J(`clipboard_write_failed`,{source:n.source,chars:e.length,error:t instanceof Error?t.message:String(t)},`warn`),re(e,n.source)})}else re(e,n.source)}if(n.type===`tmux-copy-mode-status`&&r&&n.sessionId===r){let e=n.appMouse===!0&&!n.inCopyMode,t=R.current;R.current=e,z.current=n.altScreen===!0,!t&&e&&C.current?.write(xH),Oe(n.inCopyMode)}});return()=>{n(),e(),Te()}},[s,De,Oe,re]),(0,x.useEffect)(()=>{let e=S.current,t=C.current,n=T.current;if(!e||!t||!n)return;let r=()=>{M.current&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{Ae()},150)},i=new ResizeObserver(r);return i.observe(e),r(),()=>{i.disconnect(),M.current&&window.clearTimeout(M.current)}},[]),(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=()=>{document.visibilityState!==`hidden`&&J(`terminal_visibility_resume`,{isiOS:b,hasWebGL:!!E.current,useWebGL:he.current,hasTerminal:!!C.current,bufferLines:C.current?.buffer.active.length??0,sessionId:oe.current},`info`)};if(document.addEventListener(`visibilitychange`,e),!b)return()=>{document.removeEventListener(`visibilitychange`,e)};let t=e=>{let t=C.current;if(t&&E.current&&he.current){try{E.current.dispose()}catch{}E.current=null;try{let n=new pz;n.onContextLoss(()=>{J(`webgl_context_loss`,{sessionId:oe.current},`info`);try{n.dispose()}catch{}E.current=null}),t.loadAddon(n),E.current=n,J(`ios_webgl_recreated`,{trigger:e},`info`)}catch{J(`ios_webgl_recreate_failed`,{trigger:e},`info`)}}},n=()=>{document.visibilityState!==`hidden`&&(t(`visibilitychange`),Ee(200,`visibilitychange`))},r=e=>{e.persisted&&(t(`pageshow`),Ee(200,`pageshow`))},i=()=>{t(`focus`),Ee(200,`focus`)};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`pageshow`,r),window.addEventListener(`focus`,i),()=>{document.removeEventListener(`visibilitychange`,e),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`pageshow`,r),window.removeEventListener(`focus`,i),Te()}},[]),{containerRef:S,terminalRef:C,searchAddonRef:k,serializeAddonRef:A,progressAddonRef:j,inTmuxCopyModeRef:I,isTmuxCopyMode:L,appMouseRef:R,setTmuxCopyMode:Oe,isSwitching:be,isInputReady:!!e&&r&&i===`connected`&&se.current===e,pendingClipboardOffer:V,copyPendingClipboardOffer:U,dismissPendingClipboardOffer:ie}}function IH(e=`(max-width: 767px)`){let[t,n]=(0,x.useState)(()=>typeof window>`u`||!window.matchMedia?!1:window.matchMedia(e).matches);return(0,x.useEffect)(()=>{if(typeof window>`u`||!window.matchMedia)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),typeof t.addEventListener==`function`?(t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)):(t.addListener(r),()=>t.removeListener(r))},[e]),t}function LH(e,t,n){(0,x.useEffect)(()=>{if(!t)return;let r=t=>{e.current&&!e.current.contains(t.target)&&n()};return document.addEventListener(`mousedown`,r),document.addEventListener(`touchstart`,r),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`touchstart`,r)}},[e,t,n])}function RH(e,t){(0,x.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t])}function zH({enabled:e,isOpen:t,onOpen:n,edgeThresholdPx:r=30,swipeDistancePx:i=50,swipeRatio:a=1.5}){let o=(0,x.useRef)(!1);return(0,x.useEffect)(()=>{if(!e)return;let s=0,c=0,l=!1,u=e=>{if(t)return;let n=e.touches[0];n.clientX<=r?(s=n.clientX,c=n.clientY,l=!0,o.current=!0):l=!1},d=e=>{if(o.current=!1,!l||t)return;let r=e.changedTouches[0],u=r.clientX-s,d=Math.abs(r.clientY-c);u>=i&&u>d*a&&n(),l=!1};return document.addEventListener(`touchstart`,u,{passive:!0}),document.addEventListener(`touchend`,d,{passive:!0}),()=>{o.current=!1,document.removeEventListener(`touchstart`,u),document.removeEventListener(`touchend`,d)}},[e,t,n,r,i,a]),o}var BH=T()(k(e=>({theme:`dark`,setTheme:t=>e({theme:t}),toggleTheme:()=>e(e=>({theme:e.theme===`dark`?`light`:`dark`}))}),{name:`agentboard-theme`,storage:D(()=>M)})),VH={dark:{background:`#2d2d2d`,foreground:`#d4d4d4`,cursor:`#3b82f6`,cursorAccent:`#2d2d2d`,selectionBackground:`rgba(59, 130, 246, 0.35)`,selectionForeground:`#ffffff`,black:`#808080`,red:`#f87171`,green:`#4ade80`,yellow:`#fbbf24`,blue:`#60a5fa`,magenta:`#c084fc`,cyan:`#22d3ee`,white:`#d4d4d4`,brightBlack:`#a0a0a0`,brightRed:`#fca5a5`,brightGreen:`#86efac`,brightYellow:`#fde047`,brightBlue:`#93c5fd`,brightMagenta:`#d8b4fe`,brightCyan:`#67e8f9`,brightWhite:`#ffffff`},light:{background:`#fafafa`,foreground:`#171717`,cursor:`#2563eb`,cursorAccent:`#fafafa`,selectionBackground:`rgba(37, 99, 235, 0.2)`,selectionForeground:`#000000`,black:`#171717`,red:`#dc2626`,green:`#16a34a`,yellow:`#ca8a04`,blue:`#2563eb`,magenta:`#9333ea`,cyan:`#0891b2`,white:`#f5f5f5`,brightBlack:`#737373`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#eab308`,brightBlue:`#3b82f6`,brightMagenta:`#a855f7`,brightCyan:`#06b6d4`,brightWhite:`#ffffff`}},HH=new WeakSet;function UH(e,t){let n=Object.getOwnPropertyDescriptor(e,t);return!n?.get||!n.set?null:{get:n.get,set:n.set,enumerable:n.enumerable??!0,configurable:n.configurable??!0}}var WH=!1,GH=null,KH=null;function qH(){WH||(WH=!0,!(typeof Node>`u`||typeof HTMLElement>`u`)&&(GH=UH(Node.prototype,`textContent`),KH=UH(HTMLElement.prototype,`innerText`)))}function JH(e){if(HH.has(e))return;HH.add(e);let t=GH?.get;if(t)for(let[n,r]of[[`textContent`,GH],[`innerText`,KH]])r&&Object.defineProperty(e,n,{configurable:r.configurable,enumerable:r.enumerable,get(){return r.get.call(this)},set(e){t.call(this)!==e&&r.set.call(this,e)}})}function YH(e){qH();let t=()=>{for(let t of Array.from(e.children))t instanceof HTMLElement&&JH(t)};t();let n=new MutationObserver(t);return n.observe(e,{childList:!0}),()=>n.disconnect()}function XH(e,t){let n=(0,x.useRef)(!1);return(0,x.useEffect)(()=>{if(n.current=!1,t||typeof document>`u`)return;let e=document,r=window,i=e=>{e.key===`Shift`&&(n.current=!0)},a=e=>{e.key===`Shift`&&(n.current=!1)},o=()=>{n.current=!1},s=()=>{e.visibilityState===`hidden`&&o()};return e.addEventListener(`keydown`,i,!0),e.addEventListener(`keyup`,a,!0),e.addEventListener(`focusout`,o,!0),e.addEventListener(`visibilitychange`,s),r.addEventListener(`blur`,o),()=>{o(),e.removeEventListener(`keydown`,i,!0),e.removeEventListener(`keyup`,a,!0),e.removeEventListener(`focusout`,o,!0),e.removeEventListener(`visibilitychange`,s),r.removeEventListener(`blur`,o)}},[e,t]),n}var ZH={up:`\x1B[A`,down:`\x1B[B`,left:`\x1B[D`,right:`\x1B[C`},QH={up:`\x1B[1;2A`,down:`\x1B[1;2B`,left:`\x1B[1;2D`,right:`\x1B[1;2C`},$H=44,eU=6,tU=8,nU=10,rU=8,iU=700;3*$H+2*eU+2*tU,2*$H+eU+2*tU;var aU={up:`↑`,down:`↓`,left:`←`,right:`→`},oU={up:`1 / 2 / 2 / 3`,left:`2 / 1 / 3 / 2`,down:`2 / 2 / 3 / 3`,right:`2 / 3 / 3 / 4`};function sU(e=10){typeof navigator<`u`&&`vibrate`in navigator&&navigator.vibrate(e)}function cU(e,t){let n=e.left-t.left+e.width/2,r=rU+160/2,i=t.width-rU-160/2;return r>i?t.width/2:Math.max(r,Math.min(i,n))}function lU({onSendKey:e,disabled:t=!1,onRefocus:n,isKeyboardVisible:r,sessionKey:i=null}){let[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(0),[l,u]=(0,x.useState)(null),d=(0,x.useId)(),f=XH(i,t),p=(0,x.useRef)(null),m=(0,x.useRef)(!1),h=(0,x.useRef)(null),g=(0,x.useRef)(null),_=(0,x.useRef)(null),v=(0,x.useRef)(null),y=(0,x.useRef)(0),b=(0,x.useRef)(e),S=(0,x.useRef)(t);b.current=e,S.current=t;let C=(0,x.useCallback)(()=>{h.current&&=(clearTimeout(h.current),null),g.current&&=(clearInterval(g.current),null),_.current=null,v.current=null},[]),w=(0,x.useCallback)(()=>{C(),u(null)},[C]),T=(0,x.useCallback)(()=>{w(),o(!1),m.current&&n?.()},[w,n]),E=(0,x.useCallback)(()=>{let e=p.current,t=e?.getBoundingClientRect?.(),n=e?.closest?.(`.terminal-controls`)?.getBoundingClientRect?.();if(!t||!n){c(160/2+rU);return}c(cU(t,n))},[]),D=(0,x.useCallback)(()=>{m.current=r?.()??!1,E(),o(!0)},[r,E]),O=(0,x.useCallback)(()=>{t||(sU(),a?T():D())},[t,a,T,D]),k=(0,x.useCallback)(e=>{e.preventDefault(),y.current=Date.now(),O()},[O]),A=(0,x.useCallback)(()=>Date.now()-y.current<iU,[]),j=(0,x.useCallback)(e=>{A()||O()},[A,O]),M=(0,x.useCallback)(e=>{if(S.current)return;let t=f.current?QH:ZH;b.current(t[e])},[f]),N=(0,x.useCallback)(e=>{C(),_.current=e,u(e),sU(8),M(e),h.current=setTimeout(()=>{g.current=setInterval(()=>{_.current===e&&(sU(5),M(e))},100)},400)},[C,M]),P=(0,x.useCallback)(e=>n=>{t||(n.preventDefault(),v.current===null&&(n.currentTarget.setPointerCapture?.(n.pointerId),y.current=Date.now(),N(e),v.current=n.pointerId))},[t,N]),F=(0,x.useCallback)(e=>{e.preventDefault(),!(v.current!==null&&e.pointerId!==v.current)&&w()},[w]),I=(0,x.useCallback)(e=>n=>{t||A()||(sU(8),M(e))},[t,A,M]),L=(0,x.useCallback)(e=>{e.preventDefault(),T()},[T]);(0,x.useEffect)(()=>{t&&a&&T()},[t,a,T]);let ee=(0,x.useRef)(i);return(0,x.useEffect)(()=>{ee.current!==i&&(ee.current=i,w())},[i,w]),(0,x.useEffect)(()=>{if(!a)return;let e=p.current?.parentElement;if(e?.addEventListener)return e.addEventListener(`scroll`,E,{passive:!0}),()=>e.removeEventListener(`scroll`,E)},[a,E]),(0,x.useEffect)(()=>C,[C]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{ref:p,type:`button`,"aria-label":`Arrow keys`,"aria-haspopup":`true`,"aria-expanded":a,"aria-controls":a?d:void 0,className:`
|
|
213
213
|
terminal-key
|
|
214
214
|
flex items-center justify-center
|
|
215
215
|
size-[44px] p-0
|
|
@@ -220,12 +220,12 @@ ${s.join(`
|
|
|
220
220
|
select-none
|
|
221
221
|
${t?`opacity-50`:``}
|
|
222
222
|
${a?`bg-accent/20 text-accent border-accent/40`:`bg-surface border-border text-secondary active:bg-hover`}
|
|
223
|
-
`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onPointerDown:
|
|
223
|
+
`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onPointerDown:k,onClick:j,disabled:t,children:(0,W.jsx)(ke,{width:20,height:20})}),a&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{"data-testid":`arrow-keys-backdrop`,className:`absolute left-0 right-0 z-40`,style:{bottom:`100%`,height:`100vh`,touchAction:`none`},onPointerDown:L}),(0,W.jsx)(`div`,{id:d,role:`group`,"aria-label":`Arrow key cluster`,className:`absolute z-50 select-none rounded-2xl bg-black/40 backdrop-blur-md border-2 border-white/20`,style:{left:s,bottom:`calc(100% + ${nU}px)`,transform:`translateX(-50%)`,padding:tU,touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},children:(0,W.jsx)(`div`,{className:`grid`,style:{gridTemplateColumns:`repeat(3, ${$H}px)`,gridTemplateRows:`repeat(2, ${$H}px)`,gap:eU},children:Object.keys(ZH).map(e=>(0,W.jsx)(`button`,{type:`button`,"aria-label":`Arrow ${e}`,className:`
|
|
224
224
|
flex items-center justify-center
|
|
225
225
|
rounded-lg text-xl font-bold
|
|
226
226
|
select-none transition-all duration-75
|
|
227
227
|
${l===e?`bg-accent text-white scale-110`:`bg-white/90 text-gray-800`}
|
|
228
|
-
`,style:{gridArea:
|
|
228
|
+
`,style:{gridArea:oU[e],touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onMouseDown:e=>e.preventDefault(),onPointerDown:P(e),onPointerUp:F,onPointerCancel:F,onLostPointerCapture:F,onClick:I(e),disabled:t,children:aU[e]},e))})})]})]})}var uU=150,dU=56,fU=48,pU=6,mU=8,hU=2,gU=hU+mU,_U=20+pU+2,vU=3*dU+2*pU+2*gU,yU=3*fU+2*pU+2*gU+_U;function bU(e=10){`vibrate`in navigator&&navigator.vibrate(e)}var xU=[[`7`,`8`,`9`],[`4`,`5`,`6`],[`1`,`2`,`3`]];function SU(e,t,n){let r=n.x-vU/2,i=n.y-yU/2,a=e-r-gU,o=t-i-gU,s=3*dU+2*pU,c=3*fU+2*pU;if(a<0||a>s||o<0||o>c)return null;let l=Math.floor(a/(dU+pU)),u=Math.floor(o/(fU+pU));if(l<0||l>2||u<0||u>2)return null;let d=l*(dU+pU),f=u*(fU+pU);return a>d+dU||o>f+fU?null:xU[u]?.[l]||null}function CU({onSendKey:e,disabled:t=!1,onRefocus:n,isKeyboardVisible:r}){let[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)({x:0,y:0}),u=(0,x.useRef)(null),d=(0,x.useRef)(!1),f=(0,x.useRef)(!1),p=(0,x.useCallback)(()=>{a(!1),s(null),f.current=!1,d.current&&n?.()},[n]),m=(0,x.useCallback)(e=>{if(t)return;e.preventDefault(),e.stopPropagation();let n=e.touches[0];d.current=r?.()??!1,f.current=!1,u.current=setTimeout(()=>{bU(15);let e=n.clientX,t=n.clientY-120;e=Math.max(10+vU/2,Math.min(window.innerWidth-10-vU/2,e)),t=Math.max(10+yU/2,t),l({x:e,y:t}),a(!0)},uU)},[t,r]),h=(0,x.useCallback)((e,t)=>SU(e,t,c),[c]),g=(0,x.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!i)return;let t=e.touches[0],n=h(t.clientX,t.clientY);n!==o&&(s(n),n&&bU(5))},[i,o,h]),_=(0,x.useCallback)(t=>{t.preventDefault(),t.stopPropagation(),u.current&&=(clearTimeout(u.current),null),i&&o&&!f.current&&(bU(10),e(o),f.current=!0),p()},[i,o,e,p]),v=(0,x.useCallback)(e=>{e.preventDefault(),u.current&&=(clearTimeout(u.current),null),p()},[p]);return(0,x.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{type:`button`,className:`
|
|
229
229
|
terminal-key
|
|
230
230
|
flex items-center justify-center
|
|
231
231
|
size-[44px] p-0
|
|
@@ -237,15 +237,16 @@ ${s.join(`
|
|
|
237
237
|
text-secondary
|
|
238
238
|
${t?`opacity-50`:``}
|
|
239
239
|
${i?`bg-hover scale-95`:``}
|
|
240
|
-
`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onTouchStart:m,onTouchMove:g,onTouchEnd:_,onTouchCancel:v,disabled:t,children:`123`}),i&&(0,W.jsxs)(`div`,{className:`fixed inset-0 z-50 select-none`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`},onTouchMove:g,onTouchEnd:_,onTouchCancel:v,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 bg-black/20`}),(0,W.jsx)(`div`,{className:`absolute select-none`,style:{left:c.x-
|
|
240
|
+
`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onTouchStart:m,onTouchMove:g,onTouchEnd:_,onTouchCancel:v,disabled:t,children:`123`}),i&&(0,W.jsxs)(`div`,{className:`fixed inset-0 z-50 select-none`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`},onTouchMove:g,onTouchEnd:_,onTouchCancel:v,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 bg-black/20`}),(0,W.jsx)(`div`,{className:`absolute select-none`,style:{left:c.x-vU/2,top:c.y-yU/2,width:vU,WebkitUserSelect:`none`,userSelect:`none`},children:(0,W.jsxs)(`div`,{className:`rounded-2xl bg-black/40 backdrop-blur-md border-white/20 select-none`,style:{padding:mU,borderWidth:hU},children:[(0,W.jsx)(`div`,{className:`grid grid-cols-3 select-none`,style:{gap:pU},children:xU.flat().map((e,t)=>e?(0,W.jsx)(`div`,{className:`
|
|
241
241
|
flex items-center justify-center
|
|
242
242
|
rounded-lg text-xl font-bold
|
|
243
243
|
select-none
|
|
244
244
|
transition-all duration-75
|
|
245
245
|
${o===e?`bg-accent text-white scale-110`:`bg-white/90 text-gray-800`}
|
|
246
|
-
`,style:{width:
|
|
247
|
-
`)&&a(e=>e+n)}}),n&&(0,W.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Attach files`,(0,W.jsx)(`input`,{type:`file`,multiple:!0,"aria-label":`Choose files`,className:`mt-2 block w-full text-sm`,onChange:e=>{let t=Array.from(e.target.files??[]);s(e=>[...e,...t]),e.target.value=``}})]}),o.length>0&&(0,W.jsx)(`ul`,{className:`mt-2 text-sm`,children:o.map((e,t)=>(0,W.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,W.jsx)(`button`,{type:`button`,className:`min-h-[44px] px-2`,"aria-label":`Remove ${e.name}`,onClick:()=>s(e=>e.filter((e,n)=>n!==t)),children:`Remove`})]},t))}),(0,W.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`min-h-[44px] px-3 text-secondary`,onClick:e,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,disabled:!i&&o.length===0,className:`min-h-[44px] rounded bg-accent px-3 text-white disabled:opacity-50`,children:`Submit`})]})]})});return typeof document>`u`?c:(0,U.createPortal)(c,document.body)}function
|
|
248
|
-
`);l&&r.current.onPasteText(l+(a.length?` `:``));for(let{path:e}of c)r.current.onPasteImage(tH(e,r.current.agentType)+` `);s.current=null,n({status:`idle`}),r.current.onRefocus?.()}catch(e){u()&&!i.signal.aborted&&n({status:`error`,message:e instanceof Error?e.message:`Upload failed. Try again.`})}finally{o.current===i&&(o.current=null)}}),a.current):Promise.resolve()},[]);return{state:t,paste:l,pasteClipboard:()=>l(cH(),!0),openDialog:()=>{r.current.disabled||(c(),n({status:`awaiting-paste`}))},retry:()=>s.current?l(s.current):Promise.resolve(),cancel:c,fail:e=>{c(),n({status:`error`,message:e})}}}var
|
|
246
|
+
`,style:{width:dU,height:fU,WebkitUserSelect:`none`,userSelect:`none`},children:e},t):(0,W.jsx)(`div`,{style:{width:dU,height:fU}},t))}),(0,W.jsx)(`div`,{className:`text-center text-white text-sm font-medium select-none`,style:{marginTop:pU+2,height:20},children:o?`Release to send "${o}"`:`\xA0`})]})})]})]})}function wU({state:e,cancel:t,retry:n,paste:r,allowFiles:i}){return e.status===`idle`?null:e.status===`awaiting-paste`?(0,W.jsx)(TU,{cancel:t,paste:r,allowFiles:i}):(0,W.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-border bg-elevated px-3 py-2 text-sm text-primary`,children:[(0,W.jsx)(`span`,{role:e.status===`error`?`alert`:`status`,children:e.status===`error`?e.message:e.status===`reading`?`Reading clipboard…`:`Uploading files…`}),e.status===`error`&&(0,W.jsx)(`button`,{type:`button`,className:`min-h-[44px] px-2`,onClick:n,children:`Retry`}),(0,W.jsx)(`button`,{type:`button`,className:`min-h-[44px] px-2 text-secondary`,onClick:t,children:e.status===`error`?`Dismiss`:`Cancel`})]})}function TU({cancel:e,paste:t,allowFiles:n}){let r=(0,x.useRef)(null),[i,a]=(0,x.useState)(``),[o,s]=(0,x.useState)([]);(0,x.useLayoutEffect)(()=>{r.current?.showModal()},[]);let c=(0,W.jsx)(`dialog`,{ref:r,"aria-label":`Paste from this device`,onCancel:e,style:{top:`calc(var(--viewport-offset-top, 0px) + 1rem)`,bottom:`auto`,maxHeight:`calc(var(--visual-viewport-height, 100dvh) - 2rem)`},className:`mx-auto my-0 w-[calc(100%_-_2rem)] max-w-sm overflow-y-auto rounded-lg border border-border bg-elevated p-4 text-primary backdrop:bg-black/50`,children:(0,W.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),(i||o.length)&&(e(),t({text:i,files:o}))},children:[(0,W.jsx)(`p`,{className:`mb-3 text-sm text-primary`,children:`Type or paste text, then submit it to your terminal.`}),(0,W.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Paste here`,placeholder:`Type or paste here`,rows:4,value:i,onChange:e=>a(e.target.value),className:`w-full rounded border border-border bg-surface p-3 text-base text-primary`,onPaste:e=>{let t=iH(e.clipboardData);if(!t.length)return;e.preventDefault(),s(e=>[...e,...t]);let n=e.clipboardData.getData(`text/plain`);n&&n.trim()!==t.map(e=>e.name).join(`
|
|
247
|
+
`)&&a(e=>e+n)}}),n&&(0,W.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Attach files`,(0,W.jsx)(`input`,{type:`file`,multiple:!0,"aria-label":`Choose files`,className:`mt-2 block w-full text-sm`,onChange:e=>{let t=Array.from(e.target.files??[]);s(e=>[...e,...t]),e.target.value=``}})]}),o.length>0&&(0,W.jsx)(`ul`,{className:`mt-2 text-sm`,children:o.map((e,t)=>(0,W.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,W.jsx)(`button`,{type:`button`,className:`min-h-[44px] px-2`,"aria-label":`Remove ${e.name}`,onClick:()=>s(e=>e.filter((e,n)=>n!==t)),children:`Remove`})]},t))}),(0,W.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`min-h-[44px] px-3 text-secondary`,onClick:e,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,disabled:!i&&o.length===0,className:`min-h-[44px] rounded bg-accent px-3 text-white disabled:opacity-50`,children:`Submit`})]})]})});return typeof document>`u`?c:(0,U.createPortal)(c,document.body)}function EU(e){let[t,n]=(0,x.useState)({status:`idle`}),r=(0,x.useRef)(e);r.current=e;let i=(0,x.useRef)(0),a=(0,x.useRef)(Promise.resolve()),o=(0,x.useRef)(null),s=(0,x.useRef)(null),c=(0,x.useCallback)(()=>{i.current++,o.current?.abort(),o.current=null,a.current=Promise.resolve(),s.current=null,n({status:`idle`})},[]);(0,x.useLayoutEffect)(()=>(c(),()=>{i.current++,o.current?.abort()}),[e.sessionId,e.disabled,c]);let l=(0,x.useCallback)((e,t=!1)=>{let c=Promise.resolve(e).then(e=>({value:e}),e=>({error:e})),l=i.current,u=()=>l===i.current&&!r.current.disabled;return u()?(t&&n({status:`reading`}),a.current=a.current.then(async()=>{if(!u())return;let e=await c;if(!u())return;if(`error`in e){n({status:`awaiting-paste`});return}let t=e.value;s.current=t;let i=new AbortController;o.current=i;try{let e=aH(t.files);if(e)throw Error(e);if(t.files.length&&r.current.fileUploadsAllowed===!1)throw Error(`File uploads are unavailable for SSH sessions.`);t.files.length&&n({status:`uploading`});let a=[];for(let e of t.files){if(!u())return;a.push({file:e,path:await oH(e,i.signal)})}if(!u()||i.signal.aborted)return;let o=a.filter(({file:e})=>!/^image\/(png|jpeg|gif|webp)$/.test(e.type)),c=a.filter(({file:e})=>/^image\/(png|jpeg|gif|webp)$/.test(e.type)),l=[t.text,...o.map(({path:e})=>sH(e))].filter(Boolean).join(`
|
|
248
|
+
`);l&&r.current.onPasteText(l+(a.length?` `:``));for(let{path:e}of c)r.current.onPasteImage(tH(e,r.current.agentType)+` `);s.current=null,n({status:`idle`}),r.current.onRefocus?.()}catch(e){u()&&!i.signal.aborted&&n({status:`error`,message:e instanceof Error?e.message:`Upload failed. Try again.`})}finally{o.current===i&&(o.current=null)}}),a.current):Promise.resolve()},[]);return{state:t,paste:l,pasteClipboard:()=>l(cH(),!0),openDialog:()=>{r.current.disabled||(c(),n({status:`awaiting-paste`}))},retry:()=>s.current?l(s.current):Promise.resolve(),cancel:c,fail:e=>{c(),n({status:`error`,message:e})}}}var DU=(0,W.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`path`,{d:`M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7.07L2.4 12l4.66-7H22v14zm-11.59-2L14 13.41 17.59 17 19 15.59 15.41 12 19 8.41 17.59 7 14 10.59 10.41 7 9 8.41 12.59 12 9 15.59z`})}),OU=(0,W.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`}),(0,W.jsx)(`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`})]}),kU=(0,W.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,ry:`2`}),(0,W.jsx)(`line`,{x1:`6`,y1:`8`,x2:`6`,y2:`8`}),(0,W.jsx)(`line`,{x1:`10`,y1:`8`,x2:`10`,y2:`8`}),(0,W.jsx)(`line`,{x1:`14`,y1:`8`,x2:`14`,y2:`8`}),(0,W.jsx)(`line`,{x1:`18`,y1:`8`,x2:`18`,y2:`8`}),(0,W.jsx)(`line`,{x1:`6`,y1:`12`,x2:`6`,y2:`12`}),(0,W.jsx)(`line`,{x1:`10`,y1:`12`,x2:`10`,y2:`12`}),(0,W.jsx)(`line`,{x1:`14`,y1:`12`,x2:`14`,y2:`12`}),(0,W.jsx)(`line`,{x1:`18`,y1:`12`,x2:`18`,y2:`12`}),(0,W.jsx)(`line`,{x1:`7`,y1:`16`,x2:`17`,y2:`16`})]}),AU={label:(0,W.jsx)(pe,{width:18,height:18}),key:`\r`,className:`bg-accent/20 text-accent border-accent/40`,ariaLabel:`Enter`},jU={label:`esc`,key:`\x1B`},MU={label:DU,key:``,ariaLabel:`Delete word`},NU={label:`tab`,key:` `},PU={[NU.key]:`\x1B[Z`,[AU.key]:`
|
|
249
|
+
`};function FU(){`vibrate`in navigator&&navigator.vibrate(10)}function IU(e,t){if(!t||e.length!==1)return{output:e,consumeCtrl:!1};let n=e.toUpperCase().charCodeAt(0);return n>=65&&n<=90?{output:String.fromCharCode(n-64),consumeCtrl:!0}:{output:e,consumeCtrl:!0}}var LU={working:`bg-working`,waiting:`bg-waiting`,permission:`bg-approval`,unknown:`bg-muted`};function RU({onSendKey:e,onPasteText:t,onPasteImage:n,disabled:r=!1,sessions:i,currentSessionId:a,agentType:o,fileUploadsAllowed:s=!0,onSelectSession:c,hideSessionSwitcher:l=!1,onRefocus:u,isKeyboardVisible:d,onEnterTextMode:f}){let p=EU({sessionId:a,disabled:r,fileUploadsAllowed:s,agentType:o,onPasteText:t??e,onPasteImage:n??e,onRefocus:u}),[m,h]=(0,x.useState)(!1),g=XH(a,r),_=(0,x.useRef)(0),v=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!m||r||p.state.status===`awaiting-paste`||typeof document>`u`)return;let t=t=>{let{output:n,consumeCtrl:r}=IU(t.key,!0);r&&(t.preventDefault(),t.stopPropagation(),FU(),e(n),h(!1))};return document.addEventListener(`keydown`,t,{capture:!0}),()=>{document.removeEventListener(`keydown`,t,{capture:!0})}},[m,r,p.state.status,e]);let y=t=>{if(r)return;let n=d?.()??!1;FU();let{output:i,consumeCtrl:a}=IU(g.current?PU[t]??t:t,m);a&&h(!1),e(i),n&&u?.()},b=()=>{r||(FU(),h(!m))},S=t=>{let{output:n,consumeCtrl:r}=IU(t,m);r&&h(!1),e(n)},C=()=>{if(!r)return FU(),p.openDialog()},w=e=>{FU(),c(e)},T=()=>{r||(FU(),d?.()?document.activeElement instanceof HTMLElement&&document.activeElement.blur():f?.())},E=i.length>1&&!l,D=e=>t=>{if(r)return;let n=v.current,i=t.changedTouches[0];!n||!i||Math.hypot(i.clientX-n.x,i.clientY-n.y)>10||(t.preventDefault(),t.stopPropagation(),_.current=Date.now(),e())},O=e=>()=>{r||Date.now()-_.current<700||e()},k=e=>(0,W.jsx)(`button`,{type:`button`,"aria-label":e.ariaLabel,className:`
|
|
249
250
|
terminal-key
|
|
250
251
|
flex items-center justify-center
|
|
251
252
|
size-[44px] p-0
|
|
@@ -256,13 +257,13 @@ ${s.join(`
|
|
|
256
257
|
select-none touch-manipulation
|
|
257
258
|
${e.className??`text-secondary`}
|
|
258
259
|
${r?`opacity-50`:``}
|
|
259
|
-
`,onMouseDown:e=>e.preventDefault(),onTouchEnd:
|
|
260
|
+
`,onMouseDown:e=>e.preventDefault(),onTouchEnd:D(()=>y(e.key)),onClick:O(()=>y(e.key)),disabled:r,children:e.label},e.key);return(0,W.jsxs)(`div`,{className:`terminal-controls flex flex-col gap-[6px] border-t border-border bg-elevated p-[6px] ${We()?``:`md:hidden`}`,children:[E&&(0,W.jsxs)(`div`,{className:`relative -mx-[6px]`,children:[(0,W.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-3 bg-gradient-to-r from-elevated to-transparent z-10 pointer-events-none`}),(0,W.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-3 bg-gradient-to-l from-elevated to-transparent z-10 pointer-events-none`}),(0,W.jsx)(`div`,{className:`flex items-center gap-[6px] overflow-x-auto px-[6px] scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:i.map((e,t)=>(0,W.jsxs)(`button`,{type:`button`,className:`
|
|
260
261
|
terminal-key flex items-center justify-center gap-1.5 shrink-0 snap-start
|
|
261
262
|
h-[44px] min-w-[44px] px-2.5 text-xs font-medium rounded-md
|
|
262
263
|
active:scale-95 transition-transform duration-75
|
|
263
264
|
select-none touch-manipulation
|
|
264
265
|
${e.id===a?`bg-accent/20 text-accent border border-accent/40`:`bg-surface border border-border text-secondary`}
|
|
265
|
-
`,onClick:()=>
|
|
266
|
+
`,onClick:()=>w(e.id),children:[(0,W.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${LU[e.status]}`}),(0,W.jsx)(`span`,{className:`truncate`,children:t+1})]},e.id))})]}),(0,W.jsxs)(`div`,{className:`grid grid-flow-col auto-cols-[44px] items-center gap-[4px] overflow-x-auto scrollbar-none`,onTouchStartCapture:e=>{let t=e.touches[0];v.current=t?{x:t.clientX,y:t.clientY}:null},onTouchMoveCapture:e=>{let t=v.current,n=e.touches[0];t&&n&&Math.hypot(n.clientX-t.x,n.clientY-t.y)>10&&(v.current=null)},onTouchCancel:()=>{v.current=null},children:[k(AU),k(jU),(0,W.jsx)(lU,{onSendKey:S,disabled:r,onRefocus:u,isKeyboardVisible:d,sessionKey:a}),(0,W.jsx)(`button`,{type:`button`,"aria-label":`Paste`,className:`
|
|
266
267
|
terminal-key
|
|
267
268
|
flex items-center justify-center
|
|
268
269
|
size-[44px] p-0
|
|
@@ -273,7 +274,7 @@ ${s.join(`
|
|
|
273
274
|
select-none touch-manipulation
|
|
274
275
|
text-secondary
|
|
275
276
|
${r?`opacity-50`:``}
|
|
276
|
-
`,onMouseDown:e=>e.preventDefault(),"data-native-gesture":!0,onClick:
|
|
277
|
+
`,onMouseDown:e=>e.preventDefault(),"data-native-gesture":!0,onClick:C,disabled:r,children:OU}),k(MU),(0,W.jsx)(CU,{onSendKey:S,disabled:r,onRefocus:u,isKeyboardVisible:d}),k(NU),(0,W.jsx)(`button`,{type:`button`,className:`
|
|
277
278
|
terminal-key
|
|
278
279
|
flex items-center justify-center
|
|
279
280
|
size-[44px] p-0
|
|
@@ -284,7 +285,7 @@ ${s.join(`
|
|
|
284
285
|
select-none touch-manipulation
|
|
285
286
|
${m?`bg-accent/20 text-accent border border-accent/40`:`bg-surface border border-border text-secondary`}
|
|
286
287
|
${r?`opacity-50`:``}
|
|
287
|
-
`,onMouseDown:e=>e.preventDefault(),onTouchEnd:
|
|
288
|
+
`,onMouseDown:e=>e.preventDefault(),onTouchEnd:D(b),onClick:O(b),disabled:r,children:`ctrl`}),(0,W.jsx)(`button`,{type:`button`,"aria-label":`Show keyboard`,className:`
|
|
288
289
|
terminal-key
|
|
289
290
|
flex items-center justify-center
|
|
290
291
|
size-[44px] p-0
|
|
@@ -295,11 +296,11 @@ ${s.join(`
|
|
|
295
296
|
select-none touch-manipulation
|
|
296
297
|
text-secondary
|
|
297
298
|
${r?`opacity-50`:``}
|
|
298
|
-
`,onMouseDown:e=>e.preventDefault(),onTouchEnd:E(w),onClick:D(w),disabled:r,children:DU})]}),(0,W.jsx)(SU,{...p,allowFiles:s})]})}function LU({isOpen:e,onClose:t,sessions:n,hibernatingSessions:r=[],historySessions:i=[],selectedSessionId:a,selectedHibernatingSessionId:o=null,onSelect:s,onSelectHibernating:c,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:p,loading:m,error:h}){let g=pd(),_=(0,x.useRef)(null),v=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),(0,x.useEffect)(()=>{e?(v.current=document.activeElement,_.current?.focus()):v.current&&=(v.current.focus(),null)},[e]),(0,x.useEffect)(()=>{if(!e)return;let n=_.current;if(!n)return;let r=0,i=0,a=e=>{let t=e.touches[0];r=t.clientX,i=t.clientY},o=e=>{let n=e.changedTouches[0],a=r-n.clientX,o=Math.abs(n.clientY-i);a>=50&&a>o*1.5&&(`vibrate`in navigator&&navigator.vibrate(10),t())};return n.addEventListener(`touchstart`,a,{passive:!0}),n.addEventListener(`touchend`,o,{passive:!0}),()=>{n.removeEventListener(`touchstart`,a),n.removeEventListener(`touchend`,o)}},[e,t]);let y=e=>{s(e),t()},b=e=>{c?.(e),t()},S=g?{transition:`none`}:void 0;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`session-drawer-backdrop ${e?`open`:``}`,style:S,onClick:t,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{ref:_,className:`session-drawer ${e?`open`:``}`,style:S,role:`dialog`,"aria-modal":`true`,"aria-label":`Session list`,tabIndex:-1,children:[(0,W.jsx)(qT,{sessions:n,hibernatingSessions:r,historySessions:i,selectedSessionId:a,selectedHibernatingSessionId:o,onSelect:y,onSelectHibernating:b,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:()=>{p()!==!1&&t()},loading:m,error:h}),(0,W.jsx)(`div`,{className:`shrink-0 border-t border-border px-2 pt-2`,style:{paddingBottom:`max(0.5rem, env(safe-area-inset-bottom, 0.5rem))`},children:(0,W.jsx)(`button`,{onClick:()=>{p()!==!1&&t()},className:`btn btn-primary w-full py-2 text-sm`,children:`New Session`})})]})]})}var RU={working:`Working`,waiting:`Waiting`,permission:`Needs Input`,unknown:`Unknown`},zU={working:`text-working`,waiting:`text-waiting`,permission:`text-approval`,unknown:`text-muted`},BU={working:`bg-green-500/35 text-white`,waiting:`bg-blue-500/35 text-white`,permission:`bg-amber-500/35 text-white`,unknown:`bg-gray-500/35 text-white`},VU={working:`bg-working text-white`,waiting:`bg-waiting text-white`,permission:`bg-approval text-white`,unknown:`bg-muted text-white`};function HU(){`vibrate`in navigator&&navigator.vibrate(10)}function UU({session:e,sessions:t,hibernatingSession:n=null,hibernatingSessions:r=[],historySessions:i=[],connectionStatus:a,connectionEpoch:o=0,sendMessage:s,subscribe:c,onClose:l,onSelectSession:u,onSelectHibernatingSession:d,onNewSession:f,onKillSession:p,onRenameSession:m,onResumeSession:h,onHibernateSession:g,onMoveToHistory:_,onOpenSettings:v,loading:y=!1,error:b=null}){let S=VH[BH(e=>e.theme)],C=H(e=>e.useWebGL),w=H(e=>e.fontSize),T=H(e=>e.lineHeight),E=H(e=>e.letterSpacing),D=ee(H(e=>e.fontOption),H(e=>e.customFontFamily)),O=Ye(qe(H(e=>e.shortcutModifier))),k=We(),A=IH(),[j,M]=(0,x.useState)(!1),[N,P]=(0,x.useState)(!1),[F,I]=(0,x.useState)(!1),[L,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(!1),[te,V]=(0,x.useState)(!1),[ne,re]=(0,x.useState)(``),U=(0,x.useRef)(!1),ie=(0,x.useRef)(null),oe=(0,x.useRef)(null),se=(0,x.useRef)(null),ce=(0,x.useRef)(null),le=(0,x.useRef)(()=>{}),ue=(0,x.useRef)(()=>{}),fe=e?.remote===!0,pe=qm(e=>e.remoteAllowControl),me=qm(e=>e.remoteAllowAttach),ge=qm(e=>e.preferWindowName),ve=fe&&!me,ye=!fe||pe&&e?.source===`managed`,be=n?n.displayName||Im(n.projectPath)||n.sessionId.slice(0,8):``,xe=n?Im(n.projectPath):``,Se=n?Fm(n.lastActivityAt):``,Ce=!!e&&!!g&&e.source===`managed`&&!e.remote&&!!e.agentSessionId?.trim(),{containerRef:we,terminalRef:Ee,inTmuxCopyModeRef:Oe,isTmuxCopyMode:ke,appMouseRef:Ae,setTmuxCopyMode:je,isSwitching:Me,isInputReady:Pe,pendingClipboardOffer:Fe,copyPendingClipboardOffer:Ie,dismissPendingClipboardOffer:Re}=FH({sessionId:e?.id??null,tmuxTarget:e?.tmuxWindow??null,agentType:e?.agentType,onPasteFiles:e=>le.current(e),onPasteError:e=>ue.current(e),allowAttach:!ve,connectionStatus:a,connectionEpoch:o,sendMessage:s,subscribe:c,theme:S,fontSize:w,lineHeight:T,letterSpacing:E,fontFamily:D,useWebGL:C,onScrollChange:e=>{M(!e)}}),ze=(0,x.useCallback)(()=>{!e||ve||(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1),Ee.current?.scrollToBottom())},[e,ve,s,je,Ee]),Be=(0,x.useCallback)(()=>{B(!0),HU()},[]),Ve=zH({enabled:A||k,isOpen:z,onOpen:Be});(0,x.useEffect)(()=>{!A&&!k&&z&&B(!1)},[z,A,k]),LH(oe,L,(0,x.useCallback)(()=>R(!1),[])),(0,x.useEffect)(()=>{te&&se.current&&(se.current.focus(),se.current.select())},[te]),(0,x.useEffect)(()=>{F&&ce.current&&ce.current.focus()},[F]),RH(F,(0,x.useCallback)(()=>I(!1),[]));let He=()=>{e&&(p(e.id,`terminal_confirm_modal`),I(!1))},Ge=()=>{!e||!Ce||(g?.(e.agentSessionId.trim()),R(!1))},Ke=()=>{e&&(re(e.agentSessionName||e.name),V(!0),R(!1))},Je=()=>{if(!e)return;let t=ne.trim(),n=e.agentSessionName||e.name;t&&t!==n&&m(e.id,t),V(!1)},Xe=e=>{e.key===`Enter`?(e.preventDefault(),Je()):e.key===`Escape`&&(e.preventDefault(),V(!1))};(0,x.useEffect)(()=>{if(!k||!e){P(!1);return}let t=we.current;if(!t)return;let n=e=>{let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},r=()=>{let e=t.querySelector(`.xterm-accessibility`),n=t.querySelector(`.xterm-accessibility-tree`);!e||!n||(e.style.setProperty(`opacity`,`0`),n.style.setProperty(`opacity`,`0`),e.style.setProperty(`-webkit-user-select`,`none`),e.style.setProperty(`user-select`,`none`),n.style.setProperty(`-webkit-user-select`,`none`),n.style.setProperty(`user-select`,`none`),e.offsetHeight,requestAnimationFrame(()=>{e.style.removeProperty(`opacity`),n.style.removeProperty(`opacity`),e.style.removeProperty(`-webkit-user-select`),e.style.removeProperty(`user-select`),n.style.removeProperty(`-webkit-user-select`),n.style.removeProperty(`user-select`)}))},i=()=>{U.current=!1;let e=window.getSelection();try{e?.removeAllRanges()}catch{}Ee.current?.clearSelection(),r(),P(!1)};ie.current=i;let a=()=>{let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed){U.current?i():P(e=>e&&!1);return}let t=n(e);if(!t&&U.current){i();return}U.current=t;let r=t;P(e=>e===r?e:r)},o=()=>{let e=window.getSelection();!e||e.isCollapsed||n(e)&&setTimeout(i,0)},s=null,c=!1,l=e=>{if(e.touches.length===1){let t=e.touches[0];s={x:t.clientX,y:t.clientY},c=!1}},u=e=>{if(c||!s||e.touches.length!==1)return;let t=e.touches[0],n=Math.abs(t.clientX-s.x),r=Math.abs(t.clientY-s.y);(n>10||r>10)&&(c=!0)},d=e=>{let r=c;s=null,c=!1;let a=window.getSelection();if(!a||a.rangeCount===0||a.isCollapsed){P(!1);return}let o=t.querySelector(`.xterm-accessibility-tree`);if(!o)return;if(!n(a)){P(!1);return}if(r)return;let l=e.target,u=l?o.contains(l):!1,d=!1;if(u&&l)try{d=a.containsNode(l,!0)}catch{d=!1}(!u||!d)&&setTimeout(i,0)};return document.addEventListener(`selectionchange`,a),document.addEventListener(`copy`,o),document.addEventListener(`touchstart`,l,{passive:!0}),document.addEventListener(`touchmove`,u,{passive:!0}),document.addEventListener(`touchend`,d,{passive:!0}),()=>{document.removeEventListener(`selectionchange`,a),document.removeEventListener(`copy`,o),document.removeEventListener(`touchstart`,l),document.removeEventListener(`touchmove`,u),document.removeEventListener(`touchend`,d),ie.current=null,U.current=!1}},[we,k,e?.id]),(0,x.useEffect)(()=>{if(!k)return;let t=we.current;if(!t)return;let n=null,r=()=>{let e=Ee.current,r=t.querySelector(`.xterm`);if(!e||!r)return;let i=r.querySelector(`.xterm-screen`),a=r.querySelector(`.xterm-accessibility`),o=r.querySelector(`.xterm-accessibility-tree`);if(!i||!a||!o)return;n||=YH(o);let s=r.getBoundingClientRect(),c=i.getBoundingClientRect(),l=c.left-s.left,u=c.top-s.top;Object.assign(a.style,{left:`${l}px`,top:`${u}px`,right:`auto`,bottom:`auto`,width:`${c.width}px`,height:`${c.height}px`});let d=c.width/e.cols,f=c.height/e.rows,p=document.createElement(`span`);p.textContent=`0`.repeat(200),p.style.cssText=`position:absolute;visibility:hidden;white-space:pre;pointer-events:none;letter-spacing:0px`,o.appendChild(p);let m=p.getBoundingClientRect().width/200;p.remove();let h=Math.max(-2,Math.min(2,d-m));t.style.setProperty(`--xterm-font-size`,`${e.options.fontSize}px`),t.style.setProperty(`--xterm-cell-height`,`${f}px`),t.style.setProperty(`--xterm-a11y-letter-spacing`,`${h}px`)},i=performance.now();r();let a=Math.round(performance.now()-i);a>10&&J(`switch_a11y_overlay`,{sessionId:e?.id,a11yMs:a});let o=window.requestAnimationFrame(r),s=window.setTimeout(r,100),c=()=>window.requestAnimationFrame(r);return window.visualViewport?.addEventListener(`resize`,c),window.addEventListener(`orientationchange`,c),()=>{window.cancelAnimationFrame(o),window.clearTimeout(s),window.visualViewport?.removeEventListener(`resize`,c),window.removeEventListener(`orientationchange`,c),n?.()}},[we,w,k,e?.id,Ee]);let Ze=(0,x.useRef)(N);(0,x.useEffect)(()=>{Ze.current=N},[N]);let Qe=(0,x.useRef)(e?.id);(0,x.useEffect)(()=>{Qe.current=e?.id},[e?.id]);let $e=(0,x.useRef)(s);(0,x.useEffect)(()=>{$e.current=s},[s]);let et=(0,x.useRef)(!1),tt=(0,x.useRef)(`idle`);(0,x.useEffect)(()=>{if(!k)return;let e=we.current;if(!e)return;let t=null,n=()=>e.querySelector(`.xterm-helper-textarea`),r=e=>{e.target===n()&&(tt.current=`focused`)},i=e=>{e.target===n()&&(t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{t=null;let e=n(),r=typeof document.hasFocus!=`function`||document.hasFocus();document.activeElement!==e&&document.visibilityState!==`hidden`&&r&&(tt.current=`idle`)},0))},a=()=>{let e=n();(document.activeElement===e||tt.current===`focused`)&&(tt.current=`interrupted`)},o=()=>{tt.current===`interrupted`&&(tt.current=`armed`)},s=()=>{document.visibilityState===`hidden`?a():o()},c=e=>{e.persisted&&o()};return document.addEventListener(`focusin`,r),document.addEventListener(`focusout`,i),document.addEventListener(`visibilitychange`,s),window.addEventListener(`blur`,a),window.addEventListener(`focus`,o),window.addEventListener(`pageshow`,c),()=>{document.removeEventListener(`focusin`,r),document.removeEventListener(`focusout`,i),document.removeEventListener(`visibilitychange`,s),window.removeEventListener(`blur`,a),window.removeEventListener(`focus`,o),window.removeEventListener(`pageshow`,c),t!==null&&window.clearTimeout(t),tt.current=`idle`}},[we,k,e?.id]),(0,x.useEffect)(()=>{let t=we.current;if(!t||!e?.id||!A&&!k)return;let n={x:0,y:0},r=0,i=!1,a=null,o=0,s=0,c=0,l=Math.round(w*T),u=null,d=null,f=!1,p=null,m=()=>{let e=window.getComputedStyle(t).getPropertyValue(`--xterm-cell-height`).trim(),n=Number.parseFloat(e);return!Number.isNaN(n)&&n>0?n:Math.round(w*T)},h=()=>t.querySelector(`.xterm-helper-textarea`),g=e=>{let n=Ee.current;if(!n)return null;let r=(t.querySelector(`.xterm`)?.querySelector(`.xterm-screen`))?.getBoundingClientRect();if(!r||r.width<=0||r.height<=0)return null;let i=r.width/n.cols,a=r.height/n.rows;return i<=0||a<=0?null:{col:Math.min(n.cols,Math.max(1,Math.floor((e.clientX-r.left)/i)+1)),row:Math.min(n.rows,Math.max(1,Math.floor((e.clientY-r.top)/a)+1))}},_=()=>{let e=h();e&&document.activeElement!==e&&(e.disabled=!0)},v=()=>{let e=h();e&&(e.disabled=!1)};_();let y=()=>{if(Oe.current)return;let e=h();e&&(e.disabled=!1,e.focus())},b=()=>{u!==null&&(cancelAnimationFrame(u),u=null),s=0},x=()=>{d!==null&&(clearTimeout(d),d=null)},S=(e,t,n)=>{let r=Qe.current;return r?($e.current({type:`terminal-input`,sessionId:r,data:`\x1b[<${e};${t.col};${t.row}${n}`}),!0):!1},C=e=>{let t=Qe.current;if(!t||e===0)return!1;let n=Ee.current,r=n?.cols??80,i=n?.rows??24,a=Math.floor(r/2),o=Math.floor(i/2),s=e>0?65:64,c=Math.abs(e),l=e<0;for(let e=0;e<c;e++)$e.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${s};${a};${o}M`});return l&&!Ae.current&&je(!0),l},E=e=>{let t=Qe.current,n=g(e);return!t||!n?!1:($e.current({type:`terminal-input`,sessionId:t,data:`\x1b[<0;${n.col};${n.row}M\x1b[<0;${n.col};${n.row}m`}),!0)},D=e=>{if(!k||!Ae.current)return!1;let t=g(e);return t?(f=!0,p=t,_(),HU(),S(0,t,`M`)):!1},O=e=>{let t=g(e);return t?p&&p.col===t.col&&p.row===t.row?!0:(p=t,S(32,t,`M`)):!1},j=e=>{let t=e?g(e):p;return f=!1,p=null,t?S(0,t,`m`):!1},M=()=>{x(),f=!1,p=null,a=null,s=0,c=0},N=()=>{if(!k)return!1;let e=window.getSelection();if(!e||e.isCollapsed)return!1;let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},P=()=>{!k||!U.current||N()||ie.current?.()},F=e=>{if(b(),P(),Ve.current||z){M();return}if(Ze.current){M();return}if(tt.current===`armed`&&!Oe.current&&(tt.current=`idle`,y()),e.touches.length===1){let t=e.touches[0];if(n={x:t.clientX,y:t.clientY},r=performance.now(),i=!1,a=t.clientY,o=r,s=0,c=0,l=m(),v(),k&&Ae.current){let e={clientX:t.clientX,clientY:t.clientY};d=setTimeout(()=>{d=null,!(i||Ve.current||z)&&(Ze.current||N()||D(e))},350)}}},I=e=>{if(e.touches.length!==1||a===null)return;if(P(),Ve.current||z){M();return}let t=performance.now(),r=e.touches[0],u=r.clientX,d=r.clientY;if(f){e.preventDefault(),e.stopPropagation(),O(r),a=d,o=t;return}if(Ze.current||N()){M();return}e.preventDefault(),e.stopPropagation();let p=Math.abs(u-n.x),m=Math.abs(d-n.y);!i&&(p>6||m>6)&&(i=!0,x(),_());let h=a-d,g=t-o;if(a=d,o=t,g>0){let e=h/g;s=s*.7+e*.3}c+=h;let v=Math.max(6,l*.6),y=Math.trunc(c/v);y!==0&&(C(y),c-=y*v)},L=e=>{let t=s,n=performance.now()-r;if(x(),f){j(e.changedTouches[0]),M(),e.preventDefault(),e.stopPropagation();return}if(M(),Ve.current||z)return;let a=N();if(Ze.current&&!a&&ie.current?.(),Ze.current||a){Oe.current&&(et.current=!0);return}if(!i){if(k&&n>=350)return;if(Ae.current){let t=e.changedTouches[0];if(t&&E(t)){y(),e.preventDefault(),e.stopPropagation();return}}if(Oe.current){e.preventDefault(),e.stopPropagation(),et.current=!0;return}y();return}if(Math.abs(t)>.12){let e=t,n=performance.now(),r=()=>{let t=performance.now(),i=t-n;n=t;let a=e*i;c+=a;let o=Math.max(6,l*.6),s=Math.trunc(c/o);s!==0&&(C(s),c-=s*o),e*=.95**(i/16.67),u=Math.abs(e)>.02?requestAnimationFrame(r):null};u=requestAnimationFrame(r)}},ee=e=>{et.current&&=(e.preventDefault(),e.stopPropagation(),!1)},R={passive:!0,capture:!0},B={passive:!1,capture:!0},te={passive:!1,capture:!0},V={capture:!0};return t.addEventListener(`touchstart`,F,R),t.addEventListener(`touchmove`,I,B),t.addEventListener(`touchend`,L,te),t.addEventListener(`mousedown`,ee,V),()=>{t.removeEventListener(`touchstart`,F,R),t.removeEventListener(`touchmove`,I,B),t.removeEventListener(`touchend`,L,te),t.removeEventListener(`mousedown`,ee,V),x();let e=h();e&&(e.disabled=!1)}},[e?.id,we,Ee,k,A,z,w,T]);let nt=(0,x.useCallback)(t=>{!e||ve||!Pe||s({type:`terminal-input`,sessionId:e.id,data:t})},[e,ve,Pe,s]),rt=(0,x.useCallback)(t=>{!e||ve||!Pe||(Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1)),s({type:`terminal-paste`,sessionId:e.id,data:t}))},[e,ve,Pe,s,Oe,je]),it=(0,x.useCallback)(t=>{!e||ve||!Pe||(Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1)),nt(t))},[e,ve,Pe,s,Oe,je,nt]),at=(0,x.useCallback)(()=>{let e=we.current;if(!e)return;let t=e.querySelector(`.xterm-helper-textarea`);t&&(t.removeAttribute(`disabled`),t.focus())},[we]),ot=wU({sessionId:e?.id??null,disabled:a!==`connected`||ve||!Pe,fileUploadsAllowed:!fe,agentType:e?.agentType,onPasteText:rt,onPasteImage:it,onRefocus:at});le.current=ot.paste,ue.current=ot.fail;let st=(0,x.useCallback)(()=>{if(!e||ve||!Pe)return;Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1));let t=we.current;if(!t)return;let n=t.querySelector(`.xterm-helper-textarea`);n&&(n.removeAttribute(`disabled`),n.focus())},[e,ve,Pe,s,we,Oe,je]),ct=(0,x.useCallback)(()=>{if(typeof document>`u`)return!1;let e=we.current;if(!e)return!1;let t=e.querySelector(`.xterm-helper-textarea`);if(t&&document.activeElement===t)return!0;let n=document.activeElement,r=typeof HTMLInputElement<`u`&&n instanceof HTMLInputElement,i=typeof HTMLTextAreaElement<`u`&&n instanceof HTMLTextAreaElement;return r||i||n&&n.isContentEditable?!1:!!document.documentElement?.classList?.contains(`keyboard-visible`)},[we]);(0,x.useEffect)(()=>{if(!k)return;let e=we.current;if(!e)return;let t=e.querySelector(`.xterm-accessibility`),n=e.querySelector(`.xterm-accessibility-tree`);if(!t||!n)return;let r=()=>{let r=e.querySelector(`.xterm-helper-textarea`);r&&document.activeElement===r&&!Ze.current?(t.style.pointerEvents=`none`,n.style.pointerEvents=`none`):(t.style.removeProperty(`pointer-events`),n.style.removeProperty(`pointer-events`))};return r(),document.addEventListener(`focusin`,r),document.addEventListener(`focusout`,r),()=>{document.removeEventListener(`focusin`,r),document.removeEventListener(`focusout`,r)}},[we,k,N]),(0,x.useEffect)(()=>{let e=we.current;e&&(e.inert=!!n)},[we,n]);let lt=(0,x.useMemo)(()=>{if(!ge||t.length===0)return!1;let e=t.map(e=>e.name.trim()).filter(Boolean);return e.length===t.length&&new Set(e).size===t.length},[ge,t]);return(0,W.jsxs)(`section`,{className:`flex flex-1 flex-col bg-base terminal-mobile-overlay md:relative md:inset-auto ${k?`ios-native-term-selection`:``}`,"data-testid":`terminal-panel`,onDragOver:t=>{Array.from(t.dataTransfer.types).includes(`Files`)&&(t.preventDefault(),t.dataTransfer.dropEffect=e&&!ve&&Pe&&!fe&&a===`connected`?`copy`:`none`)},onDrop:t=>{if(!Array.from(t.dataTransfer.types).includes(`Files`)||(t.preventDefault(),t.stopPropagation(),!e||ve||!Pe||fe||a!==`connected`))return;let n=iH(t.dataTransfer);n.length&&ot.paste({text:``,files:n})},children:[(0,W.jsxs)(`div`,{className:`flex min-h-[52px] shrink-0 items-center justify-between border-b border-border bg-elevated px-[6px] md:h-10 md:min-h-0 md:px-3 ${e||n?``:`md:hidden`}`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[7px] md:gap-3`,children:[(0,W.jsx)(`button`,{onClick:()=>B(!0),className:`flex size-[44px] shrink-0 items-center justify-center rounded border border-border bg-surface text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95 md:hidden`,"aria-label":`Open session menu`,children:(0,W.jsx)(Te,{width:16,height:16})}),e&&ye&&(0,W.jsx)(`button`,{disabled:Me,onClick:()=>I(!0),className:`hidden md:flex h-7 w-7 items-center justify-center rounded bg-danger/10 border border-danger/30 text-danger hover:bg-danger/20 active:scale-95 transition-all shrink-0 disabled:cursor-not-allowed disabled:opacity-40`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,W.jsx)(Ue,{width:16,height:16})}),Ce&&(0,W.jsx)(`button`,{onClick:Ge,className:`hidden md:flex h-7 w-7 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all shrink-0`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,W.jsx)(De,{width:16,height:16})}),e?(0,W.jsxs)(`div`,{className:`flex min-w-[72px] flex-col items-start gap-px leading-none md:min-w-0 md:flex-row md:items-baseline md:gap-3 md:leading-normal`,children:[te?(0,W.jsx)(`input`,{ref:se,type:`text`,value:ne,onChange:e=>re(e.target.value),onBlur:Je,onKeyDown:Xe,className:`w-full max-w-[112px] rounded border border-border bg-surface px-2 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent md:max-w-[200px]`}):(0,W.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:e.agentSessionName||e.name}),(0,W.jsx)(`span`,{className:`shrink-0 text-[10px] md:hidden ${a===`connected`?zU[e.status]:`text-approval`}`,children:a===`connected`?RU[e.status]:a}),(0,W.jsx)(`span`,{className:`hidden shrink-0 text-xs md:inline ${zU[e.status]}`,children:RU[e.status]})]}):n?(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-px leading-none md:flex-row md:items-baseline md:gap-2 md:leading-normal`,children:[(0,W.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:be}),(0,W.jsx)(`span`,{className:`text-[10px] font-medium text-blue-400 md:rounded-full md:bg-blue-500/15 md:px-1.5 md:py-0.5 md:uppercase md:tracking-wide`,children:`Hibernating`})]}):(0,W.jsx)(`span`,{className:`text-sm font-medium text-primary md:hidden`,children:`Sessions`})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[4px] md:gap-1.5`,children:[a!==`connected`&&(0,W.jsx)(`span`,{className:`hidden text-xs text-approval md:inline`,children:a}),(0,W.jsx)(`button`,{onClick:f,className:`flex size-[44px] items-center justify-center rounded bg-accent text-white transition-all hover:bg-accent/90 active:scale-95 md:hidden`,title:`New session (${O}N)`,"aria-label":`New session`,children:(0,W.jsx)(Ne,{width:16,height:16})}),e&&ye&&(0,W.jsx)(`button`,{disabled:Me,onClick:()=>I(!0),className:`flex size-[44px] items-center justify-center rounded border border-danger/30 bg-danger/10 text-danger transition-all hover:bg-danger/20 active:scale-95 disabled:cursor-not-allowed disabled:opacity-40 md:hidden`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,W.jsx)(Ue,{width:16,height:16})}),Ce&&(0,W.jsx)(`button`,{onClick:Ge,className:`hidden size-[44px] items-center justify-center rounded border border-border text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95 min-[360px]:flex md:hidden`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,W.jsx)(De,{width:16,height:16})}),n&&(0,W.jsx)(`button`,{onClick:()=>h(n.sessionId),className:`btn btn-primary h-[44px] px-3 text-xs md:hidden`,children:`Wake`}),e&&(0,W.jsxs)(`div`,{className:`relative md:hidden`,ref:oe,children:[(0,W.jsx)(`button`,{onClick:()=>R(!L),className:`flex size-[44px] items-center justify-center rounded border border-border bg-surface text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95`,title:`More options`,"aria-label":`More options`,children:(0,W.jsx)(he,{width:16,height:16})}),L&&(0,W.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border bg-elevated shadow-lg py-1`,children:[ye&&(0,W.jsxs)(`button`,{onClick:Ke,className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(_e,{width:14,height:14}),`Rename`]}),Ce&&(0,W.jsxs)(`button`,{onClick:Ge,className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(De,{width:14,height:14}),`Hibernate`]}),(0,W.jsxs)(`button`,{onClick:()=>{v(),R(!1)},className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(Le,{width:14,height:14}),`Settings`]})]})]})]})]}),e&&t.length>1&&(0,W.jsxs)(`div`,{className:`relative overflow-hidden bg-elevated border-b border-border md:hidden`,children:[(0,W.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-4 bg-gradient-to-l from-elevated to-transparent z-10 pointer-events-none`}),(0,W.jsx)(`div`,{className:`flex items-center gap-[6px] overflow-x-auto px-[8px] py-[5px] scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:t.map((t,n)=>{let r=t.id===e.id,i=lt?t.name.trim():n+1;return(0,W.jsx)(`button`,{type:`button`,className:`
|
|
299
|
+
`,onMouseDown:e=>e.preventDefault(),onTouchEnd:D(T),onClick:O(T),disabled:r,children:kU})]}),(0,W.jsx)(wU,{...p,allowFiles:s})]})}function zU({isOpen:e,onClose:t,sessions:n,hibernatingSessions:r=[],historySessions:i=[],selectedSessionId:a,selectedHibernatingSessionId:o=null,onSelect:s,onSelectHibernating:c,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:p,loading:m,error:h}){let g=pd(),_=(0,x.useRef)(null),v=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),(0,x.useEffect)(()=>{e?(v.current=document.activeElement,_.current?.focus()):v.current&&=(v.current.focus(),null)},[e]),(0,x.useEffect)(()=>{if(!e)return;let n=_.current;if(!n)return;let r=0,i=0,a=e=>{let t=e.touches[0];r=t.clientX,i=t.clientY},o=e=>{let n=e.changedTouches[0],a=r-n.clientX,o=Math.abs(n.clientY-i);a>=50&&a>o*1.5&&(`vibrate`in navigator&&navigator.vibrate(10),t())};return n.addEventListener(`touchstart`,a,{passive:!0}),n.addEventListener(`touchend`,o,{passive:!0}),()=>{n.removeEventListener(`touchstart`,a),n.removeEventListener(`touchend`,o)}},[e,t]);let y=e=>{s(e),t()},b=e=>{c?.(e),t()},S=g?{transition:`none`}:void 0;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`session-drawer-backdrop ${e?`open`:``}`,style:S,onClick:t,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{ref:_,className:`session-drawer ${e?`open`:``}`,style:S,role:`dialog`,"aria-modal":`true`,"aria-label":`Session list`,tabIndex:-1,children:[(0,W.jsx)(qT,{sessions:n,hibernatingSessions:r,historySessions:i,selectedSessionId:a,selectedHibernatingSessionId:o,onSelect:y,onSelectHibernating:b,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:()=>{p()!==!1&&t()},loading:m,error:h}),(0,W.jsx)(`div`,{className:`shrink-0 border-t border-border px-2 pt-2`,style:{paddingBottom:`max(0.5rem, env(safe-area-inset-bottom, 0.5rem))`},children:(0,W.jsx)(`button`,{onClick:()=>{p()!==!1&&t()},className:`btn btn-primary w-full py-2 text-sm`,children:`New Session`})})]})]})}var BU={working:`Working`,waiting:`Waiting`,permission:`Needs Input`,unknown:`Unknown`},VU={working:`text-working`,waiting:`text-waiting`,permission:`text-approval`,unknown:`text-muted`},HU={working:`bg-green-500/35 text-white`,waiting:`bg-blue-500/35 text-white`,permission:`bg-amber-500/35 text-white`,unknown:`bg-gray-500/35 text-white`},UU={working:`bg-working text-white`,waiting:`bg-waiting text-white`,permission:`bg-approval text-white`,unknown:`bg-muted text-white`};function WU(){`vibrate`in navigator&&navigator.vibrate(10)}function GU({session:e,sessions:t,hibernatingSession:n=null,hibernatingSessions:r=[],historySessions:i=[],connectionStatus:a,connectionEpoch:o=0,sendMessage:s,subscribe:c,onClose:l,onSelectSession:u,onSelectHibernatingSession:d,onNewSession:f,onKillSession:p,onRenameSession:m,onResumeSession:h,onHibernateSession:g,onMoveToHistory:_,onOpenSettings:v,loading:y=!1,error:b=null}){let S=VH[BH(e=>e.theme)],C=H(e=>e.useWebGL),w=H(e=>e.fontSize),T=H(e=>e.lineHeight),E=H(e=>e.letterSpacing),D=ee(H(e=>e.fontOption),H(e=>e.customFontFamily)),O=Ye(qe(H(e=>e.shortcutModifier))),k=We(),A=IH(),[j,M]=(0,x.useState)(!1),[N,P]=(0,x.useState)(!1),[F,I]=(0,x.useState)(!1),[L,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(!1),[te,V]=(0,x.useState)(!1),[ne,re]=(0,x.useState)(``),U=(0,x.useRef)(!1),ie=(0,x.useRef)(null),oe=(0,x.useRef)(null),se=(0,x.useRef)(null),ce=(0,x.useRef)(null),le=(0,x.useRef)(()=>{}),ue=(0,x.useRef)(()=>{}),fe=e?.remote===!0,pe=qm(e=>e.remoteAllowControl),me=qm(e=>e.remoteAllowAttach),ge=qm(e=>e.preferWindowName),ve=fe&&!me,ye=!fe||pe&&e?.source===`managed`,be=n?n.displayName||Im(n.projectPath)||n.sessionId.slice(0,8):``,xe=n?Im(n.projectPath):``,Se=n?Fm(n.lastActivityAt):``,Ce=!!e&&!!g&&e.source===`managed`&&!e.remote&&!!e.agentSessionId?.trim(),{containerRef:we,terminalRef:Ee,inTmuxCopyModeRef:Oe,isTmuxCopyMode:ke,appMouseRef:Ae,setTmuxCopyMode:je,isSwitching:Me,isInputReady:Pe,pendingClipboardOffer:Fe,copyPendingClipboardOffer:Ie,dismissPendingClipboardOffer:Re}=FH({sessionId:e?.id??null,tmuxTarget:e?.tmuxWindow??null,agentType:e?.agentType,onPasteFiles:e=>le.current(e),onPasteError:e=>ue.current(e),allowAttach:!ve,connectionStatus:a,connectionEpoch:o,sendMessage:s,subscribe:c,theme:S,fontSize:w,lineHeight:T,letterSpacing:E,fontFamily:D,useWebGL:C,onScrollChange:e=>{M(!e)}}),ze=(0,x.useCallback)(()=>{!e||ve||(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1),Ee.current?.scrollToBottom())},[e,ve,s,je,Ee]),Be=(0,x.useCallback)(()=>{B(!0),WU()},[]),Ve=zH({enabled:A||k,isOpen:z,onOpen:Be});(0,x.useEffect)(()=>{!A&&!k&&z&&B(!1)},[z,A,k]),LH(oe,L,(0,x.useCallback)(()=>R(!1),[])),(0,x.useEffect)(()=>{te&&se.current&&(se.current.focus(),se.current.select())},[te]),(0,x.useEffect)(()=>{F&&ce.current&&ce.current.focus()},[F]),RH(F,(0,x.useCallback)(()=>I(!1),[]));let He=()=>{e&&(p(e.id,`terminal_confirm_modal`),I(!1))},Ge=()=>{!e||!Ce||(g?.(e.agentSessionId.trim()),R(!1))},Ke=()=>{e&&(re(e.agentSessionName||e.name),V(!0),R(!1))},Je=()=>{if(!e)return;let t=ne.trim(),n=e.agentSessionName||e.name;t&&t!==n&&m(e.id,t),V(!1)},Xe=e=>{e.key===`Enter`?(e.preventDefault(),Je()):e.key===`Escape`&&(e.preventDefault(),V(!1))};(0,x.useEffect)(()=>{if(!k||!e){P(!1);return}let t=we.current;if(!t)return;let n=e=>{let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},r=()=>{let e=t.querySelector(`.xterm-accessibility`),n=t.querySelector(`.xterm-accessibility-tree`);!e||!n||(e.style.setProperty(`opacity`,`0`),n.style.setProperty(`opacity`,`0`),e.style.setProperty(`-webkit-user-select`,`none`),e.style.setProperty(`user-select`,`none`),n.style.setProperty(`-webkit-user-select`,`none`),n.style.setProperty(`user-select`,`none`),e.offsetHeight,requestAnimationFrame(()=>{e.style.removeProperty(`opacity`),n.style.removeProperty(`opacity`),e.style.removeProperty(`-webkit-user-select`),e.style.removeProperty(`user-select`),n.style.removeProperty(`-webkit-user-select`),n.style.removeProperty(`user-select`)}))},i=()=>{U.current=!1;let e=window.getSelection();try{e?.removeAllRanges()}catch{}Ee.current?.clearSelection(),r(),P(!1)};ie.current=i;let a=()=>{let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed){U.current?i():P(e=>e&&!1);return}let t=n(e);if(!t&&U.current){i();return}U.current=t;let r=t;P(e=>e===r?e:r)},o=()=>{let e=window.getSelection();!e||e.isCollapsed||n(e)&&setTimeout(i,0)},s=null,c=!1,l=e=>{if(e.touches.length===1){let t=e.touches[0];s={x:t.clientX,y:t.clientY},c=!1}},u=e=>{if(c||!s||e.touches.length!==1)return;let t=e.touches[0],n=Math.abs(t.clientX-s.x),r=Math.abs(t.clientY-s.y);(n>10||r>10)&&(c=!0)},d=e=>{let r=c;s=null,c=!1;let a=window.getSelection();if(!a||a.rangeCount===0||a.isCollapsed){P(!1);return}let o=t.querySelector(`.xterm-accessibility-tree`);if(!o)return;if(!n(a)){P(!1);return}if(r)return;let l=e.target,u=l?o.contains(l):!1,d=!1;if(u&&l)try{d=a.containsNode(l,!0)}catch{d=!1}(!u||!d)&&setTimeout(i,0)};return document.addEventListener(`selectionchange`,a),document.addEventListener(`copy`,o),document.addEventListener(`touchstart`,l,{passive:!0}),document.addEventListener(`touchmove`,u,{passive:!0}),document.addEventListener(`touchend`,d,{passive:!0}),()=>{document.removeEventListener(`selectionchange`,a),document.removeEventListener(`copy`,o),document.removeEventListener(`touchstart`,l),document.removeEventListener(`touchmove`,u),document.removeEventListener(`touchend`,d),ie.current=null,U.current=!1}},[we,k,e?.id]),(0,x.useEffect)(()=>{if(!k)return;let t=we.current;if(!t)return;let n=null,r=()=>{let e=Ee.current,r=t.querySelector(`.xterm`);if(!e||!r)return;let i=r.querySelector(`.xterm-screen`),a=r.querySelector(`.xterm-accessibility`),o=r.querySelector(`.xterm-accessibility-tree`);if(!i||!a||!o)return;n||=YH(o);let s=r.getBoundingClientRect(),c=i.getBoundingClientRect(),l=c.left-s.left,u=c.top-s.top;Object.assign(a.style,{left:`${l}px`,top:`${u}px`,right:`auto`,bottom:`auto`,width:`${c.width}px`,height:`${c.height}px`});let d=c.width/e.cols,f=c.height/e.rows,p=document.createElement(`span`);p.textContent=`0`.repeat(200),p.style.cssText=`position:absolute;visibility:hidden;white-space:pre;pointer-events:none;letter-spacing:0px`,o.appendChild(p);let m=p.getBoundingClientRect().width/200;p.remove();let h=Math.max(-2,Math.min(2,d-m));t.style.setProperty(`--xterm-font-size`,`${e.options.fontSize}px`),t.style.setProperty(`--xterm-cell-height`,`${f}px`),t.style.setProperty(`--xterm-a11y-letter-spacing`,`${h}px`)},i=performance.now();r();let a=Math.round(performance.now()-i);a>10&&J(`switch_a11y_overlay`,{sessionId:e?.id,a11yMs:a});let o=window.requestAnimationFrame(r),s=window.setTimeout(r,100),c=()=>window.requestAnimationFrame(r);return window.visualViewport?.addEventListener(`resize`,c),window.addEventListener(`orientationchange`,c),()=>{window.cancelAnimationFrame(o),window.clearTimeout(s),window.visualViewport?.removeEventListener(`resize`,c),window.removeEventListener(`orientationchange`,c),n?.()}},[we,w,k,e?.id,Ee]);let Ze=(0,x.useRef)(N);(0,x.useEffect)(()=>{Ze.current=N},[N]);let Qe=(0,x.useRef)(e?.id);(0,x.useEffect)(()=>{Qe.current=e?.id},[e?.id]);let $e=(0,x.useRef)(s);(0,x.useEffect)(()=>{$e.current=s},[s]);let et=(0,x.useRef)(!1),tt=(0,x.useRef)(`idle`);(0,x.useEffect)(()=>{if(!k)return;let e=we.current;if(!e)return;let t=null,n=()=>e.querySelector(`.xterm-helper-textarea`),r=e=>{e.target===n()&&(tt.current=`focused`)},i=e=>{e.target===n()&&(t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{t=null;let e=n(),r=typeof document.hasFocus!=`function`||document.hasFocus();document.activeElement!==e&&document.visibilityState!==`hidden`&&r&&(tt.current=`idle`)},0))},a=()=>{let e=n();(document.activeElement===e||tt.current===`focused`)&&(tt.current=`interrupted`)},o=()=>{tt.current===`interrupted`&&(tt.current=`armed`)},s=()=>{document.visibilityState===`hidden`?a():o()},c=e=>{e.persisted&&o()};return document.addEventListener(`focusin`,r),document.addEventListener(`focusout`,i),document.addEventListener(`visibilitychange`,s),window.addEventListener(`blur`,a),window.addEventListener(`focus`,o),window.addEventListener(`pageshow`,c),()=>{document.removeEventListener(`focusin`,r),document.removeEventListener(`focusout`,i),document.removeEventListener(`visibilitychange`,s),window.removeEventListener(`blur`,a),window.removeEventListener(`focus`,o),window.removeEventListener(`pageshow`,c),t!==null&&window.clearTimeout(t),tt.current=`idle`}},[we,k,e?.id]),(0,x.useEffect)(()=>{let t=we.current;if(!t||!e?.id||!A&&!k)return;let n={x:0,y:0},r=0,i=!1,a=null,o=0,s=0,c=0,l=Math.round(w*T),u=null,d=null,f=!1,p=null,m=()=>{let e=window.getComputedStyle(t).getPropertyValue(`--xterm-cell-height`).trim(),n=Number.parseFloat(e);return!Number.isNaN(n)&&n>0?n:Math.round(w*T)},h=()=>t.querySelector(`.xterm-helper-textarea`),g=e=>{let n=Ee.current;if(!n)return null;let r=(t.querySelector(`.xterm`)?.querySelector(`.xterm-screen`))?.getBoundingClientRect();if(!r||r.width<=0||r.height<=0)return null;let i=r.width/n.cols,a=r.height/n.rows;return i<=0||a<=0?null:{col:Math.min(n.cols,Math.max(1,Math.floor((e.clientX-r.left)/i)+1)),row:Math.min(n.rows,Math.max(1,Math.floor((e.clientY-r.top)/a)+1))}},_=()=>{let e=h();e&&document.activeElement!==e&&(e.disabled=!0)},v=()=>{let e=h();e&&(e.disabled=!1)};_();let y=()=>{if(Oe.current)return;let e=h();e&&(e.disabled=!1,e.focus())},b=()=>{u!==null&&(cancelAnimationFrame(u),u=null),s=0},x=()=>{d!==null&&(clearTimeout(d),d=null)},S=(e,t,n)=>{let r=Qe.current;return r?($e.current({type:`terminal-input`,sessionId:r,data:`\x1b[<${e};${t.col};${t.row}${n}`}),!0):!1},C=e=>{let t=Qe.current;if(!t||e===0)return!1;let n=Ee.current,r=n?.cols??80,i=n?.rows??24,a=Math.floor(r/2),o=Math.floor(i/2),s=e>0?65:64,c=Math.abs(e),l=e<0;for(let e=0;e<c;e++)$e.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${s};${a};${o}M`});return l&&!Ae.current&&je(!0),l},E=e=>{let t=Qe.current,n=g(e);return!t||!n?!1:($e.current({type:`terminal-input`,sessionId:t,data:`\x1b[<0;${n.col};${n.row}M\x1b[<0;${n.col};${n.row}m`}),!0)},D=e=>{if(!k||!Ae.current)return!1;let t=g(e);return t?(f=!0,p=t,_(),WU(),S(0,t,`M`)):!1},O=e=>{let t=g(e);return t?p&&p.col===t.col&&p.row===t.row?!0:(p=t,S(32,t,`M`)):!1},j=e=>{let t=e?g(e):p;return f=!1,p=null,t?S(0,t,`m`):!1},M=()=>{x(),f=!1,p=null,a=null,s=0,c=0},N=()=>{if(!k)return!1;let e=window.getSelection();if(!e||e.isCollapsed)return!1;let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},P=()=>{!k||!U.current||N()||ie.current?.()},F=e=>{if(b(),P(),Ve.current||z){M();return}if(Ze.current){M();return}if(tt.current===`armed`&&!Oe.current&&(tt.current=`idle`,y()),e.touches.length===1){let t=e.touches[0];if(n={x:t.clientX,y:t.clientY},r=performance.now(),i=!1,a=t.clientY,o=r,s=0,c=0,l=m(),v(),k&&Ae.current){let e={clientX:t.clientX,clientY:t.clientY};d=setTimeout(()=>{d=null,!(i||Ve.current||z)&&(Ze.current||N()||D(e))},350)}}},I=e=>{if(e.touches.length!==1||a===null)return;if(P(),Ve.current||z){M();return}let t=performance.now(),r=e.touches[0],u=r.clientX,d=r.clientY;if(f){e.preventDefault(),e.stopPropagation(),O(r),a=d,o=t;return}if(Ze.current||N()){M();return}e.preventDefault(),e.stopPropagation();let p=Math.abs(u-n.x),m=Math.abs(d-n.y);!i&&(p>6||m>6)&&(i=!0,x(),_());let h=a-d,g=t-o;if(a=d,o=t,g>0){let e=h/g;s=s*.7+e*.3}c+=h;let v=Math.max(6,l*.6),y=Math.trunc(c/v);y!==0&&(C(y),c-=y*v)},L=e=>{let t=s,n=performance.now()-r;if(x(),f){j(e.changedTouches[0]),M(),e.preventDefault(),e.stopPropagation();return}if(M(),Ve.current||z)return;let a=N();if(Ze.current&&!a&&ie.current?.(),Ze.current||a){Oe.current&&(et.current=!0);return}if(!i){if(k&&n>=350)return;if(Ae.current){let t=e.changedTouches[0];if(t&&E(t)){y(),e.preventDefault(),e.stopPropagation();return}}if(Oe.current){e.preventDefault(),e.stopPropagation(),et.current=!0;return}y();return}if(Math.abs(t)>.12){let e=t,n=performance.now(),r=()=>{let t=performance.now(),i=t-n;n=t;let a=e*i;c+=a;let o=Math.max(6,l*.6),s=Math.trunc(c/o);s!==0&&(C(s),c-=s*o),e*=.95**(i/16.67),u=Math.abs(e)>.02?requestAnimationFrame(r):null};u=requestAnimationFrame(r)}},ee=e=>{et.current&&=(e.preventDefault(),e.stopPropagation(),!1)},R={passive:!0,capture:!0},B={passive:!1,capture:!0},te={passive:!1,capture:!0},V={capture:!0};return t.addEventListener(`touchstart`,F,R),t.addEventListener(`touchmove`,I,B),t.addEventListener(`touchend`,L,te),t.addEventListener(`mousedown`,ee,V),()=>{t.removeEventListener(`touchstart`,F,R),t.removeEventListener(`touchmove`,I,B),t.removeEventListener(`touchend`,L,te),t.removeEventListener(`mousedown`,ee,V),x();let e=h();e&&(e.disabled=!1)}},[e?.id,we,Ee,k,A,z,w,T]);let nt=(0,x.useCallback)(t=>{!e||ve||!Pe||s({type:`terminal-input`,sessionId:e.id,data:t})},[e,ve,Pe,s]),rt=(0,x.useCallback)(t=>{!e||ve||!Pe||(Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1)),s({type:`terminal-paste`,sessionId:e.id,data:t}))},[e,ve,Pe,s,Oe,je]),it=(0,x.useCallback)(t=>{!e||ve||!Pe||(Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1)),nt(t))},[e,ve,Pe,s,Oe,je,nt]),at=(0,x.useCallback)(()=>{let e=we.current;if(!e)return;let t=e.querySelector(`.xterm-helper-textarea`);t&&(t.removeAttribute(`disabled`),t.focus())},[we]),ot=EU({sessionId:e?.id??null,disabled:a!==`connected`||ve||!Pe,fileUploadsAllowed:!fe,agentType:e?.agentType,onPasteText:rt,onPasteImage:it,onRefocus:at});le.current=ot.paste,ue.current=ot.fail;let st=(0,x.useCallback)(()=>{if(!e||ve||!Pe)return;Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1));let t=we.current;if(!t)return;let n=t.querySelector(`.xterm-helper-textarea`);n&&(n.removeAttribute(`disabled`),n.focus())},[e,ve,Pe,s,we,Oe,je]),ct=(0,x.useCallback)(()=>{if(typeof document>`u`)return!1;let e=we.current;if(!e)return!1;let t=e.querySelector(`.xterm-helper-textarea`);if(t&&document.activeElement===t)return!0;let n=document.activeElement,r=typeof HTMLInputElement<`u`&&n instanceof HTMLInputElement,i=typeof HTMLTextAreaElement<`u`&&n instanceof HTMLTextAreaElement;return r||i||n&&n.isContentEditable?!1:!!document.documentElement?.classList?.contains(`keyboard-visible`)},[we]);(0,x.useEffect)(()=>{if(!k)return;let e=we.current;if(!e)return;let t=e.querySelector(`.xterm-accessibility`),n=e.querySelector(`.xterm-accessibility-tree`);if(!t||!n)return;let r=()=>{let r=e.querySelector(`.xterm-helper-textarea`);r&&document.activeElement===r&&!Ze.current?(t.style.pointerEvents=`none`,n.style.pointerEvents=`none`):(t.style.removeProperty(`pointer-events`),n.style.removeProperty(`pointer-events`))};return r(),document.addEventListener(`focusin`,r),document.addEventListener(`focusout`,r),()=>{document.removeEventListener(`focusin`,r),document.removeEventListener(`focusout`,r)}},[we,k,N]),(0,x.useEffect)(()=>{let e=we.current;e&&(e.inert=!!n)},[we,n]);let lt=(0,x.useMemo)(()=>{if(!ge||t.length===0)return!1;let e=t.map(e=>e.name.trim()).filter(Boolean);return e.length===t.length&&new Set(e).size===t.length},[ge,t]);return(0,W.jsxs)(`section`,{className:`flex flex-1 flex-col bg-base terminal-mobile-overlay md:relative md:inset-auto ${k?`ios-native-term-selection`:``}`,"data-testid":`terminal-panel`,onDragOver:t=>{Array.from(t.dataTransfer.types).includes(`Files`)&&(t.preventDefault(),t.dataTransfer.dropEffect=e&&!ve&&Pe&&!fe&&a===`connected`?`copy`:`none`)},onDrop:t=>{if(!Array.from(t.dataTransfer.types).includes(`Files`)||(t.preventDefault(),t.stopPropagation(),!e||ve||!Pe||fe||a!==`connected`))return;let n=iH(t.dataTransfer);n.length&&ot.paste({text:``,files:n})},children:[(0,W.jsxs)(`div`,{className:`flex min-h-[52px] shrink-0 items-center justify-between border-b border-border bg-elevated px-[6px] md:h-10 md:min-h-0 md:px-3 ${e||n?``:`md:hidden`}`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[7px] md:gap-3`,children:[(0,W.jsx)(`button`,{onClick:()=>B(!0),className:`flex size-[44px] shrink-0 items-center justify-center rounded border border-border bg-surface text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95 md:hidden`,"aria-label":`Open session menu`,children:(0,W.jsx)(Te,{width:16,height:16})}),e&&ye&&(0,W.jsx)(`button`,{disabled:Me,onClick:()=>I(!0),className:`hidden md:flex h-7 w-7 items-center justify-center rounded bg-danger/10 border border-danger/30 text-danger hover:bg-danger/20 active:scale-95 transition-all shrink-0 disabled:cursor-not-allowed disabled:opacity-40`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,W.jsx)(Ue,{width:16,height:16})}),Ce&&(0,W.jsx)(`button`,{onClick:Ge,className:`hidden md:flex h-7 w-7 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all shrink-0`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,W.jsx)(De,{width:16,height:16})}),e?(0,W.jsxs)(`div`,{className:`flex min-w-[72px] flex-col items-start gap-px leading-none md:min-w-0 md:flex-row md:items-baseline md:gap-3 md:leading-normal`,children:[te?(0,W.jsx)(`input`,{ref:se,type:`text`,value:ne,onChange:e=>re(e.target.value),onBlur:Je,onKeyDown:Xe,className:`w-full max-w-[112px] rounded border border-border bg-surface px-2 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent md:max-w-[200px]`}):(0,W.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:e.agentSessionName||e.name}),(0,W.jsx)(`span`,{className:`shrink-0 text-[10px] md:hidden ${a===`connected`?VU[e.status]:`text-approval`}`,children:a===`connected`?BU[e.status]:a}),(0,W.jsx)(`span`,{className:`hidden shrink-0 text-xs md:inline ${VU[e.status]}`,children:BU[e.status]})]}):n?(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-px leading-none md:flex-row md:items-baseline md:gap-2 md:leading-normal`,children:[(0,W.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:be}),(0,W.jsx)(`span`,{className:`text-[10px] font-medium text-blue-400 md:rounded-full md:bg-blue-500/15 md:px-1.5 md:py-0.5 md:uppercase md:tracking-wide`,children:`Hibernating`})]}):(0,W.jsx)(`span`,{className:`text-sm font-medium text-primary md:hidden`,children:`Sessions`})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[4px] md:gap-1.5`,children:[a!==`connected`&&(0,W.jsx)(`span`,{className:`hidden text-xs text-approval md:inline`,children:a}),(0,W.jsx)(`button`,{onClick:f,className:`flex size-[44px] items-center justify-center rounded bg-accent text-white transition-all hover:bg-accent/90 active:scale-95 md:hidden`,title:`New session (${O}N)`,"aria-label":`New session`,children:(0,W.jsx)(Ne,{width:16,height:16})}),e&&ye&&(0,W.jsx)(`button`,{disabled:Me,onClick:()=>I(!0),className:`flex size-[44px] items-center justify-center rounded border border-danger/30 bg-danger/10 text-danger transition-all hover:bg-danger/20 active:scale-95 disabled:cursor-not-allowed disabled:opacity-40 md:hidden`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,W.jsx)(Ue,{width:16,height:16})}),Ce&&(0,W.jsx)(`button`,{onClick:Ge,className:`hidden size-[44px] items-center justify-center rounded border border-border text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95 min-[360px]:flex md:hidden`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,W.jsx)(De,{width:16,height:16})}),n&&(0,W.jsx)(`button`,{onClick:()=>h(n.sessionId),className:`btn btn-primary h-[44px] px-3 text-xs md:hidden`,children:`Wake`}),e&&(0,W.jsxs)(`div`,{className:`relative md:hidden`,ref:oe,children:[(0,W.jsx)(`button`,{onClick:()=>R(!L),className:`flex size-[44px] items-center justify-center rounded border border-border bg-surface text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95`,title:`More options`,"aria-label":`More options`,children:(0,W.jsx)(he,{width:16,height:16})}),L&&(0,W.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border bg-elevated shadow-lg py-1`,children:[ye&&(0,W.jsxs)(`button`,{onClick:Ke,className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(_e,{width:14,height:14}),`Rename`]}),Ce&&(0,W.jsxs)(`button`,{onClick:Ge,className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(De,{width:14,height:14}),`Hibernate`]}),(0,W.jsxs)(`button`,{onClick:()=>{v(),R(!1)},className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(Le,{width:14,height:14}),`Settings`]})]})]})]})]}),e&&t.length>1&&(0,W.jsxs)(`div`,{className:`relative overflow-hidden bg-elevated border-b border-border md:hidden`,children:[(0,W.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-4 bg-gradient-to-l from-elevated to-transparent z-10 pointer-events-none`}),(0,W.jsx)(`div`,{className:`flex items-center gap-[6px] overflow-x-auto px-[8px] py-[5px] scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:t.map((t,n)=>{let r=t.id===e.id,i=lt?t.name.trim():n+1;return(0,W.jsx)(`button`,{type:`button`,className:`
|
|
299
300
|
flex items-center justify-center shrink-0 snap-start
|
|
300
301
|
h-[44px] ${lt?`min-w-[44px] px-2.5 max-w-[8rem] truncate`:`w-[44px]`}
|
|
301
302
|
text-sm font-extrabold rounded-lg
|
|
302
303
|
active:scale-95 transition-all duration-75
|
|
303
304
|
select-none touch-manipulation
|
|
304
|
-
${r?
|
|
305
|
-
`,onClick:()=>{HU(),u(t.id)},title:lt?t.name:void 0,children:i},t.id)})})]}),(0,W.jsxs)(`div`,{className:`relative flex-1`,children:[(0,W.jsx)(`div`,{ref:we,className:`absolute inset-0`,style:{backgroundColor:S.background}}),Me&&e&&(0,W.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,W.jsxs)(`svg`,{className:`h-3 w-3 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,W.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,W.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Loading`]}),Fe&&e&&(0,W.jsxs)(`div`,{className:`absolute ${j&&!N?`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:left-auto md:right-4 md:translate-x-0`,children:[(0,W.jsx)(`span`,{className:`max-w-[12rem] truncate text-xs text-secondary md:max-w-[18rem]`,children:`Selection ready`}),(0,W.jsxs)(`button`,{type:`button`,onClick:Ie,className:`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`,title:`Copy selection`,"aria-label":`Copy selection`,children:[(0,W.jsx)(de,{width:14,height:14}),`Copy`]}),(0,W.jsx)(`button`,{type:`button`,onClick:Re,className:`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`,title:`Dismiss`,"aria-label":`Dismiss`,children:(0,W.jsx)(Ue,{width:14,height:14})})]}),!e&&(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted`,children:n?null:`Select a session to view terminal`}),e&&ve&&(0,W.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.`}),n&&(0,W.jsx)(`div`,{className:`absolute inset-0 z-10 overflow-y-auto bg-base`,children:(0,W.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,W.jsx)(`div`,{className:`border-b border-border pb-4`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,W.jsx)(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-primary`,children:be}),(0,W.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`}),xe&&(0,W.jsx)(`span`,{className:`text-muted`,children:xe}),(0,W.jsxs)(`span`,{className:`text-muted`,children:[`Last active `,Se]})]}),n.lastResumeError&&(0,W.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: ${n.lastResumeError}`,children:[(0,W.jsx)(ae,{width:12,height:12}),`Last wake failed`]}),n.lastUserMessage&&(0,W.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:n.lastUserMessage})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>h(n.sessionId),className:`btn btn-primary hidden md:inline-flex`,children:`Wake`}),_&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>_(n.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,W.jsx)(HT,{session:n})]})}),ke&&e&&!N?(0,W.jsxs)(`button`,{type:`button`,onClick:ze,className:`absolute bottom-14 left-1/2 z-20 flex h-10 items-center justify-center overflow-hidden 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:bottom-8`,style:{transform:`translateX(-50%)`},title:`Exit tmux copy mode and return to live output`,"aria-label":`Exit copy mode`,children:[(0,W.jsx)(`span`,{className:`px-3 text-[11px] font-semibold uppercase tracking-wide`,children:`Copy mode`}),(0,W.jsx)(`span`,{className:`self-stretch border-l border-amber-400/25`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`px-3 text-sm font-medium`,children:`Exit`})]}):j&&e&&!N?(0,W.jsxs)(`button`,{type:`button`,onClick:ze,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`,style:{transform:`translateX(-50%)`},title:`Scroll to bottom`,"aria-label":`Scroll to bottom`,children:[(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`path`,{d:`M12 5v14M5 12l7 7 7-7`})}),(0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]}):null]}),(0,W.jsx)(SU,{...ot}),e&&(0,W.jsx)(IU,{onSendKey:nt,onPasteText:rt,onPasteImage:it,disabled:a!==`connected`||ve||!Pe,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,agentType:e.agentType,fileUploadsAllowed:!fe,onSelectSession:u,hideSessionSwitcher:!0,onRefocus:at,isKeyboardVisible:ct,onEnterTextMode:st}),(A||k)&&(0,W.jsx)(LU,{isOpen:z,onClose:()=>B(!1),sessions:t,hibernatingSessions:r,historySessions:i,selectedSessionId:e?.id??null,selectedHibernatingSessionId:n?.sessionId??null,onSelect:u,onSelectHibernating:d,onRename:m,onResume:h,onHibernate:g,onMoveToHistory:_,onNewSession:f,loading:y,error:b}),F&&e&&(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,W.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,W.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,W.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,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{onClick:()=>I(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,W.jsx)(`button`,{ref:ce,onClick:He,className:`btn btn-danger py-1.5 px-3 text-sm`,children:`Kill Session`})]})]})})]})}function WU({onSelect:e,onCancel:t,initialPath:n}){let[r,i]=(0,x.useState)(n||`~`),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(!0),[d,f]=(0,x.useState)(-1),p=(0,x.useRef)(null),m=H(e=>e.recentPaths),h=(0,x.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,x.useEffect)(()=>(h(n||`~`),()=>{p.current?.abort()}),[h,n]);let g=a?.directories??[],_=a?.path||r,v=a?.parent;return(0,x.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,W.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,W.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,W.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,W.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,W.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,W.jsx)(`p`,{className:`text-danger`,children:s}),(0,W.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,W.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,W.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,W.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,W.jsx)(xe,{width:14,height:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,W.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,W.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,W.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,W.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,W.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,W.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function GU({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,x.useState)(``),[h,g]=(0,x.useState)(``),[_,v]=(0,x.useState)(null),[y,b]=(0,x.useState)(``),[S,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(``),E=(0,x.useRef)(null),D=(0,x.useRef)(null),O=(0,x.useRef)(null),k=l&&c.length>0;if((0,x.useEffect)(()=>{if(!e){m(``),g(``),v(null),b(``),C(!1),T(u??``),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(``),T(u??``);let t=f?.trim();if(t){let e=i.find(e=>te(e)===t);e?(v(e.id),b(te(e))):(v(null),b(t))}else{let e=i.find(e=>e.id===a);e?(v(a),b(te(e))):i.length>0?(v(i[0].id),b(te(i[0]))):(v(null),b(``))}setTimeout(()=>{if(O.current?.focus(),D.current){let e=D.current;e.scrollLeft=e.scrollWidth}},50)},[s,i,a,r,e,o,u,d,f]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=()=>E.current?Array.from(E.current.querySelectorAll(`input:not([disabled]), select:not([disabled]), button:not([disabled]):not([tabindex="-1"]), [tabindex="0"]`)):[],r=e=>{if(!S){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(),E.current?.requestSubmit();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,S]),!e)return null;let A=e=>{let t=i.find(t=>t.id===e);t&&(v(e),b(te(t)))},j=()=>{v(null),b(``)},M=_===null,N=w!==``,P=e=>{e.preventDefault();let r=p.trim();if(!r)return;let i=y.trim();n(r,h.trim()||void 0,i||void 0,N?w:void 0),t()},F=[...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}],I=[{id:``,label:`Local`,ok:!0,error:void 0},...c.map(e=>({id:e.host,label:e.host,ok:e.ok,error:e.error}))],L=p.trim()||`~`;return(0,W.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-session-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:[(0,W.jsxs)(`form`,{ref:E,onSubmit:P,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,W.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[k&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Host`,"data-testid":`host-select`,children:I.map((e,t)=>{let n=w===e.id,r=!e.ok&&!n;return(0,W.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:()=>T(e.id),onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%I.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+I.length)%I.length;else return;let r=I[n];T(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,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Command preset`,"data-testid":`command-select`,children:F.map((e,t)=>{let n=e.isCustom?M:_===e.id;return(0,W.jsxs)(`button`,{ref:n?O:void 0,type:`button`,role:`radio`,"aria-checked":n,tabIndex:n?0:-1,onClick:()=>{e.isCustom?j():A(e.id)},onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%F.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+F.length)%F.length;else return;let r=F[n];r.isCustom?j():A(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:[(0,W.jsx)(eh,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,W.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{ref:D,value:p,onChange:e=>m(e.target.value),placeholder:N?`/home/user/project`:s||o||r||`/Users/you/code/my-project`,className:`input flex-1 text-sm`}),!N&&(0,W.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>C(!0),children:`Browse`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,W.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,W.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),S&&!N&&(0,W.jsx)(WU,{initialPath:L,onSelect:e=>{m(e),C(!1)},onCancel:()=>C(!1)})]})}function KU({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=x.useRef(e!==void 0),[a,o]=x.useState(t);return[i?e:a,x.useCallback(e=>{i||o(e)},[])]}var qU={};function JU(e,t){let n=x.useRef(qU);return n.current===qU&&(n.current=e(t)),n}var YU=x[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],XU=YU&&YU!==x.useLayoutEffect?YU:e=>e();function ZU(e){let t=JU(QU).current;return t.next=e,XU(t.effect),t.trampoline}function QU(){let e={next:void 0,callback:$U,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function $U(){}function eW(e,t,n,r){let i=JU(nW).current;return rW(i,e,t,n,r)&&aW(i,[e,t,n,r]),i.callback}function tW(e){let t=JU(nW).current;return iW(t,e)&&aW(t,e),t.callback}function nW(){return{callback:null,cleanup:null,refs:[]}}function rW(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function iW(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function aW(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 oW=typeof document<`u`?x.useLayoutEffect:()=>{},sW={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},cW={...sW,position:`fixed`,top:0,left:0},lW={...sW,position:`absolute`};function uW(){}Object.freeze([]);var dW=Object.freeze({});function fW(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 pW=18;function mW(e){return pW>=e}function hW(e){if(!x.isValidElement(e))return null;let t=e,n=t.props;return(mW(19)?n?.ref:t.ref)??null}function gW(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function _W(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 vW(e,t){return typeof e==`function`?e(t):e}function yW(e,t){return typeof e==`function`?e(t):e}var bW={};function xW(e,t,n,r,i){let a={...DW(e,bW)};return t&&(a=CW(a,t)),n&&(a=CW(a,n)),r&&(a=CW(a,r)),i&&(a=CW(a,i)),a}function SW(e){if(e.length===0)return bW;if(e.length===1)return DW(e[0],bW);let t={...DW(e[0],bW)};for(let n=1;n<e.length;n+=1)t=CW(t,e[n]);return t}function CW(e,t){return EW(t)?t(e):wW(e,t)}function wW(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=gW(e.style,r);break;case`className`:e[n]=AW(e.className,r);break;default:TW(n,r)?e[n]=OW(e[n],r):e[n]=r}}return e}function TW(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 EW(e){return typeof e==`function`}function DW(e,t){return EW(e)?e(t):e??bW}function OW(e,t){return t?e?n=>{if(jW(n)){let r=n;kW(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function kW(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function AW(e,t){return t?e?t+` `+e:t:e}function jW(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function MW(e,t,n={}){let r=t.render,i=NW(t,n);return n.enabled===!1?null:FW(e,r,i,n.state??dW)}function NW(e,t={}){let{className:n,style:r,render:i}=e,{state:a=dW,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?vW(n,a):void 0,d=l?yW(r,a):void 0,f=l?_W(a,c):dW,p=l?gW(f,Array.isArray(s)?SW(s):s)??dW:dW;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=tW([p.ref,hW(i),...o]):p.ref=eW(p.ref,hW(i),o):eW(null,null)),l?(u!==void 0&&(p.className=AW(p.className,u)),d!==void 0&&(p.style=gW(p.style,d)),p):dW}var PW=Symbol.for(`react.lazy`);function FW(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=xW(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===PW&&(i=x.Children.toArray(t)[0]),x.cloneElement(i,e)}if(e&&typeof e==`string`)return IW(e,n);throw Error(fW(8))}function IW(e,t){return e===`button`?(0,x.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,x.createElement)(`img`,{alt:``,...t,key:t.key}):x.createElement(e,t)}var LW={...x},RW=0;function zW(e,t=`mui`){let[n,r]=x.useState(e),i=e||n;return x.useEffect(()=>{n??(RW+=1,r(`${t}-${RW}`))},[n,t]),i}var BW=LW.useId;function VW(e,t){if(BW!==void 0){let n=BW();return e??(t?`${t}-${n}`:n)}return zW(e,t)}function HW(e){return VW(e,`base-ui`)}function UW(){return typeof window<`u`}function WW(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function GW(e){return UW()?e instanceof Element||e instanceof WW(e).Element:!1}function KW(e){return UW()?e instanceof HTMLElement||e instanceof WW(e).HTMLElement:!1}function qW(e){return!UW()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof WW(e).ShadowRoot}var JW=x.createContext(void 0);function YW(e=!1){let t=x.useContext(JW);if(t===void 0&&!e)throw Error(fW(16));return t}function XW(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:x.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 ZW(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=x.useRef(null),o=YW(!0)!==void 0,s=ZU(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=XW({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=x.useCallback(()=>{let e=a.current;QW(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return oW(l,[l]),{getButtonProps:x.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return xW({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(kW(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||(kW(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:ZU(e=>{a.current=e,l()})}}function QW(e){return KW(e)&&e.tagName===`BUTTON`}var $W=x.createContext(void 0);function eG(){let e=x.useContext($W);if(e===void 0)throw Error(fW(63));return e}var tG=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}({}),nG={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},rG={valid(e){return e===null?null:e?{[tG.valid]:``}:{[tG.invalid]:``}}},iG=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}({}),aG={...rG,checked(e){return e?{[iG.checked]:``}:{[iG.unchecked]:``}}};function oG(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var sG=x.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:uW,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function cG(){return x.useContext(sG)}var lG=x.createContext({invalid:void 0,name:void 0,validityData:{state:nG,errors:[],error:``,value:``,initialValue:null},setValidityData:uW,disabled:void 0,touched:!1,setTouched:uW,dirty:!1,setDirty:uW,filled:!1,setFilled:uW,focused:!1,setFocused:uW,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=dW)=>e,getInputValidationProps:(e=dW)=>e,inputRef:{current:null},commit:async()=>{}}});function uG(e=!0){let t=x.useContext(lG);if(t.setValidityData===uW&&!e)throw Error(fW(28));return t}function dG(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=cG(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=uG(),f=ZU(e.getValue);oW(()=>{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]),oW(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:oG(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?U.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),oW(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var fG=x.createContext({controlId:void 0,registerControlId:uW,labelId:void 0,setLabelId:uW,messageIds:[],setMessageIds:uW,getDescriptionProps:e=>e});function pG(){return x.useContext(fG)}function mG(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=pG(),o=HW(t),s=n?i:void 0,c=JU(()=>Symbol(`labelable-control`)),l=x.useRef(!1),u=x.useRef(t!=null),d=ZU(()=>{!l.current||a===uW||(l.current=!1,a(c.current,void 0))});return oW(()=>{if(a===uW)return;let e;if(n){let n=r?.current;e=GW(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]),x.useEffect(()=>d,[d]),i??o}var hG=`none`;function gG(e,t,n,r){let i=!1,a=!1,o=r??dW;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 _G(e,t){let n=x.useRef(e),r=ZU(t);oW(()=>{n.current!==e&&r(n.current)},[e,r]),oW(()=>{n.current=e},[e])}var vG=x.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:_}=cG(),{state:v,setTouched:y,setDirty:b,validityData:S,setFilled:C,setFocused:w,shouldValidateOnChange:T,validationMode:E,disabled:D,name:O,validation:k}=uG(),{labelId:A}=pG(),j=D||f,M=O??s,N=ZU(l),P=x.useRef(null),F=eW(P,o,k.inputRef),I=x.useRef(null),L=HW(),ee=mG({id:a,implicit:!1,controlRef:I}),R=c?void 0:ee,[z,B]=KU({controlled:n,default:!!i,name:`Switch`,state:`checked`});dG({id:L,commit:k.commit,value:z,controlRef:I,name:M,getValue:()=>z}),oW(()=>{P.current&&C(P.current.checked)},[P,C]),_G(z,()=>{_(M),b(z!==S.initialValue),C(z),T()?k.commit(z):k.commit(z,!0)});let{getButtonProps:te,buttonRef:V}=ZW({disabled:j,native:c}),ne={id:c?ee:L,role:`switch`,"aria-checked":z,"aria-readonly":u||void 0,"aria-required":d||void 0,"aria-labelledby":A,onFocus(){j||w(!0)},onBlur(){let e=P.current;!e||j||(y(!0),w(!1),E===`onBlur`&&k.commit(e.checked))},onClick(e){u||j||(e.preventDefault(),P.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},H=x.useMemo(()=>xW({checked:z,disabled:j,id:R,name:M,required:d,style:M?lW:cW,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=gG(hG,e.nativeEvent);N?.(t,n),!n.isCanceled&&B(t)},onFocus(){I.current?.focus()}},k.getInputValidationProps,h===void 0?dW:{value:h}),[z,j,F,R,M,N,d,B,k,h]),re=x.useMemo(()=>({...v,checked:z,disabled:j,readOnly:u,required:d}),[v,z,j,u,d]),U=MW(`span`,e,{state:re,ref:[t,I,V],props:[ne,k.getValidationProps,g,te],stateAttributesMapping:aG});return(0,W.jsxs)($W.Provider,{value:re,children:[U,!z&&M&&m!==void 0&&(0,W.jsx)(`input`,{type:`hidden`,name:M,value:m}),(0,W.jsx)(`input`,{...H})]})}),yG=x.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=uG(),o=eG();return MW(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:aG,props:i})});function bG(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=bG(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function xG(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=bG(e))&&(r&&(r+=` `),r+=t);return r}var SG=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},CG=(e,t)=>({classGroupId:e,validator:t}),wG=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),TG=`-`,EG=[],DG=`arbitrary..`,OG=e=>{let t=jG(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return AG(e);let n=e.split(TG);return kG(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?SG(i,t):t:i||EG}return n[e]||EG}}},kG=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=kG(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(TG):e.slice(t).join(TG),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},AG=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?DG+r:void 0})(),jG=e=>{let{theme:t,classGroups:n}=e;return MG(n,t)},MG=(e,t)=>{let n=wG();for(let r in e){let i=e[r];NG(i,n,r,t)}return n},NG=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];PG(i,t,n,r)}},PG=(e,t,n,r)=>{if(typeof e==`string`){FG(e,t,n);return}if(typeof e==`function`){IG(e,t,n,r);return}LG(e,t,n,r)},FG=(e,t,n)=>{let r=e===``?t:RG(t,e);r.classGroupId=n},IG=(e,t,n,r)=>{if(zG(e)){NG(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(CG(n,e))},LG=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];NG(o,RG(t,a),n,r)}},RG=(e,t)=>{let n=e,r=t.split(TG),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=wG(),n.nextPart.set(t,i)),n=i}return n},zG=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,BG=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},VG=`!`,HG=`:`,UG=[],WG=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),GG=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===HG){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(VG)?(c=s.slice(0,-1),l=!0):s.startsWith(VG)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return WG(t,l,c,u)};if(t){let e=t+HG,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):WG(UG,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},KG=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},qG=e=>({cache:BG(e.cacheSize),parseClassName:GG(e),sortModifiers:KG(e),...OG(e)}),JG=/\s+/,YG=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(JG),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+VG:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},XG=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=ZG(n))&&(i&&(i+=` `),i+=r);return i},ZG=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=ZG(e[r]))&&(n&&(n+=` `),n+=t);return n},QG=(e,...t)=>{let n,r,i,a,o=o=>(n=qG(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=YG(e,n);return i(e,a),a};return a=o,(...e)=>a(XG(...e))},$G=[],eK=e=>{let t=t=>t[e]||$G;return t.isThemeGetter=!0,t},tK=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,nK=/^\((?:(\w[\w-]*):)?(.+)\)$/i,rK=/^\d+\/\d+$/,iK=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,aK=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,oK=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,sK=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,cK=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,lK=e=>rK.test(e),uK=e=>!!e&&!Number.isNaN(Number(e)),dK=e=>!!e&&Number.isInteger(Number(e)),fK=e=>e.endsWith(`%`)&&uK(e.slice(0,-1)),pK=e=>iK.test(e),mK=()=>!0,hK=e=>aK.test(e)&&!oK.test(e),gK=()=>!1,_K=e=>sK.test(e),vK=e=>cK.test(e),yK=e=>!Q(e)&&!$(e),bK=e=>MK(e,IK,gK),Q=e=>tK.test(e),xK=e=>MK(e,LK,hK),SK=e=>MK(e,RK,uK),CK=e=>MK(e,PK,gK),wK=e=>MK(e,FK,vK),TK=e=>MK(e,BK,_K),$=e=>nK.test(e),EK=e=>NK(e,LK),DK=e=>NK(e,zK),OK=e=>NK(e,PK),kK=e=>NK(e,IK),AK=e=>NK(e,FK),jK=e=>NK(e,BK,!0),MK=(e,t,n)=>{let r=tK.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},NK=(e,t,n=!1)=>{let r=nK.exec(e);return r?r[1]?t(r[1]):n:!1},PK=e=>e===`position`||e===`percentage`,FK=e=>e===`image`||e===`url`,IK=e=>e===`length`||e===`size`||e===`bg-size`,LK=e=>e===`length`,RK=e=>e===`number`,zK=e=>e===`family-name`,BK=e=>e===`shadow`,VK=QG(()=>{let e=eK(`color`),t=eK(`font`),n=eK(`text`),r=eK(`font-weight`),i=eK(`tracking`),a=eK(`leading`),o=eK(`breakpoint`),s=eK(`container`),c=eK(`spacing`),l=eK(`radius`),u=eK(`shadow`),d=eK(`inset-shadow`),f=eK(`text-shadow`),p=eK(`drop-shadow`),m=eK(`blur`),h=eK(`perspective`),g=eK(`aspect`),_=eK(`ease`),v=eK(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),$,Q],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[$,Q,c],T=()=>[lK,`full`,`auto`,...w()],E=()=>[dK,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,dK,$,Q]},dK,$,Q],O=()=>[dK,`auto`,$,Q],k=()=>[`auto`,`min`,`max`,`fr`,$,Q],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[lK,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,$,Q],F=()=>[...b(),OK,CK,{position:[$,Q]}],I=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],L=()=>[`auto`,`cover`,`contain`,kK,bK,{size:[$,Q]}],ee=()=>[fK,EK,xK],R=()=>[``,`none`,`full`,l,$,Q],z=()=>[``,uK,EK,xK],B=()=>[`solid`,`dashed`,`dotted`,`double`],te=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],V=()=>[uK,fK,OK,CK],ne=()=>[``,`none`,m,$,Q],H=()=>[`none`,uK,$,Q],re=()=>[`none`,uK,$,Q],U=()=>[uK,$,Q],ie=()=>[lK,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[pK],breakpoint:[pK],color:[mK],container:[pK],"drop-shadow":[pK],ease:[`in`,`out`,`in-out`],font:[yK],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[pK],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[pK],shadow:[pK],spacing:[`px`,uK],text:[pK],"text-shadow":[pK],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,lK,Q,$,g]}],container:[`container`],columns:[{columns:[uK,Q,$,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{start:T()}],end:[{end:T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[dK,`auto`,$,Q]}],basis:[{basis:[lK,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[uK,lK,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,uK,$,Q]}],shrink:[{shrink:[``,uK,$,Q]}],order:[{order:[dK,`first`,`last`,`none`,$,Q]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,EK,xK]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,$,SK]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,fK,Q]}],"font-family":[{font:[DK,Q,t]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,$,Q]}],"line-clamp":[{"line-clamp":[uK,`none`,$,SK]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,$,Q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,$,Q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...B(),`wavy`]}],"text-decoration-thickness":[{decoration:[uK,`from-font`,`auto`,$,xK]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[uK,`auto`,$,Q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,$,Q]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,$,Q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:L()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},dK,$,Q],radial:[``,$,Q],conic:[dK,$,Q]},AK,wK]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:ee()}],"gradient-via-pos":[{via:ee()}],"gradient-to-pos":[{to:ee()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:R()}],"rounded-s":[{"rounded-s":R()}],"rounded-e":[{"rounded-e":R()}],"rounded-t":[{"rounded-t":R()}],"rounded-r":[{"rounded-r":R()}],"rounded-b":[{"rounded-b":R()}],"rounded-l":[{"rounded-l":R()}],"rounded-ss":[{"rounded-ss":R()}],"rounded-se":[{"rounded-se":R()}],"rounded-ee":[{"rounded-ee":R()}],"rounded-es":[{"rounded-es":R()}],"rounded-tl":[{"rounded-tl":R()}],"rounded-tr":[{"rounded-tr":R()}],"rounded-br":[{"rounded-br":R()}],"rounded-bl":[{"rounded-bl":R()}],"border-w":[{border:z()}],"border-w-x":[{"border-x":z()}],"border-w-y":[{"border-y":z()}],"border-w-s":[{"border-s":z()}],"border-w-e":[{"border-e":z()}],"border-w-t":[{"border-t":z()}],"border-w-r":[{"border-r":z()}],"border-w-b":[{"border-b":z()}],"border-w-l":[{"border-l":z()}],"divide-x":[{"divide-x":z()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":z()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...B(),`hidden`,`none`]}],"divide-style":[{divide:[...B(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...B(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[uK,$,Q]}],"outline-w":[{outline:[``,uK,EK,xK]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,jK,TK]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,jK,TK]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:z()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[uK,xK]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":z()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,jK,TK]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[uK,$,Q]}],"mix-blend":[{"mix-blend":[...te(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":te()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[uK]}],"mask-image-linear-from-pos":[{"mask-linear-from":V()}],"mask-image-linear-to-pos":[{"mask-linear-to":V()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":V()}],"mask-image-t-to-pos":[{"mask-t-to":V()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":V()}],"mask-image-r-to-pos":[{"mask-r-to":V()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":V()}],"mask-image-b-to-pos":[{"mask-b-to":V()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":V()}],"mask-image-l-to-pos":[{"mask-l-to":V()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":V()}],"mask-image-x-to-pos":[{"mask-x-to":V()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":V()}],"mask-image-y-to-pos":[{"mask-y-to":V()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[$,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":V()}],"mask-image-radial-to-pos":[{"mask-radial-to":V()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[uK]}],"mask-image-conic-from-pos":[{"mask-conic-from":V()}],"mask-image-conic-to-pos":[{"mask-conic-to":V()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,$,Q]}],filter:[{filter:[``,`none`,$,Q]}],blur:[{blur:ne()}],brightness:[{brightness:[uK,$,Q]}],contrast:[{contrast:[uK,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,jK,TK]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,uK,$,Q]}],"hue-rotate":[{"hue-rotate":[uK,$,Q]}],invert:[{invert:[``,uK,$,Q]}],saturate:[{saturate:[uK,$,Q]}],sepia:[{sepia:[``,uK,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[uK,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[uK,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,uK,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[uK,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,uK,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[uK,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[uK,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,uK,$,Q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,$,Q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[uK,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[uK,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:H()}],"rotate-x":[{"rotate-x":H()}],"rotate-y":[{"rotate-y":H()}],"rotate-z":[{"rotate-z":H()}],scale:[{scale:re()}],"scale-x":[{"scale-x":re()}],"scale-y":[{"scale-y":re()}],"scale-z":[{"scale-z":re()}],"scale-3d":[`scale-3d`],skew:[{skew:U()}],"skew-x":[{"skew-x":U()}],"skew-y":[{"skew-y":U()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"translate-none":[`translate-none`],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,$,Q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,$,Q]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[uK,EK,xK,SK]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function HK(...e){return VK(xG(e))}function UK({checked:e,onCheckedChange:t,disabled:n,className:r,ariaLabel:i}){return(0,W.jsx)(vG,{checked:e,onCheckedChange:t,disabled:n,"aria-label":i,className:HK(`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,W.jsx)(yG,{className:HK(`pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform`,`translate-x-1 group-data-[checked]:translate-x-5`)})})}var WK=null,GK=!1,KK={},qK=500;function JK(){if(typeof window>`u`)return null;if(WK?.state===`closed`&&(WK=null),!WK){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;WK=new e}return WK}function YK(){WK&&=(WK.close().catch(()=>{}),null),JK()}function XK(){return GK}function ZK(){WK&&(YK(),GK=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&ZK()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&ZK()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&ZK(),e=t},5e3)}async function QK(){let e=JK();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),GK=!1}async function $K(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function eq(e){let t=JK();if(!t||(await $K(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 tq(){let e=Date.now();if(!(e-(KK.permission||0)<qK)){KK.permission=e;try{await eq({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function nq(){let e=Date.now();if(!(e-(KK.idle||0)<qK)){KK.idle=e;try{await eq({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function rq({isOpen:e,onClose:t}){let n=H(e=>e.defaultProjectDir),r=H(e=>e.setDefaultProjectDir),i=H(e=>e.commandPresets),a=H(e=>e.setCommandPresets),o=H(e=>e.defaultPresetId),s=H(e=>e.setDefaultPresetId),c=H(e=>e.sessionSortMode),l=H(e=>e.setSessionSortMode),u=H(e=>e.sessionSortDirection),d=H(e=>e.setSessionSortDirection),f=H(e=>e.useWebGL),p=H(e=>e.setUseWebGL),m=H(e=>e.fontSize),h=H(e=>e.setFontSize),g=H(e=>e.lineHeight),_=H(e=>e.setLineHeight),v=H(e=>e.letterSpacing),y=H(e=>e.setLetterSpacing),b=H(e=>e.fontOption),S=H(e=>e.setFontOption),C=H(e=>e.customFontFamily),w=H(e=>e.setCustomFontFamily),T=H(e=>e.shortcutModifier),E=H(e=>e.setShortcutModifier),D=H(e=>e.showProjectName),O=H(e=>e.setShowProjectName),k=H(e=>e.showLastUserMessage),A=H(e=>e.setShowLastUserMessage),j=H(e=>e.showSessionIdPrefix),M=H(e=>e.setShowSessionIdPrefix),N=BH(e=>e.theme),F=BH(e=>e.setTheme),I=H(e=>e.soundOnPermission),ee=H(e=>e.setSoundOnPermission),R=H(e=>e.soundOnIdle),z=H(e=>e.setSoundOnIdle),[B,te]=(0,x.useState)(n),[V,ne]=(0,x.useState)(i),[re,U]=(0,x.useState)(o),[ie,ae]=(0,x.useState)(c),[oe,se]=(0,x.useState)(u),[ce,le]=(0,x.useState)(f),[ue,de]=(0,x.useState)(m),[fe,pe]=(0,x.useState)(g),[me,he]=(0,x.useState)(v),[ge,_e]=(0,x.useState)(b),[ve,ye]=(0,x.useState)(C),[be,xe]=(0,x.useState)(T),[Se,Ce]=(0,x.useState)(D),[we,Te]=(0,x.useState)(k),[Ee,De]=(0,x.useState)(j),[Oe,ke]=(0,x.useState)(N),[Ae,je]=(0,x.useState)(I),[Me,Ne]=(0,x.useState)(R),[Pe,Fe]=(0,x.useState)(!0),[Ie,Le]=(0,x.useState)(!1),[Re,ze]=(0,x.useState)(!0),[Be,Ve]=(0,x.useState)(!0),[He,Ue]=(0,x.useState)(!1),[We,Ge]=(0,x.useState)(!1),[Ke,Je]=(0,x.useState)(24),[Xe,Ze]=(0,x.useState)(!1),[Qe,$e]=(0,x.useState)(!1),[et,tt]=(0,x.useState)(``),[nt,rt]=(0,x.useState)(``),[it,at]=(0,x.useState)(``),ot=(0,x.useRef)(null),st=(0,x.useRef)(0);if((0,x.useEffect)(()=>{let t=++st.current;if(ot.current&&=(clearTimeout(ot.current),null),e){if(te(n),ne(i),U(o),ae(c),se(u),le(f),de(m),pe(g),he(v),_e(b),ye(C),xe(T),Ce(D),Te(k),De(j),ke(N),je(I),Ne(R),$e(!1),tt(``),rt(``),at(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>Fe(e.enabled)).catch(()=>{}),Ve(!0),fetch(`/api/settings/terminal-colors`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{st.current===t&&ze(e.enabled)}).catch(()=>{}).finally(()=>{st.current===t&&Ve(!1)}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>Je(e.hours)).catch(()=>{}),fetch(`/api/settings/prefer-window-name`).then(e=>e.json()).then(e=>Ue(e.enabled)).catch(()=>{}),typeof document<`u`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}}else typeof document<`u`&&(ot.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{ot.current&&=(clearTimeout(ot.current),null)}},[i,o,n,c,u,f,m,g,v,b,C,T,D,k,j,N,I,R,e]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=e=>{e.key===`Escape`&&(typeof e.stopPropagation==`function`&&e.stopPropagation(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let ct=e=>{e.preventDefault();let n=B.trim(),i=ce!==f;r(n||`~/Documents/GitHub`),a(V),s(re),l(ie),d(oe),p(ce),h(ue),_(fe),y(me),S(ge),w(ve),E(be),O(Se),A(we),M(Ee),F(Oe),ee(Ae),z(Me),t({webglChanged:i})},lt=(e,t)=>{ne(n=>n.map(n=>n.id===e?{...n,...t}:n))},ut=e=>{let t=V.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=V.filter(t=>t.id!==e);ne(n),e===re&&U(n[0]?.id||`claude`)},dt=()=>{if(!et.trim()||!nt.trim()||V.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:et.trim(),command:nt.trim(),isBuiltIn:!1,agentType:it||void 0};ne([...V,e]),$e(!1),tt(``),rt(``),at(``)},ft=V.length<50,pt=e=>{Le(!0),Fe(e),fetch(`/api/settings/tmux-mouse-mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Fe(!e)).finally(()=>Le(!1))},mt=e=>{Ge(!0),Ue(e),fetch(`/api/settings/prefer-window-name`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Ue(!e)).finally(()=>Ge(!1))},ht=e=>{Ve(!0),ze(e),fetch(`/api/settings/terminal-colors`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>ze(!e)).finally(()=>Ve(!1))},gt=e=>{let t=Ke;Ze(!0),Je(e),fetch(`/api/settings/history-max-age-hours`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hours:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Je(t)).finally(()=>Ze(!1))};return(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,W.jsxs)(`form`,{onSubmit:ct,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,W.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,W.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,W.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,W.jsx)(`input`,{value:B,onChange:e=>te(e.target.value),placeholder:P,className:`input`,autoFocus:!0})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,W.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,W.jsx)(`select`,{value:re,onChange:e=>U(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:V.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,W.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,W.jsx)(`div`,{className:`space-y-3`,children:V.map(e=>(0,W.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,W.jsx)(`input`,{value:e.label,onChange:t=>lt(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>ut(e.id),className:`btn text-xs px-2 py-1 text-error hover:bg-error/10`,children:`Delete`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,W.jsx)(`input`,{value:e.command,onChange:t=>lt(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,W.jsxs)(`select`,{value:e.agentType||``,onChange:t=>lt(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,W.jsx)(`option`,{value:``,children:`Terminal`}),(0,W.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,W.jsx)(`option`,{value:`codex`,children:`Codex`})]})]})]},e.id))}),Qe?(0,W.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,W.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,W.jsx)(`input`,{value:et,onChange:e=>tt(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,W.jsx)(`input`,{value:nt,onChange:e=>rt(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`select`,{value:it,onChange:e=>at(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,W.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,W.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,W.jsx)(`option`,{value:`codex`,children:`Codex Icon`})]}),(0,W.jsx)(`div`,{className:`flex-1`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>$e(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,onClick:dt,disabled:!et.trim()||!nt.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,W.jsx)(`button`,{type:`button`,onClick:()=>$e(!0),disabled:!ft,className:`btn text-xs mt-3 w-full`,children:ft?`+ Add Preset`:`Max 50 presets`})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`created`?`btn-primary`:``}`,onClick:()=>ae(`created`),children:`Created`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`status`?`btn-primary`:``}`,onClick:()=>ae(`status`),children:`Status`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`manual`?`btn-primary`:``}`,onClick:()=>ae(`manual`),children:`Manual`})]}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:ie===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:ie===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),ie===`created`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`desc`?`btn-primary`:``}`,onClick:()=>se(`desc`),children:`Newest First`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`asc`?`btn-primary`:``}`,onClick:()=>se(`asc`),children:`Oldest First`})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,W.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,W.jsx)(UK,{checked:Se,onCheckedChange:Ce})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,W.jsx)(UK,{checked:we,onCheckedChange:Te})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,W.jsx)(UK,{checked:Ee,onCheckedChange:De})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,W.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`number`,min:1,max:168,value:Ke,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&>(t)},disabled:Xe,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,W.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,W.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>void tq(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,W.jsx)(UK,{checked:Ae,onCheckedChange:e=>{je(e),e&&QK()}})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>void nq(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,W.jsx)(UK,{checked:Me,onCheckedChange:e=>{Ne(e),e&&QK()}})]})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,W.jsx)(UK,{checked:ce,onCheckedChange:le})]}),ce!==f&&(0,W.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,W.jsx)(UK,{checked:Pe,onCheckedChange:pt,disabled:Ie})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Terminal Colors`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Preserve ANSI colors for terminal output. Hibernate then Wake running agents after changing this setting.`})]}),(0,W.jsx)(UK,{checked:Re,onCheckedChange:ht,disabled:Be,ariaLabel:`Enable terminal colors`})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Prefer Window Names`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Label discovered sessions with their tmux window name instead of the session name. Applies immediately.`})]}),(0,W.jsx)(UK,{checked:He,onCheckedChange:mt,disabled:We})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>de(Math.max(6,ue-1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,W.jsx)(`span`,{className:`text-sm font-bold`,children:`−`})}),(0,W.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:ue}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>de(Math.min(24,ue+1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,W.jsx)(`span`,{className:`text-sm font-bold`,children:`+`})})]})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:fe,onChange:e=>pe(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,W.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:fe.toFixed(1)})]})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:me,onChange:e=>he(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,W.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[me,`px`]})]})]}),(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,W.jsx)(`select`,{value:ge,onChange:e=>_e(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:L.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),ge===`custom`&&(0,W.jsx)(`input`,{value:ve,onChange:e=>ye(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,W.jsx)(UK,{checked:Oe===`dark`,onCheckedChange:e=>ke(e?`dark`:`light`)})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,W.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,W.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${be===e?`btn-primary`:``}`,onClick:()=>xe(e),children:e===`auto`?`Auto`:Ye(e)},e))}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:be===`auto`?`Shortcuts: ${Ye(qe(`auto`))}+[1-9/N/X/[/]]`:`Shortcuts: ${Ye(be)}+[1-9/N/X/[/]]`})]})]})}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var iq=[];function aq(e){x.useEffect(e,iq)}var oq=x.createContext(void 0);function sq(){let e=x.useContext(oq);if(!e)throw Error(fW(73));return e}var cq=Symbol(`NOT_FOUND`);function lq(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function uq(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function dq(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 fq=e=>Array.isArray(e)?e:[e];function pq(e){let t=Array.isArray(e[0])?e[0]:e;return dq(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function mq(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function hq(e){let t;return{get(n){return t&&e(t.key,n)?t.value:cq},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function gq(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 cq}function i(t,i){r(t)===cq&&(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 _q=(e,t)=>e===t;function vq(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 yq(e,t){let{equalityCheck:n=_q,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=vq(n),o=0,s=r<=1?hq(a):gq(r,a);function c(){let t=s.get(arguments);if(t===cq){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 bq=class{constructor(e){this.value=e}deref(){return this.value}},xq=typeof WeakRef<`u`?WeakRef:bq,Sq=0,Cq=1;function wq(){return{s:Sq,v:void 0,o:null,p:null}}function Tq(e,t={}){let n=wq(),{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=wq(),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=wq(),e.set(n,t)):t=r}}let s=t,c;if(t.s===Cq)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 xq(c):c}return s.s=Cq,s.v=c,c}return o.clearCache=()=>{n=wq(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Eq(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()),lq(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=Tq,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=fq(c),p=fq(u),m=pq(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=mq(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 Dq=Eq(Tq),Oq=Object.assign((e,t=Dq)=>{uq(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:()=>Oq}),kq=Eq({memoize:yq,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),Aq=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(fW(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},jq=(...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(fW(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(fW(2))}u=kq(...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`)}}},Mq=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})),Nq=s(((e,t)=>{t.exports=Mq()})),Pq=s((e=>{var t=p(),n=Nq();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}})),Fq=s(((e,t)=>{t.exports=Pq()})),Iq=[],Lq=void 0;function Rq(){return Lq}function zq(e){Iq.push(e)}var Bq=Nq(),Vq=Fq(),Hq=mW(19)?Gq:Kq;function Uq(e,t,n,r,i){return Hq(e,t,n,r,i)}function Wq(e,t,n,r,i){let a=x.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,Bq.useSyncExternalStore)(e.subscribe,a,a)}zq({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,Bq.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function Gq(e,t,n,r,i){let a=Rq();if(!a)return Wq(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 Kq(e,t,n,r,i){return(0,Vq.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var qq=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 Uq(this,e,t,n,r)}},Jq=class extends qq{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){x.useDebugValue(e),oW(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;oW(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;oW(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){x.useDebugValue(e);let n=t!==void 0;oW(()=>{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 x.useDebugValue(e),Uq(this,this.selectors[e],t,n,r)}useContextCallback(e,t){x.useDebugValue(e);let n=ZU(t??uW);this.context[e]=n}useStateSetter(e){let t=x.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)}})}},Yq=null;globalThis.requestAnimationFrame;var Xq=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)}},Zq=class e{static create(){return new e}static request(e){return Xq.request(e)}static cancel(e){return Xq.cancel(e)}currentId=Yq;request(e){this.cancel(),this.currentId=Xq.request(()=>{this.currentId=Yq,e()})}cancel=()=>{this.currentId!==Yq&&(Xq.cancel(this.currentId),this.currentId=Yq)};disposeEffect=()=>this.cancel};function Qq(){let e=JU(Zq.create).current;return aq(e.disposeEffect),e}var $q=0,eJ=class e{static create(){return new e}currentId=$q;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=$q,t()},e)}isStarted(){return this.currentId!==$q}clear=()=>{this.currentId!==$q&&(clearTimeout(this.currentId),this.currentId=$q)};disposeEffect=()=>this.clear};function tJ(){let e=JU(eJ.create).current;return aq(e.disposeEffect),e}var nJ=0;function rJ(e){return nJ+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${nJ}`}function iJ(e){return e?.ownerDocument||document}function aJ(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 oJ=typeof navigator<`u`,sJ=fJ(),cJ=mJ(),lJ=pJ();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),sJ.platform===`MacIntel`&&sJ.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(sJ.platform),oJ&&/firefox/i.test(lJ);var uJ=oJ&&/apple/i.test(navigator.vendor);oJ&&/Edg/i.test(lJ),oJ&&/android/i.test(cJ)||/android/i.test(lJ),oJ&&cJ.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var dJ=lJ.includes(`jsdom/`);function fJ(){if(!oJ)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 pJ(){if(!oJ)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function mJ(){if(!oJ)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function hJ(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function gJ(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&qW(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function _J(e){return`composedPath`in e?e.composedPath()[0]:e.target}function vJ(e){if(!e||dJ)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var yJ=jq(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}),bJ={toasts:Aq(e=>e.toasts),isEmpty:Aq(e=>e.toasts.length===0),toast:Aq(yJ,(e,t)=>e.get(t)?.value),toastIndex:Aq(yJ,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:Aq(yJ,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:Aq(yJ,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:Aq(e=>e.hovering),focused:Aq(e=>e.focused),expanded:Aq(e=>e.hovering||e.focused),expandedOrOutOfFocus:Aq(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:Aq(e=>e.prevFocusElement)},xJ=class extends Jq{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},bJ)}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=bJ.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||rJ(`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)),bJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=bJ.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)),bJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{bJ.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=aJ(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=aJ(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=aJ(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??=eJ.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=_J(e);gJ(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!bJ.expandedOrOutOfFocus(this.state),a=i?eJ.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=hJ(iJ(this.state.viewport));if(!this.state.viewport||!gJ(this.state.viewport,t)||!vJ(t))return;let n=bJ.toasts(this.state),r=bJ.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()}},SJ=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=JU(()=>new xJ({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return aq(a.disposeEffect),x.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,W.jsx)(oq.Provider,{value:a,children:t})},CJ=x.forwardRef(function(e,t){let[n,r]=x.useState();oW(()=>{uJ&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,W.jsx)(`span`,{...e,ref:t,style:cW,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),wJ=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),TJ=x.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=sq(),s=tJ(),c=x.useRef(!1),l=x.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=x.useMemo(()=>d.some(e=>e.transitionStatus===`ending`),[d]);x.useEffect(()=>{let e=o.state.viewport;if(!e)return;function t(t){u||t.key===`F6`&&t.target!==e&&(t.preventDefault(),o.setPrevFocusElement(hJ(iJ(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=WW(e);return n.addEventListener(`keydown`,t),()=>{n.removeEventListener(`keydown`,t)}},[o,u]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=WW(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=_J(n),i=hJ(iJ(e));(!gJ(e,r)||!vJ(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]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=iJ(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())}x.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 S(){if(c.current){c.current=!1;return}f||vJ(iJ(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function C(e){!f||gJ(o.state.viewport,e.relatedTarget)||(o.setFocused(!1),o.resumeTimers())}let w={tabIndex:-1,role:`region`,"aria-live":`polite`,"aria-atomic":!1,"aria-relevant":`additions text`,"aria-label":`Notifications`,onMouseEnter:y,onMouseMove:y,onMouseLeave:b,onFocus:S,onBlur:C,onKeyDown:v,onClick:S},T={expanded:p},E=MW(`div`,e,{ref:[t,o.setViewport],state:T,props:[w,{style:{[wJ.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,W.jsxs)(x.Fragment,{children:[!u&&m&&(0,W.jsx)(CJ,{onFocus:_}),i,!u&&m&&(0,W.jsx)(CJ,{onFocus:_})]})}]}),D=x.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,W.jsxs)(x.Fragment,{children:[!u&&m&&(0,W.jsx)(CJ,{onFocus:_}),E,!f&&D.length>0&&(0,W.jsx)(`div`,{style:cW,children:D.map(e=>(0,W.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,W.jsx)(`div`,{children:e.title}),(0,W.jsx)(`div`,{children:e.description})]},e.id))})]})});function EJ(e){return mW(19)?e:e?`true`:void 0}var DJ=x.createContext(void 0);function OJ(){let e=x.useContext(DJ);if(!e)throw Error(fW(66));return e}var kJ=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),AJ={[kJ.startingStyle]:``},jJ={[kJ.endingStyle]:``},MJ={transitionStatus(e){return e===`starting`?AJ:e===`ending`?jJ:null}};function NJ(e){return e==null?e:`current`in e?e.current:e}function PJ(e,t=!1,n=!0){let r=Qq();return ZU((i,a=null)=>{r.cancel();function o(){U.flushSync(i)}let s=NJ(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=kJ.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 FJ(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=ZU(i),o=PJ(r,n,!1);x.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var IJ=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}({}),LJ={...MJ,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},RJ=40,zJ=10,BJ=.5,VJ=1;function HJ(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 UJ(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 WJ=x.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=sq(),[d,f]=x.useState(void 0),[p,m]=x.useState(!1),[h,g]=x.useState(!1),[_,v]=x.useState(!1),[y,b]=x.useState({x:0,y:0}),[S,C]=x.useState({x:0,y:0,scale:1}),[w,T]=x.useState(),[E,D]=x.useState(),[O,k]=x.useState(null),A=x.useRef(null),j=x.useRef({x:0,y:0}),M=x.useRef({x:0,y:0,scale:1}),N=x.useRef(void 0),P=x.useRef(0),F=x.useRef(!1),I=x.useRef({x:0,y:0}),L=x.useRef(!1),ee=u.useState(`toastIndex`,n.id),R=u.useState(`toastVisibleIndex`,n.id),z=u.useState(`toastOffsetY`,n.id),B=u.useState(`focused`),te=u.useState(`expanded`);FJ({open:n.transitionStatus!==`ending`,ref:A,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let V=ZU((e=!1)=>{let t=A.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:A,height:i,...n.transitionStatus===`starting`?{transitionStatus:void 0}:{}})}e?U.flushSync(a):a()});oW(V,[V]);function ne(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**BJ:-(Math.abs(e)**BJ):(!c.includes(`right`)&&e>0&&(n=e**BJ),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**BJ))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**BJ:-(Math.abs(t)**BJ):(!c.includes(`down`)&&t>0&&(r=t**BJ),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**BJ))),{x:n,y:r}}function H(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=_J(e.nativeEvent);if(!(t&&t.closest(`button,a,input,textarea,[role="button"],[data-swipe-ignore]`))){if(F.current=!1,N.current=void 0,P.current=0,j.current={x:e.clientX,y:e.clientY},I.current=j.current,A.current){let e=UJ(A.current);M.current=e,C(e),b({x:e.x,y:e.y})}u.setHovering(!0),m(!0),g(!1),k(null),L.current=!0,A.current?.setPointerCapture(e.pointerId)}}function re(e){if(!p)return;e.preventDefault(),L.current&&=(j.current={x:e.clientX,y:e.clientY},!1);let{clientY:t,clientX:n,movementX:r,movementY:i}=e;(i<0&&t>I.current.y||i>0&&t<I.current.y)&&(I.current={x:I.current.x,y:t}),(r<0&&n>I.current.x||r>0&&n<I.current.x)&&(I.current={x:n,y:I.current.y});let a=n-j.current.x,o=t-j.current.y,s=t-I.current.y,l=n-I.current.x;if(!h&&Math.sqrt(a*a+o*o)>=VJ&&(g(!0),O===null)){let e=c.includes(`left`)||c.includes(`right`),t=c.includes(`up`)||c.includes(`down`);e&&t&&k(Math.abs(a)>Math.abs(o)?`horizontal`:`vertical`)}let u;if(!N.current)O===`vertical`?o>0?u=`down`:o<0&&(u=`up`):O===`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)&&(N.current=u,P.current=HJ(u,a,o),f(u));else{let e=N.current,t=HJ(e,l,s);t>RJ?(F.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&P.current-t>=zJ&&(F.current=!0)}let d=ne(a,o),m=M.current.x,_=M.current.y;O===`horizontal`?(c.includes(`left`)||c.includes(`right`))&&(m+=d.x):(O===`vertical`||(c.includes(`left`)||c.includes(`right`))&&(m+=d.x),(c.includes(`up`)||c.includes(`down`))&&(_+=d.y)),b({x:m,y:_})}function ie(e){if(!p)return;if(m(!1),g(!1),k(null),A.current?.releasePointerCapture(e.pointerId),F.current){b({x:S.x,y:S.y}),f(void 0);return}let t=!1,r=y.x-S.x,i=y.y-S.y,a;for(let e of c){switch(e){case`right`:r>RJ&&(t=!0,a=`right`);break;case`left`:r<-RJ&&(t=!0,a=`left`);break;case`down`:i>RJ&&(t=!0,a=`down`);break;case`up`:i<-RJ&&(t=!0,a=`up`);break;default:break}if(t)break}t?(f(a),v(!0),u.closeToast(n.id)):(b({x:S.x,y:S.y}),f(void 0))}function ae(e){if(e.key===`Escape`){if(!A.current||!gJ(A.current,hJ(iJ(A.current))))return;u.closeToast(n.id)}}x.useEffect(()=>{if(!l)return;let e=A.current;if(!e)return;function t(t){gJ(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function oe(){if(!p&&y.x===S.x&&y.y===S.y&&!_)return{[IJ.swipeMovementX]:`0px`,[IJ.swipeMovementY]:`0px`};let e=y.x-S.x,t=y.y-S.y;return{transition:p?`none`:void 0,transform:p?`translateX(${y.x}px) translateY(${y.y}px) scale(${S.scale})`:void 0,[IJ.swipeMovementX]:`${e}px`,[IJ.swipeMovementY]:`${t}px`}}let se=n.priority===`high`,ce={role:se?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":w,"aria-describedby":E,"aria-hidden":se&&!B?!0:void 0,onPointerDown:l?H:void 0,onPointerMove:l?re:void 0,onPointerUp:l?ie:void 0,onKeyDown:ae,inert:EJ(n.limited),style:{...oe(),[IJ.index]:n.transitionStatus===`ending`?ee:R,[IJ.offsetY]:`${z}px`,[IJ.height]:n.height?`${n.height}px`:void 0}},le=x.useMemo(()=>({rootRef:A,toast:n,titleId:w,setTitleId:T,descriptionId:E,setDescriptionId:D,swiping:p,swipeDirection:d,recalculateHeight:V,index:ee,visibleIndex:R,expanded:te}),[n,w,E,p,d,V,ee,R,te]),ue={transitionStatus:n.transitionStatus,expanded:te,limited:n.limited||!1,type:n.type,swiping:le.swiping,swipeDirection:le.swipeDirection},de=MW(`div`,e,{ref:[t,le.rootRef],state:ue,stateAttributesMapping:LJ,props:[ce,o]});return(0,W.jsx)(DJ.Provider,{value:le,children:de})}),GJ=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=OJ(),l=a??s.description,u=!!l,d=VW(i);oW(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=MW(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),KJ=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=OJ(),l=a??s.title,u=!!l,d=VW(i);oW(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=MW(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),qJ=x.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=sq(),{toast:c}=OJ(),l=s.useState(`expanded`),[u,d]=x.useState(!1),{getButtonProps:f,buttonRef:p}=ZW({disabled:i,native:a}),m={type:c.type};return MW(`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 JJ(){let e=x.useContext(oq);if(!e)throw Error(fW(73));let t=e.useState(`toasts`);return x.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function YJ(){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||rJ(`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 XJ=5e3,ZJ=YJ();function QJ({toast:e}){return(0,W.jsxs)(WJ,{toast:e,className:HK(`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-error/50`,e.type===`success`&&`border-approval/50`,(!e.type||e.type===`info`)&&`border-border`),children:[(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsx)(KJ,{className:HK(`text-sm font-medium`,e.type===`error`&&`text-error`,e.type===`success`&&`text-approval`,(!e.type||e.type===`info`)&&`text-primary`),children:e.title}),e.description&&(0,W.jsx)(GJ,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,W.jsx)(qJ,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,W.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function $J(){let{toasts:e}=JJ();return(0,W.jsx)(W.Fragment,{children:e.map(e=>(0,W.jsx)(QJ,{toast:e},e.id))})}function eY(){return(0,W.jsxs)(SJ,{timeout:XJ,toastManager:ZJ,children:[(0,W.jsx)($J,{}),(0,W.jsx)(TJ,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var tY=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],nY=3e3,rY=8e3,iY=15e3,aY=5e3,oY=2e4,sY=1e4,cY=1500,lY=5e3,uY=750,dY=4,fY=5e3,pY=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.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{if(J(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,J(`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=>{J(`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?tY[this.ws.readyState]:null,attempt:this.reconnectAttempts,failures:this.consecutiveFailures,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`){J(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){J(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}J(`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`;J(`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?rY:nY;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(J(`ws_connect_timeout`,{wsState:tY[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){J(`ws_onopen_stale`,this.wsSnap(),`info`);return}J(`ws_onopen`,this.wsSnap(),`info`),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=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(),J(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(lY)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(J(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){J(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}J(`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>iY&&(J(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},aY))}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 J(`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(J(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){J(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(J(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},cY)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){J(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){J(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){J(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,J(`ws_force_reconnect`,{trigger:e,force:t,...this.wsSnap()},`info`),this.reconnectAttempts=0,this.consecutiveFailures=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()},uY)):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,J(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},sY)))};e!==void 0&&e<oY?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,oY)},e):this.heartbeatTimer=window.setInterval(t,oY)}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()){J(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=dY){J(`ws_stall_detected`,this.wsSnap(),`info`),this.purgeLeakedSockets(),this.consecutiveFailures=0,this.reconnectAttempts=0,this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},fY);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);J(`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){J(`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 mY(){let e=qm(e=>e.setConnectionState);return(0,x.useEffect)(()=>{pY.connect(),pY.startLifecycleListeners();let t=pY.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),pY.stopLifecycleListeners()}},[e]),{sendMessage:(0,x.useMemo)(()=>e=>{pY.send(e)},[]),subscribe:(0,x.useMemo)(()=>pY.subscribe.bind(pY),[]),getConnectionEpoch:(0,x.useMemo)(()=>()=>pY.getConnectionEpoch(),[])}}var hY=100;function gY({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>hY?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function _Y(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 vY(){(0,x.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=()=>{gY({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(),_Y(document)}},[])}function yY(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 bY(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(void 0),[i,a]=(0,x.useState)(void 0),[o,s]=(0,x.useState)(void 0),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(null),g=qm(e=>e.sessions),_=qm(e=>e.agentSessions),v=qm(e=>e.agentSessionsEpoch),y=qm(e=>e.selectedSessionId),b=qm(e=>e.selectedHibernatingSessionId),S=qm(e=>e.setSessions),C=qm(e=>e.setAgentSessions),w=qm(e=>e.setActiveAgentSessions),T=qm(e=>e.setHostStatuses),E=qm(e=>e.updateSession),D=qm(e=>e.setSelectedSessionId),O=qm(e=>e.setSelectedHibernatingSessionId),k=qm(e=>e.hasLoaded),A=qm(e=>e.connectionStatus),j=qm(e=>e.connectionError),M=qm(e=>e.clearExitingSession),N=qm(e=>e.markSessionExiting),P=qm(e=>e.setRemoteAllowControl),F=qm(e=>e.setRemoteAllowAttach),I=qm(e=>e.setHostLabel),L=qm(e=>e.setPreferWindowName),ee=qm(e=>e.hostStatuses),R=qm(e=>e.remoteAllowControl),z=qm(e=>e.hostLabel),B=BH(e=>e.theme),te=re(),V=H(e=>e.defaultProjectDir),ne=H(e=>e.commandPresets),ie=H(e=>e.defaultPresetId),ae=H(e=>e.lastProjectPath),oe=H(e=>e.setLastProjectPath),se=H(e=>e.addRecentPath),ce=H(e=>e.shortcutModifier),le=H(e=>e.sidebarWidth),ue=H(e=>e.setSidebarWidth),de=H(e=>e.projectFilters),fe=H(e=>e.hostFilters),pe=H(e=>e.soundOnPermission),me=H(e=>e.soundOnIdle),he=qm(e=>e.connectionEpoch),{sendMessage:ge,subscribe:_e,getConnectionEpoch:ve}=mY();vY(),(0,x.useEffect)(()=>{if(typeof document>`u`||!pe&&!me)return;let e=!1,t=()=>{e&&!XK()||(e=!0,QK())};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)}},[pe,me]);let ye=(0,x.useRef)(!1),be=(0,x.useCallback)(e=>{e.preventDefault(),ye.current=!0,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[]);(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=e=>{if(!ye.current)return;let t=e.clientX;ue(Math.max(180,Math.min(400,t)))},t=()=>{ye.current&&(ye.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)}},[ue]),(0,x.useEffect)(()=>{let e=_e(e=>{if(e.type!==`terminal-output`){if(e.type===`sessions`){let t=qm.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=H.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&&tq(),e.status===`working`&&i.status===`waiting`&&r&&nq())}if(Ie.current.size>0){let e=ve();for(let[t,n]of Ie.current)n.epoch!==e&&Ie.current.delete(t)}let i=Ie.current.size>0?e.sessions.filter(e=>!Ie.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=qm.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(Me.current=s),S(i);let c=Ne.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=qm.getState(),{projectFilters:d,hostFilters:f}=H.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&&(Ne.current=null,D(e.id))}}if(e.type===`host-status`&&T(e.hosts),e.type===`server-config`&&(P(e.remoteAllowControl),F(e.remoteAllowAttach),I(e.hostLabel),L(e.preferWindowName),e.clientLogLevel&&QT(e.clientLogLevel)),e.type===`session-update`){let t=qm.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(E(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=H.getState();t!==`permission`&&n===`permission`&&e&&tq(),t===`working`&&n===`waiting`&&r&&nq()}}if(e.type===`session-created`){let t=qm.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id),se(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=H.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){dH(e.sessionId);let t=qm.getState().sessions,n=t.filter(t=>t.id!==e.sessionId);n.length!==t.length&&S(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}=qm.getState(),a=Me.current;i&&!n.some(e=>e.sessionId===i)&&(Ne.current=i),C(t,n,r),h(e=>e&&n.some(t=>t.sessionId===e.sessionId)?null:e),a&&n.some(e=>e.sessionId===a)?(Me.current=null,O(a)):a&&(Me.current=null)}if(e.type===`agent-sessions-active`&&w(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=qm.getState().sessions,n=t.filter(t=>t.agentSessionId?.trim()!==e.session.sessionId);n.length!==t.length&&S(n)}if(e.type===`session-activated`){let t=qm.getState().sessions.find(t=>t.tmuxWindow===e.window);t&&E({...t,agentSessionId:e.session.sessionId,agentSessionName:e.session.displayName,logFilePath:e.session.logFilePath,isPinned:e.session.isPinned,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=qm.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(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),O(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=Ie.current.get(e.sessionId);if(t){let n=qm.getState().sessions;n.some(t=>t.id===e.sessionId)||S([t.session,...n]),t.wasSelected&&D(e.sessionId),Ie.current.delete(e.sessionId)}M(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,se,M,ge,D,O,h,S,C,w,T,P,F,I,L,_e,E]);let xe=(0,x.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),Se=_.hibernating??[],Ce=_.history??[],we=(0,x.useMemo)(()=>yY(Se,de,fe),[Se,de,fe]),Te=(0,x.useMemo)(()=>we.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[we,m,b]);(0,x.useEffect)(()=>{xe?.projectPath&&!xe.remote&&oe(xe.projectPath)},[xe?.projectPath,xe?.remote,oe]);let Ee=H(e=>e.sessionSortMode),De=H(e=>e.sessionSortDirection),Oe=H(e=>e.manualSessionOrder),ke=(0,x.useMemo)(()=>Mm(g,{mode:Ee,direction:De,manualOrder:Oe}),[g,Ee,De,Oe]),Ae=(0,x.useMemo)(()=>{let e=ke;return de.length>0&&(e=e.filter(e=>de.includes(e.projectPath))),fe.length>0&&(e=e.filter(e=>fe.includes(e.host??``))),e},[ke,de,fe]),je=(0,x.useRef)(b),Me=(0,x.useRef)(null),Ne=(0,x.useRef)(null),Pe=(0,x.useRef)(he),Fe=(0,x.useCallback)(()=>Ae.length>0?(D(Ae[0].id),!0):we.length>0?(O(we[0].sessionId),!0):!1,[Ae,we,D,O]);(0,x.useEffect)(()=>{let e=je.current;e&&b===null&&!Se.some(t=>t.sessionId===e)?Ne.current=e:b!==null&&(Ne.current=null),je.current=b},[Se,b]),(0,x.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,x.useEffect)(()=>{Pe.current!==he&&(Pe.current=he,Me.current=null,Ne.current=null,h(null))},[he]),(0,x.useEffect)(()=>{k&&(b||y&&(Ae.some(e=>e.id===y)||Fe()||D(null)))},[k,y,b,Fe,D]),(0,x.useEffect)(()=>{if(!b||m?.sessionId===b||v!==he||we.some(e=>e.sessionId===b))return;let e=Ae.find(e=>e.agentSessionId?.trim()===b);if(e){D(e.id);return}Fe()||O(null)},[we,Ae,v,m,b,Fe,D,O,he]),(0,x.useEffect)(()=>{let e=Ne.current;if(!e)return;if(b!==null){Ne.current=null;return}let t=Ae.find(t=>t.agentSessionId?.trim()===e);if(t){Ne.current=null,D(t.id);return}if(y!==null){Ne.current=null;return}Fe()&&(Ne.current=null)},[Ae,y,b,Fe,D]),(0,x.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&k&&y===null&&b===null&&(Ae.length>0||we.length>0)&&Fe()},[we.length,Ae.length,k,Fe,y,b]);let Ie=(0,x.useRef)(new Map),Le=(0,x.useCallback)((e,t=`unknown`)=>{dH(e);let{sessions:n,selectedSessionId:r}=qm.getState(),i=n.find(t=>t.id===e);i&&Ie.current.set(e,{session:i,wasSelected:r===e,epoch:ve()}),(0,U.flushSync)(()=>{N(e),S(n.filter(t=>t.id!==e))}),ge({type:`session-kill`,sessionId:e,source:t})},[N,S,ge]);(0,x.useEffect)(()=>{let n=qe(ce),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=Xe(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=i===`BracketLeft`?-1:1,t=Ae;if(t.length===0){let t=we;if(t.length===0)return;let n=t.findIndex(e=>e.sessionId===b);if(n===-1){O(t[0].sessionId);return}O(t[(n+e+t.length)%t.length].sessionId);return}let n=t.findIndex(e=>e.id===y);if(n===-1){D(t[0].id);return}D(t[(n+e+t.length)%t.length].id);return}if(a&&/^Digit[1-9]$/.test(i)){let e=Number(i.slice(5))-1;if(Ae.length>0){let t=Ae[e];if(!t)return;r.preventDefault(),D(t.id);return}let t=we[e];if(!t)return;r.preventDefault(),O(t.sessionId);return}if(a&&i===`KeyN`){r.preventDefault(),!e&&te&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Le(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,D,O,Ae,we,Le,ce,te]);let Re=()=>te?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,ze=()=>l(!0),Be=(e,t,n,r)=>{ge({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||oe(e)},Ve=e=>{ge({type:`session-wake`,sessionId:e})},He=(0,x.useCallback)(e=>{ge({type:`session-hibernate`,sessionId:e})},[ge]),Ue=(e,t)=>{ge({type:`session-rename`,sessionId:e,newName:t})},We=(0,x.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&ge({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,ge]),Ge=(0,x.useCallback)(e=>{ge({type:`session-move-to-history`,sessionId:e})},[ge]);(0,x.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,B)},[B]),(0,x.useEffect)(()=>{fetch(`/api/server-info`).then(e=>e.json()).then(e=>p(e)).catch(()=>{})},[]);let Ke=(0,x.useMemo)(()=>z?ee.filter(e=>e.host!==z):ee,[ee,z]);return(0,W.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:le},children:[(0,W.jsx)($e,{connectionStatus:A,onNewSession:Re,onOpenSettings:ze,tailscaleIp:f?.tailscaleIp??null}),(0,W.jsx)(qT,{sessions:g,hibernatingSessions:Se,historySessions:Ce,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:D,onSelectHibernating:O,onRename:Ue,onResume:Ve,onHibernate:He,onKill:Le,onDuplicate:We,onMoveToHistory:Ge,onNewSession:Re,loading:!k,error:j||u})]}),(0,W.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:be}),(0,W.jsx)(UU,{session:xe,sessions:Ae,hibernatingSession:Te,hibernatingSessions:Se,connectionStatus:A,connectionEpoch:he,sendMessage:ge,subscribe:_e,onClose:()=>D(null),onSelectSession:D,onSelectHibernatingSession:O,onNewSession:Re,onKillSession:Le,onRenameSession:Ue,onOpenSettings:ze,onResumeSession:Ve,onHibernateSession:He,onMoveToHistory:Ge,historySessions:Ce,loading:!k,error:j||u}),(0,W.jsx)(GU,{isOpen:e,onClose:()=>t(!1),onCreate:Be,defaultProjectDir:V,commandPresets:ne,defaultPresetId:ie,lastProjectPath:ae,activeProjectPath:xe&&!xe.remote?xe.projectPath:void 0,remoteHosts:Ke,remoteAllowControl:R,initialHost:n,initialPath:i,initialCommand:o}),(0,W.jsx)(rq,{isOpen:c,onClose:()=>l(!1)}),(0,W.jsx)(eY,{})]})}var xY=`modulepreload`,SY=function(e){return`/`+e},CY={},wY=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=SY(t,n),t in CY)return;CY[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`:xY,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)})},TY=`true`,EY=`false`,DY=TY===`true`,OY=EY===`true`;function kY(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,DY||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await wY(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()},!OY)if(DY)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}We()&&document.documentElement.classList.add(`ios`),Ge()&&document.documentElement.classList.add(`ios-pwa`),kY({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var AY=document.getElementById(`root`);if(!AY)throw Error(`Root element not found`);(0,E.createRoot)(AY).render((0,W.jsx)(x.StrictMode,{children:(0,W.jsx)(bY,{})}));
|
|
305
|
+
${r?UU[t.status]:HU[t.status]}
|
|
306
|
+
`,onClick:()=>{WU(),u(t.id)},title:lt?t.name:void 0,children:i},t.id)})})]}),(0,W.jsxs)(`div`,{className:`relative flex-1`,children:[(0,W.jsx)(`div`,{ref:we,className:`absolute inset-0`,style:{backgroundColor:S.background}}),Me&&e&&(0,W.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,W.jsxs)(`svg`,{className:`h-3 w-3 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,W.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,W.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Loading`]}),Fe&&e&&(0,W.jsxs)(`div`,{className:`absolute ${j&&!N?`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:left-auto md:right-4 md:translate-x-0`,children:[(0,W.jsx)(`span`,{className:`max-w-[12rem] truncate text-xs text-secondary md:max-w-[18rem]`,children:`Selection ready`}),(0,W.jsxs)(`button`,{type:`button`,onClick:Ie,className:`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`,title:`Copy selection`,"aria-label":`Copy selection`,children:[(0,W.jsx)(de,{width:14,height:14}),`Copy`]}),(0,W.jsx)(`button`,{type:`button`,onClick:Re,className:`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`,title:`Dismiss`,"aria-label":`Dismiss`,children:(0,W.jsx)(Ue,{width:14,height:14})})]}),!e&&(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted`,children:n?null:`Select a session to view terminal`}),e&&ve&&(0,W.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.`}),n&&(0,W.jsx)(`div`,{className:`absolute inset-0 z-10 overflow-y-auto bg-base`,children:(0,W.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,W.jsx)(`div`,{className:`border-b border-border pb-4`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,W.jsx)(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-primary`,children:be}),(0,W.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`}),xe&&(0,W.jsx)(`span`,{className:`text-muted`,children:xe}),(0,W.jsxs)(`span`,{className:`text-muted`,children:[`Last active `,Se]})]}),n.lastResumeError&&(0,W.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: ${n.lastResumeError}`,children:[(0,W.jsx)(ae,{width:12,height:12}),`Last wake failed`]}),n.lastUserMessage&&(0,W.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:n.lastUserMessage})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>h(n.sessionId),className:`btn btn-primary hidden md:inline-flex`,children:`Wake`}),_&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>_(n.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,W.jsx)(HT,{session:n})]})}),ke&&e&&!N?(0,W.jsxs)(`button`,{type:`button`,onClick:ze,className:`absolute bottom-14 left-1/2 z-20 flex h-10 items-center justify-center overflow-hidden 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:bottom-8`,style:{transform:`translateX(-50%)`},title:`Exit tmux copy mode and return to live output`,"aria-label":`Exit copy mode`,children:[(0,W.jsx)(`span`,{className:`px-3 text-[11px] font-semibold uppercase tracking-wide`,children:`Copy mode`}),(0,W.jsx)(`span`,{className:`self-stretch border-l border-amber-400/25`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`px-3 text-sm font-medium`,children:`Exit`})]}):j&&e&&!N?(0,W.jsxs)(`button`,{type:`button`,onClick:ze,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`,style:{transform:`translateX(-50%)`},title:`Scroll to bottom`,"aria-label":`Scroll to bottom`,children:[(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`path`,{d:`M12 5v14M5 12l7 7 7-7`})}),(0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]}):null]}),(0,W.jsx)(wU,{...ot}),e&&(0,W.jsx)(RU,{onSendKey:nt,onPasteText:rt,onPasteImage:it,disabled:a!==`connected`||ve||!Pe,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,agentType:e.agentType,fileUploadsAllowed:!fe,onSelectSession:u,hideSessionSwitcher:!0,onRefocus:at,isKeyboardVisible:ct,onEnterTextMode:st}),(A||k)&&(0,W.jsx)(zU,{isOpen:z,onClose:()=>B(!1),sessions:t,hibernatingSessions:r,historySessions:i,selectedSessionId:e?.id??null,selectedHibernatingSessionId:n?.sessionId??null,onSelect:u,onSelectHibernating:d,onRename:m,onResume:h,onHibernate:g,onMoveToHistory:_,onNewSession:f,loading:y,error:b}),F&&e&&(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,W.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,W.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,W.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,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{onClick:()=>I(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,W.jsx)(`button`,{ref:ce,onClick:He,className:`btn btn-danger py-1.5 px-3 text-sm`,children:`Kill Session`})]})]})})]})}function KU({onSelect:e,onCancel:t,initialPath:n}){let[r,i]=(0,x.useState)(n||`~`),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(!0),[d,f]=(0,x.useState)(-1),p=(0,x.useRef)(null),m=H(e=>e.recentPaths),h=(0,x.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,x.useEffect)(()=>(h(n||`~`),()=>{p.current?.abort()}),[h,n]);let g=a?.directories??[],_=a?.path||r,v=a?.parent;return(0,x.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,W.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,W.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,W.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,W.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,W.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,W.jsx)(`p`,{className:`text-danger`,children:s}),(0,W.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,W.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,W.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,W.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,W.jsx)(xe,{width:14,height:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,W.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,W.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,W.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,W.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,W.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,W.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function qU({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,x.useState)(``),[h,g]=(0,x.useState)(``),[_,v]=(0,x.useState)(null),[y,b]=(0,x.useState)(``),[S,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(``),E=(0,x.useRef)(null),D=(0,x.useRef)(null),O=(0,x.useRef)(null),k=l&&c.length>0;if((0,x.useEffect)(()=>{if(!e){m(``),g(``),v(null),b(``),C(!1),T(u??``),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(``),T(u??``);let t=f?.trim();if(t){let e=i.find(e=>te(e)===t);e?(v(e.id),b(te(e))):(v(null),b(t))}else{let e=i.find(e=>e.id===a);e?(v(a),b(te(e))):i.length>0?(v(i[0].id),b(te(i[0]))):(v(null),b(``))}setTimeout(()=>{if(O.current?.focus(),D.current){let e=D.current;e.scrollLeft=e.scrollWidth}},50)},[s,i,a,r,e,o,u,d,f]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=()=>E.current?Array.from(E.current.querySelectorAll(`input:not([disabled]), select:not([disabled]), button:not([disabled]):not([tabindex="-1"]), [tabindex="0"]`)):[],r=e=>{if(!S){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(),E.current?.requestSubmit();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,S]),!e)return null;let A=e=>{let t=i.find(t=>t.id===e);t&&(v(e),b(te(t)))},j=()=>{v(null),b(``)},M=_===null,N=w!==``,P=e=>{e.preventDefault();let r=p.trim();if(!r)return;let i=y.trim();n(r,h.trim()||void 0,i||void 0,N?w:void 0),t()},F=[...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}],I=[{id:``,label:`Local`,ok:!0,error:void 0},...c.map(e=>({id:e.host,label:e.host,ok:e.ok,error:e.error}))],L=p.trim()||`~`;return(0,W.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-session-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:[(0,W.jsxs)(`form`,{ref:E,onSubmit:P,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,W.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[k&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Host`,"data-testid":`host-select`,children:I.map((e,t)=>{let n=w===e.id,r=!e.ok&&!n;return(0,W.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:()=>T(e.id),onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%I.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+I.length)%I.length;else return;let r=I[n];T(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,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Command preset`,"data-testid":`command-select`,children:F.map((e,t)=>{let n=e.isCustom?M:_===e.id;return(0,W.jsxs)(`button`,{ref:n?O:void 0,type:`button`,role:`radio`,"aria-checked":n,tabIndex:n?0:-1,onClick:()=>{e.isCustom?j():A(e.id)},onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%F.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+F.length)%F.length;else return;let r=F[n];r.isCustom?j():A(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:[(0,W.jsx)(eh,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,W.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{ref:D,value:p,onChange:e=>m(e.target.value),placeholder:N?`/home/user/project`:s||o||r||`/Users/you/code/my-project`,className:`input flex-1 text-sm`}),!N&&(0,W.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>C(!0),children:`Browse`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,W.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,W.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),S&&!N&&(0,W.jsx)(KU,{initialPath:L,onSelect:e=>{m(e),C(!1)},onCancel:()=>C(!1)})]})}function JU({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=x.useRef(e!==void 0),[a,o]=x.useState(t);return[i?e:a,x.useCallback(e=>{i||o(e)},[])]}var YU={};function XU(e,t){let n=x.useRef(YU);return n.current===YU&&(n.current=e(t)),n}var ZU=x[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],QU=ZU&&ZU!==x.useLayoutEffect?ZU:e=>e();function $U(e){let t=XU(eW).current;return t.next=e,QU(t.effect),t.trampoline}function eW(){let e={next:void 0,callback:tW,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function tW(){}function nW(e,t,n,r){let i=XU(iW).current;return aW(i,e,t,n,r)&&sW(i,[e,t,n,r]),i.callback}function rW(e){let t=XU(iW).current;return oW(t,e)&&sW(t,e),t.callback}function iW(){return{callback:null,cleanup:null,refs:[]}}function aW(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function oW(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function sW(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 cW=typeof document<`u`?x.useLayoutEffect:()=>{},lW={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},uW={...lW,position:`fixed`,top:0,left:0},dW={...lW,position:`absolute`};function fW(){}Object.freeze([]);var pW=Object.freeze({});function mW(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 hW=18;function gW(e){return hW>=e}function _W(e){if(!x.isValidElement(e))return null;let t=e,n=t.props;return(gW(19)?n?.ref:t.ref)??null}function vW(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function yW(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 bW(e,t){return typeof e==`function`?e(t):e}function xW(e,t){return typeof e==`function`?e(t):e}var SW={};function CW(e,t,n,r,i){let a={...kW(e,SW)};return t&&(a=TW(a,t)),n&&(a=TW(a,n)),r&&(a=TW(a,r)),i&&(a=TW(a,i)),a}function wW(e){if(e.length===0)return SW;if(e.length===1)return kW(e[0],SW);let t={...kW(e[0],SW)};for(let n=1;n<e.length;n+=1)t=TW(t,e[n]);return t}function TW(e,t){return OW(t)?t(e):EW(e,t)}function EW(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=vW(e.style,r);break;case`className`:e[n]=MW(e.className,r);break;default:DW(n,r)?e[n]=AW(e[n],r):e[n]=r}}return e}function DW(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 OW(e){return typeof e==`function`}function kW(e,t){return OW(e)?e(t):e??SW}function AW(e,t){return t?e?n=>{if(NW(n)){let r=n;jW(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function jW(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function MW(e,t){return t?e?t+` `+e:t:e}function NW(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function PW(e,t,n={}){let r=t.render,i=FW(t,n);return n.enabled===!1?null:LW(e,r,i,n.state??pW)}function FW(e,t={}){let{className:n,style:r,render:i}=e,{state:a=pW,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?bW(n,a):void 0,d=l?xW(r,a):void 0,f=l?yW(a,c):pW,p=l?vW(f,Array.isArray(s)?wW(s):s)??pW:pW;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=rW([p.ref,_W(i),...o]):p.ref=nW(p.ref,_W(i),o):nW(null,null)),l?(u!==void 0&&(p.className=MW(p.className,u)),d!==void 0&&(p.style=vW(p.style,d)),p):pW}var IW=Symbol.for(`react.lazy`);function LW(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=CW(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===IW&&(i=x.Children.toArray(t)[0]),x.cloneElement(i,e)}if(e&&typeof e==`string`)return RW(e,n);throw Error(mW(8))}function RW(e,t){return e===`button`?(0,x.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,x.createElement)(`img`,{alt:``,...t,key:t.key}):x.createElement(e,t)}var zW={...x},BW=0;function VW(e,t=`mui`){let[n,r]=x.useState(e),i=e||n;return x.useEffect(()=>{n??(BW+=1,r(`${t}-${BW}`))},[n,t]),i}var HW=zW.useId;function UW(e,t){if(HW!==void 0){let n=HW();return e??(t?`${t}-${n}`:n)}return VW(e,t)}function WW(e){return UW(e,`base-ui`)}function GW(){return typeof window<`u`}function KW(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function qW(e){return GW()?e instanceof Element||e instanceof KW(e).Element:!1}function JW(e){return GW()?e instanceof HTMLElement||e instanceof KW(e).HTMLElement:!1}function YW(e){return!GW()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof KW(e).ShadowRoot}var XW=x.createContext(void 0);function ZW(e=!1){let t=x.useContext(XW);if(t===void 0&&!e)throw Error(mW(16));return t}function QW(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:x.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 $W(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=x.useRef(null),o=ZW(!0)!==void 0,s=$U(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=QW({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=x.useCallback(()=>{let e=a.current;eG(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return cW(l,[l]),{getButtonProps:x.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return CW({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(jW(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||(jW(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:$U(e=>{a.current=e,l()})}}function eG(e){return JW(e)&&e.tagName===`BUTTON`}var tG=x.createContext(void 0);function nG(){let e=x.useContext(tG);if(e===void 0)throw Error(mW(63));return e}var rG=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}({}),iG={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},aG={valid(e){return e===null?null:e?{[rG.valid]:``}:{[rG.invalid]:``}}},oG=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}({}),sG={...aG,checked(e){return e?{[oG.checked]:``}:{[oG.unchecked]:``}}};function cG(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var lG=x.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:fW,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function uG(){return x.useContext(lG)}var dG=x.createContext({invalid:void 0,name:void 0,validityData:{state:iG,errors:[],error:``,value:``,initialValue:null},setValidityData:fW,disabled:void 0,touched:!1,setTouched:fW,dirty:!1,setDirty:fW,filled:!1,setFilled:fW,focused:!1,setFocused:fW,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=pW)=>e,getInputValidationProps:(e=pW)=>e,inputRef:{current:null},commit:async()=>{}}});function fG(e=!0){let t=x.useContext(dG);if(t.setValidityData===fW&&!e)throw Error(mW(28));return t}function pG(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=uG(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=fG(),f=$U(e.getValue);cW(()=>{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]),cW(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:cG(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?U.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),cW(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var mG=x.createContext({controlId:void 0,registerControlId:fW,labelId:void 0,setLabelId:fW,messageIds:[],setMessageIds:fW,getDescriptionProps:e=>e});function hG(){return x.useContext(mG)}function gG(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=hG(),o=WW(t),s=n?i:void 0,c=XU(()=>Symbol(`labelable-control`)),l=x.useRef(!1),u=x.useRef(t!=null),d=$U(()=>{!l.current||a===fW||(l.current=!1,a(c.current,void 0))});return cW(()=>{if(a===fW)return;let e;if(n){let n=r?.current;e=qW(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]),x.useEffect(()=>d,[d]),i??o}var _G=`none`;function vG(e,t,n,r){let i=!1,a=!1,o=r??pW;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 yG(e,t){let n=x.useRef(e),r=$U(t);cW(()=>{n.current!==e&&r(n.current)},[e,r]),cW(()=>{n.current=e},[e])}var bG=x.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:_}=uG(),{state:v,setTouched:y,setDirty:b,validityData:S,setFilled:C,setFocused:w,shouldValidateOnChange:T,validationMode:E,disabled:D,name:O,validation:k}=fG(),{labelId:A}=hG(),j=D||f,M=O??s,N=$U(l),P=x.useRef(null),F=nW(P,o,k.inputRef),I=x.useRef(null),L=WW(),ee=gG({id:a,implicit:!1,controlRef:I}),R=c?void 0:ee,[z,B]=JU({controlled:n,default:!!i,name:`Switch`,state:`checked`});pG({id:L,commit:k.commit,value:z,controlRef:I,name:M,getValue:()=>z}),cW(()=>{P.current&&C(P.current.checked)},[P,C]),yG(z,()=>{_(M),b(z!==S.initialValue),C(z),T()?k.commit(z):k.commit(z,!0)});let{getButtonProps:te,buttonRef:V}=$W({disabled:j,native:c}),ne={id:c?ee:L,role:`switch`,"aria-checked":z,"aria-readonly":u||void 0,"aria-required":d||void 0,"aria-labelledby":A,onFocus(){j||w(!0)},onBlur(){let e=P.current;!e||j||(y(!0),w(!1),E===`onBlur`&&k.commit(e.checked))},onClick(e){u||j||(e.preventDefault(),P.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},H=x.useMemo(()=>CW({checked:z,disabled:j,id:R,name:M,required:d,style:M?dW:uW,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=vG(_G,e.nativeEvent);N?.(t,n),!n.isCanceled&&B(t)},onFocus(){I.current?.focus()}},k.getInputValidationProps,h===void 0?pW:{value:h}),[z,j,F,R,M,N,d,B,k,h]),re=x.useMemo(()=>({...v,checked:z,disabled:j,readOnly:u,required:d}),[v,z,j,u,d]),U=PW(`span`,e,{state:re,ref:[t,I,V],props:[ne,k.getValidationProps,g,te],stateAttributesMapping:sG});return(0,W.jsxs)(tG.Provider,{value:re,children:[U,!z&&M&&m!==void 0&&(0,W.jsx)(`input`,{type:`hidden`,name:M,value:m}),(0,W.jsx)(`input`,{...H})]})}),xG=x.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=fG(),o=nG();return PW(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:sG,props:i})});function SG(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=SG(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function CG(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=SG(e))&&(r&&(r+=` `),r+=t);return r}var wG=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},TG=(e,t)=>({classGroupId:e,validator:t}),EG=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),DG=`-`,OG=[],kG=`arbitrary..`,AG=e=>{let t=NG(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return MG(e);let n=e.split(DG);return jG(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?wG(i,t):t:i||OG}return n[e]||OG}}},jG=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=jG(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(DG):e.slice(t).join(DG),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},MG=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?kG+r:void 0})(),NG=e=>{let{theme:t,classGroups:n}=e;return PG(n,t)},PG=(e,t)=>{let n=EG();for(let r in e){let i=e[r];FG(i,n,r,t)}return n},FG=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];IG(i,t,n,r)}},IG=(e,t,n,r)=>{if(typeof e==`string`){LG(e,t,n);return}if(typeof e==`function`){RG(e,t,n,r);return}zG(e,t,n,r)},LG=(e,t,n)=>{let r=e===``?t:BG(t,e);r.classGroupId=n},RG=(e,t,n,r)=>{if(VG(e)){FG(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(TG(n,e))},zG=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];FG(o,BG(t,a),n,r)}},BG=(e,t)=>{let n=e,r=t.split(DG),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=EG(),n.nextPart.set(t,i)),n=i}return n},VG=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,HG=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},UG=`!`,WG=`:`,GG=[],KG=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),qG=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===WG){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(UG)?(c=s.slice(0,-1),l=!0):s.startsWith(UG)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return KG(t,l,c,u)};if(t){let e=t+WG,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):KG(GG,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},JG=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},YG=e=>({cache:HG(e.cacheSize),parseClassName:qG(e),sortModifiers:JG(e),...AG(e)}),XG=/\s+/,ZG=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(XG),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+UG:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},QG=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=$G(n))&&(i&&(i+=` `),i+=r);return i},$G=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=$G(e[r]))&&(n&&(n+=` `),n+=t);return n},eK=(e,...t)=>{let n,r,i,a,o=o=>(n=YG(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=ZG(e,n);return i(e,a),a};return a=o,(...e)=>a(QG(...e))},tK=[],nK=e=>{let t=t=>t[e]||tK;return t.isThemeGetter=!0,t},rK=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,iK=/^\((?:(\w[\w-]*):)?(.+)\)$/i,aK=/^\d+\/\d+$/,oK=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sK=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,cK=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,lK=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,uK=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,dK=e=>aK.test(e),fK=e=>!!e&&!Number.isNaN(Number(e)),pK=e=>!!e&&Number.isInteger(Number(e)),mK=e=>e.endsWith(`%`)&&fK(e.slice(0,-1)),hK=e=>oK.test(e),gK=()=>!0,_K=e=>sK.test(e)&&!cK.test(e),vK=()=>!1,yK=e=>lK.test(e),bK=e=>uK.test(e),xK=e=>!Q(e)&&!$(e),SK=e=>PK(e,RK,vK),Q=e=>rK.test(e),CK=e=>PK(e,zK,_K),wK=e=>PK(e,BK,fK),TK=e=>PK(e,IK,vK),EK=e=>PK(e,LK,bK),DK=e=>PK(e,HK,yK),$=e=>iK.test(e),OK=e=>FK(e,zK),kK=e=>FK(e,VK),AK=e=>FK(e,IK),jK=e=>FK(e,RK),MK=e=>FK(e,LK),NK=e=>FK(e,HK,!0),PK=(e,t,n)=>{let r=rK.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},FK=(e,t,n=!1)=>{let r=iK.exec(e);return r?r[1]?t(r[1]):n:!1},IK=e=>e===`position`||e===`percentage`,LK=e=>e===`image`||e===`url`,RK=e=>e===`length`||e===`size`||e===`bg-size`,zK=e=>e===`length`,BK=e=>e===`number`,VK=e=>e===`family-name`,HK=e=>e===`shadow`,UK=eK(()=>{let e=nK(`color`),t=nK(`font`),n=nK(`text`),r=nK(`font-weight`),i=nK(`tracking`),a=nK(`leading`),o=nK(`breakpoint`),s=nK(`container`),c=nK(`spacing`),l=nK(`radius`),u=nK(`shadow`),d=nK(`inset-shadow`),f=nK(`text-shadow`),p=nK(`drop-shadow`),m=nK(`blur`),h=nK(`perspective`),g=nK(`aspect`),_=nK(`ease`),v=nK(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),$,Q],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[$,Q,c],T=()=>[dK,`full`,`auto`,...w()],E=()=>[pK,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,pK,$,Q]},pK,$,Q],O=()=>[pK,`auto`,$,Q],k=()=>[`auto`,`min`,`max`,`fr`,$,Q],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[dK,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,$,Q],F=()=>[...b(),AK,TK,{position:[$,Q]}],I=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],L=()=>[`auto`,`cover`,`contain`,jK,SK,{size:[$,Q]}],ee=()=>[mK,OK,CK],R=()=>[``,`none`,`full`,l,$,Q],z=()=>[``,fK,OK,CK],B=()=>[`solid`,`dashed`,`dotted`,`double`],te=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],V=()=>[fK,mK,AK,TK],ne=()=>[``,`none`,m,$,Q],H=()=>[`none`,fK,$,Q],re=()=>[`none`,fK,$,Q],U=()=>[fK,$,Q],ie=()=>[dK,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[hK],breakpoint:[hK],color:[gK],container:[hK],"drop-shadow":[hK],ease:[`in`,`out`,`in-out`],font:[xK],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[hK],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[hK],shadow:[hK],spacing:[`px`,fK],text:[hK],"text-shadow":[hK],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,dK,Q,$,g]}],container:[`container`],columns:[{columns:[fK,Q,$,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{start:T()}],end:[{end:T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[pK,`auto`,$,Q]}],basis:[{basis:[dK,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[fK,dK,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,fK,$,Q]}],shrink:[{shrink:[``,fK,$,Q]}],order:[{order:[pK,`first`,`last`,`none`,$,Q]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,OK,CK]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,$,wK]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,mK,Q]}],"font-family":[{font:[kK,Q,t]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,$,Q]}],"line-clamp":[{"line-clamp":[fK,`none`,$,wK]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,$,Q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,$,Q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...B(),`wavy`]}],"text-decoration-thickness":[{decoration:[fK,`from-font`,`auto`,$,CK]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[fK,`auto`,$,Q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,$,Q]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,$,Q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:L()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},pK,$,Q],radial:[``,$,Q],conic:[pK,$,Q]},MK,EK]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:ee()}],"gradient-via-pos":[{via:ee()}],"gradient-to-pos":[{to:ee()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:R()}],"rounded-s":[{"rounded-s":R()}],"rounded-e":[{"rounded-e":R()}],"rounded-t":[{"rounded-t":R()}],"rounded-r":[{"rounded-r":R()}],"rounded-b":[{"rounded-b":R()}],"rounded-l":[{"rounded-l":R()}],"rounded-ss":[{"rounded-ss":R()}],"rounded-se":[{"rounded-se":R()}],"rounded-ee":[{"rounded-ee":R()}],"rounded-es":[{"rounded-es":R()}],"rounded-tl":[{"rounded-tl":R()}],"rounded-tr":[{"rounded-tr":R()}],"rounded-br":[{"rounded-br":R()}],"rounded-bl":[{"rounded-bl":R()}],"border-w":[{border:z()}],"border-w-x":[{"border-x":z()}],"border-w-y":[{"border-y":z()}],"border-w-s":[{"border-s":z()}],"border-w-e":[{"border-e":z()}],"border-w-t":[{"border-t":z()}],"border-w-r":[{"border-r":z()}],"border-w-b":[{"border-b":z()}],"border-w-l":[{"border-l":z()}],"divide-x":[{"divide-x":z()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":z()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...B(),`hidden`,`none`]}],"divide-style":[{divide:[...B(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...B(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[fK,$,Q]}],"outline-w":[{outline:[``,fK,OK,CK]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,NK,DK]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,NK,DK]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:z()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[fK,CK]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":z()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,NK,DK]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[fK,$,Q]}],"mix-blend":[{"mix-blend":[...te(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":te()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[fK]}],"mask-image-linear-from-pos":[{"mask-linear-from":V()}],"mask-image-linear-to-pos":[{"mask-linear-to":V()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":V()}],"mask-image-t-to-pos":[{"mask-t-to":V()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":V()}],"mask-image-r-to-pos":[{"mask-r-to":V()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":V()}],"mask-image-b-to-pos":[{"mask-b-to":V()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":V()}],"mask-image-l-to-pos":[{"mask-l-to":V()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":V()}],"mask-image-x-to-pos":[{"mask-x-to":V()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":V()}],"mask-image-y-to-pos":[{"mask-y-to":V()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[$,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":V()}],"mask-image-radial-to-pos":[{"mask-radial-to":V()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[fK]}],"mask-image-conic-from-pos":[{"mask-conic-from":V()}],"mask-image-conic-to-pos":[{"mask-conic-to":V()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,$,Q]}],filter:[{filter:[``,`none`,$,Q]}],blur:[{blur:ne()}],brightness:[{brightness:[fK,$,Q]}],contrast:[{contrast:[fK,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,NK,DK]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,fK,$,Q]}],"hue-rotate":[{"hue-rotate":[fK,$,Q]}],invert:[{invert:[``,fK,$,Q]}],saturate:[{saturate:[fK,$,Q]}],sepia:[{sepia:[``,fK,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[fK,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[fK,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,fK,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[fK,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,fK,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[fK,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[fK,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,fK,$,Q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,$,Q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[fK,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[fK,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:H()}],"rotate-x":[{"rotate-x":H()}],"rotate-y":[{"rotate-y":H()}],"rotate-z":[{"rotate-z":H()}],scale:[{scale:re()}],"scale-x":[{"scale-x":re()}],"scale-y":[{"scale-y":re()}],"scale-z":[{"scale-z":re()}],"scale-3d":[`scale-3d`],skew:[{skew:U()}],"skew-x":[{"skew-x":U()}],"skew-y":[{"skew-y":U()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"translate-none":[`translate-none`],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,$,Q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,$,Q]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[fK,OK,CK,wK]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function WK(...e){return UK(CG(e))}function GK({checked:e,onCheckedChange:t,disabled:n,className:r,ariaLabel:i}){return(0,W.jsx)(bG,{checked:e,onCheckedChange:t,disabled:n,"aria-label":i,className:WK(`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,W.jsx)(xG,{className:WK(`pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform`,`translate-x-1 group-data-[checked]:translate-x-5`)})})}var KK=null,qK=!1,JK={},YK=500;function XK(){if(typeof window>`u`)return null;if(KK?.state===`closed`&&(KK=null),!KK){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;KK=new e}return KK}function ZK(){KK&&=(KK.close().catch(()=>{}),null),XK()}function QK(){return qK}function $K(){KK&&(ZK(),qK=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&$K()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&$K()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&$K(),e=t},5e3)}async function eq(){let e=XK();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),qK=!1}async function tq(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function nq(e){let t=XK();if(!t||(await tq(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 rq(){let e=Date.now();if(!(e-(JK.permission||0)<YK)){JK.permission=e;try{await nq({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function iq(){let e=Date.now();if(!(e-(JK.idle||0)<YK)){JK.idle=e;try{await nq({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function aq({isOpen:e,onClose:t}){let n=H(e=>e.defaultProjectDir),r=H(e=>e.setDefaultProjectDir),i=H(e=>e.commandPresets),a=H(e=>e.setCommandPresets),o=H(e=>e.defaultPresetId),s=H(e=>e.setDefaultPresetId),c=H(e=>e.sessionSortMode),l=H(e=>e.setSessionSortMode),u=H(e=>e.sessionSortDirection),d=H(e=>e.setSessionSortDirection),f=H(e=>e.useWebGL),p=H(e=>e.setUseWebGL),m=H(e=>e.fontSize),h=H(e=>e.setFontSize),g=H(e=>e.lineHeight),_=H(e=>e.setLineHeight),v=H(e=>e.letterSpacing),y=H(e=>e.setLetterSpacing),b=H(e=>e.fontOption),S=H(e=>e.setFontOption),C=H(e=>e.customFontFamily),w=H(e=>e.setCustomFontFamily),T=H(e=>e.shortcutModifier),E=H(e=>e.setShortcutModifier),D=H(e=>e.showProjectName),O=H(e=>e.setShowProjectName),k=H(e=>e.showLastUserMessage),A=H(e=>e.setShowLastUserMessage),j=H(e=>e.showSessionIdPrefix),M=H(e=>e.setShowSessionIdPrefix),N=BH(e=>e.theme),F=BH(e=>e.setTheme),I=H(e=>e.soundOnPermission),ee=H(e=>e.setSoundOnPermission),R=H(e=>e.soundOnIdle),z=H(e=>e.setSoundOnIdle),[B,te]=(0,x.useState)(n),[V,ne]=(0,x.useState)(i),[re,U]=(0,x.useState)(o),[ie,ae]=(0,x.useState)(c),[oe,se]=(0,x.useState)(u),[ce,le]=(0,x.useState)(f),[ue,de]=(0,x.useState)(m),[fe,pe]=(0,x.useState)(g),[me,he]=(0,x.useState)(v),[ge,_e]=(0,x.useState)(b),[ve,ye]=(0,x.useState)(C),[be,xe]=(0,x.useState)(T),[Se,Ce]=(0,x.useState)(D),[we,Te]=(0,x.useState)(k),[Ee,De]=(0,x.useState)(j),[Oe,ke]=(0,x.useState)(N),[Ae,je]=(0,x.useState)(I),[Me,Ne]=(0,x.useState)(R),[Pe,Fe]=(0,x.useState)(!0),[Ie,Le]=(0,x.useState)(!1),[Re,ze]=(0,x.useState)(!0),[Be,Ve]=(0,x.useState)(!0),[He,Ue]=(0,x.useState)(!1),[We,Ge]=(0,x.useState)(!1),[Ke,Je]=(0,x.useState)(24),[Xe,Ze]=(0,x.useState)(!1),[Qe,$e]=(0,x.useState)(!1),[et,tt]=(0,x.useState)(``),[nt,rt]=(0,x.useState)(``),[it,at]=(0,x.useState)(``),ot=(0,x.useRef)(null),st=(0,x.useRef)(0);if((0,x.useEffect)(()=>{let t=++st.current;if(ot.current&&=(clearTimeout(ot.current),null),e){if(te(n),ne(i),U(o),ae(c),se(u),le(f),de(m),pe(g),he(v),_e(b),ye(C),xe(T),Ce(D),Te(k),De(j),ke(N),je(I),Ne(R),$e(!1),tt(``),rt(``),at(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>Fe(e.enabled)).catch(()=>{}),Ve(!0),fetch(`/api/settings/terminal-colors`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{st.current===t&&ze(e.enabled)}).catch(()=>{}).finally(()=>{st.current===t&&Ve(!1)}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>Je(e.hours)).catch(()=>{}),fetch(`/api/settings/prefer-window-name`).then(e=>e.json()).then(e=>Ue(e.enabled)).catch(()=>{}),typeof document<`u`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}}else typeof document<`u`&&(ot.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{ot.current&&=(clearTimeout(ot.current),null)}},[i,o,n,c,u,f,m,g,v,b,C,T,D,k,j,N,I,R,e]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=e=>{e.key===`Escape`&&(typeof e.stopPropagation==`function`&&e.stopPropagation(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let ct=e=>{e.preventDefault();let n=B.trim(),i=ce!==f;r(n||`~/Documents/GitHub`),a(V),s(re),l(ie),d(oe),p(ce),h(ue),_(fe),y(me),S(ge),w(ve),E(be),O(Se),A(we),M(Ee),F(Oe),ee(Ae),z(Me),t({webglChanged:i})},lt=(e,t)=>{ne(n=>n.map(n=>n.id===e?{...n,...t}:n))},ut=e=>{let t=V.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=V.filter(t=>t.id!==e);ne(n),e===re&&U(n[0]?.id||`claude`)},dt=()=>{if(!et.trim()||!nt.trim()||V.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:et.trim(),command:nt.trim(),isBuiltIn:!1,agentType:it||void 0};ne([...V,e]),$e(!1),tt(``),rt(``),at(``)},ft=V.length<50,pt=e=>{Le(!0),Fe(e),fetch(`/api/settings/tmux-mouse-mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Fe(!e)).finally(()=>Le(!1))},mt=e=>{Ge(!0),Ue(e),fetch(`/api/settings/prefer-window-name`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Ue(!e)).finally(()=>Ge(!1))},ht=e=>{Ve(!0),ze(e),fetch(`/api/settings/terminal-colors`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>ze(!e)).finally(()=>Ve(!1))},gt=e=>{let t=Ke;Ze(!0),Je(e),fetch(`/api/settings/history-max-age-hours`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hours:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Je(t)).finally(()=>Ze(!1))};return(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,W.jsxs)(`form`,{onSubmit:ct,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,W.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,W.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,W.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,W.jsx)(`input`,{value:B,onChange:e=>te(e.target.value),placeholder:P,className:`input`,autoFocus:!0})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,W.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,W.jsx)(`select`,{value:re,onChange:e=>U(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:V.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,W.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,W.jsx)(`div`,{className:`space-y-3`,children:V.map(e=>(0,W.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,W.jsx)(`input`,{value:e.label,onChange:t=>lt(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>ut(e.id),className:`btn text-xs px-2 py-1 text-error hover:bg-error/10`,children:`Delete`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,W.jsx)(`input`,{value:e.command,onChange:t=>lt(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,W.jsxs)(`select`,{value:e.agentType||``,onChange:t=>lt(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,W.jsx)(`option`,{value:``,children:`Terminal`}),(0,W.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,W.jsx)(`option`,{value:`codex`,children:`Codex`})]})]})]},e.id))}),Qe?(0,W.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,W.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,W.jsx)(`input`,{value:et,onChange:e=>tt(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,W.jsx)(`input`,{value:nt,onChange:e=>rt(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`select`,{value:it,onChange:e=>at(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,W.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,W.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,W.jsx)(`option`,{value:`codex`,children:`Codex Icon`})]}),(0,W.jsx)(`div`,{className:`flex-1`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>$e(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,onClick:dt,disabled:!et.trim()||!nt.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,W.jsx)(`button`,{type:`button`,onClick:()=>$e(!0),disabled:!ft,className:`btn text-xs mt-3 w-full`,children:ft?`+ Add Preset`:`Max 50 presets`})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`created`?`btn-primary`:``}`,onClick:()=>ae(`created`),children:`Created`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`status`?`btn-primary`:``}`,onClick:()=>ae(`status`),children:`Status`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`manual`?`btn-primary`:``}`,onClick:()=>ae(`manual`),children:`Manual`})]}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:ie===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:ie===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),ie===`created`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`desc`?`btn-primary`:``}`,onClick:()=>se(`desc`),children:`Newest First`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`asc`?`btn-primary`:``}`,onClick:()=>se(`asc`),children:`Oldest First`})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,W.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,W.jsx)(GK,{checked:Se,onCheckedChange:Ce})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,W.jsx)(GK,{checked:we,onCheckedChange:Te})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,W.jsx)(GK,{checked:Ee,onCheckedChange:De})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,W.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`number`,min:1,max:168,value:Ke,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&>(t)},disabled:Xe,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,W.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,W.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>void rq(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,W.jsx)(GK,{checked:Ae,onCheckedChange:e=>{je(e),e&&eq()}})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>void iq(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,W.jsx)(GK,{checked:Me,onCheckedChange:e=>{Ne(e),e&&eq()}})]})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,W.jsx)(GK,{checked:ce,onCheckedChange:le})]}),ce!==f&&(0,W.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,W.jsx)(GK,{checked:Pe,onCheckedChange:pt,disabled:Ie})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Terminal Colors`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Preserve ANSI colors for terminal output. Hibernate then Wake running agents after changing this setting.`})]}),(0,W.jsx)(GK,{checked:Re,onCheckedChange:ht,disabled:Be,ariaLabel:`Enable terminal colors`})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Prefer Window Names`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Label discovered sessions with their tmux window name instead of the session name. Applies immediately.`})]}),(0,W.jsx)(GK,{checked:He,onCheckedChange:mt,disabled:We})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>de(Math.max(6,ue-1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,W.jsx)(`span`,{className:`text-sm font-bold`,children:`−`})}),(0,W.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:ue}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>de(Math.min(24,ue+1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,W.jsx)(`span`,{className:`text-sm font-bold`,children:`+`})})]})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:fe,onChange:e=>pe(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,W.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:fe.toFixed(1)})]})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:me,onChange:e=>he(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,W.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[me,`px`]})]})]}),(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,W.jsx)(`select`,{value:ge,onChange:e=>_e(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:L.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),ge===`custom`&&(0,W.jsx)(`input`,{value:ve,onChange:e=>ye(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,W.jsx)(GK,{checked:Oe===`dark`,onCheckedChange:e=>ke(e?`dark`:`light`)})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,W.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,W.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${be===e?`btn-primary`:``}`,onClick:()=>xe(e),children:e===`auto`?`Auto`:Ye(e)},e))}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:be===`auto`?`Shortcuts: ${Ye(qe(`auto`))}+[1-9/N/X/[/]]`:`Shortcuts: ${Ye(be)}+[1-9/N/X/[/]]`})]})]})}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var oq=[];function sq(e){x.useEffect(e,oq)}var cq=x.createContext(void 0);function lq(){let e=x.useContext(cq);if(!e)throw Error(mW(73));return e}var uq=Symbol(`NOT_FOUND`);function dq(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function fq(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function pq(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 mq=e=>Array.isArray(e)?e:[e];function hq(e){let t=Array.isArray(e[0])?e[0]:e;return pq(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function gq(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function _q(e){let t;return{get(n){return t&&e(t.key,n)?t.value:uq},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function vq(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 uq}function i(t,i){r(t)===uq&&(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 yq=(e,t)=>e===t;function bq(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 xq(e,t){let{equalityCheck:n=yq,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=bq(n),o=0,s=r<=1?_q(a):vq(r,a);function c(){let t=s.get(arguments);if(t===uq){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 Sq=class{constructor(e){this.value=e}deref(){return this.value}},Cq=typeof WeakRef<`u`?WeakRef:Sq,wq=0,Tq=1;function Eq(){return{s:wq,v:void 0,o:null,p:null}}function Dq(e,t={}){let n=Eq(),{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=Eq(),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=Eq(),e.set(n,t)):t=r}}let s=t,c;if(t.s===Tq)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 Cq(c):c}return s.s=Tq,s.v=c,c}return o.clearCache=()=>{n=Eq(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Oq(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()),dq(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=Dq,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=mq(c),p=mq(u),m=hq(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=gq(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 kq=Oq(Dq),Aq=Object.assign((e,t=kq)=>{fq(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:()=>Aq}),jq=Oq({memoize:xq,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),Mq=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(mW(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},Nq=(...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(mW(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(mW(2))}u=jq(...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`)}}},Pq=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})),Fq=s(((e,t)=>{t.exports=Pq()})),Iq=s((e=>{var t=p(),n=Fq();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}})),Lq=s(((e,t)=>{t.exports=Iq()})),Rq=[],zq=void 0;function Bq(){return zq}function Vq(e){Rq.push(e)}var Hq=Fq(),Uq=Lq(),Wq=gW(19)?qq:Jq;function Gq(e,t,n,r,i){return Wq(e,t,n,r,i)}function Kq(e,t,n,r,i){let a=x.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,Hq.useSyncExternalStore)(e.subscribe,a,a)}Vq({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,Hq.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function qq(e,t,n,r,i){let a=Bq();if(!a)return Kq(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 Jq(e,t,n,r,i){return(0,Uq.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var Yq=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 Gq(this,e,t,n,r)}},Xq=class extends Yq{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){x.useDebugValue(e),cW(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;cW(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;cW(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){x.useDebugValue(e);let n=t!==void 0;cW(()=>{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 x.useDebugValue(e),Gq(this,this.selectors[e],t,n,r)}useContextCallback(e,t){x.useDebugValue(e);let n=$U(t??fW);this.context[e]=n}useStateSetter(e){let t=x.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)}})}},Zq=null;globalThis.requestAnimationFrame;var Qq=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)}},$q=class e{static create(){return new e}static request(e){return Qq.request(e)}static cancel(e){return Qq.cancel(e)}currentId=Zq;request(e){this.cancel(),this.currentId=Qq.request(()=>{this.currentId=Zq,e()})}cancel=()=>{this.currentId!==Zq&&(Qq.cancel(this.currentId),this.currentId=Zq)};disposeEffect=()=>this.cancel};function eJ(){let e=XU($q.create).current;return sq(e.disposeEffect),e}var tJ=0,nJ=class e{static create(){return new e}currentId=tJ;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=tJ,t()},e)}isStarted(){return this.currentId!==tJ}clear=()=>{this.currentId!==tJ&&(clearTimeout(this.currentId),this.currentId=tJ)};disposeEffect=()=>this.clear};function rJ(){let e=XU(nJ.create).current;return sq(e.disposeEffect),e}var iJ=0;function aJ(e){return iJ+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${iJ}`}function oJ(e){return e?.ownerDocument||document}function sJ(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 cJ=typeof navigator<`u`,lJ=mJ(),uJ=gJ(),dJ=hJ();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),lJ.platform===`MacIntel`&&lJ.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(lJ.platform),cJ&&/firefox/i.test(dJ);var fJ=cJ&&/apple/i.test(navigator.vendor);cJ&&/Edg/i.test(dJ),cJ&&/android/i.test(uJ)||/android/i.test(dJ),cJ&&uJ.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var pJ=dJ.includes(`jsdom/`);function mJ(){if(!cJ)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 hJ(){if(!cJ)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function gJ(){if(!cJ)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function _J(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function vJ(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&YW(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function yJ(e){return`composedPath`in e?e.composedPath()[0]:e.target}function bJ(e){if(!e||pJ)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var xJ=Nq(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}),SJ={toasts:Mq(e=>e.toasts),isEmpty:Mq(e=>e.toasts.length===0),toast:Mq(xJ,(e,t)=>e.get(t)?.value),toastIndex:Mq(xJ,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:Mq(xJ,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:Mq(xJ,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:Mq(e=>e.hovering),focused:Mq(e=>e.focused),expanded:Mq(e=>e.hovering||e.focused),expandedOrOutOfFocus:Mq(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:Mq(e=>e.prevFocusElement)},CJ=class extends Xq{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},SJ)}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=SJ.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||aJ(`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)),SJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=SJ.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)),SJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{SJ.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=sJ(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=sJ(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=sJ(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??=nJ.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=yJ(e);vJ(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!SJ.expandedOrOutOfFocus(this.state),a=i?nJ.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=_J(oJ(this.state.viewport));if(!this.state.viewport||!vJ(this.state.viewport,t)||!bJ(t))return;let n=SJ.toasts(this.state),r=SJ.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()}},wJ=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=XU(()=>new CJ({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return sq(a.disposeEffect),x.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,W.jsx)(cq.Provider,{value:a,children:t})},TJ=x.forwardRef(function(e,t){let[n,r]=x.useState();cW(()=>{fJ&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,W.jsx)(`span`,{...e,ref:t,style:uW,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),EJ=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),DJ=x.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=lq(),s=rJ(),c=x.useRef(!1),l=x.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=x.useMemo(()=>d.some(e=>e.transitionStatus===`ending`),[d]);x.useEffect(()=>{let e=o.state.viewport;if(!e)return;function t(t){u||t.key===`F6`&&t.target!==e&&(t.preventDefault(),o.setPrevFocusElement(_J(oJ(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=KW(e);return n.addEventListener(`keydown`,t),()=>{n.removeEventListener(`keydown`,t)}},[o,u]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=KW(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=yJ(n),i=_J(oJ(e));(!vJ(e,r)||!bJ(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]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=oJ(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())}x.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 S(){if(c.current){c.current=!1;return}f||bJ(oJ(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function C(e){!f||vJ(o.state.viewport,e.relatedTarget)||(o.setFocused(!1),o.resumeTimers())}let w={tabIndex:-1,role:`region`,"aria-live":`polite`,"aria-atomic":!1,"aria-relevant":`additions text`,"aria-label":`Notifications`,onMouseEnter:y,onMouseMove:y,onMouseLeave:b,onFocus:S,onBlur:C,onKeyDown:v,onClick:S},T={expanded:p},E=PW(`div`,e,{ref:[t,o.setViewport],state:T,props:[w,{style:{[EJ.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,W.jsxs)(x.Fragment,{children:[!u&&m&&(0,W.jsx)(TJ,{onFocus:_}),i,!u&&m&&(0,W.jsx)(TJ,{onFocus:_})]})}]}),D=x.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,W.jsxs)(x.Fragment,{children:[!u&&m&&(0,W.jsx)(TJ,{onFocus:_}),E,!f&&D.length>0&&(0,W.jsx)(`div`,{style:uW,children:D.map(e=>(0,W.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,W.jsx)(`div`,{children:e.title}),(0,W.jsx)(`div`,{children:e.description})]},e.id))})]})});function OJ(e){return gW(19)?e:e?`true`:void 0}var kJ=x.createContext(void 0);function AJ(){let e=x.useContext(kJ);if(!e)throw Error(mW(66));return e}var jJ=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),MJ={[jJ.startingStyle]:``},NJ={[jJ.endingStyle]:``},PJ={transitionStatus(e){return e===`starting`?MJ:e===`ending`?NJ:null}};function FJ(e){return e==null?e:`current`in e?e.current:e}function IJ(e,t=!1,n=!0){let r=eJ();return $U((i,a=null)=>{r.cancel();function o(){U.flushSync(i)}let s=FJ(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=jJ.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 LJ(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=$U(i),o=IJ(r,n,!1);x.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var RJ=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}({}),zJ={...PJ,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},BJ=40,VJ=10,HJ=.5,UJ=1;function WJ(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 GJ(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 KJ=x.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=lq(),[d,f]=x.useState(void 0),[p,m]=x.useState(!1),[h,g]=x.useState(!1),[_,v]=x.useState(!1),[y,b]=x.useState({x:0,y:0}),[S,C]=x.useState({x:0,y:0,scale:1}),[w,T]=x.useState(),[E,D]=x.useState(),[O,k]=x.useState(null),A=x.useRef(null),j=x.useRef({x:0,y:0}),M=x.useRef({x:0,y:0,scale:1}),N=x.useRef(void 0),P=x.useRef(0),F=x.useRef(!1),I=x.useRef({x:0,y:0}),L=x.useRef(!1),ee=u.useState(`toastIndex`,n.id),R=u.useState(`toastVisibleIndex`,n.id),z=u.useState(`toastOffsetY`,n.id),B=u.useState(`focused`),te=u.useState(`expanded`);LJ({open:n.transitionStatus!==`ending`,ref:A,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let V=$U((e=!1)=>{let t=A.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:A,height:i,...n.transitionStatus===`starting`?{transitionStatus:void 0}:{}})}e?U.flushSync(a):a()});cW(V,[V]);function ne(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**HJ:-(Math.abs(e)**HJ):(!c.includes(`right`)&&e>0&&(n=e**HJ),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**HJ))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**HJ:-(Math.abs(t)**HJ):(!c.includes(`down`)&&t>0&&(r=t**HJ),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**HJ))),{x:n,y:r}}function H(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=yJ(e.nativeEvent);if(!(t&&t.closest(`button,a,input,textarea,[role="button"],[data-swipe-ignore]`))){if(F.current=!1,N.current=void 0,P.current=0,j.current={x:e.clientX,y:e.clientY},I.current=j.current,A.current){let e=GJ(A.current);M.current=e,C(e),b({x:e.x,y:e.y})}u.setHovering(!0),m(!0),g(!1),k(null),L.current=!0,A.current?.setPointerCapture(e.pointerId)}}function re(e){if(!p)return;e.preventDefault(),L.current&&=(j.current={x:e.clientX,y:e.clientY},!1);let{clientY:t,clientX:n,movementX:r,movementY:i}=e;(i<0&&t>I.current.y||i>0&&t<I.current.y)&&(I.current={x:I.current.x,y:t}),(r<0&&n>I.current.x||r>0&&n<I.current.x)&&(I.current={x:n,y:I.current.y});let a=n-j.current.x,o=t-j.current.y,s=t-I.current.y,l=n-I.current.x;if(!h&&Math.sqrt(a*a+o*o)>=UJ&&(g(!0),O===null)){let e=c.includes(`left`)||c.includes(`right`),t=c.includes(`up`)||c.includes(`down`);e&&t&&k(Math.abs(a)>Math.abs(o)?`horizontal`:`vertical`)}let u;if(!N.current)O===`vertical`?o>0?u=`down`:o<0&&(u=`up`):O===`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)&&(N.current=u,P.current=WJ(u,a,o),f(u));else{let e=N.current,t=WJ(e,l,s);t>BJ?(F.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&P.current-t>=VJ&&(F.current=!0)}let d=ne(a,o),m=M.current.x,_=M.current.y;O===`horizontal`?(c.includes(`left`)||c.includes(`right`))&&(m+=d.x):(O===`vertical`||(c.includes(`left`)||c.includes(`right`))&&(m+=d.x),(c.includes(`up`)||c.includes(`down`))&&(_+=d.y)),b({x:m,y:_})}function ie(e){if(!p)return;if(m(!1),g(!1),k(null),A.current?.releasePointerCapture(e.pointerId),F.current){b({x:S.x,y:S.y}),f(void 0);return}let t=!1,r=y.x-S.x,i=y.y-S.y,a;for(let e of c){switch(e){case`right`:r>BJ&&(t=!0,a=`right`);break;case`left`:r<-BJ&&(t=!0,a=`left`);break;case`down`:i>BJ&&(t=!0,a=`down`);break;case`up`:i<-BJ&&(t=!0,a=`up`);break;default:break}if(t)break}t?(f(a),v(!0),u.closeToast(n.id)):(b({x:S.x,y:S.y}),f(void 0))}function ae(e){if(e.key===`Escape`){if(!A.current||!vJ(A.current,_J(oJ(A.current))))return;u.closeToast(n.id)}}x.useEffect(()=>{if(!l)return;let e=A.current;if(!e)return;function t(t){vJ(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function oe(){if(!p&&y.x===S.x&&y.y===S.y&&!_)return{[RJ.swipeMovementX]:`0px`,[RJ.swipeMovementY]:`0px`};let e=y.x-S.x,t=y.y-S.y;return{transition:p?`none`:void 0,transform:p?`translateX(${y.x}px) translateY(${y.y}px) scale(${S.scale})`:void 0,[RJ.swipeMovementX]:`${e}px`,[RJ.swipeMovementY]:`${t}px`}}let se=n.priority===`high`,ce={role:se?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":w,"aria-describedby":E,"aria-hidden":se&&!B?!0:void 0,onPointerDown:l?H:void 0,onPointerMove:l?re:void 0,onPointerUp:l?ie:void 0,onKeyDown:ae,inert:OJ(n.limited),style:{...oe(),[RJ.index]:n.transitionStatus===`ending`?ee:R,[RJ.offsetY]:`${z}px`,[RJ.height]:n.height?`${n.height}px`:void 0}},le=x.useMemo(()=>({rootRef:A,toast:n,titleId:w,setTitleId:T,descriptionId:E,setDescriptionId:D,swiping:p,swipeDirection:d,recalculateHeight:V,index:ee,visibleIndex:R,expanded:te}),[n,w,E,p,d,V,ee,R,te]),ue={transitionStatus:n.transitionStatus,expanded:te,limited:n.limited||!1,type:n.type,swiping:le.swiping,swipeDirection:le.swipeDirection},de=PW(`div`,e,{ref:[t,le.rootRef],state:ue,stateAttributesMapping:zJ,props:[ce,o]});return(0,W.jsx)(kJ.Provider,{value:le,children:de})}),qJ=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=AJ(),l=a??s.description,u=!!l,d=UW(i);cW(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=PW(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),JJ=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=AJ(),l=a??s.title,u=!!l,d=UW(i);cW(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=PW(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),YJ=x.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=lq(),{toast:c}=AJ(),l=s.useState(`expanded`),[u,d]=x.useState(!1),{getButtonProps:f,buttonRef:p}=$W({disabled:i,native:a}),m={type:c.type};return PW(`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 XJ(){let e=x.useContext(cq);if(!e)throw Error(mW(73));let t=e.useState(`toasts`);return x.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function ZJ(){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||aJ(`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 QJ=5e3,$J=ZJ();function eY({toast:e}){return(0,W.jsxs)(KJ,{toast:e,className:WK(`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-error/50`,e.type===`success`&&`border-approval/50`,(!e.type||e.type===`info`)&&`border-border`),children:[(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsx)(JJ,{className:WK(`text-sm font-medium`,e.type===`error`&&`text-error`,e.type===`success`&&`text-approval`,(!e.type||e.type===`info`)&&`text-primary`),children:e.title}),e.description&&(0,W.jsx)(qJ,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,W.jsx)(YJ,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,W.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function tY(){let{toasts:e}=XJ();return(0,W.jsx)(W.Fragment,{children:e.map(e=>(0,W.jsx)(eY,{toast:e},e.id))})}function nY(){return(0,W.jsxs)(wJ,{timeout:QJ,toastManager:$J,children:[(0,W.jsx)(tY,{}),(0,W.jsx)(DJ,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var rY=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],iY=3e3,aY=8e3,oY=15e3,sY=5e3,cY=2e4,lY=1e4,uY=1500,dY=5e3,fY=750,pY=4,mY=5e3,hY=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.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{if(J(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,J(`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=>{J(`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?rY[this.ws.readyState]:null,attempt:this.reconnectAttempts,failures:this.consecutiveFailures,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`){J(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){J(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}J(`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`;J(`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?aY:iY;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(J(`ws_connect_timeout`,{wsState:rY[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){J(`ws_onopen_stale`,this.wsSnap(),`info`);return}J(`ws_onopen`,this.wsSnap(),`info`),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=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(),J(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(dY)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(J(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){J(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}J(`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>oY&&(J(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},sY))}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 J(`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(J(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){J(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(J(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},uY)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){J(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){J(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){J(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,J(`ws_force_reconnect`,{trigger:e,force:t,...this.wsSnap()},`info`),this.reconnectAttempts=0,this.consecutiveFailures=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()},fY)):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,J(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},lY)))};e!==void 0&&e<cY?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,cY)},e):this.heartbeatTimer=window.setInterval(t,cY)}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()){J(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=pY){J(`ws_stall_detected`,this.wsSnap(),`info`),this.purgeLeakedSockets(),this.consecutiveFailures=0,this.reconnectAttempts=0,this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},mY);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);J(`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){J(`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 gY(){let e=qm(e=>e.setConnectionState);return(0,x.useEffect)(()=>{hY.connect(),hY.startLifecycleListeners();let t=hY.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),hY.stopLifecycleListeners()}},[e]),{sendMessage:(0,x.useMemo)(()=>e=>{hY.send(e)},[]),subscribe:(0,x.useMemo)(()=>hY.subscribe.bind(hY),[]),getConnectionEpoch:(0,x.useMemo)(()=>()=>hY.getConnectionEpoch(),[])}}var _Y=100;function vY({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>_Y?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function yY(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 bY(){(0,x.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=()=>{vY({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(),yY(document)}},[])}function xY(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 SY(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(void 0),[i,a]=(0,x.useState)(void 0),[o,s]=(0,x.useState)(void 0),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(null),g=qm(e=>e.sessions),_=qm(e=>e.agentSessions),v=qm(e=>e.agentSessionsEpoch),y=qm(e=>e.selectedSessionId),b=qm(e=>e.selectedHibernatingSessionId),S=qm(e=>e.setSessions),C=qm(e=>e.setAgentSessions),w=qm(e=>e.setActiveAgentSessions),T=qm(e=>e.setHostStatuses),E=qm(e=>e.updateSession),D=qm(e=>e.setSelectedSessionId),O=qm(e=>e.setSelectedHibernatingSessionId),k=qm(e=>e.hasLoaded),A=qm(e=>e.connectionStatus),j=qm(e=>e.connectionError),M=qm(e=>e.clearExitingSession),N=qm(e=>e.markSessionExiting),P=qm(e=>e.setRemoteAllowControl),F=qm(e=>e.setRemoteAllowAttach),I=qm(e=>e.setHostLabel),L=qm(e=>e.setPreferWindowName),ee=qm(e=>e.hostStatuses),R=qm(e=>e.remoteAllowControl),z=qm(e=>e.hostLabel),B=BH(e=>e.theme),te=re(),V=H(e=>e.defaultProjectDir),ne=H(e=>e.commandPresets),ie=H(e=>e.defaultPresetId),ae=H(e=>e.lastProjectPath),oe=H(e=>e.setLastProjectPath),se=H(e=>e.addRecentPath),ce=H(e=>e.shortcutModifier),le=H(e=>e.sidebarWidth),ue=H(e=>e.setSidebarWidth),de=H(e=>e.projectFilters),fe=H(e=>e.hostFilters),pe=H(e=>e.soundOnPermission),me=H(e=>e.soundOnIdle),he=qm(e=>e.connectionEpoch),{sendMessage:ge,subscribe:_e,getConnectionEpoch:ve}=gY();bY(),(0,x.useEffect)(()=>{if(typeof document>`u`||!pe&&!me)return;let e=!1,t=()=>{e&&!QK()||(e=!0,eq())};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)}},[pe,me]);let ye=(0,x.useRef)(!1),be=(0,x.useCallback)(e=>{e.preventDefault(),ye.current=!0,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[]);(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=e=>{if(!ye.current)return;let t=e.clientX;ue(Math.max(180,Math.min(400,t)))},t=()=>{ye.current&&(ye.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)}},[ue]),(0,x.useEffect)(()=>{let e=_e(e=>{if(e.type!==`terminal-output`){if(e.type===`sessions`){let t=qm.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=H.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&&rq(),e.status===`working`&&i.status===`waiting`&&r&&iq())}if(Ie.current.size>0){let e=ve();for(let[t,n]of Ie.current)n.epoch!==e&&Ie.current.delete(t)}let i=Ie.current.size>0?e.sessions.filter(e=>!Ie.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=qm.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(Me.current=s),S(i);let c=Ne.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=qm.getState(),{projectFilters:d,hostFilters:f}=H.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&&(Ne.current=null,D(e.id))}}if(e.type===`host-status`&&T(e.hosts),e.type===`server-config`&&(P(e.remoteAllowControl),F(e.remoteAllowAttach),I(e.hostLabel),L(e.preferWindowName),e.clientLogLevel&&QT(e.clientLogLevel)),e.type===`session-update`){let t=qm.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(E(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=H.getState();t!==`permission`&&n===`permission`&&e&&rq(),t===`working`&&n===`waiting`&&r&&iq()}}if(e.type===`session-created`){let t=qm.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id),se(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=H.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){dH(e.sessionId);let t=qm.getState().sessions,n=t.filter(t=>t.id!==e.sessionId);n.length!==t.length&&S(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}=qm.getState(),a=Me.current;i&&!n.some(e=>e.sessionId===i)&&(Ne.current=i),C(t,n,r),h(e=>e&&n.some(t=>t.sessionId===e.sessionId)?null:e),a&&n.some(e=>e.sessionId===a)?(Me.current=null,O(a)):a&&(Me.current=null)}if(e.type===`agent-sessions-active`&&w(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=qm.getState().sessions,n=t.filter(t=>t.agentSessionId?.trim()!==e.session.sessionId);n.length!==t.length&&S(n)}if(e.type===`session-activated`){let t=qm.getState().sessions.find(t=>t.tmuxWindow===e.window);t&&E({...t,agentSessionId:e.session.sessionId,agentSessionName:e.session.displayName,logFilePath:e.session.logFilePath,isPinned:e.session.isPinned,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=qm.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(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),O(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=Ie.current.get(e.sessionId);if(t){let n=qm.getState().sessions;n.some(t=>t.id===e.sessionId)||S([t.session,...n]),t.wasSelected&&D(e.sessionId),Ie.current.delete(e.sessionId)}M(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,se,M,ge,D,O,h,S,C,w,T,P,F,I,L,_e,E]);let xe=(0,x.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),Se=_.hibernating??[],Ce=_.history??[],we=(0,x.useMemo)(()=>xY(Se,de,fe),[Se,de,fe]),Te=(0,x.useMemo)(()=>we.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[we,m,b]);(0,x.useEffect)(()=>{xe?.projectPath&&!xe.remote&&oe(xe.projectPath)},[xe?.projectPath,xe?.remote,oe]);let Ee=H(e=>e.sessionSortMode),De=H(e=>e.sessionSortDirection),Oe=H(e=>e.manualSessionOrder),ke=(0,x.useMemo)(()=>Mm(g,{mode:Ee,direction:De,manualOrder:Oe}),[g,Ee,De,Oe]),Ae=(0,x.useMemo)(()=>{let e=ke;return de.length>0&&(e=e.filter(e=>de.includes(e.projectPath))),fe.length>0&&(e=e.filter(e=>fe.includes(e.host??``))),e},[ke,de,fe]),je=(0,x.useRef)(b),Me=(0,x.useRef)(null),Ne=(0,x.useRef)(null),Pe=(0,x.useRef)(he),Fe=(0,x.useCallback)(()=>Ae.length>0?(D(Ae[0].id),!0):we.length>0?(O(we[0].sessionId),!0):!1,[Ae,we,D,O]);(0,x.useEffect)(()=>{let e=je.current;e&&b===null&&!Se.some(t=>t.sessionId===e)?Ne.current=e:b!==null&&(Ne.current=null),je.current=b},[Se,b]),(0,x.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,x.useEffect)(()=>{Pe.current!==he&&(Pe.current=he,Me.current=null,Ne.current=null,h(null))},[he]),(0,x.useEffect)(()=>{k&&(b||y&&(Ae.some(e=>e.id===y)||Fe()||D(null)))},[k,y,b,Fe,D]),(0,x.useEffect)(()=>{if(!b||m?.sessionId===b||v!==he||we.some(e=>e.sessionId===b))return;let e=Ae.find(e=>e.agentSessionId?.trim()===b);if(e){D(e.id);return}Fe()||O(null)},[we,Ae,v,m,b,Fe,D,O,he]),(0,x.useEffect)(()=>{let e=Ne.current;if(!e)return;if(b!==null){Ne.current=null;return}let t=Ae.find(t=>t.agentSessionId?.trim()===e);if(t){Ne.current=null,D(t.id);return}if(y!==null){Ne.current=null;return}Fe()&&(Ne.current=null)},[Ae,y,b,Fe,D]),(0,x.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&k&&y===null&&b===null&&(Ae.length>0||we.length>0)&&Fe()},[we.length,Ae.length,k,Fe,y,b]);let Ie=(0,x.useRef)(new Map),Le=(0,x.useCallback)((e,t=`unknown`)=>{dH(e);let{sessions:n,selectedSessionId:r}=qm.getState(),i=n.find(t=>t.id===e);i&&Ie.current.set(e,{session:i,wasSelected:r===e,epoch:ve()}),(0,U.flushSync)(()=>{N(e),S(n.filter(t=>t.id!==e))}),ge({type:`session-kill`,sessionId:e,source:t})},[N,S,ge]);(0,x.useEffect)(()=>{let n=qe(ce),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=Xe(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=i===`BracketLeft`?-1:1,t=Ae;if(t.length===0){let t=we;if(t.length===0)return;let n=t.findIndex(e=>e.sessionId===b);if(n===-1){O(t[0].sessionId);return}O(t[(n+e+t.length)%t.length].sessionId);return}let n=t.findIndex(e=>e.id===y);if(n===-1){D(t[0].id);return}D(t[(n+e+t.length)%t.length].id);return}if(a&&/^Digit[1-9]$/.test(i)){let e=Number(i.slice(5))-1;if(Ae.length>0){let t=Ae[e];if(!t)return;r.preventDefault(),D(t.id);return}let t=we[e];if(!t)return;r.preventDefault(),O(t.sessionId);return}if(a&&i===`KeyN`){r.preventDefault(),!e&&te&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Le(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,D,O,Ae,we,Le,ce,te]);let Re=()=>te?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,ze=()=>l(!0),Be=(e,t,n,r)=>{ge({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||oe(e)},Ve=e=>{ge({type:`session-wake`,sessionId:e})},He=(0,x.useCallback)(e=>{ge({type:`session-hibernate`,sessionId:e})},[ge]),Ue=(e,t)=>{ge({type:`session-rename`,sessionId:e,newName:t})},We=(0,x.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&ge({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,ge]),Ge=(0,x.useCallback)(e=>{ge({type:`session-move-to-history`,sessionId:e})},[ge]);(0,x.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,B)},[B]),(0,x.useEffect)(()=>{fetch(`/api/server-info`).then(e=>e.json()).then(e=>p(e)).catch(()=>{})},[]);let Ke=(0,x.useMemo)(()=>z?ee.filter(e=>e.host!==z):ee,[ee,z]);return(0,W.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:le},children:[(0,W.jsx)($e,{connectionStatus:A,onNewSession:Re,onOpenSettings:ze,tailscaleIp:f?.tailscaleIp??null}),(0,W.jsx)(qT,{sessions:g,hibernatingSessions:Se,historySessions:Ce,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:D,onSelectHibernating:O,onRename:Ue,onResume:Ve,onHibernate:He,onKill:Le,onDuplicate:We,onMoveToHistory:Ge,onNewSession:Re,loading:!k,error:j||u})]}),(0,W.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:be}),(0,W.jsx)(GU,{session:xe,sessions:Ae,hibernatingSession:Te,hibernatingSessions:Se,connectionStatus:A,connectionEpoch:he,sendMessage:ge,subscribe:_e,onClose:()=>D(null),onSelectSession:D,onSelectHibernatingSession:O,onNewSession:Re,onKillSession:Le,onRenameSession:Ue,onOpenSettings:ze,onResumeSession:Ve,onHibernateSession:He,onMoveToHistory:Ge,historySessions:Ce,loading:!k,error:j||u}),(0,W.jsx)(qU,{isOpen:e,onClose:()=>t(!1),onCreate:Be,defaultProjectDir:V,commandPresets:ne,defaultPresetId:ie,lastProjectPath:ae,activeProjectPath:xe&&!xe.remote?xe.projectPath:void 0,remoteHosts:Ke,remoteAllowControl:R,initialHost:n,initialPath:i,initialCommand:o}),(0,W.jsx)(aq,{isOpen:c,onClose:()=>l(!1)}),(0,W.jsx)(nY,{})]})}var CY=`modulepreload`,wY=function(e){return`/`+e},TY={},EY=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=wY(t,n),t in TY)return;TY[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`:CY,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)})},DY=`true`,OY=`false`,kY=DY===`true`,AY=OY===`true`;function jY(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,kY||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await EY(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()},!AY)if(kY)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}We()&&document.documentElement.classList.add(`ios`),Ge()&&document.documentElement.classList.add(`ios-pwa`),jY({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var MY=document.getElementById(`root`);if(!MY)throw Error(`Root element not found`);(0,E.createRoot)(MY).render((0,W.jsx)(x.StrictMode,{children:(0,W.jsx)(SY,{})}));
|
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-BwMF3DIa.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-pg4kQMhp.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
|
|
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:"6a4c9160a02f73644d75dabdfa6b039b"},{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-pg4kQMhp.css",revision:null},{url:"assets/index-BwMF3DIa.js",revision:null},{url:"icons/pwa-192x192.png",revision:"affb57c15619ee7223d1adea372ad514"},{url:"icons/pwa-512x512.png",revision:"eb82042b3e4ed505f3efe1b79622d998"},{url:"manifest.webmanifest",revision:"b6d4b3666a548fa0f0c6919d31ec2eee"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"),{denylist:[/^\/api(?:\/|$)/,/^\/ws(?:\/|$)/]}))});
|